const {
  SvelteComponent: eF,
  assign: tF,
  create_slot: iF,
  detach: nF,
  element: rF,
  get_all_dirty_from_scope: oF,
  get_slot_changes: aF,
  get_spread_update: sF,
  init: lF,
  insert: cF,
  safe_not_equal: uF,
  set_dynamic_element_data: RO,
  set_style: qr,
  toggle_class: zs,
  transition_in: n1,
  transition_out: r1,
  update_slot_base: hF
} = window.__gradio__svelte__internal;
function dF(Z) {
  let k, G, $;
  const ce = (
    /*#slots*/
    Z[17].default
  ), le = iF(
    ce,
    Z,
    /*$$scope*/
    Z[16],
    null
  );
  let be = [
    { "data-testid": (
      /*test_id*/
      Z[7]
    ) },
    { id: (
      /*elem_id*/
      Z[2]
    ) },
    {
      class: G = "block " + /*elem_classes*/
      Z[3].join(" ") + " svelte-1t38q2d"
    }
  ], pe = {};
  for (let _ = 0; _ < be.length; _ += 1)
    pe = tF(pe, be[_]);
  return {
    c() {
      k = rF(
        /*tag*/
        Z[14]
      ), le && le.c(), RO(
        /*tag*/
        Z[14]
      )(k, pe), zs(
        k,
        "hidden",
        /*visible*/
        Z[10] === !1
      ), zs(
        k,
        "padded",
        /*padding*/
        Z[6]
      ), zs(
        k,
        "border_focus",
        /*border_mode*/
        Z[5] === "focus"
      ), zs(k, "hide-container", !/*explicit_call*/
      Z[8] && !/*container*/
      Z[9]), qr(k, "height", typeof /*height*/
      Z[0] == "number" ? (
        /*height*/
        Z[0] + "px"
      ) : void 0), qr(k, "width", typeof /*width*/
      Z[1] == "number" ? `calc(min(${/*width*/
      Z[1]}px, 100%))` : void 0), qr(
        k,
        "border-style",
        /*variant*/
        Z[4]
      ), qr(
        k,
        "overflow",
        /*allow_overflow*/
        Z[11] ? "visible" : "hidden"
      ), qr(
        k,
        "flex-grow",
        /*scale*/
        Z[12]
      ), qr(k, "min-width", `calc(min(${/*min_width*/
      Z[13]}px, 100%))`), qr(k, "border-width", "var(--block-border-width)");
    },
    m(_, Ee) {
      cF(_, k, Ee), le && le.m(k, null), $ = !0;
    },
    p(_, Ee) {
      le && le.p && (!$ || Ee & /*$$scope*/
      65536) && hF(
        le,
        ce,
        _,
        /*$$scope*/
        _[16],
        $ ? aF(
          ce,
          /*$$scope*/
          _[16],
          Ee,
          null
        ) : oF(
          /*$$scope*/
          _[16]
        ),
        null
      ), RO(
        /*tag*/
        _[14]
      )(k, pe = sF(be, [
        (!$ || Ee & /*test_id*/
        128) && { "data-testid": (
          /*test_id*/
          _[7]
        ) },
        (!$ || Ee & /*elem_id*/
        4) && { id: (
          /*elem_id*/
          _[2]
        ) },
        (!$ || Ee & /*elem_classes*/
        8 && G !== (G = "block " + /*elem_classes*/
        _[3].join(" ") + " svelte-1t38q2d")) && { class: G }
      ])), zs(
        k,
        "hidden",
        /*visible*/
        _[10] === !1
      ), zs(
        k,
        "padded",
        /*padding*/
        _[6]
      ), zs(
        k,
        "border_focus",
        /*border_mode*/
        _[5] === "focus"
      ), zs(k, "hide-container", !/*explicit_call*/
      _[8] && !/*container*/
      _[9]), Ee & /*height*/
      1 && qr(k, "height", typeof /*height*/
      _[0] == "number" ? (
        /*height*/
        _[0] + "px"
      ) : void 0), Ee & /*width*/
      2 && qr(k, "width", typeof /*width*/
      _[1] == "number" ? `calc(min(${/*width*/
      _[1]}px, 100%))` : void 0), Ee & /*variant*/
      16 && qr(
        k,
        "border-style",
        /*variant*/
        _[4]
      ), Ee & /*allow_overflow*/
      2048 && qr(
        k,
        "overflow",
        /*allow_overflow*/
        _[11] ? "visible" : "hidden"
      ), Ee & /*scale*/
      4096 && qr(
        k,
        "flex-grow",
        /*scale*/
        _[12]
      ), Ee & /*min_width*/
      8192 && qr(k, "min-width", `calc(min(${/*min_width*/
      _[13]}px, 100%))`);
    },
    i(_) {
      $ || (n1(le, _), $ = !0);
    },
    o(_) {
      r1(le, _), $ = !1;
    },
    d(_) {
      _ && nF(k), le && le.d(_);
    }
  };
}
function pF(Z) {
  let k, G = (
    /*tag*/
    Z[14] && dF(Z)
  );
  return {
    c() {
      G && G.c();
    },
    m($, ce) {
      G && G.m($, ce), k = !0;
    },
    p($, [ce]) {
      /*tag*/
      $[14] && G.p($, ce);
    },
    i($) {
      k || (n1(G, $), k = !0);
    },
    o($) {
      r1(G, $), k = !1;
    },
    d($) {
      G && G.d($);
    }
  };
}
function fF(Z, k, G) {
  let { $$slots: $ = {}, $$scope: ce } = k, { height: le = void 0 } = k, { width: be = void 0 } = k, { elem_id: pe = "" } = k, { elem_classes: _ = [] } = k, { variant: Ee = "solid" } = k, { border_mode: Xe = "base" } = k, { padding: yt = !0 } = k, { type: H = "normal" } = k, { test_id: ue = void 0 } = k, { explicit_call: ct = !1 } = k, { container: Ht = !0 } = k, { visible: gt = !0 } = k, { allow_overflow: Ge = !0 } = k, { scale: pt = null } = k, { min_width: Ve = 0 } = k, ot = H === "fieldset" ? "fieldset" : "div";
  return Z.$$set = (ft) => {
    "height" in ft && G(0, le = ft.height), "width" in ft && G(1, be = ft.width), "elem_id" in ft && G(2, pe = ft.elem_id), "elem_classes" in ft && G(3, _ = ft.elem_classes), "variant" in ft && G(4, Ee = ft.variant), "border_mode" in ft && G(5, Xe = ft.border_mode), "padding" in ft && G(6, yt = ft.padding), "type" in ft && G(15, H = ft.type), "test_id" in ft && G(7, ue = ft.test_id), "explicit_call" in ft && G(8, ct = ft.explicit_call), "container" in ft && G(9, Ht = ft.container), "visible" in ft && G(10, gt = ft.visible), "allow_overflow" in ft && G(11, Ge = ft.allow_overflow), "scale" in ft && G(12, pt = ft.scale), "min_width" in ft && G(13, Ve = ft.min_width), "$$scope" in ft && G(16, ce = ft.$$scope);
  }, [
    le,
    be,
    pe,
    _,
    Ee,
    Xe,
    yt,
    ue,
    ct,
    Ht,
    gt,
    Ge,
    pt,
    Ve,
    ot,
    H,
    ce,
    $
  ];
}
class _F extends eF {
  constructor(k) {
    super(), lF(this, k, fF, pF, uF, {
      height: 0,
      width: 1,
      elem_id: 2,
      elem_classes: 3,
      variant: 4,
      border_mode: 5,
      padding: 6,
      type: 15,
      test_id: 7,
      explicit_call: 8,
      container: 9,
      visible: 10,
      allow_overflow: 11,
      scale: 12,
      min_width: 13
    });
  }
}
const {
  SvelteComponent: mF,
  attr: gF,
  create_slot: vF,
  detach: yF,
  element: bF,
  get_all_dirty_from_scope: TF,
  get_slot_changes: EF,
  init: SF,
  insert: xF,
  safe_not_equal: AF,
  transition_in: RF,
  transition_out: CF,
  update_slot_base: PF
} = window.__gradio__svelte__internal;
function IF(Z) {
  let k, G;
  const $ = (
    /*#slots*/
    Z[1].default
  ), ce = vF(
    $,
    Z,
    /*$$scope*/
    Z[0],
    null
  );
  return {
    c() {
      k = bF("div"), ce && ce.c(), gF(k, "class", "svelte-1hnfib2");
    },
    m(le, be) {
      xF(le, k, be), ce && ce.m(k, null), G = !0;
    },
    p(le, [be]) {
      ce && ce.p && (!G || be & /*$$scope*/
      1) && PF(
        ce,
        $,
        le,
        /*$$scope*/
        le[0],
        G ? EF(
          $,
          /*$$scope*/
          le[0],
          be,
          null
        ) : TF(
          /*$$scope*/
          le[0]
        ),
        null
      );
    },
    i(le) {
      G || (RF(ce, le), G = !0);
    },
    o(le) {
      CF(ce, le), G = !1;
    },
    d(le) {
      le && yF(k), ce && ce.d(le);
    }
  };
}
function MF(Z, k, G) {
  let { $$slots: $ = {}, $$scope: ce } = k;
  return Z.$$set = (le) => {
    "$$scope" in le && G(0, ce = le.$$scope);
  }, [ce, $];
}
class OF extends mF {
  constructor(k) {
    super(), SF(this, k, MF, IF, AF, {});
  }
}
const {
  SvelteComponent: DF,
  attr: CO,
  check_outros: NF,
  create_component: FF,
  create_slot: LF,
  destroy_component: wF,
  detach: Nm,
  element: BF,
  empty: UF,
  get_all_dirty_from_scope: VF,
  get_slot_changes: kF,
  group_outros: GF,
  init: zF,
  insert: Fm,
  mount_component: WF,
  safe_not_equal: HF,
  set_data: XF,
  space: jF,
  text: YF,
  toggle_class: bu,
  transition_in: Yd,
  transition_out: Lm,
  update_slot_base: KF
} = window.__gradio__svelte__internal;
function PO(Z) {
  let k, G;
  return k = new OF({
    props: {
      $$slots: { default: [qF] },
      $$scope: { ctx: Z }
    }
  }), {
    c() {
      FF(k.$$.fragment);
    },
    m($, ce) {
      WF(k, $, ce), G = !0;
    },
    p($, ce) {
      const le = {};
      ce & /*$$scope, info*/
      10 && (le.$$scope = { dirty: ce, ctx: $ }), k.$set(le);
    },
    i($) {
      G || (Yd(k.$$.fragment, $), G = !0);
    },
    o($) {
      Lm(k.$$.fragment, $), G = !1;
    },
    d($) {
      wF(k, $);
    }
  };
}
function qF(Z) {
  let k;
  return {
    c() {
      k = YF(
        /*info*/
        Z[1]
      );
    },
    m(G, $) {
      Fm(G, k, $);
    },
    p(G, $) {
      $ & /*info*/
      2 && XF(
        k,
        /*info*/
        G[1]
      );
    },
    d(G) {
      G && Nm(k);
    }
  };
}
function QF(Z) {
  let k, G, $, ce;
  const le = (
    /*#slots*/
    Z[2].default
  ), be = LF(
    le,
    Z,
    /*$$scope*/
    Z[3],
    null
  );
  let pe = (
    /*info*/
    Z[1] && PO(Z)
  );
  return {
    c() {
      k = BF("span"), be && be.c(), G = jF(), pe && pe.c(), $ = UF(), CO(k, "data-testid", "block-info"), CO(k, "class", "svelte-22c38v"), bu(k, "sr-only", !/*show_label*/
      Z[0]), bu(k, "hide", !/*show_label*/
      Z[0]), bu(
        k,
        "has-info",
        /*info*/
        Z[1] != null
      );
    },
    m(_, Ee) {
      Fm(_, k, Ee), be && be.m(k, null), Fm(_, G, Ee), pe && pe.m(_, Ee), Fm(_, $, Ee), ce = !0;
    },
    p(_, [Ee]) {
      be && be.p && (!ce || Ee & /*$$scope*/
      8) && KF(
        be,
        le,
        _,
        /*$$scope*/
        _[3],
        ce ? kF(
          le,
          /*$$scope*/
          _[3],
          Ee,
          null
        ) : VF(
          /*$$scope*/
          _[3]
        ),
        null
      ), (!ce || Ee & /*show_label*/
      1) && bu(k, "sr-only", !/*show_label*/
      _[0]), (!ce || Ee & /*show_label*/
      1) && bu(k, "hide", !/*show_label*/
      _[0]), (!ce || Ee & /*info*/
      2) && bu(
        k,
        "has-info",
        /*info*/
        _[1] != null
      ), /*info*/
      _[1] ? pe ? (pe.p(_, Ee), Ee & /*info*/
      2 && Yd(pe, 1)) : (pe = PO(_), pe.c(), Yd(pe, 1), pe.m($.parentNode, $)) : pe && (GF(), Lm(pe, 1, 1, () => {
        pe = null;
      }), NF());
    },
    i(_) {
      ce || (Yd(be, _), Yd(pe), ce = !0);
    },
    o(_) {
      Lm(be, _), Lm(pe), ce = !1;
    },
    d(_) {
      _ && (Nm(k), Nm(G), Nm($)), be && be.d(_), pe && pe.d(_);
    }
  };
}
function ZF(Z, k, G) {
  let { $$slots: $ = {}, $$scope: ce } = k, { show_label: le = !0 } = k, { info: be = void 0 } = k;
  return Z.$$set = (pe) => {
    "show_label" in pe && G(0, le = pe.show_label), "info" in pe && G(1, be = pe.info), "$$scope" in pe && G(3, ce = pe.$$scope);
  }, [le, be, $, ce];
}
class JF extends DF {
  constructor(k) {
    super(), zF(this, k, ZF, QF, HF, { show_label: 0, info: 1 });
  }
}
const $F = [
  { color: "red", primary: 600, secondary: 100 },
  { color: "green", primary: 600, secondary: 100 },
  { color: "blue", primary: 600, secondary: 100 },
  { color: "yellow", primary: 500, secondary: 100 },
  { color: "purple", primary: 600, secondary: 100 },
  { color: "teal", primary: 600, secondary: 100 },
  { color: "orange", primary: 600, secondary: 100 },
  { color: "cyan", primary: 600, secondary: 100 },
  { color: "lime", primary: 500, secondary: 100 },
  { color: "pink", primary: 600, secondary: 100 }
], IO = {
  inherit: "inherit",
  current: "currentColor",
  transparent: "transparent",
  black: "#000",
  white: "#fff",
  slate: {
    50: "#f8fafc",
    100: "#f1f5f9",
    200: "#e2e8f0",
    300: "#cbd5e1",
    400: "#94a3b8",
    500: "#64748b",
    600: "#475569",
    700: "#334155",
    800: "#1e293b",
    900: "#0f172a",
    950: "#020617"
  },
  gray: {
    50: "#f9fafb",
    100: "#f3f4f6",
    200: "#e5e7eb",
    300: "#d1d5db",
    400: "#9ca3af",
    500: "#6b7280",
    600: "#4b5563",
    700: "#374151",
    800: "#1f2937",
    900: "#111827",
    950: "#030712"
  },
  zinc: {
    50: "#fafafa",
    100: "#f4f4f5",
    200: "#e4e4e7",
    300: "#d4d4d8",
    400: "#a1a1aa",
    500: "#71717a",
    600: "#52525b",
    700: "#3f3f46",
    800: "#27272a",
    900: "#18181b",
    950: "#09090b"
  },
  neutral: {
    50: "#fafafa",
    100: "#f5f5f5",
    200: "#e5e5e5",
    300: "#d4d4d4",
    400: "#a3a3a3",
    500: "#737373",
    600: "#525252",
    700: "#404040",
    800: "#262626",
    900: "#171717",
    950: "#0a0a0a"
  },
  stone: {
    50: "#fafaf9",
    100: "#f5f5f4",
    200: "#e7e5e4",
    300: "#d6d3d1",
    400: "#a8a29e",
    500: "#78716c",
    600: "#57534e",
    700: "#44403c",
    800: "#292524",
    900: "#1c1917",
    950: "#0c0a09"
  },
  red: {
    50: "#fef2f2",
    100: "#fee2e2",
    200: "#fecaca",
    300: "#fca5a5",
    400: "#f87171",
    500: "#ef4444",
    600: "#dc2626",
    700: "#b91c1c",
    800: "#991b1b",
    900: "#7f1d1d",
    950: "#450a0a"
  },
  orange: {
    50: "#fff7ed",
    100: "#ffedd5",
    200: "#fed7aa",
    300: "#fdba74",
    400: "#fb923c",
    500: "#f97316",
    600: "#ea580c",
    700: "#c2410c",
    800: "#9a3412",
    900: "#7c2d12",
    950: "#431407"
  },
  amber: {
    50: "#fffbeb",
    100: "#fef3c7",
    200: "#fde68a",
    300: "#fcd34d",
    400: "#fbbf24",
    500: "#f59e0b",
    600: "#d97706",
    700: "#b45309",
    800: "#92400e",
    900: "#78350f",
    950: "#451a03"
  },
  yellow: {
    50: "#fefce8",
    100: "#fef9c3",
    200: "#fef08a",
    300: "#fde047",
    400: "#facc15",
    500: "#eab308",
    600: "#ca8a04",
    700: "#a16207",
    800: "#854d0e",
    900: "#713f12",
    950: "#422006"
  },
  lime: {
    50: "#f7fee7",
    100: "#ecfccb",
    200: "#d9f99d",
    300: "#bef264",
    400: "#a3e635",
    500: "#84cc16",
    600: "#65a30d",
    700: "#4d7c0f",
    800: "#3f6212",
    900: "#365314",
    950: "#1a2e05"
  },
  green: {
    50: "#f0fdf4",
    100: "#dcfce7",
    200: "#bbf7d0",
    300: "#86efac",
    400: "#4ade80",
    500: "#22c55e",
    600: "#16a34a",
    700: "#15803d",
    800: "#166534",
    900: "#14532d",
    950: "#052e16"
  },
  emerald: {
    50: "#ecfdf5",
    100: "#d1fae5",
    200: "#a7f3d0",
    300: "#6ee7b7",
    400: "#34d399",
    500: "#10b981",
    600: "#059669",
    700: "#047857",
    800: "#065f46",
    900: "#064e3b",
    950: "#022c22"
  },
  teal: {
    50: "#f0fdfa",
    100: "#ccfbf1",
    200: "#99f6e4",
    300: "#5eead4",
    400: "#2dd4bf",
    500: "#14b8a6",
    600: "#0d9488",
    700: "#0f766e",
    800: "#115e59",
    900: "#134e4a",
    950: "#042f2e"
  },
  cyan: {
    50: "#ecfeff",
    100: "#cffafe",
    200: "#a5f3fc",
    300: "#67e8f9",
    400: "#22d3ee",
    500: "#06b6d4",
    600: "#0891b2",
    700: "#0e7490",
    800: "#155e75",
    900: "#164e63",
    950: "#083344"
  },
  sky: {
    50: "#f0f9ff",
    100: "#e0f2fe",
    200: "#bae6fd",
    300: "#7dd3fc",
    400: "#38bdf8",
    500: "#0ea5e9",
    600: "#0284c7",
    700: "#0369a1",
    800: "#075985",
    900: "#0c4a6e",
    950: "#082f49"
  },
  blue: {
    50: "#eff6ff",
    100: "#dbeafe",
    200: "#bfdbfe",
    300: "#93c5fd",
    400: "#60a5fa",
    500: "#3b82f6",
    600: "#2563eb",
    700: "#1d4ed8",
    800: "#1e40af",
    900: "#1e3a8a",
    950: "#172554"
  },
  indigo: {
    50: "#eef2ff",
    100: "#e0e7ff",
    200: "#c7d2fe",
    300: "#a5b4fc",
    400: "#818cf8",
    500: "#6366f1",
    600: "#4f46e5",
    700: "#4338ca",
    800: "#3730a3",
    900: "#312e81",
    950: "#1e1b4b"
  },
  violet: {
    50: "#f5f3ff",
    100: "#ede9fe",
    200: "#ddd6fe",
    300: "#c4b5fd",
    400: "#a78bfa",
    500: "#8b5cf6",
    600: "#7c3aed",
    700: "#6d28d9",
    800: "#5b21b6",
    900: "#4c1d95",
    950: "#2e1065"
  },
  purple: {
    50: "#faf5ff",
    100: "#f3e8ff",
    200: "#e9d5ff",
    300: "#d8b4fe",
    400: "#c084fc",
    500: "#a855f7",
    600: "#9333ea",
    700: "#7e22ce",
    800: "#6b21a8",
    900: "#581c87",
    950: "#3b0764"
  },
  fuchsia: {
    50: "#fdf4ff",
    100: "#fae8ff",
    200: "#f5d0fe",
    300: "#f0abfc",
    400: "#e879f9",
    500: "#d946ef",
    600: "#c026d3",
    700: "#a21caf",
    800: "#86198f",
    900: "#701a75",
    950: "#4a044e"
  },
  pink: {
    50: "#fdf2f8",
    100: "#fce7f3",
    200: "#fbcfe8",
    300: "#f9a8d4",
    400: "#f472b6",
    500: "#ec4899",
    600: "#db2777",
    700: "#be185d",
    800: "#9d174d",
    900: "#831843",
    950: "#500724"
  },
  rose: {
    50: "#fff1f2",
    100: "#ffe4e6",
    200: "#fecdd3",
    300: "#fda4af",
    400: "#fb7185",
    500: "#f43f5e",
    600: "#e11d48",
    700: "#be123c",
    800: "#9f1239",
    900: "#881337",
    950: "#4c0519"
  }
};
$F.reduce(
  (Z, { color: k, primary: G, secondary: $ }) => ({
    ...Z,
    [k]: {
      primary: IO[k][G],
      secondary: IO[k][$]
    }
  }),
  {}
);
function Eu(Z) {
  let k = ["", "k", "M", "G", "T", "P", "E", "Z"], G = 0;
  for (; Z > 1e3 && G < k.length - 1; )
    Z /= 1e3, G++;
  let $ = k[G];
  return (Number.isInteger(Z) ? Z : Z.toFixed(1)) + $;
}
function wm() {
}
function eL(Z, k) {
  return Z != Z ? k == k : Z !== k || Z && typeof Z == "object" || typeof Z == "function";
}
const o1 = typeof window < "u";
let MO = o1 ? () => window.performance.now() : () => Date.now(), a1 = o1 ? (Z) => requestAnimationFrame(Z) : wm;
const xu = /* @__PURE__ */ new Set();
function s1(Z) {
  xu.forEach((k) => {
    k.c(Z) || (xu.delete(k), k.f());
  }), xu.size !== 0 && a1(s1);
}
function tL(Z) {
  let k;
  return xu.size === 0 && a1(s1), {
    promise: new Promise((G) => {
      xu.add(k = { c: Z, f: G });
    }),
    abort() {
      xu.delete(k);
    }
  };
}
const Tu = [];
function iL(Z, k = wm) {
  let G;
  const $ = /* @__PURE__ */ new Set();
  function ce(pe) {
    if (eL(Z, pe) && (Z = pe, G)) {
      const _ = !Tu.length;
      for (const Ee of $)
        Ee[1](), Tu.push(Ee, Z);
      if (_) {
        for (let Ee = 0; Ee < Tu.length; Ee += 2)
          Tu[Ee][0](Tu[Ee + 1]);
        Tu.length = 0;
      }
    }
  }
  function le(pe) {
    ce(pe(Z));
  }
  function be(pe, _ = wm) {
    const Ee = [pe, _];
    return $.add(Ee), $.size === 1 && (G = k(ce, le) || wm), pe(Z), () => {
      $.delete(Ee), $.size === 0 && G && (G(), G = null);
    };
  }
  return { set: ce, update: le, subscribe: be };
}
function OO(Z) {
  return Object.prototype.toString.call(Z) === "[object Date]";
}
function DA(Z, k, G, $) {
  if (typeof G == "number" || OO(G)) {
    const ce = $ - G, le = (G - k) / (Z.dt || 1 / 60), be = Z.opts.stiffness * ce, pe = Z.opts.damping * le, _ = (be - pe) * Z.inv_mass, Ee = (le + _) * Z.dt;
    return Math.abs(Ee) < Z.opts.precision && Math.abs(ce) < Z.opts.precision ? $ : (Z.settled = !1, OO(G) ? new Date(G.getTime() + Ee) : G + Ee);
  } else {
    if (Array.isArray(G))
      return G.map(
        (ce, le) => DA(Z, k[le], G[le], $[le])
      );
    if (typeof G == "object") {
      const ce = {};
      for (const le in G)
        ce[le] = DA(Z, k[le], G[le], $[le]);
      return ce;
    } else
      throw new Error(`Cannot spring ${typeof G} values`);
  }
}
function DO(Z, k = {}) {
  const G = iL(Z), { stiffness: $ = 0.15, damping: ce = 0.8, precision: le = 0.01 } = k;
  let be, pe, _, Ee = Z, Xe = Z, yt = 1, H = 0, ue = !1;
  function ct(gt, Ge = {}) {
    Xe = gt;
    const pt = _ = {};
    return Z == null || Ge.hard || Ht.stiffness >= 1 && Ht.damping >= 1 ? (ue = !0, be = MO(), Ee = gt, G.set(Z = Xe), Promise.resolve()) : (Ge.soft && (H = 1 / ((Ge.soft === !0 ? 0.5 : +Ge.soft) * 60), yt = 0), pe || (be = MO(), ue = !1, pe = tL((Ve) => {
      if (ue)
        return ue = !1, pe = null, !1;
      yt = Math.min(yt + H, 1);
      const ot = {
        inv_mass: yt,
        opts: Ht,
        settled: !0,
        dt: (Ve - be) * 60 / 1e3
      }, ft = DA(ot, Ee, Z, Xe);
      return be = Ve, Ee = Z, G.set(Z = ft), ot.settled && (pe = null), !ot.settled;
    })), new Promise((Ve) => {
      pe.promise.then(() => {
        pt === _ && Ve();
      });
    }));
  }
  const Ht = {
    set: ct,
    update: (gt, Ge) => ct(gt(Xe, Z), Ge),
    subscribe: G.subscribe,
    stiffness: $,
    damping: ce,
    precision: le
  };
  return Ht;
}
const {
  SvelteComponent: nL,
  append: Ko,
  attr: _i,
  component_subscribe: NO,
  detach: rL,
  element: oL,
  init: aL,
  insert: sL,
  noop: FO,
  safe_not_equal: lL,
  set_style: Om,
  svg_element: qo,
  toggle_class: LO
} = window.__gradio__svelte__internal, { onMount: cL } = window.__gradio__svelte__internal;
function uL(Z) {
  let k, G, $, ce, le, be, pe, _, Ee, Xe, yt, H;
  return {
    c() {
      k = oL("div"), G = qo("svg"), $ = qo("g"), ce = qo("path"), le = qo("path"), be = qo("path"), pe = qo("path"), _ = qo("g"), Ee = qo("path"), Xe = qo("path"), yt = qo("path"), H = qo("path"), _i(ce, "d", "M255.926 0.754768L509.702 139.936V221.027L255.926 81.8465V0.754768Z"), _i(ce, "fill", "#FF7C00"), _i(ce, "fill-opacity", "0.4"), _i(ce, "class", "svelte-43sxxs"), _i(le, "d", "M509.69 139.936L254.981 279.641V361.255L509.69 221.55V139.936Z"), _i(le, "fill", "#FF7C00"), _i(le, "class", "svelte-43sxxs"), _i(be, "d", "M0.250138 139.937L254.981 279.641V361.255L0.250138 221.55V139.937Z"), _i(be, "fill", "#FF7C00"), _i(be, "fill-opacity", "0.4"), _i(be, "class", "svelte-43sxxs"), _i(pe, "d", "M255.923 0.232622L0.236328 139.936V221.55L255.923 81.8469V0.232622Z"), _i(pe, "fill", "#FF7C00"), _i(pe, "class", "svelte-43sxxs"), Om($, "transform", "translate(" + /*$top*/
      Z[1][0] + "px, " + /*$top*/
      Z[1][1] + "px)"), _i(Ee, "d", "M255.926 141.5L509.702 280.681V361.773L255.926 222.592V141.5Z"), _i(Ee, "fill", "#FF7C00"), _i(Ee, "fill-opacity", "0.4"), _i(Ee, "class", "svelte-43sxxs"), _i(Xe, "d", "M509.69 280.679L254.981 420.384V501.998L509.69 362.293V280.679Z"), _i(Xe, "fill", "#FF7C00"), _i(Xe, "class", "svelte-43sxxs"), _i(yt, "d", "M0.250138 280.681L254.981 420.386V502L0.250138 362.295V280.681Z"), _i(yt, "fill", "#FF7C00"), _i(yt, "fill-opacity", "0.4"), _i(yt, "class", "svelte-43sxxs"), _i(H, "d", "M255.923 140.977L0.236328 280.68V362.294L255.923 222.591V140.977Z"), _i(H, "fill", "#FF7C00"), _i(H, "class", "svelte-43sxxs"), Om(_, "transform", "translate(" + /*$bottom*/
      Z[2][0] + "px, " + /*$bottom*/
      Z[2][1] + "px)"), _i(G, "viewBox", "-1200 -1200 3000 3000"), _i(G, "fill", "none"), _i(G, "xmlns", "http://www.w3.org/2000/svg"), _i(G, "class", "svelte-43sxxs"), _i(k, "class", "svelte-43sxxs"), LO(
        k,
        "margin",
        /*margin*/
        Z[0]
      );
    },
    m(ue, ct) {
      sL(ue, k, ct), Ko(k, G), Ko(G, $), Ko($, ce), Ko($, le), Ko($, be), Ko($, pe), Ko(G, _), Ko(_, Ee), Ko(_, Xe), Ko(_, yt), Ko(_, H);
    },
    p(ue, [ct]) {
      ct & /*$top*/
      2 && Om($, "transform", "translate(" + /*$top*/
      ue[1][0] + "px, " + /*$top*/
      ue[1][1] + "px)"), ct & /*$bottom*/
      4 && Om(_, "transform", "translate(" + /*$bottom*/
      ue[2][0] + "px, " + /*$bottom*/
      ue[2][1] + "px)"), ct & /*margin*/
      1 && LO(
        k,
        "margin",
        /*margin*/
        ue[0]
      );
    },
    i: FO,
    o: FO,
    d(ue) {
      ue && rL(k);
    }
  };
}
function hL(Z, k, G) {
  let $, ce, { margin: le = !0 } = k;
  const be = DO([0, 0]);
  NO(Z, be, (H) => G(1, $ = H));
  const pe = DO([0, 0]);
  NO(Z, pe, (H) => G(2, ce = H));
  let _;
  async function Ee() {
    await Promise.all([be.set([125, 140]), pe.set([-125, -140])]), await Promise.all([be.set([-125, 140]), pe.set([125, -140])]), await Promise.all([be.set([-125, 0]), pe.set([125, -0])]), await Promise.all([be.set([125, 0]), pe.set([-125, 0])]);
  }
  async function Xe() {
    await Ee(), _ || Xe();
  }
  async function yt() {
    await Promise.all([be.set([125, 0]), pe.set([-125, 0])]), Xe();
  }
  return cL(() => (yt(), () => _ = !0)), Z.$$set = (H) => {
    "margin" in H && G(0, le = H.margin);
  }, [le, $, ce, be, pe];
}
class dL extends nL {
  constructor(k) {
    super(), aL(this, k, hL, uL, lL, { margin: 0 });
  }
}
const {
  SvelteComponent: pL,
  append: Ul,
  attr: Na,
  binding_callbacks: wO,
  check_outros: l1,
  create_component: fL,
  create_slot: _L,
  destroy_component: mL,
  destroy_each: c1,
  detach: jt,
  element: os,
  empty: Cu,
  ensure_array_like: km,
  get_all_dirty_from_scope: gL,
  get_slot_changes: vL,
  group_outros: u1,
  init: yL,
  insert: Yt,
  mount_component: bL,
  noop: NA,
  safe_not_equal: TL,
  set_data: To,
  set_style: Hs,
  space: Fa,
  text: un,
  toggle_class: bo,
  transition_in: Au,
  transition_out: Ru,
  update_slot_base: EL
} = window.__gradio__svelte__internal, { tick: SL } = window.__gradio__svelte__internal, { onDestroy: xL } = window.__gradio__svelte__internal, AL = (Z) => ({}), BO = (Z) => ({});
function UO(Z, k, G) {
  const $ = Z.slice();
  return $[38] = k[G], $[40] = G, $;
}
function VO(Z, k, G) {
  const $ = Z.slice();
  return $[38] = k[G], $;
}
function RL(Z) {
  let k, G = (
    /*i18n*/
    Z[1]("common.error") + ""
  ), $, ce, le;
  const be = (
    /*#slots*/
    Z[29].error
  ), pe = _L(
    be,
    Z,
    /*$$scope*/
    Z[28],
    BO
  );
  return {
    c() {
      k = os("span"), $ = un(G), ce = Fa(), pe && pe.c(), Na(k, "class", "error svelte-1txqlrd");
    },
    m(_, Ee) {
      Yt(_, k, Ee), Ul(k, $), Yt(_, ce, Ee), pe && pe.m(_, Ee), le = !0;
    },
    p(_, Ee) {
      (!le || Ee[0] & /*i18n*/
      2) && G !== (G = /*i18n*/
      _[1]("common.error") + "") && To($, G), pe && pe.p && (!le || Ee[0] & /*$$scope*/
      268435456) && EL(
        pe,
        be,
        _,
        /*$$scope*/
        _[28],
        le ? vL(
          be,
          /*$$scope*/
          _[28],
          Ee,
          AL
        ) : gL(
          /*$$scope*/
          _[28]
        ),
        BO
      );
    },
    i(_) {
      le || (Au(pe, _), le = !0);
    },
    o(_) {
      Ru(pe, _), le = !1;
    },
    d(_) {
      _ && (jt(k), jt(ce)), pe && pe.d(_);
    }
  };
}
function CL(Z) {
  let k, G, $, ce, le, be, pe, _, Ee, Xe = (
    /*variant*/
    Z[8] === "default" && /*show_eta_bar*/
    Z[18] && /*show_progress*/
    Z[6] === "full" && kO(Z)
  );
  function yt(Ve, ot) {
    if (
      /*progress*/
      Ve[7]
    )
      return ML;
    if (
      /*queue_position*/
      Ve[2] !== null && /*queue_size*/
      Ve[3] !== void 0 && /*queue_position*/
      Ve[2] >= 0
    )
      return IL;
    if (
      /*queue_position*/
      Ve[2] === 0
    )
      return PL;
  }
  let H = yt(Z), ue = H && H(Z), ct = (
    /*timer*/
    Z[5] && WO(Z)
  );
  const Ht = [FL, NL], gt = [];
  function Ge(Ve, ot) {
    return (
      /*last_progress_level*/
      Ve[15] != null ? 0 : (
        /*show_progress*/
        Ve[6] === "full" ? 1 : -1
      )
    );
  }
  ~(le = Ge(Z)) && (be = gt[le] = Ht[le](Z));
  let pt = !/*timer*/
  Z[5] && QO(Z);
  return {
    c() {
      Xe && Xe.c(), k = Fa(), G = os("div"), ue && ue.c(), $ = Fa(), ct && ct.c(), ce = Fa(), be && be.c(), pe = Fa(), pt && pt.c(), _ = Cu(), Na(G, "class", "progress-text svelte-1txqlrd"), bo(
        G,
        "meta-text-center",
        /*variant*/
        Z[8] === "center"
      ), bo(
        G,
        "meta-text",
        /*variant*/
        Z[8] === "default"
      );
    },
    m(Ve, ot) {
      Xe && Xe.m(Ve, ot), Yt(Ve, k, ot), Yt(Ve, G, ot), ue && ue.m(G, null), Ul(G, $), ct && ct.m(G, null), Yt(Ve, ce, ot), ~le && gt[le].m(Ve, ot), Yt(Ve, pe, ot), pt && pt.m(Ve, ot), Yt(Ve, _, ot), Ee = !0;
    },
    p(Ve, ot) {
      /*variant*/
      Ve[8] === "default" && /*show_eta_bar*/
      Ve[18] && /*show_progress*/
      Ve[6] === "full" ? Xe ? Xe.p(Ve, ot) : (Xe = kO(Ve), Xe.c(), Xe.m(k.parentNode, k)) : Xe && (Xe.d(1), Xe = null), H === (H = yt(Ve)) && ue ? ue.p(Ve, ot) : (ue && ue.d(1), ue = H && H(Ve), ue && (ue.c(), ue.m(G, $))), /*timer*/
      Ve[5] ? ct ? ct.p(Ve, ot) : (ct = WO(Ve), ct.c(), ct.m(G, null)) : ct && (ct.d(1), ct = null), (!Ee || ot[0] & /*variant*/
      256) && bo(
        G,
        "meta-text-center",
        /*variant*/
        Ve[8] === "center"
      ), (!Ee || ot[0] & /*variant*/
      256) && bo(
        G,
        "meta-text",
        /*variant*/
        Ve[8] === "default"
      );
      let ft = le;
      le = Ge(Ve), le === ft ? ~le && gt[le].p(Ve, ot) : (be && (u1(), Ru(gt[ft], 1, 1, () => {
        gt[ft] = null;
      }), l1()), ~le ? (be = gt[le], be ? be.p(Ve, ot) : (be = gt[le] = Ht[le](Ve), be.c()), Au(be, 1), be.m(pe.parentNode, pe)) : be = null), /*timer*/
      Ve[5] ? pt && (pt.d(1), pt = null) : pt ? pt.p(Ve, ot) : (pt = QO(Ve), pt.c(), pt.m(_.parentNode, _));
    },
    i(Ve) {
      Ee || (Au(be), Ee = !0);
    },
    o(Ve) {
      Ru(be), Ee = !1;
    },
    d(Ve) {
      Ve && (jt(k), jt(G), jt(ce), jt(pe), jt(_)), Xe && Xe.d(Ve), ue && ue.d(), ct && ct.d(), ~le && gt[le].d(Ve), pt && pt.d(Ve);
    }
  };
}
function kO(Z) {
  let k, G = `translateX(${/*eta_level*/
  (Z[17] || 0) * 100 - 100}%)`;
  return {
    c() {
      k = os("div"), Na(k, "class", "eta-bar svelte-1txqlrd"), Hs(k, "transform", G);
    },
    m($, ce) {
      Yt($, k, ce);
    },
    p($, ce) {
      ce[0] & /*eta_level*/
      131072 && G !== (G = `translateX(${/*eta_level*/
      ($[17] || 0) * 100 - 100}%)`) && Hs(k, "transform", G);
    },
    d($) {
      $ && jt(k);
    }
  };
}
function PL(Z) {
  let k;
  return {
    c() {
      k = un("processing |");
    },
    m(G, $) {
      Yt(G, k, $);
    },
    p: NA,
    d(G) {
      G && jt(k);
    }
  };
}
function IL(Z) {
  let k, G = (
    /*queue_position*/
    Z[2] + 1 + ""
  ), $, ce, le, be;
  return {
    c() {
      k = un("queue: "), $ = un(G), ce = un("/"), le = un(
        /*queue_size*/
        Z[3]
      ), be = un(" |");
    },
    m(pe, _) {
      Yt(pe, k, _), Yt(pe, $, _), Yt(pe, ce, _), Yt(pe, le, _), Yt(pe, be, _);
    },
    p(pe, _) {
      _[0] & /*queue_position*/
      4 && G !== (G = /*queue_position*/
      pe[2] + 1 + "") && To($, G), _[0] & /*queue_size*/
      8 && To(
        le,
        /*queue_size*/
        pe[3]
      );
    },
    d(pe) {
      pe && (jt(k), jt($), jt(ce), jt(le), jt(be));
    }
  };
}
function ML(Z) {
  let k, G = km(
    /*progress*/
    Z[7]
  ), $ = [];
  for (let ce = 0; ce < G.length; ce += 1)
    $[ce] = zO(VO(Z, G, ce));
  return {
    c() {
      for (let ce = 0; ce < $.length; ce += 1)
        $[ce].c();
      k = Cu();
    },
    m(ce, le) {
      for (let be = 0; be < $.length; be += 1)
        $[be] && $[be].m(ce, le);
      Yt(ce, k, le);
    },
    p(ce, le) {
      if (le[0] & /*progress*/
      128) {
        G = km(
          /*progress*/
          ce[7]
        );
        let be;
        for (be = 0; be < G.length; be += 1) {
          const pe = VO(ce, G, be);
          $[be] ? $[be].p(pe, le) : ($[be] = zO(pe), $[be].c(), $[be].m(k.parentNode, k));
        }
        for (; be < $.length; be += 1)
          $[be].d(1);
        $.length = G.length;
      }
    },
    d(ce) {
      ce && jt(k), c1($, ce);
    }
  };
}
function GO(Z) {
  let k, G = (
    /*p*/
    Z[38].unit + ""
  ), $, ce, le = " ", be;
  function pe(Xe, yt) {
    return (
      /*p*/
      Xe[38].length != null ? DL : OL
    );
  }
  let _ = pe(Z), Ee = _(Z);
  return {
    c() {
      Ee.c(), k = Fa(), $ = un(G), ce = un(" | "), be = un(le);
    },
    m(Xe, yt) {
      Ee.m(Xe, yt), Yt(Xe, k, yt), Yt(Xe, $, yt), Yt(Xe, ce, yt), Yt(Xe, be, yt);
    },
    p(Xe, yt) {
      _ === (_ = pe(Xe)) && Ee ? Ee.p(Xe, yt) : (Ee.d(1), Ee = _(Xe), Ee && (Ee.c(), Ee.m(k.parentNode, k))), yt[0] & /*progress*/
      128 && G !== (G = /*p*/
      Xe[38].unit + "") && To($, G);
    },
    d(Xe) {
      Xe && (jt(k), jt($), jt(ce), jt(be)), Ee.d(Xe);
    }
  };
}
function OL(Z) {
  let k = Eu(
    /*p*/
    Z[38].index || 0
  ) + "", G;
  return {
    c() {
      G = un(k);
    },
    m($, ce) {
      Yt($, G, ce);
    },
    p($, ce) {
      ce[0] & /*progress*/
      128 && k !== (k = Eu(
        /*p*/
        $[38].index || 0
      ) + "") && To(G, k);
    },
    d($) {
      $ && jt(G);
    }
  };
}
function DL(Z) {
  let k = Eu(
    /*p*/
    Z[38].index || 0
  ) + "", G, $, ce = Eu(
    /*p*/
    Z[38].length
  ) + "", le;
  return {
    c() {
      G = un(k), $ = un("/"), le = un(ce);
    },
    m(be, pe) {
      Yt(be, G, pe), Yt(be, $, pe), Yt(be, le, pe);
    },
    p(be, pe) {
      pe[0] & /*progress*/
      128 && k !== (k = Eu(
        /*p*/
        be[38].index || 0
      ) + "") && To(G, k), pe[0] & /*progress*/
      128 && ce !== (ce = Eu(
        /*p*/
        be[38].length
      ) + "") && To(le, ce);
    },
    d(be) {
      be && (jt(G), jt($), jt(le));
    }
  };
}
function zO(Z) {
  let k, G = (
    /*p*/
    Z[38].index != null && GO(Z)
  );
  return {
    c() {
      G && G.c(), k = Cu();
    },
    m($, ce) {
      G && G.m($, ce), Yt($, k, ce);
    },
    p($, ce) {
      /*p*/
      $[38].index != null ? G ? G.p($, ce) : (G = GO($), G.c(), G.m(k.parentNode, k)) : G && (G.d(1), G = null);
    },
    d($) {
      $ && jt(k), G && G.d($);
    }
  };
}
function WO(Z) {
  let k, G = (
    /*eta*/
    Z[0] ? `/${/*formatted_eta*/
    Z[19]}` : ""
  ), $, ce;
  return {
    c() {
      k = un(
        /*formatted_timer*/
        Z[20]
      ), $ = un(G), ce = un("s");
    },
    m(le, be) {
      Yt(le, k, be), Yt(le, $, be), Yt(le, ce, be);
    },
    p(le, be) {
      be[0] & /*formatted_timer*/
      1048576 && To(
        k,
        /*formatted_timer*/
        le[20]
      ), be[0] & /*eta, formatted_eta*/
      524289 && G !== (G = /*eta*/
      le[0] ? `/${/*formatted_eta*/
      le[19]}` : "") && To($, G);
    },
    d(le) {
      le && (jt(k), jt($), jt(ce));
    }
  };
}
function NL(Z) {
  let k, G;
  return k = new dL({
    props: { margin: (
      /*variant*/
      Z[8] === "default"
    ) }
  }), {
    c() {
      fL(k.$$.fragment);
    },
    m($, ce) {
      bL(k, $, ce), G = !0;
    },
    p($, ce) {
      const le = {};
      ce[0] & /*variant*/
      256 && (le.margin = /*variant*/
      $[8] === "default"), k.$set(le);
    },
    i($) {
      G || (Au(k.$$.fragment, $), G = !0);
    },
    o($) {
      Ru(k.$$.fragment, $), G = !1;
    },
    d($) {
      mL(k, $);
    }
  };
}
function FL(Z) {
  let k, G, $, ce, le, be = `${/*last_progress_level*/
  Z[15] * 100}%`, pe = (
    /*progress*/
    Z[7] != null && HO(Z)
  );
  return {
    c() {
      k = os("div"), G = os("div"), pe && pe.c(), $ = Fa(), ce = os("div"), le = os("div"), Na(G, "class", "progress-level-inner svelte-1txqlrd"), Na(le, "class", "progress-bar svelte-1txqlrd"), Hs(le, "width", be), Na(ce, "class", "progress-bar-wrap svelte-1txqlrd"), Na(k, "class", "progress-level svelte-1txqlrd");
    },
    m(_, Ee) {
      Yt(_, k, Ee), Ul(k, G), pe && pe.m(G, null), Ul(k, $), Ul(k, ce), Ul(ce, le), Z[30](le);
    },
    p(_, Ee) {
      /*progress*/
      _[7] != null ? pe ? pe.p(_, Ee) : (pe = HO(_), pe.c(), pe.m(G, null)) : pe && (pe.d(1), pe = null), Ee[0] & /*last_progress_level*/
      32768 && be !== (be = `${/*last_progress_level*/
      _[15] * 100}%`) && Hs(le, "width", be);
    },
    i: NA,
    o: NA,
    d(_) {
      _ && jt(k), pe && pe.d(), Z[30](null);
    }
  };
}
function HO(Z) {
  let k, G = km(
    /*progress*/
    Z[7]
  ), $ = [];
  for (let ce = 0; ce < G.length; ce += 1)
    $[ce] = qO(UO(Z, G, ce));
  return {
    c() {
      for (let ce = 0; ce < $.length; ce += 1)
        $[ce].c();
      k = Cu();
    },
    m(ce, le) {
      for (let be = 0; be < $.length; be += 1)
        $[be] && $[be].m(ce, le);
      Yt(ce, k, le);
    },
    p(ce, le) {
      if (le[0] & /*progress_level, progress*/
      16512) {
        G = km(
          /*progress*/
          ce[7]
        );
        let be;
        for (be = 0; be < G.length; be += 1) {
          const pe = UO(ce, G, be);
          $[be] ? $[be].p(pe, le) : ($[be] = qO(pe), $[be].c(), $[be].m(k.parentNode, k));
        }
        for (; be < $.length; be += 1)
          $[be].d(1);
        $.length = G.length;
      }
    },
    d(ce) {
      ce && jt(k), c1($, ce);
    }
  };
}
function XO(Z) {
  let k, G, $, ce, le = (
    /*i*/
    Z[40] !== 0 && LL()
  ), be = (
    /*p*/
    Z[38].desc != null && jO(Z)
  ), pe = (
    /*p*/
    Z[38].desc != null && /*progress_level*/
    Z[14] && /*progress_level*/
    Z[14][
      /*i*/
      Z[40]
    ] != null && YO()
  ), _ = (
    /*progress_level*/
    Z[14] != null && KO(Z)
  );
  return {
    c() {
      le && le.c(), k = Fa(), be && be.c(), G = Fa(), pe && pe.c(), $ = Fa(), _ && _.c(), ce = Cu();
    },
    m(Ee, Xe) {
      le && le.m(Ee, Xe), Yt(Ee, k, Xe), be && be.m(Ee, Xe), Yt(Ee, G, Xe), pe && pe.m(Ee, Xe), Yt(Ee, $, Xe), _ && _.m(Ee, Xe), Yt(Ee, ce, Xe);
    },
    p(Ee, Xe) {
      /*p*/
      Ee[38].desc != null ? be ? be.p(Ee, Xe) : (be = jO(Ee), be.c(), be.m(G.parentNode, G)) : be && (be.d(1), be = null), /*p*/
      Ee[38].desc != null && /*progress_level*/
      Ee[14] && /*progress_level*/
      Ee[14][
        /*i*/
        Ee[40]
      ] != null ? pe || (pe = YO(), pe.c(), pe.m($.parentNode, $)) : pe && (pe.d(1), pe = null), /*progress_level*/
      Ee[14] != null ? _ ? _.p(Ee, Xe) : (_ = KO(Ee), _.c(), _.m(ce.parentNode, ce)) : _ && (_.d(1), _ = null);
    },
    d(Ee) {
      Ee && (jt(k), jt(G), jt($), jt(ce)), le && le.d(Ee), be && be.d(Ee), pe && pe.d(Ee), _ && _.d(Ee);
    }
  };
}
function LL(Z) {
  let k;
  return {
    c() {
      k = un(" /");
    },
    m(G, $) {
      Yt(G, k, $);
    },
    d(G) {
      G && jt(k);
    }
  };
}
function jO(Z) {
  let k = (
    /*p*/
    Z[38].desc + ""
  ), G;
  return {
    c() {
      G = un(k);
    },
    m($, ce) {
      Yt($, G, ce);
    },
    p($, ce) {
      ce[0] & /*progress*/
      128 && k !== (k = /*p*/
      $[38].desc + "") && To(G, k);
    },
    d($) {
      $ && jt(G);
    }
  };
}
function YO(Z) {
  let k;
  return {
    c() {
      k = un("-");
    },
    m(G, $) {
      Yt(G, k, $);
    },
    d(G) {
      G && jt(k);
    }
  };
}
function KO(Z) {
  let k = (100 * /*progress_level*/
  (Z[14][
    /*i*/
    Z[40]
  ] || 0)).toFixed(1) + "", G, $;
  return {
    c() {
      G = un(k), $ = un("%");
    },
    m(ce, le) {
      Yt(ce, G, le), Yt(ce, $, le);
    },
    p(ce, le) {
      le[0] & /*progress_level*/
      16384 && k !== (k = (100 * /*progress_level*/
      (ce[14][
        /*i*/
        ce[40]
      ] || 0)).toFixed(1) + "") && To(G, k);
    },
    d(ce) {
      ce && (jt(G), jt($));
    }
  };
}
function qO(Z) {
  let k, G = (
    /*p*/
    (Z[38].desc != null || /*progress_level*/
    Z[14] && /*progress_level*/
    Z[14][
      /*i*/
      Z[40]
    ] != null) && XO(Z)
  );
  return {
    c() {
      G && G.c(), k = Cu();
    },
    m($, ce) {
      G && G.m($, ce), Yt($, k, ce);
    },
    p($, ce) {
      /*p*/
      $[38].desc != null || /*progress_level*/
      $[14] && /*progress_level*/
      $[14][
        /*i*/
        $[40]
      ] != null ? G ? G.p($, ce) : (G = XO($), G.c(), G.m(k.parentNode, k)) : G && (G.d(1), G = null);
    },
    d($) {
      $ && jt(k), G && G.d($);
    }
  };
}
function QO(Z) {
  let k, G;
  return {
    c() {
      k = os("p"), G = un(
        /*loading_text*/
        Z[9]
      ), Na(k, "class", "loading svelte-1txqlrd");
    },
    m($, ce) {
      Yt($, k, ce), Ul(k, G);
    },
    p($, ce) {
      ce[0] & /*loading_text*/
      512 && To(
        G,
        /*loading_text*/
        $[9]
      );
    },
    d($) {
      $ && jt(k);
    }
  };
}
function wL(Z) {
  let k, G, $, ce, le;
  const be = [CL, RL], pe = [];
  function _(Ee, Xe) {
    return (
      /*status*/
      Ee[4] === "pending" ? 0 : (
        /*status*/
        Ee[4] === "error" ? 1 : -1
      )
    );
  }
  return ~(G = _(Z)) && ($ = pe[G] = be[G](Z)), {
    c() {
      k = os("div"), $ && $.c(), Na(k, "class", ce = "wrap " + /*variant*/
      Z[8] + " " + /*show_progress*/
      Z[6] + " svelte-1txqlrd"), bo(k, "hide", !/*status*/
      Z[4] || /*status*/
      Z[4] === "complete" || /*show_progress*/
      Z[6] === "hidden"), bo(
        k,
        "translucent",
        /*variant*/
        Z[8] === "center" && /*status*/
        (Z[4] === "pending" || /*status*/
        Z[4] === "error") || /*translucent*/
        Z[11] || /*show_progress*/
        Z[6] === "minimal"
      ), bo(
        k,
        "generating",
        /*status*/
        Z[4] === "generating"
      ), bo(
        k,
        "border",
        /*border*/
        Z[12]
      ), Hs(
        k,
        "position",
        /*absolute*/
        Z[10] ? "absolute" : "static"
      ), Hs(
        k,
        "padding",
        /*absolute*/
        Z[10] ? "0" : "var(--size-8) 0"
      );
    },
    m(Ee, Xe) {
      Yt(Ee, k, Xe), ~G && pe[G].m(k, null), Z[31](k), le = !0;
    },
    p(Ee, Xe) {
      let yt = G;
      G = _(Ee), G === yt ? ~G && pe[G].p(Ee, Xe) : ($ && (u1(), Ru(pe[yt], 1, 1, () => {
        pe[yt] = null;
      }), l1()), ~G ? ($ = pe[G], $ ? $.p(Ee, Xe) : ($ = pe[G] = be[G](Ee), $.c()), Au($, 1), $.m(k, null)) : $ = null), (!le || Xe[0] & /*variant, show_progress*/
      320 && ce !== (ce = "wrap " + /*variant*/
      Ee[8] + " " + /*show_progress*/
      Ee[6] + " svelte-1txqlrd")) && Na(k, "class", ce), (!le || Xe[0] & /*variant, show_progress, status, show_progress*/
      336) && bo(k, "hide", !/*status*/
      Ee[4] || /*status*/
      Ee[4] === "complete" || /*show_progress*/
      Ee[6] === "hidden"), (!le || Xe[0] & /*variant, show_progress, variant, status, translucent, show_progress*/
      2384) && bo(
        k,
        "translucent",
        /*variant*/
        Ee[8] === "center" && /*status*/
        (Ee[4] === "pending" || /*status*/
        Ee[4] === "error") || /*translucent*/
        Ee[11] || /*show_progress*/
        Ee[6] === "minimal"
      ), (!le || Xe[0] & /*variant, show_progress, status*/
      336) && bo(
        k,
        "generating",
        /*status*/
        Ee[4] === "generating"
      ), (!le || Xe[0] & /*variant, show_progress, border*/
      4416) && bo(
        k,
        "border",
        /*border*/
        Ee[12]
      ), Xe[0] & /*absolute*/
      1024 && Hs(
        k,
        "position",
        /*absolute*/
        Ee[10] ? "absolute" : "static"
      ), Xe[0] & /*absolute*/
      1024 && Hs(
        k,
        "padding",
        /*absolute*/
        Ee[10] ? "0" : "var(--size-8) 0"
      );
    },
    i(Ee) {
      le || (Au($), le = !0);
    },
    o(Ee) {
      Ru($), le = !1;
    },
    d(Ee) {
      Ee && jt(k), ~G && pe[G].d(), Z[31](null);
    }
  };
}
let Dm = [], IA = !1;
async function BL(Z, k = !0) {
  if (!(window.__gradio_mode__ === "website" || window.__gradio_mode__ !== "app" && k !== !0)) {
    if (Dm.push(Z), !IA)
      IA = !0;
    else
      return;
    await SL(), requestAnimationFrame(() => {
      let G = [0, 0];
      for (let $ = 0; $ < Dm.length; $++) {
        const le = Dm[$].getBoundingClientRect();
        ($ === 0 || le.top + window.scrollY <= G[0]) && (G[0] = le.top + window.scrollY, G[1] = $);
      }
      window.scrollTo({ top: G[0] - 20, behavior: "smooth" }), IA = !1, Dm = [];
    });
  }
}
function UL(Z, k, G) {
  let $, { $$slots: ce = {}, $$scope: le } = k, { i18n: be } = k, { eta: pe = null } = k, { queue: _ = !1 } = k, { queue_position: Ee } = k, { queue_size: Xe } = k, { status: yt } = k, { scroll_to_output: H = !1 } = k, { timer: ue = !0 } = k, { show_progress: ct = "full" } = k, { message: Ht = null } = k, { progress: gt = null } = k, { variant: Ge = "default" } = k, { loading_text: pt = "Loading..." } = k, { absolute: Ve = !0 } = k, { translucent: ot = !1 } = k, { border: ft = !1 } = k, { autoscroll: j } = k, Kt, Ti = !1, Me = 0, Zt = 0, fe = null, v = 0, lt = null, oe, B = null, ze = !0;
  const F = () => {
    G(25, Me = performance.now()), G(26, Zt = 0), Ti = !0, ur();
  };
  function ur() {
    requestAnimationFrame(() => {
      G(26, Zt = (performance.now() - Me) / 1e3), Ti && ur();
    });
  }
  function En() {
    G(26, Zt = 0), Ti && (Ti = !1);
  }
  xL(() => {
    Ti && En();
  });
  let br = null;
  function Nn(ne) {
    wO[ne ? "unshift" : "push"](() => {
      B = ne, G(16, B), G(7, gt), G(14, lt), G(15, oe);
    });
  }
  function Lr(ne) {
    wO[ne ? "unshift" : "push"](() => {
      Kt = ne, G(13, Kt);
    });
  }
  return Z.$$set = (ne) => {
    "i18n" in ne && G(1, be = ne.i18n), "eta" in ne && G(0, pe = ne.eta), "queue" in ne && G(21, _ = ne.queue), "queue_position" in ne && G(2, Ee = ne.queue_position), "queue_size" in ne && G(3, Xe = ne.queue_size), "status" in ne && G(4, yt = ne.status), "scroll_to_output" in ne && G(22, H = ne.scroll_to_output), "timer" in ne && G(5, ue = ne.timer), "show_progress" in ne && G(6, ct = ne.show_progress), "message" in ne && G(23, Ht = ne.message), "progress" in ne && G(7, gt = ne.progress), "variant" in ne && G(8, Ge = ne.variant), "loading_text" in ne && G(9, pt = ne.loading_text), "absolute" in ne && G(10, Ve = ne.absolute), "translucent" in ne && G(11, ot = ne.translucent), "border" in ne && G(12, ft = ne.border), "autoscroll" in ne && G(24, j = ne.autoscroll), "$$scope" in ne && G(28, le = ne.$$scope);
  }, Z.$$.update = () => {
    Z.$$.dirty[0] & /*eta, old_eta, queue, timer_start*/
    169869313 && (pe === null ? G(0, pe = fe) : _ && G(0, pe = (performance.now() - Me) / 1e3 + pe), pe != null && (G(19, br = pe.toFixed(1)), G(27, fe = pe))), Z.$$.dirty[0] & /*eta, timer_diff*/
    67108865 && G(17, v = pe === null || pe <= 0 || !Zt ? null : Math.min(Zt / pe, 1)), Z.$$.dirty[0] & /*progress*/
    128 && gt != null && G(18, ze = !1), Z.$$.dirty[0] & /*progress, progress_level, progress_bar, last_progress_level*/
    114816 && (gt != null ? G(14, lt = gt.map((ne) => {
      if (ne.index != null && ne.length != null)
        return ne.index / ne.length;
      if (ne.progress != null)
        return ne.progress;
    })) : G(14, lt = null), lt ? (G(15, oe = lt[lt.length - 1]), B && (oe === 0 ? G(16, B.style.transition = "0", B) : G(16, B.style.transition = "150ms", B))) : G(15, oe = void 0)), Z.$$.dirty[0] & /*status*/
    16 && (yt === "pending" ? F() : En()), Z.$$.dirty[0] & /*el, scroll_to_output, status, autoscroll*/
    20979728 && Kt && H && (yt === "pending" || yt === "complete") && BL(Kt, j), Z.$$.dirty[0] & /*status, message*/
    8388624, Z.$$.dirty[0] & /*timer_diff*/
    67108864 && G(20, $ = Zt.toFixed(1));
  }, [
    pe,
    be,
    Ee,
    Xe,
    yt,
    ue,
    ct,
    gt,
    Ge,
    pt,
    Ve,
    ot,
    ft,
    Kt,
    lt,
    oe,
    B,
    v,
    ze,
    br,
    $,
    _,
    H,
    Ht,
    j,
    Me,
    Zt,
    fe,
    le,
    ce,
    Nn,
    Lr
  ];
}
class VL extends pL {
  constructor(k) {
    super(), yL(
      this,
      k,
      UL,
      wL,
      TL,
      {
        i18n: 1,
        eta: 0,
        queue: 21,
        queue_position: 2,
        queue_size: 3,
        status: 4,
        scroll_to_output: 22,
        timer: 5,
        show_progress: 6,
        message: 23,
        progress: 7,
        variant: 8,
        loading_text: 9,
        absolute: 10,
        translucent: 11,
        border: 12,
        autoscroll: 24
      },
      null,
      [-1, -1]
    );
  }
}
var MA = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function kL(Z) {
  return Z && Z.__esModule && Object.prototype.hasOwnProperty.call(Z, "default") ? Z.default : Z;
}
var h1 = { exports: {} };
(function(Z, k) {
  (function(G, $) {
    Z.exports = $();
  })(typeof self < "u" ? self : MA, () => (() => {
    var G = { d: (n, t) => {
      for (var e in t)
        G.o(t, e) && !G.o(n, e) && Object.defineProperty(n, e, { enumerable: !0, get: t[e] });
    } };
    G.g = function() {
      if (typeof globalThis == "object")
        return globalThis;
      try {
        return this || new Function("return this")();
      } catch {
        if (typeof window == "object")
          return window;
      }
    }(), G.o = (n, t) => Object.prototype.hasOwnProperty.call(n, t), G.r = (n) => {
      typeof Symbol < "u" && Symbol.toStringTag && Object.defineProperty(n, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(n, "__esModule", { value: !0 });
    };
    var $ = {};
    G.d($, { default: () => $N });
    var ce = {};
    G.r(ce), G.d(ce, { AxesViewer: () => yl, BoneAxesViewer: () => yf, DebugLayer: () => bf, DebugLayerTab: () => vh, DirectionalLightFrustumViewer: () => kv, PhysicsViewer: () => Lf, RayHelper: () => Vv, SkeletonViewer: () => wf });
    var le = {};
    G.r(le), G.d(le, { AbstractActionManager: () => Ee, AbstractAssetTask: () => uo, AbstractMesh: () => Dt, AbstractScene: () => pe, AcquireNativeObjectAsync: () => ny, Action: () => wt, ActionEvent: () => mi, ActionManager: () => Qs, AddBlock: () => Fb, AddressMode: () => As, AdvancedTimer: () => Ly, AlignBlock: () => T0, AlphaState: () => Qm, AmmoJSPlugin: () => R_, AnaglyphArcRotateCamera: () => Jg, AnaglyphFreeCamera: () => $g, AnaglyphGamepadCamera: () => ev, AnaglyphPostProcess: () => uf, AnaglyphUniversalCamera: () => tv, Analyser: () => sR, AndOrNotEvaluator: () => Vi, Angle: () => ac, Animatable: () => Tp, AnimatedInputBlockTypes: () => sa, Animation: () => Je, AnimationAssetTask: () => dI, AnimationEvent: () => tR, AnimationGroup: () => pg, AnimationGroupMask: () => nR, AnimationGroupMaskMode: () => oc, AnimationKeyInterpolation: () => Ou, AnimationPropertiesOverride: () => YA, AnimationRange: () => Zl, AnisotropyBlock: () => U_, ApplyPostProcess: () => Oh, Arc2: () => sg, ArcFollowCamera: () => Yg, ArcRotateCamera: () => gs, ArcRotateCameraGamepadInput: () => Hp, ArcRotateCameraInputsManager: () => sh, ArcRotateCameraKeyboardMoveInput: () => Xp, ArcRotateCameraMouseWheelInput: () => jp, ArcRotateCameraPointersInput: () => Yp, ArcRotateCameraVRDeviceOrientationInput: () => Kp, ArcTan2Block: () => tT, AssetContainer: () => Rg, AssetTaskState: () => Wo, AssetsManager: () => pI, AssetsProgressEvent: () => DE, AsyncLoop: () => So, AttachToBoxBehavior: () => _R, AudioEngine: () => Cg, AudioSceneComponent: () => Rr, AutoLayoutMode: () => xl, AutoReleaseWorkerPool: () => p_, AutoRotationBehavior: () => Ig, AxesViewer: () => yl, Axis: () => qi, AxisDragGizmo: () => Fo, AxisScaleGizmo: () => Hc, BRDFTextureTools: () => BC, BabylonFileLoaderConfiguration: () => id, BackEase: () => cg, BackgroundMaterial: () => jc, BakedVertexAnimationManager: () => cR, BallAndSocketConstraint: () => WP, BaseCameraMouseWheelInput: () => zg, BaseCameraPointersInput: () => Wp, BaseError: () => il, BaseParticleSystem: () => fc, BaseSixDofDragBehavior: () => Ip, BaseTexture: () => Vn, BasisTools: () => od, BasisToolsOptions: () => Ta, BasisTranscodeConfiguration: () => rP, BezierCurve: () => ag, BezierCurveEase: () => eR, BiPlanarBlock: () => xT, BinaryFileAssetTask: () => wE, BlackAndWhitePostProcess: () => $0, BlendFactor: () => An, BlendOperation: () => va, BloomEffect: () => om, BloomMergePostProcess: () => rm, BlurPostProcess: () => Cn, Bone: () => Wu, BoneAxesViewer: () => yf, BoneIKController: () => DR, BoneLookController: () => NR, BonesBlock: () => lb, BooleanGeometryBlock: () => k0, BooleanGeometryOperations: () => lo, BounceEase: () => KA, BouncingBehavior: () => Mg, BoundingBlock: () => V0, BoundingBox: () => cl, BoundingBoxGizmo: () => hy, BoundingBoxRenderer: () => _E, BoundingInfo: () => wr, BoundingSphere: () => ul, BoxBlock: () => Q_, BoxBuilder: () => YR, BoxParticleEmitter: () => _l, Buffer: () => Yi, BufferBindingType: () => ma, BufferMapState: () => zf, BufferUsage: () => $t, CSG: () => X_, Camera: () => dt, CameraGizmo: () => LC, CameraInputTypes: () => gn, CameraInputsManager: () => yc, CannonJSPlugin: () => td, CanvasAlphaMode: () => Gc, CapsuleBlock: () => qT, CapsuleBuilder: () => qR, CascadedShadowGenerator: () => b_, ChromaticAberrationPostProcess: () => am, CircleEase: () => lg, CircleOfConfusionPostProcess: () => sm, ClampBlock: () => wb, ClearCoatBlock: () => sd, ClipPlanesBlock: () => Mb, ClipboardEventTypes: () => zh, ClipboardInfo: () => OC, CloudBlock: () => TT, CloudPoint: () => q0, Collider: () => Rv, Color3: () => ne, Color3Gradient: () => X0, Color4: () => Ie, ColorCorrectionPostProcess: () => eE, ColorCurves: () => tc, ColorGradient: () => Z_, ColorGradingTexture: () => Jy, ColorMergerBlock: () => Gb, ColorSplitterBlock: () => Gp, ColorWrite: () => jf, CombineAction: () => Hl, CompareFunction: () => an, CompatibilityOptions: () => Lt, CompilationMessageType: () => Hf, CompleteGreasedLineColorTable: () => VT, CompleteGreasedLineWidthTable: () => UT, ComputeBindingType: () => di, ComputeEffect: () => Pv, ComputeNormalsBlock: () => h0, ComputePassTimestampLocation: () => Yf, ComputeShader: () => gf, ComputeShaderParticleSystem: () => H0, Condition: () => Jn, ConditionBlock: () => o0, ConditionBlockTests: () => Ji, ConditionalBlock: () => bT, ConditionalBlockConditions: () => fr, ConeParticleEmitter: () => wp, Constants: () => _, ContainerAssetTask: () => NE, ConversionMode: () => fd, ConvolutionPostProcess: () => tE, Coordinate: () => Ua, CopyTextureToTexture: () => RE, CopyTools: () => uR, CreateBox: () => Ur, CreateBoxVertexData: () => yh, CreateCapsule: () => Ic, CreateCapsuleVertexData: () => Th, CreateCylinder: () => Fn, CreateCylinderVertexData: () => gh, CreateDashedLines: () => xh, CreateDashedLinesVertexData: () => Pf, CreateDecal: () => Ch, CreateDisc: () => bl, CreateDiscVertexData: () => Eh, CreateEnvTextureAsync: () => Qv, CreateGeodesic: () => Fv, CreateGoldberg: () => wv, CreateGoldbergVertexData: () => Lv, CreateGreasedLine: () => PP, CreateGreasedLineMaterial: () => BT, CreateGround: () => vl, CreateGroundFromHeightMap: () => _h, CreateGroundFromHeightMapVertexData: () => mf, CreateGroundVertexData: () => Do, CreateHemisphere: () => Xc, CreateIcoSphere: () => vc, CreateIcoSphereVertexData: () => nh, CreateImageDataArrayBufferViews: () => wh, CreateLathe: () => Ah, CreateLineSystem: () => Ss, CreateLineSystemVertexData: () => Cf, CreateLines: () => si, CreatePlane: () => Ro, CreatePlaneVertexData: () => Zu, CreatePolygon: () => Mc, CreatePolygonVertexData: () => If, CreatePolyhedron: () => xs, CreatePolyhedronVertexData: () => Mf, CreateResizedCopy: () => Xv, CreateRibbon: () => pa, CreateRibbonVertexData: () => Tf, CreateScreenshot: () => du, CreateScreenshotAsync: () => Tm, CreateScreenshotUsingRenderTarget: () => pu, CreateScreenshotUsingRenderTargetAsync: () => Em, CreateScreenshotWithResizeAsync: () => XE, CreateSegmentedBoxVertexData: () => Mv, CreateSphere: () => yn, CreateSphereVertexData: () => bh, CreateText: () => Bv, CreateTextShapePaths: () => Ff, CreateTiledBox: () => xf, CreateTiledBoxVertexData: () => Sf, CreateTiledGround: () => fh, CreateTiledGroundVertexData: () => _f, CreateTiledPlane: () => Ef, CreateTiledPlaneVertexData: () => Tl, CreateTorus: () => eo, CreateTorusKnot: () => Sh, CreateTorusKnotVertexData: () => Af, CreateTorusVertexData: () => mh, CreateTube: () => Rh, CrossBlock: () => Bb, CubeMapToSphericalPolynomialTools: () => Nh, CubeTexture: () => Gr, CubeTextureAssetTask: () => VE, CubicEase: () => qA, CullMode: () => Al, CurrentScreenBlock: () => Op, Curve3: () => Ep, CurveBlock: () => PT, CurveBlockTypes: () => pi, CustomBlock: () => Ub, CustomOptimization: () => zE, CustomParticleEmitter: () => ml, CustomProceduralTexture: () => ab, CylinderBlock: () => KT, CylinderBuilder: () => jR, CylinderDirectedParticleEmitter: () => Bp, CylinderParticleEmitter: () => th, DDSTools: () => Ka, DataBuffer: () => wa, DataReader: () => SI, DataStorage: () => xI, Database: () => z0, DebugBlock: () => O0, DebugLayer: () => bf, DebugLayerTab: () => vh, DecalBuilder: () => uC, DecalMapConfiguration: () => cd, DecalMapDefines: () => IT, Decode: () => ep, DecodeBase64ToBinary: () => Nu, DecodeBase64ToString: () => Du, DecodeBase64UrlToBinary: () => Vu, DecodeBase64UrlToString: () => up, DeepCopier: () => Ui, DefaultCollisionCoordinator: () => Cv, DefaultKTX2DecoderOptions: () => Ay, DefaultLoadingScreen: () => jy, DefaultRenderingPipeline: () => cE, Deferred: () => fI, DepthCullingState: () => np, DepthOfFieldBlurPostProcess: () => pd, DepthOfFieldEffect: () => lm, DepthOfFieldEffectBlurLevel: () => Ds, DepthOfFieldMergePostProcess: () => iE, DepthPeelingRenderer: () => gE, DepthPeelingSceneComponent: () => vE, DepthReducer: () => Hy, DepthRenderer: () => tu, DepthRendererSceneComponent: () => mE, DepthSortedParticle: () => Y0, DerivativeBlock: () => _b, DesaturateBlock: () => _T, DetailMapConfiguration: () => dh, DeviceInputEventType: () => mp, DeviceLostReason: () => qf, DeviceOrientationCamera: () => lh, DeviceSource: () => yp, DeviceSourceManager: () => og, DeviceType: () => Ze, DirectionalLight: () => jh, DirectionalLightFrustumViewer: () => kv, DiscBlock: () => QT, DiscBuilder: () => ZR, DiscardBlock: () => pb, DisplayPassPostProcess: () => nE, DistanceBlock: () => Qb, DistanceConstraint: () => HP, DistanceJoint: () => TR, DivideBlock: () => Hb, DoNothingAction: () => Ks, DomManagement: () => BA, DotBlock: () => Vb, DracoCompression: () => EP, DrawWrapper: () => Ei, DualSenseInput: () => pp, DualShockButton: () => Pr, DualShockDpad: () => ys, DualShockInput: () => dp, DualShockPad: () => qg, DumpTools: () => la, DynamicFloat32Array: () => Aa, DynamicTexture: () => Es, EasingFunction: () => xn, EdgesRenderer: () => fm, Effect: () => Jt, EffectFallbacks: () => Va, EffectLayer: () => eu, EffectLayerSceneComponent: () => Vy, EffectRenderer: () => _c, EffectWrapper: () => Io, ElasticEase: () => QA, ElbowBlock: () => ST, EncodeArrayBufferToBase64: () => $l, EndsWith: () => Hm, Engine: () => ve, EngineFactory: () => MC, EngineFormat: () => Kh, EngineInstrumentation: () => By, EngineStore: () => Me, EngineView: () => dC, EnvironmentHelper: () => a_, EnvironmentTextureTools: () => gC, Epsilon: () => Ge, EquiRectangularCubeTexture: () => $y, EquiRectangularCubeTextureAssetTask: () => GE, ErrorCodes: () => ta, ErrorFilter: () => Qf, EventConstants: () => zu, EventState: () => Xe, ExecuteCodeAction: () => Xl, ExponentialEase: () => ug, ExternalTexture: () => t_, ExtractHighlightsPostProcess: () => nm, ExtrudePolygon: () => Oc, ExtrudeShape: () => Dc, ExtrudeShapeCustom: () => Nc, FactorGradient: () => J_, FadeInOutBehavior: () => mR, FeatureName: () => Lo, FileTools: () => al, FileToolsOptions: () => zi, FilesInput: () => mI, FilesInputStore: () => tl, FilterMode: () => Ct, FilterPostProcess: () => rE, FlowGraph: () => Rm, FlowGraphACosNumberBlock: () => gx, FlowGraphASinNumberBlock: () => mx, FlowGraphATan2NumberBlock: () => Tx, FlowGraphATanNumberBlock: () => vx, FlowGraphAbsNumberBlock: () => nx, FlowGraphAddMatrixAndNumberBlock: () => hA, FlowGraphAddMatrixBlock: () => uA, FlowGraphAddNumberBlock: () => KS, FlowGraphAddVector2Block: () => Ox, FlowGraphAddVector3Block: () => Gx, FlowGraphAddVector4Block: () => eA, FlowGraphBitwiseAndBlock: () => BS, FlowGraphBitwiseLeftShiftBlock: () => GS, FlowGraphBitwiseNotBlock: () => kS, FlowGraphBitwiseOrBlock: () => US, FlowGraphBitwiseRightShiftBlock: () => zS, FlowGraphBitwiseXorBlock: () => VS, FlowGraphBlock: () => bn, FlowGraphBranchBlock: () => _S, FlowGraphCeilNumberBlock: () => ax, FlowGraphClampMatrixBlock: () => vA, FlowGraphComposeMatrixBlock: () => bA, FlowGraphConditionalDataBlock: () => DS, FlowGraphConstantBlock: () => LS, FlowGraphContext: () => Am, FlowGraphContextLogger: () => GI, FlowGraphCoordinateTransformBlock: () => FS, FlowGraphCoordinator: () => kI, FlowGraphCosNumberBlock: () => fx, FlowGraphCountLeadingZerosBlock: () => WS, FlowGraphCountTrailingZerosBlock: () => HS, FlowGraphCounterBlock: () => SS, FlowGraphCreateVector2Block: () => Ux, FlowGraphCreateVector3Block: () => Qx, FlowGraphCreateVector4Block: () => lA, FlowGraphCrossVector3Block: () => qx, FlowGraphDebounceBlock: () => AS, FlowGraphDecomposeMatrixBlock: () => yA, FlowGraphDivideMatrixAndNumberBlock: () => mA, FlowGraphDivideMatrixBlock: () => _A, FlowGraphDivideNumberBlock: () => ZS, FlowGraphDivideVector2Block: () => Fx, FlowGraphDivideVector3Block: () => Hx, FlowGraphDivideVector4Block: () => nA, FlowGraphDoNBlock: () => mS, FlowGraphDotVector3Block: () => Kx, FlowGraphENumberBlock: () => yx, FlowGraphEqualsNumberBlock: () => Ax, FlowGraphEventBlock: () => Ll, FlowGraphExecutionBlock: () => po, FlowGraphExpNumberBlock: () => cx, FlowGraphFlipFlopBlock: () => RS, FlowGraphFloorNumberBlock: () => ox, FlowGraphForLoopBlock: () => gS, FlowGraphGetTransformationMatrixBlock: () => EA, FlowGraphGetVariableBlock: () => NS, FlowGraphGreaterThanNumberBlock: () => Rx, FlowGraphGreaterThanOrEqualsNumberBlock: () => Cx, FlowGraphIsInfinityNumberBlock: () => tx, FlowGraphIsNaNNumberBlock: () => ex, FlowGraphLengthVector2Block: () => wx, FlowGraphLengthVector3Block: () => jx, FlowGraphLengthVector4Block: () => oA, FlowGraphLessThanNumberBlock: () => Px, FlowGraphLessThanOrEqualsNumberBlock: () => Ix, FlowGraphLnNumberBlock: () => dx, FlowGraphLog10NumberBlock: () => ux, FlowGraphLogBlock: () => uS, FlowGraphLogNumberBlock: () => hx, FlowGraphLogicAndBlock: () => XS, FlowGraphLogicNotBlock: () => YS, FlowGraphLogicOrBlock: () => jS, FlowGraphMaxNumberBlock: () => xx, FlowGraphMeshPickEventBlock: () => SA, FlowGraphMinNumberBlock: () => Sx, FlowGraphMixNumberBlock: () => Mx, FlowGraphModNumberBlock: () => JS, FlowGraphMultiGateBlock: () => bS, FlowGraphMultiplyMatrixBlock: () => fA, FlowGraphMultiplyNumberBlock: () => QS, FlowGraphMultiplyVector2Block: () => Nx, FlowGraphMultiplyVector3Block: () => Wx, FlowGraphMultiplyVector4Block: () => iA, FlowGraphNegateNumberBlock: () => rx, FlowGraphNormalizeVector2Block: () => Bx, FlowGraphNormalizeVector3Block: () => Yx, FlowGraphNormalizeVector4Block: () => sA, FlowGraphPath: () => cS, FlowGraphPauseAnimationBlock: () => IS, FlowGraphPiNumberBlock: () => bx, FlowGraphPlayAnimationBlock: () => CS, FlowGraphPlayAudioBlock: () => MS, FlowGraphPowNumberBlock: () => $S, FlowGraphQuaternionToRotationMatrixBlock: () => TA, FlowGraphRandomNumberBlock: () => Ex, FlowGraphReceiveCustomEventBlock: () => AA, FlowGraphRotate2dVector2Block: () => kx, FlowGraphRotate3dVector3Block: () => Jx, FlowGraphRoundNumberBlock: () => sx, FlowGraphScaleMatrixBlock: () => gA, FlowGraphScaleVector2Block: () => Lx, FlowGraphScaleVector3Block: () => Xx, FlowGraphScaleVector4Block: () => rA, FlowGraphSceneReadyEventBlock: () => xA, FlowGraphSceneTickEventBlock: () => RA, FlowGraphSendCustomEventBlock: () => fS, FlowGraphSetPropertyBlock: () => pS, FlowGraphSetVariableBlock: () => hS, FlowGraphSignalConnection: () => kd, FlowGraphSinNumberBlock: () => px, FlowGraphSplitVector2Block: () => Vx, FlowGraphSplitVector3Block: () => Zx, FlowGraphSplitVector4Block: () => cA, FlowGraphSqrtNumberBlock: () => ix, FlowGraphState: () => is, FlowGraphStopAnimationBlock: () => PS, FlowGraphStopAudioBlock: () => OS, FlowGraphSubtractMatrixAndNumberBlock: () => pA, FlowGraphSubtractMatrixBlock: () => dA, FlowGraphSubtractNumberBlock: () => qS, FlowGraphSubtractVector2Block: () => Dx, FlowGraphSubtractVector3Block: () => zx, FlowGraphSubtractVector4Block: () => tA, FlowGraphSwitchBlock: () => TS, FlowGraphTanNumberBlock: () => _x, FlowGraphThrottleBlock: () => vS, FlowGraphTimerBlock: () => yS, FlowGraphTransformVector3Block: () => $x, FlowGraphTruncNumberBlock: () => lx, FlowGraphWaitAllBlock: () => ES, FlowGraphWhileLoopBlock: () => xS, FluidRenderer: () => PE, FluidRendererSceneComponent: () => CE, FluidRenderingDebug: () => gr, FluidRenderingObject: () => mm, FluidRenderingObjectCustomParticles: () => AE, FluidRenderingObjectParticleSystem: () => SE, FluidRenderingTargetRenderer: () => gm, FlyCamera: () => LR, FlyCameraInputsManager: () => Hg, FlyCameraKeyboardInput: () => qp, FlyCameraMouseInput: () => Qp, FogBlock: () => xb, FollowBehavior: () => bR, FollowCamera: () => jg, FollowCameraInputsManager: () => Xg, FollowCameraKeyboardMoveInput: () => Zp, FollowCameraMouseWheelInput: () => Jp, FollowCameraPointersInput: () => $p, FragCoordBlock: () => mb, FragDepthBlock: () => Tb, FragmentOutputBlock: () => fl, FramingBehavior: () => Og, FreeCamera: () => Oo, FreeCameraDeviceOrientationInput: () => of, FreeCameraGamepadInput: () => af, FreeCameraInputsManager: () => bc, FreeCameraKeyboardMoveInput: () => ef, FreeCameraMouseInput: () => tf, FreeCameraMouseWheelInput: () => nf, FreeCameraTouchInput: () => rf, FreeCameraVirtualJoystickInput: () => lf, FresnelBlock: () => Yb, FresnelParameters: () => qy, FromHalfFloat: () => io, FrontFace: () => Uc, FrontFacingBlock: () => fb, Frustum: () => ll, FxaaPostProcess: () => hu, GPUParticleSystem: () => Os, GUID: () => WA, Gamepad: () => qn, GamepadCamera: () => ch, GamepadManager: () => Qg, GamepadSystemSceneComponent: () => Zg, GenerateBase64StringFromPixelData: () => Qu, GenerateBase64StringFromTexture: () => Cp, GenerateBase64StringFromTextureAsync: () => Pp, GenericPad: () => Wg, GeodesicData: () => Df, Geometry: () => er, GeometryBufferRenderer: () => mr, GeometryBufferRendererSceneComponent: () => oE, GeometryCollectionBlock: () => c0, GeometryElbowBlock: () => u0, GeometryInfoBlock: () => D0, GeometryInputBlock: () => Di, GeometryOptimizeBlock: () => GT, GeometryOutputBlock: () => q_, GeometryTextureBlock: () => B0, GeometryTextureFetchBlock: () => U0, GeometryTransformBlock: () => m0, GeometryTrigonometryBlock: () => _0, GeometryTrigonometryBlockOperations: () => Wt, GetClass: () => Kt, GetDOMTextContent: () => Jl, GetEnvInfo: () => Lh, GetEnvironmentBRDFTexture: () => Yc, GetInternalFormatFromBasisFormat: () => nb, GetTGAHeader: () => au, GetTextureDataAsync: () => jv, Gizmo: () => vn, GizmoAnchorPoint: () => Cc, GizmoCoordinatesMode: () => Ha, GizmoManager: () => DC, GlowLayer: () => Zh, GoldbergMesh: () => Nf, GradientBlock: () => sT, GradientBlockColorStep: () => ad, GradientHelper: () => sr, GrainPostProcess: () => cm, GreasedLineBaseMesh: () => j_, GreasedLineMaterialDefaults: () => Pn, GreasedLineMesh: () => Y_, GreasedLineMeshColorDistribution: () => Vo, GreasedLineMeshColorDistributionType: () => Uo, GreasedLineMeshColorMode: () => _r, GreasedLineMeshMaterialType: () => Cl, GreasedLineMeshWidthDistribution: () => Sa, GreasedLinePluginMaterial: () => Pl, GreasedLineRibbonAutoDirectionMode: () => $a, GreasedLineRibbonFacesMode: () => Il, GreasedLineRibbonMesh: () => ud, GreasedLineRibbonPointsMode: () => zr, GreasedLineSimpleMaterial: () => z_, GreasedLineTools: () => Oi, GridBlock: () => jT, GroundBuilder: () => zR, GroundMesh: () => ph, HDRCubeTexture: () => $h, HDRCubeTextureAssetTask: () => kE, HDRFiltering: () => S_, HDRTools: () => Jh, HandConstraintBehavior: () => OR, HandConstraintOrientation: () => ua, HandConstraintVisibility: () => za, HandConstraintZone: () => Ga, HandPart: () => ca, HardwareScalingOptimization: () => vm, HavokPlugin: () => tI, HeightToNormalBlock: () => bb, HemisphereBuilder: () => NC, HemisphericLight: () => Pc, HemisphericParticleEmitter: () => Up, HighlightLayer: () => g_, HighlightsPostProcess: () => rI, Hinge2Joint: () => SR, HingeConstraint: () => XP, HingeJoint: () => ER, HtmlElementTexture: () => nP, IFlowGraphCoordinatorConfiguration: () => VI, IWebXRControllerPhysicsOptions: () => LI, IcoSphereBlock: () => HT, IcoSphereBuilder: () => MR, ImageAssetTask: () => BE, ImageProcessingBlock: () => hb, ImageProcessingConfiguration: () => tn, ImageProcessingConfigurationDefines: () => tg, ImageProcessingPostProcess: () => um, ImageSourceBlock: () => Bo, IncrementValueAction: () => Gl, IndexFormat: () => ya, InputBlock: () => vt, InspectableType: () => Sm, InstancedLinesMesh: () => Rf, InstancedMesh: () => dl, InstancesBlock: () => cb, InstantiateBlock: () => C0, InstantiateLinearBlock: () => P0, InstantiateOnFacesBlock: () => x0, InstantiateOnVerticesBlock: () => S0, InstantiateOnVolumeBlock: () => A0, InstantiateRadialBlock: () => I0, InstantiatedEntries: () => Ag, IntFloatConverterBlock: () => M0, InternalTexture: () => Ut, InternalTextureSource: () => ut, InterpolateValueAction: () => Gm, IntersectionInfo: () => Ku, IsBase64DataUrl: () => Uu, IsDocumentAvailable: () => hs, IsFileURL: () => cp, IsNavigatorAvailable: () => us, IsWindowObjectExist: () => Gi, JoystickAxis: () => Zi, KeepAssets: () => xg, KeyboardEventTypes: () => ps, KeyboardInfo: () => Gu, KeyboardInfoPre: () => vp, KhronosTextureContainer: () => qh, KhronosTextureContainer2: () => f_, LatheBuilder: () => aC, Layer: () => QC, LayerSceneComponent: () => ky, LengthBlock: () => Zb, LensFlare: () => Gy, LensFlareSystem: () => v_, LensFlareSystemSceneComponent: () => zy, LensFlaresOptimization: () => vd, LensRenderingPipeline: () => aI, LerpBlock: () => Wb, Light: () => Kn, LightBlock: () => Ab, LightGizmo: () => FC, LightInformationBlock: () => ub, LineEdgesRenderer: () => yE, LinesBuilder: () => tC, LinesMesh: () => El, LoadFile: () => na, LoadFileError: () => sp, LoadImage: () => rl, LoadOp: () => ji, LoadTextureFromTranscodeResult: () => rd, LockConstraint: () => YP, Logger: () => q, MapMode: () => Ya, MapRangeBlock: () => r0, MappingBlock: () => N0, MappingTypes: () => so, Material: () => Et, MaterialAnisotropicDefines: () => gy, MaterialClearCoatDefines: () => _y, MaterialDefines: () => jn, MaterialDetailMapDefines: () => _v, MaterialFlags: () => Pe, MaterialGreasedLineDefines: () => MT, MaterialHelper: () => Se, MaterialIridescenceDefines: () => my, MaterialPluginBase: () => $r, MaterialPluginEvent: () => rn, MaterialPluginManager: () => dv, MaterialSheenDefines: () => vy, MaterialSubSurfaceDefines: () => yy, MathBlock: () => n0, MathBlockOperations: () => Gn, Matrix: () => B, MatrixBuilderBlock: () => yT, MatrixComposeBlock: () => F0, MatrixDeterminantBlock: () => AT, MatrixTransposeBlock: () => RT, MaxBlock: () => Kb, MergeGeometryBlock: () => l0, MergeMeshesOptimization: () => bd, Mesh: () => ie, MeshAssetTask: () => FE, MeshAttributeExistsBlock: () => CT, MeshAttributeExistsBlockTypes: () => ti, MeshBlock: () => WT, MeshBuilder: () => Uv, MeshDebugMode: () => Ms, MeshDebugPluginMaterial: () => OT, MeshExploder: () => _I, MeshLODLevel: () => Sg, MeshParticleEmitter: () => Lg, MeshUVSpaceRenderer: () => AP, MeshoptCompression: () => SP, MinBlock: () => qb, MinMaxReducer: () => Wy, MipmapFilterMode: () => Wf, MirrorTexture: () => o_, ModBlock: () => vT, ModelShape: () => em, MorphTarget: () => Yy, MorphTargetManager: () => ed, MorphTargetsBlock: () => F_, MotionBlurPostProcess: () => hm, MotorEnabledJoint: () => Mp, MultiMaterial: () => Ao, MultiObserver: () => gI, MultiPointerScaleBehavior: () => vR, MultiRenderTarget: () => Ja, MultiplyBlock: () => eh, NLerpBlock: () => lT, NativeDataStream: () => Ih, NativeEngine: () => kf, NativePointerInput: () => ic, NativeXRFrame: () => iS, NativeXRLayerRenderTargetTextureProvider: () => Sv, NativeXRLayerWrapper: () => Ev, NativeXRRenderTarget: () => xv, NegateBlock: () => Jb, Node: () => oi, NodeGeometry: () => IP, NodeGeometryBlock: () => At, NodeGeometryBlockConnectionPointTypes: () => Q, NodeGeometryBuildState: () => kT, NodeGeometryConnectionPoint: () => K_, NodeGeometryConnectionPointCompatibilityStates: () => xa, NodeGeometryConnectionPointDirection: () => Ml, NodeGeometryContextualSources: () => zt, NodeMaterial: () => ka, NodeMaterialBlock: () => We, NodeMaterialBlockConnectionPointMode: () => mn, NodeMaterialBlockConnectionPointTypes: () => M, NodeMaterialBlockTargets: () => W, NodeMaterialConnectionPoint: () => Ju, NodeMaterialConnectionPointCompatibilityStates: () => Cr, NodeMaterialConnectionPointCustomObject: () => xi, NodeMaterialConnectionPointDirection: () => ui, NodeMaterialDefines: () => gc, NodeMaterialModes: () => kn, NodeMaterialOptimizer: () => uP, NodeMaterialSystemValues: () => Tt, NodeMaterialTeleportInBlock: () => Db, NodeMaterialTeleportOutBlock: () => Nb, NoiseBlock: () => s0, NoiseProceduralTexture: () => sb, NormalBlendBlock: () => hT, NormalizeBlock: () => kb, NormalizeVectorBlock: () => p0, NullBlock: () => ZT, NullEngine: () => zv, NullEngineOptions: () => Gv, Observable: () => H, Observer: () => yt, OcclusionMaterial: () => iP, Octree: () => Rc, OctreeBlock: () => Iv, OctreeSceneComponent: () => vf, OimoJSPlugin: () => A_, OnAfterEnteringVRObservableEvent: () => XR, OneMinusBlock: () => L_, Orientation: () => fs, OutlineRenderer: () => EE, PBRAnisotropicConfiguration: () => s_, PBRBaseMaterial: () => Si, PBRBaseSimpleMaterial: () => M_, PBRClearCoatConfiguration: () => Kc, PBRIridescenceConfiguration: () => qc, PBRMaterial: () => Yh, PBRMaterialDefines: () => u_, PBRMetallicRoughnessBlock: () => gT, PBRMetallicRoughnessMaterial: () => Qy, PBRSheenConfiguration: () => l_, PBRSpecularGlossinessMaterial: () => Zy, PBRSubSurfaceConfiguration: () => c_, PHI: () => gt, PadNumber: () => jm, PanoramaToCubeMapTools: () => E_, Particle: () => j0, ParticleBlendMultiplyBlock: () => Fp, ParticleHelper: () => DP, ParticleRampGradientBlock: () => Np, ParticleSystem: () => Ai, ParticleSystemSet: () => hd, ParticleTextureBlock: () => Dp, ParticlesOptimization: () => yd, PassCubePostProcess: () => wR, PassPostProcess: () => da, Path2: () => Hu, Path3D: () => Xu, PathCursor: () => iR, PerfCollectionStrategy: () => NI, PerfCounter: () => Sn, PerformanceConfigurator: () => Ti, PerformanceMonitor: () => yg, PerformanceViewerCollector: () => KE, PerturbNormalBlock: () => db, PhotoDome: () => wC, Physics6DoFConstraint: () => J0, Physics6DoFLimit: () => zP, PhysicsAggregate: () => QP, PhysicsBody: () => Z0, PhysicsConstraint: () => ts, PhysicsConstraintAxis: () => co, PhysicsConstraintAxisLimitMode: () => ko, PhysicsConstraintMotorType: () => es, PhysicsConstraintType: () => Wn, PhysicsEngine: () => x_, PhysicsEngineV2: () => Q0, PhysicsEventType: () => Wr, PhysicsHelper: () => iI, PhysicsImpostor: () => bt, PhysicsJoint: () => Ii, PhysicsMaterialCombineMode: () => Go, PhysicsMotionType: () => Hr, PhysicsRadialExplosionEventOptions: () => Fl, PhysicsRadialImpulseFalloff: () => uu, PhysicsRaycastResult: () => nu, PhysicsShape: () => zo, PhysicsShapeBox: () => UP, PhysicsShapeCapsule: () => wP, PhysicsShapeContainer: () => GP, PhysicsShapeConvexHull: () => VP, PhysicsShapeCylinder: () => BP, PhysicsShapeMesh: () => kP, PhysicsShapeSphere: () => LP, PhysicsShapeType: () => Bi, PhysicsUpdraftEventOptions: () => tm, PhysicsUpdraftMode: () => Dl, PhysicsViewer: () => Lf, PhysicsVortexEventOptions: () => im, PickingInfo: () => Ki, PipelineErrorReason: () => Xf, PivotTools: () => tr, Plane: () => xo, PlaneBlock: () => zT, PlaneBuilder: () => gR, PlaneDragGizmo: () => Hh, PlaneRotationGizmo: () => Wh, PlayAnimationAction: () => zl, PlaySoundAction: () => jl, PointColor: () => zn, PointLight: () => T_, PointParticleEmitter: () => Vp, PointerDragBehavior: () => Co, PointerEventTypes: () => Le, PointerInfo: () => Sr, PointerInfoBase: () => gp, PointerInfoPre: () => rg, PointerInput: () => at, PointsCloudSystem: () => FP, PointsGroup: () => dd, Polar: () => bP, Polygon: () => iC, PolygonBuilder: () => nC, PolygonMeshBuilder: () => Nv, PolyhedronBuilder: () => lC, PolyhedronData: () => Ph, PositionGizmo: () => py, PositionNormalTextureVertex: () => RR, PositionNormalVertex: () => AR, PostProcess: () => nt, PostProcessManager: () => nc, PostProcessRenderEffect: () => Vt, PostProcessRenderPipeline: () => Ns, PostProcessRenderPipelineManager: () => sE, PostProcessRenderPipelineManagerSceneComponent: () => lE, PostProcessesOptimization: () => gd, PosterizeBlock: () => oT, PowBlock: () => $b, PowerEase: () => ZA, PowerPreference: () => Gf, PrePassOutputBlock: () => Sb, PrePassRenderer: () => _m, PrePassRendererSceneComponent: () => bE, PrePassTextureBlock: () => Ob, PrecisionDate: () => It, PredicateCondition: () => Qr, PressureObserverWrapper: () => YE, PrimitiveTopology: () => rr, PrismaticConstraint: () => KP, ProceduralTexture: () => mc, ProceduralTextureSceneComponent: () => Bg, PropertyTypeForEdition: () => Ye, PushMaterial: () => pl, QuadraticEase: () => hg, QuadraticErrorSimplification: () => LT, QuarticEase: () => JA, Quaternion: () => oe, QueryType: () => kc, QuinticEase: () => $A, RGBDTextureTools: () => Dh, RandomBlock: () => a0, RandomBlockLocks: () => ao, RandomGUID: () => ra, RandomNumberBlock: () => eT, RawCubeTexture: () => aP, RawTexture: () => on, RawTexture2DArray: () => Ky, RawTexture3D: () => sP, Ray: () => gi, RayHelper: () => Vv, ReadFile: () => ol, ReadFileError: () => Jm, RecastJSCrowd: () => G0, RecastJSPlugin: () => MP, ReciprocalBlock: () => nT, ReflectBlock: () => pT, ReflectionBlock: () => V_, ReflectionProbe: () => C_, ReflectionTextureBlock: () => Pb, Reflector: () => MI, RefractBlock: () => fT, RefractionBlock: () => k_, RefractionPostProcess: () => aE, RefractionTexture: () => lP, RegisterClass: () => j, RegisterMaterialPlugin: () => kR, RegisterNativeTypeAsync: () => ry, RemapBlock: () => Lp, RenderPassTimestampLocation: () => Kf, RenderTargetTexture: () => Mi, RenderTargetWrapper: () => dc, RenderTargetsOptimization: () => ym, RenderingGroup: () => ig, RenderingGroupInfo: () => ng, RenderingManager: () => rc, ReplaceColorBlock: () => rT, RequestFile: () => Bu, RequestFileError: () => lp, RetryStrategy: () => Wm, RibbonBuilder: () => QR, RichType: () => Or, RichTypeAny: () => ln, RichTypeBoolean: () => cn, RichTypeColor3: () => rS, RichTypeColor4: () => oS, RichTypeMatrix: () => Ri, RichTypeNumber: () => Ae, RichTypeQuaternion: () => mu, RichTypeString: () => _u, RichTypeVector2: () => $i, RichTypeVector3: () => ii, RichTypeVector4: () => pn, RollingAverage: () => bg, Rotate2dBlock: () => dT, RotationGizmo: () => dy, RotationXBlock: () => g0, RotationYBlock: () => v0, RotationZBlock: () => y0, RuntimeAnimation: () => zm, RuntimeError: () => ia, SSAO2RenderingPipeline: () => uE, SSAORenderingPipeline: () => sI, SSRRenderingPipeline: () => dE, SamplerBindingType: () => ga, Scalar: () => ue, ScaleBlock: () => Lb, ScaleGizmo: () => fy, ScalingBlock: () => b0, Scene: () => Ue, SceneComponentConstants: () => we, SceneDepthBlock: () => Ib, SceneInstrumentation: () => Uy, SceneLoader: () => yi, SceneLoaderAnimationGroupLoadingMode: () => Po, SceneLoaderFlags: () => Jr, SceneOptimization: () => Ho, SceneOptimizer: () => vI, SceneOptimizerOptions: () => bm, ScenePerformancePriority: () => Zr, SceneRecorder: () => AI, SceneSerializer: () => Td, ScreenSizeBlock: () => gb, ScreenSpaceBlock: () => vb, ScreenSpaceCurvaturePostProcess: () => fE, ScreenSpaceReflectionPostProcess: () => pm, ScreenshotTools: () => EI, SerializationHelper: () => Ne, SetColorsBlock: () => t0, SetCorsBehavior: () => wu, SetMaterialIDBlock: () => f0, SetNormalsBlock: () => $T, SetParentAction: () => qs, SetPositionsBlock: () => JT, SetStateAction: () => hn, SetTangentsBlock: () => i0, SetUVsBlock: () => e0, SetValueAction: () => dn, ShaderCodeInliner: () => Bc, ShaderLanguage: () => li, ShaderMaterial: () => dr, ShaderStage: () => _a, ShaderStore: () => re, ShadowDepthWrapper: () => hP, ShadowGenerator: () => ar, ShadowGeneratorSceneComponent: () => Xy, ShadowLight: () => Xh, ShadowMapBlock: () => Eb, ShadowsOptimization: () => md, ShapeBuilder: () => oC, SharpenPostProcess: () => dm, SheenBlock: () => B_, SimplexPerlin3DBlock: () => uT, SimplicationQueueSceneComponent: () => wT, SimplificationQueue: () => FT, SimplificationSettings: () => RP, SimplificationType: () => lu, SineEase: () => Sp, SixDofDragBehavior: () => Ng, Size: () => el, Skeleton: () => oh, SkeletonViewer: () => wf, SliderConstraint: () => jP, SmartArray: () => en, SmartArrayNoDuplicate: () => oa, SmoothStepBlock: () => iT, SolidParticle: () => $_, SolidParticleSystem: () => NP, SolidParticleVertex: () => K0, Sound: () => _s, SoundTrack: () => Pg, SourceTextureFormat: () => d_, Space: () => ht, SphereBlock: () => XT, SphereBuilder: () => KR, SphereDirectedParticleEmitter: () => kp, SphereParticleEmitter: () => ih, Spherical: () => TP, SphericalHarmonics: () => Mh, SphericalPolynomial: () => Sl, SpotLight: () => r_, SpringConstraint: () => qP, Sprite: () => IE, SpriteManager: () => OE, SpriteMap: () => uI, SpritePackedManager: () => hI, SpriteSceneComponent: () => ME, Stage: () => Ni, StandardMaterial: () => Gt, StandardMaterialDefines: () => gv, StandardRenderingPipeline: () => hE, StartsWith: () => Xm, StateCondition: () => as, StencilOperation: () => Vr, StencilState: () => qm, StencilStateComposer: () => ap, StepBlock: () => jb, StereoscopicArcRotateCamera: () => nv, StereoscopicFreeCamera: () => rv, StereoscopicGamepadCamera: () => ov, StereoscopicInterlacePostProcess: () => BR, StereoscopicInterlacePostProcessI: () => iv, StereoscopicScreenUniversalCamera: () => UR, StereoscopicUniversalCamera: () => av, StickValues: () => FR, StopAnimationAction: () => Wl, StopSoundAction: () => mt, StorageBuffer: () => Gg, StorageTextureAccess: () => Vh, StoreOp: () => pr, StringDictionary: () => ku, StringTools: () => UA, SubEmitter: () => cu, SubEmitterType: () => Ol, SubMesh: () => Yn, SubSurfaceBlock: () => ld, SubSurfaceSceneComponent: () => TE, SubtractBlock: () => Xb, SurfaceMagnetismBehavior: () => yR, SwitchBooleanAction: () => kl, SwitchInput: () => _p, TBNBlock: () => su, TGATools: () => eb, Tags: () => Xt, TargetCamera: () => ha, TargetedAnimation: () => dg, TeleportInBlock: () => L0, TeleportOutBlock: () => w0, TestBase64DataUrl: () => $m, TextFileAssetTask: () => LE, Texture: () => ae, TextureAspect: () => no, TextureAssetTask: () => UE, TextureBlock: () => Rb, TextureDimension: () => Ir, TextureFormat: () => U, TextureOptimization: () => _d, TexturePacker: () => oP, TexturePackerFrame: () => N_, TextureSampleType: () => nr, TextureSampler: () => rp, TextureTools: () => Yv, TextureUsage: () => fi, TextureViewDimension: () => ei, ThinEngine: () => Qe, ThinRenderTargetTexture: () => cP, ThinTexture: () => ms, TiledBoxBuilder: () => $R, TiledPlaneBuilder: () => JR, TimerState: () => Qa, TmpColors: () => Ot, TmpVectors: () => F, ToGammaSpace: () => ct, ToHalfFloat: () => to, ToLinearSpace: () => Ht, TonemapPostProcess: () => lI, TonemappingOperator: () => Fs, Tools: () => de, TorusBlock: () => YT, TorusBuilder: () => WR, TorusKnotBuilder: () => eC, TouchCamera: () => cf, TrailMesh: () => NT, Trajectory: () => RI, TrajectoryClassifier: () => II, TranscodeAsync: () => nd, TranscodeTarget: () => Rl, TransformBlock: () => $u, TransformNode: () => ai, TranslationBlock: () => E0, TriPlanarBlock: () => G_, TrigonometryBlock: () => zp, TrigonometryBlockOperations: () => Hi, TubeBuilder: () => sC, TwirlBlock: () => yb, UniformBuffer: () => Er, UniversalCamera: () => Wa, UnregisterAllMaterialPlugins: () => df, UnregisterMaterialPlugin: () => GR, UploadContent: () => O_, UploadEnvLevelsAsync: () => Uf, UploadEnvSpherical: () => Bh, UploadLevelsAsync: () => wc, UtilityLayerRenderer: () => Fi, VRCameraMetrics: () => Sc, VRDeviceOrientationArcRotateCamera: () => uv, VRDeviceOrientationFreeCamera: () => hh, VRDeviceOrientationGamepadCamera: () => hv, VRDistortionCorrectionPostProcess: () => hf, VRExperienceHelper: () => Av, VRMultiviewToSingleviewPostProcess: () => cv, ValidatedNativeDataStream: () => oy, ValueCondition: () => Ys, Vector2: () => fe, Vector3: () => v, Vector4: () => lt, VectorConverterBlock: () => d0, VectorMergerBlock: () => pc, VectorSplitterBlock: () => zb, VertexAnimationBaker: () => fR, VertexBuffer: () => P, VertexData: () => Oe, VertexDataMaterialInfo: () => lc, VertexFormat: () => bi, VertexOutputBlock: () => hc, VertexStepMode: () => Vc, VideoDome: () => KC, VideoRecorder: () => bI, VideoTexture: () => Qh, ViewDirectionBlock: () => w_, Viewport: () => xr, VirtualJoystick: () => sf, VirtualJoysticksCamera: () => sv, VolumetricLightScatteringPostProcess: () => pE, VoronoiNoiseBlock: () => ET, WaveBlock: () => aT, WaveBlockKind: () => Is, WebGL2ParticleSystem: () => W0, WebGL2ShaderProcessor: () => op, WebGLDataBuffer: () => nl, WebGLHardwareTexture: () => ds, WebGLPipelineContext: () => Zm, WebGPUCacheBindGroups: () => cy, WebGPUCacheRenderPipeline: () => sy, WebGPUCacheRenderPipelineTree: () => e_, WebGPUCacheSampler: () => Jf, WebGPUDataBuffer: () => ay, WebGPUDrawContext: () => ly, WebGPUEngine: () => st, WebGPUTintWASM: () => uy, WebRequest: () => _n, WebXRAbstractFeature: () => Qi, WebXRAbstractMotionController: () => Cs, WebXRAnchorSystem: () => Sd, WebXRBackgroundRemover: () => Ad, WebXRCamera: () => Cy, WebXRCompositionLayerWrapper: () => qE, WebXRControllerComponent: () => wo, WebXRControllerMovement: () => Dd, WebXRControllerPhysics: () => Rd, WebXRControllerPointerSelection: () => Zc, WebXRDefaultExperience: () => wy, WebXRDefaultExperienceOptions: () => XC, WebXRDepthSensing: () => Bd, WebXRDomOverlay: () => Od, WebXREnterExitUI: () => Fy, WebXREnterExitUIButton: () => Ny, WebXREnterExitUIOptions: () => HC, WebXRExperienceHelper: () => Py, WebXREyeTracking: () => Fd, WebXRFeatureName: () => vi, WebXRFeaturePointSystem: () => Pd, WebXRFeaturesManager: () => Wi, WebXRGenericHandController: () => $E, WebXRGenericTriggerMotionController: () => __, WebXRHTCViveMotionController: () => tS, WebXRHand: () => Vg, WebXRHandJoint: () => tt, WebXRHandTracking: () => rh, WebXRHitTest: () => Cd, WebXRHitTestLegacy: () => Ed, WebXRImageTracking: () => Md, WebXRInput: () => Dy, WebXRInputSource: () => Oy, WebXRLayers: () => wd, WebXRLightEstimation: () => Nd, WebXRManagedOutputCanvas: () => Tv, WebXRManagedOutputCanvasOptions: () => pf, WebXRMeshDetector: () => Id, WebXRMicrosoftMixedRealityController: () => eS, WebXRMotionControllerManager: () => Qn, WebXRMotionControllerTeleportation: () => $c, WebXRNearControllerMode: () => qa, WebXRNearInteraction: () => Jc, WebXROculusTouchMotionController: () => xm, WebXRPlaneDetector: () => xd, WebXRProfiledMotionController: () => Iy, WebXRProjectionLayerWrapper: () => QE, WebXRRawCameraAccess: () => Vd, WebXRSessionManager: () => ff, WebXRSpaceWarp: () => Ud, WebXRSpaceWarpRenderTargetTextureProvider: () => JE, WebXRState: () => Xi, WebXRTrackingState: () => Ts, WebXRWalkingLocomotion: () => Ld, WeightedSound: () => lR, WorkerPool: () => Sy, WorleyNoise3DBlock: () => cT, XRSpaceWarpRenderTarget: () => ZE, Xbox360Button: () => ir, Xbox360Dpad: () => vs, Xbox360Pad: () => Kg, XboxInput: () => fp, _BabylonLoaderRegistered: () => JC, _BasisTextureLoader: () => ob, _CreationDataStorage: () => Ap, _DDSTextureLoader: () => Ty, _ENVTextureLoader: () => Ey, _HDRTextureLoader: () => ib, _InstancesBatch: () => Rp, _KTXTextureLoader: () => Ry, _MeshCollisionData: () => Tg, _OcclusionDataStorage: () => Hv, _PrimaryIsoTriangle: () => Of, _TGATextureLoader: () => tb, _TimeToken: () => Wv, _UpdateRGBDAsync: () => Zv, _forceSceneHelpersToBundle: () => jC, _forceTransformFeedbackToBundle: () => hC, _injectLTSFileTools: () => eg, _staticOffsetValueColor3: () => Jd, _staticOffsetValueColor4: () => $d, _staticOffsetValueQuaternion: () => Kd, _staticOffsetValueSize: () => Zd, _staticOffsetValueVector2: () => Qd, _staticOffsetValueVector3: () => qd, addClipPlaneUniforms: () => Br, allocateAndCopyTypedBuffer: () => qu, bindClipPlane: () => Ar, captureEquirectangularFromScene: () => FI, className: () => HA, createDetailMapPlugin: () => vP, createPBRAnisotropicPlugin: () => dP, createPBRBRDFPlugin: () => pP, createPBRClearCoatPlugin: () => fP, createPBRIridescencePlugin: () => _P, createPBRSheenPlugin: () => mP, createPBRSubSurfacePlugin: () => gP, createYieldingScheduler: () => fg, editableInPropertyPage: () => qe, expandToProperty: () => ye, extractMinAndMax: () => hl, extractMinAndMaxIndexed: () => vg, getRichTypeFromValue: () => aS, inlineScheduler: () => sc, makeAsyncFunction: () => rR, makeSyncFunction: () => _g, nativeOverride: () => ea, normalizeEnvInfo: () => Lc, prepareDefinesForClipPlanes: () => Eg, prepareStringDefinesForClipPlanes: () => aa, runCoroutine: () => xp, runCoroutineAsync: () => Yu, runCoroutineSync: () => ju, serialize: () => N, serializeAsCameraReference: () => Ql, serializeAsColor3: () => ri, serializeAsColor4: () => ls, serializeAsColorCurves: () => Kl, serializeAsFresnelParameters: () => Jo, serializeAsImageProcessingConfiguration: () => $s, serializeAsMatrix: () => cs, serializeAsMeshReference: () => $o, serializeAsQuaternion: () => ql, serializeAsTexture: () => St, serializeAsVector2: () => ss, serializeAsVector3: () => ki, setAndStartTimer: () => m_, setStereoscopicAnaglyphRigMode: () => Tc, setStereoscopicRigMode: () => Ec, setVRRigMode: () => uh });
    var be = {};
    G.r(be), G.d(be, { AbstractActionManager: () => Ee, AbstractAssetTask: () => uo, AbstractMesh: () => Dt, AbstractScene: () => pe, AcquireNativeObjectAsync: () => ny, Action: () => wt, ActionEvent: () => mi, ActionManager: () => Qs, AddBlock: () => Fb, AddressMode: () => As, AdvancedTimer: () => Ly, AlignBlock: () => T0, AlphaState: () => Qm, AmmoJSPlugin: () => R_, AnaglyphArcRotateCamera: () => Jg, AnaglyphFreeCamera: () => $g, AnaglyphGamepadCamera: () => ev, AnaglyphPostProcess: () => uf, AnaglyphUniversalCamera: () => tv, Analyser: () => sR, AndOrNotEvaluator: () => Vi, Angle: () => ac, Animatable: () => Tp, AnimatedInputBlockTypes: () => sa, Animation: () => Je, AnimationAssetTask: () => dI, AnimationEvent: () => tR, AnimationGroup: () => pg, AnimationGroupMask: () => nR, AnimationGroupMaskMode: () => oc, AnimationKeyInterpolation: () => Ou, AnimationPropertiesOverride: () => YA, AnimationRange: () => Zl, AnisotropyBlock: () => U_, ApplyPostProcess: () => Oh, Arc2: () => sg, ArcFollowCamera: () => Yg, ArcRotateCamera: () => gs, ArcRotateCameraGamepadInput: () => Hp, ArcRotateCameraInputsManager: () => sh, ArcRotateCameraKeyboardMoveInput: () => Xp, ArcRotateCameraMouseWheelInput: () => jp, ArcRotateCameraPointersInput: () => Yp, ArcRotateCameraVRDeviceOrientationInput: () => Kp, ArcTan2Block: () => tT, AssetContainer: () => Rg, AssetTaskState: () => Wo, AssetsManager: () => pI, AssetsProgressEvent: () => DE, AsyncLoop: () => So, AttachToBoxBehavior: () => _R, AudioEngine: () => Cg, AudioSceneComponent: () => Rr, AutoLayoutMode: () => xl, AutoReleaseWorkerPool: () => p_, AutoRotationBehavior: () => Ig, AxesViewer: () => yl, Axis: () => qi, AxisDragGizmo: () => Fo, AxisScaleGizmo: () => Hc, BRDFTextureTools: () => BC, BabylonFileLoaderConfiguration: () => id, BackEase: () => cg, BackgroundMaterial: () => jc, BakedVertexAnimationManager: () => cR, BallAndSocketConstraint: () => WP, BaseCameraMouseWheelInput: () => zg, BaseCameraPointersInput: () => Wp, BaseError: () => il, BaseParticleSystem: () => fc, BaseSixDofDragBehavior: () => Ip, BaseTexture: () => Vn, BasisTools: () => od, BasisToolsOptions: () => Ta, BasisTranscodeConfiguration: () => rP, BezierCurve: () => ag, BezierCurveEase: () => eR, BiPlanarBlock: () => xT, BinaryFileAssetTask: () => wE, BlackAndWhitePostProcess: () => $0, BlendFactor: () => An, BlendOperation: () => va, BloomEffect: () => om, BloomMergePostProcess: () => rm, BlurPostProcess: () => Cn, Bone: () => Wu, BoneAxesViewer: () => yf, BoneIKController: () => DR, BoneLookController: () => NR, BonesBlock: () => lb, BooleanGeometryBlock: () => k0, BooleanGeometryOperations: () => lo, BounceEase: () => KA, BouncingBehavior: () => Mg, BoundingBlock: () => V0, BoundingBox: () => cl, BoundingBoxGizmo: () => hy, BoundingBoxRenderer: () => _E, BoundingInfo: () => wr, BoundingSphere: () => ul, BoxBlock: () => Q_, BoxBuilder: () => YR, BoxParticleEmitter: () => _l, Buffer: () => Yi, BufferBindingType: () => ma, BufferMapState: () => zf, BufferUsage: () => $t, CSG: () => X_, Camera: () => dt, CameraGizmo: () => LC, CameraInputTypes: () => gn, CameraInputsManager: () => yc, CannonJSPlugin: () => td, CanvasAlphaMode: () => Gc, CapsuleBlock: () => qT, CapsuleBuilder: () => qR, CascadedShadowGenerator: () => b_, ChromaticAberrationPostProcess: () => am, CircleEase: () => lg, CircleOfConfusionPostProcess: () => sm, ClampBlock: () => wb, ClearCoatBlock: () => sd, ClipPlanesBlock: () => Mb, ClipboardEventTypes: () => zh, ClipboardInfo: () => OC, CloudBlock: () => TT, CloudPoint: () => q0, Collider: () => Rv, Color3: () => ne, Color3Gradient: () => X0, Color4: () => Ie, ColorCorrectionPostProcess: () => eE, ColorCurves: () => tc, ColorGradient: () => Z_, ColorGradingTexture: () => Jy, ColorMergerBlock: () => Gb, ColorSplitterBlock: () => Gp, ColorWrite: () => jf, CombineAction: () => Hl, CompareFunction: () => an, CompatibilityOptions: () => Lt, CompilationMessageType: () => Hf, CompleteGreasedLineColorTable: () => VT, CompleteGreasedLineWidthTable: () => UT, ComputeBindingType: () => di, ComputeEffect: () => Pv, ComputeNormalsBlock: () => h0, ComputePassTimestampLocation: () => Yf, ComputeShader: () => gf, ComputeShaderParticleSystem: () => H0, Condition: () => Jn, ConditionBlock: () => o0, ConditionBlockTests: () => Ji, ConditionalBlock: () => bT, ConditionalBlockConditions: () => fr, ConeParticleEmitter: () => wp, Constants: () => _, ContainerAssetTask: () => NE, ConversionMode: () => fd, ConvolutionPostProcess: () => tE, Coordinate: () => Ua, CopyTextureToTexture: () => RE, CopyTools: () => uR, CreateBox: () => Ur, CreateBoxVertexData: () => yh, CreateCapsule: () => Ic, CreateCapsuleVertexData: () => Th, CreateCylinder: () => Fn, CreateCylinderVertexData: () => gh, CreateDashedLines: () => xh, CreateDashedLinesVertexData: () => Pf, CreateDecal: () => Ch, CreateDisc: () => bl, CreateDiscVertexData: () => Eh, CreateEnvTextureAsync: () => Qv, CreateGeodesic: () => Fv, CreateGoldberg: () => wv, CreateGoldbergVertexData: () => Lv, CreateGreasedLine: () => PP, CreateGreasedLineMaterial: () => BT, CreateGround: () => vl, CreateGroundFromHeightMap: () => _h, CreateGroundFromHeightMapVertexData: () => mf, CreateGroundVertexData: () => Do, CreateHemisphere: () => Xc, CreateIcoSphere: () => vc, CreateIcoSphereVertexData: () => nh, CreateImageDataArrayBufferViews: () => wh, CreateLathe: () => Ah, CreateLineSystem: () => Ss, CreateLineSystemVertexData: () => Cf, CreateLines: () => si, CreatePlane: () => Ro, CreatePlaneVertexData: () => Zu, CreatePolygon: () => Mc, CreatePolygonVertexData: () => If, CreatePolyhedron: () => xs, CreatePolyhedronVertexData: () => Mf, CreateResizedCopy: () => Xv, CreateRibbon: () => pa, CreateRibbonVertexData: () => Tf, CreateScreenshot: () => du, CreateScreenshotAsync: () => Tm, CreateScreenshotUsingRenderTarget: () => pu, CreateScreenshotUsingRenderTargetAsync: () => Em, CreateScreenshotWithResizeAsync: () => XE, CreateSegmentedBoxVertexData: () => Mv, CreateSphere: () => yn, CreateSphereVertexData: () => bh, CreateText: () => Bv, CreateTextShapePaths: () => Ff, CreateTiledBox: () => xf, CreateTiledBoxVertexData: () => Sf, CreateTiledGround: () => fh, CreateTiledGroundVertexData: () => _f, CreateTiledPlane: () => Ef, CreateTiledPlaneVertexData: () => Tl, CreateTorus: () => eo, CreateTorusKnot: () => Sh, CreateTorusKnotVertexData: () => Af, CreateTorusVertexData: () => mh, CreateTube: () => Rh, CrossBlock: () => Bb, CubeMapToSphericalPolynomialTools: () => Nh, CubeTexture: () => Gr, CubeTextureAssetTask: () => VE, CubicEase: () => qA, CullMode: () => Al, CurrentScreenBlock: () => Op, Curve3: () => Ep, CurveBlock: () => PT, CurveBlockTypes: () => pi, CustomBlock: () => Ub, CustomOptimization: () => zE, CustomParticleEmitter: () => ml, CustomProceduralTexture: () => ab, CylinderBlock: () => KT, CylinderBuilder: () => jR, CylinderDirectedParticleEmitter: () => Bp, CylinderParticleEmitter: () => th, DDSTools: () => Ka, DataBuffer: () => wa, DataReader: () => SI, DataStorage: () => xI, Database: () => z0, Debug: () => JN, DebugBlock: () => O0, DebugLayer: () => bf, DebugLayerTab: () => vh, DecalBuilder: () => uC, DecalMapConfiguration: () => cd, DecalMapDefines: () => IT, Decode: () => ep, DecodeBase64ToBinary: () => Nu, DecodeBase64ToString: () => Du, DecodeBase64UrlToBinary: () => Vu, DecodeBase64UrlToString: () => up, DeepCopier: () => Ui, DefaultCollisionCoordinator: () => Cv, DefaultKTX2DecoderOptions: () => Ay, DefaultLoadingScreen: () => jy, DefaultRenderingPipeline: () => cE, Deferred: () => fI, DepthCullingState: () => np, DepthOfFieldBlurPostProcess: () => pd, DepthOfFieldEffect: () => lm, DepthOfFieldEffectBlurLevel: () => Ds, DepthOfFieldMergePostProcess: () => iE, DepthPeelingRenderer: () => gE, DepthPeelingSceneComponent: () => vE, DepthReducer: () => Hy, DepthRenderer: () => tu, DepthRendererSceneComponent: () => mE, DepthSortedParticle: () => Y0, DerivativeBlock: () => _b, DesaturateBlock: () => _T, DetailMapConfiguration: () => dh, DeviceInputEventType: () => mp, DeviceLostReason: () => qf, DeviceOrientationCamera: () => lh, DeviceSource: () => yp, DeviceSourceManager: () => og, DeviceType: () => Ze, DirectionalLight: () => jh, DirectionalLightFrustumViewer: () => kv, DiscBlock: () => QT, DiscBuilder: () => ZR, DiscardBlock: () => pb, DisplayPassPostProcess: () => nE, DistanceBlock: () => Qb, DistanceConstraint: () => HP, DistanceJoint: () => TR, DivideBlock: () => Hb, DoNothingAction: () => Ks, DomManagement: () => BA, DotBlock: () => Vb, DracoCompression: () => EP, DrawWrapper: () => Ei, DualSenseInput: () => pp, DualShockButton: () => Pr, DualShockDpad: () => ys, DualShockInput: () => dp, DualShockPad: () => qg, DumpTools: () => la, DynamicFloat32Array: () => Aa, DynamicTexture: () => Es, EasingFunction: () => xn, EdgesRenderer: () => fm, Effect: () => Jt, EffectFallbacks: () => Va, EffectLayer: () => eu, EffectLayerSceneComponent: () => Vy, EffectRenderer: () => _c, EffectWrapper: () => Io, ElasticEase: () => QA, ElbowBlock: () => ST, EncodeArrayBufferToBase64: () => $l, EndsWith: () => Hm, Engine: () => ve, EngineFactory: () => MC, EngineFormat: () => Kh, EngineInstrumentation: () => By, EngineStore: () => Me, EngineView: () => dC, EnvironmentHelper: () => a_, EnvironmentTextureTools: () => gC, Epsilon: () => Ge, EquiRectangularCubeTexture: () => $y, EquiRectangularCubeTextureAssetTask: () => GE, ErrorCodes: () => ta, ErrorFilter: () => Qf, EventConstants: () => zu, EventState: () => Xe, ExecuteCodeAction: () => Xl, ExponentialEase: () => ug, ExternalTexture: () => t_, ExtractHighlightsPostProcess: () => nm, ExtrudePolygon: () => Oc, ExtrudeShape: () => Dc, ExtrudeShapeCustom: () => Nc, FactorGradient: () => J_, FadeInOutBehavior: () => mR, FeatureName: () => Lo, FileTools: () => al, FileToolsOptions: () => zi, FilesInput: () => mI, FilesInputStore: () => tl, FilterMode: () => Ct, FilterPostProcess: () => rE, FlowGraph: () => Rm, FlowGraphACosNumberBlock: () => gx, FlowGraphASinNumberBlock: () => mx, FlowGraphATan2NumberBlock: () => Tx, FlowGraphATanNumberBlock: () => vx, FlowGraphAbsNumberBlock: () => nx, FlowGraphAddMatrixAndNumberBlock: () => hA, FlowGraphAddMatrixBlock: () => uA, FlowGraphAddNumberBlock: () => KS, FlowGraphAddVector2Block: () => Ox, FlowGraphAddVector3Block: () => Gx, FlowGraphAddVector4Block: () => eA, FlowGraphBitwiseAndBlock: () => BS, FlowGraphBitwiseLeftShiftBlock: () => GS, FlowGraphBitwiseNotBlock: () => kS, FlowGraphBitwiseOrBlock: () => US, FlowGraphBitwiseRightShiftBlock: () => zS, FlowGraphBitwiseXorBlock: () => VS, FlowGraphBlock: () => bn, FlowGraphBranchBlock: () => _S, FlowGraphCeilNumberBlock: () => ax, FlowGraphClampMatrixBlock: () => vA, FlowGraphComposeMatrixBlock: () => bA, FlowGraphConditionalDataBlock: () => DS, FlowGraphConstantBlock: () => LS, FlowGraphContext: () => Am, FlowGraphContextLogger: () => GI, FlowGraphCoordinateTransformBlock: () => FS, FlowGraphCoordinator: () => kI, FlowGraphCosNumberBlock: () => fx, FlowGraphCountLeadingZerosBlock: () => WS, FlowGraphCountTrailingZerosBlock: () => HS, FlowGraphCounterBlock: () => SS, FlowGraphCreateVector2Block: () => Ux, FlowGraphCreateVector3Block: () => Qx, FlowGraphCreateVector4Block: () => lA, FlowGraphCrossVector3Block: () => qx, FlowGraphDebounceBlock: () => AS, FlowGraphDecomposeMatrixBlock: () => yA, FlowGraphDivideMatrixAndNumberBlock: () => mA, FlowGraphDivideMatrixBlock: () => _A, FlowGraphDivideNumberBlock: () => ZS, FlowGraphDivideVector2Block: () => Fx, FlowGraphDivideVector3Block: () => Hx, FlowGraphDivideVector4Block: () => nA, FlowGraphDoNBlock: () => mS, FlowGraphDotVector3Block: () => Kx, FlowGraphENumberBlock: () => yx, FlowGraphEqualsNumberBlock: () => Ax, FlowGraphEventBlock: () => Ll, FlowGraphExecutionBlock: () => po, FlowGraphExpNumberBlock: () => cx, FlowGraphFlipFlopBlock: () => RS, FlowGraphFloorNumberBlock: () => ox, FlowGraphForLoopBlock: () => gS, FlowGraphGetTransformationMatrixBlock: () => EA, FlowGraphGetVariableBlock: () => NS, FlowGraphGreaterThanNumberBlock: () => Rx, FlowGraphGreaterThanOrEqualsNumberBlock: () => Cx, FlowGraphIsInfinityNumberBlock: () => tx, FlowGraphIsNaNNumberBlock: () => ex, FlowGraphLengthVector2Block: () => wx, FlowGraphLengthVector3Block: () => jx, FlowGraphLengthVector4Block: () => oA, FlowGraphLessThanNumberBlock: () => Px, FlowGraphLessThanOrEqualsNumberBlock: () => Ix, FlowGraphLnNumberBlock: () => dx, FlowGraphLog10NumberBlock: () => ux, FlowGraphLogBlock: () => uS, FlowGraphLogNumberBlock: () => hx, FlowGraphLogicAndBlock: () => XS, FlowGraphLogicNotBlock: () => YS, FlowGraphLogicOrBlock: () => jS, FlowGraphMaxNumberBlock: () => xx, FlowGraphMeshPickEventBlock: () => SA, FlowGraphMinNumberBlock: () => Sx, FlowGraphMixNumberBlock: () => Mx, FlowGraphModNumberBlock: () => JS, FlowGraphMultiGateBlock: () => bS, FlowGraphMultiplyMatrixBlock: () => fA, FlowGraphMultiplyNumberBlock: () => QS, FlowGraphMultiplyVector2Block: () => Nx, FlowGraphMultiplyVector3Block: () => Wx, FlowGraphMultiplyVector4Block: () => iA, FlowGraphNegateNumberBlock: () => rx, FlowGraphNormalizeVector2Block: () => Bx, FlowGraphNormalizeVector3Block: () => Yx, FlowGraphNormalizeVector4Block: () => sA, FlowGraphPath: () => cS, FlowGraphPauseAnimationBlock: () => IS, FlowGraphPiNumberBlock: () => bx, FlowGraphPlayAnimationBlock: () => CS, FlowGraphPlayAudioBlock: () => MS, FlowGraphPowNumberBlock: () => $S, FlowGraphQuaternionToRotationMatrixBlock: () => TA, FlowGraphRandomNumberBlock: () => Ex, FlowGraphReceiveCustomEventBlock: () => AA, FlowGraphRotate2dVector2Block: () => kx, FlowGraphRotate3dVector3Block: () => Jx, FlowGraphRoundNumberBlock: () => sx, FlowGraphScaleMatrixBlock: () => gA, FlowGraphScaleVector2Block: () => Lx, FlowGraphScaleVector3Block: () => Xx, FlowGraphScaleVector4Block: () => rA, FlowGraphSceneReadyEventBlock: () => xA, FlowGraphSceneTickEventBlock: () => RA, FlowGraphSendCustomEventBlock: () => fS, FlowGraphSetPropertyBlock: () => pS, FlowGraphSetVariableBlock: () => hS, FlowGraphSignalConnection: () => kd, FlowGraphSinNumberBlock: () => px, FlowGraphSplitVector2Block: () => Vx, FlowGraphSplitVector3Block: () => Zx, FlowGraphSplitVector4Block: () => cA, FlowGraphSqrtNumberBlock: () => ix, FlowGraphState: () => is, FlowGraphStopAnimationBlock: () => PS, FlowGraphStopAudioBlock: () => OS, FlowGraphSubtractMatrixAndNumberBlock: () => pA, FlowGraphSubtractMatrixBlock: () => dA, FlowGraphSubtractNumberBlock: () => qS, FlowGraphSubtractVector2Block: () => Dx, FlowGraphSubtractVector3Block: () => zx, FlowGraphSubtractVector4Block: () => tA, FlowGraphSwitchBlock: () => TS, FlowGraphTanNumberBlock: () => _x, FlowGraphThrottleBlock: () => vS, FlowGraphTimerBlock: () => yS, FlowGraphTransformVector3Block: () => $x, FlowGraphTruncNumberBlock: () => lx, FlowGraphWaitAllBlock: () => ES, FlowGraphWhileLoopBlock: () => xS, FluidRenderer: () => PE, FluidRendererSceneComponent: () => CE, FluidRenderingDebug: () => gr, FluidRenderingObject: () => mm, FluidRenderingObjectCustomParticles: () => AE, FluidRenderingObjectParticleSystem: () => SE, FluidRenderingTargetRenderer: () => gm, FlyCamera: () => LR, FlyCameraInputsManager: () => Hg, FlyCameraKeyboardInput: () => qp, FlyCameraMouseInput: () => Qp, FogBlock: () => xb, FollowBehavior: () => bR, FollowCamera: () => jg, FollowCameraInputsManager: () => Xg, FollowCameraKeyboardMoveInput: () => Zp, FollowCameraMouseWheelInput: () => Jp, FollowCameraPointersInput: () => $p, FragCoordBlock: () => mb, FragDepthBlock: () => Tb, FragmentOutputBlock: () => fl, FramingBehavior: () => Og, FreeCamera: () => Oo, FreeCameraDeviceOrientationInput: () => of, FreeCameraGamepadInput: () => af, FreeCameraInputsManager: () => bc, FreeCameraKeyboardMoveInput: () => ef, FreeCameraMouseInput: () => tf, FreeCameraMouseWheelInput: () => nf, FreeCameraTouchInput: () => rf, FreeCameraVirtualJoystickInput: () => lf, FresnelBlock: () => Yb, FresnelParameters: () => qy, FromHalfFloat: () => io, FrontFace: () => Uc, FrontFacingBlock: () => fb, Frustum: () => ll, FxaaPostProcess: () => hu, GPUParticleSystem: () => Os, GUID: () => WA, Gamepad: () => qn, GamepadCamera: () => ch, GamepadManager: () => Qg, GamepadSystemSceneComponent: () => Zg, GenerateBase64StringFromPixelData: () => Qu, GenerateBase64StringFromTexture: () => Cp, GenerateBase64StringFromTextureAsync: () => Pp, GenericPad: () => Wg, GeodesicData: () => Df, Geometry: () => er, GeometryBufferRenderer: () => mr, GeometryBufferRendererSceneComponent: () => oE, GeometryCollectionBlock: () => c0, GeometryElbowBlock: () => u0, GeometryInfoBlock: () => D0, GeometryInputBlock: () => Di, GeometryOptimizeBlock: () => GT, GeometryOutputBlock: () => q_, GeometryTextureBlock: () => B0, GeometryTextureFetchBlock: () => U0, GeometryTransformBlock: () => m0, GeometryTrigonometryBlock: () => _0, GeometryTrigonometryBlockOperations: () => Wt, GetClass: () => Kt, GetDOMTextContent: () => Jl, GetEnvInfo: () => Lh, GetEnvironmentBRDFTexture: () => Yc, GetInternalFormatFromBasisFormat: () => nb, GetTGAHeader: () => au, GetTextureDataAsync: () => jv, Gizmo: () => vn, GizmoAnchorPoint: () => Cc, GizmoCoordinatesMode: () => Ha, GizmoManager: () => DC, GlowLayer: () => Zh, GoldbergMesh: () => Nf, GradientBlock: () => sT, GradientBlockColorStep: () => ad, GradientHelper: () => sr, GrainPostProcess: () => cm, GreasedLineBaseMesh: () => j_, GreasedLineMaterialDefaults: () => Pn, GreasedLineMesh: () => Y_, GreasedLineMeshColorDistribution: () => Vo, GreasedLineMeshColorDistributionType: () => Uo, GreasedLineMeshColorMode: () => _r, GreasedLineMeshMaterialType: () => Cl, GreasedLineMeshWidthDistribution: () => Sa, GreasedLinePluginMaterial: () => Pl, GreasedLineRibbonAutoDirectionMode: () => $a, GreasedLineRibbonFacesMode: () => Il, GreasedLineRibbonMesh: () => ud, GreasedLineRibbonPointsMode: () => zr, GreasedLineSimpleMaterial: () => z_, GreasedLineTools: () => Oi, GridBlock: () => jT, GroundBuilder: () => zR, GroundMesh: () => ph, HDRCubeTexture: () => $h, HDRCubeTextureAssetTask: () => kE, HDRFiltering: () => S_, HDRTools: () => Jh, HandConstraintBehavior: () => OR, HandConstraintOrientation: () => ua, HandConstraintVisibility: () => za, HandConstraintZone: () => Ga, HandPart: () => ca, HardwareScalingOptimization: () => vm, HavokPlugin: () => tI, HeightToNormalBlock: () => bb, HemisphereBuilder: () => NC, HemisphericLight: () => Pc, HemisphericParticleEmitter: () => Up, HighlightLayer: () => g_, HighlightsPostProcess: () => rI, Hinge2Joint: () => SR, HingeConstraint: () => XP, HingeJoint: () => ER, HtmlElementTexture: () => nP, IFlowGraphCoordinatorConfiguration: () => VI, IWebXRControllerPhysicsOptions: () => LI, IcoSphereBlock: () => HT, IcoSphereBuilder: () => MR, ImageAssetTask: () => BE, ImageProcessingBlock: () => hb, ImageProcessingConfiguration: () => tn, ImageProcessingConfigurationDefines: () => tg, ImageProcessingPostProcess: () => um, ImageSourceBlock: () => Bo, IncrementValueAction: () => Gl, IndexFormat: () => ya, InputBlock: () => vt, InspectableType: () => Sm, InstancedLinesMesh: () => Rf, InstancedMesh: () => dl, InstancesBlock: () => cb, InstantiateBlock: () => C0, InstantiateLinearBlock: () => P0, InstantiateOnFacesBlock: () => x0, InstantiateOnVerticesBlock: () => S0, InstantiateOnVolumeBlock: () => A0, InstantiateRadialBlock: () => I0, InstantiatedEntries: () => Ag, IntFloatConverterBlock: () => M0, InternalTexture: () => Ut, InternalTextureSource: () => ut, InterpolateValueAction: () => Gm, IntersectionInfo: () => Ku, IsBase64DataUrl: () => Uu, IsDocumentAvailable: () => hs, IsFileURL: () => cp, IsNavigatorAvailable: () => us, IsWindowObjectExist: () => Gi, JoystickAxis: () => Zi, KeepAssets: () => xg, KeyboardEventTypes: () => ps, KeyboardInfo: () => Gu, KeyboardInfoPre: () => vp, KhronosTextureContainer: () => qh, KhronosTextureContainer2: () => f_, LatheBuilder: () => aC, Layer: () => QC, LayerSceneComponent: () => ky, LengthBlock: () => Zb, LensFlare: () => Gy, LensFlareSystem: () => v_, LensFlareSystemSceneComponent: () => zy, LensFlaresOptimization: () => vd, LensRenderingPipeline: () => aI, LerpBlock: () => Wb, Light: () => Kn, LightBlock: () => Ab, LightGizmo: () => FC, LightInformationBlock: () => ub, LineEdgesRenderer: () => yE, LinesBuilder: () => tC, LinesMesh: () => El, LoadFile: () => na, LoadFileError: () => sp, LoadImage: () => rl, LoadOp: () => ji, LoadTextureFromTranscodeResult: () => rd, LockConstraint: () => YP, Logger: () => q, MapMode: () => Ya, MapRangeBlock: () => r0, MappingBlock: () => N0, MappingTypes: () => so, Material: () => Et, MaterialAnisotropicDefines: () => gy, MaterialClearCoatDefines: () => _y, MaterialDefines: () => jn, MaterialDetailMapDefines: () => _v, MaterialFlags: () => Pe, MaterialGreasedLineDefines: () => MT, MaterialHelper: () => Se, MaterialIridescenceDefines: () => my, MaterialPluginBase: () => $r, MaterialPluginEvent: () => rn, MaterialPluginManager: () => dv, MaterialSheenDefines: () => vy, MaterialSubSurfaceDefines: () => yy, MathBlock: () => n0, MathBlockOperations: () => Gn, Matrix: () => B, MatrixBuilderBlock: () => yT, MatrixComposeBlock: () => F0, MatrixDeterminantBlock: () => AT, MatrixTransposeBlock: () => RT, MaxBlock: () => Kb, MergeGeometryBlock: () => l0, MergeMeshesOptimization: () => bd, Mesh: () => ie, MeshAssetTask: () => FE, MeshAttributeExistsBlock: () => CT, MeshAttributeExistsBlockTypes: () => ti, MeshBlock: () => WT, MeshBuilder: () => Uv, MeshDebugMode: () => Ms, MeshDebugPluginMaterial: () => OT, MeshExploder: () => _I, MeshLODLevel: () => Sg, MeshParticleEmitter: () => Lg, MeshUVSpaceRenderer: () => AP, MeshoptCompression: () => SP, MinBlock: () => qb, MinMaxReducer: () => Wy, MipmapFilterMode: () => Wf, MirrorTexture: () => o_, ModBlock: () => vT, ModelShape: () => em, MorphTarget: () => Yy, MorphTargetManager: () => ed, MorphTargetsBlock: () => F_, MotionBlurPostProcess: () => hm, MotorEnabledJoint: () => Mp, MultiMaterial: () => Ao, MultiObserver: () => gI, MultiPointerScaleBehavior: () => vR, MultiRenderTarget: () => Ja, MultiplyBlock: () => eh, NLerpBlock: () => lT, NativeDataStream: () => Ih, NativeEngine: () => kf, NativePointerInput: () => ic, NativeXRFrame: () => iS, NativeXRLayerRenderTargetTextureProvider: () => Sv, NativeXRLayerWrapper: () => Ev, NativeXRRenderTarget: () => xv, NegateBlock: () => Jb, Node: () => oi, NodeGeometry: () => IP, NodeGeometryBlock: () => At, NodeGeometryBlockConnectionPointTypes: () => Q, NodeGeometryBuildState: () => kT, NodeGeometryConnectionPoint: () => K_, NodeGeometryConnectionPointCompatibilityStates: () => xa, NodeGeometryConnectionPointDirection: () => Ml, NodeGeometryContextualSources: () => zt, NodeMaterial: () => ka, NodeMaterialBlock: () => We, NodeMaterialBlockConnectionPointMode: () => mn, NodeMaterialBlockConnectionPointTypes: () => M, NodeMaterialBlockTargets: () => W, NodeMaterialConnectionPoint: () => Ju, NodeMaterialConnectionPointCompatibilityStates: () => Cr, NodeMaterialConnectionPointCustomObject: () => xi, NodeMaterialConnectionPointDirection: () => ui, NodeMaterialDefines: () => gc, NodeMaterialModes: () => kn, NodeMaterialOptimizer: () => uP, NodeMaterialSystemValues: () => Tt, NodeMaterialTeleportInBlock: () => Db, NodeMaterialTeleportOutBlock: () => Nb, NoiseBlock: () => s0, NoiseProceduralTexture: () => sb, NormalBlendBlock: () => hT, NormalizeBlock: () => kb, NormalizeVectorBlock: () => p0, NullBlock: () => ZT, NullEngine: () => zv, NullEngineOptions: () => Gv, Observable: () => H, Observer: () => yt, OcclusionMaterial: () => iP, Octree: () => Rc, OctreeBlock: () => Iv, OctreeSceneComponent: () => vf, OimoJSPlugin: () => A_, OnAfterEnteringVRObservableEvent: () => XR, OneMinusBlock: () => L_, Orientation: () => fs, OutlineRenderer: () => EE, PBRAnisotropicConfiguration: () => s_, PBRBaseMaterial: () => Si, PBRBaseSimpleMaterial: () => M_, PBRClearCoatConfiguration: () => Kc, PBRIridescenceConfiguration: () => qc, PBRMaterial: () => Yh, PBRMaterialDefines: () => u_, PBRMetallicRoughnessBlock: () => gT, PBRMetallicRoughnessMaterial: () => Qy, PBRSheenConfiguration: () => l_, PBRSpecularGlossinessMaterial: () => Zy, PBRSubSurfaceConfiguration: () => c_, PHI: () => gt, PadNumber: () => jm, PanoramaToCubeMapTools: () => E_, Particle: () => j0, ParticleBlendMultiplyBlock: () => Fp, ParticleHelper: () => DP, ParticleRampGradientBlock: () => Np, ParticleSystem: () => Ai, ParticleSystemSet: () => hd, ParticleTextureBlock: () => Dp, ParticlesOptimization: () => yd, PassCubePostProcess: () => wR, PassPostProcess: () => da, Path2: () => Hu, Path3D: () => Xu, PathCursor: () => iR, PerfCollectionStrategy: () => NI, PerfCounter: () => Sn, PerformanceConfigurator: () => Ti, PerformanceMonitor: () => yg, PerformanceViewerCollector: () => KE, PerturbNormalBlock: () => db, PhotoDome: () => wC, Physics6DoFConstraint: () => J0, Physics6DoFLimit: () => zP, PhysicsAggregate: () => QP, PhysicsBody: () => Z0, PhysicsConstraint: () => ts, PhysicsConstraintAxis: () => co, PhysicsConstraintAxisLimitMode: () => ko, PhysicsConstraintMotorType: () => es, PhysicsConstraintType: () => Wn, PhysicsEngine: () => x_, PhysicsEngineV2: () => Q0, PhysicsEventType: () => Wr, PhysicsHelper: () => iI, PhysicsImpostor: () => bt, PhysicsJoint: () => Ii, PhysicsMaterialCombineMode: () => Go, PhysicsMotionType: () => Hr, PhysicsRadialExplosionEventOptions: () => Fl, PhysicsRadialImpulseFalloff: () => uu, PhysicsRaycastResult: () => nu, PhysicsShape: () => zo, PhysicsShapeBox: () => UP, PhysicsShapeCapsule: () => wP, PhysicsShapeContainer: () => GP, PhysicsShapeConvexHull: () => VP, PhysicsShapeCylinder: () => BP, PhysicsShapeMesh: () => kP, PhysicsShapeSphere: () => LP, PhysicsShapeType: () => Bi, PhysicsUpdraftEventOptions: () => tm, PhysicsUpdraftMode: () => Dl, PhysicsViewer: () => Lf, PhysicsVortexEventOptions: () => im, PickingInfo: () => Ki, PipelineErrorReason: () => Xf, PivotTools: () => tr, Plane: () => xo, PlaneBlock: () => zT, PlaneBuilder: () => gR, PlaneDragGizmo: () => Hh, PlaneRotationGizmo: () => Wh, PlayAnimationAction: () => zl, PlaySoundAction: () => jl, PointColor: () => zn, PointLight: () => T_, PointParticleEmitter: () => Vp, PointerDragBehavior: () => Co, PointerEventTypes: () => Le, PointerInfo: () => Sr, PointerInfoBase: () => gp, PointerInfoPre: () => rg, PointerInput: () => at, PointsCloudSystem: () => FP, PointsGroup: () => dd, Polar: () => bP, Polygon: () => iC, PolygonBuilder: () => nC, PolygonMeshBuilder: () => Nv, PolyhedronBuilder: () => lC, PolyhedronData: () => Ph, PositionGizmo: () => py, PositionNormalTextureVertex: () => RR, PositionNormalVertex: () => AR, PostProcess: () => nt, PostProcessManager: () => nc, PostProcessRenderEffect: () => Vt, PostProcessRenderPipeline: () => Ns, PostProcessRenderPipelineManager: () => sE, PostProcessRenderPipelineManagerSceneComponent: () => lE, PostProcessesOptimization: () => gd, PosterizeBlock: () => oT, PowBlock: () => $b, PowerEase: () => ZA, PowerPreference: () => Gf, PrePassOutputBlock: () => Sb, PrePassRenderer: () => _m, PrePassRendererSceneComponent: () => bE, PrePassTextureBlock: () => Ob, PrecisionDate: () => It, PredicateCondition: () => Qr, PressureObserverWrapper: () => YE, PrimitiveTopology: () => rr, PrismaticConstraint: () => KP, ProceduralTexture: () => mc, ProceduralTextureSceneComponent: () => Bg, PropertyTypeForEdition: () => Ye, PushMaterial: () => pl, QuadraticEase: () => hg, QuadraticErrorSimplification: () => LT, QuarticEase: () => JA, Quaternion: () => oe, QueryType: () => kc, QuinticEase: () => $A, RGBDTextureTools: () => Dh, RandomBlock: () => a0, RandomBlockLocks: () => ao, RandomGUID: () => ra, RandomNumberBlock: () => eT, RawCubeTexture: () => aP, RawTexture: () => on, RawTexture2DArray: () => Ky, RawTexture3D: () => sP, Ray: () => gi, RayHelper: () => Vv, ReadFile: () => ol, ReadFileError: () => Jm, RecastJSCrowd: () => G0, RecastJSPlugin: () => MP, ReciprocalBlock: () => nT, ReflectBlock: () => pT, ReflectionBlock: () => V_, ReflectionProbe: () => C_, ReflectionTextureBlock: () => Pb, Reflector: () => MI, RefractBlock: () => fT, RefractionBlock: () => k_, RefractionPostProcess: () => aE, RefractionTexture: () => lP, RegisterClass: () => j, RegisterMaterialPlugin: () => kR, RegisterNativeTypeAsync: () => ry, RemapBlock: () => Lp, RenderPassTimestampLocation: () => Kf, RenderTargetTexture: () => Mi, RenderTargetWrapper: () => dc, RenderTargetsOptimization: () => ym, RenderingGroup: () => ig, RenderingGroupInfo: () => ng, RenderingManager: () => rc, ReplaceColorBlock: () => rT, RequestFile: () => Bu, RequestFileError: () => lp, RetryStrategy: () => Wm, RibbonBuilder: () => QR, RichType: () => Or, RichTypeAny: () => ln, RichTypeBoolean: () => cn, RichTypeColor3: () => rS, RichTypeColor4: () => oS, RichTypeMatrix: () => Ri, RichTypeNumber: () => Ae, RichTypeQuaternion: () => mu, RichTypeString: () => _u, RichTypeVector2: () => $i, RichTypeVector3: () => ii, RichTypeVector4: () => pn, RollingAverage: () => bg, Rotate2dBlock: () => dT, RotationGizmo: () => dy, RotationXBlock: () => g0, RotationYBlock: () => v0, RotationZBlock: () => y0, RuntimeAnimation: () => zm, RuntimeError: () => ia, SSAO2RenderingPipeline: () => uE, SSAORenderingPipeline: () => sI, SSRRenderingPipeline: () => dE, SamplerBindingType: () => ga, Scalar: () => ue, ScaleBlock: () => Lb, ScaleGizmo: () => fy, ScalingBlock: () => b0, Scene: () => Ue, SceneComponentConstants: () => we, SceneDepthBlock: () => Ib, SceneInstrumentation: () => Uy, SceneLoader: () => yi, SceneLoaderAnimationGroupLoadingMode: () => Po, SceneLoaderFlags: () => Jr, SceneOptimization: () => Ho, SceneOptimizer: () => vI, SceneOptimizerOptions: () => bm, ScenePerformancePriority: () => Zr, SceneRecorder: () => AI, SceneSerializer: () => Td, ScreenSizeBlock: () => gb, ScreenSpaceBlock: () => vb, ScreenSpaceCurvaturePostProcess: () => fE, ScreenSpaceReflectionPostProcess: () => pm, ScreenshotTools: () => EI, SerializationHelper: () => Ne, SetColorsBlock: () => t0, SetCorsBehavior: () => wu, SetMaterialIDBlock: () => f0, SetNormalsBlock: () => $T, SetParentAction: () => qs, SetPositionsBlock: () => JT, SetStateAction: () => hn, SetTangentsBlock: () => i0, SetUVsBlock: () => e0, SetValueAction: () => dn, ShaderCodeInliner: () => Bc, ShaderLanguage: () => li, ShaderMaterial: () => dr, ShaderStage: () => _a, ShaderStore: () => re, ShadowDepthWrapper: () => hP, ShadowGenerator: () => ar, ShadowGeneratorSceneComponent: () => Xy, ShadowLight: () => Xh, ShadowMapBlock: () => Eb, ShadowsOptimization: () => md, ShapeBuilder: () => oC, SharpenPostProcess: () => dm, SheenBlock: () => B_, SimplexPerlin3DBlock: () => uT, SimplicationQueueSceneComponent: () => wT, SimplificationQueue: () => FT, SimplificationSettings: () => RP, SimplificationType: () => lu, SineEase: () => Sp, SixDofDragBehavior: () => Ng, Size: () => el, Skeleton: () => oh, SkeletonViewer: () => wf, SliderConstraint: () => jP, SmartArray: () => en, SmartArrayNoDuplicate: () => oa, SmoothStepBlock: () => iT, SolidParticle: () => $_, SolidParticleSystem: () => NP, SolidParticleVertex: () => K0, Sound: () => _s, SoundTrack: () => Pg, SourceTextureFormat: () => d_, Space: () => ht, SphereBlock: () => XT, SphereBuilder: () => KR, SphereDirectedParticleEmitter: () => kp, SphereParticleEmitter: () => ih, Spherical: () => TP, SphericalHarmonics: () => Mh, SphericalPolynomial: () => Sl, SpotLight: () => r_, SpringConstraint: () => qP, Sprite: () => IE, SpriteManager: () => OE, SpriteMap: () => uI, SpritePackedManager: () => hI, SpriteSceneComponent: () => ME, Stage: () => Ni, StandardMaterial: () => Gt, StandardMaterialDefines: () => gv, StandardRenderingPipeline: () => hE, StartsWith: () => Xm, StateCondition: () => as, StencilOperation: () => Vr, StencilState: () => qm, StencilStateComposer: () => ap, StepBlock: () => jb, StereoscopicArcRotateCamera: () => nv, StereoscopicFreeCamera: () => rv, StereoscopicGamepadCamera: () => ov, StereoscopicInterlacePostProcess: () => BR, StereoscopicInterlacePostProcessI: () => iv, StereoscopicScreenUniversalCamera: () => UR, StereoscopicUniversalCamera: () => av, StickValues: () => FR, StopAnimationAction: () => Wl, StopSoundAction: () => mt, StorageBuffer: () => Gg, StorageTextureAccess: () => Vh, StoreOp: () => pr, StringDictionary: () => ku, StringTools: () => UA, SubEmitter: () => cu, SubEmitterType: () => Ol, SubMesh: () => Yn, SubSurfaceBlock: () => ld, SubSurfaceSceneComponent: () => TE, SubtractBlock: () => Xb, SurfaceMagnetismBehavior: () => yR, SwitchBooleanAction: () => kl, SwitchInput: () => _p, TBNBlock: () => su, TGATools: () => eb, Tags: () => Xt, TargetCamera: () => ha, TargetedAnimation: () => dg, TeleportInBlock: () => L0, TeleportOutBlock: () => w0, TestBase64DataUrl: () => $m, TextFileAssetTask: () => LE, Texture: () => ae, TextureAspect: () => no, TextureAssetTask: () => UE, TextureBlock: () => Rb, TextureDimension: () => Ir, TextureFormat: () => U, TextureOptimization: () => _d, TexturePacker: () => oP, TexturePackerFrame: () => N_, TextureSampleType: () => nr, TextureSampler: () => rp, TextureTools: () => Yv, TextureUsage: () => fi, TextureViewDimension: () => ei, ThinEngine: () => Qe, ThinRenderTargetTexture: () => cP, ThinTexture: () => ms, TiledBoxBuilder: () => $R, TiledPlaneBuilder: () => JR, TimerState: () => Qa, TmpColors: () => Ot, TmpVectors: () => F, ToGammaSpace: () => ct, ToHalfFloat: () => to, ToLinearSpace: () => Ht, TonemapPostProcess: () => lI, TonemappingOperator: () => Fs, Tools: () => de, TorusBlock: () => YT, TorusBuilder: () => WR, TorusKnotBuilder: () => eC, TouchCamera: () => cf, TrailMesh: () => NT, Trajectory: () => RI, TrajectoryClassifier: () => II, TranscodeAsync: () => nd, TranscodeTarget: () => Rl, TransformBlock: () => $u, TransformNode: () => ai, TranslationBlock: () => E0, TriPlanarBlock: () => G_, TrigonometryBlock: () => zp, TrigonometryBlockOperations: () => Hi, TubeBuilder: () => sC, TwirlBlock: () => yb, UniformBuffer: () => Er, UniversalCamera: () => Wa, UnregisterAllMaterialPlugins: () => df, UnregisterMaterialPlugin: () => GR, UploadContent: () => O_, UploadEnvLevelsAsync: () => Uf, UploadEnvSpherical: () => Bh, UploadLevelsAsync: () => wc, UtilityLayerRenderer: () => Fi, VRCameraMetrics: () => Sc, VRDeviceOrientationArcRotateCamera: () => uv, VRDeviceOrientationFreeCamera: () => hh, VRDeviceOrientationGamepadCamera: () => hv, VRDistortionCorrectionPostProcess: () => hf, VRExperienceHelper: () => Av, VRMultiviewToSingleviewPostProcess: () => cv, ValidatedNativeDataStream: () => oy, ValueCondition: () => Ys, Vector2: () => fe, Vector3: () => v, Vector4: () => lt, VectorConverterBlock: () => d0, VectorMergerBlock: () => pc, VectorSplitterBlock: () => zb, VertexAnimationBaker: () => fR, VertexBuffer: () => P, VertexData: () => Oe, VertexDataMaterialInfo: () => lc, VertexFormat: () => bi, VertexOutputBlock: () => hc, VertexStepMode: () => Vc, VideoDome: () => KC, VideoRecorder: () => bI, VideoTexture: () => Qh, ViewDirectionBlock: () => w_, Viewport: () => xr, VirtualJoystick: () => sf, VirtualJoysticksCamera: () => sv, VolumetricLightScatteringPostProcess: () => pE, VoronoiNoiseBlock: () => ET, WaveBlock: () => aT, WaveBlockKind: () => Is, WebGL2ParticleSystem: () => W0, WebGL2ShaderProcessor: () => op, WebGLDataBuffer: () => nl, WebGLHardwareTexture: () => ds, WebGLPipelineContext: () => Zm, WebGPUCacheBindGroups: () => cy, WebGPUCacheRenderPipeline: () => sy, WebGPUCacheRenderPipelineTree: () => e_, WebGPUCacheSampler: () => Jf, WebGPUDataBuffer: () => ay, WebGPUDrawContext: () => ly, WebGPUEngine: () => st, WebGPUTintWASM: () => uy, WebRequest: () => _n, WebXRAbstractFeature: () => Qi, WebXRAbstractMotionController: () => Cs, WebXRAnchorSystem: () => Sd, WebXRBackgroundRemover: () => Ad, WebXRCamera: () => Cy, WebXRCompositionLayerWrapper: () => qE, WebXRControllerComponent: () => wo, WebXRControllerMovement: () => Dd, WebXRControllerPhysics: () => Rd, WebXRControllerPointerSelection: () => Zc, WebXRDefaultExperience: () => wy, WebXRDefaultExperienceOptions: () => XC, WebXRDepthSensing: () => Bd, WebXRDomOverlay: () => Od, WebXREnterExitUI: () => Fy, WebXREnterExitUIButton: () => Ny, WebXREnterExitUIOptions: () => HC, WebXRExperienceHelper: () => Py, WebXREyeTracking: () => Fd, WebXRFeatureName: () => vi, WebXRFeaturePointSystem: () => Pd, WebXRFeaturesManager: () => Wi, WebXRGenericHandController: () => $E, WebXRGenericTriggerMotionController: () => __, WebXRHTCViveMotionController: () => tS, WebXRHand: () => Vg, WebXRHandJoint: () => tt, WebXRHandTracking: () => rh, WebXRHitTest: () => Cd, WebXRHitTestLegacy: () => Ed, WebXRImageTracking: () => Md, WebXRInput: () => Dy, WebXRInputSource: () => Oy, WebXRLayers: () => wd, WebXRLightEstimation: () => Nd, WebXRManagedOutputCanvas: () => Tv, WebXRManagedOutputCanvasOptions: () => pf, WebXRMeshDetector: () => Id, WebXRMicrosoftMixedRealityController: () => eS, WebXRMotionControllerManager: () => Qn, WebXRMotionControllerTeleportation: () => $c, WebXRNearControllerMode: () => qa, WebXRNearInteraction: () => Jc, WebXROculusTouchMotionController: () => xm, WebXRPlaneDetector: () => xd, WebXRProfiledMotionController: () => Iy, WebXRProjectionLayerWrapper: () => QE, WebXRRawCameraAccess: () => Vd, WebXRSessionManager: () => ff, WebXRSpaceWarp: () => Ud, WebXRSpaceWarpRenderTargetTextureProvider: () => JE, WebXRState: () => Xi, WebXRTrackingState: () => Ts, WebXRWalkingLocomotion: () => Ld, WeightedSound: () => lR, WorkerPool: () => Sy, WorleyNoise3DBlock: () => cT, XRSpaceWarpRenderTarget: () => ZE, Xbox360Button: () => ir, Xbox360Dpad: () => vs, Xbox360Pad: () => Kg, XboxInput: () => fp, _BabylonLoaderRegistered: () => JC, _BasisTextureLoader: () => ob, _CreationDataStorage: () => Ap, _DDSTextureLoader: () => Ty, _ENVTextureLoader: () => Ey, _HDRTextureLoader: () => ib, _InstancesBatch: () => Rp, _KTXTextureLoader: () => Ry, _MeshCollisionData: () => Tg, _OcclusionDataStorage: () => Hv, _PrimaryIsoTriangle: () => Of, _TGATextureLoader: () => tb, _TimeToken: () => Wv, _UpdateRGBDAsync: () => Zv, _forceSceneHelpersToBundle: () => jC, _forceTransformFeedbackToBundle: () => hC, _injectLTSFileTools: () => eg, _staticOffsetValueColor3: () => Jd, _staticOffsetValueColor4: () => $d, _staticOffsetValueQuaternion: () => Kd, _staticOffsetValueSize: () => Zd, _staticOffsetValueVector2: () => Qd, _staticOffsetValueVector3: () => qd, addClipPlaneUniforms: () => Br, allocateAndCopyTypedBuffer: () => qu, bindClipPlane: () => Ar, captureEquirectangularFromScene: () => FI, className: () => HA, createDetailMapPlugin: () => vP, createPBRAnisotropicPlugin: () => dP, createPBRBRDFPlugin: () => pP, createPBRClearCoatPlugin: () => fP, createPBRIridescencePlugin: () => _P, createPBRSheenPlugin: () => mP, createPBRSubSurfacePlugin: () => gP, createYieldingScheduler: () => fg, editableInPropertyPage: () => qe, expandToProperty: () => ye, extractMinAndMax: () => hl, extractMinAndMaxIndexed: () => vg, getRichTypeFromValue: () => aS, inlineScheduler: () => sc, makeAsyncFunction: () => rR, makeSyncFunction: () => _g, nativeOverride: () => ea, normalizeEnvInfo: () => Lc, prepareDefinesForClipPlanes: () => Eg, prepareStringDefinesForClipPlanes: () => aa, runCoroutine: () => xp, runCoroutineAsync: () => Yu, runCoroutineSync: () => ju, serialize: () => N, serializeAsCameraReference: () => Ql, serializeAsColor3: () => ri, serializeAsColor4: () => ls, serializeAsColorCurves: () => Kl, serializeAsFresnelParameters: () => Jo, serializeAsImageProcessingConfiguration: () => $s, serializeAsMatrix: () => cs, serializeAsMeshReference: () => $o, serializeAsQuaternion: () => ql, serializeAsTexture: () => St, serializeAsVector2: () => ss, serializeAsVector3: () => ki, setAndStartTimer: () => m_, setStereoscopicAnaglyphRigMode: () => Tc, setStereoscopicRigMode: () => Ec, setVRRigMode: () => uh });
    var pe = function() {
      function n() {
        this.rootNodes = [], this.cameras = [], this.lights = [], this.meshes = [], this.skeletons = [], this.particleSystems = [], this.animations = [], this.animationGroups = [], this.multiMaterials = [], this.materials = [], this.morphTargetManagers = [], this.geometries = [], this.transformNodes = [], this.actionManagers = [], this.textures = [], this._environmentTexture = null, this.postProcesses = [];
      }
      return n.AddParser = function(t, e) {
        this._BabylonFileParsers[t] = e;
      }, n.GetParser = function(t) {
        return this._BabylonFileParsers[t] ? this._BabylonFileParsers[t] : null;
      }, n.AddIndividualParser = function(t, e) {
        this._IndividualBabylonFileParsers[t] = e;
      }, n.GetIndividualParser = function(t) {
        return this._IndividualBabylonFileParsers[t] ? this._IndividualBabylonFileParsers[t] : null;
      }, n.Parse = function(t, e, i, r) {
        for (var o in this._BabylonFileParsers)
          Object.prototype.hasOwnProperty.call(this._BabylonFileParsers, o) && this._BabylonFileParsers[o](t, e, i, r);
      }, Object.defineProperty(n.prototype, "environmentTexture", { get: function() {
        return this._environmentTexture;
      }, set: function(t) {
        this._environmentTexture = t;
      }, enumerable: !1, configurable: !0 }), n.prototype.getNodes = function() {
        var t = [];
        return t = (t = (t = (t = t.concat(this.meshes)).concat(this.lights)).concat(this.cameras)).concat(this.transformNodes), this.skeletons.forEach(function(e) {
          return t = t.concat(e.bones);
        }), t;
      }, n._BabylonFileParsers = {}, n._IndividualBabylonFileParsers = {}, n;
    }(), _ = function() {
      function n() {
      }
      return n.ALPHA_DISABLE = 0, n.ALPHA_ADD = 1, n.ALPHA_COMBINE = 2, n.ALPHA_SUBTRACT = 3, n.ALPHA_MULTIPLY = 4, n.ALPHA_MAXIMIZED = 5, n.ALPHA_ONEONE = 6, n.ALPHA_PREMULTIPLIED = 7, n.ALPHA_PREMULTIPLIED_PORTERDUFF = 8, n.ALPHA_INTERPOLATE = 9, n.ALPHA_SCREENMODE = 10, n.ALPHA_ONEONE_ONEONE = 11, n.ALPHA_ALPHATOCOLOR = 12, n.ALPHA_REVERSEONEMINUS = 13, n.ALPHA_SRC_DSTONEMINUSSRCALPHA = 14, n.ALPHA_ONEONE_ONEZERO = 15, n.ALPHA_EXCLUSION = 16, n.ALPHA_LAYER_ACCUMULATE = 17, n.ALPHA_EQUATION_ADD = 0, n.ALPHA_EQUATION_SUBSTRACT = 1, n.ALPHA_EQUATION_REVERSE_SUBTRACT = 2, n.ALPHA_EQUATION_MAX = 3, n.ALPHA_EQUATION_MIN = 4, n.ALPHA_EQUATION_DARKEN = 5, n.DELAYLOADSTATE_NONE = 0, n.DELAYLOADSTATE_LOADED = 1, n.DELAYLOADSTATE_LOADING = 2, n.DELAYLOADSTATE_NOTLOADED = 4, n.NEVER = 512, n.ALWAYS = 519, n.LESS = 513, n.EQUAL = 514, n.LEQUAL = 515, n.GREATER = 516, n.GEQUAL = 518, n.NOTEQUAL = 517, n.KEEP = 7680, n.ZERO = 0, n.REPLACE = 7681, n.INCR = 7682, n.DECR = 7683, n.INVERT = 5386, n.INCR_WRAP = 34055, n.DECR_WRAP = 34056, n.TEXTURE_CLAMP_ADDRESSMODE = 0, n.TEXTURE_WRAP_ADDRESSMODE = 1, n.TEXTURE_MIRROR_ADDRESSMODE = 2, n.TEXTURE_CREATIONFLAG_STORAGE = 1, n.TEXTUREFORMAT_ALPHA = 0, n.TEXTUREFORMAT_LUMINANCE = 1, n.TEXTUREFORMAT_LUMINANCE_ALPHA = 2, n.TEXTUREFORMAT_RGB = 4, n.TEXTUREFORMAT_RGBA = 5, n.TEXTUREFORMAT_RED = 6, n.TEXTUREFORMAT_R = 6, n.TEXTUREFORMAT_RG = 7, n.TEXTUREFORMAT_RED_INTEGER = 8, n.TEXTUREFORMAT_R_INTEGER = 8, n.TEXTUREFORMAT_RG_INTEGER = 9, n.TEXTUREFORMAT_RGB_INTEGER = 10, n.TEXTUREFORMAT_RGBA_INTEGER = 11, n.TEXTUREFORMAT_BGRA = 12, n.TEXTUREFORMAT_DEPTH24_STENCIL8 = 13, n.TEXTUREFORMAT_DEPTH32_FLOAT = 14, n.TEXTUREFORMAT_DEPTH16 = 15, n.TEXTUREFORMAT_DEPTH24 = 16, n.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8 = 17, n.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8 = 18, n.TEXTUREFORMAT_STENCIL8 = 19, n.TEXTUREFORMAT_UNDEFINED = 4294967295, n.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM = 36492, n.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_BPTC_UNORM = 36493, n.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT = 36495, n.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT = 36494, n.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5 = 33779, n.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT = 35919, n.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3 = 33778, n.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT = 35918, n.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1 = 33777, n.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1 = 33776, n.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT = 35917, n.TEXTUREFORMAT_COMPRESSED_SRGB_S3TC_DXT1_EXT = 35916, n.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4 = 37808, n.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = 37840, n.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL = 36196, n.TEXTUREFORMAT_COMPRESSED_RGB8_ETC2 = 37492, n.TEXTUREFORMAT_COMPRESSED_SRGB8_ETC2 = 37493, n.TEXTUREFORMAT_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 37494, n.TEXTUREFORMAT_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 37495, n.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC = 37496, n.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 37497, n.TEXTURETYPE_UNSIGNED_BYTE = 0, n.TEXTURETYPE_UNSIGNED_INT = 0, n.TEXTURETYPE_FLOAT = 1, n.TEXTURETYPE_HALF_FLOAT = 2, n.TEXTURETYPE_BYTE = 3, n.TEXTURETYPE_SHORT = 4, n.TEXTURETYPE_UNSIGNED_SHORT = 5, n.TEXTURETYPE_INT = 6, n.TEXTURETYPE_UNSIGNED_INTEGER = 7, n.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = 8, n.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = 9, n.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = 10, n.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = 11, n.TEXTURETYPE_UNSIGNED_INT_24_8 = 12, n.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = 13, n.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = 14, n.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15, n.TEXTURETYPE_UNDEFINED = 16, n.TEXTURE_2D = 3553, n.TEXTURE_2D_ARRAY = 35866, n.TEXTURE_CUBE_MAP = 34067, n.TEXTURE_CUBE_MAP_ARRAY = 3735928559, n.TEXTURE_3D = 32879, n.TEXTURE_NEAREST_SAMPLINGMODE = 1, n.TEXTURE_NEAREST_NEAREST = 1, n.TEXTURE_BILINEAR_SAMPLINGMODE = 2, n.TEXTURE_LINEAR_LINEAR = 2, n.TEXTURE_TRILINEAR_SAMPLINGMODE = 3, n.TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3, n.TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4, n.TEXTURE_NEAREST_LINEAR_MIPNEAREST = 5, n.TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6, n.TEXTURE_NEAREST_LINEAR = 7, n.TEXTURE_NEAREST_NEAREST_MIPLINEAR = 8, n.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9, n.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10, n.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 11, n.TEXTURE_LINEAR_NEAREST = 12, n.TEXTURE_EXPLICIT_MODE = 0, n.TEXTURE_SPHERICAL_MODE = 1, n.TEXTURE_PLANAR_MODE = 2, n.TEXTURE_CUBIC_MODE = 3, n.TEXTURE_PROJECTION_MODE = 4, n.TEXTURE_SKYBOX_MODE = 5, n.TEXTURE_INVCUBIC_MODE = 6, n.TEXTURE_EQUIRECTANGULAR_MODE = 7, n.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = 8, n.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9, n.TEXTURE_FILTERING_QUALITY_OFFLINE = 4096, n.TEXTURE_FILTERING_QUALITY_HIGH = 64, n.TEXTURE_FILTERING_QUALITY_MEDIUM = 16, n.TEXTURE_FILTERING_QUALITY_LOW = 8, n.SCALEMODE_FLOOR = 1, n.SCALEMODE_NEAREST = 2, n.SCALEMODE_CEILING = 3, n.MATERIAL_TextureDirtyFlag = 1, n.MATERIAL_LightDirtyFlag = 2, n.MATERIAL_FresnelDirtyFlag = 4, n.MATERIAL_AttributesDirtyFlag = 8, n.MATERIAL_MiscDirtyFlag = 16, n.MATERIAL_PrePassDirtyFlag = 32, n.MATERIAL_AllDirtyFlag = 63, n.MATERIAL_TriangleFillMode = 0, n.MATERIAL_WireFrameFillMode = 1, n.MATERIAL_PointFillMode = 2, n.MATERIAL_PointListDrawMode = 3, n.MATERIAL_LineListDrawMode = 4, n.MATERIAL_LineLoopDrawMode = 5, n.MATERIAL_LineStripDrawMode = 6, n.MATERIAL_TriangleStripDrawMode = 7, n.MATERIAL_TriangleFanDrawMode = 8, n.MATERIAL_ClockWiseSideOrientation = 0, n.MATERIAL_CounterClockWiseSideOrientation = 1, n.ACTION_NothingTrigger = 0, n.ACTION_OnPickTrigger = 1, n.ACTION_OnLeftPickTrigger = 2, n.ACTION_OnRightPickTrigger = 3, n.ACTION_OnCenterPickTrigger = 4, n.ACTION_OnPickDownTrigger = 5, n.ACTION_OnDoublePickTrigger = 6, n.ACTION_OnPickUpTrigger = 7, n.ACTION_OnPickOutTrigger = 16, n.ACTION_OnLongPressTrigger = 8, n.ACTION_OnPointerOverTrigger = 9, n.ACTION_OnPointerOutTrigger = 10, n.ACTION_OnEveryFrameTrigger = 11, n.ACTION_OnIntersectionEnterTrigger = 12, n.ACTION_OnIntersectionExitTrigger = 13, n.ACTION_OnKeyDownTrigger = 14, n.ACTION_OnKeyUpTrigger = 15, n.PARTICLES_BILLBOARDMODE_Y = 2, n.PARTICLES_BILLBOARDMODE_ALL = 7, n.PARTICLES_BILLBOARDMODE_STRETCHED = 8, n.PARTICLES_BILLBOARDMODE_STRETCHED_LOCAL = 9, n.MESHES_CULLINGSTRATEGY_STANDARD = 0, n.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1, n.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2, n.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3, n.SCENELOADER_NO_LOGGING = 0, n.SCENELOADER_MINIMAL_LOGGING = 1, n.SCENELOADER_SUMMARY_LOGGING = 2, n.SCENELOADER_DETAILED_LOGGING = 3, n.PREPASS_IRRADIANCE_TEXTURE_TYPE = 0, n.PREPASS_POSITION_TEXTURE_TYPE = 1, n.PREPASS_VELOCITY_TEXTURE_TYPE = 2, n.PREPASS_REFLECTIVITY_TEXTURE_TYPE = 3, n.PREPASS_COLOR_TEXTURE_TYPE = 4, n.PREPASS_DEPTH_TEXTURE_TYPE = 5, n.PREPASS_NORMAL_TEXTURE_TYPE = 6, n.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE = 7, n.BUFFER_CREATIONFLAG_READ = 1, n.BUFFER_CREATIONFLAG_WRITE = 2, n.BUFFER_CREATIONFLAG_READWRITE = 3, n.BUFFER_CREATIONFLAG_UNIFORM = 4, n.BUFFER_CREATIONFLAG_VERTEX = 8, n.BUFFER_CREATIONFLAG_INDEX = 16, n.BUFFER_CREATIONFLAG_STORAGE = 32, n.RENDERPASS_MAIN = 0, n.INPUT_ALT_KEY = 18, n.INPUT_CTRL_KEY = 17, n.INPUT_META_KEY1 = 91, n.INPUT_META_KEY2 = 92, n.INPUT_META_KEY3 = 93, n.INPUT_SHIFT_KEY = 16, n.SNAPSHOTRENDERING_STANDARD = 0, n.SNAPSHOTRENDERING_FAST = 1, n.PERSPECTIVE_CAMERA = 0, n.ORTHOGRAPHIC_CAMERA = 1, n.FOVMODE_VERTICAL_FIXED = 0, n.FOVMODE_HORIZONTAL_FIXED = 1, n.RIG_MODE_NONE = 0, n.RIG_MODE_STEREOSCOPIC_ANAGLYPH = 10, n.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = 11, n.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12, n.RIG_MODE_STEREOSCOPIC_OVERUNDER = 13, n.RIG_MODE_STEREOSCOPIC_INTERLACED = 14, n.RIG_MODE_VR = 20, n.RIG_MODE_CUSTOM = 22, n.MAX_SUPPORTED_UV_SETS = 6, n.GL_ALPHA_EQUATION_ADD = 32774, n.GL_ALPHA_EQUATION_MIN = 32775, n.GL_ALPHA_EQUATION_MAX = 32776, n.GL_ALPHA_EQUATION_SUBTRACT = 32778, n.GL_ALPHA_EQUATION_REVERSE_SUBTRACT = 32779, n.GL_ALPHA_FUNCTION_SRC = 768, n.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR = 769, n.GL_ALPHA_FUNCTION_SRC_ALPHA = 770, n.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA = 771, n.GL_ALPHA_FUNCTION_DST_ALPHA = 772, n.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA = 773, n.GL_ALPHA_FUNCTION_DST_COLOR = 774, n.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR = 775, n.GL_ALPHA_FUNCTION_SRC_ALPHA_SATURATED = 776, n.GL_ALPHA_FUNCTION_CONSTANT_COLOR = 32769, n.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR = 32770, n.GL_ALPHA_FUNCTION_CONSTANT_ALPHA = 32771, n.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA = 32772, n.SnippetUrl = "https://snippet.babylonjs.com", n;
    }(), Ee = function() {
      function n() {
        this.hoverCursor = "", this.actions = [], this.isRecursive = !1;
      }
      return Object.defineProperty(n, "HasTriggers", { get: function() {
        for (var t in n.Triggers)
          if (Object.prototype.hasOwnProperty.call(n.Triggers, t))
            return !0;
        return !1;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "HasPickTriggers", { get: function() {
        for (var t in n.Triggers)
          if (Object.prototype.hasOwnProperty.call(n.Triggers, t)) {
            var e = parseInt(t);
            if (e >= _.ACTION_OnPickTrigger && e <= _.ACTION_OnPickUpTrigger)
              return !0;
          }
        return !1;
      }, enumerable: !1, configurable: !0 }), n.HasSpecificTrigger = function(t) {
        for (var e in n.Triggers)
          if (Object.prototype.hasOwnProperty.call(n.Triggers, e) && parseInt(e) === t)
            return !0;
        return !1;
      }, n.Triggers = {}, n;
    }(), Xe = function() {
      function n(t, e, i, r) {
        e === void 0 && (e = !1), this.initialize(t, e, i, r);
      }
      return n.prototype.initialize = function(t, e, i, r) {
        return e === void 0 && (e = !1), this.mask = t, this.skipNextObservers = e, this.target = i, this.currentTarget = r, this;
      }, n;
    }(), yt = function() {
      function n(t, e, i) {
        i === void 0 && (i = null), this.callback = t, this.mask = e, this.scope = i, this._willBeUnregistered = !1, this.unregisterOnNextCall = !1, this._remove = null;
      }
      return n.prototype.remove = function() {
        this._remove && this._remove();
      }, n;
    }(), H = function() {
      function n(t, e) {
        e === void 0 && (e = !1), this.notifyIfTriggered = e, this._observers = new Array(), this._numObserversMarkedAsDeleted = 0, this._hasNotified = !1, this._eventState = new Xe(0), t && (this._onObserverAdded = t);
      }
      return n.FromPromise = function(t, e) {
        var i = new n();
        return t.then(function(r) {
          i.notifyObservers(r);
        }).catch(function(r) {
          if (!e)
            throw r;
          e.notifyObservers(r);
        }), i;
      }, Object.defineProperty(n.prototype, "observers", { get: function() {
        return this._observers;
      }, enumerable: !1, configurable: !0 }), n.prototype.add = function(t, e, i, r, o) {
        var a = this;
        if (e === void 0 && (e = -1), i === void 0 && (i = !1), r === void 0 && (r = null), o === void 0 && (o = !1), !t)
          return null;
        var s = new yt(t, e, r);
        return s.unregisterOnNextCall = o, i ? this._observers.unshift(s) : this._observers.push(s), this._onObserverAdded && this._onObserverAdded(s), this._hasNotified && this.notifyIfTriggered && this._lastNotifiedValue !== void 0 && this.notifyObserver(s, this._lastNotifiedValue), s._remove = function() {
          a.remove(s);
        }, s;
      }, n.prototype.addOnce = function(t) {
        return this.add(t, void 0, void 0, void 0, !0);
      }, n.prototype.remove = function(t) {
        return !!t && (t._remove = null, this._observers.indexOf(t) !== -1 && (this._deferUnregister(t), !0));
      }, n.prototype.removeCallback = function(t, e) {
        for (var i = 0; i < this._observers.length; i++) {
          var r = this._observers[i];
          if (!(r._willBeUnregistered || r.callback !== t || e && e !== r.scope))
            return this._deferUnregister(r), !0;
        }
        return !1;
      }, n.prototype._deferUnregister = function(t) {
        var e = this;
        t._willBeUnregistered || (this._numObserversMarkedAsDeleted++, t.unregisterOnNextCall = !1, t._willBeUnregistered = !0, setTimeout(function() {
          e._remove(t);
        }, 0));
      }, n.prototype._remove = function(t, e) {
        if (e === void 0 && (e = !0), !t)
          return !1;
        var i = this._observers.indexOf(t);
        return i !== -1 && (e && this._numObserversMarkedAsDeleted--, this._observers.splice(i, 1), !0);
      }, n.prototype.makeObserverTopPriority = function(t) {
        this._remove(t, !1), this._observers.unshift(t);
      }, n.prototype.makeObserverBottomPriority = function(t) {
        this._remove(t, !1), this._observers.push(t);
      }, n.prototype.notifyObservers = function(t, e, i, r, o) {
        if (e === void 0 && (e = -1), this.notifyIfTriggered && (this._hasNotified = !0, this._lastNotifiedValue = t), !this._observers.length)
          return !0;
        var a = this._eventState;
        a.mask = e, a.target = i, a.currentTarget = r, a.skipNextObservers = !1, a.lastReturnValue = t, a.userInfo = o;
        for (var s = 0, l = this._observers; s < l.length; s++) {
          var c = l[s];
          if (!c._willBeUnregistered && (c.mask & e && (c.unregisterOnNextCall && this._deferUnregister(c), c.scope ? a.lastReturnValue = c.callback.apply(c.scope, [t, a]) : a.lastReturnValue = c.callback(t, a)), a.skipNextObservers))
            return !1;
        }
        return !0;
      }, n.prototype.notifyObserver = function(t, e, i) {
        if (i === void 0 && (i = -1), this.notifyIfTriggered && (this._hasNotified = !0, this._lastNotifiedValue = e), !t._willBeUnregistered) {
          var r = this._eventState;
          r.mask = i, r.skipNextObservers = !1, t.unregisterOnNextCall && this._deferUnregister(t), t.callback(e, r);
        }
      }, n.prototype.hasObservers = function() {
        return this._observers.length - this._numObserversMarkedAsDeleted > 0;
      }, n.prototype.clear = function() {
        for (; this._observers.length; ) {
          var t = this._observers.pop();
          t && (t._remove = null);
        }
        this._onObserverAdded = null, this._numObserversMarkedAsDeleted = 0, this.cleanLastNotifiedState();
      }, n.prototype.cleanLastNotifiedState = function() {
        this._hasNotified = !1, this._lastNotifiedValue = void 0;
      }, n.prototype.clone = function() {
        var t = new n();
        return t._observers = this._observers.slice(0), t;
      }, n.prototype.hasSpecificMask = function(t) {
        t === void 0 && (t = -1);
        for (var e = 0, i = this._observers; e < i.length; e++) {
          var r = i[e];
          if (r.mask & t || r.mask === t)
            return !0;
        }
        return !1;
      }, n;
    }(), ue = function() {
      function n() {
      }
      return n.WithinEpsilon = function(t, e, i) {
        return i === void 0 && (i = 1401298e-51), Math.abs(t - e) <= i;
      }, n.ToHex = function(t) {
        var e = t.toString(16);
        return t <= 15 ? ("0" + e).toUpperCase() : e.toUpperCase();
      }, n.Sign = function(t) {
        return (t = +t) == 0 || isNaN(t) ? t : t > 0 ? 1 : -1;
      }, n.Clamp = function(t, e, i) {
        return e === void 0 && (e = 0), i === void 0 && (i = 1), Math.min(i, Math.max(e, t));
      }, n.Log2 = function(t) {
        return Math.log(t) * Math.LOG2E;
      }, n.ILog2 = function(t) {
        if (Math.log2)
          return Math.floor(Math.log2(t));
        if (t < 0)
          return NaN;
        if (t === 0)
          return -1 / 0;
        var e = 0;
        if (t < 1) {
          for (; t < 1; )
            e++, t *= 2;
          e = -e;
        } else if (t > 1)
          for (; t > 1; )
            e++, t = Math.floor(t / 2);
        return e;
      }, n.Repeat = function(t, e) {
        return t - Math.floor(t / e) * e;
      }, n.Normalize = function(t, e, i) {
        return (t - e) / (i - e);
      }, n.Denormalize = function(t, e, i) {
        return t * (i - e) + e;
      }, n.DeltaAngle = function(t, e) {
        var i = n.Repeat(e - t, 360);
        return i > 180 && (i -= 360), i;
      }, n.PingPong = function(t, e) {
        var i = n.Repeat(t, 2 * e);
        return e - Math.abs(i - e);
      }, n.SmoothStep = function(t, e, i) {
        var r = n.Clamp(i);
        return e * (r = -2 * r * r * r + 3 * r * r) + t * (1 - r);
      }, n.MoveTowards = function(t, e, i) {
        return Math.abs(e - t) <= i ? e : t + n.Sign(e - t) * i;
      }, n.MoveTowardsAngle = function(t, e, i) {
        var r = n.DeltaAngle(t, e), o = 0;
        return -i < r && r < i ? o = e : (e = t + r, o = n.MoveTowards(t, e, i)), o;
      }, n.Lerp = function(t, e, i) {
        return t + (e - t) * i;
      }, n.LerpAngle = function(t, e, i) {
        var r = n.Repeat(e - t, 360);
        return r > 180 && (r -= 360), t + r * n.Clamp(i);
      }, n.InverseLerp = function(t, e, i) {
        return t != e ? n.Clamp((i - t) / (e - t)) : 0;
      }, n.Hermite = function(t, e, i, r, o) {
        var a = o * o, s = o * a;
        return t * (2 * s - 3 * a + 1) + i * (-2 * s + 3 * a) + e * (s - 2 * a + o) + r * (s - a);
      }, n.Hermite1stDerivative = function(t, e, i, r, o) {
        var a = o * o;
        return 6 * (a - o) * t + (3 * a - 4 * o + 1) * e + 6 * (-a + o) * i + (3 * a - 2 * o) * r;
      }, n.RandomRange = function(t, e) {
        return t === e ? t : Math.random() * (e - t) + t;
      }, n.RangeToPercent = function(t, e, i) {
        return (t - e) / (i - e);
      }, n.PercentToRange = function(t, e, i) {
        return (i - e) * t + e;
      }, n.NormalizeRadians = function(t) {
        return t - n.TwoPi * Math.floor((t + Math.PI) / n.TwoPi);
      }, n.HCF = function(t, e) {
        var i = t % e;
        return i === 0 ? e : n.HCF(e, i);
      }, n.TwoPi = 2 * Math.PI, n;
    }(), ct = 1 / 2.2, Ht = 2.2, gt = (1 + Math.sqrt(5)) / 2, Ge = 1e-3, pt = function() {
      function n() {
      }
      return n.BuildArray = function(t, e) {
        for (var i = [], r = 0; r < t; ++r)
          i.push(e());
        return i;
      }, n.BuildTuple = function(t, e) {
        return n.BuildArray(t, e);
      }, n;
    }(), Ve = ["push", "splice", "pop", "shift", "unshift"];
    function ot(n, t) {
      var e = Ve.map(function(i) {
        return function(r, o, a) {
          var s = r[o];
          if (typeof s != "function")
            return null;
          var l = function() {
            var c = r.length, u = l.previous.apply(r, arguments);
            return a(o, c), u;
          };
          return s.next = l, l.previous = s, r[o] = l, function() {
            var c = l.previous;
            if (c) {
              var u = l.next;
              u ? (c.next = u, u.previous = c) : (c.next = void 0, r[o] = c), l.next = void 0, l.previous = void 0;
            }
          };
        }(n, i, t);
      });
      return function() {
        e.forEach(function(i) {
          i == null || i();
        });
      };
    }
    var ft = {};
    function j(n, t) {
      ft[n] = t;
    }
    function Kt(n) {
      return ft[n];
    }
    var Ti = function() {
      function n() {
      }
      return n.SetMatrixPrecision = function(t) {
        if (n.MatrixTrackPrecisionChange = !1, t && !n.MatrixUse64Bits && n.MatrixTrackedMatrices)
          for (var e = 0; e < n.MatrixTrackedMatrices.length; ++e) {
            var i = n.MatrixTrackedMatrices[e], r = i._m;
            i._m = new Array(16);
            for (var o = 0; o < 16; ++o)
              i._m[o] = r[o];
          }
        n.MatrixUse64Bits = t, n.MatrixCurrentType = n.MatrixUse64Bits ? Array : Float32Array, n.MatrixTrackedMatrices = null;
      }, n.MatrixUse64Bits = !1, n.MatrixTrackPrecisionChange = !0, n.MatrixCurrentType = Float32Array, n.MatrixTrackedMatrices = [], n;
    }(), Me = function() {
      function n() {
      }
      return Object.defineProperty(n, "LastCreatedEngine", { get: function() {
        return this.Instances.length === 0 ? null : this.Instances[this.Instances.length - 1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "LastCreatedScene", { get: function() {
        return this._LastCreatedScene;
      }, enumerable: !1, configurable: !0 }), n.Instances = [], n.OnEnginesDisposedObservable = new H(), n._LastCreatedScene = null, n.UseFallbackTexture = !0, n.FallbackTexture = "", n;
    }(), Zt = function(n) {
      return parseInt(n.toString().replace(/\W/g, ""));
    }, fe = function() {
      function n(t, e) {
        t === void 0 && (t = 0), e === void 0 && (e = 0), this.x = t, this.y = e;
      }
      return n.prototype.toString = function() {
        return "{X: ".concat(this.x, " Y: ").concat(this.y, "}");
      }, n.prototype.getClassName = function() {
        return "Vector2";
      }, n.prototype.getHashCode = function() {
        var t = Zt(this.x);
        return 397 * t ^ Zt(this.y);
      }, n.prototype.toArray = function(t, e) {
        return e === void 0 && (e = 0), t[e] = this.x, t[e + 1] = this.y, this;
      }, n.prototype.fromArray = function(t, e) {
        return e === void 0 && (e = 0), n.FromArrayToRef(t, e, this), this;
      }, n.prototype.asArray = function() {
        var t = [];
        return this.toArray(t, 0), t;
      }, n.prototype.copyFrom = function(t) {
        return this.x = t.x, this.y = t.y, this;
      }, n.prototype.copyFromFloats = function(t, e) {
        return this.x = t, this.y = e, this;
      }, n.prototype.set = function(t, e) {
        return this.copyFromFloats(t, e);
      }, n.prototype.add = function(t) {
        return new this.constructor(this.x + t.x, this.y + t.y);
      }, n.prototype.addToRef = function(t, e) {
        return e.x = this.x + t.x, e.y = this.y + t.y, e;
      }, n.prototype.addInPlace = function(t) {
        return this.x += t.x, this.y += t.y, this;
      }, n.prototype.addVector3 = function(t) {
        return new this.constructor(this.x + t.x, this.y + t.y);
      }, n.prototype.subtract = function(t) {
        return new this.constructor(this.x - t.x, this.y - t.y);
      }, n.prototype.subtractToRef = function(t, e) {
        return e.x = this.x - t.x, e.y = this.y - t.y, e;
      }, n.prototype.subtractInPlace = function(t) {
        return this.x -= t.x, this.y -= t.y, this;
      }, n.prototype.multiplyInPlace = function(t) {
        return this.x *= t.x, this.y *= t.y, this;
      }, n.prototype.multiply = function(t) {
        return new this.constructor(this.x * t.x, this.y * t.y);
      }, n.prototype.multiplyToRef = function(t, e) {
        return e.x = this.x * t.x, e.y = this.y * t.y, e;
      }, n.prototype.multiplyByFloats = function(t, e) {
        return new this.constructor(this.x * t, this.y * e);
      }, n.prototype.divide = function(t) {
        return new this.constructor(this.x / t.x, this.y / t.y);
      }, n.prototype.divideToRef = function(t, e) {
        return e.x = this.x / t.x, e.y = this.y / t.y, e;
      }, n.prototype.divideInPlace = function(t) {
        return this.divideToRef(t, this);
      }, n.prototype.negate = function() {
        return new this.constructor(-this.x, -this.y);
      }, n.prototype.negateInPlace = function() {
        return this.x *= -1, this.y *= -1, this;
      }, n.prototype.negateToRef = function(t) {
        return t.copyFromFloats(-1 * this.x, -1 * this.y);
      }, n.prototype.scaleInPlace = function(t) {
        return this.x *= t, this.y *= t, this;
      }, n.prototype.scale = function(t) {
        var e = new this.constructor(0, 0);
        return this.scaleToRef(t, e), e;
      }, n.prototype.scaleToRef = function(t, e) {
        return e.x = this.x * t, e.y = this.y * t, e;
      }, n.prototype.scaleAndAddToRef = function(t, e) {
        return e.x += this.x * t, e.y += this.y * t, e;
      }, n.prototype.equals = function(t) {
        return t && this.x === t.x && this.y === t.y;
      }, n.prototype.equalsWithEpsilon = function(t, e) {
        return e === void 0 && (e = Ge), t && ue.WithinEpsilon(this.x, t.x, e) && ue.WithinEpsilon(this.y, t.y, e);
      }, n.prototype.floor = function() {
        return new this.constructor(Math.floor(this.x), Math.floor(this.y));
      }, n.prototype.fract = function() {
        return new this.constructor(this.x - Math.floor(this.x), this.y - Math.floor(this.y));
      }, n.prototype.rotateToRef = function(t, e) {
        var i = Math.cos(t), r = Math.sin(t), o = i * this.x - r * this.y, a = r * this.x + i * this.y;
        return e.x = o, e.y = a, e;
      }, n.prototype.length = function() {
        return Math.sqrt(this.x * this.x + this.y * this.y);
      }, n.prototype.lengthSquared = function() {
        return this.x * this.x + this.y * this.y;
      }, n.prototype.normalize = function() {
        return this.normalizeFromLength(this.length());
      }, n.prototype.normalizeFromLength = function(t) {
        return t === 0 || t === 1 ? this : this.scaleInPlace(1 / t);
      }, n.prototype.normalizeToNew = function() {
        var t = new this.constructor(0, 0);
        return this.normalizeToRef(t), t;
      }, n.prototype.normalizeToRef = function(t) {
        var e = this.length();
        return e === 0 || e === 1 ? t.copyFromFloats(this.x, this.y) : this.scaleToRef(1 / e, t);
      }, n.prototype.clone = function() {
        return new this.constructor(this.x, this.y);
      }, n.prototype.dot = function(t) {
        return this.x * t.x + this.y * t.y;
      }, n.Zero = function() {
        return new n(0, 0);
      }, n.One = function() {
        return new n(1, 1);
      }, n.Random = function(t, e) {
        return t === void 0 && (t = 0), e === void 0 && (e = 1), new n(ue.RandomRange(t, e), ue.RandomRange(t, e));
      }, Object.defineProperty(n, "ZeroReadOnly", { get: function() {
        return n._ZeroReadOnly;
      }, enumerable: !1, configurable: !0 }), n.FromArray = function(t, e) {
        return e === void 0 && (e = 0), new n(t[e], t[e + 1]);
      }, n.FromArrayToRef = function(t, e, i) {
        return i.x = t[e], i.y = t[e + 1], i;
      }, n.CatmullRom = function(t, e, i, r, o) {
        var a = o * o, s = o * a, l = 0.5 * (2 * e.x + (-t.x + i.x) * o + (2 * t.x - 5 * e.x + 4 * i.x - r.x) * a + (-t.x + 3 * e.x - 3 * i.x + r.x) * s), c = 0.5 * (2 * e.y + (-t.y + i.y) * o + (2 * t.y - 5 * e.y + 4 * i.y - r.y) * a + (-t.y + 3 * e.y - 3 * i.y + r.y) * s);
        return new t.constructor(l, c);
      }, n.Clamp = function(t, e, i) {
        var r = t.x;
        r = (r = r > i.x ? i.x : r) < e.x ? e.x : r;
        var o = t.y;
        return o = (o = o > i.y ? i.y : o) < e.y ? e.y : o, new t.constructor(r, o);
      }, n.Hermite = function(t, e, i, r, o) {
        var a = o * o, s = o * a, l = 2 * s - 3 * a + 1, c = -2 * s + 3 * a, u = s - 2 * a + o, h = s - a, d = t.x * l + i.x * c + e.x * u + r.x * h, p = t.y * l + i.y * c + e.y * u + r.y * h;
        return new t.constructor(d, p);
      }, n.Hermite1stDerivative = function(t, e, i, r, o) {
        var a = new t.constructor();
        return this.Hermite1stDerivativeToRef(t, e, i, r, o, a), a;
      }, n.Hermite1stDerivativeToRef = function(t, e, i, r, o, a) {
        var s = o * o;
        return a.x = 6 * (s - o) * t.x + (3 * s - 4 * o + 1) * e.x + 6 * (-s + o) * i.x + (3 * s - 2 * o) * r.x, a.y = 6 * (s - o) * t.y + (3 * s - 4 * o + 1) * e.y + 6 * (-s + o) * i.y + (3 * s - 2 * o) * r.y, a;
      }, n.Lerp = function(t, e, i) {
        var r = t.x + (e.x - t.x) * i, o = t.y + (e.y - t.y) * i;
        return new t.constructor(r, o);
      }, n.Dot = function(t, e) {
        return t.x * e.x + t.y * e.y;
      }, n.Normalize = function(t) {
        var e = new t.constructor();
        return n.NormalizeToRef(t, e), e;
      }, n.NormalizeToRef = function(t, e) {
        return t.normalizeToRef(e), e;
      }, n.Minimize = function(t, e) {
        var i = t.x < e.x ? t.x : e.x, r = t.y < e.y ? t.y : e.y;
        return new t.constructor(i, r);
      }, n.Maximize = function(t, e) {
        var i = t.x > e.x ? t.x : e.x, r = t.y > e.y ? t.y : e.y;
        return new t.constructor(i, r);
      }, n.Transform = function(t, e) {
        var i = new t.constructor();
        return n.TransformToRef(t, e, i), i;
      }, n.TransformToRef = function(t, e, i) {
        var r = e.m, o = t.x * r[0] + t.y * r[4] + r[12], a = t.x * r[1] + t.y * r[5] + r[13];
        return i.x = o, i.y = a, i;
      }, n.PointInTriangle = function(t, e, i, r) {
        var o = 0.5 * (-i.y * r.x + e.y * (-i.x + r.x) + e.x * (i.y - r.y) + i.x * r.y), a = o < 0 ? -1 : 1, s = (e.y * r.x - e.x * r.y + (r.y - e.y) * t.x + (e.x - r.x) * t.y) * a, l = (e.x * i.y - e.y * i.x + (e.y - i.y) * t.x + (i.x - e.x) * t.y) * a;
        return s > 0 && l > 0 && s + l < 2 * o * a;
      }, n.Distance = function(t, e) {
        return Math.sqrt(n.DistanceSquared(t, e));
      }, n.DistanceSquared = function(t, e) {
        var i = t.x - e.x, r = t.y - e.y;
        return i * i + r * r;
      }, n.Center = function(t, e) {
        var i = new t.constructor();
        return n.CenterToRef(t, e, i);
      }, n.CenterToRef = function(t, e, i) {
        return i.copyFromFloats((t.x + e.x) / 2, (t.y + e.y) / 2);
      }, n.DistanceOfPointFromSegment = function(t, e, i) {
        var r = n.DistanceSquared(e, i);
        if (r === 0)
          return n.Distance(t, e);
        var o = i.subtract(e), a = Math.max(0, Math.min(1, n.Dot(t.subtract(e), o) / r)), s = e.add(o.multiplyByFloats(a, a));
        return n.Distance(t, s);
      }, n._ZeroReadOnly = n.Zero(), n;
    }(), v = function() {
      function n(t, e, i) {
        t === void 0 && (t = 0), e === void 0 && (e = 0), i === void 0 && (i = 0), this._isDirty = !0, this._x = t, this._y = e, this._z = i;
      }
      return Object.defineProperty(n.prototype, "x", { get: function() {
        return this._x;
      }, set: function(t) {
        this._x = t, this._isDirty = !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "y", { get: function() {
        return this._y;
      }, set: function(t) {
        this._y = t, this._isDirty = !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "z", { get: function() {
        return this._z;
      }, set: function(t) {
        this._z = t, this._isDirty = !0;
      }, enumerable: !1, configurable: !0 }), n.prototype.toString = function() {
        return "{X: ".concat(this._x, " Y: ").concat(this._y, " Z: ").concat(this._z, "}");
      }, n.prototype.getClassName = function() {
        return "Vector3";
      }, n.prototype.getHashCode = function() {
        var t = Zt(this._x);
        return 397 * (t = 397 * t ^ Zt(this._y)) ^ Zt(this._z);
      }, n.prototype.asArray = function() {
        var t = [];
        return this.toArray(t, 0), t;
      }, n.prototype.toArray = function(t, e) {
        return e === void 0 && (e = 0), t[e] = this._x, t[e + 1] = this._y, t[e + 2] = this._z, this;
      }, n.prototype.fromArray = function(t, e) {
        return e === void 0 && (e = 0), n.FromArrayToRef(t, e, this), this;
      }, n.prototype.toQuaternion = function() {
        return oe.RotationYawPitchRoll(this._y, this._x, this._z);
      }, n.prototype.addInPlace = function(t) {
        return this.addInPlaceFromFloats(t._x, t._y, t._z);
      }, n.prototype.addInPlaceFromFloats = function(t, e, i) {
        return this._x += t, this._y += e, this._z += i, this._isDirty = !0, this;
      }, n.prototype.add = function(t) {
        return new this.constructor(this._x + t._x, this._y + t._y, this._z + t._z);
      }, n.prototype.addToRef = function(t, e) {
        return e.copyFromFloats(this._x + t._x, this._y + t._y, this._z + t._z);
      }, n.prototype.subtractInPlace = function(t) {
        return this._x -= t._x, this._y -= t._y, this._z -= t._z, this._isDirty = !0, this;
      }, n.prototype.subtract = function(t) {
        return new this.constructor(this._x - t._x, this._y - t._y, this._z - t._z);
      }, n.prototype.subtractToRef = function(t, e) {
        return this.subtractFromFloatsToRef(t._x, t._y, t._z, e);
      }, n.prototype.subtractFromFloats = function(t, e, i) {
        return new this.constructor(this._x - t, this._y - e, this._z - i);
      }, n.prototype.subtractFromFloatsToRef = function(t, e, i, r) {
        return r.copyFromFloats(this._x - t, this._y - e, this._z - i);
      }, n.prototype.negate = function() {
        return new this.constructor(-this._x, -this._y, -this._z);
      }, n.prototype.negateInPlace = function() {
        return this._x *= -1, this._y *= -1, this._z *= -1, this._isDirty = !0, this;
      }, n.prototype.negateToRef = function(t) {
        return t.copyFromFloats(-1 * this._x, -1 * this._y, -1 * this._z);
      }, n.prototype.scaleInPlace = function(t) {
        return this._x *= t, this._y *= t, this._z *= t, this._isDirty = !0, this;
      }, n.prototype.scale = function(t) {
        return new this.constructor(this._x * t, this._y * t, this._z * t);
      }, n.prototype.scaleToRef = function(t, e) {
        return e.copyFromFloats(this._x * t, this._y * t, this._z * t);
      }, n.prototype.getNormalToRef = function(t) {
        var e = this.length(), i = Math.acos(this.y / e), r = Math.atan2(this.z, this.x);
        i > Math.PI / 2 ? i -= Math.PI / 2 : i += Math.PI / 2;
        var o = e * Math.sin(i) * Math.cos(r), a = e * Math.cos(i), s = e * Math.sin(i) * Math.sin(r);
        return t.set(o, a, s), t;
      }, n.prototype.applyRotationQuaternionToRef = function(t, e) {
        var i = this._x, r = this._y, o = this._z, a = t._x, s = t._y, l = t._z, c = t._w, u = 2 * (s * o - l * r), h = 2 * (l * i - a * o), d = 2 * (a * r - s * i);
        return e._x = i + c * u + s * d - l * h, e._y = r + c * h + l * u - a * d, e._z = o + c * d + a * h - s * u, e._isDirty = !0, e;
      }, n.prototype.applyRotationQuaternionInPlace = function(t) {
        return this.applyRotationQuaternionToRef(t, this);
      }, n.prototype.applyRotationQuaternion = function(t) {
        return this.applyRotationQuaternionToRef(t, new this.constructor());
      }, n.prototype.scaleAndAddToRef = function(t, e) {
        return e.addInPlaceFromFloats(this._x * t, this._y * t, this._z * t);
      }, n.prototype.projectOnPlane = function(t, e) {
        var i = new this.constructor();
        return this.projectOnPlaneToRef(t, e, i), i;
      }, n.prototype.projectOnPlaneToRef = function(t, e, i) {
        var r = t.normal, o = t.d, a = ze.Vector3[0];
        this.subtractToRef(e, a), a.normalize();
        var s = n.Dot(a, r);
        if (Math.abs(s) < 1e-10)
          i.setAll(1 / 0);
        else {
          var l = -(n.Dot(e, r) + o) / s, c = a.scaleInPlace(l);
          e.addToRef(c, i);
        }
        return i;
      }, n.prototype.equals = function(t) {
        return t && this._x === t._x && this._y === t._y && this._z === t._z;
      }, n.prototype.equalsWithEpsilon = function(t, e) {
        return e === void 0 && (e = Ge), t && ue.WithinEpsilon(this._x, t._x, e) && ue.WithinEpsilon(this._y, t._y, e) && ue.WithinEpsilon(this._z, t._z, e);
      }, n.prototype.equalsToFloats = function(t, e, i) {
        return this._x === t && this._y === e && this._z === i;
      }, n.prototype.multiplyInPlace = function(t) {
        return this._x *= t._x, this._y *= t._y, this._z *= t._z, this._isDirty = !0, this;
      }, n.prototype.multiply = function(t) {
        return this.multiplyByFloats(t._x, t._y, t._z);
      }, n.prototype.multiplyToRef = function(t, e) {
        return e.copyFromFloats(this._x * t._x, this._y * t._y, this._z * t._z);
      }, n.prototype.multiplyByFloats = function(t, e, i) {
        return new this.constructor(this._x * t, this._y * e, this._z * i);
      }, n.prototype.divide = function(t) {
        return new this.constructor(this._x / t._x, this._y / t._y, this._z / t._z);
      }, n.prototype.divideToRef = function(t, e) {
        return e.copyFromFloats(this._x / t._x, this._y / t._y, this._z / t._z);
      }, n.prototype.divideInPlace = function(t) {
        return this.divideToRef(t, this);
      }, n.prototype.minimizeInPlace = function(t) {
        return this.minimizeInPlaceFromFloats(t._x, t._y, t._z);
      }, n.prototype.maximizeInPlace = function(t) {
        return this.maximizeInPlaceFromFloats(t._x, t._y, t._z);
      }, n.prototype.minimizeInPlaceFromFloats = function(t, e, i) {
        return t < this._x && (this.x = t), e < this._y && (this.y = e), i < this._z && (this.z = i), this;
      }, n.prototype.maximizeInPlaceFromFloats = function(t, e, i) {
        return t > this._x && (this.x = t), e > this._y && (this.y = e), i > this._z && (this.z = i), this;
      }, n.prototype.isNonUniformWithinEpsilon = function(t) {
        var e = Math.abs(this._x), i = Math.abs(this._y);
        if (!ue.WithinEpsilon(e, i, t))
          return !0;
        var r = Math.abs(this._z);
        return !ue.WithinEpsilon(e, r, t) || !ue.WithinEpsilon(i, r, t);
      }, Object.defineProperty(n.prototype, "isNonUniform", { get: function() {
        var t = Math.abs(this._x);
        return t !== Math.abs(this._y) || t !== Math.abs(this._z);
      }, enumerable: !1, configurable: !0 }), n.prototype.floor = function() {
        return new this.constructor(Math.floor(this._x), Math.floor(this._y), Math.floor(this._z));
      }, n.prototype.fract = function() {
        return new this.constructor(this._x - Math.floor(this._x), this._y - Math.floor(this._y), this._z - Math.floor(this._z));
      }, n.prototype.length = function() {
        return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z);
      }, n.prototype.lengthSquared = function() {
        return this._x * this._x + this._y * this._y + this._z * this._z;
      }, Object.defineProperty(n.prototype, "hasAZeroComponent", { get: function() {
        return this._x * this._y * this._z == 0;
      }, enumerable: !1, configurable: !0 }), n.prototype.normalize = function() {
        return this.normalizeFromLength(this.length());
      }, n.prototype.reorderInPlace = function(t) {
        if ((t = t.toLowerCase()) === "xyz")
          return this;
        var e = ze.Vector3[0].copyFrom(this);
        return this.x = e[t[0]], this.y = e[t[1]], this.z = e[t[2]], this;
      }, n.prototype.rotateByQuaternionToRef = function(t, e) {
        return t.toRotationMatrix(ze.Matrix[0]), n.TransformCoordinatesToRef(this, ze.Matrix[0], e), e;
      }, n.prototype.rotateByQuaternionAroundPointToRef = function(t, e, i) {
        return this.subtractToRef(e, ze.Vector3[0]), ze.Vector3[0].rotateByQuaternionToRef(t, ze.Vector3[0]), e.addToRef(ze.Vector3[0], i), i;
      }, n.prototype.cross = function(t) {
        var e = new this.constructor();
        return n.CrossToRef(this, t, e);
      }, n.prototype.normalizeFromLength = function(t) {
        return t === 0 || t === 1 ? this : this.scaleInPlace(1 / t);
      }, n.prototype.normalizeToNew = function() {
        var t = new this.constructor(0, 0, 0);
        return this.normalizeToRef(t), t;
      }, n.prototype.normalizeToRef = function(t) {
        var e = this.length();
        return e === 0 || e === 1 ? t.copyFromFloats(this._x, this._y, this._z) : this.scaleToRef(1 / e, t);
      }, n.prototype.clone = function() {
        return new this.constructor(this._x, this._y, this._z);
      }, n.prototype.copyFrom = function(t) {
        return this.copyFromFloats(t._x, t._y, t._z);
      }, n.prototype.copyFromFloats = function(t, e, i) {
        return this._x = t, this._y = e, this._z = i, this._isDirty = !0, this;
      }, n.prototype.set = function(t, e, i) {
        return this.copyFromFloats(t, e, i);
      }, n.prototype.setAll = function(t) {
        return this._x = this._y = this._z = t, this._isDirty = !0, this;
      }, n.GetClipFactor = function(t, e, i, r) {
        var o = n.Dot(t, i);
        return (o - r) / (o - n.Dot(e, i));
      }, n.GetAngleBetweenVectors = function(t, e, i) {
        var r = t.normalizeToRef(ze.Vector3[1]), o = e.normalizeToRef(ze.Vector3[2]), a = n.Dot(r, o);
        a = ue.Clamp(a, -1, 1);
        var s = Math.acos(a), l = ze.Vector3[3];
        return n.CrossToRef(r, o, l), n.Dot(l, i) > 0 ? isNaN(s) ? 0 : s : isNaN(s) ? -Math.PI : -Math.acos(a);
      }, n.GetAngleBetweenVectorsOnPlane = function(t, e, i) {
        ze.Vector3[0].copyFrom(t);
        var r = ze.Vector3[0];
        ze.Vector3[1].copyFrom(e);
        var o = ze.Vector3[1];
        ze.Vector3[2].copyFrom(i);
        var a = ze.Vector3[2], s = ze.Vector3[3], l = ze.Vector3[4];
        r.normalize(), o.normalize(), a.normalize(), n.CrossToRef(a, r, s), n.CrossToRef(s, a, l);
        var c = Math.atan2(n.Dot(o, s), n.Dot(o, l));
        return ue.NormalizeRadians(c);
      }, n.PitchYawRollToMoveBetweenPointsToRef = function(t, e, i) {
        var r = F.Vector3[0];
        return e.subtractToRef(t, r), i._y = Math.atan2(r.x, r.z) || 0, i._x = Math.atan2(Math.sqrt(Math.pow(r.x, 2) + Math.pow(r.z, 2)), r.y) || 0, i._z = 0, i._isDirty = !0, i;
      }, n.PitchYawRollToMoveBetweenPoints = function(t, e) {
        var i = n.Zero();
        return n.PitchYawRollToMoveBetweenPointsToRef(t, e, i);
      }, n.SlerpToRef = function(t, e, i, r) {
        i = ue.Clamp(i, 0, 1);
        var o = ze.Vector3[0], a = ze.Vector3[1];
        o.copyFrom(t);
        var s = o.length();
        o.normalizeFromLength(s), a.copyFrom(e);
        var l = a.length();
        a.normalizeFromLength(l);
        var c, u, h = n.Dot(o, a);
        if (h < 1 - Ge) {
          var d = Math.acos(h), p = 1 / Math.sin(d);
          c = Math.sin((1 - i) * d) * p, u = Math.sin(i * d) * p;
        } else
          c = 1 - i, u = i;
        return o.scaleInPlace(c), a.scaleInPlace(u), r.copyFrom(o).addInPlace(a), r.scaleInPlace(ue.Lerp(s, l, i)), r;
      }, n.SmoothToRef = function(t, e, i, r, o) {
        return n.SlerpToRef(t, e, r === 0 ? 1 : i / r, o), o;
      }, n.FromArray = function(t, e) {
        return e === void 0 && (e = 0), new n(t[e], t[e + 1], t[e + 2]);
      }, n.FromFloatArray = function(t, e) {
        return n.FromArray(t, e);
      }, n.FromArrayToRef = function(t, e, i) {
        return i._x = t[e], i._y = t[e + 1], i._z = t[e + 2], i._isDirty = !0, i;
      }, n.FromFloatArrayToRef = function(t, e, i) {
        return n.FromArrayToRef(t, e, i);
      }, n.FromFloatsToRef = function(t, e, i, r) {
        return r.copyFromFloats(t, e, i), r;
      }, n.Zero = function() {
        return new n(0, 0, 0);
      }, n.One = function() {
        return new n(1, 1, 1);
      }, n.Up = function() {
        return new n(0, 1, 0);
      }, Object.defineProperty(n, "UpReadOnly", { get: function() {
        return n._UpReadOnly;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "DownReadOnly", { get: function() {
        return n._DownReadOnly;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "RightReadOnly", { get: function() {
        return n._RightReadOnly;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "LeftReadOnly", { get: function() {
        return n._LeftReadOnly;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "LeftHandedForwardReadOnly", { get: function() {
        return n._LeftHandedForwardReadOnly;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "RightHandedForwardReadOnly", { get: function() {
        return n._RightHandedForwardReadOnly;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "LeftHandedBackwardReadOnly", { get: function() {
        return n._LeftHandedBackwardReadOnly;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "RightHandedBackwardReadOnly", { get: function() {
        return n._RightHandedBackwardReadOnly;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "ZeroReadOnly", { get: function() {
        return n._ZeroReadOnly;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "OneReadOnly", { get: function() {
        return n._OneReadOnly;
      }, enumerable: !1, configurable: !0 }), n.Down = function() {
        return new n(0, -1, 0);
      }, n.Forward = function(t) {
        return t === void 0 && (t = !1), new n(0, 0, t ? -1 : 1);
      }, n.Backward = function(t) {
        return t === void 0 && (t = !1), new n(0, 0, t ? 1 : -1);
      }, n.Right = function() {
        return new n(1, 0, 0);
      }, n.Left = function() {
        return new n(-1, 0, 0);
      }, n.Random = function(t, e) {
        return t === void 0 && (t = 0), e === void 0 && (e = 1), new n(ue.RandomRange(t, e), ue.RandomRange(t, e), ue.RandomRange(t, e));
      }, n.TransformCoordinates = function(t, e) {
        var i = n.Zero();
        return n.TransformCoordinatesToRef(t, e, i), i;
      }, n.TransformCoordinatesToRef = function(t, e, i) {
        return n.TransformCoordinatesFromFloatsToRef(t._x, t._y, t._z, e, i), i;
      }, n.TransformCoordinatesFromFloatsToRef = function(t, e, i, r, o) {
        var a = r.m, s = t * a[0] + e * a[4] + i * a[8] + a[12], l = t * a[1] + e * a[5] + i * a[9] + a[13], c = t * a[2] + e * a[6] + i * a[10] + a[14], u = 1 / (t * a[3] + e * a[7] + i * a[11] + a[15]);
        return o._x = s * u, o._y = l * u, o._z = c * u, o._isDirty = !0, o;
      }, n.TransformNormal = function(t, e) {
        var i = n.Zero();
        return n.TransformNormalToRef(t, e, i), i;
      }, n.TransformNormalToRef = function(t, e, i) {
        return this.TransformNormalFromFloatsToRef(t._x, t._y, t._z, e, i), i;
      }, n.TransformNormalFromFloatsToRef = function(t, e, i, r, o) {
        var a = r.m;
        return o._x = t * a[0] + e * a[4] + i * a[8], o._y = t * a[1] + e * a[5] + i * a[9], o._z = t * a[2] + e * a[6] + i * a[10], o._isDirty = !0, o;
      }, n.CatmullRom = function(t, e, i, r, o) {
        var a = o * o, s = o * a, l = 0.5 * (2 * e._x + (-t._x + i._x) * o + (2 * t._x - 5 * e._x + 4 * i._x - r._x) * a + (-t._x + 3 * e._x - 3 * i._x + r._x) * s), c = 0.5 * (2 * e._y + (-t._y + i._y) * o + (2 * t._y - 5 * e._y + 4 * i._y - r._y) * a + (-t._y + 3 * e._y - 3 * i._y + r._y) * s), u = 0.5 * (2 * e._z + (-t._z + i._z) * o + (2 * t._z - 5 * e._z + 4 * i._z - r._z) * a + (-t._z + 3 * e._z - 3 * i._z + r._z) * s);
        return new t.constructor(l, c, u);
      }, n.Clamp = function(t, e, i) {
        var r = new t.constructor();
        return n.ClampToRef(t, e, i, r), r;
      }, n.ClampToRef = function(t, e, i, r) {
        var o = t._x;
        o = (o = o > i._x ? i._x : o) < e._x ? e._x : o;
        var a = t._y;
        a = (a = a > i._y ? i._y : a) < e._y ? e._y : a;
        var s = t._z;
        return s = (s = s > i._z ? i._z : s) < e._z ? e._z : s, r.copyFromFloats(o, a, s), r;
      }, n.CheckExtends = function(t, e, i) {
        e.minimizeInPlace(t), i.maximizeInPlace(t);
      }, n.Hermite = function(t, e, i, r, o) {
        var a = o * o, s = o * a, l = 2 * s - 3 * a + 1, c = -2 * s + 3 * a, u = s - 2 * a + o, h = s - a, d = t._x * l + i._x * c + e._x * u + r._x * h, p = t._y * l + i._y * c + e._y * u + r._y * h, f = t._z * l + i._z * c + e._z * u + r._z * h;
        return new t.constructor(d, p, f);
      }, n.Hermite1stDerivative = function(t, e, i, r, o) {
        var a = new t.constructor();
        return this.Hermite1stDerivativeToRef(t, e, i, r, o, a), a;
      }, n.Hermite1stDerivativeToRef = function(t, e, i, r, o, a) {
        var s = o * o;
        return a._x = 6 * (s - o) * t._x + (3 * s - 4 * o + 1) * e._x + 6 * (-s + o) * i._x + (3 * s - 2 * o) * r._x, a._y = 6 * (s - o) * t._y + (3 * s - 4 * o + 1) * e._y + 6 * (-s + o) * i._y + (3 * s - 2 * o) * r._y, a._z = 6 * (s - o) * t._z + (3 * s - 4 * o + 1) * e._z + 6 * (-s + o) * i._z + (3 * s - 2 * o) * r._z, a._isDirty = !0, a;
      }, n.Lerp = function(t, e, i) {
        var r = new t.constructor(0, 0, 0);
        return n.LerpToRef(t, e, i, r), r;
      }, n.LerpToRef = function(t, e, i, r) {
        return r._x = t._x + (e._x - t._x) * i, r._y = t._y + (e._y - t._y) * i, r._z = t._z + (e._z - t._z) * i, r._isDirty = !0, r;
      }, n.Dot = function(t, e) {
        return t._x * e._x + t._y * e._y + t._z * e._z;
      }, n.prototype.dot = function(t) {
        return this._x * t._x + this._y * t._y + this._z * t._z;
      }, n.Cross = function(t, e) {
        var i = new t.constructor();
        return n.CrossToRef(t, e, i), i;
      }, n.CrossToRef = function(t, e, i) {
        var r = t._y * e._z - t._z * e._y, o = t._z * e._x - t._x * e._z, a = t._x * e._y - t._y * e._x;
        return i.copyFromFloats(r, o, a), i;
      }, n.Normalize = function(t) {
        var e = n.Zero();
        return n.NormalizeToRef(t, e), e;
      }, n.NormalizeToRef = function(t, e) {
        return t.normalizeToRef(e), e;
      }, n.Project = function(t, e, i, r) {
        var o = new t.constructor();
        return n.ProjectToRef(t, e, i, r, o), o;
      }, n.ProjectToRef = function(t, e, i, r, o) {
        var a = r.width, s = r.height, l = r.x, c = r.y, u = ze.Matrix[1];
        B.FromValuesToRef(a / 2, 0, 0, 0, 0, -s / 2, 0, 0, 0, 0, 0.5, 0, l + a / 2, s / 2 + c, 0.5, 1, u);
        var h = ze.Matrix[0];
        return e.multiplyToRef(i, h), h.multiplyToRef(u, h), n.TransformCoordinatesToRef(t, h, o), o;
      }, n.Reflect = function(t, e) {
        return this.ReflectToRef(t, e, new n());
      }, n.ReflectToRef = function(t, e, i) {
        var r = F.Vector3[0];
        return r.copyFrom(e).scaleInPlace(2 * n.Dot(t, e)), i.copyFrom(t).subtractInPlace(r);
      }, n._UnprojectFromInvertedMatrixToRef = function(t, e, i) {
        n.TransformCoordinatesToRef(t, e, i);
        var r = e.m, o = t._x * r[3] + t._y * r[7] + t._z * r[11] + r[15];
        return ue.WithinEpsilon(o, 1) && i.scaleInPlace(1 / o), i;
      }, n.UnprojectFromTransform = function(t, e, i, r, o) {
        return this.Unproject(t, e, i, r, o, B.IdentityReadOnly);
      }, n.Unproject = function(t, e, i, r, o, a) {
        var s = new t.constructor();
        return n.UnprojectToRef(t, e, i, r, o, a, s), s;
      }, n.UnprojectToRef = function(t, e, i, r, o, a, s) {
        return n.UnprojectFloatsToRef(t._x, t._y, t._z, e, i, r, o, a, s), s;
      }, n.UnprojectFloatsToRef = function(t, e, i, r, o, a, s, l, c) {
        var u, h = ze.Matrix[0];
        a.multiplyToRef(s, h), h.multiplyToRef(l, h), h.invert();
        var d = ze.Vector3[0];
        return d.x = t / r * 2 - 1, d.y = -(e / o * 2 - 1), !((u = Me.LastCreatedEngine) === null || u === void 0) && u.isNDCHalfZRange ? d.z = i : d.z = 2 * i - 1, n._UnprojectFromInvertedMatrixToRef(d, h, c), c;
      }, n.Minimize = function(t, e) {
        var i = new t.constructor();
        return i.copyFrom(t), i.minimizeInPlace(e), i;
      }, n.Maximize = function(t, e) {
        var i = new t.constructor();
        return i.copyFrom(t), i.maximizeInPlace(e), i;
      }, n.Distance = function(t, e) {
        return Math.sqrt(n.DistanceSquared(t, e));
      }, n.DistanceSquared = function(t, e) {
        var i = t._x - e._x, r = t._y - e._y, o = t._z - e._z;
        return i * i + r * r + o * o;
      }, n.ProjectOnTriangleToRef = function(t, e, i, r, o) {
        var a = ze.Vector3[0], s = ze.Vector3[1], l = ze.Vector3[2], c = ze.Vector3[3], u = ze.Vector3[4];
        i.subtractToRef(e, a), r.subtractToRef(e, s), r.subtractToRef(i, l);
        var h = a.length(), d = s.length(), p = l.length();
        if (h < Ge || d < Ge || p < Ge)
          return o.copyFrom(e), n.Distance(t, e);
        t.subtractToRef(e, u), n.CrossToRef(a, s, c);
        var f = c.length();
        if (f < Ge)
          return o.copyFrom(e), n.Distance(t, e);
        c.normalizeFromLength(f);
        var m = u.length();
        if (m < Ge)
          return o.copyFrom(e), 0;
        u.normalizeFromLength(m);
        var g = n.Dot(c, u), y = ze.Vector3[5], b = ze.Vector3[6];
        y.copyFrom(c).scaleInPlace(-m * g), b.copyFrom(t).addInPlace(y);
        var T = ze.Vector3[4], S = ze.Vector3[5], E = ze.Vector3[7], A = ze.Vector3[8];
        T.copyFrom(a).scaleInPlace(1 / h), A.copyFrom(s).scaleInPlace(1 / d), T.addInPlace(A).scaleInPlace(-1), S.copyFrom(a).scaleInPlace(-1 / h), A.copyFrom(l).scaleInPlace(1 / p), S.addInPlace(A).scaleInPlace(-1), E.copyFrom(l).scaleInPlace(-1 / p), A.copyFrom(s).scaleInPlace(-1 / d), E.addInPlace(A).scaleInPlace(-1);
        var R = ze.Vector3[9];
        R.copyFrom(b).subtractInPlace(e), n.CrossToRef(T, R, A);
        var C = n.Dot(A, c);
        R.copyFrom(b).subtractInPlace(i), n.CrossToRef(S, R, A);
        var L = n.Dot(A, c);
        R.copyFrom(b).subtractInPlace(r), n.CrossToRef(E, R, A);
        var I, O, w = n.Dot(A, c), z = ze.Vector3[10];
        C > 0 && L < 0 ? (z.copyFrom(a), I = e, O = i) : L > 0 && w < 0 ? (z.copyFrom(l), I = i, O = r) : (z.copyFrom(s).scaleInPlace(-1), I = r, O = e);
        var V = ze.Vector3[9], Y = ze.Vector3[4];
        if (I.subtractToRef(b, A), O.subtractToRef(b, V), n.CrossToRef(A, V, Y), !(n.Dot(Y, c) < 0))
          return o.copyFrom(b), Math.abs(m * g);
        var ee = ze.Vector3[5];
        n.CrossToRef(z, Y, ee), ee.normalize();
        var J = ze.Vector3[9];
        J.copyFrom(I).subtractInPlace(b);
        var X = J.length();
        if (X < Ge)
          return o.copyFrom(I), n.Distance(t, I);
        J.normalizeFromLength(X);
        var K = n.Dot(ee, J), te = ze.Vector3[7];
        te.copyFrom(b).addInPlace(ee.scaleInPlace(X * K)), A.copyFrom(te).subtractInPlace(I), m = z.length(), z.normalizeFromLength(m);
        var se = n.Dot(A, z) / Math.max(m, Ge);
        return se = ue.Clamp(se, 0, 1), te.copyFrom(I).addInPlace(z.scaleInPlace(se * m)), o.copyFrom(te), n.Distance(t, te);
      }, n.Center = function(t, e) {
        return n.CenterToRef(t, e, n.Zero());
      }, n.CenterToRef = function(t, e, i) {
        return i.copyFromFloats((t._x + e._x) / 2, (t._y + e._y) / 2, (t._z + e._z) / 2);
      }, n.RotationFromAxis = function(t, e, i) {
        var r = new t.constructor();
        return n.RotationFromAxisToRef(t, e, i, r), r;
      }, n.RotationFromAxisToRef = function(t, e, i, r) {
        var o = ze.Quaternion[0];
        return oe.RotationQuaternionFromAxisToRef(t, e, i, o), o.toEulerAnglesToRef(r), r;
      }, n._UpReadOnly = n.Up(), n._DownReadOnly = n.Down(), n._LeftHandedForwardReadOnly = n.Forward(!1), n._RightHandedForwardReadOnly = n.Forward(!0), n._LeftHandedBackwardReadOnly = n.Backward(!1), n._RightHandedBackwardReadOnly = n.Backward(!0), n._RightReadOnly = n.Right(), n._LeftReadOnly = n.Left(), n._ZeroReadOnly = n.Zero(), n._OneReadOnly = n.One(), n;
    }(), lt = function() {
      function n(t, e, i, r) {
        t === void 0 && (t = 0), e === void 0 && (e = 0), i === void 0 && (i = 0), r === void 0 && (r = 0), this.x = t, this.y = e, this.z = i, this.w = r;
      }
      return n.prototype.toString = function() {
        return "{X: ".concat(this.x, " Y: ").concat(this.y, " Z: ").concat(this.z, " W: ").concat(this.w, "}");
      }, n.prototype.getClassName = function() {
        return "Vector4";
      }, n.prototype.getHashCode = function() {
        var t = Zt(this.x);
        return 397 * (t = 397 * (t = 397 * t ^ Zt(this.y)) ^ Zt(this.z)) ^ Zt(this.w);
      }, n.prototype.asArray = function() {
        var t = [];
        return this.toArray(t, 0), t;
      }, n.prototype.toArray = function(t, e) {
        return e === void 0 && (e = 0), t[e] = this.x, t[e + 1] = this.y, t[e + 2] = this.z, t[e + 3] = this.w, this;
      }, n.prototype.fromArray = function(t, e) {
        return e === void 0 && (e = 0), n.FromArrayToRef(t, e, this), this;
      }, n.prototype.addInPlace = function(t) {
        return this.x += t.x, this.y += t.y, this.z += t.z, this.w += t.w, this;
      }, n.prototype.add = function(t) {
        return new this.constructor(this.x + t.x, this.y + t.y, this.z + t.z, this.w + t.w);
      }, n.prototype.addToRef = function(t, e) {
        return e.x = this.x + t.x, e.y = this.y + t.y, e.z = this.z + t.z, e.w = this.w + t.w, e;
      }, n.prototype.subtractInPlace = function(t) {
        return this.x -= t.x, this.y -= t.y, this.z -= t.z, this.w -= t.w, this;
      }, n.prototype.subtract = function(t) {
        return new this.constructor(this.x - t.x, this.y - t.y, this.z - t.z, this.w - t.w);
      }, n.prototype.subtractToRef = function(t, e) {
        return e.x = this.x - t.x, e.y = this.y - t.y, e.z = this.z - t.z, e.w = this.w - t.w, e;
      }, n.prototype.subtractFromFloats = function(t, e, i, r) {
        return new this.constructor(this.x - t, this.y - e, this.z - i, this.w - r);
      }, n.prototype.subtractFromFloatsToRef = function(t, e, i, r, o) {
        return o.x = this.x - t, o.y = this.y - e, o.z = this.z - i, o.w = this.w - r, o;
      }, n.prototype.negate = function() {
        return new this.constructor(-this.x, -this.y, -this.z, -this.w);
      }, n.prototype.negateInPlace = function() {
        return this.x *= -1, this.y *= -1, this.z *= -1, this.w *= -1, this;
      }, n.prototype.negateToRef = function(t) {
        return t.copyFromFloats(-1 * this.x, -1 * this.y, -1 * this.z, -1 * this.w);
      }, n.prototype.scaleInPlace = function(t) {
        return this.x *= t, this.y *= t, this.z *= t, this.w *= t, this;
      }, n.prototype.scale = function(t) {
        return new this.constructor(this.x * t, this.y * t, this.z * t, this.w * t);
      }, n.prototype.scaleToRef = function(t, e) {
        return e.x = this.x * t, e.y = this.y * t, e.z = this.z * t, e.w = this.w * t, e;
      }, n.prototype.scaleAndAddToRef = function(t, e) {
        return e.x += this.x * t, e.y += this.y * t, e.z += this.z * t, e.w += this.w * t, e;
      }, n.prototype.equals = function(t) {
        return t && this.x === t.x && this.y === t.y && this.z === t.z && this.w === t.w;
      }, n.prototype.equalsWithEpsilon = function(t, e) {
        return e === void 0 && (e = Ge), t && ue.WithinEpsilon(this.x, t.x, e) && ue.WithinEpsilon(this.y, t.y, e) && ue.WithinEpsilon(this.z, t.z, e) && ue.WithinEpsilon(this.w, t.w, e);
      }, n.prototype.equalsToFloats = function(t, e, i, r) {
        return this.x === t && this.y === e && this.z === i && this.w === r;
      }, n.prototype.multiplyInPlace = function(t) {
        return this.x *= t.x, this.y *= t.y, this.z *= t.z, this.w *= t.w, this;
      }, n.prototype.multiply = function(t) {
        return new this.constructor(this.x * t.x, this.y * t.y, this.z * t.z, this.w * t.w);
      }, n.prototype.multiplyToRef = function(t, e) {
        return e.x = this.x * t.x, e.y = this.y * t.y, e.z = this.z * t.z, e.w = this.w * t.w, e;
      }, n.prototype.multiplyByFloats = function(t, e, i, r) {
        return new this.constructor(this.x * t, this.y * e, this.z * i, this.w * r);
      }, n.prototype.divide = function(t) {
        return new this.constructor(this.x / t.x, this.y / t.y, this.z / t.z, this.w / t.w);
      }, n.prototype.divideToRef = function(t, e) {
        return e.x = this.x / t.x, e.y = this.y / t.y, e.z = this.z / t.z, e.w = this.w / t.w, e;
      }, n.prototype.divideInPlace = function(t) {
        return this.divideToRef(t, this);
      }, n.prototype.minimizeInPlace = function(t) {
        return t.x < this.x && (this.x = t.x), t.y < this.y && (this.y = t.y), t.z < this.z && (this.z = t.z), t.w < this.w && (this.w = t.w), this;
      }, n.prototype.maximizeInPlace = function(t) {
        return t.x > this.x && (this.x = t.x), t.y > this.y && (this.y = t.y), t.z > this.z && (this.z = t.z), t.w > this.w && (this.w = t.w), this;
      }, n.prototype.floor = function() {
        return new this.constructor(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z), Math.floor(this.w));
      }, n.prototype.fract = function() {
        return new this.constructor(this.x - Math.floor(this.x), this.y - Math.floor(this.y), this.z - Math.floor(this.z), this.w - Math.floor(this.w));
      }, n.prototype.length = function() {
        return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
      }, n.prototype.lengthSquared = function() {
        return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
      }, n.prototype.normalize = function() {
        return this.normalizeFromLength(this.length());
      }, n.prototype.normalizeFromLength = function(t) {
        return t === 0 || t === 1 ? this : this.scaleInPlace(1 / t);
      }, n.prototype.normalizeToNew = function() {
        var t = new this.constructor(0, 0, 0, 0);
        return this.normalizeToRef(t), t;
      }, n.prototype.normalizeToRef = function(t) {
        var e = this.length();
        return e === 0 || e === 1 ? t.copyFromFloats(this.x, this.y, this.z, this.w) : this.scaleToRef(1 / e, t);
      }, n.prototype.toVector3 = function() {
        return new v(this.x, this.y, this.z);
      }, n.prototype.clone = function() {
        return new this.constructor(this.x, this.y, this.z, this.w);
      }, n.prototype.copyFrom = function(t) {
        return this.x = t.x, this.y = t.y, this.z = t.z, this.w = t.w, this;
      }, n.prototype.copyFromFloats = function(t, e, i, r) {
        return this.x = t, this.y = e, this.z = i, this.w = r, this;
      }, n.prototype.set = function(t, e, i, r) {
        return this.copyFromFloats(t, e, i, r);
      }, n.prototype.setAll = function(t) {
        return this.x = this.y = this.z = this.w = t, this;
      }, n.prototype.dot = function(t) {
        return this.x * t.x + this.y * t.y + this.z * t.z + this.w * t.w;
      }, n.FromArray = function(t, e) {
        return e || (e = 0), new n(t[e], t[e + 1], t[e + 2], t[e + 3]);
      }, n.FromArrayToRef = function(t, e, i) {
        return i.x = t[e], i.y = t[e + 1], i.z = t[e + 2], i.w = t[e + 3], i;
      }, n.FromFloatArrayToRef = function(t, e, i) {
        return n.FromArrayToRef(t, e, i), i;
      }, n.FromFloatsToRef = function(t, e, i, r, o) {
        return o.x = t, o.y = e, o.z = i, o.w = r, o;
      }, n.Zero = function() {
        return new n(0, 0, 0, 0);
      }, n.One = function() {
        return new n(1, 1, 1, 1);
      }, n.Random = function(t, e) {
        return t === void 0 && (t = 0), e === void 0 && (e = 1), new n(ue.RandomRange(t, e), ue.RandomRange(t, e), ue.RandomRange(t, e), ue.RandomRange(t, e));
      }, Object.defineProperty(n, "ZeroReadOnly", { get: function() {
        return n._ZeroReadOnly;
      }, enumerable: !1, configurable: !0 }), n.Normalize = function(t) {
        var e = n.Zero();
        return n.NormalizeToRef(t, e), e;
      }, n.NormalizeToRef = function(t, e) {
        return t.normalizeToRef(e), e;
      }, n.Minimize = function(t, e) {
        var i = new t.constructor();
        return i.copyFrom(t), i.minimizeInPlace(e), i;
      }, n.Maximize = function(t, e) {
        var i = new t.constructor();
        return i.copyFrom(t), i.maximizeInPlace(e), i;
      }, n.Distance = function(t, e) {
        return Math.sqrt(n.DistanceSquared(t, e));
      }, n.DistanceSquared = function(t, e) {
        var i = t.x - e.x, r = t.y - e.y, o = t.z - e.z, a = t.w - e.w;
        return i * i + r * r + o * o + a * a;
      }, n.Center = function(t, e) {
        return n.CenterToRef(t, e, n.Zero());
      }, n.CenterToRef = function(t, e, i) {
        return i.copyFromFloats((t.x + e.x) / 2, (t.y + e.y) / 2, (t.z + e.z) / 2, (t.w + e.w) / 2);
      }, n.TransformCoordinates = function(t, e) {
        var i = n.Zero();
        return n.TransformCoordinatesToRef(t, e, i), i;
      }, n.TransformCoordinatesToRef = function(t, e, i) {
        return n.TransformCoordinatesFromFloatsToRef(t._x, t._y, t._z, e, i), i;
      }, n.TransformCoordinatesFromFloatsToRef = function(t, e, i, r, o) {
        var a = r.m, s = t * a[0] + e * a[4] + i * a[8] + a[12], l = t * a[1] + e * a[5] + i * a[9] + a[13], c = t * a[2] + e * a[6] + i * a[10] + a[14], u = t * a[3] + e * a[7] + i * a[11] + a[15];
        return o.x = s, o.y = l, o.z = c, o.w = u, o;
      }, n.TransformNormal = function(t, e) {
        var i = new t.constructor();
        return n.TransformNormalToRef(t, e, i), i;
      }, n.TransformNormalToRef = function(t, e, i) {
        var r = e.m, o = t.x * r[0] + t.y * r[4] + t.z * r[8], a = t.x * r[1] + t.y * r[5] + t.z * r[9], s = t.x * r[2] + t.y * r[6] + t.z * r[10];
        return i.x = o, i.y = a, i.z = s, i.w = t.w, i;
      }, n.TransformNormalFromFloatsToRef = function(t, e, i, r, o, a) {
        var s = o.m;
        return a.x = t * s[0] + e * s[4] + i * s[8], a.y = t * s[1] + e * s[5] + i * s[9], a.z = t * s[2] + e * s[6] + i * s[10], a.w = r, a;
      }, n.FromVector3 = function(t, e) {
        return e === void 0 && (e = 0), new n(t._x, t._y, t._z, e);
      }, n.Dot = function(t, e) {
        return t.dot(e);
      }, n._ZeroReadOnly = n.Zero(), n;
    }(), oe = function() {
      function n(t, e, i, r) {
        t === void 0 && (t = 0), e === void 0 && (e = 0), i === void 0 && (i = 0), r === void 0 && (r = 1), this._isDirty = !0, this._x = t, this._y = e, this._z = i, this._w = r;
      }
      return Object.defineProperty(n.prototype, "x", { get: function() {
        return this._x;
      }, set: function(t) {
        this._x = t, this._isDirty = !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "y", { get: function() {
        return this._y;
      }, set: function(t) {
        this._y = t, this._isDirty = !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "z", { get: function() {
        return this._z;
      }, set: function(t) {
        this._z = t, this._isDirty = !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "w", { get: function() {
        return this._w;
      }, set: function(t) {
        this._w = t, this._isDirty = !0;
      }, enumerable: !1, configurable: !0 }), n.prototype.toString = function() {
        return "{X: ".concat(this._x, " Y: ").concat(this._y, " Z: ").concat(this._z, " W: ").concat(this._w, "}");
      }, n.prototype.getClassName = function() {
        return "Quaternion";
      }, n.prototype.getHashCode = function() {
        var t = Zt(this._x);
        return 397 * (t = 397 * (t = 397 * t ^ Zt(this._y)) ^ Zt(this._z)) ^ Zt(this._w);
      }, n.prototype.asArray = function() {
        return [this._x, this._y, this._z, this._w];
      }, n.prototype.toArray = function(t, e) {
        return e === void 0 && (e = 0), t[e] = this._x, t[e + 1] = this._y, t[e + 2] = this._z, t[e + 3] = this._w, this;
      }, n.prototype.equals = function(t) {
        return t && this._x === t._x && this._y === t._y && this._z === t._z && this._w === t._w;
      }, n.prototype.equalsWithEpsilon = function(t, e) {
        return e === void 0 && (e = Ge), t && ue.WithinEpsilon(this._x, t._x, e) && ue.WithinEpsilon(this._y, t._y, e) && ue.WithinEpsilon(this._z, t._z, e) && ue.WithinEpsilon(this._w, t._w, e);
      }, n.prototype.clone = function() {
        return new this.constructor(this._x, this._y, this._z, this._w);
      }, n.prototype.copyFrom = function(t) {
        return this._x = t._x, this._y = t._y, this._z = t._z, this._w = t._w, this._isDirty = !0, this;
      }, n.prototype.copyFromFloats = function(t, e, i, r) {
        return this._x = t, this._y = e, this._z = i, this._w = r, this._isDirty = !0, this;
      }, n.prototype.set = function(t, e, i, r) {
        return this.copyFromFloats(t, e, i, r);
      }, n.prototype.add = function(t) {
        return new this.constructor(this._x + t._x, this._y + t._y, this._z + t._z, this._w + t._w);
      }, n.prototype.addInPlace = function(t) {
        return this._x += t._x, this._y += t._y, this._z += t._z, this._w += t._w, this._isDirty = !0, this;
      }, n.prototype.subtract = function(t) {
        return new this.constructor(this._x - t._x, this._y - t._y, this._z - t._z, this._w - t._w);
      }, n.prototype.subtractInPlace = function(t) {
        return this._x -= t._x, this._y -= t._y, this._z -= t._z, this._w -= t._w, this._isDirty = !0, this;
      }, n.prototype.scale = function(t) {
        return new this.constructor(this._x * t, this._y * t, this._z * t, this._w * t);
      }, n.prototype.scaleToRef = function(t, e) {
        return e._x = this._x * t, e._y = this._y * t, e._z = this._z * t, e._w = this._w * t, e._isDirty = !0, e;
      }, n.prototype.scaleInPlace = function(t) {
        return this._x *= t, this._y *= t, this._z *= t, this._w *= t, this._isDirty = !0, this;
      }, n.prototype.scaleAndAddToRef = function(t, e) {
        return e._x += this._x * t, e._y += this._y * t, e._z += this._z * t, e._w += this._w * t, e._isDirty = !0, e;
      }, n.prototype.multiply = function(t) {
        var e = new this.constructor(0, 0, 0, 1);
        return this.multiplyToRef(t, e), e;
      }, n.prototype.multiplyToRef = function(t, e) {
        var i = this._x * t._w + this._y * t._z - this._z * t._y + this._w * t._x, r = -this._x * t._z + this._y * t._w + this._z * t._x + this._w * t._y, o = this._x * t._y - this._y * t._x + this._z * t._w + this._w * t._z, a = -this._x * t._x - this._y * t._y - this._z * t._z + this._w * t._w;
        return e.copyFromFloats(i, r, o, a), e;
      }, n.prototype.multiplyInPlace = function(t) {
        return this.multiplyToRef(t, this), this;
      }, n.prototype.conjugateToRef = function(t) {
        return t.copyFromFloats(-this._x, -this._y, -this._z, this._w), t;
      }, n.prototype.conjugateInPlace = function() {
        return this._x *= -1, this._y *= -1, this._z *= -1, this._isDirty = !0, this;
      }, n.prototype.conjugate = function() {
        return new this.constructor(-this._x, -this._y, -this._z, this._w);
      }, n.prototype.invert = function() {
        var t = this.conjugate(), e = this.lengthSquared();
        return e == 0 || e == 1 || t.scaleInPlace(1 / e), t;
      }, n.prototype.invertInPlace = function() {
        this.conjugateInPlace();
        var t = this.lengthSquared();
        return t == 0 || t == 1 || this.scaleInPlace(1 / t), this;
      }, n.prototype.lengthSquared = function() {
        return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
      }, n.prototype.length = function() {
        return Math.sqrt(this.lengthSquared());
      }, n.prototype.normalize = function() {
        return this.normalizeFromLength(this.length());
      }, n.prototype.normalizeFromLength = function(t) {
        return t === 0 || t === 1 ? this : this.scaleInPlace(1 / t);
      }, n.prototype.normalizeToNew = function() {
        var t = new this.constructor(0, 0, 0, 1);
        return this.normalizeToRef(t), t;
      }, n.prototype.normalizeToRef = function(t) {
        var e = this.length();
        return e === 0 || e === 1 ? t.copyFromFloats(this._x, this._y, this._z, this._w) : this.scaleToRef(1 / e, t);
      }, n.prototype.toEulerAngles = function() {
        var t = v.Zero();
        return this.toEulerAnglesToRef(t), t;
      }, n.prototype.toEulerAnglesToRef = function(t) {
        var e = this._z, i = this._x, r = this._y, o = this._w, a = r * e - i * o, s = 0.4999999;
        if (a < -s)
          t._y = 2 * Math.atan2(r, o), t._x = Math.PI / 2, t._z = 0, t._isDirty = !0;
        else if (a > s)
          t._y = 2 * Math.atan2(r, o), t._x = -Math.PI / 2, t._z = 0, t._isDirty = !0;
        else {
          var l = o * o, c = e * e, u = i * i, h = r * r;
          t._z = Math.atan2(2 * (i * r + e * o), -c - u + h + l), t._x = Math.asin(-2 * a), t._y = Math.atan2(2 * (e * i + r * o), c - u - h + l), t._isDirty = !0;
        }
        return t;
      }, n.prototype.toRotationMatrix = function(t) {
        return B.FromQuaternionToRef(this, t), t;
      }, n.prototype.fromRotationMatrix = function(t) {
        return n.FromRotationMatrixToRef(t, this), this;
      }, n.prototype.dot = function(t) {
        return this._x * t._x + this._y * t._y + this._z * t._z + this._w * t._w;
      }, n.FromRotationMatrix = function(t) {
        var e = new n();
        return n.FromRotationMatrixToRef(t, e), e;
      }, n.FromRotationMatrixToRef = function(t, e) {
        var i, r = t.m, o = r[0], a = r[4], s = r[8], l = r[1], c = r[5], u = r[9], h = r[2], d = r[6], p = r[10], f = o + c + p;
        return f > 0 ? (i = 0.5 / Math.sqrt(f + 1), e._w = 0.25 / i, e._x = (d - u) * i, e._y = (s - h) * i, e._z = (l - a) * i, e._isDirty = !0) : o > c && o > p ? (i = 2 * Math.sqrt(1 + o - c - p), e._w = (d - u) / i, e._x = 0.25 * i, e._y = (a + l) / i, e._z = (s + h) / i, e._isDirty = !0) : c > p ? (i = 2 * Math.sqrt(1 + c - o - p), e._w = (s - h) / i, e._x = (a + l) / i, e._y = 0.25 * i, e._z = (u + d) / i, e._isDirty = !0) : (i = 2 * Math.sqrt(1 + p - o - c), e._w = (l - a) / i, e._x = (s + h) / i, e._y = (u + d) / i, e._z = 0.25 * i, e._isDirty = !0), e;
      }, n.Dot = function(t, e) {
        return t._x * e._x + t._y * e._y + t._z * e._z + t._w * e._w;
      }, n.AreClose = function(t, e, i) {
        i === void 0 && (i = 0.1);
        var r = n.Dot(t, e);
        return 1 - r * r <= i;
      }, n.SmoothToRef = function(t, e, i, r, o) {
        var a = r === 0 ? 1 : i / r;
        return a = ue.Clamp(a, 0, 1), n.SlerpToRef(t, e, a, o), o;
      }, n.Zero = function() {
        return new n(0, 0, 0, 0);
      }, n.Inverse = function(t) {
        return new t.constructor(-t._x, -t._y, -t._z, t._w);
      }, n.InverseToRef = function(t, e) {
        return e.set(-t._x, -t._y, -t._z, t._w), e;
      }, n.Identity = function() {
        return new n(0, 0, 0, 1);
      }, n.IsIdentity = function(t) {
        return t && t._x === 0 && t._y === 0 && t._z === 0 && t._w === 1;
      }, n.RotationAxis = function(t, e) {
        return n.RotationAxisToRef(t, e, new n());
      }, n.RotationAxisToRef = function(t, e, i) {
        var r = Math.sin(e / 2);
        return t.normalize(), i._w = Math.cos(e / 2), i._x = t._x * r, i._y = t._y * r, i._z = t._z * r, i._isDirty = !0, i;
      }, n.FromArray = function(t, e) {
        return e || (e = 0), new n(t[e], t[e + 1], t[e + 2], t[e + 3]);
      }, n.FromArrayToRef = function(t, e, i) {
        return i._x = t[e], i._y = t[e + 1], i._z = t[e + 2], i._w = t[e + 3], i._isDirty = !0, i;
      }, n.FromEulerAngles = function(t, e, i) {
        var r = new n();
        return n.RotationYawPitchRollToRef(e, t, i, r), r;
      }, n.FromEulerAnglesToRef = function(t, e, i, r) {
        return n.RotationYawPitchRollToRef(e, t, i, r), r;
      }, n.FromEulerVector = function(t) {
        var e = new n();
        return n.RotationYawPitchRollToRef(t._y, t._x, t._z, e), e;
      }, n.FromEulerVectorToRef = function(t, e) {
        return n.RotationYawPitchRollToRef(t._y, t._x, t._z, e), e;
      }, n.FromUnitVectorsToRef = function(t, e, i, r) {
        r === void 0 && (r = Ge);
        var o = v.Dot(t, e) + 1;
        return o < r ? Math.abs(t.x) > Math.abs(t.z) ? i.set(-t.y, t.x, 0, 0) : i.set(0, -t.z, t.y, 0) : (v.CrossToRef(t, e, F.Vector3[0]), i.set(F.Vector3[0].x, F.Vector3[0].y, F.Vector3[0].z, o)), i.normalize();
      }, n.RotationYawPitchRoll = function(t, e, i) {
        var r = new n();
        return n.RotationYawPitchRollToRef(t, e, i, r), r;
      }, n.RotationYawPitchRollToRef = function(t, e, i, r) {
        var o = 0.5 * i, a = 0.5 * e, s = 0.5 * t, l = Math.sin(o), c = Math.cos(o), u = Math.sin(a), h = Math.cos(a), d = Math.sin(s), p = Math.cos(s);
        return r._x = p * u * c + d * h * l, r._y = d * h * c - p * u * l, r._z = p * h * l - d * u * c, r._w = p * h * c + d * u * l, r._isDirty = !0, r;
      }, n.RotationAlphaBetaGamma = function(t, e, i) {
        var r = new n();
        return n.RotationAlphaBetaGammaToRef(t, e, i, r), r;
      }, n.RotationAlphaBetaGammaToRef = function(t, e, i, r) {
        var o = 0.5 * (i + t), a = 0.5 * (i - t), s = 0.5 * e;
        return r._x = Math.cos(a) * Math.sin(s), r._y = Math.sin(a) * Math.sin(s), r._z = Math.sin(o) * Math.cos(s), r._w = Math.cos(o) * Math.cos(s), r._isDirty = !0, r;
      }, n.RotationQuaternionFromAxis = function(t, e, i) {
        var r = new n(0, 0, 0, 0);
        return n.RotationQuaternionFromAxisToRef(t, e, i, r), r;
      }, n.RotationQuaternionFromAxisToRef = function(t, e, i, r) {
        var o = ze.Matrix[0];
        return B.FromXYZAxesToRef(t.normalize(), e.normalize(), i.normalize(), o), n.FromRotationMatrixToRef(o, r), r;
      }, n.FromLookDirectionLH = function(t, e) {
        var i = new n();
        return n.FromLookDirectionLHToRef(t, e, i), i;
      }, n.FromLookDirectionLHToRef = function(t, e, i) {
        var r = ze.Matrix[0];
        return B.LookDirectionLHToRef(t, e, r), n.FromRotationMatrixToRef(r, i), i;
      }, n.FromLookDirectionRH = function(t, e) {
        var i = new n();
        return n.FromLookDirectionRHToRef(t, e, i), i;
      }, n.FromLookDirectionRHToRef = function(t, e, i) {
        var r = ze.Matrix[0];
        return B.LookDirectionRHToRef(t, e, r), n.FromRotationMatrixToRef(r, i);
      }, n.Slerp = function(t, e, i) {
        var r = n.Identity();
        return n.SlerpToRef(t, e, i, r), r;
      }, n.SlerpToRef = function(t, e, i, r) {
        var o, a, s = t._x * e._x + t._y * e._y + t._z * e._z + t._w * e._w, l = !1;
        if (s < 0 && (l = !0, s = -s), s > 0.999999)
          a = 1 - i, o = l ? -i : i;
        else {
          var c = Math.acos(s), u = 1 / Math.sin(c);
          a = Math.sin((1 - i) * c) * u, o = l ? -Math.sin(i * c) * u : Math.sin(i * c) * u;
        }
        return r._x = a * t._x + o * e._x, r._y = a * t._y + o * e._y, r._z = a * t._z + o * e._z, r._w = a * t._w + o * e._w, r._isDirty = !0, r;
      }, n.Hermite = function(t, e, i, r, o) {
        var a = o * o, s = o * a, l = 2 * s - 3 * a + 1, c = -2 * s + 3 * a, u = s - 2 * a + o, h = s - a, d = t._x * l + i._x * c + e._x * u + r._x * h, p = t._y * l + i._y * c + e._y * u + r._y * h, f = t._z * l + i._z * c + e._z * u + r._z * h, m = t._w * l + i._w * c + e._w * u + r._w * h;
        return new t.constructor(d, p, f, m);
      }, n.Hermite1stDerivative = function(t, e, i, r, o) {
        var a = new t.constructor();
        return this.Hermite1stDerivativeToRef(t, e, i, r, o, a), a;
      }, n.Hermite1stDerivativeToRef = function(t, e, i, r, o, a) {
        var s = o * o;
        return a._x = 6 * (s - o) * t._x + (3 * s - 4 * o + 1) * e._x + 6 * (-s + o) * i._x + (3 * s - 2 * o) * r._x, a._y = 6 * (s - o) * t._y + (3 * s - 4 * o + 1) * e._y + 6 * (-s + o) * i._y + (3 * s - 2 * o) * r._y, a._z = 6 * (s - o) * t._z + (3 * s - 4 * o + 1) * e._z + 6 * (-s + o) * i._z + (3 * s - 2 * o) * r._z, a._w = 6 * (s - o) * t._w + (3 * s - 4 * o + 1) * e._w + 6 * (-s + o) * i._w + (3 * s - 2 * o) * r._w, a._isDirty = !0, a;
      }, n.Normalize = function(t) {
        var e = n.Zero();
        return n.NormalizeToRef(t, e), e;
      }, n.NormalizeToRef = function(t, e) {
        return t.normalizeToRef(e), e;
      }, n;
    }(), B = function() {
      function n() {
        this._isIdentity = !1, this._isIdentityDirty = !0, this._isIdentity3x2 = !0, this._isIdentity3x2Dirty = !0, this.updateFlag = -1, Ti.MatrixTrackPrecisionChange && Ti.MatrixTrackedMatrices.push(this), this._m = new Ti.MatrixCurrentType(16), this.markAsUpdated();
      }
      return Object.defineProperty(n, "Use64Bits", { get: function() {
        return Ti.MatrixUse64Bits;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "m", { get: function() {
        return this._m;
      }, enumerable: !1, configurable: !0 }), n.prototype.markAsUpdated = function() {
        this.updateFlag = n._UpdateFlagSeed++, this._isIdentity = !1, this._isIdentity3x2 = !1, this._isIdentityDirty = !0, this._isIdentity3x2Dirty = !0;
      }, n.prototype._updateIdentityStatus = function(t, e, i, r) {
        e === void 0 && (e = !1), i === void 0 && (i = !1), r === void 0 && (r = !0), this._isIdentity = t, this._isIdentity3x2 = t || i, this._isIdentityDirty = !this._isIdentity && e, this._isIdentity3x2Dirty = !this._isIdentity3x2 && r;
      }, n.prototype.isIdentity = function() {
        if (this._isIdentityDirty) {
          this._isIdentityDirty = !1;
          var t = this._m;
          this._isIdentity = t[0] === 1 && t[1] === 0 && t[2] === 0 && t[3] === 0 && t[4] === 0 && t[5] === 1 && t[6] === 0 && t[7] === 0 && t[8] === 0 && t[9] === 0 && t[10] === 1 && t[11] === 0 && t[12] === 0 && t[13] === 0 && t[14] === 0 && t[15] === 1;
        }
        return this._isIdentity;
      }, n.prototype.isIdentityAs3x2 = function() {
        return this._isIdentity3x2Dirty && (this._isIdentity3x2Dirty = !1, this._m[0] !== 1 || this._m[5] !== 1 || this._m[15] !== 1 || this._m[1] !== 0 || this._m[2] !== 0 || this._m[3] !== 0 || this._m[4] !== 0 || this._m[6] !== 0 || this._m[7] !== 0 || this._m[8] !== 0 || this._m[9] !== 0 || this._m[10] !== 0 || this._m[11] !== 0 || this._m[12] !== 0 || this._m[13] !== 0 || this._m[14] !== 0 ? this._isIdentity3x2 = !1 : this._isIdentity3x2 = !0), this._isIdentity3x2;
      }, n.prototype.determinant = function() {
        if (this._isIdentity === !0)
          return 1;
        var t = this._m, e = t[0], i = t[1], r = t[2], o = t[3], a = t[4], s = t[5], l = t[6], c = t[7], u = t[8], h = t[9], d = t[10], p = t[11], f = t[12], m = t[13], g = t[14], y = t[15], b = d * y - g * p, T = h * y - m * p, S = h * g - m * d, E = u * y - f * p, A = u * g - d * f, R = u * m - f * h;
        return e * +(s * b - l * T + c * S) + i * -(a * b - l * E + c * A) + r * +(a * T - s * E + c * R) + o * -(a * S - s * A + l * R);
      }, n.prototype.toString = function() {
        return "{".concat(this.m[0], ", ").concat(this.m[1], ", ").concat(this.m[2], ", ").concat(this.m[3], `
`).concat(this.m[4], ", ").concat(this.m[5], ", ").concat(this.m[6], ", ").concat(this.m[7], `
`).concat(this.m[8], ", ").concat(this.m[9], ", ").concat(this.m[10], ", ").concat(this.m[11], `
`).concat(this.m[12], ", ").concat(this.m[13], ", ").concat(this.m[14], ", ").concat(this.m[15], "}");
      }, n.prototype.toArray = function() {
        return this._m;
      }, n.prototype.asArray = function() {
        return this._m;
      }, n.prototype.invert = function() {
        return this.invertToRef(this), this;
      }, n.prototype.reset = function() {
        return n.FromValuesToRef(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, this), this._updateIdentityStatus(!1), this;
      }, n.prototype.add = function(t) {
        var e = new this.constructor();
        return this.addToRef(t, e), e;
      }, n.prototype.addToRef = function(t, e) {
        for (var i = this._m, r = e._m, o = t.m, a = 0; a < 16; a++)
          r[a] = i[a] + o[a];
        return e.markAsUpdated(), e;
      }, n.prototype.addToSelf = function(t) {
        for (var e = this._m, i = t.m, r = 0; r < 16; r++)
          e[r] += i[r];
        return this.markAsUpdated(), this;
      }, n.prototype.invertToRef = function(t) {
        if (this._isIdentity === !0)
          return n.IdentityToRef(t), t;
        var e = this._m, i = e[0], r = e[1], o = e[2], a = e[3], s = e[4], l = e[5], c = e[6], u = e[7], h = e[8], d = e[9], p = e[10], f = e[11], m = e[12], g = e[13], y = e[14], b = e[15], T = p * b - y * f, S = d * b - g * f, E = d * y - g * p, A = h * b - m * f, R = h * y - p * m, C = h * g - m * d, L = +(l * T - c * S + u * E), I = -(s * T - c * A + u * R), O = +(s * S - l * A + u * C), w = -(s * E - l * R + c * C), z = i * L + r * I + o * O + a * w;
        if (z === 0)
          return t.copyFrom(this), t;
        var V = 1 / z, Y = c * b - y * u, ee = l * b - g * u, J = l * y - g * c, X = s * b - m * u, K = s * y - m * c, te = s * g - m * l, se = c * f - p * u, _e = l * f - d * u, xe = l * p - d * c, Te = s * f - h * u, he = s * p - h * c, me = s * d - h * l, Fe = -(r * T - o * S + a * E), Ce = +(i * T - o * A + a * R), Re = -(i * S - r * A + a * C), Be = +(i * E - r * R + o * C), De = +(r * Y - o * ee + a * J), Ke = -(i * Y - o * X + a * K), ge = +(i * ee - r * X + a * te), rt = -(i * J - r * K + o * te), it = -(r * se - o * _e + a * xe), He = +(i * se - o * Te + a * he), Pt = -(i * _e - r * Te + a * me), ke = +(i * xe - r * he + o * me);
        return n.FromValuesToRef(L * V, Fe * V, De * V, it * V, I * V, Ce * V, Ke * V, He * V, O * V, Re * V, ge * V, Pt * V, w * V, Be * V, rt * V, ke * V, t), t;
      }, n.prototype.addAtIndex = function(t, e) {
        return this._m[t] += e, this.markAsUpdated(), this;
      }, n.prototype.multiplyAtIndex = function(t, e) {
        return this._m[t] *= e, this.markAsUpdated(), this;
      }, n.prototype.setTranslationFromFloats = function(t, e, i) {
        return this._m[12] = t, this._m[13] = e, this._m[14] = i, this.markAsUpdated(), this;
      }, n.prototype.addTranslationFromFloats = function(t, e, i) {
        return this._m[12] += t, this._m[13] += e, this._m[14] += i, this.markAsUpdated(), this;
      }, n.prototype.setTranslation = function(t) {
        return this.setTranslationFromFloats(t._x, t._y, t._z);
      }, n.prototype.getTranslation = function() {
        return new v(this._m[12], this._m[13], this._m[14]);
      }, n.prototype.getTranslationToRef = function(t) {
        return t.x = this._m[12], t.y = this._m[13], t.z = this._m[14], t;
      }, n.prototype.removeRotationAndScaling = function() {
        var t = this.m;
        return n.FromValuesToRef(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, t[12], t[13], t[14], t[15], this), this._updateIdentityStatus(t[12] === 0 && t[13] === 0 && t[14] === 0 && t[15] === 1), this;
      }, n.prototype.multiply = function(t) {
        var e = new this.constructor();
        return this.multiplyToRef(t, e), e;
      }, n.prototype.copyFrom = function(t) {
        t.copyToArray(this._m);
        var e = t;
        return this.updateFlag = e.updateFlag, this._updateIdentityStatus(e._isIdentity, e._isIdentityDirty, e._isIdentity3x2, e._isIdentity3x2Dirty), this;
      }, n.prototype.copyToArray = function(t, e) {
        e === void 0 && (e = 0);
        var i = this._m;
        return t[e] = i[0], t[e + 1] = i[1], t[e + 2] = i[2], t[e + 3] = i[3], t[e + 4] = i[4], t[e + 5] = i[5], t[e + 6] = i[6], t[e + 7] = i[7], t[e + 8] = i[8], t[e + 9] = i[9], t[e + 10] = i[10], t[e + 11] = i[11], t[e + 12] = i[12], t[e + 13] = i[13], t[e + 14] = i[14], t[e + 15] = i[15], this;
      }, n.prototype.multiplyToRef = function(t, e) {
        return this._isIdentity ? (e.copyFrom(t), e) : t._isIdentity ? (e.copyFrom(this), e) : (this.multiplyToArray(t, e._m, 0), e.markAsUpdated(), e);
      }, n.prototype.multiplyToArray = function(t, e, i) {
        var r = this._m, o = t.m, a = r[0], s = r[1], l = r[2], c = r[3], u = r[4], h = r[5], d = r[6], p = r[7], f = r[8], m = r[9], g = r[10], y = r[11], b = r[12], T = r[13], S = r[14], E = r[15], A = o[0], R = o[1], C = o[2], L = o[3], I = o[4], O = o[5], w = o[6], z = o[7], V = o[8], Y = o[9], ee = o[10], J = o[11], X = o[12], K = o[13], te = o[14], se = o[15];
        return e[i] = a * A + s * I + l * V + c * X, e[i + 1] = a * R + s * O + l * Y + c * K, e[i + 2] = a * C + s * w + l * ee + c * te, e[i + 3] = a * L + s * z + l * J + c * se, e[i + 4] = u * A + h * I + d * V + p * X, e[i + 5] = u * R + h * O + d * Y + p * K, e[i + 6] = u * C + h * w + d * ee + p * te, e[i + 7] = u * L + h * z + d * J + p * se, e[i + 8] = f * A + m * I + g * V + y * X, e[i + 9] = f * R + m * O + g * Y + y * K, e[i + 10] = f * C + m * w + g * ee + y * te, e[i + 11] = f * L + m * z + g * J + y * se, e[i + 12] = b * A + T * I + S * V + E * X, e[i + 13] = b * R + T * O + S * Y + E * K, e[i + 14] = b * C + T * w + S * ee + E * te, e[i + 15] = b * L + T * z + S * J + E * se, this;
      }, n.prototype.equals = function(t) {
        var e = t;
        if (!e)
          return !1;
        if ((this._isIdentity || e._isIdentity) && !this._isIdentityDirty && !e._isIdentityDirty)
          return this._isIdentity && e._isIdentity;
        var i = this.m, r = e.m;
        return i[0] === r[0] && i[1] === r[1] && i[2] === r[2] && i[3] === r[3] && i[4] === r[4] && i[5] === r[5] && i[6] === r[6] && i[7] === r[7] && i[8] === r[8] && i[9] === r[9] && i[10] === r[10] && i[11] === r[11] && i[12] === r[12] && i[13] === r[13] && i[14] === r[14] && i[15] === r[15];
      }, n.prototype.clone = function() {
        var t = new this.constructor();
        return t.copyFrom(this), t;
      }, n.prototype.getClassName = function() {
        return "Matrix";
      }, n.prototype.getHashCode = function() {
        for (var t = Zt(this._m[0]), e = 1; e < 16; e++)
          t = 397 * t ^ Zt(this._m[e]);
        return t;
      }, n.prototype.decomposeToTransformNode = function(t) {
        return t.rotationQuaternion = t.rotationQuaternion || new oe(), this.decompose(t.scaling, t.rotationQuaternion, t.position);
      }, n.prototype.decompose = function(t, e, i, r) {
        if (this._isIdentity)
          return i && i.setAll(0), t && t.setAll(1), e && e.copyFromFloats(0, 0, 0, 1), !0;
        var o = this._m;
        if (i && i.copyFromFloats(o[12], o[13], o[14]), (t = t || ze.Vector3[0]).x = Math.sqrt(o[0] * o[0] + o[1] * o[1] + o[2] * o[2]), t.y = Math.sqrt(o[4] * o[4] + o[5] * o[5] + o[6] * o[6]), t.z = Math.sqrt(o[8] * o[8] + o[9] * o[9] + o[10] * o[10]), r) {
          var a = r.absoluteScaling.x < 0 ? -1 : 1, s = r.absoluteScaling.y < 0 ? -1 : 1, l = r.absoluteScaling.z < 0 ? -1 : 1;
          t.x *= a, t.y *= s, t.z *= l;
        } else
          this.determinant() <= 0 && (t.y *= -1);
        if (t._x === 0 || t._y === 0 || t._z === 0)
          return e && e.copyFromFloats(0, 0, 0, 1), !1;
        if (e) {
          var c = 1 / t._x, u = 1 / t._y, h = 1 / t._z;
          n.FromValuesToRef(o[0] * c, o[1] * c, o[2] * c, 0, o[4] * u, o[5] * u, o[6] * u, 0, o[8] * h, o[9] * h, o[10] * h, 0, 0, 0, 0, 1, ze.Matrix[0]), oe.FromRotationMatrixToRef(ze.Matrix[0], e);
        }
        return !0;
      }, n.prototype.getRow = function(t) {
        if (t < 0 || t > 3)
          return null;
        var e = 4 * t;
        return new lt(this._m[e + 0], this._m[e + 1], this._m[e + 2], this._m[e + 3]);
      }, n.prototype.getRowToRef = function(t, e) {
        if (t >= 0 && t <= 3) {
          var i = 4 * t;
          e.x = this._m[i + 0], e.y = this._m[i + 1], e.z = this._m[i + 2], e.w = this._m[i + 3];
        }
        return e;
      }, n.prototype.setRow = function(t, e) {
        return this.setRowFromFloats(t, e.x, e.y, e.z, e.w);
      }, n.prototype.transpose = function() {
        var t = new this.constructor();
        return n.TransposeToRef(this, t), t;
      }, n.prototype.transposeToRef = function(t) {
        return n.TransposeToRef(this, t), t;
      }, n.prototype.setRowFromFloats = function(t, e, i, r, o) {
        if (t < 0 || t > 3)
          return this;
        var a = 4 * t;
        return this._m[a + 0] = e, this._m[a + 1] = i, this._m[a + 2] = r, this._m[a + 3] = o, this.markAsUpdated(), this;
      }, n.prototype.scale = function(t) {
        var e = new this.constructor();
        return this.scaleToRef(t, e), e;
      }, n.prototype.scaleToRef = function(t, e) {
        for (var i = 0; i < 16; i++)
          e._m[i] = this._m[i] * t;
        return e.markAsUpdated(), e;
      }, n.prototype.scaleAndAddToRef = function(t, e) {
        for (var i = 0; i < 16; i++)
          e._m[i] += this._m[i] * t;
        return e.markAsUpdated(), e;
      }, n.prototype.toNormalMatrix = function(t) {
        var e = ze.Matrix[0];
        this.invertToRef(e), e.transposeToRef(t);
        var i = t._m;
        return n.FromValuesToRef(i[0], i[1], i[2], 0, i[4], i[5], i[6], 0, i[8], i[9], i[10], 0, 0, 0, 0, 1, t), t;
      }, n.prototype.getRotationMatrix = function() {
        var t = new this.constructor();
        return this.getRotationMatrixToRef(t), t;
      }, n.prototype.getRotationMatrixToRef = function(t) {
        var e = ze.Vector3[0];
        if (!this.decompose(e))
          return n.IdentityToRef(t), t;
        var i = this._m, r = 1 / e._x, o = 1 / e._y, a = 1 / e._z;
        return n.FromValuesToRef(i[0] * r, i[1] * r, i[2] * r, 0, i[4] * o, i[5] * o, i[6] * o, 0, i[8] * a, i[9] * a, i[10] * a, 0, 0, 0, 0, 1, t), t;
      }, n.prototype.toggleModelMatrixHandInPlace = function() {
        var t = this._m;
        return t[2] *= -1, t[6] *= -1, t[8] *= -1, t[9] *= -1, t[14] *= -1, this.markAsUpdated(), this;
      }, n.prototype.toggleProjectionMatrixHandInPlace = function() {
        var t = this._m;
        return t[8] *= -1, t[9] *= -1, t[10] *= -1, t[11] *= -1, this.markAsUpdated(), this;
      }, n.FromArray = function(t, e) {
        e === void 0 && (e = 0);
        var i = new n();
        return n.FromArrayToRef(t, e, i), i;
      }, n.FromArrayToRef = function(t, e, i) {
        for (var r = 0; r < 16; r++)
          i._m[r] = t[r + e];
        return i.markAsUpdated(), i;
      }, n.FromFloat32ArrayToRefScaled = function(t, e, i, r) {
        for (var o = 0; o < 16; o++)
          r._m[o] = t[o + e] * i;
        return r.markAsUpdated(), r;
      }, Object.defineProperty(n, "IdentityReadOnly", { get: function() {
        return n._IdentityReadOnly;
      }, enumerable: !1, configurable: !0 }), n.FromValuesToRef = function(t, e, i, r, o, a, s, l, c, u, h, d, p, f, m, g, y) {
        var b = y._m;
        b[0] = t, b[1] = e, b[2] = i, b[3] = r, b[4] = o, b[5] = a, b[6] = s, b[7] = l, b[8] = c, b[9] = u, b[10] = h, b[11] = d, b[12] = p, b[13] = f, b[14] = m, b[15] = g, y.markAsUpdated();
      }, n.FromValues = function(t, e, i, r, o, a, s, l, c, u, h, d, p, f, m, g) {
        var y = new n(), b = y._m;
        return b[0] = t, b[1] = e, b[2] = i, b[3] = r, b[4] = o, b[5] = a, b[6] = s, b[7] = l, b[8] = c, b[9] = u, b[10] = h, b[11] = d, b[12] = p, b[13] = f, b[14] = m, b[15] = g, y.markAsUpdated(), y;
      }, n.Compose = function(t, e, i) {
        var r = new n();
        return n.ComposeToRef(t, e, i, r), r;
      }, n.ComposeToRef = function(t, e, i, r) {
        var o = r._m, a = e._x, s = e._y, l = e._z, c = e._w, u = a + a, h = s + s, d = l + l, p = a * u, f = a * h, m = a * d, g = s * h, y = s * d, b = l * d, T = c * u, S = c * h, E = c * d, A = t._x, R = t._y, C = t._z;
        return o[0] = (1 - (g + b)) * A, o[1] = (f + E) * A, o[2] = (m - S) * A, o[3] = 0, o[4] = (f - E) * R, o[5] = (1 - (p + b)) * R, o[6] = (y + T) * R, o[7] = 0, o[8] = (m + S) * C, o[9] = (y - T) * C, o[10] = (1 - (p + g)) * C, o[11] = 0, o[12] = i._x, o[13] = i._y, o[14] = i._z, o[15] = 1, r.markAsUpdated(), r;
      }, n.Identity = function() {
        var t = n.FromValues(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
        return t._updateIdentityStatus(!0), t;
      }, n.IdentityToRef = function(t) {
        return n.FromValuesToRef(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, t), t._updateIdentityStatus(!0), t;
      }, n.Zero = function() {
        var t = n.FromValues(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
        return t._updateIdentityStatus(!1), t;
      }, n.RotationX = function(t) {
        var e = new n();
        return n.RotationXToRef(t, e), e;
      }, n.Invert = function(t) {
        var e = new t.constructor();
        return t.invertToRef(e), e;
      }, n.RotationXToRef = function(t, e) {
        var i = Math.sin(t), r = Math.cos(t);
        return n.FromValuesToRef(1, 0, 0, 0, 0, r, i, 0, 0, -i, r, 0, 0, 0, 0, 1, e), e._updateIdentityStatus(r === 1 && i === 0), e;
      }, n.RotationY = function(t) {
        var e = new n();
        return n.RotationYToRef(t, e), e;
      }, n.RotationYToRef = function(t, e) {
        var i = Math.sin(t), r = Math.cos(t);
        return n.FromValuesToRef(r, 0, -i, 0, 0, 1, 0, 0, i, 0, r, 0, 0, 0, 0, 1, e), e._updateIdentityStatus(r === 1 && i === 0), e;
      }, n.RotationZ = function(t) {
        var e = new n();
        return n.RotationZToRef(t, e), e;
      }, n.RotationZToRef = function(t, e) {
        var i = Math.sin(t), r = Math.cos(t);
        return n.FromValuesToRef(r, i, 0, 0, -i, r, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, e), e._updateIdentityStatus(r === 1 && i === 0), e;
      }, n.RotationAxis = function(t, e) {
        var i = new n();
        return n.RotationAxisToRef(t, e, i), i;
      }, n.RotationAxisToRef = function(t, e, i) {
        var r = Math.sin(-e), o = Math.cos(-e), a = 1 - o;
        t.normalize();
        var s = i._m;
        return s[0] = t._x * t._x * a + o, s[1] = t._x * t._y * a - t._z * r, s[2] = t._x * t._z * a + t._y * r, s[3] = 0, s[4] = t._y * t._x * a + t._z * r, s[5] = t._y * t._y * a + o, s[6] = t._y * t._z * a - t._x * r, s[7] = 0, s[8] = t._z * t._x * a - t._y * r, s[9] = t._z * t._y * a + t._x * r, s[10] = t._z * t._z * a + o, s[11] = 0, s[12] = 0, s[13] = 0, s[14] = 0, s[15] = 1, i.markAsUpdated(), i;
      }, n.RotationAlignToRef = function(t, e, i, r) {
        r === void 0 && (r = !1);
        var o = v.Dot(e, t), a = i._m;
        if (o < -1 + Ge)
          a[0] = -1, a[1] = 0, a[2] = 0, a[3] = 0, a[4] = 0, a[5] = r ? 1 : -1, a[6] = 0, a[7] = 0, a[8] = 0, a[9] = 0, a[10] = r ? -1 : 1, a[11] = 0;
        else {
          var s = v.Cross(e, t), l = 1 / (1 + o);
          a[0] = s._x * s._x * l + o, a[1] = s._y * s._x * l - s._z, a[2] = s._z * s._x * l + s._y, a[3] = 0, a[4] = s._x * s._y * l + s._z, a[5] = s._y * s._y * l + o, a[6] = s._z * s._y * l - s._x, a[7] = 0, a[8] = s._x * s._z * l - s._y, a[9] = s._y * s._z * l + s._x, a[10] = s._z * s._z * l + o, a[11] = 0;
        }
        return a[12] = 0, a[13] = 0, a[14] = 0, a[15] = 1, i.markAsUpdated(), i;
      }, n.RotationYawPitchRoll = function(t, e, i) {
        var r = new n();
        return n.RotationYawPitchRollToRef(t, e, i, r), r;
      }, n.RotationYawPitchRollToRef = function(t, e, i, r) {
        return oe.RotationYawPitchRollToRef(t, e, i, ze.Quaternion[0]), ze.Quaternion[0].toRotationMatrix(r), r;
      }, n.Scaling = function(t, e, i) {
        var r = new n();
        return n.ScalingToRef(t, e, i, r), r;
      }, n.ScalingToRef = function(t, e, i, r) {
        return n.FromValuesToRef(t, 0, 0, 0, 0, e, 0, 0, 0, 0, i, 0, 0, 0, 0, 1, r), r._updateIdentityStatus(t === 1 && e === 1 && i === 1), r;
      }, n.Translation = function(t, e, i) {
        var r = new n();
        return n.TranslationToRef(t, e, i, r), r;
      }, n.TranslationToRef = function(t, e, i, r) {
        return n.FromValuesToRef(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, t, e, i, 1, r), r._updateIdentityStatus(t === 0 && e === 0 && i === 0), r;
      }, n.Lerp = function(t, e, i) {
        var r = new t.constructor();
        return n.LerpToRef(t, e, i, r), r;
      }, n.LerpToRef = function(t, e, i, r) {
        for (var o = r._m, a = t.m, s = e.m, l = 0; l < 16; l++)
          o[l] = a[l] * (1 - i) + s[l] * i;
        return r.markAsUpdated(), r;
      }, n.DecomposeLerp = function(t, e, i) {
        var r = new t.constructor();
        return n.DecomposeLerpToRef(t, e, i, r), r;
      }, n.DecomposeLerpToRef = function(t, e, i, r) {
        var o = ze.Vector3[0], a = ze.Quaternion[0], s = ze.Vector3[1];
        t.decompose(o, a, s);
        var l = ze.Vector3[2], c = ze.Quaternion[1], u = ze.Vector3[3];
        e.decompose(l, c, u);
        var h = ze.Vector3[4];
        v.LerpToRef(o, l, i, h);
        var d = ze.Quaternion[2];
        oe.SlerpToRef(a, c, i, d);
        var p = ze.Vector3[5];
        return v.LerpToRef(s, u, i, p), n.ComposeToRef(h, d, p, r), r;
      }, n.LookAtLH = function(t, e, i) {
        var r = new n();
        return n.LookAtLHToRef(t, e, i, r), r;
      }, n.LookAtLHToRef = function(t, e, i, r) {
        var o = ze.Vector3[0], a = ze.Vector3[1], s = ze.Vector3[2];
        e.subtractToRef(t, s), s.normalize(), v.CrossToRef(i, s, o);
        var l = o.lengthSquared();
        l === 0 ? o.x = 1 : o.normalizeFromLength(Math.sqrt(l)), v.CrossToRef(s, o, a), a.normalize();
        var c = -v.Dot(o, t), u = -v.Dot(a, t), h = -v.Dot(s, t);
        return n.FromValuesToRef(o._x, a._x, s._x, 0, o._y, a._y, s._y, 0, o._z, a._z, s._z, 0, c, u, h, 1, r), r;
      }, n.LookAtRH = function(t, e, i) {
        var r = new n();
        return n.LookAtRHToRef(t, e, i, r), r;
      }, n.LookAtRHToRef = function(t, e, i, r) {
        var o = ze.Vector3[0], a = ze.Vector3[1], s = ze.Vector3[2];
        t.subtractToRef(e, s), s.normalize(), v.CrossToRef(i, s, o);
        var l = o.lengthSquared();
        l === 0 ? o.x = 1 : o.normalizeFromLength(Math.sqrt(l)), v.CrossToRef(s, o, a), a.normalize();
        var c = -v.Dot(o, t), u = -v.Dot(a, t), h = -v.Dot(s, t);
        return n.FromValuesToRef(o._x, a._x, s._x, 0, o._y, a._y, s._y, 0, o._z, a._z, s._z, 0, c, u, h, 1, r), r;
      }, n.LookDirectionLH = function(t, e) {
        var i = new n();
        return n.LookDirectionLHToRef(t, e, i), i;
      }, n.LookDirectionLHToRef = function(t, e, i) {
        var r = ze.Vector3[0];
        r.copyFrom(t), r.scaleInPlace(-1);
        var o = ze.Vector3[1];
        return v.CrossToRef(e, r, o), n.FromValuesToRef(o._x, o._y, o._z, 0, e._x, e._y, e._z, 0, r._x, r._y, r._z, 0, 0, 0, 0, 1, i), i;
      }, n.LookDirectionRH = function(t, e) {
        var i = new n();
        return n.LookDirectionRHToRef(t, e, i), i;
      }, n.LookDirectionRHToRef = function(t, e, i) {
        var r = ze.Vector3[2];
        return v.CrossToRef(e, t, r), n.FromValuesToRef(r._x, r._y, r._z, 0, e._x, e._y, e._z, 0, t._x, t._y, t._z, 0, 0, 0, 0, 1, i), i;
      }, n.OrthoLH = function(t, e, i, r, o) {
        var a = new n();
        return n.OrthoLHToRef(t, e, i, r, a, o), a;
      }, n.OrthoLHToRef = function(t, e, i, r, o, a) {
        var s = 2 / t, l = 2 / e, c = 2 / (r - i), u = -(r + i) / (r - i);
        return n.FromValuesToRef(s, 0, 0, 0, 0, l, 0, 0, 0, 0, c, 0, 0, 0, u, 1, o), a && o.multiplyToRef(ur, o), o._updateIdentityStatus(s === 1 && l === 1 && c === 1 && u === 0), o;
      }, n.OrthoOffCenterLH = function(t, e, i, r, o, a, s) {
        var l = new n();
        return n.OrthoOffCenterLHToRef(t, e, i, r, o, a, l, s), l;
      }, n.OrthoOffCenterLHToRef = function(t, e, i, r, o, a, s, l) {
        var c = 2 / (e - t), u = 2 / (r - i), h = 2 / (a - o), d = -(a + o) / (a - o), p = (t + e) / (t - e), f = (r + i) / (i - r);
        return n.FromValuesToRef(c, 0, 0, 0, 0, u, 0, 0, 0, 0, h, 0, p, f, d, 1, s), l && s.multiplyToRef(ur, s), s.markAsUpdated(), s;
      }, n.ObliqueOffCenterLHToRef = function(t, e, i, r, o, a, s, l, c, u, h) {
        var d = -s * Math.cos(l), p = -s * Math.sin(l);
        return n.TranslationToRef(0, 0, -c, ze.Matrix[1]), n.FromValuesToRef(1, 0, 0, 0, 0, 1, 0, 0, d, p, 1, 0, 0, 0, 0, 1, ze.Matrix[0]), ze.Matrix[1].multiplyToRef(ze.Matrix[0], ze.Matrix[0]), n.TranslationToRef(0, 0, c, ze.Matrix[1]), ze.Matrix[0].multiplyToRef(ze.Matrix[1], ze.Matrix[0]), n.OrthoOffCenterLHToRef(t, e, i, r, o, a, u, h), ze.Matrix[0].multiplyToRef(u, u), u;
      }, n.OrthoOffCenterRH = function(t, e, i, r, o, a, s) {
        var l = new n();
        return n.OrthoOffCenterRHToRef(t, e, i, r, o, a, l, s), l;
      }, n.OrthoOffCenterRHToRef = function(t, e, i, r, o, a, s, l) {
        return n.OrthoOffCenterLHToRef(t, e, i, r, o, a, s, l), s._m[10] *= -1, s;
      }, n.ObliqueOffCenterRHToRef = function(t, e, i, r, o, a, s, l, c, u, h) {
        var d = s * Math.cos(l), p = s * Math.sin(l);
        return n.TranslationToRef(0, 0, c, ze.Matrix[1]), n.FromValuesToRef(1, 0, 0, 0, 0, 1, 0, 0, d, p, 1, 0, 0, 0, 0, 1, ze.Matrix[0]), ze.Matrix[1].multiplyToRef(ze.Matrix[0], ze.Matrix[0]), n.TranslationToRef(0, 0, -c, ze.Matrix[1]), ze.Matrix[0].multiplyToRef(ze.Matrix[1], ze.Matrix[0]), n.OrthoOffCenterRHToRef(t, e, i, r, o, a, u, h), ze.Matrix[0].multiplyToRef(u, u), u;
      }, n.PerspectiveLH = function(t, e, i, r, o, a) {
        a === void 0 && (a = 0);
        var s = new n(), l = 2 * i / t, c = 2 * i / e, u = (r + i) / (r - i), h = -2 * r * i / (r - i), d = Math.tan(a);
        return n.FromValuesToRef(l, 0, 0, 0, 0, c, 0, d, 0, 0, u, 1, 0, 0, h, 0, s), o && s.multiplyToRef(ur, s), s._updateIdentityStatus(!1), s;
      }, n.PerspectiveFovLH = function(t, e, i, r, o, a, s) {
        a === void 0 && (a = 0), s === void 0 && (s = !1);
        var l = new n();
        return n.PerspectiveFovLHToRef(t, e, i, r, l, !0, o, a, s), l;
      }, n.PerspectiveFovLHToRef = function(t, e, i, r, o, a, s, l, c) {
        a === void 0 && (a = !0), l === void 0 && (l = 0), c === void 0 && (c = !1);
        var u = i, h = r, d = 1 / Math.tan(0.5 * t), p = a ? d / e : d, f = a ? d : d * e, m = c && u === 0 ? -1 : h !== 0 ? (h + u) / (h - u) : 1, g = c && u === 0 ? 2 * h : h !== 0 ? -2 * h * u / (h - u) : -2 * u, y = Math.tan(l);
        return n.FromValuesToRef(p, 0, 0, 0, 0, f, 0, y, 0, 0, m, 1, 0, 0, g, 0, o), s && o.multiplyToRef(ur, o), o._updateIdentityStatus(!1), o;
      }, n.PerspectiveFovReverseLHToRef = function(t, e, i, r, o, a, s, l) {
        a === void 0 && (a = !0), l === void 0 && (l = 0);
        var c = 1 / Math.tan(0.5 * t), u = a ? c / e : c, h = a ? c : c * e, d = Math.tan(l);
        return n.FromValuesToRef(u, 0, 0, 0, 0, h, 0, d, 0, 0, -i, 1, 0, 0, 1, 0, o), s && o.multiplyToRef(ur, o), o._updateIdentityStatus(!1), o;
      }, n.PerspectiveFovRH = function(t, e, i, r, o, a, s) {
        a === void 0 && (a = 0), s === void 0 && (s = !1);
        var l = new n();
        return n.PerspectiveFovRHToRef(t, e, i, r, l, !0, o, a, s), l;
      }, n.PerspectiveFovRHToRef = function(t, e, i, r, o, a, s, l, c) {
        a === void 0 && (a = !0), l === void 0 && (l = 0), c === void 0 && (c = !1);
        var u = i, h = r, d = 1 / Math.tan(0.5 * t), p = a ? d / e : d, f = a ? d : d * e, m = c && u === 0 ? 1 : h !== 0 ? -(h + u) / (h - u) : -1, g = c && u === 0 ? 2 * h : h !== 0 ? -2 * h * u / (h - u) : -2 * u, y = Math.tan(l);
        return n.FromValuesToRef(p, 0, 0, 0, 0, f, 0, y, 0, 0, m, -1, 0, 0, g, 0, o), s && o.multiplyToRef(ur, o), o._updateIdentityStatus(!1), o;
      }, n.PerspectiveFovReverseRHToRef = function(t, e, i, r, o, a, s, l) {
        a === void 0 && (a = !0), l === void 0 && (l = 0);
        var c = 1 / Math.tan(0.5 * t), u = a ? c / e : c, h = a ? c : c * e, d = Math.tan(l);
        return n.FromValuesToRef(u, 0, 0, 0, 0, h, 0, d, 0, 0, -i, -1, 0, 0, -1, 0, o), s && o.multiplyToRef(ur, o), o._updateIdentityStatus(!1), o;
      }, n.GetFinalMatrix = function(t, e, i, r, o, a) {
        var s = t.width, l = t.height, c = t.x, u = t.y, h = n.FromValues(s / 2, 0, 0, 0, 0, -l / 2, 0, 0, 0, 0, a - o, 0, c + s / 2, l / 2 + u, o, 1), d = new e.constructor();
        return e.multiplyToRef(i, d), d.multiplyToRef(r, d), d.multiplyToRef(h, d);
      }, n.GetAsMatrix2x2 = function(t) {
        var e = t.m, i = [e[0], e[1], e[4], e[5]];
        return Ti.MatrixUse64Bits ? i : new Float32Array(i);
      }, n.GetAsMatrix3x3 = function(t) {
        var e = t.m, i = [e[0], e[1], e[2], e[4], e[5], e[6], e[8], e[9], e[10]];
        return Ti.MatrixUse64Bits ? i : new Float32Array(i);
      }, n.Transpose = function(t) {
        var e = new t.constructor();
        return n.TransposeToRef(t, e), e;
      }, n.TransposeToRef = function(t, e) {
        var i = t.m, r = i[0], o = i[4], a = i[8], s = i[12], l = i[1], c = i[5], u = i[9], h = i[13], d = i[2], p = i[6], f = i[10], m = i[14], g = i[3], y = i[7], b = i[11], T = i[15], S = e._m;
        return S[0] = r, S[1] = o, S[2] = a, S[3] = s, S[4] = l, S[5] = c, S[6] = u, S[7] = h, S[8] = d, S[9] = p, S[10] = f, S[11] = m, S[12] = g, S[13] = y, S[14] = b, S[15] = T, e.markAsUpdated(), e._updateIdentityStatus(t._isIdentity, t._isIdentityDirty), e;
      }, n.Reflection = function(t) {
        var e = new n();
        return n.ReflectionToRef(t, e), e;
      }, n.ReflectionToRef = function(t, e) {
        t.normalize();
        var i = t.normal.x, r = t.normal.y, o = t.normal.z, a = -2 * i, s = -2 * r, l = -2 * o;
        return n.FromValuesToRef(a * i + 1, s * i, l * i, 0, a * r, s * r + 1, l * r, 0, a * o, s * o, l * o + 1, 0, a * t.d, s * t.d, l * t.d, 1, e), e;
      }, n.FromXYZAxesToRef = function(t, e, i, r) {
        return n.FromValuesToRef(t._x, t._y, t._z, 0, e._x, e._y, e._z, 0, i._x, i._y, i._z, 0, 0, 0, 0, 1, r), r;
      }, n.FromQuaternionToRef = function(t, e) {
        var i = t._x * t._x, r = t._y * t._y, o = t._z * t._z, a = t._x * t._y, s = t._z * t._w, l = t._z * t._x, c = t._y * t._w, u = t._y * t._z, h = t._x * t._w;
        return e._m[0] = 1 - 2 * (r + o), e._m[1] = 2 * (a + s), e._m[2] = 2 * (l - c), e._m[3] = 0, e._m[4] = 2 * (a - s), e._m[5] = 1 - 2 * (o + i), e._m[6] = 2 * (u + h), e._m[7] = 0, e._m[8] = 2 * (l + c), e._m[9] = 2 * (u - h), e._m[10] = 1 - 2 * (r + i), e._m[11] = 0, e._m[12] = 0, e._m[13] = 0, e._m[14] = 0, e._m[15] = 1, e.markAsUpdated(), e;
      }, n._UpdateFlagSeed = 0, n._IdentityReadOnly = n.Identity(), n;
    }(), ze = function() {
      function n() {
      }
      return n.Vector3 = pt.BuildTuple(11, v.Zero), n.Matrix = pt.BuildTuple(2, B.Identity), n.Quaternion = pt.BuildTuple(3, oe.Zero), n;
    }(), F = function() {
      function n() {
      }
      return n.Vector2 = pt.BuildTuple(3, fe.Zero), n.Vector3 = pt.BuildTuple(13, v.Zero), n.Vector4 = pt.BuildTuple(3, lt.Zero), n.Quaternion = pt.BuildTuple(2, oe.Zero), n.Matrix = pt.BuildTuple(8, B.Identity), n;
    }();
    j("BABYLON.Vector2", fe), j("BABYLON.Vector3", v), j("BABYLON.Vector4", lt), j("BABYLON.Matrix", B);
    var ur = B.FromValues(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 1);
    function En(n) {
      return Math.pow(n, Ht);
    }
    function br(n) {
      return n <= 0.04045 ? 0.0773993808 * n : Math.pow(0.947867299 * (n + 0.055), 2.4);
    }
    function Nn(n) {
      return Math.pow(n, ct);
    }
    function Lr(n) {
      return n <= 31308e-7 ? 12.92 * n : 1.055 * Math.pow(n, 0.41666) - 0.055;
    }
    var ne = function() {
      function n(t, e, i) {
        t === void 0 && (t = 0), e === void 0 && (e = 0), i === void 0 && (i = 0), this.r = t, this.g = e, this.b = i;
      }
      return n.prototype.toString = function() {
        return "{R: " + this.r + " G:" + this.g + " B:" + this.b + "}";
      }, n.prototype.getClassName = function() {
        return "Color3";
      }, n.prototype.getHashCode = function() {
        var t = 255 * this.r | 0;
        return 397 * (t = 397 * t ^ (255 * this.g | 0)) ^ (255 * this.b | 0);
      }, n.prototype.toArray = function(t, e) {
        return e === void 0 && (e = 0), t[e] = this.r, t[e + 1] = this.g, t[e + 2] = this.b, this;
      }, n.prototype.fromArray = function(t, e) {
        return e === void 0 && (e = 0), n.FromArrayToRef(t, e, this), this;
      }, n.prototype.toColor4 = function(t) {
        return t === void 0 && (t = 1), new Ie(this.r, this.g, this.b, t);
      }, n.prototype.asArray = function() {
        return [this.r, this.g, this.b];
      }, n.prototype.toLuminance = function() {
        return 0.3 * this.r + 0.59 * this.g + 0.11 * this.b;
      }, n.prototype.multiply = function(t) {
        return new n(this.r * t.r, this.g * t.g, this.b * t.b);
      }, n.prototype.multiplyToRef = function(t, e) {
        return e.r = this.r * t.r, e.g = this.g * t.g, e.b = this.b * t.b, this;
      }, n.prototype.equals = function(t) {
        return t && this.r === t.r && this.g === t.g && this.b === t.b;
      }, n.prototype.equalsFloats = function(t, e, i) {
        return this.r === t && this.g === e && this.b === i;
      }, n.prototype.scale = function(t) {
        return new n(this.r * t, this.g * t, this.b * t);
      }, n.prototype.scaleInPlace = function(t) {
        return this.r *= t, this.g *= t, this.b *= t, this;
      }, n.prototype.scaleToRef = function(t, e) {
        return e.r = this.r * t, e.g = this.g * t, e.b = this.b * t, this;
      }, n.prototype.scaleAndAddToRef = function(t, e) {
        return e.r += this.r * t, e.g += this.g * t, e.b += this.b * t, this;
      }, n.prototype.clampToRef = function(t, e, i) {
        return t === void 0 && (t = 0), e === void 0 && (e = 1), i.r = ue.Clamp(this.r, t, e), i.g = ue.Clamp(this.g, t, e), i.b = ue.Clamp(this.b, t, e), this;
      }, n.prototype.add = function(t) {
        return new n(this.r + t.r, this.g + t.g, this.b + t.b);
      }, n.prototype.addToRef = function(t, e) {
        return e.r = this.r + t.r, e.g = this.g + t.g, e.b = this.b + t.b, this;
      }, n.prototype.subtract = function(t) {
        return new n(this.r - t.r, this.g - t.g, this.b - t.b);
      }, n.prototype.subtractToRef = function(t, e) {
        return e.r = this.r - t.r, e.g = this.g - t.g, e.b = this.b - t.b, this;
      }, n.prototype.clone = function() {
        return new n(this.r, this.g, this.b);
      }, n.prototype.copyFrom = function(t) {
        return this.r = t.r, this.g = t.g, this.b = t.b, this;
      }, n.prototype.copyFromFloats = function(t, e, i) {
        return this.r = t, this.g = e, this.b = i, this;
      }, n.prototype.set = function(t, e, i) {
        return this.copyFromFloats(t, e, i);
      }, n.prototype.toHexString = function() {
        var t = Math.round(255 * this.r), e = Math.round(255 * this.g), i = Math.round(255 * this.b);
        return "#" + ue.ToHex(t) + ue.ToHex(e) + ue.ToHex(i);
      }, n.prototype.toHSV = function() {
        var t = new n();
        return this.toHSVToRef(t), t;
      }, n.prototype.toHSVToRef = function(t) {
        var e = this.r, i = this.g, r = this.b, o = Math.max(e, i, r), a = Math.min(e, i, r), s = 0, l = 0, c = o, u = o - a;
        o !== 0 && (l = u / o), o != a && (o == e ? (s = (i - r) / u, i < r && (s += 6)) : o == i ? s = (r - e) / u + 2 : o == r && (s = (e - i) / u + 4), s *= 60), t.r = s, t.g = l, t.b = c;
      }, n.prototype.toLinearSpace = function(t) {
        t === void 0 && (t = !1);
        var e = new n();
        return this.toLinearSpaceToRef(e, t), e;
      }, n.prototype.toLinearSpaceToRef = function(t, e) {
        return e === void 0 && (e = !1), e ? (t.r = br(this.r), t.g = br(this.g), t.b = br(this.b)) : (t.r = En(this.r), t.g = En(this.g), t.b = En(this.b)), this;
      }, n.prototype.toGammaSpace = function(t) {
        t === void 0 && (t = !1);
        var e = new n();
        return this.toGammaSpaceToRef(e, t), e;
      }, n.prototype.toGammaSpaceToRef = function(t, e) {
        return e === void 0 && (e = !1), e ? (t.r = Lr(this.r), t.g = Lr(this.g), t.b = Lr(this.b)) : (t.r = Nn(this.r), t.g = Nn(this.g), t.b = Nn(this.b)), this;
      }, n.HSVtoRGBToRef = function(t, e, i, r) {
        var o = i * e, a = t / 60, s = o * (1 - Math.abs(a % 2 - 1)), l = 0, c = 0, u = 0;
        a >= 0 && a <= 1 ? (l = o, c = s) : a >= 1 && a <= 2 ? (l = s, c = o) : a >= 2 && a <= 3 ? (c = o, u = s) : a >= 3 && a <= 4 ? (c = s, u = o) : a >= 4 && a <= 5 ? (l = s, u = o) : a >= 5 && a <= 6 && (l = o, u = s);
        var h = i - o;
        r.set(l + h, c + h, u + h);
      }, n.FromHSV = function(t, e, i) {
        var r = new n(0, 0, 0);
        return n.HSVtoRGBToRef(t, e, i, r), r;
      }, n.FromHexString = function(t) {
        if (t.substring(0, 1) !== "#" || t.length !== 7)
          return new n(0, 0, 0);
        var e = parseInt(t.substring(1, 3), 16), i = parseInt(t.substring(3, 5), 16), r = parseInt(t.substring(5, 7), 16);
        return n.FromInts(e, i, r);
      }, n.FromArray = function(t, e) {
        return e === void 0 && (e = 0), new n(t[e], t[e + 1], t[e + 2]);
      }, n.FromArrayToRef = function(t, e, i) {
        e === void 0 && (e = 0), i.r = t[e], i.g = t[e + 1], i.b = t[e + 2];
      }, n.FromInts = function(t, e, i) {
        return new n(t / 255, e / 255, i / 255);
      }, n.Lerp = function(t, e, i) {
        var r = new n(0, 0, 0);
        return n.LerpToRef(t, e, i, r), r;
      }, n.LerpToRef = function(t, e, i, r) {
        r.r = t.r + (e.r - t.r) * i, r.g = t.g + (e.g - t.g) * i, r.b = t.b + (e.b - t.b) * i;
      }, n.Hermite = function(t, e, i, r, o) {
        var a = o * o, s = o * a, l = 2 * s - 3 * a + 1, c = -2 * s + 3 * a, u = s - 2 * a + o, h = s - a;
        return new n(t.r * l + i.r * c + e.r * u + r.r * h, t.g * l + i.g * c + e.g * u + r.g * h, t.b * l + i.b * c + e.b * u + r.b * h);
      }, n.Hermite1stDerivative = function(t, e, i, r, o) {
        var a = n.Black();
        return this.Hermite1stDerivativeToRef(t, e, i, r, o, a), a;
      }, n.Hermite1stDerivativeToRef = function(t, e, i, r, o, a) {
        var s = o * o;
        a.r = 6 * (s - o) * t.r + (3 * s - 4 * o + 1) * e.r + 6 * (-s + o) * i.r + (3 * s - 2 * o) * r.r, a.g = 6 * (s - o) * t.g + (3 * s - 4 * o + 1) * e.g + 6 * (-s + o) * i.g + (3 * s - 2 * o) * r.g, a.b = 6 * (s - o) * t.b + (3 * s - 4 * o + 1) * e.b + 6 * (-s + o) * i.b + (3 * s - 2 * o) * r.b;
      }, n.Red = function() {
        return new n(1, 0, 0);
      }, n.Green = function() {
        return new n(0, 1, 0);
      }, n.Blue = function() {
        return new n(0, 0, 1);
      }, n.Black = function() {
        return new n(0, 0, 0);
      }, Object.defineProperty(n, "BlackReadOnly", { get: function() {
        return n._BlackReadOnly;
      }, enumerable: !1, configurable: !0 }), n.White = function() {
        return new n(1, 1, 1);
      }, n.Purple = function() {
        return new n(0.5, 0, 0.5);
      }, n.Magenta = function() {
        return new n(1, 0, 1);
      }, n.Yellow = function() {
        return new n(1, 1, 0);
      }, n.Gray = function() {
        return new n(0.5, 0.5, 0.5);
      }, n.Teal = function() {
        return new n(0, 1, 1);
      }, n.Random = function() {
        return new n(Math.random(), Math.random(), Math.random());
      }, n._BlackReadOnly = n.Black(), n;
    }(), Ie = function() {
      function n(t, e, i, r) {
        t === void 0 && (t = 0), e === void 0 && (e = 0), i === void 0 && (i = 0), r === void 0 && (r = 1), this.r = t, this.g = e, this.b = i, this.a = r;
      }
      return n.prototype.addInPlace = function(t) {
        return this.r += t.r, this.g += t.g, this.b += t.b, this.a += t.a, this;
      }, n.prototype.asArray = function() {
        return [this.r, this.g, this.b, this.a];
      }, n.prototype.toArray = function(t, e) {
        return e === void 0 && (e = 0), t[e] = this.r, t[e + 1] = this.g, t[e + 2] = this.b, t[e + 3] = this.a, this;
      }, n.prototype.fromArray = function(t, e) {
        return e === void 0 && (e = 0), n.FromArrayToRef(t, e, this), this;
      }, n.prototype.equals = function(t) {
        return t && this.r === t.r && this.g === t.g && this.b === t.b && this.a === t.a;
      }, n.prototype.add = function(t) {
        return new n(this.r + t.r, this.g + t.g, this.b + t.b, this.a + t.a);
      }, n.prototype.subtract = function(t) {
        return new n(this.r - t.r, this.g - t.g, this.b - t.b, this.a - t.a);
      }, n.prototype.subtractToRef = function(t, e) {
        return e.r = this.r - t.r, e.g = this.g - t.g, e.b = this.b - t.b, e.a = this.a - t.a, this;
      }, n.prototype.scale = function(t) {
        return new n(this.r * t, this.g * t, this.b * t, this.a * t);
      }, n.prototype.scaleInPlace = function(t) {
        return this.r *= t, this.g *= t, this.b *= t, this.a *= t, this;
      }, n.prototype.scaleToRef = function(t, e) {
        return e.r = this.r * t, e.g = this.g * t, e.b = this.b * t, e.a = this.a * t, this;
      }, n.prototype.scaleAndAddToRef = function(t, e) {
        return e.r += this.r * t, e.g += this.g * t, e.b += this.b * t, e.a += this.a * t, this;
      }, n.prototype.clampToRef = function(t, e, i) {
        return t === void 0 && (t = 0), e === void 0 && (e = 1), i.r = ue.Clamp(this.r, t, e), i.g = ue.Clamp(this.g, t, e), i.b = ue.Clamp(this.b, t, e), i.a = ue.Clamp(this.a, t, e), this;
      }, n.prototype.multiply = function(t) {
        return new n(this.r * t.r, this.g * t.g, this.b * t.b, this.a * t.a);
      }, n.prototype.multiplyToRef = function(t, e) {
        return e.r = this.r * t.r, e.g = this.g * t.g, e.b = this.b * t.b, e.a = this.a * t.a, e;
      }, n.prototype.toString = function() {
        return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}";
      }, n.prototype.getClassName = function() {
        return "Color4";
      }, n.prototype.getHashCode = function() {
        var t = 255 * this.r | 0;
        return 397 * (t = 397 * (t = 397 * t ^ (255 * this.g | 0)) ^ (255 * this.b | 0)) ^ (255 * this.a | 0);
      }, n.prototype.clone = function() {
        return new n(this.r, this.g, this.b, this.a);
      }, n.prototype.copyFrom = function(t) {
        return this.r = t.r, this.g = t.g, this.b = t.b, this.a = t.a, this;
      }, n.prototype.copyFromFloats = function(t, e, i, r) {
        return this.r = t, this.g = e, this.b = i, this.a = r, this;
      }, n.prototype.set = function(t, e, i, r) {
        return this.copyFromFloats(t, e, i, r);
      }, n.prototype.toHexString = function(t) {
        t === void 0 && (t = !1);
        var e = Math.round(255 * this.r), i = Math.round(255 * this.g), r = Math.round(255 * this.b);
        if (t)
          return "#" + ue.ToHex(e) + ue.ToHex(i) + ue.ToHex(r);
        var o = Math.round(255 * this.a);
        return "#" + ue.ToHex(e) + ue.ToHex(i) + ue.ToHex(r) + ue.ToHex(o);
      }, n.prototype.toLinearSpace = function(t) {
        t === void 0 && (t = !1);
        var e = new n();
        return this.toLinearSpaceToRef(e, t), e;
      }, n.prototype.toLinearSpaceToRef = function(t, e) {
        return e === void 0 && (e = !1), e ? (t.r = br(this.r), t.g = br(this.g), t.b = br(this.b)) : (t.r = En(this.r), t.g = En(this.g), t.b = En(this.b)), t.a = this.a, this;
      }, n.prototype.toGammaSpace = function(t) {
        t === void 0 && (t = !1);
        var e = new n();
        return this.toGammaSpaceToRef(e, t), e;
      }, n.prototype.toGammaSpaceToRef = function(t, e) {
        return e === void 0 && (e = !1), e ? (t.r = Lr(this.r), t.g = Lr(this.g), t.b = Lr(this.b)) : (t.r = Nn(this.r), t.g = Nn(this.g), t.b = Nn(this.b)), t.a = this.a, this;
      }, n.FromHexString = function(t) {
        if (t.substring(0, 1) !== "#" || t.length !== 9 && t.length !== 7)
          return new n(0, 0, 0, 0);
        var e = parseInt(t.substring(1, 3), 16), i = parseInt(t.substring(3, 5), 16), r = parseInt(t.substring(5, 7), 16), o = t.length === 9 ? parseInt(t.substring(7, 9), 16) : 255;
        return n.FromInts(e, i, r, o);
      }, n.Lerp = function(t, e, i) {
        var r = new n(0, 0, 0, 0);
        return n.LerpToRef(t, e, i, r), r;
      }, n.LerpToRef = function(t, e, i, r) {
        r.r = t.r + (e.r - t.r) * i, r.g = t.g + (e.g - t.g) * i, r.b = t.b + (e.b - t.b) * i, r.a = t.a + (e.a - t.a) * i;
      }, n.Hermite = function(t, e, i, r, o) {
        var a = o * o, s = o * a, l = 2 * s - 3 * a + 1, c = -2 * s + 3 * a, u = s - 2 * a + o, h = s - a;
        return new n(t.r * l + i.r * c + e.r * u + r.r * h, t.g * l + i.g * c + e.g * u + r.g * h, t.b * l + i.b * c + e.b * u + r.b * h, t.a * l + i.a * c + e.a * u + r.a * h);
      }, n.Hermite1stDerivative = function(t, e, i, r, o) {
        var a = new n();
        return this.Hermite1stDerivativeToRef(t, e, i, r, o, a), a;
      }, n.Hermite1stDerivativeToRef = function(t, e, i, r, o, a) {
        var s = o * o;
        a.r = 6 * (s - o) * t.r + (3 * s - 4 * o + 1) * e.r + 6 * (-s + o) * i.r + (3 * s - 2 * o) * r.r, a.g = 6 * (s - o) * t.g + (3 * s - 4 * o + 1) * e.g + 6 * (-s + o) * i.g + (3 * s - 2 * o) * r.g, a.b = 6 * (s - o) * t.b + (3 * s - 4 * o + 1) * e.b + 6 * (-s + o) * i.b + (3 * s - 2 * o) * r.b, a.a = 6 * (s - o) * t.a + (3 * s - 4 * o + 1) * e.a + 6 * (-s + o) * i.a + (3 * s - 2 * o) * r.a;
      }, n.FromColor3 = function(t, e) {
        return e === void 0 && (e = 1), new n(t.r, t.g, t.b, e);
      }, n.FromArray = function(t, e) {
        return e === void 0 && (e = 0), new n(t[e], t[e + 1], t[e + 2], t[e + 3]);
      }, n.FromArrayToRef = function(t, e, i) {
        e === void 0 && (e = 0), i.r = t[e], i.g = t[e + 1], i.b = t[e + 2], i.a = t[e + 3];
      }, n.FromInts = function(t, e, i, r) {
        return new n(t / 255, e / 255, i / 255, r / 255);
      }, n.CheckColors4 = function(t, e) {
        if (t.length === 3 * e) {
          for (var i = [], r = 0; r < t.length; r += 3) {
            var o = r / 3 * 4;
            i[o] = t[r], i[o + 1] = t[r + 1], i[o + 2] = t[r + 2], i[o + 3] = 1;
          }
          return i;
        }
        return t;
      }, n;
    }(), Ot = function() {
      function n() {
      }
      return n.Color3 = pt.BuildArray(3, ne.Black), n.Color4 = pt.BuildArray(3, function() {
        return new Ie(0, 0, 0, 0);
      }), n;
    }();
    j("BABYLON.Color3", ne), j("BABYLON.Color4", Ie);
    var wt = function() {
      function n(t, e) {
        this.triggerOptions = t, this.onBeforeExecuteObservable = new H(), t.parameter ? (this.trigger = t.trigger, this._triggerParameter = t.parameter) : t.trigger ? this.trigger = t.trigger : this.trigger = t, this._nextActiveAction = this, this._condition = e;
      }
      return n.prototype._prepare = function() {
      }, n.prototype.getTriggerParameter = function() {
        return this._triggerParameter;
      }, n.prototype.setTriggerParameter = function(t) {
        this._triggerParameter = t;
      }, n.prototype._evaluateConditionForCurrentFrame = function() {
        var t = this._condition;
        if (!t)
          return !0;
        var e = this._actionManager.getScene().getRenderId();
        return t._evaluationId !== e && (t._evaluationId = e, t._currentResult = t.isValid()), t._currentResult;
      }, n.prototype._executeCurrent = function(t) {
        this._evaluateConditionForCurrentFrame() && (this.onBeforeExecuteObservable.notifyObservers(this), this._nextActiveAction.execute(t), this.skipToNextActiveAction());
      }, n.prototype.execute = function(t) {
      }, n.prototype.skipToNextActiveAction = function() {
        this._nextActiveAction._child ? (this._nextActiveAction._child._actionManager || (this._nextActiveAction._child._actionManager = this._actionManager), this._nextActiveAction = this._nextActiveAction._child) : this._nextActiveAction = this;
      }, n.prototype.then = function(t) {
        return this._child = t, t._actionManager = this._actionManager, t._prepare(), t;
      }, n.prototype._getProperty = function(t) {
        return this._actionManager._getProperty(t);
      }, n.prototype._getEffectiveTarget = function(t, e) {
        return this._actionManager._getEffectiveTarget(t, e);
      }, n.prototype.serialize = function(t) {
      }, n.prototype._serialize = function(t, e) {
        var i = { type: 1, children: [], name: t.name, properties: t.properties || [] };
        if (this._child && this._child.serialize(i), this._condition) {
          var r = this._condition.serialize();
          return r.children.push(i), e && e.children.push(r), r;
        }
        return e && e.children.push(i), i;
      }, n._SerializeValueAsString = function(t) {
        return typeof t == "number" ? t.toString() : typeof t == "boolean" ? t ? "true" : "false" : t instanceof fe ? t.x + ", " + t.y : t instanceof v ? t.x + ", " + t.y + ", " + t.z : t instanceof ne ? t.r + ", " + t.g + ", " + t.b : t instanceof Ie ? t.r + ", " + t.g + ", " + t.b + ", " + t.a : t;
      }, n._GetTargetProperty = function(t) {
        return { name: "target", targetType: t._isMesh ? "MeshProperties" : t._isLight ? "LightProperties" : t._isCamera ? "CameraProperties" : t._isMaterial ? "MaterialProperties" : "SceneProperties", value: t._isScene ? "Scene" : t.name };
      }, n;
    }();
    j("BABYLON.Action", wt);
    var mi = function() {
      function n(t, e, i, r, o, a) {
        this.source = t, this.pointerX = e, this.pointerY = i, this.meshUnderPointer = r, this.sourceEvent = o, this.additionalData = a;
      }
      return n.CreateNew = function(t, e, i) {
        var r = t.getScene();
        return new n(t, r.pointerX, r.pointerY, r.meshUnderPointer || t, e, i);
      }, n.CreateNewFromSprite = function(t, e, i, r) {
        return new n(t, e.pointerX, e.pointerY, e.meshUnderPointer, i, r);
      }, n.CreateNewFromScene = function(t, e) {
        return new n(null, t.pointerX, t.pointerY, t.meshUnderPointer, e);
      }, n.CreateNewFromPrimitive = function(t, e, i, r) {
        return new n(t, e.x, e.y, null, i, r);
      }, n;
    }(), Tr = function(n, t) {
      return Tr = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, i) {
        e.__proto__ = i;
      } || function(e, i) {
        for (var r in i)
          Object.prototype.hasOwnProperty.call(i, r) && (e[r] = i[r]);
      }, Tr(n, t);
    };
    function D(n, t) {
      if (typeof t != "function" && t !== null)
        throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
      function e() {
        this.constructor = n;
      }
      Tr(n, t), n.prototype = t === null ? Object.create(t) : (e.prototype = t.prototype, new e());
    }
    var je = function() {
      return je = Object.assign || function(n) {
        for (var t, e = 1, i = arguments.length; e < i; e++)
          for (var r in t = arguments[e])
            Object.prototype.hasOwnProperty.call(t, r) && (n[r] = t[r]);
        return n;
      }, je.apply(this, arguments);
    };
    function x(n, t, e, i) {
      var r, o = arguments.length, a = o < 3 ? t : i === null ? i = Object.getOwnPropertyDescriptor(t, e) : i;
      if (typeof Reflect == "object" && typeof Reflect.decorate == "function")
        a = Reflect.decorate(n, t, e, i);
      else
        for (var s = n.length - 1; s >= 0; s--)
          (r = n[s]) && (a = (o < 3 ? r(a) : o > 3 ? r(t, e, a) : r(t, e)) || a);
      return o > 3 && a && Object.defineProperty(t, e, a), a;
    }
    function Ft(n, t, e, i) {
      return new (e || (e = Promise))(function(r, o) {
        function a(c) {
          try {
            l(i.next(c));
          } catch (u) {
            o(u);
          }
        }
        function s(c) {
          try {
            l(i.throw(c));
          } catch (u) {
            o(u);
          }
        }
        function l(c) {
          var u;
          c.done ? r(c.value) : (u = c.value, u instanceof e ? u : new e(function(h) {
            h(u);
          })).then(a, s);
        }
        l((i = i.apply(n, t || [])).next());
      });
    }
    function Bt(n, t) {
      var e, i, r, o, a = { label: 0, sent: function() {
        if (1 & r[0])
          throw r[1];
        return r[1];
      }, trys: [], ops: [] };
      return o = { next: s(0), throw: s(1), return: s(2) }, typeof Symbol == "function" && (o[Symbol.iterator] = function() {
        return this;
      }), o;
      function s(l) {
        return function(c) {
          return function(u) {
            if (e)
              throw new TypeError("Generator is already executing.");
            for (; o && (o = 0, u[0] && (a = 0)), a; )
              try {
                if (e = 1, i && (r = 2 & u[0] ? i.return : u[0] ? i.throw || ((r = i.return) && r.call(i), 0) : i.next) && !(r = r.call(i, u[1])).done)
                  return r;
                switch (i = 0, r && (u = [2 & u[0], r.value]), u[0]) {
                  case 0:
                  case 1:
                    r = u;
                    break;
                  case 4:
                    return a.label++, { value: u[1], done: !1 };
                  case 5:
                    a.label++, i = u[1], u = [0];
                    continue;
                  case 7:
                    u = a.ops.pop(), a.trys.pop();
                    continue;
                  default:
                    if (!((r = (r = a.trys).length > 0 && r[r.length - 1]) || u[0] !== 6 && u[0] !== 2)) {
                      a = 0;
                      continue;
                    }
                    if (u[0] === 3 && (!r || u[1] > r[0] && u[1] < r[3])) {
                      a.label = u[1];
                      break;
                    }
                    if (u[0] === 6 && a.label < r[1]) {
                      a.label = r[1], r = u;
                      break;
                    }
                    if (r && a.label < r[2]) {
                      a.label = r[2], a.ops.push(u);
                      break;
                    }
                    r[2] && a.ops.pop(), a.trys.pop();
                    continue;
                }
                u = t.call(n, a);
              } catch (h) {
                u = [6, h], i = 0;
              } finally {
                e = r = 0;
              }
            if (5 & u[0])
              throw u[1];
            return { value: u[0] ? u[1] : void 0, done: !0 };
          }([l, c]);
        };
      }
    }
    function js(n, t, e) {
      if (e || arguments.length === 2)
        for (var i, r = 0, o = t.length; r < o; r++)
          !i && r in t || (i || (i = Array.prototype.slice.call(t, 0, r)), i[r] = t[r]);
      return n.concat(i || Array.prototype.slice.call(t));
    }
    typeof SuppressedError == "function" && SuppressedError;
    var Jn = function() {
      function n(t) {
        this._actionManager = t;
      }
      return n.prototype.isValid = function() {
        return !0;
      }, n.prototype._getProperty = function(t) {
        return this._actionManager._getProperty(t);
      }, n.prototype._getEffectiveTarget = function(t, e) {
        return this._actionManager._getEffectiveTarget(t, e);
      }, n.prototype.serialize = function() {
      }, n.prototype._serialize = function(t) {
        return { type: 2, children: [], name: t.name, properties: t.properties };
      }, n;
    }(), Ys = function(n) {
      function t(e, i, r, o, a) {
        a === void 0 && (a = t.IsEqual);
        var s = n.call(this, e) || this;
        return s.propertyPath = r, s.value = o, s.operator = a, s._target = i, s._effectiveTarget = s._getEffectiveTarget(i, s.propertyPath), s._property = s._getProperty(s.propertyPath), s;
      }
      return D(t, n), Object.defineProperty(t, "IsEqual", { get: function() {
        return t._IsEqual;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "IsDifferent", { get: function() {
        return t._IsDifferent;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "IsGreater", { get: function() {
        return t._IsGreater;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "IsLesser", { get: function() {
        return t._IsLesser;
      }, enumerable: !1, configurable: !0 }), t.prototype.isValid = function() {
        switch (this.operator) {
          case t.IsGreater:
            return this._effectiveTarget[this._property] > this.value;
          case t.IsLesser:
            return this._effectiveTarget[this._property] < this.value;
          case t.IsEqual:
          case t.IsDifferent:
            var e;
            return e = this.value.equals ? this.value.equals(this._effectiveTarget[this._property]) : this.value === this._effectiveTarget[this._property], this.operator === t.IsEqual ? e : !e;
        }
        return !1;
      }, t.prototype.serialize = function() {
        return this._serialize({ name: "ValueCondition", properties: [wt._GetTargetProperty(this._target), { name: "propertyPath", value: this.propertyPath }, { name: "value", value: wt._SerializeValueAsString(this.value) }, { name: "operator", value: t.GetOperatorName(this.operator) }] });
      }, t.GetOperatorName = function(e) {
        switch (e) {
          case t._IsEqual:
            return "IsEqual";
          case t._IsDifferent:
            return "IsDifferent";
          case t._IsGreater:
            return "IsGreater";
          case t._IsLesser:
            return "IsLesser";
          default:
            return "";
        }
      }, t._IsEqual = 0, t._IsDifferent = 1, t._IsGreater = 2, t._IsLesser = 3, t;
    }(Jn), Qr = function(n) {
      function t(e, i) {
        var r = n.call(this, e) || this;
        return r.predicate = i, r;
      }
      return D(t, n), t.prototype.isValid = function() {
        return this.predicate();
      }, t;
    }(Jn), as = function(n) {
      function t(e, i, r) {
        var o = n.call(this, e) || this;
        return o.value = r, o._target = i, o;
      }
      return D(t, n), t.prototype.isValid = function() {
        return this._target.state === this.value;
      }, t.prototype.serialize = function() {
        return this._serialize({ name: "StateCondition", properties: [wt._GetTargetProperty(this._target), { name: "value", value: this.value }] });
      }, t;
    }(Jn);
    j("BABYLON.ValueCondition", Ys), j("BABYLON.PredicateCondition", Qr), j("BABYLON.StateCondition", as);
    var q = function() {
      function n() {
      }
      return n._CheckLimit = function(t, e) {
        var i = n._LogLimitOutputs[t];
        return i ? i.current++ : (i = { limit: e, current: 1 }, n._LogLimitOutputs[t] = i), i.current <= i.limit;
      }, n._GenerateLimitMessage = function(t, e) {
        var i;
        e === void 0 && (e = 1);
        var r = n._LogLimitOutputs[t];
        if (r && n.MessageLimitReached) {
          var o = this._Levels[e];
          r.current === r.limit && n[o.name](n.MessageLimitReached.replace(/%LIMIT%/g, "" + r.limit).replace(/%TYPE%/g, (i = o.name) !== null && i !== void 0 ? i : ""));
        }
      }, n._AddLogEntry = function(t) {
        n._LogCache = t + n._LogCache, n.OnNewCacheEntry && n.OnNewCacheEntry(t);
      }, n._FormatMessage = function(t) {
        var e = function(r) {
          return r < 10 ? "0" + r : "" + r;
        }, i = /* @__PURE__ */ new Date();
        return "[" + e(i.getHours()) + ":" + e(i.getMinutes()) + ":" + e(i.getSeconds()) + "]: " + t;
      }, n._LogDisabled = function(t, e) {
      }, n._LogEnabled = function(t, e, i) {
        if (t === void 0 && (t = 1), i === void 0 || n._CheckLimit(e, i)) {
          var r = n._FormatMessage(e), o = this._Levels[t];
          o.logFunc && o.logFunc("BJS - " + r);
          var a = "<div style='color:".concat(o.color, "'>").concat(r, "</div><br>");
          n._AddLogEntry(a), n._GenerateLimitMessage(e, t);
        }
      }, Object.defineProperty(n, "LogCache", { get: function() {
        return n._LogCache;
      }, enumerable: !1, configurable: !0 }), n.ClearLogCache = function() {
        n._LogCache = "", n._LogLimitOutputs = {}, n.errorsCount = 0;
      }, Object.defineProperty(n, "LogLevels", { set: function(t) {
        var e = this;
        n.Log = n._LogDisabled, n.Warn = n._LogDisabled, n.Error = n._LogDisabled, [n.MessageLogLevel, n.WarningLogLevel, n.ErrorLogLevel].forEach(function(i) {
          (t & i) === i && (n[e._Levels[i].name] = n._LogEnabled.bind(n, i));
        });
      }, enumerable: !1, configurable: !0 }), n.NoneLogLevel = 0, n.MessageLogLevel = 1, n.WarningLogLevel = 2, n.ErrorLogLevel = 4, n.AllLogLevel = 7, n.MessageLimitReached = "Too many %TYPE%s (%LIMIT%), no more %TYPE%s will be reported for this message.", n._LogCache = "", n._LogLimitOutputs = {}, n._Levels = [{}, { color: "white", logFunc: console.log, name: "Log" }, { color: "orange", logFunc: console.warn, name: "Warn" }, {}, { color: "red", logFunc: console.error, name: "Error" }], n.errorsCount = 0, n.Log = n._LogEnabled.bind(n, n.MessageLogLevel), n.Warn = n._LogEnabled.bind(n, n.WarningLogLevel), n.Error = n._LogEnabled.bind(n, n.ErrorLogLevel), n;
    }(), kl = function(n) {
      function t(e, i, r, o) {
        var a = n.call(this, e, o) || this;
        return a.propertyPath = r, a._target = a._effectiveTarget = i, a;
      }
      return D(t, n), t.prototype._prepare = function() {
        this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath), this._property = this._getProperty(this.propertyPath);
      }, t.prototype.execute = function() {
        this._effectiveTarget[this._property] = !this._effectiveTarget[this._property];
      }, t.prototype.serialize = function(e) {
        return n.prototype._serialize.call(this, { name: "SwitchBooleanAction", properties: [wt._GetTargetProperty(this._target), { name: "propertyPath", value: this.propertyPath }] }, e);
      }, t;
    }(wt), hn = function(n) {
      function t(e, i, r, o) {
        var a = n.call(this, e, o) || this;
        return a.value = r, a._target = i, a;
      }
      return D(t, n), t.prototype.execute = function() {
        this._target.state = this.value;
      }, t.prototype.serialize = function(e) {
        return n.prototype._serialize.call(this, { name: "SetStateAction", properties: [wt._GetTargetProperty(this._target), { name: "value", value: this.value }] }, e);
      }, t;
    }(wt), dn = function(n) {
      function t(e, i, r, o, a) {
        var s = n.call(this, e, a) || this;
        return s.propertyPath = r, s.value = o, s._target = s._effectiveTarget = i, s;
      }
      return D(t, n), t.prototype._prepare = function() {
        this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath), this._property = this._getProperty(this.propertyPath);
      }, t.prototype.execute = function() {
        this._effectiveTarget[this._property] = this.value, this._target.markAsDirty && this._target.markAsDirty(this._property);
      }, t.prototype.serialize = function(e) {
        return n.prototype._serialize.call(this, { name: "SetValueAction", properties: [wt._GetTargetProperty(this._target), { name: "propertyPath", value: this.propertyPath }, { name: "value", value: wt._SerializeValueAsString(this.value) }] }, e);
      }, t;
    }(wt), Gl = function(n) {
      function t(e, i, r, o, a) {
        var s = n.call(this, e, a) || this;
        return s.propertyPath = r, s.value = o, s._target = s._effectiveTarget = i, s;
      }
      return D(t, n), t.prototype._prepare = function() {
        this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath), this._property = this._getProperty(this.propertyPath), typeof this._effectiveTarget[this._property] != "number" && q.Warn("Warning: IncrementValueAction can only be used with number values");
      }, t.prototype.execute = function() {
        this._effectiveTarget[this._property] += this.value, this._target.markAsDirty && this._target.markAsDirty(this._property);
      }, t.prototype.serialize = function(e) {
        return n.prototype._serialize.call(this, { name: "IncrementValueAction", properties: [wt._GetTargetProperty(this._target), { name: "propertyPath", value: this.propertyPath }, { name: "value", value: wt._SerializeValueAsString(this.value) }] }, e);
      }, t;
    }(wt), zl = function(n) {
      function t(e, i, r, o, a, s) {
        var l = n.call(this, e, s) || this;
        return l.from = r, l.to = o, l.loop = a, l._target = i, l;
      }
      return D(t, n), t.prototype._prepare = function() {
      }, t.prototype.execute = function() {
        this._actionManager.getScene().beginAnimation(this._target, this.from, this.to, this.loop);
      }, t.prototype.serialize = function(e) {
        return n.prototype._serialize.call(this, { name: "PlayAnimationAction", properties: [wt._GetTargetProperty(this._target), { name: "from", value: String(this.from) }, { name: "to", value: String(this.to) }, { name: "loop", value: wt._SerializeValueAsString(this.loop) || !1 }] }, e);
      }, t;
    }(wt), Wl = function(n) {
      function t(e, i, r) {
        var o = n.call(this, e, r) || this;
        return o._target = i, o;
      }
      return D(t, n), t.prototype._prepare = function() {
      }, t.prototype.execute = function() {
        this._actionManager.getScene().stopAnimation(this._target);
      }, t.prototype.serialize = function(e) {
        return n.prototype._serialize.call(this, { name: "StopAnimationAction", properties: [wt._GetTargetProperty(this._target)] }, e);
      }, t;
    }(wt), Ks = function(n) {
      function t(e, i) {
        return e === void 0 && (e = _.ACTION_NothingTrigger), n.call(this, e, i) || this;
      }
      return D(t, n), t.prototype.execute = function() {
      }, t.prototype.serialize = function(e) {
        return n.prototype._serialize.call(this, { name: "DoNothingAction", properties: [] }, e);
      }, t;
    }(wt), Hl = function(n) {
      function t(e, i, r, o) {
        o === void 0 && (o = !0);
        var a = n.call(this, e, r) || this;
        return a.children = i, a.enableChildrenConditions = o, a;
      }
      return D(t, n), t.prototype._prepare = function() {
        for (var e = 0; e < this.children.length; e++)
          this.children[e]._actionManager = this._actionManager, this.children[e]._prepare();
      }, t.prototype.execute = function(e) {
        for (var i = 0, r = this.children; i < r.length; i++) {
          var o = r[i];
          this.enableChildrenConditions && !o._evaluateConditionForCurrentFrame() || o.execute(e);
        }
      }, t.prototype.serialize = function(e) {
        for (var i = n.prototype._serialize.call(this, { name: "CombineAction", properties: [], combine: [] }, e), r = 0; r < this.children.length; r++)
          i.combine.push(this.children[r].serialize(null));
        return i;
      }, t;
    }(wt), Xl = function(n) {
      function t(e, i, r) {
        var o = n.call(this, e, r) || this;
        return o.func = i, o;
      }
      return D(t, n), t.prototype.execute = function(e) {
        this.func(e);
      }, t;
    }(wt), qs = function(n) {
      function t(e, i, r, o) {
        var a = n.call(this, e, o) || this;
        return a._target = i, a._parent = r, a;
      }
      return D(t, n), t.prototype._prepare = function() {
      }, t.prototype.execute = function() {
        if (this._target.parent !== this._parent) {
          var e = this._parent.getWorldMatrix().clone();
          e.invert(), this._target.position = v.TransformCoordinates(this._target.position, e), this._target.parent = this._parent;
        }
      }, t.prototype.serialize = function(e) {
        return n.prototype._serialize.call(this, { name: "SetParentAction", properties: [wt._GetTargetProperty(this._target), wt._GetTargetProperty(this._parent)] }, e);
      }, t;
    }(wt);
    j("BABYLON.SetParentAction", qs), j("BABYLON.ExecuteCodeAction", Xl), j("BABYLON.DoNothingAction", Ks), j("BABYLON.StopAnimationAction", Wl), j("BABYLON.PlayAnimationAction", zl), j("BABYLON.IncrementValueAction", Gl), j("BABYLON.SetValueAction", dn), j("BABYLON.SetStateAction", hn), j("BABYLON.SetParentAction", qs), j("BABYLON.SwitchBooleanAction", kl), j("BABYLON.CombineAction", Hl);
    var Pu = function(n, t, e) {
      return n ? n.getClassName && n.getClassName() === "Mesh" ? null : !n.getClassName || n.getClassName() !== "SubMesh" && n.getClassName() !== "PhysicsBody" ? n.clone ? n.clone() : Array.isArray(n) ? n.slice() : e && typeof n == "object" ? je({}, n) : null : n.clone(t) : null;
    }, Ui = function() {
      function n() {
      }
      return n.DeepCopy = function(t, e, i, r, o) {
        o === void 0 && (o = !1);
        for (var a = function(f) {
          var m = [];
          do
            Object.getOwnPropertyNames(f).forEach(function(g) {
              m.indexOf(g) === -1 && m.push(g);
            });
          while (f = Object.getPrototypeOf(f));
          return m;
        }(t), s = 0, l = a; s < l.length; s++) {
          var c = l[s];
          if ((c[0] !== "_" || r && r.indexOf(c) !== -1) && !(c.endsWith("Observable") || i && i.indexOf(c) !== -1)) {
            var u = t[c], h = typeof u;
            if (h !== "function")
              try {
                if (h === "object")
                  if (u instanceof Uint8Array)
                    e[c] = Uint8Array.from(u);
                  else if (u instanceof Array) {
                    if (e[c] = [], u.length > 0)
                      if (typeof u[0] == "object")
                        for (var d = 0; d < u.length; d++) {
                          var p = Pu(u[d], e, o);
                          e[c].indexOf(p) === -1 && e[c].push(p);
                        }
                      else
                        e[c] = u.slice(0);
                  } else
                    e[c] = Pu(u, e, o);
                else
                  e[c] = u;
              } catch (f) {
                q.Warn(f.message);
              }
          }
        }
      }, n;
    }(), Qs = function(n) {
      function t(e) {
        var i = n.call(this) || this;
        return (e = e || Me.LastCreatedScene) && (i._scene = e, e.actionManagers.push(i)), i;
      }
      return D(t, n), t.prototype.dispose = function() {
        for (var e = this, i = this._scene.actionManagers.indexOf(this), r = 0; r < this.actions.length; r++) {
          var o = this.actions[r];
          t.Triggers[o.trigger]--, t.Triggers[o.trigger] === 0 && delete t.Triggers[o.trigger];
        }
        this.actions.length = 0, i > -1 && this._scene.actionManagers.splice(i, 1);
        for (var a = 0, s = this._scene.meshes.filter(function(l) {
          return l.actionManager === e;
        }); a < s.length; a++)
          s[a].actionManager = null;
      }, t.prototype.getScene = function() {
        return this._scene;
      }, t.prototype.hasSpecificTriggers = function(e) {
        for (var i = 0; i < this.actions.length; i++) {
          var r = this.actions[i];
          if (e.indexOf(r.trigger) > -1)
            return !0;
        }
        return !1;
      }, t.prototype.hasSpecificTriggers2 = function(e, i) {
        for (var r = 0; r < this.actions.length; r++) {
          var o = this.actions[r];
          if (e == o.trigger || i == o.trigger)
            return !0;
        }
        return !1;
      }, t.prototype.hasSpecificTrigger = function(e, i) {
        for (var r = 0; r < this.actions.length; r++) {
          var o = this.actions[r];
          if (o.trigger === e && (!i || i(o.getTriggerParameter())))
            return !0;
        }
        return !1;
      }, Object.defineProperty(t.prototype, "hasPointerTriggers", { get: function() {
        for (var e = 0; e < this.actions.length; e++) {
          var i = this.actions[e];
          if (i.trigger >= t.OnPickTrigger && i.trigger <= t.OnPointerOutTrigger)
            return !0;
        }
        return !1;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hasPickTriggers", { get: function() {
        for (var e = 0; e < this.actions.length; e++) {
          var i = this.actions[e];
          if (i.trigger >= t.OnPickTrigger && i.trigger <= t.OnPickUpTrigger)
            return !0;
        }
        return !1;
      }, enumerable: !1, configurable: !0 }), t.prototype.registerAction = function(e) {
        return e.trigger === t.OnEveryFrameTrigger && this.getScene().actionManager !== this ? (q.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"), null) : (this.actions.push(e), this.getScene()._registeredActions++, t.Triggers[e.trigger] ? t.Triggers[e.trigger]++ : t.Triggers[e.trigger] = 1, e._actionManager = this, e._prepare(), e);
      }, t.prototype.unregisterAction = function(e) {
        var i = this.actions.indexOf(e);
        return i !== -1 && (this.actions.splice(i, 1), t.Triggers[e.trigger] -= 1, t.Triggers[e.trigger] === 0 && delete t.Triggers[e.trigger], e._actionManager = null, this.getScene()._registeredActions--, !0);
      }, t.prototype.processTrigger = function(e, i) {
        for (var r = 0; r < this.actions.length; r++) {
          var o = this.actions[r];
          if (o.trigger === e) {
            if (i && (e === t.OnKeyUpTrigger || e === t.OnKeyDownTrigger)) {
              var a = o.getTriggerParameter();
              if (typeof a == "function") {
                if (!a(i))
                  continue;
              } else if (a && a !== i.sourceEvent.keyCode) {
                if (!a.toLowerCase)
                  continue;
                var s = a.toLowerCase();
                if (s !== i.sourceEvent.key) {
                  var l = i.sourceEvent.charCode ? i.sourceEvent.charCode : i.sourceEvent.keyCode;
                  if (String.fromCharCode(l).toLowerCase() !== s)
                    continue;
                }
              }
            }
            o._executeCurrent(i);
          }
        }
      }, t.prototype._getEffectiveTarget = function(e, i) {
        for (var r = i.split("."), o = 0; o < r.length - 1; o++)
          e = e[r[o]];
        return e;
      }, t.prototype._getProperty = function(e) {
        var i = e.split(".");
        return i[i.length - 1];
      }, t.prototype.serialize = function(e) {
        for (var i = { children: new Array(), name: e, type: 3, properties: new Array() }, r = 0; r < this.actions.length; r++) {
          var o = { type: 0, children: new Array(), name: t.GetTriggerName(this.actions[r].trigger), properties: new Array() }, a = this.actions[r].triggerOptions;
          if (a && typeof a != "number")
            if (a.parameter instanceof Node)
              o.properties.push(wt._GetTargetProperty(a.parameter));
            else if (typeof a.parameter == "object") {
              var s = {};
              Ui.DeepCopy(a.parameter, s, ["mesh"]), a.parameter && a.parameter.mesh && (s._meshId = a.parameter.mesh.id), o.properties.push({ name: "parameter", targetType: null, value: s });
            } else
              o.properties.push({ name: "parameter", targetType: null, value: a.parameter });
          this.actions[r].serialize(o), i.children.push(o);
        }
        return i;
      }, t.Parse = function(e, i, r) {
        var o = new t(r);
        i === null ? r.actionManager = o : i.actionManager = o;
        for (var a = function(f, m, g, y) {
          if (y === null) {
            var b = parseFloat(m);
            return m === "true" || m === "false" ? m === "true" : isNaN(b) ? m : b;
          }
          for (var T = y.split("."), S = m.split(","), E = 0; E < T.length; E++)
            g = g[T[E]];
          if (typeof g == "boolean")
            return S[0] === "true";
          if (typeof g == "string")
            return S[0];
          var A = [];
          for (E = 0; E < S.length; E++)
            A.push(parseFloat(S[E]));
          return g instanceof v ? v.FromArray(A) : g instanceof lt ? lt.FromArray(A) : g instanceof ne ? ne.FromArray(A) : g instanceof Ie ? Ie.FromArray(A) : parseFloat(S[0]);
        }, s = function(f, m, g, y, b) {
          if (b === void 0 && (b = null), !f.detached) {
            var T = [], S = null, E = null, A = f.combine && f.combine.length > 0;
            if (f.type === 2 ? T.push(o) : T.push(m), A) {
              for (var R = [], C = 0; C < f.combine.length; C++)
                s(f.combine[C], t.NothingTrigger, g, y, R);
              T.push(R);
            } else
              for (var L = 0; L < f.properties.length; L++) {
                var I = f.properties[L].value, O = f.properties[L].name, w = f.properties[L].targetType;
                O === "target" ? I = S = w === "SceneProperties" ? r : w === "MaterialProperties" ? r.getMaterialByName(I) : r.getNodeByName(I) : O === "parent" ? I = r.getNodeByName(I) : O === "sound" ? r.getSoundByName && (I = r.getSoundByName(I)) : O !== "propertyPath" ? I = f.type === 2 && O === "operator" ? Ys[I] : a(0, I, S, O === "value" ? E : null) : E = I, T.push(I);
              }
            if (b === null ? T.push(g) : T.push(null), f.name === "InterpolateValueAction") {
              var z = T[T.length - 2];
              T[T.length - 1] = z, T[T.length - 2] = g;
            }
            var V, Y, ee = (V = T, (Y = Kt("BABYLON." + f.name)) && new (Y.bind.apply(Y, js([void 0], V, !1)))());
            if (ee instanceof Jn && g !== null) {
              var J = new Ks(m, g);
              y ? y.then(J) : o.registerAction(J), y = J;
            }
            for (b === null ? ee instanceof Jn ? (g = ee, ee = y) : (g = null, y ? y.then(ee) : o.registerAction(ee)) : b.push(ee), L = 0; L < f.children.length; L++)
              s(f.children[L], m, g, ee, null);
          }
        }, l = 0; l < e.children.length; l++) {
          var c = void 0, u = e.children[l];
          if (u.properties.length > 0) {
            var h = u.properties[0].value, d = u.properties[0].targetType === null ? h : r.getMeshByName(h);
            d._meshId && (d.mesh = r.getMeshById(d._meshId)), c = { trigger: t[u.name], parameter: d };
          } else
            c = t[u.name];
          for (var p = 0; p < u.children.length; p++)
            u.detached || s(u.children[p], c, null, null);
        }
      }, t.GetTriggerName = function(e) {
        switch (e) {
          case _.ACTION_NothingTrigger:
            return "NothingTrigger";
          case _.ACTION_OnPickTrigger:
            return "OnPickTrigger";
          case _.ACTION_OnLeftPickTrigger:
            return "OnLeftPickTrigger";
          case _.ACTION_OnRightPickTrigger:
            return "OnRightPickTrigger";
          case _.ACTION_OnCenterPickTrigger:
            return "OnCenterPickTrigger";
          case _.ACTION_OnPickDownTrigger:
            return "OnPickDownTrigger";
          case _.ACTION_OnDoublePickTrigger:
            return "OnDoublePickTrigger";
          case _.ACTION_OnPickUpTrigger:
            return "OnPickUpTrigger";
          case _.ACTION_OnLongPressTrigger:
            return "OnLongPressTrigger";
          case _.ACTION_OnPointerOverTrigger:
            return "OnPointerOverTrigger";
          case _.ACTION_OnPointerOutTrigger:
            return "OnPointerOutTrigger";
          case _.ACTION_OnEveryFrameTrigger:
            return "OnEveryFrameTrigger";
          case _.ACTION_OnIntersectionEnterTrigger:
            return "OnIntersectionEnterTrigger";
          case _.ACTION_OnIntersectionExitTrigger:
            return "OnIntersectionExitTrigger";
          case _.ACTION_OnKeyDownTrigger:
            return "OnKeyDownTrigger";
          case _.ACTION_OnKeyUpTrigger:
            return "OnKeyUpTrigger";
          case _.ACTION_OnPickOutTrigger:
            return "OnPickOutTrigger";
          default:
            return "";
        }
      }, t.NothingTrigger = _.ACTION_NothingTrigger, t.OnPickTrigger = _.ACTION_OnPickTrigger, t.OnLeftPickTrigger = _.ACTION_OnLeftPickTrigger, t.OnRightPickTrigger = _.ACTION_OnRightPickTrigger, t.OnCenterPickTrigger = _.ACTION_OnCenterPickTrigger, t.OnPickDownTrigger = _.ACTION_OnPickDownTrigger, t.OnDoublePickTrigger = _.ACTION_OnDoublePickTrigger, t.OnPickUpTrigger = _.ACTION_OnPickUpTrigger, t.OnPickOutTrigger = _.ACTION_OnPickOutTrigger, t.OnLongPressTrigger = _.ACTION_OnLongPressTrigger, t.OnPointerOverTrigger = _.ACTION_OnPointerOverTrigger, t.OnPointerOutTrigger = _.ACTION_OnPointerOutTrigger, t.OnEveryFrameTrigger = _.ACTION_OnEveryFrameTrigger, t.OnIntersectionEnterTrigger = _.ACTION_OnIntersectionEnterTrigger, t.OnIntersectionExitTrigger = _.ACTION_OnIntersectionExitTrigger, t.OnKeyDownTrigger = _.ACTION_OnKeyDownTrigger, t.OnKeyUpTrigger = _.ACTION_OnKeyUpTrigger, t;
    }(Ee), jl = function(n) {
      function t(e, i, r) {
        var o = n.call(this, e, r) || this;
        return o._sound = i, o;
      }
      return D(t, n), t.prototype._prepare = function() {
      }, t.prototype.execute = function() {
        this._sound !== void 0 && this._sound.play();
      }, t.prototype.serialize = function(e) {
        return n.prototype._serialize.call(this, { name: "PlaySoundAction", properties: [{ name: "sound", value: this._sound.name }] }, e);
      }, t;
    }(wt), mt = function(n) {
      function t(e, i, r) {
        var o = n.call(this, e, r) || this;
        return o._sound = i, o;
      }
      return D(t, n), t.prototype._prepare = function() {
      }, t.prototype.execute = function() {
        this._sound !== void 0 && this._sound.stop();
      }, t.prototype.serialize = function(e) {
        return n.prototype._serialize.call(this, { name: "StopSoundAction", properties: [{ name: "sound", value: this._sound.name }] }, e);
      }, t;
    }(wt);
    j("BABYLON.PlaySoundAction", jl), j("BABYLON.StopSoundAction", mt);
    var Vi = function() {
      function n() {
      }
      return n.Eval = function(t, e) {
        return (t = t.match(/\([^()]*\)/g) ? t.replace(/\([^()]*\)/g, function(i) {
          return i = i.slice(1, i.length - 1), n._HandleParenthesisContent(i, e);
        }) : n._HandleParenthesisContent(t, e)) === "true" || t !== "false" && n.Eval(t, e);
      }, n._HandleParenthesisContent = function(t, e) {
        var i;
        e = e || function(u) {
          return u === "true";
        };
        var r = t.split("||");
        for (var o in r)
          if (Object.prototype.hasOwnProperty.call(r, o)) {
            var a = n._SimplifyNegation(r[o].trim()), s = a.split("&&");
            if (s.length > 1)
              for (var l = 0; l < s.length; ++l) {
                var c = n._SimplifyNegation(s[l].trim());
                if (!(i = c !== "true" && c !== "false" ? c[0] === "!" ? !e(c.substring(1)) : e(c) : c === "true")) {
                  a = "false";
                  break;
                }
              }
            if (i || a === "true") {
              i = !0;
              break;
            }
            i = a !== "true" && a !== "false" ? a[0] === "!" ? !e(a.substring(1)) : e(a) : a === "true";
          }
        return i ? "true" : "false";
      }, n._SimplifyNegation = function(t) {
        return (t = (t = t.replace(/^[\s!]+/, function(e) {
          return (e = e.replace(/[\s]/g, function() {
            return "";
          })).length % 2 ? "!" : "";
        })).trim()) === "!true" ? t = "false" : t === "!false" && (t = "true"), t;
      }, n;
    }(), Xt = function() {
      function n() {
      }
      return n.EnableFor = function(t) {
        t._tags = t._tags || {}, t.hasTags = function() {
          return n.HasTags(t);
        }, t.addTags = function(e) {
          return n.AddTagsTo(t, e);
        }, t.removeTags = function(e) {
          return n.RemoveTagsFrom(t, e);
        }, t.matchesTagsQuery = function(e) {
          return n.MatchesQuery(t, e);
        };
      }, n.DisableFor = function(t) {
        delete t._tags, delete t.hasTags, delete t.addTags, delete t.removeTags, delete t.matchesTagsQuery;
      }, n.HasTags = function(t) {
        if (!t._tags)
          return !1;
        var e = t._tags;
        for (var i in e)
          if (Object.prototype.hasOwnProperty.call(e, i))
            return !0;
        return !1;
      }, n.GetTags = function(t, e) {
        if (e === void 0 && (e = !0), !t._tags)
          return null;
        if (e) {
          var i = [];
          for (var r in t._tags)
            Object.prototype.hasOwnProperty.call(t._tags, r) && t._tags[r] === !0 && i.push(r);
          return i.join(" ");
        }
        return t._tags;
      }, n.AddTagsTo = function(t, e) {
        e && typeof e == "string" && e.split(" ").forEach(function(i) {
          n._AddTagTo(t, i);
        });
      }, n._AddTagTo = function(t, e) {
        (e = e.trim()) !== "" && e !== "true" && e !== "false" && (e.match(/[\s]/) || e.match(/^([!]|([|]|[&]){2})/) || (n.EnableFor(t), t._tags[e] = !0));
      }, n.RemoveTagsFrom = function(t, e) {
        if (n.HasTags(t)) {
          var i = e.split(" ");
          for (var r in i)
            n._RemoveTagFrom(t, i[r]);
        }
      }, n._RemoveTagFrom = function(t, e) {
        delete t._tags[e];
      }, n.MatchesQuery = function(t, e) {
        return e === void 0 || (e === "" ? n.HasTags(t) : Vi.Eval(e, function(i) {
          return n.HasTags(t) && t._tags[i];
        }));
      }, n;
    }(), Iu = {};
    function et(n, t) {
      if (t === void 0 && (t = !1), !t || !Iu[n])
        return Iu[n] = !0, "".concat(n, " needs to be imported before as it contains a side-effect required by your code.");
    }
    var Zs = {}, Js = {}, Mu = function(n, t, e, i) {
      i === void 0 && (i = {});
      var r = n();
      Xt && Xt.HasTags(t) && Xt.AddTagsTo(r, Xt.GetTags(t, !0));
      var o = Yl(r), a = {};
      for (var s in o) {
        var l = o[s], c = t[s], u = l.type;
        if (c != null && (s !== "uniqueId" || Ne.AllowLoadingUniqueId))
          switch (u) {
            case 0:
            case 6:
            case 11:
              r[s] = c;
              break;
            case 1:
              i.cloneTexturesOnlyOnce && a[c.uniqueId] ? r[s] = a[c.uniqueId] : (r[s] = e || c.isRenderTarget ? c : c.clone(), a[c.uniqueId] = r[s]);
              break;
            case 2:
            case 3:
            case 4:
            case 5:
            case 7:
            case 10:
            case 12:
              r[s] = e ? c : c.clone();
          }
      }
      return r;
    };
    function Yl(n) {
      var t = n.getClassName();
      if (Js[t])
        return Js[t];
      Js[t] = {};
      for (var e = Js[t], i = n, r = t; r; ) {
        var o = Zs[r];
        for (var a in o)
          e[a] = o[a];
        var s = void 0, l = !1;
        do {
          if (!(s = Object.getPrototypeOf(i)).getClassName) {
            l = !0;
            break;
          }
          if (s.getClassName() !== r)
            break;
          i = s;
        } while (s);
        if (l)
          break;
        r = s.getClassName(), i = s;
      }
      return e;
    }
    function $n(n, t) {
      return function(e, i) {
        var r = function(o) {
          var a = o.getClassName();
          return Zs[a] || (Zs[a] = {}), Zs[a];
        }(e);
        r[i] || (r[i] = { type: n, sourceName: t });
      };
    }
    function ye(n, t) {
      return t === void 0 && (t = null), function(e, i) {
        return i === void 0 && (i = null), function(r, o) {
          var a = i || "_" + o;
          Object.defineProperty(r, o, { get: function() {
            return this[a];
          }, set: function(s) {
            typeof this.equals == "function" && this.equals(s) || this[a] !== s && (this[a] = s, r[e].apply(this));
          }, enumerable: !0, configurable: !0 });
        };
      }(n, t);
    }
    function N(n) {
      return $n(0, n);
    }
    function St(n) {
      return $n(1, n);
    }
    function ri(n) {
      return $n(2, n);
    }
    function Jo(n) {
      return $n(3, n);
    }
    function ss(n) {
      return $n(4, n);
    }
    function ki(n) {
      return $n(5, n);
    }
    function $o(n) {
      return $n(6, n);
    }
    function Kl(n) {
      return $n(7, n);
    }
    function ls(n) {
      return $n(8, n);
    }
    function $s(n) {
      return $n(9, n);
    }
    function ql(n) {
      return $n(10, n);
    }
    function cs(n) {
      return $n(12, n);
    }
    function Ql(n) {
      return $n(11, n);
    }
    var Ou, Ne = function() {
      function n() {
      }
      return n.AppendSerializedAnimations = function(t, e) {
        if (t.animations) {
          e.animations = [];
          for (var i = 0; i < t.animations.length; i++) {
            var r = t.animations[i];
            e.animations.push(r.serialize());
          }
        }
      }, n.Serialize = function(t, e) {
        e || (e = {}), Xt && (e.tags = Xt.GetTags(t));
        var i = Yl(t);
        for (var r in i) {
          var o = i[r], a = o.sourceName || r, s = o.type, l = t[r];
          if (l != null && (r !== "uniqueId" || n.AllowLoadingUniqueId))
            switch (s) {
              case 0:
                e[a] = l;
                break;
              case 1:
              case 3:
              case 7:
              case 9:
                e[a] = l.serialize();
                break;
              case 2:
              case 4:
              case 5:
              case 8:
              case 10:
              case 12:
                e[a] = l.asArray();
                break;
              case 6:
              case 11:
                e[a] = l.id;
            }
        }
        return e;
      }, n.ParseProperties = function(t, e, i, r) {
        r || (r = "");
        var o = Yl(e);
        for (var a in o) {
          var s = o[a], l = t[s.sourceName || a], c = s.type;
          if (l != null && (a !== "uniqueId" || n.AllowLoadingUniqueId)) {
            var u = e;
            switch (c) {
              case 0:
                u[a] = l;
                break;
              case 1:
                i && (u[a] = n._TextureParser(l, i, r));
                break;
              case 2:
                u[a] = ne.FromArray(l);
                break;
              case 3:
                u[a] = n._FresnelParametersParser(l);
                break;
              case 4:
                u[a] = fe.FromArray(l);
                break;
              case 5:
                u[a] = v.FromArray(l);
                break;
              case 6:
                i && (u[a] = i.getLastMeshById(l));
                break;
              case 7:
                u[a] = n._ColorCurvesParser(l);
                break;
              case 8:
                u[a] = Ie.FromArray(l);
                break;
              case 9:
                u[a] = n._ImageProcessingConfigurationParser(l);
                break;
              case 10:
                u[a] = oe.FromArray(l);
                break;
              case 11:
                i && (u[a] = i.getCameraById(l));
                break;
              case 12:
                u[a] = B.FromArray(l);
            }
          }
        }
      }, n.Parse = function(t, e, i, r) {
        r === void 0 && (r = null);
        var o = t();
        return Xt && Xt.AddTagsTo(o, e.tags), n.ParseProperties(e, o, i, r), o;
      }, n.Clone = function(t, e, i) {
        return i === void 0 && (i = {}), Mu(t, e, !1, i);
      }, n.Instanciate = function(t, e) {
        return Mu(t, e, !0);
      }, n.AllowLoadingUniqueId = !1, n._ImageProcessingConfigurationParser = function(t) {
        throw et("ImageProcessingConfiguration");
      }, n._FresnelParametersParser = function(t) {
        throw et("FresnelParameters");
      }, n._ColorCurvesParser = function(t) {
        throw et("ColorCurves");
      }, n._TextureParser = function(t, e, i) {
        throw et("Texture");
      }, n;
    }();
    function ea(n, t, e, i) {
      var r = e.value;
      e.value = function() {
        for (var o = [], a = 0; a < arguments.length; a++)
          o[a] = arguments[a];
        var s = r;
        if (typeof _native < "u" && _native[t]) {
          var l = _native[t];
          s = i ? function() {
            for (var c = [], u = 0; u < arguments.length; u++)
              c[u] = arguments[u];
            return i.apply(void 0, c) ? l.apply(void 0, c) : r.apply(void 0, c);
          } : l;
        }
        return n[t] = s, s.apply(void 0, o);
      };
    }
    ea.filter = function(n) {
      return function(t, e, i) {
        return ea(t, e, i, n);
      };
    }, function(n) {
      n[n.NONE = 0] = "NONE", n[n.STEP = 1] = "STEP";
    }(Ou || (Ou = {}));
    var Zl = function() {
      function n(t, e, i) {
        this.name = t, this.from = e, this.to = i;
      }
      return n.prototype.clone = function() {
        return new n(this.name, this.from, this.to);
      }, n;
    }(), _1 = function() {
      this._doNotSerialize = !1, this._isDisposed = !1, this._sceneRootNodesIndex = -1, this._isEnabled = !0, this._isParentEnabled = !0, this._isReady = !0, this._onEnabledStateChangedObservable = new H(), this._onClonedObservable = new H();
    }, oi = function() {
      function n(t, e) {
        e === void 0 && (e = null), this._isDirty = !1, this._nodeDataStorage = new _1(), this.state = "", this.metadata = null, this.reservedDataStore = null, this._accessibilityTag = null, this.onAccessibilityTagChangedObservable = new H(), this._parentContainer = null, this.animations = [], this._ranges = {}, this.onReady = null, this._currentRenderId = -1, this._parentUpdateId = -1, this._childUpdateId = -1, this._waitingParentId = null, this._waitingParentInstanceIndex = null, this._waitingParsedUniqueId = null, this._cache = {}, this._parentNode = null, this._children = null, this._worldMatrix = B.Identity(), this._worldMatrixDeterminant = 0, this._worldMatrixDeterminantIsDirty = !0, this._animationPropertiesOverride = null, this._isNode = !0, this.onDisposeObservable = new H(), this._onDisposeObserver = null, this._behaviors = new Array(), this.name = t, this.id = t, this._scene = e || Me.LastCreatedScene, this.uniqueId = this._scene.getUniqueId(), this._initCache();
      }
      return n.AddNodeConstructor = function(t, e) {
        this._NodeConstructors[t] = e;
      }, n.Construct = function(t, e, i, r) {
        var o = this._NodeConstructors[t];
        return o ? o(e, i, r) : null;
      }, Object.defineProperty(n.prototype, "accessibilityTag", { get: function() {
        return this._accessibilityTag;
      }, set: function(t) {
        this._accessibilityTag = t, this.onAccessibilityTagChangedObservable.notifyObservers(t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "doNotSerialize", { get: function() {
        return !!this._nodeDataStorage._doNotSerialize || !!this._parentNode && this._parentNode.doNotSerialize;
      }, set: function(t) {
        this._nodeDataStorage._doNotSerialize = t;
      }, enumerable: !1, configurable: !0 }), n.prototype.isDisposed = function() {
        return this._nodeDataStorage._isDisposed;
      }, Object.defineProperty(n.prototype, "parent", { get: function() {
        return this._parentNode;
      }, set: function(t) {
        if (this._parentNode !== t) {
          var e = this._parentNode;
          if (this._parentNode && this._parentNode._children !== void 0 && this._parentNode._children !== null) {
            var i = this._parentNode._children.indexOf(this);
            i !== -1 && this._parentNode._children.splice(i, 1), t || this._nodeDataStorage._isDisposed || this._addToSceneRootNodes();
          }
          this._parentNode = t, this._parentNode && (this._parentNode._children !== void 0 && this._parentNode._children !== null || (this._parentNode._children = new Array()), this._parentNode._children.push(this), e || this._removeFromSceneRootNodes()), this._syncParentEnabledState();
        }
      }, enumerable: !1, configurable: !0 }), n.prototype._serializeAsParent = function(t) {
        t.parentId = this.uniqueId;
      }, n.prototype._addToSceneRootNodes = function() {
        this._nodeDataStorage._sceneRootNodesIndex === -1 && (this._nodeDataStorage._sceneRootNodesIndex = this._scene.rootNodes.length, this._scene.rootNodes.push(this));
      }, n.prototype._removeFromSceneRootNodes = function() {
        if (this._nodeDataStorage._sceneRootNodesIndex !== -1) {
          var t = this._scene.rootNodes, e = t.length - 1;
          t[this._nodeDataStorage._sceneRootNodesIndex] = t[e], t[this._nodeDataStorage._sceneRootNodesIndex]._nodeDataStorage._sceneRootNodesIndex = this._nodeDataStorage._sceneRootNodesIndex, this._scene.rootNodes.pop(), this._nodeDataStorage._sceneRootNodesIndex = -1;
        }
      }, Object.defineProperty(n.prototype, "animationPropertiesOverride", { get: function() {
        return this._animationPropertiesOverride ? this._animationPropertiesOverride : this._scene.animationPropertiesOverride;
      }, set: function(t) {
        this._animationPropertiesOverride = t;
      }, enumerable: !1, configurable: !0 }), n.prototype.getClassName = function() {
        return "Node";
      }, Object.defineProperty(n.prototype, "onDispose", { set: function(t) {
        this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver), this._onDisposeObserver = this.onDisposeObservable.add(t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "onEnabledStateChangedObservable", { get: function() {
        return this._nodeDataStorage._onEnabledStateChangedObservable;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "onClonedObservable", { get: function() {
        return this._nodeDataStorage._onClonedObservable;
      }, enumerable: !1, configurable: !0 }), n.prototype.getScene = function() {
        return this._scene;
      }, n.prototype.getEngine = function() {
        return this._scene.getEngine();
      }, n.prototype.addBehavior = function(t, e) {
        var i = this;
        return e === void 0 && (e = !1), this._behaviors.indexOf(t) !== -1 || (t.init(), this._scene.isLoading && !e ? this._scene.onDataLoadedObservable.addOnce(function() {
          t.attach(i);
        }) : t.attach(this), this._behaviors.push(t)), this;
      }, n.prototype.removeBehavior = function(t) {
        var e = this._behaviors.indexOf(t);
        return e === -1 || (this._behaviors[e].detach(), this._behaviors.splice(e, 1)), this;
      }, Object.defineProperty(n.prototype, "behaviors", { get: function() {
        return this._behaviors;
      }, enumerable: !1, configurable: !0 }), n.prototype.getBehaviorByName = function(t) {
        for (var e = 0, i = this._behaviors; e < i.length; e++) {
          var r = i[e];
          if (r.name === t)
            return r;
        }
        return null;
      }, n.prototype.getWorldMatrix = function() {
        return this._currentRenderId !== this._scene.getRenderId() && this.computeWorldMatrix(), this._worldMatrix;
      }, n.prototype._getWorldMatrixDeterminant = function() {
        return this._worldMatrixDeterminantIsDirty && (this._worldMatrixDeterminantIsDirty = !1, this._worldMatrixDeterminant = this._worldMatrix.determinant()), this._worldMatrixDeterminant;
      }, Object.defineProperty(n.prototype, "worldMatrixFromCache", { get: function() {
        return this._worldMatrix;
      }, enumerable: !1, configurable: !0 }), n.prototype._initCache = function() {
        this._cache = {}, this._cache.parent = void 0;
      }, n.prototype.updateCache = function(t) {
        !t && this.isSynchronized() || (this._cache.parent = this.parent, this._updateCache());
      }, n.prototype._getActionManagerForTrigger = function(t, e) {
        return this.parent ? this.parent._getActionManagerForTrigger(t, !1) : null;
      }, n.prototype._updateCache = function(t) {
      }, n.prototype._isSynchronized = function() {
        return !0;
      }, n.prototype._markSyncedWithParent = function() {
        this._parentNode && (this._parentUpdateId = this._parentNode._childUpdateId);
      }, n.prototype.isSynchronizedWithParent = function() {
        return !this._parentNode || !this._parentNode._isDirty && this._parentUpdateId === this._parentNode._childUpdateId && this._parentNode.isSynchronized();
      }, n.prototype.isSynchronized = function() {
        return this._cache.parent !== this._parentNode ? (this._cache.parent = this._parentNode, !1) : !(this._parentNode && !this.isSynchronizedWithParent()) && this._isSynchronized();
      }, n.prototype.isReady = function(t) {
        return this._nodeDataStorage._isReady;
      }, n.prototype.markAsDirty = function(t) {
        return this._currentRenderId = Number.MAX_VALUE, this._isDirty = !0, this;
      }, n.prototype.isEnabled = function(t) {
        return t === void 0 && (t = !0), t === !1 ? this._nodeDataStorage._isEnabled : !!this._nodeDataStorage._isEnabled && this._nodeDataStorage._isParentEnabled;
      }, n.prototype._syncParentEnabledState = function() {
        this._nodeDataStorage._isParentEnabled = !this._parentNode || this._parentNode.isEnabled(), this._children && this._children.forEach(function(t) {
          t._syncParentEnabledState();
        });
      }, n.prototype.setEnabled = function(t) {
        this._nodeDataStorage._isEnabled !== t && (this._nodeDataStorage._isEnabled = t, this._syncParentEnabledState(), this._nodeDataStorage._onEnabledStateChangedObservable.notifyObservers(t));
      }, n.prototype.isDescendantOf = function(t) {
        return !!this.parent && (this.parent === t || this.parent.isDescendantOf(t));
      }, n.prototype._getDescendants = function(t, e, i) {
        if (e === void 0 && (e = !1), this._children)
          for (var r = 0; r < this._children.length; r++) {
            var o = this._children[r];
            i && !i(o) || t.push(o), e || o._getDescendants(t, !1, i);
          }
      }, n.prototype.getDescendants = function(t, e) {
        var i = [];
        return this._getDescendants(i, t, e), i;
      }, n.prototype.getChildMeshes = function(t, e) {
        var i = [];
        return this._getDescendants(i, t, function(r) {
          return (!e || e(r)) && r.cullingStrategy !== void 0;
        }), i;
      }, n.prototype.getChildren = function(t, e) {
        return e === void 0 && (e = !0), this.getDescendants(e, t);
      }, n.prototype._setReady = function(t) {
        t !== this._nodeDataStorage._isReady && (t ? (this.onReady && this.onReady(this), this._nodeDataStorage._isReady = !0) : this._nodeDataStorage._isReady = !1);
      }, n.prototype.getAnimationByName = function(t) {
        for (var e = 0; e < this.animations.length; e++) {
          var i = this.animations[e];
          if (i.name === t)
            return i;
        }
        return null;
      }, n.prototype.createAnimationRange = function(t, e, i) {
        if (!this._ranges[t]) {
          this._ranges[t] = n._AnimationRangeFactory(t, e, i);
          for (var r = 0, o = this.animations.length; r < o; r++)
            this.animations[r] && this.animations[r].createRange(t, e, i);
        }
      }, n.prototype.deleteAnimationRange = function(t, e) {
        e === void 0 && (e = !0);
        for (var i = 0, r = this.animations.length; i < r; i++)
          this.animations[i] && this.animations[i].deleteRange(t, e);
        this._ranges[t] = null;
      }, n.prototype.getAnimationRange = function(t) {
        return this._ranges[t] || null;
      }, n.prototype.clone = function(t, e, i) {
        var r = this, o = Ne.Clone(function() {
          return new n(t, r.getScene());
        }, this);
        if (e && (o.parent = e), !i)
          for (var a = this.getDescendants(!0), s = 0; s < a.length; s++) {
            var l = a[s];
            l.clone(t + "." + l.name, o);
          }
        return o;
      }, n.prototype.getAnimationRanges = function() {
        var t, e = [];
        for (t in this._ranges)
          e.push(this._ranges[t]);
        return e;
      }, n.prototype.beginAnimation = function(t, e, i, r) {
        var o = this.getAnimationRange(t);
        return o ? this._scene.beginAnimation(this, o.from, o.to, e, i, r) : null;
      }, n.prototype.serializeAnimationRanges = function() {
        var t = [];
        for (var e in this._ranges) {
          var i = this._ranges[e];
          if (i) {
            var r = {};
            r.name = e, r.from = i.from, r.to = i.to, t.push(r);
          }
        }
        return t;
      }, n.prototype.computeWorldMatrix = function(t) {
        return this._worldMatrix || (this._worldMatrix = B.Identity()), this._worldMatrix;
      }, n.prototype.dispose = function(t, e) {
        if (e === void 0 && (e = !1), this._nodeDataStorage._isDisposed = !0, !t)
          for (var i = 0, r = this.getDescendants(!0); i < r.length; i++)
            r[i].dispose(t, e);
        this.parent ? this.parent = null : this._removeFromSceneRootNodes(), this.onDisposeObservable.notifyObservers(this), this.onDisposeObservable.clear(), this.onEnabledStateChangedObservable.clear(), this.onClonedObservable.clear();
        for (var o = 0, a = this._behaviors; o < a.length; o++)
          a[o].detach();
        this._behaviors.length = 0, this.metadata = null;
      }, n.ParseAnimationRanges = function(t, e, i) {
        if (e.ranges)
          for (var r = 0; r < e.ranges.length; r++) {
            var o = e.ranges[r];
            t.createAnimationRange(o.name, o.from, o.to);
          }
      }, n.prototype.getHierarchyBoundingVectors = function(t, e) {
        var i, r;
        t === void 0 && (t = !0), e === void 0 && (e = null), this.getScene().incrementRenderId(), this.computeWorldMatrix(!0);
        var o = this;
        if (o.getBoundingInfo && o.subMeshes) {
          var a = o.getBoundingInfo();
          i = a.boundingBox.minimumWorld.clone(), r = a.boundingBox.maximumWorld.clone();
        } else
          i = new v(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), r = new v(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
        if (t)
          for (var s = 0, l = this.getDescendants(!1); s < l.length; s++) {
            var c = l[s];
            if (c.computeWorldMatrix(!0), (!e || e(c)) && c.getBoundingInfo && c.getTotalVertices() !== 0) {
              var u = c.getBoundingInfo().boundingBox, h = u.minimumWorld, d = u.maximumWorld;
              v.CheckExtends(h, i, r), v.CheckExtends(d, i, r);
            }
          }
        return { min: i, max: r };
      }, n._AnimationRangeFactory = function(t, e, i) {
        throw et("AnimationRange");
      }, n._NodeConstructors = {}, x([N()], n.prototype, "name", void 0), x([N()], n.prototype, "id", void 0), x([N()], n.prototype, "uniqueId", void 0), x([N()], n.prototype, "state", void 0), x([N()], n.prototype, "metadata", void 0), n;
    }(), el = function() {
      function n(t, e) {
        this.width = t, this.height = e;
      }
      return n.prototype.toString = function() {
        return "{W: ".concat(this.width, ", H: ").concat(this.height, "}");
      }, n.prototype.getClassName = function() {
        return "Size";
      }, n.prototype.getHashCode = function() {
        var t = 0 | this.width;
        return 397 * t ^ (0 | this.height);
      }, n.prototype.copyFrom = function(t) {
        this.width = t.width, this.height = t.height;
      }, n.prototype.copyFromFloats = function(t, e) {
        return this.width = t, this.height = e, this;
      }, n.prototype.set = function(t, e) {
        return this.copyFromFloats(t, e);
      }, n.prototype.multiplyByFloats = function(t, e) {
        return new n(this.width * t, this.height * e);
      }, n.prototype.clone = function() {
        return new n(this.width, this.height);
      }, n.prototype.equals = function(t) {
        return !!t && this.width === t.width && this.height === t.height;
      }, Object.defineProperty(n.prototype, "surface", { get: function() {
        return this.width * this.height;
      }, enumerable: !1, configurable: !0 }), n.Zero = function() {
        return new n(0, 0);
      }, n.prototype.add = function(t) {
        return new n(this.width + t.width, this.height + t.height);
      }, n.prototype.subtract = function(t) {
        return new n(this.width - t.width, this.height - t.height);
      }, n.prototype.scale = function(t) {
        return new n(this.width * t, this.height * t);
      }, n.Lerp = function(t, e, i) {
        return new n(t.width + (e.width - t.width) * i, t.height + (e.height - t.height) * i);
      }, n;
    }(), _n = function() {
      function n() {
        this._xhr = typeof _native < "u" && _native.XMLHttpRequest ? new _native.XMLHttpRequest() : new XMLHttpRequest(), this._requestURL = "";
      }
      return Object.defineProperty(n, "IsCustomRequestAvailable", { get: function() {
        return Object.keys(n.CustomRequestHeaders).length > 0 || n.CustomRequestModifiers.length > 0;
      }, enumerable: !1, configurable: !0 }), n.prototype._injectCustomRequestHeaders = function() {
        if (!this._shouldSkipRequestModifications(this._requestURL))
          for (var t in n.CustomRequestHeaders) {
            var e = n.CustomRequestHeaders[t];
            e && this._xhr.setRequestHeader(t, e);
          }
      }, n.prototype._shouldSkipRequestModifications = function(t) {
        return n.SkipRequestModificationForBabylonCDN && (t.includes("preview.babylonjs.com") || t.includes("cdn.babylonjs.com"));
      }, Object.defineProperty(n.prototype, "onprogress", { get: function() {
        return this._xhr.onprogress;
      }, set: function(t) {
        this._xhr.onprogress = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "readyState", { get: function() {
        return this._xhr.readyState;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "status", { get: function() {
        return this._xhr.status;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "statusText", { get: function() {
        return this._xhr.statusText;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "response", { get: function() {
        return this._xhr.response;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "responseURL", { get: function() {
        return this._xhr.responseURL;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "responseText", { get: function() {
        return this._xhr.responseText;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "responseType", { get: function() {
        return this._xhr.responseType;
      }, set: function(t) {
        this._xhr.responseType = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "timeout", { get: function() {
        return this._xhr.timeout;
      }, set: function(t) {
        this._xhr.timeout = t;
      }, enumerable: !1, configurable: !0 }), n.prototype.addEventListener = function(t, e, i) {
        this._xhr.addEventListener(t, e, i);
      }, n.prototype.removeEventListener = function(t, e, i) {
        this._xhr.removeEventListener(t, e, i);
      }, n.prototype.abort = function() {
        this._xhr.abort();
      }, n.prototype.send = function(t) {
        n.CustomRequestHeaders && this._injectCustomRequestHeaders(), this._xhr.send(t);
      }, n.prototype.open = function(t, e) {
        for (var i = 0, r = n.CustomRequestModifiers; i < r.length; i++) {
          var o = r[i];
          if (this._shouldSkipRequestModifications(e))
            return;
          o(this._xhr, e);
        }
        return e = (e = e.replace("file:http:", "http:")).replace("file:https:", "https:"), this._requestURL = e, this._xhr.open(t, e, !0);
      }, n.prototype.setRequestHeader = function(t, e) {
        this._xhr.setRequestHeader(t, e);
      }, n.prototype.getResponseHeader = function(t) {
        return this._xhr.getResponseHeader(t);
      }, n.CustomRequestHeaders = {}, n.CustomRequestModifiers = new Array(), n.SkipRequestModificationForBabylonCDN = !0, n;
    }(), Kd = Object.freeze(new oe(0, 0, 0, 0)), qd = Object.freeze(v.Zero()), Qd = Object.freeze(fe.Zero()), Zd = Object.freeze(el.Zero()), Jd = Object.freeze(ne.Black()), $d = Object.freeze(new Ie(0, 0, 0, 0)), Eo = { key: 0, repeatCount: 0, loopMode: 2 }, Je = function() {
      function n(t, e, i, r, o, a) {
        this.name = t, this.targetProperty = e, this.framePerSecond = i, this.dataType = r, this.loopMode = o, this.enableBlending = a, this._easingFunction = null, this._runtimeAnimations = new Array(), this._events = new Array(), this.blendingSpeed = 0.01, this._ranges = {}, this.targetPropertyPath = e.split("."), this.dataType = r, this.loopMode = o === void 0 ? n.ANIMATIONLOOPMODE_CYCLE : o, this.uniqueId = n._UniqueIdGenerator++;
      }
      return n._PrepareAnimation = function(t, e, i, r, o, a, s, l) {
        var c = void 0;
        if (!isNaN(parseFloat(o)) && isFinite(o) ? c = n.ANIMATIONTYPE_FLOAT : o instanceof oe ? c = n.ANIMATIONTYPE_QUATERNION : o instanceof v ? c = n.ANIMATIONTYPE_VECTOR3 : o instanceof fe ? c = n.ANIMATIONTYPE_VECTOR2 : o instanceof ne ? c = n.ANIMATIONTYPE_COLOR3 : o instanceof Ie ? c = n.ANIMATIONTYPE_COLOR4 : o instanceof el && (c = n.ANIMATIONTYPE_SIZE), c == null)
          return null;
        var u = new n(t, e, i, c, s), h = [{ frame: 0, value: o }, { frame: r, value: a }];
        return u.setKeys(h), l !== void 0 && u.setEasingFunction(l), u;
      }, n.CreateAnimation = function(t, e, i, r) {
        var o = new n(t + "Animation", t, i, e, n.ANIMATIONLOOPMODE_CONSTANT);
        return o.setEasingFunction(r), o;
      }, n.CreateAndStartAnimation = function(t, e, i, r, o, a, s, l, c, u, h) {
        var d = n._PrepareAnimation(t, i, r, o, a, s, l, c);
        return d ? (e.getScene && (h = e.getScene()), h ? h.beginDirectAnimation(e, [d], 0, o, d.loopMode === 1, 1, u) : null) : null;
      }, n.CreateAndStartHierarchyAnimation = function(t, e, i, r, o, a, s, l, c, u, h) {
        var d = n._PrepareAnimation(t, r, o, a, s, l, c, u);
        return d ? e.getScene().beginDirectHierarchyAnimation(e, i, [d], 0, a, d.loopMode === 1, 1, h) : null;
      }, n.CreateMergeAndStartAnimation = function(t, e, i, r, o, a, s, l, c, u) {
        var h = n._PrepareAnimation(t, i, r, o, a, s, l, c);
        return h ? (e.animations.push(h), e.getScene().beginAnimation(e, 0, o, h.loopMode === 1, 1, u)) : null;
      }, n.MakeAnimationAdditive = function(t, e, i, r, o) {
        var a, s, l;
        r === void 0 && (r = !1);
        var c = t;
        if ((l = typeof e == "object" ? e : { referenceFrame: e ?? 0, range: i, cloneOriginalAnimation: r, clonedAnimationName: o }).cloneOriginalAnimation && ((c = t.clone()).name = l.clonedAnimationName || c.name), !c._keys.length)
          return c;
        var u = l.referenceFrame && l.referenceFrame >= 0 ? l.referenceFrame : 0, h = 0, d = c._keys[0], p = c._keys.length - 1, f = c._keys[p], m = { referenceValue: d.value, referencePosition: F.Vector3[0], referenceQuaternion: F.Quaternion[0], referenceScaling: F.Vector3[1], keyPosition: F.Vector3[2], keyQuaternion: F.Quaternion[1], keyScaling: F.Vector3[3] }, g = d.frame, y = f.frame;
        if (l.range) {
          var b = c.getRange(l.range);
          b && (g = b.from, y = b.to);
        } else
          g = (a = l.fromFrame) !== null && a !== void 0 ? a : g, y = (s = l.toFrame) !== null && s !== void 0 ? s : y;
        if (g !== d.frame && (h = c.createKeyForFrame(g)), y !== f.frame && (p = c.createKeyForFrame(y)), c._keys.length === 1) {
          var T = c._getKeyValue(c._keys[0]);
          m.referenceValue = T.clone ? T.clone() : T;
        } else
          u <= d.frame ? (T = c._getKeyValue(d.value), m.referenceValue = T.clone ? T.clone() : T) : u >= f.frame ? (T = c._getKeyValue(f.value), m.referenceValue = T.clone ? T.clone() : T) : (Eo.key = 0, T = c._interpolate(u, Eo), m.referenceValue = T.clone ? T.clone() : T);
        c.dataType === n.ANIMATIONTYPE_QUATERNION ? m.referenceValue.normalize().conjugateInPlace() : c.dataType === n.ANIMATIONTYPE_MATRIX && (m.referenceValue.decompose(m.referenceScaling, m.referenceQuaternion, m.referencePosition), m.referenceQuaternion.normalize().conjugateInPlace());
        for (var S = Number.MAX_VALUE, E = l.clipKeys ? [] : null, A = h; A <= p; A++) {
          var R = c._keys[A];
          if (E && (R = { frame: R.frame, value: R.value.clone ? R.value.clone() : R.value, inTangent: R.inTangent, outTangent: R.outTangent, interpolation: R.interpolation, lockedTangent: R.lockedTangent }, S === Number.MAX_VALUE && (S = R.frame), R.frame -= S, E.push(R)), !A || c.dataType === n.ANIMATIONTYPE_FLOAT || R.value !== d.value)
            switch (c.dataType) {
              case n.ANIMATIONTYPE_MATRIX:
                R.value.decompose(m.keyScaling, m.keyQuaternion, m.keyPosition), m.keyPosition.subtractInPlace(m.referencePosition), m.keyScaling.divideInPlace(m.referenceScaling), m.referenceQuaternion.multiplyToRef(m.keyQuaternion, m.keyQuaternion), B.ComposeToRef(m.keyScaling, m.keyQuaternion, m.keyPosition, R.value);
                break;
              case n.ANIMATIONTYPE_QUATERNION:
                m.referenceValue.multiplyToRef(R.value, R.value);
                break;
              case n.ANIMATIONTYPE_VECTOR2:
              case n.ANIMATIONTYPE_VECTOR3:
              case n.ANIMATIONTYPE_COLOR3:
              case n.ANIMATIONTYPE_COLOR4:
                R.value.subtractToRef(m.referenceValue, R.value);
                break;
              case n.ANIMATIONTYPE_SIZE:
                R.value.width -= m.referenceValue.width, R.value.height -= m.referenceValue.height;
                break;
              default:
                R.value -= m.referenceValue;
            }
        }
        return E && c.setKeys(E, !0), c;
      }, n.TransitionTo = function(t, e, i, r, o, a, s, l) {
        if (l === void 0 && (l = null), s <= 0)
          return i[t] = e, l && l(), null;
        var c = o * (s / 1e3);
        a.setKeys([{ frame: 0, value: i[t].clone ? i[t].clone() : i[t] }, { frame: c, value: e }]), i.animations || (i.animations = []), i.animations.push(a);
        var u = r.beginAnimation(i, 0, c, !1);
        return u.onAnimationEnd = l, u;
      }, Object.defineProperty(n.prototype, "runtimeAnimations", { get: function() {
        return this._runtimeAnimations;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "hasRunningRuntimeAnimations", { get: function() {
        for (var t = 0, e = this._runtimeAnimations; t < e.length; t++)
          if (!e[t].isStopped())
            return !0;
        return !1;
      }, enumerable: !1, configurable: !0 }), n.prototype.toString = function(t) {
        var e = "Name: " + this.name + ", property: " + this.targetProperty;
        if (e += ", datatype: " + ["Float", "Vector3", "Quaternion", "Matrix", "Color3", "Vector2"][this.dataType], e += ", nKeys: " + (this._keys ? this._keys.length : "none"), e += ", nRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none"), t) {
          e += ", Ranges: {";
          var i = !0;
          for (var r in this._ranges)
            i && (e += ", ", i = !1), e += r;
          e += "}";
        }
        return e;
      }, n.prototype.addEvent = function(t) {
        this._events.push(t), this._events.sort(function(e, i) {
          return e.frame - i.frame;
        });
      }, n.prototype.removeEvents = function(t) {
        for (var e = 0; e < this._events.length; e++)
          this._events[e].frame === t && (this._events.splice(e, 1), e--);
      }, n.prototype.getEvents = function() {
        return this._events;
      }, n.prototype.createRange = function(t, e, i) {
        this._ranges[t] || (this._ranges[t] = new Zl(t, e, i));
      }, n.prototype.deleteRange = function(t, e) {
        e === void 0 && (e = !0);
        var i = this._ranges[t];
        if (i) {
          if (e)
            for (var r = i.from, o = i.to, a = this._keys.length - 1; a >= 0; a--)
              this._keys[a].frame >= r && this._keys[a].frame <= o && this._keys.splice(a, 1);
          this._ranges[t] = null;
        }
      }, n.prototype.getRange = function(t) {
        return this._ranges[t];
      }, n.prototype.getKeys = function() {
        return this._keys;
      }, n.prototype.getHighestFrame = function() {
        for (var t = 0, e = 0, i = this._keys.length; e < i; e++)
          t < this._keys[e].frame && (t = this._keys[e].frame);
        return t;
      }, n.prototype.getEasingFunction = function() {
        return this._easingFunction;
      }, n.prototype.setEasingFunction = function(t) {
        this._easingFunction = t;
      }, n.prototype.floatInterpolateFunction = function(t, e, i) {
        return ue.Lerp(t, e, i);
      }, n.prototype.floatInterpolateFunctionWithTangents = function(t, e, i, r, o) {
        return ue.Hermite(t, e, i, r, o);
      }, n.prototype.quaternionInterpolateFunction = function(t, e, i) {
        return oe.Slerp(t, e, i);
      }, n.prototype.quaternionInterpolateFunctionWithTangents = function(t, e, i, r, o) {
        return oe.Hermite(t, e, i, r, o).normalize();
      }, n.prototype.vector3InterpolateFunction = function(t, e, i) {
        return v.Lerp(t, e, i);
      }, n.prototype.vector3InterpolateFunctionWithTangents = function(t, e, i, r, o) {
        return v.Hermite(t, e, i, r, o);
      }, n.prototype.vector2InterpolateFunction = function(t, e, i) {
        return fe.Lerp(t, e, i);
      }, n.prototype.vector2InterpolateFunctionWithTangents = function(t, e, i, r, o) {
        return fe.Hermite(t, e, i, r, o);
      }, n.prototype.sizeInterpolateFunction = function(t, e, i) {
        return el.Lerp(t, e, i);
      }, n.prototype.color3InterpolateFunction = function(t, e, i) {
        return ne.Lerp(t, e, i);
      }, n.prototype.color3InterpolateFunctionWithTangents = function(t, e, i, r, o) {
        return ne.Hermite(t, e, i, r, o);
      }, n.prototype.color4InterpolateFunction = function(t, e, i) {
        return Ie.Lerp(t, e, i);
      }, n.prototype.color4InterpolateFunctionWithTangents = function(t, e, i, r, o) {
        return Ie.Hermite(t, e, i, r, o);
      }, n.prototype._getKeyValue = function(t) {
        return typeof t == "function" ? t() : t;
      }, n.prototype.evaluate = function(t) {
        return Eo.key = 0, this._interpolate(t, Eo);
      }, n.prototype._interpolate = function(t, e, i) {
        var r;
        if (i === void 0 && (i = !1), e.loopMode === n.ANIMATIONLOOPMODE_CONSTANT && e.repeatCount > 0)
          return e.highLimitValue.clone ? e.highLimitValue.clone() : e.highLimitValue;
        for (var o = this._keys, a = o.length, s = e.key; s >= 0 && t < o[s].frame; )
          --s;
        for (; s + 1 <= a - 1 && t >= o[s + 1].frame; )
          ++s;
        if (e.key = s, s < 0)
          return i ? void 0 : this._getKeyValue(o[0].value);
        if (s + 1 > a - 1)
          return i ? void 0 : this._getKeyValue(o[a - 1].value);
        var l = o[s], c = o[s + 1];
        if (!i || t !== l.frame && t !== c.frame) {
          var u = this._getKeyValue(l.value), h = this._getKeyValue(c.value);
          if (l.interpolation === Ou.STEP)
            return c.frame > t ? u : h;
          var d = l.outTangent !== void 0 && c.inTangent !== void 0, p = c.frame - l.frame, f = (t - l.frame) / p, m = l.easingFunction || this.getEasingFunction();
          switch (m !== null && (f = m.ease(f)), this.dataType) {
            case n.ANIMATIONTYPE_FLOAT:
              var g = d ? this.floatInterpolateFunctionWithTangents(u, l.outTangent * p, h, c.inTangent * p, f) : this.floatInterpolateFunction(u, h, f);
              switch (e.loopMode) {
                case n.ANIMATIONLOOPMODE_CYCLE:
                case n.ANIMATIONLOOPMODE_CONSTANT:
                case n.ANIMATIONLOOPMODE_YOYO:
                  return g;
                case n.ANIMATIONLOOPMODE_RELATIVE:
                  return ((r = e.offsetValue) !== null && r !== void 0 ? r : 0) * e.repeatCount + g;
              }
              break;
            case n.ANIMATIONTYPE_QUATERNION:
              var y = d ? this.quaternionInterpolateFunctionWithTangents(u, l.outTangent.scale(p), h, c.inTangent.scale(p), f) : this.quaternionInterpolateFunction(u, h, f);
              switch (e.loopMode) {
                case n.ANIMATIONLOOPMODE_CYCLE:
                case n.ANIMATIONLOOPMODE_CONSTANT:
                case n.ANIMATIONLOOPMODE_YOYO:
                  return y;
                case n.ANIMATIONLOOPMODE_RELATIVE:
                  return y.addInPlace((e.offsetValue || Kd).scale(e.repeatCount));
              }
              return y;
            case n.ANIMATIONTYPE_VECTOR3:
              var b = d ? this.vector3InterpolateFunctionWithTangents(u, l.outTangent.scale(p), h, c.inTangent.scale(p), f) : this.vector3InterpolateFunction(u, h, f);
              switch (e.loopMode) {
                case n.ANIMATIONLOOPMODE_CYCLE:
                case n.ANIMATIONLOOPMODE_CONSTANT:
                case n.ANIMATIONLOOPMODE_YOYO:
                  return b;
                case n.ANIMATIONLOOPMODE_RELATIVE:
                  return b.add((e.offsetValue || qd).scale(e.repeatCount));
              }
              break;
            case n.ANIMATIONTYPE_VECTOR2:
              var T = d ? this.vector2InterpolateFunctionWithTangents(u, l.outTangent.scale(p), h, c.inTangent.scale(p), f) : this.vector2InterpolateFunction(u, h, f);
              switch (e.loopMode) {
                case n.ANIMATIONLOOPMODE_CYCLE:
                case n.ANIMATIONLOOPMODE_CONSTANT:
                case n.ANIMATIONLOOPMODE_YOYO:
                  return T;
                case n.ANIMATIONLOOPMODE_RELATIVE:
                  return T.add((e.offsetValue || Qd).scale(e.repeatCount));
              }
              break;
            case n.ANIMATIONTYPE_SIZE:
              switch (e.loopMode) {
                case n.ANIMATIONLOOPMODE_CYCLE:
                case n.ANIMATIONLOOPMODE_CONSTANT:
                case n.ANIMATIONLOOPMODE_YOYO:
                  return this.sizeInterpolateFunction(u, h, f);
                case n.ANIMATIONLOOPMODE_RELATIVE:
                  return this.sizeInterpolateFunction(u, h, f).add((e.offsetValue || Zd).scale(e.repeatCount));
              }
              break;
            case n.ANIMATIONTYPE_COLOR3:
              var S = d ? this.color3InterpolateFunctionWithTangents(u, l.outTangent.scale(p), h, c.inTangent.scale(p), f) : this.color3InterpolateFunction(u, h, f);
              switch (e.loopMode) {
                case n.ANIMATIONLOOPMODE_CYCLE:
                case n.ANIMATIONLOOPMODE_CONSTANT:
                case n.ANIMATIONLOOPMODE_YOYO:
                  return S;
                case n.ANIMATIONLOOPMODE_RELATIVE:
                  return S.add((e.offsetValue || Jd).scale(e.repeatCount));
              }
              break;
            case n.ANIMATIONTYPE_COLOR4:
              var E = d ? this.color4InterpolateFunctionWithTangents(u, l.outTangent.scale(p), h, c.inTangent.scale(p), f) : this.color4InterpolateFunction(u, h, f);
              switch (e.loopMode) {
                case n.ANIMATIONLOOPMODE_CYCLE:
                case n.ANIMATIONLOOPMODE_CONSTANT:
                case n.ANIMATIONLOOPMODE_YOYO:
                  return E;
                case n.ANIMATIONLOOPMODE_RELATIVE:
                  return E.add((e.offsetValue || $d).scale(e.repeatCount));
              }
              break;
            case n.ANIMATIONTYPE_MATRIX:
              switch (e.loopMode) {
                case n.ANIMATIONLOOPMODE_CYCLE:
                case n.ANIMATIONLOOPMODE_CONSTANT:
                case n.ANIMATIONLOOPMODE_YOYO:
                  return n.AllowMatricesInterpolation ? this.matrixInterpolateFunction(u, h, f, e.workValue) : u;
                case n.ANIMATIONLOOPMODE_RELATIVE:
                  return u;
              }
          }
          return 0;
        }
      }, n.prototype.matrixInterpolateFunction = function(t, e, i, r) {
        return n.AllowMatrixDecomposeForInterpolation ? r ? (B.DecomposeLerpToRef(t, e, i, r), r) : B.DecomposeLerp(t, e, i) : r ? (B.LerpToRef(t, e, i, r), r) : B.Lerp(t, e, i);
      }, n.prototype.clone = function() {
        var t = new n(this.name, this.targetPropertyPath.join("."), this.framePerSecond, this.dataType, this.loopMode);
        if (t.enableBlending = this.enableBlending, t.blendingSpeed = this.blendingSpeed, this._keys && t.setKeys(this._keys), this._ranges)
          for (var e in t._ranges = {}, this._ranges) {
            var i = this._ranges[e];
            i && (t._ranges[e] = i.clone());
          }
        return t;
      }, n.prototype.setKeys = function(t, e) {
        e === void 0 && (e = !1), this._keys = e ? t : t.slice(0);
      }, n.prototype.createKeyForFrame = function(t) {
        Eo.key = 0;
        var e = this._interpolate(t, Eo, !0);
        if (!e)
          return Eo.key === t ? Eo.key : Eo.key + 1;
        var i = { frame: t, value: e.clone ? e.clone() : e };
        return this._keys.splice(Eo.key + 1, 0, i), Eo.key + 1;
      }, n.prototype.serialize = function() {
        var t = {};
        t.name = this.name, t.property = this.targetProperty, t.framePerSecond = this.framePerSecond, t.dataType = this.dataType, t.loopBehavior = this.loopMode, t.enableBlending = this.enableBlending, t.blendingSpeed = this.blendingSpeed;
        var e = this.dataType;
        t.keys = [];
        for (var i = this.getKeys(), r = 0; r < i.length; r++) {
          var o = i[r], a = {};
          switch (a.frame = o.frame, e) {
            case n.ANIMATIONTYPE_FLOAT:
              a.values = [o.value], o.inTangent !== void 0 && a.values.push(o.inTangent), o.outTangent !== void 0 && (o.inTangent === void 0 && a.values.push(void 0), a.values.push(o.outTangent)), o.interpolation !== void 0 && (o.inTangent === void 0 && a.values.push(void 0), o.outTangent === void 0 && a.values.push(void 0), a.values.push(o.interpolation));
              break;
            case n.ANIMATIONTYPE_QUATERNION:
            case n.ANIMATIONTYPE_MATRIX:
            case n.ANIMATIONTYPE_VECTOR3:
            case n.ANIMATIONTYPE_COLOR3:
            case n.ANIMATIONTYPE_COLOR4:
              a.values = o.value.asArray(), o.inTangent != null && a.values.push(o.inTangent.asArray()), o.outTangent != null && (o.inTangent === void 0 && a.values.push(void 0), a.values.push(o.outTangent.asArray())), o.interpolation !== void 0 && (o.inTangent === void 0 && a.values.push(void 0), o.outTangent === void 0 && a.values.push(void 0), a.values.push(o.interpolation));
          }
          t.keys.push(a);
        }
        for (var s in t.ranges = [], this._ranges) {
          var l = this._ranges[s];
          if (l) {
            var c = {};
            c.name = s, c.from = l.from, c.to = l.to, t.ranges.push(c);
          }
        }
        return t;
      }, n._UniversalLerp = function(t, e, i) {
        var r = t.constructor;
        return r.Lerp ? r.Lerp(t, e, i) : r.Slerp ? r.Slerp(t, e, i) : t.toFixed ? t * (1 - i) + i * e : e;
      }, n.Parse = function(t) {
        var e, i, r = new n(t.name, t.property, t.framePerSecond, t.dataType, t.loopBehavior), o = t.dataType, a = [];
        for (t.enableBlending && (r.enableBlending = t.enableBlending), t.blendingSpeed && (r.blendingSpeed = t.blendingSpeed), i = 0; i < t.keys.length; i++) {
          var s = t.keys[i], l = void 0, c = void 0, u = void 0;
          switch (o) {
            case n.ANIMATIONTYPE_FLOAT:
              e = s.values[0], s.values.length >= 2 && (l = s.values[1]), s.values.length >= 3 && (c = s.values[2]), s.values.length >= 4 && (u = s.values[3]);
              break;
            case n.ANIMATIONTYPE_QUATERNION:
              if (e = oe.FromArray(s.values), s.values.length >= 8) {
                var h = oe.FromArray(s.values.slice(4, 8));
                h.equals(oe.Zero()) || (l = h);
              }
              if (s.values.length >= 12) {
                var d = oe.FromArray(s.values.slice(8, 12));
                d.equals(oe.Zero()) || (c = d);
              }
              s.values.length >= 13 && (u = s.values[12]);
              break;
            case n.ANIMATIONTYPE_MATRIX:
              e = B.FromArray(s.values), s.values.length >= 17 && (u = s.values[16]);
              break;
            case n.ANIMATIONTYPE_COLOR3:
              e = ne.FromArray(s.values), s.values[3] && (l = ne.FromArray(s.values[3])), s.values[4] && (c = ne.FromArray(s.values[4])), s.values[5] && (u = s.values[5]);
              break;
            case n.ANIMATIONTYPE_COLOR4:
              e = Ie.FromArray(s.values), s.values[4] && (l = Ie.FromArray(s.values[4])), s.values[5] && (c = Ie.FromArray(s.values[5])), s.values[6] && (u = Ie.FromArray(s.values[6]));
              break;
            case n.ANIMATIONTYPE_VECTOR3:
            default:
              e = v.FromArray(s.values), s.values[3] && (l = v.FromArray(s.values[3])), s.values[4] && (c = v.FromArray(s.values[4])), s.values[5] && (u = s.values[5]);
          }
          var p = {};
          p.frame = s.frame, p.value = e, l != null && (p.inTangent = l), c != null && (p.outTangent = c), u != null && (p.interpolation = u), a.push(p);
        }
        if (r.setKeys(a), t.ranges)
          for (i = 0; i < t.ranges.length; i++)
            e = t.ranges[i], r.createRange(e.name, e.from, e.to);
        return r;
      }, n.AppendSerializedAnimations = function(t, e) {
        Ne.AppendSerializedAnimations(t, e);
      }, n.ParseFromFileAsync = function(t, e) {
        var i = this;
        return new Promise(function(r, o) {
          var a = new _n();
          a.addEventListener("readystatechange", function() {
            if (a.readyState == 4)
              if (a.status == 200) {
                var s = JSON.parse(a.responseText);
                if (s.animations && (s = s.animations), s.length) {
                  for (var l = [], c = 0, u = s; c < u.length; c++) {
                    var h = u[c];
                    l.push(i.Parse(h));
                  }
                  r(l);
                } else
                  l = i.Parse(s), t && (l.name = t), r(l);
              } else
                o("Unable to load the animation");
          }), a.open("GET", e), a.send();
        });
      }, n.ParseFromSnippetAsync = function(t) {
        var e = this;
        return new Promise(function(i, r) {
          var o = new _n();
          o.addEventListener("readystatechange", function() {
            if (o.readyState == 4)
              if (o.status == 200) {
                var a = JSON.parse(JSON.parse(o.responseText).jsonPayload);
                if (a.animations) {
                  for (var s = [], l = 0, c = (d = JSON.parse(a.animations)).animations; l < c.length; l++) {
                    var u = c[l];
                    (h = e.Parse(u)).snippetId = t, s.push(h);
                  }
                  i(s);
                } else {
                  var h, d = JSON.parse(a.animation);
                  (h = e.Parse(d)).snippetId = t, i(h);
                }
              } else
                r("Unable to load the snippet " + t);
          }), o.open("GET", e.SnippetUrl + "/" + t.replace(/#/g, "/")), o.send();
        });
      }, n._UniqueIdGenerator = 0, n.AllowMatricesInterpolation = !1, n.AllowMatrixDecomposeForInterpolation = !0, n.SnippetUrl = _.SnippetUrl, n.ANIMATIONTYPE_FLOAT = 0, n.ANIMATIONTYPE_VECTOR3 = 1, n.ANIMATIONTYPE_QUATERNION = 2, n.ANIMATIONTYPE_MATRIX = 3, n.ANIMATIONTYPE_COLOR3 = 4, n.ANIMATIONTYPE_COLOR4 = 7, n.ANIMATIONTYPE_VECTOR2 = 5, n.ANIMATIONTYPE_SIZE = 6, n.ANIMATIONLOOPMODE_RELATIVE = 0, n.ANIMATIONLOOPMODE_CYCLE = 1, n.ANIMATIONLOOPMODE_CONSTANT = 2, n.ANIMATIONLOOPMODE_YOYO = 4, n.CreateFromSnippetAsync = n.ParseFromSnippetAsync, n;
    }();
    j("BABYLON.Animation", Je), oi._AnimationRangeFactory = function(n, t, e) {
      return new Zl(n, t, e);
    };
    var Gm = function(n) {
      function t(e, i, r, o, a, s, l, c) {
        a === void 0 && (a = 1e3);
        var u = n.call(this, e, s) || this;
        return u.duration = 1e3, u.onInterpolationDoneObservable = new H(), u.propertyPath = r, u.value = o, u.duration = a, u.stopOtherAnimations = l, u.onInterpolationDone = c, u._target = u._effectiveTarget = i, u;
      }
      return D(t, n), t.prototype._prepare = function() {
        this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath), this._property = this._getProperty(this.propertyPath);
      }, t.prototype.execute = function() {
        var e, i = this, r = this._actionManager.getScene(), o = [{ frame: 0, value: this._effectiveTarget[this._property] }, { frame: 100, value: this.value }];
        if (typeof this.value == "number")
          e = Je.ANIMATIONTYPE_FLOAT;
        else if (this.value instanceof ne)
          e = Je.ANIMATIONTYPE_COLOR3;
        else if (this.value instanceof v)
          e = Je.ANIMATIONTYPE_VECTOR3;
        else if (this.value instanceof B)
          e = Je.ANIMATIONTYPE_MATRIX;
        else {
          if (!(this.value instanceof oe))
            return void q.Warn("InterpolateValueAction: Unsupported type (" + typeof this.value + ")");
          e = Je.ANIMATIONTYPE_QUATERNION;
        }
        var a = new Je("InterpolateValueAction", this._property, 1e3 / this.duration * 100, e, Je.ANIMATIONLOOPMODE_CONSTANT);
        a.setKeys(o), this.stopOtherAnimations && r.stopAnimation(this._effectiveTarget), r.beginDirectAnimation(this._effectiveTarget, [a], 0, 100, !1, 1, function() {
          i.onInterpolationDoneObservable.notifyObservers(i), i.onInterpolationDone && i.onInterpolationDone();
        });
      }, t.prototype.serialize = function(e) {
        return n.prototype._serialize.call(this, { name: "InterpolateValueAction", properties: [wt._GetTargetProperty(this._target), { name: "propertyPath", value: this.propertyPath }, { name: "value", value: wt._SerializeValueAsString(this.value) }, { name: "duration", value: wt._SerializeValueAsString(this.duration) }, { name: "stopOtherAnimations", value: wt._SerializeValueAsString(this.stopOtherAnimations) || !1 }] }, e);
      }, t;
    }(wt);
    j("BABYLON.InterpolateValueAction", Gm);
    var zm = function() {
      function n(t, e, i, r) {
        var o = this;
        if (this._events = new Array(), this._currentFrame = 0, this._originalValue = new Array(), this._originalBlendValue = null, this._offsetsCache = {}, this._highLimitsCache = {}, this._stopped = !1, this._blendingFactor = 0, this._currentValue = null, this._currentActiveTarget = null, this._directTarget = null, this._targetPath = "", this._weight = 1, this._absoluteFrameOffset = 0, this._previousElapsedTime = 0, this._previousAbsoluteFrame = 0, this._targetIsArray = !1, this._animation = e, this._target = t, this._scene = i, this._host = r, this._activeTargets = [], e._runtimeAnimations.push(this), this._animationState = { key: 0, repeatCount: 0, loopMode: this._getCorrectLoopMode() }, this._animation.dataType === Je.ANIMATIONTYPE_MATRIX && (this._animationState.workValue = B.Zero()), this._keys = this._animation.getKeys(), this._minFrame = this._keys[0].frame, this._maxFrame = this._keys[this._keys.length - 1].frame, this._minValue = this._keys[0].value, this._maxValue = this._keys[this._keys.length - 1].value, this._minFrame !== 0) {
          var a = { frame: 0, value: this._minValue };
          this._keys.splice(0, 0, a);
        }
        if (this._target instanceof Array) {
          for (var s = 0, l = 0, c = this._target; l < c.length; l++) {
            var u = c[l];
            this._preparePath(u, s), this._getOriginalValues(s), s++;
          }
          this._targetIsArray = !0;
        } else
          this._preparePath(this._target), this._getOriginalValues(), this._targetIsArray = !1, this._directTarget = this._activeTargets[0];
        var h = e.getEvents();
        h && h.length > 0 && h.forEach(function(d) {
          o._events.push(d._clone());
        }), this._enableBlending = t && t.animationPropertiesOverride ? t.animationPropertiesOverride.enableBlending : this._animation.enableBlending;
      }
      return Object.defineProperty(n.prototype, "currentFrame", { get: function() {
        return this._currentFrame;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "weight", { get: function() {
        return this._weight;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "currentValue", { get: function() {
        return this._currentValue;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "targetPath", { get: function() {
        return this._targetPath;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "target", { get: function() {
        return this._currentActiveTarget;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isAdditive", { get: function() {
        return this._host && this._host.isAdditive;
      }, enumerable: !1, configurable: !0 }), n.prototype._preparePath = function(t, e) {
        e === void 0 && (e = 0);
        var i = this._animation.targetPropertyPath;
        if (i.length > 1) {
          for (var r = t[i[0]], o = 1; o < i.length - 1; o++)
            r = r[i[o]];
          this._targetPath = i[i.length - 1], this._activeTargets[e] = r;
        } else
          this._targetPath = i[0], this._activeTargets[e] = t;
      }, Object.defineProperty(n.prototype, "animation", { get: function() {
        return this._animation;
      }, enumerable: !1, configurable: !0 }), n.prototype.reset = function(t) {
        if (t === void 0 && (t = !1), t)
          if (this._target instanceof Array)
            for (var e = 0, i = 0, r = this._target; i < r.length; i++) {
              var o = r[i];
              this._originalValue[e] !== void 0 && this._setValue(o, this._activeTargets[e], this._originalValue[e], -1, e), e++;
            }
          else
            this._originalValue[0] !== void 0 && this._setValue(this._target, this._directTarget, this._originalValue[0], -1, 0);
        for (this._offsetsCache = {}, this._highLimitsCache = {}, this._currentFrame = 0, this._blendingFactor = 0, e = 0; e < this._events.length; e++)
          this._events[e].isDone = !1;
      }, n.prototype.isStopped = function() {
        return this._stopped;
      }, n.prototype.dispose = function() {
        var t = this._animation.runtimeAnimations.indexOf(this);
        t > -1 && this._animation.runtimeAnimations.splice(t, 1);
      }, n.prototype.setValue = function(t, e) {
        if (this._targetIsArray)
          for (var i = 0; i < this._target.length; i++) {
            var r = this._target[i];
            this._setValue(r, this._activeTargets[i], t, e, i);
          }
        else
          this._setValue(this._target, this._directTarget, t, e, 0);
      }, n.prototype._getOriginalValues = function(t) {
        var e;
        t === void 0 && (t = 0);
        var i = this._activeTargets[t];
        (e = i.getLocalMatrix && this._targetPath === "_matrix" ? i.getLocalMatrix() : i[this._targetPath]) && e.clone ? this._originalValue[t] = e.clone() : this._originalValue[t] = e;
      }, n.prototype._setValue = function(t, e, i, r, o) {
        if (this._currentActiveTarget = e, this._weight = r, this._enableBlending && this._blendingFactor <= 1) {
          if (!this._originalBlendValue) {
            var a = e[this._targetPath];
            a.clone ? this._originalBlendValue = a.clone() : this._originalBlendValue = a;
          }
          this._originalBlendValue.m ? Je.AllowMatrixDecomposeForInterpolation ? this._currentValue ? B.DecomposeLerpToRef(this._originalBlendValue, i, this._blendingFactor, this._currentValue) : this._currentValue = B.DecomposeLerp(this._originalBlendValue, i, this._blendingFactor) : this._currentValue ? B.LerpToRef(this._originalBlendValue, i, this._blendingFactor, this._currentValue) : this._currentValue = B.Lerp(this._originalBlendValue, i, this._blendingFactor) : this._currentValue = Je._UniversalLerp(this._originalBlendValue, i, this._blendingFactor);
          var s = t && t.animationPropertiesOverride ? t.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;
          this._blendingFactor += s;
        } else
          this._currentValue ? this._currentValue.copyFrom ? this._currentValue.copyFrom(i) : this._currentValue = i : i != null && i.clone ? this._currentValue = i.clone() : this._currentValue = i;
        r !== -1 ? this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[o]) : this._animationState.loopMode === Je.ANIMATIONLOOPMODE_RELATIVE ? this._currentValue.addToRef ? this._currentValue.addToRef(this._originalValue[o], e[this._targetPath]) : e[this._targetPath] = this._originalValue[o] + this._currentValue : e[this._targetPath] = this._currentValue, t.markAsDirty && t.markAsDirty(this._animation.targetProperty);
      }, n.prototype._getCorrectLoopMode = function() {
        return this._target && this._target.animationPropertiesOverride ? this._target.animationPropertiesOverride.loopMode : this._animation.loopMode;
      }, n.prototype.goToFrame = function(t) {
        var e = this._animation.getKeys();
        t < e[0].frame ? t = e[0].frame : t > e[e.length - 1].frame && (t = e[e.length - 1].frame);
        var i = this._events;
        if (i.length)
          for (var r = 0; r < i.length; r++)
            i[r].onlyOnce || (i[r].isDone = i[r].frame < t);
        this._currentFrame = t;
        var o = this._animation._interpolate(t, this._animationState);
        this.setValue(o, -1);
      }, n.prototype._prepareForSpeedRatioChange = function(t) {
        var e = this._previousElapsedTime * (this._animation.framePerSecond * t) / 1e3;
        this._absoluteFrameOffset = this._previousAbsoluteFrame - e;
      }, n.prototype.animate = function(t, e, i, r, o, a) {
        a === void 0 && (a = -1);
        var s = this._animation, l = s.targetPropertyPath;
        if (!l || l.length < 1)
          return this._stopped = !0, !1;
        var c = !0;
        (e < this._minFrame || e > this._maxFrame) && (e = this._minFrame), (i < this._minFrame || i > this._maxFrame) && (i = this._maxFrame);
        var u, h, d = i - e, p = t * (s.framePerSecond * o) / 1e3 + this._absoluteFrameOffset, f = 0;
        if (r && this._animationState.loopMode === Je.ANIMATIONLOOPMODE_YOYO) {
          var m = (p - e) / d;
          p = Math.abs(Math.sin(m * Math.PI)) * d + e;
        }
        if (this._previousElapsedTime = t, this._previousAbsoluteFrame = p, !r && i >= e && p >= d)
          c = !1, f = s._getKeyValue(this._maxValue);
        else if (!r && e >= i && p <= d)
          c = !1, f = s._getKeyValue(this._minValue);
        else if (this._animationState.loopMode !== Je.ANIMATIONLOOPMODE_CYCLE) {
          var g = i.toString() + e.toString();
          if (!this._offsetsCache[g]) {
            this._animationState.repeatCount = 0, this._animationState.loopMode = Je.ANIMATIONLOOPMODE_CYCLE;
            var y = s._interpolate(e, this._animationState), b = s._interpolate(i, this._animationState);
            switch (this._animationState.loopMode = this._getCorrectLoopMode(), s.dataType) {
              case Je.ANIMATIONTYPE_FLOAT:
                this._offsetsCache[g] = b - y;
                break;
              case Je.ANIMATIONTYPE_QUATERNION:
              case Je.ANIMATIONTYPE_VECTOR3:
              case Je.ANIMATIONTYPE_VECTOR2:
              case Je.ANIMATIONTYPE_SIZE:
              case Je.ANIMATIONTYPE_COLOR3:
                this._offsetsCache[g] = b.subtract(y);
            }
            this._highLimitsCache[g] = b;
          }
          f = this._highLimitsCache[g], u = this._offsetsCache[g];
        }
        if (u === void 0)
          switch (s.dataType) {
            case Je.ANIMATIONTYPE_FLOAT:
              u = 0;
              break;
            case Je.ANIMATIONTYPE_QUATERNION:
              u = Kd;
              break;
            case Je.ANIMATIONTYPE_VECTOR3:
              u = qd;
              break;
            case Je.ANIMATIONTYPE_VECTOR2:
              u = Qd;
              break;
            case Je.ANIMATIONTYPE_SIZE:
              u = Zd;
              break;
            case Je.ANIMATIONTYPE_COLOR3:
              u = Jd;
              break;
            case Je.ANIMATIONTYPE_COLOR4:
              u = $d;
          }
        if (this._host && this._host.syncRoot) {
          var T = this._host.syncRoot;
          h = e + d * ((T.masterFrame - T.fromFrame) / (T.toFrame - T.fromFrame));
        } else
          h = p > 0 && e > i || p < 0 && e < i ? c && d !== 0 ? i + p % d : e : c && d !== 0 ? e + p % d : i;
        var S = this._events;
        if (o > 0 && this.currentFrame > h || o < 0 && this.currentFrame < h) {
          this._onLoop();
          for (var E = 0; E < S.length; E++)
            S[E].onlyOnce || (S[E].isDone = !1);
          this._animationState.key = o > 0 ? 0 : s.getKeys().length - 1;
        }
        this._currentFrame = h, this._animationState.repeatCount = d === 0 ? 0 : p / d >> 0, this._animationState.highLimitValue = f, this._animationState.offsetValue = u;
        var A = s._interpolate(h, this._animationState);
        if (this.setValue(A, a), S.length) {
          for (E = 0; E < S.length; E++)
            if (d > 0 && h >= S[E].frame && S[E].frame >= e || d < 0 && h <= S[E].frame && S[E].frame <= e) {
              var R = S[E];
              R.isDone || (R.onlyOnce && (S.splice(E, 1), E--), R.isDone = !0, R.action(h));
            }
        }
        return c || (this._stopped = !0), c;
      }, n;
    }();
    function Gi() {
      return typeof window < "u";
    }
    function us() {
      return typeof navigator < "u";
    }
    function hs() {
      return typeof document < "u";
    }
    function Jl(n) {
      for (var t = "", e = n.firstChild; e; )
        e.nodeType === 3 && (t += e.textContent), e = e.nextSibling;
      return t;
    }
    var li, BA = { IsWindowObjectExist: Gi, IsNavigatorAvailable: us, IsDocumentAvailable: hs, GetDOMTextContent: Jl }, It = function() {
      function n() {
      }
      return Object.defineProperty(n, "Now", { get: function() {
        return Gi() && window.performance && window.performance.now ? window.performance.now() : Date.now();
      }, enumerable: !1, configurable: !0 }), n;
    }(), tl = function() {
      function n() {
      }
      return n.FilesToLoad = {}, n;
    }(), Wm = function() {
      function n() {
      }
      return n.ExponentialBackoff = function(t, e) {
        return t === void 0 && (t = 3), e === void 0 && (e = 500), function(i, r, o) {
          return r.status !== 0 || o >= t || i.indexOf("file:") !== -1 ? -1 : Math.pow(2, o) * e;
        };
      }, n;
    }(), il = function(n) {
      function t() {
        return n !== null && n.apply(this, arguments) || this;
      }
      return D(t, n), t._setPrototypeOf = Object.setPrototypeOf || function(e, i) {
        return e.__proto__ = i, e;
      }, t;
    }(Error), ta = { MeshInvalidPositionsError: 0, UnsupportedTextureError: 1e3, GLTFLoaderUnexpectedMagicError: 2e3, SceneLoaderError: 3e3, LoadFileError: 4e3, RequestFileError: 4001, ReadFileError: 4002 }, ia = function(n) {
      function t(e, i, r) {
        var o = n.call(this, e) || this;
        return o.errorCode = i, o.innerError = r, o.name = "RuntimeError", il._setPrototypeOf(o, t.prototype), o;
      }
      return D(t, n), t;
    }(il), Hm = function(n, t) {
      return n.endsWith(t);
    }, Xm = function(n, t) {
      return !!n && n.startsWith(t);
    }, ep = function(n) {
      if (typeof TextDecoder < "u")
        return new TextDecoder().decode(n);
      for (var t = "", e = 0; e < n.byteLength; e++)
        t += String.fromCharCode(n[e]);
      return t;
    }, $l = function(n) {
      for (var t, e, i, r, o, a, s, l = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", c = "", u = 0, h = ArrayBuffer.isView(n) ? new Uint8Array(n.buffer, n.byteOffset, n.byteLength) : new Uint8Array(n); u < h.length; )
        r = (t = h[u++]) >> 2, o = (3 & t) << 4 | (e = u < h.length ? h[u++] : Number.NaN) >> 4, a = (15 & e) << 2 | (i = u < h.length ? h[u++] : Number.NaN) >> 6, s = 63 & i, isNaN(e) ? a = s = 64 : isNaN(i) && (s = 64), c += l.charAt(r) + l.charAt(o) + l.charAt(a) + l.charAt(s);
      return c;
    }, Du = function(n) {
      return atob(n);
    }, Nu = function(n) {
      for (var t = Du(n), e = t.length, i = new Uint8Array(new ArrayBuffer(e)), r = 0; r < e; r++)
        i[r] = t.charCodeAt(r);
      return i.buffer;
    }, jm = function(n, t) {
      for (var e = String(n); e.length < t; )
        e = "0" + e;
      return e;
    }, UA = { EndsWith: Hm, StartsWith: Xm, Decode: ep, EncodeArrayBufferToBase64: $l, DecodeBase64ToString: Du, DecodeBase64ToBinary: Nu, PadNumber: jm }, Fu = function() {
      function n() {
        this.children = [];
      }
      return n.prototype.isValid = function(t) {
        return !0;
      }, n.prototype.process = function(t, e) {
        var i, r, o, a, s, l, c, u = "";
        if (this.line) {
          var h = this.line, d = e.processor;
          if (d) {
            d.lineProcessor && (h = d.lineProcessor(h, e.isFragment, e.processingContext));
            var p = (r = (i = e.processor) === null || i === void 0 ? void 0 : i.attributeKeywordName) !== null && r !== void 0 ? r : "attribute", f = e.isFragment && (!((o = e.processor) === null || o === void 0) && o.varyingFragmentKeywordName) ? (a = e.processor) === null || a === void 0 ? void 0 : a.varyingFragmentKeywordName : !e.isFragment && (!((s = e.processor) === null || s === void 0) && s.varyingVertexKeywordName) ? (l = e.processor) === null || l === void 0 ? void 0 : l.varyingVertexKeywordName : "varying";
            !e.isFragment && d.attributeProcessor && this.line.startsWith(p) ? h = d.attributeProcessor(this.line, t, e.processingContext) : d.varyingProcessor && (!((c = d.varyingCheck) === null || c === void 0) && c.call(d, this.line, e.isFragment) || !d.varyingCheck && this.line.startsWith(f)) ? h = d.varyingProcessor(this.line, e.isFragment, t, e.processingContext) : d.uniformProcessor && d.uniformRegexp && d.uniformRegexp.test(this.line) ? e.lookForClosingBracketForUniformBuffer || (h = d.uniformProcessor(this.line, e.isFragment, t, e.processingContext)) : d.uniformBufferProcessor && d.uniformBufferRegexp && d.uniformBufferRegexp.test(this.line) ? e.lookForClosingBracketForUniformBuffer || (h = d.uniformBufferProcessor(this.line, e.isFragment, e.processingContext), e.lookForClosingBracketForUniformBuffer = !0) : d.textureProcessor && d.textureRegexp && d.textureRegexp.test(this.line) ? h = d.textureProcessor(this.line, e.isFragment, t, e.processingContext) : (d.uniformProcessor || d.uniformBufferProcessor) && this.line.startsWith("uniform") && !e.lookForClosingBracketForUniformBuffer && (/uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/.test(this.line) ? d.uniformProcessor && (h = d.uniformProcessor(this.line, e.isFragment, t, e.processingContext)) : d.uniformBufferProcessor && (h = d.uniformBufferProcessor(this.line, e.isFragment, e.processingContext), e.lookForClosingBracketForUniformBuffer = !0)), e.lookForClosingBracketForUniformBuffer && this.line.indexOf("}") !== -1 && (e.lookForClosingBracketForUniformBuffer = !1, d.endOfUniformBufferProcessor && (h = d.endOfUniformBufferProcessor(this.line, e.isFragment, e.processingContext)));
          }
          u += h + `
`;
        }
        return this.children.forEach(function(m) {
          u += m.process(t, e);
        }), this.additionalDefineKey && (t[this.additionalDefineKey] = this.additionalDefineValue || "true"), u;
      }, n;
    }(), m1 = function() {
      function n() {
        this._lines = [];
      }
      return Object.defineProperty(n.prototype, "currentLine", { get: function() {
        return this._lines[this.lineIndex];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "canRead", { get: function() {
        return this.lineIndex < this._lines.length - 1;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "lines", { set: function(t) {
        this._lines.length = 0;
        for (var e = 0, i = t; e < i.length; e++) {
          var r = i[e];
          if (r && r !== "\r")
            if (r[0] !== "#") {
              var o = r.trim();
              if (o)
                if (o.startsWith("//"))
                  this._lines.push(r);
                else {
                  var a = o.indexOf(";");
                  if (a === -1)
                    this._lines.push(o);
                  else if (a === o.length - 1)
                    o.length > 1 && this._lines.push(o);
                  else
                    for (var s = r.split(";"), l = 0; l < s.length; l++) {
                      var c = s[l];
                      c && (c = c.trim()) && this._lines.push(c + (l !== s.length - 1 ? ";" : ""));
                    }
                }
            } else
              this._lines.push(r);
        }
      }, enumerable: !1, configurable: !0 }), n;
    }(), Ym = function(n) {
      function t() {
        return n !== null && n.apply(this, arguments) || this;
      }
      return D(t, n), t.prototype.process = function(e, i) {
        for (var r = 0; r < this.children.length; r++) {
          var o = this.children[r];
          if (o.isValid(e))
            return o.process(e, i);
        }
        return "";
      }, t;
    }(Fu), g1 = function(n) {
      function t() {
        return n !== null && n.apply(this, arguments) || this;
      }
      return D(t, n), t.prototype.isValid = function(e) {
        return this.testExpression.isTrue(e);
      }, t;
    }(Fu), Lu = function() {
      function n() {
      }
      return n.prototype.isTrue = function(t) {
        return !0;
      }, n.postfixToInfix = function(t) {
        for (var e = [], i = 0, r = t; i < r.length; i++) {
          var o = r[i];
          if (n._OperatorPriority[o] === void 0)
            e.push(o);
          else {
            var a = e[e.length - 1], s = e[e.length - 2];
            e.length -= 2, e.push("(".concat(s).concat(o).concat(a, ")"));
          }
        }
        return e[e.length - 1];
      }, n.infixToPostfix = function(t) {
        var e = n._InfixToPostfixCache.get(t);
        if (e)
          return e.accessTime = Date.now(), e.result;
        if (!(t.includes("&&") || t.includes("||") || t.includes(")") || t.includes("(")))
          return [t];
        for (var i = [], r = -1, o = function() {
          (u = u.trim()) !== "" && (i.push(u), u = "");
        }, a = function(p) {
          r < n._Stack.length - 1 && (n._Stack[++r] = p);
        }, s = function() {
          return n._Stack[r];
        }, l = function() {
          return r === -1 ? "!!INVALID EXPRESSION!!" : n._Stack[r--];
        }, c = 0, u = ""; c < t.length; ) {
          var h = t.charAt(c), d = c < t.length - 1 ? t.substr(c, 2) : "";
          if (h === "(")
            u = "", a(h);
          else if (h === ")") {
            for (o(); r !== -1 && s() !== "("; )
              i.push(l());
            l();
          } else if (n._OperatorPriority[d] > 1) {
            for (o(); r !== -1 && n._OperatorPriority[s()] >= n._OperatorPriority[d]; )
              i.push(l());
            a(d), c++;
          } else
            u += h;
          c++;
        }
        for (o(); r !== -1; )
          s() === "(" ? l() : i.push(l());
        return n._InfixToPostfixCache.size >= n.InfixToPostfixCacheLimitSize && n.ClearCache(), n._InfixToPostfixCache.set(t, { result: i, accessTime: Date.now() }), i;
      }, n.ClearCache = function() {
        for (var t = Array.from(n._InfixToPostfixCache.entries()).sort(function(i, r) {
          return i[1].accessTime - r[1].accessTime;
        }), e = 0; e < n.InfixToPostfixCacheCleanupSize; e++)
          n._InfixToPostfixCache.delete(t[e][0]);
      }, n.InfixToPostfixCacheLimitSize = 5e4, n.InfixToPostfixCacheCleanupSize = 25e3, n._InfixToPostfixCache = /* @__PURE__ */ new Map(), n._OperatorPriority = { ")": 0, "(": 1, "||": 2, "&&": 3 }, n._Stack = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""], n;
    }(), tp = function(n) {
      function t(e, i) {
        i === void 0 && (i = !1);
        var r = n.call(this) || this;
        return r.define = e, r.not = i, r;
      }
      return D(t, n), t.prototype.isTrue = function(e) {
        var i = e[this.define] !== void 0;
        return this.not && (i = !i), i;
      }, t;
    }(Lu), v1 = function(n) {
      function t() {
        return n !== null && n.apply(this, arguments) || this;
      }
      return D(t, n), t.prototype.isTrue = function(e) {
        return this.leftOperand.isTrue(e) || this.rightOperand.isTrue(e);
      }, t;
    }(Lu), y1 = function(n) {
      function t() {
        return n !== null && n.apply(this, arguments) || this;
      }
      return D(t, n), t.prototype.isTrue = function(e) {
        return this.leftOperand.isTrue(e) && this.rightOperand.isTrue(e);
      }, t;
    }(Lu), b1 = function(n) {
      function t(e, i, r) {
        var o = n.call(this) || this;
        return o.define = e, o.operand = i, o.testValue = r, o;
      }
      return D(t, n), t.prototype.isTrue = function(e) {
        var i = e[this.define];
        i === void 0 && (i = this.define);
        var r = !1, o = parseInt(i), a = parseInt(this.testValue);
        switch (this.operand) {
          case ">":
            r = o > a;
            break;
          case "<":
            r = o < a;
            break;
          case "<=":
            r = o <= a;
            break;
          case ">=":
            r = o >= a;
            break;
          case "==":
            r = o === a;
            break;
          case "!=":
            r = o !== a;
        }
        return r;
      }, t;
    }(Lu);
    (function(n) {
      n[n.GLSL = 0] = "GLSL", n[n.WGSL = 1] = "WGSL";
    })(li || (li = {}));
    var ut, T1 = /defined\s*?\((.+?)\)/g, Km = /defined\s*?\[(.+?)\]/g, E1 = /#include\s?<(.+)>(\((.*)\))*(\[(.*)\])*/g, S1 = /__decl__/, VA = /light\{X\}.(\w*)/g, kA = /\{X\}/g, ip = [], La = function() {
      function n() {
      }
      return n.Initialize = function(t) {
        t.processor && t.processor.initializeShaders && t.processor.initializeShaders(t.processingContext);
      }, n.Process = function(t, e, i, r) {
        var o, a = this;
        !((o = e.processor) === null || o === void 0) && o.preProcessShaderCode && (t = e.processor.preProcessShaderCode(t, e.isFragment)), this._ProcessIncludes(t, e, function(s) {
          e.processCodeAfterIncludes && (s = e.processCodeAfterIncludes(e.isFragment ? "fragment" : "vertex", s));
          var l = a._ProcessShaderConversion(s, e, r);
          i(l, s);
        });
      }, n.PreProcess = function(t, e, i, r) {
        var o, a = this;
        !((o = e.processor) === null || o === void 0) && o.preProcessShaderCode && (t = e.processor.preProcessShaderCode(t, e.isFragment)), this._ProcessIncludes(t, e, function(s) {
          e.processCodeAfterIncludes && (s = e.processCodeAfterIncludes(e.isFragment ? "fragment" : "vertex", s));
          var l = a._ApplyPreProcessing(s, e, r);
          i(l, s);
        });
      }, n.Finalize = function(t, e, i) {
        return i.processor && i.processor.finalizeShaders ? i.processor.finalizeShaders(t, e, i.processingContext) : { vertexCode: t, fragmentCode: e };
      }, n._ProcessPrecision = function(t, e) {
        var i;
        if (!((i = e.processor) === null || i === void 0) && i.noPrecision)
          return t;
        var r = e.shouldUseHighPrecisionShader;
        return t.indexOf("precision highp float") === -1 ? t = r ? `precision highp float;
` + t : `precision mediump float;
` + t : r || (t = t.replace("precision highp float", "precision mediump float")), t;
      }, n._ExtractOperation = function(t) {
        var e = /defined\((.+)\)/.exec(t);
        if (e && e.length)
          return new tp(e[1].trim(), t[0] === "!");
        for (var i = "", r = 0, o = 0, a = ["==", "!=", ">=", "<=", "<", ">"]; o < a.length && (i = a[o], !((r = t.indexOf(i)) > -1)); o++)
          ;
        if (r === -1)
          return new tp(t);
        var s = t.substring(0, r).trim(), l = t.substring(r + i.length).trim();
        return new b1(s, i, l);
      }, n._BuildSubExpression = function(t) {
        t = t.replace(T1, "defined[$1]");
        for (var e = [], i = 0, r = Lu.infixToPostfix(t); i < r.length; i++) {
          var o = r[i];
          if (o !== "||" && o !== "&&")
            e.push(o);
          else if (e.length >= 2) {
            var a = e[e.length - 1], s = e[e.length - 2];
            e.length -= 2;
            var l = o == "&&" ? new y1() : new v1();
            typeof a == "string" && (a = a.replace(Km, "defined($1)")), typeof s == "string" && (s = s.replace(Km, "defined($1)")), l.leftOperand = typeof s == "string" ? this._ExtractOperation(s) : s, l.rightOperand = typeof a == "string" ? this._ExtractOperation(a) : a, e.push(l);
          }
        }
        var c = e[e.length - 1];
        return typeof c == "string" && (c = c.replace(Km, "defined($1)")), typeof c == "string" ? this._ExtractOperation(c) : c;
      }, n._BuildExpression = function(t, e) {
        var i = new g1(), r = t.substring(0, e), o = t.substring(e);
        return o = o.substring(0, (o.indexOf("//") + 1 || o.length + 1) - 1).trim(), i.testExpression = r === "#ifdef" ? new tp(o) : r === "#ifndef" ? new tp(o, !0) : this._BuildSubExpression(o), i;
      }, n._MoveCursorWithinIf = function(t, e, i) {
        for (var r = t.currentLine; this._MoveCursor(t, i); ) {
          var o = (r = t.currentLine).substring(0, 5).toLowerCase();
          if (o === "#else") {
            var a = new Fu();
            return e.children.push(a), void this._MoveCursor(t, a);
          }
          if (o === "#elif") {
            var s = this._BuildExpression(r, 5);
            e.children.push(s), i = s;
          }
        }
      }, n._MoveCursor = function(t, e) {
        for (; t.canRead; ) {
          t.lineIndex++;
          var i = t.currentLine;
          if (i.indexOf("#") >= 0) {
            var r = n._MoveCursorRegex.exec(i);
            if (r && r.length) {
              switch (r[0]) {
                case "#ifdef":
                  var o = new Ym();
                  e.children.push(o);
                  var a = this._BuildExpression(i, 6);
                  o.children.push(a), this._MoveCursorWithinIf(t, o, a);
                  break;
                case "#else":
                case "#elif":
                  return !0;
                case "#endif":
                  return !1;
                case "#ifndef":
                  o = new Ym(), e.children.push(o), a = this._BuildExpression(i, 7), o.children.push(a), this._MoveCursorWithinIf(t, o, a);
                  break;
                case "#if":
                  o = new Ym(), a = this._BuildExpression(i, 3), e.children.push(o), o.children.push(a), this._MoveCursorWithinIf(t, o, a);
              }
              continue;
            }
          }
          var s = new Fu();
          if (s.line = i, e.children.push(s), i[0] === "#" && i[1] === "d") {
            var l = i.replace(";", "").split(" ");
            s.additionalDefineKey = l[1], l.length === 3 && (s.additionalDefineValue = l[2]);
          }
        }
        return !1;
      }, n._EvaluatePreProcessors = function(t, e, i) {
        var r = new Fu(), o = new m1();
        return o.lineIndex = -1, o.lines = t.split(`
`), this._MoveCursor(o, r), r.process(e, i);
      }, n._PreparePreProcessors = function(t, e) {
        for (var i, r = {}, o = 0, a = t.defines; o < a.length; o++) {
          var s = a[o].replace("#define", "").replace(";", "").trim().split(" ");
          r[s[0]] = s.length > 1 ? s[1] : "";
        }
        return ((i = t.processor) === null || i === void 0 ? void 0 : i.shaderLanguage) === li.GLSL && (r.GL_ES = "true"), r.__VERSION__ = t.version, r[t.platformName] = "true", e._getGlobalDefines(r), r;
      }, n._ProcessShaderConversion = function(t, e, i) {
        var r = this._ProcessPrecision(t, e);
        if (!e.processor || e.processor.shaderLanguage === li.GLSL && r.indexOf("#version 3") !== -1 && (r = r.replace("#version 300 es", ""), !e.processor.parseGLES3))
          return r;
        var o = e.defines, a = this._PreparePreProcessors(e, i);
        return e.processor.preProcessor && (r = e.processor.preProcessor(r, o, e.isFragment, e.processingContext)), r = this._EvaluatePreProcessors(r, a, e), e.processor.postProcessor && (r = e.processor.postProcessor(r, o, e.isFragment, e.processingContext, i)), i._features.needShaderCodeInlining && (r = i.inlineShaderCode(r)), r;
      }, n._ApplyPreProcessing = function(t, e, i) {
        var r, o, a = t, s = e.defines, l = this._PreparePreProcessors(e, i);
        return !((r = e.processor) === null || r === void 0) && r.preProcessor && (a = e.processor.preProcessor(a, s, e.isFragment, e.processingContext)), a = this._EvaluatePreProcessors(a, l, e), !((o = e.processor) === null || o === void 0) && o.postProcessor && (a = e.processor.postProcessor(a, s, e.isFragment, e.processingContext, i)), i._features.needShaderCodeInlining && (a = i.inlineShaderCode(a)), a;
      }, n._ProcessIncludes = function(t, e, i) {
        var r, o = this;
        for (ip.length = 0; (r = E1.exec(t)) !== null; )
          ip.push(r);
        for (var a = String(t), s = [t], l = !1, c = function(p) {
          var f = p[1];
          if (f.indexOf("__decl__") !== -1 && (f = f.replace(S1, ""), e.supportsUniformBuffers && (f = f.replace("Vertex", "Ubo").replace("Fragment", "Ubo")), f += "Declaration"), !e.includesShadersStore[f]) {
            var m = e.shadersRepository + "ShadersInclude/" + f + ".fx";
            return n._FileToolsLoadFile(m, function(Y) {
              e.includesShadersStore[f] = Y, o._ProcessIncludes(s.join(""), e, i);
            }), { value: void 0 };
          }
          var g = e.includesShadersStore[f];
          if (p[2])
            for (var y = p[3].split(","), b = 0; b < y.length; b += 2) {
              var T = new RegExp(y[b], "g"), S = y[b + 1];
              g = g.replace(T, S);
            }
          if (p[4]) {
            var E = p[5];
            if (E.indexOf("..") !== -1) {
              var A = E.split(".."), R = parseInt(A[0]), C = parseInt(A[1]), L = g.slice(0);
              g = "", isNaN(C) && (C = e.indexParameters[A[1]]);
              for (var I = R; I < C; I++)
                e.supportsUniformBuffers || (L = L.replace(VA, function(Y, ee) {
                  return ee + "{X}";
                })), g += L.replace(kA, I.toString()) + `
`;
            } else
              e.supportsUniformBuffers || (g = g.replace(VA, function(Y, ee) {
                return ee + "{X}";
              })), g = g.replace(kA, E);
          }
          for (var O = [], w = 0, z = s; w < z.length; w++) {
            var V = z[w].split(p[0]);
            for (I = 0; I < V.length - 1; I++)
              O.push(V[I]), O.push(g);
            O.push(V[V.length - 1]);
          }
          s = O, l = l || g.indexOf("#include<") >= 0 || g.indexOf("#include <") >= 0;
        }, u = 0, h = ip; u < h.length; u++) {
          var d = c(h[u]);
          if (typeof d == "object")
            return d.value;
        }
        ip.length = 0, a = s.join(""), l ? this._ProcessIncludes(a.toString(), e, i) : i(a);
      }, n._FileToolsLoadFile = function(t, e, i, r, o, a) {
        throw et("FileTools");
      }, n._MoveCursorRegex = /(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/, n;
    }(), re = function() {
      function n() {
      }
      return n.GetShadersRepository = function(t) {
        return t === void 0 && (t = li.GLSL), t === li.GLSL ? n.ShadersRepository : n.ShadersRepositoryWGSL;
      }, n.GetShadersStore = function(t) {
        return t === void 0 && (t = li.GLSL), t === li.GLSL ? n.ShadersStore : n.ShadersStoreWGSL;
      }, n.GetIncludesShadersStore = function(t) {
        return t === void 0 && (t = li.GLSL), t === li.GLSL ? n.IncludesShadersStore : n.IncludesShadersStoreWGSL;
      }, n.ShadersRepository = "src/Shaders/", n.ShadersStore = {}, n.IncludesShadersStore = {}, n.ShadersRepositoryWGSL = "src/ShadersWGSL/", n.ShadersStoreWGSL = {}, n.IncludesShadersStoreWGSL = {}, n;
    }(), Jt = function() {
      function n(t, e, i, r, o, a, s, l, c, u, h, d) {
        var p, f, m;
        if (r === void 0 && (r = null), a === void 0 && (a = null), s === void 0 && (s = null), l === void 0 && (l = null), c === void 0 && (c = null), h === void 0 && (h = ""), d === void 0 && (d = li.GLSL), this.name = null, this.defines = "", this.onCompiled = null, this.onError = null, this.onBind = null, this.uniqueId = 0, this.onCompileObservable = new H(), this.onErrorObservable = new H(), this._onBindObservable = null, this._wasPreviouslyReady = !1, this._forceRebindOnNextCall = !1, this._wasPreviouslyUsingInstances = null, this._isDisposed = !1, this._bonesComputationForcedToCPU = !1, this._uniformBuffersNames = {}, this._multiTarget = !1, this._samplers = {}, this._isReady = !1, this._compilationError = "", this._allFallbacksProcessed = !1, this._uniforms = {}, this._key = "", this._fallbacks = null, this._vertexSourceCodeOverride = "", this._fragmentSourceCodeOverride = "", this._transformFeedbackVaryings = null, this._pipelineContext = null, this._vertexSourceCode = "", this._fragmentSourceCode = "", this._vertexSourceCodeBeforeMigration = "", this._fragmentSourceCodeBeforeMigration = "", this._rawVertexSourceCode = "", this._rawFragmentSourceCode = "", this._processCodeAfterIncludes = void 0, this._processFinalCode = null, this.name = t, this._key = h, e.attributes) {
          var g = e;
          if (this._engine = i, this._attributesNames = g.attributes, this._uniformsNames = g.uniformsNames.concat(g.samplers), this._samplerList = g.samplers.slice(), this.defines = g.defines, this.onError = g.onError, this.onCompiled = g.onCompiled, this._fallbacks = g.fallbacks, this._indexParameters = g.indexParameters, this._transformFeedbackVaryings = g.transformFeedbackVaryings || null, this._multiTarget = !!g.multiTarget, this._shaderLanguage = (p = g.shaderLanguage) !== null && p !== void 0 ? p : li.GLSL, g.uniformBuffersNames) {
            this._uniformBuffersNamesList = g.uniformBuffersNames.slice();
            for (var y = 0; y < g.uniformBuffersNames.length; y++)
              this._uniformBuffersNames[g.uniformBuffersNames[y]] = y;
          }
          this._processFinalCode = (f = g.processFinalCode) !== null && f !== void 0 ? f : null, this._processCodeAfterIncludes = (m = g.processCodeAfterIncludes) !== null && m !== void 0 ? m : void 0;
        } else
          this._engine = o, this.defines = a ?? "", this._uniformsNames = i.concat(r), this._samplerList = r ? r.slice() : [], this._attributesNames = e, this._uniformBuffersNamesList = [], this._shaderLanguage = d, this.onError = c, this.onCompiled = l, this._indexParameters = u, this._fallbacks = s;
        this._attributeLocationByName = {}, this.uniqueId = n._UniqueIdSeed++, this._processShaderCode();
      }
      return Object.defineProperty(n, "ShadersRepository", { get: function() {
        return re.ShadersRepository;
      }, set: function(t) {
        re.ShadersRepository = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "onBindObservable", { get: function() {
        return this._onBindObservable || (this._onBindObservable = new H()), this._onBindObservable;
      }, enumerable: !1, configurable: !0 }), n.prototype._processShaderCode = function(t, e) {
        var i, r, o = this;
        t === void 0 && (t = null), e === void 0 && (e = !1);
        var a = this.name, s = Gi() ? this._engine.getHostDocument() : null;
        a.vertexSource ? i = "source:" + a.vertexSource : a.vertexElement ? (i = s ? s.getElementById(a.vertexElement) : null) || (i = a.vertexElement) : i = a.vertex || a, a.fragmentSource ? r = "source:" + a.fragmentSource : a.fragmentElement ? (r = s ? s.getElementById(a.fragmentElement) : null) || (r = a.fragmentElement) : r = a.fragment || a, this._processingContext = this._engine._getShaderProcessingContext(this._shaderLanguage);
        var l = { defines: this.defines.split(`
`), indexParameters: this._indexParameters, isFragment: !1, shouldUseHighPrecisionShader: this._engine._shouldUseHighPrecisionShader, processor: t ?? this._engine._getShaderProcessor(this._shaderLanguage), supportsUniformBuffers: this._engine.supportsUniformBuffers, shadersRepository: re.GetShadersRepository(this._shaderLanguage), includesShadersStore: re.GetIncludesShadersStore(this._shaderLanguage), version: (100 * this._engine.version).toString(), platformName: this._engine.shaderPlatformName, processingContext: this._processingContext, isNDCHalfZRange: this._engine.isNDCHalfZRange, useReverseDepthBuffer: this._engine.useReverseDepthBuffer, processCodeAfterIncludes: this._processCodeAfterIncludes }, c = [void 0, void 0], u = function() {
          if (c[0] && c[1]) {
            l.isFragment = !0;
            var h = c[0], d = c[1];
            La.Process(d, l, function(p, f) {
              o._fragmentSourceCodeBeforeMigration = f, o._processFinalCode && (p = o._processFinalCode("fragment", p));
              var m = La.Finalize(h, p, l);
              l = null, o._useFinalCode(m.vertexCode, m.fragmentCode, a, e);
            }, o._engine);
          }
        };
        this._loadShader(i, "Vertex", "", function(h) {
          La.Initialize(l), La.Process(h, l, function(d, p) {
            o._rawVertexSourceCode = h, o._vertexSourceCodeBeforeMigration = p, o._processFinalCode && (d = o._processFinalCode("vertex", d)), c[0] = d, u();
          }, o._engine);
        }), this._loadShader(r, "Fragment", "Pixel", function(h) {
          o._rawFragmentSourceCode = h, c[1] = h, u();
        });
      }, n.prototype._useFinalCode = function(t, e, i, r) {
        if (r === void 0 && (r = !1), i) {
          var o = i.vertexElement || i.vertex || i.spectorName || i, a = i.fragmentElement || i.fragment || i.spectorName || i;
          this._vertexSourceCode = (this._shaderLanguage === li.WGSL ? "//" : "") + "#define SHADER_NAME vertex:" + o + `
` + t, this._fragmentSourceCode = (this._shaderLanguage === li.WGSL ? "//" : "") + "#define SHADER_NAME fragment:" + a + `
` + e;
        } else
          this._vertexSourceCode = t, this._fragmentSourceCode = e;
        this._prepareEffect(r);
      }, Object.defineProperty(n.prototype, "key", { get: function() {
        return this._key;
      }, enumerable: !1, configurable: !0 }), n.prototype.isReady = function() {
        try {
          return this._isReadyInternal();
        } catch {
          return !1;
        }
      }, n.prototype._isReadyInternal = function() {
        return !!this._isReady || !!this._pipelineContext && this._pipelineContext.isReady;
      }, n.prototype.getEngine = function() {
        return this._engine;
      }, n.prototype.getPipelineContext = function() {
        return this._pipelineContext;
      }, n.prototype.getAttributesNames = function() {
        return this._attributesNames;
      }, n.prototype.getAttributeLocation = function(t) {
        return this._attributes[t];
      }, n.prototype.getAttributeLocationByName = function(t) {
        return this._attributeLocationByName[t];
      }, n.prototype.getAttributesCount = function() {
        return this._attributes.length;
      }, n.prototype.getUniformIndex = function(t) {
        return this._uniformsNames.indexOf(t);
      }, n.prototype.getUniform = function(t) {
        return this._uniforms[t];
      }, n.prototype.getSamplers = function() {
        return this._samplerList;
      }, n.prototype.getUniformNames = function() {
        return this._uniformsNames;
      }, n.prototype.getUniformBuffersNames = function() {
        return this._uniformBuffersNamesList;
      }, n.prototype.getIndexParameters = function() {
        return this._indexParameters;
      }, n.prototype.getCompilationError = function() {
        return this._compilationError;
      }, n.prototype.allFallbacksProcessed = function() {
        return this._allFallbacksProcessed;
      }, n.prototype.executeWhenCompiled = function(t) {
        var e = this;
        this.isReady() ? t(this) : (this.onCompileObservable.add(function(i) {
          t(i);
        }), this._pipelineContext && !this._pipelineContext.isAsync || setTimeout(function() {
          e._checkIsReady(null);
        }, 16));
      }, n.prototype._checkIsReady = function(t) {
        var e = this;
        try {
          if (this._isReadyInternal())
            return;
        } catch (i) {
          return void this._processCompilationErrors(i, t);
        }
        this._isDisposed || setTimeout(function() {
          e._checkIsReady(t);
        }, 16);
      }, n.prototype._loadShader = function(t, e, i, r) {
        if (typeof HTMLElement < "u" && t instanceof HTMLElement)
          r(Jl(t));
        else if (t.substr(0, 7) !== "source:")
          if (t.substr(0, 7) !== "base64:") {
            var o, a = re.GetShadersStore(this._shaderLanguage);
            a[t + e + "Shader"] ? r(a[t + e + "Shader"]) : i && a[t + i + "Shader"] ? r(a[t + i + "Shader"]) : (o = t[0] === "." || t[0] === "/" || t.indexOf("http") > -1 ? t : re.GetShadersRepository(this._shaderLanguage) + t, this._engine._loadFile(o + "." + e.toLowerCase() + ".fx", r));
          } else
            r(window.atob(t.substr(7)));
        else
          r(t.substr(7));
      }, Object.defineProperty(n.prototype, "vertexSourceCode", { get: function() {
        var t, e;
        return this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride ? this._vertexSourceCodeOverride : (e = (t = this._pipelineContext) === null || t === void 0 ? void 0 : t._getVertexShaderCode()) !== null && e !== void 0 ? e : this._vertexSourceCode;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "fragmentSourceCode", { get: function() {
        var t, e;
        return this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride ? this._fragmentSourceCodeOverride : (e = (t = this._pipelineContext) === null || t === void 0 ? void 0 : t._getFragmentShaderCode()) !== null && e !== void 0 ? e : this._fragmentSourceCode;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "vertexSourceCodeBeforeMigration", { get: function() {
        return this._vertexSourceCodeBeforeMigration;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "fragmentSourceCodeBeforeMigration", { get: function() {
        return this._fragmentSourceCodeBeforeMigration;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "rawVertexSourceCode", { get: function() {
        return this._rawVertexSourceCode;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "rawFragmentSourceCode", { get: function() {
        return this._rawFragmentSourceCode;
      }, enumerable: !1, configurable: !0 }), n.prototype._rebuildProgram = function(t, e, i, r) {
        var o = this;
        this._isReady = !1, this._vertexSourceCodeOverride = t, this._fragmentSourceCodeOverride = e, this.onError = function(a, s) {
          r && r(s);
        }, this.onCompiled = function() {
          var a = o.getEngine().scenes;
          if (a)
            for (var s = 0; s < a.length; s++)
              a[s].markAllMaterialsAsDirty(_.MATERIAL_AllDirtyFlag);
          o._pipelineContext._handlesSpectorRebuildCallback(i);
        }, this._fallbacks = null, this._prepareEffect();
      }, n.prototype._prepareEffect = function(t) {
        var e, i = this;
        t === void 0 && (t = !1);
        var r = this._attributesNames, o = this.defines, a = this._pipelineContext;
        this._isReady = !1;
        try {
          var s = this._engine;
          this._pipelineContext = (e = t ? a : void 0) !== null && e !== void 0 ? e : s.createPipelineContext(this._processingContext), this._pipelineContext._name = this._key.replace(/\r/g, "").replace(/\n/g, "|");
          var l = function(c, u, h, d) {
            return i._rebuildProgram(c, u, h, d);
          };
          this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride ? s._preparePipelineContext(this._pipelineContext, this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, !0, this._rawVertexSourceCode, this._rawFragmentSourceCode, l, null, this._transformFeedbackVaryings, this._key) : s._preparePipelineContext(this._pipelineContext, this._vertexSourceCode, this._fragmentSourceCode, !1, this._rawVertexSourceCode, this._rawFragmentSourceCode, l, o, this._transformFeedbackVaryings, this._key), s._executeWhenRenderingStateIsCompiled(this._pipelineContext, function() {
            if (i._attributes = [], i._pipelineContext._fillEffectInformation(i, i._uniformBuffersNames, i._uniformsNames, i._uniforms, i._samplerList, i._samplers, r, i._attributes), r)
              for (var c = 0; c < r.length; c++) {
                var u = r[c];
                i._attributeLocationByName[u] = i._attributes[c];
              }
            s.bindSamplers(i), i._compilationError = "", i._isReady = !0, i.onCompiled && i.onCompiled(i), i.onCompileObservable.notifyObservers(i), i.onCompileObservable.clear(), i._fallbacks && i._fallbacks.unBindMesh(), a && !t && i.getEngine()._deletePipelineContext(a);
          }), this._pipelineContext.isAsync && this._checkIsReady(a);
        } catch (c) {
          this._processCompilationErrors(c, a);
        }
      }, n.prototype._getShaderCodeAndErrorLine = function(t, e, i) {
        var r = i ? /FRAGMENT SHADER ERROR: 0:(\d+?):/ : /VERTEX SHADER ERROR: 0:(\d+?):/, o = null;
        if (e && t) {
          var a = e.match(r);
          if (a && a.length === 2) {
            var s = parseInt(a[1]), l = t.split(`
`, -1);
            l.length >= s && (o = "Offending line [".concat(s, "] in ").concat(i ? "fragment" : "vertex", " code: ").concat(l[s - 1]));
          }
        }
        return [t, o];
      }, n.prototype._processCompilationErrors = function(t, e) {
        var i, r, o, a, s, l = this;
        e === void 0 && (e = null), this._compilationError = t.message;
        var c = this._attributesNames, u = this._fallbacks;
        if (q.Error("Unable to compile effect:"), q.Error("Uniforms: " + this._uniformsNames.map(function(m) {
          return " " + m;
        })), q.Error("Attributes: " + c.map(function(m) {
          return " " + m;
        })), q.Error(`Defines:
` + this.defines), n.LogShaderCodeOnCompilationError) {
          var h = null, d = null, p = null;
          !((o = this._pipelineContext) === null || o === void 0) && o._getVertexShaderCode() && (p = (i = this._getShaderCodeAndErrorLine(this._pipelineContext._getVertexShaderCode(), this._compilationError, !1))[0], h = i[1], p && (q.Error("Vertex code:"), q.Error(p))), !((a = this._pipelineContext) === null || a === void 0) && a._getFragmentShaderCode() && (p = (r = this._getShaderCodeAndErrorLine((s = this._pipelineContext) === null || s === void 0 ? void 0 : s._getFragmentShaderCode(), this._compilationError, !0))[0], d = r[1], p && (q.Error("Fragment code:"), q.Error(p))), h && q.Error(h), d && q.Error(d);
        }
        q.Error("Error: " + this._compilationError);
        var f = function() {
          l.onError && l.onError(l, l._compilationError), l.onErrorObservable.notifyObservers(l);
        };
        e && (this._pipelineContext = e, this._isReady = !0, f()), u ? (this._pipelineContext = null, u.hasMoreFallbacks ? (this._allFallbacksProcessed = !1, q.Error("Trying next fallback."), this.defines = u.reduce(this.defines, this), this._prepareEffect()) : (this._allFallbacksProcessed = !0, f(), this.onErrorObservable.clear(), this._fallbacks && this._fallbacks.unBindMesh())) : (this._allFallbacksProcessed = !0, e || f());
      }, Object.defineProperty(n.prototype, "isSupported", { get: function() {
        return this._compilationError === "";
      }, enumerable: !1, configurable: !0 }), n.prototype._bindTexture = function(t, e) {
        this._engine._bindTexture(this._samplers[t], e, t);
      }, n.prototype.setTexture = function(t, e) {
        this._engine.setTexture(this._samplers[t], this._uniforms[t], e, t);
      }, n.prototype.setDepthStencilTexture = function(t, e) {
        this._engine.setDepthStencilTexture(this._samplers[t], this._uniforms[t], e, t);
      }, n.prototype.setTextureArray = function(t, e) {
        var i = t + "Ex";
        if (this._samplerList.indexOf(i + "0") === -1) {
          for (var r = this._samplerList.indexOf(t), o = 1; o < e.length; o++) {
            var a = i + (o - 1).toString();
            this._samplerList.splice(r + o, 0, a);
          }
          for (var s = 0, l = 0, c = this._samplerList; l < c.length; l++) {
            var u = c[l];
            this._samplers[u] = s, s += 1;
          }
        }
        this._engine.setTextureArray(this._samplers[t], this._uniforms[t], e, t);
      }, n.prototype.setTextureFromPostProcess = function(t, e) {
        this._engine.setTextureFromPostProcess(this._samplers[t], e, t);
      }, n.prototype.setTextureFromPostProcessOutput = function(t, e) {
        this._engine.setTextureFromPostProcessOutput(this._samplers[t], e, t);
      }, n.prototype.bindUniformBuffer = function(t, e) {
        var i = this._uniformBuffersNames[e];
        i === void 0 || n._BaseCache[i] === t && this._engine._features.useUBOBindingCache || (n._BaseCache[i] = t, this._engine.bindUniformBufferBase(t, i, e));
      }, n.prototype.bindUniformBlock = function(t, e) {
        this._engine.bindUniformBlock(this._pipelineContext, t, e);
      }, n.prototype.setInt = function(t, e) {
        return this._pipelineContext.setInt(t, e), this;
      }, n.prototype.setInt2 = function(t, e, i) {
        return this._pipelineContext.setInt2(t, e, i), this;
      }, n.prototype.setInt3 = function(t, e, i, r) {
        return this._pipelineContext.setInt3(t, e, i, r), this;
      }, n.prototype.setInt4 = function(t, e, i, r, o) {
        return this._pipelineContext.setInt4(t, e, i, r, o), this;
      }, n.prototype.setIntArray = function(t, e) {
        return this._pipelineContext.setIntArray(t, e), this;
      }, n.prototype.setIntArray2 = function(t, e) {
        return this._pipelineContext.setIntArray2(t, e), this;
      }, n.prototype.setIntArray3 = function(t, e) {
        return this._pipelineContext.setIntArray3(t, e), this;
      }, n.prototype.setIntArray4 = function(t, e) {
        return this._pipelineContext.setIntArray4(t, e), this;
      }, n.prototype.setUInt = function(t, e) {
        return this._pipelineContext.setUInt(t, e), this;
      }, n.prototype.setUInt2 = function(t, e, i) {
        return this._pipelineContext.setUInt2(t, e, i), this;
      }, n.prototype.setUInt3 = function(t, e, i, r) {
        return this._pipelineContext.setUInt3(t, e, i, r), this;
      }, n.prototype.setUInt4 = function(t, e, i, r, o) {
        return this._pipelineContext.setUInt4(t, e, i, r, o), this;
      }, n.prototype.setUIntArray = function(t, e) {
        return this._pipelineContext.setUIntArray(t, e), this;
      }, n.prototype.setUIntArray2 = function(t, e) {
        return this._pipelineContext.setUIntArray2(t, e), this;
      }, n.prototype.setUIntArray3 = function(t, e) {
        return this._pipelineContext.setUIntArray3(t, e), this;
      }, n.prototype.setUIntArray4 = function(t, e) {
        return this._pipelineContext.setUIntArray4(t, e), this;
      }, n.prototype.setFloatArray = function(t, e) {
        return this._pipelineContext.setArray(t, e), this;
      }, n.prototype.setFloatArray2 = function(t, e) {
        return this._pipelineContext.setArray2(t, e), this;
      }, n.prototype.setFloatArray3 = function(t, e) {
        return this._pipelineContext.setArray3(t, e), this;
      }, n.prototype.setFloatArray4 = function(t, e) {
        return this._pipelineContext.setArray4(t, e), this;
      }, n.prototype.setArray = function(t, e) {
        return this._pipelineContext.setArray(t, e), this;
      }, n.prototype.setArray2 = function(t, e) {
        return this._pipelineContext.setArray2(t, e), this;
      }, n.prototype.setArray3 = function(t, e) {
        return this._pipelineContext.setArray3(t, e), this;
      }, n.prototype.setArray4 = function(t, e) {
        return this._pipelineContext.setArray4(t, e), this;
      }, n.prototype.setMatrices = function(t, e) {
        return this._pipelineContext.setMatrices(t, e), this;
      }, n.prototype.setMatrix = function(t, e) {
        return this._pipelineContext.setMatrix(t, e), this;
      }, n.prototype.setMatrix3x3 = function(t, e) {
        return this._pipelineContext.setMatrix3x3(t, e), this;
      }, n.prototype.setMatrix2x2 = function(t, e) {
        return this._pipelineContext.setMatrix2x2(t, e), this;
      }, n.prototype.setFloat = function(t, e) {
        return this._pipelineContext.setFloat(t, e), this;
      }, n.prototype.setBool = function(t, e) {
        return this._pipelineContext.setInt(t, e ? 1 : 0), this;
      }, n.prototype.setVector2 = function(t, e) {
        return this._pipelineContext.setVector2(t, e), this;
      }, n.prototype.setFloat2 = function(t, e, i) {
        return this._pipelineContext.setFloat2(t, e, i), this;
      }, n.prototype.setVector3 = function(t, e) {
        return this._pipelineContext.setVector3(t, e), this;
      }, n.prototype.setFloat3 = function(t, e, i, r) {
        return this._pipelineContext.setFloat3(t, e, i, r), this;
      }, n.prototype.setVector4 = function(t, e) {
        return this._pipelineContext.setVector4(t, e), this;
      }, n.prototype.setQuaternion = function(t, e) {
        return this._pipelineContext.setQuaternion(t, e), this;
      }, n.prototype.setFloat4 = function(t, e, i, r, o) {
        return this._pipelineContext.setFloat4(t, e, i, r, o), this;
      }, n.prototype.setColor3 = function(t, e) {
        return this._pipelineContext.setColor3(t, e), this;
      }, n.prototype.setColor4 = function(t, e, i) {
        return this._pipelineContext.setColor4(t, e, i), this;
      }, n.prototype.setDirectColor4 = function(t, e) {
        return this._pipelineContext.setDirectColor4(t, e), this;
      }, n.prototype.dispose = function() {
        this._pipelineContext && this._pipelineContext.dispose(), this._engine._releaseEffect(this), this._isDisposed = !0;
      }, n.RegisterShader = function(t, e, i, r) {
        r === void 0 && (r = li.GLSL), e && (re.GetShadersStore(r)["".concat(t, "PixelShader")] = e), i && (re.GetShadersStore(r)["".concat(t, "VertexShader")] = i);
      }, n.ResetCache = function() {
        n._BaseCache = {};
      }, n.LogShaderCodeOnCompilationError = !0, n._UniqueIdSeed = 0, n._BaseCache = {}, n.ShadersStore = re.ShadersStore, n.IncludesShadersStore = re.IncludesShadersStore, n;
    }(), np = function() {
      function n(t) {
        t === void 0 && (t = !0), this._isDepthTestDirty = !1, this._isDepthMaskDirty = !1, this._isDepthFuncDirty = !1, this._isCullFaceDirty = !1, this._isCullDirty = !1, this._isZOffsetDirty = !1, this._isFrontFaceDirty = !1, t && this.reset();
      }
      return Object.defineProperty(n.prototype, "isDirty", { get: function() {
        return this._isDepthFuncDirty || this._isDepthTestDirty || this._isDepthMaskDirty || this._isCullFaceDirty || this._isCullDirty || this._isZOffsetDirty || this._isFrontFaceDirty;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "zOffset", { get: function() {
        return this._zOffset;
      }, set: function(t) {
        this._zOffset !== t && (this._zOffset = t, this._isZOffsetDirty = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "zOffsetUnits", { get: function() {
        return this._zOffsetUnits;
      }, set: function(t) {
        this._zOffsetUnits !== t && (this._zOffsetUnits = t, this._isZOffsetDirty = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "cullFace", { get: function() {
        return this._cullFace;
      }, set: function(t) {
        this._cullFace !== t && (this._cullFace = t, this._isCullFaceDirty = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "cull", { get: function() {
        return this._cull;
      }, set: function(t) {
        this._cull !== t && (this._cull = t, this._isCullDirty = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "depthFunc", { get: function() {
        return this._depthFunc;
      }, set: function(t) {
        this._depthFunc !== t && (this._depthFunc = t, this._isDepthFuncDirty = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "depthMask", { get: function() {
        return this._depthMask;
      }, set: function(t) {
        this._depthMask !== t && (this._depthMask = t, this._isDepthMaskDirty = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "depthTest", { get: function() {
        return this._depthTest;
      }, set: function(t) {
        this._depthTest !== t && (this._depthTest = t, this._isDepthTestDirty = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "frontFace", { get: function() {
        return this._frontFace;
      }, set: function(t) {
        this._frontFace !== t && (this._frontFace = t, this._isFrontFaceDirty = !0);
      }, enumerable: !1, configurable: !0 }), n.prototype.reset = function() {
        this._depthMask = !0, this._depthTest = !0, this._depthFunc = null, this._cullFace = null, this._cull = null, this._zOffset = 0, this._zOffsetUnits = 0, this._frontFace = null, this._isDepthTestDirty = !0, this._isDepthMaskDirty = !0, this._isDepthFuncDirty = !1, this._isCullFaceDirty = !1, this._isCullDirty = !1, this._isZOffsetDirty = !0, this._isFrontFaceDirty = !1;
      }, n.prototype.apply = function(t) {
        this.isDirty && (this._isCullDirty && (this.cull ? t.enable(t.CULL_FACE) : t.disable(t.CULL_FACE), this._isCullDirty = !1), this._isCullFaceDirty && (t.cullFace(this.cullFace), this._isCullFaceDirty = !1), this._isDepthMaskDirty && (t.depthMask(this.depthMask), this._isDepthMaskDirty = !1), this._isDepthTestDirty && (this.depthTest ? t.enable(t.DEPTH_TEST) : t.disable(t.DEPTH_TEST), this._isDepthTestDirty = !1), this._isDepthFuncDirty && (t.depthFunc(this.depthFunc), this._isDepthFuncDirty = !1), this._isZOffsetDirty && (this.zOffset || this.zOffsetUnits ? (t.enable(t.POLYGON_OFFSET_FILL), t.polygonOffset(this.zOffset, this.zOffsetUnits)) : t.disable(t.POLYGON_OFFSET_FILL), this._isZOffsetDirty = !1), this._isFrontFaceDirty && (t.frontFace(this.frontFace), this._isFrontFaceDirty = !1));
      }, n;
    }(), qm = function() {
      function n() {
        this.reset();
      }
      return n.prototype.reset = function() {
        this.enabled = !1, this.mask = 255, this.func = n.ALWAYS, this.funcRef = 1, this.funcMask = 255, this.opStencilFail = n.KEEP, this.opDepthFail = n.KEEP, this.opStencilDepthPass = n.REPLACE;
      }, Object.defineProperty(n.prototype, "stencilFunc", { get: function() {
        return this.func;
      }, set: function(t) {
        this.func = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "stencilFuncRef", { get: function() {
        return this.funcRef;
      }, set: function(t) {
        this.funcRef = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "stencilFuncMask", { get: function() {
        return this.funcMask;
      }, set: function(t) {
        this.funcMask = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "stencilOpStencilFail", { get: function() {
        return this.opStencilFail;
      }, set: function(t) {
        this.opStencilFail = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "stencilOpDepthFail", { get: function() {
        return this.opDepthFail;
      }, set: function(t) {
        this.opDepthFail = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "stencilOpStencilDepthPass", { get: function() {
        return this.opStencilDepthPass;
      }, set: function(t) {
        this.opStencilDepthPass = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "stencilMask", { get: function() {
        return this.mask;
      }, set: function(t) {
        this.mask = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "stencilTest", { get: function() {
        return this.enabled;
      }, set: function(t) {
        this.enabled = t;
      }, enumerable: !1, configurable: !0 }), n.ALWAYS = _.ALWAYS, n.KEEP = _.KEEP, n.REPLACE = _.REPLACE, n;
    }(), Qm = function() {
      function n() {
        this._blendFunctionParameters = new Array(4), this._blendEquationParameters = new Array(2), this._blendConstants = new Array(4), this._isBlendConstantsDirty = !1, this._alphaBlend = !1, this._isAlphaBlendDirty = !1, this._isBlendFunctionParametersDirty = !1, this._isBlendEquationParametersDirty = !1, this.reset();
      }
      return Object.defineProperty(n.prototype, "isDirty", { get: function() {
        return this._isAlphaBlendDirty || this._isBlendFunctionParametersDirty || this._isBlendEquationParametersDirty;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "alphaBlend", { get: function() {
        return this._alphaBlend;
      }, set: function(t) {
        this._alphaBlend !== t && (this._alphaBlend = t, this._isAlphaBlendDirty = !0);
      }, enumerable: !1, configurable: !0 }), n.prototype.setAlphaBlendConstants = function(t, e, i, r) {
        this._blendConstants[0] === t && this._blendConstants[1] === e && this._blendConstants[2] === i && this._blendConstants[3] === r || (this._blendConstants[0] = t, this._blendConstants[1] = e, this._blendConstants[2] = i, this._blendConstants[3] = r, this._isBlendConstantsDirty = !0);
      }, n.prototype.setAlphaBlendFunctionParameters = function(t, e, i, r) {
        this._blendFunctionParameters[0] === t && this._blendFunctionParameters[1] === e && this._blendFunctionParameters[2] === i && this._blendFunctionParameters[3] === r || (this._blendFunctionParameters[0] = t, this._blendFunctionParameters[1] = e, this._blendFunctionParameters[2] = i, this._blendFunctionParameters[3] = r, this._isBlendFunctionParametersDirty = !0);
      }, n.prototype.setAlphaEquationParameters = function(t, e) {
        this._blendEquationParameters[0] === t && this._blendEquationParameters[1] === e || (this._blendEquationParameters[0] = t, this._blendEquationParameters[1] = e, this._isBlendEquationParametersDirty = !0);
      }, n.prototype.reset = function() {
        this._alphaBlend = !1, this._blendFunctionParameters[0] = null, this._blendFunctionParameters[1] = null, this._blendFunctionParameters[2] = null, this._blendFunctionParameters[3] = null, this._blendEquationParameters[0] = null, this._blendEquationParameters[1] = null, this._blendConstants[0] = null, this._blendConstants[1] = null, this._blendConstants[2] = null, this._blendConstants[3] = null, this._isAlphaBlendDirty = !0, this._isBlendFunctionParametersDirty = !1, this._isBlendEquationParametersDirty = !1, this._isBlendConstantsDirty = !1;
      }, n.prototype.apply = function(t) {
        this.isDirty && (this._isAlphaBlendDirty && (this._alphaBlend ? t.enable(t.BLEND) : t.disable(t.BLEND), this._isAlphaBlendDirty = !1), this._isBlendFunctionParametersDirty && (t.blendFuncSeparate(this._blendFunctionParameters[0], this._blendFunctionParameters[1], this._blendFunctionParameters[2], this._blendFunctionParameters[3]), this._isBlendFunctionParametersDirty = !1), this._isBlendEquationParametersDirty && (t.blendEquationSeparate(this._blendEquationParameters[0], this._blendEquationParameters[1]), this._isBlendEquationParametersDirty = !1), this._isBlendConstantsDirty && (t.blendColor(this._blendConstants[0], this._blendConstants[1], this._blendConstants[2], this._blendConstants[3]), this._isBlendConstantsDirty = !1));
      }, n;
    }(), rp = function() {
      function n() {
        this.samplingMode = -1, this._useMipMaps = !0, this._cachedWrapU = null, this._cachedWrapV = null, this._cachedWrapR = null, this._cachedAnisotropicFilteringLevel = null, this._comparisonFunction = 0;
      }
      return Object.defineProperty(n.prototype, "wrapU", { get: function() {
        return this._cachedWrapU;
      }, set: function(t) {
        this._cachedWrapU = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "wrapV", { get: function() {
        return this._cachedWrapV;
      }, set: function(t) {
        this._cachedWrapV = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "wrapR", { get: function() {
        return this._cachedWrapR;
      }, set: function(t) {
        this._cachedWrapR = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "anisotropicFilteringLevel", { get: function() {
        return this._cachedAnisotropicFilteringLevel;
      }, set: function(t) {
        this._cachedAnisotropicFilteringLevel = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "comparisonFunction", { get: function() {
        return this._comparisonFunction;
      }, set: function(t) {
        this._comparisonFunction = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "useMipMaps", { get: function() {
        return this._useMipMaps;
      }, set: function(t) {
        this._useMipMaps = t;
      }, enumerable: !1, configurable: !0 }), n.prototype.setParameters = function(t, e, i, r, o, a) {
        return t === void 0 && (t = _.TEXTURE_WRAP_ADDRESSMODE), e === void 0 && (e = _.TEXTURE_WRAP_ADDRESSMODE), i === void 0 && (i = _.TEXTURE_WRAP_ADDRESSMODE), r === void 0 && (r = 1), o === void 0 && (o = _.TEXTURE_BILINEAR_SAMPLINGMODE), a === void 0 && (a = 0), this._cachedWrapU = t, this._cachedWrapV = e, this._cachedWrapR = i, this._cachedAnisotropicFilteringLevel = r, this.samplingMode = o, this._comparisonFunction = a, this;
      }, n.prototype.compareSampler = function(t) {
        return this._cachedWrapU === t._cachedWrapU && this._cachedWrapV === t._cachedWrapV && this._cachedWrapR === t._cachedWrapR && this._cachedAnisotropicFilteringLevel === t._cachedAnisotropicFilteringLevel && this.samplingMode === t.samplingMode && this._comparisonFunction === t._comparisonFunction && this._useMipMaps === t._useMipMaps;
      }, n;
    }();
    (function(n) {
      n[n.Unknown = 0] = "Unknown", n[n.Url = 1] = "Url", n[n.Temp = 2] = "Temp", n[n.Raw = 3] = "Raw", n[n.Dynamic = 4] = "Dynamic", n[n.RenderTarget = 5] = "RenderTarget", n[n.MultiRenderTarget = 6] = "MultiRenderTarget", n[n.Cube = 7] = "Cube", n[n.CubeRaw = 8] = "CubeRaw", n[n.CubePrefiltered = 9] = "CubePrefiltered", n[n.Raw3D = 10] = "Raw3D", n[n.Raw2DArray = 11] = "Raw2DArray", n[n.DepthStencil = 12] = "DepthStencil", n[n.CubeRawRGBD = 13] = "CubeRawRGBD", n[n.Depth = 14] = "Depth";
    })(ut || (ut = {}));
    var Ut = function(n) {
      function t(e, i, r) {
        r === void 0 && (r = !1);
        var o = n.call(this) || this;
        return o.isReady = !1, o.isCube = !1, o.is3D = !1, o.is2DArray = !1, o.isMultiview = !1, o.url = "", o.generateMipMaps = !1, o.samples = 0, o.type = -1, o.format = -1, o.onLoadedObservable = new H(), o.onErrorObservable = new H(), o.onRebuildCallback = null, o.width = 0, o.height = 0, o.depth = 0, o.baseWidth = 0, o.baseHeight = 0, o.baseDepth = 0, o.invertY = !1, o._invertVScale = !1, o._associatedChannel = -1, o._source = ut.Unknown, o._buffer = null, o._bufferView = null, o._bufferViewArray = null, o._bufferViewArrayArray = null, o._size = 0, o._extension = "", o._files = null, o._workingCanvas = null, o._workingContext = null, o._cachedCoordinatesMode = null, o._isDisabled = !1, o._compression = null, o._sphericalPolynomial = null, o._sphericalPolynomialPromise = null, o._sphericalPolynomialComputed = !1, o._lodGenerationScale = 0, o._lodGenerationOffset = 0, o._useSRGBBuffer = !1, o._lodTextureHigh = null, o._lodTextureMid = null, o._lodTextureLow = null, o._isRGBD = !1, o._linearSpecularLOD = !1, o._irradianceTexture = null, o._hardwareTexture = null, o._maxLodLevel = null, o._references = 1, o._gammaSpace = null, o._engine = e, o._source = i, o._uniqueId = t._Counter++, r || (o._hardwareTexture = e._createHardwareTexture()), o;
      }
      return D(t, n), Object.defineProperty(t.prototype, "useMipMaps", { get: function() {
        return this.generateMipMaps;
      }, set: function(e) {
        this.generateMipMaps = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "uniqueId", { get: function() {
        return this._uniqueId;
      }, enumerable: !1, configurable: !0 }), t.prototype._setUniqueId = function(e) {
        this._uniqueId = e;
      }, t.prototype.getEngine = function() {
        return this._engine;
      }, Object.defineProperty(t.prototype, "source", { get: function() {
        return this._source;
      }, enumerable: !1, configurable: !0 }), t.prototype.incrementReferences = function() {
        this._references++;
      }, t.prototype.updateSize = function(e, i, r) {
        r === void 0 && (r = 1), this._engine.updateTextureDimensions(this, e, i, r), this.width = e, this.height = i, this.depth = r, this.baseWidth = e, this.baseHeight = i, this.baseDepth = r, this._size = e * i * r;
      }, t.prototype._rebuild = function() {
        var e, i = this;
        if (this.isReady = !1, this._cachedCoordinatesMode = null, this._cachedWrapU = null, this._cachedWrapV = null, this._cachedWrapR = null, this._cachedAnisotropicFilteringLevel = null, this.onRebuildCallback) {
          var r = this.onRebuildCallback(this), o = function(s) {
            s._swapAndDie(i, !1), i.isReady = r.isReady;
          };
          r.isAsync ? r.proxy.then(o) : o(r.proxy);
        } else {
          var a;
          switch (this.source) {
            case ut.Temp:
              break;
            case ut.Url:
              return void (a = this._engine.createTexture((e = this._originalUrl) !== null && e !== void 0 ? e : this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, function(s) {
                s._swapAndDie(i, !1), i.isReady = !0;
              }, null, this._buffer, void 0, this.format, this._extension, void 0, void 0, void 0, this._useSRGBBuffer));
            case ut.Raw:
              (a = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression, this.type, void 0, this._useSRGBBuffer))._swapAndDie(this, !1), this.isReady = !0;
              break;
            case ut.Raw3D:
              (a = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression, this.type))._swapAndDie(this, !1), this.isReady = !0;
              break;
            case ut.Raw2DArray:
              (a = this._engine.createRawTexture2DArray(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression, this.type))._swapAndDie(this, !1), this.isReady = !0;
              break;
            case ut.Dynamic:
              (a = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode))._swapAndDie(this, !1), this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas(), this.invertY, void 0, void 0, !0);
              break;
            case ut.Cube:
              return void (a = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function() {
                a._swapAndDie(i, !1), i.isReady = !0;
              }, null, this.format, this._extension, !1, 0, 0, null, void 0, this._useSRGBBuffer));
            case ut.CubeRaw:
              (a = this._engine.createRawCubeTexture(this._bufferViewArray, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression))._swapAndDie(this, !1), this.isReady = !0;
              break;
            case ut.CubeRawRGBD:
              return;
            case ut.CubePrefiltered:
              return void ((a = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, function(s) {
                s && s._swapAndDie(i, !1), i.isReady = !0;
              }, null, this.format, this._extension))._sphericalPolynomial = this._sphericalPolynomial);
          }
        }
      }, t.prototype._swapAndDie = function(e, i) {
        var r;
        i === void 0 && (i = !0), (r = this._hardwareTexture) === null || r === void 0 || r.setUsage(e._source, this.generateMipMaps, this.isCube, this.width, this.height), e._hardwareTexture = this._hardwareTexture, i && (e._isRGBD = this._isRGBD), this._lodTextureHigh && (e._lodTextureHigh && e._lodTextureHigh.dispose(), e._lodTextureHigh = this._lodTextureHigh), this._lodTextureMid && (e._lodTextureMid && e._lodTextureMid.dispose(), e._lodTextureMid = this._lodTextureMid), this._lodTextureLow && (e._lodTextureLow && e._lodTextureLow.dispose(), e._lodTextureLow = this._lodTextureLow), this._irradianceTexture && (e._irradianceTexture && e._irradianceTexture.dispose(), e._irradianceTexture = this._irradianceTexture);
        var o = this._engine.getLoadedTexturesCache(), a = o.indexOf(this);
        a !== -1 && o.splice(a, 1), (a = o.indexOf(e)) === -1 && o.push(e);
      }, t.prototype.dispose = function() {
        this._references--, this.onLoadedObservable.clear(), this.onErrorObservable.clear(), this._references === 0 && (this._engine._releaseTexture(this), this._hardwareTexture = null);
      }, t._Counter = 0, t;
    }(rp), x1 = function() {
      function n() {
        this.shaderLanguage = li.GLSL;
      }
      return n.prototype.postProcessor = function(t, e, i, r, o) {
        return o.getCaps().drawBuffersExtension || (t = t.replace(/#extension.+GL_EXT_draw_buffers.+(enable|require)/g, "")), t;
      }, n;
    }(), A1 = /(flat\s)?\s*varying\s*.*/, op = function() {
      function n() {
        this.shaderLanguage = li.GLSL;
      }
      return n.prototype.attributeProcessor = function(t) {
        return t.replace("attribute", "in");
      }, n.prototype.varyingCheck = function(t, e) {
        return A1.test(t);
      }, n.prototype.varyingProcessor = function(t, e) {
        return t.replace("varying", e ? "in" : "out");
      }, n.prototype.postProcessor = function(t, e, i) {
        var r = t.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1;
        if (t = (t = t.replace(/#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g, "")).replace(/texture2D\s*\(/g, "texture("), i) {
          var o = t.search(/layout *\(location *= *0\) *out/g) !== -1;
          t = (t = (t = (t = (t = (t = (t = t.replace(/texture2DLodEXT\s*\(/g, "textureLod(")).replace(/textureCubeLodEXT\s*\(/g, "textureLod(")).replace(/textureCube\s*\(/g, "texture(")).replace(/gl_FragDepthEXT/g, "gl_FragDepth")).replace(/gl_FragColor/g, "glFragColor")).replace(/gl_FragData/g, "glFragData")).replace(/void\s+?main\s*\(/g, (r || o ? "" : `layout(location = 0) out vec4 glFragColor;
`) + "void main(");
        } else if (e.indexOf("#define MULTIVIEW") !== -1)
          return `#extension GL_OVR_multiview2 : require
layout (num_views = 2) in;
` + t;
        return t;
      }, n;
    }(), wa = function() {
      function n() {
        this.references = 0, this.capacity = 0, this.is32Bits = !1, this.uniqueId = n._Counter++;
      }
      return Object.defineProperty(n.prototype, "underlyingResource", { get: function() {
        return null;
      }, enumerable: !1, configurable: !0 }), n._Counter = 0, n;
    }(), nl = function(n) {
      function t(e) {
        var i = n.call(this) || this;
        return i._buffer = e, i;
      }
      return D(t, n), Object.defineProperty(t.prototype, "underlyingResource", { get: function() {
        return this._buffer;
      }, enumerable: !1, configurable: !0 }), t;
    }(wa), Zm = function() {
      function n() {
        this._valueCache = {}, this.vertexCompilationError = null, this.fragmentCompilationError = null, this.programLinkError = null, this.programValidationError = null, this._isDisposed = !1;
      }
      return Object.defineProperty(n.prototype, "isAsync", { get: function() {
        return this.isParallelCompiled;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isReady", { get: function() {
        return !!this.program && (!this.isParallelCompiled || this.engine._isRenderingStateCompiled(this));
      }, enumerable: !1, configurable: !0 }), n.prototype._handlesSpectorRebuildCallback = function(t) {
        t && this.program && t(this.program);
      }, n.prototype._fillEffectInformation = function(t, e, i, r, o, a, s, l) {
        var c, u = this.engine;
        if (u.supportsUniformBuffers)
          for (var h in e)
            t.bindUniformBlock(h, e[h]);
        for (this.engine.getUniforms(this, i).forEach(function(m, g) {
          r[i[g]] = m;
        }), this._uniforms = r, c = 0; c < o.length; c++)
          t.getUniform(o[c]) == null && (o.splice(c, 1), c--);
        o.forEach(function(m, g) {
          a[m] = g;
        });
        for (var d = 0, p = u.getAttributes(this, s); d < p.length; d++) {
          var f = p[d];
          l.push(f);
        }
      }, n.prototype.dispose = function() {
        this._uniforms = {}, this._isDisposed = !0;
      }, n.prototype._cacheMatrix = function(t, e) {
        var i = this._valueCache[t], r = e.updateFlag;
        return (i === void 0 || i !== r) && (this._valueCache[t] = r, !0);
      }, n.prototype._cacheFloat2 = function(t, e, i) {
        var r = this._valueCache[t];
        if (!r || r.length !== 2)
          return r = [e, i], this._valueCache[t] = r, !0;
        var o = !1;
        return r[0] !== e && (r[0] = e, o = !0), r[1] !== i && (r[1] = i, o = !0), o;
      }, n.prototype._cacheFloat3 = function(t, e, i, r) {
        var o = this._valueCache[t];
        if (!o || o.length !== 3)
          return o = [e, i, r], this._valueCache[t] = o, !0;
        var a = !1;
        return o[0] !== e && (o[0] = e, a = !0), o[1] !== i && (o[1] = i, a = !0), o[2] !== r && (o[2] = r, a = !0), a;
      }, n.prototype._cacheFloat4 = function(t, e, i, r, o) {
        var a = this._valueCache[t];
        if (!a || a.length !== 4)
          return a = [e, i, r, o], this._valueCache[t] = a, !0;
        var s = !1;
        return a[0] !== e && (a[0] = e, s = !0), a[1] !== i && (a[1] = i, s = !0), a[2] !== r && (a[2] = r, s = !0), a[3] !== o && (a[3] = o, s = !0), s;
      }, n.prototype.setInt = function(t, e) {
        var i = this._valueCache[t];
        i !== void 0 && i === e || this.engine.setInt(this._uniforms[t], e) && (this._valueCache[t] = e);
      }, n.prototype.setInt2 = function(t, e, i) {
        this._cacheFloat2(t, e, i) && (this.engine.setInt2(this._uniforms[t], e, i) || (this._valueCache[t] = null));
      }, n.prototype.setInt3 = function(t, e, i, r) {
        this._cacheFloat3(t, e, i, r) && (this.engine.setInt3(this._uniforms[t], e, i, r) || (this._valueCache[t] = null));
      }, n.prototype.setInt4 = function(t, e, i, r, o) {
        this._cacheFloat4(t, e, i, r, o) && (this.engine.setInt4(this._uniforms[t], e, i, r, o) || (this._valueCache[t] = null));
      }, n.prototype.setIntArray = function(t, e) {
        this._valueCache[t] = null, this.engine.setIntArray(this._uniforms[t], e);
      }, n.prototype.setIntArray2 = function(t, e) {
        this._valueCache[t] = null, this.engine.setIntArray2(this._uniforms[t], e);
      }, n.prototype.setIntArray3 = function(t, e) {
        this._valueCache[t] = null, this.engine.setIntArray3(this._uniforms[t], e);
      }, n.prototype.setIntArray4 = function(t, e) {
        this._valueCache[t] = null, this.engine.setIntArray4(this._uniforms[t], e);
      }, n.prototype.setUInt = function(t, e) {
        var i = this._valueCache[t];
        i !== void 0 && i === e || this.engine.setUInt(this._uniforms[t], e) && (this._valueCache[t] = e);
      }, n.prototype.setUInt2 = function(t, e, i) {
        this._cacheFloat2(t, e, i) && (this.engine.setUInt2(this._uniforms[t], e, i) || (this._valueCache[t] = null));
      }, n.prototype.setUInt3 = function(t, e, i, r) {
        this._cacheFloat3(t, e, i, r) && (this.engine.setUInt3(this._uniforms[t], e, i, r) || (this._valueCache[t] = null));
      }, n.prototype.setUInt4 = function(t, e, i, r, o) {
        this._cacheFloat4(t, e, i, r, o) && (this.engine.setUInt4(this._uniforms[t], e, i, r, o) || (this._valueCache[t] = null));
      }, n.prototype.setUIntArray = function(t, e) {
        this._valueCache[t] = null, this.engine.setUIntArray(this._uniforms[t], e);
      }, n.prototype.setUIntArray2 = function(t, e) {
        this._valueCache[t] = null, this.engine.setUIntArray2(this._uniforms[t], e);
      }, n.prototype.setUIntArray3 = function(t, e) {
        this._valueCache[t] = null, this.engine.setUIntArray3(this._uniforms[t], e);
      }, n.prototype.setUIntArray4 = function(t, e) {
        this._valueCache[t] = null, this.engine.setUIntArray4(this._uniforms[t], e);
      }, n.prototype.setArray = function(t, e) {
        this._valueCache[t] = null, this.engine.setArray(this._uniforms[t], e);
      }, n.prototype.setArray2 = function(t, e) {
        this._valueCache[t] = null, this.engine.setArray2(this._uniforms[t], e);
      }, n.prototype.setArray3 = function(t, e) {
        this._valueCache[t] = null, this.engine.setArray3(this._uniforms[t], e);
      }, n.prototype.setArray4 = function(t, e) {
        this._valueCache[t] = null, this.engine.setArray4(this._uniforms[t], e);
      }, n.prototype.setMatrices = function(t, e) {
        e && (this._valueCache[t] = null, this.engine.setMatrices(this._uniforms[t], e));
      }, n.prototype.setMatrix = function(t, e) {
        this._cacheMatrix(t, e) && (this.engine.setMatrices(this._uniforms[t], e.toArray()) || (this._valueCache[t] = null));
      }, n.prototype.setMatrix3x3 = function(t, e) {
        this._valueCache[t] = null, this.engine.setMatrix3x3(this._uniforms[t], e);
      }, n.prototype.setMatrix2x2 = function(t, e) {
        this._valueCache[t] = null, this.engine.setMatrix2x2(this._uniforms[t], e);
      }, n.prototype.setFloat = function(t, e) {
        var i = this._valueCache[t];
        i !== void 0 && i === e || this.engine.setFloat(this._uniforms[t], e) && (this._valueCache[t] = e);
      }, n.prototype.setVector2 = function(t, e) {
        this._cacheFloat2(t, e.x, e.y) && (this.engine.setFloat2(this._uniforms[t], e.x, e.y) || (this._valueCache[t] = null));
      }, n.prototype.setFloat2 = function(t, e, i) {
        this._cacheFloat2(t, e, i) && (this.engine.setFloat2(this._uniforms[t], e, i) || (this._valueCache[t] = null));
      }, n.prototype.setVector3 = function(t, e) {
        this._cacheFloat3(t, e.x, e.y, e.z) && (this.engine.setFloat3(this._uniforms[t], e.x, e.y, e.z) || (this._valueCache[t] = null));
      }, n.prototype.setFloat3 = function(t, e, i, r) {
        this._cacheFloat3(t, e, i, r) && (this.engine.setFloat3(this._uniforms[t], e, i, r) || (this._valueCache[t] = null));
      }, n.prototype.setVector4 = function(t, e) {
        this._cacheFloat4(t, e.x, e.y, e.z, e.w) && (this.engine.setFloat4(this._uniforms[t], e.x, e.y, e.z, e.w) || (this._valueCache[t] = null));
      }, n.prototype.setQuaternion = function(t, e) {
        this._cacheFloat4(t, e.x, e.y, e.z, e.w) && (this.engine.setFloat4(this._uniforms[t], e.x, e.y, e.z, e.w) || (this._valueCache[t] = null));
      }, n.prototype.setFloat4 = function(t, e, i, r, o) {
        this._cacheFloat4(t, e, i, r, o) && (this.engine.setFloat4(this._uniforms[t], e, i, r, o) || (this._valueCache[t] = null));
      }, n.prototype.setColor3 = function(t, e) {
        this._cacheFloat3(t, e.r, e.g, e.b) && (this.engine.setFloat3(this._uniforms[t], e.r, e.g, e.b) || (this._valueCache[t] = null));
      }, n.prototype.setColor4 = function(t, e, i) {
        this._cacheFloat4(t, e.r, e.g, e.b, i) && (this.engine.setFloat4(this._uniforms[t], e.r, e.g, e.b, i) || (this._valueCache[t] = null));
      }, n.prototype.setDirectColor4 = function(t, e) {
        this._cacheFloat4(t, e.r, e.g, e.b, e.a) && (this.engine.setFloat4(this._uniforms[t], e.r, e.g, e.b, e.a) || (this._valueCache[t] = null));
      }, n.prototype._getVertexShaderCode = function() {
        return this.vertexShader ? this.engine._getShaderSource(this.vertexShader) : null;
      }, n.prototype._getFragmentShaderCode = function() {
        return this.fragmentShader ? this.engine._getShaderSource(this.fragmentShader) : null;
      }, n;
    }(), ds = function() {
      function n(t, e) {
        if (t === void 0 && (t = null), this._MSAARenderBuffers = null, this._context = e, !t && !(t = e.createTexture()))
          throw new Error("Unable to create webGL texture");
        this.set(t);
      }
      return Object.defineProperty(n.prototype, "underlyingResource", { get: function() {
        return this._webGLTexture;
      }, enumerable: !1, configurable: !0 }), n.prototype.setUsage = function() {
      }, n.prototype.set = function(t) {
        this._webGLTexture = t;
      }, n.prototype.reset = function() {
        this._webGLTexture = null, this._MSAARenderBuffers = null;
      }, n.prototype.addMSAARenderBuffer = function(t) {
        this._MSAARenderBuffers || (this._MSAARenderBuffers = []), this._MSAARenderBuffers.push(t);
      }, n.prototype.releaseMSAARenderBuffers = function() {
        if (this._MSAARenderBuffers) {
          for (var t = 0, e = this._MSAARenderBuffers; t < e.length; t++) {
            var i = e[t];
            this._context.deleteRenderbuffer(i);
          }
          this._MSAARenderBuffers = null;
        }
      }, n.prototype.getMSAARenderBuffer = function(t) {
        var e, i;
        return t === void 0 && (t = 0), (i = (e = this._MSAARenderBuffers) === null || e === void 0 ? void 0 : e[t]) !== null && i !== void 0 ? i : null;
      }, n.prototype.release = function() {
        this.releaseMSAARenderBuffers(), this._webGLTexture && this._context.deleteTexture(this._webGLTexture), this.reset();
      }, n;
    }(), Ei = function() {
      function n(t, e) {
        e === void 0 && (e = !0), this.effect = null, this.defines = null, this.drawContext = t.createDrawContext(), e && (this.materialContext = t.createMaterialContext());
      }
      return n.IsWrapper = function(t) {
        return t.getPipelineContext === void 0;
      }, n.GetEffect = function(t) {
        return t.getPipelineContext === void 0 ? t.effect : t;
      }, n.prototype.setEffect = function(t, e, i) {
        var r;
        i === void 0 && (i = !0), this.effect = t, e !== void 0 && (this.defines = e), i && ((r = this.drawContext) === null || r === void 0 || r.reset());
      }, n.prototype.dispose = function() {
        var t;
        (t = this.drawContext) === null || t === void 0 || t.dispose();
      }, n;
    }(), ap = function() {
      function n(t) {
        t === void 0 && (t = !0), this._isStencilTestDirty = !1, this._isStencilMaskDirty = !1, this._isStencilFuncDirty = !1, this._isStencilOpDirty = !1, this.useStencilGlobalOnly = !1, t && this.reset();
      }
      return Object.defineProperty(n.prototype, "isDirty", { get: function() {
        return this._isStencilTestDirty || this._isStencilMaskDirty || this._isStencilFuncDirty || this._isStencilOpDirty;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "func", { get: function() {
        return this._func;
      }, set: function(t) {
        this._func !== t && (this._func = t, this._isStencilFuncDirty = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "funcRef", { get: function() {
        return this._funcRef;
      }, set: function(t) {
        this._funcRef !== t && (this._funcRef = t, this._isStencilFuncDirty = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "funcMask", { get: function() {
        return this._funcMask;
      }, set: function(t) {
        this._funcMask !== t && (this._funcMask = t, this._isStencilFuncDirty = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "opStencilFail", { get: function() {
        return this._opStencilFail;
      }, set: function(t) {
        this._opStencilFail !== t && (this._opStencilFail = t, this._isStencilOpDirty = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "opDepthFail", { get: function() {
        return this._opDepthFail;
      }, set: function(t) {
        this._opDepthFail !== t && (this._opDepthFail = t, this._isStencilOpDirty = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "opStencilDepthPass", { get: function() {
        return this._opStencilDepthPass;
      }, set: function(t) {
        this._opStencilDepthPass !== t && (this._opStencilDepthPass = t, this._isStencilOpDirty = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "mask", { get: function() {
        return this._mask;
      }, set: function(t) {
        this._mask !== t && (this._mask = t, this._isStencilMaskDirty = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "enabled", { get: function() {
        return this._enabled;
      }, set: function(t) {
        this._enabled !== t && (this._enabled = t, this._isStencilTestDirty = !0);
      }, enumerable: !1, configurable: !0 }), n.prototype.reset = function() {
        var t;
        this.stencilMaterial = void 0, (t = this.stencilGlobal) === null || t === void 0 || t.reset(), this._isStencilTestDirty = !0, this._isStencilMaskDirty = !0, this._isStencilFuncDirty = !0, this._isStencilOpDirty = !0;
      }, n.prototype.apply = function(t) {
        var e;
        if (t) {
          var i = !this.useStencilGlobalOnly && !!(!((e = this.stencilMaterial) === null || e === void 0) && e.enabled);
          this.enabled = i ? this.stencilMaterial.enabled : this.stencilGlobal.enabled, this.func = i ? this.stencilMaterial.func : this.stencilGlobal.func, this.funcRef = i ? this.stencilMaterial.funcRef : this.stencilGlobal.funcRef, this.funcMask = i ? this.stencilMaterial.funcMask : this.stencilGlobal.funcMask, this.opStencilFail = i ? this.stencilMaterial.opStencilFail : this.stencilGlobal.opStencilFail, this.opDepthFail = i ? this.stencilMaterial.opDepthFail : this.stencilGlobal.opDepthFail, this.opStencilDepthPass = i ? this.stencilMaterial.opStencilDepthPass : this.stencilGlobal.opStencilDepthPass, this.mask = i ? this.stencilMaterial.mask : this.stencilGlobal.mask, this.isDirty && (this._isStencilTestDirty && (this.enabled ? t.enable(t.STENCIL_TEST) : t.disable(t.STENCIL_TEST), this._isStencilTestDirty = !1), this._isStencilMaskDirty && (t.stencilMask(this.mask), this._isStencilMaskDirty = !1), this._isStencilFuncDirty && (t.stencilFunc(this.func, this.funcRef, this.funcMask), this._isStencilFuncDirty = !1), this._isStencilOpDirty && (t.stencilOp(this.opStencilFail, this.opDepthFail, this.opStencilDepthPass), this._isStencilOpDirty = !1));
        }
      }, n;
    }(), R1 = function() {
    }, Qe = function() {
      function n(t, e, i, r) {
        var o, a, s, l, c, u, h, d, p, f, m, g = this;
        this._name = "WebGL", this._isDisposed = !1, this.forcePOTTextures = !1, this.isFullscreen = !1, this.cullBackFaces = null, this.renderEvenInBackground = !0, this.preventCacheWipeBetweenFrames = !1, this.validateShaderPrograms = !1, this._useReverseDepthBuffer = !1, this.isNDCHalfZRange = !1, this.hasOriginBottomLeft = !0, this.disableUniformBuffers = !1, this.onDisposeObservable = new H(), this._frameId = 0, this._uniformBuffers = new Array(), this._storageBuffers = new Array(), this._webGLVersion = 1, this._windowIsBackground = !1, this._highPrecisionShadersAllowed = !0, this._badOS = !1, this._badDesktopOS = !1, this._renderingQueueLaunched = !1, this._activeRenderLoops = new Array(), this.onContextLostObservable = new H(), this.onContextRestoredObservable = new H(), this._contextWasLost = !1, this._doNotHandleContextLost = !1, this.disableVertexArrayObjects = !1, this._colorWrite = !0, this._colorWriteChanged = !0, this._depthCullingState = new np(), this._stencilStateComposer = new ap(), this._stencilState = new qm(), this._alphaState = new Qm(), this._alphaMode = _.ALPHA_ADD, this._alphaEquation = _.ALPHA_DISABLE, this._internalTexturesCache = new Array(), this._renderTargetWrapperCache = new Array(), this._activeChannel = 0, this._currentTextureChannel = -1, this._boundTexturesCache = {}, this._compiledEffects = {}, this._vertexAttribArraysEnabled = [], this._currentRenderTarget = null, this._uintIndicesCurrentlySet = !1, this._currentBoundBuffer = new Array(), this._currentFramebuffer = null, this._dummyFramebuffer = null, this._currentBufferPointers = new Array(), this._currentInstanceLocations = new Array(), this._currentInstanceBuffers = new Array(), this._vaoRecordInProgress = !1, this._mustWipeVertexAttributes = !1, this._nextFreeTextureSlots = new Array(), this._maxSimultaneousTextures = 0, this._maxMSAASamplesOverride = null, this._activeRequests = new Array(), this.adaptToDeviceRatio = !1, this._lastDevicePixelRatio = 1, this._transformTextureUrl = null, this.hostInformation = { isMobile: !1 }, this.premultipliedAlpha = !0, this.onBeforeTextureInitObservable = new H(), this._isWebGPU = !1, this._snapshotRenderingMode = _.SNAPSHOTRENDERING_STANDARD, this._viewportCached = { x: 0, y: 0, z: 0, w: 0 }, this._unpackFlipYCached = null, this.enableUnpackFlipYCached = !0, this._boundUniforms = {}, this.startTime = It.Now;
        var y = null;
        i = i || {}, this._creationOptions = i, this.adaptToDeviceRatio = r != null && r, this._stencilStateComposer.stencilGlobal = this._stencilState, Ti.SetMatrixPrecision(!!i.useHighPrecisionMatrix), i.antialias = e ?? i.antialias, i.deterministicLockstep = (o = i.deterministicLockstep) !== null && o !== void 0 && o, i.lockstepMaxSteps = (a = i.lockstepMaxSteps) !== null && a !== void 0 ? a : 4, i.timeStep = (s = i.timeStep) !== null && s !== void 0 ? s : 1 / 60, i.audioEngine = (l = i.audioEngine) === null || l === void 0 || l, i.stencil = (c = i.stencil) === null || c === void 0 || c, this._audioContext = (h = (u = i.audioEngineOptions) === null || u === void 0 ? void 0 : u.audioContext) !== null && h !== void 0 ? h : null, this._audioDestination = (p = (d = i.audioEngineOptions) === null || d === void 0 ? void 0 : d.audioDestination) !== null && p !== void 0 ? p : null, this.premultipliedAlpha = (f = i.premultipliedAlpha) === null || f === void 0 || f, this.useExactSrgbConversions = (m = i.useExactSrgbConversions) !== null && m !== void 0 && m, this._doNotHandleContextLost = !!i.doNotHandleContextLost, this._isStencilEnable = !!i.stencil, r = r || i.adaptToDeviceRatio || !1;
        var b = Gi() && window.devicePixelRatio || 1, T = i.limitDeviceRatio || b;
        if (this._hardwareScalingLevel = r ? 1 / Math.min(T, b) : 1, this._lastDevicePixelRatio = b, t) {
          if (t.getContext) {
            if (y = t, this._renderingCanvas = y, i.preserveDrawingBuffer === void 0 && (i.preserveDrawingBuffer = !1), i.xrCompatible === void 0 && (i.xrCompatible = !0), navigator && navigator.userAgent) {
              this._setupMobileChecks();
              for (var S = navigator.userAgent, E = 0, A = n.ExceptionList; E < A.length; E++) {
                var R = A[E], C = R.key, L = R.targets;
                if (new RegExp(C).test(S)) {
                  if (R.capture && R.captureConstraint) {
                    var I = R.capture, O = R.captureConstraint, w = new RegExp(I).exec(S);
                    if (w && w.length > 0 && parseInt(w[w.length - 1]) >= O)
                      continue;
                  }
                  for (var z = 0, V = L; z < V.length; z++)
                    switch (V[z]) {
                      case "uniformBuffer":
                        this.disableUniformBuffers = !0;
                        break;
                      case "vao":
                        this.disableVertexArrayObjects = !0;
                        break;
                      case "antialias":
                        i.antialias = !1;
                        break;
                      case "maxMSAASamples":
                        this._maxMSAASamplesOverride = 1;
                    }
                }
              }
            }
            if (this._doNotHandleContextLost || (this._onContextLost = function(X) {
              X.preventDefault(), g._contextWasLost = !0, q.Warn("WebGL context lost."), g.onContextLostObservable.notifyObservers(g);
            }, this._onContextRestored = function() {
              g._restoreEngineAfterContextLost(function() {
                return g._initGLContext();
              });
            }, y.addEventListener("webglcontextlost", this._onContextLost, !1), y.addEventListener("webglcontextrestored", this._onContextRestored, !1), i.powerPreference = i.powerPreference || "high-performance"), this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent), this._badDesktopOS && (i.xrCompatible = !1), !i.disableWebGL2Support)
              try {
                this._gl = y.getContext("webgl2", i) || y.getContext("experimental-webgl2", i), this._gl && (this._webGLVersion = 2, this._shaderPlatformName = "WEBGL2", this._gl.deleteQuery || (this._webGLVersion = 1, this._shaderPlatformName = "WEBGL1"));
              } catch {
              }
            if (!this._gl) {
              if (!y)
                throw new Error("The provided canvas is null or undefined.");
              try {
                this._gl = y.getContext("webgl", i) || y.getContext("experimental-webgl", i);
              } catch {
                throw new Error("WebGL not supported");
              }
            }
            if (!this._gl)
              throw new Error("WebGL not supported");
          } else {
            this._gl = t, this._renderingCanvas = this._gl.canvas, this._gl.renderbufferStorageMultisample ? (this._webGLVersion = 2, this._shaderPlatformName = "WEBGL2") : this._shaderPlatformName = "WEBGL1";
            var Y = this._gl.getContextAttributes();
            Y && (i.stencil = Y.stencil);
          }
          this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE), i.useHighPrecisionFloats !== void 0 && (this._highPrecisionShadersAllowed = i.useHighPrecisionFloats), this.resize(), this._initGLContext(), this._initFeatures();
          for (var ee = 0; ee < this._caps.maxVertexAttribs; ee++)
            this._currentBufferPointers[ee] = new R1();
          this._shaderProcessor = this.webGLVersion > 1 ? new op() : new x1(), this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);
          var J = "Babylon.js v".concat(n.Version);
          console.log(J + " - ".concat(this.description)), this._renderingCanvas && this._renderingCanvas.setAttribute && this._renderingCanvas.setAttribute("data-engine", J);
        }
      }
      return Object.defineProperty(n, "NpmPackage", { get: function() {
        return "babylonjs@6.32.1";
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "Version", { get: function() {
        return "6.32.1";
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "description", { get: function() {
        var t = this.name + this.webGLVersion;
        return this._caps.parallelShaderCompile && (t += " - Parallel shader compilation"), t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "name", { get: function() {
        return this._name;
      }, set: function(t) {
        this._name = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "version", { get: function() {
        return this._webGLVersion;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isDisposed", { get: function() {
        return this._isDisposed;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "ShadersRepository", { get: function() {
        return Jt.ShadersRepository;
      }, set: function(t) {
        Jt.ShadersRepository = t;
      }, enumerable: !1, configurable: !0 }), n.prototype._getShaderProcessor = function(t) {
        return this._shaderProcessor;
      }, Object.defineProperty(n.prototype, "useReverseDepthBuffer", { get: function() {
        return this._useReverseDepthBuffer;
      }, set: function(t) {
        t !== this._useReverseDepthBuffer && (this._useReverseDepthBuffer = t, this._depthCullingState.depthFunc = t ? _.GEQUAL : _.LEQUAL);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "frameId", { get: function() {
        return this._frameId;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "supportsUniformBuffers", { get: function() {
        return this.webGLVersion > 1 && !this.disableUniformBuffers;
      }, enumerable: !1, configurable: !0 }), n.prototype.getCreationOptions = function() {
        return this._creationOptions;
      }, Object.defineProperty(n.prototype, "_shouldUseHighPrecisionShader", { get: function() {
        return !(!this._caps.highPrecisionShaderSupported || !this._highPrecisionShadersAllowed);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "needPOTTextures", { get: function() {
        return this._webGLVersion < 2 || this.forcePOTTextures;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "activeRenderLoops", { get: function() {
        return this._activeRenderLoops;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "doNotHandleContextLost", { get: function() {
        return this._doNotHandleContextLost;
      }, set: function(t) {
        this._doNotHandleContextLost = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "_supportsHardwareTextureRescaling", { get: function() {
        return !1;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "framebufferDimensionsObject", { set: function(t) {
        this._framebufferDimensionsObject = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "currentViewport", { get: function() {
        return this._cachedViewport;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "emptyTexture", { get: function() {
        return this._emptyTexture || (this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, _.TEXTUREFORMAT_RGBA, !1, !1, _.TEXTURE_NEAREST_SAMPLINGMODE)), this._emptyTexture;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "emptyTexture3D", { get: function() {
        return this._emptyTexture3D || (this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, _.TEXTUREFORMAT_RGBA, !1, !1, _.TEXTURE_NEAREST_SAMPLINGMODE)), this._emptyTexture3D;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "emptyTexture2DArray", { get: function() {
        return this._emptyTexture2DArray || (this._emptyTexture2DArray = this.createRawTexture2DArray(new Uint8Array(4), 1, 1, 1, _.TEXTUREFORMAT_RGBA, !1, !1, _.TEXTURE_NEAREST_SAMPLINGMODE)), this._emptyTexture2DArray;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "emptyCubeTexture", { get: function() {
        if (!this._emptyCubeTexture) {
          var t = new Uint8Array(4), e = [t, t, t, t, t, t];
          this._emptyCubeTexture = this.createRawCubeTexture(e, 1, _.TEXTUREFORMAT_RGBA, _.TEXTURETYPE_UNSIGNED_INT, !1, !1, _.TEXTURE_NEAREST_SAMPLINGMODE);
        }
        return this._emptyCubeTexture;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isWebGPU", { get: function() {
        return this._isWebGPU;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "shaderPlatformName", { get: function() {
        return this._shaderPlatformName;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "snapshotRendering", { get: function() {
        return !1;
      }, set: function(t) {
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "snapshotRenderingMode", { get: function() {
        return this._snapshotRenderingMode;
      }, set: function(t) {
        this._snapshotRenderingMode = t;
      }, enumerable: !1, configurable: !0 }), n.prototype.snapshotRenderingReset = function() {
        this.snapshotRendering = !1;
      }, n._CreateCanvas = function(t, e) {
        if (typeof document > "u")
          return new OffscreenCanvas(t, e);
        var i = document.createElement("canvas");
        return i.width = t, i.height = e, i;
      }, n.prototype.createCanvas = function(t, e) {
        return n._CreateCanvas(t, e);
      }, n.prototype.createCanvasImage = function() {
        return document.createElement("img");
      }, n.prototype._setupMobileChecks = function() {
        var t = this;
        navigator && navigator.userAgent && (this._checkForMobile = function() {
          var e = navigator.userAgent;
          t.hostInformation.isMobile = e.indexOf("Mobile") !== -1 || e.indexOf("Mac") !== -1 && hs() && "ontouchend" in document;
        }, this._checkForMobile(), Gi() && window.addEventListener("resize", this._checkForMobile));
      }, n.prototype._restoreEngineAfterContextLost = function(t) {
        var e = this;
        setTimeout(function() {
          return Ft(e, void 0, void 0, function() {
            var i, r, o, a, s;
            return Bt(this, function(l) {
              switch (l.label) {
                case 0:
                  return this._dummyFramebuffer = null, i = this._depthCullingState.depthTest, r = this._depthCullingState.depthFunc, o = this._depthCullingState.depthMask, a = this._stencilState.stencilTest, [4, t()];
                case 1:
                  return l.sent(), this.wipeCaches(!0), this._rebuildEffects(), (s = this._rebuildComputeEffects) === null || s === void 0 || s.call(this), this._rebuildBuffers(), this._rebuildInternalTextures(), this._rebuildRenderTargetWrappers(), this.wipeCaches(!0), this._depthCullingState.depthTest = i, this._depthCullingState.depthFunc = r, this._depthCullingState.depthMask = o, this._stencilState.stencilTest = a, q.Warn(this.name + " context successfully restored."), this.onContextRestoredObservable.notifyObservers(this), this._contextWasLost = !1, [2];
              }
            });
          });
        }, 0);
      }, n.prototype._sharedInit = function(t) {
        this._renderingCanvas = t;
      }, n.prototype._getShaderProcessingContext = function(t) {
        return null;
      }, n.prototype._rebuildInternalTextures = function() {
        for (var t = 0, e = this._internalTexturesCache.slice(); t < e.length; t++)
          e[t]._rebuild();
      }, n.prototype._rebuildRenderTargetWrappers = function() {
        for (var t = 0, e = this._renderTargetWrapperCache.slice(); t < e.length; t++)
          e[t]._rebuild();
      }, n.prototype._rebuildEffects = function() {
        for (var t in this._compiledEffects) {
          var e = this._compiledEffects[t];
          e._pipelineContext = null, e._wasPreviouslyReady = !1, e._prepareEffect();
        }
        Jt.ResetCache();
      }, n.prototype.areAllEffectsReady = function() {
        for (var t in this._compiledEffects)
          if (!this._compiledEffects[t].isReady())
            return !1;
        return !0;
      }, n.prototype._rebuildBuffers = function() {
        for (var t = 0, e = this._uniformBuffers; t < e.length; t++)
          e[t]._rebuild();
        for (var i = 0, r = this._storageBuffers; i < r.length; i++)
          r[i]._rebuild();
      }, n.prototype._initGLContext = function() {
        var t;
        this._caps = { maxTexturesImageUnits: this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS), maxCombinedTexturesImageUnits: this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS), maxVertexTextureImageUnits: this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS), maxTextureSize: this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE), maxSamples: this._webGLVersion > 1 ? this._gl.getParameter(this._gl.MAX_SAMPLES) : 1, maxCubemapTextureSize: this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE), maxRenderTextureSize: this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE), maxVertexAttribs: this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS), maxVaryingVectors: this._gl.getParameter(this._gl.MAX_VARYING_VECTORS), maxFragmentUniformVectors: this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS), maxVertexUniformVectors: this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS), parallelShaderCompile: this._gl.getExtension("KHR_parallel_shader_compile") || void 0, standardDerivatives: this._webGLVersion > 1 || this._gl.getExtension("OES_standard_derivatives") !== null, maxAnisotropy: 1, astc: this._gl.getExtension("WEBGL_compressed_texture_astc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_astc"), bptc: this._gl.getExtension("EXT_texture_compression_bptc") || this._gl.getExtension("WEBKIT_EXT_texture_compression_bptc"), s3tc: this._gl.getExtension("WEBGL_compressed_texture_s3tc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"), s3tc_srgb: this._gl.getExtension("WEBGL_compressed_texture_s3tc_srgb") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc_srgb"), pvrtc: this._gl.getExtension("WEBGL_compressed_texture_pvrtc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"), etc1: this._gl.getExtension("WEBGL_compressed_texture_etc1") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"), etc2: this._gl.getExtension("WEBGL_compressed_texture_etc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc") || this._gl.getExtension("WEBGL_compressed_texture_es3_0"), textureAnisotropicFilterExtension: this._gl.getExtension("EXT_texture_filter_anisotropic") || this._gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic") || this._gl.getExtension("MOZ_EXT_texture_filter_anisotropic"), uintIndices: this._webGLVersion > 1 || this._gl.getExtension("OES_element_index_uint") !== null, fragmentDepthSupported: this._webGLVersion > 1 || this._gl.getExtension("EXT_frag_depth") !== null, highPrecisionShaderSupported: !1, timerQuery: this._gl.getExtension("EXT_disjoint_timer_query_webgl2") || this._gl.getExtension("EXT_disjoint_timer_query"), supportOcclusionQuery: this._webGLVersion > 1, canUseTimestampForTimerQuery: !1, drawBuffersExtension: !1, maxMSAASamples: 1, colorBufferFloat: !!(this._webGLVersion > 1 && this._gl.getExtension("EXT_color_buffer_float")), supportFloatTexturesResolve: !1, colorBufferHalfFloat: !!(this._webGLVersion > 1 && this._gl.getExtension("EXT_color_buffer_half_float")), textureFloat: !!(this._webGLVersion > 1 || this._gl.getExtension("OES_texture_float")), textureHalfFloat: !!(this._webGLVersion > 1 || this._gl.getExtension("OES_texture_half_float")), textureHalfFloatRender: !1, textureFloatLinearFiltering: !1, textureFloatRender: !1, textureHalfFloatLinearFiltering: !1, vertexArrayObject: !1, instancedArrays: !1, textureLOD: !!(this._webGLVersion > 1 || this._gl.getExtension("EXT_shader_texture_lod")), texelFetch: this._webGLVersion !== 1, blendMinMax: !1, multiview: this._gl.getExtension("OVR_multiview2"), oculusMultiview: this._gl.getExtension("OCULUS_multiview"), depthTextureExtension: !1, canUseGLInstanceID: this._webGLVersion > 1, canUseGLVertexID: this._webGLVersion > 1, supportComputeShaders: !1, supportSRGBBuffers: !1, supportTransformFeedbacks: this._webGLVersion > 1, textureMaxLevel: this._webGLVersion > 1, texture2DArrayMaxLayerCount: this._webGLVersion > 1 ? this._gl.getParameter(this._gl.MAX_ARRAY_TEXTURE_LAYERS) : 128, disableMorphTargetTexture: !1 }, this._caps.supportFloatTexturesResolve = this._caps.colorBufferFloat, this._glVersion = this._gl.getParameter(this._gl.VERSION);
        var e = this._gl.getExtension("WEBGL_debug_renderer_info");
        if (e != null && (this._glRenderer = this._gl.getParameter(e.UNMASKED_RENDERER_WEBGL), this._glVendor = this._gl.getParameter(e.UNMASKED_VENDOR_WEBGL)), this._glVendor || (this._glVendor = this._gl.getParameter(this._gl.VENDOR) || "Unknown vendor"), this._glRenderer || (this._glRenderer = this._gl.getParameter(this._gl.RENDERER) || "Unknown renderer"), this._gl.HALF_FLOAT_OES !== 36193 && (this._gl.HALF_FLOAT_OES = 36193), this._gl.RGBA16F !== 34842 && (this._gl.RGBA16F = 34842), this._gl.RGBA32F !== 34836 && (this._gl.RGBA32F = 34836), this._gl.DEPTH24_STENCIL8 !== 35056 && (this._gl.DEPTH24_STENCIL8 = 35056), this._caps.timerQuery && (this._webGLVersion === 1 && (this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery)), this._caps.canUseTimestampForTimerQuery = ((t = this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT)) !== null && t !== void 0 ? t : 0) > 0), this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0, this._caps.textureFloatLinearFiltering = !(!this._caps.textureFloat || !this._gl.getExtension("OES_texture_float_linear")), this._caps.textureFloatRender = !(!this._caps.textureFloat || !this._canRenderToFloatFramebuffer()), this._caps.textureHalfFloatLinearFiltering = !!(this._webGLVersion > 1 || this._caps.textureHalfFloat && this._gl.getExtension("OES_texture_half_float_linear")), this._caps.astc && (this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR), this._caps.bptc && (this._gl.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT = this._caps.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT), this._caps.s3tc_srgb && (this._gl.COMPRESSED_SRGB_S3TC_DXT1_EXT = this._caps.s3tc_srgb.COMPRESSED_SRGB_S3TC_DXT1_EXT, this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT = this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT = this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT), this._caps.etc2 && (this._gl.COMPRESSED_SRGB8_ETC2 = this._caps.etc2.COMPRESSED_SRGB8_ETC2, this._gl.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = this._caps.etc2.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC), this._webGLVersion > 1 && this._gl.HALF_FLOAT_OES !== 5131 && (this._gl.HALF_FLOAT_OES = 5131), this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer(), this._webGLVersion > 1)
          this._caps.drawBuffersExtension = !0, this._caps.maxMSAASamples = this._maxMSAASamplesOverride !== null ? this._maxMSAASamplesOverride : this._gl.getParameter(this._gl.MAX_SAMPLES);
        else {
          var i = this._gl.getExtension("WEBGL_draw_buffers");
          if (i !== null) {
            this._caps.drawBuffersExtension = !0, this._gl.drawBuffers = i.drawBuffersWEBGL.bind(i), this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
            for (var r = 0; r < 16; r++)
              this._gl["COLOR_ATTACHMENT" + r + "_WEBGL"] = i["COLOR_ATTACHMENT" + r + "_WEBGL"];
          }
        }
        if (this._webGLVersion > 1)
          this._caps.depthTextureExtension = !0;
        else {
          var o = this._gl.getExtension("WEBGL_depth_texture");
          o != null && (this._caps.depthTextureExtension = !0, this._gl.UNSIGNED_INT_24_8 = o.UNSIGNED_INT_24_8_WEBGL);
        }
        if (this.disableVertexArrayObjects)
          this._caps.vertexArrayObject = !1;
        else if (this._webGLVersion > 1)
          this._caps.vertexArrayObject = !0;
        else {
          var a = this._gl.getExtension("OES_vertex_array_object");
          a != null && (this._caps.vertexArrayObject = !0, this._gl.createVertexArray = a.createVertexArrayOES.bind(a), this._gl.bindVertexArray = a.bindVertexArrayOES.bind(a), this._gl.deleteVertexArray = a.deleteVertexArrayOES.bind(a));
        }
        if (this._webGLVersion > 1)
          this._caps.instancedArrays = !0;
        else {
          var s = this._gl.getExtension("ANGLE_instanced_arrays");
          s != null ? (this._caps.instancedArrays = !0, this._gl.drawArraysInstanced = s.drawArraysInstancedANGLE.bind(s), this._gl.drawElementsInstanced = s.drawElementsInstancedANGLE.bind(s), this._gl.vertexAttribDivisor = s.vertexAttribDivisorANGLE.bind(s)) : this._caps.instancedArrays = !1;
        }
        if (this._gl.getShaderPrecisionFormat) {
          var l = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT), c = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
          l && c && (this._caps.highPrecisionShaderSupported = l.precision !== 0 && c.precision !== 0);
        }
        if (this._webGLVersion > 1)
          this._caps.blendMinMax = !0;
        else {
          var u = this._gl.getExtension("EXT_blend_minmax");
          u != null && (this._caps.blendMinMax = !0, this._gl.MAX = u.MAX_EXT, this._gl.MIN = u.MIN_EXT);
        }
        if (!this._caps.supportSRGBBuffers) {
          if (this._webGLVersion > 1)
            this._caps.supportSRGBBuffers = !0, this._glSRGBExtensionValues = { SRGB: WebGL2RenderingContext.SRGB, SRGB8: WebGL2RenderingContext.SRGB8, SRGB8_ALPHA8: WebGL2RenderingContext.SRGB8_ALPHA8 };
          else {
            var h = this._gl.getExtension("EXT_sRGB");
            h != null && (this._caps.supportSRGBBuffers = !0, this._glSRGBExtensionValues = { SRGB: h.SRGB_EXT, SRGB8: h.SRGB_ALPHA_EXT, SRGB8_ALPHA8: h.SRGB_ALPHA_EXT });
          }
          this._caps.supportSRGBBuffers = this._caps.supportSRGBBuffers && !(!this._creationOptions || !this._creationOptions.forceSRGBBufferSupportState);
        }
        this._depthCullingState.depthTest = !0, this._depthCullingState.depthFunc = this._gl.LEQUAL, this._depthCullingState.depthMask = !0, this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;
        for (var d = 0; d < this._maxSimultaneousTextures; d++)
          this._nextFreeTextureSlots.push(d);
        this._glRenderer === "Mali-G72" && (this._caps.disableMorphTargetTexture = !0);
      }, n.prototype._initFeatures = function() {
        this._features = { forceBitmapOverHTMLImageElement: !1, supportRenderAndCopyToLodForFloatTextures: this._webGLVersion !== 1, supportDepthStencilTexture: this._webGLVersion !== 1, supportShadowSamplers: this._webGLVersion !== 1, uniformBufferHardCheckMatrix: !1, allowTexturePrefiltering: this._webGLVersion !== 1, trackUbosInFrame: !1, checkUbosContentBeforeUpload: !1, supportCSM: this._webGLVersion !== 1, basisNeedsPOT: this._webGLVersion === 1, support3DTextures: this._webGLVersion !== 1, needTypeSuffixInShaderConstants: this._webGLVersion !== 1, supportMSAA: this._webGLVersion !== 1, supportSSAO2: this._webGLVersion !== 1, supportExtendedTextureFormats: this._webGLVersion !== 1, supportSwitchCaseInShader: this._webGLVersion !== 1, supportSyncTextureRead: !0, needsInvertingBitmap: !0, useUBOBindingCache: !0, needShaderCodeInlining: !1, needToAlwaysBindUniformBuffers: !1, supportRenderPasses: !1, supportSpriteInstancing: !0, forceVertexBufferStrideMultiple4Bytes: !1, _collectUbosUpdatedInFrame: !1 };
      }, Object.defineProperty(n.prototype, "webGLVersion", { get: function() {
        return this._webGLVersion;
      }, enumerable: !1, configurable: !0 }), n.prototype.getClassName = function() {
        return "ThinEngine";
      }, Object.defineProperty(n.prototype, "isStencilEnable", { get: function() {
        return this._isStencilEnable;
      }, enumerable: !1, configurable: !0 }), n.prototype._prepareWorkingCanvas = function() {
        if (!this._workingCanvas) {
          this._workingCanvas = this.createCanvas(1, 1);
          var t = this._workingCanvas.getContext("2d");
          t && (this._workingContext = t);
        }
      }, n.prototype.resetTextureCache = function() {
        for (var t in this._boundTexturesCache)
          Object.prototype.hasOwnProperty.call(this._boundTexturesCache, t) && (this._boundTexturesCache[t] = null);
        this._currentTextureChannel = -1;
      }, n.prototype.getInfo = function() {
        return this.getGlInfo();
      }, n.prototype.getGlInfo = function() {
        return { vendor: this._glVendor, renderer: this._glRenderer, version: this._glVersion };
      }, n.prototype.setHardwareScalingLevel = function(t) {
        this._hardwareScalingLevel = t, this.resize();
      }, n.prototype.getHardwareScalingLevel = function() {
        return this._hardwareScalingLevel;
      }, n.prototype.getLoadedTexturesCache = function() {
        return this._internalTexturesCache;
      }, n.prototype.getCaps = function() {
        return this._caps;
      }, n.prototype.stopRenderLoop = function(t) {
        if (!t)
          return this._activeRenderLoops.length = 0, void this._cancelFrame();
        var e = this._activeRenderLoops.indexOf(t);
        e >= 0 && (this._activeRenderLoops.splice(e, 1), this._activeRenderLoops.length == 0 && this._cancelFrame());
      }, n.prototype._cancelFrame = function() {
        if (this._renderingQueueLaunched && this._frameHandler) {
          if (this._renderingQueueLaunched = !1, Gi()) {
            var t = (this.getHostWindow() || window).cancelAnimationFrame;
            if (typeof t == "function")
              return t(this._frameHandler);
          } else if (typeof cancelAnimationFrame == "function")
            return cancelAnimationFrame(this._frameHandler);
          return clearTimeout(this._frameHandler);
        }
      }, n.prototype._renderLoop = function() {
        if (!this._contextWasLost) {
          var t = !0;
          if ((this._isDisposed || !this.renderEvenInBackground && this._windowIsBackground) && (t = !1), t) {
            this.beginFrame();
            for (var e = 0; e < this._activeRenderLoops.length; e++)
              (0, this._activeRenderLoops[e])();
            this.endFrame();
          }
        }
        this._activeRenderLoops.length > 0 ? this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow()) : this._renderingQueueLaunched = !1;
      }, n.prototype.getRenderingCanvas = function() {
        return this._renderingCanvas;
      }, n.prototype.getAudioContext = function() {
        return this._audioContext;
      }, n.prototype.getAudioDestination = function() {
        return this._audioDestination;
      }, n.prototype.getHostWindow = function() {
        return Gi() ? this._renderingCanvas && this._renderingCanvas.ownerDocument && this._renderingCanvas.ownerDocument.defaultView ? this._renderingCanvas.ownerDocument.defaultView : window : null;
      }, n.prototype.getRenderWidth = function(t) {
        return t === void 0 && (t = !1), !t && this._currentRenderTarget ? this._currentRenderTarget.width : this._framebufferDimensionsObject ? this._framebufferDimensionsObject.framebufferWidth : this._gl.drawingBufferWidth;
      }, n.prototype.getRenderHeight = function(t) {
        return t === void 0 && (t = !1), !t && this._currentRenderTarget ? this._currentRenderTarget.height : this._framebufferDimensionsObject ? this._framebufferDimensionsObject.framebufferHeight : this._gl.drawingBufferHeight;
      }, n.prototype._queueNewFrame = function(t, e) {
        return n.QueueNewFrame(t, e);
      }, n.prototype.runRenderLoop = function(t) {
        var e = this;
        this._activeRenderLoops.indexOf(t) === -1 && (this._activeRenderLoops.push(t), this._renderingQueueLaunched || (this._renderingQueueLaunched = !0, this._boundRenderFunction = function() {
          return e._renderLoop();
        }, this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow())));
      }, n.prototype.clear = function(t, e, i, r) {
        var o, a;
        r === void 0 && (r = !1);
        var s = this.stencilStateComposer.useStencilGlobalOnly;
        this.stencilStateComposer.useStencilGlobalOnly = !0, this.applyStates(), this.stencilStateComposer.useStencilGlobalOnly = s;
        var l = 0;
        if (e && t) {
          var c = !0;
          if (this._currentRenderTarget) {
            var u = (o = this._currentRenderTarget.texture) === null || o === void 0 ? void 0 : o.format;
            if (u === _.TEXTUREFORMAT_RED_INTEGER || u === _.TEXTUREFORMAT_RG_INTEGER || u === _.TEXTUREFORMAT_RGB_INTEGER || u === _.TEXTUREFORMAT_RGBA_INTEGER) {
              var h = (a = this._currentRenderTarget.texture) === null || a === void 0 ? void 0 : a.type;
              h === _.TEXTURETYPE_UNSIGNED_INTEGER || h === _.TEXTURETYPE_UNSIGNED_SHORT ? (n._TempClearColorUint32[0] = 255 * t.r, n._TempClearColorUint32[1] = 255 * t.g, n._TempClearColorUint32[2] = 255 * t.b, n._TempClearColorUint32[3] = 255 * t.a, this._gl.clearBufferuiv(this._gl.COLOR, 0, n._TempClearColorUint32), c = !1) : (n._TempClearColorInt32[0] = 255 * t.r, n._TempClearColorInt32[1] = 255 * t.g, n._TempClearColorInt32[2] = 255 * t.b, n._TempClearColorInt32[3] = 255 * t.a, this._gl.clearBufferiv(this._gl.COLOR, 0, n._TempClearColorInt32), c = !1);
            }
          }
          c && (this._gl.clearColor(t.r, t.g, t.b, t.a !== void 0 ? t.a : 1), l |= this._gl.COLOR_BUFFER_BIT);
        }
        i && (this.useReverseDepthBuffer ? (this._depthCullingState.depthFunc = this._gl.GEQUAL, this._gl.clearDepth(0)) : this._gl.clearDepth(1), l |= this._gl.DEPTH_BUFFER_BIT), r && (this._gl.clearStencil(0), l |= this._gl.STENCIL_BUFFER_BIT), this._gl.clear(l);
      }, n.prototype._viewport = function(t, e, i, r) {
        t === this._viewportCached.x && e === this._viewportCached.y && i === this._viewportCached.z && r === this._viewportCached.w || (this._viewportCached.x = t, this._viewportCached.y = e, this._viewportCached.z = i, this._viewportCached.w = r, this._gl.viewport(t, e, i, r));
      }, n.prototype.setViewport = function(t, e, i) {
        var r = e || this.getRenderWidth(), o = i || this.getRenderHeight(), a = t.x || 0, s = t.y || 0;
        this._cachedViewport = t, this._viewport(a * r, s * o, r * t.width, o * t.height);
      }, n.prototype.beginFrame = function() {
      }, n.prototype.endFrame = function() {
        this._badOS && this.flushFramebuffer(), this._frameId++;
      }, n.prototype.resize = function(t) {
        var e, i;
        if (t === void 0 && (t = !1), this.adaptToDeviceRatio) {
          var r = Gi() && window.devicePixelRatio || 1, o = this._lastDevicePixelRatio / r;
          this._lastDevicePixelRatio = r, this._hardwareScalingLevel *= o;
        }
        if (Gi() && hs())
          if (this._renderingCanvas) {
            var a = this._renderingCanvas.getBoundingClientRect ? this._renderingCanvas.getBoundingClientRect() : { width: this._renderingCanvas.width * this._hardwareScalingLevel, height: this._renderingCanvas.height * this._hardwareScalingLevel };
            e = this._renderingCanvas.clientWidth || a.width || this._renderingCanvas.width || 100, i = this._renderingCanvas.clientHeight || a.height || this._renderingCanvas.height || 100;
          } else
            e = window.innerWidth, i = window.innerHeight;
        else
          e = this._renderingCanvas ? this._renderingCanvas.width : 100, i = this._renderingCanvas ? this._renderingCanvas.height : 100;
        this.setSize(e / this._hardwareScalingLevel, i / this._hardwareScalingLevel, t);
      }, n.prototype.setSize = function(t, e, i) {
        return i === void 0 && (i = !1), !(!this._renderingCanvas || (t |= 0, e |= 0, !i && this._renderingCanvas.width === t && this._renderingCanvas.height === e || (this._renderingCanvas.width = t, this._renderingCanvas.height = e, 0)));
      }, n.prototype.bindFramebuffer = function(t, e, i, r, o, a, s) {
        var l, c, u, h, d, p;
        e === void 0 && (e = 0), a === void 0 && (a = 0), s === void 0 && (s = 0);
        var f = t;
        this._currentRenderTarget && this.unBindFramebuffer(this._currentRenderTarget), this._currentRenderTarget = t, this._bindUnboundFramebuffer(f._MSAAFramebuffer ? f._MSAAFramebuffer : f._framebuffer);
        var m = this._gl;
        t.isMulti || (t.is2DArray ? m.framebufferTextureLayer(m.FRAMEBUFFER, m.COLOR_ATTACHMENT0, (l = t.texture._hardwareTexture) === null || l === void 0 ? void 0 : l.underlyingResource, a, s) : t.isCube ? m.framebufferTexture2D(m.FRAMEBUFFER, m.COLOR_ATTACHMENT0, m.TEXTURE_CUBE_MAP_POSITIVE_X + e, (c = t.texture._hardwareTexture) === null || c === void 0 ? void 0 : c.underlyingResource, a) : f._currentLOD !== a && (m.framebufferTexture2D(m.FRAMEBUFFER, m.COLOR_ATTACHMENT0, m.TEXTURE_2D, (u = t.texture._hardwareTexture) === null || u === void 0 ? void 0 : u.underlyingResource, a), f._currentLOD = a));
        var g = t._depthStencilTexture;
        if (g) {
          var y = t._depthStencilTextureWithStencil ? m.DEPTH_STENCIL_ATTACHMENT : m.DEPTH_ATTACHMENT;
          t.is2DArray ? m.framebufferTextureLayer(m.FRAMEBUFFER, y, (h = g._hardwareTexture) === null || h === void 0 ? void 0 : h.underlyingResource, a, s) : t.isCube ? m.framebufferTexture2D(m.FRAMEBUFFER, y, m.TEXTURE_CUBE_MAP_POSITIVE_X + e, (d = g._hardwareTexture) === null || d === void 0 ? void 0 : d.underlyingResource, a) : m.framebufferTexture2D(m.FRAMEBUFFER, y, m.TEXTURE_2D, (p = g._hardwareTexture) === null || p === void 0 ? void 0 : p.underlyingResource, a);
        }
        this._cachedViewport && !o ? this.setViewport(this._cachedViewport, i, r) : (i || (i = t.width, a && (i /= Math.pow(2, a))), r || (r = t.height, a && (r /= Math.pow(2, a))), this._viewport(0, 0, i, r)), this.wipeCaches();
      }, n.prototype.setState = function(t, e, i, r, o, a, s) {
        var l, c;
        e === void 0 && (e = 0), r === void 0 && (r = !1), s === void 0 && (s = 0), (this._depthCullingState.cull !== t || i) && (this._depthCullingState.cull = t);
        var u = (c = (l = this.cullBackFaces) !== null && l !== void 0 ? l : o) === null || c === void 0 || c ? this._gl.BACK : this._gl.FRONT;
        (this._depthCullingState.cullFace !== u || i) && (this._depthCullingState.cullFace = u), this.setZOffset(e), this.setZOffsetUnits(s);
        var h = r ? this._gl.CW : this._gl.CCW;
        (this._depthCullingState.frontFace !== h || i) && (this._depthCullingState.frontFace = h), this._stencilStateComposer.stencilMaterial = a;
      }, n.prototype.getDepthBuffer = function() {
        return this._depthCullingState.depthTest;
      }, n.prototype.setDepthBuffer = function(t) {
        this._depthCullingState.depthTest = t;
      }, n.prototype.setZOffset = function(t) {
        this._depthCullingState.zOffset = this.useReverseDepthBuffer ? -t : t;
      }, n.prototype.getZOffset = function() {
        var t = this._depthCullingState.zOffset;
        return this.useReverseDepthBuffer ? -t : t;
      }, n.prototype.setZOffsetUnits = function(t) {
        this._depthCullingState.zOffsetUnits = this.useReverseDepthBuffer ? -t : t;
      }, n.prototype.getZOffsetUnits = function() {
        var t = this._depthCullingState.zOffsetUnits;
        return this.useReverseDepthBuffer ? -t : t;
      }, n.prototype._bindUnboundFramebuffer = function(t) {
        this._currentFramebuffer !== t && (this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, t), this._currentFramebuffer = t);
      }, n.prototype._currentFrameBufferIsDefaultFrameBuffer = function() {
        return this._currentFramebuffer === null;
      }, n.prototype.generateMipmaps = function(t) {
        this._bindTextureDirectly(this._gl.TEXTURE_2D, t, !0), this._gl.generateMipmap(this._gl.TEXTURE_2D), this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
      }, n.prototype.unBindFramebuffer = function(t, e, i) {
        var r;
        e === void 0 && (e = !1);
        var o = t;
        this._currentRenderTarget = null;
        var a = this._gl;
        if (o._MSAAFramebuffer) {
          if (t.isMulti)
            return void this.unBindMultiColorAttachmentFramebuffer(t, e, i);
          a.bindFramebuffer(a.READ_FRAMEBUFFER, o._MSAAFramebuffer), a.bindFramebuffer(a.DRAW_FRAMEBUFFER, o._framebuffer), a.blitFramebuffer(0, 0, t.width, t.height, 0, 0, t.width, t.height, a.COLOR_BUFFER_BIT, a.NEAREST);
        }
        !(!((r = t.texture) === null || r === void 0) && r.generateMipMaps) || e || t.isCube || this.generateMipmaps(t.texture), i && (o._MSAAFramebuffer && this._bindUnboundFramebuffer(o._framebuffer), i()), this._bindUnboundFramebuffer(null);
      }, n.prototype.flushFramebuffer = function() {
        this._gl.flush();
      }, n.prototype.restoreDefaultFramebuffer = function() {
        this._currentRenderTarget ? this.unBindFramebuffer(this._currentRenderTarget) : this._bindUnboundFramebuffer(null), this._cachedViewport && this.setViewport(this._cachedViewport), this.wipeCaches();
      }, n.prototype._resetVertexBufferBinding = function() {
        this.bindArrayBuffer(null), this._cachedVertexBuffers = null;
      }, n.prototype.createVertexBuffer = function(t, e, i) {
        return this._createVertexBuffer(t, this._gl.STATIC_DRAW);
      }, n.prototype._createVertexBuffer = function(t, e) {
        var i = this._gl.createBuffer();
        if (!i)
          throw new Error("Unable to create vertex buffer");
        var r = new nl(i);
        return this.bindArrayBuffer(r), t instanceof Array ? this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(t), e) : this._gl.bufferData(this._gl.ARRAY_BUFFER, t, e), this._resetVertexBufferBinding(), r.references = 1, r;
      }, n.prototype.createDynamicVertexBuffer = function(t, e) {
        return this._createVertexBuffer(t, this._gl.DYNAMIC_DRAW);
      }, n.prototype._resetIndexBufferBinding = function() {
        this.bindIndexBuffer(null), this._cachedIndexBuffer = null;
      }, n.prototype.createIndexBuffer = function(t, e, i) {
        var r = this._gl.createBuffer(), o = new nl(r);
        if (!r)
          throw new Error("Unable to create index buffer");
        this.bindIndexBuffer(o);
        var a = this._normalizeIndexData(t);
        return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, a, e ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW), this._resetIndexBufferBinding(), o.references = 1, o.is32Bits = a.BYTES_PER_ELEMENT === 4, o;
      }, n.prototype._normalizeIndexData = function(t) {
        if (t.BYTES_PER_ELEMENT === 2)
          return t;
        if (this._caps.uintIndices) {
          if (t instanceof Uint32Array)
            return t;
          for (var e = 0; e < t.length; e++)
            if (t[e] >= 65535)
              return new Uint32Array(t);
          return new Uint16Array(t);
        }
        return new Uint16Array(t);
      }, n.prototype.bindArrayBuffer = function(t) {
        this._vaoRecordInProgress || this._unbindVertexArrayObject(), this._bindBuffer(t, this._gl.ARRAY_BUFFER);
      }, n.prototype.bindUniformBlock = function(t, e, i) {
        var r = t.program, o = this._gl.getUniformBlockIndex(r, e);
        this._gl.uniformBlockBinding(r, o, i);
      }, n.prototype.bindIndexBuffer = function(t) {
        this._vaoRecordInProgress || this._unbindVertexArrayObject(), this._bindBuffer(t, this._gl.ELEMENT_ARRAY_BUFFER);
      }, n.prototype._bindBuffer = function(t, e) {
        (this._vaoRecordInProgress || this._currentBoundBuffer[e] !== t) && (this._gl.bindBuffer(e, t ? t.underlyingResource : null), this._currentBoundBuffer[e] = t);
      }, n.prototype.updateArrayBuffer = function(t) {
        this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, t);
      }, n.prototype._vertexAttribPointer = function(t, e, i, r, o, a, s) {
        var l = this._currentBufferPointers[e];
        if (l) {
          var c = !1;
          l.active ? (l.buffer !== t && (l.buffer = t, c = !0), l.size !== i && (l.size = i, c = !0), l.type !== r && (l.type = r, c = !0), l.normalized !== o && (l.normalized = o, c = !0), l.stride !== a && (l.stride = a, c = !0), l.offset !== s && (l.offset = s, c = !0)) : (c = !0, l.active = !0, l.index = e, l.size = i, l.type = r, l.normalized = o, l.stride = a, l.offset = s, l.buffer = t), (c || this._vaoRecordInProgress) && (this.bindArrayBuffer(t), r === this._gl.UNSIGNED_INT || r === this._gl.INT ? this._gl.vertexAttribIPointer(e, i, r, a, s) : this._gl.vertexAttribPointer(e, i, r, o, a, s));
        }
      }, n.prototype._bindIndexBufferWithCache = function(t) {
        t != null && this._cachedIndexBuffer !== t && (this._cachedIndexBuffer = t, this.bindIndexBuffer(t), this._uintIndicesCurrentlySet = t.is32Bits);
      }, n.prototype._bindVertexBuffersAttributes = function(t, e, i) {
        var r = e.getAttributesNames();
        this._vaoRecordInProgress || this._unbindVertexArrayObject(), this.unbindAllAttributes();
        for (var o = 0; o < r.length; o++) {
          var a = e.getAttributeLocation(o);
          if (a >= 0) {
            var s = r[o], l = null;
            if (i && (l = i[s]), l || (l = t[s]), !l)
              continue;
            this._gl.enableVertexAttribArray(a), this._vaoRecordInProgress || (this._vertexAttribArraysEnabled[a] = !0);
            var c = l.getBuffer();
            c && (this._vertexAttribPointer(c, a, l.getSize(), l.type, l.normalized, l.byteStride, l.byteOffset), l.getIsInstanced() && (this._gl.vertexAttribDivisor(a, l.getInstanceDivisor()), this._vaoRecordInProgress || (this._currentInstanceLocations.push(a), this._currentInstanceBuffers.push(c))));
          }
        }
      }, n.prototype.recordVertexArrayObject = function(t, e, i, r) {
        var o = this._gl.createVertexArray();
        if (!o)
          throw new Error("Unable to create VAO");
        return this._vaoRecordInProgress = !0, this._gl.bindVertexArray(o), this._mustWipeVertexAttributes = !0, this._bindVertexBuffersAttributes(t, i, r), this.bindIndexBuffer(e), this._vaoRecordInProgress = !1, this._gl.bindVertexArray(null), o;
      }, n.prototype.bindVertexArrayObject = function(t, e) {
        this._cachedVertexArrayObject !== t && (this._cachedVertexArrayObject = t, this._gl.bindVertexArray(t), this._cachedVertexBuffers = null, this._cachedIndexBuffer = null, this._uintIndicesCurrentlySet = e != null && e.is32Bits, this._mustWipeVertexAttributes = !0);
      }, n.prototype.bindBuffersDirectly = function(t, e, i, r, o) {
        if (this._cachedVertexBuffers !== t || this._cachedEffectForVertexBuffers !== o) {
          this._cachedVertexBuffers = t, this._cachedEffectForVertexBuffers = o;
          var a = o.getAttributesCount();
          this._unbindVertexArrayObject(), this.unbindAllAttributes();
          for (var s = 0, l = 0; l < a; l++)
            if (l < i.length) {
              var c = o.getAttributeLocation(l);
              c >= 0 && (this._gl.enableVertexAttribArray(c), this._vertexAttribArraysEnabled[c] = !0, this._vertexAttribPointer(t, c, i[l], this._gl.FLOAT, !1, r, s)), s += 4 * i[l];
            }
        }
        this._bindIndexBufferWithCache(e);
      }, n.prototype._unbindVertexArrayObject = function() {
        this._cachedVertexArrayObject && (this._cachedVertexArrayObject = null, this._gl.bindVertexArray(null));
      }, n.prototype.bindBuffers = function(t, e, i, r) {
        this._cachedVertexBuffers === t && this._cachedEffectForVertexBuffers === i || (this._cachedVertexBuffers = t, this._cachedEffectForVertexBuffers = i, this._bindVertexBuffersAttributes(t, i, r)), this._bindIndexBufferWithCache(e);
      }, n.prototype.unbindInstanceAttributes = function() {
        for (var t, e = 0, i = this._currentInstanceLocations.length; e < i; e++) {
          var r = this._currentInstanceBuffers[e];
          t != r && r.references && (t = r, this.bindArrayBuffer(r));
          var o = this._currentInstanceLocations[e];
          this._gl.vertexAttribDivisor(o, 0);
        }
        this._currentInstanceBuffers.length = 0, this._currentInstanceLocations.length = 0;
      }, n.prototype.releaseVertexArrayObject = function(t) {
        this._gl.deleteVertexArray(t);
      }, n.prototype._releaseBuffer = function(t) {
        return t.references--, t.references === 0 && (this._deleteBuffer(t), !0);
      }, n.prototype._deleteBuffer = function(t) {
        this._gl.deleteBuffer(t.underlyingResource);
      }, n.prototype.updateAndBindInstancesBuffer = function(t, e, i) {
        if (this.bindArrayBuffer(t), e && this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, e), i[0].index !== void 0)
          this.bindInstancesBuffer(t, i, !0);
        else
          for (var r = 0; r < 4; r++) {
            var o = i[r];
            this._vertexAttribArraysEnabled[o] || (this._gl.enableVertexAttribArray(o), this._vertexAttribArraysEnabled[o] = !0), this._vertexAttribPointer(t, o, 4, this._gl.FLOAT, !1, 64, 16 * r), this._gl.vertexAttribDivisor(o, 1), this._currentInstanceLocations.push(o), this._currentInstanceBuffers.push(t);
          }
      }, n.prototype.bindInstancesBuffer = function(t, e, i) {
        i === void 0 && (i = !0), this.bindArrayBuffer(t);
        var r = 0;
        if (i)
          for (var o = 0; o < e.length; o++)
            r += 4 * (a = e[o]).attributeSize;
        for (o = 0; o < e.length; o++) {
          var a;
          (a = e[o]).index === void 0 && (a.index = this._currentEffect.getAttributeLocationByName(a.attributeName)), a.index < 0 || (this._vertexAttribArraysEnabled[a.index] || (this._gl.enableVertexAttribArray(a.index), this._vertexAttribArraysEnabled[a.index] = !0), this._vertexAttribPointer(t, a.index, a.attributeSize, a.attributeType || this._gl.FLOAT, a.normalized || !1, r, a.offset), this._gl.vertexAttribDivisor(a.index, a.divisor === void 0 ? 1 : a.divisor), this._currentInstanceLocations.push(a.index), this._currentInstanceBuffers.push(t));
        }
      }, n.prototype.disableInstanceAttributeByName = function(t) {
        if (this._currentEffect) {
          var e = this._currentEffect.getAttributeLocationByName(t);
          this.disableInstanceAttribute(e);
        }
      }, n.prototype.disableInstanceAttribute = function(t) {
        for (var e, i = !1; (e = this._currentInstanceLocations.indexOf(t)) !== -1; )
          this._currentInstanceLocations.splice(e, 1), this._currentInstanceBuffers.splice(e, 1), i = !0, e = this._currentInstanceLocations.indexOf(t);
        i && (this._gl.vertexAttribDivisor(t, 0), this.disableAttributeByIndex(t));
      }, n.prototype.disableAttributeByIndex = function(t) {
        this._gl.disableVertexAttribArray(t), this._vertexAttribArraysEnabled[t] = !1, this._currentBufferPointers[t].active = !1;
      }, n.prototype.draw = function(t, e, i, r) {
        this.drawElementsType(t ? _.MATERIAL_TriangleFillMode : _.MATERIAL_WireFrameFillMode, e, i, r);
      }, n.prototype.drawPointClouds = function(t, e, i) {
        this.drawArraysType(_.MATERIAL_PointFillMode, t, e, i);
      }, n.prototype.drawUnIndexed = function(t, e, i, r) {
        this.drawArraysType(t ? _.MATERIAL_TriangleFillMode : _.MATERIAL_WireFrameFillMode, e, i, r);
      }, n.prototype.drawElementsType = function(t, e, i, r) {
        this.applyStates(), this._reportDrawCall();
        var o = this._drawMode(t), a = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT, s = this._uintIndicesCurrentlySet ? 4 : 2;
        r ? this._gl.drawElementsInstanced(o, i, a, e * s, r) : this._gl.drawElements(o, i, a, e * s);
      }, n.prototype.drawArraysType = function(t, e, i, r) {
        this.applyStates(), this._reportDrawCall();
        var o = this._drawMode(t);
        r ? this._gl.drawArraysInstanced(o, e, i, r) : this._gl.drawArrays(o, e, i);
      }, n.prototype._drawMode = function(t) {
        switch (t) {
          case _.MATERIAL_TriangleFillMode:
            return this._gl.TRIANGLES;
          case _.MATERIAL_PointFillMode:
            return this._gl.POINTS;
          case _.MATERIAL_WireFrameFillMode:
            return this._gl.LINES;
          case _.MATERIAL_PointListDrawMode:
            return this._gl.POINTS;
          case _.MATERIAL_LineListDrawMode:
            return this._gl.LINES;
          case _.MATERIAL_LineLoopDrawMode:
            return this._gl.LINE_LOOP;
          case _.MATERIAL_LineStripDrawMode:
            return this._gl.LINE_STRIP;
          case _.MATERIAL_TriangleStripDrawMode:
            return this._gl.TRIANGLE_STRIP;
          case _.MATERIAL_TriangleFanDrawMode:
            return this._gl.TRIANGLE_FAN;
          default:
            return this._gl.TRIANGLES;
        }
      }, n.prototype._reportDrawCall = function() {
      }, n.prototype._releaseEffect = function(t) {
        this._compiledEffects[t._key] && delete this._compiledEffects[t._key];
        var e = t.getPipelineContext();
        e && this._deletePipelineContext(e);
      }, n.prototype._deletePipelineContext = function(t) {
        var e = t;
        e && e.program && (e.program.__SPECTOR_rebuildProgram = null, this._gl.deleteProgram(e.program));
      }, n.prototype._getGlobalDefines = function(t) {
        if (t)
          return this.isNDCHalfZRange ? t.IS_NDC_HALF_ZRANGE = "" : delete t.IS_NDC_HALF_ZRANGE, this.useReverseDepthBuffer ? t.USE_REVERSE_DEPTHBUFFER = "" : delete t.USE_REVERSE_DEPTHBUFFER, void (this.useExactSrgbConversions ? t.USE_EXACT_SRGB_CONVERSIONS = "" : delete t.USE_EXACT_SRGB_CONVERSIONS);
        var e = "";
        return this.isNDCHalfZRange && (e += "#define IS_NDC_HALF_ZRANGE"), this.useReverseDepthBuffer && (e && (e += `
`), e += "#define USE_REVERSE_DEPTHBUFFER"), this.useExactSrgbConversions && (e && (e += `
`), e += "#define USE_EXACT_SRGB_CONVERSIONS"), e;
      }, n.prototype.createEffect = function(t, e, i, r, o, a, s, l, c, u) {
        var h;
        u === void 0 && (u = li.GLSL);
        var d = t.vertexElement || t.vertex || t.vertexToken || t.vertexSource || t, p = t.fragmentElement || t.fragment || t.fragmentToken || t.fragmentSource || t, f = this._getGlobalDefines(), m = (h = o ?? e.defines) !== null && h !== void 0 ? h : "";
        f && (m += f);
        var g = d + "+" + p + "@" + m;
        if (this._compiledEffects[g]) {
          var y = this._compiledEffects[g];
          return s && y.isReady() && s(y), y;
        }
        var b = new Jt(t, e, i, r, this, o, a, s, l, c, g, u);
        return this._compiledEffects[g] = b, b;
      }, n._ConcatenateShader = function(t, e, i) {
        return i === void 0 && (i = ""), i + (e ? e + `
` : "") + t;
      }, n.prototype._compileShader = function(t, e, i, r) {
        return this._compileRawShader(n._ConcatenateShader(t, i, r), e);
      }, n.prototype._compileRawShader = function(t, e) {
        var i = this._gl, r = i.createShader(e === "vertex" ? i.VERTEX_SHADER : i.FRAGMENT_SHADER);
        if (!r) {
          for (var o = i.NO_ERROR, a = i.NO_ERROR; (a = i.getError()) !== i.NO_ERROR; )
            o = a;
          throw new Error("Something went wrong while creating a gl ".concat(e, " shader object. gl error=").concat(o, ", gl isContextLost=").concat(i.isContextLost(), ", _contextWasLost=").concat(this._contextWasLost));
        }
        return i.shaderSource(r, t), i.compileShader(r), r;
      }, n.prototype._getShaderSource = function(t) {
        return this._gl.getShaderSource(t);
      }, n.prototype.createRawShaderProgram = function(t, e, i, r, o) {
        o === void 0 && (o = null), r = r || this._gl;
        var a = this._compileRawShader(e, "vertex"), s = this._compileRawShader(i, "fragment");
        return this._createShaderProgram(t, a, s, r, o);
      }, n.prototype.createShaderProgram = function(t, e, i, r, o, a) {
        a === void 0 && (a = null), o = o || this._gl;
        var s = this._webGLVersion > 1 ? `#version 300 es
#define WEBGL2 
` : "", l = this._compileShader(e, "vertex", r, s), c = this._compileShader(i, "fragment", r, s);
        return this._createShaderProgram(t, l, c, o, a);
      }, n.prototype.inlineShaderCode = function(t) {
        return t;
      }, n.prototype.createPipelineContext = function(t) {
        var e = new Zm();
        return e.engine = this, this._caps.parallelShaderCompile && (e.isParallelCompiled = !0), e;
      }, n.prototype.createMaterialContext = function() {
      }, n.prototype.createDrawContext = function() {
      }, n.prototype._createShaderProgram = function(t, e, i, r, o) {
        var a = r.createProgram();
        if (t.program = a, !a)
          throw new Error("Unable to create program");
        return r.attachShader(a, e), r.attachShader(a, i), r.linkProgram(a), t.context = r, t.vertexShader = e, t.fragmentShader = i, t.isParallelCompiled || this._finalizePipelineContext(t), a;
      }, n.prototype._finalizePipelineContext = function(t) {
        var e = t.context, i = t.vertexShader, r = t.fragmentShader, o = t.program;
        if (!e.getProgramParameter(o, e.LINK_STATUS)) {
          var a, s;
          if (!this._gl.getShaderParameter(i, this._gl.COMPILE_STATUS) && (a = this._gl.getShaderInfoLog(i)))
            throw t.vertexCompilationError = a, new Error("VERTEX SHADER " + a);
          if (!this._gl.getShaderParameter(r, this._gl.COMPILE_STATUS) && (a = this._gl.getShaderInfoLog(r)))
            throw t.fragmentCompilationError = a, new Error("FRAGMENT SHADER " + a);
          if (s = e.getProgramInfoLog(o))
            throw t.programLinkError = s, new Error(s);
        }
        if (this.validateShaderPrograms && (e.validateProgram(o), !e.getProgramParameter(o, e.VALIDATE_STATUS) && (s = e.getProgramInfoLog(o))))
          throw t.programValidationError = s, new Error(s);
        e.deleteShader(i), e.deleteShader(r), t.vertexShader = void 0, t.fragmentShader = void 0, t.onCompiled && (t.onCompiled(), t.onCompiled = void 0);
      }, n.prototype._preparePipelineContext = function(t, e, i, r, o, a, s, l, c, u) {
        var h = t;
        h.program = r ? this.createRawShaderProgram(h, e, i, void 0, c) : this.createShaderProgram(h, e, i, l, void 0, c), h.program.__SPECTOR_rebuildProgram = s;
      }, n.prototype._isRenderingStateCompiled = function(t) {
        var e = t;
        return !(this._isDisposed || e._isDisposed || !this._gl.getProgramParameter(e.program, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR) || (this._finalizePipelineContext(e), 0));
      }, n.prototype._executeWhenRenderingStateIsCompiled = function(t, e) {
        var i = t;
        if (i.isParallelCompiled) {
          var r = i.onCompiled;
          i.onCompiled = r ? function() {
            r(), e();
          } : e;
        } else
          e();
      }, n.prototype.getUniforms = function(t, e) {
        for (var i = new Array(), r = t, o = 0; o < e.length; o++)
          i.push(this._gl.getUniformLocation(r.program, e[o]));
        return i;
      }, n.prototype.getAttributes = function(t, e) {
        for (var i = [], r = t, o = 0; o < e.length; o++)
          try {
            i.push(this._gl.getAttribLocation(r.program, e[o]));
          } catch {
            i.push(-1);
          }
        return i;
      }, n.prototype.enableEffect = function(t) {
        (t = t !== null && Ei.IsWrapper(t) ? t.effect : t) && t !== this._currentEffect && (this._stencilStateComposer.stencilMaterial = void 0, this.bindSamplers(t), this._currentEffect = t, t.onBind && t.onBind(t), t._onBindObservable && t._onBindObservable.notifyObservers(t));
      }, n.prototype.setInt = function(t, e) {
        return !!t && (this._gl.uniform1i(t, e), !0);
      }, n.prototype.setInt2 = function(t, e, i) {
        return !!t && (this._gl.uniform2i(t, e, i), !0);
      }, n.prototype.setInt3 = function(t, e, i, r) {
        return !!t && (this._gl.uniform3i(t, e, i, r), !0);
      }, n.prototype.setInt4 = function(t, e, i, r, o) {
        return !!t && (this._gl.uniform4i(t, e, i, r, o), !0);
      }, n.prototype.setIntArray = function(t, e) {
        return !!t && (this._gl.uniform1iv(t, e), !0);
      }, n.prototype.setIntArray2 = function(t, e) {
        return !(!t || e.length % 2 != 0 || (this._gl.uniform2iv(t, e), 0));
      }, n.prototype.setIntArray3 = function(t, e) {
        return !(!t || e.length % 3 != 0 || (this._gl.uniform3iv(t, e), 0));
      }, n.prototype.setIntArray4 = function(t, e) {
        return !(!t || e.length % 4 != 0 || (this._gl.uniform4iv(t, e), 0));
      }, n.prototype.setUInt = function(t, e) {
        return !!t && (this._gl.uniform1ui(t, e), !0);
      }, n.prototype.setUInt2 = function(t, e, i) {
        return !!t && (this._gl.uniform2ui(t, e, i), !0);
      }, n.prototype.setUInt3 = function(t, e, i, r) {
        return !!t && (this._gl.uniform3ui(t, e, i, r), !0);
      }, n.prototype.setUInt4 = function(t, e, i, r, o) {
        return !!t && (this._gl.uniform4ui(t, e, i, r, o), !0);
      }, n.prototype.setUIntArray = function(t, e) {
        return !!t && (this._gl.uniform1uiv(t, e), !0);
      }, n.prototype.setUIntArray2 = function(t, e) {
        return !(!t || e.length % 2 != 0 || (this._gl.uniform2uiv(t, e), 0));
      }, n.prototype.setUIntArray3 = function(t, e) {
        return !(!t || e.length % 3 != 0 || (this._gl.uniform3uiv(t, e), 0));
      }, n.prototype.setUIntArray4 = function(t, e) {
        return !(!t || e.length % 4 != 0 || (this._gl.uniform4uiv(t, e), 0));
      }, n.prototype.setArray = function(t, e) {
        return !(!t || e.length < 1 || (this._gl.uniform1fv(t, e), 0));
      }, n.prototype.setArray2 = function(t, e) {
        return !(!t || e.length % 2 != 0 || (this._gl.uniform2fv(t, e), 0));
      }, n.prototype.setArray3 = function(t, e) {
        return !(!t || e.length % 3 != 0 || (this._gl.uniform3fv(t, e), 0));
      }, n.prototype.setArray4 = function(t, e) {
        return !(!t || e.length % 4 != 0 || (this._gl.uniform4fv(t, e), 0));
      }, n.prototype.setMatrices = function(t, e) {
        return !!t && (this._gl.uniformMatrix4fv(t, !1, e), !0);
      }, n.prototype.setMatrix3x3 = function(t, e) {
        return !!t && (this._gl.uniformMatrix3fv(t, !1, e), !0);
      }, n.prototype.setMatrix2x2 = function(t, e) {
        return !!t && (this._gl.uniformMatrix2fv(t, !1, e), !0);
      }, n.prototype.setFloat = function(t, e) {
        return !!t && (this._gl.uniform1f(t, e), !0);
      }, n.prototype.setFloat2 = function(t, e, i) {
        return !!t && (this._gl.uniform2f(t, e, i), !0);
      }, n.prototype.setFloat3 = function(t, e, i, r) {
        return !!t && (this._gl.uniform3f(t, e, i, r), !0);
      }, n.prototype.setFloat4 = function(t, e, i, r, o) {
        return !!t && (this._gl.uniform4f(t, e, i, r, o), !0);
      }, n.prototype.applyStates = function() {
        if (this._depthCullingState.apply(this._gl), this._stencilStateComposer.apply(this._gl), this._alphaState.apply(this._gl), this._colorWriteChanged) {
          this._colorWriteChanged = !1;
          var t = this._colorWrite;
          this._gl.colorMask(t, t, t, t);
        }
      }, n.prototype.setColorWrite = function(t) {
        t !== this._colorWrite && (this._colorWriteChanged = !0, this._colorWrite = t);
      }, n.prototype.getColorWrite = function() {
        return this._colorWrite;
      }, Object.defineProperty(n.prototype, "depthCullingState", { get: function() {
        return this._depthCullingState;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "alphaState", { get: function() {
        return this._alphaState;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "stencilState", { get: function() {
        return this._stencilState;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "stencilStateComposer", { get: function() {
        return this._stencilStateComposer;
      }, enumerable: !1, configurable: !0 }), n.prototype.clearInternalTexturesCache = function() {
        this._internalTexturesCache.length = 0;
      }, n.prototype.wipeCaches = function(t) {
        this.preventCacheWipeBetweenFrames && !t || (this._currentEffect = null, this._viewportCached.x = 0, this._viewportCached.y = 0, this._viewportCached.z = 0, this._viewportCached.w = 0, this._unbindVertexArrayObject(), t && (this._currentProgram = null, this.resetTextureCache(), this._stencilStateComposer.reset(), this._depthCullingState.reset(), this._depthCullingState.depthFunc = this._gl.LEQUAL, this._alphaState.reset(), this._alphaMode = _.ALPHA_ADD, this._alphaEquation = _.ALPHA_DISABLE, this._colorWrite = !0, this._colorWriteChanged = !0, this._unpackFlipYCached = null, this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE), this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0), this._mustWipeVertexAttributes = !0, this.unbindAllAttributes()), this._resetVertexBufferBinding(), this._cachedIndexBuffer = null, this._cachedEffectForVertexBuffers = null, this.bindIndexBuffer(null));
      }, n.prototype._getSamplingParameters = function(t, e) {
        var i = this._gl, r = i.NEAREST, o = i.NEAREST;
        switch (t) {
          case _.TEXTURE_LINEAR_LINEAR_MIPNEAREST:
            r = i.LINEAR, o = e ? i.LINEAR_MIPMAP_NEAREST : i.LINEAR;
            break;
          case _.TEXTURE_LINEAR_LINEAR_MIPLINEAR:
            r = i.LINEAR, o = e ? i.LINEAR_MIPMAP_LINEAR : i.LINEAR;
            break;
          case _.TEXTURE_NEAREST_NEAREST_MIPLINEAR:
            r = i.NEAREST, o = e ? i.NEAREST_MIPMAP_LINEAR : i.NEAREST;
            break;
          case _.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
            r = i.NEAREST, o = e ? i.NEAREST_MIPMAP_NEAREST : i.NEAREST;
            break;
          case _.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
            r = i.NEAREST, o = e ? i.LINEAR_MIPMAP_NEAREST : i.LINEAR;
            break;
          case _.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
            r = i.NEAREST, o = e ? i.LINEAR_MIPMAP_LINEAR : i.LINEAR;
            break;
          case _.TEXTURE_NEAREST_LINEAR:
            r = i.NEAREST, o = i.LINEAR;
            break;
          case _.TEXTURE_NEAREST_NEAREST:
            r = i.NEAREST, o = i.NEAREST;
            break;
          case _.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
            r = i.LINEAR, o = e ? i.NEAREST_MIPMAP_NEAREST : i.NEAREST;
            break;
          case _.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
            r = i.LINEAR, o = e ? i.NEAREST_MIPMAP_LINEAR : i.NEAREST;
            break;
          case _.TEXTURE_LINEAR_LINEAR:
            r = i.LINEAR, o = i.LINEAR;
            break;
          case _.TEXTURE_LINEAR_NEAREST:
            r = i.LINEAR, o = i.NEAREST;
        }
        return { min: o, mag: r };
      }, n.prototype._createTexture = function() {
        var t = this._gl.createTexture();
        if (!t)
          throw new Error("Unable to create texture");
        return t;
      }, n.prototype._createHardwareTexture = function() {
        return new ds(this._createTexture(), this._gl);
      }, n.prototype._createInternalTexture = function(t, e, i, r) {
        var o;
        r === void 0 && (r = ut.Unknown);
        var a, s = !1, l = _.TEXTURETYPE_UNSIGNED_INT, c = _.TEXTURE_TRILINEAR_SAMPLINGMODE, u = _.TEXTUREFORMAT_RGBA, h = !1, d = 1;
        e !== void 0 && typeof e == "object" ? (s = !!e.generateMipMaps, l = e.type === void 0 ? _.TEXTURETYPE_UNSIGNED_INT : e.type, c = e.samplingMode === void 0 ? _.TEXTURE_TRILINEAR_SAMPLINGMODE : e.samplingMode, u = e.format === void 0 ? _.TEXTUREFORMAT_RGBA : e.format, h = e.useSRGBBuffer !== void 0 && e.useSRGBBuffer, d = (o = e.samples) !== null && o !== void 0 ? o : 1, a = e.label) : s = !!e, h && (h = this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || this.isWebGPU)), (l !== _.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (l !== _.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (c = _.TEXTURE_NEAREST_SAMPLINGMODE), l !== _.TEXTURETYPE_FLOAT || this._caps.textureFloat || (l = _.TEXTURETYPE_UNSIGNED_INT, q.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));
        var p = this._gl, f = new Ut(this, r), m = t.width || t, g = t.height || t, y = t.layers || 0, b = this._getSamplingParameters(c, s), T = y !== 0 ? p.TEXTURE_2D_ARRAY : p.TEXTURE_2D, S = this._getRGBABufferInternalSizedFormat(l, u, h), E = this._getInternalFormat(u), A = this._getWebGLTextureType(l);
        return this._bindTextureDirectly(T, f), y !== 0 ? (f.is2DArray = !0, p.texImage3D(T, 0, S, m, g, y, 0, E, A, null)) : p.texImage2D(T, 0, S, m, g, 0, E, A, null), p.texParameteri(T, p.TEXTURE_MAG_FILTER, b.mag), p.texParameteri(T, p.TEXTURE_MIN_FILTER, b.min), p.texParameteri(T, p.TEXTURE_WRAP_S, p.CLAMP_TO_EDGE), p.texParameteri(T, p.TEXTURE_WRAP_T, p.CLAMP_TO_EDGE), s && this._gl.generateMipmap(T), this._bindTextureDirectly(T, null), f._useSRGBBuffer = h, f.baseWidth = m, f.baseHeight = g, f.width = m, f.height = g, f.depth = y, f.isReady = !0, f.samples = d, f.generateMipMaps = s, f.samplingMode = c, f.type = l, f.format = u, f.label = a, this._internalTexturesCache.push(f), f;
      }, n.prototype._getUseSRGBBuffer = function(t, e) {
        return t && this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || this.isWebGPU || e);
      }, n.prototype._createTextureBase = function(t, e, i, r, o, a, s, l, c, u, h, d, p, f, m, g) {
        var y = this;
        o === void 0 && (o = _.TEXTURE_TRILINEAR_SAMPLINGMODE), a === void 0 && (a = null), s === void 0 && (s = null), u === void 0 && (u = null), h === void 0 && (h = null), d === void 0 && (d = null), p === void 0 && (p = null);
        var b = (t = t || "").substr(0, 5) === "data:", T = t.substr(0, 5) === "blob:", S = b && t.indexOf(";base64,") !== -1, E = h || new Ut(this, ut.Url);
        E !== h && (E.label = t.substring(0, 60));
        var A = t;
        !this._transformTextureUrl || S || h || u || (t = this._transformTextureUrl(t)), A !== t && (E._originalUrl = A);
        var R = t.lastIndexOf("."), C = p || (R > -1 ? t.substring(R).toLowerCase() : ""), L = null;
        C.indexOf("?") > -1 && (C = C.split("?")[0]);
        for (var I = 0, O = n._TextureLoaders; I < O.length; I++) {
          var w = O[I];
          if (w.canLoad(C, f)) {
            L = w;
            break;
          }
        }
        r && r.addPendingData(E), E.url = t, E.generateMipMaps = !e, E.samplingMode = o, E.invertY = i, E._useSRGBBuffer = this._getUseSRGBBuffer(!!g, e), this._doNotHandleContextLost || (E._buffer = u);
        var z = null;
        a && !h && (z = E.onLoadedObservable.add(a)), h || this._internalTexturesCache.push(E);
        var V = function(J, X) {
          r && r.removePendingData(E), t === A ? (z && E.onLoadedObservable.remove(z), Me.UseFallbackTexture && y._createTextureBase(Me.FallbackTexture, e, E.invertY, r, o, null, s, l, c, u, E), J = (J || "Unknown error") + (Me.UseFallbackTexture ? " - Fallback texture was used" : ""), E.onErrorObservable.notifyObservers({ message: J, exception: X }), s && s(J, X)) : (q.Warn("Failed to load ".concat(t, ", falling back to ").concat(A)), y._createTextureBase(A, e, E.invertY, r, o, a, s, l, c, u, E, d, p, f, m, g));
        };
        if (L) {
          var Y = function(J) {
            L.loadData(J, E, function(X, K, te, se, _e, xe) {
              xe ? V("TextureLoader failed to load data") : l(E, C, r, { width: X, height: K }, E.invertY, !te, se, function() {
                return _e(), !1;
              }, o);
            }, m);
          };
          u ? u instanceof ArrayBuffer ? Y(new Uint8Array(u)) : ArrayBuffer.isView(u) ? Y(u) : s && s("Unable to load: only ArrayBuffer or ArrayBufferView is supported", null) : this._loadFile(t, function(J) {
            return Y(new Uint8Array(J));
          }, void 0, r ? r.offlineProvider : void 0, !0, function(J, X) {
            V("Unable to load " + (J && J.responseURL, X));
          });
        } else {
          var ee = function(J) {
            T && !y._doNotHandleContextLost && (E._buffer = J), l(E, C, r, J, E.invertY, e, !1, c, o);
          };
          !b || S ? u && (typeof u.decoding == "string" || u.close) ? ee(u) : n._FileToolsLoadImage(t, ee, V, r ? r.offlineProvider : null, f, E.invertY && this._features.needsInvertingBitmap ? { imageOrientation: "flipY" } : void 0) : typeof u == "string" || u instanceof ArrayBuffer || ArrayBuffer.isView(u) || u instanceof Blob ? n._FileToolsLoadImage(u, ee, V, r ? r.offlineProvider : null, f, E.invertY && this._features.needsInvertingBitmap ? { imageOrientation: "flipY" } : void 0) : u && ee(u);
        }
        return E;
      }, n.prototype.createTexture = function(t, e, i, r, o, a, s, l, c, u, h, d, p, f, m) {
        var g = this;
        return o === void 0 && (o = _.TEXTURE_TRILINEAR_SAMPLINGMODE), a === void 0 && (a = null), s === void 0 && (s = null), l === void 0 && (l = null), c === void 0 && (c = null), u === void 0 && (u = null), h === void 0 && (h = null), this._createTextureBase(t, e, i, r, o, a, s, this._prepareWebGLTexture.bind(this), function(y, b, T, S, E, A) {
          var R = g._gl, C = T.width === y && T.height === b, L = g._getTexImageParametersForCreateTexture(u, S, E._useSRGBBuffer);
          if (C)
            return R.texImage2D(R.TEXTURE_2D, 0, L.internalFormat, L.format, L.type, T), !1;
          var I = g._caps.maxTextureSize;
          if (T.width > I || T.height > I || !g._supportsHardwareTextureRescaling)
            return g._prepareWorkingCanvas(), !(!g._workingCanvas || !g._workingContext || (g._workingCanvas.width = y, g._workingCanvas.height = b, g._workingContext.drawImage(T, 0, 0, T.width, T.height, 0, 0, y, b), R.texImage2D(R.TEXTURE_2D, 0, L.internalFormat, L.format, L.type, g._workingCanvas), E.width = y, E.height = b, 1));
          var O = new Ut(g, ut.Temp);
          return g._bindTextureDirectly(R.TEXTURE_2D, O, !0), R.texImage2D(R.TEXTURE_2D, 0, L.internalFormat, L.format, L.type, T), g._rescaleTexture(O, E, r, L.format, function() {
            g._releaseTexture(O), g._bindTextureDirectly(R.TEXTURE_2D, E, !0), A();
          }), !0;
        }, l, c, u, h, d, p, m);
      }, n.prototype._getTexImageParametersForCreateTexture = function(t, e, i) {
        var r, o;
        return t == null && (t = e !== ".jpg" || i ? _.TEXTUREFORMAT_RGBA : _.TEXTUREFORMAT_RGB), this.webGLVersion === 1 ? o = r = this._getInternalFormat(t, i) : (r = this._getInternalFormat(t, !1), o = this._getRGBABufferInternalSizedFormat(_.TEXTURETYPE_UNSIGNED_BYTE, t, i)), { internalFormat: o, format: r, type: this._gl.UNSIGNED_BYTE };
      }, n._FileToolsLoadImage = function(t, e, i, r, o, a) {
        throw et("FileTools");
      }, n.prototype._rescaleTexture = function(t, e, i, r, o) {
      }, n.prototype.createRawTexture = function(t, e, i, r, o, a, s, l, c, u, h) {
        throw c === void 0 && (c = _.TEXTURETYPE_UNSIGNED_INT), et("Engine.RawTexture");
      }, n.prototype.createRawCubeTexture = function(t, e, i, r, o, a, s, l) {
        throw et("Engine.RawTexture");
      }, n.prototype.createRawTexture3D = function(t, e, i, r, o, a, s, l, c, u) {
        throw u === void 0 && (u = _.TEXTURETYPE_UNSIGNED_INT), et("Engine.RawTexture");
      }, n.prototype.createRawTexture2DArray = function(t, e, i, r, o, a, s, l, c, u) {
        throw u === void 0 && (u = _.TEXTURETYPE_UNSIGNED_INT), et("Engine.RawTexture");
      }, n.prototype._unpackFlipY = function(t) {
        this._unpackFlipYCached !== t && (this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, t ? 1 : 0), this.enableUnpackFlipYCached && (this._unpackFlipYCached = t));
      }, n.prototype._getUnpackAlignement = function() {
        return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT);
      }, n.prototype._getTextureTarget = function(t) {
        return t.isCube ? this._gl.TEXTURE_CUBE_MAP : t.is3D ? this._gl.TEXTURE_3D : t.is2DArray || t.isMultiview ? this._gl.TEXTURE_2D_ARRAY : this._gl.TEXTURE_2D;
      }, n.prototype.updateTextureSamplingMode = function(t, e, i) {
        i === void 0 && (i = !1);
        var r = this._getTextureTarget(e), o = this._getSamplingParameters(t, e.useMipMaps || i);
        this._setTextureParameterInteger(r, this._gl.TEXTURE_MAG_FILTER, o.mag, e), this._setTextureParameterInteger(r, this._gl.TEXTURE_MIN_FILTER, o.min), i && (e.generateMipMaps = !0, this._gl.generateMipmap(r)), this._bindTextureDirectly(r, null), e.samplingMode = t;
      }, n.prototype.updateTextureDimensions = function(t, e, i, r) {
      }, n.prototype.updateTextureWrappingMode = function(t, e, i, r) {
        i === void 0 && (i = null), r === void 0 && (r = null);
        var o = this._getTextureTarget(t);
        e !== null && (this._setTextureParameterInteger(o, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(e), t), t._cachedWrapU = e), i !== null && (this._setTextureParameterInteger(o, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(i), t), t._cachedWrapV = i), (t.is2DArray || t.is3D) && r !== null && (this._setTextureParameterInteger(o, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(r), t), t._cachedWrapR = r), this._bindTextureDirectly(o, null);
      }, n.prototype._setupDepthStencilTexture = function(t, e, i, r, o, a) {
        a === void 0 && (a = 1);
        var s = e.width || e, l = e.height || e, c = e.layers || 0;
        t.baseWidth = s, t.baseHeight = l, t.width = s, t.height = l, t.is2DArray = c > 0, t.depth = c, t.isReady = !0, t.samples = a, t.generateMipMaps = !1, t.samplingMode = r ? _.TEXTURE_BILINEAR_SAMPLINGMODE : _.TEXTURE_NEAREST_SAMPLINGMODE, t.type = _.TEXTURETYPE_UNSIGNED_INT, t._comparisonFunction = o;
        var u = this._gl, h = this._getTextureTarget(t), d = this._getSamplingParameters(t.samplingMode, !1);
        u.texParameteri(h, u.TEXTURE_MAG_FILTER, d.mag), u.texParameteri(h, u.TEXTURE_MIN_FILTER, d.min), u.texParameteri(h, u.TEXTURE_WRAP_S, u.CLAMP_TO_EDGE), u.texParameteri(h, u.TEXTURE_WRAP_T, u.CLAMP_TO_EDGE), this.webGLVersion > 1 && (o === 0 ? (u.texParameteri(h, u.TEXTURE_COMPARE_FUNC, _.LEQUAL), u.texParameteri(h, u.TEXTURE_COMPARE_MODE, u.NONE)) : (u.texParameteri(h, u.TEXTURE_COMPARE_FUNC, o), u.texParameteri(h, u.TEXTURE_COMPARE_MODE, u.COMPARE_REF_TO_TEXTURE)));
      }, n.prototype._uploadCompressedDataToTextureDirectly = function(t, e, i, r, o, a, s) {
        a === void 0 && (a = 0), s === void 0 && (s = 0);
        var l = this._gl, c = l.TEXTURE_2D;
        if (t.isCube && (c = l.TEXTURE_CUBE_MAP_POSITIVE_X + a), t._useSRGBBuffer)
          switch (e) {
            case _.TEXTUREFORMAT_COMPRESSED_RGB8_ETC2:
            case _.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL:
              this._caps.etc2 ? e = l.COMPRESSED_SRGB8_ETC2 : t._useSRGBBuffer = !1;
              break;
            case _.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC:
              this._caps.etc2 ? e = l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : t._useSRGBBuffer = !1;
              break;
            case _.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM:
              e = l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT;
              break;
            case _.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4:
              e = l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;
              break;
            case _.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1:
              this._caps.s3tc_srgb ? e = l.COMPRESSED_SRGB_S3TC_DXT1_EXT : t._useSRGBBuffer = !1;
              break;
            case _.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1:
              this._caps.s3tc_srgb ? e = l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT : t._useSRGBBuffer = !1;
              break;
            case _.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5:
              this._caps.s3tc_srgb ? e = l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT : t._useSRGBBuffer = !1;
              break;
            default:
              t._useSRGBBuffer = !1;
          }
        this._gl.compressedTexImage2D(c, s, e, i, r, 0, o);
      }, n.prototype._uploadDataToTextureDirectly = function(t, e, i, r, o, a) {
        i === void 0 && (i = 0), r === void 0 && (r = 0), a === void 0 && (a = !1);
        var s = this._gl, l = this._getWebGLTextureType(t.type), c = this._getInternalFormat(t.format), u = o === void 0 ? this._getRGBABufferInternalSizedFormat(t.type, t.format, t._useSRGBBuffer) : this._getInternalFormat(o, t._useSRGBBuffer);
        this._unpackFlipY(t.invertY);
        var h = s.TEXTURE_2D;
        t.isCube && (h = s.TEXTURE_CUBE_MAP_POSITIVE_X + i);
        var d = Math.round(Math.log(t.width) * Math.LOG2E), p = Math.round(Math.log(t.height) * Math.LOG2E), f = a ? t.width : Math.pow(2, Math.max(d - r, 0)), m = a ? t.height : Math.pow(2, Math.max(p - r, 0));
        s.texImage2D(h, r, u, f, m, 0, c, l, e);
      }, n.prototype.updateTextureData = function(t, e, i, r, o, a, s, l, c) {
        s === void 0 && (s = 0), l === void 0 && (l = 0), c === void 0 && (c = !1);
        var u = this._gl, h = this._getWebGLTextureType(t.type), d = this._getInternalFormat(t.format);
        this._unpackFlipY(t.invertY);
        var p = u.TEXTURE_2D, f = u.TEXTURE_2D;
        t.isCube && (f = u.TEXTURE_CUBE_MAP_POSITIVE_X + s, p = u.TEXTURE_CUBE_MAP), this._bindTextureDirectly(p, t, !0), u.texSubImage2D(f, l, i, r, o, a, d, h, e), c && this._gl.generateMipmap(f), this._bindTextureDirectly(p, null);
      }, n.prototype._uploadArrayBufferViewToTexture = function(t, e, i, r) {
        i === void 0 && (i = 0), r === void 0 && (r = 0);
        var o = this._gl, a = t.isCube ? o.TEXTURE_CUBE_MAP : o.TEXTURE_2D;
        this._bindTextureDirectly(a, t, !0), this._uploadDataToTextureDirectly(t, e, i, r), this._bindTextureDirectly(a, null, !0);
      }, n.prototype._prepareWebGLTextureContinuation = function(t, e, i, r, o) {
        var a = this._gl;
        if (a) {
          var s = this._getSamplingParameters(o, !i);
          a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MAG_FILTER, s.mag), a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MIN_FILTER, s.min), i || r || a.generateMipmap(a.TEXTURE_2D), this._bindTextureDirectly(a.TEXTURE_2D, null), e && e.removePendingData(t), t.onLoadedObservable.notifyObservers(t), t.onLoadedObservable.clear();
        }
      }, n.prototype._prepareWebGLTexture = function(t, e, i, r, o, a, s, l, c) {
        var u = this;
        c === void 0 && (c = _.TEXTURE_TRILINEAR_SAMPLINGMODE);
        var h = this.getCaps().maxTextureSize, d = Math.min(h, this.needPOTTextures ? n.GetExponentOfTwo(r.width, h) : r.width), p = Math.min(h, this.needPOTTextures ? n.GetExponentOfTwo(r.height, h) : r.height), f = this._gl;
        f && (t._hardwareTexture ? (this._bindTextureDirectly(f.TEXTURE_2D, t, !0), this._unpackFlipY(o === void 0 || !!o), t.baseWidth = r.width, t.baseHeight = r.height, t.width = d, t.height = p, t.isReady = !0, t.type = t.type !== -1 ? t.type : _.TEXTURETYPE_UNSIGNED_BYTE, t.format = t.format !== -1 ? t.format : e !== ".jpg" || t._useSRGBBuffer ? _.TEXTUREFORMAT_RGBA : _.TEXTUREFORMAT_RGB, l(d, p, r, e, t, function() {
          u._prepareWebGLTextureContinuation(t, i, a, s, c);
        }) || this._prepareWebGLTextureContinuation(t, i, a, s, c)) : i && i.removePendingData(t));
      }, n.prototype._setupFramebufferDepthAttachments = function(t, e, i, r, o) {
        o === void 0 && (o = 1);
        var a = this._gl;
        if (t && e)
          return this._createRenderBuffer(i, r, o, a.DEPTH_STENCIL, a.DEPTH24_STENCIL8, a.DEPTH_STENCIL_ATTACHMENT);
        if (e) {
          var s = a.DEPTH_COMPONENT16;
          return this._webGLVersion > 1 && (s = a.DEPTH_COMPONENT32F), this._createRenderBuffer(i, r, o, s, s, a.DEPTH_ATTACHMENT);
        }
        return t ? this._createRenderBuffer(i, r, o, a.STENCIL_INDEX8, a.STENCIL_INDEX8, a.STENCIL_ATTACHMENT) : null;
      }, n.prototype._createRenderBuffer = function(t, e, i, r, o, a, s) {
        s === void 0 && (s = !0);
        var l = this._gl.createRenderbuffer();
        return this._updateRenderBuffer(l, t, e, i, r, o, a, s);
      }, n.prototype._updateRenderBuffer = function(t, e, i, r, o, a, s, l) {
        l === void 0 && (l = !0);
        var c = this._gl;
        return c.bindRenderbuffer(c.RENDERBUFFER, t), r > 1 && c.renderbufferStorageMultisample ? c.renderbufferStorageMultisample(c.RENDERBUFFER, r, a, e, i) : c.renderbufferStorage(c.RENDERBUFFER, o, e, i), c.framebufferRenderbuffer(c.FRAMEBUFFER, s, c.RENDERBUFFER, t), l && c.bindRenderbuffer(c.RENDERBUFFER, null), t;
      }, n.prototype._releaseTexture = function(t) {
        var e;
        this._deleteTexture((e = t._hardwareTexture) === null || e === void 0 ? void 0 : e.underlyingResource), this.unbindAllTextures();
        var i = this._internalTexturesCache.indexOf(t);
        i !== -1 && this._internalTexturesCache.splice(i, 1), t._lodTextureHigh && t._lodTextureHigh.dispose(), t._lodTextureMid && t._lodTextureMid.dispose(), t._lodTextureLow && t._lodTextureLow.dispose(), t._irradianceTexture && t._irradianceTexture.dispose();
      }, n.prototype._releaseRenderTargetWrapper = function(t) {
        var e = this._renderTargetWrapperCache.indexOf(t);
        e !== -1 && this._renderTargetWrapperCache.splice(e, 1);
      }, n.prototype._deleteTexture = function(t) {
        t && this._gl.deleteTexture(t);
      }, n.prototype._setProgram = function(t) {
        this._currentProgram !== t && (this._gl.useProgram(t), this._currentProgram = t);
      }, n.prototype.bindSamplers = function(t) {
        var e = t.getPipelineContext();
        this._setProgram(e.program);
        for (var i = t.getSamplers(), r = 0; r < i.length; r++) {
          var o = t.getUniform(i[r]);
          o && (this._boundUniforms[r] = o);
        }
        this._currentEffect = null;
      }, n.prototype._activateCurrentTexture = function() {
        this._currentTextureChannel !== this._activeChannel && (this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel), this._currentTextureChannel = this._activeChannel);
      }, n.prototype._bindTextureDirectly = function(t, e, i, r) {
        var o, a;
        i === void 0 && (i = !1), r === void 0 && (r = !1);
        var s = !1, l = e && e._associatedChannel > -1;
        if (i && l && (this._activeChannel = e._associatedChannel), this._boundTexturesCache[this._activeChannel] !== e || r) {
          if (this._activateCurrentTexture(), e && e.isMultiview)
            throw console.error(t, e), "_bindTextureDirectly called with a multiview texture!";
          this._gl.bindTexture(t, (a = (o = e == null ? void 0 : e._hardwareTexture) === null || o === void 0 ? void 0 : o.underlyingResource) !== null && a !== void 0 ? a : null), this._boundTexturesCache[this._activeChannel] = e, e && (e._associatedChannel = this._activeChannel);
        } else
          i && (s = !0, this._activateCurrentTexture());
        return l && !i && this._bindSamplerUniformToChannel(e._associatedChannel, this._activeChannel), s;
      }, n.prototype._bindTexture = function(t, e, i) {
        if (t !== void 0) {
          e && (e._associatedChannel = t), this._activeChannel = t;
          var r = e ? this._getTextureTarget(e) : this._gl.TEXTURE_2D;
          this._bindTextureDirectly(r, e);
        }
      }, n.prototype.unbindAllTextures = function() {
        for (var t = 0; t < this._maxSimultaneousTextures; t++)
          this._activeChannel = t, this._bindTextureDirectly(this._gl.TEXTURE_2D, null), this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null), this.webGLVersion > 1 && (this._bindTextureDirectly(this._gl.TEXTURE_3D, null), this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY, null));
      }, n.prototype.setTexture = function(t, e, i, r) {
        t !== void 0 && (e && (this._boundUniforms[t] = e), this._setTexture(t, i));
      }, n.prototype._bindSamplerUniformToChannel = function(t, e) {
        var i = this._boundUniforms[t];
        i && i._currentState !== e && (this._gl.uniform1i(i, e), i._currentState = e);
      }, n.prototype._getTextureWrapMode = function(t) {
        switch (t) {
          case _.TEXTURE_WRAP_ADDRESSMODE:
            return this._gl.REPEAT;
          case _.TEXTURE_CLAMP_ADDRESSMODE:
            return this._gl.CLAMP_TO_EDGE;
          case _.TEXTURE_MIRROR_ADDRESSMODE:
            return this._gl.MIRRORED_REPEAT;
        }
        return this._gl.REPEAT;
      }, n.prototype._setTexture = function(t, e, i, r, o) {
        if (i === void 0 && (i = !1), r === void 0 && (r = !1), !e)
          return this._boundTexturesCache[t] != null && (this._activeChannel = t, this._bindTextureDirectly(this._gl.TEXTURE_2D, null), this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null), this.webGLVersion > 1 && (this._bindTextureDirectly(this._gl.TEXTURE_3D, null), this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY, null))), !1;
        if (e.video) {
          this._activeChannel = t;
          var a = e.getInternalTexture();
          a && (a._associatedChannel = t), e.update();
        } else if (e.delayLoadState === _.DELAYLOADSTATE_NOTLOADED)
          return e.delayLoad(), !1;
        var s;
        s = r ? e.depthStencilTexture : e.isReady() ? e.getInternalTexture() : e.isCube ? this.emptyCubeTexture : e.is3D ? this.emptyTexture3D : e.is2DArray ? this.emptyTexture2DArray : this.emptyTexture, !i && s && (s._associatedChannel = t);
        var l = !0;
        this._boundTexturesCache[t] === s && (i || this._bindSamplerUniformToChannel(s._associatedChannel, t), l = !1), this._activeChannel = t;
        var c = this._getTextureTarget(s);
        if (l && this._bindTextureDirectly(c, s, i), s && !s.isMultiview) {
          if (s.isCube && s._cachedCoordinatesMode !== e.coordinatesMode) {
            s._cachedCoordinatesMode = e.coordinatesMode;
            var u = e.coordinatesMode !== _.TEXTURE_CUBIC_MODE && e.coordinatesMode !== _.TEXTURE_SKYBOX_MODE ? _.TEXTURE_WRAP_ADDRESSMODE : _.TEXTURE_CLAMP_ADDRESSMODE;
            e.wrapU = u, e.wrapV = u;
          }
          s._cachedWrapU !== e.wrapU && (s._cachedWrapU = e.wrapU, this._setTextureParameterInteger(c, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(e.wrapU), s)), s._cachedWrapV !== e.wrapV && (s._cachedWrapV = e.wrapV, this._setTextureParameterInteger(c, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(e.wrapV), s)), s.is3D && s._cachedWrapR !== e.wrapR && (s._cachedWrapR = e.wrapR, this._setTextureParameterInteger(c, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(e.wrapR), s)), this._setAnisotropicLevel(c, s, e.anisotropicFilteringLevel);
        }
        return !0;
      }, n.prototype.setTextureArray = function(t, e, i, r) {
        if (t !== void 0 && e) {
          this._textureUnits && this._textureUnits.length === i.length || (this._textureUnits = new Int32Array(i.length));
          for (var o = 0; o < i.length; o++) {
            var a = i[o].getInternalTexture();
            a ? (this._textureUnits[o] = t + o, a._associatedChannel = t + o) : this._textureUnits[o] = -1;
          }
          this._gl.uniform1iv(e, this._textureUnits);
          for (var s = 0; s < i.length; s++)
            this._setTexture(this._textureUnits[s], i[s], !0);
        }
      }, n.prototype._setAnisotropicLevel = function(t, e, i) {
        var r = this._caps.textureAnisotropicFilterExtension;
        e.samplingMode !== _.TEXTURE_LINEAR_LINEAR_MIPNEAREST && e.samplingMode !== _.TEXTURE_LINEAR_LINEAR_MIPLINEAR && e.samplingMode !== _.TEXTURE_LINEAR_LINEAR && (i = 1), r && e._cachedAnisotropicFilteringLevel !== i && (this._setTextureParameterFloat(t, r.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(i, this._caps.maxAnisotropy), e), e._cachedAnisotropicFilteringLevel = i);
      }, n.prototype._setTextureParameterFloat = function(t, e, i, r) {
        this._bindTextureDirectly(t, r, !0, !0), this._gl.texParameterf(t, e, i);
      }, n.prototype._setTextureParameterInteger = function(t, e, i, r) {
        r && this._bindTextureDirectly(t, r, !0, !0), this._gl.texParameteri(t, e, i);
      }, n.prototype.unbindAllAttributes = function() {
        if (this._mustWipeVertexAttributes) {
          this._mustWipeVertexAttributes = !1;
          for (var t = 0; t < this._caps.maxVertexAttribs; t++)
            this.disableAttributeByIndex(t);
        } else {
          t = 0;
          for (var e = this._vertexAttribArraysEnabled.length; t < e; t++)
            t >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[t] || this.disableAttributeByIndex(t);
        }
      }, n.prototype.releaseEffects = function() {
        for (var t in this._compiledEffects) {
          var e = this._compiledEffects[t].getPipelineContext();
          this._deletePipelineContext(e);
        }
        this._compiledEffects = {};
      }, n.prototype.dispose = function() {
        var t, e;
        this._isDisposed = !0, this.stopRenderLoop(), this.onBeforeTextureInitObservable && this.onBeforeTextureInitObservable.clear(), this._emptyTexture && (this._releaseTexture(this._emptyTexture), this._emptyTexture = null), this._emptyCubeTexture && (this._releaseTexture(this._emptyCubeTexture), this._emptyCubeTexture = null), this._dummyFramebuffer && this._gl.deleteFramebuffer(this._dummyFramebuffer), this.releaseEffects(), (t = this.releaseComputeEffects) === null || t === void 0 || t.call(this), this.unbindAllAttributes(), this._boundUniforms = {}, Gi() && this._renderingCanvas && (this._doNotHandleContextLost || (this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost), this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored)), window.removeEventListener("resize", this._checkForMobile)), this._workingCanvas = null, this._workingContext = null, this._currentBufferPointers.length = 0, this._renderingCanvas = null, this._currentProgram = null, this._boundRenderFunction = null, Jt.ResetCache();
        for (var i = 0, r = this._activeRequests; i < r.length; i++)
          r[i].abort();
        this.onDisposeObservable.notifyObservers(this), this.onDisposeObservable.clear(), this._creationOptions.loseContextOnDispose && ((e = this._gl.getExtension("WEBGL_lose_context")) === null || e === void 0 || e.loseContext());
      }, n.prototype.attachContextLostEvent = function(t) {
        this._renderingCanvas && this._renderingCanvas.addEventListener("webglcontextlost", t, !1);
      }, n.prototype.attachContextRestoredEvent = function(t) {
        this._renderingCanvas && this._renderingCanvas.addEventListener("webglcontextrestored", t, !1);
      }, n.prototype.getError = function() {
        return this._gl.getError();
      }, n.prototype._canRenderToFloatFramebuffer = function() {
        return this._webGLVersion > 1 ? this._caps.colorBufferFloat : this._canRenderToFramebuffer(_.TEXTURETYPE_FLOAT);
      }, n.prototype._canRenderToHalfFloatFramebuffer = function() {
        return this._webGLVersion > 1 ? this._caps.colorBufferFloat : this._canRenderToFramebuffer(_.TEXTURETYPE_HALF_FLOAT);
      }, n.prototype._canRenderToFramebuffer = function(t) {
        for (var e = this._gl; e.getError() !== e.NO_ERROR; )
          ;
        var i = !0, r = e.createTexture();
        e.bindTexture(e.TEXTURE_2D, r), e.texImage2D(e.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(t), 1, 1, 0, e.RGBA, this._getWebGLTextureType(t), null), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.NEAREST), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.NEAREST);
        var o = e.createFramebuffer();
        e.bindFramebuffer(e.FRAMEBUFFER, o), e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, r, 0);
        var a = e.checkFramebufferStatus(e.FRAMEBUFFER);
        if ((i = (i = i && a === e.FRAMEBUFFER_COMPLETE) && e.getError() === e.NO_ERROR) && (e.clear(e.COLOR_BUFFER_BIT), i = i && e.getError() === e.NO_ERROR), i) {
          e.bindFramebuffer(e.FRAMEBUFFER, null);
          var s = e.RGBA, l = e.UNSIGNED_BYTE, c = new Uint8Array(4);
          e.readPixels(0, 0, 1, 1, s, l, c), i = i && e.getError() === e.NO_ERROR;
        }
        for (e.deleteTexture(r), e.deleteFramebuffer(o), e.bindFramebuffer(e.FRAMEBUFFER, null); !i && e.getError() !== e.NO_ERROR; )
          ;
        return i;
      }, n.prototype._getWebGLTextureType = function(t) {
        if (this._webGLVersion === 1) {
          switch (t) {
            case _.TEXTURETYPE_FLOAT:
              return this._gl.FLOAT;
            case _.TEXTURETYPE_HALF_FLOAT:
              return this._gl.HALF_FLOAT_OES;
            case _.TEXTURETYPE_UNSIGNED_BYTE:
              return this._gl.UNSIGNED_BYTE;
            case _.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
              return this._gl.UNSIGNED_SHORT_4_4_4_4;
            case _.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
              return this._gl.UNSIGNED_SHORT_5_5_5_1;
            case _.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
              return this._gl.UNSIGNED_SHORT_5_6_5;
          }
          return this._gl.UNSIGNED_BYTE;
        }
        switch (t) {
          case _.TEXTURETYPE_BYTE:
            return this._gl.BYTE;
          case _.TEXTURETYPE_UNSIGNED_BYTE:
            return this._gl.UNSIGNED_BYTE;
          case _.TEXTURETYPE_SHORT:
            return this._gl.SHORT;
          case _.TEXTURETYPE_UNSIGNED_SHORT:
            return this._gl.UNSIGNED_SHORT;
          case _.TEXTURETYPE_INT:
            return this._gl.INT;
          case _.TEXTURETYPE_UNSIGNED_INTEGER:
            return this._gl.UNSIGNED_INT;
          case _.TEXTURETYPE_FLOAT:
            return this._gl.FLOAT;
          case _.TEXTURETYPE_HALF_FLOAT:
            return this._gl.HALF_FLOAT;
          case _.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
            return this._gl.UNSIGNED_SHORT_4_4_4_4;
          case _.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
            return this._gl.UNSIGNED_SHORT_5_5_5_1;
          case _.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
            return this._gl.UNSIGNED_SHORT_5_6_5;
          case _.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
            return this._gl.UNSIGNED_INT_2_10_10_10_REV;
          case _.TEXTURETYPE_UNSIGNED_INT_24_8:
            return this._gl.UNSIGNED_INT_24_8;
          case _.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
            return this._gl.UNSIGNED_INT_10F_11F_11F_REV;
          case _.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
            return this._gl.UNSIGNED_INT_5_9_9_9_REV;
          case _.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:
            return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV;
        }
        return this._gl.UNSIGNED_BYTE;
      }, n.prototype._getInternalFormat = function(t, e) {
        e === void 0 && (e = !1);
        var i = e ? this._glSRGBExtensionValues.SRGB8_ALPHA8 : this._gl.RGBA;
        switch (t) {
          case _.TEXTUREFORMAT_ALPHA:
            i = this._gl.ALPHA;
            break;
          case _.TEXTUREFORMAT_LUMINANCE:
            i = this._gl.LUMINANCE;
            break;
          case _.TEXTUREFORMAT_LUMINANCE_ALPHA:
            i = this._gl.LUMINANCE_ALPHA;
            break;
          case _.TEXTUREFORMAT_RED:
            i = this._gl.RED;
            break;
          case _.TEXTUREFORMAT_RG:
            i = this._gl.RG;
            break;
          case _.TEXTUREFORMAT_RGB:
            i = e ? this._glSRGBExtensionValues.SRGB : this._gl.RGB;
            break;
          case _.TEXTUREFORMAT_RGBA:
            i = e ? this._glSRGBExtensionValues.SRGB8_ALPHA8 : this._gl.RGBA;
        }
        if (this._webGLVersion > 1)
          switch (t) {
            case _.TEXTUREFORMAT_RED_INTEGER:
              i = this._gl.RED_INTEGER;
              break;
            case _.TEXTUREFORMAT_RG_INTEGER:
              i = this._gl.RG_INTEGER;
              break;
            case _.TEXTUREFORMAT_RGB_INTEGER:
              i = this._gl.RGB_INTEGER;
              break;
            case _.TEXTUREFORMAT_RGBA_INTEGER:
              i = this._gl.RGBA_INTEGER;
          }
        return i;
      }, n.prototype._getRGBABufferInternalSizedFormat = function(t, e, i) {
        if (i === void 0 && (i = !1), this._webGLVersion === 1) {
          if (e !== void 0)
            switch (e) {
              case _.TEXTUREFORMAT_ALPHA:
                return this._gl.ALPHA;
              case _.TEXTUREFORMAT_LUMINANCE:
                return this._gl.LUMINANCE;
              case _.TEXTUREFORMAT_LUMINANCE_ALPHA:
                return this._gl.LUMINANCE_ALPHA;
              case _.TEXTUREFORMAT_RGB:
                return i ? this._glSRGBExtensionValues.SRGB : this._gl.RGB;
            }
          return this._gl.RGBA;
        }
        switch (t) {
          case _.TEXTURETYPE_BYTE:
            switch (e) {
              case _.TEXTUREFORMAT_RED:
                return this._gl.R8_SNORM;
              case _.TEXTUREFORMAT_RG:
                return this._gl.RG8_SNORM;
              case _.TEXTUREFORMAT_RGB:
                return this._gl.RGB8_SNORM;
              case _.TEXTUREFORMAT_RED_INTEGER:
                return this._gl.R8I;
              case _.TEXTUREFORMAT_RG_INTEGER:
                return this._gl.RG8I;
              case _.TEXTUREFORMAT_RGB_INTEGER:
                return this._gl.RGB8I;
              case _.TEXTUREFORMAT_RGBA_INTEGER:
                return this._gl.RGBA8I;
              default:
                return this._gl.RGBA8_SNORM;
            }
          case _.TEXTURETYPE_UNSIGNED_BYTE:
            switch (e) {
              case _.TEXTUREFORMAT_RED:
                return this._gl.R8;
              case _.TEXTUREFORMAT_RG:
                return this._gl.RG8;
              case _.TEXTUREFORMAT_RGB:
                return i ? this._glSRGBExtensionValues.SRGB8 : this._gl.RGB8;
              case _.TEXTUREFORMAT_RGBA:
                return i ? this._glSRGBExtensionValues.SRGB8_ALPHA8 : this._gl.RGBA8;
              case _.TEXTUREFORMAT_RED_INTEGER:
                return this._gl.R8UI;
              case _.TEXTUREFORMAT_RG_INTEGER:
                return this._gl.RG8UI;
              case _.TEXTUREFORMAT_RGB_INTEGER:
                return this._gl.RGB8UI;
              case _.TEXTUREFORMAT_RGBA_INTEGER:
                return this._gl.RGBA8UI;
              case _.TEXTUREFORMAT_ALPHA:
                return this._gl.ALPHA;
              case _.TEXTUREFORMAT_LUMINANCE:
                return this._gl.LUMINANCE;
              case _.TEXTUREFORMAT_LUMINANCE_ALPHA:
                return this._gl.LUMINANCE_ALPHA;
              default:
                return this._gl.RGBA8;
            }
          case _.TEXTURETYPE_SHORT:
            switch (e) {
              case _.TEXTUREFORMAT_RED_INTEGER:
                return this._gl.R16I;
              case _.TEXTUREFORMAT_RG_INTEGER:
                return this._gl.RG16I;
              case _.TEXTUREFORMAT_RGB_INTEGER:
                return this._gl.RGB16I;
              case _.TEXTUREFORMAT_RGBA_INTEGER:
              default:
                return this._gl.RGBA16I;
            }
          case _.TEXTURETYPE_UNSIGNED_SHORT:
            switch (e) {
              case _.TEXTUREFORMAT_RED_INTEGER:
                return this._gl.R16UI;
              case _.TEXTUREFORMAT_RG_INTEGER:
                return this._gl.RG16UI;
              case _.TEXTUREFORMAT_RGB_INTEGER:
                return this._gl.RGB16UI;
              case _.TEXTUREFORMAT_RGBA_INTEGER:
              default:
                return this._gl.RGBA16UI;
            }
          case _.TEXTURETYPE_INT:
            switch (e) {
              case _.TEXTUREFORMAT_RED_INTEGER:
                return this._gl.R32I;
              case _.TEXTUREFORMAT_RG_INTEGER:
                return this._gl.RG32I;
              case _.TEXTUREFORMAT_RGB_INTEGER:
                return this._gl.RGB32I;
              case _.TEXTUREFORMAT_RGBA_INTEGER:
              default:
                return this._gl.RGBA32I;
            }
          case _.TEXTURETYPE_UNSIGNED_INTEGER:
            switch (e) {
              case _.TEXTUREFORMAT_RED_INTEGER:
                return this._gl.R32UI;
              case _.TEXTUREFORMAT_RG_INTEGER:
                return this._gl.RG32UI;
              case _.TEXTUREFORMAT_RGB_INTEGER:
                return this._gl.RGB32UI;
              case _.TEXTUREFORMAT_RGBA_INTEGER:
              default:
                return this._gl.RGBA32UI;
            }
          case _.TEXTURETYPE_FLOAT:
            switch (e) {
              case _.TEXTUREFORMAT_RED:
                return this._gl.R32F;
              case _.TEXTUREFORMAT_RG:
                return this._gl.RG32F;
              case _.TEXTUREFORMAT_RGB:
                return this._gl.RGB32F;
              case _.TEXTUREFORMAT_RGBA:
              default:
                return this._gl.RGBA32F;
            }
          case _.TEXTURETYPE_HALF_FLOAT:
            switch (e) {
              case _.TEXTUREFORMAT_RED:
                return this._gl.R16F;
              case _.TEXTUREFORMAT_RG:
                return this._gl.RG16F;
              case _.TEXTUREFORMAT_RGB:
                return this._gl.RGB16F;
              case _.TEXTUREFORMAT_RGBA:
              default:
                return this._gl.RGBA16F;
            }
          case _.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
            return this._gl.RGB565;
          case _.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
            return this._gl.R11F_G11F_B10F;
          case _.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
            return this._gl.RGB9_E5;
          case _.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
            return this._gl.RGBA4;
          case _.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
            return this._gl.RGB5_A1;
          case _.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
            switch (e) {
              case _.TEXTUREFORMAT_RGBA:
                return this._gl.RGB10_A2;
              case _.TEXTUREFORMAT_RGBA_INTEGER:
                return this._gl.RGB10_A2UI;
              default:
                return this._gl.RGB10_A2;
            }
        }
        return i ? this._glSRGBExtensionValues.SRGB8_ALPHA8 : this._gl.RGBA8;
      }, n.prototype._getRGBAMultiSampleBufferFormat = function(t, e) {
        switch (e === void 0 && (e = _.TEXTUREFORMAT_RGBA), t) {
          case _.TEXTURETYPE_FLOAT:
            return e === _.TEXTUREFORMAT_R ? this._gl.R32F : this._gl.RGBA32F;
          case _.TEXTURETYPE_HALF_FLOAT:
            return e === _.TEXTUREFORMAT_R ? this._gl.R16F : this._gl.RGBA16F;
        }
        return this._gl.RGBA8;
      }, n.prototype._loadFile = function(t, e, i, r, o, a) {
        var s = this, l = n._FileToolsLoadFile(t, e, i, r, o, a);
        return this._activeRequests.push(l), l.onCompleteObservable.add(function(c) {
          s._activeRequests.splice(s._activeRequests.indexOf(c), 1);
        }), l;
      }, n._FileToolsLoadFile = function(t, e, i, r, o, a) {
        throw et("FileTools");
      }, n.prototype.readPixels = function(t, e, i, r, o, a) {
        o === void 0 && (o = !0), a === void 0 && (a = !0);
        var s = o ? 4 : 3, l = o ? this._gl.RGBA : this._gl.RGB, c = new Uint8Array(r * i * s);
        return a && this.flushFramebuffer(), this._gl.readPixels(t, e, i, r, l, this._gl.UNSIGNED_BYTE, c), Promise.resolve(c);
      }, Object.defineProperty(n, "IsSupportedAsync", { get: function() {
        return Promise.resolve(this.isSupported());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "IsSupported", { get: function() {
        return this.isSupported();
      }, enumerable: !1, configurable: !0 }), n.isSupported = function() {
        if (this._HasMajorPerformanceCaveat !== null)
          return !this._HasMajorPerformanceCaveat;
        if (this._IsSupported === null)
          try {
            var t = this._CreateCanvas(1, 1), e = t.getContext("webgl") || t.getContext("experimental-webgl");
            this._IsSupported = e != null && !!window.WebGLRenderingContext;
          } catch {
            this._IsSupported = !1;
          }
        return this._IsSupported;
      }, Object.defineProperty(n, "HasMajorPerformanceCaveat", { get: function() {
        if (this._HasMajorPerformanceCaveat === null)
          try {
            var t = this._CreateCanvas(1, 1), e = t.getContext("webgl", { failIfMajorPerformanceCaveat: !0 }) || t.getContext("experimental-webgl", { failIfMajorPerformanceCaveat: !0 });
            this._HasMajorPerformanceCaveat = !e;
          } catch {
            this._HasMajorPerformanceCaveat = !1;
          }
        return this._HasMajorPerformanceCaveat;
      }, enumerable: !1, configurable: !0 }), n.CeilingPOT = function(t) {
        return t--, t |= t >> 1, t |= t >> 2, t |= t >> 4, t |= t >> 8, t |= t >> 16, ++t;
      }, n.FloorPOT = function(t) {
        return t |= t >> 1, t |= t >> 2, t |= t >> 4, t |= t >> 8, (t |= t >> 16) - (t >> 1);
      }, n.NearestPOT = function(t) {
        var e = n.CeilingPOT(t), i = n.FloorPOT(t);
        return e - t > t - i ? i : e;
      }, n.GetExponentOfTwo = function(t, e, i) {
        var r;
        switch (i === void 0 && (i = _.SCALEMODE_NEAREST), i) {
          case _.SCALEMODE_FLOOR:
            r = n.FloorPOT(t);
            break;
          case _.SCALEMODE_NEAREST:
            r = n.NearestPOT(t);
            break;
          case _.SCALEMODE_CEILING:
          default:
            r = n.CeilingPOT(t);
        }
        return Math.min(r, e);
      }, n.QueueNewFrame = function(t, e) {
        if (Gi()) {
          var i = (e || window).requestAnimationFrame;
          if (typeof i == "function")
            return i(t);
        } else if (typeof requestAnimationFrame == "function")
          return requestAnimationFrame(t);
        return setTimeout(t, 16);
      }, n.prototype.getHostDocument = function() {
        return this._renderingCanvas && this._renderingCanvas.ownerDocument ? this._renderingCanvas.ownerDocument : hs() ? document : null;
      }, n._TempClearColorUint32 = new Uint32Array(4), n._TempClearColorInt32 = new Int32Array(4), n.ExceptionList = [{ key: "Chrome/63.0", capture: "63\\.0\\.3239\\.(\\d+)", captureConstraint: 108, targets: ["uniformBuffer"] }, { key: "Firefox/58", capture: null, captureConstraint: null, targets: ["uniformBuffer"] }, { key: "Firefox/59", capture: null, captureConstraint: null, targets: ["uniformBuffer"] }, { key: "Chrome/72.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] }, { key: "Chrome/73.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] }, { key: "Chrome/74.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] }, { key: "Mac OS.+Chrome/71", capture: null, captureConstraint: null, targets: ["vao"] }, { key: "Mac OS.+Chrome/72", capture: null, captureConstraint: null, targets: ["vao"] }, { key: "Mac OS.+Chrome", capture: null, captureConstraint: null, targets: ["uniformBuffer"] }, { key: ".*AppleWebKit.*(15.4).*Safari", capture: null, captureConstraint: null, targets: ["antialias", "maxMSAASamples"] }, { key: ".*(15.4).*AppleWebKit.*Safari", capture: null, captureConstraint: null, targets: ["antialias", "maxMSAASamples"] }], n._TextureLoaders = [], n.CollisionsEpsilon = 1e-3, n._IsSupported = null, n._HasMajorPerformanceCaveat = null, n;
    }(), ec = function() {
      function n() {
      }
      return n.SetImmediate = function(t) {
        Gi() && window.setImmediate ? window.setImmediate(t) : setTimeout(t, 1);
      }, n;
    }(), GA = new RegExp(/^data:([^,]+\/[^,]+)?;base64,/i), sp = function(n) {
      function t(e, i) {
        var r = n.call(this, e, ta.LoadFileError) || this;
        return r.name = "LoadFileError", il._setPrototypeOf(r, t.prototype), i instanceof _n ? r.request = i : r.file = i, r;
      }
      return D(t, n), t;
    }(ia), lp = function(n) {
      function t(e, i) {
        var r = n.call(this, e, ta.RequestFileError) || this;
        return r.request = i, r.name = "RequestFileError", il._setPrototypeOf(r, t.prototype), r;
      }
      return D(t, n), t;
    }(ia), Jm = function(n) {
      function t(e, i) {
        var r = n.call(this, e, ta.ReadFileError) || this;
        return r.file = i, r.name = "ReadFileError", il._setPrototypeOf(r, t.prototype), r;
      }
      return D(t, n), t;
    }(ia), zi = { DefaultRetryStrategy: Wm.ExponentialBackoff(), BaseUrl: "", CorsBehavior: "anonymous", PreprocessUrl: function(n) {
      return n;
    }, ScriptBaseUrl: "", ScriptPreprocessUrl: function(n) {
      return n;
    } }, zA = function(n) {
      return n.replace(/#/gm, "%23");
    }, wu = function(n, t) {
      if ((!n || n.indexOf("data:") !== 0) && zi.CorsBehavior)
        if (typeof zi.CorsBehavior == "string" || zi.CorsBehavior instanceof String)
          t.crossOrigin = zi.CorsBehavior;
        else {
          var e = zi.CorsBehavior(n);
          e && (t.crossOrigin = e);
        }
    }, rl = function(n, t, e, i, r, o) {
      var a, s;
      r === void 0 && (r = "");
      var l = !1;
      n instanceof ArrayBuffer || ArrayBuffer.isView(n) ? typeof Blob < "u" && typeof URL < "u" ? (s = URL.createObjectURL(new Blob([n], { type: r })), l = !0) : s = "data:".concat(r, ";base64,") + $l(n) : n instanceof Blob ? (s = URL.createObjectURL(n), l = !0) : (s = zA(n), s = zi.PreprocessUrl(n));
      var c = Me.LastCreatedEngine, u = function(T) {
        if (e) {
          var S = s || n.toString();
          e("Error while trying to load image: ".concat(S.indexOf("http") === 0 || S.length <= 128 ? S : S.slice(0, 128) + "..."), T);
        }
      };
      if (typeof Image > "u" || (a = c == null ? void 0 : c._features.forceBitmapOverHTMLImageElement) !== null && a !== void 0 && a)
        return na(s, function(T) {
          c.createImageBitmap(new Blob([T], { type: r }), je({ premultiplyAlpha: "none" }, o)).then(function(S) {
            t(S), l && URL.revokeObjectURL(s);
          }).catch(function(S) {
            e && e("Error while trying to load image: " + n, S);
          });
        }, void 0, i || void 0, !0, function(T, S) {
          u(S);
        }), null;
      var h = new Image();
      wu(s, h);
      var d = [], p = function() {
        d.forEach(function(T) {
          T.target.removeEventListener(T.name, T.handler);
        }), d.length = 0;
      };
      d.push({ target: h, name: "load", handler: function() {
        p(), t(h), l && h.src && URL.revokeObjectURL(h.src);
      } }), d.push({ target: h, name: "error", handler: function(T) {
        p(), u(T), l && h.src && URL.revokeObjectURL(h.src);
      } }), d.push({ target: document, name: "securitypolicyviolation", handler: function(T) {
        if (T.blockedURI === h.src) {
          p();
          var S = new Error("CSP violation of policy ".concat(T.effectiveDirective, " ").concat(T.blockedURI, ". Current policy is ").concat(T.originalPolicy));
          Me.UseFallbackTexture = !1, u(S), l && h.src && URL.revokeObjectURL(h.src), h.src = "";
        }
      } }), d.forEach(function(T) {
        T.target.addEventListener(T.name, T.handler);
      });
      var f = s.substring(0, 5) === "blob:", m = s.substring(0, 5) === "data:", g = function() {
        f || m || !_n.IsCustomRequestAvailable ? h.src = s : na(s, function(T, S, E) {
          var A = new Blob([T], { type: !r && E ? E : r }), R = URL.createObjectURL(A);
          l = !0, h.src = R;
        }, void 0, i || void 0, !0, function(T, S) {
          u(S);
        });
      };
      if (!f && !m && i && i.enableTexturesOffline)
        i.open(function() {
          i && i.loadImage(s, h);
        }, g);
      else {
        if (s.indexOf("file:") !== -1) {
          var y = decodeURIComponent(s.substring(5).toLowerCase());
          if (tl.FilesToLoad[y] && typeof URL < "u") {
            try {
              var b = void 0;
              try {
                b = URL.createObjectURL(tl.FilesToLoad[y]);
              } catch {
                b = URL.createObjectURL(tl.FilesToLoad[y]);
              }
              h.src = b, l = !0;
            } catch {
              h.src = "";
            }
            return h;
          }
        }
        g();
      }
      return h;
    }, ol = function(n, t, e, i, r) {
      var o = new FileReader(), a = { onCompleteObservable: new H(), abort: function() {
        return o.abort();
      } };
      return o.onloadend = function() {
        return a.onCompleteObservable.notifyObservers(a);
      }, r && (o.onerror = function() {
        r(new Jm("Unable to read ".concat(n.name), n));
      }), o.onload = function(s) {
        t(s.target.result);
      }, e && (o.onprogress = e), i ? o.readAsArrayBuffer(n) : o.readAsText(n), a;
    }, na = function(n, t, e, i, r, o, a) {
      if (n.name)
        return ol(n, t, e, r, o ? function(m) {
          o(void 0, m);
        } : void 0);
      var s = n;
      if (s.indexOf("file:") !== -1) {
        var l = decodeURIComponent(s.substring(5).toLowerCase());
        l.indexOf("./") === 0 && (l = l.substring(2));
        var c = tl.FilesToLoad[l];
        if (c)
          return ol(c, t, e, r, o ? function(m) {
            return o(void 0, new sp(m.message, m.file));
          } : void 0);
      }
      var u = $m(s), h = u.match, d = u.type;
      if (h) {
        var p = { onCompleteObservable: new H(), abort: function() {
          return function() {
          };
        } };
        try {
          var f = r ? Vu(s) : up(s);
          t(f, void 0, d);
        } catch (m) {
          o ? o(void 0, m) : q.Error(m.message || "Failed to parse the Data URL");
        }
        return ec.SetImmediate(function() {
          p.onCompleteObservable.notifyObservers(p);
        }), p;
      }
      return Bu(s, function(m, g) {
        t(m, g == null ? void 0 : g.responseURL, g == null ? void 0 : g.getResponseHeader("content-type"));
      }, e, i, r, o ? function(m) {
        o(m.request, new sp(m.message, m.request));
      } : void 0, a);
    }, Bu = function(n, t, e, i, r, o, a) {
      n = zA(n), n = zi.PreprocessUrl(n);
      var s = zi.BaseUrl + n, l = !1, c = { onCompleteObservable: new H(), abort: function() {
        return l = !0;
      } }, u = function() {
        var d, p = new _n(), f = null, m = function() {
          p && (e && p.removeEventListener("progress", e), d && p.removeEventListener("readystatechange", d), p.removeEventListener("loadend", g));
        }, g = function() {
          m(), c.onCompleteObservable.notifyObservers(c), c.onCompleteObservable.clear(), e = void 0, d = null, g = null, o = void 0, a = void 0, t = void 0;
        };
        c.abort = function() {
          l = !0, g && g(), p && p.readyState !== (XMLHttpRequest.DONE || 4) && p.abort(), f !== null && (clearTimeout(f), f = null), p = null;
        };
        var y = function(T) {
          var S = T.message || "Unknown error";
          o && p ? o(new lp(S, p)) : q.Error(S);
        }, b = function(T) {
          if (p) {
            if (p.open("GET", s), a)
              try {
                a(p);
              } catch (S) {
                return void y(S);
              }
            r && (p.responseType = "arraybuffer"), e && p.addEventListener("progress", e), g && p.addEventListener("loadend", g), d = function() {
              if (!l && p && p.readyState === (XMLHttpRequest.DONE || 4)) {
                if (d && p.removeEventListener("readystatechange", d), p.status >= 200 && p.status < 300 || p.status === 0 && (!Gi() || cp())) {
                  try {
                    t && t(r ? p.response : p.responseText, p);
                  } catch (R) {
                    y(R);
                  }
                  return;
                }
                var S = zi.DefaultRetryStrategy;
                if (S) {
                  var E = S(s, p, T);
                  if (E !== -1)
                    return m(), p = new _n(), void (f = setTimeout(function() {
                      return b(T + 1);
                    }, E));
                }
                var A = new lp("Error status: " + p.status + " " + p.statusText + " - Unable to load " + s, p);
                o && o(A);
              }
            }, p.addEventListener("readystatechange", d), p.send();
          }
        };
        b(0);
      };
      if (i && i.enableSceneOffline) {
        var h = function(d) {
          d && d.status > 400 ? o && o(d) : u();
        };
        i.open(function() {
          i && i.loadFile(zi.BaseUrl + n, function(d) {
            !l && t && t(d), c.onCompleteObservable.notifyObservers(c);
          }, e ? function(d) {
            !l && e && e(d);
          } : void 0, h, r);
        }, h);
      } else
        u();
      return c;
    }, cp = function() {
      return typeof location < "u" && location.protocol === "file:";
    }, Uu = function(n) {
      return GA.test(n);
    }, $m = function(n) {
      var t = GA.exec(n);
      return t === null || t.length === 0 ? { match: !1, type: "" } : { match: !0, type: t[0].replace("data:", "").replace("base64,", "") };
    };
    function Vu(n) {
      return Nu(n.split(",")[1]);
    }
    var al, up = function(n) {
      return Du(n.split(",")[1]);
    };
    Qe._FileToolsLoadImage = rl, Qe._FileToolsLoadFile = na, La._FileToolsLoadFile = na;
    var eg = function(n, t, e, i, r, o, a, s, l, c) {
      al = { DecodeBase64UrlToBinary: n, DecodeBase64UrlToString: t, DefaultRetryStrategy: e.DefaultRetryStrategy, BaseUrl: e.BaseUrl, CorsBehavior: e.CorsBehavior, PreprocessUrl: e.PreprocessUrl, IsBase64DataUrl: i, IsFileURL: r, LoadFile: o, LoadImage: a, ReadFile: s, RequestFile: l, SetCorsBehavior: c }, Object.defineProperty(al, "DefaultRetryStrategy", { get: function() {
        return e.DefaultRetryStrategy;
      }, set: function(u) {
        e.DefaultRetryStrategy = u;
      } }), Object.defineProperty(al, "BaseUrl", { get: function() {
        return e.BaseUrl;
      }, set: function(u) {
        e.BaseUrl = u;
      } }), Object.defineProperty(al, "PreprocessUrl", { get: function() {
        return e.PreprocessUrl;
      }, set: function(u) {
        e.PreprocessUrl = u;
      } }), Object.defineProperty(al, "CorsBehavior", { get: function() {
        return e.CorsBehavior;
      }, set: function(u) {
        e.CorsBehavior = u;
      } });
    };
    eg(Vu, up, zi, Uu, cp, na, rl, ol, Bu, wu);
    var hp = function() {
      function n() {
      }
      return n.Instantiate = function(t) {
        if (this.RegisteredExternalClasses && this.RegisteredExternalClasses[t])
          return this.RegisteredExternalClasses[t];
        var e = Kt(t);
        if (e)
          return e;
        q.Warn(t + " not found, you may have missed an import.");
        for (var i = t.split("."), r = window || this, o = 0, a = i.length; o < a; o++)
          r = r[i[o]];
        return typeof r != "function" ? null : r;
      }, n.RegisteredExternalClasses = {}, n;
    }();
    function ra() {
      return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(n) {
        var t = 16 * Math.random() | 0;
        return (n === "x" ? t : 3 & t | 8).toString(16);
      });
    }
    var WA = { RandomId: ra }, de = function() {
      function n() {
      }
      return Object.defineProperty(n, "BaseUrl", { get: function() {
        return zi.BaseUrl;
      }, set: function(t) {
        zi.BaseUrl = t;
      }, enumerable: !1, configurable: !0 }), n.IsAbsoluteUrl = function(t) {
        return t.indexOf("//") === 0 || t.indexOf("://") !== -1 && t.indexOf(".") !== -1 && t.indexOf("/") !== -1 && !(t.indexOf(":") > t.indexOf("/")) && (t.indexOf("://") < t.indexOf(".") || t.indexOf("data:") === 0 || t.indexOf("blob:") === 0);
      }, Object.defineProperty(n, "ScriptBaseUrl", { get: function() {
        return zi.ScriptBaseUrl;
      }, set: function(t) {
        zi.ScriptBaseUrl = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "ScriptPreprocessUrl", { get: function() {
        return zi.ScriptPreprocessUrl;
      }, set: function(t) {
        zi.ScriptPreprocessUrl = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "DefaultRetryStrategy", { get: function() {
        return zi.DefaultRetryStrategy;
      }, set: function(t) {
        zi.DefaultRetryStrategy = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "CorsBehavior", { get: function() {
        return zi.CorsBehavior;
      }, set: function(t) {
        zi.CorsBehavior = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "UseFallbackTexture", { get: function() {
        return Me.UseFallbackTexture;
      }, set: function(t) {
        Me.UseFallbackTexture = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "RegisteredExternalClasses", { get: function() {
        return hp.RegisteredExternalClasses;
      }, set: function(t) {
        hp.RegisteredExternalClasses = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "fallbackTexture", { get: function() {
        return Me.FallbackTexture;
      }, set: function(t) {
        Me.FallbackTexture = t;
      }, enumerable: !1, configurable: !0 }), n.FetchToRef = function(t, e, i, r, o, a) {
        var s = 4 * ((Math.abs(t) * i % i | 0) + (Math.abs(e) * r % r | 0) * i);
        a.r = o[s] / 255, a.g = o[s + 1] / 255, a.b = o[s + 2] / 255, a.a = o[s + 3] / 255;
      }, n.Mix = function(t, e, i) {
        return t * (1 - i) + e * i;
      }, n.Instantiate = function(t) {
        return hp.Instantiate(t);
      }, n.SetImmediate = function(t) {
        ec.SetImmediate(t);
      }, n.IsExponentOfTwo = function(t) {
        var e = 1;
        do
          e *= 2;
        while (e < t);
        return e === t;
      }, n.FloatRound = function(t) {
        return Math.fround(t);
      }, n.GetFilename = function(t) {
        var e = t.lastIndexOf("/");
        return e < 0 ? t : t.substring(e + 1);
      }, n.GetFolderPath = function(t, e) {
        e === void 0 && (e = !1);
        var i = t.lastIndexOf("/");
        return i < 0 ? e ? t : "" : t.substring(0, i + 1);
      }, n.ToDegrees = function(t) {
        return 180 * t / Math.PI;
      }, n.ToRadians = function(t) {
        return t * Math.PI / 180;
      }, n.SmoothAngleChange = function(t, e, i) {
        i === void 0 && (i = 0.9);
        var r = this.ToRadians(t), o = this.ToRadians(e);
        return this.ToDegrees(Math.atan2((1 - i) * Math.sin(o) + i * Math.sin(r), (1 - i) * Math.cos(o) + i * Math.cos(r)));
      }, n.MakeArray = function(t, e) {
        return e === !0 || t !== void 0 && t != null ? Array.isArray(t) ? t : [t] : null;
      }, n.GetPointerPrefix = function(t) {
        var e = "pointer";
        return Gi() && !window.PointerEvent && (e = "mouse"), !t._badDesktopOS || t._badOS || document && "ontouchend" in document || (e = "mouse"), e;
      }, n.SetCorsBehavior = function(t, e) {
        wu(t, e);
      }, n.SetReferrerPolicyBehavior = function(t, e) {
        e.referrerPolicy = t;
      }, n.CleanUrl = function(t) {
        return t.replace(/#/gm, "%23");
      }, Object.defineProperty(n, "PreprocessUrl", { get: function() {
        return zi.PreprocessUrl;
      }, set: function(t) {
        zi.PreprocessUrl = t;
      }, enumerable: !1, configurable: !0 }), n.LoadImage = function(t, e, i, r, o, a) {
        return rl(t, e, i, r, o, a);
      }, n.LoadFile = function(t, e, i, r, o, a) {
        return na(t, e, i, r, o, a);
      }, n.LoadFileAsync = function(t, e) {
        return e === void 0 && (e = !0), new Promise(function(i, r) {
          na(t, function(o) {
            i(o);
          }, void 0, void 0, e, function(o, a) {
            r(a);
          });
        });
      }, n.GetBabylonScriptURL = function(t, e) {
        if (!t)
          return "";
        if (n.ScriptBaseUrl && t.startsWith(n._DefaultCdnUrl)) {
          var i = n.ScriptBaseUrl[n.ScriptBaseUrl.length - 1] === "/" ? n.ScriptBaseUrl.substring(0, n.ScriptBaseUrl.length - 1) : n.ScriptBaseUrl;
          t = t.replace(n._DefaultCdnUrl, i);
        }
        return t = n.ScriptPreprocessUrl(t), e && (t = n.GetAbsoluteUrl(t)), t;
      }, n.LoadBabylonScript = function(t, e, i, r) {
        t = n.GetBabylonScriptURL(t), n.LoadScript(t, e, i);
      }, n.LoadBabylonScriptAsync = function(t) {
        return t = n.GetBabylonScriptURL(t), n.LoadScriptAsync(t);
      }, n.LoadScript = function(t, e, i, r) {
        if (typeof importScripts != "function")
          if (Gi()) {
            var o = document.getElementsByTagName("head")[0], a = document.createElement("script");
            a.setAttribute("type", "text/javascript"), a.setAttribute("src", t), r && (a.id = r), a.onload = function() {
              e && e();
            }, a.onerror = function(s) {
              i && i("Unable to load script '".concat(t, "'"), s);
            }, o.appendChild(a);
          } else
            i == null || i("Cannot load script '".concat(t, "' outside of a window or a worker"));
        else
          try {
            importScripts(t), e();
          } catch (s) {
            i == null || i("Unable to load script '".concat(t, "' in worker"), s);
          }
      }, n.LoadScriptAsync = function(t) {
        var e = this;
        return new Promise(function(i, r) {
          e.LoadScript(t, function() {
            i();
          }, function(o, a) {
            r(a || new Error(o));
          });
        });
      }, n.ReadFileAsDataURL = function(t, e, i) {
        var r = new FileReader(), o = { onCompleteObservable: new H(), abort: function() {
          return r.abort();
        } };
        return r.onloadend = function() {
          o.onCompleteObservable.notifyObservers(o);
        }, r.onload = function(a) {
          e(a.target.result);
        }, r.onprogress = i, r.readAsDataURL(t), o;
      }, n.ReadFile = function(t, e, i, r, o) {
        return ol(t, e, i, r, o);
      }, n.FileAsURL = function(t) {
        var e = new Blob([t]);
        return window.URL.createObjectURL(e);
      }, n.Format = function(t, e) {
        return e === void 0 && (e = 2), t.toFixed(e);
      }, n.DeepCopy = function(t, e, i, r) {
        Ui.DeepCopy(t, e, i, r);
      }, n.IsEmpty = function(t) {
        for (var e in t)
          if (Object.prototype.hasOwnProperty.call(t, e))
            return !1;
        return !0;
      }, n.RegisterTopRootEvents = function(t, e) {
        for (var i = 0; i < e.length; i++) {
          var r = e[i];
          t.addEventListener(r.name, r.handler, !1);
          try {
            window.parent && window.parent.addEventListener(r.name, r.handler, !1);
          } catch {
          }
        }
      }, n.UnregisterTopRootEvents = function(t, e) {
        for (var i = 0; i < e.length; i++) {
          var r = e[i];
          t.removeEventListener(r.name, r.handler);
          try {
            t.parent && t.parent.removeEventListener(r.name, r.handler);
          } catch {
          }
        }
      }, n.DumpFramebuffer = function(t, e, i, r, o, a, s) {
        return Ft(this, void 0, void 0, function() {
          return Bt(this, function(l) {
            throw et("DumpTools");
          });
        });
      }, n.DumpData = function(t, e, i, r, o, a, s, l, c) {
        throw et("DumpTools");
      }, n.DumpDataAsync = function(t, e, i, r, o, a, s, l) {
        throw et("DumpTools");
      }, n._IsOffScreenCanvas = function(t) {
        return t.convertToBlob !== void 0;
      }, n.ToBlob = function(t, e, i, r) {
        i === void 0 && (i = "image/png"), n._IsOffScreenCanvas(t) || t.toBlob || (t.toBlob = function(o, a, s) {
          var l = this;
          setTimeout(function() {
            for (var c = atob(l.toDataURL(a, s).split(",")[1]), u = c.length, h = new Uint8Array(u), d = 0; d < u; d++)
              h[d] = c.charCodeAt(d);
            o(new Blob([h]));
          });
        }), n._IsOffScreenCanvas(t) ? t.convertToBlob({ type: i, quality: r }).then(function(o) {
          return e(o);
        }) : t.toBlob(function(o) {
          e(o);
        }, i, r);
      }, n.DownloadBlob = function(t, e) {
        if ("download" in document.createElement("a")) {
          if (!e) {
            var i = /* @__PURE__ */ new Date();
            e = "screenshot_" + (i.getFullYear() + "-" + (i.getMonth() + 1)).slice(2) + "-" + i.getDate() + "_" + i.getHours() + "-" + ("0" + i.getMinutes()).slice(-2) + ".png";
          }
          n.Download(t, e);
        } else if (t && typeof URL < "u") {
          var r = URL.createObjectURL(t), o = window.open("");
          if (!o)
            return;
          var a = o.document.createElement("img");
          a.onload = function() {
            URL.revokeObjectURL(r);
          }, a.src = r, o.document.body.appendChild(a);
        }
      }, n.EncodeScreenshotCanvasData = function(t, e, i, r, o) {
        if (i === void 0 && (i = "image/png"), typeof r != "string" && e) {
          if (e) {
            if (n._IsOffScreenCanvas(t))
              return void t.convertToBlob({ type: i, quality: o }).then(function(s) {
                var l = new FileReader();
                l.readAsDataURL(s), l.onloadend = function() {
                  var c = l.result;
                  e(c);
                };
              });
            var a = t.toDataURL(i, o);
            e(a);
          }
        } else
          this.ToBlob(t, function(s) {
            s && n.DownloadBlob(s, r), e && e("");
          }, i, o);
      }, n.Download = function(t, e) {
        if (typeof URL < "u") {
          var i = window.URL.createObjectURL(t), r = document.createElement("a");
          document.body.appendChild(r), r.style.display = "none", r.href = i, r.download = e, r.addEventListener("click", function() {
            r.parentElement && r.parentElement.removeChild(r);
          }), r.click(), window.URL.revokeObjectURL(i);
        }
      }, n.BackCompatCameraNoPreventDefault = function(t) {
        return typeof t[0] == "boolean" ? t[0] : typeof t[1] == "boolean" && t[1];
      }, n.CreateScreenshot = function(t, e, i, r, o, a, s) {
        throw et("ScreenshotTools");
      }, n.CreateScreenshotAsync = function(t, e, i, r, o) {
        throw et("ScreenshotTools");
      }, n.CreateScreenshotUsingRenderTarget = function(t, e, i, r, o, a, s, l, c, u, h, d) {
        throw et("ScreenshotTools");
      }, n.CreateScreenshotUsingRenderTargetAsync = function(t, e, i, r, o, a, s, l, c, u, h) {
        throw et("ScreenshotTools");
      }, n.RandomId = function() {
        return ra();
      }, n.IsBase64 = function(t) {
        return Uu(t);
      }, n.DecodeBase64 = function(t) {
        return Vu(t);
      }, Object.defineProperty(n, "errorsCount", { get: function() {
        return q.errorsCount;
      }, enumerable: !1, configurable: !0 }), n.Log = function(t) {
        q.Log(t);
      }, n.Warn = function(t) {
        q.Warn(t);
      }, n.Error = function(t) {
        q.Error(t);
      }, Object.defineProperty(n, "LogCache", { get: function() {
        return q.LogCache;
      }, enumerable: !1, configurable: !0 }), n.ClearLogCache = function() {
        q.ClearLogCache();
      }, Object.defineProperty(n, "LogLevels", { set: function(t) {
        q.LogLevels = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "PerformanceLogLevel", { set: function(t) {
        return (t & n.PerformanceUserMarkLogLevel) === n.PerformanceUserMarkLogLevel ? (n.StartPerformanceCounter = n._StartUserMark, void (n.EndPerformanceCounter = n._EndUserMark)) : (t & n.PerformanceConsoleLogLevel) === n.PerformanceConsoleLogLevel ? (n.StartPerformanceCounter = n._StartPerformanceConsole, void (n.EndPerformanceCounter = n._EndPerformanceConsole)) : (n.StartPerformanceCounter = n._StartPerformanceCounterDisabled, void (n.EndPerformanceCounter = n._EndPerformanceCounterDisabled));
      }, enumerable: !1, configurable: !0 }), n._StartPerformanceCounterDisabled = function(t, e) {
      }, n._EndPerformanceCounterDisabled = function(t, e) {
      }, n._StartUserMark = function(t, e) {
        if (e === void 0 && (e = !0), !n._Performance) {
          if (!Gi())
            return;
          n._Performance = window.performance;
        }
        e && n._Performance.mark && n._Performance.mark(t + "-Begin");
      }, n._EndUserMark = function(t, e) {
        e === void 0 && (e = !0), e && n._Performance.mark && (n._Performance.mark(t + "-End"), n._Performance.measure(t, t + "-Begin", t + "-End"));
      }, n._StartPerformanceConsole = function(t, e) {
        e === void 0 && (e = !0), e && (n._StartUserMark(t, e), console.time && console.time(t));
      }, n._EndPerformanceConsole = function(t, e) {
        e === void 0 && (e = !0), e && (n._EndUserMark(t, e), console.timeEnd(t));
      }, Object.defineProperty(n, "Now", { get: function() {
        return It.Now;
      }, enumerable: !1, configurable: !0 }), n.GetClassName = function(t, e) {
        e === void 0 && (e = !1);
        var i = null;
        return !e && t.getClassName ? i = t.getClassName() : (t instanceof Object && (i = (e ? t : Object.getPrototypeOf(t)).constructor.__bjsclassName__), i || (i = typeof t)), i;
      }, n.First = function(t, e) {
        for (var i = 0, r = t; i < r.length; i++) {
          var o = r[i];
          if (e(o))
            return o;
        }
        return null;
      }, n.getFullClassName = function(t, e) {
        e === void 0 && (e = !1);
        var i = null, r = null;
        if (!e && t.getClassName)
          i = t.getClassName();
        else {
          if (t instanceof Object) {
            var o = e ? t : Object.getPrototypeOf(t);
            i = o.constructor.__bjsclassName__, r = o.constructor.__bjsmoduleName__;
          }
          i || (i = typeof t);
        }
        return i ? (r != null ? r + "." : "") + i : null;
      }, n.DelayAsync = function(t) {
        return new Promise(function(e) {
          setTimeout(function() {
            e();
          }, t);
        });
      }, n.IsSafari = function() {
        return !!us() && /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
      }, n.UseCustomRequestHeaders = !1, n.CustomRequestHeaders = _n.CustomRequestHeaders, n.GetDOMTextContent = Jl, n._DefaultCdnUrl = "https://cdn.babylonjs.com", n.GetAbsoluteUrl = typeof document == "object" ? function(t) {
        var e = document.createElement("a");
        return e.href = t, e.href;
      } : typeof URL == "function" && typeof location == "object" ? function(t) {
        return new URL(t, location.origin).href;
      } : function() {
        throw new Error("Unable to get absolute URL. Override BABYLON.Tools.GetAbsoluteUrl to a custom implementation for the current context.");
      }, n.NoneLogLevel = q.NoneLogLevel, n.MessageLogLevel = q.MessageLogLevel, n.WarningLogLevel = q.WarningLogLevel, n.ErrorLogLevel = q.ErrorLogLevel, n.AllLogLevel = q.AllLogLevel, n.IsWindowObjectExist = Gi, n.PerformanceNoneLogLevel = 0, n.PerformanceUserMarkLogLevel = 1, n.PerformanceConsoleLogLevel = 2, n.StartPerformanceCounter = n._StartPerformanceCounterDisabled, n.EndPerformanceCounter = n._EndPerformanceCounterDisabled, n;
    }();
    function HA(n, t) {
      return function(e) {
        e.__bjsclassName__ = n, e.__bjsmoduleName__ = t ?? null;
      };
    }
    var So = function() {
      function n(t, e, i, r) {
        r === void 0 && (r = 0), this.iterations = t, this.index = r - 1, this._done = !1, this._fn = e, this._successCallback = i;
      }
      return n.prototype.executeNext = function() {
        this._done || (this.index + 1 < this.iterations ? (++this.index, this._fn(this)) : this.breakLoop());
      }, n.prototype.breakLoop = function() {
        this._done = !0, this._successCallback();
      }, n.Run = function(t, e, i, r) {
        r === void 0 && (r = 0);
        var o = new n(t, e, i, r);
        return o.executeNext(), o;
      }, n.SyncAsyncForLoop = function(t, e, i, r, o, a) {
        return a === void 0 && (a = 0), n.Run(Math.ceil(t / e), function(s) {
          o && o() ? s.breakLoop() : setTimeout(function() {
            for (var l = 0; l < e; ++l) {
              var c = s.index * e + l;
              if (c >= t)
                break;
              if (i(c), o && o()) {
                s.breakLoop();
                break;
              }
            }
            s.executeNext();
          }, a);
        }, r);
      }, n;
    }();
    Me.FallbackTexture = "data:image/jpg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBmRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAAExAAIAAAAQAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQubmV0IDQuMC41AP/bAEMABAIDAwMCBAMDAwQEBAQFCQYFBQUFCwgIBgkNCw0NDQsMDA4QFBEODxMPDAwSGBITFRYXFxcOERkbGRYaFBYXFv/bAEMBBAQEBQUFCgYGChYPDA8WFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFv/AABEIAQABAAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APH6KKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76P//Z";
    var en = function() {
      function n(t) {
        this.length = 0, this.data = new Array(t), this._id = n._GlobalId++;
      }
      return n.prototype.push = function(t) {
        this.data[this.length++] = t, this.length > this.data.length && (this.data.length *= 2);
      }, n.prototype.forEach = function(t) {
        for (var e = 0; e < this.length; e++)
          t(this.data[e]);
      }, n.prototype.sort = function(t) {
        this.data.sort(t);
      }, n.prototype.reset = function() {
        this.length = 0;
      }, n.prototype.dispose = function() {
        this.reset(), this.data && (this.data.length = 0);
      }, n.prototype.concat = function(t) {
        if (t.length !== 0) {
          this.length + t.length > this.data.length && (this.data.length = 2 * (this.length + t.length));
          for (var e = 0; e < t.length; e++)
            this.data[this.length++] = (t.data || t)[e];
        }
      }, n.prototype.indexOf = function(t) {
        var e = this.data.indexOf(t);
        return e >= this.length ? -1 : e;
      }, n.prototype.contains = function(t) {
        return this.indexOf(t) !== -1;
      }, n._GlobalId = 0, n;
    }(), oa = function(n) {
      function t() {
        var e = n !== null && n.apply(this, arguments) || this;
        return e._duplicateId = 0, e;
      }
      return D(t, n), t.prototype.push = function(e) {
        n.prototype.push.call(this, e), e.__smartArrayFlags || (e.__smartArrayFlags = {}), e.__smartArrayFlags[this._id] = this._duplicateId;
      }, t.prototype.pushNoDuplicate = function(e) {
        return !(e.__smartArrayFlags && e.__smartArrayFlags[this._id] === this._duplicateId || (this.push(e), 0));
      }, t.prototype.reset = function() {
        n.prototype.reset.call(this), this._duplicateId++;
      }, t.prototype.concatWithNoDuplicate = function(e) {
        if (e.length !== 0) {
          this.length + e.length > this.data.length && (this.data.length = 2 * (this.length + e.length));
          for (var i = 0; i < e.length; i++) {
            var r = (e.data || e)[i];
            this.pushNoDuplicate(r);
          }
        }
      }, t;
    }(en), ku = function() {
      function n() {
        this._count = 0, this._data = {};
      }
      return n.prototype.copyFrom = function(t) {
        var e = this;
        this.clear(), t.forEach(function(i, r) {
          return e.add(i, r);
        });
      }, n.prototype.get = function(t) {
        var e = this._data[t];
        if (e !== void 0)
          return e;
      }, n.prototype.getOrAddWithFactory = function(t, e) {
        var i = this.get(t);
        return i !== void 0 || (i = e(t)) && this.add(t, i), i;
      }, n.prototype.getOrAdd = function(t, e) {
        var i = this.get(t);
        return i !== void 0 ? i : (this.add(t, e), e);
      }, n.prototype.contains = function(t) {
        return this._data[t] !== void 0;
      }, n.prototype.add = function(t, e) {
        return this._data[t] === void 0 && (this._data[t] = e, ++this._count, !0);
      }, n.prototype.set = function(t, e) {
        return this._data[t] !== void 0 && (this._data[t] = e, !0);
      }, n.prototype.getAndRemove = function(t) {
        var e = this.get(t);
        return e !== void 0 ? (delete this._data[t], --this._count, e) : null;
      }, n.prototype.remove = function(t) {
        return !!this.contains(t) && (delete this._data[t], --this._count, !0);
      }, n.prototype.clear = function() {
        this._data = {}, this._count = 0;
      }, Object.defineProperty(n.prototype, "count", { get: function() {
        return this._count;
      }, enumerable: !1, configurable: !0 }), n.prototype.forEach = function(t) {
        for (var e in this._data)
          t(e, this._data[e]);
      }, n.prototype.first = function(t) {
        for (var e in this._data) {
          var i = t(e, this._data[e]);
          if (i)
            return i;
        }
        return null;
      }, n;
    }(), jn = function() {
      function n(t) {
        if (this._keys = [], this._isDirty = !0, this._areLightsDirty = !0, this._areLightsDisposed = !1, this._areAttributesDirty = !0, this._areTexturesDirty = !0, this._areFresnelDirty = !0, this._areMiscDirty = !0, this._arePrePassDirty = !0, this._areImageProcessingDirty = !0, this._normals = !1, this._uvs = !1, this._needNormals = !1, this._needUVs = !1, this._externalProperties = t, t)
          for (var e in t)
            Object.prototype.hasOwnProperty.call(t, e) && this._setDefaultValue(e);
      }
      return Object.defineProperty(n.prototype, "isDirty", { get: function() {
        return this._isDirty;
      }, enumerable: !1, configurable: !0 }), n.prototype.markAsProcessed = function() {
        this._isDirty = !1, this._areAttributesDirty = !1, this._areTexturesDirty = !1, this._areFresnelDirty = !1, this._areLightsDirty = !1, this._areLightsDisposed = !1, this._areMiscDirty = !1, this._arePrePassDirty = !1, this._areImageProcessingDirty = !1;
      }, n.prototype.markAsUnprocessed = function() {
        this._isDirty = !0;
      }, n.prototype.markAllAsDirty = function() {
        this._areTexturesDirty = !0, this._areAttributesDirty = !0, this._areLightsDirty = !0, this._areFresnelDirty = !0, this._areMiscDirty = !0, this._arePrePassDirty = !1, this._areImageProcessingDirty = !0, this._isDirty = !0;
      }, n.prototype.markAsImageProcessingDirty = function() {
        this._areImageProcessingDirty = !0, this._isDirty = !0;
      }, n.prototype.markAsLightDirty = function(t) {
        t === void 0 && (t = !1), this._areLightsDirty = !0, this._areLightsDisposed = this._areLightsDisposed || t, this._isDirty = !0;
      }, n.prototype.markAsAttributesDirty = function() {
        this._areAttributesDirty = !0, this._isDirty = !0;
      }, n.prototype.markAsTexturesDirty = function() {
        this._areTexturesDirty = !0, this._isDirty = !0;
      }, n.prototype.markAsFresnelDirty = function() {
        this._areFresnelDirty = !0, this._isDirty = !0;
      }, n.prototype.markAsMiscDirty = function() {
        this._areMiscDirty = !0, this._isDirty = !0;
      }, n.prototype.markAsPrePassDirty = function() {
        this._arePrePassDirty = !0, this._isDirty = !0;
      }, n.prototype.rebuild = function() {
        this._keys.length = 0;
        for (var t = 0, e = Object.keys(this); t < e.length; t++) {
          var i = e[t];
          i[0] !== "_" && this._keys.push(i);
        }
        if (this._externalProperties)
          for (var r in this._externalProperties)
            this._keys.indexOf(r) === -1 && this._keys.push(r);
      }, n.prototype.isEqual = function(t) {
        if (this._keys.length !== t._keys.length)
          return !1;
        for (var e = 0; e < this._keys.length; e++) {
          var i = this._keys[e];
          if (this[i] !== t[i])
            return !1;
        }
        return !0;
      }, n.prototype.cloneTo = function(t) {
        this._keys.length !== t._keys.length && (t._keys = this._keys.slice(0));
        for (var e = 0; e < this._keys.length; e++) {
          var i = this._keys[e];
          t[i] = this[i];
        }
      }, n.prototype.reset = function() {
        var t = this;
        this._keys.forEach(function(e) {
          return t._setDefaultValue(e);
        });
      }, n.prototype._setDefaultValue = function(t) {
        var e, i, r, o, a, s = (r = (i = (e = this._externalProperties) === null || e === void 0 ? void 0 : e[t]) === null || i === void 0 ? void 0 : i.type) !== null && r !== void 0 ? r : typeof this[t], l = (a = (o = this._externalProperties) === null || o === void 0 ? void 0 : o[t]) === null || a === void 0 ? void 0 : a.default;
        switch (s) {
          case "number":
            this[t] = l ?? 0;
            break;
          case "string":
            this[t] = l ?? "";
            break;
          default:
            this[t] = l != null && l;
        }
      }, n.prototype.toString = function() {
        for (var t = "", e = 0; e < this._keys.length; e++) {
          var i = this._keys[e], r = this[i];
          switch (typeof r) {
            case "number":
            case "string":
              t += "#define " + i + " " + r + `
`;
              break;
            default:
              r && (t += "#define " + i + `
`);
          }
        }
        return t;
      }, n;
    }(), tc = function() {
      function n() {
        this._dirty = !0, this._tempColor = new Ie(0, 0, 0, 0), this._globalCurve = new Ie(0, 0, 0, 0), this._highlightsCurve = new Ie(0, 0, 0, 0), this._midtonesCurve = new Ie(0, 0, 0, 0), this._shadowsCurve = new Ie(0, 0, 0, 0), this._positiveCurve = new Ie(0, 0, 0, 0), this._negativeCurve = new Ie(0, 0, 0, 0), this._globalHue = 30, this._globalDensity = 0, this._globalSaturation = 0, this._globalExposure = 0, this._highlightsHue = 30, this._highlightsDensity = 0, this._highlightsSaturation = 0, this._highlightsExposure = 0, this._midtonesHue = 30, this._midtonesDensity = 0, this._midtonesSaturation = 0, this._midtonesExposure = 0, this._shadowsHue = 30, this._shadowsDensity = 0, this._shadowsSaturation = 0, this._shadowsExposure = 0;
      }
      return Object.defineProperty(n.prototype, "globalHue", { get: function() {
        return this._globalHue;
      }, set: function(t) {
        this._globalHue = t, this._dirty = !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "globalDensity", { get: function() {
        return this._globalDensity;
      }, set: function(t) {
        this._globalDensity = t, this._dirty = !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "globalSaturation", { get: function() {
        return this._globalSaturation;
      }, set: function(t) {
        this._globalSaturation = t, this._dirty = !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "globalExposure", { get: function() {
        return this._globalExposure;
      }, set: function(t) {
        this._globalExposure = t, this._dirty = !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "highlightsHue", { get: function() {
        return this._highlightsHue;
      }, set: function(t) {
        this._highlightsHue = t, this._dirty = !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "highlightsDensity", { get: function() {
        return this._highlightsDensity;
      }, set: function(t) {
        this._highlightsDensity = t, this._dirty = !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "highlightsSaturation", { get: function() {
        return this._highlightsSaturation;
      }, set: function(t) {
        this._highlightsSaturation = t, this._dirty = !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "highlightsExposure", { get: function() {
        return this._highlightsExposure;
      }, set: function(t) {
        this._highlightsExposure = t, this._dirty = !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "midtonesHue", { get: function() {
        return this._midtonesHue;
      }, set: function(t) {
        this._midtonesHue = t, this._dirty = !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "midtonesDensity", { get: function() {
        return this._midtonesDensity;
      }, set: function(t) {
        this._midtonesDensity = t, this._dirty = !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "midtonesSaturation", { get: function() {
        return this._midtonesSaturation;
      }, set: function(t) {
        this._midtonesSaturation = t, this._dirty = !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "midtonesExposure", { get: function() {
        return this._midtonesExposure;
      }, set: function(t) {
        this._midtonesExposure = t, this._dirty = !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "shadowsHue", { get: function() {
        return this._shadowsHue;
      }, set: function(t) {
        this._shadowsHue = t, this._dirty = !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "shadowsDensity", { get: function() {
        return this._shadowsDensity;
      }, set: function(t) {
        this._shadowsDensity = t, this._dirty = !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "shadowsSaturation", { get: function() {
        return this._shadowsSaturation;
      }, set: function(t) {
        this._shadowsSaturation = t, this._dirty = !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "shadowsExposure", { get: function() {
        return this._shadowsExposure;
      }, set: function(t) {
        this._shadowsExposure = t, this._dirty = !0;
      }, enumerable: !1, configurable: !0 }), n.prototype.getClassName = function() {
        return "ColorCurves";
      }, n.Bind = function(t, e, i, r, o) {
        i === void 0 && (i = "vCameraColorCurvePositive"), r === void 0 && (r = "vCameraColorCurveNeutral"), o === void 0 && (o = "vCameraColorCurveNegative"), t._dirty && (t._dirty = !1, t._getColorGradingDataToRef(t._globalHue, t._globalDensity, t._globalSaturation, t._globalExposure, t._globalCurve), t._getColorGradingDataToRef(t._highlightsHue, t._highlightsDensity, t._highlightsSaturation, t._highlightsExposure, t._tempColor), t._tempColor.multiplyToRef(t._globalCurve, t._highlightsCurve), t._getColorGradingDataToRef(t._midtonesHue, t._midtonesDensity, t._midtonesSaturation, t._midtonesExposure, t._tempColor), t._tempColor.multiplyToRef(t._globalCurve, t._midtonesCurve), t._getColorGradingDataToRef(t._shadowsHue, t._shadowsDensity, t._shadowsSaturation, t._shadowsExposure, t._tempColor), t._tempColor.multiplyToRef(t._globalCurve, t._shadowsCurve), t._highlightsCurve.subtractToRef(t._midtonesCurve, t._positiveCurve), t._midtonesCurve.subtractToRef(t._shadowsCurve, t._negativeCurve)), e && (e.setFloat4(i, t._positiveCurve.r, t._positiveCurve.g, t._positiveCurve.b, t._positiveCurve.a), e.setFloat4(r, t._midtonesCurve.r, t._midtonesCurve.g, t._midtonesCurve.b, t._midtonesCurve.a), e.setFloat4(o, t._negativeCurve.r, t._negativeCurve.g, t._negativeCurve.b, t._negativeCurve.a));
      }, n.PrepareUniforms = function(t) {
        t.push("vCameraColorCurveNeutral", "vCameraColorCurvePositive", "vCameraColorCurveNegative");
      }, n.prototype._getColorGradingDataToRef = function(t, e, i, r, o) {
        t != null && (t = n._Clamp(t, 0, 360), e = n._Clamp(e, -100, 100), i = n._Clamp(i, -100, 100), r = n._Clamp(r, -100, 100), e = n._ApplyColorGradingSliderNonlinear(e), e *= 0.5, r = n._ApplyColorGradingSliderNonlinear(r), e < 0 && (e *= -1, t = (t + 180) % 360), n._FromHSBToRef(t, e, 50 + 0.25 * r, o), o.scaleToRef(2, o), o.a = 1 + 0.01 * i);
      }, n._ApplyColorGradingSliderNonlinear = function(t) {
        t /= 100;
        var e = Math.abs(t);
        return e = Math.pow(e, 2), t < 0 && (e *= -1), 100 * e;
      }, n._FromHSBToRef = function(t, e, i, r) {
        var o = n._Clamp(t, 0, 360), a = n._Clamp(e / 100, 0, 1), s = n._Clamp(i / 100, 0, 1);
        if (a === 0)
          r.r = s, r.g = s, r.b = s;
        else {
          o /= 60;
          var l = Math.floor(o), c = o - l, u = s * (1 - a), h = s * (1 - a * c), d = s * (1 - a * (1 - c));
          switch (l) {
            case 0:
              r.r = s, r.g = d, r.b = u;
              break;
            case 1:
              r.r = h, r.g = s, r.b = u;
              break;
            case 2:
              r.r = u, r.g = s, r.b = d;
              break;
            case 3:
              r.r = u, r.g = h, r.b = s;
              break;
            case 4:
              r.r = d, r.g = u, r.b = s;
              break;
            default:
              r.r = s, r.g = u, r.b = h;
          }
        }
        r.a = 1;
      }, n._Clamp = function(t, e, i) {
        return Math.min(Math.max(t, e), i);
      }, n.prototype.clone = function() {
        return Ne.Clone(function() {
          return new n();
        }, this);
      }, n.prototype.serialize = function() {
        return Ne.Serialize(this);
      }, n.Parse = function(t) {
        return Ne.Parse(function() {
          return new n();
        }, t, null, null);
      }, x([N()], n.prototype, "_globalHue", void 0), x([N()], n.prototype, "_globalDensity", void 0), x([N()], n.prototype, "_globalSaturation", void 0), x([N()], n.prototype, "_globalExposure", void 0), x([N()], n.prototype, "_highlightsHue", void 0), x([N()], n.prototype, "_highlightsDensity", void 0), x([N()], n.prototype, "_highlightsSaturation", void 0), x([N()], n.prototype, "_highlightsExposure", void 0), x([N()], n.prototype, "_midtonesHue", void 0), x([N()], n.prototype, "_midtonesDensity", void 0), x([N()], n.prototype, "_midtonesSaturation", void 0), x([N()], n.prototype, "_midtonesExposure", void 0), n;
    }();
    Ne._ColorCurvesParser = tc.Parse;
    var tg = function(n) {
      function t() {
        var e = n.call(this) || this;
        return e.IMAGEPROCESSING = !1, e.VIGNETTE = !1, e.VIGNETTEBLENDMODEMULTIPLY = !1, e.VIGNETTEBLENDMODEOPAQUE = !1, e.TONEMAPPING = !1, e.TONEMAPPING_ACES = !1, e.CONTRAST = !1, e.COLORCURVES = !1, e.COLORGRADING = !1, e.COLORGRADING3D = !1, e.SAMPLER3DGREENDEPTH = !1, e.SAMPLER3DBGRMAP = !1, e.DITHER = !1, e.IMAGEPROCESSINGPOSTPROCESS = !1, e.EXPOSURE = !1, e.SKIPFINALCOLORCLAMP = !1, e.rebuild(), e;
      }
      return D(t, n), t;
    }(jn), tn = function() {
      function n() {
        this.colorCurves = new tc(), this._colorCurvesEnabled = !1, this._colorGradingEnabled = !1, this._colorGradingWithGreenDepth = !0, this._colorGradingBGR = !0, this._exposure = 1, this._toneMappingEnabled = !1, this._toneMappingType = n.TONEMAPPING_STANDARD, this._contrast = 1, this.vignetteStretch = 0, this.vignetteCenterX = 0, this.vignetteCenterY = 0, this.vignetteWeight = 1.5, this.vignetteColor = new Ie(0, 0, 0, 0), this.vignetteCameraFov = 0.5, this._vignetteBlendMode = n.VIGNETTEMODE_MULTIPLY, this._vignetteEnabled = !1, this._ditheringEnabled = !1, this._ditheringIntensity = 1 / 255, this._skipFinalColorClamp = !1, this._applyByPostProcess = !1, this._isEnabled = !0, this.onUpdateParameters = new H();
      }
      return Object.defineProperty(n.prototype, "colorCurvesEnabled", { get: function() {
        return this._colorCurvesEnabled;
      }, set: function(t) {
        this._colorCurvesEnabled !== t && (this._colorCurvesEnabled = t, this._updateParameters());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "colorGradingTexture", { get: function() {
        return this._colorGradingTexture;
      }, set: function(t) {
        this._colorGradingTexture !== t && (this._colorGradingTexture = t, this._updateParameters());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "colorGradingEnabled", { get: function() {
        return this._colorGradingEnabled;
      }, set: function(t) {
        this._colorGradingEnabled !== t && (this._colorGradingEnabled = t, this._updateParameters());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "colorGradingWithGreenDepth", { get: function() {
        return this._colorGradingWithGreenDepth;
      }, set: function(t) {
        this._colorGradingWithGreenDepth !== t && (this._colorGradingWithGreenDepth = t, this._updateParameters());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "colorGradingBGR", { get: function() {
        return this._colorGradingBGR;
      }, set: function(t) {
        this._colorGradingBGR !== t && (this._colorGradingBGR = t, this._updateParameters());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "exposure", { get: function() {
        return this._exposure;
      }, set: function(t) {
        this._exposure !== t && (this._exposure = t, this._updateParameters());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "toneMappingEnabled", { get: function() {
        return this._toneMappingEnabled;
      }, set: function(t) {
        this._toneMappingEnabled !== t && (this._toneMappingEnabled = t, this._updateParameters());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "toneMappingType", { get: function() {
        return this._toneMappingType;
      }, set: function(t) {
        this._toneMappingType !== t && (this._toneMappingType = t, this._updateParameters());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "contrast", { get: function() {
        return this._contrast;
      }, set: function(t) {
        this._contrast !== t && (this._contrast = t, this._updateParameters());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "vignetteCentreY", { get: function() {
        return this.vignetteCenterY;
      }, set: function(t) {
        this.vignetteCenterY = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "vignetteCentreX", { get: function() {
        return this.vignetteCenterX;
      }, set: function(t) {
        this.vignetteCenterX = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "vignetteBlendMode", { get: function() {
        return this._vignetteBlendMode;
      }, set: function(t) {
        this._vignetteBlendMode !== t && (this._vignetteBlendMode = t, this._updateParameters());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "vignetteEnabled", { get: function() {
        return this._vignetteEnabled;
      }, set: function(t) {
        this._vignetteEnabled !== t && (this._vignetteEnabled = t, this._updateParameters());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "ditheringEnabled", { get: function() {
        return this._ditheringEnabled;
      }, set: function(t) {
        this._ditheringEnabled !== t && (this._ditheringEnabled = t, this._updateParameters());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "ditheringIntensity", { get: function() {
        return this._ditheringIntensity;
      }, set: function(t) {
        this._ditheringIntensity !== t && (this._ditheringIntensity = t, this._updateParameters());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "skipFinalColorClamp", { get: function() {
        return this._skipFinalColorClamp;
      }, set: function(t) {
        this._skipFinalColorClamp !== t && (this._skipFinalColorClamp = t, this._updateParameters());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "applyByPostProcess", { get: function() {
        return this._applyByPostProcess;
      }, set: function(t) {
        this._applyByPostProcess !== t && (this._applyByPostProcess = t, this._updateParameters());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isEnabled", { get: function() {
        return this._isEnabled;
      }, set: function(t) {
        this._isEnabled !== t && (this._isEnabled = t, this._updateParameters());
      }, enumerable: !1, configurable: !0 }), n.prototype._updateParameters = function() {
        this.onUpdateParameters.notifyObservers(this);
      }, n.prototype.getClassName = function() {
        return "ImageProcessingConfiguration";
      }, n.PrepareUniforms = function(t, e) {
        e.EXPOSURE && t.push("exposureLinear"), e.CONTRAST && t.push("contrast"), e.COLORGRADING && t.push("colorTransformSettings"), (e.VIGNETTE || e.DITHER) && t.push("vInverseScreenSize"), e.VIGNETTE && (t.push("vignetteSettings1"), t.push("vignetteSettings2")), e.COLORCURVES && tc.PrepareUniforms(t), e.DITHER && t.push("ditherIntensity");
      }, n.PrepareSamplers = function(t, e) {
        e.COLORGRADING && t.push("txColorTransform");
      }, n.prototype.prepareDefines = function(t, e) {
        if (e === void 0 && (e = !1), e !== this.applyByPostProcess || !this._isEnabled)
          return t.VIGNETTE = !1, t.TONEMAPPING = !1, t.TONEMAPPING_ACES = !1, t.CONTRAST = !1, t.EXPOSURE = !1, t.COLORCURVES = !1, t.COLORGRADING = !1, t.COLORGRADING3D = !1, t.DITHER = !1, t.IMAGEPROCESSING = !1, t.SKIPFINALCOLORCLAMP = this.skipFinalColorClamp, void (t.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess && this._isEnabled);
        t.VIGNETTE = this.vignetteEnabled, t.VIGNETTEBLENDMODEMULTIPLY = this.vignetteBlendMode === n._VIGNETTEMODE_MULTIPLY, t.VIGNETTEBLENDMODEOPAQUE = !t.VIGNETTEBLENDMODEMULTIPLY, t.TONEMAPPING = this.toneMappingEnabled, this._toneMappingType === n.TONEMAPPING_ACES ? t.TONEMAPPING_ACES = !0 : t.TONEMAPPING_ACES = !1, t.CONTRAST = this.contrast !== 1, t.EXPOSURE = this.exposure !== 1, t.COLORCURVES = this.colorCurvesEnabled && !!this.colorCurves, t.COLORGRADING = this.colorGradingEnabled && !!this.colorGradingTexture, t.COLORGRADING ? t.COLORGRADING3D = this.colorGradingTexture.is3D : t.COLORGRADING3D = !1, t.SAMPLER3DGREENDEPTH = this.colorGradingWithGreenDepth, t.SAMPLER3DBGRMAP = this.colorGradingBGR, t.DITHER = this._ditheringEnabled, t.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess, t.SKIPFINALCOLORCLAMP = this.skipFinalColorClamp, t.IMAGEPROCESSING = t.VIGNETTE || t.TONEMAPPING || t.CONTRAST || t.EXPOSURE || t.COLORCURVES || t.COLORGRADING || t.DITHER;
      }, n.prototype.isReady = function() {
        return !this.colorGradingEnabled || !this.colorGradingTexture || this.colorGradingTexture.isReady();
      }, n.prototype.bind = function(t, e) {
        if (this._colorCurvesEnabled && this.colorCurves && tc.Bind(this.colorCurves, t), this._vignetteEnabled || this._ditheringEnabled) {
          var i = 1 / t.getEngine().getRenderWidth(), r = 1 / t.getEngine().getRenderHeight();
          if (t.setFloat2("vInverseScreenSize", i, r), this._ditheringEnabled && t.setFloat("ditherIntensity", 0.5 * this._ditheringIntensity), this._vignetteEnabled) {
            var o = e ?? r / i, a = Math.tan(0.5 * this.vignetteCameraFov), s = a * o, l = Math.sqrt(s * a);
            s = de.Mix(s, l, this.vignetteStretch), a = de.Mix(a, l, this.vignetteStretch), t.setFloat4("vignetteSettings1", s, a, -s * this.vignetteCenterX, -a * this.vignetteCenterY);
            var c = -2 * this.vignetteWeight;
            t.setFloat4("vignetteSettings2", this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, c);
          }
        }
        if (t.setFloat("exposureLinear", this.exposure), t.setFloat("contrast", this.contrast), this.colorGradingTexture) {
          t.setTexture("txColorTransform", this.colorGradingTexture);
          var u = this.colorGradingTexture.getSize().height;
          t.setFloat4("colorTransformSettings", (u - 1) / u, 0.5 / u, u, this.colorGradingTexture.level);
        }
      }, n.prototype.clone = function() {
        return Ne.Clone(function() {
          return new n();
        }, this);
      }, n.prototype.serialize = function() {
        return Ne.Serialize(this);
      }, n.Parse = function(t) {
        var e = Ne.Parse(function() {
          return new n();
        }, t, null, null);
        return t.vignetteCentreX !== void 0 && (e.vignetteCenterX = t.vignetteCentreX), t.vignetteCentreY !== void 0 && (e.vignetteCenterY = t.vignetteCentreY), e;
      }, Object.defineProperty(n, "VIGNETTEMODE_MULTIPLY", { get: function() {
        return this._VIGNETTEMODE_MULTIPLY;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "VIGNETTEMODE_OPAQUE", { get: function() {
        return this._VIGNETTEMODE_OPAQUE;
      }, enumerable: !1, configurable: !0 }), n.TONEMAPPING_STANDARD = 0, n.TONEMAPPING_ACES = 1, n._VIGNETTEMODE_MULTIPLY = 0, n._VIGNETTEMODE_OPAQUE = 1, x([Kl()], n.prototype, "colorCurves", void 0), x([N()], n.prototype, "_colorCurvesEnabled", void 0), x([St("colorGradingTexture")], n.prototype, "_colorGradingTexture", void 0), x([N()], n.prototype, "_colorGradingEnabled", void 0), x([N()], n.prototype, "_colorGradingWithGreenDepth", void 0), x([N()], n.prototype, "_colorGradingBGR", void 0), x([N()], n.prototype, "_exposure", void 0), x([N()], n.prototype, "_toneMappingEnabled", void 0), x([N()], n.prototype, "_toneMappingType", void 0), x([N()], n.prototype, "_contrast", void 0), x([N()], n.prototype, "vignetteStretch", void 0), x([N()], n.prototype, "vignetteCenterX", void 0), x([N()], n.prototype, "vignetteCenterY", void 0), x([N()], n.prototype, "vignetteWeight", void 0), x([ls()], n.prototype, "vignetteColor", void 0), x([N()], n.prototype, "vignetteCameraFov", void 0), x([N()], n.prototype, "_vignetteBlendMode", void 0), x([N()], n.prototype, "_vignetteEnabled", void 0), x([N()], n.prototype, "_ditheringEnabled", void 0), x([N()], n.prototype, "_ditheringIntensity", void 0), x([N()], n.prototype, "_skipFinalColorClamp", void 0), x([N()], n.prototype, "_applyByPostProcess", void 0), x([N()], n.prototype, "_isEnabled", void 0), n;
    }();
    Ne._ImageProcessingConfigurationParser = tn.Parse, Qe.prototype.createUniformBuffer = function(n, t) {
      var e = this._gl.createBuffer();
      if (!e)
        throw new Error("Unable to create uniform buffer");
      var i = new nl(e);
      return this.bindUniformBuffer(i), n instanceof Float32Array ? this._gl.bufferData(this._gl.UNIFORM_BUFFER, n, this._gl.STATIC_DRAW) : this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(n), this._gl.STATIC_DRAW), this.bindUniformBuffer(null), i.references = 1, i;
    }, Qe.prototype.createDynamicUniformBuffer = function(n, t) {
      var e = this._gl.createBuffer();
      if (!e)
        throw new Error("Unable to create dynamic uniform buffer");
      var i = new nl(e);
      return this.bindUniformBuffer(i), n instanceof Float32Array ? this._gl.bufferData(this._gl.UNIFORM_BUFFER, n, this._gl.DYNAMIC_DRAW) : this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(n), this._gl.DYNAMIC_DRAW), this.bindUniformBuffer(null), i.references = 1, i;
    }, Qe.prototype.updateUniformBuffer = function(n, t, e, i) {
      this.bindUniformBuffer(n), e === void 0 && (e = 0), i === void 0 ? t instanceof Float32Array ? this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, e, t) : this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, e, new Float32Array(t)) : t instanceof Float32Array ? this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, t.subarray(e, e + i)) : this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, new Float32Array(t).subarray(e, e + i)), this.bindUniformBuffer(null);
    }, Qe.prototype.bindUniformBuffer = function(n) {
      this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, n ? n.underlyingResource : null);
    }, Qe.prototype.bindUniformBufferBase = function(n, t, e) {
      this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, t, n ? n.underlyingResource : null);
    }, Qe.prototype.bindUniformBlock = function(n, t, e) {
      var i = n.program, r = this._gl.getUniformBlockIndex(i, t);
      r !== 4294967295 && this._gl.uniformBlockBinding(i, r, e);
    };
    var Ze, at, ic, dp, pp, fp, _p, mp, Er = function() {
      function n(t, e, i, r, o) {
        o === void 0 && (o = !1), this._valueCache = {}, this._engine = t, this._noUBO = !t.supportsUniformBuffers || o, this._dynamic = i, this._name = r ?? "no-name", this._data = e || [], this._uniformLocations = {}, this._uniformSizes = {}, this._uniformArraySizes = {}, this._uniformLocationPointer = 0, this._needSync = !1, this._engine._features.trackUbosInFrame && (this._buffers = [], this._bufferIndex = -1, this._createBufferOnWrite = !1, this._currentFrameId = 0), this._noUBO ? (this.updateMatrix3x3 = this._updateMatrix3x3ForEffect, this.updateMatrix2x2 = this._updateMatrix2x2ForEffect, this.updateFloat = this._updateFloatForEffect, this.updateFloat2 = this._updateFloat2ForEffect, this.updateFloat3 = this._updateFloat3ForEffect, this.updateFloat4 = this._updateFloat4ForEffect, this.updateFloatArray = this._updateFloatArrayForEffect, this.updateArray = this._updateArrayForEffect, this.updateIntArray = this._updateIntArrayForEffect, this.updateUIntArray = this._updateUIntArrayForEffect, this.updateMatrix = this._updateMatrixForEffect, this.updateMatrices = this._updateMatricesForEffect, this.updateVector3 = this._updateVector3ForEffect, this.updateVector4 = this._updateVector4ForEffect, this.updateColor3 = this._updateColor3ForEffect, this.updateColor4 = this._updateColor4ForEffect, this.updateDirectColor4 = this._updateDirectColor4ForEffect, this.updateInt = this._updateIntForEffect, this.updateInt2 = this._updateInt2ForEffect, this.updateInt3 = this._updateInt3ForEffect, this.updateInt4 = this._updateInt4ForEffect, this.updateUInt = this._updateUIntForEffect, this.updateUInt2 = this._updateUInt2ForEffect, this.updateUInt3 = this._updateUInt3ForEffect, this.updateUInt4 = this._updateUInt4ForEffect) : (this._engine._uniformBuffers.push(this), this.updateMatrix3x3 = this._updateMatrix3x3ForUniform, this.updateMatrix2x2 = this._updateMatrix2x2ForUniform, this.updateFloat = this._updateFloatForUniform, this.updateFloat2 = this._updateFloat2ForUniform, this.updateFloat3 = this._updateFloat3ForUniform, this.updateFloat4 = this._updateFloat4ForUniform, this.updateFloatArray = this._updateFloatArrayForUniform, this.updateArray = this._updateArrayForUniform, this.updateIntArray = this._updateIntArrayForUniform, this.updateUIntArray = this._updateUIntArrayForUniform, this.updateMatrix = this._updateMatrixForUniform, this.updateMatrices = this._updateMatricesForUniform, this.updateVector3 = this._updateVector3ForUniform, this.updateVector4 = this._updateVector4ForUniform, this.updateColor3 = this._updateColor3ForUniform, this.updateColor4 = this._updateColor4ForUniform, this.updateDirectColor4 = this._updateDirectColor4ForUniform, this.updateInt = this._updateIntForUniform, this.updateInt2 = this._updateInt2ForUniform, this.updateInt3 = this._updateInt3ForUniform, this.updateInt4 = this._updateInt4ForUniform, this.updateUInt = this._updateUIntForUniform, this.updateUInt2 = this._updateUInt2ForUniform, this.updateUInt3 = this._updateUInt3ForUniform, this.updateUInt4 = this._updateUInt4ForUniform);
      }
      return Object.defineProperty(n.prototype, "useUbo", { get: function() {
        return !this._noUBO;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isSync", { get: function() {
        return !this._needSync;
      }, enumerable: !1, configurable: !0 }), n.prototype.isDynamic = function() {
        return this._dynamic !== void 0;
      }, n.prototype.getData = function() {
        return this._bufferData;
      }, n.prototype.getBuffer = function() {
        return this._buffer;
      }, n.prototype._fillAlignment = function(t) {
        var e;
        if (e = t <= 2 ? t : 4, this._uniformLocationPointer % e != 0) {
          var i = this._uniformLocationPointer;
          this._uniformLocationPointer += e - this._uniformLocationPointer % e;
          for (var r = this._uniformLocationPointer - i, o = 0; o < r; o++)
            this._data.push(0);
        }
      }, n.prototype.addUniform = function(t, e, i) {
        if (i === void 0 && (i = 0), !this._noUBO && this._uniformLocations[t] === void 0) {
          var r;
          if (i > 0) {
            if (e instanceof Array)
              throw "addUniform should not be use with Array in UBO: " + t;
            this._fillAlignment(4), this._uniformArraySizes[t] = { strideSize: e, arraySize: i }, e == 16 ? e *= i : e = e * i + (4 - e) * i, r = [];
            for (var o = 0; o < e; o++)
              r.push(0);
          } else {
            if (e instanceof Array)
              e = (r = e).length;
            else
              for (r = [], o = 0; o < e; o++)
                r.push(0);
            this._fillAlignment(e);
          }
          for (this._uniformSizes[t] = e, this._uniformLocations[t] = this._uniformLocationPointer, this._uniformLocationPointer += e, o = 0; o < e; o++)
            this._data.push(r[o]);
          this._needSync = !0;
        }
      }, n.prototype.addMatrix = function(t, e) {
        this.addUniform(t, Array.prototype.slice.call(e.toArray()));
      }, n.prototype.addFloat2 = function(t, e, i) {
        var r = [e, i];
        this.addUniform(t, r);
      }, n.prototype.addFloat3 = function(t, e, i, r) {
        var o = [e, i, r];
        this.addUniform(t, o);
      }, n.prototype.addColor3 = function(t, e) {
        var i = [e.r, e.g, e.b];
        this.addUniform(t, i);
      }, n.prototype.addColor4 = function(t, e, i) {
        var r = [e.r, e.g, e.b, i];
        this.addUniform(t, r);
      }, n.prototype.addVector3 = function(t, e) {
        var i = [e.x, e.y, e.z];
        this.addUniform(t, i);
      }, n.prototype.addMatrix3x3 = function(t) {
        this.addUniform(t, 12);
      }, n.prototype.addMatrix2x2 = function(t) {
        this.addUniform(t, 8);
      }, n.prototype.create = function() {
        this._noUBO || this._buffer || (this._fillAlignment(4), this._bufferData = new Float32Array(this._data), this._rebuild(), this._needSync = !0);
      }, n.prototype._getNames = function() {
        var t = [];
        for (var e in this._uniformLocations)
          t.push(e);
        return t.join(",");
      }, n.prototype._rebuild = function() {
        !this._noUBO && this._bufferData && (this._dynamic ? this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData, this._name + "_UniformList:" + this._getNames()) : this._buffer = this._engine.createUniformBuffer(this._bufferData, this._name + "_UniformList:" + this._getNames()), this._engine._features.trackUbosInFrame && (this._buffers.push([this._buffer, this._engine._features.checkUbosContentBeforeUpload ? this._bufferData.slice() : void 0]), this._bufferIndex = this._buffers.length - 1, this._createBufferOnWrite = !1));
      }, Object.defineProperty(n.prototype, "_numBuffers", { get: function() {
        return this._buffers.length;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "_indexBuffer", { get: function() {
        return this._bufferIndex;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "name", { get: function() {
        return this._name;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "currentEffect", { get: function() {
        return this._currentEffect;
      }, enumerable: !1, configurable: !0 }), n.prototype._buffersEqual = function(t, e) {
        for (var i = 0; i < t.length; ++i)
          if (t[i] !== e[i])
            return !1;
        return !0;
      }, n.prototype._copyBuffer = function(t, e) {
        for (var i = 0; i < t.length; ++i)
          e[i] = t[i];
      }, n.prototype.update = function() {
        if (!this._noUBO)
          if (this.bindUniformBuffer(), this._buffer)
            if (this._dynamic || this._needSync) {
              if (this._buffers && this._buffers.length > 1 && this._buffers[this._bufferIndex][1]) {
                if (this._buffersEqual(this._bufferData, this._buffers[this._bufferIndex][1]))
                  return this._needSync = !1, void (this._createBufferOnWrite = this._engine._features.trackUbosInFrame);
                this._copyBuffer(this._bufferData, this._buffers[this._bufferIndex][1]);
              }
              this._engine.updateUniformBuffer(this._buffer, this._bufferData), this._engine._features._collectUbosUpdatedInFrame && (n._UpdatedUbosInFrame[this._name] || (n._UpdatedUbosInFrame[this._name] = 0), n._UpdatedUbosInFrame[this._name]++), this._needSync = !1, this._createBufferOnWrite = this._engine._features.trackUbosInFrame;
            } else
              this._createBufferOnWrite = this._engine._features.trackUbosInFrame;
          else
            this.create();
      }, n.prototype._createNewBuffer = function() {
        this._bufferIndex + 1 < this._buffers.length ? (this._bufferIndex++, this._buffer = this._buffers[this._bufferIndex][0], this._createBufferOnWrite = !1, this._needSync = !0) : this._rebuild();
      }, n.prototype._checkNewFrame = function() {
        this._engine._features.trackUbosInFrame && this._currentFrameId !== this._engine.frameId && (this._currentFrameId = this._engine.frameId, this._createBufferOnWrite = !1, this._buffers && this._buffers.length > 0 ? (this._needSync = this._bufferIndex !== 0, this._bufferIndex = 0, this._buffer = this._buffers[this._bufferIndex][0]) : this._bufferIndex = -1);
      }, n.prototype.updateUniform = function(t, e, i) {
        this._checkNewFrame();
        var r = this._uniformLocations[t];
        if (r === void 0) {
          if (this._buffer)
            return void q.Error("Cannot add an uniform after UBO has been created.");
          this.addUniform(t, i), r = this._uniformLocations[t];
        }
        if (this._buffer || this.create(), this._dynamic)
          for (a = 0; a < i; a++)
            this._bufferData[r + a] = e[a];
        else {
          for (var o = !1, a = 0; a < i; a++)
            (i === 16 && !this._engine._features.uniformBufferHardCheckMatrix || this._bufferData[r + a] !== Math.fround(e[a])) && (o = !0, this._createBufferOnWrite && this._createNewBuffer(), this._bufferData[r + a] = e[a]);
          this._needSync = this._needSync || o;
        }
      }, n.prototype.updateUniformArray = function(t, e, i) {
        this._checkNewFrame();
        var r = this._uniformLocations[t];
        if (r !== void 0) {
          this._buffer || this.create();
          var o = this._uniformArraySizes[t];
          if (this._dynamic)
            for (c = 0; c < i; c++)
              this._bufferData[r + c] = e[c];
          else {
            for (var a = !1, s = 0, l = 0, c = 0; c < i; c++)
              if (this._bufferData[r + 4 * l + s] !== de.FloatRound(e[c]) && (a = !0, this._createBufferOnWrite && this._createNewBuffer(), this._bufferData[r + 4 * l + s] = e[c]), ++s === o.strideSize) {
                for (; s < 4; s++)
                  this._bufferData[r + 4 * l + s] = 0;
                s = 0, l++;
              }
            this._needSync = this._needSync || a;
          }
        } else
          q.Error("Cannot add an uniform Array dynamically. Please, add it using addUniform and make sure that uniform buffers are supported by the current engine.");
      }, n.prototype._cacheMatrix = function(t, e) {
        this._checkNewFrame();
        var i = this._valueCache[t], r = e.updateFlag;
        return (i === void 0 || i !== r) && (this._valueCache[t] = r, !0);
      }, n.prototype._updateMatrix3x3ForUniform = function(t, e) {
        for (var i = 0; i < 3; i++)
          n._TempBuffer[4 * i] = e[3 * i], n._TempBuffer[4 * i + 1] = e[3 * i + 1], n._TempBuffer[4 * i + 2] = e[3 * i + 2], n._TempBuffer[4 * i + 3] = 0;
        this.updateUniform(t, n._TempBuffer, 12);
      }, n.prototype._updateMatrix3x3ForEffect = function(t, e) {
        this._currentEffect.setMatrix3x3(t, e);
      }, n.prototype._updateMatrix2x2ForEffect = function(t, e) {
        this._currentEffect.setMatrix2x2(t, e);
      }, n.prototype._updateMatrix2x2ForUniform = function(t, e) {
        for (var i = 0; i < 2; i++)
          n._TempBuffer[4 * i] = e[2 * i], n._TempBuffer[4 * i + 1] = e[2 * i + 1], n._TempBuffer[4 * i + 2] = 0, n._TempBuffer[4 * i + 3] = 0;
        this.updateUniform(t, n._TempBuffer, 8);
      }, n.prototype._updateFloatForEffect = function(t, e) {
        this._currentEffect.setFloat(t, e);
      }, n.prototype._updateFloatForUniform = function(t, e) {
        n._TempBuffer[0] = e, this.updateUniform(t, n._TempBuffer, 1);
      }, n.prototype._updateFloat2ForEffect = function(t, e, i, r) {
        r === void 0 && (r = ""), this._currentEffect.setFloat2(t + r, e, i);
      }, n.prototype._updateFloat2ForUniform = function(t, e, i) {
        n._TempBuffer[0] = e, n._TempBuffer[1] = i, this.updateUniform(t, n._TempBuffer, 2);
      }, n.prototype._updateFloat3ForEffect = function(t, e, i, r, o) {
        o === void 0 && (o = ""), this._currentEffect.setFloat3(t + o, e, i, r);
      }, n.prototype._updateFloat3ForUniform = function(t, e, i, r) {
        n._TempBuffer[0] = e, n._TempBuffer[1] = i, n._TempBuffer[2] = r, this.updateUniform(t, n._TempBuffer, 3);
      }, n.prototype._updateFloat4ForEffect = function(t, e, i, r, o, a) {
        a === void 0 && (a = ""), this._currentEffect.setFloat4(t + a, e, i, r, o);
      }, n.prototype._updateFloat4ForUniform = function(t, e, i, r, o) {
        n._TempBuffer[0] = e, n._TempBuffer[1] = i, n._TempBuffer[2] = r, n._TempBuffer[3] = o, this.updateUniform(t, n._TempBuffer, 4);
      }, n.prototype._updateFloatArrayForEffect = function(t, e) {
        this._currentEffect.setFloatArray(t, e);
      }, n.prototype._updateFloatArrayForUniform = function(t, e) {
        this.updateUniformArray(t, e, e.length);
      }, n.prototype._updateArrayForEffect = function(t, e) {
        this._currentEffect.setArray(t, e);
      }, n.prototype._updateArrayForUniform = function(t, e) {
        this.updateUniformArray(t, e, e.length);
      }, n.prototype._updateIntArrayForEffect = function(t, e) {
        this._currentEffect.setIntArray(t, e);
      }, n.prototype._updateIntArrayForUniform = function(t, e) {
        n._TempBufferInt32View.set(e), this.updateUniformArray(t, n._TempBuffer, e.length);
      }, n.prototype._updateUIntArrayForEffect = function(t, e) {
        this._currentEffect.setUIntArray(t, e);
      }, n.prototype._updateUIntArrayForUniform = function(t, e) {
        n._TempBufferUInt32View.set(e), this.updateUniformArray(t, n._TempBuffer, e.length);
      }, n.prototype._updateMatrixForEffect = function(t, e) {
        this._currentEffect.setMatrix(t, e);
      }, n.prototype._updateMatrixForUniform = function(t, e) {
        this._cacheMatrix(t, e) && this.updateUniform(t, e.toArray(), 16);
      }, n.prototype._updateMatricesForEffect = function(t, e) {
        this._currentEffect.setMatrices(t, e);
      }, n.prototype._updateMatricesForUniform = function(t, e) {
        this.updateUniform(t, e, e.length);
      }, n.prototype._updateVector3ForEffect = function(t, e) {
        this._currentEffect.setVector3(t, e);
      }, n.prototype._updateVector3ForUniform = function(t, e) {
        n._TempBuffer[0] = e.x, n._TempBuffer[1] = e.y, n._TempBuffer[2] = e.z, this.updateUniform(t, n._TempBuffer, 3);
      }, n.prototype._updateVector4ForEffect = function(t, e) {
        this._currentEffect.setVector4(t, e);
      }, n.prototype._updateVector4ForUniform = function(t, e) {
        n._TempBuffer[0] = e.x, n._TempBuffer[1] = e.y, n._TempBuffer[2] = e.z, n._TempBuffer[3] = e.w, this.updateUniform(t, n._TempBuffer, 4);
      }, n.prototype._updateColor3ForEffect = function(t, e, i) {
        i === void 0 && (i = ""), this._currentEffect.setColor3(t + i, e);
      }, n.prototype._updateColor3ForUniform = function(t, e) {
        n._TempBuffer[0] = e.r, n._TempBuffer[1] = e.g, n._TempBuffer[2] = e.b, this.updateUniform(t, n._TempBuffer, 3);
      }, n.prototype._updateColor4ForEffect = function(t, e, i, r) {
        r === void 0 && (r = ""), this._currentEffect.setColor4(t + r, e, i);
      }, n.prototype._updateDirectColor4ForEffect = function(t, e, i) {
        i === void 0 && (i = ""), this._currentEffect.setDirectColor4(t + i, e);
      }, n.prototype._updateColor4ForUniform = function(t, e, i) {
        n._TempBuffer[0] = e.r, n._TempBuffer[1] = e.g, n._TempBuffer[2] = e.b, n._TempBuffer[3] = i, this.updateUniform(t, n._TempBuffer, 4);
      }, n.prototype._updateDirectColor4ForUniform = function(t, e) {
        n._TempBuffer[0] = e.r, n._TempBuffer[1] = e.g, n._TempBuffer[2] = e.b, n._TempBuffer[3] = e.a, this.updateUniform(t, n._TempBuffer, 4);
      }, n.prototype._updateIntForEffect = function(t, e, i) {
        i === void 0 && (i = ""), this._currentEffect.setInt(t + i, e);
      }, n.prototype._updateIntForUniform = function(t, e) {
        n._TempBufferInt32View[0] = e, this.updateUniform(t, n._TempBuffer, 1);
      }, n.prototype._updateInt2ForEffect = function(t, e, i, r) {
        r === void 0 && (r = ""), this._currentEffect.setInt2(t + r, e, i);
      }, n.prototype._updateInt2ForUniform = function(t, e, i) {
        n._TempBufferInt32View[0] = e, n._TempBufferInt32View[1] = i, this.updateUniform(t, n._TempBuffer, 2);
      }, n.prototype._updateInt3ForEffect = function(t, e, i, r, o) {
        o === void 0 && (o = ""), this._currentEffect.setInt3(t + o, e, i, r);
      }, n.prototype._updateInt3ForUniform = function(t, e, i, r) {
        n._TempBufferInt32View[0] = e, n._TempBufferInt32View[1] = i, n._TempBufferInt32View[2] = r, this.updateUniform(t, n._TempBuffer, 3);
      }, n.prototype._updateInt4ForEffect = function(t, e, i, r, o, a) {
        a === void 0 && (a = ""), this._currentEffect.setInt4(t + a, e, i, r, o);
      }, n.prototype._updateInt4ForUniform = function(t, e, i, r, o) {
        n._TempBufferInt32View[0] = e, n._TempBufferInt32View[1] = i, n._TempBufferInt32View[2] = r, n._TempBufferInt32View[3] = o, this.updateUniform(t, n._TempBuffer, 4);
      }, n.prototype._updateUIntForEffect = function(t, e, i) {
        i === void 0 && (i = ""), this._currentEffect.setUInt(t + i, e);
      }, n.prototype._updateUIntForUniform = function(t, e) {
        n._TempBufferUInt32View[0] = e, this.updateUniform(t, n._TempBuffer, 1);
      }, n.prototype._updateUInt2ForEffect = function(t, e, i, r) {
        r === void 0 && (r = ""), this._currentEffect.setUInt2(t + r, e, i);
      }, n.prototype._updateUInt2ForUniform = function(t, e, i) {
        n._TempBufferUInt32View[0] = e, n._TempBufferUInt32View[1] = i, this.updateUniform(t, n._TempBuffer, 2);
      }, n.prototype._updateUInt3ForEffect = function(t, e, i, r, o) {
        o === void 0 && (o = ""), this._currentEffect.setUInt3(t + o, e, i, r);
      }, n.prototype._updateUInt3ForUniform = function(t, e, i, r) {
        n._TempBufferUInt32View[0] = e, n._TempBufferUInt32View[1] = i, n._TempBufferUInt32View[2] = r, this.updateUniform(t, n._TempBuffer, 3);
      }, n.prototype._updateUInt4ForEffect = function(t, e, i, r, o, a) {
        a === void 0 && (a = ""), this._currentEffect.setUInt4(t + a, e, i, r, o);
      }, n.prototype._updateUInt4ForUniform = function(t, e, i, r, o) {
        n._TempBufferUInt32View[0] = e, n._TempBufferUInt32View[1] = i, n._TempBufferUInt32View[2] = r, n._TempBufferUInt32View[3] = o, this.updateUniform(t, n._TempBuffer, 4);
      }, n.prototype.setTexture = function(t, e) {
        this._currentEffect.setTexture(t, e);
      }, n.prototype.bindTexture = function(t, e) {
        this._currentEffect._bindTexture(t, e);
      }, n.prototype.updateUniformDirectly = function(t, e) {
        this.updateUniform(t, e, e.length), this.update();
      }, n.prototype.bindToEffect = function(t, e) {
        this._currentEffect = t, this._currentEffectName = e;
      }, n.prototype.bindUniformBuffer = function() {
        !this._noUBO && this._buffer && this._currentEffect && this._currentEffect.bindUniformBuffer(this._buffer, this._currentEffectName);
      }, n.prototype.unbindEffect = function() {
        this._currentEffect = void 0, this._currentEffectName = void 0;
      }, n.prototype.setDataBuffer = function(t) {
        if (!this._buffers)
          return this._buffer === t;
        for (var e = 0; e < this._buffers.length; ++e)
          if (this._buffers[e][0] === t)
            return this._bufferIndex = e, this._buffer = t, this._createBufferOnWrite = !1, this._currentEffect = void 0, !0;
        return !1;
      }, n.prototype.dispose = function() {
        if (!this._noUBO) {
          var t = this._engine._uniformBuffers, e = t.indexOf(this);
          if (e !== -1 && (t[e] = t[t.length - 1], t.pop()), this._engine._features.trackUbosInFrame && this._buffers)
            for (var i = 0; i < this._buffers.length; ++i) {
              var r = this._buffers[i][0];
              this._engine._releaseBuffer(r);
            }
          else
            this._buffer && this._engine._releaseBuffer(this._buffer) && (this._buffer = null);
        }
      }, n._UpdatedUbosInFrame = {}, n._MAX_UNIFORM_SIZE = 256, n._TempBuffer = new Float32Array(n._MAX_UNIFORM_SIZE), n._TempBufferInt32View = new Int32Array(n._TempBuffer.buffer), n._TempBufferUInt32View = new Uint32Array(n._TempBuffer.buffer), n;
    }(), Yi = function() {
      function n(t, e, i, r, o, a, s, l, c) {
        r === void 0 && (r = 0), o === void 0 && (o = !1), a === void 0 && (a = !1), s === void 0 && (s = !1), this._isAlreadyOwned = !1, this._isDisposed = !1, t && t.getScene ? this._engine = t.getScene().getEngine() : this._engine = t, this._updatable = i, this._instanced = a, this._divisor = l || 1, this._label = c, e instanceof wa ? (this._data = null, this._buffer = e) : (this._data = e, this._buffer = null), this.byteStride = s ? r : r * Float32Array.BYTES_PER_ELEMENT, o || this.create();
      }
      return Object.defineProperty(n.prototype, "isDisposed", { get: function() {
        return this._isDisposed;
      }, enumerable: !1, configurable: !0 }), n.prototype.createVertexBuffer = function(t, e, i, r, o, a, s) {
        a === void 0 && (a = !1);
        var l = a ? e : e * Float32Array.BYTES_PER_ELEMENT, c = r ? a ? r : r * Float32Array.BYTES_PER_ELEMENT : this.byteStride;
        return new P(this._engine, this, t, this._updatable, !0, c, o === void 0 ? this._instanced : o, l, i, void 0, void 0, !0, this._divisor || s);
      }, n.prototype.isUpdatable = function() {
        return this._updatable;
      }, n.prototype.getData = function() {
        return this._data;
      }, n.prototype.getBuffer = function() {
        return this._buffer;
      }, n.prototype.getStrideSize = function() {
        return this.byteStride / Float32Array.BYTES_PER_ELEMENT;
      }, n.prototype.create = function(t) {
        t === void 0 && (t = null), !t && this._buffer || (t = t || this._data) && (this._buffer ? this._updatable && (this._engine.updateDynamicVertexBuffer(this._buffer, t), this._data = t) : this._updatable ? (this._buffer = this._engine.createDynamicVertexBuffer(t, this._label), this._data = t) : this._buffer = this._engine.createVertexBuffer(t, void 0, this._label));
      }, n.prototype._rebuild = function() {
        this._buffer = null, this.create(this._data);
      }, n.prototype.update = function(t) {
        this.create(t);
      }, n.prototype.updateDirectly = function(t, e, i, r) {
        r === void 0 && (r = !1), this._buffer && this._updatable && (this._engine.updateDynamicVertexBuffer(this._buffer, t, r ? e : e * Float32Array.BYTES_PER_ELEMENT, i ? i * this.byteStride : void 0), this._data = e === 0 && i === void 0 ? t : null);
      }, n.prototype._increaseReferences = function() {
        this._buffer && (this._isAlreadyOwned ? this._buffer.references++ : this._isAlreadyOwned = !0);
      }, n.prototype.dispose = function() {
        this._buffer && this._engine._releaseBuffer(this._buffer) && (this._isDisposed = !0, this._data = null, this._buffer = null);
      }, n;
    }(), P = function() {
      function n(t, e, i, r, o, a, s, l, c, u, h, d, p, f) {
        var m, g, y, b, T;
        h === void 0 && (h = !1), d === void 0 && (d = !1), p === void 0 && (p = 1), f === void 0 && (f = !1), this._isDisposed = !1;
        var S = !1;
        if (this.engine = t, typeof r == "object" && r !== null ? (S = (m = r.updatable) !== null && m !== void 0 && m, o = r.postponeInternalCreation, a = r.stride, s = r.instanced, l = r.offset, c = r.size, u = r.type, h = (g = r.normalized) !== null && g !== void 0 && g, d = (y = r.useBytes) !== null && y !== void 0 && y, p = (b = r.divisor) !== null && b !== void 0 ? b : 1, f = (T = r.takeBufferOwnership) !== null && T !== void 0 && T, this._label = r.label) : S = !!r, e instanceof Yi ? (this._buffer = e, this._ownsBuffer = f) : (this._buffer = new Yi(t, e, S, a, o, s, d, p, this._label), this._ownsBuffer = !0), this.uniqueId = n._Counter++, this._kind = i, u === void 0) {
          var E = this.getData();
          this.type = E ? n.GetDataType(E) : n.FLOAT;
        } else
          this.type = u;
        var A = n.GetTypeByteLength(this.type);
        d ? (this._size = c || (a ? a / A : n.DeduceStride(i)), this.byteStride = a || this._buffer.byteStride || this._size * A, this.byteOffset = l || 0) : (this._size = c || a || n.DeduceStride(i), this.byteStride = a ? a * A : this._buffer.byteStride || this._size * A, this.byteOffset = (l || 0) * A), this.normalized = h, this._instanced = s !== void 0 && s, this._instanceDivisor = s ? p : 0, this._alignBuffer(), this._computeHashCode();
      }
      return Object.defineProperty(n.prototype, "isDisposed", { get: function() {
        return this._isDisposed;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "instanceDivisor", { get: function() {
        return this._instanceDivisor;
      }, set: function(t) {
        var e = t != 0;
        this._instanceDivisor = t, e !== this._instanced && (this._instanced = e, this._computeHashCode());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "totalVertices", { get: function() {
        var t = this.getData();
        return t ? Array.isArray(t) ? t.length / (this.byteStride / 4) - this.byteOffset / 4 : (t.byteLength - this.byteOffset) / this.byteStride : 0;
      }, enumerable: !1, configurable: !0 }), n.prototype._computeHashCode = function() {
        this.hashCode = (this.type - 5120 << 0) + ((this.normalized ? 1 : 0) << 3) + (this._size << 4) + ((this._instanced ? 1 : 0) << 6) + (this.byteStride << 12);
      }, n.prototype._rebuild = function() {
        var t;
        (t = this._buffer) === null || t === void 0 || t._rebuild();
      }, n.prototype.getKind = function() {
        return this._kind;
      }, n.prototype.isUpdatable = function() {
        return this._buffer.isUpdatable();
      }, n.prototype.getData = function() {
        return this._buffer.getData();
      }, n.prototype.getFloatData = function(t, e) {
        var i = this.getData();
        return i ? (t = t ?? this.totalVertices, n.GetFloatData(i, this._size, this.type, this.byteOffset, this.byteStride, this.normalized, t, e)) : null;
      }, n.prototype.getBuffer = function() {
        return this._buffer.getBuffer();
      }, n.prototype.getStrideSize = function() {
        return this.byteStride / n.GetTypeByteLength(this.type);
      }, n.prototype.getOffset = function() {
        return this.byteOffset / n.GetTypeByteLength(this.type);
      }, n.prototype.getSize = function(t) {
        return t === void 0 && (t = !1), t ? this._size * n.GetTypeByteLength(this.type) : this._size;
      }, n.prototype.getIsInstanced = function() {
        return this._instanced;
      }, n.prototype.getInstanceDivisor = function() {
        return this._instanceDivisor;
      }, n.prototype.create = function(t) {
        this._buffer.create(t), this._alignBuffer();
      }, n.prototype.update = function(t) {
        this._buffer.update(t), this._alignBuffer();
      }, n.prototype.updateDirectly = function(t, e, i) {
        i === void 0 && (i = !1), this._buffer.updateDirectly(t, e, void 0, i), this._alignBuffer();
      }, n.prototype.dispose = function() {
        this._ownsBuffer && this._buffer.dispose(), this._isDisposed = !0;
      }, n.prototype.forEach = function(t, e) {
        n.ForEach(this._buffer.getData(), this.byteOffset, this.byteStride, this._size, this.type, t, this.normalized, e);
      }, n.prototype._alignBuffer = function() {
      }, n.DeduceStride = function(t) {
        switch (t) {
          case n.UVKind:
          case n.UV2Kind:
          case n.UV3Kind:
          case n.UV4Kind:
          case n.UV5Kind:
          case n.UV6Kind:
            return 2;
          case n.NormalKind:
          case n.PositionKind:
            return 3;
          case n.ColorKind:
          case n.ColorInstanceKind:
          case n.MatricesIndicesKind:
          case n.MatricesIndicesExtraKind:
          case n.MatricesWeightsKind:
          case n.MatricesWeightsExtraKind:
          case n.TangentKind:
            return 4;
          default:
            throw new Error("Invalid kind '" + t + "'");
        }
      }, n.GetDataType = function(t) {
        return t instanceof Int8Array ? n.BYTE : t instanceof Uint8Array ? n.UNSIGNED_BYTE : t instanceof Int16Array ? n.SHORT : t instanceof Uint16Array ? n.UNSIGNED_SHORT : t instanceof Int32Array ? n.INT : t instanceof Uint32Array ? n.UNSIGNED_INT : n.FLOAT;
      }, n.GetTypeByteLength = function(t) {
        switch (t) {
          case n.BYTE:
          case n.UNSIGNED_BYTE:
            return 1;
          case n.SHORT:
          case n.UNSIGNED_SHORT:
            return 2;
          case n.INT:
          case n.UNSIGNED_INT:
          case n.FLOAT:
            return 4;
          default:
            throw new Error("Invalid type '".concat(t, "'"));
        }
      }, n.ForEach = function(t, e, i, r, o, a, s, l) {
        if (t instanceof Array)
          for (var c = e / 4, u = i / 4, h = 0; h < a; h += r) {
            for (var d = 0; d < r; d++)
              l(t[c + d], h + d);
            c += u;
          }
        else {
          var p = t instanceof ArrayBuffer ? new DataView(t) : new DataView(t.buffer, t.byteOffset, t.byteLength), f = n.GetTypeByteLength(o);
          for (h = 0; h < a; h += r) {
            var m = e;
            for (d = 0; d < r; d++)
              l(n._GetFloatValue(p, o, m, s), h + d), m += f;
            e += i;
          }
        }
      }, n._GetFloatValue = function(t, e, i, r) {
        switch (e) {
          case n.BYTE:
            var o = t.getInt8(i);
            return r && (o = Math.max(o / 127, -1)), o;
          case n.UNSIGNED_BYTE:
            return o = t.getUint8(i), r && (o /= 255), o;
          case n.SHORT:
            return o = t.getInt16(i, !0), r && (o = Math.max(o / 32767, -1)), o;
          case n.UNSIGNED_SHORT:
            return o = t.getUint16(i, !0), r && (o /= 65535), o;
          case n.INT:
            return t.getInt32(i, !0);
          case n.UNSIGNED_INT:
            return t.getUint32(i, !0);
          case n.FLOAT:
            return t.getFloat32(i, !0);
          default:
            throw new Error("Invalid component type ".concat(e));
        }
      }, n.GetFloatData = function(t, e, i, r, o, a, s, l) {
        var c = e * n.GetTypeByteLength(i), u = s * e;
        if (i !== n.FLOAT || o !== c) {
          var h = new Float32Array(u);
          return n.ForEach(t, r, o, e, i, u, a, function(g, y) {
            return h[y] = g;
          }), h;
        }
        if (!(t instanceof Array || t instanceof Float32Array) || r !== 0 || t.length !== u) {
          if (t instanceof Array) {
            var d = r / 4;
            return t.slice(d, d + u);
          }
          if (t instanceof ArrayBuffer)
            return new Float32Array(t, r, u);
          if (d = t.byteOffset + r, l) {
            var p = new Float32Array(u), f = new Float32Array(t.buffer, d, u);
            return p.set(f), p;
          }
          var m = d % 4;
          return m && (d = Math.max(0, d - m)), new Float32Array(t.buffer, d, u);
        }
        return l ? t.slice() : t;
      }, n._Counter = 0, n.BYTE = 5120, n.UNSIGNED_BYTE = 5121, n.SHORT = 5122, n.UNSIGNED_SHORT = 5123, n.INT = 5124, n.UNSIGNED_INT = 5125, n.FLOAT = 5126, n.PositionKind = "position", n.NormalKind = "normal", n.TangentKind = "tangent", n.UVKind = "uv", n.UV2Kind = "uv2", n.UV3Kind = "uv3", n.UV4Kind = "uv4", n.UV5Kind = "uv5", n.UV6Kind = "uv6", n.ColorKind = "color", n.ColorInstanceKind = "instanceColor", n.MatricesIndicesKind = "matricesIndices", n.MatricesWeightsKind = "matricesWeights", n.MatricesIndicesExtraKind = "matricesIndicesExtra", n.MatricesWeightsExtraKind = "matricesWeightsExtra", n;
    }(), Ki = function() {
      function n() {
        this.hit = !1, this.distance = 0, this.pickedPoint = null, this.pickedMesh = null, this.bu = 0, this.bv = 0, this.faceId = -1, this.subMeshFaceId = -1, this.subMeshId = 0, this.pickedSprite = null, this.thinInstanceIndex = -1, this.ray = null, this.originMesh = null, this.aimTransform = null, this.gripTransform = null;
      }
      return n.prototype.getNormal = function(t, e) {
        if (t === void 0 && (t = !1), e === void 0 && (e = !0), !this.pickedMesh || e && !this.pickedMesh.isVerticesDataPresent(P.NormalKind))
          return null;
        var i, r = this.pickedMesh.getIndices();
        (r == null ? void 0 : r.length) === 0 && (r = null);
        var o = F.Vector3[0], a = F.Vector3[1], s = F.Vector3[2];
        if (e) {
          var l = this.pickedMesh.getVerticesData(P.NormalKind), c = r ? v.FromArrayToRef(l, 3 * r[3 * this.faceId], o) : o.copyFromFloats(l[3 * this.faceId * 3], l[3 * this.faceId * 3 + 1], l[3 * this.faceId * 3 + 2]), u = r ? v.FromArrayToRef(l, 3 * r[3 * this.faceId + 1], a) : a.copyFromFloats(l[3 * (3 * this.faceId + 1)], l[3 * (3 * this.faceId + 1) + 1], l[3 * (3 * this.faceId + 1) + 2]), h = r ? v.FromArrayToRef(l, 3 * r[3 * this.faceId + 2], s) : s.copyFromFloats(l[3 * (3 * this.faceId + 2)], l[3 * (3 * this.faceId + 2) + 1], l[3 * (3 * this.faceId + 2) + 2]);
          c = c.scale(this.bu), u = u.scale(this.bv), h = h.scale(1 - this.bu - this.bv), i = new v(c.x + u.x + h.x, c.y + u.y + h.y, c.z + u.z + h.z);
        } else {
          var d = this.pickedMesh.getVerticesData(P.PositionKind), p = r ? v.FromArrayToRef(d, 3 * r[3 * this.faceId], o) : o.copyFromFloats(d[3 * this.faceId * 3], d[3 * this.faceId * 3 + 1], d[3 * this.faceId * 3 + 2]), f = r ? v.FromArrayToRef(d, 3 * r[3 * this.faceId + 1], a) : a.copyFromFloats(d[3 * (3 * this.faceId + 1)], d[3 * (3 * this.faceId + 1) + 1], d[3 * (3 * this.faceId + 1) + 2]), m = r ? v.FromArrayToRef(d, 3 * r[3 * this.faceId + 2], s) : s.copyFromFloats(d[3 * (3 * this.faceId + 2)], d[3 * (3 * this.faceId + 2) + 1], d[3 * (3 * this.faceId + 2) + 2]), g = p.subtract(f), y = m.subtract(f);
          i = v.Cross(g, y);
        }
        var b = function(S, E) {
          var A = S.getWorldMatrix();
          S.nonUniformScaling && (F.Matrix[0].copyFrom(A), (A = F.Matrix[0]).setTranslationFromFloats(0, 0, 0), A.invert(), A.transposeToRef(F.Matrix[1]), A = F.Matrix[1]), v.TransformNormalToRef(E, A, E);
        };
        if (t && b(this.pickedMesh, i), this.ray) {
          var T = F.Vector3[0].copyFrom(i);
          t || b(this.pickedMesh, T), v.Dot(T, this.ray.direction) > 0 && i.negateInPlace();
        }
        return i.normalize(), i;
      }, n.prototype.getTextureCoordinates = function(t) {
        if (t === void 0 && (t = P.UVKind), !this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(t))
          return null;
        var e = this.pickedMesh.getIndices();
        if (!e)
          return null;
        var i = this.pickedMesh.getVerticesData(t);
        if (!i)
          return null;
        var r = fe.FromArray(i, 2 * e[3 * this.faceId]), o = fe.FromArray(i, 2 * e[3 * this.faceId + 1]), a = fe.FromArray(i, 2 * e[3 * this.faceId + 2]);
        return r = r.scale(this.bu), o = o.scale(this.bv), a = a.scale(1 - this.bu - this.bv), new fe(r.x + o.x + a.x, r.y + o.y + a.y);
      }, n;
    }(), nc = function() {
      function n(t) {
        this._vertexBuffers = {}, this._scene = t;
      }
      return n.prototype._prepareBuffers = function() {
        if (!this._vertexBuffers[P.PositionKind]) {
          var t = [];
          t.push(1, 1), t.push(-1, 1), t.push(-1, -1), t.push(1, -1), this._vertexBuffers[P.PositionKind] = new P(this._scene.getEngine(), t, P.PositionKind, !1, !1, 2), this._buildIndexBuffer();
        }
      }, n.prototype._buildIndexBuffer = function() {
        var t = [];
        t.push(0), t.push(1), t.push(2), t.push(0), t.push(2), t.push(3), this._indexBuffer = this._scene.getEngine().createIndexBuffer(t);
      }, n.prototype._rebuild = function() {
        var t = this._vertexBuffers[P.PositionKind];
        t && (t._rebuild(), this._buildIndexBuffer());
      }, n.prototype._prepareFrame = function(t, e) {
        t === void 0 && (t = null), e === void 0 && (e = null);
        var i = this._scene.activeCamera;
        return !(!i || !(e = e || i._postProcesses.filter(function(r) {
          return r != null;
        })) || e.length === 0 || !this._scene.postProcessesEnabled || (e[0].activate(i, t, e != null), 0));
      }, n.prototype.directRender = function(t, e, i, r, o, a) {
        var s;
        e === void 0 && (e = null), i === void 0 && (i = !1), r === void 0 && (r = 0), o === void 0 && (o = 0), a === void 0 && (a = !1);
        for (var l = this._scene.getEngine(), c = 0; c < t.length; c++) {
          c < t.length - 1 ? t[c + 1].activate(this._scene.activeCamera, e == null ? void 0 : e.texture) : (e ? l.bindFramebuffer(e, r, void 0, void 0, i, o) : a || l.restoreDefaultFramebuffer(), (s = l._debugInsertMarker) === null || s === void 0 || s.call(l, "post process ".concat(t[c].name, " output")));
          var u = t[c], h = u.apply();
          h && (u.onBeforeRenderObservable.notifyObservers(h), this._prepareBuffers(), l.bindBuffers(this._vertexBuffers, this._indexBuffer, h), l.drawElementsType(_.MATERIAL_TriangleFillMode, 0, 6), u.onAfterRenderObservable.notifyObservers(h));
        }
        l.setDepthBuffer(!0), l.setDepthWrite(!0);
      }, n.prototype._finalizeFrame = function(t, e, i, r, o) {
        var a;
        o === void 0 && (o = !1);
        var s = this._scene.activeCamera;
        if (s && (r = r || s._postProcesses.filter(function(p) {
          return p != null;
        }), r.length !== 0 && this._scene.postProcessesEnabled)) {
          for (var l = this._scene.getEngine(), c = 0, u = r.length; c < u; c++) {
            var h = r[c];
            if (c < u - 1 ? h._outputTexture = r[c + 1].activate(s, e == null ? void 0 : e.texture) : (e ? (l.bindFramebuffer(e, i, void 0, void 0, o), h._outputTexture = e) : (l.restoreDefaultFramebuffer(), h._outputTexture = null), (a = l._debugInsertMarker) === null || a === void 0 || a.call(l, "post process ".concat(r[c].name, " output"))), t)
              break;
            var d = h.apply();
            d && (h.onBeforeRenderObservable.notifyObservers(d), this._prepareBuffers(), l.bindBuffers(this._vertexBuffers, this._indexBuffer, d), l.drawElementsType(_.MATERIAL_TriangleFillMode, 0, 6), h.onAfterRenderObservable.notifyObservers(d));
          }
          l.setDepthBuffer(!0), l.setDepthWrite(!0), l.setAlphaMode(_.ALPHA_DISABLE);
        }
      }, n.prototype.dispose = function() {
        var t = this._vertexBuffers[P.PositionKind];
        t && (t.dispose(), this._vertexBuffers[P.PositionKind] = null), this._indexBuffer && (this._scene.getEngine()._releaseBuffer(this._indexBuffer), this._indexBuffer = null);
      }, n;
    }(), ig = function() {
      function n(t, e, i, r, o) {
        i === void 0 && (i = null), r === void 0 && (r = null), o === void 0 && (o = null), this.index = t, this._opaqueSubMeshes = new en(256), this._transparentSubMeshes = new en(256), this._alphaTestSubMeshes = new en(256), this._depthOnlySubMeshes = new en(256), this._particleSystems = new en(256), this._spriteManagers = new en(256), this._empty = !0, this._edgesRenderers = new oa(16), this._scene = e, this.opaqueSortCompareFn = i, this.alphaTestSortCompareFn = r, this.transparentSortCompareFn = o;
      }
      return Object.defineProperty(n.prototype, "opaqueSortCompareFn", { set: function(t) {
        this._opaqueSortCompareFn = t || n.PainterSortCompare, this._renderOpaque = this._renderOpaqueSorted;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "alphaTestSortCompareFn", { set: function(t) {
        this._alphaTestSortCompareFn = t || n.PainterSortCompare, this._renderAlphaTest = this._renderAlphaTestSorted;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "transparentSortCompareFn", { set: function(t) {
        this._transparentSortCompareFn = t || n.defaultTransparentSortCompare, this._renderTransparent = this._renderTransparentSorted;
      }, enumerable: !1, configurable: !0 }), n.prototype.render = function(t, e, i, r) {
        if (t)
          t(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, this._depthOnlySubMeshes);
        else {
          var o = this._scene.getEngine();
          this._depthOnlySubMeshes.length !== 0 && (o.setColorWrite(!1), this._renderAlphaTest(this._depthOnlySubMeshes), o.setColorWrite(!0)), this._opaqueSubMeshes.length !== 0 && this._renderOpaque(this._opaqueSubMeshes), this._alphaTestSubMeshes.length !== 0 && this._renderAlphaTest(this._alphaTestSubMeshes);
          var a = o.getStencilBuffer();
          if (o.setStencilBuffer(!1), e && this._renderSprites(), i && this._renderParticles(r), this.onBeforeTransparentRendering && this.onBeforeTransparentRendering(), this._transparentSubMeshes.length !== 0 || this._scene.useOrderIndependentTransparency) {
            if (o.setStencilBuffer(a), this._scene.useOrderIndependentTransparency) {
              var s = this._scene.depthPeelingRenderer.render(this._transparentSubMeshes);
              s.length && this._renderTransparent(s);
            } else
              this._renderTransparent(this._transparentSubMeshes);
            o.setAlphaMode(_.ALPHA_DISABLE);
          }
          if (o.setStencilBuffer(!1), this._edgesRenderers.length) {
            for (var l = 0; l < this._edgesRenderers.length; l++)
              this._edgesRenderers.data[l].render();
            o.setAlphaMode(_.ALPHA_DISABLE);
          }
          o.setStencilBuffer(a);
        }
      }, n.prototype._renderOpaqueSorted = function(t) {
        return n._RenderSorted(t, this._opaqueSortCompareFn, this._scene.activeCamera, !1);
      }, n.prototype._renderAlphaTestSorted = function(t) {
        return n._RenderSorted(t, this._alphaTestSortCompareFn, this._scene.activeCamera, !1);
      }, n.prototype._renderTransparentSorted = function(t) {
        return n._RenderSorted(t, this._transparentSortCompareFn, this._scene.activeCamera, !0);
      }, n._RenderSorted = function(t, e, i, r) {
        var o, a = 0, s = i ? i.globalPosition : n._ZeroVector;
        if (r)
          for (; a < t.length; a++)
            (o = t.data[a])._alphaIndex = o.getMesh().alphaIndex, o._distanceToCamera = v.Distance(o.getBoundingInfo().boundingSphere.centerWorld, s);
        var l = t.length === t.data.length ? t.data : t.data.slice(0, t.length);
        e && l.sort(e);
        var c = l[0].getMesh().getScene();
        for (a = 0; a < l.length; a++)
          if (o = l[a], !c._activeMeshesFrozenButKeepClipping || o.isInFrustum(c._frustumPlanes)) {
            if (r) {
              var u = o.getMaterial();
              if (u && u.needDepthPrePass) {
                var h = u.getScene().getEngine();
                h.setColorWrite(!1), h.setAlphaMode(_.ALPHA_DISABLE), o.render(!1), h.setColorWrite(!0);
              }
            }
            o.render(r);
          }
      }, n.defaultTransparentSortCompare = function(t, e) {
        return t._alphaIndex > e._alphaIndex ? 1 : t._alphaIndex < e._alphaIndex ? -1 : n.backToFrontSortCompare(t, e);
      }, n.backToFrontSortCompare = function(t, e) {
        return t._distanceToCamera < e._distanceToCamera ? 1 : t._distanceToCamera > e._distanceToCamera ? -1 : 0;
      }, n.frontToBackSortCompare = function(t, e) {
        return t._distanceToCamera < e._distanceToCamera ? -1 : t._distanceToCamera > e._distanceToCamera ? 1 : 0;
      }, n.PainterSortCompare = function(t, e) {
        var i = t.getMesh(), r = e.getMesh();
        return i.material && r.material ? i.material.uniqueId - r.material.uniqueId : i.uniqueId - r.uniqueId;
      }, n.prototype.prepare = function() {
        this._opaqueSubMeshes.reset(), this._transparentSubMeshes.reset(), this._alphaTestSubMeshes.reset(), this._depthOnlySubMeshes.reset(), this._particleSystems.reset(), this.prepareSprites(), this._edgesRenderers.reset(), this._empty = !0;
      }, n.prototype.prepareSprites = function() {
        this._spriteManagers.reset();
      }, n.prototype.dispose = function() {
        this._opaqueSubMeshes.dispose(), this._transparentSubMeshes.dispose(), this._alphaTestSubMeshes.dispose(), this._depthOnlySubMeshes.dispose(), this._particleSystems.dispose(), this._spriteManagers.dispose(), this._edgesRenderers.dispose();
      }, n.prototype.dispatch = function(t, e, i) {
        e === void 0 && (e = t.getMesh()), i === void 0 && (i = t.getMaterial()), i != null && (i.needAlphaBlendingForMesh(e) ? this._transparentSubMeshes.push(t) : i.needAlphaTesting() ? (i.needDepthPrePass && this._depthOnlySubMeshes.push(t), this._alphaTestSubMeshes.push(t)) : (i.needDepthPrePass && this._depthOnlySubMeshes.push(t), this._opaqueSubMeshes.push(t)), e._renderingGroup = this, e._edgesRenderer && e._edgesRenderer.isEnabled && this._edgesRenderers.pushNoDuplicate(e._edgesRenderer), this._empty = !1);
      }, n.prototype.dispatchSprites = function(t) {
        this._spriteManagers.push(t), this._empty = !1;
      }, n.prototype.dispatchParticles = function(t) {
        this._particleSystems.push(t), this._empty = !1;
      }, n.prototype._renderParticles = function(t) {
        if (this._particleSystems.length !== 0) {
          var e = this._scene.activeCamera;
          this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);
          for (var i = 0; i < this._particleSystems.length; i++) {
            var r = this._particleSystems.data[i];
            if ((e && e.layerMask & r.layerMask) !== 0) {
              var o = r.emitter;
              o.position && t && t.indexOf(o) === -1 || this._scene._activeParticles.addCount(r.render(), !1);
            }
          }
          this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene);
        }
      }, n.prototype._renderSprites = function() {
        if (this._scene.spritesEnabled && this._spriteManagers.length !== 0) {
          var t = this._scene.activeCamera;
          this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);
          for (var e = 0; e < this._spriteManagers.length; e++) {
            var i = this._spriteManagers.data[e];
            (t && t.layerMask & i.layerMask) !== 0 && i.render();
          }
          this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene);
        }
      }, n._ZeroVector = v.Zero(), n;
    }(), ng = function() {
    }, rc = function() {
      function n(t) {
        this._useSceneAutoClearSetup = !1, this._renderingGroups = new Array(), this._autoClearDepthStencil = {}, this._customOpaqueSortCompareFn = {}, this._customAlphaTestSortCompareFn = {}, this._customTransparentSortCompareFn = {}, this._renderingGroupInfo = new ng(), this._maintainStateBetweenFrames = !1, this._scene = t;
        for (var e = n.MIN_RENDERINGGROUPS; e < n.MAX_RENDERINGGROUPS; e++)
          this._autoClearDepthStencil[e] = { autoClear: !0, depth: !0, stencil: !0 };
      }
      return Object.defineProperty(n.prototype, "maintainStateBetweenFrames", { get: function() {
        return this._maintainStateBetweenFrames;
      }, set: function(t) {
        t !== this._maintainStateBetweenFrames && (this._maintainStateBetweenFrames = t, this._maintainStateBetweenFrames || this.restoreDispachedFlags());
      }, enumerable: !1, configurable: !0 }), n.prototype.restoreDispachedFlags = function() {
        for (var t = 0, e = this._scene.meshes; t < e.length; t++) {
          var i = e[t];
          if (i.subMeshes)
            for (var r = 0, o = i.subMeshes; r < o.length; r++)
              o[r]._wasDispatched = !1;
        }
        if (this._scene.spriteManagers)
          for (var a = 0, s = this._scene.spriteManagers; a < s.length; a++)
            s[a]._wasDispatched = !1;
        for (var l = 0, c = this._scene.particleSystems; l < c.length; l++)
          c[l]._wasDispatched = !1;
      }, n.prototype.getRenderingGroup = function(t) {
        var e = t || 0;
        return this._prepareRenderingGroup(e), this._renderingGroups[e];
      }, n.prototype._clearDepthStencilBuffer = function(t, e) {
        t === void 0 && (t = !0), e === void 0 && (e = !0), this._depthStencilBufferAlreadyCleaned || (this._scene.getEngine().clear(null, !1, t, e), this._depthStencilBufferAlreadyCleaned = !0);
      }, n.prototype.render = function(t, e, i, r) {
        var o = this._renderingGroupInfo;
        if (o.scene = this._scene, o.camera = this._scene.activeCamera, this._scene.spriteManagers && r)
          for (var a = 0; a < this._scene.spriteManagers.length; a++) {
            var s = this._scene.spriteManagers[a];
            this.dispatchSprites(s);
          }
        for (a = n.MIN_RENDERINGGROUPS; a < n.MAX_RENDERINGGROUPS; a++) {
          this._depthStencilBufferAlreadyCleaned = a === n.MIN_RENDERINGGROUPS;
          var l = this._renderingGroups[a];
          if (l && !l._empty) {
            var c = Math.pow(2, a);
            if (o.renderingGroupId = a, this._scene.onBeforeRenderingGroupObservable.notifyObservers(o, c), n.AUTOCLEAR) {
              var u = this._useSceneAutoClearSetup ? this._scene.getAutoClearDepthStencilSetup(a) : this._autoClearDepthStencil[a];
              u && u.autoClear && this._clearDepthStencilBuffer(u.depth, u.stencil);
            }
            for (var h = 0, d = this._scene._beforeRenderingGroupDrawStage; h < d.length; h++)
              d[h].action(a);
            l.render(t, r, i, e);
            for (var p = 0, f = this._scene._afterRenderingGroupDrawStage; p < f.length; p++)
              f[p].action(a);
            this._scene.onAfterRenderingGroupObservable.notifyObservers(o, c);
          }
        }
      }, n.prototype.reset = function() {
        if (!this.maintainStateBetweenFrames)
          for (var t = n.MIN_RENDERINGGROUPS; t < n.MAX_RENDERINGGROUPS; t++) {
            var e = this._renderingGroups[t];
            e && e.prepare();
          }
      }, n.prototype.resetSprites = function() {
        if (!this.maintainStateBetweenFrames)
          for (var t = n.MIN_RENDERINGGROUPS; t < n.MAX_RENDERINGGROUPS; t++) {
            var e = this._renderingGroups[t];
            e && e.prepareSprites();
          }
      }, n.prototype.dispose = function() {
        this.freeRenderingGroups(), this._renderingGroups.length = 0, this._renderingGroupInfo = null;
      }, n.prototype.freeRenderingGroups = function() {
        for (var t = n.MIN_RENDERINGGROUPS; t < n.MAX_RENDERINGGROUPS; t++) {
          var e = this._renderingGroups[t];
          e && e.dispose();
        }
      }, n.prototype._prepareRenderingGroup = function(t) {
        this._renderingGroups[t] === void 0 && (this._renderingGroups[t] = new ig(t, this._scene, this._customOpaqueSortCompareFn[t], this._customAlphaTestSortCompareFn[t], this._customTransparentSortCompareFn[t]));
      }, n.prototype.dispatchSprites = function(t) {
        this.maintainStateBetweenFrames && t._wasDispatched || (t._wasDispatched = !0, this.getRenderingGroup(t.renderingGroupId).dispatchSprites(t));
      }, n.prototype.dispatchParticles = function(t) {
        this.maintainStateBetweenFrames && t._wasDispatched || (t._wasDispatched = !0, this.getRenderingGroup(t.renderingGroupId).dispatchParticles(t));
      }, n.prototype.dispatch = function(t, e, i) {
        e === void 0 && (e = t.getMesh()), this.maintainStateBetweenFrames && t._wasDispatched || (t._wasDispatched = !0, this.getRenderingGroup(e.renderingGroupId).dispatch(t, e, i));
      }, n.prototype.setRenderingOrder = function(t, e, i, r) {
        if (e === void 0 && (e = null), i === void 0 && (i = null), r === void 0 && (r = null), this._customOpaqueSortCompareFn[t] = e, this._customAlphaTestSortCompareFn[t] = i, this._customTransparentSortCompareFn[t] = r, this._renderingGroups[t]) {
          var o = this._renderingGroups[t];
          o.opaqueSortCompareFn = this._customOpaqueSortCompareFn[t], o.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[t], o.transparentSortCompareFn = this._customTransparentSortCompareFn[t];
        }
      }, n.prototype.setRenderingAutoClearDepthStencil = function(t, e, i, r) {
        i === void 0 && (i = !0), r === void 0 && (r = !0), this._autoClearDepthStencil[t] = { autoClear: e, depth: i, stencil: r };
      }, n.prototype.getAutoClearDepthStencilSetup = function(t) {
        return this._autoClearDepthStencil[t];
      }, n.MAX_RENDERINGGROUPS = 4, n.MIN_RENDERINGGROUPS = 0, n.AUTOCLEAR = !0, n;
    }(), we = function() {
      function n() {
      }
      return n.NAME_EFFECTLAYER = "EffectLayer", n.NAME_LAYER = "Layer", n.NAME_LENSFLARESYSTEM = "LensFlareSystem", n.NAME_BOUNDINGBOXRENDERER = "BoundingBoxRenderer", n.NAME_PARTICLESYSTEM = "ParticleSystem", n.NAME_GAMEPAD = "Gamepad", n.NAME_SIMPLIFICATIONQUEUE = "SimplificationQueue", n.NAME_GEOMETRYBUFFERRENDERER = "GeometryBufferRenderer", n.NAME_PREPASSRENDERER = "PrePassRenderer", n.NAME_DEPTHRENDERER = "DepthRenderer", n.NAME_DEPTHPEELINGRENDERER = "DepthPeelingRenderer", n.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager", n.NAME_SPRITE = "Sprite", n.NAME_SUBSURFACE = "SubSurface", n.NAME_OUTLINERENDERER = "Outline", n.NAME_PROCEDURALTEXTURE = "ProceduralTexture", n.NAME_SHADOWGENERATOR = "ShadowGenerator", n.NAME_OCTREE = "Octree", n.NAME_PHYSICSENGINE = "PhysicsEngine", n.NAME_AUDIO = "Audio", n.NAME_FLUIDRENDERER = "FluidRenderer", n.STEP_ISREADYFORMESH_EFFECTLAYER = 0, n.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0, n.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0, n.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER = 0, n.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1, n.STEP_BEFORECAMERADRAW_PREPASS = 0, n.STEP_BEFORECAMERADRAW_EFFECTLAYER = 1, n.STEP_BEFORECAMERADRAW_LAYER = 2, n.STEP_BEFORERENDERTARGETDRAW_PREPASS = 0, n.STEP_BEFORERENDERTARGETDRAW_LAYER = 1, n.STEP_BEFORERENDERINGMESH_PREPASS = 0, n.STEP_BEFORERENDERINGMESH_OUTLINE = 1, n.STEP_AFTERRENDERINGMESH_PREPASS = 0, n.STEP_AFTERRENDERINGMESH_OUTLINE = 1, n.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0, n.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1, n.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0, n.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1, n.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0, n.STEP_BEFORECLEAR_PREPASS = 1, n.STEP_BEFORERENDERTARGETCLEAR_PREPASS = 0, n.STEP_AFTERRENDERTARGETDRAW_PREPASS = 0, n.STEP_AFTERRENDERTARGETDRAW_LAYER = 1, n.STEP_AFTERCAMERADRAW_PREPASS = 0, n.STEP_AFTERCAMERADRAW_EFFECTLAYER = 1, n.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 2, n.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 3, n.STEP_AFTERCAMERADRAW_LAYER = 4, n.STEP_AFTERCAMERADRAW_FLUIDRENDERER = 5, n.STEP_AFTERCAMERAPOSTPROCESS_LAYER = 0, n.STEP_AFTERRENDERTARGETPOSTPROCESS_LAYER = 0, n.STEP_AFTERRENDER_AUDIO = 0, n.STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 0, n.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1, n.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 2, n.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3, n.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0, n.STEP_GATHERACTIVECAMERARENDERTARGETS_FLUIDRENDERER = 1, n.STEP_POINTERMOVE_SPRITE = 0, n.STEP_POINTERDOWN_SPRITE = 0, n.STEP_POINTERUP_SPRITE = 0, n;
    }(), Ni = function(n) {
      function t(e) {
        return n.apply(this, e) || this;
      }
      return D(t, n), t.Create = function() {
        return Object.create(t.prototype);
      }, t.prototype.registerStep = function(e, i, r) {
        var o = 0;
        for (Number.MAX_VALUE; o < this.length && !(e < this[o].index); o++)
          ;
        this.splice(o, 0, { index: e, component: i, action: r.bind(i) });
      }, t.prototype.clear = function() {
        this.length = 0;
      }, t;
    }(Array), Le = function() {
      function n() {
      }
      return n.POINTERDOWN = 1, n.POINTERUP = 2, n.POINTERMOVE = 4, n.POINTERWHEEL = 8, n.POINTERPICK = 16, n.POINTERTAP = 32, n.POINTERDOUBLETAP = 64, n;
    }(), gp = function(n, t) {
      this.type = n, this.event = t;
    }, rg = function(n) {
      function t(e, i, r, o) {
        var a = n.call(this, e, i) || this;
        return a.ray = null, a.originalPickingInfo = null, a.skipOnPointerObservable = !1, a.localPosition = new fe(r, o), a;
      }
      return D(t, n), t;
    }(gp), Sr = function(n) {
      function t(e, i, r, o) {
        o === void 0 && (o = null);
        var a = n.call(this, e, i) || this;
        return a._pickInfo = r, a._inputManager = o, a;
      }
      return D(t, n), Object.defineProperty(t.prototype, "pickInfo", { get: function() {
        return this._pickInfo || this._generatePickInfo(), this._pickInfo;
      }, enumerable: !1, configurable: !0 }), t.prototype._generatePickInfo = function() {
        this._inputManager && (this._pickInfo = this._inputManager._pickMove(this.event), this._inputManager._setRayOnPointerInfo(this._pickInfo, this.event), this._inputManager = null);
      }, t;
    }(gp), ps = function() {
      function n() {
      }
      return n.KEYDOWN = 1, n.KEYUP = 2, n;
    }(), Gu = function(n, t) {
      this.type = n, this.event = t;
    }, vp = function(n) {
      function t(e, i) {
        var r = n.call(this, e, i) || this;
        return r.type = e, r.event = i, r.skipOnKeyboardObservable = !1, r;
      }
      return D(t, n), Object.defineProperty(t.prototype, "skipOnPointerObservable", { get: function() {
        return this.skipOnKeyboardObservable;
      }, set: function(e) {
        this.skipOnKeyboardObservable = e;
      }, enumerable: !1, configurable: !0 }), t;
    }(Gu);
    (function(n) {
      n[n.Generic = 0] = "Generic", n[n.Keyboard = 1] = "Keyboard", n[n.Mouse = 2] = "Mouse", n[n.Touch = 3] = "Touch", n[n.DualShock = 4] = "DualShock", n[n.Xbox = 5] = "Xbox", n[n.Switch = 6] = "Switch", n[n.DualSense = 7] = "DualSense";
    })(Ze || (Ze = {})), function(n) {
      n[n.Horizontal = 0] = "Horizontal", n[n.Vertical = 1] = "Vertical", n[n.LeftClick = 2] = "LeftClick", n[n.MiddleClick = 3] = "MiddleClick", n[n.RightClick = 4] = "RightClick", n[n.BrowserBack = 5] = "BrowserBack", n[n.BrowserForward = 6] = "BrowserForward", n[n.MouseWheelX = 7] = "MouseWheelX", n[n.MouseWheelY = 8] = "MouseWheelY", n[n.MouseWheelZ = 9] = "MouseWheelZ", n[n.Move = 12] = "Move";
    }(at || (at = {})), function(n) {
      n[n.Horizontal = 0] = "Horizontal", n[n.Vertical = 1] = "Vertical", n[n.LeftClick = 2] = "LeftClick", n[n.MiddleClick = 3] = "MiddleClick", n[n.RightClick = 4] = "RightClick", n[n.BrowserBack = 5] = "BrowserBack", n[n.BrowserForward = 6] = "BrowserForward", n[n.MouseWheelX = 7] = "MouseWheelX", n[n.MouseWheelY = 8] = "MouseWheelY", n[n.MouseWheelZ = 9] = "MouseWheelZ", n[n.DeltaHorizontal = 10] = "DeltaHorizontal", n[n.DeltaVertical = 11] = "DeltaVertical";
    }(ic || (ic = {})), function(n) {
      n[n.Cross = 0] = "Cross", n[n.Circle = 1] = "Circle", n[n.Square = 2] = "Square", n[n.Triangle = 3] = "Triangle", n[n.L1 = 4] = "L1", n[n.R1 = 5] = "R1", n[n.L2 = 6] = "L2", n[n.R2 = 7] = "R2", n[n.Share = 8] = "Share", n[n.Options = 9] = "Options", n[n.L3 = 10] = "L3", n[n.R3 = 11] = "R3", n[n.DPadUp = 12] = "DPadUp", n[n.DPadDown = 13] = "DPadDown", n[n.DPadLeft = 14] = "DPadLeft", n[n.DPadRight = 15] = "DPadRight", n[n.Home = 16] = "Home", n[n.TouchPad = 17] = "TouchPad", n[n.LStickXAxis = 18] = "LStickXAxis", n[n.LStickYAxis = 19] = "LStickYAxis", n[n.RStickXAxis = 20] = "RStickXAxis", n[n.RStickYAxis = 21] = "RStickYAxis";
    }(dp || (dp = {})), function(n) {
      n[n.Cross = 0] = "Cross", n[n.Circle = 1] = "Circle", n[n.Square = 2] = "Square", n[n.Triangle = 3] = "Triangle", n[n.L1 = 4] = "L1", n[n.R1 = 5] = "R1", n[n.L2 = 6] = "L2", n[n.R2 = 7] = "R2", n[n.Create = 8] = "Create", n[n.Options = 9] = "Options", n[n.L3 = 10] = "L3", n[n.R3 = 11] = "R3", n[n.DPadUp = 12] = "DPadUp", n[n.DPadDown = 13] = "DPadDown", n[n.DPadLeft = 14] = "DPadLeft", n[n.DPadRight = 15] = "DPadRight", n[n.Home = 16] = "Home", n[n.TouchPad = 17] = "TouchPad", n[n.LStickXAxis = 18] = "LStickXAxis", n[n.LStickYAxis = 19] = "LStickYAxis", n[n.RStickXAxis = 20] = "RStickXAxis", n[n.RStickYAxis = 21] = "RStickYAxis";
    }(pp || (pp = {})), function(n) {
      n[n.A = 0] = "A", n[n.B = 1] = "B", n[n.X = 2] = "X", n[n.Y = 3] = "Y", n[n.LB = 4] = "LB", n[n.RB = 5] = "RB", n[n.LT = 6] = "LT", n[n.RT = 7] = "RT", n[n.Back = 8] = "Back", n[n.Start = 9] = "Start", n[n.LS = 10] = "LS", n[n.RS = 11] = "RS", n[n.DPadUp = 12] = "DPadUp", n[n.DPadDown = 13] = "DPadDown", n[n.DPadLeft = 14] = "DPadLeft", n[n.DPadRight = 15] = "DPadRight", n[n.Home = 16] = "Home", n[n.LStickXAxis = 17] = "LStickXAxis", n[n.LStickYAxis = 18] = "LStickYAxis", n[n.RStickXAxis = 19] = "RStickXAxis", n[n.RStickYAxis = 20] = "RStickYAxis";
    }(fp || (fp = {})), function(n) {
      n[n.B = 0] = "B", n[n.A = 1] = "A", n[n.Y = 2] = "Y", n[n.X = 3] = "X", n[n.L = 4] = "L", n[n.R = 5] = "R", n[n.ZL = 6] = "ZL", n[n.ZR = 7] = "ZR", n[n.Minus = 8] = "Minus", n[n.Plus = 9] = "Plus", n[n.LS = 10] = "LS", n[n.RS = 11] = "RS", n[n.DPadUp = 12] = "DPadUp", n[n.DPadDown = 13] = "DPadDown", n[n.DPadLeft = 14] = "DPadLeft", n[n.DPadRight = 15] = "DPadRight", n[n.Home = 16] = "Home", n[n.Capture = 17] = "Capture", n[n.LStickXAxis = 18] = "LStickXAxis", n[n.LStickYAxis = 19] = "LStickYAxis", n[n.RStickXAxis = 20] = "RStickXAxis", n[n.RStickYAxis = 21] = "RStickYAxis";
    }(_p || (_p = {})), function(n) {
      n[n.PointerMove = 0] = "PointerMove", n[n.PointerDown = 1] = "PointerDown", n[n.PointerUp = 2] = "PointerUp";
    }(mp || (mp = {}));
    var Zr, zu = function() {
      function n() {
      }
      return n.DOM_DELTA_PIXEL = 0, n.DOM_DELTA_LINE = 1, n.DOM_DELTA_PAGE = 2, n;
    }(), sl = function() {
      function n() {
      }
      return n.CreateDeviceEvent = function(t, e, i, r, o, a, s) {
        switch (t) {
          case Ze.Keyboard:
            return this._CreateKeyboardEvent(i, r, o, a);
          case Ze.Mouse:
            if (i === at.MouseWheelX || i === at.MouseWheelY || i === at.MouseWheelZ)
              return this._CreateWheelEvent(t, e, i, r, o, a);
          case Ze.Touch:
            return this._CreatePointerEvent(t, e, i, r, o, a, s);
          default:
            throw "Unable to generate event for device ".concat(Ze[t]);
        }
      }, n._CreatePointerEvent = function(t, e, i, r, o, a, s) {
        var l = this._CreateMouseEvent(t, e, i, r, o, a);
        t === Ze.Mouse ? (l.deviceType = Ze.Mouse, l.pointerId = 1, l.pointerType = "mouse") : (l.deviceType = Ze.Touch, l.pointerId = s ?? e, l.pointerType = "touch");
        var c = 0;
        return c += o.pollInput(t, e, at.LeftClick), c += 2 * o.pollInput(t, e, at.RightClick), c += 4 * o.pollInput(t, e, at.MiddleClick), l.buttons = c, i === at.Move ? l.type = "pointermove" : i >= at.LeftClick && i <= at.RightClick && (l.type = r === 1 ? "pointerdown" : "pointerup", l.button = i - 2), l;
      }, n._CreateWheelEvent = function(t, e, i, r, o, a) {
        var s = this._CreateMouseEvent(t, e, i, r, o, a);
        switch (s.pointerId = 1, s.type = "wheel", s.deltaMode = zu.DOM_DELTA_PIXEL, s.deltaX = 0, s.deltaY = 0, s.deltaZ = 0, i) {
          case at.MouseWheelX:
            s.deltaX = r;
            break;
          case at.MouseWheelY:
            s.deltaY = r;
            break;
          case at.MouseWheelZ:
            s.deltaZ = r;
        }
        return s;
      }, n._CreateMouseEvent = function(t, e, i, r, o, a) {
        var s = this._CreateEvent(a), l = o.pollInput(t, e, at.Horizontal), c = o.pollInput(t, e, at.Vertical);
        return a ? (s.movementX = 0, s.movementY = 0, s.offsetX = s.movementX - a.getBoundingClientRect().x, s.offsetY = s.movementY - a.getBoundingClientRect().y) : (s.movementX = o.pollInput(t, e, ic.DeltaHorizontal), s.movementY = o.pollInput(t, e, ic.DeltaVertical), s.offsetX = 0, s.offsetY = 0), this._CheckNonCharacterKeys(s, o), s.clientX = l, s.clientY = c, s.x = l, s.y = c, s.deviceType = t, s.deviceSlot = e, s.inputIndex = i, s;
      }, n._CreateKeyboardEvent = function(t, e, i, r) {
        var o = this._CreateEvent(r);
        return this._CheckNonCharacterKeys(o, i), o.deviceType = Ze.Keyboard, o.deviceSlot = 0, o.inputIndex = t, o.type = e === 1 ? "keydown" : "keyup", o.key = String.fromCharCode(t), o.keyCode = t, o;
      }, n._CheckNonCharacterKeys = function(t, e) {
        var i = e.isDeviceAvailable(Ze.Keyboard), r = i && e.pollInput(Ze.Keyboard, 0, _.INPUT_ALT_KEY) === 1, o = i && e.pollInput(Ze.Keyboard, 0, _.INPUT_CTRL_KEY) === 1, a = i && (e.pollInput(Ze.Keyboard, 0, _.INPUT_META_KEY1) === 1 || e.pollInput(Ze.Keyboard, 0, _.INPUT_META_KEY2) === 1 || e.pollInput(Ze.Keyboard, 0, _.INPUT_META_KEY3) === 1), s = i && e.pollInput(Ze.Keyboard, 0, _.INPUT_SHIFT_KEY) === 1;
        t.altKey = r, t.ctrlKey = o, t.metaKey = a, t.shiftKey = s;
      }, n._CreateEvent = function(t) {
        var e = { preventDefault: function() {
        } };
        return e.target = t, e;
      }, n;
    }(), C1 = function() {
      function n(t, e, i) {
        var r = this;
        this._nativeInput = _native.DeviceInputSystem ? new _native.DeviceInputSystem(t, e, function(o, a, s, l) {
          var c = sl.CreateDeviceEvent(o, a, s, l, r);
          i(o, a, c);
        }) : this._createDummyNativeInput();
      }
      return n.prototype.pollInput = function(t, e, i) {
        return this._nativeInput.pollInput(t, e, i);
      }, n.prototype.isDeviceAvailable = function(t) {
        return t === Ze.Mouse || t === Ze.Touch;
      }, n.prototype.dispose = function() {
        this._nativeInput.dispose();
      }, n.prototype._createDummyNativeInput = function() {
        return { pollInput: function() {
          return 0;
        }, isDeviceAvailable: function() {
          return !1;
        }, dispose: function() {
        } };
      }, n;
    }(), XA = Object.keys(at).length / 2, P1 = function() {
      function n(t, e, i, r) {
        var o = this;
        this._inputs = [], this._keyboardActive = !1, this._pointerActive = !1, this._usingSafari = de.IsSafari(), this._usingMacOS = us() && /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform), this._keyboardDownEvent = function(a) {
        }, this._keyboardUpEvent = function(a) {
        }, this._keyboardBlurEvent = function(a) {
        }, this._pointerMoveEvent = function(a) {
        }, this._pointerDownEvent = function(a) {
        }, this._pointerUpEvent = function(a) {
        }, this._pointerCancelEvent = function(a) {
        }, this._pointerWheelEvent = function(a) {
        }, this._pointerBlurEvent = function(a) {
        }, this._pointerMacOSChromeOutEvent = function(a) {
        }, this._eventsAttached = !1, this._mouseId = -1, this._isUsingFirefox = us() && navigator.userAgent && navigator.userAgent.indexOf("Firefox") !== -1, this._isUsingChromium = us() && navigator.userAgent && navigator.userAgent.indexOf("Chrome") !== -1, this._maxTouchPoints = 0, this._pointerInputClearObserver = null, this._gamepadConnectedEvent = function(a) {
        }, this._gamepadDisconnectedEvent = function(a) {
        }, this._eventPrefix = de.GetPointerPrefix(t), this._engine = t, this._onDeviceConnected = e, this._onDeviceDisconnected = i, this._onInputChanged = r, this._mouseId = this._isUsingFirefox ? 0 : 1, this._enableEvents(), this._usingMacOS && (this._metaKeys = []), this._engine._onEngineViewChanged || (this._engine._onEngineViewChanged = function() {
          o._enableEvents();
        });
      }
      return n.prototype.pollInput = function(t, e, i) {
        var r = this._inputs[t][e];
        if (!r)
          throw "Unable to find device ".concat(Ze[t]);
        t >= Ze.DualShock && t <= Ze.DualSense && this._updateDevice(t, e, i);
        var o = r[i];
        if (o === void 0)
          throw "Unable to find input ".concat(i, " for device ").concat(Ze[t], " in slot ").concat(e);
        return i === at.Move && de.Warn("Unable to provide information for PointerInput.Move.  Try using PointerInput.Horizontal or PointerInput.Vertical for move data."), o;
      }, n.prototype.isDeviceAvailable = function(t) {
        return this._inputs[t] !== void 0;
      }, n.prototype.dispose = function() {
        this._onDeviceConnected = function() {
        }, this._onDeviceDisconnected = function() {
        }, this._onInputChanged = function() {
        }, delete this._engine._onEngineViewChanged, this._elementToAttachTo && this._disableEvents();
      }, n.prototype._enableEvents = function() {
        var t = this == null ? void 0 : this._engine.getInputElement();
        if (t && (!this._eventsAttached || this._elementToAttachTo !== t)) {
          if (this._disableEvents(), this._inputs)
            for (var e = 0, i = this._inputs; e < i.length; e++) {
              var r = i[e];
              if (r)
                for (var o in r) {
                  var a = r[+o];
                  if (a)
                    for (var s = 0; s < a.length; s++)
                      a[s] = 0;
                }
            }
          this._elementToAttachTo = t, this._elementToAttachTo.tabIndex = this._elementToAttachTo.tabIndex !== -1 ? this._elementToAttachTo.tabIndex : this._engine.canvasTabIndex, this._handleKeyActions(), this._handlePointerActions(), this._handleGamepadActions(), this._eventsAttached = !0, this._checkForConnectedDevices();
        }
      }, n.prototype._disableEvents = function() {
        this._elementToAttachTo && (this._elementToAttachTo.removeEventListener("blur", this._keyboardBlurEvent), this._elementToAttachTo.removeEventListener("blur", this._pointerBlurEvent), this._elementToAttachTo.removeEventListener("keydown", this._keyboardDownEvent), this._elementToAttachTo.removeEventListener("keyup", this._keyboardUpEvent), this._elementToAttachTo.removeEventListener(this._eventPrefix + "move", this._pointerMoveEvent), this._elementToAttachTo.removeEventListener(this._eventPrefix + "down", this._pointerDownEvent), this._elementToAttachTo.removeEventListener(this._eventPrefix + "up", this._pointerUpEvent), this._elementToAttachTo.removeEventListener(this._eventPrefix + "cancel", this._pointerCancelEvent), this._elementToAttachTo.removeEventListener(this._wheelEventName, this._pointerWheelEvent), this._usingMacOS && this._isUsingChromium && this._elementToAttachTo.removeEventListener("lostpointercapture", this._pointerMacOSChromeOutEvent), window.removeEventListener("gamepadconnected", this._gamepadConnectedEvent), window.removeEventListener("gamepaddisconnected", this._gamepadDisconnectedEvent)), this._pointerInputClearObserver && this._engine.onEndFrameObservable.remove(this._pointerInputClearObserver), this._eventsAttached = !1;
      }, n.prototype._checkForConnectedDevices = function() {
        if (navigator.getGamepads)
          for (var t = 0, e = navigator.getGamepads(); t < e.length; t++) {
            var i = e[t];
            i && this._addGamePad(i);
          }
        typeof matchMedia == "function" && matchMedia("(pointer:fine)").matches && this._addPointerDevice(Ze.Mouse, 0, 0, 0);
      }, n.prototype._addGamePad = function(t) {
        var e = this._getGamepadDeviceType(t.id), i = t.index;
        this._gamepads = this._gamepads || new Array(t.index + 1), this._registerDevice(e, i, t.buttons.length + t.axes.length), this._gamepads[i] = e;
      }, n.prototype._addPointerDevice = function(t, e, i, r) {
        this._pointerActive || (this._pointerActive = !0), this._registerDevice(t, e, XA);
        var o = this._inputs[t][e];
        o[0] = i, o[1] = r;
      }, n.prototype._registerDevice = function(t, e, i) {
        if (e === void 0)
          throw "Unable to register device ".concat(Ze[t], " to undefined slot.");
        if (this._inputs[t] || (this._inputs[t] = {}), !this._inputs[t][e]) {
          var r = new Array(i);
          r.fill(0), this._inputs[t][e] = r, this._onDeviceConnected(t, e);
        }
      }, n.prototype._unregisterDevice = function(t, e) {
        this._inputs[t][e] && (delete this._inputs[t][e], this._onDeviceDisconnected(t, e));
      }, n.prototype._handleKeyActions = function() {
        var t = this;
        this._keyboardDownEvent = function(e) {
          t._keyboardActive || (t._keyboardActive = !0, t._registerDevice(Ze.Keyboard, 0, 255));
          var i = t._inputs[Ze.Keyboard][0];
          if (i) {
            i[e.keyCode] = 1;
            var r = e;
            r.inputIndex = e.keyCode, t._usingMacOS && e.metaKey && e.key !== "Meta" && (t._metaKeys.includes(e.keyCode) || t._metaKeys.push(e.keyCode)), t._onInputChanged(Ze.Keyboard, 0, r);
          }
        }, this._keyboardUpEvent = function(e) {
          t._keyboardActive || (t._keyboardActive = !0, t._registerDevice(Ze.Keyboard, 0, 255));
          var i = t._inputs[Ze.Keyboard][0];
          if (i) {
            i[e.keyCode] = 0;
            var r = e;
            if (r.inputIndex = e.keyCode, t._usingMacOS && e.key === "Meta" && t._metaKeys.length > 0) {
              for (var o = 0, a = t._metaKeys; o < a.length; o++) {
                var s = a[o], l = sl.CreateDeviceEvent(Ze.Keyboard, 0, s, 0, t, t._elementToAttachTo);
                i[s] = 0, t._onInputChanged(Ze.Keyboard, 0, l);
              }
              t._metaKeys.splice(0, t._metaKeys.length);
            }
            t._onInputChanged(Ze.Keyboard, 0, r);
          }
        }, this._keyboardBlurEvent = function() {
          if (t._keyboardActive) {
            for (var e = t._inputs[Ze.Keyboard][0], i = 0; i < e.length; i++)
              if (e[i] !== 0) {
                e[i] = 0;
                var r = sl.CreateDeviceEvent(Ze.Keyboard, 0, i, 0, t, t._elementToAttachTo);
                t._onInputChanged(Ze.Keyboard, 0, r);
              }
            t._usingMacOS && t._metaKeys.splice(0, t._metaKeys.length);
          }
        }, this._elementToAttachTo.addEventListener("keydown", this._keyboardDownEvent), this._elementToAttachTo.addEventListener("keyup", this._keyboardUpEvent), this._elementToAttachTo.addEventListener("blur", this._keyboardBlurEvent);
      }, n.prototype._handlePointerActions = function() {
        var t = this;
        this._maxTouchPoints = us() && navigator.maxTouchPoints || 2, this._activeTouchIds || (this._activeTouchIds = new Array(this._maxTouchPoints));
        for (var e = 0; e < this._maxTouchPoints; e++)
          this._activeTouchIds[e] = -1;
        this._pointerMoveEvent = function(a) {
          var s = t._getPointerType(a), l = s === Ze.Mouse ? 0 : t._activeTouchIds.indexOf(a.pointerId);
          if (s === Ze.Touch && l === -1) {
            var c = t._activeTouchIds.indexOf(-1);
            if (!(c >= 0))
              return void de.Warn("Max number of touches exceeded.  Ignoring touches in excess of ".concat(t._maxTouchPoints));
            l = c, t._activeTouchIds[c] = a.pointerId, t._onDeviceConnected(s, l);
          }
          t._inputs[s] || (t._inputs[s] = {}), t._inputs[s][l] || t._addPointerDevice(s, l, a.clientX, a.clientY);
          var u = t._inputs[s][l];
          if (u) {
            var h = a;
            h.inputIndex = at.Move, u[at.Horizontal] = a.clientX, u[at.Vertical] = a.clientY, s === Ze.Touch && u[at.LeftClick] === 0 && (u[at.LeftClick] = 1), a.pointerId === void 0 && (a.pointerId = t._mouseId), t._onInputChanged(s, l, h), t._usingSafari || a.button === -1 || (h.inputIndex = a.button + 2, u[a.button + 2] = u[a.button + 2] ? 0 : 1, t._onInputChanged(s, l, h));
          }
        }, this._pointerDownEvent = function(a) {
          var s = t._getPointerType(a), l = s === Ze.Mouse ? 0 : a.pointerId;
          if (s === Ze.Touch) {
            var c = t._activeTouchIds.indexOf(-1);
            if (!(c >= 0))
              return void de.Warn("Max number of touches exceeded.  Ignoring touches in excess of ".concat(t._maxTouchPoints));
            l = c, t._activeTouchIds[c] = a.pointerId;
          }
          t._inputs[s] || (t._inputs[s] = {}), t._inputs[s][l] ? s === Ze.Touch && t._onDeviceConnected(s, l) : t._addPointerDevice(s, l, a.clientX, a.clientY);
          var u = t._inputs[s][l];
          if (u) {
            var h = u[at.Horizontal], d = u[at.Vertical];
            if (s === Ze.Mouse) {
              if (a.pointerId === void 0 && (a.pointerId = t._mouseId), !document.pointerLockElement)
                try {
                  t._elementToAttachTo.setPointerCapture(t._mouseId);
                } catch {
                }
            } else if (a.pointerId && !document.pointerLockElement)
              try {
                t._elementToAttachTo.setPointerCapture(a.pointerId);
              } catch {
              }
            u[at.Horizontal] = a.clientX, u[at.Vertical] = a.clientY, u[a.button + 2] = 1;
            var p = a;
            p.inputIndex = a.button + 2, t._onInputChanged(s, l, p), h === a.clientX && d === a.clientY || (p.inputIndex = at.Move, t._onInputChanged(s, l, p));
          }
        }, this._pointerUpEvent = function(a) {
          var s, l, c, u, h, d = t._getPointerType(a), p = d === Ze.Mouse ? 0 : t._activeTouchIds.indexOf(a.pointerId);
          if (d === Ze.Touch) {
            if (p === -1)
              return;
            t._activeTouchIds[p] = -1;
          }
          var f = (s = t._inputs[d]) === null || s === void 0 ? void 0 : s[p];
          if (f && f[a.button + 2] !== 0) {
            var m = f[at.Horizontal], g = f[at.Vertical];
            f[at.Horizontal] = a.clientX, f[at.Vertical] = a.clientY, f[a.button + 2] = 0;
            var y = a;
            a.pointerId === void 0 && (a.pointerId = t._mouseId), m === a.clientX && g === a.clientY || (y.inputIndex = at.Move, t._onInputChanged(d, p, y)), y.inputIndex = a.button + 2, d === Ze.Mouse && t._mouseId >= 0 && (!((c = (l = t._elementToAttachTo).hasPointerCapture) === null || c === void 0) && c.call(l, t._mouseId)) ? t._elementToAttachTo.releasePointerCapture(t._mouseId) : a.pointerId && (!((h = (u = t._elementToAttachTo).hasPointerCapture) === null || h === void 0) && h.call(u, a.pointerId)) && t._elementToAttachTo.releasePointerCapture(a.pointerId), t._onInputChanged(d, p, y), d === Ze.Touch && t._onDeviceDisconnected(d, p);
          }
        }, this._pointerCancelEvent = function(a) {
          var s, l, c, u;
          if (a.pointerType === "mouse") {
            var h = t._inputs[Ze.Mouse][0];
            t._mouseId >= 0 && (!((l = (s = t._elementToAttachTo).hasPointerCapture) === null || l === void 0) && l.call(s, t._mouseId)) && t._elementToAttachTo.releasePointerCapture(t._mouseId);
            for (var d = at.LeftClick; d <= at.BrowserForward; d++)
              if (h[d] === 1) {
                h[d] = 0;
                var p = sl.CreateDeviceEvent(Ze.Mouse, 0, d, 0, t, t._elementToAttachTo);
                t._onInputChanged(Ze.Mouse, 0, p);
              }
          } else {
            var f = t._activeTouchIds.indexOf(a.pointerId);
            if (f === -1)
              return;
            !((u = (c = t._elementToAttachTo).hasPointerCapture) === null || u === void 0) && u.call(c, a.pointerId) && t._elementToAttachTo.releasePointerCapture(a.pointerId), t._inputs[Ze.Touch][f][at.LeftClick] = 0, p = sl.CreateDeviceEvent(Ze.Touch, f, at.LeftClick, 0, t, t._elementToAttachTo, a.pointerId), t._onInputChanged(Ze.Touch, f, p), t._activeTouchIds[f] = -1, t._onDeviceDisconnected(Ze.Touch, f);
          }
        }, this._wheelEventName = "onwheel" in document.createElement("div") ? "wheel" : document.onmousewheel !== void 0 ? "mousewheel" : "DOMMouseScroll";
        var i = !1, r = function() {
        };
        try {
          var o = Object.defineProperty({}, "passive", { get: function() {
            i = !0;
          } });
          this._elementToAttachTo.addEventListener("test", r, o), this._elementToAttachTo.removeEventListener("test", r, o);
        } catch {
        }
        this._pointerBlurEvent = function() {
          var a, s, l, c, u;
          if (t.isDeviceAvailable(Ze.Mouse)) {
            var h = t._inputs[Ze.Mouse][0];
            t._mouseId >= 0 && (!((s = (a = t._elementToAttachTo).hasPointerCapture) === null || s === void 0) && s.call(a, t._mouseId)) && t._elementToAttachTo.releasePointerCapture(t._mouseId);
            for (var d = at.LeftClick; d <= at.BrowserForward; d++)
              if (h[d] === 1) {
                h[d] = 0;
                var p = sl.CreateDeviceEvent(Ze.Mouse, 0, d, 0, t, t._elementToAttachTo);
                t._onInputChanged(Ze.Mouse, 0, p);
              }
          }
          if (t.isDeviceAvailable(Ze.Touch)) {
            h = t._inputs[Ze.Touch];
            for (var f = 0; f < t._activeTouchIds.length; f++) {
              var m = t._activeTouchIds[f];
              !((c = (l = t._elementToAttachTo).hasPointerCapture) === null || c === void 0) && c.call(l, m) && t._elementToAttachTo.releasePointerCapture(m), m !== -1 && ((u = h[f]) === null || u === void 0 ? void 0 : u[at.LeftClick]) === 1 && (h[f][at.LeftClick] = 0, p = sl.CreateDeviceEvent(Ze.Touch, f, at.LeftClick, 0, t, t._elementToAttachTo, m), t._onInputChanged(Ze.Touch, f, p), t._activeTouchIds[f] = -1, t._onDeviceDisconnected(Ze.Touch, f));
            }
          }
        }, this._pointerWheelEvent = function(a) {
          var s = Ze.Mouse;
          t._inputs[s] || (t._inputs[s] = []), t._inputs[s][0] || (t._pointerActive = !0, t._registerDevice(s, 0, XA));
          var l = t._inputs[s][0];
          if (l) {
            l[at.MouseWheelX] = a.deltaX || 0, l[at.MouseWheelY] = a.deltaY || a.wheelDelta || 0, l[at.MouseWheelZ] = a.deltaZ || 0;
            var c = a;
            a.pointerId === void 0 && (a.pointerId = t._mouseId), l[at.MouseWheelX] !== 0 && (c.inputIndex = at.MouseWheelX, t._onInputChanged(s, 0, c)), l[at.MouseWheelY] !== 0 && (c.inputIndex = at.MouseWheelY, t._onInputChanged(s, 0, c)), l[at.MouseWheelZ] !== 0 && (c.inputIndex = at.MouseWheelZ, t._onInputChanged(s, 0, c));
          }
        }, this._usingMacOS && this._isUsingChromium && (this._pointerMacOSChromeOutEvent = function(a) {
          a.buttons > 1 && t._pointerCancelEvent(a);
        }, this._elementToAttachTo.addEventListener("lostpointercapture", this._pointerMacOSChromeOutEvent)), this._elementToAttachTo.addEventListener(this._eventPrefix + "move", this._pointerMoveEvent), this._elementToAttachTo.addEventListener(this._eventPrefix + "down", this._pointerDownEvent), this._elementToAttachTo.addEventListener(this._eventPrefix + "up", this._pointerUpEvent), this._elementToAttachTo.addEventListener(this._eventPrefix + "cancel", this._pointerCancelEvent), this._elementToAttachTo.addEventListener("blur", this._pointerBlurEvent), this._elementToAttachTo.addEventListener(this._wheelEventName, this._pointerWheelEvent, !!i && { passive: !1 }), this._pointerInputClearObserver = this._engine.onEndFrameObservable.add(function() {
          if (t.isDeviceAvailable(Ze.Mouse)) {
            var a = t._inputs[Ze.Mouse][0];
            a[at.MouseWheelX] = 0, a[at.MouseWheelY] = 0, a[at.MouseWheelZ] = 0;
          }
        });
      }, n.prototype._handleGamepadActions = function() {
        var t = this;
        this._gamepadConnectedEvent = function(e) {
          t._addGamePad(e.gamepad);
        }, this._gamepadDisconnectedEvent = function(e) {
          if (t._gamepads) {
            var i = t._getGamepadDeviceType(e.gamepad.id), r = e.gamepad.index;
            t._unregisterDevice(i, r), delete t._gamepads[r];
          }
        }, window.addEventListener("gamepadconnected", this._gamepadConnectedEvent), window.addEventListener("gamepaddisconnected", this._gamepadDisconnectedEvent);
      }, n.prototype._updateDevice = function(t, e, i) {
        var r = navigator.getGamepads()[e];
        if (r && t === this._gamepads[e]) {
          var o = this._inputs[t][e];
          i >= r.buttons.length ? o[i] = r.axes[i - r.buttons.length].valueOf() : o[i] = r.buttons[i].value;
        }
      }, n.prototype._getGamepadDeviceType = function(t) {
        return t.indexOf("054c") !== -1 ? t.indexOf("0ce6") !== -1 ? Ze.DualSense : Ze.DualShock : t.indexOf("Xbox One") !== -1 || t.search("Xbox 360") !== -1 || t.search("xinput") !== -1 ? Ze.Xbox : t.indexOf("057e") !== -1 ? Ze.Switch : Ze.Generic;
      }, n.prototype._getPointerType = function(t) {
        var e = Ze.Mouse;
        return (t.pointerType === "touch" || t.pointerType === "pen" || t.touches) && (e = Ze.Touch), e;
      }, n;
    }(), yp = function() {
      function n(t, e, i) {
        i === void 0 && (i = 0), this.deviceType = e, this.deviceSlot = i, this.onInputChangedObservable = new H(), this._deviceInputSystem = t;
      }
      return n.prototype.getInput = function(t) {
        return this._deviceInputSystem.pollInput(this.deviceType, this.deviceSlot, t);
      }, n;
    }(), I1 = function() {
      function n(t) {
        var e = this;
        this._registeredManagers = new Array(), this._refCount = 0, this.registerManager = function(s) {
          for (var l = 0; l < e._devices.length; l++) {
            var c = e._devices[l];
            for (var u in c) {
              var h = +u;
              s._addDevice(new yp(e._deviceInputSystem, l, h));
            }
          }
          e._registeredManagers.push(s);
        }, this.unregisterManager = function(s) {
          var l = e._registeredManagers.indexOf(s);
          l > -1 && e._registeredManagers.splice(l, 1);
        };
        var i = Object.keys(Ze).length / 2;
        this._devices = new Array(i);
        var r = function(s, l) {
          e._devices[s] || (e._devices[s] = new Array()), e._devices[s][l] || (e._devices[s][l] = l);
          for (var c = 0, u = e._registeredManagers; c < u.length; c++) {
            var h = u[c], d = new yp(e._deviceInputSystem, s, l);
            h._addDevice(d);
          }
        }, o = function(s, l) {
          var c;
          !((c = e._devices[s]) === null || c === void 0) && c[l] && delete e._devices[s][l];
          for (var u = 0, h = e._registeredManagers; u < h.length; u++)
            h[u]._removeDevice(s, l);
        }, a = function(s, l, c) {
          if (c)
            for (var u = 0, h = e._registeredManagers; u < h.length; u++)
              h[u]._onInputChanged(s, l, c);
        };
        typeof _native < "u" ? this._deviceInputSystem = new C1(r, o, a) : this._deviceInputSystem = new P1(t, r, o, a);
      }
      return n.prototype.dispose = function() {
        this._deviceInputSystem.dispose();
      }, n;
    }(), og = function() {
      function n(t) {
        var e = this, i = Object.keys(Ze).length / 2;
        this._devices = new Array(i), this._firstDevice = new Array(i), this._engine = t, this._engine._deviceSourceManager || (this._engine._deviceSourceManager = new I1(t)), this._engine._deviceSourceManager._refCount++, this.onDeviceConnectedObservable = new H(function(r) {
          for (var o = 0, a = e._devices; o < a.length; o++) {
            var s = a[o];
            if (s)
              for (var l = 0, c = s; l < c.length; l++) {
                var u = c[l];
                u && e.onDeviceConnectedObservable.notifyObserver(r, u);
              }
          }
        }), this.onDeviceDisconnectedObservable = new H(), this._engine._deviceSourceManager.registerManager(this), this._onDisposeObserver = t.onDisposeObservable.add(function() {
          e.dispose();
        });
      }
      return n.prototype.getDeviceSource = function(t, e) {
        if (e === void 0) {
          if (this._firstDevice[t] === void 0)
            return null;
          e = this._firstDevice[t];
        }
        return this._devices[t] && this._devices[t][e] !== void 0 ? this._devices[t][e] : null;
      }, n.prototype.getDeviceSources = function(t) {
        return this._devices[t] ? this._devices[t].filter(function(e) {
          return !!e;
        }) : [];
      }, n.prototype.dispose = function() {
        this.onDeviceConnectedObservable.clear(), this.onDeviceDisconnectedObservable.clear(), this._engine._deviceSourceManager && (this._engine._deviceSourceManager.unregisterManager(this), --this._engine._deviceSourceManager._refCount < 1 && (this._engine._deviceSourceManager.dispose(), delete this._engine._deviceSourceManager)), this._engine.onDisposeObservable.remove(this._onDisposeObserver);
      }, n.prototype._addDevice = function(t) {
        this._devices[t.deviceType] || (this._devices[t.deviceType] = new Array()), this._devices[t.deviceType][t.deviceSlot] || (this._devices[t.deviceType][t.deviceSlot] = t, this._updateFirstDevices(t.deviceType)), this.onDeviceConnectedObservable.notifyObservers(t);
      }, n.prototype._removeDevice = function(t, e) {
        var i, r, o = (i = this._devices[t]) === null || i === void 0 ? void 0 : i[e];
        this.onDeviceDisconnectedObservable.notifyObservers(o), !((r = this._devices[t]) === null || r === void 0) && r[e] && delete this._devices[t][e], this._updateFirstDevices(t);
      }, n.prototype._onInputChanged = function(t, e, i) {
        var r, o;
        (o = (r = this._devices[t]) === null || r === void 0 ? void 0 : r[e]) === null || o === void 0 || o.onInputChangedObservable.notifyObservers(i);
      }, n.prototype._updateFirstDevices = function(t) {
        switch (t) {
          case Ze.Keyboard:
          case Ze.Mouse:
            this._firstDevice[t] = 0;
            break;
          case Ze.Touch:
          case Ze.DualSense:
          case Ze.DualShock:
          case Ze.Xbox:
          case Ze.Switch:
          case Ze.Generic:
            delete this._firstDevice[t];
            var e = this._devices[t];
            if (e) {
              for (var i = 0; i < e.length; i++)
                if (e[i]) {
                  this._firstDevice[t] = i;
                  break;
                }
            }
        }
      }, n;
    }(), jA = function() {
      function n() {
        this._singleClick = !1, this._doubleClick = !1, this._hasSwiped = !1, this._ignore = !1;
      }
      return Object.defineProperty(n.prototype, "singleClick", { get: function() {
        return this._singleClick;
      }, set: function(t) {
        this._singleClick = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "doubleClick", { get: function() {
        return this._doubleClick;
      }, set: function(t) {
        this._doubleClick = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "hasSwiped", { get: function() {
        return this._hasSwiped;
      }, set: function(t) {
        this._hasSwiped = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "ignore", { get: function() {
        return this._ignore;
      }, set: function(t) {
        this._ignore = t;
      }, enumerable: !1, configurable: !0 }), n;
    }(), Ba = function() {
      function n(t) {
        this._alreadyAttached = !1, this._meshPickProceed = !1, this._currentPickResult = null, this._previousPickResult = null, this._totalPointersPressed = 0, this._doubleClickOccured = !1, this._isSwiping = !1, this._swipeButtonPressed = -1, this._skipPointerTap = !1, this._isMultiTouchGesture = !1, this._pointerX = 0, this._pointerY = 0, this._startingPointerPosition = new fe(0, 0), this._previousStartingPointerPosition = new fe(0, 0), this._startingPointerTime = 0, this._previousStartingPointerTime = 0, this._pointerCaptures = {}, this._meshUnderPointerId = {}, this._movePointerInfo = null, this._cameraObserverCount = 0, this._delayedClicks = [null, null, null, null, null], this._deviceSourceManager = null, this._scene = t || Me.LastCreatedScene, this._scene;
      }
      return Object.defineProperty(n.prototype, "meshUnderPointer", { get: function() {
        return this._movePointerInfo && (this._movePointerInfo._generatePickInfo(), this._movePointerInfo = null), this._pointerOverMesh;
      }, enumerable: !1, configurable: !0 }), n.prototype.getMeshUnderPointerByPointerId = function(t) {
        return this._meshUnderPointerId[t] || null;
      }, Object.defineProperty(n.prototype, "unTranslatedPointer", { get: function() {
        return new fe(this._unTranslatedPointerX, this._unTranslatedPointerY);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "pointerX", { get: function() {
        return this._pointerX;
      }, set: function(t) {
        this._pointerX = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "pointerY", { get: function() {
        return this._pointerY;
      }, set: function(t) {
        this._pointerY = t;
      }, enumerable: !1, configurable: !0 }), n.prototype._updatePointerPosition = function(t) {
        var e = this._scene.getEngine().getInputElementClientRect();
        e && (this._pointerX = t.clientX - e.left, this._pointerY = t.clientY - e.top, this._unTranslatedPointerX = this._pointerX, this._unTranslatedPointerY = this._pointerY);
      }, n.prototype._processPointerMove = function(t, e) {
        var i = this._scene, r = i.getEngine(), o = r.getInputElement();
        o && (o.tabIndex = r.canvasTabIndex, i.doNotHandleCursors || (o.style.cursor = i.defaultCursor)), this._setCursorAndPointerOverMesh(t, e, i);
        for (var a = 0, s = i._pointerMoveStage; a < s.length; a++) {
          var l = s[a], c = !!((t = t || this._pickMove(e)) != null && t.pickedMesh);
          t = l.action(this._unTranslatedPointerX, this._unTranslatedPointerY, t, c, o);
        }
        var u, h = e.inputIndex >= at.MouseWheelX && e.inputIndex <= at.MouseWheelZ ? Le.POINTERWHEEL : Le.POINTERMOVE;
        i.onPointerMove && (t = t || this._pickMove(e), i.onPointerMove(e, t, h)), t ? (u = new Sr(h, e, t), this._setRayOnPointerInfo(t, e)) : (u = new Sr(h, e, null, this), this._movePointerInfo = u), i.onPointerObservable.hasObservers() && i.onPointerObservable.notifyObservers(u, h);
      }, n.prototype._setRayOnPointerInfo = function(t, e) {
        var i = this._scene;
        t && i._pickingAvailable && (t.ray || (t.ray = i.createPickingRay(e.offsetX, e.offsetY, B.Identity(), i.activeCamera)));
      }, n.prototype._addCameraPointerObserver = function(t, e) {
        return this._cameraObserverCount++, this._scene.onPointerObservable.add(t, e);
      }, n.prototype._removeCameraPointerObserver = function(t) {
        return this._cameraObserverCount--, this._scene.onPointerObservable.remove(t);
      }, n.prototype._checkForPicking = function() {
        return !!(this._scene.onPointerObservable.observers.length > this._cameraObserverCount || this._scene.onPointerPick);
      }, n.prototype._checkPrePointerObservable = function(t, e, i) {
        var r = this._scene, o = new rg(i, e, this._unTranslatedPointerX, this._unTranslatedPointerY);
        return t && (o.originalPickingInfo = t, o.ray = t.ray, t.originMesh && (o.nearInteractionPickingInfo = t)), r.onPrePointerObservable.notifyObservers(o, i), !!o.skipOnPointerObservable;
      }, n.prototype._pickMove = function(t) {
        var e = this._scene, i = e.pick(this._unTranslatedPointerX, this._unTranslatedPointerY, e.pointerMovePredicate, e.pointerMoveFastCheck, e.cameraToUseForPointers, e.pointerMoveTrianglePredicate);
        return this._setCursorAndPointerOverMesh(i, t, e), i;
      }, n.prototype._setCursorAndPointerOverMesh = function(t, e, i) {
        var r = i.getEngine().getInputElement();
        if (t != null && t.pickedMesh) {
          if (this.setPointerOverMesh(t.pickedMesh, e.pointerId, t, e), !i.doNotHandleCursors && r && this._pointerOverMesh) {
            var o = this._pointerOverMesh._getActionManagerForTrigger();
            o && o.hasPointerTriggers && (r.style.cursor = o.hoverCursor || i.hoverCursor);
          }
        } else
          this.setPointerOverMesh(null, e.pointerId, t, e);
      }, n.prototype.simulatePointerMove = function(t, e) {
        var i = new PointerEvent("pointermove", e);
        i.inputIndex = at.Move, this._checkPrePointerObservable(t, i, Le.POINTERMOVE) || this._processPointerMove(t, i);
      }, n.prototype.simulatePointerDown = function(t, e) {
        var i = new PointerEvent("pointerdown", e);
        i.inputIndex = i.button + 2, this._checkPrePointerObservable(t, i, Le.POINTERDOWN) || this._processPointerDown(t, i);
      }, n.prototype._processPointerDown = function(t, e) {
        var i, r = this, o = this._scene;
        if (t != null && t.pickedMesh) {
          this._pickedDownMesh = t.pickedMesh;
          var a = t.pickedMesh._getActionManagerForTrigger();
          if (a) {
            if (a.hasPickTriggers)
              switch (a.processTrigger(_.ACTION_OnPickDownTrigger, mi.CreateNew(t.pickedMesh, e, t)), e.button) {
                case 0:
                  a.processTrigger(_.ACTION_OnLeftPickTrigger, mi.CreateNew(t.pickedMesh, e, t));
                  break;
                case 1:
                  a.processTrigger(_.ACTION_OnCenterPickTrigger, mi.CreateNew(t.pickedMesh, e, t));
                  break;
                case 2:
                  a.processTrigger(_.ACTION_OnRightPickTrigger, mi.CreateNew(t.pickedMesh, e, t));
              }
            a.hasSpecificTrigger(_.ACTION_OnLongPressTrigger) && window.setTimeout(function() {
              var u = o.pick(r._unTranslatedPointerX, r._unTranslatedPointerY, function(h) {
                return h.isPickable && h.isVisible && h.isReady() && h.actionManager && h.actionManager.hasSpecificTrigger(_.ACTION_OnLongPressTrigger) && h === r._pickedDownMesh;
              }, !1, o.cameraToUseForPointers);
              u != null && u.pickedMesh && a && r._totalPointersPressed !== 0 && Date.now() - r._startingPointerTime > n.LongPressDelay && !r._isPointerSwiping() && (r._startingPointerTime = 0, a.processTrigger(_.ACTION_OnLongPressTrigger, mi.CreateNew(u.pickedMesh, e)));
            }, n.LongPressDelay);
          }
        } else
          for (var s = 0, l = o._pointerDownStage; s < l.length; s++)
            t = l[s].action(this._unTranslatedPointerX, this._unTranslatedPointerY, t, e, !1);
        var c = Le.POINTERDOWN;
        t ? (o.onPointerDown && o.onPointerDown(e, t, c), i = new Sr(c, e, t), this._setRayOnPointerInfo(t, e)) : i = new Sr(c, e, null, this), o.onPointerObservable.hasObservers() && o.onPointerObservable.notifyObservers(i, c);
      }, n.prototype._isPointerSwiping = function() {
        return this._isSwiping;
      }, n.prototype.simulatePointerUp = function(t, e, i) {
        var r = new PointerEvent("pointerup", e);
        r.inputIndex = at.Move;
        var o = new jA();
        i ? o.doubleClick = !0 : o.singleClick = !0, this._checkPrePointerObservable(t, r, Le.POINTERUP) || this._processPointerUp(t, r, o);
      }, n.prototype._processPointerUp = function(t, e, i) {
        var r = this._scene;
        if (t != null && t.pickedMesh) {
          if (this._pickedUpMesh = t.pickedMesh, this._pickedDownMesh === this._pickedUpMesh && (r.onPointerPick && r.onPointerPick(e, t), i.singleClick && !i.ignore && r.onPointerObservable.observers.length > this._cameraObserverCount)) {
            var o = Le.POINTERPICK, a = new Sr(o, e, t);
            this._setRayOnPointerInfo(t, e), r.onPointerObservable.notifyObservers(a, o);
          }
          var s = t.pickedMesh._getActionManagerForTrigger();
          if (s && !i.ignore) {
            s.processTrigger(_.ACTION_OnPickUpTrigger, mi.CreateNew(t.pickedMesh, e, t)), !i.hasSwiped && i.singleClick && s.processTrigger(_.ACTION_OnPickTrigger, mi.CreateNew(t.pickedMesh, e, t));
            var l = t.pickedMesh._getActionManagerForTrigger(_.ACTION_OnDoublePickTrigger);
            i.doubleClick && l && l.processTrigger(_.ACTION_OnDoublePickTrigger, mi.CreateNew(t.pickedMesh, e, t));
          }
        } else if (!i.ignore)
          for (var c = 0, u = r._pointerUpStage; c < u.length; c++)
            t = u[c].action(this._unTranslatedPointerX, this._unTranslatedPointerY, t, e, i.doubleClick);
        if (this._pickedDownMesh && this._pickedDownMesh !== this._pickedUpMesh) {
          var h = this._pickedDownMesh._getActionManagerForTrigger(_.ACTION_OnPickOutTrigger);
          h && h.processTrigger(_.ACTION_OnPickOutTrigger, mi.CreateNew(this._pickedDownMesh, e));
        }
        if (!i.ignore && (a = new Sr(Le.POINTERUP, e, t), this._setRayOnPointerInfo(t, e), r.onPointerObservable.notifyObservers(a, Le.POINTERUP), r.onPointerUp && r.onPointerUp(e, t, Le.POINTERUP), !i.hasSwiped && !this._skipPointerTap && !this._isMultiTouchGesture && (o = 0, i.singleClick ? o = Le.POINTERTAP : i.doubleClick && (o = Le.POINTERDOUBLETAP), o))) {
          var d = new Sr(o, e, t);
          r.onPointerObservable.hasObservers() && r.onPointerObservable.hasSpecificMask(o) && r.onPointerObservable.notifyObservers(d, o);
        }
      }, n.prototype.isPointerCaptured = function(t) {
        return t === void 0 && (t = 0), this._pointerCaptures[t];
      }, n.prototype.attachControl = function(t, e, i, r) {
        var o = this;
        t === void 0 && (t = !0), e === void 0 && (e = !0), i === void 0 && (i = !0), r === void 0 && (r = null);
        var a = this._scene, s = a.getEngine();
        r || (r = s.getInputElement()), this._alreadyAttached && this.detachControl(), r && (this._alreadyAttachedTo = r), this._deviceSourceManager = new og(s), this._initActionManager = function(l) {
          if (!o._meshPickProceed) {
            var c = a.skipPointerUpPicking || a._registeredActions === 0 && !o._checkForPicking() && !a.onPointerUp ? null : a.pick(o._unTranslatedPointerX, o._unTranslatedPointerY, a.pointerUpPredicate, a.pointerUpFastCheck, a.cameraToUseForPointers);
            o._currentPickResult = c, c && (l = c.hit && c.pickedMesh ? c.pickedMesh._getActionManagerForTrigger() : null), o._meshPickProceed = !0;
          }
          return l;
        }, this._delayedSimpleClick = function(l, c, u) {
          if ((Date.now() - o._previousStartingPointerTime > n.DoubleClickDelay && !o._doubleClickOccured || l !== o._previousButtonPressed) && (o._doubleClickOccured = !1, c.singleClick = !0, c.ignore = !1, o._delayedClicks[l])) {
            var h = o._delayedClicks[l].evt, d = Le.POINTERTAP, p = new Sr(d, h, o._currentPickResult);
            a.onPointerObservable.hasObservers() && a.onPointerObservable.hasSpecificMask(d) && a.onPointerObservable.notifyObservers(p, d), o._delayedClicks[l] = null;
          }
        }, this._initClickEvent = function(l, c, u, h) {
          var d, p, f = new jA();
          o._currentPickResult = null;
          var m = null, g = l.hasSpecificMask(Le.POINTERPICK) || c.hasSpecificMask(Le.POINTERPICK) || l.hasSpecificMask(Le.POINTERTAP) || c.hasSpecificMask(Le.POINTERTAP) || l.hasSpecificMask(Le.POINTERDOUBLETAP) || c.hasSpecificMask(Le.POINTERDOUBLETAP);
          !g && Ee && (m = o._initActionManager(m, f)) && (g = m.hasPickTriggers);
          var y = !1;
          if (g) {
            var b = u.button;
            if (f.hasSwiped = o._isPointerSwiping(), !f.hasSwiped) {
              var T = !n.ExclusiveDoubleClickMode;
              if (T || (T = !l.hasSpecificMask(Le.POINTERDOUBLETAP) && !c.hasSpecificMask(Le.POINTERDOUBLETAP)) && !Ee.HasSpecificTrigger(_.ACTION_OnDoublePickTrigger) && (m = o._initActionManager(m, f)) && (T = !m.hasSpecificTrigger(_.ACTION_OnDoublePickTrigger)), T)
                (Date.now() - o._previousStartingPointerTime > n.DoubleClickDelay || b !== o._previousButtonPressed) && (f.singleClick = !0, h(f, o._currentPickResult), y = !0);
              else {
                var S = { evt: u, clickInfo: f, timeoutId: window.setTimeout(o._delayedSimpleClick.bind(o, b, f, h), n.DoubleClickDelay) };
                o._delayedClicks[b] = S;
              }
              var E = l.hasSpecificMask(Le.POINTERDOUBLETAP) || c.hasSpecificMask(Le.POINTERDOUBLETAP);
              !E && Ee.HasSpecificTrigger(_.ACTION_OnDoublePickTrigger) && (m = o._initActionManager(m, f)) && (E = m.hasSpecificTrigger(_.ACTION_OnDoublePickTrigger)), E && (b === o._previousButtonPressed && Date.now() - o._previousStartingPointerTime < n.DoubleClickDelay && !o._doubleClickOccured ? (f.hasSwiped || o._isPointerSwiping() ? (o._doubleClickOccured = !1, o._previousStartingPointerTime = o._startingPointerTime, o._previousStartingPointerPosition.x = o._startingPointerPosition.x, o._previousStartingPointerPosition.y = o._startingPointerPosition.y, o._previousButtonPressed = b, n.ExclusiveDoubleClickMode ? (o._delayedClicks[b] && (clearTimeout((p = o._delayedClicks[b]) === null || p === void 0 ? void 0 : p.timeoutId), o._delayedClicks[b] = null), h(f, o._previousPickResult)) : h(f, o._currentPickResult)) : (o._previousStartingPointerTime = 0, o._doubleClickOccured = !0, f.doubleClick = !0, f.ignore = !1, n.ExclusiveDoubleClickMode && o._delayedClicks[b] && (clearTimeout((d = o._delayedClicks[b]) === null || d === void 0 ? void 0 : d.timeoutId), o._delayedClicks[b] = null), h(f, o._currentPickResult)), y = !0) : (o._doubleClickOccured = !1, o._previousStartingPointerTime = o._startingPointerTime, o._previousStartingPointerPosition.x = o._startingPointerPosition.x, o._previousStartingPointerPosition.y = o._startingPointerPosition.y, o._previousButtonPressed = b));
            }
          }
          y || h(f, o._currentPickResult);
        }, this._onPointerMove = function(l) {
          if (o._updatePointerPosition(l), o._isSwiping || o._swipeButtonPressed === -1 || (o._isSwiping = Math.abs(o._startingPointerPosition.x - o._pointerX) > n.DragMovementThreshold || Math.abs(o._startingPointerPosition.y - o._pointerY) > n.DragMovementThreshold), s.isPointerLock && s._verifyPointerLock(), !o._checkPrePointerObservable(null, l, l.inputIndex >= at.MouseWheelX && l.inputIndex <= at.MouseWheelZ ? Le.POINTERWHEEL : Le.POINTERMOVE) && (a.cameraToUseForPointers || a.activeCamera))
            if (a.skipPointerMovePicking)
              o._processPointerMove(new Ki(), l);
            else {
              a.pointerMovePredicate || (a.pointerMovePredicate = function(u) {
                return u.isPickable && u.isVisible && u.isReady() && u.isEnabled() && (u.enablePointerMoveEvents || a.constantlyUpdateMeshUnderPointer || u._getActionManagerForTrigger() !== null) && (!a.cameraToUseForPointers || (a.cameraToUseForPointers.layerMask & u.layerMask) != 0);
              });
              var c = a._registeredActions > 0 || a.constantlyUpdateMeshUnderPointer ? o._pickMove(l) : null;
              o._processPointerMove(c, l);
            }
        }, this._onPointerDown = function(l) {
          var c, u;
          if (o._totalPointersPressed++, o._pickedDownMesh = null, o._meshPickProceed = !1, n.ExclusiveDoubleClickMode) {
            for (var h = 0; h < o._delayedClicks.length; h++)
              if (o._delayedClicks[h])
                if (l.button === h)
                  clearTimeout((c = o._delayedClicks[h]) === null || c === void 0 ? void 0 : c.timeoutId);
                else {
                  var d = o._delayedClicks[h].clickInfo;
                  o._doubleClickOccured = !1, d.singleClick = !0, d.ignore = !1;
                  var p = o._delayedClicks[h].evt, f = Le.POINTERTAP, m = new Sr(f, p, o._currentPickResult);
                  a.onPointerObservable.hasObservers() && a.onPointerObservable.hasSpecificMask(f) && a.onPointerObservable.notifyObservers(m, f), o._delayedClicks[h] = null;
                }
          }
          o._updatePointerPosition(l), o._swipeButtonPressed === -1 && (o._swipeButtonPressed = l.button), a.preventDefaultOnPointerDown && r && (l.preventDefault(), r.focus()), o._startingPointerPosition.x = o._pointerX, o._startingPointerPosition.y = o._pointerY, o._startingPointerTime = Date.now(), o._checkPrePointerObservable(null, l, Le.POINTERDOWN) || (a.cameraToUseForPointers || a.activeCamera) && (o._pointerCaptures[l.pointerId] = !0, a.pointerDownPredicate || (a.pointerDownPredicate = function(g) {
            return g.isPickable && g.isVisible && g.isReady() && g.isEnabled() && (!a.cameraToUseForPointers || (a.cameraToUseForPointers.layerMask & g.layerMask) != 0);
          }), o._pickedDownMesh = null, u = a.skipPointerDownPicking || a._registeredActions === 0 && !o._checkForPicking() && !a.onPointerDown ? new Ki() : a.pick(o._unTranslatedPointerX, o._unTranslatedPointerY, a.pointerDownPredicate, a.pointerDownFastCheck, a.cameraToUseForPointers), o._processPointerDown(u, l));
        }, this._onPointerUp = function(l) {
          o._totalPointersPressed !== 0 && (o._totalPointersPressed--, o._pickedUpMesh = null, o._meshPickProceed = !1, o._updatePointerPosition(l), a.preventDefaultOnPointerUp && r && (l.preventDefault(), r.focus()), o._initClickEvent(a.onPrePointerObservable, a.onPointerObservable, l, function(c, u) {
            if (a.onPrePointerObservable.hasObservers() && (o._skipPointerTap = !1, !c.ignore)) {
              if (o._checkPrePointerObservable(null, l, Le.POINTERUP))
                return o._swipeButtonPressed === l.button && (o._isSwiping = !1, o._swipeButtonPressed = -1), void (l.buttons === 0 && (o._pointerCaptures[l.pointerId] = !1));
              c.hasSwiped || (c.singleClick && a.onPrePointerObservable.hasSpecificMask(Le.POINTERTAP) && o._checkPrePointerObservable(null, l, Le.POINTERTAP) && (o._skipPointerTap = !0), c.doubleClick && a.onPrePointerObservable.hasSpecificMask(Le.POINTERDOUBLETAP) && o._checkPrePointerObservable(null, l, Le.POINTERDOUBLETAP) && (o._skipPointerTap = !0));
            }
            o._pointerCaptures[l.pointerId] ? (l.buttons === 0 && (o._pointerCaptures[l.pointerId] = !1), (a.cameraToUseForPointers || a.activeCamera) && (a.pointerUpPredicate || (a.pointerUpPredicate = function(h) {
              return h.isPickable && h.isVisible && h.isReady() && h.isEnabled() && (!a.cameraToUseForPointers || (a.cameraToUseForPointers.layerMask & h.layerMask) != 0);
            }), !o._meshPickProceed && (Ee && Ee.HasTriggers || o._checkForPicking() || a.onPointerUp) && o._initActionManager(null, c), u || (u = o._currentPickResult), o._processPointerUp(u, l, c), o._previousPickResult = o._currentPickResult, o._swipeButtonPressed === l.button && (o._isSwiping = !1, o._swipeButtonPressed = -1))) : o._swipeButtonPressed === l.button && (o._isSwiping = !1, o._swipeButtonPressed = -1);
          }));
        }, this._onKeyDown = function(l) {
          var c = ps.KEYDOWN;
          if (a.onPreKeyboardObservable.hasObservers()) {
            var u = new vp(c, l);
            if (a.onPreKeyboardObservable.notifyObservers(u, c), u.skipOnKeyboardObservable)
              return;
          }
          a.onKeyboardObservable.hasObservers() && (u = new Gu(c, l), a.onKeyboardObservable.notifyObservers(u, c)), a.actionManager && a.actionManager.processTrigger(_.ACTION_OnKeyDownTrigger, mi.CreateNewFromScene(a, l));
        }, this._onKeyUp = function(l) {
          var c = ps.KEYUP;
          if (a.onPreKeyboardObservable.hasObservers()) {
            var u = new vp(c, l);
            if (a.onPreKeyboardObservable.notifyObservers(u, c), u.skipOnKeyboardObservable)
              return;
          }
          a.onKeyboardObservable.hasObservers() && (u = new Gu(c, l), a.onKeyboardObservable.notifyObservers(u, c)), a.actionManager && a.actionManager.processTrigger(_.ACTION_OnKeyUpTrigger, mi.CreateNewFromScene(a, l));
        }, this._deviceSourceManager.onDeviceConnectedObservable.add(function(l) {
          l.deviceType === Ze.Mouse ? l.onInputChangedObservable.add(function(c) {
            c.inputIndex === at.LeftClick || c.inputIndex === at.MiddleClick || c.inputIndex === at.RightClick || c.inputIndex === at.BrowserBack || c.inputIndex === at.BrowserForward ? e && l.getInput(c.inputIndex) === 1 ? o._onPointerDown(c) : t && l.getInput(c.inputIndex) === 0 && o._onPointerUp(c) : i && (c.inputIndex === at.Move ? o._onPointerMove(c) : c.inputIndex !== at.MouseWheelX && c.inputIndex !== at.MouseWheelY && c.inputIndex !== at.MouseWheelZ || o._onPointerMove(c));
          }) : l.deviceType === Ze.Touch ? l.onInputChangedObservable.add(function(c) {
            c.inputIndex === at.LeftClick && (e && l.getInput(c.inputIndex) === 1 ? (o._onPointerDown(c), o._totalPointersPressed > 1 && (o._isMultiTouchGesture = !0)) : t && l.getInput(c.inputIndex) === 0 && (o._onPointerUp(c), o._totalPointersPressed === 0 && (o._isMultiTouchGesture = !1))), i && c.inputIndex === at.Move && o._onPointerMove(c);
          }) : l.deviceType === Ze.Keyboard && l.onInputChangedObservable.add(function(c) {
            c.type === "keydown" ? o._onKeyDown(c) : c.type === "keyup" && o._onKeyUp(c);
          });
        }), this._alreadyAttached = !0;
      }, n.prototype.detachControl = function() {
        this._alreadyAttached && (this._deviceSourceManager.dispose(), this._deviceSourceManager = null, this._alreadyAttachedTo && !this._scene.doNotHandleCursors && (this._alreadyAttachedTo.style.cursor = this._scene.defaultCursor), this._alreadyAttached = !1, this._alreadyAttachedTo = null);
      }, n.prototype.setPointerOverMesh = function(t, e, i, r) {
        if (e === void 0 && (e = 0), this._meshUnderPointerId[e] !== t || t && t._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting) {
          var o, a = this._meshUnderPointerId[e];
          a && (o = a._getActionManagerForTrigger(_.ACTION_OnPointerOutTrigger)) && o.processTrigger(_.ACTION_OnPointerOutTrigger, mi.CreateNew(a, r, { pointerId: e })), t ? (this._meshUnderPointerId[e] = t, this._pointerOverMesh = t, (o = t._getActionManagerForTrigger(_.ACTION_OnPointerOverTrigger)) && o.processTrigger(_.ACTION_OnPointerOverTrigger, mi.CreateNew(t, r, { pointerId: e, pickResult: i }))) : (delete this._meshUnderPointerId[e], this._pointerOverMesh = null);
        }
      }, n.prototype.getPointerOverMesh = function() {
        return this.meshUnderPointer;
      }, n.prototype._invalidateMesh = function(t) {
        for (var e in this._pointerOverMesh === t && (this._pointerOverMesh = null), this._pickedDownMesh === t && (this._pickedDownMesh = null), this._pickedUpMesh === t && (this._pickedUpMesh = null), this._meshUnderPointerId)
          this._meshUnderPointerId[e] === t && delete this._meshUnderPointerId[e];
      }, n.DragMovementThreshold = 10, n.LongPressDelay = 500, n.DoubleClickDelay = 300, n.ExclusiveDoubleClickMode = !1, n;
    }(), Sn = function() {
      function n() {
        this._startMonitoringTime = 0, this._min = 0, this._max = 0, this._average = 0, this._lastSecAverage = 0, this._current = 0, this._totalValueCount = 0, this._totalAccumulated = 0, this._lastSecAccumulated = 0, this._lastSecTime = 0, this._lastSecValueCount = 0;
      }
      return Object.defineProperty(n.prototype, "min", { get: function() {
        return this._min;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "max", { get: function() {
        return this._max;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "average", { get: function() {
        return this._average;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "lastSecAverage", { get: function() {
        return this._lastSecAverage;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "current", { get: function() {
        return this._current;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "total", { get: function() {
        return this._totalAccumulated;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "count", { get: function() {
        return this._totalValueCount;
      }, enumerable: !1, configurable: !0 }), n.prototype.fetchNewFrame = function() {
        this._totalValueCount++, this._current = 0, this._lastSecValueCount++;
      }, n.prototype.addCount = function(t, e) {
        n.Enabled && (this._current += t, e && this._fetchResult());
      }, n.prototype.beginMonitoring = function() {
        n.Enabled && (this._startMonitoringTime = It.Now);
      }, n.prototype.endMonitoring = function(t) {
        if (t === void 0 && (t = !0), n.Enabled) {
          t && this.fetchNewFrame();
          var e = It.Now;
          this._current = e - this._startMonitoringTime, t && this._fetchResult();
        }
      }, n.prototype.endFrame = function() {
        this._fetchResult();
      }, n.prototype._fetchResult = function() {
        this._totalAccumulated += this._current, this._lastSecAccumulated += this._current, this._min = Math.min(this._min, this._current), this._max = Math.max(this._max, this._current), this._average = this._totalAccumulated / this._totalValueCount;
        var t = It.Now;
        t - this._lastSecTime > 1e3 && (this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount, this._lastSecTime = t, this._lastSecAccumulated = 0, this._lastSecValueCount = 0);
      }, n.Enabled = !0, n;
    }(), xo = function() {
      function n(t, e, i, r) {
        this.normal = new v(t, e, i), this.d = r;
      }
      return n.prototype.asArray = function() {
        return [this.normal.x, this.normal.y, this.normal.z, this.d];
      }, n.prototype.clone = function() {
        return new n(this.normal.x, this.normal.y, this.normal.z, this.d);
      }, n.prototype.getClassName = function() {
        return "Plane";
      }, n.prototype.getHashCode = function() {
        var t = this.normal.getHashCode();
        return 397 * t ^ (0 | this.d);
      }, n.prototype.normalize = function() {
        var t = Math.sqrt(this.normal.x * this.normal.x + this.normal.y * this.normal.y + this.normal.z * this.normal.z), e = 0;
        return t !== 0 && (e = 1 / t), this.normal.x *= e, this.normal.y *= e, this.normal.z *= e, this.d *= e, this;
      }, n.prototype.transform = function(t) {
        var e = n._TmpMatrix;
        t.invertToRef(e);
        var i = e.m, r = this.normal.x, o = this.normal.y, a = this.normal.z, s = this.d;
        return new n(r * i[0] + o * i[1] + a * i[2] + s * i[3], r * i[4] + o * i[5] + a * i[6] + s * i[7], r * i[8] + o * i[9] + a * i[10] + s * i[11], r * i[12] + o * i[13] + a * i[14] + s * i[15]);
      }, n.prototype.dotCoordinate = function(t) {
        return this.normal.x * t.x + this.normal.y * t.y + this.normal.z * t.z + this.d;
      }, n.prototype.copyFromPoints = function(t, e, i) {
        var r, o = e.x - t.x, a = e.y - t.y, s = e.z - t.z, l = i.x - t.x, c = i.y - t.y, u = i.z - t.z, h = a * u - s * c, d = s * l - o * u, p = o * c - a * l, f = Math.sqrt(h * h + d * d + p * p);
        return r = f !== 0 ? 1 / f : 0, this.normal.x = h * r, this.normal.y = d * r, this.normal.z = p * r, this.d = -(this.normal.x * t.x + this.normal.y * t.y + this.normal.z * t.z), this;
      }, n.prototype.isFrontFacingTo = function(t, e) {
        return v.Dot(this.normal, t) <= e;
      }, n.prototype.signedDistanceTo = function(t) {
        return v.Dot(t, this.normal) + this.d;
      }, n.FromArray = function(t) {
        return new n(t[0], t[1], t[2], t[3]);
      }, n.FromPoints = function(t, e, i) {
        var r = new n(0, 0, 0, 0);
        return r.copyFromPoints(t, e, i), r;
      }, n.FromPositionAndNormal = function(t, e) {
        var i = new n(0, 0, 0, 0);
        return e.normalize(), i.normal = e, i.d = -(e.x * t.x + e.y * t.y + e.z * t.z), i;
      }, n.SignedDistanceToPlaneFromPositionAndNormal = function(t, e, i) {
        var r = -(e.x * t.x + e.y * t.y + e.z * t.z);
        return v.Dot(i, e) + r;
      }, n._TmpMatrix = B.Identity(), n;
    }(), ll = function() {
      function n() {
      }
      return n.GetPlanes = function(t) {
        for (var e = [], i = 0; i < 6; i++)
          e.push(new xo(0, 0, 0, 0));
        return n.GetPlanesToRef(t, e), e;
      }, n.GetNearPlaneToRef = function(t, e) {
        var i = t.m;
        e.normal.x = i[3] + i[2], e.normal.y = i[7] + i[6], e.normal.z = i[11] + i[10], e.d = i[15] + i[14], e.normalize();
      }, n.GetFarPlaneToRef = function(t, e) {
        var i = t.m;
        e.normal.x = i[3] - i[2], e.normal.y = i[7] - i[6], e.normal.z = i[11] - i[10], e.d = i[15] - i[14], e.normalize();
      }, n.GetLeftPlaneToRef = function(t, e) {
        var i = t.m;
        e.normal.x = i[3] + i[0], e.normal.y = i[7] + i[4], e.normal.z = i[11] + i[8], e.d = i[15] + i[12], e.normalize();
      }, n.GetRightPlaneToRef = function(t, e) {
        var i = t.m;
        e.normal.x = i[3] - i[0], e.normal.y = i[7] - i[4], e.normal.z = i[11] - i[8], e.d = i[15] - i[12], e.normalize();
      }, n.GetTopPlaneToRef = function(t, e) {
        var i = t.m;
        e.normal.x = i[3] - i[1], e.normal.y = i[7] - i[5], e.normal.z = i[11] - i[9], e.d = i[15] - i[13], e.normalize();
      }, n.GetBottomPlaneToRef = function(t, e) {
        var i = t.m;
        e.normal.x = i[3] + i[1], e.normal.y = i[7] + i[5], e.normal.z = i[11] + i[9], e.d = i[15] + i[13], e.normalize();
      }, n.GetPlanesToRef = function(t, e) {
        n.GetNearPlaneToRef(t, e[0]), n.GetFarPlaneToRef(t, e[1]), n.GetLeftPlaneToRef(t, e[2]), n.GetRightPlaneToRef(t, e[3]), n.GetTopPlaneToRef(t, e[4]), n.GetBottomPlaneToRef(t, e[5]);
      }, n.IsPointInFrustum = function(t, e) {
        for (var i = 0; i < 6; i++)
          if (e[i].dotCoordinate(t) < 0)
            return !1;
        return !0;
      }, n;
    }(), bp = function() {
      function n() {
      }
      return Object.defineProperty(n, "UniqueId", { get: function() {
        var t = this._UniqueIdCounter;
        return this._UniqueIdCounter++, t;
      }, enumerable: !1, configurable: !0 }), n._UniqueIdCounter = 1, n;
    }(), nn = function() {
      function n() {
      }
      return n.CompareLightsPriority = function(t, e) {
        return t.shadowEnabled !== e.shadowEnabled ? (e.shadowEnabled ? 1 : 0) - (t.shadowEnabled ? 1 : 0) : e.renderPriority - t.renderPriority;
      }, n.FALLOFF_DEFAULT = 0, n.FALLOFF_PHYSICAL = 1, n.FALLOFF_GLTF = 2, n.FALLOFF_STANDARD = 3, n.LIGHTMAP_DEFAULT = 0, n.LIGHTMAP_SPECULAR = 1, n.LIGHTMAP_SHADOWSONLY = 2, n.INTENSITYMODE_AUTOMATIC = 0, n.INTENSITYMODE_LUMINOUSPOWER = 1, n.INTENSITYMODE_LUMINOUSINTENSITY = 2, n.INTENSITYMODE_ILLUMINANCE = 3, n.INTENSITYMODE_LUMINANCE = 4, n.LIGHTTYPEID_POINTLIGHT = 0, n.LIGHTTYPEID_DIRECTIONALLIGHT = 1, n.LIGHTTYPEID_SPOTLIGHT = 2, n.LIGHTTYPEID_HEMISPHERICLIGHT = 3, n;
    }(), M1 = function() {
      this.pointerDownFastCheck = !1, this.pointerUpFastCheck = !1, this.pointerMoveFastCheck = !1, this.skipPointerMovePicking = !1, this.skipPointerDownPicking = !1, this.skipPointerUpPicking = !1;
    };
    (function(n) {
      n[n.BackwardCompatible = 0] = "BackwardCompatible", n[n.Intermediate = 1] = "Intermediate", n[n.Aggressive = 2] = "Aggressive";
    })(Zr || (Zr = {}));
    var ht, Ue = function(n) {
      function t(e, i) {
        var r = n.call(this) || this;
        r._inputManager = new Ba(r), r.cameraToUseForPointers = null, r._isScene = !0, r._blockEntityCollection = !1, r.autoClear = !0, r.autoClearDepthAndStencil = !0, r.clearColor = new Ie(0.2, 0.2, 0.3, 1), r.ambientColor = new ne(0, 0, 0), r.environmentIntensity = 1, r._performancePriority = Zr.BackwardCompatible, r.onScenePerformancePriorityChangedObservable = new H(), r._forceWireframe = !1, r._skipFrustumClipping = !1, r._forcePointsCloud = !1, r.animationsEnabled = !0, r._animationPropertiesOverride = null, r.useConstantAnimationDeltaTime = !1, r.constantlyUpdateMeshUnderPointer = !1, r.hoverCursor = "pointer", r.defaultCursor = "", r.doNotHandleCursors = !1, r.preventDefaultOnPointerDown = !0, r.preventDefaultOnPointerUp = !0, r.metadata = null, r.reservedDataStore = null, r.disableOfflineSupportExceptionRules = [], r.onDisposeObservable = new H(), r._onDisposeObserver = null, r.onBeforeRenderObservable = new H(), r._onBeforeRenderObserver = null, r.onAfterRenderObservable = new H(), r.onAfterRenderCameraObservable = new H(), r._onAfterRenderObserver = null, r.onBeforeAnimationsObservable = new H(), r.onAfterAnimationsObservable = new H(), r.onBeforeDrawPhaseObservable = new H(), r.onAfterDrawPhaseObservable = new H(), r.onReadyObservable = new H(), r.onBeforeCameraRenderObservable = new H(), r._onBeforeCameraRenderObserver = null, r.onAfterCameraRenderObservable = new H(), r._onAfterCameraRenderObserver = null, r.onBeforeActiveMeshesEvaluationObservable = new H(), r.onAfterActiveMeshesEvaluationObservable = new H(), r.onBeforeParticlesRenderingObservable = new H(), r.onAfterParticlesRenderingObservable = new H(), r.onDataLoadedObservable = new H(), r.onNewCameraAddedObservable = new H(), r.onCameraRemovedObservable = new H(), r.onNewLightAddedObservable = new H(), r.onLightRemovedObservable = new H(), r.onNewGeometryAddedObservable = new H(), r.onGeometryRemovedObservable = new H(), r.onNewTransformNodeAddedObservable = new H(), r.onTransformNodeRemovedObservable = new H(), r.onNewMeshAddedObservable = new H(), r.onMeshRemovedObservable = new H(), r.onNewSkeletonAddedObservable = new H(), r.onSkeletonRemovedObservable = new H(), r.onNewMaterialAddedObservable = new H(), r.onNewMultiMaterialAddedObservable = new H(), r.onMaterialRemovedObservable = new H(), r.onMultiMaterialRemovedObservable = new H(), r.onNewTextureAddedObservable = new H(), r.onTextureRemovedObservable = new H(), r.onBeforeRenderTargetsRenderObservable = new H(), r.onAfterRenderTargetsRenderObservable = new H(), r.onBeforeStepObservable = new H(), r.onAfterStepObservable = new H(), r.onActiveCameraChanged = new H(), r.onActiveCamerasChanged = new H(), r.onBeforeRenderingGroupObservable = new H(), r.onAfterRenderingGroupObservable = new H(), r.onMeshImportedObservable = new H(), r.onAnimationFileImportedObservable = new H(), r._registeredForLateAnimationBindings = new oa(256), r._pointerPickingConfiguration = new M1(), r.onPrePointerObservable = new H(), r.onPointerObservable = new H(), r.onPreKeyboardObservable = new H(), r.onKeyboardObservable = new H(), r._useRightHandedSystem = !1, r._timeAccumulator = 0, r._currentStepId = 0, r._currentInternalStep = 0, r._fogEnabled = !0, r._fogMode = t.FOGMODE_NONE, r.fogColor = new ne(0.2, 0.2, 0.3), r.fogDensity = 0.1, r.fogStart = 0, r.fogEnd = 1e3, r.needsPreviousWorldMatrices = !1, r._shadowsEnabled = !0, r._lightsEnabled = !0, r._unObserveActiveCameras = null, r._texturesEnabled = !0, r.physicsEnabled = !0, r.particlesEnabled = !0, r.spritesEnabled = !0, r._skeletonsEnabled = !0, r.lensFlaresEnabled = !0, r.collisionsEnabled = !0, r.gravity = new v(0, -9.807, 0), r.postProcessesEnabled = !0, r.renderTargetsEnabled = !0, r.dumpNextRenderTargets = !1, r.customRenderTargets = [], r.importedMeshesFiles = [], r.probesEnabled = !0, r._meshesForIntersections = new oa(256), r.proceduralTexturesEnabled = !0, r._totalVertices = new Sn(), r._activeIndices = new Sn(), r._activeParticles = new Sn(), r._activeBones = new Sn(), r._animationTime = 0, r.animationTimeScale = 1, r._renderId = 0, r._frameId = 0, r._executeWhenReadyTimeoutId = null, r._intermediateRendering = !1, r._defaultFrameBufferCleared = !1, r._viewUpdateFlag = -1, r._projectionUpdateFlag = -1, r._toBeDisposed = new Array(256), r._activeRequests = new Array(), r._pendingData = new Array(), r._isDisposed = !1, r.dispatchAllSubMeshesOfActiveMeshes = !1, r._activeMeshes = new en(256), r._processedMaterials = new en(256), r._renderTargets = new oa(256), r._materialsRenderTargets = new oa(256), r._activeParticleSystems = new en(256), r._activeSkeletons = new oa(32), r._softwareSkinnedMeshes = new oa(32), r._activeAnimatables = new Array(), r._transformMatrix = B.Zero(), r.requireLightSorting = !1, r._components = [], r._serializableComponents = [], r._transientComponents = [], r._beforeCameraUpdateStage = Ni.Create(), r._beforeClearStage = Ni.Create(), r._beforeRenderTargetClearStage = Ni.Create(), r._gatherRenderTargetsStage = Ni.Create(), r._gatherActiveCameraRenderTargetsStage = Ni.Create(), r._isReadyForMeshStage = Ni.Create(), r._beforeEvaluateActiveMeshStage = Ni.Create(), r._evaluateSubMeshStage = Ni.Create(), r._preActiveMeshStage = Ni.Create(), r._cameraDrawRenderTargetStage = Ni.Create(), r._beforeCameraDrawStage = Ni.Create(), r._beforeRenderTargetDrawStage = Ni.Create(), r._beforeRenderingGroupDrawStage = Ni.Create(), r._beforeRenderingMeshStage = Ni.Create(), r._afterRenderingMeshStage = Ni.Create(), r._afterRenderingGroupDrawStage = Ni.Create(), r._afterCameraDrawStage = Ni.Create(), r._afterCameraPostProcessStage = Ni.Create(), r._afterRenderTargetDrawStage = Ni.Create(), r._afterRenderTargetPostProcessStage = Ni.Create(), r._afterRenderStage = Ni.Create(), r._pointerMoveStage = Ni.Create(), r._pointerDownStage = Ni.Create(), r._pointerUpStage = Ni.Create(), r._geometriesByUniqueId = null, r._defaultMeshCandidates = { data: [], length: 0 }, r._defaultSubMeshCandidates = { data: [], length: 0 }, r._preventFreeActiveMeshesAndRenderingGroups = !1, r._activeMeshesFrozen = !1, r._activeMeshesFrozenButKeepClipping = !1, r._skipEvaluateActiveMeshesCompletely = !1, r._allowPostProcessClearColor = !0, r.getDeterministicFrameTime = function() {
          return r._engine.getTimeStep();
        }, r._registeredActions = 0, r._blockMaterialDirtyMechanism = !1, r._perfCollector = null, r.activeCameras = [];
        var o = je({ useGeometryUniqueIdsMap: !0, useMaterialMeshMap: !0, useClonedMeshMap: !0, virtual: !1 }, i);
        return e = r._engine = e || Me.LastCreatedEngine, o.virtual ? e._virtualScenes.push(r) : (Me._LastCreatedScene = r, e.scenes.push(r)), r._uid = null, r._renderingManager = new rc(r), nc && (r.postProcessManager = new nc(r)), Gi() && r.attachControl(), r._createUbo(), tn && (r._imageProcessingConfiguration = new tn()), r.setDefaultCandidateProviders(), o.useGeometryUniqueIdsMap && (r._geometriesByUniqueId = {}), r.useMaterialMeshMap = o.useMaterialMeshMap, r.useClonedMeshMap = o.useClonedMeshMap, i && i.virtual || e.onNewSceneAddedObservable.notifyObservers(r), r;
      }
      return D(t, n), t.DefaultMaterialFactory = function(e) {
        throw et("StandardMaterial");
      }, t.CollisionCoordinatorFactory = function() {
        throw et("DefaultCollisionCoordinator");
      }, Object.defineProperty(t.prototype, "environmentTexture", { get: function() {
        return this._environmentTexture;
      }, set: function(e) {
        this._environmentTexture !== e && (this._environmentTexture = e, this.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "imageProcessingConfiguration", { get: function() {
        return this._imageProcessingConfiguration;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "performancePriority", { get: function() {
        return this._performancePriority;
      }, set: function(e) {
        if (e !== this._performancePriority) {
          switch (this._performancePriority = e, e) {
            case Zr.BackwardCompatible:
              this.skipFrustumClipping = !1, this._renderingManager.maintainStateBetweenFrames = !1, this.skipPointerMovePicking = !1, this.autoClear = !0;
              break;
            case Zr.Intermediate:
              this.skipFrustumClipping = !1, this._renderingManager.maintainStateBetweenFrames = !1, this.skipPointerMovePicking = !0, this.autoClear = !1;
              break;
            case Zr.Aggressive:
              this.skipFrustumClipping = !0, this._renderingManager.maintainStateBetweenFrames = !0, this.skipPointerMovePicking = !0, this.autoClear = !1;
          }
          this.onScenePerformancePriorityChangedObservable.notifyObservers(e);
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "forceWireframe", { get: function() {
        return this._forceWireframe;
      }, set: function(e) {
        this._forceWireframe !== e && (this._forceWireframe = e, this.markAllMaterialsAsDirty(_.MATERIAL_MiscDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "skipFrustumClipping", { get: function() {
        return this._skipFrustumClipping;
      }, set: function(e) {
        this._skipFrustumClipping !== e && (this._skipFrustumClipping = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "forcePointsCloud", { get: function() {
        return this._forcePointsCloud;
      }, set: function(e) {
        this._forcePointsCloud !== e && (this._forcePointsCloud = e, this.markAllMaterialsAsDirty(_.MATERIAL_MiscDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "animationPropertiesOverride", { get: function() {
        return this._animationPropertiesOverride;
      }, set: function(e) {
        this._animationPropertiesOverride = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onDispose", { set: function(e) {
        this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver), this._onDisposeObserver = this.onDisposeObservable.add(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "beforeRender", { set: function(e) {
        this._onBeforeRenderObserver && this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver), e && (this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(e));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "afterRender", { set: function(e) {
        this._onAfterRenderObserver && this.onAfterRenderObservable.remove(this._onAfterRenderObserver), e && (this._onAfterRenderObserver = this.onAfterRenderObservable.add(e));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "beforeCameraRender", { set: function(e) {
        this._onBeforeCameraRenderObserver && this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver), this._onBeforeCameraRenderObserver = this.onBeforeCameraRenderObservable.add(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "afterCameraRender", { set: function(e) {
        this._onAfterCameraRenderObserver && this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver), this._onAfterCameraRenderObserver = this.onAfterCameraRenderObservable.add(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "pointerDownPredicate", { get: function() {
        return this._pointerPickingConfiguration.pointerDownPredicate;
      }, set: function(e) {
        this._pointerPickingConfiguration.pointerDownPredicate = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "pointerUpPredicate", { get: function() {
        return this._pointerPickingConfiguration.pointerUpPredicate;
      }, set: function(e) {
        this._pointerPickingConfiguration.pointerUpPredicate = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "pointerMovePredicate", { get: function() {
        return this._pointerPickingConfiguration.pointerMovePredicate;
      }, set: function(e) {
        this._pointerPickingConfiguration.pointerMovePredicate = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "pointerDownFastCheck", { get: function() {
        return this._pointerPickingConfiguration.pointerDownFastCheck;
      }, set: function(e) {
        this._pointerPickingConfiguration.pointerDownFastCheck = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "pointerUpFastCheck", { get: function() {
        return this._pointerPickingConfiguration.pointerUpFastCheck;
      }, set: function(e) {
        this._pointerPickingConfiguration.pointerUpFastCheck = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "pointerMoveFastCheck", { get: function() {
        return this._pointerPickingConfiguration.pointerMoveFastCheck;
      }, set: function(e) {
        this._pointerPickingConfiguration.pointerMoveFastCheck = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "skipPointerMovePicking", { get: function() {
        return this._pointerPickingConfiguration.skipPointerMovePicking;
      }, set: function(e) {
        this._pointerPickingConfiguration.skipPointerMovePicking = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "skipPointerDownPicking", { get: function() {
        return this._pointerPickingConfiguration.skipPointerDownPicking;
      }, set: function(e) {
        this._pointerPickingConfiguration.skipPointerDownPicking = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "skipPointerUpPicking", { get: function() {
        return this._pointerPickingConfiguration.skipPointerUpPicking;
      }, set: function(e) {
        this._pointerPickingConfiguration.skipPointerUpPicking = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "unTranslatedPointer", { get: function() {
        return this._inputManager.unTranslatedPointer;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "DragMovementThreshold", { get: function() {
        return Ba.DragMovementThreshold;
      }, set: function(e) {
        Ba.DragMovementThreshold = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "LongPressDelay", { get: function() {
        return Ba.LongPressDelay;
      }, set: function(e) {
        Ba.LongPressDelay = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "DoubleClickDelay", { get: function() {
        return Ba.DoubleClickDelay;
      }, set: function(e) {
        Ba.DoubleClickDelay = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "ExclusiveDoubleClickMode", { get: function() {
        return Ba.ExclusiveDoubleClickMode;
      }, set: function(e) {
        Ba.ExclusiveDoubleClickMode = e;
      }, enumerable: !1, configurable: !0 }), t.prototype.bindEyePosition = function(e, i, r) {
        i === void 0 && (i = "vEyePosition"), r === void 0 && (r = !1);
        var o = this._forcedViewPosition ? this._forcedViewPosition : this._mirroredCameraPosition ? this._mirroredCameraPosition : this.activeCamera.globalPosition, a = this.useRightHandedSystem === (this._mirroredCameraPosition != null);
        return F.Vector4[0].set(o.x, o.y, o.z, a ? -1 : 1), e && (r ? e.setFloat3(i, F.Vector4[0].x, F.Vector4[0].y, F.Vector4[0].z) : e.setVector4(i, F.Vector4[0])), F.Vector4[0];
      }, t.prototype.finalizeSceneUbo = function() {
        var e = this.getSceneUniformBuffer(), i = this.bindEyePosition(null);
        return e.updateFloat4("vEyePosition", i.x, i.y, i.z, i.w), e.update(), e;
      }, Object.defineProperty(t.prototype, "useRightHandedSystem", { get: function() {
        return this._useRightHandedSystem;
      }, set: function(e) {
        this._useRightHandedSystem !== e && (this._useRightHandedSystem = e, this.markAllMaterialsAsDirty(_.MATERIAL_MiscDirtyFlag));
      }, enumerable: !1, configurable: !0 }), t.prototype.setStepId = function(e) {
        this._currentStepId = e;
      }, t.prototype.getStepId = function() {
        return this._currentStepId;
      }, t.prototype.getInternalStep = function() {
        return this._currentInternalStep;
      }, Object.defineProperty(t.prototype, "fogEnabled", { get: function() {
        return this._fogEnabled;
      }, set: function(e) {
        this._fogEnabled !== e && (this._fogEnabled = e, this.markAllMaterialsAsDirty(_.MATERIAL_MiscDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "fogMode", { get: function() {
        return this._fogMode;
      }, set: function(e) {
        this._fogMode !== e && (this._fogMode = e, this.markAllMaterialsAsDirty(_.MATERIAL_MiscDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "prePass", { get: function() {
        return !!this.prePassRenderer && this.prePassRenderer.defaultRT.enabled;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "shadowsEnabled", { get: function() {
        return this._shadowsEnabled;
      }, set: function(e) {
        this._shadowsEnabled !== e && (this._shadowsEnabled = e, this.markAllMaterialsAsDirty(_.MATERIAL_LightDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "lightsEnabled", { get: function() {
        return this._lightsEnabled;
      }, set: function(e) {
        this._lightsEnabled !== e && (this._lightsEnabled = e, this.markAllMaterialsAsDirty(_.MATERIAL_LightDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "activeCameras", { get: function() {
        return this._activeCameras;
      }, set: function(e) {
        var i = this;
        this._unObserveActiveCameras && (this._unObserveActiveCameras(), this._unObserveActiveCameras = null), e && (this._unObserveActiveCameras = ot(e, function() {
          i.onActiveCamerasChanged.notifyObservers(i);
        })), this._activeCameras = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "activeCamera", { get: function() {
        return this._activeCamera;
      }, set: function(e) {
        e !== this._activeCamera && (this._activeCamera = e, this.onActiveCameraChanged.notifyObservers(this));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "defaultMaterial", { get: function() {
        return this._defaultMaterial || (this._defaultMaterial = t.DefaultMaterialFactory(this)), this._defaultMaterial;
      }, set: function(e) {
        this._defaultMaterial = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "texturesEnabled", { get: function() {
        return this._texturesEnabled;
      }, set: function(e) {
        this._texturesEnabled !== e && (this._texturesEnabled = e, this.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "skeletonsEnabled", { get: function() {
        return this._skeletonsEnabled;
      }, set: function(e) {
        this._skeletonsEnabled !== e && (this._skeletonsEnabled = e, this.markAllMaterialsAsDirty(_.MATERIAL_AttributesDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "collisionCoordinator", { get: function() {
        return this._collisionCoordinator || (this._collisionCoordinator = t.CollisionCoordinatorFactory(), this._collisionCoordinator.init(this)), this._collisionCoordinator;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "renderingManager", { get: function() {
        return this._renderingManager;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "frustumPlanes", { get: function() {
        return this._frustumPlanes;
      }, enumerable: !1, configurable: !0 }), t.prototype._registerTransientComponents = function() {
        if (this._transientComponents.length > 0) {
          for (var e = 0, i = this._transientComponents; e < i.length; e++)
            i[e].register();
          this._transientComponents.length = 0;
        }
      }, t.prototype._addComponent = function(e) {
        this._components.push(e), this._transientComponents.push(e);
        var i = e;
        i.addFromContainer && i.serialize && this._serializableComponents.push(i);
      }, t.prototype._getComponent = function(e) {
        for (var i = 0, r = this._components; i < r.length; i++) {
          var o = r[i];
          if (o.name === e)
            return o;
        }
        return null;
      }, t.prototype.getClassName = function() {
        return "Scene";
      }, t.prototype._getDefaultMeshCandidates = function() {
        return this._defaultMeshCandidates.data = this.meshes, this._defaultMeshCandidates.length = this.meshes.length, this._defaultMeshCandidates;
      }, t.prototype._getDefaultSubMeshCandidates = function(e) {
        return this._defaultSubMeshCandidates.data = e.subMeshes, this._defaultSubMeshCandidates.length = e.subMeshes.length, this._defaultSubMeshCandidates;
      }, t.prototype.setDefaultCandidateProviders = function() {
        var e = this;
        this.getActiveMeshCandidates = function() {
          return e._getDefaultMeshCandidates();
        }, this.getActiveSubMeshCandidates = function(i) {
          return e._getDefaultSubMeshCandidates(i);
        }, this.getIntersectingSubMeshCandidates = function(i, r) {
          return e._getDefaultSubMeshCandidates(i);
        }, this.getCollidingSubMeshCandidates = function(i, r) {
          return e._getDefaultSubMeshCandidates(i);
        };
      }, Object.defineProperty(t.prototype, "meshUnderPointer", { get: function() {
        return this._inputManager.meshUnderPointer;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "pointerX", { get: function() {
        return this._inputManager.pointerX;
      }, set: function(e) {
        this._inputManager.pointerX = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "pointerY", { get: function() {
        return this._inputManager.pointerY;
      }, set: function(e) {
        this._inputManager.pointerY = e;
      }, enumerable: !1, configurable: !0 }), t.prototype.getCachedMaterial = function() {
        return this._cachedMaterial;
      }, t.prototype.getCachedEffect = function() {
        return this._cachedEffect;
      }, t.prototype.getCachedVisibility = function() {
        return this._cachedVisibility;
      }, t.prototype.isCachedMaterialInvalid = function(e, i, r) {
        return r === void 0 && (r = 1), this._cachedEffect !== i || this._cachedMaterial !== e || this._cachedVisibility !== r;
      }, t.prototype.getEngine = function() {
        return this._engine;
      }, t.prototype.getTotalVertices = function() {
        return this._totalVertices.current;
      }, Object.defineProperty(t.prototype, "totalVerticesPerfCounter", { get: function() {
        return this._totalVertices;
      }, enumerable: !1, configurable: !0 }), t.prototype.getActiveIndices = function() {
        return this._activeIndices.current;
      }, Object.defineProperty(t.prototype, "totalActiveIndicesPerfCounter", { get: function() {
        return this._activeIndices;
      }, enumerable: !1, configurable: !0 }), t.prototype.getActiveParticles = function() {
        return this._activeParticles.current;
      }, Object.defineProperty(t.prototype, "activeParticlesPerfCounter", { get: function() {
        return this._activeParticles;
      }, enumerable: !1, configurable: !0 }), t.prototype.getActiveBones = function() {
        return this._activeBones.current;
      }, Object.defineProperty(t.prototype, "activeBonesPerfCounter", { get: function() {
        return this._activeBones;
      }, enumerable: !1, configurable: !0 }), t.prototype.getActiveMeshes = function() {
        return this._activeMeshes;
      }, t.prototype.getAnimationRatio = function() {
        return this._animationRatio !== void 0 ? this._animationRatio : 1;
      }, t.prototype.getRenderId = function() {
        return this._renderId;
      }, t.prototype.getFrameId = function() {
        return this._frameId;
      }, t.prototype.incrementRenderId = function() {
        this._renderId++;
      }, t.prototype._createUbo = function() {
        this.setSceneUniformBuffer(this.createSceneUniformBuffer());
      }, t.prototype.simulatePointerMove = function(e, i) {
        return this._inputManager.simulatePointerMove(e, i), this;
      }, t.prototype.simulatePointerDown = function(e, i) {
        return this._inputManager.simulatePointerDown(e, i), this;
      }, t.prototype.simulatePointerUp = function(e, i, r) {
        return this._inputManager.simulatePointerUp(e, i, r), this;
      }, t.prototype.isPointerCaptured = function(e) {
        return e === void 0 && (e = 0), this._inputManager.isPointerCaptured(e);
      }, t.prototype.attachControl = function(e, i, r) {
        e === void 0 && (e = !0), i === void 0 && (i = !0), r === void 0 && (r = !0), this._inputManager.attachControl(e, i, r);
      }, t.prototype.detachControl = function() {
        this._inputManager.detachControl();
      }, t.prototype.isReady = function(e) {
        var i, r, o, a;
        if (e === void 0 && (e = !0), this._isDisposed)
          return !1;
        var s = this.getEngine(), l = s.currentRenderPassId;
        s.currentRenderPassId = (r = (i = this.activeCamera) === null || i === void 0 ? void 0 : i.renderPassId) !== null && r !== void 0 ? r : l;
        var c = !0;
        for (this._pendingData.length > 0 && (c = !1), (o = this.prePassRenderer) === null || o === void 0 || o.update(), this.useOrderIndependentTransparency && this.depthPeelingRenderer && c && (c = this.depthPeelingRenderer.isReady()), e && (this._processedMaterials.reset(), this._materialsRenderTargets.reset()), a = 0; a < this.meshes.length; a++) {
          var u = this.meshes[a];
          if (u.subMeshes && u.subMeshes.length !== 0)
            if (u.isReady(!0)) {
              for (var h = u.hasThinInstances || u.getClassName() === "InstancedMesh" || u.getClassName() === "InstancedLinesMesh" || s.getCaps().instancedArrays && u.instances.length > 0, d = 0, p = this._isReadyForMeshStage; d < p.length; d++)
                p[d].action(u, h) || (c = !1);
              if (e) {
                var f = u.material || this.defaultMaterial;
                if (f)
                  if (f._storeEffectOnSubMeshes)
                    for (var m = 0, g = u.subMeshes; m < g.length; m++) {
                      var y = g[m].getMaterial();
                      y && y.hasRenderTargetTextures && y.getRenderTargetTextures != null && this._processedMaterials.indexOf(y) === -1 && (this._processedMaterials.push(y), this._materialsRenderTargets.concatWithNoDuplicate(y.getRenderTargetTextures()));
                    }
                  else
                    f.hasRenderTargetTextures && f.getRenderTargetTextures != null && this._processedMaterials.indexOf(f) === -1 && (this._processedMaterials.push(f), this._materialsRenderTargets.concatWithNoDuplicate(f.getRenderTargetTextures()));
              }
            } else
              c = !1;
        }
        if (e)
          for (a = 0; a < this._materialsRenderTargets.length; ++a)
            this._materialsRenderTargets.data[a].isReadyForRendering() || (c = !1);
        for (a = 0; a < this.geometries.length; a++)
          this.geometries[a].delayLoadState === _.DELAYLOADSTATE_LOADING && (c = !1);
        if (this.activeCameras && this.activeCameras.length > 0)
          for (var b = 0, T = this.activeCameras; b < T.length; b++)
            T[b].isReady(!0) || (c = !1);
        else
          this.activeCamera && (this.activeCamera.isReady(!0) || (c = !1));
        for (var S = 0, E = this.particleSystems; S < E.length; S++)
          E[S].isReady() || (c = !1);
        if (this.layers)
          for (var A = 0, R = this.layers; A < R.length; A++)
            R[A].isReady() || (c = !1);
        return s.areAllEffectsReady() || (c = !1), s.currentRenderPassId = l, c;
      }, t.prototype.resetCachedMaterial = function() {
        this._cachedMaterial = null, this._cachedEffect = null, this._cachedVisibility = null;
      }, t.prototype.registerBeforeRender = function(e) {
        this.onBeforeRenderObservable.add(e);
      }, t.prototype.unregisterBeforeRender = function(e) {
        this.onBeforeRenderObservable.removeCallback(e);
      }, t.prototype.registerAfterRender = function(e) {
        this.onAfterRenderObservable.add(e);
      }, t.prototype.unregisterAfterRender = function(e) {
        this.onAfterRenderObservable.removeCallback(e);
      }, t.prototype._executeOnceBeforeRender = function(e) {
        var i = this, r = function() {
          e(), setTimeout(function() {
            i.unregisterBeforeRender(r);
          });
        };
        this.registerBeforeRender(r);
      }, t.prototype.executeOnceBeforeRender = function(e, i) {
        var r = this;
        i !== void 0 ? setTimeout(function() {
          r._executeOnceBeforeRender(e);
        }, i) : this._executeOnceBeforeRender(e);
      }, t.prototype.addPendingData = function(e) {
        this._pendingData.push(e);
      }, t.prototype.removePendingData = function(e) {
        var i = this.isLoading, r = this._pendingData.indexOf(e);
        r !== -1 && this._pendingData.splice(r, 1), i && !this.isLoading && this.onDataLoadedObservable.notifyObservers(this);
      }, t.prototype.getWaitingItemsCount = function() {
        return this._pendingData.length;
      }, Object.defineProperty(t.prototype, "isLoading", { get: function() {
        return this._pendingData.length > 0;
      }, enumerable: !1, configurable: !0 }), t.prototype.executeWhenReady = function(e, i) {
        i === void 0 && (i = !1), this.onReadyObservable.addOnce(e), this._executeWhenReadyTimeoutId === null && this._checkIsReady(i);
      }, t.prototype.whenReadyAsync = function(e) {
        var i = this;
        return e === void 0 && (e = !1), new Promise(function(r) {
          i.executeWhenReady(function() {
            r();
          }, e);
        });
      }, t.prototype._checkIsReady = function(e) {
        var i = this;
        return e === void 0 && (e = !1), this._registerTransientComponents(), this.isReady(e) ? (this.onReadyObservable.notifyObservers(this), this.onReadyObservable.clear(), void (this._executeWhenReadyTimeoutId = null)) : this._isDisposed ? (this.onReadyObservable.clear(), void (this._executeWhenReadyTimeoutId = null)) : void (this._executeWhenReadyTimeoutId = setTimeout(function() {
          i.incrementRenderId(), i._checkIsReady(e);
        }, 100));
      }, Object.defineProperty(t.prototype, "animatables", { get: function() {
        return this._activeAnimatables;
      }, enumerable: !1, configurable: !0 }), t.prototype.resetLastAnimationTimeFrame = function() {
        this._animationTimeLast = It.Now;
      }, t.prototype.getViewMatrix = function() {
        return this._viewMatrix;
      }, t.prototype.getProjectionMatrix = function() {
        return this._projectionMatrix;
      }, t.prototype.getTransformMatrix = function() {
        return this._transformMatrix;
      }, t.prototype.setTransformMatrix = function(e, i, r, o) {
        r || o || !this._multiviewSceneUbo || (this._multiviewSceneUbo.dispose(), this._multiviewSceneUbo = null), this._viewUpdateFlag === e.updateFlag && this._projectionUpdateFlag === i.updateFlag || (this._viewUpdateFlag = e.updateFlag, this._projectionUpdateFlag = i.updateFlag, this._viewMatrix = e, this._projectionMatrix = i, this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix), this._frustumPlanes ? ll.GetPlanesToRef(this._transformMatrix, this._frustumPlanes) : this._frustumPlanes = ll.GetPlanes(this._transformMatrix), this._multiviewSceneUbo && this._multiviewSceneUbo.useUbo ? this._updateMultiviewUbo(r, o) : this._sceneUbo.useUbo && (this._sceneUbo.updateMatrix("viewProjection", this._transformMatrix), this._sceneUbo.updateMatrix("view", this._viewMatrix), this._sceneUbo.updateMatrix("projection", this._projectionMatrix)));
      }, t.prototype.getSceneUniformBuffer = function() {
        return this._multiviewSceneUbo ? this._multiviewSceneUbo : this._sceneUbo;
      }, t.prototype.createSceneUniformBuffer = function(e) {
        var i = new Er(this._engine, void 0, !1, e ?? "scene");
        return i.addUniform("viewProjection", 16), i.addUniform("view", 16), i.addUniform("projection", 16), i.addUniform("vEyePosition", 4), i;
      }, t.prototype.setSceneUniformBuffer = function(e) {
        this._sceneUbo = e, this._viewUpdateFlag = -1, this._projectionUpdateFlag = -1;
      }, t.prototype.getUniqueId = function() {
        return bp.UniqueId;
      }, t.prototype.addMesh = function(e, i) {
        var r = this;
        i === void 0 && (i = !1), this._blockEntityCollection || (this.meshes.push(e), e._resyncLightSources(), e.parent || e._addToSceneRootNodes(), this.onNewMeshAddedObservable.notifyObservers(e), i && e.getChildMeshes().forEach(function(o) {
          r.addMesh(o);
        }));
      }, t.prototype.removeMesh = function(e, i) {
        var r = this;
        i === void 0 && (i = !1);
        var o = this.meshes.indexOf(e);
        return o !== -1 && (this.meshes[o] = this.meshes[this.meshes.length - 1], this.meshes.pop(), e.parent || e._removeFromSceneRootNodes()), this._inputManager._invalidateMesh(e), this.onMeshRemovedObservable.notifyObservers(e), i && e.getChildMeshes().forEach(function(a) {
          r.removeMesh(a);
        }), o;
      }, t.prototype.addTransformNode = function(e) {
        this._blockEntityCollection || e.getScene() === this && e._indexInSceneTransformNodesArray !== -1 || (e._indexInSceneTransformNodesArray = this.transformNodes.length, this.transformNodes.push(e), e.parent || e._addToSceneRootNodes(), this.onNewTransformNodeAddedObservable.notifyObservers(e));
      }, t.prototype.removeTransformNode = function(e) {
        var i = e._indexInSceneTransformNodesArray;
        if (i !== -1) {
          if (i !== this.transformNodes.length - 1) {
            var r = this.transformNodes[this.transformNodes.length - 1];
            this.transformNodes[i] = r, r._indexInSceneTransformNodesArray = i;
          }
          e._indexInSceneTransformNodesArray = -1, this.transformNodes.pop(), e.parent || e._removeFromSceneRootNodes();
        }
        return this.onTransformNodeRemovedObservable.notifyObservers(e), i;
      }, t.prototype.removeSkeleton = function(e) {
        var i = this.skeletons.indexOf(e);
        return i !== -1 && (this.skeletons.splice(i, 1), this.onSkeletonRemovedObservable.notifyObservers(e), this._executeActiveContainerCleanup(this._activeSkeletons)), i;
      }, t.prototype.removeMorphTargetManager = function(e) {
        var i = this.morphTargetManagers.indexOf(e);
        return i !== -1 && this.morphTargetManagers.splice(i, 1), i;
      }, t.prototype.removeLight = function(e) {
        var i = this.lights.indexOf(e);
        if (i !== -1) {
          for (var r = 0, o = this.meshes; r < o.length; r++)
            o[r]._removeLightSource(e, !1);
          this.lights.splice(i, 1), this.sortLightsByPriority(), e.parent || e._removeFromSceneRootNodes();
        }
        return this.onLightRemovedObservable.notifyObservers(e), i;
      }, t.prototype.removeCamera = function(e) {
        var i = this.cameras.indexOf(e);
        if (i !== -1 && (this.cameras.splice(i, 1), e.parent || e._removeFromSceneRootNodes()), this.activeCameras) {
          var r = this.activeCameras.indexOf(e);
          r !== -1 && this.activeCameras.splice(r, 1);
        }
        return this.activeCamera === e && (this.cameras.length > 0 ? this.activeCamera = this.cameras[0] : this.activeCamera = null), this.onCameraRemovedObservable.notifyObservers(e), i;
      }, t.prototype.removeParticleSystem = function(e) {
        var i = this.particleSystems.indexOf(e);
        return i !== -1 && (this.particleSystems.splice(i, 1), this._executeActiveContainerCleanup(this._activeParticleSystems)), i;
      }, t.prototype.removeAnimation = function(e) {
        var i = this.animations.indexOf(e);
        return i !== -1 && this.animations.splice(i, 1), i;
      }, t.prototype.stopAnimation = function(e, i, r) {
      }, t.prototype.removeAnimationGroup = function(e) {
        var i = this.animationGroups.indexOf(e);
        return i !== -1 && this.animationGroups.splice(i, 1), i;
      }, t.prototype.removeMultiMaterial = function(e) {
        var i = this.multiMaterials.indexOf(e);
        return i !== -1 && this.multiMaterials.splice(i, 1), this.onMultiMaterialRemovedObservable.notifyObservers(e), i;
      }, t.prototype.removeMaterial = function(e) {
        var i = e._indexInSceneMaterialArray;
        if (i !== -1 && i < this.materials.length) {
          if (i !== this.materials.length - 1) {
            var r = this.materials[this.materials.length - 1];
            this.materials[i] = r, r._indexInSceneMaterialArray = i;
          }
          e._indexInSceneMaterialArray = -1, this.materials.pop();
        }
        return this.onMaterialRemovedObservable.notifyObservers(e), i;
      }, t.prototype.removeActionManager = function(e) {
        var i = this.actionManagers.indexOf(e);
        return i !== -1 && this.actionManagers.splice(i, 1), i;
      }, t.prototype.removeTexture = function(e) {
        var i = this.textures.indexOf(e);
        return i !== -1 && this.textures.splice(i, 1), this.onTextureRemovedObservable.notifyObservers(e), i;
      }, t.prototype.addLight = function(e) {
        if (!this._blockEntityCollection) {
          this.lights.push(e), this.sortLightsByPriority(), e.parent || e._addToSceneRootNodes();
          for (var i = 0, r = this.meshes; i < r.length; i++) {
            var o = r[i];
            o.lightSources.indexOf(e) === -1 && (o.lightSources.push(e), o._resyncLightSources());
          }
          this.onNewLightAddedObservable.notifyObservers(e);
        }
      }, t.prototype.sortLightsByPriority = function() {
        this.requireLightSorting && this.lights.sort(nn.CompareLightsPriority);
      }, t.prototype.addCamera = function(e) {
        this._blockEntityCollection || (this.cameras.push(e), this.onNewCameraAddedObservable.notifyObservers(e), e.parent || e._addToSceneRootNodes());
      }, t.prototype.addSkeleton = function(e) {
        this._blockEntityCollection || (this.skeletons.push(e), this.onNewSkeletonAddedObservable.notifyObservers(e));
      }, t.prototype.addParticleSystem = function(e) {
        this._blockEntityCollection || this.particleSystems.push(e);
      }, t.prototype.addAnimation = function(e) {
        this._blockEntityCollection || this.animations.push(e);
      }, t.prototype.addAnimationGroup = function(e) {
        this._blockEntityCollection || this.animationGroups.push(e);
      }, t.prototype.addMultiMaterial = function(e) {
        this._blockEntityCollection || (this.multiMaterials.push(e), this.onNewMultiMaterialAddedObservable.notifyObservers(e));
      }, t.prototype.addMaterial = function(e) {
        this._blockEntityCollection || e.getScene() === this && e._indexInSceneMaterialArray !== -1 || (e._indexInSceneMaterialArray = this.materials.length, this.materials.push(e), this.onNewMaterialAddedObservable.notifyObservers(e));
      }, t.prototype.addMorphTargetManager = function(e) {
        this._blockEntityCollection || this.morphTargetManagers.push(e);
      }, t.prototype.addGeometry = function(e) {
        this._blockEntityCollection || (this._geometriesByUniqueId && (this._geometriesByUniqueId[e.uniqueId] = this.geometries.length), this.geometries.push(e));
      }, t.prototype.addActionManager = function(e) {
        this.actionManagers.push(e);
      }, t.prototype.addTexture = function(e) {
        this._blockEntityCollection || (this.textures.push(e), this.onNewTextureAddedObservable.notifyObservers(e));
      }, t.prototype.switchActiveCamera = function(e, i) {
        i === void 0 && (i = !0), this._engine.getInputElement() && (this.activeCamera && this.activeCamera.detachControl(), this.activeCamera = e, i && e.attachControl());
      }, t.prototype.setActiveCameraById = function(e) {
        var i = this.getCameraById(e);
        return i ? (this.activeCamera = i, i) : null;
      }, t.prototype.setActiveCameraByName = function(e) {
        var i = this.getCameraByName(e);
        return i ? (this.activeCamera = i, i) : null;
      }, t.prototype.getAnimationGroupByName = function(e) {
        for (var i = 0; i < this.animationGroups.length; i++)
          if (this.animationGroups[i].name === e)
            return this.animationGroups[i];
        return null;
      }, t.prototype._getMaterial = function(e, i) {
        for (var r = 0; r < this.materials.length; r++)
          if (i(o = this.materials[r]))
            return o;
        if (e)
          for (r = 0; r < this.multiMaterials.length; r++) {
            var o;
            if (i(o = this.multiMaterials[r]))
              return o;
          }
        return null;
      }, t.prototype.getMaterialByUniqueID = function(e, i) {
        return i === void 0 && (i = !1), this._getMaterial(i, function(r) {
          return r.uniqueId === e;
        });
      }, t.prototype.getMaterialById = function(e, i) {
        return i === void 0 && (i = !1), this._getMaterial(i, function(r) {
          return r.id === e;
        });
      }, t.prototype.getMaterialByName = function(e, i) {
        return i === void 0 && (i = !1), this._getMaterial(i, function(r) {
          return r.name === e;
        });
      }, t.prototype.getLastMaterialById = function(e, i) {
        i === void 0 && (i = !1);
        for (var r = this.materials.length - 1; r >= 0; r--)
          if (this.materials[r].id === e)
            return this.materials[r];
        if (i) {
          for (r = this.multiMaterials.length - 1; r >= 0; r--)
            if (this.multiMaterials[r].id === e)
              return this.multiMaterials[r];
        }
        return null;
      }, t.prototype.getTextureByUniqueId = function(e) {
        for (var i = 0; i < this.textures.length; i++)
          if (this.textures[i].uniqueId === e)
            return this.textures[i];
        return null;
      }, t.prototype.getTextureByName = function(e) {
        for (var i = 0; i < this.textures.length; i++)
          if (this.textures[i].name === e)
            return this.textures[i];
        return null;
      }, t.prototype.getCameraById = function(e) {
        for (var i = 0; i < this.cameras.length; i++)
          if (this.cameras[i].id === e)
            return this.cameras[i];
        return null;
      }, t.prototype.getCameraByUniqueId = function(e) {
        for (var i = 0; i < this.cameras.length; i++)
          if (this.cameras[i].uniqueId === e)
            return this.cameras[i];
        return null;
      }, t.prototype.getCameraByName = function(e) {
        for (var i = 0; i < this.cameras.length; i++)
          if (this.cameras[i].name === e)
            return this.cameras[i];
        return null;
      }, t.prototype.getBoneById = function(e) {
        for (var i = 0; i < this.skeletons.length; i++)
          for (var r = this.skeletons[i], o = 0; o < r.bones.length; o++)
            if (r.bones[o].id === e)
              return r.bones[o];
        return null;
      }, t.prototype.getBoneByName = function(e) {
        for (var i = 0; i < this.skeletons.length; i++)
          for (var r = this.skeletons[i], o = 0; o < r.bones.length; o++)
            if (r.bones[o].name === e)
              return r.bones[o];
        return null;
      }, t.prototype.getLightByName = function(e) {
        for (var i = 0; i < this.lights.length; i++)
          if (this.lights[i].name === e)
            return this.lights[i];
        return null;
      }, t.prototype.getLightById = function(e) {
        for (var i = 0; i < this.lights.length; i++)
          if (this.lights[i].id === e)
            return this.lights[i];
        return null;
      }, t.prototype.getLightByUniqueId = function(e) {
        for (var i = 0; i < this.lights.length; i++)
          if (this.lights[i].uniqueId === e)
            return this.lights[i];
        return null;
      }, t.prototype.getParticleSystemById = function(e) {
        for (var i = 0; i < this.particleSystems.length; i++)
          if (this.particleSystems[i].id === e)
            return this.particleSystems[i];
        return null;
      }, t.prototype.getGeometryById = function(e) {
        for (var i = 0; i < this.geometries.length; i++)
          if (this.geometries[i].id === e)
            return this.geometries[i];
        return null;
      }, t.prototype._getGeometryByUniqueId = function(e) {
        if (this._geometriesByUniqueId) {
          if ((i = this._geometriesByUniqueId[e]) !== void 0)
            return this.geometries[i];
        } else
          for (var i = 0; i < this.geometries.length; i++)
            if (this.geometries[i].uniqueId === e)
              return this.geometries[i];
        return null;
      }, t.prototype.pushGeometry = function(e, i) {
        return !(!i && this._getGeometryByUniqueId(e.uniqueId) || (this.addGeometry(e), this.onNewGeometryAddedObservable.notifyObservers(e), 0));
      }, t.prototype.removeGeometry = function(e) {
        var i;
        if (this._geometriesByUniqueId) {
          if ((i = this._geometriesByUniqueId[e.uniqueId]) === void 0)
            return !1;
        } else if ((i = this.geometries.indexOf(e)) < 0)
          return !1;
        if (i !== this.geometries.length - 1) {
          var r = this.geometries[this.geometries.length - 1];
          r && (this.geometries[i] = r, this._geometriesByUniqueId && (this._geometriesByUniqueId[r.uniqueId] = i));
        }
        return this._geometriesByUniqueId && (this._geometriesByUniqueId[e.uniqueId] = void 0), this.geometries.pop(), this.onGeometryRemovedObservable.notifyObservers(e), !0;
      }, t.prototype.getGeometries = function() {
        return this.geometries;
      }, t.prototype.getMeshById = function(e) {
        for (var i = 0; i < this.meshes.length; i++)
          if (this.meshes[i].id === e)
            return this.meshes[i];
        return null;
      }, t.prototype.getMeshesById = function(e) {
        return this.meshes.filter(function(i) {
          return i.id === e;
        });
      }, t.prototype.getTransformNodeById = function(e) {
        for (var i = 0; i < this.transformNodes.length; i++)
          if (this.transformNodes[i].id === e)
            return this.transformNodes[i];
        return null;
      }, t.prototype.getTransformNodeByUniqueId = function(e) {
        for (var i = 0; i < this.transformNodes.length; i++)
          if (this.transformNodes[i].uniqueId === e)
            return this.transformNodes[i];
        return null;
      }, t.prototype.getTransformNodesById = function(e) {
        return this.transformNodes.filter(function(i) {
          return i.id === e;
        });
      }, t.prototype.getMeshByUniqueId = function(e) {
        for (var i = 0; i < this.meshes.length; i++)
          if (this.meshes[i].uniqueId === e)
            return this.meshes[i];
        return null;
      }, t.prototype.getLastMeshById = function(e) {
        for (var i = this.meshes.length - 1; i >= 0; i--)
          if (this.meshes[i].id === e)
            return this.meshes[i];
        return null;
      }, t.prototype.getLastTransformNodeById = function(e) {
        for (var i = this.transformNodes.length - 1; i >= 0; i--)
          if (this.transformNodes[i].id === e)
            return this.transformNodes[i];
        return null;
      }, t.prototype.getLastEntryById = function(e) {
        var i;
        for (i = this.meshes.length - 1; i >= 0; i--)
          if (this.meshes[i].id === e)
            return this.meshes[i];
        for (i = this.transformNodes.length - 1; i >= 0; i--)
          if (this.transformNodes[i].id === e)
            return this.transformNodes[i];
        for (i = this.cameras.length - 1; i >= 0; i--)
          if (this.cameras[i].id === e)
            return this.cameras[i];
        for (i = this.lights.length - 1; i >= 0; i--)
          if (this.lights[i].id === e)
            return this.lights[i];
        return null;
      }, t.prototype.getNodeById = function(e) {
        var i = this.getMeshById(e);
        if (i)
          return i;
        var r = this.getTransformNodeById(e);
        if (r)
          return r;
        var o = this.getLightById(e);
        if (o)
          return o;
        var a = this.getCameraById(e);
        return a || this.getBoneById(e) || null;
      }, t.prototype.getNodeByName = function(e) {
        var i = this.getMeshByName(e);
        if (i)
          return i;
        var r = this.getTransformNodeByName(e);
        if (r)
          return r;
        var o = this.getLightByName(e);
        if (o)
          return o;
        var a = this.getCameraByName(e);
        return a || this.getBoneByName(e) || null;
      }, t.prototype.getMeshByName = function(e) {
        for (var i = 0; i < this.meshes.length; i++)
          if (this.meshes[i].name === e)
            return this.meshes[i];
        return null;
      }, t.prototype.getTransformNodeByName = function(e) {
        for (var i = 0; i < this.transformNodes.length; i++)
          if (this.transformNodes[i].name === e)
            return this.transformNodes[i];
        return null;
      }, t.prototype.getLastSkeletonById = function(e) {
        for (var i = this.skeletons.length - 1; i >= 0; i--)
          if (this.skeletons[i].id === e)
            return this.skeletons[i];
        return null;
      }, t.prototype.getSkeletonByUniqueId = function(e) {
        for (var i = 0; i < this.skeletons.length; i++)
          if (this.skeletons[i].uniqueId === e)
            return this.skeletons[i];
        return null;
      }, t.prototype.getSkeletonById = function(e) {
        for (var i = 0; i < this.skeletons.length; i++)
          if (this.skeletons[i].id === e)
            return this.skeletons[i];
        return null;
      }, t.prototype.getSkeletonByName = function(e) {
        for (var i = 0; i < this.skeletons.length; i++)
          if (this.skeletons[i].name === e)
            return this.skeletons[i];
        return null;
      }, t.prototype.getMorphTargetManagerById = function(e) {
        for (var i = 0; i < this.morphTargetManagers.length; i++)
          if (this.morphTargetManagers[i].uniqueId === e)
            return this.morphTargetManagers[i];
        return null;
      }, t.prototype.getMorphTargetById = function(e) {
        for (var i = 0; i < this.morphTargetManagers.length; ++i)
          for (var r = this.morphTargetManagers[i], o = 0; o < r.numTargets; ++o) {
            var a = r.getTarget(o);
            if (a.id === e)
              return a;
          }
        return null;
      }, t.prototype.getMorphTargetByName = function(e) {
        for (var i = 0; i < this.morphTargetManagers.length; ++i)
          for (var r = this.morphTargetManagers[i], o = 0; o < r.numTargets; ++o) {
            var a = r.getTarget(o);
            if (a.name === e)
              return a;
          }
        return null;
      }, t.prototype.getPostProcessByName = function(e) {
        for (var i = 0; i < this.postProcesses.length; ++i) {
          var r = this.postProcesses[i];
          if (r.name === e)
            return r;
        }
        return null;
      }, t.prototype.isActiveMesh = function(e) {
        return this._activeMeshes.indexOf(e) !== -1;
      }, Object.defineProperty(t.prototype, "uid", { get: function() {
        return this._uid || (this._uid = de.RandomId()), this._uid;
      }, enumerable: !1, configurable: !0 }), t.prototype.addExternalData = function(e, i) {
        return this._externalData || (this._externalData = new ku()), this._externalData.add(e, i);
      }, t.prototype.getExternalData = function(e) {
        return this._externalData ? this._externalData.get(e) : null;
      }, t.prototype.getOrAddExternalDataWithFactory = function(e, i) {
        return this._externalData || (this._externalData = new ku()), this._externalData.getOrAddWithFactory(e, i);
      }, t.prototype.removeExternalData = function(e) {
        return this._externalData.remove(e);
      }, t.prototype._evaluateSubMesh = function(e, i, r, o) {
        if (o || e.isInFrustum(this._frustumPlanes)) {
          for (var a = 0, s = this._evaluateSubMeshStage; a < s.length; a++)
            s[a].action(i, e);
          var l = e.getMaterial();
          l != null && (l.hasRenderTargetTextures && l.getRenderTargetTextures != null && this._processedMaterials.indexOf(l) === -1 && (this._processedMaterials.push(l), this._materialsRenderTargets.concatWithNoDuplicate(l.getRenderTargetTextures())), this._renderingManager.dispatch(e, i, l));
        }
      }, t.prototype.freeProcessedMaterials = function() {
        this._processedMaterials.dispose();
      }, Object.defineProperty(t.prototype, "blockfreeActiveMeshesAndRenderingGroups", { get: function() {
        return this._preventFreeActiveMeshesAndRenderingGroups;
      }, set: function(e) {
        this._preventFreeActiveMeshesAndRenderingGroups !== e && (e && (this.freeActiveMeshes(), this.freeRenderingGroups()), this._preventFreeActiveMeshesAndRenderingGroups = e);
      }, enumerable: !1, configurable: !0 }), t.prototype.freeActiveMeshes = function() {
        if (!this.blockfreeActiveMeshesAndRenderingGroups && (this._activeMeshes.dispose(), this.activeCamera && this.activeCamera._activeMeshes && this.activeCamera._activeMeshes.dispose(), this.activeCameras))
          for (var e = 0; e < this.activeCameras.length; e++) {
            var i = this.activeCameras[e];
            i && i._activeMeshes && i._activeMeshes.dispose();
          }
      }, t.prototype.freeRenderingGroups = function() {
        if (!this.blockfreeActiveMeshesAndRenderingGroups && (this._renderingManager && this._renderingManager.freeRenderingGroups(), this.textures))
          for (var e = 0; e < this.textures.length; e++) {
            var i = this.textures[e];
            i && i.renderList && i.freeRenderingGroups();
          }
      }, t.prototype._isInIntermediateRendering = function() {
        return this._intermediateRendering;
      }, t.prototype.freezeActiveMeshes = function(e, i, r, o, a) {
        var s = this;
        return e === void 0 && (e = !1), o === void 0 && (o = !0), a === void 0 && (a = !1), this.executeWhenReady(function() {
          if (s.activeCamera) {
            if (s._frustumPlanes || s.updateTransformMatrix(), s._evaluateActiveMeshes(), s._activeMeshesFrozen = !0, s._activeMeshesFrozenButKeepClipping = a, s._skipEvaluateActiveMeshesCompletely = e, o)
              for (var l = 0; l < s._activeMeshes.length; l++)
                s._activeMeshes.data[l]._freeze();
            i && i();
          } else
            r && r("No active camera found");
        }), this;
      }, t.prototype.unfreezeActiveMeshes = function() {
        for (var e = 0; e < this.meshes.length; e++) {
          var i = this.meshes[e];
          i._internalAbstractMeshDataInfo && (i._internalAbstractMeshDataInfo._isActive = !1);
        }
        for (e = 0; e < this._activeMeshes.length; e++)
          this._activeMeshes.data[e]._unFreeze();
        return this._activeMeshesFrozen = !1, this;
      }, t.prototype._executeActiveContainerCleanup = function(e) {
        (!this._engine.snapshotRendering || this._engine.snapshotRenderingMode !== _.SNAPSHOTRENDERING_FAST) && this._activeMeshesFrozen && this._activeMeshes.length || this.onBeforeRenderObservable.addOnce(function() {
          return e.dispose();
        });
      }, t.prototype._evaluateActiveMeshes = function() {
        var e;
        if (this._engine.snapshotRendering && this._engine.snapshotRenderingMode === _.SNAPSHOTRENDERING_FAST)
          this._activeMeshes.length > 0 && ((e = this.activeCamera) === null || e === void 0 || e._activeMeshes.reset(), this._activeMeshes.reset(), this._renderingManager.reset(), this._processedMaterials.reset(), this._activeParticleSystems.reset(), this._activeSkeletons.reset(), this._softwareSkinnedMeshes.reset());
        else if (this._activeMeshesFrozen && this._activeMeshes.length) {
          if (!this._skipEvaluateActiveMeshesCompletely)
            for (var i = this._activeMeshes.length, r = 0; r < i; r++)
              (u = this._activeMeshes.data[r]).computeWorldMatrix();
          if (this._activeParticleSystems) {
            var o = this._activeParticleSystems.length;
            for (r = 0; r < o; r++)
              this._activeParticleSystems.data[r].animate();
          }
          this._renderingManager.resetSprites();
        } else if (this.activeCamera) {
          this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this), this.activeCamera._activeMeshes.reset(), this._activeMeshes.reset(), this._renderingManager.reset(), this._processedMaterials.reset(), this._activeParticleSystems.reset(), this._activeSkeletons.reset(), this._softwareSkinnedMeshes.reset(), this._materialsRenderTargets.reset();
          for (var a = 0, s = this._beforeEvaluateActiveMeshStage; a < s.length; a++)
            s[a].action();
          var l = this.getActiveMeshCandidates(), c = l.length;
          for (r = 0; r < c; r++) {
            var u;
            if ((u = l.data[r])._internalAbstractMeshDataInfo._currentLODIsUpToDate = !1, !u.isBlocked && (this._totalVertices.addCount(u.getTotalVertices(), !1), u.isReady() && u.isEnabled() && !u.scaling.hasAZeroComponent)) {
              u.computeWorldMatrix(), u.actionManager && u.actionManager.hasSpecificTriggers2(_.ACTION_OnIntersectionEnterTrigger, _.ACTION_OnIntersectionExitTrigger) && this._meshesForIntersections.pushNoDuplicate(u);
              var h = this.customLODSelector ? this.customLODSelector(u, this.activeCamera) : u.getLOD(this.activeCamera);
              if (u._internalAbstractMeshDataInfo._currentLOD = h, u._internalAbstractMeshDataInfo._currentLODIsUpToDate = !0, h != null && (h !== u && h.billboardMode !== 0 && h.computeWorldMatrix(), u._preActivate(), u.isVisible && u.visibility > 0 && (u.layerMask & this.activeCamera.layerMask) != 0 && (this._skipFrustumClipping || u.alwaysSelectAsActiveMesh || u.isInFrustum(this._frustumPlanes)))) {
                this._activeMeshes.push(u), this.activeCamera._activeMeshes.push(u), h !== u && h._activate(this._renderId, !1);
                for (var d = 0, p = this._preActiveMeshStage; d < p.length; d++)
                  p[d].action(u);
                u._activate(this._renderId, !1) && (u.isAnInstance ? u._internalAbstractMeshDataInfo._actAsRegularMesh && (h = u) : h._internalAbstractMeshDataInfo._onlyForInstances = !1, h._internalAbstractMeshDataInfo._isActive = !0, this._activeMesh(u, h)), u._postActivate();
              }
            }
          }
          if (this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this), this.particlesEnabled) {
            this.onBeforeParticlesRenderingObservable.notifyObservers(this);
            for (var f = 0; f < this.particleSystems.length; f++) {
              var m = this.particleSystems[f];
              if (m.isStarted() && m.emitter) {
                var g = m.emitter;
                g.position && !g.isEnabled() || (this._activeParticleSystems.push(m), m.animate(), this._renderingManager.dispatchParticles(m));
              }
            }
            this.onAfterParticlesRenderingObservable.notifyObservers(this);
          }
        }
      }, t.prototype._activeMesh = function(e, i) {
        this._skeletonsEnabled && i.skeleton !== null && i.skeleton !== void 0 && (this._activeSkeletons.pushNoDuplicate(i.skeleton) && (i.skeleton.prepare(), this._activeBones.addCount(i.skeleton.bones.length, !1)), i.computeBonesUsingShaders || this._softwareSkinnedMeshes.pushNoDuplicate(i));
        var r = e.hasInstances || e.isAnInstance || this.dispatchAllSubMeshesOfActiveMeshes || this._skipFrustumClipping || i.alwaysSelectAsActiveMesh;
        if (i && i.subMeshes && i.subMeshes.length > 0) {
          var o = this.getActiveSubMeshCandidates(i), a = o.length;
          r = r || a === 1;
          for (var s = 0; s < a; s++) {
            var l = o.data[s];
            this._evaluateSubMesh(l, i, e, r);
          }
        }
      }, t.prototype.updateTransformMatrix = function(e) {
        var i = this.activeCamera;
        if (i)
          if (i._renderingMultiview) {
            var r = i._rigCameras[0], o = i._rigCameras[1];
            this.setTransformMatrix(r.getViewMatrix(), r.getProjectionMatrix(e), o.getViewMatrix(), o.getProjectionMatrix(e));
          } else
            this.setTransformMatrix(i.getViewMatrix(), i.getProjectionMatrix(e));
      }, t.prototype._bindFrameBuffer = function(e, i) {
        i === void 0 && (i = !0), e && e._multiviewTexture ? e._multiviewTexture._bindFrameBuffer() : e && e.outputRenderTarget ? e.outputRenderTarget._bindFrameBuffer() : this._engine._currentFrameBufferIsDefaultFrameBuffer() || this._engine.restoreDefaultFramebuffer(), i && this._clearFrameBuffer(e);
      }, t.prototype._clearFrameBuffer = function(e) {
        if (!(e && e._multiviewTexture))
          if (e && e.outputRenderTarget && !e._renderingMultiview) {
            var i = e.outputRenderTarget;
            i.onClearObservable.hasObservers() ? i.onClearObservable.notifyObservers(this._engine) : i.skipInitialClear || (this.autoClear && this._engine.clear(i.clearColor || this.clearColor, !i._cleared, !0, !0), i._cleared = !0);
          } else
            this._defaultFrameBufferCleared ? this._engine.clear(null, !1, !0, !0) : (this._defaultFrameBufferCleared = !0, this._clear());
      }, t.prototype._renderForCamera = function(e, i, r) {
        var o, a, s;
        if (r === void 0 && (r = !0), !e || !e._skipRendering) {
          var l = this._engine;
          if (this._activeCamera = e, !this.activeCamera)
            throw new Error("Active camera not set");
          if (l.setViewport(this.activeCamera.viewport), this.resetCachedMaterial(), this._renderId++, !this.prePass && r) {
            var c = !0;
            e._renderingMultiview && e.outputRenderTarget && (c = e.outputRenderTarget.skipInitialClear, this.autoClear && (this._defaultFrameBufferCleared = !1, e.outputRenderTarget.skipInitialClear = !1)), this._bindFrameBuffer(this._activeCamera), e._renderingMultiview && e.outputRenderTarget && (e.outputRenderTarget.skipInitialClear = c);
          }
          this.updateTransformMatrix(), this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera), this._evaluateActiveMeshes();
          for (var u = 0; u < this._softwareSkinnedMeshes.length; u++) {
            var h = this._softwareSkinnedMeshes.data[u];
            h.applySkeleton(h.skeleton);
          }
          this.onBeforeRenderTargetsRenderObservable.notifyObservers(this), this._renderTargets.concatWithNoDuplicate(this._materialsRenderTargets), e.customRenderTargets && e.customRenderTargets.length > 0 && this._renderTargets.concatWithNoDuplicate(e.customRenderTargets), i && i.customRenderTargets && i.customRenderTargets.length > 0 && this._renderTargets.concatWithNoDuplicate(i.customRenderTargets), this.environmentTexture && this.environmentTexture.isRenderTarget && this._renderTargets.pushNoDuplicate(this.environmentTexture);
          for (var d = 0, p = this._gatherActiveCameraRenderTargetsStage; d < p.length; d++)
            p[d].action(this._renderTargets);
          var f = !1;
          if (this.renderTargetsEnabled) {
            if (this._intermediateRendering = !0, this._renderTargets.length > 0) {
              de.StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
              for (var m = 0; m < this._renderTargets.length; m++) {
                var g = this._renderTargets.data[m];
                if (g._shouldRender()) {
                  this._renderId++;
                  var y = g.activeCamera && g.activeCamera !== this.activeCamera;
                  g.render(y, this.dumpNextRenderTargets), f = !0;
                }
              }
              de.EndPerformanceCounter("Render targets", this._renderTargets.length > 0), this._renderId++;
            }
            for (var b = 0, T = this._cameraDrawRenderTargetStage; b < T.length; b++)
              f = T[b].action(this.activeCamera) || f;
            this._intermediateRendering = !1;
          }
          this._engine.currentRenderPassId = (s = (a = (o = e.outputRenderTarget) === null || o === void 0 ? void 0 : o.renderPassId) !== null && a !== void 0 ? a : e.renderPassId) !== null && s !== void 0 ? s : _.RENDERPASS_MAIN, f && !this.prePass && this._bindFrameBuffer(this._activeCamera, !1), this.onAfterRenderTargetsRenderObservable.notifyObservers(this), !this.postProcessManager || e._multiviewTexture || this.prePass || this.postProcessManager._prepareFrame();
          for (var S = 0, E = this._beforeCameraDrawStage; S < E.length; S++)
            E[S].action(this.activeCamera);
          this.onBeforeDrawPhaseObservable.notifyObservers(this), l.snapshotRendering && l.snapshotRenderingMode === _.SNAPSHOTRENDERING_FAST && this.finalizeSceneUbo(), this._renderingManager.render(null, null, !0, !0), this.onAfterDrawPhaseObservable.notifyObservers(this);
          for (var A = 0, R = this._afterCameraDrawStage; A < R.length; A++)
            R[A].action(this.activeCamera);
          if (this.postProcessManager && !e._multiviewTexture) {
            var C = e.outputRenderTarget ? e.outputRenderTarget.renderTarget : void 0;
            this.postProcessManager._finalizeFrame(e.isIntermediate, C);
          }
          for (var L = 0, I = this._afterCameraPostProcessStage; L < I.length; L++)
            I[L].action(this.activeCamera);
          this._renderTargets.reset(), this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera);
        }
      }, t.prototype._processSubCameras = function(e, i) {
        if (i === void 0 && (i = !0), e.cameraRigMode === _.RIG_MODE_NONE || e._renderingMultiview)
          return e._renderingMultiview && !this._multiviewSceneUbo && this._createMultiviewUbo(), this._renderForCamera(e, void 0, i), void this.onAfterRenderCameraObservable.notifyObservers(e);
        if (e._useMultiviewToSingleView)
          this._renderMultiviewToSingleView(e);
        else {
          this.onBeforeCameraRenderObservable.notifyObservers(e);
          for (var r = 0; r < e._rigCameras.length; r++)
            this._renderForCamera(e._rigCameras[r], e);
        }
        this._activeCamera = e, this.updateTransformMatrix(), this.onAfterRenderCameraObservable.notifyObservers(e);
      }, t.prototype._checkIntersections = function() {
        for (var e = 0; e < this._meshesForIntersections.length; e++) {
          var i = this._meshesForIntersections.data[e];
          if (i.actionManager)
            for (var r = function(a) {
              var s = i.actionManager.actions[a];
              if (s.trigger === _.ACTION_OnIntersectionEnterTrigger || s.trigger === _.ACTION_OnIntersectionExitTrigger) {
                var l = s.getTriggerParameter(), c = l.mesh ? l.mesh : l, u = c.intersectsMesh(i, l.usePreciseIntersection), h = i._intersectionsInProgress.indexOf(c);
                u && h === -1 ? s.trigger === _.ACTION_OnIntersectionEnterTrigger ? (s._executeCurrent(mi.CreateNew(i, void 0, c)), i._intersectionsInProgress.push(c)) : s.trigger === _.ACTION_OnIntersectionExitTrigger && i._intersectionsInProgress.push(c) : !u && h > -1 && (s.trigger === _.ACTION_OnIntersectionExitTrigger && s._executeCurrent(mi.CreateNew(i, void 0, c)), i.actionManager.hasSpecificTrigger(_.ACTION_OnIntersectionExitTrigger, function(d) {
                  var p = d.mesh ? d.mesh : d;
                  return c === p;
                }) && s.trigger !== _.ACTION_OnIntersectionExitTrigger || i._intersectionsInProgress.splice(h, 1));
              }
            }, o = 0; i.actionManager && o < i.actionManager.actions.length; o++)
              r(o);
        }
      }, t.prototype._advancePhysicsEngineStep = function(e) {
      }, t.prototype._animate = function() {
      }, t.prototype.animate = function() {
        if (this._engine.isDeterministicLockStep()) {
          var e = Math.max(t.MinDeltaTime, Math.min(this._engine.getDeltaTime(), t.MaxDeltaTime)) + this._timeAccumulator, i = this._engine.getTimeStep(), r = 1e3 / i / 1e3, o = 0, a = this._engine.getLockstepMaxSteps(), s = Math.floor(e / i);
          for (s = Math.min(s, a); e > 0 && o < s; )
            this.onBeforeStepObservable.notifyObservers(this), this._animationRatio = i * r, this._animate(), this.onAfterAnimationsObservable.notifyObservers(this), this.physicsEnabled && this._advancePhysicsEngineStep(i), this.onAfterStepObservable.notifyObservers(this), this._currentStepId++, o++, e -= i;
          this._timeAccumulator = e < 0 ? 0 : e;
        } else
          e = this.useConstantAnimationDeltaTime ? 16 : Math.max(t.MinDeltaTime, Math.min(this._engine.getDeltaTime(), t.MaxDeltaTime)), this._animationRatio = 0.06 * e, this._animate(), this.onAfterAnimationsObservable.notifyObservers(this), this.physicsEnabled && this._advancePhysicsEngineStep(e);
      }, t.prototype._clear = function() {
        (this.autoClearDepthAndStencil || this.autoClear) && this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil);
      }, t.prototype._checkCameraRenderTarget = function(e) {
        var i;
        if (e != null && e.outputRenderTarget && !(e != null && e.isRigCamera) && (e.outputRenderTarget._cleared = !1), (i = e == null ? void 0 : e.rigCameras) === null || i === void 0 ? void 0 : i.length)
          for (var r = 0; r < e.rigCameras.length; ++r) {
            var o = e.rigCameras[r].outputRenderTarget;
            o && (o._cleared = !1);
          }
      }, t.prototype.resetDrawCache = function(e) {
        if (this.meshes)
          for (var i = 0, r = this.meshes; i < r.length; i++)
            r[i].resetDrawCache(e);
      }, t.prototype.render = function(e, i) {
        var r, o, a;
        if (e === void 0 && (e = !0), i === void 0 && (i = !1), !this.isDisposed) {
          this.onReadyObservable.hasObservers() && this._executeWhenReadyTimeoutId === null && this._checkIsReady(), this._frameId++, this._defaultFrameBufferCleared = !1, this._checkCameraRenderTarget(this.activeCamera), !((r = this.activeCameras) === null || r === void 0) && r.length && this.activeCameras.forEach(this._checkCameraRenderTarget), this._registerTransientComponents(), this._activeParticles.fetchNewFrame(), this._totalVertices.fetchNewFrame(), this._activeIndices.fetchNewFrame(), this._activeBones.fetchNewFrame(), this._meshesForIntersections.reset(), this.resetCachedMaterial(), this.onBeforeAnimationsObservable.notifyObservers(this), this.actionManager && this.actionManager.processTrigger(_.ACTION_OnEveryFrameTrigger), i || this.animate();
          for (var s = 0, l = this._beforeCameraUpdateStage; s < l.length; s++)
            l[s].action();
          if (e) {
            if (this.activeCameras && this.activeCameras.length > 0)
              for (var c = 0; c < this.activeCameras.length; c++) {
                var u = this.activeCameras[c];
                if (u.update(), u.cameraRigMode !== _.RIG_MODE_NONE)
                  for (var h = 0; h < u._rigCameras.length; h++)
                    u._rigCameras[h].update();
              }
            else if (this.activeCamera && (this.activeCamera.update(), this.activeCamera.cameraRigMode !== _.RIG_MODE_NONE))
              for (h = 0; h < this.activeCamera._rigCameras.length; h++)
                this.activeCamera._rigCameras[h].update();
          }
          this.onBeforeRenderObservable.notifyObservers(this);
          var d = this.getEngine();
          this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
          var p = !((o = this.activeCameras) === null || o === void 0) && o.length ? this.activeCameras[0] : this.activeCamera;
          if (this.renderTargetsEnabled) {
            de.StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0), this._intermediateRendering = !0;
            for (var f = 0; f < this.customRenderTargets.length; f++) {
              var m = this.customRenderTargets[f];
              if (m._shouldRender()) {
                if (this._renderId++, this.activeCamera = m.activeCamera || this.activeCamera, !this.activeCamera)
                  throw new Error("Active camera not set");
                d.setViewport(this.activeCamera.viewport), this.updateTransformMatrix(), m.render(p !== this.activeCamera, this.dumpNextRenderTargets);
              }
            }
            de.EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0), this._intermediateRendering = !1, this._renderId++;
          }
          this._engine.currentRenderPassId = (a = p == null ? void 0 : p.renderPassId) !== null && a !== void 0 ? a : _.RENDERPASS_MAIN, this.activeCamera = p, this._activeCamera && this._activeCamera.cameraRigMode !== _.RIG_MODE_CUSTOM && !this.prePass && this._bindFrameBuffer(this._activeCamera, !1), this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
          for (var g = 0, y = this._beforeClearStage; g < y.length; g++)
            y[g].action();
          this._clearFrameBuffer(this.activeCamera);
          for (var b = 0, T = this._gatherRenderTargetsStage; b < T.length; b++)
            T[b].action(this._renderTargets);
          if (this.activeCameras && this.activeCameras.length > 0)
            for (c = 0; c < this.activeCameras.length; c++)
              this._processSubCameras(this.activeCameras[c], c > 0);
          else {
            if (!this.activeCamera)
              throw new Error("No camera defined");
            this._processSubCameras(this.activeCamera, !!this.activeCamera.outputRenderTarget);
          }
          this._checkIntersections();
          for (var S = 0, E = this._afterRenderStage; S < E.length; S++)
            E[S].action();
          if (this.afterRender && this.afterRender(), this.onAfterRenderObservable.notifyObservers(this), this._toBeDisposed.length) {
            for (h = 0; h < this._toBeDisposed.length; h++) {
              var A = this._toBeDisposed[h];
              A && A.dispose();
            }
            this._toBeDisposed.length = 0;
          }
          this.dumpNextRenderTargets && (this.dumpNextRenderTargets = !1), this._activeBones.addCount(0, !0), this._activeIndices.addCount(0, !0), this._activeParticles.addCount(0, !0), this._engine.restoreDefaultFramebuffer();
        }
      }, t.prototype.freezeMaterials = function() {
        for (var e = 0; e < this.materials.length; e++)
          this.materials[e].freeze();
      }, t.prototype.unfreezeMaterials = function() {
        for (var e = 0; e < this.materials.length; e++)
          this.materials[e].unfreeze();
      }, t.prototype.dispose = function() {
        if (!this.isDisposed) {
          this.beforeRender = null, this.afterRender = null, this.metadata = null, this.skeletons.length = 0, this.morphTargetManagers.length = 0, this._transientComponents.length = 0, this._isReadyForMeshStage.clear(), this._beforeEvaluateActiveMeshStage.clear(), this._evaluateSubMeshStage.clear(), this._preActiveMeshStage.clear(), this._cameraDrawRenderTargetStage.clear(), this._beforeCameraDrawStage.clear(), this._beforeRenderTargetDrawStage.clear(), this._beforeRenderingGroupDrawStage.clear(), this._beforeRenderingMeshStage.clear(), this._afterRenderingMeshStage.clear(), this._afterRenderingGroupDrawStage.clear(), this._afterCameraDrawStage.clear(), this._afterRenderTargetDrawStage.clear(), this._afterRenderStage.clear(), this._beforeCameraUpdateStage.clear(), this._beforeClearStage.clear(), this._gatherRenderTargetsStage.clear(), this._gatherActiveCameraRenderTargetsStage.clear(), this._pointerMoveStage.clear(), this._pointerDownStage.clear(), this._pointerUpStage.clear(), this.importedMeshesFiles = [], this.stopAllAnimations && (this._activeAnimatables.forEach(function(s) {
            s.onAnimationEndObservable.clear(), s.onAnimationEnd = null;
          }), this.stopAllAnimations()), this.resetCachedMaterial(), this.activeCamera && (this.activeCamera._activeMeshes.dispose(), this.activeCamera = null), this.activeCameras = null, this._activeMeshes.dispose(), this._renderingManager.dispose(), this._processedMaterials.dispose(), this._activeParticleSystems.dispose(), this._activeSkeletons.dispose(), this._softwareSkinnedMeshes.dispose(), this._renderTargets.dispose(), this._materialsRenderTargets.dispose(), this._registeredForLateAnimationBindings.dispose(), this._meshesForIntersections.dispose(), this._toBeDisposed.length = 0;
          for (var e = 0, i = this._activeRequests.slice(); e < i.length; e++)
            i[e].abort();
          this._activeRequests.length = 0;
          try {
            this.onDisposeObservable.notifyObservers(this);
          } catch (s) {
            console.error("An error occurred while calling onDisposeObservable!", s);
          }
          if (this.detachControl(), this._engine.getInputElement())
            for (var r = 0; r < this.cameras.length; r++)
              this.cameras[r].detachControl();
          this._disposeList(this.animationGroups), this._disposeList(this.lights), this._disposeList(this.meshes, function(s) {
            return s.dispose(!0);
          }), this._disposeList(this.transformNodes, function(s) {
            return s.dispose(!0);
          });
          var o = this.cameras;
          this._disposeList(o), this._defaultMaterial && this._defaultMaterial.dispose(), this._disposeList(this.multiMaterials), this._disposeList(this.materials), this._disposeList(this.particleSystems), this._disposeList(this.postProcesses), this._disposeList(this.textures), this._disposeList(this.morphTargetManagers), this._sceneUbo.dispose(), this._multiviewSceneUbo && this._multiviewSceneUbo.dispose(), this.postProcessManager.dispose(), this._disposeList(this._components);
          var a = this._engine.scenes.indexOf(this);
          a > -1 && this._engine.scenes.splice(a, 1), Me._LastCreatedScene === this && (this._engine.scenes.length > 0 ? Me._LastCreatedScene = this._engine.scenes[this._engine.scenes.length - 1] : Me._LastCreatedScene = null), (a = this._engine._virtualScenes.indexOf(this)) > -1 && this._engine._virtualScenes.splice(a, 1), this._engine.wipeCaches(!0), this.onDisposeObservable.clear(), this.onBeforeRenderObservable.clear(), this.onAfterRenderObservable.clear(), this.onBeforeRenderTargetsRenderObservable.clear(), this.onAfterRenderTargetsRenderObservable.clear(), this.onAfterStepObservable.clear(), this.onBeforeStepObservable.clear(), this.onBeforeActiveMeshesEvaluationObservable.clear(), this.onAfterActiveMeshesEvaluationObservable.clear(), this.onBeforeParticlesRenderingObservable.clear(), this.onAfterParticlesRenderingObservable.clear(), this.onBeforeDrawPhaseObservable.clear(), this.onAfterDrawPhaseObservable.clear(), this.onBeforeAnimationsObservable.clear(), this.onAfterAnimationsObservable.clear(), this.onDataLoadedObservable.clear(), this.onBeforeRenderingGroupObservable.clear(), this.onAfterRenderingGroupObservable.clear(), this.onMeshImportedObservable.clear(), this.onBeforeCameraRenderObservable.clear(), this.onAfterCameraRenderObservable.clear(), this.onAfterRenderCameraObservable.clear(), this.onReadyObservable.clear(), this.onNewCameraAddedObservable.clear(), this.onCameraRemovedObservable.clear(), this.onNewLightAddedObservable.clear(), this.onLightRemovedObservable.clear(), this.onNewGeometryAddedObservable.clear(), this.onGeometryRemovedObservable.clear(), this.onNewTransformNodeAddedObservable.clear(), this.onTransformNodeRemovedObservable.clear(), this.onNewMeshAddedObservable.clear(), this.onMeshRemovedObservable.clear(), this.onNewSkeletonAddedObservable.clear(), this.onSkeletonRemovedObservable.clear(), this.onNewMaterialAddedObservable.clear(), this.onNewMultiMaterialAddedObservable.clear(), this.onMaterialRemovedObservable.clear(), this.onMultiMaterialRemovedObservable.clear(), this.onNewTextureAddedObservable.clear(), this.onTextureRemovedObservable.clear(), this.onPrePointerObservable.clear(), this.onPointerObservable.clear(), this.onPreKeyboardObservable.clear(), this.onKeyboardObservable.clear(), this.onActiveCameraChanged.clear(), this.onScenePerformancePriorityChangedObservable.clear(), this._isDisposed = !0;
        }
      }, t.prototype._disposeList = function(e, i) {
        i = i ?? function(a) {
          return a.dispose();
        };
        for (var r = 0, o = e.slice(0); r < o.length; r++)
          i(o[r]);
        e.length = 0;
      }, Object.defineProperty(t.prototype, "isDisposed", { get: function() {
        return this._isDisposed;
      }, enumerable: !1, configurable: !0 }), t.prototype.clearCachedVertexData = function() {
        for (var e = 0; e < this.meshes.length; e++) {
          var i = this.meshes[e].geometry;
          i && i.clearCachedData();
        }
      }, t.prototype.cleanCachedTextureBuffer = function() {
        for (var e = 0, i = this.textures; e < i.length; e++) {
          var r = i[e];
          r._buffer && (r._buffer = null);
        }
      }, t.prototype.getWorldExtends = function(e) {
        var i = new v(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), r = new v(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
        return e = e || function() {
          return !0;
        }, this.meshes.filter(e).forEach(function(o) {
          if (o.computeWorldMatrix(!0), o.subMeshes && o.subMeshes.length !== 0 && !o.infiniteDistance) {
            var a = o.getBoundingInfo(), s = a.boundingBox.minimumWorld, l = a.boundingBox.maximumWorld;
            v.CheckExtends(s, i, r), v.CheckExtends(l, i, r);
          }
        }), { min: i, max: r };
      }, t.prototype.createPickingRay = function(e, i, r, o, a) {
        throw et("Ray");
      }, t.prototype.createPickingRayToRef = function(e, i, r, o, a, s, l) {
        throw et("Ray");
      }, t.prototype.createPickingRayInCameraSpace = function(e, i, r) {
        throw et("Ray");
      }, t.prototype.createPickingRayInCameraSpaceToRef = function(e, i, r, o) {
        throw et("Ray");
      }, Object.defineProperty(t.prototype, "_pickingAvailable", { get: function() {
        return !1;
      }, enumerable: !1, configurable: !0 }), t.prototype.pick = function(e, i, r, o, a, s) {
        var l = et("Ray", !0);
        return l && q.Warn(l), new Ki();
      }, t.prototype.pickWithBoundingInfo = function(e, i, r, o, a) {
        var s = et("Ray", !0);
        return s && q.Warn(s), new Ki();
      }, t.prototype.pickWithRay = function(e, i, r, o) {
        throw et("Ray");
      }, t.prototype.multiPick = function(e, i, r, o, a) {
        throw et("Ray");
      }, t.prototype.multiPickWithRay = function(e, i, r) {
        throw et("Ray");
      }, t.prototype.setPointerOverMesh = function(e, i, r) {
        this._inputManager.setPointerOverMesh(e, i, r);
      }, t.prototype.getPointerOverMesh = function() {
        return this._inputManager.getPointerOverMesh();
      }, t.prototype._rebuildGeometries = function() {
        for (var e = 0, i = this.geometries; e < i.length; e++)
          i[e]._rebuild();
        for (var r = 0, o = this.meshes; r < o.length; r++)
          o[r]._rebuild();
        this.postProcessManager && this.postProcessManager._rebuild();
        for (var a = 0, s = this._components; a < s.length; a++)
          s[a].rebuild();
        for (var l = 0, c = this.particleSystems; l < c.length; l++)
          c[l].rebuild();
        if (this.spriteManagers)
          for (var u = 0, h = this.spriteManagers; u < h.length; u++)
            h[u].rebuild();
      }, t.prototype._rebuildTextures = function() {
        for (var e = 0, i = this.textures; e < i.length; e++)
          i[e]._rebuild();
        this.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag);
      }, t.prototype._getByTags = function(e, i, r) {
        if (i === void 0)
          return e;
        var o = [];
        for (var a in e) {
          var s = e[a];
          Xt && Xt.MatchesQuery(s, i) && (!r || r(s)) && o.push(s);
        }
        return o;
      }, t.prototype.getMeshesByTags = function(e, i) {
        return this._getByTags(this.meshes, e, i);
      }, t.prototype.getCamerasByTags = function(e, i) {
        return this._getByTags(this.cameras, e, i);
      }, t.prototype.getLightsByTags = function(e, i) {
        return this._getByTags(this.lights, e, i);
      }, t.prototype.getMaterialByTags = function(e, i) {
        return this._getByTags(this.materials, e, i).concat(this._getByTags(this.multiMaterials, e, i));
      }, t.prototype.getTransformNodesByTags = function(e, i) {
        return this._getByTags(this.transformNodes, e, i);
      }, t.prototype.setRenderingOrder = function(e, i, r, o) {
        i === void 0 && (i = null), r === void 0 && (r = null), o === void 0 && (o = null), this._renderingManager.setRenderingOrder(e, i, r, o);
      }, t.prototype.setRenderingAutoClearDepthStencil = function(e, i, r, o) {
        r === void 0 && (r = !0), o === void 0 && (o = !0), this._renderingManager.setRenderingAutoClearDepthStencil(e, i, r, o);
      }, t.prototype.getAutoClearDepthStencilSetup = function(e) {
        return this._renderingManager.getAutoClearDepthStencilSetup(e);
      }, t.prototype._forceBlockMaterialDirtyMechanism = function(e) {
        this._blockMaterialDirtyMechanism = e;
      }, Object.defineProperty(t.prototype, "blockMaterialDirtyMechanism", { get: function() {
        return this._blockMaterialDirtyMechanism;
      }, set: function(e) {
        this._blockMaterialDirtyMechanism !== e && (this._blockMaterialDirtyMechanism = e, e || this.markAllMaterialsAsDirty(_.MATERIAL_AllDirtyFlag));
      }, enumerable: !1, configurable: !0 }), t.prototype.markAllMaterialsAsDirty = function(e, i) {
        if (!this._blockMaterialDirtyMechanism)
          for (var r = 0, o = this.materials; r < o.length; r++) {
            var a = o[r];
            i && !i(a) || a.markAsDirty(e);
          }
      }, t.prototype._loadFile = function(e, i, r, o, a, s, l) {
        var c = this, u = na(e, i, r, o ? this.offlineProvider : void 0, a, s, l);
        return this._activeRequests.push(u), u.onCompleteObservable.add(function(h) {
          c._activeRequests.splice(c._activeRequests.indexOf(h), 1);
        }), u;
      }, t.prototype._loadFileAsync = function(e, i, r, o, a) {
        var s = this;
        return new Promise(function(l, c) {
          s._loadFile(e, function(u) {
            l(u);
          }, i, r, o, function(u, h) {
            c(h);
          }, a);
        });
      }, t.prototype._requestFile = function(e, i, r, o, a, s, l) {
        var c = this, u = Bu(e, i, r, o ? this.offlineProvider : void 0, a, s, l);
        return this._activeRequests.push(u), u.onCompleteObservable.add(function(h) {
          c._activeRequests.splice(c._activeRequests.indexOf(h), 1);
        }), u;
      }, t.prototype._requestFileAsync = function(e, i, r, o, a) {
        var s = this;
        return new Promise(function(l, c) {
          s._requestFile(e, function(u) {
            l(u);
          }, i, r, o, function(u) {
            c(u);
          }, a);
        });
      }, t.prototype._readFile = function(e, i, r, o, a) {
        var s = this, l = ol(e, i, r, o, a);
        return this._activeRequests.push(l), l.onCompleteObservable.add(function(c) {
          s._activeRequests.splice(s._activeRequests.indexOf(c), 1);
        }), l;
      }, t.prototype._readFileAsync = function(e, i, r) {
        var o = this;
        return new Promise(function(a, s) {
          o._readFile(e, function(l) {
            a(l);
          }, i, r, function(l) {
            s(l);
          });
        });
      }, t.prototype.getPerfCollector = function() {
        throw et("performanceViewerSceneExtension");
      }, t.prototype.setActiveCameraByID = function(e) {
        return this.setActiveCameraById(e);
      }, t.prototype.getMaterialByID = function(e) {
        return this.getMaterialById(e);
      }, t.prototype.getLastMaterialByID = function(e) {
        return this.getLastMaterialById(e);
      }, t.prototype.getTextureByUniqueID = function(e) {
        return this.getTextureByUniqueId(e);
      }, t.prototype.getCameraByID = function(e) {
        return this.getCameraById(e);
      }, t.prototype.getCameraByUniqueID = function(e) {
        return this.getCameraByUniqueId(e);
      }, t.prototype.getBoneByID = function(e) {
        return this.getBoneById(e);
      }, t.prototype.getLightByID = function(e) {
        return this.getLightById(e);
      }, t.prototype.getLightByUniqueID = function(e) {
        return this.getLightByUniqueId(e);
      }, t.prototype.getParticleSystemByID = function(e) {
        return this.getParticleSystemById(e);
      }, t.prototype.getGeometryByID = function(e) {
        return this.getGeometryById(e);
      }, t.prototype.getMeshByID = function(e) {
        return this.getMeshById(e);
      }, t.prototype.getMeshByUniqueID = function(e) {
        return this.getMeshByUniqueId(e);
      }, t.prototype.getLastMeshByID = function(e) {
        return this.getLastMeshById(e);
      }, t.prototype.getMeshesByID = function(e) {
        return this.getMeshesById(e);
      }, t.prototype.getTransformNodeByID = function(e) {
        return this.getTransformNodeById(e);
      }, t.prototype.getTransformNodeByUniqueID = function(e) {
        return this.getTransformNodeByUniqueId(e);
      }, t.prototype.getTransformNodesByID = function(e) {
        return this.getTransformNodesById(e);
      }, t.prototype.getNodeByID = function(e) {
        return this.getNodeById(e);
      }, t.prototype.getLastEntryByID = function(e) {
        return this.getLastEntryById(e);
      }, t.prototype.getLastSkeletonByID = function(e) {
        return this.getLastSkeletonById(e);
      }, t.FOGMODE_NONE = 0, t.FOGMODE_EXP = 1, t.FOGMODE_EXP2 = 2, t.FOGMODE_LINEAR = 3, t.MinDeltaTime = 1, t.MaxDeltaTime = 1e3, t;
    }(pe);
    (function(n) {
      n[n.LOCAL = 0] = "LOCAL", n[n.WORLD = 1] = "WORLD", n[n.BONE = 2] = "BONE";
    })(ht || (ht = {}));
    var Ua, qi = function() {
      function n() {
      }
      return n.X = new v(1, 0, 0), n.Y = new v(0, 1, 0), n.Z = new v(0, 0, 1), n;
    }();
    (function(n) {
      n[n.X = 0] = "X", n[n.Y = 1] = "Y", n[n.Z = 2] = "Z";
    })(Ua || (Ua = {}));
    var Wu = function(n) {
      function t(e, i, r, o, a, s, l) {
        r === void 0 && (r = null), o === void 0 && (o = null), a === void 0 && (a = null), s === void 0 && (s = null), l === void 0 && (l = null);
        var c, u = this;
        return (u = n.call(this, e, i.getScene()) || this).name = e, u.children = [], u.animations = [], u._index = null, u._scalingDeterminant = 1, u._needToDecompose = !0, u._needToCompose = !1, u._linkedTransformNode = null, u._waitingTransformNodeId = null, u._skeleton = i, u._localMatrix = (c = o == null ? void 0 : o.clone()) !== null && c !== void 0 ? c : B.Identity(), u._restMatrix = a ?? u._localMatrix.clone(), u._bindMatrix = s ?? u._localMatrix.clone(), u._index = l, u._absoluteMatrix = new B(), u._absoluteBindMatrix = new B(), u._absoluteInverseBindMatrix = new B(), u._finalMatrix = new B(), i.bones.push(u), u.setParent(r, !1), u._updateAbsoluteBindMatrices(), u;
      }
      return D(t, n), Object.defineProperty(t.prototype, "_matrix", { get: function() {
        return this._compose(), this._localMatrix;
      }, set: function(e) {
        (e.updateFlag !== this._localMatrix.updateFlag || this._needToCompose) && (this._needToCompose = !1, this._localMatrix.copyFrom(e), this._markAsDirtyAndDecompose());
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "Bone";
      }, t.prototype.getSkeleton = function() {
        return this._skeleton;
      }, Object.defineProperty(t.prototype, "parent", { get: function() {
        return this._parentNode;
      }, set: function(e) {
        this.setParent(e);
      }, enumerable: !1, configurable: !0 }), t.prototype.getParent = function() {
        return this.parent;
      }, t.prototype.getChildren = function() {
        return this.children;
      }, t.prototype.getIndex = function() {
        return this._index === null ? this.getSkeleton().bones.indexOf(this) : this._index;
      }, t.prototype.setParent = function(e, i) {
        if (i === void 0 && (i = !0), this.parent !== e) {
          if (this.parent) {
            var r = this.parent.children.indexOf(this);
            r !== -1 && this.parent.children.splice(r, 1);
          }
          this._parentNode = e, this.parent && this.parent.children.push(this), i && this._updateAbsoluteBindMatrices(), this.markAsDirty();
        }
      }, t.prototype.getLocalMatrix = function() {
        return this._compose(), this._localMatrix;
      }, t.prototype.getBindMatrix = function() {
        return this._bindMatrix;
      }, t.prototype.getBaseMatrix = function() {
        return this.getBindMatrix();
      }, t.prototype.getRestMatrix = function() {
        return this._restMatrix;
      }, t.prototype.getRestPose = function() {
        return this.getRestMatrix();
      }, t.prototype.setRestMatrix = function(e) {
        this._restMatrix.copyFrom(e);
      }, t.prototype.setRestPose = function(e) {
        this.setRestMatrix(e);
      }, t.prototype.getBindPose = function() {
        return this.getBindMatrix();
      }, t.prototype.setBindMatrix = function(e) {
        this.updateMatrix(e);
      }, t.prototype.setBindPose = function(e) {
        this.setBindMatrix(e);
      }, t.prototype.getFinalMatrix = function() {
        return this._finalMatrix;
      }, t.prototype.getWorldMatrix = function() {
        return this.getFinalMatrix();
      }, t.prototype.returnToRest = function() {
        var e;
        if (this._linkedTransformNode) {
          var i = F.Vector3[0], r = F.Quaternion[0], o = F.Vector3[1];
          this.getRestMatrix().decompose(i, r, o), this._linkedTransformNode.position.copyFrom(o), this._linkedTransformNode.rotationQuaternion = (e = this._linkedTransformNode.rotationQuaternion) !== null && e !== void 0 ? e : oe.Identity(), this._linkedTransformNode.rotationQuaternion.copyFrom(r), this._linkedTransformNode.scaling.copyFrom(i);
        } else
          this._matrix = this._restMatrix;
      }, t.prototype.getAbsoluteInverseBindMatrix = function() {
        return this._absoluteInverseBindMatrix;
      }, t.prototype.getInvertedAbsoluteTransform = function() {
        return this.getAbsoluteInverseBindMatrix();
      }, t.prototype.getAbsoluteMatrix = function() {
        return this._absoluteMatrix;
      }, t.prototype.getAbsoluteTransform = function() {
        return this._absoluteMatrix;
      }, t.prototype.linkTransformNode = function(e) {
        this._linkedTransformNode && this._skeleton._numBonesWithLinkedTransformNode--, this._linkedTransformNode = e, this._linkedTransformNode && this._skeleton._numBonesWithLinkedTransformNode++;
      }, t.prototype.getTransformNode = function() {
        return this._linkedTransformNode;
      }, Object.defineProperty(t.prototype, "position", { get: function() {
        return this._decompose(), this._localPosition;
      }, set: function(e) {
        this._decompose(), this._localPosition.copyFrom(e), this._markAsDirtyAndCompose();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rotation", { get: function() {
        return this.getRotation();
      }, set: function(e) {
        this.setRotation(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rotationQuaternion", { get: function() {
        return this._decompose(), this._localRotation;
      }, set: function(e) {
        this.setRotationQuaternion(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "scaling", { get: function() {
        return this.getScale();
      }, set: function(e) {
        this.setScale(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "animationPropertiesOverride", { get: function() {
        return this._skeleton.animationPropertiesOverride;
      }, enumerable: !1, configurable: !0 }), t.prototype._decompose = function() {
        this._needToDecompose && (this._needToDecompose = !1, this._localScaling || (this._localScaling = v.Zero(), this._localRotation = oe.Zero(), this._localPosition = v.Zero()), this._localMatrix.decompose(this._localScaling, this._localRotation, this._localPosition));
      }, t.prototype._compose = function() {
        this._needToCompose && (this._localScaling ? (this._needToCompose = !1, B.ComposeToRef(this._localScaling, this._localRotation, this._localPosition, this._localMatrix)) : this._needToCompose = !1);
      }, t.prototype.updateMatrix = function(e, i, r) {
        i === void 0 && (i = !0), r === void 0 && (r = !0), this._bindMatrix.copyFrom(e), i && this._updateAbsoluteBindMatrices(), r ? this._matrix = e : this.markAsDirty();
      }, t.prototype._updateAbsoluteBindMatrices = function(e, i) {
        if (i === void 0 && (i = !0), e || (e = this._bindMatrix), this.parent ? e.multiplyToRef(this.parent._absoluteBindMatrix, this._absoluteBindMatrix) : this._absoluteBindMatrix.copyFrom(e), this._absoluteBindMatrix.invertToRef(this._absoluteInverseBindMatrix), i)
          for (var r = 0; r < this.children.length; r++)
            this.children[r]._updateAbsoluteBindMatrices();
        this._scalingDeterminant = this._absoluteBindMatrix.determinant() < 0 ? -1 : 1;
      }, t.prototype.markAsDirty = function() {
        return this._currentRenderId++, this._childUpdateId++, this._skeleton._markAsDirty(), this;
      }, t.prototype._markAsDirtyAndCompose = function() {
        this.markAsDirty(), this._needToCompose = !0;
      }, t.prototype._markAsDirtyAndDecompose = function() {
        this.markAsDirty(), this._needToDecompose = !0;
      }, t.prototype._updatePosition = function(e, i, r, o) {
        i === void 0 && (i = ht.LOCAL), o === void 0 && (o = !0);
        var a = this.getLocalMatrix();
        if (i == ht.LOCAL)
          o ? (a.addAtIndex(12, e.x), a.addAtIndex(13, e.y), a.addAtIndex(14, e.z)) : a.setTranslationFromFloats(e.x, e.y, e.z);
        else {
          var s = null;
          r && (s = r.getWorldMatrix()), this._skeleton.computeAbsoluteMatrices();
          var l = t._TmpMats[0], c = t._TmpVecs[0];
          this.parent ? r && s ? (l.copyFrom(this.parent.getAbsoluteMatrix()), l.multiplyToRef(s, l)) : l.copyFrom(this.parent.getAbsoluteMatrix()) : B.IdentityToRef(l), o && l.setTranslationFromFloats(0, 0, 0), l.invert(), v.TransformCoordinatesToRef(e, l, c), o ? (a.addAtIndex(12, c.x), a.addAtIndex(13, c.y), a.addAtIndex(14, c.z)) : a.setTranslationFromFloats(c.x, c.y, c.z);
        }
        this._markAsDirtyAndDecompose();
      }, t.prototype.translate = function(e, i, r) {
        i === void 0 && (i = ht.LOCAL), this._updatePosition(e, i, r, !0);
      }, t.prototype.setPosition = function(e, i, r) {
        i === void 0 && (i = ht.LOCAL), this._updatePosition(e, i, r, !1);
      }, t.prototype.setAbsolutePosition = function(e, i) {
        this.setPosition(e, ht.WORLD, i);
      }, t.prototype.scale = function(e, i, r, o) {
        o === void 0 && (o = !1);
        var a = this.getLocalMatrix(), s = t._TmpMats[0];
        B.ScalingToRef(e, i, r, s), s.multiplyToRef(a, a), s.invert();
        for (var l = 0, c = this.children; l < c.length; l++) {
          var u = (p = c[l]).getLocalMatrix();
          u.multiplyToRef(s, u), u.multiplyAtIndex(12, e), u.multiplyAtIndex(13, i), u.multiplyAtIndex(14, r), p._markAsDirtyAndDecompose();
        }
        if (this._markAsDirtyAndDecompose(), o)
          for (var h = 0, d = this.children; h < d.length; h++) {
            var p;
            (p = d[h]).scale(e, i, r, o);
          }
      }, t.prototype.setScale = function(e) {
        this._decompose(), this._localScaling.copyFrom(e), this._markAsDirtyAndCompose();
      }, t.prototype.getScale = function() {
        return this._decompose(), this._localScaling;
      }, t.prototype.getScaleToRef = function(e) {
        this._decompose(), e.copyFrom(this._localScaling);
      }, t.prototype.setYawPitchRoll = function(e, i, r, o, a) {
        if (o === void 0 && (o = ht.LOCAL), o === ht.LOCAL) {
          var s = t._TmpQuat;
          return oe.RotationYawPitchRollToRef(e, i, r, s), void this.setRotationQuaternion(s, o, a);
        }
        var l = t._TmpMats[0];
        if (this._getAbsoluteInverseMatrixUnscaledToRef(l, a)) {
          var c = t._TmpMats[1];
          B.RotationYawPitchRollToRef(e, i, r, c), l.multiplyToRef(c, c), this._rotateWithMatrix(c, o, a);
        }
      }, t.prototype.rotate = function(e, i, r, o) {
        r === void 0 && (r = ht.LOCAL);
        var a = t._TmpMats[0];
        a.setTranslationFromFloats(0, 0, 0), B.RotationAxisToRef(e, i, a), this._rotateWithMatrix(a, r, o);
      }, t.prototype.setAxisAngle = function(e, i, r, o) {
        if (r === void 0 && (r = ht.LOCAL), r === ht.LOCAL) {
          var a = t._TmpQuat;
          return oe.RotationAxisToRef(e, i, a), void this.setRotationQuaternion(a, r, o);
        }
        var s = t._TmpMats[0];
        if (this._getAbsoluteInverseMatrixUnscaledToRef(s, o)) {
          var l = t._TmpMats[1];
          B.RotationAxisToRef(e, i, l), s.multiplyToRef(l, l), this._rotateWithMatrix(l, r, o);
        }
      }, t.prototype.setRotation = function(e, i, r) {
        i === void 0 && (i = ht.LOCAL), this.setYawPitchRoll(e.y, e.x, e.z, i, r);
      }, t.prototype.setRotationQuaternion = function(e, i, r) {
        if (i === void 0 && (i = ht.LOCAL), i === ht.LOCAL)
          return this._decompose(), this._localRotation.copyFrom(e), void this._markAsDirtyAndCompose();
        var o = t._TmpMats[0];
        if (this._getAbsoluteInverseMatrixUnscaledToRef(o, r)) {
          var a = t._TmpMats[1];
          B.FromQuaternionToRef(e, a), o.multiplyToRef(a, a), this._rotateWithMatrix(a, i, r);
        }
      }, t.prototype.setRotationMatrix = function(e, i, r) {
        if (i === void 0 && (i = ht.LOCAL), i === ht.LOCAL) {
          var o = t._TmpQuat;
          return oe.FromRotationMatrixToRef(e, o), void this.setRotationQuaternion(o, i, r);
        }
        var a = t._TmpMats[0];
        if (this._getAbsoluteInverseMatrixUnscaledToRef(a, r)) {
          var s = t._TmpMats[1];
          s.copyFrom(e), a.multiplyToRef(e, s), this._rotateWithMatrix(s, i, r);
        }
      }, t.prototype._rotateWithMatrix = function(e, i, r) {
        i === void 0 && (i = ht.LOCAL);
        var o = this.getLocalMatrix(), a = o.m[12], s = o.m[13], l = o.m[14], c = this.getParent(), u = t._TmpMats[3], h = t._TmpMats[4];
        c && i == ht.WORLD ? (r ? (u.copyFrom(r.getWorldMatrix()), c.getAbsoluteMatrix().multiplyToRef(u, u)) : u.copyFrom(c.getAbsoluteMatrix()), h.copyFrom(u), h.invert(), o.multiplyToRef(u, o), o.multiplyToRef(e, o), o.multiplyToRef(h, o)) : i == ht.WORLD && r ? (u.copyFrom(r.getWorldMatrix()), h.copyFrom(u), h.invert(), o.multiplyToRef(u, o), o.multiplyToRef(e, o), o.multiplyToRef(h, o)) : o.multiplyToRef(e, o), o.setTranslationFromFloats(a, s, l), this.computeAbsoluteMatrices(), this._markAsDirtyAndDecompose();
      }, t.prototype._getAbsoluteInverseMatrixUnscaledToRef = function(e, i) {
        var r = t._TmpMats[2];
        return e.copyFrom(this.getAbsoluteMatrix()), i ? (e.multiplyToRef(i.getWorldMatrix(), e), B.ScalingToRef(i.scaling.x, i.scaling.y, i.scaling.z, r)) : B.IdentityToRef(r), e.invert(), !isNaN(e.m[0]) && (r.multiplyAtIndex(0, this._scalingDeterminant), e.multiplyToRef(r, e), !0);
      }, t.prototype.getPosition = function(e, i) {
        e === void 0 && (e = ht.LOCAL), i === void 0 && (i = null);
        var r = v.Zero();
        return this.getPositionToRef(e, i, r), r;
      }, t.prototype.getPositionToRef = function(e, i, r) {
        if (e === void 0 && (e = ht.LOCAL), e == ht.LOCAL) {
          var o = this.getLocalMatrix();
          r.x = o.m[12], r.y = o.m[13], r.z = o.m[14];
        } else {
          var a = null;
          i && (a = i.getWorldMatrix()), this._skeleton.computeAbsoluteMatrices();
          var s = t._TmpMats[0];
          i && a ? (s.copyFrom(this.getAbsoluteMatrix()), s.multiplyToRef(a, s)) : s = this.getAbsoluteMatrix(), r.x = s.m[12], r.y = s.m[13], r.z = s.m[14];
        }
      }, t.prototype.getAbsolutePosition = function(e) {
        e === void 0 && (e = null);
        var i = v.Zero();
        return this.getPositionToRef(ht.WORLD, e, i), i;
      }, t.prototype.getAbsolutePositionToRef = function(e, i) {
        this.getPositionToRef(ht.WORLD, e, i);
      }, t.prototype.computeAbsoluteMatrices = function() {
        if (this._compose(), this.parent)
          this._localMatrix.multiplyToRef(this.parent._absoluteMatrix, this._absoluteMatrix);
        else {
          this._absoluteMatrix.copyFrom(this._localMatrix);
          var e = this._skeleton.getPoseMatrix();
          e && this._absoluteMatrix.multiplyToRef(e, this._absoluteMatrix);
        }
        for (var i = this.children, r = i.length, o = 0; o < r; o++)
          i[o].computeAbsoluteMatrices();
      }, t.prototype.computeAbsoluteTransforms = function() {
        this.computeAbsoluteMatrices();
      }, t.prototype.getDirection = function(e, i) {
        i === void 0 && (i = null);
        var r = v.Zero();
        return this.getDirectionToRef(e, i, r), r;
      }, t.prototype.getDirectionToRef = function(e, i, r) {
        i === void 0 && (i = null);
        var o = null;
        i && (o = i.getWorldMatrix()), this._skeleton.computeAbsoluteMatrices();
        var a = t._TmpMats[0];
        a.copyFrom(this.getAbsoluteMatrix()), i && o && a.multiplyToRef(o, a), v.TransformNormalToRef(e, a, r), r.normalize();
      }, t.prototype.getRotation = function(e, i) {
        e === void 0 && (e = ht.LOCAL), i === void 0 && (i = null);
        var r = v.Zero();
        return this.getRotationToRef(e, i, r), r;
      }, t.prototype.getRotationToRef = function(e, i, r) {
        e === void 0 && (e = ht.LOCAL), i === void 0 && (i = null);
        var o = t._TmpQuat;
        this.getRotationQuaternionToRef(e, i, o), o.toEulerAnglesToRef(r);
      }, t.prototype.getRotationQuaternion = function(e, i) {
        e === void 0 && (e = ht.LOCAL), i === void 0 && (i = null);
        var r = oe.Identity();
        return this.getRotationQuaternionToRef(e, i, r), r;
      }, t.prototype.getRotationQuaternionToRef = function(e, i, r) {
        if (e === void 0 && (e = ht.LOCAL), i === void 0 && (i = null), e == ht.LOCAL)
          this._decompose(), r.copyFrom(this._localRotation);
        else {
          var o = t._TmpMats[0], a = this.getAbsoluteMatrix();
          i ? a.multiplyToRef(i.getWorldMatrix(), o) : o.copyFrom(a), o.multiplyAtIndex(0, this._scalingDeterminant), o.multiplyAtIndex(1, this._scalingDeterminant), o.multiplyAtIndex(2, this._scalingDeterminant), o.decompose(void 0, r, void 0);
        }
      }, t.prototype.getRotationMatrix = function(e, i) {
        e === void 0 && (e = ht.LOCAL);
        var r = B.Identity();
        return this.getRotationMatrixToRef(e, i, r), r;
      }, t.prototype.getRotationMatrixToRef = function(e, i, r) {
        if (e === void 0 && (e = ht.LOCAL), e == ht.LOCAL)
          this.getLocalMatrix().getRotationMatrixToRef(r);
        else {
          var o = t._TmpMats[0], a = this.getAbsoluteMatrix();
          i ? a.multiplyToRef(i.getWorldMatrix(), o) : o.copyFrom(a), o.multiplyAtIndex(0, this._scalingDeterminant), o.multiplyAtIndex(1, this._scalingDeterminant), o.multiplyAtIndex(2, this._scalingDeterminant), o.getRotationMatrixToRef(r);
        }
      }, t.prototype.getAbsolutePositionFromLocal = function(e, i) {
        i === void 0 && (i = null);
        var r = v.Zero();
        return this.getAbsolutePositionFromLocalToRef(e, i, r), r;
      }, t.prototype.getAbsolutePositionFromLocalToRef = function(e, i, r) {
        i === void 0 && (i = null);
        var o = null;
        i && (o = i.getWorldMatrix()), this._skeleton.computeAbsoluteMatrices();
        var a = t._TmpMats[0];
        a.copyFrom(this.getAbsoluteMatrix()), i && o && a.multiplyToRef(o, a), v.TransformCoordinatesToRef(e, a, r);
      }, t.prototype.getLocalPositionFromAbsolute = function(e, i) {
        i === void 0 && (i = null);
        var r = v.Zero();
        return this.getLocalPositionFromAbsoluteToRef(e, i, r), r;
      }, t.prototype.getLocalPositionFromAbsoluteToRef = function(e, i, r) {
        i === void 0 && (i = null);
        var o = null;
        i && (o = i.getWorldMatrix()), this._skeleton.computeAbsoluteMatrices();
        var a = t._TmpMats[0];
        a.copyFrom(this.getAbsoluteMatrix()), i && o && a.multiplyToRef(o, a), a.invert(), v.TransformCoordinatesToRef(e, a, r);
      }, t.prototype.setCurrentPoseAsRest = function() {
        this.setRestMatrix(this.getLocalMatrix());
      }, t._TmpVecs = pt.BuildArray(2, v.Zero), t._TmpQuat = oe.Identity(), t._TmpMats = pt.BuildArray(5, B.Identity), t;
    }(oi), Tp = function() {
      function n(t, e, i, r, o, a, s, l, c, u, h) {
        i === void 0 && (i = 0), r === void 0 && (r = 100), o === void 0 && (o = !1), a === void 0 && (a = 1), u === void 0 && (u = !1), h === void 0 && (h = 0), this.target = e, this.fromFrame = i, this.toFrame = r, this.loopAnimation = o, this.onAnimationEnd = s, this.onAnimationLoop = c, this.isAdditive = u, this.playOrder = h, this._localDelayOffset = null, this._pausedDelay = null, this._manualJumpDelay = null, this._runtimeAnimations = new Array(), this._paused = !1, this._speedRatio = 1, this._weight = -1, this._syncRoot = null, this._frameToSyncFromJump = null, this._goToFrame = null, this.disposeOnEnd = !0, this.animationStarted = !1, this.onAnimationEndObservable = new H(), this.onAnimationLoopObservable = new H(), this._scene = t, l && this.appendAnimations(e, l), this._speedRatio = a, t._activeAnimatables.push(this);
      }
      return Object.defineProperty(n.prototype, "syncRoot", { get: function() {
        return this._syncRoot;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "masterFrame", { get: function() {
        return this._runtimeAnimations.length === 0 ? 0 : this._runtimeAnimations[0].currentFrame;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "weight", { get: function() {
        return this._weight;
      }, set: function(t) {
        this._weight = t !== -1 ? Math.min(Math.max(t, 0), 1) : -1;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "speedRatio", { get: function() {
        return this._speedRatio;
      }, set: function(t) {
        for (var e = 0; e < this._runtimeAnimations.length; e++)
          this._runtimeAnimations[e]._prepareForSpeedRatioChange(t);
        this._speedRatio = t, this._goToFrame !== null && this.goToFrame(this._goToFrame);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "elapsedTime", { get: function() {
        return this._localDelayOffset === null ? 0 : this._scene._animationTime - this._localDelayOffset;
      }, enumerable: !1, configurable: !0 }), n.prototype.syncWith = function(t) {
        if (this._syncRoot = t, t) {
          var e = this._scene._activeAnimatables.indexOf(this);
          e > -1 && (this._scene._activeAnimatables.splice(e, 1), this._scene._activeAnimatables.push(this));
        }
        return this;
      }, n.prototype.getAnimations = function() {
        return this._runtimeAnimations;
      }, n.prototype.appendAnimations = function(t, e) {
        for (var i = this, r = 0; r < e.length; r++) {
          var o = e[r], a = new zm(t, o, this._scene, this);
          a._onLoop = function() {
            i.onAnimationLoopObservable.notifyObservers(i), i.onAnimationLoop && i.onAnimationLoop();
          }, this._runtimeAnimations.push(a);
        }
      }, n.prototype.getAnimationByTargetProperty = function(t) {
        for (var e = this._runtimeAnimations, i = 0; i < e.length; i++)
          if (e[i].animation.targetProperty === t)
            return e[i].animation;
        return null;
      }, n.prototype.getRuntimeAnimationByTargetProperty = function(t) {
        for (var e = this._runtimeAnimations, i = 0; i < e.length; i++)
          if (e[i].animation.targetProperty === t)
            return e[i];
        return null;
      }, n.prototype.reset = function() {
        for (var t = this._runtimeAnimations, e = 0; e < t.length; e++)
          t[e].reset(!0);
        this._localDelayOffset = null, this._pausedDelay = null;
      }, n.prototype.enableBlending = function(t) {
        for (var e = this._runtimeAnimations, i = 0; i < e.length; i++)
          e[i].animation.enableBlending = !0, e[i].animation.blendingSpeed = t;
      }, n.prototype.disableBlending = function() {
        for (var t = this._runtimeAnimations, e = 0; e < t.length; e++)
          t[e].animation.enableBlending = !1;
      }, n.prototype.goToFrame = function(t) {
        var e, i = this._runtimeAnimations;
        if (i[0]) {
          var r = i[0].animation.framePerSecond;
          this._frameToSyncFromJump = (e = this._frameToSyncFromJump) !== null && e !== void 0 ? e : i[0].currentFrame;
          var o = this.speedRatio === 0 ? 0 : (t - this._frameToSyncFromJump) / r * 1e3 / this.speedRatio;
          this._manualJumpDelay = -o;
        }
        for (var a = 0; a < i.length; a++)
          i[a].goToFrame(t);
        this._goToFrame = t;
      }, Object.defineProperty(n.prototype, "paused", { get: function() {
        return this._paused;
      }, enumerable: !1, configurable: !0 }), n.prototype.pause = function() {
        this._paused || (this._paused = !0);
      }, n.prototype.restart = function() {
        this._paused = !1;
      }, n.prototype._raiseOnAnimationEnd = function() {
        this.onAnimationEnd && this.onAnimationEnd(), this.onAnimationEndObservable.notifyObservers(this);
      }, n.prototype.stop = function(t, e, i) {
        if (i === void 0 && (i = !1), t || e) {
          var r = this._scene._activeAnimatables.indexOf(this);
          if (r > -1) {
            for (var o = (s = this._runtimeAnimations).length - 1; o >= 0; o--) {
              var a = s[o];
              t && a.animation.name != t || e && !e(a.target) || (a.dispose(), s.splice(o, 1));
            }
            s.length == 0 && (i || this._scene._activeAnimatables.splice(r, 1), this._raiseOnAnimationEnd());
          }
        } else if ((o = this._scene._activeAnimatables.indexOf(this)) > -1) {
          i || this._scene._activeAnimatables.splice(o, 1);
          for (var s = this._runtimeAnimations, l = 0; l < s.length; l++)
            s[l].dispose();
          this._runtimeAnimations.length = 0, this._raiseOnAnimationEnd();
        }
      }, n.prototype.waitAsync = function() {
        var t = this;
        return new Promise(function(e) {
          t.onAnimationEndObservable.add(function() {
            e(t);
          }, void 0, void 0, t, !0);
        });
      }, n.prototype._animate = function(t) {
        if (this._paused)
          return this.animationStarted = !1, this._pausedDelay === null && (this._pausedDelay = t), !0;
        if (this._localDelayOffset === null ? (this._localDelayOffset = t, this._pausedDelay = null) : this._pausedDelay !== null && (this._localDelayOffset += t - this._pausedDelay, this._pausedDelay = null), this._manualJumpDelay !== null && (this._localDelayOffset += this._manualJumpDelay, this._manualJumpDelay = null, this._frameToSyncFromJump = null), this._goToFrame = null, this._weight === 0)
          return !0;
        var e, i = !1, r = this._runtimeAnimations;
        for (e = 0; e < r.length; e++) {
          var o = r[e].animate(t - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this._speedRatio, this._weight);
          i = i || o;
        }
        if (this.animationStarted = i, !i) {
          if (this.disposeOnEnd)
            for (e = this._scene._activeAnimatables.indexOf(this), this._scene._activeAnimatables.splice(e, 1), e = 0; e < r.length; e++)
              r[e].dispose();
          this._raiseOnAnimationEnd(), this.disposeOnEnd && (this.onAnimationEnd = null, this.onAnimationLoop = null, this.onAnimationLoopObservable.clear(), this.onAnimationEndObservable.clear());
        }
        return i;
      }, n;
    }();
    Ue.prototype._animate = function() {
      if (this.animationsEnabled) {
        var n = It.Now;
        if (!this._animationTimeLast) {
          if (this._pendingData.length > 0)
            return;
          this._animationTimeLast = n;
        }
        this.deltaTime = this.useConstantAnimationDeltaTime ? 16 : (n - this._animationTimeLast) * this.animationTimeScale, this._animationTimeLast = n;
        var t = this._activeAnimatables;
        if (t.length !== 0) {
          this._animationTime += this.deltaTime;
          for (var e = this._animationTime, i = 0; i < t.length; i++) {
            var r = t[i];
            !r._animate(e) && r.disposeOnEnd && i--;
          }
          this._processLateAnimationBindings();
        }
      }
    }, Ue.prototype.sortActiveAnimatables = function() {
      this._activeAnimatables.sort(function(n, t) {
        return n.playOrder - t.playOrder;
      });
    }, Ue.prototype.beginWeightedAnimation = function(n, t, e, i, r, o, a, s, l, c, u) {
      i === void 0 && (i = 1), o === void 0 && (o = 1), u === void 0 && (u = !1);
      var h = this.beginAnimation(n, t, e, r, o, a, s, !1, l, c, u);
      return h.weight = i, h;
    }, Ue.prototype.beginAnimation = function(n, t, e, i, r, o, a, s, l, c, u) {
      r === void 0 && (r = 1), s === void 0 && (s = !0), u === void 0 && (u = !1), t > e && r > 0 && (r *= -1), s && this.stopAnimation(n, void 0, l), a || (a = new Tp(this, n, t, e, i, r, o, void 0, c, u));
      var h = !l || l(n);
      if (n.animations && h && a.appendAnimations(n, n.animations), n.getAnimatables)
        for (var d = n.getAnimatables(), p = 0; p < d.length; p++)
          this.beginAnimation(d[p], t, e, i, r, o, a, s, l, c);
      return a.reset(), a;
    }, Ue.prototype.beginHierarchyAnimation = function(n, t, e, i, r, o, a, s, l, c, u, h) {
      o === void 0 && (o = 1), l === void 0 && (l = !0), h === void 0 && (h = !1);
      var d = n.getDescendants(t), p = [];
      p.push(this.beginAnimation(n, e, i, r, o, a, s, l, c, void 0, h));
      for (var f = 0, m = d; f < m.length; f++) {
        var g = m[f];
        p.push(this.beginAnimation(g, e, i, r, o, a, s, l, c, void 0, h));
      }
      return p;
    }, Ue.prototype.beginDirectAnimation = function(n, t, e, i, r, o, a, s, l) {
      if (l === void 0 && (l = !1), o === void 0 && (o = 1), e > i && o > 0)
        o *= -1;
      else if (i > e && o < 0) {
        var c = i;
        i = e, e = c;
      }
      return new Tp(this, n, e, i, r, o, a, t, s, l);
    }, Ue.prototype.beginDirectHierarchyAnimation = function(n, t, e, i, r, o, a, s, l, c) {
      c === void 0 && (c = !1);
      var u = n.getDescendants(t), h = [];
      h.push(this.beginDirectAnimation(n, e, i, r, o, a, s, l, c));
      for (var d = 0, p = u; d < p.length; d++) {
        var f = p[d];
        h.push(this.beginDirectAnimation(f, e, i, r, o, a, s, l, c));
      }
      return h;
    }, Ue.prototype.getAnimatableByTarget = function(n) {
      for (var t = 0; t < this._activeAnimatables.length; t++)
        if (this._activeAnimatables[t].target === n)
          return this._activeAnimatables[t];
      return null;
    }, Ue.prototype.getAllAnimatablesByTarget = function(n) {
      for (var t = [], e = 0; e < this._activeAnimatables.length; e++)
        this._activeAnimatables[e].target === n && t.push(this._activeAnimatables[e]);
      return t;
    }, Ue.prototype.stopAnimation = function(n, t, e) {
      for (var i = 0, r = this.getAllAnimatablesByTarget(n); i < r.length; i++)
        r[i].stop(t, e);
    }, Ue.prototype.stopAllAnimations = function() {
      if (this._activeAnimatables) {
        for (var n = 0; n < this._activeAnimatables.length; n++)
          this._activeAnimatables[n].stop(void 0, void 0, !0);
        this._activeAnimatables.length = 0;
      }
      for (var t = 0, e = this.animationGroups; t < e.length; t++)
        e[t].stop();
    }, Ue.prototype._registerTargetForLateAnimationBinding = function(n, t) {
      var e = n.target;
      this._registeredForLateAnimationBindings.pushNoDuplicate(e), e._lateAnimationHolders || (e._lateAnimationHolders = {}), e._lateAnimationHolders[n.targetPath] || (e._lateAnimationHolders[n.targetPath] = { totalWeight: 0, totalAdditiveWeight: 0, animations: [], additiveAnimations: [], originalValue: t }), n.isAdditive ? (e._lateAnimationHolders[n.targetPath].additiveAnimations.push(n), e._lateAnimationHolders[n.targetPath].totalAdditiveWeight += n.weight) : (e._lateAnimationHolders[n.targetPath].animations.push(n), e._lateAnimationHolders[n.targetPath].totalWeight += n.weight);
    }, Ue.prototype._processLateAnimationBindingsForMatrices = function(n) {
      if (n.totalWeight === 0 && n.totalAdditiveWeight === 0)
        return n.originalValue;
      var t = 1, e = F.Vector3[0], i = F.Vector3[1], r = F.Quaternion[0], o = 0, a = n.animations[0], s = n.originalValue, l = 1, c = !1;
      if (n.totalWeight < 1)
        l = 1 - n.totalWeight, s.decompose(i, r, e);
      else {
        if (o = 1, t = n.totalWeight, (l = a.weight / t) == 1) {
          if (!n.totalAdditiveWeight)
            return a.currentValue;
          c = !0;
        }
        a.currentValue.decompose(i, r, e);
      }
      if (!c) {
        i.scaleInPlace(l), e.scaleInPlace(l), r.scaleInPlace(l);
        for (var u = o; u < n.animations.length; u++)
          if ((f = n.animations[u]).weight !== 0) {
            l = f.weight / t;
            var h = F.Vector3[2], d = F.Vector3[3], p = F.Quaternion[1];
            f.currentValue.decompose(d, p, h), d.scaleAndAddToRef(l, i), p.scaleAndAddToRef(oe.Dot(r, p) > 0 ? l : -l, r), h.scaleAndAddToRef(l, e);
          }
        r.normalize();
      }
      for (u = 0; u < n.additiveAnimations.length; u++) {
        var f;
        (f = n.additiveAnimations[u]).weight !== 0 && (h = F.Vector3[2], d = F.Vector3[3], p = F.Quaternion[1], f.currentValue.decompose(d, p, h), d.multiplyToRef(i, d), v.LerpToRef(i, d, f.weight, i), r.multiplyToRef(p, p), oe.SlerpToRef(r, p, f.weight, r), h.scaleAndAddToRef(f.weight, e));
      }
      var m = a ? a._animationState.workValue : F.Matrix[0].clone();
      return B.ComposeToRef(i, r, e, m), m;
    }, Ue.prototype._processLateAnimationBindingsForQuaternions = function(n, t) {
      if (n.totalWeight === 0 && n.totalAdditiveWeight === 0)
        return t;
      var e = n.animations[0], i = n.originalValue, r = t;
      if (n.totalWeight === 0 && n.totalAdditiveWeight > 0)
        r.copyFrom(i);
      else if (n.animations.length === 1) {
        if (oe.SlerpToRef(i, e.currentValue, Math.min(1, n.totalWeight), r), n.totalAdditiveWeight === 0)
          return r;
      } else if (n.animations.length > 1) {
        var o = 1, a = void 0, s = void 0;
        if (n.totalWeight < 1) {
          var l = 1 - n.totalWeight;
          s = [], (a = []).push(i), s.push(l);
        } else {
          if (n.animations.length === 2 && (oe.SlerpToRef(n.animations[0].currentValue, n.animations[1].currentValue, n.animations[1].weight / n.totalWeight, t), n.totalAdditiveWeight === 0))
            return t;
          a = [], s = [], o = n.totalWeight;
        }
        for (var c = 0; c < n.animations.length; c++) {
          var u = n.animations[c];
          a.push(u.currentValue), s.push(u.weight / o);
        }
        for (var h = 0, d = 0; d < a.length; )
          d ? (h += s[d], oe.SlerpToRef(r, a[d], s[d] / h, r), d++) : (oe.SlerpToRef(a[d], a[d + 1], s[d + 1] / (s[d] + s[d + 1]), t), r = t, h = s[d] + s[d + 1], d += 2);
      }
      for (c = 0; c < n.additiveAnimations.length; c++)
        (u = n.additiveAnimations[c]).weight !== 0 && (r.multiplyToRef(u.currentValue, F.Quaternion[0]), oe.SlerpToRef(r, F.Quaternion[0], u.weight, r));
      return r;
    }, Ue.prototype._processLateAnimationBindings = function() {
      if (this._registeredForLateAnimationBindings.length) {
        for (var n = 0; n < this._registeredForLateAnimationBindings.length; n++) {
          var t = this._registeredForLateAnimationBindings.data[n];
          for (var e in t._lateAnimationHolders) {
            var i = t._lateAnimationHolders[e], r = i.animations[0], o = i.originalValue;
            if (o != null) {
              var a = Je.AllowMatrixDecomposeForInterpolation && o.m, s = t[e];
              if (a)
                s = this._processLateAnimationBindingsForMatrices(i);
              else if (o.w !== void 0)
                s = this._processLateAnimationBindingsForQuaternions(i, s || oe.Identity());
              else {
                var l = 0, c = 1, u = r && r._animationState.loopMode === Je.ANIMATIONLOOPMODE_RELATIVE;
                i.totalWeight < 1 ? s = u ? o.clone ? o.clone() : o : r && o.scale ? o.scale(1 - i.totalWeight) : r ? o * (1 - i.totalWeight) : o.clone ? o.clone() : o : r && (c = i.totalWeight, s = (p = r.weight / c) != 1 ? r.currentValue.scale ? r.currentValue.scale(p) : r.currentValue * p : r.currentValue, u && (s.addToRef ? s.addToRef(o, s) : s += o), l = 1);
                for (var h = l; h < i.animations.length; h++)
                  (p = (d = i.animations[h]).weight / c) && (d.currentValue.scaleAndAddToRef ? d.currentValue.scaleAndAddToRef(p, s) : s += d.currentValue * p);
                for (h = 0; h < i.additiveAnimations.length; h++) {
                  var d, p;
                  (p = (d = i.additiveAnimations[h]).weight) && (d.currentValue.scaleAndAddToRef ? d.currentValue.scaleAndAddToRef(p, s) : s += d.currentValue * p);
                }
              }
              t[e] = s;
            }
          }
          t._lateAnimationHolders = {};
        }
        this._registeredForLateAnimationBindings.reset();
      }
    }, Wu.prototype.copyAnimationRange = function(n, t, e, i, r) {
      i === void 0 && (i = !1), r === void 0 && (r = null), this.animations.length === 0 && (this.animations.push(new Je(this.name, "_matrix", n.animations[0].framePerSecond, Je.ANIMATIONTYPE_MATRIX, 0)), this.animations[0].setKeys([]));
      var o = n.animations[0].getRange(t);
      if (!o)
        return !1;
      for (var a, s, l, c = o.from, u = o.to, h = n.animations[0].getKeys(), d = n.length, p = n.getParent(), f = this.getParent(), m = i && p && d && this.length && d !== this.length, g = m && f && p ? f.length / p.length : 1, y = i && !f && r && (r.x !== 1 || r.y !== 1 || r.z !== 1), b = this.animations[0].getKeys(), T = 0, S = h.length; T < S; T++)
        (a = h[T]).frame >= c && a.frame <= u && (i ? (l = a.value.clone(), m ? (s = l.getTranslation(), l.setTranslation(s.scaleInPlace(g))) : y && r ? (s = l.getTranslation(), l.setTranslation(s.multiplyInPlace(r))) : l = a.value) : l = a.value, b.push({ frame: a.frame + e, value: l }));
      return this.animations[0].createRange(t, c + e, u + e), !0;
    };
    var fs, YA = function() {
      this.enableBlending = !1, this.blendingSpeed = 0.01, this.loopMode = Je.ANIMATIONLOOPMODE_CYCLE;
    };
    (function(n) {
      n[n.CW = 0] = "CW", n[n.CCW = 1] = "CCW";
    })(fs || (fs = {}));
    var oc, ag = function() {
      function n() {
      }
      return n.Interpolate = function(t, e, i, r, o) {
        for (var a = 1 - 3 * r + 3 * e, s = 3 * r - 6 * e, l = 3 * e, c = t, u = 0; u < 5; u++) {
          var h = c * c;
          c -= 1 / (3 * a * h + 2 * s * c + l) * (a * (h * c) + s * h + l * c - t), c = Math.min(1, Math.max(0, c));
        }
        return 3 * Math.pow(1 - c, 2) * c * i + 3 * (1 - c) * Math.pow(c, 2) * o + Math.pow(c, 3);
      }, n;
    }(), ac = function() {
      function n(t) {
        this._radians = t, this._radians < 0 && (this._radians += 2 * Math.PI);
      }
      return n.prototype.degrees = function() {
        return 180 * this._radians / Math.PI;
      }, n.prototype.radians = function() {
        return this._radians;
      }, n.BetweenTwoPoints = function(t, e) {
        var i = e.subtract(t);
        return new n(Math.atan2(i.y, i.x));
      }, n.BetweenTwoVectors = function(t, e) {
        var i = t.lengthSquared() * e.lengthSquared();
        if (i === 0)
          return new n(Math.PI / 2);
        i = Math.sqrt(i);
        var r = t.dot(e) / i;
        return r = ue.Clamp(r, -1, 1), new n(Math.acos(r));
      }, n.FromRadians = function(t) {
        return new n(t);
      }, n.FromDegrees = function(t) {
        return new n(t * Math.PI / 180);
      }, n;
    }(), sg = function(n, t, e) {
      this.startPoint = n, this.midPoint = t, this.endPoint = e;
      var i = Math.pow(t.x, 2) + Math.pow(t.y, 2), r = (Math.pow(n.x, 2) + Math.pow(n.y, 2) - i) / 2, o = (i - Math.pow(e.x, 2) - Math.pow(e.y, 2)) / 2, a = (n.x - t.x) * (t.y - e.y) - (t.x - e.x) * (n.y - t.y);
      this.centerPoint = new fe((r * (t.y - e.y) - o * (n.y - t.y)) / a, ((n.x - t.x) * o - (t.x - e.x) * r) / a), this.radius = this.centerPoint.subtract(this.startPoint).length(), this.startAngle = ac.BetweenTwoPoints(this.centerPoint, this.startPoint);
      var s = this.startAngle.degrees(), l = ac.BetweenTwoPoints(this.centerPoint, this.midPoint).degrees(), c = ac.BetweenTwoPoints(this.centerPoint, this.endPoint).degrees();
      l - s > 180 && (l -= 360), l - s < -180 && (l += 360), c - l > 180 && (c -= 360), c - l < -180 && (c += 360), this.orientation = l - s < 0 ? fs.CW : fs.CCW, this.angle = ac.FromDegrees(this.orientation === fs.CW ? s - c : c - s);
    }, Hu = function() {
      function n(t, e) {
        this._points = new Array(), this._length = 0, this.closed = !1, this._points.push(new fe(t, e));
      }
      return n.prototype.addLineTo = function(t, e) {
        if (this.closed)
          return this;
        var i = new fe(t, e), r = this._points[this._points.length - 1];
        return this._points.push(i), this._length += i.subtract(r).length(), this;
      }, n.prototype.addArcTo = function(t, e, i, r, o) {
        if (o === void 0 && (o = 36), this.closed)
          return this;
        var a = this._points[this._points.length - 1], s = new fe(t, e), l = new fe(i, r), c = new sg(a, s, l), u = c.angle.radians() / o;
        c.orientation === fs.CW && (u *= -1);
        for (var h = c.startAngle.radians() + u, d = 0; d < o; d++) {
          var p = Math.cos(h) * c.radius + c.centerPoint.x, f = Math.sin(h) * c.radius + c.centerPoint.y;
          this.addLineTo(p, f), h += u;
        }
        return this;
      }, n.prototype.addQuadraticCurveTo = function(t, e, i, r, o) {
        if (o === void 0 && (o = 36), this.closed)
          return this;
        for (var a = function(d, p, f, m) {
          return (1 - d) * (1 - d) * p + 2 * d * (1 - d) * f + d * d * m;
        }, s = this._points[this._points.length - 1], l = 0; l <= o; l++) {
          var c = l / o, u = a(c, s.x, t, i), h = a(c, s.y, e, r);
          this.addLineTo(u, h);
        }
        return this;
      }, n.prototype.addBezierCurveTo = function(t, e, i, r, o, a, s) {
        if (s === void 0 && (s = 36), this.closed)
          return this;
        for (var l = function(f, m, g, y, b) {
          return (1 - f) * (1 - f) * (1 - f) * m + 3 * f * (1 - f) * (1 - f) * g + 3 * f * f * (1 - f) * y + f * f * f * b;
        }, c = this._points[this._points.length - 1], u = 0; u <= s; u++) {
          var h = u / s, d = l(h, c.x, t, i, o), p = l(h, c.y, e, r, a);
          this.addLineTo(d, p);
        }
        return this;
      }, n.prototype.isPointInside = function(t) {
        for (var e = !1, i = this._points.length, r = i - 1, o = 0; o < i; r = o++) {
          var a = this._points[r], s = this._points[o], l = s.x - a.x, c = s.y - a.y;
          if (Math.abs(c) > Number.EPSILON) {
            if (c < 0 && (a = this._points[o], l = -l, s = this._points[r], c = -c), t.y < a.y || t.y > s.y)
              continue;
            if (t.y === a.y && t.x === a.x)
              return !0;
            var u = c * (t.x - a.x) - l * (t.y - a.y);
            if (u === 0)
              return !0;
            if (u < 0)
              continue;
            e = !e;
          } else {
            if (t.y !== a.y)
              continue;
            if (s.x <= t.x && t.x <= a.x || a.x <= t.x && t.x <= s.x)
              return !0;
          }
        }
        return e;
      }, n.prototype.close = function() {
        return this.closed = !0, this;
      }, n.prototype.length = function() {
        var t = this._length;
        if (this.closed) {
          var e = this._points[this._points.length - 1];
          t += this._points[0].subtract(e).length();
        }
        return t;
      }, n.prototype.area = function() {
        for (var t = this._points.length, e = 0, i = t - 1, r = 0; r < t; i = r++)
          e += this._points[i].x * this._points[r].y - this._points[r].x * this._points[i].y;
        return 0.5 * e;
      }, n.prototype.getPoints = function() {
        return this._points;
      }, n.prototype.getPointAtLengthPosition = function(t) {
        if (t < 0 || t > 1)
          return fe.Zero();
        for (var e = t * this.length(), i = 0, r = 0; r < this._points.length; r++) {
          var o = (r + 1) % this._points.length, a = this._points[r], s = this._points[o].subtract(a), l = s.length() + i;
          if (e >= i && e <= l) {
            var c = s.normalize(), u = e - i;
            return new fe(a.x + c.x * u, a.y + c.y * u);
          }
          i = l;
        }
        return fe.Zero();
      }, n.StartingAt = function(t, e) {
        return new n(t, e);
      }, n;
    }(), Xu = function() {
      function n(t, e, i, r) {
        e === void 0 && (e = null), r === void 0 && (r = !1), this.path = t, this._curve = new Array(), this._distances = new Array(), this._tangents = new Array(), this._normals = new Array(), this._binormals = new Array(), this._pointAtData = { id: 0, point: v.Zero(), previousPointArrayIndex: 0, position: 0, subPosition: 0, interpolateReady: !1, interpolationMatrix: B.Identity() };
        for (var o = 0; o < t.length; o++)
          this._curve[o] = t[o].clone();
        this._raw = i || !1, this._alignTangentsWithPath = r, this._compute(e, r);
      }
      return n.prototype.getCurve = function() {
        return this._curve;
      }, n.prototype.getPoints = function() {
        return this._curve;
      }, n.prototype.length = function() {
        return this._distances[this._distances.length - 1];
      }, n.prototype.getTangents = function() {
        return this._tangents;
      }, n.prototype.getNormals = function() {
        return this._normals;
      }, n.prototype.getBinormals = function() {
        return this._binormals;
      }, n.prototype.getDistances = function() {
        return this._distances;
      }, n.prototype.getPointAt = function(t) {
        return this._updatePointAtData(t).point;
      }, n.prototype.getTangentAt = function(t, e) {
        return e === void 0 && (e = !1), this._updatePointAtData(t, e), e ? v.TransformCoordinates(v.Forward(), this._pointAtData.interpolationMatrix) : this._tangents[this._pointAtData.previousPointArrayIndex];
      }, n.prototype.getNormalAt = function(t, e) {
        return e === void 0 && (e = !1), this._updatePointAtData(t, e), e ? v.TransformCoordinates(v.Right(), this._pointAtData.interpolationMatrix) : this._normals[this._pointAtData.previousPointArrayIndex];
      }, n.prototype.getBinormalAt = function(t, e) {
        return e === void 0 && (e = !1), this._updatePointAtData(t, e), e ? v.TransformCoordinates(v.UpReadOnly, this._pointAtData.interpolationMatrix) : this._binormals[this._pointAtData.previousPointArrayIndex];
      }, n.prototype.getDistanceAt = function(t) {
        return this.length() * t;
      }, n.prototype.getPreviousPointIndexAt = function(t) {
        return this._updatePointAtData(t), this._pointAtData.previousPointArrayIndex;
      }, n.prototype.getSubPositionAt = function(t) {
        return this._updatePointAtData(t), this._pointAtData.subPosition;
      }, n.prototype.getClosestPositionTo = function(t) {
        for (var e = Number.MAX_VALUE, i = 0, r = 0; r < this._curve.length - 1; r++) {
          var o = this._curve[r + 0], a = this._curve[r + 1].subtract(o).normalize(), s = this._distances[r + 1] - this._distances[r + 0], l = Math.min(Math.max(v.Dot(a, t.subtract(o).normalize()), 0) * v.Distance(o, t) / s, 1), c = v.Distance(o.add(a.scale(l * s)), t);
          c < e && (e = c, i = (this._distances[r + 0] + s * l) / this.length());
        }
        return i;
      }, n.prototype.slice = function(t, e) {
        if (t === void 0 && (t = 0), e === void 0 && (e = 1), t < 0 && (t = 1 - -1 * t % 1), e < 0 && (e = 1 - -1 * e % 1), t > e) {
          var i = t;
          t = e, e = i;
        }
        var r = this.getCurve(), o = this.getPointAt(t), a = this.getPreviousPointIndexAt(t), s = this.getPointAt(e), l = this.getPreviousPointIndexAt(e) + 1, c = [];
        return t !== 0 && (a++, c.push(o)), c.push.apply(c, r.slice(a, l)), e === 1 && t !== 1 || c.push(s), new n(c, this.getNormalAt(t), this._raw, this._alignTangentsWithPath);
      }, n.prototype.update = function(t, e, i) {
        e === void 0 && (e = null), i === void 0 && (i = !1);
        for (var r = 0; r < t.length; r++)
          this._curve[r].x = t[r].x, this._curve[r].y = t[r].y, this._curve[r].z = t[r].z;
        return this._compute(e, i), this;
      }, n.prototype._compute = function(t, e) {
        e === void 0 && (e = !1);
        var i = this._curve.length;
        if (!(i < 2)) {
          this._tangents[0] = this._getFirstNonNullVector(0), this._raw || this._tangents[0].normalize(), this._tangents[i - 1] = this._curve[i - 1].subtract(this._curve[i - 2]), this._raw || this._tangents[i - 1].normalize();
          var r, o, a, s, l, c = this._tangents[0], u = this._normalVector(c, t);
          this._normals[0] = u, this._raw || this._normals[0].normalize(), this._binormals[0] = v.Cross(c, this._normals[0]), this._raw || this._binormals[0].normalize(), this._distances[0] = 0;
          for (var h = 1; h < i; h++)
            r = this._getLastNonNullVector(h), h < i - 1 && (o = this._getFirstNonNullVector(h), this._tangents[h] = e ? o : r.add(o), this._tangents[h].normalize()), this._distances[h] = this._distances[h - 1] + this._curve[h].subtract(this._curve[h - 1]).length(), a = this._tangents[h], l = this._binormals[h - 1], this._normals[h] = v.Cross(l, a), this._raw || (this._normals[h].length() === 0 ? (s = this._normals[h - 1], this._normals[h] = s.clone()) : this._normals[h].normalize()), this._binormals[h] = v.Cross(a, this._normals[h]), this._raw || this._binormals[h].normalize();
          this._pointAtData.id = NaN;
        }
      }, n.prototype._getFirstNonNullVector = function(t) {
        for (var e = 1, i = this._curve[t + e].subtract(this._curve[t]); i.length() === 0 && t + e + 1 < this._curve.length; )
          e++, i = this._curve[t + e].subtract(this._curve[t]);
        return i;
      }, n.prototype._getLastNonNullVector = function(t) {
        for (var e = 1, i = this._curve[t].subtract(this._curve[t - e]); i.length() === 0 && t > e + 1; )
          e++, i = this._curve[t].subtract(this._curve[t - e]);
        return i;
      }, n.prototype._normalVector = function(t, e) {
        var i, r = t.length();
        if (r === 0 && (r = 1), e == null) {
          var o;
          o = ue.WithinEpsilon(Math.abs(t.y) / r, 1, Ge) ? ue.WithinEpsilon(Math.abs(t.x) / r, 1, Ge) ? ue.WithinEpsilon(Math.abs(t.z) / r, 1, Ge) ? v.Zero() : new v(0, 0, 1) : new v(1, 0, 0) : new v(0, -1, 0), i = v.Cross(t, o);
        } else
          i = v.Cross(t, e), v.CrossToRef(i, t, i);
        return i.normalize(), i;
      }, n.prototype._updatePointAtData = function(t, e) {
        if (e === void 0 && (e = !1), this._pointAtData.id === t)
          return this._pointAtData.interpolateReady || this._updateInterpolationMatrix(), this._pointAtData;
        this._pointAtData.id = t;
        var i = this.getPoints();
        if (t <= 0)
          return this._setPointAtData(0, 0, i[0], 0, e);
        if (t >= 1)
          return this._setPointAtData(1, 1, i[i.length - 1], i.length - 1, e);
        for (var r, o = i[0], a = 0, s = t * this.length(), l = 1; l < i.length; l++) {
          r = i[l];
          var c = v.Distance(o, r);
          if ((a += c) === s)
            return this._setPointAtData(t, 1, r, l, e);
          if (a > s) {
            var u = (a - s) / c, h = o.subtract(r), d = r.add(h.scaleInPlace(u));
            return this._setPointAtData(t, 1 - u, d, l - 1, e);
          }
          o = r;
        }
        return this._pointAtData;
      }, n.prototype._setPointAtData = function(t, e, i, r, o) {
        return this._pointAtData.point = i, this._pointAtData.position = t, this._pointAtData.subPosition = e, this._pointAtData.previousPointArrayIndex = r, this._pointAtData.interpolateReady = o, o && this._updateInterpolationMatrix(), this._pointAtData;
      }, n.prototype._updateInterpolationMatrix = function() {
        this._pointAtData.interpolationMatrix = B.Identity();
        var t = this._pointAtData.previousPointArrayIndex;
        if (t !== this._tangents.length - 1) {
          var e = t + 1, i = this._tangents[t].clone(), r = this._normals[t].clone(), o = this._binormals[t].clone(), a = this._tangents[e].clone(), s = this._normals[e].clone(), l = this._binormals[e].clone(), c = oe.RotationQuaternionFromAxis(r, o, i), u = oe.RotationQuaternionFromAxis(s, l, a);
          oe.Slerp(c, u, this._pointAtData.subPosition).toRotationMatrix(this._pointAtData.interpolationMatrix);
        }
      }, n;
    }(), Ep = function() {
      function n(t) {
        this._length = 0, this._points = t, this._length = this._computeLength(t);
      }
      return n.CreateQuadraticBezier = function(t, e, i, r) {
        r = r > 2 ? r : 3;
        for (var o = [], a = function(l, c, u, h) {
          return (1 - l) * (1 - l) * c + 2 * l * (1 - l) * u + l * l * h;
        }, s = 0; s <= r; s++)
          o.push(new v(a(s / r, t.x, e.x, i.x), a(s / r, t.y, e.y, i.y), a(s / r, t.z, e.z, i.z)));
        return new n(o);
      }, n.CreateCubicBezier = function(t, e, i, r, o) {
        o = o > 3 ? o : 4;
        for (var a = [], s = function(c, u, h, d, p) {
          return (1 - c) * (1 - c) * (1 - c) * u + 3 * c * (1 - c) * (1 - c) * h + 3 * c * c * (1 - c) * d + c * c * c * p;
        }, l = 0; l <= o; l++)
          a.push(new v(s(l / o, t.x, e.x, i.x, r.x), s(l / o, t.y, e.y, i.y, r.y), s(l / o, t.z, e.z, i.z, r.z)));
        return new n(a);
      }, n.CreateHermiteSpline = function(t, e, i, r, o) {
        for (var a = [], s = 1 / o, l = 0; l <= o; l++)
          a.push(v.Hermite(t, e, i, r, l * s));
        return new n(a);
      }, n.CreateCatmullRomSpline = function(t, e, i) {
        var r = [], o = 1 / e, a = 0;
        if (i) {
          for (var s = t.length, l = 0; l < s; l++) {
            a = 0;
            for (var c = 0; c < e; c++)
              r.push(v.CatmullRom(t[l % s], t[(l + 1) % s], t[(l + 2) % s], t[(l + 3) % s], a)), a += o;
          }
          r.push(r[0]);
        } else {
          var u = [];
          for (u.push(t[0].clone()), Array.prototype.push.apply(u, t), u.push(t[t.length - 1].clone()), l = 0; l < u.length - 3; l++)
            for (a = 0, c = 0; c < e; c++)
              r.push(v.CatmullRom(u[l], u[l + 1], u[l + 2], u[l + 3], a)), a += o;
          l--, r.push(v.CatmullRom(u[l], u[l + 1], u[l + 2], u[l + 3], a));
        }
        return new n(r);
      }, n.ArcThru3Points = function(t, e, i, r, o, a) {
        r === void 0 && (r = 32), o === void 0 && (o = !1), a === void 0 && (a = !1);
        var s = [], l = e.subtract(t), c = i.subtract(e), u = t.subtract(i), h = v.Cross(l, c), d = h.length();
        if (d < Math.pow(10, -8))
          return new n(s);
        var p = l.lengthSquared(), f = c.lengthSquared(), m = u.lengthSquared(), g = h.lengthSquared(), y = 0.5 * l.length() * c.length() * u.length() / d, b = -0.5 * f * v.Dot(l, u) / g, T = -0.5 * m * v.Dot(l, c) / g, S = -0.5 * p * v.Dot(c, u) / g, E = t.scale(b).add(e.scale(T)).add(i.scale(S)), A = t.subtract(E).normalize(), R = v.Cross(h, A).normalize();
        if (a) {
          for (var C = 2 * Math.PI / r, L = 0; L <= 2 * Math.PI; L += C)
            s.push(E.add(A.scale(y * Math.cos(L)).add(R.scale(y * Math.sin(L)))));
          s.push(t);
        } else {
          C = 1 / r, L = 0;
          var I = v.Zero();
          do
            I = E.add(A.scale(y * Math.cos(L)).add(R.scale(y * Math.sin(L)))), s.push(I), L += C;
          while (!I.equalsWithEpsilon(i, y * C * 1.1));
          s.push(i), o && s.push(t);
        }
        return new n(s);
      }, n.prototype.getPoints = function() {
        return this._points;
      }, n.prototype.length = function() {
        return this._length;
      }, n.prototype.continue = function(t) {
        for (var e = this._points[this._points.length - 1], i = this._points.slice(), r = t.getPoints(), o = 1; o < r.length; o++)
          i.push(r[o].subtract(r[0]).add(e));
        return new n(i);
      }, n.prototype._computeLength = function(t) {
        for (var e = 0, i = 1; i < t.length; i++)
          e += t[i].subtract(t[i - 1]).length();
        return e;
      }, n;
    }(), xn = function() {
      function n() {
        this._easingMode = n.EASINGMODE_EASEIN;
      }
      return n.prototype.setEasingMode = function(t) {
        var e = Math.min(Math.max(t, 0), 2);
        this._easingMode = e;
      }, n.prototype.getEasingMode = function() {
        return this._easingMode;
      }, n.prototype.easeInCore = function(t) {
        throw new Error("You must implement this method");
      }, n.prototype.ease = function(t) {
        switch (this._easingMode) {
          case n.EASINGMODE_EASEIN:
            return this.easeInCore(t);
          case n.EASINGMODE_EASEOUT:
            return 1 - this.easeInCore(1 - t);
        }
        return t >= 0.5 ? 0.5 * (1 - this.easeInCore(2 * (1 - t))) + 0.5 : 0.5 * this.easeInCore(2 * t);
      }, n.EASINGMODE_EASEIN = 0, n.EASINGMODE_EASEOUT = 1, n.EASINGMODE_EASEINOUT = 2, n;
    }(), lg = function(n) {
      function t() {
        return n !== null && n.apply(this, arguments) || this;
      }
      return D(t, n), t.prototype.easeInCore = function(e) {
        return e = Math.max(0, Math.min(1, e)), 1 - Math.sqrt(1 - e * e);
      }, t;
    }(xn), cg = function(n) {
      function t(e) {
        e === void 0 && (e = 1);
        var i = n.call(this) || this;
        return i.amplitude = e, i;
      }
      return D(t, n), t.prototype.easeInCore = function(e) {
        var i = Math.max(0, this.amplitude);
        return Math.pow(e, 3) - e * i * Math.sin(3.141592653589793 * e);
      }, t;
    }(xn), KA = function(n) {
      function t(e, i) {
        e === void 0 && (e = 3), i === void 0 && (i = 2);
        var r = n.call(this) || this;
        return r.bounces = e, r.bounciness = i, r;
      }
      return D(t, n), t.prototype.easeInCore = function(e) {
        var i = Math.max(0, this.bounces), r = this.bounciness;
        r <= 1 && (r = 1.001);
        var o = Math.pow(r, i), a = 1 - r, s = (1 - o) / a + 0.5 * o, l = e * s, c = Math.log(-l * (1 - r) + 1) / Math.log(r), u = Math.floor(c), h = u + 1, d = (1 - Math.pow(r, u)) / (a * s), p = 0.5 * (d + (1 - Math.pow(r, h)) / (a * s)), f = e - p, m = p - d;
        return -Math.pow(1 / r, i - u) / (m * m) * (f - m) * (f + m);
      }, t;
    }(xn), qA = function(n) {
      function t() {
        return n !== null && n.apply(this, arguments) || this;
      }
      return D(t, n), t.prototype.easeInCore = function(e) {
        return e * e * e;
      }, t;
    }(xn), QA = function(n) {
      function t(e, i) {
        e === void 0 && (e = 3), i === void 0 && (i = 3);
        var r = n.call(this) || this;
        return r.oscillations = e, r.springiness = i, r;
      }
      return D(t, n), t.prototype.easeInCore = function(e) {
        var i = Math.max(0, this.oscillations), r = Math.max(0, this.springiness);
        return (r == 0 ? e : (Math.exp(r * e) - 1) / (Math.exp(r) - 1)) * Math.sin((6.283185307179586 * i + 1.5707963267948966) * e);
      }, t;
    }(xn), ug = function(n) {
      function t(e) {
        e === void 0 && (e = 2);
        var i = n.call(this) || this;
        return i.exponent = e, i;
      }
      return D(t, n), t.prototype.easeInCore = function(e) {
        return this.exponent <= 0 ? e : (Math.exp(this.exponent * e) - 1) / (Math.exp(this.exponent) - 1);
      }, t;
    }(xn), ZA = function(n) {
      function t(e) {
        e === void 0 && (e = 2);
        var i = n.call(this) || this;
        return i.power = e, i;
      }
      return D(t, n), t.prototype.easeInCore = function(e) {
        var i = Math.max(0, this.power);
        return Math.pow(e, i);
      }, t;
    }(xn), hg = function(n) {
      function t() {
        return n !== null && n.apply(this, arguments) || this;
      }
      return D(t, n), t.prototype.easeInCore = function(e) {
        return e * e;
      }, t;
    }(xn), JA = function(n) {
      function t() {
        return n !== null && n.apply(this, arguments) || this;
      }
      return D(t, n), t.prototype.easeInCore = function(e) {
        return e * e * e * e;
      }, t;
    }(xn), $A = function(n) {
      function t() {
        return n !== null && n.apply(this, arguments) || this;
      }
      return D(t, n), t.prototype.easeInCore = function(e) {
        return e * e * e * e * e;
      }, t;
    }(xn), Sp = function(n) {
      function t() {
        return n !== null && n.apply(this, arguments) || this;
      }
      return D(t, n), t.prototype.easeInCore = function(e) {
        return 1 - Math.sin(1.5707963267948966 * (1 - e));
      }, t;
    }(xn), eR = function(n) {
      function t(e, i, r, o) {
        e === void 0 && (e = 0), i === void 0 && (i = 0), r === void 0 && (r = 1), o === void 0 && (o = 1);
        var a = n.call(this) || this;
        return a.x1 = e, a.y1 = i, a.x2 = r, a.y2 = o, a;
      }
      return D(t, n), t.prototype.easeInCore = function(e) {
        return ag.Interpolate(e, this.x1, this.y1, this.x2, this.y2);
      }, t;
    }(xn), tR = function() {
      function n(t, e, i) {
        this.frame = t, this.action = e, this.onlyOnce = i, this.isDone = !1;
      }
      return n.prototype._clone = function() {
        return new n(this.frame, this.action, this.onlyOnce);
      }, n;
    }(), dg = function() {
      function n() {
      }
      return n.prototype.getClassName = function() {
        return "TargetedAnimation";
      }, n.prototype.serialize = function() {
        var t = {};
        return t.animation = this.animation.serialize(), t.targetId = this.target.id, t;
      }, n;
    }(), pg = function() {
      function n(t, e, i, r) {
        e === void 0 && (e = null), i === void 0 && (i = -1), r === void 0 && (r = 0), this.name = t, this._targetedAnimations = new Array(), this._animatables = new Array(), this._from = Number.MAX_VALUE, this._to = -Number.MAX_VALUE, this._speedRatio = 1, this._loopAnimation = !1, this._isAdditive = !1, this._weight = -1, this._playOrder = 0, this._enableBlending = null, this._blendingSpeed = null, this._numActiveAnimatables = 0, this._parentContainer = null, this.onAnimationEndObservable = new H(), this.onAnimationLoopObservable = new H(), this.onAnimationGroupLoopObservable = new H(), this.onAnimationGroupEndObservable = new H(), this.onAnimationGroupPauseObservable = new H(), this.onAnimationGroupPlayObservable = new H(), this.metadata = null, this._animationLoopFlags = [], this._scene = e || Me.LastCreatedScene, this._weight = i, this._playOrder = r, this.uniqueId = this._scene.getUniqueId(), this._scene.addAnimationGroup(this);
      }
      return n.prototype.syncWithMask = function() {
        if (this.mask) {
          this._numActiveAnimatables = 0;
          for (var t = 0; t < this._animatables.length; ++t) {
            var e = this._animatables[t];
            this.mask.retainsTarget(e.target.name) ? (this._numActiveAnimatables++, e.paused && e.restart()) : e.paused || e.pause();
          }
        } else
          this._numActiveAnimatables = this._targetedAnimations.length;
      }, n.prototype.removeUnmaskedAnimations = function() {
        if (this.mask) {
          for (var t = 0; t < this._animatables.length; ++t) {
            var e = this._animatables[t];
            this.mask.retainsTarget(e.target.name) || (e.stop(), this._animatables.splice(t, 1), --t);
          }
          for (var i = 0; i < this._targetedAnimations.length; i++) {
            var r = this._targetedAnimations[i];
            this.mask.retainsTarget(r.target.name) || (this._targetedAnimations.splice(i, 1), --i);
          }
        }
      }, Object.defineProperty(n.prototype, "from", { get: function() {
        return this._from;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "to", { get: function() {
        return this._to;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isStarted", { get: function() {
        return this._isStarted;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isPlaying", { get: function() {
        return this._isStarted && !this._isPaused;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "speedRatio", { get: function() {
        return this._speedRatio;
      }, set: function(t) {
        if (this._speedRatio !== t) {
          this._speedRatio = t;
          for (var e = 0; e < this._animatables.length; e++)
            this._animatables[e].speedRatio = this._speedRatio;
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "loopAnimation", { get: function() {
        return this._loopAnimation;
      }, set: function(t) {
        if (this._loopAnimation !== t) {
          this._loopAnimation = t;
          for (var e = 0; e < this._animatables.length; e++)
            this._animatables[e].loopAnimation = this._loopAnimation;
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isAdditive", { get: function() {
        return this._isAdditive;
      }, set: function(t) {
        if (this._isAdditive !== t) {
          this._isAdditive = t;
          for (var e = 0; e < this._animatables.length; e++)
            this._animatables[e].isAdditive = this._isAdditive;
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "weight", { get: function() {
        return this._weight;
      }, set: function(t) {
        this._weight !== t && (this._weight = t, this.setWeightForAllAnimatables(this._weight));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "targetedAnimations", { get: function() {
        return this._targetedAnimations;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "animatables", { get: function() {
        return this._animatables;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "children", { get: function() {
        return this._targetedAnimations;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "playOrder", { get: function() {
        return this._playOrder;
      }, set: function(t) {
        if (this._playOrder !== t && (this._playOrder = t, this._animatables.length > 0)) {
          for (var e = 0; e < this._animatables.length; e++)
            this._animatables[e].playOrder = this._playOrder;
          this._scene.sortActiveAnimatables();
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "enableBlending", { get: function() {
        return this._enableBlending;
      }, set: function(t) {
        if (this._enableBlending !== t && (this._enableBlending = t, t !== null))
          for (var e = 0; e < this._targetedAnimations.length; ++e)
            this._targetedAnimations[e].animation.enableBlending = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "blendingSpeed", { get: function() {
        return this._blendingSpeed;
      }, set: function(t) {
        if (this._blendingSpeed !== t && (this._blendingSpeed = t, t !== null))
          for (var e = 0; e < this._targetedAnimations.length; ++e)
            this._targetedAnimations[e].animation.blendingSpeed = t;
      }, enumerable: !1, configurable: !0 }), n.prototype.getLength = function(t, e) {
        return t = t ?? this._from, ((e = e ?? this._to) - t) / (this.targetedAnimations[0].animation.framePerSecond * this._speedRatio);
      }, n.MergeAnimationGroups = function(t, e, i, r) {
        if (e === void 0 && (e = !0), i === void 0 && (i = !1), t.length === 0)
          return null;
        r = r ?? t[0].weight;
        var o = Number.MAX_VALUE, a = -Number.MAX_VALUE;
        if (i)
          for (var s = 0, l = t; s < l.length; s++)
            (d = l[s]).from < o && (o = d.from), d.to > a && (a = d.to);
        for (var c = new n(t[0].name + "_merged", t[0]._scene, r), u = 0, h = t; u < h.length; u++) {
          var d = h[u];
          i && d.normalize(o, a);
          for (var p = 0, f = d.targetedAnimations; p < f.length; p++) {
            var m = f[p];
            c.addTargetedAnimation(m.animation, m.target);
          }
          e && d.dispose();
        }
        return c;
      }, n.prototype.addTargetedAnimation = function(t, e) {
        var i = new dg();
        i.animation = t, i.target = e;
        var r = t.getKeys();
        return this._from > r[0].frame && (this._from = r[0].frame), this._to < r[r.length - 1].frame && (this._to = r[r.length - 1].frame), this._enableBlending !== null && (t.enableBlending = this._enableBlending), this._blendingSpeed !== null && (t.blendingSpeed = this._blendingSpeed), this._targetedAnimations.push(i), i;
      }, n.prototype.removeTargetedAnimation = function(t) {
        for (var e = this._targetedAnimations.length - 1; e > -1; e--)
          this._targetedAnimations[e].animation === t && this._targetedAnimations.splice(e, 1);
      }, n.prototype.normalize = function(t, e) {
        t === void 0 && (t = null), e === void 0 && (e = null), t == null && (t = this._from), e == null && (e = this._to);
        for (var i = 0; i < this._targetedAnimations.length; i++) {
          var r = this._targetedAnimations[i].animation.getKeys(), o = r[0], a = r[r.length - 1];
          if (o.frame > t) {
            var s = { frame: t, value: o.value, inTangent: o.inTangent, outTangent: o.outTangent, interpolation: o.interpolation };
            r.splice(0, 0, s);
          }
          a.frame < e && (s = { frame: e, value: a.value, inTangent: a.inTangent, outTangent: a.outTangent, interpolation: a.interpolation }, r.push(s));
        }
        return this._from = t, this._to = e, this;
      }, n.prototype._processLoop = function(t, e, i) {
        var r = this;
        t.onAnimationLoop = function() {
          r.onAnimationLoopObservable.notifyObservers(e), r._animationLoopFlags[i] || (r._animationLoopFlags[i] = !0, r._animationLoopCount++, r._animationLoopCount === r._numActiveAnimatables && (r.onAnimationGroupLoopObservable.notifyObservers(r), r._animationLoopCount = 0, r._animationLoopFlags.length = 0));
        };
      }, n.prototype.start = function(t, e, i, r, o) {
        var a = this;
        if (t === void 0 && (t = !1), e === void 0 && (e = 1), this._isStarted || this._targetedAnimations.length === 0)
          return this;
        this._loopAnimation = t, this._animationLoopCount = 0, this._animationLoopFlags.length = 0;
        for (var s = function(u) {
          var h = l._targetedAnimations[u], d = l._scene.beginDirectAnimation(h.target, [h.animation], i !== void 0 ? i : l._from, r !== void 0 ? r : l._to, t, e, void 0, void 0, o !== void 0 ? o : l._isAdditive);
          d.weight = l._weight, d.playOrder = l._playOrder, d.onAnimationEnd = function() {
            a.onAnimationEndObservable.notifyObservers(h), a._checkAnimationGroupEnded(d);
          }, l._processLoop(d, h, u), l._animatables.push(d);
        }, l = this, c = 0; c < this._targetedAnimations.length; c++)
          s(c);
        return this.syncWithMask(), this._scene.sortActiveAnimatables(), this._speedRatio = e, this._isStarted = !0, this._isPaused = !1, this.onAnimationGroupPlayObservable.notifyObservers(this), this;
      }, n.prototype.pause = function() {
        if (!this._isStarted)
          return this;
        this._isPaused = !0;
        for (var t = 0; t < this._animatables.length; t++)
          this._animatables[t].pause();
        return this.onAnimationGroupPauseObservable.notifyObservers(this), this;
      }, n.prototype.play = function(t) {
        return this.isStarted && this._animatables.length === this._targetedAnimations.length ? (t !== void 0 && (this.loopAnimation = t), this.restart()) : (this.stop(), this.start(t, this._speedRatio)), this._isPaused = !1, this;
      }, n.prototype.reset = function() {
        if (!this._isStarted)
          return this.play(), this.goToFrame(0), this.stop(), this;
        for (var t = 0; t < this._animatables.length; t++)
          this._animatables[t].reset();
        return this;
      }, n.prototype.restart = function() {
        if (!this._isStarted)
          return this;
        for (var t = 0; t < this._animatables.length; t++)
          this._animatables[t].restart();
        return this.onAnimationGroupPlayObservable.notifyObservers(this), this;
      }, n.prototype.stop = function() {
        if (!this._isStarted)
          return this;
        for (var t = this._animatables.slice(), e = 0; e < t.length; e++)
          t[e].stop(void 0, void 0, !0);
        var i = 0;
        for (e = 0; e < this._scene._activeAnimatables.length; e++) {
          var r = this._scene._activeAnimatables[e];
          r._runtimeAnimations.length > 0 && (this._scene._activeAnimatables[i++] = r);
        }
        return this._scene._activeAnimatables.length = i, this._isStarted = !1, this;
      }, n.prototype.setWeightForAllAnimatables = function(t) {
        for (var e = 0; e < this._animatables.length; e++)
          this._animatables[e].weight = t;
        return this;
      }, n.prototype.syncAllAnimationsWith = function(t) {
        for (var e = 0; e < this._animatables.length; e++)
          this._animatables[e].syncWith(t);
        return this;
      }, n.prototype.goToFrame = function(t) {
        if (!this._isStarted)
          return this;
        for (var e = 0; e < this._animatables.length; e++)
          this._animatables[e].goToFrame(t);
        return this;
      }, n.prototype.dispose = function() {
        this._targetedAnimations.length = 0, this._animatables.length = 0;
        var t = this._scene.animationGroups.indexOf(this);
        if (t > -1 && this._scene.animationGroups.splice(t, 1), this._parentContainer) {
          var e = this._parentContainer.animationGroups.indexOf(this);
          e > -1 && this._parentContainer.animationGroups.splice(e, 1), this._parentContainer = null;
        }
        this.onAnimationEndObservable.clear(), this.onAnimationGroupEndObservable.clear(), this.onAnimationGroupPauseObservable.clear(), this.onAnimationGroupPlayObservable.clear(), this.onAnimationLoopObservable.clear(), this.onAnimationGroupLoopObservable.clear();
      }, n.prototype._checkAnimationGroupEnded = function(t) {
        var e = this._animatables.indexOf(t);
        e > -1 && this._animatables.splice(e, 1), this._animatables.length === 0 && (this._isStarted = !1, this.onAnimationGroupEndObservable.notifyObservers(this));
      }, n.prototype.clone = function(t, e, i) {
        i === void 0 && (i = !1);
        var r = new n(t || this.name, this._scene, this._weight, this._playOrder);
        r._from = this.from, r._to = this.to, r._speedRatio = this.speedRatio, r._loopAnimation = this.loopAnimation, r._isAdditive = this.isAdditive, r._enableBlending = this.enableBlending, r._blendingSpeed = this.blendingSpeed, r.metadata = this.metadata, r.mask = this.mask;
        for (var o = 0, a = this._targetedAnimations; o < a.length; o++) {
          var s = a[o];
          r.addTargetedAnimation(i ? s.animation.clone() : s.animation, e ? e(s.target) : s.target);
        }
        return r;
      }, n.prototype.serialize = function() {
        var t = {};
        t.name = this.name, t.from = this.from, t.to = this.to, t.speedRatio = this.speedRatio, t.loopAnimation = this.loopAnimation, t.isAdditive = this.isAdditive, t.weight = this.weight, t.playOrder = this.playOrder, t.enableBlending = this.enableBlending, t.blendingSpeed = this.blendingSpeed, t.targetedAnimations = [];
        for (var e = 0; e < this.targetedAnimations.length; e++) {
          var i = this.targetedAnimations[e];
          t.targetedAnimations[e] = i.serialize();
        }
        return Xt && Xt.HasTags(this) && (t.tags = Xt.GetTags(this)), this.metadata && (t.metadata = this.metadata), t;
      }, n.Parse = function(t, e) {
        for (var i = new n(t.name, e, t.weight, t.playOrder), r = 0; r < t.targetedAnimations.length; r++) {
          var o = t.targetedAnimations[r], a = Je.Parse(o.animation), s = o.targetId;
          if (o.animation.property === "influence") {
            var l = e.getMorphTargetById(s);
            l && i.addTargetedAnimation(a, l);
          } else {
            var c = e.getNodeById(s);
            c != null && i.addTargetedAnimation(a, c);
          }
        }
        return Xt && Xt.AddTagsTo(i, t.tags), t.from !== null && t.to !== null && i.normalize(t.from, t.to), t.speedRatio !== void 0 && (i._speedRatio = t.speedRatio), t.loopAnimation !== void 0 && (i._loopAnimation = t.loopAnimation), t.isAdditive !== void 0 && (i._isAdditive = t.isAdditive), t.weight !== void 0 && (i._weight = t.weight), t.playOrder !== void 0 && (i._playOrder = t.playOrder), t.enableBlending !== void 0 && (i._enableBlending = t.enableBlending), t.blendingSpeed !== void 0 && (i._blendingSpeed = t.blendingSpeed), t.metadata !== void 0 && (i.metadata = t.metadata), i;
      }, n.MakeAnimationAdditive = function(t, e, i, r, o) {
        var a;
        r === void 0 && (r = !1);
        var s = t;
        (a = typeof e == "object" ? e : { referenceFrame: e, range: i, cloneOriginalAnimationGroup: r, clonedAnimationName: o }).cloneOriginalAnimationGroup && (s = t.clone(a.clonedAnimationGroupName || s.name));
        for (var l = s.targetedAnimations, c = 0; c < l.length; c++)
          (p = l[c]).animation = Je.MakeAnimationAdditive(p.animation, a);
        if (s.isAdditive = !0, a.clipKeys) {
          var u = Number.MAX_VALUE, h = -Number.MAX_VALUE, d = s.targetedAnimations;
          for (c = 0; c < d.length; c++) {
            var p, f = (p = d[c]).animation.getKeys();
            u > f[0].frame && (u = f[0].frame), h < f[f.length - 1].frame && (h = f[f.length - 1].frame);
          }
          s._from = u, s._to = h;
        }
        return s;
      }, n.ClipKeys = function(t, e, i, r, o) {
        var a = t.clone(r || t.name);
        return n.ClipKeysInPlace(a, e, i, o);
      }, n.ClipKeysInPlace = function(t, e, i, r) {
        return n.ClipInPlace(t, e, i, r, !1);
      }, n.ClipFrames = function(t, e, i, r, o) {
        var a = t.clone(r || t.name);
        return n.ClipFramesInPlace(a, e, i, o);
      }, n.ClipFramesInPlace = function(t, e, i, r) {
        return n.ClipInPlace(t, e, i, r, !0);
      }, n.ClipInPlace = function(t, e, i, r, o) {
        o === void 0 && (o = !1);
        for (var a = Number.MAX_VALUE, s = -Number.MAX_VALUE, l = t.targetedAnimations, c = 0; c < l.length; c++) {
          var u = l[c], h = r ? u.animation : u.animation.clone();
          o && (h.createKeyForFrame(e), h.createKeyForFrame(i));
          for (var d = h.getKeys(), p = [], f = Number.MAX_VALUE, m = 0; m < d.length; m++) {
            var g = d[m];
            if (!o && m >= e && m <= i || o && g.frame >= e && g.frame <= i) {
              var y = { frame: g.frame, value: g.value.clone ? g.value.clone() : g.value, inTangent: g.inTangent, outTangent: g.outTangent, interpolation: g.interpolation, lockedTangent: g.lockedTangent };
              f === Number.MAX_VALUE && (f = y.frame), y.frame -= f, p.push(y);
            }
          }
          p.length !== 0 ? (a > p[0].frame && (a = p[0].frame), s < p[p.length - 1].frame && (s = p[p.length - 1].frame), h.setKeys(p, !0), u.animation = h) : (l.splice(c, 1), c--);
        }
        return t._from = a, t._to = s, t;
      }, n.prototype.getClassName = function() {
        return "AnimationGroup";
      }, n.prototype.toString = function(t) {
        var e = "Name: " + this.name;
        return e += ", type: " + this.getClassName(), t && (e += ", from: " + this._from, e += ", to: " + this._to, e += ", isStarted: " + this._isStarted, e += ", speedRatio: " + this._speedRatio, e += ", targetedAnimations length: " + this._targetedAnimations.length, e += ", animatables length: " + this._animatables), e;
      }, n;
    }(), iR = function() {
      function n(t) {
        this._path = t, this._onchange = new Array(), this.value = 0, this.animations = [];
      }
      return n.prototype.getPoint = function() {
        var t = this._path.getPointAtLengthPosition(this.value);
        return new v(t.x, 0, t.y);
      }, n.prototype.moveAhead = function(t) {
        return t === void 0 && (t = 2e-3), this.move(t), this;
      }, n.prototype.moveBack = function(t) {
        return t === void 0 && (t = 2e-3), this.move(-t), this;
      }, n.prototype.move = function(t) {
        if (Math.abs(t) > 1)
          throw "step size should be less than 1.";
        return this.value += t, this._ensureLimits(), this._raiseOnChange(), this;
      }, n.prototype._ensureLimits = function() {
        for (; this.value > 1; )
          this.value -= 1;
        for (; this.value < 0; )
          this.value += 1;
        return this;
      }, n.prototype._raiseOnChange = function() {
        var t = this;
        return this._onchange.forEach(function(e) {
          return e(t);
        }), this;
      }, n.prototype.onchange = function(t) {
        return this._onchange.push(t), this;
      }, n;
    }();
    (function(n) {
      n[n.Include = 0] = "Include", n[n.Exclude = 1] = "Exclude";
    })(oc || (oc = {}));
    var nR = function() {
      function n(t, e) {
        e === void 0 && (e = oc.Include), this.mode = e, this._targetNames = /* @__PURE__ */ new Set(), t && this.addTargetName(t);
      }
      return n.prototype.addTargetName = function(t) {
        if (Array.isArray(t))
          for (var e = 0, i = t; e < i.length; e++) {
            var r = i[e];
            this._targetNames.add(r);
          }
        else
          this._targetNames.add(t);
      }, n.prototype.removeTargetName = function(t) {
        if (Array.isArray(t))
          for (var e = 0, i = t; e < i.length; e++) {
            var r = i[e];
            this._targetNames.delete(r);
          }
        else
          this._targetNames.delete(t);
      }, n.prototype.hasTarget = function(t) {
        return this._targetNames.has(t);
      }, n.prototype.retainsTarget = function(t) {
        return this._targetNames.has(t) === (this.mode === oc.Include);
      }, n;
    }();
    function sc(n, t, e) {
      try {
        var i = n.next();
        i.done ? t(i) : i.value ? i.value.then(function() {
          i.value = void 0, t(i);
        }, e) : t(i);
      } catch (r) {
        e(r);
      }
    }
    function fg(n) {
      var t;
      return n === void 0 && (n = 25), function(e, i, r) {
        var o = performance.now();
        t === void 0 || o - t > n ? (t = o, setTimeout(function() {
          sc(e, i, r);
        }, 0)) : sc(e, i, r);
      };
    }
    function xp(n, t, e, i, r) {
      var o = function() {
        var a, s = function(l) {
          l.done ? e(l.value) : a === void 0 ? a = !0 : o();
        };
        do
          a = void 0, r && r.aborted ? i(new Error("Aborted")) : t(n, s, i), a === void 0 && (a = !1);
        while (a);
      };
      o();
    }
    function ju(n, t) {
      var e;
      return xp(n, sc, function(i) {
        return e = i;
      }, function(i) {
        throw i;
      }, t), e;
    }
    function Yu(n, t, e) {
      return new Promise(function(i, r) {
        xp(n, t, i, r, e);
      });
    }
    function _g(n, t) {
      return function() {
        for (var e = [], i = 0; i < arguments.length; i++)
          e[i] = arguments[i];
        return ju(n.apply(void 0, e), t);
      };
    }
    function rR(n, t, e) {
      return function() {
        for (var i = [], r = 0; r < arguments.length; r++)
          i[r] = arguments[r];
        return Yu(n.apply(void 0, i), t, e);
      };
    }
    var xr = function() {
      function n(t, e, i, r) {
        this.x = t, this.y = e, this.width = i, this.height = r;
      }
      return n.prototype.toGlobal = function(t, e) {
        return new n(this.x * t, this.y * e, this.width * t, this.height * e);
      }, n.prototype.toGlobalToRef = function(t, e, i) {
        return i.x = this.x * t, i.y = this.y * e, i.width = this.width * t, i.height = this.height * e, this;
      }, n.prototype.clone = function() {
        return new n(this.x, this.y, this.width, this.height);
      }, n;
    }(), dt = function(n) {
      function t(e, i, r, o) {
        o === void 0 && (o = !0);
        var a = n.call(this, e, r) || this;
        return a._position = v.Zero(), a._upVector = v.Up(), a.oblique = null, a._orthoLeft = null, a._orthoRight = null, a._orthoBottom = null, a._orthoTop = null, a.fov = 0.8, a.projectionPlaneTilt = 0, a.minZ = 1, a.maxZ = 1e4, a.inertia = 0.9, a._mode = t.PERSPECTIVE_CAMERA, a.isIntermediate = !1, a.viewport = new xr(0, 0, 1, 1), a.layerMask = 268435455, a.fovMode = t.FOVMODE_VERTICAL_FIXED, a.cameraRigMode = t.RIG_MODE_NONE, a.customRenderTargets = [], a.outputRenderTarget = null, a.onViewMatrixChangedObservable = new H(), a.onProjectionMatrixChangedObservable = new H(), a.onAfterCheckInputsObservable = new H(), a.onRestoreStateObservable = new H(), a.isRigCamera = !1, a._rigCameras = new Array(), a._skipRendering = !1, a._projectionMatrix = new B(), a._postProcesses = new Array(), a._activeMeshes = new en(256), a._globalPosition = v.Zero(), a._computedViewMatrix = B.Identity(), a._doNotComputeProjectionMatrix = !1, a._transformMatrix = B.Zero(), a._refreshFrustumPlanes = !0, a._absoluteRotation = oe.Identity(), a._isCamera = !0, a._isLeftCamera = !1, a._isRightCamera = !1, a.getScene().addCamera(a), o && !a.getScene().activeCamera && (a.getScene().activeCamera = a), a.position = i, a.renderPassId = a.getScene().getEngine().createRenderPassId("Camera ".concat(e)), a;
      }
      return D(t, n), Object.defineProperty(t.prototype, "position", { get: function() {
        return this._position;
      }, set: function(e) {
        this._position = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "upVector", { get: function() {
        return this._upVector;
      }, set: function(e) {
        this._upVector = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "screenArea", { get: function() {
        var e, i, r, o, a = 0, s = 0;
        if (this.mode === t.PERSPECTIVE_CAMERA)
          this.fovMode === t.FOVMODE_VERTICAL_FIXED ? (s = 2 * this.minZ * Math.tan(this.fov / 2), a = this.getEngine().getAspectRatio(this) * s) : s = (a = 2 * this.minZ * Math.tan(this.fov / 2)) / this.getEngine().getAspectRatio(this);
        else {
          var l = this.getEngine().getRenderWidth() / 2, c = this.getEngine().getRenderHeight() / 2;
          a = ((e = this.orthoRight) !== null && e !== void 0 ? e : l) - ((i = this.orthoLeft) !== null && i !== void 0 ? i : -l), s = ((r = this.orthoTop) !== null && r !== void 0 ? r : c) - ((o = this.orthoBottom) !== null && o !== void 0 ? o : -c);
        }
        return a * s;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "orthoLeft", { get: function() {
        return this._orthoLeft;
      }, set: function(e) {
        this._orthoLeft = e;
        for (var i = 0, r = this._rigCameras; i < r.length; i++)
          r[i].orthoLeft = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "orthoRight", { get: function() {
        return this._orthoRight;
      }, set: function(e) {
        this._orthoRight = e;
        for (var i = 0, r = this._rigCameras; i < r.length; i++)
          r[i].orthoRight = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "orthoBottom", { get: function() {
        return this._orthoBottom;
      }, set: function(e) {
        this._orthoBottom = e;
        for (var i = 0, r = this._rigCameras; i < r.length; i++)
          r[i].orthoBottom = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "orthoTop", { get: function() {
        return this._orthoTop;
      }, set: function(e) {
        this._orthoTop = e;
        for (var i = 0, r = this._rigCameras; i < r.length; i++)
          r[i].orthoTop = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "mode", { get: function() {
        return this._mode;
      }, set: function(e) {
        this._mode = e;
        for (var i = 0, r = this._rigCameras; i < r.length; i++)
          r[i].mode = e;
      }, enumerable: !1, configurable: !0 }), t.prototype.storeState = function() {
        return this._stateStored = !0, this._storedFov = this.fov, this;
      }, t.prototype._restoreStateValues = function() {
        return !!this._stateStored && (this.fov = this._storedFov, !0);
      }, t.prototype.restoreState = function() {
        return !!this._restoreStateValues() && (this.onRestoreStateObservable.notifyObservers(this), !0);
      }, t.prototype.getClassName = function() {
        return "Camera";
      }, t.prototype.toString = function(e) {
        var i = "Name: " + this.name;
        if (i += ", type: " + this.getClassName(), this.animations)
          for (var r = 0; r < this.animations.length; r++)
            i += ", animation[0]: " + this.animations[r].toString(e);
        return i;
      }, t.prototype.applyVerticalCorrection = function() {
        var e = this.absoluteRotation.toEulerAngles();
        this.projectionPlaneTilt = this._scene.useRightHandedSystem ? -e.x : e.x;
      }, Object.defineProperty(t.prototype, "globalPosition", { get: function() {
        return this._globalPosition;
      }, enumerable: !1, configurable: !0 }), t.prototype.getActiveMeshes = function() {
        return this._activeMeshes;
      }, t.prototype.isActiveMesh = function(e) {
        return this._activeMeshes.indexOf(e) !== -1;
      }, t.prototype.isReady = function(e) {
        if (e === void 0 && (e = !1), e)
          for (var i = 0, r = this._postProcesses; i < r.length; i++) {
            var o = r[i];
            if (o && !o.isReady())
              return !1;
          }
        return n.prototype.isReady.call(this, e);
      }, t.prototype._initCache = function() {
        n.prototype._initCache.call(this), this._cache.position = new v(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), this._cache.upVector = new v(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), this._cache.mode = void 0, this._cache.minZ = void 0, this._cache.maxZ = void 0, this._cache.fov = void 0, this._cache.fovMode = void 0, this._cache.aspectRatio = void 0, this._cache.orthoLeft = void 0, this._cache.orthoRight = void 0, this._cache.orthoBottom = void 0, this._cache.orthoTop = void 0, this._cache.obliqueAngle = void 0, this._cache.obliqueLength = void 0, this._cache.obliqueOffset = void 0, this._cache.renderWidth = void 0, this._cache.renderHeight = void 0;
      }, t.prototype._updateCache = function(e) {
        e || n.prototype._updateCache.call(this), this._cache.position.copyFrom(this.position), this._cache.upVector.copyFrom(this.upVector);
      }, t.prototype._isSynchronized = function() {
        return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix();
      }, t.prototype._isSynchronizedViewMatrix = function() {
        return !!n.prototype._isSynchronized.call(this) && this._cache.position.equals(this.position) && this._cache.upVector.equals(this.upVector) && this.isSynchronizedWithParent();
      }, t.prototype._isSynchronizedProjectionMatrix = function() {
        var e = this._cache.mode === this.mode && this._cache.minZ === this.minZ && this._cache.maxZ === this.maxZ;
        if (!e)
          return !1;
        var i = this.getEngine();
        return this.mode === t.PERSPECTIVE_CAMERA ? e = this._cache.fov === this.fov && this._cache.fovMode === this.fovMode && this._cache.aspectRatio === i.getAspectRatio(this) && this._cache.projectionPlaneTilt === this.projectionPlaneTilt : (e = this._cache.orthoLeft === this.orthoLeft && this._cache.orthoRight === this.orthoRight && this._cache.orthoBottom === this.orthoBottom && this._cache.orthoTop === this.orthoTop && this._cache.renderWidth === i.getRenderWidth() && this._cache.renderHeight === i.getRenderHeight(), this.oblique && (e = e && this._cache.obliqueAngle === this.oblique.angle && this._cache.obliqueLength === this.oblique.length && this._cache.obliqueOffset === this.oblique.offset)), e;
      }, t.prototype.attachControl = function(e, i) {
      }, t.prototype.detachControl = function(e) {
      }, t.prototype.update = function() {
        this._checkInputs(), this.cameraRigMode !== t.RIG_MODE_NONE && this._updateRigCameras(), this.getViewMatrix(), this.getProjectionMatrix();
      }, t.prototype._checkInputs = function() {
        this.onAfterCheckInputsObservable.notifyObservers(this);
      }, Object.defineProperty(t.prototype, "rigCameras", { get: function() {
        return this._rigCameras;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rigPostProcess", { get: function() {
        return this._rigPostProcess;
      }, enumerable: !1, configurable: !0 }), t.prototype._getFirstPostProcess = function() {
        for (var e = 0; e < this._postProcesses.length; e++)
          if (this._postProcesses[e] !== null)
            return this._postProcesses[e];
        return null;
      }, t.prototype._cascadePostProcessesToRigCams = function() {
        var e = this._getFirstPostProcess();
        e && e.markTextureDirty();
        for (var i = 0, r = this._rigCameras.length; i < r; i++) {
          var o = this._rigCameras[i], a = o._rigPostProcess;
          a ? (a.getEffectName() === "pass" && (o.isIntermediate = this._postProcesses.length === 0), o._postProcesses = this._postProcesses.slice(0).concat(a), a.markTextureDirty()) : o._postProcesses = this._postProcesses.slice(0);
        }
      }, t.prototype.attachPostProcess = function(e, i) {
        return i === void 0 && (i = null), !e.isReusable() && this._postProcesses.indexOf(e) > -1 ? (q.Error("You're trying to reuse a post process not defined as reusable."), 0) : (i == null || i < 0 ? this._postProcesses.push(e) : this._postProcesses[i] === null ? this._postProcesses[i] = e : this._postProcesses.splice(i, 0, e), this._cascadePostProcessesToRigCams(), this._scene.prePassRenderer && this._scene.prePassRenderer.markAsDirty(), this._postProcesses.indexOf(e));
      }, t.prototype.detachPostProcess = function(e) {
        var i = this._postProcesses.indexOf(e);
        i !== -1 && (this._postProcesses[i] = null), this._scene.prePassRenderer && this._scene.prePassRenderer.markAsDirty(), this._cascadePostProcessesToRigCams();
      }, t.prototype.getWorldMatrix = function() {
        return this._isSynchronizedViewMatrix() || this.getViewMatrix(), this._worldMatrix;
      }, t.prototype._getViewMatrix = function() {
        return B.Identity();
      }, t.prototype.getViewMatrix = function(e) {
        return !e && this._isSynchronizedViewMatrix() || (this.updateCache(), this._computedViewMatrix = this._getViewMatrix(), this._currentRenderId = this.getScene().getRenderId(), this._childUpdateId++, this._refreshFrustumPlanes = !0, this._cameraRigParams && this._cameraRigParams.vrPreViewMatrix && this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix, this._computedViewMatrix), this.parent && this.parent.onViewMatrixChangedObservable && this.parent.onViewMatrixChangedObservable.notifyObservers(this.parent), this.onViewMatrixChangedObservable.notifyObservers(this), this._computedViewMatrix.invertToRef(this._worldMatrix)), this._computedViewMatrix;
      }, t.prototype.freezeProjectionMatrix = function(e) {
        this._doNotComputeProjectionMatrix = !0, e !== void 0 && (this._projectionMatrix = e);
      }, t.prototype.unfreezeProjectionMatrix = function() {
        this._doNotComputeProjectionMatrix = !1;
      }, t.prototype.getProjectionMatrix = function(e) {
        var i, r, o, a, s, l, c, u, h, d, p, f, m, g, y, b, T, S, E;
        if (this._doNotComputeProjectionMatrix || !e && this._isSynchronizedProjectionMatrix())
          return this._projectionMatrix;
        this._cache.mode = this.mode, this._cache.minZ = this.minZ, this._cache.maxZ = this.maxZ, this._refreshFrustumPlanes = !0;
        var A = this.getEngine(), R = this.getScene(), C = A.useReverseDepthBuffer;
        if (this.mode === t.PERSPECTIVE_CAMERA)
          this._cache.fov = this.fov, this._cache.fovMode = this.fovMode, this._cache.aspectRatio = A.getAspectRatio(this), this._cache.projectionPlaneTilt = this.projectionPlaneTilt, this.minZ <= 0 && (this.minZ = 0.1), (R.useRightHandedSystem ? B.PerspectiveFovRHToRef : B.PerspectiveFovLHToRef)(this.fov, A.getAspectRatio(this), C ? this.maxZ : this.minZ, C ? this.minZ : this.maxZ, this._projectionMatrix, this.fovMode === t.FOVMODE_VERTICAL_FIXED, A.isNDCHalfZRange, this.projectionPlaneTilt, C);
        else {
          var L = A.getRenderWidth() / 2, I = A.getRenderHeight() / 2;
          R.useRightHandedSystem ? this.oblique ? B.ObliqueOffCenterRHToRef((i = this.orthoLeft) !== null && i !== void 0 ? i : -L, (r = this.orthoRight) !== null && r !== void 0 ? r : L, (o = this.orthoBottom) !== null && o !== void 0 ? o : -I, (a = this.orthoTop) !== null && a !== void 0 ? a : I, C ? this.maxZ : this.minZ, C ? this.minZ : this.maxZ, this.oblique.length, this.oblique.angle, this._computeObliqueDistance(this.oblique.offset), this._projectionMatrix, A.isNDCHalfZRange) : B.OrthoOffCenterRHToRef((s = this.orthoLeft) !== null && s !== void 0 ? s : -L, (l = this.orthoRight) !== null && l !== void 0 ? l : L, (c = this.orthoBottom) !== null && c !== void 0 ? c : -I, (u = this.orthoTop) !== null && u !== void 0 ? u : I, C ? this.maxZ : this.minZ, C ? this.minZ : this.maxZ, this._projectionMatrix, A.isNDCHalfZRange) : this.oblique ? B.ObliqueOffCenterLHToRef((h = this.orthoLeft) !== null && h !== void 0 ? h : -L, (d = this.orthoRight) !== null && d !== void 0 ? d : L, (p = this.orthoBottom) !== null && p !== void 0 ? p : -I, (f = this.orthoTop) !== null && f !== void 0 ? f : I, C ? this.maxZ : this.minZ, C ? this.minZ : this.maxZ, this.oblique.length, this.oblique.angle, this._computeObliqueDistance(this.oblique.offset), this._projectionMatrix, A.isNDCHalfZRange) : B.OrthoOffCenterLHToRef((m = this.orthoLeft) !== null && m !== void 0 ? m : -L, (g = this.orthoRight) !== null && g !== void 0 ? g : L, (y = this.orthoBottom) !== null && y !== void 0 ? y : -I, (b = this.orthoTop) !== null && b !== void 0 ? b : I, C ? this.maxZ : this.minZ, C ? this.minZ : this.maxZ, this._projectionMatrix, A.isNDCHalfZRange), this._cache.orthoLeft = this.orthoLeft, this._cache.orthoRight = this.orthoRight, this._cache.orthoBottom = this.orthoBottom, this._cache.orthoTop = this.orthoTop, this._cache.obliqueAngle = (T = this.oblique) === null || T === void 0 ? void 0 : T.angle, this._cache.obliqueLength = (S = this.oblique) === null || S === void 0 ? void 0 : S.length, this._cache.obliqueOffset = (E = this.oblique) === null || E === void 0 ? void 0 : E.offset, this._cache.renderWidth = A.getRenderWidth(), this._cache.renderHeight = A.getRenderHeight();
        }
        return this.onProjectionMatrixChangedObservable.notifyObservers(this), this._projectionMatrix;
      }, t.prototype.getTransformationMatrix = function() {
        return this._computedViewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix), this._transformMatrix;
      }, t.prototype._computeObliqueDistance = function(e) {
        return (this.radius || (this.target ? v.Distance(this.position, this.target) : this.position.length())) + e;
      }, t.prototype._updateFrustumPlanes = function() {
        this._refreshFrustumPlanes && (this.getTransformationMatrix(), this._frustumPlanes ? ll.GetPlanesToRef(this._transformMatrix, this._frustumPlanes) : this._frustumPlanes = ll.GetPlanes(this._transformMatrix), this._refreshFrustumPlanes = !1);
      }, t.prototype.isInFrustum = function(e, i) {
        if (i === void 0 && (i = !1), this._updateFrustumPlanes(), i && this.rigCameras.length > 0) {
          var r = !1;
          return this.rigCameras.forEach(function(o) {
            o._updateFrustumPlanes(), r = r || e.isInFrustum(o._frustumPlanes);
          }), r;
        }
        return e.isInFrustum(this._frustumPlanes);
      }, t.prototype.isCompletelyInFrustum = function(e) {
        return this._updateFrustumPlanes(), e.isCompletelyInFrustum(this._frustumPlanes);
      }, t.prototype.getForwardRay = function(e, i, r) {
        throw et("Ray");
      }, t.prototype.getForwardRayToRef = function(e, i, r, o) {
        throw et("Ray");
      }, t.prototype.dispose = function(e, i) {
        for (i === void 0 && (i = !1), this.onViewMatrixChangedObservable.clear(), this.onProjectionMatrixChangedObservable.clear(), this.onAfterCheckInputsObservable.clear(), this.onRestoreStateObservable.clear(), this.inputs && this.inputs.clear(), this.getScene().stopAnimation(this), this.getScene().removeCamera(this); this._rigCameras.length > 0; ) {
          var r = this._rigCameras.pop();
          r && r.dispose();
        }
        if (this._parentContainer) {
          var o = this._parentContainer.cameras.indexOf(this);
          o > -1 && this._parentContainer.cameras.splice(o, 1), this._parentContainer = null;
        }
        if (this._rigPostProcess)
          this._rigPostProcess.dispose(this), this._rigPostProcess = null, this._postProcesses.length = 0;
        else if (this.cameraRigMode !== t.RIG_MODE_NONE)
          this._rigPostProcess = null, this._postProcesses.length = 0;
        else
          for (var a = this._postProcesses.length; --a >= 0; ) {
            var s = this._postProcesses[a];
            s && s.dispose(this);
          }
        for (var l = this.customRenderTargets.length; --l >= 0; )
          this.customRenderTargets[l].dispose();
        this.customRenderTargets.length = 0, this._activeMeshes.dispose(), this.getScene().getEngine().releaseRenderPassId(this.renderPassId), n.prototype.dispose.call(this, e, i);
      }, Object.defineProperty(t.prototype, "isLeftCamera", { get: function() {
        return this._isLeftCamera;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isRightCamera", { get: function() {
        return this._isRightCamera;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "leftCamera", { get: function() {
        return this._rigCameras.length < 1 ? null : this._rigCameras[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rightCamera", { get: function() {
        return this._rigCameras.length < 2 ? null : this._rigCameras[1];
      }, enumerable: !1, configurable: !0 }), t.prototype.getLeftTarget = function() {
        return this._rigCameras.length < 1 ? null : this._rigCameras[0].getTarget();
      }, t.prototype.getRightTarget = function() {
        return this._rigCameras.length < 2 ? null : this._rigCameras[1].getTarget();
      }, t.prototype.setCameraRigMode = function(e, i) {
        if (this.cameraRigMode !== e) {
          for (; this._rigCameras.length > 0; ) {
            var r = this._rigCameras.pop();
            r && r.dispose();
          }
          if (this.cameraRigMode = e, this._cameraRigParams = {}, this._cameraRigParams.interaxialDistance = i.interaxialDistance || 0.0637, this._cameraRigParams.stereoHalfAngle = de.ToRadians(this._cameraRigParams.interaxialDistance / 0.0637), this.cameraRigMode !== t.RIG_MODE_NONE) {
            var o = this.createRigCamera(this.name + "_L", 0);
            o && (o._isLeftCamera = !0);
            var a = this.createRigCamera(this.name + "_R", 1);
            a && (a._isRightCamera = !0), o && a && (this._rigCameras.push(o), this._rigCameras.push(a));
          }
          this._setRigMode(i), this._cascadePostProcessesToRigCams(), this.update();
        }
      }, t.prototype._setRigMode = function(e) {
      }, t.prototype._getVRProjectionMatrix = function() {
        return B.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov, this._cameraRigParams.vrMetrics.aspectRatio, this.minZ, this.maxZ, this._cameraRigParams.vrWorkMatrix, !0, this.getEngine().isNDCHalfZRange), this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix, this._projectionMatrix), this._projectionMatrix;
      }, t.prototype.setCameraRigParameter = function(e, i) {
        this._cameraRigParams || (this._cameraRigParams = {}), this._cameraRigParams[e] = i, e === "interaxialDistance" && (this._cameraRigParams.stereoHalfAngle = de.ToRadians(i / 0.0637));
      }, t.prototype.createRigCamera = function(e, i) {
        return null;
      }, t.prototype._updateRigCameras = function() {
        for (var e = 0; e < this._rigCameras.length; e++)
          this._rigCameras[e].minZ = this.minZ, this._rigCameras[e].maxZ = this.maxZ, this._rigCameras[e].fov = this.fov, this._rigCameras[e].upVector.copyFrom(this.upVector);
        this.cameraRigMode === t.RIG_MODE_STEREOSCOPIC_ANAGLYPH && (this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport);
      }, t.prototype._setupInputs = function() {
      }, t.prototype.serialize = function() {
        var e = Ne.Serialize(this);
        return e.uniqueId = this.uniqueId, e.type = this.getClassName(), this.parent && this.parent._serializeAsParent(e), this.inputs && this.inputs.serialize(e), Ne.AppendSerializedAnimations(this, e), e.ranges = this.serializeAnimationRanges(), e.isEnabled = this.isEnabled(), e;
      }, t.prototype.clone = function(e, i) {
        i === void 0 && (i = null);
        var r = Ne.Clone(t.GetConstructorFromName(this.getClassName(), e, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this);
        return r.name = e, r.parent = i, this.onClonedObservable.notifyObservers(r), r;
      }, t.prototype.getDirection = function(e) {
        var i = v.Zero();
        return this.getDirectionToRef(e, i), i;
      }, Object.defineProperty(t.prototype, "absoluteRotation", { get: function() {
        return this.getWorldMatrix().decompose(void 0, this._absoluteRotation), this._absoluteRotation;
      }, enumerable: !1, configurable: !0 }), t.prototype.getDirectionToRef = function(e, i) {
        v.TransformNormalToRef(e, this.getWorldMatrix(), i);
      }, t.GetConstructorFromName = function(e, i, r, o, a) {
        return o === void 0 && (o = 0), a === void 0 && (a = !0), oi.Construct(e, i, r, { interaxial_distance: o, isStereoscopicSideBySide: a }) || function() {
          return t._CreateDefaultParsedCamera(i, r);
        };
      }, t.prototype.computeWorldMatrix = function() {
        return this.getWorldMatrix();
      }, t.Parse = function(e, i) {
        var r = e.type, o = t.GetConstructorFromName(r, e.name, i, e.interaxial_distance, e.isStereoscopicSideBySide), a = Ne.Parse(o, e, i);
        if (e.parentId !== void 0 && (a._waitingParentId = e.parentId), e.parentInstanceIndex !== void 0 && (a._waitingParentInstanceIndex = e.parentInstanceIndex), a.inputs && (a.inputs.parse(e), a._setupInputs()), e.upVector && (a.upVector = v.FromArray(e.upVector)), a.setPosition && (a.position.copyFromFloats(0, 0, 0), a.setPosition(v.FromArray(e.position))), e.target && a.setTarget && a.setTarget(v.FromArray(e.target)), e.cameraRigMode) {
          var s = e.interaxial_distance ? { interaxialDistance: e.interaxial_distance } : {};
          a.setCameraRigMode(e.cameraRigMode, s);
        }
        if (e.animations) {
          for (var l = 0; l < e.animations.length; l++) {
            var c = e.animations[l], u = Kt("BABYLON.Animation");
            u && a.animations.push(u.Parse(c));
          }
          oi.ParseAnimationRanges(a, e, i);
        }
        return e.autoAnimate && i.beginAnimation(a, e.autoAnimateFrom, e.autoAnimateTo, e.autoAnimateLoop, e.autoAnimateSpeed || 1), e.isEnabled !== void 0 && a.setEnabled(e.isEnabled), a;
      }, t.prototype._calculateHandednessMultiplier = function() {
        var e = this.getScene().useRightHandedSystem ? -1 : 1;
        return this.parent && this.parent._getWorldMatrixDeterminant() < 0 && (e *= -1), e;
      }, t._CreateDefaultParsedCamera = function(e, i) {
        throw et("UniversalCamera");
      }, t.PERSPECTIVE_CAMERA = _.PERSPECTIVE_CAMERA, t.ORTHOGRAPHIC_CAMERA = _.ORTHOGRAPHIC_CAMERA, t.FOVMODE_VERTICAL_FIXED = _.FOVMODE_VERTICAL_FIXED, t.FOVMODE_HORIZONTAL_FIXED = _.FOVMODE_HORIZONTAL_FIXED, t.RIG_MODE_NONE = _.RIG_MODE_NONE, t.RIG_MODE_STEREOSCOPIC_ANAGLYPH = _.RIG_MODE_STEREOSCOPIC_ANAGLYPH, t.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = _.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL, t.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = _.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED, t.RIG_MODE_STEREOSCOPIC_OVERUNDER = _.RIG_MODE_STEREOSCOPIC_OVERUNDER, t.RIG_MODE_STEREOSCOPIC_INTERLACED = _.RIG_MODE_STEREOSCOPIC_INTERLACED, t.RIG_MODE_VR = _.RIG_MODE_VR, t.RIG_MODE_CUSTOM = _.RIG_MODE_CUSTOM, t.ForceAttachControlToAlwaysPreventDefault = !1, x([ki("position")], t.prototype, "_position", void 0), x([ki("upVector")], t.prototype, "_upVector", void 0), x([N()], t.prototype, "orthoLeft", null), x([N()], t.prototype, "orthoRight", null), x([N()], t.prototype, "orthoBottom", null), x([N()], t.prototype, "orthoTop", null), x([N()], t.prototype, "fov", void 0), x([N()], t.prototype, "projectionPlaneTilt", void 0), x([N()], t.prototype, "minZ", void 0), x([N()], t.prototype, "maxZ", void 0), x([N()], t.prototype, "inertia", void 0), x([N()], t.prototype, "mode", null), x([N()], t.prototype, "layerMask", void 0), x([N()], t.prototype, "fovMode", void 0), x([N()], t.prototype, "cameraRigMode", void 0), x([N()], t.prototype, "interaxialDistance", void 0), x([N()], t.prototype, "isStereoscopicSideBySide", void 0), t;
    }(oi), Ku = function(n, t, e) {
      this.bu = n, this.bv = t, this.distance = e, this.faceId = 0, this.subMeshId = 0;
    }, cl = function() {
      function n(t, e, i) {
        this.vectors = pt.BuildArray(8, v.Zero), this.center = v.Zero(), this.centerWorld = v.Zero(), this.extendSize = v.Zero(), this.extendSizeWorld = v.Zero(), this.directions = pt.BuildArray(3, v.Zero), this.vectorsWorld = pt.BuildArray(8, v.Zero), this.minimumWorld = v.Zero(), this.maximumWorld = v.Zero(), this.minimum = v.Zero(), this.maximum = v.Zero(), this._drawWrapperFront = null, this._drawWrapperBack = null, this.reConstruct(t, e, i);
      }
      return n.prototype.reConstruct = function(t, e, i) {
        var r = t.x, o = t.y, a = t.z, s = e.x, l = e.y, c = e.z, u = this.vectors;
        this.minimum.copyFromFloats(r, o, a), this.maximum.copyFromFloats(s, l, c), u[0].copyFromFloats(r, o, a), u[1].copyFromFloats(s, l, c), u[2].copyFromFloats(s, o, a), u[3].copyFromFloats(r, l, a), u[4].copyFromFloats(r, o, c), u[5].copyFromFloats(s, l, a), u[6].copyFromFloats(r, l, c), u[7].copyFromFloats(s, o, c), e.addToRef(t, this.center).scaleInPlace(0.5), e.subtractToRef(t, this.extendSize).scaleInPlace(0.5), this._worldMatrix = i || B.IdentityReadOnly, this._update(this._worldMatrix);
      }, n.prototype.scale = function(t) {
        var e = n._TmpVector3, i = this.maximum.subtractToRef(this.minimum, e[0]), r = i.length();
        i.normalizeFromLength(r);
        var o = r * t, a = i.scaleInPlace(0.5 * o), s = this.center.subtractToRef(a, e[1]), l = this.center.addToRef(a, e[2]);
        return this.reConstruct(s, l, this._worldMatrix), this;
      }, n.prototype.getWorldMatrix = function() {
        return this._worldMatrix;
      }, n.prototype._update = function(t) {
        var e = this.minimumWorld, i = this.maximumWorld, r = this.directions, o = this.vectorsWorld, a = this.vectors;
        if (t.isIdentity()) {
          for (e.copyFrom(this.minimum), i.copyFrom(this.maximum), s = 0; s < 8; ++s)
            o[s].copyFrom(a[s]);
          this.extendSizeWorld.copyFrom(this.extendSize), this.centerWorld.copyFrom(this.center);
        } else {
          e.setAll(Number.MAX_VALUE), i.setAll(-Number.MAX_VALUE);
          for (var s = 0; s < 8; ++s) {
            var l = o[s];
            v.TransformCoordinatesToRef(a[s], t, l), e.minimizeInPlace(l), i.maximizeInPlace(l);
          }
          i.subtractToRef(e, this.extendSizeWorld).scaleInPlace(0.5), i.addToRef(e, this.centerWorld).scaleInPlace(0.5);
        }
        v.FromArrayToRef(t.m, 0, r[0]), v.FromArrayToRef(t.m, 4, r[1]), v.FromArrayToRef(t.m, 8, r[2]), this._worldMatrix = t;
      }, n.prototype.isInFrustum = function(t) {
        return n.IsInFrustum(this.vectorsWorld, t);
      }, n.prototype.isCompletelyInFrustum = function(t) {
        return n.IsCompletelyInFrustum(this.vectorsWorld, t);
      }, n.prototype.intersectsPoint = function(t) {
        var e = this.minimumWorld, i = this.maximumWorld, r = e.x, o = e.y, a = e.z, s = i.x, l = i.y, c = i.z, u = t.x, h = t.y, d = t.z, p = -Ge;
        return !(s - u < p || p > u - r || l - h < p || p > h - o || c - d < p || p > d - a);
      }, n.prototype.intersectsSphere = function(t) {
        return n.IntersectsSphere(this.minimumWorld, this.maximumWorld, t.centerWorld, t.radiusWorld);
      }, n.prototype.intersectsMinMax = function(t, e) {
        var i = this.minimumWorld, r = this.maximumWorld, o = i.x, a = i.y, s = i.z, l = r.x, c = r.y, u = r.z, h = t.x, d = t.y, p = t.z, f = e.x, m = e.y, g = e.z;
        return !(l < h || o > f || c < d || a > m || u < p || s > g);
      }, n.prototype.dispose = function() {
        var t, e;
        (t = this._drawWrapperFront) === null || t === void 0 || t.dispose(), (e = this._drawWrapperBack) === null || e === void 0 || e.dispose();
      }, n.Intersects = function(t, e) {
        return t.intersectsMinMax(e.minimumWorld, e.maximumWorld);
      }, n.IntersectsSphere = function(t, e, i, r) {
        var o = n._TmpVector3[0];
        return v.ClampToRef(i, t, e, o), v.DistanceSquared(i, o) <= r * r;
      }, n.IsCompletelyInFrustum = function(t, e) {
        for (var i = 0; i < 6; ++i)
          for (var r = e[i], o = 0; o < 8; ++o)
            if (r.dotCoordinate(t[o]) < 0)
              return !1;
        return !0;
      }, n.IsInFrustum = function(t, e) {
        for (var i = 0; i < 6; ++i) {
          for (var r = !0, o = e[i], a = 0; a < 8; ++a)
            if (o.dotCoordinate(t[a]) >= 0) {
              r = !1;
              break;
            }
          if (r)
            return !1;
        }
        return !0;
      }, n._TmpVector3 = pt.BuildArray(3, v.Zero), n;
    }(), ul = function() {
      function n(t, e, i) {
        this.center = v.Zero(), this.centerWorld = v.Zero(), this.minimum = v.Zero(), this.maximum = v.Zero(), this.reConstruct(t, e, i);
      }
      return n.prototype.reConstruct = function(t, e, i) {
        this.minimum.copyFrom(t), this.maximum.copyFrom(e);
        var r = v.Distance(t, e);
        e.addToRef(t, this.center).scaleInPlace(0.5), this.radius = 0.5 * r, this._update(i || B.IdentityReadOnly);
      }, n.prototype.scale = function(t) {
        var e = this.radius * t, i = n._TmpVector3, r = i[0].setAll(e), o = this.center.subtractToRef(r, i[1]), a = this.center.addToRef(r, i[2]);
        return this.reConstruct(o, a, this._worldMatrix), this;
      }, n.prototype.getWorldMatrix = function() {
        return this._worldMatrix;
      }, n.prototype._update = function(t) {
        if (t.isIdentity())
          this.centerWorld.copyFrom(this.center), this.radiusWorld = this.radius;
        else {
          v.TransformCoordinatesToRef(this.center, t, this.centerWorld);
          var e = n._TmpVector3[0];
          v.TransformNormalFromFloatsToRef(1, 1, 1, t, e), this.radiusWorld = Math.max(Math.abs(e.x), Math.abs(e.y), Math.abs(e.z)) * this.radius;
        }
      }, n.prototype.isInFrustum = function(t) {
        for (var e = this.centerWorld, i = this.radiusWorld, r = 0; r < 6; r++)
          if (t[r].dotCoordinate(e) <= -i)
            return !1;
        return !0;
      }, n.prototype.isCenterInFrustum = function(t) {
        for (var e = this.centerWorld, i = 0; i < 6; i++)
          if (t[i].dotCoordinate(e) < 0)
            return !1;
        return !0;
      }, n.prototype.intersectsPoint = function(t) {
        var e = v.DistanceSquared(this.centerWorld, t);
        return !(this.radiusWorld * this.radiusWorld < e);
      }, n.Intersects = function(t, e) {
        var i = v.DistanceSquared(t.centerWorld, e.centerWorld), r = t.radiusWorld + e.radiusWorld;
        return !(r * r < i);
      }, n.CreateFromCenterAndRadius = function(t, e, i) {
        this._TmpVector3[0].copyFrom(t), this._TmpVector3[1].copyFromFloats(0, 0, e), this._TmpVector3[2].copyFrom(t), this._TmpVector3[0].addInPlace(this._TmpVector3[1]), this._TmpVector3[2].subtractInPlace(this._TmpVector3[1]);
        var r = new n(this._TmpVector3[0], this._TmpVector3[2]);
        return r._worldMatrix = i || B.Identity(), r;
      }, n._TmpVector3 = pt.BuildArray(3, v.Zero), n;
    }(), mg = { min: 0, max: 0 }, gg = { min: 0, max: 0 }, oR = function(n, t, e) {
      var i = v.Dot(t.centerWorld, n), r = Math.abs(v.Dot(t.directions[0], n)) * t.extendSize.x + Math.abs(v.Dot(t.directions[1], n)) * t.extendSize.y + Math.abs(v.Dot(t.directions[2], n)) * t.extendSize.z;
      e.min = i - r, e.max = i + r;
    }, hr = function(n, t, e) {
      return oR(n, t, mg), oR(n, e, gg), !(mg.min > gg.max || gg.min > mg.max);
    }, wr = function() {
      function n(t, e, i) {
        this._isLocked = !1, this.boundingBox = new cl(t, e, i), this.boundingSphere = new ul(t, e, i);
      }
      return n.prototype.reConstruct = function(t, e, i) {
        this.boundingBox.reConstruct(t, e, i), this.boundingSphere.reConstruct(t, e, i);
      }, Object.defineProperty(n.prototype, "minimum", { get: function() {
        return this.boundingBox.minimum;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "maximum", { get: function() {
        return this.boundingBox.maximum;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isLocked", { get: function() {
        return this._isLocked;
      }, set: function(t) {
        this._isLocked = t;
      }, enumerable: !1, configurable: !0 }), n.prototype.update = function(t) {
        this._isLocked || (this.boundingBox._update(t), this.boundingSphere._update(t));
      }, n.prototype.centerOn = function(t, e) {
        var i = n._TmpVector3[0].copyFrom(t).subtractInPlace(e), r = n._TmpVector3[1].copyFrom(t).addInPlace(e);
        return this.boundingBox.reConstruct(i, r, this.boundingBox.getWorldMatrix()), this.boundingSphere.reConstruct(i, r, this.boundingBox.getWorldMatrix()), this;
      }, n.prototype.encapsulate = function(t) {
        var e = v.Minimize(this.minimum, t), i = v.Maximize(this.maximum, t);
        return this.reConstruct(e, i, this.boundingBox.getWorldMatrix()), this;
      }, n.prototype.encapsulateBoundingInfo = function(t) {
        var e = F.Matrix[0];
        this.boundingBox.getWorldMatrix().invertToRef(e);
        var i = F.Vector3[0];
        return v.TransformCoordinatesToRef(t.boundingBox.minimumWorld, e, i), this.encapsulate(i), v.TransformCoordinatesToRef(t.boundingBox.maximumWorld, e, i), this.encapsulate(i), this;
      }, n.prototype.scale = function(t) {
        return this.boundingBox.scale(t), this.boundingSphere.scale(t), this;
      }, n.prototype.isInFrustum = function(t, e) {
        return e === void 0 && (e = _.MESHES_CULLINGSTRATEGY_STANDARD), !(e !== _.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION && e !== _.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY || !this.boundingSphere.isCenterInFrustum(t)) || !!this.boundingSphere.isInFrustum(t) && (!(e !== _.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY && e !== _.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY) || this.boundingBox.isInFrustum(t));
      }, Object.defineProperty(n.prototype, "diagonalLength", { get: function() {
        var t = this.boundingBox;
        return t.maximumWorld.subtractToRef(t.minimumWorld, n._TmpVector3[0]).length();
      }, enumerable: !1, configurable: !0 }), n.prototype.isCompletelyInFrustum = function(t) {
        return this.boundingBox.isCompletelyInFrustum(t);
      }, n.prototype._checkCollision = function(t) {
        return t._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld);
      }, n.prototype.intersectsPoint = function(t) {
        return !!this.boundingSphere.centerWorld && !!this.boundingSphere.intersectsPoint(t) && !!this.boundingBox.intersectsPoint(t);
      }, n.prototype.intersects = function(t, e) {
        if (!ul.Intersects(this.boundingSphere, t.boundingSphere) || !cl.Intersects(this.boundingBox, t.boundingBox))
          return !1;
        if (!e)
          return !0;
        var i = this.boundingBox, r = t.boundingBox;
        return !!(hr(i.directions[0], i, r) && hr(i.directions[1], i, r) && hr(i.directions[2], i, r) && hr(r.directions[0], i, r) && hr(r.directions[1], i, r) && hr(r.directions[2], i, r) && hr(v.Cross(i.directions[0], r.directions[0]), i, r) && hr(v.Cross(i.directions[0], r.directions[1]), i, r) && hr(v.Cross(i.directions[0], r.directions[2]), i, r) && hr(v.Cross(i.directions[1], r.directions[0]), i, r) && hr(v.Cross(i.directions[1], r.directions[1]), i, r) && hr(v.Cross(i.directions[1], r.directions[2]), i, r) && hr(v.Cross(i.directions[2], r.directions[0]), i, r) && hr(v.Cross(i.directions[2], r.directions[1]), i, r) && hr(v.Cross(i.directions[2], r.directions[2]), i, r));
      }, n._TmpVector3 = pt.BuildArray(2, v.Zero), n;
    }(), aR = function() {
      function n() {
      }
      return n.extractMinAndMaxIndexed = function(t, e, i, r, o, a) {
        for (var s = i; s < i + r; s++) {
          var l = 3 * e[s], c = t[l], u = t[l + 1], h = t[l + 2];
          o.minimizeInPlaceFromFloats(c, u, h), a.maximizeInPlaceFromFloats(c, u, h);
        }
      }, n.extractMinAndMax = function(t, e, i, r, o, a) {
        for (var s = e, l = e * r; s < e + i; s++, l += r) {
          var c = t[l], u = t[l + 1], h = t[l + 2];
          o.minimizeInPlaceFromFloats(c, u, h), a.maximizeInPlaceFromFloats(c, u, h);
        }
      }, x([ea.filter(function() {
        for (var t = [], e = 0; e < arguments.length; e++)
          t[e] = arguments[e];
        var i = t[0], r = t[1];
        return !Array.isArray(i) && !Array.isArray(r);
      })], n, "extractMinAndMaxIndexed", null), x([ea.filter(function() {
        for (var t = [], e = 0; e < arguments.length; e++)
          t[e] = arguments[e];
        var i = t[0];
        return !Array.isArray(i);
      })], n, "extractMinAndMax", null), n;
    }();
    function vg(n, t, e, i, r) {
      r === void 0 && (r = null);
      var o = new v(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), a = new v(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
      return aR.extractMinAndMaxIndexed(n, t, e, i, o, a), r && (o.x -= o.x * r.x + r.y, o.y -= o.y * r.x + r.y, o.z -= o.z * r.x + r.y, a.x += a.x * r.x + r.y, a.y += a.y * r.x + r.y, a.z += a.z * r.x + r.y), { minimum: o, maximum: a };
    }
    function hl(n, t, e, i, r) {
      i === void 0 && (i = null);
      var o = new v(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), a = new v(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
      return r || (r = 3), aR.extractMinAndMax(n, t, e, r, o, a), i && (o.x -= o.x * i.x + i.y, o.y -= o.y * i.x + i.y, o.z -= o.z * i.x + i.y, a.x += a.x * i.x + i.y, a.y += a.y * i.x + i.y, a.z += a.z * i.x + i.y), { minimum: o, maximum: a };
    }
    var Yn = function() {
      function n(t, e, i, r, o, a, s, l, c) {
        l === void 0 && (l = !0), c === void 0 && (c = !0), this.materialIndex = t, this.verticesStart = e, this.verticesCount = i, this.indexStart = r, this.indexCount = o, this._mainDrawWrapperOverride = null, this._linesIndexCount = 0, this._linesIndexBuffer = null, this._lastColliderWorldVertices = null, this._lastColliderTransformMatrix = null, this._wasDispatched = !1, this._renderId = 0, this._alphaIndex = 0, this._distanceToCamera = 0, this._currentMaterial = null, this._mesh = a, this._renderingMesh = s || a, c && a.subMeshes.push(this), this._engine = this._mesh.getScene().getEngine(), this.resetDrawCache(), this._trianglePlanes = [], this._id = a.subMeshes.length - 1, l && (this.refreshBoundingInfo(), a.computeWorldMatrix(!0));
      }
      return Object.defineProperty(n.prototype, "materialDefines", { get: function() {
        var t;
        return this._mainDrawWrapperOverride ? this._mainDrawWrapperOverride.defines : (t = this._getDrawWrapper()) === null || t === void 0 ? void 0 : t.defines;
      }, set: function(t) {
        var e;
        ((e = this._mainDrawWrapperOverride) !== null && e !== void 0 ? e : this._getDrawWrapper(void 0, !0)).defines = t;
      }, enumerable: !1, configurable: !0 }), n.prototype._getDrawWrapper = function(t, e) {
        e === void 0 && (e = !1), t = t ?? this._engine.currentRenderPassId;
        var i = this._drawWrappers[t];
        return !i && e && (this._drawWrappers[t] = i = new Ei(this._mesh.getScene().getEngine())), i;
      }, n.prototype._removeDrawWrapper = function(t, e) {
        var i;
        e === void 0 && (e = !0), e && ((i = this._drawWrappers[t]) === null || i === void 0 || i.dispose()), this._drawWrappers[t] = void 0;
      }, Object.defineProperty(n.prototype, "effect", { get: function() {
        var t, e;
        return this._mainDrawWrapperOverride ? this._mainDrawWrapperOverride.effect : (e = (t = this._getDrawWrapper()) === null || t === void 0 ? void 0 : t.effect) !== null && e !== void 0 ? e : null;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "_drawWrapper", { get: function() {
        var t;
        return (t = this._mainDrawWrapperOverride) !== null && t !== void 0 ? t : this._getDrawWrapper(void 0, !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "_drawWrapperOverride", { get: function() {
        return this._mainDrawWrapperOverride;
      }, enumerable: !1, configurable: !0 }), n.prototype._setMainDrawWrapperOverride = function(t) {
        this._mainDrawWrapperOverride = t;
      }, n.prototype.setEffect = function(t, e, i, r) {
        e === void 0 && (e = null), r === void 0 && (r = !0);
        var o = this._drawWrapper;
        o.setEffect(t, e, r), i !== void 0 && (o.materialContext = i), t || (o.defines = null, o.materialContext = void 0);
      }, n.prototype.resetDrawCache = function(t) {
        if (this._drawWrappers) {
          if (t !== void 0)
            return void this._removeDrawWrapper(t);
          for (var e = 0, i = this._drawWrappers; e < i.length; e++) {
            var r = i[e];
            r == null || r.dispose();
          }
        }
        this._drawWrappers = [];
      }, n.AddToMesh = function(t, e, i, r, o, a, s, l) {
        return l === void 0 && (l = !0), new n(t, e, i, r, o, a, s, l);
      }, Object.defineProperty(n.prototype, "IsGlobal", { get: function() {
        return this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices() && this.indexStart === 0 && this.indexCount === this._mesh.getTotalIndices();
      }, enumerable: !1, configurable: !0 }), n.prototype.getBoundingInfo = function() {
        return this.IsGlobal || this._mesh.hasThinInstances ? this._mesh.getBoundingInfo() : this._boundingInfo;
      }, n.prototype.setBoundingInfo = function(t) {
        return this._boundingInfo = t, this;
      }, n.prototype.getMesh = function() {
        return this._mesh;
      }, n.prototype.getRenderingMesh = function() {
        return this._renderingMesh;
      }, n.prototype.getReplacementMesh = function() {
        return this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : null;
      }, n.prototype.getEffectiveMesh = function() {
        return (this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : null) || this._renderingMesh;
      }, n.prototype.getMaterial = function(t) {
        var e;
        t === void 0 && (t = !0);
        var i = (e = this._renderingMesh.getMaterialForRenderPass(this._engine.currentRenderPassId)) !== null && e !== void 0 ? e : this._renderingMesh.material;
        if (!i)
          return t ? this._mesh.getScene().defaultMaterial : null;
        if (this._isMultiMaterial(i)) {
          var r = i.getSubMaterial(this.materialIndex);
          return this._currentMaterial !== r && (this._currentMaterial = r, this.resetDrawCache()), r;
        }
        return i;
      }, n.prototype._isMultiMaterial = function(t) {
        return t.getSubMaterial !== void 0;
      }, n.prototype.refreshBoundingInfo = function(t) {
        if (t === void 0 && (t = null), this._lastColliderWorldVertices = null, this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry)
          return this;
        if (t || (t = this._renderingMesh.getVerticesData(P.PositionKind)), !t)
          return this._boundingInfo = this._mesh.getBoundingInfo(), this;
        var e, i = this._renderingMesh.getIndices();
        if (this.indexStart === 0 && this.indexCount === i.length) {
          var r = this._renderingMesh.getBoundingInfo();
          e = { minimum: r.minimum.clone(), maximum: r.maximum.clone() };
        } else
          e = vg(t, i, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);
        return this._boundingInfo ? this._boundingInfo.reConstruct(e.minimum, e.maximum) : this._boundingInfo = new wr(e.minimum, e.maximum), this;
      }, n.prototype._checkCollision = function(t) {
        return this.getBoundingInfo()._checkCollision(t);
      }, n.prototype.updateBoundingInfo = function(t) {
        var e = this.getBoundingInfo();
        return e || (this.refreshBoundingInfo(), e = this.getBoundingInfo()), e && e.update(t), this;
      }, n.prototype.isInFrustum = function(t) {
        var e = this.getBoundingInfo();
        return !!e && e.isInFrustum(t, this._mesh.cullingStrategy);
      }, n.prototype.isCompletelyInFrustum = function(t) {
        var e = this.getBoundingInfo();
        return !!e && e.isCompletelyInFrustum(t);
      }, n.prototype.render = function(t) {
        return this._renderingMesh.render(this, t, this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : void 0), this;
      }, n.prototype._getLinesIndexBuffer = function(t, e) {
        if (!this._linesIndexBuffer) {
          for (var i = [], r = this.indexStart; r < this.indexStart + this.indexCount; r += 3)
            i.push(t[r], t[r + 1], t[r + 1], t[r + 2], t[r + 2], t[r]);
          this._linesIndexBuffer = e.createIndexBuffer(i), this._linesIndexCount = i.length;
        }
        return this._linesIndexBuffer;
      }, n.prototype.canIntersects = function(t) {
        var e = this.getBoundingInfo();
        return !!e && t.intersectsBox(e.boundingBox);
      }, n.prototype.intersects = function(t, e, i, r, o) {
        var a = this.getMaterial();
        if (!a)
          return null;
        var s = 3, l = !1;
        switch (a.fillMode) {
          case _.MATERIAL_PointListDrawMode:
          case _.MATERIAL_LineLoopDrawMode:
          case _.MATERIAL_LineStripDrawMode:
          case _.MATERIAL_TriangleFanDrawMode:
            return null;
          case _.MATERIAL_TriangleStripDrawMode:
            s = 1, l = !0;
        }
        return a.fillMode === _.MATERIAL_LineListDrawMode ? i.length ? this._intersectLines(t, e, i, this._mesh.intersectionThreshold, r) : this._intersectUnIndexedLines(t, e, i, this._mesh.intersectionThreshold, r) : !i.length && this._mesh._unIndexed ? this._intersectUnIndexedTriangles(t, e, i, r, o) : this._intersectTriangles(t, e, i, s, l, r, o);
      }, n.prototype._intersectLines = function(t, e, i, r, o) {
        for (var a = null, s = this.indexStart; s < this.indexStart + this.indexCount; s += 2) {
          var l = e[i[s]], c = e[i[s + 1]], u = t.intersectionSegment(l, c, r);
          if (!(u < 0) && (o || !a || u < a.distance) && ((a = new Ku(null, null, u)).faceId = s / 2, o))
            break;
        }
        return a;
      }, n.prototype._intersectUnIndexedLines = function(t, e, i, r, o) {
        for (var a = null, s = this.verticesStart; s < this.verticesStart + this.verticesCount; s += 2) {
          var l = e[s], c = e[s + 1], u = t.intersectionSegment(l, c, r);
          if (!(u < 0) && (o || !a || u < a.distance) && ((a = new Ku(null, null, u)).faceId = s / 2, o))
            break;
        }
        return a;
      }, n.prototype._intersectTriangles = function(t, e, i, r, o, a, s) {
        for (var l = null, c = -1, u = this.indexStart; u < this.indexStart + this.indexCount - (3 - r); u += r) {
          c++;
          var h = i[u], d = i[u + 1], p = i[u + 2];
          if (o && p === 4294967295)
            u += 2;
          else {
            var f = e[h], m = e[d], g = e[p];
            if (f && m && g && (!s || s(f, m, g, t, h, d, p))) {
              var y = t.intersectsTriangle(f, m, g);
              if (y) {
                if (y.distance < 0)
                  continue;
                if ((a || !l || y.distance < l.distance) && ((l = y).faceId = c, a))
                  break;
              }
            }
          }
        }
        return l;
      }, n.prototype._intersectUnIndexedTriangles = function(t, e, i, r, o) {
        for (var a = null, s = this.verticesStart; s < this.verticesStart + this.verticesCount; s += 3) {
          var l = e[s], c = e[s + 1], u = e[s + 2];
          if (!o || o(l, c, u, t, -1, -1, -1)) {
            var h = t.intersectsTriangle(l, c, u);
            if (h) {
              if (h.distance < 0)
                continue;
              if ((r || !a || h.distance < a.distance) && ((a = h).faceId = s / 3, r))
                break;
            }
          }
        }
        return a;
      }, n.prototype._rebuild = function() {
        this._linesIndexBuffer && (this._linesIndexBuffer = null);
      }, n.prototype.clone = function(t, e) {
        var i = new n(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, t, e, !1);
        if (!this.IsGlobal) {
          var r = this.getBoundingInfo();
          if (!r)
            return i;
          i._boundingInfo = new wr(r.minimum, r.maximum);
        }
        return i;
      }, n.prototype.dispose = function() {
        this._linesIndexBuffer && (this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer), this._linesIndexBuffer = null);
        var t = this._mesh.subMeshes.indexOf(this);
        this._mesh.subMeshes.splice(t, 1), this.resetDrawCache();
      }, n.prototype.getClassName = function() {
        return "SubMesh";
      }, n.CreateFromIndices = function(t, e, i, r, o, a) {
        a === void 0 && (a = !0);
        for (var s = Number.MAX_VALUE, l = -Number.MAX_VALUE, c = (o || r).getIndices(), u = e; u < e + i; u++) {
          var h = c[u];
          h < s && (s = h), h > l && (l = h);
        }
        return new n(t, s, l - s + 1, e, i, r, o, a);
      }, n;
    }(), lc = function() {
    }, Oe = function() {
      function n() {
        this.uniqueId = 0, this.metadata = {}, this._applyTo = _g(this._applyToCoroutine.bind(this)), this.uniqueId = n._UniqueIDGenerator, n._UniqueIDGenerator++;
      }
      return n.prototype.set = function(t, e) {
        switch (t.length || q.Warn("Setting vertex data kind '".concat(e, "' with an empty array")), e) {
          case P.PositionKind:
            this.positions = t;
            break;
          case P.NormalKind:
            this.normals = t;
            break;
          case P.TangentKind:
            this.tangents = t;
            break;
          case P.UVKind:
            this.uvs = t;
            break;
          case P.UV2Kind:
            this.uvs2 = t;
            break;
          case P.UV3Kind:
            this.uvs3 = t;
            break;
          case P.UV4Kind:
            this.uvs4 = t;
            break;
          case P.UV5Kind:
            this.uvs5 = t;
            break;
          case P.UV6Kind:
            this.uvs6 = t;
            break;
          case P.ColorKind:
            this.colors = t;
            break;
          case P.MatricesIndicesKind:
            this.matricesIndices = t;
            break;
          case P.MatricesWeightsKind:
            this.matricesWeights = t;
            break;
          case P.MatricesIndicesExtraKind:
            this.matricesIndicesExtra = t;
            break;
          case P.MatricesWeightsExtraKind:
            this.matricesWeightsExtra = t;
        }
      }, n.prototype.applyToMesh = function(t, e) {
        return this._applyTo(t, e, !1), this;
      }, n.prototype.applyToGeometry = function(t, e) {
        return this._applyTo(t, e, !1), this;
      }, n.prototype.updateMesh = function(t) {
        return this._update(t), this;
      }, n.prototype.updateGeometry = function(t) {
        return this._update(t), this;
      }, n.prototype._applyToCoroutine = function(t, e, i) {
        var r, o, a, s;
        return e === void 0 && (e = !1), Bt(this, function(l) {
          switch (l.label) {
            case 0:
              return this.positions ? (t.setVerticesData(P.PositionKind, this.positions, e), i ? [4] : [3, 2]) : [3, 2];
            case 1:
              l.sent(), l.label = 2;
            case 2:
              return this.normals ? (t.setVerticesData(P.NormalKind, this.normals, e), i ? [4] : [3, 4]) : [3, 4];
            case 3:
              l.sent(), l.label = 4;
            case 4:
              return this.tangents ? (t.setVerticesData(P.TangentKind, this.tangents, e), i ? [4] : [3, 6]) : [3, 6];
            case 5:
              l.sent(), l.label = 6;
            case 6:
              return this.uvs ? (t.setVerticesData(P.UVKind, this.uvs, e), i ? [4] : [3, 8]) : [3, 8];
            case 7:
              l.sent(), l.label = 8;
            case 8:
              return this.uvs2 ? (t.setVerticesData(P.UV2Kind, this.uvs2, e), i ? [4] : [3, 10]) : [3, 10];
            case 9:
              l.sent(), l.label = 10;
            case 10:
              return this.uvs3 ? (t.setVerticesData(P.UV3Kind, this.uvs3, e), i ? [4] : [3, 12]) : [3, 12];
            case 11:
              l.sent(), l.label = 12;
            case 12:
              return this.uvs4 ? (t.setVerticesData(P.UV4Kind, this.uvs4, e), i ? [4] : [3, 14]) : [3, 14];
            case 13:
              l.sent(), l.label = 14;
            case 14:
              return this.uvs5 ? (t.setVerticesData(P.UV5Kind, this.uvs5, e), i ? [4] : [3, 16]) : [3, 16];
            case 15:
              l.sent(), l.label = 16;
            case 16:
              return this.uvs6 ? (t.setVerticesData(P.UV6Kind, this.uvs6, e), i ? [4] : [3, 18]) : [3, 18];
            case 17:
              l.sent(), l.label = 18;
            case 18:
              return this.colors ? (t.setVerticesData(P.ColorKind, this.colors, e), i ? [4] : [3, 20]) : [3, 20];
            case 19:
              l.sent(), l.label = 20;
            case 20:
              return this.matricesIndices ? (t.setVerticesData(P.MatricesIndicesKind, this.matricesIndices, e), i ? [4] : [3, 22]) : [3, 22];
            case 21:
              l.sent(), l.label = 22;
            case 22:
              return this.matricesWeights ? (t.setVerticesData(P.MatricesWeightsKind, this.matricesWeights, e), i ? [4] : [3, 24]) : [3, 24];
            case 23:
              l.sent(), l.label = 24;
            case 24:
              return this.matricesIndicesExtra ? (t.setVerticesData(P.MatricesIndicesExtraKind, this.matricesIndicesExtra, e), i ? [4] : [3, 26]) : [3, 26];
            case 25:
              l.sent(), l.label = 26;
            case 26:
              return this.matricesWeightsExtra ? (t.setVerticesData(P.MatricesWeightsExtraKind, this.matricesWeightsExtra, e), i ? [4] : [3, 28]) : [3, 28];
            case 27:
              l.sent(), l.label = 28;
            case 28:
              return this.indices ? (t.setIndices(this.indices, null, e), i ? [4] : [3, 30]) : [3, 31];
            case 29:
              l.sent(), l.label = 30;
            case 30:
              return [3, 32];
            case 31:
              t.setIndices([], null), l.label = 32;
            case 32:
              if (t.subMeshes && this.materialInfos && this.materialInfos.length > 1)
                for ((r = t).subMeshes = [], o = 0, a = this.materialInfos; o < a.length; o++)
                  s = a[o], new Yn(s.materialIndex, s.verticesStart, s.verticesCount, s.indexStart, s.indexCount, r);
              return [2, this];
          }
        });
      }, n.prototype._update = function(t, e, i) {
        return this.positions && t.updateVerticesData(P.PositionKind, this.positions, e, i), this.normals && t.updateVerticesData(P.NormalKind, this.normals, e, i), this.tangents && t.updateVerticesData(P.TangentKind, this.tangents, e, i), this.uvs && t.updateVerticesData(P.UVKind, this.uvs, e, i), this.uvs2 && t.updateVerticesData(P.UV2Kind, this.uvs2, e, i), this.uvs3 && t.updateVerticesData(P.UV3Kind, this.uvs3, e, i), this.uvs4 && t.updateVerticesData(P.UV4Kind, this.uvs4, e, i), this.uvs5 && t.updateVerticesData(P.UV5Kind, this.uvs5, e, i), this.uvs6 && t.updateVerticesData(P.UV6Kind, this.uvs6, e, i), this.colors && t.updateVerticesData(P.ColorKind, this.colors, e, i), this.matricesIndices && t.updateVerticesData(P.MatricesIndicesKind, this.matricesIndices, e, i), this.matricesWeights && t.updateVerticesData(P.MatricesWeightsKind, this.matricesWeights, e, i), this.matricesIndicesExtra && t.updateVerticesData(P.MatricesIndicesExtraKind, this.matricesIndicesExtra, e, i), this.matricesWeightsExtra && t.updateVerticesData(P.MatricesWeightsExtraKind, this.matricesWeightsExtra, e, i), this.indices && t.setIndices(this.indices, null), this;
      }, n._TransformVector3Coordinates = function(t, e, i, r) {
        i === void 0 && (i = 0), r === void 0 && (r = t.length);
        for (var o = F.Vector3[0], a = F.Vector3[1], s = i; s < i + r; s += 3)
          v.FromArrayToRef(t, s, o), v.TransformCoordinatesToRef(o, e, a), t[s] = a.x, t[s + 1] = a.y, t[s + 2] = a.z;
      }, n._TransformVector3Normals = function(t, e, i, r) {
        i === void 0 && (i = 0), r === void 0 && (r = t.length);
        for (var o = F.Vector3[0], a = F.Vector3[1], s = i; s < i + r; s += 3)
          v.FromArrayToRef(t, s, o), v.TransformNormalToRef(o, e, a), t[s] = a.x, t[s + 1] = a.y, t[s + 2] = a.z;
      }, n._TransformVector4Normals = function(t, e, i, r) {
        i === void 0 && (i = 0), r === void 0 && (r = t.length);
        for (var o = F.Vector4[0], a = F.Vector4[1], s = i; s < i + r; s += 4)
          lt.FromArrayToRef(t, s, o), lt.TransformNormalToRef(o, e, a), t[s] = a.x, t[s + 1] = a.y, t[s + 2] = a.z, t[s + 3] = a.w;
      }, n._FlipFaces = function(t, e, i) {
        e === void 0 && (e = 0), i === void 0 && (i = t.length);
        for (var r = e; r < e + i; r += 3) {
          var o = t[r + 1];
          t[r + 1] = t[r + 2], t[r + 2] = o;
        }
      }, n.prototype.transform = function(t) {
        var e = t.determinant() < 0;
        return this.positions && n._TransformVector3Coordinates(this.positions, t), this.normals && n._TransformVector3Normals(this.normals, t), this.tangents && n._TransformVector4Normals(this.tangents, t), e && this.indices && n._FlipFaces(this.indices), this;
      }, n.prototype.splitBasedOnMaterialID = function() {
        if (!this.materialInfos || this.materialInfos.length < 2)
          return [this];
        for (var t = [], e = 0, i = this.materialInfos; e < i.length; e++) {
          var r = i[e], o = new n();
          if (this.positions && (o.positions = this.positions.slice(3 * r.verticesStart, 3 * (r.verticesCount + r.verticesStart))), this.normals && (o.normals = this.normals.slice(3 * r.verticesStart, 3 * (r.verticesCount + r.verticesStart))), this.tangents && (o.tangents = this.tangents.slice(4 * r.verticesStart, 4 * (r.verticesCount + r.verticesStart))), this.colors && (o.colors = this.colors.slice(4 * r.verticesStart, 4 * (r.verticesCount + r.verticesStart))), this.uvs && (o.uvs = this.uvs.slice(2 * r.verticesStart, 2 * (r.verticesCount + r.verticesStart))), this.uvs2 && (o.uvs2 = this.uvs2.slice(2 * r.verticesStart, 2 * (r.verticesCount + r.verticesStart))), this.uvs3 && (o.uvs3 = this.uvs3.slice(2 * r.verticesStart, 2 * (r.verticesCount + r.verticesStart))), this.uvs4 && (o.uvs4 = this.uvs4.slice(2 * r.verticesStart, 2 * (r.verticesCount + r.verticesStart))), this.uvs5 && (o.uvs5 = this.uvs5.slice(2 * r.verticesStart, 2 * (r.verticesCount + r.verticesStart))), this.uvs6 && (o.uvs6 = this.uvs6.slice(2 * r.verticesStart, 2 * (r.verticesCount + r.verticesStart))), this.matricesIndices && (o.matricesIndices = this.matricesIndices.slice(4 * r.verticesStart, 4 * (r.verticesCount + r.verticesStart))), this.matricesIndicesExtra && (o.matricesIndicesExtra = this.matricesIndicesExtra.slice(4 * r.verticesStart, 4 * (r.verticesCount + r.verticesStart))), this.matricesWeights && (o.matricesWeights = this.matricesWeights.slice(4 * r.verticesStart, 4 * (r.verticesCount + r.verticesStart))), this.matricesWeightsExtra && (o.matricesWeightsExtra = this.matricesWeightsExtra.slice(4 * r.verticesStart, 4 * (r.verticesCount + r.verticesStart))), this.indices) {
            o.indices = [];
            for (var a = r.indexStart; a < r.indexStart + r.indexCount; a++)
              o.indices.push(this.indices[a] - r.verticesStart);
          }
          var s = new lc();
          s.indexStart = 0, s.indexCount = o.indices ? o.indices.length : 0, s.materialIndex = r.materialIndex, s.verticesStart = 0, s.verticesCount = (o.positions ? o.positions.length : 0) / 3, o.materialInfos = [s], t.push(o);
        }
        return t;
      }, n.prototype.merge = function(t, e, i, r, o) {
        e === void 0 && (e = !1), i === void 0 && (i = !1), r === void 0 && (r = !1), o === void 0 && (o = !1);
        var a = Array.isArray(t) ? t.map(function(s) {
          return { vertexData: s };
        }) : [{ vertexData: t }];
        return ju(this._mergeCoroutine(void 0, a, e, !1, i, r, o));
      }, n.prototype._mergeCoroutine = function(t, e, i, r, o, a, s) {
        var l, c, u, h, d, p, f, m, g, y, b, T, S, E, A, R, C, L, I, O, w, z, V, Y, ee, J, X, K, te, se, _e, xe, Te, he, me, Fe, Ce, Re, Be, De;
        return i === void 0 && (i = !1), a === void 0 && (a = !1), s === void 0 && (s = !1), Bt(this, function(Ke) {
          switch (Ke.label) {
            case 0:
              for (this._validate(), l = e.map(function(ge) {
                return ge.vertexData;
              }), c = this, u = 0, h = l; u < h.length; u++)
                if (he = h[u]) {
                  if (he._validate(), s)
                    !this.normals != !he.normals && (this.normals ? he.normals = new Float32Array(he.positions.length) : this.normals = new Float32Array(this.positions.length)), !this.tangents != !he.tangents && (this.tangents ? he.tangents = new Float32Array(he.positions.length / 3 * 4) : this.tangents = new Float32Array(this.positions.length / 3 * 4)), !this.uvs != !he.uvs && (this.uvs ? he.uvs = new Float32Array(he.positions.length / 3 * 2) : this.uvs = new Float32Array(this.positions.length / 3 * 2)), !this.uvs2 != !he.uvs2 && (this.uvs2 ? he.uvs2 = new Float32Array(he.positions.length / 3 * 2) : this.uvs2 = new Float32Array(this.positions.length / 3 * 2)), !this.uvs3 != !he.uvs3 && (this.uvs3 ? he.uvs3 = new Float32Array(he.positions.length / 3 * 2) : this.uvs3 = new Float32Array(this.positions.length / 3 * 2)), !this.uvs4 != !he.uvs4 && (this.uvs4 ? he.uvs4 = new Float32Array(he.positions.length / 3 * 2) : this.uvs4 = new Float32Array(this.positions.length / 3 * 2)), !this.uvs5 != !he.uvs5 && (this.uvs5 ? he.uvs5 = new Float32Array(he.positions.length / 3 * 2) : this.uvs5 = new Float32Array(this.positions.length / 3 * 2)), !this.uvs6 != !he.uvs6 && (this.uvs6 ? he.uvs6 = new Float32Array(he.positions.length / 3 * 2) : this.uvs6 = new Float32Array(this.positions.length / 3 * 2)), !this.colors != !he.colors && (this.colors ? (he.colors = new Float32Array(he.positions.length / 3 * 4), he.colors.fill(1)) : (this.colors = new Float32Array(this.positions.length / 3 * 4), this.colors.fill(1))), !this.matricesIndices != !he.matricesIndices && (this.matricesIndices ? he.matricesIndices = new Float32Array(he.positions.length / 3 * 4) : this.matricesIndices = new Float32Array(this.positions.length / 3 * 4)), !this.matricesWeights != !he.matricesWeights && (this.matricesWeights ? he.matricesWeights = new Float32Array(he.positions.length / 3 * 4) : this.matricesWeights = new Float32Array(this.positions.length / 3 * 4)), !this.matricesIndicesExtra != !he.matricesIndicesExtra && (this.matricesIndicesExtra ? he.matricesIndicesExtra = new Float32Array(he.positions.length / 3 * 4) : this.matricesIndicesExtra = new Float32Array(this.positions.length / 3 * 4)), !this.matricesWeightsExtra != !he.matricesWeightsExtra && (this.matricesWeightsExtra ? he.matricesWeightsExtra = new Float32Array(he.positions.length / 3 * 4) : this.matricesWeightsExtra = new Float32Array(this.positions.length / 3 * 4));
                  else if (!this.normals != !he.normals || !this.tangents != !he.tangents || !this.uvs != !he.uvs || !this.uvs2 != !he.uvs2 || !this.uvs3 != !he.uvs3 || !this.uvs4 != !he.uvs4 || !this.uvs5 != !he.uvs5 || !this.uvs6 != !he.uvs6 || !this.colors != !he.colors || !this.matricesIndices != !he.matricesIndices || !this.matricesWeights != !he.matricesWeights || !this.matricesIndicesExtra != !he.matricesIndicesExtra || !this.matricesWeightsExtra != !he.matricesWeightsExtra)
                    throw new Error("Cannot merge vertex data that do not have the same set of attributes");
                }
              if (a) {
                for (d = 0, p = 0, f = 0, m = [], g = null, y = [], b = 0, T = this.splitBasedOnMaterialID(); b < T.length; b++)
                  L = T[b], y.push({ vertexData: L, transform: t });
                for (S = 0, E = e; S < E.length; S++)
                  if ((A = E[S]).vertexData)
                    for (R = 0, C = A.vertexData.splitBasedOnMaterialID(); R < C.length; R++)
                      L = C[R], y.push({ vertexData: L, transform: A.transform });
                for (y.sort(function(ge, rt) {
                  var it = ge.vertexData.materialInfos ? ge.vertexData.materialInfos[0].materialIndex : 0, He = rt.vertexData.materialInfos ? rt.vertexData.materialInfos[0].materialIndex : 0;
                  return it > He ? 1 : it === He ? 0 : -1;
                }), I = 0, O = y; I < O.length; I++)
                  w = O[I], z = w.vertexData, d = z.materialInfos ? z.materialInfos[0].materialIndex : 0, g && g.materialIndex === d ? (g.indexCount += z.indices.length, g.verticesCount += z.positions.length / 3) : ((V = new lc()).materialIndex = d, V.indexStart = p, V.indexCount = z.indices.length, V.verticesStart = f, V.verticesCount = z.positions.length / 3, m.push(V), g = V), p += z.indices.length, f += z.positions.length / 3;
                Y = y.splice(0, 1)[0], c = Y.vertexData, t = Y.transform, l = y.map(function(ge) {
                  return ge.vertexData;
                }), e = y, this.materialInfos = m;
              }
              if (ee = l.reduce(function(ge, rt) {
                var it, He;
                return ge + ((He = (it = rt.indices) === null || it === void 0 ? void 0 : it.length) !== null && He !== void 0 ? He : 0);
              }, (Re = (Ce = c.indices) === null || Ce === void 0 ? void 0 : Ce.length) !== null && Re !== void 0 ? Re : 0), J = o || l.some(function(ge) {
                return ge.indices === c.indices;
              }), X = J ? (Be = c.indices) === null || Be === void 0 ? void 0 : Be.slice() : c.indices, !(ee > 0))
                return [3, 4];
              K = (De = X == null ? void 0 : X.length) !== null && De !== void 0 ? De : 0, X || (X = new Array(ee)), X.length !== ee && (Array.isArray(X) ? X.length = ee : ((te = i || X instanceof Uint32Array ? new Uint32Array(ee) : new Uint16Array(ee)).set(X), X = te), t && t.determinant() < 0 && n._FlipFaces(X, 0, K)), se = c.positions ? c.positions.length / 3 : 0, _e = 0, xe = e, Ke.label = 1;
            case 1:
              if (!(_e < xe.length))
                return [3, 4];
              if (Te = xe[_e], he = Te.vertexData, me = Te.transform, !he.indices)
                return [3, 3];
              for (Fe = 0; Fe < he.indices.length; Fe++)
                X[K + Fe] = he.indices[Fe] + se;
              return me && me.determinant() < 0 && n._FlipFaces(X, K, he.indices.length), se += he.positions.length / 3, K += he.indices.length, r ? [4] : [3, 3];
            case 2:
              Ke.sent(), Ke.label = 3;
            case 3:
              return _e++, [3, 1];
            case 4:
              return this.indices = X, this.positions = n._MergeElement(P.PositionKind, c.positions, t, e.map(function(ge) {
                return [ge.vertexData.positions, ge.transform];
              })), r ? [4] : [3, 6];
            case 5:
              Ke.sent(), Ke.label = 6;
            case 6:
              return c.normals ? (this.normals = n._MergeElement(P.NormalKind, c.normals, t, e.map(function(ge) {
                return [ge.vertexData.normals, ge.transform];
              })), r ? [4] : [3, 8]) : [3, 8];
            case 7:
              Ke.sent(), Ke.label = 8;
            case 8:
              return c.tangents ? (this.tangents = n._MergeElement(P.TangentKind, c.tangents, t, e.map(function(ge) {
                return [ge.vertexData.tangents, ge.transform];
              })), r ? [4] : [3, 10]) : [3, 10];
            case 9:
              Ke.sent(), Ke.label = 10;
            case 10:
              return c.uvs ? (this.uvs = n._MergeElement(P.UVKind, c.uvs, t, e.map(function(ge) {
                return [ge.vertexData.uvs, ge.transform];
              })), r ? [4] : [3, 12]) : [3, 12];
            case 11:
              Ke.sent(), Ke.label = 12;
            case 12:
              return c.uvs2 ? (this.uvs2 = n._MergeElement(P.UV2Kind, c.uvs2, t, e.map(function(ge) {
                return [ge.vertexData.uvs2, ge.transform];
              })), r ? [4] : [3, 14]) : [3, 14];
            case 13:
              Ke.sent(), Ke.label = 14;
            case 14:
              return c.uvs3 ? (this.uvs3 = n._MergeElement(P.UV3Kind, c.uvs3, t, e.map(function(ge) {
                return [ge.vertexData.uvs3, ge.transform];
              })), r ? [4] : [3, 16]) : [3, 16];
            case 15:
              Ke.sent(), Ke.label = 16;
            case 16:
              return c.uvs4 ? (this.uvs4 = n._MergeElement(P.UV4Kind, c.uvs4, t, e.map(function(ge) {
                return [ge.vertexData.uvs4, ge.transform];
              })), r ? [4] : [3, 18]) : [3, 18];
            case 17:
              Ke.sent(), Ke.label = 18;
            case 18:
              return c.uvs5 ? (this.uvs5 = n._MergeElement(P.UV5Kind, c.uvs5, t, e.map(function(ge) {
                return [ge.vertexData.uvs5, ge.transform];
              })), r ? [4] : [3, 20]) : [3, 20];
            case 19:
              Ke.sent(), Ke.label = 20;
            case 20:
              return c.uvs6 ? (this.uvs6 = n._MergeElement(P.UV6Kind, c.uvs6, t, e.map(function(ge) {
                return [ge.vertexData.uvs6, ge.transform];
              })), r ? [4] : [3, 22]) : [3, 22];
            case 21:
              Ke.sent(), Ke.label = 22;
            case 22:
              return c.colors ? (this.colors = n._MergeElement(P.ColorKind, c.colors, t, e.map(function(ge) {
                return [ge.vertexData.colors, ge.transform];
              })), r ? [4] : [3, 24]) : [3, 24];
            case 23:
              Ke.sent(), Ke.label = 24;
            case 24:
              return c.matricesIndices ? (this.matricesIndices = n._MergeElement(P.MatricesIndicesKind, c.matricesIndices, t, e.map(function(ge) {
                return [ge.vertexData.matricesIndices, ge.transform];
              })), r ? [4] : [3, 26]) : [3, 26];
            case 25:
              Ke.sent(), Ke.label = 26;
            case 26:
              return c.matricesWeights ? (this.matricesWeights = n._MergeElement(P.MatricesWeightsKind, c.matricesWeights, t, e.map(function(ge) {
                return [ge.vertexData.matricesWeights, ge.transform];
              })), r ? [4] : [3, 28]) : [3, 28];
            case 27:
              Ke.sent(), Ke.label = 28;
            case 28:
              return c.matricesIndicesExtra ? (this.matricesIndicesExtra = n._MergeElement(P.MatricesIndicesExtraKind, c.matricesIndicesExtra, t, e.map(function(ge) {
                return [ge.vertexData.matricesIndicesExtra, ge.transform];
              })), r ? [4] : [3, 30]) : [3, 30];
            case 29:
              Ke.sent(), Ke.label = 30;
            case 30:
              return c.matricesWeightsExtra && (this.matricesWeightsExtra = n._MergeElement(P.MatricesWeightsExtraKind, c.matricesWeightsExtra, t, e.map(function(ge) {
                return [ge.vertexData.matricesWeightsExtra, ge.transform];
              }))), [2, this];
          }
        });
      }, n._MergeElement = function(t, e, i, r) {
        var o = r.filter(function(E) {
          return E[0] !== null && E[0] !== void 0;
        });
        if (!e && o.length == 0)
          return e;
        if (!e)
          return this._MergeElement(t, o[0][0], o[0][1], o.slice(1));
        var a = o.reduce(function(E, A) {
          return E + A[0].length;
        }, e.length), s = t === P.PositionKind ? n._TransformVector3Coordinates : t === P.NormalKind ? n._TransformVector3Normals : t === P.TangentKind ? n._TransformVector4Normals : function() {
        };
        if (e instanceof Float32Array) {
          var l = new Float32Array(a);
          l.set(e), i && s(l, i, 0, e.length);
          for (var c = e.length, u = 0, h = o; u < h.length; u++) {
            var d = h[u], p = d[0], f = d[1];
            l.set(p, c), f && s(l, f, c, p.length), c += p.length;
          }
          return l;
        }
        for (var m = new Array(a), g = 0; g < e.length; g++)
          m[g] = e[g];
        i && s(m, i, 0, e.length), c = e.length;
        for (var y = 0, b = o; y < b.length; y++) {
          var T = b[y], S = (p = T[0], T[1]);
          for (g = 0; g < p.length; g++)
            m[c + g] = p[g];
          S && s(m, S, c, p.length), c += p.length;
        }
        return m;
      }, n.prototype._validate = function() {
        if (!this.positions)
          throw new ia("Positions are required", ta.MeshInvalidPositionsError);
        var t = function(r, o) {
          var a = P.DeduceStride(r);
          if (o.length % a != 0)
            throw new Error("The " + r + "s array count must be a multiple of " + a);
          return o.length / a;
        }, e = t(P.PositionKind, this.positions), i = function(r, o) {
          var a = t(r, o);
          if (a !== e)
            throw new Error("The " + r + "s element count (" + a + ") does not match the positions count (" + e + ")");
        };
        this.normals && i(P.NormalKind, this.normals), this.tangents && i(P.TangentKind, this.tangents), this.uvs && i(P.UVKind, this.uvs), this.uvs2 && i(P.UV2Kind, this.uvs2), this.uvs3 && i(P.UV3Kind, this.uvs3), this.uvs4 && i(P.UV4Kind, this.uvs4), this.uvs5 && i(P.UV5Kind, this.uvs5), this.uvs6 && i(P.UV6Kind, this.uvs6), this.colors && i(P.ColorKind, this.colors), this.matricesIndices && i(P.MatricesIndicesKind, this.matricesIndices), this.matricesWeights && i(P.MatricesWeightsKind, this.matricesWeights), this.matricesIndicesExtra && i(P.MatricesIndicesExtraKind, this.matricesIndicesExtra), this.matricesWeightsExtra && i(P.MatricesWeightsExtraKind, this.matricesWeightsExtra);
      }, n.prototype.clone = function() {
        var t = this.serialize();
        return n.Parse(t);
      }, n.prototype.serialize = function() {
        var t = {};
        if (this.positions && (t.positions = Array.from(this.positions)), this.normals && (t.normals = Array.from(this.normals)), this.tangents && (t.tangents = Array.from(this.tangents)), this.uvs && (t.uvs = Array.from(this.uvs)), this.uvs2 && (t.uvs2 = Array.from(this.uvs2)), this.uvs3 && (t.uvs3 = Array.from(this.uvs3)), this.uvs4 && (t.uvs4 = Array.from(this.uvs4)), this.uvs5 && (t.uvs5 = Array.from(this.uvs5)), this.uvs6 && (t.uvs6 = Array.from(this.uvs6)), this.colors && (t.colors = Array.from(this.colors)), this.matricesIndices && (t.matricesIndices = Array.from(this.matricesIndices), t.matricesIndices._isExpanded = !0), this.matricesWeights && (t.matricesWeights = Array.from(this.matricesWeights)), this.matricesIndicesExtra && (t.matricesIndicesExtra = Array.from(this.matricesIndicesExtra), t.matricesIndicesExtra._isExpanded = !0), this.matricesWeightsExtra && (t.matricesWeightsExtra = Array.from(this.matricesWeightsExtra)), t.indices = Array.from(this.indices), this.materialInfos) {
          t.materialInfos = [];
          for (var e = 0, i = this.materialInfos; e < i.length; e++) {
            var r = i[e], o = { indexStart: r.indexStart, indexCount: r.indexCount, materialIndex: r.materialIndex, verticesStart: r.verticesStart, verticesCount: r.verticesCount };
            t.materialInfos.push(o);
          }
        }
        return t;
      }, n.ExtractFromMesh = function(t, e, i) {
        return n._ExtractFrom(t, e, i);
      }, n.ExtractFromGeometry = function(t, e, i) {
        return n._ExtractFrom(t, e, i);
      }, n._ExtractFrom = function(t, e, i) {
        var r = new n();
        return t.isVerticesDataPresent(P.PositionKind) && (r.positions = t.getVerticesData(P.PositionKind, e, i)), t.isVerticesDataPresent(P.NormalKind) && (r.normals = t.getVerticesData(P.NormalKind, e, i)), t.isVerticesDataPresent(P.TangentKind) && (r.tangents = t.getVerticesData(P.TangentKind, e, i)), t.isVerticesDataPresent(P.UVKind) && (r.uvs = t.getVerticesData(P.UVKind, e, i)), t.isVerticesDataPresent(P.UV2Kind) && (r.uvs2 = t.getVerticesData(P.UV2Kind, e, i)), t.isVerticesDataPresent(P.UV3Kind) && (r.uvs3 = t.getVerticesData(P.UV3Kind, e, i)), t.isVerticesDataPresent(P.UV4Kind) && (r.uvs4 = t.getVerticesData(P.UV4Kind, e, i)), t.isVerticesDataPresent(P.UV5Kind) && (r.uvs5 = t.getVerticesData(P.UV5Kind, e, i)), t.isVerticesDataPresent(P.UV6Kind) && (r.uvs6 = t.getVerticesData(P.UV6Kind, e, i)), t.isVerticesDataPresent(P.ColorKind) && (r.colors = t.getVerticesData(P.ColorKind, e, i)), t.isVerticesDataPresent(P.MatricesIndicesKind) && (r.matricesIndices = t.getVerticesData(P.MatricesIndicesKind, e, i)), t.isVerticesDataPresent(P.MatricesWeightsKind) && (r.matricesWeights = t.getVerticesData(P.MatricesWeightsKind, e, i)), t.isVerticesDataPresent(P.MatricesIndicesExtraKind) && (r.matricesIndicesExtra = t.getVerticesData(P.MatricesIndicesExtraKind, e, i)), t.isVerticesDataPresent(P.MatricesWeightsExtraKind) && (r.matricesWeightsExtra = t.getVerticesData(P.MatricesWeightsExtraKind, e, i)), r.indices = t.getIndices(e, i), r;
      }, n.CreateRibbon = function(t) {
        throw et("ribbonBuilder");
      }, n.CreateBox = function(t) {
        throw et("boxBuilder");
      }, n.CreateTiledBox = function(t) {
        throw et("tiledBoxBuilder");
      }, n.CreateTiledPlane = function(t) {
        throw et("tiledPlaneBuilder");
      }, n.CreateSphere = function(t) {
        throw et("sphereBuilder");
      }, n.CreateCylinder = function(t) {
        throw et("cylinderBuilder");
      }, n.CreateTorus = function(t) {
        throw et("torusBuilder");
      }, n.CreateLineSystem = function(t) {
        throw et("linesBuilder");
      }, n.CreateDashedLines = function(t) {
        throw et("linesBuilder");
      }, n.CreateGround = function(t) {
        throw et("groundBuilder");
      }, n.CreateTiledGround = function(t) {
        throw et("groundBuilder");
      }, n.CreateGroundFromHeightMap = function(t) {
        throw et("groundBuilder");
      }, n.CreatePlane = function(t) {
        throw et("planeBuilder");
      }, n.CreateDisc = function(t) {
        throw et("discBuilder");
      }, n.CreatePolygon = function(t, e, i, r, o, a, s) {
        throw et("polygonBuilder");
      }, n.CreateIcoSphere = function(t) {
        throw et("icoSphereBuilder");
      }, n.CreatePolyhedron = function(t) {
        throw et("polyhedronBuilder");
      }, n.CreateCapsule = function(t) {
        throw t === void 0 && (t = { orientation: v.Up(), subdivisions: 2, tessellation: 16, height: 1, radius: 0.25, capSubdivisions: 6 }), et("capsuleBuilder");
      }, n.CreateTorusKnot = function(t) {
        throw et("torusKnotBuilder");
      }, n.ComputeNormals = function(t, e, i, r) {
        var o = 0, a = 0, s = 0, l = 0, c = 0, u = 0, h = 0, d = 0, p = 0, f = 0, m = 0, g = 0, y = 0, b = 0, T = 0, S = 0, E = 0, A = 0, R = 0, C = 0, L = !1, I = !1, O = !1, w = !1, z = 1, V = 0, Y = null;
        r && (L = !!r.facetNormals, I = !!r.facetPositions, O = !!r.facetPartitioning, z = r.useRightHandedSystem === !0 ? -1 : 1, V = r.ratio || 0, w = !!r.depthSort, Y = r.distanceTo, w && Y === void 0 && (Y = v.Zero()));
        var ee = 0, J = 0, X = 0, K = 0;
        for (O && r && r.bbSize && (ee = r.subDiv.X * V / r.bbSize.x, J = r.subDiv.Y * V / r.bbSize.y, X = r.subDiv.Z * V / r.bbSize.z, K = r.subDiv.max * r.subDiv.max, r.facetPartitioning.length = 0), o = 0; o < t.length; o++)
          i[o] = 0;
        var te = e.length / 3 | 0;
        for (o = 0; o < te; o++) {
          if (y = 1 + (g = 3 * e[3 * o]), b = g + 2, S = 1 + (T = 3 * e[3 * o + 1]), E = T + 2, R = 1 + (A = 3 * e[3 * o + 2]), C = A + 2, a = t[g] - t[T], s = t[y] - t[S], l = t[b] - t[E], c = t[A] - t[T], u = t[R] - t[S], d = z * (s * (h = t[C] - t[E]) - l * u), p = z * (l * c - a * h), f = z * (a * u - s * c), d /= m = (m = Math.sqrt(d * d + p * p + f * f)) === 0 ? 1 : m, p /= m, f /= m, L && r && (r.facetNormals[o].x = d, r.facetNormals[o].y = p, r.facetNormals[o].z = f), I && r && (r.facetPositions[o].x = (t[g] + t[T] + t[A]) / 3, r.facetPositions[o].y = (t[y] + t[S] + t[R]) / 3, r.facetPositions[o].z = (t[b] + t[E] + t[C]) / 3), O && r) {
            var se = Math.floor((r.facetPositions[o].x - r.bInfo.minimum.x * V) * ee), _e = Math.floor((r.facetPositions[o].y - r.bInfo.minimum.y * V) * J), xe = Math.floor((r.facetPositions[o].z - r.bInfo.minimum.z * V) * X), Te = Math.floor((t[g] - r.bInfo.minimum.x * V) * ee), he = Math.floor((t[y] - r.bInfo.minimum.y * V) * J), me = Math.floor((t[b] - r.bInfo.minimum.z * V) * X), Fe = Math.floor((t[T] - r.bInfo.minimum.x * V) * ee), Ce = Math.floor((t[S] - r.bInfo.minimum.y * V) * J), Re = Math.floor((t[E] - r.bInfo.minimum.z * V) * X), Be = Math.floor((t[A] - r.bInfo.minimum.x * V) * ee), De = Math.floor((t[R] - r.bInfo.minimum.y * V) * J), Ke = Math.floor((t[C] - r.bInfo.minimum.z * V) * X), ge = Te + r.subDiv.max * he + K * me, rt = Fe + r.subDiv.max * Ce + K * Re, it = Be + r.subDiv.max * De + K * Ke, He = se + r.subDiv.max * _e + K * xe;
            r.facetPartitioning[He] = r.facetPartitioning[He] ? r.facetPartitioning[He] : new Array(), r.facetPartitioning[ge] = r.facetPartitioning[ge] ? r.facetPartitioning[ge] : new Array(), r.facetPartitioning[rt] = r.facetPartitioning[rt] ? r.facetPartitioning[rt] : new Array(), r.facetPartitioning[it] = r.facetPartitioning[it] ? r.facetPartitioning[it] : new Array(), r.facetPartitioning[ge].push(o), rt != ge && r.facetPartitioning[rt].push(o), it != rt && it != ge && r.facetPartitioning[it].push(o), He != ge && He != rt && He != it && r.facetPartitioning[He].push(o);
          }
          if (w && r && r.facetPositions) {
            var Pt = r.depthSortedFacets[o];
            Pt.ind = 3 * o, Pt.sqDistance = v.DistanceSquared(r.facetPositions[o], Y);
          }
          i[g] += d, i[y] += p, i[b] += f, i[T] += d, i[S] += p, i[E] += f, i[A] += d, i[R] += p, i[C] += f;
        }
        for (o = 0; o < i.length / 3; o++)
          d = i[3 * o], p = i[3 * o + 1], f = i[3 * o + 2], d /= m = (m = Math.sqrt(d * d + p * p + f * f)) === 0 ? 1 : m, p /= m, f /= m, i[3 * o] = d, i[3 * o + 1] = p, i[3 * o + 2] = f;
      }, n._ComputeSides = function(t, e, i, r, o, a, s) {
        var l, c, u = i.length, h = r.length;
        switch (t = t || n.DEFAULTSIDE) {
          case n.FRONTSIDE:
            break;
          case n.BACKSIDE:
            for (l = 0; l < u; l += 3) {
              var d = i[l];
              i[l] = i[l + 2], i[l + 2] = d;
            }
            for (c = 0; c < h; c++)
              r[c] = -r[c];
            break;
          case n.DOUBLESIDE:
            for (var p = e.length, f = p / 3, m = 0; m < p; m++)
              e[p + m] = e[m];
            for (l = 0; l < u; l += 3)
              i[l + u] = i[l + 2] + f, i[l + 1 + u] = i[l + 1] + f, i[l + 2 + u] = i[l] + f;
            for (c = 0; c < h; c++)
              r[h + c] = -r[c];
            var g = o.length, y = 0;
            for (y = 0; y < g; y++)
              o[y + g] = o[y];
            for (a = a || new lt(0, 0, 1, 1), s = s || new lt(0, 0, 1, 1), y = 0, l = 0; l < g / 2; l++)
              o[y] = a.x + (a.z - a.x) * o[y], o[y + 1] = a.y + (a.w - a.y) * o[y + 1], o[y + g] = s.x + (s.z - s.x) * o[y + g], o[y + g + 1] = s.y + (s.w - s.y) * o[y + g + 1], y += 2;
        }
      }, n.Parse = function(t) {
        var e = new n(), i = t.positions;
        i && e.set(i, P.PositionKind);
        var r = t.normals;
        r && e.set(r, P.NormalKind);
        var o = t.tangents;
        o && e.set(o, P.TangentKind);
        var a = t.uvs;
        a && e.set(a, P.UVKind);
        var s = t.uvs2;
        s && e.set(s, P.UV2Kind);
        var l = t.uvs3;
        l && e.set(l, P.UV3Kind);
        var c = t.uvs4;
        c && e.set(c, P.UV4Kind);
        var u = t.uvs5;
        u && e.set(u, P.UV5Kind);
        var h = t.uvs6;
        h && e.set(h, P.UV6Kind);
        var d = t.colors;
        d && e.set(Ie.CheckColors4(d, i.length / 3), P.ColorKind);
        var p = t.matricesIndices;
        p && e.set(p, P.MatricesIndicesKind);
        var f = t.matricesWeights;
        f && e.set(f, P.MatricesWeightsKind);
        var m = t.indices;
        m && (e.indices = m);
        var g = t.materialInfos;
        if (g) {
          e.materialInfos = [];
          for (var y = 0, b = g; y < b.length; y++) {
            var T = b[y], S = new lc();
            S.indexCount = T.indexCount, S.indexStart = T.indexStart, S.verticesCount = T.verticesCount, S.verticesStart = T.verticesStart, S.materialIndex = T.materialIndex, e.materialInfos.push(S);
          }
        }
        return e;
      }, n.ImportVertexData = function(t, e) {
        var i = n.Parse(t);
        e.setAllVerticesData(i, t.updatable);
      }, n.FRONTSIDE = 0, n.BACKSIDE = 1, n.DOUBLESIDE = 2, n.DEFAULTSIDE = 0, n._UniqueIDGenerator = 0, x([ea.filter(function() {
        for (var t = [], e = 0; e < arguments.length; e++)
          t[e] = arguments[e];
        var i = t[0];
        return !Array.isArray(i);
      })], n, "_TransformVector3Coordinates", null), x([ea.filter(function() {
        for (var t = [], e = 0; e < arguments.length; e++)
          t[e] = arguments[e];
        var i = t[0];
        return !Array.isArray(i);
      })], n, "_TransformVector3Normals", null), x([ea.filter(function() {
        for (var t = [], e = 0; e < arguments.length; e++)
          t[e] = arguments[e];
        var i = t[0];
        return !Array.isArray(i);
      })], n, "_TransformVector4Normals", null), x([ea.filter(function() {
        for (var t = [], e = 0; e < arguments.length; e++)
          t[e] = arguments[e];
        var i = t[0];
        return !Array.isArray(i);
      })], n, "_FlipFaces", null), n;
    }(), Jr = function() {
      function n() {
      }
      return Object.defineProperty(n, "ForceFullSceneLoadingForIncremental", { get: function() {
        return n._ForceFullSceneLoadingForIncremental;
      }, set: function(t) {
        n._ForceFullSceneLoadingForIncremental = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "ShowLoadingScreen", { get: function() {
        return n._ShowLoadingScreen;
      }, set: function(t) {
        n._ShowLoadingScreen = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "loggingLevel", { get: function() {
        return n._LoggingLevel;
      }, set: function(t) {
        n._LoggingLevel = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "CleanBoneMatrixWeights", { get: function() {
        return n._CleanBoneMatrixWeights;
      }, set: function(t) {
        n._CleanBoneMatrixWeights = t;
      }, enumerable: !1, configurable: !0 }), n._ForceFullSceneLoadingForIncremental = !1, n._ShowLoadingScreen = !0, n._CleanBoneMatrixWeights = !1, n._LoggingLevel = _.SCENELOADER_NO_LOGGING, n;
    }(), Lt = function() {
      function n() {
      }
      return n.UseOpenGLOrientationForUV = !1, n;
    }(), er = function() {
      function n(t, e, i, r, o) {
        r === void 0 && (r = !1), o === void 0 && (o = null), this.delayLoadState = _.DELAYLOADSTATE_NONE, this._totalVertices = 0, this._isDisposed = !1, this._indexBufferIsUpdatable = !1, this._positionsCache = [], this._parentContainer = null, this.useBoundingInfoFromGeometry = !1, this._scene = e || Me.LastCreatedScene, this._scene && (this.id = t, this.uniqueId = this._scene.getUniqueId(), this._engine = this._scene.getEngine(), this._meshes = [], this._vertexBuffers = {}, this._indices = [], this._updatable = r, i ? this.setAllVerticesData(i, r) : this._totalVertices = 0, this._engine.getCaps().vertexArrayObject && (this._vertexArrayObjects = {}), o && (this.applyToMesh(o), o.computeWorldMatrix(!0)));
      }
      return Object.defineProperty(n.prototype, "boundingBias", { get: function() {
        return this._boundingBias;
      }, set: function(t) {
        this._boundingBias ? this._boundingBias.copyFrom(t) : this._boundingBias = t.clone(), this._updateBoundingInfo(!0, null);
      }, enumerable: !1, configurable: !0 }), n.CreateGeometryForMesh = function(t) {
        var e = new n(n.RandomId(), t.getScene());
        return e.applyToMesh(t), e;
      }, Object.defineProperty(n.prototype, "meshes", { get: function() {
        return this._meshes;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "extend", { get: function() {
        return this._extend;
      }, enumerable: !1, configurable: !0 }), n.prototype.getScene = function() {
        return this._scene;
      }, n.prototype.getEngine = function() {
        return this._engine;
      }, n.prototype.isReady = function() {
        return this.delayLoadState === _.DELAYLOADSTATE_LOADED || this.delayLoadState === _.DELAYLOADSTATE_NONE;
      }, Object.defineProperty(n.prototype, "doNotSerialize", { get: function() {
        for (var t = 0; t < this._meshes.length; t++)
          if (!this._meshes[t].doNotSerialize)
            return !1;
        return !0;
      }, enumerable: !1, configurable: !0 }), n.prototype._rebuild = function() {
        for (var t in this._vertexArrayObjects && (this._vertexArrayObjects = {}), this._meshes.length !== 0 && this._indices && (this._indexBuffer = this._engine.createIndexBuffer(this._indices, this._updatable)), this._vertexBuffers)
          this._vertexBuffers[t]._rebuild();
      }, n.prototype.setAllVerticesData = function(t, e) {
        t.applyToGeometry(this, e), this._notifyUpdate();
      }, n.prototype.setVerticesData = function(t, e, i, r) {
        i === void 0 && (i = !1), i && Array.isArray(e) && (e = new Float32Array(e));
        var o = new P(this._engine, e, t, { updatable: i, postponeInternalCreation: this._meshes.length === 0, stride: r, label: "Geometry_" + this.id + "_" + t });
        this.setVerticesBuffer(o);
      }, n.prototype.removeVerticesData = function(t) {
        this._vertexBuffers[t] && (this._vertexBuffers[t].dispose(), delete this._vertexBuffers[t]), this._vertexArrayObjects && this._disposeVertexArrayObjects();
      }, n.prototype.setVerticesBuffer = function(t, e, i) {
        e === void 0 && (e = null), i === void 0 && (i = !0);
        var r = t.getKind();
        this._vertexBuffers[r] && i && this._vertexBuffers[r].dispose(), t._buffer && t._buffer._increaseReferences(), this._vertexBuffers[r] = t;
        var o = this._meshes, a = o.length;
        if (r === P.PositionKind) {
          this._totalVertices = e ?? t.totalVertices, this._updateExtend(t.getFloatData()), this._resetPointsArrayCache();
          for (var s = this._extend && this._extend.minimum || new v(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE), l = this._extend && this._extend.maximum || new v(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), c = 0; c < a; c++) {
            var u = o[c];
            u.buildBoundingInfo(s, l), u._createGlobalSubMesh(u.isUnIndexed), u.computeWorldMatrix(!0), u.synchronizeInstances();
          }
        }
        this._notifyUpdate(r);
      }, n.prototype.updateVerticesDataDirectly = function(t, e, i, r) {
        r === void 0 && (r = !1);
        var o = this.getVertexBuffer(t);
        o && (o.updateDirectly(e, i, r), this._notifyUpdate(t));
      }, n.prototype.updateVerticesData = function(t, e, i) {
        i === void 0 && (i = !1);
        var r = this.getVertexBuffer(t);
        r && (r.update(e), t === P.PositionKind && this._updateBoundingInfo(i, e), this._notifyUpdate(t));
      }, n.prototype._updateBoundingInfo = function(t, e) {
        if (t && this._updateExtend(e), this._resetPointsArrayCache(), t)
          for (var i = 0, r = this._meshes; i < r.length; i++) {
            var o = r[i];
            o.hasBoundingInfo ? o.getBoundingInfo().reConstruct(this._extend.minimum, this._extend.maximum) : o.buildBoundingInfo(this._extend.minimum, this._extend.maximum);
            for (var a = 0, s = o.subMeshes; a < s.length; a++)
              s[a].refreshBoundingInfo();
          }
      }, n.prototype._bind = function(t, e, i, r) {
        if (t) {
          e === void 0 && (e = this._indexBuffer);
          var o = this.getVertexBuffers();
          if (o)
            if (e == this._indexBuffer && (this._vertexArrayObjects || r)) {
              var a = r || this._vertexArrayObjects;
              a[t.key] || (a[t.key] = this._engine.recordVertexArrayObject(o, e, t, i)), this._engine.bindVertexArrayObject(a[t.key], e);
            } else
              this._engine.bindBuffers(o, e, t, i);
        }
      }, n.prototype.getTotalVertices = function() {
        return this.isReady() ? this._totalVertices : 0;
      }, n.prototype.getVerticesData = function(t, e, i) {
        var r = this.getVertexBuffer(t);
        return r ? r.getFloatData(this._totalVertices, i || e && this._meshes.length !== 1) : null;
      }, n.prototype.isVertexBufferUpdatable = function(t) {
        var e = this._vertexBuffers[t];
        return !!e && e.isUpdatable();
      }, n.prototype.getVertexBuffer = function(t) {
        return this.isReady() ? this._vertexBuffers[t] : null;
      }, n.prototype.getVertexBuffers = function() {
        return this.isReady() ? this._vertexBuffers : null;
      }, n.prototype.isVerticesDataPresent = function(t) {
        return this._vertexBuffers ? this._vertexBuffers[t] !== void 0 : !!this._delayInfo && this._delayInfo.indexOf(t) !== -1;
      }, n.prototype.getVerticesDataKinds = function() {
        var t, e = [];
        if (!this._vertexBuffers && this._delayInfo)
          for (t in this._delayInfo)
            e.push(t);
        else
          for (t in this._vertexBuffers)
            e.push(t);
        return e;
      }, n.prototype.updateIndices = function(t, e, i) {
        if (i === void 0 && (i = !1), this._indexBuffer)
          if (this._indexBufferIsUpdatable) {
            var r = t.length !== this._indices.length;
            if (i || (this._indices = t.slice()), this._engine.updateDynamicIndexBuffer(this._indexBuffer, t, e), r)
              for (var o = 0, a = this._meshes; o < a.length; o++)
                a[o]._createGlobalSubMesh(!0);
          } else
            this.setIndices(t, null, !0);
      }, n.prototype.setIndexBuffer = function(t, e, i) {
        this._indices = [], this._indexBufferIsUpdatable = !1, this._indexBuffer = t, this._totalVertices = e, this._totalIndices = i, t.is32Bits || (t.is32Bits = this._totalIndices > 65535);
        for (var r = 0, o = this._meshes; r < o.length; r++) {
          var a = o[r];
          a._createGlobalSubMesh(!0), a.synchronizeInstances();
        }
        this._notifyUpdate();
      }, n.prototype.setIndices = function(t, e, i) {
        e === void 0 && (e = null), i === void 0 && (i = !1), this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer), this._indices = t, this._indexBufferIsUpdatable = i, this._meshes.length !== 0 && this._indices && (this._indexBuffer = this._engine.createIndexBuffer(this._indices, i)), e != null && (this._totalVertices = e);
        for (var r = 0, o = this._meshes; r < o.length; r++) {
          var a = o[r];
          a._createGlobalSubMesh(!0), a.synchronizeInstances();
        }
        this._notifyUpdate();
      }, n.prototype.getTotalIndices = function() {
        return this.isReady() ? this._totalIndices !== void 0 ? this._totalIndices : this._indices.length : 0;
      }, n.prototype.getIndices = function(t, e) {
        if (!this.isReady())
          return null;
        var i = this._indices;
        return e || t && this._meshes.length !== 1 ? i.slice() : i;
      }, n.prototype.getIndexBuffer = function() {
        return this.isReady() ? this._indexBuffer : null;
      }, n.prototype._releaseVertexArrayObject = function(t) {
        t === void 0 && (t = null), t && this._vertexArrayObjects && this._vertexArrayObjects[t.key] && (this._engine.releaseVertexArrayObject(this._vertexArrayObjects[t.key]), delete this._vertexArrayObjects[t.key]);
      }, n.prototype.releaseForMesh = function(t, e) {
        var i = this._meshes, r = i.indexOf(t);
        r !== -1 && (i.splice(r, 1), this._vertexArrayObjects && t._invalidateInstanceVertexArrayObject(), t._geometry = null, i.length === 0 && e && this.dispose());
      }, n.prototype.applyToMesh = function(t) {
        if (t._geometry !== this) {
          var e = t._geometry;
          e && e.releaseForMesh(t), this._vertexArrayObjects && t._invalidateInstanceVertexArrayObject();
          var i = this._meshes;
          t._geometry = this, t._internalAbstractMeshDataInfo._positions = null, this._scene.pushGeometry(this), i.push(t), this.isReady() ? this._applyToMesh(t) : this._boundingInfo && t.setBoundingInfo(this._boundingInfo);
        }
      }, n.prototype._updateExtend = function(t) {
        if (t === void 0 && (t = null), this.useBoundingInfoFromGeometry && this._boundingInfo)
          this._extend = { minimum: this._boundingInfo.minimum.clone(), maximum: this._boundingInfo.maximum.clone() };
        else {
          if (!t && !(t = this.getVerticesData(P.PositionKind)))
            return;
          this._extend = hl(t, 0, this._totalVertices, this.boundingBias, 3);
        }
      }, n.prototype._applyToMesh = function(t) {
        var e = this._meshes.length;
        for (var i in this._vertexBuffers)
          e === 1 && this._vertexBuffers[i].create(), i === P.PositionKind && (this._extend || this._updateExtend(), t.buildBoundingInfo(this._extend.minimum, this._extend.maximum), t._createGlobalSubMesh(t.isUnIndexed), t._updateBoundingInfo());
        e === 1 && this._indices && this._indices.length > 0 && (this._indexBuffer = this._engine.createIndexBuffer(this._indices, this._updatable)), t._syncGeometryWithMorphTargetManager(), t.synchronizeInstances();
      }, n.prototype._notifyUpdate = function(t) {
        this.onGeometryUpdated && this.onGeometryUpdated(this, t), this._vertexArrayObjects && this._disposeVertexArrayObjects();
        for (var e = 0, i = this._meshes; e < i.length; e++)
          i[e]._markSubMeshesAsAttributesDirty();
      }, n.prototype.load = function(t, e) {
        this.delayLoadState !== _.DELAYLOADSTATE_LOADING && (this.isReady() ? e && e() : (this.delayLoadState = _.DELAYLOADSTATE_LOADING, this._queueLoad(t, e)));
      }, n.prototype._queueLoad = function(t, e) {
        var i = this;
        this.delayLoadingFile && (t.addPendingData(this), t._loadFile(this.delayLoadingFile, function(r) {
          if (i._delayLoadingFunction) {
            i._delayLoadingFunction(JSON.parse(r), i), i.delayLoadState = _.DELAYLOADSTATE_LOADED, i._delayInfo = [], t.removePendingData(i);
            for (var o = i._meshes, a = o.length, s = 0; s < a; s++)
              i._applyToMesh(o[s]);
            e && e();
          }
        }, void 0, !0));
      }, n.prototype.toLeftHanded = function() {
        var t = this.getIndices(!1);
        if (t != null && t.length > 0) {
          for (var e = 0; e < t.length; e += 3) {
            var i = t[e + 0];
            t[e + 0] = t[e + 2], t[e + 2] = i;
          }
          this.setIndices(t);
        }
        var r = this.getVerticesData(P.PositionKind, !1);
        if (r != null && r.length > 0) {
          for (e = 0; e < r.length; e += 3)
            r[e + 2] = -r[e + 2];
          this.setVerticesData(P.PositionKind, r, !1);
        }
        var o = this.getVerticesData(P.NormalKind, !1);
        if (o != null && o.length > 0) {
          for (e = 0; e < o.length; e += 3)
            o[e + 2] = -o[e + 2];
          this.setVerticesData(P.NormalKind, o, !1);
        }
      }, n.prototype._resetPointsArrayCache = function() {
        this._positions = null;
      }, n.prototype._generatePointsArray = function() {
        if (this._positions)
          return !0;
        var t = this.getVerticesData(P.PositionKind);
        if (!t || t.length === 0)
          return !1;
        for (var e = 3 * this._positionsCache.length, i = this._positionsCache.length; e < t.length; e += 3, ++i)
          this._positionsCache[i] = v.FromArray(t, e);
        for (e = 0, i = 0; e < t.length; e += 3, ++i)
          this._positionsCache[i].set(t[0 + e], t[1 + e], t[2 + e]);
        return this._positionsCache.length = t.length / 3, this._positions = this._positionsCache, !0;
      }, n.prototype.isDisposed = function() {
        return this._isDisposed;
      }, n.prototype._disposeVertexArrayObjects = function() {
        if (this._vertexArrayObjects) {
          for (var t in this._vertexArrayObjects)
            this._engine.releaseVertexArrayObject(this._vertexArrayObjects[t]);
          this._vertexArrayObjects = {};
          for (var e = this._meshes, i = e.length, r = 0; r < i; r++)
            e[r]._invalidateInstanceVertexArrayObject();
        }
      }, n.prototype.dispose = function() {
        var t, e = this._meshes, i = e.length;
        for (t = 0; t < i; t++)
          this.releaseForMesh(e[t]);
        for (var r in this._meshes.length = 0, this._disposeVertexArrayObjects(), this._vertexBuffers)
          this._vertexBuffers[r].dispose();
        if (this._vertexBuffers = {}, this._totalVertices = 0, this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer), this._indexBuffer = null, this._indices = [], this.delayLoadState = _.DELAYLOADSTATE_NONE, this.delayLoadingFile = null, this._delayLoadingFunction = null, this._delayInfo = [], this._boundingInfo = null, this._scene.removeGeometry(this), this._parentContainer) {
          var o = this._parentContainer.geometries.indexOf(this);
          o > -1 && this._parentContainer.geometries.splice(o, 1), this._parentContainer = null;
        }
        this._isDisposed = !0;
      }, n.prototype.copy = function(t) {
        var e = new Oe();
        e.indices = [];
        var i = this.getIndices();
        if (i)
          for (var r = 0; r < i.length; r++)
            e.indices.push(i[r]);
        var o, a = !1, s = !1;
        for (o in this._vertexBuffers) {
          var l = this.getVerticesData(o);
          if (l && (l instanceof Float32Array ? e.set(new Float32Array(l), o) : e.set(l.slice(0), o), !s)) {
            var c = this.getVertexBuffer(o);
            c && (s = !(a = c.isUpdatable()));
          }
        }
        var u = new n(t, this._scene, e, a);
        for (o in u.delayLoadState = this.delayLoadState, u.delayLoadingFile = this.delayLoadingFile, u._delayLoadingFunction = this._delayLoadingFunction, this._delayInfo)
          u._delayInfo = u._delayInfo || [], u._delayInfo.push(o);
        return u._boundingInfo = new wr(this._extend.minimum, this._extend.maximum), u;
      }, n.prototype.serialize = function() {
        var t = {};
        return t.id = this.id, t.uniqueId = this.uniqueId, t.updatable = this._updatable, Xt && Xt.HasTags(this) && (t.tags = Xt.GetTags(this)), t;
      }, n.prototype._toNumberArray = function(t) {
        return Array.isArray(t) ? t : Array.prototype.slice.call(t);
      }, n.prototype.clearCachedData = function() {
        for (var t in this._indices = [], this._resetPointsArrayCache(), this._vertexBuffers)
          Object.prototype.hasOwnProperty.call(this._vertexBuffers, t) && (this._vertexBuffers[t]._buffer._data = null);
      }, n.prototype.serializeVerticeData = function() {
        var t = this.serialize();
        return this.isVerticesDataPresent(P.PositionKind) && (t.positions = this._toNumberArray(this.getVerticesData(P.PositionKind)), this.isVertexBufferUpdatable(P.PositionKind) && (t.positions._updatable = !0)), this.isVerticesDataPresent(P.NormalKind) && (t.normals = this._toNumberArray(this.getVerticesData(P.NormalKind)), this.isVertexBufferUpdatable(P.NormalKind) && (t.normals._updatable = !0)), this.isVerticesDataPresent(P.TangentKind) && (t.tangents = this._toNumberArray(this.getVerticesData(P.TangentKind)), this.isVertexBufferUpdatable(P.TangentKind) && (t.tangents._updatable = !0)), this.isVerticesDataPresent(P.UVKind) && (t.uvs = this._toNumberArray(this.getVerticesData(P.UVKind)), this.isVertexBufferUpdatable(P.UVKind) && (t.uvs._updatable = !0)), this.isVerticesDataPresent(P.UV2Kind) && (t.uvs2 = this._toNumberArray(this.getVerticesData(P.UV2Kind)), this.isVertexBufferUpdatable(P.UV2Kind) && (t.uvs2._updatable = !0)), this.isVerticesDataPresent(P.UV3Kind) && (t.uvs3 = this._toNumberArray(this.getVerticesData(P.UV3Kind)), this.isVertexBufferUpdatable(P.UV3Kind) && (t.uvs3._updatable = !0)), this.isVerticesDataPresent(P.UV4Kind) && (t.uvs4 = this._toNumberArray(this.getVerticesData(P.UV4Kind)), this.isVertexBufferUpdatable(P.UV4Kind) && (t.uvs4._updatable = !0)), this.isVerticesDataPresent(P.UV5Kind) && (t.uvs5 = this._toNumberArray(this.getVerticesData(P.UV5Kind)), this.isVertexBufferUpdatable(P.UV5Kind) && (t.uvs5._updatable = !0)), this.isVerticesDataPresent(P.UV6Kind) && (t.uvs6 = this._toNumberArray(this.getVerticesData(P.UV6Kind)), this.isVertexBufferUpdatable(P.UV6Kind) && (t.uvs6._updatable = !0)), this.isVerticesDataPresent(P.ColorKind) && (t.colors = this._toNumberArray(this.getVerticesData(P.ColorKind)), this.isVertexBufferUpdatable(P.ColorKind) && (t.colors._updatable = !0)), this.isVerticesDataPresent(P.MatricesIndicesKind) && (t.matricesIndices = this._toNumberArray(this.getVerticesData(P.MatricesIndicesKind)), t.matricesIndices._isExpanded = !0, this.isVertexBufferUpdatable(P.MatricesIndicesKind) && (t.matricesIndices._updatable = !0)), this.isVerticesDataPresent(P.MatricesWeightsKind) && (t.matricesWeights = this._toNumberArray(this.getVerticesData(P.MatricesWeightsKind)), this.isVertexBufferUpdatable(P.MatricesWeightsKind) && (t.matricesWeights._updatable = !0)), t.indices = this._toNumberArray(this.getIndices()), t;
      }, n.ExtractFromMesh = function(t, e) {
        var i = t._geometry;
        return i ? i.copy(e) : null;
      }, n.RandomId = function() {
        return de.RandomId();
      }, n._GetGeometryByLoadedUniqueId = function(t, e) {
        for (var i = 0; i < e.geometries.length; i++)
          if (e.geometries[i]._loadedUniqueId === t)
            return e.geometries[i];
        return null;
      }, n._ImportGeometry = function(t, e) {
        var i = e.getScene(), r = t.geometryUniqueId, o = t.geometryId;
        if (r || o) {
          var a = r ? this._GetGeometryByLoadedUniqueId(r, i) : i.getGeometryById(o);
          a && a.applyToMesh(e);
        } else if (t instanceof ArrayBuffer) {
          var s = e._binaryInfo;
          if (s.positionsAttrDesc && s.positionsAttrDesc.count > 0) {
            var l = new Float32Array(t, s.positionsAttrDesc.offset, s.positionsAttrDesc.count);
            e.setVerticesData(P.PositionKind, l, !1);
          }
          if (s.normalsAttrDesc && s.normalsAttrDesc.count > 0) {
            var c = new Float32Array(t, s.normalsAttrDesc.offset, s.normalsAttrDesc.count);
            e.setVerticesData(P.NormalKind, c, !1);
          }
          if (s.tangetsAttrDesc && s.tangetsAttrDesc.count > 0) {
            var u = new Float32Array(t, s.tangetsAttrDesc.offset, s.tangetsAttrDesc.count);
            e.setVerticesData(P.TangentKind, u, !1);
          }
          if (s.uvsAttrDesc && s.uvsAttrDesc.count > 0) {
            var h = new Float32Array(t, s.uvsAttrDesc.offset, s.uvsAttrDesc.count);
            if (Lt.UseOpenGLOrientationForUV)
              for (var d = 1; d < h.length; d += 2)
                h[d] = 1 - h[d];
            e.setVerticesData(P.UVKind, h, !1);
          }
          if (s.uvs2AttrDesc && s.uvs2AttrDesc.count > 0) {
            var p = new Float32Array(t, s.uvs2AttrDesc.offset, s.uvs2AttrDesc.count);
            if (Lt.UseOpenGLOrientationForUV)
              for (d = 1; d < p.length; d += 2)
                p[d] = 1 - p[d];
            e.setVerticesData(P.UV2Kind, p, !1);
          }
          if (s.uvs3AttrDesc && s.uvs3AttrDesc.count > 0) {
            var f = new Float32Array(t, s.uvs3AttrDesc.offset, s.uvs3AttrDesc.count);
            if (Lt.UseOpenGLOrientationForUV)
              for (d = 1; d < f.length; d += 2)
                f[d] = 1 - f[d];
            e.setVerticesData(P.UV3Kind, f, !1);
          }
          if (s.uvs4AttrDesc && s.uvs4AttrDesc.count > 0) {
            var m = new Float32Array(t, s.uvs4AttrDesc.offset, s.uvs4AttrDesc.count);
            if (Lt.UseOpenGLOrientationForUV)
              for (d = 1; d < m.length; d += 2)
                m[d] = 1 - m[d];
            e.setVerticesData(P.UV4Kind, m, !1);
          }
          if (s.uvs5AttrDesc && s.uvs5AttrDesc.count > 0) {
            var g = new Float32Array(t, s.uvs5AttrDesc.offset, s.uvs5AttrDesc.count);
            if (Lt.UseOpenGLOrientationForUV)
              for (d = 1; d < g.length; d += 2)
                g[d] = 1 - g[d];
            e.setVerticesData(P.UV5Kind, g, !1);
          }
          if (s.uvs6AttrDesc && s.uvs6AttrDesc.count > 0) {
            var y = new Float32Array(t, s.uvs6AttrDesc.offset, s.uvs6AttrDesc.count);
            if (Lt.UseOpenGLOrientationForUV)
              for (d = 1; d < y.length; d += 2)
                y[d] = 1 - y[d];
            e.setVerticesData(P.UV6Kind, y, !1);
          }
          if (s.colorsAttrDesc && s.colorsAttrDesc.count > 0) {
            var b = new Float32Array(t, s.colorsAttrDesc.offset, s.colorsAttrDesc.count);
            e.setVerticesData(P.ColorKind, b, !1, s.colorsAttrDesc.stride);
          }
          if (s.matricesIndicesAttrDesc && s.matricesIndicesAttrDesc.count > 0) {
            for (var T = new Int32Array(t, s.matricesIndicesAttrDesc.offset, s.matricesIndicesAttrDesc.count), S = [], E = 0; E < T.length; E++)
              d = T[E], S.push(255 & d), S.push((65280 & d) >> 8), S.push((16711680 & d) >> 16), S.push(d >> 24 & 255);
            e.setVerticesData(P.MatricesIndicesKind, S, !1);
          }
          if (s.matricesIndicesExtraAttrDesc && s.matricesIndicesExtraAttrDesc.count > 0) {
            for (T = new Int32Array(t, s.matricesIndicesExtraAttrDesc.offset, s.matricesIndicesExtraAttrDesc.count), S = [], E = 0; E < T.length; E++)
              d = T[E], S.push(255 & d), S.push((65280 & d) >> 8), S.push((16711680 & d) >> 16), S.push(d >> 24 & 255);
            e.setVerticesData(P.MatricesIndicesExtraKind, S, !1);
          }
          if (s.matricesWeightsAttrDesc && s.matricesWeightsAttrDesc.count > 0) {
            var A = new Float32Array(t, s.matricesWeightsAttrDesc.offset, s.matricesWeightsAttrDesc.count);
            e.setVerticesData(P.MatricesWeightsKind, A, !1);
          }
          if (s.indicesAttrDesc && s.indicesAttrDesc.count > 0) {
            var R = new Int32Array(t, s.indicesAttrDesc.offset, s.indicesAttrDesc.count);
            e.setIndices(R, null);
          }
          if (s.subMeshesAttrDesc && s.subMeshesAttrDesc.count > 0) {
            var C = new Int32Array(t, s.subMeshesAttrDesc.offset, 5 * s.subMeshesAttrDesc.count);
            for (e.subMeshes = [], E = 0; E < s.subMeshesAttrDesc.count; E++) {
              var L = C[5 * E + 0], I = C[5 * E + 1], O = C[5 * E + 2], w = C[5 * E + 3], z = C[5 * E + 4];
              Yn.AddToMesh(L, I, O, w, z, e);
            }
          }
        } else if (t.positions && t.normals && t.indices) {
          if (e.setVerticesData(P.PositionKind, t.positions, t.positions._updatable), e.setVerticesData(P.NormalKind, t.normals, t.normals._updatable), t.tangents && e.setVerticesData(P.TangentKind, t.tangents, t.tangents._updatable), t.uvs && e.setVerticesData(P.UVKind, t.uvs, t.uvs._updatable), t.uvs2 && e.setVerticesData(P.UV2Kind, t.uvs2, t.uvs2._updatable), t.uvs3 && e.setVerticesData(P.UV3Kind, t.uvs3, t.uvs3._updatable), t.uvs4 && e.setVerticesData(P.UV4Kind, t.uvs4, t.uvs4._updatable), t.uvs5 && e.setVerticesData(P.UV5Kind, t.uvs5, t.uvs5._updatable), t.uvs6 && e.setVerticesData(P.UV6Kind, t.uvs6, t.uvs6._updatable), t.colors && e.setVerticesData(P.ColorKind, Ie.CheckColors4(t.colors, t.positions.length / 3), t.colors._updatable), t.matricesIndices)
            if (t.matricesIndices._isExpanded)
              delete t.matricesIndices._isExpanded, e.setVerticesData(P.MatricesIndicesKind, t.matricesIndices, t.matricesIndices._updatable);
            else {
              for (S = [], E = 0; E < t.matricesIndices.length; E++) {
                var V = t.matricesIndices[E];
                S.push(255 & V), S.push((65280 & V) >> 8), S.push((16711680 & V) >> 16), S.push(V >> 24 & 255);
              }
              e.setVerticesData(P.MatricesIndicesKind, S, t.matricesIndices._updatable);
            }
          if (t.matricesIndicesExtra)
            if (t.matricesIndicesExtra._isExpanded)
              delete t.matricesIndices._isExpanded, e.setVerticesData(P.MatricesIndicesExtraKind, t.matricesIndicesExtra, t.matricesIndicesExtra._updatable);
            else {
              for (S = [], E = 0; E < t.matricesIndicesExtra.length; E++)
                V = t.matricesIndicesExtra[E], S.push(255 & V), S.push((65280 & V) >> 8), S.push((16711680 & V) >> 16), S.push(V >> 24 & 255);
              e.setVerticesData(P.MatricesIndicesExtraKind, S, t.matricesIndicesExtra._updatable);
            }
          t.matricesWeights && (n._CleanMatricesWeights(t, e), e.setVerticesData(P.MatricesWeightsKind, t.matricesWeights, t.matricesWeights._updatable)), t.matricesWeightsExtra && e.setVerticesData(P.MatricesWeightsExtraKind, t.matricesWeightsExtra, t.matricesWeights._updatable), e.setIndices(t.indices, null);
        }
        if (t.subMeshes) {
          e.subMeshes = [];
          for (var Y = 0; Y < t.subMeshes.length; Y++) {
            var ee = t.subMeshes[Y];
            Yn.AddToMesh(ee.materialIndex, ee.verticesStart, ee.verticesCount, ee.indexStart, ee.indexCount, e);
          }
        }
        e._shouldGenerateFlatShading && (e.convertToFlatShadedMesh(), e._shouldGenerateFlatShading = !1), e.computeWorldMatrix(!0), i.onMeshImportedObservable.notifyObservers(e);
      }, n._CleanMatricesWeights = function(t, e) {
        var i = 1e-3;
        if (Jr.CleanBoneMatrixWeights) {
          var r = 0;
          if (t.skeletonId > -1) {
            var o = e.getScene().getLastSkeletonById(t.skeletonId);
            if (o) {
              r = o.bones.length;
              for (var a = e.getVerticesData(P.MatricesIndicesKind), s = e.getVerticesData(P.MatricesIndicesExtraKind), l = t.matricesWeights, c = t.matricesWeightsExtra, u = t.numBoneInfluencer, h = l.length, d = 0; d < h; d += 4) {
                for (var p = 0, f = -1, m = 0; m < 4; m++)
                  p += g = l[d + m], g < i && f < 0 && (f = m);
                if (c)
                  for (m = 0; m < 4; m++) {
                    var g;
                    p += g = c[d + m], g < i && f < 0 && (f = m + 4);
                  }
                if ((f < 0 || f > u - 1) && (f = u - 1), p > i) {
                  var y = 1 / p;
                  for (m = 0; m < 4; m++)
                    l[d + m] *= y;
                  if (c)
                    for (m = 0; m < 4; m++)
                      c[d + m] *= y;
                } else
                  f >= 4 ? (c[d + f - 4] = 1 - p, s[d + f - 4] = r) : (l[d + f] = 1 - p, a[d + f] = r);
              }
              e.setVerticesData(P.MatricesIndicesKind, a), t.matricesWeightsExtra && e.setVerticesData(P.MatricesIndicesExtraKind, s);
            }
          }
        }
      }, n.Parse = function(t, e, i) {
        var r = new n(t.id, e, void 0, t.updatable);
        return r._loadedUniqueId = t.uniqueId, Xt && Xt.AddTagsTo(r, t.tags), t.delayLoadingFile ? (r.delayLoadState = _.DELAYLOADSTATE_NOTLOADED, r.delayLoadingFile = i + t.delayLoadingFile, r._boundingInfo = new wr(v.FromArray(t.boundingBoxMinimum), v.FromArray(t.boundingBoxMaximum)), r._delayInfo = [], t.hasUVs && r._delayInfo.push(P.UVKind), t.hasUVs2 && r._delayInfo.push(P.UV2Kind), t.hasUVs3 && r._delayInfo.push(P.UV3Kind), t.hasUVs4 && r._delayInfo.push(P.UV4Kind), t.hasUVs5 && r._delayInfo.push(P.UV5Kind), t.hasUVs6 && r._delayInfo.push(P.UV6Kind), t.hasColors && r._delayInfo.push(P.ColorKind), t.hasMatricesIndices && r._delayInfo.push(P.MatricesIndicesKind), t.hasMatricesWeights && r._delayInfo.push(P.MatricesWeightsKind), r._delayLoadingFunction = Oe.ImportVertexData) : Oe.ImportVertexData(t, r), e.pushGeometry(r, !0), r;
      }, n;
    }(), yg = function() {
      function n(t) {
        t === void 0 && (t = 30), this._enabled = !0, this._rollingFrameTime = new bg(t);
      }
      return n.prototype.sampleFrame = function(t) {
        if (t === void 0 && (t = It.Now), this._enabled) {
          if (this._lastFrameTimeMs != null) {
            var e = t - this._lastFrameTimeMs;
            this._rollingFrameTime.add(e);
          }
          this._lastFrameTimeMs = t;
        }
      }, Object.defineProperty(n.prototype, "averageFrameTime", { get: function() {
        return this._rollingFrameTime.average;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "averageFrameTimeVariance", { get: function() {
        return this._rollingFrameTime.variance;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "instantaneousFrameTime", { get: function() {
        return this._rollingFrameTime.history(0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "averageFPS", { get: function() {
        return 1e3 / this._rollingFrameTime.average;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "instantaneousFPS", { get: function() {
        var t = this._rollingFrameTime.history(0);
        return t === 0 ? 0 : 1e3 / t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isSaturated", { get: function() {
        return this._rollingFrameTime.isSaturated();
      }, enumerable: !1, configurable: !0 }), n.prototype.enable = function() {
        this._enabled = !0;
      }, n.prototype.disable = function() {
        this._enabled = !1, this._lastFrameTimeMs = null;
      }, Object.defineProperty(n.prototype, "isEnabled", { get: function() {
        return this._enabled;
      }, enumerable: !1, configurable: !0 }), n.prototype.reset = function() {
        this._lastFrameTimeMs = null, this._rollingFrameTime.reset();
      }, n;
    }(), bg = function() {
      function n(t) {
        this._samples = new Array(t), this.reset();
      }
      return n.prototype.add = function(t) {
        var e;
        if (this.isSaturated()) {
          var i = this._samples[this._pos];
          e = i - this.average, this.average -= e / (this._sampleCount - 1), this._m2 -= e * (i - this.average);
        } else
          this._sampleCount++;
        e = t - this.average, this.average += e / this._sampleCount, this._m2 += e * (t - this.average), this.variance = this._m2 / (this._sampleCount - 1), this._samples[this._pos] = t, this._pos++, this._pos %= this._samples.length;
      }, n.prototype.history = function(t) {
        if (t >= this._sampleCount || t >= this._samples.length)
          return 0;
        var e = this._wrapPosition(this._pos - 1);
        return this._samples[this._wrapPosition(e - t)];
      }, n.prototype.isSaturated = function() {
        return this._sampleCount >= this._samples.length;
      }, n.prototype.reset = function() {
        this.average = 0, this.variance = 0, this._sampleCount = 0, this._pos = 0, this._m2 = 0;
      }, n.prototype._wrapPosition = function(t) {
        var e = this._samples.length;
        return (t % e + e) % e;
      }, n;
    }();
    function qu(n, t, e, i) {
      switch (e === void 0 && (e = !1), n) {
        case _.TEXTURETYPE_BYTE:
          var r = new Int8Array(t);
          return i && r.set(new Int8Array(i)), r;
        case _.TEXTURETYPE_UNSIGNED_BYTE:
          var o = new Uint8Array(t);
          return i && o.set(new Uint8Array(i)), o;
        case _.TEXTURETYPE_SHORT:
          var a = t instanceof ArrayBuffer ? new Int16Array(t) : new Int16Array(e ? t / 2 : t);
          return i && a.set(new Int16Array(i)), a;
        case _.TEXTURETYPE_UNSIGNED_SHORT:
        case _.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
        case _.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
        case _.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
        case _.TEXTURETYPE_HALF_FLOAT:
          var s = t instanceof ArrayBuffer ? new Uint16Array(t) : new Uint16Array(e ? t / 2 : t);
          return i && s.set(new Uint16Array(i)), s;
        case _.TEXTURETYPE_INT:
          var l = t instanceof ArrayBuffer ? new Int32Array(t) : new Int32Array(e ? t / 4 : t);
          return i && l.set(new Int32Array(i)), l;
        case _.TEXTURETYPE_UNSIGNED_INTEGER:
        case _.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
        case _.TEXTURETYPE_UNSIGNED_INT_24_8:
        case _.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
        case _.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
        case _.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:
          var c = t instanceof ArrayBuffer ? new Uint32Array(t) : new Uint32Array(e ? t / 4 : t);
          return i && c.set(new Uint32Array(i)), c;
        case _.TEXTURETYPE_FLOAT:
          var u = t instanceof ArrayBuffer ? new Float32Array(t) : new Float32Array(e ? t / 4 : t);
          return i && u.set(new Float32Array(i)), u;
      }
      var h = new Uint8Array(t);
      return i && h.set(new Uint8Array(i)), h;
    }
    Qe.prototype.setAlphaConstants = function(n, t, e, i) {
      this._alphaState.setAlphaBlendConstants(n, t, e, i);
    }, Qe.prototype.setAlphaMode = function(n, t) {
      if (t === void 0 && (t = !1), this._alphaMode !== n) {
        switch (n) {
          case _.ALPHA_DISABLE:
            this._alphaState.alphaBlend = !1;
            break;
          case _.ALPHA_PREMULTIPLIED:
            this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_PREMULTIPLIED_PORTERDUFF:
            this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_COMBINE:
            this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_ONEONE:
            this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_ADD:
            this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ONE), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_SUBTRACT:
            this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_MULTIPLY:
            this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR, this._gl.ZERO, this._gl.ONE, this._gl.ONE), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_MAXIMIZED:
            this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_INTERPOLATE:
            this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR, this._gl.ONE_MINUS_CONSTANT_COLOR, this._gl.CONSTANT_ALPHA, this._gl.ONE_MINUS_CONSTANT_ALPHA), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_SCREENMODE:
            this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_ONEONE_ONEONE:
            this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ONE, this._gl.ONE), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_ALPHATOCOLOR:
            this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ZERO), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_REVERSEONEMINUS:
            this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE_MINUS_DST_COLOR, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE_MINUS_DST_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_SRC_DSTONEMINUSSRCALPHA:
            this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_ONEONE_ONEZERO:
            this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ONE, this._gl.ZERO), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_EXCLUSION:
            this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE_MINUS_DST_COLOR, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ZERO, this._gl.ONE), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_LAYER_ACCUMULATE:
            this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA), this._alphaState.alphaBlend = !0;
        }
        t || (this.depthCullingState.depthMask = n === _.ALPHA_DISABLE), this._alphaMode = n;
      } else if (!t) {
        var e = n === _.ALPHA_DISABLE;
        this.depthCullingState.depthMask !== e && (this.depthCullingState.depthMask = e);
      }
    }, Qe.prototype.getAlphaMode = function() {
      return this._alphaMode;
    }, Qe.prototype.setAlphaEquation = function(n) {
      if (this._alphaEquation !== n) {
        switch (n) {
          case _.ALPHA_EQUATION_ADD:
            this._alphaState.setAlphaEquationParameters(_.GL_ALPHA_EQUATION_ADD, _.GL_ALPHA_EQUATION_ADD);
            break;
          case _.ALPHA_EQUATION_SUBSTRACT:
            this._alphaState.setAlphaEquationParameters(_.GL_ALPHA_EQUATION_SUBTRACT, _.GL_ALPHA_EQUATION_SUBTRACT);
            break;
          case _.ALPHA_EQUATION_REVERSE_SUBTRACT:
            this._alphaState.setAlphaEquationParameters(_.GL_ALPHA_EQUATION_REVERSE_SUBTRACT, _.GL_ALPHA_EQUATION_REVERSE_SUBTRACT);
            break;
          case _.ALPHA_EQUATION_MAX:
            this._alphaState.setAlphaEquationParameters(_.GL_ALPHA_EQUATION_MAX, _.GL_ALPHA_EQUATION_MAX);
            break;
          case _.ALPHA_EQUATION_MIN:
            this._alphaState.setAlphaEquationParameters(_.GL_ALPHA_EQUATION_MIN, _.GL_ALPHA_EQUATION_MIN);
            break;
          case _.ALPHA_EQUATION_DARKEN:
            this._alphaState.setAlphaEquationParameters(_.GL_ALPHA_EQUATION_MIN, _.GL_ALPHA_EQUATION_ADD);
        }
        this._alphaEquation = n;
      }
    }, Qe.prototype.getAlphaEquation = function() {
      return this._alphaEquation;
    }, Qe.prototype._readTexturePixelsSync = function(n, t, e, i, r, o, a, s, l, c) {
      var u, h;
      i === void 0 && (i = -1), r === void 0 && (r = 0), o === void 0 && (o = null), a === void 0 && (a = !0), s === void 0 && (s = !1), l === void 0 && (l = 0), c === void 0 && (c = 0);
      var d = this._gl;
      if (!d)
        throw new Error("Engine does not have gl rendering context.");
      if (!this._dummyFramebuffer) {
        var p = d.createFramebuffer();
        if (!p)
          throw new Error("Unable to create dummy framebuffer");
        this._dummyFramebuffer = p;
      }
      d.bindFramebuffer(d.FRAMEBUFFER, this._dummyFramebuffer), i > -1 ? d.framebufferTexture2D(d.FRAMEBUFFER, d.COLOR_ATTACHMENT0, d.TEXTURE_CUBE_MAP_POSITIVE_X + i, (u = n._hardwareTexture) === null || u === void 0 ? void 0 : u.underlyingResource, r) : d.framebufferTexture2D(d.FRAMEBUFFER, d.COLOR_ATTACHMENT0, d.TEXTURE_2D, (h = n._hardwareTexture) === null || h === void 0 ? void 0 : h.underlyingResource, r);
      var f = n.type !== void 0 ? this._getWebGLTextureType(n.type) : d.UNSIGNED_BYTE;
      return s ? o || (o = qu(n.type, 4 * t * e)) : f === d.UNSIGNED_BYTE ? (o || (o = new Uint8Array(4 * t * e)), f = d.UNSIGNED_BYTE) : (o || (o = new Float32Array(4 * t * e)), f = d.FLOAT), a && this.flushFramebuffer(), d.readPixels(l, c, t, e, d.RGBA, f, o), d.bindFramebuffer(d.FRAMEBUFFER, this._currentFramebuffer), o;
    }, Qe.prototype._readTexturePixels = function(n, t, e, i, r, o, a, s, l, c) {
      return i === void 0 && (i = -1), r === void 0 && (r = 0), o === void 0 && (o = null), a === void 0 && (a = !0), s === void 0 && (s = !1), l === void 0 && (l = 0), c === void 0 && (c = 0), Promise.resolve(this._readTexturePixelsSync(n, t, e, i, r, o, a, s, l, c));
    }, Qe.prototype.updateDynamicIndexBuffer = function(n, t, e) {
      var i;
      this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null, this.bindIndexBuffer(n), i = n.is32Bits ? t instanceof Uint32Array ? t : new Uint32Array(t) : t instanceof Uint16Array ? t : new Uint16Array(t), this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, i, this._gl.DYNAMIC_DRAW), this._resetIndexBufferBinding();
    }, Qe.prototype.updateDynamicVertexBuffer = function(n, t, e, i) {
      this.bindArrayBuffer(n), e === void 0 && (e = 0);
      var r = t.byteLength || t.length;
      i === void 0 || i >= r && e === 0 ? t instanceof Array ? this._gl.bufferSubData(this._gl.ARRAY_BUFFER, e, new Float32Array(t)) : this._gl.bufferSubData(this._gl.ARRAY_BUFFER, e, t) : t instanceof Array ? this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, new Float32Array(t).subarray(e, e + i)) : (t = t instanceof ArrayBuffer ? new Uint8Array(t, e, i) : new Uint8Array(t.buffer, t.byteOffset + e, i), this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, t)), this._resetVertexBufferBinding();
    };
    var ve = function(n) {
      function t(e, i, r, o) {
        o === void 0 && (o = !1);
        var a = n.call(this, e, i, r, o) || this;
        if (a.enableOfflineSupport = !1, a.disableManifestCheck = !1, a.disableContextMenu = !0, a.scenes = [], a._virtualScenes = new Array(), a.onNewSceneAddedObservable = new H(), a.postProcesses = [], a.isPointerLock = !1, a.onResizeObservable = new H(), a.onCanvasBlurObservable = new H(), a.onCanvasFocusObservable = new H(), a.onCanvasPointerOutObservable = new H(), a.onBeginFrameObservable = new H(), a.customAnimationFrameRequester = null, a.onEndFrameObservable = new H(), a.onBeforeShaderCompilationObservable = new H(), a.onAfterShaderCompilationObservable = new H(), a._deterministicLockstep = !1, a._lockstepMaxSteps = 4, a._timeStep = 1 / 60, a._fps = 60, a._deltaTime = 0, a._drawCalls = new Sn(), a.canvasTabIndex = 1, a.disablePerformanceMonitorInBackground = !1, a._performanceMonitor = new yg(), a._compatibilityMode = !0, a.currentRenderPassId = _.RENDERPASS_MAIN, a._renderPassNames = ["main"], t.Instances.push(a), !e)
          return a;
        if (a._features.supportRenderPasses = !0, r = a._creationOptions, e.getContext) {
          var s = e;
          a._sharedInit(s);
        }
        return a;
      }
      return D(t, n), Object.defineProperty(t, "NpmPackage", { get: function() {
        return Qe.NpmPackage;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "Version", { get: function() {
        return Qe.Version;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "Instances", { get: function() {
        return Me.Instances;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "LastCreatedEngine", { get: function() {
        return Me.LastCreatedEngine;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "LastCreatedScene", { get: function() {
        return Me.LastCreatedScene;
      }, enumerable: !1, configurable: !0 }), t.prototype._createImageBitmapFromSource = function(e, i) {
        var r = this;
        return new Promise(function(o, a) {
          var s = new Image();
          s.onload = function() {
            s.decode().then(function() {
              r.createImageBitmap(s, i).then(function(l) {
                o(l);
              });
            });
          }, s.onerror = function() {
            a("Error loading image ".concat(s.src));
          }, s.src = e;
        });
      }, t.prototype.createImageBitmap = function(e, i) {
        return createImageBitmap(e, i);
      }, t.prototype.resizeImageBitmap = function(e, i, r) {
        var o = this.createCanvas(i, r).getContext("2d");
        if (!o)
          throw new Error("Unable to get 2d context for resizeImageBitmap");
        return o.drawImage(e, 0, 0), o.getImageData(0, 0, i, r).data;
      }, t.MarkAllMaterialsAsDirty = function(e, i) {
        for (var r = 0; r < t.Instances.length; r++)
          for (var o = t.Instances[r], a = 0; a < o.scenes.length; a++)
            o.scenes[a].markAllMaterialsAsDirty(e, i);
      }, t.DefaultLoadingScreenFactory = function(e) {
        throw et("LoadingScreen");
      }, Object.defineProperty(t.prototype, "_supportsHardwareTextureRescaling", { get: function() {
        return !!t._RescalePostProcessFactory;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "performanceMonitor", { get: function() {
        return this._performanceMonitor;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "compatibilityMode", { get: function() {
        return this._compatibilityMode;
      }, set: function(e) {
        this._compatibilityMode = !0;
      }, enumerable: !1, configurable: !0 }), t.prototype.getInputElement = function() {
        return this._renderingCanvas;
      }, t.prototype._initGLContext = function() {
        n.prototype._initGLContext.call(this), this._rescalePostProcess = null;
      }, t.prototype._sharedInit = function(e) {
        var i = this;
        n.prototype._sharedInit.call(this, e), this._onCanvasFocus = function() {
          i.onCanvasFocusObservable.notifyObservers(i);
        }, this._onCanvasBlur = function() {
          i.onCanvasBlurObservable.notifyObservers(i);
        }, this._onCanvasContextMenu = function(o) {
          i.disableContextMenu && o.preventDefault();
        }, e.addEventListener("focus", this._onCanvasFocus), e.addEventListener("blur", this._onCanvasBlur), e.addEventListener("contextmenu", this._onCanvasContextMenu), this._onBlur = function() {
          i.disablePerformanceMonitorInBackground && i._performanceMonitor.disable(), i._windowIsBackground = !0;
        }, this._onFocus = function() {
          i.disablePerformanceMonitorInBackground && i._performanceMonitor.enable(), i._windowIsBackground = !1;
        }, this._onCanvasPointerOut = function(o) {
          document.elementFromPoint(o.clientX, o.clientY) !== e && i.onCanvasPointerOutObservable.notifyObservers(o);
        };
        var r = this.getHostWindow();
        r && typeof r.addEventListener == "function" && (r.addEventListener("blur", this._onBlur), r.addEventListener("focus", this._onFocus)), e.addEventListener("pointerout", this._onCanvasPointerOut), this._creationOptions.doNotHandleTouchAction || this._disableTouchAction(), !t.audioEngine && this._creationOptions.audioEngine && t.AudioEngineFactory && (t.audioEngine = t.AudioEngineFactory(this.getRenderingCanvas(), this.getAudioContext(), this.getAudioDestination())), hs() && (this._onFullscreenChange = function() {
          i.isFullscreen = !!document.fullscreenElement, i.isFullscreen && i._pointerLockRequested && e && t._RequestPointerlock(e);
        }, document.addEventListener("fullscreenchange", this._onFullscreenChange, !1), document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, !1), this._onPointerLockChange = function() {
          i.isPointerLock = document.pointerLockElement === e;
        }, document.addEventListener("pointerlockchange", this._onPointerLockChange, !1), document.addEventListener("webkitpointerlockchange", this._onPointerLockChange, !1)), this.enableOfflineSupport = t.OfflineProviderFactory !== void 0, this._deterministicLockstep = !!this._creationOptions.deterministicLockstep, this._lockstepMaxSteps = this._creationOptions.lockstepMaxSteps || 0, this._timeStep = this._creationOptions.timeStep || 1 / 60;
      }, t.prototype._verifyPointerLock = function() {
        var e;
        (e = this._onPointerLockChange) === null || e === void 0 || e.call(this);
      }, t.prototype.getAspectRatio = function(e, i) {
        i === void 0 && (i = !1);
        var r = e.viewport;
        return this.getRenderWidth(i) * r.width / (this.getRenderHeight(i) * r.height);
      }, t.prototype.getScreenAspectRatio = function() {
        return this.getRenderWidth(!0) / this.getRenderHeight(!0);
      }, t.prototype.getRenderingCanvasClientRect = function() {
        return this._renderingCanvas ? this._renderingCanvas.getBoundingClientRect() : null;
      }, t.prototype.getInputElementClientRect = function() {
        return this._renderingCanvas ? this.getInputElement().getBoundingClientRect() : null;
      }, t.prototype.isDeterministicLockStep = function() {
        return this._deterministicLockstep;
      }, t.prototype.getLockstepMaxSteps = function() {
        return this._lockstepMaxSteps;
      }, t.prototype.getTimeStep = function() {
        return 1e3 * this._timeStep;
      }, t.prototype.generateMipMapsForCubemap = function(e, i) {
        if (i === void 0 && (i = !0), e.generateMipMaps) {
          var r = this._gl;
          this._bindTextureDirectly(r.TEXTURE_CUBE_MAP, e, !0), r.generateMipmap(r.TEXTURE_CUBE_MAP), i && this._bindTextureDirectly(r.TEXTURE_CUBE_MAP, null);
        }
      }, t.prototype.getDepthWrite = function() {
        return this._depthCullingState.depthMask;
      }, t.prototype.setDepthWrite = function(e) {
        this._depthCullingState.depthMask = e;
      }, t.prototype.getStencilBuffer = function() {
        return this._stencilState.stencilTest;
      }, t.prototype.setStencilBuffer = function(e) {
        this._stencilState.stencilTest = e;
      }, t.prototype.getStencilMask = function() {
        return this._stencilState.stencilMask;
      }, t.prototype.setStencilMask = function(e) {
        this._stencilState.stencilMask = e;
      }, t.prototype.getStencilFunction = function() {
        return this._stencilState.stencilFunc;
      }, t.prototype.getStencilFunctionReference = function() {
        return this._stencilState.stencilFuncRef;
      }, t.prototype.getStencilFunctionMask = function() {
        return this._stencilState.stencilFuncMask;
      }, t.prototype.setStencilFunction = function(e) {
        this._stencilState.stencilFunc = e;
      }, t.prototype.setStencilFunctionReference = function(e) {
        this._stencilState.stencilFuncRef = e;
      }, t.prototype.setStencilFunctionMask = function(e) {
        this._stencilState.stencilFuncMask = e;
      }, t.prototype.getStencilOperationFail = function() {
        return this._stencilState.stencilOpStencilFail;
      }, t.prototype.getStencilOperationDepthFail = function() {
        return this._stencilState.stencilOpDepthFail;
      }, t.prototype.getStencilOperationPass = function() {
        return this._stencilState.stencilOpStencilDepthPass;
      }, t.prototype.setStencilOperationFail = function(e) {
        this._stencilState.stencilOpStencilFail = e;
      }, t.prototype.setStencilOperationDepthFail = function(e) {
        this._stencilState.stencilOpDepthFail = e;
      }, t.prototype.setStencilOperationPass = function(e) {
        this._stencilState.stencilOpStencilDepthPass = e;
      }, t.prototype.setDitheringState = function(e) {
        e ? this._gl.enable(this._gl.DITHER) : this._gl.disable(this._gl.DITHER);
      }, t.prototype.setRasterizerState = function(e) {
        e ? this._gl.disable(this._gl.RASTERIZER_DISCARD) : this._gl.enable(this._gl.RASTERIZER_DISCARD);
      }, t.prototype.getDepthFunction = function() {
        return this._depthCullingState.depthFunc;
      }, t.prototype.setDepthFunction = function(e) {
        this._depthCullingState.depthFunc = e;
      }, t.prototype.setDepthFunctionToGreater = function() {
        this.setDepthFunction(_.GREATER);
      }, t.prototype.setDepthFunctionToGreaterOrEqual = function() {
        this.setDepthFunction(_.GEQUAL);
      }, t.prototype.setDepthFunctionToLess = function() {
        this.setDepthFunction(_.LESS);
      }, t.prototype.setDepthFunctionToLessOrEqual = function() {
        this.setDepthFunction(_.LEQUAL);
      }, t.prototype.cacheStencilState = function() {
        this._cachedStencilBuffer = this.getStencilBuffer(), this._cachedStencilFunction = this.getStencilFunction(), this._cachedStencilMask = this.getStencilMask(), this._cachedStencilOperationPass = this.getStencilOperationPass(), this._cachedStencilOperationFail = this.getStencilOperationFail(), this._cachedStencilOperationDepthFail = this.getStencilOperationDepthFail(), this._cachedStencilReference = this.getStencilFunctionReference();
      }, t.prototype.restoreStencilState = function() {
        this.setStencilFunction(this._cachedStencilFunction), this.setStencilMask(this._cachedStencilMask), this.setStencilBuffer(this._cachedStencilBuffer), this.setStencilOperationPass(this._cachedStencilOperationPass), this.setStencilOperationFail(this._cachedStencilOperationFail), this.setStencilOperationDepthFail(this._cachedStencilOperationDepthFail), this.setStencilFunctionReference(this._cachedStencilReference);
      }, t.prototype.setDirectViewport = function(e, i, r, o) {
        var a = this._cachedViewport;
        return this._cachedViewport = null, this._viewport(e, i, r, o), a;
      }, t.prototype.scissorClear = function(e, i, r, o, a) {
        this.enableScissor(e, i, r, o), this.clear(a, !0, !0, !0), this.disableScissor();
      }, t.prototype.enableScissor = function(e, i, r, o) {
        var a = this._gl;
        a.enable(a.SCISSOR_TEST), a.scissor(e, i, r, o);
      }, t.prototype.disableScissor = function() {
        var e = this._gl;
        e.disable(e.SCISSOR_TEST);
      }, t.prototype._reportDrawCall = function(e) {
        e === void 0 && (e = 1), this._drawCalls.addCount(e, !1);
      }, t.prototype._loadFileAsync = function(e, i, r) {
        var o = this;
        return new Promise(function(a, s) {
          o._loadFile(e, function(l) {
            a(l);
          }, void 0, i, r, function(l, c) {
            s(c);
          });
        });
      }, t.prototype.getVertexShaderSource = function(e) {
        var i = this._gl.getAttachedShaders(e);
        return i ? this._gl.getShaderSource(i[0]) : null;
      }, t.prototype.getFragmentShaderSource = function(e) {
        var i = this._gl.getAttachedShaders(e);
        return i ? this._gl.getShaderSource(i[1]) : null;
      }, t.prototype.setDepthStencilTexture = function(e, i, r, o) {
        e !== void 0 && (i && (this._boundUniforms[e] = i), r && r.depthStencilTexture ? this._setTexture(e, r, !1, !0, o) : this._setTexture(e, null, void 0, void 0, o));
      }, t.prototype.setTextureFromPostProcess = function(e, i, r) {
        var o, a = null;
        i && (i._forcedOutputTexture ? a = i._forcedOutputTexture : i._textures.data[i._currentRenderTextureInd] && (a = i._textures.data[i._currentRenderTextureInd])), this._bindTexture(e, (o = a == null ? void 0 : a.texture) !== null && o !== void 0 ? o : null, r);
      }, t.prototype.setTextureFromPostProcessOutput = function(e, i, r) {
        var o, a;
        this._bindTexture(e, (a = (o = i == null ? void 0 : i._outputTexture) === null || o === void 0 ? void 0 : o.texture) !== null && a !== void 0 ? a : null, r);
      }, t.prototype._rebuildBuffers = function() {
        for (var e = 0, i = this.scenes; e < i.length; e++)
          (a = i[e]).resetCachedMaterial(), a._rebuildGeometries(), a._rebuildTextures();
        for (var r = 0, o = this._virtualScenes; r < o.length; r++) {
          var a;
          (a = o[r]).resetCachedMaterial(), a._rebuildGeometries(), a._rebuildTextures();
        }
        n.prototype._rebuildBuffers.call(this);
      }, t.prototype._renderFrame = function() {
        for (var e = 0; e < this._activeRenderLoops.length; e++)
          (0, this._activeRenderLoops[e])();
      }, t.prototype._cancelFrame = function() {
        if (this._renderingQueueLaunched && this.customAnimationFrameRequester) {
          this._renderingQueueLaunched = !1;
          var e = this.customAnimationFrameRequester.cancelAnimationFrame;
          e && e(this.customAnimationFrameRequester.requestID);
        } else
          n.prototype._cancelFrame.call(this);
      }, t.prototype._renderLoop = function() {
        if (!this._contextWasLost) {
          var e = !0;
          (this.isDisposed || !this.renderEvenInBackground && this._windowIsBackground) && (e = !1), e && (this.beginFrame(), this._renderViews() || this._renderFrame(), this.endFrame());
        }
        this._activeRenderLoops.length > 0 ? this.customAnimationFrameRequester ? (this.customAnimationFrameRequester.requestID = this._queueNewFrame(this.customAnimationFrameRequester.renderFunction || this._boundRenderFunction, this.customAnimationFrameRequester), this._frameHandler = this.customAnimationFrameRequester.requestID) : this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow()) : this._renderingQueueLaunched = !1;
      }, t.prototype._renderViews = function() {
        return !1;
      }, t.prototype.switchFullscreen = function(e) {
        this.isFullscreen ? this.exitFullscreen() : this.enterFullscreen(e);
      }, t.prototype.enterFullscreen = function(e) {
        this.isFullscreen || (this._pointerLockRequested = e, this._renderingCanvas && t._RequestFullscreen(this._renderingCanvas));
      }, t.prototype.exitFullscreen = function() {
        this.isFullscreen && t._ExitFullscreen();
      }, t.prototype.enterPointerlock = function() {
        this._renderingCanvas && t._RequestPointerlock(this._renderingCanvas);
      }, t.prototype.exitPointerlock = function() {
        t._ExitPointerlock();
      }, t.prototype.beginFrame = function() {
        this._measureFps(), this.onBeginFrameObservable.notifyObservers(this), n.prototype.beginFrame.call(this);
      }, t.prototype.endFrame = function() {
        n.prototype.endFrame.call(this), this.onEndFrameObservable.notifyObservers(this);
      }, t.prototype.setSize = function(e, i, r) {
        if (r === void 0 && (r = !1), !this._renderingCanvas || !n.prototype.setSize.call(this, e, i, r))
          return !1;
        if (this.scenes) {
          for (var o = 0; o < this.scenes.length; o++)
            for (var a = this.scenes[o], s = 0; s < a.cameras.length; s++)
              a.cameras[s]._currentRenderId = 0;
          this.onResizeObservable.hasObservers() && this.onResizeObservable.notifyObservers(this);
        }
        return !0;
      }, t.prototype._deletePipelineContext = function(e) {
        var i = e;
        i && i.program && i.transformFeedback && (this.deleteTransformFeedback(i.transformFeedback), i.transformFeedback = null), n.prototype._deletePipelineContext.call(this, e);
      }, t.prototype.createShaderProgram = function(e, i, r, o, a, s) {
        s === void 0 && (s = null), a = a || this._gl, this.onBeforeShaderCompilationObservable.notifyObservers(this);
        var l = n.prototype.createShaderProgram.call(this, e, i, r, o, a, s);
        return this.onAfterShaderCompilationObservable.notifyObservers(this), l;
      }, t.prototype._createShaderProgram = function(e, i, r, o, a) {
        a === void 0 && (a = null);
        var s = o.createProgram();
        if (e.program = s, !s)
          throw new Error("Unable to create program");
        if (o.attachShader(s, i), o.attachShader(s, r), this.webGLVersion > 1 && a) {
          var l = this.createTransformFeedback();
          this.bindTransformFeedback(l), this.setTranformFeedbackVaryings(s, a), e.transformFeedback = l;
        }
        return o.linkProgram(s), this.webGLVersion > 1 && a && this.bindTransformFeedback(null), e.context = o, e.vertexShader = i, e.fragmentShader = r, e.isParallelCompiled || this._finalizePipelineContext(e), s;
      }, t.prototype._releaseTexture = function(e) {
        n.prototype._releaseTexture.call(this, e);
      }, t.prototype._releaseRenderTargetWrapper = function(e) {
        n.prototype._releaseRenderTargetWrapper.call(this, e), this.scenes.forEach(function(i) {
          i.postProcesses.forEach(function(r) {
            r._outputTexture === e && (r._outputTexture = null);
          }), i.cameras.forEach(function(r) {
            r._postProcesses.forEach(function(o) {
              o && o._outputTexture === e && (o._outputTexture = null);
            });
          });
        });
      }, t.prototype.getRenderPassNames = function() {
        return this._renderPassNames;
      }, t.prototype.getCurrentRenderPassName = function() {
        return this._renderPassNames[this.currentRenderPassId];
      }, t.prototype.createRenderPassId = function(e) {
        var i = ++t._RenderPassIdCounter;
        return this._renderPassNames[i] = e ?? "NONAME", i;
      }, t.prototype.releaseRenderPassId = function(e) {
        this._renderPassNames[e] = void 0;
        for (var i = 0; i < this.scenes.length; ++i)
          for (var r = this.scenes[i], o = 0; o < r.meshes.length; ++o) {
            var a = r.meshes[o];
            if (a.subMeshes)
              for (var s = 0; s < a.subMeshes.length; ++s)
                a.subMeshes[s]._removeDrawWrapper(e);
          }
      }, t.prototype._rescaleTexture = function(e, i, r, o, a) {
        var s = this;
        this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, this._gl.LINEAR), this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, this._gl.LINEAR), this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._gl.CLAMP_TO_EDGE), this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._gl.CLAMP_TO_EDGE);
        var l = this.createRenderTargetTexture({ width: i.width, height: i.height }, { generateMipMaps: !1, type: _.TEXTURETYPE_UNSIGNED_INT, samplingMode: _.TEXTURE_BILINEAR_SAMPLINGMODE, generateDepthBuffer: !1, generateStencilBuffer: !1 });
        !this._rescalePostProcess && t._RescalePostProcessFactory && (this._rescalePostProcess = t._RescalePostProcessFactory(this)), this._rescalePostProcess && (this._rescalePostProcess.externalTextureSamplerBinding = !0, this._rescalePostProcess.getEffect().executeWhenCompiled(function() {
          s._rescalePostProcess.onApply = function(u) {
            u._bindTexture("textureSampler", e);
          };
          var c = r;
          c || (c = s.scenes[s.scenes.length - 1]), c.postProcessManager.directRender([s._rescalePostProcess], l, !0), s._bindTextureDirectly(s._gl.TEXTURE_2D, i, !0), s._gl.copyTexImage2D(s._gl.TEXTURE_2D, 0, o, 0, 0, i.width, i.height, 0), s.unBindFramebuffer(l), l.dispose(), a && a();
        }));
      }, t.prototype.getFps = function() {
        return this._fps;
      }, t.prototype.getDeltaTime = function() {
        return this._deltaTime;
      }, t.prototype._measureFps = function() {
        this._performanceMonitor.sampleFrame(), this._fps = this._performanceMonitor.averageFPS, this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0;
      }, t.prototype.wrapWebGLTexture = function(e, i, r, o, a) {
        i === void 0 && (i = !1), r === void 0 && (r = _.TEXTURE_TRILINEAR_SAMPLINGMODE), o === void 0 && (o = 0), a === void 0 && (a = 0);
        var s = new ds(e, this._gl), l = new Ut(this, ut.Unknown, !0);
        return l._hardwareTexture = s, l.baseWidth = o, l.baseHeight = a, l.width = o, l.height = a, l.isReady = !0, l.useMipMaps = i, this.updateTextureSamplingMode(r, l), l;
      }, t.prototype._uploadImageToTexture = function(e, i, r, o) {
        r === void 0 && (r = 0), o === void 0 && (o = 0);
        var a = this._gl, s = this._getWebGLTextureType(e.type), l = this._getInternalFormat(e.format), c = this._getRGBABufferInternalSizedFormat(e.type, l), u = e.isCube ? a.TEXTURE_CUBE_MAP : a.TEXTURE_2D;
        this._bindTextureDirectly(u, e, !0), this._unpackFlipY(e.invertY);
        var h = a.TEXTURE_2D;
        e.isCube && (h = a.TEXTURE_CUBE_MAP_POSITIVE_X + r), a.texImage2D(h, o, c, l, s, i), this._bindTextureDirectly(u, null, !0);
      }, t.prototype.updateTextureComparisonFunction = function(e, i) {
        if (this.webGLVersion !== 1) {
          var r = this._gl;
          e.isCube ? (this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, e, !0), i === 0 ? (r.texParameteri(r.TEXTURE_CUBE_MAP, r.TEXTURE_COMPARE_FUNC, _.LEQUAL), r.texParameteri(r.TEXTURE_CUBE_MAP, r.TEXTURE_COMPARE_MODE, r.NONE)) : (r.texParameteri(r.TEXTURE_CUBE_MAP, r.TEXTURE_COMPARE_FUNC, i), r.texParameteri(r.TEXTURE_CUBE_MAP, r.TEXTURE_COMPARE_MODE, r.COMPARE_REF_TO_TEXTURE)), this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null)) : (this._bindTextureDirectly(this._gl.TEXTURE_2D, e, !0), i === 0 ? (r.texParameteri(r.TEXTURE_2D, r.TEXTURE_COMPARE_FUNC, _.LEQUAL), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_COMPARE_MODE, r.NONE)) : (r.texParameteri(r.TEXTURE_2D, r.TEXTURE_COMPARE_FUNC, i), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_COMPARE_MODE, r.COMPARE_REF_TO_TEXTURE)), this._bindTextureDirectly(this._gl.TEXTURE_2D, null)), e._comparisonFunction = i;
        } else
          q.Error("WebGL 1 does not support texture comparison.");
      }, t.prototype.createInstancesBuffer = function(e) {
        var i = this._gl.createBuffer();
        if (!i)
          throw new Error("Unable to create instance buffer");
        var r = new nl(i);
        return r.capacity = e, this.bindArrayBuffer(r), this._gl.bufferData(this._gl.ARRAY_BUFFER, e, this._gl.DYNAMIC_DRAW), r.references = 1, r;
      }, t.prototype.deleteInstancesBuffer = function(e) {
        this._gl.deleteBuffer(e);
      }, t.prototype._clientWaitAsync = function(e, i, r) {
        i === void 0 && (i = 0), r === void 0 && (r = 10);
        var o = this._gl;
        return new Promise(function(a, s) {
          var l = function() {
            var c = o.clientWaitSync(e, i, 0);
            c != o.WAIT_FAILED ? c != o.TIMEOUT_EXPIRED ? a() : setTimeout(l, r) : s();
          };
          l();
        });
      }, t.prototype._readPixelsAsync = function(e, i, r, o, a, s, l) {
        if (this._webGLVersion < 2)
          throw new Error("_readPixelsAsync only work on WebGL2+");
        var c = this._gl, u = c.createBuffer();
        c.bindBuffer(c.PIXEL_PACK_BUFFER, u), c.bufferData(c.PIXEL_PACK_BUFFER, l.byteLength, c.STREAM_READ), c.readPixels(e, i, r, o, a, s, 0), c.bindBuffer(c.PIXEL_PACK_BUFFER, null);
        var h = c.fenceSync(c.SYNC_GPU_COMMANDS_COMPLETE, 0);
        return h ? (c.flush(), this._clientWaitAsync(h, 0, 10).then(function() {
          return c.deleteSync(h), c.bindBuffer(c.PIXEL_PACK_BUFFER, u), c.getBufferSubData(c.PIXEL_PACK_BUFFER, 0, l), c.bindBuffer(c.PIXEL_PACK_BUFFER, null), c.deleteBuffer(u), l;
        })) : null;
      }, t.prototype.dispose = function() {
        for (this.hideLoadingUI(), this.onNewSceneAddedObservable.clear(); this.postProcesses.length; )
          this.postProcesses[0].dispose();
        for (this._rescalePostProcess && this._rescalePostProcess.dispose(); this.scenes.length; )
          this.scenes[0].dispose();
        for (; this._virtualScenes.length; )
          this._virtualScenes[0].dispose();
        Me.Instances.length === 1 && t.audioEngine && (t.audioEngine.dispose(), t.audioEngine = null);
        var e = this.getHostWindow();
        e && typeof e.removeEventListener == "function" && (e.removeEventListener("blur", this._onBlur), e.removeEventListener("focus", this._onFocus)), this._renderingCanvas && (this._renderingCanvas.removeEventListener("focus", this._onCanvasFocus), this._renderingCanvas.removeEventListener("blur", this._onCanvasBlur), this._renderingCanvas.removeEventListener("pointerout", this._onCanvasPointerOut), this._renderingCanvas.removeEventListener("contextmenu", this._onCanvasContextMenu)), hs() && (document.removeEventListener("fullscreenchange", this._onFullscreenChange), document.removeEventListener("mozfullscreenchange", this._onFullscreenChange), document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange), document.removeEventListener("msfullscreenchange", this._onFullscreenChange), document.removeEventListener("pointerlockchange", this._onPointerLockChange), document.removeEventListener("mspointerlockchange", this._onPointerLockChange), document.removeEventListener("mozpointerlockchange", this._onPointerLockChange), document.removeEventListener("webkitpointerlockchange", this._onPointerLockChange)), n.prototype.dispose.call(this);
        var i = Me.Instances.indexOf(this);
        i >= 0 && Me.Instances.splice(i, 1), t.Instances.length || Me.OnEnginesDisposedObservable.notifyObservers(this), this.onResizeObservable.clear(), this.onCanvasBlurObservable.clear(), this.onCanvasFocusObservable.clear(), this.onCanvasPointerOutObservable.clear(), this.onBeginFrameObservable.clear(), this.onEndFrameObservable.clear();
      }, t.prototype._disableTouchAction = function() {
        this._renderingCanvas && this._renderingCanvas.setAttribute && (this._renderingCanvas.setAttribute("touch-action", "none"), this._renderingCanvas.style.touchAction = "none", this._renderingCanvas.style.webkitTapHighlightColor = "transparent");
      }, t.prototype.displayLoadingUI = function() {
        if (Gi()) {
          var e = this.loadingScreen;
          e && e.displayLoadingUI();
        }
      }, t.prototype.hideLoadingUI = function() {
        if (Gi()) {
          var e = this._loadingScreen;
          e && e.hideLoadingUI();
        }
      }, Object.defineProperty(t.prototype, "loadingScreen", { get: function() {
        return !this._loadingScreen && this._renderingCanvas && (this._loadingScreen = t.DefaultLoadingScreenFactory(this._renderingCanvas)), this._loadingScreen;
      }, set: function(e) {
        this._loadingScreen = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "loadingUIText", { set: function(e) {
        this.loadingScreen.loadingUIText = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "loadingUIBackgroundColor", { set: function(e) {
        this.loadingScreen.loadingUIBackgroundColor = e;
      }, enumerable: !1, configurable: !0 }), t.prototype.createVideoElement = function(e) {
        return document.createElement("video");
      }, t._RequestPointerlock = function(e) {
        if (e.requestPointerLock) {
          var i = e.requestPointerLock();
          i instanceof Promise ? i.then(function() {
            e.focus();
          }).catch(function() {
          }) : e.focus();
        }
      }, t._ExitPointerlock = function() {
        document.exitPointerLock && document.exitPointerLock();
      }, t._RequestFullscreen = function(e) {
        var i = e.requestFullscreen || e.webkitRequestFullscreen;
        i && i.call(e);
      }, t._ExitFullscreen = function() {
        var e = document;
        document.exitFullscreen ? document.exitFullscreen() : e.webkitCancelFullScreen && e.webkitCancelFullScreen();
      }, t.prototype.getFontOffset = function(e) {
        var i = document.createElement("span");
        i.innerHTML = "Hg", i.setAttribute("style", "font: ".concat(e, " !important"));
        var r = document.createElement("div");
        r.style.display = "inline-block", r.style.width = "1px", r.style.height = "0px", r.style.verticalAlign = "bottom";
        var o = document.createElement("div");
        o.style.whiteSpace = "nowrap", o.appendChild(i), o.appendChild(r), document.body.appendChild(o);
        var a = 0, s = 0;
        try {
          s = r.getBoundingClientRect().top - i.getBoundingClientRect().top, r.style.verticalAlign = "baseline", a = r.getBoundingClientRect().top - i.getBoundingClientRect().top;
        } finally {
          document.body.removeChild(o);
        }
        return { ascent: a, height: s, descent: s - a };
      }, t.ALPHA_DISABLE = _.ALPHA_DISABLE, t.ALPHA_ADD = _.ALPHA_ADD, t.ALPHA_COMBINE = _.ALPHA_COMBINE, t.ALPHA_SUBTRACT = _.ALPHA_SUBTRACT, t.ALPHA_MULTIPLY = _.ALPHA_MULTIPLY, t.ALPHA_MAXIMIZED = _.ALPHA_MAXIMIZED, t.ALPHA_ONEONE = _.ALPHA_ONEONE, t.ALPHA_PREMULTIPLIED = _.ALPHA_PREMULTIPLIED, t.ALPHA_PREMULTIPLIED_PORTERDUFF = _.ALPHA_PREMULTIPLIED_PORTERDUFF, t.ALPHA_INTERPOLATE = _.ALPHA_INTERPOLATE, t.ALPHA_SCREENMODE = _.ALPHA_SCREENMODE, t.DELAYLOADSTATE_NONE = _.DELAYLOADSTATE_NONE, t.DELAYLOADSTATE_LOADED = _.DELAYLOADSTATE_LOADED, t.DELAYLOADSTATE_LOADING = _.DELAYLOADSTATE_LOADING, t.DELAYLOADSTATE_NOTLOADED = _.DELAYLOADSTATE_NOTLOADED, t.NEVER = _.NEVER, t.ALWAYS = _.ALWAYS, t.LESS = _.LESS, t.EQUAL = _.EQUAL, t.LEQUAL = _.LEQUAL, t.GREATER = _.GREATER, t.GEQUAL = _.GEQUAL, t.NOTEQUAL = _.NOTEQUAL, t.KEEP = _.KEEP, t.REPLACE = _.REPLACE, t.INCR = _.INCR, t.DECR = _.DECR, t.INVERT = _.INVERT, t.INCR_WRAP = _.INCR_WRAP, t.DECR_WRAP = _.DECR_WRAP, t.TEXTURE_CLAMP_ADDRESSMODE = _.TEXTURE_CLAMP_ADDRESSMODE, t.TEXTURE_WRAP_ADDRESSMODE = _.TEXTURE_WRAP_ADDRESSMODE, t.TEXTURE_MIRROR_ADDRESSMODE = _.TEXTURE_MIRROR_ADDRESSMODE, t.TEXTUREFORMAT_ALPHA = _.TEXTUREFORMAT_ALPHA, t.TEXTUREFORMAT_LUMINANCE = _.TEXTUREFORMAT_LUMINANCE, t.TEXTUREFORMAT_LUMINANCE_ALPHA = _.TEXTUREFORMAT_LUMINANCE_ALPHA, t.TEXTUREFORMAT_RGB = _.TEXTUREFORMAT_RGB, t.TEXTUREFORMAT_RGBA = _.TEXTUREFORMAT_RGBA, t.TEXTUREFORMAT_RED = _.TEXTUREFORMAT_RED, t.TEXTUREFORMAT_R = _.TEXTUREFORMAT_R, t.TEXTUREFORMAT_RG = _.TEXTUREFORMAT_RG, t.TEXTUREFORMAT_RED_INTEGER = _.TEXTUREFORMAT_RED_INTEGER, t.TEXTUREFORMAT_R_INTEGER = _.TEXTUREFORMAT_R_INTEGER, t.TEXTUREFORMAT_RG_INTEGER = _.TEXTUREFORMAT_RG_INTEGER, t.TEXTUREFORMAT_RGB_INTEGER = _.TEXTUREFORMAT_RGB_INTEGER, t.TEXTUREFORMAT_RGBA_INTEGER = _.TEXTUREFORMAT_RGBA_INTEGER, t.TEXTURETYPE_UNSIGNED_BYTE = _.TEXTURETYPE_UNSIGNED_BYTE, t.TEXTURETYPE_UNSIGNED_INT = _.TEXTURETYPE_UNSIGNED_INT, t.TEXTURETYPE_FLOAT = _.TEXTURETYPE_FLOAT, t.TEXTURETYPE_HALF_FLOAT = _.TEXTURETYPE_HALF_FLOAT, t.TEXTURETYPE_BYTE = _.TEXTURETYPE_BYTE, t.TEXTURETYPE_SHORT = _.TEXTURETYPE_SHORT, t.TEXTURETYPE_UNSIGNED_SHORT = _.TEXTURETYPE_UNSIGNED_SHORT, t.TEXTURETYPE_INT = _.TEXTURETYPE_INT, t.TEXTURETYPE_UNSIGNED_INTEGER = _.TEXTURETYPE_UNSIGNED_INTEGER, t.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = _.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4, t.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = _.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1, t.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = _.TEXTURETYPE_UNSIGNED_SHORT_5_6_5, t.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = _.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV, t.TEXTURETYPE_UNSIGNED_INT_24_8 = _.TEXTURETYPE_UNSIGNED_INT_24_8, t.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = _.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV, t.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = _.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV, t.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = _.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV, t.TEXTURE_NEAREST_SAMPLINGMODE = _.TEXTURE_NEAREST_SAMPLINGMODE, t.TEXTURE_BILINEAR_SAMPLINGMODE = _.TEXTURE_BILINEAR_SAMPLINGMODE, t.TEXTURE_TRILINEAR_SAMPLINGMODE = _.TEXTURE_TRILINEAR_SAMPLINGMODE, t.TEXTURE_NEAREST_NEAREST_MIPLINEAR = _.TEXTURE_NEAREST_NEAREST_MIPLINEAR, t.TEXTURE_LINEAR_LINEAR_MIPNEAREST = _.TEXTURE_LINEAR_LINEAR_MIPNEAREST, t.TEXTURE_LINEAR_LINEAR_MIPLINEAR = _.TEXTURE_LINEAR_LINEAR_MIPLINEAR, t.TEXTURE_NEAREST_NEAREST_MIPNEAREST = _.TEXTURE_NEAREST_NEAREST_MIPNEAREST, t.TEXTURE_NEAREST_LINEAR_MIPNEAREST = _.TEXTURE_NEAREST_LINEAR_MIPNEAREST, t.TEXTURE_NEAREST_LINEAR_MIPLINEAR = _.TEXTURE_NEAREST_LINEAR_MIPLINEAR, t.TEXTURE_NEAREST_LINEAR = _.TEXTURE_NEAREST_LINEAR, t.TEXTURE_NEAREST_NEAREST = _.TEXTURE_NEAREST_NEAREST, t.TEXTURE_LINEAR_NEAREST_MIPNEAREST = _.TEXTURE_LINEAR_NEAREST_MIPNEAREST, t.TEXTURE_LINEAR_NEAREST_MIPLINEAR = _.TEXTURE_LINEAR_NEAREST_MIPLINEAR, t.TEXTURE_LINEAR_LINEAR = _.TEXTURE_LINEAR_LINEAR, t.TEXTURE_LINEAR_NEAREST = _.TEXTURE_LINEAR_NEAREST, t.TEXTURE_EXPLICIT_MODE = _.TEXTURE_EXPLICIT_MODE, t.TEXTURE_SPHERICAL_MODE = _.TEXTURE_SPHERICAL_MODE, t.TEXTURE_PLANAR_MODE = _.TEXTURE_PLANAR_MODE, t.TEXTURE_CUBIC_MODE = _.TEXTURE_CUBIC_MODE, t.TEXTURE_PROJECTION_MODE = _.TEXTURE_PROJECTION_MODE, t.TEXTURE_SKYBOX_MODE = _.TEXTURE_SKYBOX_MODE, t.TEXTURE_INVCUBIC_MODE = _.TEXTURE_INVCUBIC_MODE, t.TEXTURE_EQUIRECTANGULAR_MODE = _.TEXTURE_EQUIRECTANGULAR_MODE, t.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = _.TEXTURE_FIXED_EQUIRECTANGULAR_MODE, t.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE, t.SCALEMODE_FLOOR = _.SCALEMODE_FLOOR, t.SCALEMODE_NEAREST = _.SCALEMODE_NEAREST, t.SCALEMODE_CEILING = _.SCALEMODE_CEILING, t._RescalePostProcessFactory = null, t._RenderPassIdCounter = 0, t;
    }(Qe), O1 = B.Compose(v.One(), oe.FromEulerAngles(0, Math.PI, 0), v.Zero()), ai = function(n) {
      function t(e, i, r) {
        i === void 0 && (i = null), r === void 0 && (r = !0);
        var o = n.call(this, e, i) || this;
        return o._forward = new v(0, 0, 1), o._up = new v(0, 1, 0), o._right = new v(1, 0, 0), o._position = v.Zero(), o._rotation = v.Zero(), o._rotationQuaternion = null, o._scaling = v.One(), o._transformToBoneReferal = null, o._isAbsoluteSynced = !1, o._billboardMode = t.BILLBOARDMODE_NONE, o._preserveParentRotationForBillboard = !1, o.scalingDeterminant = 1, o._infiniteDistance = !1, o.ignoreNonUniformScaling = !1, o.reIntegrateRotationIntoRotationQuaternion = !1, o._poseMatrix = null, o._localMatrix = B.Zero(), o._usePivotMatrix = !1, o._absolutePosition = v.Zero(), o._absoluteScaling = v.Zero(), o._absoluteRotationQuaternion = oe.Identity(), o._pivotMatrix = B.Identity(), o._postMultiplyPivotMatrix = !1, o._isWorldMatrixFrozen = !1, o._indexInSceneTransformNodesArray = -1, o.onAfterWorldMatrixUpdateObservable = new H(), o._nonUniformScaling = !1, r && o.getScene().addTransformNode(o), o;
      }
      return D(t, n), Object.defineProperty(t.prototype, "billboardMode", { get: function() {
        return this._billboardMode;
      }, set: function(e) {
        this._billboardMode !== e && (this._billboardMode = e, this._cache.useBillboardPosition = (this._billboardMode & t.BILLBOARDMODE_USE_POSITION) != 0, this._computeUseBillboardPath());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "preserveParentRotationForBillboard", { get: function() {
        return this._preserveParentRotationForBillboard;
      }, set: function(e) {
        e !== this._preserveParentRotationForBillboard && (this._preserveParentRotationForBillboard = e, this._computeUseBillboardPath());
      }, enumerable: !1, configurable: !0 }), t.prototype._computeUseBillboardPath = function() {
        this._cache.useBillboardPath = this._billboardMode !== t.BILLBOARDMODE_NONE && !this.preserveParentRotationForBillboard;
      }, Object.defineProperty(t.prototype, "infiniteDistance", { get: function() {
        return this._infiniteDistance;
      }, set: function(e) {
        this._infiniteDistance !== e && (this._infiniteDistance = e);
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "TransformNode";
      }, Object.defineProperty(t.prototype, "position", { get: function() {
        return this._position;
      }, set: function(e) {
        this._position = e, this._isDirty = !0;
      }, enumerable: !1, configurable: !0 }), t.prototype.isUsingPivotMatrix = function() {
        return this._usePivotMatrix;
      }, Object.defineProperty(t.prototype, "rotation", { get: function() {
        return this._rotation;
      }, set: function(e) {
        this._rotation = e, this._rotationQuaternion = null, this._isDirty = !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "scaling", { get: function() {
        return this._scaling;
      }, set: function(e) {
        this._scaling = e, this._isDirty = !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rotationQuaternion", { get: function() {
        return this._rotationQuaternion;
      }, set: function(e) {
        this._rotationQuaternion = e, e && this._rotation.setAll(0), this._isDirty = !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "forward", { get: function() {
        return v.TransformNormalFromFloatsToRef(0, 0, this.getScene().useRightHandedSystem ? -1 : 1, this.getWorldMatrix(), this._forward), this._forward.normalize();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "up", { get: function() {
        return v.TransformNormalFromFloatsToRef(0, 1, 0, this.getWorldMatrix(), this._up), this._up.normalize();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function() {
        return v.TransformNormalFromFloatsToRef(this.getScene().useRightHandedSystem ? -1 : 1, 0, 0, this.getWorldMatrix(), this._right), this._right.normalize();
      }, enumerable: !1, configurable: !0 }), t.prototype.updatePoseMatrix = function(e) {
        return this._poseMatrix ? (this._poseMatrix.copyFrom(e), this) : (this._poseMatrix = e.clone(), this);
      }, t.prototype.getPoseMatrix = function() {
        return this._poseMatrix || (this._poseMatrix = B.Identity()), this._poseMatrix;
      }, t.prototype._isSynchronized = function() {
        var e = this._cache;
        return !(this._billboardMode !== e.billboardMode || this._billboardMode !== t.BILLBOARDMODE_NONE || e.pivotMatrixUpdated || this._infiniteDistance || this._position._isDirty || this._scaling._isDirty || this._rotationQuaternion && this._rotationQuaternion._isDirty || this._rotation._isDirty);
      }, t.prototype._initCache = function() {
        n.prototype._initCache.call(this);
        var e = this._cache;
        e.localMatrixUpdated = !1, e.billboardMode = -1, e.infiniteDistance = !1, e.useBillboardPosition = !1, e.useBillboardPath = !1;
      }, Object.defineProperty(t.prototype, "absolutePosition", { get: function() {
        return this.getAbsolutePosition();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "absoluteScaling", { get: function() {
        return this._syncAbsoluteScalingAndRotation(), this._absoluteScaling;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "absoluteRotationQuaternion", { get: function() {
        return this._syncAbsoluteScalingAndRotation(), this._absoluteRotationQuaternion;
      }, enumerable: !1, configurable: !0 }), t.prototype.setPreTransformMatrix = function(e) {
        return this.setPivotMatrix(e, !1);
      }, t.prototype.setPivotMatrix = function(e, i) {
        return i === void 0 && (i = !0), this._pivotMatrix.copyFrom(e), this._usePivotMatrix = !this._pivotMatrix.isIdentity(), this._cache.pivotMatrixUpdated = !0, this._postMultiplyPivotMatrix = i, this._postMultiplyPivotMatrix && (this._pivotMatrixInverse ? this._pivotMatrix.invertToRef(this._pivotMatrixInverse) : this._pivotMatrixInverse = B.Invert(this._pivotMatrix)), this;
      }, t.prototype.getPivotMatrix = function() {
        return this._pivotMatrix;
      }, t.prototype.instantiateHierarchy = function(e, i, r) {
        e === void 0 && (e = null);
        var o = this.clone("Clone of " + (this.name || this.id), e || this.parent, !0);
        o && r && r(this, o);
        for (var a = 0, s = this.getChildTransformNodes(!0); a < s.length; a++)
          s[a].instantiateHierarchy(o, i, r);
        return o;
      }, t.prototype.freezeWorldMatrix = function(e, i) {
        return e === void 0 && (e = null), i === void 0 && (i = !1), e ? i ? (this._rotation.setAll(0), this._rotationQuaternion = this._rotationQuaternion || oe.Identity(), e.decompose(this._scaling, this._rotationQuaternion, this._position), this.computeWorldMatrix(!0)) : (this._worldMatrix = e, this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]), this._afterComputeWorldMatrix()) : (this._isWorldMatrixFrozen = !1, this.computeWorldMatrix(!0)), this._isDirty = !1, this._isWorldMatrixFrozen = !0, this;
      }, t.prototype.unfreezeWorldMatrix = function() {
        return this._isWorldMatrixFrozen = !1, this.computeWorldMatrix(!0), this;
      }, Object.defineProperty(t.prototype, "isWorldMatrixFrozen", { get: function() {
        return this._isWorldMatrixFrozen;
      }, enumerable: !1, configurable: !0 }), t.prototype.getAbsolutePosition = function() {
        return this.computeWorldMatrix(), this._absolutePosition;
      }, t.prototype.setAbsolutePosition = function(e) {
        if (!e)
          return this;
        var i, r, o;
        if (e.x === void 0) {
          if (arguments.length < 3)
            return this;
          i = arguments[0], r = arguments[1], o = arguments[2];
        } else
          i = e.x, r = e.y, o = e.z;
        if (this.parent) {
          var a = F.Matrix[0];
          this.parent.getWorldMatrix().invertToRef(a), v.TransformCoordinatesFromFloatsToRef(i, r, o, a, this.position);
        } else
          this.position.x = i, this.position.y = r, this.position.z = o;
        return this._absolutePosition.copyFrom(e), this;
      }, t.prototype.setPositionWithLocalVector = function(e) {
        return this.computeWorldMatrix(), this.position = v.TransformNormal(e, this._localMatrix), this;
      }, t.prototype.getPositionExpressedInLocalSpace = function() {
        this.computeWorldMatrix();
        var e = F.Matrix[0];
        return this._localMatrix.invertToRef(e), v.TransformNormal(this.position, e);
      }, t.prototype.locallyTranslate = function(e) {
        return this.computeWorldMatrix(!0), this.position = v.TransformCoordinates(e, this._localMatrix), this;
      }, t.prototype.lookAt = function(e, i, r, o, a) {
        i === void 0 && (i = 0), r === void 0 && (r = 0), o === void 0 && (o = 0), a === void 0 && (a = ht.LOCAL);
        var s = t._LookAtVectorCache, l = a === ht.LOCAL ? this.position : this.getAbsolutePosition();
        if (e.subtractToRef(l, s), this.setDirection(s, i, r, o), a === ht.WORLD && this.parent)
          if (this.rotationQuaternion) {
            var c = F.Matrix[0];
            this.rotationQuaternion.toRotationMatrix(c);
            var u = F.Matrix[1];
            this.parent.getWorldMatrix().getRotationMatrixToRef(u), u.invert(), c.multiplyToRef(u, c), this.rotationQuaternion.fromRotationMatrix(c);
          } else {
            var h = F.Quaternion[0];
            oe.FromEulerVectorToRef(this.rotation, h), c = F.Matrix[0], h.toRotationMatrix(c), u = F.Matrix[1], this.parent.getWorldMatrix().getRotationMatrixToRef(u), u.invert(), c.multiplyToRef(u, c), h.fromRotationMatrix(c), h.toEulerAnglesToRef(this.rotation);
          }
        return this;
      }, t.prototype.getDirection = function(e) {
        var i = v.Zero();
        return this.getDirectionToRef(e, i), i;
      }, t.prototype.getDirectionToRef = function(e, i) {
        return v.TransformNormalToRef(e, this.getWorldMatrix(), i), this;
      }, t.prototype.setDirection = function(e, i, r, o) {
        i === void 0 && (i = 0), r === void 0 && (r = 0), o === void 0 && (o = 0);
        var a = -Math.atan2(e.z, e.x) + Math.PI / 2, s = Math.sqrt(e.x * e.x + e.z * e.z), l = -Math.atan2(e.y, s);
        return this.rotationQuaternion ? oe.RotationYawPitchRollToRef(a + i, l + r, o, this.rotationQuaternion) : (this.rotation.x = l + r, this.rotation.y = a + i, this.rotation.z = o), this;
      }, t.prototype.setPivotPoint = function(e, i) {
        i === void 0 && (i = ht.LOCAL), this.getScene().getRenderId() == 0 && this.computeWorldMatrix(!0);
        var r = this.getWorldMatrix();
        if (i == ht.WORLD) {
          var o = F.Matrix[0];
          r.invertToRef(o), e = v.TransformCoordinates(e, o);
        }
        return this.setPivotMatrix(B.Translation(-e.x, -e.y, -e.z), !0);
      }, t.prototype.getPivotPoint = function() {
        var e = v.Zero();
        return this.getPivotPointToRef(e), e;
      }, t.prototype.getPivotPointToRef = function(e) {
        return e.x = -this._pivotMatrix.m[12], e.y = -this._pivotMatrix.m[13], e.z = -this._pivotMatrix.m[14], this;
      }, t.prototype.getAbsolutePivotPoint = function() {
        var e = v.Zero();
        return this.getAbsolutePivotPointToRef(e), e;
      }, t.prototype.getAbsolutePivotPointToRef = function(e) {
        return this.getPivotPointToRef(e), v.TransformCoordinatesToRef(e, this.getWorldMatrix(), e), this;
      }, t.prototype.markAsDirty = function(e) {
        if (this._isDirty)
          return this;
        if (this._children)
          for (var i = 0, r = this._children; i < r.length; i++)
            r[i].markAsDirty(e);
        return n.prototype.markAsDirty.call(this, e);
      }, t.prototype.setParent = function(e, i, r) {
        if (i === void 0 && (i = !1), r === void 0 && (r = !1), !e && !this.parent)
          return this;
        var o = F.Quaternion[0], a = F.Vector3[0], s = F.Vector3[1], l = F.Matrix[1];
        B.IdentityToRef(l);
        var c = F.Matrix[0];
        this.computeWorldMatrix(!0);
        var u = this.rotationQuaternion;
        return u || (u = t._TmpRotation, oe.RotationYawPitchRollToRef(this._rotation.y, this._rotation.x, this._rotation.z, u)), B.ComposeToRef(this.scaling, u, this.position, c), this.parent && c.multiplyToRef(this.parent.computeWorldMatrix(!0), c), e && (e.computeWorldMatrix(!0).invertToRef(l), c.multiplyToRef(l, c)), c.decompose(s, o, a, i ? this : void 0), this.rotationQuaternion ? this.rotationQuaternion.copyFrom(o) : o.toEulerAnglesToRef(this.rotation), this.scaling.copyFrom(s), this.position.copyFrom(a), this.parent = e, r && this.setPivotMatrix(B.Identity()), this;
      }, Object.defineProperty(t.prototype, "nonUniformScaling", { get: function() {
        return this._nonUniformScaling;
      }, enumerable: !1, configurable: !0 }), t.prototype._updateNonUniformScalingState = function(e) {
        return this._nonUniformScaling !== e && (this._nonUniformScaling = e, !0);
      }, t.prototype.attachToBone = function(e, i) {
        return this._currentParentWhenAttachingToBone = this.parent, this._transformToBoneReferal = i, this.parent = e, e.getSkeleton().prepare(!0), e.getFinalMatrix().determinant() < 0 && (this.scalingDeterminant *= -1), this;
      }, t.prototype.detachFromBone = function(e) {
        return e === void 0 && (e = !1), this.parent ? (this.parent.getWorldMatrix().determinant() < 0 && (this.scalingDeterminant *= -1), this._transformToBoneReferal = null, this.parent = e ? this._currentParentWhenAttachingToBone : null, this) : (e && (this.parent = this._currentParentWhenAttachingToBone), this);
      }, t.prototype.rotate = function(e, i, r) {
        var o;
        if (e.normalize(), this.rotationQuaternion || (this.rotationQuaternion = this.rotation.toQuaternion(), this.rotation.setAll(0)), r && r !== ht.LOCAL) {
          if (this.parent) {
            var a = this.parent.getWorldMatrix(), s = F.Matrix[0];
            a.invertToRef(s), e = v.TransformNormal(e, s), a.determinant() < 0 && (i *= -1);
          }
          (o = oe.RotationAxisToRef(e, i, t._RotationAxisCache)).multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
        } else
          o = oe.RotationAxisToRef(e, i, t._RotationAxisCache), this.rotationQuaternion.multiplyToRef(o, this.rotationQuaternion);
        return this;
      }, t.prototype.rotateAround = function(e, i, r) {
        i.normalize(), this.rotationQuaternion || (this.rotationQuaternion = oe.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z), this.rotation.setAll(0));
        var o = F.Vector3[0], a = F.Vector3[1], s = F.Vector3[2], l = F.Quaternion[0], c = F.Matrix[0], u = F.Matrix[1], h = F.Matrix[2], d = F.Matrix[3];
        return e.subtractToRef(this.position, o), B.TranslationToRef(o.x, o.y, o.z, c), B.TranslationToRef(-o.x, -o.y, -o.z, u), B.RotationAxisToRef(i, r, h), u.multiplyToRef(h, d), d.multiplyToRef(c, d), d.decompose(a, l, s), this.position.addInPlace(s), l.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion), this;
      }, t.prototype.translate = function(e, i, r) {
        var o = e.scale(i);
        if (r && r !== ht.LOCAL)
          this.setAbsolutePosition(this.getAbsolutePosition().add(o));
        else {
          var a = this.getPositionExpressedInLocalSpace().add(o);
          this.setPositionWithLocalVector(a);
        }
        return this;
      }, t.prototype.addRotation = function(e, i, r) {
        var o;
        this.rotationQuaternion ? o = this.rotationQuaternion : (o = F.Quaternion[1], oe.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, o));
        var a = F.Quaternion[0];
        return oe.RotationYawPitchRollToRef(i, e, r, a), o.multiplyInPlace(a), this.rotationQuaternion || o.toEulerAnglesToRef(this.rotation), this;
      }, t.prototype._getEffectiveParent = function() {
        return this.parent;
      }, t.prototype.isWorldMatrixCameraDependent = function() {
        return this._infiniteDistance && !this.parent || this._billboardMode !== t.BILLBOARDMODE_NONE && !this.preserveParentRotationForBillboard;
      }, t.prototype.computeWorldMatrix = function(e, i) {
        if (e === void 0 && (e = !1), i === void 0 && (i = null), this._isWorldMatrixFrozen && !this._isDirty)
          return this._worldMatrix;
        var r = this.getScene().getRenderId();
        if (!this._isDirty && !e && (this._currentRenderId === r || this.isSynchronized()))
          return this._currentRenderId = r, this._worldMatrix;
        i = i || this.getScene().activeCamera, this._updateCache();
        var o = this._cache;
        o.pivotMatrixUpdated = !1, o.billboardMode = this.billboardMode, o.infiniteDistance = this.infiniteDistance, o.parent = this._parentNode, this._currentRenderId = r, this._childUpdateId += 1, this._isDirty = !1, this._position._isDirty = !1, this._rotation._isDirty = !1, this._scaling._isDirty = !1;
        var a, s = this._getEffectiveParent(), l = t._TmpScaling, c = this._position;
        if (this._infiniteDistance && !this.parent && i) {
          var u = i.getWorldMatrix(), h = new v(u.m[12], u.m[13], u.m[14]);
          (c = t._TmpTranslation).copyFromFloats(this._position.x + h.x, this._position.y + h.y, this._position.z + h.z);
        }
        if (l.copyFromFloats(this._scaling.x * this.scalingDeterminant, this._scaling.y * this.scalingDeterminant, this._scaling.z * this.scalingDeterminant), this._rotationQuaternion ? (this._rotationQuaternion._isDirty = !1, a = this._rotationQuaternion, this.reIntegrateRotationIntoRotationQuaternion && (R = this.rotation.lengthSquared()) && (this._rotationQuaternion.multiplyInPlace(oe.RotationYawPitchRoll(this._rotation.y, this._rotation.x, this._rotation.z)), this._rotation.copyFromFloats(0, 0, 0))) : (a = t._TmpRotation, oe.RotationYawPitchRollToRef(this._rotation.y, this._rotation.x, this._rotation.z, a)), this._usePivotMatrix) {
          var d = F.Matrix[1];
          B.ScalingToRef(l.x, l.y, l.z, d);
          var p = F.Matrix[0];
          a.toRotationMatrix(p), this._pivotMatrix.multiplyToRef(d, F.Matrix[4]), F.Matrix[4].multiplyToRef(p, this._localMatrix), this._postMultiplyPivotMatrix && this._localMatrix.multiplyToRef(this._pivotMatrixInverse, this._localMatrix), this._localMatrix.addTranslationFromFloats(c.x, c.y, c.z);
        } else
          B.ComposeToRef(l, a, c, this._localMatrix);
        if (s && s.getWorldMatrix) {
          if (e && s.computeWorldMatrix(e), o.useBillboardPath) {
            this._transformToBoneReferal ? ((y = this.parent).getSkeleton().prepare(), y.getFinalMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), F.Matrix[7])) : F.Matrix[7].copyFrom(s.getWorldMatrix());
            var f = F.Vector3[5], m = F.Vector3[6], g = F.Quaternion[0];
            F.Matrix[7].decompose(m, g, f), B.ScalingToRef(m.x, m.y, m.z, F.Matrix[7]), F.Matrix[7].setTranslation(f), t.BillboardUseParentOrientation && (this._position.applyRotationQuaternionToRef(g, f), this._localMatrix.setTranslation(f)), this._localMatrix.multiplyToRef(F.Matrix[7], this._worldMatrix);
          } else {
            var y;
            this._transformToBoneReferal ? ((y = this.parent).getSkeleton().prepare(), this._localMatrix.multiplyToRef(y.getFinalMatrix(), F.Matrix[6]), F.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix)) : this._localMatrix.multiplyToRef(s.getWorldMatrix(), this._worldMatrix);
          }
          this._markSyncedWithParent();
        } else
          this._worldMatrix.copyFrom(this._localMatrix);
        if (o.useBillboardPath && i && this.billboardMode && !o.useBillboardPosition) {
          var b = F.Vector3[0];
          if (this._worldMatrix.getTranslationToRef(b), F.Matrix[1].copyFrom(i.getViewMatrix()), this._scene.useRightHandedSystem && F.Matrix[1].multiplyToRef(O1, F.Matrix[1]), F.Matrix[1].setTranslationFromFloats(0, 0, 0), F.Matrix[1].invertToRef(F.Matrix[0]), (this.billboardMode & t.BILLBOARDMODE_ALL) !== t.BILLBOARDMODE_ALL) {
            F.Matrix[0].decompose(void 0, F.Quaternion[0], void 0);
            var T = F.Vector3[1];
            F.Quaternion[0].toEulerAnglesToRef(T), (this.billboardMode & t.BILLBOARDMODE_X) !== t.BILLBOARDMODE_X && (T.x = 0), (this.billboardMode & t.BILLBOARDMODE_Y) !== t.BILLBOARDMODE_Y && (T.y = 0), (this.billboardMode & t.BILLBOARDMODE_Z) !== t.BILLBOARDMODE_Z && (T.z = 0), B.RotationYawPitchRollToRef(T.y, T.x, T.z, F.Matrix[0]);
          }
          this._worldMatrix.setTranslationFromFloats(0, 0, 0), this._worldMatrix.multiplyToRef(F.Matrix[0], this._worldMatrix), this._worldMatrix.setTranslation(F.Vector3[0]);
        } else if (o.useBillboardPath && i && o.useBillboardPosition) {
          b = F.Vector3[0], this._worldMatrix.getTranslationToRef(b);
          var S = i.globalPosition;
          this._worldMatrix.invertToRef(F.Matrix[1]);
          var E = F.Vector3[1];
          v.TransformCoordinatesToRef(S, F.Matrix[1], E), E.normalize();
          var A = -Math.atan2(E.z, E.x) + Math.PI / 2, R = Math.sqrt(E.x * E.x + E.z * E.z), C = -Math.atan2(E.y, R);
          oe.RotationYawPitchRollToRef(A, C, 0, F.Quaternion[0]), (this.billboardMode & t.BILLBOARDMODE_ALL) !== t.BILLBOARDMODE_ALL ? (T = F.Vector3[1], F.Quaternion[0].toEulerAnglesToRef(T), (this.billboardMode & t.BILLBOARDMODE_X) !== t.BILLBOARDMODE_X && (T.x = 0), (this.billboardMode & t.BILLBOARDMODE_Y) !== t.BILLBOARDMODE_Y && (T.y = 0), (this.billboardMode & t.BILLBOARDMODE_Z) !== t.BILLBOARDMODE_Z && (T.z = 0), B.RotationYawPitchRollToRef(T.y, T.x, T.z, F.Matrix[0])) : B.FromQuaternionToRef(F.Quaternion[0], F.Matrix[0]), this._worldMatrix.setTranslationFromFloats(0, 0, 0), this._worldMatrix.multiplyToRef(F.Matrix[0], this._worldMatrix), this._worldMatrix.setTranslation(F.Vector3[0]);
        }
        return this.ignoreNonUniformScaling ? this._updateNonUniformScalingState(!1) : this._scaling.isNonUniformWithinEpsilon(1e-6) ? this._updateNonUniformScalingState(!0) : s && s._nonUniformScaling ? this._updateNonUniformScalingState(s._nonUniformScaling) : this._updateNonUniformScalingState(!1), this._afterComputeWorldMatrix(), this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]), this._isAbsoluteSynced = !1, this.onAfterWorldMatrixUpdateObservable.notifyObservers(this), this._poseMatrix || (this._poseMatrix = B.Invert(this._worldMatrix)), this._worldMatrixDeterminantIsDirty = !0, this._worldMatrix;
      }, t.prototype.resetLocalMatrix = function(e) {
        if (e === void 0 && (e = !0), this.computeWorldMatrix(), e)
          for (var i = this.getChildren(), r = 0; r < i.length; ++r) {
            var o = i[r];
            if (o) {
              o.computeWorldMatrix();
              var a = F.Matrix[0];
              o._localMatrix.multiplyToRef(this._localMatrix, a);
              var s = F.Quaternion[0];
              a.decompose(o.scaling, s, o.position), o.rotationQuaternion ? o.rotationQuaternion.copyFrom(s) : s.toEulerAnglesToRef(o.rotation);
            }
          }
        this.scaling.copyFromFloats(1, 1, 1), this.position.copyFromFloats(0, 0, 0), this.rotation.copyFromFloats(0, 0, 0), this.rotationQuaternion && (this.rotationQuaternion = oe.Identity()), this._worldMatrix = B.Identity();
      }, t.prototype._afterComputeWorldMatrix = function() {
      }, t.prototype.registerAfterWorldMatrixUpdate = function(e) {
        return this.onAfterWorldMatrixUpdateObservable.add(e), this;
      }, t.prototype.unregisterAfterWorldMatrixUpdate = function(e) {
        return this.onAfterWorldMatrixUpdateObservable.removeCallback(e), this;
      }, t.prototype.getPositionInCameraSpace = function(e) {
        return e === void 0 && (e = null), e || (e = this.getScene().activeCamera), v.TransformCoordinates(this.getAbsolutePosition(), e.getViewMatrix());
      }, t.prototype.getDistanceToCamera = function(e) {
        return e === void 0 && (e = null), e || (e = this.getScene().activeCamera), this.getAbsolutePosition().subtract(e.globalPosition).length();
      }, t.prototype.clone = function(e, i, r) {
        var o = this, a = Ne.Clone(function() {
          return new t(e, o.getScene());
        }, this);
        if (a.name = e, a.id = e, i && (a.parent = i), !r)
          for (var s = this.getDescendants(!0), l = 0; l < s.length; l++) {
            var c = s[l];
            c.clone && c.clone(e + "." + c.name, a);
          }
        return a;
      }, t.prototype.serialize = function(e) {
        var i = Ne.Serialize(this, e);
        return i.type = this.getClassName(), i.uniqueId = this.uniqueId, this.parent && this.parent._serializeAsParent(i), i.localMatrix = this.getPivotMatrix().asArray(), i.isEnabled = this.isEnabled(), i;
      }, t.Parse = function(e, i, r) {
        var o = Ne.Parse(function() {
          return new t(e.name, i);
        }, e, i, r);
        return e.localMatrix ? o.setPreTransformMatrix(B.FromArray(e.localMatrix)) : e.pivotMatrix && o.setPivotMatrix(B.FromArray(e.pivotMatrix)), o.setEnabled(e.isEnabled), o._waitingParsedUniqueId = e.uniqueId, e.parentId !== void 0 && (o._waitingParentId = e.parentId), e.parentInstanceIndex !== void 0 && (o._waitingParentInstanceIndex = e.parentInstanceIndex), o;
      }, t.prototype.getChildTransformNodes = function(e, i) {
        var r = [];
        return this._getDescendants(r, e, function(o) {
          return (!i || i(o)) && o instanceof t;
        }), r;
      }, t.prototype.dispose = function(e, i) {
        if (i === void 0 && (i = !1), this.getScene().stopAnimation(this), this.getScene().removeTransformNode(this), this._parentContainer) {
          var r = this._parentContainer.transformNodes.indexOf(this);
          r > -1 && this._parentContainer.transformNodes.splice(r, 1), this._parentContainer = null;
        }
        if (this.onAfterWorldMatrixUpdateObservable.clear(), e)
          for (var o = 0, a = this.getChildTransformNodes(!0); o < a.length; o++) {
            var s = a[o];
            s.parent = null, s.computeWorldMatrix(!0);
          }
        n.prototype.dispose.call(this, e, i);
      }, t.prototype.normalizeToUnitCube = function(e, i, r) {
        e === void 0 && (e = !0), i === void 0 && (i = !1);
        var o = null, a = null;
        i && (this.rotationQuaternion ? (a = this.rotationQuaternion.clone(), this.rotationQuaternion.copyFromFloats(0, 0, 0, 1)) : this.rotation && (o = this.rotation.clone(), this.rotation.copyFromFloats(0, 0, 0)));
        var s = this.getHierarchyBoundingVectors(e, r), l = s.max.subtract(s.min), c = Math.max(l.x, l.y, l.z);
        if (c === 0)
          return this;
        var u = 1 / c;
        return this.scaling.scaleInPlace(u), i && (this.rotationQuaternion && a ? this.rotationQuaternion.copyFrom(a) : this.rotation && o && this.rotation.copyFrom(o)), this;
      }, t.prototype._syncAbsoluteScalingAndRotation = function() {
        this._isAbsoluteSynced || (this._worldMatrix.decompose(this._absoluteScaling, this._absoluteRotationQuaternion), this._isAbsoluteSynced = !0);
      }, t.BILLBOARDMODE_NONE = 0, t.BILLBOARDMODE_X = 1, t.BILLBOARDMODE_Y = 2, t.BILLBOARDMODE_Z = 4, t.BILLBOARDMODE_ALL = 7, t.BILLBOARDMODE_USE_POSITION = 128, t.BillboardUseParentOrientation = !1, t._TmpRotation = oe.Zero(), t._TmpScaling = v.Zero(), t._TmpTranslation = v.Zero(), t._LookAtVectorCache = new v(0, 0, 0), t._RotationAxisCache = new oe(), x([ki("position")], t.prototype, "_position", void 0), x([ki("rotation")], t.prototype, "_rotation", void 0), x([ql("rotationQuaternion")], t.prototype, "_rotationQuaternion", void 0), x([ki("scaling")], t.prototype, "_scaling", void 0), x([N("billboardMode")], t.prototype, "_billboardMode", void 0), x([N()], t.prototype, "scalingDeterminant", void 0), x([N("infiniteDistance")], t.prototype, "_infiniteDistance", void 0), x([N()], t.prototype, "ignoreNonUniformScaling", void 0), x([N()], t.prototype, "reIntegrateRotationIntoRotationQuaternion", void 0), t;
    }(oi), Tg = function() {
      this._checkCollisions = !1, this._collisionMask = -1, this._collisionGroup = -1, this._surroundingMeshes = null, this._collider = null, this._oldPositionForCollisions = new v(0, 0, 0), this._diffPositionForCollisions = new v(0, 0, 0), this._collisionResponse = !0;
    }, D1 = function() {
      this.facetNb = 0, this.partitioningSubdivisions = 10, this.partitioningBBoxRatio = 1.01, this.facetDataEnabled = !1, this.facetParameters = {}, this.bbSize = v.Zero(), this.subDiv = { max: 1, X: 1, Y: 1, Z: 1 }, this.facetDepthSort = !1, this.facetDepthSortEnabled = !1;
    }, N1 = function() {
      this._hasVertexAlpha = !1, this._useVertexColors = !0, this._numBoneInfluencers = 4, this._applyFog = !0, this._receiveShadows = !1, this._facetData = new D1(), this._visibility = 1, this._skeleton = null, this._layerMask = 268435455, this._computeBonesUsingShaders = !0, this._isActive = !1, this._onlyForInstances = !1, this._isActiveIntermediate = !1, this._onlyForInstancesIntermediate = !1, this._actAsRegularMesh = !1, this._currentLOD = null, this._currentLODIsUpToDate = !1, this._collisionRetryCount = 3, this._morphTargetManager = null, this._renderingGroupId = 0, this._bakedVertexAnimationManager = null, this._material = null, this._positions = null, this._pointerOverDisableMeshTesting = !1, this._meshCollisionData = new Tg(), this._enableDistantPicking = !1, this._rawBoundingInfo = null;
    }, Dt = function(n) {
      function t(e, i) {
        i === void 0 && (i = null);
        var r = n.call(this, e, i, !1) || this;
        switch (r._internalAbstractMeshDataInfo = new N1(), r._waitingMaterialId = null, r.cullingStrategy = t.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY, r.onCollideObservable = new H(), r.onCollisionPositionChangeObservable = new H(), r.onMaterialChangedObservable = new H(), r.definedFacingForward = !0, r._occlusionQuery = null, r._renderingGroup = null, r.alphaIndex = Number.MAX_VALUE, r.isVisible = !0, r.isPickable = !0, r.isNearPickable = !1, r.isNearGrabbable = !1, r.showSubMeshesBoundingBox = !1, r.isBlocker = !1, r.enablePointerMoveEvents = !1, r.outlineColor = ne.Red(), r.outlineWidth = 0.02, r.overlayColor = ne.Red(), r.overlayAlpha = 0.5, r.useOctreeForRenderingSelection = !0, r.useOctreeForPicking = !0, r.useOctreeForCollisions = !0, r.alwaysSelectAsActiveMesh = !1, r.doNotSyncBoundingInfo = !1, r.actionManager = null, r.ellipsoid = new v(0.5, 1, 0.5), r.ellipsoidOffset = new v(0, 0, 0), r.edgesWidth = 1, r.edgesColor = new Ie(1, 0, 0, 1), r._edgesRenderer = null, r._masterMesh = null, r._boundingInfo = null, r._boundingInfoIsDirty = !0, r._renderId = 0, r._intersectionsInProgress = new Array(), r._unIndexed = !1, r._lightSources = new Array(), r._waitingData = { lods: null, actions: null, freezeWorldMatrix: null }, r._bonesTransformMatrices = null, r._transformMatrixTexture = null, r.onRebuildObservable = new H(), r._onCollisionPositionChange = function(o, a, s) {
          s === void 0 && (s = null), a.subtractToRef(r._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions, r._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions), r._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions.length() > ve.CollisionsEpsilon && r.position.addInPlace(r._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions), s && r.onCollideObservable.notifyObservers(s), r.onCollisionPositionChangeObservable.notifyObservers(r.position);
        }, (i = r.getScene()).addMesh(r), r._resyncLightSources(), r._uniformBuffer = new Er(r.getScene().getEngine(), void 0, void 0, e, !r.getScene().getEngine().isWebGPU), r._buildUniformLayout(), i.performancePriority) {
          case Zr.Aggressive:
            r.doNotSyncBoundingInfo = !0;
          case Zr.Intermediate:
            r.alwaysSelectAsActiveMesh = !0, r.isPickable = !1;
        }
        return r;
      }
      return D(t, n), Object.defineProperty(t, "BILLBOARDMODE_NONE", { get: function() {
        return ai.BILLBOARDMODE_NONE;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "BILLBOARDMODE_X", { get: function() {
        return ai.BILLBOARDMODE_X;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "BILLBOARDMODE_Y", { get: function() {
        return ai.BILLBOARDMODE_Y;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "BILLBOARDMODE_Z", { get: function() {
        return ai.BILLBOARDMODE_Z;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "BILLBOARDMODE_ALL", { get: function() {
        return ai.BILLBOARDMODE_ALL;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "BILLBOARDMODE_USE_POSITION", { get: function() {
        return ai.BILLBOARDMODE_USE_POSITION;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "facetNb", { get: function() {
        return this._internalAbstractMeshDataInfo._facetData.facetNb;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "partitioningSubdivisions", { get: function() {
        return this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions;
      }, set: function(e) {
        this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "partitioningBBoxRatio", { get: function() {
        return this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio;
      }, set: function(e) {
        this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "mustDepthSortFacets", { get: function() {
        return this._internalAbstractMeshDataInfo._facetData.facetDepthSort;
      }, set: function(e) {
        this._internalAbstractMeshDataInfo._facetData.facetDepthSort = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "facetDepthSortFrom", { get: function() {
        return this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom;
      }, set: function(e) {
        this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "collisionRetryCount", { get: function() {
        return this._internalAbstractMeshDataInfo._collisionRetryCount;
      }, set: function(e) {
        this._internalAbstractMeshDataInfo._collisionRetryCount = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isFacetDataEnabled", { get: function() {
        return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "morphTargetManager", { get: function() {
        return this._internalAbstractMeshDataInfo._morphTargetManager;
      }, set: function(e) {
        this._internalAbstractMeshDataInfo._morphTargetManager !== e && (this._internalAbstractMeshDataInfo._morphTargetManager = e, this._syncGeometryWithMorphTargetManager());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "bakedVertexAnimationManager", { get: function() {
        return this._internalAbstractMeshDataInfo._bakedVertexAnimationManager;
      }, set: function(e) {
        this._internalAbstractMeshDataInfo._bakedVertexAnimationManager !== e && (this._internalAbstractMeshDataInfo._bakedVertexAnimationManager = e, this._markSubMeshesAsAttributesDirty());
      }, enumerable: !1, configurable: !0 }), t.prototype._syncGeometryWithMorphTargetManager = function() {
      }, t.prototype._updateNonUniformScalingState = function(e) {
        return !!n.prototype._updateNonUniformScalingState.call(this, e) && (this._markSubMeshesAsMiscDirty(), !0);
      }, Object.defineProperty(t.prototype, "rawBoundingInfo", { get: function() {
        return this._internalAbstractMeshDataInfo._rawBoundingInfo;
      }, set: function(e) {
        this._internalAbstractMeshDataInfo._rawBoundingInfo = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onCollide", { set: function(e) {
        this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver && this.onCollideObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver), this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver = this.onCollideObservable.add(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onCollisionPositionChange", { set: function(e) {
        this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver && this.onCollisionPositionChangeObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver), this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver = this.onCollisionPositionChangeObservable.add(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "visibility", { get: function() {
        return this._internalAbstractMeshDataInfo._visibility;
      }, set: function(e) {
        if (this._internalAbstractMeshDataInfo._visibility !== e) {
          var i = this._internalAbstractMeshDataInfo._visibility;
          this._internalAbstractMeshDataInfo._visibility = e, (i === 1 && e !== 1 || i !== 1 && e === 1) && this._markSubMeshesAsDirty(function(r) {
            r.markAsMiscDirty(), r.markAsPrePassDirty();
          });
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "pointerOverDisableMeshTesting", { get: function() {
        return this._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting;
      }, set: function(e) {
        this._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "renderingGroupId", { get: function() {
        return this._internalAbstractMeshDataInfo._renderingGroupId;
      }, set: function(e) {
        this._internalAbstractMeshDataInfo._renderingGroupId = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "material", { get: function() {
        return this._internalAbstractMeshDataInfo._material;
      }, set: function(e) {
        this._internalAbstractMeshDataInfo._material !== e && (this._internalAbstractMeshDataInfo._material && this._internalAbstractMeshDataInfo._material.meshMap && (this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId] = void 0), this._internalAbstractMeshDataInfo._material = e, e && e.meshMap && (e.meshMap[this.uniqueId] = this), this.onMaterialChangedObservable.hasObservers() && this.onMaterialChangedObservable.notifyObservers(this), this.subMeshes && (this.resetDrawCache(), this._unBindEffect()));
      }, enumerable: !1, configurable: !0 }), t.prototype.getMaterialForRenderPass = function(e) {
        var i;
        return (i = this._internalAbstractMeshDataInfo._materialForRenderPass) === null || i === void 0 ? void 0 : i[e];
      }, t.prototype.setMaterialForRenderPass = function(e, i) {
        this.resetDrawCache(e), this._internalAbstractMeshDataInfo._materialForRenderPass || (this._internalAbstractMeshDataInfo._materialForRenderPass = []), this._internalAbstractMeshDataInfo._materialForRenderPass[e] = i;
      }, Object.defineProperty(t.prototype, "receiveShadows", { get: function() {
        return this._internalAbstractMeshDataInfo._receiveShadows;
      }, set: function(e) {
        this._internalAbstractMeshDataInfo._receiveShadows !== e && (this._internalAbstractMeshDataInfo._receiveShadows = e, this._markSubMeshesAsLightDirty());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hasVertexAlpha", { get: function() {
        return this._internalAbstractMeshDataInfo._hasVertexAlpha;
      }, set: function(e) {
        this._internalAbstractMeshDataInfo._hasVertexAlpha !== e && (this._internalAbstractMeshDataInfo._hasVertexAlpha = e, this._markSubMeshesAsAttributesDirty(), this._markSubMeshesAsMiscDirty());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "useVertexColors", { get: function() {
        return this._internalAbstractMeshDataInfo._useVertexColors;
      }, set: function(e) {
        this._internalAbstractMeshDataInfo._useVertexColors !== e && (this._internalAbstractMeshDataInfo._useVertexColors = e, this._markSubMeshesAsAttributesDirty());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "computeBonesUsingShaders", { get: function() {
        return this._internalAbstractMeshDataInfo._computeBonesUsingShaders;
      }, set: function(e) {
        this._internalAbstractMeshDataInfo._computeBonesUsingShaders !== e && (this._internalAbstractMeshDataInfo._computeBonesUsingShaders = e, this._markSubMeshesAsAttributesDirty());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "numBoneInfluencers", { get: function() {
        return this._internalAbstractMeshDataInfo._numBoneInfluencers;
      }, set: function(e) {
        this._internalAbstractMeshDataInfo._numBoneInfluencers !== e && (this._internalAbstractMeshDataInfo._numBoneInfluencers = e, this._markSubMeshesAsAttributesDirty());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "applyFog", { get: function() {
        return this._internalAbstractMeshDataInfo._applyFog;
      }, set: function(e) {
        this._internalAbstractMeshDataInfo._applyFog !== e && (this._internalAbstractMeshDataInfo._applyFog = e, this._markSubMeshesAsMiscDirty());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "enableDistantPicking", { get: function() {
        return this._internalAbstractMeshDataInfo._enableDistantPicking;
      }, set: function(e) {
        this._internalAbstractMeshDataInfo._enableDistantPicking = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "layerMask", { get: function() {
        return this._internalAbstractMeshDataInfo._layerMask;
      }, set: function(e) {
        e !== this._internalAbstractMeshDataInfo._layerMask && (this._internalAbstractMeshDataInfo._layerMask = e, this._resyncLightSources());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "collisionMask", { get: function() {
        return this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask;
      }, set: function(e) {
        this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask = isNaN(e) ? -1 : e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "collisionResponse", { get: function() {
        return this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse;
      }, set: function(e) {
        this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "collisionGroup", { get: function() {
        return this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup;
      }, set: function(e) {
        this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup = isNaN(e) ? -1 : e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "surroundingMeshes", { get: function() {
        return this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes;
      }, set: function(e) {
        this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "lightSources", { get: function() {
        return this._lightSources;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "_positions", { get: function() {
        return null;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "skeleton", { get: function() {
        return this._internalAbstractMeshDataInfo._skeleton;
      }, set: function(e) {
        var i = this._internalAbstractMeshDataInfo._skeleton;
        i && i.needInitialSkinMatrix && i._unregisterMeshWithPoseMatrix(this), e && e.needInitialSkinMatrix && e._registerMeshWithPoseMatrix(this), this._internalAbstractMeshDataInfo._skeleton = e, this._internalAbstractMeshDataInfo._skeleton || (this._bonesTransformMatrices = null), this._markSubMeshesAsAttributesDirty();
      }, enumerable: !1, configurable: !0 }), t.prototype._buildUniformLayout = function() {
        this._uniformBuffer.addUniform("world", 16), this._uniformBuffer.addUniform("visibility", 1), this._uniformBuffer.create();
      }, t.prototype.transferToEffect = function(e) {
        var i = this._uniformBuffer;
        i.updateMatrix("world", e), i.updateFloat("visibility", this._internalAbstractMeshDataInfo._visibility), i.update();
      }, t.prototype.getMeshUniformBuffer = function() {
        return this._uniformBuffer;
      }, t.prototype.getClassName = function() {
        return "AbstractMesh";
      }, t.prototype.toString = function(e) {
        var i = "Name: " + this.name + ", isInstance: " + (this.getClassName() !== "InstancedMesh" ? "YES" : "NO");
        i += ", # of submeshes: " + (this.subMeshes ? this.subMeshes.length : 0);
        var r = this._internalAbstractMeshDataInfo._skeleton;
        return r && (i += ", skeleton: " + r.name), e && (i += ", billboard mode: " + ["NONE", "X", "Y", null, "Z", null, null, "ALL"][this.billboardMode], i += ", freeze wrld mat: " + (this._isWorldMatrixFrozen || this._waitingData.freezeWorldMatrix ? "YES" : "NO")), i;
      }, t.prototype._getEffectiveParent = function() {
        return this._masterMesh && this.billboardMode !== ai.BILLBOARDMODE_NONE ? this._masterMesh : n.prototype._getEffectiveParent.call(this);
      }, t.prototype._getActionManagerForTrigger = function(e, i) {
        if (i === void 0 && (i = !0), this.actionManager && (i || this.actionManager.isRecursive)) {
          if (!e)
            return this.actionManager;
          if (this.actionManager.hasSpecificTrigger(e))
            return this.actionManager;
        }
        return this.parent ? this.parent._getActionManagerForTrigger(e, !1) : null;
      }, t.prototype._rebuild = function(e) {
        if (this.onRebuildObservable.notifyObservers(this), this._occlusionQuery !== null && (this._occlusionQuery = null), this.subMeshes)
          for (var i = 0, r = this.subMeshes; i < r.length; i++)
            r[i]._rebuild();
      }, t.prototype._resyncLightSources = function() {
        this._lightSources.length = 0;
        for (var e = 0, i = this.getScene().lights; e < i.length; e++) {
          var r = i[e];
          r.isEnabled() && r.canAffectMesh(this) && this._lightSources.push(r);
        }
        this._markSubMeshesAsLightDirty();
      }, t.prototype._resyncLightSource = function(e) {
        var i = e.isEnabled() && e.canAffectMesh(this), r = this._lightSources.indexOf(e), o = !1;
        if (r === -1) {
          if (!i)
            return;
          this._lightSources.push(e);
        } else {
          if (i)
            return;
          o = !0, this._lightSources.splice(r, 1);
        }
        this._markSubMeshesAsLightDirty(o);
      }, t.prototype._unBindEffect = function() {
        for (var e = 0, i = this.subMeshes; e < i.length; e++)
          i[e].setEffect(null);
      }, t.prototype._removeLightSource = function(e, i) {
        var r = this._lightSources.indexOf(e);
        r !== -1 && (this._lightSources.splice(r, 1), this._markSubMeshesAsLightDirty(i));
      }, t.prototype._markSubMeshesAsDirty = function(e) {
        if (this.subMeshes)
          for (var i = 0, r = this.subMeshes; i < r.length; i++)
            for (var o = r[i], a = 0; a < o._drawWrappers.length; ++a) {
              var s = o._drawWrappers[a];
              s && s.defines && s.defines.markAllAsDirty && e(s.defines);
            }
      }, t.prototype._markSubMeshesAsLightDirty = function(e) {
        e === void 0 && (e = !1), this._markSubMeshesAsDirty(function(i) {
          return i.markAsLightDirty(e);
        });
      }, t.prototype._markSubMeshesAsAttributesDirty = function() {
        this._markSubMeshesAsDirty(function(e) {
          return e.markAsAttributesDirty();
        });
      }, t.prototype._markSubMeshesAsMiscDirty = function() {
        this._markSubMeshesAsDirty(function(e) {
          return e.markAsMiscDirty();
        });
      }, t.prototype.markAsDirty = function(e) {
        return this._currentRenderId = Number.MAX_VALUE, this._isDirty = !0, this;
      }, t.prototype.resetDrawCache = function(e) {
        if (this.subMeshes)
          for (var i = 0, r = this.subMeshes; i < r.length; i++)
            r[i].resetDrawCache(e);
      }, Object.defineProperty(t.prototype, "isBlocked", { get: function() {
        return !1;
      }, enumerable: !1, configurable: !0 }), t.prototype.getLOD = function(e) {
        return this;
      }, t.prototype.getTotalVertices = function() {
        return 0;
      }, t.prototype.getTotalIndices = function() {
        return 0;
      }, t.prototype.getIndices = function() {
        return null;
      }, t.prototype.getVerticesData = function(e) {
        return null;
      }, t.prototype.setVerticesData = function(e, i, r, o) {
        return this;
      }, t.prototype.updateVerticesData = function(e, i, r, o) {
        return this;
      }, t.prototype.setIndices = function(e, i) {
        return this;
      }, t.prototype.isVerticesDataPresent = function(e) {
        return !1;
      }, t.prototype.getBoundingInfo = function() {
        return this._masterMesh ? this._masterMesh.getBoundingInfo() : (this._boundingInfoIsDirty && (this._boundingInfoIsDirty = !1, this._updateBoundingInfo()), this._boundingInfo);
      }, t.prototype.getRawBoundingInfo = function() {
        var e;
        return (e = this.rawBoundingInfo) !== null && e !== void 0 ? e : this.getBoundingInfo();
      }, t.prototype.setBoundingInfo = function(e) {
        return this._boundingInfo = e, this;
      }, Object.defineProperty(t.prototype, "hasBoundingInfo", { get: function() {
        return this._boundingInfo !== null;
      }, enumerable: !1, configurable: !0 }), t.prototype.buildBoundingInfo = function(e, i, r) {
        return this._boundingInfo = new wr(e, i, r), this._boundingInfo;
      }, t.prototype.normalizeToUnitCube = function(e, i, r) {
        return e === void 0 && (e = !0), i === void 0 && (i = !1), n.prototype.normalizeToUnitCube.call(this, e, i, r);
      }, Object.defineProperty(t.prototype, "useBones", { get: function() {
        return this.skeleton && this.getScene().skeletonsEnabled && this.isVerticesDataPresent(P.MatricesIndicesKind) && this.isVerticesDataPresent(P.MatricesWeightsKind);
      }, enumerable: !1, configurable: !0 }), t.prototype._preActivate = function() {
      }, t.prototype._preActivateForIntermediateRendering = function(e) {
      }, t.prototype._activate = function(e, i) {
        return this._renderId = e, !0;
      }, t.prototype._postActivate = function() {
      }, t.prototype._freeze = function() {
      }, t.prototype._unFreeze = function() {
      }, t.prototype.getWorldMatrix = function() {
        return this._masterMesh && this.billboardMode === ai.BILLBOARDMODE_NONE ? this._masterMesh.getWorldMatrix() : n.prototype.getWorldMatrix.call(this);
      }, t.prototype._getWorldMatrixDeterminant = function() {
        return this._masterMesh ? this._masterMesh._getWorldMatrixDeterminant() : n.prototype._getWorldMatrixDeterminant.call(this);
      }, Object.defineProperty(t.prototype, "isAnInstance", { get: function() {
        return !1;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hasInstances", { get: function() {
        return !1;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hasThinInstances", { get: function() {
        return !1;
      }, enumerable: !1, configurable: !0 }), t.prototype.movePOV = function(e, i, r) {
        return this.position.addInPlace(this.calcMovePOV(e, i, r)), this;
      }, t.prototype.calcMovePOV = function(e, i, r) {
        var o = new B();
        (this.rotationQuaternion ? this.rotationQuaternion : oe.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z)).toRotationMatrix(o);
        var a = v.Zero(), s = this.definedFacingForward ? -1 : 1;
        return v.TransformCoordinatesFromFloatsToRef(e * s, i, r * s, o, a), a;
      }, t.prototype.rotatePOV = function(e, i, r) {
        return this.rotation.addInPlace(this.calcRotatePOV(e, i, r)), this;
      }, t.prototype.calcRotatePOV = function(e, i, r) {
        var o = this.definedFacingForward ? 1 : -1;
        return new v(e * o, i, r * o);
      }, t.prototype.refreshBoundingInfo = function(e, i) {
        return e === void 0 && (e = !1), i === void 0 && (i = !1), this._boundingInfo && this._boundingInfo.isLocked || this._refreshBoundingInfo(this._getPositionData(e, i), null), this;
      }, t.prototype._refreshBoundingInfo = function(e, i) {
        if (e) {
          var r = hl(e, 0, this.getTotalVertices(), i);
          this._boundingInfo ? this._boundingInfo.reConstruct(r.minimum, r.maximum) : this._boundingInfo = new wr(r.minimum, r.maximum);
        }
        if (this.subMeshes)
          for (var o = 0; o < this.subMeshes.length; o++)
            this.subMeshes[o].refreshBoundingInfo(e);
        this._updateBoundingInfo();
      }, t.prototype._getData = function(e, i, r, o) {
        if (e === void 0 && (e = !1), i === void 0 && (i = !1), o === void 0 && (o = P.PositionKind), (r = r ?? this.getVerticesData(o).slice()) && i && this.morphTargetManager)
          for (var a = 0, s = 0, l = 0; l < r.length; l++) {
            for (var c = 0; c < this.morphTargetManager.numTargets; c++) {
              var u = this.morphTargetManager.getTarget(c), h = u.influence;
              if (h > 0) {
                var d = u.getPositions();
                d && (r[l] += (d[l] - r[l]) * h);
              }
            }
            if (a++, o === P.PositionKind && this._positions && a === 3) {
              a = 0;
              var p = 3 * s;
              this._positions[s++].copyFromFloats(r[p], r[p + 1], r[p + 2]);
            }
          }
        if (r && e && this.skeleton) {
          var f = this.getVerticesData(P.MatricesIndicesKind), m = this.getVerticesData(P.MatricesWeightsKind);
          if (m && f) {
            var g = this.numBoneInfluencers > 4, y = g ? this.getVerticesData(P.MatricesIndicesExtraKind) : null, b = g ? this.getVerticesData(P.MatricesWeightsExtraKind) : null, T = this.skeleton.getTransformMatrices(this), S = F.Vector3[0], E = F.Matrix[0], A = F.Matrix[1], R = 0;
            for (p = 0; p < r.length; p += 3, R += 4) {
              E.reset();
              var C = void 0, L = void 0;
              for (C = 0; C < 4; C++)
                (L = m[R + C]) > 0 && (B.FromFloat32ArrayToRefScaled(T, Math.floor(16 * f[R + C]), L, A), E.addToSelf(A));
              if (g)
                for (C = 0; C < 4; C++)
                  (L = b[R + C]) > 0 && (B.FromFloat32ArrayToRefScaled(T, Math.floor(16 * y[R + C]), L, A), E.addToSelf(A));
              o === P.NormalKind ? v.TransformNormalFromFloatsToRef(r[p], r[p + 1], r[p + 2], E, S) : v.TransformCoordinatesFromFloatsToRef(r[p], r[p + 1], r[p + 2], E, S), S.toArray(r, p), o === P.PositionKind && this._positions && this._positions[p / 3].copyFrom(S);
            }
          }
        }
        return r;
      }, t.prototype.getNormalsData = function(e, i) {
        return e === void 0 && (e = !1), i === void 0 && (i = !1), this._getData(e, i, null, P.NormalKind);
      }, t.prototype.getPositionData = function(e, i, r) {
        return e === void 0 && (e = !1), i === void 0 && (i = !1), this._getData(e, i, r, P.PositionKind);
      }, t.prototype._getPositionData = function(e, i) {
        var r, o = this.getVerticesData(P.PositionKind);
        if (this._internalAbstractMeshDataInfo._positions && (this._internalAbstractMeshDataInfo._positions = null), o && (e && this.skeleton || i && this.morphTargetManager)) {
          if (o = o.slice(), this._generatePointsArray(), this._positions) {
            var a = this._positions;
            this._internalAbstractMeshDataInfo._positions = new Array(a.length);
            for (var s = 0; s < a.length; s++)
              this._internalAbstractMeshDataInfo._positions[s] = ((r = a[s]) === null || r === void 0 ? void 0 : r.clone()) || new v();
          }
          return this.getPositionData(e, i, o);
        }
        return o;
      }, t.prototype._updateBoundingInfo = function() {
        return this._boundingInfo ? this._boundingInfo.update(this.worldMatrixFromCache) : this._boundingInfo = new wr(v.Zero(), v.Zero(), this.worldMatrixFromCache), this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache), this;
      }, t.prototype._updateSubMeshesBoundingInfo = function(e) {
        if (!this.subMeshes)
          return this;
        for (var i = this.subMeshes.length, r = 0; r < i; r++) {
          var o = this.subMeshes[r];
          (i > 1 || !o.IsGlobal) && o.updateBoundingInfo(e);
        }
        return this;
      }, t.prototype._afterComputeWorldMatrix = function() {
        this.doNotSyncBoundingInfo || (this._boundingInfoIsDirty = !0);
      }, t.prototype.isInFrustum = function(e) {
        return this.getBoundingInfo().isInFrustum(e, this.cullingStrategy);
      }, t.prototype.isCompletelyInFrustum = function(e) {
        return this.getBoundingInfo().isCompletelyInFrustum(e);
      }, t.prototype.intersectsMesh = function(e, i, r) {
        i === void 0 && (i = !1);
        var o = this.getBoundingInfo(), a = e.getBoundingInfo();
        if (o.intersects(a, i))
          return !0;
        if (r) {
          for (var s = 0, l = this.getChildMeshes(); s < l.length; s++)
            if (l[s].intersectsMesh(e, i, !0))
              return !0;
        }
        return !1;
      }, t.prototype.intersectsPoint = function(e) {
        return this.getBoundingInfo().intersectsPoint(e);
      }, Object.defineProperty(t.prototype, "checkCollisions", { get: function() {
        return this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions;
      }, set: function(e) {
        this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "collider", { get: function() {
        return this._internalAbstractMeshDataInfo._meshCollisionData._collider;
      }, enumerable: !1, configurable: !0 }), t.prototype.moveWithCollisions = function(e) {
        this.getAbsolutePosition().addToRef(this.ellipsoidOffset, this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions);
        var i = this.getScene().collisionCoordinator;
        return this._internalAbstractMeshDataInfo._meshCollisionData._collider || (this._internalAbstractMeshDataInfo._meshCollisionData._collider = i.createCollider()), this._internalAbstractMeshDataInfo._meshCollisionData._collider._radius = this.ellipsoid, i.getNewPosition(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions, e, this._internalAbstractMeshDataInfo._meshCollisionData._collider, this.collisionRetryCount, this, this._onCollisionPositionChange, this.uniqueId), this;
      }, t.prototype._collideForSubMesh = function(e, i, r) {
        var o;
        if (this._generatePointsArray(), !this._positions)
          return this;
        if (!e._lastColliderWorldVertices || !e._lastColliderTransformMatrix.equals(i)) {
          e._lastColliderTransformMatrix = i.clone(), e._lastColliderWorldVertices = [], e._trianglePlanes = [];
          for (var a = e.verticesStart, s = e.verticesStart + e.verticesCount, l = a; l < s; l++)
            e._lastColliderWorldVertices.push(v.TransformCoordinates(this._positions[l], i));
        }
        return r._collide(e._trianglePlanes, e._lastColliderWorldVertices, this.getIndices(), e.indexStart, e.indexStart + e.indexCount, e.verticesStart, !!e.getMaterial(), this, this._shouldConvertRHS(), ((o = e.getMaterial()) === null || o === void 0 ? void 0 : o.fillMode) === _.MATERIAL_TriangleStripDrawMode), this;
      }, t.prototype._processCollisionsForSubMeshes = function(e, i) {
        for (var r = this._scene.getCollidingSubMeshCandidates(this, e), o = r.length, a = 0; a < o; a++) {
          var s = r.data[a];
          o > 1 && !s._checkCollision(e) || this._collideForSubMesh(s, i, e);
        }
        return this;
      }, t.prototype._shouldConvertRHS = function() {
        return !1;
      }, t.prototype._checkCollision = function(e) {
        if (!this.getBoundingInfo()._checkCollision(e))
          return this;
        var i = F.Matrix[0], r = F.Matrix[1];
        return B.ScalingToRef(1 / e._radius.x, 1 / e._radius.y, 1 / e._radius.z, i), this.worldMatrixFromCache.multiplyToRef(i, r), this._processCollisionsForSubMeshes(e, r), this;
      }, t.prototype._generatePointsArray = function() {
        return !1;
      }, t.prototype.intersects = function(e, i, r, o, a, s) {
        o === void 0 && (o = !1), s === void 0 && (s = !1);
        var l = new Ki(), c = this.getClassName(), u = c === "InstancedLinesMesh" || c === "LinesMesh" || c === "GreasedLineMesh" ? this.intersectionThreshold : 0, h = this.getBoundingInfo();
        if (!this.subMeshes || !(s || e.intersectsSphere(h.boundingSphere, u) && e.intersectsBox(h.boundingBox, u)))
          return l;
        if (o)
          return l.hit = !s, l.pickedMesh = s ? null : this, l.distance = s ? 0 : v.Distance(e.origin, h.boundingSphere.center), l.subMeshId = 0, l;
        if (!this._generatePointsArray())
          return l;
        for (var d = null, p = this._scene.getIntersectingSubMeshCandidates(this, e), f = p.length, m = !1, g = 0; g < f; g++) {
          var y = (b = p.data[g]).getMaterial();
          if (y && (y.fillMode == _.MATERIAL_TriangleStripDrawMode || y.fillMode == _.MATERIAL_TriangleFillMode || y.fillMode == _.MATERIAL_WireFrameFillMode || y.fillMode == _.MATERIAL_PointFillMode || y.fillMode == _.MATERIAL_LineListDrawMode)) {
            m = !0;
            break;
          }
        }
        if (!m)
          return l.hit = !0, l.pickedMesh = this, l.distance = v.Distance(e.origin, h.boundingSphere.center), l.subMeshId = -1, l;
        for (g = 0; g < f; g++) {
          var b = p.data[g];
          if (!(f > 1) || s || b.canIntersects(e)) {
            var T = b.intersects(e, this._positions, this.getIndices(), i, r);
            if (T && (i || !d || T.distance < d.distance) && ((d = T).subMeshId = g, i))
              break;
          }
        }
        if (d) {
          var S = a ?? this.getWorldMatrix(), E = F.Vector3[0], A = F.Vector3[1];
          v.TransformCoordinatesToRef(e.origin, S, E), e.direction.scaleToRef(d.distance, A);
          var R = v.TransformNormal(A, S).addInPlace(E);
          return l.hit = !0, l.distance = v.Distance(E, R), l.pickedPoint = R, l.pickedMesh = this, l.bu = d.bu || 0, l.bv = d.bv || 0, l.subMeshFaceId = d.faceId, l.faceId = d.faceId + p.data[d.subMeshId].indexStart / (this.getClassName().indexOf("LinesMesh") !== -1 ? 2 : 3), l.subMeshId = d.subMeshId, l;
        }
        return l;
      }, t.prototype.clone = function(e, i, r) {
        return null;
      }, t.prototype.releaseSubMeshes = function() {
        if (this.subMeshes)
          for (; this.subMeshes.length; )
            this.subMeshes[0].dispose();
        else
          this.subMeshes = [];
        return this;
      }, t.prototype.dispose = function(e, i) {
        var r, o = this;
        i === void 0 && (i = !1);
        var a = this.getScene();
        for (this._scene.useMaterialMeshMap && this._internalAbstractMeshDataInfo._material && this._internalAbstractMeshDataInfo._material.meshMap && (this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId] = void 0), a.freeActiveMeshes(), a.freeRenderingGroups(), a.renderingManager.maintainStateBetweenFrames && a.renderingManager.restoreDispachedFlags(), this.actionManager !== void 0 && this.actionManager !== null && (this._scene.meshes.some(function(h) {
          return h !== o && h.actionManager === o.actionManager;
        }) || this.actionManager.dispose(), this.actionManager = null), this._internalAbstractMeshDataInfo._skeleton = null, this._transformMatrixTexture && (this._transformMatrixTexture.dispose(), this._transformMatrixTexture = null), r = 0; r < this._intersectionsInProgress.length; r++) {
          var s = this._intersectionsInProgress[r], l = s._intersectionsInProgress.indexOf(this);
          s._intersectionsInProgress.splice(l, 1);
        }
        this._intersectionsInProgress.length = 0, a.lights.forEach(function(h) {
          var d = h.includedOnlyMeshes.indexOf(o);
          d !== -1 && h.includedOnlyMeshes.splice(d, 1), (d = h.excludedMeshes.indexOf(o)) !== -1 && h.excludedMeshes.splice(d, 1);
          var p = h.getShadowGenerators();
          if (p)
            for (var f = p.values(), m = f.next(); m.done !== !0; m = f.next()) {
              var g = m.value.getShadowMap();
              g && g.renderList && (d = g.renderList.indexOf(o)) !== -1 && g.renderList.splice(d, 1);
            }
        }), this.getClassName() === "InstancedMesh" && this.getClassName() === "InstancedLinesMesh" || this.releaseSubMeshes();
        var c = a.getEngine();
        if (this._occlusionQuery !== null && (this.isOcclusionQueryInProgress = !1, c.deleteQuery(this._occlusionQuery), this._occlusionQuery = null), c.wipeCaches(), a.removeMesh(this), this._parentContainer) {
          var u = this._parentContainer.meshes.indexOf(this);
          u > -1 && this._parentContainer.meshes.splice(u, 1), this._parentContainer = null;
        }
        if (i && this.material && (this.material.getClassName() === "MultiMaterial" ? this.material.dispose(!1, !0, !0) : this.material.dispose(!1, !0)), !e)
          for (r = 0; r < a.particleSystems.length; r++)
            a.particleSystems[r].emitter === this && (a.particleSystems[r].dispose(), r--);
        this._internalAbstractMeshDataInfo._facetData.facetDataEnabled && this.disableFacetData(), this._uniformBuffer.dispose(), this.onAfterWorldMatrixUpdateObservable.clear(), this.onCollideObservable.clear(), this.onCollisionPositionChangeObservable.clear(), this.onRebuildObservable.clear(), n.prototype.dispose.call(this, e, i);
      }, t.prototype.addChild = function(e, i) {
        return i === void 0 && (i = !1), e.setParent(this, i), this;
      }, t.prototype.removeChild = function(e, i) {
        return i === void 0 && (i = !1), e.setParent(null, i), this;
      }, t.prototype._initFacetData = function() {
        var e = this._internalAbstractMeshDataInfo._facetData;
        e.facetNormals || (e.facetNormals = []), e.facetPositions || (e.facetPositions = []), e.facetPartitioning || (e.facetPartitioning = new Array()), e.facetNb = this.getIndices().length / 3 | 0, e.partitioningSubdivisions = e.partitioningSubdivisions ? e.partitioningSubdivisions : 10, e.partitioningBBoxRatio = e.partitioningBBoxRatio ? e.partitioningBBoxRatio : 1.01;
        for (var i = 0; i < e.facetNb; i++)
          e.facetNormals[i] = v.Zero(), e.facetPositions[i] = v.Zero();
        return e.facetDataEnabled = !0, this;
      }, t.prototype.updateFacetData = function() {
        var e = this._internalAbstractMeshDataInfo._facetData;
        e.facetDataEnabled || this._initFacetData();
        var i = this.getVerticesData(P.PositionKind), r = this.getIndices(), o = this.getVerticesData(P.NormalKind), a = this.getBoundingInfo();
        if (e.facetDepthSort && !e.facetDepthSortEnabled) {
          if (e.facetDepthSortEnabled = !0, r instanceof Uint16Array)
            e.depthSortedIndices = new Uint16Array(r);
          else if (r instanceof Uint32Array)
            e.depthSortedIndices = new Uint32Array(r);
          else {
            for (var s = !1, l = 0; l < r.length; l++)
              if (r[l] > 65535) {
                s = !0;
                break;
              }
            e.depthSortedIndices = s ? new Uint32Array(r) : new Uint16Array(r);
          }
          if (e.facetDepthSortFunction = function(m, g) {
            return g.sqDistance - m.sqDistance;
          }, !e.facetDepthSortFrom) {
            var c = this.getScene().activeCamera;
            e.facetDepthSortFrom = c ? c.position : v.Zero();
          }
          e.depthSortedFacets = [];
          for (var u = 0; u < e.facetNb; u++) {
            var h = { ind: 3 * u, sqDistance: 0 };
            e.depthSortedFacets.push(h);
          }
          e.invertedMatrix = B.Identity(), e.facetDepthSortOrigin = v.Zero();
        }
        e.bbSize.x = a.maximum.x - a.minimum.x > Ge ? a.maximum.x - a.minimum.x : Ge, e.bbSize.y = a.maximum.y - a.minimum.y > Ge ? a.maximum.y - a.minimum.y : Ge, e.bbSize.z = a.maximum.z - a.minimum.z > Ge ? a.maximum.z - a.minimum.z : Ge;
        var d = e.bbSize.x > e.bbSize.y ? e.bbSize.x : e.bbSize.y;
        if (d = d > e.bbSize.z ? d : e.bbSize.z, e.subDiv.max = e.partitioningSubdivisions, e.subDiv.X = Math.floor(e.subDiv.max * e.bbSize.x / d), e.subDiv.Y = Math.floor(e.subDiv.max * e.bbSize.y / d), e.subDiv.Z = Math.floor(e.subDiv.max * e.bbSize.z / d), e.subDiv.X = e.subDiv.X < 1 ? 1 : e.subDiv.X, e.subDiv.Y = e.subDiv.Y < 1 ? 1 : e.subDiv.Y, e.subDiv.Z = e.subDiv.Z < 1 ? 1 : e.subDiv.Z, e.facetParameters.facetNormals = this.getFacetLocalNormals(), e.facetParameters.facetPositions = this.getFacetLocalPositions(), e.facetParameters.facetPartitioning = this.getFacetLocalPartitioning(), e.facetParameters.bInfo = a, e.facetParameters.bbSize = e.bbSize, e.facetParameters.subDiv = e.subDiv, e.facetParameters.ratio = this.partitioningBBoxRatio, e.facetParameters.depthSort = e.facetDepthSort, e.facetDepthSort && e.facetDepthSortEnabled && (this.computeWorldMatrix(!0), this._worldMatrix.invertToRef(e.invertedMatrix), v.TransformCoordinatesToRef(e.facetDepthSortFrom, e.invertedMatrix, e.facetDepthSortOrigin), e.facetParameters.distanceTo = e.facetDepthSortOrigin), e.facetParameters.depthSortedFacets = e.depthSortedFacets, o && Oe.ComputeNormals(i, r, o, e.facetParameters), e.facetDepthSort && e.facetDepthSortEnabled) {
          e.depthSortedFacets.sort(e.facetDepthSortFunction);
          var p = e.depthSortedIndices.length / 3 | 0;
          for (u = 0; u < p; u++) {
            var f = e.depthSortedFacets[u].ind;
            e.depthSortedIndices[3 * u] = r[f], e.depthSortedIndices[3 * u + 1] = r[f + 1], e.depthSortedIndices[3 * u + 2] = r[f + 2];
          }
          this.updateIndices(e.depthSortedIndices, void 0, !0);
        }
        return this;
      }, t.prototype.getFacetLocalNormals = function() {
        var e = this._internalAbstractMeshDataInfo._facetData;
        return e.facetNormals || this.updateFacetData(), e.facetNormals;
      }, t.prototype.getFacetLocalPositions = function() {
        var e = this._internalAbstractMeshDataInfo._facetData;
        return e.facetPositions || this.updateFacetData(), e.facetPositions;
      }, t.prototype.getFacetLocalPartitioning = function() {
        var e = this._internalAbstractMeshDataInfo._facetData;
        return e.facetPartitioning || this.updateFacetData(), e.facetPartitioning;
      }, t.prototype.getFacetPosition = function(e) {
        var i = v.Zero();
        return this.getFacetPositionToRef(e, i), i;
      }, t.prototype.getFacetPositionToRef = function(e, i) {
        var r = this.getFacetLocalPositions()[e], o = this.getWorldMatrix();
        return v.TransformCoordinatesToRef(r, o, i), this;
      }, t.prototype.getFacetNormal = function(e) {
        var i = v.Zero();
        return this.getFacetNormalToRef(e, i), i;
      }, t.prototype.getFacetNormalToRef = function(e, i) {
        var r = this.getFacetLocalNormals()[e];
        return v.TransformNormalToRef(r, this.getWorldMatrix(), i), this;
      }, t.prototype.getFacetsAtLocalCoordinates = function(e, i, r) {
        var o = this.getBoundingInfo(), a = this._internalAbstractMeshDataInfo._facetData, s = Math.floor((e - o.minimum.x * a.partitioningBBoxRatio) * a.subDiv.X * a.partitioningBBoxRatio / a.bbSize.x), l = Math.floor((i - o.minimum.y * a.partitioningBBoxRatio) * a.subDiv.Y * a.partitioningBBoxRatio / a.bbSize.y), c = Math.floor((r - o.minimum.z * a.partitioningBBoxRatio) * a.subDiv.Z * a.partitioningBBoxRatio / a.bbSize.z);
        return s < 0 || s > a.subDiv.max || l < 0 || l > a.subDiv.max || c < 0 || c > a.subDiv.max ? null : a.facetPartitioning[s + a.subDiv.max * l + a.subDiv.max * a.subDiv.max * c];
      }, t.prototype.getClosestFacetAtCoordinates = function(e, i, r, o, a, s) {
        a === void 0 && (a = !1), s === void 0 && (s = !0);
        var l = this.getWorldMatrix(), c = F.Matrix[5];
        l.invertToRef(c);
        var u = F.Vector3[8];
        v.TransformCoordinatesFromFloatsToRef(e, i, r, c, u);
        var h = this.getClosestFacetAtLocalCoordinates(u.x, u.y, u.z, o, a, s);
        return o && v.TransformCoordinatesFromFloatsToRef(o.x, o.y, o.z, l, o), h;
      }, t.prototype.getClosestFacetAtLocalCoordinates = function(e, i, r, o, a, s) {
        a === void 0 && (a = !1), s === void 0 && (s = !0);
        var l = null, c = 0, u = 0, h = 0, d = 0, p = 0, f = 0, m = 0, g = 0, y = this.getFacetLocalPositions(), b = this.getFacetLocalNormals(), T = this.getFacetsAtLocalCoordinates(e, i, r);
        if (!T)
          return null;
        for (var S, E, A, R = Number.MAX_VALUE, C = R, L = 0; L < T.length; L++)
          E = b[S = T[L]], d = (e - (A = y[S]).x) * E.x + (i - A.y) * E.y + (r - A.z) * E.z, (!a || a && s && d >= 0 || a && !s && d <= 0) && (d = E.x * A.x + E.y * A.y + E.z * A.z, p = -(E.x * e + E.y * i + E.z * r - d) / (E.x * E.x + E.y * E.y + E.z * E.z), (C = (c = (f = e + E.x * p) - e) * c + (u = (m = i + E.y * p) - i) * u + (h = (g = r + E.z * p) - r) * h) < R && (R = C, l = S, o && (o.x = f, o.y = m, o.z = g)));
        return l;
      }, t.prototype.getFacetDataParameters = function() {
        return this._internalAbstractMeshDataInfo._facetData.facetParameters;
      }, t.prototype.disableFacetData = function() {
        var e = this._internalAbstractMeshDataInfo._facetData;
        return e.facetDataEnabled && (e.facetDataEnabled = !1, e.facetPositions = [], e.facetNormals = [], e.facetPartitioning = new Array(), e.facetParameters = null, e.depthSortedIndices = new Uint32Array(0)), this;
      }, t.prototype.updateIndices = function(e, i, r) {
        return this;
      }, t.prototype.createNormals = function(e) {
        var i, r = this.getVerticesData(P.PositionKind), o = this.getIndices();
        return i = this.isVerticesDataPresent(P.NormalKind) ? this.getVerticesData(P.NormalKind) : [], Oe.ComputeNormals(r, o, i, { useRightHandedSystem: this.getScene().useRightHandedSystem }), this.setVerticesData(P.NormalKind, i, e), this;
      }, t.prototype.alignWithNormal = function(e, i) {
        i || (i = qi.Y);
        var r = F.Vector3[0], o = F.Vector3[1];
        return v.CrossToRef(i, e, o), v.CrossToRef(e, o, r), this.rotationQuaternion ? oe.RotationQuaternionFromAxisToRef(r, e, o, this.rotationQuaternion) : v.RotationFromAxisToRef(r, e, o, this.rotation), this;
      }, t.prototype._checkOcclusionQuery = function() {
        return !1;
      }, t.prototype.disableEdgesRendering = function() {
        throw et("EdgesRenderer");
      }, t.prototype.enableEdgesRendering = function(e, i, r) {
        throw et("EdgesRenderer");
      }, t.prototype.getConnectedParticleSystems = function() {
        var e = this;
        return this._scene.particleSystems.filter(function(i) {
          return i.emitter === e;
        });
      }, t.OCCLUSION_TYPE_NONE = 0, t.OCCLUSION_TYPE_OPTIMISTIC = 1, t.OCCLUSION_TYPE_STRICT = 2, t.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0, t.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1, t.CULLINGSTRATEGY_STANDARD = _.MESHES_CULLINGSTRATEGY_STANDARD, t.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = _.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY, t.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = _.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION, t.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = _.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY, t;
    }(ai);
    function Br(n) {
      n.indexOf("vClipPlane") === -1 && n.push("vClipPlane"), n.indexOf("vClipPlane2") === -1 && n.push("vClipPlane2"), n.indexOf("vClipPlane3") === -1 && n.push("vClipPlane3"), n.indexOf("vClipPlane4") === -1 && n.push("vClipPlane4"), n.indexOf("vClipPlane5") === -1 && n.push("vClipPlane5"), n.indexOf("vClipPlane6") === -1 && n.push("vClipPlane6");
    }
    function aa(n, t, e) {
      var i, r, o, a, s, l, c = !!((i = n.clipPlane) !== null && i !== void 0 ? i : t.clipPlane), u = !!((r = n.clipPlane2) !== null && r !== void 0 ? r : t.clipPlane2), h = !!((o = n.clipPlane3) !== null && o !== void 0 ? o : t.clipPlane3), d = !!((a = n.clipPlane4) !== null && a !== void 0 ? a : t.clipPlane4), p = !!((s = n.clipPlane5) !== null && s !== void 0 ? s : t.clipPlane5), f = !!((l = n.clipPlane6) !== null && l !== void 0 ? l : t.clipPlane6);
      c && e.push("#define CLIPPLANE"), u && e.push("#define CLIPPLANE2"), h && e.push("#define CLIPPLANE3"), d && e.push("#define CLIPPLANE4"), p && e.push("#define CLIPPLANE5"), f && e.push("#define CLIPPLANE6");
    }
    function Eg(n, t, e) {
      var i, r, o, a, s, l, c = !1, u = !!((i = n.clipPlane) !== null && i !== void 0 ? i : t.clipPlane), h = !!((r = n.clipPlane2) !== null && r !== void 0 ? r : t.clipPlane2), d = !!((o = n.clipPlane3) !== null && o !== void 0 ? o : t.clipPlane3), p = !!((a = n.clipPlane4) !== null && a !== void 0 ? a : t.clipPlane4), f = !!((s = n.clipPlane5) !== null && s !== void 0 ? s : t.clipPlane5), m = !!((l = n.clipPlane6) !== null && l !== void 0 ? l : t.clipPlane6);
      return e.CLIPPLANE !== u && (e.CLIPPLANE = u, c = !0), e.CLIPPLANE2 !== h && (e.CLIPPLANE2 = h, c = !0), e.CLIPPLANE3 !== d && (e.CLIPPLANE3 = d, c = !0), e.CLIPPLANE4 !== p && (e.CLIPPLANE4 = p, c = !0), e.CLIPPLANE5 !== f && (e.CLIPPLANE5 = f, c = !0), e.CLIPPLANE6 !== m && (e.CLIPPLANE6 = m, c = !0), c;
    }
    function Ar(n, t, e) {
      var i, r, o, a, s, l, c = (i = t.clipPlane) !== null && i !== void 0 ? i : e.clipPlane;
      cc(n, "vClipPlane", c), cc(n, "vClipPlane2", c = (r = t.clipPlane2) !== null && r !== void 0 ? r : e.clipPlane2), cc(n, "vClipPlane3", c = (o = t.clipPlane3) !== null && o !== void 0 ? o : e.clipPlane3), cc(n, "vClipPlane4", c = (a = t.clipPlane4) !== null && a !== void 0 ? a : e.clipPlane4), cc(n, "vClipPlane5", c = (s = t.clipPlane5) !== null && s !== void 0 ? s : e.clipPlane5), cc(n, "vClipPlane6", c = (l = t.clipPlane6) !== null && l !== void 0 ? l : e.clipPlane6);
    }
    function cc(n, t, e) {
      e && n.setFloat4(t, e.normal.x, e.normal.y, e.normal.z, e.d);
    }
    j("BABYLON.AbstractMesh", Dt);
    var rn, Se = function() {
      function n() {
      }
      return n.BindSceneUniformBuffer = function(t, e) {
        e.bindToEffect(t, "Scene");
      }, n.PrepareDefinesForMergedUV = function(t, e, i) {
        e._needUVs = !0, e[i] = !0, t.optimizeUVAllocation && t.getTextureMatrix().isIdentityAs3x2() ? (e[i + "DIRECTUV"] = t.coordinatesIndex + 1, e["MAINUV" + (t.coordinatesIndex + 1)] = !0) : e[i + "DIRECTUV"] = 0;
      }, n.BindTextureMatrix = function(t, e, i) {
        var r = t.getTextureMatrix();
        e.updateMatrix(i + "Matrix", r);
      }, n.GetFogState = function(t, e) {
        return e.fogEnabled && t.applyFog && e.fogMode !== Ue.FOGMODE_NONE;
      }, n.PrepareDefinesForMisc = function(t, e, i, r, o, a, s, l) {
        l === void 0 && (l = !1), s._areMiscDirty && (s.LOGARITHMICDEPTH = i, s.POINTSIZE = r, s.FOG = o && this.GetFogState(t, e), s.NONUNIFORMSCALING = t.nonUniformScaling, s.ALPHATEST = a, s.DECAL_AFTER_DETAIL = l);
      }, n.PrepareDefinesForCamera = function(t, e) {
        var i = !1;
        if (t.activeCamera) {
          var r = e.CAMERA_ORTHOGRAPHIC ? 1 : 0, o = e.CAMERA_PERSPECTIVE ? 1 : 0, a = t.activeCamera.mode === dt.ORTHOGRAPHIC_CAMERA ? 1 : 0, s = t.activeCamera.mode === dt.PERSPECTIVE_CAMERA ? 1 : 0;
          (r ^ a || o ^ s) && (e.CAMERA_ORTHOGRAPHIC = a === 1, e.CAMERA_PERSPECTIVE = s === 1, i = !0);
        }
        return i;
      }, n.PrepareDefinesForFrameBoundValues = function(t, e, i, r, o, a, s) {
        a === void 0 && (a = null), s === void 0 && (s = !1);
        var l = n.PrepareDefinesForCamera(t, r);
        a !== !1 && (l = Eg(i, t, r)), r.DEPTHPREPASS !== !e.getColorWrite() && (r.DEPTHPREPASS = !r.DEPTHPREPASS, l = !0), r.INSTANCES !== o && (r.INSTANCES = o, l = !0), r.THIN_INSTANCES !== s && (r.THIN_INSTANCES = s, l = !0), l && r.markAsUnprocessed();
      }, n.PrepareDefinesForBones = function(t, e) {
        if (t.useBones && t.computeBonesUsingShaders && t.skeleton) {
          e.NUM_BONE_INFLUENCERS = t.numBoneInfluencers;
          var i = e.BONETEXTURE !== void 0;
          if (t.skeleton.isUsingTextureForMatrices && i)
            e.BONETEXTURE = !0;
          else {
            e.BonesPerMesh = t.skeleton.bones.length + 1, e.BONETEXTURE = !i && void 0;
            var r = t.getScene().prePassRenderer;
            if (r && r.enabled) {
              var o = r.excludedSkinnedMesh.indexOf(t) === -1;
              e.BONES_VELOCITY_ENABLED = o;
            }
          }
        } else
          e.NUM_BONE_INFLUENCERS = 0, e.BonesPerMesh = 0, e.BONETEXTURE !== void 0 && (e.BONETEXTURE = !1);
      }, n.PrepareDefinesForMorphTargets = function(t, e) {
        var i = t.morphTargetManager;
        i ? (e.MORPHTARGETS_UV = i.supportsUVs && e.UV1, e.MORPHTARGETS_TANGENT = i.supportsTangents && e.TANGENT, e.MORPHTARGETS_NORMAL = i.supportsNormals && e.NORMAL, e.MORPHTARGETS = i.numInfluencers > 0, e.NUM_MORPH_INFLUENCERS = i.numInfluencers, e.MORPHTARGETS_TEXTURE = i.isUsingTextureForTargets) : (e.MORPHTARGETS_UV = !1, e.MORPHTARGETS_TANGENT = !1, e.MORPHTARGETS_NORMAL = !1, e.MORPHTARGETS = !1, e.NUM_MORPH_INFLUENCERS = 0);
      }, n.PrepareDefinesForBakedVertexAnimation = function(t, e) {
        var i = t.bakedVertexAnimationManager;
        e.BAKED_VERTEX_ANIMATION_TEXTURE = !(!i || !i.isEnabled);
      }, n.PrepareDefinesForAttributes = function(t, e, i, r, o, a, s) {
        if (o === void 0 && (o = !1), a === void 0 && (a = !0), s === void 0 && (s = !0), !e._areAttributesDirty && e._needNormals === e._normals && e._needUVs === e._uvs)
          return !1;
        e._normals = e._needNormals, e._uvs = e._needUVs, e.NORMAL = e._needNormals && t.isVerticesDataPresent(P.NormalKind), e._needNormals && t.isVerticesDataPresent(P.TangentKind) && (e.TANGENT = !0);
        for (var l = 1; l <= _.MAX_SUPPORTED_UV_SETS; ++l)
          e["UV" + l] = !!e._needUVs && t.isVerticesDataPresent("uv".concat(l === 1 ? "" : l));
        if (i) {
          var c = t.useVertexColors && t.isVerticesDataPresent(P.ColorKind);
          e.VERTEXCOLOR = c, e.VERTEXALPHA = t.hasVertexAlpha && c && a;
        }
        return t.isVerticesDataPresent(P.ColorInstanceKind) && (t.hasInstances || t.hasThinInstances) && (e.INSTANCESCOLOR = !0), r && this.PrepareDefinesForBones(t, e), o && this.PrepareDefinesForMorphTargets(t, e), s && this.PrepareDefinesForBakedVertexAnimation(t, e), !0;
      }, n.PrepareDefinesForMultiview = function(t, e) {
        if (t.activeCamera) {
          var i = e.MULTIVIEW;
          e.MULTIVIEW = t.activeCamera.outputRenderTarget !== null && t.activeCamera.outputRenderTarget.getViewCount() > 1, e.MULTIVIEW != i && e.markAsUnprocessed();
        }
      }, n.PrepareDefinesForOIT = function(t, e, i) {
        var r = e.ORDER_INDEPENDENT_TRANSPARENCY, o = e.ORDER_INDEPENDENT_TRANSPARENCY_16BITS;
        e.ORDER_INDEPENDENT_TRANSPARENCY = t.useOrderIndependentTransparency && i, e.ORDER_INDEPENDENT_TRANSPARENCY_16BITS = !t.getEngine().getCaps().textureFloatLinearFiltering, r === e.ORDER_INDEPENDENT_TRANSPARENCY && o === e.ORDER_INDEPENDENT_TRANSPARENCY_16BITS || e.markAsUnprocessed();
      }, n.PrepareDefinesForPrePass = function(t, e, i) {
        var r = e.PREPASS;
        if (e._arePrePassDirty) {
          var o = [{ type: _.PREPASS_POSITION_TEXTURE_TYPE, define: "PREPASS_POSITION", index: "PREPASS_POSITION_INDEX" }, { type: _.PREPASS_VELOCITY_TEXTURE_TYPE, define: "PREPASS_VELOCITY", index: "PREPASS_VELOCITY_INDEX" }, { type: _.PREPASS_REFLECTIVITY_TEXTURE_TYPE, define: "PREPASS_REFLECTIVITY", index: "PREPASS_REFLECTIVITY_INDEX" }, { type: _.PREPASS_IRRADIANCE_TEXTURE_TYPE, define: "PREPASS_IRRADIANCE", index: "PREPASS_IRRADIANCE_INDEX" }, { type: _.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE, define: "PREPASS_ALBEDO_SQRT", index: "PREPASS_ALBEDO_SQRT_INDEX" }, { type: _.PREPASS_DEPTH_TEXTURE_TYPE, define: "PREPASS_DEPTH", index: "PREPASS_DEPTH_INDEX" }, { type: _.PREPASS_NORMAL_TEXTURE_TYPE, define: "PREPASS_NORMAL", index: "PREPASS_NORMAL_INDEX" }];
          if (t.prePassRenderer && t.prePassRenderer.enabled && i) {
            e.PREPASS = !0, e.SCENE_MRT_COUNT = t.prePassRenderer.mrtCount, e.PREPASS_NORMAL_WORLDSPACE = t.prePassRenderer.generateNormalsInWorldSpace;
            for (var a = 0; a < o.length; a++) {
              var s = t.prePassRenderer.getIndex(o[a].type);
              s !== -1 ? (e[o[a].define] = !0, e[o[a].index] = s) : e[o[a].define] = !1;
            }
          } else
            for (e.PREPASS = !1, a = 0; a < o.length; a++)
              e[o[a].define] = !1;
          e.PREPASS != r && (e.markAsUnprocessed(), e.markAsImageProcessingDirty());
        }
      }, n.PrepareDefinesForLight = function(t, e, i, r, o, a, s) {
        var l;
        switch (s.needNormals = !0, o["LIGHT" + r] === void 0 && (s.needRebuild = !0), o["LIGHT" + r] = !0, o["SPOTLIGHT" + r] = !1, o["HEMILIGHT" + r] = !1, o["POINTLIGHT" + r] = !1, o["DIRLIGHT" + r] = !1, i.prepareLightSpecificDefines(o, r), o["LIGHT_FALLOFF_PHYSICAL" + r] = !1, o["LIGHT_FALLOFF_GLTF" + r] = !1, o["LIGHT_FALLOFF_STANDARD" + r] = !1, i.falloffType) {
          case nn.FALLOFF_GLTF:
            o["LIGHT_FALLOFF_GLTF" + r] = !0;
            break;
          case nn.FALLOFF_PHYSICAL:
            o["LIGHT_FALLOFF_PHYSICAL" + r] = !0;
            break;
          case nn.FALLOFF_STANDARD:
            o["LIGHT_FALLOFF_STANDARD" + r] = !0;
        }
        if (a && !i.specular.equalsFloats(0, 0, 0) && (s.specularEnabled = !0), o["SHADOW" + r] = !1, o["SHADOWCSM" + r] = !1, o["SHADOWCSMDEBUG" + r] = !1, o["SHADOWCSMNUM_CASCADES" + r] = !1, o["SHADOWCSMUSESHADOWMAXZ" + r] = !1, o["SHADOWCSMNOBLEND" + r] = !1, o["SHADOWCSM_RIGHTHANDED" + r] = !1, o["SHADOWPCF" + r] = !1, o["SHADOWPCSS" + r] = !1, o["SHADOWPOISSON" + r] = !1, o["SHADOWESM" + r] = !1, o["SHADOWCLOSEESM" + r] = !1, o["SHADOWCUBE" + r] = !1, o["SHADOWLOWQUALITY" + r] = !1, o["SHADOWMEDIUMQUALITY" + r] = !1, e && e.receiveShadows && t.shadowsEnabled && i.shadowEnabled) {
          var c = (l = i.getShadowGenerator(t.activeCamera)) !== null && l !== void 0 ? l : i.getShadowGenerator();
          if (c) {
            var u = c.getShadowMap();
            u && u.renderList && u.renderList.length > 0 && (s.shadowEnabled = !0, c.prepareDefines(o, r));
          }
        }
        i.lightmapMode != nn.LIGHTMAP_DEFAULT ? (s.lightmapMode = !0, o["LIGHTMAPEXCLUDED" + r] = !0, o["LIGHTMAPNOSPECULAR" + r] = i.lightmapMode == nn.LIGHTMAP_SHADOWSONLY) : (o["LIGHTMAPEXCLUDED" + r] = !1, o["LIGHTMAPNOSPECULAR" + r] = !1);
      }, n.PrepareDefinesForLights = function(t, e, i, r, o, a) {
        if (o === void 0 && (o = 4), a === void 0 && (a = !1), !i._areLightsDirty)
          return i._needNormals;
        var s = 0, l = { needNormals: i._needNormals, needRebuild: !1, lightmapMode: !1, shadowEnabled: !1, specularEnabled: !1 };
        if (t.lightsEnabled && !a)
          for (var c = 0, u = e.lightSources; c < u.length; c++) {
            var h = u[c];
            if (this.PrepareDefinesForLight(t, e, h, s, i, r, l), ++s === o)
              break;
          }
        i.SPECULARTERM = l.specularEnabled, i.SHADOWS = l.shadowEnabled;
        for (var d = s; d < o; d++)
          i["LIGHT" + d] !== void 0 && (i["LIGHT" + d] = !1, i["HEMILIGHT" + d] = !1, i["POINTLIGHT" + d] = !1, i["DIRLIGHT" + d] = !1, i["SPOTLIGHT" + d] = !1, i["SHADOW" + d] = !1, i["SHADOWCSM" + d] = !1, i["SHADOWCSMDEBUG" + d] = !1, i["SHADOWCSMNUM_CASCADES" + d] = !1, i["SHADOWCSMUSESHADOWMAXZ" + d] = !1, i["SHADOWCSMNOBLEND" + d] = !1, i["SHADOWCSM_RIGHTHANDED" + d] = !1, i["SHADOWPCF" + d] = !1, i["SHADOWPCSS" + d] = !1, i["SHADOWPOISSON" + d] = !1, i["SHADOWESM" + d] = !1, i["SHADOWCLOSEESM" + d] = !1, i["SHADOWCUBE" + d] = !1, i["SHADOWLOWQUALITY" + d] = !1, i["SHADOWMEDIUMQUALITY" + d] = !1);
        var p = t.getEngine().getCaps();
        return i.SHADOWFLOAT === void 0 && (l.needRebuild = !0), i.SHADOWFLOAT = l.shadowEnabled && (p.textureFloatRender && p.textureFloatLinearFiltering || p.textureHalfFloatRender && p.textureHalfFloatLinearFiltering), i.LIGHTMAPEXCLUDED = l.lightmapMode, l.needRebuild && i.rebuild(), l.needNormals;
      }, n.PrepareUniformsAndSamplersForLight = function(t, e, i, r, o, a) {
        o === void 0 && (o = null), a === void 0 && (a = !1), o && o.push("Light" + t), a || (e.push("vLightData" + t, "vLightDiffuse" + t, "vLightSpecular" + t, "vLightDirection" + t, "vLightFalloff" + t, "vLightGround" + t, "lightMatrix" + t, "shadowsInfo" + t, "depthValues" + t), i.push("shadowSampler" + t), i.push("depthSampler" + t), e.push("viewFrustumZ" + t, "cascadeBlendFactor" + t, "lightSizeUVCorrection" + t, "depthCorrection" + t, "penumbraDarkness" + t, "frustumLengths" + t), r && (i.push("projectionLightSampler" + t), e.push("textureProjectionMatrix" + t)));
      }, n.PrepareUniformsAndSamplersList = function(t, e, i, r) {
        var o;
        r === void 0 && (r = 4);
        var a = null;
        if (t.uniformsNames) {
          var s = t;
          o = s.uniformsNames, a = s.uniformBuffersNames, e = s.samplers, i = s.defines, r = s.maxSimultaneousLights || 0;
        } else
          o = t, e || (e = []);
        for (var l = 0; l < r && i["LIGHT" + l]; l++)
          this.PrepareUniformsAndSamplersForLight(l, o, e, i["PROJECTEDLIGHTTEXTURE" + l], a);
        i.NUM_MORPH_INFLUENCERS && o.push("morphTargetInfluences"), i.BAKED_VERTEX_ANIMATION_TEXTURE && (o.push("bakedVertexAnimationSettings"), o.push("bakedVertexAnimationTextureSizeInverted"), o.push("bakedVertexAnimationTime"), e.push("bakedVertexAnimationTexture"));
      }, n.HandleFallbacksForShadows = function(t, e, i, r) {
        i === void 0 && (i = 4), r === void 0 && (r = 0);
        for (var o = 0, a = 0; a < i && t["LIGHT" + a]; a++)
          a > 0 && (o = r + a, e.addFallback(o, "LIGHT" + a)), t.SHADOWS || (t["SHADOW" + a] && e.addFallback(r, "SHADOW" + a), t["SHADOWPCF" + a] && e.addFallback(r, "SHADOWPCF" + a), t["SHADOWPCSS" + a] && e.addFallback(r, "SHADOWPCSS" + a), t["SHADOWPOISSON" + a] && e.addFallback(r, "SHADOWPOISSON" + a), t["SHADOWESM" + a] && e.addFallback(r, "SHADOWESM" + a), t["SHADOWCLOSEESM" + a] && e.addFallback(r, "SHADOWCLOSEESM" + a));
        return o++;
      }, n.PrepareAttributesForMorphTargetsInfluencers = function(t, e, i) {
        this._TmpMorphInfluencers.NUM_MORPH_INFLUENCERS = i, this.PrepareAttributesForMorphTargets(t, e, this._TmpMorphInfluencers);
      }, n.PrepareAttributesForMorphTargets = function(t, e, i) {
        var r = i.NUM_MORPH_INFLUENCERS;
        if (r > 0 && Me.LastCreatedEngine) {
          var o = Me.LastCreatedEngine.getCaps().maxVertexAttribs, a = e.morphTargetManager;
          if (a != null && a.isUsingTextureForTargets)
            return;
          for (var s = a && a.supportsNormals && i.NORMAL, l = a && a.supportsTangents && i.TANGENT, c = a && a.supportsUVs && i.UV1, u = 0; u < r; u++)
            t.push(P.PositionKind + u), s && t.push(P.NormalKind + u), l && t.push(P.TangentKind + u), c && t.push(P.UVKind + "_" + u), t.length > o && q.Error("Cannot add more vertex attributes for mesh " + e.name);
        }
      }, n.PrepareAttributesForBakedVertexAnimation = function(t, e, i) {
        i.BAKED_VERTEX_ANIMATION_TEXTURE && i.INSTANCES && t.push("bakedVertexAnimationSettingsInstanced");
      }, n.PrepareAttributesForBones = function(t, e, i, r) {
        i.NUM_BONE_INFLUENCERS > 0 && (r.addCPUSkinningFallback(0, e), t.push(P.MatricesIndicesKind), t.push(P.MatricesWeightsKind), i.NUM_BONE_INFLUENCERS > 4 && (t.push(P.MatricesIndicesExtraKind), t.push(P.MatricesWeightsExtraKind)));
      }, n.PrepareAttributesForInstances = function(t, e) {
        (e.INSTANCES || e.THIN_INSTANCES) && this.PushAttributesForInstances(t, !!e.PREPASS_VELOCITY), e.INSTANCESCOLOR && t.push(P.ColorInstanceKind);
      }, n.PushAttributesForInstances = function(t, e) {
        e === void 0 && (e = !1), t.push("world0"), t.push("world1"), t.push("world2"), t.push("world3"), e && (t.push("previousWorld0"), t.push("previousWorld1"), t.push("previousWorld2"), t.push("previousWorld3"));
      }, n.BindLightProperties = function(t, e, i) {
        t.transferToEffect(e, i + "");
      }, n.BindLight = function(t, e, i, r, o, a) {
        a === void 0 && (a = !0), t._bindLight(e, i, r, o, a);
      }, n.BindLights = function(t, e, i, r, o) {
        o === void 0 && (o = 4);
        for (var a = Math.min(e.lightSources.length, o), s = 0; s < a; s++) {
          var l = e.lightSources[s];
          this.BindLight(l, s, t, i, typeof r == "boolean" ? r : r.SPECULARTERM, e.receiveShadows);
        }
      }, n.BindFogParameters = function(t, e, i, r) {
        r === void 0 && (r = !1), t.fogEnabled && e.applyFog && t.fogMode !== Ue.FOGMODE_NONE && (i.setFloat4("vFogInfos", t.fogMode, t.fogStart, t.fogEnd, t.fogDensity), r ? (t.fogColor.toLinearSpaceToRef(this._TempFogColor, t.getEngine().useExactSrgbConversions), i.setColor3("vFogColor", this._TempFogColor)) : i.setColor3("vFogColor", t.fogColor));
      }, n.BindBonesParameters = function(t, e, i) {
        if (e && t && (t.computeBonesUsingShaders && e._bonesComputationForcedToCPU && (t.computeBonesUsingShaders = !1), t.useBones && t.computeBonesUsingShaders && t.skeleton)) {
          var r = t.skeleton;
          if (r.isUsingTextureForMatrices && e.getUniformIndex("boneTextureWidth") > -1) {
            var o = r.getTransformMatrixTexture(t);
            e.setTexture("boneSampler", o), e.setFloat("boneTextureWidth", 4 * (r.bones.length + 1));
          } else {
            var a = r.getTransformMatrices(t);
            a && (e.setMatrices("mBones", a), i && t.getScene().prePassRenderer && t.getScene().prePassRenderer.getIndex(_.PREPASS_VELOCITY_TEXTURE_TYPE) && (i.previousBones[t.uniqueId] || (i.previousBones[t.uniqueId] = a.slice()), e.setMatrices("mPreviousBones", i.previousBones[t.uniqueId]), n._CopyBonesTransformationMatrices(a, i.previousBones[t.uniqueId])));
          }
        }
      }, n._CopyBonesTransformationMatrices = function(t, e) {
        return e.set(t), e;
      }, n.BindMorphTargetParameters = function(t, e) {
        var i = t.morphTargetManager;
        t && i && e.setFloatArray("morphTargetInfluences", i.influences);
      }, n.BindLogDepth = function(t, e, i) {
        if (!t || t.LOGARITHMICDEPTH || t.indexOf && t.indexOf("LOGARITHMICDEPTH") >= 0) {
          var r = i.activeCamera;
          r.mode === dt.ORTHOGRAPHIC_CAMERA && q.Error("Logarithmic depth is not compatible with orthographic cameras!", 20), e.setFloat("logarithmicDepthConstant", 2 / (Math.log(r.maxZ + 1) / Math.LN2));
        }
      }, n._TmpMorphInfluencers = { NUM_MORPH_INFLUENCERS: 0 }, n._TempFogColor = ne.Black(), n;
    }(), F1 = function() {
      function n() {
        this.reset();
      }
      return n.prototype.reset = function() {
        this.enabled = !1, this.mask = 255, this.func = _.ALWAYS, this.funcRef = 1, this.funcMask = 255, this.opStencilFail = _.KEEP, this.opDepthFail = _.KEEP, this.opStencilDepthPass = _.REPLACE;
      }, Object.defineProperty(n.prototype, "func", { get: function() {
        return this._func;
      }, set: function(t) {
        this._func = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "funcRef", { get: function() {
        return this._funcRef;
      }, set: function(t) {
        this._funcRef = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "funcMask", { get: function() {
        return this._funcMask;
      }, set: function(t) {
        this._funcMask = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "opStencilFail", { get: function() {
        return this._opStencilFail;
      }, set: function(t) {
        this._opStencilFail = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "opDepthFail", { get: function() {
        return this._opDepthFail;
      }, set: function(t) {
        this._opDepthFail = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "opStencilDepthPass", { get: function() {
        return this._opStencilDepthPass;
      }, set: function(t) {
        this._opStencilDepthPass = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "mask", { get: function() {
        return this._mask;
      }, set: function(t) {
        this._mask = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "enabled", { get: function() {
        return this._enabled;
      }, set: function(t) {
        this._enabled = t;
      }, enumerable: !1, configurable: !0 }), n.prototype.getClassName = function() {
        return "MaterialStencilState";
      }, n.prototype.copyTo = function(t) {
        Ne.Clone(function() {
          return t;
        }, this);
      }, n.prototype.serialize = function() {
        return Ne.Serialize(this);
      }, n.prototype.parse = function(t, e, i) {
        var r = this;
        Ne.Parse(function() {
          return r;
        }, t, e, i);
      }, x([N()], n.prototype, "func", null), x([N()], n.prototype, "funcRef", null), x([N()], n.prototype, "funcMask", null), x([N()], n.prototype, "opStencilFail", null), x([N()], n.prototype, "opDepthFail", null), x([N()], n.prototype, "opStencilDepthPass", null), x([N()], n.prototype, "mask", null), x([N()], n.prototype, "enabled", null), n;
    }();
    (function(n) {
      n[n.Created = 1] = "Created", n[n.Disposed = 2] = "Disposed", n[n.GetDefineNames = 4] = "GetDefineNames", n[n.PrepareUniformBuffer = 8] = "PrepareUniformBuffer", n[n.IsReadyForSubMesh = 16] = "IsReadyForSubMesh", n[n.PrepareDefines = 32] = "PrepareDefines", n[n.BindForSubMesh = 64] = "BindForSubMesh", n[n.PrepareEffect = 128] = "PrepareEffect", n[n.GetAnimatables = 256] = "GetAnimatables", n[n.GetActiveTextures = 512] = "GetActiveTextures", n[n.HasTexture = 1024] = "HasTexture", n[n.FillRenderTargetTextures = 2048] = "FillRenderTargetTextures", n[n.HasRenderTargetTextures = 4096] = "HasRenderTargetTextures", n[n.HardBindForSubMesh = 8192] = "HardBindForSubMesh";
    })(rn || (rn = {}));
    var Et = function() {
      function n(t, e, i) {
        this.shadowDepthWrapper = null, this.allowShaderHotSwapping = !0, this.metadata = null, this.reservedDataStore = null, this.checkReadyOnEveryCall = !1, this.checkReadyOnlyOnce = !1, this.state = "", this._alpha = 1, this._backFaceCulling = !0, this._cullBackFaces = !0, this._blockDirtyMechanism = !1, this.onCompiled = null, this.onError = null, this.getRenderTargetTextures = null, this.doNotSerialize = !1, this._storeEffectOnSubMeshes = !1, this.animations = null, this.onDisposeObservable = new H(), this._onDisposeObserver = null, this._onUnBindObservable = null, this._onBindObserver = null, this._alphaMode = _.ALPHA_COMBINE, this._needDepthPrePass = !1, this.disableDepthWrite = !1, this.disableColorWrite = !1, this.forceDepthWrite = !1, this.depthFunction = 0, this.separateCullingPass = !1, this._fogEnabled = !0, this.pointSize = 1, this.zOffset = 0, this.zOffsetUnits = 0, this.stencil = new F1(), this._useUBO = !1, this._fillMode = n.TriangleFillMode, this._cachedDepthWriteState = !1, this._cachedColorWriteState = !1, this._cachedDepthFunctionState = 0, this._indexInSceneMaterialArray = -1, this.meshMap = null, this._parentContainer = null, this._uniformBufferLayoutBuilt = !1, this._eventInfo = {}, this._callbackPluginEventGeneric = function() {
        }, this._callbackPluginEventIsReadyForSubMesh = function() {
        }, this._callbackPluginEventPrepareDefines = function() {
        }, this._callbackPluginEventPrepareDefinesBeforeAttributes = function() {
        }, this._callbackPluginEventHardBindForSubMesh = function() {
        }, this._callbackPluginEventBindForSubMesh = function() {
        }, this._callbackPluginEventHasRenderTargetTextures = function() {
        }, this._callbackPluginEventFillRenderTargetTextures = function() {
        }, this._forceAlphaTest = !1, this._transparencyMode = null, this.name = t;
        var r = e || Me.LastCreatedScene;
        r && (this._scene = r, this._dirtyCallbacks = {}, this._dirtyCallbacks[_.MATERIAL_TextureDirtyFlag] = this._markAllSubMeshesAsTexturesDirty.bind(this), this._dirtyCallbacks[_.MATERIAL_LightDirtyFlag] = this._markAllSubMeshesAsLightsDirty.bind(this), this._dirtyCallbacks[_.MATERIAL_FresnelDirtyFlag] = this._markAllSubMeshesAsFresnelDirty.bind(this), this._dirtyCallbacks[_.MATERIAL_AttributesDirtyFlag] = this._markAllSubMeshesAsAttributesDirty.bind(this), this._dirtyCallbacks[_.MATERIAL_MiscDirtyFlag] = this._markAllSubMeshesAsMiscDirty.bind(this), this._dirtyCallbacks[_.MATERIAL_PrePassDirtyFlag] = this._markAllSubMeshesAsPrePassDirty.bind(this), this._dirtyCallbacks[_.MATERIAL_AllDirtyFlag] = this._markAllSubMeshesAsAllDirty.bind(this), this.id = t || de.RandomId(), this.uniqueId = this._scene.getUniqueId(), this._materialContext = this._scene.getEngine().createMaterialContext(), this._drawWrapper = new Ei(this._scene.getEngine(), !1), this._drawWrapper.materialContext = this._materialContext, this._scene.useRightHandedSystem ? this.sideOrientation = n.ClockWiseSideOrientation : this.sideOrientation = n.CounterClockWiseSideOrientation, this._uniformBuffer = new Er(this._scene.getEngine(), void 0, void 0, t), this._useUBO = this.getScene().getEngine().supportsUniformBuffers, i || this._scene.addMaterial(this), this._scene.useMaterialMeshMap && (this.meshMap = {}), n.OnEventObservable.notifyObservers(this, rn.Created));
      }
      return Object.defineProperty(n.prototype, "canRenderToMRT", { get: function() {
        return !1;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "alpha", { get: function() {
        return this._alpha;
      }, set: function(t) {
        if (this._alpha !== t) {
          var e = this._alpha;
          this._alpha = t, e !== 1 && t !== 1 || this.markAsDirty(n.MiscDirtyFlag + n.PrePassDirtyFlag);
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "backFaceCulling", { get: function() {
        return this._backFaceCulling;
      }, set: function(t) {
        this._backFaceCulling !== t && (this._backFaceCulling = t, this.markAsDirty(n.TextureDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "cullBackFaces", { get: function() {
        return this._cullBackFaces;
      }, set: function(t) {
        this._cullBackFaces !== t && (this._cullBackFaces = t, this.markAsDirty(n.TextureDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "blockDirtyMechanism", { get: function() {
        return this._blockDirtyMechanism;
      }, set: function(t) {
        this._blockDirtyMechanism !== t && (this._blockDirtyMechanism = t, t || this.markDirty());
      }, enumerable: !1, configurable: !0 }), n.prototype.atomicMaterialsUpdate = function(t) {
        this.blockDirtyMechanism = !0;
        try {
          t(this);
        } finally {
          this.blockDirtyMechanism = !1;
        }
      }, Object.defineProperty(n.prototype, "hasRenderTargetTextures", { get: function() {
        return this._eventInfo.hasRenderTargetTextures = !1, this._callbackPluginEventHasRenderTargetTextures(this._eventInfo), this._eventInfo.hasRenderTargetTextures;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "onDispose", { set: function(t) {
        this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver), this._onDisposeObserver = this.onDisposeObservable.add(t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "onBindObservable", { get: function() {
        return this._onBindObservable || (this._onBindObservable = new H()), this._onBindObservable;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "onBind", { set: function(t) {
        this._onBindObserver && this.onBindObservable.remove(this._onBindObserver), this._onBindObserver = this.onBindObservable.add(t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "onUnBindObservable", { get: function() {
        return this._onUnBindObservable || (this._onUnBindObservable = new H()), this._onUnBindObservable;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "onEffectCreatedObservable", { get: function() {
        return this._onEffectCreatedObservable || (this._onEffectCreatedObservable = new H()), this._onEffectCreatedObservable;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "alphaMode", { get: function() {
        return this._alphaMode;
      }, set: function(t) {
        this._alphaMode !== t && (this._alphaMode = t, this.markAsDirty(n.TextureDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "needDepthPrePass", { get: function() {
        return this._needDepthPrePass;
      }, set: function(t) {
        this._needDepthPrePass !== t && (this._needDepthPrePass = t, this._needDepthPrePass && (this.checkReadyOnEveryCall = !0));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isPrePassCapable", { get: function() {
        return !1;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "fogEnabled", { get: function() {
        return this._fogEnabled;
      }, set: function(t) {
        this._fogEnabled !== t && (this._fogEnabled = t, this.markAsDirty(n.MiscDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "wireframe", { get: function() {
        switch (this._fillMode) {
          case n.WireFrameFillMode:
          case n.LineListDrawMode:
          case n.LineLoopDrawMode:
          case n.LineStripDrawMode:
            return !0;
        }
        return this._scene.forceWireframe;
      }, set: function(t) {
        this.fillMode = t ? n.WireFrameFillMode : n.TriangleFillMode;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "pointsCloud", { get: function() {
        switch (this._fillMode) {
          case n.PointFillMode:
          case n.PointListDrawMode:
            return !0;
        }
        return this._scene.forcePointsCloud;
      }, set: function(t) {
        this.fillMode = t ? n.PointFillMode : n.TriangleFillMode;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "fillMode", { get: function() {
        return this._fillMode;
      }, set: function(t) {
        this._fillMode !== t && (this._fillMode = t, this.markAsDirty(n.MiscDirtyFlag));
      }, enumerable: !1, configurable: !0 }), n.prototype._getDrawWrapper = function() {
        return this._drawWrapper;
      }, n.prototype._setDrawWrapper = function(t) {
        this._drawWrapper = t;
      }, n.prototype.toString = function(t) {
        return "Name: " + this.name;
      }, n.prototype.getClassName = function() {
        return "Material";
      }, Object.defineProperty(n.prototype, "_isMaterial", { get: function() {
        return !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isFrozen", { get: function() {
        return this.checkReadyOnlyOnce;
      }, enumerable: !1, configurable: !0 }), n.prototype.freeze = function() {
        this.markDirty(), this.checkReadyOnlyOnce = !0;
      }, n.prototype.unfreeze = function() {
        this.markDirty(), this.checkReadyOnlyOnce = !1;
      }, n.prototype.isReady = function(t, e) {
        return !0;
      }, n.prototype.isReadyForSubMesh = function(t, e, i) {
        var r = e.materialDefines;
        return !!r && (this._eventInfo.isReadyForSubMesh = !0, this._eventInfo.defines = r, this._callbackPluginEventIsReadyForSubMesh(this._eventInfo), this._eventInfo.isReadyForSubMesh);
      }, n.prototype.getEffect = function() {
        return this._drawWrapper.effect;
      }, n.prototype.getScene = function() {
        return this._scene;
      }, Object.defineProperty(n.prototype, "transparencyMode", { get: function() {
        return this._transparencyMode;
      }, set: function(t) {
        this._transparencyMode !== t && (this._transparencyMode = t, this._forceAlphaTest = t === n.MATERIAL_ALPHATESTANDBLEND, this._markAllSubMeshesAsTexturesAndMiscDirty());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "_disableAlphaBlending", { get: function() {
        return this._transparencyMode === n.MATERIAL_OPAQUE || this._transparencyMode === n.MATERIAL_ALPHATEST;
      }, enumerable: !1, configurable: !0 }), n.prototype.needAlphaBlending = function() {
        return !this._disableAlphaBlending && this.alpha < 1;
      }, n.prototype.needAlphaBlendingForMesh = function(t) {
        return t.visibility < 1 || !this._disableAlphaBlending && (t.hasVertexAlpha || this.needAlphaBlending());
      }, n.prototype.needAlphaTesting = function() {
        return !!this._forceAlphaTest;
      }, n.prototype._shouldTurnAlphaTestOn = function(t) {
        return !this.needAlphaBlendingForMesh(t) && this.needAlphaTesting();
      }, n.prototype.getAlphaTestTexture = function() {
        return null;
      }, n.prototype.markDirty = function(t) {
        t === void 0 && (t = !1);
        for (var e = 0, i = this.getScene().meshes; e < i.length; e++) {
          var r = i[e];
          if (r.subMeshes)
            for (var o = 0, a = r.subMeshes; o < a.length; o++) {
              var s = a[o];
              s.getMaterial() === this && s.effect && (s.effect._wasPreviouslyReady = !1, s.effect._wasPreviouslyUsingInstances = null, s.effect._forceRebindOnNextCall = t);
            }
        }
        t && this.markAsDirty(n.AllDirtyFlag);
      }, n.prototype._preBind = function(t, e) {
        e === void 0 && (e = null);
        var i = this._scene.getEngine(), r = (e ?? this.sideOrientation) === n.ClockWiseSideOrientation;
        return i.enableEffect(t || this._getDrawWrapper()), i.setState(this.backFaceCulling, this.zOffset, !1, r, this._scene._mirroredCameraPosition ? !this.cullBackFaces : this.cullBackFaces, this.stencil, this.zOffsetUnits), r;
      }, n.prototype.bind = function(t, e) {
      }, n.prototype.buildUniformLayout = function() {
        var t = this._uniformBuffer;
        this._eventInfo.ubo = t, this._callbackPluginEventGeneric(rn.PrepareUniformBuffer, this._eventInfo), t.create(), this._uniformBufferLayoutBuilt = !0;
      }, n.prototype.bindForSubMesh = function(t, e, i) {
        var r = i.effect;
        r && (this._eventInfo.subMesh = i, this._callbackPluginEventBindForSubMesh(this._eventInfo), r._forceRebindOnNextCall = !1);
      }, n.prototype.bindOnlyWorldMatrix = function(t) {
      }, n.prototype.bindView = function(t) {
        this._useUBO ? this._needToBindSceneUbo = !0 : t.setMatrix("view", this.getScene().getViewMatrix());
      }, n.prototype.bindViewProjection = function(t) {
        this._useUBO ? this._needToBindSceneUbo = !0 : (t.setMatrix("viewProjection", this.getScene().getTransformMatrix()), t.setMatrix("projection", this.getScene().getProjectionMatrix()));
      }, n.prototype.bindEyePosition = function(t, e) {
        this._useUBO ? this._needToBindSceneUbo = !0 : this._scene.bindEyePosition(t, e);
      }, n.prototype._afterBind = function(t, e) {
        if (e === void 0 && (e = null), this._scene._cachedMaterial = this, this._needToBindSceneUbo && e && (this._needToBindSceneUbo = !1, Se.BindSceneUniformBuffer(e, this.getScene().getSceneUniformBuffer()), this._scene.finalizeSceneUbo()), this._scene._cachedVisibility = t ? t.visibility : 1, this._onBindObservable && t && this._onBindObservable.notifyObservers(t), this.disableDepthWrite) {
          var i = this._scene.getEngine();
          this._cachedDepthWriteState = i.getDepthWrite(), i.setDepthWrite(!1);
        }
        this.disableColorWrite && (i = this._scene.getEngine(), this._cachedColorWriteState = i.getColorWrite(), i.setColorWrite(!1)), this.depthFunction !== 0 && (i = this._scene.getEngine(), this._cachedDepthFunctionState = i.getDepthFunction() || 0, i.setDepthFunction(this.depthFunction));
      }, n.prototype.unbind = function() {
        this._onUnBindObservable && this._onUnBindObservable.notifyObservers(this), this.depthFunction !== 0 && this._scene.getEngine().setDepthFunction(this._cachedDepthFunctionState), this.disableDepthWrite && this._scene.getEngine().setDepthWrite(this._cachedDepthWriteState), this.disableColorWrite && this._scene.getEngine().setColorWrite(this._cachedColorWriteState);
      }, n.prototype.getAnimatables = function() {
        return this._eventInfo.animatables = [], this._callbackPluginEventGeneric(rn.GetAnimatables, this._eventInfo), this._eventInfo.animatables;
      }, n.prototype.getActiveTextures = function() {
        return this._eventInfo.activeTextures = [], this._callbackPluginEventGeneric(rn.GetActiveTextures, this._eventInfo), this._eventInfo.activeTextures;
      }, n.prototype.hasTexture = function(t) {
        return this._eventInfo.hasTexture = !1, this._eventInfo.texture = t, this._callbackPluginEventGeneric(rn.HasTexture, this._eventInfo), this._eventInfo.hasTexture;
      }, n.prototype.clone = function(t) {
        return null;
      }, n.prototype._clonePlugins = function(t, e) {
        var i = {};
        if (this._serializePlugins(i), n._parsePlugins(i, t, this._scene, e), this.pluginManager)
          for (var r = 0, o = this.pluginManager._plugins; r < o.length; r++) {
            var a = o[r], s = t.pluginManager.getPlugin(a.name);
            a.copyTo(s);
          }
      }, n.prototype.getBindedMeshes = function() {
        var t = this;
        if (this.meshMap) {
          var e = [];
          for (var i in this.meshMap) {
            var r = this.meshMap[i];
            r && e.push(r);
          }
          return e;
        }
        return this._scene.meshes.filter(function(o) {
          return o.material === t;
        });
      }, n.prototype.forceCompilation = function(t, e, i, r) {
        var o = this, a = je({ clipPlane: !1, useInstances: !1 }, i), s = this.getScene(), l = this.allowShaderHotSwapping;
        this.allowShaderHotSwapping = !1;
        var c = function() {
          if (o._scene && o._scene.getEngine()) {
            var u = s.clipPlane;
            if (a.clipPlane && (s.clipPlane = new xo(0, 0, 0, 1)), o._storeEffectOnSubMeshes) {
              var h = !0, d = null;
              if (t.subMeshes) {
                var p = new Yn(0, 0, 0, 0, 0, t, void 0, !1, !1);
                p.materialDefines && (p.materialDefines._renderId = -1), o.isReadyForSubMesh(t, p, a.useInstances) || (p.effect && p.effect.getCompilationError() && p.effect.allFallbacksProcessed() ? d = p.effect.getCompilationError() : (h = !1, setTimeout(c, 16)));
              }
              h && (o.allowShaderHotSwapping = l, d && r && r(d), e && e(o));
            } else
              o.isReady() ? (o.allowShaderHotSwapping = l, e && e(o)) : setTimeout(c, 16);
            a.clipPlane && (s.clipPlane = u);
          }
        };
        c();
      }, n.prototype.forceCompilationAsync = function(t, e) {
        var i = this;
        return new Promise(function(r, o) {
          i.forceCompilation(t, function() {
            r();
          }, e, function(a) {
            o(a);
          });
        });
      }, n.prototype.markAsDirty = function(t) {
        this.getScene().blockMaterialDirtyMechanism || this._blockDirtyMechanism || (n._DirtyCallbackArray.length = 0, t & n.TextureDirtyFlag && n._DirtyCallbackArray.push(n._TextureDirtyCallBack), t & n.LightDirtyFlag && n._DirtyCallbackArray.push(n._LightsDirtyCallBack), t & n.FresnelDirtyFlag && n._DirtyCallbackArray.push(n._FresnelDirtyCallBack), t & n.AttributesDirtyFlag && n._DirtyCallbackArray.push(n._AttributeDirtyCallBack), t & n.MiscDirtyFlag && n._DirtyCallbackArray.push(n._MiscDirtyCallBack), t & n.PrePassDirtyFlag && n._DirtyCallbackArray.push(n._PrePassDirtyCallBack), n._DirtyCallbackArray.length && this._markAllSubMeshesAsDirty(n._RunDirtyCallBacks), this.getScene().resetCachedMaterial());
      }, n.prototype.resetDrawCache = function() {
        for (var t = 0, e = this.getScene().meshes; t < e.length; t++) {
          var i = e[t];
          if (i.subMeshes)
            for (var r = 0, o = i.subMeshes; r < o.length; r++) {
              var a = o[r];
              a.getMaterial() === this && a.resetDrawCache();
            }
        }
      }, n.prototype._markAllSubMeshesAsDirty = function(t) {
        if (!this.getScene().blockMaterialDirtyMechanism && !this._blockDirtyMechanism)
          for (var e = 0, i = this.getScene().meshes; e < i.length; e++) {
            var r = i[e];
            if (r.subMeshes)
              for (var o = 0, a = r.subMeshes; o < a.length; o++) {
                var s = a[o];
                if (s.getMaterial(!1) === this)
                  for (var l = 0, c = s._drawWrappers; l < c.length; l++) {
                    var u = c[l];
                    u && u.defines && u.defines.markAllAsDirty && this._materialContext === u.materialContext && t(u.defines);
                  }
              }
          }
      }, n.prototype._markScenePrePassDirty = function() {
        if (!this.getScene().blockMaterialDirtyMechanism && !this._blockDirtyMechanism) {
          var t = this.getScene().enablePrePassRenderer();
          t && t.markAsDirty();
        }
      }, n.prototype._markAllSubMeshesAsAllDirty = function() {
        this._markAllSubMeshesAsDirty(n._AllDirtyCallBack);
      }, n.prototype._markAllSubMeshesAsImageProcessingDirty = function() {
        this._markAllSubMeshesAsDirty(n._ImageProcessingDirtyCallBack);
      }, n.prototype._markAllSubMeshesAsTexturesDirty = function() {
        this._markAllSubMeshesAsDirty(n._TextureDirtyCallBack);
      }, n.prototype._markAllSubMeshesAsFresnelDirty = function() {
        this._markAllSubMeshesAsDirty(n._FresnelDirtyCallBack);
      }, n.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function() {
        this._markAllSubMeshesAsDirty(n._FresnelAndMiscDirtyCallBack);
      }, n.prototype._markAllSubMeshesAsLightsDirty = function() {
        this._markAllSubMeshesAsDirty(n._LightsDirtyCallBack);
      }, n.prototype._markAllSubMeshesAsAttributesDirty = function() {
        this._markAllSubMeshesAsDirty(n._AttributeDirtyCallBack);
      }, n.prototype._markAllSubMeshesAsMiscDirty = function() {
        this._markAllSubMeshesAsDirty(n._MiscDirtyCallBack);
      }, n.prototype._markAllSubMeshesAsPrePassDirty = function() {
        this._markAllSubMeshesAsDirty(n._MiscDirtyCallBack);
      }, n.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function() {
        this._markAllSubMeshesAsDirty(n._TextureAndMiscDirtyCallBack);
      }, n.prototype._checkScenePerformancePriority = function() {
        var t = this;
        if (this._scene.performancePriority !== Zr.BackwardCompatible) {
          this.checkReadyOnlyOnce = !0;
          var e = this._scene.onScenePerformancePriorityChangedObservable.addOnce(function() {
            t.checkReadyOnlyOnce = !1;
          });
          this.onDisposeObservable.add(function() {
            t._scene.onScenePerformancePriorityChangedObservable.remove(e);
          });
        }
      }, n.prototype.setPrePassRenderer = function(t) {
        return !1;
      }, n.prototype.dispose = function(t, e, i) {
        var r = this.getScene();
        if (r.stopAnimation(this), r.freeProcessedMaterials(), r.removeMaterial(this), this._eventInfo.forceDisposeTextures = e, this._callbackPluginEventGeneric(rn.Disposed, this._eventInfo), this._parentContainer) {
          var o = this._parentContainer.materials.indexOf(this);
          o > -1 && this._parentContainer.materials.splice(o, 1), this._parentContainer = null;
        }
        if (i !== !0)
          if (this.meshMap)
            for (var a in this.meshMap)
              (c = this.meshMap[a]) && (c.material = null, this.releaseVertexArrayObject(c, t));
          else
            for (var s = 0, l = r.meshes; s < l.length; s++) {
              var c;
              (c = l[s]).material !== this || c.sourceMesh || (c.material = null, this.releaseVertexArrayObject(c, t));
            }
        this._uniformBuffer.dispose(), t && this._drawWrapper.effect && (this._storeEffectOnSubMeshes || this._drawWrapper.effect.dispose(), this._drawWrapper.effect = null), this.metadata = null, this.onDisposeObservable.notifyObservers(this), this.onDisposeObservable.clear(), this._onBindObservable && this._onBindObservable.clear(), this._onUnBindObservable && this._onUnBindObservable.clear(), this._onEffectCreatedObservable && this._onEffectCreatedObservable.clear(), this._eventInfo && (this._eventInfo = {});
      }, n.prototype.releaseVertexArrayObject = function(t, e) {
        var i = t.geometry;
        if (i)
          if (this._storeEffectOnSubMeshes) {
            if (t.subMeshes)
              for (var r = 0, o = t.subMeshes; r < o.length; r++) {
                var a = o[r];
                i._releaseVertexArrayObject(a.effect), e && a.effect && a.effect.dispose();
              }
          } else
            i._releaseVertexArrayObject(this._drawWrapper.effect);
      }, n.prototype.serialize = function() {
        var t = Ne.Serialize(this);
        return t.stencil = this.stencil.serialize(), t.uniqueId = this.uniqueId, this._serializePlugins(t), t;
      }, n.prototype._serializePlugins = function(t) {
        if (t.plugins = {}, this.pluginManager)
          for (var e = 0, i = this.pluginManager._plugins; e < i.length; e++) {
            var r = i[e];
            t.plugins[r.getClassName()] = r.serialize();
          }
      }, n.Parse = function(t, e, i) {
        if (t.customType) {
          if (t.customType === "BABYLON.PBRMaterial" && t.overloadedAlbedo && (t.customType = "BABYLON.LegacyPBRMaterial", !BABYLON.LegacyPBRMaterial))
            return q.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library."), null;
        } else
          t.customType = "BABYLON.StandardMaterial";
        var r = de.Instantiate(t.customType).Parse(t, e, i);
        return r._loadedUniqueId = t.uniqueId, r;
      }, n._parsePlugins = function(t, e, i, r) {
        var o;
        if (t.plugins)
          for (var a in t.plugins) {
            var s = t.plugins[a], l = (o = e.pluginManager) === null || o === void 0 ? void 0 : o.getPlugin(s.name);
            if (!l) {
              var c = de.Instantiate("BABYLON." + a);
              c && (l = new c(e));
            }
            l == null || l.parse(s, i, r);
          }
      }, n.TriangleFillMode = _.MATERIAL_TriangleFillMode, n.WireFrameFillMode = _.MATERIAL_WireFrameFillMode, n.PointFillMode = _.MATERIAL_PointFillMode, n.PointListDrawMode = _.MATERIAL_PointListDrawMode, n.LineListDrawMode = _.MATERIAL_LineListDrawMode, n.LineLoopDrawMode = _.MATERIAL_LineLoopDrawMode, n.LineStripDrawMode = _.MATERIAL_LineStripDrawMode, n.TriangleStripDrawMode = _.MATERIAL_TriangleStripDrawMode, n.TriangleFanDrawMode = _.MATERIAL_TriangleFanDrawMode, n.ClockWiseSideOrientation = _.MATERIAL_ClockWiseSideOrientation, n.CounterClockWiseSideOrientation = _.MATERIAL_CounterClockWiseSideOrientation, n.TextureDirtyFlag = _.MATERIAL_TextureDirtyFlag, n.LightDirtyFlag = _.MATERIAL_LightDirtyFlag, n.FresnelDirtyFlag = _.MATERIAL_FresnelDirtyFlag, n.AttributesDirtyFlag = _.MATERIAL_AttributesDirtyFlag, n.MiscDirtyFlag = _.MATERIAL_MiscDirtyFlag, n.PrePassDirtyFlag = _.MATERIAL_PrePassDirtyFlag, n.AllDirtyFlag = _.MATERIAL_AllDirtyFlag, n.MATERIAL_OPAQUE = 0, n.MATERIAL_ALPHATEST = 1, n.MATERIAL_ALPHABLEND = 2, n.MATERIAL_ALPHATESTANDBLEND = 3, n.MATERIAL_NORMALBLENDMETHOD_WHITEOUT = 0, n.MATERIAL_NORMALBLENDMETHOD_RNM = 1, n.OnEventObservable = new H(), n._AllDirtyCallBack = function(t) {
        return t.markAllAsDirty();
      }, n._ImageProcessingDirtyCallBack = function(t) {
        return t.markAsImageProcessingDirty();
      }, n._TextureDirtyCallBack = function(t) {
        return t.markAsTexturesDirty();
      }, n._FresnelDirtyCallBack = function(t) {
        return t.markAsFresnelDirty();
      }, n._MiscDirtyCallBack = function(t) {
        return t.markAsMiscDirty();
      }, n._PrePassDirtyCallBack = function(t) {
        return t.markAsPrePassDirty();
      }, n._LightsDirtyCallBack = function(t) {
        return t.markAsLightDirty();
      }, n._AttributeDirtyCallBack = function(t) {
        return t.markAsAttributesDirty();
      }, n._FresnelAndMiscDirtyCallBack = function(t) {
        n._FresnelDirtyCallBack(t), n._MiscDirtyCallBack(t);
      }, n._TextureAndMiscDirtyCallBack = function(t) {
        n._TextureDirtyCallBack(t), n._MiscDirtyCallBack(t);
      }, n._DirtyCallbackArray = [], n._RunDirtyCallBacks = function(t) {
        for (var e = 0, i = n._DirtyCallbackArray; e < i.length; e++)
          (0, i[e])(t);
      }, x([N()], n.prototype, "id", void 0), x([N()], n.prototype, "uniqueId", void 0), x([N()], n.prototype, "name", void 0), x([N()], n.prototype, "metadata", void 0), x([N()], n.prototype, "checkReadyOnEveryCall", void 0), x([N()], n.prototype, "checkReadyOnlyOnce", void 0), x([N()], n.prototype, "state", void 0), x([N("alpha")], n.prototype, "_alpha", void 0), x([N("backFaceCulling")], n.prototype, "_backFaceCulling", void 0), x([N("cullBackFaces")], n.prototype, "_cullBackFaces", void 0), x([N()], n.prototype, "sideOrientation", void 0), x([N("alphaMode")], n.prototype, "_alphaMode", void 0), x([N()], n.prototype, "_needDepthPrePass", void 0), x([N()], n.prototype, "disableDepthWrite", void 0), x([N()], n.prototype, "disableColorWrite", void 0), x([N()], n.prototype, "forceDepthWrite", void 0), x([N()], n.prototype, "depthFunction", void 0), x([N()], n.prototype, "separateCullingPass", void 0), x([N("fogEnabled")], n.prototype, "_fogEnabled", void 0), x([N()], n.prototype, "pointSize", void 0), x([N()], n.prototype, "zOffset", void 0), x([N()], n.prototype, "zOffsetUnits", void 0), x([N()], n.prototype, "pointsCloud", null), x([N()], n.prototype, "fillMode", null), x([N()], n.prototype, "transparencyMode", null), n;
    }(), Ao = function(n) {
      function t(e, i) {
        var r = n.call(this, e, i, !0) || this;
        return r._waitingSubMaterialsUniqueIds = [], r.getScene().addMultiMaterial(r), r.subMaterials = [], r._storeEffectOnSubMeshes = !0, r;
      }
      return D(t, n), Object.defineProperty(t.prototype, "subMaterials", { get: function() {
        return this._subMaterials;
      }, set: function(e) {
        this._subMaterials = e, this._hookArray(e);
      }, enumerable: !1, configurable: !0 }), t.prototype.getChildren = function() {
        return this.subMaterials;
      }, t.prototype._hookArray = function(e) {
        var i = this, r = e.push;
        e.push = function() {
          for (var a = [], s = 0; s < arguments.length; s++)
            a[s] = arguments[s];
          var l = r.apply(e, a);
          return i._markAllSubMeshesAsTexturesDirty(), l;
        };
        var o = e.splice;
        e.splice = function(a, s) {
          var l = o.apply(e, [a, s]);
          return i._markAllSubMeshesAsTexturesDirty(), l;
        };
      }, t.prototype.getSubMaterial = function(e) {
        return e < 0 || e >= this.subMaterials.length ? this.getScene().defaultMaterial : this.subMaterials[e];
      }, t.prototype.getActiveTextures = function() {
        var e;
        return (e = n.prototype.getActiveTextures.call(this)).concat.apply(e, this.subMaterials.map(function(i) {
          return i ? i.getActiveTextures() : [];
        }));
      }, t.prototype.hasTexture = function(e) {
        var i;
        if (n.prototype.hasTexture.call(this, e))
          return !0;
        for (var r = 0; r < this.subMaterials.length; r++)
          if (!((i = this.subMaterials[r]) === null || i === void 0) && i.hasTexture(e))
            return !0;
        return !1;
      }, t.prototype.getClassName = function() {
        return "MultiMaterial";
      }, t.prototype.isReadyForSubMesh = function(e, i, r) {
        for (var o = 0; o < this.subMaterials.length; o++) {
          var a = this.subMaterials[o];
          if (a) {
            if (a._storeEffectOnSubMeshes) {
              if (!a.isReadyForSubMesh(e, i, r))
                return !1;
              continue;
            }
            if (!a.isReady(e))
              return !1;
          }
        }
        return !0;
      }, t.prototype.clone = function(e, i) {
        for (var r = new t(e, this.getScene()), o = 0; o < this.subMaterials.length; o++) {
          var a, s = this.subMaterials[o];
          a = i && s ? s.clone(e + "-" + s.name) : this.subMaterials[o], r.subMaterials.push(a);
        }
        return r;
      }, t.prototype.serialize = function() {
        var e = {};
        e.name = this.name, e.id = this.id, e.uniqueId = this.uniqueId, Xt && (e.tags = Xt.GetTags(this)), e.materialsUniqueIds = [], e.materials = [];
        for (var i = 0; i < this.subMaterials.length; i++) {
          var r = this.subMaterials[i];
          r ? (e.materialsUniqueIds.push(r.uniqueId), e.materials.push(r.id)) : (e.materialsUniqueIds.push(null), e.materials.push(null));
        }
        return e;
      }, t.prototype.dispose = function(e, i, r) {
        var o = this.getScene();
        if (o) {
          if (r)
            for (var a = 0; a < this.subMaterials.length; a++) {
              var s = this.subMaterials[a];
              s && s.dispose(e, i);
            }
          var l = o.multiMaterials.indexOf(this);
          l >= 0 && o.multiMaterials.splice(l, 1), n.prototype.dispose.call(this, e, i);
        }
      }, t.ParseMultiMaterial = function(e, i) {
        var r = new t(e.name, i);
        return r.id = e.id, r._loadedUniqueId = e.uniqueId, Xt && Xt.AddTagsTo(r, e.tags), e.materialsUniqueIds ? r._waitingSubMaterialsUniqueIds = e.materialsUniqueIds : e.materials.forEach(function(o) {
          return r.subMaterials.push(i.getLastMaterialById(o));
        }), r;
      }, t;
    }(Et);
    j("BABYLON.MultiMaterial", Ao);
    var Sg = function(n, t) {
      this.distanceOrScreenCoverage = n, this.mesh = t;
    }, Ap = function() {
    }, L1 = function() {
      this.visibleInstances = {}, this.batchCache = new Rp(), this.batchCacheReplacementModeInFrozenMode = new Rp(), this.instancesBufferSize = 2048;
    }, Rp = function() {
      this.mustReturn = !1, this.visibleInstances = new Array(), this.renderSelf = [], this.hardwareInstancedRendering = [];
    }, w1 = function() {
      this.instancesCount = 0, this.matrixBuffer = null, this.previousMatrixBuffer = null, this.matrixBufferSize = 512, this.matrixData = null, this.boundingVectors = [], this.worldMatrices = null;
    }, B1 = function() {
      this._areNormalsFrozen = !1, this._source = null, this.meshMap = null, this._preActivateId = -1, this._LODLevels = new Array(), this._useLODScreenCoverage = !1, this._effectiveMaterial = null, this._forcedInstanceCount = 0, this._overrideRenderingFillMode = null;
    }, ie = function(n) {
      function t(e, i, r, o, a, s) {
        i === void 0 && (i = null), r === void 0 && (r = null), o === void 0 && (o = null), s === void 0 && (s = !0);
        var l = n.call(this, e, i) || this;
        if (l._internalMeshDataInfo = new B1(), l.delayLoadState = _.DELAYLOADSTATE_NONE, l.instances = [], l._creationDataStorage = null, l._geometry = null, l._instanceDataStorage = new L1(), l._thinInstanceDataStorage = new w1(), l._shouldGenerateFlatShading = !1, l._originalBuilderSideOrientation = t.DEFAULTSIDE, l.overrideMaterialSideOrientation = null, l.ignoreCameraMaxZ = !1, i = l.getScene(), l._onBeforeDraw = function(y, b, T) {
          y && T && (l._uniformBuffer ? l.transferToEffect(b) : T.bindOnlyWorldMatrix(b));
        }, o) {
          if (o._geometry && o._geometry.applyToMesh(l), Ui.DeepCopy(o, l, ["name", "material", "skeleton", "instances", "parent", "uniqueId", "source", "metadata", "morphTargetManager", "hasInstances", "worldMatrixInstancedBuffer", "previousWorldMatrixInstancedBuffer", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen", "facetNb", "isFacetDataEnabled", "lightSources", "useBones", "isAnInstance", "collider", "edgesRenderer", "forward", "up", "right", "absolutePosition", "absoluteScaling", "absoluteRotationQuaternion", "isWorldMatrixFrozen", "nonUniformScaling", "behaviors", "worldMatrixFromCache", "hasThinInstances", "cloneMeshMap", "hasBoundingInfo", "physicsBody", "physicsImpostor"], ["_poseMatrix"]), l._internalMeshDataInfo._source = o, i.useClonedMeshMap && (o._internalMeshDataInfo.meshMap || (o._internalMeshDataInfo.meshMap = {}), o._internalMeshDataInfo.meshMap[l.uniqueId] = l), l._originalBuilderSideOrientation = o._originalBuilderSideOrientation, l._creationDataStorage = o._creationDataStorage, o._ranges) {
            var c = o._ranges;
            for (var u in c)
              Object.prototype.hasOwnProperty.call(c, u) && c[u] && l.createAnimationRange(u, c[u].from, c[u].to);
          }
          if (o.metadata && o.metadata.clone ? l.metadata = o.metadata.clone() : l.metadata = o.metadata, l._internalMetadata = o._internalMetadata, Xt && Xt.HasTags(o) && Xt.AddTagsTo(l, Xt.GetTags(o, !0)), l.setEnabled(o.isEnabled(!1)), l.parent = o.parent, l.setPivotMatrix(o.getPivotMatrix()), l.id = e + "." + o.id, l.material = o.material, !a)
            for (var h = o.getDescendants(!0), d = 0; d < h.length; d++) {
              var p = h[d];
              p.clone && p.clone(e + "." + p.name, l);
            }
          if (o.morphTargetManager && (l.morphTargetManager = o.morphTargetManager), i.getPhysicsEngine) {
            var f = i.getPhysicsEngine();
            if (s && f)
              if (f.getPluginVersion() === 1) {
                var m = f.getImpostorForPhysicsObject(o);
                m && (l.physicsImpostor = m.clone(l));
              } else
                f.getPluginVersion() === 2 && o.physicsBody && o.physicsBody.clone(l);
          }
          for (d = 0; d < i.particleSystems.length; d++) {
            var g = i.particleSystems[d];
            g.emitter === o && g.clone(g.name, l);
          }
          l.skeleton = o.skeleton, l.refreshBoundingInfo(!0, !0), l.computeWorldMatrix(!0);
        }
        return r !== null && (l.parent = r), l._instanceDataStorage.hardwareInstancedRendering = l.getEngine().getCaps().instancedArrays, l._internalMeshDataInfo._onMeshReadyObserverAdded = function(y) {
          y.unregisterOnNextCall = !0, l.isReady(!0) ? l.onMeshReadyObservable.notifyObservers(l) : l._internalMeshDataInfo._checkReadinessObserver || (l._internalMeshDataInfo._checkReadinessObserver = l._scene.onBeforeRenderObservable.add(function() {
            l.isReady(!0) && (l._scene.onBeforeRenderObservable.remove(l._internalMeshDataInfo._checkReadinessObserver), l._internalMeshDataInfo._checkReadinessObserver = null, l.onMeshReadyObservable.notifyObservers(l));
          }));
        }, l.onMeshReadyObservable = new H(l._internalMeshDataInfo._onMeshReadyObserverAdded), o && o.onClonedObservable.notifyObservers(l), l;
      }
      return D(t, n), t._GetDefaultSideOrientation = function(e) {
        return e || t.FRONTSIDE;
      }, Object.defineProperty(t.prototype, "useLODScreenCoverage", { get: function() {
        return this._internalMeshDataInfo._useLODScreenCoverage;
      }, set: function(e) {
        this._internalMeshDataInfo._useLODScreenCoverage = e, this._sortLODLevels();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "computeBonesUsingShaders", { get: function() {
        return this._internalAbstractMeshDataInfo._computeBonesUsingShaders;
      }, set: function(e) {
        this._internalAbstractMeshDataInfo._computeBonesUsingShaders !== e && (e && this._internalMeshDataInfo._sourcePositions && (this.setVerticesData(P.PositionKind, this._internalMeshDataInfo._sourcePositions, !0), this._internalMeshDataInfo._sourceNormals && this.setVerticesData(P.NormalKind, this._internalMeshDataInfo._sourceNormals, !0), this._internalMeshDataInfo._sourcePositions = null, this._internalMeshDataInfo._sourceNormals = null), this._internalAbstractMeshDataInfo._computeBonesUsingShaders = e, this._markSubMeshesAsAttributesDirty());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onBeforeRenderObservable", { get: function() {
        return this._internalMeshDataInfo._onBeforeRenderObservable || (this._internalMeshDataInfo._onBeforeRenderObservable = new H()), this._internalMeshDataInfo._onBeforeRenderObservable;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onBeforeBindObservable", { get: function() {
        return this._internalMeshDataInfo._onBeforeBindObservable || (this._internalMeshDataInfo._onBeforeBindObservable = new H()), this._internalMeshDataInfo._onBeforeBindObservable;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onAfterRenderObservable", { get: function() {
        return this._internalMeshDataInfo._onAfterRenderObservable || (this._internalMeshDataInfo._onAfterRenderObservable = new H()), this._internalMeshDataInfo._onAfterRenderObservable;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onBetweenPassObservable", { get: function() {
        return this._internalMeshDataInfo._onBetweenPassObservable || (this._internalMeshDataInfo._onBetweenPassObservable = new H()), this._internalMeshDataInfo._onBetweenPassObservable;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onBeforeDrawObservable", { get: function() {
        return this._internalMeshDataInfo._onBeforeDrawObservable || (this._internalMeshDataInfo._onBeforeDrawObservable = new H()), this._internalMeshDataInfo._onBeforeDrawObservable;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onBeforeDraw", { set: function(e) {
        this._onBeforeDrawObserver && this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver), this._onBeforeDrawObserver = this.onBeforeDrawObservable.add(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hasInstances", { get: function() {
        return this.instances.length > 0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hasThinInstances", { get: function() {
        return (this.forcedInstanceCount || this._thinInstanceDataStorage.instancesCount || 0) > 0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "forcedInstanceCount", { get: function() {
        return this._internalMeshDataInfo._forcedInstanceCount;
      }, set: function(e) {
        this._internalMeshDataInfo._forcedInstanceCount = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "overrideRenderingFillMode", { get: function() {
        return this._internalMeshDataInfo._overrideRenderingFillMode;
      }, set: function(e) {
        this._internalMeshDataInfo._overrideRenderingFillMode = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "source", { get: function() {
        return this._internalMeshDataInfo._source;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cloneMeshMap", { get: function() {
        return this._internalMeshDataInfo.meshMap;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isUnIndexed", { get: function() {
        return this._unIndexed;
      }, set: function(e) {
        this._unIndexed !== e && (this._unIndexed = e, this._markSubMeshesAsAttributesDirty());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldMatrixInstancedBuffer", { get: function() {
        return this._instanceDataStorage.instancesData;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "previousWorldMatrixInstancedBuffer", { get: function() {
        return this._instanceDataStorage.instancesPreviousData;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "manualUpdateOfWorldMatrixInstancedBuffer", { get: function() {
        return this._instanceDataStorage.manualUpdate;
      }, set: function(e) {
        this._instanceDataStorage.manualUpdate = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "manualUpdateOfPreviousWorldMatrixInstancedBuffer", { get: function() {
        return this._instanceDataStorage.previousManualUpdate;
      }, set: function(e) {
        this._instanceDataStorage.previousManualUpdate = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "forceWorldMatrixInstancedBufferUpdate", { get: function() {
        return this._instanceDataStorage.forceMatrixUpdates;
      }, set: function(e) {
        this._instanceDataStorage.forceMatrixUpdates = e;
      }, enumerable: !1, configurable: !0 }), t.prototype.instantiateHierarchy = function(e, i, r) {
        e === void 0 && (e = null);
        var o = this.getTotalVertices() === 0 || i && i.doNotInstantiate && (i.doNotInstantiate === !0 || i.doNotInstantiate(this)) ? this.clone("Clone of " + (this.name || this.id), e || this.parent, !0) : this.createInstance("instance of " + (this.name || this.id));
        o.parent = e || this.parent, o.position = this.position.clone(), o.scaling = this.scaling.clone(), this.rotationQuaternion ? o.rotationQuaternion = this.rotationQuaternion.clone() : o.rotation = this.rotation.clone(), r && r(this, o);
        for (var a = 0, s = this.getChildTransformNodes(!0); a < s.length; a++) {
          var l = s[a];
          l.getClassName() === "InstancedMesh" && o.getClassName() === "Mesh" && l.sourceMesh === this ? l.instantiateHierarchy(o, { doNotInstantiate: i && i.doNotInstantiate || !1, newSourcedMesh: o }, r) : l.instantiateHierarchy(o, i, r);
        }
        return o;
      }, t.prototype.getClassName = function() {
        return "Mesh";
      }, Object.defineProperty(t.prototype, "_isMesh", { get: function() {
        return !0;
      }, enumerable: !1, configurable: !0 }), t.prototype.toString = function(e) {
        var i = n.prototype.toString.call(this, e);
        if (i += ", n vertices: " + this.getTotalVertices(), i += ", parent: " + (this._waitingParentId ? this._waitingParentId : this.parent ? this.parent.name : "NONE"), this.animations)
          for (var r = 0; r < this.animations.length; r++)
            i += ", animation[0]: " + this.animations[r].toString(e);
        if (e)
          if (this._geometry) {
            var o = this.getIndices(), a = this.getVerticesData(P.PositionKind);
            a && o && (i += ", flat shading: " + (a.length / 3 === o.length ? "YES" : "NO"));
          } else
            i += ", flat shading: UNKNOWN";
        return i;
      }, t.prototype._unBindEffect = function() {
        n.prototype._unBindEffect.call(this);
        for (var e = 0, i = this.instances; e < i.length; e++)
          i[e]._unBindEffect();
      }, Object.defineProperty(t.prototype, "hasLODLevels", { get: function() {
        return this._internalMeshDataInfo._LODLevels.length > 0;
      }, enumerable: !1, configurable: !0 }), t.prototype.getLODLevels = function() {
        return this._internalMeshDataInfo._LODLevels;
      }, t.prototype._sortLODLevels = function() {
        var e = this._internalMeshDataInfo._useLODScreenCoverage ? -1 : 1;
        this._internalMeshDataInfo._LODLevels.sort(function(i, r) {
          return i.distanceOrScreenCoverage < r.distanceOrScreenCoverage ? e : i.distanceOrScreenCoverage > r.distanceOrScreenCoverage ? -e : 0;
        });
      }, t.prototype.addLODLevel = function(e, i) {
        if (i && i._masterMesh)
          return q.Warn("You cannot use a mesh as LOD level twice"), this;
        var r = new Sg(e, i);
        return this._internalMeshDataInfo._LODLevels.push(r), i && (i._masterMesh = this), this._sortLODLevels(), this;
      }, t.prototype.getLODLevelAtDistance = function(e) {
        for (var i = this._internalMeshDataInfo, r = 0; r < i._LODLevels.length; r++) {
          var o = i._LODLevels[r];
          if (o.distanceOrScreenCoverage === e)
            return o.mesh;
        }
        return null;
      }, t.prototype.removeLODLevel = function(e) {
        for (var i = this._internalMeshDataInfo, r = 0; r < i._LODLevels.length; r++)
          i._LODLevels[r].mesh === e && (i._LODLevels.splice(r, 1), e && (e._masterMesh = null));
        return this._sortLODLevels(), this;
      }, t.prototype.getLOD = function(e, i) {
        var r = this._internalMeshDataInfo;
        if (!r._LODLevels || r._LODLevels.length === 0)
          return this;
        var o = i || this.getBoundingInfo().boundingSphere, a = e.mode === dt.ORTHOGRAPHIC_CAMERA ? e.minZ : o.centerWorld.subtract(e.globalPosition).length(), s = a, l = 1;
        if (r._useLODScreenCoverage) {
          var c = e.screenArea, u = o.radiusWorld * e.minZ / a;
          s = (u = u * u * Math.PI) / c, l = -1;
        }
        if (l * r._LODLevels[r._LODLevels.length - 1].distanceOrScreenCoverage > l * s)
          return this.onLODLevelSelection && this.onLODLevelSelection(s, this, this), this;
        for (var h = 0; h < r._LODLevels.length; h++) {
          var d = r._LODLevels[h];
          if (l * d.distanceOrScreenCoverage < l * s) {
            if (d.mesh) {
              if (d.mesh.delayLoadState === _.DELAYLOADSTATE_NOTLOADED)
                return d.mesh._checkDelayState(), this;
              if (d.mesh.delayLoadState === _.DELAYLOADSTATE_LOADING)
                return this;
              d.mesh._preActivate(), d.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);
            }
            return this.onLODLevelSelection && this.onLODLevelSelection(s, this, d.mesh), d.mesh;
          }
        }
        return this.onLODLevelSelection && this.onLODLevelSelection(s, this, this), this;
      }, Object.defineProperty(t.prototype, "geometry", { get: function() {
        return this._geometry;
      }, enumerable: !1, configurable: !0 }), t.prototype.getTotalVertices = function() {
        return this._geometry === null || this._geometry === void 0 ? 0 : this._geometry.getTotalVertices();
      }, t.prototype.getVerticesData = function(e, i, r, o) {
        var a, s;
        if (!this._geometry)
          return null;
        var l = o || (s = (a = this._userInstancedBuffersStorage) === null || a === void 0 ? void 0 : a.vertexBuffers[e]) === null || s === void 0 ? void 0 : s.getFloatData(this.instances.length + 1, r || i && this._geometry.meshes.length !== 1);
        return l || (l = this._geometry.getVerticesData(e, i, r)), l;
      }, t.prototype.getVertexBuffer = function(e, i) {
        var r, o;
        return this._geometry ? (o = i || (r = this._userInstancedBuffersStorage) === null || r === void 0 ? void 0 : r.vertexBuffers[e]) !== null && o !== void 0 ? o : this._geometry.getVertexBuffer(e) : null;
      }, t.prototype.isVerticesDataPresent = function(e, i) {
        var r;
        return this._geometry ? !i && ((r = this._userInstancedBuffersStorage) === null || r === void 0 ? void 0 : r.vertexBuffers[e]) !== void 0 || this._geometry.isVerticesDataPresent(e) : !!this._delayInfo && this._delayInfo.indexOf(e) !== -1;
      }, t.prototype.isVertexBufferUpdatable = function(e, i) {
        var r;
        if (!this._geometry)
          return !!this._delayInfo && this._delayInfo.indexOf(e) !== -1;
        if (!i) {
          var o = (r = this._userInstancedBuffersStorage) === null || r === void 0 ? void 0 : r.vertexBuffers[e];
          if (o)
            return o.isUpdatable();
        }
        return this._geometry.isVertexBufferUpdatable(e);
      }, t.prototype.getVerticesDataKinds = function(e) {
        if (!this._geometry) {
          var i = [];
          return this._delayInfo && this._delayInfo.forEach(function(a) {
            i.push(a);
          }), i;
        }
        var r = this._geometry.getVerticesDataKinds();
        if (!e && this._userInstancedBuffersStorage)
          for (var o in this._userInstancedBuffersStorage.vertexBuffers)
            r.indexOf(o) === -1 && r.push(o);
        return r;
      }, t.prototype.getTotalIndices = function() {
        return this._geometry ? this._geometry.getTotalIndices() : 0;
      }, t.prototype.getIndices = function(e, i) {
        return this._geometry ? this._geometry.getIndices(e, i) : [];
      }, Object.defineProperty(t.prototype, "isBlocked", { get: function() {
        return this._masterMesh !== null && this._masterMesh !== void 0;
      }, enumerable: !1, configurable: !0 }), t.prototype.isReady = function(e, i) {
        var r, o, a, s, l, c, u;
        if (e === void 0 && (e = !1), i === void 0 && (i = !1), this.delayLoadState === _.DELAYLOADSTATE_LOADING || !n.prototype.isReady.call(this, e))
          return !1;
        if (!this.subMeshes || this.subMeshes.length === 0 || !e)
          return !0;
        var h = this.getEngine(), d = this.getScene(), p = i || h.getCaps().instancedArrays && (this.instances.length > 0 || this.hasThinInstances);
        this.computeWorldMatrix();
        var f = this.material || d.defaultMaterial;
        if (f) {
          if (f._storeEffectOnSubMeshes)
            for (var m = 0, g = this.subMeshes; m < g.length; m++) {
              var y = (z = g[m]).getMaterial();
              if (y) {
                if (y._storeEffectOnSubMeshes) {
                  if (!y.isReadyForSubMesh(this, z, p))
                    return !1;
                } else if (!y.isReady(this, p))
                  return !1;
              }
            }
          else if (!f.isReady(this, p))
            return !1;
        }
        for (var b = h.currentRenderPassId, T = 0, S = this.lightSources; T < S.length; T++) {
          var E = S[T].getShadowGenerators();
          if (E)
            for (var A = E.values(), R = A.next(); R.done !== !0; R = A.next()) {
              var C = R.value;
              if (C && (!(!((r = C.getShadowMap()) === null || r === void 0) && r.renderList) || !((o = C.getShadowMap()) === null || o === void 0) && o.renderList && ((s = (a = C.getShadowMap()) === null || a === void 0 ? void 0 : a.renderList) === null || s === void 0 ? void 0 : s.indexOf(this)) !== -1)) {
                for (var L = (l = C.getShadowMap().renderPassIds) !== null && l !== void 0 ? l : [h.currentRenderPassId], I = 0; I < L.length; ++I) {
                  h.currentRenderPassId = L[I];
                  for (var O = 0, w = this.subMeshes; O < w.length; O++) {
                    var z = w[O];
                    if (!C.isReady(z, p, (u = (c = z.getMaterial()) === null || c === void 0 ? void 0 : c.needAlphaBlendingForMesh(this)) !== null && u !== void 0 && u))
                      return h.currentRenderPassId = b, !1;
                  }
                }
                h.currentRenderPassId = b;
              }
            }
        }
        for (var V = 0, Y = this._internalMeshDataInfo._LODLevels; V < Y.length; V++) {
          var ee = Y[V];
          if (ee.mesh && !ee.mesh.isReady(p))
            return !1;
        }
        return !0;
      }, Object.defineProperty(t.prototype, "areNormalsFrozen", { get: function() {
        return this._internalMeshDataInfo._areNormalsFrozen;
      }, enumerable: !1, configurable: !0 }), t.prototype.freezeNormals = function() {
        return this._internalMeshDataInfo._areNormalsFrozen = !0, this;
      }, t.prototype.unfreezeNormals = function() {
        return this._internalMeshDataInfo._areNormalsFrozen = !1, this;
      }, Object.defineProperty(t.prototype, "overridenInstanceCount", { set: function(e) {
        this._instanceDataStorage.overridenInstanceCount = e;
      }, enumerable: !1, configurable: !0 }), t.prototype._preActivate = function() {
        var e = this._internalMeshDataInfo, i = this.getScene().getRenderId();
        return e._preActivateId === i || (e._preActivateId = i, this._instanceDataStorage.visibleInstances = null), this;
      }, t.prototype._preActivateForIntermediateRendering = function(e) {
        return this._instanceDataStorage.visibleInstances && (this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId = e), this;
      }, t.prototype._registerInstanceForRenderId = function(e, i) {
        return this._instanceDataStorage.visibleInstances || (this._instanceDataStorage.visibleInstances = { defaultRenderId: i, selfDefaultRenderId: this._renderId }), this._instanceDataStorage.visibleInstances[i] || (this._instanceDataStorage.previousRenderId !== void 0 && this._instanceDataStorage.isFrozen && (this._instanceDataStorage.visibleInstances[this._instanceDataStorage.previousRenderId] = null), this._instanceDataStorage.previousRenderId = i, this._instanceDataStorage.visibleInstances[i] = new Array()), this._instanceDataStorage.visibleInstances[i].push(e), this;
      }, t.prototype._afterComputeWorldMatrix = function() {
        n.prototype._afterComputeWorldMatrix.call(this), this.hasThinInstances && (this.doNotSyncBoundingInfo || this.thinInstanceRefreshBoundingInfo(!1));
      }, t.prototype._postActivate = function() {
        this.edgesShareWithInstances && this.edgesRenderer && this.edgesRenderer.isEnabled && this._renderingGroup && (this._renderingGroup._edgesRenderers.pushNoDuplicate(this.edgesRenderer), this.edgesRenderer.customInstances.push(this.getWorldMatrix()));
      }, t.prototype.refreshBoundingInfo = function(e, i) {
        if (e === void 0 && (e = !1), i === void 0 && (i = !1), this.hasBoundingInfo && this.getBoundingInfo().isLocked)
          return this;
        var r = this.geometry ? this.geometry.boundingBias : null;
        return this._refreshBoundingInfo(this._getPositionData(e, i), r), this;
      }, t.prototype._createGlobalSubMesh = function(e) {
        var i = this.getTotalVertices();
        if (!i || !this.getIndices())
          return null;
        if (this.subMeshes && this.subMeshes.length > 0) {
          var r = this.getIndices();
          if (!r)
            return null;
          var o = r.length, a = !1;
          if (e)
            a = !0;
          else
            for (var s = 0, l = this.subMeshes; s < l.length; s++) {
              var c = l[s];
              if (c.indexStart + c.indexCount > o) {
                a = !0;
                break;
              }
              if (c.verticesStart + c.verticesCount > i) {
                a = !0;
                break;
              }
            }
          if (!a)
            return this.subMeshes[0];
        }
        return this.releaseSubMeshes(), new Yn(0, 0, i, 0, this.getTotalIndices(), this);
      }, t.prototype.subdivide = function(e) {
        if (!(e < 1)) {
          for (var i = this.getTotalIndices(), r = i / e | 0, o = 0; r % 3 != 0; )
            r++;
          this.releaseSubMeshes();
          for (var a = 0; a < e && !(o >= i); a++)
            Yn.CreateFromIndices(0, o, a === e - 1 ? i - o : r, this, void 0, !1), o += r;
          this.refreshBoundingInfo(), this.synchronizeInstances();
        }
      }, t.prototype.setVerticesData = function(e, i, r, o) {
        if (r === void 0 && (r = !1), this._geometry)
          this._geometry.setVerticesData(e, i, r, o);
        else {
          var a = new Oe();
          a.set(i, e);
          var s = this.getScene();
          new er(er.RandomId(), s, a, r, this);
        }
        return this;
      }, t.prototype.removeVerticesData = function(e) {
        this._geometry && this._geometry.removeVerticesData(e);
      }, t.prototype.markVerticesDataAsUpdatable = function(e, i) {
        i === void 0 && (i = !0);
        var r = this.getVertexBuffer(e);
        r && r.isUpdatable() !== i && this.setVerticesData(e, this.getVerticesData(e), i);
      }, t.prototype.setVerticesBuffer = function(e, i) {
        return i === void 0 && (i = !0), this._geometry || (this._geometry = er.CreateGeometryForMesh(this)), this._geometry.setVerticesBuffer(e, null, i), this;
      }, t.prototype.updateVerticesData = function(e, i, r, o) {
        return this._geometry ? (o ? (this.makeGeometryUnique(), this.updateVerticesData(e, i, r, !1)) : this._geometry.updateVerticesData(e, i, r), this) : this;
      }, t.prototype.updateMeshPositions = function(e, i) {
        i === void 0 && (i = !0);
        var r = this.getVerticesData(P.PositionKind);
        if (!r)
          return this;
        if (e(r), this.updateVerticesData(P.PositionKind, r, !1, !1), i) {
          var o = this.getIndices(), a = this.getVerticesData(P.NormalKind);
          if (!a)
            return this;
          Oe.ComputeNormals(r, o, a), this.updateVerticesData(P.NormalKind, a, !1, !1);
        }
        return this;
      }, t.prototype.makeGeometryUnique = function() {
        if (!this._geometry)
          return this;
        if (this._geometry.meshes.length === 1)
          return this;
        var e = this._geometry, i = this._geometry.copy(er.RandomId());
        return e.releaseForMesh(this, !0), i.applyToMesh(this), this;
      }, t.prototype.setIndexBuffer = function(e, i, r) {
        var o = this._geometry;
        o || (o = new er(er.RandomId(), this.getScene(), void 0, void 0, this)), o.setIndexBuffer(e, i, r);
      }, t.prototype.setIndices = function(e, i, r) {
        if (i === void 0 && (i = null), r === void 0 && (r = !1), this._geometry)
          this._geometry.setIndices(e, i, r);
        else {
          var o = new Oe();
          o.indices = e;
          var a = this.getScene();
          new er(er.RandomId(), a, o, r, this);
        }
        return this;
      }, t.prototype.updateIndices = function(e, i, r) {
        return r === void 0 && (r = !1), this._geometry ? (this._geometry.updateIndices(e, i, r), this) : this;
      }, t.prototype.toLeftHanded = function() {
        return this._geometry ? (this._geometry.toLeftHanded(), this) : this;
      }, t.prototype._bind = function(e, i, r, o) {
        if (o === void 0 && (o = !0), !this._geometry)
          return this;
        var a, s = this.getScene().getEngine();
        if (this.morphTargetManager && this.morphTargetManager.isUsingTextureForTargets && this.morphTargetManager._bind(i), this._unIndexed)
          a = null;
        else
          switch (this._getRenderingFillMode(r)) {
            case Et.PointFillMode:
              a = null;
              break;
            case Et.WireFrameFillMode:
              a = e._getLinesIndexBuffer(this.getIndices(), s);
              break;
            default:
            case Et.TriangleFillMode:
              a = this._geometry.getIndexBuffer();
          }
        return o && this._userInstancedBuffersStorage && !this.hasThinInstances ? this._geometry._bind(i, a, this._userInstancedBuffersStorage.vertexBuffers, this._userInstancedBuffersStorage.vertexArrayObjects) : this._geometry._bind(i, a), this;
      }, t.prototype._draw = function(e, i, r) {
        if (!this._geometry || !this._geometry.getVertexBuffers() || !this._unIndexed && !this._geometry.getIndexBuffer())
          return this;
        this._internalMeshDataInfo._onBeforeDrawObservable && this._internalMeshDataInfo._onBeforeDrawObservable.notifyObservers(this);
        var o = this.getScene().getEngine();
        return this._unIndexed || i == Et.PointFillMode ? o.drawArraysType(i, e.verticesStart, e.verticesCount, this.forcedInstanceCount || r) : i == Et.WireFrameFillMode ? o.drawElementsType(i, 0, e._linesIndexCount, this.forcedInstanceCount || r) : o.drawElementsType(i, e.indexStart, e.indexCount, this.forcedInstanceCount || r), this;
      }, t.prototype.registerBeforeRender = function(e) {
        return this.onBeforeRenderObservable.add(e), this;
      }, t.prototype.unregisterBeforeRender = function(e) {
        return this.onBeforeRenderObservable.removeCallback(e), this;
      }, t.prototype.registerAfterRender = function(e) {
        return this.onAfterRenderObservable.add(e), this;
      }, t.prototype.unregisterAfterRender = function(e) {
        return this.onAfterRenderObservable.removeCallback(e), this;
      }, t.prototype._getInstancesRenderList = function(e, i) {
        if (i === void 0 && (i = !1), this._instanceDataStorage.isFrozen) {
          if (i)
            return this._instanceDataStorage.batchCacheReplacementModeInFrozenMode.hardwareInstancedRendering[e] = !1, this._instanceDataStorage.batchCacheReplacementModeInFrozenMode.renderSelf[e] = !0, this._instanceDataStorage.batchCacheReplacementModeInFrozenMode;
          if (this._instanceDataStorage.previousBatch)
            return this._instanceDataStorage.previousBatch;
        }
        var r = this.getScene(), o = r._isInIntermediateRendering(), a = o ? this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate : this._internalAbstractMeshDataInfo._onlyForInstances, s = this._instanceDataStorage.batchCache;
        if (s.mustReturn = !1, s.renderSelf[e] = i || !a && this.isEnabled() && this.isVisible, s.visibleInstances[e] = null, this._instanceDataStorage.visibleInstances && !i) {
          var l = this._instanceDataStorage.visibleInstances, c = r.getRenderId(), u = o ? l.intermediateDefaultRenderId : l.defaultRenderId;
          s.visibleInstances[e] = l[c], !s.visibleInstances[e] && u && (s.visibleInstances[e] = l[u]);
        }
        return s.hardwareInstancedRendering[e] = !i && this._instanceDataStorage.hardwareInstancedRendering && s.visibleInstances[e] !== null && s.visibleInstances[e] !== void 0, this._instanceDataStorage.previousBatch = s, s;
      }, t.prototype._renderWithInstances = function(e, i, r, o, a) {
        for (var s, l = r.visibleInstances[e._id], c = l ? l.length : 0, u = this._instanceDataStorage, h = u.instancesBufferSize, d = u.instancesBuffer, p = u.instancesPreviousBuffer, f = 16 * (c + 1) * 4; u.instancesBufferSize < f; )
          u.instancesBufferSize *= 2;
        u.instancesData && h == u.instancesBufferSize || (u.instancesData = new Float32Array(u.instancesBufferSize / 4)), (this._scene.needsPreviousWorldMatrices && !u.instancesPreviousData || h != u.instancesBufferSize) && (u.instancesPreviousData = new Float32Array(u.instancesBufferSize / 4));
        var m = 0, g = 0, y = r.renderSelf[e._id], b = !d || h !== u.instancesBufferSize || this._scene.needsPreviousWorldMatrices && !u.instancesPreviousBuffer;
        if (this._instanceDataStorage.manualUpdate || u.isFrozen && !b)
          g = (y ? 1 : 0) + c;
        else {
          var T = this.getWorldMatrix();
          if (y && (this._scene.needsPreviousWorldMatrices && (u.masterMeshPreviousWorldMatrix ? (u.masterMeshPreviousWorldMatrix.copyToArray(u.instancesPreviousData, m), u.masterMeshPreviousWorldMatrix.copyFrom(T)) : (u.masterMeshPreviousWorldMatrix = T.clone(), u.masterMeshPreviousWorldMatrix.copyToArray(u.instancesPreviousData, m))), T.copyToArray(u.instancesData, m), m += 16, g++), l) {
            if (t.INSTANCEDMESH_SORT_TRANSPARENT && this._scene.activeCamera && (!((s = e.getMaterial()) === null || s === void 0) && s.needAlphaBlendingForMesh(e.getRenderingMesh()))) {
              for (var S = this._scene.activeCamera.globalPosition, E = 0; E < l.length; E++) {
                var A = l[E];
                A._distanceToCamera = v.Distance(A.getBoundingInfo().boundingSphere.centerWorld, S);
              }
              l.sort(function(L, I) {
                return L._distanceToCamera > I._distanceToCamera ? -1 : L._distanceToCamera < I._distanceToCamera ? 1 : 0;
              });
            }
            for (E = 0; E < l.length; E++) {
              var R = l[E], C = R.getWorldMatrix();
              C.copyToArray(u.instancesData, m), this._scene.needsPreviousWorldMatrices && (R._previousWorldMatrix ? (R._previousWorldMatrix.copyToArray(u.instancesPreviousData, m), R._previousWorldMatrix.copyFrom(C)) : (R._previousWorldMatrix = C.clone(), R._previousWorldMatrix.copyToArray(u.instancesPreviousData, m))), m += 16, g++;
            }
          }
        }
        return b ? (d && d.dispose(), p && p.dispose(), d = new Yi(a, u.instancesData, !0, 16, !1, !0), u.instancesBuffer = d, this._userInstancedBuffersStorage || (this._userInstancedBuffersStorage = { data: {}, vertexBuffers: {}, strides: {}, sizes: {}, vertexArrayObjects: this.getEngine().getCaps().vertexArrayObject ? {} : void 0 }), this._userInstancedBuffersStorage.vertexBuffers.world0 = d.createVertexBuffer("world0", 0, 4), this._userInstancedBuffersStorage.vertexBuffers.world1 = d.createVertexBuffer("world1", 4, 4), this._userInstancedBuffersStorage.vertexBuffers.world2 = d.createVertexBuffer("world2", 8, 4), this._userInstancedBuffersStorage.vertexBuffers.world3 = d.createVertexBuffer("world3", 12, 4), this._scene.needsPreviousWorldMatrices && (p = new Yi(a, u.instancesPreviousData, !0, 16, !1, !0), u.instancesPreviousBuffer = p, this._userInstancedBuffersStorage.vertexBuffers.previousWorld0 = p.createVertexBuffer("previousWorld0", 0, 4), this._userInstancedBuffersStorage.vertexBuffers.previousWorld1 = p.createVertexBuffer("previousWorld1", 4, 4), this._userInstancedBuffersStorage.vertexBuffers.previousWorld2 = p.createVertexBuffer("previousWorld2", 8, 4), this._userInstancedBuffersStorage.vertexBuffers.previousWorld3 = p.createVertexBuffer("previousWorld3", 12, 4)), this._invalidateInstanceVertexArrayObject()) : this._instanceDataStorage.isFrozen && !this._instanceDataStorage.forceMatrixUpdates || (d.updateDirectly(u.instancesData, 0, g), !this._scene.needsPreviousWorldMatrices || this._instanceDataStorage.manualUpdate && !this._instanceDataStorage.previousManualUpdate || p.updateDirectly(u.instancesPreviousData, 0, g)), this._processInstancedBuffers(l, y), this.getScene()._activeIndices.addCount(e.indexCount * g, !1), a._currentDrawContext && (a._currentDrawContext.useInstancing = !0), this._bind(e, o, i), this._draw(e, i, g), !this._scene.needsPreviousWorldMatrices || b || !this._instanceDataStorage.manualUpdate || this._instanceDataStorage.isFrozen && !this._instanceDataStorage.forceMatrixUpdates || this._instanceDataStorage.previousManualUpdate || p.updateDirectly(u.instancesData, 0, g), a.unbindInstanceAttributes(), this;
      }, t.prototype._renderWithThinInstances = function(e, i, r, o) {
        var a, s, l = (s = (a = this._thinInstanceDataStorage) === null || a === void 0 ? void 0 : a.instancesCount) !== null && s !== void 0 ? s : 0;
        this.getScene()._activeIndices.addCount(e.indexCount * l, !1), o._currentDrawContext && (o._currentDrawContext.useInstancing = !0), this._bind(e, r, i), this._draw(e, i, l), this._scene.needsPreviousWorldMatrices && !this._thinInstanceDataStorage.previousMatrixData && this._thinInstanceDataStorage.matrixData && (this._thinInstanceDataStorage.previousMatrixBuffer ? this._thinInstanceDataStorage.previousMatrixBuffer.updateDirectly(this._thinInstanceDataStorage.matrixData, 0, l) : this._thinInstanceDataStorage.previousMatrixBuffer = this._thinInstanceCreateMatrixBuffer("previousWorld", this._thinInstanceDataStorage.matrixData, !1)), o.unbindInstanceAttributes();
      }, t.prototype._processInstancedBuffers = function(e, i) {
      }, t.prototype._processRendering = function(e, i, r, o, a, s, l, c) {
        var u = this.getScene(), h = u.getEngine();
        if (o = this._getRenderingFillMode(o), s && i.getRenderingMesh().hasThinInstances)
          return this._renderWithThinInstances(i, o, r, h), this;
        if (s)
          this._renderWithInstances(i, o, a, r, h);
        else {
          h._currentDrawContext && (h._currentDrawContext.useInstancing = !1);
          var d = 0;
          a.renderSelf[i._id] && (l && l(!1, e.getWorldMatrix(), c), d++, this._draw(i, o, this._instanceDataStorage.overridenInstanceCount));
          var p = a.visibleInstances[i._id];
          if (p) {
            var f = p.length;
            d += f;
            for (var m = 0; m < f; m++) {
              var g = p[m].getWorldMatrix();
              l && l(!0, g, c), this._draw(i, o);
            }
          }
          u._activeIndices.addCount(i.indexCount * d, !1);
        }
        return this;
      }, t.prototype._rebuild = function(e) {
        if (e === void 0 && (e = !1), this._instanceDataStorage.instancesBuffer && (e && this._instanceDataStorage.instancesBuffer.dispose(), this._instanceDataStorage.instancesBuffer = null), this._userInstancedBuffersStorage) {
          for (var i in this._userInstancedBuffersStorage.vertexBuffers) {
            var r = this._userInstancedBuffersStorage.vertexBuffers[i];
            r && (e && r.dispose(), this._userInstancedBuffersStorage.vertexBuffers[i] = null);
          }
          this._userInstancedBuffersStorage.vertexArrayObjects && (this._userInstancedBuffersStorage.vertexArrayObjects = {});
        }
        this._internalMeshDataInfo._effectiveMaterial = null, n.prototype._rebuild.call(this, e);
      }, t.prototype._freeze = function() {
        if (this.subMeshes) {
          for (var e = 0; e < this.subMeshes.length; e++)
            this._getInstancesRenderList(e);
          this._internalMeshDataInfo._effectiveMaterial = null, this._instanceDataStorage.isFrozen = !0;
        }
      }, t.prototype._unFreeze = function() {
        this._instanceDataStorage.isFrozen = !1, this._instanceDataStorage.previousBatch = null;
      }, t.prototype.renderWithRenderPassId = function(e, i, r, o, a) {
        a === void 0 && (a = !0);
        var s = this._scene.getEngine(), l = s.currentRenderPassId;
        if (e !== void 0 && (s.currentRenderPassId = e), o)
          (!a || a && o.isInFrustum(this._scene._frustumPlanes)) && this.render(o, !!i, r);
        else
          for (var c = 0; c < this.subMeshes.length; c++) {
            var u = this.subMeshes[c];
            (!a || a && u.isInFrustum(this._scene._frustumPlanes)) && this.render(u, !!i, r);
          }
        return e !== void 0 && (s.currentRenderPassId = l), this;
      }, t.prototype.render = function(e, i, r) {
        var o, a, s, l, c, u = this.getScene();
        this._internalAbstractMeshDataInfo._isActiveIntermediate ? this._internalAbstractMeshDataInfo._isActiveIntermediate = !1 : this._internalAbstractMeshDataInfo._isActive = !1;
        var h = (a = (o = u.activeCameras) === null || o === void 0 ? void 0 : o.length) !== null && a !== void 0 ? a : 0;
        if ((h > 1 && u.activeCamera === u.activeCameras[0] || h <= 1) && this._checkOcclusionQuery() && !this._occlusionDataStorage.forceRenderingWhenOccluded)
          return this;
        var d = this._getInstancesRenderList(e._id, !!r);
        if (d.mustReturn)
          return this;
        if (!this._geometry || !this._geometry.getVertexBuffers() || !this._unIndexed && !this._geometry.getIndexBuffer())
          return this;
        var p = u.getEngine(), f = 0, m = null;
        this.ignoreCameraMaxZ && u.activeCamera && !u._isInIntermediateRendering() && (f = u.activeCamera.maxZ, m = u.activeCamera, u.activeCamera.maxZ = 0, u.updateTransformMatrix(!0)), this._internalMeshDataInfo._onBeforeRenderObservable && this._internalMeshDataInfo._onBeforeRenderObservable.notifyObservers(this);
        var g, y = e.getRenderingMesh(), b = d.hardwareInstancedRendering[e._id] || y.hasThinInstances || !!this._userInstancedBuffersStorage && !e.getMesh()._internalAbstractMeshDataInfo._actAsRegularMesh, T = this._instanceDataStorage, S = e.getMaterial();
        if (!S)
          return m && (m.maxZ = f, u.updateTransformMatrix(!0)), this;
        if (T.isFrozen && this._internalMeshDataInfo._effectiveMaterial && this._internalMeshDataInfo._effectiveMaterial === S) {
          if (S._storeEffectOnSubMeshes && !(!((s = e.effect) === null || s === void 0) && s._wasPreviouslyReady) || !S._storeEffectOnSubMeshes && !(!((l = S.getEffect()) === null || l === void 0) && l._wasPreviouslyReady))
            return m && (m.maxZ = f, u.updateTransformMatrix(!0)), this;
        } else {
          if (S._storeEffectOnSubMeshes) {
            if (!S.isReadyForSubMesh(this, e, b))
              return m && (m.maxZ = f, u.updateTransformMatrix(!0)), this;
          } else if (!S.isReady(this, b))
            return m && (m.maxZ = f, u.updateTransformMatrix(!0)), this;
          this._internalMeshDataInfo._effectiveMaterial = S;
        }
        i && p.setAlphaMode(this._internalMeshDataInfo._effectiveMaterial.alphaMode);
        for (var E = (c = (g = this._internalMeshDataInfo._effectiveMaterial._storeEffectOnSubMeshes ? e._drawWrapper : this._internalMeshDataInfo._effectiveMaterial._getDrawWrapper()) == null ? void 0 : g.effect) !== null && c !== void 0 ? c : null, A = 0, R = u._beforeRenderingMeshStage; A < R.length; A++)
          R[A].action(this, e, d, E);
        if (!g || !E)
          return m && (m.maxZ = f, u.updateTransformMatrix(!0)), this;
        var C, L = r || this;
        if (T.isFrozen || !this._internalMeshDataInfo._effectiveMaterial.backFaceCulling && this.overrideMaterialSideOrientation === null && !this._internalMeshDataInfo._effectiveMaterial.twoSidedLighting)
          C = T.sideOrientation;
        else {
          var I = L._getWorldMatrixDeterminant();
          (C = this.overrideMaterialSideOrientation) == null && (C = this._internalMeshDataInfo._effectiveMaterial.sideOrientation), I < 0 && (C = C === Et.ClockWiseSideOrientation ? Et.CounterClockWiseSideOrientation : Et.ClockWiseSideOrientation), T.sideOrientation = C;
        }
        var O = this._internalMeshDataInfo._effectiveMaterial._preBind(g, C);
        this._internalMeshDataInfo._effectiveMaterial.forceDepthWrite && p.setDepthWrite(!0);
        var w = this._internalMeshDataInfo._effectiveMaterial, z = w.fillMode;
        this._internalMeshDataInfo._onBeforeBindObservable && this._internalMeshDataInfo._onBeforeBindObservable.notifyObservers(this), b || this._bind(e, E, z, !1);
        var V = L.getWorldMatrix();
        w._storeEffectOnSubMeshes ? w.bindForSubMesh(V, this, e) : w.bind(V, this), !w.backFaceCulling && w.separateCullingPass && (p.setState(!0, w.zOffset, !1, !O, w.cullBackFaces, w.stencil, w.zOffsetUnits), this._processRendering(this, e, E, z, d, b, this._onBeforeDraw, this._internalMeshDataInfo._effectiveMaterial), p.setState(!0, w.zOffset, !1, O, w.cullBackFaces, w.stencil, w.zOffsetUnits), this._internalMeshDataInfo._onBetweenPassObservable && this._internalMeshDataInfo._onBetweenPassObservable.notifyObservers(e)), this._processRendering(this, e, E, z, d, b, this._onBeforeDraw, this._internalMeshDataInfo._effectiveMaterial), this._internalMeshDataInfo._effectiveMaterial.unbind();
        for (var Y = 0, ee = u._afterRenderingMeshStage; Y < ee.length; Y++)
          ee[Y].action(this, e, d, E);
        return this._internalMeshDataInfo._onAfterRenderObservable && this._internalMeshDataInfo._onAfterRenderObservable.notifyObservers(this), m && (m.maxZ = f, u.updateTransformMatrix(!0)), u.performancePriority !== Zr.Aggressive || T.isFrozen || this._freeze(), this;
      }, t.prototype.cleanMatrixWeights = function() {
        this.isVerticesDataPresent(P.MatricesWeightsKind) && (this.isVerticesDataPresent(P.MatricesWeightsExtraKind) ? this._normalizeSkinWeightsAndExtra() : this._normalizeSkinFourWeights());
      }, t.prototype._normalizeSkinFourWeights = function() {
        for (var e = this.getVerticesData(P.MatricesWeightsKind), i = e.length, r = 0; r < i; r += 4) {
          var o = e[r] + e[r + 1] + e[r + 2] + e[r + 3];
          if (o === 0)
            e[r] = 1;
          else {
            var a = 1 / o;
            e[r] *= a, e[r + 1] *= a, e[r + 2] *= a, e[r + 3] *= a;
          }
        }
        this.setVerticesData(P.MatricesWeightsKind, e);
      }, t.prototype._normalizeSkinWeightsAndExtra = function() {
        for (var e = this.getVerticesData(P.MatricesWeightsExtraKind), i = this.getVerticesData(P.MatricesWeightsKind), r = i.length, o = 0; o < r; o += 4) {
          var a = i[o] + i[o + 1] + i[o + 2] + i[o + 3];
          if ((a += e[o] + e[o + 1] + e[o + 2] + e[o + 3]) === 0)
            i[o] = 1;
          else {
            var s = 1 / a;
            i[o] *= s, i[o + 1] *= s, i[o + 2] *= s, i[o + 3] *= s, e[o] *= s, e[o + 1] *= s, e[o + 2] *= s, e[o + 3] *= s;
          }
        }
        this.setVerticesData(P.MatricesWeightsKind, i), this.setVerticesData(P.MatricesWeightsKind, e);
      }, t.prototype.validateSkinning = function() {
        var e = this.getVerticesData(P.MatricesWeightsExtraKind), i = this.getVerticesData(P.MatricesWeightsKind);
        if (i === null || this.skeleton == null)
          return { skinned: !1, valid: !0, report: "not skinned" };
        for (var r = i.length, o = 0, a = 0, s = 0, l = 0, c = e === null ? 4 : 8, u = [], h = 0; h <= c; h++)
          u[h] = 0;
        for (h = 0; h < r; h += 4) {
          for (var d = i[h], p = d, f = p === 0 ? 0 : 1, m = 1; m < c; m++) {
            var g = m < 4 ? i[h + m] : e[h + m - 4];
            g > d && o++, g !== 0 && f++, p += g, d = g;
          }
          if (u[f]++, f > s && (s = f), p === 0)
            a++;
          else {
            var y = 1 / p, b = 0;
            for (m = 0; m < c; m++)
              b += m < 4 ? Math.abs(i[h + m] - i[h + m] * y) : Math.abs(e[h + m - 4] - e[h + m - 4] * y);
            b > 1e-3 && l++;
          }
        }
        var T = this.skeleton.bones.length, S = this.getVerticesData(P.MatricesIndicesKind), E = this.getVerticesData(P.MatricesIndicesExtraKind), A = 0;
        for (h = 0; h < r; h += 4)
          for (m = 0; m < c; m++) {
            var R = m < 4 ? S[h + m] : E[h + m - 4];
            (R >= T || R < 0) && A++;
          }
        return { skinned: !0, valid: a === 0 && l === 0 && A === 0, report: "Number of Weights = " + r / 4 + `
Maximum influences = ` + s + `
Missing Weights = ` + a + `
Not Sorted = ` + o + `
Not Normalized = ` + l + `
WeightCounts = [` + u + `]
Number of bones = ` + T + `
Bad Bone Indices = ` + A };
      }, t.prototype._checkDelayState = function() {
        var e = this.getScene();
        return this._geometry ? this._geometry.load(e) : this.delayLoadState === _.DELAYLOADSTATE_NOTLOADED && (this.delayLoadState = _.DELAYLOADSTATE_LOADING, this._queueLoad(e)), this;
      }, t.prototype._queueLoad = function(e) {
        var i = this;
        e.addPendingData(this);
        var r = this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1;
        return de.LoadFile(this.delayLoadingFile, function(o) {
          o instanceof ArrayBuffer ? i._delayLoadingFunction(o, i) : i._delayLoadingFunction(JSON.parse(o), i), i.instances.forEach(function(a) {
            a.refreshBoundingInfo(), a._syncSubMeshes();
          }), i.delayLoadState = _.DELAYLOADSTATE_LOADED, e.removePendingData(i);
        }, function() {
        }, e.offlineProvider, r), this;
      }, t.prototype.isInFrustum = function(e) {
        return this.delayLoadState !== _.DELAYLOADSTATE_LOADING && !!n.prototype.isInFrustum.call(this, e) && (this._checkDelayState(), !0);
      }, t.prototype.setMaterialById = function(e) {
        var i, r = this.getScene().materials;
        for (i = r.length - 1; i > -1; i--)
          if (r[i].id === e)
            return this.material = r[i], this;
        var o = this.getScene().multiMaterials;
        for (i = o.length - 1; i > -1; i--)
          if (o[i].id === e)
            return this.material = o[i], this;
        return this;
      }, t.prototype.getAnimatables = function() {
        var e = [];
        return this.material && e.push(this.material), this.skeleton && e.push(this.skeleton), e;
      }, t.prototype.bakeTransformIntoVertices = function(e) {
        if (!this.isVerticesDataPresent(P.PositionKind))
          return this;
        var i = this.subMeshes.splice(0);
        this._resetPointsArrayCache();
        var r, o = this.getVerticesData(P.PositionKind), a = v.Zero();
        for (r = 0; r < o.length; r += 3)
          v.TransformCoordinatesFromFloatsToRef(o[r], o[r + 1], o[r + 2], e, a).toArray(o, r);
        if (this.setVerticesData(P.PositionKind, o, this.getVertexBuffer(P.PositionKind).isUpdatable()), this.isVerticesDataPresent(P.NormalKind)) {
          for (o = this.getVerticesData(P.NormalKind), r = 0; r < o.length; r += 3)
            v.TransformNormalFromFloatsToRef(o[r], o[r + 1], o[r + 2], e, a).normalize().toArray(o, r);
          this.setVerticesData(P.NormalKind, o, this.getVertexBuffer(P.NormalKind).isUpdatable());
        }
        return e.determinant() < 0 && this.flipFaces(), this.releaseSubMeshes(), this.subMeshes = i, this;
      }, t.prototype.bakeCurrentTransformIntoVertices = function(e) {
        return e === void 0 && (e = !0), this.bakeTransformIntoVertices(this.computeWorldMatrix(!0)), this.resetLocalMatrix(e), this;
      }, Object.defineProperty(t.prototype, "_positions", { get: function() {
        return this._internalAbstractMeshDataInfo._positions ? this._internalAbstractMeshDataInfo._positions : this._geometry ? this._geometry._positions : null;
      }, enumerable: !1, configurable: !0 }), t.prototype._resetPointsArrayCache = function() {
        return this._geometry && this._geometry._resetPointsArrayCache(), this;
      }, t.prototype._generatePointsArray = function() {
        return !!this._geometry && this._geometry._generatePointsArray();
      }, t.prototype.clone = function(e, i, r, o) {
        return e === void 0 && (e = ""), i === void 0 && (i = null), o === void 0 && (o = !0), new t(e, this.getScene(), i, this, r, o);
      }, t.prototype.dispose = function(e, i) {
        i === void 0 && (i = !1), this.morphTargetManager = null, this._geometry && this._geometry.releaseForMesh(this, !0);
        var r = this._internalMeshDataInfo;
        if (r._onBeforeDrawObservable && r._onBeforeDrawObservable.clear(), r._onBeforeBindObservable && r._onBeforeBindObservable.clear(), r._onBeforeRenderObservable && r._onBeforeRenderObservable.clear(), r._onAfterRenderObservable && r._onAfterRenderObservable.clear(), r._onBetweenPassObservable && r._onBetweenPassObservable.clear(), this._scene.useClonedMeshMap) {
          if (r.meshMap)
            for (var o in r.meshMap)
              (l = r.meshMap[o]) && (l._internalMeshDataInfo._source = null, r.meshMap[o] = void 0);
          r._source && r._source._internalMeshDataInfo.meshMap && (r._source._internalMeshDataInfo.meshMap[this.uniqueId] = void 0);
        } else
          for (var a = 0, s = this.getScene().meshes; a < s.length; a++) {
            var l;
            (l = s[a])._internalMeshDataInfo && l._internalMeshDataInfo._source && l._internalMeshDataInfo._source === this && (l._internalMeshDataInfo._source = null);
          }
        r._source = null, this._instanceDataStorage.visibleInstances = {}, this._disposeInstanceSpecificData(), this._disposeThinInstanceSpecificData(), this._internalMeshDataInfo._checkReadinessObserver && this._scene.onBeforeRenderObservable.remove(this._internalMeshDataInfo._checkReadinessObserver), n.prototype.dispose.call(this, e, i);
      }, t.prototype._disposeInstanceSpecificData = function() {
      }, t.prototype._disposeThinInstanceSpecificData = function() {
      }, t.prototype._invalidateInstanceVertexArrayObject = function() {
      }, t.prototype.applyDisplacementMap = function(e, i, r, o, a, s, l) {
        var c = this;
        l === void 0 && (l = !1);
        var u = this.getScene();
        return de.LoadImage(e, function(h) {
          var d = h.width, p = h.height, f = c.getEngine().createCanvas(d, p).getContext("2d");
          f.drawImage(h, 0, 0);
          var m = f.getImageData(0, 0, d, p).data;
          c.applyDisplacementMapFromBuffer(m, d, p, i, r, a, s, l), o && o(c);
        }, function() {
        }, u.offlineProvider), this;
      }, t.prototype.applyDisplacementMapFromBuffer = function(e, i, r, o, a, s, l, c) {
        if (c === void 0 && (c = !1), !this.isVerticesDataPresent(P.PositionKind) || !this.isVerticesDataPresent(P.NormalKind) || !this.isVerticesDataPresent(P.UVKind))
          return q.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing"), this;
        var u = this.getVerticesData(P.PositionKind, !0, !0), h = this.getVerticesData(P.NormalKind), d = this.getVerticesData(P.UVKind), p = v.Zero(), f = v.Zero(), m = fe.Zero();
        s = s || fe.Zero(), l = l || new fe(1, 1);
        for (var g = 0; g < u.length; g += 3) {
          v.FromArrayToRef(u, g, p), v.FromArrayToRef(h, g, f), fe.FromArrayToRef(d, g / 3 * 2, m);
          var y = 4 * ((Math.abs(m.x * l.x + s.x % 1) * (i - 1) % i | 0) + (Math.abs(m.y * l.y + s.y % 1) * (r - 1) % r | 0) * i), b = e[y] / 255 * 0.3 + e[y + 1] / 255 * 0.59 + e[y + 2] / 255 * 0.11;
          f.normalize(), f.scaleInPlace(o + (a - o) * b), (p = p.add(f)).toArray(u, g);
        }
        return Oe.ComputeNormals(u, this.getIndices(), h), c ? (this.setVerticesData(P.PositionKind, u), this.setVerticesData(P.NormalKind, h), this.setVerticesData(P.UVKind, d)) : (this.updateVerticesData(P.PositionKind, u), this.updateVerticesData(P.NormalKind, h)), this;
      }, t.prototype._getFlattenedNormals = function(e, i) {
        for (var r = new Float32Array(3 * e.length), o = 0, a = this.overrideMaterialSideOrientation === (this._scene.useRightHandedSystem ? _.MATERIAL_CounterClockWiseSideOrientation : _.MATERIAL_ClockWiseSideOrientation), s = 0; s < e.length; s += 3) {
          var l = v.FromArray(i, 3 * e[s]), c = v.FromArray(i, 3 * e[s + 1]), u = v.FromArray(i, 3 * e[s + 2]), h = l.subtract(c), d = u.subtract(c), p = v.Normalize(v.Cross(h, d));
          a && p.scaleInPlace(-1);
          for (var f = 0; f < 3; f++)
            r[o++] = p.x, r[o++] = p.y, r[o++] = p.z;
        }
        return r;
      }, t.prototype._convertToUnIndexedMesh = function(e) {
        e === void 0 && (e = !1);
        for (var i = this.getVerticesDataKinds(), r = this.getIndices(), o = {}, a = function(L, I) {
          for (var O = new Float32Array(r.length * I), w = 0, z = 0; z < r.length; z++)
            for (var V = 0; V < I; V++)
              O[w++] = L[r[z] * I + V];
          return O;
        }, s = this.geometry ? this.subMeshes.slice(0) : [], l = 0, c = i; l < c.length; l++)
          o[d = c[l]] = this.getVerticesData(d);
        for (var u = 0, h = i; u < h.length; u++) {
          var d = h[u], p = this.getVertexBuffer(d), f = p.getStrideSize();
          if (e && d === P.NormalKind) {
            var m = this._getFlattenedNormals(r, o[P.PositionKind]);
            this.setVerticesData(P.NormalKind, m, p.isUpdatable(), f);
          } else
            this.setVerticesData(d, a(o[d], f), p.isUpdatable(), f);
        }
        if (this.morphTargetManager) {
          for (var g = 0; g < this.morphTargetManager.numTargets; g++) {
            var y = this.morphTargetManager.getTarget(g), b = y.getPositions();
            y.setPositions(a(b, 3)), (m = y.getNormals()) && y.setNormals(e ? this._getFlattenedNormals(r, b) : a(m, 3));
            var T = y.getTangents();
            T && y.setTangents(a(T, 3));
            var S = y.getUVs();
            S && y.setUVs(a(S, 2));
          }
          this.morphTargetManager.synchronize();
        }
        for (var E = 0; E < r.length; E++)
          r[E] = E;
        this.setIndices(r), this._unIndexed = !0, this.releaseSubMeshes();
        for (var A = 0, R = s; A < R.length; A++) {
          var C = R[A];
          Yn.AddToMesh(C.materialIndex, C.indexStart, C.indexCount, C.indexStart, C.indexCount, this);
        }
        return this.synchronizeInstances(), this;
      }, t.prototype.convertToFlatShadedMesh = function() {
        return this._convertToUnIndexedMesh(!0);
      }, t.prototype.convertToUnIndexedMesh = function() {
        return this._convertToUnIndexedMesh();
      }, t.prototype.flipFaces = function(e) {
        e === void 0 && (e = !1);
        var i, r = Oe.ExtractFromMesh(this);
        if (e && this.isVerticesDataPresent(P.NormalKind) && r.normals)
          for (i = 0; i < r.normals.length; i++)
            r.normals[i] *= -1;
        if (r.indices) {
          var o = void 0;
          for (i = 0; i < r.indices.length; i += 3)
            o = r.indices[i + 1], r.indices[i + 1] = r.indices[i + 2], r.indices[i + 2] = o;
        }
        return r.applyToMesh(this, this.isVertexBufferUpdatable(P.PositionKind)), this;
      }, t.prototype.increaseVertices = function(e) {
        e === void 0 && (e = 1);
        var i = Oe.ExtractFromMesh(this), r = i.indices && !Array.isArray(i.indices) && Array.from ? Array.from(i.indices) : i.indices, o = i.positions && !Array.isArray(i.positions) && Array.from ? Array.from(i.positions) : i.positions, a = i.uvs && !Array.isArray(i.uvs) && Array.from ? Array.from(i.uvs) : i.uvs, s = i.normals && !Array.isArray(i.normals) && Array.from ? Array.from(i.normals) : i.normals;
        if (r && o) {
          i.indices = r, i.positions = o, a && (i.uvs = a), s && (i.normals = s);
          for (var l = e + 1, c = new Array(), u = 0; u < l + 1; u++)
            c[u] = new Array();
          var h = void 0, d = void 0, p = new v(0, 0, 0), f = new v(0, 0, 0), m = new fe(0, 0), g = new Array(), y = new Array(), b = new Array(), T = void 0, S = o.length, E = void 0;
          a && (E = a.length);
          var A = void 0;
          for (s && (A = s.length), u = 0; u < r.length; u += 3) {
            y[0] = r[u], y[1] = r[u + 1], y[2] = r[u + 2];
            for (var R = 0; R < 3; R++)
              if (h = y[R], d = y[(R + 1) % 3], b[h] === void 0 && b[d] === void 0 ? (b[h] = new Array(), b[d] = new Array()) : (b[h] === void 0 && (b[h] = new Array()), b[d] === void 0 && (b[d] = new Array())), b[h][d] === void 0 && b[d][h] === void 0) {
                b[h][d] = [], p.x = (o[3 * d] - o[3 * h]) / l, p.y = (o[3 * d + 1] - o[3 * h + 1]) / l, p.z = (o[3 * d + 2] - o[3 * h + 2]) / l, s && (f.x = (s[3 * d] - s[3 * h]) / l, f.y = (s[3 * d + 1] - s[3 * h + 1]) / l, f.z = (s[3 * d + 2] - s[3 * h + 2]) / l), a && (m.x = (a[2 * d] - a[2 * h]) / l, m.y = (a[2 * d + 1] - a[2 * h + 1]) / l), b[h][d].push(h);
                for (var C = 1; C < l; C++)
                  b[h][d].push(o.length / 3), o[S++] = o[3 * h] + C * p.x, o[S++] = o[3 * h + 1] + C * p.y, o[S++] = o[3 * h + 2] + C * p.z, s && (s[A++] = s[3 * h] + C * f.x, s[A++] = s[3 * h + 1] + C * f.y, s[A++] = s[3 * h + 2] + C * f.z), a && (a[E++] = a[2 * h] + C * m.x, a[E++] = a[2 * h + 1] + C * m.y);
                b[h][d].push(d), b[d][h] = new Array(), T = b[h][d].length;
                for (var L = 0; L < T; L++)
                  b[d][h][L] = b[h][d][T - 1 - L];
              }
            for (c[0][0] = r[u], c[1][0] = b[r[u]][r[u + 1]][1], c[1][1] = b[r[u]][r[u + 2]][1], C = 2; C < l; C++)
              for (c[C][0] = b[r[u]][r[u + 1]][C], c[C][C] = b[r[u]][r[u + 2]][C], p.x = (o[3 * c[C][C]] - o[3 * c[C][0]]) / C, p.y = (o[3 * c[C][C] + 1] - o[3 * c[C][0] + 1]) / C, p.z = (o[3 * c[C][C] + 2] - o[3 * c[C][0] + 2]) / C, s && (f.x = (s[3 * c[C][C]] - s[3 * c[C][0]]) / C, f.y = (s[3 * c[C][C] + 1] - s[3 * c[C][0] + 1]) / C, f.z = (s[3 * c[C][C] + 2] - s[3 * c[C][0] + 2]) / C), a && (m.x = (a[2 * c[C][C]] - a[2 * c[C][0]]) / C, m.y = (a[2 * c[C][C] + 1] - a[2 * c[C][0] + 1]) / C), R = 1; R < C; R++)
                c[C][R] = o.length / 3, o[S++] = o[3 * c[C][0]] + R * p.x, o[S++] = o[3 * c[C][0] + 1] + R * p.y, o[S++] = o[3 * c[C][0] + 2] + R * p.z, s && (s[A++] = s[3 * c[C][0]] + R * f.x, s[A++] = s[3 * c[C][0] + 1] + R * f.y, s[A++] = s[3 * c[C][0] + 2] + R * f.z), a && (a[E++] = a[2 * c[C][0]] + R * m.x, a[E++] = a[2 * c[C][0] + 1] + R * m.y);
            for (c[l] = b[r[u + 1]][r[u + 2]], g.push(c[0][0], c[1][0], c[1][1]), C = 1; C < l; C++) {
              for (R = void 0, R = 0; R < C; R++)
                g.push(c[C][R], c[C + 1][R], c[C + 1][R + 1]), g.push(c[C][R], c[C + 1][R + 1], c[C][R + 1]);
              g.push(c[C][R], c[C + 1][R], c[C + 1][R + 1]);
            }
          }
          i.indices = g, i.applyToMesh(this, this.isVertexBufferUpdatable(P.PositionKind));
        } else
          q.Warn("Couldn't increase number of vertices : VertexData must contain at least indices and positions");
      }, t.prototype.forceSharedVertices = function() {
        var e = Oe.ExtractFromMesh(this), i = e.uvs, r = e.indices, o = e.positions, a = e.colors, s = e.matricesIndices, l = e.matricesWeights, c = e.matricesIndicesExtra, u = e.matricesWeightsExtra;
        if (r === void 0 || o === void 0 || r === null || o === null)
          q.Warn("VertexData contains empty entries");
        else {
          for (var h = new Array(), d = new Array(), p = new Array(), f = new Array(), m = new Array(), g = new Array(), y = new Array(), b = new Array(), T = new Array(), S = 0, E = {}, A = void 0, R = void 0, C = 0; C < r.length; C += 3) {
            R = [r[C], r[C + 1], r[C + 2]], T = [];
            for (var L = 0; L < 3; L++) {
              T[L] = "";
              for (var I = 0; I < 3; I++)
                Math.abs(o[3 * R[L] + I]) < 1e-8 && (o[3 * R[L] + I] = 0), T[L] += o[3 * R[L] + I] + "|";
            }
            if (T[0] != T[1] && T[0] != T[2] && T[1] != T[2])
              for (L = 0; L < 3; L++) {
                if ((A = E[T[L]]) === void 0) {
                  for (E[T[L]] = S, A = S++, I = 0; I < 3; I++)
                    h.push(o[3 * R[L] + I]);
                  if (a != null)
                    for (I = 0; I < 4; I++)
                      f.push(a[4 * R[L] + I]);
                  if (i != null)
                    for (I = 0; I < 2; I++)
                      p.push(i[2 * R[L] + I]);
                  if (s != null)
                    for (I = 0; I < 4; I++)
                      m.push(s[4 * R[L] + I]);
                  if (l != null)
                    for (I = 0; I < 4; I++)
                      g.push(l[4 * R[L] + I]);
                  if (c != null)
                    for (I = 0; I < 4; I++)
                      y.push(c[4 * R[L] + I]);
                  if (u != null)
                    for (I = 0; I < 4; I++)
                      b.push(u[4 * R[L] + I]);
                }
                d.push(A);
              }
          }
          var O = new Array();
          Oe.ComputeNormals(h, d, O), e.positions = h, e.indices = d, e.normals = O, i != null && (e.uvs = p), a != null && (e.colors = f), s != null && (e.matricesIndices = m), l != null && (e.matricesWeights = g), c != null && (e.matricesIndicesExtra = y), l != null && (e.matricesWeightsExtra = b), e.applyToMesh(this, this.isVertexBufferUpdatable(P.PositionKind));
        }
      }, t._instancedMeshFactory = function(e, i) {
        throw et("InstancedMesh");
      }, t._PhysicsImpostorParser = function(e, i, r) {
        throw et("PhysicsImpostor");
      }, t.prototype.createInstance = function(e) {
        return t._instancedMeshFactory(e, this);
      }, t.prototype.synchronizeInstances = function() {
        for (var e = 0; e < this.instances.length; e++)
          this.instances[e]._syncSubMeshes();
        return this;
      }, t.prototype.optimizeIndices = function(e) {
        var i = this, r = this.getIndices(), o = this.getVerticesData(P.PositionKind);
        if (!o || !r)
          return this;
        for (var a = [], s = 0; s < o.length; s += 3)
          a.push(v.FromArray(o, s));
        var l = [];
        return So.SyncAsyncForLoop(a.length, 40, function(c) {
          for (var u = a.length - 1 - c, h = a[u], d = 0; d < u; ++d) {
            var p = a[d];
            if (h.equals(p)) {
              l[u] = d;
              break;
            }
          }
        }, function() {
          for (var c = 0; c < r.length; ++c)
            r[c] = l[r[c]] || r[c];
          var u = i.subMeshes.slice(0);
          i.setIndices(r), i.subMeshes = u, e && e(i);
        }), this;
      }, t.prototype.serialize = function(e) {
        e === void 0 && (e = {}), e.name = this.name, e.id = this.id, e.uniqueId = this.uniqueId, e.type = this.getClassName(), Xt && Xt.HasTags(this) && (e.tags = Xt.GetTags(this)), e.position = this.position.asArray(), this.rotationQuaternion ? e.rotationQuaternion = this.rotationQuaternion.asArray() : this.rotation && (e.rotation = this.rotation.asArray()), e.scaling = this.scaling.asArray(), this._postMultiplyPivotMatrix ? e.pivotMatrix = this.getPivotMatrix().asArray() : e.localMatrix = this.getPivotMatrix().asArray(), e.isEnabled = this.isEnabled(!1), e.isVisible = this.isVisible, e.infiniteDistance = this.infiniteDistance, e.pickable = this.isPickable, e.receiveShadows = this.receiveShadows, e.billboardMode = this.billboardMode, e.visibility = this.visibility, e.checkCollisions = this.checkCollisions, e.isBlocker = this.isBlocker, e.overrideMaterialSideOrientation = this.overrideMaterialSideOrientation, this.parent && this.parent._serializeAsParent(e), e.isUnIndexed = this.isUnIndexed;
        var i = this._geometry;
        if (i && this.subMeshes) {
          e.geometryUniqueId = i.uniqueId, e.geometryId = i.id, e.subMeshes = [];
          for (var r = 0; r < this.subMeshes.length; r++) {
            var o = this.subMeshes[r];
            e.subMeshes.push({ materialIndex: o.materialIndex, verticesStart: o.verticesStart, verticesCount: o.verticesCount, indexStart: o.indexStart, indexCount: o.indexCount });
          }
        }
        this.material ? this.material.doNotSerialize || (e.materialUniqueId = this.material.uniqueId, e.materialId = this.material.id) : (this.material = null, e.materialUniqueId = this._scene.defaultMaterial.uniqueId, e.materialId = this._scene.defaultMaterial.id), this.morphTargetManager && (e.morphTargetManagerId = this.morphTargetManager.uniqueId), this.skeleton && (e.skeletonId = this.skeleton.id, e.numBoneInfluencers = this.numBoneInfluencers), this.getScene()._getComponent(we.NAME_PHYSICSENGINE) && (l = this.getPhysicsImpostor()) && (e.physicsMass = l.getParam("mass"), e.physicsFriction = l.getParam("friction"), e.physicsRestitution = l.getParam("mass"), e.physicsImpostor = l.type), this.metadata && (e.metadata = this.metadata), e.instances = [];
        for (var a = 0; a < this.instances.length; a++) {
          var s = this.instances[a];
          if (!s.doNotSerialize) {
            var l, c = { name: s.name, id: s.id, isEnabled: s.isEnabled(!1), isVisible: s.isVisible, isPickable: s.isPickable, checkCollisions: s.checkCollisions, position: s.position.asArray(), scaling: s.scaling.asArray() };
            s.parent && s.parent._serializeAsParent(c), s.rotationQuaternion ? c.rotationQuaternion = s.rotationQuaternion.asArray() : s.rotation && (c.rotation = s.rotation.asArray()), this.getScene()._getComponent(we.NAME_PHYSICSENGINE) && (l = s.getPhysicsImpostor()) && (c.physicsMass = l.getParam("mass"), c.physicsFriction = l.getParam("friction"), c.physicsRestitution = l.getParam("mass"), c.physicsImpostor = l.type), s.metadata && (c.metadata = s.metadata), s.actionManager && (c.actions = s.actionManager.serialize(s.name)), e.instances.push(c), Ne.AppendSerializedAnimations(s, c), c.ranges = s.serializeAnimationRanges();
          }
        }
        if (this._thinInstanceDataStorage.instancesCount && this._thinInstanceDataStorage.matrixData && (e.thinInstances = { instancesCount: this._thinInstanceDataStorage.instancesCount, matrixData: Array.from(this._thinInstanceDataStorage.matrixData), matrixBufferSize: this._thinInstanceDataStorage.matrixBufferSize, enablePicking: this.thinInstanceEnablePicking }, this._userThinInstanceBuffersStorage)) {
          var u = { data: {}, sizes: {}, strides: {} };
          for (var h in this._userThinInstanceBuffersStorage.data)
            u.data[h] = Array.from(this._userThinInstanceBuffersStorage.data[h]), u.sizes[h] = this._userThinInstanceBuffersStorage.sizes[h], u.strides[h] = this._userThinInstanceBuffersStorage.strides[h];
          e.thinInstances.userThinInstance = u;
        }
        return Ne.AppendSerializedAnimations(this, e), e.ranges = this.serializeAnimationRanges(), e.layerMask = this.layerMask, e.alphaIndex = this.alphaIndex, e.hasVertexAlpha = this.hasVertexAlpha, e.overlayAlpha = this.overlayAlpha, e.overlayColor = this.overlayColor.asArray(), e.renderOverlay = this.renderOverlay, e.applyFog = this.applyFog, this.actionManager && (e.actions = this.actionManager.serialize(this.name)), e;
      }, t.prototype._syncGeometryWithMorphTargetManager = function() {
        if (this.geometry) {
          this._markSubMeshesAsAttributesDirty();
          var e = this._internalAbstractMeshDataInfo._morphTargetManager;
          if (e && e.vertexCount) {
            if (e.vertexCount !== this.getTotalVertices())
              return q.Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count."), void (this.morphTargetManager = null);
            if (e.isUsingTextureForTargets)
              return;
            for (var i = 0; i < e.numInfluencers; i++) {
              var r = e.getActiveTarget(i), o = r.getPositions();
              if (!o)
                return void q.Error("Invalid morph target. Target must have positions.");
              this.geometry.setVerticesData(P.PositionKind + i, o, !1, 3);
              var a = r.getNormals();
              a && this.geometry.setVerticesData(P.NormalKind + i, a, !1, 3);
              var s = r.getTangents();
              s && this.geometry.setVerticesData(P.TangentKind + i, s, !1, 3);
              var l = r.getUVs();
              l && this.geometry.setVerticesData(P.UVKind + "_" + i, l, !1, 2);
            }
          } else
            for (i = 0; this.geometry.isVerticesDataPresent(P.PositionKind + i); )
              this.geometry.removeVerticesData(P.PositionKind + i), this.geometry.isVerticesDataPresent(P.NormalKind + i) && this.geometry.removeVerticesData(P.NormalKind + i), this.geometry.isVerticesDataPresent(P.TangentKind + i) && this.geometry.removeVerticesData(P.TangentKind + i), this.geometry.isVerticesDataPresent(P.UVKind + i) && this.geometry.removeVerticesData(P.UVKind + "_" + i), i++;
        }
      }, t.Parse = function(e, i, r) {
        var o;
        if ((o = e.type && e.type === "LinesMesh" ? t._LinesMeshParser(e, i) : e.type && e.type === "GroundMesh" ? t._GroundMeshParser(e, i) : e.type && e.type === "GoldbergMesh" ? t._GoldbergMeshParser(e, i) : e.type && e.type === "GreasedLineMesh" ? t._GreasedLineMeshParser(e, i) : e.type && e.type === "TrailMesh" ? t._TrailMeshParser(e, i) : new t(e.name, i)).id = e.id, o._waitingParsedUniqueId = e.uniqueId, Xt && Xt.AddTagsTo(o, e.tags), o.position = v.FromArray(e.position), e.metadata !== void 0 && (o.metadata = e.metadata), e.rotationQuaternion ? o.rotationQuaternion = oe.FromArray(e.rotationQuaternion) : e.rotation && (o.rotation = v.FromArray(e.rotation)), o.scaling = v.FromArray(e.scaling), e.localMatrix ? o.setPreTransformMatrix(B.FromArray(e.localMatrix)) : e.pivotMatrix && o.setPivotMatrix(B.FromArray(e.pivotMatrix)), o.setEnabled(e.isEnabled), o.isVisible = e.isVisible, o.infiniteDistance = e.infiniteDistance, o.showBoundingBox = e.showBoundingBox, o.showSubMeshesBoundingBox = e.showSubMeshesBoundingBox, e.applyFog !== void 0 && (o.applyFog = e.applyFog), e.pickable !== void 0 && (o.isPickable = e.pickable), e.alphaIndex !== void 0 && (o.alphaIndex = e.alphaIndex), o.receiveShadows = e.receiveShadows, e.billboardMode !== void 0 && (o.billboardMode = e.billboardMode), e.visibility !== void 0 && (o.visibility = e.visibility), o.checkCollisions = e.checkCollisions, e.overrideMaterialSideOrientation !== void 0 && (o.overrideMaterialSideOrientation = e.overrideMaterialSideOrientation), e.isBlocker !== void 0 && (o.isBlocker = e.isBlocker), o._shouldGenerateFlatShading = e.useFlatShading, e.freezeWorldMatrix && (o._waitingData.freezeWorldMatrix = e.freezeWorldMatrix), e.parentId !== void 0 && (o._waitingParentId = e.parentId), e.parentInstanceIndex !== void 0 && (o._waitingParentInstanceIndex = e.parentInstanceIndex), e.actions !== void 0 && (o._waitingData.actions = e.actions), e.overlayAlpha !== void 0 && (o.overlayAlpha = e.overlayAlpha), e.overlayColor !== void 0 && (o.overlayColor = ne.FromArray(e.overlayColor)), e.renderOverlay !== void 0 && (o.renderOverlay = e.renderOverlay), o.isUnIndexed = !!e.isUnIndexed, o.hasVertexAlpha = e.hasVertexAlpha, e.delayLoadingFile ? (o.delayLoadState = _.DELAYLOADSTATE_NOTLOADED, o.delayLoadingFile = r + e.delayLoadingFile, o.buildBoundingInfo(v.FromArray(e.boundingBoxMinimum), v.FromArray(e.boundingBoxMaximum)), e._binaryInfo && (o._binaryInfo = e._binaryInfo), o._delayInfo = [], e.hasUVs && o._delayInfo.push(P.UVKind), e.hasUVs2 && o._delayInfo.push(P.UV2Kind), e.hasUVs3 && o._delayInfo.push(P.UV3Kind), e.hasUVs4 && o._delayInfo.push(P.UV4Kind), e.hasUVs5 && o._delayInfo.push(P.UV5Kind), e.hasUVs6 && o._delayInfo.push(P.UV6Kind), e.hasColors && o._delayInfo.push(P.ColorKind), e.hasMatricesIndices && o._delayInfo.push(P.MatricesIndicesKind), e.hasMatricesWeights && o._delayInfo.push(P.MatricesWeightsKind), o._delayLoadingFunction = er._ImportGeometry, Jr.ForceFullSceneLoadingForIncremental && o._checkDelayState()) : er._ImportGeometry(e, o), e.materialUniqueId ? o._waitingMaterialId = e.materialUniqueId : e.materialId && (o._waitingMaterialId = e.materialId), e.morphTargetManagerId > -1 && (o.morphTargetManager = i.getMorphTargetManagerById(e.morphTargetManagerId)), e.skeletonId !== void 0 && e.skeletonId !== null && (o.skeleton = i.getLastSkeletonById(e.skeletonId), e.numBoneInfluencers && (o.numBoneInfluencers = e.numBoneInfluencers)), e.animations) {
          for (var a = 0; a < e.animations.length; a++) {
            var s = e.animations[a];
            (h = Kt("BABYLON.Animation")) && o.animations.push(h.Parse(s));
          }
          oi.ParseAnimationRanges(o, e, i);
        }
        if (e.autoAnimate && i.beginAnimation(o, e.autoAnimateFrom, e.autoAnimateTo, e.autoAnimateLoop, e.autoAnimateSpeed || 1), e.layerMask && !isNaN(e.layerMask) ? o.layerMask = Math.abs(parseInt(e.layerMask)) : o.layerMask = 268435455, e.physicsImpostor && t._PhysicsImpostorParser(i, o, e), e.lodMeshIds && (o._waitingData.lods = { ids: e.lodMeshIds, distances: e.lodDistances ? e.lodDistances : null, coverages: e.lodCoverages ? e.lodCoverages : null }), e.instances)
          for (var l = 0; l < e.instances.length; l++) {
            var c = e.instances[l], u = o.createInstance(c.name);
            if (c.id && (u.id = c.id), Xt && (c.tags ? Xt.AddTagsTo(u, c.tags) : Xt.AddTagsTo(u, e.tags)), u.position = v.FromArray(c.position), c.metadata !== void 0 && (u.metadata = c.metadata), c.parentId !== void 0 && (u._waitingParentId = c.parentId), c.parentInstanceIndex !== void 0 && (u._waitingParentInstanceIndex = c.parentInstanceIndex), c.isEnabled !== void 0 && c.isEnabled !== null && u.setEnabled(c.isEnabled), c.isVisible !== void 0 && c.isVisible !== null && (u.isVisible = c.isVisible), c.isPickable !== void 0 && c.isPickable !== null && (u.isPickable = c.isPickable), c.rotationQuaternion ? u.rotationQuaternion = oe.FromArray(c.rotationQuaternion) : c.rotation && (u.rotation = v.FromArray(c.rotation)), u.scaling = v.FromArray(c.scaling), c.checkCollisions != null && c.checkCollisions != null && (u.checkCollisions = c.checkCollisions), c.pickable != null && c.pickable != null && (u.isPickable = c.pickable), c.showBoundingBox != null && c.showBoundingBox != null && (u.showBoundingBox = c.showBoundingBox), c.showSubMeshesBoundingBox != null && c.showSubMeshesBoundingBox != null && (u.showSubMeshesBoundingBox = c.showSubMeshesBoundingBox), c.alphaIndex != null && c.showSubMeshesBoundingBox != null && (u.alphaIndex = c.alphaIndex), c.physicsImpostor && t._PhysicsImpostorParser(i, u, c), c.actions !== void 0 && (u._waitingData.actions = c.actions), c.animations) {
              for (a = 0; a < c.animations.length; a++) {
                var h;
                s = c.animations[a], (h = Kt("BABYLON.Animation")) && u.animations.push(h.Parse(s));
              }
              oi.ParseAnimationRanges(u, c, i), c.autoAnimate && i.beginAnimation(u, c.autoAnimateFrom, c.autoAnimateTo, c.autoAnimateLoop, c.autoAnimateSpeed || 1);
            }
          }
        if (e.thinInstances) {
          var d = e.thinInstances;
          if (o.thinInstanceEnablePicking = !!d.enablePicking, d.matrixData ? (o.thinInstanceSetBuffer("matrix", new Float32Array(d.matrixData), 16, !1), o._thinInstanceDataStorage.matrixBufferSize = d.matrixBufferSize, o._thinInstanceDataStorage.instancesCount = d.instancesCount) : o._thinInstanceDataStorage.matrixBufferSize = d.matrixBufferSize, e.thinInstances.userThinInstance) {
            var p = e.thinInstances.userThinInstance;
            for (var f in p.data)
              o.thinInstanceSetBuffer(f, new Float32Array(p.data[f]), p.strides[f], !1), o._userThinInstanceBuffersStorage.sizes[f] = p.sizes[f];
          }
        }
        return o;
      }, t.prototype.setPositionsForCPUSkinning = function() {
        var e = this._internalMeshDataInfo;
        if (!e._sourcePositions) {
          var i = this.getVerticesData(P.PositionKind);
          if (!i)
            return e._sourcePositions;
          e._sourcePositions = new Float32Array(i), this.isVertexBufferUpdatable(P.PositionKind) || this.setVerticesData(P.PositionKind, i, !0);
        }
        return e._sourcePositions;
      }, t.prototype.setNormalsForCPUSkinning = function() {
        var e = this._internalMeshDataInfo;
        if (!e._sourceNormals) {
          var i = this.getVerticesData(P.NormalKind);
          if (!i)
            return e._sourceNormals;
          e._sourceNormals = new Float32Array(i), this.isVertexBufferUpdatable(P.NormalKind) || this.setVerticesData(P.NormalKind, i, !0);
        }
        return e._sourceNormals;
      }, t.prototype.applySkeleton = function(e) {
        if (!this.geometry)
          return this;
        if (this.geometry._softwareSkinningFrameId == this.getScene().getFrameId())
          return this;
        if (this.geometry._softwareSkinningFrameId = this.getScene().getFrameId(), !this.isVerticesDataPresent(P.PositionKind))
          return this;
        if (!this.isVerticesDataPresent(P.MatricesIndicesKind))
          return this;
        if (!this.isVerticesDataPresent(P.MatricesWeightsKind))
          return this;
        var i = this.isVerticesDataPresent(P.NormalKind), r = this._internalMeshDataInfo;
        if (!r._sourcePositions) {
          var o = this.subMeshes.slice();
          this.setPositionsForCPUSkinning(), this.subMeshes = o;
        }
        i && !r._sourceNormals && this.setNormalsForCPUSkinning();
        var a = this.getVerticesData(P.PositionKind);
        if (!a)
          return this;
        a instanceof Float32Array || (a = new Float32Array(a));
        var s = this.getVerticesData(P.NormalKind);
        if (i) {
          if (!s)
            return this;
          s instanceof Float32Array || (s = new Float32Array(s));
        }
        var l = this.getVerticesData(P.MatricesIndicesKind), c = this.getVerticesData(P.MatricesWeightsKind);
        if (!c || !l)
          return this;
        for (var u, h = this.numBoneInfluencers > 4, d = h ? this.getVerticesData(P.MatricesIndicesExtraKind) : null, p = h ? this.getVerticesData(P.MatricesWeightsExtraKind) : null, f = e.getTransformMatrices(this), m = v.Zero(), g = new B(), y = new B(), b = 0, T = 0; T < a.length; T += 3, b += 4) {
          var S = void 0;
          for (u = 0; u < 4; u++)
            (S = c[b + u]) > 0 && (B.FromFloat32ArrayToRefScaled(f, Math.floor(16 * l[b + u]), S, y), g.addToSelf(y));
          if (h)
            for (u = 0; u < 4; u++)
              (S = p[b + u]) > 0 && (B.FromFloat32ArrayToRefScaled(f, Math.floor(16 * d[b + u]), S, y), g.addToSelf(y));
          v.TransformCoordinatesFromFloatsToRef(r._sourcePositions[T], r._sourcePositions[T + 1], r._sourcePositions[T + 2], g, m), m.toArray(a, T), i && (v.TransformNormalFromFloatsToRef(r._sourceNormals[T], r._sourceNormals[T + 1], r._sourceNormals[T + 2], g, m), m.toArray(s, T)), g.reset();
        }
        return this.updateVerticesData(P.PositionKind, a), i && this.updateVerticesData(P.NormalKind, s), this;
      }, t.MinMax = function(e) {
        var i = null, r = null;
        return e.forEach(function(o) {
          var a = o.getBoundingInfo().boundingBox;
          i && r ? (i.minimizeInPlace(a.minimumWorld), r.maximizeInPlace(a.maximumWorld)) : (i = a.minimumWorld, r = a.maximumWorld);
        }), i && r ? { min: i, max: r } : { min: v.Zero(), max: v.Zero() };
      }, t.Center = function(e) {
        var i = e instanceof Array ? t.MinMax(e) : e;
        return v.Center(i.min, i.max);
      }, t.MergeMeshes = function(e, i, r, o, a, s) {
        return i === void 0 && (i = !0), ju(t._MergeMeshesCoroutine(e, i, r, o, a, s, !1));
      }, t.MergeMeshesAsync = function(e, i, r, o, a, s) {
        return i === void 0 && (i = !0), Yu(t._MergeMeshesCoroutine(e, i, r, o, a, s, !0), fg());
      }, t._MergeMeshesCoroutine = function(e, i, r, o, a, s, l) {
        var c, u, h, d, p, f, m, g, y, b, T, S, E, A, R, C, L, I, O, w, z, V, Y, ee, J, X;
        return i === void 0 && (i = !0), Bt(this, function(K) {
          switch (K.label) {
            case 0:
              if ((e = e.filter(Boolean)).length === 0)
                return [2, null];
              if (!r) {
                for (u = 0, c = 0; c < e.length; c++)
                  if ((u += e[c].getTotalVertices()) >= 65536)
                    return q.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"), [2, null];
              }
              for (s && (a = !1), h = new Array(), d = new Array(), p = new Array(), f = e[0].overrideMaterialSideOrientation, c = 0; c < e.length; c++) {
                if ((m = e[c]).isAnInstance)
                  return q.Warn("Cannot merge instance meshes."), [2, null];
                if (f !== m.overrideMaterialSideOrientation)
                  return q.Warn("Cannot merge meshes with different overrideMaterialSideOrientation values."), [2, null];
                if (a && p.push(m.getTotalIndices()), s)
                  if (m.material)
                    if ((g = m.material) instanceof Ao) {
                      for (y = 0; y < g.subMaterials.length; y++)
                        h.indexOf(g.subMaterials[y]) < 0 && h.push(g.subMaterials[y]);
                      for (J = 0; J < m.subMeshes.length; J++)
                        d.push(h.indexOf(g.subMaterials[m.subMeshes[J].materialIndex])), p.push(m.subMeshes[J].indexCount);
                    } else
                      for (h.indexOf(g) < 0 && h.push(g), J = 0; J < m.subMeshes.length; J++)
                        d.push(h.indexOf(g)), p.push(m.subMeshes[J].indexCount);
                  else
                    for (J = 0; J < m.subMeshes.length; J++)
                      d.push(0), p.push(m.subMeshes[J].indexCount);
              }
              return b = e[0], T = function(te) {
                var se = te.computeWorldMatrix(!0);
                return { vertexData: Oe.ExtractFromMesh(te, !1, !1), transform: se };
              }, X = T(b), S = X.vertexData, E = X.transform, l ? [4] : [3, 2];
            case 1:
              K.sent(), K.label = 2;
            case 2:
              A = new Array(e.length - 1), R = 1, K.label = 3;
            case 3:
              return R < e.length ? (A[R - 1] = T(e[R]), l ? [4] : [3, 5]) : [3, 6];
            case 4:
              K.sent(), K.label = 5;
            case 5:
              return R++, [3, 3];
            case 6:
              C = S._mergeCoroutine(E, A, r, l, !i), L = C.next(), K.label = 7;
            case 7:
              return L.done ? [3, 10] : l ? [4] : [3, 9];
            case 8:
              K.sent(), K.label = 9;
            case 9:
              return L = C.next(), [3, 7];
            case 10:
              I = L.value, o || (o = new t(b.name + "_merged", b.getScene())), O = I._applyToCoroutine(o, void 0, l), w = O.next(), K.label = 11;
            case 11:
              return w.done ? [3, 14] : l ? [4] : [3, 13];
            case 12:
              K.sent(), K.label = 13;
            case 13:
              return w = O.next(), [3, 11];
            case 14:
              if (o.checkCollisions = b.checkCollisions, o.overrideMaterialSideOrientation = b.overrideMaterialSideOrientation, i)
                for (c = 0; c < e.length; c++)
                  e[c].dispose();
              if (a || s) {
                for (o.releaseSubMeshes(), c = 0, z = 0; c < p.length; )
                  Yn.CreateFromIndices(0, z, p[c], o, void 0, !1), z += p[c], c++;
                for (V = 0, Y = o.subMeshes; V < Y.length; V++)
                  Y[V].refreshBoundingInfo();
                o.computeWorldMatrix(!0);
              }
              if (s) {
                for ((ee = new Ao(b.name + "_merged", b.getScene())).subMaterials = h, J = 0; J < o.subMeshes.length; J++)
                  o.subMeshes[J].materialIndex = d[J];
                o.material = ee;
              } else
                o.material = b.material;
              return [2, o];
          }
        });
      }, t.prototype.addInstance = function(e) {
        e._indexInSourceMeshInstanceArray = this.instances.length, this.instances.push(e);
      }, t.prototype.removeInstance = function(e) {
        var i = e._indexInSourceMeshInstanceArray;
        if (i != -1) {
          if (i !== this.instances.length - 1) {
            var r = this.instances[this.instances.length - 1];
            this.instances[i] = r, r._indexInSourceMeshInstanceArray = i;
          }
          e._indexInSourceMeshInstanceArray = -1, this.instances.pop();
        }
      }, t.prototype._shouldConvertRHS = function() {
        return this.overrideMaterialSideOrientation === Et.CounterClockWiseSideOrientation;
      }, t.prototype._getRenderingFillMode = function(e) {
        var i, r = this.getScene();
        return r.forcePointsCloud ? Et.PointFillMode : r.forceWireframe ? Et.WireFrameFillMode : (i = this.overrideRenderingFillMode) !== null && i !== void 0 ? i : e;
      }, t.prototype.setMaterialByID = function(e) {
        return this.setMaterialById(e);
      }, t.CreateRibbon = function(e, i, r, o, a, s, l, c, u) {
        throw new Error("Import MeshBuilder to populate this function");
      }, t.CreateDisc = function(e, i, r, o, a, s) {
        throw new Error("Import MeshBuilder to populate this function");
      }, t.CreateBox = function(e, i, r, o, a) {
        throw new Error("Import MeshBuilder to populate this function");
      }, t.CreateSphere = function(e, i, r, o, a, s) {
        throw new Error("Import MeshBuilder to populate this function");
      }, t.CreateHemisphere = function(e, i, r, o) {
        throw new Error("Import MeshBuilder to populate this function");
      }, t.CreateCylinder = function(e, i, r, o, a, s, l, c, u) {
        throw new Error("Import MeshBuilder to populate this function");
      }, t.CreateTorus = function(e, i, r, o, a, s, l) {
        throw new Error("Import MeshBuilder to populate this function");
      }, t.CreateTorusKnot = function(e, i, r, o, a, s, l, c, u, h) {
        throw new Error("Import MeshBuilder to populate this function");
      }, t.CreateLines = function(e, i, r, o, a) {
        throw new Error("Import MeshBuilder to populate this function");
      }, t.CreateDashedLines = function(e, i, r, o, a, s, l, c) {
        throw new Error("Import MeshBuilder to populate this function");
      }, t.CreatePolygon = function(e, i, r, o, a, s, l) {
        throw new Error("Import MeshBuilder to populate this function");
      }, t.ExtrudePolygon = function(e, i, r, o, a, s, l, c) {
        throw new Error("Import MeshBuilder to populate this function");
      }, t.ExtrudeShape = function(e, i, r, o, a, s, l, c, u, h) {
        throw new Error("Import MeshBuilder to populate this function");
      }, t.ExtrudeShapeCustom = function(e, i, r, o, a, s, l, c, u, h, d, p) {
        throw new Error("Import MeshBuilder to populate this function");
      }, t.CreateLathe = function(e, i, r, o, a, s, l) {
        throw new Error("Import MeshBuilder to populate this function");
      }, t.CreatePlane = function(e, i, r, o, a) {
        throw new Error("Import MeshBuilder to populate this function");
      }, t.CreateGround = function(e, i, r, o, a, s) {
        throw new Error("Import MeshBuilder to populate this function");
      }, t.CreateTiledGround = function(e, i, r, o, a, s, l, c, u) {
        throw new Error("Import MeshBuilder to populate this function");
      }, t.CreateGroundFromHeightMap = function(e, i, r, o, a, s, l, c, u, h, d) {
        throw new Error("Import MeshBuilder to populate this function");
      }, t.CreateTube = function(e, i, r, o, a, s, l, c, u, h) {
        throw new Error("Import MeshBuilder to populate this function");
      }, t.CreatePolyhedron = function(e, i, r) {
        throw new Error("Import MeshBuilder to populate this function");
      }, t.CreateIcoSphere = function(e, i, r) {
        throw new Error("Import MeshBuilder to populate this function");
      }, t.CreateDecal = function(e, i, r, o, a, s) {
        throw new Error("Import MeshBuilder to populate this function");
      }, t.CreateCapsule = function(e, i, r) {
        throw new Error("Import MeshBuilder to populate this function");
      }, t.ExtendToGoldberg = function(e) {
        throw new Error("Import MeshBuilder to populate this function");
      }, t.FRONTSIDE = Oe.FRONTSIDE, t.BACKSIDE = Oe.BACKSIDE, t.DOUBLESIDE = Oe.DOUBLESIDE, t.DEFAULTSIDE = Oe.DEFAULTSIDE, t.NO_CAP = 0, t.CAP_START = 1, t.CAP_END = 2, t.CAP_ALL = 3, t.NO_FLIP = 0, t.FLIP_TILE = 1, t.ROTATE_TILE = 2, t.FLIP_ROW = 3, t.ROTATE_ROW = 4, t.FLIP_N_ROTATE_TILE = 5, t.FLIP_N_ROTATE_ROW = 6, t.CENTER = 0, t.LEFT = 1, t.RIGHT = 2, t.TOP = 3, t.BOTTOM = 4, t.INSTANCEDMESH_SORT_TRANSPARENT = !1, t._GroundMeshParser = function(e, i) {
        throw et("GroundMesh");
      }, t._GoldbergMeshParser = function(e, i) {
        throw et("GoldbergMesh");
      }, t._LinesMeshParser = function(e, i) {
        throw et("LinesMesh");
      }, t._GreasedLineMeshParser = function(e, i) {
        throw et("GreasedLineMesh");
      }, t._GreasedLineRibbonMeshParser = function(e, i) {
        throw et("GreasedLineRibbonMesh");
      }, t._TrailMeshParser = function(e, i) {
        throw et("TrailMesh");
      }, t;
    }(Dt);
    j("BABYLON.Mesh", ie), ie._instancedMeshFactory = function(n, t) {
      var e = new dl(n, t);
      if (t.instancedBuffers)
        for (var i in e.instancedBuffers = {}, t.instancedBuffers)
          e.instancedBuffers[i] = t.instancedBuffers[i];
      return e;
    };
    var dl = function(n) {
      function t(e, i) {
        var r = n.call(this, e, i.getScene()) || this;
        r._indexInSourceMeshInstanceArray = -1, r._distanceToCamera = 0, i.addInstance(r), r._sourceMesh = i, r._unIndexed = i._unIndexed, r.position.copyFrom(i.position), r.rotation.copyFrom(i.rotation), r.scaling.copyFrom(i.scaling), i.rotationQuaternion && (r.rotationQuaternion = i.rotationQuaternion.clone()), r.animations = i.animations.slice();
        for (var o = 0, a = i.getAnimationRanges(); o < a.length; o++) {
          var s = a[o];
          s != null && r.createAnimationRange(s.name, s.from, s.to);
        }
        return r.infiniteDistance = i.infiniteDistance, r.setPivotMatrix(i.getPivotMatrix()), r.refreshBoundingInfo(!0, !0), r._syncSubMeshes(), r;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "InstancedMesh";
      }, Object.defineProperty(t.prototype, "lightSources", { get: function() {
        return this._sourceMesh._lightSources;
      }, enumerable: !1, configurable: !0 }), t.prototype._resyncLightSources = function() {
      }, t.prototype._resyncLightSource = function() {
      }, t.prototype._removeLightSource = function() {
      }, Object.defineProperty(t.prototype, "receiveShadows", { get: function() {
        return this._sourceMesh.receiveShadows;
      }, set: function(e) {
        var i;
        ((i = this._sourceMesh) === null || i === void 0 ? void 0 : i.receiveShadows) !== e && de.Warn("Setting receiveShadows on an instanced mesh has no effect");
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "material", { get: function() {
        return this._sourceMesh.material;
      }, set: function(e) {
        var i;
        ((i = this._sourceMesh) === null || i === void 0 ? void 0 : i.material) !== e && de.Warn("Setting material on an instanced mesh has no effect");
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "visibility", { get: function() {
        return this._sourceMesh.visibility;
      }, set: function(e) {
        var i;
        ((i = this._sourceMesh) === null || i === void 0 ? void 0 : i.visibility) !== e && de.Warn("Setting visibility on an instanced mesh has no effect");
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "skeleton", { get: function() {
        return this._sourceMesh.skeleton;
      }, set: function(e) {
        var i;
        ((i = this._sourceMesh) === null || i === void 0 ? void 0 : i.skeleton) !== e && de.Warn("Setting skeleton on an instanced mesh has no effect");
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "renderingGroupId", { get: function() {
        return this._sourceMesh.renderingGroupId;
      }, set: function(e) {
        this._sourceMesh && e !== this._sourceMesh.renderingGroupId && q.Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene");
      }, enumerable: !1, configurable: !0 }), t.prototype.getTotalVertices = function() {
        return this._sourceMesh ? this._sourceMesh.getTotalVertices() : 0;
      }, t.prototype.getTotalIndices = function() {
        return this._sourceMesh.getTotalIndices();
      }, Object.defineProperty(t.prototype, "sourceMesh", { get: function() {
        return this._sourceMesh;
      }, enumerable: !1, configurable: !0 }), t.prototype.createInstance = function(e) {
        return this._sourceMesh.createInstance(e);
      }, t.prototype.isReady = function(e) {
        return e === void 0 && (e = !1), this._sourceMesh.isReady(e, !0);
      }, t.prototype.getVerticesData = function(e, i, r) {
        return this._sourceMesh.getVerticesData(e, i, r);
      }, t.prototype.setVerticesData = function(e, i, r, o) {
        return this.sourceMesh && this.sourceMesh.setVerticesData(e, i, r, o), this.sourceMesh;
      }, t.prototype.updateVerticesData = function(e, i, r, o) {
        return this.sourceMesh && this.sourceMesh.updateVerticesData(e, i, r, o), this.sourceMesh;
      }, t.prototype.setIndices = function(e, i) {
        return i === void 0 && (i = null), this.sourceMesh && this.sourceMesh.setIndices(e, i), this.sourceMesh;
      }, t.prototype.isVerticesDataPresent = function(e) {
        return this._sourceMesh.isVerticesDataPresent(e);
      }, t.prototype.getIndices = function() {
        return this._sourceMesh.getIndices();
      }, Object.defineProperty(t.prototype, "_positions", { get: function() {
        return this._sourceMesh._positions;
      }, enumerable: !1, configurable: !0 }), t.prototype.refreshBoundingInfo = function(e, i) {
        if (e === void 0 && (e = !1), i === void 0 && (i = !1), this.hasBoundingInfo && this.getBoundingInfo().isLocked)
          return this;
        var r = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;
        return this._refreshBoundingInfo(this._sourceMesh._getPositionData(e, i), r), this;
      }, t.prototype._preActivate = function() {
        return this._currentLOD && this._currentLOD._preActivate(), this;
      }, t.prototype._activate = function(e, i) {
        if (n.prototype._activate.call(this, e, i), this._sourceMesh.subMeshes || q.Warn("Instances should only be created for meshes with geometry."), this._currentLOD) {
          if (this._currentLOD._getWorldMatrixDeterminant() >= 0 != this._getWorldMatrixDeterminant() >= 0)
            return this._internalAbstractMeshDataInfo._actAsRegularMesh = !0, !0;
          if (this._internalAbstractMeshDataInfo._actAsRegularMesh = !1, this._currentLOD._registerInstanceForRenderId(this, e), i) {
            if (!this._currentLOD._internalAbstractMeshDataInfo._isActiveIntermediate)
              return this._currentLOD._internalAbstractMeshDataInfo._onlyForInstancesIntermediate = !0, !0;
          } else if (!this._currentLOD._internalAbstractMeshDataInfo._isActive)
            return this._currentLOD._internalAbstractMeshDataInfo._onlyForInstances = !0, !0;
        }
        return !1;
      }, t.prototype._postActivate = function() {
        this._sourceMesh.edgesShareWithInstances && this._sourceMesh._edgesRenderer && this._sourceMesh._edgesRenderer.isEnabled && this._sourceMesh._renderingGroup ? (this._sourceMesh._renderingGroup._edgesRenderers.pushNoDuplicate(this._sourceMesh._edgesRenderer), this._sourceMesh._edgesRenderer.customInstances.push(this.getWorldMatrix())) : this._edgesRenderer && this._edgesRenderer.isEnabled && this._sourceMesh._renderingGroup && this._sourceMesh._renderingGroup._edgesRenderers.push(this._edgesRenderer);
      }, t.prototype.getWorldMatrix = function() {
        if (this._currentLOD && this._currentLOD.billboardMode !== ai.BILLBOARDMODE_NONE && this._currentLOD._masterMesh !== this) {
          this._billboardWorldMatrix || (this._billboardWorldMatrix = new B());
          var e = this._currentLOD._masterMesh;
          return this._currentLOD._masterMesh = this, F.Vector3[7].copyFrom(this._currentLOD.position), this._currentLOD.position.set(0, 0, 0), this._billboardWorldMatrix.copyFrom(this._currentLOD.computeWorldMatrix(!0)), this._currentLOD.position.copyFrom(F.Vector3[7]), this._currentLOD._masterMesh = e, this._billboardWorldMatrix;
        }
        return n.prototype.getWorldMatrix.call(this);
      }, Object.defineProperty(t.prototype, "isAnInstance", { get: function() {
        return !0;
      }, enumerable: !1, configurable: !0 }), t.prototype.getLOD = function(e) {
        if (!e)
          return this;
        var i = this.sourceMesh.getLODLevels();
        if (i && i.length !== 0) {
          var r = this.getBoundingInfo();
          this._currentLOD = this.sourceMesh.getLOD(e, r.boundingSphere);
        } else
          this._currentLOD = this.sourceMesh;
        return this._currentLOD;
      }, t.prototype._preActivateForIntermediateRendering = function(e) {
        return this.sourceMesh._preActivateForIntermediateRendering(e);
      }, t.prototype._syncSubMeshes = function() {
        if (this.releaseSubMeshes(), this._sourceMesh.subMeshes)
          for (var e = 0; e < this._sourceMesh.subMeshes.length; e++)
            this._sourceMesh.subMeshes[e].clone(this, this._sourceMesh);
        return this;
      }, t.prototype._generatePointsArray = function() {
        return this._sourceMesh._generatePointsArray();
      }, t.prototype._updateBoundingInfo = function() {
        return this.hasBoundingInfo ? this.getBoundingInfo().update(this.worldMatrixFromCache) : this.buildBoundingInfo(this.absolutePosition, this.absolutePosition, this.worldMatrixFromCache), this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache), this;
      }, t.prototype.clone = function(e, i, r, o) {
        i === void 0 && (i = null);
        var a = (o || this._sourceMesh).createInstance(e);
        if (Ui.DeepCopy(this, a, ["name", "subMeshes", "uniqueId", "parent", "lightSources", "receiveShadows", "material", "visibility", "skeleton", "sourceMesh", "isAnInstance", "facetNb", "isFacetDataEnabled", "isBlocked", "useBones", "hasInstances", "collider", "edgesRenderer", "forward", "up", "right", "absolutePosition", "absoluteScaling", "absoluteRotationQuaternion", "isWorldMatrixFrozen", "nonUniformScaling", "behaviors", "worldMatrixFromCache", "hasThinInstances", "hasBoundingInfo"], []), this.refreshBoundingInfo(), i && (a.parent = i), !r)
          for (var s = 0; s < this.getScene().meshes.length; s++) {
            var l = this.getScene().meshes[s];
            l.parent === this && l.clone(l.name, a);
          }
        return a.computeWorldMatrix(!0), this.onClonedObservable.notifyObservers(a), a;
      }, t.prototype.dispose = function(e, i) {
        i === void 0 && (i = !1), this._sourceMesh.removeInstance(this), n.prototype.dispose.call(this, e, i);
      }, t.prototype._serializeAsParent = function(e) {
        n.prototype._serializeAsParent.call(this, e), e.parentId = this._sourceMesh.uniqueId, e.parentInstanceIndex = this._indexInSourceMeshInstanceArray;
      }, t.prototype.instantiateHierarchy = function(e, i, r) {
        e === void 0 && (e = null);
        var o = this.clone("Clone of " + (this.name || this.id), e || this.parent, !0, i && i.newSourcedMesh);
        o && r && r(this, o);
        for (var a = 0, s = this.getChildTransformNodes(!0); a < s.length; a++)
          s[a].instantiateHierarchy(o, i, r);
        return o;
      }, t;
    }(Dt);
    ie.prototype.registerInstancedBuffer = function(n, t) {
      var e, i;
      if ((i = (e = this._userInstancedBuffersStorage) === null || e === void 0 ? void 0 : e.vertexBuffers[n]) === null || i === void 0 || i.dispose(), !this.instancedBuffers) {
        this.instancedBuffers = {};
        for (var r = 0, o = this.instances; r < o.length; r++)
          o[r].instancedBuffers = {};
      }
      this._userInstancedBuffersStorage || (this._userInstancedBuffersStorage = { data: {}, vertexBuffers: {}, strides: {}, sizes: {}, vertexArrayObjects: this.getEngine().getCaps().vertexArrayObject ? {} : void 0 }), this.instancedBuffers[n] = null, this._userInstancedBuffersStorage.strides[n] = t, this._userInstancedBuffersStorage.sizes[n] = 32 * t, this._userInstancedBuffersStorage.data[n] = new Float32Array(this._userInstancedBuffersStorage.sizes[n]), this._userInstancedBuffersStorage.vertexBuffers[n] = new P(this.getEngine(), this._userInstancedBuffersStorage.data[n], n, !0, !1, t, !0);
      for (var a = 0, s = this.instances; a < s.length; a++)
        s[a].instancedBuffers[n] = null;
      this._invalidateInstanceVertexArrayObject(), this._markSubMeshesAsAttributesDirty();
    }, ie.prototype._processInstancedBuffers = function(n, t) {
      var e = n ? n.length : 0;
      for (var i in this.instancedBuffers) {
        for (var r = this._userInstancedBuffersStorage.sizes[i], o = this._userInstancedBuffersStorage.strides[i], a = (e + 1) * o; r < a; )
          r *= 2;
        this._userInstancedBuffersStorage.data[i].length != r && (this._userInstancedBuffersStorage.data[i] = new Float32Array(r), this._userInstancedBuffersStorage.sizes[i] = r, this._userInstancedBuffersStorage.vertexBuffers[i] && (this._userInstancedBuffersStorage.vertexBuffers[i].dispose(), this._userInstancedBuffersStorage.vertexBuffers[i] = null));
        var s = this._userInstancedBuffersStorage.data[i], l = 0;
        t && ((u = this.instancedBuffers[i]).toArray ? u.toArray(s, l) : u.copyToArray ? u.copyToArray(s, l) : s[l] = u, l += o);
        for (var c = 0; c < e; c++) {
          var u;
          (u = n[c].instancedBuffers[i]).toArray ? u.toArray(s, l) : u.copyToArray ? u.copyToArray(s, l) : s[l] = u, l += o;
        }
        this._userInstancedBuffersStorage.vertexBuffers[i] ? this._userInstancedBuffersStorage.vertexBuffers[i].updateDirectly(s, 0) : (this._userInstancedBuffersStorage.vertexBuffers[i] = new P(this.getEngine(), this._userInstancedBuffersStorage.data[i], i, !0, !1, o, !0), this._invalidateInstanceVertexArrayObject());
      }
    }, ie.prototype._invalidateInstanceVertexArrayObject = function() {
      if (this._userInstancedBuffersStorage && this._userInstancedBuffersStorage.vertexArrayObjects !== void 0) {
        for (var n in this._userInstancedBuffersStorage.vertexArrayObjects)
          this.getEngine().releaseVertexArrayObject(this._userInstancedBuffersStorage.vertexArrayObjects[n]);
        this._userInstancedBuffersStorage.vertexArrayObjects = {};
      }
    }, ie.prototype._disposeInstanceSpecificData = function() {
      for (this._instanceDataStorage.instancesBuffer && (this._instanceDataStorage.instancesBuffer.dispose(), this._instanceDataStorage.instancesBuffer = null); this.instances.length; )
        this.instances[0].dispose();
      for (var n in this.instancedBuffers)
        this._userInstancedBuffersStorage.vertexBuffers[n] && this._userInstancedBuffersStorage.vertexBuffers[n].dispose();
      this._invalidateInstanceVertexArrayObject(), this.instancedBuffers = {};
    };
    var Kn = function(n) {
      function t(e, i) {
        var r = n.call(this, e, i) || this;
        return r.diffuse = new ne(1, 1, 1), r.specular = new ne(1, 1, 1), r.falloffType = t.FALLOFF_DEFAULT, r.intensity = 1, r._range = Number.MAX_VALUE, r._inverseSquaredRange = 0, r._photometricScale = 1, r._intensityMode = t.INTENSITYMODE_AUTOMATIC, r._radius = 1e-5, r.renderPriority = 0, r._shadowEnabled = !0, r._excludeWithLayerMask = 0, r._includeOnlyWithLayerMask = 0, r._lightmapMode = 0, r._shadowGenerators = null, r._excludedMeshesIds = new Array(), r._includedOnlyMeshesIds = new Array(), r._isLight = !0, r.getScene().addLight(r), r._uniformBuffer = new Er(r.getScene().getEngine(), void 0, void 0, e), r._buildUniformLayout(), r.includedOnlyMeshes = [], r.excludedMeshes = [], r._resyncMeshes(), r;
      }
      return D(t, n), Object.defineProperty(t.prototype, "range", { get: function() {
        return this._range;
      }, set: function(e) {
        this._range = e, this._inverseSquaredRange = 1 / (this.range * this.range);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "intensityMode", { get: function() {
        return this._intensityMode;
      }, set: function(e) {
        this._intensityMode = e, this._computePhotometricScale();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "radius", { get: function() {
        return this._radius;
      }, set: function(e) {
        this._radius = e, this._computePhotometricScale();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "shadowEnabled", { get: function() {
        return this._shadowEnabled;
      }, set: function(e) {
        this._shadowEnabled !== e && (this._shadowEnabled = e, this._markMeshesAsLightDirty());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "includedOnlyMeshes", { get: function() {
        return this._includedOnlyMeshes;
      }, set: function(e) {
        this._includedOnlyMeshes = e, this._hookArrayForIncludedOnly(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "excludedMeshes", { get: function() {
        return this._excludedMeshes;
      }, set: function(e) {
        this._excludedMeshes = e, this._hookArrayForExcluded(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "excludeWithLayerMask", { get: function() {
        return this._excludeWithLayerMask;
      }, set: function(e) {
        this._excludeWithLayerMask = e, this._resyncMeshes();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "includeOnlyWithLayerMask", { get: function() {
        return this._includeOnlyWithLayerMask;
      }, set: function(e) {
        this._includeOnlyWithLayerMask = e, this._resyncMeshes();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "lightmapMode", { get: function() {
        return this._lightmapMode;
      }, set: function(e) {
        this._lightmapMode !== e && (this._lightmapMode = e, this._markMeshesAsLightDirty());
      }, enumerable: !1, configurable: !0 }), t.prototype.transferTexturesToEffect = function(e, i) {
        return this;
      }, t.prototype._bindLight = function(e, i, r, o, a) {
        var s;
        a === void 0 && (a = !0);
        var l = e.toString(), c = !1;
        if (this._uniformBuffer.bindToEffect(r, "Light" + l), this._renderId !== i.getRenderId() || this._lastUseSpecular !== o || !this._uniformBuffer.useUbo) {
          this._renderId = i.getRenderId(), this._lastUseSpecular = o;
          var u = this.getScaledIntensity();
          this.transferToEffect(r, l), this.diffuse.scaleToRef(u, Ot.Color3[0]), this._uniformBuffer.updateColor4("vLightDiffuse", Ot.Color3[0], this.range, l), o && (this.specular.scaleToRef(u, Ot.Color3[1]), this._uniformBuffer.updateColor4("vLightSpecular", Ot.Color3[1], this.radius, l)), c = !0;
        }
        if (this.transferTexturesToEffect(r, l), i.shadowsEnabled && this.shadowEnabled && a) {
          var h = (s = this.getShadowGenerator(i.activeCamera)) !== null && s !== void 0 ? s : this.getShadowGenerator();
          h && (h.bindShadowLight(l, r), c = !0);
        }
        c ? this._uniformBuffer.update() : this._uniformBuffer.bindUniformBuffer();
      }, t.prototype.getClassName = function() {
        return "Light";
      }, t.prototype.toString = function(e) {
        var i = "Name: " + this.name;
        if (i += ", type: " + ["Point", "Directional", "Spot", "Hemispheric"][this.getTypeID()], this.animations)
          for (var r = 0; r < this.animations.length; r++)
            i += ", animation[0]: " + this.animations[r].toString(e);
        return i;
      }, t.prototype._syncParentEnabledState = function() {
        n.prototype._syncParentEnabledState.call(this), this.isDisposed() || this._resyncMeshes();
      }, t.prototype.setEnabled = function(e) {
        n.prototype.setEnabled.call(this, e), this._resyncMeshes();
      }, t.prototype.getShadowGenerator = function(e) {
        var i;
        return e === void 0 && (e = null), this._shadowGenerators === null ? null : (i = this._shadowGenerators.get(e)) !== null && i !== void 0 ? i : null;
      }, t.prototype.getShadowGenerators = function() {
        return this._shadowGenerators;
      }, t.prototype.getAbsolutePosition = function() {
        return v.Zero();
      }, t.prototype.canAffectMesh = function(e) {
        return !(e && (this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(e) === -1 || this.excludedMeshes && this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(e) !== -1 || this.includeOnlyWithLayerMask !== 0 && !(this.includeOnlyWithLayerMask & e.layerMask) || this.excludeWithLayerMask !== 0 && this.excludeWithLayerMask & e.layerMask));
      }, t.prototype.dispose = function(e, i) {
        if (i === void 0 && (i = !1), this._shadowGenerators) {
          for (var r = this._shadowGenerators.values(), o = r.next(); o.done !== !0; o = r.next())
            o.value.dispose();
          this._shadowGenerators = null;
        }
        if (this.getScene().stopAnimation(this), this._parentContainer) {
          var a = this._parentContainer.lights.indexOf(this);
          a > -1 && this._parentContainer.lights.splice(a, 1), this._parentContainer = null;
        }
        for (var s = 0, l = this.getScene().meshes; s < l.length; s++)
          l[s]._removeLightSource(this, !0);
        this._uniformBuffer.dispose(), this.getScene().removeLight(this), n.prototype.dispose.call(this, e, i);
      }, t.prototype.getTypeID = function() {
        return 0;
      }, t.prototype.getScaledIntensity = function() {
        return this._photometricScale * this.intensity;
      }, t.prototype.clone = function(e, i) {
        i === void 0 && (i = null);
        var r = t.GetConstructorFromName(this.getTypeID(), e, this.getScene());
        if (!r)
          return null;
        var o = Ne.Clone(r, this);
        return e && (o.name = e), i && (o.parent = i), o.setEnabled(this.isEnabled()), this.onClonedObservable.notifyObservers(o), o;
      }, t.prototype.serialize = function() {
        var e = Ne.Serialize(this);
        return e.uniqueId = this.uniqueId, e.type = this.getTypeID(), this.parent && this.parent._serializeAsParent(e), this.excludedMeshes.length > 0 && (e.excludedMeshesIds = [], this.excludedMeshes.forEach(function(i) {
          e.excludedMeshesIds.push(i.id);
        })), this.includedOnlyMeshes.length > 0 && (e.includedOnlyMeshesIds = [], this.includedOnlyMeshes.forEach(function(i) {
          e.includedOnlyMeshesIds.push(i.id);
        })), Ne.AppendSerializedAnimations(this, e), e.ranges = this.serializeAnimationRanges(), e.isEnabled = this.isEnabled(), e;
      }, t.GetConstructorFromName = function(e, i, r) {
        return oi.Construct("Light_Type_" + e, i, r) || null;
      }, t.Parse = function(e, i) {
        var r = t.GetConstructorFromName(e.type, e.name, i);
        if (!r)
          return null;
        var o = Ne.Parse(r, e, i);
        if (e.excludedMeshesIds && (o._excludedMeshesIds = e.excludedMeshesIds), e.includedOnlyMeshesIds && (o._includedOnlyMeshesIds = e.includedOnlyMeshesIds), e.parentId !== void 0 && (o._waitingParentId = e.parentId), e.parentInstanceIndex !== void 0 && (o._waitingParentInstanceIndex = e.parentInstanceIndex), e.falloffType !== void 0 && (o.falloffType = e.falloffType), e.lightmapMode !== void 0 && (o.lightmapMode = e.lightmapMode), e.animations) {
          for (var a = 0; a < e.animations.length; a++) {
            var s = e.animations[a], l = Kt("BABYLON.Animation");
            l && o.animations.push(l.Parse(s));
          }
          oi.ParseAnimationRanges(o, e, i);
        }
        return e.autoAnimate && i.beginAnimation(o, e.autoAnimateFrom, e.autoAnimateTo, e.autoAnimateLoop, e.autoAnimateSpeed || 1), e.isEnabled !== void 0 && o.setEnabled(e.isEnabled), o;
      }, t.prototype._hookArrayForExcluded = function(e) {
        var i = this, r = e.push;
        e.push = function() {
          for (var l = [], c = 0; c < arguments.length; c++)
            l[c] = arguments[c];
          for (var u = r.apply(e, l), h = 0, d = l; h < d.length; h++)
            d[h]._resyncLightSource(i);
          return u;
        };
        var o = e.splice;
        e.splice = function(l, c) {
          for (var u = o.apply(e, [l, c]), h = 0, d = u; h < d.length; h++)
            d[h]._resyncLightSource(i);
          return u;
        };
        for (var a = 0, s = e; a < s.length; a++)
          s[a]._resyncLightSource(this);
      }, t.prototype._hookArrayForIncludedOnly = function(e) {
        var i = this, r = e.push;
        e.push = function() {
          for (var a = [], s = 0; s < arguments.length; s++)
            a[s] = arguments[s];
          var l = r.apply(e, a);
          return i._resyncMeshes(), l;
        };
        var o = e.splice;
        e.splice = function(a, s) {
          var l = o.apply(e, [a, s]);
          return i._resyncMeshes(), l;
        }, this._resyncMeshes();
      }, t.prototype._resyncMeshes = function() {
        for (var e = 0, i = this.getScene().meshes; e < i.length; e++)
          i[e]._resyncLightSource(this);
      }, t.prototype._markMeshesAsLightDirty = function() {
        for (var e = 0, i = this.getScene().meshes; e < i.length; e++) {
          var r = i[e];
          r.lightSources.indexOf(this) !== -1 && r._markSubMeshesAsLightDirty();
        }
      }, t.prototype._computePhotometricScale = function() {
        this._photometricScale = this._getPhotometricScale(), this.getScene().resetCachedMaterial();
      }, t.prototype._getPhotometricScale = function() {
        var e = 0, i = this.getTypeID(), r = this.intensityMode;
        switch (r === t.INTENSITYMODE_AUTOMATIC && (r = i === t.LIGHTTYPEID_DIRECTIONALLIGHT ? t.INTENSITYMODE_ILLUMINANCE : t.INTENSITYMODE_LUMINOUSINTENSITY), i) {
          case t.LIGHTTYPEID_POINTLIGHT:
          case t.LIGHTTYPEID_SPOTLIGHT:
            switch (r) {
              case t.INTENSITYMODE_LUMINOUSPOWER:
                e = 1 / (4 * Math.PI);
                break;
              case t.INTENSITYMODE_LUMINOUSINTENSITY:
                e = 1;
                break;
              case t.INTENSITYMODE_LUMINANCE:
                e = this.radius * this.radius;
            }
            break;
          case t.LIGHTTYPEID_DIRECTIONALLIGHT:
            switch (r) {
              case t.INTENSITYMODE_ILLUMINANCE:
                e = 1;
                break;
              case t.INTENSITYMODE_LUMINANCE:
                var o = this.radius;
                o = Math.max(o, 1e-3), e = 2 * Math.PI * (1 - Math.cos(o));
            }
            break;
          case t.LIGHTTYPEID_HEMISPHERICLIGHT:
            e = 1;
        }
        return e;
      }, t.prototype._reorderLightsInScene = function() {
        var e = this.getScene();
        this._renderPriority != 0 && (e.requireLightSorting = !0), this.getScene().sortLightsByPriority();
      }, t.FALLOFF_DEFAULT = nn.FALLOFF_DEFAULT, t.FALLOFF_PHYSICAL = nn.FALLOFF_PHYSICAL, t.FALLOFF_GLTF = nn.FALLOFF_GLTF, t.FALLOFF_STANDARD = nn.FALLOFF_STANDARD, t.LIGHTMAP_DEFAULT = nn.LIGHTMAP_DEFAULT, t.LIGHTMAP_SPECULAR = nn.LIGHTMAP_SPECULAR, t.LIGHTMAP_SHADOWSONLY = nn.LIGHTMAP_SHADOWSONLY, t.INTENSITYMODE_AUTOMATIC = nn.INTENSITYMODE_AUTOMATIC, t.INTENSITYMODE_LUMINOUSPOWER = nn.INTENSITYMODE_LUMINOUSPOWER, t.INTENSITYMODE_LUMINOUSINTENSITY = nn.INTENSITYMODE_LUMINOUSINTENSITY, t.INTENSITYMODE_ILLUMINANCE = nn.INTENSITYMODE_ILLUMINANCE, t.INTENSITYMODE_LUMINANCE = nn.INTENSITYMODE_LUMINANCE, t.LIGHTTYPEID_POINTLIGHT = nn.LIGHTTYPEID_POINTLIGHT, t.LIGHTTYPEID_DIRECTIONALLIGHT = nn.LIGHTTYPEID_DIRECTIONALLIGHT, t.LIGHTTYPEID_SPOTLIGHT = nn.LIGHTTYPEID_SPOTLIGHT, t.LIGHTTYPEID_HEMISPHERICLIGHT = nn.LIGHTTYPEID_HEMISPHERICLIGHT, x([ri()], t.prototype, "diffuse", void 0), x([ri()], t.prototype, "specular", void 0), x([N()], t.prototype, "falloffType", void 0), x([N()], t.prototype, "intensity", void 0), x([N()], t.prototype, "range", null), x([N()], t.prototype, "intensityMode", null), x([N()], t.prototype, "radius", null), x([N()], t.prototype, "_renderPriority", void 0), x([ye("_reorderLightsInScene")], t.prototype, "renderPriority", void 0), x([N("shadowEnabled")], t.prototype, "_shadowEnabled", void 0), x([N("excludeWithLayerMask")], t.prototype, "_excludeWithLayerMask", void 0), x([N("includeOnlyWithLayerMask")], t.prototype, "_includeOnlyWithLayerMask", void 0), x([N("lightmapMode")], t.prototype, "_lightmapMode", void 0), t;
    }(oi), xg = function(n) {
      function t() {
        return n !== null && n.apply(this, arguments) || this;
      }
      return D(t, n), t;
    }(pe), Ag = function() {
      function n() {
        this.rootNodes = [], this.skeletons = [], this.animationGroups = [];
      }
      return n.prototype.dispose = function() {
        this.rootNodes.slice(0).forEach(function(t) {
          t.dispose();
        }), this.rootNodes.length = 0, this.skeletons.slice(0).forEach(function(t) {
          t.dispose();
        }), this.skeletons.length = 0, this.animationGroups.slice(0).forEach(function(t) {
          t.dispose();
        }), this.animationGroups.length = 0;
      }, n;
    }(), Rg = function(n) {
      function t(e) {
        var i = n.call(this) || this;
        return i._wasAddedToScene = !1, (e = e || Me.LastCreatedScene) && (i.scene = e, i.sounds = [], i.effectLayers = [], i.layers = [], i.lensFlareSystems = [], i.proceduralTextures = [], i.reflectionProbes = [], e.onDisposeObservable.add(function() {
          i._wasAddedToScene || i.dispose();
        }), i._onContextRestoredObserver = e.getEngine().onContextRestoredObservable.add(function() {
          for (var r = 0, o = i.geometries; r < o.length; r++)
            o[r]._rebuild();
          for (var a = 0, s = i.meshes; a < s.length; a++)
            s[a]._rebuild();
          for (var l = 0, c = i.particleSystems; l < c.length; l++)
            c[l].rebuild();
          for (var u = 0, h = i.textures; u < h.length; u++)
            h[u]._rebuild();
        })), i;
      }
      return D(t, n), t.prototype._topologicalSort = function(e) {
        for (var i = /* @__PURE__ */ new Map(), r = 0, o = e; r < o.length; r++) {
          var a = o[r];
          i.set(a.uniqueId, a);
        }
        for (var s = { dependsOn: /* @__PURE__ */ new Map(), dependedBy: /* @__PURE__ */ new Map() }, l = 0, c = e; l < c.length; l++) {
          var u = (a = c[l]).uniqueId;
          s.dependsOn.set(u, /* @__PURE__ */ new Set()), s.dependedBy.set(u, /* @__PURE__ */ new Set());
        }
        for (var h = 0, d = e; h < d.length; h++) {
          u = (a = d[h]).uniqueId;
          var p = s.dependsOn.get(u);
          if (a instanceof dl) {
            var f = a.sourceMesh;
            i.has(f.uniqueId) && (p.add(f.uniqueId), s.dependedBy.get(f.uniqueId).add(u));
          }
          for (var m = s.dependedBy.get(u), g = 0, y = a.getDescendants(); g < y.length; g++) {
            var b = y[g].uniqueId;
            i.has(b) && (m.add(b), s.dependsOn.get(b).add(u));
          }
        }
        for (var T = [], S = [], E = 0, A = e; E < A.length; E++)
          u = (a = A[E]).uniqueId, s.dependsOn.get(u).size === 0 && (S.push(a), i.delete(u));
        for (var R = S; R.length > 0; ) {
          var C = R.shift();
          T.push(C);
          for (var L = s.dependedBy.get(C.uniqueId), I = 0, O = Array.from(L.values()); I < O.length; I++) {
            var w = O[I], z = s.dependsOn.get(w);
            z.delete(C.uniqueId), z.size === 0 && i.get(w) && (R.push(i.get(w)), i.delete(w));
          }
        }
        return i.size > 0 && (console.error("SceneSerializer._topologicalSort: There were unvisited nodes:"), i.forEach(function(V) {
          return console.error(V.name);
        })), T;
      }, t.prototype._addNodeAndDescendantsToList = function(e, i, r, o) {
        if (r && (!o || o(r)) && !i.has(r.uniqueId)) {
          e.push(r), i.add(r.uniqueId);
          for (var a = 0, s = r.getDescendants(!0); a < s.length; a++) {
            var l = s[a];
            this._addNodeAndDescendantsToList(e, i, l, o);
          }
        }
      }, t.prototype._isNodeInContainer = function(e) {
        return e instanceof ie && this.meshes.indexOf(e) !== -1 || e instanceof ai && this.transformNodes.indexOf(e) !== -1 || e instanceof Kn && this.lights.indexOf(e) !== -1 || e instanceof dt && this.cameras.indexOf(e) !== -1;
      }, t.prototype._isValidHierarchy = function() {
        for (var e = 0, i = this.meshes; e < i.length; e++)
          if ((u = i[e]).parent && !this._isNodeInContainer(u.parent))
            return q.Warn("Node ".concat(u.name, " has a parent that is not in the container.")), !1;
        for (var r = 0, o = this.transformNodes; r < o.length; r++)
          if ((u = o[r]).parent && !this._isNodeInContainer(u.parent))
            return q.Warn("Node ".concat(u.name, " has a parent that is not in the container.")), !1;
        for (var a = 0, s = this.lights; a < s.length; a++)
          if ((u = s[a]).parent && !this._isNodeInContainer(u.parent))
            return q.Warn("Node ".concat(u.name, " has a parent that is not in the container.")), !1;
        for (var l = 0, c = this.cameras; l < c.length; l++) {
          var u;
          if ((u = c[l]).parent && !this._isNodeInContainer(u.parent))
            return q.Warn("Node ".concat(u.name, " has a parent that is not in the container.")), !1;
        }
        return !0;
      }, t.prototype.instantiateModelsToScene = function(e, i, r) {
        var o = this;
        i === void 0 && (i = !1), this._isValidHierarchy() || de.Warn("SceneSerializer.InstantiateModelsToScene: The Asset Container hierarchy is not valid.");
        for (var a = {}, s = {}, l = new Ag(), c = [], u = [], h = je({ doNotInstantiate: !0 }, r), d = [], p = /* @__PURE__ */ new Set(), f = 0, m = this.transformNodes; f < m.length; f++) {
          var g = m[f];
          g.parent === null && this._addNodeAndDescendantsToList(d, p, g, h.predicate);
        }
        for (var y = 0, b = this.meshes; y < b.length; y++) {
          var T = b[y];
          T.parent === null && this._addNodeAndDescendantsToList(d, p, T, h.predicate);
        }
        var S = this._topologicalSort(d), E = function(A, R) {
          if (function(J, X) {
            if (a[J.uniqueId] = X.uniqueId, s[X.uniqueId] = X, e && (X.name = e(J.name)), X instanceof ie) {
              var K = X;
              if (K.morphTargetManager) {
                var te = J.morphTargetManager;
                K.morphTargetManager = te.clone();
                for (var se = 0; se < te.numTargets; se++) {
                  var _e = te.getTarget(se), xe = K.morphTargetManager.getTarget(se);
                  a[_e.uniqueId] = xe.uniqueId, s[xe.uniqueId] = xe;
                }
              }
            }
          }(A, R), A.parent) {
            var C = a[A.parent.uniqueId], L = s[C];
            R.parent = L || A.parent;
          }
          if (R.position && A.position && R.position.copyFrom(A.position), R.rotationQuaternion && A.rotationQuaternion && R.rotationQuaternion.copyFrom(A.rotationQuaternion), R.rotation && A.rotation && R.rotation.copyFrom(A.rotation), R.scaling && A.scaling && R.scaling.copyFrom(A.scaling), R.material) {
            var I = R;
            if (I.material)
              if (i) {
                var O = A.material;
                if (u.indexOf(O) === -1) {
                  var w = O.clone(e ? e(O.name) : "Clone of " + O.name);
                  if (u.push(O), a[O.uniqueId] = w.uniqueId, s[w.uniqueId] = w, O.getClassName() === "MultiMaterial") {
                    for (var z = O, V = 0, Y = z.subMaterials; V < Y.length; V++) {
                      var ee = Y[V];
                      ee && (w = ee.clone(e ? e(ee.name) : "Clone of " + ee.name), u.push(ee), a[ee.uniqueId] = w.uniqueId, s[w.uniqueId] = w);
                    }
                    z.subMaterials = z.subMaterials.map(function(J) {
                      return J && s[a[J.uniqueId]];
                    });
                  }
                }
                I.getClassName() !== "InstancedMesh" && (I.material = s[a[O.uniqueId]]);
              } else
                I.material.getClassName() === "MultiMaterial" ? o.scene.multiMaterials.indexOf(I.material) === -1 && o.scene.addMultiMaterial(I.material) : o.scene.materials.indexOf(I.material) === -1 && o.scene.addMaterial(I.material);
          }
          R.parent === null && l.rootNodes.push(R);
        };
        return S.forEach(function(A) {
          if (A.getClassName() === "InstancedMesh") {
            var R = A, C = R.sourceMesh, L = a[C.uniqueId], I = (typeof L == "number" ? s[L] : C).createInstance(R.name);
            E(R, I);
          } else {
            var O = !0;
            A.getClassName() === "TransformNode" || A.getClassName() === "Node" || A.skeleton || !A.getTotalVertices || A.getTotalVertices() === 0 ? O = !1 : h.doNotInstantiate && (O = typeof h.doNotInstantiate == "function" ? !h.doNotInstantiate(A) : !h.doNotInstantiate);
            var w = O ? A.createInstance("instance of ".concat(A.name)) : A.clone("Clone of ".concat(A.name), null, !0);
            if (!w)
              throw new Error("Could not clone or instantiate node on Asset Container ".concat(A.name));
            E(A, w);
          }
        }), this.skeletons.forEach(function(A) {
          if (!h.predicate || h.predicate(A)) {
            for (var R = A.clone(e ? e(A.name) : "Clone of " + A.name), C = 0, L = o.meshes; C < L.length; C++) {
              var I = L[C];
              if (I.skeleton === A && !I.isAnInstance) {
                var O = s[a[I.uniqueId]];
                if (!O || O.isAnInstance || (O.skeleton = R, c.indexOf(R) !== -1))
                  continue;
                c.push(R);
                for (var w = 0, z = R.bones; w < z.length; w++) {
                  var V = z[w];
                  V._linkedTransformNode && (V._linkedTransformNode = s[a[V._linkedTransformNode.uniqueId]]);
                }
              }
            }
            l.skeletons.push(R);
          }
        }), this.animationGroups.forEach(function(A) {
          if (!h.predicate || h.predicate(A)) {
            var R = A.clone(e ? e(A.name) : "Clone of " + A.name, function(C) {
              return s[a[C.uniqueId]] || C;
            });
            l.animationGroups.push(R);
          }
        }), l;
      }, t.prototype.addAllToScene = function() {
        if (!this._wasAddedToScene) {
          this._isValidHierarchy() || de.Warn("SceneSerializer.addAllToScene: The Asset Container hierarchy is not valid."), this._wasAddedToScene = !0, this.addToScene(null), this.environmentTexture && (this.scene.environmentTexture = this.environmentTexture);
          for (var e = 0, i = this.scene._serializableComponents; e < i.length; e++)
            i[e].addFromContainer(this);
          this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver), this._onContextRestoredObserver = null;
        }
      }, t.prototype.addToScene = function(e) {
        var i = this;
        e === void 0 && (e = null);
        var r = [];
        this.cameras.forEach(function(l) {
          e && !e(l) || (i.scene.addCamera(l), r.push(l));
        }), this.lights.forEach(function(l) {
          e && !e(l) || (i.scene.addLight(l), r.push(l));
        }), this.meshes.forEach(function(l) {
          e && !e(l) || (i.scene.addMesh(l), r.push(l));
        }), this.skeletons.forEach(function(l) {
          e && !e(l) || i.scene.addSkeleton(l);
        }), this.animations.forEach(function(l) {
          e && !e(l) || i.scene.addAnimation(l);
        }), this.animationGroups.forEach(function(l) {
          e && !e(l) || i.scene.addAnimationGroup(l);
        }), this.multiMaterials.forEach(function(l) {
          e && !e(l) || i.scene.addMultiMaterial(l);
        }), this.materials.forEach(function(l) {
          e && !e(l) || i.scene.addMaterial(l);
        }), this.morphTargetManagers.forEach(function(l) {
          e && !e(l) || i.scene.addMorphTargetManager(l);
        }), this.geometries.forEach(function(l) {
          e && !e(l) || i.scene.addGeometry(l);
        }), this.transformNodes.forEach(function(l) {
          e && !e(l) || (i.scene.addTransformNode(l), r.push(l));
        }), this.actionManagers.forEach(function(l) {
          e && !e(l) || i.scene.addActionManager(l);
        }), this.textures.forEach(function(l) {
          e && !e(l) || i.scene.addTexture(l);
        }), this.reflectionProbes.forEach(function(l) {
          e && !e(l) || i.scene.addReflectionProbe(l);
        });
        for (var o = 0, a = r; o < a.length; o++) {
          var s = a[o];
          s.parent && this.scene.getNodes().indexOf(s.parent) === -1 && (s.setParent ? s.setParent(null) : s.parent = null);
        }
      }, t.prototype.removeAllFromScene = function() {
        this._isValidHierarchy() || de.Warn("SceneSerializer.removeAllFromScene: The Asset Container hierarchy is not valid."), this._wasAddedToScene = !1, this.removeFromScene(null), this.environmentTexture === this.scene.environmentTexture && (this.scene.environmentTexture = null);
        for (var e = 0, i = this.scene._serializableComponents; e < i.length; e++)
          i[e].removeFromContainer(this);
      }, t.prototype.removeFromScene = function(e) {
        var i = this;
        e === void 0 && (e = null), this.cameras.forEach(function(r) {
          e && !e(r) || i.scene.removeCamera(r);
        }), this.lights.forEach(function(r) {
          e && !e(r) || i.scene.removeLight(r);
        }), this.meshes.forEach(function(r) {
          e && !e(r) || i.scene.removeMesh(r, !0);
        }), this.skeletons.forEach(function(r) {
          e && !e(r) || i.scene.removeSkeleton(r);
        }), this.animations.forEach(function(r) {
          e && !e(r) || i.scene.removeAnimation(r);
        }), this.animationGroups.forEach(function(r) {
          e && !e(r) || i.scene.removeAnimationGroup(r);
        }), this.multiMaterials.forEach(function(r) {
          e && !e(r) || i.scene.removeMultiMaterial(r);
        }), this.materials.forEach(function(r) {
          e && !e(r) || i.scene.removeMaterial(r);
        }), this.morphTargetManagers.forEach(function(r) {
          e && !e(r) || i.scene.removeMorphTargetManager(r);
        }), this.geometries.forEach(function(r) {
          e && !e(r) || i.scene.removeGeometry(r);
        }), this.transformNodes.forEach(function(r) {
          e && !e(r) || i.scene.removeTransformNode(r);
        }), this.actionManagers.forEach(function(r) {
          e && !e(r) || i.scene.removeActionManager(r);
        }), this.textures.forEach(function(r) {
          e && !e(r) || i.scene.removeTexture(r);
        }), this.reflectionProbes.forEach(function(r) {
          e && !e(r) || i.scene.removeReflectionProbe(r);
        });
      }, t.prototype.dispose = function() {
        this.cameras.slice(0).forEach(function(r) {
          r.dispose();
        }), this.cameras.length = 0, this.lights.slice(0).forEach(function(r) {
          r.dispose();
        }), this.lights.length = 0, this.meshes.slice(0).forEach(function(r) {
          r.dispose();
        }), this.meshes.length = 0, this.skeletons.slice(0).forEach(function(r) {
          r.dispose();
        }), this.skeletons.length = 0, this.animationGroups.slice(0).forEach(function(r) {
          r.dispose();
        }), this.animationGroups.length = 0, this.multiMaterials.slice(0).forEach(function(r) {
          r.dispose();
        }), this.multiMaterials.length = 0, this.materials.slice(0).forEach(function(r) {
          r.dispose();
        }), this.materials.length = 0, this.geometries.slice(0).forEach(function(r) {
          r.dispose();
        }), this.geometries.length = 0, this.transformNodes.slice(0).forEach(function(r) {
          r.dispose();
        }), this.transformNodes.length = 0, this.actionManagers.slice(0).forEach(function(r) {
          r.dispose();
        }), this.actionManagers.length = 0, this.textures.slice(0).forEach(function(r) {
          r.dispose();
        }), this.textures.length = 0, this.reflectionProbes.slice(0).forEach(function(r) {
          r.dispose();
        }), this.reflectionProbes.length = 0, this.morphTargetManagers.slice(0).forEach(function(r) {
          r.dispose();
        }), this.morphTargetManagers.length = 0, this.environmentTexture && (this.environmentTexture.dispose(), this.environmentTexture = null);
        for (var e = 0, i = this.scene._serializableComponents; e < i.length; e++)
          i[e].removeFromContainer(this, !0);
        this._onContextRestoredObserver && (this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver), this._onContextRestoredObserver = null);
      }, t.prototype._moveAssets = function(e, i, r) {
        if (e && i)
          for (var o = 0, a = e; o < a.length; o++) {
            var s = a[o], l = !0;
            if (r) {
              for (var c = 0, u = r; c < u.length; c++)
                if (s === u[c]) {
                  l = !1;
                  break;
                }
            }
            l && (i.push(s), s._parentContainer = this);
          }
      }, t.prototype.moveAllFromScene = function(e) {
        for (var i in this._wasAddedToScene = !1, e === void 0 && (e = new xg()), this)
          Object.prototype.hasOwnProperty.call(this, i) && (this[i] = this[i] || (i === "_environmentTexture" ? null : []), this._moveAssets(this.scene[i], this[i], e[i]));
        this.environmentTexture = this.scene.environmentTexture, this.removeAllFromScene();
      }, t.prototype.createRootMesh = function() {
        var e = new ie("assetContainerRootMesh", this.scene);
        return this.meshes.forEach(function(i) {
          i.parent || e.addChild(i);
        }), this.meshes.unshift(e), e;
      }, t.prototype.mergeAnimationsTo = function(e, i, r) {
        if (e === void 0 && (e = Me.LastCreatedScene), r === void 0 && (r = null), !e)
          return q.Error("No scene available to merge animations to"), [];
        var o = r || function(s) {
          var l = null, c = s.animations.length ? s.animations[0].targetProperty : "", u = s.name.split(".").join("").split("_primitive")[0];
          switch (c) {
            case "position":
            case "rotationQuaternion":
              l = e.getTransformNodeByName(s.name) || e.getTransformNodeByName(u);
              break;
            case "influence":
              l = e.getMorphTargetByName(s.name) || e.getMorphTargetByName(u);
              break;
            default:
              l = e.getNodeByName(s.name) || e.getNodeByName(u);
          }
          return l;
        };
        this.getNodes().forEach(function(s) {
          var l = o(s);
          if (l !== null) {
            for (var c = function(d) {
              for (var p = 0, f = l.animations.filter(function(y) {
                return y.targetProperty === d.targetProperty;
              }); p < f.length; p++) {
                var m = f[p], g = l.animations.indexOf(m, 0);
                g > -1 && l.animations.splice(g, 1);
              }
            }, u = 0, h = s.animations; u < h.length; u++)
              c(h[u]);
            l.animations = l.animations.concat(s.animations);
          }
        });
        var a = [];
        return this.animationGroups.slice().forEach(function(s) {
          a.push(s.clone(s.name, o)), s.animatables.forEach(function(l) {
            l.stop();
          });
        }), i.forEach(function(s) {
          var l = o(s.target);
          l && (e.beginAnimation(l, s.fromFrame, s.toFrame, s.loopAnimation, s.speedRatio, s.onAnimationEnd ? s.onAnimationEnd : void 0, void 0, !0, void 0, s.onAnimationLoop ? s.onAnimationLoop : void 0), e.stopAnimation(s.target));
        }), a;
      }, t.prototype.populateRootNodes = function() {
        var e = this;
        this.rootNodes.length = 0, this.meshes.forEach(function(i) {
          i.parent || e.rootNodes.indexOf(i) !== -1 || e.rootNodes.push(i);
        }), this.transformNodes.forEach(function(i) {
          i.parent || e.rootNodes.indexOf(i) !== -1 || e.rootNodes.push(i);
        }), this.lights.forEach(function(i) {
          i.parent || e.rootNodes.indexOf(i) !== -1 || e.rootNodes.push(i);
        }), this.cameras.forEach(function(i) {
          i.parent || e.rootNodes.indexOf(i) !== -1 || e.rootNodes.push(i);
        });
      }, t.prototype.addAllAssetsToContainer = function(e) {
        if (e) {
          var i = [], r = /* @__PURE__ */ new Set();
          for (i.push(e); i.length > 0; ) {
            var o = i.pop();
            if (o instanceof ie ? (o.geometry && this.geometries.indexOf(o.geometry) === -1 && this.geometries.push(o.geometry), this.meshes.push(o)) : o instanceof ai ? this.transformNodes.push(o) : o instanceof Kn ? this.lights.push(o) : o instanceof dt && this.cameras.push(o), o instanceof Dt) {
              if (o.material && this.materials.indexOf(o.material) === -1) {
                this.materials.push(o.material);
                for (var a = 0, s = o.material.getActiveTextures(); a < s.length; a++) {
                  var l = s[a];
                  this.textures.indexOf(l) === -1 && this.textures.push(l);
                }
              }
              o.skeleton && this.skeletons.indexOf(o.skeleton) === -1 && this.skeletons.push(o.skeleton), o.morphTargetManager && this.morphTargetManagers.indexOf(o.morphTargetManager) === -1 && this.morphTargetManagers.push(o.morphTargetManager);
            }
            for (var c = 0, u = o.getChildren(); c < u.length; c++) {
              var h = u[c];
              r.has(h) || i.push(h);
            }
            r.add(o);
          }
          this.populateRootNodes();
        }
      }, t;
    }(pe), sR = function() {
      function n(t) {
        this.SMOOTHING = 0.75, this.FFT_SIZE = 512, this.BARGRAPHAMPLITUDE = 256, this.DEBUGCANVASPOS = { x: 20, y: 20 }, this.DEBUGCANVASSIZE = { width: 320, height: 200 }, (t = t || Me.LastCreatedScene) && (this._scene = t, ve.audioEngine ? (this._audioEngine = ve.audioEngine, this._audioEngine.canUseWebAudio && this._audioEngine.audioContext && (this._webAudioAnalyser = this._audioEngine.audioContext.createAnalyser(), this._webAudioAnalyser.minDecibels = -140, this._webAudioAnalyser.maxDecibels = 0, this._byteFreqs = new Uint8Array(this._webAudioAnalyser.frequencyBinCount), this._byteTime = new Uint8Array(this._webAudioAnalyser.frequencyBinCount), this._floatFreqs = new Float32Array(this._webAudioAnalyser.frequencyBinCount))) : de.Warn("No audio engine initialized, failed to create an audio analyser"));
      }
      return n.prototype.getFrequencyBinCount = function() {
        return this._audioEngine.canUseWebAudio ? this._webAudioAnalyser.frequencyBinCount : 0;
      }, n.prototype.getByteFrequencyData = function() {
        return this._audioEngine.canUseWebAudio && (this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING, this._webAudioAnalyser.fftSize = this.FFT_SIZE, this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs)), this._byteFreqs;
      }, n.prototype.getByteTimeDomainData = function() {
        return this._audioEngine.canUseWebAudio && (this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING, this._webAudioAnalyser.fftSize = this.FFT_SIZE, this._webAudioAnalyser.getByteTimeDomainData(this._byteTime)), this._byteTime;
      }, n.prototype.getFloatFrequencyData = function() {
        return this._audioEngine.canUseWebAudio && (this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING, this._webAudioAnalyser.fftSize = this.FFT_SIZE, this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs)), this._floatFreqs;
      }, n.prototype.drawDebugCanvas = function() {
        var t = this;
        if (this._audioEngine.canUseWebAudio && (this._debugCanvas || (this._debugCanvas = document.createElement("canvas"), this._debugCanvas.width = this.DEBUGCANVASSIZE.width, this._debugCanvas.height = this.DEBUGCANVASSIZE.height, this._debugCanvas.style.position = "absolute", this._debugCanvas.style.top = this.DEBUGCANVASPOS.y + "px", this._debugCanvas.style.left = this.DEBUGCANVASPOS.x + "px", this._debugCanvasContext = this._debugCanvas.getContext("2d"), document.body.appendChild(this._debugCanvas), this._registerFunc = function() {
          t.drawDebugCanvas();
        }, this._scene.registerBeforeRender(this._registerFunc)), this._registerFunc && this._debugCanvasContext)) {
          var e = this.getByteFrequencyData();
          this._debugCanvasContext.fillStyle = "rgb(0, 0, 0)", this._debugCanvasContext.fillRect(0, 0, this.DEBUGCANVASSIZE.width, this.DEBUGCANVASSIZE.height);
          for (var i = 0; i < this.getFrequencyBinCount(); i++) {
            var r = e[i] / this.BARGRAPHAMPLITUDE, o = this.DEBUGCANVASSIZE.height * r, a = this.DEBUGCANVASSIZE.height - o - 1, s = this.DEBUGCANVASSIZE.width / this.getFrequencyBinCount(), l = i / this.getFrequencyBinCount() * 360;
            this._debugCanvasContext.fillStyle = "hsl(" + l + ", 100%, 50%)", this._debugCanvasContext.fillRect(i * s, a, s, o);
          }
        }
      }, n.prototype.stopDebugCanvas = function() {
        this._debugCanvas && (this._registerFunc && (this._scene.unregisterBeforeRender(this._registerFunc), this._registerFunc = null), document.body.removeChild(this._debugCanvas), this._debugCanvas = null, this._debugCanvasContext = null);
      }, n.prototype.connectAudioNodes = function(t, e) {
        this._audioEngine.canUseWebAudio && (t.connect(this._webAudioAnalyser), this._webAudioAnalyser.connect(e));
      }, n.prototype.dispose = function() {
        this._audioEngine.canUseWebAudio && this._webAudioAnalyser.disconnect();
      }, n;
    }();
    ve.AudioEngineFactory = function(n, t, e) {
      return new Cg(n, t, e);
    };
    var Cg = function() {
      function n(t, e, i) {
        t === void 0 && (t = null), e === void 0 && (e = null), i === void 0 && (i = null);
        var r = this;
        if (this._audioContext = null, this._audioContextInitialized = !1, this._muteButton = null, this._audioDestination = null, this.canUseWebAudio = !1, this.WarnedWebAudioUnsupported = !1, this.isMP3supported = !1, this.isOGGsupported = !1, this.unlocked = !1, this.useCustomUnlockedButton = !1, this.onAudioUnlockedObservable = new H(), this.onAudioLockedObservable = new H(), this._tryToRun = !1, this._onResize = function() {
          r._moveButtonToTopLeft();
        }, Gi()) {
          window.AudioContext !== void 0 && (this.canUseWebAudio = !0);
          var o = document.createElement("audio");
          this._hostElement = t, this._audioContext = e, this._audioDestination = i;
          try {
            o && o.canPlayType && (o.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, "") || o.canPlayType("audio/mp3").replace(/^no$/, "")) && (this.isMP3supported = !0);
          } catch {
          }
          try {
            o && o.canPlayType && o.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, "") && (this.isOGGsupported = !0);
          } catch {
          }
        }
      }
      return Object.defineProperty(n.prototype, "audioContext", { get: function() {
        return this._audioContextInitialized || this._initializeAudioContext(), this._audioContext;
      }, enumerable: !1, configurable: !0 }), n.prototype.lock = function() {
        this._triggerSuspendedState();
      }, n.prototype.unlock = function() {
        var t, e, i = this;
        ((t = this._audioContext) === null || t === void 0 ? void 0 : t.state) !== "running" ? this._tryToRun ? (e = this._audioContext) === null || e === void 0 || e.suspend().then(function() {
          i._tryToRun = !1, i._triggerRunningState();
        }) : this._triggerRunningState() : this._hideMuteButton();
      }, n.prototype._resumeAudioContext = function() {
        var t;
        return !((t = this._audioContext) === null || t === void 0) && t.resume ? this._audioContext.resume() : Promise.resolve();
      }, n.prototype._initializeAudioContext = function() {
        try {
          this.canUseWebAudio && (this._audioContext || (this._audioContext = new AudioContext()), this.masterGain = this._audioContext.createGain(), this.masterGain.gain.value = 1, this._audioDestination || (this._audioDestination = this._audioContext.destination), this.masterGain.connect(this._audioDestination), this._audioContextInitialized = !0, this._audioContext.state === "running" && this._triggerRunningState());
        } catch (t) {
          this.canUseWebAudio = !1, q.Error("Web Audio: " + t.message);
        }
      }, n.prototype._triggerRunningState = function() {
        var t = this;
        this._tryToRun || (this._tryToRun = !0, this._resumeAudioContext().then(function() {
          t._tryToRun = !1, t._muteButton && t._hideMuteButton(), t.unlocked = !0, t.onAudioUnlockedObservable.notifyObservers(t);
        }).catch(function() {
          t._tryToRun = !1, t.unlocked = !1;
        }));
      }, n.prototype._triggerSuspendedState = function() {
        this.unlocked = !1, this.onAudioLockedObservable.notifyObservers(this), this._displayMuteButton();
      }, n.prototype._displayMuteButton = function() {
        var t = this;
        if (!this.useCustomUnlockedButton && !this._muteButton) {
          this._muteButton = document.createElement("BUTTON"), this._muteButton.className = "babylonUnmuteIcon", this._muteButton.id = "babylonUnmuteIconBtn", this._muteButton.title = "Unmute";
          var e = ".babylonUnmuteIcon { position: absolute; left: 20px; top: 20px; height: 40px; width: 60px; background-color: rgba(51,51,51,0.7); background-image: url(" + (window.SVGSVGElement ? "data:image/svg+xml;charset=UTF-8,%3Csvg%20version%3D%221.1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2239%22%20height%3D%2232%22%20viewBox%3D%220%200%2039%2032%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22M9.625%2018.938l-0.031%200.016h-4.953q-0.016%200-0.031-0.016v-12.453q0-0.016%200.031-0.016h4.953q0.031%200%200.031%200.016v12.453zM12.125%207.688l8.719-8.703v27.453l-8.719-8.719-0.016-0.047v-9.938zM23.359%207.875l1.406-1.406%204.219%204.203%204.203-4.203%201.422%201.406-4.219%204.219%204.219%204.203-1.484%201.359-4.141-4.156-4.219%204.219-1.406-1.422%204.219-4.203z%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E" : "https://cdn.babylonjs.com/Assets/audio.png") + ");  background-size: 80%; background-repeat:no-repeat; background-position: center; background-position-y: 4px; border: none; outline: none; transition: transform 0.125s ease-out; cursor: pointer; z-index: 9999; } .babylonUnmuteIcon:hover { transform: scale(1.05) } .babylonUnmuteIcon:active { background-color: rgba(51,51,51,1) }", i = document.createElement("style");
          i.appendChild(document.createTextNode(e)), document.getElementsByTagName("head")[0].appendChild(i), document.body.appendChild(this._muteButton), this._moveButtonToTopLeft(), this._muteButton.addEventListener("touchend", function() {
            t._triggerRunningState();
          }, !0), this._muteButton.addEventListener("click", function() {
            t.unlock();
          }, !0), window.addEventListener("resize", this._onResize);
        }
      }, n.prototype._moveButtonToTopLeft = function() {
        this._hostElement && this._muteButton && (this._muteButton.style.top = this._hostElement.offsetTop + 20 + "px", this._muteButton.style.left = this._hostElement.offsetLeft + 20 + "px");
      }, n.prototype._hideMuteButton = function() {
        this._muteButton && (document.body.removeChild(this._muteButton), this._muteButton = null);
      }, n.prototype.dispose = function() {
        this.canUseWebAudio && this._audioContextInitialized && (this._connectedAnalyser && this._audioContext && (this._connectedAnalyser.stopDebugCanvas(), this._connectedAnalyser.dispose(), this.masterGain.disconnect(), this.masterGain.connect(this._audioContext.destination), this._connectedAnalyser = null), this.masterGain.gain.value = 1), this.WarnedWebAudioUnsupported = !1, this._hideMuteButton(), window.removeEventListener("resize", this._onResize), this.onAudioUnlockedObservable.clear(), this.onAudioLockedObservable.clear();
      }, n.prototype.getGlobalVolume = function() {
        return this.canUseWebAudio && this._audioContextInitialized ? this.masterGain.gain.value : -1;
      }, n.prototype.setGlobalVolume = function(t) {
        this.canUseWebAudio && this._audioContextInitialized && (this.masterGain.gain.value = t);
      }, n.prototype.connectToAnalyser = function(t) {
        this._connectedAnalyser && this._connectedAnalyser.stopDebugCanvas(), this.canUseWebAudio && this._audioContextInitialized && this._audioContext && (this._connectedAnalyser = t, this.masterGain.disconnect(), this._connectedAnalyser.connectAudioNodes(this.masterGain, this._audioContext.destination));
      }, n;
    }(), _s = function() {
      function n(t, e, i, r, o) {
        r === void 0 && (r = null);
        var a, s, l, c, u, h = this;
        if (this.autoplay = !1, this._loop = !1, this.useCustomAttenuation = !1, this.isPlaying = !1, this.isPaused = !1, this.refDistance = 1, this.rolloffFactor = 1, this.maxDistance = 100, this.distanceModel = "linear", this.metadata = null, this.onEndedObservable = new H(), this._spatialSound = !1, this._panningModel = "equalpower", this._playbackRate = 1, this._streaming = !1, this._startTime = 0, this._currentTime = 0, this._position = v.Zero(), this._localDirection = new v(1, 0, 0), this._volume = 1, this._isReadyToPlay = !1, this._isDirectional = !1, this._coneInnerAngle = 360, this._coneOuterAngle = 360, this._coneOuterGain = 0, this._isOutputConnected = !1, this._urlType = "Unknown", this.name = t, i = i || Me.LastCreatedScene)
          if (this._scene = i, n._SceneComponentInitialization(i), this._readyToPlayCallback = r, this._customAttenuationFunction = function(b, T, S, E, A) {
            return T < S ? b * (1 - T / S) : 0;
          }, o && (this.autoplay = o.autoplay || !1, this._loop = o.loop || !1, o.volume !== void 0 && (this._volume = o.volume), this._spatialSound = (a = o.spatialSound) !== null && a !== void 0 && a, this.maxDistance = (s = o.maxDistance) !== null && s !== void 0 ? s : 100, this.useCustomAttenuation = (l = o.useCustomAttenuation) !== null && l !== void 0 && l, this.rolloffFactor = o.rolloffFactor || 1, this.refDistance = o.refDistance || 1, this.distanceModel = o.distanceModel || "linear", this._playbackRate = o.playbackRate || 1, this._streaming = (c = o.streaming) !== null && c !== void 0 && c, this._length = o.length, this._offset = o.offset), ((u = ve.audioEngine) === null || u === void 0 ? void 0 : u.canUseWebAudio) && ve.audioEngine.audioContext) {
            this._soundGain = ve.audioEngine.audioContext.createGain(), this._soundGain.gain.value = this._volume, this._inputAudioNode = this._soundGain, this._outputAudioNode = this._soundGain, this._spatialSound && this._createSpatialParameters(), this._scene.mainSoundTrack.addSound(this);
            var d = !0;
            if (e)
              try {
                typeof e == "string" ? (this._urlType = "String", this._url = e) : e instanceof ArrayBuffer ? this._urlType = "ArrayBuffer" : e instanceof HTMLMediaElement ? this._urlType = "MediaElement" : e instanceof MediaStream ? this._urlType = "MediaStream" : e instanceof AudioBuffer ? this._urlType = "AudioBuffer" : Array.isArray(e) && (this._urlType = "Array");
                var p = [], f = !1;
                switch (this._urlType) {
                  case "MediaElement":
                    this._streaming = !0, this._isReadyToPlay = !0, this._streamingSource = ve.audioEngine.audioContext.createMediaElementSource(e), this.autoplay && this.play(0, this._offset, this._length), this._readyToPlayCallback && this._readyToPlayCallback();
                    break;
                  case "MediaStream":
                    this._streaming = !0, this._isReadyToPlay = !0, this._streamingSource = ve.audioEngine.audioContext.createMediaStreamSource(e), this.autoplay && this.play(0, this._offset, this._length), this._readyToPlayCallback && this._readyToPlayCallback();
                    break;
                  case "ArrayBuffer":
                    e.byteLength > 0 && (f = !0, this._soundLoaded(e));
                    break;
                  case "AudioBuffer":
                    this._audioBufferLoaded(e);
                    break;
                  case "String":
                    p.push(e);
                  case "Array":
                    p.length === 0 && (p = e);
                    for (var m = function(b) {
                      var T = p[b];
                      if (f = o && o.skipCodecCheck || T.indexOf(".mp3", T.length - 4) !== -1 && ve.audioEngine.isMP3supported || T.indexOf(".ogg", T.length - 4) !== -1 && ve.audioEngine.isOGGsupported || T.indexOf(".wav", T.length - 4) !== -1 || T.indexOf(".m4a", T.length - 4) !== -1 || T.indexOf(".mp4", T.length - 4) !== -1 || T.indexOf("blob:") !== -1)
                        return g._streaming ? (g._htmlAudioElement = new Audio(T), g._htmlAudioElement.controls = !1, g._htmlAudioElement.loop = g.loop, de.SetCorsBehavior(T, g._htmlAudioElement), g._htmlAudioElement.preload = "auto", g._htmlAudioElement.addEventListener("canplaythrough", function() {
                          h._isReadyToPlay = !0, h.autoplay && h.play(0, h._offset, h._length), h._readyToPlayCallback && h._readyToPlayCallback();
                        }), document.body.appendChild(g._htmlAudioElement), g._htmlAudioElement.load()) : g._scene._loadFile(T, function(S) {
                          h._soundLoaded(S);
                        }, void 0, !0, !0, function(S) {
                          S && q.Error("XHR " + S.status + " error on: " + T + "."), q.Error("Sound creation aborted."), h._scene.mainSoundTrack.removeSound(h);
                        }), "break";
                    }, g = this, y = 0; y < p.length && m(y) !== "break"; y++)
                      ;
                    break;
                  default:
                    d = !1;
                }
                d ? f || (this._isReadyToPlay = !0, this._readyToPlayCallback && setTimeout(function() {
                  h._readyToPlayCallback && h._readyToPlayCallback();
                }, 1e3)) : q.Error("Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.");
              } catch {
                q.Error("Unexpected error. Sound creation aborted."), this._scene.mainSoundTrack.removeSound(this);
              }
          } else
            this._scene.mainSoundTrack.addSound(this), ve.audioEngine && !ve.audioEngine.WarnedWebAudioUnsupported && (q.Error("Web Audio is not supported by your browser."), ve.audioEngine.WarnedWebAudioUnsupported = !0), this._readyToPlayCallback && setTimeout(function() {
              h._readyToPlayCallback && h._readyToPlayCallback();
            }, 1e3);
      }
      return Object.defineProperty(n.prototype, "loop", { get: function() {
        return this._loop;
      }, set: function(t) {
        t !== this._loop && (this._loop = t, this.updateOptions({ loop: t }));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "currentTime", { get: function() {
        var t;
        if (this._htmlAudioElement)
          return this._htmlAudioElement.currentTime;
        if (!((t = ve.audioEngine) === null || t === void 0) && t.audioContext && (this.isPlaying || this.isPaused)) {
          var e = this.isPaused ? 0 : ve.audioEngine.audioContext.currentTime - this._startTime;
          return this._currentTime + e;
        }
        return 0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "spatialSound", { get: function() {
        return this._spatialSound;
      }, set: function(t) {
        if (t != this._spatialSound) {
          var e = this.isPlaying;
          this.pause(), t ? (this._spatialSound = t, this._updateSpatialParameters()) : this._disableSpatialSound(), e && this.play();
        }
      }, enumerable: !1, configurable: !0 }), n.prototype.dispose = function() {
        var t;
        !((t = ve.audioEngine) === null || t === void 0) && t.canUseWebAudio && (this.isPlaying && this.stop(), this._isReadyToPlay = !1, this.soundTrackId === -1 ? this._scene.mainSoundTrack.removeSound(this) : this._scene.soundTracks && this._scene.soundTracks[this.soundTrackId].removeSound(this), this._soundGain && (this._soundGain.disconnect(), this._soundGain = null), this._soundPanner && (this._soundPanner.disconnect(), this._soundPanner = null), this._soundSource && (this._soundSource.disconnect(), this._soundSource = null), this._audioBuffer = null, this._htmlAudioElement && (this._htmlAudioElement.pause(), this._htmlAudioElement.src = "", document.body.removeChild(this._htmlAudioElement)), this._streamingSource && this._streamingSource.disconnect(), this._connectedTransformNode && this._registerFunc && (this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc), this._connectedTransformNode = null), this._clearTimeoutsAndObservers());
      }, n.prototype.isReady = function() {
        return this._isReadyToPlay;
      }, n.prototype.getClassName = function() {
        return "Sound";
      }, n.prototype._audioBufferLoaded = function(t) {
        var e;
        !((e = ve.audioEngine) === null || e === void 0) && e.audioContext && (this._audioBuffer = t, this._isReadyToPlay = !0, this.autoplay && this.play(0, this._offset, this._length), this._readyToPlayCallback && this._readyToPlayCallback());
      }, n.prototype._soundLoaded = function(t) {
        var e, i = this;
        !((e = ve.audioEngine) === null || e === void 0) && e.audioContext && ve.audioEngine.audioContext.decodeAudioData(t, function(r) {
          i._audioBufferLoaded(r);
        }, function(r) {
          q.Error("Error while decoding audio data for: " + i.name + " / Error: " + r);
        });
      }, n.prototype.setAudioBuffer = function(t) {
        var e;
        !((e = ve.audioEngine) === null || e === void 0) && e.canUseWebAudio && (this._audioBuffer = t, this._isReadyToPlay = !0);
      }, n.prototype.updateOptions = function(t) {
        var e, i, r, o, a, s, l, c, u, h, d;
        t && (this.loop = (e = t.loop) !== null && e !== void 0 ? e : this.loop, this.maxDistance = (i = t.maxDistance) !== null && i !== void 0 ? i : this.maxDistance, this.useCustomAttenuation = (r = t.useCustomAttenuation) !== null && r !== void 0 ? r : this.useCustomAttenuation, this.rolloffFactor = (o = t.rolloffFactor) !== null && o !== void 0 ? o : this.rolloffFactor, this.refDistance = (a = t.refDistance) !== null && a !== void 0 ? a : this.refDistance, this.distanceModel = (s = t.distanceModel) !== null && s !== void 0 ? s : this.distanceModel, this._playbackRate = (l = t.playbackRate) !== null && l !== void 0 ? l : this._playbackRate, this._length = (c = t.length) !== null && c !== void 0 ? c : void 0, this.spatialSound = (u = t.spatialSound) !== null && u !== void 0 ? u : this._spatialSound, this._setOffset((h = t.offset) !== null && h !== void 0 ? h : void 0), this.setVolume((d = t.volume) !== null && d !== void 0 ? d : this._volume), this._updateSpatialParameters(), this.isPlaying && (this._streaming && this._htmlAudioElement ? (this._htmlAudioElement.playbackRate = this._playbackRate, this._htmlAudioElement.loop !== this.loop && (this._htmlAudioElement.loop = this.loop)) : this._soundSource && (this._soundSource.playbackRate.value = this._playbackRate, this._soundSource.loop !== this.loop && (this._soundSource.loop = this.loop), this._offset !== void 0 && this._soundSource.loopStart !== this._offset && (this._soundSource.loopStart = this._offset), this._length !== void 0 && this._length !== this._soundSource.loopEnd && (this._soundSource.loopEnd = (0 | this._offset) + this._length))));
      }, n.prototype._createSpatialParameters = function() {
        var t, e;
        !((t = ve.audioEngine) === null || t === void 0) && t.canUseWebAudio && ve.audioEngine.audioContext && (this._scene.headphone && (this._panningModel = "HRTF"), this._soundPanner = (e = this._soundPanner) !== null && e !== void 0 ? e : ve.audioEngine.audioContext.createPanner(), this._soundPanner && this._outputAudioNode && (this._updateSpatialParameters(), this._soundPanner.connect(this._outputAudioNode), this._inputAudioNode = this._soundPanner));
      }, n.prototype._disableSpatialSound = function() {
        var t;
        this._spatialSound && (this._inputAudioNode = this._soundGain, (t = this._soundPanner) === null || t === void 0 || t.disconnect(), this._soundPanner = null, this._spatialSound = !1);
      }, n.prototype._updateSpatialParameters = function() {
        this._spatialSound && (this._soundPanner ? this.useCustomAttenuation ? (this._soundPanner.distanceModel = "linear", this._soundPanner.maxDistance = Number.MAX_VALUE, this._soundPanner.refDistance = 1, this._soundPanner.rolloffFactor = 1, this._soundPanner.panningModel = this._panningModel) : (this._soundPanner.distanceModel = this.distanceModel, this._soundPanner.maxDistance = this.maxDistance, this._soundPanner.refDistance = this.refDistance, this._soundPanner.rolloffFactor = this.rolloffFactor, this._soundPanner.panningModel = this._panningModel) : this._createSpatialParameters());
      }, n.prototype.switchPanningModelToHRTF = function() {
        this._panningModel = "HRTF", this._switchPanningModel();
      }, n.prototype.switchPanningModelToEqualPower = function() {
        this._panningModel = "equalpower", this._switchPanningModel();
      }, n.prototype._switchPanningModel = function() {
        var t;
        !((t = ve.audioEngine) === null || t === void 0) && t.canUseWebAudio && this._spatialSound && this._soundPanner && (this._soundPanner.panningModel = this._panningModel);
      }, n.prototype.connectToSoundTrackAudioNode = function(t) {
        var e;
        !((e = ve.audioEngine) === null || e === void 0) && e.canUseWebAudio && this._outputAudioNode && (this._isOutputConnected && this._outputAudioNode.disconnect(), this._outputAudioNode.connect(t), this._isOutputConnected = !0);
      }, n.prototype.setDirectionalCone = function(t, e, i) {
        e < t ? q.Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.") : (this._coneInnerAngle = t, this._coneOuterAngle = e, this._coneOuterGain = i, this._isDirectional = !0, this.isPlaying && this.loop && (this.stop(), this.play(0, this._offset, this._length)));
      }, Object.defineProperty(n.prototype, "directionalConeInnerAngle", { get: function() {
        return this._coneInnerAngle;
      }, set: function(t) {
        var e;
        if (t != this._coneInnerAngle) {
          if (this._coneOuterAngle < t)
            return void q.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
          this._coneInnerAngle = t, !((e = ve.audioEngine) === null || e === void 0) && e.canUseWebAudio && this._spatialSound && this._soundPanner && (this._soundPanner.coneInnerAngle = this._coneInnerAngle);
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "directionalConeOuterAngle", { get: function() {
        return this._coneOuterAngle;
      }, set: function(t) {
        var e;
        if (t != this._coneOuterAngle) {
          if (t < this._coneInnerAngle)
            return void q.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
          this._coneOuterAngle = t, !((e = ve.audioEngine) === null || e === void 0) && e.canUseWebAudio && this._spatialSound && this._soundPanner && (this._soundPanner.coneOuterAngle = this._coneOuterAngle);
        }
      }, enumerable: !1, configurable: !0 }), n.prototype.setPosition = function(t) {
        var e;
        t.equals(this._position) || (this._position.copyFrom(t), !((e = ve.audioEngine) === null || e === void 0) && e.canUseWebAudio && this._spatialSound && this._soundPanner && !isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z) && (this._soundPanner.positionX.value = this._position.x, this._soundPanner.positionY.value = this._position.y, this._soundPanner.positionZ.value = this._position.z));
      }, n.prototype.setLocalDirectionToMesh = function(t) {
        var e;
        this._localDirection = t, !((e = ve.audioEngine) === null || e === void 0) && e.canUseWebAudio && this._connectedTransformNode && this.isPlaying && this._updateDirection();
      }, n.prototype._updateDirection = function() {
        if (this._connectedTransformNode && this._soundPanner) {
          var t = this._connectedTransformNode.getWorldMatrix(), e = v.TransformNormal(this._localDirection, t);
          e.normalize(), this._soundPanner.orientationX.value = e.x, this._soundPanner.orientationY.value = e.y, this._soundPanner.orientationZ.value = e.z;
        }
      }, n.prototype.updateDistanceFromListener = function() {
        var t;
        if (!((t = ve.audioEngine) === null || t === void 0) && t.canUseWebAudio && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {
          var e = this._scene.audioListenerPositionProvider ? this._connectedTransformNode.position.subtract(this._scene.audioListenerPositionProvider()).length() : this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);
          this._soundGain.gain.value = this._customAttenuationFunction(this._volume, e, this.maxDistance, this.refDistance, this.rolloffFactor);
        }
      }, n.prototype.setAttenuationFunction = function(t) {
        this._customAttenuationFunction = t;
      }, n.prototype.play = function(t, e, i) {
        var r, o, a, s, l = this;
        if (this._isReadyToPlay && this._scene.audioEnabled && (!((r = ve.audioEngine) === null || r === void 0) && r.audioContext))
          try {
            this._clearTimeoutsAndObservers();
            var c = t ? ((o = ve.audioEngine) === null || o === void 0 ? void 0 : o.audioContext.currentTime) + t : (a = ve.audioEngine) === null || a === void 0 ? void 0 : a.audioContext.currentTime;
            if (this._soundSource && this._streamingSource || this._spatialSound && this._soundPanner && (isNaN(this._position.x) || isNaN(this._position.y) || isNaN(this._position.z) || (this._soundPanner.positionX.value = this._position.x, this._soundPanner.positionY.value = this._position.y, this._soundPanner.positionZ.value = this._position.z), this._isDirectional && (this._soundPanner.coneInnerAngle = this._coneInnerAngle, this._soundPanner.coneOuterAngle = this._coneOuterAngle, this._soundPanner.coneOuterGain = this._coneOuterGain, this._connectedTransformNode ? this._updateDirection() : this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z))), this._streaming) {
              if (this._streamingSource || (this._streamingSource = ve.audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement), this._htmlAudioElement.onended = function() {
                l._onended();
              }, this._htmlAudioElement.playbackRate = this._playbackRate), this._streamingSource.disconnect(), this._inputAudioNode && this._streamingSource.connect(this._inputAudioNode), this._htmlAudioElement) {
                var u = function() {
                  var d, p;
                  if (!((d = ve.audioEngine) === null || d === void 0) && d.unlocked) {
                    var f = l._htmlAudioElement.play();
                    f !== void 0 && f.catch(function() {
                      var m, g;
                      (m = ve.audioEngine) === null || m === void 0 || m.lock(), (l.loop || l.autoplay) && (l._audioUnlockedObserver = (g = ve.audioEngine) === null || g === void 0 ? void 0 : g.onAudioUnlockedObservable.addOnce(function() {
                        u();
                      }));
                    });
                  } else
                    (l.loop || l.autoplay) && (l._audioUnlockedObserver = (p = ve.audioEngine) === null || p === void 0 ? void 0 : p.onAudioUnlockedObservable.addOnce(function() {
                      u();
                    }));
                };
                u();
              }
            } else {
              var h = function() {
                var d, p, f, m;
                if (!((d = ve.audioEngine) === null || d === void 0) && d.audioContext) {
                  if (i = i || l._length, e !== void 0 && l._setOffset(e), l._soundSource) {
                    var g = l._soundSource;
                    g.onended = function() {
                      g.disconnect();
                    };
                  }
                  if (l._soundSource = (p = ve.audioEngine) === null || p === void 0 ? void 0 : p.audioContext.createBufferSource(), l._soundSource && l._inputAudioNode) {
                    l._soundSource.buffer = l._audioBuffer, l._soundSource.connect(l._inputAudioNode), l._soundSource.loop = l.loop, e !== void 0 && (l._soundSource.loopStart = e), i !== void 0 && (l._soundSource.loopEnd = (0 | e) + i), l._soundSource.playbackRate.value = l._playbackRate, l._soundSource.onended = function() {
                      l._onended();
                    }, c = t ? ((f = ve.audioEngine) === null || f === void 0 ? void 0 : f.audioContext.currentTime) + t : ve.audioEngine.audioContext.currentTime;
                    var y = ((l.isPaused ? l.currentTime : 0) + ((m = l._offset) !== null && m !== void 0 ? m : 0)) % l._soundSource.buffer.duration;
                    l._soundSource.start(c, y, l.loop ? void 0 : i);
                  }
                }
              };
              ((s = ve.audioEngine) === null || s === void 0 ? void 0 : s.audioContext.state) === "suspended" ? this._tryToPlayTimeout = setTimeout(function() {
                var d;
                ((d = ve.audioEngine) === null || d === void 0 ? void 0 : d.audioContext.state) === "suspended" ? (ve.audioEngine.lock(), (l.loop || l.autoplay) && (l._audioUnlockedObserver = ve.audioEngine.onAudioUnlockedObservable.addOnce(function() {
                  h();
                }))) : h();
              }, 500) : h();
            }
            this._startTime = c, this.isPlaying = !0, this.isPaused = !1;
          } catch (d) {
            q.Error("Error while trying to play audio: " + this.name + ", " + d.message);
          }
      }, n.prototype._onended = function() {
        this.isPlaying = !1, this._startTime = 0, this._currentTime = 0, this.onended && this.onended(), this.onEndedObservable.notifyObservers(this);
      }, n.prototype.stop = function(t) {
        var e, i = this;
        if (this.isPlaying)
          if (this._clearTimeoutsAndObservers(), this._streaming)
            this._htmlAudioElement ? (this._htmlAudioElement.pause(), this._htmlAudioElement.currentTime > 0 && (this._htmlAudioElement.currentTime = 0)) : this._streamingSource.disconnect(), this.isPlaying = !1;
          else if (!((e = ve.audioEngine) === null || e === void 0) && e.audioContext && this._soundSource) {
            var r = t ? ve.audioEngine.audioContext.currentTime + t : void 0;
            this._soundSource.onended = function() {
              i.isPlaying = !1, i.isPaused = !1, i._startTime = 0, i._currentTime = 0, i._soundSource && (i._soundSource.onended = function() {
              }), i._onended();
            }, this._soundSource.stop(r);
          } else
            this.isPlaying = !1;
        else
          this.isPaused && (this.isPaused = !1, this._startTime = 0, this._currentTime = 0);
      }, n.prototype.pause = function() {
        var t;
        this.isPlaying && (this._clearTimeoutsAndObservers(), this._streaming ? (this._htmlAudioElement ? this._htmlAudioElement.pause() : this._streamingSource.disconnect(), this.isPlaying = !1, this.isPaused = !0) : !((t = ve.audioEngine) === null || t === void 0) && t.audioContext && this._soundSource && (this._soundSource.onended = function() {
        }, this._soundSource.stop(), this.isPlaying = !1, this.isPaused = !0, this._currentTime += ve.audioEngine.audioContext.currentTime - this._startTime));
      }, n.prototype.setVolume = function(t, e) {
        var i;
        !((i = ve.audioEngine) === null || i === void 0) && i.canUseWebAudio && this._soundGain && (e && ve.audioEngine.audioContext ? (this._soundGain.gain.cancelScheduledValues(ve.audioEngine.audioContext.currentTime), this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, ve.audioEngine.audioContext.currentTime), this._soundGain.gain.linearRampToValueAtTime(t, ve.audioEngine.audioContext.currentTime + e)) : this._soundGain.gain.value = t), this._volume = t;
      }, n.prototype.setPlaybackRate = function(t) {
        this._playbackRate = t, this.isPlaying && (this._streaming && this._htmlAudioElement ? this._htmlAudioElement.playbackRate = this._playbackRate : this._soundSource && (this._soundSource.playbackRate.value = this._playbackRate));
      }, n.prototype.getPlaybackRate = function() {
        return this._playbackRate;
      }, n.prototype.getVolume = function() {
        return this._volume;
      }, n.prototype.attachToMesh = function(t) {
        var e = this;
        this._connectedTransformNode && this._registerFunc && (this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc), this._registerFunc = null), this._connectedTransformNode = t, this._spatialSound || (this._spatialSound = !0, this._createSpatialParameters(), this.isPlaying && this.loop && (this.stop(), this.play(0, this._offset, this._length))), this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode), this._registerFunc = function(i) {
          return e._onRegisterAfterWorldMatrixUpdate(i);
        }, this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc);
      }, n.prototype.detachFromMesh = function() {
        this._connectedTransformNode && this._registerFunc && (this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc), this._registerFunc = null, this._connectedTransformNode = null);
      }, n.prototype._onRegisterAfterWorldMatrixUpdate = function(t) {
        var e;
        if (t.getBoundingInfo) {
          var i = t.getBoundingInfo();
          this.setPosition(i.boundingSphere.centerWorld);
        } else
          this.setPosition(t.absolutePosition);
        !((e = ve.audioEngine) === null || e === void 0) && e.canUseWebAudio && this._isDirectional && this.isPlaying && this._updateDirection();
      }, n.prototype.clone = function() {
        var t = this;
        if (this._streaming)
          return null;
        var e = function() {
          t._isReadyToPlay ? (r._audioBuffer = t.getAudioBuffer(), r._isReadyToPlay = !0, r.autoplay && r.play(0, t._offset, t._length)) : setTimeout(e, 300);
        }, i = { autoplay: this.autoplay, loop: this.loop, volume: this._volume, spatialSound: this._spatialSound, maxDistance: this.maxDistance, useCustomAttenuation: this.useCustomAttenuation, rolloffFactor: this.rolloffFactor, refDistance: this.refDistance, distanceModel: this.distanceModel }, r = new n(this.name + "_cloned", new ArrayBuffer(0), this._scene, null, i);
        return this.useCustomAttenuation && r.setAttenuationFunction(this._customAttenuationFunction), r.setPosition(this._position), r.setPlaybackRate(this._playbackRate), e(), r;
      }, n.prototype.getAudioBuffer = function() {
        return this._audioBuffer;
      }, n.prototype.getSoundSource = function() {
        return this._soundSource;
      }, n.prototype.getSoundGain = function() {
        return this._soundGain;
      }, n.prototype.serialize = function() {
        var t = { name: this.name, url: this._url, autoplay: this.autoplay, loop: this.loop, volume: this._volume, spatialSound: this._spatialSound, maxDistance: this.maxDistance, rolloffFactor: this.rolloffFactor, refDistance: this.refDistance, distanceModel: this.distanceModel, playbackRate: this._playbackRate, panningModel: this._panningModel, soundTrackId: this.soundTrackId, metadata: this.metadata };
        return this._spatialSound && (this._connectedTransformNode && (t.connectedMeshId = this._connectedTransformNode.id), t.position = this._position.asArray(), t.refDistance = this.refDistance, t.distanceModel = this.distanceModel, t.isDirectional = this._isDirectional, t.localDirectionToMesh = this._localDirection.asArray(), t.coneInnerAngle = this._coneInnerAngle, t.coneOuterAngle = this._coneOuterAngle, t.coneOuterGain = this._coneOuterGain), t;
      }, n.Parse = function(t, e, i, r) {
        var o, a = t.name;
        o = t.url ? i + t.url : i + a;
        var s, l = { autoplay: t.autoplay, loop: t.loop, volume: t.volume, spatialSound: t.spatialSound, maxDistance: t.maxDistance, rolloffFactor: t.rolloffFactor, refDistance: t.refDistance, distanceModel: t.distanceModel, playbackRate: t.playbackRate };
        if (r) {
          var c = function() {
            r._isReadyToPlay ? (s._audioBuffer = r.getAudioBuffer(), s._isReadyToPlay = !0, s.autoplay && s.play(0, s._offset, s._length)) : setTimeout(c, 300);
          };
          s = new n(a, new ArrayBuffer(0), e, null, l), c();
        } else
          s = new n(a, o, e, function() {
            e.removePendingData(s);
          }, l), e.addPendingData(s);
        if (t.position) {
          var u = v.FromArray(t.position);
          s.setPosition(u);
        }
        if (t.isDirectional && (s.setDirectionalCone(t.coneInnerAngle || 360, t.coneOuterAngle || 360, t.coneOuterGain || 0), t.localDirectionToMesh)) {
          var h = v.FromArray(t.localDirectionToMesh);
          s.setLocalDirectionToMesh(h);
        }
        if (t.connectedMeshId) {
          var d = e.getMeshById(t.connectedMeshId);
          d && s.attachToMesh(d);
        }
        return t.metadata && (s.metadata = t.metadata), s;
      }, n.prototype._setOffset = function(t) {
        this._offset !== t && (this.isPaused && (this.stop(), this.isPaused = !1), this._offset = t);
      }, n.prototype._clearTimeoutsAndObservers = function() {
        var t;
        this._tryToPlayTimeout && (clearTimeout(this._tryToPlayTimeout), this._tryToPlayTimeout = null), this._audioUnlockedObserver && ((t = ve.audioEngine) === null || t === void 0 || t.onAudioUnlockedObservable.remove(this._audioUnlockedObserver), this._audioUnlockedObserver = null);
      }, n._SceneComponentInitialization = function(t) {
        throw et("AudioSceneComponent");
      }, n;
    }(), Pg = function() {
      function n(t, e) {
        e === void 0 && (e = {}), this.id = -1, this._isInitialized = !1, (t = t || Me.LastCreatedScene) && (this._scene = t, this.soundCollection = [], this._options = e, !this._options.mainTrack && this._scene.soundTracks && (this._scene.soundTracks.push(this), this.id = this._scene.soundTracks.length - 1));
      }
      return n.prototype._initializeSoundTrackAudioGraph = function() {
        var t;
        !((t = ve.audioEngine) === null || t === void 0) && t.canUseWebAudio && ve.audioEngine.audioContext && (this._outputAudioNode = ve.audioEngine.audioContext.createGain(), this._outputAudioNode.connect(ve.audioEngine.masterGain), this._options && this._options.volume && (this._outputAudioNode.gain.value = this._options.volume), this._isInitialized = !0);
      }, n.prototype.dispose = function() {
        if (ve.audioEngine && ve.audioEngine.canUseWebAudio) {
          for (this._connectedAnalyser && this._connectedAnalyser.stopDebugCanvas(); this.soundCollection.length; )
            this.soundCollection[0].dispose();
          this._outputAudioNode && this._outputAudioNode.disconnect(), this._outputAudioNode = null;
        }
      }, n.prototype.addSound = function(t) {
        var e;
        this._isInitialized || this._initializeSoundTrackAudioGraph(), !((e = ve.audioEngine) === null || e === void 0) && e.canUseWebAudio && this._outputAudioNode && t.connectToSoundTrackAudioNode(this._outputAudioNode), t.soundTrackId !== void 0 && (t.soundTrackId === -1 ? this._scene.mainSoundTrack.removeSound(t) : this._scene.soundTracks && this._scene.soundTracks[t.soundTrackId].removeSound(t)), this.soundCollection.push(t), t.soundTrackId = this.id;
      }, n.prototype.removeSound = function(t) {
        var e = this.soundCollection.indexOf(t);
        e !== -1 && this.soundCollection.splice(e, 1);
      }, n.prototype.setVolume = function(t) {
        var e;
        !((e = ve.audioEngine) === null || e === void 0) && e.canUseWebAudio && this._outputAudioNode && (this._outputAudioNode.gain.value = t);
      }, n.prototype.switchPanningModelToHRTF = function() {
        var t;
        if (!((t = ve.audioEngine) === null || t === void 0) && t.canUseWebAudio)
          for (var e = 0; e < this.soundCollection.length; e++)
            this.soundCollection[e].switchPanningModelToHRTF();
      }, n.prototype.switchPanningModelToEqualPower = function() {
        var t;
        if (!((t = ve.audioEngine) === null || t === void 0) && t.canUseWebAudio)
          for (var e = 0; e < this.soundCollection.length; e++)
            this.soundCollection[e].switchPanningModelToEqualPower();
      }, n.prototype.connectToAnalyser = function(t) {
        var e;
        this._connectedAnalyser && this._connectedAnalyser.stopDebugCanvas(), this._connectedAnalyser = t, !((e = ve.audioEngine) === null || e === void 0) && e.canUseWebAudio && this._outputAudioNode && (this._outputAudioNode.disconnect(), this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, ve.audioEngine.masterGain));
      }, n;
    }();
    pe.AddParser(we.NAME_AUDIO, function(n, t, e, i) {
      var r, o, a = [];
      if (e.sounds = e.sounds || [], n.sounds !== void 0 && n.sounds !== null)
        for (var s = 0, l = n.sounds.length; s < l; s++) {
          var c = n.sounds[s];
          !((r = ve.audioEngine) === null || r === void 0) && r.canUseWebAudio ? (c.url || (c.url = c.name), a[c.url] ? e.sounds.push(_s.Parse(c, t, i, a[c.url])) : (o = _s.Parse(c, t, i), a[c.url] = o, e.sounds.push(o))) : e.sounds.push(new _s(c.name, null, t));
        }
      a = [];
    }), Object.defineProperty(Ue.prototype, "mainSoundTrack", { get: function() {
      var n = this._getComponent(we.NAME_AUDIO);
      return n || (n = new Rr(this), this._addComponent(n)), this._mainSoundTrack || (this._mainSoundTrack = new Pg(this, { mainTrack: !0 })), this._mainSoundTrack;
    }, enumerable: !0, configurable: !0 }), Ue.prototype.getSoundByName = function(n) {
      var t;
      for (t = 0; t < this.mainSoundTrack.soundCollection.length; t++)
        if (this.mainSoundTrack.soundCollection[t].name === n)
          return this.mainSoundTrack.soundCollection[t];
      if (this.soundTracks) {
        for (var e = 0; e < this.soundTracks.length; e++)
          for (t = 0; t < this.soundTracks[e].soundCollection.length; t++)
            if (this.soundTracks[e].soundCollection[t].name === n)
              return this.soundTracks[e].soundCollection[t];
      }
      return null;
    }, Object.defineProperty(Ue.prototype, "audioEnabled", { get: function() {
      var n = this._getComponent(we.NAME_AUDIO);
      return n || (n = new Rr(this), this._addComponent(n)), n.audioEnabled;
    }, set: function(n) {
      var t = this._getComponent(we.NAME_AUDIO);
      t || (t = new Rr(this), this._addComponent(t)), n ? t.enableAudio() : t.disableAudio();
    }, enumerable: !0, configurable: !0 }), Object.defineProperty(Ue.prototype, "headphone", { get: function() {
      var n = this._getComponent(we.NAME_AUDIO);
      return n || (n = new Rr(this), this._addComponent(n)), n.headphone;
    }, set: function(n) {
      var t = this._getComponent(we.NAME_AUDIO);
      t || (t = new Rr(this), this._addComponent(t)), n ? t.switchAudioModeForHeadphones() : t.switchAudioModeForNormalSpeakers();
    }, enumerable: !0, configurable: !0 }), Object.defineProperty(Ue.prototype, "audioListenerPositionProvider", { get: function() {
      var n = this._getComponent(we.NAME_AUDIO);
      return n || (n = new Rr(this), this._addComponent(n)), n.audioListenerPositionProvider;
    }, set: function(n) {
      var t = this._getComponent(we.NAME_AUDIO);
      if (t || (t = new Rr(this), this._addComponent(t)), n && typeof n != "function")
        throw new Error("The value passed to [Scene.audioListenerPositionProvider] must be a function that returns a Vector3");
      t.audioListenerPositionProvider = n;
    }, enumerable: !0, configurable: !0 }), Object.defineProperty(Ue.prototype, "audioListenerRotationProvider", { get: function() {
      var n = this._getComponent(we.NAME_AUDIO);
      return n || (n = new Rr(this), this._addComponent(n)), n.audioListenerRotationProvider;
    }, set: function(n) {
      var t = this._getComponent(we.NAME_AUDIO);
      if (t || (t = new Rr(this), this._addComponent(t)), n && typeof n != "function")
        throw new Error("The value passed to [Scene.audioListenerRotationProvider] must be a function that returns a Vector3");
      t.audioListenerRotationProvider = n;
    }, enumerable: !0, configurable: !0 }), Object.defineProperty(Ue.prototype, "audioPositioningRefreshRate", { get: function() {
      var n = this._getComponent(we.NAME_AUDIO);
      return n || (n = new Rr(this), this._addComponent(n)), n.audioPositioningRefreshRate;
    }, set: function(n) {
      var t = this._getComponent(we.NAME_AUDIO);
      t || (t = new Rr(this), this._addComponent(t)), t.audioPositioningRefreshRate = n;
    }, enumerable: !0, configurable: !0 });
    var Rr = function() {
      function n(t) {
        this.name = we.NAME_AUDIO, this._audioEnabled = !0, this._headphone = !1, this.audioPositioningRefreshRate = 500, this.audioListenerPositionProvider = null, this.audioListenerRotationProvider = null, this._cachedCameraDirection = new v(), this._cachedCameraPosition = new v(), this._lastCheck = 0, this._invertMatrixTemp = new B(), this._cameraDirectionTemp = new v(), (t = t || Me.LastCreatedScene) && (this.scene = t, t.soundTracks = [], t.sounds = []);
      }
      return Object.defineProperty(n.prototype, "audioEnabled", { get: function() {
        return this._audioEnabled;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "headphone", { get: function() {
        return this._headphone;
      }, enumerable: !1, configurable: !0 }), n.prototype.register = function() {
        this.scene._afterRenderStage.registerStep(we.STEP_AFTERRENDER_AUDIO, this, this._afterRender);
      }, n.prototype.rebuild = function() {
      }, n.prototype.serialize = function(t) {
        if (t.sounds = [], this.scene.soundTracks)
          for (var e = 0; e < this.scene.soundTracks.length; e++)
            for (var i = this.scene.soundTracks[e], r = 0; r < i.soundCollection.length; r++)
              t.sounds.push(i.soundCollection[r].serialize());
      }, n.prototype.addFromContainer = function(t) {
        var e = this;
        t.sounds && t.sounds.forEach(function(i) {
          i.play(), i.autoplay = !0, e.scene.mainSoundTrack.addSound(i);
        });
      }, n.prototype.removeFromContainer = function(t, e) {
        var i = this;
        e === void 0 && (e = !1), t.sounds && t.sounds.forEach(function(r) {
          r.stop(), r.autoplay = !1, i.scene.mainSoundTrack.removeSound(r), e && r.dispose();
        });
      }, n.prototype.dispose = function() {
        var t = this.scene;
        if (t._mainSoundTrack && t.mainSoundTrack.dispose(), t.soundTracks)
          for (var e = 0; e < t.soundTracks.length; e++)
            t.soundTracks[e].dispose();
      }, n.prototype.disableAudio = function() {
        var t, e = this.scene;
        for (this._audioEnabled = !1, ve.audioEngine && ve.audioEngine.audioContext && ve.audioEngine.audioContext.suspend(), t = 0; t < e.mainSoundTrack.soundCollection.length; t++)
          e.mainSoundTrack.soundCollection[t].pause();
        if (e.soundTracks)
          for (t = 0; t < e.soundTracks.length; t++)
            for (var i = 0; i < e.soundTracks[t].soundCollection.length; i++)
              e.soundTracks[t].soundCollection[i].pause();
      }, n.prototype.enableAudio = function() {
        var t, e = this.scene;
        for (this._audioEnabled = !0, ve.audioEngine && ve.audioEngine.audioContext && ve.audioEngine.audioContext.resume(), t = 0; t < e.mainSoundTrack.soundCollection.length; t++)
          e.mainSoundTrack.soundCollection[t].isPaused && e.mainSoundTrack.soundCollection[t].play();
        if (e.soundTracks)
          for (t = 0; t < e.soundTracks.length; t++)
            for (var i = 0; i < e.soundTracks[t].soundCollection.length; i++)
              e.soundTracks[t].soundCollection[i].isPaused && e.soundTracks[t].soundCollection[i].play();
      }, n.prototype.switchAudioModeForHeadphones = function() {
        var t = this.scene;
        if (this._headphone = !0, t.mainSoundTrack.switchPanningModelToHRTF(), t.soundTracks)
          for (var e = 0; e < t.soundTracks.length; e++)
            t.soundTracks[e].switchPanningModelToHRTF();
      }, n.prototype.switchAudioModeForNormalSpeakers = function() {
        var t = this.scene;
        if (this._headphone = !1, t.mainSoundTrack.switchPanningModelToEqualPower(), t.soundTracks)
          for (var e = 0; e < t.soundTracks.length; e++)
            t.soundTracks[e].switchPanningModelToEqualPower();
      }, n.prototype._afterRender = function() {
        var t = It.Now;
        if (!(this._lastCheck && t - this._lastCheck < this.audioPositioningRefreshRate)) {
          this._lastCheck = t;
          var e = this.scene;
          if (this._audioEnabled && e._mainSoundTrack && e.soundTracks && (e._mainSoundTrack.soundCollection.length !== 0 || e.soundTracks.length !== 1)) {
            var i = ve.audioEngine;
            if (i && i.audioContext) {
              var r = e.activeCamera;
              if (e.activeCameras && e.activeCameras.length > 0 && (r = e.activeCameras[0]), this.audioListenerPositionProvider) {
                var o = this.audioListenerPositionProvider();
                i.audioContext.listener.setPosition(o.x || 0, o.y || 0, o.z || 0);
              } else
                r ? this._cachedCameraPosition.equals(r.globalPosition) || (this._cachedCameraPosition.copyFrom(r.globalPosition), i.audioContext.listener.setPosition(r.globalPosition.x, r.globalPosition.y, r.globalPosition.z)) : i.audioContext.listener.setPosition(0, 0, 0);
              if (this.audioListenerRotationProvider) {
                var a = this.audioListenerRotationProvider();
                i.audioContext.listener.setOrientation(a.x || 0, a.y || 0, a.z || 0, 0, 1, 0);
              } else
                r ? (r.rigCameras && r.rigCameras.length > 0 && (r = r.rigCameras[0]), r.getViewMatrix().invertToRef(this._invertMatrixTemp), v.TransformNormalToRef(n._CameraDirection, this._invertMatrixTemp, this._cameraDirectionTemp), this._cameraDirectionTemp.normalize(), isNaN(this._cameraDirectionTemp.x) || isNaN(this._cameraDirectionTemp.y) || isNaN(this._cameraDirectionTemp.z) || this._cachedCameraDirection.equals(this._cameraDirectionTemp) || (this._cachedCameraDirection.copyFrom(this._cameraDirectionTemp), i.audioContext.listener.setOrientation(this._cameraDirectionTemp.x, this._cameraDirectionTemp.y, this._cameraDirectionTemp.z, 0, 1, 0))) : i.audioContext.listener.setOrientation(0, 0, 0, 0, 1, 0);
              var s = void 0;
              for (s = 0; s < e.mainSoundTrack.soundCollection.length; s++)
                (c = e.mainSoundTrack.soundCollection[s]).useCustomAttenuation && c.updateDistanceFromListener();
              if (e.soundTracks)
                for (s = 0; s < e.soundTracks.length; s++)
                  for (var l = 0; l < e.soundTracks[s].soundCollection.length; l++) {
                    var c;
                    (c = e.soundTracks[s].soundCollection[l]).useCustomAttenuation && c.updateDistanceFromListener();
                  }
            }
          }
        }
      }, n._CameraDirection = new v(0, 0, -1), n;
    }();
    _s._SceneComponentInitialization = function(n) {
      var t = n._getComponent(we.NAME_AUDIO);
      t || (t = new Rr(n), n._addComponent(t));
    };
    var lR = function() {
      function n(t, e, i) {
        var r = this;
        if (this.loop = !1, this._coneInnerAngle = 360, this._coneOuterAngle = 360, this._volume = 1, this.isPlaying = !1, this.isPaused = !1, this._sounds = [], this._weights = [], e.length !== i.length)
          throw new Error("Sounds length does not equal weights length");
        this.loop = t, this._weights = i;
        for (var o = 0, a = 0, s = i; a < s.length; a++)
          o += s[a];
        for (var l = o > 0 ? 1 / o : 0, c = 0; c < this._weights.length; c++)
          this._weights[c] *= l;
        this._sounds = e;
        for (var u = 0, h = this._sounds; u < h.length; u++)
          h[u].onEndedObservable.add(function() {
            r._onended();
          });
      }
      return Object.defineProperty(n.prototype, "directionalConeInnerAngle", { get: function() {
        return this._coneInnerAngle;
      }, set: function(t) {
        if (t !== this._coneInnerAngle) {
          if (this._coneOuterAngle < t)
            return void q.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
          this._coneInnerAngle = t;
          for (var e = 0, i = this._sounds; e < i.length; e++)
            i[e].directionalConeInnerAngle = t;
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "directionalConeOuterAngle", { get: function() {
        return this._coneOuterAngle;
      }, set: function(t) {
        if (t !== this._coneOuterAngle) {
          if (t < this._coneInnerAngle)
            return void q.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
          this._coneOuterAngle = t;
          for (var e = 0, i = this._sounds; e < i.length; e++)
            i[e].directionalConeOuterAngle = t;
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "volume", { get: function() {
        return this._volume;
      }, set: function(t) {
        if (t !== this._volume)
          for (var e = 0, i = this._sounds; e < i.length; e++)
            i[e].setVolume(t);
      }, enumerable: !1, configurable: !0 }), n.prototype._onended = function() {
        this._currentIndex !== void 0 && (this._sounds[this._currentIndex].autoplay = !1), this.loop && this.isPlaying ? this.play() : this.isPlaying = !1;
      }, n.prototype.pause = function() {
        this.isPaused = !0, this._currentIndex !== void 0 && this._sounds[this._currentIndex].pause();
      }, n.prototype.stop = function() {
        this.isPlaying = !1, this._currentIndex !== void 0 && this._sounds[this._currentIndex].stop();
      }, n.prototype.play = function(t) {
        if (!this.isPaused) {
          this.stop();
          for (var e = Math.random(), i = 0, r = 0; r < this._weights.length; r++)
            if (e <= (i += this._weights[r])) {
              this._currentIndex = r;
              break;
            }
        }
        var o = this._sounds[this._currentIndex];
        o.isReady() ? o.play(0, this.isPaused ? void 0 : t) : o.autoplay = !0, this.isPlaying = !0, this.isPaused = !1;
      }, n;
    }(), cR = function() {
      function n(t) {
        this._texture = null, this._isEnabled = !0, this.isEnabled = !0, this.time = 0, (t = t || Me.LastCreatedScene) && (this._scene = t, this.animationParameters = new lt(0, 0, 0, 30));
      }
      return n.prototype._markSubMeshesAsAttributesDirty = function() {
        for (var t = 0, e = this._scene.meshes; t < e.length; t++) {
          var i = e[t];
          i.bakedVertexAnimationManager === this && i._markSubMeshesAsAttributesDirty();
        }
      }, n.prototype.bind = function(t, e) {
        if (e === void 0 && (e = !1), this._texture && this._isEnabled) {
          var i = this._texture.getSize();
          t.setFloat2("bakedVertexAnimationTextureSizeInverted", 1 / i.width, 1 / i.height), t.setFloat("bakedVertexAnimationTime", this.time), e || t.setVector4("bakedVertexAnimationSettings", this.animationParameters), t.setTexture("bakedVertexAnimationTexture", this._texture);
        }
      }, n.prototype.clone = function() {
        var t = new n(this._scene);
        return this.copyTo(t), t;
      }, n.prototype.setAnimationParameters = function(t, e, i, r) {
        i === void 0 && (i = 0), r === void 0 && (r = 30), this.animationParameters = new lt(t, e, i, r);
      }, n.prototype.dispose = function(t) {
        var e;
        t && ((e = this._texture) === null || e === void 0 || e.dispose());
      }, n.prototype.getClassName = function() {
        return "BakedVertexAnimationManager";
      }, n.prototype.copyTo = function(t) {
        Ne.Clone(function() {
          return t;
        }, this);
      }, n.prototype.serialize = function() {
        return Ne.Serialize(this);
      }, n.prototype.parse = function(t, e, i) {
        var r = this;
        Ne.Parse(function() {
          return r;
        }, t, e, i);
      }, x([St(), ye("_markSubMeshesAsAttributesDirty")], n.prototype, "texture", void 0), x([N(), ye("_markSubMeshesAsAttributesDirty")], n.prototype, "isEnabled", void 0), x([N()], n.prototype, "animationParameters", void 0), x([N()], n.prototype, "time", void 0), n;
    }(), ms = function() {
      function n(t) {
        this._wrapU = _.TEXTURE_WRAP_ADDRESSMODE, this._wrapV = _.TEXTURE_WRAP_ADDRESSMODE, this.wrapR = _.TEXTURE_WRAP_ADDRESSMODE, this.anisotropicFilteringLevel = 4, this.delayLoadState = _.DELAYLOADSTATE_NONE, this._texture = null, this._engine = null, this._cachedSize = el.Zero(), this._cachedBaseSize = el.Zero(), this._initialSamplingMode = _.TEXTURE_BILINEAR_SAMPLINGMODE, this._texture = n._IsRenderTargetWrapper(t) ? t.texture : t, this._texture && (this._engine = this._texture.getEngine());
      }
      return Object.defineProperty(n.prototype, "wrapU", { get: function() {
        return this._wrapU;
      }, set: function(t) {
        this._wrapU = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "wrapV", { get: function() {
        return this._wrapV;
      }, set: function(t) {
        this._wrapV = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "coordinatesMode", { get: function() {
        return 0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isCube", { get: function() {
        return !!this._texture && this._texture.isCube;
      }, set: function(t) {
        this._texture && (this._texture.isCube = t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "is3D", { get: function() {
        return !!this._texture && this._texture.is3D;
      }, set: function(t) {
        this._texture && (this._texture.is3D = t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "is2DArray", { get: function() {
        return !!this._texture && this._texture.is2DArray;
      }, set: function(t) {
        this._texture && (this._texture.is2DArray = t);
      }, enumerable: !1, configurable: !0 }), n.prototype.getClassName = function() {
        return "ThinTexture";
      }, n._IsRenderTargetWrapper = function(t) {
        return (t == null ? void 0 : t._shareDepth) !== void 0;
      }, n.prototype.isReady = function() {
        return this.delayLoadState === _.DELAYLOADSTATE_NOTLOADED ? (this.delayLoad(), !1) : !!this._texture && this._texture.isReady;
      }, n.prototype.delayLoad = function() {
      }, n.prototype.getInternalTexture = function() {
        return this._texture;
      }, n.prototype.getSize = function() {
        if (this._texture) {
          if (this._texture.width)
            return this._cachedSize.width = this._texture.width, this._cachedSize.height = this._texture.height, this._cachedSize;
          if (this._texture._size)
            return this._cachedSize.width = this._texture._size, this._cachedSize.height = this._texture._size, this._cachedSize;
        }
        return this._cachedSize;
      }, n.prototype.getBaseSize = function() {
        return this.isReady() && this._texture ? this._texture._size ? (this._cachedBaseSize.width = this._texture._size, this._cachedBaseSize.height = this._texture._size, this._cachedBaseSize) : (this._cachedBaseSize.width = this._texture.baseWidth, this._cachedBaseSize.height = this._texture.baseHeight, this._cachedBaseSize) : (this._cachedBaseSize.width = 0, this._cachedBaseSize.height = 0, this._cachedBaseSize);
      }, Object.defineProperty(n.prototype, "samplingMode", { get: function() {
        return this._texture ? this._texture.samplingMode : this._initialSamplingMode;
      }, enumerable: !1, configurable: !0 }), n.prototype.updateSamplingMode = function(t) {
        this._texture && this._engine && this._engine.updateTextureSamplingMode(t, this._texture);
      }, n.prototype.releaseInternalTexture = function() {
        this._texture && (this._texture.dispose(), this._texture = null);
      }, n.prototype.dispose = function() {
        this._texture && (this.releaseInternalTexture(), this._engine = null);
      }, n;
    }(), Vn = function(n) {
      function t(e, i) {
        i === void 0 && (i = null);
        var r = n.call(this, null) || this;
        return r.metadata = null, r.reservedDataStore = null, r._hasAlpha = !1, r._getAlphaFromRGB = !1, r.level = 1, r._coordinatesIndex = 0, r.optimizeUVAllocation = !0, r._coordinatesMode = _.TEXTURE_EXPLICIT_MODE, r.wrapR = _.TEXTURE_WRAP_ADDRESSMODE, r.anisotropicFilteringLevel = t.DEFAULT_ANISOTROPIC_FILTERING_LEVEL, r._isCube = !1, r._gammaSpace = !0, r.invertZ = !1, r.lodLevelInAlpha = !1, r.isRenderTarget = !1, r._prefiltered = !1, r._forceSerialize = !1, r.animations = [], r.onDisposeObservable = new H(), r._onDisposeObserver = null, r._scene = null, r._uid = null, r._parentContainer = null, r._loadingError = !1, e ? t._IsScene(e) ? r._scene = e : r._engine = e : r._scene = Me.LastCreatedScene, r._scene && (r.uniqueId = r._scene.getUniqueId(), r._scene.addTexture(r), r._engine = r._scene.getEngine()), r._texture = i, r._uid = null, r;
      }
      return D(t, n), Object.defineProperty(t.prototype, "hasAlpha", { get: function() {
        return this._hasAlpha;
      }, set: function(e) {
        var i = this;
        this._hasAlpha !== e && (this._hasAlpha = e, this._scene && this._scene.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag, function(r) {
          return r.hasTexture(i);
        }));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "getAlphaFromRGB", { get: function() {
        return this._getAlphaFromRGB;
      }, set: function(e) {
        var i = this;
        this._getAlphaFromRGB !== e && (this._getAlphaFromRGB = e, this._scene && this._scene.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag, function(r) {
          return r.hasTexture(i);
        }));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "coordinatesIndex", { get: function() {
        return this._coordinatesIndex;
      }, set: function(e) {
        var i = this;
        this._coordinatesIndex !== e && (this._coordinatesIndex = e, this._scene && this._scene.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag, function(r) {
          return r.hasTexture(i);
        }));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "coordinatesMode", { get: function() {
        return this._coordinatesMode;
      }, set: function(e) {
        var i = this;
        this._coordinatesMode !== e && (this._coordinatesMode = e, this._scene && this._scene.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag, function(r) {
          return r.hasTexture(i);
        }));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wrapU", { get: function() {
        return this._wrapU;
      }, set: function(e) {
        this._wrapU = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wrapV", { get: function() {
        return this._wrapV;
      }, set: function(e) {
        this._wrapV = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isCube", { get: function() {
        return this._texture ? this._texture.isCube : this._isCube;
      }, set: function(e) {
        this._texture ? this._texture.isCube = e : this._isCube = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "is3D", { get: function() {
        return !!this._texture && this._texture.is3D;
      }, set: function(e) {
        this._texture && (this._texture.is3D = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "is2DArray", { get: function() {
        return !!this._texture && this._texture.is2DArray;
      }, set: function(e) {
        this._texture && (this._texture.is2DArray = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "gammaSpace", { get: function() {
        return this._texture ? (this._texture._gammaSpace === null && (this._texture._gammaSpace = this._gammaSpace), this._texture._gammaSpace && !this._texture._useSRGBBuffer) : this._gammaSpace;
      }, set: function(e) {
        var i, r = this;
        if (this._texture) {
          if (this._texture._gammaSpace === e)
            return;
          this._texture._gammaSpace = e;
        } else {
          if (this._gammaSpace === e)
            return;
          this._gammaSpace = e;
        }
        (i = this.getScene()) === null || i === void 0 || i.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag, function(o) {
          return o.hasTexture(r);
        });
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isRGBD", { get: function() {
        return this._texture != null && this._texture._isRGBD;
      }, set: function(e) {
        var i, r = this;
        e !== this.isRGBD && (this._texture && (this._texture._isRGBD = e), (i = this.getScene()) === null || i === void 0 || i.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag, function(o) {
          return o.hasTexture(r);
        }));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "noMipmap", { get: function() {
        return !1;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "lodGenerationOffset", { get: function() {
        return this._texture ? this._texture._lodGenerationOffset : 0;
      }, set: function(e) {
        this._texture && (this._texture._lodGenerationOffset = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "lodGenerationScale", { get: function() {
        return this._texture ? this._texture._lodGenerationScale : 0;
      }, set: function(e) {
        this._texture && (this._texture._lodGenerationScale = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "linearSpecularLOD", { get: function() {
        return !!this._texture && this._texture._linearSpecularLOD;
      }, set: function(e) {
        this._texture && (this._texture._linearSpecularLOD = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "irradianceTexture", { get: function() {
        return this._texture ? this._texture._irradianceTexture : null;
      }, set: function(e) {
        this._texture && (this._texture._irradianceTexture = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "uid", { get: function() {
        return this._uid || (this._uid = ra()), this._uid;
      }, enumerable: !1, configurable: !0 }), t.prototype.toString = function() {
        return this.name;
      }, t.prototype.getClassName = function() {
        return "BaseTexture";
      }, Object.defineProperty(t.prototype, "onDispose", { set: function(e) {
        this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver), this._onDisposeObserver = this.onDisposeObservable.add(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isBlocking", { get: function() {
        return !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "loadingError", { get: function() {
        return this._loadingError;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "errorObject", { get: function() {
        return this._errorObject;
      }, enumerable: !1, configurable: !0 }), t.prototype.getScene = function() {
        return this._scene;
      }, t.prototype._getEngine = function() {
        return this._engine;
      }, t.prototype.checkTransformsAreIdentical = function(e) {
        return e !== null;
      }, t.prototype.getTextureMatrix = function() {
        return B.IdentityReadOnly;
      }, t.prototype.getReflectionTextureMatrix = function() {
        return B.IdentityReadOnly;
      }, t.prototype.getRefractionTextureMatrix = function() {
        return this.getReflectionTextureMatrix();
      }, t.prototype.isReadyOrNotBlocking = function() {
        return !this.isBlocking || this.isReady() || this.loadingError;
      }, t.prototype.scale = function(e) {
      }, Object.defineProperty(t.prototype, "canRescale", { get: function() {
        return !1;
      }, enumerable: !1, configurable: !0 }), t.prototype._getFromCache = function(e, i, r, o, a, s) {
        var l = this._getEngine();
        if (!l)
          return null;
        for (var c = l._getUseSRGBBuffer(!!a, i), u = l.getLoadedTexturesCache(), h = 0; h < u.length; h++) {
          var d = u[h];
          if (!(a !== void 0 && c !== d._useSRGBBuffer || o !== void 0 && o !== d.invertY || d.url !== e || d.generateMipMaps !== !i || r && r !== d.samplingMode || s !== void 0 && s !== d.isCube))
            return d.incrementReferences(), d;
        }
        return null;
      }, t.prototype._rebuild = function() {
      }, t.prototype.clone = function() {
        return null;
      }, Object.defineProperty(t.prototype, "textureType", { get: function() {
        return this._texture && this._texture.type !== void 0 ? this._texture.type : _.TEXTURETYPE_UNSIGNED_INT;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "textureFormat", { get: function() {
        return this._texture && this._texture.format !== void 0 ? this._texture.format : _.TEXTUREFORMAT_RGBA;
      }, enumerable: !1, configurable: !0 }), t.prototype._markAllSubMeshesAsTexturesDirty = function() {
        var e = this.getScene();
        e && e.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag);
      }, t.prototype.readPixels = function(e, i, r, o, a, s, l, c, u) {
        if (e === void 0 && (e = 0), i === void 0 && (i = 0), r === void 0 && (r = null), o === void 0 && (o = !0), a === void 0 && (a = !1), s === void 0 && (s = 0), l === void 0 && (l = 0), c === void 0 && (c = Number.MAX_VALUE), u === void 0 && (u = Number.MAX_VALUE), !this._texture)
          return null;
        var h = this._getEngine();
        if (!h)
          return null;
        var d = this.getSize(), p = d.width, f = d.height;
        i !== 0 && (p /= Math.pow(2, i), f /= Math.pow(2, i), p = Math.round(p), f = Math.round(f)), c = Math.min(p, c), u = Math.min(f, u);
        try {
          return this._texture.isCube ? h._readTexturePixels(this._texture, c, u, e, i, r, o, a, s, l) : h._readTexturePixels(this._texture, c, u, -1, i, r, o, a, s, l);
        } catch {
          return null;
        }
      }, t.prototype._readPixelsSync = function(e, i, r, o, a) {
        if (e === void 0 && (e = 0), i === void 0 && (i = 0), r === void 0 && (r = null), o === void 0 && (o = !0), a === void 0 && (a = !1), !this._texture)
          return null;
        var s = this.getSize(), l = s.width, c = s.height, u = this._getEngine();
        if (!u)
          return null;
        i != 0 && (l /= Math.pow(2, i), c /= Math.pow(2, i), l = Math.round(l), c = Math.round(c));
        try {
          return this._texture.isCube ? u._readTexturePixelsSync(this._texture, l, c, e, i, r, o, a) : u._readTexturePixelsSync(this._texture, l, c, -1, i, r, o, a);
        } catch {
          return null;
        }
      }, Object.defineProperty(t.prototype, "_lodTextureHigh", { get: function() {
        return this._texture ? this._texture._lodTextureHigh : null;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "_lodTextureMid", { get: function() {
        return this._texture ? this._texture._lodTextureMid : null;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "_lodTextureLow", { get: function() {
        return this._texture ? this._texture._lodTextureLow : null;
      }, enumerable: !1, configurable: !0 }), t.prototype.dispose = function() {
        if (this._scene) {
          this._scene.stopAnimation && this._scene.stopAnimation(this), this._scene.removePendingData(this);
          var e = this._scene.textures.indexOf(this);
          if (e >= 0 && this._scene.textures.splice(e, 1), this._scene.onTextureRemovedObservable.notifyObservers(this), this._scene = null, this._parentContainer) {
            var i = this._parentContainer.textures.indexOf(this);
            i > -1 && this._parentContainer.textures.splice(i, 1), this._parentContainer = null;
          }
        }
        this.onDisposeObservable.notifyObservers(this), this.onDisposeObservable.clear(), this.metadata = null, n.prototype.dispose.call(this);
      }, t.prototype.serialize = function(e) {
        if (e === void 0 && (e = !1), !this.name && !e)
          return null;
        var i = Ne.Serialize(this);
        return Ne.AppendSerializedAnimations(this, i), i;
      }, t.WhenAllReady = function(e, i) {
        var r = e.length;
        if (r !== 0)
          for (var o = 0; o < e.length; o++) {
            var a = e[o];
            if (a.isReady())
              --r == 0 && i();
            else {
              var s = a.onLoadObservable;
              s ? s.addOnce(function() {
                --r == 0 && i();
              }) : --r == 0 && i();
            }
          }
        else
          i();
      }, t._IsScene = function(e) {
        return e.getClassName() === "Scene";
      }, t.DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4, x([N()], t.prototype, "uniqueId", void 0), x([N()], t.prototype, "name", void 0), x([N()], t.prototype, "metadata", void 0), x([N("hasAlpha")], t.prototype, "_hasAlpha", void 0), x([N("getAlphaFromRGB")], t.prototype, "_getAlphaFromRGB", void 0), x([N()], t.prototype, "level", void 0), x([N("coordinatesIndex")], t.prototype, "_coordinatesIndex", void 0), x([N()], t.prototype, "optimizeUVAllocation", void 0), x([N("coordinatesMode")], t.prototype, "_coordinatesMode", void 0), x([N()], t.prototype, "wrapU", null), x([N()], t.prototype, "wrapV", null), x([N()], t.prototype, "wrapR", void 0), x([N()], t.prototype, "anisotropicFilteringLevel", void 0), x([N()], t.prototype, "isCube", null), x([N()], t.prototype, "is3D", null), x([N()], t.prototype, "is2DArray", null), x([N()], t.prototype, "gammaSpace", null), x([N()], t.prototype, "invertZ", void 0), x([N()], t.prototype, "lodLevelInAlpha", void 0), x([N()], t.prototype, "lodGenerationOffset", null), x([N()], t.prototype, "lodGenerationScale", null), x([N()], t.prototype, "linearSpecularLOD", null), x([St()], t.prototype, "irradianceTexture", null), x([N()], t.prototype, "isRenderTarget", void 0), t;
    }(ms);
    function Qu(n, t, e) {
      e === void 0 && (e = !1);
      var i = t.width, r = t.height;
      if (n instanceof Float32Array) {
        for (var o = n.byteLength / n.BYTES_PER_ELEMENT, a = new Uint8Array(o); --o >= 0; ) {
          var s = n[o];
          s < 0 ? s = 0 : s > 1 && (s = 1), a[o] = 255 * s;
        }
        n = a;
      }
      var l = document.createElement("canvas");
      l.width = i, l.height = r;
      var c = l.getContext("2d");
      if (!c)
        return null;
      var u = c.createImageData(i, r);
      if (u.data.set(n), c.putImageData(u, 0, 0), e) {
        var h = document.createElement("canvas");
        h.width = i, h.height = r;
        var d = h.getContext("2d");
        return d ? (d.translate(0, r), d.scale(1, -1), d.drawImage(l, 0, 0), h.toDataURL("image/png")) : null;
      }
      return l.toDataURL("image/png");
    }
    function Cp(n, t, e) {
      t === void 0 && (t = 0), e === void 0 && (e = 0);
      var i = n.getInternalTexture();
      if (!i)
        return null;
      var r = n._readPixelsSync(t, e);
      return r ? Qu(r, n.getSize(), i.invertY) : null;
    }
    function Pp(n, t, e) {
      return t === void 0 && (t = 0), e === void 0 && (e = 0), Ft(this, void 0, void 0, function() {
        var i, r;
        return Bt(this, function(o) {
          switch (o.label) {
            case 0:
              return (i = n.getInternalTexture()) ? [4, n.readPixels(t, e)] : [2, null];
            case 1:
              return (r = o.sent()) ? [2, Qu(r, n.getSize(), i.invertY)] : [2, null];
          }
        });
      });
    }
    var uR = { GenerateBase64StringFromPixelData: Qu, GenerateBase64StringFromTexture: Cp, GenerateBase64StringFromTextureAsync: Pp }, ae = function(n) {
      function t(e, i, r, o, a, s, l, c, u, h, d, p, f, m) {
        a === void 0 && (a = t.TRILINEAR_SAMPLINGMODE), s === void 0 && (s = null), l === void 0 && (l = null), c === void 0 && (c = null), u === void 0 && (u = !1);
        var g, y, b, T, S, E, A, R, C, L, I, O = this;
        (O = n.call(this, i) || this).url = null, O.uOffset = 0, O.vOffset = 0, O.uScale = 1, O.vScale = 1, O.uAng = 0, O.vAng = 0, O.wAng = 0, O.uRotationCenter = 0.5, O.vRotationCenter = 0.5, O.wRotationCenter = 0.5, O.homogeneousRotationInUVTransform = !1, O.inspectableCustomProperties = null, O._noMipmap = !1, O._invertY = !1, O._rowGenerationMatrix = null, O._cachedTextureMatrix = null, O._projectionModeMatrix = null, O._t0 = null, O._t1 = null, O._t2 = null, O._cachedUOffset = -1, O._cachedVOffset = -1, O._cachedUScale = 0, O._cachedVScale = 0, O._cachedUAng = -1, O._cachedVAng = -1, O._cachedWAng = -1, O._cachedReflectionProjectionMatrixId = -1, O._cachedURotationCenter = -1, O._cachedVRotationCenter = -1, O._cachedWRotationCenter = -1, O._cachedHomogeneousRotationInUVTransform = !1, O._cachedReflectionTextureMatrix = null, O._cachedReflectionUOffset = -1, O._cachedReflectionVOffset = -1, O._cachedReflectionUScale = 0, O._cachedReflectionVScale = 0, O._cachedReflectionCoordinatesMode = -1, O._buffer = null, O._deleteBuffer = !1, O._format = null, O._delayedOnLoad = null, O._delayedOnError = null, O.onLoadObservable = new H(), O._isBlocking = !0, O.name = e || "", O.url = e;
        var w = !1, z = null, V = !0;
        typeof r == "object" && r !== null ? (I = (g = r.noMipmap) !== null && g !== void 0 && g, o = (y = r.invertY) !== null && y !== void 0 ? y : !Lt.UseOpenGLOrientationForUV, a = (b = r.samplingMode) !== null && b !== void 0 ? b : t.TRILINEAR_SAMPLINGMODE, s = (T = r.onLoad) !== null && T !== void 0 ? T : null, l = (S = r.onError) !== null && S !== void 0 ? S : null, c = (E = r.buffer) !== null && E !== void 0 ? E : null, u = (A = r.deleteBuffer) !== null && A !== void 0 && A, h = r.format, d = r.mimeType, p = r.loaderOptions, f = r.creationFlags, w = (R = r.useSRGBBuffer) !== null && R !== void 0 && R, z = (C = r.internalTexture) !== null && C !== void 0 ? C : null, V = (L = r.gammaSpace) !== null && L !== void 0 ? L : V) : I = !!r, O._gammaSpace = V, O._noMipmap = I, O._invertY = o === void 0 ? !Lt.UseOpenGLOrientationForUV : o, O._initialSamplingMode = a, O._buffer = c, O._deleteBuffer = u, O._mimeType = d, O._loaderOptions = p, O._creationFlags = f, O._useSRGBBuffer = w, O._forcedExtension = m, h && (O._format = h);
        var Y = O.getScene(), ee = O._getEngine();
        if (!ee)
          return O;
        ee.onBeforeTextureInitObservable.notifyObservers(O);
        var J = function() {
          O._texture && (O._texture._invertVScale && (O.vScale *= -1, O.vOffset += 1), O._texture._cachedWrapU !== null && (O.wrapU = O._texture._cachedWrapU, O._texture._cachedWrapU = null), O._texture._cachedWrapV !== null && (O.wrapV = O._texture._cachedWrapV, O._texture._cachedWrapV = null), O._texture._cachedWrapR !== null && (O.wrapR = O._texture._cachedWrapR, O._texture._cachedWrapR = null)), O.onLoadObservable.hasObservers() && O.onLoadObservable.notifyObservers(O), s && s(), !O.isBlocking && Y && Y.resetCachedMaterial();
        }, X = function(te, se) {
          O._loadingError = !0, O._errorObject = { message: te, exception: se }, l && l(te, se), t.OnTextureLoadErrorObservable.notifyObservers(O);
        };
        if (!O.url && !z)
          return O._delayedOnLoad = J, O._delayedOnError = X, O;
        if (O._texture = z ?? O._getFromCache(O.url, I, a, O._invertY, w, O.isCube), O._texture)
          if (O._texture.isReady)
            ec.SetImmediate(function() {
              return J();
            });
          else {
            var K = O._texture.onLoadedObservable.add(J);
            O._texture.onErrorObservable.add(function(te) {
              var se;
              X(te.message, te.exception), (se = O._texture) === null || se === void 0 || se.onLoadedObservable.remove(K);
            });
          }
        else if (Y && Y.useDelayedTextureLoading)
          O.delayLoadState = _.DELAYLOADSTATE_NOTLOADED, O._delayedOnLoad = J, O._delayedOnError = X;
        else {
          try {
            O._texture = ee.createTexture(O.url, I, O._invertY, Y, a, J, X, O._buffer, void 0, O._format, O._forcedExtension, d, p, f, w);
          } catch (te) {
            throw X("error loading", te), te;
          }
          u && (O._buffer = null);
        }
        return O;
      }
      return D(t, n), t._CreateVideoTexture = function(e, i, r, o, a, s, l, c, u) {
        throw s === void 0 && (s = t.TRILINEAR_SAMPLINGMODE), u === void 0 && (u = _.TEXTUREFORMAT_RGBA), et("VideoTexture");
      }, Object.defineProperty(t.prototype, "noMipmap", { get: function() {
        return this._noMipmap;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "mimeType", { get: function() {
        return this._mimeType;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isBlocking", { get: function() {
        return this._isBlocking;
      }, set: function(e) {
        this._isBlocking = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "invertY", { get: function() {
        return this._invertY;
      }, enumerable: !1, configurable: !0 }), t.prototype.updateURL = function(e, i, r, o) {
        var a = this;
        i === void 0 && (i = null), this.url && (this.releaseInternalTexture(), this.getScene().markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag, function(s) {
          return s.hasTexture(a);
        })), this.name && !this.name.startsWith("data:") || (this.name = e), this.url = e, this._buffer = i, this._forcedExtension = o, this.delayLoadState = _.DELAYLOADSTATE_NOTLOADED, r && (this._delayedOnLoad = r), this.delayLoad();
      }, t.prototype.delayLoad = function() {
        if (this.delayLoadState === _.DELAYLOADSTATE_NOTLOADED) {
          var e = this.getScene();
          e && (this.delayLoadState = _.DELAYLOADSTATE_LOADED, this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode, this._invertY, this._useSRGBBuffer, this.isCube), this._texture ? this._delayedOnLoad && (this._texture.isReady ? ec.SetImmediate(this._delayedOnLoad) : this._texture.onLoadedObservable.add(this._delayedOnLoad)) : (this._texture = e.getEngine().createTexture(this.url, this._noMipmap, this._invertY, e, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format, this._forcedExtension, this._mimeType, this._loaderOptions, this._creationFlags, this._useSRGBBuffer), this._deleteBuffer && (this._buffer = null)), this._delayedOnLoad = null, this._delayedOnError = null);
        }
      }, t.prototype._prepareRowForTextureGeneration = function(e, i, r, o) {
        e *= this._cachedUScale, i *= this._cachedVScale, e -= this.uRotationCenter * this._cachedUScale, i -= this.vRotationCenter * this._cachedVScale, r -= this.wRotationCenter, v.TransformCoordinatesFromFloatsToRef(e, i, r, this._rowGenerationMatrix, o), o.x += this.uRotationCenter * this._cachedUScale + this._cachedUOffset, o.y += this.vRotationCenter * this._cachedVScale + this._cachedVOffset, o.z += this.wRotationCenter;
      }, t.prototype.checkTransformsAreIdentical = function(e) {
        return e !== null && this.uOffset === e.uOffset && this.vOffset === e.vOffset && this.uScale === e.uScale && this.vScale === e.vScale && this.uAng === e.uAng && this.vAng === e.vAng && this.wAng === e.wAng;
      }, t.prototype.getTextureMatrix = function(e) {
        var i = this;
        if (e === void 0 && (e = 1), this.uOffset === this._cachedUOffset && this.vOffset === this._cachedVOffset && this.uScale * e === this._cachedUScale && this.vScale === this._cachedVScale && this.uAng === this._cachedUAng && this.vAng === this._cachedVAng && this.wAng === this._cachedWAng && this.uRotationCenter === this._cachedURotationCenter && this.vRotationCenter === this._cachedVRotationCenter && this.wRotationCenter === this._cachedWRotationCenter && this.homogeneousRotationInUVTransform === this._cachedHomogeneousRotationInUVTransform)
          return this._cachedTextureMatrix;
        this._cachedUOffset = this.uOffset, this._cachedVOffset = this.vOffset, this._cachedUScale = this.uScale * e, this._cachedVScale = this.vScale, this._cachedUAng = this.uAng, this._cachedVAng = this.vAng, this._cachedWAng = this.wAng, this._cachedURotationCenter = this.uRotationCenter, this._cachedVRotationCenter = this.vRotationCenter, this._cachedWRotationCenter = this.wRotationCenter, this._cachedHomogeneousRotationInUVTransform = this.homogeneousRotationInUVTransform, this._cachedTextureMatrix && this._rowGenerationMatrix || (this._cachedTextureMatrix = B.Zero(), this._rowGenerationMatrix = new B(), this._t0 = v.Zero(), this._t1 = v.Zero(), this._t2 = v.Zero()), B.RotationYawPitchRollToRef(this.vAng, this.uAng, this.wAng, this._rowGenerationMatrix), this.homogeneousRotationInUVTransform ? (B.TranslationToRef(-this._cachedURotationCenter, -this._cachedVRotationCenter, -this._cachedWRotationCenter, F.Matrix[0]), B.TranslationToRef(this._cachedURotationCenter, this._cachedVRotationCenter, this._cachedWRotationCenter, F.Matrix[1]), B.ScalingToRef(this._cachedUScale, this._cachedVScale, 0, F.Matrix[2]), B.TranslationToRef(this._cachedUOffset, this._cachedVOffset, 0, F.Matrix[3]), F.Matrix[0].multiplyToRef(this._rowGenerationMatrix, this._cachedTextureMatrix), this._cachedTextureMatrix.multiplyToRef(F.Matrix[1], this._cachedTextureMatrix), this._cachedTextureMatrix.multiplyToRef(F.Matrix[2], this._cachedTextureMatrix), this._cachedTextureMatrix.multiplyToRef(F.Matrix[3], this._cachedTextureMatrix), this._cachedTextureMatrix.setRowFromFloats(2, this._cachedTextureMatrix.m[12], this._cachedTextureMatrix.m[13], this._cachedTextureMatrix.m[14], 1)) : (this._prepareRowForTextureGeneration(0, 0, 0, this._t0), this._prepareRowForTextureGeneration(1, 0, 0, this._t1), this._prepareRowForTextureGeneration(0, 1, 0, this._t2), this._t1.subtractInPlace(this._t0), this._t2.subtractInPlace(this._t0), B.FromValuesToRef(this._t1.x, this._t1.y, this._t1.z, 0, this._t2.x, this._t2.y, this._t2.z, 0, this._t0.x, this._t0.y, this._t0.z, 0, 0, 0, 0, 1, this._cachedTextureMatrix));
        var r = this.getScene();
        return r ? (this.optimizeUVAllocation && r.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag, function(o) {
          return o.hasTexture(i);
        }), this._cachedTextureMatrix) : this._cachedTextureMatrix;
      }, t.prototype.getReflectionTextureMatrix = function() {
        var e = this, i = this.getScene();
        if (!i)
          return this._cachedReflectionTextureMatrix;
        if (this.uOffset === this._cachedReflectionUOffset && this.vOffset === this._cachedReflectionVOffset && this.uScale === this._cachedReflectionUScale && this.vScale === this._cachedReflectionVScale && this.coordinatesMode === this._cachedReflectionCoordinatesMode) {
          if (this.coordinatesMode !== t.PROJECTION_MODE)
            return this._cachedReflectionTextureMatrix;
          if (this._cachedReflectionProjectionMatrixId === i.getProjectionMatrix().updateFlag)
            return this._cachedReflectionTextureMatrix;
        }
        this._cachedReflectionTextureMatrix || (this._cachedReflectionTextureMatrix = B.Zero()), this._projectionModeMatrix || (this._projectionModeMatrix = B.Zero());
        var r = this._cachedReflectionCoordinatesMode !== this.coordinatesMode;
        switch (this._cachedReflectionUOffset = this.uOffset, this._cachedReflectionVOffset = this.vOffset, this._cachedReflectionUScale = this.uScale, this._cachedReflectionVScale = this.vScale, this._cachedReflectionCoordinatesMode = this.coordinatesMode, this.coordinatesMode) {
          case t.PLANAR_MODE:
            B.IdentityToRef(this._cachedReflectionTextureMatrix), this._cachedReflectionTextureMatrix[0] = this.uScale, this._cachedReflectionTextureMatrix[5] = this.vScale, this._cachedReflectionTextureMatrix[12] = this.uOffset, this._cachedReflectionTextureMatrix[13] = this.vOffset;
            break;
          case t.PROJECTION_MODE:
            B.FromValuesToRef(0.5, 0, 0, 0, 0, -0.5, 0, 0, 0, 0, 0, 0, 0.5, 0.5, 1, 1, this._projectionModeMatrix);
            var o = i.getProjectionMatrix();
            this._cachedReflectionProjectionMatrixId = o.updateFlag, o.multiplyToRef(this._projectionModeMatrix, this._cachedReflectionTextureMatrix);
            break;
          default:
            B.IdentityToRef(this._cachedReflectionTextureMatrix);
        }
        return r && i.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag, function(a) {
          return a.hasTexture(e);
        }), this._cachedReflectionTextureMatrix;
      }, t.prototype.clone = function() {
        var e = this, i = { noMipmap: this._noMipmap, invertY: this._invertY, samplingMode: this.samplingMode, onLoad: void 0, onError: void 0, buffer: this._texture ? this._texture._buffer : void 0, deleteBuffer: this._deleteBuffer, format: this.textureFormat, mimeType: this.mimeType, loaderOptions: this._loaderOptions, creationFlags: this._creationFlags, useSRGBBuffer: this._useSRGBBuffer };
        return Ne.Clone(function() {
          return new t(e._texture ? e._texture.url : null, e.getScene(), i);
        }, this);
      }, t.prototype.serialize = function() {
        var e, i, r = this.name;
        t.SerializeBuffers || this.name.startsWith("data:") && (this.name = ""), this.name.startsWith("data:") && this.url === this.name && (this.url = "");
        var o = n.prototype.serialize.call(this, t._SerializeInternalTextureUniqueId);
        return o ? ((t.SerializeBuffers || t.ForceSerializeBuffers) && (typeof this._buffer == "string" && this._buffer.substr(0, 5) === "data:" ? (o.base64String = this._buffer, o.name = o.name.replace("data:", "")) : this.url && this.url.startsWith("data:") && this._buffer instanceof Uint8Array ? o.base64String = "data:image/png;base64," + $l(this._buffer) : (t.ForceSerializeBuffers || this.url && this.url.startsWith("blob:") || this._forceSerialize) && (o.base64String = !this._engine || this._engine._features.supportSyncTextureRead ? Cp(this) : Pp(this))), o.invertY = this._invertY, o.samplingMode = this.samplingMode, o._creationFlags = this._creationFlags, o._useSRGBBuffer = this._useSRGBBuffer, t._SerializeInternalTextureUniqueId && (o.internalTextureUniqueId = (i = (e = this._texture) === null || e === void 0 ? void 0 : e.uniqueId) !== null && i !== void 0 ? i : void 0), o.noMipmap = this._noMipmap, this.name = r, o) : null;
      }, t.prototype.getClassName = function() {
        return "Texture";
      }, t.prototype.dispose = function() {
        n.prototype.dispose.call(this), this.onLoadObservable.clear(), this._delayedOnLoad = null, this._delayedOnError = null, this._buffer = null;
      }, t.Parse = function(e, i, r) {
        if (e.customType) {
          var o = hp.Instantiate(e.customType).Parse(e, i, r);
          return e.samplingMode && o.updateSamplingMode && o._samplingMode && o._samplingMode !== e.samplingMode && o.updateSamplingMode(e.samplingMode), o;
        }
        if (e.isCube && !e.isRenderTarget)
          return t._CubeTextureParser(e, i, r);
        var a, s = e.internalTextureUniqueId !== void 0;
        if (!e.name && !e.isRenderTarget && !s)
          return null;
        if (s)
          for (var l = 0, c = i.getEngine().getLoadedTexturesCache(); l < c.length; l++) {
            var u = c[l];
            if (u.uniqueId === e.internalTextureUniqueId) {
              a = u;
              break;
            }
          }
        var h = function(p) {
          var f;
          if (p && p._texture && (p._texture._cachedWrapU = null, p._texture._cachedWrapV = null, p._texture._cachedWrapR = null), e.samplingMode) {
            var m = e.samplingMode;
            p && p.samplingMode !== m && p.updateSamplingMode(m);
          }
          if (p && e.animations)
            for (var g = 0; g < e.animations.length; g++) {
              var y = e.animations[g], b = Kt("BABYLON.Animation");
              b && p.animations.push(b.Parse(y));
            }
          s && !a && ((f = p == null ? void 0 : p._texture) === null || f === void 0 || f._setUniqueId(e.internalTextureUniqueId));
        }, d = Ne.Parse(function() {
          var p, f, m, g, y = !0;
          if (e.noMipmap && (y = !1), e.mirrorPlane) {
            var b = t._CreateMirror(e.name, e.renderTargetSize, i, y);
            return b._waitingRenderList = e.renderList, b.mirrorPlane = xo.FromArray(e.mirrorPlane), h(b), b;
          }
          if (e.isRenderTarget) {
            var T = null;
            if (e.isCube) {
              if (i.reflectionProbes)
                for (var S = 0; S < i.reflectionProbes.length; S++) {
                  var E = i.reflectionProbes[S];
                  if (E.name === e.name)
                    return E.cubeTexture;
                }
            } else
              (T = t._CreateRenderTargetTexture(e.name, e.renderTargetSize, i, y, (p = e._creationFlags) !== null && p !== void 0 ? p : 0))._waitingRenderList = e.renderList;
            return h(T), T;
          }
          if (e.isVideo) {
            var A = t._CreateVideoTexture(r + (e.url || e.name), r + (e.src || e.url), i, y, e.invertY, e.samplingMode, e.settings || {});
            return h(A), A;
          }
          if (e.base64String && !a)
            (g = t.CreateFromBase64String(e.base64String, e.base64String, i, !y, e.invertY, e.samplingMode, function() {
              h(g);
            }, (f = e._creationFlags) !== null && f !== void 0 ? f : 0, (m = e._useSRGBBuffer) !== null && m !== void 0 && m)).name = e.name;
          else {
            var R = void 0;
            R = e.name && (e.name.indexOf("://") > 0 || e.name.startsWith("data:")) ? e.name : r + e.name, e.url && (e.url.startsWith("data:") || t.UseSerializedUrlIfAny) && (R = e.url);
            var C = { noMipmap: !y, invertY: e.invertY, samplingMode: e.samplingMode, onLoad: function() {
              h(g);
            }, internalTexture: a };
            g = new t(R, i, C);
          }
          return g;
        }, e, i);
        return d;
      }, t.CreateFromBase64String = function(e, i, r, o, a, s, l, c, u, h) {
        return s === void 0 && (s = t.TRILINEAR_SAMPLINGMODE), l === void 0 && (l = null), c === void 0 && (c = null), u === void 0 && (u = _.TEXTUREFORMAT_RGBA), new t("data:" + i, r, o, a, s, l, c, e, !1, u, void 0, void 0, h);
      }, t.LoadFromDataString = function(e, i, r, o, a, s, l, c, u, h, d) {
        return o === void 0 && (o = !1), s === void 0 && (s = !0), l === void 0 && (l = t.TRILINEAR_SAMPLINGMODE), c === void 0 && (c = null), u === void 0 && (u = null), h === void 0 && (h = _.TEXTUREFORMAT_RGBA), e.substr(0, 5) !== "data:" && (e = "data:" + e), new t(e, r, a, s, l, c, u, i, o, h, void 0, void 0, d);
      }, t.SerializeBuffers = !0, t.ForceSerializeBuffers = !1, t.OnTextureLoadErrorObservable = new H(), t._SerializeInternalTextureUniqueId = !1, t._CubeTextureParser = function(e, i, r) {
        throw et("CubeTexture");
      }, t._CreateMirror = function(e, i, r, o) {
        throw et("MirrorTexture");
      }, t._CreateRenderTargetTexture = function(e, i, r, o, a) {
        throw et("RenderTargetTexture");
      }, t.NEAREST_SAMPLINGMODE = _.TEXTURE_NEAREST_SAMPLINGMODE, t.NEAREST_NEAREST_MIPLINEAR = _.TEXTURE_NEAREST_NEAREST_MIPLINEAR, t.BILINEAR_SAMPLINGMODE = _.TEXTURE_BILINEAR_SAMPLINGMODE, t.LINEAR_LINEAR_MIPNEAREST = _.TEXTURE_LINEAR_LINEAR_MIPNEAREST, t.TRILINEAR_SAMPLINGMODE = _.TEXTURE_TRILINEAR_SAMPLINGMODE, t.LINEAR_LINEAR_MIPLINEAR = _.TEXTURE_LINEAR_LINEAR_MIPLINEAR, t.NEAREST_NEAREST_MIPNEAREST = _.TEXTURE_NEAREST_NEAREST_MIPNEAREST, t.NEAREST_LINEAR_MIPNEAREST = _.TEXTURE_NEAREST_LINEAR_MIPNEAREST, t.NEAREST_LINEAR_MIPLINEAR = _.TEXTURE_NEAREST_LINEAR_MIPLINEAR, t.NEAREST_LINEAR = _.TEXTURE_NEAREST_LINEAR, t.NEAREST_NEAREST = _.TEXTURE_NEAREST_NEAREST, t.LINEAR_NEAREST_MIPNEAREST = _.TEXTURE_LINEAR_NEAREST_MIPNEAREST, t.LINEAR_NEAREST_MIPLINEAR = _.TEXTURE_LINEAR_NEAREST_MIPLINEAR, t.LINEAR_LINEAR = _.TEXTURE_LINEAR_LINEAR, t.LINEAR_NEAREST = _.TEXTURE_LINEAR_NEAREST, t.EXPLICIT_MODE = _.TEXTURE_EXPLICIT_MODE, t.SPHERICAL_MODE = _.TEXTURE_SPHERICAL_MODE, t.PLANAR_MODE = _.TEXTURE_PLANAR_MODE, t.CUBIC_MODE = _.TEXTURE_CUBIC_MODE, t.PROJECTION_MODE = _.TEXTURE_PROJECTION_MODE, t.SKYBOX_MODE = _.TEXTURE_SKYBOX_MODE, t.INVCUBIC_MODE = _.TEXTURE_INVCUBIC_MODE, t.EQUIRECTANGULAR_MODE = _.TEXTURE_EQUIRECTANGULAR_MODE, t.FIXED_EQUIRECTANGULAR_MODE = _.TEXTURE_FIXED_EQUIRECTANGULAR_MODE, t.FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE, t.CLAMP_ADDRESSMODE = _.TEXTURE_CLAMP_ADDRESSMODE, t.WRAP_ADDRESSMODE = _.TEXTURE_WRAP_ADDRESSMODE, t.MIRROR_ADDRESSMODE = _.TEXTURE_MIRROR_ADDRESSMODE, t.UseSerializedUrlIfAny = !1, x([N()], t.prototype, "url", void 0), x([N()], t.prototype, "uOffset", void 0), x([N()], t.prototype, "vOffset", void 0), x([N()], t.prototype, "uScale", void 0), x([N()], t.prototype, "vScale", void 0), x([N()], t.prototype, "uAng", void 0), x([N()], t.prototype, "vAng", void 0), x([N()], t.prototype, "wAng", void 0), x([N()], t.prototype, "uRotationCenter", void 0), x([N()], t.prototype, "vRotationCenter", void 0), x([N()], t.prototype, "wRotationCenter", void 0), x([N()], t.prototype, "homogeneousRotationInUVTransform", void 0), x([N()], t.prototype, "isBlocking", null), t;
    }(Vn);
    function hR(n, t, e, i) {
      var r, o = 1;
      i === _.TEXTURETYPE_FLOAT ? r = new Float32Array(t * e * 4) : i === _.TEXTURETYPE_HALF_FLOAT ? (r = new Uint16Array(t * e * 4), o = 15360) : r = i === _.TEXTURETYPE_UNSIGNED_INTEGER ? new Uint32Array(t * e * 4) : new Uint8Array(t * e * 4);
      for (var a = 0; a < t; a++)
        for (var s = 0; s < e; s++) {
          var l = 3 * (s * t + a), c = 4 * (s * t + a);
          r[c + 0] = n[l + 0], r[c + 1] = n[l + 1], r[c + 2] = n[l + 2], r[c + 3] = o;
        }
      return r;
    }
    function dR(n) {
      return function(t, e, i, r, o, a, s, l, c, u) {
        c === void 0 && (c = null), u === void 0 && (u = _.TEXTURETYPE_UNSIGNED_INT);
        var h = n ? this._gl.TEXTURE_3D : this._gl.TEXTURE_2D_ARRAY, d = n ? ut.Raw3D : ut.Raw2DArray, p = new Ut(this, d);
        p.baseWidth = e, p.baseHeight = i, p.baseDepth = r, p.width = e, p.height = i, p.depth = r, p.format = o, p.type = u, p.generateMipMaps = a, p.samplingMode = l, n ? p.is3D = !0 : p.is2DArray = !0, this._doNotHandleContextLost || (p._bufferView = t), n ? this.updateRawTexture3D(p, t, o, s, c, u) : this.updateRawTexture2DArray(p, t, o, s, c, u), this._bindTextureDirectly(h, p, !0);
        var f = this._getSamplingParameters(l, a);
        return this._gl.texParameteri(h, this._gl.TEXTURE_MAG_FILTER, f.mag), this._gl.texParameteri(h, this._gl.TEXTURE_MIN_FILTER, f.min), a && this._gl.generateMipmap(h), this._bindTextureDirectly(h, null), this._internalTexturesCache.push(p), p;
      };
    }
    function pR(n) {
      return function(t, e, i, r, o, a) {
        o === void 0 && (o = null), a === void 0 && (a = _.TEXTURETYPE_UNSIGNED_INT);
        var s = n ? this._gl.TEXTURE_3D : this._gl.TEXTURE_2D_ARRAY, l = this._getWebGLTextureType(a), c = this._getInternalFormat(i), u = this._getRGBABufferInternalSizedFormat(a, i);
        this._bindTextureDirectly(s, t, !0), this._unpackFlipY(r === void 0 || !!r), this._doNotHandleContextLost || (t._bufferView = e, t.format = i, t.invertY = r, t._compression = o), t.width % 4 != 0 && this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1), o && e ? this._gl.compressedTexImage3D(s, 0, this.getCaps().s3tc[o], t.width, t.height, t.depth, 0, e) : this._gl.texImage3D(s, 0, u, t.width, t.height, t.depth, 0, c, l, e), t.generateMipMaps && this._gl.generateMipmap(s), this._bindTextureDirectly(s, null), t.isReady = !0;
      };
    }
    j("BABYLON.Texture", ae), Ne._TextureParser = ae.Parse, Qe.prototype.updateRawTexture = function(n, t, e, i, r, o, a) {
      if (r === void 0 && (r = null), o === void 0 && (o = _.TEXTURETYPE_UNSIGNED_INT), a === void 0 && (a = !1), n) {
        var s = this._getRGBABufferInternalSizedFormat(o, e, a), l = this._getInternalFormat(e), c = this._getWebGLTextureType(o);
        this._bindTextureDirectly(this._gl.TEXTURE_2D, n, !0), this._unpackFlipY(i === void 0 || !!i), this._doNotHandleContextLost || (n._bufferView = t, n.format = e, n.type = o, n.invertY = i, n._compression = r), n.width % 4 != 0 && this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1), r && t ? this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[r], n.width, n.height, 0, t) : this._gl.texImage2D(this._gl.TEXTURE_2D, 0, s, n.width, n.height, 0, l, c, t), n.generateMipMaps && this._gl.generateMipmap(this._gl.TEXTURE_2D), this._bindTextureDirectly(this._gl.TEXTURE_2D, null), n.isReady = !0;
      }
    }, Qe.prototype.createRawTexture = function(n, t, e, i, r, o, a, s, l, c, u) {
      s === void 0 && (s = null), l === void 0 && (l = _.TEXTURETYPE_UNSIGNED_INT), u === void 0 && (u = !1);
      var h = new Ut(this, ut.Raw);
      h.baseWidth = t, h.baseHeight = e, h.width = t, h.height = e, h.format = i, h.generateMipMaps = r, h.samplingMode = a, h.invertY = o, h._compression = s, h.type = l, h._useSRGBBuffer = this._getUseSRGBBuffer(u, !r), this._doNotHandleContextLost || (h._bufferView = n), this.updateRawTexture(h, n, i, o, s, l, h._useSRGBBuffer), this._bindTextureDirectly(this._gl.TEXTURE_2D, h, !0);
      var d = this._getSamplingParameters(a, r);
      return this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, d.mag), this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, d.min), r && this._gl.generateMipmap(this._gl.TEXTURE_2D), this._bindTextureDirectly(this._gl.TEXTURE_2D, null), this._internalTexturesCache.push(h), h;
    }, Qe.prototype.createRawCubeTexture = function(n, t, e, i, r, o, a, s) {
      s === void 0 && (s = null);
      var l = this._gl, c = new Ut(this, ut.CubeRaw);
      c.isCube = !0, c.format = e, c.type = i, this._doNotHandleContextLost || (c._bufferViewArray = n);
      var u = this._getWebGLTextureType(i), h = this._getInternalFormat(e);
      h === l.RGB && (h = l.RGBA), u !== l.FLOAT || this._caps.textureFloatLinearFiltering ? u !== this._gl.HALF_FLOAT_OES || this._caps.textureHalfFloatLinearFiltering ? u !== l.FLOAT || this._caps.textureFloatRender ? u !== l.HALF_FLOAT || this._caps.colorBufferFloat || (r = !1, q.Warn("Render to half float textures is not supported. Mipmap generation forced to false.")) : (r = !1, q.Warn("Render to float textures is not supported. Mipmap generation forced to false.")) : (r = !1, a = _.TEXTURE_NEAREST_SAMPLINGMODE, q.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")) : (r = !1, a = _.TEXTURE_NEAREST_SAMPLINGMODE, q.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively."));
      var d = t, p = d;
      if (c.width = d, c.height = p, c.invertY = o, c._compression = s, !this.needPOTTextures || de.IsExponentOfTwo(c.width) && de.IsExponentOfTwo(c.height) || (r = !1), n)
        this.updateRawCubeTexture(c, n, e, i, o, s);
      else {
        var f = this._getRGBABufferInternalSizedFormat(i);
        this._bindTextureDirectly(l.TEXTURE_CUBE_MAP, c, !0);
        for (var m = 0; m < 6; m++)
          s ? l.compressedTexImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X + m, 0, this.getCaps().s3tc[s], c.width, c.height, 0, void 0) : l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X + m, 0, f, c.width, c.height, 0, h, u, null);
        this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
      }
      this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, c, !0), n && r && this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
      var g = this._getSamplingParameters(a, r);
      return l.texParameteri(l.TEXTURE_CUBE_MAP, l.TEXTURE_MAG_FILTER, g.mag), l.texParameteri(l.TEXTURE_CUBE_MAP, l.TEXTURE_MIN_FILTER, g.min), l.texParameteri(l.TEXTURE_CUBE_MAP, l.TEXTURE_WRAP_S, l.CLAMP_TO_EDGE), l.texParameteri(l.TEXTURE_CUBE_MAP, l.TEXTURE_WRAP_T, l.CLAMP_TO_EDGE), this._bindTextureDirectly(l.TEXTURE_CUBE_MAP, null), c.generateMipMaps = r, c.samplingMode = a, c.isReady = !0, c;
    }, Qe.prototype.updateRawCubeTexture = function(n, t, e, i, r, o, a) {
      o === void 0 && (o = null), a === void 0 && (a = 0), n._bufferViewArray = t, n.format = e, n.type = i, n.invertY = r, n._compression = o;
      var s = this._gl, l = this._getWebGLTextureType(i), c = this._getInternalFormat(e), u = this._getRGBABufferInternalSizedFormat(i), h = !1;
      c === s.RGB && (c = s.RGBA, h = !0), this._bindTextureDirectly(s.TEXTURE_CUBE_MAP, n, !0), this._unpackFlipY(r === void 0 || !!r), n.width % 4 != 0 && s.pixelStorei(s.UNPACK_ALIGNMENT, 1);
      for (var d = 0; d < 6; d++) {
        var p = t[d];
        o ? s.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X + d, a, this.getCaps().s3tc[o], n.width, n.height, 0, p) : (h && (p = hR(p, n.width, n.height, i)), s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X + d, a, u, n.width, n.height, 0, c, l, p));
      }
      (!this.needPOTTextures || de.IsExponentOfTwo(n.width) && de.IsExponentOfTwo(n.height)) && n.generateMipMaps && a === 0 && this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP), this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null), n.isReady = !0;
    }, Qe.prototype.createRawCubeTextureFromUrl = function(n, t, e, i, r, o, a, s, l, c, u, h) {
      var d = this;
      l === void 0 && (l = null), c === void 0 && (c = null), u === void 0 && (u = _.TEXTURE_TRILINEAR_SAMPLINGMODE), h === void 0 && (h = !1);
      var p = this._gl, f = this.createRawCubeTexture(null, e, i, r, !o, h, u, null);
      return t == null || t.addPendingData(f), f.url = n, f.isReady = !1, this._internalTexturesCache.push(f), this._loadFile(n, function(m) {
        (function(g) {
          var y = f.width, b = a(g);
          if (b) {
            if (s) {
              var T = d._getWebGLTextureType(r), S = d._getInternalFormat(i), E = d._getRGBABufferInternalSizedFormat(r), A = !1;
              S === p.RGB && (S = p.RGBA, A = !0), d._bindTextureDirectly(p.TEXTURE_CUBE_MAP, f, !0), d._unpackFlipY(!1);
              for (var R = s(b), C = 0; C < R.length; C++)
                for (var L = y >> C, I = 0; I < 6; I++) {
                  var O = R[C][I];
                  A && (O = hR(O, L, L, r)), p.texImage2D(I, C, E, L, L, 0, S, T, O);
                }
              d._bindTextureDirectly(p.TEXTURE_CUBE_MAP, null);
            } else
              d.updateRawCubeTexture(f, b, i, r, h);
            f.isReady = !0, t == null || t.removePendingData(f), f.onLoadedObservable.notifyObservers(f), f.onLoadedObservable.clear(), l && l();
          }
        })(m);
      }, void 0, t == null ? void 0 : t.offlineProvider, !0, function(m, g) {
        t == null || t.removePendingData(f), c && m && c(m.status + " " + m.statusText, g);
      }), f;
    }, Qe.prototype.createRawTexture2DArray = dR(!1), Qe.prototype.createRawTexture3D = dR(!0), Qe.prototype.updateRawTexture2DArray = pR(!1), Qe.prototype.updateRawTexture3D = pR(!0);
    var on = function(n) {
      function t(e, i, r, o, a, s, l, c, u, h, d) {
        s === void 0 && (s = !0), l === void 0 && (l = !1), c === void 0 && (c = _.TEXTURE_TRILINEAR_SAMPLINGMODE), u === void 0 && (u = _.TEXTURETYPE_UNSIGNED_INT);
        var p = n.call(this, null, a, !s, l, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0, h) || this;
        return p.format = o, p._engine && (p._engine._caps.textureFloatLinearFiltering || u !== _.TEXTURETYPE_FLOAT || (c = _.TEXTURE_NEAREST_SAMPLINGMODE), p._engine._caps.textureHalfFloatLinearFiltering || u !== _.TEXTURETYPE_HALF_FLOAT || (c = _.TEXTURE_NEAREST_SAMPLINGMODE), p._texture = p._engine.createRawTexture(e, i, r, o, s, l, c, null, u, h ?? 0, d != null && d), p.wrapU = ae.CLAMP_ADDRESSMODE, p.wrapV = ae.CLAMP_ADDRESSMODE), p;
      }
      return D(t, n), t.prototype.update = function(e) {
        this._getEngine().updateRawTexture(this._texture, e, this._texture.format, this._texture.invertY, null, this._texture.type, this._texture._useSRGBBuffer);
      }, t.CreateLuminanceTexture = function(e, i, r, o, a, s, l) {
        return a === void 0 && (a = !0), s === void 0 && (s = !1), l === void 0 && (l = _.TEXTURE_TRILINEAR_SAMPLINGMODE), new t(e, i, r, _.TEXTUREFORMAT_LUMINANCE, o, a, s, l);
      }, t.CreateLuminanceAlphaTexture = function(e, i, r, o, a, s, l) {
        return a === void 0 && (a = !0), s === void 0 && (s = !1), l === void 0 && (l = _.TEXTURE_TRILINEAR_SAMPLINGMODE), new t(e, i, r, _.TEXTUREFORMAT_LUMINANCE_ALPHA, o, a, s, l);
      }, t.CreateAlphaTexture = function(e, i, r, o, a, s, l) {
        return a === void 0 && (a = !0), s === void 0 && (s = !1), l === void 0 && (l = _.TEXTURE_TRILINEAR_SAMPLINGMODE), new t(e, i, r, _.TEXTUREFORMAT_ALPHA, o, a, s, l);
      }, t.CreateRGBTexture = function(e, i, r, o, a, s, l, c, u, h) {
        return a === void 0 && (a = !0), s === void 0 && (s = !1), l === void 0 && (l = _.TEXTURE_TRILINEAR_SAMPLINGMODE), c === void 0 && (c = _.TEXTURETYPE_UNSIGNED_INT), u === void 0 && (u = 0), h === void 0 && (h = !1), new t(e, i, r, _.TEXTUREFORMAT_RGB, o, a, s, l, c, u, h);
      }, t.CreateRGBATexture = function(e, i, r, o, a, s, l, c, u, h) {
        return a === void 0 && (a = !0), s === void 0 && (s = !1), l === void 0 && (l = _.TEXTURE_TRILINEAR_SAMPLINGMODE), c === void 0 && (c = _.TEXTURETYPE_UNSIGNED_INT), u === void 0 && (u = 0), h === void 0 && (h = !1), new t(e, i, r, _.TEXTUREFORMAT_RGBA, o, a, s, l, c, u, h);
      }, t.CreateRGBAStorageTexture = function(e, i, r, o, a, s, l, c, u) {
        return a === void 0 && (a = !0), s === void 0 && (s = !1), l === void 0 && (l = _.TEXTURE_TRILINEAR_SAMPLINGMODE), c === void 0 && (c = _.TEXTURETYPE_UNSIGNED_INT), u === void 0 && (u = !1), new t(e, i, r, _.TEXTUREFORMAT_RGBA, o, a, s, l, c, _.TEXTURE_CREATIONFLAG_STORAGE, u);
      }, t.CreateRTexture = function(e, i, r, o, a, s, l, c) {
        return a === void 0 && (a = !0), s === void 0 && (s = !1), l === void 0 && (l = ae.TRILINEAR_SAMPLINGMODE), c === void 0 && (c = _.TEXTURETYPE_FLOAT), new t(e, i, r, _.TEXTUREFORMAT_R, o, a, s, l, c);
      }, t.CreateRStorageTexture = function(e, i, r, o, a, s, l, c) {
        return a === void 0 && (a = !0), s === void 0 && (s = !1), l === void 0 && (l = ae.TRILINEAR_SAMPLINGMODE), c === void 0 && (c = _.TEXTURETYPE_FLOAT), new t(e, i, r, _.TEXTUREFORMAT_R, o, a, s, l, c, _.TEXTURE_CREATIONFLAG_STORAGE);
      }, t;
    }(ae), fR = function() {
      function n(t, e) {
        this._scene = t, this._mesh = e;
      }
      return n.prototype.bakeVertexData = function(t) {
        return Ft(this, void 0, void 0, function() {
          var e, i, r, o, a, s, l, c;
          return Bt(this, function(u) {
            switch (u.label) {
              case 0:
                if (!this._mesh.skeleton)
                  throw new Error("No skeleton in this mesh.");
                if (e = this._mesh.skeleton.bones.length, i = t.reduce(function(h, d) {
                  return h + d.to - d.from + 1;
                }, 0), isNaN(i))
                  throw new Error("Invalid animation ranges.");
                r = 0, o = new Float32Array(4 * (e + 1) * 4 * i), this._scene.stopAnimation(this._mesh), this._mesh.skeleton.returnToRest(), a = 0, s = t, u.label = 1;
              case 1:
                if (!(a < s.length))
                  return [3, 6];
                l = s[a], c = l.from, u.label = 2;
              case 2:
                return c <= l.to ? [4, this._executeAnimationFrame(o, c, r++)] : [3, 5];
              case 3:
                u.sent(), u.label = 4;
              case 4:
                return c++, [3, 2];
              case 5:
                return a++, [3, 1];
              case 6:
                return [2, o];
            }
          });
        });
      }, n.prototype._executeAnimationFrame = function(t, e, i) {
        return Ft(this, void 0, void 0, function() {
          var r = this;
          return Bt(this, function(o) {
            return [2, new Promise(function(a, s) {
              r._scene.beginAnimation(r._mesh.skeleton, e, e, !1, 1, function() {
                var l = r._mesh.skeleton.getTransformMatrices(r._mesh);
                t.set(l, i * l.length), a();
              });
            })];
          });
        });
      }, n.prototype.textureFromBakedVertexData = function(t) {
        if (!this._mesh.skeleton)
          throw new Error("No skeleton in this mesh.");
        var e = this._mesh.skeleton.bones.length, i = on.CreateRGBATexture(t, 4 * (e + 1), t.length / (4 * (e + 1) * 4), this._scene, !1, !1, ae.NEAREST_NEAREST, _.TEXTURETYPE_FLOAT);
        return i.name = "VAT" + this._mesh.skeleton.name, i;
      }, n.prototype.serializeBakedVertexDataToObject = function(t) {
        if (!this._mesh.skeleton)
          throw new Error("No skeleton in this mesh.");
        var e = this._mesh.skeleton.bones.length, i = 4 * (e + 1), r = t.length / (4 * (e + 1) * 4);
        return { vertexData: $l(t), width: i, height: r };
      }, n.prototype.loadBakedVertexDataFromObject = function(t) {
        return new Float32Array(Nu(t.vertexData));
      }, n.prototype.serializeBakedVertexDataToJSON = function(t) {
        return JSON.stringify(this.serializeBakedVertexDataToObject(t));
      }, n.prototype.loadBakedVertexDataFromJSON = function(t) {
        return this.loadBakedVertexDataFromObject(JSON.parse(t));
      }, n;
    }(), Ig = function() {
      function n() {
        this._zoomStopsAnimation = !1, this._idleRotationSpeed = 0.05, this._idleRotationWaitTime = 2e3, this._idleRotationSpinupTime = 2e3, this.targetAlpha = null, this._isPointerDown = !1, this._lastFrameTime = null, this._lastInteractionTime = -1 / 0, this._cameraRotationSpeed = 0, this._lastFrameRadius = 0;
      }
      return Object.defineProperty(n.prototype, "name", { get: function() {
        return "AutoRotation";
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "zoomStopsAnimation", { get: function() {
        return this._zoomStopsAnimation;
      }, set: function(t) {
        this._zoomStopsAnimation = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "idleRotationSpeed", { get: function() {
        return this._idleRotationSpeed;
      }, set: function(t) {
        this._idleRotationSpeed = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "idleRotationWaitTime", { get: function() {
        return this._idleRotationWaitTime;
      }, set: function(t) {
        this._idleRotationWaitTime = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "idleRotationSpinupTime", { get: function() {
        return this._idleRotationSpinupTime;
      }, set: function(t) {
        this._idleRotationSpinupTime = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "rotationInProgress", { get: function() {
        return Math.abs(this._cameraRotationSpeed) > 0;
      }, enumerable: !1, configurable: !0 }), n.prototype.init = function() {
      }, n.prototype.attach = function(t) {
        var e = this;
        this._attachedCamera = t;
        var i = this._attachedCamera.getScene();
        this._onPrePointerObservableObserver = i.onPrePointerObservable.add(function(r) {
          r.type !== Le.POINTERDOWN ? r.type === Le.POINTERUP && (e._isPointerDown = !1) : e._isPointerDown = !0;
        }), this._onAfterCheckInputsObserver = t.onAfterCheckInputsObservable.add(function() {
          if (!e._reachTargetAlpha()) {
            var r = It.Now, o = 0;
            e._lastFrameTime != null && (o = r - e._lastFrameTime), e._lastFrameTime = r, e._applyUserInteraction();
            var a = r - e._lastInteractionTime - e._idleRotationWaitTime, s = Math.max(Math.min(a / e._idleRotationSpinupTime, 1), 0);
            e._cameraRotationSpeed = e._idleRotationSpeed * s, e._attachedCamera && (e._attachedCamera.alpha -= e._cameraRotationSpeed * (o / 1e3));
          }
        });
      }, n.prototype.detach = function() {
        if (this._attachedCamera) {
          var t = this._attachedCamera.getScene();
          this._onPrePointerObservableObserver && t.onPrePointerObservable.remove(this._onPrePointerObservableObserver), this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver), this._attachedCamera = null;
        }
      }, n.prototype.resetLastInteractionTime = function(t) {
        this._lastInteractionTime = t ?? It.Now;
      }, n.prototype._reachTargetAlpha = function() {
        return !(!this._attachedCamera || !this.targetAlpha) && Math.abs(this._attachedCamera.alpha - this.targetAlpha) < Ge;
      }, n.prototype._userIsZooming = function() {
        return !!this._attachedCamera && this._attachedCamera.inertialRadiusOffset !== 0;
      }, n.prototype._shouldAnimationStopForInteraction = function() {
        if (!this._attachedCamera)
          return !1;
        var t = !1;
        return this._lastFrameRadius === this._attachedCamera.radius && this._attachedCamera.inertialRadiusOffset !== 0 && (t = !0), this._lastFrameRadius = this._attachedCamera.radius, this._zoomStopsAnimation ? t : this._userIsZooming();
      }, n.prototype._applyUserInteraction = function() {
        this._userIsMoving() && !this._shouldAnimationStopForInteraction() && (this._lastInteractionTime = It.Now);
      }, n.prototype._userIsMoving = function() {
        return !!this._attachedCamera && (this._attachedCamera.inertialAlphaOffset !== 0 || this._attachedCamera.inertialBetaOffset !== 0 || this._attachedCamera.inertialRadiusOffset !== 0 || this._attachedCamera.inertialPanningX !== 0 || this._attachedCamera.inertialPanningY !== 0 || this._isPointerDown);
      }, n;
    }(), Mg = function() {
      function n() {
        this.transitionDuration = 450, this.lowerRadiusTransitionRange = 2, this.upperRadiusTransitionRange = -2, this._autoTransitionRange = !1, this._radiusIsAnimating = !1, this._radiusBounceTransition = null, this._animatables = new Array();
      }
      return Object.defineProperty(n.prototype, "name", { get: function() {
        return "Bouncing";
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "autoTransitionRange", { get: function() {
        return this._autoTransitionRange;
      }, set: function(t) {
        var e = this;
        if (this._autoTransitionRange !== t) {
          this._autoTransitionRange = t;
          var i = this._attachedCamera;
          i && (t ? this._onMeshTargetChangedObserver = i.onMeshTargetChangedObservable.add(function(r) {
            if (r) {
              r.computeWorldMatrix(!0);
              var o = r.getBoundingInfo().diagonalLength;
              e.lowerRadiusTransitionRange = 0.05 * o, e.upperRadiusTransitionRange = 0.05 * o;
            }
          }) : this._onMeshTargetChangedObserver && i.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver));
        }
      }, enumerable: !1, configurable: !0 }), n.prototype.init = function() {
      }, n.prototype.attach = function(t) {
        var e = this;
        this._attachedCamera = t, this._onAfterCheckInputsObserver = t.onAfterCheckInputsObservable.add(function() {
          e._attachedCamera && (e._isRadiusAtLimit(e._attachedCamera.lowerRadiusLimit) && e._applyBoundRadiusAnimation(e.lowerRadiusTransitionRange), e._isRadiusAtLimit(e._attachedCamera.upperRadiusLimit) && e._applyBoundRadiusAnimation(e.upperRadiusTransitionRange));
        });
      }, n.prototype.detach = function() {
        this._attachedCamera && (this._onAfterCheckInputsObserver && this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver), this._onMeshTargetChangedObserver && this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver), this._attachedCamera = null);
      }, n.prototype._isRadiusAtLimit = function(t) {
        return !!this._attachedCamera && this._attachedCamera.radius === t && !this._radiusIsAnimating;
      }, n.prototype._applyBoundRadiusAnimation = function(t) {
        var e = this;
        if (this._attachedCamera) {
          this._radiusBounceTransition || (n.EasingFunction.setEasingMode(n.EasingMode), this._radiusBounceTransition = Je.CreateAnimation("radius", Je.ANIMATIONTYPE_FLOAT, 60, n.EasingFunction)), this._cachedWheelPrecision = this._attachedCamera.wheelPrecision, this._attachedCamera.wheelPrecision = 1 / 0, this._attachedCamera.inertialRadiusOffset = 0, this.stopAllAnimations(), this._radiusIsAnimating = !0;
          var i = Je.TransitionTo("radius", this._attachedCamera.radius + t, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusBounceTransition, this.transitionDuration, function() {
            return e._clearAnimationLocks();
          });
          i && this._animatables.push(i);
        }
      }, n.prototype._clearAnimationLocks = function() {
        this._radiusIsAnimating = !1, this._attachedCamera && (this._attachedCamera.wheelPrecision = this._cachedWheelPrecision);
      }, n.prototype.stopAllAnimations = function() {
        for (this._attachedCamera && (this._attachedCamera.animations = []); this._animatables.length; )
          this._animatables[0].onAnimationEnd = null, this._animatables[0].stop(), this._animatables.shift();
      }, n.EasingFunction = new cg(0.3), n.EasingMode = xn.EASINGMODE_EASEOUT, n;
    }(), Og = function() {
      function n() {
        this.onTargetFramingAnimationEndObservable = new H(), this._mode = n.FitFrustumSidesMode, this._radiusScale = 1, this._positionScale = 0.5, this._defaultElevation = 0.3, this._elevationReturnTime = 1500, this._elevationReturnWaitTime = 1e3, this._zoomStopsAnimation = !1, this._framingTime = 1500, this.autoCorrectCameraLimitsAndSensibility = !0, this._isPointerDown = !1, this._lastInteractionTime = -1 / 0, this._animatables = new Array(), this._betaIsAnimating = !1;
      }
      return Object.defineProperty(n.prototype, "name", { get: function() {
        return "Framing";
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "mode", { get: function() {
        return this._mode;
      }, set: function(t) {
        this._mode = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "radiusScale", { get: function() {
        return this._radiusScale;
      }, set: function(t) {
        this._radiusScale = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "positionScale", { get: function() {
        return this._positionScale;
      }, set: function(t) {
        this._positionScale = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "defaultElevation", { get: function() {
        return this._defaultElevation;
      }, set: function(t) {
        this._defaultElevation = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "elevationReturnTime", { get: function() {
        return this._elevationReturnTime;
      }, set: function(t) {
        this._elevationReturnTime = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "elevationReturnWaitTime", { get: function() {
        return this._elevationReturnWaitTime;
      }, set: function(t) {
        this._elevationReturnWaitTime = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "zoomStopsAnimation", { get: function() {
        return this._zoomStopsAnimation;
      }, set: function(t) {
        this._zoomStopsAnimation = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "framingTime", { get: function() {
        return this._framingTime;
      }, set: function(t) {
        this._framingTime = t;
      }, enumerable: !1, configurable: !0 }), n.prototype.init = function() {
      }, n.prototype.attach = function(t) {
        var e = this;
        this._attachedCamera = t;
        var i = this._attachedCamera.getScene();
        n.EasingFunction.setEasingMode(n.EasingMode), this._onPrePointerObservableObserver = i.onPrePointerObservable.add(function(r) {
          r.type !== Le.POINTERDOWN ? r.type === Le.POINTERUP && (e._isPointerDown = !1) : e._isPointerDown = !0;
        }), this._onMeshTargetChangedObserver = t.onMeshTargetChangedObservable.add(function(r) {
          r && e.zoomOnMesh(r, void 0, function() {
            e.onTargetFramingAnimationEndObservable.notifyObservers();
          });
        }), this._onAfterCheckInputsObserver = t.onAfterCheckInputsObservable.add(function() {
          e._applyUserInteraction(), e._maintainCameraAboveGround();
        });
      }, n.prototype.detach = function() {
        if (this._attachedCamera) {
          var t = this._attachedCamera.getScene();
          this._onPrePointerObservableObserver && t.onPrePointerObservable.remove(this._onPrePointerObservableObserver), this._onAfterCheckInputsObserver && this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver), this._onMeshTargetChangedObserver && this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver), this._attachedCamera = null;
        }
      }, n.prototype.zoomOnMesh = function(t, e, i) {
        e === void 0 && (e = !1), i === void 0 && (i = null), t.computeWorldMatrix(!0);
        var r = t.getBoundingInfo().boundingBox;
        this.zoomOnBoundingInfo(r.minimumWorld, r.maximumWorld, e, i);
      }, n.prototype.zoomOnMeshHierarchy = function(t, e, i) {
        e === void 0 && (e = !1), i === void 0 && (i = null), t.computeWorldMatrix(!0);
        var r = t.getHierarchyBoundingVectors(!0);
        this.zoomOnBoundingInfo(r.min, r.max, e, i);
      }, n.prototype.zoomOnMeshesHierarchy = function(t, e, i) {
        e === void 0 && (e = !1), i === void 0 && (i = null);
        for (var r = new v(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), o = new v(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE), a = 0; a < t.length; a++) {
          var s = t[a].getHierarchyBoundingVectors(!0);
          v.CheckExtends(s.min, r, o), v.CheckExtends(s.max, r, o);
        }
        this.zoomOnBoundingInfo(r, o, e, i);
      }, n.prototype.zoomOnBoundingInfo = function(t, e, i, r) {
        var o, a = this;
        if (i === void 0 && (i = !1), r === void 0 && (r = null), !this._attachedCamera)
          return !1;
        var s = t.y, l = s + (e.y - s) * this._positionScale, c = e.subtract(t).scale(0.5);
        if (i)
          o = new v(0, l, 0);
        else {
          var u = t.add(c);
          o = new v(u.x, l, u.z);
        }
        this._vectorTransition || (this._vectorTransition = Je.CreateAnimation("target", Je.ANIMATIONTYPE_VECTOR3, 60, n.EasingFunction)), this._betaIsAnimating = !0;
        var h = Je.TransitionTo("target", o, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);
        h && this._animatables.push(h);
        var d = 0;
        if (this._mode === n.FitFrustumSidesMode) {
          var p = this._calculateLowerRadiusFromModelBoundingSphere(t, e);
          this.autoCorrectCameraLimitsAndSensibility && (this._attachedCamera.lowerRadiusLimit = c.length() + this._attachedCamera.minZ), d = p;
        } else
          this._mode === n.IgnoreBoundsSizeMode && (d = this._calculateLowerRadiusFromModelBoundingSphere(t, e), this.autoCorrectCameraLimitsAndSensibility && this._attachedCamera.lowerRadiusLimit === null && (this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ));
        if (this.autoCorrectCameraLimitsAndSensibility) {
          var f = e.subtract(t).length();
          this._attachedCamera.panningSensibility = 5e3 / f, this._attachedCamera.wheelPrecision = 100 / d;
        }
        return this._radiusTransition || (this._radiusTransition = Je.CreateAnimation("radius", Je.ANIMATIONTYPE_FLOAT, 60, n.EasingFunction)), (h = Je.TransitionTo("radius", d, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, function() {
          a.stopAllAnimations(), r && r(), a._attachedCamera && a._attachedCamera.useInputToRestoreState && a._attachedCamera.storeState();
        })) && this._animatables.push(h), !0;
      }, n.prototype._calculateLowerRadiusFromModelBoundingSphere = function(t, e) {
        var i = this._attachedCamera;
        if (!i)
          return 0;
        var r = i._calculateLowerRadiusFromModelBoundingSphere(t, e, this._radiusScale);
        return i.lowerRadiusLimit && this._mode === n.IgnoreBoundsSizeMode && (r = r < i.lowerRadiusLimit ? i.lowerRadiusLimit : r), i.upperRadiusLimit && (r = r > i.upperRadiusLimit ? i.upperRadiusLimit : r), r;
      }, n.prototype._maintainCameraAboveGround = function() {
        var t = this;
        if (!(this._elevationReturnTime < 0)) {
          var e = It.Now - this._lastInteractionTime, i = 0.5 * Math.PI - this._defaultElevation, r = 0.5 * Math.PI;
          if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > r && e >= this._elevationReturnWaitTime) {
            this._betaIsAnimating = !0, this.stopAllAnimations(), this._betaTransition || (this._betaTransition = Je.CreateAnimation("beta", Je.ANIMATIONTYPE_FLOAT, 60, n.EasingFunction));
            var o = Je.TransitionTo("beta", i, this._attachedCamera, this._attachedCamera.getScene(), 60, this._betaTransition, this._elevationReturnTime, function() {
              t._clearAnimationLocks(), t.stopAllAnimations();
            });
            o && this._animatables.push(o);
          }
        }
      }, n.prototype._clearAnimationLocks = function() {
        this._betaIsAnimating = !1;
      }, n.prototype._applyUserInteraction = function() {
        this.isUserIsMoving && (this._lastInteractionTime = It.Now, this.stopAllAnimations(), this._clearAnimationLocks());
      }, n.prototype.stopAllAnimations = function() {
        for (this._attachedCamera && (this._attachedCamera.animations = []); this._animatables.length; )
          this._animatables[0] && (this._animatables[0].onAnimationEnd = null, this._animatables[0].stop()), this._animatables.shift();
      }, Object.defineProperty(n.prototype, "isUserIsMoving", { get: function() {
        return !!this._attachedCamera && (this._attachedCamera.inertialAlphaOffset !== 0 || this._attachedCamera.inertialBetaOffset !== 0 || this._attachedCamera.inertialRadiusOffset !== 0 || this._attachedCamera.inertialPanningX !== 0 || this._attachedCamera.inertialPanningY !== 0 || this._isPointerDown);
      }, enumerable: !1, configurable: !0 }), n.EasingFunction = new ug(), n.EasingMode = xn.EASINGMODE_EASEINOUT, n.IgnoreBoundsSizeMode = 0, n.FitFrustumSidesMode = 1, n;
    }(), uc = function(n, t, e, i) {
      t === void 0 && (t = new v()), e === void 0 && (e = 0), i === void 0 && (i = !1), this.direction = n, this.rotatedDirection = t, this.diff = e, this.ignore = i;
    }, _R = function() {
      function n(t) {
        this._ui = t, this.name = "AttachToBoxBehavior", this.distanceAwayFromFace = 0.15, this.distanceAwayFromBottomOfFace = 0.15, this._faceVectors = [new uc(v.Up()), new uc(v.Down()), new uc(v.Left()), new uc(v.Right()), new uc(v.Forward()), new uc(v.Forward().scaleInPlace(-1))], this._tmpMatrix = new B(), this._tmpVector = new v(), this._zeroVector = v.Zero(), this._lookAtTmpMatrix = new B();
      }
      return n.prototype.init = function() {
      }, n.prototype._closestFace = function(t) {
        var e = this;
        return this._faceVectors.forEach(function(i) {
          e._target.rotationQuaternion || (e._target.rotationQuaternion = oe.RotationYawPitchRoll(e._target.rotation.y, e._target.rotation.x, e._target.rotation.z)), e._target.rotationQuaternion.toRotationMatrix(e._tmpMatrix), v.TransformCoordinatesToRef(i.direction, e._tmpMatrix, i.rotatedDirection), i.diff = v.GetAngleBetweenVectors(i.rotatedDirection, t, v.Cross(i.rotatedDirection, t));
        }), this._faceVectors.reduce(function(i, r) {
          return i.ignore ? r : r.ignore || i.diff < r.diff ? i : r;
        }, this._faceVectors[0]);
      }, n.prototype._lookAtToRef = function(t, e, i) {
        e === void 0 && (e = new v(0, 1, 0)), B.LookAtLHToRef(this._zeroVector, t, e, this._lookAtTmpMatrix), this._lookAtTmpMatrix.invert(), oe.FromRotationMatrixToRef(this._lookAtTmpMatrix, i);
      }, n.prototype.attach = function(t) {
        var e = this;
        this._target = t, this._scene = this._target.getScene(), this._onRenderObserver = this._scene.onBeforeRenderObservable.add(function() {
          if (e._scene.activeCamera) {
            var i = e._scene.activeCamera.position;
            e._scene.activeCamera.devicePosition && (i = e._scene.activeCamera.devicePosition);
            var r = e._closestFace(i.subtract(t.position));
            e._scene.activeCamera.leftCamera ? e._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(e._tmpMatrix) : e._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(e._tmpMatrix), v.TransformCoordinatesToRef(v.Up(), e._tmpMatrix, e._tmpVector), e._faceVectors.forEach(function(a) {
              r.direction.x && a.direction.x && (a.ignore = !0), r.direction.y && a.direction.y && (a.ignore = !0), r.direction.z && a.direction.z && (a.ignore = !0);
            });
            var o = e._closestFace(e._tmpVector);
            e._faceVectors.forEach(function(a) {
              a.ignore = !1;
            }), e._ui.position.copyFrom(t.position), r.direction.x && (r.rotatedDirection.scaleToRef(t.scaling.x / 2 + e.distanceAwayFromFace, e._tmpVector), e._ui.position.addInPlace(e._tmpVector)), r.direction.y && (r.rotatedDirection.scaleToRef(t.scaling.y / 2 + e.distanceAwayFromFace, e._tmpVector), e._ui.position.addInPlace(e._tmpVector)), r.direction.z && (r.rotatedDirection.scaleToRef(t.scaling.z / 2 + e.distanceAwayFromFace, e._tmpVector), e._ui.position.addInPlace(e._tmpVector)), e._ui.rotationQuaternion || (e._ui.rotationQuaternion = oe.RotationYawPitchRoll(e._ui.rotation.y, e._ui.rotation.x, e._ui.rotation.z)), r.rotatedDirection.scaleToRef(-1, e._tmpVector), e._lookAtToRef(e._tmpVector, o.rotatedDirection, e._ui.rotationQuaternion), o.direction.x && e._ui.up.scaleToRef(e.distanceAwayFromBottomOfFace - t.scaling.x / 2, e._tmpVector), o.direction.y && e._ui.up.scaleToRef(e.distanceAwayFromBottomOfFace - t.scaling.y / 2, e._tmpVector), o.direction.z && e._ui.up.scaleToRef(e.distanceAwayFromBottomOfFace - t.scaling.z / 2, e._tmpVector), e._ui.position.addInPlace(e._tmpVector);
          }
        });
      }, n.prototype.detach = function() {
        this._scene.onBeforeRenderObservable.remove(this._onRenderObserver);
      }, n;
    }(), mR = function() {
      function n() {
        var t = this;
        this.fadeInDelay = 0, this.fadeOutDelay = 0, this.fadeInTime = 300, this.fadeOutTime = 300, this._millisecondsPerFrame = 1e3 / 60, this._hovered = !1, this._hoverValue = 0, this._ownerNode = null, this._delay = 0, this._time = 300, this._update = function() {
          if (t._ownerNode) {
            if (t._hoverValue += t._hovered ? t._millisecondsPerFrame : -t._millisecondsPerFrame, t._setAllVisibility(t._ownerNode, (t._hoverValue - t._delay) / t._time), t._ownerNode.visibility > 1) {
              if (t._setAllVisibility(t._ownerNode, 1), t._hoverValue > t._time)
                return t._hoverValue = t._time, void t._detachObserver();
            } else if (t._ownerNode.visibility < 0 && (t._setAllVisibility(t._ownerNode, 0), t._hoverValue < 0))
              return t._hoverValue = 0, void t._detachObserver();
            t._attachObserver();
          }
        };
      }
      return Object.defineProperty(n.prototype, "delay", { get: function() {
        return this.fadeInDelay;
      }, set: function(t) {
        this.fadeInDelay = t, this.fadeOutDelay = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "name", { get: function() {
        return "FadeInOut";
      }, enumerable: !1, configurable: !0 }), n.prototype.init = function() {
      }, n.prototype.attach = function(t) {
        this._ownerNode = t, this._setAllVisibility(this._ownerNode, 0);
      }, n.prototype.detach = function() {
        this._ownerNode = null;
      }, n.prototype.fadeIn = function(t) {
        t === void 0 && (t = !0), this._delay = t ? this.fadeInDelay : this.fadeOutDelay, this._time = t ? this.fadeInTime : this.fadeOutTime, this._detachObserver(), this._ownerNode && (t && this._ownerNode.visibility >= 1 || !t && this._ownerNode.visibility <= 0) || (this._hovered = t, this._hovered || (this._delay *= -1), this._ownerNode.visibility >= 1 ? this._hoverValue = this._time : this._ownerNode.visibility <= 0 && (this._hoverValue = 0), this._update());
      }, n.prototype.fadeOut = function() {
        this.fadeIn(!1);
      }, n.prototype._setAllVisibility = function(t, e) {
        var i = this;
        t.visibility = e, t.getChildMeshes().forEach(function(r) {
          i._setAllVisibility(r, e);
        });
      }, n.prototype._attachObserver = function() {
        var t;
        this._onBeforeRenderObserver || (this._onBeforeRenderObserver = (t = this._ownerNode) === null || t === void 0 ? void 0 : t.getScene().onBeforeRenderObservable.add(this._update));
      }, n.prototype._detachObserver = function() {
        var t;
        this._onBeforeRenderObserver && ((t = this._ownerNode) === null || t === void 0 || t.getScene().onBeforeRenderObservable.remove(this._onBeforeRenderObserver), this._onBeforeRenderObserver = null);
      }, n;
    }(), gi = function() {
      function n(t, e, i) {
        i === void 0 && (i = Number.MAX_VALUE), this.origin = t, this.direction = e, this.length = i;
      }
      return n.prototype.clone = function() {
        return new n(this.origin.clone(), this.direction.clone(), this.length);
      }, n.prototype.intersectsBoxMinMax = function(t, e, i) {
        i === void 0 && (i = 0);
        var r, o, a, s, l = n._TmpVector3[0].copyFromFloats(t.x - i, t.y - i, t.z - i), c = n._TmpVector3[1].copyFromFloats(e.x + i, e.y + i, e.z + i), u = 0, h = Number.MAX_VALUE;
        if (Math.abs(this.direction.x) < 1e-7) {
          if (this.origin.x < l.x || this.origin.x > c.x)
            return !1;
        } else if (r = 1 / this.direction.x, o = (l.x - this.origin.x) * r, (a = (c.x - this.origin.x) * r) == -1 / 0 && (a = 1 / 0), o > a && (s = o, o = a, a = s), (u = Math.max(o, u)) > (h = Math.min(a, h)))
          return !1;
        if (Math.abs(this.direction.y) < 1e-7) {
          if (this.origin.y < l.y || this.origin.y > c.y)
            return !1;
        } else if (r = 1 / this.direction.y, o = (l.y - this.origin.y) * r, (a = (c.y - this.origin.y) * r) == -1 / 0 && (a = 1 / 0), o > a && (s = o, o = a, a = s), (u = Math.max(o, u)) > (h = Math.min(a, h)))
          return !1;
        if (Math.abs(this.direction.z) < 1e-7) {
          if (this.origin.z < l.z || this.origin.z > c.z)
            return !1;
        } else if (r = 1 / this.direction.z, o = (l.z - this.origin.z) * r, (a = (c.z - this.origin.z) * r) == -1 / 0 && (a = 1 / 0), o > a && (s = o, o = a, a = s), (u = Math.max(o, u)) > (h = Math.min(a, h)))
          return !1;
        return !0;
      }, n.prototype.intersectsBox = function(t, e) {
        return e === void 0 && (e = 0), this.intersectsBoxMinMax(t.minimum, t.maximum, e);
      }, n.prototype.intersectsSphere = function(t, e) {
        e === void 0 && (e = 0);
        var i = t.center.x - this.origin.x, r = t.center.y - this.origin.y, o = t.center.z - this.origin.z, a = i * i + r * r + o * o, s = t.radius + e, l = s * s;
        if (a <= l)
          return !0;
        var c = i * this.direction.x + r * this.direction.y + o * this.direction.z;
        return !(c < 0) && a - c * c <= l;
      }, n.prototype.intersectsTriangle = function(t, e, i) {
        var r = n._TmpVector3[0], o = n._TmpVector3[1], a = n._TmpVector3[2], s = n._TmpVector3[3], l = n._TmpVector3[4];
        e.subtractToRef(t, r), i.subtractToRef(t, o), v.CrossToRef(this.direction, o, a);
        var c = v.Dot(r, a);
        if (c === 0)
          return null;
        var u = 1 / c;
        this.origin.subtractToRef(t, s);
        var h = v.Dot(s, a) * u;
        if (h < 0 || h > 1)
          return null;
        v.CrossToRef(s, r, l);
        var d = v.Dot(this.direction, l) * u;
        if (d < 0 || h + d > 1)
          return null;
        var p = v.Dot(o, l) * u;
        return p > this.length ? null : new Ku(1 - h - d, h, p);
      }, n.prototype.intersectsPlane = function(t) {
        var e, i = v.Dot(t.normal, this.direction);
        if (Math.abs(i) < 999999997475243e-21)
          return null;
        var r = v.Dot(t.normal, this.origin);
        return (e = (-t.d - r) / i) < 0 ? e < -999999997475243e-21 ? null : 0 : e;
      }, n.prototype.intersectsAxis = function(t, e) {
        switch (e === void 0 && (e = 0), t) {
          case "y":
            return (i = (this.origin.y - e) / this.direction.y) > 0 ? null : new v(this.origin.x + this.direction.x * -i, e, this.origin.z + this.direction.z * -i);
          case "x":
            return (i = (this.origin.x - e) / this.direction.x) > 0 ? null : new v(e, this.origin.y + this.direction.y * -i, this.origin.z + this.direction.z * -i);
          case "z":
            var i;
            return (i = (this.origin.z - e) / this.direction.z) > 0 ? null : new v(this.origin.x + this.direction.x * -i, this.origin.y + this.direction.y * -i, e);
          default:
            return null;
        }
      }, n.prototype.intersectsMesh = function(t, e, i, r, o, a) {
        r === void 0 && (r = !1), a === void 0 && (a = !1);
        var s = F.Matrix[0];
        return t.getWorldMatrix().invertToRef(s), this._tmpRay ? n.TransformToRef(this, s, this._tmpRay) : this._tmpRay = n.Transform(this, s), t.intersects(this._tmpRay, e, i, r, o, a);
      }, n.prototype.intersectsMeshes = function(t, e, i) {
        i ? i.length = 0 : i = [];
        for (var r = 0; r < t.length; r++) {
          var o = this.intersectsMesh(t[r], e);
          o.hit && i.push(o);
        }
        return i.sort(this._comparePickingInfo), i;
      }, n.prototype._comparePickingInfo = function(t, e) {
        return t.distance < e.distance ? -1 : t.distance > e.distance ? 1 : 0;
      }, n.prototype.intersectionSegment = function(t, e, i) {
        var r = this.origin, o = F.Vector3[0], a = F.Vector3[1], s = F.Vector3[2], l = F.Vector3[3];
        e.subtractToRef(t, o), this.direction.scaleToRef(n._Rayl, s), r.addToRef(s, a), t.subtractToRef(r, l);
        var c, u, h = v.Dot(o, o), d = v.Dot(o, s), p = v.Dot(s, s), f = v.Dot(o, l), m = v.Dot(s, l), g = h * p - d * d, y = g, b = g;
        g < n._Smallnum ? (c = 0, y = 1, u = m, b = p) : (u = h * m - d * f, (c = d * m - p * f) < 0 ? (c = 0, u = m, b = p) : c > y && (c = y, u = m + d, b = p)), u < 0 ? (u = 0, -f < 0 ? c = 0 : -f > h ? c = y : (c = -f, y = h)) : u > b && (u = b, -f + d < 0 ? c = 0 : -f + d > h ? c = y : (c = -f + d, y = h));
        var T = Math.abs(c) < n._Smallnum ? 0 : c / y, S = Math.abs(u) < n._Smallnum ? 0 : u / b, E = F.Vector3[4];
        s.scaleToRef(S, E);
        var A = F.Vector3[5];
        o.scaleToRef(T, A), A.addInPlace(l);
        var R = F.Vector3[6];
        return A.subtractToRef(E, R), S > 0 && S <= this.length && R.lengthSquared() < i * i ? A.length() : -1;
      }, n.prototype.update = function(t, e, i, r, o, a, s, l) {
        if (l === void 0 && (l = !1), l) {
          n._RayDistant || (n._RayDistant = n.Zero()), n._RayDistant.unprojectRayToRef(t, e, i, r, B.IdentityReadOnly, a, s);
          var c = F.Matrix[0];
          o.invertToRef(c), n.TransformToRef(n._RayDistant, c, this);
        } else
          this.unprojectRayToRef(t, e, i, r, o, a, s);
        return this;
      }, n.Zero = function() {
        return new n(v.Zero(), v.Zero());
      }, n.CreateNew = function(t, e, i, r, o, a, s) {
        return n.Zero().update(t, e, i, r, o, a, s);
      }, n.CreateNewFromTo = function(t, e, i) {
        i === void 0 && (i = B.IdentityReadOnly);
        var r = e.subtract(t), o = Math.sqrt(r.x * r.x + r.y * r.y + r.z * r.z);
        return r.normalize(), n.Transform(new n(t, r, o), i);
      }, n.Transform = function(t, e) {
        var i = new n(new v(0, 0, 0), new v(0, 0, 0));
        return n.TransformToRef(t, e, i), i;
      }, n.TransformToRef = function(t, e, i) {
        v.TransformCoordinatesToRef(t.origin, e, i.origin), v.TransformNormalToRef(t.direction, e, i.direction), i.length = t.length;
        var r = i.direction, o = r.length();
        if (o !== 0 && o !== 1) {
          var a = 1 / o;
          r.x *= a, r.y *= a, r.z *= a, i.length *= o;
        }
      }, n.prototype.unprojectRayToRef = function(t, e, i, r, o, a, s) {
        var l = F.Matrix[0];
        o.multiplyToRef(a, l), l.multiplyToRef(s, l), l.invert();
        var c = Me.LastCreatedEngine, u = F.Vector3[0];
        u.x = t / i * 2 - 1, u.y = -(e / r * 2 - 1), u.z = c != null && c.useReverseDepthBuffer ? 1 : c != null && c.isNDCHalfZRange ? 0 : -1;
        var h = F.Vector3[1].copyFromFloats(u.x, u.y, 1 - 1e-8), d = F.Vector3[2], p = F.Vector3[3];
        v._UnprojectFromInvertedMatrixToRef(u, l, d), v._UnprojectFromInvertedMatrixToRef(h, l, p), this.origin.copyFrom(d), p.subtractToRef(d, this.direction), this.direction.normalize();
      }, n._TmpVector3 = pt.BuildArray(6, v.Zero), n._RayDistant = n.Zero(), n._Smallnum = 1e-8, n._Rayl = 1e9, n;
    }();
    Ue.prototype.createPickingRay = function(n, t, e, i, r) {
      r === void 0 && (r = !1);
      var o = gi.Zero();
      return this.createPickingRayToRef(n, t, e, o, i, r), o;
    }, Ue.prototype.createPickingRayToRef = function(n, t, e, i, r, o, a) {
      o === void 0 && (o = !1), a === void 0 && (a = !1);
      var s = this.getEngine();
      if (!r && !(r = this.activeCamera))
        return this;
      var l = r.viewport, c = s.getRenderHeight(), u = l.toGlobal(s.getRenderWidth(), c), h = u.x, d = u.y, p = u.width, f = u.height, m = 1 / s.getHardwareScalingLevel();
      return n = n * m - h, t = t * m - (c - d - f), i.update(n, t, p, f, e || B.IdentityReadOnly, o ? B.IdentityReadOnly : r.getViewMatrix(), r.getProjectionMatrix(), a), this;
    }, Ue.prototype.createPickingRayInCameraSpace = function(n, t, e) {
      var i = gi.Zero();
      return this.createPickingRayInCameraSpaceToRef(n, t, i, e), i;
    }, Ue.prototype.createPickingRayInCameraSpaceToRef = function(n, t, e, i) {
      if (!Ki)
        return this;
      var r = this.getEngine();
      if (!i && !(i = this.activeCamera))
        throw new Error("Active camera not set");
      var o = i.viewport, a = r.getRenderHeight(), s = o.toGlobal(r.getRenderWidth(), a), l = s.x, c = s.y, u = s.width, h = s.height, d = B.Identity(), p = 1 / r.getHardwareScalingLevel();
      return n = n * p - l, t = t * p - (a - c - h), e.update(n, t, u, h, d, d, i.getProjectionMatrix()), this;
    }, Ue.prototype._internalPickForMesh = function(n, t, e, i, r, o, a, s) {
      var l = t(i, e.enableDistantPicking), c = e.intersects(l, r, a, o, i, s);
      return c && c.hit ? !r && n != null && c.distance >= n.distance ? null : c : null;
    }, Ue.prototype._internalPick = function(n, t, e, i, r) {
      for (var o = null, a = !!(this.activeCameras && this.activeCameras.length > 1 && this.cameraToUseForPointers !== this.activeCamera), s = this.cameraToUseForPointers || this.activeCamera, l = 0; l < this.meshes.length; l++) {
        var c = this.meshes[l];
        if (t) {
          if (!t(c))
            continue;
        } else if (!c.isEnabled() || !c.isVisible || !c.isPickable)
          continue;
        var u, h = a && c.isWorldMatrixCameraDependent(), d = c.computeWorldMatrix(h, s);
        if (c.hasThinInstances && c.thinInstanceEnablePicking) {
          if (u = this._internalPickForMesh(o, n, c, d, !0, !0, r)) {
            if (i)
              return u;
            for (var p = F.Matrix[1], f = c.thinInstanceGetWorldMatrices(), m = 0; m < f.length; m++) {
              f[m].multiplyToRef(d, p);
              var g = this._internalPickForMesh(o, n, c, p, e, i, r, !0);
              if (g && ((o = g).thinInstanceIndex = m, e))
                return o;
            }
          }
        } else if ((u = this._internalPickForMesh(o, n, c, d, e, i, r)) && (o = u, e))
          return o;
      }
      return o || new Ki();
    }, Ue.prototype._internalMultiPick = function(n, t, e) {
      if (!Ki)
        return null;
      for (var i = [], r = !!(this.activeCameras && this.activeCameras.length > 1 && this.cameraToUseForPointers !== this.activeCamera), o = this.cameraToUseForPointers || this.activeCamera, a = 0; a < this.meshes.length; a++) {
        var s = this.meshes[a];
        if (t) {
          if (!t(s))
            continue;
        } else if (!s.isEnabled() || !s.isVisible || !s.isPickable)
          continue;
        var l, c = r && s.isWorldMatrixCameraDependent(), u = s.computeWorldMatrix(c, o);
        if (s.hasThinInstances && s.thinInstanceEnablePicking) {
          if (l = this._internalPickForMesh(null, n, s, u, !0, !0, e))
            for (var h = F.Matrix[1], d = s.thinInstanceGetWorldMatrices(), p = 0; p < d.length; p++) {
              d[p].multiplyToRef(u, h);
              var f = this._internalPickForMesh(null, n, s, h, !1, !1, e, !0);
              f && (f.thinInstanceIndex = p, i.push(f));
            }
        } else
          (l = this._internalPickForMesh(null, n, s, u, !1, !1, e)) && i.push(l);
      }
      return i;
    }, Ue.prototype.pickWithBoundingInfo = function(n, t, e, i, r) {
      var o = this;
      if (!Ki)
        return null;
      var a = this._internalPick(function(s) {
        return o._tempPickingRay || (o._tempPickingRay = gi.Zero()), o.createPickingRayToRef(n, t, s, o._tempPickingRay, r || null), o._tempPickingRay;
      }, e, i, !0);
      return a && (a.ray = this.createPickingRay(n, t, B.Identity(), r || null)), a;
    }, Object.defineProperty(Ue.prototype, "_pickingAvailable", { get: function() {
      return !0;
    }, enumerable: !1, configurable: !1 }), Ue.prototype.pick = function(n, t, e, i, r, o, a) {
      var s = this, l = this._internalPick(function(c, u) {
        return s._tempPickingRay || (s._tempPickingRay = gi.Zero()), s.createPickingRayToRef(n, t, c, s._tempPickingRay, r || null, !1, u), s._tempPickingRay;
      }, e, i, !1, o);
      return l && (l.ray = this.createPickingRay(n, t, B.Identity(), r || null)), l;
    }, Ue.prototype.pickWithRay = function(n, t, e, i) {
      var r = this, o = this._internalPick(function(a) {
        return r._pickWithRayInverseMatrix || (r._pickWithRayInverseMatrix = B.Identity()), a.invertToRef(r._pickWithRayInverseMatrix), r._cachedRayForTransform || (r._cachedRayForTransform = gi.Zero()), gi.TransformToRef(n, r._pickWithRayInverseMatrix, r._cachedRayForTransform), r._cachedRayForTransform;
      }, t, e, !1, i);
      return o && (o.ray = n), o;
    }, Ue.prototype.multiPick = function(n, t, e, i, r) {
      var o = this;
      return this._internalMultiPick(function(a) {
        return o.createPickingRay(n, t, a, i || null);
      }, e, r);
    }, Ue.prototype.multiPickWithRay = function(n, t, e) {
      var i = this;
      return this._internalMultiPick(function(r) {
        return i._pickWithRayInverseMatrix || (i._pickWithRayInverseMatrix = B.Identity()), r.invertToRef(i._pickWithRayInverseMatrix), i._cachedRayForTransform || (i._cachedRayForTransform = gi.Zero()), gi.TransformToRef(n, i._pickWithRayInverseMatrix, i._cachedRayForTransform), i._cachedRayForTransform;
      }, t, e);
    }, dt.prototype.getForwardRay = function(n, t, e) {
      return n === void 0 && (n = 100), this.getForwardRayToRef(new gi(v.Zero(), v.Zero(), n), n, t, e);
    }, dt.prototype.getForwardRayToRef = function(n, t, e, i) {
      t === void 0 && (t = 100), e || (e = this.getWorldMatrix()), n.length = t, i ? n.origin.copyFrom(i) : n.origin.copyFrom(this.position);
      var r = F.Vector3[2];
      r.set(0, 0, this._scene.useRightHandedSystem ? -1 : 1);
      var o = F.Vector3[3];
      return v.TransformNormalToRef(r, e, o), v.NormalizeToRef(o, n.direction), n;
    };
    var tr = function() {
      function n() {
      }
      return n._RemoveAndStorePivotPoint = function(t) {
        t && n._PivotCached === 0 && (t.getPivotPointToRef(n._OldPivotPoint), n._PivotPostMultiplyPivotMatrix = t._postMultiplyPivotMatrix, n._OldPivotPoint.equalsToFloats(0, 0, 0) || (t.setPivotMatrix(B.IdentityReadOnly), n._OldPivotPoint.subtractToRef(t.getPivotPoint(), n._PivotTranslation), n._PivotTmpVector.copyFromFloats(1, 1, 1), n._PivotTmpVector.subtractInPlace(t.scaling), n._PivotTmpVector.multiplyInPlace(n._PivotTranslation), t.position.addInPlace(n._PivotTmpVector))), n._PivotCached++;
      }, n._RestorePivotPoint = function(t) {
        t && !n._OldPivotPoint.equalsToFloats(0, 0, 0) && n._PivotCached === 1 && (t.setPivotPoint(n._OldPivotPoint), t._postMultiplyPivotMatrix = n._PivotPostMultiplyPivotMatrix, n._PivotTmpVector.copyFromFloats(1, 1, 1), n._PivotTmpVector.subtractInPlace(t.scaling), n._PivotTmpVector.multiplyInPlace(n._PivotTranslation), t.position.subtractInPlace(n._PivotTmpVector)), this._PivotCached--;
      }, n._PivotCached = 0, n._OldPivotPoint = new v(), n._PivotTranslation = new v(), n._PivotTmpVector = new v(), n._PivotPostMultiplyPivotMatrix = !1, n;
    }();
    function Zu(n) {
      var t = [], e = [], i = [], r = [], o = n.width || n.size || 1, a = n.height || n.size || 1, s = n.sideOrientation === 0 ? 0 : n.sideOrientation || Oe.DEFAULTSIDE, l = o / 2, c = a / 2;
      e.push(-l, -c, 0), i.push(0, 0, -1), r.push(0, Lt.UseOpenGLOrientationForUV ? 1 : 0), e.push(l, -c, 0), i.push(0, 0, -1), r.push(1, Lt.UseOpenGLOrientationForUV ? 1 : 0), e.push(l, c, 0), i.push(0, 0, -1), r.push(1, Lt.UseOpenGLOrientationForUV ? 0 : 1), e.push(-l, c, 0), i.push(0, 0, -1), r.push(0, Lt.UseOpenGLOrientationForUV ? 0 : 1), t.push(0), t.push(1), t.push(2), t.push(0), t.push(2), t.push(3), Oe._ComputeSides(s, e, t, i, r, n.frontUVs, n.backUVs);
      var u = new Oe();
      return u.indices = t, u.positions = e, u.normals = i, u.uvs = r, u;
    }
    function Ro(n, t, e) {
      t === void 0 && (t = {}), e === void 0 && (e = null);
      var i = new ie(n, e);
      return t.sideOrientation = ie._GetDefaultSideOrientation(t.sideOrientation), i._originalBuilderSideOrientation = t.sideOrientation, Zu(t).applyToMesh(i, t.updatable), t.sourcePlane && (i.translate(t.sourcePlane.normal, -t.sourcePlane.d), i.setDirection(t.sourcePlane.normal.scale(-1))), i;
    }
    var gR = { CreatePlane: Ro };
    Oe.CreatePlane = Zu, ie.CreatePlane = function(n, t, e, i, r) {
      return Ro(n, { size: t, width: t, height: t, sideOrientation: r, updatable: i }, e);
    };
    var Dg, Co = function() {
      function n(t) {
        this._useAlternatePickedPointAboveMaxDragAngleDragSpeed = -1.1, this._activeDragButton = -1, this.maxDragAngle = 0, this.dragButtons = [0, 1, 2], this._useAlternatePickedPointAboveMaxDragAngle = !1, this.currentDraggingPointerId = -1, this.dragging = !1, this.dragDeltaRatio = 0.2, this.updateDragPlane = !0, this._debugMode = !1, this._moving = !1, this.onDragObservable = new H(), this.onDragStartObservable = new H(), this.onDragEndObservable = new H(), this.onEnabledObservable = new H(), this.moveAttached = !0, this._enabled = !0, this.startAndReleaseDragOnPointerEvents = !0, this.detachCameraControls = !0, this.useObjectOrientationForDragging = !0, this.validateDrag = function(i) {
          return !0;
        }, this._tmpVector = new v(0, 0, 0), this._alternatePickedPoint = new v(0, 0, 0), this._worldDragAxis = new v(0, 0, 0), this._targetPosition = new v(0, 0, 0), this._attachedToElement = !1, this._startDragRay = new gi(new v(), new v()), this._lastPointerRay = {}, this._dragDelta = new v(), this._pointA = new v(0, 0, 0), this._pointC = new v(0, 0, 0), this._localAxis = new v(0, 0, 0), this._lookAt = new v(0, 0, 0), this._options = t || {};
        var e = 0;
        if (this._options.dragAxis && e++, this._options.dragPlaneNormal && e++, e > 1)
          throw "Multiple drag modes specified in dragBehavior options. Only one expected";
      }
      return Object.defineProperty(n.prototype, "currentDraggingPointerID", { get: function() {
        return this.currentDraggingPointerId;
      }, set: function(t) {
        this.currentDraggingPointerId = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "enabled", { get: function() {
        return this._enabled;
      }, set: function(t) {
        t != this._enabled && this.onEnabledObservable.notifyObservers(t), this._enabled = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "options", { get: function() {
        return this._options;
      }, set: function(t) {
        this._options = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "name", { get: function() {
        return "PointerDrag";
      }, enumerable: !1, configurable: !0 }), n.prototype.init = function() {
      }, n.prototype.attach = function(t, e) {
        var i = this;
        this._scene = t.getScene(), t.isNearGrabbable = !0, this.attachedNode = t, n._PlaneScene || (this._debugMode ? n._PlaneScene = this._scene : (n._PlaneScene = new Ue(this._scene.getEngine(), { virtual: !0 }), n._PlaneScene.detachControl(), this._scene.onDisposeObservable.addOnce(function() {
          n._PlaneScene.dispose(), n._PlaneScene = null;
        }))), this._dragPlane = Ro("pointerDragPlane", { size: this._debugMode ? 1 : 1e4, updatable: !1, sideOrientation: ie.DOUBLESIDE }, n._PlaneScene), this.lastDragPosition = new v(0, 0, 0);
        var r = e || function(o) {
          return i.attachedNode == o || o.isDescendantOf(i.attachedNode);
        };
        this._pointerObserver = this._scene.onPointerObservable.add(function(o) {
          if (i.enabled) {
            if (o.type == Le.POINTERDOWN)
              i.startAndReleaseDragOnPointerEvents && !i.dragging && o.pickInfo && o.pickInfo.hit && o.pickInfo.pickedMesh && o.pickInfo.pickedPoint && o.pickInfo.ray && r(o.pickInfo.pickedMesh) && i._activeDragButton === -1 && i.dragButtons.indexOf(o.event.button) !== -1 && (i._activeDragButton = o.event.button, i._activePointerInfo = o, i._startDrag(o.event.pointerId, o.pickInfo.ray, o.pickInfo.pickedPoint));
            else if (o.type == Le.POINTERUP)
              !i.startAndReleaseDragOnPointerEvents || i.currentDraggingPointerId != o.event.pointerId || i._activeDragButton !== o.event.button && i._activeDragButton !== -1 || i.releaseDrag();
            else if (o.type == Le.POINTERMOVE) {
              var a = o.event.pointerId;
              if (i.currentDraggingPointerId === n._AnyMouseId && a !== n._AnyMouseId) {
                var s = o.event;
                (s.pointerType === "mouse" || !i._scene.getEngine().hostInformation.isMobile && s instanceof MouseEvent) && (i._lastPointerRay[i.currentDraggingPointerId] && (i._lastPointerRay[a] = i._lastPointerRay[i.currentDraggingPointerId], delete i._lastPointerRay[i.currentDraggingPointerId]), i.currentDraggingPointerId = a);
              }
              i._lastPointerRay[a] || (i._lastPointerRay[a] = new gi(new v(), new v())), o.pickInfo && o.pickInfo.ray && (i._lastPointerRay[a].origin.copyFrom(o.pickInfo.ray.origin), i._lastPointerRay[a].direction.copyFrom(o.pickInfo.ray.direction), i.currentDraggingPointerId == a && i.dragging && i._moveDrag(o.pickInfo.ray));
            }
          } else
            i._attachedToElement && i.releaseDrag();
        }), this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add(function() {
          if (i._moving && i.moveAttached) {
            var o = !1;
            tr._RemoveAndStorePivotPoint(i.attachedNode), i._targetPosition.subtractToRef(i.attachedNode.absolutePosition, i._tmpVector), i._tmpVector.scaleInPlace(i.dragDeltaRatio), i.attachedNode.getAbsolutePosition().addToRef(i._tmpVector, i._tmpVector), i.validateDrag(i._tmpVector) && (i.attachedNode.setAbsolutePosition(i._tmpVector), o = !0), tr._RestorePivotPoint(i.attachedNode), o && i.attachedNode.computeWorldMatrix();
          }
        });
      }, n.prototype.releaseDrag = function() {
        if (this.dragging && (this.dragging = !1, this.onDragEndObservable.notifyObservers({ dragPlanePoint: this.lastDragPosition, pointerId: this.currentDraggingPointerId, pointerInfo: this._activePointerInfo })), this.currentDraggingPointerId = -1, this._activeDragButton = -1, this._activePointerInfo = null, this._moving = !1, this.detachCameraControls && this._attachedToElement && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
          if (this._scene.activeCamera.getClassName() === "ArcRotateCamera") {
            var t = this._scene.activeCamera;
            t.attachControl(!t.inputs || t.inputs.noPreventDefault, t._useCtrlForPanning, t._panningMouseButton);
          } else
            this._scene.activeCamera.attachControl(!this._scene.activeCamera.inputs || this._scene.activeCamera.inputs.noPreventDefault);
          this._attachedToElement = !1;
        }
      }, n.prototype.startDrag = function(t, e, i) {
        t === void 0 && (t = n._AnyMouseId), this._startDrag(t, e, i);
        var r = this._lastPointerRay[t];
        t === n._AnyMouseId && (r = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]]), r && this._moveDrag(r);
      }, n.prototype._startDrag = function(t, e, i) {
        if (this._scene.activeCamera && !this.dragging && this.attachedNode) {
          tr._RemoveAndStorePivotPoint(this.attachedNode), e ? (this._startDragRay.direction.copyFrom(e.direction), this._startDragRay.origin.copyFrom(e.origin)) : (this._startDragRay.origin.copyFrom(this._scene.activeCamera.position), this.attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector), this._tmpVector.subtractToRef(this._scene.activeCamera.position, this._startDragRay.direction)), this._updateDragPlanePosition(this._startDragRay, i || this._tmpVector);
          var r = this._pickWithRayOnDragPlane(this._startDragRay);
          r ? (this.dragging = !0, this.currentDraggingPointerId = t, this.lastDragPosition.copyFrom(r), this.onDragStartObservable.notifyObservers({ dragPlanePoint: r, pointerId: this.currentDraggingPointerId, pointerInfo: this._activePointerInfo }), this._targetPosition.copyFrom(this.attachedNode.getAbsolutePosition()), this.detachCameraControls && this._scene.activeCamera && this._scene.activeCamera.inputs && !this._scene.activeCamera.leftCamera && (this._scene.activeCamera.inputs.attachedToElement ? (this._scene.activeCamera.detachControl(), this._attachedToElement = !0) : this._attachedToElement = !1)) : this.releaseDrag(), tr._RestorePivotPoint(this.attachedNode);
        }
      }, n.prototype._moveDrag = function(t) {
        this._moving = !0;
        var e = this._pickWithRayOnDragPlane(t);
        if (e) {
          tr._RemoveAndStorePivotPoint(this.attachedNode), this.updateDragPlane && this._updateDragPlanePosition(t, e);
          var i = 0;
          this._options.dragAxis ? (this.useObjectOrientationForDragging ? v.TransformCoordinatesToRef(this._options.dragAxis, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis) : this._worldDragAxis.copyFrom(this._options.dragAxis), e.subtractToRef(this.lastDragPosition, this._tmpVector), i = v.Dot(this._tmpVector, this._worldDragAxis), this._worldDragAxis.scaleToRef(i, this._dragDelta)) : (i = this._dragDelta.length(), e.subtractToRef(this.lastDragPosition, this._dragDelta)), this._targetPosition.addInPlace(this._dragDelta), this.onDragObservable.notifyObservers({ dragDistance: i, delta: this._dragDelta, dragPlanePoint: e, dragPlaneNormal: this._dragPlane.forward, pointerId: this.currentDraggingPointerId, pointerInfo: this._activePointerInfo }), this.lastDragPosition.copyFrom(e), tr._RestorePivotPoint(this.attachedNode);
        }
      }, n.prototype._pickWithRayOnDragPlane = function(t) {
        var e = this;
        if (!t)
          return null;
        var i = Math.acos(v.Dot(this._dragPlane.forward, t.direction));
        if (i > Math.PI / 2 && (i = Math.PI - i), this.maxDragAngle > 0 && i > this.maxDragAngle) {
          if (this._useAlternatePickedPointAboveMaxDragAngle) {
            this._tmpVector.copyFrom(t.direction), this.attachedNode.absolutePosition.subtractToRef(t.origin, this._alternatePickedPoint), this._alternatePickedPoint.normalize(), this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed * v.Dot(this._alternatePickedPoint, this._tmpVector)), this._tmpVector.addInPlace(this._alternatePickedPoint);
            var r = v.Dot(this._dragPlane.forward, this._tmpVector);
            return this._dragPlane.forward.scaleToRef(-r, this._alternatePickedPoint), this._alternatePickedPoint.addInPlace(this._tmpVector), this._alternatePickedPoint.addInPlace(this.attachedNode.absolutePosition), this._alternatePickedPoint;
          }
          return null;
        }
        var o = n._PlaneScene.pickWithRay(t, function(a) {
          return a == e._dragPlane;
        });
        return o && o.hit && o.pickedMesh && o.pickedPoint ? o.pickedPoint : null;
      }, n.prototype._updateDragPlanePosition = function(t, e) {
        this._pointA.copyFrom(e), this._options.dragAxis ? (this.useObjectOrientationForDragging ? v.TransformCoordinatesToRef(this._options.dragAxis, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis) : this._localAxis.copyFrom(this._options.dragAxis), t.origin.subtractToRef(this._pointA, this._pointC), this._pointC.normalize(), Math.abs(v.Dot(this._localAxis, this._pointC)) > 0.999 ? Math.abs(v.Dot(v.UpReadOnly, this._pointC)) > 0.999 ? this._lookAt.copyFrom(v.Right()) : this._lookAt.copyFrom(v.UpReadOnly) : (v.CrossToRef(this._localAxis, this._pointC, this._lookAt), v.CrossToRef(this._localAxis, this._lookAt, this._lookAt), this._lookAt.normalize()), this._dragPlane.position.copyFrom(this._pointA), this._pointA.addToRef(this._lookAt, this._lookAt), this._dragPlane.lookAt(this._lookAt)) : this._options.dragPlaneNormal ? (this.useObjectOrientationForDragging ? v.TransformCoordinatesToRef(this._options.dragPlaneNormal, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis) : this._localAxis.copyFrom(this._options.dragPlaneNormal), this._dragPlane.position.copyFrom(this._pointA), this._pointA.addToRef(this._localAxis, this._lookAt), this._dragPlane.lookAt(this._lookAt)) : (this._dragPlane.position.copyFrom(this._pointA), this._dragPlane.lookAt(t.origin)), this._dragPlane.position.copyFrom(this.attachedNode.getAbsolutePosition()), this._dragPlane.computeWorldMatrix(!0);
      }, n.prototype.detach = function() {
        this._lastPointerRay = {}, this.attachedNode && (this.attachedNode.isNearGrabbable = !1), this._pointerObserver && this._scene.onPointerObservable.remove(this._pointerObserver), this._beforeRenderObserver && this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver), this._dragPlane && this._dragPlane.dispose(), this.releaseDrag();
      }, n._AnyMouseId = -2, n;
    }(), vR = function() {
      function n() {
        this._startDistance = 0, this._initialScale = new v(0, 0, 0), this._targetScale = new v(0, 0, 0), this._sceneRenderObserver = null, this._dragBehaviorA = new Co({}), this._dragBehaviorA.moveAttached = !1, this._dragBehaviorB = new Co({}), this._dragBehaviorB.moveAttached = !1;
      }
      return Object.defineProperty(n.prototype, "name", { get: function() {
        return "MultiPointerScale";
      }, enumerable: !1, configurable: !0 }), n.prototype.init = function() {
      }, n.prototype._getCurrentDistance = function() {
        return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length();
      }, n.prototype.attach = function(t) {
        var e = this;
        this._ownerNode = t, this._dragBehaviorA.onDragStartObservable.add(function() {
          e._dragBehaviorA.dragging && e._dragBehaviorB.dragging && (e._dragBehaviorA.currentDraggingPointerId == e._dragBehaviorB.currentDraggingPointerId ? e._dragBehaviorA.releaseDrag() : (e._initialScale.copyFrom(t.scaling), e._startDistance = e._getCurrentDistance()));
        }), this._dragBehaviorB.onDragStartObservable.add(function() {
          e._dragBehaviorA.dragging && e._dragBehaviorB.dragging && (e._dragBehaviorA.currentDraggingPointerId == e._dragBehaviorB.currentDraggingPointerId ? e._dragBehaviorB.releaseDrag() : (e._initialScale.copyFrom(t.scaling), e._startDistance = e._getCurrentDistance()));
        }), [this._dragBehaviorA, this._dragBehaviorB].forEach(function(i) {
          i.onDragObservable.add(function() {
            if (e._dragBehaviorA.dragging && e._dragBehaviorB.dragging) {
              var r = e._getCurrentDistance() / e._startDistance;
              e._initialScale.scaleToRef(r, e._targetScale);
            }
          });
        }), t.addBehavior(this._dragBehaviorA), t.addBehavior(this._dragBehaviorB), this._sceneRenderObserver = t.getScene().onBeforeRenderObservable.add(function() {
          if (e._dragBehaviorA.dragging && e._dragBehaviorB.dragging) {
            var i = e._targetScale.subtract(t.scaling).scaleInPlace(0.1);
            i.length() > 0.01 && t.scaling.addInPlace(i);
          }
        });
      }, n.prototype.detach = function() {
        var t = this;
        this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver), [this._dragBehaviorA, this._dragBehaviorB].forEach(function(e) {
          e.onDragStartObservable.clear(), e.onDragObservable.clear(), t._ownerNode.removeBehavior(e);
        });
      }, n;
    }(), Ip = function() {
      function n() {
        this._attachedToElement = !1, this._virtualMeshesInfo = {}, this._tmpVector = new v(), this._tmpQuaternion = new oe(), this._dragType = { NONE: 0, DRAG: 1, DRAG_WITH_CONTROLLER: 2, NEAR_DRAG: 3 }, this._moving = !1, this._dragging = this._dragType.NONE, this.draggableMeshes = null, this.zDragFactor = 3, this.currentDraggingPointerIds = [], this.detachCameraControls = !0, this.onDragStartObservable = new H(), this.onDragObservable = new H(), this.onDragEndObservable = new H(), this.allowMultiPointer = !0;
      }
      return Object.defineProperty(n.prototype, "currentDraggingPointerId", { get: function() {
        return this.currentDraggingPointerIds[0] !== void 0 ? this.currentDraggingPointerIds[0] : -1;
      }, set: function(t) {
        this.currentDraggingPointerIds[0] = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "currentDraggingPointerID", { get: function() {
        return this.currentDraggingPointerId;
      }, set: function(t) {
        this.currentDraggingPointerId = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "name", { get: function() {
        return "BaseSixDofDrag";
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isMoving", { get: function() {
        return this._moving;
      }, enumerable: !1, configurable: !0 }), n.prototype.init = function() {
      }, Object.defineProperty(n.prototype, "_pointerCamera", { get: function() {
        return this._scene.cameraToUseForPointers ? this._scene.cameraToUseForPointers : this._scene.activeCamera;
      }, enumerable: !1, configurable: !0 }), n.prototype._createVirtualMeshInfo = function() {
        var t = new Dt("", n._virtualScene);
        t.rotationQuaternion = new oe();
        var e = new Dt("", n._virtualScene);
        e.rotationQuaternion = new oe();
        var i = new Dt("", n._virtualScene);
        return i.rotationQuaternion = new oe(), { dragging: !1, moving: !1, dragMesh: t, originMesh: e, pivotMesh: i, startingPivotPosition: new v(), startingPivotOrientation: new oe(), startingPosition: new v(), startingOrientation: new oe(), lastOriginPosition: new v(), lastDragPosition: new v() };
      }, n.prototype._resetVirtualMeshesPosition = function() {
        for (var t = 0; t < this.currentDraggingPointerIds.length; t++)
          this._virtualMeshesInfo[this.currentDraggingPointerIds[t]].pivotMesh.position.copyFrom(this._ownerNode.getAbsolutePivotPoint()), this._virtualMeshesInfo[this.currentDraggingPointerIds[t]].pivotMesh.rotationQuaternion.copyFrom(this._ownerNode.rotationQuaternion), this._virtualMeshesInfo[this.currentDraggingPointerIds[t]].startingPivotPosition.copyFrom(this._virtualMeshesInfo[this.currentDraggingPointerIds[t]].pivotMesh.position), this._virtualMeshesInfo[this.currentDraggingPointerIds[t]].startingPivotOrientation.copyFrom(this._virtualMeshesInfo[this.currentDraggingPointerIds[t]].pivotMesh.rotationQuaternion), this._virtualMeshesInfo[this.currentDraggingPointerIds[t]].startingPosition.copyFrom(this._virtualMeshesInfo[this.currentDraggingPointerIds[t]].dragMesh.position), this._virtualMeshesInfo[this.currentDraggingPointerIds[t]].startingOrientation.copyFrom(this._virtualMeshesInfo[this.currentDraggingPointerIds[t]].dragMesh.rotationQuaternion);
      }, n.prototype._pointerUpdate2D = function(t, e, i) {
        !this._pointerCamera || this._pointerCamera.cameraRigMode != dt.RIG_MODE_NONE || this._pointerCamera._isLeftCamera || this._pointerCamera._isRightCamera || (t.origin.copyFrom(this._pointerCamera.globalPosition), i = 0);
        var r = this._virtualMeshesInfo[e], o = F.Vector3[0];
        t.origin.subtractToRef(r.lastOriginPosition, o), r.lastOriginPosition.copyFrom(t.origin);
        var a = -v.Dot(o, t.direction);
        r.originMesh.addChild(r.dragMesh), r.originMesh.addChild(r.pivotMesh), this._applyZOffset(r.dragMesh, a, i), this._applyZOffset(r.pivotMesh, a, i), r.originMesh.position.copyFrom(t.origin);
        var s = F.Vector3[0];
        t.origin.addToRef(t.direction, s), r.originMesh.lookAt(s), r.originMesh.removeChild(r.dragMesh), r.originMesh.removeChild(r.pivotMesh);
      }, n.prototype._pointerUpdateXR = function(t, e, i, r) {
        var o = this._virtualMeshesInfo[i];
        if (o.originMesh.position.copyFrom(t.position), this._dragging === this._dragType.NEAR_DRAG && e ? o.originMesh.rotationQuaternion.copyFrom(e.rotationQuaternion) : o.originMesh.rotationQuaternion.copyFrom(t.rotationQuaternion), o.pivotMesh.computeWorldMatrix(!0), o.dragMesh.computeWorldMatrix(!0), r !== 0) {
          var a = F.Vector3[0], s = F.Vector3[1];
          a.copyFrom(this._pointerCamera.getForwardRay().direction), o.originMesh.position.subtractToRef(o.lastOriginPosition, s), o.lastOriginPosition.copyFrom(o.originMesh.position);
          var l = s.length();
          s.normalize();
          var c = F.Vector3[2], u = F.Vector3[3];
          o.dragMesh.absolutePosition.subtractToRef(this._pointerCamera.globalPosition, c), o.dragMesh.absolutePosition.subtractToRef(o.originMesh.position, u);
          var h = u.length();
          c.normalize(), u.normalize();
          var d = Math.abs(v.Dot(s, u)) * v.Dot(s, a) * r * l * h;
          d < 0 && 0.01 - h > d && (d = Math.min(0.01 - h, 0)), u.scaleInPlace(d), u.addToRef(o.pivotMesh.absolutePosition, this._tmpVector), o.pivotMesh.setAbsolutePosition(this._tmpVector), u.addToRef(o.dragMesh.absolutePosition, this._tmpVector), o.dragMesh.setAbsolutePosition(this._tmpVector);
        }
      }, n.prototype.attach = function(t) {
        var e = this;
        this._ownerNode = t, this._scene = this._ownerNode.getScene(), n._virtualScene || (n._virtualScene = new Ue(this._scene.getEngine(), { virtual: !0 }), n._virtualScene.detachControl()), this._pointerObserver = this._scene.onPointerObservable.add(function(i) {
          var r = i.event.pointerId;
          e._virtualMeshesInfo[r] || (e._virtualMeshesInfo[r] = e._createVirtualMeshInfo());
          var o, a = e._virtualMeshesInfo[r], s = i.event.pointerType === "xr-near";
          if (i.type == Le.POINTERDOWN) {
            if (!a.dragging && i.pickInfo && i.pickInfo.hit && i.pickInfo.pickedMesh && i.pickInfo.pickedPoint && i.pickInfo.ray && (!s || i.pickInfo.aimTransform) && (o = i.pickInfo.pickedMesh, e._ownerNode === o || o.isDescendantOf(e._ownerNode) && (!e.draggableMeshes || e.draggableMeshes.indexOf(o) !== -1))) {
              if (!e.allowMultiPointer && e.currentDraggingPointerIds.length > 0)
                return;
              !e._pointerCamera || e._pointerCamera.cameraRigMode !== dt.RIG_MODE_NONE || e._pointerCamera._isLeftCamera || e._pointerCamera._isRightCamera || i.pickInfo.ray.origin.copyFrom(e._pointerCamera.globalPosition), e._ownerNode.computeWorldMatrix(!0);
              var l = e._virtualMeshesInfo[r];
              s ? (e._dragging = i.pickInfo.originMesh ? e._dragType.NEAR_DRAG : e._dragType.DRAG_WITH_CONTROLLER, l.originMesh.position.copyFrom(i.pickInfo.aimTransform.position), e._dragging === e._dragType.NEAR_DRAG && i.pickInfo.gripTransform ? l.originMesh.rotationQuaternion.copyFrom(i.pickInfo.gripTransform.rotationQuaternion) : l.originMesh.rotationQuaternion.copyFrom(i.pickInfo.aimTransform.rotationQuaternion)) : (e._dragging = e._dragType.DRAG, l.originMesh.position.copyFrom(i.pickInfo.ray.origin)), l.lastOriginPosition.copyFrom(l.originMesh.position), l.dragMesh.position.copyFrom(i.pickInfo.pickedPoint), l.lastDragPosition.copyFrom(i.pickInfo.pickedPoint), l.pivotMesh.position.copyFrom(e._ownerNode.getAbsolutePivotPoint()), l.pivotMesh.rotationQuaternion.copyFrom(e._ownerNode.absoluteRotationQuaternion), l.startingPosition.copyFrom(l.dragMesh.position), l.startingPivotPosition.copyFrom(l.pivotMesh.position), l.startingOrientation.copyFrom(l.dragMesh.rotationQuaternion), l.startingPivotOrientation.copyFrom(l.pivotMesh.rotationQuaternion), s ? (l.originMesh.addChild(l.dragMesh), l.originMesh.addChild(l.pivotMesh)) : l.originMesh.lookAt(l.dragMesh.position), l.dragging = !0, e.currentDraggingPointerIds.indexOf(r) === -1 && e.currentDraggingPointerIds.push(r), e.detachCameraControls && e._pointerCamera && !e._pointerCamera.leftCamera && (e._pointerCamera.inputs && e._pointerCamera.inputs.attachedToElement ? (e._pointerCamera.detachControl(), e._attachedToElement = !0) : e._attachedToElement = !1), e._targetDragStart(l.pivotMesh.position, l.pivotMesh.rotationQuaternion, r), e.onDragStartObservable.notifyObservers({ position: l.pivotMesh.position });
            }
          } else if (i.type == Le.POINTERUP || i.type == Le.POINTERDOUBLETAP) {
            var c = e.currentDraggingPointerIds.indexOf(r);
            a.dragging = !1, c !== -1 && (e.currentDraggingPointerIds.splice(c, 1), e.currentDraggingPointerIds.length === 0 && (e._moving = !1, e._dragging = e._dragType.NONE, e.detachCameraControls && e._attachedToElement && e._pointerCamera && !e._pointerCamera.leftCamera && (e._reattachCameraControls(), e._attachedToElement = !1)), a.originMesh.removeChild(a.dragMesh), a.originMesh.removeChild(a.pivotMesh), e._targetDragEnd(r), e.onDragEndObservable.notifyObservers({}));
          } else if (i.type == Le.POINTERMOVE && (c = e.currentDraggingPointerIds.indexOf(r)) !== -1 && a.dragging && i.pickInfo && (i.pickInfo.ray || i.pickInfo.aimTransform)) {
            var u = e.zDragFactor;
            (e.currentDraggingPointerIds.length > 1 || i.pickInfo.originMesh) && (u = 0), e._ownerNode.computeWorldMatrix(!0), s ? e._pointerUpdateXR(i.pickInfo.aimTransform, i.pickInfo.gripTransform, r, u) : e._pointerUpdate2D(i.pickInfo.ray, r, u), e._tmpQuaternion.copyFrom(a.startingPivotOrientation), e._tmpQuaternion.x = -e._tmpQuaternion.x, e._tmpQuaternion.y = -e._tmpQuaternion.y, e._tmpQuaternion.z = -e._tmpQuaternion.z, a.pivotMesh.absoluteRotationQuaternion.multiplyToRef(e._tmpQuaternion, e._tmpQuaternion), a.pivotMesh.absolutePosition.subtractToRef(a.startingPivotPosition, e._tmpVector), e.onDragObservable.notifyObservers({ delta: e._tmpVector, position: a.pivotMesh.position, pickInfo: i.pickInfo }), e._targetDrag(e._tmpVector, e._tmpQuaternion, r), a.lastDragPosition.copyFrom(a.dragMesh.absolutePosition), e._moving = !0;
          }
        });
      }, n.prototype._applyZOffset = function(t, e, i) {
        t.position.z -= t.position.z < 1 ? e * i : e * i * t.position.z, t.position.z < 0 && (t.position.z = 0);
      }, n.prototype._targetDragStart = function(t, e, i) {
      }, n.prototype._targetDrag = function(t, e, i) {
      }, n.prototype._targetDragEnd = function(t) {
      }, n.prototype._reattachCameraControls = function() {
        if (this._pointerCamera)
          if (this._pointerCamera.getClassName() === "ArcRotateCamera") {
            var t = this._pointerCamera;
            t.attachControl(!t.inputs || t.inputs.noPreventDefault, t._useCtrlForPanning, t._panningMouseButton);
          } else
            this._pointerCamera.attachControl(!this._pointerCamera.inputs || this._pointerCamera.inputs.noPreventDefault);
      }, n.prototype.detach = function() {
        for (var t in this._scene && (this.detachCameraControls && this._attachedToElement && this._pointerCamera && !this._pointerCamera.leftCamera && (this._reattachCameraControls(), this._attachedToElement = !1), this._scene.onPointerObservable.remove(this._pointerObserver)), this._virtualMeshesInfo)
          this._virtualMeshesInfo[t].originMesh.dispose(), this._virtualMeshesInfo[t].dragMesh.dispose();
        this.onDragEndObservable.clear(), this.onDragObservable.clear(), this.onDragStartObservable.clear();
      }, n;
    }(), Ng = function(n) {
      function t() {
        var e = n !== null && n.apply(this, arguments) || this;
        return e._sceneRenderObserver = null, e._targetPosition = new v(0, 0, 0), e._targetOrientation = new oe(), e._targetScaling = new v(1, 1, 1), e._startingPosition = new v(0, 0, 0), e._startingOrientation = new oe(), e._startingScaling = new v(1, 1, 1), e.onPositionChangedObservable = new H(), e.dragDeltaRatio = 0.2, e.rotateDraggedObject = !0, e.rotateAroundYOnly = !1, e.rotateWithMotionController = !0, e.disableMovement = !1, e.faceCameraOnDragStart = !1, e;
      }
      return D(t, n), Object.defineProperty(t.prototype, "name", { get: function() {
        return "SixDofDrag";
      }, enumerable: !1, configurable: !0 }), t.prototype.attach = function(e) {
        var i = this;
        n.prototype.attach.call(this, e), e.isNearGrabbable = !0, this._virtualTransformNode = new ai("virtual_sixDof", Ip._virtualScene), this._virtualTransformNode.rotationQuaternion = oe.Identity(), this._sceneRenderObserver = e.getScene().onBeforeRenderObservable.add(function() {
          if (i.currentDraggingPointerIds.length === 1 && i._moving && !i.disableMovement) {
            var r = e.parent;
            e.setParent(null), e.position.addInPlace(i._targetPosition.subtract(e.position).scale(i.dragDeltaRatio)), i.onPositionChangedObservable.notifyObservers({ position: e.absolutePosition }), (!r || r.scaling && !r.scaling.isNonUniformWithinEpsilon(1e-3)) && oe.SlerpToRef(e.rotationQuaternion, i._targetOrientation, i.dragDeltaRatio, e.rotationQuaternion), e.setParent(r);
          }
        });
      }, t.prototype._getPositionOffsetAround = function(e, i, r) {
        var o = F.Matrix[0], a = F.Matrix[1], s = F.Matrix[2], l = F.Matrix[3], c = F.Matrix[4];
        return B.TranslationToRef(e.x, e.y, e.z, o), B.TranslationToRef(-e.x, -e.y, -e.z, a), B.FromQuaternionToRef(r, s), B.ScalingToRef(i, i, i, l), a.multiplyToRef(s, c), c.multiplyToRef(l, c), c.multiplyToRef(o, c), c.getTranslation();
      }, t.prototype._onePointerPositionUpdated = function(e, i) {
        F.Vector3[0].setAll(0), this._dragging === this._dragType.DRAG ? this.rotateDraggedObject && (this.rotateAroundYOnly ? oe.RotationYawPitchRollToRef(i.toEulerAngles().y, 0, 0, F.Quaternion[0]) : F.Quaternion[0].copyFrom(i), F.Quaternion[0].multiplyToRef(this._startingOrientation, this._targetOrientation)) : (this._dragging === this._dragType.NEAR_DRAG || this._dragging === this._dragType.DRAG_WITH_CONTROLLER && this.rotateWithMotionController) && i.multiplyToRef(this._startingOrientation, this._targetOrientation), this._targetPosition.copyFrom(this._startingPosition).addInPlace(e);
      }, t.prototype._twoPointersPositionUpdated = function() {
        var e = this._virtualMeshesInfo[this.currentDraggingPointerIds[0]].startingPosition, i = this._virtualMeshesInfo[this.currentDraggingPointerIds[1]].startingPosition, r = F.Vector3[0];
        e.addToRef(i, r), r.scaleInPlace(0.5);
        var o = F.Vector3[1];
        i.subtractToRef(e, o);
        var a = this._virtualMeshesInfo[this.currentDraggingPointerIds[0]].dragMesh.absolutePosition, s = this._virtualMeshesInfo[this.currentDraggingPointerIds[1]].dragMesh.absolutePosition, l = F.Vector3[2];
        a.addToRef(s, l), l.scaleInPlace(0.5);
        var c = F.Vector3[3];
        s.subtractToRef(a, c);
        var u = c.length() / o.length(), h = l.subtract(r), d = oe.FromEulerAngles(0, v.GetAngleBetweenVectorsOnPlane(o.normalize(), c.normalize(), v.UpReadOnly), 0), p = this._ownerNode.parent;
        this._ownerNode.setParent(null);
        var f = this._getPositionOffsetAround(r.subtract(this._virtualTransformNode.getAbsolutePivotPoint()), u, d);
        this._virtualTransformNode.rotationQuaternion.multiplyToRef(d, this._ownerNode.rotationQuaternion), this._virtualTransformNode.scaling.scaleToRef(u, this._ownerNode.scaling), this._virtualTransformNode.position.addToRef(h.addInPlace(f), this._ownerNode.position), this.onPositionChangedObservable.notifyObservers({ position: this._ownerNode.position }), this._ownerNode.setParent(p);
      }, t.prototype._targetDragStart = function() {
        var e = this.currentDraggingPointerIds.length, i = this._ownerNode.parent;
        this._ownerNode.rotationQuaternion || (this._ownerNode.rotationQuaternion = oe.RotationYawPitchRoll(this._ownerNode.rotation.y, this._ownerNode.rotation.x, this._ownerNode.rotation.z));
        var r = this._ownerNode.getAbsolutePivotPoint();
        if (this._ownerNode.setParent(null), e === 1) {
          if (this._targetPosition.copyFrom(this._ownerNode.position), this._targetOrientation.copyFrom(this._ownerNode.rotationQuaternion), this._targetScaling.copyFrom(this._ownerNode.scaling), this.faceCameraOnDragStart && this._scene.activeCamera) {
            var o = F.Vector3[0];
            this._scene.activeCamera.position.subtractToRef(r, o), o.normalize();
            var a = F.Quaternion[0];
            this._scene.useRightHandedSystem ? oe.FromLookDirectionRHToRef(o, new v(0, 1, 0), a) : oe.FromLookDirectionLHToRef(o, new v(0, 1, 0), a), a.normalize(), oe.RotationYawPitchRollToRef(a.toEulerAngles().y, 0, 0, F.Quaternion[0]), this._targetOrientation.copyFrom(F.Quaternion[0]);
          }
          this._startingPosition.copyFrom(this._targetPosition), this._startingOrientation.copyFrom(this._targetOrientation), this._startingScaling.copyFrom(this._targetScaling);
        } else
          e === 2 && (this._virtualTransformNode.setPivotPoint(new v(0, 0, 0), ht.LOCAL), this._virtualTransformNode.position.copyFrom(this._ownerNode.position), this._virtualTransformNode.scaling.copyFrom(this._ownerNode.scaling), this._virtualTransformNode.rotationQuaternion.copyFrom(this._ownerNode.rotationQuaternion), this._virtualTransformNode.setPivotPoint(r, ht.WORLD), this._resetVirtualMeshesPosition());
        this._ownerNode.setParent(i);
      }, t.prototype._targetDrag = function(e, i) {
        this.currentDraggingPointerIds.length === 1 ? this._onePointerPositionUpdated(e, i) : this.currentDraggingPointerIds.length === 2 && this._twoPointersPositionUpdated();
      }, t.prototype._targetDragEnd = function() {
        if (this.currentDraggingPointerIds.length === 1) {
          this._resetVirtualMeshesPosition();
          var e = this.faceCameraOnDragStart;
          this.faceCameraOnDragStart = !1, this._targetDragStart(), this.faceCameraOnDragStart = e;
        }
      }, t.prototype.detach = function() {
        n.prototype.detach.call(this), this._ownerNode && (this._ownerNode.isNearGrabbable = !1, this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver)), this._virtualTransformNode && this._virtualTransformNode.dispose();
      }, t;
    }(Ip), yR = function() {
      function n() {
        this._attachPointLocalOffset = new v(), this._workingPosition = new v(), this._workingQuaternion = new oe(), this._lastTick = -1, this._hit = !1, this.hitNormalOffset = 0.05, this.meshes = [], this.interpolatePose = !0, this.lerpTime = 250, this.keepOrientationVertical = !0, this.enabled = !0, this.maxStickingDistance = 0.8;
      }
      return Object.defineProperty(n.prototype, "name", { get: function() {
        return "SurfaceMagnetism";
      }, enumerable: !1, configurable: !0 }), n.prototype.init = function() {
      }, n.prototype.attach = function(t, e) {
        this._attachedMesh = t, this._scene = e || t.getScene(), this._attachedMesh.rotationQuaternion || (this._attachedMesh.rotationQuaternion = oe.RotationYawPitchRoll(this._attachedMesh.rotation.y, this._attachedMesh.rotation.x, this._attachedMesh.rotation.z)), this.updateAttachPoint(), this._workingPosition.copyFrom(this._attachedMesh.position), this._workingQuaternion.copyFrom(this._attachedMesh.rotationQuaternion), this._addObservables();
      }, n.prototype.detach = function() {
        this._attachedMesh = null, this._removeObservables();
      }, n.prototype._getTargetPose = function(t) {
        if (!this._attachedMesh)
          return null;
        if (t && t.hit) {
          var e = t.getNormal(!0, !0), i = t.pickedPoint;
          if (!e || !i)
            return null;
          e.normalize();
          var r = F.Vector3[0];
          return r.copyFrom(e), r.scaleInPlace(this.hitNormalOffset), r.addInPlace(i), this._attachedMesh.parent && (F.Matrix[0].copyFrom(this._attachedMesh.parent.getWorldMatrix()).invert(), v.TransformNormalToRef(r, F.Matrix[0], r)), { position: r, quaternion: oe.RotationYawPitchRoll(-Math.atan2(e.x, -e.z), this.keepOrientationVertical ? 0 : Math.atan2(e.y, Math.sqrt(e.z * e.z + e.x * e.x)), 0) };
        }
        return null;
      }, n.prototype.updateAttachPoint = function() {
        this._getAttachPointOffsetToRef(this._attachPointLocalOffset);
      }, n.prototype.findAndUpdateTarget = function(t) {
        if (this._hit = !1, !t.ray)
          return !1;
        var e = t.ray.intersectsMeshes(this.meshes)[0];
        if (this._attachedMesh && e && e.hit && e.pickedMesh) {
          var i = this._getTargetPose(e);
          i && v.Distance(this._attachedMesh.position, i.position) < this.maxStickingDistance && (this._workingPosition.copyFrom(i.position), this._workingQuaternion.copyFrom(i.quaternion), this._hit = !0);
        }
        return this._hit;
      }, n.prototype._getAttachPointOffsetToRef = function(t) {
        if (this._attachedMesh) {
          var e = F.Quaternion[0];
          e.copyFrom(this._attachedMesh.rotationQuaternion), this._attachedMesh.rotationQuaternion.copyFromFloats(0, 0, 0, 1), this._attachedMesh.computeWorldMatrix();
          var i = this._attachedMesh.getHierarchyBoundingVectors(), r = F.Vector3[0];
          i.max.addToRef(i.min, r), r.scaleInPlace(0.5), r.z = i.max.z;
          var o = F.Matrix[0];
          this._attachedMesh.getWorldMatrix().invertToRef(o), v.TransformCoordinatesToRef(r, o, t), this._attachedMesh.rotationQuaternion.copyFrom(e);
        } else
          t.setAll(0);
      }, n.prototype._updateTransformToGoal = function(t) {
        if (this._attachedMesh && this._hit) {
          var e = this._attachedMesh.parent;
          this._attachedMesh.setParent(null);
          var i = F.Vector3[0];
          if (v.TransformNormalToRef(this._attachPointLocalOffset, this._attachedMesh.getWorldMatrix(), i), !this.interpolatePose)
            return this._attachedMesh.position.copyFrom(this._workingPosition).subtractInPlace(i), void this._attachedMesh.rotationQuaternion.copyFrom(this._workingQuaternion);
          var r = new v();
          v.SmoothToRef(this._attachedMesh.position, this._workingPosition, t, this.lerpTime, r), this._attachedMesh.position.copyFrom(r);
          var o = new oe();
          o.copyFrom(this._attachedMesh.rotationQuaternion), oe.SmoothToRef(o, this._workingQuaternion, t, this.lerpTime, this._attachedMesh.rotationQuaternion), this._attachedMesh.setParent(e);
        }
      }, n.prototype._addObservables = function() {
        var t = this;
        this._pointerObserver = this._scene.onPointerObservable.add(function(e) {
          t.enabled && e.type == Le.POINTERMOVE && e.pickInfo && t.findAndUpdateTarget(e.pickInfo);
        }), this._lastTick = Date.now(), this._onBeforeRender = this._scene.onBeforeRenderObservable.add(function() {
          var e = Date.now();
          t._updateTransformToGoal(e - t._lastTick), t._lastTick = e;
        });
      }, n.prototype._removeObservables = function() {
        this._scene.onPointerObservable.remove(this._pointerObserver), this._scene.onBeforeRenderObservable.remove(this._onBeforeRender), this._pointerObserver = null, this._onBeforeRender = null;
      }, n;
    }(), bR = function() {
      function n() {
        this._tmpQuaternion = new oe(), this._tmpVectors = [new v(), new v(), new v(), new v(), new v(), new v(), new v()], this._tmpMatrix = new B(), this._tmpInvertView = new B(), this._tmpForward = new v(), this._tmpNodeForward = new v(), this._tmpPosition = new v(), this._workingPosition = new v(), this._workingQuaternion = new oe(), this._lastTick = -1, this._recenterNextUpdate = !0, this.interpolatePose = !0, this.lerpTime = 500, this.ignoreCameraPitchAndRoll = !1, this.pitchOffset = 15, this.maxViewVerticalDegrees = 30, this.maxViewHorizontalDegrees = 30, this.orientToCameraDeadzoneDegrees = 60, this.ignoreDistanceClamp = !1, this.ignoreAngleClamp = !1, this.verticalMaxDistance = 0, this.defaultDistance = 0.8, this.maximumDistance = 2, this.minimumDistance = 0.3, this.useFixedVerticalOffset = !1, this.fixedVerticalOffset = 0, this._enabled = !0;
      }
      return Object.defineProperty(n.prototype, "followedCamera", { get: function() {
        return this._followedCamera || this._scene.activeCamera;
      }, set: function(t) {
        this._followedCamera = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "name", { get: function() {
        return "Follow";
      }, enumerable: !1, configurable: !0 }), n.prototype.init = function() {
      }, n.prototype.attach = function(t, e) {
        this._scene = t.getScene(), this.attachedNode = t, e && (this.followedCamera = e), this._addObservables();
      }, n.prototype.detach = function() {
        this.attachedNode = null, this._removeObservables();
      }, n.prototype.recenter = function() {
        this._recenterNextUpdate = !0;
      }, n.prototype._angleBetweenVectorAndPlane = function(t, e) {
        return this._tmpVectors[0].copyFrom(t), t = this._tmpVectors[0], this._tmpVectors[1].copyFrom(e), e = this._tmpVectors[1], t.normalize(), e.normalize(), Math.PI / 2 - Math.acos(v.Dot(t, e));
      }, n.prototype._length2D = function(t) {
        return Math.sqrt(t.x * t.x + t.z * t.z);
      }, n.prototype._distanceClamp = function(t, e) {
        e === void 0 && (e = !1);
        var i = this.minimumDistance, r = this.maximumDistance, o = this.defaultDistance, a = this._tmpVectors[0];
        a.copyFrom(t);
        var s = a.length();
        if (a.normalizeFromLength(s), this.ignoreCameraPitchAndRoll) {
          i = this._length2D(a) * i, r = this._length2D(a) * r;
          var l = this._length2D(t);
          a.scaleInPlace(s / l), s = l;
        }
        var c;
        return c = e ? o : ue.Clamp(s, i, r), t.copyFrom(a).scaleInPlace(c), s !== c;
      }, n.prototype._applyVerticalClamp = function(t) {
        this.verticalMaxDistance !== 0 && (t.y = ue.Clamp(t.y, -this.verticalMaxDistance, this.verticalMaxDistance));
      }, n.prototype._toOrientationQuatToRef = function(t, e) {
        oe.RotationYawPitchRollToRef(Math.atan2(t.x, t.z), Math.atan2(t.y, Math.sqrt(t.z * t.z + t.x * t.x)), 0, e);
      }, n.prototype._applyPitchOffset = function(t) {
        var e = this._tmpVectors[0], i = this._tmpVectors[1];
        e.copyFromFloats(0, 0, this._scene.useRightHandedSystem ? -1 : 1), i.copyFromFloats(1, 0, 0), v.TransformNormalToRef(e, t, e), e.y = 0, e.normalize(), v.TransformNormalToRef(i, t, i), oe.RotationAxisToRef(i, this.pitchOffset * Math.PI / 180, this._tmpQuaternion), e.rotateByQuaternionToRef(this._tmpQuaternion, e), this._toOrientationQuatToRef(e, this._tmpQuaternion), this._tmpQuaternion.toRotationMatrix(this._tmpMatrix), t.copyFrom(this._tmpMatrix);
      }, n.prototype._angularClamp = function(t, e) {
        var i = this._tmpVectors[5];
        i.copyFromFloats(0, 0, this._scene.useRightHandedSystem ? -1 : 1);
        var r = this._tmpVectors[6];
        r.copyFromFloats(1, 0, 0), v.TransformNormalToRef(i, t, i), v.TransformNormalToRef(r, t, r);
        var o = v.UpReadOnly;
        if (e.length() < Ge)
          return !1;
        var a = !1, s = this._tmpQuaternion;
        if (this.ignoreCameraPitchAndRoll) {
          var l = v.GetAngleBetweenVectorsOnPlane(e, i, r);
          oe.RotationAxisToRef(r, l, s), e.rotateByQuaternionToRef(s, e);
        } else {
          var c = -v.GetAngleBetweenVectorsOnPlane(e, i, r), u = this.maxViewVerticalDegrees * Math.PI / 180 * 0.5;
          c < -u ? (oe.RotationAxisToRef(r, -c - u, s), e.rotateByQuaternionToRef(s, e), a = !0) : c > u && (oe.RotationAxisToRef(r, -c + u, s), e.rotateByQuaternionToRef(s, e), a = !0);
        }
        var h = this._angleBetweenVectorAndPlane(e, r) * (this._scene.useRightHandedSystem ? -1 : 1), d = this.maxViewHorizontalDegrees * Math.PI / 180 * 0.5;
        return h < -d ? (oe.RotationAxisToRef(o, -h - d, s), e.rotateByQuaternionToRef(s, e), a = !0) : h > d && (oe.RotationAxisToRef(o, -h + d, s), e.rotateByQuaternionToRef(s, e), a = !0), a;
      }, n.prototype._orientationClamp = function(t, e) {
        var i, r = this._tmpVectors[0];
        r.copyFrom(t).scaleInPlace(-1).normalize();
        var o = this._tmpVectors[1], a = this._tmpVectors[2];
        o.copyFromFloats(0, 1, 0), v.CrossToRef(r, o, a);
        var s = a.length();
        s < Ge || (a.normalizeFromLength(s), v.CrossToRef(a, r, o), !((i = this.attachedNode) === null || i === void 0) && i.getScene().useRightHandedSystem ? oe.FromLookDirectionRHToRef(r, o, e) : oe.FromLookDirectionLHToRef(r, o, e));
      }, n.prototype._passedOrientationDeadzone = function(t, e) {
        var i = this._tmpVectors[5];
        return i.copyFrom(t), i.normalize(), 180 * Math.abs(v.GetAngleBetweenVectorsOnPlane(e, i, v.UpReadOnly)) / Math.PI > this.orientToCameraDeadzoneDegrees;
      }, n.prototype._updateLeashing = function(t) {
        if (this.attachedNode && this._enabled) {
          var e = this.attachedNode.parent;
          this.attachedNode.setParent(null);
          var i = this.attachedNode.getWorldMatrix(), r = this._workingPosition, o = this._workingQuaternion, a = this.attachedNode.getPivotPoint(), s = this._tmpInvertView;
          s.copyFrom(t.getViewMatrix()), s.invert(), v.TransformCoordinatesToRef(a, i, r);
          var l = this._tmpPosition;
          l.copyFromFloats(0, 0, 0), v.TransformCoordinatesToRef(l, i, l), l.scaleInPlace(-1).subtractInPlace(a), r.subtractInPlace(t.globalPosition), this.ignoreCameraPitchAndRoll && this._applyPitchOffset(s);
          var c = !1, u = this._tmpForward;
          u.copyFromFloats(0, 0, this._scene.useRightHandedSystem ? -1 : 1), v.TransformNormalToRef(u, s, u);
          var h = this._tmpNodeForward;
          if (h.copyFromFloats(0, 0, this._scene.useRightHandedSystem ? -1 : 1), v.TransformNormalToRef(h, i, h), this._recenterNextUpdate)
            r.copyFrom(u).scaleInPlace(this.defaultDistance);
          else if (this.ignoreAngleClamp) {
            var d = r.length();
            r.copyFrom(u).scaleInPlace(d);
          } else
            c = this._angularClamp(s, r);
          var p = !1;
          this.ignoreDistanceClamp || (p = this._distanceClamp(r, c), this._applyVerticalClamp(r)), this.useFixedVerticalOffset && (r.y = l.y - t.globalPosition.y + this.fixedVerticalOffset), (c || p || this._passedOrientationDeadzone(r, h) || this._recenterNextUpdate) && this._orientationClamp(r, o), this._workingPosition.subtractInPlace(a), this._recenterNextUpdate = !1, this.attachedNode.setParent(e);
        }
      }, n.prototype._updateTransformToGoal = function(t) {
        if (this.attachedNode && this.followedCamera && this._enabled) {
          this.attachedNode.rotationQuaternion || (this.attachedNode.rotationQuaternion = oe.Identity());
          var e = this.attachedNode.parent;
          if (this.attachedNode.setParent(null), !this.interpolatePose)
            return this.attachedNode.position.copyFrom(this.followedCamera.globalPosition).addInPlace(this._workingPosition), void this.attachedNode.rotationQuaternion.copyFrom(this._workingQuaternion);
          var i = new v();
          i.copyFrom(this.attachedNode.position).subtractInPlace(this.followedCamera.globalPosition), v.SmoothToRef(i, this._workingPosition, t, this.lerpTime, i), i.addInPlace(this.followedCamera.globalPosition), this.attachedNode.position.copyFrom(i);
          var r = new oe();
          r.copyFrom(this.attachedNode.rotationQuaternion), oe.SmoothToRef(r, this._workingQuaternion, t, this.lerpTime, this.attachedNode.rotationQuaternion), this.attachedNode.setParent(e);
        }
      }, n.prototype._addObservables = function() {
        var t = this;
        this._lastTick = Date.now(), this._onBeforeRender = this._scene.onBeforeRenderObservable.add(function() {
          if (t.followedCamera) {
            var e = Date.now();
            t._updateLeashing(t.followedCamera), t._updateTransformToGoal(e - t._lastTick), t._lastTick = e;
          }
        });
      }, n.prototype._removeObservables = function() {
        this._onBeforeRender && this._scene.onBeforeRenderObservable.remove(this._onBeforeRender);
      }, n;
    }(), vi = function() {
      function n() {
      }
      return n.ANCHOR_SYSTEM = "xr-anchor-system", n.BACKGROUND_REMOVER = "xr-background-remover", n.HIT_TEST = "xr-hit-test", n.MESH_DETECTION = "xr-mesh-detection", n.PHYSICS_CONTROLLERS = "xr-physics-controller", n.PLANE_DETECTION = "xr-plane-detection", n.POINTER_SELECTION = "xr-controller-pointer-selection", n.TELEPORTATION = "xr-controller-teleportation", n.FEATURE_POINTS = "xr-feature-points", n.HAND_TRACKING = "xr-hand-tracking", n.IMAGE_TRACKING = "xr-image-tracking", n.NEAR_INTERACTION = "xr-near-interaction", n.DOM_OVERLAY = "xr-dom-overlay", n.MOVEMENT = "xr-controller-movement", n.LIGHT_ESTIMATION = "xr-light-estimation", n.EYE_TRACKING = "xr-eye-tracking", n.WALKING_LOCOMOTION = "xr-walking-locomotion", n.LAYERS = "xr-layers", n.DEPTH_SENSING = "xr-depth-sensing", n.SPACE_WARP = "xr-space-warp", n.RAW_CAMERA_ACCESS = "xr-raw-camera-access", n;
    }(), Wi = function() {
      function n(t) {
        var e = this;
        this._xrSessionManager = t, this._features = {}, this._xrSessionManager.onXRSessionInit.add(function() {
          e.getEnabledFeatures().forEach(function(i) {
            var r = e._features[i];
            !r.enabled || r.featureImplementation.attached || r.featureImplementation.disableAutoAttach || e.attachFeature(i);
          });
        }), this._xrSessionManager.onXRSessionEnded.add(function() {
          e.getEnabledFeatures().forEach(function(i) {
            var r = e._features[i];
            r.enabled && r.featureImplementation.attached && e.detachFeature(i);
          });
        });
      }
      return n.AddWebXRFeature = function(t, e, i, r) {
        i === void 0 && (i = 1), r === void 0 && (r = !1), this._AvailableFeatures[t] = this._AvailableFeatures[t] || { latest: i }, i > this._AvailableFeatures[t].latest && (this._AvailableFeatures[t].latest = i), r && (this._AvailableFeatures[t].stable = i), this._AvailableFeatures[t][i] = e;
      }, n.ConstructFeature = function(t, e, i, r) {
        e === void 0 && (e = 1);
        var o = this._AvailableFeatures[t][e];
        if (!o)
          throw new Error("feature not found");
        return o(i, r);
      }, n.GetAvailableFeatures = function() {
        return Object.keys(this._AvailableFeatures);
      }, n.GetAvailableVersions = function(t) {
        return Object.keys(this._AvailableFeatures[t]);
      }, n.GetLatestVersionOfFeature = function(t) {
        return this._AvailableFeatures[t] && this._AvailableFeatures[t].latest || -1;
      }, n.GetStableVersionOfFeature = function(t) {
        return this._AvailableFeatures[t] && this._AvailableFeatures[t].stable || -1;
      }, n.prototype.attachFeature = function(t) {
        var e = this._features[t];
        e && e.enabled && !e.featureImplementation.attached && e.featureImplementation.attach();
      }, n.prototype.detachFeature = function(t) {
        var e = this._features[t];
        e && e.featureImplementation.attached && e.featureImplementation.detach();
      }, n.prototype.disableFeature = function(t) {
        var e = typeof t == "string" ? t : t.Name, i = this._features[e];
        return !(!i || !i.enabled || (i.enabled = !1, this.detachFeature(e), i.featureImplementation.dispose(), delete this._features[e], 0));
      }, n.prototype.dispose = function() {
        var t = this;
        this.getEnabledFeatures().forEach(function(e) {
          t.disableFeature(e);
        });
      }, n.prototype.enableFeature = function(t, e, i, r, o) {
        var a = this;
        e === void 0 && (e = "latest"), i === void 0 && (i = {}), r === void 0 && (r = !0), o === void 0 && (o = !0);
        var s = typeof t == "string" ? t : t.Name, l = 0;
        if (typeof e == "string") {
          if (!e)
            throw new Error("Error in provided version - ".concat(s, " (").concat(e, ")"));
          if ((l = e === "stable" ? n.GetStableVersionOfFeature(s) : e === "latest" ? n.GetLatestVersionOfFeature(s) : +e) === -1 || isNaN(l))
            throw new Error("feature not found - ".concat(s, " (").concat(e, ")"));
        } else
          l = e;
        var c = n._ConflictingFeatures[s];
        if (c !== void 0 && this.getEnabledFeatures().indexOf(c) !== -1)
          throw new Error("Feature ".concat(s, " cannot be enabled while ").concat(c, " is enabled."));
        var u = this._features[s], h = n.ConstructFeature(s, l, this._xrSessionManager, i);
        if (!h)
          throw new Error("feature not found - ".concat(s));
        u && this.disableFeature(s);
        var d = h();
        if (d.dependsOn) {
          var p = d.dependsOn.every(function(f) {
            return !!a._features[f];
          });
          if (!p)
            throw new Error("Dependant features missing. Make sure the following features are enabled - ".concat(d.dependsOn.join(", ")));
        }
        if (d.isCompatible())
          return this._features[s] = { featureImplementation: d, enabled: !0, version: l, required: o }, r ? this._xrSessionManager.session && !this._features[s].featureImplementation.attached && this.attachFeature(s) : this._features[s].featureImplementation.disableAutoAttach = !0, this._features[s].featureImplementation;
        if (o)
          throw new Error("required feature not compatible");
        return de.Warn("Feature ".concat(s, " not compatible with the current environment/browser and was not enabled.")), d;
      }, n.prototype.getEnabledFeature = function(t) {
        return this._features[t] && this._features[t].featureImplementation;
      }, n.prototype.getEnabledFeatures = function() {
        return Object.keys(this._features);
      }, n.prototype._extendXRSessionInitObject = function(t) {
        return Ft(this, void 0, void 0, function() {
          var e, i, r, o, a, s, l;
          return Bt(this, function(c) {
            switch (c.label) {
              case 0:
                e = this.getEnabledFeatures(), i = 0, r = e, c.label = 1;
              case 1:
                return i < r.length ? (o = r[i], a = this._features[o], (s = a.featureImplementation.xrNativeFeatureName) && (a.required ? (t.requiredFeatures = t.requiredFeatures || [], t.requiredFeatures.indexOf(s) === -1 && t.requiredFeatures.push(s)) : (t.optionalFeatures = t.optionalFeatures || [], t.optionalFeatures.indexOf(s) === -1 && t.optionalFeatures.push(s))), a.featureImplementation.getXRSessionInitExtension ? [4, a.featureImplementation.getXRSessionInitExtension()] : [3, 3]) : [3, 4];
              case 2:
                l = c.sent(), t = je(je({}, t), l), c.label = 3;
              case 3:
                return i++, [3, 1];
              case 4:
                return [2, t];
            }
          });
        });
      }, n._AvailableFeatures = {}, n._ConflictingFeatures = ((Dg = {})[vi.TELEPORTATION] = vi.MOVEMENT, Dg[vi.MOVEMENT] = vi.TELEPORTATION, Dg), n;
    }(), Qi = function() {
      function n(t) {
        this._xrSessionManager = t, this._attached = !1, this._removeOnDetach = [], this.isDisposed = !1, this.disableAutoAttach = !1, this.xrNativeFeatureName = "", this.onFeatureAttachObservable = new H(), this.onFeatureDetachObservable = new H();
      }
      return Object.defineProperty(n.prototype, "attached", { get: function() {
        return this._attached;
      }, enumerable: !1, configurable: !0 }), n.prototype.attach = function(t) {
        var e = this;
        if (this.isDisposed)
          return !1;
        if (t)
          this.attached && this.detach();
        else if (this.attached)
          return !1;
        return this._attached = !0, this._addNewAttachObserver(this._xrSessionManager.onXRFrameObservable, function(i) {
          return e._onXRFrame(i);
        }), this.onFeatureAttachObservable.notifyObservers(this), !0;
      }, n.prototype.detach = function() {
        return this._attached ? (this._attached = !1, this._removeOnDetach.forEach(function(t) {
          t.observable.remove(t.observer);
        }), this.onFeatureDetachObservable.notifyObservers(this), !0) : (this.disableAutoAttach = !0, !1);
      }, n.prototype.dispose = function() {
        this.detach(), this.isDisposed = !0, this.onFeatureAttachObservable.clear(), this.onFeatureDetachObservable.clear();
      }, n.prototype.isCompatible = function() {
        return !0;
      }, n.prototype._addNewAttachObserver = function(t, e) {
        this._removeOnDetach.push({ observable: t, observer: t.add(e) });
      }, n;
    }(), Ii = function() {
      function n(t, e) {
        this.type = t, this.jointData = e, e.nativeParams = e.nativeParams || {};
      }
      return Object.defineProperty(n.prototype, "physicsJoint", { get: function() {
        return this._physicsJoint;
      }, set: function(t) {
        this._physicsJoint, this._physicsJoint = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "physicsPlugin", { set: function(t) {
        this._physicsPlugin = t;
      }, enumerable: !1, configurable: !0 }), n.prototype.executeNativeFunction = function(t) {
        t(this._physicsPlugin.world, this._physicsJoint);
      }, n.DistanceJoint = 0, n.HingeJoint = 1, n.BallAndSocketJoint = 2, n.WheelJoint = 3, n.SliderJoint = 4, n.PrismaticJoint = 5, n.UniversalJoint = 6, n.Hinge2Joint = n.WheelJoint, n.PointToPointJoint = 8, n.SpringJoint = 9, n.LockJoint = 10, n;
    }(), TR = function(n) {
      function t(e) {
        return n.call(this, Ii.DistanceJoint, e) || this;
      }
      return D(t, n), t.prototype.updateDistance = function(e, i) {
        this._physicsPlugin.updateDistanceJoint(this, e, i);
      }, t;
    }(Ii), Mp = function(n) {
      function t(e, i) {
        return n.call(this, e, i) || this;
      }
      return D(t, n), t.prototype.setMotor = function(e, i) {
        this._physicsPlugin.setMotor(this, e || 0, i);
      }, t.prototype.setLimit = function(e, i) {
        this._physicsPlugin.setLimit(this, e, i);
      }, t;
    }(Ii), ER = function(n) {
      function t(e) {
        return n.call(this, Ii.HingeJoint, e) || this;
      }
      return D(t, n), t.prototype.setMotor = function(e, i) {
        this._physicsPlugin.setMotor(this, e || 0, i);
      }, t.prototype.setLimit = function(e, i) {
        this._physicsPlugin.setLimit(this, e, i);
      }, t;
    }(Mp), SR = function(n) {
      function t(e) {
        return n.call(this, Ii.Hinge2Joint, e) || this;
      }
      return D(t, n), t.prototype.setMotor = function(e, i, r) {
        r === void 0 && (r = 0), this._physicsPlugin.setMotor(this, e || 0, i, r);
      }, t.prototype.setLimit = function(e, i, r) {
        r === void 0 && (r = 0), this._physicsPlugin.setLimit(this, e, i, r);
      }, t;
    }(Mp);
    ie._PhysicsImpostorParser = function(n, t, e) {
      return new bt(t, e.physicsImpostor, { mass: e.physicsMass, friction: e.physicsFriction, restitution: e.physicsRestitution }, n);
    };
    var Po, bt = function() {
      function n(t, e, i, r) {
        i === void 0 && (i = { mass: 0 });
        var o = this;
        this.object = t, this.type = e, this._options = i, this._scene = r, this._pluginData = {}, this._bodyUpdateRequired = !1, this._onBeforePhysicsStepCallbacks = new Array(), this._onAfterPhysicsStepCallbacks = new Array(), this._onPhysicsCollideCallbacks = [], this._deltaPosition = v.Zero(), this._isDisposed = !1, this.soft = !1, this.segments = 0, this._tmpQuat = new oe(), this._tmpQuat2 = new oe(), this.beforeStep = function() {
          o._physicsEngine && (o.object.translate(o._deltaPosition, -1), o._deltaRotationConjugated && o.object.rotationQuaternion && o.object.rotationQuaternion.multiplyToRef(o._deltaRotationConjugated, o.object.rotationQuaternion), o.object.computeWorldMatrix(!1), o.object.parent && o.object.rotationQuaternion ? (o.getParentsRotation(), o._tmpQuat.multiplyToRef(o.object.rotationQuaternion, o._tmpQuat)) : o._tmpQuat.copyFrom(o.object.rotationQuaternion || new oe()), o._options.disableBidirectionalTransformation || o.object.rotationQuaternion && o._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(o, o.object.getAbsolutePosition(), o._tmpQuat), o._onBeforePhysicsStepCallbacks.forEach(function(a) {
            a(o);
          }));
        }, this.afterStep = function() {
          o._physicsEngine && (o._onAfterPhysicsStepCallbacks.forEach(function(a) {
            a(o);
          }), o._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(o), o.object.parent && o.object.rotationQuaternion && (o.getParentsRotation(), o._tmpQuat.conjugateInPlace(), o._tmpQuat.multiplyToRef(o.object.rotationQuaternion, o.object.rotationQuaternion)), o.object.setAbsolutePosition(o.object.position), o._deltaRotation ? (o.object.rotationQuaternion && o.object.rotationQuaternion.multiplyToRef(o._deltaRotation, o.object.rotationQuaternion), o._deltaPosition.applyRotationQuaternionToRef(o._deltaRotation, n._TmpVecs[0]), o.object.translate(n._TmpVecs[0], 1)) : o.object.translate(o._deltaPosition, 1), o.object.computeWorldMatrix(!0));
        }, this.onCollideEvent = null, this.onCollide = function(a) {
          if ((o._onPhysicsCollideCallbacks.length || o.onCollideEvent) && o._physicsEngine) {
            var s = o._physicsEngine.getImpostorWithPhysicsBody(a.body);
            s && (o.onCollideEvent && o.onCollideEvent(o, s), o._onPhysicsCollideCallbacks.filter(function(l) {
              return l.otherImpostors.indexOf(s) !== -1;
            }).forEach(function(l) {
              l.callback(o, s, a.point, a.distance, a.impulse, a.normal);
            }));
          }
        }, this.object ? (this.object.parent && i.mass !== 0 && q.Warn("A physics impostor has been created for an object which has a parent. Babylon physics currently works in local space so unexpected issues may occur."), !this._scene && t.getScene && (this._scene = t.getScene()), this._scene && (this.type > 100 && (this.soft = !0), this._physicsEngine = this._scene.getPhysicsEngine(), this._physicsEngine ? (this.object.rotationQuaternion || (this.object.rotation ? this.object.rotationQuaternion = oe.RotationYawPitchRoll(this.object.rotation.y, this.object.rotation.x, this.object.rotation.z) : this.object.rotationQuaternion = new oe()), this._options.mass = i.mass === void 0 ? 0 : i.mass, this._options.friction = i.friction === void 0 ? 0.2 : i.friction, this._options.restitution = i.restitution === void 0 ? 0.2 : i.restitution, this.soft && (this._options.mass = this._options.mass > 0 ? this._options.mass : 1, this._options.pressure = i.pressure === void 0 ? 200 : i.pressure, this._options.stiffness = i.stiffness === void 0 ? 1 : i.stiffness, this._options.velocityIterations = i.velocityIterations === void 0 ? 20 : i.velocityIterations, this._options.positionIterations = i.positionIterations === void 0 ? 20 : i.positionIterations, this._options.fixedPoints = i.fixedPoints === void 0 ? 0 : i.fixedPoints, this._options.margin = i.margin === void 0 ? 0 : i.margin, this._options.damping = i.damping === void 0 ? 0 : i.damping, this._options.path = i.path === void 0 ? null : i.path, this._options.shape = i.shape === void 0 ? null : i.shape), this._joints = [], !this.object.parent || this._options.ignoreParent ? this._init() : this.object.parent.physicsImpostor && q.Warn("You must affect impostors to children before affecting impostor to parent.")) : q.Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors."))) : q.Error("No object was provided. A physics object is obligatory");
      }
      return Object.defineProperty(n.prototype, "isDisposed", { get: function() {
        return this._isDisposed;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "mass", { get: function() {
        return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyMass(this) : 0;
      }, set: function(t) {
        this.setMass(t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "friction", { get: function() {
        return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyFriction(this) : 0;
      }, set: function(t) {
        this._physicsEngine && this._physicsEngine.getPhysicsPlugin().setBodyFriction(this, t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "restitution", { get: function() {
        return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this) : 0;
      }, set: function(t) {
        this._physicsEngine && this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this, t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "pressure", { get: function() {
        if (!this._physicsEngine)
          return 0;
        var t = this._physicsEngine.getPhysicsPlugin();
        return t.setBodyPressure ? t.getBodyPressure(this) : 0;
      }, set: function(t) {
        if (this._physicsEngine) {
          var e = this._physicsEngine.getPhysicsPlugin();
          e.setBodyPressure && e.setBodyPressure(this, t);
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "stiffness", { get: function() {
        if (!this._physicsEngine)
          return 0;
        var t = this._physicsEngine.getPhysicsPlugin();
        return t.getBodyStiffness ? t.getBodyStiffness(this) : 0;
      }, set: function(t) {
        if (this._physicsEngine) {
          var e = this._physicsEngine.getPhysicsPlugin();
          e.setBodyStiffness && e.setBodyStiffness(this, t);
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "velocityIterations", { get: function() {
        if (!this._physicsEngine)
          return 0;
        var t = this._physicsEngine.getPhysicsPlugin();
        return t.getBodyVelocityIterations ? t.getBodyVelocityIterations(this) : 0;
      }, set: function(t) {
        if (this._physicsEngine) {
          var e = this._physicsEngine.getPhysicsPlugin();
          e.setBodyVelocityIterations && e.setBodyVelocityIterations(this, t);
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "positionIterations", { get: function() {
        if (!this._physicsEngine)
          return 0;
        var t = this._physicsEngine.getPhysicsPlugin();
        return t.getBodyPositionIterations ? t.getBodyPositionIterations(this) : 0;
      }, set: function(t) {
        if (this._physicsEngine) {
          var e = this._physicsEngine.getPhysicsPlugin();
          e.setBodyPositionIterations && e.setBodyPositionIterations(this, t);
        }
      }, enumerable: !1, configurable: !0 }), n.prototype._init = function() {
        this._physicsEngine && (this._physicsEngine.removeImpostor(this), this.physicsBody = null, this._parent = this._parent || this._getPhysicsParent(), this._isDisposed || this.parent && !this._options.ignoreParent || this._physicsEngine.addImpostor(this));
      }, n.prototype._getPhysicsParent = function() {
        return this.object.parent instanceof Dt ? this.object.parent.physicsImpostor : null;
      }, n.prototype.isBodyInitRequired = function() {
        return this._bodyUpdateRequired || !this._physicsBody && (!this._parent || !!this._options.ignoreParent);
      }, n.prototype.setScalingUpdated = function() {
        this.forceUpdate();
      }, n.prototype.forceUpdate = function() {
        this._init(), this.parent && !this._options.ignoreParent && this.parent.forceUpdate();
      }, Object.defineProperty(n.prototype, "physicsBody", { get: function() {
        return this._parent && !this._options.ignoreParent ? this._parent.physicsBody : this._physicsBody;
      }, set: function(t) {
        this._physicsBody && this._physicsEngine && this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this), this._physicsBody = t, this.resetUpdateFlags();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "parent", { get: function() {
        return !this._options.ignoreParent && this._parent ? this._parent : null;
      }, set: function(t) {
        this._parent = t;
      }, enumerable: !1, configurable: !0 }), n.prototype.resetUpdateFlags = function() {
        this._bodyUpdateRequired = !1;
      }, n.prototype.getObjectExtents = function() {
        if (this.object.getBoundingInfo) {
          var t = this.object.rotationQuaternion, e = this.object.scaling.clone();
          this.object.rotationQuaternion = n.IDENTITY_QUATERNION;
          var i = this.object.computeWorldMatrix && this.object.computeWorldMatrix(!0);
          i && i.decompose(e, void 0, void 0);
          var r = this.object.getBoundingInfo().boundingBox.extendSize.scale(2).multiplyInPlace(e);
          return r.x = Math.abs(r.x), r.y = Math.abs(r.y), r.z = Math.abs(r.z), this.object.rotationQuaternion = t, this.object.computeWorldMatrix && this.object.computeWorldMatrix(!0), r;
        }
        return n.DEFAULT_OBJECT_SIZE;
      }, n.prototype.getObjectCenter = function() {
        return this.object.getBoundingInfo ? this.object.getBoundingInfo().boundingBox.centerWorld : this.object.position;
      }, n.prototype.getParam = function(t) {
        return this._options[t];
      }, n.prototype.setParam = function(t, e) {
        this._options[t] = e, this._bodyUpdateRequired = !0;
      }, n.prototype.setMass = function(t) {
        this.getParam("mass") !== t && this.setParam("mass", t), this._physicsEngine && this._physicsEngine.getPhysicsPlugin().setBodyMass(this, t);
      }, n.prototype.getLinearVelocity = function() {
        return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this) : v.Zero();
      }, n.prototype.setLinearVelocity = function(t) {
        this._physicsEngine && this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, t);
      }, n.prototype.getAngularVelocity = function() {
        return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this) : v.Zero();
      }, n.prototype.setAngularVelocity = function(t) {
        this._physicsEngine && this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this, t);
      }, n.prototype.executeNativeFunction = function(t) {
        this._physicsEngine && t(this._physicsEngine.getPhysicsPlugin().world, this.physicsBody);
      }, n.prototype.registerBeforePhysicsStep = function(t) {
        this._onBeforePhysicsStepCallbacks.push(t);
      }, n.prototype.unregisterBeforePhysicsStep = function(t) {
        var e = this._onBeforePhysicsStepCallbacks.indexOf(t);
        e > -1 ? this._onBeforePhysicsStepCallbacks.splice(e, 1) : q.Warn("Function to remove was not found");
      }, n.prototype.registerAfterPhysicsStep = function(t) {
        this._onAfterPhysicsStepCallbacks.push(t);
      }, n.prototype.unregisterAfterPhysicsStep = function(t) {
        var e = this._onAfterPhysicsStepCallbacks.indexOf(t);
        e > -1 ? this._onAfterPhysicsStepCallbacks.splice(e, 1) : q.Warn("Function to remove was not found");
      }, n.prototype.registerOnPhysicsCollide = function(t, e) {
        var i = t instanceof Array ? t : [t];
        this._onPhysicsCollideCallbacks.push({ callback: e, otherImpostors: i });
      }, n.prototype.unregisterOnPhysicsCollide = function(t, e) {
        var i = t instanceof Array ? t : [t], r = -1;
        this._onPhysicsCollideCallbacks.some(function(o, a) {
          if (o.callback === e && o.otherImpostors.length === i.length) {
            var s = o.otherImpostors.every(function(l) {
              return i.indexOf(l) > -1;
            });
            return s && (r = a), s;
          }
          return !1;
        }) ? this._onPhysicsCollideCallbacks.splice(r, 1) : q.Warn("Function to remove was not found");
      }, n.prototype.getParentsRotation = function() {
        var t = this.object.parent;
        for (this._tmpQuat.copyFromFloats(0, 0, 0, 1); t; )
          t.rotationQuaternion ? this._tmpQuat2.copyFrom(t.rotationQuaternion) : oe.RotationYawPitchRollToRef(t.rotation.y, t.rotation.x, t.rotation.z, this._tmpQuat2), this._tmpQuat.multiplyToRef(this._tmpQuat2, this._tmpQuat), t = t.parent;
        return this._tmpQuat;
      }, n.prototype.applyForce = function(t, e) {
        return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().applyForce(this, t, e), this;
      }, n.prototype.applyImpulse = function(t, e) {
        return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().applyImpulse(this, t, e), this;
      }, n.prototype.createJoint = function(t, e, i) {
        var r = new Ii(e, i);
        return this.addJoint(t, r), this;
      }, n.prototype.addJoint = function(t, e) {
        return this._joints.push({ otherImpostor: t, joint: e }), this._physicsEngine && this._physicsEngine.addJoint(this, t, e), this;
      }, n.prototype.addAnchor = function(t, e, i, r, o) {
        if (!this._physicsEngine)
          return this;
        var a = this._physicsEngine.getPhysicsPlugin();
        return a.appendAnchor ? (this._physicsEngine && a.appendAnchor(this, t, e, i, r, o), this) : this;
      }, n.prototype.addHook = function(t, e, i, r) {
        if (!this._physicsEngine)
          return this;
        var o = this._physicsEngine.getPhysicsPlugin();
        return o.appendAnchor ? (this._physicsEngine && o.appendHook(this, t, e, i, r), this) : this;
      }, n.prototype.sleep = function() {
        return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().sleepBody(this), this;
      }, n.prototype.wakeUp = function() {
        return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().wakeUpBody(this), this;
      }, n.prototype.clone = function(t) {
        return t ? new n(t, this.type, this._options, this._scene) : null;
      }, n.prototype.dispose = function() {
        var t = this;
        this._physicsEngine && (this._joints.forEach(function(e) {
          t._physicsEngine && t._physicsEngine.removeJoint(t, e.otherImpostor, e.joint);
        }), this._physicsEngine.removeImpostor(this), this.parent && this.parent.forceUpdate(), this._isDisposed = !0);
      }, n.prototype.setDeltaPosition = function(t) {
        this._deltaPosition.copyFrom(t);
      }, n.prototype.setDeltaRotation = function(t) {
        this._deltaRotation || (this._deltaRotation = new oe()), this._deltaRotation.copyFrom(t), this._deltaRotationConjugated = this._deltaRotation.conjugate();
      }, n.prototype.getBoxSizeToRef = function(t) {
        return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this, t), this;
      }, n.prototype.getRadius = function() {
        return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getRadius(this) : 0;
      }, n.prototype.syncBoneWithImpostor = function(t, e, i, r, o) {
        var a = n._TmpVecs[0], s = this.object;
        if (s.rotationQuaternion)
          if (o) {
            var l = n._TmpQuat;
            s.rotationQuaternion.multiplyToRef(o, l), t.setRotationQuaternion(l, ht.WORLD, e);
          } else
            t.setRotationQuaternion(s.rotationQuaternion, ht.WORLD, e);
        a.x = 0, a.y = 0, a.z = 0, i && (a.x = i.x, a.y = i.y, a.z = i.z, t.getDirectionToRef(a, e, a), r == null && (r = i.length()), a.x *= r, a.y *= r, a.z *= r), t.getParent() ? (a.addInPlace(s.getAbsolutePosition()), t.setAbsolutePosition(a, e)) : (e.setAbsolutePosition(s.getAbsolutePosition()), e.position.x -= a.x, e.position.y -= a.y, e.position.z -= a.z);
      }, n.prototype.syncImpostorWithBone = function(t, e, i, r, o, a) {
        var s = this.object;
        if (s.rotationQuaternion)
          if (o) {
            var l = n._TmpQuat;
            t.getRotationQuaternionToRef(ht.WORLD, e, l), l.multiplyToRef(o, s.rotationQuaternion);
          } else
            t.getRotationQuaternionToRef(ht.WORLD, e, s.rotationQuaternion);
        var c = n._TmpVecs[0], u = n._TmpVecs[1];
        a || ((a = n._TmpVecs[2]).x = 0, a.y = 1, a.z = 0), t.getDirectionToRef(a, e, u), t.getAbsolutePositionToRef(e, c), r == null && i && (r = i.length()), r != null && (c.x += u.x * r, c.y += u.y * r, c.z += u.z * r), s.setAbsolutePosition(c);
      }, n.DEFAULT_OBJECT_SIZE = new v(1, 1, 1), n.IDENTITY_QUATERNION = oe.Identity(), n._TmpVecs = pt.BuildArray(3, v.Zero), n._TmpQuat = oe.Identity(), n.NoImpostor = 0, n.SphereImpostor = 1, n.BoxImpostor = 2, n.PlaneImpostor = 3, n.MeshImpostor = 4, n.CapsuleImpostor = 6, n.CylinderImpostor = 7, n.ParticleImpostor = 8, n.HeightmapImpostor = 9, n.ConvexHullImpostor = 10, n.CustomImpostor = 100, n.RopeImpostor = 101, n.ClothImpostor = 102, n.SoftbodyImpostor = 103, n;
    }();
    (function(n) {
      n[n.Clean = 0] = "Clean", n[n.Stop = 1] = "Stop", n[n.Sync = 2] = "Sync", n[n.NoSync = 3] = "NoSync";
    })(Po || (Po = {}));
    var M, W, yi = function() {
      function n() {
      }
      return Object.defineProperty(n, "ForceFullSceneLoadingForIncremental", { get: function() {
        return Jr.ForceFullSceneLoadingForIncremental;
      }, set: function(t) {
        Jr.ForceFullSceneLoadingForIncremental = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "ShowLoadingScreen", { get: function() {
        return Jr.ShowLoadingScreen;
      }, set: function(t) {
        Jr.ShowLoadingScreen = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "loggingLevel", { get: function() {
        return Jr.loggingLevel;
      }, set: function(t) {
        Jr.loggingLevel = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "CleanBoneMatrixWeights", { get: function() {
        return Jr.CleanBoneMatrixWeights;
      }, set: function(t) {
        Jr.CleanBoneMatrixWeights = t;
      }, enumerable: !1, configurable: !0 }), n.GetDefaultPlugin = function() {
        return n._RegisteredPlugins[".babylon"];
      }, n._GetPluginForExtension = function(t) {
        return n._RegisteredPlugins[t] || (q.Warn("Unable to find a plugin to load " + t + " files. Trying to use .babylon default plugin. To load from a specific filetype (eg. gltf) see: https://doc.babylonjs.com/features/featuresDeepDive/importers/loadingFileTypes"), n.GetDefaultPlugin());
      }, n._GetPluginForDirectLoad = function(t) {
        for (var e in n._RegisteredPlugins) {
          var i = n._RegisteredPlugins[e].plugin;
          if (i.canDirectLoad && i.canDirectLoad(t))
            return n._RegisteredPlugins[e];
        }
        return n.GetDefaultPlugin();
      }, n._GetPluginForFilename = function(t) {
        var e = t.indexOf("?");
        e !== -1 && (t = t.substring(0, e));
        var i = t.lastIndexOf("."), r = t.substring(i, t.length).toLowerCase();
        return n._GetPluginForExtension(r);
      }, n._GetDirectLoad = function(t) {
        return t.substr(0, 5) === "data:" ? t.substr(5) : null;
      }, n._FormatErrorMessage = function(t, e, i) {
        var r = "Unable to load from " + (t.rawData ? "binary data" : t.url);
        return e ? r += ": ".concat(e) : i && (r += ": ".concat(i)), r;
      }, n._LoadData = function(t, e, i, r, o, a, s, l) {
        var c = n._GetDirectLoad(t.url);
        if (t.rawData && !s)
          throw "When using ArrayBufferView to load data the file extension must be provided.";
        var u, h = s ? n._GetPluginForExtension(s) : c ? n._GetPluginForDirectLoad(t.url) : n._GetPluginForFilename(t.url);
        if (t.rawData && !h.isBinary)
          throw "Loading from ArrayBufferView can not be used with plugins that don't support binary loading.";
        if (!(u = h.plugin.createPlugin !== void 0 ? h.plugin.createPlugin() : h.plugin))
          throw "The loader plugin corresponding to the file type you are trying to load has not been found. If using es6, please import the plugin you wish to use before.";
        if (n.OnPluginActivatedObservable.notifyObservers(u), c && (u.canDirectLoad && u.canDirectLoad(t.url) || !Uu(t.url))) {
          if (u.directLoad) {
            var d = u.directLoad(e, c);
            d.then ? d.then(function(C) {
              i(u, C);
            }).catch(function(C) {
              o("Error in directLoad of _loadData: " + C, C);
            }) : i(u, d);
          } else
            i(u, c);
          return u;
        }
        var p = h.isBinary, f = function(C, L) {
          e.isDisposed ? o("Scene has been disposed") : i(u, C, L);
        }, m = null, g = !1, y = u.onDisposeObservable;
        y && y.add(function() {
          g = !0, m && (m.abort(), m = null), a();
        });
        var b = function() {
          if (!g) {
            var C = function(L, I) {
              o(L == null ? void 0 : L.statusText, I);
            };
            if (!u.loadFile && t.rawData)
              throw "Plugin does not support loading ArrayBufferView.";
            m = u.loadFile ? u.loadFile(e, t.rawData || t.file || t.url, t.rootUrl, f, r, p, C, l) : e._loadFile(t.file || t.url, f, r, !0, p, C);
          }
        }, T = e.getEngine(), S = T.enableOfflineSupport;
        if (S) {
          for (var E = !1, A = 0, R = e.disableOfflineSupportExceptionRules; A < R.length; A++)
            if (R[A].test(t.url)) {
              E = !0;
              break;
            }
          S = !E;
        }
        return S && ve.OfflineProviderFactory ? e.offlineProvider = ve.OfflineProviderFactory(t.url, b, T.disableManifestCheck) : b(), u;
      }, n._GetFileInfo = function(t, e) {
        var i, r, o = null, a = null;
        if (e)
          if (e.name) {
            var s = e;
            i = "file:".concat(s.name), r = s.name, o = s;
          } else if (ArrayBuffer.isView(e))
            i = "", r = "arrayBuffer", a = e;
          else if (typeof e == "string" && e.startsWith("data:"))
            i = e, r = "";
          else {
            var l = e;
            if (l.substr(0, 1) === "/")
              return de.Error("Wrong sceneFilename parameter"), null;
            i = t + l, r = l;
          }
        else
          i = t, r = de.GetFilename(t), t = de.GetFolderPath(t);
        return { url: i, rootUrl: t, name: r, file: o, rawData: a };
      }, n.GetPluginForExtension = function(t) {
        return n._GetPluginForExtension(t).plugin;
      }, n.IsPluginForExtensionAvailable = function(t) {
        return !!n._RegisteredPlugins[t];
      }, n.RegisterPlugin = function(t) {
        if (typeof t.extensions == "string") {
          var e = t.extensions;
          n._RegisteredPlugins[e.toLowerCase()] = { plugin: t, isBinary: !1 };
        } else {
          var i = t.extensions;
          Object.keys(i).forEach(function(r) {
            n._RegisteredPlugins[r.toLowerCase()] = { plugin: t, isBinary: i[r].isBinary };
          });
        }
      }, n.ImportMesh = function(t, e, i, r, o, a, s, l, c) {
        if (i === void 0 && (i = ""), r === void 0 && (r = Me.LastCreatedScene), o === void 0 && (o = null), a === void 0 && (a = null), s === void 0 && (s = null), l === void 0 && (l = null), c === void 0 && (c = ""), !r)
          return q.Error("No scene available to import mesh to"), null;
        var u = n._GetFileInfo(e, i);
        if (!u)
          return null;
        var h = {};
        r.addPendingData(h);
        var d = function() {
          r.removePendingData(h);
        }, p = function(g, y) {
          var b = n._FormatErrorMessage(u, g, y);
          s ? s(r, b, new ia(b, ta.SceneLoaderError, y)) : q.Error(b), d();
        }, f = a ? function(g) {
          try {
            a(g);
          } catch (y) {
            p("Error in onProgress callback: " + y, y);
          }
        } : void 0, m = function(g, y, b, T, S, E, A) {
          if (r.importedMeshesFiles.push(u.url), o)
            try {
              o(g, y, b, T, S, E, A);
            } catch (R) {
              p("Error in onSuccess callback: " + R, R);
            }
          r.removePendingData(h);
        };
        return n._LoadData(u, r, function(g, y, b) {
          if (g.rewriteRootURL && (u.rootUrl = g.rewriteRootURL(u.rootUrl, b)), g.importMesh) {
            var T = [], S = [], E = [];
            if (!g.importMesh(t, r, y, u.rootUrl, T, S, E, p))
              return;
            r.loadingPluginName = g.name, m(T, S, E, [], [], [], []);
          } else
            g.importMeshAsync(t, r, y, u.rootUrl, f, u.name).then(function(A) {
              r.loadingPluginName = g.name, m(A.meshes, A.particleSystems, A.skeletons, A.animationGroups, A.transformNodes, A.geometries, A.lights);
            }).catch(function(A) {
              p(A.message, A);
            });
        }, f, p, d, l, c);
      }, n.ImportMeshAsync = function(t, e, i, r, o, a, s) {
        return i === void 0 && (i = ""), r === void 0 && (r = Me.LastCreatedScene), o === void 0 && (o = null), a === void 0 && (a = null), s === void 0 && (s = ""), new Promise(function(l, c) {
          n.ImportMesh(t, e, i, r, function(u, h, d, p, f, m, g) {
            l({ meshes: u, particleSystems: h, skeletons: d, animationGroups: p, transformNodes: f, geometries: m, lights: g });
          }, o, function(u, h, d) {
            c(d || new Error(h));
          }, a, s);
        });
      }, n.Load = function(t, e, i, r, o, a, s, l) {
        return e === void 0 && (e = ""), i === void 0 && (i = Me.LastCreatedEngine), r === void 0 && (r = null), o === void 0 && (o = null), a === void 0 && (a = null), s === void 0 && (s = null), l === void 0 && (l = ""), i ? n.Append(t, e, new Ue(i), r, o, a, s, l) : (de.Error("No engine available"), null);
      }, n.LoadAsync = function(t, e, i, r, o, a) {
        return e === void 0 && (e = ""), i === void 0 && (i = Me.LastCreatedEngine), r === void 0 && (r = null), o === void 0 && (o = null), a === void 0 && (a = ""), new Promise(function(s, l) {
          n.Load(t, e, i, function(c) {
            s(c);
          }, r, function(c, u, h) {
            l(h || new Error(u));
          }, o, a);
        });
      }, n.Append = function(t, e, i, r, o, a, s, l) {
        var c = this;
        if (e === void 0 && (e = ""), i === void 0 && (i = Me.LastCreatedScene), r === void 0 && (r = null), o === void 0 && (o = null), a === void 0 && (a = null), s === void 0 && (s = null), l === void 0 && (l = ""), !i)
          return q.Error("No scene available to append to"), null;
        var u = n._GetFileInfo(t, e);
        if (!u)
          return null;
        var h = {};
        i.addPendingData(h);
        var d = function() {
          i.removePendingData(h);
        };
        n.ShowLoadingScreen && !this._ShowingLoadingScreen && (this._ShowingLoadingScreen = !0, i.getEngine().displayLoadingUI(), i.executeWhenReady(function() {
          i.getEngine().hideLoadingUI(), c._ShowingLoadingScreen = !1;
        }));
        var p = function(g, y) {
          var b = n._FormatErrorMessage(u, g, y);
          a ? a(i, b, new ia(b, ta.SceneLoaderError, y)) : q.Error(b), d();
        }, f = o ? function(g) {
          try {
            o(g);
          } catch (y) {
            p("Error in onProgress callback", y);
          }
        } : void 0, m = function() {
          if (r)
            try {
              r(i);
            } catch (g) {
              p("Error in onSuccess callback", g);
            }
          i.removePendingData(h);
        };
        return n._LoadData(u, i, function(g, y) {
          if (g.load) {
            if (!g.load(i, y, u.rootUrl, p))
              return;
            i.loadingPluginName = g.name, m();
          } else
            g.loadAsync(i, y, u.rootUrl, f, u.name).then(function() {
              i.loadingPluginName = g.name, m();
            }).catch(function(b) {
              p(b.message, b);
            });
        }, f, p, d, s, l);
      }, n.AppendAsync = function(t, e, i, r, o, a) {
        return e === void 0 && (e = ""), i === void 0 && (i = Me.LastCreatedScene), r === void 0 && (r = null), o === void 0 && (o = null), a === void 0 && (a = ""), new Promise(function(s, l) {
          n.Append(t, e, i, function(c) {
            s(c);
          }, r, function(c, u, h) {
            l(h || new Error(u));
          }, o, a);
        });
      }, n.LoadAssetContainer = function(t, e, i, r, o, a, s, l) {
        if (e === void 0 && (e = ""), i === void 0 && (i = Me.LastCreatedScene), r === void 0 && (r = null), o === void 0 && (o = null), a === void 0 && (a = null), s === void 0 && (s = null), l === void 0 && (l = ""), !i)
          return q.Error("No scene available to load asset container to"), null;
        var c = n._GetFileInfo(t, e);
        if (!c)
          return null;
        var u = {};
        i.addPendingData(u);
        var h = function() {
          i.removePendingData(u);
        }, d = function(m, g) {
          var y = n._FormatErrorMessage(c, m, g);
          a ? a(i, y, new ia(y, ta.SceneLoaderError, g)) : q.Error(y), h();
        }, p = o ? function(m) {
          try {
            o(m);
          } catch (g) {
            d("Error in onProgress callback", g);
          }
        } : void 0, f = function(m) {
          if (r)
            try {
              r(m);
            } catch (g) {
              d("Error in onSuccess callback", g);
            }
          i.removePendingData(u);
        };
        return n._LoadData(c, i, function(m, g) {
          if (m.loadAssetContainer) {
            var y = m.loadAssetContainer(i, g, c.rootUrl, d);
            if (!y)
              return;
            y.populateRootNodes(), i.loadingPluginName = m.name, f(y);
          } else
            m.loadAssetContainerAsync ? m.loadAssetContainerAsync(i, g, c.rootUrl, p, c.name).then(function(b) {
              b.populateRootNodes(), i.loadingPluginName = m.name, f(b);
            }).catch(function(b) {
              d(b.message, b);
            }) : d("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.");
        }, p, d, h, s, l);
      }, n.LoadAssetContainerAsync = function(t, e, i, r, o) {
        return e === void 0 && (e = ""), i === void 0 && (i = Me.LastCreatedScene), r === void 0 && (r = null), o === void 0 && (o = null), new Promise(function(a, s) {
          n.LoadAssetContainer(t, e, i, function(l) {
            a(l);
          }, r, function(l, c, u) {
            s(u || new Error(c));
          }, o);
        });
      }, n.ImportAnimations = function(t, e, i, r, o, a, s, l, c, u) {
        if (e === void 0 && (e = ""), i === void 0 && (i = Me.LastCreatedScene), r === void 0 && (r = !0), o === void 0 && (o = Po.Clean), a === void 0 && (a = null), s === void 0 && (s = null), l === void 0 && (l = null), c === void 0 && (c = null), u === void 0 && (u = null), i) {
          if (r) {
            for (var h = 0, d = i.animatables; h < d.length; h++)
              d[h].reset();
            i.stopAllAnimations(), i.animationGroups.slice().forEach(function(f) {
              f.dispose();
            }), i.getNodes().forEach(function(f) {
              f.animations && (f.animations = []);
            });
          } else
            switch (o) {
              case Po.Clean:
                i.animationGroups.slice().forEach(function(f) {
                  f.dispose();
                });
                break;
              case Po.Stop:
                i.animationGroups.forEach(function(f) {
                  f.stop();
                });
                break;
              case Po.Sync:
                i.animationGroups.forEach(function(f) {
                  f.reset(), f.restart();
                });
                break;
              case Po.NoSync:
                break;
              default:
                return void q.Error("Unknown animation group loading mode value '" + o + "'");
            }
          var p = i.animatables.length;
          this.LoadAssetContainer(t, e, i, function(f) {
            f.mergeAnimationsTo(i, i.animatables.slice(p), a), f.dispose(), i.onAnimationFileImportedObservable.notifyObservers(i), s && s(i);
          }, l, c, u);
        } else
          q.Error("No scene available to load animations to");
      }, n.ImportAnimationsAsync = function(t, e, i, r, o, a, s, l, c, u) {
        return e === void 0 && (e = ""), i === void 0 && (i = Me.LastCreatedScene), r === void 0 && (r = !0), o === void 0 && (o = Po.Clean), a === void 0 && (a = null), l === void 0 && (l = null), u === void 0 && (u = null), new Promise(function(h, d) {
          n.ImportAnimations(t, e, i, r, o, a, function(p) {
            h(p);
          }, l, function(p, f, m) {
            d(m || new Error(f));
          }, u);
        });
      }, n.NO_LOGGING = _.SCENELOADER_NO_LOGGING, n.MINIMAL_LOGGING = _.SCENELOADER_MINIMAL_LOGGING, n.SUMMARY_LOGGING = _.SCENELOADER_SUMMARY_LOGGING, n.DETAILED_LOGGING = _.SCENELOADER_DETAILED_LOGGING, n.OnPluginActivatedObservable = new H(), n._RegisteredPlugins = {}, n._ShowingLoadingScreen = !1, n;
    }(), pl = function(n) {
      function t(e, i, r) {
        r === void 0 && (r = !0);
        var o = n.call(this, e, i) || this;
        return o._normalMatrix = new B(), o._storeEffectOnSubMeshes = r, o;
      }
      return D(t, n), t.prototype.getEffect = function() {
        return this._storeEffectOnSubMeshes ? this._activeEffect : n.prototype.getEffect.call(this);
      }, t.prototype.isReady = function(e, i) {
        return !!e && (!this._storeEffectOnSubMeshes || !e.subMeshes || e.subMeshes.length === 0 || this.isReadyForSubMesh(e, e.subMeshes[0], i));
      }, t.prototype._isReadyForSubMesh = function(e) {
        var i = e.materialDefines;
        return !(this.checkReadyOnEveryCall || !e.effect || !i || i._renderId !== this.getScene().getRenderId());
      }, t.prototype.bindOnlyWorldMatrix = function(e) {
        this._activeEffect.setMatrix("world", e);
      }, t.prototype.bindOnlyNormalMatrix = function(e) {
        this._activeEffect.setMatrix("normalMatrix", e);
      }, t.prototype.bind = function(e, i) {
        i && this.bindForSubMesh(e, i, i.subMeshes[0]);
      }, t.prototype._afterBind = function(e, i) {
        i === void 0 && (i = null), n.prototype._afterBind.call(this, e, i), this.getScene()._cachedEffect = i, i && (i._forceRebindOnNextCall = !1);
      }, t.prototype._mustRebind = function(e, i, r) {
        return r === void 0 && (r = 1), e.isCachedMaterialInvalid(this, i, r);
      }, t.prototype.dispose = function(e, i, r) {
        this._activeEffect = void 0, n.prototype.dispose.call(this, e, i, r);
      }, t;
    }(Et);
    (function(n) {
      n[n.Float = 1] = "Float", n[n.Int = 2] = "Int", n[n.Vector2 = 4] = "Vector2", n[n.Vector3 = 8] = "Vector3", n[n.Vector4 = 16] = "Vector4", n[n.Color3 = 32] = "Color3", n[n.Color4 = 64] = "Color4", n[n.Matrix = 128] = "Matrix", n[n.Object = 256] = "Object", n[n.AutoDetect = 1024] = "AutoDetect", n[n.BasedOnInput = 2048] = "BasedOnInput", n[n.All = 4095] = "All";
    })(M || (M = {})), function(n) {
      n[n.Vertex = 1] = "Vertex", n[n.Fragment = 2] = "Fragment", n[n.Neutral = 4] = "Neutral", n[n.VertexAndFragment = 3] = "VertexAndFragment";
    }(W || (W = {}));
    var Cr, ui, xR = function() {
      function n() {
        this.supportUniformBuffers = !1, this.attributes = [], this.uniforms = [], this.constants = [], this.samplers = [], this.functions = {}, this.extensions = {}, this.prePassOutput = {}, this.counters = {}, this._attributeDeclaration = "", this._uniformDeclaration = "", this._constantDeclaration = "", this._samplerDeclaration = "", this._varyingTransfer = "", this._injectAtEnd = "", this._repeatableContentAnchorIndex = 0, this._builtCompilationString = "", this.compilationString = "";
      }
      return n.prototype.finalize = function(t) {
        var e = t.sharedData.emitComments, i = this.target === W.Fragment;
        this.compilationString = `
`.concat(e ? `//Entry point
` : "", `void main(void) {
`).concat(this.compilationString), this._constantDeclaration && (this.compilationString = `
`.concat(e ? `//Constants
` : "").concat(this._constantDeclaration, `
`).concat(this.compilationString));
        var r = "";
        for (var o in this.functions)
          r += this.functions[o] + `
`;
        for (var a in this.compilationString = `
`.concat(r, `
`).concat(this.compilationString), !i && this._varyingTransfer && (this.compilationString = "".concat(this.compilationString, `
`).concat(this._varyingTransfer)), this._injectAtEnd && (this.compilationString = "".concat(this.compilationString, `
`).concat(this._injectAtEnd)), this.compilationString = "".concat(this.compilationString, `
}`), this.sharedData.varyingDeclaration && (this.compilationString = `
`.concat(e ? `//Varyings
` : "").concat(this.sharedData.varyingDeclaration, `
`).concat(this.compilationString)), this._samplerDeclaration && (this.compilationString = `
`.concat(e ? `//Samplers
` : "").concat(this._samplerDeclaration, `
`).concat(this.compilationString)), this._uniformDeclaration && (this.compilationString = `
`.concat(e ? `//Uniforms
` : "").concat(this._uniformDeclaration, `
`).concat(this.compilationString)), this._attributeDeclaration && !i && (this.compilationString = `
`.concat(e ? `//Attributes
` : "").concat(this._attributeDeclaration, `
`).concat(this.compilationString)), this.compilationString = `precision highp float;
` + this.compilationString, this.compilationString = `#if defined(WEBGL2) || defines(WEBGPU)
precision highp sampler2DArray;
#endif
` + this.compilationString, i && (this.compilationString = `#if defined(PREPASS)\r
#extension GL_EXT_draw_buffers : require\r
layout(location = 0) out highp vec4 glFragData[SCENE_MRT_COUNT];\r
highp vec4 gl_FragColor;\r
#endif\r
` + this.compilationString), this.extensions) {
          var s = this.extensions[a];
          this.compilationString = `
`.concat(s, `
`).concat(this.compilationString);
        }
        this._builtCompilationString = this.compilationString;
      }, Object.defineProperty(n.prototype, "_repeatableContentAnchor", { get: function() {
        return "###___ANCHOR".concat(this._repeatableContentAnchorIndex++, "___###");
      }, enumerable: !1, configurable: !0 }), n.prototype._getFreeVariableName = function(t) {
        return t = t.replace(/[^a-zA-Z_]+/g, ""), this.sharedData.variableNames[t] === void 0 ? (this.sharedData.variableNames[t] = 0, t === "output" || t === "texture" ? t + this.sharedData.variableNames[t] : t) : (this.sharedData.variableNames[t]++, t + this.sharedData.variableNames[t]);
      }, n.prototype._getFreeDefineName = function(t) {
        return this.sharedData.defineNames[t] === void 0 ? this.sharedData.defineNames[t] = 0 : this.sharedData.defineNames[t]++, t + this.sharedData.defineNames[t];
      }, n.prototype._excludeVariableName = function(t) {
        this.sharedData.variableNames[t] = 0;
      }, n.prototype._emit2DSampler = function(t) {
        this.samplers.indexOf(t) < 0 && (this._samplerDeclaration += "uniform sampler2D ".concat(t, `;
`), this.samplers.push(t));
      }, n.prototype._emit2DArraySampler = function(t) {
        this.samplers.indexOf(t) < 0 && (this._samplerDeclaration += "uniform sampler2DArray ".concat(t, `;
`), this.samplers.push(t));
      }, n.prototype._getGLType = function(t) {
        switch (t) {
          case M.Float:
            return "float";
          case M.Int:
            return "int";
          case M.Vector2:
            return "vec2";
          case M.Color3:
          case M.Vector3:
            return "vec3";
          case M.Color4:
          case M.Vector4:
            return "vec4";
          case M.Matrix:
            return "mat4";
        }
        return "";
      }, n.prototype._emitExtension = function(t, e, i) {
        i === void 0 && (i = ""), this.extensions[t] || (i && (e = "#if ".concat(i, `
`).concat(e, `
#endif`)), this.extensions[t] = e);
      }, n.prototype._emitFunction = function(t, e, i) {
        this.functions[t] || (this.sharedData.emitComments && (e = i + `
` + e), this.functions[t] = e);
      }, n.prototype._emitCodeFromInclude = function(t, e, i) {
        if (i && i.repeatKey)
          return "#include<".concat(t, ">").concat(i.substitutionVars ? "(" + i.substitutionVars + ")" : "", "[0..").concat(i.repeatKey, `]
`);
        var r = Jt.IncludesShadersStore[t] + `
`;
        if (this.sharedData.emitComments && (r = e + `
` + r), !i)
          return r;
        if (i.replaceStrings)
          for (var o = 0; o < i.replaceStrings.length; o++) {
            var a = i.replaceStrings[o];
            r = r.replace(a.search, a.replace);
          }
        return r;
      }, n.prototype._emitFunctionFromInclude = function(t, e, i, r) {
        r === void 0 && (r = "");
        var o = t + r;
        if (!this.functions[o]) {
          if (!i || !(i.removeAttributes || i.removeUniforms || i.removeVaryings || i.removeIfDef || i.replaceStrings))
            return i && i.repeatKey ? this.functions[o] = "#include<".concat(t, ">").concat(i.substitutionVars ? "(" + i.substitutionVars + ")" : "", "[0..").concat(i.repeatKey, `]
`) : this.functions[o] = "#include<".concat(t, ">").concat(i != null && i.substitutionVars ? "(" + (i == null ? void 0 : i.substitutionVars) + ")" : "", `
`), void (this.sharedData.emitComments && (this.functions[o] = e + `
` + this.functions[o]));
          if (this.functions[o] = Jt.IncludesShadersStore[t], this.sharedData.emitComments && (this.functions[o] = e + `
` + this.functions[o]), i.removeIfDef && (this.functions[o] = this.functions[o].replace(/^\s*?#ifdef.+$/gm, ""), this.functions[o] = this.functions[o].replace(/^\s*?#endif.*$/gm, ""), this.functions[o] = this.functions[o].replace(/^\s*?#else.*$/gm, ""), this.functions[o] = this.functions[o].replace(/^\s*?#elif.*$/gm, "")), i.removeAttributes && (this.functions[o] = this.functions[o].replace(/\s*?attribute .+?;/g, `
`)), i.removeUniforms && (this.functions[o] = this.functions[o].replace(/\s*?uniform .*?;/g, `
`)), i.removeVaryings && (this.functions[o] = this.functions[o].replace(/\s*?(varying|in) .+?;/g, `
`)), i.replaceStrings)
            for (var a = 0; a < i.replaceStrings.length; a++) {
              var s = i.replaceStrings[a];
              this.functions[o] = this.functions[o].replace(s.search, s.replace);
            }
        }
      }, n.prototype._registerTempVariable = function(t) {
        return this.sharedData.temps.indexOf(t) === -1 && (this.sharedData.temps.push(t), !0);
      }, n.prototype._emitVaryingFromString = function(t, e, i, r) {
        return i === void 0 && (i = ""), r === void 0 && (r = !1), this.sharedData.varyings.indexOf(t) === -1 && (this.sharedData.varyings.push(t), i && (i.startsWith("defined(") ? this.sharedData.varyingDeclaration += "#if ".concat(i, `
`) : this.sharedData.varyingDeclaration += "".concat(r ? "#ifndef" : "#ifdef", " ").concat(i, `
`)), this.sharedData.varyingDeclaration += "varying ".concat(e, " ").concat(t, `;
`), i && (this.sharedData.varyingDeclaration += `#endif
`), !0);
      }, n.prototype._emitUniformFromString = function(t, e, i, r) {
        i === void 0 && (i = ""), r === void 0 && (r = !1), this.uniforms.indexOf(t) === -1 && (this.uniforms.push(t), i && (i.startsWith("defined(") ? this._uniformDeclaration += "#if ".concat(i, `
`) : this._uniformDeclaration += "".concat(r ? "#ifndef" : "#ifdef", " ").concat(i, `
`)), this._uniformDeclaration += "uniform ".concat(e, " ").concat(t, `;
`), i && (this._uniformDeclaration += `#endif
`));
      }, n.prototype._emitFloat = function(t) {
        return t.toString() === t.toFixed(0) ? "".concat(t, ".0") : t.toString();
      }, n;
    }(), U1 = function() {
      function n() {
        this.temps = [], this.varyings = [], this.varyingDeclaration = "", this.inputBlocks = [], this.textureBlocks = [], this.bindableBlocks = [], this.forcedBindableBlocks = [], this.blocksWithFallbacks = [], this.blocksWithDefines = [], this.repeatableContentBlocks = [], this.dynamicUniformBlocks = [], this.blockingBlocks = [], this.animatedInputs = [], this.variableNames = {}, this.defineNames = {}, this.hints = { needWorldViewMatrix: !1, needWorldViewProjectionMatrix: !1, needAlphaBlending: !1, needAlphaTesting: !1 }, this.checks = { emitVertex: !1, emitFragment: !1, notConnectedNonOptionalInputs: new Array() }, this.allowEmptyVertexProgram = !1, this.variableNames.position = 0, this.variableNames.normal = 0, this.variableNames.tangent = 0, this.variableNames.uv = 0, this.variableNames.uv2 = 0, this.variableNames.uv3 = 0, this.variableNames.uv4 = 0, this.variableNames.uv5 = 0, this.variableNames.uv6 = 0, this.variableNames.color = 0, this.variableNames.matricesIndices = 0, this.variableNames.matricesWeights = 0, this.variableNames.matricesIndicesExtra = 0, this.variableNames.matricesWeightsExtra = 0, this.variableNames.diffuseBase = 0, this.variableNames.specularBase = 0, this.variableNames.worldPos = 0, this.variableNames.shadow = 0, this.variableNames.view = 0, this.variableNames.vTBN = 0, this.defineNames.MAINUV0 = 0, this.defineNames.MAINUV1 = 0, this.defineNames.MAINUV2 = 0, this.defineNames.MAINUV3 = 0, this.defineNames.MAINUV4 = 0, this.defineNames.MAINUV5 = 0, this.defineNames.MAINUV6 = 0, this.defineNames.MAINUV7 = 0;
      }
      return n.prototype.emitErrors = function() {
        var t = "";
        this.checks.emitVertex || this.allowEmptyVertexProgram || (t += `NodeMaterial does not have a vertex output. You need to at least add a block that generates a glPosition value.
`), this.checks.emitFragment || (t += `NodeMaterial does not have a fragment output. You need to at least add a block that generates a glFragColor value.
`);
        for (var e = 0, i = this.checks.notConnectedNonOptionalInputs; e < i.length; e++) {
          var r = i[e];
          t += "input ".concat(r.name, " from block ").concat(r.ownerBlock.name, "[").concat(r.ownerBlock.getClassName(), `] is not connected and is not optional.
`);
        }
        if (t)
          throw `Build of NodeMaterial failed:
` + t;
      }, n;
    }();
    (function(n) {
      n[n.Compatible = 0] = "Compatible", n[n.TypeIncompatible = 1] = "TypeIncompatible", n[n.TargetIncompatible = 2] = "TargetIncompatible", n[n.HierarchyIssue = 3] = "HierarchyIssue";
    })(Cr || (Cr = {})), function(n) {
      n[n.Input = 0] = "Input", n[n.Output = 1] = "Output";
    }(ui || (ui = {}));
    var Ju = function() {
      function n(t, e, i) {
        this._connectedPoint = null, this._endpoints = new Array(), this._typeConnectionSource = null, this._defaultConnectionPointType = null, this._linkedConnectionSource = null, this._acceptedConnectionPointType = null, this._type = M.Float, this._enforceAssociatedVariableName = !1, this.needDualDirectionValidation = !1, this.acceptedConnectionPointTypes = [], this.excludedConnectionPointTypes = [], this.onConnectionObservable = new H(), this.isExposedOnFrame = !1, this.exposedPortPosition = -1, this._prioritizeVertex = !1, this._target = W.VertexAndFragment, this._ownerBlock = e, this.name = t, this._direction = i;
      }
      return n.AreEquivalentTypes = function(t, e) {
        switch (t) {
          case M.Vector3:
            if (e === M.Color3)
              return !0;
            break;
          case M.Vector4:
            if (e === M.Color4)
              return !0;
            break;
          case M.Color3:
            if (e === M.Vector3)
              return !0;
            break;
          case M.Color4:
            if (e === M.Vector4)
              return !0;
        }
        return !1;
      }, Object.defineProperty(n.prototype, "direction", { get: function() {
        return this._direction;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "associatedVariableName", { get: function() {
        return this._ownerBlock.isInput ? this._ownerBlock.associatedVariableName : this._enforceAssociatedVariableName && this._associatedVariableName || !this._connectedPoint ? this._associatedVariableName : this._connectedPoint.associatedVariableName;
      }, set: function(t) {
        this._associatedVariableName = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "innerType", { get: function() {
        return this._linkedConnectionSource && this._linkedConnectionSource.isConnected ? this.type : this._type;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "type", { get: function() {
        if (this._type === M.AutoDetect) {
          if (this._ownerBlock.isInput)
            return this._ownerBlock.type;
          if (this._connectedPoint)
            return this._connectedPoint.type;
          if (this._linkedConnectionSource && this._linkedConnectionSource.isConnected)
            return this._linkedConnectionSource.type;
        }
        if (this._type === M.BasedOnInput) {
          if (this._typeConnectionSource)
            return !this._typeConnectionSource.isConnected && this._defaultConnectionPointType ? this._defaultConnectionPointType : this._typeConnectionSource.type;
          if (this._defaultConnectionPointType)
            return this._defaultConnectionPointType;
        }
        return this._type;
      }, set: function(t) {
        this._type = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "target", { get: function() {
        return this._prioritizeVertex && this._ownerBlock ? this._target !== W.VertexAndFragment ? this._target : this._ownerBlock.target === W.Fragment ? W.Fragment : W.Vertex : this._target;
      }, set: function(t) {
        this._target = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isConnected", { get: function() {
        return this.connectedPoint !== null || this.hasEndpoints;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isConnectedToInputBlock", { get: function() {
        return this.connectedPoint !== null && this.connectedPoint.ownerBlock.isInput;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "connectInputBlock", { get: function() {
        return this.isConnectedToInputBlock ? this.connectedPoint.ownerBlock : null;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "connectedPoint", { get: function() {
        return this._connectedPoint;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "ownerBlock", { get: function() {
        return this._ownerBlock;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "sourceBlock", { get: function() {
        return this._connectedPoint ? this._connectedPoint.ownerBlock : null;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "connectedBlocks", { get: function() {
        return this._endpoints.length === 0 ? [] : this._endpoints.map(function(t) {
          return t.ownerBlock;
        });
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "endpoints", { get: function() {
        return this._endpoints;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "hasEndpoints", { get: function() {
        return this._endpoints && this._endpoints.length > 0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isDirectlyConnectedToVertexOutput", { get: function() {
        if (!this.hasEndpoints)
          return !1;
        for (var t = 0, e = this._endpoints; t < e.length; t++) {
          var i = e[t];
          if (i.ownerBlock.target === W.Vertex || (i.ownerBlock.target === W.Neutral || i.ownerBlock.target === W.VertexAndFragment) && i.ownerBlock.outputs.some(function(r) {
            return r.isDirectlyConnectedToVertexOutput;
          }))
            return !0;
        }
        return !1;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isConnectedInVertexShader", { get: function() {
        if (this.target === W.Vertex)
          return !0;
        if (!this.hasEndpoints)
          return !1;
        for (var t = 0, e = this._endpoints; t < e.length; t++) {
          var i = e[t];
          if (i.ownerBlock.target === W.Vertex || i.target === W.Vertex || (i.ownerBlock.target === W.Neutral || i.ownerBlock.target === W.VertexAndFragment) && i.ownerBlock.outputs.some(function(r) {
            return r.isConnectedInVertexShader;
          }))
            return !0;
        }
        return !1;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isConnectedInFragmentShader", { get: function() {
        if (this.target === W.Fragment)
          return !0;
        if (!this.hasEndpoints)
          return !1;
        for (var t = 0, e = this._endpoints; t < e.length; t++) {
          var i = e[t];
          if (i.ownerBlock.target === W.Fragment || (i.ownerBlock.target === W.Neutral || i.ownerBlock.target === W.VertexAndFragment) && i.ownerBlock.isConnectedInFragmentShader())
            return !0;
        }
        return !1;
      }, enumerable: !1, configurable: !0 }), n.prototype.createCustomInputBlock = function() {
        return null;
      }, n.prototype.getClassName = function() {
        return "NodeMaterialConnectionPoint";
      }, n.prototype.canConnectTo = function(t) {
        return this.checkCompatibilityState(t) === Cr.Compatible;
      }, n.prototype.checkCompatibilityState = function(t) {
        var e = this._ownerBlock, i = t.ownerBlock;
        if (e.target === W.Fragment) {
          if (i.target === W.Vertex)
            return Cr.TargetIncompatible;
          for (var r = 0, o = i.outputs; r < o.length; r++) {
            var a = o[r];
            if (a.ownerBlock.target != W.Neutral && a.isConnectedInVertexShader)
              return Cr.TargetIncompatible;
          }
        }
        if (this.type !== t.type && t.innerType !== M.AutoDetect)
          return n.AreEquivalentTypes(this.type, t.type) || t.acceptedConnectionPointTypes && t.acceptedConnectionPointTypes.indexOf(this.type) !== -1 || t._acceptedConnectionPointType && n.AreEquivalentTypes(t._acceptedConnectionPointType.type, this.type) ? Cr.Compatible : Cr.TypeIncompatible;
        if (t.excludedConnectionPointTypes && t.excludedConnectionPointTypes.indexOf(this.type) !== -1)
          return Cr.TypeIncompatible;
        var s = i, l = e;
        return this.direction === ui.Input && (s = e, l = i), s.isAnAncestorOf(l) ? Cr.HierarchyIssue : Cr.Compatible;
      }, n.prototype.connectTo = function(t, e) {
        if (e === void 0 && (e = !1), !e && !this.canConnectTo(t))
          throw "Cannot connect these two connectors.";
        return this._endpoints.push(t), t._connectedPoint = this, this._enforceAssociatedVariableName = !1, this.onConnectionObservable.notifyObservers(t), t.onConnectionObservable.notifyObservers(this), this;
      }, n.prototype.disconnectFrom = function(t) {
        var e = this._endpoints.indexOf(t);
        return e === -1 || (this._endpoints.splice(e, 1), t._connectedPoint = null, this._enforceAssociatedVariableName = !1, t._enforceAssociatedVariableName = !1), this;
      }, n.prototype.addExcludedConnectionPointFromAllowedTypes = function(t) {
        for (var e = 1; e < M.All; )
          t & e || this.excludedConnectionPointTypes.push(e), e <<= 1;
      }, n.prototype.serialize = function(t) {
        t === void 0 && (t = !0);
        var e = {};
        return e.name = this.name, e.displayName = this.displayName, t && this.connectedPoint && (e.inputName = this.name, e.targetBlockId = this.connectedPoint.ownerBlock.uniqueId, e.targetConnectionName = this.connectedPoint.name, e.isExposedOnFrame = !0, e.exposedPortPosition = this.exposedPortPosition), (this.isExposedOnFrame || this.exposedPortPosition >= 0) && (e.isExposedOnFrame = !0, e.exposedPortPosition = this.exposedPortPosition), e;
      }, n.prototype.dispose = function() {
        this.onConnectionObservable.clear();
      }, n;
    }(), We = function() {
      function n(t, e, i) {
        e === void 0 && (e = W.Vertex), i === void 0 && (i = !1), this._isFinalMerger = !1, this._isInput = !1, this._isTeleportOut = !1, this._isTeleportIn = !1, this._name = "", this._isUnique = !1, this.inputsAreExclusive = !1, this._codeVariableName = "", this._inputs = new Array(), this._outputs = new Array(), this.comments = "", this.visibleInInspector = !1, this.visibleOnFrame = !1, this._target = e, this._originalTargetIsNeutral = e === W.Neutral, this._isFinalMerger = i, this._isInput = this.getClassName() === "InputBlock", this._isTeleportOut = this.getClassName() === "NodeMaterialTeleportOutBlock", this._isTeleportIn = this.getClassName() === "NodeMaterialTeleportInBlock", this._name = t, this.uniqueId = bp.UniqueId;
      }
      return Object.defineProperty(n.prototype, "name", { get: function() {
        return this._name;
      }, set: function(t) {
        this.validateBlockName(t) && (this._name = t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isUnique", { get: function() {
        return this._isUnique;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isFinalMerger", { get: function() {
        return this._isFinalMerger;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isInput", { get: function() {
        return this._isInput;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isTeleportOut", { get: function() {
        return this._isTeleportOut;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isTeleportIn", { get: function() {
        return this._isTeleportIn;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "buildId", { get: function() {
        return this._buildId;
      }, set: function(t) {
        this._buildId = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "target", { get: function() {
        return this._target;
      }, set: function(t) {
        !(this._target & t) && (this._target = t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "inputs", { get: function() {
        return this._inputs;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "outputs", { get: function() {
        return this._outputs;
      }, enumerable: !1, configurable: !0 }), n.prototype.getInputByName = function(t) {
        var e = this._inputs.filter(function(i) {
          return i.name === t;
        });
        return e.length ? e[0] : null;
      }, n.prototype.getOutputByName = function(t) {
        var e = this._outputs.filter(function(i) {
          return i.name === t;
        });
        return e.length ? e[0] : null;
      }, n.prototype._setInitialTarget = function(t) {
        this._target = t, this._originalTargetIsNeutral = t === W.Neutral;
      }, n.prototype.initialize = function(t) {
      }, n.prototype.bind = function(t, e, i, r) {
      }, n.prototype._declareOutput = function(t, e) {
        return "".concat(e._getGLType(t.type), " ").concat(t.associatedVariableName);
      }, n.prototype._writeVariable = function(t) {
        return t.connectedPoint ? "".concat(t.associatedVariableName) : "0.";
      }, n.prototype._writeFloat = function(t) {
        var e = t.toString();
        return e.indexOf(".") === -1 && (e += ".0"), "".concat(e);
      }, n.prototype.getClassName = function() {
        return "NodeMaterialBlock";
      }, n.prototype.isConnectedInFragmentShader = function() {
        return this.outputs.some(function(t) {
          return t.isConnectedInFragmentShader;
        });
      }, n.prototype.registerInput = function(t, e, i, r, o) {
        return i === void 0 && (i = !1), (o = o ?? new Ju(t, this, ui.Input)).type = e, o.isOptional = i, r && (o.target = r), this._inputs.push(o), this;
      }, n.prototype.registerOutput = function(t, e, i, r) {
        return (r = r ?? new Ju(t, this, ui.Output)).type = e, i && (r.target = i), this._outputs.push(r), this;
      }, n.prototype.getFirstAvailableInput = function(t) {
        t === void 0 && (t = null);
        for (var e = 0, i = this._inputs; e < i.length; e++) {
          var r = i[e];
          if (!(r.connectedPoint || t && t.type !== r.type && r.type !== M.AutoDetect))
            return r;
        }
        return null;
      }, n.prototype.getFirstAvailableOutput = function(t) {
        t === void 0 && (t = null);
        for (var e = 0, i = this._outputs; e < i.length; e++) {
          var r = i[e];
          if (!t || !t.target || t.target === W.Neutral || t.target & r.target)
            return r;
        }
        return null;
      }, n.prototype.getSiblingOutput = function(t) {
        var e = this._outputs.indexOf(t);
        return e === -1 || e >= this._outputs.length ? null : this._outputs[e + 1];
      }, n.prototype.isAnAncestorOf = function(t) {
        for (var e = 0, i = this._outputs; e < i.length; e++) {
          var r = i[e];
          if (r.hasEndpoints)
            for (var o = 0, a = r.endpoints; o < a.length; o++) {
              var s = a[o];
              if (s.ownerBlock === t || s.ownerBlock.isAnAncestorOf(t))
                return !0;
            }
        }
        return !1;
      }, n.prototype.connectTo = function(t, e) {
        if (this._outputs.length !== 0) {
          for (var i = e && e.output ? this.getOutputByName(e.output) : this.getFirstAvailableOutput(t), r = !0; r; ) {
            var o = e && e.input ? t.getInputByName(e.input) : t.getFirstAvailableInput(i);
            if (i && o && i.canConnectTo(o))
              i.connectTo(o), r = !1;
            else {
              if (!i)
                throw "Unable to find a compatible match";
              i = this.getSiblingOutput(i);
            }
          }
          return this;
        }
      }, n.prototype._buildBlock = function(t) {
      }, n.prototype.updateUniformsAndSamples = function(t, e, i, r) {
      }, n.prototype.provideFallbacks = function(t, e) {
      }, n.prototype.initializeDefines = function(t, e, i, r) {
      }, n.prototype.prepareDefines = function(t, e, i, r, o) {
      }, n.prototype.autoConfigure = function(t, e) {
      }, n.prototype.replaceRepeatableContent = function(t, e, i, r) {
      }, Object.defineProperty(n.prototype, "willBeGeneratedIntoVertexShaderFromFragmentShader", { get: function() {
        return !(this.isInput || this.isFinalMerger || this._outputs.some(function(t) {
          return t.isDirectlyConnectedToVertexOutput;
        }) || this.target === W.Vertex || this.target !== W.VertexAndFragment && this.target !== W.Neutral || !this._outputs.some(function(t) {
          return t.isConnectedInVertexShader;
        }));
      }, enumerable: !1, configurable: !0 }), n.prototype.isReady = function(t, e, i, r) {
        return !0;
      }, n.prototype._linkConnectionTypes = function(t, e, i) {
        i === void 0 && (i = !1), i ? this._inputs[e]._acceptedConnectionPointType = this._inputs[t] : this._inputs[t]._linkedConnectionSource = this._inputs[e], this._inputs[e]._linkedConnectionSource = this._inputs[t];
      }, n.prototype._processBuild = function(t, e, i, r) {
        t.build(e, r);
        var o = e._vertexState != null, a = t._buildTarget === W.Vertex && t.target !== W.VertexAndFragment;
        if (o && (!(t.target & t._buildTarget) || !(t.target & i.target) || this.target !== W.VertexAndFragment && a) && (!t.isInput && e.target !== t._buildTarget || t.isInput && t.isAttribute && !t._noContextSwitch)) {
          var s = i.connectedPoint;
          e._vertexState._emitVaryingFromString("v_" + s.associatedVariableName, e._getGLType(s.type)) && (e._vertexState.compilationString += "".concat("v_" + s.associatedVariableName, " = ").concat(s.associatedVariableName, `;
`)), i.associatedVariableName = "v_" + s.associatedVariableName, i._enforceAssociatedVariableName = !0;
        }
      }, n.prototype.validateBlockName = function(t) {
        for (var e = 0, i = ["position", "normal", "tangent", "particle_positionw", "uv", "uv2", "uv3", "uv4", "uv5", "uv6", "position2d", "particle_uv", "matricesIndices", "matricesWeights", "world0", "world1", "world2", "world3", "particle_color", "particle_texturemask"]; e < i.length; e++)
          if (t === i[e])
            return !1;
        return !0;
      }, n.prototype._customBuildStep = function(t, e) {
      }, n.prototype.build = function(t, e) {
        if (this._buildId === t.sharedData.buildId)
          return !0;
        if (!this.isInput)
          for (var i = 0, r = this._outputs; i < r.length; i++)
            (u = r[i]).associatedVariableName || (u.associatedVariableName = t._getFreeVariableName(u.name));
        for (var o = 0, a = this._inputs; o < a.length; o++) {
          var s = a[o];
          if (s.connectedPoint) {
            if (this.target !== W.Neutral && (!(s.target & this.target) || !(s.target & t.target)))
              continue;
            (p = s.connectedPoint.ownerBlock) && p !== this && this._processBuild(p, t, s, e);
          } else
            s.isOptional || t.sharedData.checks.notConnectedNonOptionalInputs.push(s);
        }
        if (this._customBuildStep(t, e), this._buildId === t.sharedData.buildId)
          return !0;
        if (t.sharedData.verbose && console.log("".concat(t.target === W.Vertex ? "Vertex shader" : "Fragment shader", ": Building ").concat(this.name, " [").concat(this.getClassName(), "]")), this.isFinalMerger)
          switch (t.target) {
            case W.Vertex:
              t.sharedData.checks.emitVertex = !0;
              break;
            case W.Fragment:
              t.sharedData.checks.emitFragment = !0;
          }
        !this.isInput && t.sharedData.emitComments && (t.compilationString += `
//`.concat(this.name, `
`)), this._buildBlock(t), this._buildId = t.sharedData.buildId, this._buildTarget = t.target;
        for (var l = 0, c = this._outputs; l < c.length; l++) {
          var u;
          if ((u = c[l]).target & t.target)
            for (var h = 0, d = u.endpoints; h < d.length; h++) {
              var p, f = d[h];
              (p = f.ownerBlock) && p.target & t.target && e.indexOf(p) !== -1 && this._processBuild(p, t, f, e);
            }
        }
        return !1;
      }, n.prototype._inputRename = function(t) {
        return t;
      }, n.prototype._outputRename = function(t) {
        return t;
      }, n.prototype._dumpPropertiesCode = function() {
        var t = this._codeVariableName;
        return "".concat(t, ".visibleInInspector = ").concat(this.visibleInInspector, `;
`).concat(t, ".visibleOnFrame = ").concat(this.visibleOnFrame, `;
`).concat(t, ".target = ").concat(this.target, `;
`);
      }, n.prototype._dumpCode = function(t, e) {
        e.push(this);
        var i = this.name.replace(/[^A-Za-z_]+/g, "");
        if (this._codeVariableName = i || "".concat(this.getClassName(), "_").concat(this.uniqueId), t.indexOf(this._codeVariableName) !== -1) {
          var r = 0;
          do
            r++, this._codeVariableName = i + r;
          while (t.indexOf(this._codeVariableName) !== -1);
        }
        t.push(this._codeVariableName);
        var o = `
// `.concat(this.getClassName(), `
`);
        this.comments && (o += "// ".concat(this.comments, `
`)), o += "var ".concat(this._codeVariableName, " = new BABYLON.").concat(this.getClassName(), '("').concat(this.name, `");
`), o += this._dumpPropertiesCode();
        for (var a = 0, s = this.inputs; a < s.length; a++) {
          var l = s[a];
          if (l.isConnected) {
            var c = l.connectedPoint.ownerBlock;
            e.indexOf(c) === -1 && (o += c._dumpCode(t, e));
          }
        }
        for (var u = 0, h = this.outputs; u < h.length; u++) {
          var d = h[u];
          if (d.hasEndpoints)
            for (var p = 0, f = d.endpoints; p < f.length; p++)
              (c = f[p].ownerBlock) && e.indexOf(c) === -1 && (o += c._dumpCode(t, e));
        }
        return o;
      }, n.prototype._dumpCodeForOutputConnections = function(t) {
        var e = "";
        if (t.indexOf(this) !== -1)
          return e;
        t.push(this);
        for (var i = 0, r = this.inputs; i < r.length; i++) {
          var o = r[i];
          if (o.isConnected) {
            var a = o.connectedPoint, s = a.ownerBlock;
            e += s._dumpCodeForOutputConnections(t), e += "".concat(s._codeVariableName, ".").concat(s._outputRename(a.name), ".connectTo(").concat(this._codeVariableName, ".").concat(this._inputRename(o.name), `);
`);
          }
        }
        return e;
      }, n.prototype.clone = function(t, e) {
        e === void 0 && (e = "");
        var i = this.serialize(), r = Kt(i.customType);
        if (r) {
          var o = new r();
          return o._deserialize(i, t, e), o;
        }
        return null;
      }, n.prototype.serialize = function() {
        var t = {};
        t.customType = "BABYLON." + this.getClassName(), t.id = this.uniqueId, t.name = this.name, t.comments = this.comments, t.visibleInInspector = this.visibleInInspector, t.visibleOnFrame = this.visibleOnFrame, t.target = this.target, t.inputs = [], t.outputs = [];
        for (var e = 0, i = this.inputs; e < i.length; e++) {
          var r = i[e];
          t.inputs.push(r.serialize());
        }
        for (var o = 0, a = this.outputs; o < a.length; o++) {
          var s = a[o];
          t.outputs.push(s.serialize(!1));
        }
        return t;
      }, n.prototype._deserialize = function(t, e, i) {
        var r;
        this.name = t.name, this.comments = t.comments, this.visibleInInspector = !!t.visibleInInspector, this.visibleOnFrame = !!t.visibleOnFrame, this._target = (r = t.target) !== null && r !== void 0 ? r : this.target, this._deserializePortDisplayNamesAndExposedOnFrame(t);
      }, n.prototype._deserializePortDisplayNamesAndExposedOnFrame = function(t) {
        var e = this, i = t.inputs, r = t.outputs;
        i && i.forEach(function(o, a) {
          o.displayName && (e.inputs[a].displayName = o.displayName), o.isExposedOnFrame && (e.inputs[a].isExposedOnFrame = o.isExposedOnFrame, e.inputs[a].exposedPortPosition = o.exposedPortPosition);
        }), r && r.forEach(function(o, a) {
          o.displayName && (e.outputs[a].displayName = o.displayName), o.isExposedOnFrame && (e.outputs[a].isExposedOnFrame = o.isExposedOnFrame, e.outputs[a].exposedPortPosition = o.exposedPortPosition);
        });
      }, n.prototype.dispose = function() {
        for (var t = 0, e = this.inputs; t < e.length; t++)
          e[t].dispose();
        for (var i = 0, r = this.outputs; i < r.length; i++)
          r[i].dispose();
      }, n;
    }(), $u = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.complementW = 1, i.complementZ = 0, i.target = W.Vertex, i.registerInput("vector", M.AutoDetect), i.registerInput("transform", M.Matrix), i.registerOutput("output", M.Vector4), i.registerOutput("xyz", M.Vector3), i._inputs[0].onConnectionObservable.add(function(r) {
          if (r.ownerBlock.isInput) {
            var o = r.ownerBlock;
            o.name !== "normal" && o.name !== "tangent" || (i.complementW = 0);
          }
        }), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "TransformBlock";
      }, Object.defineProperty(t.prototype, "vector", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyz", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "transform", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this.vector, r = this.transform;
        if (i.connectedPoint) {
          if (this.complementW === 0) {
            var o = "//".concat(this.name);
            e._emitFunctionFromInclude("helperFunctions", o), e.sharedData.blocksWithDefines.push(this);
            var a = e._getFreeVariableName("".concat(r.associatedVariableName, "_NUS"));
            switch (e.compilationString += "mat3 ".concat(a, " = mat3(").concat(r.associatedVariableName, `);
`), e.compilationString += `#ifdef NONUNIFORMSCALING
`, e.compilationString += "".concat(a, " = transposeMat3(inverseMat3(").concat(a, `));
`), e.compilationString += `#endif
`, i.connectedPoint.type) {
              case M.Vector2:
                e.compilationString += this._declareOutput(this.output, e) + " = vec4(".concat(a, " * vec3(").concat(i.associatedVariableName, ", ").concat(this._writeFloat(this.complementZ), "), ").concat(this._writeFloat(this.complementW), `);
`);
                break;
              case M.Vector3:
              case M.Color3:
                e.compilationString += this._declareOutput(this.output, e) + " = vec4(".concat(a, " * ").concat(i.associatedVariableName, ", ").concat(this._writeFloat(this.complementW), `);
`);
                break;
              default:
                e.compilationString += this._declareOutput(this.output, e) + " = vec4(".concat(a, " * ").concat(i.associatedVariableName, ".xyz, ").concat(this._writeFloat(this.complementW), `);
`);
            }
          } else
            switch (a = r.associatedVariableName, i.connectedPoint.type) {
              case M.Vector2:
                e.compilationString += this._declareOutput(this.output, e) + " = ".concat(a, " * vec4(").concat(i.associatedVariableName, ", ").concat(this._writeFloat(this.complementZ), ", ").concat(this._writeFloat(this.complementW), `);
`);
                break;
              case M.Vector3:
              case M.Color3:
                e.compilationString += this._declareOutput(this.output, e) + " = ".concat(a, " * vec4(").concat(i.associatedVariableName, ", ").concat(this._writeFloat(this.complementW), `);
`);
                break;
              default:
                e.compilationString += this._declareOutput(this.output, e) + " = ".concat(a, " * ").concat(i.associatedVariableName, `;
`);
            }
          this.xyz.hasEndpoints && (e.compilationString += this._declareOutput(this.xyz, e) + " = ".concat(this.output.associatedVariableName, `.xyz;
`));
        }
        return this;
      }, t.prototype.prepareDefines = function(e, i, r) {
        e.nonUniformScaling && r.setValue("NONUNIFORMSCALING", !0);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.complementZ = this.complementZ, e.complementW = this.complementW, e;
      }, t.prototype._deserialize = function(e, i, r) {
        n.prototype._deserialize.call(this, e, i, r), this.complementZ = e.complementZ !== void 0 ? e.complementZ : 0, this.complementW = e.complementW !== void 0 ? e.complementW : 1;
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".complementZ = ").concat(this.complementZ, `;
`) + "".concat(this._codeVariableName, ".complementW = ").concat(this.complementW, `;
`);
      }, t;
    }(We);
    j("BABYLON.TransformBlock", $u);
    var Ye, hc = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Vertex, !0) || this;
        return i.registerInput("vector", M.Vector4), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "VertexOutputBlock";
      }, Object.defineProperty(t.prototype, "vector", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._isLogarithmicDepthEnabled = function(e) {
        for (var i = 0, r = e; i < r.length; i++)
          if (r[i].useLogarithmicDepth)
            return !0;
        return !1;
      }, t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this.vector;
        return e.compilationString += "gl_Position = ".concat(i.associatedVariableName, `;
`), this._isLogarithmicDepthEnabled(e.sharedData.fragmentOutputNodes) && (e._emitUniformFromString("logarithmicDepthConstant", "float"), e._emitVaryingFromString("vFragmentDepth", "float"), e.compilationString += `vFragmentDepth = 1.0 + gl_Position.w;
`, e.compilationString += `gl_Position.z = log2(max(0.000001, vFragmentDepth)) * logarithmicDepthConstant;
`), this;
      }, t;
    }(We);
    function qe(n, t, e, i) {
      return t === void 0 && (t = Ye.Boolean), e === void 0 && (e = "PROPERTIES"), function(r, o) {
        var a = r._propStore;
        a || (a = [], r._propStore = a), a.push({ propertyName: o, displayName: n, type: t, groupName: e, options: i ?? {} });
      };
    }
    j("BABYLON.VertexOutputBlock", hc), function(n) {
      n[n.Boolean = 0] = "Boolean", n[n.Float = 1] = "Float", n[n.Int = 2] = "Int", n[n.Vector2 = 3] = "Vector2", n[n.List = 4] = "List";
    }(Ye || (Ye = {}));
    var mn, Tt, fl = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Fragment, !0) || this;
        return i.convertToGammaSpace = !1, i.convertToLinearSpace = !1, i.useLogarithmicDepth = !1, i.registerInput("rgba", M.Color4, !0), i.registerInput("rgb", M.AutoDetect, !0), i.registerInput("a", M.Float, !0), i.rgb.addExcludedConnectionPointFromAllowedTypes(M.Color3 | M.Vector3 | M.Float), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "FragmentOutputBlock";
      }, t.prototype.initialize = function(e) {
        e._excludeVariableName("logarithmicDepthConstant"), e._excludeVariableName("vFragmentDepth");
      }, Object.defineProperty(t.prototype, "rgba", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgb", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "a", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), t.prototype.prepareDefines = function(e, i, r) {
        r.setValue(this._linearDefineName, this.convertToLinearSpace, !0), r.setValue(this._gammaDefineName, this.convertToGammaSpace, !0);
      }, t.prototype.bind = function(e, i, r) {
        this.useLogarithmicDepth && r && Se.BindLogDepth(void 0, e, r.getScene());
      }, t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this.rgba, r = this.rgb, o = this.a;
        e.sharedData.hints.needAlphaBlending = i.isConnected || o.isConnected, e.sharedData.blocksWithDefines.push(this), this.useLogarithmicDepth && (e._emitUniformFromString("logarithmicDepthConstant", "float"), e._emitVaryingFromString("vFragmentDepth", "float"), e.sharedData.bindableBlocks.push(this)), this._linearDefineName = e._getFreeDefineName("CONVERTTOLINEAR"), this._gammaDefineName = e._getFreeDefineName("CONVERTTOGAMMA");
        var a = "//".concat(this.name);
        if (e._emitFunctionFromInclude("helperFunctions", a), i.connectedPoint)
          o.isConnected ? e.compilationString += "gl_FragColor = vec4(".concat(i.associatedVariableName, ".rgb, ").concat(o.associatedVariableName, `);
`) : e.compilationString += "gl_FragColor = ".concat(i.associatedVariableName, `;
`);
        else if (r.connectedPoint) {
          var s = "1.0";
          o.connectedPoint && (s = o.associatedVariableName), r.connectedPoint.type === M.Float ? e.compilationString += "gl_FragColor = vec4(".concat(r.associatedVariableName, ", ").concat(r.associatedVariableName, ", ").concat(r.associatedVariableName, ", ").concat(s, `);
`) : e.compilationString += "gl_FragColor = vec4(".concat(r.associatedVariableName, ", ").concat(s, `);
`);
        } else
          e.sharedData.checks.notConnectedNonOptionalInputs.push(i);
        return e.compilationString += "#ifdef ".concat(this._linearDefineName, `
`), e.compilationString += `gl_FragColor = toLinearSpace(gl_FragColor);
`, e.compilationString += `#endif
`, e.compilationString += "#ifdef ".concat(this._gammaDefineName, `
`), e.compilationString += `gl_FragColor = toGammaSpace(gl_FragColor);
`, e.compilationString += `#endif
`, this.useLogarithmicDepth && (e.compilationString += `gl_FragDepthEXT = log2(vFragmentDepth) * logarithmicDepthConstant * 0.5;
`), e.compilationString += `#if defined(PREPASS)\r
`, e.compilationString += `gl_FragData[0] = gl_FragColor;\r
`, e.compilationString += `#endif\r
`, this;
      }, t.prototype._dumpPropertiesCode = function() {
        var e = n.prototype._dumpPropertiesCode.call(this);
        return e += "".concat(this._codeVariableName, ".convertToGammaSpace = ").concat(this.convertToGammaSpace, `;
`), (e += "".concat(this._codeVariableName, ".convertToLinearSpace = ").concat(this.convertToLinearSpace, `;
`)) + "".concat(this._codeVariableName, ".useLogarithmicDepth = ").concat(this.useLogarithmicDepth, `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.convertToGammaSpace = this.convertToGammaSpace, e.convertToLinearSpace = this.convertToLinearSpace, e.useLogarithmicDepth = this.useLogarithmicDepth, e;
      }, t.prototype._deserialize = function(e, i, r) {
        var o;
        n.prototype._deserialize.call(this, e, i, r), this.convertToGammaSpace = e.convertToGammaSpace, this.convertToLinearSpace = e.convertToLinearSpace, this.useLogarithmicDepth = (o = e.useLogarithmicDepth) !== null && o !== void 0 && o;
      }, x([qe("Convert to gamma space", Ye.Boolean, "PROPERTIES", { notifiers: { update: !0 } })], t.prototype, "convertToGammaSpace", void 0), x([qe("Convert to linear space", Ye.Boolean, "PROPERTIES", { notifiers: { update: !0 } })], t.prototype, "convertToLinearSpace", void 0), x([qe("Use logarithmic depth", Ye.Boolean, "PROPERTIES")], t.prototype, "useLogarithmicDepth", void 0), t;
    }(We);
    j("BABYLON.FragmentOutputBlock", fl), function(n) {
      n[n.Uniform = 0] = "Uniform", n[n.Attribute = 1] = "Attribute", n[n.Varying = 2] = "Varying", n[n.Undefined = 3] = "Undefined";
    }(mn || (mn = {})), function(n) {
      n[n.World = 1] = "World", n[n.View = 2] = "View", n[n.Projection = 3] = "Projection", n[n.ViewProjection = 4] = "ViewProjection", n[n.WorldView = 5] = "WorldView", n[n.WorldViewProjection = 6] = "WorldViewProjection", n[n.CameraPosition = 7] = "CameraPosition", n[n.FogColor = 8] = "FogColor", n[n.DeltaTime = 9] = "DeltaTime", n[n.CameraParameters = 10] = "CameraParameters", n[n.MaterialAlpha = 11] = "MaterialAlpha";
    }(Tt || (Tt = {}));
    var sa, AR = function() {
      function n(t, e) {
        t === void 0 && (t = v.Zero()), e === void 0 && (e = v.Up()), this.position = t, this.normal = e;
      }
      return n.prototype.clone = function() {
        return new n(this.position.clone(), this.normal.clone());
      }, n;
    }(), RR = function() {
      function n(t, e, i) {
        t === void 0 && (t = v.Zero()), e === void 0 && (e = v.Up()), i === void 0 && (i = fe.Zero()), this.position = t, this.normal = e, this.uv = i;
      }
      return n.prototype.clone = function() {
        return new n(this.position.clone(), this.normal.clone(), this.uv.clone());
      }, n;
    }();
    (function(n) {
      n[n.None = 0] = "None", n[n.Time = 1] = "Time", n[n.RealTime = 2] = "RealTime";
    })(sa || (sa = {}));
    var V1 = { position2d: "position", particle_uv: "vUV", particle_color: "vColor", particle_texturemask: "textureMask", particle_positionw: "vPositionW" }, Fg = { particle_uv: !0, particle_color: !0, particle_texturemask: !0, particle_positionw: !0 }, CR = { particle_texturemask: !0 }, vt = function(n) {
      function t(e, i, r) {
        i === void 0 && (i = W.Vertex), r === void 0 && (r = M.AutoDetect);
        var o = n.call(this, e, i, !1) || this;
        return o._mode = mn.Undefined, o._animationType = sa.None, o.min = 0, o.max = 0, o.isBoolean = !1, o.matrixMode = 0, o._systemValue = null, o.isConstant = !1, o.groupInInspector = "", o.onValueChangedObservable = new H(), o.convertToGammaSpace = !1, o.convertToLinearSpace = !1, o._type = r, o.setDefaultValue(), o.registerOutput("output", r), o;
      }
      return D(t, n), Object.defineProperty(t.prototype, "type", { get: function() {
        if (this._type === M.AutoDetect) {
          if (this.isUniform && this.value != null) {
            if (!isNaN(this.value))
              return this._type = M.Float, this._type;
            switch (this.value.getClassName()) {
              case "Vector2":
                return this._type = M.Vector2, this._type;
              case "Vector3":
                return this._type = M.Vector3, this._type;
              case "Vector4":
                return this._type = M.Vector4, this._type;
              case "Color3":
                return this._type = M.Color3, this._type;
              case "Color4":
                return this._type = M.Color4, this._type;
              case "Matrix":
                return this._type = M.Matrix, this._type;
            }
          }
          if (this.isAttribute)
            switch (this.name) {
              case "position":
              case "normal":
              case "particle_positionw":
                return this._type = M.Vector3, this._type;
              case "uv":
              case "uv2":
              case "uv3":
              case "uv4":
              case "uv5":
              case "uv6":
              case "position2d":
              case "particle_uv":
                return this._type = M.Vector2, this._type;
              case "matricesIndices":
              case "matricesWeights":
              case "matricesIndicesExtra":
              case "matricesWeightsExtra":
              case "world0":
              case "world1":
              case "world2":
              case "world3":
              case "tangent":
                return this._type = M.Vector4, this._type;
              case "color":
              case "instanceColor":
              case "particle_color":
              case "particle_texturemask":
                return this._type = M.Color4, this._type;
            }
          if (this.isSystemValue)
            switch (this._systemValue) {
              case Tt.World:
              case Tt.WorldView:
              case Tt.WorldViewProjection:
              case Tt.View:
              case Tt.ViewProjection:
              case Tt.Projection:
                return this._type = M.Matrix, this._type;
              case Tt.CameraPosition:
                return this._type = M.Vector3, this._type;
              case Tt.FogColor:
                return this._type = M.Color3, this._type;
              case Tt.DeltaTime:
              case Tt.MaterialAlpha:
                return this._type = M.Float, this._type;
              case Tt.CameraParameters:
                return this._type = M.Vector4, this._type;
            }
        }
        return this._type;
      }, enumerable: !1, configurable: !0 }), t.prototype.validateBlockName = function(e) {
        return !!this.isAttribute || n.prototype.validateBlockName.call(this, e);
      }, Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.setAsAttribute = function(e) {
        return this._mode = mn.Attribute, e && (this.name = e), this;
      }, t.prototype.setAsSystemValue = function(e) {
        return this.systemValue = e, this;
      }, Object.defineProperty(t.prototype, "value", { get: function() {
        return this._storedValue;
      }, set: function(e) {
        this.type === M.Float && (this.isBoolean ? e = e ? 1 : 0 : this.min !== this.max && (e = Math.max(this.min, e), e = Math.min(this.max, e))), this._storedValue = e, this._mode = mn.Uniform, this.onValueChangedObservable.notifyObservers(this);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "valueCallback", { get: function() {
        return this._valueCallback;
      }, set: function(e) {
        this._valueCallback = e, this._mode = mn.Uniform;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "associatedVariableName", { get: function() {
        return this._associatedVariableName;
      }, set: function(e) {
        this._associatedVariableName = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "animationType", { get: function() {
        return this._animationType;
      }, set: function(e) {
        this._animationType = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isUndefined", { get: function() {
        return this._mode === mn.Undefined;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isUniform", { get: function() {
        return this._mode === mn.Uniform;
      }, set: function(e) {
        this._mode = e ? mn.Uniform : mn.Undefined, this.associatedVariableName = "";
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isAttribute", { get: function() {
        return this._mode === mn.Attribute;
      }, set: function(e) {
        this._mode = e ? mn.Attribute : mn.Undefined, this.associatedVariableName = "";
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isVarying", { get: function() {
        return this._mode === mn.Varying;
      }, set: function(e) {
        this._mode = e ? mn.Varying : mn.Undefined, this.associatedVariableName = "";
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isSystemValue", { get: function() {
        return this._systemValue != null;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "systemValue", { get: function() {
        return this._systemValue;
      }, set: function(e) {
        this._mode = mn.Uniform, this.associatedVariableName = "", this._systemValue = e;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "InputBlock";
      }, t.prototype.animate = function(e) {
        switch (this._animationType) {
          case sa.Time:
            this.type === M.Float && (this.value += 0.01 * e.getAnimationRatio());
            break;
          case sa.RealTime:
            this.type === M.Float && (this.value = (It.Now - e.getEngine().startTime) / 1e3);
        }
      }, t.prototype._emitDefine = function(e) {
        return e[0] === "!" ? "#ifndef ".concat(e.substring(1), `
`) : "#ifdef ".concat(e, `
`);
      }, t.prototype.initialize = function() {
        this.associatedVariableName = "";
      }, t.prototype.setDefaultValue = function() {
        switch (this.type) {
          case M.Float:
            this.value = 0;
            break;
          case M.Vector2:
            this.value = fe.Zero();
            break;
          case M.Vector3:
            this.value = v.Zero();
            break;
          case M.Vector4:
            this.value = lt.Zero();
            break;
          case M.Color3:
            this.value = ne.White();
            break;
          case M.Color4:
            this.value = new Ie(1, 1, 1, 1);
            break;
          case M.Matrix:
            this.value = B.Identity();
        }
      }, t.prototype._emitConstant = function(e) {
        switch (this.type) {
          case M.Float:
            return "".concat(e._emitFloat(this.value));
          case M.Vector2:
            return "vec2(".concat(this.value.x, ", ").concat(this.value.y, ")");
          case M.Vector3:
            return "vec3(".concat(this.value.x, ", ").concat(this.value.y, ", ").concat(this.value.z, ")");
          case M.Vector4:
            return "vec4(".concat(this.value.x, ", ").concat(this.value.y, ", ").concat(this.value.z, ", ").concat(this.value.w, ")");
          case M.Color3:
            return Ot.Color3[0].set(this.value.r, this.value.g, this.value.b), this.convertToGammaSpace && Ot.Color3[0].toGammaSpaceToRef(Ot.Color3[0], e.sharedData.scene.getEngine().useExactSrgbConversions), this.convertToLinearSpace && Ot.Color3[0].toLinearSpaceToRef(Ot.Color3[0], e.sharedData.scene.getEngine().useExactSrgbConversions), "vec3(".concat(Ot.Color3[0].r, ", ").concat(Ot.Color3[0].g, ", ").concat(Ot.Color3[0].b, ")");
          case M.Color4:
            return Ot.Color4[0].set(this.value.r, this.value.g, this.value.b, this.value.a), this.convertToGammaSpace && Ot.Color4[0].toGammaSpaceToRef(Ot.Color4[0], e.sharedData.scene.getEngine().useExactSrgbConversions), this.convertToLinearSpace && Ot.Color4[0].toLinearSpaceToRef(Ot.Color4[0], e.sharedData.scene.getEngine().useExactSrgbConversions), "vec4(".concat(Ot.Color4[0].r, ", ").concat(Ot.Color4[0].g, ", ").concat(Ot.Color4[0].b, ", ").concat(Ot.Color4[0].a, ")");
        }
        return "";
      }, Object.defineProperty(t.prototype, "_noContextSwitch", { get: function() {
        return Fg[this.name];
      }, enumerable: !1, configurable: !0 }), t.prototype._emit = function(e, i) {
        var r;
        if (this.isUniform) {
          if (this.associatedVariableName || (this.associatedVariableName = e._getFreeVariableName("u_" + this.name)), this.isConstant)
            return e.constants.indexOf(this.associatedVariableName) !== -1 ? void 0 : (e.constants.push(this.associatedVariableName), void (e._constantDeclaration += this._declareOutput(this.output, e) + " = ".concat(this._emitConstant(e), `;
`)));
          if (e.uniforms.indexOf(this.associatedVariableName) !== -1)
            return;
          e.uniforms.push(this.associatedVariableName), i && (e._uniformDeclaration += this._emitDefine(i)), e._uniformDeclaration += "uniform ".concat(e._getGLType(this.type), " ").concat(this.associatedVariableName, `;
`), i && (e._uniformDeclaration += `#endif
`);
          var o = e.sharedData.hints;
          if (this._systemValue !== null && this._systemValue !== void 0)
            switch (this._systemValue) {
              case Tt.WorldView:
                o.needWorldViewMatrix = !0;
                break;
              case Tt.WorldViewProjection:
                o.needWorldViewProjectionMatrix = !0;
            }
          else
            this._animationType !== sa.None && e.sharedData.animatedInputs.push(this);
        } else if (this.isAttribute) {
          if (this.associatedVariableName = (r = V1[this.name]) !== null && r !== void 0 ? r : this.name, this.target === W.Vertex && e._vertexState)
            return void (Fg[this.name] ? CR[this.name] ? e._emitUniformFromString(this.associatedVariableName, e._getGLType(this.type), i) : e._emitVaryingFromString(this.associatedVariableName, e._getGLType(this.type), i) : this._emit(e._vertexState, i));
          if (e.attributes.indexOf(this.associatedVariableName) !== -1)
            return;
          e.attributes.push(this.associatedVariableName), Fg[this.name] ? CR[this.name] ? e._emitUniformFromString(this.associatedVariableName, e._getGLType(this.type), i) : e._emitVaryingFromString(this.associatedVariableName, e._getGLType(this.type), i) : (i && (e._attributeDeclaration += this._emitDefine(i)), e._attributeDeclaration += "attribute ".concat(e._getGLType(this.type), " ").concat(this.associatedVariableName, `;
`), i && (e._attributeDeclaration += `#endif
`));
        }
      }, t.prototype._transmitWorld = function(e, i, r, o) {
        if (this._systemValue) {
          var a = this.associatedVariableName;
          switch (this._systemValue) {
            case Tt.World:
              e.setMatrix(a, i);
              break;
            case Tt.WorldView:
              e.setMatrix(a, r);
              break;
            case Tt.WorldViewProjection:
              e.setMatrix(a, o);
          }
        }
      }, t.prototype._transmit = function(e, i, r) {
        if (!this.isAttribute) {
          var o = this.associatedVariableName;
          if (this._systemValue)
            switch (this._systemValue) {
              case Tt.World:
              case Tt.WorldView:
              case Tt.WorldViewProjection:
                return;
              case Tt.View:
                e.setMatrix(o, i.getViewMatrix());
                break;
              case Tt.Projection:
                e.setMatrix(o, i.getProjectionMatrix());
                break;
              case Tt.ViewProjection:
                e.setMatrix(o, i.getTransformMatrix());
                break;
              case Tt.CameraPosition:
                i.bindEyePosition(e, o, !0);
                break;
              case Tt.FogColor:
                e.setColor3(o, i.fogColor);
                break;
              case Tt.DeltaTime:
                e.setFloat(o, i.deltaTime / 1e3);
                break;
              case Tt.CameraParameters:
                i.activeCamera && e.setFloat4(o, i.getEngine().hasOriginBottomLeft ? -1 : 1, i.activeCamera.minZ, i.activeCamera.maxZ, 1 / i.activeCamera.maxZ);
                break;
              case Tt.MaterialAlpha:
                e.setFloat(o, r.alpha);
            }
          else {
            var a = this._valueCallback ? this._valueCallback() : this._storedValue;
            if (a !== null)
              switch (this.type) {
                case M.Float:
                  e.setFloat(o, a);
                  break;
                case M.Int:
                  e.setInt(o, a);
                  break;
                case M.Color3:
                  Ot.Color3[0].set(this.value.r, this.value.g, this.value.b), this.convertToGammaSpace && Ot.Color3[0].toGammaSpaceToRef(Ot.Color3[0], i.getEngine().useExactSrgbConversions), this.convertToLinearSpace && Ot.Color3[0].toLinearSpaceToRef(Ot.Color3[0], i.getEngine().useExactSrgbConversions), e.setColor3(o, Ot.Color3[0]);
                  break;
                case M.Color4:
                  Ot.Color4[0].set(this.value.r, this.value.g, this.value.b, this.value.a), this.convertToGammaSpace && Ot.Color4[0].toGammaSpaceToRef(Ot.Color4[0], i.getEngine().useExactSrgbConversions), this.convertToLinearSpace && Ot.Color4[0].toLinearSpaceToRef(Ot.Color4[0], i.getEngine().useExactSrgbConversions), e.setDirectColor4(o, Ot.Color4[0]);
                  break;
                case M.Vector2:
                  e.setVector2(o, a);
                  break;
                case M.Vector3:
                  e.setVector3(o, a);
                  break;
                case M.Vector4:
                  e.setVector4(o, a);
                  break;
                case M.Matrix:
                  e.setMatrix(o, a);
              }
          }
        }
      }, t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e), (this.isUniform || this.isSystemValue) && e.sharedData.inputBlocks.push(this), this._emit(e);
      }, t.prototype._dumpPropertiesCode = function() {
        var e = this._codeVariableName;
        if (this.isAttribute)
          return n.prototype._dumpPropertiesCode.call(this) + "".concat(e, '.setAsAttribute("').concat(this.name, `");
`);
        if (this.isSystemValue)
          return n.prototype._dumpPropertiesCode.call(this) + "".concat(e, ".setAsSystemValue(BABYLON.NodeMaterialSystemValues.").concat(Tt[this._systemValue], `);
`);
        if (this.isUniform) {
          var i = [], r = "";
          switch (this.type) {
            case M.Float:
              r = "".concat(this.value);
              break;
            case M.Vector2:
              r = "new BABYLON.Vector2(".concat(this.value.x, ", ").concat(this.value.y, ")");
              break;
            case M.Vector3:
              r = "new BABYLON.Vector3(".concat(this.value.x, ", ").concat(this.value.y, ", ").concat(this.value.z, ")");
              break;
            case M.Vector4:
              r = "new BABYLON.Vector4(".concat(this.value.x, ", ").concat(this.value.y, ", ").concat(this.value.z, ", ").concat(this.value.w, ")");
              break;
            case M.Color3:
              r = "new BABYLON.Color3(".concat(this.value.r, ", ").concat(this.value.g, ", ").concat(this.value.b, ")"), this.convertToGammaSpace && (r += ".toGammaSpace()"), this.convertToLinearSpace && (r += ".toLinearSpace()");
              break;
            case M.Color4:
              r = "new BABYLON.Color4(".concat(this.value.r, ", ").concat(this.value.g, ", ").concat(this.value.b, ", ").concat(this.value.a, ")"), this.convertToGammaSpace && (r += ".toGammaSpace()"), this.convertToLinearSpace && (r += ".toLinearSpace()");
              break;
            case M.Matrix:
              r = "BABYLON.Matrix.FromArray([".concat(this.value.m, "])");
          }
          return i.push("".concat(e, ".value = ").concat(r)), this.type === M.Float && i.push("".concat(e, ".min = ").concat(this.min), "".concat(e, ".max = ").concat(this.max), "".concat(e, ".isBoolean = ").concat(this.isBoolean), "".concat(e, ".matrixMode = ").concat(this.matrixMode), "".concat(e, ".animationType = BABYLON.AnimatedInputBlockTypes.").concat(sa[this.animationType])), i.push("".concat(e, ".isConstant = ").concat(this.isConstant)), i.push(""), n.prototype._dumpPropertiesCode.call(this) + i.join(`;
`);
        }
        return n.prototype._dumpPropertiesCode.call(this);
      }, t.prototype.dispose = function() {
        this.onValueChangedObservable.clear(), n.prototype.dispose.call(this);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.type = this.type, e.mode = this._mode, e.systemValue = this._systemValue, e.animationType = this._animationType, e.min = this.min, e.max = this.max, e.isBoolean = this.isBoolean, e.matrixMode = this.matrixMode, e.isConstant = this.isConstant, e.groupInInspector = this.groupInInspector, e.convertToGammaSpace = this.convertToGammaSpace, e.convertToLinearSpace = this.convertToLinearSpace, this._storedValue != null && this._mode === mn.Uniform && (this._storedValue.asArray ? (e.valueType = "BABYLON." + this._storedValue.getClassName(), e.value = this._storedValue.asArray()) : (e.valueType = "number", e.value = this._storedValue)), e;
      }, t.prototype._deserialize = function(e, i, r) {
        if (this._mode = e.mode, n.prototype._deserialize.call(this, e, i, r), this._type = e.type, this._systemValue = e.systemValue || e.wellKnownValue, this._animationType = e.animationType, this.min = e.min || 0, this.max = e.max || 0, this.isBoolean = !!e.isBoolean, this.matrixMode = e.matrixMode || 0, this.isConstant = !!e.isConstant, this.groupInInspector = e.groupInInspector || "", this.convertToGammaSpace = !!e.convertToGammaSpace, this.convertToLinearSpace = !!e.convertToLinearSpace, e.name === "tangent" && e.mode === mn.Attribute && e.type === M.Vector3 && (this._type = M.Vector4), e.valueType)
          if (e.valueType === "number")
            this._storedValue = e.value;
          else {
            var o = Kt(e.valueType);
            o && (this._storedValue = o.FromArray(e.value));
          }
      }, t;
    }(We);
    j("BABYLON.InputBlock", vt);
    var Op = function(n) {
      function t(e) {
        var i = n.call(this, e, W.VertexAndFragment) || this;
        return i._samplerName = "textureSampler", i.convertToGammaSpace = !1, i.convertToLinearSpace = !1, i._isUnique = !1, i.registerInput("uv", M.AutoDetect, !1, W.VertexAndFragment), i.registerOutput("rgba", M.Color4, W.Neutral), i.registerOutput("rgb", M.Color3, W.Neutral), i.registerOutput("r", M.Float, W.Neutral), i.registerOutput("g", M.Float, W.Neutral), i.registerOutput("b", M.Float, W.Neutral), i.registerOutput("a", M.Float, W.Neutral), i._inputs[0].addExcludedConnectionPointFromAllowedTypes(M.Vector2 | M.Vector3 | M.Vector4), i._inputs[0]._prioritizeVertex = !1, i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "CurrentScreenBlock";
      }, Object.defineProperty(t.prototype, "uv", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgba", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgb", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "r", { get: function() {
        return this._outputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "g", { get: function() {
        return this._outputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "b", { get: function() {
        return this._outputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "a", { get: function() {
        return this._outputs[5];
      }, enumerable: !1, configurable: !0 }), t.prototype.initialize = function(e) {
        e._excludeVariableName("textureSampler");
      }, Object.defineProperty(t.prototype, "target", { get: function() {
        return this.uv.isConnected ? this.uv.sourceBlock.isInput ? W.VertexAndFragment : W.Fragment : W.VertexAndFragment;
      }, enumerable: !1, configurable: !0 }), t.prototype.prepareDefines = function(e, i, r) {
        r.setValue(this._linearDefineName, this.convertToGammaSpace, !0), r.setValue(this._gammaDefineName, this.convertToLinearSpace, !0);
      }, t.prototype.isReady = function() {
        return !(this.texture && !this.texture.isReadyOrNotBlocking());
      }, t.prototype._injectVertexCode = function(e) {
        var i = this.uv;
        if (i.connectedPoint.ownerBlock.isInput && (i.connectedPoint.ownerBlock.isAttribute || e._emitUniformFromString(i.associatedVariableName, "vec2")), this._mainUVName = "vMain" + i.associatedVariableName, e._emitVaryingFromString(this._mainUVName, "vec2"), e.compilationString += "".concat(this._mainUVName, " = ").concat(i.associatedVariableName, `.xy;
`), this._outputs.some(function(s) {
          return s.isConnectedInVertexShader;
        })) {
          this._writeTextureRead(e, !0);
          for (var r = 0, o = this._outputs; r < o.length; r++) {
            var a = o[r];
            a.hasEndpoints && this._writeOutput(e, a, a.name, !0);
          }
        }
      }, t.prototype._writeTextureRead = function(e, i) {
        i === void 0 && (i = !1);
        var r = this.uv;
        if (i) {
          if (e.target === W.Fragment)
            return;
          e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(r.associatedVariableName, `);
`);
        } else
          this.uv.ownerBlock.target !== W.Fragment ? e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(this._mainUVName, `);
`) : e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(r.associatedVariableName, `);
`);
      }, t.prototype._writeOutput = function(e, i, r, o) {
        if (o === void 0 && (o = !1), o) {
          if (e.target === W.Fragment)
            return;
          e.compilationString += "".concat(this._declareOutput(i, e), " = ").concat(this._tempTextureRead, ".").concat(r, `;
`);
        } else
          this.uv.ownerBlock.target !== W.Fragment ? (e.compilationString += "".concat(this._declareOutput(i, e), " = ").concat(this._tempTextureRead, ".").concat(r, `;
`), e.compilationString += "#ifdef ".concat(this._linearDefineName, `
`), e.compilationString += "".concat(i.associatedVariableName, " = toGammaSpace(").concat(i.associatedVariableName, `);
`), e.compilationString += `#endif
`, e.compilationString += "#ifdef ".concat(this._gammaDefineName, `
`), e.compilationString += "".concat(i.associatedVariableName, " = toLinearSpace(").concat(i.associatedVariableName, `);
`), e.compilationString += `#endif
`) : e.compilationString += "".concat(this._declareOutput(i, e), " = ").concat(this._tempTextureRead, ".").concat(r, `;
`);
      }, t.prototype._buildBlock = function(e) {
        if (n.prototype._buildBlock.call(this, e), this._tempTextureRead = e._getFreeVariableName("tempTextureRead"), e.sharedData.blockingBlocks.indexOf(this) < 0 && e.sharedData.blockingBlocks.push(this), e.sharedData.textureBlocks.indexOf(this) < 0 && e.sharedData.textureBlocks.push(this), e.sharedData.blocksWithDefines.indexOf(this) < 0 && e.sharedData.blocksWithDefines.push(this), e.target !== W.Fragment)
          return e._emit2DSampler(this._samplerName), void this._injectVertexCode(e);
        if (this._outputs.some(function(s) {
          return s.isConnectedInFragmentShader;
        })) {
          e._emit2DSampler(this._samplerName), this._linearDefineName = e._getFreeDefineName("ISLINEAR"), this._gammaDefineName = e._getFreeDefineName("ISGAMMA");
          var i = "//".concat(this.name);
          e._emitFunctionFromInclude("helperFunctions", i), this._writeTextureRead(e);
          for (var r = 0, o = this._outputs; r < o.length; r++) {
            var a = o[r];
            a.hasEndpoints && this._writeOutput(e, a, a.name);
          }
          return this;
        }
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.convertToGammaSpace = this.convertToGammaSpace, e.convertToLinearSpace = this.convertToLinearSpace, this.texture && !this.texture.isRenderTarget && (e.texture = this.texture.serialize()), e;
      }, t.prototype._deserialize = function(e, i, r) {
        n.prototype._deserialize.call(this, e, i, r), this.convertToGammaSpace = e.convertToGammaSpace, this.convertToLinearSpace = !!e.convertToLinearSpace, e.texture && (r = e.texture.url.indexOf("data:") === 0 ? "" : r, this.texture = ae.Parse(e.texture, i, r));
      }, t;
    }(We);
    j("BABYLON.CurrentScreenBlock", Op);
    var Dp = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Fragment) || this;
        return i._samplerName = "diffuseSampler", i.convertToGammaSpace = !1, i.convertToLinearSpace = !1, i._isUnique = !1, i.registerInput("uv", M.AutoDetect, !1, W.VertexAndFragment), i.registerOutput("rgba", M.Color4, W.Neutral), i.registerOutput("rgb", M.Color3, W.Neutral), i.registerOutput("r", M.Float, W.Neutral), i.registerOutput("g", M.Float, W.Neutral), i.registerOutput("b", M.Float, W.Neutral), i.registerOutput("a", M.Float, W.Neutral), i._inputs[0].addExcludedConnectionPointFromAllowedTypes(M.Vector2 | M.Vector3 | M.Vector4), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ParticleTextureBlock";
      }, Object.defineProperty(t.prototype, "uv", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgba", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgb", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "r", { get: function() {
        return this._outputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "g", { get: function() {
        return this._outputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "b", { get: function() {
        return this._outputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "a", { get: function() {
        return this._outputs[5];
      }, enumerable: !1, configurable: !0 }), t.prototype.initialize = function(e) {
        e._excludeVariableName("diffuseSampler");
      }, t.prototype.autoConfigure = function(e, i) {
        if (i === void 0 && (i = function() {
          return !0;
        }), !this.uv.isConnected) {
          var r = e.getInputBlockByPredicate(function(o) {
            return o.isAttribute && o.name === "particle_uv" && i(o);
          });
          r || (r = new vt("uv")).setAsAttribute("particle_uv"), r.output.connectTo(this.uv);
        }
      }, t.prototype.prepareDefines = function(e, i, r) {
        r.setValue(this._linearDefineName, this.convertToGammaSpace, !0), r.setValue(this._gammaDefineName, this.convertToLinearSpace, !0);
      }, t.prototype.isReady = function() {
        return !(this.texture && !this.texture.isReadyOrNotBlocking());
      }, t.prototype._writeOutput = function(e, i, r) {
        e.compilationString += "".concat(this._declareOutput(i, e), " = ").concat(this._tempTextureRead, ".").concat(r, `;
`), e.compilationString += "#ifdef ".concat(this._linearDefineName, `
`), e.compilationString += "".concat(i.associatedVariableName, " = toGammaSpace(").concat(i.associatedVariableName, `);
`), e.compilationString += `#endif
`, e.compilationString += "#ifdef ".concat(this._gammaDefineName, `
`), e.compilationString += "".concat(i.associatedVariableName, " = toLinearSpace(").concat(i.associatedVariableName, `);
`), e.compilationString += `#endif
`;
      }, t.prototype._buildBlock = function(e) {
        if (n.prototype._buildBlock.call(this, e), e.target !== W.Vertex) {
          this._tempTextureRead = e._getFreeVariableName("tempTextureRead"), e._emit2DSampler(this._samplerName), e.sharedData.blockingBlocks.push(this), e.sharedData.textureBlocks.push(this), e.sharedData.blocksWithDefines.push(this), this._linearDefineName = e._getFreeDefineName("ISLINEAR"), this._gammaDefineName = e._getFreeDefineName("ISGAMMA");
          var i = "//".concat(this.name);
          e._emitFunctionFromInclude("helperFunctions", i), e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(this.uv.associatedVariableName, `);
`);
          for (var r = 0, o = this._outputs; r < o.length; r++) {
            var a = o[r];
            a.hasEndpoints && this._writeOutput(e, a, a.name);
          }
          return this;
        }
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.convertToGammaSpace = this.convertToGammaSpace, e.convertToLinearSpace = this.convertToLinearSpace, this.texture && !this.texture.isRenderTarget && (e.texture = this.texture.serialize()), e;
      }, t.prototype._deserialize = function(e, i, r) {
        n.prototype._deserialize.call(this, e, i, r), this.convertToGammaSpace = e.convertToGammaSpace, this.convertToLinearSpace = !!e.convertToLinearSpace, e.texture && (r = e.texture.url.indexOf("data:") === 0 ? "" : r, this.texture = ae.Parse(e.texture, i, r));
      }, t;
    }(We);
    j("BABYLON.ParticleTextureBlock", Dp);
    var Np = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Fragment) || this;
        return i._isUnique = !0, i.registerInput("color", M.Color4, !1, W.Fragment), i.registerOutput("rampColor", M.Color4, W.Fragment), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ParticleRampGradientBlock";
      }, Object.defineProperty(t.prototype, "color", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rampColor", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.initialize = function(e) {
        e._excludeVariableName("remapRanges"), e._excludeVariableName("rampSampler"), e._excludeVariableName("baseColor"), e._excludeVariableName("alpha"), e._excludeVariableName("remappedColorIndex"), e._excludeVariableName("rampColor"), e._excludeVariableName("finalAlpha");
      }, t.prototype._buildBlock = function(e) {
        if (n.prototype._buildBlock.call(this, e), e.target !== W.Vertex)
          return e._emit2DSampler("rampSampler"), e._emitVaryingFromString("remapRanges", "vec4", "RAMPGRADIENT"), e.compilationString += `
            #ifdef RAMPGRADIENT
                vec4 baseColor = `.concat(this.color.associatedVariableName, `;
                float alpha = `).concat(this.color.associatedVariableName, `.a;

                float remappedColorIndex = clamp((alpha - remapRanges.x) / remapRanges.y, 0.0, 1.0);

                vec4 rampColor = texture2D(rampSampler, vec2(1.0 - remappedColorIndex, 0.));
                baseColor.rgb *= rampColor.rgb;

                // Remapped alpha
                float finalAlpha = baseColor.a;
                baseColor.a = clamp((alpha * rampColor.a - remapRanges.z) / remapRanges.w, 0.0, 1.0);

                `).concat(this._declareOutput(this.rampColor, e), ` = baseColor;
            #else
                `).concat(this._declareOutput(this.rampColor, e), " = ").concat(this.color.associatedVariableName, `;
            #endif
        `), this;
      }, t;
    }(We);
    j("BABYLON.ParticleRampGradientBlock", Np);
    var Fp = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Fragment) || this;
        return i._isUnique = !0, i.registerInput("color", M.Color4, !1, W.Fragment), i.registerInput("alphaTexture", M.Float, !1, W.Fragment), i.registerInput("alphaColor", M.Float, !1, W.Fragment), i.registerOutput("blendColor", M.Color4, W.Fragment), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ParticleBlendMultiplyBlock";
      }, Object.defineProperty(t.prototype, "color", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "alphaTexture", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "alphaColor", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "blendColor", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.initialize = function(e) {
        e._excludeVariableName("sourceAlpha");
      }, t.prototype._buildBlock = function(e) {
        if (n.prototype._buildBlock.call(this, e), e.target !== W.Vertex)
          return e.compilationString += `
            #ifdef BLENDMULTIPLYMODE
                `.concat(this._declareOutput(this.blendColor, e), `;
                float sourceAlpha = `).concat(this.alphaColor.associatedVariableName, " * ").concat(this.alphaTexture.associatedVariableName, `;
                `).concat(this.blendColor.associatedVariableName, ".rgb = ").concat(this.color.associatedVariableName, `.rgb * sourceAlpha + vec3(1.0) * (1.0 - sourceAlpha);
                `).concat(this.blendColor.associatedVariableName, ".a = ").concat(this.color.associatedVariableName, `.a;
            #else
                `).concat(this._declareOutput(this.blendColor, e), " = ").concat(this.color.associatedVariableName, `;
            #endif
        `), this;
      }, t;
    }(We);
    j("BABYLON.ParticleBlendMultiplyBlock", Fp);
    var Va = function() {
      function n() {
        this._defines = {}, this._currentRank = 32, this._maxRank = -1, this._mesh = null;
      }
      return n.prototype.unBindMesh = function() {
        this._mesh = null;
      }, n.prototype.addFallback = function(t, e) {
        this._defines[t] || (t < this._currentRank && (this._currentRank = t), t > this._maxRank && (this._maxRank = t), this._defines[t] = new Array()), this._defines[t].push(e);
      }, n.prototype.addCPUSkinningFallback = function(t, e) {
        this._mesh = e, t < this._currentRank && (this._currentRank = t), t > this._maxRank && (this._maxRank = t);
      }, Object.defineProperty(n.prototype, "hasMoreFallbacks", { get: function() {
        return this._currentRank <= this._maxRank;
      }, enumerable: !1, configurable: !0 }), n.prototype.reduce = function(t, e) {
        if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0) {
          this._mesh.computeBonesUsingShaders = !1, t = t.replace("#define NUM_BONE_INFLUENCERS " + this._mesh.numBoneInfluencers, "#define NUM_BONE_INFLUENCERS 0"), e._bonesComputationForcedToCPU = !0;
          for (var i = this._mesh.getScene(), r = 0; r < i.meshes.length; r++) {
            var o = i.meshes[r];
            if (o.material) {
              if (o.computeBonesUsingShaders && o.numBoneInfluencers !== 0) {
                if (o.material.getEffect() === e)
                  o.computeBonesUsingShaders = !1;
                else if (o.subMeshes) {
                  for (var a = 0, s = o.subMeshes; a < s.length; a++)
                    if (s[a].effect === e) {
                      o.computeBonesUsingShaders = !1;
                      break;
                    }
                }
              }
            } else
              !this._mesh.material && o.computeBonesUsingShaders && o.numBoneInfluencers > 0 && (o.computeBonesUsingShaders = !1);
          }
        } else {
          var l = this._defines[this._currentRank];
          if (l)
            for (r = 0; r < l.length; r++)
              t = t.replace("#define " + l[r], "");
          this._currentRank++;
        }
        return t;
      }, n;
    }();
    re.ShadersStore.postprocessVertexShader = `attribute vec2 position;uniform vec2 scale;varying vec2 vUV;const vec2 madd=vec2(0.5,0.5);
#define CUSTOM_VERTEX_DEFINITIONS
void main(void) {
#define CUSTOM_VERTEX_MAIN_BEGIN
vUV=(position*madd+madd)*scale;gl_Position=vec4(position,0.0,1.0);
#define CUSTOM_VERTEX_MAIN_END
}`;
    var dc = function() {
      function n(t, e, i, r, o) {
        this._textures = null, this._faceIndices = null, this._layerIndices = null, this._samples = 1, this._attachments = null, this._generateStencilBuffer = !1, this._generateDepthBuffer = !1, this._depthStencilTextureWithStencil = !1, this._isMulti = t, this._isCube = e, this._size = i, this._engine = r, this._depthStencilTexture = null, this.label = o;
      }
      return Object.defineProperty(n.prototype, "depthStencilTexture", { get: function() {
        return this._depthStencilTexture;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "depthStencilTextureWithStencil", { get: function() {
        return this._depthStencilTextureWithStencil;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isCube", { get: function() {
        return this._isCube;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isMulti", { get: function() {
        return this._isMulti;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "is2DArray", { get: function() {
        return this.layers > 0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "size", { get: function() {
        return this.width;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "width", { get: function() {
        return this._size.width || this._size;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "height", { get: function() {
        return this._size.height || this._size;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "layers", { get: function() {
        return this._size.layers || 0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "texture", { get: function() {
        var t, e;
        return (e = (t = this._textures) === null || t === void 0 ? void 0 : t[0]) !== null && e !== void 0 ? e : null;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "textures", { get: function() {
        return this._textures;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "faceIndices", { get: function() {
        return this._faceIndices;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "layerIndices", { get: function() {
        return this._layerIndices;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "samples", { get: function() {
        return this._samples;
      }, enumerable: !1, configurable: !0 }), n.prototype.setSamples = function(t, e, i) {
        if (e === void 0 && (e = !0), i === void 0 && (i = !1), this.samples === t && !i)
          return t;
        var r = this._isMulti ? this._engine.updateMultipleRenderTargetTextureSampleCount(this, t, e) : this._engine.updateRenderTargetTextureSampleCount(this, t);
        return this._samples = t, r;
      }, n.prototype.setTextures = function(t) {
        Array.isArray(t) ? this._textures = t : this._textures = t ? [t] : null;
      }, n.prototype.setTexture = function(t, e, i) {
        e === void 0 && (e = 0), i === void 0 && (i = !0), this._textures || (this._textures = []), this._textures[e] !== t && (this._textures[e] && i && this._textures[e].dispose(), this._textures[e] = t);
      }, n.prototype.setLayerAndFaceIndices = function(t, e) {
        this._layerIndices = t, this._faceIndices = e;
      }, n.prototype.setLayerAndFaceIndex = function(t, e, i) {
        t === void 0 && (t = 0), this._layerIndices || (this._layerIndices = []), this._faceIndices || (this._faceIndices = []), e !== void 0 && e >= 0 && (this._layerIndices[t] = e), i !== void 0 && i >= 0 && (this._faceIndices[t] = i);
      }, n.prototype.createDepthStencilTexture = function(t, e, i, r, o, a) {
        var s;
        return t === void 0 && (t = 0), e === void 0 && (e = !0), i === void 0 && (i = !1), r === void 0 && (r = 1), o === void 0 && (o = _.TEXTUREFORMAT_DEPTH32_FLOAT), (s = this._depthStencilTexture) === null || s === void 0 || s.dispose(), this._depthStencilTextureWithStencil = i, this._depthStencilTexture = this._engine.createDepthStencilTexture(this._size, { bilinearFiltering: e, comparisonFunction: t, generateStencil: i, isCube: this._isCube, samples: r, depthTextureFormat: o, label: a }, this), this._depthStencilTexture;
      }, n.prototype._shareDepth = function(t) {
        this._depthStencilTexture && (t._depthStencilTexture && t._depthStencilTexture.dispose(), t._depthStencilTexture = this._depthStencilTexture, this._depthStencilTexture.incrementReferences());
      }, n.prototype._swapAndDie = function(t) {
        this.texture && this.texture._swapAndDie(t), this._textures = null, this.dispose(!0);
      }, n.prototype._cloneRenderTargetWrapper = function() {
        var t, e, i, r, o, a, s, l, c = null;
        if (this._isMulti) {
          var u = this.textures;
          if (u && u.length > 0) {
            var h = !1, d = u.length, p = u[u.length - 1]._source;
            p !== ut.Depth && p !== ut.DepthStencil || (h = !0, d--);
            for (var f = [], m = [], g = [], y = [], b = [], T = [], S = [], E = {}, A = 0; A < d; ++A) {
              var R = u[A];
              f.push(R.samplingMode), m.push(R.type), g.push(R.format), (I = E[R.uniqueId]) !== void 0 ? (y.push(-1), S.push(0)) : (E[R.uniqueId] = A, R.is2DArray ? (y.push(_.TEXTURE_2D_ARRAY), S.push(R.depth)) : R.isCube ? (y.push(_.TEXTURE_CUBE_MAP), S.push(0)) : R.is3D ? (y.push(_.TEXTURE_3D), S.push(R.depth)) : (y.push(_.TEXTURE_2D), S.push(0))), this._faceIndices && b.push((t = this._faceIndices[A]) !== null && t !== void 0 ? t : 0), this._layerIndices && T.push((e = this._layerIndices[A]) !== null && e !== void 0 ? e : 0);
            }
            var C = { samplingModes: f, generateMipMaps: u[0].generateMipMaps, generateDepthBuffer: this._generateDepthBuffer, generateStencilBuffer: this._generateStencilBuffer, generateDepthTexture: h, types: m, formats: g, textureCount: d, targetTypes: y, faceIndex: b, layerIndex: T, layerCounts: S }, L = { width: this.width, height: this.height };
            for (c = this._engine.createMultipleRenderTarget(L, C), A = 0; A < d; ++A)
              if (y[A] === -1) {
                var I = E[u[A].uniqueId];
                c.setTexture(c.textures[I], A);
              }
          }
        } else {
          var O = {};
          O.generateDepthBuffer = this._generateDepthBuffer, O.generateMipMaps = (r = (i = this.texture) === null || i === void 0 ? void 0 : i.generateMipMaps) !== null && r !== void 0 && r, O.generateStencilBuffer = this._generateStencilBuffer, O.samplingMode = (o = this.texture) === null || o === void 0 ? void 0 : o.samplingMode, O.type = (a = this.texture) === null || a === void 0 ? void 0 : a.type, O.format = (s = this.texture) === null || s === void 0 ? void 0 : s.format, this.isCube ? c = this._engine.createRenderTargetCubeTexture(this.width, O) : (L = { width: this.width, height: this.height, layers: this.is2DArray ? (l = this.texture) === null || l === void 0 ? void 0 : l.depth : void 0 }, c = this._engine.createRenderTargetTexture(L, O)), c.texture.isReady = !0;
        }
        return c;
      }, n.prototype._swapRenderTargetWrapper = function(t) {
        if (this._textures && t._textures)
          for (var e = 0; e < this._textures.length; ++e)
            this._textures[e]._swapAndDie(t._textures[e], !1), t._textures[e].isReady = !0;
        this._depthStencilTexture && t._depthStencilTexture && (this._depthStencilTexture._swapAndDie(t._depthStencilTexture), t._depthStencilTexture.isReady = !0), this._textures = null, this._depthStencilTexture = null;
      }, n.prototype._rebuild = function() {
        var t = this._cloneRenderTargetWrapper();
        if (t) {
          if (this._depthStencilTexture) {
            var e = this._depthStencilTexture.samplingMode, i = e === _.TEXTURE_BILINEAR_SAMPLINGMODE || e === _.TEXTURE_TRILINEAR_SAMPLINGMODE || e === _.TEXTURE_LINEAR_LINEAR_MIPNEAREST;
            t.createDepthStencilTexture(this._depthStencilTexture._comparisonFunction, i, this._depthStencilTextureWithStencil, this._depthStencilTexture.samples);
          }
          this.samples > 1 && t.setSamples(this.samples), t._swapRenderTargetWrapper(this), t.dispose();
        }
      }, n.prototype.releaseTextures = function() {
        var t, e;
        if (this._textures)
          for (var i = 0; (e = i < ((t = this._textures) === null || t === void 0 ? void 0 : t.length)) !== null && e !== void 0 && e; ++i)
            this._textures[i].dispose();
        this._textures = null;
      }, n.prototype.dispose = function(t) {
        var e;
        t === void 0 && (t = !1), t || ((e = this._depthStencilTexture) === null || e === void 0 || e.dispose(), this._depthStencilTexture = null, this.releaseTextures()), this._engine._releaseRenderTargetWrapper(this);
      }, n;
    }(), k1 = function(n) {
      function t(e, i, r, o, a) {
        var s = n.call(this, e, i, r, o) || this;
        return s._framebuffer = null, s._depthStencilBuffer = null, s._MSAAFramebuffer = null, s._colorTextureArray = null, s._depthStencilTextureArray = null, s._disposeOnlyFramebuffers = !1, s._currentLOD = 0, s._context = a, s;
      }
      return D(t, n), t.prototype._cloneRenderTargetWrapper = function() {
        var e = null;
        return this._colorTextureArray && this._depthStencilTextureArray ? (e = this._engine.createMultiviewRenderTargetTexture(this.width, this.height)).texture.isReady = !0 : e = n.prototype._cloneRenderTargetWrapper.call(this), e;
      }, t.prototype._swapRenderTargetWrapper = function(e) {
        n.prototype._swapRenderTargetWrapper.call(this, e), e._framebuffer = this._framebuffer, e._depthStencilBuffer = this._depthStencilBuffer, e._MSAAFramebuffer = this._MSAAFramebuffer, e._colorTextureArray = this._colorTextureArray, e._depthStencilTextureArray = this._depthStencilTextureArray, this._framebuffer = this._depthStencilBuffer = this._MSAAFramebuffer = this._colorTextureArray = this._depthStencilTextureArray = null;
      }, t.prototype._shareDepth = function(e) {
        n.prototype._shareDepth.call(this, e);
        var i = this._context, r = this._depthStencilBuffer, o = e._MSAAFramebuffer || e._framebuffer;
        e._depthStencilBuffer && e._depthStencilBuffer !== r && i.deleteRenderbuffer(e._depthStencilBuffer), e._depthStencilBuffer = r;
        var a = e._generateStencilBuffer ? i.DEPTH_STENCIL_ATTACHMENT : i.DEPTH_ATTACHMENT;
        this._engine._bindUnboundFramebuffer(o), i.framebufferRenderbuffer(i.FRAMEBUFFER, a, i.RENDERBUFFER, r), this._engine._bindUnboundFramebuffer(null);
      }, t.prototype._bindTextureRenderTarget = function(e, i, r, o) {
        var a, s, l, c;
        if (i === void 0 && (i = 0), o === void 0 && (o = 0), e._hardwareTexture) {
          var u = this._framebuffer, h = this._engine._currentFramebuffer;
          if (this._engine._bindUnboundFramebuffer(u), this._engine.webGLVersion > 1) {
            var d = (p = this._context)["COLOR_ATTACHMENT" + i];
            e.is2DArray || e.is3D ? (r = (s = r ?? ((a = this.layerIndices) === null || a === void 0 ? void 0 : a[i])) !== null && s !== void 0 ? s : 0, p.framebufferTextureLayer(p.FRAMEBUFFER, d, e._hardwareTexture.underlyingResource, o, r)) : e.isCube ? (r = (c = r ?? ((l = this.faceIndices) === null || l === void 0 ? void 0 : l[i])) !== null && c !== void 0 ? c : 0, p.framebufferTexture2D(p.FRAMEBUFFER, d, p.TEXTURE_CUBE_MAP_POSITIVE_X + r, e._hardwareTexture.underlyingResource, o)) : p.framebufferTexture2D(p.FRAMEBUFFER, d, p.TEXTURE_2D, e._hardwareTexture.underlyingResource, o);
          } else {
            d = (p = this._context)["COLOR_ATTACHMENT" + i + "_WEBGL"];
            var p, f = r !== void 0 ? p.TEXTURE_CUBE_MAP_POSITIVE_X + r : p.TEXTURE_2D;
            p.framebufferTexture2D(p.FRAMEBUFFER, d, f, e._hardwareTexture.underlyingResource, o);
          }
          this._engine._bindUnboundFramebuffer(h);
        }
      }, t.prototype.setTexture = function(e, i, r) {
        i === void 0 && (i = 0), r === void 0 && (r = !0), n.prototype.setTexture.call(this, e, i, r), this._bindTextureRenderTarget(e, i);
      }, t.prototype.setLayerAndFaceIndices = function(e, i) {
        var r, o;
        if (n.prototype.setLayerAndFaceIndices.call(this, e, i), this.textures && this.layerIndices && this.faceIndices)
          for (var a = (o = (r = this._attachments) === null || r === void 0 ? void 0 : r.length) !== null && o !== void 0 ? o : this.textures.length, s = 0; s < a; s++) {
            var l = this.textures[s];
            l && (l.is2DArray || l.is3D ? this._bindTextureRenderTarget(l, s, this.layerIndices[s]) : l.isCube ? this._bindTextureRenderTarget(l, s, this.faceIndices[s]) : this._bindTextureRenderTarget(l, s));
          }
      }, t.prototype.setLayerAndFaceIndex = function(e, i, r) {
        if (e === void 0 && (e = 0), n.prototype.setLayerAndFaceIndex.call(this, e, i, r), this.textures && this.layerIndices && this.faceIndices) {
          var o = this.textures[e];
          o.is2DArray || o.is3D ? this._bindTextureRenderTarget(this.textures[e], e, this.layerIndices[e]) : o.isCube && this._bindTextureRenderTarget(this.textures[e], e, this.faceIndices[e]);
        }
      }, t.prototype.dispose = function(e) {
        e === void 0 && (e = this._disposeOnlyFramebuffers);
        var i = this._context;
        e || (this._colorTextureArray && (this._context.deleteTexture(this._colorTextureArray), this._colorTextureArray = null), this._depthStencilTextureArray && (this._context.deleteTexture(this._depthStencilTextureArray), this._depthStencilTextureArray = null)), this._framebuffer && (i.deleteFramebuffer(this._framebuffer), this._framebuffer = null), this._depthStencilBuffer && (i.deleteRenderbuffer(this._depthStencilBuffer), this._depthStencilBuffer = null), this._MSAAFramebuffer && (i.deleteFramebuffer(this._MSAAFramebuffer), this._MSAAFramebuffer = null), n.prototype.dispose.call(this, e);
      }, t;
    }(dc);
    Qe.prototype._createHardwareRenderTargetWrapper = function(n, t, e) {
      var i = new k1(n, t, e, this, this._gl);
      return this._renderTargetWrapperCache.push(i), i;
    }, Qe.prototype.createRenderTargetTexture = function(n, t) {
      var e, i, r = this._createHardwareRenderTargetWrapper(!1, !1, n), o = !0, a = !1, s = !1, l = void 0, c = 1;
      t !== void 0 && typeof t == "object" && (o = (e = t.generateDepthBuffer) === null || e === void 0 || e, a = !!t.generateStencilBuffer, s = !!t.noColorAttachment, l = t.colorAttachment, c = (i = t.samples) !== null && i !== void 0 ? i : 1);
      var u = l || (s ? null : this._createInternalTexture(n, t, !0, ut.RenderTarget)), h = n.width || n, d = n.height || n, p = this._currentFramebuffer, f = this._gl, m = f.createFramebuffer();
      return this._bindUnboundFramebuffer(m), r._depthStencilBuffer = this._setupFramebufferDepthAttachments(a, o, h, d), u && !u.is2DArray && f.framebufferTexture2D(f.FRAMEBUFFER, f.COLOR_ATTACHMENT0, f.TEXTURE_2D, u._hardwareTexture.underlyingResource, 0), this._bindUnboundFramebuffer(p), r._framebuffer = m, r._generateDepthBuffer = o, r._generateStencilBuffer = a, r.setTextures(u), this.updateRenderTargetTextureSampleCount(r, c), r;
    }, Qe.prototype.createDepthStencilTexture = function(n, t, e) {
      if (t.isCube) {
        var i = n.width || n;
        return this._createDepthStencilCubeTexture(i, t, e);
      }
      return this._createDepthStencilTexture(n, t, e);
    }, Qe.prototype._createDepthStencilTexture = function(n, t, e) {
      var i = this._gl, r = n.layers || 0, o = r !== 0 ? i.TEXTURE_2D_ARRAY : i.TEXTURE_2D, a = new Ut(this, ut.DepthStencil);
      if (!this._caps.depthTextureExtension)
        return q.Error("Depth texture is not supported by your browser or hardware."), a;
      var s = je({ bilinearFiltering: !1, comparisonFunction: 0, generateStencil: !1 }, t);
      if (this._bindTextureDirectly(o, a, !0), this._setupDepthStencilTexture(a, n, s.generateStencil, s.comparisonFunction !== 0 && s.bilinearFiltering, s.comparisonFunction, s.samples), s.depthTextureFormat !== void 0) {
        if (s.depthTextureFormat !== _.TEXTUREFORMAT_DEPTH16 && s.depthTextureFormat !== _.TEXTUREFORMAT_DEPTH24 && s.depthTextureFormat !== _.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8 && s.depthTextureFormat !== _.TEXTUREFORMAT_DEPTH24_STENCIL8 && s.depthTextureFormat !== _.TEXTUREFORMAT_DEPTH32_FLOAT && s.depthTextureFormat !== _.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8)
          return q.Error("Depth texture format is not supported."), a;
        a.format = s.depthTextureFormat;
      } else
        a.format = s.generateStencil ? _.TEXTUREFORMAT_DEPTH24_STENCIL8 : _.TEXTUREFORMAT_DEPTH24;
      var l = a.format === _.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8 || a.format === _.TEXTUREFORMAT_DEPTH24_STENCIL8 || a.format === _.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8;
      e._depthStencilTexture = a, e._depthStencilTextureWithStencil = l;
      var c = i.UNSIGNED_INT;
      a.format === _.TEXTUREFORMAT_DEPTH16 ? c = i.UNSIGNED_SHORT : a.format === _.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8 || a.format === _.TEXTUREFORMAT_DEPTH24_STENCIL8 ? c = i.UNSIGNED_INT_24_8 : a.format === _.TEXTUREFORMAT_DEPTH32_FLOAT ? c = i.FLOAT : a.format === _.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8 && (c = i.FLOAT_32_UNSIGNED_INT_24_8_REV);
      var u = l ? i.DEPTH_STENCIL : i.DEPTH_COMPONENT, h = u;
      this.webGLVersion > 1 && (a.format === _.TEXTUREFORMAT_DEPTH16 ? h = i.DEPTH_COMPONENT16 : a.format === _.TEXTUREFORMAT_DEPTH24 ? h = i.DEPTH_COMPONENT24 : a.format === _.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8 || a.format === _.TEXTUREFORMAT_DEPTH24_STENCIL8 ? h = i.DEPTH24_STENCIL8 : a.format === _.TEXTUREFORMAT_DEPTH32_FLOAT ? h = i.DEPTH_COMPONENT32F : a.format === _.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8 && (h = i.DEPTH32F_STENCIL8)), a.is2DArray ? i.texImage3D(o, 0, h, a.width, a.height, r, 0, u, c, null) : i.texImage2D(o, 0, h, a.width, a.height, 0, u, c, null), this._bindTextureDirectly(o, null), this._internalTexturesCache.push(a);
      var d = e;
      if (d._depthStencilBuffer) {
        var p = this._currentFramebuffer;
        this._bindUnboundFramebuffer(d._framebuffer), i.framebufferRenderbuffer(i.FRAMEBUFFER, i.DEPTH_STENCIL_ATTACHMENT, i.RENDERBUFFER, null), i.framebufferRenderbuffer(i.FRAMEBUFFER, i.DEPTH_ATTACHMENT, i.RENDERBUFFER, null), i.framebufferRenderbuffer(i.FRAMEBUFFER, i.STENCIL_ATTACHMENT, i.RENDERBUFFER, null), this._bindUnboundFramebuffer(p), i.deleteRenderbuffer(d._depthStencilBuffer), d._depthStencilBuffer = null;
      }
      return a;
    }, Qe.prototype.updateRenderTargetTextureSampleCount = function(n, t) {
      if (this.webGLVersion < 2 || !n || !n.texture)
        return 1;
      if (n.samples === t)
        return t;
      var e = this._gl;
      t = Math.min(t, this.getCaps().maxMSAASamples), n._depthStencilBuffer && (e.deleteRenderbuffer(n._depthStencilBuffer), n._depthStencilBuffer = null), n._MSAAFramebuffer && (e.deleteFramebuffer(n._MSAAFramebuffer), n._MSAAFramebuffer = null);
      var i = n.texture._hardwareTexture;
      if (i.releaseMSAARenderBuffers(), t > 1 && typeof e.renderbufferStorageMultisample == "function") {
        var r = e.createFramebuffer();
        if (!r)
          throw new Error("Unable to create multi sampled framebuffer");
        n._MSAAFramebuffer = r, this._bindUnboundFramebuffer(n._MSAAFramebuffer);
        var o = this._createRenderBuffer(n.texture.width, n.texture.height, t, -1, this._getRGBAMultiSampleBufferFormat(n.texture.type), e.COLOR_ATTACHMENT0, !1);
        if (!o)
          throw new Error("Unable to create multi sampled framebuffer");
        i.addMSAARenderBuffer(o);
      } else
        this._bindUnboundFramebuffer(n._framebuffer);
      return n.texture.samples = t, n._samples = t, n._depthStencilBuffer = this._setupFramebufferDepthAttachments(n._generateStencilBuffer, n._generateDepthBuffer, n.texture.width, n.texture.height, t), this._bindUnboundFramebuffer(null), t;
    };
    var nt = function() {
      function n(t, e, i, r, o, a, s, l, c, u, h, d, p, f, m, g) {
        var y, b, T, S, E, A, R, C, L, I, O, w;
        s === void 0 && (s = _.TEXTURE_NEAREST_SAMPLINGMODE), u === void 0 && (u = null), h === void 0 && (h = _.TEXTURETYPE_UNSIGNED_INT), d === void 0 && (d = "postprocess"), f === void 0 && (f = !1), m === void 0 && (m = _.TEXTUREFORMAT_RGBA), g === void 0 && (g = li.GLSL), this._parentContainer = null, this.width = -1, this.height = -1, this.nodeMaterialSource = null, this._outputTexture = null, this.autoClear = !0, this.forceAutoClearInAlphaMode = !1, this.alphaMode = _.ALPHA_DISABLE, this.animations = [], this.enablePixelPerfectMode = !1, this.forceFullscreenViewport = !0, this.scaleMode = _.SCALEMODE_FLOOR, this.alwaysForcePOT = !1, this._samples = 1, this.adaptScaleToCurrentViewport = !1, this._reusable = !1, this._renderId = 0, this.externalTextureSamplerBinding = !1, this._textures = new en(2), this._textureCache = [], this._currentRenderTextureInd = 0, this._scaleRatio = new fe(1, 1), this._texelSize = fe.Zero(), this.onActivateObservable = new H(), this.onSizeChangedObservable = new H(), this.onApplyObservable = new H(), this.onBeforeRenderObservable = new H(), this.onAfterRenderObservable = new H(), this.name = t;
        var z = 1, V = null;
        if (i && !Array.isArray(i)) {
          var Y = i;
          i = (y = Y.uniforms) !== null && y !== void 0 ? y : null, r = (b = Y.samplers) !== null && b !== void 0 ? b : null, z = (T = Y.size) !== null && T !== void 0 ? T : 1, a = (S = Y.camera) !== null && S !== void 0 ? S : null, s = (E = Y.samplingMode) !== null && E !== void 0 ? E : _.TEXTURE_NEAREST_SAMPLINGMODE, l = Y.engine, c = Y.reusable, u = (A = Y.defines) !== null && A !== void 0 ? A : null, h = (R = Y.textureType) !== null && R !== void 0 ? R : _.TEXTURETYPE_UNSIGNED_INT, d = (C = Y.vertexUrl) !== null && C !== void 0 ? C : "postprocess", p = Y.indexParameters, f = (L = Y.blockCompilation) !== null && L !== void 0 && L, m = (I = Y.textureFormat) !== null && I !== void 0 ? I : _.TEXTUREFORMAT_RGBA, g = (O = Y.shaderLanguage) !== null && O !== void 0 ? O : li.GLSL, V = (w = Y.uniformBuffers) !== null && w !== void 0 ? w : null;
        } else
          o && (z = typeof o == "number" ? o : { width: o.width, height: o.height });
        a != null ? (this._camera = a, this._scene = a.getScene(), a.attachPostProcess(this), this._engine = this._scene.getEngine(), this._scene.postProcesses.push(this), this.uniqueId = this._scene.getUniqueId()) : l && (this._engine = l, this._engine.postProcesses.push(this)), this._options = z, this.renderTargetSamplingMode = s || _.TEXTURE_NEAREST_SAMPLINGMODE, this._reusable = c || !1, this._textureType = h, this._textureFormat = m, this._shaderLanguage = g, this._samplers = r || [], this._samplers.push("textureSampler"), this._fragmentUrl = e, this._vertexUrl = d, this._parameters = i || [], this._parameters.push("scale"), this._uniformBuffers = V || [], this._indexParameters = p, this._drawWrapper = new Ei(this._engine), f || this.updateEffect(u);
      }
      return n.RegisterShaderCodeProcessing = function(t, e) {
        e ? n._CustomShaderCodeProcessing[t ?? ""] = e : delete n._CustomShaderCodeProcessing[t ?? ""];
      }, n._GetShaderCodeProcessing = function(t) {
        var e;
        return (e = n._CustomShaderCodeProcessing[t]) !== null && e !== void 0 ? e : n._CustomShaderCodeProcessing[""];
      }, Object.defineProperty(n.prototype, "samples", { get: function() {
        return this._samples;
      }, set: function(t) {
        var e = this;
        this._samples = Math.min(t, this._engine.getCaps().maxMSAASamples), this._textures.forEach(function(i) {
          i.setSamples(e._samples);
        });
      }, enumerable: !1, configurable: !0 }), n.prototype.getEffectName = function() {
        return this._fragmentUrl;
      }, Object.defineProperty(n.prototype, "onActivate", { set: function(t) {
        this._onActivateObserver && this.onActivateObservable.remove(this._onActivateObserver), t && (this._onActivateObserver = this.onActivateObservable.add(t));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "onSizeChanged", { set: function(t) {
        this._onSizeChangedObserver && this.onSizeChangedObservable.remove(this._onSizeChangedObserver), this._onSizeChangedObserver = this.onSizeChangedObservable.add(t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "onApply", { set: function(t) {
        this._onApplyObserver && this.onApplyObservable.remove(this._onApplyObserver), this._onApplyObserver = this.onApplyObservable.add(t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "onBeforeRender", { set: function(t) {
        this._onBeforeRenderObserver && this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver), this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "onAfterRender", { set: function(t) {
        this._onAfterRenderObserver && this.onAfterRenderObservable.remove(this._onAfterRenderObserver), this._onAfterRenderObserver = this.onAfterRenderObservable.add(t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "inputTexture", { get: function() {
        return this._textures.data[this._currentRenderTextureInd];
      }, set: function(t) {
        this._forcedOutputTexture = t;
      }, enumerable: !1, configurable: !0 }), n.prototype.restoreDefaultInputTexture = function() {
        this._forcedOutputTexture && (this._forcedOutputTexture = null, this.markTextureDirty());
      }, n.prototype.getCamera = function() {
        return this._camera;
      }, Object.defineProperty(n.prototype, "texelSize", { get: function() {
        return this._shareOutputWithPostProcess ? this._shareOutputWithPostProcess.texelSize : (this._forcedOutputTexture && this._texelSize.copyFromFloats(1 / this._forcedOutputTexture.width, 1 / this._forcedOutputTexture.height), this._texelSize);
      }, enumerable: !1, configurable: !0 }), n.prototype.getClassName = function() {
        return "PostProcess";
      }, n.prototype.getEngine = function() {
        return this._engine;
      }, n.prototype.getEffect = function() {
        return this._drawWrapper.effect;
      }, n.prototype.shareOutputWith = function(t) {
        return this._disposeTextures(), this._shareOutputWithPostProcess = t, this;
      }, n.prototype.useOwnOutput = function() {
        this._textures.length == 0 && (this._textures = new en(2)), this._shareOutputWithPostProcess = null;
      }, n.prototype.updateEffect = function(t, e, i, r, o, a, s, l) {
        var c, u, h = this;
        t === void 0 && (t = null), e === void 0 && (e = null), i === void 0 && (i = null);
        var d = n._GetShaderCodeProcessing(this.name);
        if (d != null && d.defineCustomBindings) {
          var p = (c = e == null ? void 0 : e.slice()) !== null && c !== void 0 ? c : [];
          p.push.apply(p, this._parameters);
          var f = (u = i == null ? void 0 : i.slice()) !== null && u !== void 0 ? u : [];
          f.push.apply(f, this._samplers), t = d.defineCustomBindings(this.name, t, p, f), e = p, i = f;
        }
        this._postProcessDefines = t, this._drawWrapper.effect = this._engine.createEffect({ vertex: s ?? this._vertexUrl, fragment: l ?? this._fragmentUrl }, { attributes: ["position"], uniformsNames: e || this._parameters, uniformBuffersNames: this._uniformBuffers, samplers: i || this._samplers, defines: t !== null ? t : "", fallbacks: null, onCompiled: o ?? null, onError: a ?? null, indexParameters: r || this._indexParameters, processCodeAfterIncludes: d != null && d.processCodeAfterIncludes ? function(m, g) {
          return d.processCodeAfterIncludes(h.name, m, g);
        } : null, processFinalCode: d != null && d.processFinalCode ? function(m, g) {
          return d.processFinalCode(h.name, m, g);
        } : null, shaderLanguage: this._shaderLanguage }, this._engine);
      }, n.prototype.isReusable = function() {
        return this._reusable;
      }, n.prototype.markTextureDirty = function() {
        this.width = -1;
      }, n.prototype._createRenderTargetTexture = function(t, e, i) {
        i === void 0 && (i = 0);
        for (var r = 0; r < this._textureCache.length; r++)
          if (this._textureCache[r].texture.width === t.width && this._textureCache[r].texture.height === t.height && this._textureCache[r].postProcessChannel === i && this._textureCache[r].texture._generateDepthBuffer === e.generateDepthBuffer && this._textureCache[r].texture.samples === e.samples)
            return this._textureCache[r].texture;
        var o = this._engine.createRenderTargetTexture(t, e);
        return this._textureCache.push({ texture: o, postProcessChannel: i, lastUsedRenderId: -1 }), o;
      }, n.prototype._flushTextureCache = function() {
        for (var t = this._renderId, e = this._textureCache.length - 1; e >= 0; e--)
          if (t - this._textureCache[e].lastUsedRenderId > 100) {
            for (var i = !1, r = 0; r < this._textures.length; r++)
              if (this._textures.data[r] === this._textureCache[e].texture) {
                i = !0;
                break;
              }
            i || (this._textureCache[e].texture.dispose(), this._textureCache.splice(e, 1));
          }
      }, n.prototype.resize = function(t, e, i, r, o) {
        i === void 0 && (i = null), r === void 0 && (r = !1), o === void 0 && (o = !1), this._textures.length > 0 && this._textures.reset(), this.width = t, this.height = e;
        var a = null;
        if (i) {
          for (var s = 0; s < i._postProcesses.length; s++)
            if (i._postProcesses[s] !== null) {
              a = i._postProcesses[s];
              break;
            }
        }
        var l = { width: this.width, height: this.height }, c = { generateMipMaps: r, generateDepthBuffer: o || a === this, generateStencilBuffer: (o || a === this) && this._engine.isStencilEnable, samplingMode: this.renderTargetSamplingMode, type: this._textureType, format: this._textureFormat, samples: this._samples, label: "PostProcessRTT-" + this.name };
        this._textures.push(this._createRenderTargetTexture(l, c, 0)), this._reusable && this._textures.push(this._createRenderTargetTexture(l, c, 1)), this._texelSize.copyFromFloats(1 / this.width, 1 / this.height), this.onSizeChangedObservable.notifyObservers(this);
      }, n.prototype._getTarget = function() {
        var t;
        if (this._shareOutputWithPostProcess)
          t = this._shareOutputWithPostProcess.inputTexture;
        else if (this._forcedOutputTexture)
          t = this._forcedOutputTexture, this.width = this._forcedOutputTexture.width, this.height = this._forcedOutputTexture.height;
        else {
          t = this.inputTexture;
          for (var e = void 0, i = 0; i < this._textureCache.length; i++)
            if (this._textureCache[i].texture === t) {
              e = this._textureCache[i];
              break;
            }
          e && (e.lastUsedRenderId = this._renderId);
        }
        return t;
      }, n.prototype.activate = function(t, e, i) {
        var r, o, a = this;
        e === void 0 && (e = null);
        var s = (t = t || this._camera).getScene(), l = s.getEngine(), c = l.getCaps().maxTextureSize, u = (e ? e.width : this._engine.getRenderWidth(!0)) * this._options | 0, h = (e ? e.height : this._engine.getRenderHeight(!0)) * this._options | 0, d = this._options.width || u, p = this._options.height || h, f = this.renderTargetSamplingMode !== _.TEXTURE_NEAREST_LINEAR && this.renderTargetSamplingMode !== _.TEXTURE_NEAREST_NEAREST && this.renderTargetSamplingMode !== _.TEXTURE_LINEAR_LINEAR, m = null;
        if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
          if (this.adaptScaleToCurrentViewport) {
            var g = l.currentViewport;
            g && (d *= g.width, p *= g.height);
          }
          (f || this.alwaysForcePOT) && (this._options.width || (d = l.needPOTTextures ? ve.GetExponentOfTwo(d, c, this.scaleMode) : d), this._options.height || (p = l.needPOTTextures ? ve.GetExponentOfTwo(p, c, this.scaleMode) : p)), this.width === d && this.height === p && (m = this._getTarget()) || this.resize(d, p, t, f, i), this._textures.forEach(function(y) {
            y.samples !== a.samples && a._engine.updateRenderTargetTextureSampleCount(y, a.samples);
          }), this._flushTextureCache(), this._renderId++;
        }
        return m || (m = this._getTarget()), this.enablePixelPerfectMode ? (this._scaleRatio.copyFromFloats(u / d, h / p), this._engine.bindFramebuffer(m, 0, u, h, this.forceFullscreenViewport)) : (this._scaleRatio.copyFromFloats(1, 1), this._engine.bindFramebuffer(m, 0, void 0, void 0, this.forceFullscreenViewport)), (o = (r = this._engine)._debugInsertMarker) === null || o === void 0 || o.call(r, "post process ".concat(this.name, " input")), this.onActivateObservable.notifyObservers(t), this.autoClear && (this.alphaMode === _.ALPHA_DISABLE || this.forceAutoClearInAlphaMode) && this._engine.clear(this.clearColor ? this.clearColor : s.clearColor, s._allowPostProcessClearColor, !0, !0), this._reusable && (this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2), m;
      }, Object.defineProperty(n.prototype, "isSupported", { get: function() {
        return this._drawWrapper.effect.isSupported;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "aspectRatio", { get: function() {
        return this._shareOutputWithPostProcess ? this._shareOutputWithPostProcess.aspectRatio : this._forcedOutputTexture ? this._forcedOutputTexture.width / this._forcedOutputTexture.height : this.width / this.height;
      }, enumerable: !1, configurable: !0 }), n.prototype.isReady = function() {
        var t, e;
        return (e = (t = this._drawWrapper.effect) === null || t === void 0 ? void 0 : t.isReady()) !== null && e !== void 0 && e;
      }, n.prototype.apply = function() {
        var t, e, i, r;
        return !((t = this._drawWrapper.effect) === null || t === void 0) && t.isReady() ? (this._engine.enableEffect(this._drawWrapper), this._engine.setState(!1), this._engine.setDepthBuffer(!1), this._engine.setDepthWrite(!1), this._engine.setAlphaMode(this.alphaMode), this.alphaConstants && this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a), r = this._shareOutputWithPostProcess ? this._shareOutputWithPostProcess.inputTexture : this._forcedOutputTexture ? this._forcedOutputTexture : this.inputTexture, this.externalTextureSamplerBinding || this._drawWrapper.effect._bindTexture("textureSampler", r == null ? void 0 : r.texture), this._drawWrapper.effect.setVector2("scale", this._scaleRatio), this.onApplyObservable.notifyObservers(this._drawWrapper.effect), (i = (e = n._GetShaderCodeProcessing(this.name)) === null || e === void 0 ? void 0 : e.bindCustomBindings) === null || i === void 0 || i.call(e, this.name, this._drawWrapper.effect), this._drawWrapper.effect) : null;
      }, n.prototype._disposeTextures = function() {
        this._shareOutputWithPostProcess || this._forcedOutputTexture ? this._disposeTextureCache() : (this._disposeTextureCache(), this._textures.dispose());
      }, n.prototype._disposeTextureCache = function() {
        for (var t = this._textureCache.length - 1; t >= 0; t--)
          this._textureCache[t].texture.dispose();
        this._textureCache.length = 0;
      }, n.prototype.setPrePassRenderer = function(t) {
        return !!this._prePassEffectConfiguration && (this._prePassEffectConfiguration = t.addEffectConfiguration(this._prePassEffectConfiguration), this._prePassEffectConfiguration.enabled = !0, !0);
      }, n.prototype.dispose = function(t) {
        var e;
        if (t = t || this._camera, this._disposeTextures(), this._scene && (e = this._scene.postProcesses.indexOf(this)) !== -1 && this._scene.postProcesses.splice(e, 1), this._parentContainer) {
          var i = this._parentContainer.postProcesses.indexOf(this);
          i > -1 && this._parentContainer.postProcesses.splice(i, 1), this._parentContainer = null;
        }
        if ((e = this._engine.postProcesses.indexOf(this)) !== -1 && this._engine.postProcesses.splice(e, 1), t) {
          if (t.detachPostProcess(this), (e = t._postProcesses.indexOf(this)) === 0 && t._postProcesses.length > 0) {
            var r = this._camera._getFirstPostProcess();
            r && r.markTextureDirty();
          }
          this.onActivateObservable.clear(), this.onAfterRenderObservable.clear(), this.onApplyObservable.clear(), this.onBeforeRenderObservable.clear(), this.onSizeChangedObservable.clear();
        }
      }, n.prototype.serialize = function() {
        var t = Ne.Serialize(this), e = this.getCamera() || this._scene && this._scene.activeCamera;
        return t.customType = "BABYLON." + this.getClassName(), t.cameraId = e ? e.id : null, t.reusable = this._reusable, t.textureType = this._textureType, t.fragmentUrl = this._fragmentUrl, t.parameters = this._parameters, t.samplers = this._samplers, t.options = this._options, t.defines = this._postProcessDefines, t.textureFormat = this._textureFormat, t.vertexUrl = this._vertexUrl, t.indexParameters = this._indexParameters, t;
      }, n.prototype.clone = function() {
        var t = this.serialize();
        t._engine = this._engine, t.cameraId = null;
        var e = n.Parse(t, this._scene, "");
        return e ? (e.onActivateObservable = this.onActivateObservable.clone(), e.onSizeChangedObservable = this.onSizeChangedObservable.clone(), e.onApplyObservable = this.onApplyObservable.clone(), e.onBeforeRenderObservable = this.onBeforeRenderObservable.clone(), e.onAfterRenderObservable = this.onAfterRenderObservable.clone(), e._prePassEffectConfiguration = this._prePassEffectConfiguration, e) : null;
      }, n.Parse = function(t, e, i) {
        var r = Kt(t.customType);
        if (!r || !r._Parse)
          return null;
        var o = e ? e.getCameraById(t.cameraId) : null;
        return r._Parse(t, o, e, i);
      }, n._Parse = function(t, e, i, r) {
        return Ne.Parse(function() {
          return new n(t.name, t.fragmentUrl, t.parameters, t.samplers, t.options, e, t.renderTargetSamplingMode, t._engine, t.reusable, t.defines, t.textureType, t.vertexUrl, t.indexParameters, !1, t.textureFormat);
        }, t, i, r);
      }, n._CustomShaderCodeProcessing = {}, x([N()], n.prototype, "uniqueId", void 0), x([N()], n.prototype, "name", void 0), x([N()], n.prototype, "width", void 0), x([N()], n.prototype, "height", void 0), x([N()], n.prototype, "renderTargetSamplingMode", void 0), x([ls()], n.prototype, "clearColor", void 0), x([N()], n.prototype, "autoClear", void 0), x([N()], n.prototype, "forceAutoClearInAlphaMode", void 0), x([N()], n.prototype, "alphaMode", void 0), x([N()], n.prototype, "alphaConstants", void 0), x([N()], n.prototype, "enablePixelPerfectMode", void 0), x([N()], n.prototype, "forceFullscreenViewport", void 0), x([N()], n.prototype, "scaleMode", void 0), x([N()], n.prototype, "alwaysForcePOT", void 0), x([N("samples")], n.prototype, "_samples", void 0), x([N()], n.prototype, "adaptScaleToCurrentViewport", void 0), n;
    }();
    j("BABYLON.PostProcess", nt);
    var pc = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.xSwizzle = "x", i.ySwizzle = "y", i.zSwizzle = "z", i.wSwizzle = "w", i.registerInput("xyzw ", M.Vector4, !0), i.registerInput("xyz ", M.Vector3, !0), i.registerInput("xy ", M.Vector2, !0), i.registerInput("zw ", M.Vector2, !0), i.registerInput("x", M.Float, !0), i.registerInput("y", M.Float, !0), i.registerInput("z", M.Float, !0), i.registerInput("w", M.Float, !0), i.registerOutput("xyzw", M.Vector4), i.registerOutput("xyz", M.Vector3), i.registerOutput("xy", M.Vector2), i.registerOutput("zw", M.Vector2), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "VectorMergerBlock";
      }, Object.defineProperty(t.prototype, "xyzwIn", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyzIn", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyIn", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "zwIn", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "x", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "y", { get: function() {
        return this._inputs[5];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "z", { get: function() {
        return this._inputs[6];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "w", { get: function() {
        return this._inputs[7];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyzw", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyzOut", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyOut", { get: function() {
        return this._outputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "zwOut", { get: function() {
        return this._outputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xy", { get: function() {
        return this.xyOut;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyz", { get: function() {
        return this.xyzOut;
      }, enumerable: !1, configurable: !0 }), t.prototype._inputRename = function(e) {
        return e === "xyzw " ? "xyzwIn" : e === "xyz " ? "xyzIn" : e === "xy " ? "xyIn" : e === "zw " ? "zwIn" : e;
      }, t.prototype._buildSwizzle = function(e) {
        return "." + (this.xSwizzle + this.ySwizzle + this.zSwizzle + this.wSwizzle).substr(0, e);
      }, t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this.x, r = this.y, o = this.z, a = this.w, s = this.xyIn, l = this.zwIn, c = this.xyzIn, u = this.xyzwIn, h = this._outputs[0], d = this._outputs[1], p = this._outputs[2], f = this._outputs[3];
        return u.isConnected ? (h.hasEndpoints && (e.compilationString += this._declareOutput(h, e) + " = ".concat(u.associatedVariableName).concat(this._buildSwizzle(4), `;
`)), d.hasEndpoints && (e.compilationString += this._declareOutput(d, e) + " = ".concat(u.associatedVariableName).concat(this._buildSwizzle(3), `;
`)), p.hasEndpoints && (e.compilationString += this._declareOutput(p, e) + " = ".concat(u.associatedVariableName).concat(this._buildSwizzle(2), `;
`))) : c.isConnected ? (h.hasEndpoints && (e.compilationString += this._declareOutput(h, e) + " = vec4(".concat(c.associatedVariableName, ", ").concat(a.isConnected ? this._writeVariable(a) : "0.0", ")").concat(this._buildSwizzle(4), `;
`)), d.hasEndpoints && (e.compilationString += this._declareOutput(d, e) + " = ".concat(c.associatedVariableName).concat(this._buildSwizzle(3), `;
`)), p.hasEndpoints && (e.compilationString += this._declareOutput(p, e) + " = ".concat(c.associatedVariableName).concat(this._buildSwizzle(2), `;
`))) : s.isConnected ? (h.hasEndpoints && (l.isConnected ? e.compilationString += this._declareOutput(h, e) + " = vec4(".concat(s.associatedVariableName, ", ").concat(l.associatedVariableName, ")").concat(this._buildSwizzle(4), `;
`) : e.compilationString += this._declareOutput(h, e) + " = vec4(".concat(s.associatedVariableName, ", ").concat(o.isConnected ? this._writeVariable(o) : "0.0", ", ").concat(a.isConnected ? this._writeVariable(a) : "0.0", ")").concat(this._buildSwizzle(4), `;
`)), d.hasEndpoints && (e.compilationString += this._declareOutput(d, e) + " = vec3(".concat(s.associatedVariableName, ", ").concat(o.isConnected ? this._writeVariable(o) : "0.0", ")").concat(this._buildSwizzle(3), `;
`)), p.hasEndpoints && (e.compilationString += this._declareOutput(p, e) + " = ".concat(s.associatedVariableName).concat(this._buildSwizzle(2), `;
`)), f.hasEndpoints && (l.isConnected ? e.compilationString += this._declareOutput(f, e) + " = ".concat(l.associatedVariableName).concat(this._buildSwizzle(2), `;
`) : e.compilationString += this._declareOutput(f, e) + " = vec2(".concat(o.isConnected ? this._writeVariable(o) : "0.0", ", ").concat(a.isConnected ? this._writeVariable(a) : "0.0", ")").concat(this._buildSwizzle(2), `;
`))) : (h.hasEndpoints && (l.isConnected ? e.compilationString += this._declareOutput(h, e) + " = vec4(".concat(i.isConnected ? this._writeVariable(i) : "0.0", ", ").concat(r.isConnected ? this._writeVariable(r) : "0.0", ", ").concat(l.associatedVariableName, ")").concat(this._buildSwizzle(4), `;
`) : e.compilationString += this._declareOutput(h, e) + " = vec4(".concat(i.isConnected ? this._writeVariable(i) : "0.0", ", ").concat(r.isConnected ? this._writeVariable(r) : "0.0", ", ").concat(o.isConnected ? this._writeVariable(o) : "0.0", ", ").concat(a.isConnected ? this._writeVariable(a) : "0.0", ")").concat(this._buildSwizzle(4), `;
`)), d.hasEndpoints && (e.compilationString += this._declareOutput(d, e) + " = vec3(".concat(i.isConnected ? this._writeVariable(i) : "0.0", ", ").concat(r.isConnected ? this._writeVariable(r) : "0.0", ", ").concat(o.isConnected ? this._writeVariable(o) : "0.0", ")").concat(this._buildSwizzle(3), `;
`)), p.hasEndpoints && (e.compilationString += this._declareOutput(p, e) + " = vec2(".concat(i.isConnected ? this._writeVariable(i) : "0.0", ", ").concat(r.isConnected ? this._writeVariable(r) : "0.0", ")").concat(this._buildSwizzle(2), `;
`)), f.hasEndpoints && (l.isConnected ? e.compilationString += this._declareOutput(f, e) + " = ".concat(l.associatedVariableName).concat(this._buildSwizzle(2), `;
`) : e.compilationString += this._declareOutput(f, e) + " = vec2(".concat(o.isConnected ? this._writeVariable(o) : "0.0", ", ").concat(a.isConnected ? this._writeVariable(a) : "0.0", ")").concat(this._buildSwizzle(2), `;
`))), this;
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.xSwizzle = this.xSwizzle, e.ySwizzle = this.ySwizzle, e.zSwizzle = this.zSwizzle, e.wSwizzle = this.wSwizzle, e;
      }, t.prototype._deserialize = function(e, i, r) {
        var o, a, s, l;
        n.prototype._deserialize.call(this, e, i, r), this.xSwizzle = (o = e.xSwizzle) !== null && o !== void 0 ? o : "x", this.ySwizzle = (a = e.ySwizzle) !== null && a !== void 0 ? a : "y", this.zSwizzle = (s = e.zSwizzle) !== null && s !== void 0 ? s : "z", this.wSwizzle = (l = e.wSwizzle) !== null && l !== void 0 ? l : "w";
      }, t.prototype._dumpPropertiesCode = function() {
        var e = n.prototype._dumpPropertiesCode.call(this);
        return e += "".concat(this._codeVariableName, '.xSwizzle = "').concat(this.xSwizzle, `";
`), e += "".concat(this._codeVariableName, '.ySwizzle = "').concat(this.ySwizzle, `";
`), (e += "".concat(this._codeVariableName, '.zSwizzle = "').concat(this.zSwizzle, `";
`)) + "".concat(this._codeVariableName, '.wSwizzle = "').concat(this.wSwizzle, `";
`);
      }, t;
    }(We);
    j("BABYLON.VectorMergerBlock", pc);
    var Lp = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.sourceRange = new fe(-1, 1), i.targetRange = new fe(0, 1), i.registerInput("input", M.AutoDetect), i.registerInput("sourceMin", M.Float, !0), i.registerInput("sourceMax", M.Float, !0), i.registerInput("targetMin", M.Float, !0), i.registerInput("targetMax", M.Float, !0), i.registerOutput("output", M.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "RemapBlock";
      }, Object.defineProperty(t.prototype, "input", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "sourceMin", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "sourceMax", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "targetMin", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "targetMax", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0], r = this.sourceMin.isConnected ? this.sourceMin.associatedVariableName : this._writeFloat(this.sourceRange.x), o = this.sourceMax.isConnected ? this.sourceMax.associatedVariableName : this._writeFloat(this.sourceRange.y), a = this.targetMin.isConnected ? this.targetMin.associatedVariableName : this._writeFloat(this.targetRange.x), s = this.targetMax.isConnected ? this.targetMax.associatedVariableName : this._writeFloat(this.targetRange.y);
        return e.compilationString += this._declareOutput(i, e) + " = ".concat(a, " + (").concat(this._inputs[0].associatedVariableName, " - ").concat(r, ") * (").concat(s, " - ").concat(a, ") / (").concat(o, " - ").concat(r, `);
`), this;
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".sourceRange = new BABYLON.Vector2(").concat(this.sourceRange.x, ", ").concat(this.sourceRange.y, `);
`) + "".concat(this._codeVariableName, ".targetRange = new BABYLON.Vector2(").concat(this.targetRange.x, ", ").concat(this.targetRange.y, `);
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.sourceRange = this.sourceRange.asArray(), e.targetRange = this.targetRange.asArray(), e;
      }, t.prototype._deserialize = function(e, i, r) {
        n.prototype._deserialize.call(this, e, i, r), this.sourceRange = fe.FromArray(e.sourceRange), this.targetRange = fe.FromArray(e.targetRange);
      }, x([qe("From", Ye.Vector2)], t.prototype, "sourceRange", void 0), x([qe("To", Ye.Vector2)], t.prototype, "targetRange", void 0), t;
    }(We);
    j("BABYLON.RemapBlock", Lp);
    var kn, eh = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("left", M.AutoDetect), i.registerInput("right", M.AutoDetect), i.registerOutput("output", M.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._linkConnectionTypes(0, 1), i._inputs[0].acceptedConnectionPointTypes.push(M.Float), i._inputs[1].acceptedConnectionPointTypes.push(M.Float), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "MultiplyBlock";
      }, Object.defineProperty(t.prototype, "left", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        return e.compilationString += this._declareOutput(i, e) + " = ".concat(this.left.associatedVariableName, " * ").concat(this.right.associatedVariableName, `;
`), this;
      }, t;
    }(We);
    j("BABYLON.MultiplyBlock", eh), function(n) {
      n[n.Material = 0] = "Material", n[n.PostProcess = 1] = "PostProcess", n[n.Particle = 2] = "Particle", n[n.ProceduralTexture = 3] = "ProceduralTexture";
    }(kn || (kn = {}));
    var _l = function() {
      function n() {
        this.direction1 = new v(0, 1, 0), this.direction2 = new v(0, 1, 0), this.minEmitBox = new v(-0.5, -0.5, -0.5), this.maxEmitBox = new v(0.5, 0.5, 0.5);
      }
      return n.prototype.startDirectionFunction = function(t, e, i, r) {
        var o = ue.RandomRange(this.direction1.x, this.direction2.x), a = ue.RandomRange(this.direction1.y, this.direction2.y), s = ue.RandomRange(this.direction1.z, this.direction2.z);
        if (r)
          return e.x = o, e.y = a, void (e.z = s);
        v.TransformNormalFromFloatsToRef(o, a, s, t, e);
      }, n.prototype.startPositionFunction = function(t, e, i, r) {
        var o = ue.RandomRange(this.minEmitBox.x, this.maxEmitBox.x), a = ue.RandomRange(this.minEmitBox.y, this.maxEmitBox.y), s = ue.RandomRange(this.minEmitBox.z, this.maxEmitBox.z);
        if (r)
          return e.x = o, e.y = a, void (e.z = s);
        v.TransformCoordinatesFromFloatsToRef(o, a, s, t, e);
      }, n.prototype.clone = function() {
        var t = new n();
        return Ui.DeepCopy(this, t), t;
      }, n.prototype.applyToShader = function(t) {
        t.setVector3("direction1", this.direction1), t.setVector3("direction2", this.direction2), t.setVector3("minEmitBox", this.minEmitBox), t.setVector3("maxEmitBox", this.maxEmitBox);
      }, n.prototype.buildUniformLayout = function(t) {
        t.addUniform("direction1", 3), t.addUniform("direction2", 3), t.addUniform("minEmitBox", 3), t.addUniform("maxEmitBox", 3);
      }, n.prototype.getEffectDefines = function() {
        return "#define BOXEMITTER";
      }, n.prototype.getClassName = function() {
        return "BoxParticleEmitter";
      }, n.prototype.serialize = function() {
        var t = {};
        return t.type = this.getClassName(), t.direction1 = this.direction1.asArray(), t.direction2 = this.direction2.asArray(), t.minEmitBox = this.minEmitBox.asArray(), t.maxEmitBox = this.maxEmitBox.asArray(), t;
      }, n.prototype.parse = function(t) {
        v.FromArrayToRef(t.direction1, 0, this.direction1), v.FromArrayToRef(t.direction2, 0, this.direction2), v.FromArrayToRef(t.minEmitBox, 0, this.minEmitBox), v.FromArrayToRef(t.maxEmitBox, 0, this.maxEmitBox);
      }, n;
    }(), wp = function() {
      function n(t, e, i) {
        t === void 0 && (t = 1), e === void 0 && (e = Math.PI), i === void 0 && (i = 0), this.directionRandomizer = i, this.radiusRange = 1, this.heightRange = 1, this.emitFromSpawnPointOnly = !1, this.angle = e, this.radius = t;
      }
      return Object.defineProperty(n.prototype, "radius", { get: function() {
        return this._radius;
      }, set: function(t) {
        this._radius = t, this._buildHeight();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "angle", { get: function() {
        return this._angle;
      }, set: function(t) {
        this._angle = t, this._buildHeight();
      }, enumerable: !1, configurable: !0 }), n.prototype._buildHeight = function() {
        this._angle !== 0 ? this._height = this._radius / Math.tan(this._angle / 2) : this._height = 1;
      }, n.prototype.startDirectionFunction = function(t, e, i, r) {
        r ? F.Vector3[0].copyFrom(i._localPosition).normalize() : i.position.subtractToRef(t.getTranslation(), F.Vector3[0]).normalize();
        var o = ue.RandomRange(0, this.directionRandomizer), a = ue.RandomRange(0, this.directionRandomizer), s = ue.RandomRange(0, this.directionRandomizer);
        e.x = F.Vector3[0].x + o, e.y = F.Vector3[0].y + a, e.z = F.Vector3[0].z + s, e.normalize();
      }, n.prototype.startPositionFunction = function(t, e, i, r) {
        var o, a = ue.RandomRange(0, 2 * Math.PI);
        o = this.emitFromSpawnPointOnly ? 1e-4 : 1 - (o = ue.RandomRange(0, this.heightRange)) * o;
        var s = this._radius - ue.RandomRange(0, this._radius * this.radiusRange), l = (s *= o) * Math.sin(a), c = s * Math.cos(a), u = o * this._height;
        if (r)
          return e.x = l, e.y = u, void (e.z = c);
        v.TransformCoordinatesFromFloatsToRef(l, u, c, t, e);
      }, n.prototype.clone = function() {
        var t = new n(this._radius, this._angle, this.directionRandomizer);
        return Ui.DeepCopy(this, t), t;
      }, n.prototype.applyToShader = function(t) {
        t.setFloat2("radius", this._radius, this.radiusRange), t.setFloat("coneAngle", this._angle), t.setFloat2("height", this._height, this.heightRange), t.setFloat("directionRandomizer", this.directionRandomizer);
      }, n.prototype.buildUniformLayout = function(t) {
        t.addUniform("radius", 2), t.addUniform("coneAngle", 1), t.addUniform("height", 2), t.addUniform("directionRandomizer", 1);
      }, n.prototype.getEffectDefines = function() {
        var t = "#define CONEEMITTER";
        return this.emitFromSpawnPointOnly && (t += `
#define CONEEMITTERSPAWNPOINT`), t;
      }, n.prototype.getClassName = function() {
        return "ConeParticleEmitter";
      }, n.prototype.serialize = function() {
        var t = {};
        return t.type = this.getClassName(), t.radius = this._radius, t.angle = this._angle, t.directionRandomizer = this.directionRandomizer, t.radiusRange = this.radiusRange, t.heightRange = this.heightRange, t.emitFromSpawnPointOnly = this.emitFromSpawnPointOnly, t;
      }, n.prototype.parse = function(t) {
        this.radius = t.radius, this.angle = t.angle, this.directionRandomizer = t.directionRandomizer, this.radiusRange = t.radiusRange !== void 0 ? t.radiusRange : 1, this.heightRange = t.radiusRange !== void 0 ? t.heightRange : 1, this.emitFromSpawnPointOnly = t.emitFromSpawnPointOnly !== void 0 && t.emitFromSpawnPointOnly;
      }, n;
    }(), th = function() {
      function n(t, e, i, r) {
        t === void 0 && (t = 1), e === void 0 && (e = 1), i === void 0 && (i = 1), r === void 0 && (r = 0), this.radius = t, this.height = e, this.radiusRange = i, this.directionRandomizer = r, this._tempVector = v.Zero();
      }
      return n.prototype.startDirectionFunction = function(t, e, i, r, o) {
        i.position.subtractToRef(t.getTranslation(), this._tempVector), this._tempVector.normalize(), v.TransformNormalToRef(this._tempVector, o, this._tempVector);
        var a = ue.RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2), s = Math.atan2(this._tempVector.x, this._tempVector.z);
        s += ue.RandomRange(-Math.PI / 2, Math.PI / 2) * this.directionRandomizer, this._tempVector.y = a, this._tempVector.x = Math.sin(s), this._tempVector.z = Math.cos(s), this._tempVector.normalize(), r ? e.copyFrom(this._tempVector) : v.TransformNormalFromFloatsToRef(this._tempVector.x, this._tempVector.y, this._tempVector.z, t, e);
      }, n.prototype.startPositionFunction = function(t, e, i, r) {
        var o = ue.RandomRange(-this.height / 2, this.height / 2), a = ue.RandomRange(0, 2 * Math.PI), s = ue.RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1), l = Math.sqrt(s) * this.radius, c = l * Math.cos(a), u = l * Math.sin(a);
        r ? e.copyFromFloats(c, o, u) : v.TransformCoordinatesFromFloatsToRef(c, o, u, t, e);
      }, n.prototype.clone = function() {
        var t = new n(this.radius, this.directionRandomizer);
        return Ui.DeepCopy(this, t), t;
      }, n.prototype.applyToShader = function(t) {
        t.setFloat("radius", this.radius), t.setFloat("height", this.height), t.setFloat("radiusRange", this.radiusRange), t.setFloat("directionRandomizer", this.directionRandomizer);
      }, n.prototype.buildUniformLayout = function(t) {
        t.addUniform("radius", 1), t.addUniform("height", 1), t.addUniform("radiusRange", 1), t.addUniform("directionRandomizer", 1);
      }, n.prototype.getEffectDefines = function() {
        return "#define CYLINDEREMITTER";
      }, n.prototype.getClassName = function() {
        return "CylinderParticleEmitter";
      }, n.prototype.serialize = function() {
        var t = {};
        return t.type = this.getClassName(), t.radius = this.radius, t.height = this.height, t.radiusRange = this.radiusRange, t.directionRandomizer = this.directionRandomizer, t;
      }, n.prototype.parse = function(t) {
        this.radius = t.radius, this.height = t.height, this.radiusRange = t.radiusRange, this.directionRandomizer = t.directionRandomizer;
      }, n;
    }(), Bp = function(n) {
      function t(e, i, r, o, a) {
        e === void 0 && (e = 1), i === void 0 && (i = 1), r === void 0 && (r = 1), o === void 0 && (o = new v(0, 1, 0)), a === void 0 && (a = new v(0, 1, 0));
        var s = n.call(this, e, i, r) || this;
        return s.direction1 = o, s.direction2 = a, s;
      }
      return D(t, n), t.prototype.startDirectionFunction = function(e, i) {
        var r = ue.RandomRange(this.direction1.x, this.direction2.x), o = ue.RandomRange(this.direction1.y, this.direction2.y), a = ue.RandomRange(this.direction1.z, this.direction2.z);
        v.TransformNormalFromFloatsToRef(r, o, a, e, i);
      }, t.prototype.clone = function() {
        var e = new t(this.radius, this.height, this.radiusRange, this.direction1, this.direction2);
        return Ui.DeepCopy(this, e), e;
      }, t.prototype.applyToShader = function(e) {
        e.setFloat("radius", this.radius), e.setFloat("height", this.height), e.setFloat("radiusRange", this.radiusRange), e.setVector3("direction1", this.direction1), e.setVector3("direction2", this.direction2);
      }, t.prototype.buildUniformLayout = function(e) {
        e.addUniform("radius", 1), e.addUniform("height", 1), e.addUniform("radiusRange", 1), e.addUniform("direction1", 3), e.addUniform("direction2", 3);
      }, t.prototype.getEffectDefines = function() {
        return `#define CYLINDEREMITTER
#define DIRECTEDCYLINDEREMITTER`;
      }, t.prototype.getClassName = function() {
        return "CylinderDirectedParticleEmitter";
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.direction1 = this.direction1.asArray(), e.direction2 = this.direction2.asArray(), e;
      }, t.prototype.parse = function(e) {
        n.prototype.parse.call(this, e), this.direction1.copyFrom(e.direction1), this.direction2.copyFrom(e.direction2);
      }, t;
    }(th), Up = function() {
      function n(t, e, i) {
        t === void 0 && (t = 1), e === void 0 && (e = 1), i === void 0 && (i = 0), this.radius = t, this.radiusRange = e, this.directionRandomizer = i;
      }
      return n.prototype.startDirectionFunction = function(t, e, i, r) {
        var o = i.position.subtract(t.getTranslation()).normalize(), a = ue.RandomRange(0, this.directionRandomizer), s = ue.RandomRange(0, this.directionRandomizer), l = ue.RandomRange(0, this.directionRandomizer);
        o.x += a, o.y += s, o.z += l, o.normalize(), r ? e.copyFrom(o) : v.TransformNormalFromFloatsToRef(o.x, o.y, o.z, t, e);
      }, n.prototype.startPositionFunction = function(t, e, i, r) {
        var o = this.radius - ue.RandomRange(0, this.radius * this.radiusRange), a = ue.RandomRange(0, 1), s = ue.RandomRange(0, 2 * Math.PI), l = Math.acos(2 * a - 1), c = o * Math.cos(s) * Math.sin(l), u = o * Math.cos(l), h = o * Math.sin(s) * Math.sin(l);
        r ? e.copyFromFloats(c, Math.abs(u), h) : v.TransformCoordinatesFromFloatsToRef(c, Math.abs(u), h, t, e);
      }, n.prototype.clone = function() {
        var t = new n(this.radius, this.directionRandomizer);
        return Ui.DeepCopy(this, t), t;
      }, n.prototype.applyToShader = function(t) {
        t.setFloat("radius", this.radius), t.setFloat("radiusRange", this.radiusRange), t.setFloat("directionRandomizer", this.directionRandomizer);
      }, n.prototype.buildUniformLayout = function(t) {
        t.addUniform("radius", 1), t.addUniform("radiusRange", 1), t.addUniform("directionRandomizer", 1);
      }, n.prototype.getEffectDefines = function() {
        return "#define HEMISPHERICEMITTER";
      }, n.prototype.getClassName = function() {
        return "HemisphericParticleEmitter";
      }, n.prototype.serialize = function() {
        var t = {};
        return t.type = this.getClassName(), t.radius = this.radius, t.radiusRange = this.radiusRange, t.directionRandomizer = this.directionRandomizer, t;
      }, n.prototype.parse = function(t) {
        this.radius = t.radius, this.radiusRange = t.radiusRange, this.directionRandomizer = t.directionRandomizer;
      }, n;
    }(), Vp = function() {
      function n() {
        this.direction1 = new v(0, 1, 0), this.direction2 = new v(0, 1, 0);
      }
      return n.prototype.startDirectionFunction = function(t, e, i, r) {
        var o = ue.RandomRange(this.direction1.x, this.direction2.x), a = ue.RandomRange(this.direction1.y, this.direction2.y), s = ue.RandomRange(this.direction1.z, this.direction2.z);
        r ? e.copyFromFloats(o, a, s) : v.TransformNormalFromFloatsToRef(o, a, s, t, e);
      }, n.prototype.startPositionFunction = function(t, e, i, r) {
        r ? e.copyFromFloats(0, 0, 0) : v.TransformCoordinatesFromFloatsToRef(0, 0, 0, t, e);
      }, n.prototype.clone = function() {
        var t = new n();
        return Ui.DeepCopy(this, t), t;
      }, n.prototype.applyToShader = function(t) {
        t.setVector3("direction1", this.direction1), t.setVector3("direction2", this.direction2);
      }, n.prototype.buildUniformLayout = function(t) {
        t.addUniform("direction1", 3), t.addUniform("direction2", 3);
      }, n.prototype.getEffectDefines = function() {
        return "#define POINTEMITTER";
      }, n.prototype.getClassName = function() {
        return "PointParticleEmitter";
      }, n.prototype.serialize = function() {
        var t = {};
        return t.type = this.getClassName(), t.direction1 = this.direction1.asArray(), t.direction2 = this.direction2.asArray(), t;
      }, n.prototype.parse = function(t) {
        v.FromArrayToRef(t.direction1, 0, this.direction1), v.FromArrayToRef(t.direction2, 0, this.direction2);
      }, n;
    }(), ih = function() {
      function n(t, e, i) {
        t === void 0 && (t = 1), e === void 0 && (e = 1), i === void 0 && (i = 0), this.radius = t, this.radiusRange = e, this.directionRandomizer = i;
      }
      return n.prototype.startDirectionFunction = function(t, e, i, r) {
        var o = i.position.subtract(t.getTranslation()).normalize(), a = ue.RandomRange(0, this.directionRandomizer), s = ue.RandomRange(0, this.directionRandomizer), l = ue.RandomRange(0, this.directionRandomizer);
        o.x += a, o.y += s, o.z += l, o.normalize(), r ? e.copyFrom(o) : v.TransformNormalFromFloatsToRef(o.x, o.y, o.z, t, e);
      }, n.prototype.startPositionFunction = function(t, e, i, r) {
        var o = this.radius - ue.RandomRange(0, this.radius * this.radiusRange), a = ue.RandomRange(0, 1), s = ue.RandomRange(0, 2 * Math.PI), l = Math.acos(2 * a - 1), c = o * Math.cos(s) * Math.sin(l), u = o * Math.cos(l), h = o * Math.sin(s) * Math.sin(l);
        r ? e.copyFromFloats(c, u, h) : v.TransformCoordinatesFromFloatsToRef(c, u, h, t, e);
      }, n.prototype.clone = function() {
        var t = new n(this.radius, this.directionRandomizer);
        return Ui.DeepCopy(this, t), t;
      }, n.prototype.applyToShader = function(t) {
        t.setFloat("radius", this.radius), t.setFloat("radiusRange", this.radiusRange), t.setFloat("directionRandomizer", this.directionRandomizer);
      }, n.prototype.buildUniformLayout = function(t) {
        t.addUniform("radius", 1), t.addUniform("radiusRange", 1), t.addUniform("directionRandomizer", 1);
      }, n.prototype.getEffectDefines = function() {
        return "#define SPHEREEMITTER";
      }, n.prototype.getClassName = function() {
        return "SphereParticleEmitter";
      }, n.prototype.serialize = function() {
        var t = {};
        return t.type = this.getClassName(), t.radius = this.radius, t.radiusRange = this.radiusRange, t.directionRandomizer = this.directionRandomizer, t;
      }, n.prototype.parse = function(t) {
        this.radius = t.radius, this.radiusRange = t.radiusRange, this.directionRandomizer = t.directionRandomizer;
      }, n;
    }(), kp = function(n) {
      function t(e, i, r) {
        e === void 0 && (e = 1), i === void 0 && (i = new v(0, 1, 0)), r === void 0 && (r = new v(0, 1, 0));
        var o = n.call(this, e) || this;
        return o.direction1 = i, o.direction2 = r, o;
      }
      return D(t, n), t.prototype.startDirectionFunction = function(e, i) {
        var r = ue.RandomRange(this.direction1.x, this.direction2.x), o = ue.RandomRange(this.direction1.y, this.direction2.y), a = ue.RandomRange(this.direction1.z, this.direction2.z);
        v.TransformNormalFromFloatsToRef(r, o, a, e, i);
      }, t.prototype.clone = function() {
        var e = new t(this.radius, this.direction1, this.direction2);
        return Ui.DeepCopy(this, e), e;
      }, t.prototype.applyToShader = function(e) {
        e.setFloat("radius", this.radius), e.setFloat("radiusRange", this.radiusRange), e.setVector3("direction1", this.direction1), e.setVector3("direction2", this.direction2);
      }, t.prototype.buildUniformLayout = function(e) {
        e.addUniform("radius", 1), e.addUniform("radiusRange", 1), e.addUniform("direction1", 3), e.addUniform("direction2", 3);
      }, t.prototype.getEffectDefines = function() {
        return `#define SPHEREEMITTER
#define DIRECTEDSPHEREEMITTER`;
      }, t.prototype.getClassName = function() {
        return "SphereDirectedParticleEmitter";
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.direction1 = this.direction1.asArray(), e.direction2 = this.direction2.asArray(), e;
      }, t.prototype.parse = function(e) {
        n.prototype.parse.call(this, e), this.direction1.copyFrom(e.direction1), this.direction2.copyFrom(e.direction2);
      }, t;
    }(ih), ml = function() {
      function n() {
        this.particlePositionGenerator = function() {
        }, this.particleDestinationGenerator = function() {
        };
      }
      return n.prototype.startDirectionFunction = function(t, e, i, r) {
        var o = F.Vector3[0];
        if (this.particleDestinationGenerator) {
          this.particleDestinationGenerator(-1, i, o);
          var a = F.Vector3[1];
          o.subtractToRef(i.position, a), a.scaleToRef(1 / i.lifeTime, o);
        } else
          o.set(0, 0, 0);
        r ? e.copyFrom(o) : v.TransformNormalToRef(o, t, e);
      }, n.prototype.startPositionFunction = function(t, e, i, r) {
        var o = F.Vector3[0];
        this.particlePositionGenerator ? this.particlePositionGenerator(-1, i, o) : o.set(0, 0, 0), r ? e.copyFrom(o) : v.TransformCoordinatesToRef(o, t, e);
      }, n.prototype.clone = function() {
        var t = new n();
        return Ui.DeepCopy(this, t), t;
      }, n.prototype.applyToShader = function(t) {
      }, n.prototype.buildUniformLayout = function(t) {
      }, n.prototype.getEffectDefines = function() {
        return "#define CUSTOMEMITTER";
      }, n.prototype.getClassName = function() {
        return "CustomParticleEmitter";
      }, n.prototype.serialize = function() {
        var t = {};
        return t.type = this.getClassName(), t;
      }, n.prototype.parse = function(t) {
      }, n;
    }(), Lg = function() {
      function n(t) {
        t === void 0 && (t = null), this._indices = null, this._positions = null, this._normals = null, this._storedNormal = v.Zero(), this._mesh = null, this.direction1 = new v(0, 1, 0), this.direction2 = new v(0, 1, 0), this.useMeshNormalsForDirection = !0, this.mesh = t;
      }
      return Object.defineProperty(n.prototype, "mesh", { get: function() {
        return this._mesh;
      }, set: function(t) {
        this._mesh !== t && (this._mesh = t, t ? (this._indices = t.getIndices(), this._positions = t.getVerticesData(P.PositionKind), this._normals = t.getVerticesData(P.NormalKind)) : (this._indices = null, this._positions = null, this._normals = null));
      }, enumerable: !1, configurable: !0 }), n.prototype.startDirectionFunction = function(t, e, i, r) {
        if (this.useMeshNormalsForDirection && this._normals)
          v.TransformNormalToRef(this._storedNormal, t, e);
        else {
          var o = ue.RandomRange(this.direction1.x, this.direction2.x), a = ue.RandomRange(this.direction1.y, this.direction2.y), s = ue.RandomRange(this.direction1.z, this.direction2.z);
          r ? e.copyFromFloats(o, a, s) : v.TransformNormalFromFloatsToRef(o, a, s, t, e);
        }
      }, n.prototype.startPositionFunction = function(t, e, i, r) {
        if (this._indices && this._positions) {
          var o = 3 * Math.random() * (this._indices.length / 3) | 0, a = Math.random(), s = Math.random() * (1 - a), l = 1 - a - s, c = this._indices[o], u = this._indices[o + 1], h = this._indices[o + 2], d = F.Vector3[0], p = F.Vector3[1], f = F.Vector3[2], m = F.Vector3[3];
          v.FromArrayToRef(this._positions, 3 * c, d), v.FromArrayToRef(this._positions, 3 * u, p), v.FromArrayToRef(this._positions, 3 * h, f), m.x = a * d.x + s * p.x + l * f.x, m.y = a * d.y + s * p.y + l * f.y, m.z = a * d.z + s * p.z + l * f.z, r ? e.copyFromFloats(m.x, m.y, m.z) : v.TransformCoordinatesFromFloatsToRef(m.x, m.y, m.z, t, e), this.useMeshNormalsForDirection && this._normals && (v.FromArrayToRef(this._normals, 3 * c, d), v.FromArrayToRef(this._normals, 3 * u, p), v.FromArrayToRef(this._normals, 3 * h, f), this._storedNormal.x = a * d.x + s * p.x + l * f.x, this._storedNormal.y = a * d.y + s * p.y + l * f.y, this._storedNormal.z = a * d.z + s * p.z + l * f.z);
        }
      }, n.prototype.clone = function() {
        var t = new n(this.mesh);
        return Ui.DeepCopy(this, t), t;
      }, n.prototype.applyToShader = function(t) {
        t.setVector3("direction1", this.direction1), t.setVector3("direction2", this.direction2);
      }, n.prototype.buildUniformLayout = function(t) {
        t.addUniform("direction1", 3), t.addUniform("direction2", 3);
      }, n.prototype.getEffectDefines = function() {
        return "";
      }, n.prototype.getClassName = function() {
        return "MeshParticleEmitter";
      }, n.prototype.serialize = function() {
        var t, e = {};
        return e.type = this.getClassName(), e.direction1 = this.direction1.asArray(), e.direction2 = this.direction2.asArray(), e.meshId = (t = this.mesh) === null || t === void 0 ? void 0 : t.id, e.useMeshNormalsForDirection = this.useMeshNormalsForDirection, e;
      }, n.prototype.parse = function(t, e) {
        v.FromArrayToRef(t.direction1, 0, this.direction1), v.FromArrayToRef(t.direction2, 0, this.direction2), t.meshId && e && (this.mesh = e.getLastMeshById(t.meshId)), this.useMeshNormalsForDirection = t.useMeshNormalsForDirection;
      }, n;
    }(), fc = function() {
      function n(t) {
        this.animations = [], this.renderingGroupId = 0, this.emitter = v.Zero(), this.emitRate = 10, this.manualEmitCount = -1, this.updateSpeed = 0.01, this.targetStopDuration = 0, this.disposeOnStop = !1, this.minEmitPower = 1, this.maxEmitPower = 1, this.minLifeTime = 1, this.maxLifeTime = 1, this.minSize = 1, this.maxSize = 1, this.minScaleX = 1, this.maxScaleX = 1, this.minScaleY = 1, this.maxScaleY = 1, this.minInitialRotation = 0, this.maxInitialRotation = 0, this.minAngularSpeed = 0, this.maxAngularSpeed = 0, this.layerMask = 268435455, this.customShader = null, this.preventAutoStart = !1, this._wasDispatched = !1, this._rootUrl = "", this.noiseStrength = new v(10, 10, 10), this.onAnimationEnd = null, this.blendMode = n.BLENDMODE_ONEONE, this.forceDepthWrite = !1, this.preWarmCycles = 0, this.preWarmStepOffset = 1, this.spriteCellChangeSpeed = 1, this.startSpriteCellID = 0, this.endSpriteCellID = 0, this.spriteCellWidth = 0, this.spriteCellHeight = 0, this.spriteCellLoop = !0, this.spriteRandomStartCell = !1, this.translationPivot = new fe(0, 0), this.beginAnimationOnStart = !1, this.beginAnimationFrom = 0, this.beginAnimationTo = 60, this.beginAnimationLoop = !1, this.worldOffset = new v(0, 0, 0), this._useLogarithmicDepth = !1, this.gravity = v.Zero(), this._colorGradients = null, this._sizeGradients = null, this._lifeTimeGradients = null, this._angularSpeedGradients = null, this._velocityGradients = null, this._limitVelocityGradients = null, this._dragGradients = null, this._emitRateGradients = null, this._startSizeGradients = null, this._rampGradients = null, this._colorRemapGradients = null, this._alphaRemapGradients = null, this.startDelay = 0, this.limitVelocityDamping = 0.4, this.color1 = new Ie(1, 1, 1, 1), this.color2 = new Ie(1, 1, 1, 1), this.colorDead = new Ie(0, 0, 0, 1), this.textureMask = new Ie(1, 1, 1, 1), this._isSubEmitter = !1, this._billboardMode = _.PARTICLES_BILLBOARDMODE_ALL, this._isBillboardBased = !0, this._imageProcessingConfigurationDefines = new tg(), this.id = t, this.name = t;
      }
      return Object.defineProperty(n.prototype, "noiseTexture", { get: function() {
        return this._noiseTexture;
      }, set: function(t) {
        this._noiseTexture !== t && (this._noiseTexture = t, this._reset());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isAnimationSheetEnabled", { get: function() {
        return this._isAnimationSheetEnabled;
      }, set: function(t) {
        this._isAnimationSheetEnabled != t && (this._isAnimationSheetEnabled = t, this._reset());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "useLogarithmicDepth", { get: function() {
        return this._useLogarithmicDepth;
      }, set: function(t) {
        this._useLogarithmicDepth = t && this.getScene().getEngine().getCaps().fragmentDepthSupported;
      }, enumerable: !1, configurable: !0 }), n.prototype.getScene = function() {
        return this._scene;
      }, n.prototype._hasTargetStopDurationDependantGradient = function() {
        return this._startSizeGradients && this._startSizeGradients.length > 0 || this._emitRateGradients && this._emitRateGradients.length > 0 || this._lifeTimeGradients && this._lifeTimeGradients.length > 0;
      }, n.prototype.getDragGradients = function() {
        return this._dragGradients;
      }, n.prototype.getLimitVelocityGradients = function() {
        return this._limitVelocityGradients;
      }, n.prototype.getColorGradients = function() {
        return this._colorGradients;
      }, n.prototype.getSizeGradients = function() {
        return this._sizeGradients;
      }, n.prototype.getColorRemapGradients = function() {
        return this._colorRemapGradients;
      }, n.prototype.getAlphaRemapGradients = function() {
        return this._alphaRemapGradients;
      }, n.prototype.getLifeTimeGradients = function() {
        return this._lifeTimeGradients;
      }, n.prototype.getAngularSpeedGradients = function() {
        return this._angularSpeedGradients;
      }, n.prototype.getVelocityGradients = function() {
        return this._velocityGradients;
      }, n.prototype.getStartSizeGradients = function() {
        return this._startSizeGradients;
      }, n.prototype.getEmitRateGradients = function() {
        return this._emitRateGradients;
      }, Object.defineProperty(n.prototype, "direction1", { get: function() {
        return this.particleEmitterType.direction1 ? this.particleEmitterType.direction1 : v.Zero();
      }, set: function(t) {
        this.particleEmitterType.direction1 && (this.particleEmitterType.direction1 = t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "direction2", { get: function() {
        return this.particleEmitterType.direction2 ? this.particleEmitterType.direction2 : v.Zero();
      }, set: function(t) {
        this.particleEmitterType.direction2 && (this.particleEmitterType.direction2 = t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "minEmitBox", { get: function() {
        return this.particleEmitterType.minEmitBox ? this.particleEmitterType.minEmitBox : v.Zero();
      }, set: function(t) {
        this.particleEmitterType.minEmitBox && (this.particleEmitterType.minEmitBox = t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "maxEmitBox", { get: function() {
        return this.particleEmitterType.maxEmitBox ? this.particleEmitterType.maxEmitBox : v.Zero();
      }, set: function(t) {
        this.particleEmitterType.maxEmitBox && (this.particleEmitterType.maxEmitBox = t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "billboardMode", { get: function() {
        return this._billboardMode;
      }, set: function(t) {
        this._billboardMode !== t && (this._billboardMode = t, this._reset());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isBillboardBased", { get: function() {
        return this._isBillboardBased;
      }, set: function(t) {
        this._isBillboardBased !== t && (this._isBillboardBased = t, this._reset());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "imageProcessingConfiguration", { get: function() {
        return this._imageProcessingConfiguration;
      }, set: function(t) {
        this._attachImageProcessingConfiguration(t);
      }, enumerable: !1, configurable: !0 }), n.prototype._attachImageProcessingConfiguration = function(t) {
        t !== this._imageProcessingConfiguration && (!t && this._scene ? this._imageProcessingConfiguration = this._scene.imageProcessingConfiguration : this._imageProcessingConfiguration = t);
      }, n.prototype._reset = function() {
      }, n.prototype._removeGradientAndTexture = function(t, e, i) {
        if (!e)
          return this;
        for (var r = 0, o = 0, a = e; o < a.length; o++) {
          if (a[o].gradient === t) {
            e.splice(r, 1);
            break;
          }
          r++;
        }
        return i && i.dispose(), this;
      }, n.prototype.createPointEmitter = function(t, e) {
        var i = new Vp();
        return i.direction1 = t, i.direction2 = e, this.particleEmitterType = i, i;
      }, n.prototype.createHemisphericEmitter = function(t, e) {
        t === void 0 && (t = 1), e === void 0 && (e = 1);
        var i = new Up(t, e);
        return this.particleEmitterType = i, i;
      }, n.prototype.createSphereEmitter = function(t, e) {
        t === void 0 && (t = 1), e === void 0 && (e = 1);
        var i = new ih(t, e);
        return this.particleEmitterType = i, i;
      }, n.prototype.createDirectedSphereEmitter = function(t, e, i) {
        t === void 0 && (t = 1), e === void 0 && (e = new v(0, 1, 0)), i === void 0 && (i = new v(0, 1, 0));
        var r = new kp(t, e, i);
        return this.particleEmitterType = r, r;
      }, n.prototype.createCylinderEmitter = function(t, e, i, r) {
        t === void 0 && (t = 1), e === void 0 && (e = 1), i === void 0 && (i = 1), r === void 0 && (r = 0);
        var o = new th(t, e, i, r);
        return this.particleEmitterType = o, o;
      }, n.prototype.createDirectedCylinderEmitter = function(t, e, i, r, o) {
        t === void 0 && (t = 1), e === void 0 && (e = 1), i === void 0 && (i = 1), r === void 0 && (r = new v(0, 1, 0)), o === void 0 && (o = new v(0, 1, 0));
        var a = new Bp(t, e, i, r, o);
        return this.particleEmitterType = a, a;
      }, n.prototype.createConeEmitter = function(t, e) {
        t === void 0 && (t = 1), e === void 0 && (e = Math.PI / 4);
        var i = new wp(t, e);
        return this.particleEmitterType = i, i;
      }, n.prototype.createBoxEmitter = function(t, e, i, r) {
        var o = new _l();
        return this.particleEmitterType = o, this.direction1 = t, this.direction2 = e, this.minEmitBox = i, this.maxEmitBox = r, o;
      }, n.BLENDMODE_ONEONE = 0, n.BLENDMODE_STANDARD = 1, n.BLENDMODE_ADD = 2, n.BLENDMODE_MULTIPLY = 3, n.BLENDMODE_MULTIPLYADD = 4, n;
    }(), Gp = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("rgba", M.Color4, !0), i.registerInput("rgb ", M.Color3, !0), i.registerOutput("rgb", M.Color3), i.registerOutput("r", M.Float), i.registerOutput("g", M.Float), i.registerOutput("b", M.Float), i.registerOutput("a", M.Float), i.inputsAreExclusive = !0, i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ColorSplitterBlock";
      }, Object.defineProperty(t.prototype, "rgba", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgbIn", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgbOut", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "r", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "g", { get: function() {
        return this._outputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "b", { get: function() {
        return this._outputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "a", { get: function() {
        return this._outputs[4];
      }, enumerable: !1, configurable: !0 }), t.prototype._inputRename = function(e) {
        return e === "rgb " ? "rgbIn" : e;
      }, t.prototype._outputRename = function(e) {
        return e === "rgb" ? "rgbOut" : e;
      }, t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this.rgba.isConnected ? this.rgba : this.rgbIn;
        if (i.isConnected) {
          var r = this._outputs[0], o = this._outputs[1], a = this._outputs[2], s = this._outputs[3], l = this._outputs[4];
          return r.hasEndpoints && (e.compilationString += this._declareOutput(r, e) + " = ".concat(i.associatedVariableName, `.rgb;
`)), o.hasEndpoints && (e.compilationString += this._declareOutput(o, e) + " = ".concat(i.associatedVariableName, `.r;
`)), a.hasEndpoints && (e.compilationString += this._declareOutput(a, e) + " = ".concat(i.associatedVariableName, `.g;
`)), s.hasEndpoints && (e.compilationString += this._declareOutput(s, e) + " = ".concat(i.associatedVariableName, `.b;
`)), l.hasEndpoints && (e.compilationString += this._declareOutput(l, e) + " = ".concat(i.associatedVariableName, `.a;
`)), this;
        }
      }, t;
    }(We);
    j("BABYLON.ColorSplitterBlock", Gp), Qe.prototype.createRenderTargetCubeTexture = function(n, t) {
      var e = this._createHardwareRenderTargetWrapper(!1, !0, n), i = je({ generateMipMaps: !0, generateDepthBuffer: !0, generateStencilBuffer: !1, type: _.TEXTURETYPE_UNSIGNED_INT, samplingMode: _.TEXTURE_TRILINEAR_SAMPLINGMODE, format: _.TEXTUREFORMAT_RGBA }, t);
      i.generateStencilBuffer = i.generateDepthBuffer && i.generateStencilBuffer, (i.type !== _.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (i.type !== _.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (i.samplingMode = _.TEXTURE_NEAREST_SAMPLINGMODE);
      var r = this._gl, o = new Ut(this, ut.RenderTarget);
      this._bindTextureDirectly(r.TEXTURE_CUBE_MAP, o, !0);
      var a = this._getSamplingParameters(i.samplingMode, i.generateMipMaps);
      i.type !== _.TEXTURETYPE_FLOAT || this._caps.textureFloat || (i.type = _.TEXTURETYPE_UNSIGNED_INT, q.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type")), r.texParameteri(r.TEXTURE_CUBE_MAP, r.TEXTURE_MAG_FILTER, a.mag), r.texParameteri(r.TEXTURE_CUBE_MAP, r.TEXTURE_MIN_FILTER, a.min), r.texParameteri(r.TEXTURE_CUBE_MAP, r.TEXTURE_WRAP_S, r.CLAMP_TO_EDGE), r.texParameteri(r.TEXTURE_CUBE_MAP, r.TEXTURE_WRAP_T, r.CLAMP_TO_EDGE);
      for (var s = 0; s < 6; s++)
        r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X + s, 0, this._getRGBABufferInternalSizedFormat(i.type, i.format), n, n, 0, this._getInternalFormat(i.format), this._getWebGLTextureType(i.type), null);
      var l = r.createFramebuffer();
      return this._bindUnboundFramebuffer(l), e._depthStencilBuffer = this._setupFramebufferDepthAttachments(i.generateStencilBuffer, i.generateDepthBuffer, n, n), i.generateMipMaps && r.generateMipmap(r.TEXTURE_CUBE_MAP), this._bindTextureDirectly(r.TEXTURE_CUBE_MAP, null), this._bindUnboundFramebuffer(null), e._framebuffer = l, e._generateDepthBuffer = i.generateDepthBuffer, e._generateStencilBuffer = i.generateStencilBuffer, o.width = n, o.height = n, o.isReady = !0, o.isCube = !0, o.samples = 1, o.generateMipMaps = i.generateMipMaps, o.samplingMode = i.samplingMode, o.type = i.type, o.format = i.format, this._internalTexturesCache.push(o), e.setTextures(o), e;
    };
    var wg = { positions: [1, 1, -1, 1, -1, -1, 1, -1], indices: [0, 1, 2, 0, 2, 3] }, _c = function() {
      function n(t, e) {
        var i;
        e === void 0 && (e = wg);
        var r, o, a = this;
        this._fullscreenViewport = new xr(0, 0, 1, 1);
        var s = (r = e.positions) !== null && r !== void 0 ? r : wg.positions, l = (o = e.indices) !== null && o !== void 0 ? o : wg.indices;
        this.engine = t, this._vertexBuffers = ((i = {})[P.PositionKind] = new P(t, s, P.PositionKind, !1, !1, 2), i), this._indexBuffer = t.createIndexBuffer(l), this._onContextRestoredObserver = t.onContextRestoredObservable.add(function() {
          for (var c in a._indexBuffer = t.createIndexBuffer(l), a._vertexBuffers)
            a._vertexBuffers[c]._rebuild();
        });
      }
      return n.prototype.setViewport = function(t) {
        t === void 0 && (t = this._fullscreenViewport), this.engine.setViewport(t);
      }, n.prototype.bindBuffers = function(t) {
        this.engine.bindBuffers(this._vertexBuffers, this._indexBuffer, t);
      }, n.prototype.applyEffectWrapper = function(t) {
        this.engine.setState(!0), this.engine.depthCullingState.depthTest = !1, this.engine.stencilState.stencilTest = !1, this.engine.enableEffect(t._drawWrapper), this.bindBuffers(t.effect), t.onApplyObservable.notifyObservers({});
      }, n.prototype.saveStates = function() {
        this._savedStateDepthTest = this.engine.depthCullingState.depthTest, this._savedStateStencilTest = this.engine.stencilState.stencilTest;
      }, n.prototype.restoreStates = function() {
        this.engine.depthCullingState.depthTest = this._savedStateDepthTest, this.engine.stencilState.stencilTest = this._savedStateStencilTest;
      }, n.prototype.draw = function() {
        this.engine.drawElementsType(_.MATERIAL_TriangleFillMode, 0, 6);
      }, n.prototype._isRenderTargetTexture = function(t) {
        return t.renderTarget !== void 0;
      }, n.prototype.render = function(t, e) {
        if (e === void 0 && (e = null), t.effect.isReady()) {
          this.saveStates(), this.setViewport();
          var i = e === null ? null : this._isRenderTargetTexture(e) ? e.renderTarget : e;
          i && this.engine.bindFramebuffer(i), this.applyEffectWrapper(t), this.draw(), i && this.engine.unBindFramebuffer(i), this.restoreStates();
        }
      }, n.prototype.dispose = function() {
        var t = this._vertexBuffers[P.PositionKind];
        t && (t.dispose(), delete this._vertexBuffers[P.PositionKind]), this._indexBuffer && this.engine._releaseBuffer(this._indexBuffer), this._onContextRestoredObserver && (this.engine.onContextRestoredObservable.remove(this._onContextRestoredObserver), this._onContextRestoredObserver = null);
      }, n;
    }(), Io = function() {
      function n(t) {
        var e, i = this;
        this.onApplyObservable = new H();
        var r = t.uniformNames || [];
        t.vertexShader ? e = { fragmentSource: t.fragmentShader, vertexSource: t.vertexShader, spectorName: t.name || "effectWrapper" } : (r.push("scale"), e = { fragmentSource: t.fragmentShader, vertex: "postprocess", spectorName: t.name || "effectWrapper" }, this.onApplyObservable.add(function() {
          i.effect.setFloat2("scale", 1, 1);
        }));
        var o = t.defines ? t.defines.join(`
`) : "";
        this._drawWrapper = new Ei(t.engine), t.useShaderStore ? (e.fragment = e.fragmentSource, e.vertex || (e.vertex = e.vertexSource), delete e.fragmentSource, delete e.vertexSource, this.effect = t.engine.createEffect(e, t.attributeNames || ["position"], r, t.samplerNames, o, void 0, t.onCompiled, void 0, void 0, t.shaderLanguage)) : (this.effect = new Jt(e, t.attributeNames || ["position"], r, t.samplerNames, t.engine, o, void 0, t.onCompiled, void 0, void 0, void 0, t.shaderLanguage), this._onContextRestoredObserver = t.engine.onContextRestoredObservable.add(function() {
          i.effect._pipelineContext = null, i.effect._wasPreviouslyReady = !1, i.effect._prepareEffect();
        }));
      }
      return Object.defineProperty(n.prototype, "effect", { get: function() {
        return this._drawWrapper.effect;
      }, set: function(t) {
        this._drawWrapper.effect = t;
      }, enumerable: !1, configurable: !0 }), n.prototype.dispose = function() {
        this._onContextRestoredObserver && (this.effect.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver), this._onContextRestoredObserver = null), this.effect.dispose();
      }, n;
    }(), PR = "passPixelShader", IR = `varying vec2 vUV;uniform sampler2D textureSampler;
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void) 
{gl_FragColor=texture2D(textureSampler,vUV);}`;
    re.ShadersStore[PR] = IR;
    var G1 = PR, z1 = IR, la = function() {
      function n() {
      }
      return n._CreateDumpRenderer = function() {
        if (!n._DumpToolsEngine) {
          var t = void 0, e = null, i = { preserveDrawingBuffer: !0, depth: !1, stencil: !1, alpha: !0, premultipliedAlpha: !1, antialias: !1, failIfMajorPerformanceCaveat: !1 };
          try {
            t = new OffscreenCanvas(100, 100), e = new Qe(t, !1, i);
          } catch {
            t = document.createElement("canvas"), e = new Qe(t, !1, i);
          }
          e.getCaps().parallelShaderCompile = void 0;
          var r = new _c(e), o = new Io({ engine: e, name: G1, fragmentShader: z1, samplerNames: ["textureSampler"] });
          n._DumpToolsEngine = { canvas: t, engine: e, renderer: r, wrapper: o };
        }
        return n._DumpToolsEngine;
      }, n.DumpFramebuffer = function(t, e, i, r, o, a, s) {
        return o === void 0 && (o = "image/png"), Ft(this, void 0, void 0, function() {
          var l, c;
          return Bt(this, function(u) {
            switch (u.label) {
              case 0:
                return [4, i.readPixels(0, 0, t, e)];
              case 1:
                return l = u.sent(), c = new Uint8Array(l.buffer), n.DumpData(t, e, c, r, o, a, !0, void 0, s), [2];
            }
          });
        });
      }, n.DumpDataAsync = function(t, e, i, r, o, a, s, l) {
        return r === void 0 && (r = "image/png"), a === void 0 && (a = !1), s === void 0 && (s = !1), new Promise(function(c) {
          n.DumpData(t, e, i, function(u) {
            return c(u);
          }, r, o, a, s, l);
        });
      }, n.DumpData = function(t, e, i, r, o, a, s, l, c) {
        o === void 0 && (o = "image/png"), s === void 0 && (s = !1), l === void 0 && (l = !1);
        var u = n._CreateDumpRenderer();
        if (u.engine.setSize(t, e, !0), i instanceof Float32Array) {
          for (var h = new Uint8Array(i.length), d = i.length; d--; ) {
            var p = i[d];
            h[d] = Math.round(255 * ue.Clamp(p));
          }
          i = h;
        }
        var f = u.engine.createRawTexture(i, t, e, _.TEXTUREFORMAT_RGBA, !1, !s, _.TEXTURE_NEAREST_NEAREST);
        u.renderer.setViewport(), u.renderer.applyEffectWrapper(u.wrapper), u.wrapper.effect._bindTexture("textureSampler", f), u.renderer.draw(), l ? de.ToBlob(u.canvas, function(m) {
          var g = new FileReader();
          g.onload = function(y) {
            var b = y.target.result;
            r && r(b);
          }, g.readAsArrayBuffer(m);
        }, o, c) : de.EncodeScreenshotCanvasData(u.canvas, r, o, a, c), f.dispose();
      }, n.Dispose = function() {
        n._DumpToolsEngine && (n._DumpToolsEngine.wrapper.dispose(), n._DumpToolsEngine.renderer.dispose(), n._DumpToolsEngine.engine.dispose()), n._DumpToolsEngine = null;
      }, n;
    }();
    de.DumpData = la.DumpData, de.DumpDataAsync = la.DumpDataAsync, de.DumpFramebuffer = la.DumpFramebuffer;
    var Mi = function(n) {
      function t(e, i, r, o, a, s, l, c, u, h, d, p, f, m, g, y, b) {
        o === void 0 && (o = !1), a === void 0 && (a = !0), s === void 0 && (s = _.TEXTURETYPE_UNSIGNED_INT), l === void 0 && (l = !1), c === void 0 && (c = ae.TRILINEAR_SAMPLINGMODE), u === void 0 && (u = !0), h === void 0 && (h = !1), d === void 0 && (d = !1), p === void 0 && (p = _.TEXTUREFORMAT_RGBA), f === void 0 && (f = !1), y === void 0 && (y = !1), b === void 0 && (b = !1);
        var T, S, E, A, R, C, L, I = this, O = void 0, w = !0;
        if (typeof o == "object") {
          var z = o;
          o = !!z.generateMipMaps, a = (T = z.doNotChangeAspectRatio) === null || T === void 0 || T, s = (S = z.type) !== null && S !== void 0 ? S : _.TEXTURETYPE_UNSIGNED_BYTE, l = !!z.isCube, c = (E = z.samplingMode) !== null && E !== void 0 ? E : ae.TRILINEAR_SAMPLINGMODE, u = (A = z.generateDepthBuffer) === null || A === void 0 || A, h = !!z.generateStencilBuffer, d = !!z.isMulti, p = (R = z.format) !== null && R !== void 0 ? R : _.TEXTUREFORMAT_RGBA, f = !!z.delayAllocation, m = z.samples, g = z.creationFlags, y = !!z.noColorAttachment, b = !!z.useSRGBBuffer, O = z.colorAttachment, w = (C = z.gammaSpace) !== null && C !== void 0 ? C : w;
        }
        if ((I = n.call(this, null, r, !o, void 0, c, void 0, void 0, void 0, void 0, p) || this)._unObserveRenderList = null, I._renderListHasChanged = function(Y, ee) {
          var J, X = I._renderList ? I._renderList.length : 0;
          (ee === 0 && X > 0 || X === 0) && ((J = I.getScene()) === null || J === void 0 || J.meshes.forEach(function(K) {
            K._markSubMeshesAsLightDirty();
          }));
        }, I.renderParticles = !0, I.renderSprites = !1, I.forceLayerMaskCheck = !1, I.ignoreCameraViewport = !1, I.onBeforeBindObservable = new H(), I.onAfterUnbindObservable = new H(), I.onBeforeRenderObservable = new H(), I.onAfterRenderObservable = new H(), I.onClearObservable = new H(), I.onResizeObservable = new H(), I._cleared = !1, I.skipInitialClear = !1, I._currentRefreshId = -1, I._refreshRate = 1, I._samples = 1, I._canRescale = !0, I._renderTarget = null, I.boundingBoxPosition = v.Zero(), !(r = I.getScene()))
          return I;
        var V = I.getScene().getEngine();
        return I._gammaSpace = w, I._coordinatesMode = ae.PROJECTION_MODE, I.renderList = [], I.name = e, I.isRenderTarget = !0, I._initialSizeParameter = i, I._renderPassIds = [], I._isCubeData = l, I._processSizeParameter(i), I.renderPassId = I._renderPassIds[0], I._resizeObserver = V.onResizeObservable.add(function() {
        }), I._generateMipMaps = !!o, I._doNotChangeAspectRatio = a, I._renderingManager = new rc(r), I._renderingManager._useSceneAutoClearSetup = !0, d || (I._renderTargetOptions = { generateMipMaps: o, type: s, format: (L = I._format) !== null && L !== void 0 ? L : void 0, samplingMode: I.samplingMode, generateDepthBuffer: u, generateStencilBuffer: h, samples: m, creationFlags: g, noColorAttachment: y, useSRGBBuffer: b, colorAttachment: O, label: I.name }, I.samplingMode === ae.NEAREST_SAMPLINGMODE && (I.wrapU = ae.CLAMP_ADDRESSMODE, I.wrapV = ae.CLAMP_ADDRESSMODE), f || (l ? (I._renderTarget = r.getEngine().createRenderTargetCubeTexture(I.getRenderSize(), I._renderTargetOptions), I.coordinatesMode = ae.INVCUBIC_MODE, I._textureMatrix = B.Identity()) : I._renderTarget = r.getEngine().createRenderTargetTexture(I._size, I._renderTargetOptions), I._texture = I._renderTarget.texture, m !== void 0 && (I.samples = m))), I;
      }
      return D(t, n), Object.defineProperty(t.prototype, "renderList", { get: function() {
        return this._renderList;
      }, set: function(e) {
        this._unObserveRenderList && (this._unObserveRenderList(), this._unObserveRenderList = null), e && (this._unObserveRenderList = ot(e, this._renderListHasChanged)), this._renderList = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "postProcesses", { get: function() {
        return this._postProcesses;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "_prePassEnabled", { get: function() {
        return !!this._prePassRenderTarget && this._prePassRenderTarget.enabled;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onAfterUnbind", { set: function(e) {
        this._onAfterUnbindObserver && this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver), this._onAfterUnbindObserver = this.onAfterUnbindObservable.add(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onBeforeRender", { set: function(e) {
        this._onBeforeRenderObserver && this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver), this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onAfterRender", { set: function(e) {
        this._onAfterRenderObserver && this.onAfterRenderObservable.remove(this._onAfterRenderObserver), this._onAfterRenderObserver = this.onAfterRenderObservable.add(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onClear", { set: function(e) {
        this._onClearObserver && this.onClearObservable.remove(this._onClearObserver), this._onClearObserver = this.onClearObservable.add(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "renderPassIds", { get: function() {
        return this._renderPassIds;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "currentRefreshId", { get: function() {
        return this._currentRefreshId;
      }, enumerable: !1, configurable: !0 }), t.prototype.setMaterialForRendering = function(e, i) {
        var r;
        r = Array.isArray(e) ? e : [e];
        for (var o = 0; o < r.length; ++o)
          for (var a = 0; a < this._renderPassIds.length; ++a)
            r[o].setMaterialForRenderPass(this._renderPassIds[a], i !== void 0 ? Array.isArray(i) ? i[a] : i : void 0);
      }, Object.defineProperty(t.prototype, "isMulti", { get: function() {
        var e, i;
        return (i = (e = this._renderTarget) === null || e === void 0 ? void 0 : e.isMulti) !== null && i !== void 0 && i;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "renderTargetOptions", { get: function() {
        return this._renderTargetOptions;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "renderTarget", { get: function() {
        return this._renderTarget;
      }, enumerable: !1, configurable: !0 }), t.prototype._onRatioRescale = function() {
        this._sizeRatio && this.resize(this._initialSizeParameter);
      }, Object.defineProperty(t.prototype, "boundingBoxSize", { get: function() {
        return this._boundingBoxSize;
      }, set: function(e) {
        if (!this._boundingBoxSize || !this._boundingBoxSize.equals(e)) {
          this._boundingBoxSize = e;
          var i = this.getScene();
          i && i.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag);
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "depthStencilTexture", { get: function() {
        var e, i;
        return (i = (e = this._renderTarget) === null || e === void 0 ? void 0 : e._depthStencilTexture) !== null && i !== void 0 ? i : null;
      }, enumerable: !1, configurable: !0 }), t.prototype.createDepthStencilTexture = function(e, i, r, o, a) {
        var s;
        e === void 0 && (e = 0), i === void 0 && (i = !0), r === void 0 && (r = !1), o === void 0 && (o = 1), a === void 0 && (a = _.TEXTUREFORMAT_DEPTH32_FLOAT), (s = this._renderTarget) === null || s === void 0 || s.createDepthStencilTexture(e, i, r, o, a);
      }, t.prototype._releaseRenderPassId = function() {
        if (this._scene)
          for (var e = this._scene.getEngine(), i = 0; i < this._renderPassIds.length; ++i)
            e.releaseRenderPassId(this._renderPassIds[i]);
        this._renderPassIds = [];
      }, t.prototype._createRenderPassId = function() {
        this._releaseRenderPassId();
        for (var e = this._scene.getEngine(), i = this._isCubeData ? 6 : this.getRenderLayers() || 1, r = 0; r < i; ++r)
          this._renderPassIds[r] = e.createRenderPassId("RenderTargetTexture - ".concat(this.name, "#").concat(r));
      }, t.prototype._processSizeParameter = function(e, i) {
        if (i === void 0 && (i = !0), e.ratio) {
          this._sizeRatio = e.ratio;
          var r = this._getEngine();
          this._size = { width: this._bestReflectionRenderTargetDimension(r.getRenderWidth(), this._sizeRatio), height: this._bestReflectionRenderTargetDimension(r.getRenderHeight(), this._sizeRatio) };
        } else
          this._size = e;
        i && this._createRenderPassId();
      }, Object.defineProperty(t.prototype, "samples", { get: function() {
        var e, i;
        return (i = (e = this._renderTarget) === null || e === void 0 ? void 0 : e.samples) !== null && i !== void 0 ? i : this._samples;
      }, set: function(e) {
        this._renderTarget && (this._samples = this._renderTarget.setSamples(e));
      }, enumerable: !1, configurable: !0 }), t.prototype.resetRefreshCounter = function() {
        this._currentRefreshId = -1;
      }, Object.defineProperty(t.prototype, "refreshRate", { get: function() {
        return this._refreshRate;
      }, set: function(e) {
        this._refreshRate = e, this.resetRefreshCounter();
      }, enumerable: !1, configurable: !0 }), t.prototype.addPostProcess = function(e) {
        if (!this._postProcessManager) {
          var i = this.getScene();
          if (!i)
            return;
          this._postProcessManager = new nc(i), this._postProcesses = new Array();
        }
        this._postProcesses.push(e), this._postProcesses[0].autoClear = !1;
      }, t.prototype.clearPostProcesses = function(e) {
        if (e === void 0 && (e = !1), this._postProcesses) {
          if (e)
            for (var i = 0, r = this._postProcesses; i < r.length; i++)
              r[i].dispose();
          this._postProcesses = [];
        }
      }, t.prototype.removePostProcess = function(e) {
        if (this._postProcesses) {
          var i = this._postProcesses.indexOf(e);
          i !== -1 && (this._postProcesses.splice(i, 1), this._postProcesses.length > 0 && (this._postProcesses[0].autoClear = !1));
        }
      }, t.prototype._shouldRender = function() {
        return this._currentRefreshId === -1 || this.refreshRate === this._currentRefreshId ? (this._currentRefreshId = 1, !0) : (this._currentRefreshId++, !1);
      }, t.prototype.getRenderSize = function() {
        return this.getRenderWidth();
      }, t.prototype.getRenderWidth = function() {
        return this._size.width ? this._size.width : this._size;
      }, t.prototype.getRenderHeight = function() {
        return this._size.width ? this._size.height : this._size;
      }, t.prototype.getRenderLayers = function() {
        return this._size.layers || 0;
      }, t.prototype.disableRescaling = function() {
        this._canRescale = !1;
      }, Object.defineProperty(t.prototype, "canRescale", { get: function() {
        return this._canRescale;
      }, enumerable: !1, configurable: !0 }), t.prototype.scale = function(e) {
        var i = Math.max(1, this.getRenderSize() * e);
        this.resize(i);
      }, t.prototype.getReflectionTextureMatrix = function() {
        return this.isCube ? this._textureMatrix : n.prototype.getReflectionTextureMatrix.call(this);
      }, t.prototype.resize = function(e) {
        var i, r = this.isCube;
        (i = this._renderTarget) === null || i === void 0 || i.dispose(), this._renderTarget = null;
        var o = this.getScene();
        o && (this._processSizeParameter(e, !1), this._renderTarget = r ? o.getEngine().createRenderTargetCubeTexture(this.getRenderSize(), this._renderTargetOptions) : o.getEngine().createRenderTargetTexture(this._size, this._renderTargetOptions), this._texture = this._renderTarget.texture, this._renderTargetOptions.samples !== void 0 && (this.samples = this._renderTargetOptions.samples), this.onResizeObservable.hasObservers() && this.onResizeObservable.notifyObservers(this));
      }, t.prototype.render = function(e, i) {
        e === void 0 && (e = !1), i === void 0 && (i = !1), this._render(e, i);
      }, t.prototype.isReadyForRendering = function() {
        return this._render(!1, !1, !0);
      }, t.prototype._render = function(e, i, r) {
        var o;
        e === void 0 && (e = !1), i === void 0 && (i = !1), r === void 0 && (r = !1);
        var a = this.getScene();
        if (!a)
          return r;
        var s = a.getEngine();
        if (this.useCameraPostProcesses !== void 0 && (e = this.useCameraPostProcesses), this._waitingRenderList) {
          this.renderList = [];
          for (var l = 0; l < this._waitingRenderList.length; l++) {
            var c = this._waitingRenderList[l];
            (d = a.getMeshById(c)) && this.renderList.push(d);
          }
          this._waitingRenderList = void 0;
        }
        if (this.renderListPredicate) {
          this.renderList ? this.renderList.length = 0 : this.renderList = [];
          var u = this.getScene();
          if (!u)
            return r;
          var h = u.meshes;
          for (l = 0; l < h.length; l++) {
            var d = h[l];
            this.renderListPredicate(d) && this.renderList.push(d);
          }
        }
        var p = s.currentRenderPassId;
        this.onBeforeBindObservable.notifyObservers(this);
        var f = (o = this.activeCamera) !== null && o !== void 0 ? o : a.activeCamera, m = a.activeCamera;
        f && (f !== a.activeCamera && (a.setTransformMatrix(f.getViewMatrix(), f.getProjectionMatrix(!0)), a.activeCamera = f), s.setViewport(f.rigParent ? f.rigParent.viewport : f.viewport, this.getRenderWidth(), this.getRenderHeight())), this._defaultRenderListPrepared = !1;
        var g = r;
        if (r) {
          a.getViewMatrix() || a.updateTransformMatrix();
          var y = this.is2DArray ? this.getRenderLayers() : this.isCube ? 6 : 1;
          for (A = 0; A < y && g; A++) {
            var b = null, T = this.renderList ? this.renderList : a.getActiveMeshes().data, S = this.renderList ? this.renderList.length : a.getActiveMeshes().length;
            s.currentRenderPassId = this._renderPassIds[A], this.onBeforeRenderObservable.notifyObservers(A), this.getCustomRenderList && (b = this.getCustomRenderList(A, T, S)), b || (b = T), this._doNotChangeAspectRatio || a.updateTransformMatrix(!0);
            for (var E = 0; E < b.length && g; ++E)
              if ((d = b[E]).isEnabled() && !d.isBlocked && d.isVisible && d.subMeshes) {
                if (this.customIsReadyFunction) {
                  if (!this.customIsReadyFunction(d, this.refreshRate, r)) {
                    g = !1;
                    continue;
                  }
                } else if (!d.isReady(!0)) {
                  g = !1;
                  continue;
                }
              }
            this.onAfterRenderObservable.notifyObservers(A), (this.is2DArray || this.isCube) && (a.incrementRenderId(), a.resetCachedMaterial());
          }
        } else if (this.is2DArray && !this.isMulti)
          for (var A = 0; A < this.getRenderLayers(); A++)
            this._renderToTarget(0, e, i, A, f), a.incrementRenderId(), a.resetCachedMaterial();
        else if (this.isCube && !this.isMulti)
          for (var R = 0; R < 6; R++)
            this._renderToTarget(R, e, i, void 0, f), a.incrementRenderId(), a.resetCachedMaterial();
        else
          this._renderToTarget(0, e, i, void 0, f);
        return this.onAfterUnbindObservable.notifyObservers(this), s.currentRenderPassId = p, m && (a.activeCamera = m, (a.getEngine().scenes.length > 1 || this.activeCamera && this.activeCamera !== a.activeCamera) && a.setTransformMatrix(a.activeCamera.getViewMatrix(), a.activeCamera.getProjectionMatrix(!0)), s.setViewport(a.activeCamera.viewport)), a.resetCachedMaterial(), g;
      }, t.prototype._bestReflectionRenderTargetDimension = function(e, i) {
        var r = e * i, o = ve.NearestPOT(r + 16384 / (128 + r));
        return Math.min(ve.FloorPOT(e), o);
      }, t.prototype._prepareRenderingManager = function(e, i, r, o) {
        var a = this.getScene();
        if (a) {
          this._renderingManager.reset();
          for (var s = a.getRenderId(), l = 0; l < i; l++) {
            var c = e[l];
            if (c && !c.isBlocked) {
              if (this.customIsReadyFunction) {
                if (!this.customIsReadyFunction(c, this.refreshRate, !1)) {
                  this.resetRefreshCounter();
                  continue;
                }
              } else if (!c.isReady(this.refreshRate === 0)) {
                this.resetRefreshCounter();
                continue;
              }
              if (!c._internalAbstractMeshDataInfo._currentLODIsUpToDate && a.activeCamera && (c._internalAbstractMeshDataInfo._currentLOD = a.customLODSelector ? a.customLODSelector(c, this.activeCamera || a.activeCamera) : c.getLOD(this.activeCamera || a.activeCamera), c._internalAbstractMeshDataInfo._currentLODIsUpToDate = !0), !c._internalAbstractMeshDataInfo._currentLOD)
                continue;
              var u = c._internalAbstractMeshDataInfo._currentLOD;
              u._preActivateForIntermediateRendering(s);
              var h;
              if (h = !(!o || !r) && (c.layerMask & r.layerMask) == 0, c.isEnabled() && c.isVisible && c.subMeshes && !h && (u !== c && u._activate(s, !0), c._activate(s, !0) && c.subMeshes.length)) {
                c.isAnInstance ? c._internalAbstractMeshDataInfo._actAsRegularMesh && (u = c) : u._internalAbstractMeshDataInfo._onlyForInstancesIntermediate = !1, u._internalAbstractMeshDataInfo._isActiveIntermediate = !0;
                for (var d = 0; d < u.subMeshes.length; d++) {
                  var p = u.subMeshes[d];
                  this._renderingManager.dispatch(p, u);
                }
              }
            }
          }
          for (var f = 0; f < a.particleSystems.length; f++) {
            var m = a.particleSystems[f], g = m.emitter;
            m.isStarted() && g && (!g.position || g.isEnabled()) && this._renderingManager.dispatchParticles(m);
          }
        }
      }, t.prototype._bindFrameBuffer = function(e, i) {
        e === void 0 && (e = 0), i === void 0 && (i = 0);
        var r = this.getScene();
        if (r) {
          var o = r.getEngine();
          this._renderTarget && o.bindFramebuffer(this._renderTarget, this.isCube ? e : void 0, void 0, void 0, this.ignoreCameraViewport, 0, i);
        }
      }, t.prototype._unbindFrameBuffer = function(e, i) {
        var r = this;
        this._renderTarget && e.unBindFramebuffer(this._renderTarget, this.isCube, function() {
          r.onAfterRenderObservable.notifyObservers(i);
        });
      }, t.prototype._prepareFrame = function(e, i, r, o) {
        this._postProcessManager ? this._prePassEnabled || this._postProcessManager._prepareFrame(this._texture, this._postProcesses) : o && e.postProcessManager._prepareFrame(this._texture) || this._bindFrameBuffer(i, r);
      }, t.prototype._renderToTarget = function(e, i, r, o, a) {
        var s, l, c, u, h, d;
        o === void 0 && (o = 0), a === void 0 && (a = null);
        var p = this.getScene();
        if (p) {
          var f = p.getEngine();
          if ((s = f._debugPushGroup) === null || s === void 0 || s.call(f, "render to face #".concat(e, " layer #").concat(o), 1), this._prepareFrame(p, e, o, i), this.is2DArray ? (f.currentRenderPassId = this._renderPassIds[o], this.onBeforeRenderObservable.notifyObservers(o)) : (f.currentRenderPassId = this._renderPassIds[e], this.onBeforeRenderObservable.notifyObservers(e)), f.snapshotRendering && f.snapshotRenderingMode === _.SNAPSHOTRENDERING_FAST)
            this.onClearObservable.hasObservers() ? this.onClearObservable.notifyObservers(f) : this.skipInitialClear || f.clear(this.clearColor || p.clearColor, !0, !0, !0);
          else {
            var m = null, g = this.renderList ? this.renderList : p.getActiveMeshes().data, y = this.renderList ? this.renderList.length : p.getActiveMeshes().length;
            this.getCustomRenderList && (m = this.getCustomRenderList(this.is2DArray ? o : e, g, y)), m ? this._prepareRenderingManager(m, m.length, a, this.forceLayerMaskCheck) : (this._defaultRenderListPrepared || (this._prepareRenderingManager(g, y, a, !this.renderList || this.forceLayerMaskCheck), this._defaultRenderListPrepared = !0), m = g);
            for (var b = 0, T = p._beforeRenderTargetClearStage; b < T.length; b++)
              T[b].action(this, e, o);
            this.onClearObservable.hasObservers() ? this.onClearObservable.notifyObservers(f) : this.skipInitialClear || f.clear(this.clearColor || p.clearColor, !0, !0, !0), this._doNotChangeAspectRatio || p.updateTransformMatrix(!0);
            for (var S = 0, E = p._beforeRenderTargetDrawStage; S < E.length; S++)
              E[S].action(this, e, o);
            this._renderingManager.render(this.customRenderFunction, m, this.renderParticles, this.renderSprites);
            for (var A = 0, R = p._afterRenderTargetDrawStage; A < R.length; A++)
              R[A].action(this, e, o);
            var C = (c = (l = this._texture) === null || l === void 0 ? void 0 : l.generateMipMaps) !== null && c !== void 0 && c;
            this._texture && (this._texture.generateMipMaps = !1), this._postProcessManager ? this._postProcessManager._finalizeFrame(!1, (u = this._renderTarget) !== null && u !== void 0 ? u : void 0, e, this._postProcesses, this.ignoreCameraViewport) : i && p.postProcessManager._finalizeFrame(!1, (h = this._renderTarget) !== null && h !== void 0 ? h : void 0, e);
            for (var L = 0, I = p._afterRenderTargetPostProcessStage; L < I.length; L++)
              I[L].action(this, e, o);
            this._texture && (this._texture.generateMipMaps = C), this._doNotChangeAspectRatio || p.updateTransformMatrix(!0), r && la.DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), f);
          }
          this._unbindFrameBuffer(f, e), this._texture && this.isCube && e === 5 && f.generateMipMapsForCubemap(this._texture), (d = f._debugPopGroup) === null || d === void 0 || d.call(f, 1);
        }
      }, t.prototype.setRenderingOrder = function(e, i, r, o) {
        i === void 0 && (i = null), r === void 0 && (r = null), o === void 0 && (o = null), this._renderingManager.setRenderingOrder(e, i, r, o);
      }, t.prototype.setRenderingAutoClearDepthStencil = function(e, i) {
        this._renderingManager.setRenderingAutoClearDepthStencil(e, i), this._renderingManager._useSceneAutoClearSetup = !1;
      }, t.prototype.clone = function() {
        var e = this.getSize(), i = new t(this.name, e, this.getScene(), this._renderTargetOptions.generateMipMaps, this._doNotChangeAspectRatio, this._renderTargetOptions.type, this.isCube, this._renderTargetOptions.samplingMode, this._renderTargetOptions.generateDepthBuffer, this._renderTargetOptions.generateStencilBuffer, void 0, this._renderTargetOptions.format, void 0, this._renderTargetOptions.samples);
        return i.hasAlpha = this.hasAlpha, i.level = this.level, i.coordinatesMode = this.coordinatesMode, this.renderList && (i.renderList = this.renderList.slice(0)), i;
      }, t.prototype.serialize = function() {
        if (!this.name)
          return null;
        var e = n.prototype.serialize.call(this);
        if (e.renderTargetSize = this.getRenderSize(), e.renderList = [], this.renderList)
          for (var i = 0; i < this.renderList.length; i++)
            e.renderList.push(this.renderList[i].id);
        return e;
      }, t.prototype.disposeFramebufferObjects = function() {
        var e;
        (e = this._renderTarget) === null || e === void 0 || e.dispose(!0);
      }, t.prototype.releaseInternalTexture = function() {
        var e;
        (e = this._renderTarget) === null || e === void 0 || e.releaseTextures(), this._texture = null;
      }, t.prototype.dispose = function() {
        var e;
        this.onResizeObservable.clear(), this.onClearObservable.clear(), this.onAfterRenderObservable.clear(), this.onAfterUnbindObservable.clear(), this.onBeforeBindObservable.clear(), this.onBeforeRenderObservable.clear(), this._postProcessManager && (this._postProcessManager.dispose(), this._postProcessManager = null), this._prePassRenderTarget && this._prePassRenderTarget.dispose(), this._releaseRenderPassId(), this.clearPostProcesses(!0), this._resizeObserver && (this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver), this._resizeObserver = null), this.renderList = null;
        var i = this.getScene();
        if (i) {
          var r = i.customRenderTargets.indexOf(this);
          r >= 0 && i.customRenderTargets.splice(r, 1);
          for (var o = 0, a = i.cameras; o < a.length; o++) {
            var s = a[o];
            (r = s.customRenderTargets.indexOf(this)) >= 0 && s.customRenderTargets.splice(r, 1);
          }
          (e = this._renderTarget) === null || e === void 0 || e.dispose(), this._renderTarget = null, this._texture = null, n.prototype.dispose.call(this);
        }
      }, t.prototype._rebuild = function() {
        this.refreshRate === t.REFRESHRATE_RENDER_ONCE && (this.refreshRate = t.REFRESHRATE_RENDER_ONCE), this._postProcessManager && this._postProcessManager._rebuild();
      }, t.prototype.freeRenderingGroups = function() {
        this._renderingManager && this._renderingManager.freeRenderingGroups();
      }, t.prototype.getViewCount = function() {
        return 1;
      }, t.REFRESHRATE_RENDER_ONCE = 0, t.REFRESHRATE_RENDER_ONEVERYFRAME = 1, t.REFRESHRATE_RENDER_ONEVERYTWOFRAMES = 2, t;
    }(ae);
    ae._CreateRenderTargetTexture = function(n, t, e, i, r) {
      return new Mi(n, t, e, i);
    };
    var Bg = function() {
      function n(t) {
        this.name = we.NAME_PROCEDURALTEXTURE, this.scene = t, this.scene.proceduralTextures = [];
      }
      return n.prototype.register = function() {
        this.scene._beforeClearStage.registerStep(we.STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear);
      }, n.prototype.rebuild = function() {
      }, n.prototype.dispose = function() {
      }, n.prototype._beforeClear = function() {
        if (this.scene.proceduralTexturesEnabled) {
          de.StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
          for (var t = 0; t < this.scene.proceduralTextures.length; t++) {
            var e = this.scene.proceduralTextures[t];
            e._shouldRender() && e.render();
          }
          de.EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
        }
      }, n;
    }();
    re.ShadersStore.proceduralVertexShader = `attribute vec2 position;varying vec2 vPosition;varying vec2 vUV;const vec2 madd=vec2(0.5,0.5);
#define CUSTOM_VERTEX_DEFINITIONS
void main(void) {
#define CUSTOM_VERTEX_MAIN_BEGIN
vPosition=position;vUV=position*madd+madd;gl_Position=vec4(position,0.0,1.0);
#define CUSTOM_VERTEX_MAIN_END
}`;
    var Hi, mc = function(n) {
      function t(e, i, r, o, a, s, l, c) {
        a === void 0 && (a = null), s === void 0 && (s = !0), l === void 0 && (l = !1), c === void 0 && (c = _.TEXTURETYPE_UNSIGNED_INT);
        var u = n.call(this, null, o, !s) || this;
        u.isEnabled = !0, u.autoClear = !0, u.onGeneratedObservable = new H(), u.onBeforeGenerationObservable = new H(), u.nodeMaterialSource = null, u._textures = {}, u._currentRefreshId = -1, u._frameId = -1, u._refreshRate = 1, u._vertexBuffers = {}, u._uniforms = new Array(), u._samplers = new Array(), u._floats = {}, u._ints = {}, u._floatsArrays = {}, u._colors3 = {}, u._colors4 = {}, u._vectors2 = {}, u._vectors3 = {}, u._matrices = {}, u._fallbackTextureUsed = !1, u._cachedDefines = null, u._contentUpdateId = -1, u._rtWrapper = null;
        var h = (o = u.getScene() || Me.LastCreatedScene)._getComponent(we.NAME_PROCEDURALTEXTURE);
        h || (h = new Bg(o), o._addComponent(h)), o.proceduralTextures.push(u), u._fullEngine = o.getEngine(), u.name = e, u.isRenderTarget = !0, u._size = i, u._textureType = c, u._generateMipMaps = s, u._drawWrapper = new Ei(u._fullEngine), u.setFragment(r), u._fallbackTexture = a;
        var d = u._createRtWrapper(l, i, s, c);
        u._texture = d.texture;
        var p = [];
        return p.push(1, 1), p.push(-1, 1), p.push(-1, -1), p.push(1, -1), u._vertexBuffers[P.PositionKind] = new P(u._fullEngine, p, P.PositionKind, !1, !1, 2), u._createIndexBuffer(), u;
      }
      return D(t, n), t.prototype._createRtWrapper = function(e, i, r, o) {
        return e ? (this._rtWrapper = this._fullEngine.createRenderTargetCubeTexture(i, { generateMipMaps: r, generateDepthBuffer: !1, generateStencilBuffer: !1, type: o }), this.setFloat("face", 0)) : this._rtWrapper = this._fullEngine.createRenderTargetTexture(i, { generateMipMaps: r, generateDepthBuffer: !1, generateStencilBuffer: !1, type: o }), this._rtWrapper;
      }, t.prototype.getEffect = function() {
        return this._drawWrapper.effect;
      }, t.prototype._setEffect = function(e) {
        this._drawWrapper.effect = e;
      }, t.prototype.getContent = function() {
        var e = this;
        return this._contentData && this._frameId === this._contentUpdateId || (this._contentData ? this._contentData.then(function(i) {
          e._contentData = e.readPixels(0, 0, i), e._contentUpdateId = e._frameId;
        }) : (this._contentData = this.readPixels(0, 0), this._contentUpdateId = this._frameId)), this._contentData;
      }, t.prototype._createIndexBuffer = function() {
        var e = this._fullEngine, i = [];
        i.push(0), i.push(1), i.push(2), i.push(0), i.push(2), i.push(3), this._indexBuffer = e.createIndexBuffer(i);
      }, t.prototype._rebuild = function() {
        var e = this._vertexBuffers[P.PositionKind];
        e && e._rebuild(), this._createIndexBuffer(), this.refreshRate === Mi.REFRESHRATE_RENDER_ONCE && (this.refreshRate = Mi.REFRESHRATE_RENDER_ONCE);
      }, t.prototype.reset = function() {
        var e;
        (e = this._drawWrapper.effect) === null || e === void 0 || e.dispose(), this._drawWrapper.effect = null, this._cachedDefines = null;
      }, t.prototype._getDefines = function() {
        return "";
      }, t.prototype.isReady = function() {
        var e = this, i = this._fullEngine;
        if (this.nodeMaterialSource)
          return this._drawWrapper.effect.isReady();
        if (!this._fragment)
          return !1;
        if (this._fallbackTextureUsed)
          return !0;
        if (!this._texture)
          return !1;
        var r = this._getDefines();
        if (this._drawWrapper.effect && r === this._cachedDefines && this._drawWrapper.effect.isReady())
          return !0;
        var o = { vertex: "procedural", fragmentElement: this._fragment.fragmentElement, fragmentSource: this._fragment.fragmentSource, fragment: typeof this._fragment == "string" ? this._fragment : void 0 };
        return this._cachedDefines !== r && (this._cachedDefines = r, this._drawWrapper.effect = i.createEffect(o, [P.PositionKind], this._uniforms, this._samplers, r, void 0, void 0, function() {
          var a;
          (a = e._rtWrapper) === null || a === void 0 || a.dispose(), e._rtWrapper = e._texture = null, e._fallbackTexture && (e._texture = e._fallbackTexture._texture, e._texture && e._texture.incrementReferences()), e._fallbackTextureUsed = !0;
        })), this._drawWrapper.effect.isReady();
      }, t.prototype.resetRefreshCounter = function() {
        this._currentRefreshId = -1;
      }, t.prototype.setFragment = function(e) {
        this._fragment = e;
      }, Object.defineProperty(t.prototype, "refreshRate", { get: function() {
        return this._refreshRate;
      }, set: function(e) {
        this._refreshRate = e, this.resetRefreshCounter();
      }, enumerable: !1, configurable: !0 }), t.prototype._shouldRender = function() {
        return this.isEnabled && this.isReady() && this._texture ? !this._fallbackTextureUsed && (this._currentRefreshId === -1 || this.refreshRate === this._currentRefreshId ? (this._currentRefreshId = 1, this._frameId++, !0) : (this._currentRefreshId++, !1)) : (this._texture && (this._texture.isReady = !1), !1);
      }, t.prototype.getRenderSize = function() {
        return this._size;
      }, t.prototype.resize = function(e, i) {
        if (!this._fallbackTextureUsed && this._rtWrapper && this._texture) {
          var r = this._texture.isCube;
          this._rtWrapper.dispose();
          var o = this._createRtWrapper(r, e, i, this._textureType);
          this._texture = o.texture, this._size = e, this._generateMipMaps = i;
        }
      }, t.prototype._checkUniform = function(e) {
        this._uniforms.indexOf(e) === -1 && this._uniforms.push(e);
      }, t.prototype.setTexture = function(e, i) {
        return this._samplers.indexOf(e) === -1 && this._samplers.push(e), this._textures[e] = i, this;
      }, t.prototype.setFloat = function(e, i) {
        return this._checkUniform(e), this._floats[e] = i, this;
      }, t.prototype.setInt = function(e, i) {
        return this._checkUniform(e), this._ints[e] = i, this;
      }, t.prototype.setFloats = function(e, i) {
        return this._checkUniform(e), this._floatsArrays[e] = i, this;
      }, t.prototype.setColor3 = function(e, i) {
        return this._checkUniform(e), this._colors3[e] = i, this;
      }, t.prototype.setColor4 = function(e, i) {
        return this._checkUniform(e), this._colors4[e] = i, this;
      }, t.prototype.setVector2 = function(e, i) {
        return this._checkUniform(e), this._vectors2[e] = i, this;
      }, t.prototype.setVector3 = function(e, i) {
        return this._checkUniform(e), this._vectors3[e] = i, this;
      }, t.prototype.setMatrix = function(e, i) {
        return this._checkUniform(e), this._matrices[e] = i, this;
      }, t.prototype.render = function(e) {
        var i, r, o = this.getScene();
        if (o) {
          var a = this._fullEngine;
          if (a.enableEffect(this._drawWrapper), this.onBeforeGenerationObservable.notifyObservers(this), a.setState(!1), !this.nodeMaterialSource) {
            for (var s in this._textures)
              this._drawWrapper.effect.setTexture(s, this._textures[s]);
            for (var l in this._ints)
              this._drawWrapper.effect.setInt(l, this._ints[l]);
            for (var c in this._floats)
              this._drawWrapper.effect.setFloat(c, this._floats[c]);
            for (var u in this._floatsArrays)
              this._drawWrapper.effect.setArray(u, this._floatsArrays[u]);
            for (var h in this._colors3)
              this._drawWrapper.effect.setColor3(h, this._colors3[h]);
            for (var d in this._colors4) {
              var p = this._colors4[d];
              this._drawWrapper.effect.setFloat4(d, p.r, p.g, p.b, p.a);
            }
            for (var f in this._vectors2)
              this._drawWrapper.effect.setVector2(f, this._vectors2[f]);
            for (var m in this._vectors3)
              this._drawWrapper.effect.setVector3(m, this._vectors3[m]);
            for (var g in this._matrices)
              this._drawWrapper.effect.setMatrix(g, this._matrices[g]);
          }
          if (this._texture && this._rtWrapper) {
            (i = a._debugPushGroup) === null || i === void 0 || i.call(a, "procedural texture generation for ".concat(this.name), 1);
            var y = a.currentViewport;
            if (this.isCube)
              for (var b = 0; b < 6; b++)
                a.bindFramebuffer(this._rtWrapper, b, void 0, void 0, !0), a.bindBuffers(this._vertexBuffers, this._indexBuffer, this._drawWrapper.effect), this._drawWrapper.effect.setFloat("face", b), this.autoClear && a.clear(o.clearColor, !0, !1, !1), a.drawElementsType(Et.TriangleFillMode, 0, 6);
            else
              a.bindFramebuffer(this._rtWrapper, 0, void 0, void 0, !0), a.bindBuffers(this._vertexBuffers, this._indexBuffer, this._drawWrapper.effect), this.autoClear && a.clear(o.clearColor, !0, !1, !1), a.drawElementsType(Et.TriangleFillMode, 0, 6);
            a.unBindFramebuffer(this._rtWrapper, this.isCube), y && a.setViewport(y), this.isCube && a.generateMipMapsForCubemap(this._texture), (r = a._debugPopGroup) === null || r === void 0 || r.call(a, 1), this.onGenerated && this.onGenerated(), this.onGeneratedObservable.notifyObservers(this);
          }
        }
      }, t.prototype.clone = function() {
        var e = this.getSize(), i = new t(this.name, e.width, this._fragment, this.getScene(), this._fallbackTexture, this._generateMipMaps);
        return i.hasAlpha = this.hasAlpha, i.level = this.level, i.coordinatesMode = this.coordinatesMode, i;
      }, t.prototype.dispose = function() {
        var e = this.getScene();
        if (e) {
          var i = e.proceduralTextures.indexOf(this);
          i >= 0 && e.proceduralTextures.splice(i, 1);
          var r = this._vertexBuffers[P.PositionKind];
          r && (r.dispose(), this._vertexBuffers[P.PositionKind] = null), this._indexBuffer && this._fullEngine._releaseBuffer(this._indexBuffer) && (this._indexBuffer = null), this.onGeneratedObservable.clear(), this.onBeforeGenerationObservable.clear(), n.prototype.dispose.call(this);
        }
      }, x([N()], t.prototype, "isEnabled", void 0), x([N()], t.prototype, "autoClear", void 0), x([N()], t.prototype, "_generateMipMaps", void 0), x([N()], t.prototype, "_size", void 0), x([N()], t.prototype, "refreshRate", null), t;
    }(ae);
    j("BABYLON.ProceduralTexture", mc), function(n) {
      n[n.Cos = 0] = "Cos", n[n.Sin = 1] = "Sin", n[n.Abs = 2] = "Abs", n[n.Exp = 3] = "Exp", n[n.Exp2 = 4] = "Exp2", n[n.Round = 5] = "Round", n[n.Floor = 6] = "Floor", n[n.Ceiling = 7] = "Ceiling", n[n.Sqrt = 8] = "Sqrt", n[n.Log = 9] = "Log", n[n.Tan = 10] = "Tan", n[n.ArcTan = 11] = "ArcTan", n[n.ArcCos = 12] = "ArcCos", n[n.ArcSin = 13] = "ArcSin", n[n.Fract = 14] = "Fract", n[n.Sign = 15] = "Sign", n[n.Radians = 16] = "Radians", n[n.Degrees = 17] = "Degrees";
    }(Hi || (Hi = {}));
    var zp = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.operation = Hi.Cos, i.registerInput("input", M.AutoDetect), i.registerOutput("output", M.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "TrigonometryBlock";
      }, Object.defineProperty(t.prototype, "input", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0], r = "";
        switch (this.operation) {
          case Hi.Cos:
            r = "cos";
            break;
          case Hi.Sin:
            r = "sin";
            break;
          case Hi.Abs:
            r = "abs";
            break;
          case Hi.Exp:
            r = "exp";
            break;
          case Hi.Exp2:
            r = "exp2";
            break;
          case Hi.Round:
            r = "round";
            break;
          case Hi.Floor:
            r = "floor";
            break;
          case Hi.Ceiling:
            r = "ceil";
            break;
          case Hi.Sqrt:
            r = "sqrt";
            break;
          case Hi.Log:
            r = "log";
            break;
          case Hi.Tan:
            r = "tan";
            break;
          case Hi.ArcTan:
            r = "atan";
            break;
          case Hi.ArcCos:
            r = "acos";
            break;
          case Hi.ArcSin:
            r = "asin";
            break;
          case Hi.Fract:
            r = "fract";
            break;
          case Hi.Sign:
            r = "sign";
            break;
          case Hi.Radians:
            r = "radians";
            break;
          case Hi.Degrees:
            r = "degrees";
        }
        return e.compilationString += this._declareOutput(i, e) + " = ".concat(r, "(").concat(this.input.associatedVariableName, `);
`), this;
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.operation = this.operation, e;
      }, t.prototype._deserialize = function(e, i, r) {
        n.prototype._deserialize.call(this, e, i, r), this.operation = e.operation;
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".operation = BABYLON.TrigonometryBlockOperations.").concat(Hi[this.operation], `;
`);
      }, t;
    }(We);
    j("BABYLON.TrigonometryBlock", zp);
    var Ug = { effect: null, subMesh: null }, gc = function(n) {
      function t() {
        var e = n.call(this) || this;
        return e.NORMAL = !1, e.TANGENT = !1, e.VERTEXCOLOR_NME = !1, e.UV1 = !1, e.UV2 = !1, e.UV3 = !1, e.UV4 = !1, e.UV5 = !1, e.UV6 = !1, e.PREPASS = !1, e.PREPASS_NORMAL = !1, e.PREPASS_NORMAL_INDEX = -1, e.PREPASS_POSITION = !1, e.PREPASS_POSITION_INDEX = -1, e.PREPASS_DEPTH = !1, e.PREPASS_DEPTH_INDEX = -1, e.SCENE_MRT_COUNT = 0, e.NUM_BONE_INFLUENCERS = 0, e.BonesPerMesh = 0, e.BONETEXTURE = !1, e.MORPHTARGETS = !1, e.MORPHTARGETS_NORMAL = !1, e.MORPHTARGETS_TANGENT = !1, e.MORPHTARGETS_UV = !1, e.NUM_MORPH_INFLUENCERS = 0, e.MORPHTARGETS_TEXTURE = !1, e.IMAGEPROCESSING = !1, e.VIGNETTE = !1, e.VIGNETTEBLENDMODEMULTIPLY = !1, e.VIGNETTEBLENDMODEOPAQUE = !1, e.TONEMAPPING = !1, e.TONEMAPPING_ACES = !1, e.CONTRAST = !1, e.EXPOSURE = !1, e.COLORCURVES = !1, e.COLORGRADING = !1, e.COLORGRADING3D = !1, e.SAMPLER3DGREENDEPTH = !1, e.SAMPLER3DBGRMAP = !1, e.DITHER = !1, e.IMAGEPROCESSINGPOSTPROCESS = !1, e.SKIPFINALCOLORCLAMP = !1, e.BUMPDIRECTUV = 0, e.CAMERA_ORTHOGRAPHIC = !1, e.CAMERA_PERSPECTIVE = !1, e.rebuild(), e;
      }
      return D(t, n), t.prototype.setValue = function(e, i, r) {
        r === void 0 && (r = !1), this[e] === void 0 && this._keys.push(e), r && this[e] !== i && this.markAsUnprocessed(), this[e] = i;
      }, t;
    }(jn), ka = function(n) {
      function t(e, i, r) {
        r === void 0 && (r = {});
        var o = n.call(this, e, i || Me.LastCreatedScene) || this;
        return o._buildId = t._BuildIdGenerator++, o._buildWasSuccessful = !1, o._cachedWorldViewMatrix = new B(), o._cachedWorldViewProjectionMatrix = new B(), o._optimizers = new Array(), o._animationFrame = -1, o.BJSNODEMATERIALEDITOR = o._getGlobalNodeMaterialEditor(), o.editorData = null, o.ignoreAlpha = !1, o.maxSimultaneousLights = 4, o.onBuildObservable = new H(), o._vertexOutputNodes = new Array(), o._fragmentOutputNodes = new Array(), o.attachedBlocks = [], o._mode = kn.Material, o.forceAlphaBlending = !1, o._options = je({ emitComments: !1 }, r), o._attachImageProcessingConfiguration(null), o;
      }
      return D(t, n), t._BlockIsTextureBlock = function(e) {
        return e.getClassName() === "TextureBlock" || e.getClassName() === "ReflectionTextureBaseBlock" || e.getClassName() === "RefractionBlock" || e.getClassName() === "CurrentScreenBlock" || e.getClassName() === "ParticleTextureBlock" || e.getClassName() === "ImageSourceBlock" || e.getClassName() === "TriPlanarBlock" || e.getClassName() === "BiPlanarBlock" || e.getClassName() === "PrePassTextureBlock";
      }, t.prototype._getGlobalNodeMaterialEditor = function() {
        return typeof NODEEDITOR < "u" ? NODEEDITOR : typeof BABYLON < "u" && BABYLON.NodeEditor !== void 0 ? BABYLON : void 0;
      }, Object.defineProperty(t.prototype, "options", { get: function() {
        return this._options;
      }, set: function(e) {
        this._options = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "imageProcessingConfiguration", { get: function() {
        return this._imageProcessingConfiguration;
      }, set: function(e) {
        this._attachImageProcessingConfiguration(e), this._markAllSubMeshesAsTexturesDirty();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "mode", { get: function() {
        return this._mode;
      }, set: function(e) {
        this._mode = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buildId", { get: function() {
        return this._buildId;
      }, set: function(e) {
        this._buildId = e;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "NodeMaterial";
      }, t.prototype._attachImageProcessingConfiguration = function(e) {
        var i = this;
        e !== this._imageProcessingConfiguration && (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver), this._imageProcessingConfiguration = e || this.getScene().imageProcessingConfiguration, this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function() {
          i._markAllSubMeshesAsImageProcessingDirty();
        })));
      }, t.prototype.getBlockByName = function(e) {
        for (var i = null, r = 0, o = this.attachedBlocks; r < o.length; r++) {
          var a = o[r];
          if (a.name === e) {
            if (i)
              return de.Warn("More than one block was found with the name `" + e + "`"), i;
            i = a;
          }
        }
        return i;
      }, t.prototype.getBlockByPredicate = function(e) {
        for (var i = 0, r = this.attachedBlocks; i < r.length; i++) {
          var o = r[i];
          if (e(o))
            return o;
        }
        return null;
      }, t.prototype.getInputBlockByPredicate = function(e) {
        for (var i = 0, r = this.attachedBlocks; i < r.length; i++) {
          var o = r[i];
          if (o.isInput && e(o))
            return o;
        }
        return null;
      }, t.prototype.getInputBlocks = function() {
        for (var e = [], i = 0, r = this.attachedBlocks; i < r.length; i++) {
          var o = r[i];
          o.isInput && e.push(o);
        }
        return e;
      }, t.prototype.registerOptimizer = function(e) {
        if (!(this._optimizers.indexOf(e) > -1))
          return this._optimizers.push(e), this;
      }, t.prototype.unregisterOptimizer = function(e) {
        var i = this._optimizers.indexOf(e);
        if (i !== -1)
          return this._optimizers.splice(i, 1), this;
      }, t.prototype.addOutputNode = function(e) {
        if (e.target === null)
          throw "This node is not meant to be an output node. You may want to explicitly set its target value.";
        return e.target & W.Vertex && this._addVertexOutputNode(e), e.target & W.Fragment && this._addFragmentOutputNode(e), this;
      }, t.prototype.removeOutputNode = function(e) {
        return e.target === null || (e.target & W.Vertex && this._removeVertexOutputNode(e), e.target & W.Fragment && this._removeFragmentOutputNode(e)), this;
      }, t.prototype._addVertexOutputNode = function(e) {
        if (this._vertexOutputNodes.indexOf(e) === -1)
          return e.target = W.Vertex, this._vertexOutputNodes.push(e), this;
      }, t.prototype._removeVertexOutputNode = function(e) {
        var i = this._vertexOutputNodes.indexOf(e);
        if (i !== -1)
          return this._vertexOutputNodes.splice(i, 1), this;
      }, t.prototype._addFragmentOutputNode = function(e) {
        if (this._fragmentOutputNodes.indexOf(e) === -1)
          return e.target = W.Fragment, this._fragmentOutputNodes.push(e), this;
      }, t.prototype._removeFragmentOutputNode = function(e) {
        var i = this._fragmentOutputNodes.indexOf(e);
        if (i !== -1)
          return this._fragmentOutputNodes.splice(i, 1), this;
      }, t.prototype.needAlphaBlending = function() {
        return !this.ignoreAlpha && (this.forceAlphaBlending || this.alpha < 1 || this._sharedData && this._sharedData.hints.needAlphaBlending);
      }, t.prototype.needAlphaTesting = function() {
        return this._sharedData && this._sharedData.hints.needAlphaTesting;
      }, t.prototype._processInitializeOnLink = function(e, i, r, o) {
        o === void 0 && (o = !0), (e.target === W.VertexAndFragment || i.target === W.Fragment && e.target === W.Vertex && e._preparationId !== this._buildId) && r.push(e), this._initializeBlock(e, i, r, o);
      }, t.prototype._initializeBlock = function(e, i, r, o) {
        if (o === void 0 && (o = !0), e.initialize(i), o && e.autoConfigure(this), e._preparationId = this._buildId, this.attachedBlocks.indexOf(e) === -1) {
          if (e.isUnique) {
            for (var a = e.getClassName(), s = 0, l = this.attachedBlocks; s < l.length; s++)
              if (l[s].getClassName() === a)
                throw "Cannot have multiple blocks of type ".concat(a, " in the same NodeMaterial");
          }
          this.attachedBlocks.push(e);
        }
        for (var c = 0, u = e.inputs; c < u.length; c++) {
          var h = u[c];
          h.associatedVariableName = "";
          var d = h.connectedPoint;
          if (d) {
            var p = d.ownerBlock;
            p !== e && this._processInitializeOnLink(p, i, r, o);
          }
        }
        if (e.isTeleportOut) {
          var f = e;
          f.entryPoint && this._processInitializeOnLink(f.entryPoint, i, r, o);
        }
        for (var m = 0, g = e.outputs; m < g.length; m++)
          g[m].associatedVariableName = "";
      }, t.prototype._resetDualBlocks = function(e, i) {
        e.target === W.VertexAndFragment && (e.buildId = i);
        for (var r = 0, o = e.inputs; r < o.length; r++) {
          var a = o[r].connectedPoint;
          if (a) {
            var s = a.ownerBlock;
            s !== e && this._resetDualBlocks(s, i);
          }
        }
        if (e.isTeleportOut) {
          var l = e;
          l.entryPoint && this._resetDualBlocks(l.entryPoint, i);
        }
      }, t.prototype.removeBlock = function(e) {
        var i = this.attachedBlocks.indexOf(e);
        i > -1 && this.attachedBlocks.splice(i, 1), e.isFinalMerger && this.removeOutputNode(e);
      }, t.prototype.build = function(e, i, r) {
        e === void 0 && (e = !1), i === void 0 && (i = !0), r === void 0 && (r = !1), this._vertexCompilationState || r || (r = !0), this._buildWasSuccessful = !1;
        var o = this.getScene().getEngine(), a = this._mode === kn.Particle;
        if (this._vertexOutputNodes.length === 0 && !a)
          throw "You must define at least one vertexOutputNode";
        if (this._fragmentOutputNodes.length === 0)
          throw "You must define at least one fragmentOutputNode";
        this._vertexCompilationState = new xR(), this._vertexCompilationState.supportUniformBuffers = o.supportsUniformBuffers, this._vertexCompilationState.target = W.Vertex, this._fragmentCompilationState = new xR(), this._fragmentCompilationState.supportUniformBuffers = o.supportsUniformBuffers, this._fragmentCompilationState.target = W.Fragment, this._sharedData = new U1(), this._sharedData.fragmentOutputNodes = this._fragmentOutputNodes, this._vertexCompilationState.sharedData = this._sharedData, this._fragmentCompilationState.sharedData = this._sharedData, this._sharedData.buildId = this._buildId, this._sharedData.emitComments = this._options.emitComments, this._sharedData.verbose = e, this._sharedData.scene = this.getScene(), this._sharedData.allowEmptyVertexProgram = a;
        for (var s = [], l = [], c = 0, u = this._vertexOutputNodes; c < u.length; c++) {
          var h = u[c];
          s.push(h), this._initializeBlock(h, this._vertexCompilationState, l, r);
        }
        for (var d = 0, p = this._fragmentOutputNodes; d < p.length; d++) {
          var f = p[d];
          l.push(f), this._initializeBlock(f, this._fragmentCompilationState, s, r);
        }
        this.optimize();
        for (var m = 0, g = s; m < g.length; m++)
          (h = g[m]).build(this._vertexCompilationState, s);
        this._fragmentCompilationState.uniforms = this._vertexCompilationState.uniforms.slice(0), this._fragmentCompilationState._uniformDeclaration = this._vertexCompilationState._uniformDeclaration, this._fragmentCompilationState._constantDeclaration = this._vertexCompilationState._constantDeclaration, this._fragmentCompilationState._vertexState = this._vertexCompilationState;
        for (var y = 0, b = l; y < b.length; y++)
          f = b[y], this._resetDualBlocks(f, this._buildId - 1);
        for (var T = 0, S = l; T < S.length; T++)
          (f = S[T]).build(this._fragmentCompilationState, l);
        this._vertexCompilationState.finalize(this._vertexCompilationState), this._fragmentCompilationState.finalize(this._fragmentCompilationState), i && (this._buildId = t._BuildIdGenerator++), this._sharedData.emitErrors(), e && (console.log("Vertex shader:"), console.log(this._vertexCompilationState.compilationString), console.log("Fragment shader:"), console.log(this._fragmentCompilationState.compilationString)), this._buildWasSuccessful = !0, this.onBuildObservable.notifyObservers(this);
        for (var E = 0, A = this.getScene().meshes; E < A.length; E++) {
          var R = A[E];
          if (R.subMeshes)
            for (var C = 0, L = R.subMeshes; C < L.length; C++) {
              var I = L[C];
              if (I.getMaterial() === this && I.materialDefines) {
                var O = I.materialDefines;
                O.markAllAsDirty(), O.reset();
              }
            }
        }
        this.prePassTextureInputs.length && this.getScene().enablePrePassRenderer();
        var w = this.getScene().prePassRenderer;
        w && w.markAsDirty();
      }, t.prototype.optimize = function() {
        for (var e = 0, i = this._optimizers; e < i.length; e++)
          i[e].optimize(this._vertexOutputNodes, this._fragmentOutputNodes);
      }, t.prototype._prepareDefinesForAttributes = function(e, i) {
        var r = i.NORMAL, o = i.TANGENT, a = i.VERTEXCOLOR_NME;
        i.NORMAL = e.isVerticesDataPresent(P.NormalKind), i.TANGENT = e.isVerticesDataPresent(P.TangentKind);
        var s = e.useVertexColors && e.isVerticesDataPresent(P.ColorKind);
        i.VERTEXCOLOR_NME = s;
        for (var l = !1, c = 1; c <= _.MAX_SUPPORTED_UV_SETS; ++c) {
          var u = i["UV" + c];
          i["UV" + c] = e.isVerticesDataPresent("uv".concat(c === 1 ? "" : c)), l = l || i["UV" + c] !== u;
        }
        var h = this.needAlphaBlendingForMesh(e) && this.getScene().useOrderIndependentTransparency;
        Se.PrepareDefinesForPrePass(this.getScene(), i, !h), (r !== i.NORMAL || o !== i.TANGENT || a !== i.VERTEXCOLOR_NME || l) && i.markAsAttributesDirty();
      }, Object.defineProperty(t.prototype, "isPrePassCapable", { get: function() {
        return !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "prePassTextureOutputs", { get: function() {
        var e = this.getBlockByPredicate(function(r) {
          return r.getClassName() === "PrePassOutputBlock";
        }), i = [_.PREPASS_COLOR_TEXTURE_TYPE];
        return e && (this.prePassTextureInputs.length || (e.viewDepth.isConnected && i.push(_.PREPASS_DEPTH_TEXTURE_TYPE), e.viewNormal.isConnected && i.push(_.PREPASS_NORMAL_TEXTURE_TYPE), e.worldPosition.isConnected && i.push(_.PREPASS_POSITION_TEXTURE_TYPE))), i;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "prePassTextureInputs", { get: function() {
        for (var e = this.getAllTextureBlocks().filter(function(s) {
          return s.getClassName() === "PrePassTextureBlock";
        }), i = [], r = 0, o = e; r < o.length; r++) {
          var a = o[r];
          a.position.isConnected && !i.includes(_.PREPASS_POSITION_TEXTURE_TYPE) && i.push(_.PREPASS_POSITION_TEXTURE_TYPE), a.depth.isConnected && !i.includes(_.PREPASS_DEPTH_TEXTURE_TYPE) && i.push(_.PREPASS_DEPTH_TEXTURE_TYPE), a.normal.isConnected && !i.includes(_.PREPASS_NORMAL_TEXTURE_TYPE) && i.push(_.PREPASS_NORMAL_TEXTURE_TYPE);
        }
        return i;
      }, enumerable: !1, configurable: !0 }), t.prototype.setPrePassRenderer = function(e) {
        var i = this.prePassTextureInputs.concat(this.prePassTextureOutputs);
        if (e && i.length > 1) {
          var r = e.getEffectConfiguration("nodeMaterial");
          r || (r = e.addEffectConfiguration({ enabled: !0, needsImageProcessing: !1, name: "nodeMaterial", texturesRequired: [] }));
          for (var o = 0, a = i; o < a.length; o++) {
            var s = a[o];
            r.texturesRequired.includes(s) || r.texturesRequired.push(s);
          }
          r.enabled = !0;
        }
        return i.length > 1;
      }, t.prototype.createPostProcess = function(e, i, r, o, a, s, l) {
        return i === void 0 && (i = 1), r === void 0 && (r = _.TEXTURE_NEAREST_SAMPLINGMODE), s === void 0 && (s = _.TEXTURETYPE_UNSIGNED_INT), l === void 0 && (l = _.TEXTUREFORMAT_RGBA), this.mode !== kn.PostProcess ? (console.log("Incompatible material mode"), null) : this._createEffectForPostProcess(null, e, i, r, o, a, s, l);
      }, t.prototype.createEffectForPostProcess = function(e) {
        this._createEffectForPostProcess(e);
      }, t.prototype._createEffectForPostProcess = function(e, i, r, o, a, s, l, c) {
        var u = this;
        r === void 0 && (r = 1), o === void 0 && (o = _.TEXTURE_NEAREST_SAMPLINGMODE), l === void 0 && (l = _.TEXTURETYPE_UNSIGNED_INT), c === void 0 && (c = _.TEXTUREFORMAT_RGBA);
        var h = this.name + this._buildId, d = new gc(), p = new Dt(h + "PostProcess", this.getScene()), f = this._buildId;
        return this._processDefines(p, d), Jt.RegisterShader(h, this._fragmentCompilationState._builtCompilationString, this._vertexCompilationState._builtCompilationString), e ? e.updateEffect(d.toString(), this._fragmentCompilationState.uniforms, this._fragmentCompilationState.samplers, { maxSimultaneousLights: this.maxSimultaneousLights }, void 0, void 0, h, h) : e = new nt(this.name + "PostProcess", h, this._fragmentCompilationState.uniforms, this._fragmentCompilationState.samplers, r, i, o, a, s, d.toString(), l, h, { maxSimultaneousLights: this.maxSimultaneousLights }, !1, c), e.nodeMaterialSource = this, e.onApplyObservable.add(function(m) {
          f !== u._buildId && (delete Jt.ShadersStore[h + "VertexShader"], delete Jt.ShadersStore[h + "PixelShader"], h = u.name + u._buildId, d.markAllAsDirty(), f = u._buildId), u._processDefines(p, d) && (Jt.RegisterShader(h, u._fragmentCompilationState._builtCompilationString, u._vertexCompilationState._builtCompilationString), ec.SetImmediate(function() {
            return e.updateEffect(d.toString(), u._fragmentCompilationState.uniforms, u._fragmentCompilationState.samplers, { maxSimultaneousLights: u.maxSimultaneousLights }, void 0, void 0, h, h);
          })), u._checkInternals(m);
        }), e;
      }, t.prototype.createProceduralTexture = function(e, i) {
        var r = this;
        if (this.mode !== kn.ProceduralTexture)
          return console.log("Incompatible material mode"), null;
        var o = this.name + this._buildId, a = new mc(o, e, null, i), s = new Dt(o + "Procedural", this.getScene());
        s.reservedDataStore = { hidden: !0 };
        var l = new gc(), c = this._processDefines(s, l);
        Jt.RegisterShader(o, this._fragmentCompilationState._builtCompilationString, this._vertexCompilationState._builtCompilationString);
        var u = this.getScene().getEngine().createEffect({ vertexElement: o, fragmentElement: o }, [P.PositionKind], this._fragmentCompilationState.uniforms, this._fragmentCompilationState.samplers, l.toString(), c == null ? void 0 : c.fallbacks, void 0);
        a.nodeMaterialSource = this, a._setEffect(u);
        var h = this._buildId;
        return a.onBeforeGenerationObservable.add(function() {
          h !== r._buildId && (delete Jt.ShadersStore[o + "VertexShader"], delete Jt.ShadersStore[o + "PixelShader"], o = r.name + r._buildId, l.markAllAsDirty(), h = r._buildId);
          var d = r._processDefines(s, l);
          d && (Jt.RegisterShader(o, r._fragmentCompilationState._builtCompilationString, r._vertexCompilationState._builtCompilationString), ec.SetImmediate(function() {
            u = r.getScene().getEngine().createEffect({ vertexElement: o, fragmentElement: o }, [P.PositionKind], r._fragmentCompilationState.uniforms, r._fragmentCompilationState.samplers, l.toString(), d == null ? void 0 : d.fallbacks, void 0), a._setEffect(u);
          })), r._checkInternals(u);
        }), a;
      }, t.prototype._createEffectForParticles = function(e, i, r, o, a, s, l, c) {
        var u = this;
        c === void 0 && (c = "");
        var h = this.name + this._buildId + "_" + i;
        s || (s = new gc()), l || (l = this.getScene().getMeshByName(this.name + "Particle")) || ((l = new Dt(this.name + "Particle", this.getScene())).reservedDataStore = { hidden: !0 });
        var d = this._buildId, p = [], f = c;
        if (!a) {
          var m = this._processDefines(l, s);
          Jt.RegisterShader(h, this._fragmentCompilationState._builtCompilationString), e.fillDefines(p, i), f = p.join(`
`), a = this.getScene().getEngine().createEffectForParticles(h, this._fragmentCompilationState.uniforms, this._fragmentCompilationState.samplers, s.toString() + `
` + f, m == null ? void 0 : m.fallbacks, r, o, e), e.setCustomEffect(a, i);
        }
        a.onBindObservable.add(function(g) {
          d !== u._buildId && (delete Jt.ShadersStore[h + "PixelShader"], h = u.name + u._buildId + "_" + i, s.markAllAsDirty(), d = u._buildId), p.length = 0, e.fillDefines(p, i);
          var y = p.join(`
`);
          y !== f && (s.markAllAsDirty(), f = y);
          var b = u._processDefines(l, s);
          if (b)
            return Jt.RegisterShader(h, u._fragmentCompilationState._builtCompilationString), g = u.getScene().getEngine().createEffectForParticles(h, u._fragmentCompilationState.uniforms, u._fragmentCompilationState.samplers, s.toString() + `
` + f, b == null ? void 0 : b.fallbacks, r, o, e), e.setCustomEffect(g, i), void u._createEffectForParticles(e, i, r, o, g, s, l, c);
          u._checkInternals(g);
        });
      }, t.prototype._checkInternals = function(e) {
        if (this._sharedData.animatedInputs) {
          var i = this.getScene(), r = i.getFrameId();
          if (this._animationFrame !== r) {
            for (var o = 0, a = this._sharedData.animatedInputs; o < a.length; o++)
              a[o].animate(i);
            this._animationFrame = r;
          }
        }
        for (var s = 0, l = this._sharedData.bindableBlocks; s < l.length; s++)
          l[s].bind(e, this);
        for (var c = 0, u = this._sharedData.inputBlocks; c < u.length; c++)
          u[c]._transmit(e, this.getScene(), this);
      }, t.prototype.createEffectForParticles = function(e, i, r) {
        this.mode === kn.Particle ? (this._createEffectForParticles(e, fc.BLENDMODE_ONEONE, i, r), this._createEffectForParticles(e, fc.BLENDMODE_MULTIPLY, i, r)) : console.log("Incompatible material mode");
      }, t.prototype.createAsShadowDepthWrapper = function(e) {
        this.mode === kn.Material ? e.shadowDepthWrapper = new BABYLON.ShadowDepthWrapper(this, this.getScene()) : console.log("Incompatible material mode");
      }, t.prototype._processDefines = function(e, i, r, o) {
        var a = this;
        r === void 0 && (r = !1);
        var s = null, l = this.getScene();
        if (Se.PrepareDefinesForCamera(l, i) && i.markAsMiscDirty(), this._sharedData.blocksWithDefines.forEach(function(f) {
          f.initializeDefines(e, a, i, r);
        }), this._sharedData.blocksWithDefines.forEach(function(f) {
          f.prepareDefines(e, a, i, r, o);
        }), i.isDirty) {
          var c = i._areLightsDisposed;
          i.markAsProcessed(), this._vertexCompilationState.compilationString = this._vertexCompilationState._builtCompilationString, this._fragmentCompilationState.compilationString = this._fragmentCompilationState._builtCompilationString, this._sharedData.repeatableContentBlocks.forEach(function(f) {
            f.replaceRepeatableContent(a._vertexCompilationState, a._fragmentCompilationState, e, i);
          });
          var u = [];
          this._sharedData.dynamicUniformBlocks.forEach(function(f) {
            f.updateUniformsAndSamples(a._vertexCompilationState, a, i, u);
          });
          var h = this._vertexCompilationState.uniforms;
          this._fragmentCompilationState.uniforms.forEach(function(f) {
            h.indexOf(f) === -1 && h.push(f);
          });
          var d = this._vertexCompilationState.samplers;
          this._fragmentCompilationState.samplers.forEach(function(f) {
            d.indexOf(f) === -1 && d.push(f);
          });
          var p = new Va();
          this._sharedData.blocksWithFallbacks.forEach(function(f) {
            f.provideFallbacks(e, p);
          }), s = { lightDisposed: c, uniformBuffers: u, mergedUniforms: h, mergedSamplers: d, fallbacks: p };
        }
        return s;
      }, t.prototype.isReadyForSubMesh = function(e, i, r) {
        var o = this;
        if (r === void 0 && (r = !1), !this._buildWasSuccessful)
          return !1;
        var a = this.getScene();
        if (this._sharedData.animatedInputs) {
          var s = a.getFrameId();
          if (this._animationFrame !== s) {
            for (var l = 0, c = this._sharedData.animatedInputs; l < c.length; l++)
              c[l].animate(a);
            this._animationFrame = s;
          }
        }
        if (i.effect && this.isFrozen && i.effect._wasPreviouslyReady && i.effect._wasPreviouslyUsingInstances === r)
          return !0;
        i.materialDefines || (i.materialDefines = new gc());
        var u = i.materialDefines;
        if (this._isReadyForSubMesh(i))
          return !0;
        var h = a.getEngine();
        if (this._prepareDefinesForAttributes(e, u), this._sharedData.blockingBlocks.some(function(g) {
          return !g.isReady(e, o, u, r);
        }))
          return !1;
        var d = this._processDefines(e, u, r, i);
        if (d) {
          var p = i.effect, f = u.toString(), m = h.createEffect({ vertex: "nodeMaterial" + this._buildId, fragment: "nodeMaterial" + this._buildId, vertexSource: this._vertexCompilationState.compilationString, fragmentSource: this._fragmentCompilationState.compilationString }, { attributes: this._vertexCompilationState.attributes, uniformsNames: d.mergedUniforms, uniformBuffersNames: d.uniformBuffers, samplers: d.mergedSamplers, defines: f, fallbacks: d.fallbacks, onCompiled: this.onCompiled, onError: this.onError, multiTarget: u.PREPASS, indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights, maxSimultaneousMorphTargets: u.NUM_MORPH_INFLUENCERS } }, h);
          if (m)
            if (this._onEffectCreatedObservable && (Ug.effect = m, Ug.subMesh = i, this._onEffectCreatedObservable.notifyObservers(Ug)), this.allowShaderHotSwapping && p && !m.isReady()) {
              if (m = p, u.markAsUnprocessed(), d.lightDisposed)
                return u._areLightsDisposed = !0, !1;
            } else
              a.resetCachedMaterial(), i.setEffect(m, u, this._materialContext);
        }
        return !(!i.effect || !i.effect.isReady() || (u._renderId = a.getRenderId(), i.effect._wasPreviouslyReady = !0, i.effect._wasPreviouslyUsingInstances = r, this._checkScenePerformancePriority(), 0));
      }, Object.defineProperty(t.prototype, "compiledShaders", { get: function() {
        return `// Vertex shader
`.concat(this._vertexCompilationState.compilationString, `

// Fragment shader
`).concat(this._fragmentCompilationState.compilationString);
      }, enumerable: !1, configurable: !0 }), t.prototype.bindOnlyWorldMatrix = function(e) {
        var i = this.getScene();
        if (this._activeEffect) {
          var r = this._sharedData.hints;
          r.needWorldViewMatrix && e.multiplyToRef(i.getViewMatrix(), this._cachedWorldViewMatrix), r.needWorldViewProjectionMatrix && e.multiplyToRef(i.getTransformMatrix(), this._cachedWorldViewProjectionMatrix);
          for (var o = 0, a = this._sharedData.inputBlocks; o < a.length; o++)
            a[o]._transmitWorld(this._activeEffect, e, this._cachedWorldViewMatrix, this._cachedWorldViewProjectionMatrix);
        }
      }, t.prototype.bindForSubMesh = function(e, i, r) {
        var o = this.getScene(), a = r.effect;
        if (a) {
          this._activeEffect = a, this.bindOnlyWorldMatrix(e);
          var s = this._mustRebind(o, a, i.visibility), l = this._sharedData;
          if (s) {
            for (var c = 0, u = l.bindableBlocks; c < u.length; c++)
              u[c].bind(a, this, i, r);
            for (var h = 0, d = l.forcedBindableBlocks; h < d.length; h++)
              d[h].bind(a, this, i, r);
            for (var p = 0, f = l.inputBlocks; p < f.length; p++)
              f[p]._transmit(a, o, this);
          } else if (!this.isFrozen)
            for (var m = 0, g = l.forcedBindableBlocks; m < g.length; m++)
              g[m].bind(a, this, i, r);
          this._afterBind(i, this._activeEffect);
        }
      }, t.prototype.getActiveTextures = function() {
        var e = n.prototype.getActiveTextures.call(this);
        return this._sharedData && e.push.apply(e, this._sharedData.textureBlocks.filter(function(i) {
          return i.texture;
        }).map(function(i) {
          return i.texture;
        })), e;
      }, t.prototype.getTextureBlocks = function() {
        return this._sharedData ? this._sharedData.textureBlocks : [];
      }, t.prototype.getAllTextureBlocks = function() {
        for (var e = [], i = 0, r = this.attachedBlocks; i < r.length; i++) {
          var o = r[i];
          t._BlockIsTextureBlock(o) && e.push(o);
        }
        return e;
      }, t.prototype.hasTexture = function(e) {
        if (n.prototype.hasTexture.call(this, e))
          return !0;
        if (!this._sharedData)
          return !1;
        for (var i = 0, r = this._sharedData.textureBlocks; i < r.length; i++)
          if (r[i].texture === e)
            return !0;
        return !1;
      }, t.prototype.dispose = function(e, i, r) {
        if (i)
          for (var o = 0, a = this.getTextureBlocks().filter(function(c) {
            return c.texture;
          }).map(function(c) {
            return c.texture;
          }); o < a.length; o++)
            a[o].dispose();
        for (var s = 0, l = this.attachedBlocks; s < l.length; s++)
          l[s].dispose();
        this.attachedBlocks.length = 0, this._sharedData = null, this._vertexCompilationState = null, this._fragmentCompilationState = null, this.onBuildObservable.clear(), this._imageProcessingObserver && (this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver), this._imageProcessingObserver = null), n.prototype.dispose.call(this, e, i, r);
      }, t.prototype._createNodeEditor = function(e) {
        var i = je({ nodeMaterial: this }, e);
        this.BJSNODEMATERIALEDITOR.NodeEditor.Show(i);
      }, t.prototype.edit = function(e) {
        var i = this;
        return new Promise(function(r) {
          if (i.BJSNODEMATERIALEDITOR = i.BJSNODEMATERIALEDITOR || i._getGlobalNodeMaterialEditor(), i.BJSNODEMATERIALEDITOR === void 0) {
            var o = e && e.editorURL ? e.editorURL : t.EditorURL;
            de.LoadBabylonScript(o, function() {
              i.BJSNODEMATERIALEDITOR = i.BJSNODEMATERIALEDITOR || i._getGlobalNodeMaterialEditor(), i._createNodeEditor(e == null ? void 0 : e.nodeEditorConfig), r();
            });
          } else
            i._createNodeEditor(e == null ? void 0 : e.nodeEditorConfig), r();
        });
      }, t.prototype.clear = function() {
        this._vertexOutputNodes.length = 0, this._fragmentOutputNodes.length = 0, this.attachedBlocks.length = 0;
      }, t.prototype.setToDefault = function() {
        this.clear(), this.editorData = null;
        var e = new vt("Position");
        e.setAsAttribute("position");
        var i = new vt("World");
        i.setAsSystemValue(Tt.World);
        var r = new $u("WorldPos");
        e.connectTo(r), i.connectTo(r);
        var o = new vt("ViewProjection");
        o.setAsSystemValue(Tt.ViewProjection);
        var a = new $u("WorldPos * ViewProjectionTransform");
        r.connectTo(a), o.connectTo(a);
        var s = new hc("VertexOutput");
        a.connectTo(s);
        var l = new vt("color");
        l.value = new Ie(0.8, 0.8, 0.8, 1);
        var c = new fl("FragmentOutput");
        l.connectTo(c), this.addOutputNode(s), this.addOutputNode(c), this._mode = kn.Material;
      }, t.prototype.setToDefaultPostProcess = function() {
        this.clear(), this.editorData = null;
        var e = new vt("Position");
        e.setAsAttribute("position2d");
        var i = new vt("Constant1");
        i.isConstant = !0, i.value = 1;
        var r = new pc("Position3D");
        e.connectTo(r), i.connectTo(r, { input: "w" });
        var o = new hc("VertexOutput");
        r.connectTo(o);
        var a = new vt("Scale");
        a.visibleInInspector = !0, a.value = new fe(1, 1);
        var s = new Lp("uv0");
        e.connectTo(s);
        var l = new eh("UV scale");
        s.connectTo(l), a.connectTo(l);
        var c = new Op("CurrentScreen");
        l.connectTo(c), c.texture = new ae("https://assets.babylonjs.com/nme/currentScreenPostProcess.png", this.getScene());
        var u = new fl("FragmentOutput");
        c.connectTo(u, { output: "rgba" }), this.addOutputNode(o), this.addOutputNode(u), this._mode = kn.PostProcess;
      }, t.prototype.setToDefaultProceduralTexture = function() {
        this.clear(), this.editorData = null;
        var e = new vt("Position");
        e.setAsAttribute("position2d");
        var i = new vt("Constant1");
        i.isConstant = !0, i.value = 1;
        var r = new pc("Position3D");
        e.connectTo(r), i.connectTo(r, { input: "w" });
        var o = new hc("VertexOutput");
        r.connectTo(o);
        var a = new vt("Time");
        a.value = 0, a.min = 0, a.max = 0, a.isBoolean = !1, a.matrixMode = 0, a.animationType = sa.Time, a.isConstant = !1;
        var s = new vt("Color3");
        s.value = new ne(1, 1, 1), s.isConstant = !1;
        var l = new fl("FragmentOutput"), c = new pc("VectorMerger");
        c.visibleInInspector = !1;
        var u = new zp("Cos");
        u.operation = Hi.Cos, e.connectTo(c), a.output.connectTo(u.input), u.output.connectTo(c.z), c.xyzOut.connectTo(l.rgb), this.addOutputNode(o), this.addOutputNode(l), this._mode = kn.ProceduralTexture;
      }, t.prototype.setToDefaultParticle = function() {
        this.clear(), this.editorData = null;
        var e = new vt("uv");
        e.setAsAttribute("particle_uv");
        var i = new Dp("ParticleTexture");
        e.connectTo(i);
        var r = new vt("Color");
        r.setAsAttribute("particle_color");
        var o = new eh("Texture * Color");
        i.connectTo(o), r.connectTo(o);
        var a = new Np("ParticleRampGradient");
        o.connectTo(a);
        var s = new Gp("ColorSplitter");
        r.connectTo(s);
        var l = new Fp("ParticleBlendMultiply");
        a.connectTo(l), i.connectTo(l, { output: "a" }), s.connectTo(l, { output: "a" });
        var c = new fl("FragmentOutput");
        l.connectTo(c), this.addOutputNode(c), this._mode = kn.Particle;
      }, t.prototype.loadAsync = function(e, i) {
        return i === void 0 && (i = ""), Ft(this, void 0, void 0, function() {
          return Bt(this, function(r) {
            return [2, t.ParseFromFileAsync("", e, this.getScene(), i, !0, this)];
          });
        });
      }, t.prototype._gatherBlocks = function(e, i) {
        if (i.indexOf(e) === -1) {
          i.push(e);
          for (var r = 0, o = e.inputs; r < o.length; r++) {
            var a = o[r].connectedPoint;
            a && (s = a.ownerBlock) !== e && this._gatherBlocks(s, i);
          }
          var s;
          e.isTeleportOut && (s = e).entryPoint && this._gatherBlocks(s.entryPoint, i);
        }
      }, t.prototype.generateCode = function() {
        for (var e = [], i = [], r = ["const", "var", "let"], o = 0, a = this._vertexOutputNodes; o < a.length; o++) {
          var s = a[o];
          this._gatherBlocks(s, i);
        }
        for (var l = [], c = 0, u = this._fragmentOutputNodes; c < u.length; c++)
          s = u[c], this._gatherBlocks(s, l);
        var h = 'var nodeMaterial = new BABYLON.NodeMaterial("'.concat(this.name || "node material", `");
`);
        h += "nodeMaterial.mode = BABYLON.NodeMaterialModes.".concat(kn[this.mode], `;
`);
        for (var d = 0, p = i; d < p.length; d++)
          (A = p[d]).isInput && e.indexOf(A) === -1 && (h += A._dumpCode(r, e));
        for (var f = 0, m = l; f < m.length; f++)
          (A = m[f]).isInput && e.indexOf(A) === -1 && (h += A._dumpCode(r, e));
        e = [], h += `
// Connections
`;
        for (var g = 0, y = this._vertexOutputNodes; g < y.length; g++)
          h += (A = y[g])._dumpCodeForOutputConnections(e);
        for (var b = 0, T = this._fragmentOutputNodes; b < T.length; b++)
          h += (A = T[b])._dumpCodeForOutputConnections(e);
        h += `
// Output nodes
`;
        for (var S = 0, E = this._vertexOutputNodes; S < E.length; S++) {
          var A = E[S];
          h += "nodeMaterial.addOutputNode(".concat(A._codeVariableName, `);
`);
        }
        for (var R = 0, C = this._fragmentOutputNodes; R < C.length; R++)
          A = C[R], h += "nodeMaterial.addOutputNode(".concat(A._codeVariableName, `);
`);
        return h + `nodeMaterial.build();
`;
      }, t.prototype.serialize = function(e) {
        var i = e ? {} : Ne.Serialize(this);
        i.editorData = JSON.parse(JSON.stringify(this.editorData));
        var r = [];
        if (e)
          r = e;
        else {
          i.customType = "BABYLON.NodeMaterial", i.outputNodes = [];
          for (var o = 0, a = this._vertexOutputNodes; o < a.length; o++) {
            var s = a[o];
            this._gatherBlocks(s, r), i.outputNodes.push(s.uniqueId);
          }
          for (var l = 0, c = this._fragmentOutputNodes; l < c.length; l++)
            s = c[l], this._gatherBlocks(s, r), i.outputNodes.indexOf(s.uniqueId) === -1 && i.outputNodes.push(s.uniqueId);
        }
        i.blocks = [];
        for (var u = 0, h = r; u < h.length; u++) {
          var d = h[u];
          i.blocks.push(d.serialize());
        }
        if (!e)
          for (var p = 0, f = this.attachedBlocks; p < f.length; p++)
            d = f[p], r.indexOf(d) === -1 && i.blocks.push(d.serialize());
        return i;
      }, t.prototype._restoreConnections = function(e, i, r) {
        for (var o = 0, a = e.outputs; o < a.length; o++)
          for (var s = a[o], l = 0, c = i.blocks; l < c.length; l++) {
            var u = c[l], h = r[u.id];
            if (h)
              for (var d = 0, p = u.inputs; d < p.length; d++) {
                var f = p[d];
                if (!(r[f.targetBlockId] !== e || f.targetConnectionName !== s.name)) {
                  var m = h.getInputByName(f.inputName);
                  if (!m || m.isConnected)
                    continue;
                  s.connectTo(m, !0), this._restoreConnections(h, i, r);
                }
              }
          }
      }, t.prototype.parseSerializedObject = function(e, i, r) {
        var o;
        i === void 0 && (i = ""), r === void 0 && (r = !1), r || this.clear();
        for (var a = {}, s = 0, l = e.blocks; s < l.length; s++) {
          var c = Kt((m = l[s]).customType);
          c && ((g = new c())._deserialize(m, this.getScene(), i), a[m.id] = g, this.attachedBlocks.push(g));
        }
        for (var u = 0, h = this.attachedBlocks; u < h.length; u++)
          if ((g = h[u]).isTeleportOut) {
            var d = g, p = d._tempEntryPointUniqueId;
            p && a[p].attachToEndpoint(d);
          }
        for (var f = 0; f < e.blocks.length; f++) {
          var m, g;
          (g = a[(m = e.blocks[f]).id]) && (g.inputs.length && !r || this._restoreConnections(g, e, a));
        }
        if (e.outputNodes)
          for (var y = 0, b = e.outputNodes; y < b.length; y++) {
            var T = b[y];
            this.addOutputNode(a[T]);
          }
        if (e.locations || e.editorData && e.editorData.locations) {
          for (var S = e.locations || e.editorData.locations, E = 0, A = S; E < A.length; E++) {
            var R = A[E];
            a[R.blockId] && (R.blockId = a[R.blockId].uniqueId);
          }
          r && this.editorData && this.editorData.locations && S.concat(this.editorData.locations), e.locations ? this.editorData = { locations: S } : (this.editorData = e.editorData, this.editorData.locations = S);
          var C = [];
          for (var L in a)
            C[L] = a[L].uniqueId;
          this.editorData.map = C;
        }
        this.comment = e.comment, e.forceAlphaBlending !== void 0 && (this.forceAlphaBlending = e.forceAlphaBlending), r || (this._mode = (o = e.mode) !== null && o !== void 0 ? o : kn.Material);
      }, t.prototype.loadFromSerialization = function(e, i, r) {
        i === void 0 && (i = ""), r === void 0 && (r = !1), this.parseSerializedObject(e, i, r);
      }, t.prototype.clone = function(e, i) {
        var r = this;
        i === void 0 && (i = !1);
        var o = this.serialize(), a = Ne.Clone(function() {
          return new t(e, r.getScene(), r.options);
        }, this);
        return a.id = e, a.name = e, a.parseSerializedObject(o), a._buildId = this._buildId, a.build(!1, !i), a;
      }, t.prototype.whenTexturesReadyAsync = function() {
        var e = [];
        return this.getActiveTextures().forEach(function(i) {
          var r = i.getInternalTexture();
          r && !r.isReady && e.push(new Promise(function(o, a) {
            r.onLoadedObservable.addOnce(function() {
              o();
            }), r.onErrorObservable.addOnce(function(s) {
              a(s);
            });
          }));
        }), Promise.all(e);
      }, t.Parse = function(e, i, r) {
        r === void 0 && (r = "");
        var o = Ne.Parse(function() {
          return new t(e.name, i);
        }, e, i, r);
        return o.parseSerializedObject(e, r), o.build(), o;
      }, t.ParseFromFileAsync = function(e, i, r, o, a, s) {
        return o === void 0 && (o = ""), a === void 0 && (a = !1), Ft(this, void 0, void 0, function() {
          var l, c, u;
          return Bt(this, function(h) {
            switch (h.label) {
              case 0:
                return l = s ?? new t(e, r), [4, r._loadFileAsync(i)];
              case 1:
                return c = h.sent(), u = JSON.parse(c), l.parseSerializedObject(u, o), a || l.build(), [2, l];
            }
          });
        });
      }, t.ParseFromSnippetAsync = function(e, i, r, o, a, s) {
        var l = this;
        return i === void 0 && (i = Me.LastCreatedScene), r === void 0 && (r = ""), a === void 0 && (a = !1), s === void 0 && (s = !1), e === "_BLANK" ? Promise.resolve(t.CreateDefault("blank", i)) : new Promise(function(c, u) {
          var h = new _n();
          h.addEventListener("readystatechange", function() {
            if (h.readyState == 4)
              if (h.status == 200) {
                var d = JSON.parse(JSON.parse(h.responseText).jsonPayload), p = JSON.parse(d.nodeMaterial);
                o || ((o = Ne.Parse(function() {
                  return new t(e, i);
                }, p, i, r)).uniqueId = i.getUniqueId()), o.parseSerializedObject(p), o.snippetId = e;
                try {
                  a || o.build();
                } catch (f) {
                  u(f);
                }
                s ? o.whenTexturesReadyAsync().then(function() {
                  c(o);
                }).catch(function(f) {
                  u(f);
                }) : c(o);
              } else
                u("Unable to load the snippet " + e);
          }), h.open("GET", l.SnippetUrl + "/" + e.replace(/#/g, "/")), h.send();
        });
      }, t.CreateDefault = function(e, i) {
        var r = new t(e, i);
        return r.setToDefault(), r.build(), r;
      }, t._BuildIdGenerator = 0, t.EditorURL = "".concat(de._DefaultCdnUrl, "/v").concat(ve.Version, "/nodeEditor/babylon.nodeEditor.js"), t.SnippetUrl = _.SnippetUrl, t.IgnoreTexturesAtLoadTime = !1, x([N()], t.prototype, "ignoreAlpha", void 0), x([N()], t.prototype, "maxSimultaneousLights", void 0), x([N("mode")], t.prototype, "_mode", void 0), x([N("comment")], t.prototype, "comment", void 0), x([N()], t.prototype, "forceAlphaBlending", void 0), t;
    }(pl);
    function nh(n) {
      var t, e = n.sideOrientation || Oe.DEFAULTSIDE, i = n.radius || 1, r = n.flat === void 0 || n.flat, o = 0 | (n.subdivisions || 4), a = n.radiusX || i, s = n.radiusY || i, l = n.radiusZ || i, c = (1 + Math.sqrt(5)) / 2, u = [-1, c, -0, 1, c, 0, -1, -c, 0, 1, -c, 0, 0, -1, -c, 0, 1, -c, 0, -1, c, 0, 1, c, c, 0, 1, c, 0, -1, -c, 0, 1, -c, 0, -1], h = [0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 12, 22, 23, 1, 5, 20, 5, 11, 4, 23, 22, 13, 22, 18, 6, 7, 1, 8, 14, 21, 4, 14, 4, 2, 16, 13, 6, 15, 6, 19, 3, 8, 9, 4, 21, 5, 13, 17, 23, 6, 13, 22, 19, 6, 18, 9, 8, 1], d = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 2, 3, 3, 3, 4, 7, 8, 9, 9, 10, 11], p = [5, 1, 3, 1, 6, 4, 0, 0, 5, 3, 4, 2, 2, 2, 4, 0, 2, 0, 1, 1, 6, 0, 6, 2, 0, 4, 3, 3, 4, 4, 3, 1, 4, 2, 4, 4, 0, 2, 1, 1, 2, 2, 3, 3, 1, 3, 2, 4], f = [0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0], m = [], g = [], y = [], b = [], T = 0, S = new Array(3), E = new Array(3);
      for (t = 0; t < 3; t++)
        S[t] = v.Zero(), E[t] = fe.Zero();
      for (var A = 0; A < 20; A++) {
        for (t = 0; t < 3; t++) {
          var R = h[3 * A + t];
          S[t].copyFromFloats(u[3 * d[R]], u[3 * d[R] + 1], u[3 * d[R] + 2]), S[t].normalize(), E[t].copyFromFloats(0.134765625 * p[2 * R] + 0.05859375 + -0.0390625 * f[A], 0.2333984375 * p[2 * R + 1] + 0.025390625 + 0.01953125 * f[A]);
        }
        for (var C = function(w, z, V, Y) {
          var ee, J = v.Lerp(S[0], S[2], z / o), X = v.Lerp(S[1], S[2], z / o), K = o === z ? S[2] : v.Lerp(J, X, w / (o - z));
          if (K.normalize(), r) {
            var te = v.Lerp(S[0], S[2], Y / o), se = v.Lerp(S[1], S[2], Y / o);
            ee = v.Lerp(te, se, V / (o - Y));
          } else
            ee = new v(K.x, K.y, K.z);
          ee.x /= a, ee.y /= s, ee.z /= l, ee.normalize();
          var _e = fe.Lerp(E[0], E[2], z / o), xe = fe.Lerp(E[1], E[2], z / o), Te = o === z ? E[2] : fe.Lerp(_e, xe, w / (o - z));
          g.push(K.x * a, K.y * s, K.z * l), y.push(ee.x, ee.y, ee.z), b.push(Te.x, Lt.UseOpenGLOrientationForUV ? 1 - Te.y : Te.y), m.push(T), T++;
        }, L = 0; L < o; L++)
          for (var I = 0; I + L < o; I++)
            C(I, L, I + 1 / 3, L + 1 / 3), C(I + 1, L, I + 1 / 3, L + 1 / 3), C(I, L + 1, I + 1 / 3, L + 1 / 3), I + L + 1 < o && (C(I + 1, L, I + 2 / 3, L + 2 / 3), C(I + 1, L + 1, I + 2 / 3, L + 2 / 3), C(I, L + 1, I + 2 / 3, L + 2 / 3));
      }
      Oe._ComputeSides(e, g, m, y, b, n.frontUVs, n.backUVs);
      var O = new Oe();
      return O.indices = m, O.positions = g, O.normals = y, O.uvs = b, O;
    }
    function vc(n, t, e) {
      t === void 0 && (t = {}), e === void 0 && (e = null);
      var i = new ie(n, e);
      return t.sideOrientation = ie._GetDefaultSideOrientation(t.sideOrientation), i._originalBuilderSideOrientation = t.sideOrientation, nh(t).applyToMesh(i, t.updatable), i;
    }
    j("BABYLON.NodeMaterial", ka);
    var gl, ca, tt, MR = { CreateIcoSphere: vc };
    Oe.CreateIcoSphere = nh, ie.CreateIcoSphere = function(n, t, e) {
      return vc(n, t, e);
    }, function(n) {
      n.WRIST = "wrist", n.THUMB = "thumb", n.INDEX = "index", n.MIDDLE = "middle", n.RING = "ring", n.LITTLE = "little";
    }(ca || (ca = {})), function(n) {
      n.WRIST = "wrist", n.THUMB_METACARPAL = "thumb-metacarpal", n.THUMB_PHALANX_PROXIMAL = "thumb-phalanx-proximal", n.THUMB_PHALANX_DISTAL = "thumb-phalanx-distal", n.THUMB_TIP = "thumb-tip", n.INDEX_FINGER_METACARPAL = "index-finger-metacarpal", n.INDEX_FINGER_PHALANX_PROXIMAL = "index-finger-phalanx-proximal", n.INDEX_FINGER_PHALANX_INTERMEDIATE = "index-finger-phalanx-intermediate", n.INDEX_FINGER_PHALANX_DISTAL = "index-finger-phalanx-distal", n.INDEX_FINGER_TIP = "index-finger-tip", n.MIDDLE_FINGER_METACARPAL = "middle-finger-metacarpal", n.MIDDLE_FINGER_PHALANX_PROXIMAL = "middle-finger-phalanx-proximal", n.MIDDLE_FINGER_PHALANX_INTERMEDIATE = "middle-finger-phalanx-intermediate", n.MIDDLE_FINGER_PHALANX_DISTAL = "middle-finger-phalanx-distal", n.MIDDLE_FINGER_TIP = "middle-finger-tip", n.RING_FINGER_METACARPAL = "ring-finger-metacarpal", n.RING_FINGER_PHALANX_PROXIMAL = "ring-finger-phalanx-proximal", n.RING_FINGER_PHALANX_INTERMEDIATE = "ring-finger-phalanx-intermediate", n.RING_FINGER_PHALANX_DISTAL = "ring-finger-phalanx-distal", n.RING_FINGER_TIP = "ring-finger-tip", n.PINKY_FINGER_METACARPAL = "pinky-finger-metacarpal", n.PINKY_FINGER_PHALANX_PROXIMAL = "pinky-finger-phalanx-proximal", n.PINKY_FINGER_PHALANX_INTERMEDIATE = "pinky-finger-phalanx-intermediate", n.PINKY_FINGER_PHALANX_DISTAL = "pinky-finger-phalanx-distal", n.PINKY_FINGER_TIP = "pinky-finger-tip";
    }(tt || (tt = {}));
    var Ga, ua, za, Mo = [tt.WRIST, tt.THUMB_METACARPAL, tt.THUMB_PHALANX_PROXIMAL, tt.THUMB_PHALANX_DISTAL, tt.THUMB_TIP, tt.INDEX_FINGER_METACARPAL, tt.INDEX_FINGER_PHALANX_PROXIMAL, tt.INDEX_FINGER_PHALANX_INTERMEDIATE, tt.INDEX_FINGER_PHALANX_DISTAL, tt.INDEX_FINGER_TIP, tt.MIDDLE_FINGER_METACARPAL, tt.MIDDLE_FINGER_PHALANX_PROXIMAL, tt.MIDDLE_FINGER_PHALANX_INTERMEDIATE, tt.MIDDLE_FINGER_PHALANX_DISTAL, tt.MIDDLE_FINGER_TIP, tt.RING_FINGER_METACARPAL, tt.RING_FINGER_PHALANX_PROXIMAL, tt.RING_FINGER_PHALANX_INTERMEDIATE, tt.RING_FINGER_PHALANX_DISTAL, tt.RING_FINGER_TIP, tt.PINKY_FINGER_METACARPAL, tt.PINKY_FINGER_PHALANX_PROXIMAL, tt.PINKY_FINGER_PHALANX_INTERMEDIATE, tt.PINKY_FINGER_PHALANX_DISTAL, tt.PINKY_FINGER_TIP], W1 = ((gl = {})[ca.WRIST] = [tt.WRIST], gl[ca.THUMB] = [tt.THUMB_METACARPAL, tt.THUMB_PHALANX_PROXIMAL, tt.THUMB_PHALANX_DISTAL, tt.THUMB_TIP], gl[ca.INDEX] = [tt.INDEX_FINGER_METACARPAL, tt.INDEX_FINGER_PHALANX_PROXIMAL, tt.INDEX_FINGER_PHALANX_INTERMEDIATE, tt.INDEX_FINGER_PHALANX_DISTAL, tt.INDEX_FINGER_TIP], gl[ca.MIDDLE] = [tt.MIDDLE_FINGER_METACARPAL, tt.MIDDLE_FINGER_PHALANX_PROXIMAL, tt.MIDDLE_FINGER_PHALANX_INTERMEDIATE, tt.MIDDLE_FINGER_PHALANX_DISTAL, tt.MIDDLE_FINGER_TIP], gl[ca.RING] = [tt.RING_FINGER_METACARPAL, tt.RING_FINGER_PHALANX_PROXIMAL, tt.RING_FINGER_PHALANX_INTERMEDIATE, tt.RING_FINGER_PHALANX_DISTAL, tt.RING_FINGER_TIP], gl[ca.LITTLE] = [tt.PINKY_FINGER_METACARPAL, tt.PINKY_FINGER_PHALANX_PROXIMAL, tt.PINKY_FINGER_PHALANX_INTERMEDIATE, tt.PINKY_FINGER_PHALANX_DISTAL, tt.PINKY_FINGER_TIP], gl), Vg = function() {
      function n(t, e, i, r, o, a, s) {
        o === void 0 && (o = !1), a === void 0 && (a = !1), s === void 0 && (s = 1), this.xrController = t, this._jointMeshes = e, this._handMesh = i, this.rigMapping = r, this._leftHandedMeshes = o, this._jointsInvisible = a, this._jointScaleFactor = s, this._jointTransforms = new Array(Mo.length), this._jointTransformMatrices = new Float32Array(16 * Mo.length), this._tempJointMatrix = new B(), this._jointRadii = new Float32Array(Mo.length), this._scene = e[0].getScene();
        for (var l = 0; l < this._jointTransforms.length; l++)
          (this._jointTransforms[l] = new ai(Mo[l], this._scene)).rotationQuaternion = new oe(), e[l].rotationQuaternion = new oe();
        i && this.setHandMesh(i, r), this.xrController.motionController && (this.xrController.motionController.rootMesh ? this.xrController.motionController.rootMesh.setEnabled(!1) : this.xrController.motionController.onModelLoadedObservable.add(function(c) {
          c.rootMesh && c.rootMesh.setEnabled(!1);
        })), this.xrController.onMotionControllerInitObservable.add(function(c) {
          c.onModelLoadedObservable.add(function(u) {
            u.rootMesh && u.rootMesh.setEnabled(!1);
          }), c.rootMesh && c.rootMesh.setEnabled(!1);
        });
      }
      return Object.defineProperty(n.prototype, "handMesh", { get: function() {
        return this._handMesh;
      }, enumerable: !1, configurable: !0 }), n.prototype.getHandPartMeshes = function(t) {
        var e = this;
        return W1[t].map(function(i) {
          return e._jointMeshes[Mo.indexOf(i)];
        });
      }, n.prototype.getJointMesh = function(t) {
        return this._jointMeshes[Mo.indexOf(t)];
      }, n.prototype.setHandMesh = function(t, e) {
        var i = this;
        if (this._handMesh = t, t.alwaysSelectAsActiveMesh = !0, t.getChildMeshes().forEach(function(o) {
          return o.alwaysSelectAsActiveMesh = !0;
        }), this._handMesh.skeleton) {
          var r = this._handMesh.skeleton;
          Mo.forEach(function(o, a) {
            var s = r.getBoneIndexByName(e ? e[o] : o);
            s !== -1 && r.bones[s].linkTransformNode(i._jointTransforms[a]);
          });
        }
      }, n.prototype.updateFromXRFrame = function(t, e) {
        var i = this, r = this.xrController.inputSource.hand;
        if (r) {
          var o = r, a = Mo.map(function(u) {
            return o[u] || r.get(u);
          }), s = !1;
          if (t.fillPoses && t.fillJointRadii)
            s = t.fillPoses(a, e, this._jointTransformMatrices) && t.fillJointRadii(a, this._jointRadii);
          else if (t.getJointPose) {
            s = !0;
            for (var l = 0; l < a.length; l++) {
              var c = t.getJointPose(a[l], e);
              if (!c) {
                s = !1;
                break;
              }
              this._jointTransformMatrices.set(c.transform.matrix, 16 * l), this._jointRadii[l] = c.radius || 8e-3;
            }
          }
          s && (Mo.forEach(function(u, h) {
            var d = i._jointTransforms[h];
            B.FromArrayToRef(i._jointTransformMatrices, 16 * h, i._tempJointMatrix), i._tempJointMatrix.decompose(void 0, d.rotationQuaternion, d.position);
            var p = i._jointRadii[h] * i._jointScaleFactor, f = i._jointMeshes[h];
            f.isVisible = !i._handMesh && !i._jointsInvisible, f.position.copyFrom(d.position), f.rotationQuaternion.copyFrom(d.rotationQuaternion), f.scaling.setAll(p), i._scene.useRightHandedSystem || (f.position.z *= -1, f.rotationQuaternion.z *= -1, f.rotationQuaternion.w *= -1, i._leftHandedMeshes && i._handMesh && (d.position.z *= -1, d.rotationQuaternion.z *= -1, d.rotationQuaternion.w *= -1));
          }), this._handMesh && (this._handMesh.isVisible = !0));
        }
      }, n.prototype.dispose = function() {
        this._handMesh && (this._handMesh.isVisible = !1);
      }, n;
    }(), rh = function(n) {
      function t(e, i) {
        var r = n.call(this, e) || this;
        r.options = i, r._attachedHands = {}, r._trackingHands = { left: null, right: null }, r._handResources = { jointMeshes: null, handMeshes: null, rigMappings: null }, r.onHandAddedObservable = new H(), r.onHandRemovedObservable = new H(), r._attachHand = function(l) {
          var c, u, h;
          if (l.inputSource.hand && l.inputSource.handedness != "none" && r._handResources.jointMeshes) {
            var d = l.inputSource.handedness, p = new Vg(l, r._handResources.jointMeshes[d], r._handResources.handMeshes && r._handResources.handMeshes[d], r._handResources.rigMappings && r._handResources.rigMappings[d], (c = r.options.handMeshes) === null || c === void 0 ? void 0 : c.meshesUseLeftHandedCoordinates, (u = r.options.jointMeshes) === null || u === void 0 ? void 0 : u.invisible, (h = r.options.jointMeshes) === null || h === void 0 ? void 0 : h.scaleFactor);
            r._attachedHands[l.uniqueId] = p, r._trackingHands[d] = p, r.onHandAddedObservable.notifyObservers(p);
          }
        }, r._detachHand = function(l) {
          r._detachHandById(l.uniqueId);
        }, r.xrNativeFeatureName = "hand-tracking";
        var o = i.jointMeshes;
        if (o && (o.disableDefaultHandMesh !== void 0 && (i.handMeshes = i.handMeshes || {}, i.handMeshes.disableDefaultMeshes = o.disableDefaultHandMesh), o.handMeshes !== void 0 && (i.handMeshes = i.handMeshes || {}, i.handMeshes.customMeshes = o.handMeshes), o.leftHandedSystemMeshes !== void 0 && (i.handMeshes = i.handMeshes || {}, i.handMeshes.meshesUseLeftHandedCoordinates = o.leftHandedSystemMeshes), o.rigMapping !== void 0)) {
          i.handMeshes = i.handMeshes || {};
          var a = {}, s = {};
          [[o.rigMapping.left, a], [o.rigMapping.right, s]].forEach(function(l) {
            var c = l[0], u = l[1];
            c.forEach(function(h, d) {
              u[Mo[d]] = h;
            });
          }), i.handMeshes.customRigMappings = { left: a, right: s };
        }
        return r;
      }
      return D(t, n), t._GenerateTrackedJointMeshes = function(e) {
        var i = {};
        return ["left", "right"].map(function(r) {
          var o, a, s, l, c, u = [], h = ((o = e.jointMeshes) === null || o === void 0 ? void 0 : o.sourceMesh) || vc("jointParent", t._ICOSPHERE_PARAMS);
          h.isVisible = !!(!((a = e.jointMeshes) === null || a === void 0) && a.keepOriginalVisible);
          for (var d = 0; d < Mo.length; ++d) {
            var p = h.createInstance("".concat(r, "-handJoint-").concat(d));
            if (!((s = e.jointMeshes) === null || s === void 0) && s.onHandJointMeshGenerated) {
              var f = e.jointMeshes.onHandJointMeshGenerated(p, d, r);
              f && f !== p && (p.dispose(), p = f);
            }
            if (p.isPickable = !1, (l = e.jointMeshes) === null || l === void 0 ? void 0 : l.enablePhysics) {
              var m = ((c = e.jointMeshes) === null || c === void 0 ? void 0 : c.physicsProps) || {};
              p.scaling.setAll(0.02);
              var g = m.impostorType !== void 0 ? m.impostorType : bt.SphereImpostor;
              p.physicsImpostor = new bt(p, g, je({ mass: 0 }, m));
            }
            p.rotationQuaternion = new oe(), p.isVisible = !1, u.push(p);
          }
          i[r] = u;
        }), { left: i.left, right: i.right };
      }, t._GenerateDefaultHandMeshesAsync = function(e, i) {
        var r = this;
        return new Promise(function(o) {
          return Ft(r, void 0, void 0, function() {
            var a, s, l, c, u, h, d, p, f, m, g;
            return Bt(this, function(y) {
              switch (y.label) {
                case 0:
                  return a = {}, !((p = (d = t._RightHandGLB) === null || d === void 0 ? void 0 : d.meshes[1]) === null || p === void 0) && p.isDisposed() && (t._RightHandGLB = null), !((m = (f = t._LeftHandGLB) === null || f === void 0 ? void 0 : f.meshes[1]) === null || m === void 0) && m.isDisposed() && (t._LeftHandGLB = null), s = !(!t._RightHandGLB || !t._LeftHandGLB), [4, Promise.all([t._RightHandGLB || yi.ImportMeshAsync("", t.DEFAULT_HAND_MODEL_BASE_URL, t.DEFAULT_HAND_MODEL_RIGHT_FILENAME, e), t._LeftHandGLB || yi.ImportMeshAsync("", t.DEFAULT_HAND_MODEL_BASE_URL, t.DEFAULT_HAND_MODEL_LEFT_FILENAME, e)])];
                case 1:
                  return l = y.sent(), t._RightHandGLB = l[0], t._LeftHandGLB = l[1], [4, (c = new ka("handShader", e, { emitComments: !1 })).loadAsync(t.DEFAULT_HAND_MODEL_SHADER_URL)];
                case 2:
                  return y.sent(), c.needDepthPrePass = !0, c.transparencyMode = Et.MATERIAL_ALPHABLEND, c.alphaMode = _.ALPHA_COMBINE, c.build(!1), u = je({ base: ne.FromInts(116, 63, 203), fresnel: ne.FromInts(149, 102, 229), fingerColor: ne.FromInts(177, 130, 255), tipFresnel: ne.FromInts(220, 200, 255) }, (g = i == null ? void 0 : i.handMeshes) === null || g === void 0 ? void 0 : g.customColors), (h = { base: c.getBlockByName("baseColor"), fresnel: c.getBlockByName("fresnelColor"), fingerColor: c.getBlockByName("fingerColor"), tipFresnel: c.getBlockByName("tipFresnelColor") }).base.value = u.base, h.fresnel.value = u.fresnel, h.fingerColor.value = u.fingerColor, h.tipFresnel.value = u.tipFresnel, ["left", "right"].forEach(function(b) {
                    var T = b == "left" ? t._LeftHandGLB : t._RightHandGLB;
                    if (!T)
                      throw new Error("Could not load hand model");
                    var S = T.meshes[1];
                    S._internalAbstractMeshDataInfo._computeBonesUsingShaders = !0, S.material = c.clone("".concat(b, "HandShaderClone"), !0), S.isVisible = !1, a[b] = S, s || e.useRightHandedSystem || T.meshes[1].rotate(qi.Y, Math.PI);
                  }), c.dispose(), o({ left: a.left, right: a.right }), [2];
              }
            });
          });
        });
      }, t._GenerateDefaultHandMeshRigMapping = function(e) {
        var i, r = e == "right" ? "R" : "L";
        return (i = {})[tt.WRIST] = "wrist_".concat(r), i[tt.THUMB_METACARPAL] = "thumb_metacarpal_".concat(r), i[tt.THUMB_PHALANX_PROXIMAL] = "thumb_proxPhalanx_".concat(r), i[tt.THUMB_PHALANX_DISTAL] = "thumb_distPhalanx_".concat(r), i[tt.THUMB_TIP] = "thumb_tip_".concat(r), i[tt.INDEX_FINGER_METACARPAL] = "index_metacarpal_".concat(r), i[tt.INDEX_FINGER_PHALANX_PROXIMAL] = "index_proxPhalanx_".concat(r), i[tt.INDEX_FINGER_PHALANX_INTERMEDIATE] = "index_intPhalanx_".concat(r), i[tt.INDEX_FINGER_PHALANX_DISTAL] = "index_distPhalanx_".concat(r), i[tt.INDEX_FINGER_TIP] = "index_tip_".concat(r), i[tt.MIDDLE_FINGER_METACARPAL] = "middle_metacarpal_".concat(r), i[tt.MIDDLE_FINGER_PHALANX_PROXIMAL] = "middle_proxPhalanx_".concat(r), i[tt.MIDDLE_FINGER_PHALANX_INTERMEDIATE] = "middle_intPhalanx_".concat(r), i[tt.MIDDLE_FINGER_PHALANX_DISTAL] = "middle_distPhalanx_".concat(r), i[tt.MIDDLE_FINGER_TIP] = "middle_tip_".concat(r), i[tt.RING_FINGER_METACARPAL] = "ring_metacarpal_".concat(r), i[tt.RING_FINGER_PHALANX_PROXIMAL] = "ring_proxPhalanx_".concat(r), i[tt.RING_FINGER_PHALANX_INTERMEDIATE] = "ring_intPhalanx_".concat(r), i[tt.RING_FINGER_PHALANX_DISTAL] = "ring_distPhalanx_".concat(r), i[tt.RING_FINGER_TIP] = "ring_tip_".concat(r), i[tt.PINKY_FINGER_METACARPAL] = "little_metacarpal_".concat(r), i[tt.PINKY_FINGER_PHALANX_PROXIMAL] = "little_proxPhalanx_".concat(r), i[tt.PINKY_FINGER_PHALANX_INTERMEDIATE] = "little_intPhalanx_".concat(r), i[tt.PINKY_FINGER_PHALANX_DISTAL] = "little_distPhalanx_".concat(r), i[tt.PINKY_FINGER_TIP] = "little_tip_".concat(r), i;
      }, t.prototype.isCompatible = function() {
        return typeof XRHand < "u";
      }, t.prototype.getHandByControllerId = function(e) {
        return this._attachedHands[e];
      }, t.prototype.getHandByHandedness = function(e) {
        return e == "none" ? null : this._trackingHands[e];
      }, t.prototype.attach = function() {
        var e, i, r, o, a = this;
        return !!n.prototype.attach.call(this) && (this._handResources = { jointMeshes: t._GenerateTrackedJointMeshes(this.options), handMeshes: ((e = this.options.handMeshes) === null || e === void 0 ? void 0 : e.customMeshes) || null, rigMappings: ((i = this.options.handMeshes) === null || i === void 0 ? void 0 : i.customRigMappings) || null }, !((r = this.options.handMeshes) === null || r === void 0) && r.customMeshes || !((o = this.options.handMeshes) === null || o === void 0) && o.disableDefaultMeshes || t._GenerateDefaultHandMeshesAsync(Me.LastCreatedScene, this.options).then(function(s) {
          var l, c;
          a._handResources.handMeshes = s, a._handResources.rigMappings = { left: t._GenerateDefaultHandMeshRigMapping("left"), right: t._GenerateDefaultHandMeshRigMapping("right") }, (l = a._trackingHands.left) === null || l === void 0 || l.setHandMesh(a._handResources.handMeshes.left, a._handResources.rigMappings.left), (c = a._trackingHands.right) === null || c === void 0 || c.setHandMesh(a._handResources.handMeshes.right, a._handResources.rigMappings.right);
        }), this.options.xrInput.controllers.forEach(this._attachHand), this._addNewAttachObserver(this.options.xrInput.onControllerAddedObservable, this._attachHand), this._addNewAttachObserver(this.options.xrInput.onControllerRemovedObservable, this._detachHand), !0);
      }, t.prototype._onXRFrame = function(e) {
        var i, r;
        (i = this._trackingHands.left) === null || i === void 0 || i.updateFromXRFrame(e, this._xrSessionManager.referenceSpace), (r = this._trackingHands.right) === null || r === void 0 || r.updateFromXRFrame(e, this._xrSessionManager.referenceSpace);
      }, t.prototype._detachHandById = function(e) {
        var i, r = this.getHandByControllerId(e);
        if (r) {
          var o = r.xrController.inputSource.handedness == "left" ? "left" : "right";
          ((i = this._trackingHands[o]) === null || i === void 0 ? void 0 : i.xrController.uniqueId) === e && (this._trackingHands[o] = null), this.onHandRemovedObservable.notifyObservers(r), r.dispose(), delete this._attachedHands[e];
        }
      }, t.prototype.detach = function() {
        var e = this;
        return !!n.prototype.detach.call(this) && (Object.keys(this._attachedHands).forEach(function(i) {
          return e._detachHandById(i);
        }), !0);
      }, t.prototype.dispose = function() {
        var e;
        n.prototype.dispose.call(this), this.onHandAddedObservable.clear(), this.onHandRemovedObservable.clear(), this._handResources.handMeshes && !(!((e = this.options.handMeshes) === null || e === void 0) && e.customMeshes) && (this._handResources.handMeshes.left.dispose(), this._handResources.handMeshes.right.dispose(), t._RightHandGLB = null, t._LeftHandGLB = null), this._handResources.jointMeshes && (this._handResources.jointMeshes.left.forEach(function(i) {
          return i.dispose();
        }), this._handResources.jointMeshes.right.forEach(function(i) {
          return i.dispose();
        }));
      }, t.Name = vi.HAND_TRACKING, t.Version = 1, t.DEFAULT_HAND_MODEL_BASE_URL = "https://assets.babylonjs.com/meshes/HandMeshes/", t.DEFAULT_HAND_MODEL_RIGHT_FILENAME = "r_hand_rhs.glb", t.DEFAULT_HAND_MODEL_LEFT_FILENAME = "l_hand_rhs.glb", t.DEFAULT_HAND_MODEL_SHADER_URL = "https://assets.babylonjs.com/meshes/HandMeshes/handsShader.json", t._ICOSPHERE_PARAMS = { radius: 0.5, flat: !1, subdivisions: 2 }, t._RightHandGLB = null, t._LeftHandGLB = null, t;
    }(Qi);
    Wi.AddWebXRFeature(rh.Name, function(n, t) {
      return function() {
        return new rh(n, t);
      };
    }, rh.Version, !1), function(n) {
      n[n.ABOVE_FINGER_TIPS = 0] = "ABOVE_FINGER_TIPS", n[n.RADIAL_SIDE = 1] = "RADIAL_SIDE", n[n.ULNAR_SIDE = 2] = "ULNAR_SIDE", n[n.BELOW_WRIST = 3] = "BELOW_WRIST";
    }(Ga || (Ga = {})), function(n) {
      n[n.LOOK_AT_CAMERA = 0] = "LOOK_AT_CAMERA", n[n.HAND_ROTATION = 1] = "HAND_ROTATION";
    }(ua || (ua = {})), function(n) {
      n[n.ALWAYS_VISIBLE = 0] = "ALWAYS_VISIBLE", n[n.PALM_UP = 1] = "PALM_UP", n[n.GAZE_FOCUS = 2] = "GAZE_FOCUS", n[n.PALM_AND_GAZE = 3] = "PALM_AND_GAZE";
    }(za || (za = {}));
    var kg, OR = function() {
      function n() {
        this._sceneRenderObserver = null, this._zoneAxis = {}, this.handConstraintVisibility = za.PALM_AND_GAZE, this.palmUpStrictness = 0.95, this.gazeProximityRadius = 0.15, this.targetOffset = 0.1, this.targetZone = Ga.ULNAR_SIDE, this.zoneOrientationMode = ua.HAND_ROTATION, this.nodeOrientationMode = ua.HAND_ROTATION, this.handedness = "none", this.lerpTime = 100, this._zoneAxis[Ga.ABOVE_FINGER_TIPS] = new v(0, 1, 0), this._zoneAxis[Ga.RADIAL_SIDE] = new v(-1, 0, 0), this._zoneAxis[Ga.ULNAR_SIDE] = new v(1, 0, 0), this._zoneAxis[Ga.BELOW_WRIST] = new v(0, -1, 0);
      }
      return Object.defineProperty(n.prototype, "name", { get: function() {
        return "HandConstraint";
      }, enumerable: !1, configurable: !0 }), n.prototype.enable = function() {
        this._node.setEnabled(!0);
      }, n.prototype.disable = function() {
        this._node.setEnabled(!1);
      }, n.prototype._getHandPose = function() {
        if (!this._handTracking)
          return null;
        var t;
        if (t = this.handedness === "none" ? this._handTracking.getHandByHandedness("left") || this._handTracking.getHandByHandedness("right") : this._handTracking.getHandByHandedness(this.handedness)) {
          var e = t.getJointMesh(tt.PINKY_FINGER_METACARPAL), i = t.getJointMesh(tt.MIDDLE_FINGER_METACARPAL), r = t.getJointMesh(tt.WRIST);
          if (r && i && e) {
            var o = { position: i.absolutePosition, quaternion: new oe(), id: t.xrController.uniqueId }, a = F.Vector3[0], s = F.Vector3[1], l = F.Vector3[2];
            return a.copyFrom(i.absolutePosition).subtractInPlace(r.absolutePosition).normalize(), s.copyFrom(e.absolutePosition).subtractInPlace(i.absolutePosition).normalize(), v.CrossToRef(a, s, s), v.CrossToRef(s, a, l), oe.FromLookDirectionLHToRef(s, a, o.quaternion), o;
          }
        }
        return null;
      }, n.prototype.init = function() {
      }, n.prototype.attach = function(t) {
        var e = this;
        this._node = t, this._scene = t.getScene(), this._node.rotationQuaternion || (this._node.rotationQuaternion = oe.RotationYawPitchRoll(this._node.rotation.y, this._node.rotation.x, this._node.rotation.z));
        var i = Date.now();
        this._sceneRenderObserver = this._scene.onBeforeRenderObservable.add(function() {
          var r = e._getHandPose();
          if (e._node.reservedDataStore = e._node.reservedDataStore || {}, e._node.reservedDataStore.nearInteraction = e._node.reservedDataStore.nearInteraction || {}, e._node.reservedDataStore.nearInteraction.excludedControllerId = null, r) {
            var o = F.Vector3[0], a = e._scene.activeCamera;
            o.copyFrom(e._zoneAxis[e.targetZone]);
            var s = F.Quaternion[0];
            if (a && (e.zoneOrientationMode === ua.LOOK_AT_CAMERA || e.nodeOrientationMode === ua.LOOK_AT_CAMERA)) {
              var l = F.Vector3[1];
              l.copyFrom(a.position).subtractInPlace(r.position).normalize(), e._scene.useRightHandedSystem ? oe.FromLookDirectionRHToRef(l, v.UpReadOnly, s) : oe.FromLookDirectionLHToRef(l, v.UpReadOnly, s);
            }
            e.zoneOrientationMode === ua.HAND_ROTATION ? r.quaternion.toRotationMatrix(F.Matrix[0]) : s.toRotationMatrix(F.Matrix[0]), v.TransformNormalToRef(o, F.Matrix[0], o), o.scaleInPlace(e.targetOffset);
            var c = F.Vector3[2], u = F.Quaternion[1];
            c.copyFrom(r.position).addInPlace(o), e.nodeOrientationMode === ua.HAND_ROTATION ? u.copyFrom(r.quaternion) : u.copyFrom(s);
            var h = Date.now() - i;
            v.SmoothToRef(e._node.position, c, h, e.lerpTime, e._node.position), oe.SmoothToRef(e._node.rotationQuaternion, u, h, e.lerpTime, e._node.rotationQuaternion), e._node.reservedDataStore.nearInteraction.excludedControllerId = r.id;
          }
          e._setVisibility(r), i = Date.now();
        });
      }, n.prototype._setVisibility = function(t) {
        var e = !0, i = !0, r = this._scene.activeCamera;
        if (r) {
          var o = r.getForwardRay();
          if (this.handConstraintVisibility === za.GAZE_FOCUS || this.handConstraintVisibility === za.PALM_AND_GAZE) {
            i = !1;
            var a = void 0;
            this._eyeTracking && (a = this._eyeTracking.getEyeGaze()), a = a || o;
            var s = F.Vector3[0];
            t ? t.position.subtractToRef(a.origin, s) : this._node.getAbsolutePosition().subtractToRef(a.origin, s);
            var l = v.Dot(s, a.direction), c = l * l;
            l > 0 && s.lengthSquared() - c < this.gazeProximityRadius * this.gazeProximityRadius && (i = !0);
          }
          if ((this.handConstraintVisibility === za.PALM_UP || this.handConstraintVisibility === za.PALM_AND_GAZE) && (e = !1, t)) {
            var u = F.Vector3[0];
            v.LeftHandedForwardReadOnly.rotateByQuaternionToRef(t.quaternion, u), v.Dot(u, o.direction) > 2 * this.palmUpStrictness - 1 && (e = !0);
          }
        }
        this._node.setEnabled(e && i);
      }, n.prototype.detach = function() {
        this._scene.onBeforeRenderObservable.remove(this._sceneRenderObserver);
      }, n.prototype.linkToXRExperience = function(t) {
        var e = t.featuresManager ? t.featuresManager : t;
        if (e) {
          try {
            this._eyeTracking = e.getEnabledFeature(vi.EYE_TRACKING);
          } catch {
          }
          try {
            this._handTracking = e.getEnabledFeature(vi.HAND_TRACKING);
          } catch {
            de.Error("Hand tracking must be enabled for the Hand Menu to work");
          }
        } else
          de.Error("XR features manager must be available or provided directly for the Hand Menu to work");
      }, n;
    }(), DR = function() {
      function n(t, e, i) {
        this.targetPosition = v.Zero(), this.poleTargetPosition = v.Zero(), this.poleTargetLocalOffset = v.Zero(), this.poleAngle = 0, this.slerpAmount = 1, this._bone1Quat = oe.Identity(), this._bone1Mat = B.Identity(), this._bone2Ang = Math.PI, this._maxAngle = Math.PI, this._rightHandedSystem = !1, this._bendAxis = v.Right(), this._slerping = !1, this._adjustRoll = 0, this._notEnoughInformation = !1, this._bone2 = e;
        var r = e.getParent();
        if (!r)
          return this._notEnoughInformation = !0, void q.Error("BoneIKController: bone must have a parent for IK to work.");
        if (this._bone1 = r, this._bone2.children.length === 0 && !this._bone2.length)
          return this._notEnoughInformation = !0, void q.Error("BoneIKController: bone must not be a leaf or it should have a length for IK to work.");
        this.mesh = t, e.getSkeleton().computeAbsoluteMatrices();
        var o = e.getPosition();
        if (e.getAbsoluteMatrix().determinant() > 0 && (this._rightHandedSystem = !0, this._bendAxis.x = 0, this._bendAxis.y = 0, this._bendAxis.z = -1, o.x > o.y && o.x > o.z && (this._adjustRoll = 0.5 * Math.PI, this._bendAxis.z = 1)), this._bone1.length && this._bone2.length) {
          var a = this._bone1.getScale(), s = this._bone2.getScale();
          this._bone1Length = this._bone1.length * a.y * this.mesh.scaling.y, this._bone2Length = this._bone2.length * s.y * this.mesh.scaling.y;
        } else if (this._bone2.children[0]) {
          t.computeWorldMatrix(!0);
          var l = this._bone2.children[0].getAbsolutePosition(t), c = this._bone2.getAbsolutePosition(t), u = this._bone1.getAbsolutePosition(t);
          this._bone2Length = v.Distance(l, c), this._bone1Length = v.Distance(c, u);
        } else
          t.computeWorldMatrix(!0), s = this._bone2.getScale(), this._bone2Length = this._bone2.length * s.y * this.mesh.scaling.y, c = this._bone2.getAbsolutePosition(t), u = this._bone1.getAbsolutePosition(t), this._bone1Length = v.Distance(c, u);
        this._bone1.getRotationMatrixToRef(ht.WORLD, t, this._bone1Mat), this.maxAngle = Math.PI, i && (i.targetMesh && (this.targetMesh = i.targetMesh, this.targetMesh.computeWorldMatrix(!0)), i.poleTargetMesh ? (this.poleTargetMesh = i.poleTargetMesh, this.poleTargetMesh.computeWorldMatrix(!0)) : i.poleTargetBone ? this.poleTargetBone = i.poleTargetBone : this._bone1.getParent() && (this.poleTargetBone = this._bone1.getParent()), i.poleTargetLocalOffset && this.poleTargetLocalOffset.copyFrom(i.poleTargetLocalOffset), i.poleAngle && (this.poleAngle = i.poleAngle), i.bendAxis && this._bendAxis.copyFrom(i.bendAxis), i.maxAngle && (this.maxAngle = i.maxAngle), i.slerpAmount && (this.slerpAmount = i.slerpAmount));
      }
      return Object.defineProperty(n.prototype, "maxAngle", { get: function() {
        return this._maxAngle;
      }, set: function(t) {
        this._setMaxAngle(t);
      }, enumerable: !1, configurable: !0 }), n.prototype._setMaxAngle = function(t) {
        t < 0 && (t = 0), (t > Math.PI || t == null) && (t = Math.PI), this._maxAngle = t;
        var e = this._bone1Length, i = this._bone2Length;
        this._maxReach = Math.sqrt(e * e + i * i - 2 * e * i * Math.cos(t));
      }, n.prototype.update = function() {
        if (!this._notEnoughInformation) {
          var t = this.targetPosition, e = this.poleTargetPosition, i = n._TmpMats[0], r = n._TmpMats[1];
          this.targetMesh && t.copyFrom(this.targetMesh.getAbsolutePosition()), this.poleTargetBone ? this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset, this.mesh, e) : this.poleTargetMesh && v.TransformCoordinatesToRef(this.poleTargetLocalOffset, this.poleTargetMesh.getWorldMatrix(), e);
          var o = n._TmpVecs[0], a = n._TmpVecs[1], s = n._TmpVecs[2], l = n._TmpVecs[3], c = n._TmpVecs[4], u = n._TmpQuat;
          this._bone1.getAbsolutePositionToRef(this.mesh, o), e.subtractToRef(o, c), c.x == 0 && c.y == 0 && c.z == 0 ? c.y = 1 : c.normalize(), t.subtractToRef(o, l), l.normalize(), v.CrossToRef(l, c, a), a.normalize(), v.CrossToRef(l, a, s), s.normalize(), B.FromXYZAxesToRef(s, l, a, i);
          var h = this._bone1Length, d = this._bone2Length, p = v.Distance(o, t);
          this._maxReach > 0 && (p = Math.min(this._maxReach, p));
          var f = (d * d + p * p - h * h) / (2 * d * p), m = (p * p + h * h - d * d) / (2 * p * h);
          f > 1 && (f = 1), m > 1 && (m = 1), f < -1 && (f = -1), m < -1 && (m = -1);
          var g = Math.acos(f), y = Math.acos(m), b = -g - y;
          if (this._rightHandedSystem)
            B.RotationYawPitchRollToRef(0, 0, this._adjustRoll, r), r.multiplyToRef(i, i), B.RotationAxisToRef(this._bendAxis, y, r), r.multiplyToRef(i, i);
          else {
            var T = n._TmpVecs[5];
            T.copyFrom(this._bendAxis), T.x *= -1, B.RotationAxisToRef(T, -y, r), r.multiplyToRef(i, i);
          }
          this.poleAngle && (B.RotationAxisToRef(l, this.poleAngle, r), i.multiplyToRef(r, i)), this._bone1 && (this.slerpAmount < 1 ? (this._slerping || oe.FromRotationMatrixToRef(this._bone1Mat, this._bone1Quat), oe.FromRotationMatrixToRef(i, u), oe.SlerpToRef(this._bone1Quat, u, this.slerpAmount, this._bone1Quat), b = this._bone2Ang * (1 - this.slerpAmount) + b * this.slerpAmount, this._bone1.setRotationQuaternion(this._bone1Quat, ht.WORLD, this.mesh), this._slerping = !0) : (this._bone1.setRotationMatrix(i, ht.WORLD, this.mesh), this._bone1Mat.copyFrom(i), this._slerping = !1), this._updateLinkedTransformRotation(this._bone1)), this._bone2.setAxisAngle(this._bendAxis, b, ht.LOCAL), this._updateLinkedTransformRotation(this._bone2), this._bone2Ang = b;
        }
      }, n.prototype._updateLinkedTransformRotation = function(t) {
        t._linkedTransformNode && (t._linkedTransformNode.rotationQuaternion || (t._linkedTransformNode.rotationQuaternion = new oe()), t.getRotationQuaternionToRef(ht.LOCAL, null, t._linkedTransformNode.rotationQuaternion));
      }, n._TmpVecs = [v.Zero(), v.Zero(), v.Zero(), v.Zero(), v.Zero(), v.Zero()], n._TmpQuat = oe.Identity(), n._TmpMats = [B.Identity(), B.Identity()], n;
    }(), NR = function() {
      function n(t, e, i, r) {
        if (this.upAxis = v.Up(), this.upAxisSpace = ht.LOCAL, this.adjustYaw = 0, this.adjustPitch = 0, this.adjustRoll = 0, this.slerpAmount = 1, this._boneQuat = oe.Identity(), this._slerping = !1, this._firstFrameSkipped = !1, this._fowardAxis = v.Forward(), this.useAbsoluteValueForYaw = !1, this.mesh = t, this.bone = e, this.target = i, r) {
          if (r.adjustYaw && (this.adjustYaw = r.adjustYaw), r.adjustPitch && (this.adjustPitch = r.adjustPitch), r.adjustRoll && (this.adjustRoll = r.adjustRoll), r.maxYaw != null ? this.maxYaw = r.maxYaw : this.maxYaw = Math.PI, r.minYaw != null ? this.minYaw = r.minYaw : this.minYaw = -Math.PI, r.maxPitch != null ? this.maxPitch = r.maxPitch : this.maxPitch = Math.PI, r.minPitch != null ? this.minPitch = r.minPitch : this.minPitch = -Math.PI, r.slerpAmount != null && (this.slerpAmount = r.slerpAmount), r.upAxis != null && (this.upAxis = r.upAxis), r.upAxisSpace != null && (this.upAxisSpace = r.upAxisSpace), r.yawAxis != null || r.pitchAxis != null) {
            var o = qi.Y, a = qi.X;
            r.yawAxis != null && (o = r.yawAxis.clone()).normalize(), r.pitchAxis != null && (a = r.pitchAxis.clone()).normalize();
            var s = v.Cross(a, o);
            this._transformYawPitch = B.Identity(), B.FromXYZAxesToRef(a, o, s, this._transformYawPitch), this._transformYawPitchInv = this._transformYawPitch.clone(), this._transformYawPitch.invert();
          }
          r.useAbsoluteValueForYaw !== void 0 && (this.useAbsoluteValueForYaw = r.useAbsoluteValueForYaw);
        }
        e.getParent() || this.upAxisSpace != ht.BONE || (this.upAxisSpace = ht.LOCAL);
      }
      return Object.defineProperty(n.prototype, "minYaw", { get: function() {
        return this._minYaw;
      }, set: function(t) {
        this._minYaw = t, this._minYawSin = Math.sin(t), this._minYawCos = Math.cos(t), this._maxYaw != null && (this._midYawConstraint = 0.5 * this._getAngleDiff(this._minYaw, this._maxYaw) + this._minYaw, this._yawRange = this._maxYaw - this._minYaw);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "maxYaw", { get: function() {
        return this._maxYaw;
      }, set: function(t) {
        this._maxYaw = t, this._maxYawSin = Math.sin(t), this._maxYawCos = Math.cos(t), this._minYaw != null && (this._midYawConstraint = 0.5 * this._getAngleDiff(this._minYaw, this._maxYaw) + this._minYaw, this._yawRange = this._maxYaw - this._minYaw);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "minPitch", { get: function() {
        return this._minPitch;
      }, set: function(t) {
        this._minPitch = t, this._minPitchTan = Math.tan(t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "maxPitch", { get: function() {
        return this._maxPitch;
      }, set: function(t) {
        this._maxPitch = t, this._maxPitchTan = Math.tan(t);
      }, enumerable: !1, configurable: !0 }), n.prototype.update = function() {
        if (this.slerpAmount < 1 && !this._firstFrameSkipped)
          this._firstFrameSkipped = !0;
        else {
          var t = this.bone, e = n._TmpVecs[0];
          t.getAbsolutePositionToRef(this.mesh, e);
          var i = this.target, r = n._TmpMats[0], o = n._TmpMats[1], a = this.mesh, s = t.getParent(), l = n._TmpVecs[1];
          l.copyFrom(this.upAxis), this.upAxisSpace == ht.BONE && s ? (this._transformYawPitch && v.TransformCoordinatesToRef(l, this._transformYawPitchInv, l), s.getDirectionToRef(l, this.mesh, l)) : this.upAxisSpace == ht.LOCAL && (a.getDirectionToRef(l, l), a.scaling.x == 1 && a.scaling.y == 1 && a.scaling.z == 1 || l.normalize());
          var c = !1, u = !1;
          if (this._maxYaw == Math.PI && this._minYaw == -Math.PI || (c = !0), this._maxPitch == Math.PI && this._minPitch == -Math.PI || (u = !0), c || u) {
            var h = n._TmpMats[2], d = n._TmpMats[3];
            if (this.upAxisSpace == ht.BONE && l.y == 1 && s)
              s.getRotationMatrixToRef(ht.WORLD, this.mesh, h);
            else if (this.upAxisSpace != ht.LOCAL || l.y != 1 || s) {
              var p = n._TmpVecs[2];
              p.copyFrom(this._fowardAxis), this._transformYawPitch && v.TransformCoordinatesToRef(p, this._transformYawPitchInv, p), s ? s.getDirectionToRef(p, this.mesh, p) : a.getDirectionToRef(p, p);
              var f = v.Cross(l, p);
              f.normalize(), p = v.Cross(f, l), B.FromXYZAxesToRef(f, l, p, h);
            } else
              h.copyFrom(a.getWorldMatrix());
            h.invertToRef(d);
            var m = null;
            if (u) {
              var g = n._TmpVecs[3];
              i.subtractToRef(e, g), v.TransformCoordinatesToRef(g, d, g), m = Math.sqrt(g.x * g.x + g.z * g.z);
              var y = Math.atan2(g.y, m), b = y;
              y > this._maxPitch ? (g.y = this._maxPitchTan * m, b = this._maxPitch) : y < this._minPitch && (g.y = this._minPitchTan * m, b = this._minPitch), y != b && (v.TransformCoordinatesToRef(g, h, g), g.addInPlace(e), i = g);
            }
            if (c) {
              g = n._TmpVecs[4], i.subtractToRef(e, g), v.TransformCoordinatesToRef(g, d, g);
              var T = Math.atan2(g.x, g.z), S = this.useAbsoluteValueForYaw ? Math.abs(T) : T, E = T;
              if ((S > this._maxYaw || S < this._minYaw) && (m == null && (m = Math.sqrt(g.x * g.x + g.z * g.z)), this._yawRange > Math.PI ? this._isAngleBetween(T, this._maxYaw, this._midYawConstraint) ? (g.z = this._maxYawCos * m, g.x = this._maxYawSin * m, E = this._maxYaw) : this._isAngleBetween(T, this._midYawConstraint, this._minYaw) && (g.z = this._minYawCos * m, g.x = this._minYawSin * m, E = this._minYaw) : S > this._maxYaw ? (g.z = this._maxYawCos * m, g.x = this._maxYawSin * m, T < 0 && this.useAbsoluteValueForYaw && (g.x *= -1), E = this._maxYaw) : S < this._minYaw && (g.z = this._minYawCos * m, g.x = this._minYawSin * m, T < 0 && this.useAbsoluteValueForYaw && (g.x *= -1), E = this._minYaw)), this._slerping && this._yawRange > Math.PI) {
                var A = n._TmpVecs[8];
                A.copyFrom(qi.Z), this._transformYawPitch && v.TransformCoordinatesToRef(A, this._transformYawPitchInv, A);
                var R = n._TmpMats[4];
                this._boneQuat.toRotationMatrix(R), this.mesh.getWorldMatrix().multiplyToRef(R, R), v.TransformCoordinatesToRef(A, R, A), v.TransformCoordinatesToRef(A, d, A);
                var C = Math.atan2(A.x, A.z);
                if (this._getAngleBetween(C, T) > this._getAngleBetween(C, this._midYawConstraint)) {
                  m == null && (m = Math.sqrt(g.x * g.x + g.z * g.z));
                  var L = this._getAngleBetween(C, this._maxYaw);
                  this._getAngleBetween(C, this._minYaw) < L ? (E = C + 0.75 * Math.PI, g.z = Math.cos(E) * m, g.x = Math.sin(E) * m) : (E = C - 0.75 * Math.PI, g.z = Math.cos(E) * m, g.x = Math.sin(E) * m);
                }
              }
              T != E && (v.TransformCoordinatesToRef(g, h, g), g.addInPlace(e), i = g);
            }
          }
          var I = n._TmpVecs[5], O = n._TmpVecs[6], w = n._TmpVecs[7], z = n._TmpQuat;
          i.subtractToRef(e, I), I.normalize(), v.CrossToRef(l, I, O), O.normalize(), v.CrossToRef(I, O, w), w.normalize(), B.FromXYZAxesToRef(O, w, I, r), O.x === 0 && O.y === 0 && O.z === 0 || w.x === 0 && w.y === 0 && w.z === 0 || I.x === 0 && I.y === 0 && I.z === 0 || ((this.adjustYaw || this.adjustPitch || this.adjustRoll) && (B.RotationYawPitchRollToRef(this.adjustYaw, this.adjustPitch, this.adjustRoll, o), o.multiplyToRef(r, r)), this.slerpAmount < 1 ? (this._slerping || this.bone.getRotationQuaternionToRef(ht.WORLD, this.mesh, this._boneQuat), this._transformYawPitch && this._transformYawPitch.multiplyToRef(r, r), oe.FromRotationMatrixToRef(r, z), oe.SlerpToRef(this._boneQuat, z, this.slerpAmount, this._boneQuat), this.bone.setRotationQuaternion(this._boneQuat, ht.WORLD, this.mesh), this._slerping = !0) : (this._transformYawPitch && this._transformYawPitch.multiplyToRef(r, r), this.bone.setRotationMatrix(r, ht.WORLD, this.mesh), this._slerping = !1), this._updateLinkedTransformRotation());
        }
      }, n.prototype._getAngleDiff = function(t, e) {
        var i = e - t;
        return (i %= 2 * Math.PI) > Math.PI ? i -= 2 * Math.PI : i < -Math.PI && (i += 2 * Math.PI), i;
      }, n.prototype._getAngleBetween = function(t, e) {
        var i = 0;
        return (i = (t = (t %= 2 * Math.PI) < 0 ? t + 2 * Math.PI : t) < (e = (e %= 2 * Math.PI) < 0 ? e + 2 * Math.PI : e) ? e - t : t - e) > Math.PI && (i = 2 * Math.PI - i), i;
      }, n.prototype._isAngleBetween = function(t, e, i) {
        if (t = (t %= 2 * Math.PI) < 0 ? t + 2 * Math.PI : t, (e = (e %= 2 * Math.PI) < 0 ? e + 2 * Math.PI : e) < (i = (i %= 2 * Math.PI) < 0 ? i + 2 * Math.PI : i)) {
          if (t > e && t < i)
            return !0;
        } else if (t > i && t < e)
          return !0;
        return !1;
      }, n.prototype._updateLinkedTransformRotation = function() {
        var t = this.bone;
        t._linkedTransformNode && (t._linkedTransformNode.rotationQuaternion || (t._linkedTransformNode.rotationQuaternion = new oe()), t.getRotationQuaternionToRef(ht.LOCAL, null, t._linkedTransformNode.rotationQuaternion));
      }, n._TmpVecs = pt.BuildArray(10, v.Zero), n._TmpQuat = oe.Identity(), n._TmpMats = pt.BuildArray(5, B.Identity), n;
    }(), oh = function() {
      function n(t, e, i) {
        this.name = t, this.id = e, this.bones = [], this.needInitialSkinMatrix = !1, this._isDirty = !0, this._meshesWithPoseMatrix = new Array(), this._identity = B.Identity(), this._currentRenderId = -1, this._ranges = {}, this._absoluteTransformIsDirty = !0, this._canUseTextureForBones = !1, this._uniqueId = 0, this._numBonesWithLinkedTransformNode = 0, this._hasWaitingData = null, this._parentContainer = null, this.doNotSerialize = !1, this._useTextureToStoreBoneMatrices = !0, this._animationPropertiesOverride = null, this.onBeforeComputeObservable = new H(), this.bones = [], this._scene = i || Me.LastCreatedScene, this._uniqueId = this._scene.getUniqueId(), this._scene.addSkeleton(this), this._isDirty = !0;
        var r = this._scene.getEngine().getCaps();
        this._canUseTextureForBones = r.textureFloat && r.maxVertexTextureImageUnits > 0;
      }
      return Object.defineProperty(n.prototype, "useTextureToStoreBoneMatrices", { get: function() {
        return this._useTextureToStoreBoneMatrices;
      }, set: function(t) {
        this._useTextureToStoreBoneMatrices = t, this._markAsDirty();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "animationPropertiesOverride", { get: function() {
        return this._animationPropertiesOverride ? this._animationPropertiesOverride : this._scene.animationPropertiesOverride;
      }, set: function(t) {
        this._animationPropertiesOverride = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isUsingTextureForMatrices", { get: function() {
        return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "uniqueId", { get: function() {
        return this._uniqueId;
      }, enumerable: !1, configurable: !0 }), n.prototype.getClassName = function() {
        return "Skeleton";
      }, n.prototype.getChildren = function() {
        return this.bones.filter(function(t) {
          return !t.getParent();
        });
      }, n.prototype.getTransformMatrices = function(t) {
        return this.needInitialSkinMatrix ? (t._bonesTransformMatrices || this.prepare(), t._bonesTransformMatrices) : (this._transformMatrices && !this._isDirty || this.prepare(), this._transformMatrices);
      }, n.prototype.getTransformMatrixTexture = function(t) {
        return this.needInitialSkinMatrix && t._transformMatrixTexture ? t._transformMatrixTexture : this._transformMatrixTexture;
      }, n.prototype.getScene = function() {
        return this._scene;
      }, n.prototype.toString = function(t) {
        var e = "Name: ".concat(this.name, ", nBones: ").concat(this.bones.length);
        if (e += ", nAnimationRanges: ".concat(this._ranges ? Object.keys(this._ranges).length : "none"), t) {
          e += ", Ranges: {";
          var i = !0;
          for (var r in this._ranges)
            i && (e += ", ", i = !1), e += r;
          e += "}";
        }
        return e;
      }, n.prototype.getBoneIndexByName = function(t) {
        for (var e = 0, i = this.bones.length; e < i; e++)
          if (this.bones[e].name === t)
            return e;
        return -1;
      }, n.prototype.createAnimationRange = function(t, e, i) {
        if (!this._ranges[t]) {
          this._ranges[t] = new Zl(t, e, i);
          for (var r = 0, o = this.bones.length; r < o; r++)
            this.bones[r].animations[0] && this.bones[r].animations[0].createRange(t, e, i);
        }
      }, n.prototype.deleteAnimationRange = function(t, e) {
        e === void 0 && (e = !0);
        for (var i = 0, r = this.bones.length; i < r; i++)
          this.bones[i].animations[0] && this.bones[i].animations[0].deleteRange(t, e);
        this._ranges[t] = null;
      }, n.prototype.getAnimationRange = function(t) {
        return this._ranges[t] || null;
      }, n.prototype.getAnimationRanges = function() {
        var t, e = [];
        for (t in this._ranges)
          e.push(this._ranges[t]);
        return e;
      }, n.prototype.copyAnimationRange = function(t, e, i) {
        if (i === void 0 && (i = !1), this._ranges[e] || !t.getAnimationRange(e))
          return !1;
        var r, o, a = !0, s = this._getHighestAnimationFrame() + 1, l = {}, c = t.bones;
        for (o = 0, r = c.length; o < r; o++)
          l[c[o].name] = c[o];
        this.bones.length !== c.length && (q.Warn("copyAnimationRange: this rig has ".concat(this.bones.length, " bones, while source as ").concat(c.length)), a = !1);
        var u = i && this.dimensionsAtRest && t.dimensionsAtRest ? this.dimensionsAtRest.divide(t.dimensionsAtRest) : null;
        for (o = 0, r = this.bones.length; o < r; o++) {
          var h = this.bones[o].name, d = l[h];
          d ? a = a && this.bones[o].copyAnimationRange(d, e, s, i, u) : (q.Warn("copyAnimationRange: not same rig, missing source bone " + h), a = !1);
        }
        var p = t.getAnimationRange(e);
        return p && (this._ranges[e] = new Zl(e, p.from + s, p.to + s)), a;
      }, n.prototype.returnToRest = function() {
        for (var t = 0, e = this.bones; t < e.length; t++) {
          var i = e[t];
          i._index !== -1 && i.returnToRest();
        }
      }, n.prototype._getHighestAnimationFrame = function() {
        for (var t = 0, e = 0, i = this.bones.length; e < i; e++)
          if (this.bones[e].animations[0]) {
            var r = this.bones[e].animations[0].getHighestFrame();
            t < r && (t = r);
          }
        return t;
      }, n.prototype.beginAnimation = function(t, e, i, r) {
        var o = this.getAnimationRange(t);
        return o ? this._scene.beginAnimation(this, o.from, o.to, e, i, r) : null;
      }, n.MakeAnimationAdditive = function(t, e, i) {
        e === void 0 && (e = 0);
        var r = t.getAnimationRange(i);
        if (!r)
          return null;
        for (var o = t._scene.getAllAnimatablesByTarget(t), a = null, s = 0; s < o.length; s++) {
          var l = o[s];
          if (l.fromFrame === (r == null ? void 0 : r.from) && l.toFrame === (r == null ? void 0 : r.to)) {
            a = l;
            break;
          }
        }
        var c = t.getAnimatables();
        for (s = 0; s < c.length; s++) {
          var u = c[s].animations;
          if (u)
            for (var h = 0; h < u.length; h++)
              Je.MakeAnimationAdditive(u[h], e, i);
        }
        return a && (a.isAdditive = !0), t;
      }, n.prototype._markAsDirty = function() {
        this._isDirty = !0, this._absoluteTransformIsDirty = !0;
      }, n.prototype._registerMeshWithPoseMatrix = function(t) {
        this._meshesWithPoseMatrix.push(t);
      }, n.prototype._unregisterMeshWithPoseMatrix = function(t) {
        var e = this._meshesWithPoseMatrix.indexOf(t);
        e > -1 && this._meshesWithPoseMatrix.splice(e, 1);
      }, n.prototype._computeTransformMatrices = function(t, e) {
        this.onBeforeComputeObservable.notifyObservers(this);
        for (var i = 0; i < this.bones.length; i++) {
          var r = this.bones[i];
          r._childUpdateId++;
          var o = r.getParent();
          if (o ? r.getLocalMatrix().multiplyToRef(o.getFinalMatrix(), r.getFinalMatrix()) : e ? r.getLocalMatrix().multiplyToRef(e, r.getFinalMatrix()) : r.getFinalMatrix().copyFrom(r.getLocalMatrix()), r._index !== -1) {
            var a = r._index === null ? i : r._index;
            r.getAbsoluteInverseBindMatrix().multiplyToArray(r.getFinalMatrix(), t, 16 * a);
          }
        }
        this._identity.copyToArray(t, 16 * this.bones.length);
      }, n.prototype.prepare = function(t) {
        if (t === void 0 && (t = !1), !t) {
          var e = this.getScene().getRenderId();
          if (this._currentRenderId === e)
            return;
          this._currentRenderId = e;
        }
        if (this._numBonesWithLinkedTransformNode > 0) {
          for (var i = 0, r = this.bones; i < r.length; i++)
            if ((p = r[i])._linkedTransformNode) {
              var o = p._linkedTransformNode;
              p.position = o.position, o.rotationQuaternion ? p.rotationQuaternion = o.rotationQuaternion : p.rotation = o.rotation, p.scaling = o.scaling;
            }
        }
        if (this.needInitialSkinMatrix)
          for (var a = 0, s = this._meshesWithPoseMatrix; a < s.length; a++) {
            var l = s[a], c = l.getPoseMatrix(), u = this._isDirty;
            if (l._bonesTransformMatrices && l._bonesTransformMatrices.length === 16 * (this.bones.length + 1) || (l._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1)), u = !0), u) {
              if (this._synchronizedWithMesh !== l) {
                this._synchronizedWithMesh = l;
                for (var h = 0, d = this.bones; h < d.length; h++) {
                  var p;
                  (p = d[h]).getParent() || (p.getBindMatrix().multiplyToRef(c, F.Matrix[1]), p._updateAbsoluteBindMatrices(F.Matrix[1]));
                }
                if (this.isUsingTextureForMatrices) {
                  var f = 4 * (this.bones.length + 1);
                  l._transformMatrixTexture && l._transformMatrixTexture.getSize().width === f || (l._transformMatrixTexture && l._transformMatrixTexture.dispose(), l._transformMatrixTexture = on.CreateRGBATexture(l._bonesTransformMatrices, 4 * (this.bones.length + 1), 1, this._scene, !1, !1, _.TEXTURE_NEAREST_SAMPLINGMODE, _.TEXTURETYPE_FLOAT));
                }
              }
              this._computeTransformMatrices(l._bonesTransformMatrices, c), this.isUsingTextureForMatrices && l._transformMatrixTexture && l._transformMatrixTexture.update(l._bonesTransformMatrices);
            }
          }
        else {
          if (!this._isDirty)
            return;
          this._transformMatrices && this._transformMatrices.length === 16 * (this.bones.length + 1) || (this._transformMatrices = new Float32Array(16 * (this.bones.length + 1)), this.isUsingTextureForMatrices && (this._transformMatrixTexture && this._transformMatrixTexture.dispose(), this._transformMatrixTexture = on.CreateRGBATexture(this._transformMatrices, 4 * (this.bones.length + 1), 1, this._scene, !1, !1, _.TEXTURE_NEAREST_SAMPLINGMODE, _.TEXTURETYPE_FLOAT))), this._computeTransformMatrices(this._transformMatrices, null), this.isUsingTextureForMatrices && this._transformMatrixTexture && this._transformMatrixTexture.update(this._transformMatrices);
        }
        this._isDirty = !1;
      }, n.prototype.getAnimatables = function() {
        if (!this._animatables || this._animatables.length !== this.bones.length) {
          this._animatables = [];
          for (var t = 0; t < this.bones.length; t++)
            this._animatables.push(this.bones[t]);
        }
        return this._animatables;
      }, n.prototype.clone = function(t, e) {
        var i = new n(t, e || t, this._scene);
        i.needInitialSkinMatrix = this.needInitialSkinMatrix;
        for (var r = 0; r < this.bones.length; r++) {
          var o = this.bones[r], a = null, s = o.getParent();
          if (s) {
            var l = this.bones.indexOf(s);
            a = i.bones[l];
          }
          var c = new Wu(o.name, i, a, o.getBindMatrix().clone(), o.getRestMatrix().clone());
          c._index = o._index, o._linkedTransformNode && c.linkTransformNode(o._linkedTransformNode), Ui.DeepCopy(o.animations, c.animations);
        }
        if (this._ranges)
          for (var u in i._ranges = {}, this._ranges) {
            var h = this._ranges[u];
            h && (i._ranges[u] = h.clone());
          }
        return this._isDirty = !0, i.prepare(!0), i;
      }, n.prototype.enableBlending = function(t) {
        t === void 0 && (t = 0.01), this.bones.forEach(function(e) {
          e.animations.forEach(function(i) {
            i.enableBlending = !0, i.blendingSpeed = t;
          });
        });
      }, n.prototype.dispose = function() {
        if (this._meshesWithPoseMatrix.length = 0, this.getScene().stopAnimation(this), this.getScene().removeSkeleton(this), this._parentContainer) {
          var t = this._parentContainer.skeletons.indexOf(this);
          t > -1 && this._parentContainer.skeletons.splice(t, 1), this._parentContainer = null;
        }
        this._transformMatrixTexture && (this._transformMatrixTexture.dispose(), this._transformMatrixTexture = null);
      }, n.prototype.serialize = function() {
        var t, e = {};
        e.name = this.name, e.id = this.id, this.dimensionsAtRest && (e.dimensionsAtRest = this.dimensionsAtRest.asArray()), e.bones = [], e.needInitialSkinMatrix = this.needInitialSkinMatrix;
        for (var i = 0; i < this.bones.length; i++) {
          var r = this.bones[i], o = r.getParent(), a = { parentBoneIndex: o ? this.bones.indexOf(o) : -1, index: r.getIndex(), name: r.name, id: r.id, matrix: r.getBindMatrix().toArray(), rest: r.getRestMatrix().toArray(), linkedTransformNodeId: (t = r.getTransformNode()) === null || t === void 0 ? void 0 : t.id };
          for (var s in e.bones.push(a), r.length && (a.length = r.length), r.metadata && (a.metadata = r.metadata), r.animations && r.animations.length > 0 && (a.animation = r.animations[0].serialize()), e.ranges = [], this._ranges) {
            var l = this._ranges[s];
            if (l) {
              var c = {};
              c.name = s, c.from = l.from, c.to = l.to, e.ranges.push(c);
            }
          }
        }
        return e;
      }, n.Parse = function(t, e) {
        var i, r = new n(t.name, t.id, e);
        for (t.dimensionsAtRest && (r.dimensionsAtRest = v.FromArray(t.dimensionsAtRest)), r.needInitialSkinMatrix = t.needInitialSkinMatrix, i = 0; i < t.bones.length; i++) {
          var o = t.bones[i], a = t.bones[i].index, s = null;
          o.parentBoneIndex > -1 && (s = r.bones[o.parentBoneIndex]);
          var l = o.rest ? B.FromArray(o.rest) : null, c = new Wu(o.name, r, s, B.FromArray(o.matrix), l, null, a);
          o.id !== void 0 && o.id !== null && (c.id = o.id), o.length && (c.length = o.length), o.metadata && (c.metadata = o.metadata), o.animation && c.animations.push(Je.Parse(o.animation)), o.linkedTransformNodeId !== void 0 && o.linkedTransformNodeId !== null && (r._hasWaitingData = !0, c._waitingTransformNodeId = o.linkedTransformNodeId);
        }
        if (t.ranges)
          for (i = 0; i < t.ranges.length; i++) {
            var u = t.ranges[i];
            r.createAnimationRange(u.name, u.from, u.to);
          }
        return r;
      }, n.prototype.computeAbsoluteMatrices = function(t) {
        t === void 0 && (t = !1), (this._absoluteTransformIsDirty || t) && (this.bones[0].computeAbsoluteMatrices(), this._absoluteTransformIsDirty = !1);
      }, n.prototype.computeAbsoluteTransforms = function(t) {
        t === void 0 && (t = !1), this.computeAbsoluteMatrices(t);
      }, n.prototype.getPoseMatrix = function() {
        var t = null;
        return this._meshesWithPoseMatrix.length > 0 && (t = this._meshesWithPoseMatrix[0].getPoseMatrix()), t;
      }, n.prototype.sortBones = function() {
        for (var t = [], e = new Array(this.bones.length), i = 0; i < this.bones.length; i++)
          this._sortBones(i, t, e);
        this.bones = t;
      }, n.prototype._sortBones = function(t, e, i) {
        if (!i[t]) {
          i[t] = !0;
          var r = this.bones[t];
          if (r) {
            r._index === void 0 && (r._index = t);
            var o = r.getParent();
            o && this._sortBones(this.bones.indexOf(o), e, i), e.push(r);
          }
        }
      }, n.prototype.setCurrentPoseAsRest = function() {
        this.bones.forEach(function(t) {
          t.setCurrentPoseAsRest();
        });
      }, n;
    }(), Gg = function() {
      function n(t, e, i, r) {
        i === void 0 && (i = _.BUFFER_CREATIONFLAG_READWRITE), this._engine = t, this._label = r, this._engine._storageBuffers.push(this), this._create(e, i);
      }
      return n.prototype._create = function(t, e) {
        this._bufferSize = t, this._creationFlags = e, this._buffer = this._engine.createStorageBuffer(t, e, this._label);
      }, n.prototype._rebuild = function() {
        this._create(this._bufferSize, this._creationFlags);
      }, n.prototype.getBuffer = function() {
        return this._buffer;
      }, n.prototype.update = function(t, e, i) {
        this._buffer && this._engine.updateStorageBuffer(this._buffer, t, e, i);
      }, n.prototype.read = function(t, e, i) {
        return this._engine.readFromStorageBuffer(this._buffer, t, e, i);
      }, n.prototype.dispose = function() {
        var t = this._engine._storageBuffers, e = t.indexOf(this);
        e !== -1 && (t[e] = t[t.length - 1], t.pop()), this._engine._releaseBuffer(this._buffer), this._buffer = null;
      }, n;
    }(), ah = (kg = new Uint8Array(4), !!((new Uint32Array(kg.buffer)[0] = 1) & kg[0]));
    Object.defineProperty(P.prototype, "effectiveByteStride", { get: function() {
      return this._alignedBuffer && this._alignedBuffer.byteStride || this.byteStride;
    }, enumerable: !0, configurable: !0 }), Object.defineProperty(P.prototype, "effectiveByteOffset", { get: function() {
      return this._alignedBuffer ? 0 : this.byteOffset;
    }, enumerable: !0, configurable: !0 }), Object.defineProperty(P.prototype, "effectiveBuffer", { get: function() {
      return this._alignedBuffer && this._alignedBuffer.getBuffer() || this._buffer.getBuffer();
    }, enumerable: !0, configurable: !0 }), P.prototype._rebuild = function() {
      var n, t;
      (n = this._buffer) === null || n === void 0 || n._rebuild(), (t = this._alignedBuffer) === null || t === void 0 || t._rebuild();
    }, P.prototype.dispose = function() {
      var n;
      this._ownsBuffer && this._buffer.dispose(), (n = this._alignedBuffer) === null || n === void 0 || n.dispose(), this._alignedBuffer = void 0, this._isDisposed = !0;
    }, P.prototype._alignBuffer = function() {
      var n, t, e = this._buffer.getData();
      if (this.engine._features.forceVertexBufferStrideMultiple4Bytes && this.byteStride % 4 != 0 && e) {
        var i, r, o = P.GetTypeByteLength(this.type), a = this.byteStride + 3 & -4, s = a / o, l = this.totalVertices, c = l * a / o;
        if (Array.isArray(e)) {
          var u = new Float32Array(e);
          i = new DataView(u.buffer, u.byteOffset, u.byteLength);
        } else
          i = e instanceof ArrayBuffer ? new DataView(e, 0, e.byteLength) : new DataView(e.buffer, e.byteOffset, e.byteLength);
        r = this.type === P.BYTE ? new Int8Array(c) : this.type === P.UNSIGNED_BYTE ? new Uint8Array(c) : this.type === P.SHORT ? new Int16Array(c) : this.type === P.UNSIGNED_SHORT ? new Uint16Array(c) : this.type === P.INT ? new Int32Array(c) : this.type === P.UNSIGNED_INT ? new Uint32Array(c) : new Float32Array(c);
        for (var h = this.getSize(), d = this.byteOffset, p = 0; p < l; ++p) {
          for (var f = 0; f < h; ++f)
            switch (this.type) {
              case P.BYTE:
                r[p * s + f] = i.getInt8(d + f);
                break;
              case P.UNSIGNED_BYTE:
                r[p * s + f] = i.getUint8(d + f);
                break;
              case P.SHORT:
                r[p * s + f] = i.getInt16(d + 2 * f, ah);
                break;
              case P.UNSIGNED_SHORT:
                r[p * s + f] = i.getUint16(d + 2 * f, ah);
                break;
              case P.INT:
                r[p * s + f] = i.getInt32(d + 4 * f, ah);
                break;
              case P.UNSIGNED_INT:
                r[p * s + f] = i.getUint32(d + 4 * f, ah);
                break;
              case P.FLOAT:
                r[p * s + f] = i.getFloat32(d + 4 * f, ah);
            }
          d += this.byteStride;
        }
        (n = this._alignedBuffer) === null || n === void 0 || n.dispose(), this._alignedBuffer = new Yi(this.engine, r, !1, a, !1, this.getIsInstanced(), !0, this.instanceDivisor, ((t = this._label) !== null && t !== void 0 ? t : "VertexBuffer") + "_aligned");
      }
    };
    var zg = function() {
      function n() {
        this.wheelPrecisionX = 3, this.wheelPrecisionY = 3, this.wheelPrecisionZ = 3, this.onChangedObservable = new H(), this._wheelDeltaX = 0, this._wheelDeltaY = 0, this._wheelDeltaZ = 0, this._ffMultiplier = 12, this._normalize = 120;
      }
      return n.prototype.attachControl = function(t) {
        var e = this;
        t = de.BackCompatCameraNoPreventDefault(arguments), this._wheel = function(i) {
          if (i.type === Le.POINTERWHEEL) {
            var r = i.event, o = r.deltaMode === zu.DOM_DELTA_LINE ? e._ffMultiplier : 1;
            e._wheelDeltaX += e.wheelPrecisionX * o * r.deltaX / e._normalize, e._wheelDeltaY -= e.wheelPrecisionY * o * r.deltaY / e._normalize, e._wheelDeltaZ += e.wheelPrecisionZ * o * r.deltaZ / e._normalize, r.preventDefault && (t || r.preventDefault());
          }
        }, this._observer = this.camera.getScene()._inputManager._addCameraPointerObserver(this._wheel, Le.POINTERWHEEL);
      }, n.prototype.detachControl = function() {
        this._observer && (this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer), this._observer = null, this._wheel = null), this.onChangedObservable && this.onChangedObservable.clear();
      }, n.prototype.checkInputs = function() {
        this.onChangedObservable.notifyObservers({ wheelDeltaX: this._wheelDeltaX, wheelDeltaY: this._wheelDeltaY, wheelDeltaZ: this._wheelDeltaZ }), this._wheelDeltaX = 0, this._wheelDeltaY = 0, this._wheelDeltaZ = 0;
      }, n.prototype.getClassName = function() {
        return "BaseCameraMouseWheelInput";
      }, n.prototype.getSimpleName = function() {
        return "mousewheel";
      }, x([N()], n.prototype, "wheelPrecisionX", void 0), x([N()], n.prototype, "wheelPrecisionY", void 0), x([N()], n.prototype, "wheelPrecisionZ", void 0), n;
    }(), Wp = function() {
      function n() {
        this._currentActiveButton = -1, this.buttons = [0, 1, 2];
      }
      return n.prototype.attachControl = function(t) {
        var e = this;
        t = de.BackCompatCameraNoPreventDefault(arguments);
        var i = this.camera.getEngine(), r = i.getInputElement(), o = 0, a = null;
        this._pointA = null, this._pointB = null, this._altKey = !1, this._ctrlKey = !1, this._metaKey = !1, this._shiftKey = !1, this._buttonsPressed = 0, this._pointerInput = function(l) {
          var c, u, h = l.event, d = h.pointerType === "touch";
          if (l.type === Le.POINTERMOVE || e.buttons.indexOf(h.button) !== -1) {
            var p = h.target;
            if (e._altKey = h.altKey, e._ctrlKey = h.ctrlKey, e._metaKey = h.metaKey, e._shiftKey = h.shiftKey, e._buttonsPressed = h.buttons, i.isPointerLock) {
              var f = h.movementX, m = h.movementY;
              e.onTouch(null, f, m), e._pointA = null, e._pointB = null;
            } else {
              if (l.type !== Le.POINTERDOWN && d && ((c = e._pointA) === null || c === void 0 ? void 0 : c.pointerId) !== h.pointerId && ((u = e._pointB) === null || u === void 0 ? void 0 : u.pointerId) !== h.pointerId)
                return;
              if (l.type !== Le.POINTERDOWN || e._currentActiveButton !== -1 && !d)
                if (l.type === Le.POINTERDOUBLETAP)
                  e.onDoubleTap(h.pointerType);
                else if (l.type !== Le.POINTERUP || e._currentActiveButton !== h.button && !d) {
                  if (l.type === Le.POINTERMOVE) {
                    if (t || h.preventDefault(), e._pointA && e._pointB === null)
                      f = h.clientX - e._pointA.x, m = h.clientY - e._pointA.y, e.onTouch(e._pointA, f, m), e._pointA.x = h.clientX, e._pointA.y = h.clientY;
                    else if (e._pointA && e._pointB) {
                      var g = e._pointA.pointerId === h.pointerId ? e._pointA : e._pointB;
                      g.x = h.clientX, g.y = h.clientY;
                      var y = e._pointA.x - e._pointB.x, b = e._pointA.y - e._pointB.y, T = y * y + b * b, S = { x: (e._pointA.x + e._pointB.x) / 2, y: (e._pointA.y + e._pointB.y) / 2, pointerId: h.pointerId, type: l.type };
                      e.onMultiTouch(e._pointA, e._pointB, o, T, a, S), a = S, o = T;
                    }
                  }
                } else {
                  try {
                    p == null || p.releasePointerCapture(h.pointerId);
                  } catch {
                  }
                  d || (e._pointB = null), i._badOS ? e._pointA = e._pointB = null : e._pointB && e._pointA && e._pointA.pointerId == h.pointerId ? (e._pointA = e._pointB, e._pointB = null) : e._pointA && e._pointB && e._pointB.pointerId == h.pointerId ? e._pointB = null : e._pointA = e._pointB = null, (o !== 0 || a) && (e.onMultiTouch(e._pointA, e._pointB, o, 0, a, null), o = 0, a = null), e._currentActiveButton = -1, e.onButtonUp(h), t || h.preventDefault();
                }
              else {
                try {
                  p == null || p.setPointerCapture(h.pointerId);
                } catch {
                }
                if (e._pointA === null)
                  e._pointA = { x: h.clientX, y: h.clientY, pointerId: h.pointerId, type: h.pointerType };
                else {
                  if (e._pointB !== null)
                    return;
                  e._pointB = { x: h.clientX, y: h.clientY, pointerId: h.pointerId, type: h.pointerType };
                }
                e._currentActiveButton !== -1 || d || (e._currentActiveButton = h.button), e.onButtonDown(h), t || (h.preventDefault(), r && r.focus());
              }
            }
          }
        }, this._observer = this.camera.getScene()._inputManager._addCameraPointerObserver(this._pointerInput, Le.POINTERDOWN | Le.POINTERUP | Le.POINTERMOVE | Le.POINTERDOUBLETAP), this._onLostFocus = function() {
          e._pointA = e._pointB = null, o = 0, a = null, e.onLostFocus();
        }, this._contextMenuBind = function(l) {
          return e.onContextMenu(l);
        }, r && r.addEventListener("contextmenu", this._contextMenuBind, !1);
        var s = this.camera.getScene().getEngine().getHostWindow();
        s && de.RegisterTopRootEvents(s, [{ name: "blur", handler: this._onLostFocus }]);
      }, n.prototype.detachControl = function() {
        if (this._onLostFocus) {
          var t = this.camera.getScene().getEngine().getHostWindow();
          t && de.UnregisterTopRootEvents(t, [{ name: "blur", handler: this._onLostFocus }]);
        }
        if (this._observer) {
          if (this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer), this._observer = null, this._contextMenuBind) {
            var e = this.camera.getScene().getEngine().getInputElement();
            e && e.removeEventListener("contextmenu", this._contextMenuBind);
          }
          this._onLostFocus = null;
        }
        this._altKey = !1, this._ctrlKey = !1, this._metaKey = !1, this._shiftKey = !1, this._buttonsPressed = 0, this._currentActiveButton = -1;
      }, n.prototype.getClassName = function() {
        return "BaseCameraPointersInput";
      }, n.prototype.getSimpleName = function() {
        return "pointers";
      }, n.prototype.onDoubleTap = function(t) {
      }, n.prototype.onTouch = function(t, e, i) {
      }, n.prototype.onMultiTouch = function(t, e, i, r, o, a) {
      }, n.prototype.onContextMenu = function(t) {
        t.preventDefault();
      }, n.prototype.onButtonDown = function(t) {
      }, n.prototype.onButtonUp = function(t) {
      }, n.prototype.onLostFocus = function() {
      }, x([N()], n.prototype, "buttons", void 0), n;
    }(), gn = {}, yc = function() {
      function n(t) {
        this.attachedToElement = !1, this.attached = {}, this.camera = t, this.checkInputs = function() {
        };
      }
      return n.prototype.add = function(t) {
        var e = t.getSimpleName();
        this.attached[e] ? q.Warn("camera input of type " + e + " already exists on camera") : (this.attached[e] = t, t.camera = this.camera, t.checkInputs && (this.checkInputs = this._addCheckInputs(t.checkInputs.bind(t))), this.attachedToElement && t.attachControl(this.noPreventDefault));
      }, n.prototype.remove = function(t) {
        for (var e in this.attached) {
          var i = this.attached[e];
          if (i === t)
            return i.detachControl(), i.camera = null, delete this.attached[e], void this.rebuildInputCheck();
        }
      }, n.prototype.removeByType = function(t) {
        for (var e in this.attached) {
          var i = this.attached[e];
          i.getClassName() === t && (i.detachControl(), i.camera = null, delete this.attached[e], this.rebuildInputCheck());
        }
      }, n.prototype._addCheckInputs = function(t) {
        var e = this.checkInputs;
        return function() {
          e(), t();
        };
      }, n.prototype.attachInput = function(t) {
        this.attachedToElement && t.attachControl(this.noPreventDefault);
      }, n.prototype.attachElement = function(t) {
        if (t === void 0 && (t = !1), !this.attachedToElement)
          for (var e in t = !dt.ForceAttachControlToAlwaysPreventDefault && t, this.attachedToElement = !0, this.noPreventDefault = t, this.attached)
            this.attached[e].attachControl(t);
      }, n.prototype.detachElement = function(t) {
        for (var e in t === void 0 && (t = !1), this.attached)
          this.attached[e].detachControl(), t && (this.attached[e].camera = null);
        this.attachedToElement = !1;
      }, n.prototype.rebuildInputCheck = function() {
        for (var t in this.checkInputs = function() {
        }, this.attached) {
          var e = this.attached[t];
          e.checkInputs && (this.checkInputs = this._addCheckInputs(e.checkInputs.bind(e)));
        }
      }, n.prototype.clear = function() {
        this.attachedToElement && this.detachElement(!0), this.attached = {}, this.attachedToElement = !1, this.checkInputs = function() {
        };
      }, n.prototype.serialize = function(t) {
        var e = {};
        for (var i in this.attached) {
          var r = this.attached[i], o = Ne.Serialize(r);
          e[r.getClassName()] = o;
        }
        t.inputsmgr = e;
      }, n.prototype.parse = function(t) {
        var e = t.inputsmgr;
        if (e) {
          this.clear();
          var i = function(l) {
            var c = gn[l];
            if (c) {
              var u = e[l], h = Ne.Parse(function() {
                return new c();
              }, u, null);
              r.add(h);
            }
          }, r = this;
          for (var o in e)
            i(o);
        } else {
          var a = function(l) {
            var c = gn[s.attached[l].getClassName()];
            if (c) {
              var u = Ne.Parse(function() {
                return new c();
              }, t, null);
              s.remove(s.attached[l]), s.add(u);
            }
          }, s = this;
          for (var o in this.attached)
            a(o);
        }
      }, n;
    }(), FR = function(n, t) {
      this.x = n, this.y = t;
    }, qn = function() {
      function n(t, e, i, r, o, a, s) {
        r === void 0 && (r = 0), o === void 0 && (o = 1), a === void 0 && (a = 2), s === void 0 && (s = 3), this.id = t, this.index = e, this.browserGamepad = i, this._leftStick = { x: 0, y: 0 }, this._rightStick = { x: 0, y: 0 }, this._isConnected = !0, this._invertLeftStickY = !1, this.type = n.GAMEPAD, this._leftStickAxisX = r, this._leftStickAxisY = o, this._rightStickAxisX = a, this._rightStickAxisY = s, this.browserGamepad.axes.length >= 2 && (this._leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] }), this.browserGamepad.axes.length >= 4 && (this._rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] });
      }
      return Object.defineProperty(n.prototype, "isConnected", { get: function() {
        return this._isConnected;
      }, enumerable: !1, configurable: !0 }), n.prototype.onleftstickchanged = function(t) {
        this._onleftstickchanged = t;
      }, n.prototype.onrightstickchanged = function(t) {
        this._onrightstickchanged = t;
      }, Object.defineProperty(n.prototype, "leftStick", { get: function() {
        return this._leftStick;
      }, set: function(t) {
        !this._onleftstickchanged || this._leftStick.x === t.x && this._leftStick.y === t.y || this._onleftstickchanged(t), this._leftStick = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "rightStick", { get: function() {
        return this._rightStick;
      }, set: function(t) {
        !this._onrightstickchanged || this._rightStick.x === t.x && this._rightStick.y === t.y || this._onrightstickchanged(t), this._rightStick = t;
      }, enumerable: !1, configurable: !0 }), n.prototype.update = function() {
        this._leftStick && (this.leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] }, this._invertLeftStickY && (this.leftStick.y *= -1)), this._rightStick && (this.rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] });
      }, n.prototype.dispose = function() {
      }, n.GAMEPAD = 0, n.GENERIC = 1, n.XBOX = 2, n.POSE_ENABLED = 3, n.DUALSHOCK = 4, n;
    }(), Wg = function(n) {
      function t(e, i, r) {
        var o = n.call(this, e, i, r) || this;
        return o.onButtonDownObservable = new H(), o.onButtonUpObservable = new H(), o.type = qn.GENERIC, o._buttons = new Array(r.buttons.length), o;
      }
      return D(t, n), t.prototype.onbuttondown = function(e) {
        this._onbuttondown = e;
      }, t.prototype.onbuttonup = function(e) {
        this._onbuttonup = e;
      }, t.prototype._setButtonValue = function(e, i, r) {
        return e !== i && (e === 1 && (this._onbuttondown && this._onbuttondown(r), this.onButtonDownObservable.notifyObservers(r)), e === 0 && (this._onbuttonup && this._onbuttonup(r), this.onButtonUpObservable.notifyObservers(r))), e;
      }, t.prototype.update = function() {
        n.prototype.update.call(this);
        for (var e = 0; e < this._buttons.length; e++)
          this._buttons[e] = this._setButtonValue(this.browserGamepad.buttons[e].value, this._buttons[e], e);
      }, t.prototype.dispose = function() {
        n.prototype.dispose.call(this), this.onButtonDownObservable.clear(), this.onButtonUpObservable.clear();
      }, t;
    }(qn), Hp = function() {
      function n() {
        this.gamepadRotationSensibility = 80, this.gamepadMoveSensibility = 40, this._yAxisScale = 1;
      }
      return Object.defineProperty(n.prototype, "invertYAxis", { get: function() {
        return this._yAxisScale !== 1;
      }, set: function(t) {
        this._yAxisScale = t ? -1 : 1;
      }, enumerable: !1, configurable: !0 }), n.prototype.attachControl = function() {
        var t = this, e = this.camera.getScene().gamepadManager;
        this._onGamepadConnectedObserver = e.onGamepadConnectedObservable.add(function(i) {
          i.type !== qn.POSE_ENABLED && (t.gamepad && i.type !== qn.XBOX || (t.gamepad = i));
        }), this._onGamepadDisconnectedObserver = e.onGamepadDisconnectedObservable.add(function(i) {
          t.gamepad === i && (t.gamepad = null);
        }), this.gamepad = e.getGamepadByType(qn.XBOX);
      }, n.prototype.detachControl = function() {
        this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver), this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver), this.gamepad = null;
      }, n.prototype.checkInputs = function() {
        if (this.gamepad) {
          var t = this.camera, e = this.gamepad.rightStick;
          if (e) {
            if (e.x != 0) {
              var i = e.x / this.gamepadRotationSensibility;
              i != 0 && Math.abs(i) > 5e-3 && (t.inertialAlphaOffset += i);
            }
            if (e.y != 0) {
              var r = e.y / this.gamepadRotationSensibility * this._yAxisScale;
              r != 0 && Math.abs(r) > 5e-3 && (t.inertialBetaOffset += r);
            }
          }
          var o = this.gamepad.leftStick;
          if (o && o.y != 0) {
            var a = o.y / this.gamepadMoveSensibility;
            a != 0 && Math.abs(a) > 5e-3 && (this.camera.inertialRadiusOffset -= a);
          }
        }
      }, n.prototype.getClassName = function() {
        return "ArcRotateCameraGamepadInput";
      }, n.prototype.getSimpleName = function() {
        return "gamepad";
      }, x([N()], n.prototype, "gamepadRotationSensibility", void 0), x([N()], n.prototype, "gamepadMoveSensibility", void 0), n;
    }();
    gn.ArcRotateCameraGamepadInput = Hp;
    var Xp = function() {
      function n() {
        this.keysUp = [38], this.keysDown = [40], this.keysLeft = [37], this.keysRight = [39], this.keysReset = [220], this.panningSensibility = 50, this.zoomingSensibility = 25, this.useAltToZoom = !0, this.angularSpeed = 0.01, this._keys = new Array();
      }
      return n.prototype.attachControl = function(t) {
        var e = this;
        t = de.BackCompatCameraNoPreventDefault(arguments), this._onCanvasBlurObserver || (this._scene = this.camera.getScene(), this._engine = this._scene.getEngine(), this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function() {
          e._keys.length = 0;
        }), this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function(i) {
          var r, o = i.event;
          o.metaKey || (i.type === ps.KEYDOWN ? (e._ctrlPressed = o.ctrlKey, e._altPressed = o.altKey, (e.keysUp.indexOf(o.keyCode) !== -1 || e.keysDown.indexOf(o.keyCode) !== -1 || e.keysLeft.indexOf(o.keyCode) !== -1 || e.keysRight.indexOf(o.keyCode) !== -1 || e.keysReset.indexOf(o.keyCode) !== -1) && ((r = e._keys.indexOf(o.keyCode)) === -1 && e._keys.push(o.keyCode), o.preventDefault && (t || o.preventDefault()))) : e.keysUp.indexOf(o.keyCode) === -1 && e.keysDown.indexOf(o.keyCode) === -1 && e.keysLeft.indexOf(o.keyCode) === -1 && e.keysRight.indexOf(o.keyCode) === -1 && e.keysReset.indexOf(o.keyCode) === -1 || ((r = e._keys.indexOf(o.keyCode)) >= 0 && e._keys.splice(r, 1), o.preventDefault && (t || o.preventDefault())));
        }));
      }, n.prototype.detachControl = function() {
        this._scene && (this._onKeyboardObserver && this._scene.onKeyboardObservable.remove(this._onKeyboardObserver), this._onCanvasBlurObserver && this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver), this._onKeyboardObserver = null, this._onCanvasBlurObserver = null), this._keys.length = 0;
      }, n.prototype.checkInputs = function() {
        if (this._onKeyboardObserver)
          for (var t = this.camera, e = 0; e < this._keys.length; e++) {
            var i = this._keys[e];
            this.keysLeft.indexOf(i) !== -1 ? this._ctrlPressed && this.camera._useCtrlForPanning ? t.inertialPanningX -= 1 / this.panningSensibility : t.inertialAlphaOffset -= this.angularSpeed : this.keysUp.indexOf(i) !== -1 ? this._ctrlPressed && this.camera._useCtrlForPanning ? t.inertialPanningY += 1 / this.panningSensibility : this._altPressed && this.useAltToZoom ? t.inertialRadiusOffset += 1 / this.zoomingSensibility : t.inertialBetaOffset -= this.angularSpeed : this.keysRight.indexOf(i) !== -1 ? this._ctrlPressed && this.camera._useCtrlForPanning ? t.inertialPanningX += 1 / this.panningSensibility : t.inertialAlphaOffset += this.angularSpeed : this.keysDown.indexOf(i) !== -1 ? this._ctrlPressed && this.camera._useCtrlForPanning ? t.inertialPanningY -= 1 / this.panningSensibility : this._altPressed && this.useAltToZoom ? t.inertialRadiusOffset -= 1 / this.zoomingSensibility : t.inertialBetaOffset += this.angularSpeed : this.keysReset.indexOf(i) !== -1 && t.useInputToRestoreState && t.restoreState();
          }
      }, n.prototype.getClassName = function() {
        return "ArcRotateCameraKeyboardMoveInput";
      }, n.prototype.getSimpleName = function() {
        return "keyboard";
      }, x([N()], n.prototype, "keysUp", void 0), x([N()], n.prototype, "keysDown", void 0), x([N()], n.prototype, "keysLeft", void 0), x([N()], n.prototype, "keysRight", void 0), x([N()], n.prototype, "keysReset", void 0), x([N()], n.prototype, "panningSensibility", void 0), x([N()], n.prototype, "zoomingSensibility", void 0), x([N()], n.prototype, "useAltToZoom", void 0), x([N()], n.prototype, "angularSpeed", void 0), n;
    }();
    gn.ArcRotateCameraKeyboardMoveInput = Xp;
    var jp = function() {
      function n() {
        this.wheelPrecision = 3, this.zoomToMouseLocation = !1, this.wheelDeltaPercentage = 0, this.customComputeDeltaFromMouseWheel = null, this._viewOffset = new v(0, 0, 0), this._globalOffset = new v(0, 0, 0), this._inertialPanning = v.Zero();
      }
      return n.prototype._computeDeltaFromMouseWheelLegacyEvent = function(t, e) {
        var i = 0.01 * t * this.wheelDeltaPercentage * e;
        return t > 0 ? i / (1 + this.wheelDeltaPercentage) : i * (1 + this.wheelDeltaPercentage);
      }, n.prototype.attachControl = function(t) {
        var e = this;
        t = de.BackCompatCameraNoPreventDefault(arguments), this._wheel = function(i) {
          if (i.type === Le.POINTERWHEEL) {
            var r = i.event, o = 0, a = r.deltaMode === zu.DOM_DELTA_LINE ? 40 : 1, s = -r.deltaY * a;
            if (e.customComputeDeltaFromMouseWheel)
              o = e.customComputeDeltaFromMouseWheel(s, e, r);
            else if (e.wheelDeltaPercentage) {
              if ((o = e._computeDeltaFromMouseWheelLegacyEvent(s, e.camera.radius)) > 0) {
                for (var l = e.camera.radius, c = e.camera.inertialRadiusOffset + o, u = 0; u < 20 && Math.abs(c) > 1e-3; u++)
                  l -= c, c *= e.camera.inertia;
                l = ue.Clamp(l, 0, Number.MAX_VALUE), o = e._computeDeltaFromMouseWheelLegacyEvent(s, l);
              }
            } else
              o = s / (40 * e.wheelPrecision);
            o && (e.zoomToMouseLocation ? (e._hitPlane || e._updateHitPlane(), e._zoomToMouse(o)) : e.camera.inertialRadiusOffset += o), r.preventDefault && (t || r.preventDefault());
          }
        }, this._observer = this.camera.getScene()._inputManager._addCameraPointerObserver(this._wheel, Le.POINTERWHEEL), this.zoomToMouseLocation && this._inertialPanning.setAll(0);
      }, n.prototype.detachControl = function() {
        this._observer && (this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer), this._observer = null, this._wheel = null);
      }, n.prototype.checkInputs = function() {
        if (this.zoomToMouseLocation) {
          var t = this.camera;
          0 + t.inertialAlphaOffset + t.inertialBetaOffset + t.inertialRadiusOffset && (this._updateHitPlane(), t.target.addInPlace(this._inertialPanning), this._inertialPanning.scaleInPlace(t.inertia), this._zeroIfClose(this._inertialPanning));
        }
      }, n.prototype.getClassName = function() {
        return "ArcRotateCameraMouseWheelInput";
      }, n.prototype.getSimpleName = function() {
        return "mousewheel";
      }, n.prototype._updateHitPlane = function() {
        var t = this.camera, e = t.target.subtract(t.position);
        this._hitPlane = xo.FromPositionAndNormal(t.target, e);
      }, n.prototype._getPosition = function() {
        var t, e = this.camera, i = e.getScene(), r = i.createPickingRay(i.pointerX, i.pointerY, B.Identity(), e, !1);
        e.targetScreenOffset.x === 0 && e.targetScreenOffset.y === 0 || (this._viewOffset.set(e.targetScreenOffset.x, e.targetScreenOffset.y, 0), e.getViewMatrix().invertToRef(e._cameraTransformMatrix), this._globalOffset = v.TransformNormal(this._viewOffset, e._cameraTransformMatrix), r.origin.addInPlace(this._globalOffset));
        var o = 0;
        return this._hitPlane && (o = (t = r.intersectsPlane(this._hitPlane)) !== null && t !== void 0 ? t : 0), r.origin.addInPlace(r.direction.scaleInPlace(o));
      }, n.prototype._zoomToMouse = function(t) {
        var e, i, r = this.camera, o = 1 - r.inertia;
        if (r.lowerRadiusLimit) {
          var a = (e = r.lowerRadiusLimit) !== null && e !== void 0 ? e : 0;
          r.radius - (r.inertialRadiusOffset + t) / o < a && (t = (r.radius - a) * o - r.inertialRadiusOffset);
        }
        if (r.upperRadiusLimit) {
          var s = (i = r.upperRadiusLimit) !== null && i !== void 0 ? i : 0;
          r.radius - (r.inertialRadiusOffset + t) / o > s && (t = (r.radius - s) * o - r.inertialRadiusOffset);
        }
        var l = t / o / r.radius, c = this._getPosition(), u = F.Vector3[6];
        c.subtractToRef(r.target, u), u.scaleInPlace(l), u.scaleInPlace(o), this._inertialPanning.addInPlace(u), r.inertialRadiusOffset += t;
      }, n.prototype._zeroIfClose = function(t) {
        Math.abs(t.x) < Ge && (t.x = 0), Math.abs(t.y) < Ge && (t.y = 0), Math.abs(t.z) < Ge && (t.z = 0);
      }, x([N()], n.prototype, "wheelPrecision", void 0), x([N()], n.prototype, "zoomToMouseLocation", void 0), x([N()], n.prototype, "wheelDeltaPercentage", void 0), n;
    }();
    gn.ArcRotateCameraMouseWheelInput = jp;
    var Yp = function(n) {
      function t() {
        var e = n !== null && n.apply(this, arguments) || this;
        return e.buttons = [0, 1, 2], e.angularSensibilityX = 1e3, e.angularSensibilityY = 1e3, e.pinchPrecision = 12, e.pinchDeltaPercentage = 0, e.useNaturalPinchZoom = !1, e.pinchZoom = !0, e.panningSensibility = 1e3, e.multiTouchPanning = !0, e.multiTouchPanAndZoom = !0, e.pinchInwards = !0, e._isPanClick = !1, e._twoFingerActivityCount = 0, e._isPinching = !1, e;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ArcRotateCameraPointersInput";
      }, t.prototype._computeMultiTouchPanning = function(e, i) {
        if (this.panningSensibility !== 0 && e && i) {
          var r = i.x - e.x, o = i.y - e.y;
          this.camera.inertialPanningX += -r / this.panningSensibility, this.camera.inertialPanningY += o / this.panningSensibility;
        }
      }, t.prototype._computePinchZoom = function(e, i) {
        var r = this.camera.radius || t.MinimumRadiusForPinch;
        this.useNaturalPinchZoom ? this.camera.radius = r * Math.sqrt(e) / Math.sqrt(i) : this.pinchDeltaPercentage ? this.camera.inertialRadiusOffset += 1e-3 * (i - e) * r * this.pinchDeltaPercentage : this.camera.inertialRadiusOffset += (i - e) / (this.pinchPrecision * (this.pinchInwards ? 1 : -1) * (this.angularSensibilityX + this.angularSensibilityY) / 2);
      }, t.prototype.onTouch = function(e, i, r) {
        this.panningSensibility !== 0 && (this._ctrlKey && this.camera._useCtrlForPanning || this._isPanClick) ? (this.camera.inertialPanningX += -i / this.panningSensibility, this.camera.inertialPanningY += r / this.panningSensibility) : (this.camera.inertialAlphaOffset -= i / this.angularSensibilityX, this.camera.inertialBetaOffset -= r / this.angularSensibilityY);
      }, t.prototype.onDoubleTap = function() {
        this.camera.useInputToRestoreState && this.camera.restoreState();
      }, t.prototype.onMultiTouch = function(e, i, r, o, a, s) {
        r === 0 && a === null || o === 0 && s === null || (this.multiTouchPanAndZoom ? (this._computePinchZoom(r, o), this._computeMultiTouchPanning(a, s)) : this.multiTouchPanning && this.pinchZoom ? (this._twoFingerActivityCount++, this._isPinching || this._twoFingerActivityCount < 20 && Math.abs(Math.sqrt(o) - Math.sqrt(r)) > this.camera.pinchToPanMaxDistance ? (this._computePinchZoom(r, o), this._isPinching = !0) : this._computeMultiTouchPanning(a, s)) : this.multiTouchPanning ? this._computeMultiTouchPanning(a, s) : this.pinchZoom && this._computePinchZoom(r, o));
      }, t.prototype.onButtonDown = function(e) {
        this._isPanClick = e.button === this.camera._panningMouseButton;
      }, t.prototype.onButtonUp = function(e) {
        this._twoFingerActivityCount = 0, this._isPinching = !1;
      }, t.prototype.onLostFocus = function() {
        this._isPanClick = !1, this._twoFingerActivityCount = 0, this._isPinching = !1;
      }, t.MinimumRadiusForPinch = 1e-3, x([N()], t.prototype, "buttons", void 0), x([N()], t.prototype, "angularSensibilityX", void 0), x([N()], t.prototype, "angularSensibilityY", void 0), x([N()], t.prototype, "pinchPrecision", void 0), x([N()], t.prototype, "pinchDeltaPercentage", void 0), x([N()], t.prototype, "useNaturalPinchZoom", void 0), x([N()], t.prototype, "pinchZoom", void 0), x([N()], t.prototype, "panningSensibility", void 0), x([N()], t.prototype, "multiTouchPanning", void 0), x([N()], t.prototype, "multiTouchPanAndZoom", void 0), t;
    }(Wp);
    gn.ArcRotateCameraPointersInput = Yp;
    var sh = function(n) {
      function t(e) {
        return n.call(this, e) || this;
      }
      return D(t, n), t.prototype.addMouseWheel = function() {
        return this.add(new jp()), this;
      }, t.prototype.addPointers = function() {
        return this.add(new Yp()), this;
      }, t.prototype.addKeyboard = function() {
        return this.add(new Xp()), this;
      }, t;
    }(yc);
    sh.prototype.addVRDeviceOrientation = function() {
      return this.add(new Kp()), this;
    };
    var Kp = function() {
      function n() {
        var t = this;
        this.alphaCorrection = 1, this.gammaCorrection = 1, this._alpha = 0, this._gamma = 0, this._dirty = !1, this._deviceOrientationHandler = function(e) {
          return t._onOrientationEvent(e);
        };
      }
      return n.prototype.attachControl = function(t) {
        var e = this;
        t = de.BackCompatCameraNoPreventDefault(arguments), this.camera.attachControl(t);
        var i = this.camera.getScene().getEngine().getHostWindow();
        i && (typeof DeviceOrientationEvent < "u" && typeof DeviceOrientationEvent.requestPermission == "function" ? DeviceOrientationEvent.requestPermission().then(function(r) {
          r === "granted" ? i.addEventListener("deviceorientation", e._deviceOrientationHandler) : de.Warn("Permission not granted.");
        }).catch(function(r) {
          de.Error(r);
        }) : i.addEventListener("deviceorientation", this._deviceOrientationHandler));
      }, n.prototype._onOrientationEvent = function(t) {
        t.alpha !== null && (this._alpha = (0 | +t.alpha) * this.alphaCorrection), t.gamma !== null && (this._gamma = (0 | +t.gamma) * this.gammaCorrection), this._dirty = !0;
      }, n.prototype.checkInputs = function() {
        this._dirty && (this._dirty = !1, this._gamma < 0 && (this._gamma = 180 + this._gamma), this.camera.alpha = -this._alpha / 180 * Math.PI % Math.PI * 2, this.camera.beta = this._gamma / 180 * Math.PI);
      }, n.prototype.detachControl = function() {
        window.removeEventListener("deviceorientation", this._deviceOrientationHandler);
      }, n.prototype.getClassName = function() {
        return "ArcRotateCameraVRDeviceOrientationInput";
      }, n.prototype.getSimpleName = function() {
        return "VRDeviceOrientation";
      }, n;
    }();
    gn.ArcRotateCameraVRDeviceOrientationInput = Kp;
    var qp = function() {
      function n() {
        this.keysForward = [87], this.keysBackward = [83], this.keysUp = [69], this.keysDown = [81], this.keysRight = [68], this.keysLeft = [65], this._keys = new Array();
      }
      return n.prototype.attachControl = function(t) {
        var e = this;
        t = de.BackCompatCameraNoPreventDefault(arguments), this._onCanvasBlurObserver || (this._scene = this.camera.getScene(), this._engine = this._scene.getEngine(), this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function() {
          e._keys.length = 0;
        }), this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function(i) {
          var r, o = i.event;
          i.type === ps.KEYDOWN ? e.keysForward.indexOf(o.keyCode) === -1 && e.keysBackward.indexOf(o.keyCode) === -1 && e.keysUp.indexOf(o.keyCode) === -1 && e.keysDown.indexOf(o.keyCode) === -1 && e.keysLeft.indexOf(o.keyCode) === -1 && e.keysRight.indexOf(o.keyCode) === -1 || ((r = e._keys.indexOf(o.keyCode)) === -1 && e._keys.push(o.keyCode), t || o.preventDefault()) : e.keysForward.indexOf(o.keyCode) === -1 && e.keysBackward.indexOf(o.keyCode) === -1 && e.keysUp.indexOf(o.keyCode) === -1 && e.keysDown.indexOf(o.keyCode) === -1 && e.keysLeft.indexOf(o.keyCode) === -1 && e.keysRight.indexOf(o.keyCode) === -1 || ((r = e._keys.indexOf(o.keyCode)) >= 0 && e._keys.splice(r, 1), t || o.preventDefault());
        }));
      }, n.prototype.detachControl = function() {
        this._scene && (this._onKeyboardObserver && this._scene.onKeyboardObservable.remove(this._onKeyboardObserver), this._onCanvasBlurObserver && this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver), this._onKeyboardObserver = null, this._onCanvasBlurObserver = null), this._keys.length = 0;
      }, n.prototype.getClassName = function() {
        return "FlyCameraKeyboardInput";
      }, n.prototype._onLostFocus = function() {
        this._keys.length = 0;
      }, n.prototype.getSimpleName = function() {
        return "keyboard";
      }, n.prototype.checkInputs = function() {
        if (this._onKeyboardObserver)
          for (var t = this.camera, e = 0; e < this._keys.length; e++) {
            var i = this._keys[e], r = t._computeLocalCameraSpeed();
            this.keysForward.indexOf(i) !== -1 ? t._localDirection.copyFromFloats(0, 0, r) : this.keysBackward.indexOf(i) !== -1 ? t._localDirection.copyFromFloats(0, 0, -r) : this.keysUp.indexOf(i) !== -1 ? t._localDirection.copyFromFloats(0, r, 0) : this.keysDown.indexOf(i) !== -1 ? t._localDirection.copyFromFloats(0, -r, 0) : this.keysRight.indexOf(i) !== -1 ? t._localDirection.copyFromFloats(r, 0, 0) : this.keysLeft.indexOf(i) !== -1 && t._localDirection.copyFromFloats(-r, 0, 0), t.getScene().useRightHandedSystem && (t._localDirection.z *= -1), t.getViewMatrix().invertToRef(t._cameraTransformMatrix), v.TransformNormalToRef(t._localDirection, t._cameraTransformMatrix, t._transformedDirection), t.cameraDirection.addInPlace(t._transformedDirection);
          }
      }, x([N()], n.prototype, "keysForward", void 0), x([N()], n.prototype, "keysBackward", void 0), x([N()], n.prototype, "keysUp", void 0), x([N()], n.prototype, "keysDown", void 0), x([N()], n.prototype, "keysRight", void 0), x([N()], n.prototype, "keysLeft", void 0), n;
    }();
    gn.FlyCameraKeyboardInput = qp;
    var Qp = function() {
      function n() {
        this.buttons = [0, 1, 2], this.buttonsYaw = [-1, 0, 1], this.buttonsPitch = [-1, 0, 1], this.buttonsRoll = [2], this.activeButton = -1, this.angularSensibility = 1e3, this._previousPosition = null;
      }
      return n.prototype.attachControl = function(t) {
        var e = this;
        t = de.BackCompatCameraNoPreventDefault(arguments), this._noPreventDefault = t, this._observer = this.camera.getScene()._inputManager._addCameraPointerObserver(function(i) {
          e._pointerInput(i);
        }, Le.POINTERDOWN | Le.POINTERUP | Le.POINTERMOVE), this._rollObserver = this.camera.getScene().onBeforeRenderObservable.add(function() {
          e.camera.rollCorrect && e.camera.restoreRoll(e.camera.rollCorrect);
        });
      }, n.prototype.detachControl = function() {
        this._observer && (this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer), this.camera.getScene().onBeforeRenderObservable.remove(this._rollObserver), this._observer = null, this._rollObserver = null, this._previousPosition = null, this._noPreventDefault = void 0);
      }, n.prototype.getClassName = function() {
        return "FlyCameraMouseInput";
      }, n.prototype.getSimpleName = function() {
        return "mouse";
      }, n.prototype._pointerInput = function(t) {
        var e = t.event, i = this.camera.getEngine();
        if ((this.touchEnabled || e.pointerType !== "touch") && (t.type === Le.POINTERMOVE || this.buttons.indexOf(e.button) !== -1)) {
          var r = e.target;
          if (t.type === Le.POINTERDOWN) {
            try {
              r == null || r.setPointerCapture(e.pointerId);
            } catch {
            }
            this._previousPosition = { x: e.clientX, y: e.clientY }, this.activeButton = e.button, this._noPreventDefault || (e.preventDefault(), this._element.focus()), i.isPointerLock && this._onMouseMove(t.event);
          } else if (t.type === Le.POINTERUP) {
            try {
              r == null || r.releasePointerCapture(e.pointerId);
            } catch {
            }
            this.activeButton = -1, this._previousPosition = null, this._noPreventDefault || e.preventDefault();
          } else if (t.type === Le.POINTERMOVE) {
            if (!this._previousPosition)
              return void (i.isPointerLock && this._onMouseMove(t.event));
            var o = e.clientX - this._previousPosition.x, a = e.clientY - this._previousPosition.y;
            this._rotateCamera(o, a), this._previousPosition = { x: e.clientX, y: e.clientY }, this._noPreventDefault || e.preventDefault();
          }
        }
      }, n.prototype._onMouseMove = function(t) {
        if (this.camera.getEngine().isPointerLock) {
          var e = t.movementX, i = t.movementY;
          this._rotateCamera(e, i), this._previousPosition = null, this._noPreventDefault || t.preventDefault();
        }
      }, n.prototype._rotateCamera = function(t, e) {
        var i, r = this, o = this.camera, a = (t *= o._calculateHandednessMultiplier()) / this.angularSensibility, s = e / this.angularSensibility, l = oe.RotationYawPitchRoll(o.rotation.y, o.rotation.x, o.rotation.z);
        if (this.buttonsPitch.some(function(h) {
          return h === r.activeButton;
        }) && (i = oe.RotationAxis(qi.X, s), l.multiplyInPlace(i)), this.buttonsYaw.some(function(h) {
          return h === r.activeButton;
        })) {
          i = oe.RotationAxis(qi.Y, a), l.multiplyInPlace(i);
          var c = o.bankedTurnLimit + o._trackRoll;
          if (o.bankedTurn && -c < o.rotation.z && o.rotation.z < c) {
            var u = o.bankedTurnMultiplier * -a;
            i = oe.RotationAxis(qi.Z, u), l.multiplyInPlace(i);
          }
        }
        this.buttonsRoll.some(function(h) {
          return h === r.activeButton;
        }) && (i = oe.RotationAxis(qi.Z, -a), o._trackRoll -= a, l.multiplyInPlace(i)), l.toEulerAnglesToRef(o.rotation);
      }, x([N()], n.prototype, "buttons", void 0), x([N()], n.prototype, "angularSensibility", void 0), n;
    }();
    gn.FlyCameraMouseInput = Qp;
    var Zp = function() {
      function n() {
        this.keysHeightOffsetIncr = [38], this.keysHeightOffsetDecr = [40], this.keysHeightOffsetModifierAlt = !1, this.keysHeightOffsetModifierCtrl = !1, this.keysHeightOffsetModifierShift = !1, this.keysRotationOffsetIncr = [37], this.keysRotationOffsetDecr = [39], this.keysRotationOffsetModifierAlt = !1, this.keysRotationOffsetModifierCtrl = !1, this.keysRotationOffsetModifierShift = !1, this.keysRadiusIncr = [40], this.keysRadiusDecr = [38], this.keysRadiusModifierAlt = !0, this.keysRadiusModifierCtrl = !1, this.keysRadiusModifierShift = !1, this.heightSensibility = 1, this.rotationSensibility = 1, this.radiusSensibility = 1, this._keys = new Array();
      }
      return n.prototype.attachControl = function(t) {
        var e = this;
        t = de.BackCompatCameraNoPreventDefault(arguments), this._onCanvasBlurObserver || (this._scene = this.camera.getScene(), this._engine = this._scene.getEngine(), this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function() {
          e._keys.length = 0;
        }), this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function(i) {
          var r, o = i.event;
          o.metaKey || (i.type === ps.KEYDOWN ? (e._ctrlPressed = o.ctrlKey, e._altPressed = o.altKey, e._shiftPressed = o.shiftKey, (e.keysHeightOffsetIncr.indexOf(o.keyCode) !== -1 || e.keysHeightOffsetDecr.indexOf(o.keyCode) !== -1 || e.keysRotationOffsetIncr.indexOf(o.keyCode) !== -1 || e.keysRotationOffsetDecr.indexOf(o.keyCode) !== -1 || e.keysRadiusIncr.indexOf(o.keyCode) !== -1 || e.keysRadiusDecr.indexOf(o.keyCode) !== -1) && ((r = e._keys.indexOf(o.keyCode)) === -1 && e._keys.push(o.keyCode), o.preventDefault && (t || o.preventDefault()))) : e.keysHeightOffsetIncr.indexOf(o.keyCode) === -1 && e.keysHeightOffsetDecr.indexOf(o.keyCode) === -1 && e.keysRotationOffsetIncr.indexOf(o.keyCode) === -1 && e.keysRotationOffsetDecr.indexOf(o.keyCode) === -1 && e.keysRadiusIncr.indexOf(o.keyCode) === -1 && e.keysRadiusDecr.indexOf(o.keyCode) === -1 || ((r = e._keys.indexOf(o.keyCode)) >= 0 && e._keys.splice(r, 1), o.preventDefault && (t || o.preventDefault())));
        }));
      }, n.prototype.detachControl = function() {
        this._scene && (this._onKeyboardObserver && this._scene.onKeyboardObservable.remove(this._onKeyboardObserver), this._onCanvasBlurObserver && this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver), this._onKeyboardObserver = null, this._onCanvasBlurObserver = null), this._keys.length = 0;
      }, n.prototype.checkInputs = function() {
        var t = this;
        this._onKeyboardObserver && this._keys.forEach(function(e) {
          t.keysHeightOffsetIncr.indexOf(e) !== -1 && t._modifierHeightOffset() ? t.camera.heightOffset += t.heightSensibility : t.keysHeightOffsetDecr.indexOf(e) !== -1 && t._modifierHeightOffset() ? t.camera.heightOffset -= t.heightSensibility : t.keysRotationOffsetIncr.indexOf(e) !== -1 && t._modifierRotationOffset() ? (t.camera.rotationOffset += t.rotationSensibility, t.camera.rotationOffset %= 360) : t.keysRotationOffsetDecr.indexOf(e) !== -1 && t._modifierRotationOffset() ? (t.camera.rotationOffset -= t.rotationSensibility, t.camera.rotationOffset %= 360) : t.keysRadiusIncr.indexOf(e) !== -1 && t._modifierRadius() ? t.camera.radius += t.radiusSensibility : t.keysRadiusDecr.indexOf(e) !== -1 && t._modifierRadius() && (t.camera.radius -= t.radiusSensibility);
        });
      }, n.prototype.getClassName = function() {
        return "FollowCameraKeyboardMoveInput";
      }, n.prototype.getSimpleName = function() {
        return "keyboard";
      }, n.prototype._modifierHeightOffset = function() {
        return this.keysHeightOffsetModifierAlt === this._altPressed && this.keysHeightOffsetModifierCtrl === this._ctrlPressed && this.keysHeightOffsetModifierShift === this._shiftPressed;
      }, n.prototype._modifierRotationOffset = function() {
        return this.keysRotationOffsetModifierAlt === this._altPressed && this.keysRotationOffsetModifierCtrl === this._ctrlPressed && this.keysRotationOffsetModifierShift === this._shiftPressed;
      }, n.prototype._modifierRadius = function() {
        return this.keysRadiusModifierAlt === this._altPressed && this.keysRadiusModifierCtrl === this._ctrlPressed && this.keysRadiusModifierShift === this._shiftPressed;
      }, x([N()], n.prototype, "keysHeightOffsetIncr", void 0), x([N()], n.prototype, "keysHeightOffsetDecr", void 0), x([N()], n.prototype, "keysHeightOffsetModifierAlt", void 0), x([N()], n.prototype, "keysHeightOffsetModifierCtrl", void 0), x([N()], n.prototype, "keysHeightOffsetModifierShift", void 0), x([N()], n.prototype, "keysRotationOffsetIncr", void 0), x([N()], n.prototype, "keysRotationOffsetDecr", void 0), x([N()], n.prototype, "keysRotationOffsetModifierAlt", void 0), x([N()], n.prototype, "keysRotationOffsetModifierCtrl", void 0), x([N()], n.prototype, "keysRotationOffsetModifierShift", void 0), x([N()], n.prototype, "keysRadiusIncr", void 0), x([N()], n.prototype, "keysRadiusDecr", void 0), x([N()], n.prototype, "keysRadiusModifierAlt", void 0), x([N()], n.prototype, "keysRadiusModifierCtrl", void 0), x([N()], n.prototype, "keysRadiusModifierShift", void 0), x([N()], n.prototype, "heightSensibility", void 0), x([N()], n.prototype, "rotationSensibility", void 0), x([N()], n.prototype, "radiusSensibility", void 0), n;
    }();
    gn.FollowCameraKeyboardMoveInput = Zp;
    var Jp = function() {
      function n() {
        this.axisControlRadius = !0, this.axisControlHeight = !1, this.axisControlRotation = !1, this.wheelPrecision = 3, this.wheelDeltaPercentage = 0;
      }
      return n.prototype.attachControl = function(t) {
        var e = this;
        t = de.BackCompatCameraNoPreventDefault(arguments), this._wheel = function(i) {
          if (i.type === Le.POINTERWHEEL) {
            var r = i.event, o = 0, a = Math.max(-1, Math.min(1, r.deltaY));
            e.wheelDeltaPercentage ? (console.assert(e.axisControlRadius + e.axisControlHeight + e.axisControlRotation <= 1, "wheelDeltaPercentage only usable when mouse wheel controls ONE axis. Currently enabled: axisControlRadius: " + e.axisControlRadius + ", axisControlHeightOffset: " + e.axisControlHeight + ", axisControlRotationOffset: " + e.axisControlRotation), e.axisControlRadius ? o = 0.01 * a * e.wheelDeltaPercentage * e.camera.radius : e.axisControlHeight ? o = 0.01 * a * e.wheelDeltaPercentage * e.camera.heightOffset : e.axisControlRotation && (o = 0.01 * a * e.wheelDeltaPercentage * e.camera.rotationOffset)) : o = a * e.wheelPrecision, o && (e.axisControlRadius ? e.camera.radius += o : e.axisControlHeight ? e.camera.heightOffset -= o : e.axisControlRotation && (e.camera.rotationOffset -= o)), r.preventDefault && (t || r.preventDefault());
          }
        }, this._observer = this.camera.getScene()._inputManager._addCameraPointerObserver(this._wheel, Le.POINTERWHEEL);
      }, n.prototype.detachControl = function() {
        this._observer && (this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer), this._observer = null, this._wheel = null);
      }, n.prototype.getClassName = function() {
        return "ArcRotateCameraMouseWheelInput";
      }, n.prototype.getSimpleName = function() {
        return "mousewheel";
      }, x([N()], n.prototype, "axisControlRadius", void 0), x([N()], n.prototype, "axisControlHeight", void 0), x([N()], n.prototype, "axisControlRotation", void 0), x([N()], n.prototype, "wheelPrecision", void 0), x([N()], n.prototype, "wheelDeltaPercentage", void 0), n;
    }();
    gn.FollowCameraMouseWheelInput = Jp;
    var $p = function(n) {
      function t() {
        var e = n !== null && n.apply(this, arguments) || this;
        return e.angularSensibilityX = 1, e.angularSensibilityY = 1, e.pinchPrecision = 1e4, e.pinchDeltaPercentage = 0, e.axisXControlRadius = !1, e.axisXControlHeight = !1, e.axisXControlRotation = !0, e.axisYControlRadius = !1, e.axisYControlHeight = !0, e.axisYControlRotation = !1, e.axisPinchControlRadius = !0, e.axisPinchControlHeight = !1, e.axisPinchControlRotation = !1, e.warningEnable = !0, e._warningCounter = 0, e;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "FollowCameraPointersInput";
      }, t.prototype.onTouch = function(e, i, r) {
        this._warning(), this.axisXControlRotation ? this.camera.rotationOffset += i / this.angularSensibilityX : this.axisYControlRotation && (this.camera.rotationOffset += r / this.angularSensibilityX), this.axisXControlHeight ? this.camera.heightOffset += i / this.angularSensibilityY : this.axisYControlHeight && (this.camera.heightOffset += r / this.angularSensibilityY), this.axisXControlRadius ? this.camera.radius -= i / this.angularSensibilityY : this.axisYControlRadius && (this.camera.radius -= r / this.angularSensibilityY);
      }, t.prototype.onMultiTouch = function(e, i, r, o, a, s) {
        if (!(r === 0 && a === null || o === 0 && s === null)) {
          var l = (o - r) / (this.pinchPrecision * (this.angularSensibilityX + this.angularSensibilityY) / 2);
          this.pinchDeltaPercentage ? (l *= 0.01 * this.pinchDeltaPercentage, this.axisPinchControlRotation && (this.camera.rotationOffset += l * this.camera.rotationOffset), this.axisPinchControlHeight && (this.camera.heightOffset += l * this.camera.heightOffset), this.axisPinchControlRadius && (this.camera.radius -= l * this.camera.radius)) : (this.axisPinchControlRotation && (this.camera.rotationOffset += l), this.axisPinchControlHeight && (this.camera.heightOffset += l), this.axisPinchControlRadius && (this.camera.radius -= l));
        }
      }, t.prototype._warning = function() {
        if (this.warningEnable && this._warningCounter++ % 100 == 0) {
          var e = "It probably only makes sense to control ONE camera property with each pointer axis. Set 'warningEnable = false' if you are sure. Currently enabled: ";
          console.assert(this.axisXControlRotation + this.axisXControlHeight + this.axisXControlRadius <= 1, e + "axisXControlRotation: " + this.axisXControlRotation + ", axisXControlHeight: " + this.axisXControlHeight + ", axisXControlRadius: " + this.axisXControlRadius), console.assert(this.axisYControlRotation + this.axisYControlHeight + this.axisYControlRadius <= 1, e + "axisYControlRotation: " + this.axisYControlRotation + ", axisYControlHeight: " + this.axisYControlHeight + ", axisYControlRadius: " + this.axisYControlRadius), console.assert(this.axisPinchControlRotation + this.axisPinchControlHeight + this.axisPinchControlRadius <= 1, e + "axisPinchControlRotation: " + this.axisPinchControlRotation + ", axisPinchControlHeight: " + this.axisPinchControlHeight + ", axisPinchControlRadius: " + this.axisPinchControlRadius);
        }
      }, x([N()], t.prototype, "angularSensibilityX", void 0), x([N()], t.prototype, "angularSensibilityY", void 0), x([N()], t.prototype, "pinchPrecision", void 0), x([N()], t.prototype, "pinchDeltaPercentage", void 0), x([N()], t.prototype, "axisXControlRadius", void 0), x([N()], t.prototype, "axisXControlHeight", void 0), x([N()], t.prototype, "axisXControlRotation", void 0), x([N()], t.prototype, "axisYControlRadius", void 0), x([N()], t.prototype, "axisYControlHeight", void 0), x([N()], t.prototype, "axisYControlRotation", void 0), x([N()], t.prototype, "axisPinchControlRadius", void 0), x([N()], t.prototype, "axisPinchControlHeight", void 0), x([N()], t.prototype, "axisPinchControlRotation", void 0), t;
    }(Wp);
    gn.FollowCameraPointersInput = $p;
    var ef = function() {
      function n() {
        this.keysUp = [38], this.keysUpward = [33], this.keysDown = [40], this.keysDownward = [34], this.keysLeft = [37], this.keysRight = [39], this.rotationSpeed = 0.5, this.keysRotateLeft = [], this.keysRotateRight = [], this.keysRotateUp = [], this.keysRotateDown = [], this._keys = new Array();
      }
      return n.prototype.attachControl = function(t) {
        var e = this;
        t = de.BackCompatCameraNoPreventDefault(arguments), this._onCanvasBlurObserver || (this._scene = this.camera.getScene(), this._engine = this._scene.getEngine(), this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function() {
          e._keys.length = 0;
        }), this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function(i) {
          var r, o = i.event;
          o.metaKey || (i.type === ps.KEYDOWN ? e.keysUp.indexOf(o.keyCode) === -1 && e.keysDown.indexOf(o.keyCode) === -1 && e.keysLeft.indexOf(o.keyCode) === -1 && e.keysRight.indexOf(o.keyCode) === -1 && e.keysUpward.indexOf(o.keyCode) === -1 && e.keysDownward.indexOf(o.keyCode) === -1 && e.keysRotateLeft.indexOf(o.keyCode) === -1 && e.keysRotateRight.indexOf(o.keyCode) === -1 && e.keysRotateUp.indexOf(o.keyCode) === -1 && e.keysRotateDown.indexOf(o.keyCode) === -1 || ((r = e._keys.indexOf(o.keyCode)) === -1 && e._keys.push(o.keyCode), t || o.preventDefault()) : e.keysUp.indexOf(o.keyCode) === -1 && e.keysDown.indexOf(o.keyCode) === -1 && e.keysLeft.indexOf(o.keyCode) === -1 && e.keysRight.indexOf(o.keyCode) === -1 && e.keysUpward.indexOf(o.keyCode) === -1 && e.keysDownward.indexOf(o.keyCode) === -1 && e.keysRotateLeft.indexOf(o.keyCode) === -1 && e.keysRotateRight.indexOf(o.keyCode) === -1 && e.keysRotateUp.indexOf(o.keyCode) === -1 && e.keysRotateDown.indexOf(o.keyCode) === -1 || ((r = e._keys.indexOf(o.keyCode)) >= 0 && e._keys.splice(r, 1), t || o.preventDefault()));
        }));
      }, n.prototype.detachControl = function() {
        this._scene && (this._onKeyboardObserver && this._scene.onKeyboardObservable.remove(this._onKeyboardObserver), this._onCanvasBlurObserver && this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver), this._onKeyboardObserver = null, this._onCanvasBlurObserver = null), this._keys.length = 0;
      }, n.prototype.checkInputs = function() {
        if (this._onKeyboardObserver)
          for (var t = this.camera, e = 0; e < this._keys.length; e++) {
            var i = this._keys[e], r = t._computeLocalCameraSpeed();
            this.keysLeft.indexOf(i) !== -1 ? t._localDirection.copyFromFloats(-r, 0, 0) : this.keysUp.indexOf(i) !== -1 ? t._localDirection.copyFromFloats(0, 0, r) : this.keysRight.indexOf(i) !== -1 ? t._localDirection.copyFromFloats(r, 0, 0) : this.keysDown.indexOf(i) !== -1 ? t._localDirection.copyFromFloats(0, 0, -r) : this.keysUpward.indexOf(i) !== -1 ? t._localDirection.copyFromFloats(0, r, 0) : this.keysDownward.indexOf(i) !== -1 ? t._localDirection.copyFromFloats(0, -r, 0) : this.keysRotateLeft.indexOf(i) !== -1 ? (t._localDirection.copyFromFloats(0, 0, 0), t.cameraRotation.y -= this._getLocalRotation()) : this.keysRotateRight.indexOf(i) !== -1 ? (t._localDirection.copyFromFloats(0, 0, 0), t.cameraRotation.y += this._getLocalRotation()) : this.keysRotateUp.indexOf(i) !== -1 ? (t._localDirection.copyFromFloats(0, 0, 0), t.cameraRotation.x -= this._getLocalRotation()) : this.keysRotateDown.indexOf(i) !== -1 && (t._localDirection.copyFromFloats(0, 0, 0), t.cameraRotation.x += this._getLocalRotation()), t.getScene().useRightHandedSystem && (t._localDirection.z *= -1), t.getViewMatrix().invertToRef(t._cameraTransformMatrix), v.TransformNormalToRef(t._localDirection, t._cameraTransformMatrix, t._transformedDirection), t.cameraDirection.addInPlace(t._transformedDirection);
          }
      }, n.prototype.getClassName = function() {
        return "FreeCameraKeyboardMoveInput";
      }, n.prototype._onLostFocus = function() {
        this._keys.length = 0;
      }, n.prototype.getSimpleName = function() {
        return "keyboard";
      }, n.prototype._getLocalRotation = function() {
        var t = this.camera._calculateHandednessMultiplier();
        return this.rotationSpeed * this._engine.getDeltaTime() / 1e3 * t;
      }, x([N()], n.prototype, "keysUp", void 0), x([N()], n.prototype, "keysUpward", void 0), x([N()], n.prototype, "keysDown", void 0), x([N()], n.prototype, "keysDownward", void 0), x([N()], n.prototype, "keysLeft", void 0), x([N()], n.prototype, "keysRight", void 0), x([N()], n.prototype, "rotationSpeed", void 0), x([N()], n.prototype, "keysRotateLeft", void 0), x([N()], n.prototype, "keysRotateRight", void 0), x([N()], n.prototype, "keysRotateUp", void 0), x([N()], n.prototype, "keysRotateDown", void 0), n;
    }();
    gn.FreeCameraKeyboardMoveInput = ef;
    var hi, tf = function() {
      function n(t) {
        t === void 0 && (t = !0), this.touchEnabled = t, this.buttons = [0, 1, 2], this.angularSensibility = 2e3, this._previousPosition = null, this.onPointerMovedObservable = new H(), this._allowCameraRotation = !0, this._currentActiveButton = -1, this._activePointerId = -1;
      }
      return n.prototype.attachControl = function(t) {
        var e = this;
        t = de.BackCompatCameraNoPreventDefault(arguments);
        var i = this.camera.getEngine(), r = i.getInputElement();
        this._pointerInput || (this._pointerInput = function(o) {
          var a = o.event, s = a.pointerType === "touch";
          if ((e.touchEnabled || !s) && (o.type === Le.POINTERMOVE || e.buttons.indexOf(a.button) !== -1)) {
            var l = a.target;
            if (o.type === Le.POINTERDOWN) {
              if (s && e._activePointerId !== -1 || !s && e._currentActiveButton !== -1)
                return;
              e._activePointerId = a.pointerId;
              try {
                l == null || l.setPointerCapture(a.pointerId);
              } catch {
              }
              e._currentActiveButton === -1 && (e._currentActiveButton = a.button), e._previousPosition = { x: a.clientX, y: a.clientY }, t || (a.preventDefault(), r && r.focus()), i.isPointerLock && e._onMouseMove && e._onMouseMove(o.event);
            } else if (o.type === Le.POINTERUP) {
              if (s && e._activePointerId !== a.pointerId || !s && e._currentActiveButton !== a.button)
                return;
              try {
                l == null || l.releasePointerCapture(a.pointerId);
              } catch {
              }
              e._currentActiveButton = -1, e._previousPosition = null, t || a.preventDefault(), e._activePointerId = -1;
            } else if (o.type === Le.POINTERMOVE && (e._activePointerId === a.pointerId || !s)) {
              if (i.isPointerLock && e._onMouseMove)
                e._onMouseMove(o.event);
              else if (e._previousPosition) {
                var c = e.camera._calculateHandednessMultiplier(), u = (a.clientX - e._previousPosition.x) * c, h = a.clientY - e._previousPosition.y;
                e._allowCameraRotation && (e.camera.cameraRotation.y += u / e.angularSensibility, e.camera.cameraRotation.x += h / e.angularSensibility), e.onPointerMovedObservable.notifyObservers({ offsetX: u, offsetY: h }), e._previousPosition = { x: a.clientX, y: a.clientY }, t || a.preventDefault();
              }
            }
          }
        }), this._onMouseMove = function(o) {
          if (i.isPointerLock) {
            var a = e.camera._calculateHandednessMultiplier(), s = o.movementX * a;
            e.camera.cameraRotation.y += s / e.angularSensibility;
            var l = o.movementY;
            e.camera.cameraRotation.x += l / e.angularSensibility, e._previousPosition = null, t || o.preventDefault();
          }
        }, this._observer = this.camera.getScene()._inputManager._addCameraPointerObserver(this._pointerInput, Le.POINTERDOWN | Le.POINTERUP | Le.POINTERMOVE), r && (this._contextMenuBind = function(o) {
          return e.onContextMenu(o);
        }, r.addEventListener("contextmenu", this._contextMenuBind, !1));
      }, n.prototype.onContextMenu = function(t) {
        t.preventDefault();
      }, n.prototype.detachControl = function() {
        if (this._observer) {
          if (this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer), this._contextMenuBind) {
            var t = this.camera.getEngine().getInputElement();
            t && t.removeEventListener("contextmenu", this._contextMenuBind);
          }
          this.onPointerMovedObservable && this.onPointerMovedObservable.clear(), this._observer = null, this._onMouseMove = null, this._previousPosition = null;
        }
        this._activePointerId = -1, this._currentActiveButton = -1;
      }, n.prototype.getClassName = function() {
        return "FreeCameraMouseInput";
      }, n.prototype.getSimpleName = function() {
        return "mouse";
      }, x([N()], n.prototype, "buttons", void 0), x([N()], n.prototype, "angularSensibility", void 0), n;
    }();
    gn.FreeCameraMouseInput = tf, function(n) {
      n[n.MoveRelative = 0] = "MoveRelative", n[n.RotateRelative = 1] = "RotateRelative", n[n.MoveScene = 2] = "MoveScene";
    }(hi || (hi = {}));
    var nf = function(n) {
      function t() {
        var e = n !== null && n.apply(this, arguments) || this;
        return e._moveRelative = v.Zero(), e._rotateRelative = v.Zero(), e._moveScene = v.Zero(), e._wheelXAction = hi.MoveRelative, e._wheelXActionCoordinate = Ua.X, e._wheelYAction = hi.MoveRelative, e._wheelYActionCoordinate = Ua.Z, e._wheelZAction = null, e._wheelZActionCoordinate = null, e;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "FreeCameraMouseWheelInput";
      }, Object.defineProperty(t.prototype, "wheelXMoveRelative", { get: function() {
        return this._wheelXAction !== hi.MoveRelative ? null : this._wheelXActionCoordinate;
      }, set: function(e) {
        e === null && this._wheelXAction !== hi.MoveRelative || (this._wheelXAction = hi.MoveRelative, this._wheelXActionCoordinate = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wheelYMoveRelative", { get: function() {
        return this._wheelYAction !== hi.MoveRelative ? null : this._wheelYActionCoordinate;
      }, set: function(e) {
        e === null && this._wheelYAction !== hi.MoveRelative || (this._wheelYAction = hi.MoveRelative, this._wheelYActionCoordinate = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wheelZMoveRelative", { get: function() {
        return this._wheelZAction !== hi.MoveRelative ? null : this._wheelZActionCoordinate;
      }, set: function(e) {
        e === null && this._wheelZAction !== hi.MoveRelative || (this._wheelZAction = hi.MoveRelative, this._wheelZActionCoordinate = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wheelXRotateRelative", { get: function() {
        return this._wheelXAction !== hi.RotateRelative ? null : this._wheelXActionCoordinate;
      }, set: function(e) {
        e === null && this._wheelXAction !== hi.RotateRelative || (this._wheelXAction = hi.RotateRelative, this._wheelXActionCoordinate = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wheelYRotateRelative", { get: function() {
        return this._wheelYAction !== hi.RotateRelative ? null : this._wheelYActionCoordinate;
      }, set: function(e) {
        e === null && this._wheelYAction !== hi.RotateRelative || (this._wheelYAction = hi.RotateRelative, this._wheelYActionCoordinate = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wheelZRotateRelative", { get: function() {
        return this._wheelZAction !== hi.RotateRelative ? null : this._wheelZActionCoordinate;
      }, set: function(e) {
        e === null && this._wheelZAction !== hi.RotateRelative || (this._wheelZAction = hi.RotateRelative, this._wheelZActionCoordinate = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wheelXMoveScene", { get: function() {
        return this._wheelXAction !== hi.MoveScene ? null : this._wheelXActionCoordinate;
      }, set: function(e) {
        e === null && this._wheelXAction !== hi.MoveScene || (this._wheelXAction = hi.MoveScene, this._wheelXActionCoordinate = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wheelYMoveScene", { get: function() {
        return this._wheelYAction !== hi.MoveScene ? null : this._wheelYActionCoordinate;
      }, set: function(e) {
        e === null && this._wheelYAction !== hi.MoveScene || (this._wheelYAction = hi.MoveScene, this._wheelYActionCoordinate = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wheelZMoveScene", { get: function() {
        return this._wheelZAction !== hi.MoveScene ? null : this._wheelZActionCoordinate;
      }, set: function(e) {
        e === null && this._wheelZAction !== hi.MoveScene || (this._wheelZAction = hi.MoveScene, this._wheelZActionCoordinate = e);
      }, enumerable: !1, configurable: !0 }), t.prototype.checkInputs = function() {
        if (this._wheelDeltaX !== 0 || this._wheelDeltaY !== 0 || this._wheelDeltaZ != 0) {
          this._moveRelative.setAll(0), this._rotateRelative.setAll(0), this._moveScene.setAll(0), this._updateCamera(), this.camera.getScene().useRightHandedSystem && (this._moveRelative.z *= -1);
          var e = B.Zero();
          this.camera.getViewMatrix().invertToRef(e);
          var i = v.Zero();
          v.TransformNormalToRef(this._moveRelative, e, i), this.camera.cameraRotation.x += this._rotateRelative.x / 200, this.camera.cameraRotation.y += this._rotateRelative.y / 200, this.camera.cameraDirection.addInPlace(i), this.camera.cameraDirection.addInPlace(this._moveScene), n.prototype.checkInputs.call(this);
        }
      }, t.prototype._updateCamera = function() {
        this._updateCameraProperty(this._wheelDeltaX, this._wheelXAction, this._wheelXActionCoordinate), this._updateCameraProperty(this._wheelDeltaY, this._wheelYAction, this._wheelYActionCoordinate), this._updateCameraProperty(this._wheelDeltaZ, this._wheelZAction, this._wheelZActionCoordinate);
      }, t.prototype._updateCameraProperty = function(e, i, r) {
        if (e !== 0 && i !== null && r !== null) {
          var o = null;
          switch (i) {
            case hi.MoveRelative:
              o = this._moveRelative;
              break;
            case hi.RotateRelative:
              o = this._rotateRelative;
              break;
            case hi.MoveScene:
              o = this._moveScene;
          }
          switch (r) {
            case Ua.X:
              o.set(e, 0, 0);
              break;
            case Ua.Y:
              o.set(0, e, 0);
              break;
            case Ua.Z:
              o.set(0, 0, e);
          }
        }
      }, x([N()], t.prototype, "wheelXMoveRelative", null), x([N()], t.prototype, "wheelYMoveRelative", null), x([N()], t.prototype, "wheelZMoveRelative", null), x([N()], t.prototype, "wheelXRotateRelative", null), x([N()], t.prototype, "wheelYRotateRelative", null), x([N()], t.prototype, "wheelZRotateRelative", null), x([N()], t.prototype, "wheelXMoveScene", null), x([N()], t.prototype, "wheelYMoveScene", null), x([N()], t.prototype, "wheelZMoveScene", null), t;
    }(zg);
    gn.FreeCameraMouseWheelInput = nf;
    var rf = function() {
      function n(t) {
        t === void 0 && (t = !1), this.allowMouse = t, this.touchAngularSensibility = 2e5, this.touchMoveSensibility = 250, this.singleFingerRotate = !1, this._offsetX = null, this._offsetY = null, this._pointerPressed = new Array(), this._isSafari = de.IsSafari();
      }
      return n.prototype.attachControl = function(t) {
        var e = this;
        t = de.BackCompatCameraNoPreventDefault(arguments);
        var i = null;
        if (this._pointerInput === void 0 && (this._onLostFocus = function() {
          e._offsetX = null, e._offsetY = null;
        }, this._pointerInput = function(o) {
          var a = o.event, s = a.pointerType === "mouse" || e._isSafari && a.pointerType === void 0;
          if (e.allowMouse || !s) {
            if (o.type === Le.POINTERDOWN) {
              if (t || a.preventDefault(), e._pointerPressed.push(a.pointerId), e._pointerPressed.length !== 1)
                return;
              i = { x: a.clientX, y: a.clientY };
            } else if (o.type === Le.POINTERUP) {
              if (t || a.preventDefault(), (l = e._pointerPressed.indexOf(a.pointerId)) === -1 || (e._pointerPressed.splice(l, 1), l != 0))
                return;
              i = null, e._offsetX = null, e._offsetY = null;
            } else if (o.type === Le.POINTERMOVE) {
              if (t || a.preventDefault(), !i)
                return;
              var l;
              if ((l = e._pointerPressed.indexOf(a.pointerId)) != 0)
                return;
              e._offsetX = a.clientX - i.x, e._offsetY = -(a.clientY - i.y);
            }
          }
        }), this._observer = this.camera.getScene()._inputManager._addCameraPointerObserver(this._pointerInput, Le.POINTERDOWN | Le.POINTERUP | Le.POINTERMOVE), this._onLostFocus) {
          var r = this.camera.getEngine().getInputElement();
          r && r.addEventListener("blur", this._onLostFocus);
        }
      }, n.prototype.detachControl = function() {
        if (this._pointerInput) {
          if (this._observer && (this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer), this._observer = null), this._onLostFocus) {
            var t = this.camera.getEngine().getInputElement();
            t && t.removeEventListener("blur", this._onLostFocus), this._onLostFocus = null;
          }
          this._pointerPressed.length = 0, this._offsetX = null, this._offsetY = null;
        }
      }, n.prototype.checkInputs = function() {
        if (this._offsetX !== null && this._offsetY !== null && (this._offsetX !== 0 || this._offsetY !== 0)) {
          var t = this.camera, e = t._calculateHandednessMultiplier();
          if (t.cameraRotation.y = e * this._offsetX / this.touchAngularSensibility, this.singleFingerRotate && this._pointerPressed.length === 1 || !this.singleFingerRotate && this._pointerPressed.length > 1)
            t.cameraRotation.x = -this._offsetY / this.touchAngularSensibility;
          else {
            var i = t._computeLocalCameraSpeed(), r = new v(0, 0, this.touchMoveSensibility !== 0 ? i * this._offsetY / this.touchMoveSensibility : 0);
            B.RotationYawPitchRollToRef(t.rotation.y, t.rotation.x, 0, t._cameraRotationMatrix), t.cameraDirection.addInPlace(v.TransformCoordinates(r, t._cameraRotationMatrix));
          }
        }
      }, n.prototype.getClassName = function() {
        return "FreeCameraTouchInput";
      }, n.prototype.getSimpleName = function() {
        return "touch";
      }, x([N()], n.prototype, "touchAngularSensibility", void 0), x([N()], n.prototype, "touchMoveSensibility", void 0), n;
    }();
    gn.FreeCameraTouchInput = rf;
    var bc = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i._mouseInput = null, i._mouseWheelInput = null, i;
      }
      return D(t, n), t.prototype.addKeyboard = function() {
        return this.add(new ef()), this;
      }, t.prototype.addMouse = function(e) {
        return e === void 0 && (e = !0), this._mouseInput || (this._mouseInput = new tf(e), this.add(this._mouseInput)), this;
      }, t.prototype.removeMouse = function() {
        return this._mouseInput && this.remove(this._mouseInput), this;
      }, t.prototype.addMouseWheel = function() {
        return this._mouseWheelInput || (this._mouseWheelInput = new nf(), this.add(this._mouseWheelInput)), this;
      }, t.prototype.removeMouseWheel = function() {
        return this._mouseWheelInput && this.remove(this._mouseWheelInput), this;
      }, t.prototype.addTouch = function() {
        return this.add(new rf()), this;
      }, t.prototype.clear = function() {
        n.prototype.clear.call(this), this._mouseInput = null;
      }, t;
    }(yc);
    bc.prototype.addDeviceOrientation = function(n) {
      return this._deviceOrientationInput || (this._deviceOrientationInput = new of(), n && (this._deviceOrientationInput.smoothFactor = n), this.add(this._deviceOrientationInput)), this;
    };
    var of = function() {
      function n() {
        var t = this;
        this._screenOrientationAngle = 0, this._screenQuaternion = new oe(), this._alpha = 0, this._beta = 0, this._gamma = 0, this.smoothFactor = 0, this._onDeviceOrientationChangedObservable = new H(), this._orientationChanged = function() {
          t._screenOrientationAngle = window.orientation !== void 0 ? +window.orientation : window.screen.orientation && window.screen.orientation.angle ? window.screen.orientation.angle : 0, t._screenOrientationAngle = -de.ToRadians(t._screenOrientationAngle / 2), t._screenQuaternion.copyFromFloats(0, Math.sin(t._screenOrientationAngle), 0, Math.cos(t._screenOrientationAngle));
        }, this._deviceOrientation = function(e) {
          t.smoothFactor ? (t._alpha = e.alpha !== null ? de.SmoothAngleChange(t._alpha, e.alpha, t.smoothFactor) : 0, t._beta = e.beta !== null ? de.SmoothAngleChange(t._beta, e.beta, t.smoothFactor) : 0, t._gamma = e.gamma !== null ? de.SmoothAngleChange(t._gamma, e.gamma, t.smoothFactor) : 0) : (t._alpha = e.alpha !== null ? e.alpha : 0, t._beta = e.beta !== null ? e.beta : 0, t._gamma = e.gamma !== null ? e.gamma : 0), e.alpha !== null && t._onDeviceOrientationChangedObservable.notifyObservers();
        }, this._constantTranform = new oe(-Math.sqrt(0.5), 0, 0, Math.sqrt(0.5)), this._orientationChanged();
      }
      return n.WaitForOrientationChangeAsync = function(t) {
        return new Promise(function(e, i) {
          var r = !1, o = function() {
            window.removeEventListener("deviceorientation", o), r = !0, e();
          };
          t && setTimeout(function() {
            r || (window.removeEventListener("deviceorientation", o), i("WaitForOrientationChangeAsync timed out"));
          }, t), typeof DeviceOrientationEvent < "u" && typeof DeviceOrientationEvent.requestPermission == "function" ? DeviceOrientationEvent.requestPermission().then(function(a) {
            a == "granted" ? window.addEventListener("deviceorientation", o) : de.Warn("Permission not granted.");
          }).catch(function(a) {
            de.Error(a);
          }) : window.addEventListener("deviceorientation", o);
        });
      }, Object.defineProperty(n.prototype, "camera", { get: function() {
        return this._camera;
      }, set: function(t) {
        var e = this;
        this._camera = t, this._camera == null || this._camera.rotationQuaternion || (this._camera.rotationQuaternion = new oe()), this._camera && this._camera.onDisposeObservable.add(function() {
          e._onDeviceOrientationChangedObservable.clear();
        });
      }, enumerable: !1, configurable: !0 }), n.prototype.attachControl = function() {
        var t = this, e = this.camera.getScene().getEngine().getHostWindow();
        if (e) {
          var i = function() {
            e.addEventListener("orientationchange", t._orientationChanged), e.addEventListener("deviceorientation", t._deviceOrientation), t._orientationChanged();
          };
          typeof DeviceOrientationEvent < "u" && typeof DeviceOrientationEvent.requestPermission == "function" ? DeviceOrientationEvent.requestPermission().then(function(r) {
            r === "granted" ? i() : de.Warn("Permission not granted.");
          }).catch(function(r) {
            de.Error(r);
          }) : i();
        }
      }, n.prototype.detachControl = function() {
        window.removeEventListener("orientationchange", this._orientationChanged), window.removeEventListener("deviceorientation", this._deviceOrientation), this._alpha = 0;
      }, n.prototype.checkInputs = function() {
        this._alpha && (oe.RotationYawPitchRollToRef(de.ToRadians(this._alpha), de.ToRadians(this._beta), -de.ToRadians(this._gamma), this.camera.rotationQuaternion), this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion), this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform), this._camera.rotationQuaternion.z *= -1, this._camera.rotationQuaternion.w *= -1);
      }, n.prototype.getClassName = function() {
        return "FreeCameraDeviceOrientationInput";
      }, n.prototype.getSimpleName = function() {
        return "deviceOrientation";
      }, n;
    }();
    gn.FreeCameraDeviceOrientationInput = of;
    var Zi, af = function() {
      function n() {
        this.gamepadAngularSensibility = 200, this.gamepadMoveSensibility = 40, this.deadzoneDelta = 0.1, this._yAxisScale = 1, this._cameraTransform = B.Identity(), this._deltaTransform = v.Zero(), this._vector3 = v.Zero(), this._vector2 = fe.Zero();
      }
      return Object.defineProperty(n.prototype, "invertYAxis", { get: function() {
        return this._yAxisScale !== 1;
      }, set: function(t) {
        this._yAxisScale = t ? -1 : 1;
      }, enumerable: !1, configurable: !0 }), n.prototype.attachControl = function() {
        var t = this, e = this.camera.getScene().gamepadManager;
        this._onGamepadConnectedObserver = e.onGamepadConnectedObservable.add(function(i) {
          i.type !== qn.POSE_ENABLED && (t.gamepad && i.type !== qn.XBOX || (t.gamepad = i));
        }), this._onGamepadDisconnectedObserver = e.onGamepadDisconnectedObservable.add(function(i) {
          t.gamepad === i && (t.gamepad = null);
        }), this.gamepad = e.getGamepadByType(qn.XBOX), !this.gamepad && e.gamepads.length && (this.gamepad = e.gamepads[0]);
      }, n.prototype.detachControl = function() {
        this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver), this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver), this.gamepad = null;
      }, n.prototype.checkInputs = function() {
        if (this.gamepad && this.gamepad.leftStick) {
          var t = this.camera, e = this.gamepad.leftStick;
          this.gamepadMoveSensibility !== 0 && (e.x = Math.abs(e.x) > this.deadzoneDelta ? e.x / this.gamepadMoveSensibility : 0, e.y = Math.abs(e.y) > this.deadzoneDelta ? e.y / this.gamepadMoveSensibility : 0);
          var i = this.gamepad.rightStick;
          i && this.gamepadAngularSensibility !== 0 ? (i.x = Math.abs(i.x) > this.deadzoneDelta ? i.x / this.gamepadAngularSensibility : 0, i.y = (Math.abs(i.y) > this.deadzoneDelta ? i.y / this.gamepadAngularSensibility : 0) * this._yAxisScale) : i = { x: 0, y: 0 }, t.rotationQuaternion ? t.rotationQuaternion.toRotationMatrix(this._cameraTransform) : B.RotationYawPitchRollToRef(t.rotation.y, t.rotation.x, 0, this._cameraTransform);
          var r = 50 * t._computeLocalCameraSpeed();
          this._vector3.copyFromFloats(e.x * r, 0, -e.y * r), v.TransformCoordinatesToRef(this._vector3, this._cameraTransform, this._deltaTransform), t.cameraDirection.addInPlace(this._deltaTransform), this._vector2.copyFromFloats(i.y, i.x), t.cameraRotation.addInPlace(this._vector2);
        }
      }, n.prototype.getClassName = function() {
        return "FreeCameraGamepadInput";
      }, n.prototype.getSimpleName = function() {
        return "gamepad";
      }, x([N()], n.prototype, "gamepadAngularSensibility", void 0), x([N()], n.prototype, "gamepadMoveSensibility", void 0), n;
    }();
    gn.FreeCameraGamepadInput = af, function(n) {
      n[n.X = 0] = "X", n[n.Y = 1] = "Y", n[n.Z = 2] = "Z";
    }(Zi || (Zi = {}));
    var sf = function() {
      function n(t, e) {
        var i = this;
        this._released = !1;
        var r = je(je({}, n._GetDefaultOptions()), e);
        if (this._leftJoystick = !!t, n._GlobalJoystickIndex++, this._axisTargetedByLeftAndRight = Zi.X, this._axisTargetedByUpAndDown = Zi.Y, this.reverseLeftRight = !1, this.reverseUpDown = !1, this._touches = new ku(), this.deltaPosition = v.Zero(), this._joystickSensibility = 25, this._inversedSensibility = 1 / (this._joystickSensibility / 1e3), this._onResize = function() {
          n._VJCanvasWidth = window.innerWidth, n._VJCanvasHeight = window.innerHeight, n.Canvas && (n.Canvas.width = n._VJCanvasWidth, n.Canvas.height = n._VJCanvasHeight), n._HalfWidth = n._VJCanvasWidth / 2;
        }, !n.Canvas) {
          window.addEventListener("resize", this._onResize, !1), n.Canvas = document.createElement("canvas"), n._VJCanvasWidth = window.innerWidth, n._VJCanvasHeight = window.innerHeight, n.Canvas.width = window.innerWidth, n.Canvas.height = window.innerHeight, n.Canvas.style.width = "100%", n.Canvas.style.height = "100%", n.Canvas.style.position = "absolute", n.Canvas.style.backgroundColor = "transparent", n.Canvas.style.top = "0px", n.Canvas.style.left = "0px", n.Canvas.style.zIndex = "5", n.Canvas.style.touchAction = "none", n.Canvas.setAttribute("touch-action", "none");
          var o = n.Canvas.getContext("2d");
          if (!o)
            throw new Error("Unable to create canvas for virtual joystick");
          n._VJCanvasContext = o, n._VJCanvasContext.strokeStyle = "#ffffff", n._VJCanvasContext.lineWidth = 2, document.body.appendChild(n.Canvas);
        }
        n._HalfWidth = n.Canvas.width / 2, this.pressed = !1, this.limitToContainer = r.limitToContainer, this._joystickColor = r.color, this.containerSize = r.containerSize, this.puckSize = r.puckSize, r.position && this.setPosition(r.position.x, r.position.y), r.puckImage && this.setPuckImage(r.puckImage), r.containerImage && this.setContainerImage(r.containerImage), r.alwaysVisible && n._AlwaysVisibleSticks++, this.alwaysVisible = r.alwaysVisible, this._joystickPointerId = -1, this._joystickPointerPos = new fe(0, 0), this._joystickPreviousPointerPos = new fe(0, 0), this._joystickPointerStartPos = new fe(0, 0), this._deltaJoystickVector = new fe(0, 0), this._onPointerDownHandlerRef = function(a) {
          i._onPointerDown(a);
        }, this._onPointerMoveHandlerRef = function(a) {
          i._onPointerMove(a);
        }, this._onPointerUpHandlerRef = function(a) {
          i._onPointerUp(a);
        }, n.Canvas.addEventListener("pointerdown", this._onPointerDownHandlerRef, !1), n.Canvas.addEventListener("pointermove", this._onPointerMoveHandlerRef, !1), n.Canvas.addEventListener("pointerup", this._onPointerUpHandlerRef, !1), n.Canvas.addEventListener("pointerout", this._onPointerUpHandlerRef, !1), n.Canvas.addEventListener("contextmenu", function(a) {
          a.preventDefault();
        }, !1), requestAnimationFrame(function() {
          i._drawVirtualJoystick();
        });
      }
      return n._GetDefaultOptions = function() {
        return { puckSize: 40, containerSize: 60, color: "cyan", puckImage: void 0, containerImage: void 0, position: void 0, alwaysVisible: !1, limitToContainer: !1 };
      }, n.prototype.setJoystickSensibility = function(t) {
        this._joystickSensibility = t, this._inversedSensibility = 1 / (this._joystickSensibility / 1e3);
      }, n.prototype._onPointerDown = function(t) {
        t.preventDefault(), (this._leftJoystick === !0 ? t.clientX < n._HalfWidth : t.clientX > n._HalfWidth) && this._joystickPointerId < 0 ? (this._joystickPointerId = t.pointerId, this._joystickPosition ? (this._joystickPointerStartPos = this._joystickPosition.clone(), this._joystickPointerPos = this._joystickPosition.clone(), this._joystickPreviousPointerPos = this._joystickPosition.clone(), this._onPointerMove(t)) : (this._joystickPointerStartPos.x = t.clientX, this._joystickPointerStartPos.y = t.clientY, this._joystickPointerPos = this._joystickPointerStartPos.clone(), this._joystickPreviousPointerPos = this._joystickPointerStartPos.clone()), this._deltaJoystickVector.x = 0, this._deltaJoystickVector.y = 0, this.pressed = !0, this._touches.add(t.pointerId.toString(), t)) : n._GlobalJoystickIndex < 2 && this._action && (this._action(), this._touches.add(t.pointerId.toString(), { x: t.clientX, y: t.clientY, prevX: t.clientX, prevY: t.clientY }));
      }, n.prototype._onPointerMove = function(t) {
        if (this._joystickPointerId == t.pointerId) {
          if (this.limitToContainer) {
            var e = new fe(t.clientX - this._joystickPointerStartPos.x, t.clientY - this._joystickPointerStartPos.y), i = e.length();
            i > this.containerSize && e.scaleInPlace(this.containerSize / i), this._joystickPointerPos.x = this._joystickPointerStartPos.x + e.x, this._joystickPointerPos.y = this._joystickPointerStartPos.y + e.y;
          } else
            this._joystickPointerPos.x = t.clientX, this._joystickPointerPos.y = t.clientY;
          this._deltaJoystickVector = this._joystickPointerPos.clone(), this._deltaJoystickVector = this._deltaJoystickVector.subtract(this._joystickPointerStartPos), 0 < n._AlwaysVisibleSticks && (this._leftJoystick ? this._joystickPointerPos.x = Math.min(n._HalfWidth, this._joystickPointerPos.x) : this._joystickPointerPos.x = Math.max(n._HalfWidth, this._joystickPointerPos.x));
          var r = (this.reverseLeftRight ? -1 : 1) * this._deltaJoystickVector.x / this._inversedSensibility;
          switch (this._axisTargetedByLeftAndRight) {
            case Zi.X:
              this.deltaPosition.x = Math.min(1, Math.max(-1, r));
              break;
            case Zi.Y:
              this.deltaPosition.y = Math.min(1, Math.max(-1, r));
              break;
            case Zi.Z:
              this.deltaPosition.z = Math.min(1, Math.max(-1, r));
          }
          var o = (this.reverseUpDown ? 1 : -1) * this._deltaJoystickVector.y / this._inversedSensibility;
          switch (this._axisTargetedByUpAndDown) {
            case Zi.X:
              this.deltaPosition.x = Math.min(1, Math.max(-1, o));
              break;
            case Zi.Y:
              this.deltaPosition.y = Math.min(1, Math.max(-1, o));
              break;
            case Zi.Z:
              this.deltaPosition.z = Math.min(1, Math.max(-1, o));
          }
        } else {
          var a = this._touches.get(t.pointerId.toString());
          a && (a.x = t.clientX, a.y = t.clientY);
        }
      }, n.prototype._onPointerUp = function(t) {
        if (this._joystickPointerId == t.pointerId)
          this._clearPreviousDraw(), this._joystickPointerId = -1, this.pressed = !1;
        else {
          var e = this._touches.get(t.pointerId.toString());
          e && n._VJCanvasContext.clearRect(e.prevX - 44, e.prevY - 44, 88, 88);
        }
        this._deltaJoystickVector.x = 0, this._deltaJoystickVector.y = 0, this._touches.remove(t.pointerId.toString());
      }, n.prototype.setJoystickColor = function(t) {
        this._joystickColor = t;
      }, Object.defineProperty(n.prototype, "containerSize", { get: function() {
        return this._joystickContainerSize;
      }, set: function(t) {
        this._joystickContainerSize = t, this._clearContainerSize = ~~(2.1 * this._joystickContainerSize), this._clearContainerSizeOffset = ~~(this._clearContainerSize / 2);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "puckSize", { get: function() {
        return this._joystickPuckSize;
      }, set: function(t) {
        this._joystickPuckSize = t, this._clearPuckSize = ~~(2.1 * this._joystickPuckSize), this._clearPuckSizeOffset = ~~(this._clearPuckSize / 2);
      }, enumerable: !1, configurable: !0 }), n.prototype.clearPosition = function() {
        this.alwaysVisible = !1, this._joystickPosition = null;
      }, Object.defineProperty(n.prototype, "alwaysVisible", { get: function() {
        return this._alwaysVisible;
      }, set: function(t) {
        this._alwaysVisible !== t && (t && this._joystickPosition ? (n._AlwaysVisibleSticks++, this._alwaysVisible = !0) : (n._AlwaysVisibleSticks--, this._alwaysVisible = !1));
      }, enumerable: !1, configurable: !0 }), n.prototype.setPosition = function(t, e) {
        this._joystickPointerStartPos && this._clearPreviousDraw(), this._joystickPosition = new fe(t, e);
      }, n.prototype.setActionOnTouch = function(t) {
        this._action = t;
      }, n.prototype.setAxisForLeftRight = function(t) {
        switch (t) {
          case Zi.X:
          case Zi.Y:
          case Zi.Z:
            this._axisTargetedByLeftAndRight = t;
            break;
          default:
            this._axisTargetedByLeftAndRight = Zi.X;
        }
      }, n.prototype.setAxisForUpDown = function(t) {
        switch (t) {
          case Zi.X:
          case Zi.Y:
          case Zi.Z:
            this._axisTargetedByUpAndDown = t;
            break;
          default:
            this._axisTargetedByUpAndDown = Zi.Y;
        }
      }, n.prototype._clearPreviousDraw = function() {
        var t = this._joystickPosition || this._joystickPointerStartPos;
        n._VJCanvasContext.clearRect(t.x - this._clearContainerSizeOffset, t.y - this._clearContainerSizeOffset, this._clearContainerSize, this._clearContainerSize), n._VJCanvasContext.clearRect(this._joystickPreviousPointerPos.x - this._clearPuckSizeOffset - 1, this._joystickPreviousPointerPos.y - this._clearPuckSizeOffset - 1, this._clearPuckSize + 2, this._clearPuckSize + 2);
      }, n.prototype.setContainerImage = function(t) {
        var e = this, i = new Image();
        i.src = t, i.onload = function() {
          return e._containerImage = i;
        };
      }, n.prototype.setPuckImage = function(t) {
        var e = this, i = new Image();
        i.src = t, i.onload = function() {
          return e._puckImage = i;
        };
      }, n.prototype._drawContainer = function() {
        var t = this._joystickPosition || this._joystickPointerStartPos;
        this._clearPreviousDraw(), this._containerImage ? n._VJCanvasContext.drawImage(this._containerImage, t.x - this.containerSize, t.y - this.containerSize, 2 * this.containerSize, 2 * this.containerSize) : (n._VJCanvasContext.beginPath(), n._VJCanvasContext.strokeStyle = this._joystickColor, n._VJCanvasContext.lineWidth = 2, n._VJCanvasContext.arc(t.x, t.y, this.containerSize, 0, 2 * Math.PI, !0), n._VJCanvasContext.stroke(), n._VJCanvasContext.closePath(), n._VJCanvasContext.beginPath(), n._VJCanvasContext.lineWidth = 6, n._VJCanvasContext.strokeStyle = this._joystickColor, n._VJCanvasContext.arc(t.x, t.y, this.puckSize, 0, 2 * Math.PI, !0), n._VJCanvasContext.stroke(), n._VJCanvasContext.closePath());
      }, n.prototype._drawPuck = function() {
        this._puckImage ? n._VJCanvasContext.drawImage(this._puckImage, this._joystickPointerPos.x - this.puckSize, this._joystickPointerPos.y - this.puckSize, 2 * this.puckSize, 2 * this.puckSize) : (n._VJCanvasContext.beginPath(), n._VJCanvasContext.strokeStyle = this._joystickColor, n._VJCanvasContext.lineWidth = 2, n._VJCanvasContext.arc(this._joystickPointerPos.x, this._joystickPointerPos.y, this.puckSize, 0, 2 * Math.PI, !0), n._VJCanvasContext.stroke(), n._VJCanvasContext.closePath());
      }, n.prototype._drawVirtualJoystick = function() {
        var t = this;
        this._released || (this.alwaysVisible && this._drawContainer(), this.pressed && this._touches.forEach(function(e, i) {
          i.pointerId === t._joystickPointerId ? (t.alwaysVisible || t._drawContainer(), t._drawPuck(), t._joystickPreviousPointerPos = t._joystickPointerPos.clone()) : (n._VJCanvasContext.clearRect(i.prevX - 44, i.prevY - 44, 88, 88), n._VJCanvasContext.beginPath(), n._VJCanvasContext.fillStyle = "white", n._VJCanvasContext.beginPath(), n._VJCanvasContext.strokeStyle = "red", n._VJCanvasContext.lineWidth = 6, n._VJCanvasContext.arc(i.x, i.y, 40, 0, 2 * Math.PI, !0), n._VJCanvasContext.stroke(), n._VJCanvasContext.closePath(), i.prevX = i.x, i.prevY = i.y);
        }), requestAnimationFrame(function() {
          t._drawVirtualJoystick();
        }));
      }, n.prototype.releaseCanvas = function() {
        n.Canvas && (n.Canvas.removeEventListener("pointerdown", this._onPointerDownHandlerRef), n.Canvas.removeEventListener("pointermove", this._onPointerMoveHandlerRef), n.Canvas.removeEventListener("pointerup", this._onPointerUpHandlerRef), n.Canvas.removeEventListener("pointerout", this._onPointerUpHandlerRef), window.removeEventListener("resize", this._onResize), document.body.removeChild(n.Canvas), n.Canvas = null), this._released = !0;
      }, n._GlobalJoystickIndex = 0, n._AlwaysVisibleSticks = 0, n;
    }();
    bc.prototype.addVirtualJoystick = function() {
      return this.add(new lf()), this;
    };
    var lf = function() {
      function n() {
      }
      return n.prototype.getLeftJoystick = function() {
        return this._leftjoystick;
      }, n.prototype.getRightJoystick = function() {
        return this._rightjoystick;
      }, n.prototype.checkInputs = function() {
        if (this._leftjoystick) {
          var t = this.camera, e = 50 * t._computeLocalCameraSpeed(), i = B.RotationYawPitchRoll(t.rotation.y, t.rotation.x, 0), r = v.TransformCoordinates(new v(this._leftjoystick.deltaPosition.x * e, this._leftjoystick.deltaPosition.y * e, this._leftjoystick.deltaPosition.z * e), i);
          t.cameraDirection = t.cameraDirection.add(r), t.cameraRotation = t.cameraRotation.addVector3(this._rightjoystick.deltaPosition), this._leftjoystick.pressed || (this._leftjoystick.deltaPosition = this._leftjoystick.deltaPosition.scale(0.9)), this._rightjoystick.pressed || (this._rightjoystick.deltaPosition = this._rightjoystick.deltaPosition.scale(0.9));
        }
      }, n.prototype.attachControl = function() {
        this._leftjoystick = new sf(!0), this._leftjoystick.setAxisForUpDown(Zi.Z), this._leftjoystick.setAxisForLeftRight(Zi.X), this._leftjoystick.setJoystickSensibility(0.15), this._rightjoystick = new sf(!1), this._rightjoystick.setAxisForUpDown(Zi.X), this._rightjoystick.setAxisForLeftRight(Zi.Y), this._rightjoystick.reverseUpDown = !0, this._rightjoystick.setJoystickSensibility(0.05), this._rightjoystick.setJoystickColor("yellow");
      }, n.prototype.detachControl = function() {
        this._leftjoystick.releaseCanvas(), this._rightjoystick.releaseCanvas();
      }, n.prototype.getClassName = function() {
        return "FreeCameraVirtualJoystickInput";
      }, n.prototype.getSimpleName = function() {
        return "virtualJoystick";
      }, n;
    }();
    gn.FreeCameraVirtualJoystickInput = lf;
    var ha = function(n) {
      function t(e, i, r, o) {
        o === void 0 && (o = !0);
        var a = n.call(this, e, i, r, o) || this;
        return a._tmpUpVector = v.Zero(), a._tmpTargetVector = v.Zero(), a.cameraDirection = new v(0, 0, 0), a.cameraRotation = new fe(0, 0), a.ignoreParentScaling = !1, a.updateUpVectorFromRotation = !1, a._tmpQuaternion = new oe(), a.rotation = new v(0, 0, 0), a.speed = 2, a.noRotationConstraint = !1, a.invertRotation = !1, a.inverseRotationSpeed = 0.2, a.lockedTarget = null, a._currentTarget = v.Zero(), a._initialFocalDistance = 1, a._viewMatrix = B.Zero(), a._camMatrix = B.Zero(), a._cameraTransformMatrix = B.Zero(), a._cameraRotationMatrix = B.Zero(), a._referencePoint = new v(0, 0, 1), a._transformedReferencePoint = v.Zero(), a._deferredPositionUpdate = new v(), a._deferredRotationQuaternionUpdate = new oe(), a._deferredRotationUpdate = new v(), a._deferredUpdated = !1, a._deferOnly = !1, a._defaultUp = v.Up(), a._cachedRotationZ = 0, a._cachedQuaternionRotationZ = 0, a;
      }
      return D(t, n), t.prototype.getFrontPosition = function(e) {
        this.getWorldMatrix();
        var i = this.getTarget().subtract(this.position);
        return i.normalize(), i.scaleInPlace(e), this.globalPosition.add(i);
      }, t.prototype._getLockedTargetPosition = function() {
        if (!this.lockedTarget)
          return null;
        if (this.lockedTarget.absolutePosition) {
          var e = this.lockedTarget;
          e.computeWorldMatrix().getTranslationToRef(e.absolutePosition);
        }
        return this.lockedTarget.absolutePosition || this.lockedTarget;
      }, t.prototype.storeState = function() {
        return this._storedPosition = this.position.clone(), this._storedRotation = this.rotation.clone(), this.rotationQuaternion && (this._storedRotationQuaternion = this.rotationQuaternion.clone()), n.prototype.storeState.call(this);
      }, t.prototype._restoreStateValues = function() {
        return !!n.prototype._restoreStateValues.call(this) && (this.position = this._storedPosition.clone(), this.rotation = this._storedRotation.clone(), this.rotationQuaternion && (this.rotationQuaternion = this._storedRotationQuaternion.clone()), this.cameraDirection.copyFromFloats(0, 0, 0), this.cameraRotation.copyFromFloats(0, 0), !0);
      }, t.prototype._initCache = function() {
        n.prototype._initCache.call(this), this._cache.lockedTarget = new v(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), this._cache.rotation = new v(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), this._cache.rotationQuaternion = new oe(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
      }, t.prototype._updateCache = function(e) {
        e || n.prototype._updateCache.call(this);
        var i = this._getLockedTargetPosition();
        i ? this._cache.lockedTarget ? this._cache.lockedTarget.copyFrom(i) : this._cache.lockedTarget = i.clone() : this._cache.lockedTarget = null, this._cache.rotation.copyFrom(this.rotation), this.rotationQuaternion && this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
      }, t.prototype._isSynchronizedViewMatrix = function() {
        if (!n.prototype._isSynchronizedViewMatrix.call(this))
          return !1;
        var e = this._getLockedTargetPosition();
        return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(e) : !e) && (this.rotationQuaternion ? this.rotationQuaternion.equals(this._cache.rotationQuaternion) : this._cache.rotation.equals(this.rotation));
      }, t.prototype._computeLocalCameraSpeed = function() {
        var e = this.getEngine();
        return this.speed * Math.sqrt(e.getDeltaTime() / (100 * e.getFps()));
      }, t.prototype.setTarget = function(e) {
        this.upVector.normalize(), this._initialFocalDistance = e.subtract(this.position).length(), this.position.z === e.z && (this.position.z += Ge), this._referencePoint.normalize().scaleInPlace(this._initialFocalDistance), B.LookAtLHToRef(this.position, e, this._defaultUp, this._camMatrix), this._camMatrix.invert(), this.rotation.x = Math.atan(this._camMatrix.m[6] / this._camMatrix.m[10]);
        var i = e.subtract(this.position);
        i.x >= 0 ? this.rotation.y = -Math.atan(i.z / i.x) + Math.PI / 2 : this.rotation.y = -Math.atan(i.z / i.x) - Math.PI / 2, this.rotation.z = 0, isNaN(this.rotation.x) && (this.rotation.x = 0), isNaN(this.rotation.y) && (this.rotation.y = 0), isNaN(this.rotation.z) && (this.rotation.z = 0), this.rotationQuaternion && oe.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
      }, Object.defineProperty(t.prototype, "target", { get: function() {
        return this.getTarget();
      }, set: function(e) {
        this.setTarget(e);
      }, enumerable: !1, configurable: !0 }), t.prototype.getTarget = function() {
        return this._currentTarget;
      }, t.prototype._decideIfNeedsToMove = function() {
        return Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
      }, t.prototype._updatePosition = function() {
        if (this.parent)
          return this.parent.getWorldMatrix().invertToRef(F.Matrix[0]), v.TransformNormalToRef(this.cameraDirection, F.Matrix[0], F.Vector3[0]), this._deferredPositionUpdate.addInPlace(F.Vector3[0]), void (this._deferOnly ? this._deferredUpdated = !0 : this.position.copyFrom(this._deferredPositionUpdate));
        this._deferredPositionUpdate.addInPlace(this.cameraDirection), this._deferOnly ? this._deferredUpdated = !0 : this.position.copyFrom(this._deferredPositionUpdate);
      }, t.prototype._checkInputs = function() {
        var e = this.invertRotation ? -this.inverseRotationSpeed : 1, i = this._decideIfNeedsToMove(), r = this.cameraRotation.x || this.cameraRotation.y;
        if (this._deferredUpdated = !1, this._deferredRotationUpdate.copyFrom(this.rotation), this._deferredPositionUpdate.copyFrom(this.position), this.rotationQuaternion && this._deferredRotationQuaternionUpdate.copyFrom(this.rotationQuaternion), i && this._updatePosition(), r) {
          if (this.rotationQuaternion && this.rotationQuaternion.toEulerAnglesToRef(this._deferredRotationUpdate), this._deferredRotationUpdate.x += this.cameraRotation.x * e, this._deferredRotationUpdate.y += this.cameraRotation.y * e, !this.noRotationConstraint) {
            var o = 1.570796;
            this._deferredRotationUpdate.x > o && (this._deferredRotationUpdate.x = o), this._deferredRotationUpdate.x < -o && (this._deferredRotationUpdate.x = -o);
          }
          this._deferOnly ? this._deferredUpdated = !0 : this.rotation.copyFrom(this._deferredRotationUpdate), this.rotationQuaternion && this._deferredRotationUpdate.lengthSquared() && (oe.RotationYawPitchRollToRef(this._deferredRotationUpdate.y, this._deferredRotationUpdate.x, this._deferredRotationUpdate.z, this._deferredRotationQuaternionUpdate), this._deferOnly ? this._deferredUpdated = !0 : this.rotationQuaternion.copyFrom(this._deferredRotationQuaternionUpdate));
        }
        i && (Math.abs(this.cameraDirection.x) < this.speed * Ge && (this.cameraDirection.x = 0), Math.abs(this.cameraDirection.y) < this.speed * Ge && (this.cameraDirection.y = 0), Math.abs(this.cameraDirection.z) < this.speed * Ge && (this.cameraDirection.z = 0), this.cameraDirection.scaleInPlace(this.inertia)), r && (Math.abs(this.cameraRotation.x) < this.speed * Ge && (this.cameraRotation.x = 0), Math.abs(this.cameraRotation.y) < this.speed * Ge && (this.cameraRotation.y = 0), this.cameraRotation.scaleInPlace(this.inertia)), n.prototype._checkInputs.call(this);
      }, t.prototype._updateCameraRotationMatrix = function() {
        this.rotationQuaternion ? this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix) : B.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
      }, t.prototype._rotateUpVectorWithCameraRotationMatrix = function() {
        return v.TransformNormalToRef(this._defaultUp, this._cameraRotationMatrix, this.upVector), this;
      }, t.prototype._getViewMatrix = function() {
        return this.lockedTarget && this.setTarget(this._getLockedTargetPosition()), this._updateCameraRotationMatrix(), this.rotationQuaternion && this._cachedQuaternionRotationZ != this.rotationQuaternion.z ? (this._rotateUpVectorWithCameraRotationMatrix(), this._cachedQuaternionRotationZ = this.rotationQuaternion.z) : this._cachedRotationZ !== this.rotation.z && (this._rotateUpVectorWithCameraRotationMatrix(), this._cachedRotationZ = this.rotation.z), v.TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint), this.position.addToRef(this._transformedReferencePoint, this._currentTarget), this.updateUpVectorFromRotation && (this.rotationQuaternion ? qi.Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector) : (oe.FromEulerVectorToRef(this.rotation, this._tmpQuaternion), qi.Y.rotateByQuaternionToRef(this._tmpQuaternion, this.upVector))), this._computeViewMatrix(this.position, this._currentTarget, this.upVector), this._viewMatrix;
      }, t.prototype._computeViewMatrix = function(e, i, r) {
        if (this.ignoreParentScaling) {
          if (this.parent) {
            var o = this.parent.getWorldMatrix();
            v.TransformCoordinatesToRef(e, o, this._globalPosition), v.TransformCoordinatesToRef(i, o, this._tmpTargetVector), v.TransformNormalToRef(r, o, this._tmpUpVector), this._markSyncedWithParent();
          } else
            this._globalPosition.copyFrom(e), this._tmpTargetVector.copyFrom(i), this._tmpUpVector.copyFrom(r);
          this.getScene().useRightHandedSystem ? B.LookAtRHToRef(this._globalPosition, this._tmpTargetVector, this._tmpUpVector, this._viewMatrix) : B.LookAtLHToRef(this._globalPosition, this._tmpTargetVector, this._tmpUpVector, this._viewMatrix);
        } else
          this.getScene().useRightHandedSystem ? B.LookAtRHToRef(e, i, r, this._viewMatrix) : B.LookAtLHToRef(e, i, r, this._viewMatrix), this.parent ? (o = this.parent.getWorldMatrix(), this._viewMatrix.invert(), this._viewMatrix.multiplyToRef(o, this._viewMatrix), this._viewMatrix.getTranslationToRef(this._globalPosition), this._viewMatrix.invert(), this._markSyncedWithParent()) : this._globalPosition.copyFrom(e);
      }, t.prototype.createRigCamera = function(e, i) {
        if (this.cameraRigMode !== dt.RIG_MODE_NONE) {
          var r = new t(e, this.position.clone(), this.getScene());
          return r.isRigCamera = !0, r.rigParent = this, this.cameraRigMode === dt.RIG_MODE_VR && (this.rotationQuaternion || (this.rotationQuaternion = new oe()), r._cameraRigParams = {}, r.rotationQuaternion = new oe()), r.mode = this.mode, r.orthoLeft = this.orthoLeft, r.orthoRight = this.orthoRight, r.orthoTop = this.orthoTop, r.orthoBottom = this.orthoBottom, r;
        }
        return null;
      }, t.prototype._updateRigCameras = function() {
        var e = this._rigCameras[0], i = this._rigCameras[1];
        switch (this.computeWorldMatrix(), this.cameraRigMode) {
          case dt.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
          case dt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
          case dt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
          case dt.RIG_MODE_STEREOSCOPIC_OVERUNDER:
          case dt.RIG_MODE_STEREOSCOPIC_INTERLACED:
            var r = this.cameraRigMode === dt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED ? 1 : -1, o = this.cameraRigMode === dt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED ? -1 : 1;
            this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * r, e), this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * o, i);
            break;
          case dt.RIG_MODE_VR:
            e.rotationQuaternion ? (e.rotationQuaternion.copyFrom(this.rotationQuaternion), i.rotationQuaternion.copyFrom(this.rotationQuaternion)) : (e.rotation.copyFrom(this.rotation), i.rotation.copyFrom(this.rotation)), e.position.copyFrom(this.position), i.position.copyFrom(this.position);
        }
        n.prototype._updateRigCameras.call(this);
      }, t.prototype._getRigCamPositionAndTarget = function(e, i) {
        this.getTarget().subtractToRef(this.position, t._TargetFocalPoint), t._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);
        var r = t._TargetFocalPoint.addInPlace(this.position);
        B.TranslationToRef(-r.x, -r.y, -r.z, t._TargetTransformMatrix), t._TargetTransformMatrix.multiplyToRef(B.RotationAxis(i.upVector, e), t._RigCamTransformMatrix), B.TranslationToRef(r.x, r.y, r.z, t._TargetTransformMatrix), t._RigCamTransformMatrix.multiplyToRef(t._TargetTransformMatrix, t._RigCamTransformMatrix), v.TransformCoordinatesToRef(this.position, t._RigCamTransformMatrix, i.position), i.setTarget(r);
      }, t.prototype.getClassName = function() {
        return "TargetCamera";
      }, t._RigCamTransformMatrix = new B(), t._TargetTransformMatrix = new B(), t._TargetFocalPoint = new v(), x([ki()], t.prototype, "rotation", void 0), x([N()], t.prototype, "speed", void 0), x([$o("lockedTargetId")], t.prototype, "lockedTarget", void 0), t;
    }(dt), Oo = function(n) {
      function t(e, i, r, o) {
        o === void 0 && (o = !0);
        var a = n.call(this, e, i, r, o) || this;
        return a.ellipsoid = new v(0.5, 1, 0.5), a.ellipsoidOffset = new v(0, 0, 0), a.checkCollisions = !1, a.applyGravity = !1, a._needMoveForGravity = !1, a._oldPosition = v.Zero(), a._diffPosition = v.Zero(), a._newPosition = v.Zero(), a._collisionMask = -1, a._onCollisionPositionChange = function(s, l, c) {
          c === void 0 && (c = null), a._newPosition.copyFrom(l), a._newPosition.subtractToRef(a._oldPosition, a._diffPosition), a._diffPosition.length() > ve.CollisionsEpsilon && (a.position.addToRef(a._diffPosition, a._deferredPositionUpdate), a._deferOnly ? a._deferredUpdated = !0 : a.position.copyFrom(a._deferredPositionUpdate), a.onCollide && c && a.onCollide(c));
        }, a.inputs = new bc(a), a.inputs.addKeyboard().addMouse(), a;
      }
      return D(t, n), Object.defineProperty(t.prototype, "angularSensibility", { get: function() {
        var e = this.inputs.attached.mouse;
        return e ? e.angularSensibility : 0;
      }, set: function(e) {
        var i = this.inputs.attached.mouse;
        i && (i.angularSensibility = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysUp", { get: function() {
        var e = this.inputs.attached.keyboard;
        return e ? e.keysUp : [];
      }, set: function(e) {
        var i = this.inputs.attached.keyboard;
        i && (i.keysUp = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysUpward", { get: function() {
        var e = this.inputs.attached.keyboard;
        return e ? e.keysUpward : [];
      }, set: function(e) {
        var i = this.inputs.attached.keyboard;
        i && (i.keysUpward = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysDown", { get: function() {
        var e = this.inputs.attached.keyboard;
        return e ? e.keysDown : [];
      }, set: function(e) {
        var i = this.inputs.attached.keyboard;
        i && (i.keysDown = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysDownward", { get: function() {
        var e = this.inputs.attached.keyboard;
        return e ? e.keysDownward : [];
      }, set: function(e) {
        var i = this.inputs.attached.keyboard;
        i && (i.keysDownward = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysLeft", { get: function() {
        var e = this.inputs.attached.keyboard;
        return e ? e.keysLeft : [];
      }, set: function(e) {
        var i = this.inputs.attached.keyboard;
        i && (i.keysLeft = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysRight", { get: function() {
        var e = this.inputs.attached.keyboard;
        return e ? e.keysRight : [];
      }, set: function(e) {
        var i = this.inputs.attached.keyboard;
        i && (i.keysRight = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysRotateLeft", { get: function() {
        var e = this.inputs.attached.keyboard;
        return e ? e.keysRotateLeft : [];
      }, set: function(e) {
        var i = this.inputs.attached.keyboard;
        i && (i.keysRotateLeft = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysRotateRight", { get: function() {
        var e = this.inputs.attached.keyboard;
        return e ? e.keysRotateRight : [];
      }, set: function(e) {
        var i = this.inputs.attached.keyboard;
        i && (i.keysRotateRight = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysRotateUp", { get: function() {
        var e = this.inputs.attached.keyboard;
        return e ? e.keysRotateUp : [];
      }, set: function(e) {
        var i = this.inputs.attached.keyboard;
        i && (i.keysRotateUp = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysRotateDown", { get: function() {
        var e = this.inputs.attached.keyboard;
        return e ? e.keysRotateDown : [];
      }, set: function(e) {
        var i = this.inputs.attached.keyboard;
        i && (i.keysRotateDown = e);
      }, enumerable: !1, configurable: !0 }), t.prototype.attachControl = function(e, i) {
        i = de.BackCompatCameraNoPreventDefault(arguments), this.inputs.attachElement(i);
      }, t.prototype.detachControl = function() {
        this.inputs.detachElement(), this.cameraDirection = new v(0, 0, 0), this.cameraRotation = new fe(0, 0);
      }, Object.defineProperty(t.prototype, "collisionMask", { get: function() {
        return this._collisionMask;
      }, set: function(e) {
        this._collisionMask = isNaN(e) ? -1 : e;
      }, enumerable: !1, configurable: !0 }), t.prototype._collideWithWorld = function(e) {
        (this.parent ? v.TransformCoordinates(this.position, this.parent.getWorldMatrix()) : this.position).subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition), this._oldPosition.addInPlace(this.ellipsoidOffset);
        var i = this.getScene().collisionCoordinator;
        this._collider || (this._collider = i.createCollider()), this._collider._radius = this.ellipsoid, this._collider.collisionMask = this._collisionMask;
        var r = e;
        this.applyGravity && (r = e.add(this.getScene().gravity)), i.getNewPosition(this._oldPosition, r, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
      }, t.prototype._checkInputs = function() {
        this._localDirection || (this._localDirection = v.Zero(), this._transformedDirection = v.Zero()), this.inputs.checkInputs(), n.prototype._checkInputs.call(this);
      }, Object.defineProperty(t.prototype, "needMoveForGravity", { get: function() {
        return this._needMoveForGravity;
      }, set: function(e) {
        this._needMoveForGravity = e;
      }, enumerable: !1, configurable: !0 }), t.prototype._decideIfNeedsToMove = function() {
        return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
      }, t.prototype._updatePosition = function() {
        this.checkCollisions && this.getScene().collisionsEnabled ? this._collideWithWorld(this.cameraDirection) : n.prototype._updatePosition.call(this);
      }, t.prototype.dispose = function() {
        this.inputs.clear(), n.prototype.dispose.call(this);
      }, t.prototype.getClassName = function() {
        return "FreeCamera";
      }, x([ki()], t.prototype, "ellipsoid", void 0), x([ki()], t.prototype, "ellipsoidOffset", void 0), x([N()], t.prototype, "checkCollisions", void 0), x([N()], t.prototype, "applyGravity", void 0), t;
    }(ha);
    oi.AddNodeConstructor("TouchCamera", function(n, t) {
      return function() {
        return new cf(n, v.Zero(), t);
      };
    });
    var cf = function(n) {
      function t(e, i, r) {
        var o = n.call(this, e, i, r) || this;
        return o.inputs.addTouch(), o._setupInputs(), o;
      }
      return D(t, n), Object.defineProperty(t.prototype, "touchAngularSensibility", { get: function() {
        var e = this.inputs.attached.touch;
        return e ? e.touchAngularSensibility : 0;
      }, set: function(e) {
        var i = this.inputs.attached.touch;
        i && (i.touchAngularSensibility = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "touchMoveSensibility", { get: function() {
        var e = this.inputs.attached.touch;
        return e ? e.touchMoveSensibility : 0;
      }, set: function(e) {
        var i = this.inputs.attached.touch;
        i && (i.touchMoveSensibility = e);
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "TouchCamera";
      }, t.prototype._setupInputs = function() {
        var e = this.inputs.attached.touch, i = this.inputs.attached.mouse;
        i ? i.touchEnabled = !1 : e.allowMouse = !0;
      }, t;
    }(Oo);
    oi.AddNodeConstructor("ArcRotateCamera", function(n, t) {
      return function() {
        return new gs(n, 0, 0, 1, v.Zero(), t);
      };
    });
    var gs = function(n) {
      function t(e, i, r, o, a, s, l) {
        l === void 0 && (l = !0);
        var c = n.call(this, e, v.Zero(), s, l) || this;
        return c.inertialAlphaOffset = 0, c.inertialBetaOffset = 0, c.inertialRadiusOffset = 0, c.lowerAlphaLimit = null, c.upperAlphaLimit = null, c.lowerBetaLimit = 0.01, c.upperBetaLimit = Math.PI - 0.01, c.lowerRadiusLimit = null, c.upperRadiusLimit = null, c.inertialPanningX = 0, c.inertialPanningY = 0, c.pinchToPanMaxDistance = 20, c.panningDistanceLimit = null, c.panningOriginTarget = v.Zero(), c.panningInertia = 0.9, c.zoomOnFactor = 1, c.targetScreenOffset = fe.Zero(), c.allowUpsideDown = !0, c.useInputToRestoreState = !0, c._viewMatrix = new B(), c.panningAxis = new v(1, 1, 0), c._transformedDirection = new v(), c.mapPanning = !1, c.onMeshTargetChangedObservable = new H(), c.checkCollisions = !1, c.collisionRadius = new v(0.5, 0.5, 0.5), c._previousPosition = v.Zero(), c._collisionVelocity = v.Zero(), c._newPosition = v.Zero(), c._computationVector = v.Zero(), c._onCollisionPositionChange = function(u, h, d) {
          d === void 0 && (d = null), d ? (c.setPosition(h), c.onCollide && c.onCollide(d)) : c._previousPosition.copyFrom(c._position);
          var p = Math.cos(c.alpha), f = Math.sin(c.alpha), m = Math.cos(c.beta), g = Math.sin(c.beta);
          g === 0 && (g = 1e-4);
          var y = c._getTargetPosition();
          c._computationVector.copyFromFloats(c.radius * p * g, c.radius * m, c.radius * f * g), y.addToRef(c._computationVector, c._newPosition), c._position.copyFrom(c._newPosition);
          var b = c.upVector;
          c.allowUpsideDown && c.beta < 0 && (b = (b = b.clone()).negate()), c._computeViewMatrix(c._position, y, b), c._viewMatrix.addAtIndex(12, c.targetScreenOffset.x), c._viewMatrix.addAtIndex(13, c.targetScreenOffset.y), c._collisionTriggered = !1;
        }, c._target = v.Zero(), a && c.setTarget(a), c.alpha = i, c.beta = r, c.radius = o, c.getViewMatrix(), c.inputs = new sh(c), c.inputs.addKeyboard().addMouseWheel().addPointers(), c;
      }
      return D(t, n), Object.defineProperty(t.prototype, "target", { get: function() {
        return this._target;
      }, set: function(e) {
        this.setTarget(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "targetHost", { get: function() {
        return this._targetHost;
      }, set: function(e) {
        e && this.setTarget(e);
      }, enumerable: !1, configurable: !0 }), t.prototype.getTarget = function() {
        return this.target;
      }, Object.defineProperty(t.prototype, "position", { get: function() {
        return this._position;
      }, set: function(e) {
        this.setPosition(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "upVector", { get: function() {
        return this._upVector;
      }, set: function(e) {
        this._upToYMatrix || (this._yToUpMatrix = new B(), this._upToYMatrix = new B(), this._upVector = v.Zero()), e.normalize(), this._upVector.copyFrom(e), this.setMatUp();
      }, enumerable: !1, configurable: !0 }), t.prototype.setMatUp = function() {
        B.RotationAlignToRef(v.UpReadOnly, this._upVector, this._yToUpMatrix), B.RotationAlignToRef(this._upVector, v.UpReadOnly, this._upToYMatrix);
      }, Object.defineProperty(t.prototype, "angularSensibilityX", { get: function() {
        var e = this.inputs.attached.pointers;
        return e ? e.angularSensibilityX : 0;
      }, set: function(e) {
        var i = this.inputs.attached.pointers;
        i && (i.angularSensibilityX = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "angularSensibilityY", { get: function() {
        var e = this.inputs.attached.pointers;
        return e ? e.angularSensibilityY : 0;
      }, set: function(e) {
        var i = this.inputs.attached.pointers;
        i && (i.angularSensibilityY = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "pinchPrecision", { get: function() {
        var e = this.inputs.attached.pointers;
        return e ? e.pinchPrecision : 0;
      }, set: function(e) {
        var i = this.inputs.attached.pointers;
        i && (i.pinchPrecision = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "pinchDeltaPercentage", { get: function() {
        var e = this.inputs.attached.pointers;
        return e ? e.pinchDeltaPercentage : 0;
      }, set: function(e) {
        var i = this.inputs.attached.pointers;
        i && (i.pinchDeltaPercentage = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "useNaturalPinchZoom", { get: function() {
        var e = this.inputs.attached.pointers;
        return !!e && e.useNaturalPinchZoom;
      }, set: function(e) {
        var i = this.inputs.attached.pointers;
        i && (i.useNaturalPinchZoom = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "panningSensibility", { get: function() {
        var e = this.inputs.attached.pointers;
        return e ? e.panningSensibility : 0;
      }, set: function(e) {
        var i = this.inputs.attached.pointers;
        i && (i.panningSensibility = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysUp", { get: function() {
        var e = this.inputs.attached.keyboard;
        return e ? e.keysUp : [];
      }, set: function(e) {
        var i = this.inputs.attached.keyboard;
        i && (i.keysUp = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysDown", { get: function() {
        var e = this.inputs.attached.keyboard;
        return e ? e.keysDown : [];
      }, set: function(e) {
        var i = this.inputs.attached.keyboard;
        i && (i.keysDown = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysLeft", { get: function() {
        var e = this.inputs.attached.keyboard;
        return e ? e.keysLeft : [];
      }, set: function(e) {
        var i = this.inputs.attached.keyboard;
        i && (i.keysLeft = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysRight", { get: function() {
        var e = this.inputs.attached.keyboard;
        return e ? e.keysRight : [];
      }, set: function(e) {
        var i = this.inputs.attached.keyboard;
        i && (i.keysRight = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wheelPrecision", { get: function() {
        var e = this.inputs.attached.mousewheel;
        return e ? e.wheelPrecision : 0;
      }, set: function(e) {
        var i = this.inputs.attached.mousewheel;
        i && (i.wheelPrecision = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "zoomToMouseLocation", { get: function() {
        var e = this.inputs.attached.mousewheel;
        return !!e && e.zoomToMouseLocation;
      }, set: function(e) {
        var i = this.inputs.attached.mousewheel;
        i && (i.zoomToMouseLocation = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wheelDeltaPercentage", { get: function() {
        var e = this.inputs.attached.mousewheel;
        return e ? e.wheelDeltaPercentage : 0;
      }, set: function(e) {
        var i = this.inputs.attached.mousewheel;
        i && (i.wheelDeltaPercentage = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "bouncingBehavior", { get: function() {
        return this._bouncingBehavior;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "useBouncingBehavior", { get: function() {
        return this._bouncingBehavior != null;
      }, set: function(e) {
        e !== this.useBouncingBehavior && (e ? (this._bouncingBehavior = new Mg(), this.addBehavior(this._bouncingBehavior)) : this._bouncingBehavior && (this.removeBehavior(this._bouncingBehavior), this._bouncingBehavior = null));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "framingBehavior", { get: function() {
        return this._framingBehavior;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "useFramingBehavior", { get: function() {
        return this._framingBehavior != null;
      }, set: function(e) {
        e !== this.useFramingBehavior && (e ? (this._framingBehavior = new Og(), this.addBehavior(this._framingBehavior)) : this._framingBehavior && (this.removeBehavior(this._framingBehavior), this._framingBehavior = null));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "autoRotationBehavior", { get: function() {
        return this._autoRotationBehavior;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "useAutoRotationBehavior", { get: function() {
        return this._autoRotationBehavior != null;
      }, set: function(e) {
        e !== this.useAutoRotationBehavior && (e ? (this._autoRotationBehavior = new Ig(), this.addBehavior(this._autoRotationBehavior)) : this._autoRotationBehavior && (this.removeBehavior(this._autoRotationBehavior), this._autoRotationBehavior = null));
      }, enumerable: !1, configurable: !0 }), t.prototype._initCache = function() {
        n.prototype._initCache.call(this), this._cache._target = new v(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), this._cache.alpha = void 0, this._cache.beta = void 0, this._cache.radius = void 0, this._cache.targetScreenOffset = fe.Zero();
      }, t.prototype._updateCache = function(e) {
        e || n.prototype._updateCache.call(this), this._cache._target.copyFrom(this._getTargetPosition()), this._cache.alpha = this.alpha, this._cache.beta = this.beta, this._cache.radius = this.radius, this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset);
      }, t.prototype._getTargetPosition = function() {
        if (this._targetHost && this._targetHost.getAbsolutePosition) {
          var e = this._targetHost.getAbsolutePosition();
          this._targetBoundingCenter ? e.addToRef(this._targetBoundingCenter, this._target) : this._target.copyFrom(e);
        }
        return this._getLockedTargetPosition() || this._target;
      }, t.prototype.storeState = function() {
        return this._storedAlpha = this.alpha, this._storedBeta = this.beta, this._storedRadius = this.radius, this._storedTarget = this._getTargetPosition().clone(), this._storedTargetScreenOffset = this.targetScreenOffset.clone(), n.prototype.storeState.call(this);
      }, t.prototype._restoreStateValues = function() {
        return !!n.prototype._restoreStateValues.call(this) && (this.setTarget(this._storedTarget.clone()), this.alpha = this._storedAlpha, this.beta = this._storedBeta, this.radius = this._storedRadius, this.targetScreenOffset = this._storedTargetScreenOffset.clone(), this.inertialAlphaOffset = 0, this.inertialBetaOffset = 0, this.inertialRadiusOffset = 0, this.inertialPanningX = 0, this.inertialPanningY = 0, !0);
      }, t.prototype._isSynchronizedViewMatrix = function() {
        return !!n.prototype._isSynchronizedViewMatrix.call(this) && this._cache._target.equals(this._getTargetPosition()) && this._cache.alpha === this.alpha && this._cache.beta === this.beta && this._cache.radius === this.radius && this._cache.targetScreenOffset.equals(this.targetScreenOffset);
      }, t.prototype.attachControl = function(e, i, r, o) {
        var a = this;
        r === void 0 && (r = !0), o === void 0 && (o = 2);
        var s = arguments;
        i = de.BackCompatCameraNoPreventDefault(s), this._useCtrlForPanning = r, this._panningMouseButton = o, typeof s[0] == "boolean" && (s.length > 1 && (this._useCtrlForPanning = s[1]), s.length > 2 && (this._panningMouseButton = s[2])), this.inputs.attachElement(i), this._reset = function() {
          a.inertialAlphaOffset = 0, a.inertialBetaOffset = 0, a.inertialRadiusOffset = 0, a.inertialPanningX = 0, a.inertialPanningY = 0;
        };
      }, t.prototype.detachControl = function() {
        this.inputs.detachElement(), this._reset && this._reset();
      }, t.prototype._checkInputs = function() {
        if (!this._collisionTriggered) {
          if (this.inputs.checkInputs(), this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
            var e = this.invertRotation ? -1 : 1, i = this._calculateHandednessMultiplier(), r = this.inertialAlphaOffset * i;
            this.beta <= 0 && (r *= -1), this.alpha += r * e, this.beta += this.inertialBetaOffset * e, this.radius -= this.inertialRadiusOffset, this.inertialAlphaOffset *= this.inertia, this.inertialBetaOffset *= this.inertia, this.inertialRadiusOffset *= this.inertia, Math.abs(this.inertialAlphaOffset) < Ge && (this.inertialAlphaOffset = 0), Math.abs(this.inertialBetaOffset) < Ge && (this.inertialBetaOffset = 0), Math.abs(this.inertialRadiusOffset) < this.speed * Ge && (this.inertialRadiusOffset = 0);
          }
          if (this.inertialPanningX !== 0 || this.inertialPanningY !== 0) {
            var o = new v(this.inertialPanningX, this.inertialPanningY, this.inertialPanningY);
            if (this._viewMatrix.invertToRef(this._cameraTransformMatrix), o.multiplyInPlace(this.panningAxis), v.TransformNormalToRef(o, this._cameraTransformMatrix, this._transformedDirection), this.mapPanning) {
              var a = this.upVector, s = v.CrossToRef(this._transformedDirection, a, this._transformedDirection);
              v.CrossToRef(a, s, this._transformedDirection);
            } else
              this.panningAxis.y || (this._transformedDirection.y = 0);
            this._targetHost || (this.panningDistanceLimit ? (this._transformedDirection.addInPlace(this._target), v.DistanceSquared(this._transformedDirection, this.panningOriginTarget) <= this.panningDistanceLimit * this.panningDistanceLimit && this._target.copyFrom(this._transformedDirection)) : this._target.addInPlace(this._transformedDirection)), this.inertialPanningX *= this.panningInertia, this.inertialPanningY *= this.panningInertia, Math.abs(this.inertialPanningX) < this.speed * Ge && (this.inertialPanningX = 0), Math.abs(this.inertialPanningY) < this.speed * Ge && (this.inertialPanningY = 0);
          }
          this._checkLimits(), n.prototype._checkInputs.call(this);
        }
      }, t.prototype._checkLimits = function() {
        this.lowerBetaLimit === null || this.lowerBetaLimit === void 0 ? this.allowUpsideDown && this.beta > Math.PI && (this.beta = this.beta - 2 * Math.PI) : this.beta < this.lowerBetaLimit && (this.beta = this.lowerBetaLimit), this.upperBetaLimit === null || this.upperBetaLimit === void 0 ? this.allowUpsideDown && this.beta < -Math.PI && (this.beta = this.beta + 2 * Math.PI) : this.beta > this.upperBetaLimit && (this.beta = this.upperBetaLimit), this.lowerAlphaLimit !== null && this.alpha < this.lowerAlphaLimit && (this.alpha = this.lowerAlphaLimit), this.upperAlphaLimit !== null && this.alpha > this.upperAlphaLimit && (this.alpha = this.upperAlphaLimit), this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit && (this.radius = this.lowerRadiusLimit, this.inertialRadiusOffset = 0), this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit && (this.radius = this.upperRadiusLimit, this.inertialRadiusOffset = 0);
      }, t.prototype.rebuildAnglesAndRadius = function() {
        this._position.subtractToRef(this._getTargetPosition(), this._computationVector), this._upVector.x === 0 && this._upVector.y === 1 && this._upVector.z === 0 || v.TransformCoordinatesToRef(this._computationVector, this._upToYMatrix, this._computationVector), this.radius = this._computationVector.length(), this.radius === 0 && (this.radius = 1e-4);
        var e = this.alpha;
        this._computationVector.x === 0 && this._computationVector.z === 0 ? this.alpha = Math.PI / 2 : this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2))), this._computationVector.z < 0 && (this.alpha = 2 * Math.PI - this.alpha);
        var i = Math.round((e - this.alpha) / (2 * Math.PI));
        this.alpha += 2 * i * Math.PI, this.beta = Math.acos(this._computationVector.y / this.radius), this._checkLimits();
      }, t.prototype.setPosition = function(e) {
        this._position.equals(e) || (this._position.copyFrom(e), this.rebuildAnglesAndRadius());
      }, t.prototype.setTarget = function(e, i, r, o) {
        var a;
        if (i === void 0 && (i = !1), r === void 0 && (r = !1), o === void 0 && (o = !1), o = (a = this.overrideCloneAlphaBetaRadius) !== null && a !== void 0 ? a : o, e.getBoundingInfo)
          this._targetBoundingCenter = i ? e.getBoundingInfo().boundingBox.centerWorld.clone() : null, e.computeWorldMatrix(), this._targetHost = e, this._target = this._getTargetPosition(), this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);
        else {
          var s = e, l = this._getTargetPosition();
          if (l && !r && l.equals(s))
            return;
          this._targetHost = null, this._target = s, this._targetBoundingCenter = null, this.onMeshTargetChangedObservable.notifyObservers(null);
        }
        o || this.rebuildAnglesAndRadius();
      }, t.prototype._getViewMatrix = function() {
        var e = Math.cos(this.alpha), i = Math.sin(this.alpha), r = Math.cos(this.beta), o = Math.sin(this.beta);
        o === 0 && (o = 1e-4), this.radius === 0 && (this.radius = 1e-4);
        var a = this._getTargetPosition();
        if (this._computationVector.copyFromFloats(this.radius * e * o, this.radius * r, this.radius * i * o), this._upVector.x === 0 && this._upVector.y === 1 && this._upVector.z === 0 || v.TransformCoordinatesToRef(this._computationVector, this._yToUpMatrix, this._computationVector), a.addToRef(this._computationVector, this._newPosition), this.getScene().collisionsEnabled && this.checkCollisions) {
          var s = this.getScene().collisionCoordinator;
          this._collider || (this._collider = s.createCollider()), this._collider._radius = this.collisionRadius, this._newPosition.subtractToRef(this._position, this._collisionVelocity), this._collisionTriggered = !0, s.getNewPosition(this._position, this._collisionVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
        } else {
          this._position.copyFrom(this._newPosition);
          var l = this.upVector;
          this.allowUpsideDown && o < 0 && (l = l.negate()), this._computeViewMatrix(this._position, a, l), this._viewMatrix.addAtIndex(12, this.targetScreenOffset.x), this._viewMatrix.addAtIndex(13, this.targetScreenOffset.y);
        }
        return this._currentTarget = a, this._viewMatrix;
      }, t.prototype.zoomOn = function(e, i) {
        i === void 0 && (i = !1), e = e || this.getScene().meshes;
        var r = ie.MinMax(e), o = this._calculateLowerRadiusFromModelBoundingSphere(r.min, r.max);
        o = Math.max(Math.min(o, this.upperRadiusLimit || Number.MAX_VALUE), this.lowerRadiusLimit || 0), this.radius = o * this.zoomOnFactor, this.focusOn({ min: r.min, max: r.max, distance: o }, i);
      }, t.prototype.focusOn = function(e, i) {
        var r, o;
        if (i === void 0 && (i = !1), e.min === void 0) {
          var a = e || this.getScene().meshes;
          r = ie.MinMax(a), o = v.Distance(r.min, r.max);
        } else
          r = e, o = e.distance;
        this._target = ie.Center(r), i || (this.maxZ = 2 * o);
      }, t.prototype.createRigCamera = function(e, i) {
        var r = 0;
        switch (this.cameraRigMode) {
          case dt.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
          case dt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
          case dt.RIG_MODE_STEREOSCOPIC_OVERUNDER:
          case dt.RIG_MODE_STEREOSCOPIC_INTERLACED:
          case dt.RIG_MODE_VR:
            r = this._cameraRigParams.stereoHalfAngle * (i === 0 ? 1 : -1);
            break;
          case dt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
            r = this._cameraRigParams.stereoHalfAngle * (i === 0 ? -1 : 1);
        }
        var o = new t(e, this.alpha + r, this.beta, this.radius, this._target, this.getScene());
        return o._cameraRigParams = {}, o.isRigCamera = !0, o.rigParent = this, o.upVector = this.upVector, o.mode = this.mode, o.orthoLeft = this.orthoLeft, o.orthoRight = this.orthoRight, o.orthoBottom = this.orthoBottom, o.orthoTop = this.orthoTop, o;
      }, t.prototype._updateRigCameras = function() {
        var e = this._rigCameras[0], i = this._rigCameras[1];
        switch (e.beta = i.beta = this.beta, this.cameraRigMode) {
          case dt.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
          case dt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
          case dt.RIG_MODE_STEREOSCOPIC_OVERUNDER:
          case dt.RIG_MODE_STEREOSCOPIC_INTERLACED:
          case dt.RIG_MODE_VR:
            e.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle, i.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
            break;
          case dt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
            e.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle, i.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
        }
        n.prototype._updateRigCameras.call(this);
      }, t.prototype._calculateLowerRadiusFromModelBoundingSphere = function(e, i, r) {
        r === void 0 && (r = 1);
        var o = v.Distance(e, i), a = this.getScene().getEngine().getAspectRatio(this), s = Math.tan(this.fov / 2), l = s * a, c = 0.5 * o * r, u = c * Math.sqrt(1 + 1 / (l * l)), h = c * Math.sqrt(1 + 1 / (s * s));
        return Math.max(u, h);
      }, t.prototype.dispose = function() {
        this.inputs.clear(), n.prototype.dispose.call(this);
      }, t.prototype.getClassName = function() {
        return "ArcRotateCamera";
      }, x([N()], t.prototype, "alpha", void 0), x([N()], t.prototype, "beta", void 0), x([N()], t.prototype, "radius", void 0), x([N()], t.prototype, "overrideCloneAlphaBetaRadius", void 0), x([ki("target")], t.prototype, "_target", void 0), x([$o("targetHost")], t.prototype, "_targetHost", void 0), x([N()], t.prototype, "inertialAlphaOffset", void 0), x([N()], t.prototype, "inertialBetaOffset", void 0), x([N()], t.prototype, "inertialRadiusOffset", void 0), x([N()], t.prototype, "lowerAlphaLimit", void 0), x([N()], t.prototype, "upperAlphaLimit", void 0), x([N()], t.prototype, "lowerBetaLimit", void 0), x([N()], t.prototype, "upperBetaLimit", void 0), x([N()], t.prototype, "lowerRadiusLimit", void 0), x([N()], t.prototype, "upperRadiusLimit", void 0), x([N()], t.prototype, "inertialPanningX", void 0), x([N()], t.prototype, "inertialPanningY", void 0), x([N()], t.prototype, "pinchToPanMaxDistance", void 0), x([N()], t.prototype, "panningDistanceLimit", void 0), x([ki()], t.prototype, "panningOriginTarget", void 0), x([N()], t.prototype, "panningInertia", void 0), x([N()], t.prototype, "zoomToMouseLocation", null), x([N()], t.prototype, "zoomOnFactor", void 0), x([ss()], t.prototype, "targetScreenOffset", void 0), x([N()], t.prototype, "allowUpsideDown", void 0), x([N()], t.prototype, "useInputToRestoreState", void 0), t;
    }(ha);
    oi.AddNodeConstructor("DeviceOrientationCamera", function(n, t) {
      return function() {
        return new lh(n, v.Zero(), t);
      };
    });
    var lh = function(n) {
      function t(e, i, r) {
        var o = n.call(this, e, i, r) || this;
        return o._tmpDragQuaternion = new oe(), o._disablePointerInputWhenUsingDeviceOrientation = !0, o._dragFactor = 0, o._quaternionCache = new oe(), o.inputs.addDeviceOrientation(), o.inputs._deviceOrientationInput && o.inputs._deviceOrientationInput._onDeviceOrientationChangedObservable.addOnce(function() {
          o._disablePointerInputWhenUsingDeviceOrientation && o.inputs._mouseInput && (o.inputs._mouseInput._allowCameraRotation = !1, o.inputs._mouseInput.onPointerMovedObservable.add(function(a) {
            o._dragFactor != 0 && (o._initialQuaternion || (o._initialQuaternion = new oe()), oe.FromEulerAnglesToRef(0, a.offsetX * o._dragFactor, 0, o._tmpDragQuaternion), o._initialQuaternion.multiplyToRef(o._tmpDragQuaternion, o._initialQuaternion));
          }));
        }), o;
      }
      return D(t, n), Object.defineProperty(t.prototype, "disablePointerInputWhenUsingDeviceOrientation", { get: function() {
        return this._disablePointerInputWhenUsingDeviceOrientation;
      }, set: function(e) {
        this._disablePointerInputWhenUsingDeviceOrientation = e;
      }, enumerable: !1, configurable: !0 }), t.prototype.enableHorizontalDragging = function(e) {
        e === void 0 && (e = 1 / 300), this._dragFactor = e;
      }, t.prototype.getClassName = function() {
        return "DeviceOrientationCamera";
      }, t.prototype._checkInputs = function() {
        n.prototype._checkInputs.call(this), this._quaternionCache.copyFrom(this.rotationQuaternion), this._initialQuaternion && this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
      }, t.prototype.resetToCurrentRotation = function(e) {
        var i = this;
        e === void 0 && (e = qi.Y), this.rotationQuaternion && (this._initialQuaternion || (this._initialQuaternion = new oe()), this._initialQuaternion.copyFrom(this._quaternionCache || this.rotationQuaternion), ["x", "y", "z"].forEach(function(r) {
          e[r] ? i._initialQuaternion[r] *= -1 : i._initialQuaternion[r] = 0;
        }), this._initialQuaternion.normalize(), this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion));
      }, t;
    }(Oo), Hg = function(n) {
      function t(e) {
        return n.call(this, e) || this;
      }
      return D(t, n), t.prototype.addKeyboard = function() {
        return this.add(new qp()), this;
      }, t.prototype.addMouse = function() {
        return this.add(new Qp()), this;
      }, t;
    }(yc), LR = function(n) {
      function t(e, i, r, o) {
        o === void 0 && (o = !0);
        var a = n.call(this, e, i, r, o) || this;
        return a.ellipsoid = new v(1, 1, 1), a.ellipsoidOffset = new v(0, 0, 0), a.checkCollisions = !1, a.applyGravity = !1, a.cameraDirection = v.Zero(), a._trackRoll = 0, a.rollCorrect = 100, a.bankedTurn = !1, a.bankedTurnLimit = Math.PI / 2, a.bankedTurnMultiplier = 1, a._needMoveForGravity = !1, a._oldPosition = v.Zero(), a._diffPosition = v.Zero(), a._newPosition = v.Zero(), a._collisionMask = -1, a._onCollisionPositionChange = function(s, l, c) {
          var u;
          c === void 0 && (c = null), u = l, a._newPosition.copyFrom(u), a._newPosition.subtractToRef(a._oldPosition, a._diffPosition), a._diffPosition.length() > ve.CollisionsEpsilon && (a.position.addInPlace(a._diffPosition), a.onCollide && c && a.onCollide(c));
        }, a.inputs = new Hg(a), a.inputs.addKeyboard().addMouse(), a;
      }
      return D(t, n), Object.defineProperty(t.prototype, "angularSensibility", { get: function() {
        var e = this.inputs.attached.mouse;
        return e ? e.angularSensibility : 0;
      }, set: function(e) {
        var i = this.inputs.attached.mouse;
        i && (i.angularSensibility = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysForward", { get: function() {
        var e = this.inputs.attached.keyboard;
        return e ? e.keysForward : [];
      }, set: function(e) {
        var i = this.inputs.attached.keyboard;
        i && (i.keysForward = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysBackward", { get: function() {
        var e = this.inputs.attached.keyboard;
        return e ? e.keysBackward : [];
      }, set: function(e) {
        var i = this.inputs.attached.keyboard;
        i && (i.keysBackward = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysUp", { get: function() {
        var e = this.inputs.attached.keyboard;
        return e ? e.keysUp : [];
      }, set: function(e) {
        var i = this.inputs.attached.keyboard;
        i && (i.keysUp = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysDown", { get: function() {
        var e = this.inputs.attached.keyboard;
        return e ? e.keysDown : [];
      }, set: function(e) {
        var i = this.inputs.attached.keyboard;
        i && (i.keysDown = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysLeft", { get: function() {
        var e = this.inputs.attached.keyboard;
        return e ? e.keysLeft : [];
      }, set: function(e) {
        var i = this.inputs.attached.keyboard;
        i && (i.keysLeft = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysRight", { get: function() {
        var e = this.inputs.attached.keyboard;
        return e ? e.keysRight : [];
      }, set: function(e) {
        var i = this.inputs.attached.keyboard;
        i && (i.keysRight = e);
      }, enumerable: !1, configurable: !0 }), t.prototype.attachControl = function(e, i) {
        i = de.BackCompatCameraNoPreventDefault(arguments), this.inputs.attachElement(i);
      }, t.prototype.detachControl = function() {
        this.inputs.detachElement(), this.cameraDirection = new v(0, 0, 0);
      }, Object.defineProperty(t.prototype, "collisionMask", { get: function() {
        return this._collisionMask;
      }, set: function(e) {
        this._collisionMask = isNaN(e) ? -1 : e;
      }, enumerable: !1, configurable: !0 }), t.prototype._collideWithWorld = function(e) {
        (this.parent ? v.TransformCoordinates(this.position, this.parent.getWorldMatrix()) : this.position).subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition), this._oldPosition.addInPlace(this.ellipsoidOffset);
        var i = this.getScene().collisionCoordinator;
        this._collider || (this._collider = i.createCollider()), this._collider._radius = this.ellipsoid, this._collider.collisionMask = this._collisionMask;
        var r = e;
        this.applyGravity && (r = e.add(this.getScene().gravity)), i.getNewPosition(this._oldPosition, r, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
      }, t.prototype._checkInputs = function() {
        this._localDirection || (this._localDirection = v.Zero(), this._transformedDirection = v.Zero()), this.inputs.checkInputs(), n.prototype._checkInputs.call(this);
      }, Object.defineProperty(t.prototype, "needMoveForGravity", { get: function() {
        return this._needMoveForGravity;
      }, set: function(e) {
        this._needMoveForGravity = e;
      }, enumerable: !1, configurable: !0 }), t.prototype._decideIfNeedsToMove = function() {
        return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
      }, t.prototype._updatePosition = function() {
        this.checkCollisions && this.getScene().collisionsEnabled ? this._collideWithWorld(this.cameraDirection) : n.prototype._updatePosition.call(this);
      }, t.prototype.restoreRoll = function(e) {
        var i = this._trackRoll, r = i - this.rotation.z;
        Math.abs(r) >= 1e-3 && (this.rotation.z += r / e, Math.abs(i - this.rotation.z) <= 1e-3 && (this.rotation.z = i));
      }, t.prototype.dispose = function() {
        this.inputs.clear(), n.prototype.dispose.call(this);
      }, t.prototype.getClassName = function() {
        return "FlyCamera";
      }, x([ki()], t.prototype, "ellipsoid", void 0), x([ki()], t.prototype, "ellipsoidOffset", void 0), x([N()], t.prototype, "checkCollisions", void 0), x([N()], t.prototype, "applyGravity", void 0), t;
    }(ha), Xg = function(n) {
      function t(e) {
        return n.call(this, e) || this;
      }
      return D(t, n), t.prototype.addKeyboard = function() {
        return this.add(new Zp()), this;
      }, t.prototype.addMouseWheel = function() {
        return this.add(new Jp()), this;
      }, t.prototype.addPointers = function() {
        return this.add(new $p()), this;
      }, t.prototype.addVRDeviceOrientation = function() {
        return console.warn("DeviceOrientation support not yet implemented for FollowCamera."), this;
      }, t;
    }(yc);
    oi.AddNodeConstructor("FollowCamera", function(n, t) {
      return function() {
        return new jg(n, v.Zero(), t);
      };
    }), oi.AddNodeConstructor("ArcFollowCamera", function(n, t) {
      return function() {
        return new Yg(n, 0, 0, 1, null, t);
      };
    });
    var ir, vs, jg = function(n) {
      function t(e, i, r, o) {
        o === void 0 && (o = null);
        var a = n.call(this, e, i, r) || this;
        return a.radius = 12, a.lowerRadiusLimit = null, a.upperRadiusLimit = null, a.rotationOffset = 0, a.lowerRotationOffsetLimit = null, a.upperRotationOffsetLimit = null, a.heightOffset = 4, a.lowerHeightOffsetLimit = null, a.upperHeightOffsetLimit = null, a.cameraAcceleration = 0.05, a.maxCameraSpeed = 20, a.lockedTarget = o, a.inputs = new Xg(a), a.inputs.addKeyboard().addMouseWheel().addPointers(), a;
      }
      return D(t, n), t.prototype._follow = function(e) {
        if (e) {
          var i = F.Matrix[0];
          e.absoluteRotationQuaternion.toRotationMatrix(i);
          var r = Math.atan2(i.m[8], i.m[10]), o = de.ToRadians(this.rotationOffset) + r, a = e.getAbsolutePosition(), s = a.x + Math.sin(o) * this.radius, l = a.z + Math.cos(o) * this.radius, c = s - this.position.x, u = a.y + this.heightOffset - this.position.y, h = l - this.position.z, d = c * this.cameraAcceleration * 2, p = u * this.cameraAcceleration, f = h * this.cameraAcceleration * 2;
          (d > this.maxCameraSpeed || d < -this.maxCameraSpeed) && (d = d < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed), (p > this.maxCameraSpeed || p < -this.maxCameraSpeed) && (p = p < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed), (f > this.maxCameraSpeed || f < -this.maxCameraSpeed) && (f = f < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed), this.position = new v(this.position.x + d, this.position.y + p, this.position.z + f), this.setTarget(a);
        }
      }, t.prototype.attachControl = function(e, i) {
        i = de.BackCompatCameraNoPreventDefault(arguments), this.inputs.attachElement(i), this._reset = function() {
        };
      }, t.prototype.detachControl = function() {
        this.inputs.detachElement(), this._reset && this._reset();
      }, t.prototype._checkInputs = function() {
        this.inputs.checkInputs(), this._checkLimits(), n.prototype._checkInputs.call(this), this.lockedTarget && this._follow(this.lockedTarget);
      }, t.prototype._checkLimits = function() {
        this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit && (this.radius = this.lowerRadiusLimit), this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit && (this.radius = this.upperRadiusLimit), this.lowerHeightOffsetLimit !== null && this.heightOffset < this.lowerHeightOffsetLimit && (this.heightOffset = this.lowerHeightOffsetLimit), this.upperHeightOffsetLimit !== null && this.heightOffset > this.upperHeightOffsetLimit && (this.heightOffset = this.upperHeightOffsetLimit), this.lowerRotationOffsetLimit !== null && this.rotationOffset < this.lowerRotationOffsetLimit && (this.rotationOffset = this.lowerRotationOffsetLimit), this.upperRotationOffsetLimit !== null && this.rotationOffset > this.upperRotationOffsetLimit && (this.rotationOffset = this.upperRotationOffsetLimit);
      }, t.prototype.getClassName = function() {
        return "FollowCamera";
      }, x([N()], t.prototype, "radius", void 0), x([N()], t.prototype, "lowerRadiusLimit", void 0), x([N()], t.prototype, "upperRadiusLimit", void 0), x([N()], t.prototype, "rotationOffset", void 0), x([N()], t.prototype, "lowerRotationOffsetLimit", void 0), x([N()], t.prototype, "upperRotationOffsetLimit", void 0), x([N()], t.prototype, "heightOffset", void 0), x([N()], t.prototype, "lowerHeightOffsetLimit", void 0), x([N()], t.prototype, "upperHeightOffsetLimit", void 0), x([N()], t.prototype, "cameraAcceleration", void 0), x([N()], t.prototype, "maxCameraSpeed", void 0), x([$o("lockedTargetId")], t.prototype, "lockedTarget", void 0), t;
    }(ha), Yg = function(n) {
      function t(e, i, r, o, a, s) {
        var l = n.call(this, e, v.Zero(), s) || this;
        return l.alpha = i, l.beta = r, l.radius = o, l._cartesianCoordinates = v.Zero(), l.setMeshTarget(a), l;
      }
      return D(t, n), t.prototype.setMeshTarget = function(e) {
        this._meshTarget = e, this._follow();
      }, t.prototype._follow = function() {
        if (this._meshTarget) {
          this._cartesianCoordinates.x = this.radius * Math.cos(this.alpha) * Math.cos(this.beta), this._cartesianCoordinates.y = this.radius * Math.sin(this.beta), this._cartesianCoordinates.z = this.radius * Math.sin(this.alpha) * Math.cos(this.beta);
          var e = this._meshTarget.getAbsolutePosition();
          this.position = e.add(this._cartesianCoordinates), this.setTarget(e);
        }
      }, t.prototype._checkInputs = function() {
        n.prototype._checkInputs.call(this), this._follow();
      }, t.prototype.getClassName = function() {
        return "ArcFollowCamera";
      }, t;
    }(ha);
    (function(n) {
      n[n.A = 0] = "A", n[n.B = 1] = "B", n[n.X = 2] = "X", n[n.Y = 3] = "Y", n[n.LB = 4] = "LB", n[n.RB = 5] = "RB", n[n.Back = 8] = "Back", n[n.Start = 9] = "Start", n[n.LeftStick = 10] = "LeftStick", n[n.RightStick = 11] = "RightStick";
    })(ir || (ir = {})), function(n) {
      n[n.Up = 12] = "Up", n[n.Down = 13] = "Down", n[n.Left = 14] = "Left", n[n.Right = 15] = "Right";
    }(vs || (vs = {}));
    var Pr, ys, Kg = function(n) {
      function t(e, i, r, o) {
        o === void 0 && (o = !1);
        var a = n.call(this, e, i, r, 0, 1, 2, 3) || this;
        return a._leftTrigger = 0, a._rightTrigger = 0, a.onButtonDownObservable = new H(), a.onButtonUpObservable = new H(), a.onPadDownObservable = new H(), a.onPadUpObservable = new H(), a._buttonA = 0, a._buttonB = 0, a._buttonX = 0, a._buttonY = 0, a._buttonBack = 0, a._buttonStart = 0, a._buttonLB = 0, a._buttonRB = 0, a._buttonLeftStick = 0, a._buttonRightStick = 0, a._dPadUp = 0, a._dPadDown = 0, a._dPadLeft = 0, a._dPadRight = 0, a._isXboxOnePad = !1, a.type = qn.XBOX, a._isXboxOnePad = o, a;
      }
      return D(t, n), t.prototype.onlefttriggerchanged = function(e) {
        this._onlefttriggerchanged = e;
      }, t.prototype.onrighttriggerchanged = function(e) {
        this._onrighttriggerchanged = e;
      }, Object.defineProperty(t.prototype, "leftTrigger", { get: function() {
        return this._leftTrigger;
      }, set: function(e) {
        this._onlefttriggerchanged && this._leftTrigger !== e && this._onlefttriggerchanged(e), this._leftTrigger = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rightTrigger", { get: function() {
        return this._rightTrigger;
      }, set: function(e) {
        this._onrighttriggerchanged && this._rightTrigger !== e && this._onrighttriggerchanged(e), this._rightTrigger = e;
      }, enumerable: !1, configurable: !0 }), t.prototype.onbuttondown = function(e) {
        this._onbuttondown = e;
      }, t.prototype.onbuttonup = function(e) {
        this._onbuttonup = e;
      }, t.prototype.ondpaddown = function(e) {
        this._ondpaddown = e;
      }, t.prototype.ondpadup = function(e) {
        this._ondpadup = e;
      }, t.prototype._setButtonValue = function(e, i, r) {
        return e !== i && (e === 1 && (this._onbuttondown && this._onbuttondown(r), this.onButtonDownObservable.notifyObservers(r)), e === 0 && (this._onbuttonup && this._onbuttonup(r), this.onButtonUpObservable.notifyObservers(r))), e;
      }, t.prototype._setDPadValue = function(e, i, r) {
        return e !== i && (e === 1 && (this._ondpaddown && this._ondpaddown(r), this.onPadDownObservable.notifyObservers(r)), e === 0 && (this._ondpadup && this._ondpadup(r), this.onPadUpObservable.notifyObservers(r))), e;
      }, Object.defineProperty(t.prototype, "buttonA", { get: function() {
        return this._buttonA;
      }, set: function(e) {
        this._buttonA = this._setButtonValue(e, this._buttonA, ir.A);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonB", { get: function() {
        return this._buttonB;
      }, set: function(e) {
        this._buttonB = this._setButtonValue(e, this._buttonB, ir.B);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonX", { get: function() {
        return this._buttonX;
      }, set: function(e) {
        this._buttonX = this._setButtonValue(e, this._buttonX, ir.X);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonY", { get: function() {
        return this._buttonY;
      }, set: function(e) {
        this._buttonY = this._setButtonValue(e, this._buttonY, ir.Y);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonStart", { get: function() {
        return this._buttonStart;
      }, set: function(e) {
        this._buttonStart = this._setButtonValue(e, this._buttonStart, ir.Start);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonBack", { get: function() {
        return this._buttonBack;
      }, set: function(e) {
        this._buttonBack = this._setButtonValue(e, this._buttonBack, ir.Back);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonLB", { get: function() {
        return this._buttonLB;
      }, set: function(e) {
        this._buttonLB = this._setButtonValue(e, this._buttonLB, ir.LB);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonRB", { get: function() {
        return this._buttonRB;
      }, set: function(e) {
        this._buttonRB = this._setButtonValue(e, this._buttonRB, ir.RB);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonLeftStick", { get: function() {
        return this._buttonLeftStick;
      }, set: function(e) {
        this._buttonLeftStick = this._setButtonValue(e, this._buttonLeftStick, ir.LeftStick);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonRightStick", { get: function() {
        return this._buttonRightStick;
      }, set: function(e) {
        this._buttonRightStick = this._setButtonValue(e, this._buttonRightStick, ir.RightStick);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dPadUp", { get: function() {
        return this._dPadUp;
      }, set: function(e) {
        this._dPadUp = this._setDPadValue(e, this._dPadUp, vs.Up);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dPadDown", { get: function() {
        return this._dPadDown;
      }, set: function(e) {
        this._dPadDown = this._setDPadValue(e, this._dPadDown, vs.Down);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dPadLeft", { get: function() {
        return this._dPadLeft;
      }, set: function(e) {
        this._dPadLeft = this._setDPadValue(e, this._dPadLeft, vs.Left);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dPadRight", { get: function() {
        return this._dPadRight;
      }, set: function(e) {
        this._dPadRight = this._setDPadValue(e, this._dPadRight, vs.Right);
      }, enumerable: !1, configurable: !0 }), t.prototype.update = function() {
        n.prototype.update.call(this), this._isXboxOnePad, this.buttonA = this.browserGamepad.buttons[0].value, this.buttonB = this.browserGamepad.buttons[1].value, this.buttonX = this.browserGamepad.buttons[2].value, this.buttonY = this.browserGamepad.buttons[3].value, this.buttonLB = this.browserGamepad.buttons[4].value, this.buttonRB = this.browserGamepad.buttons[5].value, this.leftTrigger = this.browserGamepad.buttons[6].value, this.rightTrigger = this.browserGamepad.buttons[7].value, this.buttonBack = this.browserGamepad.buttons[8].value, this.buttonStart = this.browserGamepad.buttons[9].value, this.buttonLeftStick = this.browserGamepad.buttons[10].value, this.buttonRightStick = this.browserGamepad.buttons[11].value, this.dPadUp = this.browserGamepad.buttons[12].value, this.dPadDown = this.browserGamepad.buttons[13].value, this.dPadLeft = this.browserGamepad.buttons[14].value, this.dPadRight = this.browserGamepad.buttons[15].value;
      }, t.prototype.dispose = function() {
        n.prototype.dispose.call(this), this.onButtonDownObservable.clear(), this.onButtonUpObservable.clear(), this.onPadDownObservable.clear(), this.onPadUpObservable.clear();
      }, t;
    }(qn);
    (function(n) {
      n[n.Cross = 0] = "Cross", n[n.Circle = 1] = "Circle", n[n.Square = 2] = "Square", n[n.Triangle = 3] = "Triangle", n[n.L1 = 4] = "L1", n[n.R1 = 5] = "R1", n[n.Share = 8] = "Share", n[n.Options = 9] = "Options", n[n.LeftStick = 10] = "LeftStick", n[n.RightStick = 11] = "RightStick";
    })(Pr || (Pr = {})), function(n) {
      n[n.Up = 12] = "Up", n[n.Down = 13] = "Down", n[n.Left = 14] = "Left", n[n.Right = 15] = "Right";
    }(ys || (ys = {}));
    var qg = function(n) {
      function t(e, i, r) {
        var o = n.call(this, e.replace("STANDARD GAMEPAD", "SONY PLAYSTATION DUALSHOCK"), i, r, 0, 1, 2, 3) || this;
        return o._leftTrigger = 0, o._rightTrigger = 0, o.onButtonDownObservable = new H(), o.onButtonUpObservable = new H(), o.onPadDownObservable = new H(), o.onPadUpObservable = new H(), o._buttonCross = 0, o._buttonCircle = 0, o._buttonSquare = 0, o._buttonTriangle = 0, o._buttonShare = 0, o._buttonOptions = 0, o._buttonL1 = 0, o._buttonR1 = 0, o._buttonLeftStick = 0, o._buttonRightStick = 0, o._dPadUp = 0, o._dPadDown = 0, o._dPadLeft = 0, o._dPadRight = 0, o.type = qn.DUALSHOCK, o;
      }
      return D(t, n), t.prototype.onlefttriggerchanged = function(e) {
        this._onlefttriggerchanged = e;
      }, t.prototype.onrighttriggerchanged = function(e) {
        this._onrighttriggerchanged = e;
      }, Object.defineProperty(t.prototype, "leftTrigger", { get: function() {
        return this._leftTrigger;
      }, set: function(e) {
        this._onlefttriggerchanged && this._leftTrigger !== e && this._onlefttriggerchanged(e), this._leftTrigger = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rightTrigger", { get: function() {
        return this._rightTrigger;
      }, set: function(e) {
        this._onrighttriggerchanged && this._rightTrigger !== e && this._onrighttriggerchanged(e), this._rightTrigger = e;
      }, enumerable: !1, configurable: !0 }), t.prototype.onbuttondown = function(e) {
        this._onbuttondown = e;
      }, t.prototype.onbuttonup = function(e) {
        this._onbuttonup = e;
      }, t.prototype.ondpaddown = function(e) {
        this._ondpaddown = e;
      }, t.prototype.ondpadup = function(e) {
        this._ondpadup = e;
      }, t.prototype._setButtonValue = function(e, i, r) {
        return e !== i && (e === 1 && (this._onbuttondown && this._onbuttondown(r), this.onButtonDownObservable.notifyObservers(r)), e === 0 && (this._onbuttonup && this._onbuttonup(r), this.onButtonUpObservable.notifyObservers(r))), e;
      }, t.prototype._setDPadValue = function(e, i, r) {
        return e !== i && (e === 1 && (this._ondpaddown && this._ondpaddown(r), this.onPadDownObservable.notifyObservers(r)), e === 0 && (this._ondpadup && this._ondpadup(r), this.onPadUpObservable.notifyObservers(r))), e;
      }, Object.defineProperty(t.prototype, "buttonCross", { get: function() {
        return this._buttonCross;
      }, set: function(e) {
        this._buttonCross = this._setButtonValue(e, this._buttonCross, Pr.Cross);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonCircle", { get: function() {
        return this._buttonCircle;
      }, set: function(e) {
        this._buttonCircle = this._setButtonValue(e, this._buttonCircle, Pr.Circle);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonSquare", { get: function() {
        return this._buttonSquare;
      }, set: function(e) {
        this._buttonSquare = this._setButtonValue(e, this._buttonSquare, Pr.Square);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonTriangle", { get: function() {
        return this._buttonTriangle;
      }, set: function(e) {
        this._buttonTriangle = this._setButtonValue(e, this._buttonTriangle, Pr.Triangle);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonOptions", { get: function() {
        return this._buttonOptions;
      }, set: function(e) {
        this._buttonOptions = this._setButtonValue(e, this._buttonOptions, Pr.Options);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonShare", { get: function() {
        return this._buttonShare;
      }, set: function(e) {
        this._buttonShare = this._setButtonValue(e, this._buttonShare, Pr.Share);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonL1", { get: function() {
        return this._buttonL1;
      }, set: function(e) {
        this._buttonL1 = this._setButtonValue(e, this._buttonL1, Pr.L1);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonR1", { get: function() {
        return this._buttonR1;
      }, set: function(e) {
        this._buttonR1 = this._setButtonValue(e, this._buttonR1, Pr.R1);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonLeftStick", { get: function() {
        return this._buttonLeftStick;
      }, set: function(e) {
        this._buttonLeftStick = this._setButtonValue(e, this._buttonLeftStick, Pr.LeftStick);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonRightStick", { get: function() {
        return this._buttonRightStick;
      }, set: function(e) {
        this._buttonRightStick = this._setButtonValue(e, this._buttonRightStick, Pr.RightStick);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dPadUp", { get: function() {
        return this._dPadUp;
      }, set: function(e) {
        this._dPadUp = this._setDPadValue(e, this._dPadUp, ys.Up);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dPadDown", { get: function() {
        return this._dPadDown;
      }, set: function(e) {
        this._dPadDown = this._setDPadValue(e, this._dPadDown, ys.Down);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dPadLeft", { get: function() {
        return this._dPadLeft;
      }, set: function(e) {
        this._dPadLeft = this._setDPadValue(e, this._dPadLeft, ys.Left);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dPadRight", { get: function() {
        return this._dPadRight;
      }, set: function(e) {
        this._dPadRight = this._setDPadValue(e, this._dPadRight, ys.Right);
      }, enumerable: !1, configurable: !0 }), t.prototype.update = function() {
        n.prototype.update.call(this), this.buttonCross = this.browserGamepad.buttons[0].value, this.buttonCircle = this.browserGamepad.buttons[1].value, this.buttonSquare = this.browserGamepad.buttons[2].value, this.buttonTriangle = this.browserGamepad.buttons[3].value, this.buttonL1 = this.browserGamepad.buttons[4].value, this.buttonR1 = this.browserGamepad.buttons[5].value, this.leftTrigger = this.browserGamepad.buttons[6].value, this.rightTrigger = this.browserGamepad.buttons[7].value, this.buttonShare = this.browserGamepad.buttons[8].value, this.buttonOptions = this.browserGamepad.buttons[9].value, this.buttonLeftStick = this.browserGamepad.buttons[10].value, this.buttonRightStick = this.browserGamepad.buttons[11].value, this.dPadUp = this.browserGamepad.buttons[12].value, this.dPadDown = this.browserGamepad.buttons[13].value, this.dPadLeft = this.browserGamepad.buttons[14].value, this.dPadRight = this.browserGamepad.buttons[15].value;
      }, t.prototype.dispose = function() {
        n.prototype.dispose.call(this), this.onButtonDownObservable.clear(), this.onButtonUpObservable.clear(), this.onPadDownObservable.clear(), this.onPadUpObservable.clear();
      }, t;
    }(qn), Qg = function() {
      function n(t) {
        var e = this;
        if (this._scene = t, this._babylonGamepads = [], this._oneGamepadConnected = !1, this._isMonitoring = !1, this.onGamepadDisconnectedObservable = new H(), Gi() ? (this._gamepadEventSupported = "GamepadEvent" in window, this._gamepadSupport = navigator && navigator.getGamepads) : this._gamepadEventSupported = !1, this.onGamepadConnectedObservable = new H(function(r) {
          for (var o in e._babylonGamepads) {
            var a = e._babylonGamepads[o];
            a && a._isConnected && e.onGamepadConnectedObservable.notifyObserver(r, a);
          }
        }), this._onGamepadConnectedEvent = function(r) {
          var o, a = r.gamepad;
          a.index in e._babylonGamepads && e._babylonGamepads[a.index].isConnected || (e._babylonGamepads[a.index] ? ((o = e._babylonGamepads[a.index]).browserGamepad = a, o._isConnected = !0) : o = e._addNewGamepad(a), e.onGamepadConnectedObservable.notifyObservers(o), e._startMonitoringGamepads());
        }, this._onGamepadDisconnectedEvent = function(r) {
          var o = r.gamepad;
          for (var a in e._babylonGamepads)
            if (e._babylonGamepads[a].index === o.index) {
              var s = e._babylonGamepads[a];
              s._isConnected = !1, e.onGamepadDisconnectedObservable.notifyObservers(s), s.dispose && s.dispose();
              break;
            }
        }, this._gamepadSupport)
          if (this._updateGamepadObjects(), this._babylonGamepads.length && this._startMonitoringGamepads(), this._gamepadEventSupported) {
            var i = this._scene ? this._scene.getEngine().getHostWindow() : window;
            i && (i.addEventListener("gamepadconnected", this._onGamepadConnectedEvent, !1), i.addEventListener("gamepaddisconnected", this._onGamepadDisconnectedEvent, !1));
          } else
            this._startMonitoringGamepads();
      }
      return Object.defineProperty(n.prototype, "gamepads", { get: function() {
        return this._babylonGamepads;
      }, enumerable: !1, configurable: !0 }), n.prototype.getGamepadByType = function(t) {
        t === void 0 && (t = qn.XBOX);
        for (var e = 0, i = this._babylonGamepads; e < i.length; e++) {
          var r = i[e];
          if (r && r.type === t)
            return r;
        }
        return null;
      }, n.prototype.dispose = function() {
        this._gamepadEventSupported && (this._onGamepadConnectedEvent && window.removeEventListener("gamepadconnected", this._onGamepadConnectedEvent), this._onGamepadDisconnectedEvent && window.removeEventListener("gamepaddisconnected", this._onGamepadDisconnectedEvent), this._onGamepadConnectedEvent = null, this._onGamepadDisconnectedEvent = null), this._babylonGamepads.forEach(function(t) {
          t.dispose();
        }), this.onGamepadConnectedObservable.clear(), this.onGamepadDisconnectedObservable.clear(), this._oneGamepadConnected = !1, this._stopMonitoringGamepads(), this._babylonGamepads = [];
      }, n.prototype._addNewGamepad = function(t) {
        var e;
        this._oneGamepadConnected || (this._oneGamepadConnected = !0);
        var i = t.id.search("054c") !== -1 && t.id.search("0ce6") === -1, r = t.id.search("Xbox One") !== -1;
        return e = r || t.id.search("Xbox 360") !== -1 || t.id.search("xinput") !== -1 || t.id.search("045e") !== -1 && t.id.search("Surface Dock") === -1 ? new Kg(t.id, t.index, t, r) : i ? new qg(t.id, t.index, t) : new Wg(t.id, t.index, t), this._babylonGamepads[e.index] = e, e;
      }, n.prototype._startMonitoringGamepads = function() {
        this._isMonitoring || (this._isMonitoring = !0, this._checkGamepadsStatus());
      }, n.prototype._stopMonitoringGamepads = function() {
        this._isMonitoring = !1;
      }, n.prototype._checkGamepadsStatus = function() {
        var t = this;
        for (var e in this._updateGamepadObjects(), this._babylonGamepads) {
          var i = this._babylonGamepads[e];
          if (i && i.isConnected)
            try {
              i.update();
            } catch {
              this._loggedErrors.indexOf(i.index) === -1 && (de.Warn("Error updating gamepad ".concat(i.id)), this._loggedErrors.push(i.index));
            }
        }
        this._isMonitoring && ve.QueueNewFrame(function() {
          t._checkGamepadsStatus();
        });
      }, n.prototype._updateGamepadObjects = function() {
        for (var t = navigator.getGamepads ? navigator.getGamepads() : [], e = 0; e < t.length; e++) {
          var i = t[e];
          if (i)
            if (this._babylonGamepads[i.index])
              this._babylonGamepads[e].browserGamepad = i, this._babylonGamepads[e].isConnected || (this._babylonGamepads[e]._isConnected = !0, this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[e]));
            else {
              var r = this._addNewGamepad(i);
              this.onGamepadConnectedObservable.notifyObservers(r);
            }
        }
      }, n;
    }();
    Object.defineProperty(Ue.prototype, "gamepadManager", { get: function() {
      if (!this._gamepadManager) {
        this._gamepadManager = new Qg(this);
        var n = this._getComponent(we.NAME_GAMEPAD);
        n || (n = new Zg(this), this._addComponent(n));
      }
      return this._gamepadManager;
    }, enumerable: !0, configurable: !0 }), bc.prototype.addGamepad = function() {
      return this.add(new af()), this;
    }, sh.prototype.addGamepad = function() {
      return this.add(new Hp()), this;
    };
    var Zg = function() {
      function n(t) {
        this.name = we.NAME_GAMEPAD, this.scene = t;
      }
      return n.prototype.register = function() {
        this.scene._beforeCameraUpdateStage.registerStep(we.STEP_BEFORECAMERAUPDATE_GAMEPAD, this, this._beforeCameraUpdate);
      }, n.prototype.rebuild = function() {
      }, n.prototype.dispose = function() {
        var t = this.scene._gamepadManager;
        t && (t.dispose(), this.scene._gamepadManager = null);
      }, n.prototype._beforeCameraUpdate = function() {
        var t = this.scene._gamepadManager;
        t && t._isMonitoring && t._checkGamepadsStatus();
      }, n;
    }();
    oi.AddNodeConstructor("FreeCamera", function(n, t) {
      return function() {
        return new Wa(n, v.Zero(), t);
      };
    });
    var Wa = function(n) {
      function t(e, i, r) {
        var o = n.call(this, e, i, r) || this;
        return o.inputs.addGamepad(), o;
      }
      return D(t, n), Object.defineProperty(t.prototype, "gamepadAngularSensibility", { get: function() {
        var e = this.inputs.attached.gamepad;
        return e ? e.gamepadAngularSensibility : 0;
      }, set: function(e) {
        var i = this.inputs.attached.gamepad;
        i && (i.gamepadAngularSensibility = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "gamepadMoveSensibility", { get: function() {
        var e = this.inputs.attached.gamepad;
        return e ? e.gamepadMoveSensibility : 0;
      }, set: function(e) {
        var i = this.inputs.attached.gamepad;
        i && (i.gamepadMoveSensibility = e);
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "UniversalCamera";
      }, t;
    }(cf);
    dt._CreateDefaultParsedCamera = function(n, t) {
      return new Wa(n, v.Zero(), t);
    }, oi.AddNodeConstructor("GamepadCamera", function(n, t) {
      return function() {
        return new ch(n, v.Zero(), t);
      };
    });
    var ch = function(n) {
      function t(e, i, r) {
        return n.call(this, e, i, r) || this;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "GamepadCamera";
      }, t;
    }(Wa);
    re.ShadersStore.passCubePixelShader = `varying vec2 vUV;uniform samplerCube textureSampler;
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void) 
{vec2 uv=vUV*2.0-1.0;
#ifdef POSITIVEX
gl_FragColor=textureCube(textureSampler,vec3(1.001,uv.y,uv.x));
#endif
#ifdef NEGATIVEX
gl_FragColor=textureCube(textureSampler,vec3(-1.001,uv.y,uv.x));
#endif
#ifdef POSITIVEY
gl_FragColor=textureCube(textureSampler,vec3(uv.y,1.001,uv.x));
#endif
#ifdef NEGATIVEY
gl_FragColor=textureCube(textureSampler,vec3(uv.y,-1.001,uv.x));
#endif
#ifdef POSITIVEZ
gl_FragColor=textureCube(textureSampler,vec3(uv,1.001));
#endif
#ifdef NEGATIVEZ
gl_FragColor=textureCube(textureSampler,vec3(uv,-1.001));
#endif
}`;
    var da = function(n) {
      function t(e, i, r, o, a, s, l, c) {
        return r === void 0 && (r = null), l === void 0 && (l = _.TEXTURETYPE_UNSIGNED_INT), c === void 0 && (c = !1), n.call(this, e, "pass", null, null, i, r, o, a, s, void 0, l, void 0, null, c) || this;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "PassPostProcess";
      }, t._Parse = function(e, i, r, o) {
        return Ne.Parse(function() {
          return new t(e.name, e.options, i, e.renderTargetSamplingMode, e._engine, e.reusable);
        }, e, r, o);
      }, t;
    }(nt);
    j("BABYLON.PassPostProcess", da);
    var wR = function(n) {
      function t(e, i, r, o, a, s, l, c) {
        r === void 0 && (r = null), l === void 0 && (l = _.TEXTURETYPE_UNSIGNED_INT), c === void 0 && (c = !1);
        var u = n.call(this, e, "passCube", null, null, i, r, o, a, s, "#define POSITIVEX", l, void 0, null, c) || this;
        return u._face = 0, u;
      }
      return D(t, n), Object.defineProperty(t.prototype, "face", { get: function() {
        return this._face;
      }, set: function(e) {
        if (!(e < 0 || e > 5))
          switch (this._face = e, this._face) {
            case 0:
              this.updateEffect("#define POSITIVEX");
              break;
            case 1:
              this.updateEffect("#define NEGATIVEX");
              break;
            case 2:
              this.updateEffect("#define POSITIVEY");
              break;
            case 3:
              this.updateEffect("#define NEGATIVEY");
              break;
            case 4:
              this.updateEffect("#define POSITIVEZ");
              break;
            case 5:
              this.updateEffect("#define NEGATIVEZ");
          }
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "PassCubePostProcess";
      }, t._Parse = function(e, i, r, o) {
        return Ne.Parse(function() {
          return new t(e.name, e.options, i, e.renderTargetSamplingMode, e._engine, e.reusable);
        }, e, r, o);
      }, t;
    }(nt);
    ve._RescalePostProcessFactory = function(n) {
      return new da("rescale", 1, null, _.TEXTURE_BILINEAR_SAMPLINGMODE, n, !1, _.TEXTURETYPE_UNSIGNED_INT);
    }, re.ShadersStore.anaglyphPixelShader = `varying vec2 vUV;uniform sampler2D textureSampler;uniform sampler2D leftSampler;
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void)
{vec4 leftFrag=texture2D(leftSampler,vUV);leftFrag=vec4(1.0,leftFrag.g,leftFrag.b,1.0);vec4 rightFrag=texture2D(textureSampler,vUV);rightFrag=vec4(rightFrag.r,1.0,1.0,1.0);gl_FragColor=vec4(rightFrag.rgb*leftFrag.rgb,1.0);}`;
    var uf = function(n) {
      function t(e, i, r, o, a, s) {
        var l = n.call(this, e, "anaglyph", null, ["leftSampler"], i, r[1], o, a, s) || this;
        return l._passedProcess = r[0]._rigPostProcess, l.onApplyObservable.add(function(c) {
          c.setTextureFromPostProcess("leftSampler", l._passedProcess);
        }), l;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "AnaglyphPostProcess";
      }, t;
    }(nt);
    function Tc(n) {
      n._rigCameras[0]._rigPostProcess = new da(n.name + "_passthru", 1, n._rigCameras[0]), n._rigCameras[1]._rigPostProcess = new uf(n.name + "_anaglyph", 1, n._rigCameras);
    }
    j("BABYLON.AnaglyphPostProcess", uf), oi.AddNodeConstructor("AnaglyphArcRotateCamera", function(n, t, e) {
      return function() {
        return new Jg(n, 0, 0, 1, v.Zero(), e.interaxial_distance, t);
      };
    });
    var Jg = function(n) {
      function t(e, i, r, o, a, s, l) {
        var c = n.call(this, e, i, r, o, a, l) || this;
        return c._setRigMode = function() {
          return Tc(c);
        }, c.interaxialDistance = s, c.setCameraRigMode(dt.RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: s }), c;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "AnaglyphArcRotateCamera";
      }, t;
    }(gs);
    oi.AddNodeConstructor("AnaglyphFreeCamera", function(n, t, e) {
      return function() {
        return new $g(n, v.Zero(), e.interaxial_distance, t);
      };
    });
    var $g = function(n) {
      function t(e, i, r, o) {
        var a = n.call(this, e, i, o) || this;
        return a._setRigMode = function() {
          return Tc(a);
        }, a.interaxialDistance = r, a.setCameraRigMode(dt.RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: r }), a;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "AnaglyphFreeCamera";
      }, t;
    }(Oo);
    oi.AddNodeConstructor("AnaglyphGamepadCamera", function(n, t, e) {
      return function() {
        return new ev(n, v.Zero(), e.interaxial_distance, t);
      };
    });
    var ev = function(n) {
      function t(e, i, r, o) {
        var a = n.call(this, e, i, o) || this;
        return a._setRigMode = function() {
          return Tc(a);
        }, a.interaxialDistance = r, a.setCameraRigMode(dt.RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: r }), a;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "AnaglyphGamepadCamera";
      }, t;
    }(ch);
    oi.AddNodeConstructor("AnaglyphUniversalCamera", function(n, t, e) {
      return function() {
        return new tv(n, v.Zero(), e.interaxial_distance, t);
      };
    });
    var tv = function(n) {
      function t(e, i, r, o) {
        var a = n.call(this, e, i, o) || this;
        return a._setRigMode = function() {
          return Tc(a);
        }, a.interaxialDistance = r, a.setCameraRigMode(dt.RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: r }), a;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "AnaglyphUniversalCamera";
      }, t;
    }(Wa);
    re.ShadersStore.stereoscopicInterlacePixelShader = `const vec3 TWO=vec3(2.0,2.0,2.0);varying vec2 vUV;uniform sampler2D camASampler;uniform sampler2D textureSampler;uniform vec2 stepSize;
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void)
{bool useCamA;bool useCamB;vec2 texCoord1;vec2 texCoord2;vec3 frag1;vec3 frag2;
#ifdef IS_STEREOSCOPIC_HORIZ
useCamB=vUV.x>0.5;useCamA=!useCamB;texCoord1=vec2(useCamB ? (vUV.x-0.5)*2.0 : vUV.x*2.0,vUV.y);texCoord2=vec2(texCoord1.x+stepSize.x,vUV.y);
#else
#ifdef IS_STEREOSCOPIC_INTERLACED
float rowNum=floor(vUV.y/stepSize.y);useCamA=mod(rowNum,2.0)==1.0;useCamB=mod(rowNum,2.0)==0.0;texCoord1=vec2(vUV.x,vUV.y);texCoord2=vec2(vUV.x,vUV.y);
#else
useCamB=vUV.y>0.5;useCamA=!useCamB;texCoord1=vec2(vUV.x,useCamB ? (vUV.y-0.5)*2.0 : vUV.y*2.0);texCoord2=vec2(vUV.x,texCoord1.y+stepSize.y);
#endif
#endif
if (useCamB){frag1=texture2D(textureSampler,texCoord1).rgb;frag2=texture2D(textureSampler,texCoord2).rgb;}else if (useCamA){frag1=texture2D(camASampler ,texCoord1).rgb;frag2=texture2D(camASampler ,texCoord2).rgb;}else {discard;}
gl_FragColor=vec4((frag1+frag2)/TWO,1.0);}
`;
    var iv = function(n) {
      function t(e, i, r, o, a, s, l) {
        var c = n.call(this, e, "stereoscopicInterlace", ["stepSize"], ["camASampler"], 1, i[1], a, s, l, o ? "#define IS_STEREOSCOPIC_INTERLACED 1" : r ? "#define IS_STEREOSCOPIC_HORIZ 1" : void 0) || this;
        return c._passedProcess = i[0]._rigPostProcess, c._stepSize = new fe(1 / c.width, 1 / c.height), c.onSizeChangedObservable.add(function() {
          c._stepSize = new fe(1 / c.width, 1 / c.height);
        }), c.onApplyObservable.add(function(u) {
          u.setTextureFromPostProcess("camASampler", c._passedProcess), u.setFloat2("stepSize", c._stepSize.x, c._stepSize.y);
        }), c;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "StereoscopicInterlacePostProcessI";
      }, t;
    }(nt), BR = function(n) {
      function t(e, i, r, o, a, s) {
        var l = n.call(this, e, "stereoscopicInterlace", ["stepSize"], ["camASampler"], 1, i[1], o, a, s, r ? "#define IS_STEREOSCOPIC_HORIZ 1" : void 0) || this;
        return l._passedProcess = i[0]._rigPostProcess, l._stepSize = new fe(1 / l.width, 1 / l.height), l.onSizeChangedObservable.add(function() {
          l._stepSize = new fe(1 / l.width, 1 / l.height);
        }), l.onApplyObservable.add(function(c) {
          c.setTextureFromPostProcess("camASampler", l._passedProcess), c.setFloat2("stepSize", l._stepSize.x, l._stepSize.y);
        }), l;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "StereoscopicInterlacePostProcess";
      }, t;
    }(nt);
    function Ec(n) {
      var t = n.cameraRigMode === dt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL || n.cameraRigMode === dt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED, e = n.cameraRigMode === dt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
      n.cameraRigMode === dt.RIG_MODE_STEREOSCOPIC_INTERLACED ? (n._rigCameras[0]._rigPostProcess = new da(n.name + "_passthru", 1, n._rigCameras[0]), n._rigCameras[1]._rigPostProcess = new iv(n.name + "_stereoInterlace", n._rigCameras, !1, !0)) : (n._rigCameras[e ? 1 : 0].viewport = new xr(0, 0, t ? 0.5 : 1, t ? 1 : 0.5), n._rigCameras[e ? 0 : 1].viewport = new xr(t ? 0.5 : 0, t ? 0 : 0.5, t ? 0.5 : 1, t ? 1 : 0.5));
    }
    oi.AddNodeConstructor("StereoscopicArcRotateCamera", function(n, t, e) {
      return function() {
        return new nv(n, 0, 0, 1, v.Zero(), e.interaxial_distance, e.isStereoscopicSideBySide, t);
      };
    });
    var nv = function(n) {
      function t(e, i, r, o, a, s, l, c) {
        var u = n.call(this, e, i, r, o, a, c) || this;
        return u._setRigMode = function() {
          return Ec(u);
        }, u.interaxialDistance = s, u.isStereoscopicSideBySide = l, u.setCameraRigMode(l ? dt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL : dt.RIG_MODE_STEREOSCOPIC_OVERUNDER, { interaxialDistance: s }), u;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "StereoscopicArcRotateCamera";
      }, t;
    }(gs);
    oi.AddNodeConstructor("StereoscopicFreeCamera", function(n, t, e) {
      return function() {
        return new rv(n, v.Zero(), e.interaxial_distance, e.isStereoscopicSideBySide, t);
      };
    });
    var rv = function(n) {
      function t(e, i, r, o, a) {
        var s = n.call(this, e, i, a) || this;
        return s._setRigMode = function() {
          return Ec(s);
        }, s.interaxialDistance = r, s.isStereoscopicSideBySide = o, s.setCameraRigMode(o ? dt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL : dt.RIG_MODE_STEREOSCOPIC_OVERUNDER, { interaxialDistance: r }), s;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "StereoscopicFreeCamera";
      }, t;
    }(Oo);
    oi.AddNodeConstructor("StereoscopicGamepadCamera", function(n, t, e) {
      return function() {
        return new ov(n, v.Zero(), e.interaxial_distance, e.isStereoscopicSideBySide, t);
      };
    });
    var ov = function(n) {
      function t(e, i, r, o, a) {
        var s = n.call(this, e, i, a) || this;
        return s._setRigMode = function() {
          return Ec(s);
        }, s.interaxialDistance = r, s.isStereoscopicSideBySide = o, s.setCameraRigMode(o ? dt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL : dt.RIG_MODE_STEREOSCOPIC_OVERUNDER, { interaxialDistance: r }), s;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "StereoscopicGamepadCamera";
      }, t;
    }(ch);
    oi.AddNodeConstructor("StereoscopicFreeCamera", function(n, t, e) {
      return function() {
        return new av(n, v.Zero(), e.interaxial_distance, e.isStereoscopicSideBySide, t);
      };
    });
    var av = function(n) {
      function t(e, i, r, o, a) {
        var s = n.call(this, e, i, a) || this;
        return s._setRigMode = function() {
          return Ec(s);
        }, s.interaxialDistance = r, s.isStereoscopicSideBySide = o, s.setCameraRigMode(o ? dt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL : dt.RIG_MODE_STEREOSCOPIC_OVERUNDER, { interaxialDistance: r }), s;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "StereoscopicUniversalCamera";
      }, t;
    }(Wa), UR = function(n) {
      function t(e, i, r, o, a) {
        o === void 0 && (o = 1), a === void 0 && (a = 0.065);
        var s = n.call(this, e, i, r) || this;
        return s._distanceBetweenEyes = a, s._distanceToProjectionPlane = o, s.setCameraRigMode(dt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL, { stereoHalfAngle: 0 }), s._cameraRigParams.stereoHalfAngle = 0, s._cameraRigParams.interaxialDistance = a, s;
      }
      return D(t, n), Object.defineProperty(t.prototype, "distanceBetweenEyes", { get: function() {
        return this._distanceBetweenEyes;
      }, set: function(e) {
        this._distanceBetweenEyes = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "distanceToProjectionPlane", { get: function() {
        return this._distanceToProjectionPlane;
      }, set: function(e) {
        this._distanceToProjectionPlane = e;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "StereoscopicUniversalCamera";
      }, t.prototype.createRigCamera = function(e) {
        var i = new ha(e, v.Zero(), this.getScene()), r = new ai("tm_" + e, this.getScene());
        return i.parent = r, r.setPivotMatrix(B.Identity(), !1), i.isRigCamera = !0, i.rigParent = this, i;
      }, t.prototype._updateRigCameras = function() {
        for (var e = 0; e < this._rigCameras.length; e++) {
          var i = this._rigCameras[e];
          i.minZ = this.minZ, i.maxZ = this.maxZ, i.fov = this.fov, i.upVector.copyFrom(this.upVector), i.rotationQuaternion ? i.rotationQuaternion.copyFrom(this.rotationQuaternion) : i.rotation.copyFrom(this.rotation), this._updateCamera(this._rigCameras[e], e);
        }
      }, t.prototype._updateCamera = function(e, i) {
        var r = this.distanceBetweenEyes / 2, o = r / this.distanceToProjectionPlane;
        e.position.copyFrom(this.position), e.position.addInPlaceFromFloats(i === 0 ? -r : r, 0, -this._distanceToProjectionPlane);
        var a = e.parent, s = a.getPivotMatrix();
        s.setTranslationFromFloats(i === 0 ? r : -r, 0, 0), s.setRowFromFloats(2, i === 0 ? o : -o, 0, 1, 0), a.setPivotMatrix(s, !1);
      }, t.prototype._setRigMode = function() {
        this._rigCameras[0].viewport = new xr(0, 0, 0.5, 1), this._rigCameras[1].viewport = new xr(0.5, 0, 0.5, 1);
        for (var e = 0; e < this._rigCameras.length; e++)
          this._updateCamera(this._rigCameras[e], e);
      }, t;
    }(Wa);
    oi.AddNodeConstructor("VirtualJoysticksCamera", function(n, t) {
      return function() {
        return new sv(n, v.Zero(), t);
      };
    });
    var sv = function(n) {
      function t(e, i, r) {
        var o = n.call(this, e, i, r) || this;
        return o.inputs.addVirtualJoystick(), o;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "VirtualJoysticksCamera";
      }, t;
    }(Oo), Sc = function() {
      function n() {
        this.compensateDistortion = !0, this.multiviewEnabled = !1;
      }
      return Object.defineProperty(n.prototype, "aspectRatio", { get: function() {
        return this.hResolution / (2 * this.vResolution);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "aspectRatioFov", { get: function() {
        return 2 * Math.atan(this.postProcessScaleFactor * this.vScreenSize / (2 * this.eyeToScreenDistance));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "leftHMatrix", { get: function() {
        var t = 4 * (this.hScreenSize / 4 - this.lensSeparationDistance / 2) / this.hScreenSize;
        return B.Translation(t, 0, 0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "rightHMatrix", { get: function() {
        var t = 4 * (this.hScreenSize / 4 - this.lensSeparationDistance / 2) / this.hScreenSize;
        return B.Translation(-t, 0, 0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "leftPreViewMatrix", { get: function() {
        return B.Translation(0.5 * this.interpupillaryDistance, 0, 0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "rightPreViewMatrix", { get: function() {
        return B.Translation(-0.5 * this.interpupillaryDistance, 0, 0);
      }, enumerable: !1, configurable: !0 }), n.GetDefault = function() {
        var t = new n();
        return t.hResolution = 1280, t.vResolution = 800, t.hScreenSize = 0.149759993, t.vScreenSize = 0.0935999975, t.vScreenCenter = 0.0467999987, t.eyeToScreenDistance = 0.0410000011, t.lensSeparationDistance = 0.063500002, t.interpupillaryDistance = 0.064000003, t.distortionK = [1, 0.219999999, 0.239999995, 0], t.chromaAbCorrection = [0.995999992, -0.00400000019, 1.01400006, 0], t.postProcessScaleFactor = 1.714605507808412, t.lensCenterOffset = 0.151976421, t;
      }, n;
    }();
    re.ShadersStore.vrDistortionCorrectionPixelShader = `varying vec2 vUV;uniform sampler2D textureSampler;uniform vec2 LensCenter;uniform vec2 Scale;uniform vec2 ScaleIn;uniform vec4 HmdWarpParam;vec2 HmdWarp(vec2 in01) {vec2 theta=(in01-LensCenter)*ScaleIn; 
float rSq=theta.x*theta.x+theta.y*theta.y;vec2 rvector=theta*(HmdWarpParam.x+HmdWarpParam.y*rSq+HmdWarpParam.z*rSq*rSq+HmdWarpParam.w*rSq*rSq*rSq);return LensCenter+Scale*rvector;}
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void)
{vec2 tc=HmdWarp(vUV);if (tc.x <0.0 || tc.x>1.0 || tc.y<0.0 || tc.y>1.0)
gl_FragColor=vec4(0.0,0.0,0.0,0.0);else{gl_FragColor=texture2D(textureSampler,tc);}}`;
    var hf = function(n) {
      function t(e, i, r, o) {
        var a = n.call(this, e, "vrDistortionCorrection", ["LensCenter", "Scale", "ScaleIn", "HmdWarpParam"], null, o.postProcessScaleFactor, i, ae.BILINEAR_SAMPLINGMODE) || this;
        return a._isRightEye = r, a._distortionFactors = o.distortionK, a._postProcessScaleFactor = o.postProcessScaleFactor, a._lensCenterOffset = o.lensCenterOffset, a.adaptScaleToCurrentViewport = !0, a.onSizeChangedObservable.add(function() {
          a._scaleIn = new fe(2, 2 / a.aspectRatio), a._scaleFactor = new fe(1 / a._postProcessScaleFactor * 0.5, 1 / a._postProcessScaleFactor * 0.5 * a.aspectRatio), a._lensCenter = new fe(a._isRightEye ? 0.5 - 0.5 * a._lensCenterOffset : 0.5 + 0.5 * a._lensCenterOffset, 0.5);
        }), a.onApplyObservable.add(function(s) {
          s.setFloat2("LensCenter", a._lensCenter.x, a._lensCenter.y), s.setFloat2("Scale", a._scaleFactor.x, a._scaleFactor.y), s.setFloat2("ScaleIn", a._scaleIn.x, a._scaleIn.y), s.setFloat4("HmdWarpParam", a._distortionFactors[0], a._distortionFactors[1], a._distortionFactors[2], a._distortionFactors[3]);
        }), a;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "VRDistortionCorrectionPostProcess";
      }, t;
    }(nt);
    re.ShadersStore.vrMultiviewToSingleviewPixelShader = `precision mediump sampler2DArray;varying vec2 vUV;uniform sampler2DArray multiviewSampler;uniform int imageIndex;
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void)
{gl_FragColor=texture2D(multiviewSampler,vec3(vUV,imageIndex));}`;
    var lv = function(n) {
      function t(e, i) {
        i === void 0 && (i = 512);
        var r = n.call(this, "multiview rtt", i, e, !1, !0, _.TEXTURETYPE_UNSIGNED_INT, !1, void 0, !1, !1, !0, void 0, !0) || this;
        return r._renderTarget = r.getScene().getEngine().createMultiviewRenderTargetTexture(r.getRenderWidth(), r.getRenderHeight()), r._texture = r._renderTarget.texture, r._texture.isMultiview = !0, r._texture.format = _.TEXTUREFORMAT_RGBA, r.samples = r._getEngine().getCaps().maxSamples || r.samples, r._texture.samples = r._samples, r;
      }
      return D(t, n), Object.defineProperty(t.prototype, "samples", { get: function() {
        return this._samples;
      }, set: function(e) {
        this._samples = e;
      }, enumerable: !1, configurable: !0 }), t.prototype._bindFrameBuffer = function() {
        this._renderTarget && this.getScene().getEngine().bindMultiviewFramebuffer(this._renderTarget);
      }, t.prototype.getViewCount = function() {
        return 2;
      }, t;
    }(Mi);
    function VR(n, t) {
      var e = new Er(n, void 0, !0, t);
      return e.addUniform("viewProjection", 16), e.addUniform("viewProjectionR", 16), e.addUniform("view", 16), e.addUniform("projection", 16), e.addUniform("vEyePosition", 4), e;
    }
    ve.prototype.createMultiviewRenderTargetTexture = function(n, t, e, i) {
      var r = this._gl;
      if (!this.getCaps().multiview)
        throw "Multiview is not supported";
      var o = this._createHardwareRenderTargetWrapper(!1, !1, { width: n, height: t });
      o._framebuffer = r.createFramebuffer();
      var a = new Ut(this, ut.Unknown, !0);
      return a.width = n, a.height = t, a.isMultiview = !0, e || (e = r.createTexture(), r.bindTexture(r.TEXTURE_2D_ARRAY, e), r.texStorage3D(r.TEXTURE_2D_ARRAY, 1, r.RGBA8, n, t, 2)), o._colorTextureArray = e, i || (i = r.createTexture(), r.bindTexture(r.TEXTURE_2D_ARRAY, i), r.texStorage3D(r.TEXTURE_2D_ARRAY, 1, r.DEPTH24_STENCIL8, n, t, 2)), o._depthStencilTextureArray = i, a.isReady = !0, o.setTextures(a), o._depthStencilTexture = a, o;
    }, ve.prototype.bindMultiviewFramebuffer = function(n) {
      var t = n, e = this._gl, i = this.getCaps().oculusMultiview || this.getCaps().multiview;
      if (this.bindFramebuffer(t, void 0, void 0, void 0, !0), e.bindFramebuffer(e.DRAW_FRAMEBUFFER, t._framebuffer), !t._colorTextureArray || !t._depthStencilTextureArray)
        throw "Invalid multiview frame buffer";
      this.getCaps().oculusMultiview ? (i.framebufferTextureMultisampleMultiviewOVR(e.DRAW_FRAMEBUFFER, e.COLOR_ATTACHMENT0, t._colorTextureArray, 0, t.samples, 0, 2), i.framebufferTextureMultisampleMultiviewOVR(e.DRAW_FRAMEBUFFER, e.DEPTH_STENCIL_ATTACHMENT, t._depthStencilTextureArray, 0, t.samples, 0, 2)) : (i.framebufferTextureMultiviewOVR(e.DRAW_FRAMEBUFFER, e.COLOR_ATTACHMENT0, t._colorTextureArray, 0, 0, 2), i.framebufferTextureMultiviewOVR(e.DRAW_FRAMEBUFFER, e.DEPTH_STENCIL_ATTACHMENT, t._depthStencilTextureArray, 0, 0, 2));
    }, ve.prototype.bindSpaceWarpFramebuffer = function(n) {
      var t = n, e = this._gl, i = this.getCaps().oculusMultiview || this.getCaps().multiview;
      if (this.bindFramebuffer(t, void 0, void 0, void 0, !0), e.bindFramebuffer(e.DRAW_FRAMEBUFFER, t._framebuffer), !t._colorTextureArray || !t._depthStencilTextureArray)
        throw new Error("Invalid Space Warp framebuffer");
      i.framebufferTextureMultiviewOVR(e.DRAW_FRAMEBUFFER, e.COLOR_ATTACHMENT0, t._colorTextureArray, 0, 0, 2), i.framebufferTextureMultiviewOVR(e.DRAW_FRAMEBUFFER, e.DEPTH_ATTACHMENT, t._depthStencilTextureArray, 0, 0, 2);
    }, dt.prototype._useMultiviewToSingleView = !1, dt.prototype._multiviewTexture = null, dt.prototype._resizeOrCreateMultiviewTexture = function(n, t) {
      this._multiviewTexture ? this._multiviewTexture.getRenderWidth() == n && this._multiviewTexture.getRenderHeight() == t || (this._multiviewTexture.dispose(), this._multiviewTexture = new lv(this.getScene(), { width: n, height: t })) : this._multiviewTexture = new lv(this.getScene(), { width: n, height: t });
    };
    var H1 = Ue.prototype.createSceneUniformBuffer;
    Ue.prototype._transformMatrixR = B.Zero(), Ue.prototype._multiviewSceneUbo = null, Ue.prototype._createMultiviewUbo = function() {
      this._multiviewSceneUbo = VR(this.getEngine(), "scene_multiview");
    }, Ue.prototype.createSceneUniformBuffer = function(n) {
      return this._multiviewSceneUbo ? VR(this.getEngine(), n) : H1.bind(this)(n);
    }, Ue.prototype._updateMultiviewUbo = function(n, t) {
      n && t && n.multiplyToRef(t, this._transformMatrixR), n && t && (n.multiplyToRef(t, F.Matrix[0]), ll.GetRightPlaneToRef(F.Matrix[0], this._frustumPlanes[3])), this._multiviewSceneUbo && (this._multiviewSceneUbo.updateMatrix("viewProjection", this.getTransformMatrix()), this._multiviewSceneUbo.updateMatrix("viewProjectionR", this._transformMatrixR), this._multiviewSceneUbo.updateMatrix("view", this._viewMatrix), this._multiviewSceneUbo.updateMatrix("projection", this._projectionMatrix));
    }, Ue.prototype._renderMultiviewToSingleView = function(n) {
      n._resizeOrCreateMultiviewTexture(n._rigPostProcess && n._rigPostProcess && n._rigPostProcess.width > 0 ? n._rigPostProcess.width : this.getEngine().getRenderWidth(!0), n._rigPostProcess && n._rigPostProcess && n._rigPostProcess.height > 0 ? n._rigPostProcess.height : this.getEngine().getRenderHeight(!0)), this._multiviewSceneUbo || this._createMultiviewUbo(), n.outputRenderTarget = n._multiviewTexture, this._renderForCamera(n), n.outputRenderTarget = null;
      for (var t = 0; t < n._rigCameras.length; t++) {
        var e = this.getEngine();
        this._activeCamera = n._rigCameras[t], e.setViewport(this._activeCamera.viewport), this.postProcessManager && (this.postProcessManager._prepareFrame(), this.postProcessManager._finalizeFrame(this._activeCamera.isIntermediate));
      }
    };
    var cv = function(n) {
      function t(e, i, r) {
        var o = n.call(this, e, "vrMultiviewToSingleview", ["imageIndex"], ["multiviewSampler"], r, i, ae.BILINEAR_SAMPLINGMODE) || this, a = i ?? o.getCamera();
        return o.onSizeChangedObservable.add(function() {
        }), o.onApplyObservable.add(function(s) {
          a._scene.activeCamera && a._scene.activeCamera.isLeftCamera ? s.setInt("imageIndex", 0) : s.setInt("imageIndex", 1), s.setTexture("multiviewSampler", a._multiviewTexture);
        }), o;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "VRMultiviewToSingleviewPostProcess";
      }, t;
    }(nt);
    function uh(n, t) {
      var e = t.vrCameraMetrics || Sc.GetDefault();
      n._rigCameras[0]._cameraRigParams.vrMetrics = e, n._rigCameras[0].viewport = new xr(0, 0, 0.5, 1), n._rigCameras[0]._cameraRigParams.vrWorkMatrix = new B(), n._rigCameras[0]._cameraRigParams.vrHMatrix = e.leftHMatrix, n._rigCameras[0]._cameraRigParams.vrPreViewMatrix = e.leftPreViewMatrix, n._rigCameras[0].getProjectionMatrix = n._rigCameras[0]._getVRProjectionMatrix, n._rigCameras[1]._cameraRigParams.vrMetrics = e, n._rigCameras[1].viewport = new xr(0.5, 0, 0.5, 1), n._rigCameras[1]._cameraRigParams.vrWorkMatrix = new B(), n._rigCameras[1]._cameraRigParams.vrHMatrix = e.rightHMatrix, n._rigCameras[1]._cameraRigParams.vrPreViewMatrix = e.rightPreViewMatrix, n._rigCameras[1].getProjectionMatrix = n._rigCameras[1]._getVRProjectionMatrix, e.multiviewEnabled && (n.getScene().getEngine().getCaps().multiview ? (n._useMultiviewToSingleView = !0, n._rigPostProcess = new cv("VRMultiviewToSingleview", n, e.postProcessScaleFactor)) : (q.Warn("Multiview is not supported, falling back to standard rendering"), e.multiviewEnabled = !1)), e.compensateDistortion && (n._rigCameras[0]._rigPostProcess = new hf("VR_Distort_Compensation_Left", n._rigCameras[0], !1, e), n._rigCameras[1]._rigPostProcess = new hf("VR_Distort_Compensation_Right", n._rigCameras[1], !0, e));
    }
    oi.AddNodeConstructor("VRDeviceOrientationArcRotateCamera", function(n, t) {
      return function() {
        return new uv(n, 0, 0, 1, v.Zero(), t);
      };
    });
    var uv = function(n) {
      function t(e, i, r, o, a, s, l, c) {
        l === void 0 && (l = !0), c === void 0 && (c = Sc.GetDefault());
        var u = n.call(this, e, i, r, o, a, s) || this;
        return u._setRigMode = function(h) {
          return uh(u, h);
        }, c.compensateDistortion = l, u.setCameraRigMode(dt.RIG_MODE_VR, { vrCameraMetrics: c }), u.inputs.addVRDeviceOrientation(), u;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "VRDeviceOrientationArcRotateCamera";
      }, t;
    }(gs);
    oi.AddNodeConstructor("VRDeviceOrientationFreeCamera", function(n, t) {
      return function() {
        return new hh(n, v.Zero(), t);
      };
    });
    var hh = function(n) {
      function t(e, i, r, o, a) {
        o === void 0 && (o = !0), a === void 0 && (a = Sc.GetDefault());
        var s = n.call(this, e, i, r) || this;
        return s._setRigMode = function(l) {
          return uh(s, l);
        }, a.compensateDistortion = o, s.setCameraRigMode(dt.RIG_MODE_VR, { vrCameraMetrics: a }), s;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "VRDeviceOrientationFreeCamera";
      }, t;
    }(lh);
    oi.AddNodeConstructor("VRDeviceOrientationGamepadCamera", function(n, t) {
      return function() {
        return new hv(n, v.Zero(), t);
      };
    });
    var hv = function(n) {
      function t(e, i, r, o, a) {
        o === void 0 && (o = !0), a === void 0 && (a = Sc.GetDefault());
        var s = n.call(this, e, i, r, o, a) || this;
        return s._setRigMode = function(l) {
          return uh(s, l);
        }, s.inputs.addGamepad(), s;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "VRDeviceOrientationGamepadCamera";
      }, t;
    }(hh), xc = function() {
      function n() {
        this.previousWorldMatrices = {}, this.previousBones = {};
      }
      return n.AddUniforms = function(t) {
        t.push("previousWorld", "previousViewProjection", "mPreviousBones");
      }, n.AddSamplers = function(t) {
      }, n.prototype.bindForSubMesh = function(t, e, i, r, o) {
        if (e.prePassRenderer && e.prePassRenderer.enabled && e.prePassRenderer.currentRTisSceneRT && e.prePassRenderer.getIndex(_.PREPASS_VELOCITY_TEXTURE_TYPE) !== -1) {
          this.previousWorldMatrices[i.uniqueId] || (this.previousWorldMatrices[i.uniqueId] = r.clone()), this.previousViewProjection || (this.previousViewProjection = e.getTransformMatrix().clone(), this.currentViewProjection = e.getTransformMatrix().clone());
          var a = e.getEngine();
          this.currentViewProjection.updateFlag !== e.getTransformMatrix().updateFlag ? (this._lastUpdateFrameId = a.frameId, this.previousViewProjection.copyFrom(this.currentViewProjection), this.currentViewProjection.copyFrom(e.getTransformMatrix())) : this._lastUpdateFrameId !== a.frameId && (this._lastUpdateFrameId = a.frameId, this.previousViewProjection.copyFrom(this.currentViewProjection)), t.setMatrix("previousWorld", this.previousWorldMatrices[i.uniqueId]), t.setMatrix("previousViewProjection", this.previousViewProjection), this.previousWorldMatrices[i.uniqueId] = r.clone();
        }
      }, n;
    }(), Pe = function() {
      function n() {
      }
      return Object.defineProperty(n, "DiffuseTextureEnabled", { get: function() {
        return this._DiffuseTextureEnabled;
      }, set: function(t) {
        this._DiffuseTextureEnabled !== t && (this._DiffuseTextureEnabled = t, ve.MarkAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "DetailTextureEnabled", { get: function() {
        return this._DetailTextureEnabled;
      }, set: function(t) {
        this._DetailTextureEnabled !== t && (this._DetailTextureEnabled = t, ve.MarkAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "DecalMapEnabled", { get: function() {
        return this._DecalMapEnabled;
      }, set: function(t) {
        this._DecalMapEnabled !== t && (this._DecalMapEnabled = t, ve.MarkAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "AmbientTextureEnabled", { get: function() {
        return this._AmbientTextureEnabled;
      }, set: function(t) {
        this._AmbientTextureEnabled !== t && (this._AmbientTextureEnabled = t, ve.MarkAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "OpacityTextureEnabled", { get: function() {
        return this._OpacityTextureEnabled;
      }, set: function(t) {
        this._OpacityTextureEnabled !== t && (this._OpacityTextureEnabled = t, ve.MarkAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "ReflectionTextureEnabled", { get: function() {
        return this._ReflectionTextureEnabled;
      }, set: function(t) {
        this._ReflectionTextureEnabled !== t && (this._ReflectionTextureEnabled = t, ve.MarkAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "EmissiveTextureEnabled", { get: function() {
        return this._EmissiveTextureEnabled;
      }, set: function(t) {
        this._EmissiveTextureEnabled !== t && (this._EmissiveTextureEnabled = t, ve.MarkAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "SpecularTextureEnabled", { get: function() {
        return this._SpecularTextureEnabled;
      }, set: function(t) {
        this._SpecularTextureEnabled !== t && (this._SpecularTextureEnabled = t, ve.MarkAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "BumpTextureEnabled", { get: function() {
        return this._BumpTextureEnabled;
      }, set: function(t) {
        this._BumpTextureEnabled !== t && (this._BumpTextureEnabled = t, ve.MarkAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "LightmapTextureEnabled", { get: function() {
        return this._LightmapTextureEnabled;
      }, set: function(t) {
        this._LightmapTextureEnabled !== t && (this._LightmapTextureEnabled = t, ve.MarkAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "RefractionTextureEnabled", { get: function() {
        return this._RefractionTextureEnabled;
      }, set: function(t) {
        this._RefractionTextureEnabled !== t && (this._RefractionTextureEnabled = t, ve.MarkAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "ColorGradingTextureEnabled", { get: function() {
        return this._ColorGradingTextureEnabled;
      }, set: function(t) {
        this._ColorGradingTextureEnabled !== t && (this._ColorGradingTextureEnabled = t, ve.MarkAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "FresnelEnabled", { get: function() {
        return this._FresnelEnabled;
      }, set: function(t) {
        this._FresnelEnabled !== t && (this._FresnelEnabled = t, ve.MarkAllMaterialsAsDirty(_.MATERIAL_FresnelDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "ClearCoatTextureEnabled", { get: function() {
        return this._ClearCoatTextureEnabled;
      }, set: function(t) {
        this._ClearCoatTextureEnabled !== t && (this._ClearCoatTextureEnabled = t, ve.MarkAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "ClearCoatBumpTextureEnabled", { get: function() {
        return this._ClearCoatBumpTextureEnabled;
      }, set: function(t) {
        this._ClearCoatBumpTextureEnabled !== t && (this._ClearCoatBumpTextureEnabled = t, ve.MarkAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "ClearCoatTintTextureEnabled", { get: function() {
        return this._ClearCoatTintTextureEnabled;
      }, set: function(t) {
        this._ClearCoatTintTextureEnabled !== t && (this._ClearCoatTintTextureEnabled = t, ve.MarkAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "SheenTextureEnabled", { get: function() {
        return this._SheenTextureEnabled;
      }, set: function(t) {
        this._SheenTextureEnabled !== t && (this._SheenTextureEnabled = t, ve.MarkAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "AnisotropicTextureEnabled", { get: function() {
        return this._AnisotropicTextureEnabled;
      }, set: function(t) {
        this._AnisotropicTextureEnabled !== t && (this._AnisotropicTextureEnabled = t, ve.MarkAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "ThicknessTextureEnabled", { get: function() {
        return this._ThicknessTextureEnabled;
      }, set: function(t) {
        this._ThicknessTextureEnabled !== t && (this._ThicknessTextureEnabled = t, ve.MarkAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "RefractionIntensityTextureEnabled", { get: function() {
        return this._ThicknessTextureEnabled;
      }, set: function(t) {
        this._RefractionIntensityTextureEnabled !== t && (this._RefractionIntensityTextureEnabled = t, ve.MarkAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "TranslucencyIntensityTextureEnabled", { get: function() {
        return this._ThicknessTextureEnabled;
      }, set: function(t) {
        this._TranslucencyIntensityTextureEnabled !== t && (this._TranslucencyIntensityTextureEnabled = t, ve.MarkAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "IridescenceTextureEnabled", { get: function() {
        return this._IridescenceTextureEnabled;
      }, set: function(t) {
        this._IridescenceTextureEnabled !== t && (this._IridescenceTextureEnabled = t, ve.MarkAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag));
      }, enumerable: !1, configurable: !0 }), n._DiffuseTextureEnabled = !0, n._DetailTextureEnabled = !0, n._DecalMapEnabled = !0, n._AmbientTextureEnabled = !0, n._OpacityTextureEnabled = !0, n._ReflectionTextureEnabled = !0, n._EmissiveTextureEnabled = !0, n._SpecularTextureEnabled = !0, n._BumpTextureEnabled = !0, n._LightmapTextureEnabled = !0, n._RefractionTextureEnabled = !0, n._ColorGradingTextureEnabled = !0, n._FresnelEnabled = !0, n._ClearCoatTextureEnabled = !0, n._ClearCoatBumpTextureEnabled = !0, n._ClearCoatTintTextureEnabled = !0, n._SheenTextureEnabled = !0, n._AnisotropicTextureEnabled = !0, n._ThicknessTextureEnabled = !0, n._RefractionIntensityTextureEnabled = !0, n._TranslucencyIntensityTextureEnabled = !0, n._IridescenceTextureEnabled = !0, n;
    }();
    re.IncludesShadersStore.decalFragmentDeclaration = `#ifdef DECAL
uniform vec4 vDecalInfos;
#endif
`, re.IncludesShadersStore.defaultFragmentDeclaration = `uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;
#ifdef SPECULARTERM
uniform vec4 vSpecularColor;
#endif
uniform vec3 vEmissiveColor;uniform vec3 vAmbientColor;uniform float visibility;
#ifdef DIFFUSE
uniform vec2 vDiffuseInfos;
#endif
#ifdef AMBIENT
uniform vec2 vAmbientInfos;
#endif
#ifdef OPACITY 
uniform vec2 vOpacityInfos;
#endif
#ifdef EMISSIVE
uniform vec2 vEmissiveInfos;
#endif
#ifdef LIGHTMAP
uniform vec2 vLightmapInfos;
#endif
#ifdef BUMP
uniform vec3 vBumpInfos;uniform vec2 vTangentSpaceParams;
#endif
#ifdef ALPHATEST
uniform float alphaCutOff;
#endif
#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION) || defined(PREPASS)
uniform mat4 view;
#endif
#ifdef REFRACTION
uniform vec4 vRefractionInfos;
#ifndef REFRACTIONMAP_3D
uniform mat4 refractionMatrix;
#endif
#ifdef REFRACTIONFRESNEL
uniform vec4 refractionLeftColor;uniform vec4 refractionRightColor;
#endif
#if defined(USE_LOCAL_REFRACTIONMAP_CUBIC) && defined(REFRACTIONMAP_3D)
uniform vec3 vRefractionPosition;uniform vec3 vRefractionSize; 
#endif
#endif
#if defined(SPECULAR) && defined(SPECULARTERM)
uniform vec2 vSpecularInfos;
#endif
#ifdef DIFFUSEFRESNEL
uniform vec4 diffuseLeftColor;uniform vec4 diffuseRightColor;
#endif
#ifdef OPACITYFRESNEL
uniform vec4 opacityParts;
#endif
#ifdef EMISSIVEFRESNEL
uniform vec4 emissiveLeftColor;uniform vec4 emissiveRightColor;
#endif
#ifdef REFLECTION
uniform vec2 vReflectionInfos;
#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION) || defined(REFLECTIONMAP_EQUIRECTANGULAR) || defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_SKYBOX)
uniform mat4 reflectionMatrix;
#endif
#ifndef REFLECTIONMAP_SKYBOX
#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)
uniform vec3 vReflectionPosition;uniform vec3 vReflectionSize; 
#endif
#endif
#ifdef REFLECTIONFRESNEL
uniform vec4 reflectionLeftColor;uniform vec4 reflectionRightColor;
#endif
#endif
#ifdef DETAIL
uniform vec4 vDetailInfos;
#endif
#include<decalFragmentDeclaration>
#define ADDITIONAL_FRAGMENT_DECLARATION
`, re.IncludesShadersStore.sceneUboDeclaration = `layout(std140,column_major) uniform;uniform Scene {mat4 viewProjection;
#ifdef MULTIVIEW
mat4 viewProjectionR;
#endif 
mat4 view;mat4 projection;vec4 vEyePosition;};
`, re.IncludesShadersStore.meshUboDeclaration = `#ifdef WEBGL2
uniform mat4 world;uniform float visibility;
#else
layout(std140,column_major) uniform;uniform Mesh
{mat4 world;float visibility;};
#endif
#define WORLD_UBO
`, re.IncludesShadersStore.defaultUboDeclaration = `layout(std140,column_major) uniform;uniform Material
{vec4 diffuseLeftColor;vec4 diffuseRightColor;vec4 opacityParts;vec4 reflectionLeftColor;vec4 reflectionRightColor;vec4 refractionLeftColor;vec4 refractionRightColor;vec4 emissiveLeftColor;vec4 emissiveRightColor;vec2 vDiffuseInfos;vec2 vAmbientInfos;vec2 vOpacityInfos;vec2 vReflectionInfos;vec3 vReflectionPosition;vec3 vReflectionSize;vec2 vEmissiveInfos;vec2 vLightmapInfos;vec2 vSpecularInfos;vec3 vBumpInfos;mat4 diffuseMatrix;mat4 ambientMatrix;mat4 opacityMatrix;mat4 reflectionMatrix;mat4 emissiveMatrix;mat4 lightmapMatrix;mat4 specularMatrix;mat4 bumpMatrix;vec2 vTangentSpaceParams;float pointSize;float alphaCutOff;mat4 refractionMatrix;vec4 vRefractionInfos;vec3 vRefractionPosition;vec3 vRefractionSize;vec4 vSpecularColor;vec3 vEmissiveColor;vec4 vDiffuseColor;vec3 vAmbientColor;
#define ADDITIONAL_UBO_DECLARATION
};
#include<sceneUboDeclaration>
#include<meshUboDeclaration>
`, re.IncludesShadersStore.prePassDeclaration = `#ifdef PREPASS
#extension GL_EXT_draw_buffers : require
layout(location=0) out highp vec4 glFragData[{X}];highp vec4 gl_FragColor;
#ifdef PREPASS_DEPTH
varying highp vec3 vViewPos;
#endif
#ifdef PREPASS_VELOCITY
varying highp vec4 vCurrentPosition;varying highp vec4 vPreviousPosition;
#endif
#endif
`, re.IncludesShadersStore.oitDeclaration = `#ifdef ORDER_INDEPENDENT_TRANSPARENCY
#extension GL_EXT_draw_buffers : require
layout(location=0) out vec2 depth; 
layout(location=1) out vec4 frontColor;layout(location=2) out vec4 backColor;
#define MAX_DEPTH 99999.0
highp vec4 gl_FragColor;uniform sampler2D oitDepthSampler;uniform sampler2D oitFrontColorSampler;
#endif
`, re.IncludesShadersStore.mainUVVaryingDeclaration = `#ifdef MAINUV{X}
varying vec2 vMainUV{X};
#endif
`, re.IncludesShadersStore.helperFunctions = `const float PI=3.1415926535897932384626433832795;const float RECIPROCAL_PI=0.3183098861837907;const float RECIPROCAL_PI2=0.15915494309189535;const float HALF_MIN=5.96046448e-08; 
const float LinearEncodePowerApprox=2.2;const float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;const vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);const float Epsilon=0.0000001;
#define saturate(x) clamp(x,0.0,1.0)
#define absEps(x) abs(x)+Epsilon
#define maxEps(x) max(x,Epsilon)
#define saturateEps(x) clamp(x,Epsilon,1.0)
mat3 transposeMat3(mat3 inMatrix) {vec3 i0=inMatrix[0];vec3 i1=inMatrix[1];vec3 i2=inMatrix[2];mat3 outMatrix=mat3(
vec3(i0.x,i1.x,i2.x),
vec3(i0.y,i1.y,i2.y),
vec3(i0.z,i1.z,i2.z)
);return outMatrix;}
mat3 inverseMat3(mat3 inMatrix) {float a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];float a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];float a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];float b01=a22*a11-a12*a21;float b11=-a22*a10+a12*a20;float b21=a21*a10-a11*a20;float det=a00*b01+a01*b11+a02*b21;return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),
b11,(a22*a00-a02*a20),(-a12*a00+a02*a10),
b21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;}
#if USE_EXACT_SRGB_CONVERSIONS
vec3 toLinearSpaceExact(vec3 color)
{vec3 nearZeroSection=0.0773993808*color;vec3 remainingSection=pow(0.947867299*(color+vec3(0.055)),vec3(2.4));
#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
return mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3(0.04045)));
#else
return
vec3(
color.r<=0.04045 ? nearZeroSection.r : remainingSection.r,
color.g<=0.04045 ? nearZeroSection.g : remainingSection.g,
color.b<=0.04045 ? nearZeroSection.b : remainingSection.b);
#endif
}
vec3 toGammaSpaceExact(vec3 color)
{vec3 nearZeroSection=12.92*color;vec3 remainingSection=1.055*pow(color,vec3(0.41666))-vec3(0.055);
#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
return mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3(0.0031308)));
#else
return
vec3(
color.r<=0.0031308 ? nearZeroSection.r : remainingSection.r,
color.g<=0.0031308 ? nearZeroSection.g : remainingSection.g,
color.b<=0.0031308 ? nearZeroSection.b : remainingSection.b);
#endif
}
#endif
float toLinearSpace(float color)
{
#if USE_EXACT_SRGB_CONVERSIONS
float nearZeroSection=0.0773993808*color;float remainingSection=pow(0.947867299*(color+0.055),2.4);return color<=0.04045 ? nearZeroSection : remainingSection;
#else
return pow(color,LinearEncodePowerApprox);
#endif
}
vec3 toLinearSpace(vec3 color)
{
#if USE_EXACT_SRGB_CONVERSIONS
return toLinearSpaceExact(color);
#else
return pow(color,vec3(LinearEncodePowerApprox));
#endif
}
vec4 toLinearSpace(vec4 color)
{
#if USE_EXACT_SRGB_CONVERSIONS
return vec4(toLinearSpaceExact(color.rgb),color.a);
#else
return vec4(pow(color.rgb,vec3(LinearEncodePowerApprox)),color.a);
#endif
}
float toGammaSpace(float color)
{
#if USE_EXACT_SRGB_CONVERSIONS
float nearZeroSection=12.92*color;float remainingSection=1.055*pow(color,0.41666)-0.055;return color<=0.0031308 ? nearZeroSection : remainingSection;
#else
return pow(color,GammaEncodePowerApprox);
#endif
}
vec3 toGammaSpace(vec3 color)
{
#if USE_EXACT_SRGB_CONVERSIONS
return toGammaSpaceExact(color);
#else
return pow(color,vec3(GammaEncodePowerApprox));
#endif
}
vec4 toGammaSpace(vec4 color)
{
#if USE_EXACT_SRGB_CONVERSIONS
return vec4(toGammaSpaceExact(color.rgb),color.a);
#else
return vec4(pow(color.rgb,vec3(GammaEncodePowerApprox)),color.a);
#endif
}
float square(float value)
{return value*value;}
vec3 square(vec3 value)
{return value*value;}
float pow5(float value) {float sq=value*value;return sq*sq*value;}
float getLuminance(vec3 color)
{return clamp(dot(color,LuminanceEncodeApprox),0.,1.);}
float getRand(vec2 seed) {return fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);}
float dither(vec2 seed,float varianceAmount) {float rand=getRand(seed);float normVariance=varianceAmount/255.0;float dither=mix(-normVariance,normVariance,rand);return dither;}
const float rgbdMaxRange=255.0;vec4 toRGBD(vec3 color) {float maxRGB=maxEps(max(color.r,max(color.g,color.b)));float D =max(rgbdMaxRange/maxRGB,1.);D =clamp(floor(D)/255.0,0.,1.);vec3 rgb=color.rgb*D;rgb=toGammaSpace(rgb);return vec4(clamp(rgb,0.,1.),D); }
vec3 fromRGBD(vec4 rgbd) {rgbd.rgb=toLinearSpace(rgbd.rgb);return rgbd.rgb/rgbd.a;}
vec3 parallaxCorrectNormal( vec3 vertexPos,vec3 origVec,vec3 cubeSize,vec3 cubePos ) {vec3 invOrigVec=vec3(1.0,1.0,1.0)/origVec;vec3 halfSize=cubeSize*0.5;vec3 intersecAtMaxPlane=(cubePos+halfSize-vertexPos)*invOrigVec;vec3 intersecAtMinPlane=(cubePos-halfSize-vertexPos)*invOrigVec;vec3 largestIntersec=max(intersecAtMaxPlane,intersecAtMinPlane);float distance=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);vec3 intersectPositionWS=vertexPos+origVec*distance;return intersectPositionWS-cubePos;}
`, re.IncludesShadersStore.lightFragmentDeclaration = `#ifdef LIGHT{X}
uniform vec4 vLightData{X};uniform vec4 vLightDiffuse{X};
#ifdef SPECULARTERM
uniform vec4 vLightSpecular{X};
#else
vec4 vLightSpecular{X}=vec4(0.);
#endif
#ifdef SHADOW{X}
#ifdef SHADOWCSM{X}
uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];uniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];uniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];uniform float cascadeBlendFactor{X};varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X};
#if defined(SHADOWPCSS{X})
uniform highp sampler2DArrayShadow shadowSampler{X};uniform highp sampler2DArray depthSampler{X};uniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float penumbraDarkness{X};
#elif defined(SHADOWPCF{X})
uniform highp sampler2DArrayShadow shadowSampler{X};
#else
uniform highp sampler2DArray shadowSampler{X};
#endif
#ifdef SHADOWCSMDEBUG{X}
const vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]
(
vec3 ( 1.5,0.0,0.0 ),
vec3 ( 0.0,1.5,0.0 ),
vec3 ( 0.0,0.0,5.5 ),
vec3 ( 1.5,0.0,5.5 ),
vec3 ( 1.5,1.5,0.0 ),
vec3 ( 1.0,1.0,1.0 ),
vec3 ( 0.0,1.0,5.5 ),
vec3 ( 0.5,3.5,0.75 )
);vec3 shadowDebug{X};
#endif
#ifdef SHADOWCSMUSESHADOWMAXZ{X}
int index{X}=-1;
#else
int index{X}=SHADOWCSMNUM_CASCADES{X}-1;
#endif
float diff{X}=0.;
#elif defined(SHADOWCUBE{X})
uniform samplerCube shadowSampler{X};
#else
varying vec4 vPositionFromLight{X};varying float vDepthMetric{X};
#if defined(SHADOWPCSS{X})
uniform highp sampler2DShadow shadowSampler{X};uniform highp sampler2D depthSampler{X};
#elif defined(SHADOWPCF{X})
uniform highp sampler2DShadow shadowSampler{X};
#else
uniform sampler2D shadowSampler{X};
#endif
uniform mat4 lightMatrix{X};
#endif
uniform vec4 shadowsInfo{X};uniform vec2 depthValues{X};
#endif
#ifdef SPOTLIGHT{X}
uniform vec4 vLightDirection{X};uniform vec4 vLightFalloff{X};
#elif defined(POINTLIGHT{X})
uniform vec4 vLightFalloff{X};
#elif defined(HEMILIGHT{X})
uniform vec3 vLightGround{X};
#endif
#ifdef PROJECTEDLIGHTTEXTURE{X}
uniform mat4 textureProjectionMatrix{X};uniform sampler2D projectionLightSampler{X};
#endif
#endif
`, re.IncludesShadersStore.lightUboDeclaration = `#ifdef LIGHT{X}
uniform Light{X}
{vec4 vLightData;vec4 vLightDiffuse;vec4 vLightSpecular;
#ifdef SPOTLIGHT{X}
vec4 vLightDirection;vec4 vLightFalloff;
#elif defined(POINTLIGHT{X})
vec4 vLightFalloff;
#elif defined(HEMILIGHT{X})
vec3 vLightGround;
#endif
vec4 shadowsInfo;vec2 depthValues;} light{X};
#ifdef PROJECTEDLIGHTTEXTURE{X}
uniform mat4 textureProjectionMatrix{X};uniform sampler2D projectionLightSampler{X};
#endif
#ifdef SHADOW{X}
#ifdef SHADOWCSM{X}
uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];uniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];uniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];uniform float cascadeBlendFactor{X};varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X};
#if defined(SHADOWPCSS{X})
uniform highp sampler2DArrayShadow shadowSampler{X};uniform highp sampler2DArray depthSampler{X};uniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float penumbraDarkness{X};
#elif defined(SHADOWPCF{X})
uniform highp sampler2DArrayShadow shadowSampler{X};
#else
uniform highp sampler2DArray shadowSampler{X};
#endif
#ifdef SHADOWCSMDEBUG{X}
const vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]
(
vec3 ( 1.5,0.0,0.0 ),
vec3 ( 0.0,1.5,0.0 ),
vec3 ( 0.0,0.0,5.5 ),
vec3 ( 1.5,0.0,5.5 ),
vec3 ( 1.5,1.5,0.0 ),
vec3 ( 1.0,1.0,1.0 ),
vec3 ( 0.0,1.0,5.5 ),
vec3 ( 0.5,3.5,0.75 )
);vec3 shadowDebug{X};
#endif
#ifdef SHADOWCSMUSESHADOWMAXZ{X}
int index{X}=-1;
#else
int index{X}=SHADOWCSMNUM_CASCADES{X}-1;
#endif
float diff{X}=0.;
#elif defined(SHADOWCUBE{X})
uniform samplerCube shadowSampler{X}; 
#else
varying vec4 vPositionFromLight{X};varying float vDepthMetric{X};
#if defined(SHADOWPCSS{X})
uniform highp sampler2DShadow shadowSampler{X};uniform highp sampler2D depthSampler{X};
#elif defined(SHADOWPCF{X})
uniform highp sampler2DShadow shadowSampler{X};
#else
uniform sampler2D shadowSampler{X};
#endif
uniform mat4 lightMatrix{X};
#endif
#endif
#endif
`, re.IncludesShadersStore.lightsFragmentFunctions = `struct lightingInfo
{vec3 diffuse;
#ifdef SPECULARTERM
vec3 specular;
#endif
#ifdef NDOTL
float ndl;
#endif
};lightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {lightingInfo result;vec3 lightVectorW;float attenuation=1.0;if (lightData.w==0.)
{vec3 direction=lightData.xyz-vPositionW;attenuation=max(0.,1.0-length(direction)/range);lightVectorW=normalize(direction);}
else
{lightVectorW=normalize(-lightData.xyz);}
float ndl=max(0.,dot(vNormal,lightVectorW));
#ifdef NDOTL
result.ndl=ndl;
#endif
result.diffuse=ndl*diffuseColor*attenuation;
#ifdef SPECULARTERM
vec3 angleW=normalize(viewDirectionW+lightVectorW);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation;
#endif
return result;}
lightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {lightingInfo result;vec3 direction=lightData.xyz-vPositionW;vec3 lightVectorW=normalize(direction);float attenuation=max(0.,1.0-length(direction)/range);float cosAngle=max(0.,dot(lightDirection.xyz,-lightVectorW));if (cosAngle>=lightDirection.w)
{cosAngle=max(0.,pow(cosAngle,lightData.w));attenuation*=cosAngle;float ndl=max(0.,dot(vNormal,lightVectorW));
#ifdef NDOTL
result.ndl=ndl;
#endif
result.diffuse=ndl*diffuseColor*attenuation;
#ifdef SPECULARTERM
vec3 angleW=normalize(viewDirectionW+lightVectorW);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation;
#endif
return result;}
result.diffuse=vec3(0.);
#ifdef SPECULARTERM
result.specular=vec3(0.);
#endif
#ifdef NDOTL
result.ndl=0.;
#endif
return result;}
lightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) {lightingInfo result;float ndl=dot(vNormal,lightData.xyz)*0.5+0.5;
#ifdef NDOTL
result.ndl=ndl;
#endif
result.diffuse=mix(groundColor,diffuseColor,ndl);
#ifdef SPECULARTERM
vec3 angleW=normalize(viewDirectionW+lightData.xyz);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor;
#endif
return result;}
#define inline
vec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){vec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);strq/=strq.w;vec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;return textureColor;}`, re.IncludesShadersStore.shadowsFragmentFunctions = `#ifdef SHADOWS
#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
#define TEXTUREFUNC(s,c,l) texture2DLodEXT(s,c,l)
#else
#define TEXTUREFUNC(s,c,b) texture2D(s,c,b)
#endif
#ifndef SHADOWFLOAT
float unpack(vec4 color)
{const vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(color,bit_shift);}
#endif
float computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)
{float mask=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.));return mix(value,1.0,mask);}
#define inline
float computeShadowCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)
{vec3 directionToLight=worldPos-lightPosition;float depth=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);depth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;
#ifndef SHADOWFLOAT
float shadow=unpack(textureCube(shadowSampler,directionToLight));
#else
float shadow=textureCube(shadowSampler,directionToLight).x;
#endif
return depth>shadow ? darkness : 1.0;}
#define inline
float computeShadowWithPoissonSamplingCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)
{vec3 directionToLight=worldPos-lightPosition;float depth=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);depth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;float visibility=1.;vec3 poissonDisk[4];poissonDisk[0]=vec3(-1.0,1.0,-1.0);poissonDisk[1]=vec3(1.0,-1.0,-1.0);poissonDisk[2]=vec3(-1.0,-1.0,-1.0);poissonDisk[3]=vec3(1.0,-1.0,1.0);
#ifndef SHADOWFLOAT
if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) visibility-=0.25;if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) visibility-=0.25;if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) visibility-=0.25;if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) visibility-=0.25;
#else
if (textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) visibility-=0.25;if (textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) visibility-=0.25;if (textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) visibility-=0.25;if (textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) visibility-=0.25;
#endif
return min(1.0,visibility+darkness);}
#define inline
float computeShadowWithESMCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)
{vec3 directionToLight=worldPos-lightPosition;float depth=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);float shadowPixelDepth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;
#ifndef SHADOWFLOAT
float shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));
#else
float shadowMapSample=textureCube(shadowSampler,directionToLight).x;
#endif
float esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);return esm;}
#define inline
float computeShadowWithCloseESMCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)
{vec3 directionToLight=worldPos-lightPosition;float depth=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);float shadowPixelDepth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;
#ifndef SHADOWFLOAT
float shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));
#else
float shadowMapSample=textureCube(shadowSampler,directionToLight).x;
#endif
float esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);return esm;}
#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
#define inline
float computeShadowCSM(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray shadowSampler,float darkness,float frustumEdgeFalloff)
{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);vec3 uvLayer=vec3(uv.x,uv.y,layer);float shadowPixelDepth=clamp(depthMetric,0.,1.0);
#ifndef SHADOWFLOAT
float shadow=unpack(texture2D(shadowSampler,uvLayer));
#else
float shadow=texture2D(shadowSampler,uvLayer).x;
#endif
return shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;}
#endif
#define inline
float computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)
{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
{return 1.0;}
else
{float shadowPixelDepth=clamp(depthMetric,0.,1.0);
#ifndef SHADOWFLOAT
float shadow=unpack(TEXTUREFUNC(shadowSampler,uv,0.));
#else
float shadow=TEXTUREFUNC(shadowSampler,uv,0.).x;
#endif
return shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;}}
#define inline
float computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)
{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
{return 1.0;}
else
{float shadowPixelDepth=clamp(depthMetric,0.,1.0);float visibility=1.;vec2 poissonDisk[4];poissonDisk[0]=vec2(-0.94201624,-0.39906216);poissonDisk[1]=vec2(0.94558609,-0.76890725);poissonDisk[2]=vec2(-0.094184101,-0.92938870);poissonDisk[3]=vec2(0.34495938,0.29387760);
#ifndef SHADOWFLOAT
if (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[0]*mapSize,0.))<shadowPixelDepth) visibility-=0.25;if (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[1]*mapSize,0.))<shadowPixelDepth) visibility-=0.25;if (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[2]*mapSize,0.))<shadowPixelDepth) visibility-=0.25;if (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[3]*mapSize,0.))<shadowPixelDepth) visibility-=0.25;
#else
if (TEXTUREFUNC(shadowSampler,uv+poissonDisk[0]*mapSize,0.).x<shadowPixelDepth) visibility-=0.25;if (TEXTUREFUNC(shadowSampler,uv+poissonDisk[1]*mapSize,0.).x<shadowPixelDepth) visibility-=0.25;if (TEXTUREFUNC(shadowSampler,uv+poissonDisk[2]*mapSize,0.).x<shadowPixelDepth) visibility-=0.25;if (TEXTUREFUNC(shadowSampler,uv+poissonDisk[3]*mapSize,0.).x<shadowPixelDepth) visibility-=0.25;
#endif
return computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);}}
#define inline
float computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)
{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
{return 1.0;}
else
{float shadowPixelDepth=clamp(depthMetric,0.,1.0);
#ifndef SHADOWFLOAT
float shadowMapSample=unpack(TEXTUREFUNC(shadowSampler,uv,0.));
#else
float shadowMapSample=TEXTUREFUNC(shadowSampler,uv,0.).x;
#endif
float esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);}}
#define inline
float computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)
{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
{return 1.0;}
else
{float shadowPixelDepth=clamp(depthMetric,0.,1.0); 
#ifndef SHADOWFLOAT
float shadowMapSample=unpack(TEXTUREFUNC(shadowSampler,uv,0.));
#else
float shadowMapSample=TEXTUREFUNC(shadowSampler,uv,0.).x;
#endif
float esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);}}
#ifdef IS_NDC_HALF_ZRANGE
#define ZINCLIP clipSpace.z
#else
#define ZINCLIP uvDepth.z
#endif
#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
#define GREATEST_LESS_THAN_ONE 0.99999994
/* disable_uniformity_analysis */
#define inline
float computeShadowWithCSMPCF1(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,float darkness,float frustumEdgeFalloff)
{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);vec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);float shadow=texture2D(shadowSampler,uvDepthLayer);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}
#define inline
float computeShadowWithCSMPCF3(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; 
uv+=0.5; 
vec2 st=fract(uv); 
vec2 base_uv=floor(uv)-0.5; 
base_uv*=shadowMapSizeAndInverse.y; 
vec2 uvw0=3.-2.*st;vec2 uvw1=1.+2.*st;vec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;vec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));shadow=shadow/16.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}
#define inline
float computeShadowWithCSMPCF5(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; 
uv+=0.5; 
vec2 st=fract(uv); 
vec2 base_uv=floor(uv)-0.5; 
base_uv*=shadowMapSizeAndInverse.y; 
vec2 uvw0=4.-3.*st;vec2 uvw1=vec2(7.);vec2 uvw2=1.+3.*st;vec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;vec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));shadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[0]),layer,uvDepth.z));shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));shadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[1]),layer,uvDepth.z));shadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[2]),layer,uvDepth.z));shadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[2]),layer,uvDepth.z));shadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[2]),layer,uvDepth.z));shadow=shadow/144.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}
#define inline
float computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)
{if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;}
else
{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;float shadow=TEXTUREFUNC(shadowSampler,uvDepth,0.);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}
#define inline
float computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
{if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;}
else
{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; 
uv+=0.5; 
vec2 st=fract(uv); 
vec2 base_uv=floor(uv)-0.5; 
base_uv*=shadowMapSizeAndInverse.y; 
vec2 uvw0=3.-2.*st;vec2 uvw1=1.+2.*st;vec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;vec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z),0.);shadow+=uvw1.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z),0.);shadow+=uvw0.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z),0.);shadow+=uvw1.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z),0.);shadow=shadow/16.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}
#define inline
float computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
{if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;}
else
{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; 
uv+=0.5; 
vec2 st=fract(uv); 
vec2 base_uv=floor(uv)-0.5; 
base_uv*=shadowMapSizeAndInverse.y; 
vec2 uvw0=4.-3.*st;vec2 uvw1=vec2(7.);vec2 uvw2=1.+3.*st;vec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;vec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z),0.);shadow+=uvw1.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z),0.);shadow+=uvw2.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z),0.);shadow+=uvw0.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z),0.);shadow+=uvw1.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z),0.);shadow+=uvw2.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z),0.);shadow+=uvw0.x*uvw2.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z),0.);shadow+=uvw1.x*uvw2.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z),0.);shadow+=uvw2.x*uvw2.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z),0.);shadow=shadow/144.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}
const vec3 PoissonSamplers32[64]=vec3[64](
vec3(0.06407013,0.05409927,0.),
vec3(0.7366577,0.5789394,0.),
vec3(-0.6270542,-0.5320278,0.),
vec3(-0.4096107,0.8411095,0.),
vec3(0.6849564,-0.4990818,0.),
vec3(-0.874181,-0.04579735,0.),
vec3(0.9989998,0.0009880066,0.),
vec3(-0.004920578,-0.9151649,0.),
vec3(0.1805763,0.9747483,0.),
vec3(-0.2138451,0.2635818,0.),
vec3(0.109845,0.3884785,0.),
vec3(0.06876755,-0.3581074,0.),
vec3(0.374073,-0.7661266,0.),
vec3(0.3079132,-0.1216763,0.),
vec3(-0.3794335,-0.8271583,0.),
vec3(-0.203878,-0.07715034,0.),
vec3(0.5912697,0.1469799,0.),
vec3(-0.88069,0.3031784,0.),
vec3(0.5040108,0.8283722,0.),
vec3(-0.5844124,0.5494877,0.),
vec3(0.6017799,-0.1726654,0.),
vec3(-0.5554981,0.1559997,0.),
vec3(-0.3016369,-0.3900928,0.),
vec3(-0.5550632,-0.1723762,0.),
vec3(0.925029,0.2995041,0.),
vec3(-0.2473137,0.5538505,0.),
vec3(0.9183037,-0.2862392,0.),
vec3(0.2469421,0.6718712,0.),
vec3(0.3916397,-0.4328209,0.),
vec3(-0.03576927,-0.6220032,0.),
vec3(-0.04661255,0.7995201,0.),
vec3(0.4402924,0.3640312,0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.),
vec3(0.)
);const vec3 PoissonSamplers64[64]=vec3[64](
vec3(-0.613392,0.617481,0.),
vec3(0.170019,-0.040254,0.),
vec3(-0.299417,0.791925,0.),
vec3(0.645680,0.493210,0.),
vec3(-0.651784,0.717887,0.),
vec3(0.421003,0.027070,0.),
vec3(-0.817194,-0.271096,0.),
vec3(-0.705374,-0.668203,0.),
vec3(0.977050,-0.108615,0.),
vec3(0.063326,0.142369,0.),
vec3(0.203528,0.214331,0.),
vec3(-0.667531,0.326090,0.),
vec3(-0.098422,-0.295755,0.),
vec3(-0.885922,0.215369,0.),
vec3(0.566637,0.605213,0.),
vec3(0.039766,-0.396100,0.),
vec3(0.751946,0.453352,0.),
vec3(0.078707,-0.715323,0.),
vec3(-0.075838,-0.529344,0.),
vec3(0.724479,-0.580798,0.),
vec3(0.222999,-0.215125,0.),
vec3(-0.467574,-0.405438,0.),
vec3(-0.248268,-0.814753,0.),
vec3(0.354411,-0.887570,0.),
vec3(0.175817,0.382366,0.),
vec3(0.487472,-0.063082,0.),
vec3(-0.084078,0.898312,0.),
vec3(0.488876,-0.783441,0.),
vec3(0.470016,0.217933,0.),
vec3(-0.696890,-0.549791,0.),
vec3(-0.149693,0.605762,0.),
vec3(0.034211,0.979980,0.),
vec3(0.503098,-0.308878,0.),
vec3(-0.016205,-0.872921,0.),
vec3(0.385784,-0.393902,0.),
vec3(-0.146886,-0.859249,0.),
vec3(0.643361,0.164098,0.),
vec3(0.634388,-0.049471,0.),
vec3(-0.688894,0.007843,0.),
vec3(0.464034,-0.188818,0.),
vec3(-0.440840,0.137486,0.),
vec3(0.364483,0.511704,0.),
vec3(0.034028,0.325968,0.),
vec3(0.099094,-0.308023,0.),
vec3(0.693960,-0.366253,0.),
vec3(0.678884,-0.204688,0.),
vec3(0.001801,0.780328,0.),
vec3(0.145177,-0.898984,0.),
vec3(0.062655,-0.611866,0.),
vec3(0.315226,-0.604297,0.),
vec3(-0.780145,0.486251,0.),
vec3(-0.371868,0.882138,0.),
vec3(0.200476,0.494430,0.),
vec3(-0.494552,-0.711051,0.),
vec3(0.612476,0.705252,0.),
vec3(-0.578845,-0.768792,0.),
vec3(-0.772454,-0.090976,0.),
vec3(0.504440,0.372295,0.),
vec3(0.155736,0.065157,0.),
vec3(0.391522,0.849605,0.),
vec3(-0.620106,-0.328104,0.),
vec3(0.789239,-0.419965,0.),
vec3(-0.545396,0.538133,0.),
vec3(-0.178564,-0.596057,0.)
);
#define inline
float computeShadowWithCSMPCSS(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)
{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);vec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);float blockerDepth=0.0;float sumBlockerDepth=0.0;float numBlocker=0.0;for (int i=0; i<searchTapCount; i ++) {blockerDepth=texture2D(depthSampler,vec3(uvDepth.xy+(lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse*PoissonSamplers32[i].xy),layer)).r;if (blockerDepth<depthMetric) {sumBlockerDepth+=blockerDepth;numBlocker++;}}
float avgBlockerDepth=sumBlockerDepth/numBlocker;float AAOffset=shadowMapSizeInverse*10.;float penumbraRatio=((depthMetric-avgBlockerDepth)*depthCorrection+AAOffset);vec4 filterRadius=vec4(penumbraRatio*lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse,0.,0.);float random=getRand(vPositionFromLight.xy);float rotationAngle=random*3.1415926;vec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));float shadow=0.;for (int i=0; i<pcfTapCount; i++) {vec4 offset=vec4(poissonSamplers[i],0.);offset=vec4(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.,0.);shadow+=texture2D(shadowSampler,uvDepthLayer+offset*filterRadius);}
shadow/=float(pcfTapCount);shadow=mix(shadow,1.,min((depthMetric-avgBlockerDepth)*depthCorrection*penumbraDarkness,1.));shadow=mix(darkness,1.,shadow);if (numBlocker<1.0) {return 1.0;}
else
{return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}
#define inline
float computeShadowWithPCSS(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers)
{if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;}
else
{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;float blockerDepth=0.0;float sumBlockerDepth=0.0;float numBlocker=0.0;for (int i=0; i<searchTapCount; i ++) {blockerDepth=TEXTUREFUNC(depthSampler,uvDepth.xy+(lightSizeUV*shadowMapSizeInverse*PoissonSamplers32[i].xy),0.).r;if (blockerDepth<depthMetric) {sumBlockerDepth+=blockerDepth;numBlocker++;}}
if (numBlocker<1.0) {return 1.0;}
else
{float avgBlockerDepth=sumBlockerDepth/numBlocker;float AAOffset=shadowMapSizeInverse*10.;float penumbraRatio=((depthMetric-avgBlockerDepth)+AAOffset);float filterRadius=penumbraRatio*lightSizeUV*shadowMapSizeInverse;float random=getRand(vPositionFromLight.xy);float rotationAngle=random*3.1415926;vec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));float shadow=0.;for (int i=0; i<pcfTapCount; i++) {vec3 offset=poissonSamplers[i];offset=vec3(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.);shadow+=TEXTUREFUNC(shadowSampler,uvDepth+offset*filterRadius,0.);}
shadow/=float(pcfTapCount);shadow=mix(shadow,1.,depthMetric-avgBlockerDepth);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}}
#define inline
float computeShadowWithPCSS16(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)
{return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32);}
#define inline
float computeShadowWithPCSS32(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)
{return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32);}
#define inline
float computeShadowWithPCSS64(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)
{return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64);}
#define inline
float computeShadowWithCSMPCSS16(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)
{return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);}
#define inline
float computeShadowWithCSMPCSS32(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)
{return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);}
#define inline
float computeShadowWithCSMPCSS64(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)
{return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64,lightSizeUVCorrection,depthCorrection,penumbraDarkness);}
#endif
#endif
`, re.IncludesShadersStore.samplerFragmentDeclaration = `#ifdef _DEFINENAME_
#if _DEFINENAME_DIRECTUV==1
#define v_VARYINGNAME_UV vMainUV1
#elif _DEFINENAME_DIRECTUV==2
#define v_VARYINGNAME_UV vMainUV2
#elif _DEFINENAME_DIRECTUV==3
#define v_VARYINGNAME_UV vMainUV3
#elif _DEFINENAME_DIRECTUV==4
#define v_VARYINGNAME_UV vMainUV4
#elif _DEFINENAME_DIRECTUV==5
#define v_VARYINGNAME_UV vMainUV5
#elif _DEFINENAME_DIRECTUV==6
#define v_VARYINGNAME_UV vMainUV6
#else
varying vec2 v_VARYINGNAME_UV;
#endif
uniform sampler2D _SAMPLERNAME_Sampler;
#endif
`, re.IncludesShadersStore.fresnelFunction = `#ifdef FRESNEL
float computeFresnelTerm(vec3 viewDirection,vec3 worldNormal,float bias,float power)
{float fresnelTerm=pow(bias+abs(dot(viewDirection,worldNormal)),power);return clamp(fresnelTerm,0.,1.);}
#endif
`, re.IncludesShadersStore.reflectionFunction = `vec3 computeFixedEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 direction)
{float lon=atan(direction.z,direction.x);float lat=acos(direction.y);vec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;float s=sphereCoords.x*0.5+0.5;float t=sphereCoords.y;return vec3(s,t,0); }
vec3 computeMirroredFixedEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 direction)
{float lon=atan(direction.z,direction.x);float lat=acos(direction.y);vec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;float s=sphereCoords.x*0.5+0.5;float t=sphereCoords.y;return vec3(1.0-s,t,0); }
vec3 computeEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)
{vec3 cameraToVertex=normalize(worldPos.xyz-eyePosition);vec3 r=normalize(reflect(cameraToVertex,worldNormal));r=vec3(reflectionMatrix*vec4(r,0));float lon=atan(r.z,r.x);float lat=acos(r.y);vec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;float s=sphereCoords.x*0.5+0.5;float t=sphereCoords.y;return vec3(s,t,0);}
vec3 computeSphericalCoords(vec4 worldPos,vec3 worldNormal,mat4 view,mat4 reflectionMatrix)
{vec3 viewDir=normalize(vec3(view*worldPos));vec3 viewNormal=normalize(vec3(view*vec4(worldNormal,0.0)));vec3 r=reflect(viewDir,viewNormal);r=vec3(reflectionMatrix*vec4(r,0));r.z=r.z-1.0;float m=2.0*length(r);return vec3(r.x/m+0.5,1.0-r.y/m-0.5,0);}
vec3 computePlanarCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)
{vec3 viewDir=worldPos.xyz-eyePosition;vec3 coords=normalize(reflect(viewDir,worldNormal));return vec3(reflectionMatrix*vec4(coords,1));}
vec3 computeCubicCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)
{vec3 viewDir=normalize(worldPos.xyz-eyePosition);vec3 coords=reflect(viewDir,worldNormal);coords=vec3(reflectionMatrix*vec4(coords,0));
#ifdef INVERTCUBICMAP
coords.y*=-1.0;
#endif
return coords;}
vec3 computeCubicLocalCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix,vec3 reflectionSize,vec3 reflectionPosition)
{vec3 viewDir=normalize(worldPos.xyz-eyePosition);vec3 coords=reflect(viewDir,worldNormal);coords=parallaxCorrectNormal(worldPos.xyz,coords,reflectionSize,reflectionPosition);coords=vec3(reflectionMatrix*vec4(coords,0));
#ifdef INVERTCUBICMAP
coords.y*=-1.0;
#endif
return coords;}
vec3 computeProjectionCoords(vec4 worldPos,mat4 view,mat4 reflectionMatrix)
{return vec3(reflectionMatrix*(view*worldPos));}
vec3 computeSkyBoxCoords(vec3 positionW,mat4 reflectionMatrix)
{return vec3(reflectionMatrix*vec4(positionW,1.));}
#ifdef REFLECTION
vec3 computeReflectionCoords(vec4 worldPos,vec3 worldNormal)
{
#ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED
vec3 direction=normalize(vDirectionW);return computeMirroredFixedEquirectangularCoords(worldPos,worldNormal,direction);
#endif
#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED
vec3 direction=normalize(vDirectionW);return computeFixedEquirectangularCoords(worldPos,worldNormal,direction);
#endif
#ifdef REFLECTIONMAP_EQUIRECTANGULAR
return computeEquirectangularCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);
#endif
#ifdef REFLECTIONMAP_SPHERICAL
return computeSphericalCoords(worldPos,worldNormal,view,reflectionMatrix);
#endif
#ifdef REFLECTIONMAP_PLANAR
return computePlanarCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);
#endif
#ifdef REFLECTIONMAP_CUBIC
#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC
return computeCubicLocalCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix,vReflectionSize,vReflectionPosition);
#else
return computeCubicCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);
#endif
#endif
#ifdef REFLECTIONMAP_PROJECTION
return computeProjectionCoords(worldPos,view,reflectionMatrix);
#endif
#ifdef REFLECTIONMAP_SKYBOX
return computeSkyBoxCoords(vPositionUVW,reflectionMatrix);
#endif
#ifdef REFLECTIONMAP_EXPLICIT
return vec3(0,0,0);
#endif
}
#endif
`, re.IncludesShadersStore.imageProcessingDeclaration = `#ifdef EXPOSURE
uniform float exposureLinear;
#endif
#ifdef CONTRAST
uniform float contrast;
#endif
#if defined(VIGNETTE) || defined(DITHER)
uniform vec2 vInverseScreenSize;
#endif
#ifdef VIGNETTE
uniform vec4 vignetteSettings1;uniform vec4 vignetteSettings2;
#endif
#ifdef COLORCURVES
uniform vec4 vCameraColorCurveNegative;uniform vec4 vCameraColorCurveNeutral;uniform vec4 vCameraColorCurvePositive;
#endif
#ifdef COLORGRADING
#ifdef COLORGRADING3D
uniform highp sampler3D txColorTransform;
#else
uniform sampler2D txColorTransform;
#endif
uniform vec4 colorTransformSettings;
#endif
#ifdef DITHER
uniform float ditherIntensity;
#endif
`, re.IncludesShadersStore.imageProcessingFunctions = `#if defined(COLORGRADING) && !defined(COLORGRADING3D)
/** 
* Polyfill for SAMPLE_TEXTURE_3D,which is unsupported in WebGL.
* sampler3dSetting.x=textureOffset (0.5/textureSize).
* sampler3dSetting.y=textureSize.
*/
#define inline
vec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)
{float sliceSize=2.0*sampler3dSetting.x; 
#ifdef SAMPLER3DGREENDEPTH
float sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;
#else
float sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;
#endif
float sliceInteger=floor(sliceContinuous);float sliceFraction=sliceContinuous-sliceInteger;
#ifdef SAMPLER3DGREENDEPTH
vec2 sliceUV=color.rb;
#else
vec2 sliceUV=color.rg;
#endif
sliceUV.x*=sliceSize;sliceUV.x+=sliceInteger*sliceSize;sliceUV=saturate(sliceUV);vec4 slice0Color=texture2D(colorTransform,sliceUV);sliceUV.x+=sliceSize;sliceUV=saturate(sliceUV);vec4 slice1Color=texture2D(colorTransform,sliceUV);vec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);
#ifdef SAMPLER3DBGRMAP
color.rgb=result.rgb;
#else
color.rgb=result.bgr;
#endif
return color;}
#endif
#ifdef TONEMAPPING_ACES
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)
);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 ACESFitted(vec3 color)
{color=ACESInputMat*color;color=RRTAndODTFit(color);color=ACESOutputMat*color;color=saturate(color);return color;}
#endif
#define CUSTOM_IMAGEPROCESSINGFUNCTIONS_DEFINITIONS
vec4 applyImageProcessing(vec4 result) {
#define CUSTOM_IMAGEPROCESSINGFUNCTIONS_UPDATERESULT_ATSTART
#ifdef EXPOSURE
result.rgb*=exposureLinear;
#endif
#ifdef VIGNETTE
vec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize;viewportXY=viewportXY*2.0-1.0;vec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0);float vignetteTerm=dot(vignetteXY1,vignetteXY1);float vignette=pow(vignetteTerm,vignetteSettings2.w);vec3 vignetteColor=vignetteSettings2.rgb;
#ifdef VIGNETTEBLENDMODEMULTIPLY
vec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);result.rgb*=vignetteColorMultiplier;
#endif
#ifdef VIGNETTEBLENDMODEOPAQUE
result.rgb=mix(vignetteColor,result.rgb,vignette);
#endif
#endif
#ifdef TONEMAPPING
#ifdef TONEMAPPING_ACES
result.rgb=ACESFitted(result.rgb);
#else
const float tonemappingCalibration=1.590579;result.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);
#endif
#endif
result.rgb=toGammaSpace(result.rgb);result.rgb=saturate(result.rgb);
#ifdef CONTRAST
vec3 resultHighContrast=result.rgb*result.rgb*(3.0-2.0*result.rgb);if (contrast<1.0) {result.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);} else {result.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);}
#endif
#ifdef COLORGRADING
vec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;
#ifdef COLORGRADING3D
vec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb;
#else
vec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb;
#endif
result.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);
#endif
#ifdef COLORCURVES
float luma=getLuminance(result.rgb);vec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0));vec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;result.rgb*=colorCurve.rgb;result.rgb=mix(vec3(luma),result.rgb,colorCurve.a);
#endif
#ifdef DITHER
float rand=getRand(gl_FragCoord.xy*vInverseScreenSize);float dither=mix(-ditherIntensity,ditherIntensity,rand);result.rgb=saturate(result.rgb+vec3(dither));
#endif
#define CUSTOM_IMAGEPROCESSINGFUNCTIONS_UPDATERESULT_ATEND
return result;}`, re.IncludesShadersStore.bumpFragmentMainFunctions = `#if defined(BUMP) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) || defined(DETAIL)
#if defined(TANGENT) && defined(NORMAL) 
varying mat3 vTBN;
#endif
#ifdef OBJECTSPACE_NORMALMAP
uniform mat4 normalMatrix;
#if defined(WEBGL2) || defined(WEBGPU)
mat4 toNormalMatrix(mat4 wMatrix)
{mat4 ret=inverse(wMatrix);ret=transpose(ret);ret[0][3]=0.;ret[1][3]=0.;ret[2][3]=0.;ret[3]=vec4(0.,0.,0.,1.);return ret;}
#else
mat4 toNormalMatrix(mat4 m)
{float
a00=m[0][0],a01=m[0][1],a02=m[0][2],a03=m[0][3],
a10=m[1][0],a11=m[1][1],a12=m[1][2],a13=m[1][3],
a20=m[2][0],a21=m[2][1],a22=m[2][2],a23=m[2][3],
a30=m[3][0],a31=m[3][1],a32=m[3][2],a33=m[3][3],
b00=a00*a11-a01*a10,
b01=a00*a12-a02*a10,
b02=a00*a13-a03*a10,
b03=a01*a12-a02*a11,
b04=a01*a13-a03*a11,
b05=a02*a13-a03*a12,
b06=a20*a31-a21*a30,
b07=a20*a32-a22*a30,
b08=a20*a33-a23*a30,
b09=a21*a32-a22*a31,
b10=a21*a33-a23*a31,
b11=a22*a33-a23*a32,
det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;mat4 mi=mat4(
a11*b11-a12*b10+a13*b09,
a02*b10-a01*b11-a03*b09,
a31*b05-a32*b04+a33*b03,
a22*b04-a21*b05-a23*b03,
a12*b08-a10*b11-a13*b07,
a00*b11-a02*b08+a03*b07,
a32*b02-a30*b05-a33*b01,
a20*b05-a22*b02+a23*b01,
a10*b10-a11*b08+a13*b06,
a01*b08-a00*b10-a03*b06,
a30*b04-a31*b02+a33*b00,
a21*b02-a20*b04-a23*b00,
a11*b07-a10*b09-a12*b06,
a00*b09-a01*b07+a02*b06,
a31*b01-a30*b03-a32*b00,
a20*b03-a21*b01+a22*b00)/det;return mat4(mi[0][0],mi[1][0],mi[2][0],mi[3][0],
mi[0][1],mi[1][1],mi[2][1],mi[3][1],
mi[0][2],mi[1][2],mi[2][2],mi[3][2],
mi[0][3],mi[1][3],mi[2][3],mi[3][3]);}
#endif
#endif
vec3 perturbNormalBase(mat3 cotangentFrame,vec3 normal,float scale)
{
#ifdef NORMALXYSCALE
normal=normalize(normal*vec3(scale,scale,1.0));
#endif
return normalize(cotangentFrame*normal);}
vec3 perturbNormal(mat3 cotangentFrame,vec3 textureSample,float scale)
{return perturbNormalBase(cotangentFrame,textureSample*2.0-1.0,scale);}
mat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv,vec2 tangentSpaceParams)
{vec3 dp1=dFdx(p);vec3 dp2=dFdy(p);vec2 duv1=dFdx(uv);vec2 duv2=dFdy(uv);vec3 dp2perp=cross(dp2,normal);vec3 dp1perp=cross(normal,dp1);vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;vec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;tangent*=tangentSpaceParams.x;bitangent*=tangentSpaceParams.y;float det=max(dot(tangent,tangent),dot(bitangent,bitangent));float invmax=det==0.0 ? 0.0 : inversesqrt(det);return mat3(tangent*invmax,bitangent*invmax,normal);}
#endif
`, re.IncludesShadersStore.bumpFragmentFunctions = `#if defined(BUMP)
#include<samplerFragmentDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump)
#endif
#if defined(DETAIL)
#include<samplerFragmentDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_SAMPLERNAME_,detail)
#endif
#if defined(BUMP) && defined(PARALLAX)
const float minSamples=4.;const float maxSamples=15.;const int iMaxSamples=15;vec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {float parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;parallaxLimit*=parallaxScale;vec2 vOffsetDir=normalize(vViewDirCoT.xy);vec2 vMaxOffset=vOffsetDir*parallaxLimit;float numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));float stepSize=1.0/numSamples;float currRayHeight=1.0;vec2 vCurrOffset=vec2(0,0);vec2 vLastOffset=vec2(0,0);float lastSampledHeight=1.0;float currSampledHeight=1.0;bool keepWorking=true;for (int i=0; i<iMaxSamples; i++)
{currSampledHeight=texture2D(bumpSampler,texCoord+vCurrOffset).w;if (!keepWorking)
{}
else if (currSampledHeight>currRayHeight)
{float delta1=currSampledHeight-currRayHeight;float delta2=(currRayHeight+stepSize)-lastSampledHeight;float ratio=delta1/(delta1+delta2);vCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;keepWorking=false;}
else
{currRayHeight-=stepSize;vLastOffset=vCurrOffset;
#ifdef PARALLAX_RHS
vCurrOffset-=stepSize*vMaxOffset;
#else
vCurrOffset+=stepSize*vMaxOffset;
#endif
lastSampledHeight=currSampledHeight;}}
return vCurrOffset;}
vec2 parallaxOffset(vec3 viewDir,float heightScale)
{float height=texture2D(bumpSampler,vBumpUV).w;vec2 texCoordOffset=heightScale*viewDir.xy*height;
#ifdef PARALLAX_RHS
return texCoordOffset;
#else
return -texCoordOffset;
#endif
}
#endif
`, re.IncludesShadersStore.clipPlaneFragmentDeclaration = `#ifdef CLIPPLANE
varying float fClipDistance;
#endif
#ifdef CLIPPLANE2
varying float fClipDistance2;
#endif
#ifdef CLIPPLANE3
varying float fClipDistance3;
#endif
#ifdef CLIPPLANE4
varying float fClipDistance4;
#endif
#ifdef CLIPPLANE5
varying float fClipDistance5;
#endif
#ifdef CLIPPLANE6
varying float fClipDistance6;
#endif
`, re.IncludesShadersStore.logDepthDeclaration = `#ifdef LOGARITHMICDEPTH
uniform float logarithmicDepthConstant;varying float vFragmentDepth;
#endif
`, re.IncludesShadersStore.fogFragmentDeclaration = `#ifdef FOG
#define FOGMODE_NONE 0.
#define FOGMODE_EXP 1.
#define FOGMODE_EXP2 2.
#define FOGMODE_LINEAR 3.
#define E 2.71828
uniform vec4 vFogInfos;uniform vec3 vFogColor;varying vec3 vFogDistance;float CalcFogFactor()
{float fogCoeff=1.0;float fogStart=vFogInfos.y;float fogEnd=vFogInfos.z;float fogDensity=vFogInfos.w;float fogDistance=length(vFogDistance);if (FOGMODE_LINEAR==vFogInfos.x)
{fogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart);}
else if (FOGMODE_EXP==vFogInfos.x)
{fogCoeff=1.0/pow(E,fogDistance*fogDensity);}
else if (FOGMODE_EXP2==vFogInfos.x)
{fogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity);}
return clamp(fogCoeff,0.0,1.0);}
#endif
`, re.IncludesShadersStore.clipPlaneFragment = `#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
if (false) {}
#endif
#ifdef CLIPPLANE
else if (fClipDistance>0.0)
{discard;}
#endif
#ifdef CLIPPLANE2
else if (fClipDistance2>0.0)
{discard;}
#endif
#ifdef CLIPPLANE3
else if (fClipDistance3>0.0)
{discard;}
#endif
#ifdef CLIPPLANE4
else if (fClipDistance4>0.0)
{discard;}
#endif
#ifdef CLIPPLANE5
else if (fClipDistance5>0.0)
{discard;}
#endif
#ifdef CLIPPLANE6
else if (fClipDistance6>0.0)
{discard;}
#endif
`, re.IncludesShadersStore.bumpFragment = `vec2 uvOffset=vec2(0.0,0.0);
#if defined(BUMP) || defined(PARALLAX) || defined(DETAIL)
#ifdef NORMALXYSCALE
float normalScale=1.0;
#elif defined(BUMP)
float normalScale=vBumpInfos.y;
#else
float normalScale=1.0;
#endif
#if defined(TANGENT) && defined(NORMAL)
mat3 TBN=vTBN;
#elif defined(BUMP)
vec2 TBNUV=gl_FrontFacing ? vBumpUV : -vBumpUV;mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vTangentSpaceParams);
#else
vec2 TBNUV=gl_FrontFacing ? vDetailUV : -vDetailUV;mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vec2(1.,1.));
#endif
#elif defined(ANISOTROPIC)
#if defined(TANGENT) && defined(NORMAL)
mat3 TBN=vTBN;
#else
vec2 TBNUV=gl_FrontFacing ? vMainUV1 : -vMainUV1;mat3 TBN=cotangent_frame(normalW,vPositionW,TBNUV,vec2(1.,1.));
#endif
#endif
#ifdef PARALLAX
mat3 invTBN=transposeMat3(TBN);
#ifdef PARALLAXOCCLUSION
uvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z);
#else
uvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);
#endif
#endif
#ifdef DETAIL
vec4 detailColor=texture2D(detailSampler,vDetailUV+uvOffset);vec2 detailNormalRG=detailColor.wy*2.0-1.0;float detailNormalB=sqrt(1.-saturate(dot(detailNormalRG,detailNormalRG)));vec3 detailNormal=vec3(detailNormalRG,detailNormalB);
#endif
#ifdef BUMP
#ifdef OBJECTSPACE_NORMALMAP
#define CUSTOM_FRAGMENT_BUMP_FRAGMENT
normalW=normalize(texture2D(bumpSampler,vBumpUV).xyz *2.0-1.0);normalW=normalize(mat3(normalMatrix)*normalW);
#elif !defined(DETAIL)
normalW=perturbNormal(TBN,texture2D(bumpSampler,vBumpUV+uvOffset).xyz,vBumpInfos.y);
#else
vec3 bumpNormal=texture2D(bumpSampler,vBumpUV+uvOffset).xyz*2.0-1.0;
#if DETAIL_NORMALBLENDMETHOD==0 
detailNormal.xy*=vDetailInfos.z;vec3 blendedNormal=normalize(vec3(bumpNormal.xy+detailNormal.xy,bumpNormal.z*detailNormal.z));
#elif DETAIL_NORMALBLENDMETHOD==1 
detailNormal.xy*=vDetailInfos.z;bumpNormal+=vec3(0.0,0.0,1.0);detailNormal*=vec3(-1.0,-1.0,1.0);vec3 blendedNormal=bumpNormal*dot(bumpNormal,detailNormal)/bumpNormal.z-detailNormal;
#endif
normalW=perturbNormalBase(TBN,blendedNormal,vBumpInfos.y);
#endif
#elif defined(DETAIL)
detailNormal.xy*=vDetailInfos.z;normalW=perturbNormalBase(TBN,detailNormal,vDetailInfos.z);
#endif
`, re.IncludesShadersStore.decalFragment = `#ifdef DECAL
#ifdef GAMMADECAL
decalColor.rgb=toLinearSpace(decalColor.rgb);
#endif
#ifdef DECAL_SMOOTHALPHA
decalColor.a*=decalColor.a;
#endif
surfaceAlbedo.rgb=mix(surfaceAlbedo.rgb,decalColor.rgb,decalColor.a);
#endif
`, re.IncludesShadersStore.depthPrePass = `#ifdef DEPTHPREPASS
gl_FragColor=vec4(0.,0.,0.,1.0);return;
#endif
`, re.IncludesShadersStore.lightFragment = `#ifdef LIGHT{X}
#if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})
#else
#ifdef PBR
#ifdef SPOTLIGHT{X}
preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
#elif defined(POINTLIGHT{X})
preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
#elif defined(HEMILIGHT{X})
preInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
#elif defined(DIRLIGHT{X})
preInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
#endif
preInfo.NdotV=NdotV;
#ifdef SPOTLIGHT{X}
#ifdef LIGHT_FALLOFF_GLTF{X}
preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);preInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
#elif defined(LIGHT_FALLOFF_PHYSICAL{X})
preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);preInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w);
#elif defined(LIGHT_FALLOFF_STANDARD{X})
preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);preInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w);
#else
preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);preInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
#endif
#elif defined(POINTLIGHT{X})
#ifdef LIGHT_FALLOFF_GLTF{X}
preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);
#elif defined(LIGHT_FALLOFF_PHYSICAL{X})
preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);
#elif defined(LIGHT_FALLOFF_STANDARD{X})
preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);
#else
preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
#endif
#else
preInfo.attenuation=1.0;
#endif
#ifdef HEMILIGHT{X}
preInfo.roughness=roughness;
#else
preInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
#endif
#ifdef IRIDESCENCE
preInfo.iridescenceIntensity=iridescenceIntensity;
#endif
#ifdef HEMILIGHT{X}
info.diffuse=computeHemisphericDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb,light{X}.vLightGround);
#elif defined(SS_TRANSLUCENCY)
info.diffuse=computeDiffuseAndTransmittedLighting(preInfo,light{X}.vLightDiffuse.rgb,subSurfaceOut.transmittance);
#else
info.diffuse=computeDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb);
#endif
#ifdef SPECULARTERM
#ifdef ANISOTROPIC
info.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);
#else
info.specular=computeSpecularLighting(preInfo,normalW,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);
#endif
#endif
#ifdef SHEEN
#ifdef SHEEN_LINKWITHALBEDO
preInfo.roughness=sheenOut.sheenIntensity;
#else
#ifdef HEMILIGHT{X}
preInfo.roughness=sheenOut.sheenRoughness;
#else
preInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
#endif
#endif
info.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);
#endif
#ifdef CLEARCOAT
#ifdef HEMILIGHT{X}
preInfo.roughness=clearcoatOut.clearCoatRoughness;
#else
preInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
#endif
info.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,light{X}.vLightDiffuse.rgb);
#ifdef CLEARCOAT_TINT
absorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity);info.diffuse*=absorption;
#ifdef SPECULARTERM
info.specular*=absorption;
#endif
#endif
info.diffuse*=info.clearCoat.w;
#ifdef SPECULARTERM
info.specular*=info.clearCoat.w;
#endif
#ifdef SHEEN
info.sheen*=info.clearCoat.w;
#endif
#endif
#else
#ifdef SPOTLIGHT{X}
info=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightDiffuse.a,glossiness);
#elif defined(HEMILIGHT{X})
info=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightGround,glossiness);
#elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})
info=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightDiffuse.a,glossiness);
#endif
#endif
#ifdef PROJECTEDLIGHTTEXTURE{X}
info.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightSampler{X},textureProjectionMatrix{X});
#endif
#endif
#ifdef SHADOW{X}
#ifdef SHADOWCSM{X}
for (int i=0; i<SHADOWCSMNUM_CASCADES{X}; i++) 
{
#ifdef SHADOWCSM_RIGHTHANDED{X}
diff{X}=viewFrustumZ{X}[i]+vPositionFromCamera{X}.z;
#else
diff{X}=viewFrustumZ{X}[i]-vPositionFromCamera{X}.z;
#endif
if (diff{X}>=0.) {index{X}=i;break;}}
#ifdef SHADOWCSMUSESHADOWMAXZ{X}
if (index{X}>=0)
#endif
{
#if defined(SHADOWPCF{X})
#if defined(SHADOWLOWQUALITY{X})
shadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#elif defined(SHADOWMEDIUMQUALITY{X})
shadow=computeShadowWithCSMPCF3(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#else
shadow=computeShadowWithCSMPCF5(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#endif
#elif defined(SHADOWPCSS{X})
#if defined(SHADOWLOWQUALITY{X})
shadow=computeShadowWithCSMPCSS16(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
#elif defined(SHADOWMEDIUMQUALITY{X})
shadow=computeShadowWithCSMPCSS32(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
#else
shadow=computeShadowWithCSMPCSS64(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
#endif
#else
shadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#endif
#ifdef SHADOWCSMDEBUG{X}
shadowDebug{X}=vec3(shadow)*vCascadeColorsMultiplier{X}[index{X}];
#endif
#ifndef SHADOWCSMNOBLEND{X}
float frustumLength=frustumLengths{X}[index{X}];float diffRatio=clamp(diff{X}/frustumLength,0.,1.)*cascadeBlendFactor{X};if (index{X}<(SHADOWCSMNUM_CASCADES{X}-1) && diffRatio<1.)
{index{X}+=1;float nextShadow=0.;
#if defined(SHADOWPCF{X})
#if defined(SHADOWLOWQUALITY{X})
nextShadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#elif defined(SHADOWMEDIUMQUALITY{X})
nextShadow=computeShadowWithCSMPCF3(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#else
nextShadow=computeShadowWithCSMPCF5(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#endif
#elif defined(SHADOWPCSS{X})
#if defined(SHADOWLOWQUALITY{X})
nextShadow=computeShadowWithCSMPCSS16(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
#elif defined(SHADOWMEDIUMQUALITY{X})
nextShadow=computeShadowWithCSMPCSS32(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
#else
nextShadow=computeShadowWithCSMPCSS64(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
#endif
#else
nextShadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#endif
shadow=mix(nextShadow,shadow,diffRatio);
#ifdef SHADOWCSMDEBUG{X}
shadowDebug{X}=mix(vec3(nextShadow)*vCascadeColorsMultiplier{X}[index{X}],shadowDebug{X},diffRatio);
#endif
}
#endif
}
#elif defined(SHADOWCLOSEESM{X})
#if defined(SHADOWCUBE{X})
shadow=computeShadowWithCloseESMCube(vPositionW,light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);
#else
shadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);
#endif
#elif defined(SHADOWESM{X})
#if defined(SHADOWCUBE{X})
shadow=computeShadowWithESMCube(vPositionW,light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);
#else
shadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);
#endif
#elif defined(SHADOWPOISSON{X})
#if defined(SHADOWCUBE{X})
shadow=computeShadowWithPoissonSamplingCube(vPositionW,light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);
#else
shadow=computeShadowWithPoissonSampling(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#endif
#elif defined(SHADOWPCF{X})
#if defined(SHADOWLOWQUALITY{X})
shadow=computeShadowWithPCF1(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#elif defined(SHADOWMEDIUMQUALITY{X})
shadow=computeShadowWithPCF3(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#else
shadow=computeShadowWithPCF5(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#endif
#elif defined(SHADOWPCSS{X})
#if defined(SHADOWLOWQUALITY{X})
shadow=computeShadowWithPCSS16(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#elif defined(SHADOWMEDIUMQUALITY{X})
shadow=computeShadowWithPCSS32(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#else
shadow=computeShadowWithPCSS64(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#endif
#else
#if defined(SHADOWCUBE{X})
shadow=computeShadowCube(vPositionW,light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.depthValues);
#else
shadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#endif
#endif
#ifdef SHADOWONLY
#ifndef SHADOWINUSE
#define SHADOWINUSE
#endif
globalShadow+=shadow;shadowLightCount+=1.0;
#endif
#else
shadow=1.;
#endif
aggShadow+=shadow;numLights+=1.0;
#ifndef SHADOWONLY
#ifdef CUSTOMUSERLIGHTING
diffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);
#ifdef SPECULARTERM
specularBase+=computeCustomSpecularLighting(info,specularBase,shadow);
#endif
#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})
diffuseBase+=lightmapColor.rgb*shadow;
#ifdef SPECULARTERM
#ifndef LIGHTMAPNOSPECULAR{X}
specularBase+=info.specular*shadow*lightmapColor.rgb;
#endif
#endif
#ifdef CLEARCOAT
#ifndef LIGHTMAPNOSPECULAR{X}
clearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor.rgb;
#endif
#endif
#ifdef SHEEN
#ifndef LIGHTMAPNOSPECULAR{X}
sheenBase+=info.sheen.rgb*shadow;
#endif
#endif
#else
#ifdef SHADOWCSMDEBUG{X}
diffuseBase+=info.diffuse*shadowDebug{X};
#else 
diffuseBase+=info.diffuse*shadow;
#endif
#ifdef SPECULARTERM
specularBase+=info.specular*shadow;
#endif
#ifdef CLEARCOAT
clearCoatBase+=info.clearCoat.rgb*shadow;
#endif
#ifdef SHEEN
sheenBase+=info.sheen.rgb*shadow;
#endif
#endif
#endif
#endif
`, re.IncludesShadersStore.logDepthFragment = `#ifdef LOGARITHMICDEPTH
gl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;
#endif
`, re.IncludesShadersStore.fogFragment = `#ifdef FOG
float fog=CalcFogFactor();
#ifdef PBR
fog=toLinearSpace(fog);
#endif
color.rgb=mix(vFogColor,color.rgb,fog);
#endif
`, re.IncludesShadersStore.oitFragment = `#ifdef ORDER_INDEPENDENT_TRANSPARENCY
float fragDepth=gl_FragCoord.z; 
#ifdef ORDER_INDEPENDENT_TRANSPARENCY_16BITS
uint halfFloat=packHalf2x16(vec2(fragDepth));vec2 full=unpackHalf2x16(halfFloat);fragDepth=full.x;
#endif
ivec2 fragCoord=ivec2(gl_FragCoord.xy);vec2 lastDepth=texelFetch(oitDepthSampler,fragCoord,0).rg;vec4 lastFrontColor=texelFetch(oitFrontColorSampler,fragCoord,0);depth.rg=vec2(-MAX_DEPTH);frontColor=lastFrontColor;backColor=vec4(0.0);
#ifdef USE_REVERSE_DEPTHBUFFER
float furthestDepth=-lastDepth.x;float nearestDepth=lastDepth.y;
#else
float nearestDepth=-lastDepth.x;float furthestDepth=lastDepth.y;
#endif
float alphaMultiplier=1.0-lastFrontColor.a;
#ifdef USE_REVERSE_DEPTHBUFFER
if (fragDepth>nearestDepth || fragDepth<furthestDepth) {
#else
if (fragDepth<nearestDepth || fragDepth>furthestDepth) {
#endif
return;}
#ifdef USE_REVERSE_DEPTHBUFFER
if (fragDepth<nearestDepth && fragDepth>furthestDepth) {
#else
if (fragDepth>nearestDepth && fragDepth<furthestDepth) {
#endif
depth.rg=vec2(-fragDepth,fragDepth);return;}
#endif
`, re.ShadersStore.defaultPixelShader = `#include<__decl__defaultFragment>
#if defined(BUMP) || !defined(NORMAL)
#extension GL_OES_standard_derivatives : enable
#endif
#include<prePassDeclaration>[SCENE_MRT_COUNT]
#include<oitDeclaration>
#define CUSTOM_FRAGMENT_BEGIN
#ifdef LOGARITHMICDEPTH
#extension GL_EXT_frag_depth : enable
#endif
varying vec3 vPositionW;
#ifdef NORMAL
varying vec3 vNormalW;
#endif
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
varying vec4 vColor;
#endif
#include<mainUVVaryingDeclaration>[1..7]
#include<helperFunctions>
#include<__decl__lightFragment>[0..maxSimultaneousLights]
#include<lightsFragmentFunctions>
#include<shadowsFragmentFunctions>
#include<samplerFragmentDeclaration>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_SAMPLERNAME_,diffuse)
#include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)
#include<samplerFragmentDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)
#include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)
#include<samplerFragmentDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)
#include<samplerFragmentDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal)
#ifdef REFRACTION
#ifdef REFRACTIONMAP_3D
uniform samplerCube refractionCubeSampler;
#else
uniform sampler2D refraction2DSampler;
#endif
#endif
#if defined(SPECULARTERM)
#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_SAMPLERNAME_,specular)
#endif
#include<fresnelFunction>
#ifdef REFLECTION
#ifdef REFLECTIONMAP_3D
uniform samplerCube reflectionCubeSampler;
#else
uniform sampler2D reflection2DSampler;
#endif
#ifdef REFLECTIONMAP_SKYBOX
varying vec3 vPositionUVW;
#else
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
varying vec3 vDirectionW;
#endif
#endif
#include<reflectionFunction>
#endif
#include<imageProcessingDeclaration>
#include<imageProcessingFunctions>
#include<bumpFragmentMainFunctions>
#include<bumpFragmentFunctions>
#include<clipPlaneFragmentDeclaration>
#include<logDepthDeclaration>
#include<fogFragmentDeclaration>
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void) {
#define CUSTOM_FRAGMENT_MAIN_BEGIN
#include<clipPlaneFragment>
vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=vec4(1.,1.,1.,1.);vec3 diffuseColor=vDiffuseColor.rgb;float alpha=vDiffuseColor.a;
#ifdef NORMAL
vec3 normalW=normalize(vNormalW);
#else
vec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));
#endif
#include<bumpFragment>
#ifdef TWOSIDEDLIGHTING
normalW=gl_FrontFacing ? normalW : -normalW;
#endif
#ifdef DIFFUSE
baseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);
#if defined(ALPHATEST) && !defined(ALPHATEST_AFTERALLALPHACOMPUTATIONS)
if (baseColor.a<alphaCutOff)
discard;
#endif
#ifdef ALPHAFROMDIFFUSE
alpha*=baseColor.a;
#endif
#define CUSTOM_FRAGMENT_UPDATE_ALPHA
baseColor.rgb*=vDiffuseInfos.y;
#endif
#if defined(DECAL) && !defined(DECAL_AFTER_DETAIL)
vec4 decalColor=texture2D(decalSampler,vDecalUV+uvOffset);
#include<decalFragment>(surfaceAlbedo,baseColor,GAMMADECAL,_GAMMADECAL_NOTUSED_)
#endif
#include<depthPrePass>
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
baseColor.rgb*=vColor.rgb;
#endif
#ifdef DETAIL
baseColor.rgb=baseColor.rgb*2.0*mix(0.5,detailColor.r,vDetailInfos.y);
#endif
#if defined(DECAL) && defined(DECAL_AFTER_DETAIL)
vec4 decalColor=texture2D(decalSampler,vDecalUV+uvOffset);
#include<decalFragment>(surfaceAlbedo,baseColor,GAMMADECAL,_GAMMADECAL_NOTUSED_)
#endif
#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE
vec3 baseAmbientColor=vec3(1.,1.,1.);
#ifdef AMBIENT
baseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;
#endif
#define CUSTOM_FRAGMENT_BEFORE_LIGHTS
#ifdef SPECULARTERM
float glossiness=vSpecularColor.a;vec3 specularColor=vSpecularColor.rgb;
#ifdef SPECULAR
vec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);specularColor=specularMapColor.rgb;
#ifdef GLOSSINESS
glossiness=glossiness*specularMapColor.a;
#endif
#endif
#else
float glossiness=0.;
#endif
vec3 diffuseBase=vec3(0.,0.,0.);lightingInfo info;
#ifdef SPECULARTERM
vec3 specularBase=vec3(0.,0.,0.);
#endif
float shadow=1.;float aggShadow=0.;float numLights=0.;
#ifdef LIGHTMAP
vec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset);
#ifdef RGBDLIGHTMAP
lightmapColor.rgb=fromRGBD(lightmapColor);
#endif
lightmapColor.rgb*=vLightmapInfos.y;
#endif
#include<lightFragment>[0..maxSimultaneousLights]
aggShadow=aggShadow/numLights;vec4 refractionColor=vec4(0.,0.,0.,1.);
#ifdef REFRACTION
vec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));
#ifdef REFRACTIONMAP_3D
#ifdef USE_LOCAL_REFRACTIONMAP_CUBIC
refractionVector=parallaxCorrectNormal(vPositionW,refractionVector,vRefractionSize,vRefractionPosition);
#endif
refractionVector.y=refractionVector.y*vRefractionInfos.w;vec4 refractionLookup=textureCube(refractionCubeSampler,refractionVector);if (dot(refractionVector,viewDirectionW)<1.0) {refractionColor=refractionLookup;}
#else
vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));vec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;refractionCoords.y=1.0-refractionCoords.y;refractionColor=texture2D(refraction2DSampler,refractionCoords);
#endif
#ifdef RGBDREFRACTION
refractionColor.rgb=fromRGBD(refractionColor);
#endif
#ifdef IS_REFRACTION_LINEAR
refractionColor.rgb=toGammaSpace(refractionColor.rgb);
#endif
refractionColor.rgb*=vRefractionInfos.x;
#endif
vec4 reflectionColor=vec4(0.,0.,0.,1.);
#ifdef REFLECTION
vec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);
#ifdef REFLECTIONMAP_OPPOSITEZ
vReflectionUVW.z*=-1.0;
#endif
#ifdef REFLECTIONMAP_3D
#ifdef ROUGHNESS
float bias=vReflectionInfos.y;
#ifdef SPECULARTERM
#ifdef SPECULAR
#ifdef GLOSSINESS
bias*=(1.0-specularMapColor.a);
#endif
#endif
#endif
reflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias);
#else
reflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW);
#endif
#else
vec2 coords=vReflectionUVW.xy;
#ifdef REFLECTIONMAP_PROJECTION
coords/=vReflectionUVW.z;
#endif
coords.y=1.0-coords.y;reflectionColor=texture2D(reflection2DSampler,coords);
#endif
#ifdef RGBDREFLECTION
reflectionColor.rgb=fromRGBD(reflectionColor);
#endif
#ifdef IS_REFLECTION_LINEAR
reflectionColor.rgb=toGammaSpace(reflectionColor.rgb);
#endif
reflectionColor.rgb*=vReflectionInfos.x;
#ifdef REFLECTIONFRESNEL
float reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);
#ifdef REFLECTIONFRESNELFROMSPECULAR
#ifdef SPECULARTERM
reflectionColor.rgb*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;
#else
reflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;
#endif
#else
reflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;
#endif
#endif
#endif
#ifdef REFRACTIONFRESNEL
float refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);refractionColor.rgb*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;
#endif
#ifdef OPACITY
vec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);
#ifdef OPACITYRGB
opacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);alpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;
#else
alpha*=opacityMap.a*vOpacityInfos.y;
#endif
#endif
#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)
alpha*=vColor.a;
#endif
#ifdef OPACITYFRESNEL
float opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);alpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;
#endif
#ifdef ALPHATEST
#ifdef ALPHATEST_AFTERALLALPHACOMPUTATIONS
if (alpha<alphaCutOff)
discard;
#endif
#ifndef ALPHABLEND
alpha=1.0;
#endif
#endif
vec3 emissiveColor=vEmissiveColor;
#ifdef EMISSIVE
emissiveColor+=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y;
#endif
#ifdef EMISSIVEFRESNEL
float emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);emissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;
#endif
#ifdef DIFFUSEFRESNEL
float diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);diffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;
#endif
#ifdef EMISSIVEASILLUMINATION
vec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;
#else
#ifdef LINKEMISSIVEWITHDIFFUSE
vec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;
#else
vec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;
#endif
#endif
#ifdef SPECULARTERM
vec3 finalSpecular=specularBase*specularColor;
#ifdef SPECULAROVERALPHA
alpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);
#endif
#else
vec3 finalSpecular=vec3(0.0);
#endif
#ifdef REFLECTIONOVERALPHA
alpha=clamp(alpha+dot(reflectionColor.rgb,vec3(0.3,0.59,0.11)),0.,1.);
#endif
#ifdef EMISSIVEASILLUMINATION
vec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+emissiveColor+refractionColor.rgb,0.0,1.0),alpha);
#else
vec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+refractionColor.rgb,alpha);
#endif
#ifdef LIGHTMAP
#ifndef LIGHTMAPEXCLUDED
#ifdef USELIGHTMAPASSHADOWMAP
color.rgb*=lightmapColor.rgb;
#else
color.rgb+=lightmapColor.rgb;
#endif
#endif
#endif
#define CUSTOM_FRAGMENT_BEFORE_FOG
color.rgb=max(color.rgb,0.);
#include<logDepthFragment>
#include<fogFragment>
#ifdef IMAGEPROCESSINGPOSTPROCESS
color.rgb=toLinearSpace(color.rgb);
#else
#ifdef IMAGEPROCESSING
color.rgb=toLinearSpace(color.rgb);color=applyImageProcessing(color);
#endif
#endif
color.a*=visibility;
#ifdef PREMULTIPLYALPHA
color.rgb*=color.a;
#endif
#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
#ifdef PREPASS
float writeGeometryInfo=color.a>0.4 ? 1.0 : 0.0;gl_FragData[0]=color; 
#ifdef PREPASS_POSITION
gl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo);
#endif
#ifdef PREPASS_VELOCITY
vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;vec2 velocity=abs(a-b);velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;gl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,writeGeometryInfo);
#endif
#ifdef PREPASS_IRRADIANCE
gl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo); 
#endif
#ifdef PREPASS_DEPTH
gl_FragData[PREPASS_DEPTH_INDEX]=vec4(vViewPos.z,0.0,0.0,writeGeometryInfo); 
#endif
#ifdef PREPASS_NORMAL
#ifdef PREPASS_NORMAL_WORLDSPACE
gl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalW,writeGeometryInfo); 
#else
gl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalize((view*vec4(normalW,0.0)).rgb),writeGeometryInfo); 
#endif
#endif
#ifdef PREPASS_ALBEDO_SQRT
gl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo); 
#endif
#ifdef PREPASS_REFLECTIVITY
#if defined(SPECULARTERM)
#if defined(SPECULAR)
gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(toLinearSpace(specularMapColor))*writeGeometryInfo; 
#else
gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(toLinearSpace(specularColor),1.0)*writeGeometryInfo;
#endif
#else
gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(0.0,0.0,0.0,1.0)*writeGeometryInfo;
#endif
#endif
#endif
#if !defined(PREPASS) || defined(WEBGL2)
gl_FragColor=color;
#endif
#include<oitFragment>
#if ORDER_INDEPENDENT_TRANSPARENCY
if (fragDepth==nearestDepth) {frontColor.rgb+=color.rgb*color.a*alphaMultiplier;frontColor.a=1.0-alphaMultiplier*(1.0-color.a);} else {backColor+=color;}
#endif
#define CUSTOM_FRAGMENT_MAIN_END
}
`, re.IncludesShadersStore.decalVertexDeclaration = `#ifdef DECAL
uniform vec4 vDecalInfos;uniform mat4 decalMatrix;
#endif
`, re.IncludesShadersStore.defaultVertexDeclaration = `uniform mat4 viewProjection;uniform mat4 view;
#ifdef DIFFUSE
uniform mat4 diffuseMatrix;uniform vec2 vDiffuseInfos;
#endif
#ifdef AMBIENT
uniform mat4 ambientMatrix;uniform vec2 vAmbientInfos;
#endif
#ifdef OPACITY
uniform mat4 opacityMatrix;uniform vec2 vOpacityInfos;
#endif
#ifdef EMISSIVE
uniform vec2 vEmissiveInfos;uniform mat4 emissiveMatrix;
#endif
#ifdef LIGHTMAP
uniform vec2 vLightmapInfos;uniform mat4 lightmapMatrix;
#endif
#if defined(SPECULAR) && defined(SPECULARTERM)
uniform vec2 vSpecularInfos;uniform mat4 specularMatrix;
#endif
#ifdef BUMP
uniform vec3 vBumpInfos;uniform mat4 bumpMatrix;
#endif
#ifdef REFLECTION
uniform mat4 reflectionMatrix;
#endif
#ifdef POINTSIZE
uniform float pointSize;
#endif
#ifdef DETAIL
uniform vec4 vDetailInfos;uniform mat4 detailMatrix;
#endif
#include<decalVertexDeclaration>
#define ADDITIONAL_VERTEX_DECLARATION
`, re.IncludesShadersStore.uvAttributeDeclaration = `#ifdef UV{X}
attribute vec2 uv{X};
#endif
`, re.IncludesShadersStore.bonesDeclaration = `#if NUM_BONE_INFLUENCERS>0
attribute vec4 matricesIndices;attribute vec4 matricesWeights;
#if NUM_BONE_INFLUENCERS>4
attribute vec4 matricesIndicesExtra;attribute vec4 matricesWeightsExtra;
#endif
#ifndef BAKED_VERTEX_ANIMATION_TEXTURE
#ifdef BONETEXTURE
uniform highp sampler2D boneSampler;uniform float boneTextureWidth;
#else
uniform mat4 mBones[BonesPerMesh];
#endif
#ifdef BONES_VELOCITY_ENABLED
uniform mat4 mPreviousBones[BonesPerMesh];
#endif
#ifdef BONETEXTURE
#define inline
mat4 readMatrixFromRawSampler(sampler2D smp,float index)
{float offset=index *4.0;float dx=1.0/boneTextureWidth;vec4 m0=texture2D(smp,vec2(dx*(offset+0.5),0.));vec4 m1=texture2D(smp,vec2(dx*(offset+1.5),0.));vec4 m2=texture2D(smp,vec2(dx*(offset+2.5),0.));vec4 m3=texture2D(smp,vec2(dx*(offset+3.5),0.));return mat4(m0,m1,m2,m3);}
#endif
#endif
#endif
`, re.IncludesShadersStore.bakedVertexAnimationDeclaration = `#ifdef BAKED_VERTEX_ANIMATION_TEXTURE
uniform float bakedVertexAnimationTime;uniform vec2 bakedVertexAnimationTextureSizeInverted;uniform vec4 bakedVertexAnimationSettings;uniform sampler2D bakedVertexAnimationTexture;
#ifdef INSTANCES
attribute vec4 bakedVertexAnimationSettingsInstanced;
#endif
#define inline
mat4 readMatrixFromRawSamplerVAT(sampler2D smp,float index,float frame)
{float offset=index*4.0;float frameUV=(frame+0.5)*bakedVertexAnimationTextureSizeInverted.y;float dx=bakedVertexAnimationTextureSizeInverted.x;vec4 m0=texture2D(smp,vec2(dx*(offset+0.5),frameUV));vec4 m1=texture2D(smp,vec2(dx*(offset+1.5),frameUV));vec4 m2=texture2D(smp,vec2(dx*(offset+2.5),frameUV));vec4 m3=texture2D(smp,vec2(dx*(offset+3.5),frameUV));return mat4(m0,m1,m2,m3);}
#endif
`, re.IncludesShadersStore.instancesDeclaration = `#ifdef INSTANCES
attribute vec4 world0;attribute vec4 world1;attribute vec4 world2;attribute vec4 world3;
#ifdef INSTANCESCOLOR
attribute vec4 instanceColor;
#endif
#if defined(THIN_INSTANCES) && !defined(WORLD_UBO)
uniform mat4 world;
#endif
#if defined(VELOCITY) || defined(PREPASS_VELOCITY)
attribute vec4 previousWorld0;attribute vec4 previousWorld1;attribute vec4 previousWorld2;attribute vec4 previousWorld3;
#ifdef THIN_INSTANCES
uniform mat4 previousWorld;
#endif
#endif
#else
#if !defined(WORLD_UBO)
uniform mat4 world;
#endif
#if defined(VELOCITY) || defined(PREPASS_VELOCITY)
uniform mat4 previousWorld;
#endif
#endif
`, re.IncludesShadersStore.prePassVertexDeclaration = `#ifdef PREPASS
#ifdef PREPASS_DEPTH
varying vec3 vViewPos;
#endif
#ifdef PREPASS_VELOCITY
uniform mat4 previousViewProjection;varying vec4 vCurrentPosition;varying vec4 vPreviousPosition;
#endif
#endif
`, re.IncludesShadersStore.samplerVertexDeclaration = `#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0
varying vec2 v_VARYINGNAME_UV;
#endif
`, re.IncludesShadersStore.bumpVertexDeclaration = `#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)
#if defined(TANGENT) && defined(NORMAL) 
varying mat3 vTBN;
#endif
#endif
`, re.IncludesShadersStore.clipPlaneVertexDeclaration = `#ifdef CLIPPLANE
uniform vec4 vClipPlane;varying float fClipDistance;
#endif
#ifdef CLIPPLANE2
uniform vec4 vClipPlane2;varying float fClipDistance2;
#endif
#ifdef CLIPPLANE3
uniform vec4 vClipPlane3;varying float fClipDistance3;
#endif
#ifdef CLIPPLANE4
uniform vec4 vClipPlane4;varying float fClipDistance4;
#endif
#ifdef CLIPPLANE5
uniform vec4 vClipPlane5;varying float fClipDistance5;
#endif
#ifdef CLIPPLANE6
uniform vec4 vClipPlane6;varying float fClipDistance6;
#endif
`, re.IncludesShadersStore.fogVertexDeclaration = `#ifdef FOG
varying vec3 vFogDistance;
#endif
`, re.IncludesShadersStore.lightVxFragmentDeclaration = `#ifdef LIGHT{X}
uniform vec4 vLightData{X};uniform vec4 vLightDiffuse{X};
#ifdef SPECULARTERM
uniform vec4 vLightSpecular{X};
#else
vec4 vLightSpecular{X}=vec4(0.);
#endif
#ifdef SHADOW{X}
#ifdef SHADOWCSM{X}
uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X};
#elif defined(SHADOWCUBE{X})
#else
varying vec4 vPositionFromLight{X};varying float vDepthMetric{X};uniform mat4 lightMatrix{X};
#endif
uniform vec4 shadowsInfo{X};uniform vec2 depthValues{X};
#endif
#ifdef SPOTLIGHT{X}
uniform vec4 vLightDirection{X};uniform vec4 vLightFalloff{X};
#elif defined(POINTLIGHT{X})
uniform vec4 vLightFalloff{X};
#elif defined(HEMILIGHT{X})
uniform vec3 vLightGround{X};
#endif
#endif
`, re.IncludesShadersStore.lightVxUboDeclaration = `#ifdef LIGHT{X}
uniform Light{X}
{vec4 vLightData;vec4 vLightDiffuse;vec4 vLightSpecular;
#ifdef SPOTLIGHT{X}
vec4 vLightDirection;vec4 vLightFalloff;
#elif defined(POINTLIGHT{X})
vec4 vLightFalloff;
#elif defined(HEMILIGHT{X})
vec3 vLightGround;
#endif
vec4 shadowsInfo;vec2 depthValues;} light{X};
#ifdef SHADOW{X}
#ifdef SHADOWCSM{X}
uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X};
#elif defined(SHADOWCUBE{X})
#else
varying vec4 vPositionFromLight{X};varying float vDepthMetric{X};uniform mat4 lightMatrix{X};
#endif
#endif
#endif
`, re.IncludesShadersStore.morphTargetsVertexGlobalDeclaration = `#ifdef MORPHTARGETS
uniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];
#ifdef MORPHTARGETS_TEXTURE 
uniform float morphTargetTextureIndices[NUM_MORPH_INFLUENCERS];uniform vec3 morphTargetTextureInfo;uniform highp sampler2DArray morphTargets;vec3 readVector3FromRawSampler(int targetIndex,float vertexIndex)
{ 
float y=floor(vertexIndex/morphTargetTextureInfo.y);float x=vertexIndex-y*morphTargetTextureInfo.y;vec3 textureUV=vec3((x+0.5)/morphTargetTextureInfo.y,(y+0.5)/morphTargetTextureInfo.z,morphTargetTextureIndices[targetIndex]);return texture(morphTargets,textureUV).xyz;}
#endif
#endif
`, re.IncludesShadersStore.morphTargetsVertexDeclaration = `#ifdef MORPHTARGETS
#ifndef MORPHTARGETS_TEXTURE
attribute vec3 position{X};
#ifdef MORPHTARGETS_NORMAL
attribute vec3 normal{X};
#endif
#ifdef MORPHTARGETS_TANGENT
attribute vec3 tangent{X};
#endif
#ifdef MORPHTARGETS_UV
attribute vec2 uv_{X};
#endif
#endif
#endif
`, re.IncludesShadersStore.morphTargetsVertexGlobal = `#ifdef MORPHTARGETS
#ifdef MORPHTARGETS_TEXTURE
float vertexID;
#endif
#endif
`, re.IncludesShadersStore.morphTargetsVertex = `#ifdef MORPHTARGETS
#ifdef MORPHTARGETS_TEXTURE 
vertexID=float(gl_VertexID)*morphTargetTextureInfo.x;positionUpdated+=(readVector3FromRawSampler({X},vertexID)-position)*morphTargetInfluences[{X}];vertexID+=1.0;
#ifdef MORPHTARGETS_NORMAL
normalUpdated+=(readVector3FromRawSampler({X},vertexID) -normal)*morphTargetInfluences[{X}];vertexID+=1.0;
#endif
#ifdef MORPHTARGETS_UV
uvUpdated+=(readVector3FromRawSampler({X},vertexID).xy-uv)*morphTargetInfluences[{X}];vertexID+=1.0;
#endif
#ifdef MORPHTARGETS_TANGENT
tangentUpdated.xyz+=(readVector3FromRawSampler({X},vertexID) -tangent.xyz)*morphTargetInfluences[{X}];
#endif
#else
positionUpdated+=(position{X}-position)*morphTargetInfluences[{X}];
#ifdef MORPHTARGETS_NORMAL
normalUpdated+=(normal{X}-normal)*morphTargetInfluences[{X}];
#endif
#ifdef MORPHTARGETS_TANGENT
tangentUpdated.xyz+=(tangent{X}-tangent.xyz)*morphTargetInfluences[{X}];
#endif
#ifdef MORPHTARGETS_UV
uvUpdated+=(uv_{X}-uv)*morphTargetInfluences[{X}];
#endif
#endif
#endif
`, re.IncludesShadersStore.instancesVertex = `#ifdef INSTANCES
mat4 finalWorld=mat4(world0,world1,world2,world3);
#if defined(PREPASS_VELOCITY) || defined(VELOCITY)
mat4 finalPreviousWorld=mat4(previousWorld0,previousWorld1,previousWorld2,previousWorld3);
#endif
#ifdef THIN_INSTANCES
finalWorld=world*finalWorld;
#if defined(PREPASS_VELOCITY) || defined(VELOCITY)
finalPreviousWorld=previousWorld*finalPreviousWorld;
#endif
#endif
#else
mat4 finalWorld=world;
#if defined(PREPASS_VELOCITY) || defined(VELOCITY)
mat4 finalPreviousWorld=previousWorld;
#endif
#endif
`, re.IncludesShadersStore.bonesVertex = `#ifndef BAKED_VERTEX_ANIMATION_TEXTURE
#if NUM_BONE_INFLUENCERS>0
mat4 influence;
#ifdef BONETEXTURE
influence=readMatrixFromRawSampler(boneSampler,matricesIndices[0])*matricesWeights[0];
#if NUM_BONE_INFLUENCERS>1
influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[1])*matricesWeights[1];
#endif
#if NUM_BONE_INFLUENCERS>2
influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[2])*matricesWeights[2];
#endif
#if NUM_BONE_INFLUENCERS>3
influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[3])*matricesWeights[3];
#endif
#if NUM_BONE_INFLUENCERS>4
influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[0])*matricesWeightsExtra[0];
#endif
#if NUM_BONE_INFLUENCERS>5
influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[1])*matricesWeightsExtra[1];
#endif
#if NUM_BONE_INFLUENCERS>6
influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[2])*matricesWeightsExtra[2];
#endif
#if NUM_BONE_INFLUENCERS>7
influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[3])*matricesWeightsExtra[3];
#endif
#else
influence=mBones[int(matricesIndices[0])]*matricesWeights[0];
#if NUM_BONE_INFLUENCERS>1
influence+=mBones[int(matricesIndices[1])]*matricesWeights[1];
#endif
#if NUM_BONE_INFLUENCERS>2
influence+=mBones[int(matricesIndices[2])]*matricesWeights[2];
#endif
#if NUM_BONE_INFLUENCERS>3
influence+=mBones[int(matricesIndices[3])]*matricesWeights[3];
#endif
#if NUM_BONE_INFLUENCERS>4
influence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];
#endif
#if NUM_BONE_INFLUENCERS>5
influence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];
#endif
#if NUM_BONE_INFLUENCERS>6
influence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];
#endif
#if NUM_BONE_INFLUENCERS>7
influence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];
#endif
#endif
finalWorld=finalWorld*influence;
#endif
#endif
`, re.IncludesShadersStore.bakedVertexAnimation = `#ifdef BAKED_VERTEX_ANIMATION_TEXTURE
{
#ifdef INSTANCES
#define BVASNAME bakedVertexAnimationSettingsInstanced
#else
#define BVASNAME bakedVertexAnimationSettings
#endif
float VATStartFrame=BVASNAME.x;float VATEndFrame=BVASNAME.y;float VATOffsetFrame=BVASNAME.z;float VATSpeed=BVASNAME.w;float totalFrames=VATEndFrame-VATStartFrame+1.0;float time=bakedVertexAnimationTime*VATSpeed/totalFrames;float frameCorrection=time<1.0 ? 0.0 : 1.0;float numOfFrames=totalFrames-frameCorrection;float VATFrameNum=fract(time)*numOfFrames;VATFrameNum=mod(VATFrameNum+VATOffsetFrame,numOfFrames);VATFrameNum=floor(VATFrameNum);VATFrameNum+=VATStartFrame+frameCorrection;mat4 VATInfluence;VATInfluence=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[0],VATFrameNum)*matricesWeights[0];
#if NUM_BONE_INFLUENCERS>1
VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[1],VATFrameNum)*matricesWeights[1];
#endif
#if NUM_BONE_INFLUENCERS>2
VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[2],VATFrameNum)*matricesWeights[2];
#endif
#if NUM_BONE_INFLUENCERS>3
VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[3],VATFrameNum)*matricesWeights[3];
#endif
#if NUM_BONE_INFLUENCERS>4
VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[0],VATFrameNum)*matricesWeightsExtra[0];
#endif
#if NUM_BONE_INFLUENCERS>5
VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[1],VATFrameNum)*matricesWeightsExtra[1];
#endif
#if NUM_BONE_INFLUENCERS>6
VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[2],VATFrameNum)*matricesWeightsExtra[2];
#endif
#if NUM_BONE_INFLUENCERS>7
VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[3],VATFrameNum)*matricesWeightsExtra[3];
#endif
finalWorld=finalWorld*VATInfluence;}
#endif
`, re.IncludesShadersStore.prePassVertex = `#ifdef PREPASS_DEPTH
vViewPos=(view*worldPos).rgb;
#endif
#if defined(PREPASS_VELOCITY) && defined(BONES_VELOCITY_ENABLED)
vCurrentPosition=viewProjection*worldPos;
#if NUM_BONE_INFLUENCERS>0
mat4 previousInfluence;previousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];
#if NUM_BONE_INFLUENCERS>1
previousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];
#endif 
#if NUM_BONE_INFLUENCERS>2
previousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];
#endif 
#if NUM_BONE_INFLUENCERS>3
previousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];
#endif
#if NUM_BONE_INFLUENCERS>4
previousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];
#endif 
#if NUM_BONE_INFLUENCERS>5
previousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];
#endif 
#if NUM_BONE_INFLUENCERS>6
previousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];
#endif 
#if NUM_BONE_INFLUENCERS>7
previousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];
#endif
vPreviousPosition=previousViewProjection*finalPreviousWorld*previousInfluence*vec4(positionUpdated,1.0);
#else
vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);
#endif
#endif
`, re.IncludesShadersStore.uvVariableDeclaration = `#if !defined(UV{X}) && defined(MAINUV{X})
vec2 uv{X}=vec2(0.,0.);
#endif
#ifdef MAINUV{X}
vMainUV{X}=uv{X};
#endif
`, re.IncludesShadersStore.samplerVertexImplementation = `#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0
if (v_INFONAME_==0.)
{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uvUpdated,1.0,0.0));}
#ifdef UV2
else if (v_INFONAME_==1.)
{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv2,1.0,0.0));}
#endif
#ifdef UV3
else if (v_INFONAME_==2.)
{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv3,1.0,0.0));}
#endif
#ifdef UV4
else if (v_INFONAME_==3.)
{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv4,1.0,0.0));}
#endif
#ifdef UV5
else if (v_INFONAME_==4.)
{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv5,1.0,0.0));}
#endif
#ifdef UV6
else if (v_INFONAME_==5.)
{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv6,1.0,0.0));}
#endif
#endif
`, re.IncludesShadersStore.bumpVertex = `#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)
#if defined(TANGENT) && defined(NORMAL)
vec3 tbnNormal=normalize(normalUpdated);vec3 tbnTangent=normalize(tangentUpdated.xyz);vec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;vTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal);
#endif
#endif
`, re.IncludesShadersStore.clipPlaneVertex = `#ifdef CLIPPLANE
fClipDistance=dot(worldPos,vClipPlane);
#endif
#ifdef CLIPPLANE2
fClipDistance2=dot(worldPos,vClipPlane2);
#endif
#ifdef CLIPPLANE3
fClipDistance3=dot(worldPos,vClipPlane3);
#endif
#ifdef CLIPPLANE4
fClipDistance4=dot(worldPos,vClipPlane4);
#endif
#ifdef CLIPPLANE5
fClipDistance5=dot(worldPos,vClipPlane5);
#endif
#ifdef CLIPPLANE6
fClipDistance6=dot(worldPos,vClipPlane6);
#endif
`, re.IncludesShadersStore.fogVertex = `#ifdef FOG
vFogDistance=(view*worldPos).xyz;
#endif
`, re.IncludesShadersStore.shadowsVertex = `#ifdef SHADOWS
#if defined(SHADOWCSM{X})
vPositionFromCamera{X}=view*worldPos;for (int i=0; i<SHADOWCSMNUM_CASCADES{X}; i++) {vPositionFromLight{X}[i]=lightMatrix{X}[i]*worldPos;
#ifdef USE_REVERSE_DEPTHBUFFER
vDepthMetric{X}[i]=(-vPositionFromLight{X}[i].z+light{X}.depthValues.x)/light{X}.depthValues.y;
#else
vDepthMetric{X}[i]=(vPositionFromLight{X}[i].z+light{X}.depthValues.x)/light{X}.depthValues.y;
#endif
}
#elif defined(SHADOW{X}) && !defined(SHADOWCUBE{X})
vPositionFromLight{X}=lightMatrix{X}*worldPos;
#ifdef USE_REVERSE_DEPTHBUFFER
vDepthMetric{X}=(-vPositionFromLight{X}.z+light{X}.depthValues.x)/light{X}.depthValues.y;
#else
vDepthMetric{X}=(vPositionFromLight{X}.z+light{X}.depthValues.x)/light{X}.depthValues.y;
#endif
#endif
#endif
`, re.IncludesShadersStore.vertexColorMixing = `#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
vColor=vec4(1.0);
#ifdef VERTEXCOLOR
#ifdef VERTEXALPHA
vColor*=color;
#else
vColor.rgb*=color.rgb;
#endif
#endif
#ifdef INSTANCESCOLOR
vColor*=instanceColor;
#endif
#endif
`, re.IncludesShadersStore.pointCloudVertex = `#if defined(POINTSIZE) && !defined(WEBGPU)
gl_PointSize=pointSize;
#endif
`, re.IncludesShadersStore.logDepthVertex = `#ifdef LOGARITHMICDEPTH
vFragmentDepth=1.0+gl_Position.w;gl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;
#endif
`, re.ShadersStore.defaultVertexShader = `#include<__decl__defaultVertex>
#define CUSTOM_VERTEX_BEGIN
attribute vec3 position;
#ifdef NORMAL
attribute vec3 normal;
#endif
#ifdef TANGENT
attribute vec4 tangent;
#endif
#ifdef UV1
attribute vec2 uv;
#endif
#include<uvAttributeDeclaration>[2..7]
#ifdef VERTEXCOLOR
attribute vec4 color;
#endif
#include<helperFunctions>
#include<bonesDeclaration>
#include<bakedVertexAnimationDeclaration>
#include<instancesDeclaration>
#include<prePassVertexDeclaration>
#include<mainUVVaryingDeclaration>[1..7]
#include<samplerVertexDeclaration>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse)
#include<samplerVertexDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail)
#include<samplerVertexDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient)
#include<samplerVertexDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity)
#include<samplerVertexDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive)
#include<samplerVertexDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap)
#if defined(SPECULARTERM)
#include<samplerVertexDeclaration>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular)
#endif
#include<samplerVertexDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump)
#include<samplerVertexDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal)
varying vec3 vPositionW;
#ifdef NORMAL
varying vec3 vNormalW;
#endif
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
varying vec4 vColor;
#endif
#include<bumpVertexDeclaration>
#include<clipPlaneVertexDeclaration>
#include<fogVertexDeclaration>
#include<__decl__lightVxFragment>[0..maxSimultaneousLights]
#include<morphTargetsVertexGlobalDeclaration>
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
#ifdef REFLECTIONMAP_SKYBOX
varying vec3 vPositionUVW;
#endif
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
varying vec3 vDirectionW;
#endif
#include<logDepthDeclaration>
#define CUSTOM_VERTEX_DEFINITIONS
void main(void) {
#define CUSTOM_VERTEX_MAIN_BEGIN
vec3 positionUpdated=position;
#ifdef NORMAL
vec3 normalUpdated=normal;
#endif
#ifdef TANGENT
vec4 tangentUpdated=tangent;
#endif
#ifdef UV1
vec2 uvUpdated=uv;
#endif
#include<morphTargetsVertexGlobal>
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
#ifdef REFLECTIONMAP_SKYBOX
vPositionUVW=positionUpdated;
#endif
#define CUSTOM_VERTEX_UPDATE_POSITION
#define CUSTOM_VERTEX_UPDATE_NORMAL
#include<instancesVertex>
#if defined(PREPASS) && defined(PREPASS_VELOCITY) && !defined(BONES_VELOCITY_ENABLED)
vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);
#endif
#include<bonesVertex>
#include<bakedVertexAnimation>
vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);
#ifdef NORMAL
mat3 normalWorld=mat3(finalWorld);
#if defined(INSTANCES) && defined(THIN_INSTANCES)
vNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));vNormalW=normalize(normalWorld*vNormalW);
#else
#ifdef NONUNIFORMSCALING
normalWorld=transposeMat3(inverseMat3(normalWorld));
#endif
vNormalW=normalize(normalWorld*normalUpdated);
#endif
#endif
#define CUSTOM_VERTEX_UPDATE_WORLDPOS
#ifdef MULTIVIEW
if (gl_ViewID_OVR==0u) {gl_Position=viewProjection*worldPos;} else {gl_Position=viewProjectionR*worldPos;}
#else
gl_Position=viewProjection*worldPos;
#endif
vPositionW=vec3(worldPos);
#include<prePassVertex>
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
vDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));
#endif
#ifndef UV1
vec2 uvUpdated=vec2(0.,0.);
#endif
#ifdef MAINUV1
vMainUV1=uvUpdated;
#endif
#include<uvVariableDeclaration>[2..7]
#include<samplerVertexImplementation>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_MATRIXNAME_,diffuse,_INFONAME_,DiffuseInfos.x)
#include<samplerVertexImplementation>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x)
#include<samplerVertexImplementation>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_MATRIXNAME_,ambient,_INFONAME_,AmbientInfos.x)
#include<samplerVertexImplementation>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_MATRIXNAME_,opacity,_INFONAME_,OpacityInfos.x)
#include<samplerVertexImplementation>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_MATRIXNAME_,emissive,_INFONAME_,EmissiveInfos.x)
#include<samplerVertexImplementation>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x)
#if defined(SPECULARTERM)
#include<samplerVertexImplementation>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_MATRIXNAME_,specular,_INFONAME_,SpecularInfos.x)
#endif
#include<samplerVertexImplementation>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_MATRIXNAME_,bump,_INFONAME_,BumpInfos.x)
#include<samplerVertexImplementation>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_MATRIXNAME_,decal,_INFONAME_,DecalInfos.x)
#include<bumpVertex>
#include<clipPlaneVertex>
#include<fogVertex>
#include<shadowsVertex>[0..maxSimultaneousLights]
#include<vertexColorMixing>
#include<pointCloudVertex>
#include<logDepthVertex>
#define CUSTOM_VERTEX_MAIN_END
}
`;
    var X1 = new RegExp("^([gimus]+)!"), dv = function() {
      function n(t) {
        this._plugins = [], this._activePlugins = [], this._activePluginsForExtraEvents = [], this._material = t, this._scene = t.getScene(), this._engine = this._scene.getEngine();
      }
      return n.prototype._addPlugin = function(t) {
        for (var e = this, i = 0; i < this._plugins.length; ++i)
          if (this._plugins[i].name === t.name)
            return !1;
        if (this._material._uniformBufferLayoutBuilt)
          throw 'The plugin "'.concat(t.name, `" can't be added to the material "`).concat(this._material.name, '" because this material has already been used for rendering! Please add plugins to materials before any rendering with this material occurs.');
        var r = t.getClassName();
        n._MaterialPluginClassToMainDefine[r] || (n._MaterialPluginClassToMainDefine[r] = "MATERIALPLUGIN_" + ++n._MaterialPluginCounter), this._material._callbackPluginEventGeneric = function(c, u) {
          return e._handlePluginEvent(c, u);
        }, this._plugins.push(t), this._plugins.sort(function(c, u) {
          return c.priority - u.priority;
        }), this._codeInjectionPoints = {};
        var o = {};
        o[n._MaterialPluginClassToMainDefine[r]] = { type: "boolean", default: !0 };
        for (var a = 0, s = this._plugins; a < s.length; a++) {
          var l = s[a];
          l.collectDefines(o), this._collectPointNames("vertex", l.getCustomCode("vertex")), this._collectPointNames("fragment", l.getCustomCode("fragment"));
        }
        return this._defineNamesFromPlugins = o, !0;
      }, n.prototype._activatePlugin = function(t) {
        this._activePlugins.indexOf(t) === -1 && (this._activePlugins.push(t), this._activePlugins.sort(function(e, i) {
          return e.priority - i.priority;
        }), this._material._callbackPluginEventIsReadyForSubMesh = this._handlePluginEventIsReadyForSubMesh.bind(this), this._material._callbackPluginEventPrepareDefinesBeforeAttributes = this._handlePluginEventPrepareDefinesBeforeAttributes.bind(this), this._material._callbackPluginEventPrepareDefines = this._handlePluginEventPrepareDefines.bind(this), this._material._callbackPluginEventBindForSubMesh = this._handlePluginEventBindForSubMesh.bind(this), t.registerForExtraEvents && (this._activePluginsForExtraEvents.push(t), this._activePluginsForExtraEvents.sort(function(e, i) {
          return e.priority - i.priority;
        }), this._material._callbackPluginEventHasRenderTargetTextures = this._handlePluginEventHasRenderTargetTextures.bind(this), this._material._callbackPluginEventFillRenderTargetTextures = this._handlePluginEventFillRenderTargetTextures.bind(this), this._material._callbackPluginEventHardBindForSubMesh = this._handlePluginEventHardBindForSubMesh.bind(this)));
      }, n.prototype.getPlugin = function(t) {
        for (var e = 0; e < this._plugins.length; ++e)
          if (this._plugins[e].name === t)
            return this._plugins[e];
        return null;
      }, n.prototype._handlePluginEventIsReadyForSubMesh = function(t) {
        for (var e = !0, i = 0, r = this._activePlugins; i < r.length; i++) {
          var o = r[i];
          e = e && o.isReadyForSubMesh(t.defines, this._scene, this._engine, t.subMesh);
        }
        t.isReadyForSubMesh = e;
      }, n.prototype._handlePluginEventPrepareDefinesBeforeAttributes = function(t) {
        for (var e = 0, i = this._activePlugins; e < i.length; e++)
          i[e].prepareDefinesBeforeAttributes(t.defines, this._scene, t.mesh);
      }, n.prototype._handlePluginEventPrepareDefines = function(t) {
        for (var e = 0, i = this._activePlugins; e < i.length; e++)
          i[e].prepareDefines(t.defines, this._scene, t.mesh);
      }, n.prototype._handlePluginEventHardBindForSubMesh = function(t) {
        for (var e = 0, i = this._activePluginsForExtraEvents; e < i.length; e++)
          i[e].hardBindForSubMesh(this._material._uniformBuffer, this._scene, this._engine, t.subMesh);
      }, n.prototype._handlePluginEventBindForSubMesh = function(t) {
        for (var e = 0, i = this._activePlugins; e < i.length; e++)
          i[e].bindForSubMesh(this._material._uniformBuffer, this._scene, this._engine, t.subMesh);
      }, n.prototype._handlePluginEventHasRenderTargetTextures = function(t) {
        for (var e = !1, i = 0, r = this._activePluginsForExtraEvents; i < r.length && !(e = r[i].hasRenderTargetTextures()); i++)
          ;
        t.hasRenderTargetTextures = e;
      }, n.prototype._handlePluginEventFillRenderTargetTextures = function(t) {
        for (var e = 0, i = this._activePluginsForExtraEvents; e < i.length; e++)
          i[e].fillRenderTargetTextures(t.renderTargets);
      }, n.prototype._handlePluginEvent = function(t, e) {
        var i, r, o, a;
        switch (t) {
          case rn.GetActiveTextures:
            for (var s = e, l = 0, c = this._activePlugins; l < c.length; l++)
              (T = c[l]).getActiveTextures(s.activeTextures);
            break;
          case rn.GetAnimatables:
            s = e;
            for (var u = 0, h = this._activePlugins; u < h.length; u++)
              (T = h[u]).getAnimatables(s.animatables);
            break;
          case rn.HasTexture:
            s = e;
            for (var d = !1, p = 0, f = this._activePlugins; p < f.length && !(d = (T = f[p]).hasTexture(s.texture)); p++)
              ;
            s.hasTexture = d;
            break;
          case rn.Disposed:
            s = e;
            for (var m = 0, g = this._plugins; m < g.length; m++)
              (T = g[m]).dispose(s.forceDisposeTextures);
            break;
          case rn.GetDefineNames:
            (s = e).defineNames = this._defineNamesFromPlugins;
            break;
          case rn.PrepareEffect:
            s = e;
            for (var y = 0, b = this._activePlugins; y < b.length; y++) {
              var T = b[y];
              s.fallbackRank = T.addFallbacks(s.defines, s.fallbacks, s.fallbackRank), T.getAttributes(s.attributes, this._scene, s.mesh);
            }
            this._uniformList.length > 0 && (i = s.uniforms).push.apply(i, this._uniformList), this._samplerList.length > 0 && (r = s.samplers).push.apply(r, this._samplerList), this._uboList.length > 0 && (o = s.uniformBuffersNames).push.apply(o, this._uboList), s.customCode = this._injectCustomCode(s, s.customCode);
            break;
          case rn.PrepareUniformBuffer:
            s = e, this._uboDeclaration = "", this._vertexDeclaration = "", this._fragmentDeclaration = "", this._uniformList = [], this._samplerList = [], this._uboList = [];
            for (var S = 0, E = this._plugins; S < E.length; S++) {
              var A = (T = E[S]).getUniforms();
              if (A) {
                if (A.ubo)
                  for (var R = 0, C = A.ubo; R < C.length; R++) {
                    var L = C[R];
                    if (L.size && L.type) {
                      var I = (a = L.arraySize) !== null && a !== void 0 ? a : 0;
                      s.ubo.addUniform(L.name, L.size, I), this._uboDeclaration += "".concat(L.type, " ").concat(L.name).concat(I > 0 ? "[".concat(I, "]") : "", `;
`);
                    }
                    this._uniformList.push(L.name);
                  }
                A.vertex && (this._vertexDeclaration += A.vertex + `
`), A.fragment && (this._fragmentDeclaration += A.fragment + `
`);
              }
              T.getSamplers(this._samplerList), T.getUniformBuffersNames(this._uboList);
            }
        }
      }, n.prototype._collectPointNames = function(t, e) {
        if (e)
          for (var i in e)
            this._codeInjectionPoints[t] || (this._codeInjectionPoints[t] = {}), this._codeInjectionPoints[t][i] = !0;
      }, n.prototype._injectCustomCode = function(t, e) {
        var i = this;
        return function(r, o) {
          var a, s;
          e && (o = e(r, o)), i._uboDeclaration && (o = o.replace("#define ADDITIONAL_UBO_DECLARATION", i._uboDeclaration)), i._vertexDeclaration && (o = o.replace("#define ADDITIONAL_VERTEX_DECLARATION", i._vertexDeclaration)), i._fragmentDeclaration && (o = o.replace("#define ADDITIONAL_FRAGMENT_DECLARATION", i._fragmentDeclaration));
          var l = (a = i._codeInjectionPoints) === null || a === void 0 ? void 0 : a[r];
          if (!l)
            return o;
          var c = null;
          for (var u in l) {
            for (var h = "", d = function(R) {
              var C = (s = R.getCustomCode(r)) === null || s === void 0 ? void 0 : s[u];
              if (!C)
                return "continue";
              if (R.resolveIncludes) {
                if (c === null) {
                  var L = li.GLSL;
                  c = { defines: [], indexParameters: t.indexParameters, isFragment: !1, shouldUseHighPrecisionShader: i._engine._shouldUseHighPrecisionShader, processor: void 0, supportsUniformBuffers: i._engine.supportsUniformBuffers, shadersRepository: re.GetShadersRepository(L), includesShadersStore: re.GetIncludesShadersStore(L), version: void 0, platformName: i._engine.shaderPlatformName, processingContext: void 0, isNDCHalfZRange: i._engine.isNDCHalfZRange, useReverseDepthBuffer: i._engine.useReverseDepthBuffer, processCodeAfterIncludes: void 0 };
                }
                c.isFragment = r === "fragment", La._ProcessIncludes(C, c, function(I) {
                  return C = I;
                });
              }
              h += C + `
`;
            }, p = 0, f = i._activePlugins; p < f.length; p++)
              d(f[p]);
            if (h.length > 0)
              if (u.charAt(0) === "!") {
                var m = "g";
                if ((u = u.substring(1)).charAt(0) === "!")
                  m = "", u = u.substring(1);
                else {
                  var g = X1.exec(u);
                  g && g.length >= 2 && (m = g[1], u = u.substring(m.length + 1));
                }
                m.indexOf("g") < 0 && (m += "g");
                for (var y = o, b = new RegExp(u, m), T = b.exec(y); T !== null; ) {
                  for (var S = h, E = 0; E < T.length; ++E)
                    S = S.replace("$" + E, T[E]);
                  o = o.replace(T[0], S), T = b.exec(y);
                }
              } else {
                var A = "#define " + u;
                o = o.replace(A, `
` + h + `
` + A);
              }
          }
          return o;
        };
      }, n._MaterialPluginClassToMainDefine = {}, n._MaterialPluginCounter = 0, Me.OnEnginesDisposedObservable.add(function() {
        df();
      }), n;
    }(), bs = [], pv = !1, fv = null;
    function kR(n, t) {
      pv || (fv = Et.OnEventObservable.add(function(i) {
        for (var r = 0, o = bs; r < o.length; r++)
          (0, o[r][1])(i);
      }, rn.Created), pv = !0);
      var e = bs.filter(function(i) {
        var r = i[0];
        return i[1], r === n;
      });
      e.length > 0 ? e[0][1] = t : bs.push([n, t]);
    }
    function GR(n) {
      for (var t = 0; t < bs.length; ++t)
        if (bs[t][0] === n)
          return bs.splice(t, 1), bs.length === 0 && df(), !0;
      return !1;
    }
    function df() {
      bs.length = 0, pv = !1, Et.OnEventObservable.remove(fv), fv = null;
    }
    var $r = function() {
      function n(t, e, i, r, o, a, s) {
        o === void 0 && (o = !0), a === void 0 && (a = !1), s === void 0 && (s = !1), this.priority = 500, this.resolveIncludes = !1, this.registerForExtraEvents = !1, this._material = t, this.name = e, this.priority = i, this.resolveIncludes = s, t.pluginManager || (t.pluginManager = new dv(t), t.onDisposeObservable.add(function() {
          t.pluginManager = void 0;
        })), this._pluginDefineNames = r, this._pluginManager = t.pluginManager, o && this._pluginManager._addPlugin(this), a && this._enable(!0), this.markAllDefinesAsDirty = t._dirtyCallbacks[_.MATERIAL_AllDirtyFlag];
      }
      return n.prototype._enable = function(t) {
        t && this._pluginManager._activatePlugin(this);
      }, n.prototype.getClassName = function() {
        return "MaterialPluginBase";
      }, n.prototype.isReadyForSubMesh = function(t, e, i, r) {
        return !0;
      }, n.prototype.hardBindForSubMesh = function(t, e, i, r) {
      }, n.prototype.bindForSubMesh = function(t, e, i, r) {
      }, n.prototype.dispose = function(t) {
      }, n.prototype.getCustomCode = function(t) {
        return null;
      }, n.prototype.collectDefines = function(t) {
        if (this._pluginDefineNames)
          for (var e = 0, i = Object.keys(this._pluginDefineNames); e < i.length; e++) {
            var r = i[e];
            if (r[0] !== "_") {
              var o = typeof this._pluginDefineNames[r];
              t[r] = { type: o === "number" ? "number" : o === "string" ? "string" : o === "boolean" ? "boolean" : "object", default: this._pluginDefineNames[r] };
            }
          }
      }, n.prototype.prepareDefinesBeforeAttributes = function(t, e, i) {
      }, n.prototype.prepareDefines = function(t, e, i) {
      }, n.prototype.hasTexture = function(t) {
        return !1;
      }, n.prototype.hasRenderTargetTextures = function() {
        return !1;
      }, n.prototype.fillRenderTargetTextures = function(t) {
      }, n.prototype.getActiveTextures = function(t) {
      }, n.prototype.getAnimatables = function(t) {
      }, n.prototype.addFallbacks = function(t, e, i) {
        return i;
      }, n.prototype.getSamplers = function(t) {
      }, n.prototype.getAttributes = function(t, e, i) {
      }, n.prototype.getUniformBuffersNames = function(t) {
      }, n.prototype.getUniforms = function() {
        return {};
      }, n.prototype.copyTo = function(t) {
        Ne.Clone(function() {
          return t;
        }, this);
      }, n.prototype.serialize = function() {
        return Ne.Serialize(this);
      }, n.prototype.parse = function(t, e, i) {
        var r = this;
        Ne.Parse(function() {
          return r;
        }, t, e, i);
      }, x([N()], n.prototype, "name", void 0), x([N()], n.prototype, "priority", void 0), x([N()], n.prototype, "resolveIncludes", void 0), x([N()], n.prototype, "registerForExtraEvents", void 0), n;
    }(), _v = function(n) {
      function t() {
        var e = n !== null && n.apply(this, arguments) || this;
        return e.DETAIL = !1, e.DETAILDIRECTUV = 0, e.DETAIL_NORMALBLENDMETHOD = 0, e;
      }
      return D(t, n), t;
    }(jn), dh = function(n) {
      function t(e, i) {
        i === void 0 && (i = !0);
        var r = n.call(this, e, "DetailMap", 140, new _v(), i) || this;
        return r._texture = null, r.diffuseBlendLevel = 1, r.roughnessBlendLevel = 1, r.bumpLevel = 1, r._normalBlendMethod = Et.MATERIAL_NORMALBLENDMETHOD_WHITEOUT, r._isEnabled = !1, r.isEnabled = !1, r._internalMarkAllSubMeshesAsTexturesDirty = e._dirtyCallbacks[_.MATERIAL_TextureDirtyFlag], r;
      }
      return D(t, n), t.prototype._markAllSubMeshesAsTexturesDirty = function() {
        this._enable(this._isEnabled), this._internalMarkAllSubMeshesAsTexturesDirty();
      }, t.prototype.isReadyForSubMesh = function(e, i, r) {
        return !this._isEnabled || !(e._areTexturesDirty && i.texturesEnabled && r.getCaps().standardDerivatives && this._texture && Pe.DetailTextureEnabled && !this._texture.isReady());
      }, t.prototype.prepareDefines = function(e, i) {
        if (this._isEnabled) {
          e.DETAIL_NORMALBLENDMETHOD = this._normalBlendMethod;
          var r = i.getEngine();
          e._areTexturesDirty && (r.getCaps().standardDerivatives && this._texture && Pe.DetailTextureEnabled && this._isEnabled ? (Se.PrepareDefinesForMergedUV(this._texture, e, "DETAIL"), e.DETAIL_NORMALBLENDMETHOD = this._normalBlendMethod) : e.DETAIL = !1);
        } else
          e.DETAIL = !1;
      }, t.prototype.bindForSubMesh = function(e, i) {
        if (this._isEnabled) {
          var r = this._material.isFrozen;
          e.useUbo && r && e.isSync || this._texture && Pe.DetailTextureEnabled && (e.updateFloat4("vDetailInfos", this._texture.coordinatesIndex, this.diffuseBlendLevel, this.bumpLevel, this.roughnessBlendLevel), Se.BindTextureMatrix(this._texture, e, "detail")), i.texturesEnabled && this._texture && Pe.DetailTextureEnabled && e.setTexture("detailSampler", this._texture);
        }
      }, t.prototype.hasTexture = function(e) {
        return this._texture === e;
      }, t.prototype.getActiveTextures = function(e) {
        this._texture && e.push(this._texture);
      }, t.prototype.getAnimatables = function(e) {
        this._texture && this._texture.animations && this._texture.animations.length > 0 && e.push(this._texture);
      }, t.prototype.dispose = function(e) {
        var i;
        e && ((i = this._texture) === null || i === void 0 || i.dispose());
      }, t.prototype.getClassName = function() {
        return "DetailMapConfiguration";
      }, t.prototype.getSamplers = function(e) {
        e.push("detailSampler");
      }, t.prototype.getUniforms = function() {
        return { ubo: [{ name: "vDetailInfos", size: 4, type: "vec4" }, { name: "detailMatrix", size: 16, type: "mat4" }] };
      }, x([St("detailTexture"), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "texture", void 0), x([N()], t.prototype, "diffuseBlendLevel", void 0), x([N()], t.prototype, "roughnessBlendLevel", void 0), x([N()], t.prototype, "bumpLevel", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "normalBlendMethod", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isEnabled", void 0), t;
    }($r), mv = { effect: null, subMesh: null }, gv = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.MAINUV1 = !1, i.MAINUV2 = !1, i.MAINUV3 = !1, i.MAINUV4 = !1, i.MAINUV5 = !1, i.MAINUV6 = !1, i.DIFFUSE = !1, i.DIFFUSEDIRECTUV = 0, i.BAKED_VERTEX_ANIMATION_TEXTURE = !1, i.AMBIENT = !1, i.AMBIENTDIRECTUV = 0, i.OPACITY = !1, i.OPACITYDIRECTUV = 0, i.OPACITYRGB = !1, i.REFLECTION = !1, i.EMISSIVE = !1, i.EMISSIVEDIRECTUV = 0, i.SPECULAR = !1, i.SPECULARDIRECTUV = 0, i.BUMP = !1, i.BUMPDIRECTUV = 0, i.PARALLAX = !1, i.PARALLAX_RHS = !1, i.PARALLAXOCCLUSION = !1, i.SPECULAROVERALPHA = !1, i.CLIPPLANE = !1, i.CLIPPLANE2 = !1, i.CLIPPLANE3 = !1, i.CLIPPLANE4 = !1, i.CLIPPLANE5 = !1, i.CLIPPLANE6 = !1, i.ALPHATEST = !1, i.DEPTHPREPASS = !1, i.ALPHAFROMDIFFUSE = !1, i.POINTSIZE = !1, i.FOG = !1, i.SPECULARTERM = !1, i.DIFFUSEFRESNEL = !1, i.OPACITYFRESNEL = !1, i.REFLECTIONFRESNEL = !1, i.REFRACTIONFRESNEL = !1, i.EMISSIVEFRESNEL = !1, i.FRESNEL = !1, i.NORMAL = !1, i.TANGENT = !1, i.UV1 = !1, i.UV2 = !1, i.UV3 = !1, i.UV4 = !1, i.UV5 = !1, i.UV6 = !1, i.VERTEXCOLOR = !1, i.VERTEXALPHA = !1, i.NUM_BONE_INFLUENCERS = 0, i.BonesPerMesh = 0, i.BONETEXTURE = !1, i.BONES_VELOCITY_ENABLED = !1, i.INSTANCES = !1, i.THIN_INSTANCES = !1, i.INSTANCESCOLOR = !1, i.GLOSSINESS = !1, i.ROUGHNESS = !1, i.EMISSIVEASILLUMINATION = !1, i.LINKEMISSIVEWITHDIFFUSE = !1, i.REFLECTIONFRESNELFROMSPECULAR = !1, i.LIGHTMAP = !1, i.LIGHTMAPDIRECTUV = 0, i.OBJECTSPACE_NORMALMAP = !1, i.USELIGHTMAPASSHADOWMAP = !1, i.REFLECTIONMAP_3D = !1, i.REFLECTIONMAP_SPHERICAL = !1, i.REFLECTIONMAP_PLANAR = !1, i.REFLECTIONMAP_CUBIC = !1, i.USE_LOCAL_REFLECTIONMAP_CUBIC = !1, i.USE_LOCAL_REFRACTIONMAP_CUBIC = !1, i.REFLECTIONMAP_PROJECTION = !1, i.REFLECTIONMAP_SKYBOX = !1, i.REFLECTIONMAP_EXPLICIT = !1, i.REFLECTIONMAP_EQUIRECTANGULAR = !1, i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1, i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1, i.REFLECTIONMAP_OPPOSITEZ = !1, i.INVERTCUBICMAP = !1, i.LOGARITHMICDEPTH = !1, i.REFRACTION = !1, i.REFRACTIONMAP_3D = !1, i.REFLECTIONOVERALPHA = !1, i.TWOSIDEDLIGHTING = !1, i.SHADOWFLOAT = !1, i.MORPHTARGETS = !1, i.MORPHTARGETS_NORMAL = !1, i.MORPHTARGETS_TANGENT = !1, i.MORPHTARGETS_UV = !1, i.NUM_MORPH_INFLUENCERS = 0, i.MORPHTARGETS_TEXTURE = !1, i.NONUNIFORMSCALING = !1, i.PREMULTIPLYALPHA = !1, i.ALPHATEST_AFTERALLALPHACOMPUTATIONS = !1, i.ALPHABLEND = !0, i.PREPASS = !1, i.PREPASS_IRRADIANCE = !1, i.PREPASS_IRRADIANCE_INDEX = -1, i.PREPASS_ALBEDO_SQRT = !1, i.PREPASS_ALBEDO_SQRT_INDEX = -1, i.PREPASS_DEPTH = !1, i.PREPASS_DEPTH_INDEX = -1, i.PREPASS_NORMAL = !1, i.PREPASS_NORMAL_INDEX = -1, i.PREPASS_NORMAL_WORLDSPACE = !1, i.PREPASS_POSITION = !1, i.PREPASS_POSITION_INDEX = -1, i.PREPASS_VELOCITY = !1, i.PREPASS_VELOCITY_INDEX = -1, i.PREPASS_REFLECTIVITY = !1, i.PREPASS_REFLECTIVITY_INDEX = -1, i.SCENE_MRT_COUNT = 0, i.RGBDLIGHTMAP = !1, i.RGBDREFLECTION = !1, i.RGBDREFRACTION = !1, i.IMAGEPROCESSING = !1, i.VIGNETTE = !1, i.VIGNETTEBLENDMODEMULTIPLY = !1, i.VIGNETTEBLENDMODEOPAQUE = !1, i.TONEMAPPING = !1, i.TONEMAPPING_ACES = !1, i.CONTRAST = !1, i.COLORCURVES = !1, i.COLORGRADING = !1, i.COLORGRADING3D = !1, i.SAMPLER3DGREENDEPTH = !1, i.SAMPLER3DBGRMAP = !1, i.DITHER = !1, i.IMAGEPROCESSINGPOSTPROCESS = !1, i.SKIPFINALCOLORCLAMP = !1, i.MULTIVIEW = !1, i.ORDER_INDEPENDENT_TRANSPARENCY = !1, i.ORDER_INDEPENDENT_TRANSPARENCY_16BITS = !1, i.CAMERA_ORTHOGRAPHIC = !1, i.CAMERA_PERSPECTIVE = !1, i.IS_REFLECTION_LINEAR = !1, i.IS_REFRACTION_LINEAR = !1, i.EXPOSURE = !1, i.DECAL_AFTER_DETAIL = !1, i.rebuild(), i;
      }
      return D(t, n), t.prototype.setReflectionMode = function(e) {
        for (var i = 0, r = ["REFLECTIONMAP_CUBIC", "REFLECTIONMAP_EXPLICIT", "REFLECTIONMAP_PLANAR", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_SKYBOX", "REFLECTIONMAP_SPHERICAL", "REFLECTIONMAP_EQUIRECTANGULAR", "REFLECTIONMAP_EQUIRECTANGULAR_FIXED", "REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"]; i < r.length; i++) {
          var o = r[i];
          this[o] = o === e;
        }
      }, t;
    }(jn), Gt = function(n) {
      function t(e, i) {
        var r = n.call(this, e, i) || this;
        return r._diffuseTexture = null, r._ambientTexture = null, r._opacityTexture = null, r._reflectionTexture = null, r._emissiveTexture = null, r._specularTexture = null, r._bumpTexture = null, r._lightmapTexture = null, r._refractionTexture = null, r.ambientColor = new ne(0, 0, 0), r.diffuseColor = new ne(1, 1, 1), r.specularColor = new ne(1, 1, 1), r.emissiveColor = new ne(0, 0, 0), r.specularPower = 64, r._useAlphaFromDiffuseTexture = !1, r._useEmissiveAsIllumination = !1, r._linkEmissiveWithDiffuse = !1, r._useSpecularOverAlpha = !1, r._useReflectionOverAlpha = !1, r._disableLighting = !1, r._useObjectSpaceNormalMap = !1, r._useParallax = !1, r._useParallaxOcclusion = !1, r.parallaxScaleBias = 0.05, r._roughness = 0, r.indexOfRefraction = 0.98, r.invertRefractionY = !0, r.alphaCutOff = 0.4, r._useLightmapAsShadowmap = !1, r._useReflectionFresnelFromSpecular = !1, r._useGlossinessFromSpecularMapAlpha = !1, r._maxSimultaneousLights = 4, r._invertNormalMapX = !1, r._invertNormalMapY = !1, r._twoSidedLighting = !1, r._applyDecalMapAfterDetailMap = !1, r._renderTargets = new en(16), r._worldViewProjectionMatrix = B.Zero(), r._globalAmbientColor = new ne(0, 0, 0), r._cacheHasRenderTargetTextures = !1, r.detailMap = new dh(r), r._attachImageProcessingConfiguration(null), r.prePassConfiguration = new xc(), r.getRenderTargetTextures = function() {
          return r._renderTargets.reset(), t.ReflectionTextureEnabled && r._reflectionTexture && r._reflectionTexture.isRenderTarget && r._renderTargets.push(r._reflectionTexture), t.RefractionTextureEnabled && r._refractionTexture && r._refractionTexture.isRenderTarget && r._renderTargets.push(r._refractionTexture), r._eventInfo.renderTargets = r._renderTargets, r._callbackPluginEventFillRenderTargetTextures(r._eventInfo), r._renderTargets;
        }, r;
      }
      return D(t, n), Object.defineProperty(t.prototype, "imageProcessingConfiguration", { get: function() {
        return this._imageProcessingConfiguration;
      }, set: function(e) {
        this._attachImageProcessingConfiguration(e), this._markAllSubMeshesAsTexturesDirty();
      }, enumerable: !1, configurable: !0 }), t.prototype._attachImageProcessingConfiguration = function(e) {
        var i = this;
        e !== this._imageProcessingConfiguration && (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver), this._imageProcessingConfiguration = e || this.getScene().imageProcessingConfiguration, this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function() {
          i._markAllSubMeshesAsImageProcessingDirty();
        })));
      }, Object.defineProperty(t.prototype, "isPrePassCapable", { get: function() {
        return !this.disableDepthWrite;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraColorCurvesEnabled", { get: function() {
        return this.imageProcessingConfiguration.colorCurvesEnabled;
      }, set: function(e) {
        this.imageProcessingConfiguration.colorCurvesEnabled = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraColorGradingEnabled", { get: function() {
        return this.imageProcessingConfiguration.colorGradingEnabled;
      }, set: function(e) {
        this.imageProcessingConfiguration.colorGradingEnabled = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraToneMappingEnabled", { get: function() {
        return this._imageProcessingConfiguration.toneMappingEnabled;
      }, set: function(e) {
        this._imageProcessingConfiguration.toneMappingEnabled = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraExposure", { get: function() {
        return this._imageProcessingConfiguration.exposure;
      }, set: function(e) {
        this._imageProcessingConfiguration.exposure = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraContrast", { get: function() {
        return this._imageProcessingConfiguration.contrast;
      }, set: function(e) {
        this._imageProcessingConfiguration.contrast = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraColorGradingTexture", { get: function() {
        return this._imageProcessingConfiguration.colorGradingTexture;
      }, set: function(e) {
        this._imageProcessingConfiguration.colorGradingTexture = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraColorCurves", { get: function() {
        return this._imageProcessingConfiguration.colorCurves;
      }, set: function(e) {
        this._imageProcessingConfiguration.colorCurves = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "canRenderToMRT", { get: function() {
        return !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hasRenderTargetTextures", { get: function() {
        return !!(t.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) || !!(t.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) || this._cacheHasRenderTargetTextures;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "StandardMaterial";
      }, Object.defineProperty(t.prototype, "useLogarithmicDepth", { get: function() {
        return this._useLogarithmicDepth;
      }, set: function(e) {
        this._useLogarithmicDepth = e && this.getScene().getEngine().getCaps().fragmentDepthSupported, this._markAllSubMeshesAsMiscDirty();
      }, enumerable: !1, configurable: !0 }), t.prototype.needAlphaBlending = function() {
        return !this._disableAlphaBlending && (this.alpha < 1 || this._opacityTexture != null || this._shouldUseAlphaFromDiffuseTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled);
      }, t.prototype.needAlphaTesting = function() {
        return !!this._forceAlphaTest || this._hasAlphaChannel() && (this._transparencyMode == null || this._transparencyMode === Et.MATERIAL_ALPHATEST);
      }, t.prototype._shouldUseAlphaFromDiffuseTexture = function() {
        return this._diffuseTexture != null && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture && this._transparencyMode !== Et.MATERIAL_OPAQUE;
      }, t.prototype._hasAlphaChannel = function() {
        return this._diffuseTexture != null && this._diffuseTexture.hasAlpha || this._opacityTexture != null;
      }, t.prototype.getAlphaTestTexture = function() {
        return this._diffuseTexture;
      }, t.prototype.isReadyForSubMesh = function(e, i, r) {
        if (r === void 0 && (r = !1), this._uniformBufferLayoutBuilt || this.buildUniformLayout(), i.effect && this.isFrozen && i.effect._wasPreviouslyReady && i.effect._wasPreviouslyUsingInstances === r)
          return !0;
        i.materialDefines || (this._callbackPluginEventGeneric(rn.GetDefineNames, this._eventInfo), i.materialDefines = new gv(this._eventInfo.defineNames));
        var o = this.getScene(), a = i.materialDefines;
        if (this._isReadyForSubMesh(i))
          return !0;
        var s = o.getEngine();
        a._needNormals = Se.PrepareDefinesForLights(o, e, a, !0, this._maxSimultaneousLights, this._disableLighting), Se.PrepareDefinesForMultiview(o, a);
        var l = this.needAlphaBlendingForMesh(e) && this.getScene().useOrderIndependentTransparency;
        if (Se.PrepareDefinesForPrePass(o, a, this.canRenderToMRT && !l), Se.PrepareDefinesForOIT(o, a, l), a._areTexturesDirty) {
          this._eventInfo.hasRenderTargetTextures = !1, this._callbackPluginEventHasRenderTargetTextures(this._eventInfo), this._cacheHasRenderTargetTextures = this._eventInfo.hasRenderTargetTextures, a._needUVs = !1;
          for (var c = 1; c <= _.MAX_SUPPORTED_UV_SETS; ++c)
            a["MAINUV" + c] = !1;
          if (o.texturesEnabled) {
            if (a.DIFFUSEDIRECTUV = 0, a.BUMPDIRECTUV = 0, a.AMBIENTDIRECTUV = 0, a.OPACITYDIRECTUV = 0, a.EMISSIVEDIRECTUV = 0, a.SPECULARDIRECTUV = 0, a.LIGHTMAPDIRECTUV = 0, this._diffuseTexture && t.DiffuseTextureEnabled) {
              if (!this._diffuseTexture.isReadyOrNotBlocking())
                return !1;
              Se.PrepareDefinesForMergedUV(this._diffuseTexture, a, "DIFFUSE");
            } else
              a.DIFFUSE = !1;
            if (this._ambientTexture && t.AmbientTextureEnabled) {
              if (!this._ambientTexture.isReadyOrNotBlocking())
                return !1;
              Se.PrepareDefinesForMergedUV(this._ambientTexture, a, "AMBIENT");
            } else
              a.AMBIENT = !1;
            if (this._opacityTexture && t.OpacityTextureEnabled) {
              if (!this._opacityTexture.isReadyOrNotBlocking())
                return !1;
              Se.PrepareDefinesForMergedUV(this._opacityTexture, a, "OPACITY"), a.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
            } else
              a.OPACITY = !1;
            if (this._reflectionTexture && t.ReflectionTextureEnabled) {
              if (!this._reflectionTexture.isReadyOrNotBlocking())
                return !1;
              switch (a._needNormals = !0, a.REFLECTION = !0, a.ROUGHNESS = this._roughness > 0, a.REFLECTIONOVERALPHA = this._useReflectionOverAlpha, a.INVERTCUBICMAP = this._reflectionTexture.coordinatesMode === ae.INVCUBIC_MODE, a.REFLECTIONMAP_3D = this._reflectionTexture.isCube, a.REFLECTIONMAP_OPPOSITEZ = a.REFLECTIONMAP_3D && this.getScene().useRightHandedSystem ? !this._reflectionTexture.invertZ : this._reflectionTexture.invertZ, a.RGBDREFLECTION = this._reflectionTexture.isRGBD, this._reflectionTexture.coordinatesMode) {
                case ae.EXPLICIT_MODE:
                  a.setReflectionMode("REFLECTIONMAP_EXPLICIT");
                  break;
                case ae.PLANAR_MODE:
                  a.setReflectionMode("REFLECTIONMAP_PLANAR");
                  break;
                case ae.PROJECTION_MODE:
                  a.setReflectionMode("REFLECTIONMAP_PROJECTION");
                  break;
                case ae.SKYBOX_MODE:
                  a.setReflectionMode("REFLECTIONMAP_SKYBOX");
                  break;
                case ae.SPHERICAL_MODE:
                  a.setReflectionMode("REFLECTIONMAP_SPHERICAL");
                  break;
                case ae.EQUIRECTANGULAR_MODE:
                  a.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");
                  break;
                case ae.FIXED_EQUIRECTANGULAR_MODE:
                  a.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");
                  break;
                case ae.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
                  a.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");
                  break;
                case ae.CUBIC_MODE:
                case ae.INVCUBIC_MODE:
                default:
                  a.setReflectionMode("REFLECTIONMAP_CUBIC");
              }
              a.USE_LOCAL_REFLECTIONMAP_CUBIC = !!this._reflectionTexture.boundingBoxSize;
            } else
              a.REFLECTION = !1, a.REFLECTIONMAP_OPPOSITEZ = !1;
            if (this._emissiveTexture && t.EmissiveTextureEnabled) {
              if (!this._emissiveTexture.isReadyOrNotBlocking())
                return !1;
              Se.PrepareDefinesForMergedUV(this._emissiveTexture, a, "EMISSIVE");
            } else
              a.EMISSIVE = !1;
            if (this._lightmapTexture && t.LightmapTextureEnabled) {
              if (!this._lightmapTexture.isReadyOrNotBlocking())
                return !1;
              Se.PrepareDefinesForMergedUV(this._lightmapTexture, a, "LIGHTMAP"), a.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap, a.RGBDLIGHTMAP = this._lightmapTexture.isRGBD;
            } else
              a.LIGHTMAP = !1;
            if (this._specularTexture && t.SpecularTextureEnabled) {
              if (!this._specularTexture.isReadyOrNotBlocking())
                return !1;
              Se.PrepareDefinesForMergedUV(this._specularTexture, a, "SPECULAR"), a.GLOSSINESS = this._useGlossinessFromSpecularMapAlpha;
            } else
              a.SPECULAR = !1;
            if (o.getEngine().getCaps().standardDerivatives && this._bumpTexture && t.BumpTextureEnabled) {
              if (!this._bumpTexture.isReady())
                return !1;
              Se.PrepareDefinesForMergedUV(this._bumpTexture, a, "BUMP"), a.PARALLAX = this._useParallax, a.PARALLAX_RHS = o.useRightHandedSystem, a.PARALLAXOCCLUSION = this._useParallaxOcclusion, a.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
            } else
              a.BUMP = !1, a.PARALLAX = !1, a.PARALLAX_RHS = !1, a.PARALLAXOCCLUSION = !1;
            if (this._refractionTexture && t.RefractionTextureEnabled) {
              if (!this._refractionTexture.isReadyOrNotBlocking())
                return !1;
              a._needUVs = !0, a.REFRACTION = !0, a.REFRACTIONMAP_3D = this._refractionTexture.isCube, a.RGBDREFRACTION = this._refractionTexture.isRGBD, a.USE_LOCAL_REFRACTIONMAP_CUBIC = !!this._refractionTexture.boundingBoxSize;
            } else
              a.REFRACTION = !1;
            a.TWOSIDEDLIGHTING = !this._backFaceCulling && this._twoSidedLighting;
          } else
            a.DIFFUSE = !1, a.AMBIENT = !1, a.OPACITY = !1, a.REFLECTION = !1, a.EMISSIVE = !1, a.LIGHTMAP = !1, a.BUMP = !1, a.REFRACTION = !1;
          a.ALPHAFROMDIFFUSE = this._shouldUseAlphaFromDiffuseTexture(), a.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination, a.LINKEMISSIVEWITHDIFFUSE = this._linkEmissiveWithDiffuse, a.SPECULAROVERALPHA = this._useSpecularOverAlpha, a.PREMULTIPLYALPHA = this.alphaMode === _.ALPHA_PREMULTIPLIED || this.alphaMode === _.ALPHA_PREMULTIPLIED_PORTERDUFF, a.ALPHATEST_AFTERALLALPHACOMPUTATIONS = this.transparencyMode !== null, a.ALPHABLEND = this.transparencyMode === null || this.needAlphaBlendingForMesh(e);
        }
        if (this._eventInfo.isReadyForSubMesh = !0, this._eventInfo.defines = a, this._eventInfo.subMesh = i, this._callbackPluginEventIsReadyForSubMesh(this._eventInfo), !this._eventInfo.isReadyForSubMesh)
          return !1;
        if (a._areImageProcessingDirty && this._imageProcessingConfiguration) {
          if (!this._imageProcessingConfiguration.isReady())
            return !1;
          this._imageProcessingConfiguration.prepareDefines(a), a.IS_REFLECTION_LINEAR = this.reflectionTexture != null && !this.reflectionTexture.gammaSpace, a.IS_REFRACTION_LINEAR = this.refractionTexture != null && !this.refractionTexture.gammaSpace;
        }
        a._areFresnelDirty && (t.FresnelEnabled ? (this._diffuseFresnelParameters || this._opacityFresnelParameters || this._emissiveFresnelParameters || this._refractionFresnelParameters || this._reflectionFresnelParameters) && (a.DIFFUSEFRESNEL = this._diffuseFresnelParameters && this._diffuseFresnelParameters.isEnabled, a.OPACITYFRESNEL = this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled, a.REFLECTIONFRESNEL = this._reflectionFresnelParameters && this._reflectionFresnelParameters.isEnabled, a.REFLECTIONFRESNELFROMSPECULAR = this._useReflectionFresnelFromSpecular, a.REFRACTIONFRESNEL = this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled, a.EMISSIVEFRESNEL = this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled, a._needNormals = !0, a.FRESNEL = !0) : a.FRESNEL = !1), Se.PrepareDefinesForMisc(e, o, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(e) || this._forceAlphaTest, a, this._applyDecalMapAfterDetailMap), Se.PrepareDefinesForFrameBoundValues(o, s, this, a, r, null, i.getRenderingMesh().hasThinInstances), this._eventInfo.defines = a, this._eventInfo.mesh = e, this._callbackPluginEventPrepareDefinesBeforeAttributes(this._eventInfo), Se.PrepareDefinesForAttributes(e, a, !0, !0, !0), this._callbackPluginEventPrepareDefines(this._eventInfo);
        var u = !1;
        if (a.isDirty) {
          var h = a._areLightsDisposed;
          a.markAsProcessed();
          var d = new Va();
          a.REFLECTION && d.addFallback(0, "REFLECTION"), a.SPECULAR && d.addFallback(0, "SPECULAR"), a.BUMP && d.addFallback(0, "BUMP"), a.PARALLAX && d.addFallback(1, "PARALLAX"), a.PARALLAX_RHS && d.addFallback(1, "PARALLAX_RHS"), a.PARALLAXOCCLUSION && d.addFallback(0, "PARALLAXOCCLUSION"), a.SPECULAROVERALPHA && d.addFallback(0, "SPECULAROVERALPHA"), a.FOG && d.addFallback(1, "FOG"), a.POINTSIZE && d.addFallback(0, "POINTSIZE"), a.LOGARITHMICDEPTH && d.addFallback(0, "LOGARITHMICDEPTH"), Se.HandleFallbacksForShadows(a, d, this._maxSimultaneousLights), a.SPECULARTERM && d.addFallback(0, "SPECULARTERM"), a.DIFFUSEFRESNEL && d.addFallback(1, "DIFFUSEFRESNEL"), a.OPACITYFRESNEL && d.addFallback(2, "OPACITYFRESNEL"), a.REFLECTIONFRESNEL && d.addFallback(3, "REFLECTIONFRESNEL"), a.EMISSIVEFRESNEL && d.addFallback(4, "EMISSIVEFRESNEL"), a.FRESNEL && d.addFallback(4, "FRESNEL"), a.MULTIVIEW && d.addFallback(0, "MULTIVIEW");
          var p = [P.PositionKind];
          for (a.NORMAL && p.push(P.NormalKind), a.TANGENT && p.push(P.TangentKind), c = 1; c <= _.MAX_SUPPORTED_UV_SETS; ++c)
            a["UV" + c] && p.push("uv".concat(c === 1 ? "" : c));
          a.VERTEXCOLOR && p.push(P.ColorKind), Se.PrepareAttributesForBones(p, e, a, d), Se.PrepareAttributesForInstances(p, a), Se.PrepareAttributesForMorphTargets(p, e, a), Se.PrepareAttributesForBakedVertexAnimation(p, e, a);
          var f = "default", m = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor", "visibility", "vFogInfos", "vFogColor", "pointSize", "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos", "mBones", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "normalMatrix", "lightmapMatrix", "refractionMatrix", "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor", "vReflectionPosition", "vReflectionSize", "vRefractionPosition", "vRefractionSize", "logarithmicDepthConstant", "vTangentSpaceParams", "alphaCutOff", "boneTextureWidth", "morphTargetTextureInfo", "morphTargetTextureIndices"], g = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler", "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler", "refractionCubeSampler", "refraction2DSampler", "boneSampler", "morphTargets", "oitDepthSampler", "oitFrontColorSampler"], y = ["Material", "Scene", "Mesh"], b = { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: a.NUM_MORPH_INFLUENCERS };
          this._eventInfo.fallbacks = d, this._eventInfo.fallbackRank = 0, this._eventInfo.defines = a, this._eventInfo.uniforms = m, this._eventInfo.attributes = p, this._eventInfo.samplers = g, this._eventInfo.uniformBuffersNames = y, this._eventInfo.customCode = void 0, this._eventInfo.mesh = e, this._eventInfo.indexParameters = b, this._callbackPluginEventGeneric(rn.PrepareEffect, this._eventInfo), xc.AddUniforms(m), xc.AddSamplers(g), tn && (tn.PrepareUniforms(m, a), tn.PrepareSamplers(g, a)), Se.PrepareUniformsAndSamplersList({ uniformsNames: m, uniformBuffersNames: y, samplers: g, defines: a, maxSimultaneousLights: this._maxSimultaneousLights }), Br(m);
          var T = {};
          this.customShaderNameResolve && (f = this.customShaderNameResolve(f, m, y, g, a, p, T));
          var S = a.toString(), E = i.effect, A = o.getEngine().createEffect(f, { attributes: p, uniformsNames: m, uniformBuffersNames: y, samplers: g, defines: S, fallbacks: d, onCompiled: this.onCompiled, onError: this.onError, indexParameters: b, processFinalCode: T.processFinalCode, processCodeAfterIncludes: this._eventInfo.customCode, multiTarget: a.PREPASS }, s);
          if (this._eventInfo.customCode = void 0, A)
            if (this._onEffectCreatedObservable && (mv.effect = A, mv.subMesh = i, this._onEffectCreatedObservable.notifyObservers(mv)), this.allowShaderHotSwapping && E && !A.isReady()) {
              if (A = E, a.markAsUnprocessed(), u = this.isFrozen, h)
                return a._areLightsDisposed = !0, !1;
            } else
              o.resetCachedMaterial(), i.setEffect(A, a, this._materialContext);
        }
        return !(!i.effect || !i.effect.isReady() || (a._renderId = o.getRenderId(), i.effect._wasPreviouslyReady = !u, i.effect._wasPreviouslyUsingInstances = r, this._checkScenePerformancePriority(), 0));
      }, t.prototype.buildUniformLayout = function() {
        var e = this._uniformBuffer;
        e.addUniform("diffuseLeftColor", 4), e.addUniform("diffuseRightColor", 4), e.addUniform("opacityParts", 4), e.addUniform("reflectionLeftColor", 4), e.addUniform("reflectionRightColor", 4), e.addUniform("refractionLeftColor", 4), e.addUniform("refractionRightColor", 4), e.addUniform("emissiveLeftColor", 4), e.addUniform("emissiveRightColor", 4), e.addUniform("vDiffuseInfos", 2), e.addUniform("vAmbientInfos", 2), e.addUniform("vOpacityInfos", 2), e.addUniform("vReflectionInfos", 2), e.addUniform("vReflectionPosition", 3), e.addUniform("vReflectionSize", 3), e.addUniform("vEmissiveInfos", 2), e.addUniform("vLightmapInfos", 2), e.addUniform("vSpecularInfos", 2), e.addUniform("vBumpInfos", 3), e.addUniform("diffuseMatrix", 16), e.addUniform("ambientMatrix", 16), e.addUniform("opacityMatrix", 16), e.addUniform("reflectionMatrix", 16), e.addUniform("emissiveMatrix", 16), e.addUniform("lightmapMatrix", 16), e.addUniform("specularMatrix", 16), e.addUniform("bumpMatrix", 16), e.addUniform("vTangentSpaceParams", 2), e.addUniform("pointSize", 1), e.addUniform("alphaCutOff", 1), e.addUniform("refractionMatrix", 16), e.addUniform("vRefractionInfos", 4), e.addUniform("vRefractionPosition", 3), e.addUniform("vRefractionSize", 3), e.addUniform("vSpecularColor", 4), e.addUniform("vEmissiveColor", 3), e.addUniform("vDiffuseColor", 4), e.addUniform("vAmbientColor", 3), n.prototype.buildUniformLayout.call(this);
      }, t.prototype.bindForSubMesh = function(e, i, r) {
        var o, a = this.getScene(), s = r.materialDefines;
        if (s) {
          var l = r.effect;
          if (l) {
            this._activeEffect = l, i.getMeshUniformBuffer().bindToEffect(l, "Mesh"), i.transferToEffect(e), this._uniformBuffer.bindToEffect(l, "Material"), this.prePassConfiguration.bindForSubMesh(this._activeEffect, a, i, e, this.isFrozen), this._eventInfo.subMesh = r, this._callbackPluginEventHardBindForSubMesh(this._eventInfo), s.OBJECTSPACE_NORMALMAP && (e.toNormalMatrix(this._normalMatrix), this.bindOnlyNormalMatrix(this._normalMatrix));
            var c = l._forceRebindOnNextCall || this._mustRebind(a, l, i.visibility);
            Se.BindBonesParameters(i, l);
            var u = this._uniformBuffer;
            if (c) {
              if (this.bindViewProjection(l), !u.useUbo || !this.isFrozen || !u.isSync || l._forceRebindOnNextCall) {
                if (t.FresnelEnabled && s.FRESNEL && (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled && (u.updateColor4("diffuseLeftColor", this.diffuseFresnelParameters.leftColor, this.diffuseFresnelParameters.power), u.updateColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias)), this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled && u.updateColor4("opacityParts", new ne(this.opacityFresnelParameters.leftColor.toLuminance(), this.opacityFresnelParameters.rightColor.toLuminance(), this.opacityFresnelParameters.bias), this.opacityFresnelParameters.power), this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled && (u.updateColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power), u.updateColor4("reflectionRightColor", this.reflectionFresnelParameters.rightColor, this.reflectionFresnelParameters.bias)), this.refractionFresnelParameters && this.refractionFresnelParameters.isEnabled && (u.updateColor4("refractionLeftColor", this.refractionFresnelParameters.leftColor, this.refractionFresnelParameters.power), u.updateColor4("refractionRightColor", this.refractionFresnelParameters.rightColor, this.refractionFresnelParameters.bias)), this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled && (u.updateColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power), u.updateColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias))), a.texturesEnabled) {
                  if (this._diffuseTexture && t.DiffuseTextureEnabled && (u.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level), Se.BindTextureMatrix(this._diffuseTexture, u, "diffuse")), this._ambientTexture && t.AmbientTextureEnabled && (u.updateFloat2("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level), Se.BindTextureMatrix(this._ambientTexture, u, "ambient")), this._opacityTexture && t.OpacityTextureEnabled && (u.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level), Se.BindTextureMatrix(this._opacityTexture, u, "opacity")), this._hasAlphaChannel() && u.updateFloat("alphaCutOff", this.alphaCutOff), this._reflectionTexture && t.ReflectionTextureEnabled && (u.updateFloat2("vReflectionInfos", this._reflectionTexture.level, this.roughness), u.updateMatrix("reflectionMatrix", this._reflectionTexture.getReflectionTextureMatrix()), this._reflectionTexture.boundingBoxSize)) {
                    var h = this._reflectionTexture;
                    u.updateVector3("vReflectionPosition", h.boundingBoxPosition), u.updateVector3("vReflectionSize", h.boundingBoxSize);
                  }
                  if (this._emissiveTexture && t.EmissiveTextureEnabled && (u.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level), Se.BindTextureMatrix(this._emissiveTexture, u, "emissive")), this._lightmapTexture && t.LightmapTextureEnabled && (u.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level), Se.BindTextureMatrix(this._lightmapTexture, u, "lightmap")), this._specularTexture && t.SpecularTextureEnabled && (u.updateFloat2("vSpecularInfos", this._specularTexture.coordinatesIndex, this._specularTexture.level), Se.BindTextureMatrix(this._specularTexture, u, "specular")), this._bumpTexture && a.getEngine().getCaps().standardDerivatives && t.BumpTextureEnabled && (u.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1 / this._bumpTexture.level, this.parallaxScaleBias), Se.BindTextureMatrix(this._bumpTexture, u, "bump"), a._mirroredCameraPosition ? u.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1 : -1, this._invertNormalMapY ? 1 : -1) : u.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1 : 1, this._invertNormalMapY ? -1 : 1)), this._refractionTexture && t.RefractionTextureEnabled) {
                    var d = 1;
                    this._refractionTexture.isCube || (u.updateMatrix("refractionMatrix", this._refractionTexture.getReflectionTextureMatrix()), this._refractionTexture.depth && (d = this._refractionTexture.depth)), u.updateFloat4("vRefractionInfos", this._refractionTexture.level, this.indexOfRefraction, d, this.invertRefractionY ? -1 : 1), this._refractionTexture.boundingBoxSize && (h = this._refractionTexture, u.updateVector3("vRefractionPosition", h.boundingBoxPosition), u.updateVector3("vRefractionSize", h.boundingBoxSize));
                  }
                }
                this.pointsCloud && u.updateFloat("pointSize", this.pointSize), s.SPECULARTERM && u.updateColor4("vSpecularColor", this.specularColor, this.specularPower), u.updateColor3("vEmissiveColor", t.EmissiveTextureEnabled ? this.emissiveColor : ne.BlackReadOnly), u.updateColor4("vDiffuseColor", this.diffuseColor, this.alpha), a.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor), u.updateColor3("vAmbientColor", this._globalAmbientColor);
              }
              a.texturesEnabled && (this._diffuseTexture && t.DiffuseTextureEnabled && l.setTexture("diffuseSampler", this._diffuseTexture), this._ambientTexture && t.AmbientTextureEnabled && l.setTexture("ambientSampler", this._ambientTexture), this._opacityTexture && t.OpacityTextureEnabled && l.setTexture("opacitySampler", this._opacityTexture), this._reflectionTexture && t.ReflectionTextureEnabled && (this._reflectionTexture.isCube ? l.setTexture("reflectionCubeSampler", this._reflectionTexture) : l.setTexture("reflection2DSampler", this._reflectionTexture)), this._emissiveTexture && t.EmissiveTextureEnabled && l.setTexture("emissiveSampler", this._emissiveTexture), this._lightmapTexture && t.LightmapTextureEnabled && l.setTexture("lightmapSampler", this._lightmapTexture), this._specularTexture && t.SpecularTextureEnabled && l.setTexture("specularSampler", this._specularTexture), this._bumpTexture && a.getEngine().getCaps().standardDerivatives && t.BumpTextureEnabled && l.setTexture("bumpSampler", this._bumpTexture), this._refractionTexture && t.RefractionTextureEnabled && (this._refractionTexture.isCube ? l.setTexture("refractionCubeSampler", this._refractionTexture) : l.setTexture("refraction2DSampler", this._refractionTexture))), this.getScene().useOrderIndependentTransparency && this.needAlphaBlendingForMesh(i) && this.getScene().depthPeelingRenderer.bind(l), this._eventInfo.subMesh = r, this._callbackPluginEventBindForSubMesh(this._eventInfo), Ar(l, this, a), this.bindEyePosition(l);
            } else
              a.getEngine()._features.needToAlwaysBindUniformBuffers && (this._needToBindSceneUbo = !0);
            !c && this.isFrozen || (a.lightsEnabled && !this._disableLighting && Se.BindLights(a, i, l, s, this._maxSimultaneousLights), (a.fogEnabled && i.applyFog && a.fogMode !== Ue.FOGMODE_NONE || this._reflectionTexture || this._refractionTexture || i.receiveShadows || s.PREPASS) && this.bindView(l), Se.BindFogParameters(a, i, l), s.NUM_MORPH_INFLUENCERS && Se.BindMorphTargetParameters(i, l), s.BAKED_VERTEX_ANIMATION_TEXTURE && ((o = i.bakedVertexAnimationManager) === null || o === void 0 || o.bind(l, s.INSTANCES)), this.useLogarithmicDepth && Se.BindLogDepth(s, l, a), this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess && this._imageProcessingConfiguration.bind(this._activeEffect)), this._afterBind(i, this._activeEffect), u.update();
          }
        }
      }, t.prototype.getAnimatables = function() {
        var e = n.prototype.getAnimatables.call(this);
        return this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0 && e.push(this._diffuseTexture), this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0 && e.push(this._ambientTexture), this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0 && e.push(this._opacityTexture), this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0 && e.push(this._reflectionTexture), this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0 && e.push(this._emissiveTexture), this._specularTexture && this._specularTexture.animations && this._specularTexture.animations.length > 0 && e.push(this._specularTexture), this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0 && e.push(this._bumpTexture), this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0 && e.push(this._lightmapTexture), this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0 && e.push(this._refractionTexture), e;
      }, t.prototype.getActiveTextures = function() {
        var e = n.prototype.getActiveTextures.call(this);
        return this._diffuseTexture && e.push(this._diffuseTexture), this._ambientTexture && e.push(this._ambientTexture), this._opacityTexture && e.push(this._opacityTexture), this._reflectionTexture && e.push(this._reflectionTexture), this._emissiveTexture && e.push(this._emissiveTexture), this._specularTexture && e.push(this._specularTexture), this._bumpTexture && e.push(this._bumpTexture), this._lightmapTexture && e.push(this._lightmapTexture), this._refractionTexture && e.push(this._refractionTexture), e;
      }, t.prototype.hasTexture = function(e) {
        return !!n.prototype.hasTexture.call(this, e) || this._diffuseTexture === e || this._ambientTexture === e || this._opacityTexture === e || this._reflectionTexture === e || this._emissiveTexture === e || this._specularTexture === e || this._bumpTexture === e || this._lightmapTexture === e || this._refractionTexture === e;
      }, t.prototype.dispose = function(e, i) {
        var r, o, a, s, l, c, u, h, d;
        i && ((r = this._diffuseTexture) === null || r === void 0 || r.dispose(), (o = this._ambientTexture) === null || o === void 0 || o.dispose(), (a = this._opacityTexture) === null || a === void 0 || a.dispose(), (s = this._reflectionTexture) === null || s === void 0 || s.dispose(), (l = this._emissiveTexture) === null || l === void 0 || l.dispose(), (c = this._specularTexture) === null || c === void 0 || c.dispose(), (u = this._bumpTexture) === null || u === void 0 || u.dispose(), (h = this._lightmapTexture) === null || h === void 0 || h.dispose(), (d = this._refractionTexture) === null || d === void 0 || d.dispose()), this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver), n.prototype.dispose.call(this, e, i);
      }, t.prototype.clone = function(e, i, r) {
        var o = this;
        i === void 0 && (i = !0), r === void 0 && (r = "");
        var a = Ne.Clone(function() {
          return new t(e, o.getScene());
        }, this, { cloneTexturesOnlyOnce: i });
        return a.name = e, a.id = e, this.stencil.copyTo(a.stencil), this._clonePlugins(a, r), a;
      }, t.Parse = function(e, i, r) {
        var o = Ne.Parse(function() {
          return new t(e.name, i);
        }, e, i, r);
        return e.stencil && o.stencil.parse(e.stencil, i, r), Et._parsePlugins(e, o, i, r), o;
      }, Object.defineProperty(t, "DiffuseTextureEnabled", { get: function() {
        return Pe.DiffuseTextureEnabled;
      }, set: function(e) {
        Pe.DiffuseTextureEnabled = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "DetailTextureEnabled", { get: function() {
        return Pe.DetailTextureEnabled;
      }, set: function(e) {
        Pe.DetailTextureEnabled = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "AmbientTextureEnabled", { get: function() {
        return Pe.AmbientTextureEnabled;
      }, set: function(e) {
        Pe.AmbientTextureEnabled = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "OpacityTextureEnabled", { get: function() {
        return Pe.OpacityTextureEnabled;
      }, set: function(e) {
        Pe.OpacityTextureEnabled = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "ReflectionTextureEnabled", { get: function() {
        return Pe.ReflectionTextureEnabled;
      }, set: function(e) {
        Pe.ReflectionTextureEnabled = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "EmissiveTextureEnabled", { get: function() {
        return Pe.EmissiveTextureEnabled;
      }, set: function(e) {
        Pe.EmissiveTextureEnabled = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "SpecularTextureEnabled", { get: function() {
        return Pe.SpecularTextureEnabled;
      }, set: function(e) {
        Pe.SpecularTextureEnabled = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "BumpTextureEnabled", { get: function() {
        return Pe.BumpTextureEnabled;
      }, set: function(e) {
        Pe.BumpTextureEnabled = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "LightmapTextureEnabled", { get: function() {
        return Pe.LightmapTextureEnabled;
      }, set: function(e) {
        Pe.LightmapTextureEnabled = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "RefractionTextureEnabled", { get: function() {
        return Pe.RefractionTextureEnabled;
      }, set: function(e) {
        Pe.RefractionTextureEnabled = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "ColorGradingTextureEnabled", { get: function() {
        return Pe.ColorGradingTextureEnabled;
      }, set: function(e) {
        Pe.ColorGradingTextureEnabled = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "FresnelEnabled", { get: function() {
        return Pe.FresnelEnabled;
      }, set: function(e) {
        Pe.FresnelEnabled = e;
      }, enumerable: !1, configurable: !0 }), x([St("diffuseTexture")], t.prototype, "_diffuseTexture", void 0), x([ye("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "diffuseTexture", void 0), x([St("ambientTexture")], t.prototype, "_ambientTexture", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientTexture", void 0), x([St("opacityTexture")], t.prototype, "_opacityTexture", void 0), x([ye("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "opacityTexture", void 0), x([St("reflectionTexture")], t.prototype, "_reflectionTexture", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionTexture", void 0), x([St("emissiveTexture")], t.prototype, "_emissiveTexture", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveTexture", void 0), x([St("specularTexture")], t.prototype, "_specularTexture", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "specularTexture", void 0), x([St("bumpTexture")], t.prototype, "_bumpTexture", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "bumpTexture", void 0), x([St("lightmapTexture")], t.prototype, "_lightmapTexture", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "lightmapTexture", void 0), x([St("refractionTexture")], t.prototype, "_refractionTexture", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "refractionTexture", void 0), x([ri("ambient")], t.prototype, "ambientColor", void 0), x([ri("diffuse")], t.prototype, "diffuseColor", void 0), x([ri("specular")], t.prototype, "specularColor", void 0), x([ri("emissive")], t.prototype, "emissiveColor", void 0), x([N()], t.prototype, "specularPower", void 0), x([N("useAlphaFromDiffuseTexture")], t.prototype, "_useAlphaFromDiffuseTexture", void 0), x([ye("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "useAlphaFromDiffuseTexture", void 0), x([N("useEmissiveAsIllumination")], t.prototype, "_useEmissiveAsIllumination", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useEmissiveAsIllumination", void 0), x([N("linkEmissiveWithDiffuse")], t.prototype, "_linkEmissiveWithDiffuse", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "linkEmissiveWithDiffuse", void 0), x([N("useSpecularOverAlpha")], t.prototype, "_useSpecularOverAlpha", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useSpecularOverAlpha", void 0), x([N("useReflectionOverAlpha")], t.prototype, "_useReflectionOverAlpha", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useReflectionOverAlpha", void 0), x([N("disableLighting")], t.prototype, "_disableLighting", void 0), x([ye("_markAllSubMeshesAsLightsDirty")], t.prototype, "disableLighting", void 0), x([N("useObjectSpaceNormalMap")], t.prototype, "_useObjectSpaceNormalMap", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useObjectSpaceNormalMap", void 0), x([N("useParallax")], t.prototype, "_useParallax", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useParallax", void 0), x([N("useParallaxOcclusion")], t.prototype, "_useParallaxOcclusion", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useParallaxOcclusion", void 0), x([N()], t.prototype, "parallaxScaleBias", void 0), x([N("roughness")], t.prototype, "_roughness", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "roughness", void 0), x([N()], t.prototype, "indexOfRefraction", void 0), x([N()], t.prototype, "invertRefractionY", void 0), x([N()], t.prototype, "alphaCutOff", void 0), x([N("useLightmapAsShadowmap")], t.prototype, "_useLightmapAsShadowmap", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useLightmapAsShadowmap", void 0), x([Jo("diffuseFresnelParameters")], t.prototype, "_diffuseFresnelParameters", void 0), x([ye("_markAllSubMeshesAsFresnelDirty")], t.prototype, "diffuseFresnelParameters", void 0), x([Jo("opacityFresnelParameters")], t.prototype, "_opacityFresnelParameters", void 0), x([ye("_markAllSubMeshesAsFresnelAndMiscDirty")], t.prototype, "opacityFresnelParameters", void 0), x([Jo("reflectionFresnelParameters")], t.prototype, "_reflectionFresnelParameters", void 0), x([ye("_markAllSubMeshesAsFresnelDirty")], t.prototype, "reflectionFresnelParameters", void 0), x([Jo("refractionFresnelParameters")], t.prototype, "_refractionFresnelParameters", void 0), x([ye("_markAllSubMeshesAsFresnelDirty")], t.prototype, "refractionFresnelParameters", void 0), x([Jo("emissiveFresnelParameters")], t.prototype, "_emissiveFresnelParameters", void 0), x([ye("_markAllSubMeshesAsFresnelDirty")], t.prototype, "emissiveFresnelParameters", void 0), x([N("useReflectionFresnelFromSpecular")], t.prototype, "_useReflectionFresnelFromSpecular", void 0), x([ye("_markAllSubMeshesAsFresnelDirty")], t.prototype, "useReflectionFresnelFromSpecular", void 0), x([N("useGlossinessFromSpecularMapAlpha")], t.prototype, "_useGlossinessFromSpecularMapAlpha", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useGlossinessFromSpecularMapAlpha", void 0), x([N("maxSimultaneousLights")], t.prototype, "_maxSimultaneousLights", void 0), x([ye("_markAllSubMeshesAsLightsDirty")], t.prototype, "maxSimultaneousLights", void 0), x([N("invertNormalMapX")], t.prototype, "_invertNormalMapX", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapX", void 0), x([N("invertNormalMapY")], t.prototype, "_invertNormalMapY", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapY", void 0), x([N("twoSidedLighting")], t.prototype, "_twoSidedLighting", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "twoSidedLighting", void 0), x([N("applyDecalMapAfterDetailMap")], t.prototype, "_applyDecalMapAfterDetailMap", void 0), x([ye("_markAllSubMeshesAsMiscDirty")], t.prototype, "applyDecalMapAfterDetailMap", void 0), x([N()], t.prototype, "useLogarithmicDepth", null), t;
    }(pl);
    j("BABYLON.StandardMaterial", Gt), Ue.DefaultMaterialFactory = function(n) {
      return new Gt("default material", n);
    }, Qe.prototype.createDynamicTexture = function(n, t, e, i) {
      var r = new Ut(this, ut.Dynamic);
      return r.baseWidth = n, r.baseHeight = t, e && (n = this.needPOTTextures ? Qe.GetExponentOfTwo(n, this._caps.maxTextureSize) : n, t = this.needPOTTextures ? Qe.GetExponentOfTwo(t, this._caps.maxTextureSize) : t), r.width = n, r.height = t, r.isReady = !1, r.generateMipMaps = e, r.samplingMode = i, this.updateTextureSamplingMode(i, r), this._internalTexturesCache.push(r), r;
    }, Qe.prototype.updateDynamicTexture = function(n, t, e, i, r, o, a) {
      if (i === void 0 && (i = !1), o === void 0 && (o = !1), n) {
        var s = this._gl, l = s.TEXTURE_2D, c = this._bindTextureDirectly(l, n, !0, o);
        this._unpackFlipY(e === void 0 ? n.invertY : e), i && s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
        var u = this._getWebGLTextureType(n.type), h = this._getInternalFormat(r || n.format), d = this._getRGBABufferInternalSizedFormat(n.type, h);
        s.texImage2D(l, 0, d, h, u, t), n.generateMipMaps && s.generateMipmap(l), c || this._bindTextureDirectly(l, null), i && s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0), n.isReady = !0;
      }
    };
    var Xi, Ts, Es = function(n) {
      function t(e, i, r, o, a, s, l) {
        r === void 0 && (r = null), o === void 0 && (o = !1), a === void 0 && (a = _.TEXTURE_TRILINEAR_SAMPLINGMODE), s === void 0 && (s = _.TEXTUREFORMAT_RGBA);
        var c = n.call(this, null, r, !o, l, a, void 0, void 0, void 0, void 0, s) || this;
        c.name = e, c.wrapU = ae.CLAMP_ADDRESSMODE, c.wrapV = ae.CLAMP_ADDRESSMODE, c._generateMipMaps = o;
        var u = c._getEngine();
        if (!u)
          return c;
        i.getContext ? (c._canvas = i, c._texture = u.createDynamicTexture(i.width, i.height, o, a)) : (c._canvas = u.createCanvas(1, 1), i.width || i.width === 0 ? c._texture = u.createDynamicTexture(i.width, i.height, o, a) : c._texture = u.createDynamicTexture(i, i, o, a));
        var h = c.getSize();
        return c._canvas.width !== h.width && (c._canvas.width = h.width), c._canvas.height !== h.height && (c._canvas.height = h.height), c._context = c._canvas.getContext("2d"), c;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "DynamicTexture";
      }, Object.defineProperty(t.prototype, "canRescale", { get: function() {
        return !0;
      }, enumerable: !1, configurable: !0 }), t.prototype._recreate = function(e) {
        this._canvas.width = e.width, this._canvas.height = e.height, this.releaseInternalTexture(), this._texture = this._getEngine().createDynamicTexture(e.width, e.height, this._generateMipMaps, this.samplingMode);
      }, t.prototype.scale = function(e) {
        var i = this.getSize();
        i.width *= e, i.height *= e, this._recreate(i);
      }, t.prototype.scaleTo = function(e, i) {
        var r = this.getSize();
        r.width = e, r.height = i, this._recreate(r);
      }, t.prototype.getContext = function() {
        return this._context;
      }, t.prototype.clear = function(e) {
        var i = this.getSize();
        e && (this._context.fillStyle = e), this._context.clearRect(0, 0, i.width, i.height);
      }, t.prototype.update = function(e, i, r) {
        i === void 0 && (i = !1), r === void 0 && (r = !1), this._getEngine().updateDynamicTexture(this._texture, this._canvas, e === void 0 || e, i, this._format || void 0, void 0, r);
      }, t.prototype.drawText = function(e, i, r, o, a, s, l, c) {
        c === void 0 && (c = !0);
        var u = this.getSize();
        if (s && (this._context.fillStyle = s, this._context.fillRect(0, 0, u.width, u.height)), this._context.font = o, i == null) {
          var h = this._context.measureText(e);
          i = (u.width - h.width) / 2;
        }
        if (r == null) {
          var d = parseInt(o.replace(/\D/g, ""));
          r = u.height / 2 + d / 3.65;
        }
        this._context.fillStyle = a || "", this._context.fillText(e, i, r), c && this.update(l);
      }, t.prototype.clone = function() {
        var e = this.getScene();
        if (!e)
          return this;
        var i = this.getSize(), r = new t(this.name, i, e, this._generateMipMaps);
        return r.hasAlpha = this.hasAlpha, r.level = this.level, r.wrapU = this.wrapU, r.wrapV = this.wrapV, r;
      }, t.prototype.serialize = function() {
        var e = this.getScene();
        e && !e.isReady() && q.Warn("The scene must be ready before serializing the dynamic texture");
        var i = n.prototype.serialize.call(this);
        return t._IsCanvasElement(this._canvas) && (i.base64String = this._canvas.toDataURL()), i.invertY = this._invertY, i.samplingMode = this.samplingMode, i;
      }, t._IsCanvasElement = function(e) {
        return e.toDataURL !== void 0;
      }, t.prototype._rebuild = function() {
        this.update();
      }, t;
    }(ae), vv = function() {
      function n(t, e, i, r, o) {
        this.getWidth = t, this.getHeight = e, this.layer = i, this.layerType = r, this.createRenderTargetTextureProvider = o;
      }
      return Object.defineProperty(n.prototype, "isFixedFoveationSupported", { get: function() {
        return this.layerType == "XRWebGLLayer" && typeof this.layer.fixedFoveation == "number";
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "fixedFoveation", { get: function() {
        return this.isFixedFoveationSupported ? this.layer.fixedFoveation : null;
      }, set: function(t) {
        if (this.isFixedFoveationSupported) {
          var e = Math.max(0, Math.min(1, t || 0));
          this.layer.fixedFoveation = e;
        }
      }, enumerable: !1, configurable: !0 }), n;
    }(), yv = function() {
      function n(t, e) {
        this._scene = t, this.layerWrapper = e, this._renderTargetTextures = new Array(), this._engine = t.getEngine();
      }
      return n.prototype._createInternalTexture = function(t, e) {
        var i = new Ut(this._engine, ut.Unknown, !0);
        return i.width = t.width, i.height = t.height, i._hardwareTexture = new ds(e, this._engine._gl), i.isReady = !0, i;
      }, n.prototype._createRenderTargetTexture = function(t, e, i, r, o, a) {
        if (!this._engine)
          throw new Error("Engine is disposed");
        var s = { width: t, height: e }, l = a ? new lv(this._scene, s) : new Mi("XR renderTargetTexture", s, this._scene), c = l.renderTarget;
        if (c._samples = l.samples, !i && r || (c._framebuffer = i), r)
          if (a)
            c._colorTextureArray = r;
          else {
            var u = this._createInternalTexture(s, r);
            c.setTexture(u, 0), l._texture = u;
          }
        return o && (a ? c._depthStencilTextureArray = o : c._depthStencilTexture = this._createInternalTexture(s, o)), l.disableRescaling(), typeof XRWebGLBinding < "u" && (l.skipInitialClear = !0), this._renderTargetTextures.push(l), l;
      }, n.prototype._destroyRenderTargetTexture = function(t) {
        this._renderTargetTextures.splice(this._renderTargetTextures.indexOf(t), 1), t.dispose();
      }, n.prototype.getFramebufferDimensions = function() {
        return this._framebufferDimensions;
      }, n.prototype.dispose = function() {
        this._renderTargetTextures.forEach(function(t) {
          return t.dispose();
        }), this._renderTargetTextures.length = 0;
      }, n;
    }(), bv = function(n) {
      function t(e) {
        var i = n.call(this, function() {
          return e.framebufferWidth;
        }, function() {
          return e.framebufferHeight;
        }, e, "XRWebGLLayer", function(r) {
          return new j1(r.scene, i);
        }) || this;
        return i.layer = e, i;
      }
      return D(t, n), t;
    }(vv), j1 = function(n) {
      function t(e, i) {
        var r = n.call(this, e, i) || this;
        return r.layerWrapper = i, r._layer = i.layer, r._framebufferDimensions = { framebufferWidth: r._layer.framebufferWidth, framebufferHeight: r._layer.framebufferHeight }, r;
      }
      return D(t, n), t.prototype.trySetViewportForView = function(e, i) {
        var r = this._layer.getViewport(i);
        if (!r)
          return !1;
        var o = this._framebufferDimensions.framebufferWidth, a = this._framebufferDimensions.framebufferHeight;
        return e.x = r.x / o, e.y = r.y / a, e.width = r.width / o, e.height = r.height / a, !0;
      }, t.prototype.getRenderTargetTextureForEye = function(e) {
        var i = this._layer.framebufferWidth, r = this._layer.framebufferHeight, o = this._layer.framebuffer;
        return this._rtt && i === this._framebufferDimensions.framebufferWidth && r === this._framebufferDimensions.framebufferHeight && o === this._framebuffer || (this._rtt = this._createRenderTargetTexture(i, r, o), this._framebufferDimensions.framebufferWidth = i, this._framebufferDimensions.framebufferHeight = r, this._framebuffer = o), this._rtt;
      }, t.prototype.getRenderTargetTextureForView = function(e) {
        return this.getRenderTargetTextureForEye(e.eye);
      }, t;
    }(yv), pf = function() {
      function n() {
      }
      return n.GetDefaults = function(t) {
        var e = new n();
        return e.canvasOptions = { antialias: !0, depth: !0, stencil: !t || t.isStencilEnable, alpha: !0, framebufferScaleFactor: 1 }, e.newCanvasCssStyle = "position:absolute; bottom:0px;right:0px;z-index:10;width:90%;height:100%;background-color: #000000;", e;
      }, n;
    }(), Tv = function() {
      function n(t, e) {
        e === void 0 && (e = pf.GetDefaults());
        var i = this;
        if (this._options = e, this._canvas = null, this._engine = null, this.xrLayer = null, this._xrLayerWrapper = null, this.onXRLayerInitObservable = new H(), this._engine = t.scene.getEngine(), this._engine.onDisposeObservable.addOnce(function() {
          i._engine = null;
        }), e.canvasElement)
          this._setManagedOutputCanvas(e.canvasElement);
        else {
          var r = document.createElement("canvas");
          r.style.cssText = this._options.newCanvasCssStyle || "position:absolute; bottom:0px;right:0px;", this._setManagedOutputCanvas(r);
        }
        t.onXRSessionInit.add(function() {
          i._addCanvas();
        }), t.onXRSessionEnded.add(function() {
          i._removeCanvas();
        });
      }
      return n.prototype.dispose = function() {
        this._removeCanvas(), this._setManagedOutputCanvas(null);
      }, n.prototype.initializeXRLayerAsync = function(t) {
        return Ft(this, void 0, void 0, function() {
          var e, i = this;
          return Bt(this, function(r) {
            return e = function() {
              return i.xrLayer = new XRWebGLLayer(t, i.canvasContext, i._options.canvasOptions), i._xrLayerWrapper = new bv(i.xrLayer), i.onXRLayerInitObservable.notifyObservers(i.xrLayer), i.xrLayer;
            }, this.canvasContext.makeXRCompatible ? [2, this.canvasContext.makeXRCompatible().then(function() {
            }, function() {
              de.Warn("Error executing makeXRCompatible. This does not mean that the session will work incorrectly.");
            }).then(function() {
              return e();
            })] : [2, Promise.resolve(e())];
          });
        });
      }, n.prototype._addCanvas = function() {
        var t = this;
        this._canvas && this._engine && this._canvas !== this._engine.getRenderingCanvas() && document.body.appendChild(this._canvas), this.xrLayer ? this._setCanvasSize(!0) : this.onXRLayerInitObservable.addOnce(function() {
          t._setCanvasSize(!0);
        });
      }, n.prototype._removeCanvas = function() {
        this._canvas && this._engine && document.body.contains(this._canvas) && this._canvas !== this._engine.getRenderingCanvas() && document.body.removeChild(this._canvas), this._setCanvasSize(!1);
      }, n.prototype._setCanvasSize = function(t, e) {
        t === void 0 && (t = !0), e === void 0 && (e = this._xrLayerWrapper), this._canvas && this._engine && (t ? e && (this._canvas !== this._engine.getRenderingCanvas() ? (this._canvas.style.width = e.getWidth() + "px", this._canvas.style.height = e.getHeight() + "px") : this._engine.setSize(e.getWidth(), e.getHeight())) : this._originalCanvasSize && (this._canvas !== this._engine.getRenderingCanvas() ? (this._canvas.style.width = this._originalCanvasSize.width + "px", this._canvas.style.height = this._originalCanvasSize.height + "px") : this._engine.setSize(this._originalCanvasSize.width, this._originalCanvasSize.height)));
      }, n.prototype._setManagedOutputCanvas = function(t) {
        this._removeCanvas(), t ? (this._originalCanvasSize = { width: t.offsetWidth, height: t.offsetHeight }, this._canvas = t, this.canvasContext = this._canvas.getContext("webgl2"), this.canvasContext || (this.canvasContext = this._canvas.getContext("webgl"))) : (this._canvas = null, this.canvasContext = null);
      }, n;
    }(), Ev = function(n) {
      function t(e) {
        var i = n.call(this, function() {
          return e.framebufferWidth;
        }, function() {
          return e.framebufferHeight;
        }, e, "XRWebGLLayer", function(r) {
          return new Sv(r, i);
        }) || this;
        return i.layer = e, i;
      }
      return D(t, n), t;
    }(vv), Sv = function(n) {
      function t(e, i) {
        var r = n.call(this, e.scene, i) || this;
        return r.layerWrapper = i, r._nativeRTTProvider = navigator.xr.getNativeRenderTargetProvider(e.session, r._createRenderTargetTexture.bind(r), r._destroyRenderTargetTexture.bind(r)), r._nativeLayer = i.layer, r;
      }
      return D(t, n), t.prototype.trySetViewportForView = function(e) {
        return e.x = 0, e.y = 0, e.width = 1, e.height = 1, !0;
      }, t.prototype.getRenderTargetTextureForEye = function(e) {
        return this._nativeRTTProvider.getRenderTargetForEye(e);
      }, t.prototype.getRenderTargetTextureForView = function(e) {
        return this._nativeRTTProvider.getRenderTargetForEye(e.eye);
      }, t.prototype.getFramebufferDimensions = function() {
        return { framebufferWidth: this._nativeLayer.framebufferWidth, framebufferHeight: this._nativeLayer.framebufferHeight };
      }, t;
    }(yv), xv = function() {
      function n(t) {
        this._nativeRenderTarget = navigator.xr.getWebXRRenderTarget(t.scene.getEngine());
      }
      return n.prototype.initializeXRLayerAsync = function(t) {
        return Ft(this, void 0, void 0, function() {
          return Bt(this, function(e) {
            switch (e.label) {
              case 0:
                return [4, this._nativeRenderTarget.initializeXRLayerAsync(t)];
              case 1:
                return e.sent(), this.xrLayer = this._nativeRenderTarget.xrLayer, [2, this.xrLayer];
            }
          });
        });
      }, n.prototype.dispose = function() {
      }, n;
    }(), ff = function() {
      function n(t) {
        var e = this;
        this.scene = t, this.currentTimestamp = -1, this.defaultHeightCompensation = 1.7, this.onXRFrameObservable = new H(), this.onXRReferenceSpaceChanged = new H(), this.onXRSessionEnded = new H(), this.onXRSessionInit = new H(), this.inXRFrameLoop = !1, this.inXRSession = !1, this._engine = t.getEngine(), this._onEngineDisposedObserver = this._engine.onDisposeObservable.addOnce(function() {
          e._engine = null;
        }), t.onDisposeObservable.addOnce(function() {
          e.dispose();
        });
      }
      return Object.defineProperty(n.prototype, "referenceSpace", { get: function() {
        return this._referenceSpace;
      }, set: function(t) {
        this._referenceSpace = t, this.onXRReferenceSpaceChanged.notifyObservers(this._referenceSpace);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "sessionMode", { get: function() {
        return this._sessionMode;
      }, enumerable: !1, configurable: !0 }), n.prototype.dispose = function() {
        var t;
        this.inXRSession && this.exitXRAsync(), this.onXRFrameObservable.clear(), this.onXRSessionEnded.clear(), this.onXRReferenceSpaceChanged.clear(), this.onXRSessionInit.clear(), (t = this._engine) === null || t === void 0 || t.onDisposeObservable.remove(this._onEngineDisposedObserver), this._engine = null;
      }, n.prototype.exitXRAsync = function() {
        return this.session && this.inXRSession ? (this.inXRSession = !1, this.session.end().catch(function() {
          q.Warn("Could not end XR session.");
        })) : Promise.resolve();
      }, n.prototype.trySetViewportForView = function(t, e) {
        var i;
        return ((i = this._baseLayerRTTProvider) === null || i === void 0 ? void 0 : i.trySetViewportForView(t, e)) || !1;
      }, n.prototype.getRenderTargetTextureForEye = function(t) {
        var e;
        return ((e = this._baseLayerRTTProvider) === null || e === void 0 ? void 0 : e.getRenderTargetTextureForEye(t)) || null;
      }, n.prototype.getRenderTargetTextureForView = function(t) {
        var e;
        return ((e = this._baseLayerRTTProvider) === null || e === void 0 ? void 0 : e.getRenderTargetTextureForView(t)) || null;
      }, n.prototype.getWebXRRenderTarget = function(t) {
        var e = this.scene.getEngine();
        return this._xrNavigator.xr.native ? new xv(this) : ((t = t || pf.GetDefaults(e)).canvasElement = t.canvasElement || e.getRenderingCanvas() || void 0, new Tv(this, t));
      }, n.prototype.initializeAsync = function() {
        return this._xrNavigator = navigator, this._xrNavigator.xr ? Promise.resolve() : Promise.reject("WebXR not available");
      }, n.prototype.initializeSessionAsync = function(t, e) {
        var i = this;
        return t === void 0 && (t = "immersive-vr"), e === void 0 && (e = {}), this._xrNavigator.xr.requestSession(t, e).then(function(r) {
          return i.session = r, i._sessionMode = t, i.onXRSessionInit.notifyObservers(r), i.inXRSession = !0, i.session.addEventListener("end", function() {
            var o;
            i.inXRSession = !1, i.onXRSessionEnded.notifyObservers(null), i._engine && (i._engine.framebufferDimensionsObject = null, i._engine.restoreDefaultFramebuffer(), i._engine.customAnimationFrameRequester = null, i._engine._renderLoop()), i.isNative && ((o = i._baseLayerRTTProvider) === null || o === void 0 || o.dispose()), i._baseLayerRTTProvider = null, i._baseLayerWrapper = null;
          }, { once: !0 }), i.session;
        });
      }, n.prototype.isSessionSupportedAsync = function(t) {
        return n.IsSessionSupportedAsync(t);
      }, n.prototype.resetReferenceSpace = function() {
        this.referenceSpace = this.baseReferenceSpace;
      }, n.prototype.runXRRenderLoop = function() {
        var t, e = this;
        this.inXRSession && this._engine && (this._engine.customAnimationFrameRequester = { requestAnimationFrame: function(i) {
          return e.session.requestAnimationFrame(i);
        }, renderFunction: function(i, r) {
          var o;
          e.inXRSession && e._engine && (e.currentFrame = r, e.currentTimestamp = i, r && (e.inXRFrameLoop = !0, e._engine.framebufferDimensionsObject = ((o = e._baseLayerRTTProvider) === null || o === void 0 ? void 0 : o.getFramebufferDimensions()) || null, e.onXRFrameObservable.notifyObservers(r), e._engine._renderLoop(), e._engine.framebufferDimensionsObject = null, e.inXRFrameLoop = !1));
        } }, this._engine.framebufferDimensionsObject = ((t = this._baseLayerRTTProvider) === null || t === void 0 ? void 0 : t.getFramebufferDimensions()) || null, typeof window < "u" && window.cancelAnimationFrame && window.cancelAnimationFrame(this._engine._frameHandler), this._engine._renderLoop());
      }, n.prototype.setReferenceSpaceTypeAsync = function(t) {
        var e = this;
        return t === void 0 && (t = "local-floor"), this.session.requestReferenceSpace(t).then(function(i) {
          return i;
        }, function(i) {
          return q.Error("XR.requestReferenceSpace failed for the following reason: "), q.Error(i), q.Log('Defaulting to universally-supported "viewer" reference space type.'), e.session.requestReferenceSpace("viewer").then(function(r) {
            var o = new XRRigidTransform({ x: 0, y: -e.defaultHeightCompensation, z: 0 });
            return r.getOffsetReferenceSpace(o);
          }, function(r) {
            throw q.Error(r), 'XR initialization failed: required "viewer" reference space type not supported.';
          });
        }).then(function(i) {
          return e.session.requestReferenceSpace("viewer").then(function(r) {
            return e.viewerReferenceSpace = r, i;
          });
        }).then(function(i) {
          return e.referenceSpace = e.baseReferenceSpace = i, e.referenceSpace;
        });
      }, n.prototype.updateRenderStateAsync = function(t) {
        return Promise.resolve(this.session.updateRenderState(t));
      }, n.prototype._setBaseLayerWrapper = function(t) {
        var e, i;
        this.isNative && ((e = this._baseLayerRTTProvider) === null || e === void 0 || e.dispose()), this._baseLayerWrapper = t, this._baseLayerRTTProvider = ((i = this._baseLayerWrapper) === null || i === void 0 ? void 0 : i.createRenderTargetTextureProvider(this)) || null;
      }, n.prototype._getBaseLayerWrapper = function() {
        return this._baseLayerWrapper;
      }, n.prototype.updateRenderState = function(t) {
        t.baseLayer && this._setBaseLayerWrapper(this.isNative ? new Ev(t.baseLayer) : new bv(t.baseLayer)), this.session.updateRenderState(t);
      }, n.IsSessionSupportedAsync = function(t) {
        if (!navigator.xr)
          return Promise.resolve(!1);
        var e = navigator.xr.isSessionSupported || navigator.xr.supportsSession;
        return e ? e.call(navigator.xr, t).then(function(i) {
          var r = i === void 0 || i;
          return Promise.resolve(r);
        }).catch(function(i) {
          return q.Warn(i), Promise.resolve(!1);
        }) : Promise.resolve(!1);
      }, Object.defineProperty(n.prototype, "isNative", { get: function() {
        var t;
        return (t = this._xrNavigator.xr.native) !== null && t !== void 0 && t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "currentFrameRate", { get: function() {
        var t;
        return (t = this.session) === null || t === void 0 ? void 0 : t.frameRate;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "supportedFrameRates", { get: function() {
        var t;
        return (t = this.session) === null || t === void 0 ? void 0 : t.supportedFrameRates;
      }, enumerable: !1, configurable: !0 }), n.prototype.updateTargetFrameRate = function(t) {
        return this.session.updateTargetFrameRate(t);
      }, n.prototype.runInXRFrame = function(t, e) {
        e === void 0 && (e = !0), this.inXRFrameLoop ? t() : !this.inXRSession && e || this.onXRFrameObservable.addOnce(t);
      }, Object.defineProperty(n.prototype, "isFixedFoveationSupported", { get: function() {
        var t;
        return ((t = this._baseLayerWrapper) === null || t === void 0 ? void 0 : t.isFixedFoveationSupported) || !1;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "fixedFoveation", { get: function() {
        var t;
        return ((t = this._baseLayerWrapper) === null || t === void 0 ? void 0 : t.fixedFoveation) || null;
      }, set: function(t) {
        var e = Math.max(0, Math.min(1, t || 0));
        this._baseLayerWrapper && (this._baseLayerWrapper.fixedFoveation = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "enabledFeatures", { get: function() {
        var t, e;
        return (e = (t = this.session) === null || t === void 0 ? void 0 : t.enabledFeatures) !== null && e !== void 0 ? e : null;
      }, enumerable: !1, configurable: !0 }), n;
    }();
    (function(n) {
      n[n.ENTERING_XR = 0] = "ENTERING_XR", n[n.EXITING_XR = 1] = "EXITING_XR", n[n.IN_XR = 2] = "IN_XR", n[n.NOT_IN_XR = 3] = "NOT_IN_XR";
    })(Xi || (Xi = {})), function(n) {
      n[n.NOT_TRACKING = 0] = "NOT_TRACKING", n[n.TRACKING_LOST = 1] = "TRACKING_LOST", n[n.TRACKING = 2] = "TRACKING";
    }(Ts || (Ts = {})), ie._GroundMeshParser = function(n, t) {
      return ph.Parse(n, t);
    };
    var ph = function(n) {
      function t(e, i) {
        var r = n.call(this, e, i) || this;
        return r.generateOctree = !1, r;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "GroundMesh";
      }, Object.defineProperty(t.prototype, "subdivisions", { get: function() {
        return Math.min(this._subdivisionsX, this._subdivisionsY);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subdivisionsX", { get: function() {
        return this._subdivisionsX;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subdivisionsY", { get: function() {
        return this._subdivisionsY;
      }, enumerable: !1, configurable: !0 }), t.prototype.optimize = function(e, i) {
        i === void 0 && (i = 32), this._subdivisionsX = e, this._subdivisionsY = e, this.subdivide(e), this.createOrUpdateSubmeshesOctree && this.createOrUpdateSubmeshesOctree(i);
      }, t.prototype.getHeightAtCoordinates = function(e, i) {
        var r = this.getWorldMatrix(), o = F.Matrix[5];
        r.invertToRef(o);
        var a = F.Vector3[8];
        if (v.TransformCoordinatesFromFloatsToRef(e, 0, i, o, a), e = a.x, i = a.z, e < this._minX || e >= this._maxX || i <= this._minZ || i > this._maxZ)
          return this.position.y;
        this._heightQuads && this._heightQuads.length != 0 || (this._initHeightQuads(), this._computeHeightQuads());
        var s = this._getFacetAt(e, i), l = -(s.x * e + s.z * i + s.w) / s.y;
        return v.TransformCoordinatesFromFloatsToRef(0, l, 0, r, a), a.y;
      }, t.prototype.getNormalAtCoordinates = function(e, i) {
        var r = new v(0, 1, 0);
        return this.getNormalAtCoordinatesToRef(e, i, r), r;
      }, t.prototype.getNormalAtCoordinatesToRef = function(e, i, r) {
        var o = this.getWorldMatrix(), a = F.Matrix[5];
        o.invertToRef(a);
        var s = F.Vector3[8];
        if (v.TransformCoordinatesFromFloatsToRef(e, 0, i, a, s), e = s.x, i = s.z, e < this._minX || e > this._maxX || i < this._minZ || i > this._maxZ)
          return this;
        this._heightQuads && this._heightQuads.length != 0 || (this._initHeightQuads(), this._computeHeightQuads());
        var l = this._getFacetAt(e, i);
        return v.TransformNormalFromFloatsToRef(l.x, l.y, l.z, o, r), this;
      }, t.prototype.updateCoordinateHeights = function() {
        return this._heightQuads && this._heightQuads.length != 0 || this._initHeightQuads(), this._computeHeightQuads(), this;
      }, t.prototype._getFacetAt = function(e, i) {
        var r = Math.floor((e + this._maxX) * this._subdivisionsX / this._width), o = Math.floor(-(i + this._maxZ) * this._subdivisionsY / this._height + this._subdivisionsY), a = this._heightQuads[o * this._subdivisionsX + r];
        return i < a.slope.x * e + a.slope.y ? a.facet1 : a.facet2;
      }, t.prototype._initHeightQuads = function() {
        var e = this._subdivisionsX, i = this._subdivisionsY;
        this._heightQuads = new Array();
        for (var r = 0; r < i; r++)
          for (var o = 0; o < e; o++) {
            var a = { slope: fe.Zero(), facet1: new lt(0, 0, 0, 0), facet2: new lt(0, 0, 0, 0) };
            this._heightQuads[r * e + o] = a;
          }
        return this;
      }, t.prototype._computeHeightQuads = function() {
        var e = this.getVerticesData(P.PositionKind);
        if (!e)
          return this;
        for (var i = F.Vector3[3], r = F.Vector3[2], o = F.Vector3[1], a = F.Vector3[0], s = F.Vector3[4], l = F.Vector3[5], c = F.Vector3[6], u = F.Vector3[7], h = F.Vector3[8], d = 0, p = 0, f = 0, m = 0, g = 0, y = 0, b = 0, T = this._subdivisionsX, S = this._subdivisionsY, E = 0; E < S; E++)
          for (var A = 0; A < T; A++) {
            d = 3 * A, p = E * (T + 1) * 3, f = (E + 1) * (T + 1) * 3, i.x = e[p + d], i.y = e[p + d + 1], i.z = e[p + d + 2], r.x = e[p + d + 3], r.y = e[p + d + 4], r.z = e[p + d + 5], o.x = e[f + d], o.y = e[f + d + 1], o.z = e[f + d + 2], a.x = e[f + d + 3], a.y = e[f + d + 4], a.z = e[f + d + 5], m = (a.z - i.z) / (a.x - i.x), g = i.z - m * i.x, r.subtractToRef(i, s), o.subtractToRef(i, l), a.subtractToRef(i, c), v.CrossToRef(c, l, u), v.CrossToRef(s, c, h), u.normalize(), h.normalize(), y = -(u.x * i.x + u.y * i.y + u.z * i.z), b = -(h.x * r.x + h.y * r.y + h.z * r.z);
            var R = this._heightQuads[E * T + A];
            R.slope.copyFromFloats(m, g), R.facet1.copyFromFloats(u.x, u.y, u.z, y), R.facet2.copyFromFloats(h.x, h.y, h.z, b);
          }
        return this;
      }, t.prototype.serialize = function(e) {
        n.prototype.serialize.call(this, e), e.subdivisionsX = this._subdivisionsX, e.subdivisionsY = this._subdivisionsY, e.minX = this._minX, e.maxX = this._maxX, e.minZ = this._minZ, e.maxZ = this._maxZ, e.width = this._width, e.height = this._height;
      }, t.Parse = function(e, i) {
        var r = new t(e.name, i);
        return r._subdivisionsX = e.subdivisionsX || 1, r._subdivisionsY = e.subdivisionsY || 1, r._minX = e.minX, r._maxX = e.maxX, r._minZ = e.minZ, r._maxZ = e.maxZ, r._width = e.width, r._height = e.height, r;
      }, t;
    }(ie);
    function Do(n) {
      var t, e, i = [], r = [], o = [], a = [], s = n.width || 1, l = n.height || 1, c = 0 | (n.subdivisionsX || n.subdivisions || 1), u = 0 | (n.subdivisionsY || n.subdivisions || 1);
      for (t = 0; t <= u; t++)
        for (e = 0; e <= c; e++) {
          var h = new v(e * s / c - s / 2, 0, (u - t) * l / u - l / 2), d = new v(0, 1, 0);
          r.push(h.x, h.y, h.z), o.push(d.x, d.y, d.z), a.push(e / c, Lt.UseOpenGLOrientationForUV ? t / u : 1 - t / u);
        }
      for (t = 0; t < u; t++)
        for (e = 0; e < c; e++)
          i.push(e + 1 + (t + 1) * (c + 1)), i.push(e + 1 + t * (c + 1)), i.push(e + t * (c + 1)), i.push(e + (t + 1) * (c + 1)), i.push(e + 1 + (t + 1) * (c + 1)), i.push(e + t * (c + 1));
      var p = new Oe();
      return p.indices = i, p.positions = r, p.normals = o, p.uvs = a, p;
    }
    function _f(n) {
      var t, e, i, r, o = n.xmin !== void 0 && n.xmin !== null ? n.xmin : -1, a = n.zmin !== void 0 && n.zmin !== null ? n.zmin : -1, s = n.xmax !== void 0 && n.xmax !== null ? n.xmax : 1, l = n.zmax !== void 0 && n.zmax !== null ? n.zmax : 1, c = n.subdivisions || { w: 1, h: 1 }, u = n.precision || { w: 1, h: 1 }, h = [], d = [], p = [], f = [];
      c.h = c.h < 1 ? 1 : c.h, c.w = c.w < 1 ? 1 : c.w, u.w = u.w < 1 ? 1 : u.w, u.h = u.h < 1 ? 1 : u.h;
      var m = (s - o) / c.w, g = (l - a) / c.h;
      function y(T, S, E, A) {
        var R = d.length / 3, C = u.w + 1;
        for (t = 0; t < u.h; t++)
          for (e = 0; e < u.w; e++) {
            var L = [R + e + t * C, R + (e + 1) + t * C, R + (e + 1) + (t + 1) * C, R + e + (t + 1) * C];
            h.push(L[1]), h.push(L[2]), h.push(L[3]), h.push(L[0]), h.push(L[1]), h.push(L[3]);
          }
        var I = v.Zero(), O = new v(0, 1, 0);
        for (t = 0; t <= u.h; t++)
          for (I.z = t * (A - S) / u.h + S, e = 0; e <= u.w; e++)
            I.x = e * (E - T) / u.w + T, I.y = 0, d.push(I.x, I.y, I.z), p.push(O.x, O.y, O.z), f.push(e / u.w, t / u.h);
      }
      for (i = 0; i < c.h; i++)
        for (r = 0; r < c.w; r++)
          y(o + r * m, a + i * g, o + (r + 1) * m, a + (i + 1) * g);
      var b = new Oe();
      return b.indices = h, b.positions = d, b.normals = p, b.uvs = f, b;
    }
    function mf(n) {
      var t, e, i = [], r = [], o = [], a = [], s = n.colorFilter || new ne(0.3, 0.59, 0.11), l = n.alphaFilter || 0, c = !1;
      if (n.minHeight > n.maxHeight) {
        c = !0;
        var u = n.maxHeight;
        n.maxHeight = n.minHeight, n.minHeight = u;
      }
      for (t = 0; t <= n.subdivisions; t++)
        for (e = 0; e <= n.subdivisions; e++) {
          var h = new v(e * n.width / n.subdivisions - n.width / 2, 0, (n.subdivisions - t) * n.height / n.subdivisions - n.height / 2), d = 4 * (((h.x + n.width / 2) / n.width * (n.bufferWidth - 1) | 0) + ((1 - (h.z + n.height / 2) / n.height) * (n.bufferHeight - 1) | 0) * n.bufferWidth), p = n.buffer[d] / 255, f = n.buffer[d + 1] / 255, m = n.buffer[d + 2] / 255, g = n.buffer[d + 3] / 255;
          c && (p = 1 - p, f = 1 - f, m = 1 - m);
          var y = p * s.r + f * s.g + m * s.b;
          h.y = g >= l ? n.minHeight + (n.maxHeight - n.minHeight) * y : n.minHeight - Ge, r.push(h.x, h.y, h.z), o.push(0, 0, 0), a.push(e / n.subdivisions, 1 - t / n.subdivisions);
        }
      for (t = 0; t < n.subdivisions; t++)
        for (e = 0; e < n.subdivisions; e++) {
          var b = e + 1 + (t + 1) * (n.subdivisions + 1), T = e + 1 + t * (n.subdivisions + 1), S = e + t * (n.subdivisions + 1), E = e + (t + 1) * (n.subdivisions + 1), A = r[3 * b + 1] >= n.minHeight, R = r[3 * T + 1] >= n.minHeight, C = r[3 * S + 1] >= n.minHeight;
          A && R && C && (i.push(b), i.push(T), i.push(S)), r[3 * E + 1] >= n.minHeight && A && C && (i.push(E), i.push(b), i.push(S));
        }
      Oe.ComputeNormals(r, i, o);
      var L = new Oe();
      return L.indices = i, L.positions = r, L.normals = o, L.uvs = a, L;
    }
    function vl(n, t, e) {
      t === void 0 && (t = {});
      var i = new ph(n, e);
      return i._setReady(!1), i._subdivisionsX = t.subdivisionsX || t.subdivisions || 1, i._subdivisionsY = t.subdivisionsY || t.subdivisions || 1, i._width = t.width || 1, i._height = t.height || 1, i._maxX = i._width / 2, i._maxZ = i._height / 2, i._minX = -i._maxX, i._minZ = -i._maxZ, Do(t).applyToMesh(i, t.updatable), i._setReady(!0), i;
    }
    function fh(n, t, e) {
      e === void 0 && (e = null);
      var i = new ie(n, e);
      return _f(t).applyToMesh(i, t.updatable), i;
    }
    function _h(n, t, e, i) {
      e === void 0 && (e = {}), i === void 0 && (i = null);
      var r = e.width || 10, o = e.height || 10, a = e.subdivisions || 1, s = e.minHeight || 0, l = e.maxHeight || 1, c = e.colorFilter || new ne(0.3, 0.59, 0.11), u = e.alphaFilter || 0, h = e.updatable, d = e.onReady;
      i = i || Me.LastCreatedScene;
      var p = new ph(n, i);
      return p._subdivisionsX = a, p._subdivisionsY = a, p._width = r, p._height = o, p._maxX = p._width / 2, p._maxZ = p._height / 2, p._minX = -p._maxX, p._minZ = -p._maxZ, p._setReady(!1), de.LoadImage(t, function(f) {
        var m = f.width, g = f.height;
        if (!i.isDisposed) {
          var y = i == null ? void 0 : i.getEngine().resizeImageBitmap(f, m, g);
          mf({ width: r, height: o, subdivisions: a, minHeight: s, maxHeight: l, colorFilter: c, buffer: y, bufferWidth: m, bufferHeight: g, alphaFilter: u }).applyToMesh(p, h), d && d(p), p._setReady(!0);
        }
      }, function() {
      }, i.offlineProvider), p;
    }
    var zR = { CreateGround: vl, CreateGroundFromHeightMap: _h, CreateTiledGround: fh };
    function mh(n) {
      for (var t = [], e = [], i = [], r = [], o = n.diameter || 1, a = n.thickness || 0.5, s = 0 | (n.tessellation || 16), l = n.sideOrientation === 0 ? 0 : n.sideOrientation || Oe.DEFAULTSIDE, c = s + 1, u = 0; u <= s; u++)
        for (var h = u / s, d = u * Math.PI * 2 / s - Math.PI / 2, p = B.Translation(o / 2, 0, 0).multiply(B.RotationY(d)), f = 0; f <= s; f++) {
          var m = 1 - f / s, g = f * Math.PI * 2 / s + Math.PI, y = Math.cos(g), b = Math.sin(g), T = new v(y, b, 0), S = T.scale(a / 2), E = new fe(h, m);
          S = v.TransformCoordinates(S, p), T = v.TransformNormal(T, p), e.push(S.x, S.y, S.z), i.push(T.x, T.y, T.z), r.push(E.x, Lt.UseOpenGLOrientationForUV ? 1 - E.y : E.y);
          var A = (u + 1) % c, R = (f + 1) % c;
          t.push(u * c + f), t.push(u * c + R), t.push(A * c + f), t.push(u * c + R), t.push(A * c + R), t.push(A * c + f);
        }
      Oe._ComputeSides(l, e, t, i, r, n.frontUVs, n.backUVs);
      var C = new Oe();
      return C.indices = t, C.positions = e, C.normals = i, C.uvs = r, C;
    }
    function eo(n, t, e) {
      t === void 0 && (t = {});
      var i = new ie(n, e);
      return t.sideOrientation = ie._GetDefaultSideOrientation(t.sideOrientation), i._originalBuilderSideOrientation = t.sideOrientation, mh(t).applyToMesh(i, t.updatable), i;
    }
    Oe.CreateGround = Do, Oe.CreateTiledGround = _f, Oe.CreateGroundFromHeightMap = mf, ie.CreateGround = function(n, t, e, i, r, o) {
      return vl(n, { width: t, height: e, subdivisions: i, updatable: o }, r);
    }, ie.CreateTiledGround = function(n, t, e, i, r, o, a, s, l) {
      return fh(n, { xmin: t, zmin: e, xmax: i, zmax: r, subdivisions: o, precision: a, updatable: l }, s);
    }, ie.CreateGroundFromHeightMap = function(n, t, e, i, r, o, a, s, l, c, u) {
      return _h(n, t, { width: e, height: i, subdivisions: r, minHeight: o, maxHeight: a, updatable: l, onReady: c, alphaFilter: u }, s);
    };
    var WR = { CreateTorus: eo };
    Oe.CreateTorus = mh, ie.CreateTorus = function(n, t, e, i, r, o, a) {
      return eo(n, { diameter: t, thickness: e, tessellation: i, sideOrientation: a, updatable: o }, r);
    };
    var No, HR = function(n) {
      function t(e, i) {
        var r = n.call(this, i) || this;
        return r._getCamera = e, r;
      }
      return D(t, n), t.prototype._getForwardRay = function(e) {
        var i = this._getCamera();
        return i ? i.getForwardRay(e) : new gi(v.Zero(), v.Forward());
      }, t;
    }(function() {
      function n(t, e) {
        if (e === void 0 && (e = null), this.scene = t, this._pointerDownOnMeshAsked = !1, this._isActionableMesh = !1, this._teleportationRequestInitiated = !1, this._teleportationBackRequestInitiated = !1, this._rotationRightAsked = !1, this._rotationLeftAsked = !1, this._dpadPressed = !0, this._activePointer = !1, this._id = n._IdCounter++, e)
          this._gazeTracker = e.clone("gazeTracker");
        else {
          this._gazeTracker = eo("gazeTracker", { diameter: 35e-4, thickness: 25e-4, tessellation: 20, updatable: !1 }, t), this._gazeTracker.bakeCurrentTransformIntoVertices(), this._gazeTracker.isPickable = !1, this._gazeTracker.isVisible = !1;
          var i = new Gt("targetMat", t);
          i.specularColor = ne.Black(), i.emissiveColor = new ne(0.7, 0.7, 0.7), i.backFaceCulling = !1, this._gazeTracker.material = i;
        }
      }
      return n.prototype._getForwardRay = function(t) {
        return new gi(v.Zero(), new v(0, 0, t));
      }, n.prototype._selectionPointerDown = function() {
        this._pointerDownOnMeshAsked = !0, this._currentHit && this.scene.simulatePointerDown(this._currentHit, { pointerId: this._id });
      }, n.prototype._selectionPointerUp = function() {
        this._currentHit && this.scene.simulatePointerUp(this._currentHit, { pointerId: this._id }), this._pointerDownOnMeshAsked = !1;
      }, n.prototype._activatePointer = function() {
        this._activePointer = !0;
      }, n.prototype._deactivatePointer = function() {
        this._activePointer = !1;
      }, n.prototype._updatePointerDistance = function(t) {
      }, n.prototype.dispose = function() {
        this._interactionsEnabled = !1, this._teleportationEnabled = !1, this._gazeTracker && this._gazeTracker.dispose();
      }, n._IdCounter = 0, n;
    }()), XR = function() {
    }, Av = function() {
      function n(t, e) {
        e === void 0 && (e = {});
        var i = this;
        if (this.webVROptions = e, this._fullscreenVRpresenting = !1, this.enableGazeEvenWhenNoPointerLock = !1, this.exitVROnDoubleTap = !0, this.onEnteringVRObservable = new H(), this.onAfterEnteringVRObservable = new H(), this.onExitingVRObservable = new H(), this._useCustomVRButton = !1, this._teleportActive = !1, this._floorMeshesCollection = [], this._teleportationMode = n.TELEPORTATIONMODE_CONSTANTTIME, this._teleportationTime = 122, this._teleportationSpeed = 20, this._rotationAllowed = !0, this._teleportBackwardsVector = new v(0, -1, -1), this._isDefaultTeleportationTarget = !0, this._teleportationFillColor = "#444444", this._teleportationBorderColor = "#FFFFFF", this._rotationAngle = 0, this._haloCenter = new v(0, 0, 0), this._padSensibilityUp = 0.65, this._padSensibilityDown = 0.35, this._pickedLaserColor = new ne(0.2, 0.2, 1), this._pickedGazeColor = new ne(0, 0, 1), this.onNewMeshSelected = new H(), this.onNewMeshPicked = new H(), this.onBeforeCameraTeleport = new H(), this.onAfterCameraTeleport = new H(), this.onSelectedMeshUnselected = new H(), this.teleportationEnabled = !0, this._teleportationInitialized = !1, this._interactionsEnabled = !1, this._displayGaze = !0, this._displayLaserPointer = !0, this.updateGazeTrackerScale = !0, this.updateGazeTrackerColor = !0, this.updateControllerLaserColor = !0, this.requestPointerLockOnFullScreen = !0, this.xrTestDone = !1, this._onResize = function() {
          i._moveButtonToBottomRight();
        }, this._onFullscreenChange = function() {
          i._fullscreenVRpresenting = !!document.fullscreenElement, !i._fullscreenVRpresenting && i._inputElement && (i.exitVR(), !i._useCustomVRButton && i._btnVR && (i._btnVR.style.top = i._inputElement.offsetTop + i._inputElement.offsetHeight - 70 + "px", i._btnVR.style.left = i._inputElement.offsetLeft + i._inputElement.offsetWidth - 100 + "px", i._updateButtonVisibility()));
        }, this._cachedAngularSensibility = { angularSensibilityX: null, angularSensibilityY: null, angularSensibility: null }, this._beforeRender = function() {
          i._scene.getEngine().isPointerLock || i.enableGazeEvenWhenNoPointerLock || (i._cameraGazer._gazeTracker.isVisible = !1);
        }, this._onNewGamepadConnected = function(o) {
          o.type !== qn.POSE_ENABLED && (o.leftStick && o.onleftstickchanged(function(a) {
            i._teleportationInitialized && i.teleportationEnabled && (i._checkTeleportWithRay(a, i._cameraGazer), i._checkTeleportBackwards(a, i._cameraGazer));
          }), o.rightStick && o.onrightstickchanged(function(a) {
            i._teleportationInitialized && i._checkRotate(a, i._cameraGazer);
          }), o.type === qn.XBOX && (o.onbuttondown(function(a) {
            i._interactionsEnabled && a === ir.A && i._cameraGazer._selectionPointerDown();
          }), o.onbuttonup(function(a) {
            i._interactionsEnabled && a === ir.A && i._cameraGazer._selectionPointerUp();
          })));
        }, this._workingVector = v.Zero(), this._workingQuaternion = oe.Identity(), this._workingMatrix = B.Identity(), q.Warn("WebVR is deprecated. Please avoid using this experience helper and use the WebXR experience helper instead"), this._scene = t, this._inputElement = t.getEngine().getInputElement(), "getVRDisplays" in navigator || e.useXR !== void 0 || (e.useXR = !0), e.createFallbackVRDeviceOrientationFreeCamera === void 0 && (e.createFallbackVRDeviceOrientationFreeCamera = !0), e.createDeviceOrientationCamera === void 0 && (e.createDeviceOrientationCamera = !0), e.laserToggle === void 0 && (e.laserToggle = !0), this._hasEnteredVR = !1, this._scene.activeCamera ? this._position = this._scene.activeCamera.position.clone() : this._position = new v(0, this._defaultHeight, 0), e.createDeviceOrientationCamera || !this._scene.activeCamera) {
          if (this._deviceOrientationCamera = new lh("deviceOrientationVRHelper", this._position.clone(), t), this._scene.activeCamera && (this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ, this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ, this._scene.activeCamera instanceof ha && this._scene.activeCamera.rotation)) {
            var r = this._scene.activeCamera;
            r.rotationQuaternion ? this._deviceOrientationCamera.rotationQuaternion.copyFrom(r.rotationQuaternion) : this._deviceOrientationCamera.rotationQuaternion.copyFrom(oe.RotationYawPitchRoll(r.rotation.y, r.rotation.x, r.rotation.z)), this._deviceOrientationCamera.rotation = r.rotation.clone();
          }
          this._scene.activeCamera = this._deviceOrientationCamera, this._inputElement && this._scene.activeCamera.attachControl();
        } else
          this._existingCamera = this._scene.activeCamera;
        this.webVROptions.useXR && navigator.xr ? ff.IsSessionSupportedAsync("immersive-vr").then(function(o) {
          o ? (q.Log("Using WebXR. It is recommended to use the WebXRDefaultExperience directly"), t.createDefaultXRExperienceAsync({ floorMeshes: e.floorMeshes || [] }).then(function(a) {
            i.xr = a, i.xrTestDone = !0, i._cameraGazer = new HR(function() {
              return i.xr.baseExperience.camera;
            }, t), i.xr.baseExperience.onStateChangedObservable.add(function(s) {
              switch (s) {
                case Xi.ENTERING_XR:
                  i.onEnteringVRObservable.notifyObservers(i), i._interactionsEnabled || i.xr.pointerSelection.detach(), i.xr.pointerSelection.displayLaserPointer = i._displayLaserPointer;
                  break;
                case Xi.EXITING_XR:
                  i.onExitingVRObservable.notifyObservers(i), i._scene.getEngine().resize();
                  break;
                case Xi.IN_XR:
                  i._hasEnteredVR = !0;
                  break;
                case Xi.NOT_IN_XR:
                  i._hasEnteredVR = !1;
              }
            });
          })) : i._completeVRInit(t, e);
        }) : this._completeVRInit(t, e);
      }
      return Object.defineProperty(n.prototype, "onEnteringVR", { get: function() {
        return this.onEnteringVRObservable;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "onExitingVR", { get: function() {
        return this.onExitingVRObservable;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "teleportationTarget", { get: function() {
        return this._teleportationTarget;
      }, set: function(t) {
        t && (t.name = "teleportationTarget", this._isDefaultTeleportationTarget = !1, this._teleportationTarget = t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "gazeTrackerMesh", { get: function() {
        return this._cameraGazer._gazeTracker;
      }, set: function(t) {
        t && (this._cameraGazer._gazeTracker && this._cameraGazer._gazeTracker.dispose(), this._cameraGazer._gazeTracker = t, this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices(), this._cameraGazer._gazeTracker.isPickable = !1, this._cameraGazer._gazeTracker.isVisible = !1, this._cameraGazer._gazeTracker.name = "gazeTracker");
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "displayGaze", { get: function() {
        return this._displayGaze;
      }, set: function(t) {
        this._displayGaze = t, t || (this._cameraGazer._gazeTracker.isVisible = !1);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "displayLaserPointer", { get: function() {
        return this._displayLaserPointer;
      }, set: function(t) {
        this._displayLaserPointer = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "deviceOrientationCamera", { get: function() {
        return this._deviceOrientationCamera;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "currentVRCamera", { get: function() {
        return this._scene.activeCamera;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "vrDeviceOrientationCamera", { get: function() {
        return this._vrDeviceOrientationCamera;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "vrButton", { get: function() {
        return this._btnVR;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "_teleportationRequestInitiated", { get: function() {
        return this._cameraGazer._teleportationRequestInitiated;
      }, enumerable: !1, configurable: !0 }), n.prototype._completeVRInit = function(t, e) {
        var i = this;
        if (this.xrTestDone = !0, e.createFallbackVRDeviceOrientationFreeCamera && (this._vrDeviceOrientationCamera = new hh("VRDeviceOrientationVRHelper", this._position, this._scene, !0, e.vrDeviceOrientationCameraMetrics), this._vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE), this._cameraGazer = new HR(function() {
          return i.currentVRCamera;
        }, t), !this._useCustomVRButton) {
          this._btnVR = document.createElement("BUTTON"), this._btnVR.className = "babylonVRicon", this._btnVR.id = "babylonVRiconbtn", this._btnVR.title = "Click to switch to VR";
          var r = ".babylonVRicon { position: absolute; right: 20px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-image: url(" + (window.SVGSVGElement ? "data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%222048%22%20height%3D%221152%22%20viewBox%3D%220%200%202048%201152%22%20version%3D%221.1%22%3E%3Cpath%20transform%3D%22rotate%28180%201024%2C576.0000000000001%29%22%20d%3D%22m1109%2C896q17%2C0%2030%2C-12t13%2C-30t-12.5%2C-30.5t-30.5%2C-12.5l-170%2C0q-18%2C0%20-30.5%2C12.5t-12.5%2C30.5t13%2C30t30%2C12l170%2C0zm-85%2C256q59%2C0%20132.5%2C-1.5t154.5%2C-5.5t164.5%2C-11.5t163%2C-20t150%2C-30t124.5%2C-41.5q23%2C-11%2042%2C-24t38%2C-30q27%2C-25%2041%2C-61.5t14%2C-72.5l0%2C-257q0%2C-123%20-47%2C-232t-128%2C-190t-190%2C-128t-232%2C-47l-81%2C0q-37%2C0%20-68.5%2C14t-60.5%2C34.5t-55.5%2C45t-53%2C45t-53%2C34.5t-55.5%2C14t-55.5%2C-14t-53%2C-34.5t-53%2C-45t-55.5%2C-45t-60.5%2C-34.5t-68.5%2C-14l-81%2C0q-123%2C0%20-232%2C47t-190%2C128t-128%2C190t-47%2C232l0%2C257q0%2C68%2038%2C115t97%2C73q54%2C24%20124.5%2C41.5t150%2C30t163%2C20t164.5%2C11.5t154.5%2C5.5t132.5%2C1.5zm939%2C-298q0%2C39%20-24.5%2C67t-58.5%2C42q-54%2C23%20-122%2C39.5t-143.5%2C28t-155.5%2C19t-157%2C11t-148.5%2C5t-129.5%2C1.5q-59%2C0%20-130%2C-1.5t-148%2C-5t-157%2C-11t-155.5%2C-19t-143.5%2C-28t-122%2C-39.5q-34%2C-14%20-58.5%2C-42t-24.5%2C-67l0%2C-257q0%2C-106%2040.5%2C-199t110%2C-162.5t162.5%2C-109.5t199%2C-40l81%2C0q27%2C0%2052%2C14t50%2C34.5t51%2C44.5t55.5%2C44.5t63.5%2C34.5t74%2C14t74%2C-14t63.5%2C-34.5t55.5%2C-44.5t51%2C-44.5t50%2C-34.5t52%2C-14l14%2C0q37%2C0%2070%2C0.5t64.5%2C4.5t63.5%2C12t68%2C23q71%2C30%20128.5%2C78.5t98.5%2C110t63.5%2C133.5t22.5%2C149l0%2C257z%22%20fill%3D%22white%22%20/%3E%3C/svg%3E%0A" : "https://cdn.babylonjs.com/Assets/vrButton.png") + "); background-size: 80%; background-repeat:no-repeat; background-position: center; border: none; outline: none; transition: transform 0.125s ease-out } .babylonVRicon:hover { transform: scale(1.05) } .babylonVRicon:active {background-color: rgba(51,51,51,1) } .babylonVRicon:focus {background-color: rgba(51,51,51,1) }";
          r += ".babylonVRicon.vrdisplaypresenting { display: none; }";
          var o = document.createElement("style");
          o.appendChild(document.createTextNode(r)), document.getElementsByTagName("head")[0].appendChild(o), this._moveButtonToBottomRight();
        }
        this._btnVR && this._btnVR.addEventListener("click", function() {
          i.isInVRMode || i.enterVR();
        });
        var a = this._scene.getEngine().getHostWindow();
        a && (a.addEventListener("resize", this._onResize), document.addEventListener("fullscreenchange", this._onFullscreenChange, !1), e.createFallbackVRDeviceOrientationFreeCamera && this._displayVRButton(), this._onKeyDown = function(s) {
          s.keyCode === 27 && i.isInVRMode && i.exitVR();
        }, document.addEventListener("keydown", this._onKeyDown), this._scene.onPrePointerObservable.add(function() {
          i._hasEnteredVR && i.exitVROnDoubleTap && (i.exitVR(), i._fullscreenVRpresenting && i._scene.getEngine().exitFullscreen());
        }, Le.POINTERDOUBLETAP, !1), t.onDisposeObservable.add(function() {
          i.dispose();
        }), this._updateButtonVisibility(), this._circleEase = new lg(), this._circleEase.setEasingMode(xn.EASINGMODE_EASEINOUT), this._teleportationEasing = this._circleEase, t.onPointerObservable.add(function(s) {
          i._interactionsEnabled && t.activeCamera === i.vrDeviceOrientationCamera && s.event.pointerType === "mouse" && (s.type === Le.POINTERDOWN ? i._cameraGazer._selectionPointerDown() : s.type === Le.POINTERUP && i._cameraGazer._selectionPointerUp());
        }), this.webVROptions.floorMeshes && this.enableTeleportation({ floorMeshes: this.webVROptions.floorMeshes }));
      }, Object.defineProperty(n.prototype, "isInVRMode", { get: function() {
        return this.xr && this.webVROptions.useXR && this.xr.baseExperience.state === Xi.IN_XR || this._fullscreenVRpresenting;
      }, enumerable: !1, configurable: !0 }), n.prototype._moveButtonToBottomRight = function() {
        if (this._inputElement && !this._useCustomVRButton && this._btnVR) {
          var t = this._inputElement.getBoundingClientRect();
          this._btnVR.style.top = t.top + t.height - 70 + "px", this._btnVR.style.left = t.left + t.width - 100 + "px";
        }
      }, n.prototype._displayVRButton = function() {
        this._useCustomVRButton || this._btnVRDisplayed || !this._btnVR || (document.body.appendChild(this._btnVR), this._btnVRDisplayed = !0);
      }, n.prototype._updateButtonVisibility = function() {
        this._btnVR && !this._useCustomVRButton && (this._btnVR.className = "babylonVRicon", this.isInVRMode && (this._btnVR.className += " vrdisplaypresenting"));
      }, n.prototype.enterVR = function() {
        var t = this;
        if (this.xr)
          this.xr.baseExperience.enterXRAsync("immersive-vr", "local-floor", this.xr.renderTarget);
        else {
          if (this.onEnteringVRObservable)
            try {
              this.onEnteringVRObservable.notifyObservers(this);
            } catch (e) {
              q.Warn("Error in your custom logic onEnteringVR: " + e);
            }
          this._scene.activeCamera && (this._position = this._scene.activeCamera.position.clone(), this.vrDeviceOrientationCamera && (this.vrDeviceOrientationCamera.rotation = oe.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles(), this.vrDeviceOrientationCamera.angularSensibility = 2e3), this._existingCamera = this._scene.activeCamera, this._existingCamera.angularSensibilityX && (this._cachedAngularSensibility.angularSensibilityX = this._existingCamera.angularSensibilityX, this._existingCamera.angularSensibilityX = Number.MAX_VALUE), this._existingCamera.angularSensibilityY && (this._cachedAngularSensibility.angularSensibilityY = this._existingCamera.angularSensibilityY, this._existingCamera.angularSensibilityY = Number.MAX_VALUE), this._existingCamera.angularSensibility && (this._cachedAngularSensibility.angularSensibility = this._existingCamera.angularSensibility, this._existingCamera.angularSensibility = Number.MAX_VALUE)), this._vrDeviceOrientationCamera && (this._vrDeviceOrientationCamera.position = this._position, this._scene.activeCamera && (this._vrDeviceOrientationCamera.minZ = this._scene.activeCamera.minZ), this._scene.activeCamera = this._vrDeviceOrientationCamera, this._scene.getEngine().enterFullscreen(this.requestPointerLockOnFullScreen), this._updateButtonVisibility(), this._vrDeviceOrientationCamera.onViewMatrixChangedObservable.addOnce(function() {
            t.onAfterEnteringVRObservable.notifyObservers({ success: !0 });
          })), this._scene.activeCamera && this._inputElement && this._scene.activeCamera.attachControl(), this._interactionsEnabled && this._scene.registerBeforeRender(this._beforeRender), this._hasEnteredVR = !0;
        }
      }, n.prototype.exitVR = function() {
        if (this.xr)
          this.xr.baseExperience.exitXRAsync();
        else if (this._hasEnteredVR) {
          if (this.onExitingVRObservable)
            try {
              this.onExitingVRObservable.notifyObservers(this);
            } catch (t) {
              q.Warn("Error in your custom logic onExitingVR: " + t);
            }
          this._scene.activeCamera && (this._position = this._scene.activeCamera.position.clone()), this.vrDeviceOrientationCamera && (this.vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE), this._deviceOrientationCamera ? (this._deviceOrientationCamera.position = this._position, this._scene.activeCamera = this._deviceOrientationCamera, this._cachedAngularSensibility.angularSensibilityX && (this._deviceOrientationCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX, this._cachedAngularSensibility.angularSensibilityX = null), this._cachedAngularSensibility.angularSensibilityY && (this._deviceOrientationCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY, this._cachedAngularSensibility.angularSensibilityY = null), this._cachedAngularSensibility.angularSensibility && (this._deviceOrientationCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility, this._cachedAngularSensibility.angularSensibility = null)) : this._existingCamera && (this._existingCamera.position = this._position, this._scene.activeCamera = this._existingCamera, this._inputElement && this._scene.activeCamera.attachControl(), this._cachedAngularSensibility.angularSensibilityX && (this._existingCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX, this._cachedAngularSensibility.angularSensibilityX = null), this._cachedAngularSensibility.angularSensibilityY && (this._existingCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY, this._cachedAngularSensibility.angularSensibilityY = null), this._cachedAngularSensibility.angularSensibility && (this._existingCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility, this._cachedAngularSensibility.angularSensibility = null)), this._updateButtonVisibility(), this._interactionsEnabled && (this._scene.unregisterBeforeRender(this._beforeRender), this._cameraGazer._gazeTracker.isVisible = !1), this._scene.getEngine().resize(), this._hasEnteredVR = !1;
        }
      }, Object.defineProperty(n.prototype, "position", { get: function() {
        return this._position;
      }, set: function(t) {
        this._position = t, this._scene.activeCamera && (this._scene.activeCamera.position = t);
      }, enumerable: !1, configurable: !0 }), n.prototype.enableInteractions = function() {
        var t = this;
        if (!this._interactionsEnabled) {
          if (this.xr)
            return void (this.xr.baseExperience.state === Xi.IN_XR && this.xr.pointerSelection.attach());
          this.raySelectionPredicate = function(e) {
            return e.isVisible && (e.isPickable || e.name === t._floorMeshName);
          }, this.meshSelectionPredicate = function() {
            return !0;
          }, this._raySelectionPredicate = function(e) {
            return !!(t._isTeleportationFloor(e) || e.name.indexOf("gazeTracker") === -1 && e.name.indexOf("teleportationTarget") === -1 && e.name.indexOf("torusTeleportation") === -1) && t.raySelectionPredicate(e);
          }, this._interactionsEnabled = !0;
        }
      }, n.prototype._isTeleportationFloor = function(t) {
        for (var e = 0; e < this._floorMeshesCollection.length; e++)
          if (this._floorMeshesCollection[e].id === t.id)
            return !0;
        return !(!this._floorMeshName || t.name !== this._floorMeshName);
      }, n.prototype.addFloorMesh = function(t) {
        this._floorMeshesCollection && (this._floorMeshesCollection.indexOf(t) > -1 || this._floorMeshesCollection.push(t));
      }, n.prototype.removeFloorMesh = function(t) {
        if (this._floorMeshesCollection) {
          var e = this._floorMeshesCollection.indexOf(t);
          e !== -1 && this._floorMeshesCollection.splice(e, 1);
        }
      }, n.prototype.enableTeleportation = function(t) {
        var e = this;
        if (t === void 0 && (t = {}), !this._teleportationInitialized) {
          if (this.enableInteractions(), this.webVROptions.useXR && (t.floorMeshes || t.floorMeshName)) {
            var i = t.floorMeshes || [];
            if (!i.length) {
              var r = this._scene.getMeshByName(t.floorMeshName);
              r && i.push(r);
            }
            if (this.xr)
              return i.forEach(function(s) {
                e.xr.teleportation.addFloorMesh(s);
              }), void (this.xr.teleportation.attached || this.xr.teleportation.attach());
            if (!this.xrTestDone) {
              var o = function() {
                e.xrTestDone && (e._scene.unregisterBeforeRender(o), e.xr ? e.xr.teleportation.attached || e.xr.teleportation.attach() : e.enableTeleportation(t));
              };
              return void this._scene.registerBeforeRender(o);
            }
          }
          t.floorMeshName && (this._floorMeshName = t.floorMeshName), t.floorMeshes && (this._floorMeshesCollection = t.floorMeshes), t.teleportationMode && (this._teleportationMode = t.teleportationMode), t.teleportationTime && t.teleportationTime > 0 && (this._teleportationTime = t.teleportationTime), t.teleportationSpeed && t.teleportationSpeed > 0 && (this._teleportationSpeed = t.teleportationSpeed), t.easingFunction !== void 0 && (this._teleportationEasing = t.easingFunction);
          var a = new tn();
          a.vignetteColor = new Ie(0, 0, 0, 0), a.vignetteEnabled = !0, this._teleportationInitialized = !0, this._isDefaultTeleportationTarget && this._createTeleportationCircles();
        }
      }, n.prototype._checkTeleportWithRay = function(t, e) {
        this._teleportationRequestInitiated && !e._teleportationRequestInitiated || (e._teleportationRequestInitiated ? Math.sqrt(t.y * t.y + t.x * t.x) < this._padSensibilityDown && (this._teleportActive && this.teleportCamera(this._haloCenter), e._teleportationRequestInitiated = !1) : t.y < -this._padSensibilityUp && e._dpadPressed && (e._activatePointer(), e._teleportationRequestInitiated = !0));
      }, n.prototype._checkRotate = function(t, e) {
        e._teleportationRequestInitiated || (e._rotationLeftAsked ? t.x > -this._padSensibilityDown && (e._rotationLeftAsked = !1) : t.x < -this._padSensibilityUp && e._dpadPressed && (e._rotationLeftAsked = !0, this._rotationAllowed && this._rotateCamera(!1)), e._rotationRightAsked ? t.x < this._padSensibilityDown && (e._rotationRightAsked = !1) : t.x > this._padSensibilityUp && e._dpadPressed && (e._rotationRightAsked = !0, this._rotationAllowed && this._rotateCamera(!0)));
      }, n.prototype._checkTeleportBackwards = function(t, e) {
        if (!e._teleportationRequestInitiated)
          if (t.y > this._padSensibilityUp && e._dpadPressed) {
            if (!e._teleportationBackRequestInitiated) {
              if (!this.currentVRCamera)
                return;
              var i = oe.FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix()), r = this.currentVRCamera.position;
              i.toEulerAnglesToRef(this._workingVector), this._workingVector.z = 0, this._workingVector.x = 0, oe.RotationYawPitchRollToRef(this._workingVector.y, this._workingVector.x, this._workingVector.z, this._workingQuaternion), this._workingQuaternion.toRotationMatrix(this._workingMatrix), v.TransformCoordinatesToRef(this._teleportBackwardsVector, this._workingMatrix, this._workingVector);
              var o = new gi(r, this._workingVector), a = this._scene.pickWithRay(o, this._raySelectionPredicate);
              a && a.pickedPoint && a.pickedMesh && this._isTeleportationFloor(a.pickedMesh) && a.distance < 5 && this.teleportCamera(a.pickedPoint), e._teleportationBackRequestInitiated = !0;
            }
          } else
            e._teleportationBackRequestInitiated = !1;
      }, n.prototype._createTeleportationCircles = function() {
        this._teleportationTarget = vl("teleportationTarget", { width: 2, height: 2, subdivisions: 2 }, this._scene), this._teleportationTarget.isPickable = !1;
        var t = new Es("DynamicTexture", 512, this._scene, !0);
        t.hasAlpha = !0;
        var e = t.getContext();
        e.beginPath(), e.arc(256, 256, 200, 0, 2 * Math.PI, !1), e.fillStyle = this._teleportationFillColor, e.fill(), e.lineWidth = 10, e.strokeStyle = this._teleportationBorderColor, e.stroke(), e.closePath(), t.update();
        var i = new Gt("TextPlaneMaterial", this._scene);
        i.diffuseTexture = t, this._teleportationTarget.material = i;
        var r = eo("torusTeleportation", { diameter: 0.75, thickness: 0.1, tessellation: 25, updatable: !1 }, this._scene);
        r.isPickable = !1, r.parent = this._teleportationTarget;
        var o = new Je("animationInnerCircle", "position.y", 30, Je.ANIMATIONTYPE_FLOAT, Je.ANIMATIONLOOPMODE_CYCLE), a = [];
        a.push({ frame: 0, value: 0 }), a.push({ frame: 30, value: 0.4 }), a.push({ frame: 60, value: 0 }), o.setKeys(a);
        var s = new Sp();
        s.setEasingMode(xn.EASINGMODE_EASEINOUT), o.setEasingFunction(s), r.animations = [], r.animations.push(o), this._scene.beginAnimation(r, 0, 60, !0), this._hideTeleportationTarget();
      }, n.prototype._hideTeleportationTarget = function() {
        this._teleportActive = !1, this._teleportationInitialized && (this._teleportationTarget.isVisible = !1, this._isDefaultTeleportationTarget && (this._teleportationTarget.getChildren()[0].isVisible = !1));
      }, n.prototype._rotateCamera = function(t) {
        if (this.currentVRCamera instanceof Oo) {
          t ? this._rotationAngle++ : this._rotationAngle--, this.currentVRCamera.animations = [];
          var e = oe.FromRotationMatrix(B.RotationY(Math.PI / 4 * this._rotationAngle)), i = new Je("animationRotation", "rotationQuaternion", 90, Je.ANIMATIONTYPE_QUATERNION, Je.ANIMATIONLOOPMODE_CONSTANT), r = [];
          r.push({ frame: 0, value: this.currentVRCamera.rotationQuaternion }), r.push({ frame: 6, value: e }), i.setKeys(r), i.setEasingFunction(this._circleEase), this.currentVRCamera.animations.push(i), this._postProcessMove.animations = [];
          var o = new Je("animationPP", "vignetteWeight", 90, Je.ANIMATIONTYPE_FLOAT, Je.ANIMATIONLOOPMODE_CONSTANT), a = [];
          a.push({ frame: 0, value: 0 }), a.push({ frame: 3, value: 4 }), a.push({ frame: 6, value: 0 }), o.setKeys(a), o.setEasingFunction(this._circleEase), this._postProcessMove.animations.push(o);
          var s = new Je("animationPP2", "vignetteStretch", 90, Je.ANIMATIONTYPE_FLOAT, Je.ANIMATIONLOOPMODE_CONSTANT), l = [];
          l.push({ frame: 0, value: 0 }), l.push({ frame: 3, value: 10 }), l.push({ frame: 6, value: 0 }), s.setKeys(l), s.setEasingFunction(this._circleEase), this._postProcessMove.animations.push(s), this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0, this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0, this._postProcessMove.samples = 4, this._scene.beginAnimation(this.currentVRCamera, 0, 6, !1, 1);
        }
      }, n.prototype.teleportCamera = function(t) {
        var e = this;
        if (this.currentVRCamera instanceof Oo) {
          var i, r;
          if (this._workingVector.copyFrom(t), this.isInVRMode || (this._workingVector.y += this._defaultHeight), this.onBeforeCameraTeleport.notifyObservers(this._workingVector), this._teleportationMode == n.TELEPORTATIONMODE_CONSTANTSPEED) {
            r = 90;
            var o = v.Distance(this.currentVRCamera.position, this._workingVector);
            i = this._teleportationSpeed / o;
          } else
            r = Math.round(90 * this._teleportationTime / 1e3), i = 1;
          this.currentVRCamera.animations = [];
          var a = new Je("animationCameraTeleportation", "position", 90, Je.ANIMATIONTYPE_VECTOR3, Je.ANIMATIONLOOPMODE_CONSTANT), s = [{ frame: 0, value: this.currentVRCamera.position }, { frame: r, value: this._workingVector }];
          a.setKeys(s), a.setEasingFunction(this._teleportationEasing), this.currentVRCamera.animations.push(a), this._postProcessMove.animations = [];
          var l = Math.round(r / 2), c = new Je("animationPP", "vignetteWeight", 90, Je.ANIMATIONTYPE_FLOAT, Je.ANIMATIONLOOPMODE_CONSTANT), u = [];
          u.push({ frame: 0, value: 0 }), u.push({ frame: l, value: 8 }), u.push({ frame: r, value: 0 }), c.setKeys(u), this._postProcessMove.animations.push(c);
          var h = new Je("animationPP2", "vignetteStretch", 90, Je.ANIMATIONTYPE_FLOAT, Je.ANIMATIONLOOPMODE_CONSTANT), d = [];
          d.push({ frame: 0, value: 0 }), d.push({ frame: l, value: 10 }), d.push({ frame: r, value: 0 }), h.setKeys(d), this._postProcessMove.animations.push(h), this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0, this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0, this._scene.beginAnimation(this.currentVRCamera, 0, r, !1, i, function() {
            e.onAfterCameraTeleport.notifyObservers(e._workingVector);
          }), this._hideTeleportationTarget();
        }
      }, n.prototype.setLaserColor = function(t, e) {
        e === void 0 && (e = this._pickedLaserColor), this._pickedLaserColor = e;
      }, n.prototype.setLaserLightingState = function(t) {
      }, n.prototype.setGazeColor = function(t, e) {
        e === void 0 && (e = this._pickedGazeColor), this._pickedGazeColor = e;
      }, n.prototype.changeLaserColor = function(t) {
        this.updateControllerLaserColor;
      }, n.prototype.changeGazeColor = function(t) {
        this.updateGazeTrackerColor && this._cameraGazer._gazeTracker.material && (this._cameraGazer._gazeTracker.material.emissiveColor = t);
      }, n.prototype.dispose = function() {
        this.isInVRMode && this.exitVR(), this._postProcessMove && this._postProcessMove.dispose(), this._vrDeviceOrientationCamera && this._vrDeviceOrientationCamera.dispose(), !this._useCustomVRButton && this._btnVR && this._btnVR.parentNode && document.body.removeChild(this._btnVR), this._deviceOrientationCamera && this._scene.activeCamera != this._deviceOrientationCamera && this._deviceOrientationCamera.dispose(), this._cameraGazer && this._cameraGazer.dispose(), this._teleportationTarget && this._teleportationTarget.dispose(), this.xr && this.xr.dispose(), this._floorMeshesCollection.length = 0, document.removeEventListener("keydown", this._onKeyDown), window.removeEventListener("vrdisplaypresentchange", this._onVrDisplayPresentChangeBind), window.removeEventListener("resize", this._onResize), document.removeEventListener("fullscreenchange", this._onFullscreenChange), this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected), this._scene.unregisterBeforeRender(this._beforeRender);
      }, n.prototype.getClassName = function() {
        return "VRExperienceHelper";
      }, n.TELEPORTATIONMODE_CONSTANTTIME = 0, n.TELEPORTATIONMODE_CONSTANTSPEED = 1, n;
    }(), Ac = (No = { root: 0, found: !1 }, function(n, t, e, i) {
      No.root = 0, No.found = !1;
      var r = t * t - 4 * n * e;
      if (r < 0)
        return No;
      var o = Math.sqrt(r), a = (-t - o) / (2 * n), s = (-t + o) / (2 * n);
      if (a > s) {
        var l = s;
        s = a, a = l;
      }
      return a > 0 && a < i ? (No.root = a, No.found = !0, No) : (s > 0 && s < i && (No.root = s, No.found = !0), No);
    }), Rv = function() {
      function n() {
        this._collisionPoint = v.Zero(), this._planeIntersectionPoint = v.Zero(), this._tempVector = v.Zero(), this._tempVector2 = v.Zero(), this._tempVector3 = v.Zero(), this._tempVector4 = v.Zero(), this._edge = v.Zero(), this._baseToVertex = v.Zero(), this._destinationPoint = v.Zero(), this._slidePlaneNormal = v.Zero(), this._displacementVector = v.Zero(), this._radius = v.One(), this._retry = 0, this._basePointWorld = v.Zero(), this._velocityWorld = v.Zero(), this._normalizedVelocity = v.Zero(), this._collisionMask = -1;
      }
      return Object.defineProperty(n.prototype, "collisionMask", { get: function() {
        return this._collisionMask;
      }, set: function(t) {
        this._collisionMask = isNaN(t) ? -1 : t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "slidePlaneNormal", { get: function() {
        return this._slidePlaneNormal;
      }, enumerable: !1, configurable: !0 }), n.prototype._initialize = function(t, e, i) {
        this._velocity = e, this._velocitySquaredLength = this._velocity.lengthSquared();
        var r = Math.sqrt(this._velocitySquaredLength);
        r === 0 || r === 1 ? this._normalizedVelocity.copyFromFloats(e._x, e._y, e._z) : e.scaleToRef(1 / r, this._normalizedVelocity), this._basePoint = t, t.multiplyToRef(this._radius, this._basePointWorld), e.multiplyToRef(this._radius, this._velocityWorld), this._velocityWorldLength = this._velocityWorld.length(), this._epsilon = i, this.collisionFound = !1;
      }, n.prototype._checkPointInTriangle = function(t, e, i, r, o) {
        e.subtractToRef(t, this._tempVector), i.subtractToRef(t, this._tempVector2), v.CrossToRef(this._tempVector, this._tempVector2, this._tempVector4);
        var a = v.Dot(this._tempVector4, o);
        return !(a < 0) && (r.subtractToRef(t, this._tempVector3), v.CrossToRef(this._tempVector2, this._tempVector3, this._tempVector4), !((a = v.Dot(this._tempVector4, o)) < 0) && (v.CrossToRef(this._tempVector3, this._tempVector, this._tempVector4), (a = v.Dot(this._tempVector4, o)) >= 0));
      }, n.prototype._canDoCollision = function(t, e, i, r) {
        var o = v.Distance(this._basePointWorld, t), a = Math.max(this._radius.x, this._radius.y, this._radius.z);
        return !(o > this._velocityWorldLength + a + e || !function(s, l, c, u) {
          return !(s.x > c.x + u || c.x - u > l.x || s.y > c.y + u || c.y - u > l.y || s.z > c.z + u || c.z - u > l.z);
        }(i, r, this._basePointWorld, this._velocityWorldLength + a));
      }, n.prototype._testTriangle = function(t, e, i, r, o, a, s) {
        var l, c = !1;
        e || (e = []), e[t] || (e[t] = new xo(0, 0, 0, 0), e[t].copyFromPoints(i, r, o));
        var u = e[t];
        if (a || u.isFrontFacingTo(this._normalizedVelocity, 0)) {
          var h = u.signedDistanceTo(this._basePoint), d = v.Dot(u.normal, this._velocity);
          if (!(n.DoubleSidedCheck && d > 1e-4)) {
            if (d == 0) {
              if (Math.abs(h) >= 1)
                return;
              c = !0, l = 0;
            } else {
              var p = (1 - h) / d;
              if ((l = (-1 - h) / d) > p) {
                var f = p;
                p = l, l = f;
              }
              if (l > 1 || p < 0)
                return;
              l < 0 && (l = 0), l > 1 && (l = 1);
            }
            this._collisionPoint.copyFromFloats(0, 0, 0);
            var m = !1, g = 1;
            if (c || (this._basePoint.subtractToRef(u.normal, this._planeIntersectionPoint), this._velocity.scaleToRef(l, this._tempVector), this._planeIntersectionPoint.addInPlace(this._tempVector), this._checkPointInTriangle(this._planeIntersectionPoint, i, r, o, u.normal) && (m = !0, g = l, this._collisionPoint.copyFrom(this._planeIntersectionPoint))), !m) {
              var y = this._velocitySquaredLength;
              this._basePoint.subtractToRef(i, this._tempVector);
              var b = 2 * v.Dot(this._velocity, this._tempVector), T = this._tempVector.lengthSquared() - 1, S = Ac(y, b, T, g);
              S.found && (g = S.root, m = !0, this._collisionPoint.copyFrom(i)), this._basePoint.subtractToRef(r, this._tempVector), b = 2 * v.Dot(this._velocity, this._tempVector), T = this._tempVector.lengthSquared() - 1, (S = Ac(y, b, T, g)).found && (g = S.root, m = !0, this._collisionPoint.copyFrom(r)), this._basePoint.subtractToRef(o, this._tempVector), b = 2 * v.Dot(this._velocity, this._tempVector), T = this._tempVector.lengthSquared() - 1, (S = Ac(y, b, T, g)).found && (g = S.root, m = !0, this._collisionPoint.copyFrom(o)), r.subtractToRef(i, this._edge), i.subtractToRef(this._basePoint, this._baseToVertex);
              var E, A = this._edge.lengthSquared(), R = v.Dot(this._edge, this._velocity), C = v.Dot(this._edge, this._baseToVertex);
              y = A * -this._velocitySquaredLength + R * R, b = 2 * (A * v.Dot(this._velocity, this._baseToVertex) - R * C), T = A * (1 - this._baseToVertex.lengthSquared()) + C * C, (S = Ac(y, b, T, g)).found && (E = (R * S.root - C) / A) >= 0 && E <= 1 && (g = S.root, m = !0, this._edge.scaleInPlace(E), i.addToRef(this._edge, this._collisionPoint)), o.subtractToRef(r, this._edge), r.subtractToRef(this._basePoint, this._baseToVertex), A = this._edge.lengthSquared(), R = v.Dot(this._edge, this._velocity), C = v.Dot(this._edge, this._baseToVertex), y = A * -this._velocitySquaredLength + R * R, b = 2 * (A * v.Dot(this._velocity, this._baseToVertex) - R * C), T = A * (1 - this._baseToVertex.lengthSquared()) + C * C, (S = Ac(y, b, T, g)).found && (E = (R * S.root - C) / A) >= 0 && E <= 1 && (g = S.root, m = !0, this._edge.scaleInPlace(E), r.addToRef(this._edge, this._collisionPoint)), i.subtractToRef(o, this._edge), o.subtractToRef(this._basePoint, this._baseToVertex), A = this._edge.lengthSquared(), R = v.Dot(this._edge, this._velocity), C = v.Dot(this._edge, this._baseToVertex), y = A * -this._velocitySquaredLength + R * R, b = 2 * (A * v.Dot(this._velocity, this._baseToVertex) - R * C), T = A * (1 - this._baseToVertex.lengthSquared()) + C * C, (S = Ac(y, b, T, g)).found && (E = (R * S.root - C) / A) >= 0 && E <= 1 && (g = S.root, m = !0, this._edge.scaleInPlace(E), o.addToRef(this._edge, this._collisionPoint));
            }
            if (m) {
              var L = g * g * this._velocitySquaredLength;
              (!this.collisionFound || L < this._nearestDistanceSquared) && (s.collisionResponse && (this.intersectionPoint ? this.intersectionPoint.copyFrom(this._collisionPoint) : this.intersectionPoint = this._collisionPoint.clone(), this._nearestDistanceSquared = L, this._nearestDistance = Math.sqrt(L), this.collisionFound = !0), this.collidedMesh = s);
            }
          }
        }
      }, n.prototype._collide = function(t, e, i, r, o, a, s, l, c, u) {
        if (u === void 0 && (u = !1), u)
          if (i && i.length !== 0)
            for (f = r; f < o - 2; f += 1) {
              var h = i[f], d = i[f + 1], p = i[f + 2];
              p !== 4294967295 ? (m = e[h], g = e[d], y = e[p], m && g && y && ((c ? 1 : 0) ^ f % 2 ? this._testTriangle(f, t, m, g, y, s, l) : this._testTriangle(f, t, g, m, y, s, l))) : f += 2;
            }
          else
            for (var f = 0; f < e.length - 2; f += 1) {
              var m = e[f], g = e[f + 1], y = e[f + 2];
              m && g && y && ((c ? 1 : 0) ^ f % 2 ? this._testTriangle(f, t, m, g, y, s, l) : this._testTriangle(f, t, g, m, y, s, l));
            }
        else if (i && i.length !== 0)
          for (f = r; f < o; f += 3)
            m = e[i[f] - a], g = e[i[f + 1] - a], y = e[i[f + 2] - a], c ? this._testTriangle(f, t, m, g, y, s, l) : this._testTriangle(f, t, y, g, m, s, l);
        else
          for (f = 0; f < e.length; f += 3)
            m = e[f], g = e[f + 1], y = e[f + 2], c ? this._testTriangle(f, t, m, g, y, s, l) : this._testTriangle(f, t, y, g, m, s, l);
      }, n.prototype._getResponse = function(t, e) {
        t.addToRef(e, this._destinationPoint), e.scaleInPlace(this._nearestDistance / e.length()), this._basePoint.addToRef(e, t), t.subtractToRef(this.intersectionPoint, this._slidePlaneNormal), this._slidePlaneNormal.normalize(), this._slidePlaneNormal.scaleToRef(this._epsilon, this._displacementVector), t.addInPlace(this._displacementVector), this.intersectionPoint.addInPlace(this._displacementVector), this._slidePlaneNormal.scaleInPlace(xo.SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint, this._slidePlaneNormal, this._destinationPoint)), this._destinationPoint.subtractInPlace(this._slidePlaneNormal), this._destinationPoint.subtractToRef(this.intersectionPoint, e);
      }, n.DoubleSidedCheck = !1, n;
    }(), Cv = function() {
      function n() {
        this._scaledPosition = v.Zero(), this._scaledVelocity = v.Zero(), this._finalPosition = v.Zero();
      }
      return n.prototype.getNewPosition = function(t, e, i, r, o, a, s) {
        t.divideToRef(i._radius, this._scaledPosition), e.divideToRef(i._radius, this._scaledVelocity), i.collidedMesh = null, i._retry = 0, i._initialVelocity = this._scaledVelocity, i._initialPosition = this._scaledPosition, this._collideWithWorld(this._scaledPosition, this._scaledVelocity, i, r, this._finalPosition, o), this._finalPosition.multiplyInPlace(i._radius), a(s, this._finalPosition, i.collidedMesh);
      }, n.prototype.createCollider = function() {
        return new Rv();
      }, n.prototype.init = function(t) {
        this._scene = t;
      }, n.prototype._collideWithWorld = function(t, e, i, r, o, a) {
        a === void 0 && (a = null);
        var s = 10 * ve.CollisionsEpsilon;
        if (i._retry >= r)
          o.copyFrom(t);
        else {
          var l = a ? a.collisionMask : i.collisionMask;
          i._initialize(t, e, s);
          for (var c = a && a.surroundingMeshes || this._scene.meshes, u = 0; u < c.length; u++) {
            var h = c[u];
            h.isEnabled() && h.checkCollisions && h.subMeshes && h !== a && l & h.collisionGroup && h._checkCollision(i);
          }
          i.collisionFound ? (e.x === 0 && e.y === 0 && e.z === 0 || i._getResponse(t, e), e.length() <= s ? o.copyFrom(t) : (i._retry++, this._collideWithWorld(t, e, i, r, o, a))) : t.addToRef(e, o);
        }
      }, n;
    }();
    Ue.CollisionCoordinatorFactory = function() {
      return new Cv();
    };
    var di, Pv = function() {
      function n(t, e, i, r) {
        r === void 0 && (r = "");
        var o, a, s, l = this;
        this.name = null, this.defines = "", this.onCompiled = null, this.onError = null, this.uniqueId = 0, this.onCompileObservable = new H(), this.onErrorObservable = new H(), this.onBindObservable = new H(), this._wasPreviouslyReady = !1, this._isReady = !1, this._compilationError = "", this._key = "", this._computeSourceCodeOverride = "", this._pipelineContext = null, this._computeSourceCode = "", this._rawComputeSourceCode = "", this._shaderLanguage = li.WGSL, this.name = t, this._key = r, this._engine = i, this.uniqueId = n._UniqueIdSeed++, this.defines = (o = e.defines) !== null && o !== void 0 ? o : "", this.onError = e.onError, this.onCompiled = e.onCompiled, this._entryPoint = (a = e.entryPoint) !== null && a !== void 0 ? a : "main", this._shaderStore = re.GetShadersStore(this._shaderLanguage), this._shaderRepository = re.GetShadersRepository(this._shaderLanguage), this._includeShaderStore = re.GetIncludesShadersStore(this._shaderLanguage);
        var c = Gi() ? this._engine.getHostDocument() : null;
        t.computeSource ? s = "source:" + t.computeSource : t.computeElement ? (s = c ? c.getElementById(t.computeElement) : null) || (s = t.computeElement) : s = t.compute || t;
        var u = { defines: this.defines.split(`
`), indexParameters: void 0, isFragment: !1, shouldUseHighPrecisionShader: !1, processor: null, supportsUniformBuffers: this._engine.supportsUniformBuffers, shadersRepository: this._shaderRepository, includesShadersStore: this._includeShaderStore, version: (100 * this._engine.version).toString(), platformName: this._engine.shaderPlatformName, processingContext: null, isNDCHalfZRange: this._engine.isNDCHalfZRange, useReverseDepthBuffer: this._engine.useReverseDepthBuffer };
        this._loadShader(s, "Compute", "", function(h) {
          La.Initialize(u), La.PreProcess(h, u, function(d) {
            l._rawComputeSourceCode = h, e.processFinalCode && (d = e.processFinalCode(d));
            var p = La.Finalize(d, "", u);
            l._useFinalCode(p.vertexCode, t);
          }, l._engine);
        });
      }
      return n.prototype._useFinalCode = function(t, e) {
        if (e) {
          var i = e.computeElement || e.compute || e.spectorName || e;
          this._computeSourceCode = "//#define SHADER_NAME compute:" + i + `
` + t;
        } else
          this._computeSourceCode = t;
        this._prepareEffect();
      }, Object.defineProperty(n.prototype, "key", { get: function() {
        return this._key;
      }, enumerable: !1, configurable: !0 }), n.prototype.isReady = function() {
        try {
          return this._isReadyInternal();
        } catch {
          return !1;
        }
      }, n.prototype._isReadyInternal = function() {
        return !!this._isReady || !!this._pipelineContext && this._pipelineContext.isReady;
      }, n.prototype.getEngine = function() {
        return this._engine;
      }, n.prototype.getPipelineContext = function() {
        return this._pipelineContext;
      }, n.prototype.getCompilationError = function() {
        return this._compilationError;
      }, n.prototype.executeWhenCompiled = function(t) {
        var e = this;
        this.isReady() ? t(this) : (this.onCompileObservable.add(function(i) {
          t(i);
        }), this._pipelineContext && !this._pipelineContext.isAsync || setTimeout(function() {
          e._checkIsReady(null);
        }, 16));
      }, n.prototype._checkIsReady = function(t) {
        var e = this;
        try {
          if (this._isReadyInternal())
            return;
        } catch (i) {
          return void this._processCompilationErrors(i, t);
        }
        setTimeout(function() {
          e._checkIsReady(t);
        }, 16);
      }, n.prototype._loadShader = function(t, e, i, r) {
        var o;
        typeof HTMLElement < "u" && t instanceof HTMLElement ? r(Jl(t)) : t.substr(0, 7) !== "source:" ? t.substr(0, 7) !== "base64:" ? this._shaderStore[t + e + "Shader"] ? r(this._shaderStore[t + e + "Shader"]) : i && this._shaderStore[t + i + "Shader"] ? r(this._shaderStore[t + i + "Shader"]) : (o = t[0] === "." || t[0] === "/" || t.indexOf("http") > -1 ? t : this._shaderRepository + t, this._engine._loadFile(o + "." + e.toLowerCase() + ".fx", r)) : r(window.atob(t.substr(7))) : r(t.substr(7));
      }, Object.defineProperty(n.prototype, "computeSourceCode", { get: function() {
        var t, e;
        return this._computeSourceCodeOverride ? this._computeSourceCodeOverride : (e = (t = this._pipelineContext) === null || t === void 0 ? void 0 : t._getComputeShaderCode()) !== null && e !== void 0 ? e : this._computeSourceCode;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "rawComputeSourceCode", { get: function() {
        return this._rawComputeSourceCode;
      }, enumerable: !1, configurable: !0 }), n.prototype._prepareEffect = function() {
        var t = this, e = this.defines, i = this._pipelineContext;
        this._isReady = !1;
        try {
          var r = this._engine;
          this._pipelineContext = r.createComputePipelineContext(), this._pipelineContext._name = this._key, r._prepareComputePipelineContext(this._pipelineContext, this._computeSourceCodeOverride ? this._computeSourceCodeOverride : this._computeSourceCode, this._rawComputeSourceCode, this._computeSourceCodeOverride ? null : e, this._entryPoint), r._executeWhenComputeStateIsCompiled(this._pipelineContext, function() {
            t._compilationError = "", t._isReady = !0, t.onCompiled && t.onCompiled(t), t.onCompileObservable.notifyObservers(t), t.onCompileObservable.clear(), i && t.getEngine()._deleteComputePipelineContext(i);
          }), this._pipelineContext.isAsync && this._checkIsReady(i);
        } catch (o) {
          this._processCompilationErrors(o, i);
        }
      }, n.prototype._getShaderCodeAndErrorLine = function(t, e) {
        var i = null;
        if (e && t) {
          var r = e.match(/COMPUTE SHADER ERROR: 0:(\d+?):/);
          if (r && r.length === 2) {
            var o = parseInt(r[1]), a = t.split(`
`, -1);
            a.length >= o && (i = "Offending line [".concat(o, "] in compute code: ").concat(a[o - 1]));
          }
        }
        return [t, i];
      }, n.prototype._processCompilationErrors = function(t, e) {
        var i, r;
        if (e === void 0 && (e = null), this._compilationError = t.message, q.Error("Unable to compile compute effect:"), q.Error(`Defines:
` + this.defines), n.LogShaderCodeOnCompilationError) {
          var o = null, a = null;
          !((r = this._pipelineContext) === null || r === void 0) && r._getComputeShaderCode() && (a = (i = this._getShaderCodeAndErrorLine(this._pipelineContext._getComputeShaderCode(), this._compilationError))[0], o = i[1], a && (q.Error("Compute code:"), q.Error(a))), o && q.Error(o);
        }
        q.Error("Error: " + this._compilationError), e && (this._pipelineContext = e, this._isReady = !0, this.onError && this.onError(this, this._compilationError), this.onErrorObservable.notifyObservers(this));
      }, n.prototype.dispose = function() {
        this._pipelineContext && this._pipelineContext.dispose(), this._engine._releaseComputeEffect(this);
      }, n.RegisterShader = function(t, e) {
        re.GetShadersStore(li.WGSL)["".concat(t, "ComputeShader")] = e;
      }, n._UniqueIdSeed = 0, n.LogShaderCodeOnCompilationError = !0, n;
    }();
    (function(n) {
      n[n.Texture = 0] = "Texture", n[n.StorageTexture = 1] = "StorageTexture", n[n.UniformBuffer = 2] = "UniformBuffer", n[n.StorageBuffer = 3] = "StorageBuffer", n[n.TextureWithoutSampler = 4] = "TextureWithoutSampler", n[n.Sampler = 5] = "Sampler", n[n.ExternalTexture = 6] = "ExternalTexture";
    })(di || (di = {})), Qe.prototype.createComputeEffect = function(n, t) {
      throw new Error("createComputeEffect: This engine does not support compute shaders!");
    }, Qe.prototype.createComputePipelineContext = function() {
      throw new Error("createComputePipelineContext: This engine does not support compute shaders!");
    }, Qe.prototype.createComputeContext = function() {
    }, Qe.prototype.computeDispatch = function(n, t, e, i, r, o, a) {
      throw new Error("computeDispatch: This engine does not support compute shaders!");
    }, Qe.prototype.areAllComputeEffectsReady = function() {
      return !0;
    }, Qe.prototype.releaseComputeEffects = function() {
    }, Qe.prototype._prepareComputePipelineContext = function(n, t, e, i, r) {
    }, Qe.prototype._rebuildComputeEffects = function() {
    }, Qe.prototype._executeWhenComputeStateIsCompiled = function(n, t) {
      t();
    }, Qe.prototype._releaseComputeEffect = function(n) {
    }, Qe.prototype._deleteComputePipelineContext = function(n) {
    };
    var gf = function() {
      function n(t, e, i, r) {
        r === void 0 && (r = {}), this._bindings = {}, this._samplers = {}, this._contextIsDirty = !1, this.onCompiled = null, this.onError = null, this.name = t, this._engine = e, this.uniqueId = bp.UniqueId, this._engine.getCaps().supportComputeShaders ? r.bindingsMapping ? (this._context = e.createComputeContext(), this._shaderPath = i, this._options = je({ bindingsMapping: {}, defines: [] }, r)) : q.Error("You must provide the binding mappings as browsers don't support reflection for wgsl shaders yet!") : q.Error("This engine does not support compute shaders!");
      }
      return Object.defineProperty(n.prototype, "options", { get: function() {
        return this._options;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "shaderPath", { get: function() {
        return this._shaderPath;
      }, enumerable: !1, configurable: !0 }), n.prototype.getClassName = function() {
        return "ComputeShader";
      }, n.prototype.setTexture = function(t, e, i) {
        i === void 0 && (i = !0);
        var r = this._bindings[t];
        this._bindings[t] = { type: i ? di.Texture : di.TextureWithoutSampler, object: e, indexInGroupEntries: r == null ? void 0 : r.indexInGroupEntries }, this._contextIsDirty || (this._contextIsDirty = !r || r.object !== e || r.type !== this._bindings[t].type);
      }, n.prototype.setStorageTexture = function(t, e) {
        var i = this._bindings[t];
        this._contextIsDirty || (this._contextIsDirty = !i || i.object !== e), this._bindings[t] = { type: di.StorageTexture, object: e, indexInGroupEntries: i == null ? void 0 : i.indexInGroupEntries };
      }, n.prototype.setExternalTexture = function(t, e) {
        var i = this._bindings[t];
        this._contextIsDirty || (this._contextIsDirty = !i || i.object !== e), this._bindings[t] = { type: di.ExternalTexture, object: e, indexInGroupEntries: i == null ? void 0 : i.indexInGroupEntries };
      }, n.prototype.setVideoTexture = function(t, e) {
        return !!e.externalTexture && (this.setExternalTexture(t, e.externalTexture), !0);
      }, n.prototype.setUniformBuffer = function(t, e) {
        var i = this._bindings[t];
        this._contextIsDirty || (this._contextIsDirty = !i || i.object !== e), this._bindings[t] = { type: di.UniformBuffer, object: e, indexInGroupEntries: i == null ? void 0 : i.indexInGroupEntries };
      }, n.prototype.setStorageBuffer = function(t, e) {
        var i = this._bindings[t];
        this._contextIsDirty || (this._contextIsDirty = !i || i.object !== e), this._bindings[t] = { type: di.StorageBuffer, object: e, indexInGroupEntries: i == null ? void 0 : i.indexInGroupEntries };
      }, n.prototype.setTextureSampler = function(t, e) {
        var i = this._bindings[t];
        this._contextIsDirty || (this._contextIsDirty = !i || !e.compareSampler(i.object)), this._bindings[t] = { type: di.Sampler, object: e, indexInGroupEntries: i == null ? void 0 : i.indexInGroupEntries };
      }, n.prototype.isReady = function() {
        var t = this._effect;
        for (var e in this._bindings) {
          var i = this._bindings[e], r = i.type, o = i.object;
          switch (r) {
            case di.Texture:
            case di.TextureWithoutSampler:
            case di.StorageTexture:
            case di.ExternalTexture:
              if (!o.isReady())
                return !1;
          }
        }
        var a = [], s = this._shaderPath;
        if (this._options.defines)
          for (var l = 0; l < this._options.defines.length; l++)
            a.push(this._options.defines[l]);
        var c = a.join(`
`);
        return this._cachedDefines !== c && (this._cachedDefines = c, t = this._engine.createComputeEffect(s, { defines: c, entryPoint: this._options.entryPoint, onCompiled: this.onCompiled, onError: this.onError }), this._effect = t), !!t.isReady();
      }, n.prototype.dispatch = function(t, e, i) {
        var r;
        if (!this.isReady())
          return !1;
        for (var o in this._bindings) {
          var a = this._bindings[o];
          if (!this._options.bindingsMapping[o])
            throw new Error("ComputeShader ('" + this.name + "'): No binding mapping has been provided for the property '" + o + "'");
          switch (a.type) {
            case di.Texture:
              var s = this._samplers[o], l = a.object;
              s && l._texture && s.compareSampler(l._texture) || (this._samplers[o] = new rp().setParameters(l.wrapU, l.wrapV, l.wrapR, l.anisotropicFilteringLevel, l._texture.samplingMode, (r = l._texture) === null || r === void 0 ? void 0 : r._comparisonFunction), this._contextIsDirty = !0);
              break;
            case di.ExternalTexture:
              this._contextIsDirty = !0;
              break;
            case di.UniformBuffer:
              var c = a.object;
              c.getBuffer() !== a.buffer && (a.buffer = c.getBuffer(), this._contextIsDirty = !0);
          }
        }
        return this._contextIsDirty && (this._contextIsDirty = !1, this._context.clear()), this._engine.computeDispatch(this._effect, this._context, this._bindings, t, e, i, this._options.bindingsMapping), !0;
      }, n.prototype.dispatchWhenReady = function(t, e, i, r) {
        var o = this;
        return r === void 0 && (r = 10), new Promise(function(a) {
          var s = function() {
            o.dispatch(t, e, i) ? a() : setTimeout(s, r);
          };
          s();
        });
      }, n.prototype.serialize = function() {
        var t = Ne.Serialize(this);
        for (var e in t.options = this._options, t.shaderPath = this._shaderPath, t.bindings = {}, t.textures = {}, this._bindings) {
          var i = this._bindings[e], r = i.object;
          switch (i.type) {
            case di.Texture:
            case di.TextureWithoutSampler:
            case di.StorageTexture:
              var o = r.serialize();
              o && (t.textures[e] = o, t.bindings[e] = { type: i.type });
            case di.UniformBuffer:
          }
        }
        return t;
      }, n.Parse = function(t, e, i) {
        var r = Ne.Parse(function() {
          return new n(t.name, e.getEngine(), t.shaderPath, t.options);
        }, t, e, i);
        for (var o in t.textures) {
          var a = t.bindings[o], s = ae.Parse(t.textures[o], e, i);
          a.type === di.Texture ? r.setTexture(o, s) : a.type === di.TextureWithoutSampler ? r.setTexture(o, s, !1) : r.setStorageTexture(o, s);
        }
        return r;
      }, x([N()], n.prototype, "name", void 0), n;
    }();
    j("BABYLON.ComputeShader", gf);
    var Iv = function() {
      function n(t, e, i, r, o, a) {
        this.entries = [], this._boundingVectors = new Array(), this._capacity = i, this._depth = r, this._maxDepth = o, this._creationFunc = a, this._minPoint = t, this._maxPoint = e, this._boundingVectors.push(t.clone()), this._boundingVectors.push(e.clone()), this._boundingVectors.push(t.clone()), this._boundingVectors[2].x = e.x, this._boundingVectors.push(t.clone()), this._boundingVectors[3].y = e.y, this._boundingVectors.push(t.clone()), this._boundingVectors[4].z = e.z, this._boundingVectors.push(e.clone()), this._boundingVectors[5].z = t.z, this._boundingVectors.push(e.clone()), this._boundingVectors[6].x = t.x, this._boundingVectors.push(e.clone()), this._boundingVectors[7].y = t.y;
      }
      return Object.defineProperty(n.prototype, "capacity", { get: function() {
        return this._capacity;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "minPoint", { get: function() {
        return this._minPoint;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "maxPoint", { get: function() {
        return this._maxPoint;
      }, enumerable: !1, configurable: !0 }), n.prototype.addEntry = function(t) {
        if (this.blocks)
          for (var e = 0; e < this.blocks.length; e++)
            this.blocks[e].addEntry(t);
        else
          this._creationFunc(t, this), this.entries.length > this.capacity && this._depth < this._maxDepth && this.createInnerBlocks();
      }, n.prototype.removeEntry = function(t) {
        if (this.blocks)
          for (var e = 0; e < this.blocks.length; e++)
            this.blocks[e].removeEntry(t);
        else {
          var i = this.entries.indexOf(t);
          i > -1 && this.entries.splice(i, 1);
        }
      }, n.prototype.addEntries = function(t) {
        for (var e = 0; e < t.length; e++) {
          var i = t[e];
          this.addEntry(i);
        }
      }, n.prototype.select = function(t, e, i) {
        if (cl.IsInFrustum(this._boundingVectors, t)) {
          if (this.blocks) {
            for (var r = 0; r < this.blocks.length; r++)
              this.blocks[r].select(t, e, i);
            return;
          }
          i ? e.concat(this.entries) : e.concatWithNoDuplicate(this.entries);
        }
      }, n.prototype.intersects = function(t, e, i, r) {
        if (cl.IntersectsSphere(this._minPoint, this._maxPoint, t, e)) {
          if (this.blocks) {
            for (var o = 0; o < this.blocks.length; o++)
              this.blocks[o].intersects(t, e, i, r);
            return;
          }
          r ? i.concat(this.entries) : i.concatWithNoDuplicate(this.entries);
        }
      }, n.prototype.intersectsRay = function(t, e) {
        if (t.intersectsBoxMinMax(this._minPoint, this._maxPoint)) {
          if (this.blocks) {
            for (var i = 0; i < this.blocks.length; i++)
              this.blocks[i].intersectsRay(t, e);
            return;
          }
          e.concatWithNoDuplicate(this.entries);
        }
      }, n.prototype.createInnerBlocks = function() {
        n._CreateBlocks(this._minPoint, this._maxPoint, this.entries, this._capacity, this._depth, this._maxDepth, this, this._creationFunc), this.entries.splice(0);
      }, n._CreateBlocks = function(t, e, i, r, o, a, s, l) {
        s.blocks = new Array();
        for (var c = new v((e.x - t.x) / 2, (e.y - t.y) / 2, (e.z - t.z) / 2), u = 0; u < 2; u++)
          for (var h = 0; h < 2; h++)
            for (var d = 0; d < 2; d++) {
              var p = new n(t.add(c.multiplyByFloats(u, h, d)), t.add(c.multiplyByFloats(u + 1, h + 1, d + 1)), r, o + 1, a, l);
              p.addEntries(i), s.blocks.push(p);
            }
      }, n;
    }(), Rc = function() {
      function n(t, e, i) {
        i === void 0 && (i = 2), this.maxDepth = i, this.dynamicContent = [], this._maxBlockCapacity = e || 64, this._selectionContent = new oa(1024), this._creationFunc = t;
      }
      return n.prototype.update = function(t, e, i) {
        Iv._CreateBlocks(t, e, i, this._maxBlockCapacity, 0, this.maxDepth, this, this._creationFunc);
      }, n.prototype.addMesh = function(t) {
        for (var e = 0; e < this.blocks.length; e++)
          this.blocks[e].addEntry(t);
      }, n.prototype.removeMesh = function(t) {
        for (var e = 0; e < this.blocks.length; e++)
          this.blocks[e].removeEntry(t);
      }, n.prototype.select = function(t, e) {
        this._selectionContent.reset();
        for (var i = 0; i < this.blocks.length; i++)
          this.blocks[i].select(t, this._selectionContent, e);
        return e ? this._selectionContent.concat(this.dynamicContent) : this._selectionContent.concatWithNoDuplicate(this.dynamicContent), this._selectionContent;
      }, n.prototype.intersects = function(t, e, i) {
        this._selectionContent.reset();
        for (var r = 0; r < this.blocks.length; r++)
          this.blocks[r].intersects(t, e, this._selectionContent, i);
        return i ? this._selectionContent.concat(this.dynamicContent) : this._selectionContent.concatWithNoDuplicate(this.dynamicContent), this._selectionContent;
      }, n.prototype.intersectsRay = function(t) {
        this._selectionContent.reset();
        for (var e = 0; e < this.blocks.length; e++)
          this.blocks[e].intersectsRay(t, this._selectionContent);
        return this._selectionContent.concatWithNoDuplicate(this.dynamicContent), this._selectionContent;
      }, n.CreationFuncForMeshes = function(t, e) {
        var i = t.getBoundingInfo();
        !t.isBlocked && i.boundingBox.intersectsMinMax(e.minPoint, e.maxPoint) && e.entries.push(t);
      }, n.CreationFuncForSubMeshes = function(t, e) {
        t.getBoundingInfo().boundingBox.intersectsMinMax(e.minPoint, e.maxPoint) && e.entries.push(t);
      }, n;
    }();
    Ue.prototype.createOrUpdateSelectionOctree = function(n, t) {
      n === void 0 && (n = 64), t === void 0 && (t = 2);
      var e = this._getComponent(we.NAME_OCTREE);
      e || (e = new vf(this), this._addComponent(e)), this._selectionOctree || (this._selectionOctree = new Rc(Rc.CreationFuncForMeshes, n, t));
      var i = this.getWorldExtends();
      return this._selectionOctree.update(i.min, i.max, this.meshes), this._selectionOctree;
    }, Object.defineProperty(Ue.prototype, "selectionOctree", { get: function() {
      return this._selectionOctree;
    }, enumerable: !0, configurable: !0 }), Dt.prototype.createOrUpdateSubmeshesOctree = function(n, t) {
      n === void 0 && (n = 64), t === void 0 && (t = 2);
      var e = this.getScene(), i = e._getComponent(we.NAME_OCTREE);
      i || (i = new vf(e), e._addComponent(i)), this._submeshesOctree || (this._submeshesOctree = new Rc(Rc.CreationFuncForSubMeshes, n, t)), this.computeWorldMatrix(!0);
      var r = this.getBoundingInfo().boundingBox;
      return this._submeshesOctree.update(r.minimumWorld, r.maximumWorld, this.subMeshes), this._submeshesOctree;
    };
    var vf = function() {
      function n(t) {
        var e = this;
        this.name = we.NAME_OCTREE, this.checksIsEnabled = !0, this._tempRay = new gi(v.Zero(), new v(1, 1, 1)), (t = t || Me.LastCreatedScene) && (this.scene = t, this.scene.getActiveMeshCandidates = function() {
          return e.getActiveMeshCandidates();
        }, this.scene.getActiveSubMeshCandidates = function(i) {
          return e.getActiveSubMeshCandidates(i);
        }, this.scene.getCollidingSubMeshCandidates = function(i, r) {
          return e.getCollidingSubMeshCandidates(i, r);
        }, this.scene.getIntersectingSubMeshCandidates = function(i, r) {
          return e.getIntersectingSubMeshCandidates(i, r);
        });
      }
      return n.prototype.register = function() {
        var t = this;
        this.scene.onMeshRemovedObservable.add(function(e) {
          var i = t.scene.selectionOctree;
          if (i != null) {
            var r = i.dynamicContent.indexOf(e);
            r !== -1 && i.dynamicContent.splice(r, 1);
          }
        }), this.scene.onMeshImportedObservable.add(function(e) {
          var i = t.scene.selectionOctree;
          i != null && i.addMesh(e);
        });
      }, n.prototype.getActiveMeshCandidates = function() {
        var t;
        return ((t = this.scene._selectionOctree) === null || t === void 0 ? void 0 : t.select(this.scene.frustumPlanes)) || this.scene._getDefaultMeshCandidates();
      }, n.prototype.getActiveSubMeshCandidates = function(t) {
        return t._submeshesOctree && t.useOctreeForRenderingSelection ? t._submeshesOctree.select(this.scene.frustumPlanes) : this.scene._getDefaultSubMeshCandidates(t);
      }, n.prototype.getIntersectingSubMeshCandidates = function(t, e) {
        return t._submeshesOctree && t.useOctreeForPicking ? (gi.TransformToRef(e, t.getWorldMatrix(), this._tempRay), t._submeshesOctree.intersectsRay(this._tempRay)) : this.scene._getDefaultSubMeshCandidates(t);
      }, n.prototype.getCollidingSubMeshCandidates = function(t, e) {
        if (t._submeshesOctree && t.useOctreeForCollisions) {
          var i = e._velocityWorldLength + Math.max(e._radius.x, e._radius.y, e._radius.z);
          return t._submeshesOctree.intersects(e._basePointWorld, i);
        }
        return this.scene._getDefaultSubMeshCandidates(t);
      }, n.prototype.rebuild = function() {
      }, n.prototype.dispose = function() {
      }, n;
    }();
    function gh(n) {
      var t = n.height || 2, e = n.diameterTop === 0 ? 0 : n.diameterTop || n.diameter || 1, i = n.diameterBottom === 0 ? 0 : n.diameterBottom || n.diameter || 1;
      e = e || 1e-5, i = i || 1e-5;
      var r, o = 0 | (n.tessellation || 24), a = 0 | (n.subdivisions || 1), s = !!n.hasRings, l = !!n.enclose, c = n.cap === 0 ? 0 : n.cap || ie.CAP_ALL, u = n.arc && (n.arc <= 0 || n.arc > 1) ? 1 : n.arc || 1, h = n.sideOrientation === 0 ? 0 : n.sideOrientation || Oe.DEFAULTSIDE, d = n.faceUV || new Array(3), p = n.faceColors, f = 2 + (1 + (u !== 1 && l ? 2 : 0)) * (s ? a : 1);
      for (r = 0; r < f; r++)
        p && p[r] === void 0 && (p[r] = new Ie(1, 1, 1, 1));
      for (r = 0; r < f; r++)
        d && d[r] === void 0 && (d[r] = new lt(0, 0, 1, 1));
      var m, g, y, b, T, S, E = [], A = [], R = [], C = [], L = [], I = 2 * Math.PI * u / o, O = (i - e) / 2 / t, w = v.Zero(), z = v.Zero(), V = v.Zero(), Y = v.Zero(), ee = v.Zero(), J = qi.Y, X = 1, K = 1, te = 0, se = 0;
      for (b = 0; b <= a; b++)
        for (y = ((g = b / a) * (e - i) + i) / 2, X = s && b !== 0 && b !== a ? 2 : 1, S = 0; S < X; S++) {
          for (s && (K += S), l && (K += 2 * S), T = 0; T <= o; T++)
            m = T * I, w.x = Math.cos(-m) * y, w.y = -t / 2 + g * t, w.z = Math.sin(-m) * y, e === 0 && b === a ? (z.x = R[R.length - 3 * (o + 1)], z.y = R[R.length - 3 * (o + 1) + 1], z.z = R[R.length - 3 * (o + 1) + 2]) : (z.x = w.x, z.z = w.z, z.y = Math.sqrt(z.x * z.x + z.z * z.z) * O, z.normalize()), T === 0 && (V.copyFrom(w), Y.copyFrom(z)), A.push(w.x, w.y, w.z), R.push(z.x, z.y, z.z), se = s ? te !== K ? d[K].y : d[K].w : d[K].y + (d[K].w - d[K].y) * g, C.push(d[K].x + (d[K].z - d[K].x) * T / o, Lt.UseOpenGLOrientationForUV ? 1 - se : se), p && L.push(p[K].r, p[K].g, p[K].b, p[K].a);
          u !== 1 && l && (A.push(w.x, w.y, w.z), A.push(0, w.y, 0), A.push(0, w.y, 0), A.push(V.x, V.y, V.z), v.CrossToRef(J, z, ee), ee.normalize(), R.push(ee.x, ee.y, ee.z, ee.x, ee.y, ee.z), v.CrossToRef(Y, J, ee), ee.normalize(), R.push(ee.x, ee.y, ee.z, ee.x, ee.y, ee.z), se = s ? te !== K ? d[K + 1].y : d[K + 1].w : d[K + 1].y + (d[K + 1].w - d[K + 1].y) * g, C.push(d[K + 1].x, Lt.UseOpenGLOrientationForUV ? 1 - se : se), C.push(d[K + 1].z, Lt.UseOpenGLOrientationForUV ? 1 - se : se), se = s ? te !== K ? d[K + 2].y : d[K + 2].w : d[K + 2].y + (d[K + 2].w - d[K + 2].y) * g, C.push(d[K + 2].x, Lt.UseOpenGLOrientationForUV ? 1 - se : se), C.push(d[K + 2].z, Lt.UseOpenGLOrientationForUV ? 1 - se : se), p && (L.push(p[K + 1].r, p[K + 1].g, p[K + 1].b, p[K + 1].a), L.push(p[K + 1].r, p[K + 1].g, p[K + 1].b, p[K + 1].a), L.push(p[K + 2].r, p[K + 2].g, p[K + 2].b, p[K + 2].a), L.push(p[K + 2].r, p[K + 2].g, p[K + 2].b, p[K + 2].a))), te !== K && (te = K);
        }
      var _e = u !== 1 && l ? o + 4 : o;
      for (b = 0, K = 0; K < a; K++) {
        var xe = 0, Te = 0, he = 0, me = 0;
        for (T = 0; T < o; T++)
          xe = b * (_e + 1) + T, Te = (b + 1) * (_e + 1) + T, he = b * (_e + 1) + (T + 1), me = (b + 1) * (_e + 1) + (T + 1), E.push(xe, Te, he), E.push(me, he, Te);
        u !== 1 && l && (E.push(xe + 2, Te + 2, he + 2), E.push(me + 2, he + 2, Te + 2), E.push(xe + 4, Te + 4, he + 4), E.push(me + 4, he + 4, Te + 4)), b = s ? b + 2 : b + 1;
      }
      var Fe = function(Re) {
        var Be = Re ? e / 2 : i / 2;
        if (Be !== 0) {
          var De, Ke, ge, rt = Re ? d[f - 1] : d[0], it = null;
          p && (it = Re ? p[f - 1] : p[0]);
          var He = A.length / 3, Pt = Re ? t / 2 : -t / 2, ke = new v(0, Pt, 0);
          A.push(ke.x, ke.y, ke.z), R.push(0, Re ? 1 : -1, 0);
          var xt = rt.y + 0.5 * (rt.w - rt.y);
          C.push(rt.x + 0.5 * (rt.z - rt.x), Lt.UseOpenGLOrientationForUV ? 1 - xt : xt), it && L.push(it.r, it.g, it.b, it.a);
          var Nt = new fe(0.5, 0.5);
          for (ge = 0; ge <= o; ge++) {
            De = 2 * Math.PI * ge * u / o;
            var $e = Math.cos(-De), Rt = Math.sin(-De);
            Ke = new v($e * Be, Pt, Rt * Be);
            var kt = new fe($e * Nt.x + 0.5, Rt * Nt.y + 0.5);
            A.push(Ke.x, Ke.y, Ke.z), R.push(0, Re ? 1 : -1, 0);
            var _t = rt.y + (rt.w - rt.y) * kt.y;
            C.push(rt.x + (rt.z - rt.x) * kt.x, Lt.UseOpenGLOrientationForUV ? 1 - _t : _t), it && L.push(it.r, it.g, it.b, it.a);
          }
          for (ge = 0; ge < o; ge++)
            Re ? (E.push(He), E.push(He + (ge + 2)), E.push(He + (ge + 1))) : (E.push(He), E.push(He + (ge + 1)), E.push(He + (ge + 2)));
        }
      };
      c !== ie.CAP_START && c !== ie.CAP_ALL || Fe(!1), c !== ie.CAP_END && c !== ie.CAP_ALL || Fe(!0), Oe._ComputeSides(h, A, E, R, C, n.frontUVs, n.backUVs);
      var Ce = new Oe();
      return Ce.indices = E, Ce.positions = A, Ce.normals = R, Ce.uvs = C, p && (Ce.colors = L), Ce;
    }
    function Fn(n, t, e) {
      t === void 0 && (t = {});
      var i = new ie(n, e);
      return t.sideOrientation = ie._GetDefaultSideOrientation(t.sideOrientation), i._originalBuilderSideOrientation = t.sideOrientation, gh(t).applyToMesh(i, t.updatable), i;
    }
    var jR = { CreateCylinder: Fn };
    Oe.CreateCylinder = gh, ie.CreateCylinder = function(n, t, e, i, r, o, a, s, l) {
      return a !== void 0 && a instanceof Ue || (a !== void 0 && (l = s || ie.DEFAULTSIDE, s = a), a = o, o = 1), Fn(n, { height: t, diameterTop: e, diameterBottom: i, tessellation: r, subdivisions: o, sideOrientation: l, updatable: s }, a);
    }, oi.AddNodeConstructor("Light_Type_3", function(n, t) {
      return function() {
        return new Pc(n, v.Zero(), t);
      };
    });
    var Cc, Ha, Pc = function(n) {
      function t(e, i, r) {
        var o = n.call(this, e, r) || this;
        return o.groundColor = new ne(0, 0, 0), o.direction = i || v.Up(), o;
      }
      return D(t, n), t.prototype._buildUniformLayout = function() {
        this._uniformBuffer.addUniform("vLightData", 4), this._uniformBuffer.addUniform("vLightDiffuse", 4), this._uniformBuffer.addUniform("vLightSpecular", 4), this._uniformBuffer.addUniform("vLightGround", 3), this._uniformBuffer.addUniform("shadowsInfo", 3), this._uniformBuffer.addUniform("depthValues", 2), this._uniformBuffer.create();
      }, t.prototype.getClassName = function() {
        return "HemisphericLight";
      }, t.prototype.setDirectionToTarget = function(e) {
        return this.direction = v.Normalize(e.subtract(v.Zero())), this.direction;
      }, t.prototype.getShadowGenerator = function() {
        return null;
      }, t.prototype.transferToEffect = function(e, i) {
        var r = v.Normalize(this.direction);
        return this._uniformBuffer.updateFloat4("vLightData", r.x, r.y, r.z, 0, i), this._uniformBuffer.updateColor3("vLightGround", this.groundColor.scale(this.intensity), i), this;
      }, t.prototype.transferToNodeMaterialEffect = function(e, i) {
        var r = v.Normalize(this.direction);
        return e.setFloat3(i, r.x, r.y, r.z), this;
      }, t.prototype.computeWorldMatrix = function() {
        return this._worldMatrix || (this._worldMatrix = B.Identity()), this._worldMatrix;
      }, t.prototype.getTypeID = function() {
        return Kn.LIGHTTYPEID_HEMISPHERICLIGHT;
      }, t.prototype.prepareLightSpecificDefines = function(e, i) {
        e["HEMILIGHT" + i] = !0;
      }, x([ri()], t.prototype, "groundColor", void 0), x([ki()], t.prototype, "direction", void 0), t;
    }(Kn), Fi = function() {
      function n(t, e) {
        e === void 0 && (e = !0);
        var i = this;
        this.originalScene = t, this._pointerCaptures = {}, this._lastPointerEvents = {}, this._sharedGizmoLight = null, this._renderCamera = null, this.pickUtilitySceneFirst = !0, this.shouldRender = !0, this.onlyCheckPointerDownEvents = !0, this.processAllEvents = !1, this.pickingEnabled = !0, this.onPointerOutObservable = new H(), this.utilityLayerScene = new Ue(t.getEngine(), { virtual: !0 }), this.utilityLayerScene.useRightHandedSystem = t.useRightHandedSystem, this.utilityLayerScene._allowPostProcessClearColor = !1, this.utilityLayerScene.postProcessesEnabled = !1, this.utilityLayerScene.detachControl(), e && (this._originalPointerObserver = t.onPrePointerObservable.add(function(r) {
          if (i.utilityLayerScene.activeCamera && i.pickingEnabled && (i.processAllEvents || r.type === Le.POINTERMOVE || r.type === Le.POINTERUP || r.type === Le.POINTERDOWN || r.type === Le.POINTERDOUBLETAP)) {
            i.utilityLayerScene.pointerX = t.pointerX, i.utilityLayerScene.pointerY = t.pointerY;
            var o = r.event;
            if (t.isPointerCaptured(o.pointerId))
              i._pointerCaptures[o.pointerId] = !1;
            else {
              var a = function(u) {
                var h = null;
                if (r.nearInteractionPickingInfo)
                  h = r.nearInteractionPickingInfo.pickedMesh.getScene() == u ? r.nearInteractionPickingInfo : new Ki();
                else if (u !== i.utilityLayerScene && r.originalPickingInfo)
                  h = r.originalPickingInfo;
                else {
                  var d = null;
                  i._renderCamera && (d = u._activeCamera, u._activeCamera = i._renderCamera, r.ray = null), h = r.ray ? u.pickWithRay(r.ray) : u.pick(t.pointerX, t.pointerY), d && (u._activeCamera = d);
                }
                return h;
              }, s = a(i.utilityLayerScene);
              if (!r.ray && s && (r.ray = s.ray), i.utilityLayerScene.onPrePointerObservable.notifyObservers(r), i.onlyCheckPointerDownEvents && r.type != Le.POINTERDOWN)
                return r.skipOnPointerObservable || i.utilityLayerScene.onPointerObservable.notifyObservers(new Sr(r.type, r.event, s), r.type), void (r.type === Le.POINTERUP && i._pointerCaptures[o.pointerId] && (i._pointerCaptures[o.pointerId] = !1));
              if (i.utilityLayerScene.autoClearDepthAndStencil || i.pickUtilitySceneFirst)
                s && s.hit && (r.skipOnPointerObservable || i.utilityLayerScene.onPointerObservable.notifyObservers(new Sr(r.type, r.event, s), r.type), r.skipOnPointerObservable = !0);
              else {
                var l = a(t), c = r.event;
                l && s && (s.distance === 0 && l.pickedMesh ? i.mainSceneTrackerPredicate && i.mainSceneTrackerPredicate(l.pickedMesh) ? (i._notifyObservers(r, l, c), r.skipOnPointerObservable = !0) : r.type === Le.POINTERDOWN ? i._pointerCaptures[c.pointerId] = !0 : r.type !== Le.POINTERMOVE && r.type !== Le.POINTERUP || (i._lastPointerEvents[c.pointerId] && (i.onPointerOutObservable.notifyObservers(c.pointerId), delete i._lastPointerEvents[c.pointerId]), i._notifyObservers(r, l, c)) : !i._pointerCaptures[c.pointerId] && (s.distance < l.distance || l.distance === 0) ? (i._notifyObservers(r, s, c), r.skipOnPointerObservable || (r.skipOnPointerObservable = s.distance > 0)) : !i._pointerCaptures[c.pointerId] && s.distance >= l.distance && (i.mainSceneTrackerPredicate && i.mainSceneTrackerPredicate(l.pickedMesh) ? (i._notifyObservers(r, l, c), r.skipOnPointerObservable = !0) : (r.type !== Le.POINTERMOVE && r.type !== Le.POINTERUP || i._lastPointerEvents[c.pointerId] && (i.onPointerOutObservable.notifyObservers(c.pointerId), delete i._lastPointerEvents[c.pointerId]), i._notifyObservers(r, s, c))), r.type === Le.POINTERUP && i._pointerCaptures[c.pointerId] && (i._pointerCaptures[c.pointerId] = !1));
              }
            }
          }
        }), this._originalPointerObserver && t.onPrePointerObservable.makeObserverTopPriority(this._originalPointerObserver)), this.utilityLayerScene.autoClear = !1, this._afterRenderObserver = this.originalScene.onAfterRenderCameraObservable.add(function(r) {
          i.shouldRender && r == i.getRenderCamera() && i.render();
        }), this._sceneDisposeObserver = this.originalScene.onDisposeObservable.add(function() {
          i.dispose();
        }), this._updateCamera();
      }
      return n.prototype.getRenderCamera = function(t) {
        if (this._renderCamera)
          return this._renderCamera;
        var e;
        return e = this.originalScene.activeCameras && this.originalScene.activeCameras.length > 1 ? this.originalScene.activeCameras[this.originalScene.activeCameras.length - 1] : this.originalScene.activeCamera, t && e && e.isRigCamera ? e.rigParent : e;
      }, n.prototype.setRenderCamera = function(t) {
        this._renderCamera = t;
      }, n.prototype._getSharedGizmoLight = function() {
        return this._sharedGizmoLight || (this._sharedGizmoLight = new Pc("shared gizmo light", new v(0, 1, 0), this.utilityLayerScene), this._sharedGizmoLight.intensity = 2, this._sharedGizmoLight.groundColor = ne.Gray()), this._sharedGizmoLight;
      }, Object.defineProperty(n, "DefaultUtilityLayer", { get: function() {
        return n._DefaultUtilityLayer == null ? n._CreateDefaultUtilityLayerFromScene(Me.LastCreatedScene) : n._DefaultUtilityLayer;
      }, enumerable: !1, configurable: !0 }), n._CreateDefaultUtilityLayerFromScene = function(t) {
        return n._DefaultUtilityLayer = new n(t), n._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(function() {
          n._DefaultUtilityLayer = null;
        }), n._DefaultUtilityLayer;
      }, Object.defineProperty(n, "DefaultKeepDepthUtilityLayer", { get: function() {
        return n._DefaultKeepDepthUtilityLayer == null && (n._DefaultKeepDepthUtilityLayer = new n(Me.LastCreatedScene), n._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = !1, n._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(function() {
          n._DefaultKeepDepthUtilityLayer = null;
        })), n._DefaultKeepDepthUtilityLayer;
      }, enumerable: !1, configurable: !0 }), n.prototype._notifyObservers = function(t, e, i) {
        t.skipOnPointerObservable || (this.utilityLayerScene.onPointerObservable.notifyObservers(new Sr(t.type, t.event, e), t.type), this._lastPointerEvents[i.pointerId] = !0);
      }, n.prototype.render = function() {
        if (this._updateCamera(), this.utilityLayerScene.activeCamera) {
          var t = this.utilityLayerScene.activeCamera.getScene(), e = this.utilityLayerScene.activeCamera;
          e._scene = this.utilityLayerScene, e.leftCamera && (e.leftCamera._scene = this.utilityLayerScene), e.rightCamera && (e.rightCamera._scene = this.utilityLayerScene), this.utilityLayerScene.render(!1), e._scene = t, e.leftCamera && (e.leftCamera._scene = t), e.rightCamera && (e.rightCamera._scene = t);
        }
      }, n.prototype.dispose = function() {
        this.onPointerOutObservable.clear(), this._afterRenderObserver && this.originalScene.onAfterCameraRenderObservable.remove(this._afterRenderObserver), this._sceneDisposeObserver && this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver), this._originalPointerObserver && this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver), this.utilityLayerScene.dispose();
      }, n.prototype._updateCamera = function() {
        this.utilityLayerScene.cameraToUseForPointers = this.getRenderCamera(), this.utilityLayerScene.activeCamera = this.getRenderCamera();
      }, n._DefaultUtilityLayer = null, n._DefaultKeepDepthUtilityLayer = null, n;
    }();
    (function(n) {
      n[n.Origin = 0] = "Origin", n[n.Pivot = 1] = "Pivot";
    })(Cc || (Cc = {})), function(n) {
      n[n.World = 0] = "World", n[n.Local = 1] = "Local";
    }(Ha || (Ha = {}));
    var vh, vn = function() {
      function n(t) {
        t === void 0 && (t = Fi.DefaultUtilityLayer);
        var e = this;
        this.gizmoLayer = t, this._attachedMesh = null, this._attachedNode = null, this._customRotationQuaternion = null, this._scaleRatio = 1, this._isHovered = !1, this._customMeshSet = !1, this._updateGizmoRotationToMatchAttachedMesh = !0, this._updateGizmoPositionToMatchAttachedMesh = !0, this._anchorPoint = Cc.Origin, this._updateScale = !0, this._coordinatesMode = Ha.Local, this._interactionsEnabled = !0, this._rightHandtoLeftHandMatrix = B.RotationY(Math.PI), this._rootMesh = new ie("gizmoRootNode", t.utilityLayerScene), this._rootMesh.rotationQuaternion = oe.Identity(), this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function() {
          e._update();
        });
      }
      return Object.defineProperty(n.prototype, "scaleRatio", { get: function() {
        return this._scaleRatio;
      }, set: function(t) {
        this._scaleRatio = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isHovered", { get: function() {
        return this._isHovered;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "attachedMesh", { get: function() {
        return this._attachedMesh;
      }, set: function(t) {
        this._attachedMesh = t, t && (this._attachedNode = t), this._rootMesh.setEnabled(!!t), this._attachedNodeChanged(t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "attachedNode", { get: function() {
        return this._attachedNode;
      }, set: function(t) {
        this._attachedNode = t, this._attachedMesh = null, this._rootMesh.setEnabled(!!t), this._attachedNodeChanged(t);
      }, enumerable: !1, configurable: !0 }), n.prototype.setCustomMesh = function(t) {
        if (t.getScene() != this.gizmoLayer.utilityLayerScene)
          throw "When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";
        this._rootMesh.getChildMeshes().forEach(function(e) {
          e.dispose();
        }), t.parent = this._rootMesh, this._customMeshSet = !0;
      }, Object.defineProperty(n.prototype, "updateGizmoRotationToMatchAttachedMesh", { get: function() {
        return this._updateGizmoRotationToMatchAttachedMesh;
      }, set: function(t) {
        this._updateGizmoRotationToMatchAttachedMesh = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "updateGizmoPositionToMatchAttachedMesh", { get: function() {
        return this._updateGizmoPositionToMatchAttachedMesh;
      }, set: function(t) {
        this._updateGizmoPositionToMatchAttachedMesh = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "anchorPoint", { get: function() {
        return this._anchorPoint;
      }, set: function(t) {
        this._anchorPoint = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "coordinatesMode", { get: function() {
        return this._coordinatesMode;
      }, set: function(t) {
        this._coordinatesMode = t;
        var e = t == Ha.Local;
        this.updateGizmoRotationToMatchAttachedMesh = e, this.updateGizmoPositionToMatchAttachedMesh = !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "updateScale", { get: function() {
        return this._updateScale;
      }, set: function(t) {
        this._updateScale = t;
      }, enumerable: !1, configurable: !0 }), n.prototype._attachedNodeChanged = function(t) {
      }, Object.defineProperty(n.prototype, "customRotationQuaternion", { get: function() {
        return this._customRotationQuaternion;
      }, set: function(t) {
        this._customRotationQuaternion = t;
      }, enumerable: !1, configurable: !0 }), n.prototype._update = function() {
        if (this.attachedNode) {
          var t = this.attachedNode;
          if (this.attachedMesh && (t = this.attachedMesh || this.attachedNode), this.updateGizmoPositionToMatchAttachedMesh)
            if (this.anchorPoint == Cc.Pivot && t.getAbsolutePivotPoint) {
              var e = t.getAbsolutePivotPoint();
              this._rootMesh.position.copyFrom(e);
            } else {
              var i = t.getWorldMatrix().getRow(3);
              e = i ? i.toVector3() : new v(0, 0, 0), this._rootMesh.position.copyFrom(e);
            }
          if (this.updateGizmoRotationToMatchAttachedMesh) {
            var r = t._isMesh || t.getClassName() === "AbstractMesh" || t.getClassName() === "TransformNode" || t.getClassName() === "InstancedMesh" ? t : void 0;
            t.getWorldMatrix().decompose(void 0, this._rootMesh.rotationQuaternion, void 0, n.PreserveScaling ? r : void 0), this._rootMesh.rotationQuaternion.normalize();
          } else
            this._customRotationQuaternion ? this._rootMesh.rotationQuaternion.copyFrom(this._customRotationQuaternion) : this._rootMesh.rotationQuaternion.set(0, 0, 0, 1);
          if (this.updateScale) {
            var o = this.gizmoLayer.utilityLayerScene.activeCamera, a = o.globalPosition;
            this._rootMesh.position.subtractToRef(a, F.Vector3[0]);
            var s = this.scaleRatio;
            if (o.mode == dt.ORTHOGRAPHIC_CAMERA)
              o.orthoTop && o.orthoBottom && (s *= o.orthoTop - o.orthoBottom);
            else {
              var l = o.getScene().useRightHandedSystem ? v.RightHandedForwardReadOnly : v.LeftHandedForwardReadOnly, c = o.getDirection(l);
              s *= v.Dot(F.Vector3[0], c);
            }
            this._rootMesh.scaling.setAll(s), t._getWorldMatrixDeterminant() < 0 && !n.PreserveScaling && (this._rootMesh.scaling.y *= -1);
          } else
            this._rootMesh.scaling.setAll(this.scaleRatio);
        }
      }, n.prototype._matrixChanged = function() {
        if (this._attachedNode)
          if (this._attachedNode._isCamera) {
            var t = this._attachedNode, e = void 0, i = void 0;
            if (t.parent) {
              var r = F.Matrix[1];
              t.parent._worldMatrix.invertToRef(r), this._attachedNode._worldMatrix.multiplyToRef(r, F.Matrix[0]), e = F.Matrix[0];
            } else
              e = this._attachedNode._worldMatrix;
            if (t.getScene().useRightHandedSystem ? (this._rightHandtoLeftHandMatrix.multiplyToRef(e, F.Matrix[1]), i = F.Matrix[1]) : i = e, i.decompose(F.Vector3[1], F.Quaternion[0], F.Vector3[0]), this._attachedNode.getClassName() === "FreeCamera" || this._attachedNode.getClassName() === "FlyCamera" || this._attachedNode.getClassName() === "ArcFollowCamera" || this._attachedNode.getClassName() === "TargetCamera" || this._attachedNode.getClassName() === "TouchCamera" || this._attachedNode.getClassName() === "UniversalCamera") {
              var o = this._attachedNode;
              o.rotation = F.Quaternion[0].toEulerAngles(), o.rotationQuaternion && (o.rotationQuaternion.copyFrom(F.Quaternion[0]), o.rotationQuaternion.normalize());
            }
            t.position.copyFrom(F.Vector3[0]);
          } else if (this._attachedNode._isMesh || this._attachedNode.getClassName() === "AbstractMesh" || this._attachedNode.getClassName() === "TransformNode" || this._attachedNode.getClassName() === "InstancedMesh") {
            var a = this._attachedNode;
            if (a.parent) {
              r = F.Matrix[0];
              var s = F.Matrix[1];
              if (a.parent.getWorldMatrix().invertToRef(r), this._attachedNode.getWorldMatrix().multiplyToRef(r, s), s.decompose(F.Vector3[0], F.Quaternion[0], a.position), F.Quaternion[0].normalize(), a.isUsingPivotMatrix()) {
                var l = F.Quaternion[1];
                oe.RotationYawPitchRollToRef(a.rotation.y, a.rotation.x, a.rotation.z, l);
                var c = F.Matrix[2];
                B.ScalingToRef(a.scaling.x, a.scaling.y, a.scaling.z, c);
                var u = F.Matrix[2];
                l.toRotationMatrix(u);
                var h = a.getPivotMatrix(), d = F.Matrix[3];
                h.invertToRef(d), h.multiplyToRef(c, F.Matrix[4]), F.Matrix[4].multiplyToRef(u, F.Matrix[5]), F.Matrix[5].multiplyToRef(d, F.Matrix[6]), F.Matrix[6].getTranslationToRef(F.Vector3[1]), a.position.subtractInPlace(F.Vector3[1]);
              }
            } else
              this._attachedNode._worldMatrix.decompose(F.Vector3[0], F.Quaternion[0], a.position, n.PreserveScaling ? a : void 0);
            F.Vector3[0].scaleInPlace(1 / a.scalingDeterminant), a.scaling.copyFrom(F.Vector3[0]), a.billboardMode || (a.rotationQuaternion ? (a.rotationQuaternion.copyFrom(F.Quaternion[0]), a.rotationQuaternion.normalize()) : a.rotation = F.Quaternion[0].toEulerAngles());
          } else if (this._attachedNode.getClassName() === "Bone") {
            var p = this._attachedNode, f = p.getParent();
            if (f) {
              var m = F.Matrix[0], g = F.Matrix[1];
              f.getFinalMatrix().invertToRef(m), p.getFinalMatrix().multiplyToRef(m, g), p.getLocalMatrix().copyFrom(g);
            } else
              p.getLocalMatrix().copyFrom(p.getFinalMatrix());
            p.markAsDirty();
          } else {
            var y = this._attachedNode;
            if (y.getTypeID) {
              var b = y.getTypeID();
              if (b === Kn.LIGHTTYPEID_DIRECTIONALLIGHT || b === Kn.LIGHTTYPEID_SPOTLIGHT || b === Kn.LIGHTTYPEID_POINTLIGHT) {
                var T = y.parent;
                if (T) {
                  m = F.Matrix[0];
                  var S = F.Matrix[1];
                  T.getWorldMatrix().invertToRef(m), y.getWorldMatrix().multiplyToRef(m, S), S.decompose(void 0, F.Quaternion[0], F.Vector3[0]);
                } else
                  this._attachedNode._worldMatrix.decompose(void 0, F.Quaternion[0], F.Vector3[0]);
                y.position = new v(F.Vector3[0].x, F.Vector3[0].y, F.Vector3[0].z), y.direction && (y.direction = new v(y.direction.x, y.direction.y, y.direction.z));
              }
            }
          }
      }, n.prototype._setGizmoMeshMaterial = function(t, e) {
        t && t.forEach(function(i) {
          i.material = e, i.color && (i.color = e.diffuseColor);
        });
      }, n.GizmoAxisPointerObserver = function(t, e) {
        var i = !1, r = t.utilityLayerScene.onPointerObservable.add(function(o) {
          var a, s;
          if (o.pickInfo) {
            if (o.type === Le.POINTERMOVE) {
              if (i)
                return;
              e.forEach(function(l) {
                var c, u;
                if (l.colliderMeshes && l.gizmoMeshes) {
                  var h = ((c = l.colliderMeshes) === null || c === void 0 ? void 0 : c.indexOf((u = o == null ? void 0 : o.pickInfo) === null || u === void 0 ? void 0 : u.pickedMesh)) != -1, d = l.dragBehavior.enabled ? h || l.active ? l.hoverMaterial : l.material : l.disableMaterial;
                  l.gizmoMeshes.forEach(function(p) {
                    p.material = d, p.color && (p.color = d.diffuseColor);
                  });
                }
              });
            }
            o.type === Le.POINTERDOWN && e.has((a = o.pickInfo.pickedMesh) === null || a === void 0 ? void 0 : a.parent) && (i = !0, e.get((s = o.pickInfo.pickedMesh) === null || s === void 0 ? void 0 : s.parent).active = !0, e.forEach(function(l) {
              var c, u, h = (((c = l.colliderMeshes) === null || c === void 0 ? void 0 : c.indexOf((u = o == null ? void 0 : o.pickInfo) === null || u === void 0 ? void 0 : u.pickedMesh)) != -1 || l.active) && l.dragBehavior.enabled ? l.hoverMaterial : l.disableMaterial;
              l.gizmoMeshes.forEach(function(d) {
                d.material = h, d.color && (d.color = h.diffuseColor);
              });
            })), o.type === Le.POINTERUP && e.forEach(function(l) {
              l.active = !1, i = !1, l.gizmoMeshes.forEach(function(c) {
                c.material = l.dragBehavior.enabled ? l.material : l.disableMaterial, c.color && (c.color = l.material.diffuseColor);
              });
            });
          }
        });
        return r;
      }, n.prototype.dispose = function() {
        this._rootMesh.dispose(), this._beforeRenderObserver && this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
      }, n.PreserveScaling = !1, n;
    }(), Fo = function(n) {
      function t(e, i, r, o, a, s, l) {
        i === void 0 && (i = ne.Gray()), r === void 0 && (r = Fi.DefaultUtilityLayer), o === void 0 && (o = null), a === void 0 && (a = 1), s === void 0 && (s = ne.Yellow()), l === void 0 && (l = ne.Gray());
        var c, u = this;
        (u = n.call(this, r) || this)._pointerObserver = null, u.snapDistance = 0, u.onSnapObservable = new H(), u._isEnabled = !0, u._parent = null, u._dragging = !1, u._parent = o, u._coloredMaterial = new Gt("", r.utilityLayerScene), u._coloredMaterial.diffuseColor = i, u._coloredMaterial.specularColor = i.subtract(new ne(0.1, 0.1, 0.1)), u._hoverMaterial = new Gt("", r.utilityLayerScene), u._hoverMaterial.diffuseColor = s, u._disableMaterial = new Gt("", r.utilityLayerScene), u._disableMaterial.diffuseColor = l, u._disableMaterial.alpha = 0.4;
        var h = t._CreateArrow(r.utilityLayerScene, u._coloredMaterial, a), d = t._CreateArrow(r.utilityLayerScene, u._coloredMaterial, a + 4, !0);
        u._gizmoMesh = new ie("", r.utilityLayerScene), u._gizmoMesh.addChild(h), u._gizmoMesh.addChild(d), u._gizmoMesh.lookAt(u._rootMesh.position.add(e)), u._gizmoMesh.scaling.scaleInPlace(1 / 3), u._gizmoMesh.parent = u._rootMesh;
        var p = 0, f = { snapDistance: 0 };
        u.dragBehavior = new Co({ dragAxis: e }), u.dragBehavior.moveAttached = !1, u.dragBehavior.updateDragPlane = !1, u._rootMesh.addBehavior(u.dragBehavior), u.dragBehavior.onDragObservable.add(function(y) {
          if (u.attachedNode) {
            var b = !1;
            if (u.snapDistance == 0)
              u.attachedNode.getWorldMatrix().getTranslationToRef(F.Vector3[2]), F.Vector3[2].addInPlace(y.delta), u.dragBehavior.validateDrag(F.Vector3[2]) && (u.attachedNode.position && u.attachedNode.position.addInPlaceFromFloats(y.delta.x, y.delta.y, y.delta.z), u.attachedNode.getWorldMatrix().addTranslationFromFloats(y.delta.x, y.delta.y, y.delta.z), u.attachedNode.updateCache(), b = !0);
            else if (p += y.dragDistance, Math.abs(p) > u.snapDistance) {
              var T = Math.floor(Math.abs(p) / u.snapDistance);
              p %= u.snapDistance, y.delta.normalizeToRef(F.Vector3[1]), F.Vector3[1].scaleInPlace(u.snapDistance * T), u.attachedNode.getWorldMatrix().getTranslationToRef(F.Vector3[2]), F.Vector3[2].addInPlace(F.Vector3[1]), u.dragBehavior.validateDrag(F.Vector3[2]) && (u.attachedNode.getWorldMatrix().addTranslationFromFloats(F.Vector3[1].x, F.Vector3[1].y, F.Vector3[1].z), u.attachedNode.updateCache(), f.snapDistance = u.snapDistance * T, u.onSnapObservable.notifyObservers(f), b = !0);
            }
            b && u._matrixChanged();
          }
        }), u.dragBehavior.onDragStartObservable.add(function() {
          u._dragging = !0;
        }), u.dragBehavior.onDragEndObservable.add(function() {
          u._dragging = !1;
        });
        var m = r._getSharedGizmoLight();
        m.includedOnlyMeshes = m.includedOnlyMeshes.concat(u._rootMesh.getChildMeshes(!1));
        var g = { gizmoMeshes: h.getChildMeshes(), colliderMeshes: d.getChildMeshes(), material: u._coloredMaterial, hoverMaterial: u._hoverMaterial, disableMaterial: u._disableMaterial, active: !1, dragBehavior: u.dragBehavior };
        return (c = u._parent) === null || c === void 0 || c.addToAxisCache(d, g), u._pointerObserver = r.utilityLayerScene.onPointerObservable.add(function(y) {
          var b;
          if (!u._customMeshSet && (u._isHovered = g.colliderMeshes.indexOf((b = y == null ? void 0 : y.pickInfo) === null || b === void 0 ? void 0 : b.pickedMesh) != -1, !u._parent)) {
            var T = u.dragBehavior.enabled ? u._isHovered || u._dragging ? u._hoverMaterial : u._coloredMaterial : u._disableMaterial;
            u._setGizmoMeshMaterial(g.gizmoMeshes, T);
          }
        }), u.dragBehavior.onEnabledObservable.add(function(y) {
          u._setGizmoMeshMaterial(g.gizmoMeshes, y ? g.material : g.disableMaterial);
        }), u;
      }
      return D(t, n), Object.defineProperty(t.prototype, "coloredMaterial", { get: function() {
        return this._coloredMaterial;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hoverMaterial", { get: function() {
        return this._hoverMaterial;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "disableMaterial", { get: function() {
        return this._disableMaterial;
      }, enumerable: !1, configurable: !0 }), t._CreateArrow = function(e, i, r, o) {
        r === void 0 && (r = 1), o === void 0 && (o = !1);
        var a = new ai("arrow", e), s = Fn("cylinder", { diameterTop: 0, height: 0.075, diameterBottom: 0.0375 * (1 + (r - 1) / 4), tessellation: 96 }, e), l = Fn("cylinder", { diameterTop: 5e-3 * r, height: 0.275, diameterBottom: 5e-3 * r, tessellation: 96 }, e);
        return s.parent = a, s.material = i, s.rotation.x = Math.PI / 2, s.position.z += 0.3, l.parent = a, l.material = i, l.position.z += 0.1375, l.rotation.x = Math.PI / 2, o && (l.visibility = 0, s.visibility = 0), a;
      }, t._CreateArrowInstance = function(e, i) {
        for (var r = new ai("arrow", e), o = 0, a = i.getChildMeshes(); o < a.length; o++) {
          var s = a[o];
          s.createInstance(s.name).parent = r;
        }
        return r;
      }, t.prototype._attachedNodeChanged = function(e) {
        this.dragBehavior && (this.dragBehavior.enabled = !!e);
      }, Object.defineProperty(t.prototype, "isEnabled", { get: function() {
        return this._isEnabled;
      }, set: function(e) {
        this._isEnabled = e, e ? this._parent && (this.attachedMesh = this._parent.attachedMesh, this.attachedNode = this._parent.attachedNode) : (this.attachedMesh = null, this.attachedNode = null);
      }, enumerable: !1, configurable: !0 }), t.prototype.dispose = function() {
        this.onSnapObservable.clear(), this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver), this.dragBehavior.detach(), this._gizmoMesh && this._gizmoMesh.dispose(), [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach(function(e) {
          e && e.dispose();
        }), n.prototype.dispose.call(this);
      }, t;
    }(vn), yl = function() {
      function n(t, e, i, r, o, a, s) {
        if (e === void 0 && (e = 1), i === void 0 && (i = 2), s === void 0 && (s = 1), this._scaleLinesFactor = 4, this._instanced = !1, this.scene = null, this._scaleLines = 1, t = t || Me.LastCreatedScene) {
          if (!r) {
            var l = new Gt("xAxisMaterial", t);
            l.disableLighting = !0, l.emissiveColor = ne.Red().scale(0.5), r = Fo._CreateArrow(t, l, s);
          }
          if (!o) {
            var c = new Gt("yAxisMaterial", t);
            c.disableLighting = !0, c.emissiveColor = ne.Green().scale(0.5), o = Fo._CreateArrow(t, c, s);
          }
          if (!a) {
            var u = new Gt("zAxisMaterial", t);
            u.disableLighting = !0, u.emissiveColor = ne.Blue().scale(0.5), a = Fo._CreateArrow(t, u, s);
          }
          this._xAxis = r, this._yAxis = o, this._zAxis = a, this.scaleLines = e, i != null && (n._SetRenderingGroupId(this._xAxis, i), n._SetRenderingGroupId(this._yAxis, i), n._SetRenderingGroupId(this._zAxis, i)), this.scene = t, this.update(new v(), v.Right(), v.Up(), v.Forward());
        }
      }
      return Object.defineProperty(n.prototype, "scaleLines", { get: function() {
        return this._scaleLines;
      }, set: function(t) {
        this._scaleLines = t, this._xAxis.scaling.setAll(this._scaleLines * this._scaleLinesFactor), this._yAxis.scaling.setAll(this._scaleLines * this._scaleLinesFactor), this._zAxis.scaling.setAll(this._scaleLines * this._scaleLinesFactor);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "xAxis", { get: function() {
        return this._xAxis;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "yAxis", { get: function() {
        return this._yAxis;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "zAxis", { get: function() {
        return this._zAxis;
      }, enumerable: !1, configurable: !0 }), n.prototype.update = function(t, e, i, r) {
        this._xAxis.position.copyFrom(t), this._xAxis.setDirection(e), this._yAxis.position.copyFrom(t), this._yAxis.setDirection(i), this._zAxis.position.copyFrom(t), this._zAxis.setDirection(r);
      }, n.prototype.createInstance = function() {
        var t = Fo._CreateArrowInstance(this.scene, this._xAxis), e = Fo._CreateArrowInstance(this.scene, this._yAxis), i = Fo._CreateArrowInstance(this.scene, this._zAxis), r = new n(this.scene, this.scaleLines, null, t, e, i);
        return r._instanced = !0, r;
      }, n.prototype.dispose = function() {
        this._xAxis && this._xAxis.dispose(!1, !this._instanced), this._yAxis && this._yAxis.dispose(!1, !this._instanced), this._zAxis && this._zAxis.dispose(!1, !this._instanced), this.scene = null;
      }, n._SetRenderingGroupId = function(t, e) {
        t.getChildMeshes().forEach(function(i) {
          i.renderingGroupId = e;
        });
      }, n;
    }(), yf = function(n) {
      function t(e, i, r, o) {
        o === void 0 && (o = 1);
        var a = n.call(this, e, o) || this;
        return a.pos = v.Zero(), a.xaxis = v.Zero(), a.yaxis = v.Zero(), a.zaxis = v.Zero(), a.mesh = r, a.bone = i, a;
      }
      return D(t, n), t.prototype.update = function() {
        if (this.mesh && this.bone) {
          var e = this.bone;
          e.getAbsolutePositionToRef(this.mesh, this.pos), e.getDirectionToRef(qi.X, this.mesh, this.xaxis), e.getDirectionToRef(qi.Y, this.mesh, this.yaxis), e.getDirectionToRef(qi.Z, this.mesh, this.zaxis), n.prototype.update.call(this, this.pos, this.xaxis, this.yaxis, this.zaxis);
        }
      }, t.prototype.dispose = function() {
        this.mesh && (this.mesh = null, this.bone = null, n.prototype.dispose.call(this));
      }, t;
    }(yl);
    Object.defineProperty(Ue.prototype, "debugLayer", { get: function() {
      return this._debugLayer || (this._debugLayer = new bf(this)), this._debugLayer;
    }, enumerable: !0, configurable: !0 }), function(n) {
      n[n.Properties = 0] = "Properties", n[n.Debug = 1] = "Debug", n[n.Statistics = 2] = "Statistics", n[n.Tools = 3] = "Tools", n[n.Settings = 4] = "Settings";
    }(vh || (vh = {}));
    var bf = function() {
      function n(t) {
        var e = this;
        this.BJSINSPECTOR = this._getGlobalInspector(), this._scene = t || Me.LastCreatedScene, this._scene && this._scene.onDisposeObservable.add(function() {
          e._scene._debugLayer && e._scene._debugLayer.hide();
        });
      }
      return Object.defineProperty(n.prototype, "onPropertyChangedObservable", { get: function() {
        return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector ? this.BJSINSPECTOR.Inspector.OnPropertyChangedObservable : (this._onPropertyChangedObservable || (this._onPropertyChangedObservable = new H()), this._onPropertyChangedObservable);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "onSelectionChangedObservable", { get: function() {
        return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector ? this.BJSINSPECTOR.Inspector.OnSelectionChangeObservable : (this._onSelectionChangedObservable || (this._onSelectionChangedObservable = new H()), this._onSelectionChangedObservable);
      }, enumerable: !1, configurable: !0 }), n.prototype._createInspector = function(t) {
        if (!this.isVisible()) {
          if (this._onPropertyChangedObservable) {
            for (var e = 0, i = this._onPropertyChangedObservable.observers; e < i.length; e++) {
              var r = i[e];
              this.BJSINSPECTOR.Inspector.OnPropertyChangedObservable.add(r);
            }
            this._onPropertyChangedObservable.clear(), this._onPropertyChangedObservable = void 0;
          }
          if (this._onSelectionChangedObservable) {
            for (var o = 0, a = this._onSelectionChangedObservable.observers; o < a.length; o++)
              r = a[o], this.BJSINSPECTOR.Inspector.OnSelectionChangedObservable.add(r);
            this._onSelectionChangedObservable.clear(), this._onSelectionChangedObservable = void 0;
          }
          var s = je(je({}, n.Config), t);
          this.BJSINSPECTOR = this.BJSINSPECTOR || this._getGlobalInspector(), this.BJSINSPECTOR.Inspector.Show(this._scene, s);
        }
      }, n.prototype.select = function(t, e) {
        this.BJSINSPECTOR && (e && (Object.prototype.toString.call(e) == "[object String]" ? this.BJSINSPECTOR.Inspector.MarkLineContainerTitleForHighlighting(e) : this.BJSINSPECTOR.Inspector.MarkMultipleLineContainerTitlesForHighlighting(e)), this.BJSINSPECTOR.Inspector.OnSelectionChangeObservable.notifyObservers(t));
      }, n.prototype._getGlobalInspector = function() {
        return typeof INSPECTOR < "u" ? INSPECTOR : typeof BABYLON < "u" && BABYLON.Inspector !== void 0 ? BABYLON : void 0;
      }, n.prototype.isVisible = function() {
        return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.IsVisible;
      }, n.prototype.hide = function() {
        this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.Hide();
      }, n.prototype.setAsActiveScene = function() {
        this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector._SetNewScene(this._scene);
      }, n.prototype.show = function(t) {
        var e = this;
        return new Promise(function(i) {
          if (e.BJSINSPECTOR === void 0) {
            var r = t && t.inspectorURL ? t.inspectorURL : n.InspectorURL;
            de.LoadBabylonScript(r, function() {
              e._createInspector(t), i(e);
            });
          } else
            e._createInspector(t), i(e);
        });
      }, n.InspectorURL = "".concat(de._DefaultCdnUrl, "/v").concat(ve.Version, "/inspector/babylon.inspector.bundle.js"), n.Config = { overlay: !1, showExplorer: !0, showInspector: !0, embedMode: !1, handleResize: !0, enablePopup: !0 }, n;
    }();
    function yh(n) {
      var t, e = [0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11, 12, 13, 14, 12, 14, 15, 16, 17, 18, 16, 18, 19, 20, 21, 22, 20, 22, 23], i = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0], r = [], o = n.width || n.size || 1, a = n.height || n.size || 1, s = n.depth || n.size || 1, l = n.wrap || !1, c = n.topBaseAt === void 0 ? 1 : n.topBaseAt, u = n.bottomBaseAt === void 0 ? 0 : n.bottomBaseAt, h = [2, 0, 3, 1][c = (c + 4) % 4], d = [2, 0, 1, 3][u = (u + 4) % 4], p = [1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1];
      if (l) {
        e = [2, 3, 0, 2, 0, 1, 4, 5, 6, 4, 6, 7, 9, 10, 11, 9, 11, 8, 12, 14, 15, 12, 13, 14], p = [-1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1];
        for (var f = [[1, 1, 1], [-1, 1, 1], [-1, 1, -1], [1, 1, -1]], m = [[-1, -1, 1], [1, -1, 1], [1, -1, -1], [-1, -1, -1]], g = [17, 18, 19, 16], y = [22, 23, 20, 21]; h > 0; )
          f.unshift(f.pop()), g.unshift(g.pop()), h--;
        for (; d > 0; )
          m.unshift(m.pop()), y.unshift(y.pop()), d--;
        f = f.flat(), m = m.flat(), p = p.concat(f).concat(m), e.push(g[0], g[2], g[3], g[0], g[1], g[2]), e.push(y[0], y[2], y[3], y[0], y[1], y[2]);
      }
      var b = [o / 2, a / 2, s / 2];
      t = p.reduce(function(w, z, V) {
        return w.concat(z * b[V % 3]);
      }, []);
      for (var T = n.sideOrientation === 0 ? 0 : n.sideOrientation || Oe.DEFAULTSIDE, S = n.faceUV || new Array(6), E = n.faceColors, A = [], R = 0; R < 6; R++)
        S[R] === void 0 && (S[R] = new lt(0, 0, 1, 1)), E && E[R] === void 0 && (E[R] = new Ie(1, 1, 1, 1));
      for (var C = 0; C < 6; C++)
        if (r.push(S[C].z, Lt.UseOpenGLOrientationForUV ? 1 - S[C].w : S[C].w), r.push(S[C].x, Lt.UseOpenGLOrientationForUV ? 1 - S[C].w : S[C].w), r.push(S[C].x, Lt.UseOpenGLOrientationForUV ? 1 - S[C].y : S[C].y), r.push(S[C].z, Lt.UseOpenGLOrientationForUV ? 1 - S[C].y : S[C].y), E)
          for (var L = 0; L < 4; L++)
            A.push(E[C].r, E[C].g, E[C].b, E[C].a);
      Oe._ComputeSides(T, t, e, i, r, n.frontUVs, n.backUVs);
      var I = new Oe();
      if (I.indices = e, I.positions = t, I.normals = i, I.uvs = r, E) {
        var O = T === Oe.DOUBLESIDE ? A.concat(A) : A;
        I.colors = O;
      }
      return I;
    }
    function Mv(n) {
      var t = n.width || n.size || 1, e = n.height || n.size || 1, i = n.depth || n.size || 1, r = 0 | (n.widthSegments || n.segments || 1), o = 0 | (n.heightSegments || n.segments || 1), a = 0 | (n.depthSegments || n.segments || 1), s = new B(), l = new B(), c = new B(), u = Do({ width: t, height: i, subdivisionsX: r, subdivisionsY: a });
      B.TranslationToRef(0, -e / 2, 0, l), B.RotationZToRef(Math.PI, s), s.multiplyToRef(l, c), u.transform(c);
      var h = Do({ width: t, height: i, subdivisionsX: r, subdivisionsY: a });
      B.TranslationToRef(0, e / 2, 0, c), h.transform(c);
      var d = Do({ width: e, height: i, subdivisionsX: o, subdivisionsY: a });
      B.TranslationToRef(-t / 2, 0, 0, l), B.RotationZToRef(Math.PI / 2, s), s.multiplyToRef(l, c), d.transform(c);
      var p = Do({ width: e, height: i, subdivisionsX: o, subdivisionsY: a });
      B.TranslationToRef(t / 2, 0, 0, l), B.RotationZToRef(-Math.PI / 2, s), s.multiplyToRef(l, c), p.transform(c);
      var f = Do({ width: t, height: e, subdivisionsX: r, subdivisionsY: o });
      B.TranslationToRef(0, 0, -i / 2, l), B.RotationXToRef(-Math.PI / 2, s), s.multiplyToRef(l, c), f.transform(c);
      var m = Do({ width: t, height: e, subdivisionsX: r, subdivisionsY: o });
      return B.TranslationToRef(0, 0, i / 2, l), B.RotationXToRef(Math.PI / 2, s), s.multiplyToRef(l, c), m.transform(c), u.merge([h, p, d, f, m], !0), u;
    }
    function Ur(n, t, e) {
      t === void 0 && (t = {}), e === void 0 && (e = null);
      var i = new ie(n, e);
      return t.sideOrientation = ie._GetDefaultSideOrientation(t.sideOrientation), i._originalBuilderSideOrientation = t.sideOrientation, yh(t).applyToMesh(i, t.updatable), i;
    }
    var YR = { CreateBox: Ur };
    function bh(n) {
      for (var t = 0 | (n.segments || 32), e = n.diameterX || n.diameter || 1, i = n.diameterY || n.diameter || 1, r = n.diameterZ || n.diameter || 1, o = n.arc && (n.arc <= 0 || n.arc > 1) ? 1 : n.arc || 1, a = n.slice && n.slice <= 0 ? 1 : n.slice || 1, s = n.sideOrientation === 0 ? 0 : n.sideOrientation || Oe.DEFAULTSIDE, l = !!n.dedupTopBottomIndices, c = new v(e / 2, i / 2, r / 2), u = 2 + t, h = 2 * u, d = [], p = [], f = [], m = [], g = 0; g <= u; g++) {
        for (var y = g / u, b = y * Math.PI * a, T = 0; T <= h; T++) {
          var S = T / h, E = S * Math.PI * 2 * o, A = B.RotationZ(-b), R = B.RotationY(E), C = v.TransformCoordinates(v.Up(), A), L = v.TransformCoordinates(C, R), I = L.multiply(c), O = L.divide(c).normalize();
          p.push(I.x, I.y, I.z), f.push(O.x, O.y, O.z), m.push(S, Lt.UseOpenGLOrientationForUV ? 1 - y : y);
        }
        if (g > 0)
          for (var w = p.length / 3, z = w - 2 * (h + 1); z + h + 2 < w; z++)
            l ? (g > 1 && (d.push(z), d.push(z + 1), d.push(z + h + 1)), (g < u || a < 1) && (d.push(z + h + 1), d.push(z + 1), d.push(z + h + 2))) : (d.push(z), d.push(z + 1), d.push(z + h + 1), d.push(z + h + 1), d.push(z + 1), d.push(z + h + 2));
      }
      Oe._ComputeSides(s, p, d, f, m, n.frontUVs, n.backUVs);
      var V = new Oe();
      return V.indices = d, V.positions = p, V.normals = f, V.uvs = m, V;
    }
    function yn(n, t, e) {
      t === void 0 && (t = {}), e === void 0 && (e = null);
      var i = new ie(n, e);
      return t.sideOrientation = ie._GetDefaultSideOrientation(t.sideOrientation), i._originalBuilderSideOrientation = t.sideOrientation, bh(t).applyToMesh(i, t.updatable), i;
    }
    Oe.CreateBox = yh, ie.CreateBox = function(n, t, e, i, r) {
      return e === void 0 && (e = null), Ur(n, { size: t, sideOrientation: r, updatable: i }, e);
    };
    var KR = { CreateSphere: yn };
    function Th(n) {
      n === void 0 && (n = { subdivisions: 2, tessellation: 16, height: 1, radius: 0.25, capSubdivisions: 6 });
      var t, e, i = 0 | Math.max(n.subdivisions ? n.subdivisions : 2, 1), r = 0 | Math.max(n.tessellation ? n.tessellation : 16, 3), o = Math.max(n.height ? n.height : 1, 0), a = Math.max(n.radius ? n.radius : 0.25, 0), s = 0 | Math.max(n.capSubdivisions ? n.capSubdivisions : 6, 1), l = r, c = i, u = Math.max(n.radiusTop ? n.radiusTop : a, 0), h = Math.max(n.radiusBottom ? n.radiusBottom : a, 0), d = o - (u + h), p = 2 * Math.PI, f = Math.max(n.topCapSubdivisions ? n.topCapSubdivisions : s, 1), m = Math.max(n.bottomCapSubdivisions ? n.bottomCapSubdivisions : s, 1), g = Math.acos((h - u) / o), y = [], b = [], T = [], S = [], E = 0, A = [], R = 0.5 * d, C = 0.5 * Math.PI, L = v.Zero(), I = v.Zero(), O = Math.cos(g), w = Math.sin(g), z = new fe(u * w, R + u * O).subtract(new fe(h * w, h * O - R)).length(), V = u * g + z + h * (C - g), Y = 0;
      for (e = 0; e <= f; e++) {
        var ee = [], J = C - g * (e / f);
        Y += u * g / f;
        var X = Math.cos(J), K = Math.sin(J), te = X * u;
        for (t = 0; t <= l; t++) {
          var se = (me = t / l) * p + 0, _e = Math.sin(se), xe = Math.cos(se);
          I.x = te * _e, I.y = R + K * u, I.z = te * xe, b.push(I.x, I.y, I.z), L.set(X * _e, K, X * xe), T.push(L.x, L.y, L.z), S.push(me, Lt.UseOpenGLOrientationForUV ? Y / V : 1 - Y / V), ee.push(E), E++;
        }
        A.push(ee);
      }
      var Te = o - u - h + O * u - O * h, he = w * (h - u) / Te;
      for (e = 1; e <= c; e++) {
        for (ee = [], Y += z / c, te = w * (e * (h - u) / c + u), t = 0; t <= l; t++)
          se = (me = t / l) * p + 0, _e = Math.sin(se), xe = Math.cos(se), I.x = te * _e, I.y = R + O * u - e * Te / c, I.z = te * xe, b.push(I.x, I.y, I.z), L.set(_e, he, xe).normalize(), T.push(L.x, L.y, L.z), S.push(me, Lt.UseOpenGLOrientationForUV ? Y / V : 1 - Y / V), ee.push(E), E++;
        A.push(ee);
      }
      for (e = 1; e <= m; e++) {
        for (ee = [], J = C - g - (Math.PI - g) * (e / m), Y += h * g / m, X = Math.cos(J), K = Math.sin(J), te = X * h, t = 0; t <= l; t++) {
          var me;
          se = (me = t / l) * p + 0, _e = Math.sin(se), xe = Math.cos(se), I.x = te * _e, I.y = K * h - R, I.z = te * xe, b.push(I.x, I.y, I.z), L.set(X * _e, K, X * xe), T.push(L.x, L.y, L.z), S.push(me, Lt.UseOpenGLOrientationForUV ? Y / V : 1 - Y / V), ee.push(E), E++;
        }
        A.push(ee);
      }
      for (t = 0; t < l; t++)
        for (e = 0; e < f + c + m; e++) {
          var Fe = A[e][t], Ce = A[e + 1][t], Re = A[e + 1][t + 1], Be = A[e][t + 1];
          y.push(Fe), y.push(Ce), y.push(Be), y.push(Ce), y.push(Re), y.push(Be);
        }
      if (y = y.reverse(), n.orientation && !n.orientation.equals(v.Up())) {
        var De = new B();
        n.orientation.clone().scale(0.5 * Math.PI).cross(v.Up()).toQuaternion().toRotationMatrix(De);
        for (var Ke = v.Zero(), ge = 0; ge < b.length; ge += 3)
          Ke.set(b[ge], b[ge + 1], b[ge + 2]), v.TransformCoordinatesToRef(Ke.clone(), De, Ke), b[ge] = Ke.x, b[ge + 1] = Ke.y, b[ge + 2] = Ke.z;
      }
      var rt = new Oe();
      return rt.positions = b, rt.normals = T, rt.uvs = S, rt.indices = y, rt;
    }
    function Ic(n, t, e) {
      t === void 0 && (t = { orientation: v.Up(), subdivisions: 2, tessellation: 16, height: 1, radius: 0.25, capSubdivisions: 6, updatable: !1 }), e === void 0 && (e = null);
      var i = new ie(n, e);
      return Th(t).applyToMesh(i, t.updatable), i;
    }
    Oe.CreateSphere = bh, ie.CreateSphere = function(n, t, e, i, r, o) {
      return yn(n, { segments: t, diameterX: e, diameterY: e, diameterZ: e, sideOrientation: o, updatable: r }, i);
    };
    var qR = { CreateCapsule: Ic };
    function Tf(n) {
      var t = n.pathArray, e = n.closeArray || !1, i = n.closePath || !1, r = n.invertUV || !1, o = Math.floor(t[0].length / 2), a = n.offset || o;
      a = a > o ? o : Math.floor(a);
      var s, l, c, u, h = n.sideOrientation === 0 ? 0 : n.sideOrientation || Oe.DEFAULTSIDE, d = n.uvs, p = n.colors, f = [], m = [], g = [], y = [], b = [], T = [], S = [], E = [], A = [], R = [];
      if (t.length < 2) {
        var C = [], L = [];
        for (c = 0; c < t[0].length - a; c++)
          C.push(t[0][c]), L.push(t[0][c + a]);
        t = [C, L];
      }
      var I, O, w, z, V, Y = 0, ee = i ? 1 : 0;
      for (s = t[0].length, l = 0; l < t.length; l++) {
        for (S[l] = 0, b[l] = [0], s = s < (O = (I = t[l]).length) ? s : O, u = 0; u < O; )
          f.push(I[u].x, I[u].y, I[u].z), u > 0 && (w = I[u].subtract(I[u - 1]).length() + S[l], b[l].push(w), S[l] = w), u++;
        i && (u--, f.push(I[0].x, I[0].y, I[0].z), w = I[u].subtract(I[0]).length() + S[l], b[l].push(w), S[l] = w), A[l] = O + ee, R[l] = Y, Y += O + ee;
      }
      var J, X, K = null, te = null;
      for (c = 0; c < s + ee; c++) {
        for (E[c] = 0, T[c] = [0], l = 0; l < t.length - 1; l++)
          z = t[l], V = t[l + 1], c === s ? (K = z[0], te = V[0]) : (K = z[c], te = V[c]), w = te.subtract(K).length() + E[c], T[c].push(w), E[c] = w;
        e && te && K && (z = t[l], V = t[0], c === s && (te = V[0]), w = te.subtract(K).length() + E[c], E[c] = w);
      }
      if (d)
        for (l = 0; l < d.length; l++)
          y.push(d[l].x, Lt.UseOpenGLOrientationForUV ? 1 - d[l].y : d[l].y);
      else
        for (l = 0; l < t.length; l++)
          for (c = 0; c < s + ee; c++)
            J = S[l] != 0 ? b[l][c] / S[l] : 0, X = E[c] != 0 ? T[c][l] / E[c] : 0, r ? y.push(X, J) : y.push(J, Lt.UseOpenGLOrientationForUV ? 1 - X : X);
      for (var se = 0, _e = A[l = 0] - 1, xe = A[l + 1] - 1, Te = _e < xe ? _e : xe, he = R[1] - R[0], me = e ? A.length : A.length - 1; se <= Te && l < me; )
        m.push(se, se + he, se + 1), m.push(se + he + 1, se + 1, se + he), (se += 1) === Te && (++l == A.length - 1 ? (he = R[0] - R[l], _e = A[l] - 1, xe = A[0] - 1) : (he = R[l + 1] - R[l], _e = A[l] - 1, xe = A[l + 1] - 1), se = R[l], Te = _e < xe ? _e + se : xe + se);
      if (Oe.ComputeNormals(f, m, g), i) {
        var Fe = 0, Ce = 0;
        for (l = 0; l < t.length; l++)
          Fe = 3 * R[l], Ce = l + 1 < t.length ? 3 * (R[l + 1] - 1) : g.length - 3, g[Fe] = 0.5 * (g[Fe] + g[Ce]), g[Fe + 1] = 0.5 * (g[Fe + 1] + g[Ce + 1]), g[Fe + 2] = 0.5 * (g[Fe + 2] + g[Ce + 2]), g[Ce] = g[Fe], g[Ce + 1] = g[Fe + 1], g[Ce + 2] = g[Fe + 2];
      }
      Oe._ComputeSides(h, f, m, g, y, n.frontUVs, n.backUVs);
      var Re = null;
      if (p) {
        Re = new Float32Array(4 * p.length);
        for (var Be = 0; Be < p.length; Be++)
          Re[4 * Be] = p[Be].r, Re[4 * Be + 1] = p[Be].g, Re[4 * Be + 2] = p[Be].b, Re[4 * Be + 3] = p[Be].a;
      }
      var De = new Oe(), Ke = new Float32Array(f), ge = new Float32Array(g), rt = new Float32Array(y);
      return De.indices = m, De.positions = Ke, De.normals = ge, De.uvs = rt, Re && De.set(Re, P.ColorKind), i && (De._idx = R), De;
    }
    function pa(n, t, e) {
      e === void 0 && (e = null);
      var i = t.pathArray, r = t.closeArray, o = t.closePath, a = ie._GetDefaultSideOrientation(t.sideOrientation), s = t.instance, l = t.updatable;
      if (s) {
        var c = F.Vector3[0].setAll(Number.MAX_VALUE), u = F.Vector3[1].setAll(-Number.MAX_VALUE), h = s.getVerticesData(P.PositionKind);
        if (function(I) {
          for (var O = i[0].length, w = s, z = 0, V = w._originalBuilderSideOrientation === ie.DOUBLESIDE ? 2 : 1, Y = 1; Y <= V; ++Y)
            for (var ee = 0; ee < i.length; ++ee) {
              var J = i[ee], X = J.length;
              O = O < X ? O : X;
              for (var K = 0; K < O; ++K) {
                var te = J[K];
                I[z] = te.x, I[z + 1] = te.y, I[z + 2] = te.z, c.minimizeInPlaceFromFloats(te.x, te.y, te.z), u.maximizeInPlaceFromFloats(te.x, te.y, te.z), z += 3;
              }
              w._creationDataStorage && w._creationDataStorage.closePath && (te = J[0], I[z] = te.x, I[z + 1] = te.y, I[z + 2] = te.z, z += 3);
            }
        }(h), s.hasBoundingInfo ? s.getBoundingInfo().reConstruct(c, u, s._worldMatrix) : s.buildBoundingInfo(c, u, s._worldMatrix), s.updateVerticesData(P.PositionKind, h, !1, !1), t.colors) {
          for (var d = s.getVerticesData(P.ColorKind), p = 0, f = 0; p < t.colors.length; p++, f += 4) {
            var m = t.colors[p];
            d[f] = m.r, d[f + 1] = m.g, d[f + 2] = m.b, d[f + 3] = m.a;
          }
          s.updateVerticesData(P.ColorKind, d, !1, !1);
        }
        if (t.uvs) {
          for (var g = s.getVerticesData(P.UVKind), y = 0; y < t.uvs.length; y++)
            g[2 * y] = t.uvs[y].x, g[2 * y + 1] = Lt.UseOpenGLOrientationForUV ? 1 - t.uvs[y].y : t.uvs[y].y;
          s.updateVerticesData(P.UVKind, g, !1, !1);
        }
        if (!s.areNormalsFrozen || s.isFacetDataEnabled) {
          var b = s.getIndices(), T = s.getVerticesData(P.NormalKind), S = s.isFacetDataEnabled ? s.getFacetDataParameters() : null;
          if (Oe.ComputeNormals(h, b, T, S), s._creationDataStorage && s._creationDataStorage.closePath)
            for (var E = 0, A = 0, R = 0; R < i.length; R++)
              E = 3 * s._creationDataStorage.idx[R], A = R + 1 < i.length ? 3 * (s._creationDataStorage.idx[R + 1] - 1) : T.length - 3, T[E] = 0.5 * (T[E] + T[A]), T[E + 1] = 0.5 * (T[E + 1] + T[A + 1]), T[E + 2] = 0.5 * (T[E + 2] + T[A + 2]), T[A] = T[E], T[A + 1] = T[E + 1], T[A + 2] = T[E + 2];
          s.areNormalsFrozen || s.updateVerticesData(P.NormalKind, T, !1, !1);
        }
        return s;
      }
      var C = new ie(n, e);
      C._originalBuilderSideOrientation = a, C._creationDataStorage = new Ap();
      var L = Tf(t);
      return o && (C._creationDataStorage.idx = L._idx), C._creationDataStorage.closePath = o, C._creationDataStorage.closeArray = r, L.applyToMesh(C, l), C;
    }
    ie.CreateCapsule = function(n, t, e) {
      return Ic(n, t, e);
    }, Oe.CreateCapsule = Th;
    var QR = { CreateRibbon: pa };
    function Eh(n) {
      var t = [], e = [], i = [], r = [], o = n.radius || 0.5, a = n.tessellation || 64, s = n.arc && (n.arc <= 0 || n.arc > 1) ? 1 : n.arc || 1, l = n.sideOrientation === 0 ? 0 : n.sideOrientation || Oe.DEFAULTSIDE;
      t.push(0, 0, 0), r.push(0.5, 0.5);
      for (var c = 2 * Math.PI * s, u = s === 1 ? c / a : c / (a - 1), h = 0, d = 0; d < a; d++) {
        var p = Math.cos(h), f = Math.sin(h), m = (p + 1) / 2, g = (1 - f) / 2;
        t.push(o * p, o * f, 0), r.push(m, Lt.UseOpenGLOrientationForUV ? 1 - g : g), h += u;
      }
      s === 1 && (t.push(t[3], t[4], t[5]), r.push(r[2], Lt.UseOpenGLOrientationForUV ? 1 - r[3] : r[3]));
      for (var y = t.length / 3, b = 1; b < y - 1; b++)
        e.push(b + 1, 0, b);
      Oe.ComputeNormals(t, e, i), Oe._ComputeSides(l, t, e, i, r, n.frontUVs, n.backUVs);
      var T = new Oe();
      return T.indices = e, T.positions = t, T.normals = i, T.uvs = r, T;
    }
    function bl(n, t, e) {
      t === void 0 && (t = {}), e === void 0 && (e = null);
      var i = new ie(n, e);
      return t.sideOrientation = ie._GetDefaultSideOrientation(t.sideOrientation), i._originalBuilderSideOrientation = t.sideOrientation, Eh(t).applyToMesh(i, t.updatable), i;
    }
    Oe.CreateRibbon = Tf, ie.CreateRibbon = function(n, t, e, i, r, o, a, s, l) {
      return e === void 0 && (e = !1), a === void 0 && (a = !1), pa(n, { pathArray: t, closeArray: e, closePath: i, offset: r, updatable: a, sideOrientation: s, instance: l }, o);
    };
    var ZR = { CreateDisc: bl };
    function Tl(n) {
      var t = n.pattern || ie.NO_FLIP, e = n.tileWidth || n.tileSize || 1, i = n.tileHeight || n.tileSize || 1, r = n.alignHorizontal || 0, o = n.alignVertical || 0, a = n.width || n.size || 1, s = Math.floor(a / e), l = a - s * e, c = n.height || n.size || 1, u = Math.floor(c / i), h = c - u * i, d = e * s / 2, p = i * u / 2, f = 0, m = 0, g = 0, y = 0, b = 0, T = 0;
      if (l > 0 || h > 0) {
        switch (g = -d, y = -p, b = d, T = p, r) {
          case ie.CENTER:
            g -= l /= 2, b += l;
            break;
          case ie.LEFT:
            b += l, f = -l / 2;
            break;
          case ie.RIGHT:
            g -= l, f = l / 2;
        }
        switch (o) {
          case ie.CENTER:
            y -= h /= 2, T += h;
            break;
          case ie.BOTTOM:
            T += h, m = -h / 2;
            break;
          case ie.TOP:
            y -= h, m = h / 2;
        }
      }
      var S = [], E = [], A = [];
      A[0] = [0, 0, 1, 0, 1, 1, 0, 1], A[1] = [0, 0, 1, 0, 1, 1, 0, 1], t !== ie.ROTATE_TILE && t !== ie.ROTATE_ROW || (A[1] = [1, 1, 0, 1, 0, 0, 1, 0]), t !== ie.FLIP_TILE && t !== ie.FLIP_ROW || (A[1] = [1, 0, 0, 0, 0, 1, 1, 1]), t !== ie.FLIP_N_ROTATE_TILE && t !== ie.FLIP_N_ROTATE_ROW || (A[1] = [0, 1, 1, 1, 1, 0, 0, 0]);
      for (var R = [], C = [], L = [], I = 0, O = 0; O < u; O++)
        for (var w = 0; w < s; w++)
          S.push(w * e - d + f, O * i - p + m, 0), S.push((w + 1) * e - d + f, O * i - p + m, 0), S.push((w + 1) * e - d + f, (O + 1) * i - p + m, 0), S.push(w * e - d + f, (O + 1) * i - p + m, 0), L.push(I, I + 1, I + 3, I + 1, I + 2, I + 3), R = t === ie.FLIP_TILE || t === ie.ROTATE_TILE || t === ie.FLIP_N_ROTATE_TILE ? R.concat(A[(w % 2 + O % 2) % 2]) : t === ie.FLIP_ROW || t === ie.ROTATE_ROW || t === ie.FLIP_N_ROTATE_ROW ? R.concat(A[O % 2]) : R.concat(A[0]), C.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), E.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1), I += 4;
      if (l > 0 || h > 0) {
        var z = h > 0 && (o === ie.CENTER || o === ie.TOP), V = h > 0 && (o === ie.CENTER || o === ie.BOTTOM), Y = l > 0 && (r === ie.CENTER || r === ie.RIGHT), ee = l > 0 && (r === ie.CENTER || r === ie.LEFT), J = [], X = void 0, K = void 0, te = void 0, se = void 0;
        if (z && Y && (S.push(g + f, y + m, 0), S.push(-d + f, y + m, 0), S.push(-d + f, y + h + m, 0), S.push(g + f, y + h + m, 0), L.push(I, I + 1, I + 3, I + 1, I + 2, I + 3), I += 4, J = [X = 1 - l / e, K = 1 - h / i, te = 1, K, te, se = 1, X, se], t === ie.ROTATE_ROW && (J = [1 - X, 1 - K, 1 - te, 1 - K, 1 - te, 1 - se, 1 - X, 1 - se]), t === ie.FLIP_ROW && (J = [1 - X, K, 1 - te, K, 1 - te, se, 1 - X, se]), t === ie.FLIP_N_ROTATE_ROW && (J = [X, 1 - K, te, 1 - K, te, 1 - se, X, 1 - se]), R = R.concat(J), C.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), E.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)), z && ee && (S.push(d + f, y + m, 0), S.push(b + f, y + m, 0), S.push(b + f, y + h + m, 0), S.push(d + f, y + h + m, 0), L.push(I, I + 1, I + 3, I + 1, I + 2, I + 3), I += 4, J = [X = 0, K = 1 - h / i, te = l / e, K, te, se = 1, X, se], (t === ie.ROTATE_ROW || t === ie.ROTATE_TILE && s % 2 == 0) && (J = [1 - X, 1 - K, 1 - te, 1 - K, 1 - te, 1 - se, 1 - X, 1 - se]), (t === ie.FLIP_ROW || t === ie.FLIP_TILE && s % 2 == 0) && (J = [1 - X, K, 1 - te, K, 1 - te, se, 1 - X, se]), (t === ie.FLIP_N_ROTATE_ROW || t === ie.FLIP_N_ROTATE_TILE && s % 2 == 0) && (J = [X, 1 - K, te, 1 - K, te, 1 - se, X, 1 - se]), R = R.concat(J), C.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), E.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)), V && Y && (S.push(g + f, p + m, 0), S.push(-d + f, p + m, 0), S.push(-d + f, T + m, 0), S.push(g + f, T + m, 0), L.push(I, I + 1, I + 3, I + 1, I + 2, I + 3), I += 4, J = [X = 1 - l / e, K = 0, te = 1, K, te, se = h / i, X, se], (t === ie.ROTATE_ROW && u % 2 == 1 || t === ie.ROTATE_TILE && u % 1 == 0) && (J = [1 - X, 1 - K, 1 - te, 1 - K, 1 - te, 1 - se, 1 - X, 1 - se]), (t === ie.FLIP_ROW && u % 2 == 1 || t === ie.FLIP_TILE && u % 2 == 0) && (J = [1 - X, K, 1 - te, K, 1 - te, se, 1 - X, se]), (t === ie.FLIP_N_ROTATE_ROW && u % 2 == 1 || t === ie.FLIP_N_ROTATE_TILE && u % 2 == 0) && (J = [X, 1 - K, te, 1 - K, te, 1 - se, X, 1 - se]), R = R.concat(J), C.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), E.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)), V && ee && (S.push(d + f, p + m, 0), S.push(b + f, p + m, 0), S.push(b + f, T + m, 0), S.push(d + f, T + m, 0), L.push(I, I + 1, I + 3, I + 1, I + 2, I + 3), I += 4, J = [X = 0, K = 0, te = l / e, K, te, se = h / i, X, se], (t === ie.ROTATE_ROW && u % 2 == 1 || t === ie.ROTATE_TILE && (u + s) % 2 == 1) && (J = [1 - X, 1 - K, 1 - te, 1 - K, 1 - te, 1 - se, 1 - X, 1 - se]), (t === ie.FLIP_ROW && u % 2 == 1 || t === ie.FLIP_TILE && (u + s) % 2 == 1) && (J = [1 - X, K, 1 - te, K, 1 - te, se, 1 - X, se]), (t === ie.FLIP_N_ROTATE_ROW && u % 2 == 1 || t === ie.FLIP_N_ROTATE_TILE && (u + s) % 2 == 1) && (J = [X, 1 - K, te, 1 - K, te, 1 - se, X, 1 - se]), R = R.concat(J), C.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), E.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)), z) {
          var _e = [];
          for (X = 0, K = 1 - h / i, te = 1, se = 1, _e[0] = [X, K, te, K, te, se, X, se], _e[1] = [X, K, te, K, te, se, X, se], t !== ie.ROTATE_TILE && t !== ie.ROTATE_ROW || (_e[1] = [1 - X, 1 - K, 1 - te, 1 - K, 1 - te, 1 - se, 1 - X, 1 - se]), t !== ie.FLIP_TILE && t !== ie.FLIP_ROW || (_e[1] = [1 - X, K, 1 - te, K, 1 - te, se, 1 - X, se]), t !== ie.FLIP_N_ROTATE_TILE && t !== ie.FLIP_N_ROTATE_ROW || (_e[1] = [X, 1 - K, te, 1 - K, te, 1 - se, X, 1 - se]), w = 0; w < s; w++)
            S.push(w * e - d + f, y + m, 0), S.push((w + 1) * e - d + f, y + m, 0), S.push((w + 1) * e - d + f, y + h + m, 0), S.push(w * e - d + f, y + h + m, 0), L.push(I, I + 1, I + 3, I + 1, I + 2, I + 3), I += 4, R = t === ie.FLIP_TILE || t === ie.ROTATE_TILE || t === ie.FLIP_N_ROTATE_TILE ? R.concat(_e[(w + 1) % 2]) : t === ie.FLIP_ROW || t === ie.ROTATE_ROW || t === ie.FLIP_N_ROTATE_ROW ? R.concat(_e[1]) : R.concat(_e[0]), C.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), E.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1);
        }
        if (V) {
          var xe = [];
          for (X = 0, K = 0, te = 1, se = h / i, xe[0] = [X, K, te, K, te, se, X, se], xe[1] = [X, K, te, K, te, se, X, se], t !== ie.ROTATE_TILE && t !== ie.ROTATE_ROW || (xe[1] = [1 - X, 1 - K, 1 - te, 1 - K, 1 - te, 1 - se, 1 - X, 1 - se]), t !== ie.FLIP_TILE && t !== ie.FLIP_ROW || (xe[1] = [1 - X, K, 1 - te, K, 1 - te, se, 1 - X, se]), t !== ie.FLIP_N_ROTATE_TILE && t !== ie.FLIP_N_ROTATE_ROW || (xe[1] = [X, 1 - K, te, 1 - K, te, 1 - se, X, 1 - se]), w = 0; w < s; w++)
            S.push(w * e - d + f, T - h + m, 0), S.push((w + 1) * e - d + f, T - h + m, 0), S.push((w + 1) * e - d + f, T + m, 0), S.push(w * e - d + f, T + m, 0), L.push(I, I + 1, I + 3, I + 1, I + 2, I + 3), I += 4, R = t === ie.FLIP_TILE || t === ie.ROTATE_TILE || t === ie.FLIP_N_ROTATE_TILE ? R.concat(xe[(w + u) % 2]) : t === ie.FLIP_ROW || t === ie.ROTATE_ROW || t === ie.FLIP_N_ROTATE_ROW ? R.concat(xe[u % 2]) : R.concat(xe[0]), C.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), E.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1);
        }
        if (Y) {
          var Te = [];
          for (X = 1 - l / e, K = 0, te = 1, se = 1, Te[0] = [X, K, te, K, te, se, X, se], Te[1] = [X, K, te, K, te, se, X, se], t !== ie.ROTATE_TILE && t !== ie.ROTATE_ROW || (Te[1] = [1 - X, 1 - K, 1 - te, 1 - K, 1 - te, 1 - se, 1 - X, 1 - se]), t !== ie.FLIP_TILE && t !== ie.FLIP_ROW || (Te[1] = [1 - X, K, 1 - te, K, 1 - te, se, 1 - X, se]), t !== ie.FLIP_N_ROTATE_TILE && t !== ie.FLIP_N_ROTATE_ROW || (Te[1] = [X, 1 - K, te, 1 - K, te, 1 - se, X, 1 - se]), O = 0; O < u; O++)
            S.push(g + f, O * i - p + m, 0), S.push(g + l + f, O * i - p + m, 0), S.push(g + l + f, (O + 1) * i - p + m, 0), S.push(g + f, (O + 1) * i - p + m, 0), L.push(I, I + 1, I + 3, I + 1, I + 2, I + 3), I += 4, R = t === ie.FLIP_TILE || t === ie.ROTATE_TILE || t === ie.FLIP_N_ROTATE_TILE ? R.concat(Te[(O + 1) % 2]) : t === ie.FLIP_ROW || t === ie.ROTATE_ROW || t === ie.FLIP_N_ROTATE_ROW ? R.concat(Te[O % 2]) : R.concat(Te[0]), C.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), E.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1);
        }
        if (ee) {
          var he = [];
          for (X = 0, K = 0, te = l / i, se = 1, he[0] = [X, K, te, K, te, se, X, se], he[1] = [X, K, te, K, te, se, X, se], t !== ie.ROTATE_TILE && t !== ie.ROTATE_ROW || (he[1] = [1 - X, 1 - K, 1 - te, 1 - K, 1 - te, 1 - se, 1 - X, 1 - se]), t !== ie.FLIP_TILE && t !== ie.FLIP_ROW || (he[1] = [1 - X, K, 1 - te, K, 1 - te, se, 1 - X, se]), t !== ie.FLIP_N_ROTATE_TILE && t !== ie.FLIP_N_ROTATE_ROW || (he[1] = [X, 1 - K, te, 1 - K, te, 1 - se, X, 1 - se]), O = 0; O < u; O++)
            S.push(b - l + f, O * i - p + m, 0), S.push(b + f, O * i - p + m, 0), S.push(b + f, (O + 1) * i - p + m, 0), S.push(b - l + f, (O + 1) * i - p + m, 0), L.push(I, I + 1, I + 3, I + 1, I + 2, I + 3), I += 4, R = t === ie.FLIP_TILE || t === ie.ROTATE_TILE || t === ie.FLIP_N_ROTATE_TILE ? R.concat(he[(O + s) % 2]) : t === ie.FLIP_ROW || t === ie.ROTATE_ROW || t === ie.FLIP_N_ROTATE_ROW ? R.concat(he[O % 2]) : R.concat(he[0]), C.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), E.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1);
        }
      }
      var me = n.sideOrientation === 0 ? 0 : n.sideOrientation || Oe.DEFAULTSIDE;
      Oe._ComputeSides(me, S, L, E, R, n.frontUVs, n.backUVs);
      var Fe = new Oe();
      Fe.indices = L, Fe.positions = S, Fe.normals = E, Fe.uvs = R;
      var Ce = me === Oe.DOUBLESIDE ? C.concat(C) : C;
      return Fe.colors = Ce, Fe;
    }
    function Ef(n, t, e) {
      e === void 0 && (e = null);
      var i = new ie(n, e);
      return t.sideOrientation = ie._GetDefaultSideOrientation(t.sideOrientation), i._originalBuilderSideOrientation = t.sideOrientation, Tl(t).applyToMesh(i, t.updatable), i;
    }
    Oe.CreateDisc = Eh, ie.CreateDisc = function(n, t, e, i, r, o) {
      return i === void 0 && (i = null), bl(n, { radius: t, tessellation: e, sideOrientation: o, updatable: r }, i);
    };
    var JR = { CreateTiledPlane: Ef };
    function Sf(n) {
      for (var t = n.faceUV || new Array(6), e = n.faceColors, i = n.pattern || ie.NO_FLIP, r = n.width || n.size || 1, o = n.height || n.size || 1, a = n.depth || n.size || 1, s = n.tileWidth || n.tileSize || 1, l = n.tileHeight || n.tileSize || 1, c = n.alignHorizontal || 0, u = n.alignVertical || 0, h = n.sideOrientation === 0 ? 0 : n.sideOrientation || Oe.DEFAULTSIDE, d = 0; d < 6; d++)
        t[d] === void 0 && (t[d] = new lt(0, 0, 1, 1)), e && e[d] === void 0 && (e[d] = new Ie(1, 1, 1, 1));
      var p = r / 2, f = o / 2, m = a / 2, g = [];
      for (d = 0; d < 2; d++)
        g[d] = Tl({ pattern: i, tileWidth: s, tileHeight: l, width: r, height: o, alignVertical: u, alignHorizontal: c, sideOrientation: h });
      for (d = 2; d < 4; d++)
        g[d] = Tl({ pattern: i, tileWidth: s, tileHeight: l, width: a, height: o, alignVertical: u, alignHorizontal: c, sideOrientation: h });
      var y = u;
      for (u === ie.BOTTOM ? y = ie.TOP : u === ie.TOP && (y = ie.BOTTOM), d = 4; d < 6; d++)
        g[d] = Tl({ pattern: i, tileWidth: s, tileHeight: l, width: r, height: a, alignVertical: y, alignHorizontal: c, sideOrientation: h });
      var b = [], T = [], S = [], E = [], A = [], R = [], C = [], L = [], I = 0, O = 0;
      for (d = 0; d < 6; d++) {
        var w = g[d].positions.length;
        R[d] = [], C[d] = [];
        for (var z = 0; z < w / 3; z++)
          R[d].push(new v(g[d].positions[3 * z], g[d].positions[3 * z + 1], g[d].positions[3 * z + 2])), C[d].push(new v(g[d].normals[3 * z], g[d].normals[3 * z + 1], g[d].normals[3 * z + 2]));
        I = g[d].uvs.length, L[d] = [];
        for (var V = 0; V < I; V += 2)
          L[d][V] = t[d].x + (t[d].z - t[d].x) * g[d].uvs[V], L[d][V + 1] = t[d].y + (t[d].w - t[d].y) * g[d].uvs[V + 1], Lt.UseOpenGLOrientationForUV && (L[d][V + 1] = 1 - L[d][V + 1]);
        if (S = S.concat(L[d]), E = E.concat(g[d].indices.map(function(me) {
          return me + O;
        })), O += R[d].length, e)
          for (var Y = 0; Y < 4; Y++)
            A.push(e[d].r, e[d].g, e[d].b, e[d].a);
      }
      var ee = new v(0, 0, m), J = B.RotationY(Math.PI);
      b = R[0].map(function(me) {
        return v.TransformNormal(me, J).add(ee);
      }).map(function(me) {
        return [me.x, me.y, me.z];
      }).reduce(function(me, Fe) {
        return me.concat(Fe);
      }, []), T = C[0].map(function(me) {
        return v.TransformNormal(me, J);
      }).map(function(me) {
        return [me.x, me.y, me.z];
      }).reduce(function(me, Fe) {
        return me.concat(Fe);
      }, []), b = b.concat(R[1].map(function(me) {
        return me.subtract(ee);
      }).map(function(me) {
        return [me.x, me.y, me.z];
      }).reduce(function(me, Fe) {
        return me.concat(Fe);
      }, [])), T = T.concat(C[1].map(function(me) {
        return [me.x, me.y, me.z];
      }).reduce(function(me, Fe) {
        return me.concat(Fe);
      }, []));
      var X = new v(p, 0, 0), K = B.RotationY(-Math.PI / 2);
      b = b.concat(R[2].map(function(me) {
        return v.TransformNormal(me, K).add(X);
      }).map(function(me) {
        return [me.x, me.y, me.z];
      }).reduce(function(me, Fe) {
        return me.concat(Fe);
      }, [])), T = T.concat(C[2].map(function(me) {
        return v.TransformNormal(me, K);
      }).map(function(me) {
        return [me.x, me.y, me.z];
      }).reduce(function(me, Fe) {
        return me.concat(Fe);
      }, []));
      var te = B.RotationY(Math.PI / 2);
      b = b.concat(R[3].map(function(me) {
        return v.TransformNormal(me, te).subtract(X);
      }).map(function(me) {
        return [me.x, me.y, me.z];
      }).reduce(function(me, Fe) {
        return me.concat(Fe);
      }, [])), T = T.concat(C[3].map(function(me) {
        return v.TransformNormal(me, te);
      }).map(function(me) {
        return [me.x, me.y, me.z];
      }).reduce(function(me, Fe) {
        return me.concat(Fe);
      }, []));
      var se = new v(0, f, 0), _e = B.RotationX(Math.PI / 2);
      b = b.concat(R[4].map(function(me) {
        return v.TransformNormal(me, _e).add(se);
      }).map(function(me) {
        return [me.x, me.y, me.z];
      }).reduce(function(me, Fe) {
        return me.concat(Fe);
      }, [])), T = T.concat(C[4].map(function(me) {
        return v.TransformNormal(me, _e);
      }).map(function(me) {
        return [me.x, me.y, me.z];
      }).reduce(function(me, Fe) {
        return me.concat(Fe);
      }, []));
      var xe = B.RotationX(-Math.PI / 2);
      b = b.concat(R[5].map(function(me) {
        return v.TransformNormal(me, xe).subtract(se);
      }).map(function(me) {
        return [me.x, me.y, me.z];
      }).reduce(function(me, Fe) {
        return me.concat(Fe);
      }, [])), T = T.concat(C[5].map(function(me) {
        return v.TransformNormal(me, xe);
      }).map(function(me) {
        return [me.x, me.y, me.z];
      }).reduce(function(me, Fe) {
        return me.concat(Fe);
      }, [])), Oe._ComputeSides(h, b, E, T, S);
      var Te = new Oe();
      if (Te.indices = E, Te.positions = b, Te.normals = T, Te.uvs = S, e) {
        var he = h === Oe.DOUBLESIDE ? A.concat(A) : A;
        Te.colors = he;
      }
      return Te;
    }
    function xf(n, t, e) {
      e === void 0 && (e = null);
      var i = new ie(n, e);
      return t.sideOrientation = ie._GetDefaultSideOrientation(t.sideOrientation), i._originalBuilderSideOrientation = t.sideOrientation, Sf(t).applyToMesh(i, t.updatable), i;
    }
    Oe.CreateTiledPlane = Tl;
    var $R = { CreateTiledBox: xf };
    function Af(n) {
      var t, e, i = [], r = [], o = [], a = [], s = n.radius || 2, l = n.tube || 0.5, c = n.radialSegments || 32, u = n.tubularSegments || 32, h = n.p || 2, d = n.q || 3, p = n.sideOrientation === 0 ? 0 : n.sideOrientation || Oe.DEFAULTSIDE, f = function(V) {
        var Y = Math.cos(V), ee = Math.sin(V), J = d / h * V, X = Math.cos(J), K = s * (2 + X) * 0.5 * Y, te = s * (2 + X) * ee * 0.5, se = s * Math.sin(J) * 0.5;
        return new v(K, te, se);
      };
      for (t = 0; t <= c; t++) {
        var m = t % c / c * 2 * h * Math.PI, g = f(m), y = f(m + 0.01), b = y.subtract(g), T = y.add(g), S = v.Cross(b, T);
        for (T = v.Cross(S, b), S.normalize(), T.normalize(), e = 0; e < u; e++) {
          var E = e % u / u * 2 * Math.PI, A = -l * Math.cos(E), R = l * Math.sin(E);
          r.push(g.x + A * T.x + R * S.x), r.push(g.y + A * T.y + R * S.y), r.push(g.z + A * T.z + R * S.z), a.push(t / c), a.push(Lt.UseOpenGLOrientationForUV ? 1 - e / u : e / u);
        }
      }
      for (t = 0; t < c; t++)
        for (e = 0; e < u; e++) {
          var C = (e + 1) % u, L = t * u + e, I = (t + 1) * u + e, O = (t + 1) * u + C, w = t * u + C;
          i.push(w), i.push(I), i.push(L), i.push(w), i.push(O), i.push(I);
        }
      Oe.ComputeNormals(r, i, o), Oe._ComputeSides(p, r, i, o, a, n.frontUVs, n.backUVs);
      var z = new Oe();
      return z.indices = i, z.positions = r, z.normals = o, z.uvs = a, z;
    }
    function Sh(n, t, e) {
      t === void 0 && (t = {});
      var i = new ie(n, e);
      return t.sideOrientation = ie._GetDefaultSideOrientation(t.sideOrientation), i._originalBuilderSideOrientation = t.sideOrientation, Af(t).applyToMesh(i, t.updatable), i;
    }
    Oe.CreateTiledBox = Sf;
    var eC = { CreateTorusKnot: Sh };
    Oe.CreateTorusKnot = Af, ie.CreateTorusKnot = function(n, t, e, i, r, o, a, s, l, c) {
      return Sh(n, { radius: t, tube: e, radialSegments: i, tubularSegments: r, p: o, q: a, sideOrientation: c, updatable: l }, s);
    };
    var Ov = { effect: null, subMesh: null }, dr = function(n) {
      function t(e, i, r, o, a) {
        o === void 0 && (o = {}), a === void 0 && (a = !0);
        var s = n.call(this, e, i, a) || this;
        return s._textures = {}, s._textureArrays = {}, s._externalTextures = {}, s._floats = {}, s._ints = {}, s._uints = {}, s._floatsArrays = {}, s._colors3 = {}, s._colors3Arrays = {}, s._colors4 = {}, s._colors4Arrays = {}, s._vectors2 = {}, s._vectors3 = {}, s._vectors4 = {}, s._quaternions = {}, s._quaternionsArrays = {}, s._matrices = {}, s._matrixArrays = {}, s._matrices3x3 = {}, s._matrices2x2 = {}, s._vectors2Arrays = {}, s._vectors3Arrays = {}, s._vectors4Arrays = {}, s._uniformBuffers = {}, s._textureSamplers = {}, s._storageBuffers = {}, s._cachedWorldViewMatrix = new B(), s._cachedWorldViewProjectionMatrix = new B(), s._multiview = !1, s._materialHelperNeedsPreviousMatrices = !1, s._shaderPath = r, s._options = je({ needAlphaBlending: !1, needAlphaTesting: !1, attributes: ["position", "normal", "uv"], uniforms: ["worldViewProjection"], uniformBuffers: [], samplers: [], externalTextures: [], samplerObjects: [], storageBuffers: [], defines: [], useClipPlane: !1 }, o), s;
      }
      return D(t, n), Object.defineProperty(t.prototype, "shaderPath", { get: function() {
        return this._shaderPath;
      }, set: function(e) {
        this._shaderPath = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "options", { get: function() {
        return this._options;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isMultiview", { get: function() {
        return this._multiview;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "ShaderMaterial";
      }, t.prototype.needAlphaBlending = function() {
        return this.alpha < 1 || this._options.needAlphaBlending;
      }, t.prototype.needAlphaTesting = function() {
        return this._options.needAlphaTesting;
      }, t.prototype._checkUniform = function(e) {
        this._options.uniforms.indexOf(e) === -1 && this._options.uniforms.push(e);
      }, t.prototype.setTexture = function(e, i) {
        return this._options.samplers.indexOf(e) === -1 && this._options.samplers.push(e), this._textures[e] = i, this;
      }, t.prototype.setTextureArray = function(e, i) {
        return this._options.samplers.indexOf(e) === -1 && this._options.samplers.push(e), this._checkUniform(e), this._textureArrays[e] = i, this;
      }, t.prototype.setExternalTexture = function(e, i) {
        return this._options.externalTextures.indexOf(e) === -1 && this._options.externalTextures.push(e), this._externalTextures[e] = i, this;
      }, t.prototype.setFloat = function(e, i) {
        return this._checkUniform(e), this._floats[e] = i, this;
      }, t.prototype.setInt = function(e, i) {
        return this._checkUniform(e), this._ints[e] = i, this;
      }, t.prototype.setUInt = function(e, i) {
        return this._checkUniform(e), this._uints[e] = i, this;
      }, t.prototype.setFloats = function(e, i) {
        return this._checkUniform(e), this._floatsArrays[e] = i, this;
      }, t.prototype.setColor3 = function(e, i) {
        return this._checkUniform(e), this._colors3[e] = i, this;
      }, t.prototype.setColor3Array = function(e, i) {
        return this._checkUniform(e), this._colors3Arrays[e] = i.reduce(function(r, o) {
          return o.toArray(r, r.length), r;
        }, []), this;
      }, t.prototype.setColor4 = function(e, i) {
        return this._checkUniform(e), this._colors4[e] = i, this;
      }, t.prototype.setColor4Array = function(e, i) {
        return this._checkUniform(e), this._colors4Arrays[e] = i.reduce(function(r, o) {
          return o.toArray(r, r.length), r;
        }, []), this;
      }, t.prototype.setVector2 = function(e, i) {
        return this._checkUniform(e), this._vectors2[e] = i, this;
      }, t.prototype.setVector3 = function(e, i) {
        return this._checkUniform(e), this._vectors3[e] = i, this;
      }, t.prototype.setVector4 = function(e, i) {
        return this._checkUniform(e), this._vectors4[e] = i, this;
      }, t.prototype.setQuaternion = function(e, i) {
        return this._checkUniform(e), this._quaternions[e] = i, this;
      }, t.prototype.setQuaternionArray = function(e, i) {
        return this._checkUniform(e), this._quaternionsArrays[e] = i.reduce(function(r, o) {
          return o.toArray(r, r.length), r;
        }, []), this;
      }, t.prototype.setMatrix = function(e, i) {
        return this._checkUniform(e), this._matrices[e] = i, this;
      }, t.prototype.setMatrices = function(e, i) {
        this._checkUniform(e);
        for (var r = new Float32Array(16 * i.length), o = 0; o < i.length; o++)
          i[o].copyToArray(r, 16 * o);
        return this._matrixArrays[e] = r, this;
      }, t.prototype.setMatrix3x3 = function(e, i) {
        return this._checkUniform(e), this._matrices3x3[e] = i, this;
      }, t.prototype.setMatrix2x2 = function(e, i) {
        return this._checkUniform(e), this._matrices2x2[e] = i, this;
      }, t.prototype.setArray2 = function(e, i) {
        return this._checkUniform(e), this._vectors2Arrays[e] = i, this;
      }, t.prototype.setArray3 = function(e, i) {
        return this._checkUniform(e), this._vectors3Arrays[e] = i, this;
      }, t.prototype.setArray4 = function(e, i) {
        return this._checkUniform(e), this._vectors4Arrays[e] = i, this;
      }, t.prototype.setUniformBuffer = function(e, i) {
        return this._options.uniformBuffers.indexOf(e) === -1 && this._options.uniformBuffers.push(e), this._uniformBuffers[e] = i, this;
      }, t.prototype.setTextureSampler = function(e, i) {
        return this._options.samplerObjects.indexOf(e) === -1 && this._options.samplerObjects.push(e), this._textureSamplers[e] = i, this;
      }, t.prototype.setStorageBuffer = function(e, i) {
        return this._options.storageBuffers.indexOf(e) === -1 && this._options.storageBuffers.push(e), this._storageBuffers[e] = i, this;
      }, t.prototype.setDefine = function(e, i) {
        var r = e.trimEnd() + " ", o = this.options.defines.findIndex(function(a) {
          return a === e || a.startsWith(r);
        });
        return o >= 0 && this.options.defines.splice(o, 1), (typeof i != "boolean" || i) && this.options.defines.push(r + i), this;
      }, t.prototype.isReadyForSubMesh = function(e, i, r) {
        return this.isReady(e, r, i);
      }, t.prototype.isReady = function(e, i, r) {
        var o, a, s, l, c = r && this._storeEffectOnSubMeshes;
        if (this.isFrozen)
          if (c) {
            if (r.effect && r.effect._wasPreviouslyReady)
              return !0;
          } else {
            var u = this._drawWrapper.effect;
            if (u && u._wasPreviouslyReady && u._wasPreviouslyUsingInstances === i)
              return !0;
          }
        var h = this.getScene(), d = h.getEngine(), p = [], f = [], m = new Va(), g = this._shaderPath, y = this._options.uniforms, b = this._options.uniformBuffers, T = this._options.samplers;
        d.getCaps().multiview && h.activeCamera && h.activeCamera.outputRenderTarget && h.activeCamera.outputRenderTarget.getViewCount() > 1 && (this._multiview = !0, p.push("#define MULTIVIEW"), this._options.uniforms.indexOf("viewProjection") !== -1 && this._options.uniforms.indexOf("viewProjectionR") === -1 && this._options.uniforms.push("viewProjectionR"));
        for (var S = 0; S < this._options.defines.length; S++) {
          var E = this._options.defines[S].indexOf("#define") === 0 ? this._options.defines[S] : "#define ".concat(this._options.defines[S]);
          p.push(E);
        }
        for (S = 0; S < this._options.attributes.length; S++)
          f.push(this._options.attributes[S]);
        if (e && e.isVerticesDataPresent(P.ColorKind) && (f.indexOf(P.ColorKind) === -1 && f.push(P.ColorKind), p.push("#define VERTEXCOLOR")), i && (p.push("#define INSTANCES"), Se.PushAttributesForInstances(f, this._materialHelperNeedsPreviousMatrices), e != null && e.hasThinInstances && (p.push("#define THIN_INSTANCES"), e && e.isVerticesDataPresent(P.ColorInstanceKind) && (f.push(P.ColorInstanceKind), p.push("#define INSTANCESCOLOR")))), e && e.useBones && e.computeBonesUsingShaders && e.skeleton) {
          f.push(P.MatricesIndicesKind), f.push(P.MatricesWeightsKind), e.numBoneInfluencers > 4 && (f.push(P.MatricesIndicesExtraKind), f.push(P.MatricesWeightsExtraKind));
          var A = e.skeleton;
          p.push("#define NUM_BONE_INFLUENCERS " + e.numBoneInfluencers), m.addCPUSkinningFallback(0, e), A.isUsingTextureForMatrices ? (p.push("#define BONETEXTURE"), this._options.uniforms.indexOf("boneTextureWidth") === -1 && this._options.uniforms.push("boneTextureWidth"), this._options.samplers.indexOf("boneSampler") === -1 && this._options.samplers.push("boneSampler")) : (p.push("#define BonesPerMesh " + (A.bones.length + 1)), this._options.uniforms.indexOf("mBones") === -1 && this._options.uniforms.push("mBones"));
        } else
          p.push("#define NUM_BONE_INFLUENCERS 0");
        var R = 0, C = e ? e.morphTargetManager : null;
        if (C) {
          var L = C.supportsUVs && p.indexOf("#define UV1") !== -1, I = C.supportsTangents && p.indexOf("#define TANGENT") !== -1, O = C.supportsNormals && p.indexOf("#define NORMAL") !== -1;
          for (R = C.numInfluencers, L && p.push("#define MORPHTARGETS_UV"), I && p.push("#define MORPHTARGETS_TANGENT"), O && p.push("#define MORPHTARGETS_NORMAL"), R > 0 && p.push("#define MORPHTARGETS"), C.isUsingTextureForTargets && (p.push("#define MORPHTARGETS_TEXTURE"), this._options.uniforms.indexOf("morphTargetTextureIndices") === -1 && this._options.uniforms.push("morphTargetTextureIndices"), this._options.samplers.indexOf("morphTargets") === -1 && this._options.samplers.push("morphTargets")), p.push("#define NUM_MORPH_INFLUENCERS " + R), S = 0; S < R; S++)
            f.push(P.PositionKind + S), O && f.push(P.NormalKind + S), I && f.push(P.TangentKind + S), L && f.push(P.UVKind + "_" + S);
          R > 0 && ((y = y.slice()).push("morphTargetInfluences"), y.push("morphTargetTextureInfo"), y.push("morphTargetTextureIndices"));
        } else
          p.push("#define NUM_MORPH_INFLUENCERS 0");
        if (e) {
          var w = e.bakedVertexAnimationManager;
          w && w.isEnabled && (p.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"), this._options.uniforms.indexOf("bakedVertexAnimationSettings") === -1 && this._options.uniforms.push("bakedVertexAnimationSettings"), this._options.uniforms.indexOf("bakedVertexAnimationTextureSizeInverted") === -1 && this._options.uniforms.push("bakedVertexAnimationTextureSizeInverted"), this._options.uniforms.indexOf("bakedVertexAnimationTime") === -1 && this._options.uniforms.push("bakedVertexAnimationTime"), this._options.samplers.indexOf("bakedVertexAnimationTexture") === -1 && this._options.samplers.push("bakedVertexAnimationTexture")), Se.PrepareAttributesForBakedVertexAnimation(f, e, p);
        }
        for (var z in this._textures)
          if (!this._textures[z].isReady())
            return !1;
        e && this._shouldTurnAlphaTestOn(e) && p.push("#define ALPHATEST"), this._options.useClipPlane !== !1 && (Br(y), aa(this, h, p)), this.customShaderNameResolve && (y = y.slice(), b = b.slice(), T = T.slice(), g = this.customShaderNameResolve(g, y, b, T, p, f));
        var V = c ? r._getDrawWrapper() : this._drawWrapper, Y = (o = V == null ? void 0 : V.effect) !== null && o !== void 0 ? o : null, ee = (a = V == null ? void 0 : V.defines) !== null && a !== void 0 ? a : null, J = p.join(`
`), X = Y;
        return ee !== J && (X = d.createEffect(g, { attributes: f, uniformsNames: y, uniformBuffersNames: b, samplers: T, defines: J, fallbacks: m, onCompiled: this.onCompiled, onError: this.onError, indexParameters: { maxSimultaneousMorphTargets: R }, shaderLanguage: this._options.shaderLanguage }, d), c ? r.setEffect(X, J, this._materialContext) : V && V.setEffect(X, J), this._onEffectCreatedObservable && (Ov.effect = X, Ov.subMesh = (s = r ?? (e == null ? void 0 : e.subMeshes[0])) !== null && s !== void 0 ? s : null, this._onEffectCreatedObservable.notifyObservers(Ov))), X._wasPreviouslyUsingInstances = !!i, (l = !(X != null && X.isReady())) !== null && l !== void 0 && !l && (Y !== X && h.resetCachedMaterial(), X._wasPreviouslyReady = !0, !0);
      }, t.prototype.bindOnlyWorldMatrix = function(e, i) {
        var r = this.getScene(), o = i ?? this.getEffect();
        o && (this._options.uniforms.indexOf("world") !== -1 && o.setMatrix("world", e), this._options.uniforms.indexOf("worldView") !== -1 && (e.multiplyToRef(r.getViewMatrix(), this._cachedWorldViewMatrix), o.setMatrix("worldView", this._cachedWorldViewMatrix)), this._options.uniforms.indexOf("worldViewProjection") !== -1 && (e.multiplyToRef(r.getTransformMatrix(), this._cachedWorldViewProjectionMatrix), o.setMatrix("worldViewProjection", this._cachedWorldViewProjectionMatrix)));
      }, t.prototype.bindForSubMesh = function(e, i, r) {
        var o;
        this.bind(e, i, (o = r._drawWrapperOverride) === null || o === void 0 ? void 0 : o.effect, r);
      }, t.prototype.bind = function(e, i, r, o) {
        var a, s = o && this._storeEffectOnSubMeshes, l = r ?? (s ? o.effect : this.getEffect());
        if (l) {
          this._activeEffect = l, this.bindOnlyWorldMatrix(e, r);
          var c = this._options.uniformBuffers, u = !1;
          if (l && c && c.length > 0 && this.getScene().getEngine().supportsUniformBuffers)
            for (var h = 0; h < c.length; ++h)
              switch (c[h]) {
                case "Mesh":
                  i && (i.getMeshUniformBuffer().bindToEffect(l, "Mesh"), i.transferToEffect(e));
                  break;
                case "Scene":
                  Se.BindSceneUniformBuffer(l, this.getScene().getSceneUniformBuffer()), this.getScene().finalizeSceneUbo(), u = !0;
              }
          var d = i && s ? this._mustRebind(this.getScene(), l, i.visibility) : this.getScene().getCachedMaterial() !== this;
          if (l && d) {
            var p;
            for (p in u || this._options.uniforms.indexOf("view") === -1 || l.setMatrix("view", this.getScene().getViewMatrix()), u || this._options.uniforms.indexOf("projection") === -1 || l.setMatrix("projection", this.getScene().getProjectionMatrix()), u || this._options.uniforms.indexOf("viewProjection") === -1 || (l.setMatrix("viewProjection", this.getScene().getTransformMatrix()), this._multiview && l.setMatrix("viewProjectionR", this.getScene()._transformMatrixR)), this.getScene().activeCamera && this._options.uniforms.indexOf("cameraPosition") !== -1 && l.setVector3("cameraPosition", this.getScene().activeCamera.globalPosition), Se.BindBonesParameters(i, l), Ar(l, this, this.getScene()), this._textures)
              l.setTexture(p, this._textures[p]);
            for (p in this._textureArrays)
              l.setTextureArray(p, this._textureArrays[p]);
            for (p in this._externalTextures)
              l.setExternalTexture(p, this._externalTextures[p]);
            for (p in this._ints)
              l.setInt(p, this._ints[p]);
            for (p in this._uints)
              l.setUInt(p, this._uints[p]);
            for (p in this._floats)
              l.setFloat(p, this._floats[p]);
            for (p in this._floatsArrays)
              l.setArray(p, this._floatsArrays[p]);
            for (p in this._colors3)
              l.setColor3(p, this._colors3[p]);
            for (p in this._colors3Arrays)
              l.setArray3(p, this._colors3Arrays[p]);
            for (p in this._colors4) {
              var f = this._colors4[p];
              l.setFloat4(p, f.r, f.g, f.b, f.a);
            }
            for (p in this._colors4Arrays)
              l.setArray4(p, this._colors4Arrays[p]);
            for (p in this._vectors2)
              l.setVector2(p, this._vectors2[p]);
            for (p in this._vectors3)
              l.setVector3(p, this._vectors3[p]);
            for (p in this._vectors4)
              l.setVector4(p, this._vectors4[p]);
            for (p in this._quaternions)
              l.setQuaternion(p, this._quaternions[p]);
            for (p in this._matrices)
              l.setMatrix(p, this._matrices[p]);
            for (p in this._matrixArrays)
              l.setMatrices(p, this._matrixArrays[p]);
            for (p in this._matrices3x3)
              l.setMatrix3x3(p, this._matrices3x3[p]);
            for (p in this._matrices2x2)
              l.setMatrix2x2(p, this._matrices2x2[p]);
            for (p in this._vectors2Arrays)
              l.setArray2(p, this._vectors2Arrays[p]);
            for (p in this._vectors3Arrays)
              l.setArray3(p, this._vectors3Arrays[p]);
            for (p in this._vectors4Arrays)
              l.setArray4(p, this._vectors4Arrays[p]);
            for (p in this._quaternionsArrays)
              l.setArray4(p, this._quaternionsArrays[p]);
            for (p in this._uniformBuffers) {
              var m = this._uniformBuffers[p].getBuffer();
              m && l.bindUniformBuffer(m, p);
            }
            for (p in this._textureSamplers)
              l.setTextureSampler(p, this._textureSamplers[p]);
            for (p in this._storageBuffers)
              l.setStorageBuffer(p, this._storageBuffers[p]);
          }
          if (l && i && (d || !this.isFrozen)) {
            var g = i.morphTargetManager;
            g && g.numInfluencers > 0 && Se.BindMorphTargetParameters(i, l);
            var y = i.bakedVertexAnimationManager;
            y && y.isEnabled && ((a = i.bakedVertexAnimationManager) === null || a === void 0 || a.bind(l, !!l._wasPreviouslyUsingInstances));
          }
          this._afterBind(i, l);
        }
      }, t.prototype.getActiveTextures = function() {
        var e = n.prototype.getActiveTextures.call(this);
        for (var i in this._textures)
          e.push(this._textures[i]);
        for (var r in this._textureArrays)
          for (var o = this._textureArrays[r], a = 0; a < o.length; a++)
            e.push(o[a]);
        return e;
      }, t.prototype.hasTexture = function(e) {
        if (n.prototype.hasTexture.call(this, e))
          return !0;
        for (var i in this._textures)
          if (this._textures[i] === e)
            return !0;
        for (var r in this._textureArrays)
          for (var o = this._textureArrays[r], a = 0; a < o.length; a++)
            if (o[a] === e)
              return !0;
        return !1;
      }, t.prototype.clone = function(e) {
        var i = this, r = Ne.Clone(function() {
          return new t(e, i.getScene(), i._shaderPath, i._options, i._storeEffectOnSubMeshes);
        }, this);
        for (var o in r.name = e, r.id = e, typeof r._shaderPath == "object" && (r._shaderPath = je({}, r._shaderPath)), this._options = je({}, this._options), Object.keys(this._options).forEach(function(a) {
          var s = i._options[a];
          Array.isArray(s) && (i._options[a] = s.slice(0));
        }), this.stencil.copyTo(r.stencil), this._textures)
          r.setTexture(o, this._textures[o]);
        for (var o in this._textureArrays)
          r.setTextureArray(o, this._textureArrays[o]);
        for (var o in this._externalTextures)
          r.setExternalTexture(o, this._externalTextures[o]);
        for (var o in this._ints)
          r.setInt(o, this._ints[o]);
        for (var o in this._uints)
          r.setUInt(o, this._uints[o]);
        for (var o in this._floats)
          r.setFloat(o, this._floats[o]);
        for (var o in this._floatsArrays)
          r.setFloats(o, this._floatsArrays[o]);
        for (var o in this._colors3)
          r.setColor3(o, this._colors3[o]);
        for (var o in this._colors3Arrays)
          r._colors3Arrays[o] = this._colors3Arrays[o];
        for (var o in this._colors4)
          r.setColor4(o, this._colors4[o]);
        for (var o in this._colors4Arrays)
          r._colors4Arrays[o] = this._colors4Arrays[o];
        for (var o in this._vectors2)
          r.setVector2(o, this._vectors2[o]);
        for (var o in this._vectors3)
          r.setVector3(o, this._vectors3[o]);
        for (var o in this._vectors4)
          r.setVector4(o, this._vectors4[o]);
        for (var o in this._quaternions)
          r.setQuaternion(o, this._quaternions[o]);
        for (var o in this._quaternionsArrays)
          r._quaternionsArrays[o] = this._quaternionsArrays[o];
        for (var o in this._matrices)
          r.setMatrix(o, this._matrices[o]);
        for (var o in this._matrixArrays)
          r._matrixArrays[o] = this._matrixArrays[o].slice();
        for (var o in this._matrices3x3)
          r.setMatrix3x3(o, this._matrices3x3[o]);
        for (var o in this._matrices2x2)
          r.setMatrix2x2(o, this._matrices2x2[o]);
        for (var o in this._vectors2Arrays)
          r.setArray2(o, this._vectors2Arrays[o]);
        for (var o in this._vectors3Arrays)
          r.setArray3(o, this._vectors3Arrays[o]);
        for (var o in this._vectors4Arrays)
          r.setArray4(o, this._vectors4Arrays[o]);
        for (var o in this._uniformBuffers)
          r.setUniformBuffer(o, this._uniformBuffers[o]);
        for (var o in this._textureSamplers)
          r.setTextureSampler(o, this._textureSamplers[o]);
        for (var o in this._storageBuffers)
          r.setStorageBuffer(o, this._storageBuffers[o]);
        return r;
      }, t.prototype.dispose = function(e, i, r) {
        if (i) {
          var o;
          for (o in this._textures)
            this._textures[o].dispose();
          for (o in this._textureArrays)
            for (var a = this._textureArrays[o], s = 0; s < a.length; s++)
              a[s].dispose();
        }
        this._textures = {}, n.prototype.dispose.call(this, e, i, r);
      }, t.prototype.serialize = function() {
        var e, i = Ne.Serialize(this);
        for (e in i.customType = "BABYLON.ShaderMaterial", i.uniqueId = this.uniqueId, i.options = this._options, i.shaderPath = this._shaderPath, i.storeEffectOnSubMeshes = this._storeEffectOnSubMeshes, i.stencil = this.stencil.serialize(), i.textures = {}, this._textures)
          i.textures[e] = this._textures[e].serialize();
        for (e in i.textureArrays = {}, this._textureArrays) {
          i.textureArrays[e] = [];
          for (var r = this._textureArrays[e], o = 0; o < r.length; o++)
            i.textureArrays[e].push(r[o].serialize());
        }
        for (e in i.ints = {}, this._ints)
          i.ints[e] = this._ints[e];
        for (e in i.uints = {}, this._uints)
          i.uints[e] = this._uints[e];
        for (e in i.floats = {}, this._floats)
          i.floats[e] = this._floats[e];
        for (e in i.FloatArrays = {}, this._floatsArrays)
          i.FloatArrays[e] = this._floatsArrays[e];
        for (e in i.colors3 = {}, this._colors3)
          i.colors3[e] = this._colors3[e].asArray();
        for (e in i.colors3Arrays = {}, this._colors3Arrays)
          i.colors3Arrays[e] = this._colors3Arrays[e];
        for (e in i.colors4 = {}, this._colors4)
          i.colors4[e] = this._colors4[e].asArray();
        for (e in i.colors4Arrays = {}, this._colors4Arrays)
          i.colors4Arrays[e] = this._colors4Arrays[e];
        for (e in i.vectors2 = {}, this._vectors2)
          i.vectors2[e] = this._vectors2[e].asArray();
        for (e in i.vectors3 = {}, this._vectors3)
          i.vectors3[e] = this._vectors3[e].asArray();
        for (e in i.vectors4 = {}, this._vectors4)
          i.vectors4[e] = this._vectors4[e].asArray();
        for (e in i.quaternions = {}, this._quaternions)
          i.quaternions[e] = this._quaternions[e].asArray();
        for (e in i.matrices = {}, this._matrices)
          i.matrices[e] = this._matrices[e].asArray();
        for (e in i.matrixArray = {}, this._matrixArrays)
          i.matrixArray[e] = this._matrixArrays[e];
        for (e in i.matrices3x3 = {}, this._matrices3x3)
          i.matrices3x3[e] = this._matrices3x3[e];
        for (e in i.matrices2x2 = {}, this._matrices2x2)
          i.matrices2x2[e] = this._matrices2x2[e];
        for (e in i.vectors2Arrays = {}, this._vectors2Arrays)
          i.vectors2Arrays[e] = this._vectors2Arrays[e];
        for (e in i.vectors3Arrays = {}, this._vectors3Arrays)
          i.vectors3Arrays[e] = this._vectors3Arrays[e];
        for (e in i.vectors4Arrays = {}, this._vectors4Arrays)
          i.vectors4Arrays[e] = this._vectors4Arrays[e];
        for (e in i.quaternionsArrays = {}, this._quaternionsArrays)
          i.quaternionsArrays[e] = this._quaternionsArrays[e];
        return i;
      }, t.Parse = function(e, i, r) {
        var o, a = Ne.Parse(function() {
          return new t(e.name, i, e.shaderPath, e.options, e.storeEffectOnSubMeshes);
        }, e, i, r);
        for (o in e.stencil && a.stencil.parse(e.stencil, i, r), e.textures)
          a.setTexture(o, ae.Parse(e.textures[o], i, r));
        for (o in e.textureArrays) {
          for (var s = e.textureArrays[o], l = [], c = 0; c < s.length; c++)
            l.push(ae.Parse(s[c], i, r));
          a.setTextureArray(o, l);
        }
        for (o in e.ints)
          a.setInt(o, e.ints[o]);
        for (o in e.uints)
          a.setUInt(o, e.uints[o]);
        for (o in e.floats)
          a.setFloat(o, e.floats[o]);
        for (o in e.floatsArrays)
          a.setFloats(o, e.floatsArrays[o]);
        for (o in e.colors3)
          a.setColor3(o, ne.FromArray(e.colors3[o]));
        for (o in e.colors3Arrays) {
          var u = e.colors3Arrays[o].reduce(function(h, d, p) {
            return p % 3 == 0 ? h.push([d]) : h[h.length - 1].push(d), h;
          }, []).map(function(h) {
            return ne.FromArray(h);
          });
          a.setColor3Array(o, u);
        }
        for (o in e.colors4)
          a.setColor4(o, Ie.FromArray(e.colors4[o]));
        for (o in e.colors4Arrays)
          u = e.colors4Arrays[o].reduce(function(h, d, p) {
            return p % 4 == 0 ? h.push([d]) : h[h.length - 1].push(d), h;
          }, []).map(function(h) {
            return Ie.FromArray(h);
          }), a.setColor4Array(o, u);
        for (o in e.vectors2)
          a.setVector2(o, fe.FromArray(e.vectors2[o]));
        for (o in e.vectors3)
          a.setVector3(o, v.FromArray(e.vectors3[o]));
        for (o in e.vectors4)
          a.setVector4(o, lt.FromArray(e.vectors4[o]));
        for (o in e.quaternions)
          a.setQuaternion(o, oe.FromArray(e.quaternions[o]));
        for (o in e.matrices)
          a.setMatrix(o, B.FromArray(e.matrices[o]));
        for (o in e.matrixArray)
          a._matrixArrays[o] = new Float32Array(e.matrixArray[o]);
        for (o in e.matrices3x3)
          a.setMatrix3x3(o, e.matrices3x3[o]);
        for (o in e.matrices2x2)
          a.setMatrix2x2(o, e.matrices2x2[o]);
        for (o in e.vectors2Arrays)
          a.setArray2(o, e.vectors2Arrays[o]);
        for (o in e.vectors3Arrays)
          a.setArray3(o, e.vectors3Arrays[o]);
        for (o in e.vectors4Arrays)
          a.setArray4(o, e.vectors4Arrays[o]);
        for (o in e.quaternionsArrays)
          a.setArray4(o, e.quaternionsArrays[o]);
        return a;
      }, t.ParseFromFileAsync = function(e, i, r, o) {
        var a = this;
        return o === void 0 && (o = ""), new Promise(function(s, l) {
          var c = new _n();
          c.addEventListener("readystatechange", function() {
            if (c.readyState == 4)
              if (c.status == 200) {
                var u = JSON.parse(c.responseText), h = a.Parse(u, r || Me.LastCreatedScene, o);
                e && (h.name = e), s(h);
              } else
                l("Unable to load the ShaderMaterial");
          }), c.open("GET", i), c.send();
        });
      }, t.ParseFromSnippetAsync = function(e, i, r) {
        var o = this;
        return r === void 0 && (r = ""), new Promise(function(a, s) {
          var l = new _n();
          l.addEventListener("readystatechange", function() {
            if (l.readyState == 4)
              if (l.status == 200) {
                var c = JSON.parse(JSON.parse(l.responseText).jsonPayload), u = JSON.parse(c.shaderMaterial), h = o.Parse(u, i || Me.LastCreatedScene, r);
                h.snippetId = e, a(h);
              } else
                s("Unable to load the snippet " + e);
          }), l.open("GET", o.SnippetUrl + "/" + e.replace(/#/g, "/")), l.send();
        });
      }, t.SnippetUrl = _.SnippetUrl, t.CreateFromSnippetAsync = t.ParseFromSnippetAsync, t;
    }(pl);
    j("BABYLON.ShaderMaterial", dr), re.ShadersStore.colorPixelShader = `#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
#define VERTEXCOLOR
varying vec4 vColor;
#else
uniform vec4 color;
#endif
#include<clipPlaneFragmentDeclaration>
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void) {
#define CUSTOM_FRAGMENT_MAIN_BEGIN
#include<clipPlaneFragment>
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
gl_FragColor=vColor;
#else
gl_FragColor=color;
#endif
#define CUSTOM_FRAGMENT_MAIN_END
}`, re.ShadersStore.colorVertexShader = `attribute vec3 position;
#ifdef VERTEXCOLOR
attribute vec4 color;
#endif
#include<bonesDeclaration>
#include<bakedVertexAnimationDeclaration>
#include<clipPlaneVertexDeclaration>
#include<instancesDeclaration>
uniform mat4 viewProjection;
#ifdef MULTIVIEW
uniform mat4 viewProjectionR;
#endif
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
varying vec4 vColor;
#endif
#define CUSTOM_VERTEX_DEFINITIONS
void main(void) {
#define CUSTOM_VERTEX_MAIN_BEGIN
#include<instancesVertex>
#include<bonesVertex>
#include<bakedVertexAnimation>
vec4 worldPos=finalWorld*vec4(position,1.0);
#ifdef MULTIVIEW
if (gl_ViewID_OVR==0u) {gl_Position=viewProjection*worldPos;} else {gl_Position=viewProjectionR*worldPos;}
#else
gl_Position=viewProjection*worldPos;
#endif
#include<clipPlaneVertex>
#include<vertexColorMixing>
#define CUSTOM_VERTEX_MAIN_END
}`, ie._LinesMeshParser = function(n, t) {
      return El.Parse(n, t);
    };
    var El = function(n) {
      function t(e, i, r, o, a, s, l, c) {
        i === void 0 && (i = null), r === void 0 && (r = null), o === void 0 && (o = null);
        var u = n.call(this, e, i, r, o, a) || this;
        u.useVertexColor = s, u.useVertexAlpha = l, u.color = new ne(1, 1, 1), u.alpha = 1, o && (u.color = o.color.clone(), u.alpha = o.alpha, u.useVertexColor = o.useVertexColor, u.useVertexAlpha = o.useVertexAlpha), u.intersectionThreshold = 0.1;
        var h = { attributes: [P.PositionKind], uniforms: ["world", "viewProjection"], needAlphaBlending: !0, defines: [], useClipPlane: null };
        return l === !1 ? h.needAlphaBlending = !1 : h.defines.push("#define VERTEXALPHA"), s ? (h.defines.push("#define VERTEXCOLOR"), h.attributes.push(P.ColorKind)) : (h.uniforms.push("color"), u._color4 = new Ie()), c ? u.material = c : (u.material = new dr("colorShader", u.getScene(), "color", h, !1), u.material.doNotSerialize = !0), u;
      }
      return D(t, n), t.prototype._isShaderMaterial = function(e) {
        return e.getClassName() === "ShaderMaterial";
      }, t.prototype.isReady = function() {
        return !!this._lineMaterial.isReady(this, !!this._userInstancedBuffersStorage || this.hasThinInstances) && n.prototype.isReady.call(this);
      }, t.prototype.getClassName = function() {
        return "LinesMesh";
      }, Object.defineProperty(t.prototype, "material", { get: function() {
        return this._lineMaterial;
      }, set: function(e) {
        this._lineMaterial = e, this._lineMaterial.fillMode = Et.LineListDrawMode;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "checkCollisions", { get: function() {
        return !1;
      }, set: function(e) {
      }, enumerable: !1, configurable: !0 }), t.prototype._bind = function(e, i) {
        if (!this._geometry)
          return this;
        var r = this.isUnIndexed ? null : this._geometry.getIndexBuffer();
        if (!this._userInstancedBuffersStorage || this.hasThinInstances ? this._geometry._bind(i, r) : this._geometry._bind(i, r, this._userInstancedBuffersStorage.vertexBuffers, this._userInstancedBuffersStorage.vertexArrayObjects), !this.useVertexColor && this._isShaderMaterial(this._lineMaterial)) {
          var o = this.color, a = o.r, s = o.g, l = o.b;
          this._color4.set(a, s, l, this.alpha), this._lineMaterial.setColor4("color", this._color4);
        }
        return this;
      }, t.prototype._draw = function(e, i, r) {
        if (!this._geometry || !this._geometry.getVertexBuffers() || !this._unIndexed && !this._geometry.getIndexBuffer())
          return this;
        var o = this.getScene().getEngine();
        return this._unIndexed ? o.drawArraysType(Et.LineListDrawMode, e.verticesStart, e.verticesCount, r) : o.drawElementsType(Et.LineListDrawMode, e.indexStart, e.indexCount, r), this;
      }, t.prototype.dispose = function(e, i, r) {
        r || this._lineMaterial.dispose(!1, !1, !0), n.prototype.dispose.call(this, e);
      }, t.prototype.clone = function(e, i, r) {
        return i === void 0 && (i = null), new t(e, this.getScene(), i, this, r);
      }, t.prototype.createInstance = function(e) {
        var i = new Rf(e, this);
        if (this.instancedBuffers)
          for (var r in i.instancedBuffers = {}, this.instancedBuffers)
            i.instancedBuffers[r] = this.instancedBuffers[r];
        return i;
      }, t.prototype.serialize = function(e) {
        n.prototype.serialize.call(this, e), e.color = this.color.asArray(), e.alpha = this.alpha;
      }, t.Parse = function(e, i) {
        var r = new t(e.name, i);
        return r.color = ne.FromArray(e.color), r.alpha = e.alpha, r;
      }, t;
    }(ie), Rf = function(n) {
      function t(e, i) {
        var r = n.call(this, e, i) || this;
        return r.intersectionThreshold = i.intersectionThreshold, r;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "InstancedLinesMesh";
      }, t;
    }(dl);
    function Cf(n) {
      for (var t = [], e = [], i = n.lines, r = n.colors, o = [], a = 0, s = 0; s < i.length; s++)
        for (var l = i[s], c = 0; c < l.length; c++) {
          var u = l[c], h = u.x, d = u.y, p = u.z;
          if (e.push(h, d, p), r) {
            var f = r[s][c], m = f.r, g = f.g, y = f.b, b = f.a;
            o.push(m, g, y, b);
          }
          c > 0 && (t.push(a - 1), t.push(a)), a++;
        }
      var T = new Oe();
      return T.indices = t, T.positions = e, r && (T.colors = o), T;
    }
    function Pf(n) {
      var t, e, i = n.dashSize || 3, r = n.gapSize || 1, o = n.dashNb || 200, a = n.points, s = [], l = [], c = v.Zero(), u = 0, h = 0, d = 0, p = 0, f = 0;
      for (f = 0; f < a.length - 1; f++)
        a[f + 1].subtractToRef(a[f], c), u += c.length();
      for (e = i * (t = u / o) / (i + r), f = 0; f < a.length - 1; f++) {
        a[f + 1].subtractToRef(a[f], c), h = Math.floor(c.length() / t), c.normalize();
        for (var m = 0; m < h; m++)
          d = t * m, s.push(a[f].x + d * c.x, a[f].y + d * c.y, a[f].z + d * c.z), s.push(a[f].x + (d + e) * c.x, a[f].y + (d + e) * c.y, a[f].z + (d + e) * c.z), l.push(p, p + 1), p += 2;
      }
      var g = new Oe();
      return g.positions = s, g.indices = l, g;
    }
    function Ss(n, t, e) {
      e === void 0 && (e = null);
      var i = t.instance, r = t.lines, o = t.colors;
      if (i) {
        var a = i.getVerticesData(P.PositionKind), s = void 0, l = void 0;
        o && (s = i.getVerticesData(P.ColorKind));
        for (var c = 0, u = 0, h = 0; h < r.length; h++)
          for (var d = r[h], p = 0; p < d.length; p++)
            a[c] = d[p].x, a[c + 1] = d[p].y, a[c + 2] = d[p].z, o && s && (l = o[h], s[u] = l[p].r, s[u + 1] = l[p].g, s[u + 2] = l[p].b, s[u + 3] = l[p].a, u += 4), c += 3;
        return i.updateVerticesData(P.PositionKind, a, !1, !1), o && s && i.updateVerticesData(P.ColorKind, s, !1, !1), i;
      }
      var f = new El(n, e, null, void 0, void 0, !!o, t.useVertexAlpha, t.material);
      return Cf(t).applyToMesh(f, t.updatable), f;
    }
    function si(n, t, e) {
      e === void 0 && (e = null);
      var i = t.colors ? [t.colors] : null;
      return Ss(n, { lines: [t.points], updatable: t.updatable, instance: t.instance, colors: i, useVertexAlpha: t.useVertexAlpha, material: t.material }, e);
    }
    function xh(n, t, e) {
      e === void 0 && (e = null);
      var i = t.points, r = t.instance, o = t.gapSize || 1, a = t.dashSize || 3;
      if (r)
        return (t.dashNb || t.dashSize || t.gapSize || t.useVertexAlpha || t.material) && q.Warn("You have used an option other than points with the instance option. Please be aware that these other options will be ignored."), r.updateMeshPositions(function(l) {
          var c, u, h = v.Zero(), d = l.length / 6, p = 0, f = 0, m = 0, g = 0, y = 0, b = 0;
          for (y = 0; y < i.length - 1; y++)
            i[y + 1].subtractToRef(i[y], h), p += h.length();
          c = p / d;
          var T = r._creationDataStorage.dashSize;
          for (u = T * c / (T + r._creationDataStorage.gapSize), y = 0; y < i.length - 1; y++)
            for (i[y + 1].subtractToRef(i[y], h), f = Math.floor(h.length() / c), h.normalize(), b = 0; b < f && g < l.length; )
              m = c * b, l[g] = i[y].x + m * h.x, l[g + 1] = i[y].y + m * h.y, l[g + 2] = i[y].z + m * h.z, l[g + 3] = i[y].x + (m + u) * h.x, l[g + 4] = i[y].y + (m + u) * h.y, l[g + 5] = i[y].z + (m + u) * h.z, g += 6, b++;
          for (; g < l.length; )
            l[g] = i[y].x, l[g + 1] = i[y].y, l[g + 2] = i[y].z, g += 3;
        }, !1), r;
      var s = new El(n, e, null, void 0, void 0, void 0, t.useVertexAlpha, t.material);
      return Pf(t).applyToMesh(s, t.updatable), s._creationDataStorage = new Ap(), s._creationDataStorage.dashSize = a, s._creationDataStorage.gapSize = o, s;
    }
    var tC = { CreateDashedLines: xh, CreateLineSystem: Ss, CreateLines: si };
    Oe.CreateLineSystem = Cf, Oe.CreateDashedLines = Pf, ie.CreateLines = function(n, t, e, i, r) {
      return e === void 0 && (e = null), i === void 0 && (i = !1), r === void 0 && (r = null), si(n, { points: t, updatable: i, instance: r }, e);
    }, ie.CreateDashedLines = function(n, t, e, i, r, o, a, s) {
      return o === void 0 && (o = null), xh(n, { points: t, dashSize: e, gapSize: i, dashNb: r, updatable: a, instance: s }, o);
    };
    var Y1 = function(n) {
      function t(e, i) {
        var r = n.call(this, e.x, e.y) || this;
        return r.index = i, r;
      }
      return D(t, n), t;
    }(fe), Dv = function() {
      function n() {
        this.elements = [];
      }
      return n.prototype.add = function(t) {
        var e = this, i = [];
        return t.forEach(function(r) {
          var o = new Y1(r, e.elements.length);
          i.push(o), e.elements.push(o);
        }), i;
      }, n.prototype.computeBounds = function() {
        var t = new fe(this.elements[0].x, this.elements[0].y), e = new fe(this.elements[0].x, this.elements[0].y);
        return this.elements.forEach(function(i) {
          i.x < t.x ? t.x = i.x : i.x > e.x && (e.x = i.x), i.y < t.y ? t.y = i.y : i.y > e.y && (e.y = i.y);
        }), { min: t, max: e, width: e.x - t.x, height: e.y - t.y };
      }, n;
    }(), iC = function() {
      function n() {
      }
      return n.Rectangle = function(t, e, i, r) {
        return [new fe(t, e), new fe(i, e), new fe(i, r), new fe(t, r)];
      }, n.Circle = function(t, e, i, r) {
        e === void 0 && (e = 0), i === void 0 && (i = 0), r === void 0 && (r = 32);
        for (var o = [], a = 0, s = 2 * Math.PI / r, l = 0; l < r; l++)
          o.push(new fe(e + Math.cos(a) * t, i + Math.sin(a) * t)), a -= s;
        return o;
      }, n.Parse = function(t) {
        var e, i = t.split(/[^-+eE.\d]+/).map(parseFloat).filter(function(o) {
          return !isNaN(o);
        }), r = [];
        for (e = 0; e < (2147483646 & i.length); e += 2)
          r.push(new fe(i[e], i[e + 1]));
        return r;
      }, n.StartingAt = function(t, e) {
        return Hu.StartingAt(t, e);
      }, n;
    }(), Nv = function() {
      function n(t, e, i, r) {
        var o;
        r === void 0 && (r = earcut), this._points = new Dv(), this._outlinepoints = new Dv(), this._holes = new Array(), this._epoints = new Array(), this._eholes = new Array(), this.bjsEarcut = r, this._name = t, this._scene = i || Me.LastCreatedScene, o = e instanceof Hu ? e.getPoints() : e, this._addToepoint(o), this._points.add(o), this._outlinepoints.add(o), this.bjsEarcut === void 0 && q.Warn("Earcut was not found, the polygon will not be built.");
      }
      return n.prototype._addToepoint = function(t) {
        for (var e = 0, i = t; e < i.length; e++) {
          var r = i[e];
          this._epoints.push(r.x, r.y);
        }
      }, n.prototype.addHole = function(t) {
        this._points.add(t);
        var e = new Dv();
        return e.add(t), this._holes.push(e), this._eholes.push(this._epoints.length / 2), this._addToepoint(t), this;
      }, n.prototype.build = function(t, e, i) {
        t === void 0 && (t = !1), e === void 0 && (e = 0), i === void 0 && (i = 2);
        var r = new ie(this._name, this._scene), o = this.buildVertexData(e, i);
        return r.setVerticesData(P.PositionKind, o.positions, t), r.setVerticesData(P.NormalKind, o.normals, t), r.setVerticesData(P.UVKind, o.uvs, t), r.setIndices(o.indices), r;
      }, n.prototype.buildVertexData = function(t, e) {
        var i = this;
        t === void 0 && (t = 0), e === void 0 && (e = 2);
        var r = new Oe(), o = [], a = [], s = [], l = this._points.computeBounds();
        this._points.elements.forEach(function(y) {
          o.push(0, 1, 0), a.push(y.x, 0, y.y), s.push((y.x - l.min.x) / l.width, (y.y - l.min.y) / l.height);
        });
        for (var c = [], u = this.bjsEarcut(this._epoints, this._eholes, 2), h = 0; h < u.length; h++)
          c.push(u[h]);
        if (t > 0) {
          var d = a.length / 3;
          this._points.elements.forEach(function(y) {
            o.push(0, -1, 0), a.push(y.x, -t, y.y), s.push(1 - (y.x - l.min.x) / l.width, 1 - (y.y - l.min.y) / l.height);
          });
          var p = c.length;
          for (h = 0; h < p; h += 3) {
            var f = c[h + 0], m = c[h + 1], g = c[h + 2];
            c.push(g + d), c.push(m + d), c.push(f + d);
          }
          this._addSide(a, o, s, c, l, this._outlinepoints, t, !1, e), this._holes.forEach(function(y) {
            i._addSide(a, o, s, c, l, y, t, !0, e);
          });
        }
        return r.indices = c, r.positions = a, r.normals = o, r.uvs = s, r;
      }, n.prototype._addSide = function(t, e, i, r, o, a, s, l, c) {
        for (var u = t.length / 3, h = 0, d = 0; d < a.elements.length; d++) {
          var p = a.elements[d], f = a.elements[(d + 1) % a.elements.length];
          t.push(p.x, 0, p.y), t.push(p.x, -s, p.y), t.push(f.x, 0, f.y), t.push(f.x, -s, f.y);
          var m = a.elements[(d + a.elements.length - 1) % a.elements.length], g = a.elements[(d + 2) % a.elements.length], y = new v(-(f.y - p.y), 0, f.x - p.x), b = new v(-(p.y - m.y), 0, p.x - m.x), T = new v(-(g.y - f.y), 0, g.x - f.x);
          l || (y = y.scale(-1), b = b.scale(-1), T = T.scale(-1));
          var S = y.normalizeToNew(), E = b.normalizeToNew(), A = T.normalizeToNew(), R = v.Dot(E, S);
          E = R > c ? R < Ge - 1 ? new v(p.x, 0, p.y).subtract(new v(f.x, 0, f.y)).normalize() : b.add(y).normalize() : S;
          var C = v.Dot(T, y);
          A = C > c ? C < Ge - 1 ? new v(f.x, 0, f.y).subtract(new v(p.x, 0, p.y)).normalize() : T.add(y).normalize() : S, i.push(h / o.width, 0), i.push(h / o.width, 1), h += y.length(), i.push(h / o.width, 0), i.push(h / o.width, 1), e.push(E.x, E.y, E.z), e.push(E.x, E.y, E.z), e.push(A.x, A.y, A.z), e.push(A.x, A.y, A.z), l ? (r.push(u), r.push(u + 2), r.push(u + 1), r.push(u + 1), r.push(u + 2), r.push(u + 3)) : (r.push(u), r.push(u + 1), r.push(u + 2), r.push(u + 1), r.push(u + 3), r.push(u + 2)), u += 4;
        }
      }, n;
    }();
    function If(n, t, e, i, r, o, a) {
      for (var s = e || new Array(3), l = i, c = [], u = a || !1, h = 0; h < 3; h++)
        s[h] === void 0 && (s[h] = new lt(0, 0, 1, 1)), l && l[h] === void 0 && (l[h] = new Ie(1, 1, 1, 1));
      var d = n.getVerticesData(P.PositionKind), p = n.getVerticesData(P.NormalKind), f = n.getVerticesData(P.UVKind), m = n.getIndices(), g = d.length / 9, y = 0, b = 0, T = 0, S = 0, E = [0];
      if (u)
        for (var A = g; A < d.length / 3; A += 4)
          b = d[3 * (A + 2)] - d[3 * A], T = d[3 * (A + 2) + 2] - d[3 * A + 2], S += Math.sqrt(b * b + T * T), E.push(S);
      for (var R = 0, C = 0, L = 0; L < p.length; L += 3)
        Math.abs(p[L + 1]) < 1e-3 && (C = 1), Math.abs(p[L + 1] - 1) < 1e-3 && (C = 0), Math.abs(p[L + 1] + 1) < 1e-3 && (C = 2), R = L / 3, C === 1 ? (y = R - g, f[2 * R] = y % 4 < 1.5 ? u ? s[C].x + (s[C].z - s[C].x) * E[Math.floor(y / 4)] / S : s[C].x : u ? s[C].x + (s[C].z - s[C].x) * E[Math.floor(y / 4) + 1] / S : s[C].z, f[2 * R + 1] = y % 2 == 0 ? Lt.UseOpenGLOrientationForUV ? 1 - s[C].w : s[C].w : Lt.UseOpenGLOrientationForUV ? 1 - s[C].y : s[C].y) : (f[2 * R] = (1 - f[2 * R]) * s[C].x + f[2 * R] * s[C].z, f[2 * R + 1] = (1 - f[2 * R + 1]) * s[C].y + f[2 * R + 1] * s[C].w, Lt.UseOpenGLOrientationForUV && (f[2 * R + 1] = 1 - f[2 * R + 1])), l && c.push(l[C].r, l[C].g, l[C].b, l[C].a);
      Oe._ComputeSides(t, d, m, p, f, r, o);
      var I = new Oe();
      if (I.indices = m, I.positions = d, I.normals = p, I.uvs = f, l) {
        var O = t === Oe.DOUBLESIDE ? c.concat(c) : c;
        I.colors = O;
      }
      return I;
    }
    function Mc(n, t, e, i) {
      e === void 0 && (e = null), i === void 0 && (i = earcut), t.sideOrientation = ie._GetDefaultSideOrientation(t.sideOrientation);
      for (var r = t.shape, o = t.holes || [], a = t.depth || 0, s = t.smoothingThreshold || 2, l = [], c = [], u = 0; u < r.length; u++)
        l[u] = new fe(r[u].x, r[u].z);
      l[0].equalsWithEpsilon(l[l.length - 1], 1e-8) && l.pop();
      for (var h = new Nv(n, l, e || Me.LastCreatedScene, i), d = 0; d < o.length; d++) {
        c = [];
        for (var p = 0; p < o[d].length; p++)
          c.push(new fe(o[d][p].x, o[d][p].z));
        h.addHole(c);
      }
      var f = h.build(!1, a, s);
      return f._originalBuilderSideOrientation = t.sideOrientation, If(f, t.sideOrientation, t.faceUV, t.faceColors, t.frontUVs, t.backUVs, t.wrap).applyToMesh(f, t.updatable), f;
    }
    function Oc(n, t, e, i) {
      return e === void 0 && (e = null), i === void 0 && (i = earcut), Mc(n, t, e, i);
    }
    var nC = { ExtrudePolygon: Oc, CreatePolygon: Mc };
    function Dc(n, t, e) {
      e === void 0 && (e = null);
      var i = t.path, r = t.shape, o = t.scale || 1, a = t.rotation || 0, s = t.cap === 0 ? 0 : t.cap || ie.NO_CAP, l = t.updatable, c = ie._GetDefaultSideOrientation(t.sideOrientation), u = t.instance || null, h = t.invertUV || !1, d = t.closeShape || !1;
      return rC(n, r, i, o, a, null, null, t.closePath || !1, d, s, !1, e, !!l, c, u, h, t.frontUVs || null, t.backUVs || null, t.firstNormal || null, !!t.adjustFrame);
    }
    function Nc(n, t, e) {
      e === void 0 && (e = null);
      var i = t.path, r = t.shape, o = t.scaleFunction || function() {
        return 1;
      }, a = t.rotationFunction || function() {
        return 0;
      }, s = t.closePath || t.ribbonCloseArray || !1, l = t.closeShape || t.ribbonClosePath || !1, c = t.cap === 0 ? 0 : t.cap || ie.NO_CAP, u = t.updatable, h = t.firstNormal || null, d = t.adjustFrame || !1;
      return rC(n, r, i, null, null, o, a, s, l, c, !0, e, !!u, ie._GetDefaultSideOrientation(t.sideOrientation), t.instance || null, t.invertUV || !1, t.frontUVs || null, t.backUVs || null, h, d);
    }
    function rC(n, t, e, i, r, o, a, s, l, c, u, h, d, p, f, m, g, y, b, T) {
      var S, E, A = function(L, I, O, w, z, V, Y, ee, J, X, K) {
        var te = O.getTangents(), se = O.getNormals(), _e = O.getBinormals(), xe = O.getDistances();
        if (K) {
          for (var Te = 0; Te < te.length; Te++)
            if (te[Te].x == 0 && te[Te].y == 0 && te[Te].z == 0 && te[Te].copyFrom(te[Te - 1]), se[Te].x == 0 && se[Te].y == 0 && se[Te].z == 0 && se[Te].copyFrom(se[Te - 1]), _e[Te].x == 0 && _e[Te].y == 0 && _e[Te].z == 0 && _e[Te].copyFrom(_e[Te - 1]), Te > 0) {
              var he = te[Te - 1];
              v.Dot(he, te[Te]) < 0 && te[Te].scaleInPlace(-1), he = se[Te - 1], v.Dot(he, se[Te]) < 0 && se[Te].scaleInPlace(-1), he = _e[Te - 1], v.Dot(he, _e[Te]) < 0 && _e[Te].scaleInPlace(-1);
            }
        }
        var me = 0, Fe = X && ee ? ee : function() {
          return V !== null ? V : 0;
        }, Ce = X && Y ? Y : function() {
          return z !== null ? z : 1;
        }, Re = J === ie.NO_CAP || J === ie.CAP_END ? 0 : 2, Be = F.Matrix[0];
        for (Te = 0; Te < I.length; Te++) {
          var De = [], Ke = Fe(Te, xe[Te]), ge = Ce(Te, xe[Te]);
          B.RotationAxisToRef(te[Te], me, Be);
          for (var rt = 0; rt < L.length; rt++) {
            var it = te[Te].scale(L[rt].z).add(se[Te].scale(L[rt].x)).add(_e[Te].scale(L[rt].y)), He = v.Zero();
            v.TransformCoordinatesToRef(it, Be, He), He.scaleInPlace(ge).addInPlace(I[Te]), De[rt] = He;
          }
          w[Re] = De, me += Ke, Re++;
        }
        var Pt = function(ke) {
          var xt, Nt = Array(), $e = v.Zero();
          for (xt = 0; xt < ke.length; xt++)
            $e.addInPlace(ke[xt]);
          for ($e.scaleInPlace(1 / ke.length), xt = 0; xt < ke.length; xt++)
            Nt.push($e);
          return Nt;
        };
        switch (J) {
          case ie.NO_CAP:
            break;
          case ie.CAP_START:
            w[0] = Pt(w[2]), w[1] = w[2];
            break;
          case ie.CAP_END:
            w[Re] = w[Re - 1], w[Re + 1] = Pt(w[Re - 1]);
            break;
          case ie.CAP_ALL:
            w[0] = Pt(w[2]), w[1] = w[2], w[Re] = w[Re - 1], w[Re + 1] = Pt(w[Re - 1]);
        }
        return w;
      };
      if (f) {
        var R = f._creationDataStorage;
        return S = b ? R.path3D.update(e, b) : R.path3D.update(e), pa("", { pathArray: E = A(t, e, R.path3D, R.pathArray, i, r, o, a, R.cap, u, T), closeArray: !1, closePath: !1, offset: 0, updatable: !1, sideOrientation: 0, instance: f }, h || void 0);
      }
      c = c < 0 || c > 3 ? 0 : c;
      var C = pa(n, { pathArray: E = A(t, e, S = b ? new Xu(e, b) : new Xu(e), new Array(), i, r, o, a, c, u, T), closeArray: s, closePath: l, updatable: d, sideOrientation: p, invertUV: m, frontUVs: g || void 0, backUVs: y || void 0 }, h);
      return C._creationDataStorage.pathArray = E, C._creationDataStorage.path3D = S, C._creationDataStorage.cap = c, C;
    }
    Oe.CreatePolygon = If, ie.CreatePolygon = function(n, t, e, i, r, o, a) {
      return a === void 0 && (a = earcut), Mc(n, { shape: t, holes: i, updatable: r, sideOrientation: o }, e, a);
    }, ie.ExtrudePolygon = function(n, t, e, i, r, o, a, s) {
      return s === void 0 && (s = earcut), Oc(n, { shape: t, holes: r, depth: e, updatable: o, sideOrientation: a }, i, s);
    };
    var oC = { ExtrudeShape: Dc, ExtrudeShapeCustom: Nc };
    function Ah(n, t, e) {
      e === void 0 && (e = null);
      var i, r, o = t.arc ? t.arc <= 0 || t.arc > 1 ? 1 : t.arc : 1, a = t.closed === void 0 || t.closed, s = t.shape, l = t.radius || 1, c = t.tessellation || 64, u = t.clip || 0, h = t.updatable, d = ie._GetDefaultSideOrientation(t.sideOrientation), p = t.cap || ie.NO_CAP, f = 2 * Math.PI, m = [], g = t.invertUV || !1, y = 0, b = 0, T = f / c * o;
      for (y = 0; y <= c - u; y++) {
        for (r = [], p != ie.CAP_START && p != ie.CAP_ALL || (r.push(new v(0, s[0].y, 0)), r.push(new v(Math.cos(y * T) * s[0].x * l, s[0].y, Math.sin(y * T) * s[0].x * l))), b = 0; b < s.length; b++)
          i = new v(Math.cos(y * T) * s[b].x * l, s[b].y, Math.sin(y * T) * s[b].x * l), r.push(i);
        p != ie.CAP_END && p != ie.CAP_ALL || (r.push(new v(Math.cos(y * T) * s[s.length - 1].x * l, s[s.length - 1].y, Math.sin(y * T) * s[s.length - 1].x * l)), r.push(new v(0, s[s.length - 1].y, 0))), m.push(r);
      }
      return pa(n, { pathArray: m, closeArray: a, sideOrientation: d, updatable: h, invertUV: g, frontUVs: t.frontUVs, backUVs: t.backUVs }, e);
    }
    ie.ExtrudeShape = function(n, t, e, i, r, o, a, s, l, c) {
      return a === void 0 && (a = null), Dc(n, { shape: t, path: e, scale: i, rotation: r, cap: o === 0 ? 0 : o || ie.NO_CAP, sideOrientation: l, instance: c, updatable: s }, a);
    }, ie.ExtrudeShapeCustom = function(n, t, e, i, r, o, a, s, l, c, u, h) {
      return Nc(n, { shape: t, path: e, scaleFunction: i, rotationFunction: r, ribbonCloseArray: o, ribbonClosePath: a, cap: s === 0 ? 0 : s || ie.NO_CAP, sideOrientation: u, instance: h, updatable: c }, l);
    };
    var aC = { CreateLathe: Ah };
    function Rh(n, t, e) {
      e === void 0 && (e = null);
      var i = t.path, r = t.instance, o = 1;
      t.radius !== void 0 ? o = t.radius : r && (o = r._creationDataStorage.radius);
      var a = t.tessellation || 64, s = t.radiusFunction || null, l = t.cap || ie.NO_CAP, c = t.invertUV || !1, u = t.updatable, h = ie._GetDefaultSideOrientation(t.sideOrientation);
      t.arc = t.arc && (t.arc <= 0 || t.arc > 1) ? 1 : t.arc || 1;
      var d, p, f = function(b, T, S, E, A, R, C, L) {
        for (var I, O, w, z, V = T.getTangents(), Y = T.getNormals(), ee = T.getDistances(), J = 2 * Math.PI / A * L, X = R || function() {
          return E;
        }, K = F.Matrix[0], te = C === ie.NO_CAP || C === ie.CAP_END ? 0 : 2, se = 0; se < b.length; se++) {
          O = X(se, ee[se]), I = Array(), w = Y[se];
          for (var _e = 0; _e < A; _e++)
            B.RotationAxisToRef(V[se], J * _e, K), z = I[_e] ? I[_e] : v.Zero(), v.TransformCoordinatesToRef(w, K, z), z.scaleInPlace(O).addInPlace(b[se]), I[_e] = z;
          S[te] = I, te++;
        }
        var xe = function(Te, he) {
          for (var me = Array(), Fe = 0; Fe < Te; Fe++)
            me.push(b[he]);
          return me;
        };
        switch (C) {
          case ie.NO_CAP:
            break;
          case ie.CAP_START:
            S[0] = xe(A, 0), S[1] = S[2].slice(0);
            break;
          case ie.CAP_END:
            S[te] = S[te - 1].slice(0), S[te + 1] = xe(A, b.length - 1);
            break;
          case ie.CAP_ALL:
            S[0] = xe(A, 0), S[1] = S[2].slice(0), S[te] = S[te - 1].slice(0), S[te + 1] = xe(A, b.length - 1);
        }
        return S;
      };
      if (r) {
        var m = r._creationDataStorage, g = t.arc || m.arc;
        return r = pa("", { pathArray: p = f(i, d = m.path3D.update(i), m.pathArray, o, m.tessellation, s, m.cap, g), instance: r }), m.path3D = d, m.pathArray = p, m.arc = g, m.radius = o, r;
      }
      l = l < 0 || l > 3 ? 0 : l;
      var y = pa(n, { pathArray: p = f(i, d = new Xu(i), new Array(), o, a, s, l, t.arc), closePath: !0, closeArray: !1, updatable: u, sideOrientation: h, invertUV: c, frontUVs: t.frontUVs, backUVs: t.backUVs }, e);
      return y._creationDataStorage.pathArray = p, y._creationDataStorage.path3D = d, y._creationDataStorage.tessellation = a, y._creationDataStorage.cap = l, y._creationDataStorage.arc = t.arc, y._creationDataStorage.radius = o, y;
    }
    ie.CreateLathe = function(n, t, e, i, r, o, a) {
      return Ah(n, { shape: t, radius: e, tessellation: i, sideOrientation: a, updatable: o }, r);
    };
    var sC = { CreateTube: Rh };
    function Mf(n) {
      var t = [];
      t[0] = { vertex: [[0, 0, 1.732051], [1.632993, 0, -0.5773503], [-0.8164966, 1.414214, -0.5773503], [-0.8164966, -1.414214, -0.5773503]], face: [[0, 1, 2], [0, 2, 3], [0, 3, 1], [1, 3, 2]] }, t[1] = { vertex: [[0, 0, 1.414214], [1.414214, 0, 0], [0, 1.414214, 0], [-1.414214, 0, 0], [0, -1.414214, 0], [0, 0, -1.414214]], face: [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 1], [1, 4, 5], [1, 5, 2], [2, 5, 3], [3, 5, 4]] }, t[2] = { vertex: [[0, 0, 1.070466], [0.7136442, 0, 0.7978784], [-0.3568221, 0.618034, 0.7978784], [-0.3568221, -0.618034, 0.7978784], [0.7978784, 0.618034, 0.3568221], [0.7978784, -0.618034, 0.3568221], [-0.9341724, 0.381966, 0.3568221], [0.1362939, 1, 0.3568221], [0.1362939, -1, 0.3568221], [-0.9341724, -0.381966, 0.3568221], [0.9341724, 0.381966, -0.3568221], [0.9341724, -0.381966, -0.3568221], [-0.7978784, 0.618034, -0.3568221], [-0.1362939, 1, -0.3568221], [-0.1362939, -1, -0.3568221], [-0.7978784, -0.618034, -0.3568221], [0.3568221, 0.618034, -0.7978784], [0.3568221, -0.618034, -0.7978784], [-0.7136442, 0, -0.7978784], [0, 0, -1.070466]], face: [[0, 1, 4, 7, 2], [0, 2, 6, 9, 3], [0, 3, 8, 5, 1], [1, 5, 11, 10, 4], [2, 7, 13, 12, 6], [3, 9, 15, 14, 8], [4, 10, 16, 13, 7], [5, 8, 14, 17, 11], [6, 12, 18, 15, 9], [10, 11, 17, 19, 16], [12, 13, 16, 19, 18], [14, 15, 18, 19, 17]] }, t[3] = { vertex: [[0, 0, 1.175571], [1.051462, 0, 0.5257311], [0.3249197, 1, 0.5257311], [-0.8506508, 0.618034, 0.5257311], [-0.8506508, -0.618034, 0.5257311], [0.3249197, -1, 0.5257311], [0.8506508, 0.618034, -0.5257311], [0.8506508, -0.618034, -0.5257311], [-0.3249197, 1, -0.5257311], [-1.051462, 0, -0.5257311], [-0.3249197, -1, -0.5257311], [0, 0, -1.175571]], face: [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5], [0, 5, 1], [1, 5, 7], [1, 7, 6], [1, 6, 2], [2, 6, 8], [2, 8, 3], [3, 8, 9], [3, 9, 4], [4, 9, 10], [4, 10, 5], [5, 10, 7], [6, 7, 11], [6, 11, 8], [7, 10, 11], [8, 11, 9], [9, 11, 10]] }, t[4] = { vertex: [[0, 0, 1.070722], [0.7148135, 0, 0.7971752], [-0.104682, 0.7071068, 0.7971752], [-0.6841528, 0.2071068, 0.7971752], [-0.104682, -0.7071068, 0.7971752], [0.6101315, 0.7071068, 0.5236279], [1.04156, 0.2071068, 0.1367736], [0.6101315, -0.7071068, 0.5236279], [-0.3574067, 1, 0.1367736], [-0.7888348, -0.5, 0.5236279], [-0.9368776, 0.5, 0.1367736], [-0.3574067, -1, 0.1367736], [0.3574067, 1, -0.1367736], [0.9368776, -0.5, -0.1367736], [0.7888348, 0.5, -0.5236279], [0.3574067, -1, -0.1367736], [-0.6101315, 0.7071068, -0.5236279], [-1.04156, -0.2071068, -0.1367736], [-0.6101315, -0.7071068, -0.5236279], [0.104682, 0.7071068, -0.7971752], [0.6841528, -0.2071068, -0.7971752], [0.104682, -0.7071068, -0.7971752], [-0.7148135, 0, -0.7971752], [0, 0, -1.070722]], face: [[0, 2, 3], [1, 6, 5], [4, 9, 11], [7, 15, 13], [8, 16, 10], [12, 14, 19], [17, 22, 18], [20, 21, 23], [0, 1, 5, 2], [0, 3, 9, 4], [0, 4, 7, 1], [1, 7, 13, 6], [2, 5, 12, 8], [2, 8, 10, 3], [3, 10, 17, 9], [4, 11, 15, 7], [5, 6, 14, 12], [6, 13, 20, 14], [8, 12, 19, 16], [9, 17, 18, 11], [10, 16, 22, 17], [11, 18, 21, 15], [13, 15, 21, 20], [14, 20, 23, 19], [16, 19, 23, 22], [18, 22, 23, 21]] }, t[5] = { vertex: [[0, 0, 1.322876], [1.309307, 0, 0.1889822], [-0.9819805, 0.8660254, 0.1889822], [0.1636634, -1.299038, 0.1889822], [0.3273268, 0.8660254, -0.9449112], [-0.8183171, -0.4330127, -0.9449112]], face: [[0, 3, 1], [2, 4, 5], [0, 1, 4, 2], [0, 2, 5, 3], [1, 3, 5, 4]] }, t[6] = { vertex: [[0, 0, 1.159953], [1.013464, 0, 0.5642542], [-0.3501431, 0.9510565, 0.5642542], [-0.7715208, -0.6571639, 0.5642542], [0.6633206, 0.9510565, -0.03144481], [0.8682979, -0.6571639, -0.3996071], [-1.121664, 0.2938926, -0.03144481], [-0.2348831, -1.063314, -0.3996071], [0.5181548, 0.2938926, -0.9953061], [-0.5850262, -0.112257, -0.9953061]], face: [[0, 1, 4, 2], [0, 2, 6, 3], [1, 5, 8, 4], [3, 6, 9, 7], [5, 7, 9, 8], [0, 3, 7, 5, 1], [2, 4, 8, 9, 6]] }, t[7] = { vertex: [[0, 0, 1.118034], [0.8944272, 0, 0.6708204], [-0.2236068, 0.8660254, 0.6708204], [-0.7826238, -0.4330127, 0.6708204], [0.6708204, 0.8660254, 0.2236068], [1.006231, -0.4330127, -0.2236068], [-1.006231, 0.4330127, 0.2236068], [-0.6708204, -0.8660254, -0.2236068], [0.7826238, 0.4330127, -0.6708204], [0.2236068, -0.8660254, -0.6708204], [-0.8944272, 0, -0.6708204], [0, 0, -1.118034]], face: [[0, 1, 4, 2], [0, 2, 6, 3], [1, 5, 8, 4], [3, 6, 10, 7], [5, 9, 11, 8], [7, 10, 11, 9], [0, 3, 7, 9, 5, 1], [2, 4, 8, 11, 10, 6]] }, t[8] = { vertex: [[-0.729665, 0.670121, 0.319155], [-0.655235, -0.29213, -0.754096], [-0.093922, -0.607123, 0.537818], [0.702196, 0.595691, 0.485187], [0.776626, -0.36656, -0.588064]], face: [[1, 4, 2], [0, 1, 2], [3, 0, 2], [4, 3, 2], [4, 1, 0, 3]] }, t[9] = { vertex: [[-0.868849, -0.100041, 0.61257], [-0.329458, 0.976099, 0.28078], [-0.26629, -0.013796, -0.477654], [-0.13392, -1.034115, 0.229829], [0.738834, 0.707117, -0.307018], [0.859683, -0.535264, -0.338508]], face: [[3, 0, 2], [5, 3, 2], [4, 5, 2], [1, 4, 2], [0, 1, 2], [0, 3, 5, 4, 1]] }, t[10] = { vertex: [[-0.610389, 0.243975, 0.531213], [-0.187812, -0.48795, -0.664016], [-0.187812, 0.9759, -0.664016], [0.187812, -0.9759, 0.664016], [0.798201, 0.243975, 0.132803]], face: [[1, 3, 0], [3, 4, 0], [3, 1, 4], [0, 2, 1], [0, 4, 2], [2, 4, 1]] }, t[11] = { vertex: [[-1.028778, 0.392027, -0.048786], [-0.640503, -0.646161, 0.621837], [-0.125162, -0.395663, -0.540059], [4683e-6, 0.888447, -0.651988], [0.125161, 0.395663, 0.540059], [0.632925, -0.791376, 0.433102], [1.031672, 0.157063, -0.354165]], face: [[3, 2, 0], [2, 1, 0], [2, 5, 1], [0, 4, 3], [0, 1, 4], [4, 1, 5], [2, 3, 6], [3, 4, 6], [5, 2, 6], [4, 5, 6]] }, t[12] = { vertex: [[-0.669867, 0.334933, -0.529576], [-0.669867, 0.334933, 0.529577], [-0.4043, 1.212901, 0], [-0.334933, -0.669867, -0.529576], [-0.334933, -0.669867, 0.529577], [0.334933, 0.669867, -0.529576], [0.334933, 0.669867, 0.529577], [0.4043, -1.212901, 0], [0.669867, -0.334933, -0.529576], [0.669867, -0.334933, 0.529577]], face: [[8, 9, 7], [6, 5, 2], [3, 8, 7], [5, 0, 2], [4, 3, 7], [0, 1, 2], [9, 4, 7], [1, 6, 2], [9, 8, 5, 6], [8, 3, 0, 5], [3, 4, 1, 0], [4, 9, 6, 1]] }, t[13] = { vertex: [[-0.931836, 0.219976, -0.264632], [-0.636706, 0.318353, 0.692816], [-0.613483, -0.735083, -0.264632], [-0.326545, 0.979634, 0], [-0.318353, -0.636706, 0.692816], [-0.159176, 0.477529, -0.856368], [0.159176, -0.477529, -0.856368], [0.318353, 0.636706, 0.692816], [0.326545, -0.979634, 0], [0.613482, 0.735082, -0.264632], [0.636706, -0.318353, 0.692816], [0.931835, -0.219977, -0.264632]], face: [[11, 10, 8], [7, 9, 3], [6, 11, 8], [9, 5, 3], [2, 6, 8], [5, 0, 3], [4, 2, 8], [0, 1, 3], [10, 4, 8], [1, 7, 3], [10, 11, 9, 7], [11, 6, 5, 9], [6, 2, 0, 5], [2, 4, 1, 0], [4, 10, 7, 1]] }, t[14] = { vertex: [[-0.93465, 0.300459, -0.271185], [-0.838689, -0.260219, -0.516017], [-0.711319, 0.717591, 0.128359], [-0.710334, -0.156922, 0.080946], [-0.599799, 0.556003, -0.725148], [-0.503838, -4675e-6, -0.969981], [-0.487004, 0.26021, 0.48049], [-0.460089, -0.750282, -0.512622], [-0.376468, 0.973135, -0.325605], [-0.331735, -0.646985, 0.084342], [-0.254001, 0.831847, 0.530001], [-0.125239, -0.494738, -0.966586], [0.029622, 0.027949, 0.730817], [0.056536, -0.982543, -0.262295], [0.08085, 1.087391, 0.076037], [0.125583, -0.532729, 0.485984], [0.262625, 0.599586, 0.780328], [0.391387, -0.726999, -0.716259], [0.513854, -0.868287, 0.139347], [0.597475, 0.85513, 0.326364], [0.641224, 0.109523, 0.783723], [0.737185, -0.451155, 0.538891], [0.848705, -0.612742, -0.314616], [0.976075, 0.365067, 0.32976], [1.072036, -0.19561, 0.084927]], face: [[15, 18, 21], [12, 20, 16], [6, 10, 2], [3, 0, 1], [9, 7, 13], [2, 8, 4, 0], [0, 4, 5, 1], [1, 5, 11, 7], [7, 11, 17, 13], [13, 17, 22, 18], [18, 22, 24, 21], [21, 24, 23, 20], [20, 23, 19, 16], [16, 19, 14, 10], [10, 14, 8, 2], [15, 9, 13, 18], [12, 15, 21, 20], [6, 12, 16, 10], [3, 6, 2, 0], [9, 3, 1, 7], [9, 15, 12, 6, 3], [22, 17, 11, 5, 4, 8, 14, 19, 23, 24]] };
      var e, i, r, o, a, s, l = n.type && (n.type < 0 || n.type >= t.length) ? 0 : n.type || 0, c = n.size, u = n.sizeX || c || 1, h = n.sizeY || c || 1, d = n.sizeZ || c || 1, p = n.custom || t[l], f = p.face.length, m = n.faceUV || new Array(f), g = n.faceColors, y = n.flat === void 0 || n.flat, b = n.sideOrientation === 0 ? 0 : n.sideOrientation || Oe.DEFAULTSIDE, T = [], S = [], E = [], A = [], R = [], C = 0, L = 0, I = [], O = 0, w = 0;
      if (y)
        for (w = 0; w < f; w++)
          g && g[w] === void 0 && (g[w] = new Ie(1, 1, 1, 1)), m && m[w] === void 0 && (m[w] = new lt(0, 0, 1, 1));
      if (y)
        for (w = 0; w < f; w++) {
          var z = p.face[w].length;
          for (r = 2 * Math.PI / z, o = 0.5 * Math.tan(r / 2), a = 0.5, O = 0; O < z; O++)
            T.push(p.vertex[p.face[w][O]][0] * u, p.vertex[p.face[w][O]][1] * h, p.vertex[p.face[w][O]][2] * d), I.push(C), C++, e = m[w].x + (m[w].z - m[w].x) * (0.5 + o), i = m[w].y + (m[w].w - m[w].y) * (a - 0.5), A.push(e, Lt.UseOpenGLOrientationForUV ? 1 - i : i), s = o * Math.cos(r) - a * Math.sin(r), a = o * Math.sin(r) + a * Math.cos(r), o = s, g && R.push(g[w].r, g[w].g, g[w].b, g[w].a);
          for (O = 0; O < z - 2; O++)
            S.push(I[0 + L], I[O + 2 + L], I[O + 1 + L]);
          L += z;
        }
      else {
        for (O = 0; O < p.vertex.length; O++)
          T.push(p.vertex[O][0] * u, p.vertex[O][1] * h, p.vertex[O][2] * d), A.push(0, Lt.UseOpenGLOrientationForUV ? 1 : 0);
        for (w = 0; w < f; w++)
          for (O = 0; O < p.face[w].length - 2; O++)
            S.push(p.face[w][0], p.face[w][O + 2], p.face[w][O + 1]);
      }
      Oe.ComputeNormals(T, S, E), Oe._ComputeSides(b, T, S, E, A, n.frontUVs, n.backUVs);
      var V = new Oe();
      return V.positions = T, V.indices = S, V.normals = E, V.uvs = A, g && y && (V.colors = R), V;
    }
    function xs(n, t, e) {
      t === void 0 && (t = {}), e === void 0 && (e = null);
      var i = new ie(n, e);
      return t.sideOrientation = ie._GetDefaultSideOrientation(t.sideOrientation), i._originalBuilderSideOrientation = t.sideOrientation, Mf(t).applyToMesh(i, t.updatable), i;
    }
    ie.CreateTube = function(n, t, e, i, r, o, a, s, l, c) {
      return Rh(n, { path: t, radius: e, tessellation: i, radiusFunction: r, arc: 1, cap: o, updatable: s, sideOrientation: l, instance: c }, a);
    };
    var lC = { CreatePolyhedron: xs };
    Oe.CreatePolyhedron = Mf, ie.CreatePolyhedron = function(n, t, e) {
      return xs(n, t, e);
    };
    var K1 = new v(1, 0, 0), q1 = new v(-1, 0, 0), Q1 = new v(0, 1, 0), Z1 = new v(0, -1, 0), J1 = new v(0, 0, 1), $1 = new v(0, 0, -1), cC = function() {
      function n(t, e, i, r, o, a, s, l, c) {
        t === void 0 && (t = v.Zero()), e === void 0 && (e = v.Up()), i === void 0 && (i = fe.Zero()), r === void 0 && (r = 0), o === void 0 && (o = 0), a === void 0 && (a = null), s === void 0 && (s = null), l === void 0 && (l = null), c === void 0 && (c = null), this.position = t, this.normal = e, this.uv = i, this.vertexIdx = r, this.vertexIdxForBones = o, this.localPositionOverride = a, this.localNormalOverride = s, this.matrixIndicesOverride = l, this.matrixWeightsOverride = c;
      }
      return n.prototype.clone = function() {
        var t, e, i, r;
        return new n(this.position.clone(), this.normal.clone(), this.uv.clone(), this.vertexIdx, this.vertexIdxForBones, (t = this.localPositionOverride) === null || t === void 0 ? void 0 : t.slice(), (e = this.localNormalOverride) === null || e === void 0 ? void 0 : e.slice(), (i = this.matrixIndicesOverride) === null || i === void 0 ? void 0 : i.slice(), (r = this.matrixWeightsOverride) === null || r === void 0 ? void 0 : r.slice());
      }, n;
    }();
    function Ch(n, t, e) {
      var i, r, o, a, s = !!t.skeleton, l = e.localMode || s, c = t.overrideMaterialSideOrientation !== null && t.overrideMaterialSideOrientation !== void 0, u = t.getIndices(), h = s ? t.getPositionData(!0, !0) : t.getVerticesData(P.PositionKind), d = s ? t.getNormalsData(!0, !0) : t.getVerticesData(P.NormalKind), p = l ? s ? t.getVerticesData(P.PositionKind) : h : null, f = l ? s ? t.getVerticesData(P.NormalKind) : d : null, m = t.getVerticesData(P.UVKind), g = s ? t.getVerticesData(P.MatricesIndicesKind) : null, y = s ? t.getVerticesData(P.MatricesWeightsKind) : null, b = s ? t.getVerticesData(P.MatricesIndicesExtraKind) : null, T = s ? t.getVerticesData(P.MatricesWeightsExtraKind) : null, S = e.position || v.Zero(), E = e.normal || v.Up(), A = e.size || v.One(), R = e.angle || 0;
      if (!E) {
        var C = new v(0, 0, 1), L = t.getScene().activeCamera, I = v.TransformCoordinates(C, L.getWorldMatrix());
        E = L.globalPosition.subtract(I);
      }
      var O = -Math.atan2(E.z, E.x) - Math.PI / 2, w = Math.sqrt(E.x * E.x + E.z * E.z), z = Math.atan2(E.y, w), V = new Oe();
      V.indices = [], V.positions = [], V.normals = [], V.uvs = [], V.matricesIndices = s ? [] : null, V.matricesWeights = s ? [] : null, V.matricesIndicesExtra = b ? [] : null, V.matricesWeightsExtra = T ? [] : null;
      var Y = 0, ee = function(He, Pt) {
        var ke = new cC();
        if (!u || !h || !d)
          return ke;
        var xt = u[He];
        if (ke.vertexIdx = 3 * xt, ke.vertexIdxForBones = 4 * xt, ke.position = new v(h[3 * xt], h[3 * xt + 1], h[3 * xt + 2]), v.TransformCoordinatesToRef(ke.position, Pt, ke.position), ke.normal = new v(d[3 * xt], d[3 * xt + 1], d[3 * xt + 2]), v.TransformNormalToRef(ke.normal, Pt, ke.normal), e.captureUVS && m) {
          var Nt = m[2 * xt + 1];
          ke.uv = new fe(m[2 * xt], Lt.UseOpenGLOrientationForUV ? 1 - Nt : Nt);
        }
        return ke;
      }, J = [0, 0, 0, 0], X = function(He, Pt) {
        if (He.length === 0)
          return He;
        var ke = 0.5 * Math.abs(v.Dot(A, Pt)), xt = function(ni, ci, qt, jr) {
          for (var Zn = 0; Zn < jr; ++Zn)
            if (ni[qt + Zn] === ci)
              return qt + Zn;
          return -1;
        }, Nt = function(ni, ci) {
          var qt, jr, Zn, In, yr, ns, Bs, Us, _o, mo, cr, Xo, go, Pa, Ia, Ma, Mn = v.GetClipFactor(ni.position, ci.position, Pt, ke), Yr = J, wn = J;
          if (g && y) {
            var jo = ni.matrixIndicesOverride ? 0 : ni.vertexIdxForBones, Yo = (qt = ni.matrixIndicesOverride) !== null && qt !== void 0 ? qt : g, vo = (jr = ni.matrixWeightsOverride) !== null && jr !== void 0 ? jr : y, Bn = ci.matrixIndicesOverride ? 0 : ci.vertexIdxForBones, Vs = (Zn = ci.matrixIndicesOverride) !== null && Zn !== void 0 ? Zn : g, Pm = (In = ci.matrixWeightsOverride) !== null && In !== void 0 ? In : y;
            Yr = [0, 0, 0, 0], wn = [0, 0, 0, 0];
            for (var Oa = 0, Kr = 0; Kr < 4; ++Kr)
              if (vo[jo + Kr] > 0) {
                var yo = xt(Vs, Yo[jo + Kr], Bn, 4);
                Yr[Oa] = Yo[jo + Kr], wn[Oa] = ue.Lerp(vo[jo + Kr], yo >= 0 ? Pm[yo] : 0, Mn), Oa++;
              }
            for (Kr = 0; Kr < 4 && Oa < 4; ++Kr) {
              var rs = Vs[Bn + Kr];
              xt(Yo, rs, jo, 4) === -1 && (Yr[Oa] = rs, wn[Oa] = ue.Lerp(0, Pm[Bn + Kr], Mn), Oa++);
            }
            var ks = wn[0] + wn[1] + wn[2] + wn[3];
            wn[0] /= ks, wn[1] /= ks, wn[2] /= ks, wn[3] /= ks;
          }
          var Im = ni.localPositionOverride ? ni.localPositionOverride[0] : (yr = p == null ? void 0 : p[ni.vertexIdx]) !== null && yr !== void 0 ? yr : 0, Gd = ni.localPositionOverride ? ni.localPositionOverride[1] : (ns = p == null ? void 0 : p[ni.vertexIdx + 1]) !== null && ns !== void 0 ? ns : 0, vu = ni.localPositionOverride ? ni.localPositionOverride[2] : (Bs = p == null ? void 0 : p[ni.vertexIdx + 2]) !== null && Bs !== void 0 ? Bs : 0, zd = ci.localPositionOverride ? ci.localPositionOverride[0] : (Us = p == null ? void 0 : p[ci.vertexIdx]) !== null && Us !== void 0 ? Us : 0, Wd = ci.localPositionOverride ? ci.localPositionOverride[1] : (_o = p == null ? void 0 : p[ci.vertexIdx + 1]) !== null && _o !== void 0 ? _o : 0, CA = ci.localPositionOverride ? ci.localPositionOverride[2] : (mo = p == null ? void 0 : p[ci.vertexIdx + 2]) !== null && mo !== void 0 ? mo : 0, Mm = ni.localNormalOverride ? ni.localNormalOverride[0] : (cr = f == null ? void 0 : f[ni.vertexIdx]) !== null && cr !== void 0 ? cr : 0, Hd = ni.localNormalOverride ? ni.localNormalOverride[1] : (Xo = f == null ? void 0 : f[ni.vertexIdx + 1]) !== null && Xo !== void 0 ? Xo : 0, yu = ni.localNormalOverride ? ni.localNormalOverride[2] : (go = f == null ? void 0 : f[ni.vertexIdx + 2]) !== null && go !== void 0 ? go : 0, Gs = Mm + ((ci.localNormalOverride ? ci.localNormalOverride[0] : (Pa = f == null ? void 0 : f[ci.vertexIdx]) !== null && Pa !== void 0 ? Pa : 0) - Mm) * Mn, Da = Hd + ((ci.localNormalOverride ? ci.localNormalOverride[1] : (Ia = f == null ? void 0 : f[ci.vertexIdx + 1]) !== null && Ia !== void 0 ? Ia : 0) - Hd) * Mn, Xd = yu + ((ci.localNormalOverride ? ci.localNormalOverride[2] : (Ma = f == null ? void 0 : f[ci.vertexIdx + 2]) !== null && Ma !== void 0 ? Ma : 0) - yu) * Mn, PA = Math.sqrt(Gs * Gs + Da * Da + Xd * Xd);
          return new cC(v.Lerp(ni.position, ci.position, Mn), v.Lerp(ni.normal, ci.normal, Mn).normalize(), fe.Lerp(ni.uv, ci.uv, Mn), -1, -1, p ? [Im + (zd - Im) * Mn, Gd + (Wd - Gd) * Mn, vu + (CA - vu) * Mn] : null, f ? [Gs / PA, Da / PA, Xd / PA] : null, Yr, wn);
        }, $e = null;
        He.length > 3 && ($e = []);
        for (var Rt = 0; Rt < He.length; Rt += 3) {
          var kt = null, _t = null, Pi = null, Hn = null, Xr = v.Dot(He[Rt].position, Pt) - ke > 0, fo = v.Dot(He[Rt + 1].position, Pt) - ke > 0, Ln = v.Dot(He[Rt + 2].position, Pt) - ke > 0;
          switch ((Xr ? 1 : 0) + (fo ? 1 : 0) + (Ln ? 1 : 0)) {
            case 0:
              He.length > 3 ? ($e.push(He[Rt]), $e.push(He[Rt + 1]), $e.push(He[Rt + 2])) : $e = He;
              break;
            case 1:
              if ($e = $e ?? new Array(), Xr && (kt = He[Rt + 1], _t = He[Rt + 2], Pi = Nt(He[Rt], kt), Hn = Nt(He[Rt], _t)), fo) {
                kt = He[Rt], _t = He[Rt + 2], Pi = Nt(He[Rt + 1], kt), Hn = Nt(He[Rt + 1], _t), $e.push(Pi), $e.push(_t.clone()), $e.push(kt.clone()), $e.push(_t.clone()), $e.push(Pi.clone()), $e.push(Hn);
                break;
              }
              Ln && (kt = He[Rt], _t = He[Rt + 1], Pi = Nt(He[Rt + 2], kt), Hn = Nt(He[Rt + 2], _t)), kt && _t && Pi && Hn && ($e.push(kt.clone()), $e.push(_t.clone()), $e.push(Pi), $e.push(Hn), $e.push(Pi.clone()), $e.push(_t.clone()));
              break;
            case 2:
              $e = $e ?? new Array(), Xr || (_t = Nt(kt = He[Rt].clone(), He[Rt + 1]), Pi = Nt(kt, He[Rt + 2]), $e.push(kt), $e.push(_t), $e.push(Pi)), fo || (_t = Nt(kt = He[Rt + 1].clone(), He[Rt + 2]), Pi = Nt(kt, He[Rt]), $e.push(kt), $e.push(_t), $e.push(Pi)), Ln || (_t = Nt(kt = He[Rt + 2].clone(), He[Rt]), Pi = Nt(kt, He[Rt + 1]), $e.push(kt), $e.push(_t), $e.push(Pi));
          }
        }
        return $e;
      }, K = t instanceof ie ? t : null, te = K == null ? void 0 : K._thinInstanceDataStorage.matrixData, se = (K == null ? void 0 : K.thinInstanceCount) || 1, _e = F.Matrix[0];
      _e.copyFrom(B.IdentityReadOnly);
      for (var xe = 0; xe < se; ++xe) {
        if (K != null && K.hasThinInstances && te) {
          var Te = 16 * xe;
          _e.setRowFromFloats(0, te[Te + 0], te[Te + 1], te[Te + 2], te[Te + 3]), _e.setRowFromFloats(1, te[Te + 4], te[Te + 5], te[Te + 6], te[Te + 7]), _e.setRowFromFloats(2, te[Te + 8], te[Te + 9], te[Te + 10], te[Te + 11]), _e.setRowFromFloats(3, te[Te + 12], te[Te + 13], te[Te + 14], te[Te + 15]);
        }
        for (var he = B.RotationYawPitchRoll(O, z, R).multiply(B.Translation(S.x, S.y, S.z)), me = B.Invert(he), Fe = t.getWorldMatrix(), Ce = _e.multiply(Fe).multiply(me), Re = new Array(3), Be = 0; Be < u.length; Be += 3) {
          var De = Re;
          if (De[0] = ee(Be, Ce), c && l ? (De[1] = ee(Be + 2, Ce), De[2] = ee(Be + 1, Ce)) : (De[1] = ee(Be + 1, Ce), De[2] = ee(Be + 2, Ce)), !(e.cullBackFaces && -De[0].normal.z <= 0 && -De[1].normal.z <= 0 && -De[2].normal.z <= 0) && (De = X(De, K1)) && (De = X(De, q1)) && (De = X(De, Q1)) && (De = X(De, Z1)) && (De = X(De, J1)) && (De = X(De, $1)))
            for (var Ke = 0; Ke < De.length; Ke++) {
              var ge = De[Ke];
              if (V.indices.push(Y), l ? (ge.localPositionOverride ? (V.positions[3 * Y] = ge.localPositionOverride[0], V.positions[3 * Y + 1] = ge.localPositionOverride[1], V.positions[3 * Y + 2] = ge.localPositionOverride[2]) : p && (V.positions[3 * Y] = p[ge.vertexIdx], V.positions[3 * Y + 1] = p[ge.vertexIdx + 1], V.positions[3 * Y + 2] = p[ge.vertexIdx + 2]), ge.localNormalOverride ? (V.normals[3 * Y] = ge.localNormalOverride[0], V.normals[3 * Y + 1] = ge.localNormalOverride[1], V.normals[3 * Y + 2] = ge.localNormalOverride[2]) : f && (V.normals[3 * Y] = f[ge.vertexIdx], V.normals[3 * Y + 1] = f[ge.vertexIdx + 1], V.normals[3 * Y + 2] = f[ge.vertexIdx + 2])) : (ge.position.toArray(V.positions, 3 * Y), ge.normal.toArray(V.normals, 3 * Y)), V.matricesIndices && V.matricesWeights && (ge.matrixIndicesOverride ? (V.matricesIndices[4 * Y] = ge.matrixIndicesOverride[0], V.matricesIndices[4 * Y + 1] = ge.matrixIndicesOverride[1], V.matricesIndices[4 * Y + 2] = ge.matrixIndicesOverride[2], V.matricesIndices[4 * Y + 3] = ge.matrixIndicesOverride[3]) : (g && (V.matricesIndices[4 * Y] = g[ge.vertexIdxForBones], V.matricesIndices[4 * Y + 1] = g[ge.vertexIdxForBones + 1], V.matricesIndices[4 * Y + 2] = g[ge.vertexIdxForBones + 2], V.matricesIndices[4 * Y + 3] = g[ge.vertexIdxForBones + 3]), b && V.matricesIndicesExtra && (V.matricesIndicesExtra[4 * Y] = b[ge.vertexIdxForBones], V.matricesIndicesExtra[4 * Y + 1] = b[ge.vertexIdxForBones + 1], V.matricesIndicesExtra[4 * Y + 2] = b[ge.vertexIdxForBones + 2], V.matricesIndicesExtra[4 * Y + 3] = b[ge.vertexIdxForBones + 3])), ge.matrixWeightsOverride ? (V.matricesWeights[4 * Y] = ge.matrixWeightsOverride[0], V.matricesWeights[4 * Y + 1] = ge.matrixWeightsOverride[1], V.matricesWeights[4 * Y + 2] = ge.matrixWeightsOverride[2], V.matricesWeights[4 * Y + 3] = ge.matrixWeightsOverride[3]) : (y && (V.matricesWeights[4 * Y] = y[ge.vertexIdxForBones], V.matricesWeights[4 * Y + 1] = y[ge.vertexIdxForBones + 1], V.matricesWeights[4 * Y + 2] = y[ge.vertexIdxForBones + 2], V.matricesWeights[4 * Y + 3] = y[ge.vertexIdxForBones + 3]), T && V.matricesWeightsExtra && (V.matricesWeightsExtra[4 * Y] = T[ge.vertexIdxForBones], V.matricesWeightsExtra[4 * Y + 1] = T[ge.vertexIdxForBones + 1], V.matricesWeightsExtra[4 * Y + 2] = T[ge.vertexIdxForBones + 2], V.matricesWeightsExtra[4 * Y + 3] = T[ge.vertexIdxForBones + 3]))), e.captureUVS)
                ge.uv.toArray(V.uvs, 2 * Y);
              else {
                V.uvs.push(0.5 + ge.position.x / A.x);
                var rt = 0.5 + ge.position.y / A.y;
                V.uvs.push(Lt.UseOpenGLOrientationForUV ? 1 - rt : rt);
              }
              Y++;
            }
        }
      }
      V.indices.length === 0 && (V.indices = null), V.positions.length === 0 && (V.positions = null), V.normals.length === 0 && (V.normals = null), V.uvs.length === 0 && (V.uvs = null), ((i = V.matricesIndices) === null || i === void 0 ? void 0 : i.length) === 0 && (V.matricesIndices = null), ((r = V.matricesWeights) === null || r === void 0 ? void 0 : r.length) === 0 && (V.matricesWeights = null), ((o = V.matricesIndicesExtra) === null || o === void 0 ? void 0 : o.length) === 0 && (V.matricesIndicesExtra = null), ((a = V.matricesWeightsExtra) === null || a === void 0 ? void 0 : a.length) === 0 && (V.matricesWeightsExtra = null);
      var it = new ie(n, t.getScene());
      return V.applyToMesh(it), l ? (it.skeleton = t.skeleton, it.parent = t) : (it.position = S.clone(), it.rotation = new v(z, O, R)), it.computeWorldMatrix(!0), it.refreshBoundingInfo(!0, !0), it;
    }
    var uC = { CreateDecal: Ch };
    ie.CreateDecal = function(n, t, e, i, r, o) {
      return Ch(n, t, { position: e, normal: i, size: r, angle: o });
    };
    var Li = function() {
      function n(t, e) {
        t === void 0 && (t = 0), e === void 0 && (e = 0), this.x = t, this.y = e, t !== Math.floor(t) && q.Warn("x is not an integer, floor(x) used"), e !== Math.floor(e) && q.Warn("y is not an integer, floor(y) used");
      }
      return n.prototype.clone = function() {
        return new n(this.x, this.y);
      }, n.prototype.rotate60About = function(t) {
        var e = this.x;
        return this.x = t.x + t.y - this.y, this.y = e + this.y - t.x, this;
      }, n.prototype.rotateNeg60About = function(t) {
        var e = this.x;
        return this.x = e + this.y - t.y, this.y = t.x + t.y - e, this;
      }, n.prototype.rotate120 = function(t, e) {
        t !== Math.floor(t) && q.Warn("m not an integer only floor(m) used"), e !== Math.floor(e) && q.Warn("n not an integer only floor(n) used");
        var i = this.x;
        return this.x = t - i - this.y, this.y = e + i, this;
      }, n.prototype.rotateNeg120 = function(t, e) {
        t !== Math.floor(t) && q.Warn("m is not an integer, floor(m) used"), e !== Math.floor(e) && q.Warn("n is not an integer,   floor(n) used");
        var i = this.x;
        return this.x = this.y - e, this.y = t + e - i - this.y, this;
      }, n.prototype.toCartesianOrigin = function(t, e) {
        var i = v.Zero();
        return i.x = t.x + 2 * this.x * e + this.y * e, i.y = t.y + Math.sqrt(3) * this.y * e, i;
      }, n.Zero = function() {
        return new n(0, 0);
      }, n;
    }(), Of = function() {
      function n() {
        this.cartesian = [], this.vertices = [], this.max = [], this.min = [], this.closestTo = [], this.innerFacets = [], this.isoVecsABOB = [], this.isoVecsOBOA = [], this.isoVecsBAOA = [], this.vertexTypes = [], this.IDATA = new Ph("icosahedron", "Regular", [[0, gt, -1], [-gt, 1, 0], [-1, 0, -gt], [1, 0, -gt], [gt, 1, 0], [0, gt, 1], [-1, 0, gt], [-gt, -1, 0], [0, -gt, -1], [gt, -1, 0], [1, 0, gt], [0, -gt, 1]], [[0, 2, 1], [0, 3, 2], [0, 4, 3], [0, 5, 4], [0, 1, 5], [7, 6, 1], [8, 7, 2], [9, 8, 3], [10, 9, 4], [6, 10, 5], [2, 7, 1], [3, 8, 2], [4, 9, 3], [5, 10, 4], [1, 6, 5], [11, 6, 7], [11, 7, 8], [11, 8, 9], [11, 9, 10], [11, 10, 6]]);
      }
      return n.prototype.setIndices = function() {
        var t, e, i, r, o, a, s, l = 12, c = {}, u = this.m, h = this.n, d = u;
        h !== 0 && (d = ue.HCF(u, h)), t = u / d, e = h / d;
        var p, f, m, g = Li.Zero(), y = new Li(u, h), b = new Li(-h, u + h), T = Li.Zero(), S = Li.Zero(), E = Li.Zero(), A = [], R = [], C = this.vertByDist, L = function(w, z, V, Y) {
          f = z + "|" + Y, (p = w + "|" + V) in c || f in c ? p in c && !(f in c) ? c[f] = c[p] : f in c && !(p in c) && (c[p] = c[f]) : (c[p] = l, c[f] = l, l++), C[V][0] > 2 ? R[c[p]] = [-C[V][0], C[V][1], c[p]] : R[c[p]] = [A[C[V][0]], C[V][1], c[p]];
        };
        this.IDATA.edgematch = [[1, "B"], [2, "B"], [3, "B"], [4, "B"], [0, "B"], [10, "O", 14, "A"], [11, "O", 10, "A"], [12, "O", 11, "A"], [13, "O", 12, "A"], [14, "O", 13, "A"], [0, "O"], [1, "O"], [2, "O"], [3, "O"], [4, "O"], [19, "B", 5, "A"], [15, "B", 6, "A"], [16, "B", 7, "A"], [17, "B", 8, "A"], [18, "B", 9, "A"]];
        for (var I = 0; I < 20; I++) {
          if (o = (A = this.IDATA.face[I])[2], a = A[1], s = A[0], m = g.x + "|" + g.y, (p = I + "|" + m) in c || (c[p] = o, R[o] = [A[C[m][0]], C[m][1]]), m = y.x + "|" + y.y, (p = I + "|" + m) in c || (c[p] = a, R[a] = [A[C[m][0]], C[m][1]]), m = b.x + "|" + b.y, (p = I + "|" + m) in c || (c[p] = s, R[s] = [A[C[m][0]], C[m][1]]), i = this.IDATA.edgematch[I][0], (r = this.IDATA.edgematch[I][1]) === "B")
            for (var O = 1; O < d; O++)
              S.x = u - O * (t + e), S.y = h + O * t, E.x = -O * e, E.y = O * (t + e), L(I, i, m = S.x + "|" + S.y, E.x + "|" + E.y);
          if (r === "O")
            for (O = 1; O < d; O++)
              E.x = -O * e, E.y = O * (t + e), T.x = O * t, T.y = O * e, L(I, i, m = E.x + "|" + E.y, T.x + "|" + T.y);
          if (i = this.IDATA.edgematch[I][2], (r = this.IDATA.edgematch[I][3]) && r === "A")
            for (O = 1; O < d; O++)
              T.x = O * t, T.y = O * e, S.x = u - (d - O) * (t + e), S.y = h + (d - O) * t, L(I, i, m = T.x + "|" + T.y, S.x + "|" + S.y);
          for (O = 0; O < this.vertices.length; O++)
            m = this.vertices[O].x + "|" + this.vertices[O].y, (p = I + "|" + m) in c || (c[p] = l++, C[m][0] > 2 ? R[c[p]] = [-C[m][0], C[m][1], c[p]] : R[c[p]] = [A[C[m][0]], C[m][1], c[p]]);
        }
        this.closestTo = R, this.vecToidx = c;
      }, n.prototype.calcCoeffs = function() {
        var t = this.m, e = this.n, i = Math.sqrt(3) / 3, r = t * t + e * e + t * e;
        this.coau = (t + e) / r, this.cobu = -e / r, this.coav = -i * (t - e) / r, this.cobv = i * (2 * t + e) / r;
      }, n.prototype.createInnerFacets = function() {
        for (var t = this.m, e = this.n, i = 0; i < e + t + 1; i++)
          for (var r = this.min[i]; r < this.max[i] + 1; r++)
            r < this.max[i] && r < this.max[i + 1] + 1 && this.innerFacets.push(["|" + r + "|" + i, "|" + r + "|" + (i + 1), "|" + (r + 1) + "|" + i]), i > 0 && r < this.max[i - 1] && r + 1 < this.max[i] + 1 && this.innerFacets.push(["|" + r + "|" + i, "|" + (r + 1) + "|" + i, "|" + (r + 1) + "|" + (i - 1)]);
      }, n.prototype.edgeVecsABOB = function() {
        for (var t = this.m, e = this.n, i = new Li(-e, t + e), r = 1; r < t + e; r++) {
          var o = new Li(this.min[r], r), a = new Li(this.min[r - 1], r - 1), s = new Li(this.min[r + 1], r + 1), l = o.clone(), c = a.clone(), u = s.clone();
          l.rotate60About(i), c.rotate60About(i), u.rotate60About(i);
          var h = new Li(this.max[l.y], l.y), d = new Li(this.max[l.y - 1], l.y - 1), p = new Li(this.max[l.y - 1] - 1, l.y - 1);
          l.x === h.x && l.y === h.y || (l.x !== d.x ? (this.vertexTypes.push([1, 0, 0]), this.isoVecsABOB.push([o, d, p]), this.vertexTypes.push([1, 0, 0]), this.isoVecsABOB.push([o, p, h])) : l.y === u.y ? (this.vertexTypes.push([1, 1, 0]), this.isoVecsABOB.push([o, a, d]), this.vertexTypes.push([1, 0, 1]), this.isoVecsABOB.push([o, d, s])) : (this.vertexTypes.push([1, 1, 0]), this.isoVecsABOB.push([o, a, d]), this.vertexTypes.push([1, 0, 0]), this.isoVecsABOB.push([o, d, h])));
        }
      }, n.prototype.mapABOBtoOBOA = function() {
        for (var t = new Li(0, 0), e = 0; e < this.isoVecsABOB.length; e++) {
          for (var i = [], r = 0; r < 3; r++)
            t.x = this.isoVecsABOB[e][r].x, t.y = this.isoVecsABOB[e][r].y, this.vertexTypes[e][r] === 0 && t.rotateNeg120(this.m, this.n), i.push(t.clone());
          this.isoVecsOBOA.push(i);
        }
      }, n.prototype.mapABOBtoBAOA = function() {
        for (var t = new Li(0, 0), e = 0; e < this.isoVecsABOB.length; e++) {
          for (var i = [], r = 0; r < 3; r++)
            t.x = this.isoVecsABOB[e][r].x, t.y = this.isoVecsABOB[e][r].y, this.vertexTypes[e][r] === 1 && t.rotate120(this.m, this.n), i.push(t.clone());
          this.isoVecsBAOA.push(i);
        }
      }, n.prototype.MapToFace = function(t, e) {
        for (var i, r = this.IDATA.face[t], o = r[2], a = r[1], s = r[0], l = v.FromArray(this.IDATA.vertex[o]), c = v.FromArray(this.IDATA.vertex[a]), u = v.FromArray(this.IDATA.vertex[s]), h = c.subtract(l), d = u.subtract(l), p = h.scale(this.coau).add(d.scale(this.cobu)), f = h.scale(this.coav).add(d.scale(this.cobv)), m = [], g = F.Vector3[0], y = 0; y < this.cartesian.length; y++)
          g = p.scale(this.cartesian[y].x).add(f.scale(this.cartesian[y].y)).add(l), m[y] = [g.x, g.y, g.z], i = t + "|" + this.vertices[y].x + "|" + this.vertices[y].y, e.vertex[this.vecToidx[i]] = [g.x, g.y, g.z];
      }, n.prototype.build = function(t, e) {
        var i = [], r = Li.Zero(), o = new Li(t, e), a = new Li(-e, t + e);
        i.push(r, o, a);
        for (var s = e; s < t + 1; s++)
          for (var l = 0; l < t + 1 - s; l++)
            i.push(new Li(l, s));
        if (e > 0) {
          for (var c = ue.HCF(t, e), u = t / c, h = e / c, d = 1; d < c; d++)
            i.push(new Li(d * u, d * h)), i.push(new Li(-d * h, d * (u + h))), i.push(new Li(t - d * (u + h), e + d * u));
          for (var p = t / e, f = 1; f < e; f++)
            for (var m = 0; m < f * p; m++)
              i.push(new Li(m, f)), i.push(new Li(m, f).rotate120(t, e)), i.push(new Li(m, f).rotateNeg120(t, e));
        }
        i.sort(function(Y, ee) {
          return Y.x - ee.x;
        }), i.sort(function(Y, ee) {
          return Y.y - ee.y;
        });
        var g = new Array(t + e + 1), y = new Array(t + e + 1);
        for (d = 0; d < g.length; d++)
          g[d] = 1 / 0, y[d] = -1 / 0;
        var b = 0, T = 0, S = i.length;
        for (d = 0; d < S; d++)
          T = i[d].x, g[b = i[d].y] = Math.min(T, g[b]), y[b] = Math.max(T, y[b]);
        var E = function(Y, ee) {
          var J = Y.clone();
          return ee === "A" && J.rotateNeg120(t, e), ee === "B" && J.rotate120(t, e), J.x < 0 ? J.y : J.x + J.y;
        }, A = [], R = [], C = [], L = [], I = {}, O = [], w = -1, z = -1;
        for (d = 0; d < S; d++)
          A[d] = i[d].toCartesianOrigin(new Li(0, 0), 0.5), R[d] = E(i[d], "O"), C[d] = E(i[d], "A"), L[d] = E(i[d], "B"), R[d] === C[d] && C[d] === L[d] ? (w = 3, z = R[d]) : R[d] === C[d] ? (w = 4, z = R[d]) : C[d] === L[d] ? (w = 5, z = C[d]) : L[d] === R[d] && (w = 6, z = R[d]), R[d] < C[d] && R[d] < L[d] && (w = 2, z = R[d]), C[d] < R[d] && C[d] < L[d] && (w = 1, z = C[d]), L[d] < C[d] && L[d] < R[d] && (w = 0, z = L[d]), O.push([w, z, i[d].x, i[d].y]);
        O.sort(function(Y, ee) {
          return Y[2] - ee[2];
        }), O.sort(function(Y, ee) {
          return Y[3] - ee[3];
        }), O.sort(function(Y, ee) {
          return Y[1] - ee[1];
        }), O.sort(function(Y, ee) {
          return Y[0] - ee[0];
        });
        for (var V = 0; V < O.length; V++)
          I[O[V][2] + "|" + O[V][3]] = [O[V][0], O[V][1], V];
        return this.m = t, this.n = e, this.vertices = i, this.vertByDist = I, this.cartesian = A, this.min = g, this.max = y, this;
      }, n;
    }(), Ph = function(n, t, e, i) {
      this.name = n, this.category = t, this.vertex = e, this.face = i;
    }, Df = function(n) {
      function t() {
        return n !== null && n.apply(this, arguments) || this;
      }
      return D(t, n), t.prototype.innerToData = function(e, i) {
        for (var r = 0; r < i.innerFacets.length; r++)
          this.face.push(i.innerFacets[r].map(function(o) {
            return i.vecToidx[e + o];
          }));
      }, t.prototype.mapABOBtoDATA = function(e, i) {
        for (var r = i.IDATA.edgematch[e][0], o = 0; o < i.isoVecsABOB.length; o++) {
          for (var a = [], s = 0; s < 3; s++)
            i.vertexTypes[o][s] === 0 ? a.push(e + "|" + i.isoVecsABOB[o][s].x + "|" + i.isoVecsABOB[o][s].y) : a.push(r + "|" + i.isoVecsABOB[o][s].x + "|" + i.isoVecsABOB[o][s].y);
          this.face.push([i.vecToidx[a[0]], i.vecToidx[a[1]], i.vecToidx[a[2]]]);
        }
      }, t.prototype.mapOBOAtoDATA = function(e, i) {
        for (var r = i.IDATA.edgematch[e][0], o = 0; o < i.isoVecsOBOA.length; o++) {
          for (var a = [], s = 0; s < 3; s++)
            i.vertexTypes[o][s] === 1 ? a.push(e + "|" + i.isoVecsOBOA[o][s].x + "|" + i.isoVecsOBOA[o][s].y) : a.push(r + "|" + i.isoVecsOBOA[o][s].x + "|" + i.isoVecsOBOA[o][s].y);
          this.face.push([i.vecToidx[a[0]], i.vecToidx[a[1]], i.vecToidx[a[2]]]);
        }
      }, t.prototype.mapBAOAtoDATA = function(e, i) {
        for (var r = i.IDATA.edgematch[e][2], o = 0; o < i.isoVecsBAOA.length; o++) {
          for (var a = [], s = 0; s < 3; s++)
            i.vertexTypes[o][s] === 1 ? a.push(e + "|" + i.isoVecsBAOA[o][s].x + "|" + i.isoVecsBAOA[o][s].y) : a.push(r + "|" + i.isoVecsBAOA[o][s].x + "|" + i.isoVecsBAOA[o][s].y);
          this.face.push([i.vecToidx[a[0]], i.vecToidx[a[1]], i.vecToidx[a[2]]]);
        }
      }, t.prototype.orderData = function(e) {
        for (var i = [], r = 0; r < 13; r++)
          i[r] = [];
        var o = e.closestTo;
        for (r = 0; r < o.length; r++)
          o[r][0] > -1 ? o[r][1] > 0 && i[o[r][0]].push([r, o[r][1]]) : i[12].push([r, o[r][0]]);
        var a = [];
        for (r = 0; r < 12; r++)
          a[r] = r;
        var s = 12;
        for (r = 0; r < 12; r++) {
          i[r].sort(function(c, u) {
            return c[1] - u[1];
          });
          for (var l = 0; l < i[r].length; l++)
            a[i[r][l][0]] = s++;
        }
        for (l = 0; l < i[12].length; l++)
          a[i[12][l][0]] = s++;
        for (r = 0; r < this.vertex.length; r++)
          this.vertex[r].push(a[r]);
        for (this.vertex.sort(function(c, u) {
          return c[3] - u[3];
        }), r = 0; r < this.vertex.length; r++)
          this.vertex[r].pop();
        for (r = 0; r < this.face.length; r++)
          for (l = 0; l < this.face[r].length; l++)
            this.face[r][l] = a[this.face[r][l]];
        this.sharedNodes = i[12].length, this.poleNodes = this.vertex.length - this.sharedNodes;
      }, t.prototype.setOrder = function(e, i) {
        var r = [], o = [], a = i.pop();
        o.push(a);
        var s = this.face[a].indexOf(e);
        s = (s + 2) % 3;
        var l = this.face[a][s];
        r.push(l);
        for (var c = 0; i.length > 0; )
          a = i[c], this.face[a].indexOf(l) > -1 ? (s = (this.face[a].indexOf(l) + 1) % 3, l = this.face[a][s], r.push(l), o.push(a), i.splice(c, 1), c = 0) : c++;
        return this.adjacentFaces.push(r), o;
      }, t.prototype.toGoldbergPolyhedronData = function() {
        var e = this, i = new Ph("GeoDual", "Goldberg", [], []);
        i.name = "GD dual";
        for (var r = this.vertex.length, o = new Array(r), a = 0; a < r; a++)
          o[a] = [];
        for (var s = 0; s < this.face.length; s++)
          for (var l = 0; l < 3; l++)
            o[this.face[s][l]].push(s);
        var c = 0, u = 0, h = 0, d = [], p = [];
        this.adjacentFaces = [];
        for (var f = 0; f < o.length; f++)
          i.face[f] = this.setOrder(f, o[f].concat([])), o[f].forEach(function(m) {
            c = 0, u = 0, h = 0, d = e.face[m];
            for (var g = 0; g < 3; g++)
              p = e.vertex[d[g]], c += p[0], u += p[1], h += p[2];
            i.vertex[m] = [c / 3, u / 3, h / 3];
          });
        return i;
      }, t.BuildGeodesicData = function(e) {
        var i = new t("Geodesic-m-n", "Geodesic", [[0, gt, -1], [-gt, 1, 0], [-1, 0, -gt], [1, 0, -gt], [gt, 1, 0], [0, gt, 1], [-1, 0, gt], [-gt, -1, 0], [0, -gt, -1], [gt, -1, 0], [1, 0, gt], [0, -gt, 1]], []);
        e.setIndices(), e.calcCoeffs(), e.createInnerFacets(), e.edgeVecsABOB(), e.mapABOBtoOBOA(), e.mapABOBtoBAOA();
        for (var r = 0; r < e.IDATA.face.length; r++)
          e.MapToFace(r, i), i.innerToData(r, e), e.IDATA.edgematch[r][1] === "B" && i.mapABOBtoDATA(r, e), e.IDATA.edgematch[r][1] === "O" && i.mapOBOAtoDATA(r, e), e.IDATA.edgematch[r][3] === "A" && i.mapBAOAtoDATA(r, e);
        return i.orderData(e), i.vertex = i.vertex.map(function(o) {
          var a = o[0], s = o[1], l = o[2], c = Math.sqrt(a * a + s * s + l * l);
          return o[0] *= 1 / c, o[1] *= 1 / c, o[2] *= 1 / c, o;
        }), i;
      }, t;
    }(Ph);
    function Fv(n, t, e) {
      e === void 0 && (e = null);
      var i = t.m || 1;
      i !== Math.floor(i) && q.Warn("m not an integer only floor(m) used");
      var r = t.n || 0;
      if (r !== Math.floor(r) && q.Warn("n not an integer only floor(n) used"), r > i) {
        var o = r;
        r = i, i = o, q.Warn("n > m therefore m and n swapped");
      }
      var a = new Of();
      return a.build(i, r), xs(n, { custom: Df.BuildGeodesicData(a), size: t.size, sizeX: t.sizeX, sizeY: t.sizeY, sizeZ: t.sizeZ, faceUV: t.faceUV, faceColors: t.faceColors, flat: t.flat, updatable: t.updatable, sideOrientation: t.sideOrientation, frontUVs: t.frontUVs, backUVs: t.backUVs }, e);
    }
    ie._GoldbergMeshParser = function(n, t) {
      return Nf.Parse(n, t);
    };
    var Nf = function(n) {
      function t() {
        var e = n !== null && n.apply(this, arguments) || this;
        return e.goldbergData = { faceColors: [], faceCenters: [], faceZaxis: [], faceXaxis: [], faceYaxis: [], nbSharedFaces: 0, nbUnsharedFaces: 0, nbFaces: 0, nbFacesAtPole: 0, adjacentFaces: [] }, e;
      }
      return D(t, n), t.prototype.relatedGoldbergFace = function(e, i) {
        return i === void 0 ? (e > this.goldbergData.nbUnsharedFaces - 1 && (q.Warn("Maximum number of unshared faces used"), e = this.goldbergData.nbUnsharedFaces - 1), this.goldbergData.nbUnsharedFaces + e) : (e > 11 && (q.Warn("Last pole used"), e = 11), i > this.goldbergData.nbFacesAtPole - 1 && (q.Warn("Maximum number of faces at a pole used"), i = this.goldbergData.nbFacesAtPole - 1), 12 + e * this.goldbergData.nbFacesAtPole + i);
      }, t.prototype._changeGoldbergFaceColors = function(e) {
        for (var i = 0; i < e.length; i++)
          for (var r = e[i][0], o = e[i][1], a = e[i][2], s = r; s < o + 1; s++)
            this.goldbergData.faceColors[s] = a;
        var l = [];
        for (s = 0; s < 12; s++)
          for (i = 0; i < 5; i++)
            l.push(this.goldbergData.faceColors[s].r, this.goldbergData.faceColors[s].g, this.goldbergData.faceColors[s].b, this.goldbergData.faceColors[s].a);
        for (s = 12; s < this.goldbergData.faceColors.length; s++)
          for (i = 0; i < 6; i++)
            l.push(this.goldbergData.faceColors[s].r, this.goldbergData.faceColors[s].g, this.goldbergData.faceColors[s].b, this.goldbergData.faceColors[s].a);
        return l;
      }, t.prototype.setGoldbergFaceColors = function(e) {
        var i = this._changeGoldbergFaceColors(e);
        this.setVerticesData(P.ColorKind, i);
      }, t.prototype.updateGoldbergFaceColors = function(e) {
        var i = this._changeGoldbergFaceColors(e);
        this.updateVerticesData(P.ColorKind, i);
      }, t.prototype._changeGoldbergFaceUVs = function(e) {
        for (var i = this.getVerticesData(P.UVKind), r = 0; r < e.length; r++) {
          for (var o = e[r][0], a = e[r][1], s = e[r][2], l = e[r][3], c = e[r][4], u = [], h = [], d = void 0, p = void 0, f = 0; f < 5; f++)
            d = s.x + l * Math.cos(c + f * Math.PI / 2.5), p = s.y + l * Math.sin(c + f * Math.PI / 2.5), d < 0 && (d = 0), d > 1 && (d = 1), u.push(d, p);
          for (f = 0; f < 6; f++)
            d = s.x + l * Math.cos(c + f * Math.PI / 3), p = s.y + l * Math.sin(c + f * Math.PI / 3), d < 0 && (d = 0), d > 1 && (d = 1), h.push(d, p);
          for (var m = o; m < Math.min(12, a + 1); m++)
            for (f = 0; f < 5; f++)
              i[10 * m + 2 * f] = u[2 * f], i[10 * m + 2 * f + 1] = u[2 * f + 1];
          for (m = Math.max(12, o); m < a + 1; m++)
            for (f = 0; f < 6; f++)
              i[12 * m - 24 + 2 * f] = h[2 * f], i[12 * m - 23 + 2 * f] = h[2 * f + 1];
        }
        return i;
      }, t.prototype.setGoldbergFaceUVs = function(e) {
        var i = this._changeGoldbergFaceUVs(e);
        this.setVerticesData(P.UVKind, i);
      }, t.prototype.updateGoldbergFaceUVs = function(e) {
        var i = this._changeGoldbergFaceUVs(e);
        this.updateVerticesData(P.UVKind, i);
      }, t.prototype.placeOnGoldbergFaceAt = function(e, i, r) {
        var o = v.RotationFromAxis(this.goldbergData.faceXaxis[i], this.goldbergData.faceYaxis[i], this.goldbergData.faceZaxis[i]);
        e.rotation = o, e.position = this.goldbergData.faceCenters[i].add(this.goldbergData.faceXaxis[i].scale(r.x)).add(this.goldbergData.faceYaxis[i].scale(r.y)).add(this.goldbergData.faceZaxis[i].scale(r.z));
      }, t.prototype.serialize = function(e) {
        n.prototype.serialize.call(this, e), e.type = "GoldbergMesh";
        var i = {};
        if (i.adjacentFaces = this.goldbergData.adjacentFaces, i.nbSharedFaces = this.goldbergData.nbSharedFaces, i.nbUnsharedFaces = this.goldbergData.nbUnsharedFaces, i.nbFaces = this.goldbergData.nbFaces, i.nbFacesAtPole = this.goldbergData.nbFacesAtPole, this.goldbergData.faceColors) {
          i.faceColors = [];
          for (var r = 0, o = this.goldbergData.faceColors; r < o.length; r++) {
            var a = o[r];
            i.faceColors.push(a.asArray());
          }
        }
        if (this.goldbergData.faceCenters) {
          i.faceCenters = [];
          for (var s = 0, l = this.goldbergData.faceCenters; s < l.length; s++) {
            var c = l[s];
            i.faceCenters.push(c.asArray());
          }
        }
        if (this.goldbergData.faceZaxis) {
          i.faceZaxis = [];
          for (var u = 0, h = this.goldbergData.faceZaxis; u < h.length; u++)
            c = h[u], i.faceZaxis.push(c.asArray());
        }
        if (this.goldbergData.faceYaxis) {
          i.faceYaxis = [];
          for (var d = 0, p = this.goldbergData.faceYaxis; d < p.length; d++)
            c = p[d], i.faceYaxis.push(c.asArray());
        }
        if (this.goldbergData.faceXaxis) {
          i.faceXaxis = [];
          for (var f = 0, m = this.goldbergData.faceXaxis; f < m.length; f++)
            c = m[f], i.faceXaxis.push(c.asArray());
        }
        e.goldbergData = i;
      }, t.Parse = function(e, i) {
        var r = e.goldbergData;
        r.faceColors = r.faceColors.map(function(a) {
          return Ie.FromArray(a);
        }), r.faceCenters = r.faceCenters.map(function(a) {
          return v.FromArray(a);
        }), r.faceZaxis = r.faceZaxis.map(function(a) {
          return v.FromArray(a);
        }), r.faceXaxis = r.faceXaxis.map(function(a) {
          return v.FromArray(a);
        }), r.faceYaxis = r.faceYaxis.map(function(a) {
          return v.FromArray(a);
        });
        var o = new t(e.name, i);
        return o.goldbergData = r, o;
      }, t;
    }(ie);
    function Lv(n, t) {
      for (var e = n.size, i = n.sizeX || e || 1, r = n.sizeY || e || 1, o = n.sizeZ || e || 1, a = n.sideOrientation === 0 ? 0 : n.sideOrientation || Oe.DEFAULTSIDE, s = [], l = [], c = [], u = [], h = 1 / 0, d = -1 / 0, p = 1 / 0, f = -1 / 0, m = 0; m < t.vertex.length; m++)
        h = Math.min(h, t.vertex[m][0] * i), d = Math.max(d, t.vertex[m][0] * i), p = Math.min(p, t.vertex[m][1] * r), f = Math.max(f, t.vertex[m][1] * r);
      for (var g = 0, y = 0; y < t.face.length; y++) {
        var b = t.face[y], T = v.FromArray(t.vertex[b[0]]), S = v.FromArray(t.vertex[b[2]]), E = v.FromArray(t.vertex[b[1]]), A = S.subtract(T), R = E.subtract(T), C = v.Cross(R, A).normalize();
        for (m = 0; m < b.length; m++) {
          c.push(C.x, C.y, C.z);
          var L = t.vertex[b[m]];
          s.push(L[0] * i, L[1] * r, L[2] * o);
          var I = (L[1] * r - p) / (f - p);
          u.push((L[0] * i - h) / (d - h), Lt.UseOpenGLOrientationForUV ? 1 - I : I);
        }
        for (m = 0; m < b.length - 2; m++)
          l.push(g, g + m + 2, g + m + 1);
        g += b.length;
      }
      Oe._ComputeSides(a, s, l, c, u);
      var O = new Oe();
      return O.positions = s, O.indices = l, O.normals = c, O.uvs = u, O;
    }
    function wv(n, t, e) {
      e === void 0 && (e = null);
      var i = t.size, r = t.sizeX || i || 1, o = t.sizeY || i || 1, a = t.sizeZ || i || 1, s = t.m || 1;
      s !== Math.floor(s) && q.Warn("m not an integer only floor(m) used");
      var l = t.n || 0;
      if (l !== Math.floor(l) && q.Warn("n not an integer only floor(n) used"), l > s) {
        var c = l;
        l = s, s = c, q.Warn("n > m therefore m and n swapped");
      }
      var u = new Of();
      u.build(s, l);
      var h = Df.BuildGeodesicData(u), d = h.toGoldbergPolyhedronData(), p = new Nf(n, e);
      t.sideOrientation = ie._GetDefaultSideOrientation(t.sideOrientation), p._originalBuilderSideOrientation = t.sideOrientation, Lv(t, d).applyToMesh(p, t.updatable), p.goldbergData.nbSharedFaces = h.sharedNodes, p.goldbergData.nbUnsharedFaces = h.poleNodes, p.goldbergData.adjacentFaces = h.adjacentFaces, p.goldbergData.nbFaces = p.goldbergData.nbSharedFaces + p.goldbergData.nbUnsharedFaces, p.goldbergData.nbFacesAtPole = (p.goldbergData.nbUnsharedFaces - 12) / 12;
      for (var f = 0; f < h.vertex.length; f++)
        p.goldbergData.faceCenters.push(v.FromArray(h.vertex[f])), p.goldbergData.faceCenters[f].x *= r, p.goldbergData.faceCenters[f].y *= o, p.goldbergData.faceCenters[f].z *= a, p.goldbergData.faceColors.push(new Ie(1, 1, 1, 1));
      for (f = 0; f < d.face.length; f++) {
        var m = d.face[f], g = v.FromArray(d.vertex[m[0]]), y = v.FromArray(d.vertex[m[2]]), b = v.FromArray(d.vertex[m[1]]), T = y.subtract(g), S = b.subtract(g), E = v.Cross(S, T).normalize(), A = v.Cross(S, E).normalize();
        p.goldbergData.faceXaxis.push(S.normalize()), p.goldbergData.faceYaxis.push(E), p.goldbergData.faceZaxis.push(A);
      }
      return p;
    }
    var eD = function() {
      function n(t) {
        this._paths = [], this._tempPaths = [], this._holes = [], this._resolution = t;
      }
      return n.prototype.moveTo = function(t, e) {
        this._currentPath = new Hu(t, e), this._tempPaths.push(this._currentPath);
      }, n.prototype.lineTo = function(t, e) {
        this._currentPath.addLineTo(t, e);
      }, n.prototype.quadraticCurveTo = function(t, e, i, r) {
        this._currentPath.addQuadraticCurveTo(t, e, i, r, this._resolution);
      }, n.prototype.bezierCurveTo = function(t, e, i, r, o, a) {
        this._currentPath.addBezierCurveTo(t, e, i, r, o, a, this._resolution);
      }, n.prototype.extractHoles = function() {
        for (var t = 0, e = this._tempPaths; t < e.length; t++) {
          var i = e[t];
          i.area() > 0 ? this._holes.push(i) : this._paths.push(i);
        }
        if (!this._paths.length && this._holes.length) {
          var r = this._holes;
          this._holes = this._paths, this._paths = r;
        }
        this._tempPaths.length = 0;
      }, Object.defineProperty(n.prototype, "paths", { get: function() {
        return this._paths;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "holes", { get: function() {
        return this._holes;
      }, enumerable: !1, configurable: !0 }), n;
    }();
    function tD(n, t, e, i, r, o) {
      var a = o.glyphs[n] || o.glyphs["?"];
      if (!a)
        return null;
      var s = new eD(r);
      if (a.o)
        for (var l = a.o.split(" "), c = 0, u = l.length; c < u; )
          switch (l[c++]) {
            case "m":
              var h = parseInt(l[c++]) * t + e, d = parseInt(l[c++]) * t + i;
              s.moveTo(h, d);
              break;
            case "l":
              h = parseInt(l[c++]) * t + e, d = parseInt(l[c++]) * t + i, s.lineTo(h, d);
              break;
            case "q":
              var p = parseInt(l[c++]) * t + e, f = parseInt(l[c++]) * t + i, m = parseInt(l[c++]) * t + e, g = parseInt(l[c++]) * t + i;
              s.quadraticCurveTo(m, g, p, f);
              break;
            case "b":
              p = parseInt(l[c++]) * t + e, f = parseInt(l[c++]) * t + i, m = parseInt(l[c++]) * t + e, g = parseInt(l[c++]) * t + i;
              var y = parseInt(l[c++]) * t + e, b = parseInt(l[c++]) * t + i;
              s.bezierCurveTo(m, g, y, b, p, f);
          }
      return s.extractHoles(), { offsetX: a.ha * t, shapePath: s };
    }
    function Ff(n, t, e, i) {
      for (var r = Array.from(n), o = t / i.resolution, a = (i.boundingBox.yMax - i.boundingBox.yMin + i.underlineThickness) * o, s = [], l = 0, c = 0, u = 0; u < r.length; u++) {
        var h = r[u];
        if (h === `
`)
          l = 0, c -= a;
        else {
          var d = tD(h, o, l, c, e, i);
          d && (l += d.offsetX, s.push(d.shapePath));
        }
      }
      return s;
    }
    function Bv(n, t, e, i, r, o) {
      var a, s;
      i === void 0 && (i = { size: 50, resolution: 8, depth: 1 }), r === void 0 && (r = null), o === void 0 && (o = earcut);
      for (var l = [], c = 0, u = 0, h = Ff(t, i.size || 50, i.resolution || 8, e); u < h.length; u++) {
        var d = h[u];
        if (d.paths.length)
          for (var p = d.holes.slice(), f = 0, m = d.paths; f < m.length; f++) {
            for (var g = m[f], y = [], b = [], T = 0, S = g.getPoints(); T < S.length; T++) {
              var E = S[T];
              b.push(new v(E.x, 0, E.y));
            }
            for (var A = 0, R = p.slice(); A < R.length; A++) {
              for (var C = (J = R[A]).getPoints(), L = !1, I = 0, O = C; I < O.length; I++)
                if (E = O[I], g.isPointInside(E)) {
                  L = !0;
                  break;
                }
              if (L) {
                for (var w = [], z = 0, V = C; z < V.length; z++)
                  E = V[z], w.push(new v(E.x, 0, E.y));
                y.push(w), p.splice(p.indexOf(J), 1);
              }
            }
            if (!y.length && p.length)
              for (var Y = 0, ee = p; Y < ee.length; Y++) {
                w = [];
                for (var J, X = 0, K = (J = ee[Y]).getPoints(); X < K.length; X++)
                  E = K[X], w.push(new v(E.x, 0, E.y));
                y.push(w);
              }
            var te = Oc(n, { shape: b, holes: y.length ? y : void 0, depth: i.depth || 1, faceUV: i.faceUV || ((a = i.perLetterFaceUV) === null || a === void 0 ? void 0 : a.call(i, c)), faceColors: i.faceColors || ((s = i.perLetterFaceColors) === null || s === void 0 ? void 0 : s.call(i, c)), sideOrientation: ie._GetDefaultSideOrientation(i.sideOrientation || ie.DOUBLESIDE) }, r, o);
            l.push(te), c++;
          }
      }
      var se = ie.MergeMeshes(l, !0, !0);
      if (se) {
        var _e = se.getBoundingInfo().boundingBox;
        se.position.x += -(_e.minimumWorld.x + _e.maximumWorld.x) / 2, se.position.y += -(_e.minimumWorld.y + _e.maximumWorld.y) / 2, se.position.z += -(_e.minimumWorld.z + _e.maximumWorld.z) / 2 + _e.extendSize.z, se.name = n;
        var xe = new ai("pivot", r);
        xe.rotation.x = -Math.PI / 2, se.parent = xe, se.bakeCurrentTransformIntoVertices(), se.parent = null, xe.dispose();
      }
      return se;
    }
    var Uv = { CreateBox: Ur, CreateTiledBox: xf, CreateSphere: yn, CreateDisc: bl, CreateIcoSphere: vc, CreateRibbon: pa, CreateCylinder: Fn, CreateTorus: eo, CreateTorusKnot: Sh, CreateLineSystem: Ss, CreateLines: si, CreateDashedLines: xh, ExtrudeShape: Dc, ExtrudeShapeCustom: Nc, CreateLathe: Ah, CreateTiledPlane: Ef, CreatePlane: Ro, CreateGround: vl, CreateTiledGround: fh, CreateGroundFromHeightMap: _h, CreatePolygon: Mc, ExtrudePolygon: Oc, CreateTube: Rh, CreatePolyhedron: xs, CreateGeodesic: Fv, CreateGoldberg: wv, CreateDecal: Ch, CreateCapsule: Ic, CreateText: Bv }, Lf = function() {
      function n(t) {
        if (this._impostors = [], this._meshes = [], this._bodies = [], this._inertiaBodies = [], this._constraints = [], this._bodyMeshes = [], this._inertiaMeshes = [], this._constraintMeshes = [], this._numMeshes = 0, this._numBodies = 0, this._numInertiaBodies = 0, this._numConstraints = 0, this._debugMeshMeshes = new Array(), this._constraintAxesSize = 0.4, this._scene = t || Me.LastCreatedScene, this._scene) {
          var e = this._scene.getPhysicsEngine();
          e && (this._physicsEnginePlugin = e.getPhysicsPlugin()), this._utilityLayer = new Fi(this._scene, !1), this._utilityLayer.pickUtilitySceneFirst = !1, this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = !0;
        }
      }
      return n.prototype._updateDebugMeshes = function() {
        var t = this._physicsEnginePlugin;
        (t == null ? void 0 : t.getPluginVersion()) === 1 ? this._updateDebugMeshesV1() : this._updateDebugMeshesV2();
      }, n.prototype._updateDebugMeshesV1 = function() {
        for (var t = this._physicsEnginePlugin, e = 0; e < this._numMeshes; e++) {
          var i = this._impostors[e];
          if (i)
            if (i.isDisposed)
              this.hideImpostor(this._impostors[e--]);
            else {
              if (i.type === bt.MeshImpostor)
                continue;
              var r = this._meshes[e];
              r && t && t.syncMeshWithImpostor(r, i);
            }
        }
      }, n.prototype._updateDebugMeshesV2 = function() {
        for (var t = this._physicsEnginePlugin, e = 0; e < this._numBodies; e++) {
          var i = this._bodies[e], r = this._bodyMeshes[e];
          i && r && t.syncTransform(i, r);
        }
      }, n.prototype._updateInertiaMeshes = function() {
        for (var t = 0; t < this._numInertiaBodies; t++) {
          var e = this._inertiaBodies[t], i = this._inertiaMeshes[t];
          e && i && this._updateDebugInertia(e, i);
        }
      }, n.prototype._updateDebugInertia = function(t, e) {
        var i, r = B.Identity(), o = B.Identity(), a = B.Identity();
        if (t._pluginDataInstances.length) {
          for (var s = e, l = s._thinInstanceDataStorage.matrixData, c = t.transformNode._thinInstanceDataStorage.matrixData, u = 0; u < t._pluginDataInstances.length; u++) {
            var h = t.getMassProperties(u);
            this._getMeshDebugInertiaMatrixToRef(h, r), B.FromArrayToRef(c, 16 * u, o), r.multiplyToRef(o, a), a.copyToArray(l, 16 * u);
          }
          s.thinInstanceBufferUpdated("matrix");
        } else {
          if (h = t.getMassProperties(), this._getMeshDebugInertiaMatrixToRef(h, r), (i = t.transformNode.rotationQuaternion) === null || i === void 0 || i.toRotationMatrix(o), o.setTranslation(t.transformNode.position), t.transformNode.parent) {
            var d = t.transformNode.parent.computeWorldMatrix(!0);
            o.multiplyToRef(d, o);
          }
          r.multiplyToRef(o, r), r.decomposeToTransformNode(e);
        }
      }, n.prototype._updateDebugConstraints = function() {
        for (var t = 0; t < this._numConstraints; t++) {
          var e = this._constraints[t], i = this._constraintMeshes[t];
          e && i && this._updateDebugConstraint(e, i);
        }
      }, n.prototype._makeScalingUnitInPlace = function(t) {
        Math.abs(t.x - 1) > Ge && (t.x = 1 * Math.sign(t.x)), Math.abs(t.y - 1) > Ge && (t.y = 1 * Math.sign(t.y)), Math.abs(t.z - 1) > Ge && (t.z = 1 * Math.sign(t.z));
      }, n.prototype._updateDebugConstraint = function(t, e) {
        var i = this;
        if (t._initOptions) {
          var r = t._initOptions, o = r.pivotA, a = r.pivotB, s = r.axisA, l = r.axisB, c = r.perpAxisA, u = r.perpAxisB;
          o && a && s && l && c && u && e.getDescendants(!0).forEach(function(h) {
            var d = h.getDescendants(!0)[0], p = h.getDescendants(!0)[1], f = d.metadata, m = f.parentBody, g = f.parentBodyIndex, y = p.metadata, b = y.childBody, T = y.childBodyIndex, S = i._getTransformFromBodyToRef(m, F.Matrix[0], g), E = i._getTransformFromBodyToRef(b, F.Matrix[1], T);
            S.decomposeToTransformNode(d), i._makeScalingUnitInPlace(d.scaling), E.decomposeToTransformNode(p), i._makeScalingUnitInPlace(p.scaling);
            var A = d.getDescendants(!0)[0];
            A.position.copyFrom(o);
            var R = p.getDescendants(!0)[0];
            R.position.copyFrom(a), oe.FromRotationMatrixToRef(B.FromXYZAxesToRef(s, c, v.CrossToRef(s, c, F.Vector3[0]), F.Matrix[0]), A.rotationQuaternion), oe.FromRotationMatrixToRef(B.FromXYZAxesToRef(l, u, v.CrossToRef(l, u, F.Vector3[1]), F.Matrix[1]), R.rotationQuaternion);
          });
        }
      }, n.prototype.showImpostor = function(t, e) {
        var i = this;
        if (!this._scene)
          return null;
        for (var r = 0; r < this._numMeshes; r++)
          if (this._impostors[r] == t)
            return null;
        var o = this._getDebugMesh(t, e);
        return o && (this._impostors[this._numMeshes] = t, this._meshes[this._numMeshes] = o, this._numMeshes === 0 && (this._renderFunction = function() {
          return i._updateDebugMeshes();
        }, this._scene.registerBeforeRender(this._renderFunction)), this._numMeshes++), o;
      }, n.prototype.showBody = function(t) {
        var e = this;
        if (!this._scene)
          return null;
        for (var i = 0; i < this._numBodies; i++)
          if (this._bodies[i] == t)
            return null;
        var r = this._getDebugBodyMesh(t);
        return r && (this._bodies[this._numBodies] = t, this._bodyMeshes[this._numBodies] = r, this._numBodies === 0 && (this._renderFunction = function() {
          return e._updateDebugMeshes();
        }, this._scene.registerBeforeRender(this._renderFunction)), this._numBodies++), r;
      }, n.prototype.showInertia = function(t) {
        var e = this;
        if (!this._scene)
          return null;
        for (var i = 0; i < this._numInertiaBodies; i++)
          if (this._inertiaBodies[i] == t)
            return null;
        var r = this._getDebugInertiaMesh(t);
        return r && (this._inertiaBodies[this._numInertiaBodies] = t, this._inertiaMeshes[this._numInertiaBodies] = r, this._numInertiaBodies === 0 && (this._inertiaRenderFunction = function() {
          return e._updateInertiaMeshes();
        }, this._scene.registerBeforeRender(this._inertiaRenderFunction)), this._numInertiaBodies++), r;
      }, n.prototype.showConstraint = function(t) {
        var e = this;
        if (!this._scene)
          return null;
        for (var i = 0; i < this._numConstraints; i++)
          if (this._constraints[i] == t)
            return null;
        var r = this._getDebugConstraintMesh(t);
        return r && (this._constraints[this._numConstraints] = t, this._constraintMeshes[this._numConstraints] = r, this._numConstraints === 0 && (this._constraintRenderFunction = function() {
          return e._updateDebugConstraints();
        }, this._scene.registerBeforeRender(this._constraintRenderFunction)), this._numConstraints++), r;
      }, n.prototype.hideImpostor = function(t) {
        if (t && this._scene && this._utilityLayer) {
          for (var e = !1, i = this._utilityLayer.utilityLayerScene, r = 0; r < this._numMeshes; r++)
            if (this._impostors[r] == t) {
              var o = this._meshes[r];
              if (!o)
                continue;
              i.removeMesh(o), o.dispose();
              var a = this._debugMeshMeshes.indexOf(o);
              a > -1 && this._debugMeshMeshes.splice(a, 1), this._numMeshes--, this._numMeshes > 0 ? (this._meshes[r] = this._meshes[this._numMeshes], this._impostors[r] = this._impostors[this._numMeshes], this._meshes[this._numMeshes] = null, this._impostors[this._numMeshes] = null) : (this._meshes[0] = null, this._impostors[0] = null), e = !0;
              break;
            }
          e && this._numMeshes === 0 && this._scene.unregisterBeforeRender(this._renderFunction);
        }
      }, n.prototype.hideBody = function(t) {
        if (t && this._scene && this._utilityLayer) {
          for (var e = !1, i = this._utilityLayer.utilityLayerScene, r = 0; r < this._numBodies; r++)
            if (this._bodies[r] === t) {
              var o = this._bodyMeshes[r];
              if (!o)
                continue;
              i.removeMesh(o), o.dispose(), this._numBodies--, this._numBodies > 0 ? (this._bodyMeshes[r] = this._bodyMeshes[this._numBodies], this._bodies[r] = this._bodies[this._numBodies], this._bodyMeshes[this._numBodies] = null, this._bodies[this._numBodies] = null) : (this._bodyMeshes[0] = null, this._bodies[0] = null), e = !0;
              break;
            }
          e && this._numBodies === 0 && this._scene.unregisterBeforeRender(this._renderFunction);
        }
      }, n.prototype.hideInertia = function(t) {
        if (t && this._scene && this._utilityLayer) {
          for (var e = !1, i = this._utilityLayer.utilityLayerScene, r = 0; r < this._numInertiaBodies; r++)
            if (this._inertiaBodies[r] === t) {
              var o = this._inertiaMeshes[r];
              if (!o)
                continue;
              i.removeMesh(o), o.dispose(), this._inertiaBodies.splice(r, 1), this._inertiaMeshes.splice(r, 1), this._numInertiaBodies--, e = !0;
              break;
            }
          e && this._numInertiaBodies === 0 && this._scene.unregisterBeforeRender(this._inertiaRenderFunction);
        }
      }, n.prototype.hideConstraint = function(t) {
        if (t && this._scene && this._utilityLayer) {
          for (var e = !1, i = this._utilityLayer.utilityLayerScene, r = 0; r < this._numConstraints; r++)
            if (this._constraints[r] === t) {
              var o = this._constraintMeshes[r];
              if (!o)
                continue;
              i.removeMesh(o), o.dispose(), this._constraints.splice(r, 1), this._constraintMeshes.splice(r, 1), this._numConstraints--, this._numConstraints > 0 ? (this._constraints[r] = this._constraints[this._numConstraints], this._constraintMeshes[r] = this._constraintMeshes[this._numConstraints], this._constraints[this._numConstraints] = null, this._constraintMeshes[this._numConstraints] = null) : (this._constraints[0] = null, this._constraintMeshes[0] = null), e = !0;
              break;
            }
          e && this._numConstraints === 0 && this._scene.unregisterBeforeRender(this._constraintRenderFunction);
        }
      }, n.prototype._getDebugMaterial = function(t) {
        return this._debugMaterial || (this._debugMaterial = new Gt("", t), this._debugMaterial.wireframe = !0, this._debugMaterial.emissiveColor = ne.White(), this._debugMaterial.disableLighting = !0), this._debugMaterial;
      }, n.prototype._getDebugInertiaMaterial = function(t) {
        return this._debugInertiaMaterial || (this._debugInertiaMaterial = new Gt("", t), this._debugInertiaMaterial.disableLighting = !0, this._debugInertiaMaterial.alpha = 0), this._debugInertiaMaterial;
      }, n.prototype._getDebugBoxMesh = function(t) {
        return this._debugBoxMesh || (this._debugBoxMesh = Ur("physicsBodyBoxViewMesh", { size: 1 }, t), this._debugBoxMesh.rotationQuaternion = oe.Identity(), this._debugBoxMesh.material = this._getDebugMaterial(t), this._debugBoxMesh.setEnabled(!1)), this._debugBoxMesh.createInstance("physicsBodyBoxViewInstance");
      }, n.prototype._getDebugSphereMesh = function(t) {
        return this._debugSphereMesh || (this._debugSphereMesh = yn("physicsBodySphereViewMesh", { diameter: 1 }, t), this._debugSphereMesh.rotationQuaternion = oe.Identity(), this._debugSphereMesh.material = this._getDebugMaterial(t), this._debugSphereMesh.setEnabled(!1)), this._debugSphereMesh.createInstance("physicsBodySphereViewInstance");
      }, n.prototype._getDebugCapsuleMesh = function(t) {
        return this._debugCapsuleMesh || (this._debugCapsuleMesh = Ic("physicsBodyCapsuleViewMesh", { height: 1 }, t), this._debugCapsuleMesh.rotationQuaternion = oe.Identity(), this._debugCapsuleMesh.material = this._getDebugMaterial(t), this._debugCapsuleMesh.setEnabled(!1)), this._debugCapsuleMesh.createInstance("physicsBodyCapsuleViewInstance");
      }, n.prototype._getDebugCylinderMesh = function(t) {
        return this._debugCylinderMesh || (this._debugCylinderMesh = Fn("physicsBodyCylinderViewMesh", { diameterTop: 1, diameterBottom: 1, height: 1 }, t), this._debugCylinderMesh.rotationQuaternion = oe.Identity(), this._debugCylinderMesh.material = this._getDebugMaterial(t), this._debugCylinderMesh.setEnabled(!1)), this._debugCylinderMesh.createInstance("physicsBodyCylinderViewInstance");
      }, n.prototype._getDebugMeshMesh = function(t, e) {
        var i = new ie(t.name, e, null, t);
        return i.setParent(t), i.position = v.Zero(), i.material = this._getDebugMaterial(e), this._debugMeshMeshes.push(i), i;
      }, n.prototype._getDebugMesh = function(t, e) {
        var i = this;
        if (!this._utilityLayer || e && e.parent && e.parent.physicsImpostor)
          return null;
        var r = null, o = this._utilityLayer.utilityLayerScene;
        if (!t.physicsBody)
          return q.Warn("Unable to get physicsBody of impostor. It might be initialized later by its parent's impostor."), null;
        switch (t.type) {
          case bt.BoxImpostor:
            r = this._getDebugBoxMesh(o), t.getBoxSizeToRef(r.scaling);
            break;
          case bt.SphereImpostor:
            r = this._getDebugSphereMesh(o);
            var a = t.getRadius();
            r.scaling.x = 2 * a, r.scaling.y = 2 * a, r.scaling.z = 2 * a;
            break;
          case bt.CapsuleImpostor:
            r = this._getDebugCapsuleMesh(o);
            var s = t.object.getBoundingInfo();
            r.scaling.x = 2 * (s.boundingBox.maximum.x - s.boundingBox.minimum.x) * t.object.scaling.x, r.scaling.y = (s.boundingBox.maximum.y - s.boundingBox.minimum.y) * t.object.scaling.y, r.scaling.z = 2 * (s.boundingBox.maximum.z - s.boundingBox.minimum.z) * t.object.scaling.z;
            break;
          case bt.MeshImpostor:
            e && (r = this._getDebugMeshMesh(e, o));
            break;
          case bt.NoImpostor:
            e ? e.getChildMeshes().filter(function(l) {
              return l.physicsImpostor ? 1 : 0;
            }).forEach(function(l) {
              if (l.physicsImpostor && l.getClassName() === "Mesh") {
                var c = l.getBoundingInfo(), u = c.boundingBox.minimum, h = c.boundingBox.maximum;
                switch (l.physicsImpostor.type) {
                  case bt.BoxImpostor:
                    (r = i._getDebugBoxMesh(o)).position.copyFrom(u), r.position.addInPlace(h), r.position.scaleInPlace(0.5);
                    break;
                  case bt.SphereImpostor:
                    r = i._getDebugSphereMesh(o);
                    break;
                  case bt.CylinderImpostor:
                    r = i._getDebugCylinderMesh(o);
                    break;
                  default:
                    r = null;
                }
                r && (r.scaling.x = h.x - u.x, r.scaling.y = h.y - u.y, r.scaling.z = h.z - u.z, r.parent = l);
              }
            }) : q.Warn("No target mesh parameter provided for NoImpostor. Skipping."), r = null;
            break;
          case bt.CylinderImpostor:
            r = this._getDebugCylinderMesh(o), s = t.object.getBoundingInfo(), r.scaling.x = (s.boundingBox.maximum.x - s.boundingBox.minimum.x) * t.object.scaling.x, r.scaling.y = (s.boundingBox.maximum.y - s.boundingBox.minimum.y) * t.object.scaling.y, r.scaling.z = (s.boundingBox.maximum.z - s.boundingBox.minimum.z) * t.object.scaling.z;
        }
        return r;
      }, n.prototype._getDebugBodyMesh = function(t) {
        if (!this._utilityLayer)
          return null;
        var e = this._utilityLayer.utilityLayerScene, i = new ie("custom", e), r = new Oe(), o = t.getGeometry();
        if (r.positions = o.positions, r.indices = o.indices, r.applyToMesh(i), t._pluginDataInstances) {
          var a = new Float32Array(16 * t._pluginDataInstances.length);
          i.thinInstanceSetBuffer("matrix", a, 16);
        }
        return i.material = this._getDebugMaterial(e), i;
      }, n.prototype._getMeshDebugInertiaMatrixToRef = function(t, e) {
        var i, r, o, a = (i = t.inertiaOrientation) !== null && i !== void 0 ? i : oe.Identity(), s = (r = t.inertia) !== null && r !== void 0 ? r : v.Zero(), l = (o = t.centerOfMass) !== null && o !== void 0 ? o : v.Zero(), c = 6 * (s.x - s.y + s.z), u = Math.sqrt(Math.max(c, 0)), h = 12 * s.x - c, d = Math.sqrt(Math.max(h, 0)), p = 12 * s.z - c, f = Math.sqrt(Math.max(p, 0)), m = F.Vector3[0];
        m.set(f, u, d);
        var g = B.ScalingToRef(m.x, m.y, m.z, F.Matrix[0]), y = a.toRotationMatrix(F.Matrix[1]), b = B.TranslationToRef(l.x, l.y, l.z, F.Matrix[2]);
        return g.multiplyToRef(y, e), e.multiplyToRef(b, e), e;
      }, n.prototype._getDebugInertiaMesh = function(t) {
        if (!this._utilityLayer)
          return null;
        var e = this._utilityLayer.utilityLayerScene, i = Uv.CreateBox("custom", { size: 1 }, e), r = B.Identity();
        if (t._pluginDataInstances.length) {
          for (var o = new Float32Array(16 * t._pluginDataInstances.length), a = 0; a < t._pluginDataInstances.length; ++a) {
            var s = t.getMassProperties(a);
            this._getMeshDebugInertiaMatrixToRef(s, r), r.copyToArray(o, 16 * a);
          }
          i.thinInstanceSetBuffer("matrix", o, 16);
        } else
          s = t.getMassProperties(), this._getMeshDebugInertiaMatrixToRef(s, r), r.decomposeToTransformNode(i);
        return i.enableEdgesRendering(), i.edgesWidth = 2, i.edgesColor = new Ie(1, 0, 1, 1), i.material = this._getDebugInertiaMaterial(e), i;
      }, n.prototype._getTransformFromBodyToRef = function(t, e, i) {
        var r = t.transformNode;
        return i && i >= 0 ? B.FromArrayToRef(r._thinInstanceDataStorage.matrixData, i, e) : e.copyFrom(r.getWorldMatrix());
      }, n.prototype._getDebugConstraintMesh = function(t) {
        if (!this._utilityLayer)
          return null;
        var e = this._utilityLayer.utilityLayerScene;
        if (!t._initOptions)
          return null;
        var i = t._initOptions, r = i.pivotA, o = i.pivotB, a = i.axisA, s = i.axisB, l = i.perpAxisA, c = i.perpAxisB;
        if (!(r && o && a && s && l && c))
          return null;
        for (var u = new ie("parentingDebugConstraint", e), h = 0, d = t.getBodiesUsingConstraint(); h < d.length; h++) {
          var p = d[h], f = new ai("parentOfPair", e);
          f.parent = u;
          var m = p.parentBody, g = p.parentBodyIndex, y = p.childBody, b = p.childBodyIndex, T = this._getTransformFromBodyToRef(m, F.Matrix[0], g), S = this._getTransformFromBodyToRef(y, F.Matrix[1], b), E = new ai("parentCoordSystem", e);
          E.parent = f, E.metadata = { parentBody: m, parentBodyIndex: g }, T.decomposeToTransformNode(E);
          var A = new ai("childCoordSystem", e);
          A.parent = f, A.metadata = { childBody: y, childBodyIndex: b }, S.decomposeToTransformNode(A);
          var R = oe.FromRotationMatrix(B.FromXYZAxesToRef(a, l, a.cross(l), F.Matrix[0])), C = oe.FromRotationMatrix(B.FromXYZAxesToRef(s, c, s.cross(c), F.Matrix[0])), L = r, I = o, O = new ai("constraint_parent", e);
          O.position.copyFrom(L), O.rotationQuaternion = R, O.parent = E;
          var w = new ai("constraint_child", e);
          w.parent = A, w.position.copyFrom(I), w.rotationQuaternion = C;
          var z = new yl(e, this._constraintAxesSize);
          z.xAxis.parent = O, z.yAxis.parent = O, z.zAxis.parent = O;
          var V = new yl(e, this._constraintAxesSize);
          V.xAxis.parent = w, V.yAxis.parent = w, V.zAxis.parent = w;
        }
        return u;
      }, n.prototype.dispose = function() {
        for (var t = this._numMeshes - 1; t >= 0; t--)
          this.hideImpostor(this._impostors[0]);
        for (t = this._numBodies - 1; t >= 0; t--)
          this.hideBody(this._bodies[0]);
        for (t = this._numInertiaBodies - 1; t >= 0; t--)
          this.hideInertia(this._inertiaBodies[0]);
        this._debugBoxMesh && this._debugBoxMesh.dispose(), this._debugSphereMesh && this._debugSphereMesh.dispose(), this._debugCylinderMesh && this._debugCylinderMesh.dispose(), this._debugMaterial && this._debugMaterial.dispose(), this._impostors.length = 0, this._scene = null, this._physicsEnginePlugin = null, this._utilityLayer && (this._utilityLayer.dispose(), this._utilityLayer = null);
      }, n;
    }(), Vv = function() {
      function n(t) {
        this.ray = t;
      }
      return n.CreateAndShow = function(t, e, i) {
        var r = new n(t);
        return r.show(e, i), r;
      }, n.prototype.show = function(t, e) {
        var i = this;
        if (!this._renderFunction && this.ray) {
          var r = this.ray;
          this._renderFunction = function() {
            return i._render();
          }, this._scene = t, this._renderPoints = [r.origin, r.origin.add(r.direction.scale(r.length))], this._renderLine = si("ray", { points: this._renderPoints, updatable: !0 }, t), this._renderLine.isPickable = !1, this._renderFunction && this._scene.registerBeforeRender(this._renderFunction);
        }
        e && this._renderLine && this._renderLine.color.copyFrom(e);
      }, n.prototype.hide = function() {
        this._renderFunction && this._scene && (this._scene.unregisterBeforeRender(this._renderFunction), this._scene = null, this._renderFunction = null, this._renderLine && (this._renderLine.dispose(), this._renderLine = null), this._renderPoints = []);
      }, n.prototype._render = function() {
        var t, e = this.ray;
        if (e) {
          var i = this._renderPoints[1], r = Math.min(e.length, 1e6);
          i.copyFrom(e.direction), i.scaleInPlace(r), i.addInPlace(e.origin), this._renderPoints[0].copyFrom(e.origin), si("ray", { points: this._renderPoints, updatable: !0, instance: this._renderLine }, this._scene), (t = this._renderLine) === null || t === void 0 || t.refreshBoundingInfo();
        }
      }, n.prototype.attachToMesh = function(t, e, i, r) {
        var o = this;
        this._attachedToMesh = t;
        var a = this.ray;
        a && (a.direction || (a.direction = v.Zero()), a.origin || (a.origin = v.Zero()), r && (a.length = r), i || (i = v.Zero()), e || (e = new v(0, 0, -1)), this._scene || (this._scene = t.getScene()), this._meshSpaceDirection ? (this._meshSpaceDirection.copyFrom(e), this._meshSpaceOrigin.copyFrom(i)) : (this._meshSpaceDirection = e.clone(), this._meshSpaceOrigin = i.clone()), this._onAfterRenderObserver || (this._onAfterRenderObserver = this._scene.onBeforeRenderObservable.add(function() {
          return o._updateToMesh();
        }), this._onAfterStepObserver = this._scene.onAfterStepObservable.add(function() {
          return o._updateToMesh();
        })), this._attachedToMesh.computeWorldMatrix(!0), this._updateToMesh());
      }, n.prototype.detachFromMesh = function() {
        this._attachedToMesh && this._scene && (this._onAfterRenderObserver && (this._scene.onBeforeRenderObservable.remove(this._onAfterRenderObserver), this._scene.onAfterStepObservable.remove(this._onAfterStepObserver)), this._attachedToMesh = null, this._onAfterRenderObserver = null, this._onAfterStepObserver = null, this._scene = null);
      }, n.prototype._updateToMesh = function() {
        var t = this.ray;
        this._attachedToMesh && t && (this._attachedToMesh.isDisposed() ? this.detachFromMesh() : (this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection, t.direction), v.TransformCoordinatesToRef(this._meshSpaceOrigin, this._attachedToMesh.getWorldMatrix(), t.origin)));
      }, n.prototype.dispose = function() {
        this.hide(), this.detachFromMesh(), this.ray = null;
      }, n;
    }(), wf = function() {
      function n(t, e, i, r, o, a) {
        var s, l, c, u, h, d, p, f, m, g, y, b, T, S;
        if (r === void 0 && (r = !0), o === void 0 && (o = 3), a === void 0 && (a = {}), this.skeleton = t, this.mesh = e, this.autoUpdateBonesMatrices = r, this.renderingGroupId = o, this.options = a, this.color = ne.White(), this._debugLines = new Array(), this._localAxes = null, this._isEnabled = !0, this._obs = null, this._scene = i, this._ready = !1, a.pauseAnimations = (s = a.pauseAnimations) === null || s === void 0 || s, a.returnToRest = (l = a.returnToRest) !== null && l !== void 0 && l, a.displayMode = (c = a.displayMode) !== null && c !== void 0 ? c : n.DISPLAY_LINES, a.displayOptions = (u = a.displayOptions) !== null && u !== void 0 ? u : {}, a.displayOptions.midStep = (h = a.displayOptions.midStep) !== null && h !== void 0 ? h : 0.235, a.displayOptions.midStepFactor = (d = a.displayOptions.midStepFactor) !== null && d !== void 0 ? d : 0.155, a.displayOptions.sphereBaseSize = (p = a.displayOptions.sphereBaseSize) !== null && p !== void 0 ? p : 0.15, a.displayOptions.sphereScaleUnit = (f = a.displayOptions.sphereScaleUnit) !== null && f !== void 0 ? f : 2, a.displayOptions.sphereFactor = (m = a.displayOptions.sphereFactor) !== null && m !== void 0 ? m : 0.865, a.displayOptions.spurFollowsChild = (g = a.displayOptions.spurFollowsChild) !== null && g !== void 0 && g, a.displayOptions.showLocalAxes = (y = a.displayOptions.showLocalAxes) !== null && y !== void 0 && y, a.displayOptions.localAxesSize = (b = a.displayOptions.localAxesSize) !== null && b !== void 0 ? b : 0.075, a.computeBonesUsingShaders = (T = a.computeBonesUsingShaders) === null || T === void 0 || T, a.useAllBones = (S = a.useAllBones) === null || S === void 0 || S, this._boneIndices = /* @__PURE__ */ new Set(), !a.useAllBones) {
          var E = e == null ? void 0 : e.getVerticesData(P.MatricesIndicesKind), A = e == null ? void 0 : e.getVerticesData(P.MatricesWeightsKind);
          if (E && A)
            for (var R = 0; R < E.length; ++R) {
              var C = E[R];
              A[R] !== 0 && this._boneIndices.add(C);
            }
        }
        this._utilityLayer = new Fi(this._scene, !1), this._utilityLayer.pickUtilitySceneFirst = !1, this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = !0;
        var L = this.options.displayMode || 0;
        L > n.DISPLAY_SPHERE_AND_SPURS && (L = n.DISPLAY_LINES), this.displayMode = L, this.update(), this._bindObs();
      }
      return n.CreateBoneWeightShader = function(t, e) {
        var i, r, o, a, s, l, c = t.skeleton, u = (i = t.colorBase) !== null && i !== void 0 ? i : ne.Black(), h = (r = t.colorZero) !== null && r !== void 0 ? r : ne.Blue(), d = (o = t.colorQuarter) !== null && o !== void 0 ? o : ne.Green(), p = (a = t.colorHalf) !== null && a !== void 0 ? a : ne.Yellow(), f = (s = t.colorFull) !== null && s !== void 0 ? s : ne.Red(), m = (l = t.targetBoneIndex) !== null && l !== void 0 ? l : 0;
        Jt.ShadersStore["boneWeights:" + c.name + "VertexShader"] = `precision highp float;

        attribute vec3 position;
        attribute vec2 uv;

        uniform mat4 view;
        uniform mat4 projection;
        uniform mat4 worldViewProjection;

        #include<bonesDeclaration>
        #if NUM_BONE_INFLUENCERS == 0
            attribute vec4 matricesIndices;
            attribute vec4 matricesWeights;
        #endif
        #include<bakedVertexAnimationDeclaration>

        #include<instancesDeclaration>

        varying vec3 vColor;

        uniform vec3 colorBase;
        uniform vec3 colorZero;
        uniform vec3 colorQuarter;
        uniform vec3 colorHalf;
        uniform vec3 colorFull;

        uniform float targetBoneIndex;

        void main() {
            vec3 positionUpdated = position;

            #include<instancesVertex>
            #include<bonesVertex>
            #include<bakedVertexAnimation>

            vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0);

            vec3 color = colorBase;
            float totalWeight = 0.;
            if(matricesIndices[0] == targetBoneIndex && matricesWeights[0] > 0.){
                totalWeight += matricesWeights[0];
            }
            if(matricesIndices[1] == targetBoneIndex && matricesWeights[1] > 0.){
                totalWeight += matricesWeights[1];
            }
            if(matricesIndices[2] == targetBoneIndex && matricesWeights[2] > 0.){
                totalWeight += matricesWeights[2];
            }
            if(matricesIndices[3] == targetBoneIndex && matricesWeights[3] > 0.){
                totalWeight += matricesWeights[3];
            }

            color = mix(color, colorZero, smoothstep(0., 0.25, totalWeight));
            color = mix(color, colorQuarter, smoothstep(0.25, 0.5, totalWeight));
            color = mix(color, colorHalf, smoothstep(0.5, 0.75, totalWeight));
            color = mix(color, colorFull, smoothstep(0.75, 1.0, totalWeight));
            vColor = color;

        gl_Position = projection * view * worldPos;
        }`, Jt.ShadersStore["boneWeights:" + c.name + "FragmentShader"] = `
            precision highp float;
            varying vec3 vPosition;

            varying vec3 vColor;

            void main() {
                vec4 color = vec4(vColor, 1.0);
                gl_FragColor = color;
            }
        `;
        var g = new dr("boneWeight:" + c.name, e, { vertex: "boneWeights:" + c.name, fragment: "boneWeights:" + c.name }, { attributes: ["position", "normal", "matricesIndices", "matricesWeights"], uniforms: ["world", "worldView", "worldViewProjection", "view", "projection", "viewProjection", "colorBase", "colorZero", "colorQuarter", "colorHalf", "colorFull", "targetBoneIndex"] });
        return g.setColor3("colorBase", u), g.setColor3("colorZero", h), g.setColor3("colorQuarter", d), g.setColor3("colorHalf", p), g.setColor3("colorFull", f), g.setFloat("targetBoneIndex", m), g.getClassName = function() {
          return "BoneWeightShader";
        }, g.transparencyMode = Et.MATERIAL_OPAQUE, g;
      }, n.CreateSkeletonMapShader = function(t, e) {
        var i, r = t.skeleton, o = (i = t.colorMap) !== null && i !== void 0 ? i : [{ color: new ne(1, 0.38, 0.18), location: 0 }, { color: new ne(0.59, 0.18, 1), location: 0.2 }, { color: new ne(0.59, 1, 0.18), location: 0.4 }, { color: new ne(1, 0.87, 0.17), location: 0.6 }, { color: new ne(1, 0.17, 0.42), location: 0.8 }, { color: new ne(0.17, 0.68, 1), location: 1 }], a = r.bones.length + 1, s = n._CreateBoneMapColorBuffer(a, o, e), l = new dr("boneWeights:" + r.name, e, { vertexSource: `precision highp float;

            attribute vec3 position;
            attribute vec2 uv;

            uniform mat4 view;
            uniform mat4 projection;
            uniform mat4 worldViewProjection;
            uniform float colorMap[` + 4 * r.bones.length + `];

            #include<bonesDeclaration>
            #if NUM_BONE_INFLUENCERS == 0
                attribute vec4 matricesIndices;
                attribute vec4 matricesWeights;
            #endif
            #include<bakedVertexAnimationDeclaration>
            #include<instancesDeclaration>

            varying vec3 vColor;

            void main() {
                vec3 positionUpdated = position;

                #include<instancesVertex>
                #include<bonesVertex>
                #include<bakedVertexAnimation>

                vec3 color = vec3(0.);
                bool first = true;

                for (int i = 0; i < 4; i++) {
                    int boneIdx = int(matricesIndices[i]);
                    float boneWgt = matricesWeights[i];

                    vec3 c = vec3(colorMap[boneIdx * 4 + 0], colorMap[boneIdx * 4 + 1], colorMap[boneIdx * 4 + 2]);

                    if (boneWgt > 0.) {
                        if (first) {
                            first = false;
                            color = c;
                        } else {
                            color = mix(color, c, boneWgt);
                        }
                    }
                }

                vColor = color;

                vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0);

                gl_Position = projection * view * worldPos;
            }`, fragmentSource: `
            precision highp float;
            varying vec3 vColor;

            void main() {
                vec4 color = vec4( vColor, 1.0 );
                gl_FragColor = color;
            }
            ` }, { attributes: ["position", "normal", "matricesIndices", "matricesWeights"], uniforms: ["world", "worldView", "worldViewProjection", "view", "projection", "viewProjection", "colorMap"] });
        return l.setFloats("colorMap", s), l.getClassName = function() {
          return "SkeletonMapShader";
        }, l.transparencyMode = Et.MATERIAL_OPAQUE, l;
      }, n._CreateBoneMapColorBuffer = function(t, e, i) {
        var r = new Es("temp", { width: t, height: 1 }, i, !1), o = r.getContext(), a = o.createLinearGradient(0, 0, t, 0);
        e.forEach(function(u) {
          a.addColorStop(u.location, u.color.toHexString());
        }), o.fillStyle = a, o.fillRect(0, 0, t, 1), r.update();
        for (var s = [], l = o.getImageData(0, 0, t, 1).data, c = 0; c < l.length; c++)
          s.push(0.00392156862745098 * l[c]);
        return r.dispose(), s;
      }, Object.defineProperty(n.prototype, "scene", { get: function() {
        return this._scene;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "utilityLayer", { get: function() {
        return this._utilityLayer;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isReady", { get: function() {
        return this._ready;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "ready", { set: function(t) {
        this._ready = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "debugMesh", { get: function() {
        return this._debugMesh;
      }, set: function(t) {
        this._debugMesh = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "displayMode", { get: function() {
        return this.options.displayMode || n.DISPLAY_LINES;
      }, set: function(t) {
        t > n.DISPLAY_SPHERE_AND_SPURS && (t = n.DISPLAY_LINES), this.options.displayMode = t;
      }, enumerable: !1, configurable: !0 }), n.prototype._bindObs = function() {
        var t = this;
        this.displayMode === n.DISPLAY_LINES && (this._obs = this.scene.onBeforeRenderObservable.add(function() {
          t._displayLinesUpdate();
        }));
      }, n.prototype.update = function() {
        switch (this.displayMode) {
          case n.DISPLAY_LINES:
            this._displayLinesUpdate();
            break;
          case n.DISPLAY_SPHERES:
            this._buildSpheresAndSpurs(!0);
            break;
          case n.DISPLAY_SPHERE_AND_SPURS:
            this._buildSpheresAndSpurs(!1);
        }
        this._buildLocalAxes();
      }, Object.defineProperty(n.prototype, "isEnabled", { get: function() {
        return this._isEnabled;
      }, set: function(t) {
        this.isEnabled !== t && (this._isEnabled = t, this.debugMesh && this.debugMesh.setEnabled(t), t && !this._obs ? this._bindObs() : !t && this._obs && (this.scene.onBeforeRenderObservable.remove(this._obs), this._obs = null));
      }, enumerable: !1, configurable: !0 }), n.prototype._getBonePosition = function(t, e, i, r, o, a) {
        r === void 0 && (r = 0), o === void 0 && (o = 0), a === void 0 && (a = 0);
        var s = F.Matrix[0], l = e.getParent();
        if (s.copyFrom(e.getLocalMatrix()), r !== 0 || o !== 0 || a !== 0) {
          var c = F.Matrix[1];
          B.IdentityToRef(c), c.setTranslationFromFloats(r, o, a), c.multiplyToRef(s, s);
        }
        l && s.multiplyToRef(l.getAbsoluteMatrix(), s), s.multiplyToRef(i, s), t.x = s.m[12], t.y = s.m[13], t.z = s.m[14];
      }, n.prototype._getLinesForBonesWithLength = function(t, e) {
        var i, r, o = t.length;
        e ? (i = e.getWorldMatrix(), r = e.position) : (i = new B(), r = t[0].position);
        for (var a = 0, s = 0; s < o; s++) {
          var l = t[s], c = this._debugLines[a];
          l._index !== -1 && (this._boneIndices.has(l.getIndex()) || this.options.useAllBones) && (c || (c = [v.Zero(), v.Zero()], this._debugLines[a] = c), this._getBonePosition(c[0], l, i), this._getBonePosition(c[1], l, i, 0, l.length, 0), c[0].subtractInPlace(r), c[1].subtractInPlace(r), a++);
        }
      }, n.prototype._getLinesForBonesNoLength = function(t) {
        var e, i, r = t.length, o = 0, a = this.mesh;
        a ? (e = a, i = a.position) : (e = new ai(""), i = t[0].position);
        for (var s = r - 1; s >= 0; s--) {
          var l = t[s], c = l.getParent();
          if (c && (this._boneIndices.has(l.getIndex()) || this.options.useAllBones)) {
            var u = this._debugLines[o];
            u || (u = [v.Zero(), v.Zero()], this._debugLines[o] = u), l.getAbsolutePositionToRef(e, u[0]), c.getAbsolutePositionToRef(e, u[1]), u[0].subtractInPlace(i), u[1].subtractInPlace(i), o++;
          }
        }
        a || e.dispose();
      }, n.prototype._revert = function(t) {
        this.options.pauseAnimations && (this.scene.animationsEnabled = t, this.utilityLayer.utilityLayerScene.animationsEnabled = t);
      }, n.prototype._getAbsoluteBindPoseToRef = function(t, e) {
        t !== null && t._index !== -1 ? (this._getAbsoluteBindPoseToRef(t.getParent(), e), t.getBindMatrix().multiplyToRef(e, e)) : e.copyFrom(B.Identity());
      }, n.prototype._buildSpheresAndSpurs = function(t) {
        var e, i, r;
        t === void 0 && (t = !0), this._debugMesh && (this._debugMesh.dispose(), this._debugMesh = null, this.ready = !1), this._ready = !1;
        var o = (i = this.utilityLayer) === null || i === void 0 ? void 0 : i.utilityLayerScene, a = this.skeleton.bones, s = [], l = [], c = this.scene.animationsEnabled;
        try {
          this.options.pauseAnimations && (this.scene.animationsEnabled = !1, o.animationsEnabled = !1), this.options.returnToRest && this.skeleton.returnToRest(), this.autoUpdateBonesMatrices && this.skeleton.computeAbsoluteMatrices();
          for (var u = Number.NEGATIVE_INFINITY, h = this.options.displayOptions || {}, d = function(R) {
            var C = a[R];
            if (C._index === -1 || !p._boneIndices.has(C.getIndex()) && !p.options.useAllBones)
              return "continue";
            var L = new B();
            p._getAbsoluteBindPoseToRef(C, L);
            var I = new v();
            L.decompose(void 0, void 0, I), C.children.forEach(function(ee) {
              var J = new B();
              ee.getLocalMatrix().multiplyToRef(L, J);
              var X = new v();
              J.decompose(void 0, void 0, X);
              var K = v.Distance(I, X);
              if (K > u && (u = K), !t) {
                for (var te = X.clone().subtract(I.clone()), se = te.length(), _e = te.normalize().scale(se), xe = h.midStep || 0.165, Te = h.midStepFactor || 0.215, he = _e.scale(xe), me = Nc("skeletonViewer", { shape: [new v(1, -1, 0), new v(1, 1, 0), new v(-1, 1, 0), new v(-1, -1, 0), new v(1, -1, 0)], path: [v.Zero(), he, _e], scaleFunction: function(De) {
                  switch (De) {
                    case 0:
                    case 2:
                      return 0;
                    case 1:
                      return se * Te;
                  }
                  return 0;
                }, sideOrientation: ie.DEFAULTSIDE, updatable: !1 }, o), Fe = me.getTotalVertices(), Ce = [], Re = [], Be = 0; Be < Fe; Be++)
                  Ce.push(1, 0, 0, 0), h.spurFollowsChild && Be > 9 ? Re.push(ee.getIndex(), 0, 0, 0) : Re.push(C.getIndex(), 0, 0, 0);
                me.position = I.clone(), me.setVerticesData(P.MatricesWeightsKind, Ce, !1), me.setVerticesData(P.MatricesIndicesKind, Re, !1), me.convertToFlatShadedMesh(), l.push(me);
              }
            });
            for (var O = yn("skeletonViewer", { segments: 6, diameter: h.sphereBaseSize || 0.2, updatable: !0 }, o), w = O.getTotalVertices(), z = [], V = [], Y = 0; Y < w; Y++)
              z.push(1, 0, 0, 0), V.push(C.getIndex(), 0, 0, 0);
            O.setVerticesData(P.MatricesWeightsKind, z, !1), O.setVerticesData(P.MatricesIndicesKind, V, !1), O.position = I.clone(), s.push([O, C]);
          }, p = this, f = 0; f < a.length; f++)
            d(f);
          var m = h.sphereScaleUnit || 2, g = h.sphereFactor || 0.85, y = [];
          for (f = 0; f < s.length; f++) {
            for (var b = (e = s[f])[0], T = e[1], S = 1 / (m / u), E = 0, A = T; A.getParent() && A.getParent().getIndex() !== -1; )
              E++, A = A.getParent();
            b.scaling.scaleInPlace(S * Math.pow(g, E)), y.push(b);
          }
          this.debugMesh = ie.MergeMeshes(y.concat(l), !0, !0), this.debugMesh && (this.debugMesh.renderingGroupId = this.renderingGroupId, this.debugMesh.skeleton = this.skeleton, this.debugMesh.parent = this.mesh, this.debugMesh.computeBonesUsingShaders = (r = this.options.computeBonesUsingShaders) === null || r === void 0 || r, this.debugMesh.alwaysSelectAsActiveMesh = !0), this.utilityLayer._getSharedGizmoLight().intensity = 0.7, this._revert(c), this.ready = !0;
        } catch (R) {
          console.error(R), this._revert(c), this.dispose();
        }
      }, n.prototype._buildLocalAxes = function() {
        var t;
        this._localAxes && this._localAxes.dispose(), this._localAxes = null;
        var e = this.options.displayOptions || {};
        if (e.showLocalAxes) {
          var i = this._utilityLayer.utilityLayerScene, r = e.localAxesSize || 0.075, o = [], a = [], s = new Ie(1, 0, 0, 1), l = new Ie(0, 1, 0, 1), c = new Ie(0, 0, 1, 1), u = [], h = [];
          for (var d in this.skeleton.bones) {
            var p = this.skeleton.bones[d];
            if (p._index !== -1 && (this._boneIndices.has(p.getIndex()) || this.options.useAllBones)) {
              var f = new B(), m = new v();
              this._getAbsoluteBindPoseToRef(p, f), f.decompose(void 0, F.Quaternion[0], m);
              var g = new B();
              F.Quaternion[0].toRotationMatrix(g);
              var y = v.TransformCoordinates(new v(0 + r, 0, 0), g), b = v.TransformCoordinates(new v(0, 0 + r, 0), g), T = v.TransformCoordinates(new v(0, 0, 0 + r), g), S = [[m, m.add(y)], [m, m.add(b)], [m, m.add(T)]], E = [[s, s], [l, l], [c, c]];
              o.push.apply(o, S), a.push.apply(a, E);
              for (var A = 0; A < 6; A++)
                u.push(1, 0, 0, 0), h.push(p.getIndex(), 0, 0, 0);
            }
          }
          this._localAxes = Ss("localAxes", { lines: o, colors: a, updatable: !0 }, i), this._localAxes.setVerticesData(P.MatricesWeightsKind, u, !1), this._localAxes.setVerticesData(P.MatricesIndicesKind, h, !1), this._localAxes.skeleton = this.skeleton, this._localAxes.renderingGroupId = this.renderingGroupId + 1, this._localAxes.parent = this.mesh, this._localAxes.computeBonesUsingShaders = (t = this.options.computeBonesUsingShaders) === null || t === void 0 || t;
        }
      }, n.prototype._displayLinesUpdate = function() {
        if (this._utilityLayer) {
          this.autoUpdateBonesMatrices && this.skeleton.computeAbsoluteMatrices(), this.skeleton.bones[0].length === void 0 ? this._getLinesForBonesNoLength(this.skeleton.bones) : this._getLinesForBonesWithLength(this.skeleton.bones, this.mesh);
          var t = this._utilityLayer.utilityLayerScene;
          t && (this._debugMesh ? Ss("", { lines: this._debugLines, updatable: !0, instance: this._debugMesh }, t) : (this._debugMesh = Ss("", { lines: this._debugLines, updatable: !0, instance: null }, t), this._debugMesh.renderingGroupId = this.renderingGroupId), this.mesh ? this._debugMesh.position.copyFrom(this.mesh.position) : this._debugMesh.position.copyFrom(this.skeleton.bones[0].position), this._debugMesh.color = this.color);
        }
      }, n.prototype.changeDisplayMode = function(t) {
        var e = !!this.isEnabled;
        this.displayMode !== t && (this.isEnabled = !1, this._debugMesh && (this._debugMesh.dispose(), this._debugMesh = null, this.ready = !1), this.displayMode = t, this.update(), this._bindObs(), this.isEnabled = e);
      }, n.prototype.changeDisplayOptions = function(t, e) {
        var i = !!this.isEnabled;
        this.options.displayOptions[t] = e, this.isEnabled = !1, this._debugMesh && (this._debugMesh.dispose(), this._debugMesh = null, this.ready = !1), this.update(), this._bindObs(), this.isEnabled = i;
      }, n.prototype.dispose = function() {
        this.isEnabled = !1, this._debugMesh && (this._debugMesh.dispose(), this._debugMesh = null), this._utilityLayer && (this._utilityLayer.dispose(), this._utilityLayer = null), this.ready = !1;
      }, n.DISPLAY_LINES = 0, n.DISPLAY_SPHERES = 1, n.DISPLAY_SPHERE_AND_SPURS = 2, n;
    }(), kv = function() {
      function n(t, e) {
        this._oldPosition = new v(Number.NaN, Number.NaN, Number.NaN), this._oldDirection = new v(Number.NaN, Number.NaN, Number.NaN), this._transparency = 0.3, this._showLines = !0, this._showPlanes = !0, this._scene = t.getScene(), this._light = t, this._camera = e, this._inverseViewMatrix = B.Identity(), this._lightHelperFrustumMeshes = [], this._createGeometry(), this.show(), this.update();
      }
      return Object.defineProperty(n.prototype, "transparency", { get: function() {
        return this._transparency;
      }, set: function(t) {
        this._transparency = t;
        for (var e = 6; e < 12; ++e)
          this._lightHelperFrustumMeshes[e].material.alpha = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "showLines", { get: function() {
        return this._showLines;
      }, set: function(t) {
        if (this._showLines !== t) {
          this._showLines = t;
          for (var e = 0; e < 6; ++e)
            this._lightHelperFrustumMeshes[e].setEnabled(t);
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "showPlanes", { get: function() {
        return this._showPlanes;
      }, set: function(t) {
        if (this._showPlanes !== t) {
          this._showPlanes = t;
          for (var e = 6; e < 12; ++e)
            this._lightHelperFrustumMeshes[e].setEnabled(t);
        }
      }, enumerable: !1, configurable: !0 }), n.prototype.show = function() {
        var t = this;
        this._lightHelperFrustumMeshes.forEach(function(e, i) {
          e.setEnabled(i < 6 && t._showLines || i >= 6 && t._showPlanes);
        }), this._oldPosition.set(Number.NaN, Number.NaN, Number.NaN), this._visible = !0;
      }, n.prototype.hide = function() {
        this._lightHelperFrustumMeshes.forEach(function(t) {
          t.setEnabled(!1);
        }), this._visible = !1;
      }, n.prototype.update = function() {
        var t, e, i, r, o, a;
        if (this._visible && (!this._oldPosition.equals(this._light.position) || !this._oldDirection.equals(this._light.direction) || this._oldAutoCalc !== this._light.autoCalcShadowZBounds || this._oldMinZ !== this._light.shadowMinZ || this._oldMaxZ !== this._light.shadowMaxZ)) {
          this._oldPosition.copyFrom(this._light.position), this._oldDirection.copyFrom(this._light.direction), this._oldAutoCalc = this._light.autoCalcShadowZBounds, this._oldMinZ = this._light.shadowMinZ, this._oldMaxZ = this._light.shadowMaxZ, F.Vector3[0].set(this._light.orthoLeft, this._light.orthoBottom, this._light.shadowMinZ !== void 0 ? this._light.shadowMinZ : this._camera.minZ), F.Vector3[1].set(this._light.orthoRight, this._light.orthoTop, this._light.shadowMaxZ !== void 0 ? this._light.shadowMaxZ : this._camera.maxZ);
          var s = this._getInvertViewMatrix();
          F.Vector3[2].copyFromFloats(F.Vector3[1].x, F.Vector3[1].y, F.Vector3[0].z), F.Vector3[3].copyFromFloats(F.Vector3[1].x, F.Vector3[0].y, F.Vector3[0].z), F.Vector3[4].copyFromFloats(F.Vector3[0].x, F.Vector3[0].y, F.Vector3[0].z), F.Vector3[5].copyFromFloats(F.Vector3[0].x, F.Vector3[1].y, F.Vector3[0].z), v.TransformCoordinatesToRef(F.Vector3[2], s, F.Vector3[2]), v.TransformCoordinatesToRef(F.Vector3[3], s, F.Vector3[3]), v.TransformCoordinatesToRef(F.Vector3[4], s, F.Vector3[4]), v.TransformCoordinatesToRef(F.Vector3[5], s, F.Vector3[5]), F.Vector3[6].copyFromFloats(F.Vector3[1].x, F.Vector3[1].y, F.Vector3[1].z), F.Vector3[7].copyFromFloats(F.Vector3[1].x, F.Vector3[0].y, F.Vector3[1].z), F.Vector3[8].copyFromFloats(F.Vector3[0].x, F.Vector3[0].y, F.Vector3[1].z), F.Vector3[9].copyFromFloats(F.Vector3[0].x, F.Vector3[1].y, F.Vector3[1].z), v.TransformCoordinatesToRef(F.Vector3[6], s, F.Vector3[6]), v.TransformCoordinatesToRef(F.Vector3[7], s, F.Vector3[7]), v.TransformCoordinatesToRef(F.Vector3[8], s, F.Vector3[8]), v.TransformCoordinatesToRef(F.Vector3[9], s, F.Vector3[9]), si("nearlines", { updatable: !0, points: this._nearLinesPoints, instance: this._lightHelperFrustumMeshes[0] }, this._scene), si("farlines", { updatable: !0, points: this._farLinesPoints, instance: this._lightHelperFrustumMeshes[1] }, this._scene), si("trlines", { updatable: !0, points: this._trLinesPoints, instance: this._lightHelperFrustumMeshes[2] }, this._scene), si("brlines", { updatable: !0, points: this._brLinesPoints, instance: this._lightHelperFrustumMeshes[3] }, this._scene), si("tllines", { updatable: !0, points: this._tlLinesPoints, instance: this._lightHelperFrustumMeshes[4] }, this._scene), si("bllines", { updatable: !0, points: this._blLinesPoints, instance: this._lightHelperFrustumMeshes[5] }, this._scene), F.Vector3[2].toArray(this._nearPlaneVertices, 0), F.Vector3[3].toArray(this._nearPlaneVertices, 3), F.Vector3[4].toArray(this._nearPlaneVertices, 6), F.Vector3[5].toArray(this._nearPlaneVertices, 9), (t = this._lightHelperFrustumMeshes[6].geometry) === null || t === void 0 || t.updateVerticesDataDirectly("position", this._nearPlaneVertices, 0), F.Vector3[6].toArray(this._farPlaneVertices, 0), F.Vector3[7].toArray(this._farPlaneVertices, 3), F.Vector3[8].toArray(this._farPlaneVertices, 6), F.Vector3[9].toArray(this._farPlaneVertices, 9), (e = this._lightHelperFrustumMeshes[7].geometry) === null || e === void 0 || e.updateVerticesDataDirectly("position", this._farPlaneVertices, 0), F.Vector3[2].toArray(this._rightPlaneVertices, 0), F.Vector3[6].toArray(this._rightPlaneVertices, 3), F.Vector3[7].toArray(this._rightPlaneVertices, 6), F.Vector3[3].toArray(this._rightPlaneVertices, 9), (i = this._lightHelperFrustumMeshes[8].geometry) === null || i === void 0 || i.updateVerticesDataDirectly("position", this._rightPlaneVertices, 0), F.Vector3[5].toArray(this._leftPlaneVertices, 0), F.Vector3[9].toArray(this._leftPlaneVertices, 3), F.Vector3[8].toArray(this._leftPlaneVertices, 6), F.Vector3[4].toArray(this._leftPlaneVertices, 9), (r = this._lightHelperFrustumMeshes[9].geometry) === null || r === void 0 || r.updateVerticesDataDirectly("position", this._leftPlaneVertices, 0), F.Vector3[2].toArray(this._topPlaneVertices, 0), F.Vector3[6].toArray(this._topPlaneVertices, 3), F.Vector3[9].toArray(this._topPlaneVertices, 6), F.Vector3[5].toArray(this._topPlaneVertices, 9), (o = this._lightHelperFrustumMeshes[10].geometry) === null || o === void 0 || o.updateVerticesDataDirectly("position", this._topPlaneVertices, 0), F.Vector3[3].toArray(this._bottomPlaneVertices, 0), F.Vector3[7].toArray(this._bottomPlaneVertices, 3), F.Vector3[8].toArray(this._bottomPlaneVertices, 6), F.Vector3[4].toArray(this._bottomPlaneVertices, 9), (a = this._lightHelperFrustumMeshes[11].geometry) === null || a === void 0 || a.updateVerticesDataDirectly("position", this._bottomPlaneVertices, 0);
        }
      }, n.prototype.dispose = function() {
        this._lightHelperFrustumMeshes.forEach(function(t) {
          var e;
          (e = t.material) === null || e === void 0 || e.dispose(), t.dispose();
        }), this._rootNode.dispose();
      }, n.prototype._createGeometry = function() {
        var t = this;
        this._rootNode = new ai("directionalLightHelperRoot_" + this._light.name, this._scene), this._rootNode.parent = this._light.parent, this._nearLinesPoints = [v.ZeroReadOnly, v.ZeroReadOnly, v.ZeroReadOnly, v.ZeroReadOnly, v.ZeroReadOnly];
        var e = si("nearlines", { updatable: !0, points: this._nearLinesPoints }, this._scene);
        e.parent = this._rootNode, e.alwaysSelectAsActiveMesh = !0, this._farLinesPoints = [v.ZeroReadOnly, v.ZeroReadOnly, v.ZeroReadOnly, v.ZeroReadOnly, v.ZeroReadOnly];
        var i = si("farlines", { updatable: !0, points: this._farLinesPoints }, this._scene);
        i.parent = this._rootNode, i.alwaysSelectAsActiveMesh = !0, this._trLinesPoints = [v.ZeroReadOnly, v.ZeroReadOnly];
        var r = si("trlines", { updatable: !0, points: this._trLinesPoints }, this._scene);
        r.parent = this._rootNode, r.alwaysSelectAsActiveMesh = !0, this._brLinesPoints = [v.ZeroReadOnly, v.ZeroReadOnly];
        var o = si("brlines", { updatable: !0, points: this._brLinesPoints }, this._scene);
        o.parent = this._rootNode, o.alwaysSelectAsActiveMesh = !0, this._tlLinesPoints = [v.ZeroReadOnly, v.ZeroReadOnly];
        var a = si("tllines", { updatable: !0, points: this._tlLinesPoints }, this._scene);
        a.parent = this._rootNode, a.alwaysSelectAsActiveMesh = !0, this._blLinesPoints = [v.ZeroReadOnly, v.ZeroReadOnly];
        var s = si("bllines", { updatable: !0, points: this._blLinesPoints }, this._scene);
        s.parent = this._rootNode, s.alwaysSelectAsActiveMesh = !0, this._lightHelperFrustumMeshes.push(e, i, r, o, a, s);
        var l = function(c, u, h) {
          var d = new ie(c + "plane", t._scene), p = new Gt(c + "PlaneMat", t._scene);
          d.material = p, d.parent = t._rootNode, d.alwaysSelectAsActiveMesh = !0, p.emissiveColor = u, p.alpha = t.transparency, p.backFaceCulling = !1, p.disableLighting = !0;
          var f = new Oe();
          f.positions = h, f.indices = [0, 1, 2, 0, 2, 3], f.applyToMesh(d, !0), t._lightHelperFrustumMeshes.push(d);
        };
        this._nearPlaneVertices = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], this._farPlaneVertices = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], this._rightPlaneVertices = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], this._leftPlaneVertices = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], this._topPlaneVertices = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], this._bottomPlaneVertices = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], l("near", new ne(1, 0, 0), this._nearPlaneVertices), l("far", new ne(0.3, 0, 0), this._farPlaneVertices), l("right", new ne(0, 1, 0), this._rightPlaneVertices), l("left", new ne(0, 0.3, 0), this._leftPlaneVertices), l("top", new ne(0, 0, 1), this._topPlaneVertices), l("bottom", new ne(0, 0, 0.3), this._bottomPlaneVertices), this._nearLinesPoints[0] = F.Vector3[2], this._nearLinesPoints[1] = F.Vector3[3], this._nearLinesPoints[2] = F.Vector3[4], this._nearLinesPoints[3] = F.Vector3[5], this._nearLinesPoints[4] = F.Vector3[2], this._farLinesPoints[0] = F.Vector3[6], this._farLinesPoints[1] = F.Vector3[7], this._farLinesPoints[2] = F.Vector3[8], this._farLinesPoints[3] = F.Vector3[9], this._farLinesPoints[4] = F.Vector3[6], this._trLinesPoints[0] = F.Vector3[2], this._trLinesPoints[1] = F.Vector3[6], this._brLinesPoints[0] = F.Vector3[3], this._brLinesPoints[1] = F.Vector3[7], this._tlLinesPoints[0] = F.Vector3[4], this._tlLinesPoints[1] = F.Vector3[8], this._blLinesPoints[0] = F.Vector3[5], this._blLinesPoints[1] = F.Vector3[9];
      }, n.prototype._getInvertViewMatrix = function() {
        return B.LookAtLHToRef(this._light.position, this._light.position.add(this._light.direction), v.UpReadOnly, this._inverseViewMatrix), this._inverseViewMatrix.invertToRef(this._inverseViewMatrix), this._inverseViewMatrix;
      }, n;
    }(), Gv = function() {
      this.renderWidth = 512, this.renderHeight = 256, this.textureSize = 512, this.deterministicLockstep = !1, this.lockstepMaxSteps = 4;
    }, zv = function(n) {
      function t(e) {
        e === void 0 && (e = new Gv());
        var i = n.call(this, null) || this;
        ve.Instances.push(i), e.deterministicLockstep === void 0 && (e.deterministicLockstep = !1), e.lockstepMaxSteps === void 0 && (e.lockstepMaxSteps = 4), i._options = e, Ti.SetMatrixPrecision(!!e.useHighPrecisionMatrix), i._caps = { maxTexturesImageUnits: 16, maxVertexTextureImageUnits: 16, maxCombinedTexturesImageUnits: 32, maxTextureSize: 512, maxCubemapTextureSize: 512, maxRenderTextureSize: 512, maxVertexAttribs: 16, maxVaryingVectors: 16, maxFragmentUniformVectors: 16, maxVertexUniformVectors: 16, standardDerivatives: !1, astc: null, pvrtc: null, etc1: null, etc2: null, bptc: null, maxAnisotropy: 0, uintIndices: !1, fragmentDepthSupported: !1, highPrecisionShaderSupported: !0, colorBufferFloat: !1, supportFloatTexturesResolve: !1, textureFloat: !1, textureFloatLinearFiltering: !1, textureFloatRender: !1, textureHalfFloat: !1, textureHalfFloatLinearFiltering: !1, textureHalfFloatRender: !1, textureLOD: !1, texelFetch: !1, drawBuffersExtension: !1, depthTextureExtension: !1, vertexArrayObject: !1, instancedArrays: !1, supportOcclusionQuery: !1, canUseTimestampForTimerQuery: !1, maxMSAASamples: 1, blendMinMax: !1, canUseGLInstanceID: !1, canUseGLVertexID: !1, supportComputeShaders: !1, supportSRGBBuffers: !1, supportTransformFeedbacks: !1, textureMaxLevel: !1, texture2DArrayMaxLayerCount: 128, disableMorphTargetTexture: !1 }, i._features = { forceBitmapOverHTMLImageElement: !1, supportRenderAndCopyToLodForFloatTextures: !1, supportDepthStencilTexture: !1, supportShadowSamplers: !1, uniformBufferHardCheckMatrix: !1, allowTexturePrefiltering: !1, trackUbosInFrame: !1, checkUbosContentBeforeUpload: !1, supportCSM: !1, basisNeedsPOT: !1, support3DTextures: !1, needTypeSuffixInShaderConstants: !1, supportMSAA: !1, supportSSAO2: !1, supportExtendedTextureFormats: !1, supportSwitchCaseInShader: !1, supportSyncTextureRead: !1, needsInvertingBitmap: !1, useUBOBindingCache: !1, needShaderCodeInlining: !1, needToAlwaysBindUniformBuffers: !1, supportRenderPasses: !0, supportSpriteInstancing: !1, forceVertexBufferStrideMultiple4Bytes: !1, _collectUbosUpdatedInFrame: !1 }, q.Log("Babylon.js v".concat(ve.Version, " - Null engine"));
        var r = typeof self < "u" ? self : G.g !== void 0 ? G.g : window;
        return typeof URL > "u" && (r.URL = { createObjectURL: function() {
        }, revokeObjectURL: function() {
        } }), typeof Blob > "u" && (r.Blob = function() {
        }), i;
      }
      return D(t, n), t.prototype.isDeterministicLockStep = function() {
        return this._options.deterministicLockstep;
      }, t.prototype.getLockstepMaxSteps = function() {
        return this._options.lockstepMaxSteps;
      }, t.prototype.getHardwareScalingLevel = function() {
        return 1;
      }, t.prototype.createVertexBuffer = function(e) {
        var i = new wa();
        return i.references = 1, i;
      }, t.prototype.createIndexBuffer = function(e) {
        var i = new wa();
        return i.references = 1, i;
      }, t.prototype.clear = function(e, i, r, o) {
      }, t.prototype.getRenderWidth = function(e) {
        return e === void 0 && (e = !1), !e && this._currentRenderTarget ? this._currentRenderTarget.width : this._options.renderWidth;
      }, t.prototype.getRenderHeight = function(e) {
        return e === void 0 && (e = !1), !e && this._currentRenderTarget ? this._currentRenderTarget.height : this._options.renderHeight;
      }, t.prototype.setViewport = function(e, i, r) {
        this._cachedViewport = e;
      }, t.prototype.createShaderProgram = function(e, i, r, o, a) {
        return { __SPECTOR_rebuildProgram: null };
      }, t.prototype.getUniforms = function(e, i) {
        return [];
      }, t.prototype.getAttributes = function(e, i) {
        return [];
      }, t.prototype.bindSamplers = function(e) {
        this._currentEffect = null;
      }, t.prototype.enableEffect = function(e) {
        e = e !== null && Ei.IsWrapper(e) ? e.effect : e, this._currentEffect = e, e && (e.onBind && e.onBind(e), e._onBindObservable && e._onBindObservable.notifyObservers(e));
      }, t.prototype.setState = function(e, i, r, o, a, s, l) {
      }, t.prototype.setIntArray = function(e, i) {
        return !0;
      }, t.prototype.setIntArray2 = function(e, i) {
        return !0;
      }, t.prototype.setIntArray3 = function(e, i) {
        return !0;
      }, t.prototype.setIntArray4 = function(e, i) {
        return !0;
      }, t.prototype.setFloatArray = function(e, i) {
        return !0;
      }, t.prototype.setFloatArray2 = function(e, i) {
        return !0;
      }, t.prototype.setFloatArray3 = function(e, i) {
        return !0;
      }, t.prototype.setFloatArray4 = function(e, i) {
        return !0;
      }, t.prototype.setArray = function(e, i) {
        return !0;
      }, t.prototype.setArray2 = function(e, i) {
        return !0;
      }, t.prototype.setArray3 = function(e, i) {
        return !0;
      }, t.prototype.setArray4 = function(e, i) {
        return !0;
      }, t.prototype.setMatrices = function(e, i) {
        return !0;
      }, t.prototype.setMatrix3x3 = function(e, i) {
        return !0;
      }, t.prototype.setMatrix2x2 = function(e, i) {
        return !0;
      }, t.prototype.setFloat = function(e, i) {
        return !0;
      }, t.prototype.setFloat2 = function(e, i, r) {
        return !0;
      }, t.prototype.setFloat3 = function(e, i, r, o) {
        return !0;
      }, t.prototype.setBool = function(e, i) {
        return !0;
      }, t.prototype.setFloat4 = function(e, i, r, o, a) {
        return !0;
      }, t.prototype.setAlphaMode = function(e, i) {
        i === void 0 && (i = !1), this._alphaMode !== e && (this.alphaState.alphaBlend = e !== _.ALPHA_DISABLE, i || this.setDepthWrite(e === _.ALPHA_DISABLE), this._alphaMode = e);
      }, t.prototype.bindBuffers = function(e, i, r) {
      }, t.prototype.wipeCaches = function(e) {
        this.preventCacheWipeBetweenFrames || (this.resetTextureCache(), this._currentEffect = null, e && (this._currentProgram = null, this._stencilStateComposer.reset(), this.depthCullingState.reset(), this.alphaState.reset()), this._cachedVertexBuffers = null, this._cachedIndexBuffer = null, this._cachedEffectForVertexBuffers = null);
      }, t.prototype.draw = function(e, i, r, o) {
      }, t.prototype.drawElementsType = function(e, i, r, o) {
      }, t.prototype.drawArraysType = function(e, i, r, o) {
      }, t.prototype._createTexture = function() {
        return {};
      }, t.prototype._releaseTexture = function(e) {
      }, t.prototype.createTexture = function(e, i, r, o, a, s, l, c, u, h, d, p) {
        a === void 0 && (a = _.TEXTURE_TRILINEAR_SAMPLINGMODE), s === void 0 && (s = null), h === void 0 && (h = null);
        var f = new Ut(this, ut.Url), m = String(e);
        return f.url = m, f.generateMipMaps = !i, f.samplingMode = a, f.invertY = r, f.baseWidth = this._options.textureSize, f.baseHeight = this._options.textureSize, f.width = this._options.textureSize, f.height = this._options.textureSize, h && (f.format = h), f.isReady = !0, s && setTimeout(function() {
          s(f);
        }), this._internalTexturesCache.push(f), f;
      }, t.prototype._createHardwareRenderTargetWrapper = function(e, i, r) {
        var o = new dc(e, i, r, this);
        return this._renderTargetWrapperCache.push(o), o;
      }, t.prototype.createRenderTargetTexture = function(e, i) {
        var r = this._createHardwareRenderTargetWrapper(!1, !1, e), o = {};
        i !== void 0 && typeof i == "object" ? (o.generateMipMaps = i.generateMipMaps, o.generateDepthBuffer = i.generateDepthBuffer === void 0 || i.generateDepthBuffer, o.generateStencilBuffer = o.generateDepthBuffer && i.generateStencilBuffer, o.type = i.type === void 0 ? _.TEXTURETYPE_UNSIGNED_INT : i.type, o.samplingMode = i.samplingMode === void 0 ? _.TEXTURE_TRILINEAR_SAMPLINGMODE : i.samplingMode) : (o.generateMipMaps = i, o.generateDepthBuffer = !0, o.generateStencilBuffer = !1, o.type = _.TEXTURETYPE_UNSIGNED_INT, o.samplingMode = _.TEXTURE_TRILINEAR_SAMPLINGMODE);
        var a = new Ut(this, ut.RenderTarget), s = e.width || e, l = e.height || e;
        return r._generateDepthBuffer = o.generateDepthBuffer, r._generateStencilBuffer = !!o.generateStencilBuffer, a.baseWidth = s, a.baseHeight = l, a.width = s, a.height = l, a.isReady = !0, a.samples = 1, a.generateMipMaps = !!o.generateMipMaps, a.samplingMode = o.samplingMode, a.type = o.type, this._internalTexturesCache.push(a), r;
      }, t.prototype.createRenderTargetCubeTexture = function(e, i) {
        var r = this._createHardwareRenderTargetWrapper(!1, !0, e), o = je({ generateMipMaps: !0, generateDepthBuffer: !0, generateStencilBuffer: !1, type: _.TEXTURETYPE_UNSIGNED_INT, samplingMode: _.TEXTURE_TRILINEAR_SAMPLINGMODE, format: _.TEXTUREFORMAT_RGBA }, i);
        o.generateStencilBuffer = o.generateDepthBuffer && o.generateStencilBuffer, (o.type !== _.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (o.type !== _.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (o.samplingMode = _.TEXTURE_NEAREST_SAMPLINGMODE), r._generateDepthBuffer = o.generateDepthBuffer, r._generateStencilBuffer = !!o.generateStencilBuffer;
        var a = new Ut(this, ut.RenderTarget);
        return a.baseWidth = e, a.baseHeight = e, a.width = e, a.height = e, a.isReady = !0, a.isCube = !0, a.samples = 1, a.generateMipMaps = !!o.generateMipMaps, a.samplingMode = o.samplingMode, a.type = o.type, this._internalTexturesCache.push(a), r;
      }, t.prototype.updateTextureSamplingMode = function(e, i) {
        i.samplingMode = e;
      }, t.prototype.createRawTexture = function(e, i, r, o, a, s, l, c, u, h, d) {
        c === void 0 && (c = null), u === void 0 && (u = _.TEXTURETYPE_UNSIGNED_INT), d === void 0 && (d = !1);
        var p = new Ut(this, ut.Raw);
        return p.baseWidth = i, p.baseHeight = r, p.width = i, p.height = r, p.format = o, p.generateMipMaps = a, p.samplingMode = l, p.invertY = s, p._compression = c, p.type = u, p._useSRGBBuffer = d, this._doNotHandleContextLost || (p._bufferView = e), p;
      }, t.prototype.updateRawTexture = function(e, i, r, o, a, s, l) {
        a === void 0 && (a = null), s === void 0 && (s = _.TEXTURETYPE_UNSIGNED_INT), l === void 0 && (l = !1), e && (e._bufferView = i, e.format = r, e.invertY = o, e._compression = a, e.type = s, e._useSRGBBuffer = l);
      }, t.prototype.bindFramebuffer = function(e, i, r, o, a) {
        this._currentRenderTarget && this.unBindFramebuffer(this._currentRenderTarget), this._currentRenderTarget = e, this._currentFramebuffer = null, this._cachedViewport && !a && this.setViewport(this._cachedViewport, r, o);
      }, t.prototype.unBindFramebuffer = function(e, i, r) {
        this._currentRenderTarget = null, r && r(), this._currentFramebuffer = null;
      }, t.prototype.createDynamicVertexBuffer = function(e) {
        var i = new wa();
        return i.references = 1, i.capacity = 1, i;
      }, t.prototype.updateDynamicTexture = function(e, i, r, o, a) {
      }, t.prototype.areAllEffectsReady = function() {
        return !0;
      }, t.prototype.getError = function() {
        return 0;
      }, t.prototype._getUnpackAlignement = function() {
        return 1;
      }, t.prototype._unpackFlipY = function(e) {
      }, t.prototype.updateDynamicIndexBuffer = function(e, i, r) {
      }, t.prototype.updateDynamicVertexBuffer = function(e, i, r, o) {
      }, t.prototype._bindTextureDirectly = function(e, i) {
        return this._boundTexturesCache[this._activeChannel] !== i && (this._boundTexturesCache[this._activeChannel] = i, !0);
      }, t.prototype._bindTexture = function(e, i) {
        e < 0 || this._bindTextureDirectly(0, i);
      }, t.prototype._deleteBuffer = function(e) {
      }, t.prototype.releaseEffects = function() {
      }, t.prototype.displayLoadingUI = function() {
      }, t.prototype.hideLoadingUI = function() {
      }, Object.defineProperty(t.prototype, "loadingUIText", { set: function(e) {
      }, enumerable: !1, configurable: !0 }), t.prototype._uploadCompressedDataToTextureDirectly = function(e, i, r, o, a, s, l) {
      }, t.prototype._uploadDataToTextureDirectly = function(e, i, r, o) {
      }, t.prototype._uploadArrayBufferViewToTexture = function(e, i, r, o) {
      }, t.prototype._uploadImageToTexture = function(e, i, r, o) {
      }, t;
    }(ve);
    Qe.prototype._debugPushGroup = function(n, t) {
    }, Qe.prototype._debugPopGroup = function(n) {
    }, Qe.prototype._debugInsertMarker = function(n, t) {
    }, Qe.prototype._debugFlushPendingCommands = function() {
    };
    var Wv = function() {
      this._timeElapsedQueryEnded = !1;
    }, Hv = function() {
      this.occlusionInternalRetryCounter = 0, this.isOcclusionQueryInProgress = !1, this.isOccluded = !1, this.occlusionRetryCount = -1, this.occlusionType = Dt.OCCLUSION_TYPE_NONE, this.occlusionQueryAlgorithmType = Dt.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE, this.forceRenderingWhenOccluded = !1;
    };
    ve.prototype.createQuery = function() {
      var n = this._gl.createQuery();
      if (!n)
        throw new Error("Unable to create Occlusion Query");
      return n;
    }, ve.prototype.deleteQuery = function(n) {
      return this._gl.deleteQuery(n), this;
    }, ve.prototype.isQueryResultAvailable = function(n) {
      return this._gl.getQueryParameter(n, this._gl.QUERY_RESULT_AVAILABLE);
    }, ve.prototype.getQueryResult = function(n) {
      return this._gl.getQueryParameter(n, this._gl.QUERY_RESULT);
    }, ve.prototype.beginOcclusionQuery = function(n, t) {
      var e = this._getGlAlgorithmType(n);
      return this._gl.beginQuery(e, t), !0;
    }, ve.prototype.endOcclusionQuery = function(n) {
      var t = this._getGlAlgorithmType(n);
      return this._gl.endQuery(t), this;
    }, ve.prototype._createTimeQuery = function() {
      var n = this.getCaps().timerQuery;
      return n.createQueryEXT ? n.createQueryEXT() : this.createQuery();
    }, ve.prototype._deleteTimeQuery = function(n) {
      var t = this.getCaps().timerQuery;
      t.deleteQueryEXT ? t.deleteQueryEXT(n) : this.deleteQuery(n);
    }, ve.prototype._getTimeQueryResult = function(n) {
      var t = this.getCaps().timerQuery;
      return t.getQueryObjectEXT ? t.getQueryObjectEXT(n, t.QUERY_RESULT_EXT) : this.getQueryResult(n);
    }, ve.prototype._getTimeQueryAvailability = function(n) {
      var t = this.getCaps().timerQuery;
      return t.getQueryObjectEXT ? t.getQueryObjectEXT(n, t.QUERY_RESULT_AVAILABLE_EXT) : this.isQueryResultAvailable(n);
    }, ve.prototype.startTimeQuery = function() {
      var n = this.getCaps(), t = n.timerQuery;
      if (!t)
        return null;
      var e = new Wv();
      if (this._gl.getParameter(t.GPU_DISJOINT_EXT), n.canUseTimestampForTimerQuery)
        e._startTimeQuery = this._createTimeQuery(), t.queryCounterEXT(e._startTimeQuery, t.TIMESTAMP_EXT);
      else {
        if (this._currentNonTimestampToken)
          return this._currentNonTimestampToken;
        e._timeElapsedQuery = this._createTimeQuery(), t.beginQueryEXT ? t.beginQueryEXT(t.TIME_ELAPSED_EXT, e._timeElapsedQuery) : this._gl.beginQuery(t.TIME_ELAPSED_EXT, e._timeElapsedQuery), this._currentNonTimestampToken = e;
      }
      return e;
    }, ve.prototype.endTimeQuery = function(n) {
      var t = this.getCaps(), e = t.timerQuery;
      if (!e || !n)
        return -1;
      if (t.canUseTimestampForTimerQuery) {
        if (!n._startTimeQuery)
          return -1;
        n._endTimeQuery || (n._endTimeQuery = this._createTimeQuery(), e.queryCounterEXT(n._endTimeQuery, e.TIMESTAMP_EXT));
      } else if (!n._timeElapsedQueryEnded) {
        if (!n._timeElapsedQuery)
          return -1;
        e.endQueryEXT ? e.endQueryEXT(e.TIME_ELAPSED_EXT) : (this._gl.endQuery(e.TIME_ELAPSED_EXT), this._currentNonTimestampToken = null), n._timeElapsedQueryEnded = !0;
      }
      var i = this._gl.getParameter(e.GPU_DISJOINT_EXT), r = !1;
      if (n._endTimeQuery ? r = this._getTimeQueryAvailability(n._endTimeQuery) : n._timeElapsedQuery && (r = this._getTimeQueryAvailability(n._timeElapsedQuery)), r && !i) {
        var o = 0;
        if (t.canUseTimestampForTimerQuery) {
          if (!n._startTimeQuery || !n._endTimeQuery)
            return -1;
          var a = this._getTimeQueryResult(n._startTimeQuery);
          o = this._getTimeQueryResult(n._endTimeQuery) - a, this._deleteTimeQuery(n._startTimeQuery), this._deleteTimeQuery(n._endTimeQuery), n._startTimeQuery = null, n._endTimeQuery = null;
        } else {
          if (!n._timeElapsedQuery)
            return -1;
          o = this._getTimeQueryResult(n._timeElapsedQuery), this._deleteTimeQuery(n._timeElapsedQuery), n._timeElapsedQuery = null, n._timeElapsedQueryEnded = !1;
        }
        return o;
      }
      return -1;
    }, ve.prototype._captureGPUFrameTime = !1, ve.prototype._gpuFrameTime = new Sn(), ve.prototype.getGPUFrameTimeCounter = function() {
      return this._gpuFrameTime;
    }, ve.prototype.captureGPUFrameTime = function(n) {
      var t = this;
      n !== this._captureGPUFrameTime && (this._captureGPUFrameTime = n, n ? (this._onBeginFrameObserver = this.onBeginFrameObservable.add(function() {
        t._gpuFrameTimeToken || (t._gpuFrameTimeToken = t.startTimeQuery());
      }), this._onEndFrameObserver = this.onEndFrameObservable.add(function() {
        if (t._gpuFrameTimeToken) {
          var e = t.endTimeQuery(t._gpuFrameTimeToken);
          e > -1 && (t._gpuFrameTimeToken = null, t._gpuFrameTime.fetchNewFrame(), t._gpuFrameTime.addCount(e, !0));
        }
      })) : (this.onBeginFrameObservable.remove(this._onBeginFrameObserver), this._onBeginFrameObserver = null, this.onEndFrameObservable.remove(this._onEndFrameObserver), this._onEndFrameObserver = null));
    }, ve.prototype._getGlAlgorithmType = function(n) {
      return n === Dt.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED;
    }, Object.defineProperty(Dt.prototype, "isOcclusionQueryInProgress", { get: function() {
      return this._occlusionDataStorage.isOcclusionQueryInProgress;
    }, set: function(n) {
      this._occlusionDataStorage.isOcclusionQueryInProgress = n;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(Dt.prototype, "_occlusionDataStorage", { get: function() {
      return this.__occlusionDataStorage || (this.__occlusionDataStorage = new Hv()), this.__occlusionDataStorage;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(Dt.prototype, "isOccluded", { get: function() {
      return this._occlusionDataStorage.isOccluded;
    }, set: function(n) {
      this._occlusionDataStorage.isOccluded = n;
    }, enumerable: !0, configurable: !0 }), Object.defineProperty(Dt.prototype, "occlusionQueryAlgorithmType", { get: function() {
      return this._occlusionDataStorage.occlusionQueryAlgorithmType;
    }, set: function(n) {
      this._occlusionDataStorage.occlusionQueryAlgorithmType = n;
    }, enumerable: !0, configurable: !0 }), Object.defineProperty(Dt.prototype, "occlusionType", { get: function() {
      return this._occlusionDataStorage.occlusionType;
    }, set: function(n) {
      this._occlusionDataStorage.occlusionType = n;
    }, enumerable: !0, configurable: !0 }), Object.defineProperty(Dt.prototype, "occlusionRetryCount", { get: function() {
      return this._occlusionDataStorage.occlusionRetryCount;
    }, set: function(n) {
      this._occlusionDataStorage.occlusionRetryCount = n;
    }, enumerable: !0, configurable: !0 }), Object.defineProperty(Dt.prototype, "forceRenderingWhenOccluded", { get: function() {
      return this._occlusionDataStorage.forceRenderingWhenOccluded;
    }, set: function(n) {
      this._occlusionDataStorage.forceRenderingWhenOccluded = n;
    }, enumerable: !0, configurable: !0 }), Dt.prototype._checkOcclusionQuery = function() {
      var n = this._occlusionDataStorage;
      if (n.occlusionType === Dt.OCCLUSION_TYPE_NONE)
        return n.isOccluded = !1, !1;
      var t = this.getEngine();
      if (!t.getCaps().supportOcclusionQuery || !t.isQueryResultAvailable)
        return n.isOccluded = !1, !1;
      if (this.isOcclusionQueryInProgress && this._occlusionQuery !== null && this._occlusionQuery !== void 0)
        if (t.isQueryResultAvailable(this._occlusionQuery)) {
          var e = t.getQueryResult(this._occlusionQuery);
          n.isOcclusionQueryInProgress = !1, n.occlusionInternalRetryCounter = 0, n.isOccluded = !(e > 0);
        } else {
          if (n.occlusionInternalRetryCounter++, !(n.occlusionRetryCount !== -1 && n.occlusionInternalRetryCounter > n.occlusionRetryCount))
            return n.occlusionType !== Dt.OCCLUSION_TYPE_OPTIMISTIC && n.isOccluded;
          n.isOcclusionQueryInProgress = !1, n.occlusionInternalRetryCounter = 0, n.isOccluded = n.occlusionType !== Dt.OCCLUSION_TYPE_OPTIMISTIC && n.isOccluded;
        }
      var i = this.getScene();
      if (i.getBoundingBoxRenderer) {
        var r = i.getBoundingBoxRenderer();
        this._occlusionQuery === null && (this._occlusionQuery = t.createQuery()), t.beginOcclusionQuery(n.occlusionQueryAlgorithmType, this._occlusionQuery) && (r.renderOcclusionBoundingBox(this), t.endOcclusionQuery(n.occlusionQueryAlgorithmType), this._occlusionDataStorage.isOcclusionQueryInProgress = !0);
      }
      return n.isOccluded;
    };
    var hC = !0;
    ve.prototype.createTransformFeedback = function() {
      var n = this._gl.createTransformFeedback();
      if (!n)
        throw new Error("Unable to create Transform Feedback");
      return n;
    }, ve.prototype.deleteTransformFeedback = function(n) {
      this._gl.deleteTransformFeedback(n);
    }, ve.prototype.bindTransformFeedback = function(n) {
      this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK, n);
    }, ve.prototype.beginTransformFeedback = function(n) {
      n === void 0 && (n = !0), this._gl.beginTransformFeedback(n ? this._gl.POINTS : this._gl.TRIANGLES);
    }, ve.prototype.endTransformFeedback = function() {
      this._gl.endTransformFeedback();
    }, ve.prototype.setTranformFeedbackVaryings = function(n, t) {
      this._gl.transformFeedbackVaryings(n, t, this._gl.INTERLEAVED_ATTRIBS);
    }, ve.prototype.bindTransformFeedbackBuffer = function(n) {
      this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER, 0, n ? n.underlyingResource : null);
    }, Qe.prototype.createExternalTexture = function(n) {
      return null;
    }, Qe.prototype.setExternalTexture = function(n, t) {
      throw new Error("setExternalTexture: This engine does not support external textures!");
    }, Qe.prototype.updateVideoTexture = function(n, t, e) {
      if (n && !n._isDisabled) {
        var i = this._getInternalFormat(n.format), r = this._getRGBABufferInternalSizedFormat(_.TEXTURETYPE_UNSIGNED_BYTE, n.format), o = this._bindTextureDirectly(this._gl.TEXTURE_2D, n, !0);
        this._unpackFlipY(!e);
        try {
          if (this._videoTextureSupported === void 0 && (this._gl.getError(), this._gl.texImage2D(this._gl.TEXTURE_2D, 0, r, i, this._gl.UNSIGNED_BYTE, t), this._gl.getError() !== 0 ? this._videoTextureSupported = !1 : this._videoTextureSupported = !0), this._videoTextureSupported)
            this._gl.texImage2D(this._gl.TEXTURE_2D, 0, r, i, this._gl.UNSIGNED_BYTE, t);
          else {
            if (!n._workingCanvas) {
              n._workingCanvas = this.createCanvas(n.width, n.height);
              var a = n._workingCanvas.getContext("2d");
              if (!a)
                throw new Error("Unable to get 2d context");
              n._workingContext = a, n._workingCanvas.width = n.width, n._workingCanvas.height = n.height;
            }
            n._workingContext.clearRect(0, 0, n.width, n.height), n._workingContext.drawImage(t, 0, 0, t.videoWidth, t.videoHeight, 0, 0, n.width, n.height), this._gl.texImage2D(this._gl.TEXTURE_2D, 0, r, i, this._gl.UNSIGNED_BYTE, n._workingCanvas);
          }
          n.generateMipMaps && this._gl.generateMipmap(this._gl.TEXTURE_2D), o || this._bindTextureDirectly(this._gl.TEXTURE_2D, null), n.isReady = !0;
        } catch {
          n._isDisabled = !0;
        }
      }
    }, Qe.prototype.restoreSingleAttachment = function() {
      var n = this._gl;
      this.bindAttachments([n.BACK]);
    }, Qe.prototype.restoreSingleAttachmentForRenderTarget = function() {
      var n = this._gl;
      this.bindAttachments([n.COLOR_ATTACHMENT0]);
    }, Qe.prototype.buildTextureLayout = function(n) {
      for (var t = this._gl, e = [], i = 0; i < n.length; i++)
        n[i] ? e.push(t["COLOR_ATTACHMENT" + i]) : e.push(t.NONE);
      return e;
    }, Qe.prototype.bindAttachments = function(n) {
      this._gl.drawBuffers(n);
    }, Qe.prototype.unBindMultiColorAttachmentFramebuffer = function(n, t, e) {
      t === void 0 && (t = !1), this._currentRenderTarget = null;
      var i = this._gl, r = n._attachments, o = r.length;
      if (n._MSAAFramebuffer) {
        i.bindFramebuffer(i.READ_FRAMEBUFFER, n._MSAAFramebuffer), i.bindFramebuffer(i.DRAW_FRAMEBUFFER, n._framebuffer);
        for (var a = 0; a < o; a++) {
          for (var s = n.textures[a], l = 0; l < o; l++)
            r[l] = i.NONE;
          r[a] = i[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + a : "COLOR_ATTACHMENT" + a + "_WEBGL"], i.readBuffer(r[a]), i.drawBuffers(r), i.blitFramebuffer(0, 0, s.width, s.height, 0, 0, s.width, s.height, i.COLOR_BUFFER_BIT, i.NEAREST);
        }
        for (a = 0; a < o; a++)
          r[a] = i[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + a : "COLOR_ATTACHMENT" + a + "_WEBGL"];
        i.drawBuffers(r);
      }
      for (a = 0; a < o; a++)
        !((s = n.textures[a]) != null && s.generateMipMaps) || t || s.isCube || (this._bindTextureDirectly(i.TEXTURE_2D, s, !0), i.generateMipmap(i.TEXTURE_2D), this._bindTextureDirectly(i.TEXTURE_2D, null));
      e && (n._MSAAFramebuffer && this._bindUnboundFramebuffer(n._framebuffer), e()), this._bindUnboundFramebuffer(null);
    }, Qe.prototype.createMultipleRenderTarget = function(n, t, e) {
      var i;
      e === void 0 && (e = !0);
      var r = !1, o = !0, a = !1, s = !1, l = _.TEXTUREFORMAT_DEPTH16, c = 1, u = _.TEXTURETYPE_UNSIGNED_INT, h = _.TEXTURE_TRILINEAR_SAMPLINGMODE, d = _.TEXTUREFORMAT_RGBA, p = _.TEXTURE_2D, f = [], m = [], g = [], y = [], b = [], T = [], S = [], E = [], A = this._createHardwareRenderTargetWrapper(!0, !1, n);
      t !== void 0 && (r = t.generateMipMaps !== void 0 && t.generateMipMaps, o = t.generateDepthBuffer === void 0 || t.generateDepthBuffer, a = t.generateStencilBuffer !== void 0 && t.generateStencilBuffer, s = t.generateDepthTexture !== void 0 && t.generateDepthTexture, c = t.textureCount || 1, t.types && (f = t.types), t.samplingModes && (m = t.samplingModes), t.useSRGBBuffers && (g = t.useSRGBBuffers), t.formats && (y = t.formats), t.targetTypes && (b = t.targetTypes), t.faceIndex && (T = t.faceIndex), t.layerIndex && (S = t.layerIndex), t.layerCounts && (E = t.layerCounts), this.webGLVersion > 1 && (t.depthTextureFormat === _.TEXTUREFORMAT_DEPTH24_STENCIL8 || t.depthTextureFormat === _.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8 || t.depthTextureFormat === _.TEXTUREFORMAT_DEPTH24 || t.depthTextureFormat === _.TEXTUREFORMAT_DEPTH32_FLOAT || t.depthTextureFormat === _.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8) && (l = t.depthTextureFormat));
      var R = this._gl, C = R.createFramebuffer();
      this._bindUnboundFramebuffer(C);
      var L = n.width || n, I = n.height || n, O = [], w = [], z = this.webGLVersion > 1 && s && (t.depthTextureFormat === _.TEXTUREFORMAT_DEPTH24_STENCIL8 || t.depthTextureFormat === _.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8 || t.depthTextureFormat === _.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8), V = this._setupFramebufferDepthAttachments(!z && a, !s && o, L, I);
      A._framebuffer = C, A._depthStencilBuffer = V, A._generateDepthBuffer = !s && o, A._generateStencilBuffer = !z && a, A._attachments = w;
      for (var Y = 0; Y < c; Y++) {
        var ee = m[Y] || h, J = f[Y] || u, X = g[Y] || !1, K = y[Y] || d, te = b[Y] || p, se = (i = E[Y]) !== null && i !== void 0 ? i : 1;
        (J !== _.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (J !== _.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (ee = _.TEXTURE_NEAREST_SAMPLINGMODE);
        var _e = this._getSamplingParameters(ee, r);
        J !== _.TEXTURETYPE_FLOAT || this._caps.textureFloat || (J = _.TEXTURETYPE_UNSIGNED_INT, q.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")), X = X && this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || this.isWebGPU);
        var xe = this.webGLVersion > 1, Te = R[xe ? "COLOR_ATTACHMENT" + Y : "COLOR_ATTACHMENT" + Y + "_WEBGL"];
        if (w.push(Te), te !== -1) {
          var he = new Ut(this, ut.MultiRenderTarget);
          O[Y] = he, R.activeTexture(R["TEXTURE" + Y]), R.bindTexture(te, he._hardwareTexture.underlyingResource), R.texParameteri(te, R.TEXTURE_MAG_FILTER, _e.mag), R.texParameteri(te, R.TEXTURE_MIN_FILTER, _e.min), R.texParameteri(te, R.TEXTURE_WRAP_S, R.CLAMP_TO_EDGE), R.texParameteri(te, R.TEXTURE_WRAP_T, R.CLAMP_TO_EDGE);
          var me = this._getRGBABufferInternalSizedFormat(J, K, X), Fe = this._getInternalFormat(K), Ce = this._getWebGLTextureType(J);
          if (!xe || te !== _.TEXTURE_2D_ARRAY && te !== _.TEXTURE_3D)
            if (te === _.TEXTURE_CUBE_MAP) {
              for (var Re = 0; Re < 6; Re++)
                R.texImage2D(R.TEXTURE_CUBE_MAP_POSITIVE_X + Re, 0, me, L, I, 0, Fe, Ce, null);
              he.isCube = !0;
            } else
              R.texImage2D(R.TEXTURE_2D, 0, me, L, I, 0, Fe, Ce, null);
          else
            te === _.TEXTURE_2D_ARRAY ? he.is2DArray = !0 : he.is3D = !0, he.baseDepth = he.depth = se, R.texImage3D(te, 0, me, L, I, se, 0, Fe, Ce, null);
          r && R.generateMipmap(te), this._bindTextureDirectly(te, null), he.baseWidth = L, he.baseHeight = I, he.width = L, he.height = I, he.isReady = !0, he.samples = 1, he.generateMipMaps = r, he.samplingMode = ee, he.type = J, he._useSRGBBuffer = X, he.format = K, this._internalTexturesCache.push(he);
        }
      }
      if (s && this._caps.depthTextureExtension) {
        var Be = new Ut(this, ut.Depth), De = _.TEXTURETYPE_UNSIGNED_SHORT, Ke = R.DEPTH_COMPONENT16, ge = R.DEPTH_COMPONENT, rt = R.UNSIGNED_SHORT, it = R.DEPTH_ATTACHMENT;
        this.webGLVersion < 2 ? Ke = R.DEPTH_COMPONENT : l === _.TEXTUREFORMAT_DEPTH32_FLOAT ? (De = _.TEXTURETYPE_FLOAT, rt = R.FLOAT, Ke = R.DEPTH_COMPONENT32F) : l === _.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8 ? (De = _.TEXTURETYPE_UNSIGNED_INT, rt = R.FLOAT_32_UNSIGNED_INT_24_8_REV, Ke = R.DEPTH32F_STENCIL8, ge = R.DEPTH_STENCIL, it = R.DEPTH_STENCIL_ATTACHMENT) : l === _.TEXTUREFORMAT_DEPTH24 ? (De = _.TEXTURETYPE_UNSIGNED_INT, rt = R.UNSIGNED_INT, Ke = R.DEPTH_COMPONENT24, it = R.DEPTH_ATTACHMENT) : l !== _.TEXTUREFORMAT_DEPTH24_STENCIL8 && l !== _.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8 || (De = _.TEXTURETYPE_UNSIGNED_INT_24_8, rt = R.UNSIGNED_INT_24_8, Ke = R.DEPTH24_STENCIL8, ge = R.DEPTH_STENCIL, it = R.DEPTH_STENCIL_ATTACHMENT), R.activeTexture(R.TEXTURE0), R.bindTexture(R.TEXTURE_2D, Be._hardwareTexture.underlyingResource), R.texParameteri(R.TEXTURE_2D, R.TEXTURE_MAG_FILTER, R.NEAREST), R.texParameteri(R.TEXTURE_2D, R.TEXTURE_MIN_FILTER, R.NEAREST), R.texParameteri(R.TEXTURE_2D, R.TEXTURE_WRAP_S, R.CLAMP_TO_EDGE), R.texParameteri(R.TEXTURE_2D, R.TEXTURE_WRAP_T, R.CLAMP_TO_EDGE), R.texImage2D(R.TEXTURE_2D, 0, Ke, L, I, 0, ge, rt, null), R.framebufferTexture2D(R.FRAMEBUFFER, it, R.TEXTURE_2D, Be._hardwareTexture.underlyingResource, 0), Be.baseWidth = L, Be.baseHeight = I, Be.width = L, Be.height = I, Be.isReady = !0, Be.samples = 1, Be.generateMipMaps = r, Be.samplingMode = _.TEXTURE_NEAREST_SAMPLINGMODE, Be.format = l, Be.type = De, O[c] = Be, this._internalTexturesCache.push(Be);
      }
      return A.setTextures(O), e && R.drawBuffers(w), this._bindUnboundFramebuffer(null), A.setLayerAndFaceIndices(S, T), this.resetTextureCache(), A;
    }, Qe.prototype.updateMultipleRenderTargetTextureSampleCount = function(n, t, e) {
      if (e === void 0 && (e = !0), this.webGLVersion < 2 || !n || !n.texture)
        return 1;
      if (n.samples === t)
        return t;
      var i = n._attachments.length;
      if (i === 0)
        return 1;
      var r = this._gl;
      t = Math.min(t, this.getCaps().maxMSAASamples);
      var o = !!n._depthStencilBuffer;
      if (o && (r.deleteRenderbuffer(n._depthStencilBuffer), n._depthStencilBuffer = null), n._MSAAFramebuffer && (r.deleteFramebuffer(n._MSAAFramebuffer), n._MSAAFramebuffer = null), t > 1 && typeof r.renderbufferStorageMultisample == "function") {
        var a = r.createFramebuffer();
        if (!a)
          throw new Error("Unable to create multi sampled framebuffer");
        n._MSAAFramebuffer = a, this._bindUnboundFramebuffer(a);
        for (var s = [], l = 0; l < i; l++)
          (u = (c = n.textures[l])._hardwareTexture).releaseMSAARenderBuffers();
        for (l = 0; l < i; l++) {
          var c, u = (c = n.textures[l])._hardwareTexture, h = r[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + l : "COLOR_ATTACHMENT" + l + "_WEBGL"], d = this._createRenderBuffer(c.width, c.height, t, -1, this._getRGBAMultiSampleBufferFormat(c.type, c.format), h);
          if (!d)
            throw new Error("Unable to create multi sampled framebuffer");
          u.addMSAARenderBuffer(d), c.samples = t, s.push(h);
        }
        e && r.drawBuffers(s);
      } else
        this._bindUnboundFramebuffer(n._framebuffer);
      return o && (n._depthStencilBuffer = this._setupFramebufferDepthAttachments(n._generateStencilBuffer, n._generateDepthBuffer, n.texture.width, n.texture.height, t)), this._bindUnboundFramebuffer(null), t;
    }, Qe.prototype._createDepthStencilCubeTexture = function(n, t, e) {
      var i = new Ut(this, ut.DepthStencil);
      if (i.isCube = !0, this.webGLVersion === 1)
        return q.Error("Depth cube texture is not supported by WebGL 1."), i;
      var r = je({ bilinearFiltering: !1, comparisonFunction: 0, generateStencil: !1 }, t), o = this._gl;
      this._bindTextureDirectly(o.TEXTURE_CUBE_MAP, i, !0), this._setupDepthStencilTexture(i, n, r.generateStencil, r.bilinearFiltering, r.comparisonFunction), e._depthStencilTexture = i, e._depthStencilTextureWithStencil = r.generateStencil;
      for (var a = 0; a < 6; a++)
        r.generateStencil ? o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X + a, 0, o.DEPTH24_STENCIL8, n, n, 0, o.DEPTH_STENCIL, o.UNSIGNED_INT_24_8, null) : o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X + a, 0, o.DEPTH_COMPONENT24, n, n, 0, o.DEPTH_COMPONENT, o.UNSIGNED_INT, null);
      return this._bindTextureDirectly(o.TEXTURE_CUBE_MAP, null), this._internalTexturesCache.push(i), i;
    }, Qe.prototype._partialLoadFile = function(n, t, e, i, r) {
      r === void 0 && (r = null), this._loadFile(n, function(o) {
        e[t] = o, e._internalCount++, e._internalCount === 6 && i(e);
      }, void 0, void 0, !0, function(o, a) {
        r && o && r(o.status + " " + o.statusText, a);
      });
    }, Qe.prototype._cascadeLoadFiles = function(n, t, e, i) {
      i === void 0 && (i = null);
      var r = [];
      r._internalCount = 0;
      for (var o = 0; o < 6; o++)
        this._partialLoadFile(e[o], o, r, t, i);
    }, Qe.prototype._cascadeLoadImgs = function(n, t, e, i, r, o) {
      r === void 0 && (r = null);
      var a = [];
      a._internalCount = 0;
      for (var s = 0; s < 6; s++)
        this._partialLoadImg(i[s], s, a, n, t, e, r, o);
    }, Qe.prototype._partialLoadImg = function(n, t, e, i, r, o, a, s) {
      a === void 0 && (a = null);
      var l = ra();
      rl(n, function(c) {
        e[t] = c, e._internalCount++, i && i.removePendingData(l), e._internalCount === 6 && o && o(r, e);
      }, function(c, u) {
        i && i.removePendingData(l), a && a(c, u);
      }, i ? i.offlineProvider : null, s), i && i.addPendingData(l);
    }, Qe.prototype._setCubeMapTextureParams = function(n, t, e) {
      var i = this._gl;
      i.texParameteri(i.TEXTURE_CUBE_MAP, i.TEXTURE_MAG_FILTER, i.LINEAR), i.texParameteri(i.TEXTURE_CUBE_MAP, i.TEXTURE_MIN_FILTER, t ? i.LINEAR_MIPMAP_LINEAR : i.LINEAR), i.texParameteri(i.TEXTURE_CUBE_MAP, i.TEXTURE_WRAP_S, i.CLAMP_TO_EDGE), i.texParameteri(i.TEXTURE_CUBE_MAP, i.TEXTURE_WRAP_T, i.CLAMP_TO_EDGE), n.samplingMode = t ? _.TEXTURE_TRILINEAR_SAMPLINGMODE : _.TEXTURE_LINEAR_LINEAR, t && this.getCaps().textureMaxLevel && e !== void 0 && e > 0 && (i.texParameteri(i.TEXTURE_CUBE_MAP, i.TEXTURE_MAX_LEVEL, e), n._maxLodLevel = e), this._bindTextureDirectly(i.TEXTURE_CUBE_MAP, null);
    }, Qe.prototype.createCubeTextureBase = function(n, t, e, i, r, o, a, s, l, c, u, h, d, p, f) {
      var m = this;
      r === void 0 && (r = null), o === void 0 && (o = null), s === void 0 && (s = null), l === void 0 && (l = !1), c === void 0 && (c = 0), u === void 0 && (u = 0), h === void 0 && (h = null), d === void 0 && (d = null), p === void 0 && (p = null), f === void 0 && (f = !1);
      var g = h || new Ut(this, ut.Cube);
      g.isCube = !0, g.url = n, g.generateMipMaps = !i, g._lodGenerationScale = c, g._lodGenerationOffset = u, g._useSRGBBuffer = !!f && this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || this.isWebGPU || !!i), g !== h && (g.label = n.substring(0, 60)), this._doNotHandleContextLost || (g._extension = s, g._files = e);
      var y = n;
      this._transformTextureUrl && !h && (n = this._transformTextureUrl(n));
      for (var b = n.split("?")[0], T = b.lastIndexOf("."), S = s || (T > -1 ? b.substring(T).toLowerCase() : ""), E = null, A = 0, R = Qe._TextureLoaders; A < R.length; A++) {
        var C = R[A];
        if (C.canLoad(S)) {
          E = C;
          break;
        }
      }
      if (E) {
        var L = function(I) {
          d && d(g, I), E.loadCubeData(I, g, l, r, o);
        };
        e && e.length === 6 ? E.supportCascades ? this._cascadeLoadFiles(t, function(I) {
          return L(I.map(function(O) {
            return new Uint8Array(O);
          }));
        }, e, o) : o ? o("Textures type does not support cascades.") : q.Warn("Texture loader does not support cascades.") : this._loadFile(n, function(I) {
          return L(new Uint8Array(I));
        }, void 0, void 0, !0, function(I, O) {
          n === y ? o && I && o(I.status + " " + I.statusText, O) : (q.Warn("Failed to load ".concat(n, ", falling back to the ").concat(y)), m.createCubeTextureBase(y, t, e, !!i, r, o, a, s, l, c, u, g, d, p, f));
        });
      } else {
        if (!e)
          throw new Error("Cannot load cubemap because files were not defined");
        this._cascadeLoadImgs(t, g, function(I, O) {
          p && p(I, O);
        }, e, o);
      }
      return this._internalTexturesCache.push(g), g;
    }, Qe.prototype.createCubeTexture = function(n, t, e, i, r, o, a, s, l, c, u, h, d, p) {
      var f = this;
      r === void 0 && (r = null), o === void 0 && (o = null), s === void 0 && (s = null), l === void 0 && (l = !1), c === void 0 && (c = 0), u === void 0 && (u = 0), h === void 0 && (h = null), p === void 0 && (p = !1);
      var m = this._gl;
      return this.createCubeTextureBase(n, t, e, !!i, r, o, a, s, l, c, u, h, function(g) {
        return f._bindTextureDirectly(m.TEXTURE_CUBE_MAP, g, !0);
      }, function(g, y) {
        var b = f.needPOTTextures ? Qe.GetExponentOfTwo(y[0].width, f._caps.maxCubemapTextureSize) : y[0].width, T = b, S = [m.TEXTURE_CUBE_MAP_POSITIVE_X, m.TEXTURE_CUBE_MAP_POSITIVE_Y, m.TEXTURE_CUBE_MAP_POSITIVE_Z, m.TEXTURE_CUBE_MAP_NEGATIVE_X, m.TEXTURE_CUBE_MAP_NEGATIVE_Y, m.TEXTURE_CUBE_MAP_NEGATIVE_Z];
        f._bindTextureDirectly(m.TEXTURE_CUBE_MAP, g, !0), f._unpackFlipY(!1);
        var E = a ? f._getInternalFormat(a, g._useSRGBBuffer) : g._useSRGBBuffer ? f._glSRGBExtensionValues.SRGB8_ALPHA8 : m.RGBA, A = a ? f._getInternalFormat(a) : m.RGBA;
        g._useSRGBBuffer && f.webGLVersion === 1 && (A = E);
        for (var R = 0; R < S.length; R++)
          if (y[R].width !== b || y[R].height !== T) {
            if (f._prepareWorkingCanvas(), !f._workingCanvas || !f._workingContext)
              return void q.Warn("Cannot create canvas to resize texture.");
            f._workingCanvas.width = b, f._workingCanvas.height = T, f._workingContext.drawImage(y[R], 0, 0, y[R].width, y[R].height, 0, 0, b, T), m.texImage2D(S[R], 0, E, A, m.UNSIGNED_BYTE, f._workingCanvas);
          } else
            m.texImage2D(S[R], 0, E, A, m.UNSIGNED_BYTE, y[R]);
        i || m.generateMipmap(m.TEXTURE_CUBE_MAP), f._setCubeMapTextureParams(g, !i), g.width = b, g.height = T, g.isReady = !0, a && (g.format = a), g.onLoadedObservable.notifyObservers(g), g.onLoadedObservable.clear(), r && r();
      }, !!p);
    }, Qe.prototype.setTextureSampler = function(n, t) {
      throw new Error("setTextureSampler: This engine does not support separate texture sampler objects!");
    };
    var dC = function() {
    }, pC = new H(), fC = new H();
    function iD(n) {
      if (this._excludedCompressedTextures && this._excludedCompressedTextures.some(function(r) {
        var o = "\\b" + r + "\\b";
        return n && (n === r || n.match(new RegExp(o, "g")));
      }))
        return n;
      var t = n.lastIndexOf("."), e = n.lastIndexOf("?"), i = e > -1 ? n.substring(e, n.length) : "";
      return (t > -1 ? n.substring(0, t) : n) + this._textureFormatInUse + i;
    }
    Object.defineProperty(ve.prototype, "onBeforeViewRenderObservable", { get: function() {
      return pC;
    } }), Object.defineProperty(ve.prototype, "onAfterViewRenderObservable", { get: function() {
      return fC;
    } }), Object.defineProperty(ve.prototype, "inputElement", { get: function() {
      return this._inputElement;
    }, set: function(n) {
      var t;
      this._inputElement !== n && (this._inputElement = n, (t = this._onEngineViewChanged) === null || t === void 0 || t.call(this));
    } }), ve.prototype.getInputElement = function() {
      return this.inputElement || this.getRenderingCanvas();
    }, ve.prototype.registerView = function(n, t, e) {
      var i = this;
      this.views || (this.views = []);
      for (var r = 0, o = this.views; r < o.length; r++) {
        var a = o[r];
        if (a.target === n)
          return a;
      }
      var s = this.getRenderingCanvas();
      s && (n.width = s.width, n.height = s.height);
      var l = { target: n, camera: t, clearBeforeCopy: e, enabled: !0, id: (1e5 * Math.random()).toFixed() };
      return this.views.push(l), t && !Array.isArray(t) && t.onDisposeObservable.add(function() {
        i.unRegisterView(n);
      }), l;
    }, ve.prototype.unRegisterView = function(n) {
      if (!this.views || this.views.length === 0)
        return this;
      for (var t = 0, e = this.views; t < e.length; t++) {
        var i = e[t];
        if (i.target === n) {
          var r = this.views.indexOf(i);
          r !== -1 && this.views.splice(r, 1);
          break;
        }
      }
      return this;
    }, ve.prototype._renderViewStep = function(n) {
      var t = n.target, e = t.getContext("2d");
      if (!e)
        return !0;
      var i = this.getRenderingCanvas();
      pC.notifyObservers(n);
      var r = n.camera, o = null, a = null, s = null;
      if (r && (o = (s = Array.isArray(r) ? r[0].getScene() : r.getScene()).activeCamera, a = s.activeCameras, this.activeView = n, Array.isArray(r) ? s.activeCameras = r : (s.activeCamera = r, s.activeCameras = null)), n.customResize)
        n.customResize(t);
      else {
        var l = Math.floor(t.clientWidth / this._hardwareScalingLevel), c = Math.floor(t.clientHeight / this._hardwareScalingLevel), u = l !== t.width || i.width !== t.width || c !== t.height || i.height !== t.height;
        t.clientWidth && t.clientHeight && u && (t.width = l, t.height = c, this.setSize(l, c));
      }
      return !(!i.width || !i.height || (this._renderFrame(), this.flushFramebuffer(), n.clearBeforeCopy && e.clearRect(0, 0, i.width, i.height), e.drawImage(i, 0, 0), s && (s.activeCameras = a, s.activeCamera = o), fC.notifyObservers(n), 0));
    }, ve.prototype._renderViews = function() {
      if (!this.views || this.views.length === 0)
        return !1;
      var n;
      if (!this.getRenderingCanvas())
        return !1;
      for (var t = 0, e = this.views; t < e.length; t++) {
        var i = e[t];
        if (i.enabled)
          if (i.target !== this.inputElement) {
            if (!this._renderViewStep(i))
              return !1;
          } else
            n = i;
      }
      return !(n && !this._renderViewStep(n) || (this.activeView = null, 0));
    }, Qe.prototype.createStorageBuffer = function(n, t) {
      throw new Error("createStorageBuffer: Unsupported method in this engine!");
    }, Qe.prototype.updateStorageBuffer = function(n, t, e, i) {
    }, Qe.prototype.readFromStorageBuffer = function(n, t, e, i) {
      throw new Error("readFromStorageBuffer: Unsupported method in this engine!");
    }, Qe.prototype.setStorageBuffer = function(n, t) {
      throw new Error("setStorageBuffer: Unsupported method in this engine!");
    }, Object.defineProperty(ve.prototype, "texturesSupported", { get: function() {
      var n = [];
      return this._caps.astc && n.push("-astc.ktx"), this._caps.s3tc && n.push("-dxt.ktx"), this._caps.pvrtc && n.push("-pvrtc.ktx"), this._caps.etc2 && n.push("-etc2.ktx"), this._caps.etc1 && n.push("-etc1.ktx"), n;
    }, enumerable: !0, configurable: !0 }), Object.defineProperty(ve.prototype, "textureFormatInUse", { get: function() {
      return this._textureFormatInUse || null;
    }, enumerable: !0, configurable: !0 }), ve.prototype.setCompressedTextureExclusions = function(n) {
      this._excludedCompressedTextures = n;
    }, ve.prototype.setTextureFormatToUse = function(n) {
      for (var t = this.texturesSupported, e = 0, i = t.length; e < i; e++)
        for (var r = 0, o = n.length; r < o; r++)
          if (t[e] === n[r].toLowerCase())
            return this._transformTextureUrl = iD.bind(this), this._textureFormatInUse = t[e];
      return this._textureFormatInUse = "", this._transformTextureUrl = null, null;
    };
    var Bf, _C, Ih = function() {
      function n() {
        var t = this, e = new ArrayBuffer(n.DEFAULT_BUFFER_SIZE);
        this._uint32s = new Uint32Array(e), this._int32s = new Int32Array(e), this._float32s = new Float32Array(e), this._length = n.DEFAULT_BUFFER_SIZE / 4, this._position = 0, this._nativeDataStream = new _native.NativeDataStream(function() {
          t._flush();
        });
      }
      return n.prototype.writeUint32 = function(t) {
        this._flushIfNecessary(1), this._uint32s[this._position++] = t;
      }, n.prototype.writeInt32 = function(t) {
        this._flushIfNecessary(1), this._int32s[this._position++] = t;
      }, n.prototype.writeFloat32 = function(t) {
        this._flushIfNecessary(1), this._float32s[this._position++] = t;
      }, n.prototype.writeUint32Array = function(t) {
        this._flushIfNecessary(1 + t.length), this._uint32s[this._position++] = t.length, this._uint32s.set(t, this._position), this._position += t.length;
      }, n.prototype.writeInt32Array = function(t) {
        this._flushIfNecessary(1 + t.length), this._uint32s[this._position++] = t.length, this._int32s.set(t, this._position), this._position += t.length;
      }, n.prototype.writeFloat32Array = function(t) {
        this._flushIfNecessary(1 + t.length), this._uint32s[this._position++] = t.length, this._float32s.set(t, this._position), this._position += t.length;
      }, n.prototype.writeNativeData = function(t) {
        this._flushIfNecessary(t.length), this._uint32s.set(t, this._position), this._position += t.length;
      }, n.prototype.writeBoolean = function(t) {
        this.writeUint32(t ? 1 : 0);
      }, n.prototype._flushIfNecessary = function(t) {
        this._position + t > this._length && this._flush();
      }, n.prototype._flush = function() {
        this._nativeDataStream.writeBuffer(this._uint32s.buffer, this._position), this._position = 0;
      }, n.DEFAULT_BUFFER_SIZE = 65536, n;
    }(), fa = [Math.sqrt(1 / (4 * Math.PI)), -Math.sqrt(3 / (4 * Math.PI)), Math.sqrt(3 / (4 * Math.PI)), -Math.sqrt(3 / (4 * Math.PI)), Math.sqrt(15 / (4 * Math.PI)), -Math.sqrt(15 / (4 * Math.PI)), Math.sqrt(5 / (16 * Math.PI)), -Math.sqrt(15 / (4 * Math.PI)), Math.sqrt(15 / (16 * Math.PI))], nD = [function() {
      return 1;
    }, function(n) {
      return n.y;
    }, function(n) {
      return n.z;
    }, function(n) {
      return n.x;
    }, function(n) {
      return n.x * n.y;
    }, function(n) {
      return n.y * n.z;
    }, function(n) {
      return 3 * n.z * n.z - 1;
    }, function(n) {
      return n.x * n.z;
    }, function(n) {
      return n.x * n.x - n.y * n.y;
    }], Xa = function(n, t) {
      return fa[n] * nD[n](t);
    }, ja = [Math.PI, 2 * Math.PI / 3, 2 * Math.PI / 3, 2 * Math.PI / 3, Math.PI / 4, Math.PI / 4, Math.PI / 4, Math.PI / 4, Math.PI / 4], Mh = function() {
      function n() {
        this.preScaled = !1, this.l00 = v.Zero(), this.l1_1 = v.Zero(), this.l10 = v.Zero(), this.l11 = v.Zero(), this.l2_2 = v.Zero(), this.l2_1 = v.Zero(), this.l20 = v.Zero(), this.l21 = v.Zero(), this.l22 = v.Zero();
      }
      return n.prototype.addLight = function(t, e, i) {
        F.Vector3[0].set(e.r, e.g, e.b);
        var r = F.Vector3[0], o = F.Vector3[1];
        r.scaleToRef(i, o), o.scaleToRef(Xa(0, t), F.Vector3[2]), this.l00.addInPlace(F.Vector3[2]), o.scaleToRef(Xa(1, t), F.Vector3[2]), this.l1_1.addInPlace(F.Vector3[2]), o.scaleToRef(Xa(2, t), F.Vector3[2]), this.l10.addInPlace(F.Vector3[2]), o.scaleToRef(Xa(3, t), F.Vector3[2]), this.l11.addInPlace(F.Vector3[2]), o.scaleToRef(Xa(4, t), F.Vector3[2]), this.l2_2.addInPlace(F.Vector3[2]), o.scaleToRef(Xa(5, t), F.Vector3[2]), this.l2_1.addInPlace(F.Vector3[2]), o.scaleToRef(Xa(6, t), F.Vector3[2]), this.l20.addInPlace(F.Vector3[2]), o.scaleToRef(Xa(7, t), F.Vector3[2]), this.l21.addInPlace(F.Vector3[2]), o.scaleToRef(Xa(8, t), F.Vector3[2]), this.l22.addInPlace(F.Vector3[2]);
      }, n.prototype.scaleInPlace = function(t) {
        this.l00.scaleInPlace(t), this.l1_1.scaleInPlace(t), this.l10.scaleInPlace(t), this.l11.scaleInPlace(t), this.l2_2.scaleInPlace(t), this.l2_1.scaleInPlace(t), this.l20.scaleInPlace(t), this.l21.scaleInPlace(t), this.l22.scaleInPlace(t);
      }, n.prototype.convertIncidentRadianceToIrradiance = function() {
        this.l00.scaleInPlace(ja[0]), this.l1_1.scaleInPlace(ja[1]), this.l10.scaleInPlace(ja[2]), this.l11.scaleInPlace(ja[3]), this.l2_2.scaleInPlace(ja[4]), this.l2_1.scaleInPlace(ja[5]), this.l20.scaleInPlace(ja[6]), this.l21.scaleInPlace(ja[7]), this.l22.scaleInPlace(ja[8]);
      }, n.prototype.convertIrradianceToLambertianRadiance = function() {
        this.scaleInPlace(1 / Math.PI);
      }, n.prototype.preScaleForRendering = function() {
        this.preScaled = !0, this.l00.scaleInPlace(fa[0]), this.l1_1.scaleInPlace(fa[1]), this.l10.scaleInPlace(fa[2]), this.l11.scaleInPlace(fa[3]), this.l2_2.scaleInPlace(fa[4]), this.l2_1.scaleInPlace(fa[5]), this.l20.scaleInPlace(fa[6]), this.l21.scaleInPlace(fa[7]), this.l22.scaleInPlace(fa[8]);
      }, n.prototype.updateFromArray = function(t) {
        return v.FromArrayToRef(t[0], 0, this.l00), v.FromArrayToRef(t[1], 0, this.l1_1), v.FromArrayToRef(t[2], 0, this.l10), v.FromArrayToRef(t[3], 0, this.l11), v.FromArrayToRef(t[4], 0, this.l2_2), v.FromArrayToRef(t[5], 0, this.l2_1), v.FromArrayToRef(t[6], 0, this.l20), v.FromArrayToRef(t[7], 0, this.l21), v.FromArrayToRef(t[8], 0, this.l22), this;
      }, n.prototype.updateFromFloatsArray = function(t) {
        return v.FromFloatsToRef(t[0], t[1], t[2], this.l00), v.FromFloatsToRef(t[3], t[4], t[5], this.l1_1), v.FromFloatsToRef(t[6], t[7], t[8], this.l10), v.FromFloatsToRef(t[9], t[10], t[11], this.l11), v.FromFloatsToRef(t[12], t[13], t[14], this.l2_2), v.FromFloatsToRef(t[15], t[16], t[17], this.l2_1), v.FromFloatsToRef(t[18], t[19], t[20], this.l20), v.FromFloatsToRef(t[21], t[22], t[23], this.l21), v.FromFloatsToRef(t[24], t[25], t[26], this.l22), this;
      }, n.FromArray = function(t) {
        return new n().updateFromArray(t);
      }, n.FromPolynomial = function(t) {
        var e = new n();
        return e.l00 = t.xx.scale(0.376127).add(t.yy.scale(0.376127)).add(t.zz.scale(0.376126)), e.l1_1 = t.y.scale(0.977204), e.l10 = t.z.scale(0.977204), e.l11 = t.x.scale(0.977204), e.l2_2 = t.xy.scale(1.16538), e.l2_1 = t.yz.scale(1.16538), e.l20 = t.zz.scale(1.34567).subtract(t.xx.scale(0.672834)).subtract(t.yy.scale(0.672834)), e.l21 = t.zx.scale(1.16538), e.l22 = t.xx.scale(1.16538).subtract(t.yy.scale(1.16538)), e.l1_1.scaleInPlace(-1), e.l11.scaleInPlace(-1), e.l2_1.scaleInPlace(-1), e.l21.scaleInPlace(-1), e.scaleInPlace(Math.PI), e;
      }, n;
    }(), Sl = function() {
      function n() {
        this.x = v.Zero(), this.y = v.Zero(), this.z = v.Zero(), this.xx = v.Zero(), this.yy = v.Zero(), this.zz = v.Zero(), this.xy = v.Zero(), this.yz = v.Zero(), this.zx = v.Zero();
      }
      return Object.defineProperty(n.prototype, "preScaledHarmonics", { get: function() {
        return this._harmonics || (this._harmonics = Mh.FromPolynomial(this)), this._harmonics.preScaled || this._harmonics.preScaleForRendering(), this._harmonics;
      }, enumerable: !1, configurable: !0 }), n.prototype.addAmbient = function(t) {
        F.Vector3[0].copyFromFloats(t.r, t.g, t.b);
        var e = F.Vector3[0];
        this.xx.addInPlace(e), this.yy.addInPlace(e), this.zz.addInPlace(e);
      }, n.prototype.scaleInPlace = function(t) {
        this.x.scaleInPlace(t), this.y.scaleInPlace(t), this.z.scaleInPlace(t), this.xx.scaleInPlace(t), this.yy.scaleInPlace(t), this.zz.scaleInPlace(t), this.yz.scaleInPlace(t), this.zx.scaleInPlace(t), this.xy.scaleInPlace(t);
      }, n.prototype.updateFromHarmonics = function(t) {
        return this._harmonics = t, this.x.copyFrom(t.l11), this.x.scaleInPlace(1.02333).scaleInPlace(-1), this.y.copyFrom(t.l1_1), this.y.scaleInPlace(1.02333).scaleInPlace(-1), this.z.copyFrom(t.l10), this.z.scaleInPlace(1.02333), this.xx.copyFrom(t.l00), F.Vector3[0].copyFrom(t.l20).scaleInPlace(0.247708), F.Vector3[1].copyFrom(t.l22).scaleInPlace(0.429043), this.xx.scaleInPlace(0.886277).subtractInPlace(F.Vector3[0]).addInPlace(F.Vector3[1]), this.yy.copyFrom(t.l00), this.yy.scaleInPlace(0.886277).subtractInPlace(F.Vector3[0]).subtractInPlace(F.Vector3[1]), this.zz.copyFrom(t.l00), F.Vector3[0].copyFrom(t.l20).scaleInPlace(0.495417), this.zz.scaleInPlace(0.886277).addInPlace(F.Vector3[0]), this.yz.copyFrom(t.l2_1), this.yz.scaleInPlace(0.858086).scaleInPlace(-1), this.zx.copyFrom(t.l21), this.zx.scaleInPlace(0.858086).scaleInPlace(-1), this.xy.copyFrom(t.l2_2), this.xy.scaleInPlace(0.858086), this.scaleInPlace(1 / Math.PI), this;
      }, n.FromHarmonics = function(t) {
        return new n().updateFromHarmonics(t);
      }, n.FromArray = function(t) {
        var e = new n();
        return v.FromArrayToRef(t[0], 0, e.x), v.FromArrayToRef(t[1], 0, e.y), v.FromArrayToRef(t[2], 0, e.z), v.FromArrayToRef(t[3], 0, e.xx), v.FromArrayToRef(t[4], 0, e.yy), v.FromArrayToRef(t[5], 0, e.zz), v.FromArrayToRef(t[6], 0, e.yz), v.FromArrayToRef(t[7], 0, e.zx), v.FromArrayToRef(t[8], 0, e.xy), e;
      }, n;
    }();
    function Xv(n, t, e, i) {
      i === void 0 && (i = !0);
      var r = n.getScene(), o = r.getEngine(), a = new Mi("resized" + n.name, { width: t, height: e }, r, !n.noMipmap, !0, n._texture.type, !1, n.samplingMode, !1);
      a.wrapU = n.wrapU, a.wrapV = n.wrapV, a.uOffset = n.uOffset, a.vOffset = n.vOffset, a.uScale = n.uScale, a.vScale = n.vScale, a.uAng = n.uAng, a.vAng = n.vAng, a.wAng = n.wAng, a.coordinatesIndex = n.coordinatesIndex, a.level = n.level, a.anisotropicFilteringLevel = n.anisotropicFilteringLevel, a._texture.isReady = !1, n.wrapU = ae.CLAMP_ADDRESSMODE, n.wrapV = ae.CLAMP_ADDRESSMODE;
      var s = new da("pass", 1, null, i ? ae.BILINEAR_SAMPLINGMODE : ae.NEAREST_SAMPLINGMODE, o, !1, _.TEXTURETYPE_UNSIGNED_INT);
      return s.externalTextureSamplerBinding = !0, s.getEffect().executeWhenCompiled(function() {
        s.onApply = function(c) {
          c.setTexture("textureSampler", n);
        };
        var l = a.renderTarget;
        l && (r.postProcessManager.directRender([s], l), o.unBindFramebuffer(l), a.disposeFramebufferObjects(), s.dispose(), a.getInternalTexture().isReady = !0);
      }), a;
    }
    function Oh(n, t, e, i, r, o, a, s) {
      var l = t.getEngine();
      return t.isReady = !1, r = r ?? t.samplingMode, i = i ?? t.type, o = o ?? t.format, a = a ?? t.width, s = s ?? t.height, i === -1 && (i = _.TEXTURETYPE_UNSIGNED_BYTE), new Promise(function(c) {
        var u = new nt("postprocess", n, null, null, 1, null, r, l, !1, void 0, i, void 0, null, !1, o);
        u.externalTextureSamplerBinding = !0;
        var h = l.createRenderTargetTexture({ width: a, height: s }, { generateDepthBuffer: !1, generateMipMaps: !1, generateStencilBuffer: !1, samplingMode: r, type: i, format: o });
        u.getEffect().executeWhenCompiled(function() {
          u.onApply = function(d) {
            d._bindTexture("textureSampler", t), d.setFloat2("scale", 1, 1);
          }, e.postProcessManager.directRender([u], h, !0), l.restoreDefaultFramebuffer(), l._releaseTexture(t), u && u.dispose(), h._swapAndDie(t), t.type = i, t.format = _.TEXTUREFORMAT_RGBA, t.isReady = !0, c(t);
        });
      });
    }
    function to(n) {
      Bf || (Bf = new Float32Array(1), _C = new Int32Array(Bf.buffer)), Bf[0] = n;
      var t = _C[0], e = t >> 16 & 32768, i = t >> 12 & 2047, r = t >> 23 & 255;
      return r < 103 ? e : r > 142 ? (e |= 31744, e |= (r == 255 ? 0 : 1) && 8388607 & t) : r < 113 ? e |= ((i |= 2048) >> 114 - r) + (i >> 113 - r & 1) : (e |= r - 112 << 10 | i >> 1, e += 1 & i);
    }
    function io(n) {
      var t = (32768 & n) >> 15, e = (31744 & n) >> 10, i = 1023 & n;
      return e === 0 ? (t ? -1 : 1) * Math.pow(2, -14) * (i / Math.pow(2, 10)) : e == 31 ? i ? NaN : 1 / 0 * (t ? -1 : 1) : (t ? -1 : 1) * Math.pow(2, e - 15) * (1 + i / Math.pow(2, 10));
    }
    re.ShadersStore.rgbdDecodePixelShader = `varying vec2 vUV;uniform sampler2D textureSampler;
#include<helperFunctions>
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void) 
{gl_FragColor=vec4(fromRGBD(texture2D(textureSampler,vUV)),1.0);}`;
    var rD = function(n, t, e, i, r) {
      return Ft(void 0, void 0, void 0, function() {
        var o, a, s, l, c, u, h, d, p;
        return Bt(this, function(f) {
          switch (f.label) {
            case 0:
              return o = n.getScene(), a = o.getEngine(), n.isCube ? (l = ["#define POSITIVEX", "#define NEGATIVEX", "#define POSITIVEY", "#define NEGATIVEY", "#define POSITIVEZ", "#define NEGATIVEZ"], s = new nt("lodCube", "lodCube", ["lod", "gamma"], null, 1, null, ae.NEAREST_NEAREST_MIPNEAREST, a, !1, l[i])) : s = new nt("lod", "lod", ["lod", "gamma"], null, 1, null, ae.NEAREST_NEAREST_MIPNEAREST, a), [4, new Promise(function(m) {
                s.getEffect().executeWhenCompiled(function() {
                  m(0);
                });
              })];
            case 1:
              f.sent(), c = new Mi("temp", { width: t, height: e }, o, !1), s.onApply = function(m) {
                m.setTexture("textureSampler", n), m.setFloat("lod", r), m.setBool("gamma", n.gammaSpace);
              }, u = n.getInternalTexture(), f.label = 2;
            case 2:
              return f.trys.push([2, , 6, 7]), c.renderTarget && u ? (h = u.samplingMode, r !== 0 ? n.updateSamplingMode(ae.NEAREST_NEAREST_MIPNEAREST) : n.updateSamplingMode(ae.NEAREST_NEAREST), o.postProcessManager.directRender([s], c.renderTarget, !0), n.updateSamplingMode(h), [4, a.readPixels(0, 0, t, e)]) : [3, 4];
            case 3:
              return d = f.sent(), p = new Uint8Array(d.buffer, 0, d.byteLength), a.unBindFramebuffer(c.renderTarget), [2, p];
            case 4:
              throw Error("Render to texture failed.");
            case 5:
              return [3, 7];
            case 6:
              return c.dispose(), s.dispose(), [7];
            case 7:
              return [2];
          }
        });
      });
    };
    function jv(n, t, e, i, r) {
      return i === void 0 && (i = 0), r === void 0 && (r = 0), Ft(this, void 0, void 0, function() {
        return Bt(this, function(o) {
          switch (o.label) {
            case 0:
              return n.isReady() || !n._texture ? [3, 2] : [4, new Promise(function(a, s) {
                n._texture !== null ? n._texture.onLoadedObservable.addOnce(function() {
                  a(0);
                }) : s(0);
              })];
            case 1:
              o.sent(), o.label = 2;
            case 2:
              return [4, rD(n, t, e, i, r)];
            case 3:
              return [2, o.sent()];
          }
        });
      });
    }
    var Yv = { CreateResizedCopy: Xv, ApplyPostProcess: Oh, ToHalfFloat: to, FromHalfFloat: io, GetTextureDataAsync: jv }, Dh = function() {
      function n() {
      }
      return n.ExpandRGBDTexture = function(t) {
        var e = t._texture;
        if (e && t.isRGBD) {
          var i = e.getEngine(), r = i.getCaps(), o = e.isReady, a = !1;
          r.textureHalfFloatRender && r.textureHalfFloatLinearFiltering ? (a = !0, e.type = _.TEXTURETYPE_HALF_FLOAT) : r.textureFloatRender && r.textureFloatLinearFiltering && (a = !0, e.type = _.TEXTURETYPE_FLOAT), a && (e.isReady = !1, e._isRGBD = !1, e.invertY = !1);
          var s = function() {
            if (a) {
              var l = new nt("rgbdDecode", "rgbdDecode", null, null, 1, null, _.TEXTURE_TRILINEAR_SAMPLINGMODE, i, !1, void 0, e.type, void 0, null, !1);
              l.externalTextureSamplerBinding = !0;
              var c = i.createRenderTargetTexture(e.width, { generateDepthBuffer: !1, generateMipMaps: !1, generateStencilBuffer: !1, samplingMode: e.samplingMode, type: e.type, format: _.TEXTUREFORMAT_RGBA });
              l.getEffect().executeWhenCompiled(function() {
                l.onApply = function(u) {
                  u._bindTexture("textureSampler", e), u.setFloat2("scale", 1, 1);
                }, t.getScene().postProcessManager.directRender([l], c, !0), i.restoreDefaultFramebuffer(), i._releaseTexture(e), l && l.dispose(), c._swapAndDie(e), e.isReady = !0;
              });
            }
          };
          o ? s() : t.onLoadObservable.addOnce(s);
        }
      }, n.EncodeTextureToRGBD = function(t, e, i) {
        return i === void 0 && (i = _.TEXTURETYPE_UNSIGNED_BYTE), Oh("rgbdEncode", t, e, i, _.TEXTURE_NEAREST_SAMPLINGMODE, _.TEXTUREFORMAT_RGBA);
      }, n;
    }(), Fc = function(n, t, e, i) {
      this.name = n, this.worldAxisForNormal = t, this.worldAxisForFileX = e, this.worldAxisForFileY = i;
    }, Nh = function() {
      function n() {
      }
      return n.ConvertCubeMapTextureToSphericalPolynomial = function(t) {
        var e, i = this;
        if (!t.isCube)
          return null;
        (e = t.getScene()) === null || e === void 0 || e.getEngine().flushFramebuffer();
        var r, o, a = t.getSize().width, s = t.readPixels(0, void 0, void 0, !1), l = t.readPixels(1, void 0, void 0, !1);
        t.isRenderTarget ? (r = t.readPixels(3, void 0, void 0, !1), o = t.readPixels(2, void 0, void 0, !1)) : (r = t.readPixels(2, void 0, void 0, !1), o = t.readPixels(3, void 0, void 0, !1));
        var c = t.readPixels(4, void 0, void 0, !1), u = t.readPixels(5, void 0, void 0, !1), h = t.gammaSpace, d = _.TEXTUREFORMAT_RGBA, p = _.TEXTURETYPE_UNSIGNED_INT;
        return t.textureType != _.TEXTURETYPE_FLOAT && t.textureType != _.TEXTURETYPE_HALF_FLOAT || (p = _.TEXTURETYPE_FLOAT), new Promise(function(f) {
          Promise.all([l, s, r, o, c, u]).then(function(m) {
            var g = m[0], y = m[1], b = m[2], T = m[3], S = m[4], E = m[5], A = { size: a, right: y, left: g, up: b, down: T, front: S, back: E, format: d, type: p, gammaSpace: h };
            f(i.ConvertCubeMapToSphericalPolynomial(A));
          });
        });
      }, n._AreaElement = function(t, e) {
        return Math.atan2(t * e, Math.sqrt(t * t + e * e + 1));
      }, n.ConvertCubeMapToSphericalPolynomial = function(t) {
        for (var e = new Mh(), i = 0, r = 2 / t.size, o = r, a = 0.5 * r, s = a - 1, l = 0; l < 6; l++)
          for (var c = this._FileFaces[l], u = t[c.name], h = s, d = t.format === _.TEXTUREFORMAT_RGBA ? 4 : 3, p = 0; p < t.size; p++) {
            for (var f = s, m = 0; m < t.size; m++) {
              var g = c.worldAxisForFileX.scale(f).add(c.worldAxisForFileY.scale(h)).add(c.worldAxisForNormal);
              g.normalize();
              var y = this._AreaElement(f - a, h - a) - this._AreaElement(f - a, h + a) - this._AreaElement(f + a, h - a) + this._AreaElement(f + a, h + a), b = u[p * t.size * d + m * d + 0], T = u[p * t.size * d + m * d + 1], S = u[p * t.size * d + m * d + 2];
              isNaN(b) && (b = 0), isNaN(T) && (T = 0), isNaN(S) && (S = 0), t.type === _.TEXTURETYPE_UNSIGNED_INT && (b /= 255, T /= 255, S /= 255), t.gammaSpace && (b = Math.pow(ue.Clamp(b), Ht), T = Math.pow(ue.Clamp(T), Ht), S = Math.pow(ue.Clamp(S), Ht));
              var E = this.MAX_HDRI_VALUE;
              if (this.PRESERVE_CLAMPED_COLORS) {
                var A = Math.max(b, T, S);
                if (A > E) {
                  var R = E / A;
                  b *= R, T *= R, S *= R;
                }
              } else
                b = ue.Clamp(b, 0, E), T = ue.Clamp(T, 0, E), S = ue.Clamp(S, 0, E);
              var C = new ne(b, T, S);
              e.addLight(g, C, y), i += y, f += r;
            }
            h += o;
          }
        var L = 4 * Math.PI * 6 / 6 / i;
        return e.scaleInPlace(L), e.convertIncidentRadianceToIrradiance(), e.convertIrradianceToLambertianRadiance(), Sl.FromHarmonics(e);
      }, n._FileFaces = [new Fc("right", new v(1, 0, 0), new v(0, 0, -1), new v(0, -1, 0)), new Fc("left", new v(-1, 0, 0), new v(0, 0, 1), new v(0, -1, 0)), new Fc("up", new v(0, 1, 0), new v(1, 0, 0), new v(0, 0, 1)), new Fc("down", new v(0, -1, 0), new v(1, 0, 0), new v(0, 0, -1)), new Fc("front", new v(0, 0, 1), new v(1, 0, 0), new v(0, -1, 0)), new Fc("back", new v(0, 0, -1), new v(-1, 0, 0), new v(0, -1, 0))], n.MAX_HDRI_VALUE = 4096, n.PRESERVE_CLAMPED_COLORS = !1, n;
    }();
    Vn.prototype.forceSphericalPolynomialsRecompute = function() {
      this._texture && (this._texture._sphericalPolynomial = null, this._texture._sphericalPolynomialPromise = null, this._texture._sphericalPolynomialComputed = !1);
    }, Object.defineProperty(Vn.prototype, "sphericalPolynomial", { get: function() {
      var n = this;
      if (this._texture) {
        if (this._texture._sphericalPolynomial || this._texture._sphericalPolynomialComputed)
          return this._texture._sphericalPolynomial;
        if (this._texture.isReady)
          return this._texture._sphericalPolynomialPromise || (this._texture._sphericalPolynomialPromise = Nh.ConvertCubeMapTextureToSphericalPolynomial(this), this._texture._sphericalPolynomialPromise === null ? this._texture._sphericalPolynomialComputed = !0 : this._texture._sphericalPolynomialPromise.then(function(t) {
            n._texture._sphericalPolynomial = t, n._texture._sphericalPolynomialComputed = !0;
          })), null;
      }
      return null;
    }, set: function(n) {
      this._texture && (this._texture._sphericalPolynomial = n);
    }, enumerable: !0, configurable: !0 }), re.ShadersStore.rgbdEncodePixelShader = `varying vec2 vUV;uniform sampler2D textureSampler;
#include<helperFunctions>
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void) 
{gl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);}`;
    var Kv = "image/png", qv = 2, Fh = [134, 22, 135, 150, 246, 214, 150, 54];
    function Lh(n) {
      for (var t = new DataView(n.buffer, n.byteOffset, n.byteLength), e = 0, i = 0; i < Fh.length; i++)
        if (t.getUint8(e++) !== Fh[i])
          return q.Error("Not a babylon environment map"), null;
      for (var r = "", o = 0; o = t.getUint8(e++); )
        r += String.fromCharCode(o);
      var a = JSON.parse(r);
      return (a = Lc(a)).specular && (a.specular.specularDataPosition = e, a.specular.lodGenerationScale = a.specular.lodGenerationScale || 0.8), a;
    }
    function Lc(n) {
      if (n.version > qv)
        throw new Error('Unsupported babylon environment map version "'.concat(n.version, '". Latest supported version is "').concat(qv, '".'));
      return n.version === 2 ? n : n = je(je({}, n), { version: 2, imageType: Kv });
    }
    function Qv(n, t) {
      var e, i;
      return t === void 0 && (t = {}), Ft(this, void 0, void 0, function() {
        var r, o, a, s, l, c, u, h, d, p, f, m, g, y, b, T, S, E, A, R, C, L, I, O, w, z, V, Y, ee, J, X, K, te;
        return Bt(this, function(se) {
          switch (se.label) {
            case 0:
              if (!(r = n.getInternalTexture()))
                return [2, Promise.reject("The cube texture is invalid.")];
              if (o = (e = t.imageType) !== null && e !== void 0 ? e : Kv, a = r.getEngine(), n.textureType !== _.TEXTURETYPE_HALF_FLOAT && n.textureType !== _.TEXTURETYPE_FLOAT && n.textureType !== _.TEXTURETYPE_UNSIGNED_BYTE && n.textureType !== _.TEXTURETYPE_UNSIGNED_INT && n.textureType !== _.TEXTURETYPE_UNSIGNED_INTEGER && n.textureType !== -1)
                return [2, Promise.reject("The cube texture should allow HDR (Full Float or Half Float).")];
              if (s = _.TEXTURETYPE_FLOAT, !a.getCaps().textureFloatRender && (s = _.TEXTURETYPE_HALF_FLOAT, !a.getCaps().textureHalfFloatRender))
                return [2, Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.")];
              n.sphericalPolynomial, l = (i = n.getInternalTexture()) === null || i === void 0 ? void 0 : i._sphericalPolynomialPromise, c = r.width, u = new Ue(a), h = {}, a.flushFramebuffer(), d = ue.ILog2(r.width), X = 0, se.label = 1;
            case 1:
              if (!(X <= d))
                return [3, 9];
              p = Math.pow(2, d - X), K = 0, se.label = 2;
            case 2:
              return K < 6 ? [4, n.readPixels(K, X, void 0, !1)] : [3, 8];
            case 3:
              if ((f = se.sent()) && f.byteLength === f.length) {
                for (m = new Float32Array(4 * f.byteLength), g = 0; g < f.byteLength; g++)
                  m[g] = f[g] / 255, m[g] = Math.pow(m[g], 2.2);
                f = m;
              } else if (f && n.gammaSpace)
                for (y = f, b = 0; b < y.length; b++)
                  y[b] = Math.pow(y[b], 2.2);
              return T = a.createRawTexture(f, p, p, _.TEXTUREFORMAT_RGBA, !1, !0, _.TEXTURE_NEAREST_SAMPLINGMODE, null, s), [4, Dh.EncodeTextureToRGBD(T, u, s)];
            case 4:
              return se.sent(), [4, a._readTexturePixels(T, p, p)];
            case 5:
              return S = se.sent(), [4, la.DumpDataAsync(p, p, S, o, void 0, !1, !0, t.imageQuality)];
            case 6:
              E = se.sent(), h[6 * X + K] = E, T.dispose(), se.label = 7;
            case 7:
              return K++, [3, 2];
            case 8:
              return X++, [3, 1];
            case 9:
              return u.dispose(), l ? [4, l] : [3, 11];
            case 10:
              se.sent(), se.label = 11;
            case 11:
              for (A = { version: qv, width: c, imageType: o, irradiance: oD(n), specular: { mipmaps: [], lodGenerationScale: n.lodGenerationScale } }, R = 0, X = 0; X <= d; X++)
                for (K = 0; K < 6; K++)
                  C = h[6 * X + K].byteLength, A.specular.mipmaps.push({ length: C, position: R }), R += C;
              for (L = JSON.stringify(A), I = new ArrayBuffer(L.length + 1), O = new Uint8Array(I), X = 0, w = L.length; X < w; X++)
                O[X] = L.charCodeAt(X);
              for (O[L.length] = 0, z = Fh.length + R + I.byteLength, V = new ArrayBuffer(z), Y = new Uint8Array(V), ee = new DataView(V), J = 0, X = 0; X < Fh.length; X++)
                ee.setUint8(J++, Fh[X]);
              for (Y.set(new Uint8Array(I), J), J += I.byteLength, X = 0; X <= d; X++)
                for (K = 0; K < 6; K++)
                  te = h[6 * X + K], Y.set(new Uint8Array(te), J), J += te.byteLength;
              return [2, V];
          }
        });
      });
    }
    function oD(n) {
      var t = n.sphericalPolynomial;
      return t == null ? null : { x: [t.x.x, t.x.y, t.x.z], y: [t.y.x, t.y.y, t.y.z], z: [t.z.x, t.z.y, t.z.z], xx: [t.xx.x, t.xx.y, t.xx.z], yy: [t.yy.x, t.yy.y, t.yy.z], zz: [t.zz.x, t.zz.y, t.zz.z], yz: [t.yz.x, t.yz.y, t.yz.z], zx: [t.zx.x, t.zx.y, t.zx.z], xy: [t.xy.x, t.xy.y, t.xy.z] };
    }
    function wh(n, t) {
      var e = (t = Lc(t)).specular, i = ue.Log2(t.width);
      if (i = Math.round(i) + 1, e.mipmaps.length !== 6 * i)
        throw new Error('Unsupported specular mipmaps number "'.concat(e.mipmaps.length, '"'));
      for (var r = new Array(i), o = 0; o < i; o++) {
        r[o] = new Array(6);
        for (var a = 0; a < 6; a++) {
          var s = e.mipmaps[6 * o + a];
          r[o][a] = new Uint8Array(n.buffer, n.byteOffset + e.specularDataPosition + s.position, s.length);
        }
      }
      return r;
    }
    function Uf(n, t, e) {
      var i = (e = Lc(e)).specular;
      return i ? (n._lodGenerationScale = i.lodGenerationScale, wc(n, wh(t, e), e.imageType)) : Promise.resolve();
    }
    function mC(n, t, e, i, r, o, a, s, l, c, u) {
      return new Promise(function(h, d) {
        if (e) {
          var p = t.createTexture(null, !0, !0, null, _.TEXTURE_NEAREST_SAMPLINGMODE, null, function(m) {
            d(m);
          }, n);
          i.getEffect().executeWhenCompiled(function() {
            i.externalTextureSamplerBinding = !0, i.onApply = function(m) {
              m._bindTexture("textureSampler", p), m.setFloat2("scale", 1, t._features.needsInvertingBitmap && n instanceof ImageBitmap ? -1 : 1);
            }, t.scenes.length && (t.scenes[0].postProcessManager.directRender([i], c, !0, o, a), t.restoreDefaultFramebuffer(), p.dispose(), URL.revokeObjectURL(r), h());
          });
        } else {
          if (t._uploadImageToTexture(u, n, o, a), s) {
            var f = l[a];
            f && t._uploadImageToTexture(f._texture, n, o, 0);
          }
          h();
        }
      });
    }
    function wc(n, t, e) {
      if (e === void 0 && (e = Kv), !de.IsExponentOfTwo(n.width))
        throw new Error("Texture size must be a power of two");
      var i = ue.ILog2(n.width) + 1, r = n.getEngine(), o = !1, a = !1, s = null, l = null, c = null, u = r.getCaps();
      if (n.format = _.TEXTUREFORMAT_RGBA, n.type = _.TEXTURETYPE_UNSIGNED_INT, n.generateMipMaps = !0, n._cachedAnisotropicFilteringLevel = null, r.updateTextureSamplingMode(_.TEXTURE_TRILINEAR_SAMPLINGMODE, n), u.textureLOD ? r._features.supportRenderAndCopyToLodForFloatTextures ? u.textureHalfFloatRender && u.textureHalfFloatLinearFiltering ? (o = !0, n.type = _.TEXTURETYPE_HALF_FLOAT) : u.textureFloatRender && u.textureFloatLinearFiltering && (o = !0, n.type = _.TEXTURETYPE_FLOAT) : o = !1 : (o = !1, a = !0, c = {}), o)
        s = new nt("rgbdDecode", "rgbdDecode", null, null, 1, null, _.TEXTURE_TRILINEAR_SAMPLINGMODE, r, !1, void 0, n.type, void 0, null, !1), n._isRGBD = !1, n.invertY = !1, l = r.createRenderTargetCubeTexture(n.width, { generateDepthBuffer: !1, generateMipMaps: !0, generateStencilBuffer: !1, samplingMode: _.TEXTURE_TRILINEAR_SAMPLINGMODE, type: n.type, format: _.TEXTUREFORMAT_RGBA });
      else if (n._isRGBD = !0, n.invertY = !0, a)
        for (var h = n._lodGenerationScale, d = n._lodGenerationOffset, p = 0; p < 3; p++) {
          var f = (i - 1) * h + d, m = d + (f - d) * (1 - p / 2), g = Math.round(Math.min(Math.max(m, 0), f)), y = new Ut(r, ut.Temp);
          y.isCube = !0, y.invertY = !0, y.generateMipMaps = !1, r.updateTextureSamplingMode(_.TEXTURE_LINEAR_LINEAR, y);
          var b = new Vn(null);
          switch (b._isCube = !0, b._texture = y, c[g] = b, p) {
            case 0:
              n._lodTextureLow = b;
              break;
            case 1:
              n._lodTextureMid = b;
              break;
            case 2:
              n._lodTextureHigh = b;
          }
        }
      var T = [], S = function(L) {
        for (var I = function(w) {
          var z = t[L][w], V = new Blob([z], { type: e }), Y = URL.createObjectURL(V), ee = void 0;
          if (typeof Image > "u" || r._features.forceBitmapOverHTMLImageElement)
            ee = r.createImageBitmap(V, { premultiplyAlpha: "none" }).then(function(X) {
              return mC(X, r, o, s, Y, w, L, a, c, l, n);
            });
          else {
            var J = new Image();
            J.src = Y, ee = new Promise(function(X, K) {
              J.onload = function() {
                mC(J, r, o, s, Y, w, L, a, c, l, n).then(function() {
                  return X();
                }).catch(function(te) {
                  K(te);
                });
              }, J.onerror = function(te) {
                K(te);
              };
            });
          }
          T.push(ee);
        }, O = 0; O < 6; O++)
          I(O);
      };
      for (p = 0; p < t.length; p++)
        S(p);
      if (t.length < i) {
        var E = void 0, A = Math.pow(2, i - 1 - t.length), R = A * A * 4;
        switch (n.type) {
          case _.TEXTURETYPE_UNSIGNED_INT:
            E = new Uint8Array(R);
            break;
          case _.TEXTURETYPE_HALF_FLOAT:
            E = new Uint16Array(R);
            break;
          case _.TEXTURETYPE_FLOAT:
            E = new Float32Array(R);
        }
        for (p = t.length; p < i; p++)
          for (var C = 0; C < 6; C++)
            r._uploadArrayBufferViewToTexture(n, E, C, p);
      }
      return Promise.all(T).then(function() {
        l && (r._releaseTexture(n), l._swapAndDie(n)), s && s.dispose(), a && (n._lodTextureHigh && n._lodTextureHigh._texture && (n._lodTextureHigh._texture.isReady = !0), n._lodTextureMid && n._lodTextureMid._texture && (n._lodTextureMid._texture.isReady = !0), n._lodTextureLow && n._lodTextureLow._texture && (n._lodTextureLow._texture.isReady = !0));
      });
    }
    function Bh(n, t) {
      var e = (t = Lc(t)).irradiance;
      if (e) {
        var i = new Sl();
        v.FromArrayToRef(e.x, 0, i.x), v.FromArrayToRef(e.y, 0, i.y), v.FromArrayToRef(e.z, 0, i.z), v.FromArrayToRef(e.xx, 0, i.xx), v.FromArrayToRef(e.yy, 0, i.yy), v.FromArrayToRef(e.zz, 0, i.zz), v.FromArrayToRef(e.yz, 0, i.yz), v.FromArrayToRef(e.zx, 0, i.zx), v.FromArrayToRef(e.xy, 0, i.xy), n._sphericalPolynomial = i;
      }
    }
    function Zv(n, t, e, i, r) {
      var o = wc(n.getEngine().createRawCubeTexture(null, n.width, n.format, n.type, n.generateMipMaps, n.invertY, n.samplingMode, n._compression), t).then(function() {
        return n;
      });
      return n.onRebuildCallback = function(a) {
        return { proxy: o, isReady: !0, isAsync: !0 };
      }, n._source = ut.CubeRawRGBD, n._bufferViewArrayArray = t, n._lodGenerationScale = i, n._lodGenerationOffset = r, n._sphericalPolynomial = e, wc(n, t).then(function() {
        return n.isReady = !0, n;
      });
    }
    var gC = { GetEnvInfo: Lh, CreateEnvTextureAsync: Qv, CreateImageDataArrayBufferViews: wh, UploadEnvLevelsAsync: Uf, UploadLevelsAsync: wc, UploadEnvSpherical: Bh };
    function Vf(n, t, e, i) {
      for (var r = i, o = 0, a = ""; r < e.length; ) {
        var s = e.charAt(r);
        if (a)
          s === a ? a === '"' || a === "'" ? e.charAt(r - 1) !== "\\" && (a = "") : a = "" : a === "*/" && s === "*" && r + 1 < e.length && (e.charAt(r + 1) === "/" && (a = ""), a === "" && r++);
        else
          switch (s) {
            case n:
              o++;
              break;
            case t:
              o--;
              break;
            case '"':
            case "'":
            case "`":
              a = s;
              break;
            case "/":
              if (r + 1 < e.length) {
                var l = e.charAt(r + 1);
                l === "/" ? a = `
` : l === "*" && (a = "*/");
              }
          }
        if (r++, o === 0)
          break;
      }
      return o === 0 ? r - 1 : -1;
    }
    function vC(n, t) {
      for (; t < n.length; ) {
        var e = n[t];
        if (e !== " " && e !== `
` && e !== "\r" && e !== "	" && e !== `
` && e !== " ")
          break;
        t++;
      }
      return t;
    }
    function Jv(n) {
      var t = n.charCodeAt(0);
      return t >= 48 && t <= 57 || t >= 65 && t <= 90 || t >= 97 && t <= 122 || t == 95;
    }
    function $v(n) {
      for (var t = 0, e = "", i = !1, r = []; t < n.length; ) {
        var o = n.charAt(t);
        if (e)
          o === e ? e === '"' || e === "'" ? (n.charAt(t - 1) !== "\\" && (e = ""), r.push(o)) : (e = "", i = !1) : e === "*/" && o === "*" && t + 1 < n.length ? (n.charAt(t + 1) === "/" && (e = ""), e === "" && (i = !1, t++)) : i || r.push(o);
        else {
          switch (o) {
            case '"':
            case "'":
            case "`":
              e = o;
              break;
            case "/":
              if (t + 1 < n.length) {
                var a = n.charAt(t + 1);
                a === "/" ? (e = `
`, i = !0) : a === "*" && (e = "*/", i = !0);
              }
          }
          i || r.push(o);
        }
        t++;
      }
      return r.join("");
    }
    function aD(n, t, e, i) {
      for (; t >= 0 && n.charAt(t) !== e && (!i || n.charAt(t) !== i); )
        t--;
      return t;
    }
    var Bc = function() {
      function n(t, e) {
        e === void 0 && (e = 20), this.debug = !1, this._sourceCode = t, this._numMaxIterations = e, this._functionDescr = [], this.inlineToken = "#define inline";
      }
      return Object.defineProperty(n.prototype, "code", { get: function() {
        return this._sourceCode;
      }, enumerable: !1, configurable: !0 }), n.prototype.processCode = function() {
        this.debug && console.log("Start inlining process (code size=".concat(this._sourceCode.length, ")...")), this._collectFunctions(), this._processInlining(this._numMaxIterations), this.debug && console.log("End of inlining process.");
      }, n.prototype._collectFunctions = function() {
        for (var t, e = 0; e < this._sourceCode.length; ) {
          var i = this._sourceCode.indexOf(this.inlineToken, e);
          if (i < 0)
            break;
          var r = this._sourceCode.indexOf("(", i + this.inlineToken.length);
          if (r < 0)
            this.debug && console.warn("Could not find the opening parenthesis after the token. startIndex=".concat(e)), e = i + this.inlineToken.length;
          else {
            var o = n._RegexpFindFunctionNameAndType.exec(this._sourceCode.substring(i + this.inlineToken.length, r));
            if (o) {
              var a = (t = [o[3], o[4]])[0], s = t[1], l = Vf("(", ")", this._sourceCode, r);
              if (l < 0)
                this.debug && console.warn("Could not extract the parameters the function '".concat(s, "' (type=").concat(a, "). funcParamsStartIndex=").concat(r)), e = i + this.inlineToken.length;
              else {
                var c = this._sourceCode.substring(r + 1, l), u = vC(this._sourceCode, l + 1);
                if (u !== this._sourceCode.length) {
                  var h = Vf("{", "}", this._sourceCode, u);
                  if (h < 0)
                    this.debug && console.warn("Could not extract the body of the function '".concat(s, "' (type=").concat(a, "). funcBodyStartIndex=").concat(u)), e = i + this.inlineToken.length;
                  else {
                    for (var d = this._sourceCode.substring(u, h + 1), p = $v(c).split(","), f = [], m = 0; m < p.length; ++m) {
                      var g = p[m].trim(), y = g.lastIndexOf(" ");
                      y >= 0 && f.push(g.substring(y + 1));
                    }
                    a !== "void" && f.push("return"), this._functionDescr.push({ name: s, type: a, parameters: f, body: d, callIndex: 0 }), e = h + 1;
                    var b = i > 0 ? this._sourceCode.substring(0, i) : "", T = h + 1 < this._sourceCode.length - 1 ? this._sourceCode.substring(h + 1) : "";
                    this._sourceCode = b + T, e -= h + 1 - i;
                  }
                } else
                  this.debug && console.warn("Could not extract the body of the function '".concat(s, "' (type=").concat(a, "). funcParamsEndIndex=").concat(l)), e = i + this.inlineToken.length;
              }
            } else
              this.debug && console.warn("Could not extract the name/type of the function from: ".concat(this._sourceCode.substring(i + this.inlineToken.length, r))), e = i + this.inlineToken.length;
          }
        }
        this.debug && console.log("Collect functions: ".concat(this._functionDescr.length, " functions found. functionDescr="), this._functionDescr);
      }, n.prototype._processInlining = function(t) {
        for (t === void 0 && (t = 20); t-- >= 0 && this._replaceFunctionCallsByCode(); )
          ;
        return this.debug && console.log("numMaxIterations is ".concat(t, " after inlining process")), t >= 0;
      }, n.prototype._replaceFunctionCallsByCode = function() {
        for (var t = !1, e = 0, i = this._functionDescr; e < i.length; e++)
          for (var r = i[e], o = r.name, a = r.type, s = r.parameters, l = r.body, c = 0; c < this._sourceCode.length; ) {
            var u = this._sourceCode.indexOf(o, c);
            if (u < 0)
              break;
            if (u === 0 || Jv(this._sourceCode.charAt(u - 1)))
              c = u + o.length;
            else {
              var h = vC(this._sourceCode, u + o.length);
              if (h !== this._sourceCode.length && this._sourceCode.charAt(h) === "(") {
                var d = Vf("(", ")", this._sourceCode, h);
                if (d < 0)
                  this.debug && console.warn("Could not extract the parameters of the function call. Function '".concat(o, "' (type=").concat(a, "). callParamsStartIndex=").concat(h)), c = u + o.length;
                else {
                  var p = this._sourceCode.substring(h + 1, d), f = function(C) {
                    for (var L = [], I = 0, O = 0; I < C.length; ) {
                      if (C.charAt(I) === "(") {
                        var w = Vf("(", ")", C, I);
                        if (w < 0)
                          return null;
                        I = w;
                      } else
                        C.charAt(I) === "," && (L.push(C.substring(O, I)), O = I + 1);
                      I++;
                    }
                    return O < I && L.push(C.substring(O, I)), L;
                  }($v(p));
                  if (f !== null) {
                    for (var m = [], g = 0; g < f.length; ++g) {
                      var y = f[g].trim();
                      m.push(y);
                    }
                    var b = a !== "void" ? o + "_" + r.callIndex++ : null;
                    if (b && m.push(b + " ="), m.length === s.length) {
                      c = d + 1;
                      var T = this._replaceNames(l, s, m), S = u > 0 ? this._sourceCode.substring(0, u) : "", E = d + 1 < this._sourceCode.length - 1 ? this._sourceCode.substring(d + 1) : "";
                      if (b) {
                        var A = aD(this._sourceCode, u - 1, `
`, "{");
                        S = this._sourceCode.substring(0, A + 1);
                        var R = this._sourceCode.substring(A + 1, u);
                        this._sourceCode = S + a + " " + b + `;
` + T + `
` + R + b + E, this.debug && console.log("Replace function call by code. Function '".concat(o, "' (type=").concat(a, "). injectDeclarationIndex=").concat(A, ", call parameters=").concat(m));
                      } else
                        this._sourceCode = S + T + E, c += T.length - (d + 1 - u), this.debug && console.log("Replace function call by code. Function '".concat(o, "' (type=").concat(a, "). functionCallIndex=").concat(u, ", call parameters=").concat(m));
                      t = !0;
                    } else
                      this.debug && console.warn("Invalid function call: not the same number of parameters for the call than the number expected by the function. Function '".concat(o, "' (type=").concat(a, "). function parameters=").concat(s, ", call parameters=").concat(m)), c = u + o.length;
                  } else
                    this.debug && console.warn("Invalid function call: can't extract the parameters of the function call. Function '".concat(o, "' (type=").concat(a, "). callParamsStartIndex=").concat(h, ", callParams=") + p), c = u + o.length;
                }
              } else
                c = u + o.length;
            }
          }
        return t;
      }, n.prototype._replaceNames = function(t, e, i) {
        for (var r = function(a) {
          var s = new RegExp(e[a].replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"), l = e[a].length, c = i[a];
          t = t.replace(s, function(u) {
            for (var h = [], d = 1; d < arguments.length; d++)
              h[d - 1] = arguments[d];
            var p = h[0];
            return Jv(t.charAt(p - 1)) || Jv(t.charAt(p + l)) ? e[a] : c;
          });
        }, o = 0; o < e.length; ++o)
          r(o);
        return t;
      }, n._RegexpFindFunctionNameAndType = /((\s+?)(\w+)\s+(\w+)\s*?)$/, n;
    }(), sD = function() {
      function n(t) {
        this.isParallelCompiled = !0, this.isCompiled = !1, this._valueCache = {}, this._engine = t;
      }
      return Object.defineProperty(n.prototype, "isAsync", { get: function() {
        return this.isParallelCompiled;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isReady", { get: function() {
        if (this.compilationError) {
          var t = this.compilationError.message;
          throw new Error("SHADER ERROR" + (typeof t == "string" ? `
` + t : ""));
        }
        return this.isCompiled;
      }, enumerable: !1, configurable: !0 }), n.prototype._getVertexShaderCode = function() {
        return null;
      }, n.prototype._getFragmentShaderCode = function() {
        return null;
      }, n.prototype._handlesSpectorRebuildCallback = function(t) {
        throw new Error("Not implemented");
      }, n.prototype._fillEffectInformation = function(t, e, i, r, o, a, s, l) {
        var c, u = this._engine;
        if (u.supportsUniformBuffers)
          for (var h in e)
            t.bindUniformBlock(h, e[h]);
        for (this._engine.getUniforms(this, i).forEach(function(d, p) {
          r[i[p]] = d;
        }), this._uniforms = r, c = 0; c < o.length; c++)
          t.getUniform(o[c]) == null && (o.splice(c, 1), c--);
        o.forEach(function(d, p) {
          a[d] = p;
        }), l.push.apply(l, u.getAttributes(this, s));
      }, n.prototype.dispose = function() {
        this._uniforms = {};
      }, n.prototype._cacheMatrix = function(t, e) {
        var i = this._valueCache[t], r = e.updateFlag;
        return (i === void 0 || i !== r) && (this._valueCache[t] = r, !0);
      }, n.prototype._cacheFloat2 = function(t, e, i) {
        var r = this._valueCache[t];
        if (!r)
          return r = [e, i], this._valueCache[t] = r, !0;
        var o = !1;
        return r[0] !== e && (r[0] = e, o = !0), r[1] !== i && (r[1] = i, o = !0), o;
      }, n.prototype._cacheFloat3 = function(t, e, i, r) {
        var o = this._valueCache[t];
        if (!o)
          return o = [e, i, r], this._valueCache[t] = o, !0;
        var a = !1;
        return o[0] !== e && (o[0] = e, a = !0), o[1] !== i && (o[1] = i, a = !0), o[2] !== r && (o[2] = r, a = !0), a;
      }, n.prototype._cacheFloat4 = function(t, e, i, r, o) {
        var a = this._valueCache[t];
        if (!a)
          return a = [e, i, r, o], this._valueCache[t] = a, !0;
        var s = !1;
        return a[0] !== e && (a[0] = e, s = !0), a[1] !== i && (a[1] = i, s = !0), a[2] !== r && (a[2] = r, s = !0), a[3] !== o && (a[3] = o, s = !0), s;
      }, n.prototype.setInt = function(t, e) {
        var i = this._valueCache[t];
        i !== void 0 && i === e || this._engine.setInt(this._uniforms[t], e) && (this._valueCache[t] = e);
      }, n.prototype.setInt2 = function(t, e, i) {
        this._cacheFloat2(t, e, i) && (this._engine.setInt2(this._uniforms[t], e, i) || (this._valueCache[t] = null));
      }, n.prototype.setInt3 = function(t, e, i, r) {
        this._cacheFloat3(t, e, i, r) && (this._engine.setInt3(this._uniforms[t], e, i, r) || (this._valueCache[t] = null));
      }, n.prototype.setInt4 = function(t, e, i, r, o) {
        this._cacheFloat4(t, e, i, r, o) && (this._engine.setInt4(this._uniforms[t], e, i, r, o) || (this._valueCache[t] = null));
      }, n.prototype.setIntArray = function(t, e) {
        this._valueCache[t] = null, this._engine.setIntArray(this._uniforms[t], e);
      }, n.prototype.setIntArray2 = function(t, e) {
        this._valueCache[t] = null, this._engine.setIntArray2(this._uniforms[t], e);
      }, n.prototype.setIntArray3 = function(t, e) {
        this._valueCache[t] = null, this._engine.setIntArray3(this._uniforms[t], e);
      }, n.prototype.setIntArray4 = function(t, e) {
        this._valueCache[t] = null, this._engine.setIntArray4(this._uniforms[t], e);
      }, n.prototype.setUInt = function(t, e) {
        var i = this._valueCache[t];
        i !== void 0 && i === e || this._engine.setUInt(this._uniforms[t], e) && (this._valueCache[t] = e);
      }, n.prototype.setUInt2 = function(t, e, i) {
        this._cacheFloat2(t, e, i) && (this._engine.setUInt2(this._uniforms[t], e, i) || (this._valueCache[t] = null));
      }, n.prototype.setUInt3 = function(t, e, i, r) {
        this._cacheFloat3(t, e, i, r) && (this._engine.setUInt3(this._uniforms[t], e, i, r) || (this._valueCache[t] = null));
      }, n.prototype.setUInt4 = function(t, e, i, r, o) {
        this._cacheFloat4(t, e, i, r, o) && (this._engine.setUInt4(this._uniforms[t], e, i, r, o) || (this._valueCache[t] = null));
      }, n.prototype.setUIntArray = function(t, e) {
        this._valueCache[t] = null, this._engine.setUIntArray(this._uniforms[t], e);
      }, n.prototype.setUIntArray2 = function(t, e) {
        this._valueCache[t] = null, this._engine.setUIntArray2(this._uniforms[t], e);
      }, n.prototype.setUIntArray3 = function(t, e) {
        this._valueCache[t] = null, this._engine.setUIntArray3(this._uniforms[t], e);
      }, n.prototype.setUIntArray4 = function(t, e) {
        this._valueCache[t] = null, this._engine.setUIntArray4(this._uniforms[t], e);
      }, n.prototype.setFloatArray = function(t, e) {
        this._valueCache[t] = null, this._engine.setFloatArray(this._uniforms[t], e);
      }, n.prototype.setFloatArray2 = function(t, e) {
        this._valueCache[t] = null, this._engine.setFloatArray2(this._uniforms[t], e);
      }, n.prototype.setFloatArray3 = function(t, e) {
        this._valueCache[t] = null, this._engine.setFloatArray3(this._uniforms[t], e);
      }, n.prototype.setFloatArray4 = function(t, e) {
        this._valueCache[t] = null, this._engine.setFloatArray4(this._uniforms[t], e);
      }, n.prototype.setArray = function(t, e) {
        this._valueCache[t] = null, this._engine.setArray(this._uniforms[t], e);
      }, n.prototype.setArray2 = function(t, e) {
        this._valueCache[t] = null, this._engine.setArray2(this._uniforms[t], e);
      }, n.prototype.setArray3 = function(t, e) {
        this._valueCache[t] = null, this._engine.setArray3(this._uniforms[t], e);
      }, n.prototype.setArray4 = function(t, e) {
        this._valueCache[t] = null, this._engine.setArray4(this._uniforms[t], e);
      }, n.prototype.setMatrices = function(t, e) {
        e && (this._valueCache[t] = null, this._engine.setMatrices(this._uniforms[t], e));
      }, n.prototype.setMatrix = function(t, e) {
        this._cacheMatrix(t, e) && (this._engine.setMatrices(this._uniforms[t], e.toArray()) || (this._valueCache[t] = null));
      }, n.prototype.setMatrix3x3 = function(t, e) {
        this._valueCache[t] = null, this._engine.setMatrix3x3(this._uniforms[t], e);
      }, n.prototype.setMatrix2x2 = function(t, e) {
        this._valueCache[t] = null, this._engine.setMatrix2x2(this._uniforms[t], e);
      }, n.prototype.setFloat = function(t, e) {
        var i = this._valueCache[t];
        i !== void 0 && i === e || this._engine.setFloat(this._uniforms[t], e) && (this._valueCache[t] = e);
      }, n.prototype.setBool = function(t, e) {
        var i = this._valueCache[t];
        i !== void 0 && i === e || this._engine.setInt(this._uniforms[t], e ? 1 : 0) && (this._valueCache[t] = e ? 1 : 0);
      }, n.prototype.setVector2 = function(t, e) {
        this._cacheFloat2(t, e.x, e.y) && (this._engine.setFloat2(this._uniforms[t], e.x, e.y) || (this._valueCache[t] = null));
      }, n.prototype.setFloat2 = function(t, e, i) {
        this._cacheFloat2(t, e, i) && (this._engine.setFloat2(this._uniforms[t], e, i) || (this._valueCache[t] = null));
      }, n.prototype.setVector3 = function(t, e) {
        this._cacheFloat3(t, e.x, e.y, e.z) && (this._engine.setFloat3(this._uniforms[t], e.x, e.y, e.z) || (this._valueCache[t] = null));
      }, n.prototype.setFloat3 = function(t, e, i, r) {
        this._cacheFloat3(t, e, i, r) && (this._engine.setFloat3(this._uniforms[t], e, i, r) || (this._valueCache[t] = null));
      }, n.prototype.setVector4 = function(t, e) {
        this._cacheFloat4(t, e.x, e.y, e.z, e.w) && (this._engine.setFloat4(this._uniforms[t], e.x, e.y, e.z, e.w) || (this._valueCache[t] = null));
      }, n.prototype.setQuaternion = function(t, e) {
        this._cacheFloat4(t, e.x, e.y, e.z, e.w) && (this._engine.setFloat4(this._uniforms[t], e.x, e.y, e.z, e.w) || (this._valueCache[t] = null));
      }, n.prototype.setFloat4 = function(t, e, i, r, o) {
        this._cacheFloat4(t, e, i, r, o) && (this._engine.setFloat4(this._uniforms[t], e, i, r, o) || (this._valueCache[t] = null));
      }, n.prototype.setColor3 = function(t, e) {
        this._cacheFloat3(t, e.r, e.g, e.b) && (this._engine.setFloat3(this._uniforms[t], e.r, e.g, e.b) || (this._valueCache[t] = null));
      }, n.prototype.setColor4 = function(t, e, i) {
        this._cacheFloat4(t, e.r, e.g, e.b, i) && (this._engine.setFloat4(this._uniforms[t], e.r, e.g, e.b, i) || (this._valueCache[t] = null));
      }, n.prototype.setDirectColor4 = function(t, e) {
        this._cacheFloat4(t, e.r, e.g, e.b, e.a) && (this._engine.setFloat4(this._uniforms[t], e.r, e.g, e.b, e.a) || (this._valueCache[t] = null));
      }, n;
    }(), lD = function(n) {
      function t(e, i, r, o) {
        var a = n.call(this, e, i, r, o) || this;
        return a.__framebuffer = null, a.__framebufferDepthStencil = null, a._engine = o, a;
      }
      return D(t, n), Object.defineProperty(t.prototype, "_framebuffer", { get: function() {
        return this.__framebuffer;
      }, set: function(e) {
        this.__framebuffer && this._engine._releaseFramebufferObjects(this.__framebuffer), this.__framebuffer = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "_framebufferDepthStencil", { get: function() {
        return this.__framebufferDepthStencil;
      }, set: function(e) {
        this.__framebufferDepthStencil && this._engine._releaseFramebufferObjects(this.__framebufferDepthStencil), this.__framebufferDepthStencil = e;
      }, enumerable: !1, configurable: !0 }), t.prototype.dispose = function(e) {
        e === void 0 && (e = !1), this._framebuffer = null, this._framebufferDepthStencil = null, n.prototype.dispose.call(this, e);
      }, t;
    }(dc), yC = function() {
      function n(t, e) {
        this._engine = e, this.set(t);
      }
      return Object.defineProperty(n.prototype, "underlyingResource", { get: function() {
        return this._nativeTexture;
      }, enumerable: !1, configurable: !0 }), n.prototype.setUsage = function() {
      }, n.prototype.set = function(t) {
        this._nativeTexture = t;
      }, n.prototype.reset = function() {
        this._nativeTexture = null;
      }, n.prototype.release = function() {
        this._nativeTexture && this._engine.deleteTexture(this._nativeTexture), this.reset();
      }, n;
    }();
    function ey(n, t) {
      switch (n) {
        case _.TEXTUREFORMAT_DEPTH16:
          return _native.Engine.TEXTURE_FORMAT_D16;
        case _.TEXTUREFORMAT_DEPTH24:
          return _native.Engine.TEXTURE_FORMAT_D24;
        case _.TEXTUREFORMAT_DEPTH24_STENCIL8:
          return _native.Engine.TEXTURE_FORMAT_D24S8;
        case _.TEXTUREFORMAT_DEPTH32_FLOAT:
          return _native.Engine.TEXTURE_FORMAT_D32F;
        case _.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM:
          return _native.Engine.TEXTURE_FORMAT_BC7;
        case _.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT:
          return _native.Engine.TEXTURE_FORMAT_BC6H;
        case _.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5:
          return _native.Engine.TEXTURE_FORMAT_BC3;
        case _.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3:
          return _native.Engine.TEXTURE_FORMAT_BC2;
        case _.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1:
        case _.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1:
          return _native.Engine.TEXTURE_FORMAT_BC1;
        case _.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4:
          return _native.Engine.TEXTURE_FORMAT_ASTC4x4;
        case _.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL:
          return _native.Engine.TEXTURE_FORMAT_ETC1;
        case _.TEXTUREFORMAT_COMPRESSED_RGB8_ETC2:
          return _native.Engine.TEXTURE_FORMAT_ETC2;
        case _.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC:
          return _native.Engine.TEXTURE_FORMAT_ETC2A;
        case _.TEXTUREFORMAT_RGB:
          switch (t) {
            case _.TEXTURETYPE_UNSIGNED_BYTE:
              return _native.Engine.TEXTURE_FORMAT_RGB8;
            case _.TEXTURETYPE_BYTE:
              return _native.Engine.TEXTURE_FORMAT_RGB8S;
            case _.TEXTURETYPE_INT:
              return _native.Engine.TEXTURE_FORMAT_RGB8I;
            case _.TEXTURETYPE_UNSIGNED_INTEGER:
              return _native.Engine.TEXTURE_FORMAT_RGB8U;
          }
          break;
        case _.TEXTUREFORMAT_RGBA:
          switch (t) {
            case _.TEXTURETYPE_UNSIGNED_BYTE:
              return _native.Engine.TEXTURE_FORMAT_RGBA8;
            case _.TEXTURETYPE_FLOAT:
              return _native.Engine.TEXTURE_FORMAT_RGBA32F;
            case _.TEXTURETYPE_HALF_FLOAT:
              return _native.Engine.TEXTURE_FORMAT_RGBA16F;
            case _.TEXTURETYPE_BYTE:
              return _native.Engine.TEXTURE_FORMAT_RGBA8S;
            case _.TEXTURETYPE_SHORT:
              return _native.Engine.TEXTURE_FORMAT_RGBA16I;
            case _.TEXTURETYPE_UNSIGNED_SHORT:
              return _native.Engine.TEXTURE_FORMAT_RGBA16U;
            case _.TEXTURETYPE_INT:
              return _native.Engine.TEXTURE_FORMAT_RGBA32I;
            case _.TEXTURETYPE_UNSIGNED_INTEGER:
              return _native.Engine.TEXTURE_FORMAT_RGBA32U;
          }
          break;
        case _.TEXTUREFORMAT_R:
          switch (t) {
            case _.TEXTURETYPE_UNSIGNED_BYTE:
              return _native.Engine.TEXTURE_FORMAT_R8;
            case _.TEXTURETYPE_FLOAT:
              return _native.Engine.TEXTURE_FORMAT_R32F;
            case _.TEXTURETYPE_HALF_FLOAT:
              return _native.Engine.TEXTURE_FORMAT_R16F;
            case _.TEXTURETYPE_BYTE:
              return _native.Engine.TEXTURE_FORMAT_R8S;
            case _.TEXTURETYPE_SHORT:
              return _native.Engine.TEXTURE_FORMAT_R16S;
            case _.TEXTURETYPE_UNSIGNED_SHORT:
              return _native.Engine.TEXTURE_FORMAT_R16U;
            case _.TEXTURETYPE_INT:
              return _native.Engine.TEXTURE_FORMAT_R32I;
            case _.TEXTURETYPE_UNSIGNED_INTEGER:
              return _native.Engine.TEXTURE_FORMAT_R32U;
          }
          break;
        case _.TEXTUREFORMAT_RG:
          switch (t) {
            case _.TEXTURETYPE_UNSIGNED_BYTE:
              return _native.Engine.TEXTURE_FORMAT_RG8;
            case _.TEXTURETYPE_FLOAT:
              return _native.Engine.TEXTURE_FORMAT_RG32F;
            case _.TEXTURETYPE_HALF_FLOAT:
              return _native.Engine.TEXTURE_FORMAT_RG16F;
            case _.TEXTURETYPE_BYTE:
              return _native.Engine.TEXTURE_FORMAT_RG8S;
            case _.TEXTURETYPE_SHORT:
              return _native.Engine.TEXTURE_FORMAT_RG16S;
            case _.TEXTURETYPE_UNSIGNED_SHORT:
              return _native.Engine.TEXTURE_FORMAT_RG16U;
            case _.TEXTURETYPE_INT:
              return _native.Engine.TEXTURE_FORMAT_RG32I;
            case _.TEXTURETYPE_UNSIGNED_INTEGER:
              return _native.Engine.TEXTURE_FORMAT_RG32U;
          }
          break;
        case _.TEXTUREFORMAT_BGRA:
          if (t === _.TEXTURETYPE_UNSIGNED_BYTE)
            return _native.Engine.TEXTURE_FORMAT_BGRA8;
      }
      throw new ia("Unsupported texture format or type: format ".concat(n, ", type ").concat(t, "."), ta.UnsupportedTextureError);
    }
    function Uh(n) {
      switch (n) {
        case _.TEXTURE_NEAREST_NEAREST:
          return _native.Engine.TEXTURE_NEAREST_NEAREST;
        case _.TEXTURE_LINEAR_LINEAR:
          return _native.Engine.TEXTURE_LINEAR_LINEAR;
        case _.TEXTURE_LINEAR_LINEAR_MIPLINEAR:
          return _native.Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR;
        case _.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
          return _native.Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST;
        case _.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
          return _native.Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST;
        case _.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
          return _native.Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR;
        case _.TEXTURE_NEAREST_LINEAR:
          return _native.Engine.TEXTURE_NEAREST_LINEAR;
        case _.TEXTURE_NEAREST_NEAREST_MIPLINEAR:
          return _native.Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR;
        case _.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
          return _native.Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST;
        case _.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
          return _native.Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR;
        case _.TEXTURE_LINEAR_LINEAR_MIPNEAREST:
          return _native.Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST;
        case _.TEXTURE_LINEAR_NEAREST:
          return _native.Engine.TEXTURE_LINEAR_NEAREST;
        default:
          throw new Error("Unsupported sampling mode: ".concat(n, "."));
      }
    }
    function ty(n) {
      switch (n) {
        case _.TEXTURE_WRAP_ADDRESSMODE:
          return _native.Engine.ADDRESS_MODE_WRAP;
        case _.TEXTURE_CLAMP_ADDRESSMODE:
          return _native.Engine.ADDRESS_MODE_CLAMP;
        case _.TEXTURE_MIRROR_ADDRESSMODE:
          return _native.Engine.ADDRESS_MODE_MIRROR;
        default:
          throw new Error("Unexpected wrap mode: " + n + ".");
      }
    }
    function cD(n) {
      switch (n) {
        case P.BYTE:
          return _native.Engine.ATTRIB_TYPE_INT8;
        case P.UNSIGNED_BYTE:
          return _native.Engine.ATTRIB_TYPE_UINT8;
        case P.SHORT:
          return _native.Engine.ATTRIB_TYPE_INT16;
        case P.UNSIGNED_SHORT:
          return _native.Engine.ATTRIB_TYPE_UINT16;
        case P.FLOAT:
          return _native.Engine.ATTRIB_TYPE_FLOAT;
        default:
          throw new Error("Unsupported attribute type: ".concat(n, "."));
      }
    }
    var iy, bC = new H();
    function ny() {
      return new Promise(function(n) {
        typeof _native > "u" ? bC.addOnce(function(t) {
          return n(t);
        }) : n(_native);
      });
    }
    function ry(n, t) {
      return Ft(this, void 0, void 0, function() {
        return Bt(this, function(e) {
          switch (e.label) {
            case 0:
              return [4, ny()];
            case 1:
              return e.sent()[n] = t, [2];
          }
        });
      });
    }
    typeof self > "u" || Object.prototype.hasOwnProperty.call(self, "_native") || Object.defineProperty(self, "_native", { get: function() {
      return iy;
    }, set: function(n) {
      (iy = n) && bC.notifyObservers(iy);
    } });
    var TC = function(n) {
      function t() {
        return n !== null && n.apply(this, arguments) || this;
      }
      return D(t, n), t;
    }(wa), uD = function() {
      function n(t) {
        this._engine = t, this._pending = new Array(), this._isCommandBufferScopeActive = !1, this._commandStream = kf._createNativeDataStream(), this._engine.setCommandDataStream(this._commandStream);
      }
      return n.prototype.beginCommandScope = function() {
        if (this._isCommandBufferScopeActive)
          throw new Error("Command scope already active.");
        this._isCommandBufferScopeActive = !0;
      }, n.prototype.endCommandScope = function() {
        if (!this._isCommandBufferScopeActive)
          throw new Error("Command scope is not active.");
        this._isCommandBufferScopeActive = !1, this._submit();
      }, n.prototype.startEncodingCommand = function(t) {
        this._commandStream.writeNativeData(t);
      }, n.prototype.encodeCommandArgAsUInt32 = function(t) {
        this._commandStream.writeUint32(t);
      }, n.prototype.encodeCommandArgAsUInt32s = function(t) {
        this._commandStream.writeUint32Array(t);
      }, n.prototype.encodeCommandArgAsInt32 = function(t) {
        this._commandStream.writeInt32(t);
      }, n.prototype.encodeCommandArgAsInt32s = function(t) {
        this._commandStream.writeInt32Array(t);
      }, n.prototype.encodeCommandArgAsFloat32 = function(t) {
        this._commandStream.writeFloat32(t);
      }, n.prototype.encodeCommandArgAsFloat32s = function(t) {
        this._commandStream.writeFloat32Array(t);
      }, n.prototype.encodeCommandArgAsNativeData = function(t) {
        this._commandStream.writeNativeData(t), this._pending.push(t);
      }, n.prototype.finishEncodingCommand = function() {
        this._isCommandBufferScopeActive || this._submit();
      }, n.prototype._submit = function() {
        this._engine.submitCommands(), this._pending.length = 0;
      }, n;
    }(), kf = function(n) {
      function t(e) {
        e === void 0 && (e = {});
        var i = n.call(this, null, !1, void 0, e.adaptToDeviceRatio) || this;
        if (i._engine = new _native.Engine(), i._camera = _native.Camera ? new _native.Camera() : null, i._commandBufferEncoder = new uD(i._engine), i._boundBuffersVertexArray = null, i._currentDepthTest = _native.Engine.DEPTH_TEST_LEQUAL, i._stencilTest = !1, i._stencilMask = 255, i._stencilFunc = _.ALWAYS, i._stencilFuncRef = 0, i._stencilFuncMask = 255, i._stencilOpStencilFail = _.KEEP, i._stencilOpDepthFail = _.KEEP, i._stencilOpStencilDepthPass = _.REPLACE, i._zOffset = 0, i._zOffsetUnits = 0, i._depthWrite = !0, _native.Engine.PROTOCOL_VERSION !== t.PROTOCOL_VERSION)
          throw new Error("Protocol version mismatch: ".concat(_native.Engine.PROTOCOL_VERSION, " (Native) !== ").concat(t.PROTOCOL_VERSION, " (JS)"));
        i._webGLVersion = 2, i.disableUniformBuffers = !0, i._shaderPlatformName = "NATIVE", i._caps = { maxTexturesImageUnits: 16, maxVertexTextureImageUnits: 16, maxCombinedTexturesImageUnits: 32, maxTextureSize: _native.Engine.CAPS_LIMITS_MAX_TEXTURE_SIZE, maxCubemapTextureSize: 512, maxRenderTextureSize: 512, maxVertexAttribs: 16, maxVaryingVectors: 16, maxFragmentUniformVectors: 16, maxVertexUniformVectors: 16, standardDerivatives: !0, astc: null, pvrtc: null, etc1: null, etc2: null, bptc: null, maxAnisotropy: 16, uintIndices: !0, fragmentDepthSupported: !1, highPrecisionShaderSupported: !0, colorBufferFloat: !1, supportFloatTexturesResolve: !1, textureFloat: !0, textureFloatLinearFiltering: !1, textureFloatRender: !0, textureHalfFloat: !0, textureHalfFloatLinearFiltering: !1, textureHalfFloatRender: !0, textureLOD: !0, texelFetch: !1, drawBuffersExtension: !1, depthTextureExtension: !1, vertexArrayObject: !0, instancedArrays: !0, supportOcclusionQuery: !1, canUseTimestampForTimerQuery: !1, blendMinMax: !1, maxMSAASamples: 16, canUseGLInstanceID: !0, canUseGLVertexID: !0, supportComputeShaders: !1, supportSRGBBuffers: !0, supportTransformFeedbacks: !1, textureMaxLevel: !1, texture2DArrayMaxLayerCount: _native.Engine.CAPS_LIMITS_MAX_TEXTURE_LAYERS, disableMorphTargetTexture: !1 }, i._features = { forceBitmapOverHTMLImageElement: !1, supportRenderAndCopyToLodForFloatTextures: !1, supportDepthStencilTexture: !1, supportShadowSamplers: !1, uniformBufferHardCheckMatrix: !1, allowTexturePrefiltering: !1, trackUbosInFrame: !1, checkUbosContentBeforeUpload: !1, supportCSM: !1, basisNeedsPOT: !1, support3DTextures: !1, needTypeSuffixInShaderConstants: !1, supportMSAA: !0, supportSSAO2: !1, supportExtendedTextureFormats: !1, supportSwitchCaseInShader: !1, supportSyncTextureRead: !1, needsInvertingBitmap: !0, useUBOBindingCache: !0, needShaderCodeInlining: !0, needToAlwaysBindUniformBuffers: !1, supportRenderPasses: !0, supportSpriteInstancing: !1, forceVertexBufferStrideMultiple4Bytes: !1, _collectUbosUpdatedInFrame: !1 }, de.Log("Babylon Native (v" + ve.Version + ") launched"), de.LoadScript = function(a, s, l, c) {
          de.LoadFile(a, function(u) {
            Function(u).apply(null), s && s();
          }, void 0, void 0, !1, function(u, h) {
            l && l("LoadScript Error", h);
          });
        }, typeof URL > "u" && (window.URL = { createObjectURL: function() {
        }, revokeObjectURL: function() {
        } }), typeof Blob > "u" && (window.Blob = function(a) {
          return a;
        }), Array.prototype.flat || Object.defineProperty(Array.prototype, "flat", { configurable: !0, value: function a() {
          var s = isNaN(arguments[0]) ? 1 : Number(arguments[0]);
          return s ? Array.prototype.reduce.call(this, function(l, c) {
            return Array.isArray(c) ? l.push.apply(l, a.call(c, s - 1)) : l.push(c), l;
          }, []) : Array.prototype.slice.call(this);
        }, writable: !0 });
        var r = window && window.devicePixelRatio || 1;
        i._hardwareScalingLevel = e.adaptToDeviceRatio ? 1 / r : 1, i._engine.setHardwareScalingLevel(i._hardwareScalingLevel), i._lastDevicePixelRatio = r, i.resize();
        var o = i.getDepthFunction();
        return o && i.setDepthFunction(o), i._shaderProcessor = new op(), i.onNewSceneAddedObservable.add(function(a) {
          var s = a.render;
          a.render = function() {
            for (var l = [], c = 0; c < arguments.length; c++)
              l[c] = arguments[c];
            i._commandBufferEncoder.beginCommandScope(), s.apply(a, l), i._commandBufferEncoder.endCommandScope();
          };
        }), i;
      }
      return D(t, n), t.prototype.setHardwareScalingLevel = function(e) {
        n.prototype.setHardwareScalingLevel.call(this, e), this._engine.setHardwareScalingLevel(e);
      }, t.prototype.dispose = function() {
        n.prototype.dispose.call(this), this._boundBuffersVertexArray && this._deleteVertexArray(this._boundBuffersVertexArray), this._engine.dispose();
      }, t._createNativeDataStream = function() {
        return new Ih();
      }, t.prototype._queueNewFrame = function(e, i) {
        return i.requestAnimationFrame && i !== window ? i.requestAnimationFrame(e) : this._engine.requestAnimationFrame(e), 0;
      }, t.prototype._bindUnboundFramebuffer = function(e) {
        this._currentFramebuffer !== e && (this._currentFramebuffer && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_UNBINDFRAMEBUFFER), this._commandBufferEncoder.encodeCommandArgAsNativeData(this._currentFramebuffer), this._commandBufferEncoder.finishEncodingCommand()), e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_BINDFRAMEBUFFER), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.finishEncodingCommand()), this._currentFramebuffer = e);
      }, t.prototype.getHostDocument = function() {
        return null;
      }, t.prototype.clear = function(e, i, r, o) {
        if (o === void 0 && (o = !1), this.useReverseDepthBuffer)
          throw new Error("reverse depth buffer is not currently implemented");
        this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_CLEAR), this._commandBufferEncoder.encodeCommandArgAsUInt32(i && e ? 1 : 0), this._commandBufferEncoder.encodeCommandArgAsFloat32(e ? e.r : 0), this._commandBufferEncoder.encodeCommandArgAsFloat32(e ? e.g : 0), this._commandBufferEncoder.encodeCommandArgAsFloat32(e ? e.b : 0), this._commandBufferEncoder.encodeCommandArgAsFloat32(e ? e.a : 1), this._commandBufferEncoder.encodeCommandArgAsUInt32(r ? 1 : 0), this._commandBufferEncoder.encodeCommandArgAsFloat32(1), this._commandBufferEncoder.encodeCommandArgAsUInt32(o ? 1 : 0), this._commandBufferEncoder.encodeCommandArgAsUInt32(0), this._commandBufferEncoder.finishEncodingCommand();
      }, t.prototype.createIndexBuffer = function(e, i, r) {
        var o = this._normalizeIndexData(e), a = new TC();
        return a.references = 1, a.is32Bits = o.BYTES_PER_ELEMENT === 4, o.byteLength && (a.nativeIndexBuffer = this._engine.createIndexBuffer(o.buffer, o.byteOffset, o.byteLength, a.is32Bits, i != null && i)), a;
      }, t.prototype.createVertexBuffer = function(e, i, r) {
        var o = ArrayBuffer.isView(e) ? e : new Float32Array(e), a = new TC();
        return a.references = 1, o.byteLength && (a.nativeVertexBuffer = this._engine.createVertexBuffer(o.buffer, o.byteOffset, o.byteLength, i != null && i)), a;
      }, t.prototype._recordVertexArrayObject = function(e, i, r, o, a) {
        r && this._engine.recordIndexBuffer(e, r.nativeIndexBuffer);
        for (var s = o.getAttributesNames(), l = 0; l < s.length; l++) {
          var c = o.getAttributeLocation(l);
          if (c >= 0) {
            var u = s[l], h = null;
            if (a && (h = a[u]), h || (h = i[u]), h) {
              var d = h.getBuffer();
              d && d.nativeVertexBuffer && this._engine.recordVertexBuffer(e, d.nativeVertexBuffer, c, h.byteOffset, h.byteStride, h.getSize(), cD(h.type), h.normalized, h.getInstanceDivisor());
            }
          }
        }
      }, t.prototype.bindBuffers = function(e, i, r) {
        this._boundBuffersVertexArray && this._deleteVertexArray(this._boundBuffersVertexArray), this._boundBuffersVertexArray = this._engine.createVertexArray(), this._recordVertexArrayObject(this._boundBuffersVertexArray, e, i, r), this.bindVertexArrayObject(this._boundBuffersVertexArray);
      }, t.prototype.recordVertexArrayObject = function(e, i, r, o) {
        var a = this._engine.createVertexArray();
        return this._recordVertexArrayObject(a, e, i, r, o), a;
      }, t.prototype._deleteVertexArray = function(e) {
        this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEVERTEXARRAY), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.finishEncodingCommand();
      }, t.prototype.bindVertexArrayObject = function(e) {
        this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_BINDVERTEXARRAY), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.finishEncodingCommand();
      }, t.prototype.releaseVertexArrayObject = function(e) {
        this._deleteVertexArray(e);
      }, t.prototype.getAttributes = function(e, i) {
        var r = e;
        return this._engine.getAttributes(r.nativeProgram, i);
      }, t.prototype.drawElementsType = function(e, i, r, o) {
        this._drawCalls.addCount(1, !1), o && _native.Engine.COMMAND_DRAWINDEXEDINSTANCED ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DRAWINDEXEDINSTANCED), this._commandBufferEncoder.encodeCommandArgAsUInt32(e), this._commandBufferEncoder.encodeCommandArgAsUInt32(i), this._commandBufferEncoder.encodeCommandArgAsUInt32(r), this._commandBufferEncoder.encodeCommandArgAsUInt32(o)) : (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DRAWINDEXED), this._commandBufferEncoder.encodeCommandArgAsUInt32(e), this._commandBufferEncoder.encodeCommandArgAsUInt32(i), this._commandBufferEncoder.encodeCommandArgAsUInt32(r)), this._commandBufferEncoder.finishEncodingCommand();
      }, t.prototype.drawArraysType = function(e, i, r, o) {
        this._drawCalls.addCount(1, !1), o && _native.Engine.COMMAND_DRAWINSTANCED ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DRAWINSTANCED), this._commandBufferEncoder.encodeCommandArgAsUInt32(e), this._commandBufferEncoder.encodeCommandArgAsUInt32(i), this._commandBufferEncoder.encodeCommandArgAsUInt32(r), this._commandBufferEncoder.encodeCommandArgAsUInt32(o)) : (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DRAW), this._commandBufferEncoder.encodeCommandArgAsUInt32(e), this._commandBufferEncoder.encodeCommandArgAsUInt32(i), this._commandBufferEncoder.encodeCommandArgAsUInt32(r)), this._commandBufferEncoder.finishEncodingCommand();
      }, t.prototype.createPipelineContext = function() {
        return new sD(this);
      }, t.prototype.createMaterialContext = function() {
      }, t.prototype.createDrawContext = function() {
      }, t.prototype._preparePipelineContext = function(e, i, r, o, a, s, l, c) {
        e.nativeProgram = o ? this.createRawShaderProgram() : this.createShaderProgram(e, i, r, c);
      }, t.prototype.isAsync = function(e) {
        return !(!e.isAsync || !this._engine.createProgramAsync);
      }, t.prototype._executeWhenRenderingStateIsCompiled = function(e, i) {
        var r = e;
        if (this.isAsync(e)) {
          var o = r.onCompiled;
          r.onCompiled = o ? function() {
            o(), i();
          } : i;
        } else
          i();
      }, t.prototype.createRawShaderProgram = function() {
        throw new Error("Not Supported");
      }, t.prototype.createShaderProgram = function(e, i, r, o) {
        var a = this, s = e;
        if (s.nativeProgram)
          throw new Error("Tried to create a second program in the same NativePipelineContext");
        this.onBeforeShaderCompilationObservable.notifyObservers(this);
        var l = new Bc(i);
        l.processCode(), i = l.code;
        var c = new Bc(r);
        c.processCode(), r = c.code, i = Qe._ConcatenateShader(i, o), r = Qe._ConcatenateShader(r, o);
        var u = function() {
          var p;
          s.isCompiled = !0, (p = s.onCompiled) === null || p === void 0 || p.call(s), a.onAfterShaderCompilationObservable.notifyObservers(a);
        };
        if (this.isAsync(e))
          return this._engine.createProgramAsync(i, r, u, function(p) {
            s.compilationError = p;
          });
        try {
          var h = s.nativeProgram = this._engine.createProgram(i, r);
          return u(), h;
        } catch (p) {
          var d = p == null ? void 0 : p.message;
          throw new Error("SHADER ERROR" + (typeof d == "string" ? `
` + d : ""));
        }
      }, t.prototype.inlineShaderCode = function(e) {
        var i = new Bc(e);
        return i.debug = !1, i.processCode(), i.code;
      }, t.prototype._setProgram = function(e) {
        this._currentProgram !== e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETPROGRAM), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.finishEncodingCommand(), this._currentProgram = e);
      }, t.prototype._deletePipelineContext = function(e) {
        var i = e;
        i && i.nativeProgram && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEPROGRAM), this._commandBufferEncoder.encodeCommandArgAsNativeData(i.nativeProgram), this._commandBufferEncoder.finishEncodingCommand());
      }, t.prototype.getUniforms = function(e, i) {
        var r = e;
        return this._engine.getUniforms(r.nativeProgram, i);
      }, t.prototype.bindUniformBlock = function(e, i, r) {
        throw new Error("Not Implemented");
      }, t.prototype.bindSamplers = function(e) {
        var i = e.getPipelineContext();
        this._setProgram(i.nativeProgram);
        for (var r = e.getSamplers(), o = 0; o < r.length; o++) {
          var a = e.getUniform(r[o]);
          a && (this._boundUniforms[o] = a);
        }
        this._currentEffect = null;
      }, t.prototype.getRenderWidth = function(e) {
        return e === void 0 && (e = !1), !e && this._currentRenderTarget ? this._currentRenderTarget.width : this._engine.getRenderWidth();
      }, t.prototype.getRenderHeight = function(e) {
        return e === void 0 && (e = !1), !e && this._currentRenderTarget ? this._currentRenderTarget.height : this._engine.getRenderHeight();
      }, t.prototype.setViewport = function(e, i, r) {
        this._cachedViewport = e, this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETVIEWPORT), this._commandBufferEncoder.encodeCommandArgAsFloat32(e.x), this._commandBufferEncoder.encodeCommandArgAsFloat32(e.y), this._commandBufferEncoder.encodeCommandArgAsFloat32(e.width), this._commandBufferEncoder.encodeCommandArgAsFloat32(e.height), this._commandBufferEncoder.finishEncodingCommand();
      }, t.prototype.enableScissor = function(e, i, r, o) {
        this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETSCISSOR), this._commandBufferEncoder.encodeCommandArgAsFloat32(e), this._commandBufferEncoder.encodeCommandArgAsFloat32(i), this._commandBufferEncoder.encodeCommandArgAsFloat32(r), this._commandBufferEncoder.encodeCommandArgAsFloat32(o), this._commandBufferEncoder.finishEncodingCommand();
      }, t.prototype.disableScissor = function() {
        this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETSCISSOR), this._commandBufferEncoder.encodeCommandArgAsFloat32(0), this._commandBufferEncoder.encodeCommandArgAsFloat32(0), this._commandBufferEncoder.encodeCommandArgAsFloat32(0), this._commandBufferEncoder.encodeCommandArgAsFloat32(0), this._commandBufferEncoder.finishEncodingCommand();
      }, t.prototype.setState = function(e, i, r, o, a, s, l) {
        var c, u;
        i === void 0 && (i = 0), o === void 0 && (o = !1), l === void 0 && (l = 0), this._zOffset = i, this._zOffsetUnits = l, this._zOffset !== 0 && de.Warn("zOffset is not supported in Native engine."), this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETSTATE), this._commandBufferEncoder.encodeCommandArgAsUInt32(e ? 1 : 0), this._commandBufferEncoder.encodeCommandArgAsFloat32(i), this._commandBufferEncoder.encodeCommandArgAsFloat32(l), this._commandBufferEncoder.encodeCommandArgAsUInt32((u = (c = this.cullBackFaces) !== null && c !== void 0 ? c : a) === null || u === void 0 || u ? 1 : 0), this._commandBufferEncoder.encodeCommandArgAsUInt32(o ? 1 : 0), this._commandBufferEncoder.finishEncodingCommand();
      }, t.prototype.getInputElementClientRect = function() {
        return { bottom: this.getRenderHeight(), height: this.getRenderHeight(), left: 0, right: this.getRenderWidth(), top: 0, width: this.getRenderWidth(), x: 0, y: 0, toJSON: function() {
        } };
      }, t.prototype.setZOffset = function(e) {
        e !== this._zOffset && (this._zOffset = e, this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETZOFFSET), this._commandBufferEncoder.encodeCommandArgAsFloat32(this.useReverseDepthBuffer ? -e : e), this._commandBufferEncoder.finishEncodingCommand());
      }, t.prototype.getZOffset = function() {
        return this._zOffset;
      }, t.prototype.setZOffsetUnits = function(e) {
        e !== this._zOffsetUnits && (this._zOffsetUnits = e, this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETZOFFSETUNITS), this._commandBufferEncoder.encodeCommandArgAsFloat32(this.useReverseDepthBuffer ? -e : e), this._commandBufferEncoder.finishEncodingCommand());
      }, t.prototype.getZOffsetUnits = function() {
        return this._zOffsetUnits;
      }, t.prototype.setDepthBuffer = function(e) {
        this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETDEPTHTEST), this._commandBufferEncoder.encodeCommandArgAsUInt32(e ? this._currentDepthTest : _native.Engine.DEPTH_TEST_ALWAYS), this._commandBufferEncoder.finishEncodingCommand();
      }, t.prototype.getDepthWrite = function() {
        return this._depthWrite;
      }, t.prototype.getDepthFunction = function() {
        switch (this._currentDepthTest) {
          case _native.Engine.DEPTH_TEST_NEVER:
            return _.NEVER;
          case _native.Engine.DEPTH_TEST_ALWAYS:
            return _.ALWAYS;
          case _native.Engine.DEPTH_TEST_GREATER:
            return _.GREATER;
          case _native.Engine.DEPTH_TEST_GEQUAL:
            return _.GEQUAL;
          case _native.Engine.DEPTH_TEST_NOTEQUAL:
            return _.NOTEQUAL;
          case _native.Engine.DEPTH_TEST_EQUAL:
            return _.EQUAL;
          case _native.Engine.DEPTH_TEST_LESS:
            return _.LESS;
          case _native.Engine.DEPTH_TEST_LEQUAL:
            return _.LEQUAL;
        }
        return null;
      }, t.prototype.setDepthFunction = function(e) {
        var i = 0;
        switch (e) {
          case _.NEVER:
            i = _native.Engine.DEPTH_TEST_NEVER;
            break;
          case _.ALWAYS:
            i = _native.Engine.DEPTH_TEST_ALWAYS;
            break;
          case _.GREATER:
            i = _native.Engine.DEPTH_TEST_GREATER;
            break;
          case _.GEQUAL:
            i = _native.Engine.DEPTH_TEST_GEQUAL;
            break;
          case _.NOTEQUAL:
            i = _native.Engine.DEPTH_TEST_NOTEQUAL;
            break;
          case _.EQUAL:
            i = _native.Engine.DEPTH_TEST_EQUAL;
            break;
          case _.LESS:
            i = _native.Engine.DEPTH_TEST_LESS;
            break;
          case _.LEQUAL:
            i = _native.Engine.DEPTH_TEST_LEQUAL;
        }
        this._currentDepthTest = i, this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETDEPTHTEST), this._commandBufferEncoder.encodeCommandArgAsUInt32(this._currentDepthTest), this._commandBufferEncoder.finishEncodingCommand();
      }, t.prototype.setDepthWrite = function(e) {
        this._depthWrite = e, this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETDEPTHWRITE), this._commandBufferEncoder.encodeCommandArgAsUInt32(Number(e)), this._commandBufferEncoder.finishEncodingCommand();
      }, t.prototype.setColorWrite = function(e) {
        this._colorWrite = e, this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETCOLORWRITE), this._commandBufferEncoder.encodeCommandArgAsUInt32(Number(e)), this._commandBufferEncoder.finishEncodingCommand();
      }, t.prototype.getColorWrite = function() {
        return this._colorWrite;
      }, t.prototype.applyStencil = function() {
        this._setStencil(this._stencilMask, function(e) {
          switch (e) {
            case _.KEEP:
              return _native.Engine.STENCIL_OP_FAIL_S_KEEP;
            case _.ZERO:
              return _native.Engine.STENCIL_OP_FAIL_S_ZERO;
            case _.REPLACE:
              return _native.Engine.STENCIL_OP_FAIL_S_REPLACE;
            case _.INCR:
              return _native.Engine.STENCIL_OP_FAIL_S_INCR;
            case _.DECR:
              return _native.Engine.STENCIL_OP_FAIL_S_DECR;
            case _.INVERT:
              return _native.Engine.STENCIL_OP_FAIL_S_INVERT;
            case _.INCR_WRAP:
              return _native.Engine.STENCIL_OP_FAIL_S_INCRSAT;
            case _.DECR_WRAP:
              return _native.Engine.STENCIL_OP_FAIL_S_DECRSAT;
            default:
              throw new Error("Unsupported stencil OpFail mode: ".concat(e, "."));
          }
        }(this._stencilOpStencilFail), function(e) {
          switch (e) {
            case _.KEEP:
              return _native.Engine.STENCIL_OP_FAIL_Z_KEEP;
            case _.ZERO:
              return _native.Engine.STENCIL_OP_FAIL_Z_ZERO;
            case _.REPLACE:
              return _native.Engine.STENCIL_OP_FAIL_Z_REPLACE;
            case _.INCR:
              return _native.Engine.STENCIL_OP_FAIL_Z_INCR;
            case _.DECR:
              return _native.Engine.STENCIL_OP_FAIL_Z_DECR;
            case _.INVERT:
              return _native.Engine.STENCIL_OP_FAIL_Z_INVERT;
            case _.INCR_WRAP:
              return _native.Engine.STENCIL_OP_FAIL_Z_INCRSAT;
            case _.DECR_WRAP:
              return _native.Engine.STENCIL_OP_FAIL_Z_DECRSAT;
            default:
              throw new Error("Unsupported stencil depthFail mode: ".concat(e, "."));
          }
        }(this._stencilOpDepthFail), function(e) {
          switch (e) {
            case _.KEEP:
              return _native.Engine.STENCIL_OP_PASS_Z_KEEP;
            case _.ZERO:
              return _native.Engine.STENCIL_OP_PASS_Z_ZERO;
            case _.REPLACE:
              return _native.Engine.STENCIL_OP_PASS_Z_REPLACE;
            case _.INCR:
              return _native.Engine.STENCIL_OP_PASS_Z_INCR;
            case _.DECR:
              return _native.Engine.STENCIL_OP_PASS_Z_DECR;
            case _.INVERT:
              return _native.Engine.STENCIL_OP_PASS_Z_INVERT;
            case _.INCR_WRAP:
              return _native.Engine.STENCIL_OP_PASS_Z_INCRSAT;
            case _.DECR_WRAP:
              return _native.Engine.STENCIL_OP_PASS_Z_DECRSAT;
            default:
              throw new Error("Unsupported stencil opPass mode: ".concat(e, "."));
          }
        }(this._stencilOpStencilDepthPass), function(e) {
          switch (e) {
            case _.LESS:
              return _native.Engine.STENCIL_TEST_LESS;
            case _.LEQUAL:
              return _native.Engine.STENCIL_TEST_LEQUAL;
            case _.EQUAL:
              return _native.Engine.STENCIL_TEST_EQUAL;
            case _.GEQUAL:
              return _native.Engine.STENCIL_TEST_GEQUAL;
            case _.GREATER:
              return _native.Engine.STENCIL_TEST_GREATER;
            case _.NOTEQUAL:
              return _native.Engine.STENCIL_TEST_NOTEQUAL;
            case _.NEVER:
              return _native.Engine.STENCIL_TEST_NEVER;
            case _.ALWAYS:
              return _native.Engine.STENCIL_TEST_ALWAYS;
            default:
              throw new Error("Unsupported stencil func mode: ".concat(e, "."));
          }
        }(this._stencilFunc), this._stencilFuncRef);
      }, t.prototype._setStencil = function(e, i, r, o, a, s) {
        this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETSTENCIL), this._commandBufferEncoder.encodeCommandArgAsUInt32(e), this._commandBufferEncoder.encodeCommandArgAsUInt32(i), this._commandBufferEncoder.encodeCommandArgAsUInt32(r), this._commandBufferEncoder.encodeCommandArgAsUInt32(o), this._commandBufferEncoder.encodeCommandArgAsUInt32(a), this._commandBufferEncoder.encodeCommandArgAsUInt32(s), this._commandBufferEncoder.finishEncodingCommand();
      }, t.prototype.setStencilBuffer = function(e) {
        this._stencilTest = e, e ? this.applyStencil() : this._setStencil(255, _native.Engine.STENCIL_OP_FAIL_S_KEEP, _native.Engine.STENCIL_OP_FAIL_Z_KEEP, _native.Engine.STENCIL_OP_PASS_Z_KEEP, _native.Engine.STENCIL_TEST_ALWAYS, 0);
      }, t.prototype.getStencilBuffer = function() {
        return this._stencilTest;
      }, t.prototype.getStencilOperationPass = function() {
        return this._stencilOpStencilDepthPass;
      }, t.prototype.setStencilOperationPass = function(e) {
        this._stencilOpStencilDepthPass = e, this.applyStencil();
      }, t.prototype.setStencilMask = function(e) {
        this._stencilMask = e, this.applyStencil();
      }, t.prototype.setStencilFunction = function(e) {
        this._stencilFunc = e, this.applyStencil();
      }, t.prototype.setStencilFunctionReference = function(e) {
        this._stencilFuncRef = e, this.applyStencil();
      }, t.prototype.setStencilFunctionMask = function(e) {
        this._stencilFuncMask = e;
      }, t.prototype.setStencilOperationFail = function(e) {
        this._stencilOpStencilFail = e, this.applyStencil();
      }, t.prototype.setStencilOperationDepthFail = function(e) {
        this._stencilOpDepthFail = e, this.applyStencil();
      }, t.prototype.getStencilMask = function() {
        return this._stencilMask;
      }, t.prototype.getStencilFunction = function() {
        return this._stencilFunc;
      }, t.prototype.getStencilFunctionReference = function() {
        return this._stencilFuncRef;
      }, t.prototype.getStencilFunctionMask = function() {
        return this._stencilFuncMask;
      }, t.prototype.getStencilOperationFail = function() {
        return this._stencilOpStencilFail;
      }, t.prototype.getStencilOperationDepthFail = function() {
        return this._stencilOpDepthFail;
      }, t.prototype.setAlphaConstants = function(e, i, r, o) {
        throw new Error("Setting alpha blend constant color not yet implemented.");
      }, t.prototype.setAlphaMode = function(e, i) {
        if (i === void 0 && (i = !1), this._alphaMode !== e) {
          var r = function(o) {
            switch (o) {
              case _.ALPHA_DISABLE:
                return _native.Engine.ALPHA_DISABLE;
              case _.ALPHA_ADD:
                return _native.Engine.ALPHA_ADD;
              case _.ALPHA_COMBINE:
                return _native.Engine.ALPHA_COMBINE;
              case _.ALPHA_SUBTRACT:
                return _native.Engine.ALPHA_SUBTRACT;
              case _.ALPHA_MULTIPLY:
                return _native.Engine.ALPHA_MULTIPLY;
              case _.ALPHA_MAXIMIZED:
                return _native.Engine.ALPHA_MAXIMIZED;
              case _.ALPHA_ONEONE:
                return _native.Engine.ALPHA_ONEONE;
              case _.ALPHA_PREMULTIPLIED:
                return _native.Engine.ALPHA_PREMULTIPLIED;
              case _.ALPHA_PREMULTIPLIED_PORTERDUFF:
                return _native.Engine.ALPHA_PREMULTIPLIED_PORTERDUFF;
              case _.ALPHA_INTERPOLATE:
                return _native.Engine.ALPHA_INTERPOLATE;
              case _.ALPHA_SCREENMODE:
                return _native.Engine.ALPHA_SCREENMODE;
              default:
                throw new Error("Unsupported alpha mode: ".concat(o, "."));
            }
          }(e);
          this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETBLENDMODE), this._commandBufferEncoder.encodeCommandArgAsUInt32(r), this._commandBufferEncoder.finishEncodingCommand(), i || this.setDepthWrite(e === _.ALPHA_DISABLE), this._alphaMode = e;
        }
      }, t.prototype.getAlphaMode = function() {
        return this._alphaMode;
      }, t.prototype.setInt = function(e, i) {
        return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINT), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsInt32(i), this._commandBufferEncoder.finishEncodingCommand(), !0);
      }, t.prototype.setIntArray = function(e, i) {
        return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINTARRAY), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsInt32s(i), this._commandBufferEncoder.finishEncodingCommand(), !0);
      }, t.prototype.setIntArray2 = function(e, i) {
        return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINTARRAY2), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsInt32s(i), this._commandBufferEncoder.finishEncodingCommand(), !0);
      }, t.prototype.setIntArray3 = function(e, i) {
        return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINTARRAY3), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsInt32s(i), this._commandBufferEncoder.finishEncodingCommand(), !0);
      }, t.prototype.setIntArray4 = function(e, i) {
        return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINTARRAY4), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsInt32s(i), this._commandBufferEncoder.finishEncodingCommand(), !0);
      }, t.prototype.setFloatArray = function(e, i) {
        return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOATARRAY), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsFloat32s(i), this._commandBufferEncoder.finishEncodingCommand(), !0);
      }, t.prototype.setFloatArray2 = function(e, i) {
        return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOATARRAY2), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsFloat32s(i), this._commandBufferEncoder.finishEncodingCommand(), !0);
      }, t.prototype.setFloatArray3 = function(e, i) {
        return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOATARRAY3), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsFloat32s(i), this._commandBufferEncoder.finishEncodingCommand(), !0);
      }, t.prototype.setFloatArray4 = function(e, i) {
        return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOATARRAY4), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsFloat32s(i), this._commandBufferEncoder.finishEncodingCommand(), !0);
      }, t.prototype.setArray = function(e, i) {
        return !!e && this.setFloatArray(e, new Float32Array(i));
      }, t.prototype.setArray2 = function(e, i) {
        return !!e && this.setFloatArray2(e, new Float32Array(i));
      }, t.prototype.setArray3 = function(e, i) {
        return !!e && this.setFloatArray3(e, new Float32Array(i));
      }, t.prototype.setArray4 = function(e, i) {
        return !!e && this.setFloatArray4(e, new Float32Array(i));
      }, t.prototype.setMatrices = function(e, i) {
        return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETMATRICES), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsFloat32s(i), this._commandBufferEncoder.finishEncodingCommand(), !0);
      }, t.prototype.setMatrix3x3 = function(e, i) {
        return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETMATRIX3X3), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsFloat32s(i), this._commandBufferEncoder.finishEncodingCommand(), !0);
      }, t.prototype.setMatrix2x2 = function(e, i) {
        return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETMATRIX2X2), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsFloat32s(i), this._commandBufferEncoder.finishEncodingCommand(), !0);
      }, t.prototype.setFloat = function(e, i) {
        return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsFloat32(i), this._commandBufferEncoder.finishEncodingCommand(), !0);
      }, t.prototype.setFloat2 = function(e, i, r) {
        return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT2), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsFloat32(i), this._commandBufferEncoder.encodeCommandArgAsFloat32(r), this._commandBufferEncoder.finishEncodingCommand(), !0);
      }, t.prototype.setFloat3 = function(e, i, r, o) {
        return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT3), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsFloat32(i), this._commandBufferEncoder.encodeCommandArgAsFloat32(r), this._commandBufferEncoder.encodeCommandArgAsFloat32(o), this._commandBufferEncoder.finishEncodingCommand(), !0);
      }, t.prototype.setFloat4 = function(e, i, r, o, a) {
        return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT4), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsFloat32(i), this._commandBufferEncoder.encodeCommandArgAsFloat32(r), this._commandBufferEncoder.encodeCommandArgAsFloat32(o), this._commandBufferEncoder.encodeCommandArgAsFloat32(a), this._commandBufferEncoder.finishEncodingCommand(), !0);
      }, t.prototype.setColor3 = function(e, i) {
        return !!e && (this.setFloat3(e, i.r, i.g, i.b), !0);
      }, t.prototype.setColor4 = function(e, i, r) {
        return !!e && (this.setFloat4(e, i.r, i.g, i.b, r), !0);
      }, t.prototype.wipeCaches = function(e) {
        this.preventCacheWipeBetweenFrames || (this.resetTextureCache(), this._currentEffect = null, e && (this._currentProgram = null, this._stencilStateComposer.reset(), this._depthCullingState.reset(), this._alphaState.reset()), this._cachedVertexBuffers = null, this._cachedIndexBuffer = null, this._cachedEffectForVertexBuffers = null);
      }, t.prototype._createTexture = function() {
        return this._engine.createTexture();
      }, t.prototype._deleteTexture = function(e) {
        e && this._engine.deleteTexture(e);
      }, t.prototype.updateDynamicTexture = function(e, i, r, o, a) {
        if (e && e._hardwareTexture) {
          var s = i.getCanvasTexture(), l = e._hardwareTexture.underlyingResource;
          this._engine.copyTexture(l, s), e.isReady = !0;
        }
      }, t.prototype.createDynamicTexture = function(e, i, r, o) {
        return e = Math.max(e, 1), i = Math.max(i, 1), this.createRawTexture(new Uint8Array(e * i * 4), e, i, _.TEXTUREFORMAT_RGBA, !1, !1, o);
      }, t.prototype.createVideoElement = function(e) {
        return this._camera ? this._camera.createVideo(e) : null;
      }, t.prototype.updateVideoTexture = function(e, i, r) {
        if (e && e._hardwareTexture && this._camera) {
          var o = e._hardwareTexture.underlyingResource;
          this._camera.updateVideoTexture(o, i, r);
        }
      }, t.prototype.createRawTexture = function(e, i, r, o, a, s, l, c, u, h, d) {
        c === void 0 && (c = null), u === void 0 && (u = _.TEXTURETYPE_UNSIGNED_INT), d === void 0 && (d = !1);
        var p = new Ut(this, ut.Raw);
        if (p.format = o, p.generateMipMaps = a, p.samplingMode = l, p.invertY = s, p.baseWidth = i, p.baseHeight = r, p.width = p.baseWidth, p.height = p.baseHeight, p._compression = c, p.type = u, p._useSRGBBuffer = this._getUseSRGBBuffer(d, !a), this.updateRawTexture(p, e, o, s, c, u, p._useSRGBBuffer), p._hardwareTexture) {
          var f = p._hardwareTexture.underlyingResource, m = Uh(l);
          this._setTextureSampling(f, m);
        }
        return this._internalTexturesCache.push(p), p;
      }, t.prototype.createRawTexture2DArray = function(e, i, r, o, a, s, l, c, u, h) {
        h === void 0 && (h = _.TEXTURETYPE_UNSIGNED_INT);
        var d = new Ut(this, ut.Raw2DArray);
        if (d.baseWidth = i, d.baseHeight = r, d.baseDepth = o, d.width = i, d.height = r, d.depth = o, d.format = a, d.type = h, d.generateMipMaps = s, d.samplingMode = c, d.is2DArray = !0, d._hardwareTexture) {
          var p = d._hardwareTexture.underlyingResource;
          this._engine.loadRawTexture2DArray(p, e, i, r, o, ey(a, h), s, l);
          var f = Uh(c);
          this._setTextureSampling(p, f);
        }
        return d.isReady = !0, this._internalTexturesCache.push(d), d;
      }, t.prototype.updateRawTexture = function(e, i, r, o, a, s, l) {
        if (s === void 0 && (s = _.TEXTURETYPE_UNSIGNED_INT), e) {
          if (i && e._hardwareTexture) {
            var c = e._hardwareTexture.underlyingResource;
            this._engine.loadRawTexture(c, i, e.width, e.height, ey(r, s), e.generateMipMaps, e.invertY);
          }
          e.isReady = !0;
        }
      }, t.prototype.createTexture = function(e, i, r, o, a, s, l, c, u, h, d, p, f, m, g) {
        var y = this;
        a === void 0 && (a = _.TEXTURE_TRILINEAR_SAMPLINGMODE), s === void 0 && (s = null), l === void 0 && (l = null), c === void 0 && (c = null), u === void 0 && (u = null), h === void 0 && (h = null), d === void 0 && (d = null), g === void 0 && (g = !1);
        var b = (e = e || "").substr(0, 5) === "data:", T = b && e.indexOf(";base64,") !== -1, S = u || new Ut(this, ut.Url), E = e;
        !this._transformTextureUrl || T || u || c || (e = this._transformTextureUrl(e));
        for (var A = e.lastIndexOf("."), R = d || (A > -1 ? e.substring(A).toLowerCase() : ""), C = null, L = 0, I = ve._TextureLoaders; L < I.length; L++) {
          var O = I[L];
          if (O.canLoad(R)) {
            C = O;
            break;
          }
        }
        o && o.addPendingData(S), S.url = e, S.generateMipMaps = !i, S.samplingMode = a, S.invertY = r, S._useSRGBBuffer = this._getUseSRGBBuffer(g, i), this.doNotHandleContextLost || (S._buffer = c);
        var w = null;
        if (s && !u && (w = S.onLoadedObservable.add(s)), u || this._internalTexturesCache.push(S), C)
          throw new Error("Loading textures from IInternalTextureLoader not yet implemented.");
        var z = function(V) {
          if (S._hardwareTexture) {
            var Y = S._hardwareTexture.underlyingResource;
            y._engine.loadTexture(Y, V, !i, r, S._useSRGBBuffer, function() {
              S.baseWidth = y._engine.getTextureWidth(Y), S.baseHeight = y._engine.getTextureHeight(Y), S.width = S.baseWidth, S.height = S.baseHeight, S.isReady = !0;
              var ee = Uh(a);
              y._setTextureSampling(Y, ee), o && o.removePendingData(S), S.onLoadedObservable.notifyObservers(S), S.onLoadedObservable.clear();
            }, function() {
              throw new Error("Could not load a native texture.");
            });
          } else
            o && o.removePendingData(S);
        };
        if (b && c)
          if (c instanceof ArrayBuffer)
            z(new Uint8Array(c));
          else if (ArrayBuffer.isView(c))
            z(c);
          else {
            if (typeof c != "string")
              throw new Error("Unsupported buffer type");
            z(new Uint8Array(de.DecodeBase64(c)));
          }
        else
          T ? z(new Uint8Array(de.DecodeBase64(e))) : this._loadFile(e, function(V) {
            return z(new Uint8Array(V));
          }, void 0, void 0, !0, function(V, Y) {
            var ee;
            ee = "Unable to load " + (V && V.responseURL, Y), o && o.removePendingData(S), e === E ? (w && S.onLoadedObservable.remove(w), Me.UseFallbackTexture && y.createTexture(Me.FallbackTexture, i, S.invertY, o, a, null, l, c, S), l && l((ee || "Unknown error") + (Me.UseFallbackTexture ? " - Fallback texture was used" : ""), void 0)) : (q.Warn("Failed to load ".concat(e, ", falling back to ").concat(E)), y.createTexture(E, i, S.invertY, o, a, s, l, c, S, h, d, p, f));
          });
        return S;
      }, t.prototype.wrapNativeTexture = function(e, i, r) {
        i === void 0 && (i = !1), r === void 0 && (r = _.TEXTURE_TRILINEAR_SAMPLINGMODE);
        var o = new yC(e, this._engine), a = new Ut(this, ut.Unknown, !0);
        return a._hardwareTexture = o, a.baseWidth = this._engine.getTextureWidth(e), a.baseHeight = this._engine.getTextureHeight(e), a.width = a.baseWidth, a.height = a.baseHeight, a.isReady = !0, a.useMipMaps = i, this.updateTextureSamplingMode(r, a), a;
      }, t.prototype.wrapWebGLTexture = function() {
        throw new Error("wrapWebGLTexture is not supported, use wrapNativeTexture instead.");
      }, t.prototype._createDepthStencilTexture = function(e, i, r) {
        var o, a, s = i.generateStencil || !1, l = i.samples || 1, c = r, u = new Ut(this, ut.DepthStencil), h = (o = e.width) !== null && o !== void 0 ? o : e, d = (a = e.height) !== null && a !== void 0 ? a : e, p = this._engine.createFrameBuffer(u._hardwareTexture.underlyingResource, h, d, s, !0, l);
        return c._framebufferDepthStencil = p, u;
      }, t.prototype._releaseFramebufferObjects = function(e) {
        e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEFRAMEBUFFER), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.finishEncodingCommand());
      }, t.prototype._createImageBitmapFromSource = function(e, i) {
        var r = this;
        return new Promise(function(o, a) {
          var s = r.createCanvasImage();
          s.onload = function() {
            try {
              var l = r._engine.createImageBitmap(s);
              o(l);
            } catch (c) {
              a("Error loading image ".concat(s.src, " with exception: ").concat(c));
            }
          }, s.onerror = function(l) {
            a("Error loading image ".concat(s.src, " with exception: ").concat(l));
          }, s.src = e;
        });
      }, t.prototype.createImageBitmap = function(e, i) {
        var r = this;
        return new Promise(function(o, a) {
          if (Array.isArray(e)) {
            var s = e;
            if (s.length) {
              var l = r._engine.createImageBitmap(s[0]);
              if (l)
                return void o(l);
            }
          }
          a("Unsupported data for createImageBitmap.");
        });
      }, t.prototype.resizeImageBitmap = function(e, i, r) {
        return this._engine.resizeImageBitmap(e, i, r);
      }, t.prototype.createCubeTexture = function(e, i, r, o, a, s, l, c, u, h, d, p, f, m) {
        var g = this;
        a === void 0 && (a = null), s === void 0 && (s = null), c === void 0 && (c = null), h === void 0 && (h = 0), d === void 0 && (d = 0), p === void 0 && (p = null), m === void 0 && (m = !1);
        var y = p || new Ut(this, ut.Cube);
        y.isCube = !0, y.url = e, y.generateMipMaps = !o, y._lodGenerationScale = h, y._lodGenerationOffset = d, y._useSRGBBuffer = this._getUseSRGBBuffer(m, !!o), this._doNotHandleContextLost || (y._extension = c, y._files = r);
        var b = e.lastIndexOf(".");
        if ((c || (b > -1 ? e.substring(b).toLowerCase() : "")) === ".env") {
          if (r && r.length === 6)
            throw new Error("Multi-file loading not allowed on env files.");
          this._loadFile(e, function(S) {
            return function(E) {
              var A = Lh(E);
              y.width = A.width, y.height = A.width, Bh(y, A);
              var R = A.specular;
              if (!R)
                throw new Error("Nothing else parsed so far");
              y._lodGenerationScale = R.lodGenerationScale;
              var C = wh(E, A);
              y.format = _.TEXTUREFORMAT_RGBA, y.type = _.TEXTURETYPE_UNSIGNED_INT, y.generateMipMaps = !0, y.getEngine().updateTextureSamplingMode(ae.TRILINEAR_SAMPLINGMODE, y), y._isRGBD = !0, y.invertY = !0, g._engine.loadCubeTextureWithMips(y._hardwareTexture.underlyingResource, C, !1, y._useSRGBBuffer, function() {
                y.isReady = !0, a && a();
              }, function() {
                throw new Error("Could not load a native cube texture.");
              });
            }(new Uint8Array(S));
          }, void 0, void 0, !0, function(S, E) {
            s && S && s(S.status + " " + S.statusText, E);
          });
        } else {
          if (!r || r.length !== 6)
            throw new Error("Cannot load cubemap because 6 files were not defined");
          var T = [r[0], r[3], r[1], r[4], r[2], r[5]];
          Promise.all(T.map(function(S) {
            return de.LoadFileAsync(S).then(function(E) {
              return new Uint8Array(E);
            });
          })).then(function(S) {
            return new Promise(function(E, A) {
              g._engine.loadCubeTexture(y._hardwareTexture.underlyingResource, S, !o, !0, y._useSRGBBuffer, E, A);
            });
          }).then(function() {
            y.isReady = !0, a && a();
          }, function(S) {
            s && s("Failed to load cubemap: ".concat(S.message), S);
          });
        }
        return this._internalTexturesCache.push(y), y;
      }, t.prototype._createHardwareTexture = function() {
        return new yC(this._createTexture(), this._engine);
      }, t.prototype._createHardwareRenderTargetWrapper = function(e, i, r) {
        var o = new lD(e, i, r, this);
        return this._renderTargetWrapperCache.push(o), o;
      }, t.prototype._createInternalTexture = function(e, i, r, o) {
        var a, s, l;
        o === void 0 && (o = ut.Unknown);
        var c, u = !1, h = _.TEXTURETYPE_UNSIGNED_INT, d = _.TEXTURE_TRILINEAR_SAMPLINGMODE, p = _.TEXTUREFORMAT_RGBA, f = !1, m = 1;
        i !== void 0 && typeof i == "object" ? (u = !!i.generateMipMaps, h = i.type === void 0 ? _.TEXTURETYPE_UNSIGNED_INT : i.type, d = i.samplingMode === void 0 ? _.TEXTURE_TRILINEAR_SAMPLINGMODE : i.samplingMode, p = i.format === void 0 ? _.TEXTUREFORMAT_RGBA : i.format, f = i.useSRGBBuffer !== void 0 && i.useSRGBBuffer, m = (a = i.samples) !== null && a !== void 0 ? a : 1, c = i.label) : u = !!i, f = this._getUseSRGBBuffer(f, !u), (h !== _.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (h !== _.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (d = _.TEXTURE_NEAREST_SAMPLINGMODE), h !== _.TEXTURETYPE_FLOAT || this._caps.textureFloat || (h = _.TEXTURETYPE_UNSIGNED_INT, q.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));
        var g = new Ut(this, o), y = (s = e.width) !== null && s !== void 0 ? s : e, b = (l = e.height) !== null && l !== void 0 ? l : e, T = e.layers || 0;
        if (T !== 0)
          throw new Error("Texture layers are not supported in Babylon Native");
        var S = g._hardwareTexture.underlyingResource, E = ey(p, h);
        return this._engine.initializeTexture(S, y, b, u, E, !0, f, m), this._setTextureSampling(S, Uh(d)), g._useSRGBBuffer = f, g.baseWidth = y, g.baseHeight = b, g.width = y, g.height = b, g.depth = T, g.isReady = !0, g.samples = m, g.generateMipMaps = u, g.samplingMode = d, g.type = h, g.format = p, g.label = c, this._internalTexturesCache.push(g), g;
      }, t.prototype.createRenderTargetTexture = function(e, i) {
        var r, o, a, s, l = this._createHardwareRenderTargetWrapper(!1, !1, e), c = !0, u = !1, h = !1, d = void 0, p = 1;
        i !== void 0 && typeof i == "object" && (c = (r = i.generateDepthBuffer) === null || r === void 0 || r, u = !!i.generateStencilBuffer, h = !!i.noColorAttachment, d = i.colorAttachment, p = (o = i.samples) !== null && o !== void 0 ? o : 1);
        var f = d || (h ? null : this._createInternalTexture(e, i, !0, ut.RenderTarget)), m = (a = e.width) !== null && a !== void 0 ? a : e, g = (s = e.height) !== null && s !== void 0 ? s : e, y = this._engine.createFrameBuffer(f ? f._hardwareTexture.underlyingResource : null, m, g, u, c, p);
        return l._framebuffer = y, l._generateDepthBuffer = c, l._generateStencilBuffer = u, l._samples = p, l.setTextures(f), l;
      }, t.prototype.updateRenderTargetTextureSampleCount = function(e, i) {
        return q.Warn("Updating render target sample count is not currently supported"), e.samples;
      }, t.prototype.updateTextureSamplingMode = function(e, i) {
        if (i._hardwareTexture) {
          var r = Uh(e);
          this._setTextureSampling(i._hardwareTexture.underlyingResource, r);
        }
        i.samplingMode = e;
      }, t.prototype.bindFramebuffer = function(e, i, r, o, a) {
        var s = e;
        if (this._currentRenderTarget && this.unBindFramebuffer(this._currentRenderTarget), this._currentRenderTarget = e, i)
          throw new Error("Cuboid frame buffers are not yet supported in NativeEngine.");
        if (r || o)
          throw new Error("Required width/height for frame buffers not yet supported in NativeEngine.");
        s._framebufferDepthStencil ? this._bindUnboundFramebuffer(s._framebufferDepthStencil) : this._bindUnboundFramebuffer(s._framebuffer);
      }, t.prototype.unBindFramebuffer = function(e, i, r) {
        this._currentRenderTarget = null, r && r(), this._bindUnboundFramebuffer(null);
      }, t.prototype.createDynamicVertexBuffer = function(e) {
        return this.createVertexBuffer(e, !0);
      }, t.prototype.updateDynamicIndexBuffer = function(e, i, r) {
        r === void 0 && (r = 0);
        var o = e, a = this._normalizeIndexData(i);
        o.is32Bits = a.BYTES_PER_ELEMENT === 4, this._engine.updateDynamicIndexBuffer(o.nativeIndexBuffer, a.buffer, a.byteOffset, a.byteLength, r);
      }, t.prototype.updateDynamicVertexBuffer = function(e, i, r, o) {
        var a = e, s = ArrayBuffer.isView(i) ? i : new Float32Array(i);
        this._engine.updateDynamicVertexBuffer(a.nativeVertexBuffer, s.buffer, s.byteOffset + (r ?? 0), o ?? s.byteLength);
      }, t.prototype._setTexture = function(e, i, r, o) {
        o === void 0 && (o = !1);
        var a, s = this._boundUniforms[e];
        if (!s)
          return !1;
        if (!i)
          return this._boundTexturesCache[e] != null && (this._activeChannel = e, this._boundTexturesCache[e] = null), !1;
        if (i.video)
          this._activeChannel = e, i.update();
        else if (i.delayLoadState === _.DELAYLOADSTATE_NOTLOADED)
          return i.delayLoad(), !1;
        return a = o ? i.depthStencilTexture : i.isReady() ? i.getInternalTexture() : i.isCube ? this.emptyCubeTexture : i.is3D ? this.emptyTexture3D : i.is2DArray ? this.emptyTexture2DArray : this.emptyTexture, this._activeChannel = e, !(!a || !a._hardwareTexture || (this._setTextureWrapMode(a._hardwareTexture.underlyingResource, ty(i.wrapU), ty(i.wrapV), ty(i.wrapR)), this._updateAnisotropicLevel(i), this._setTextureCore(s, a._hardwareTexture.underlyingResource), 0));
      }, t.prototype._setTextureSampling = function(e, i) {
        this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTURESAMPLING), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsUInt32(i), this._commandBufferEncoder.finishEncodingCommand();
      }, t.prototype._setTextureWrapMode = function(e, i, r, o) {
        this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTUREWRAPMODE), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsUInt32(i), this._commandBufferEncoder.encodeCommandArgAsUInt32(r), this._commandBufferEncoder.encodeCommandArgAsUInt32(o), this._commandBufferEncoder.finishEncodingCommand();
      }, t.prototype._setTextureCore = function(e, i) {
        this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTURE), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsNativeData(i), this._commandBufferEncoder.finishEncodingCommand();
      }, t.prototype._updateAnisotropicLevel = function(e) {
        var i = e.getInternalTexture(), r = e.anisotropicFilteringLevel;
        i && i._hardwareTexture && i._cachedAnisotropicFilteringLevel !== r && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTUREANISOTROPICLEVEL), this._commandBufferEncoder.encodeCommandArgAsNativeData(i._hardwareTexture.underlyingResource), this._commandBufferEncoder.encodeCommandArgAsUInt32(r), this._commandBufferEncoder.finishEncodingCommand(), i._cachedAnisotropicFilteringLevel = r);
      }, t.prototype._bindTexture = function(e, i) {
        var r = this._boundUniforms[e];
        if (r && i && i._hardwareTexture) {
          var o = i._hardwareTexture.underlyingResource;
          this._setTextureCore(r, o);
        }
      }, t.prototype._deleteBuffer = function(e) {
        e.nativeIndexBuffer && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEINDEXBUFFER), this._commandBufferEncoder.encodeCommandArgAsNativeData(e.nativeIndexBuffer), this._commandBufferEncoder.finishEncodingCommand(), delete e.nativeIndexBuffer), e.nativeVertexBuffer && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEVERTEXBUFFER), this._commandBufferEncoder.encodeCommandArgAsNativeData(e.nativeVertexBuffer), this._commandBufferEncoder.finishEncodingCommand(), delete e.nativeVertexBuffer);
      }, t.prototype.createCanvas = function(e, i) {
        if (!_native.Canvas)
          throw new Error("Native Canvas plugin not available.");
        var r = new _native.Canvas();
        return r.width = e, r.height = i, r;
      }, t.prototype.createCanvasImage = function() {
        if (!_native.Canvas)
          throw new Error("Native Canvas plugin not available.");
        return new _native.Image();
      }, t.prototype.updateTextureData = function(e, i, r, o, a, s, l, c, u) {
        throw new Error("updateTextureData not implemented.");
      }, t.prototype._uploadCompressedDataToTextureDirectly = function(e, i, r, o, a, s, l) {
        throw new Error("_uploadCompressedDataToTextureDirectly not implemented.");
      }, t.prototype._uploadDataToTextureDirectly = function(e, i, r, o) {
        throw new Error("_uploadDataToTextureDirectly not implemented.");
      }, t.prototype._uploadArrayBufferViewToTexture = function(e, i, r, o) {
        throw new Error("_uploadArrayBufferViewToTexture not implemented.");
      }, t.prototype._uploadImageToTexture = function(e, i, r, o) {
        throw new Error("_uploadArrayBufferViewToTexture not implemented.");
      }, t.prototype.getFontOffset = function(e) {
        return { ascent: 0, height: 0, descent: 0 };
      }, t.prototype._readTexturePixels = function(e, i, r, o, a, s, l, c, u, h) {
        var d, p, f, m;
        if (o !== void 0 && o !== -1)
          throw new Error("Reading cubemap faces is not supported, but faceIndex is ".concat(o, "."));
        return this._engine.readTexture((d = e._hardwareTexture) === null || d === void 0 ? void 0 : d.underlyingResource, a ?? 0, u ?? 0, h ?? 0, i, r, (p = s == null ? void 0 : s.buffer) !== null && p !== void 0 ? p : null, (f = s == null ? void 0 : s.byteOffset) !== null && f !== void 0 ? f : 0, (m = s == null ? void 0 : s.byteLength) !== null && m !== void 0 ? m : 0).then(function(g) {
          return s || (s = new Uint8Array(g)), s;
        });
      }, t.PROTOCOL_VERSION = 8, t;
    }(ve);
    kf._createNativeDataStream = function() {
      return _native.NativeDataStream.VALIDATION_ENABLED ? new oy() : new Ih();
    };
    var Gf, Lo, zf, $t, Ya, Ir, fi, ei, no, U, As, Ct, Wf, an, _a, ma, ga, nr, Vh, Hf, Xf, xl, rr, Uc, Al, jf, An, va, Vr, ya, bi, Vc, Yf, Kf, ji, pr, kc, Gc, qf, Qf, oy = function(n) {
      function t() {
        return n.call(this) || this;
      }
      return D(t, n), t.prototype.writeUint32 = function(e) {
        n.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_UINT_32), n.prototype.writeUint32.call(this, e);
      }, t.prototype.writeInt32 = function(e) {
        n.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_INT_32), n.prototype.writeInt32.call(this, e);
      }, t.prototype.writeFloat32 = function(e) {
        n.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_FLOAT_32), n.prototype.writeFloat32.call(this, e);
      }, t.prototype.writeUint32Array = function(e) {
        n.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_UINT_32_ARRAY), n.prototype.writeUint32Array.call(this, e);
      }, t.prototype.writeInt32Array = function(e) {
        n.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_INT_32_ARRAY), n.prototype.writeInt32Array.call(this, e);
      }, t.prototype.writeFloat32Array = function(e) {
        n.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_FLOAT_32_ARRAY), n.prototype.writeFloat32Array.call(this, e);
      }, t.prototype.writeNativeData = function(e) {
        n.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_NATIVE_DATA), n.prototype.writeNativeData.call(this, e);
      }, t.prototype.writeBoolean = function(e) {
        n.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_BOOLEAN), n.prototype.writeBoolean.call(this, e);
      }, t;
    }(Ih);
    (function(n) {
      n.LowPower = "low-power", n.HighPerformance = "high-performance";
    })(Gf || (Gf = {})), function(n) {
      n.DepthClipControl = "depth-clip-control", n.Depth32FloatStencil8 = "depth32float-stencil8", n.TextureCompressionBC = "texture-compression-bc", n.TextureCompressionETC2 = "texture-compression-etc2", n.TextureCompressionASTC = "texture-compression-astc", n.TimestampQuery = "timestamp-query", n.IndirectFirstInstance = "indirect-first-instance", n.ShaderF16 = "shader-f16", n.RG11B10UFloatRenderable = "rg11b10ufloat-renderable", n.BGRA8UnormStorage = "bgra8unorm-storage", n.Float32Filterable = "float32-filterable";
    }(Lo || (Lo = {})), function(n) {
      n.Unmapped = "unmapped", n.Pending = "pending", n.Mapped = "mapped";
    }(zf || (zf = {})), function(n) {
      n[n.MapRead = 1] = "MapRead", n[n.MapWrite = 2] = "MapWrite", n[n.CopySrc = 4] = "CopySrc", n[n.CopyDst = 8] = "CopyDst", n[n.Index = 16] = "Index", n[n.Vertex = 32] = "Vertex", n[n.Uniform = 64] = "Uniform", n[n.Storage = 128] = "Storage", n[n.Indirect = 256] = "Indirect", n[n.QueryResolve = 512] = "QueryResolve";
    }($t || ($t = {})), function(n) {
      n[n.Read = 1] = "Read", n[n.Write = 2] = "Write";
    }(Ya || (Ya = {})), function(n) {
      n.E1d = "1d", n.E2d = "2d", n.E3d = "3d";
    }(Ir || (Ir = {})), function(n) {
      n[n.CopySrc = 1] = "CopySrc", n[n.CopyDst = 2] = "CopyDst", n[n.TextureBinding = 4] = "TextureBinding", n[n.StorageBinding = 8] = "StorageBinding", n[n.RenderAttachment = 16] = "RenderAttachment";
    }(fi || (fi = {})), function(n) {
      n.E1d = "1d", n.E2d = "2d", n.E2dArray = "2d-array", n.Cube = "cube", n.CubeArray = "cube-array", n.E3d = "3d";
    }(ei || (ei = {})), function(n) {
      n.All = "all", n.StencilOnly = "stencil-only", n.DepthOnly = "depth-only";
    }(no || (no = {})), function(n) {
      n.R8Unorm = "r8unorm", n.R8Snorm = "r8snorm", n.R8Uint = "r8uint", n.R8Sint = "r8sint", n.R16Uint = "r16uint", n.R16Sint = "r16sint", n.R16Float = "r16float", n.RG8Unorm = "rg8unorm", n.RG8Snorm = "rg8snorm", n.RG8Uint = "rg8uint", n.RG8Sint = "rg8sint", n.R32Uint = "r32uint", n.R32Sint = "r32sint", n.R32Float = "r32float", n.RG16Uint = "rg16uint", n.RG16Sint = "rg16sint", n.RG16Float = "rg16float", n.RGBA8Unorm = "rgba8unorm", n.RGBA8UnormSRGB = "rgba8unorm-srgb", n.RGBA8Snorm = "rgba8snorm", n.RGBA8Uint = "rgba8uint", n.RGBA8Sint = "rgba8sint", n.BGRA8Unorm = "bgra8unorm", n.BGRA8UnormSRGB = "bgra8unorm-srgb", n.RGB9E5UFloat = "rgb9e5ufloat", n.RGB10A2UINT = "rgb10a2uint", n.RGB10A2Unorm = "rgb10a2unorm", n.RG11B10UFloat = "rg11b10ufloat", n.RG32Uint = "rg32uint", n.RG32Sint = "rg32sint", n.RG32Float = "rg32float", n.RGBA16Uint = "rgba16uint", n.RGBA16Sint = "rgba16sint", n.RGBA16Float = "rgba16float", n.RGBA32Uint = "rgba32uint", n.RGBA32Sint = "rgba32sint", n.RGBA32Float = "rgba32float", n.Stencil8 = "stencil8", n.Depth16Unorm = "depth16unorm", n.Depth24Plus = "depth24plus", n.Depth24PlusStencil8 = "depth24plus-stencil8", n.Depth32Float = "depth32float", n.BC1RGBAUnorm = "bc1-rgba-unorm", n.BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb", n.BC2RGBAUnorm = "bc2-rgba-unorm", n.BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb", n.BC3RGBAUnorm = "bc3-rgba-unorm", n.BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb", n.BC4RUnorm = "bc4-r-unorm", n.BC4RSnorm = "bc4-r-snorm", n.BC5RGUnorm = "bc5-rg-unorm", n.BC5RGSnorm = "bc5-rg-snorm", n.BC6HRGBUFloat = "bc6h-rgb-ufloat", n.BC6HRGBFloat = "bc6h-rgb-float", n.BC7RGBAUnorm = "bc7-rgba-unorm", n.BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb", n.ETC2RGB8Unorm = "etc2-rgb8unorm", n.ETC2RGB8UnormSRGB = "etc2-rgb8unorm-srgb", n.ETC2RGB8A1Unorm = "etc2-rgb8a1unorm", n.ETC2RGB8A1UnormSRGB = "etc2-rgb8a1unorm-srgb", n.ETC2RGBA8Unorm = "etc2-rgba8unorm", n.ETC2RGBA8UnormSRGB = "etc2-rgba8unorm-srgb", n.EACR11Unorm = "eac-r11unorm", n.EACR11Snorm = "eac-r11snorm", n.EACRG11Unorm = "eac-rg11unorm", n.EACRG11Snorm = "eac-rg11snorm", n.ASTC4x4Unorm = "astc-4x4-unorm", n.ASTC4x4UnormSRGB = "astc-4x4-unorm-srgb", n.ASTC5x4Unorm = "astc-5x4-unorm", n.ASTC5x4UnormSRGB = "astc-5x4-unorm-srgb", n.ASTC5x5Unorm = "astc-5x5-unorm", n.ASTC5x5UnormSRGB = "astc-5x5-unorm-srgb", n.ASTC6x5Unorm = "astc-6x5-unorm", n.ASTC6x5UnormSRGB = "astc-6x5-unorm-srgb", n.ASTC6x6Unorm = "astc-6x6-unorm", n.ASTC6x6UnormSRGB = "astc-6x6-unorm-srgb", n.ASTC8x5Unorm = "astc-8x5-unorm", n.ASTC8x5UnormSRGB = "astc-8x5-unorm-srgb", n.ASTC8x6Unorm = "astc-8x6-unorm", n.ASTC8x6UnormSRGB = "astc-8x6-unorm-srgb", n.ASTC8x8Unorm = "astc-8x8-unorm", n.ASTC8x8UnormSRGB = "astc-8x8-unorm-srgb", n.ASTC10x5Unorm = "astc-10x5-unorm", n.ASTC10x5UnormSRGB = "astc-10x5-unorm-srgb", n.ASTC10x6Unorm = "astc-10x6-unorm", n.ASTC10x6UnormSRGB = "astc-10x6-unorm-srgb", n.ASTC10x8Unorm = "astc-10x8-unorm", n.ASTC10x8UnormSRGB = "astc-10x8-unorm-srgb", n.ASTC10x10Unorm = "astc-10x10-unorm", n.ASTC10x10UnormSRGB = "astc-10x10-unorm-srgb", n.ASTC12x10Unorm = "astc-12x10-unorm", n.ASTC12x10UnormSRGB = "astc-12x10-unorm-srgb", n.ASTC12x12Unorm = "astc-12x12-unorm", n.ASTC12x12UnormSRGB = "astc-12x12-unorm-srgb", n.Depth32FloatStencil8 = "depth32float-stencil8";
    }(U || (U = {})), function(n) {
      n.ClampToEdge = "clamp-to-edge", n.Repeat = "repeat", n.MirrorRepeat = "mirror-repeat";
    }(As || (As = {})), function(n) {
      n.Nearest = "nearest", n.Linear = "linear";
    }(Ct || (Ct = {})), function(n) {
      n.Nearest = "nearest", n.Linear = "linear";
    }(Wf || (Wf = {})), function(n) {
      n.Never = "never", n.Less = "less", n.Equal = "equal", n.LessEqual = "less-equal", n.Greater = "greater", n.NotEqual = "not-equal", n.GreaterEqual = "greater-equal", n.Always = "always";
    }(an || (an = {})), function(n) {
      n[n.Vertex = 1] = "Vertex", n[n.Fragment = 2] = "Fragment", n[n.Compute = 4] = "Compute";
    }(_a || (_a = {})), function(n) {
      n.Uniform = "uniform", n.Storage = "storage", n.ReadOnlyStorage = "read-only-storage";
    }(ma || (ma = {})), function(n) {
      n.Filtering = "filtering", n.NonFiltering = "non-filtering", n.Comparison = "comparison";
    }(ga || (ga = {})), function(n) {
      n.Float = "float", n.UnfilterableFloat = "unfilterable-float", n.Depth = "depth", n.Sint = "sint", n.Uint = "uint";
    }(nr || (nr = {})), function(n) {
      n.WriteOnly = "write-only";
    }(Vh || (Vh = {})), function(n) {
      n.Error = "error", n.Warning = "warning", n.Info = "info";
    }(Hf || (Hf = {})), function(n) {
      n.Validation = "validation", n.Internal = "internal";
    }(Xf || (Xf = {})), function(n) {
      n.Auto = "auto";
    }(xl || (xl = {})), function(n) {
      n.PointList = "point-list", n.LineList = "line-list", n.LineStrip = "line-strip", n.TriangleList = "triangle-list", n.TriangleStrip = "triangle-strip";
    }(rr || (rr = {})), function(n) {
      n.CCW = "ccw", n.CW = "cw";
    }(Uc || (Uc = {})), function(n) {
      n.None = "none", n.Front = "front", n.Back = "back";
    }(Al || (Al = {})), function(n) {
      n[n.Red = 1] = "Red", n[n.Green = 2] = "Green", n[n.Blue = 4] = "Blue", n[n.Alpha = 8] = "Alpha", n[n.All = 15] = "All";
    }(jf || (jf = {})), function(n) {
      n.Zero = "zero", n.One = "one", n.Src = "src", n.OneMinusSrc = "one-minus-src", n.SrcAlpha = "src-alpha", n.OneMinusSrcAlpha = "one-minus-src-alpha", n.Dst = "dst", n.OneMinusDst = "one-minus-dst", n.DstAlpha = "dst-alpha", n.OneMinusDstAlpha = "one-minus-dst-alpha", n.SrcAlphaSaturated = "src-alpha-saturated", n.Constant = "constant", n.OneMinusConstant = "one-minus-constant";
    }(An || (An = {})), function(n) {
      n.Add = "add", n.Subtract = "subtract", n.ReverseSubtract = "reverse-subtract", n.Min = "min", n.Max = "max";
    }(va || (va = {})), function(n) {
      n.Keep = "keep", n.Zero = "zero", n.Replace = "replace", n.Invert = "invert", n.IncrementClamp = "increment-clamp", n.DecrementClamp = "decrement-clamp", n.IncrementWrap = "increment-wrap", n.DecrementWrap = "decrement-wrap";
    }(Vr || (Vr = {})), function(n) {
      n.Uint16 = "uint16", n.Uint32 = "uint32";
    }(ya || (ya = {})), function(n) {
      n.Uint8x2 = "uint8x2", n.Uint8x4 = "uint8x4", n.Sint8x2 = "sint8x2", n.Sint8x4 = "sint8x4", n.Unorm8x2 = "unorm8x2", n.Unorm8x4 = "unorm8x4", n.Snorm8x2 = "snorm8x2", n.Snorm8x4 = "snorm8x4", n.Uint16x2 = "uint16x2", n.Uint16x4 = "uint16x4", n.Sint16x2 = "sint16x2", n.Sint16x4 = "sint16x4", n.Unorm16x2 = "unorm16x2", n.Unorm16x4 = "unorm16x4", n.Snorm16x2 = "snorm16x2", n.Snorm16x4 = "snorm16x4", n.Float16x2 = "float16x2", n.Float16x4 = "float16x4", n.Float32 = "float32", n.Float32x2 = "float32x2", n.Float32x3 = "float32x3", n.Float32x4 = "float32x4", n.Uint32 = "uint32", n.Uint32x2 = "uint32x2", n.Uint32x3 = "uint32x3", n.Uint32x4 = "uint32x4", n.Sint32 = "sint32", n.Sint32x2 = "sint32x2", n.Sint32x3 = "sint32x3", n.Sint32x4 = "sint32x4", n.UNORM10x10x10x2 = "unorm10-10-10-2";
    }(bi || (bi = {})), function(n) {
      n.Vertex = "vertex", n.Instance = "instance";
    }(Vc || (Vc = {})), function(n) {
      n.Beginning = "beginning", n.End = "end";
    }(Yf || (Yf = {})), function(n) {
      n.Beginning = "beginning", n.End = "end";
    }(Kf || (Kf = {})), function(n) {
      n.Load = "load", n.Clear = "clear";
    }(ji || (ji = {})), function(n) {
      n.Store = "store", n.Discard = "discard";
    }(pr || (pr = {})), function(n) {
      n.Occlusion = "occlusion", n.Timestamp = "timestamp";
    }(kc || (kc = {})), function(n) {
      n.Opaque = "opaque", n.Premultiplied = "premultiplied";
    }(Gc || (Gc = {})), function(n) {
      n.Unknown = "unknown", n.Destroyed = "destroyed";
    }(qf || (qf = {})), function(n) {
      n.Validation = "validation", n.OutOfMemory = "out-of-memory", n.Internal = "internal";
    }(Qf || (Qf = {}));
    var Rn = function() {
      function n() {
        this.shaderLanguage = li.GLSL, this.vertexBufferKindToNumberOfComponents = {};
      }
      return n.prototype._addUniformToLeftOverUBO = function(t, e, i) {
        var r, o;
        t = (r = this._getArraySize(t, e, i))[0], e = r[1], o = r[2];
        for (var a = 0; a < this._webgpuProcessingContext.leftOverUniforms.length; a++)
          if (this._webgpuProcessingContext.leftOverUniforms[a].name === t)
            return;
        this._webgpuProcessingContext.leftOverUniforms.push({ name: t, type: e, length: o });
      }, n.prototype._buildLeftOverUBO = function() {
        if (!this._webgpuProcessingContext.leftOverUniforms.length)
          return "";
        var t = n.LeftOvertUBOName, e = this._webgpuProcessingContext.availableBuffers[t];
        return e || (e = { binding: this._webgpuProcessingContext.getNextFreeUBOBinding() }, this._webgpuProcessingContext.availableBuffers[t] = e, this._addBufferBindingDescription(t, e, ma.Uniform, !0), this._addBufferBindingDescription(t, e, ma.Uniform, !1)), this._generateLeftOverUBOCode(t, e);
      }, n.prototype._collectBindingNames = function() {
        for (var t = 0; t < this._webgpuProcessingContext.bindGroupLayoutEntries.length; t++) {
          var e = this._webgpuProcessingContext.bindGroupLayoutEntries[t];
          if (e !== void 0)
            for (var i = 0; i < e.length; i++) {
              var r = this._webgpuProcessingContext.bindGroupLayoutEntries[t][i], o = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[t][r.binding].name, a = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[t][r.binding].nameInArrayOfTexture;
              r && (r.texture || r.externalTexture || r.storageTexture ? this._webgpuProcessingContext.textureNames.push(a) : r.sampler ? this._webgpuProcessingContext.samplerNames.push(o) : r.buffer && this._webgpuProcessingContext.bufferNames.push(o));
            }
          else
            this._webgpuProcessingContext.bindGroupLayoutEntries[t] = [];
        }
      }, n.prototype._preCreateBindGroupEntries = function() {
        for (var t = this._webgpuProcessingContext.bindGroupEntries, e = 0; e < this._webgpuProcessingContext.bindGroupLayoutEntries.length; e++) {
          for (var i = this._webgpuProcessingContext.bindGroupLayoutEntries[e], r = [], o = 0; o < i.length; o++) {
            var a = this._webgpuProcessingContext.bindGroupLayoutEntries[e][o];
            a.sampler || a.texture || a.storageTexture || a.externalTexture ? r.push({ binding: a.binding, resource: void 0 }) : a.buffer && r.push({ binding: a.binding, resource: { buffer: void 0, offset: 0, size: 0 } });
          }
          t[e] = r;
        }
      }, n.prototype._addTextureBindingDescription = function(t, e, i, r, o, a) {
        var s, l = (s = e.textures[i]).groupIndex, c = s.bindingIndex;
        if (this._webgpuProcessingContext.bindGroupLayoutEntries[l] || (this._webgpuProcessingContext.bindGroupLayoutEntries[l] = [], this._webgpuProcessingContext.bindGroupLayoutEntryInfo[l] = []), !this._webgpuProcessingContext.bindGroupLayoutEntryInfo[l][c]) {
          var u;
          u = r === null ? this._webgpuProcessingContext.bindGroupLayoutEntries[l].push({ binding: c, visibility: 0, externalTexture: {} }) : o ? this._webgpuProcessingContext.bindGroupLayoutEntries[l].push({ binding: c, visibility: 0, storageTexture: { access: Vh.WriteOnly, format: o, viewDimension: r } }) : this._webgpuProcessingContext.bindGroupLayoutEntries[l].push({ binding: c, visibility: 0, texture: { sampleType: e.sampleType, viewDimension: r, multisampled: !1 } });
          var h = e.isTextureArray ? t + i : t;
          this._webgpuProcessingContext.bindGroupLayoutEntryInfo[l][c] = { name: t, index: u - 1, nameInArrayOfTexture: h };
        }
        c = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[l][c].index, this._webgpuProcessingContext.bindGroupLayoutEntries[l][c].visibility |= a ? _a.Vertex : _a.Fragment;
      }, n.prototype._addSamplerBindingDescription = function(t, e, i) {
        var r, o = (r = e.binding).groupIndex, a = r.bindingIndex;
        if (this._webgpuProcessingContext.bindGroupLayoutEntries[o] || (this._webgpuProcessingContext.bindGroupLayoutEntries[o] = [], this._webgpuProcessingContext.bindGroupLayoutEntryInfo[o] = []), !this._webgpuProcessingContext.bindGroupLayoutEntryInfo[o][a]) {
          var s = this._webgpuProcessingContext.bindGroupLayoutEntries[o].push({ binding: a, visibility: 0, sampler: { type: e.type } });
          this._webgpuProcessingContext.bindGroupLayoutEntryInfo[o][a] = { name: t, index: s - 1 };
        }
        a = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[o][a].index, this._webgpuProcessingContext.bindGroupLayoutEntries[o][a].visibility |= i ? _a.Vertex : _a.Fragment;
      }, n.prototype._addBufferBindingDescription = function(t, e, i, r) {
        var o, a = (o = e.binding).groupIndex, s = o.bindingIndex;
        if (this._webgpuProcessingContext.bindGroupLayoutEntries[a] || (this._webgpuProcessingContext.bindGroupLayoutEntries[a] = [], this._webgpuProcessingContext.bindGroupLayoutEntryInfo[a] = []), !this._webgpuProcessingContext.bindGroupLayoutEntryInfo[a][s]) {
          var l = this._webgpuProcessingContext.bindGroupLayoutEntries[a].push({ binding: s, visibility: 0, buffer: { type: i } });
          this._webgpuProcessingContext.bindGroupLayoutEntryInfo[a][s] = { name: t, index: l - 1 };
        }
        s = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[a][s].index, this._webgpuProcessingContext.bindGroupLayoutEntries[a][s].visibility |= r ? _a.Vertex : _a.Fragment;
      }, n.prototype._injectStartingAndEndingCode = function(t, e, i, r) {
        var o = t.indexOf(e);
        if (o < 0)
          return console.error('No "main" function found in shader code! Processing aborted.'), t;
        if (i) {
          for (; o++ < t.length && t.charAt(o) != "{"; )
            ;
          if (o < t.length) {
            var a = t.substring(0, o + 1), s = t.substring(o + 1);
            t = a + i + s;
          }
        }
        if (r) {
          var l = t.lastIndexOf("}");
          t = t.substring(0, l), t += r + `
}`;
        }
        return t;
      }, n.AutoSamplerSuffix = "Sampler", n.LeftOvertUBOName = "LeftOver", n.InternalsUBOName = "Internals", n.UniformSizes = { bool: 1, int: 1, float: 1, vec2: 2, ivec2: 2, uvec2: 2, vec3: 3, ivec3: 3, uvec3: 3, vec4: 4, ivec4: 4, uvec4: 4, mat2: 4, mat3: 12, mat4: 16, i32: 1, u32: 1, f32: 1, mat2x2: 4, mat3x3: 12, mat4x4: 16 }, n._SamplerFunctionByWebGLSamplerType = { sampler2D: "sampler2D", sampler2DArray: "sampler2DArray", sampler2DShadow: "sampler2DShadow", sampler2DArrayShadow: "sampler2DArrayShadow", samplerCube: "samplerCube", sampler3D: "sampler3D" }, n._TextureTypeByWebGLSamplerType = { sampler2D: "texture2D", sampler2DArray: "texture2DArray", sampler2DShadow: "texture2D", sampler2DArrayShadow: "texture2DArray", samplerCube: "textureCube", samplerCubeArray: "textureCubeArray", sampler3D: "texture3D" }, n._GpuTextureViewDimensionByWebGPUTextureType = { textureCube: ei.Cube, textureCubeArray: ei.CubeArray, texture2D: ei.E2d, texture2DArray: ei.E2dArray, texture3D: ei.E3d }, n._SamplerTypeByWebGLSamplerType = { sampler2DShadow: "samplerShadow", sampler2DArrayShadow: "samplerShadow" }, n._IsComparisonSamplerByWebGPUSamplerType = { samplerShadow: !0, samplerArrayShadow: !0, sampler: !1 }, n;
    }(), hD = function() {
      function n(t, e) {
        this.bindGroupLayouts = {}, this._name = "unnamed", this.shaderProcessingContext = t, this._leftOverUniformsByName = {}, this.engine = e, this.vertexBufferKindToType = {};
      }
      return Object.defineProperty(n.prototype, "isAsync", { get: function() {
        return !1;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isReady", { get: function() {
        return !!this.stages;
      }, enumerable: !1, configurable: !0 }), n.prototype._handlesSpectorRebuildCallback = function() {
      }, n.prototype._fillEffectInformation = function(t, e, i, r, o, a, s, l) {
        var c = this.engine;
        t._fragmentSourceCode = "", t._vertexSourceCode = "";
        var u, h = this.shaderProcessingContext.availableTextures;
        for (u = 0; u < o.length; u++) {
          var d = o[u], p = h[o[u]];
          p == null || p == null ? (o.splice(u, 1), u--) : a[d] = u;
        }
        for (var f = 0, m = c.getAttributes(this, s); f < m.length; f++) {
          var g = m[f];
          l.push(g);
        }
        this.buildUniformLayout();
        var y = [], b = [];
        for (u = 0; u < s.length; u++) {
          var T = l[u];
          T >= 0 && (y.push(s[u]), b.push(T));
        }
        this.shaderProcessingContext.attributeNamesFromEffect = y, this.shaderProcessingContext.attributeLocationsFromEffect = b;
      }, n.prototype.buildUniformLayout = function() {
        if (this.shaderProcessingContext.leftOverUniforms.length) {
          this.uniformBuffer = new Er(this.engine, void 0, void 0, "leftOver-" + this._name);
          for (var t = 0, e = this.shaderProcessingContext.leftOverUniforms; t < e.length; t++) {
            var i = e[t], r = i.type.replace(/^(.*?)(<.*>)?$/, "$1"), o = Rn.UniformSizes[r];
            this.uniformBuffer.addUniform(i.name, o, i.length), this._leftOverUniformsByName[i.name] = i.type;
          }
          this.uniformBuffer.create();
        }
      }, n.prototype.dispose = function() {
        this.uniformBuffer && this.uniformBuffer.dispose();
      }, n.prototype.setInt = function(t, e) {
        this.uniformBuffer && this._leftOverUniformsByName[t] && this.uniformBuffer.updateInt(t, e);
      }, n.prototype.setInt2 = function(t, e, i) {
        this.uniformBuffer && this._leftOverUniformsByName[t] && this.uniformBuffer.updateInt2(t, e, i);
      }, n.prototype.setInt3 = function(t, e, i, r) {
        this.uniformBuffer && this._leftOverUniformsByName[t] && this.uniformBuffer.updateInt3(t, e, i, r);
      }, n.prototype.setInt4 = function(t, e, i, r, o) {
        this.uniformBuffer && this._leftOverUniformsByName[t] && this.uniformBuffer.updateInt4(t, e, i, r, o);
      }, n.prototype.setIntArray = function(t, e) {
        this.uniformBuffer && this._leftOverUniformsByName[t] && this.uniformBuffer.updateIntArray(t, e);
      }, n.prototype.setIntArray2 = function(t, e) {
        this.setIntArray(t, e);
      }, n.prototype.setIntArray3 = function(t, e) {
        this.setIntArray(t, e);
      }, n.prototype.setIntArray4 = function(t, e) {
        this.setIntArray(t, e);
      }, n.prototype.setUInt = function(t, e) {
        this.uniformBuffer && this._leftOverUniformsByName[t] && this.uniformBuffer.updateUInt(t, e);
      }, n.prototype.setUInt2 = function(t, e, i) {
        this.uniformBuffer && this._leftOverUniformsByName[t] && this.uniformBuffer.updateUInt2(t, e, i);
      }, n.prototype.setUInt3 = function(t, e, i, r) {
        this.uniformBuffer && this._leftOverUniformsByName[t] && this.uniformBuffer.updateUInt3(t, e, i, r);
      }, n.prototype.setUInt4 = function(t, e, i, r, o) {
        this.uniformBuffer && this._leftOverUniformsByName[t] && this.uniformBuffer.updateUInt4(t, e, i, r, o);
      }, n.prototype.setUIntArray = function(t, e) {
        this.uniformBuffer && this._leftOverUniformsByName[t] && this.uniformBuffer.updateUIntArray(t, e);
      }, n.prototype.setUIntArray2 = function(t, e) {
        this.setUIntArray(t, e);
      }, n.prototype.setUIntArray3 = function(t, e) {
        this.setUIntArray(t, e);
      }, n.prototype.setUIntArray4 = function(t, e) {
        this.setUIntArray(t, e);
      }, n.prototype.setArray = function(t, e) {
        this.uniformBuffer && this._leftOverUniformsByName[t] && this.uniformBuffer.updateArray(t, e);
      }, n.prototype.setArray2 = function(t, e) {
        this.setArray(t, e);
      }, n.prototype.setArray3 = function(t, e) {
        this.setArray(t, e);
      }, n.prototype.setArray4 = function(t, e) {
        this.setArray(t, e);
      }, n.prototype.setMatrices = function(t, e) {
        this.uniformBuffer && this._leftOverUniformsByName[t] && this.uniformBuffer.updateMatrices(t, e);
      }, n.prototype.setMatrix = function(t, e) {
        this.uniformBuffer && this._leftOverUniformsByName[t] && this.uniformBuffer.updateMatrix(t, e);
      }, n.prototype.setMatrix3x3 = function(t, e) {
        this.uniformBuffer && this._leftOverUniformsByName[t] && this.uniformBuffer.updateMatrix3x3(t, e);
      }, n.prototype.setMatrix2x2 = function(t, e) {
        this.uniformBuffer && this._leftOverUniformsByName[t] && this.uniformBuffer.updateMatrix2x2(t, e);
      }, n.prototype.setFloat = function(t, e) {
        this.uniformBuffer && this._leftOverUniformsByName[t] && this.uniformBuffer.updateFloat(t, e);
      }, n.prototype.setVector2 = function(t, e) {
        this.setFloat2(t, e.x, e.y);
      }, n.prototype.setFloat2 = function(t, e, i) {
        this.uniformBuffer && this._leftOverUniformsByName[t] && this.uniformBuffer.updateFloat2(t, e, i);
      }, n.prototype.setVector3 = function(t, e) {
        this.setFloat3(t, e.x, e.y, e.z);
      }, n.prototype.setFloat3 = function(t, e, i, r) {
        this.uniformBuffer && this._leftOverUniformsByName[t] && this.uniformBuffer.updateFloat3(t, e, i, r);
      }, n.prototype.setVector4 = function(t, e) {
        this.setFloat4(t, e.x, e.y, e.z, e.w);
      }, n.prototype.setQuaternion = function(t, e) {
        this.setFloat4(t, e.x, e.y, e.z, e.w);
      }, n.prototype.setFloat4 = function(t, e, i, r, o) {
        this.uniformBuffer && this._leftOverUniformsByName[t] && this.uniformBuffer.updateFloat4(t, e, i, r, o);
      }, n.prototype.setColor3 = function(t, e) {
        this.setFloat3(t, e.r, e.g, e.b);
      }, n.prototype.setColor4 = function(t, e, i) {
        this.setFloat4(t, e.r, e.g, e.b, i);
      }, n.prototype.setDirectColor4 = function(t, e) {
        this.setFloat4(t, e.r, e.g, e.b, e.a);
      }, n.prototype._getVertexShaderCode = function() {
        var t;
        return (t = this.sources) === null || t === void 0 ? void 0 : t.vertex;
      }, n.prototype._getFragmentShaderCode = function() {
        var t;
        return (t = this.sources) === null || t === void 0 ? void 0 : t.fragment;
      }, n;
    }(), EC = { mat2: 2, mat3: 3, mat4: 4, mat2x2: 2, mat3x3: 3, mat4x4: 4 }, kh = function() {
      function n(t) {
        this.shaderLanguage = t, this._attributeNextLocation = 0, this._varyingNextLocation = 0, this.freeGroupIndex = 0, this.freeBindingIndex = 0, this.availableVaryings = {}, this.availableAttributes = {}, this.availableBuffers = {}, this.availableTextures = {}, this.availableSamplers = {}, this.orderedAttributes = [], this.bindGroupLayoutEntries = [], this.bindGroupLayoutEntryInfo = [], this.bindGroupEntries = [], this.bufferNames = [], this.textureNames = [], this.samplerNames = [], this.leftOverUniforms = [], this._findStartingGroupBinding();
      }
      return Object.defineProperty(n, "KnownUBOs", { get: function() {
        return n._SimplifiedKnownBindings ? n._SimplifiedKnownUBOs : n._KnownUBOs;
      }, enumerable: !1, configurable: !0 }), n.prototype._findStartingGroupBinding = function() {
        var t = n.KnownUBOs, e = [];
        for (var i in t) {
          var r = t[i].binding;
          r.groupIndex !== -1 && (e[r.groupIndex] === void 0 ? e[r.groupIndex] = r.bindingIndex : e[r.groupIndex] = Math.max(e[r.groupIndex], r.bindingIndex));
        }
        this.freeGroupIndex = e.length - 1, this.freeGroupIndex === 0 ? (this.freeGroupIndex++, this.freeBindingIndex = 0) : this.freeBindingIndex = e[e.length - 1] + 1;
      }, n.prototype.getAttributeNextLocation = function(t, e) {
        var i;
        e === void 0 && (e = 0);
        var r = this._attributeNextLocation;
        return this._attributeNextLocation += ((i = EC[t]) !== null && i !== void 0 ? i : 1) * (e || 1), r;
      }, n.prototype.getVaryingNextLocation = function(t, e) {
        var i;
        e === void 0 && (e = 0);
        var r = this._varyingNextLocation;
        return this._varyingNextLocation += ((i = EC[t]) !== null && i !== void 0 ? i : 1) * (e || 1), r;
      }, n.prototype.getNextFreeUBOBinding = function() {
        return this._getNextFreeBinding(1);
      }, n.prototype._getNextFreeBinding = function(t) {
        if (this.freeBindingIndex > 65536 - t && (this.freeGroupIndex++, this.freeBindingIndex = 0), this.freeGroupIndex === 4)
          throw "Too many textures or UBOs have been declared and it is not supported in WebGPU.";
        var e = { groupIndex: this.freeGroupIndex, bindingIndex: this.freeBindingIndex };
        return this.freeBindingIndex += t, e;
      }, n._SimplifiedKnownBindings = !0, n._SimplifiedKnownUBOs = { Scene: { binding: { groupIndex: 0, bindingIndex: 0 } }, Light0: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light1: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light2: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light3: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light4: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light5: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light6: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light7: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light8: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light9: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light10: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light11: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light12: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light13: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light14: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light15: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light16: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light17: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light18: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light19: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light20: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light21: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light22: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light23: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light24: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light25: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light26: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light27: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light28: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light29: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light30: { binding: { groupIndex: -1, bindingIndex: -1 } }, Light31: { binding: { groupIndex: -1, bindingIndex: -1 } }, Material: { binding: { groupIndex: -1, bindingIndex: -1 } }, Mesh: { binding: { groupIndex: -1, bindingIndex: -1 } }, Internals: { binding: { groupIndex: -1, bindingIndex: -1 } } }, n._KnownUBOs = { Scene: { binding: { groupIndex: 0, bindingIndex: 0 } }, Light0: { binding: { groupIndex: 1, bindingIndex: 0 } }, Light1: { binding: { groupIndex: 1, bindingIndex: 1 } }, Light2: { binding: { groupIndex: 1, bindingIndex: 2 } }, Light3: { binding: { groupIndex: 1, bindingIndex: 3 } }, Light4: { binding: { groupIndex: 1, bindingIndex: 4 } }, Light5: { binding: { groupIndex: 1, bindingIndex: 5 } }, Light6: { binding: { groupIndex: 1, bindingIndex: 6 } }, Light7: { binding: { groupIndex: 1, bindingIndex: 7 } }, Light8: { binding: { groupIndex: 1, bindingIndex: 8 } }, Light9: { binding: { groupIndex: 1, bindingIndex: 9 } }, Light10: { binding: { groupIndex: 1, bindingIndex: 10 } }, Light11: { binding: { groupIndex: 1, bindingIndex: 11 } }, Light12: { binding: { groupIndex: 1, bindingIndex: 12 } }, Light13: { binding: { groupIndex: 1, bindingIndex: 13 } }, Light14: { binding: { groupIndex: 1, bindingIndex: 14 } }, Light15: { binding: { groupIndex: 1, bindingIndex: 15 } }, Light16: { binding: { groupIndex: 1, bindingIndex: 16 } }, Light17: { binding: { groupIndex: 1, bindingIndex: 17 } }, Light18: { binding: { groupIndex: 1, bindingIndex: 18 } }, Light19: { binding: { groupIndex: 1, bindingIndex: 19 } }, Light20: { binding: { groupIndex: 1, bindingIndex: 20 } }, Light21: { binding: { groupIndex: 1, bindingIndex: 21 } }, Light22: { binding: { groupIndex: 1, bindingIndex: 22 } }, Light23: { binding: { groupIndex: 1, bindingIndex: 23 } }, Light24: { binding: { groupIndex: 1, bindingIndex: 24 } }, Light25: { binding: { groupIndex: 1, bindingIndex: 25 } }, Light26: { binding: { groupIndex: 1, bindingIndex: 26 } }, Light27: { binding: { groupIndex: 1, bindingIndex: 27 } }, Light28: { binding: { groupIndex: 1, bindingIndex: 28 } }, Light29: { binding: { groupIndex: 1, bindingIndex: 29 } }, Light30: { binding: { groupIndex: 1, bindingIndex: 30 } }, Light31: { binding: { groupIndex: 1, bindingIndex: 31 } }, Material: { binding: { groupIndex: 2, bindingIndex: 0 } }, Mesh: { binding: { groupIndex: 2, bindingIndex: 1 } }, Internals: { binding: { groupIndex: 2, bindingIndex: 2 } } }, n;
    }(), dD = function(n) {
      function t() {
        var e = n !== null && n.apply(this, arguments) || this;
        return e._missingVaryings = [], e._textureArrayProcessing = [], e._vertexIsGLES3 = !1, e._fragmentIsGLES3 = !1, e.shaderLanguage = li.GLSL, e.parseGLES3 = !0, e;
      }
      return D(t, n), t.prototype._getArraySize = function(e, i, r) {
        var o = 0, a = e.indexOf("["), s = e.indexOf("]");
        if (a > 0 && s > 0) {
          var l = e.substring(a + 1, s);
          o = +l, isNaN(o) && (o = +r[l.trim()]), e = e.substr(0, a);
        }
        return [e, i, o];
      }, t.prototype.initializeShaders = function(e) {
        this._webgpuProcessingContext = e, this._missingVaryings.length = 0, this._textureArrayProcessing.length = 0, this.attributeKeywordName = void 0, this.varyingVertexKeywordName = void 0, this.varyingFragmentKeywordName = void 0;
      }, t.prototype.preProcessShaderCode = function(e, i) {
        var r = `// Internals UBO
uniform `.concat(Rn.InternalsUBOName, ` {
float yFactor_;
float textureOutputHeight_;
};
`), o = e.indexOf("// Internals UBO") !== -1;
        return i ? (this._fragmentIsGLES3 = e.indexOf("#version 3") !== -1, this._fragmentIsGLES3 && (this.varyingFragmentKeywordName = "in"), o ? e : r + `##INJECTCODE##
` + e) : (this._vertexIsGLES3 = e.indexOf("#version 3") !== -1, this._vertexIsGLES3 && (this.attributeKeywordName = "in", this.varyingVertexKeywordName = "out"), o ? e : r + e);
      }, t.prototype.varyingCheck = function(e, i) {
        return (i && this._fragmentIsGLES3 ? /(flat\s)?\s*\bin\b/ : !i && this._vertexIsGLES3 ? /(flat\s)?\s*\bout\b/ : /(flat\s)?\s*\bvarying\b/).test(e);
      }, t.prototype.varyingProcessor = function(e, i, r) {
        var o;
        this._preProcessors = r;
        var a = (i && this._fragmentIsGLES3 ? /\s*(flat)?\s*in\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm : !i && this._vertexIsGLES3 ? /\s*(flat)?\s*out\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm : /\s*(flat)?\s*varying\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm).exec(e);
        if (a !== null) {
          var s, l = (o = a[1]) !== null && o !== void 0 ? o : "", c = a[2], u = a[3];
          i ? (s = this._webgpuProcessingContext.availableVaryings[u], this._missingVaryings[s] = "", s === void 0 && q.Warn('Invalid fragment shader: The varying named "'.concat(u, '" is not declared in the vertex shader! This declaration will be ignored.'))) : (s = this._webgpuProcessingContext.getVaryingNextLocation(c, this._getArraySize(u, c, r)[2]), this._webgpuProcessingContext.availableVaryings[u] = s, this._missingVaryings[s] = "layout(location = ".concat(s, ") ").concat(l, " in ").concat(c, " ").concat(u, ";")), e = e.replace(a[0], s === void 0 ? "" : "layout(location = ".concat(s, ") ").concat(l, " ").concat(i ? "in" : "out", " ").concat(c, " ").concat(u, ";"));
        }
        return e;
      }, t.prototype.attributeProcessor = function(e, i) {
        this._preProcessors = i;
        var r = (this._vertexIsGLES3 ? /\s*in\s+(\S+)\s+(\S+)\s*;/gm : /\s*attribute\s+(\S+)\s+(\S+)\s*;/gm).exec(e);
        if (r !== null) {
          var o = r[1], a = r[2], s = this._webgpuProcessingContext.getAttributeNextLocation(o, this._getArraySize(a, o, i)[2]);
          this._webgpuProcessingContext.availableAttributes[a] = s, this._webgpuProcessingContext.orderedAttributes[s] = a;
          var l = this.vertexBufferKindToNumberOfComponents[a];
          if (l !== void 0) {
            var c = l < 0 ? l === -1 ? "int" : "ivec" + -l : l === 1 ? "uint" : "uvec" + l, u = "_int_".concat(a, "_");
            e = e.replace(r[0], "layout(location = ".concat(s, ") in ").concat(c, " ").concat(u, "; ").concat(o, " ").concat(a, " = ").concat(o, "(").concat(u, ");"));
          } else
            e = e.replace(r[0], "layout(location = ".concat(s, ") in ").concat(o, " ").concat(a, ";"));
        }
        return e;
      }, t.prototype.uniformProcessor = function(e, i, r) {
        var o, a;
        this._preProcessors = r;
        var s = /\s*uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm.exec(e);
        if (s !== null) {
          var l = s[1], c = s[2];
          if (l.indexOf("sampler") === 0 || l.indexOf("sampler") === 1) {
            var u = 0;
            c = (o = this._getArraySize(c, l, r))[0], l = o[1], u = o[2];
            var h = this._webgpuProcessingContext.availableTextures[c];
            if (!h) {
              h = { autoBindSampler: !0, isTextureArray: u > 0, isStorageTexture: !1, textures: [], sampleType: nr.Float };
              for (var d = 0; d < (u || 1); ++d)
                h.textures.push(this._webgpuProcessingContext.getNextFreeUBOBinding());
            }
            var p = (a = Rn._SamplerTypeByWebGLSamplerType[l]) !== null && a !== void 0 ? a : "sampler", f = !!Rn._IsComparisonSamplerByWebGPUSamplerType[p], m = f ? ga.Comparison : ga.Filtering, g = c + Rn.AutoSamplerSuffix, y = this._webgpuProcessingContext.availableSamplers[g];
            y || (y = { binding: this._webgpuProcessingContext.getNextFreeUBOBinding(), type: m });
            var b = l.charAt(0) === "u" ? "u" : l.charAt(0) === "i" ? "i" : "";
            b && (l = l.substr(1));
            var T = f ? nr.Depth : b === "u" ? nr.Uint : b === "i" ? nr.Sint : nr.Float;
            h.sampleType = T;
            var S = u > 0, E = y.binding.groupIndex, A = y.binding.bindingIndex, R = Rn._SamplerFunctionByWebGLSamplerType[l], C = Rn._TextureTypeByWebGLSamplerType[l], L = Rn._GpuTextureViewDimensionByWebGPUTextureType[C];
            if (S) {
              var I = [];
              for (I.push("layout(set = ".concat(E, ", binding = ").concat(A, ") uniform ").concat(b).concat(p, " ").concat(g, ";")), e = `
`, d = 0; d < u; ++d) {
                var O = h.textures[d].groupIndex, w = h.textures[d].bindingIndex;
                I.push("layout(set = ".concat(O, ", binding = ").concat(w, ") uniform ").concat(C, " ").concat(c, "Texture").concat(d, ";")), e += "".concat(d > 0 ? `
` : "", "#define ").concat(c).concat(d, " ").concat(b).concat(R, "(").concat(c, "Texture").concat(d, ", ").concat(g, ")");
              }
              e = I.join(`
`) + e, this._textureArrayProcessing.push(c);
            } else
              u = 1, e = "layout(set = ".concat(E, ", binding = ").concat(A, ") uniform ").concat(p, " ").concat(g, `;
                        layout(set = `).concat(h.textures[0].groupIndex, ", binding = ").concat(h.textures[0].bindingIndex, ") uniform ").concat(b).concat(C, " ").concat(c, `Texture;
                        #define `).concat(c, " ").concat(b).concat(R, "(").concat(c, "Texture, ").concat(g, ")");
            for (this._webgpuProcessingContext.availableTextures[c] = h, this._webgpuProcessingContext.availableSamplers[g] = y, this._addSamplerBindingDescription(g, y, !i), d = 0; d < u; ++d)
              this._addTextureBindingDescription(c, h, d, L, null, !i);
          } else
            this._addUniformToLeftOverUBO(c, l, r), e = "";
        }
        return e;
      }, t.prototype.uniformBufferProcessor = function(e, i) {
        var r = /uniform\s+(\w+)/gm.exec(e);
        if (r !== null) {
          var o = r[1], a = this._webgpuProcessingContext.availableBuffers[o];
          if (!a) {
            var s = kh.KnownUBOs[o];
            a = { binding: s && s.binding.groupIndex !== -1 ? s.binding : this._webgpuProcessingContext.getNextFreeUBOBinding() }, this._webgpuProcessingContext.availableBuffers[o] = a;
          }
          this._addBufferBindingDescription(o, a, ma.Uniform, !i), e = e.replace("uniform", "layout(set = ".concat(a.binding.groupIndex, ", binding = ").concat(a.binding.bindingIndex, ") uniform"));
        }
        return e;
      }, t.prototype.postProcessor = function(e, i, r, o, a) {
        var s = e.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1;
        if (e = (e = e.replace(/#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g, "")).replace(/texture2D\s*\(/g, "texture("), r) {
          var l = e.indexOf("gl_FragCoord") >= 0, c = l ? `vec4 glFragCoord_;
` : "", u = e.search(/layout *\(location *= *0\) *out/g) !== -1;
          if (e = (e = (e = (e = (e = (e = (e = e.replace(/texture2DLodEXT\s*\(/g, "textureLod(")).replace(/textureCubeLodEXT\s*\(/g, "textureLod(")).replace(/textureCube\s*\(/g, "texture(")).replace(/gl_FragDepthEXT/g, "gl_FragDepth")).replace(/gl_FragColor/g, "glFragColor")).replace(/gl_FragData/g, "glFragData")).replace(/gl_FragCoord/g, "glFragCoord_"), this._fragmentIsGLES3) {
            var h = /^\s*out\s+\S+\s+\S+\s*;/gm.exec(e);
            h !== null && (e = e.substring(0, h.index) + "layout(location = 0) " + e.substring(h.index));
          } else
            e = e.replace(/void\s+?main\s*\(/g, (s || u ? "" : `layout(location = 0) out vec4 glFragColor;
`) + "void main(");
          e = (e = e.replace(/dFdy/g, "(-yFactor_)*dFdy")).replace("##INJECTCODE##", c), l && (e = this._injectStartingAndEndingCode(e, "void main", `
                glFragCoord_ = gl_FragCoord;
                if (yFactor_ == 1.) {
                    glFragCoord_.y = textureOutputHeight_ - glFragCoord_.y;
                }
            `));
        } else if (e = (e = e.replace(/gl_InstanceID/g, "gl_InstanceIndex")).replace(/gl_VertexID/g, "gl_VertexIndex"), i.indexOf("#define MULTIVIEW") !== -1)
          return `#extension GL_OVR_multiview2 : require
layout (num_views = 2) in;
` + e;
        if (!r) {
          var d = e.lastIndexOf("}");
          e = e.substring(0, d), e += `gl_Position.y *= yFactor_;
`, a.isNDCHalfZRange || (e += `gl_Position.z = (gl_Position.z + gl_Position.w) / 2.0;
`), e += "}";
        }
        return e;
      }, t.prototype._applyTextureArrayProcessing = function(e, i) {
        for (var r = new RegExp(i + "\\s*\\[(.+)?\\]", "gm"), o = r.exec(e); o !== null; ) {
          var a = o[1], s = +a;
          this._preProcessors && isNaN(s) && (s = +this._preProcessors[a.trim()]), e = e.replace(o[0], i + s), o = r.exec(e);
        }
        return e;
      }, t.prototype._generateLeftOverUBOCode = function(e, i) {
        for (var r = "layout(set = ".concat(i.binding.groupIndex, ", binding = ").concat(i.binding.bindingIndex, ") uniform ").concat(e, ` {
    `), o = 0, a = this._webgpuProcessingContext.leftOverUniforms; o < a.length; o++) {
          var s = a[o];
          s.length > 0 ? r += "    ".concat(s.type, " ").concat(s.name, "[").concat(s.length, `];
`) : r += "    ".concat(s.type, " ").concat(s.name, `;
`);
        }
        return r + `};

`;
      }, t.prototype.finalizeShaders = function(e, i) {
        for (var r = 0; r < this._textureArrayProcessing.length; ++r) {
          var o = this._textureArrayProcessing[r];
          e = this._applyTextureArrayProcessing(e, o), i = this._applyTextureArrayProcessing(i, o);
        }
        for (r = 0; r < this._missingVaryings.length; ++r) {
          var a = this._missingVaryings[r];
          a && a.length > 0 && (i = a + `
` + i);
        }
        var s = this._buildLeftOverUBO();
        return e = s + e, i = s + i, this._collectBindingNames(), this._preCreateBindGroupEntries(), this._preProcessors = null, this.vertexBufferKindToNumberOfComponents = {}, { vertexCode: e, fragmentCode: i };
      }, t;
    }(Rn);
    re.IncludesShadersStoreWGSL.bonesDeclaration = `#if NUM_BONE_INFLUENCERS>0
attribute matricesIndices : vec4<f32>;attribute matricesWeights : vec4<f32>;
#if NUM_BONE_INFLUENCERS>4
attribute matricesIndicesExtra : vec4<f32>;attribute matricesWeightsExtra : vec4<f32>;
#endif
#ifndef BAKED_VERTEX_ANIMATION_TEXTURE
#ifdef BONETEXTURE
var boneSampler : texture_2d<f32>;uniform boneTextureWidth : f32;
#else
uniform mBones : array<mat4x4,BonesPerMesh>;
#ifdef BONES_VELOCITY_ENABLED
uniform mPreviousBones : array<mat4x4,BonesPerMesh>;
#endif
#endif
#ifdef BONETEXTURE
fn readMatrixFromRawSampler(smp : texture_2d<f32>,index : f32)->mat4x4<f32>
{let offset=i32(index) *4; 
let m0=textureLoad(smp,vec2<i32>(offset+0,0),0);let m1=textureLoad(smp,vec2<i32>(offset+1,0),0);let m2=textureLoad(smp,vec2<i32>(offset+2,0),0);let m3=textureLoad(smp,vec2<i32>(offset+3,0),0);return mat4x4<f32>(m0,m1,m2,m3);}
#endif
#endif
#endif
`, re.IncludesShadersStoreWGSL.bonesVertex = `#ifndef BAKED_VERTEX_ANIMATION_TEXTURE
#if NUM_BONE_INFLUENCERS>0
var influence : mat4x4<f32>;
#ifdef BONETEXTURE
influence=readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndices[0])*vertexInputs.matricesWeights[0];
#if NUM_BONE_INFLUENCERS>1
influence=influence+readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndices[1])*vertexInputs.matricesWeights[1];
#endif 
#if NUM_BONE_INFLUENCERS>2
influence=influence+readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndices[2])*vertexInputs.matricesWeights[2];
#endif 
#if NUM_BONE_INFLUENCERS>3
influence=influence+readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndices[3])*vertexInputs.matricesWeights[3];
#endif 
#if NUM_BONE_INFLUENCERS>4
influence=influence+readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndicesExtra[0])*vertexInputs.matricesWeightsExtra[0];
#endif 
#if NUM_BONE_INFLUENCERS>5
influence=influence+readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndicesExtra[1])*vertexInputs.matricesWeightsExtra[1];
#endif 
#if NUM_BONE_INFLUENCERS>6
influence=influence+readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndicesExtra[2])*vertexInputs.matricesWeightsExtra[2];
#endif 
#if NUM_BONE_INFLUENCERS>7
influence=influence+readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndicesExtra[3])*vertexInputs.matricesWeightsExtra[3];
#endif 
#else 
influence=uniforms.mBones[int(vertexInputs.matricesIndices[0])]*vertexInputs.matricesWeights[0];
#if NUM_BONE_INFLUENCERS>1
influence=influence+uniforms.mBones[int(vertexInputs.matricesIndices[1])]*vertexInputs.matricesWeights[1];
#endif 
#if NUM_BONE_INFLUENCERS>2
influence=influence+uniforms.mBones[int(vertexInputs.matricesIndices[2])]*vertexInputs.matricesWeights[2];
#endif 
#if NUM_BONE_INFLUENCERS>3
influence=influence+uniforms.mBones[int(vertexInputs.matricesIndices[3])]*vertexInputs.matricesWeights[3];
#endif 
#if NUM_BONE_INFLUENCERS>4
influence=influence+uniforms.mBones[int(vertexInputs.matricesIndicesExtra[0])]*vertexInputs.matricesWeightsExtra[0];
#endif 
#if NUM_BONE_INFLUENCERS>5
influence=influence+uniforms.mBones[int(vertexInputs.matricesIndicesExtra[1])]*vertexInputs.matricesWeightsExtra[1];
#endif 
#if NUM_BONE_INFLUENCERS>6
influence=influence+uniforms.mBones[int(vertexInputs.matricesIndicesExtra[2])]*vertexInputs.matricesWeightsExtra[2];
#endif 
#if NUM_BONE_INFLUENCERS>7
influence=influence+uniforms.mBones[int(vertexInputs.matricesIndicesExtra[3])]*vertexInputs.matricesWeightsExtra[3];
#endif 
#endif
finalWorld=finalWorld*influence;
#endif
#endif
`, re.IncludesShadersStoreWGSL.bakedVertexAnimationDeclaration = `#ifdef BAKED_VERTEX_ANIMATION_TEXTURE
uniform bakedVertexAnimationTime: f32;uniform bakedVertexAnimationTextureSizeInverted: vec2<f32>;uniform bakedVertexAnimationSettings: vec4<f32>;var bakedVertexAnimationTexture : texture_2d<f32>;
#ifdef INSTANCES
attribute bakedVertexAnimationSettingsInstanced : vec4<f32>;
#endif
fn readMatrixFromRawSamplerVAT(smp : texture_2d<f32>,index : f32,frame : f32)->mat4x4<f32>
{let offset=i32(index)*4;let frameUV=i32(frame);let m0=textureLoad(smp,vec2<i32>(offset+0,frameUV),0);let m1=textureLoad(smp,vec2<i32>(offset+1,frameUV),0);let m2=textureLoad(smp,vec2<i32>(offset+2,frameUV),0);let m3=textureLoad(smp,vec2<i32>(offset+3,frameUV),0);return mat4x4<f32>(m0,m1,m2,m3);}
#endif
`, re.IncludesShadersStoreWGSL.bakedVertexAnimation = `#ifdef BAKED_VERTEX_ANIMATION_TEXTURE
{
#ifdef INSTANCES
let VATStartFrame: f32=vertexInputs.bakedVertexAnimationSettingsInstanced.x;let VATEndFrame: f32=vertexInputs.bakedVertexAnimationSettingsInstanced.y;let VATOffsetFrame: f32=vertexInputs.bakedVertexAnimationSettingsInstanced.z;let VATSpeed: f32=vertexInputs.bakedVertexAnimationSettingsInstanced.w;
#else
let VATStartFrame: f32=uniforms.bakedVertexAnimationSettings.x;let VATEndFrame: f32=uniforms.bakedVertexAnimationSettings.y;let VATOffsetFrame: f32=uniforms.bakedVertexAnimationSettings.z;let VATSpeed: f32=uniforms.bakedVertexAnimationSettings.w;
#endif
let totalFrames: f32=VATEndFrame-VATStartFrame+1.0;let time: f32=uniforms.bakedVertexAnimationTime*VATSpeed/totalFrames;let frameCorrection: f32=select(1.0,0.0,time<1.0);let numOfFrames: f32=totalFrames-frameCorrection;var VATFrameNum: f32=fract(time)*numOfFrames;VATFrameNum=(VATFrameNum+VATOffsetFrame) % numOfFrames;VATFrameNum=floor(VATFrameNum);VATFrameNum=VATFrameNum+VATStartFrame+frameCorrection;var VATInfluence : mat4x4<f32>;VATInfluence=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndices[0],VATFrameNum)*vertexInputs.matricesWeights[0];
#if NUM_BONE_INFLUENCERS>1
VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndices[1],VATFrameNum)*vertexInputs.matricesWeights[1];
#endif
#if NUM_BONE_INFLUENCERS>2
VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndices[2],VATFrameNum)*vertexInputs.matricesWeights[2];
#endif
#if NUM_BONE_INFLUENCERS>3
VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndices[3],VATFrameNum)*vertexInputs.matricesWeights[3];
#endif
#if NUM_BONE_INFLUENCERS>4
VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndicesExtra[0],VATFrameNum)*vertexInputs.matricesWeightsExtra[0];
#endif
#if NUM_BONE_INFLUENCERS>5
VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndicesExtra[1],VATFrameNum)*vertexInputs.matricesWeightsExtra[1];
#endif
#if NUM_BONE_INFLUENCERS>6
VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndicesExtra[2],VATFrameNum)*vertexInputs.matricesWeightsExtra[2];
#endif
#if NUM_BONE_INFLUENCERS>7
VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndicesExtra[3],VATFrameNum)*vertexInputs.matricesWeightsExtra[3];
#endif
finalWorld=finalWorld*VATInfluence;}
#endif
`, re.IncludesShadersStoreWGSL.clipPlaneFragment = `#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
if (false) {}
#endif
#ifdef CLIPPLANE
else if (fragmentInputs.fClipDistance>0.0)
{discard;}
#endif
#ifdef CLIPPLANE2
else if (fragmentInputs.fClipDistance2>0.0)
{discard;}
#endif
#ifdef CLIPPLANE3
else if (fragmentInputs.fClipDistance3>0.0)
{discard;}
#endif
#ifdef CLIPPLANE4
else if (fragmentInputs.fClipDistance4>0.0)
{discard;}
#endif
#ifdef CLIPPLANE5
else if (fragmentInputs.fClipDistance5>0.0)
{discard;}
#endif
#ifdef CLIPPLANE6
else if (fragmentInputs.fClipDistance6>0.0)
{discard;}
#endif
`, re.IncludesShadersStoreWGSL.clipPlaneFragmentDeclaration = `#ifdef CLIPPLANE
varying fClipDistance: f32;
#endif
#ifdef CLIPPLANE2
varying fClipDistance2: f32;
#endif
#ifdef CLIPPLANE3
varying fClipDistance3: f32;
#endif
#ifdef CLIPPLANE4
varying fClipDistance4: f32;
#endif
#ifdef CLIPPLANE5
varying fClipDistance5: f32;
#endif
#ifdef CLIPPLANE6
varying fClipDistance6: f32;
#endif
`, re.IncludesShadersStoreWGSL.clipPlaneVertex = `#ifdef CLIPPLANE
vertexOutputs.fClipDistance=dot(worldPos,uniforms.vClipPlane);
#endif
#ifdef CLIPPLANE2
vertexOutputs.fClipDistance2=dot(worldPos,uniforms.vClipPlane2);
#endif
#ifdef CLIPPLANE3
vertexOutputs.fClipDistance3=dot(worldPos,uniforms.vClipPlane3);
#endif
#ifdef CLIPPLANE4
vertexOutputs.fClipDistance4=dot(worldPos,uniforms.vClipPlane4);
#endif
#ifdef CLIPPLANE5
vertexOutputs.fClipDistance5=dot(worldPos,uniforms.vClipPlane5);
#endif
#ifdef CLIPPLANE6
vertexOutputs.fClipDistance6=dot(worldPos,uniforms.vClipPlane6);
#endif
`, re.IncludesShadersStoreWGSL.clipPlaneVertexDeclaration = `#ifdef CLIPPLANE
uniform vClipPlane: vec4<f32>;varying fClipDistance: f32;
#endif
#ifdef CLIPPLANE2
uniform vClipPlane2: vec4<f32>;varying fClipDistance2: f32;
#endif
#ifdef CLIPPLANE3
uniform vClipPlane3: vec4<f32>;varying fClipDistance3: f32;
#endif
#ifdef CLIPPLANE4
uniform vClipPlane4: vec4<f32>;varying fClipDistance4: f32;
#endif
#ifdef CLIPPLANE5
uniform vClipPlane5: vec4<f32>;varying fClipDistance5: f32;
#endif
#ifdef CLIPPLANE6
uniform vClipPlane6: vec4<f32>;varying fClipDistance6: f32;
#endif
`, re.IncludesShadersStoreWGSL.instancesDeclaration = `#ifdef INSTANCES
attribute world0 : vec4<f32>;attribute world1 : vec4<f32>;attribute world2 : vec4<f32>;attribute world3 : vec4<f32>;
#ifdef INSTANCESCOLOR
attribute instanceColor : vec4<f32>;
#endif
#if defined(THIN_INSTANCES) && !defined(WORLD_UBO)
uniform world : mat4x4<f32>;
#endif
#if defined(VELOCITY) || defined(PREPASS_VELOCITY)
attribute previousWorld0 : vec4<f32>;attribute previousWorld1 : vec4<f32>;attribute previousWorld2 : vec4<f32>;attribute previousWorld3 : vec4<f32>;
#ifdef THIN_INSTANCES
uniform previousWorld : mat4x4<f32>;
#endif
#endif
#else
#if !defined(WORLD_UBO)
uniform world : mat4x4<f32>;
#endif
#if defined(VELOCITY) || defined(PREPASS_VELOCITY)
uniform previousWorld : mat4x4<f32>;
#endif
#endif
`, re.IncludesShadersStoreWGSL.instancesVertex = `#ifdef INSTANCES
var finalWorld=mat4x4<f32>(vertexInputs.world0,vertexInputs.world1,vertexInputs.world2,vertexInputs.world3);
#if defined(PREPASS_VELOCITY) || defined(VELOCITY)
var finalPreviousWorld=mat4x4<f32>(previousWorld0,previousWorld1,previousWorld2,previousWorld3);
#endif
#ifdef THIN_INSTANCES
#if !defined(WORLD_UBO)
finalWorld=uniforms.world*finalWorld;
#else
finalWorld=mesh.world*finalWorld;
#endif
#if defined(PREPASS_VELOCITY) || defined(VELOCITY)
finalPreviousWorld=previousWorld*finalPreviousWorld;
#endif
#endif
#else
#if !defined(WORLD_UBO)
var finalWorld=uniforms.world;
#else
var finalWorld=mesh.world;
#endif
#if defined(PREPASS_VELOCITY) || defined(VELOCITY)
var finalPreviousWorld=previousWorld;
#endif
#endif
`, re.IncludesShadersStoreWGSL.meshUboDeclaration = `struct Mesh {world : mat4x4<f32>,
visibility : f32,};var<uniform> mesh : Mesh;
#define WORLD_UBO
`, re.IncludesShadersStoreWGSL.morphTargetsVertex = `#ifdef MORPHTARGETS
#ifdef MORPHTARGETS_TEXTURE 
vertexID=f32(vertexInputs.vertexIndex)*uniforms.morphTargetTextureInfo.x;positionUpdated=positionUpdated+(readVector3FromRawSampler({X},vertexID)-vertexInputs.position)*uniforms.morphTargetInfluences[{X}];vertexID=vertexID+1.0;
#ifdef MORPHTARGETS_NORMAL
normalUpdated=normalUpdated+(readVector3FromRawSampler({X},vertexID) -vertexInputs.normal)*uniforms.morphTargetInfluences[{X}];vertexID=vertexID+1.0;
#endif
#ifdef MORPHTARGETS_UV
uvUpdated=uvUpdated+(readVector3FromRawSampler({X},vertexID).xy-vertexInputs.uv)*uniforms.morphTargetInfluences[{X}];vertexID=vertexID+1.0;
#endif
#ifdef MORPHTARGETS_TANGENT
tangentUpdated.xyz=tangentUpdated.xyz+(readVector3FromRawSampler({X},vertexID) -vertexInputs.tangent.xyz)*uniforms.morphTargetInfluences[{X}];
#endif
#else
positionUpdated=positionUpdated+(position{X}-vertexInputs.position)*uniforms.morphTargetInfluences[{X}];
#ifdef MORPHTARGETS_NORMAL
normalUpdated+=(normal{X}-vertexInputs.normal)*uniforms.morphTargetInfluences[{X}];
#endif
#ifdef MORPHTARGETS_TANGENT
tangentUpdated.xyz=tangentUpdated.xyz+(tangent{X}-vertexInputs.tangent.xyz)*uniforms.morphTargetInfluences[{X}];
#endif
#ifdef MORPHTARGETS_UV
uvUpdated=uvUpdated+(uv_{X}-vertexInputs.uv)*uniforms.morphTargetInfluences[{X}];
#endif
#endif
#endif
`, re.IncludesShadersStoreWGSL.morphTargetsVertexDeclaration = `#ifdef MORPHTARGETS
#ifndef MORPHTARGETS_TEXTURE
attribute position{X} : vec3<f32>;
#ifdef MORPHTARGETS_NORMAL
attribute normal{X} : vec3<f32>;
#endif
#ifdef MORPHTARGETS_TANGENT
attribute tangent{X} : vec3<f32>;
#endif
#ifdef MORPHTARGETS_UV
attribute uv_{X} : vec2<f32>;
#endif
#endif
#endif
`, re.IncludesShadersStoreWGSL.morphTargetsVertexGlobal = `#ifdef MORPHTARGETS
#ifdef MORPHTARGETS_TEXTURE
var vertexID : f32;
#endif
#endif
`, re.IncludesShadersStoreWGSL.morphTargetsVertexGlobalDeclaration = `#ifdef MORPHTARGETS
uniform morphTargetInfluences : array<f32,NUM_MORPH_INFLUENCERS>;
#ifdef MORPHTARGETS_TEXTURE 
uniform morphTargetTextureIndices : array<f32,NUM_MORPH_INFLUENCERS>;uniform morphTargetTextureInfo : vec3<f32>;var morphTargets : texture_2d_array<f32>;var morphTargetsSampler : sampler;fn readVector3FromRawSampler(targetIndex : i32,vertexIndex : f32)->vec3<f32>
{ 
let y=floor(vertexIndex/uniforms.morphTargetTextureInfo.y);let x=vertexIndex-y*uniforms.morphTargetTextureInfo.y;let textureUV=vec2<f32>((x+0.5)/uniforms.morphTargetTextureInfo.y,(y+0.5)/uniforms.morphTargetTextureInfo.z);return textureSampleLevel(morphTargets,morphTargetsSampler,textureUV,i32(uniforms.morphTargetTextureIndices[targetIndex]),0.0).xyz;}
#endif
#endif
`, re.IncludesShadersStoreWGSL.sceneUboDeclaration = `struct Scene {viewProjection : mat4x4<f32>,
#ifdef MULTIVIEW
viewProjectionR : mat4x4<f32>,
#endif 
view : mat4x4<f32>,
projection : mat4x4<f32>,
vEyePosition : vec4<f32>,};var<uniform> scene : Scene;
`;
    var ro, zc, pD = { texture_1d: ei.E1d, texture_2d: ei.E2d, texture_2d_array: ei.E2dArray, texture_3d: ei.E3d, texture_cube: ei.Cube, texture_cube_array: ei.CubeArray, texture_multisampled_2d: ei.E2d, texture_depth_2d: ei.E2d, texture_depth_2d_array: ei.E2dArray, texture_depth_cube: ei.Cube, texture_depth_cube_array: ei.CubeArray, texture_depth_multisampled_2d: ei.E2d, texture_storage_1d: ei.E1d, texture_storage_2d: ei.E2d, texture_storage_2d_array: ei.E2dArray, texture_storage_3d: ei.E3d, texture_external: null }, fD = function(n) {
      function t() {
        var e = n !== null && n.apply(this, arguments) || this;
        return e.shaderLanguage = li.WGSL, e.uniformRegexp = /uniform\s+(\w+)\s*:\s*(.+)\s*;/, e.textureRegexp = /var\s+(\w+)\s*:\s*((array<\s*)?(texture_\w+)\s*(<\s*(.+)\s*>)?\s*(,\s*\w+\s*>\s*)?);/, e.noPrecision = !0, e;
      }
      return D(t, n), t.prototype._getArraySize = function(e, i, r) {
        var o = 0, a = i.lastIndexOf(">");
        if (i.indexOf("array") >= 0 && a > 0) {
          for (var s = a; s > 0 && i.charAt(s) !== " " && i.charAt(s) !== ","; )
            s--;
          var l = i.substring(s + 1, a);
          for (o = +l, isNaN(o) && (o = +r[l.trim()]); s > 0 && (i.charAt(s) === " " || i.charAt(s) === ","); )
            s--;
          i = i.substring(i.indexOf("<") + 1, s + 1);
        }
        return [e, i, o];
      }, t.prototype.initializeShaders = function(e) {
        this._webgpuProcessingContext = e, this._attributesInputWGSL = [], this._attributesWGSL = [], this._attributesConversionCodeWGSL = [], this._hasNonFloatAttribute = !1, this._varyingsWGSL = [], this._varyingNamesWGSL = [], this._stridedUniformArrays = [];
      }, t.prototype.preProcessShaderCode = function(e) {
        return "struct ".concat(Rn.InternalsUBOName, ` {
  yFactor_: f32,
  textureOutputHeight_: f32,
};
var<uniform> `).concat("internals", " : ").concat(Rn.InternalsUBOName, `;
`) + $v(e);
      }, t.prototype.varyingProcessor = function(e, i, r) {
        var o = /\s*varying\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s*:\s*(.+)\s*;/gm.exec(e);
        if (o !== null) {
          var a, s = o[2], l = o[1];
          i ? (a = this._webgpuProcessingContext.availableVaryings[l]) === void 0 && q.Warn('Invalid fragment shader: The varying named "'.concat(l, '" is not declared in the vertex shader! This declaration will be ignored.')) : (a = this._webgpuProcessingContext.getVaryingNextLocation(s, this._getArraySize(l, s, r)[2]), this._webgpuProcessingContext.availableVaryings[l] = a, this._varyingsWGSL.push("  @location(".concat(a, ") ").concat(l, " : ").concat(s, ",")), this._varyingNamesWGSL.push(l)), e = "";
        }
        return e;
      }, t.prototype.attributeProcessor = function(e, i) {
        var r = /\s*attribute\s+(\S+)\s*:\s*(.+)\s*;/gm.exec(e);
        if (r !== null) {
          var o = r[2], a = r[1], s = this._webgpuProcessingContext.getAttributeNextLocation(o, this._getArraySize(a, o, i)[2]);
          this._webgpuProcessingContext.availableAttributes[a] = s, this._webgpuProcessingContext.orderedAttributes[s] = a;
          var l = this.vertexBufferKindToNumberOfComponents[a];
          if (l !== void 0) {
            var c = l < 0 ? l === -1 ? "i32" : "vec" + -l + "<i32>" : l === 1 ? "u32" : "vec" + l + "<u32>", u = "_int_".concat(a, "_");
            this._attributesInputWGSL.push("@location(".concat(s, ") ").concat(u, " : ").concat(c, ",")), this._attributesWGSL.push("".concat(a, " : ").concat(o, ",")), this._attributesConversionCodeWGSL.push("vertexInputs.".concat(a, " = ").concat(o, "(vertexInputs_.").concat(u, ");")), this._hasNonFloatAttribute = !0;
          } else
            this._attributesInputWGSL.push("@location(".concat(s, ") ").concat(a, " : ").concat(o, ",")), this._attributesWGSL.push("".concat(a, " : ").concat(o, ",")), this._attributesConversionCodeWGSL.push("vertexInputs.".concat(a, " = vertexInputs_.").concat(a, ";"));
          e = "";
        }
        return e;
      }, t.prototype.uniformProcessor = function(e, i, r) {
        var o = this.uniformRegexp.exec(e);
        if (o !== null) {
          var a = o[2], s = o[1];
          this._addUniformToLeftOverUBO(s, a, r), e = "";
        }
        return e;
      }, t.prototype.textureProcessor = function(e, i, r) {
        var o = this.textureRegexp.exec(e);
        if (o !== null) {
          var a = o[1], s = o[2], l = !!o[3], c = o[4], u = c.indexOf("storage") > 0, h = o[6], d = u ? h.substring(0, h.indexOf(",")).trim() : null, p = l ? this._getArraySize(a, s, r)[2] : 0, f = this._webgpuProcessingContext.availableTextures[a];
          if (f)
            p = f.textures.length;
          else {
            f = { isTextureArray: p > 0, isStorageTexture: u, textures: [], sampleType: nr.Float }, p = p || 1;
            for (var m = 0; m < p; ++m)
              f.textures.push(this._webgpuProcessingContext.getNextFreeUBOBinding());
          }
          this._webgpuProcessingContext.availableTextures[a] = f;
          var g = c.indexOf("depth") > 0, y = pD[c], b = g ? nr.Depth : h === "u32" ? nr.Uint : h === "i32" ? nr.Sint : nr.Float;
          if (f.sampleType = b, y === void 0)
            throw `Can't get the texture dimension corresponding to the texture function "`.concat(c, '"!');
          for (m = 0; m < p; ++m) {
            var T = f.textures[m], S = T.groupIndex, E = T.bindingIndex;
            m === 0 && (e = "@group(".concat(S, ") @binding(").concat(E, ") ").concat(e)), this._addTextureBindingDescription(a, f, m, y, d, !i);
          }
        }
        return e;
      }, t.prototype.postProcessor = function(e) {
        return e;
      }, t.prototype.finalizeShaders = function(e, i) {
        var r = i.indexOf("fragmentInputs.position") >= 0 ? `
            if (internals.yFactor_ == 1.) {
                fragmentInputs.position.y = internals.textureOutputHeight_ - fragmentInputs.position.y;
            }
        ` : "";
        e = this._processSamplers(e, !0), i = this._processSamplers(i, !1), e = this._processCustomBuffers(e, !0), i = this._processCustomBuffers(i, !1);
        var o = this._buildLeftOverUBO();
        i = o + i, e = (e = o + e).replace(/#define /g, "//#define "), e = this._processStridedUniformArrays(e);
        var a = `struct VertexInputs {
  @builtin(vertex_index) vertexIndex : u32,
  @builtin(instance_index) instanceIndex : u32,
`;
        this._attributesInputWGSL.length > 0 && (a += this._attributesInputWGSL.join(`
`)), a += `
};
var<private> vertexInputs` + (this._hasNonFloatAttribute ? "_" : "") + ` : VertexInputs;
`, this._hasNonFloatAttribute && (a += `struct VertexInputs_ {
  vertexIndex : u32, instanceIndex : u32,
`, a += this._attributesWGSL.join(`
`), a += `
};
var<private> vertexInputs : VertexInputs_;
`);
        var s = `struct FragmentInputs {
  @builtin(position) position : vec4<f32>,
`;
        this._varyingsWGSL.length > 0 && (s += this._varyingsWGSL.join(`
`)), e = a + (s += `
};
var<private> vertexOutputs : FragmentInputs;
`) + e;
        var l = `
  vertexInputs`.concat(this._hasNonFloatAttribute ? "_" : "", ` = input;
`);
        this._hasNonFloatAttribute && (l += `vertexInputs.vertexIndex = vertexInputs_.vertexIndex;
vertexInputs.instanceIndex = vertexInputs_.instanceIndex;
`, l += this._attributesConversionCodeWGSL.join(`
`), l += `
`), e = this._injectStartingAndEndingCode(e, "fn main", l, `  vertexOutputs.position.y = vertexOutputs.position.y * internals.yFactor_;
  return vertexOutputs;`), i = i.replace(/#define /g, "//#define "), i = (i = this._processStridedUniformArrays(i)).replace(/dpdy/g, "(-internals.yFactor_)*dpdy");
        var c = `struct FragmentInputs {
  @builtin(position) position : vec4<f32>,
  @builtin(front_facing) frontFacing : bool,
`;
        this._varyingsWGSL.length > 0 && (c += this._varyingsWGSL.join(`
`)), c += `
};
var<private> fragmentInputs : FragmentInputs;
`;
        for (var u = `struct FragmentOutputs {
  @location(0) color : vec4<f32>,
`, h = !1, d = 0; !(h || (d = i.indexOf("fragmentOutputs.fragDepth", d)) < 0); ) {
          var p = d;
          for (h = !0; d > 1 && i.charAt(d) !== `
`; ) {
            if (i.charAt(d) === "/" && i.charAt(d - 1) === "/") {
              h = !1;
              break;
            }
            d--;
          }
          d = p + 25;
        }
        h && (u += `  @builtin(frag_depth) fragDepth: f32,
`), i = c + (u += `};
var<private> fragmentOutputs : FragmentOutputs;
`) + i;
        var f = `  fragmentInputs = input;
  ` + r;
        return i = this._injectStartingAndEndingCode(i, "fn main", f, "  return fragmentOutputs;"), this._collectBindingNames(), this._preCreateBindGroupEntries(), this.vertexBufferKindToNumberOfComponents = {}, { vertexCode: e, fragmentCode: i };
      }, t.prototype._generateLeftOverUBOCode = function(e, i) {
        for (var r = "", o = "struct ".concat(e, ` {
`), a = 0, s = this._webgpuProcessingContext.leftOverUniforms; a < s.length; a++) {
          var l = s[a], c = l.type.replace(/^(.*?)(<.*>)?$/, "$1"), u = Rn.UniformSizes[c];
          if (l.length > 0)
            if (u <= 2) {
              var h = "".concat(e, "_").concat(this._stridedUniformArrays.length, "_strided_arr");
              r += "struct ".concat(h, ` {
                        @size(16)
                        el: `).concat(c, `,
                    }`), this._stridedUniformArrays.push(l.name), o += " @align(16) ".concat(l.name, " : array<").concat(h, ", ").concat(l.length, `>,
`);
            } else
              o += " ".concat(l.name, " : array<").concat(l.type, ", ").concat(l.length, `>,
`);
          else
            o += "  ".concat(l.name, " : ").concat(l.type, `,
`);
        }
        return o += `};
`, (o = "".concat(r, `
`).concat(o)) + "@group(".concat(i.binding.groupIndex, ") @binding(").concat(i.binding.bindingIndex, ") var<uniform> ").concat("uniforms", " : ").concat(e, `;
`);
      }, t.prototype._processSamplers = function(e, i) {
        for (var r = /var\s+(\w+Sampler)\s*:\s*(sampler|sampler_comparison)\s*;/gm; ; ) {
          var o = r.exec(e);
          if (o === null)
            break;
          var a = o[1], s = o[2], l = a.indexOf(Rn.AutoSamplerSuffix) === a.length - Rn.AutoSamplerSuffix.length ? a.substring(0, a.indexOf(Rn.AutoSamplerSuffix)) : null, c = s === "sampler_comparison" ? ga.Comparison : ga.Filtering;
          if (l) {
            var u = this._webgpuProcessingContext.availableTextures[l];
            u && (u.autoBindSampler = !0);
          }
          var h = this._webgpuProcessingContext.availableSamplers[a];
          h || (h = { binding: this._webgpuProcessingContext.getNextFreeUBOBinding(), type: c }, this._webgpuProcessingContext.availableSamplers[a] = h), this._addSamplerBindingDescription(a, h, i);
          var d = e.substring(0, o.index), p = "@group(".concat(h.binding.groupIndex, ") @binding(").concat(h.binding.bindingIndex, ") "), f = e.substring(o.index);
          e = d + p + f, r.lastIndex += p.length;
        }
        return e;
      }, t.prototype._processCustomBuffers = function(e, i) {
        for (var r = /var<\s*(uniform|storage)\s*(,\s*(read|read_write)\s*)?>\s+(\S+)\s*:\s*(\S+)\s*;/gm; ; ) {
          var o = r.exec(e);
          if (o === null)
            break;
          var a = o[1], s = o[3], l = o[4], c = o[5], u = this._webgpuProcessingContext.availableBuffers[l];
          if (!u) {
            var h = a === "uniform" ? kh.KnownUBOs[c] : null, d = void 0;
            h ? (l = c, (d = h.binding).groupIndex === -1 && (d = this._webgpuProcessingContext.getNextFreeUBOBinding())) : d = this._webgpuProcessingContext.getNextFreeUBOBinding(), u = { binding: d }, this._webgpuProcessingContext.availableBuffers[l] = u;
          }
          this._addBufferBindingDescription(l, this._webgpuProcessingContext.availableBuffers[l], s === "read_write" ? ma.Storage : a === "storage" ? ma.ReadOnlyStorage : ma.Uniform, i);
          var p = u.binding.groupIndex, f = u.binding.bindingIndex, m = e.substring(0, o.index), g = "@group(".concat(p, ") @binding(").concat(f, ") "), y = e.substring(o.index);
          e = m + g + y, r.lastIndex += g.length;
        }
        return e;
      }, t.prototype._processStridedUniformArrays = function(e) {
        for (var i = 0, r = this._stridedUniformArrays; i < r.length; i++) {
          var o = r[i];
          e = e.replace(new RegExp("".concat(o, "\\s*\\[(.*)\\]"), "g"), "".concat(o, "[$1].el"));
        }
        return e;
      }, t;
    }(Rn), Zf = function() {
      function n(t) {
        t === void 0 && (t = null), this.format = U.RGBA8Unorm, this.textureUsages = 0, this.textureAdditionalUsages = 0, this._webgpuTexture = t, this._webgpuMSAATexture = null, this.view = null, this.viewForWriting = null;
      }
      return Object.defineProperty(n.prototype, "underlyingResource", { get: function() {
        return this._webgpuTexture;
      }, enumerable: !1, configurable: !0 }), n.prototype.getMSAATexture = function(t) {
        var e, i;
        return t === void 0 && (t = 0), (i = (e = this._webgpuMSAATexture) === null || e === void 0 ? void 0 : e[t]) !== null && i !== void 0 ? i : null;
      }, n.prototype.setMSAATexture = function(t, e) {
        e === void 0 && (e = -1), this._webgpuMSAATexture || (this._webgpuMSAATexture = []), e === -1 && (e = this._webgpuMSAATexture.length), this._webgpuMSAATexture[e] = t;
      }, n.prototype.releaseMSAATexture = function() {
        if (this._webgpuMSAATexture) {
          for (var t = 0, e = this._webgpuMSAATexture; t < e.length; t++) {
            var i = e[t];
            i == null || i.destroy();
          }
          this._webgpuMSAATexture = null;
        }
      }, n.prototype.set = function(t) {
        this._webgpuTexture = t;
      }, n.prototype.setUsage = function(t, e, i, r, o) {
        this.createView({ format: this.format, dimension: i ? ei.Cube : ei.E2d, mipLevelCount: e ? ue.ILog2(Math.max(r, o)) + 1 : 1, baseArrayLayer: 0, baseMipLevel: 0, arrayLayerCount: i ? 6 : 1, aspect: no.All });
      }, n.prototype.createView = function(t, e) {
        if (e === void 0 && (e = !1), this.view = this._webgpuTexture.createView(t), e && t) {
          var i = t.mipLevelCount;
          t.mipLevelCount = 1, this.viewForWriting = this._webgpuTexture.createView(t), t.mipLevelCount = i;
        }
      }, n.prototype.reset = function() {
        this._webgpuTexture = null, this._webgpuMSAATexture = null, this.view = null, this.viewForWriting = null;
      }, n.prototype.release = function() {
        var t, e;
        (t = this._webgpuTexture) === null || t === void 0 || t.destroy(), this.releaseMSAATexture(), (e = this._copyInvertYTempTexture) === null || e === void 0 || e.destroy(), this.reset();
      }, n;
    }(), SC = `
    #extension GL_EXT_samplerless_texture_functions : enable

    const vec2 pos[4] = vec2[4](vec2(-1.0f, 1.0f), vec2(1.0f, 1.0f), vec2(-1.0f, -1.0f), vec2(1.0f, -1.0f));
    const vec2 tex[4] = vec2[4](vec2(0.0f, 0.0f), vec2(1.0f, 0.0f), vec2(0.0f, 1.0f), vec2(1.0f, 1.0f));

    layout(set = 0, binding = 0) uniform texture2D img;

    #ifdef INVERTY
        layout(location = 0) out flat ivec2 vTextureSize;
    #endif

    void main() {
        #ifdef INVERTY
            vTextureSize = textureSize(img, 0);
        #endif
        gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);
    }
    `, _D = SC;
    (function(n) {
      n[n.MipMap = 0] = "MipMap", n[n.InvertYPremultiplyAlpha = 1] = "InvertYPremultiplyAlpha", n[n.Clear = 2] = "Clear", n[n.InvertYPremultiplyAlphaWithOfst = 3] = "InvertYPremultiplyAlphaWithOfst";
    })(ro || (ro = {})), function(n) {
      n[n.DontInvertY = 0] = "DontInvertY", n[n.InvertY = 1] = "InvertY";
    }(zc || (zc = {}));
    var or, wi, xC = [{ vertex: `
    const vec2 pos[4] = vec2[4](vec2(-1.0f, 1.0f), vec2(1.0f, 1.0f), vec2(-1.0f, -1.0f), vec2(1.0f, -1.0f));
    const vec2 tex[4] = vec2[4](vec2(0.0f, 0.0f), vec2(1.0f, 0.0f), vec2(0.0f, 1.0f), vec2(1.0f, 1.0f));

    layout(location = 0) out vec2 vTex;

    void main() {
        vTex = tex[gl_VertexIndex];
        gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);
    }
    `, fragment: `
    layout(set = 0, binding = 0) uniform sampler imgSampler;
    layout(set = 0, binding = 1) uniform texture2D img;

    layout(location = 0) in vec2 vTex;
    layout(location = 0) out vec4 outColor;

    void main() {
        outColor = texture(sampler2D(img, imgSampler), vTex);
    }
    ` }, { vertex: SC, fragment: `
    #extension GL_EXT_samplerless_texture_functions : enable

    layout(set = 0, binding = 0) uniform texture2D img;

    #ifdef INVERTY
        layout(location = 0) in flat ivec2 vTextureSize;
    #endif
    layout(location = 0) out vec4 outColor;

    void main() {
    #ifdef INVERTY
        vec4 color = texelFetch(img, ivec2(gl_FragCoord.x, vTextureSize.y - gl_FragCoord.y), 0);
    #else
        vec4 color = texelFetch(img, ivec2(gl_FragCoord.xy), 0);
    #endif
    #ifdef PREMULTIPLYALPHA
        color.rgb *= color.a;
    #endif
        outColor = color;
    }
    ` }, { vertex: `
    const vec2 pos[4] = vec2[4](vec2(-1.0f, 1.0f), vec2(1.0f, 1.0f), vec2(-1.0f, -1.0f), vec2(1.0f, -1.0f));

    void main() {
        gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);
    }
    `, fragment: `
    layout(set = 0, binding = 0) uniform Uniforms {
        uniform vec4 color;
    };

    layout(location = 0) out vec4 outColor;

    void main() {
        outColor = color;
    }
    ` }, { vertex: _D, fragment: `
    #extension GL_EXT_samplerless_texture_functions : enable

    layout(set = 0, binding = 0) uniform texture2D img;
    layout(set = 0, binding = 1) uniform Params {
        float ofstX;
        float ofstY;
        float width;
        float height;
    };

    #ifdef INVERTY
        layout(location = 0) in flat ivec2 vTextureSize;
    #endif
    layout(location = 0) out vec4 outColor;

    void main() {
        if (gl_FragCoord.x < ofstX || gl_FragCoord.x >= ofstX + width) {
            discard;
        }
        if (gl_FragCoord.y < ofstY || gl_FragCoord.y >= ofstY + height) {
            discard;
        }
    #ifdef INVERTY
        vec4 color = texelFetch(img, ivec2(gl_FragCoord.x, ofstY + height - (gl_FragCoord.y - ofstY)), 0);
    #else
        vec4 color = texelFetch(img, ivec2(gl_FragCoord.xy), 0);
    #endif
    #ifdef PREMULTIPLYALPHA
        color.rgb *= color.a;
    #endif
        outColor = color;
    }
    ` }], ba = { "": 0, r8unorm: 1, r8uint: 2, r8sint: 3, r16uint: 4, r16sint: 5, r16float: 6, rg8unorm: 7, rg8uint: 8, rg8sint: 9, r32uint: 10, r32sint: 11, r32float: 12, rg16uint: 13, rg16sint: 14, rg16float: 15, rgba8unorm: 16, "rgba8unorm-srgb": 17, rgba8uint: 18, rgba8sint: 19, bgra8unorm: 20, "bgra8unorm-srgb": 21, rgb10a2uint: 22, rgb10a2unorm: 23, rg32uint: 24, rg32sint: 25, rg32float: 26, rgba16uint: 27, rgba16sint: 28, rgba16float: 29, rgba32uint: 30, rgba32sint: 31, rgba32float: 32, stencil8: 33, depth16unorm: 34, depth24plus: 35, "depth24plus-stencil8": 36, depth32float: 37, "depth32float-stencil8": 38 }, kr = function() {
      function n(t, e, i, r, o) {
        if (this._pipelines = {}, this._compiledShaders = [], this._videoPipelines = {}, this._videoCompiledShaders = [], this._deferredReleaseTextures = [], this._device = t, this._glslang = e, this._tintWASM = i, this._bufferManager = r, o.indexOf(Lo.RG11B10UFloatRenderable) !== -1) {
          var a = Object.keys(ba);
          ba[U.RG11B10UFloat] = ba[a[a.length - 1]] + 1;
        }
        this._mipmapSampler = t.createSampler({ minFilter: Ct.Linear }), this._videoSampler = t.createSampler({ minFilter: Ct.Linear }), this._ubCopyWithOfst = this._bufferManager.createBuffer(16, $t.Uniform | $t.CopyDst, "UBCopyWithOffset").underlyingResource, this._getPipeline(U.RGBA8Unorm), this._getVideoPipeline(U.RGBA8Unorm);
      }
      return n.ComputeNumMipmapLevels = function(t, e) {
        return ue.ILog2(Math.max(t, e)) + 1;
      }, n.prototype._getPipeline = function(t, e, i) {
        e === void 0 && (e = ro.MipMap);
        var r = e === ro.MipMap ? 1 : e === ro.InvertYPremultiplyAlpha ? ((i.invertY ? 1 : 0) << 1) + ((i.premultiplyAlpha ? 1 : 0) << 2) : e === ro.Clear ? 8 : e === ro.InvertYPremultiplyAlphaWithOfst ? ((i.invertY ? 1 : 0) << 4) + ((i.premultiplyAlpha ? 1 : 0) << 5) : 0;
        this._pipelines[t] || (this._pipelines[t] = []);
        var o = this._pipelines[t][r];
        if (!o) {
          var a = `#version 450
`;
          e !== ro.InvertYPremultiplyAlpha && e !== ro.InvertYPremultiplyAlphaWithOfst || (i.invertY && (a += `#define INVERTY
`), i.premultiplyAlpha && (a += `#define PREMULTIPLYALPHA
`));
          var s = this._compiledShaders[r];
          if (!s) {
            var l = this._glslang.compileGLSL(a + xC[e].vertex, "vertex"), c = this._glslang.compileGLSL(a + xC[e].fragment, "fragment");
            this._tintWASM && (l = this._tintWASM.convertSpirV2WGSL(l), c = this._tintWASM.convertSpirV2WGSL(c));
            var u = this._device.createShaderModule({ code: l }), h = this._device.createShaderModule({ code: c });
            s = this._compiledShaders[r] = [u, h];
          }
          var d = this._device.createRenderPipeline({ layout: xl.Auto, vertex: { module: s[0], entryPoint: "main" }, fragment: { module: s[1], entryPoint: "main", targets: [{ format: t }] }, primitive: { topology: rr.TriangleStrip, stripIndexFormat: ya.Uint16 } });
          o = this._pipelines[t][r] = [d, d.getBindGroupLayout(0)];
        }
        return o;
      }, n.prototype._getVideoPipeline = function(t, e) {
        e === void 0 && (e = zc.DontInvertY);
        var i = e === zc.InvertY ? 1 : 0;
        this._videoPipelines[t] || (this._videoPipelines[t] = []);
        var r = this._videoPipelines[t][i];
        if (!r) {
          var o = this._videoCompiledShaders[i];
          if (!o) {
            var a = this._device.createShaderModule({ code: `
    struct VertexOutput {
        @builtin(position) Position : vec4<f32>,
        @location(0) fragUV : vec2<f32>
    }
  
    @vertex
    fn main(
        @builtin(vertex_index) VertexIndex : u32
    ) -> VertexOutput {
        var pos = array<vec2<f32>, 4>(
            vec2(-1.0,  1.0),
            vec2( 1.0,  1.0),
            vec2(-1.0, -1.0),
            vec2( 1.0, -1.0)
        );
        var tex = array<vec2<f32>, 4>(
            vec2(0.0, 0.0),
            vec2(1.0, 0.0),
            vec2(0.0, 1.0),
            vec2(1.0, 1.0)
        );

        var output: VertexOutput;

        output.Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
        output.fragUV = tex[VertexIndex];

        return output;
    }
    ` }), s = this._device.createShaderModule({ code: i === 0 ? `
    @group(0) @binding(0) var videoSampler: sampler;
    @group(0) @binding(1) var videoTexture: texture_external;

    @fragment
    fn main(
        @location(0) fragUV: vec2<f32>
    ) -> @location(0) vec4<f32> {
        return textureSampleBaseClampToEdge(videoTexture, videoSampler, fragUV);
    }
    ` : `
    @group(0) @binding(0) var videoSampler: sampler;
    @group(0) @binding(1) var videoTexture: texture_external;

    @fragment
    fn main(
        @location(0) fragUV: vec2<f32>
    ) -> @location(0) vec4<f32> {
        return textureSampleBaseClampToEdge(videoTexture, videoSampler, vec2<f32>(fragUV.x, 1.0 - fragUV.y));
    }
    ` });
            o = this._videoCompiledShaders[i] = [a, s];
          }
          var l = this._device.createRenderPipeline({ label: "CopyVideoToTexture_".concat(t, "_").concat(i === 0 ? "DontInvertY" : "InvertY"), layout: xl.Auto, vertex: { module: o[0], entryPoint: "main" }, fragment: { module: o[1], entryPoint: "main", targets: [{ format: t }] }, primitive: { topology: rr.TriangleStrip, stripIndexFormat: ya.Uint16 } });
          r = this._videoPipelines[t][i] = [l, l.getBindGroupLayout(0)];
        }
        return r;
      }, n.GetTextureTypeFromFormat = function(t) {
        switch (t) {
          case U.R8Unorm:
          case U.R8Snorm:
          case U.R8Uint:
          case U.R8Sint:
          case U.RG8Unorm:
          case U.RG8Snorm:
          case U.RG8Uint:
          case U.RG8Sint:
          case U.RGBA8Unorm:
          case U.RGBA8UnormSRGB:
          case U.RGBA8Snorm:
          case U.RGBA8Uint:
          case U.RGBA8Sint:
          case U.BGRA8Unorm:
          case U.BGRA8UnormSRGB:
          case U.RGB10A2UINT:
          case U.RGB10A2Unorm:
          case U.RGB9E5UFloat:
          case U.RG11B10UFloat:
          case U.BC7RGBAUnorm:
          case U.BC7RGBAUnormSRGB:
          case U.BC6HRGBUFloat:
          case U.BC6HRGBFloat:
          case U.BC5RGUnorm:
          case U.BC5RGSnorm:
          case U.BC3RGBAUnorm:
          case U.BC3RGBAUnormSRGB:
          case U.BC2RGBAUnorm:
          case U.BC2RGBAUnormSRGB:
          case U.BC4RUnorm:
          case U.BC4RSnorm:
          case U.BC1RGBAUnorm:
          case U.BC1RGBAUnormSRGB:
          case U.ETC2RGB8Unorm:
          case U.ETC2RGB8UnormSRGB:
          case U.ETC2RGB8A1Unorm:
          case U.ETC2RGB8A1UnormSRGB:
          case U.ETC2RGBA8Unorm:
          case U.ETC2RGBA8UnormSRGB:
          case U.EACR11Unorm:
          case U.EACR11Snorm:
          case U.EACRG11Unorm:
          case U.EACRG11Snorm:
          case U.ASTC4x4Unorm:
          case U.ASTC4x4UnormSRGB:
          case U.ASTC5x4Unorm:
          case U.ASTC5x4UnormSRGB:
          case U.ASTC5x5Unorm:
          case U.ASTC5x5UnormSRGB:
          case U.ASTC6x5Unorm:
          case U.ASTC6x5UnormSRGB:
          case U.ASTC6x6Unorm:
          case U.ASTC6x6UnormSRGB:
          case U.ASTC8x5Unorm:
          case U.ASTC8x5UnormSRGB:
          case U.ASTC8x6Unorm:
          case U.ASTC8x6UnormSRGB:
          case U.ASTC8x8Unorm:
          case U.ASTC8x8UnormSRGB:
          case U.ASTC10x5Unorm:
          case U.ASTC10x5UnormSRGB:
          case U.ASTC10x6Unorm:
          case U.ASTC10x6UnormSRGB:
          case U.ASTC10x8Unorm:
          case U.ASTC10x8UnormSRGB:
          case U.ASTC10x10Unorm:
          case U.ASTC10x10UnormSRGB:
          case U.ASTC12x10Unorm:
          case U.ASTC12x10UnormSRGB:
          case U.ASTC12x12Unorm:
          case U.ASTC12x12UnormSRGB:
          case U.Stencil8:
            return _.TEXTURETYPE_UNSIGNED_BYTE;
          case U.R16Uint:
          case U.R16Sint:
          case U.RG16Uint:
          case U.RG16Sint:
          case U.RGBA16Uint:
          case U.RGBA16Sint:
          case U.Depth16Unorm:
            return _.TEXTURETYPE_UNSIGNED_SHORT;
          case U.R16Float:
          case U.RG16Float:
          case U.RGBA16Float:
            return _.TEXTURETYPE_HALF_FLOAT;
          case U.R32Uint:
          case U.R32Sint:
          case U.RG32Uint:
          case U.RG32Sint:
          case U.RGBA32Uint:
          case U.RGBA32Sint:
            return _.TEXTURETYPE_UNSIGNED_INTEGER;
          case U.R32Float:
          case U.RG32Float:
          case U.RGBA32Float:
          case U.Depth32Float:
          case U.Depth32FloatStencil8:
          case U.Depth24Plus:
          case U.Depth24PlusStencil8:
            return _.TEXTURETYPE_FLOAT;
        }
        return _.TEXTURETYPE_UNSIGNED_BYTE;
      }, n._GetBlockInformationFromFormat = function(t) {
        switch (t) {
          case U.R8Unorm:
          case U.R8Snorm:
          case U.R8Uint:
          case U.R8Sint:
            return { width: 1, height: 1, length: 1 };
          case U.R16Uint:
          case U.R16Sint:
          case U.R16Float:
          case U.RG8Unorm:
          case U.RG8Snorm:
          case U.RG8Uint:
          case U.RG8Sint:
            return { width: 1, height: 1, length: 2 };
          case U.R32Uint:
          case U.R32Sint:
          case U.R32Float:
          case U.RG16Uint:
          case U.RG16Sint:
          case U.RG16Float:
          case U.RGBA8Unorm:
          case U.RGBA8UnormSRGB:
          case U.RGBA8Snorm:
          case U.RGBA8Uint:
          case U.RGBA8Sint:
          case U.BGRA8Unorm:
          case U.BGRA8UnormSRGB:
          case U.RGB9E5UFloat:
          case U.RGB10A2UINT:
          case U.RGB10A2Unorm:
          case U.RG11B10UFloat:
            return { width: 1, height: 1, length: 4 };
          case U.RG32Uint:
          case U.RG32Sint:
          case U.RG32Float:
          case U.RGBA16Uint:
          case U.RGBA16Sint:
          case U.RGBA16Float:
            return { width: 1, height: 1, length: 8 };
          case U.RGBA32Uint:
          case U.RGBA32Sint:
          case U.RGBA32Float:
            return { width: 1, height: 1, length: 16 };
          case U.Stencil8:
            throw "No fixed size for Stencil8 format!";
          case U.Depth16Unorm:
            return { width: 1, height: 1, length: 2 };
          case U.Depth24Plus:
            throw "No fixed size for Depth24Plus format!";
          case U.Depth24PlusStencil8:
            throw "No fixed size for Depth24PlusStencil8 format!";
          case U.Depth32Float:
            return { width: 1, height: 1, length: 4 };
          case U.Depth32FloatStencil8:
            return { width: 1, height: 1, length: 5 };
          case U.BC7RGBAUnorm:
          case U.BC7RGBAUnormSRGB:
          case U.BC6HRGBUFloat:
          case U.BC6HRGBFloat:
          case U.BC5RGUnorm:
          case U.BC5RGSnorm:
          case U.BC3RGBAUnorm:
          case U.BC3RGBAUnormSRGB:
          case U.BC2RGBAUnorm:
          case U.BC2RGBAUnormSRGB:
            return { width: 4, height: 4, length: 16 };
          case U.BC4RUnorm:
          case U.BC4RSnorm:
          case U.BC1RGBAUnorm:
          case U.BC1RGBAUnormSRGB:
          case U.ETC2RGB8Unorm:
          case U.ETC2RGB8UnormSRGB:
          case U.ETC2RGB8A1Unorm:
          case U.ETC2RGB8A1UnormSRGB:
          case U.EACR11Unorm:
          case U.EACR11Snorm:
            return { width: 4, height: 4, length: 8 };
          case U.ETC2RGBA8Unorm:
          case U.ETC2RGBA8UnormSRGB:
          case U.EACRG11Unorm:
          case U.EACRG11Snorm:
          case U.ASTC4x4Unorm:
          case U.ASTC4x4UnormSRGB:
            return { width: 4, height: 4, length: 16 };
          case U.ASTC5x4Unorm:
          case U.ASTC5x4UnormSRGB:
            return { width: 5, height: 4, length: 16 };
          case U.ASTC5x5Unorm:
          case U.ASTC5x5UnormSRGB:
            return { width: 5, height: 5, length: 16 };
          case U.ASTC6x5Unorm:
          case U.ASTC6x5UnormSRGB:
            return { width: 6, height: 5, length: 16 };
          case U.ASTC6x6Unorm:
          case U.ASTC6x6UnormSRGB:
            return { width: 6, height: 6, length: 16 };
          case U.ASTC8x5Unorm:
          case U.ASTC8x5UnormSRGB:
            return { width: 8, height: 5, length: 16 };
          case U.ASTC8x6Unorm:
          case U.ASTC8x6UnormSRGB:
            return { width: 8, height: 6, length: 16 };
          case U.ASTC8x8Unorm:
          case U.ASTC8x8UnormSRGB:
            return { width: 8, height: 8, length: 16 };
          case U.ASTC10x5Unorm:
          case U.ASTC10x5UnormSRGB:
            return { width: 10, height: 5, length: 16 };
          case U.ASTC10x6Unorm:
          case U.ASTC10x6UnormSRGB:
            return { width: 10, height: 6, length: 16 };
          case U.ASTC10x8Unorm:
          case U.ASTC10x8UnormSRGB:
            return { width: 10, height: 8, length: 16 };
          case U.ASTC10x10Unorm:
          case U.ASTC10x10UnormSRGB:
            return { width: 10, height: 10, length: 16 };
          case U.ASTC12x10Unorm:
          case U.ASTC12x10UnormSRGB:
            return { width: 12, height: 10, length: 16 };
          case U.ASTC12x12Unorm:
          case U.ASTC12x12UnormSRGB:
            return { width: 12, height: 12, length: 16 };
        }
        return { width: 1, height: 1, length: 4 };
      }, n._IsHardwareTexture = function(t) {
        return !!t.release;
      }, n._IsInternalTexture = function(t) {
        return !!t.dispose;
      }, n.IsImageBitmap = function(t) {
        return t.close !== void 0;
      }, n.IsImageBitmapArray = function(t) {
        return Array.isArray(t) && t[0].close !== void 0;
      }, n.prototype.setCommandEncoder = function(t) {
        this._commandEncoderForCreation = t;
      }, n.IsCompressedFormat = function(t) {
        switch (t) {
          case U.BC7RGBAUnormSRGB:
          case U.BC7RGBAUnorm:
          case U.BC6HRGBFloat:
          case U.BC6HRGBUFloat:
          case U.BC5RGSnorm:
          case U.BC5RGUnorm:
          case U.BC4RSnorm:
          case U.BC4RUnorm:
          case U.BC3RGBAUnormSRGB:
          case U.BC3RGBAUnorm:
          case U.BC2RGBAUnormSRGB:
          case U.BC2RGBAUnorm:
          case U.BC1RGBAUnormSRGB:
          case U.BC1RGBAUnorm:
          case U.ETC2RGB8Unorm:
          case U.ETC2RGB8UnormSRGB:
          case U.ETC2RGB8A1Unorm:
          case U.ETC2RGB8A1UnormSRGB:
          case U.ETC2RGBA8Unorm:
          case U.ETC2RGBA8UnormSRGB:
          case U.EACR11Unorm:
          case U.EACR11Snorm:
          case U.EACRG11Unorm:
          case U.EACRG11Snorm:
          case U.ASTC4x4Unorm:
          case U.ASTC4x4UnormSRGB:
          case U.ASTC5x4Unorm:
          case U.ASTC5x4UnormSRGB:
          case U.ASTC5x5Unorm:
          case U.ASTC5x5UnormSRGB:
          case U.ASTC6x5Unorm:
          case U.ASTC6x5UnormSRGB:
          case U.ASTC6x6Unorm:
          case U.ASTC6x6UnormSRGB:
          case U.ASTC8x5Unorm:
          case U.ASTC8x5UnormSRGB:
          case U.ASTC8x6Unorm:
          case U.ASTC8x6UnormSRGB:
          case U.ASTC8x8Unorm:
          case U.ASTC8x8UnormSRGB:
          case U.ASTC10x5Unorm:
          case U.ASTC10x5UnormSRGB:
          case U.ASTC10x6Unorm:
          case U.ASTC10x6UnormSRGB:
          case U.ASTC10x8Unorm:
          case U.ASTC10x8UnormSRGB:
          case U.ASTC10x10Unorm:
          case U.ASTC10x10UnormSRGB:
          case U.ASTC12x10Unorm:
          case U.ASTC12x10UnormSRGB:
          case U.ASTC12x12Unorm:
          case U.ASTC12x12UnormSRGB:
            return !0;
        }
        return !1;
      }, n.GetWebGPUTextureFormat = function(t, e, i) {
        switch (i === void 0 && (i = !1), e) {
          case _.TEXTUREFORMAT_DEPTH16:
            return U.Depth16Unorm;
          case _.TEXTUREFORMAT_DEPTH24:
            return U.Depth24Plus;
          case _.TEXTUREFORMAT_DEPTH24_STENCIL8:
            return U.Depth24PlusStencil8;
          case _.TEXTUREFORMAT_DEPTH32_FLOAT:
            return U.Depth32Float;
          case _.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8:
            return U.Depth32FloatStencil8;
          case _.TEXTUREFORMAT_STENCIL8:
            return U.Stencil8;
          case _.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM:
            return i ? U.BC7RGBAUnormSRGB : U.BC7RGBAUnorm;
          case _.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT:
            return U.BC6HRGBUFloat;
          case _.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT:
            return U.BC6HRGBFloat;
          case _.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5:
            return i ? U.BC3RGBAUnormSRGB : U.BC3RGBAUnorm;
          case _.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3:
            return i ? U.BC2RGBAUnormSRGB : U.BC2RGBAUnorm;
          case _.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1:
          case _.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1:
            return i ? U.BC1RGBAUnormSRGB : U.BC1RGBAUnorm;
          case _.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4:
            return i ? U.ASTC4x4UnormSRGB : U.ASTC4x4Unorm;
          case _.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL:
          case _.TEXTUREFORMAT_COMPRESSED_RGB8_ETC2:
            return i ? U.ETC2RGB8UnormSRGB : U.ETC2RGB8Unorm;
          case _.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC:
            return i ? U.ETC2RGBA8UnormSRGB : U.ETC2RGBA8Unorm;
        }
        switch (t) {
          case _.TEXTURETYPE_BYTE:
            switch (e) {
              case _.TEXTUREFORMAT_RED:
                return U.R8Snorm;
              case _.TEXTUREFORMAT_RG:
                return U.RG8Snorm;
              case _.TEXTUREFORMAT_RGB:
                throw "RGB format not supported in WebGPU";
              case _.TEXTUREFORMAT_RED_INTEGER:
                return U.R8Sint;
              case _.TEXTUREFORMAT_RG_INTEGER:
                return U.RG8Sint;
              case _.TEXTUREFORMAT_RGB_INTEGER:
                throw "RGB_INTEGER format not supported in WebGPU";
              case _.TEXTUREFORMAT_RGBA_INTEGER:
                return U.RGBA8Sint;
              default:
                return U.RGBA8Snorm;
            }
          case _.TEXTURETYPE_UNSIGNED_BYTE:
            switch (e) {
              case _.TEXTUREFORMAT_RED:
                return U.R8Unorm;
              case _.TEXTUREFORMAT_RG:
                return U.RG8Unorm;
              case _.TEXTUREFORMAT_RGB:
                throw "TEXTUREFORMAT_RGB format not supported in WebGPU";
              case _.TEXTUREFORMAT_RGBA:
                return i ? U.RGBA8UnormSRGB : U.RGBA8Unorm;
              case _.TEXTUREFORMAT_BGRA:
                return i ? U.BGRA8UnormSRGB : U.BGRA8Unorm;
              case _.TEXTUREFORMAT_RED_INTEGER:
                return U.R8Uint;
              case _.TEXTUREFORMAT_RG_INTEGER:
                return U.RG8Uint;
              case _.TEXTUREFORMAT_RGB_INTEGER:
                throw "RGB_INTEGER format not supported in WebGPU";
              case _.TEXTUREFORMAT_RGBA_INTEGER:
                return U.RGBA8Uint;
              case _.TEXTUREFORMAT_ALPHA:
                throw "TEXTUREFORMAT_ALPHA format not supported in WebGPU";
              case _.TEXTUREFORMAT_LUMINANCE:
                throw "TEXTUREFORMAT_LUMINANCE format not supported in WebGPU";
              case _.TEXTUREFORMAT_LUMINANCE_ALPHA:
                throw "TEXTUREFORMAT_LUMINANCE_ALPHA format not supported in WebGPU";
              default:
                return U.RGBA8Unorm;
            }
          case _.TEXTURETYPE_SHORT:
            switch (e) {
              case _.TEXTUREFORMAT_RED_INTEGER:
                return U.R16Sint;
              case _.TEXTUREFORMAT_RG_INTEGER:
                return U.RG16Sint;
              case _.TEXTUREFORMAT_RGB_INTEGER:
                throw "TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";
              case _.TEXTUREFORMAT_RGBA_INTEGER:
              default:
                return U.RGBA16Sint;
            }
          case _.TEXTURETYPE_UNSIGNED_SHORT:
            switch (e) {
              case _.TEXTUREFORMAT_RED_INTEGER:
                return U.R16Uint;
              case _.TEXTUREFORMAT_RG_INTEGER:
                return U.RG16Uint;
              case _.TEXTUREFORMAT_RGB_INTEGER:
                throw "TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";
              case _.TEXTUREFORMAT_RGBA_INTEGER:
              default:
                return U.RGBA16Uint;
            }
          case _.TEXTURETYPE_INT:
            switch (e) {
              case _.TEXTUREFORMAT_RED_INTEGER:
                return U.R32Sint;
              case _.TEXTUREFORMAT_RG_INTEGER:
                return U.RG32Sint;
              case _.TEXTUREFORMAT_RGB_INTEGER:
                throw "TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";
              case _.TEXTUREFORMAT_RGBA_INTEGER:
              default:
                return U.RGBA32Sint;
            }
          case _.TEXTURETYPE_UNSIGNED_INTEGER:
            switch (e) {
              case _.TEXTUREFORMAT_RED_INTEGER:
                return U.R32Uint;
              case _.TEXTUREFORMAT_RG_INTEGER:
                return U.RG32Uint;
              case _.TEXTUREFORMAT_RGB_INTEGER:
                throw "TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";
              case _.TEXTUREFORMAT_RGBA_INTEGER:
              default:
                return U.RGBA32Uint;
            }
          case _.TEXTURETYPE_FLOAT:
            switch (e) {
              case _.TEXTUREFORMAT_RED:
                return U.R32Float;
              case _.TEXTUREFORMAT_RG:
                return U.RG32Float;
              case _.TEXTUREFORMAT_RGB:
                throw "TEXTUREFORMAT_RGB format not supported in WebGPU";
              case _.TEXTUREFORMAT_RGBA:
              default:
                return U.RGBA32Float;
            }
          case _.TEXTURETYPE_HALF_FLOAT:
            switch (e) {
              case _.TEXTUREFORMAT_RED:
                return U.R16Float;
              case _.TEXTUREFORMAT_RG:
                return U.RG16Float;
              case _.TEXTUREFORMAT_RGB:
                throw "TEXTUREFORMAT_RGB format not supported in WebGPU";
              case _.TEXTUREFORMAT_RGBA:
              default:
                return U.RGBA16Float;
            }
          case _.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
            throw "TEXTURETYPE_UNSIGNED_SHORT_5_6_5 format not supported in WebGPU";
          case _.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
            switch (e) {
              case _.TEXTUREFORMAT_RGBA:
                return U.RG11B10UFloat;
              case _.TEXTUREFORMAT_RGBA_INTEGER:
                throw "TEXTUREFORMAT_RGBA_INTEGER format not supported in WebGPU when type is TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV";
              default:
                return U.RG11B10UFloat;
            }
          case _.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
            switch (e) {
              case _.TEXTUREFORMAT_RGBA:
                return U.RGB9E5UFloat;
              case _.TEXTUREFORMAT_RGBA_INTEGER:
                throw "TEXTUREFORMAT_RGBA_INTEGER format not supported in WebGPU when type is TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV";
              default:
                return U.RGB9E5UFloat;
            }
          case _.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
            throw "TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 format not supported in WebGPU";
          case _.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
            throw "TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 format not supported in WebGPU";
          case _.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
            switch (e) {
              case _.TEXTUREFORMAT_RGBA:
                return U.RGB10A2Unorm;
              case _.TEXTUREFORMAT_RGBA_INTEGER:
                return U.RGB10A2UINT;
              default:
                return U.RGB10A2Unorm;
            }
        }
        return i ? U.RGBA8UnormSRGB : U.RGBA8Unorm;
      }, n.GetNumChannelsFromWebGPUTextureFormat = function(t) {
        switch (t) {
          case U.R8Unorm:
          case U.R8Snorm:
          case U.R8Uint:
          case U.R8Sint:
          case U.BC4RUnorm:
          case U.BC4RSnorm:
          case U.R16Uint:
          case U.R16Sint:
          case U.Depth16Unorm:
          case U.R16Float:
          case U.R32Uint:
          case U.R32Sint:
          case U.R32Float:
          case U.Depth32Float:
          case U.Stencil8:
          case U.Depth24Plus:
          case U.EACR11Unorm:
          case U.EACR11Snorm:
            return 1;
          case U.RG8Unorm:
          case U.RG8Snorm:
          case U.RG8Uint:
          case U.RG8Sint:
          case U.Depth32FloatStencil8:
          case U.BC5RGUnorm:
          case U.BC5RGSnorm:
          case U.RG16Uint:
          case U.RG16Sint:
          case U.RG16Float:
          case U.RG32Uint:
          case U.RG32Sint:
          case U.RG32Float:
          case U.Depth24PlusStencil8:
          case U.EACRG11Unorm:
          case U.EACRG11Snorm:
            return 2;
          case U.RGB9E5UFloat:
          case U.RG11B10UFloat:
          case U.BC6HRGBUFloat:
          case U.BC6HRGBFloat:
          case U.ETC2RGB8Unorm:
          case U.ETC2RGB8UnormSRGB:
            return 3;
          case U.RGBA8Unorm:
          case U.RGBA8UnormSRGB:
          case U.RGBA8Snorm:
          case U.RGBA8Uint:
          case U.RGBA8Sint:
          case U.BGRA8Unorm:
          case U.BGRA8UnormSRGB:
          case U.RGB10A2UINT:
          case U.RGB10A2Unorm:
          case U.BC7RGBAUnorm:
          case U.BC7RGBAUnormSRGB:
          case U.BC3RGBAUnorm:
          case U.BC3RGBAUnormSRGB:
          case U.BC2RGBAUnorm:
          case U.BC2RGBAUnormSRGB:
          case U.BC1RGBAUnorm:
          case U.BC1RGBAUnormSRGB:
          case U.RGBA16Uint:
          case U.RGBA16Sint:
          case U.RGBA16Float:
          case U.RGBA32Uint:
          case U.RGBA32Sint:
          case U.RGBA32Float:
          case U.ETC2RGB8A1Unorm:
          case U.ETC2RGB8A1UnormSRGB:
          case U.ETC2RGBA8Unorm:
          case U.ETC2RGBA8UnormSRGB:
          case U.ASTC4x4Unorm:
          case U.ASTC4x4UnormSRGB:
          case U.ASTC5x4Unorm:
          case U.ASTC5x4UnormSRGB:
          case U.ASTC5x5Unorm:
          case U.ASTC5x5UnormSRGB:
          case U.ASTC6x5Unorm:
          case U.ASTC6x5UnormSRGB:
          case U.ASTC6x6Unorm:
          case U.ASTC6x6UnormSRGB:
          case U.ASTC8x5Unorm:
          case U.ASTC8x5UnormSRGB:
          case U.ASTC8x6Unorm:
          case U.ASTC8x6UnormSRGB:
          case U.ASTC8x8Unorm:
          case U.ASTC8x8UnormSRGB:
          case U.ASTC10x5Unorm:
          case U.ASTC10x5UnormSRGB:
          case U.ASTC10x6Unorm:
          case U.ASTC10x6UnormSRGB:
          case U.ASTC10x8Unorm:
          case U.ASTC10x8UnormSRGB:
          case U.ASTC10x10Unorm:
          case U.ASTC10x10UnormSRGB:
          case U.ASTC12x10Unorm:
          case U.ASTC12x10UnormSRGB:
          case U.ASTC12x12Unorm:
          case U.ASTC12x12UnormSRGB:
            return 4;
        }
        throw "Unknown format ".concat(t, "!");
      }, n.HasStencilAspect = function(t) {
        switch (t) {
          case U.Stencil8:
          case U.Depth32FloatStencil8:
          case U.Depth24PlusStencil8:
            return !0;
        }
        return !1;
      }, n.HasDepthAndStencilAspects = function(t) {
        switch (t) {
          case U.Depth32FloatStencil8:
          case U.Depth24PlusStencil8:
            return !0;
        }
        return !1;
      }, n.GetDepthFormatOnly = function(t) {
        switch (t) {
          case U.Depth16Unorm:
            return U.Depth16Unorm;
          case U.Depth24Plus:
          case U.Depth24PlusStencil8:
            return U.Depth24Plus;
          case U.Depth32Float:
          case U.Depth32FloatStencil8:
            return U.Depth32Float;
        }
        return t;
      }, n.GetSample = function(t) {
        return t > 1 ? 4 : 1;
      }, n.prototype.copyVideoToTexture = function(t, e, i, r, o) {
        var a, s, l, c;
        r === void 0 && (r = !1);
        var u = o === void 0, h = this._getVideoPipeline(i, r ? zc.InvertY : zc.DontInvertY), d = h[0], p = h[1];
        u && (o = this._device.createCommandEncoder({})), (s = (a = o).pushDebugGroup) === null || s === void 0 || s.call(a, "copy video to texture - invertY=".concat(r));
        var f = { colorAttachments: [{ view: e._hardwareTexture.underlyingResource.createView({ format: i, dimension: ei.E2d, mipLevelCount: 1, baseArrayLayer: 0, baseMipLevel: 0, arrayLayerCount: 1, aspect: no.All }), loadOp: ji.Load, storeOp: pr.Store }] }, m = o.beginRenderPass(f), g = { layout: p, entries: [{ binding: 0, resource: this._videoSampler }, { binding: 1, resource: this._device.importExternalTexture({ source: t.underlyingResource }) }] }, y = this._device.createBindGroup(g);
        m.setPipeline(d), m.setBindGroup(0, y), m.draw(4, 1, 0, 0), m.end(), (c = (l = o).popDebugGroup) === null || c === void 0 || c.call(l), u && (this._device.queue.submit([o.finish()]), o = null);
      }, n.prototype.invertYPreMultiplyAlpha = function(t, e, i, r, o, a, s, l, c, u, h, d, p, f, m) {
        var g, y, b, T, S, E;
        o === void 0 && (o = !1), a === void 0 && (a = !1), s === void 0 && (s = 0), l === void 0 && (l = 0), c === void 0 && (c = 1), u === void 0 && (u = 0), h === void 0 && (h = 0), d === void 0 && (d = 0), p === void 0 && (p = 0);
        var A, R = d !== 0, C = f === void 0, L = this._getPipeline(r, R ? ro.InvertYPremultiplyAlphaWithOfst : ro.InvertYPremultiplyAlpha, { invertY: o, premultiplyAlpha: a }), I = L[0], O = L[1];
        if (s = Math.max(s, 0), C && (f = this._device.createCommandEncoder({})), (y = (g = f).pushDebugGroup) === null || y === void 0 || y.call(g, "internal process texture - invertY=".concat(o, " premultiplyAlpha=").concat(a)), n._IsHardwareTexture(t) ? (A = t.underlyingResource, o && !a && c === 1 && s === 0 || (t = void 0)) : (A = t, t = void 0), A) {
          R && this._bufferManager.setRawData(this._ubCopyWithOfst, 0, new Float32Array([u, h, d, p]), 0, 16);
          var w = t, z = (b = w == null ? void 0 : w._copyInvertYTempTexture) !== null && b !== void 0 ? b : this.createTexture({ width: e, height: i, layers: 1 }, !1, !1, !1, !1, !1, r, 1, f, fi.CopySrc | fi.RenderAttachment | fi.TextureBinding, void 0, "TempTextureForCopyWithInvertY"), V = (T = w == null ? void 0 : w._copyInvertYRenderPassDescr) !== null && T !== void 0 ? T : { colorAttachments: [{ view: z.createView({ format: r, dimension: ei.E2d, baseMipLevel: 0, mipLevelCount: 1, arrayLayerCount: 1, baseArrayLayer: 0 }), loadOp: ji.Load, storeOp: pr.Store }] }, Y = f.beginRenderPass(V), ee = R ? w == null ? void 0 : w._copyInvertYBindGroupWithOfst : w == null ? void 0 : w._copyInvertYBindGroup;
          if (!ee) {
            var J = { layout: O, entries: [{ binding: 0, resource: A.createView({ format: r, dimension: ei.E2d, baseMipLevel: l, mipLevelCount: 1, arrayLayerCount: c, baseArrayLayer: s }) }] };
            R && J.entries.push({ binding: 1, resource: { buffer: this._ubCopyWithOfst } }), ee = this._device.createBindGroup(J);
          }
          Y.setPipeline(I), Y.setBindGroup(0, ee), Y.draw(4, 1, 0, 0), Y.end(), f.copyTextureToTexture({ texture: z }, { texture: A, mipLevel: l, origin: { x: 0, y: 0, z: s } }, { width: e, height: i, depthOrArrayLayers: 1 }), w ? (w._copyInvertYTempTexture = z, w._copyInvertYRenderPassDescr = V, R ? w._copyInvertYBindGroupWithOfst = ee : w._copyInvertYBindGroup = ee) : this._deferredReleaseTextures.push([z, null]), (E = (S = f).popDebugGroup) === null || E === void 0 || E.call(S), C && (this._device.queue.submit([f.finish()]), f = null);
        }
      }, n.prototype.copyWithInvertY = function(t, e, i, r) {
        var o, a, s, l, c = r === void 0, u = this._getPipeline(e, ro.InvertYPremultiplyAlpha, { invertY: !0, premultiplyAlpha: !1 }), h = u[0], d = u[1];
        c && (r = this._device.createCommandEncoder({})), (a = (o = r).pushDebugGroup) === null || a === void 0 || a.call(o, "internal copy texture with invertY");
        var p = r.beginRenderPass(i), f = this._device.createBindGroup({ layout: d, entries: [{ binding: 0, resource: t }] });
        p.setPipeline(h), p.setBindGroup(0, f), p.draw(4, 1, 0, 0), p.end(), (l = (s = r).popDebugGroup) === null || l === void 0 || l.call(s), c && (this._device.queue.submit([r.finish()]), r = null);
      }, n.prototype.createTexture = function(t, e, i, r, o, a, s, l, c, u, h, d) {
        e === void 0 && (e = !1), i === void 0 && (i = !1), r === void 0 && (r = !1), o === void 0 && (o = !1), a === void 0 && (a = !1), s === void 0 && (s = U.RGBA8Unorm), l === void 0 && (l = 1), u === void 0 && (u = -1), h === void 0 && (h = 0), l = n.GetSample(l);
        var p = t.layers || 1, f = { width: t.width, height: t.height, depthOrArrayLayers: p }, m = ba[s] ? fi.RenderAttachment : 0, g = n.IsCompressedFormat(s), y = e ? n.ComputeNumMipmapLevels(t.width, t.height) : 1, b = u >= 0 ? u : fi.CopySrc | fi.CopyDst | fi.TextureBinding;
        h |= e && !g ? fi.CopySrc | m : 0, g || a || (h |= m | fi.CopyDst);
        var T = this._device.createTexture({ label: "Texture".concat(a ? "3D" : "2D", "_").concat(d ? d + "_" : "").concat(f.width, "x").concat(f.height, "x").concat(f.depthOrArrayLayers, "_").concat(e ? "wmips" : "womips", "_").concat(s, "_samples").concat(l), size: f, dimension: a ? Ir.E3d : Ir.E2d, format: s, usage: b | h, sampleCount: l, mipLevelCount: y });
        return n.IsImageBitmap(t) && (this.updateTexture(t, T, t.width, t.height, p, s, 0, 0, r, o, 0, 0), e && i && this.generateMipmaps(T, s, y, 0, c)), T;
      }, n.prototype.createCubeTexture = function(t, e, i, r, o, a, s, l, c, u, h) {
        e === void 0 && (e = !1), i === void 0 && (i = !1), r === void 0 && (r = !1), o === void 0 && (o = !1), a === void 0 && (a = U.RGBA8Unorm), s === void 0 && (s = 1), c === void 0 && (c = -1), u === void 0 && (u = 0), s = n.GetSample(s);
        var d = n.IsImageBitmapArray(t) ? t[0].width : t.width, p = n.IsImageBitmapArray(t) ? t[0].height : t.height, f = ba[a] ? fi.RenderAttachment : 0, m = n.IsCompressedFormat(a), g = e ? n.ComputeNumMipmapLevels(d, p) : 1, y = c >= 0 ? c : fi.CopySrc | fi.CopyDst | fi.TextureBinding;
        u |= e && !m ? fi.CopySrc | f : 0, m || (u |= f | fi.CopyDst);
        var b = this._device.createTexture({ label: "TextureCube_".concat(h ? h + "_" : "").concat(d, "x").concat(p, "x6_").concat(e ? "wmips" : "womips", "_").concat(a, "_samples").concat(s), size: { width: d, height: p, depthOrArrayLayers: 6 }, dimension: Ir.E2d, format: a, usage: y | u, sampleCount: s, mipLevelCount: g });
        return n.IsImageBitmapArray(t) && (this.updateCubeTextures(t, b, d, p, a, r, o, 0, 0), e && i && this.generateCubeMipmaps(b, a, g, l)), b;
      }, n.prototype.generateCubeMipmaps = function(t, e, i, r) {
        var o, a, s, l, c = r === void 0;
        c && (r = this._device.createCommandEncoder({})), (a = (o = r).pushDebugGroup) === null || a === void 0 || a.call(o, "create cube mipmaps - ".concat(i, " levels"));
        for (var u = 0; u < 6; ++u)
          this.generateMipmaps(t, e, i, u, r);
        (l = (s = r).popDebugGroup) === null || l === void 0 || l.call(s), c && (this._device.queue.submit([r.finish()]), r = null);
      }, n.prototype.generateMipmaps = function(t, e, i, r, o) {
        var a, s, l, c, u, h, d, p;
        r === void 0 && (r = 0);
        var f, m = o === void 0, g = this._getPipeline(e), y = g[0], b = g[1];
        if (r = Math.max(r, 0), m && (o = this._device.createCommandEncoder({})), (s = (a = o).pushDebugGroup) === null || s === void 0 || s.call(a, "create mipmaps for face #".concat(r, " - ").concat(i, " levels")), n._IsHardwareTexture(t) ? (f = t.underlyingResource, t._mipmapGenRenderPassDescr = t._mipmapGenRenderPassDescr || [], t._mipmapGenBindGroup = t._mipmapGenBindGroup || []) : (f = t, t = void 0), f) {
          for (var T = t, S = 1; S < i; ++S) {
            var E = (c = (l = T == null ? void 0 : T._mipmapGenRenderPassDescr[r]) === null || l === void 0 ? void 0 : l[S - 1]) !== null && c !== void 0 ? c : { colorAttachments: [{ view: f.createView({ format: e, dimension: ei.E2d, baseMipLevel: S, mipLevelCount: 1, arrayLayerCount: 1, baseArrayLayer: r }), loadOp: ji.Load, storeOp: pr.Store }] };
            T && (T._mipmapGenRenderPassDescr[r] = T._mipmapGenRenderPassDescr[r] || [], T._mipmapGenRenderPassDescr[r][S - 1] = E);
            var A = o.beginRenderPass(E), R = (h = (u = T == null ? void 0 : T._mipmapGenBindGroup[r]) === null || u === void 0 ? void 0 : u[S - 1]) !== null && h !== void 0 ? h : this._device.createBindGroup({ layout: b, entries: [{ binding: 0, resource: this._mipmapSampler }, { binding: 1, resource: f.createView({ format: e, dimension: ei.E2d, baseMipLevel: S - 1, mipLevelCount: 1, arrayLayerCount: 1, baseArrayLayer: r }) }] });
            T && (T._mipmapGenBindGroup[r] = T._mipmapGenBindGroup[r] || [], T._mipmapGenBindGroup[r][S - 1] = R), A.setPipeline(y), A.setBindGroup(0, R), A.draw(4, 1, 0, 0), A.end();
          }
          (p = (d = o).popDebugGroup) === null || p === void 0 || p.call(d), m && (this._device.queue.submit([o.finish()]), o = null);
        }
      }, n.prototype.createGPUTextureForInternalTexture = function(t, e, i, r, o) {
        t._hardwareTexture || (t._hardwareTexture = new Zf()), e === void 0 && (e = t.width), i === void 0 && (i = t.height), r === void 0 && (r = t.depth);
        var a = t._hardwareTexture, s = ((o ?? 0) & _.TEXTURE_CREATIONFLAG_STORAGE) != 0;
        a.format = n.GetWebGPUTextureFormat(t.type, t.format, t._useSRGBBuffer), a.textureUsages = t._source === ut.RenderTarget || t.source === ut.MultiRenderTarget ? fi.TextureBinding | fi.CopySrc | fi.RenderAttachment : t._source === ut.DepthStencil ? fi.TextureBinding | fi.RenderAttachment : -1, a.textureAdditionalUsages = s ? fi.StorageBinding : 0;
        var l, c = t.generateMipMaps, u = r || 1;
        if (l = t._maxLodLevel !== null ? t._maxLodLevel : c ? n.ComputeNumMipmapLevels(e, i) : 1, t.isCube) {
          var h = this.createCubeTexture({ width: e, height: i }, t.generateMipMaps, t.generateMipMaps, t.invertY, !1, a.format, 1, this._commandEncoderForCreation, a.textureUsages, a.textureAdditionalUsages, t.label);
          a.set(h), a.createView({ format: n.GetDepthFormatOnly(a.format), dimension: ei.Cube, mipLevelCount: l, baseArrayLayer: 0, baseMipLevel: 0, arrayLayerCount: 6, aspect: n.HasDepthAndStencilAspects(a.format) ? no.DepthOnly : no.All }, s);
        } else
          h = this.createTexture({ width: e, height: i, layers: u }, t.generateMipMaps, t.generateMipMaps, t.invertY, !1, t.is3D, a.format, 1, this._commandEncoderForCreation, a.textureUsages, a.textureAdditionalUsages, t.label), a.set(h), a.createView({ format: n.GetDepthFormatOnly(a.format), dimension: t.is2DArray ? ei.E2dArray : t.is3D ? Ir.E3d : ei.E2d, mipLevelCount: l, baseArrayLayer: 0, baseMipLevel: 0, arrayLayerCount: t.is3D ? 1 : u, aspect: n.HasDepthAndStencilAspects(a.format) ? no.DepthOnly : no.All }, s);
        return t.width = t.baseWidth = e, t.height = t.baseHeight = i, t.depth = t.baseDepth = r, this.createMSAATexture(t, t.samples), a;
      }, n.prototype.createMSAATexture = function(t, e, i, r) {
        i === void 0 && (i = !0), r === void 0 && (r = -1);
        var o = t._hardwareTexture;
        if (i && (o == null || o.releaseMSAATexture()), o && !((e ?? 1) <= 1)) {
          var a = t.width, s = t.height, l = this.createTexture({ width: a, height: s, layers: 1 }, !1, !1, !1, !1, !1, o.format, e, this._commandEncoderForCreation, fi.RenderAttachment, 0, t.label ? "MSAA" + t.label : void 0);
          o.setMSAATexture(l, r);
        }
      }, n.prototype.updateCubeTextures = function(t, e, i, r, o, a, s, l, c) {
        a === void 0 && (a = !1), s === void 0 && (s = !1), l === void 0 && (l = 0), c === void 0 && (c = 0);
        for (var u = [0, 3, 1, 4, 2, 5], h = 0; h < u.length; ++h) {
          var d = t[u[h]];
          this.updateTexture(d, e, i, r, 1, o, h, 0, a, s, l, c);
        }
      }, n.prototype.updateTexture = function(t, e, i, r, o, a, s, l, c, u, h, d, p) {
        s === void 0 && (s = 0), l === void 0 && (l = 0), c === void 0 && (c = !1), u === void 0 && (u = !1), h === void 0 && (h = 0), d === void 0 && (d = 0);
        var f = n._IsInternalTexture(e) ? e._hardwareTexture.underlyingResource : e, m = n._GetBlockInformationFromFormat(a), g = n._IsInternalTexture(e) ? e._hardwareTexture : e, y = { texture: f, origin: { x: h, y: d, z: Math.max(s, 0) }, mipLevel: l, premultipliedAlpha: u }, b = { width: Math.ceil(i / m.width) * m.width, height: Math.ceil(r / m.height) * m.height, depthOrArrayLayers: o || 1 };
        if (t.byteLength !== void 0) {
          var T = Math.ceil(i / m.width) * m.length;
          if (256 * Math.ceil(T / 256) === T) {
            var S = this._device.createCommandEncoder({}), E = this._bufferManager.createRawBuffer(t.byteLength, $t.MapWrite | $t.CopySrc, !0, "TempBufferForUpdateTexture" + (f ? "_" + f.label : "")), A = E.getMappedRange();
            new Uint8Array(A).set(t), E.unmap(), S.copyBufferToTexture({ buffer: E, offset: 0, bytesPerRow: T, rowsPerImage: r }, y, b), this._device.queue.submit([S.finish()]), this._bufferManager.releaseBuffer(E);
          } else
            this._device.queue.writeTexture(y, t, { offset: 0, bytesPerRow: T, rowsPerImage: r }, b);
          if (c || u) {
            if (!n._IsInternalTexture(e))
              throw "updateTexture: Can't process the texture data because a GPUTexture was provided instead of an InternalTexture!";
            var R = h === 0 && d === 0 && i === e.width && r === e.height;
            this.invertYPreMultiplyAlpha(g, e.width, e.height, a, c, u, s, l, o || 1, h, d, R ? 0 : i, R ? 0 : r, void 0, p);
          }
        } else if (c)
          if (y.premultipliedAlpha = !1, n._IsInternalTexture(e) && h === 0 && d === 0 && i === e.width && r === e.height)
            this._device.queue.copyExternalImageToTexture({ source: t }, y, b), this.invertYPreMultiplyAlpha(g, i, r, a, c, u, s, l, o || 1, 0, 0, 0, 0, void 0, p);
          else {
            S = this._device.createCommandEncoder({});
            var C = this.createTexture({ width: i, height: r, layers: 1 }, !1, !1, !1, !1, !1, a, 1, S, fi.CopySrc | fi.TextureBinding, void 0, "TempTextureForUpdateTexture");
            this._deferredReleaseTextures.push([C, null]), b.depthOrArrayLayers = 1, this._device.queue.copyExternalImageToTexture({ source: t }, { texture: C }, b), b.depthOrArrayLayers = o || 1, this.invertYPreMultiplyAlpha(C, i, r, a, c, u, s, l, o || 1, 0, 0, 0, 0, S, p), S.copyTextureToTexture({ texture: C }, y, b), this._device.queue.submit([S.finish()]);
          }
        else
          this._device.queue.copyExternalImageToTexture({ source: t }, y, b);
      }, n.prototype.readPixels = function(t, e, i, r, o, a, s, l, c, u) {
        s === void 0 && (s = 0), l === void 0 && (l = 0), c === void 0 && (c = null), u === void 0 && (u = !1);
        var h = n._GetBlockInformationFromFormat(a), d = Math.ceil(r / h.width) * h.length, p = 256 * Math.ceil(d / 256), f = p * o, m = this._bufferManager.createRawBuffer(f, $t.MapRead | $t.CopyDst, void 0, "TempBufferForReadPixels" + (t.label ? "_" + t.label : "")), g = this._device.createCommandEncoder({});
        return g.copyTextureToBuffer({ texture: t, mipLevel: l, origin: { x: e, y: i, z: Math.max(s, 0) } }, { buffer: m, offset: 0, bytesPerRow: p }, { width: r, height: o, depthOrArrayLayers: 1 }), this._device.queue.submit([g.finish()]), this._bufferManager.readDataFromBuffer(m, f, r, o, d, p, n.GetTextureTypeFromFormat(a), 0, c, !0, u);
      }, n.prototype.releaseTexture = function(t) {
        if (n._IsInternalTexture(t)) {
          var e = t._hardwareTexture, i = t._irradianceTexture;
          this._deferredReleaseTextures.push([e, i]);
        } else
          this._deferredReleaseTextures.push([t, null]);
      }, n.prototype.destroyDeferredTextures = function() {
        for (var t = 0; t < this._deferredReleaseTextures.length; ++t) {
          var e = this._deferredReleaseTextures[t], i = e[0], r = e[1];
          i && (n._IsHardwareTexture(i) ? i.release() : i.destroy()), r == null || r.dispose();
        }
        this._deferredReleaseTextures.length = 0;
      }, n;
    }(), ay = function(n) {
      function t(e, i) {
        i === void 0 && (i = 0);
        var r = n.call(this) || this;
        return r.capacity = i, r._buffer = e, r;
      }
      return D(t, n), Object.defineProperty(t.prototype, "underlyingResource", { get: function() {
        return this._buffer;
      }, enumerable: !1, configurable: !0 }), t;
    }(wa), mD = function() {
      function n(t) {
        this._deferredReleaseBuffers = [], this._device = t;
      }
      return n._IsGPUBuffer = function(t) {
        return t.underlyingResource === void 0;
      }, n._FlagsToString = function(t, e) {
        e === void 0 && (e = "");
        for (var i = e, r = 0; r <= 9; ++r)
          t & 1 << r && (i && (i += "_"), i += $t[1 << r]);
        return i;
      }, n.prototype.createRawBuffer = function(t, e, i, r) {
        i === void 0 && (i = !1);
        var o = t.byteLength !== void 0 ? t.byteLength + 3 & -4 : t + 3 & -4, a = { label: n._FlagsToString(e, r ?? "Buffer") + "_size" + o, mappedAtCreation: i, size: o, usage: e };
        return this._device.createBuffer(a);
      }, n.prototype.createBuffer = function(t, e, i) {
        var r = t.byteLength !== void 0, o = this.createRawBuffer(t, e, void 0, i), a = new ay(o);
        return a.references = 1, a.capacity = r ? t.byteLength : t, r && this.setSubData(a, 0, t), a;
      }, n.prototype.setRawData = function(t, e, i, r, o) {
        this._device.queue.writeBuffer(t, e, i.buffer, r, o);
      }, n.prototype.setSubData = function(t, e, i, r, o) {
        r === void 0 && (r = 0), o === void 0 && (o = 0);
        var a = t.underlyingResource;
        o = o || i.byteLength, o = Math.min(o, t.capacity - e);
        var s = i.byteOffset + r, l = s + o, c = o + 3 & -4;
        if (c !== o) {
          var u = new Uint8Array(i.buffer.slice(s, l));
          (i = new Uint8Array(c)).set(u), r = 0, s = 0, l = c, o = c;
        }
        for (var h = 15728640, d = 0; l - (s + d) > h; )
          this._device.queue.writeBuffer(a, e + d, i.buffer, s + d, h), d += h;
        this._device.queue.writeBuffer(a, e + d, i.buffer, s + d, o - d);
      }, n.prototype._getHalfFloatAsFloatRGBAArrayBuffer = function(t, e, i) {
        i || (i = new Float32Array(t));
        for (var r = new Uint16Array(e); t--; )
          i[t] = io(r[t]);
        return i;
      }, n.prototype.readDataFromBuffer = function(t, e, i, r, o, a, s, l, c, u, h) {
        var d = this;
        s === void 0 && (s = _.TEXTURETYPE_UNSIGNED_BYTE), l === void 0 && (l = 0), c === void 0 && (c = null), u === void 0 && (u = !0), h === void 0 && (h = !1);
        var p = s === _.TEXTURETYPE_FLOAT ? 2 : s === _.TEXTURETYPE_HALF_FLOAT ? 1 : 0;
        return new Promise(function(f, m) {
          t.mapAsync(Ya.Read, l, e).then(function() {
            var g = t.getMappedRange(l, e), y = c;
            if (h)
              y = y === null ? qu(s, e, !0, g) : qu(s, y.buffer, void 0, g);
            else if (y === null)
              switch (p) {
                case 0:
                  (y = new Uint8Array(e)).set(new Uint8Array(g));
                  break;
                case 1:
                  y = d._getHalfFloatAsFloatRGBAArrayBuffer(e / 2, g);
                  break;
                case 2:
                  (y = new Float32Array(e / 4)).set(new Float32Array(g));
              }
            else
              switch (p) {
                case 0:
                  (y = new Uint8Array(y.buffer)).set(new Uint8Array(g));
                  break;
                case 1:
                  y = d._getHalfFloatAsFloatRGBAArrayBuffer(e / 2, g, c);
                  break;
                case 2:
                  (y = new Float32Array(y.buffer)).set(new Float32Array(g));
              }
            if (o !== a) {
              p !== 1 || h || (o *= 2, a *= 2);
              for (var b = new Uint8Array(y.buffer), T = o, S = 0, E = 1; E < r; ++E) {
                S = E * a;
                for (var A = 0; A < o; ++A)
                  b[T++] = b[S++];
              }
              y = p === 0 || h ? new Uint8Array(b.buffer, 0, T) : new Float32Array(b.buffer, 0, T / 4);
            }
            t.unmap(), u && d.releaseBuffer(t), f(y);
          }, function(g) {
            return m(g);
          });
        });
      }, n.prototype.releaseBuffer = function(t) {
        return n._IsGPUBuffer(t) ? (this._deferredReleaseBuffers.push(t), !0) : (t.references--, t.references === 0 && (this._deferredReleaseBuffers.push(t.underlyingResource), !0));
      }, n.prototype.destroyDeferredBuffers = function() {
        for (var t = 0; t < this._deferredReleaseBuffers.length; ++t)
          this._deferredReleaseBuffers[t].destroy();
        this._deferredReleaseBuffers.length = 0;
      }, n;
    }(), gD = [0, 0, 3, 7, 0, 2, 6, 2, 4, 1, 5, 3, 1], vD = [0, 64, 32, 96, 16, 80, 48, 112, 8], yD = [0, 128, 128, 0, 0, 0, 0, 128, 0, 0, 0, 0, 128], Jf = function() {
      function n(t) {
        this._samplers = {}, this._device = t, this.disabled = !1;
      }
      return n.GetSamplerHashCode = function(t) {
        var e, i, r, o = t._cachedAnisotropicFilteringLevel && t._cachedAnisotropicFilteringLevel > 1 ? 4 : 1;
        return gD[t.samplingMode] + vD[(t._comparisonFunction || 514) - 512 + 1] + yD[t.samplingMode] + (((e = t._cachedWrapU) !== null && e !== void 0 ? e : 1) << 8) + (((i = t._cachedWrapV) !== null && i !== void 0 ? i : 1) << 10) + (((r = t._cachedWrapR) !== null && r !== void 0 ? r : 1) << 12) + ((t.useMipMaps ? 1 : 0) << 14) + (o << 15);
      }, n._GetSamplerFilterDescriptor = function(t, e) {
        var i, r, o, a, s, l = t.useMipMaps;
        switch (t.samplingMode) {
          case _.TEXTURE_LINEAR_LINEAR_MIPNEAREST:
            i = Ct.Linear, r = Ct.Linear, o = Ct.Nearest, l || (a = s = 0);
            break;
          case _.TEXTURE_LINEAR_LINEAR_MIPLINEAR:
          case _.TEXTURE_TRILINEAR_SAMPLINGMODE:
            i = Ct.Linear, r = Ct.Linear, l ? o = Ct.Linear : (o = Ct.Nearest, a = s = 0);
            break;
          case _.TEXTURE_NEAREST_NEAREST_MIPLINEAR:
            i = Ct.Nearest, r = Ct.Nearest, l ? o = Ct.Linear : (o = Ct.Nearest, a = s = 0);
            break;
          case _.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
            i = Ct.Nearest, r = Ct.Nearest, o = Ct.Nearest, l || (a = s = 0);
            break;
          case _.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
            i = Ct.Nearest, r = Ct.Linear, o = Ct.Nearest, l || (a = s = 0);
            break;
          case _.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
            i = Ct.Nearest, r = Ct.Linear, l ? o = Ct.Linear : (o = Ct.Nearest, a = s = 0);
            break;
          case _.TEXTURE_NEAREST_LINEAR:
            i = Ct.Nearest, r = Ct.Linear, o = Ct.Nearest, a = s = 0;
            break;
          case _.TEXTURE_NEAREST_NEAREST:
          case _.TEXTURE_NEAREST_SAMPLINGMODE:
            i = Ct.Nearest, r = Ct.Nearest, o = Ct.Nearest, a = s = 0;
            break;
          case _.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
            i = Ct.Linear, r = Ct.Nearest, o = Ct.Nearest, l || (a = s = 0);
            break;
          case _.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
            i = Ct.Linear, r = Ct.Nearest, l ? o = Ct.Linear : (o = Ct.Nearest, a = s = 0);
            break;
          case _.TEXTURE_LINEAR_LINEAR:
          case _.TEXTURE_BILINEAR_SAMPLINGMODE:
            i = Ct.Linear, r = Ct.Linear, o = Ct.Nearest, a = s = 0;
            break;
          case _.TEXTURE_LINEAR_NEAREST:
            i = Ct.Linear, r = Ct.Nearest, o = Ct.Nearest, a = s = 0;
            break;
          default:
            i = Ct.Nearest, r = Ct.Nearest, o = Ct.Nearest, a = s = 0;
        }
        return e > 1 && (a !== 0 || s !== 0) && o !== Ct.Nearest ? { magFilter: Ct.Linear, minFilter: Ct.Linear, mipmapFilter: Ct.Linear, anisotropyEnabled: !0 } : { magFilter: i, minFilter: r, mipmapFilter: o, lodMinClamp: a, lodMaxClamp: s };
      }, n._GetWrappingMode = function(t) {
        switch (t) {
          case _.TEXTURE_WRAP_ADDRESSMODE:
            return As.Repeat;
          case _.TEXTURE_CLAMP_ADDRESSMODE:
            return As.ClampToEdge;
          case _.TEXTURE_MIRROR_ADDRESSMODE:
            return As.MirrorRepeat;
        }
        return As.Repeat;
      }, n._GetSamplerWrappingDescriptor = function(t) {
        return { addressModeU: this._GetWrappingMode(t._cachedWrapU), addressModeV: this._GetWrappingMode(t._cachedWrapV), addressModeW: this._GetWrappingMode(t._cachedWrapR) };
      }, n._GetSamplerDescriptor = function(t, e) {
        var i = t.useMipMaps && t._cachedAnisotropicFilteringLevel && t._cachedAnisotropicFilteringLevel > 1 ? 4 : 1, r = this._GetSamplerFilterDescriptor(t, i);
        return je(je(je({ label: e }, r), this._GetSamplerWrappingDescriptor(t)), { compare: t._comparisonFunction ? n.GetCompareFunction(t._comparisonFunction) : void 0, maxAnisotropy: r.anisotropyEnabled ? i : 1 });
      }, n.GetCompareFunction = function(t) {
        switch (t) {
          case _.ALWAYS:
            return an.Always;
          case _.EQUAL:
            return an.Equal;
          case _.GREATER:
            return an.Greater;
          case _.GEQUAL:
            return an.GreaterEqual;
          case _.LESS:
            return an.Less;
          case _.LEQUAL:
            return an.LessEqual;
          case _.NEVER:
            return an.Never;
          case _.NOTEQUAL:
            return an.NotEqual;
          default:
            return an.Less;
        }
      }, n.prototype.getSampler = function(t, e, i, r) {
        if (e === void 0 && (e = !1), i === void 0 && (i = 0), this.disabled)
          return this._device.createSampler(n._GetSamplerDescriptor(t, r));
        e ? i = 0 : i === 0 && (i = n.GetSamplerHashCode(t));
        var o = e ? void 0 : this._samplers[i];
        return o || (o = this._device.createSampler(n._GetSamplerDescriptor(t, r)), e || (this._samplers[i] = o)), o;
      }, n;
    }();
    (function(n) {
      n[n.StencilReadMask = 0] = "StencilReadMask", n[n.StencilWriteMask = 1] = "StencilWriteMask", n[n.DepthBias = 2] = "DepthBias", n[n.DepthBiasSlopeScale = 3] = "DepthBiasSlopeScale", n[n.DepthStencilState = 4] = "DepthStencilState", n[n.MRTAttachments1 = 5] = "MRTAttachments1", n[n.MRTAttachments2 = 6] = "MRTAttachments2", n[n.RasterizationState = 7] = "RasterizationState", n[n.ColorStates = 8] = "ColorStates", n[n.ShaderStage = 9] = "ShaderStage", n[n.TextureStage = 10] = "TextureStage", n[n.VertexState = 11] = "VertexState", n[n.NumStates = 12] = "NumStates";
    })(wi || (wi = {}));
    var $f = { 0: 1, 1: 2, 768: 3, 769: 4, 770: 5, 771: 6, 772: 7, 773: 8, 774: 9, 775: 10, 776: 11, 32769: 12, 32770: 13, 32771: 12, 32772: 13 }, Wc = { 0: 0, 7680: 1, 7681: 2, 7682: 3, 7683: 4, 5386: 5, 34055: 6, 34056: 7 }, bD = ((or = {})[P.PositionKind] = !0, or[P.NormalKind] = !0, or[P.TangentKind] = !0, or[P.UVKind] = !0, or[P.UV2Kind] = !0, or[P.UV3Kind] = !0, or[P.UV4Kind] = !0, or[P.UV5Kind] = !0, or[P.UV6Kind] = !0, or[P.ColorKind] = !0, or[P.ColorInstanceKind] = !0, or[P.MatricesIndicesKind] = !0, or[P.MatricesWeightsKind] = !0, or[P.MatricesIndicesExtraKind] = !0, or[P.MatricesWeightsExtraKind] = !0, or), sy = function() {
      function n(t, e) {
        this.mrtTextureCount = 0, this._device = t, this._useTextureStage = !0, this._states = new Array(30), this._statesLength = 0, this._stateDirtyLowestIndex = 0, this._emptyVertexBuffer = e, this._mrtFormats = [], this._parameter = { token: void 0, pipeline: null }, this.disabled = !1, this.vertexBuffers = [], this._kMaxVertexBufferStride = t.limits.maxVertexBufferArrayStride || 2048, this.reset();
      }
      return n._IsSignedType = function(t) {
        switch (t) {
          case P.BYTE:
          case P.SHORT:
          case P.INT:
          case P.FLOAT:
            return !0;
          case P.UNSIGNED_BYTE:
          case P.UNSIGNED_SHORT:
          case P.UNSIGNED_INT:
            return !1;
          default:
            throw new Error("Invalid type '".concat(t, "'"));
        }
      }, n.prototype.reset = function() {
        this._isDirty = !0, this.vertexBuffers.length = 0, this.setAlphaToCoverage(!1), this.resetDepthCullingState(), this.setClampDepth(!1), this.setDepthBias(0), this._webgpuColorFormat = [U.BGRA8Unorm], this.setColorFormat(U.BGRA8Unorm), this.setMRT([]), this.setAlphaBlendEnabled(!1), this.setAlphaBlendFactors([null, null, null, null], [null, null]), this.setWriteMask(15), this.setDepthStencilFormat(U.Depth24PlusStencil8), this.setStencilEnabled(!1), this.resetStencilState(), this.setBuffers(null, null, null), this._setTextureState(0);
      }, Object.defineProperty(n.prototype, "colorFormats", { get: function() {
        return this._mrtAttachments1 > 0 ? this._mrtFormats : this._webgpuColorFormat;
      }, enumerable: !1, configurable: !0 }), n.prototype.getRenderPipeline = function(t, e, i, r) {
        if (r === void 0 && (r = 0), i = kr.GetSample(i), this.disabled) {
          var o = n._GetTopology(t);
          return this._setVertexState(e), this._setTextureState(r), this._parameter.pipeline = this._createRenderPipeline(e, o, i), n.NumCacheMiss++, n._NumPipelineCreationCurrentFrame++, this._parameter.pipeline;
        }
        if (this._setShaderStage(e.uniqueId), this._setRasterizationState(t, i), this._setColorStates(), this._setDepthStencilState(), this._setVertexState(e), this._setTextureState(r), this.lastStateDirtyLowestIndex = this._stateDirtyLowestIndex, !this._isDirty && this._parameter.pipeline)
          return this._stateDirtyLowestIndex = this._statesLength, n.NumCacheHitWithoutHash++, this._parameter.pipeline;
        if (this._getRenderPipeline(this._parameter), this._isDirty = !1, this._stateDirtyLowestIndex = this._statesLength, this._parameter.pipeline)
          return n.NumCacheHitWithHash++, this._parameter.pipeline;
        var a = n._GetTopology(t);
        return this._parameter.pipeline = this._createRenderPipeline(e, a, i), this._setRenderPipeline(this._parameter), n.NumCacheMiss++, n._NumPipelineCreationCurrentFrame++, this._parameter.pipeline;
      }, n.prototype.endFrame = function() {
        n.NumPipelineCreationLastFrame = n._NumPipelineCreationCurrentFrame, n._NumPipelineCreationCurrentFrame = 0;
      }, n.prototype.setAlphaToCoverage = function(t) {
        this._alphaToCoverageEnabled = t;
      }, n.prototype.setFrontFace = function(t) {
        this._frontFace = t;
      }, n.prototype.setCullEnabled = function(t) {
        this._cullEnabled = t;
      }, n.prototype.setCullFace = function(t) {
        this._cullFace = t;
      }, n.prototype.setClampDepth = function(t) {
        this._clampDepth = t;
      }, n.prototype.resetDepthCullingState = function() {
        this.setDepthCullingState(!1, 2, 1, 0, 0, !0, !0, _.ALWAYS);
      }, n.prototype.setDepthCullingState = function(t, e, i, r, o, a, s, l) {
        this._depthWriteEnabled = s, this._depthTestEnabled = a, this._depthCompare = (l ?? _.ALWAYS) - 512, this._cullFace = i, this._cullEnabled = t, this._frontFace = e, this.setDepthBiasSlopeScale(r), this.setDepthBias(o);
      }, n.prototype.setDepthBias = function(t) {
        this._depthBias !== t && (this._depthBias = t, this._states[wi.DepthBias] = t, this._isDirty = !0, this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, wi.DepthBias));
      }, n.prototype.setDepthBiasSlopeScale = function(t) {
        this._depthBiasSlopeScale !== t && (this._depthBiasSlopeScale = t, this._states[wi.DepthBiasSlopeScale] = t, this._isDirty = !0, this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, wi.DepthBiasSlopeScale));
      }, n.prototype.setColorFormat = function(t) {
        this._webgpuColorFormat[0] = t, this._colorFormat = ba[t ?? ""];
      }, n.prototype.setMRTAttachments = function(t) {
        this.mrtAttachments = t;
        for (var e = 0, i = 0; i < t.length; ++i)
          t[i] !== 0 && (e += 1 << i);
        this._mrtEnabledMask !== e && (this._mrtEnabledMask = e, this._isDirty = !0, this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, wi.MRTAttachments1));
      }, n.prototype.setMRT = function(t, e) {
        var i, r;
        if ((e = e ?? t.length) > 10)
          throw "Can't handle more than 10 attachments for a MRT in cache render pipeline!";
        this.mrtTextureArray = t, this.mrtTextureCount = e, this._mrtEnabledMask = 65535;
        for (var o = [0, 0], a = 0, s = 0, l = 0, c = 0; c < e; ++c) {
          var u = t[c], h = u == null ? void 0 : u._hardwareTexture;
          this._mrtFormats[l] = (i = h == null ? void 0 : h.format) !== null && i !== void 0 ? i : this._webgpuColorFormat[0], o[a] += ba[(r = this._mrtFormats[l]) !== null && r !== void 0 ? r : ""] << s, l++, (s += 6) >= 32 && (s = 0, a++);
        }
        this._mrtFormats.length = l, this._mrtAttachments1 === o[0] && this._mrtAttachments2 === o[1] || (this._mrtAttachments1 = o[0], this._mrtAttachments2 = o[1], this._states[wi.MRTAttachments1] = o[0], this._states[wi.MRTAttachments2] = o[1], this._isDirty = !0, this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, wi.MRTAttachments1));
      }, n.prototype.setAlphaBlendEnabled = function(t) {
        this._alphaBlendEnabled = t;
      }, n.prototype.setAlphaBlendFactors = function(t, e) {
        this._alphaBlendFuncParams = t, this._alphaBlendEqParams = e;
      }, n.prototype.setWriteMask = function(t) {
        this._writeMask = t;
      }, n.prototype.setDepthStencilFormat = function(t) {
        this._webgpuDepthStencilFormat = t, this._depthStencilFormat = t === void 0 ? 0 : ba[t];
      }, n.prototype.setDepthTestEnabled = function(t) {
        this._depthTestEnabled = t;
      }, n.prototype.setDepthWriteEnabled = function(t) {
        this._depthWriteEnabled = t;
      }, n.prototype.setDepthCompare = function(t) {
        this._depthCompare = (t ?? _.ALWAYS) - 512;
      }, n.prototype.setStencilEnabled = function(t) {
        this._stencilEnabled = t;
      }, n.prototype.setStencilCompare = function(t) {
        this._stencilFrontCompare = (t ?? _.ALWAYS) - 512;
      }, n.prototype.setStencilDepthFailOp = function(t) {
        this._stencilFrontDepthFailOp = t === null ? 1 : Wc[t];
      }, n.prototype.setStencilPassOp = function(t) {
        this._stencilFrontPassOp = t === null ? 2 : Wc[t];
      }, n.prototype.setStencilFailOp = function(t) {
        this._stencilFrontFailOp = t === null ? 1 : Wc[t];
      }, n.prototype.setStencilReadMask = function(t) {
        this._stencilReadMask !== t && (this._stencilReadMask = t, this._states[wi.StencilReadMask] = t, this._isDirty = !0, this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, wi.StencilReadMask));
      }, n.prototype.setStencilWriteMask = function(t) {
        this._stencilWriteMask !== t && (this._stencilWriteMask = t, this._states[wi.StencilWriteMask] = t, this._isDirty = !0, this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, wi.StencilWriteMask));
      }, n.prototype.resetStencilState = function() {
        this.setStencilState(!1, _.ALWAYS, _.KEEP, _.REPLACE, _.KEEP, 255, 255);
      }, n.prototype.setStencilState = function(t, e, i, r, o, a, s) {
        this._stencilEnabled = t, this._stencilFrontCompare = (e ?? _.ALWAYS) - 512, this._stencilFrontDepthFailOp = i === null ? 1 : Wc[i], this._stencilFrontPassOp = r === null ? 2 : Wc[r], this._stencilFrontFailOp = o === null ? 1 : Wc[o], this.setStencilReadMask(a), this.setStencilWriteMask(s);
      }, n.prototype.setBuffers = function(t, e, i) {
        this._vertexBuffers = t, this._overrideVertexBuffers = i, this._indexBuffer = e;
      }, n._GetTopology = function(t) {
        switch (t) {
          case _.MATERIAL_TriangleFillMode:
            return rr.TriangleList;
          case _.MATERIAL_PointFillMode:
            return rr.PointList;
          case _.MATERIAL_WireFrameFillMode:
            return rr.LineList;
          case _.MATERIAL_PointListDrawMode:
            return rr.PointList;
          case _.MATERIAL_LineListDrawMode:
            return rr.LineList;
          case _.MATERIAL_LineLoopDrawMode:
            throw "LineLoop is an unsupported fillmode in WebGPU";
          case _.MATERIAL_LineStripDrawMode:
            return rr.LineStrip;
          case _.MATERIAL_TriangleStripDrawMode:
            return rr.TriangleStrip;
          case _.MATERIAL_TriangleFanDrawMode:
            throw "TriangleFan is an unsupported fillmode in WebGPU";
          default:
            return rr.TriangleList;
        }
      }, n._GetAphaBlendOperation = function(t) {
        switch (t) {
          case _.GL_ALPHA_EQUATION_ADD:
            return va.Add;
          case _.GL_ALPHA_EQUATION_SUBTRACT:
            return va.Subtract;
          case _.GL_ALPHA_EQUATION_REVERSE_SUBTRACT:
            return va.ReverseSubtract;
          case _.GL_ALPHA_EQUATION_MIN:
            return va.Min;
          case _.GL_ALPHA_EQUATION_MAX:
            return va.Max;
          default:
            return va.Add;
        }
      }, n._GetAphaBlendFactor = function(t) {
        switch (t) {
          case 0:
            return An.Zero;
          case 1:
            return An.One;
          case _.GL_ALPHA_FUNCTION_SRC:
            return An.Src;
          case _.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR:
            return An.OneMinusSrc;
          case _.GL_ALPHA_FUNCTION_SRC_ALPHA:
            return An.SrcAlpha;
          case _.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA:
            return An.OneMinusSrcAlpha;
          case _.GL_ALPHA_FUNCTION_DST_ALPHA:
            return An.DstAlpha;
          case _.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA:
            return An.OneMinusDstAlpha;
          case _.GL_ALPHA_FUNCTION_DST_COLOR:
            return An.Dst;
          case _.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR:
            return An.OneMinusDst;
          case _.GL_ALPHA_FUNCTION_SRC_ALPHA_SATURATED:
            return An.SrcAlphaSaturated;
          case _.GL_ALPHA_FUNCTION_CONSTANT_COLOR:
            return An.Constant;
          case _.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR:
            return An.OneMinusConstant;
          case _.GL_ALPHA_FUNCTION_CONSTANT_ALPHA:
            return An.Constant;
          case _.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA:
            return An.OneMinusConstant;
          default:
            return An.One;
        }
      }, n._GetCompareFunction = function(t) {
        switch (t) {
          case 0:
            return an.Never;
          case 1:
            return an.Less;
          case 2:
            return an.Equal;
          case 3:
            return an.LessEqual;
          case 4:
            return an.Greater;
          case 5:
            return an.NotEqual;
          case 6:
            return an.GreaterEqual;
          case 7:
            return an.Always;
        }
        return an.Never;
      }, n._GetStencilOpFunction = function(t) {
        switch (t) {
          case 0:
            return Vr.Zero;
          case 1:
            return Vr.Keep;
          case 2:
            return Vr.Replace;
          case 3:
            return Vr.IncrementClamp;
          case 4:
            return Vr.DecrementClamp;
          case 5:
            return Vr.Invert;
          case 6:
            return Vr.IncrementWrap;
          case 7:
            return Vr.DecrementWrap;
        }
        return Vr.Keep;
      }, n._GetVertexInputDescriptorFormat = function(t) {
        var e = t.type, i = t.normalized, r = t.getSize();
        switch (e) {
          case P.BYTE:
            switch (r) {
              case 1:
              case 2:
                return i ? bi.Snorm8x2 : bi.Sint8x2;
              case 3:
              case 4:
                return i ? bi.Snorm8x4 : bi.Sint8x4;
            }
            break;
          case P.UNSIGNED_BYTE:
            switch (r) {
              case 1:
              case 2:
                return i ? bi.Unorm8x2 : bi.Uint8x2;
              case 3:
              case 4:
                return i ? bi.Unorm8x4 : bi.Uint8x4;
            }
            break;
          case P.SHORT:
            switch (r) {
              case 1:
              case 2:
                return i ? bi.Snorm16x2 : bi.Sint16x2;
              case 3:
              case 4:
                return i ? bi.Snorm16x4 : bi.Sint16x4;
            }
            break;
          case P.UNSIGNED_SHORT:
            switch (r) {
              case 1:
              case 2:
                return i ? bi.Unorm16x2 : bi.Uint16x2;
              case 3:
              case 4:
                return i ? bi.Unorm16x4 : bi.Uint16x4;
            }
            break;
          case P.INT:
            switch (r) {
              case 1:
                return bi.Sint32;
              case 2:
                return bi.Sint32x2;
              case 3:
                return bi.Sint32x3;
              case 4:
                return bi.Sint32x4;
            }
            break;
          case P.UNSIGNED_INT:
            switch (r) {
              case 1:
                return bi.Uint32;
              case 2:
                return bi.Uint32x2;
              case 3:
                return bi.Uint32x3;
              case 4:
                return bi.Uint32x4;
            }
            break;
          case P.FLOAT:
            switch (r) {
              case 1:
                return bi.Float32;
              case 2:
                return bi.Float32x2;
              case 3:
                return bi.Float32x3;
              case 4:
                return bi.Float32x4;
            }
        }
        throw new Error("Invalid Format '".concat(t.getKind(), "' - type=").concat(e, ", normalized=").concat(i, ", size=").concat(r));
      }, n.prototype._getAphaBlendState = function() {
        return this._alphaBlendEnabled ? { srcFactor: n._GetAphaBlendFactor(this._alphaBlendFuncParams[2]), dstFactor: n._GetAphaBlendFactor(this._alphaBlendFuncParams[3]), operation: n._GetAphaBlendOperation(this._alphaBlendEqParams[1]) } : null;
      }, n.prototype._getColorBlendState = function() {
        return this._alphaBlendEnabled ? { srcFactor: n._GetAphaBlendFactor(this._alphaBlendFuncParams[0]), dstFactor: n._GetAphaBlendFactor(this._alphaBlendFuncParams[1]), operation: n._GetAphaBlendOperation(this._alphaBlendEqParams[0]) } : null;
      }, n.prototype._setShaderStage = function(t) {
        this._shaderId !== t && (this._shaderId = t, this._states[wi.ShaderStage] = t, this._isDirty = !0, this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, wi.ShaderStage));
      }, n.prototype._setRasterizationState = function(t, e) {
        var i = this._frontFace - 1 + ((this._cullEnabled ? this._cullFace : 0) << 1) + ((this._clampDepth ? 1 : 0) << 3) + ((this._alphaToCoverageEnabled ? 1 : 0) << 4) + (t << 5) + (e << 8);
        this._rasterizationState !== i && (this._rasterizationState = i, this._states[wi.RasterizationState] = this._rasterizationState, this._isDirty = !0, this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, wi.RasterizationState));
      }, n.prototype._setColorStates = function() {
        var t = ((this._writeMask ? 1 : 0) << 22) + (this._colorFormat << 23) + ((this._depthWriteEnabled ? 1 : 0) << 29);
        this._alphaBlendEnabled && (t += ((this._alphaBlendFuncParams[0] === null ? 2 : $f[this._alphaBlendFuncParams[0]]) << 0) + ((this._alphaBlendFuncParams[1] === null ? 2 : $f[this._alphaBlendFuncParams[1]]) << 4) + ((this._alphaBlendFuncParams[2] === null ? 2 : $f[this._alphaBlendFuncParams[2]]) << 8) + ((this._alphaBlendFuncParams[3] === null ? 2 : $f[this._alphaBlendFuncParams[3]]) << 12) + ((this._alphaBlendEqParams[0] === null ? 1 : this._alphaBlendEqParams[0] - 32773) << 16) + ((this._alphaBlendEqParams[1] === null ? 1 : this._alphaBlendEqParams[1] - 32773) << 19)), t !== this._colorStates && (this._colorStates = t, this._states[wi.ColorStates] = this._colorStates, this._isDirty = !0, this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, wi.ColorStates));
      }, n.prototype._setDepthStencilState = function() {
        var t = this._stencilEnabled ? this._stencilFrontCompare + (this._stencilFrontDepthFailOp << 3) + (this._stencilFrontPassOp << 6) + (this._stencilFrontFailOp << 9) : 591, e = this._depthStencilFormat + ((this._depthTestEnabled ? this._depthCompare : 7) << 6) + (t << 10);
        this._depthStencilState !== e && (this._depthStencilState = e, this._states[wi.DepthStencilState] = this._depthStencilState, this._isDirty = !0, this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, wi.DepthStencilState));
      }, n.prototype._setVertexState = function(t) {
        for (var e, i, r, o = this._statesLength, a = wi.VertexState, s = t._pipelineContext, l = s.shaderProcessingContext.attributeNamesFromEffect, c = s.shaderProcessingContext.attributeLocationsFromEffect, u = 0, h = 0; h < l.length; h++) {
          var d = c[h], p = (e = this._overrideVertexBuffers && this._overrideVertexBuffers[l[h]]) !== null && e !== void 0 ? e : this._vertexBuffers[l[h]];
          p || (p = this._emptyVertexBuffer);
          var f = (i = p.effectiveBuffer) === null || i === void 0 ? void 0 : i.underlyingResource;
          if (p._validOffsetRange === void 0) {
            var m = p.effectiveByteOffset, g = p.getSize(!0), y = p.effectiveByteStride;
            p._validOffsetRange = m + g <= this._kMaxVertexBufferStride && y === 0 || y !== 0 && m + g <= y;
          }
          r && r === f && p._validOffsetRange || (this.vertexBuffers[u++] = p, r = p._validOffsetRange ? f : null);
          var b = p.hashCode + (d << 7);
          this._isDirty = this._isDirty || this._states[a] !== b, this._states[a++] = b;
        }
        this.vertexBuffers.length = u, this._statesLength = a, this._isDirty = this._isDirty || a !== o, this._isDirty && (this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, wi.VertexState));
      }, n.prototype._setTextureState = function(t) {
        this._textureState !== t && (this._textureState = t, this._states[wi.TextureStage] = this._textureState, this._isDirty = !0, this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, wi.TextureStage));
      }, n.prototype._createPipelineLayout = function(t) {
        if (this._useTextureStage)
          return this._createPipelineLayoutWithTextureStage(t);
        for (var e = [], i = t.shaderProcessingContext.bindGroupLayoutEntries, r = 0; r < i.length; r++) {
          var o = i[r];
          e[r] = this._device.createBindGroupLayout({ entries: o });
        }
        return t.bindGroupLayouts[0] = e, this._device.createPipelineLayout({ bindGroupLayouts: e });
      }, n.prototype._createPipelineLayoutWithTextureStage = function(t) {
        for (var e, i = t.shaderProcessingContext, r = i.bindGroupLayoutEntries, o = 1, a = 0; a < r.length; a++)
          for (var s = r[a], l = 0; l < s.length; l++) {
            var c = r[a][l];
            if (c.texture) {
              var u = i.bindGroupLayoutEntryInfo[a][c.binding].name, h = i.availableTextures[u], d = h.autoBindSampler ? i.availableSamplers[u + Rn.AutoSamplerSuffix] : null, p = h.sampleType, f = (e = d == null ? void 0 : d.type) !== null && e !== void 0 ? e : ga.Filtering;
              if (this._textureState & o && p !== nr.Depth && (h.autoBindSampler && (f = ga.NonFiltering), p = nr.UnfilterableFloat), c.texture.sampleType = p, d) {
                var m = i.bindGroupLayoutEntryInfo[d.binding.groupIndex][d.binding.bindingIndex].index;
                r[d.binding.groupIndex][m].sampler.type = f;
              }
              o <<= 1;
            }
          }
        var g = [];
        for (a = 0; a < r.length; ++a)
          g[a] = this._device.createBindGroupLayout({ entries: r[a] });
        return t.bindGroupLayouts[this._textureState] = g, this._device.createPipelineLayout({ bindGroupLayouts: g });
      }, n.prototype._getVertexInputDescriptor = function(t) {
        for (var e, i, r, o, a = [], s = t._pipelineContext, l = s.shaderProcessingContext.attributeNamesFromEffect, c = s.shaderProcessingContext.attributeLocationsFromEffect, u = 0; u < l.length; u++) {
          var h = c[u], d = (e = this._overrideVertexBuffers && this._overrideVertexBuffers[l[u]]) !== null && e !== void 0 ? e : this._vertexBuffers[l[u]];
          d || (d = this._emptyVertexBuffer);
          var p = (i = d.effectiveBuffer) === null || i === void 0 ? void 0 : i.underlyingResource, f = d.effectiveByteOffset, m = !d._validOffsetRange;
          if (!r || !o || r !== p || m) {
            var g = { arrayStride: d.effectiveByteStride, stepMode: d.getIsInstanced() ? Vc.Instance : Vc.Vertex, attributes: [] };
            a.push(g), o = g.attributes, m && (f = 0, p = null);
          }
          o.push({ shaderLocation: h, offset: f, format: n._GetVertexInputDescriptorFormat(d) }), r = p;
        }
        return a;
      }, n.prototype._processNonFloatVertexBuffers = function(t, e) {
        var i = t.engine._getShaderProcessor(t.shaderProcessingContext.shaderLanguage), r = !1;
        for (var o in this._vertexBuffers) {
          var a = this._vertexBuffers[o];
          if (a && bD[o]) {
            var s = a.normalized ? P.FLOAT : a.type, l = t.vertexBufferKindToType[o];
            (s !== P.FLOAT && l === void 0 || l !== void 0 && l !== s) && (r = !0, t.vertexBufferKindToType[o] = s, s !== P.FLOAT && (i.vertexBufferKindToNumberOfComponents[o] = P.DeduceStride(o), n._IsSignedType(s) && (i.vertexBufferKindToNumberOfComponents[o] *= -1)));
          }
        }
        r && e._processShaderCode(i, !0);
      }, n.prototype._createRenderPipeline = function(t, e, i) {
        var r, o, a, s = t._pipelineContext, l = this._getVertexInputDescriptor(t), c = this._createPipelineLayout(s), u = [], h = this._getAphaBlendState(), d = this._getColorBlendState();
        if (this._processNonFloatVertexBuffers(s, t), this._mrtAttachments1 > 0)
          for (var p = 0; p < this._mrtFormats.length; ++p) {
            var f = this._mrtFormats[p];
            if (f) {
              var m = { format: f, writeMask: this._mrtEnabledMask & 1 << p ? this._writeMask : 0 };
              h && d && (m.blend = { alpha: h, color: d }), u.push(m);
            } else
              u.push(null);
          }
        else
          this._webgpuColorFormat[0] ? (m = { format: this._webgpuColorFormat[0], writeMask: this._writeMask }, h && d && (m.blend = { alpha: h, color: d }), u.push(m)) : u.push(null);
        var g = { compare: n._GetCompareFunction(this._stencilEnabled ? this._stencilFrontCompare : 7), depthFailOp: n._GetStencilOpFunction(this._stencilEnabled ? this._stencilFrontDepthFailOp : 1), failOp: n._GetStencilOpFunction(this._stencilEnabled ? this._stencilFrontFailOp : 1), passOp: n._GetStencilOpFunction(this._stencilEnabled ? this._stencilFrontPassOp : 1) }, y = void 0;
        e !== rr.LineStrip && e !== rr.TriangleStrip || (y = !this._indexBuffer || this._indexBuffer.is32Bits ? ya.Uint32 : ya.Uint16);
        var b = !!this._webgpuDepthStencilFormat && kr.HasStencilAspect(this._webgpuDepthStencilFormat);
        return this._device.createRenderPipeline({ label: "RenderPipeline_".concat((o = (r = u[0]) === null || r === void 0 ? void 0 : r.format) !== null && o !== void 0 ? o : "nooutput", "_").concat((a = this._webgpuDepthStencilFormat) !== null && a !== void 0 ? a : "nodepth", "_samples").concat(i, "_textureState").concat(this._textureState), layout: c, vertex: { module: s.stages.vertexStage.module, entryPoint: s.stages.vertexStage.entryPoint, buffers: l }, primitive: { topology: e, stripIndexFormat: y, frontFace: this._frontFace === 1 ? Uc.CCW : Uc.CW, cullMode: this._cullEnabled ? this._cullFace === 2 ? Al.Front : Al.Back : Al.None }, fragment: s.stages.fragmentStage ? { module: s.stages.fragmentStage.module, entryPoint: s.stages.fragmentStage.entryPoint, targets: u } : void 0, multisample: { count: i }, depthStencil: this._webgpuDepthStencilFormat === void 0 ? void 0 : { depthWriteEnabled: this._depthWriteEnabled, depthCompare: this._depthTestEnabled ? n._GetCompareFunction(this._depthCompare) : an.Always, format: this._webgpuDepthStencilFormat, stencilFront: this._stencilEnabled && b ? g : void 0, stencilBack: this._stencilEnabled && b ? g : void 0, stencilReadMask: this._stencilEnabled && b ? this._stencilReadMask : void 0, stencilWriteMask: this._stencilEnabled && b ? this._stencilWriteMask : void 0, depthBias: this._depthBias, depthBiasClamp: this._depthBiasClamp, depthBiasSlopeScale: this._depthBiasSlopeScale } });
      }, n.NumCacheHitWithoutHash = 0, n.NumCacheHitWithHash = 0, n.NumCacheMiss = 0, n.NumPipelineCreationLastFrame = 0, n._NumPipelineCreationCurrentFrame = 0, n;
    }(), AC = function() {
      function n() {
        this.values = {};
      }
      return n.prototype.count = function() {
        var t = 0, e = this.pipeline ? 1 : 0;
        for (var i in this.values) {
          var r = this.values[i].count();
          t += r[0], e += r[1], t++;
        }
        return [t, e];
      }, n;
    }(), e_ = function(n) {
      function t(e, i) {
        var r = n.call(this, e, i) || this;
        return r._nodeStack = [], r._nodeStack[0] = t._Cache, r;
      }
      return D(t, n), t.GetNodeCounts = function() {
        var e = t._Cache.count();
        return { nodeCount: e[0], pipelineCount: e[1] };
      }, t._GetPipelines = function(e, i, r, o) {
        if (e.pipeline) {
          var a = r.slice();
          a.length = o, i.push(a);
        }
        for (var s in e.values) {
          var l = e.values[s];
          r[o] = parseInt(s), t._GetPipelines(l, i, r, o + 1);
        }
      }, t.GetPipelines = function() {
        var e = [];
        return t._GetPipelines(t._Cache, e, [], 0), e;
      }, t.prototype._getRenderPipeline = function(e) {
        for (var i = this._nodeStack[this._stateDirtyLowestIndex], r = this._stateDirtyLowestIndex; r < this._statesLength; ++r) {
          var o = i.values[this._states[r]];
          o || (o = new AC(), i.values[this._states[r]] = o), i = o, this._nodeStack[r + 1] = i;
        }
        e.token = i, e.pipeline = i.pipeline;
      }, t.prototype._setRenderPipeline = function(e) {
        e.token.pipeline = e.pipeline;
      }, t._Cache = new AC(), t;
    }(sy), TD = function(n) {
      function t(e) {
        var i = n.call(this, !1) || this;
        return i._cache = e, i.reset(), i;
      }
      return D(t, n), Object.defineProperty(t.prototype, "func", { get: function() {
        return this._func;
      }, set: function(e) {
        this._func !== e && (this._func = e, this._cache.setStencilCompare(e));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "funcMask", { get: function() {
        return this._funcMask;
      }, set: function(e) {
        this._funcMask !== e && (this._funcMask = e, this._cache.setStencilReadMask(e));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "opStencilFail", { get: function() {
        return this._opStencilFail;
      }, set: function(e) {
        this._opStencilFail !== e && (this._opStencilFail = e, this._cache.setStencilFailOp(e));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "opDepthFail", { get: function() {
        return this._opDepthFail;
      }, set: function(e) {
        this._opDepthFail !== e && (this._opDepthFail = e, this._cache.setStencilDepthFailOp(e));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "opStencilDepthPass", { get: function() {
        return this._opStencilDepthPass;
      }, set: function(e) {
        this._opStencilDepthPass !== e && (this._opStencilDepthPass = e, this._cache.setStencilPassOp(e));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "mask", { get: function() {
        return this._mask;
      }, set: function(e) {
        this._mask !== e && (this._mask = e, this._cache.setStencilWriteMask(e));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "enabled", { get: function() {
        return this._enabled;
      }, set: function(e) {
        this._enabled !== e && (this._enabled = e, this._cache.setStencilEnabled(e));
      }, enumerable: !1, configurable: !0 }), t.prototype.reset = function() {
        n.prototype.reset.call(this), this._cache.resetStencilState();
      }, t.prototype.apply = function() {
        var e, i = (e = this.stencilMaterial) === null || e === void 0 ? void 0 : e.enabled;
        this.enabled = i ? this.stencilMaterial.enabled : this.stencilGlobal.enabled, this.enabled && (this.func = i ? this.stencilMaterial.func : this.stencilGlobal.func, this.funcRef = i ? this.stencilMaterial.funcRef : this.stencilGlobal.funcRef, this.funcMask = i ? this.stencilMaterial.funcMask : this.stencilGlobal.funcMask, this.opStencilFail = i ? this.stencilMaterial.opStencilFail : this.stencilGlobal.opStencilFail, this.opDepthFail = i ? this.stencilMaterial.opDepthFail : this.stencilGlobal.opDepthFail, this.opStencilDepthPass = i ? this.stencilMaterial.opStencilDepthPass : this.stencilGlobal.opStencilDepthPass, this.mask = i ? this.stencilMaterial.mask : this.stencilGlobal.mask);
      }, t;
    }(ap), ED = function(n) {
      function t(e) {
        var i = n.call(this, !1) || this;
        return i._cache = e, i.reset(), i;
      }
      return D(t, n), Object.defineProperty(t.prototype, "zOffset", { get: function() {
        return this._zOffset;
      }, set: function(e) {
        this._zOffset !== e && (this._zOffset = e, this._isZOffsetDirty = !0, this._cache.setDepthBiasSlopeScale(e));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "zOffsetUnits", { get: function() {
        return this._zOffsetUnits;
      }, set: function(e) {
        this._zOffsetUnits !== e && (this._zOffsetUnits = e, this._isZOffsetDirty = !0, this._cache.setDepthBias(e));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cullFace", { get: function() {
        return this._cullFace;
      }, set: function(e) {
        this._cullFace !== e && (this._cullFace = e, this._isCullFaceDirty = !0, this._cache.setCullFace(e ?? 1));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cull", { get: function() {
        return this._cull;
      }, set: function(e) {
        this._cull !== e && (this._cull = e, this._isCullDirty = !0, this._cache.setCullEnabled(!!e));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "depthFunc", { get: function() {
        return this._depthFunc;
      }, set: function(e) {
        this._depthFunc !== e && (this._depthFunc = e, this._isDepthFuncDirty = !0, this._cache.setDepthCompare(e));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "depthMask", { get: function() {
        return this._depthMask;
      }, set: function(e) {
        this._depthMask !== e && (this._depthMask = e, this._isDepthMaskDirty = !0, this._cache.setDepthWriteEnabled(e));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "depthTest", { get: function() {
        return this._depthTest;
      }, set: function(e) {
        this._depthTest !== e && (this._depthTest = e, this._isDepthTestDirty = !0, this._cache.setDepthTestEnabled(e));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "frontFace", { get: function() {
        return this._frontFace;
      }, set: function(e) {
        this._frontFace !== e && (this._frontFace = e, this._isFrontFaceDirty = !0, this._cache.setFrontFace(e ?? 2));
      }, enumerable: !1, configurable: !0 }), t.prototype.reset = function() {
        n.prototype.reset.call(this), this._cache.resetDepthCullingState();
      }, t.prototype.apply = function() {
      }, t;
    }(np), t_ = function() {
      function n(t) {
        this.useMipMaps = !1, this.type = _.TEXTURETYPE_UNDEFINED, this.format = _.TEXTUREFORMAT_UNDEFINED, this._video = t, this.uniqueId = Ut._Counter++;
      }
      return n.IsExternalTexture = function(t) {
        return t.underlyingResource !== void 0;
      }, n.prototype.getClassName = function() {
        return "ExternalTexture";
      }, Object.defineProperty(n.prototype, "underlyingResource", { get: function() {
        return this._video;
      }, enumerable: !1, configurable: !0 }), n.prototype.isReady = function() {
        return this._video.readyState >= this._video.HAVE_CURRENT_DATA;
      }, n.prototype.dispose = function() {
      }, n;
    }(), SD = function() {
      function n() {
        this.uniqueId = n._Counter++, this.updateId = 0, this.textureState = 0, this.reset();
      }
      return Object.defineProperty(n.prototype, "forceBindGroupCreation", { get: function() {
        return this._numExternalTextures > 0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "hasFloatOrDepthTextures", { get: function() {
        return this._numFloatOrDepthTextures > 0;
      }, enumerable: !1, configurable: !0 }), n.prototype.reset = function() {
        this.samplers = {}, this.textures = {}, this.isDirty = !0, this._numFloatOrDepthTextures = 0, this._numExternalTextures = 0;
      }, n.prototype.setSampler = function(t, e) {
        var i = this.samplers[t], r = -1;
        i ? r = i.hashCode : this.samplers[t] = i = { sampler: e, hashCode: 0 }, i.sampler = e, i.hashCode = e ? Jf.GetSamplerHashCode(e) : 0;
        var o = r !== i.hashCode;
        o && this.updateId++, this.isDirty || (this.isDirty = o);
      }, n.prototype.setTexture = function(t, e) {
        var i, r, o, a = this.textures[t], s = -1;
        a ? s = (r = (i = a.texture) === null || i === void 0 ? void 0 : i.uniqueId) !== null && r !== void 0 ? r : -1 : this.textures[t] = a = { texture: e, isFloatOrDepthTexture: !1, isExternalTexture: !1 }, a.isExternalTexture && this._numExternalTextures--, a.isFloatOrDepthTexture && this._numFloatOrDepthTextures--, e ? (a.isFloatOrDepthTexture = e.type === _.TEXTURETYPE_FLOAT || e.format >= _.TEXTUREFORMAT_DEPTH24_STENCIL8 && e.format <= _.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8, a.isExternalTexture = t_.IsExternalTexture(e), a.isFloatOrDepthTexture && this._numFloatOrDepthTextures++, a.isExternalTexture && this._numExternalTextures++) : (a.isFloatOrDepthTexture = !1, a.isExternalTexture = !1), a.texture = e;
        var l = s !== ((o = e == null ? void 0 : e.uniqueId) !== null && o !== void 0 ? o : -1);
        l && this.updateId++, this.isDirty || (this.isDirty = l);
      }, n._Counter = 0, n;
    }(), ly = function() {
      function n(t) {
        this._bufferManager = t, this.uniqueId = n._Counter++, this._useInstancing = !1, this._currentInstanceCount = 0, this.reset();
      }
      return n.prototype.isDirty = function(t) {
        return this._isDirty || this._materialContextUpdateId !== t;
      }, n.prototype.resetIsDirty = function(t) {
        this._isDirty = !1, this._materialContextUpdateId = t;
      }, Object.defineProperty(n.prototype, "useInstancing", { get: function() {
        return this._useInstancing;
      }, set: function(t) {
        this._useInstancing !== t && (t ? (this.indirectDrawBuffer = this._bufferManager.createRawBuffer(20, $t.CopyDst | $t.Indirect | $t.Storage, void 0, "IndirectDrawBuffer"), this._indirectDrawData = new Uint32Array(5), this._indirectDrawData[3] = 0, this._indirectDrawData[4] = 0) : (this.indirectDrawBuffer && this._bufferManager.releaseBuffer(this.indirectDrawBuffer), this.indirectDrawBuffer = void 0, this._indirectDrawData = void 0), this._useInstancing = t, this._currentInstanceCount = -1);
      }, enumerable: !1, configurable: !0 }), n.prototype.reset = function() {
        this.buffers = {}, this._isDirty = !0, this._materialContextUpdateId = 0, this.fastBundle = void 0, this.bindGroups = void 0;
      }, n.prototype.setBuffer = function(t, e) {
        var i;
        this._isDirty || (this._isDirty = (e == null ? void 0 : e.uniqueId) !== ((i = this.buffers[t]) === null || i === void 0 ? void 0 : i.uniqueId)), this.buffers[t] = e;
      }, n.prototype.setIndirectData = function(t, e, i) {
        e !== this._currentInstanceCount && this.indirectDrawBuffer && this._indirectDrawData && (this._currentInstanceCount = e, this._indirectDrawData[0] = t, this._indirectDrawData[1] = e, this._indirectDrawData[2] = i, this._bufferManager.setRawData(this.indirectDrawBuffer, 0, this._indirectDrawData, 0, 20));
      }, n.prototype.dispose = function() {
        this.indirectDrawBuffer && (this._bufferManager.releaseBuffer(this.indirectDrawBuffer), this.indirectDrawBuffer = void 0, this._indirectDrawData = void 0), this.fastBundle = void 0, this.bindGroups = void 0, this.buffers = void 0;
      }, n._Counter = 0, n;
    }(), i_ = function() {
      this.values = {};
    }, cy = function() {
      function n(t, e, i) {
        this.disabled = !1, this._device = t, this._cacheSampler = e, this._engine = i;
      }
      return Object.defineProperty(n, "Statistics", { get: function() {
        return { totalCreated: n.NumBindGroupsCreatedTotal, lastFrameCreated: n.NumBindGroupsCreatedLastFrame, lookupLastFrame: n.NumBindGroupsLookupLastFrame, noLookupLastFrame: n.NumBindGroupsNoLookupLastFrame };
      }, enumerable: !1, configurable: !0 }), n.prototype.endFrame = function() {
        n.NumBindGroupsCreatedLastFrame = n._NumBindGroupsCreatedCurrentFrame, n.NumBindGroupsLookupLastFrame = n._NumBindGroupsLookupCurrentFrame, n.NumBindGroupsNoLookupLastFrame = n._NumBindGroupsNoLookupCurrentFrame, n._NumBindGroupsCreatedCurrentFrame = 0, n._NumBindGroupsLookupCurrentFrame = 0, n._NumBindGroupsNoLookupCurrentFrame = 0;
      }, n.prototype.getBindGroups = function(t, e, i) {
        var r, o, a, s, l, c, u, h, d, p, f = void 0, m = n._Cache, g = this.disabled || i.forceBindGroupCreation;
        if (!g) {
          if (!e.isDirty(i.updateId) && !i.isDirty)
            return n._NumBindGroupsNoLookupCurrentFrame++, e.bindGroups;
          for (var y = 0, b = t.shaderProcessingContext.bufferNames; y < b.length; y++) {
            var T = b[y], S = (o = (r = e.buffers[T]) === null || r === void 0 ? void 0 : r.uniqueId) !== null && o !== void 0 ? o : 0;
            (O = m.values[S]) || (O = new i_(), m.values[S] = O), m = O;
          }
          for (var E = 0, A = t.shaderProcessingContext.samplerNames; E < A.length; E++) {
            var R = A[E], C = (s = (a = i.samplers[R]) === null || a === void 0 ? void 0 : a.hashCode) !== null && s !== void 0 ? s : 0;
            (O = m.values[C]) || (O = new i_(), m.values[C] = O), m = O;
          }
          for (var L = 0, I = t.shaderProcessingContext.textureNames; L < I.length; L++) {
            var O, w = I[L], z = (u = (c = (l = i.textures[w]) === null || l === void 0 ? void 0 : l.texture) === null || c === void 0 ? void 0 : c.uniqueId) !== null && u !== void 0 ? u : 0;
            (O = m.values[z]) || (O = new i_(), m.values[z] = O), m = O;
          }
          f = m.bindGroups;
        }
        if (e.resetIsDirty(i.updateId), i.isDirty = !1, f)
          return e.bindGroups = f, n._NumBindGroupsLookupCurrentFrame++, f;
        f = [], e.bindGroups = f, g || (m.bindGroups = f), n.NumBindGroupsCreatedTotal++, n._NumBindGroupsCreatedCurrentFrame++;
        for (var V = t.bindGroupLayouts[i.textureState], Y = 0; Y < t.shaderProcessingContext.bindGroupLayoutEntries.length; Y++) {
          for (var ee = t.shaderProcessingContext.bindGroupLayoutEntries[Y], J = t.shaderProcessingContext.bindGroupEntries[Y], X = 0; X < ee.length; X++) {
            var K = t.shaderProcessingContext.bindGroupLayoutEntries[Y][X], te = t.shaderProcessingContext.bindGroupLayoutEntryInfo[Y][K.binding], se = (h = te.nameInArrayOfTexture) !== null && h !== void 0 ? h : te.name;
            if (K.sampler)
              if (Te = i.samplers[se]) {
                var _e = Te.sampler;
                if (!_e) {
                  this._engine.dbgSanityChecks && q.Error("Trying to bind a null sampler! entry=".concat(JSON.stringify(K), ", name=").concat(se, ", bindingInfo=").concat(JSON.stringify(Te, function(Re, Be) {
                    return Re === "texture" ? "<no dump>" : Be;
                  }), ", materialContext.uniqueId=").concat(i.uniqueId), 50);
                  continue;
                }
                J[X].resource = this._cacheSampler.getSampler(_e, !1, Te.hashCode, _e.label);
              } else
                q.Error('Sampler "'.concat(se, '" could not be bound. entry=').concat(JSON.stringify(K), ", materialContext=").concat(JSON.stringify(i, function(Re, Be) {
                  return Re === "texture" || Re === "sampler" ? "<no dump>" : Be;
                })), 50);
            else if (K.texture || K.storageTexture)
              if (Te = i.textures[se]) {
                if (this._engine.dbgSanityChecks && Te.texture === null) {
                  q.Error("Trying to bind a null texture! entry=".concat(JSON.stringify(K), ", bindingInfo=").concat(JSON.stringify(Te, function(Re, Be) {
                    return Re === "texture" ? "<no dump>" : Be;
                  }), ", materialContext.uniqueId=").concat(i.uniqueId), 50);
                  continue;
                }
                var xe = Te.texture._hardwareTexture;
                if (this._engine.dbgSanityChecks && (!xe || K.texture && !xe.view || K.storageTexture && !xe.viewForWriting)) {
                  q.Error("Trying to bind a null gpu texture or view! entry=".concat(JSON.stringify(K), ", name=").concat(se, ", bindingInfo=").concat(JSON.stringify(Te, function(Re, Be) {
                    return Re === "texture" ? "<no dump>" : Be;
                  }), ", isReady=").concat((d = Te.texture) === null || d === void 0 ? void 0 : d.isReady, ", materialContext.uniqueId=").concat(i.uniqueId), 50);
                  continue;
                }
                J[X].resource = K.storageTexture ? xe.viewForWriting : xe.view;
              } else
                q.Error('Texture "'.concat(se, '" could not be bound. entry=').concat(JSON.stringify(K), ", materialContext=").concat(JSON.stringify(i, function(Re, Be) {
                  return Re === "texture" || Re === "sampler" ? "<no dump>" : Be;
                })), 50);
            else if (K.externalTexture) {
              var Te;
              if (Te = i.textures[se]) {
                if (this._engine.dbgSanityChecks && Te.texture === null) {
                  q.Error("Trying to bind a null external texture! entry=".concat(JSON.stringify(K), ", name=").concat(se, ", bindingInfo=").concat(JSON.stringify(Te, function(Re, Be) {
                    return Re === "texture" ? "<no dump>" : Be;
                  }), ", materialContext.uniqueId=").concat(i.uniqueId), 50);
                  continue;
                }
                var he = Te.texture.underlyingResource;
                if (this._engine.dbgSanityChecks && !he) {
                  q.Error("Trying to bind a null gpu external texture! entry=".concat(JSON.stringify(K), ", name=").concat(se, ", bindingInfo=").concat(JSON.stringify(Te, function(Re, Be) {
                    return Re === "texture" ? "<no dump>" : Be;
                  }), ", isReady=").concat((p = Te.texture) === null || p === void 0 ? void 0 : p.isReady, ", materialContext.uniqueId=").concat(i.uniqueId), 50);
                  continue;
                }
                J[X].resource = this._device.importExternalTexture({ source: he });
              } else
                q.Error('Texture "'.concat(se, '" could not be bound. entry=').concat(JSON.stringify(K), ", materialContext=").concat(JSON.stringify(i, function(Re, Be) {
                  return Re === "texture" || Re === "sampler" ? "<no dump>" : Be;
                })), 50);
            } else if (K.buffer) {
              var me = e.buffers[se];
              if (me) {
                var Fe = me.underlyingResource;
                J[X].resource.buffer = Fe, J[X].resource.size = me.capacity;
              } else
                q.Error(`Can't find buffer "`.concat(se, '". entry=').concat(JSON.stringify(K), ", buffers=").concat(JSON.stringify(e.buffers), ", drawContext.uniqueId=").concat(e.uniqueId), 50);
            }
          }
          var Ce = V[Y];
          f[Y] = this._device.createBindGroup({ layout: Ce, entries: J });
        }
        return f;
      }, n.NumBindGroupsCreatedTotal = 0, n.NumBindGroupsCreatedLastFrame = 0, n.NumBindGroupsLookupLastFrame = 0, n.NumBindGroupsNoLookupLastFrame = 0, n._Cache = new i_(), n._NumBindGroupsCreatedCurrentFrame = 0, n._NumBindGroupsLookupCurrentFrame = 0, n._NumBindGroupsNoLookupCurrentFrame = 0, n;
    }();
    re.ShadersStore.clearQuadVertexShader = `uniform float depthValue;const vec2 pos[4]={vec2(-1.0,1.0),
vec2(1.0,1.0),
vec2(-1.0,-1.0),
vec2(1.0,-1.0)};
#define CUSTOM_VERTEX_DEFINITIONS
void main(void) {
#define CUSTOM_VERTEX_MAIN_BEGIN
gl_Position=vec4(pos[gl_VertexID],depthValue,1.0);
#define CUSTOM_VERTEX_MAIN_END
}
`, re.ShadersStore.clearQuadPixelShader = `uniform vec4 color;void main() {gl_FragColor=color;}
`;
    var xD = function() {
      function n(t, e, i) {
        this._bindGroups = {}, this._bundleCache = {}, this._keyTemp = [], this._device = t, this._engine = e, this._cacheRenderPipeline = new e_(this._device, i), this._cacheRenderPipeline.setDepthTestEnabled(!1), this._cacheRenderPipeline.setStencilReadMask(255), this._effect = e.createEffect("clearQuad", [], ["color", "depthValue"]);
      }
      return n.prototype.setDepthStencilFormat = function(t) {
        this._depthTextureFormat = t, this._cacheRenderPipeline.setDepthStencilFormat(t);
      }, n.prototype.setColorFormat = function(t) {
        this._cacheRenderPipeline.setColorFormat(t);
      }, n.prototype.setMRTAttachments = function(t, e, i) {
        this._cacheRenderPipeline.setMRT(e, i), this._cacheRenderPipeline.setMRTAttachments(t);
      }, n.prototype.clear = function(t, e, i, r, o) {
        var a, s, l;
        o === void 0 && (o = 1);
        var c, u = null, h = !!this._engine._currentRenderTarget;
        if (t)
          l = t;
        else {
          var d = 0;
          this._keyTemp.length = 0;
          for (var p = 0; p < this._cacheRenderPipeline.colorFormats.length; ++p)
            this._keyTemp[d++] = ba[(a = this._cacheRenderPipeline.colorFormats[p]) !== null && a !== void 0 ? a : ""];
          var f = ba[(s = this._depthTextureFormat) !== null && s !== void 0 ? s : 0];
          if (this._keyTemp[d] = (e ? e.r + 256 * e.g + 256 * e.b * 256 + 256 * e.a * 256 * 256 : 0) + (i ? Math.pow(2, 32) : 0) + (r ? Math.pow(2, 33) : 0) + (this._engine.useReverseDepthBuffer ? Math.pow(2, 34) : 0) + (h ? Math.pow(2, 35) : 0) + (o > 1 ? Math.pow(2, 36) : 0) + f * Math.pow(2, 37), c = this._keyTemp.join("_"), u = this._bundleCache[c])
            return u;
          l = this._device.createRenderBundleEncoder({ colorFormats: this._cacheRenderPipeline.colorFormats, depthStencilFormat: this._depthTextureFormat, sampleCount: kr.GetSample(o) });
        }
        this._cacheRenderPipeline.setDepthWriteEnabled(!!i), this._cacheRenderPipeline.setStencilEnabled(!!r && !!this._depthTextureFormat && kr.HasStencilAspect(this._depthTextureFormat)), this._cacheRenderPipeline.setStencilWriteMask(r ? 255 : 0), this._cacheRenderPipeline.setStencilCompare(r ? _.ALWAYS : _.NEVER), this._cacheRenderPipeline.setStencilPassOp(r ? _.REPLACE : _.KEEP), this._cacheRenderPipeline.setWriteMask(e ? 15 : 0);
        var m = this._cacheRenderPipeline.getRenderPipeline(_.MATERIAL_TriangleStripDrawMode, this._effect, o), g = this._effect._pipelineContext;
        e && this._effect.setDirectColor4("color", e), this._effect.setFloat("depthValue", this._engine.useReverseDepthBuffer ? this._engine._clearReverseDepthValue : this._engine._clearDepthValue), g.uniformBuffer.update();
        var y = h ? this._engine._ubInvertY : this._engine._ubDontInvertY, b = g.uniformBuffer.getBuffer(), T = b.uniqueId + "-" + y.uniqueId, S = this._bindGroups[T];
        if (!S) {
          var E = g.bindGroupLayouts[0];
          (S = this._bindGroups[T] = []).push(this._device.createBindGroup({ layout: E[0], entries: [] })), kh._SimplifiedKnownBindings || S.push(this._device.createBindGroup({ layout: E[1], entries: [] })), S.push(this._device.createBindGroup({ layout: E[kh._SimplifiedKnownBindings ? 1 : 2], entries: [{ binding: 0, resource: { buffer: y.underlyingResource, size: y.capacity } }, { binding: 1, resource: { buffer: b.underlyingResource, size: b.capacity } }] }));
        }
        for (l.setPipeline(m), p = 0; p < S.length; ++p)
          l.setBindGroup(p, S[p]);
        return l.draw(4, 1, 0, 0), t || (u = l.finish(), this._bundleCache[c] = u), u;
      }, n;
    }(), AD = function() {
      function n(t, e, i, r) {
        this.x = Math.floor(t), this.y = Math.floor(e), this.w = Math.floor(i), this.h = Math.floor(r);
      }
      return n.prototype.run = function(t) {
        t.setViewport(this.x, this.y, this.w, this.h, 0, 1);
      }, n.prototype.clone = function() {
        return new n(this.x, this.y, this.w, this.h);
      }, n;
    }(), RD = function() {
      function n(t, e, i, r) {
        this.x = t, this.y = e, this.w = i, this.h = r;
      }
      return n.prototype.run = function(t) {
        t.setScissorRect(this.x, this.y, this.w, this.h);
      }, n.prototype.clone = function() {
        return new n(this.x, this.y, this.w, this.h);
      }, n;
    }(), RC = function() {
      function n(t) {
        this.ref = t;
      }
      return n.prototype.run = function(t) {
        t.setStencilReference(this.ref);
      }, n.prototype.clone = function() {
        return new n(this.ref);
      }, n;
    }(), CD = function() {
      function n(t) {
        this.color = t;
      }
      return n.prototype.run = function(t) {
        t.setBlendConstant(this.color);
      }, n.prototype.clone = function() {
        return new n(this.color);
      }, n;
    }(), PD = function() {
      function n(t) {
        this.query = t;
      }
      return n.prototype.run = function(t) {
        t.beginOcclusionQuery(this.query);
      }, n.prototype.clone = function() {
        return new n(this.query);
      }, n;
    }(), ID = function() {
      function n() {
      }
      return n.prototype.run = function(t) {
        t.endOcclusionQuery();
      }, n.prototype.clone = function() {
        return new n();
      }, n;
    }(), MD = function() {
      function n() {
        this.bundles = [];
      }
      return n.prototype.run = function(t) {
        t.executeBundles(this.bundles);
      }, n.prototype.clone = function() {
        var t = new n();
        return t.bundles = this.bundles, t;
      }, n;
    }(), OD = function() {
      function n(t) {
        this.numDrawCalls = 0, this._device = t, this._list = new Array(10), this._listLength = 0;
      }
      return n.prototype.addBundle = function(t) {
        if (!this._currentItemIsBundle) {
          var e = new MD();
          this._list[this._listLength++] = e, this._currentBundleList = e.bundles, this._currentItemIsBundle = !0;
        }
        t && this._currentBundleList.push(t);
      }, n.prototype._finishBundle = function() {
        this._currentItemIsBundle && this._bundleEncoder && (this._currentBundleList.push(this._bundleEncoder.finish()), this._bundleEncoder = void 0, this._currentItemIsBundle = !1);
      }, n.prototype.addItem = function(t) {
        this._finishBundle(), this._list[this._listLength++] = t, this._currentItemIsBundle = !1;
      }, n.prototype.getBundleEncoder = function(t, e, i) {
        return this._currentItemIsBundle || (this.addBundle(), this._bundleEncoder = this._device.createRenderBundleEncoder({ colorFormats: t, depthStencilFormat: e, sampleCount: kr.GetSample(i) })), this._bundleEncoder;
      }, n.prototype.close = function() {
        this._finishBundle();
      }, n.prototype.run = function(t) {
        this.close();
        for (var e = 0; e < this._listLength; ++e)
          this._list[e].run(t);
      }, n.prototype.reset = function() {
        this._listLength = 0, this._currentItemIsBundle = !1, this.numDrawCalls = 0;
      }, n.prototype.clone = function() {
        this.close();
        var t = new n(this._device);
        t._list = new Array(this._listLength), t._listLength = this._listLength, t.numDrawCalls = this.numDrawCalls;
        for (var e = 0; e < this._listLength; ++e)
          t._list[e] = this._list[e].clone();
        return t;
      }, n;
    }(), CC = function() {
      function n(t, e, i, r, o, a) {
        o === void 0 && (o = !0), this._dstBuffers = [], this._device = i, this._bufferManager = r, this._count = t, this._canUseMultipleBuffers = o, this._querySet = i.createQuerySet({ label: a, type: e, count: t }), this._queryBuffer = r.createRawBuffer(8 * t, $t.QueryResolve | $t.CopySrc, void 0, "QueryBuffer"), o || this._dstBuffers.push(this._bufferManager.createRawBuffer(8 * this._count, $t.MapRead | $t.CopyDst, void 0, "QueryBufferNoMultipleBuffers"));
      }
      return Object.defineProperty(n.prototype, "querySet", { get: function() {
        return this._querySet;
      }, enumerable: !1, configurable: !0 }), n.prototype._getBuffer = function(t, e) {
        if (!this._canUseMultipleBuffers && this._dstBuffers.length === 0)
          return null;
        var i, r = this._device.createCommandEncoder();
        return this._dstBuffers.length === 0 ? i = this._bufferManager.createRawBuffer(8 * this._count, $t.MapRead | $t.CopyDst, void 0, "QueryBufferAdditionalBuffer") : (i = this._dstBuffers[this._dstBuffers.length - 1], this._dstBuffers.length--), r.resolveQuerySet(this._querySet, t, e, this._queryBuffer, 0), r.copyBufferToBuffer(this._queryBuffer, 0, i, 0, 8 * e), this._device.queue.submit([r.finish()]), i;
      }, n.prototype.readValues = function(t, e) {
        return t === void 0 && (t = 0), e === void 0 && (e = 1), Ft(this, void 0, void 0, function() {
          var i, r;
          return Bt(this, function(o) {
            switch (o.label) {
              case 0:
                return (i = this._getBuffer(t, e)) === null ? [2, null] : [4, i.mapAsync(Ya.Read)];
              case 1:
                return o.sent(), r = new BigUint64Array(i.getMappedRange()).slice(), i.unmap(), this._dstBuffers[this._dstBuffers.length] = i, [2, r];
            }
          });
        });
      }, n.prototype.readValue = function(t) {
        return t === void 0 && (t = 0), Ft(this, void 0, void 0, function() {
          var e, i, r;
          return Bt(this, function(o) {
            switch (o.label) {
              case 0:
                return (e = this._getBuffer(t, 1)) === null ? [2, null] : [4, e.mapAsync(Ya.Read)];
              case 1:
                return o.sent(), i = new BigUint64Array(e.getMappedRange()), r = Number(i[0]), e.unmap(), this._dstBuffers[this._dstBuffers.length] = e, [2, r];
            }
          });
        });
      }, n.prototype.readTwoValuesAndSubtract = function(t) {
        return t === void 0 && (t = 0), Ft(this, void 0, void 0, function() {
          var e, i, r;
          return Bt(this, function(o) {
            switch (o.label) {
              case 0:
                return (e = this._getBuffer(t, 2)) === null ? [2, null] : [4, e.mapAsync(Ya.Read)];
              case 1:
                return o.sent(), i = new BigUint64Array(e.getMappedRange()), r = Number(i[1] - i[0]), e.unmap(), this._dstBuffers[this._dstBuffers.length] = e, [2, r];
            }
          });
        });
      }, n.prototype.dispose = function() {
        this._querySet.destroy(), this._bufferManager.releaseBuffer(this._queryBuffer);
        for (var t = 0; t < this._dstBuffers.length; ++t)
          this._bufferManager.releaseBuffer(this._dstBuffers[t]);
      }, n;
    }(), DD = function() {
      function n(t, e) {
        this._enabled = !1, this._gpuFrameTimeCounter = new Sn(), this._measureDurationState = 0, this._device = t, this._bufferManager = e;
      }
      return Object.defineProperty(n.prototype, "gpuFrameTimeCounter", { get: function() {
        return this._gpuFrameTimeCounter;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "enable", { get: function() {
        return this._enabled;
      }, set: function(t) {
        this._enabled !== t && (this._enabled = t, this._measureDurationState = 0, t ? this._measureDuration = new ND(this._device, this._bufferManager) : this._measureDuration.dispose());
      }, enumerable: !1, configurable: !0 }), n.prototype.startFrame = function(t) {
        this._enabled && this._measureDurationState === 0 && (this._measureDuration.start(t), this._measureDurationState = 1);
      }, n.prototype.endFrame = function(t) {
        var e = this;
        this._measureDurationState === 1 && (this._measureDurationState = 2, this._measureDuration.stop(t).then(function(i) {
          i !== null && i >= 0 && (e._gpuFrameTimeCounter.fetchNewFrame(), e._gpuFrameTimeCounter.addCount(i, !0)), e._measureDurationState = 0;
        }));
      }, n;
    }(), ND = function() {
      function n(t, e) {
        this._querySet = new CC(2, kc.Timestamp, t, e);
      }
      return n.prototype.start = function(t) {
        t.writeTimestamp(this._querySet.querySet, 0);
      }, n.prototype.stop = function(t) {
        return Ft(this, void 0, void 0, function() {
          return Bt(this, function(e) {
            return t.writeTimestamp(this._querySet.querySet, 1), [2, this._querySet.readTwoValuesAndSubtract(0)];
          });
        });
      }, n.prototype.dispose = function() {
        this._querySet.dispose();
      }, n;
    }(), FD = function() {
      function n(t, e, i, r, o) {
        r === void 0 && (r = 50), o === void 0 && (o = 100), this._availableIndices = [], this._frameQuerySetIsDirty = -1, this._queryFrameId = [], this._engine = t, this._device = e, this._bufferManager = i, this._frameLastBuffer = -1, this._currentTotalIndices = 0, this._countIncrement = o, this._allocateNewIndices(r);
      }
      return Object.defineProperty(n.prototype, "querySet", { get: function() {
        return this._querySet.querySet;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "hasQueries", { get: function() {
        return this._currentTotalIndices !== this._availableIndices.length;
      }, enumerable: !1, configurable: !0 }), n.prototype.canBeginQuery = function(t) {
        if (this._frameQuerySetIsDirty === this._engine.frameId || this._queryFrameId[t] === this._engine.frameId)
          return !1;
        var e = this._engine._getCurrentRenderPassWrapper().renderPassDescriptor.occlusionQuerySet !== void 0;
        return e && (this._queryFrameId[t] = this._engine.frameId), e;
      }, n.prototype.createQuery = function() {
        this._availableIndices.length === 0 && this._allocateNewIndices();
        var t = this._availableIndices[this._availableIndices.length - 1];
        return this._availableIndices.length--, t;
      }, n.prototype.deleteQuery = function(t) {
        this._availableIndices[this._availableIndices.length] = t;
      }, n.prototype.isQueryResultAvailable = function(t) {
        return this._retrieveQueryBuffer(), !!this._lastBuffer && t < this._lastBuffer.length;
      }, n.prototype.getQueryResult = function(t) {
        var e, i;
        return Number((i = (e = this._lastBuffer) === null || e === void 0 ? void 0 : e[t]) !== null && i !== void 0 ? i : -1);
      }, n.prototype._retrieveQueryBuffer = function() {
        var t = this;
        this._lastBuffer && this._frameLastBuffer === this._engine.frameId || this._frameLastBuffer !== this._engine.frameId && (this._frameLastBuffer = this._engine.frameId, this._querySet.readValues(0, this._currentTotalIndices).then(function(e) {
          t._lastBuffer = e;
        }));
      }, n.prototype._allocateNewIndices = function(t) {
        t = t ?? this._countIncrement, this._delayQuerySetDispose();
        for (var e = 0; e < t; ++e)
          this._availableIndices.push(this._currentTotalIndices + e);
        this._currentTotalIndices += t, this._querySet = new CC(this._currentTotalIndices, kc.Occlusion, this._device, this._bufferManager, !1, "QuerySet_OcclusionQuery_count_" + this._currentTotalIndices), this._frameQuerySetIsDirty = this._engine.frameId;
      }, n.prototype._delayQuerySetDispose = function() {
        var t = this._querySet;
        t && setTimeout(function() {
          return t.dispose;
        }, 1e3);
      }, n.prototype.dispose = function() {
        var t;
        (t = this._querySet) === null || t === void 0 || t.dispose(), this._availableIndices.length = 0;
      }, n;
    }(), uy = function() {
      function n() {
      }
      return n.prototype.initTwgsl = function(t) {
        return Ft(this, void 0, void 0, function() {
          var e;
          return Bt(this, function(i) {
            switch (i.label) {
              case 0:
                return n._twgsl ? [2] : (t = t || {}, (t = je(je({}, n._TWgslDefaultOptions), t)).twgsl ? (n._twgsl = t.twgsl, [2, Promise.resolve()]) : t.jsPath && t.wasmPath ? [4, de.LoadBabylonScriptAsync(t.jsPath)] : [3, 2]);
              case 1:
                i.sent(), i.label = 2;
              case 2:
                return self.twgsl ? (e = n, [4, self.twgsl(de.GetBabylonScriptURL(t.wasmPath))]) : [3, 4];
              case 3:
                return e._twgsl = i.sent(), [2, Promise.resolve()];
              case 4:
                return [2, Promise.reject("twgsl is not available.")];
            }
          });
        });
      }, n.prototype.convertSpirV2WGSL = function(t, e) {
        e === void 0 && (e = !1);
        var i = n._twgsl.convertSpirV2WGSL(t, n.DisableUniformityAnalysis || e);
        return n.ShowWGSLShaderCode && (console.log(i), console.log("***********************************************")), n.DisableUniformityAnalysis || e ? `diagnostic(off, derivative_uniformity);
` + i : i;
      }, n._TWgslDefaultOptions = { jsPath: "".concat(de._DefaultCdnUrl, "/twgsl/twgsl.js"), wasmPath: "".concat(de._DefaultCdnUrl, "/twgsl/twgsl.wasm") }, n.ShowWGSLShaderCode = !1, n.DisableUniformityAnalysis = !1, n._twgsl = null, n;
    }(), LD = function() {
      function n(t, e, i) {
        this._record = !1, this._play = !1, this._playBundleListIndex = 0, this._allBundleLists = [], this._enabled = !1, this._engine = t, this._mode = e, this._bundleList = i;
      }
      return Object.defineProperty(n.prototype, "enabled", { get: function() {
        return this._enabled;
      }, set: function(t) {
        this._allBundleLists.length = 0, this._record = this._enabled = t, this._play = !1, t && (this._modeSaved = this._mode, this._mode = _.SNAPSHOTRENDERING_STANDARD);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "play", { get: function() {
        return this._play;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "record", { get: function() {
        return this._record;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "mode", { get: function() {
        return this._mode;
      }, set: function(t) {
        this._record ? this._modeSaved = t : this._mode = t;
      }, enumerable: !1, configurable: !0 }), n.prototype.endRenderPass = function(t) {
        if (!this._record && !this._play)
          return !1;
        var e;
        if (this._record)
          e = this._bundleList.clone(), this._allBundleLists.push(e), this._bundleList.reset();
        else {
          if (this._playBundleListIndex >= this._allBundleLists.length)
            throw new Error("Invalid playBundleListIndex! Your snapshot is no longer valid for the current frame, you should recreate a new one. playBundleListIndex=".concat(this._playBundleListIndex, ", allBundleLists.length=").concat(this._allBundleLists.length, "}"));
          e = this._allBundleLists[this._playBundleListIndex++];
        }
        return e.run(t), this._mode === _.SNAPSHOTRENDERING_FAST && this._engine._reportDrawCall(e.numDrawCalls), !0;
      }, n.prototype.endFrame = function() {
        this._record && (this._record = !1, this._play = !0, this._mode = this._modeSaved), this._playBundleListIndex = 0;
      }, n.prototype.reset = function() {
        this.enabled = !1, this.enabled = !0;
      }, n;
    }();
    re.ShadersStoreWGSL.postprocessVertexShader = `attribute position: vec2<f32>;uniform scale: vec2<f32>;varying vUV: vec2<f32>;const madd=vec2(0.5,0.5);
#define CUSTOM_VERTEX_DEFINITIONS
@vertex
fn main(input : VertexInputs)->FragmentInputs {
#define CUSTOM_VERTEX_MAIN_BEGIN
vertexOutputs.vUV=(vertexInputs.position*madd+madd)*uniforms.scale;vertexOutputs.position=vec4(vertexInputs.position,0.0,1.0);
#define CUSTOM_VERTEX_MAIN_END
}
`;
    var PC = { label: "TextureView_SwapChain_ResolveTarget", dimension: Ir.E2d, format: void 0, mipLevelCount: 1, arrayLayerCount: 1 }, IC = { label: "TextureView_SwapChain", dimension: Ir.E2d, format: void 0, mipLevelCount: 1, arrayLayerCount: 1 }, n_ = "/* disable_uniformity_analysis */", wD = new Ie(), st = function(n) {
      function t(e, i) {
        i === void 0 && (i = {});
        var r, o, a = this;
        return (a = n.call(this, null, (r = i.antialias) === null || r === void 0 || r, i) || this)._uploadEncoderDescriptor = { label: "upload" }, a._renderEncoderDescriptor = { label: "render" }, a._clearDepthValue = 1, a._clearReverseDepthValue = 0, a._clearStencilValue = 0, a._defaultSampleCount = 4, a._glslang = null, a._tintWASM = null, a._adapterInfo = { vendor: "", architecture: "", device: "", description: "" }, a._compiledComputeEffects = {}, a._counters = { numEnableEffects: 0, numEnableDrawWrapper: 0, numBundleCreationNonCompatMode: 0, numBundleReuseNonCompatMode: 0 }, a.countersLastFrame = { numEnableEffects: 0, numEnableDrawWrapper: 0, numBundleCreationNonCompatMode: 0, numBundleReuseNonCompatMode: 0 }, a.numMaxUncapturedErrors = 20, a._commandBuffers = [null, null], a._currentRenderPass = null, a._mainRenderPassWrapper = { renderPassDescriptor: null, colorAttachmentViewDescriptor: null, depthAttachmentViewDescriptor: null, colorAttachmentGPUTextures: [], depthTextureFormat: void 0 }, a._rttRenderPassWrapper = { renderPassDescriptor: null, colorAttachmentViewDescriptor: null, depthAttachmentViewDescriptor: null, colorAttachmentGPUTextures: [], depthTextureFormat: void 0 }, a._pendingDebugCommands = [], a._currentOverrideVertexBuffers = null, a._currentIndexBuffer = null, a._colorWriteLocal = !0, a._forceEnableEffect = !1, a.dbgShowShaderCode = !1, a.dbgSanityChecks = !0, a.dbgVerboseLogsForFirstFrames = !1, a.dbgVerboseLogsNumFrames = 10, a.dbgLogIfNotDrawWrapper = !0, a.dbgShowEmptyEnableEffectCalls = !0, a.isNDCHalfZRange = !0, a.hasOriginBottomLeft = !1, a._viewportsCurrent = { x: 0, y: 0, w: 0, h: 0 }, a._scissorsCurrent = { x: 0, y: 0, w: 0, h: 0 }, a._scissorCached = { x: 0, y: 0, z: 0, w: 0 }, a._stencilRefsCurrent = -1, a._blendColorsCurrent = [null, null, null, null], a._name = "WebGPU", i.deviceDescriptor = i.deviceDescriptor || {}, i.enableGPUDebugMarkers = (o = i.enableGPUDebugMarkers) !== null && o !== void 0 && o, q.Log("Babylon.js v".concat(ve.Version, " - ").concat(a.description, " engine")), navigator.gpu ? (i.swapChainFormat = i.swapChainFormat || navigator.gpu.getPreferredCanvasFormat(), a._isWebGPU = !0, a._shaderPlatformName = "WEBGPU", a._renderingCanvas = e, a._options = i, a._mainPassSampleCount = i.antialias ? a._defaultSampleCount : 1, a._setupMobileChecks(), a._sharedInit(e), a._shaderProcessor = new dD(), a._shaderProcessorWGSL = new fD(), a) : (q.Error("WebGPU is not supported by your browser."), a);
      }
      return D(t, n), Object.defineProperty(t.prototype, "snapshotRenderingMode", { get: function() {
        return this._snapshotRendering.mode;
      }, set: function(e) {
        this._snapshotRendering.mode = e;
      }, enumerable: !1, configurable: !0 }), t.prototype.snapshotRenderingReset = function() {
        this._snapshotRendering.reset();
      }, Object.defineProperty(t.prototype, "snapshotRendering", { get: function() {
        return this._snapshotRendering.enabled;
      }, set: function(e) {
        this._snapshotRendering.enabled = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "disableCacheSamplers", { get: function() {
        return !!this._cacheSampler && this._cacheSampler.disabled;
      }, set: function(e) {
        this._cacheSampler && (this._cacheSampler.disabled = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "disableCacheRenderPipelines", { get: function() {
        return !!this._cacheRenderPipeline && this._cacheRenderPipeline.disabled;
      }, set: function(e) {
        this._cacheRenderPipeline && (this._cacheRenderPipeline.disabled = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "disableCacheBindGroups", { get: function() {
        return !!this._cacheBindGroups && this._cacheBindGroups.disabled;
      }, set: function(e) {
        this._cacheBindGroups && (this._cacheBindGroups.disabled = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "IsSupportedAsync", { get: function() {
        return navigator.gpu ? navigator.gpu.requestAdapter().then(function(e) {
          return !!e;
        }, function() {
          return !1;
        }).catch(function() {
          return !1;
        }) : Promise.resolve(!1);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "IsSupported", { get: function() {
        return q.Warn("You must call IsSupportedAsync for WebGPU!"), !1;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "supportsUniformBuffers", { get: function() {
        return !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "supportedExtensions", { get: function() {
        return this._adapterSupportedExtensions;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "enabledExtensions", { get: function() {
        return this._deviceEnabledExtensions;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "supportedLimits", { get: function() {
        return this._adapterSupportedLimits;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "currentLimits", { get: function() {
        return this._deviceLimits;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "description", { get: function() {
        return this.name + this.version;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "version", { get: function() {
        return 1;
      }, enumerable: !1, configurable: !0 }), t.prototype.getInfo = function() {
        return { vendor: this._adapterInfo.vendor || "unknown vendor", renderer: this._adapterInfo.architecture || "unknown renderer", version: this._adapterInfo.description || "unknown version" };
      }, Object.defineProperty(t.prototype, "compatibilityMode", { get: function() {
        return this._compatibilityMode;
      }, set: function(e) {
        this._compatibilityMode = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "currentSampleCount", { get: function() {
        return this._currentRenderTarget ? this._currentRenderTarget.samples : this._mainPassSampleCount;
      }, enumerable: !1, configurable: !0 }), t.CreateAsync = function(e, i) {
        i === void 0 && (i = {});
        var r = new t(e, i);
        return new Promise(function(o) {
          r.initAsync(i.glslangOptions, i.twgslOptions).then(function() {
            return o(r);
          });
        });
      }, t.prototype.initAsync = function(e, i) {
        var r, o = this;
        return this._initGlslang(e ?? ((r = this._options) === null || r === void 0 ? void 0 : r.glslangOptions)).then(function(a) {
          var s;
          return o._glslang = a, o._tintWASM = t.UseTWGSL ? new uy() : null, o._tintWASM ? o._tintWASM.initTwgsl(i ?? ((s = o._options) === null || s === void 0 ? void 0 : s.twgslOptions)).then(function() {
            return navigator.gpu.requestAdapter(o._options);
          }, function(l) {
            throw q.Error("Can not initialize twgsl!"), q.Error(l), Error("WebGPU initializations stopped.");
          }) : navigator.gpu.requestAdapter(o._options);
        }, function(a) {
          throw q.Error("Can not initialize glslang!"), q.Error(a), Error("WebGPU initializations stopped.");
        }).then(function(a) {
          var s, l, c;
          if (a) {
            o._adapter = a, o._adapterSupportedExtensions = [], (s = o._adapter.features) === null || s === void 0 || s.forEach(function(y) {
              return o._adapterSupportedExtensions.push(y);
            }), o._adapterSupportedLimits = o._adapter.limits, o._adapter.requestAdapterInfo().then(function(y) {
              o._adapterInfo = y;
            });
            var u = (l = o._options.deviceDescriptor) !== null && l !== void 0 ? l : {}, h = (c = u == null ? void 0 : u.requiredFeatures) !== null && c !== void 0 ? c : o._options.enableAllFeatures ? o._adapterSupportedExtensions : void 0;
            if (h) {
              for (var d = [], p = 0, f = h; p < f.length; p++) {
                var m = f[p];
                o._adapterSupportedExtensions.indexOf(m) !== -1 && d.push(m);
              }
              u.requiredFeatures = d;
            }
            if (o._options.setMaximumLimits && !u.requiredLimits)
              for (var g in u.requiredLimits = {}, o._adapterSupportedLimits)
                u.requiredLimits[g] = o._adapterSupportedLimits[g];
            return o._adapter.requestDevice(u);
          }
          throw "Could not retrieve a WebGPU adapter (adapter is null).";
        }).then(function(a) {
          var s, l;
          o._device = a, o._deviceEnabledExtensions = [], (s = o._device.features) === null || s === void 0 || s.forEach(function(u) {
            return o._deviceEnabledExtensions.push(u);
          }), o._deviceLimits = a.limits;
          var c = -1;
          o._device.addEventListener("uncapturederror", function(u) {
            ++c < o.numMaxUncapturedErrors ? q.Warn("WebGPU uncaptured error (".concat(c + 1, "): ").concat(u.error, " - ").concat(u.error.message)) : c++ === o.numMaxUncapturedErrors && q.Warn("WebGPU uncaptured error: too many warnings (".concat(o.numMaxUncapturedErrors, "), no more warnings will be reported to the console for this engine."));
          }), o._doNotHandleContextLost || (l = o._device.lost) === null || l === void 0 || l.then(function(u) {
            o._isDisposed || (o._contextWasLost = !0, q.Warn("WebGPU context lost. " + u), o.onContextLostObservable.notifyObservers(o), o._restoreEngineAfterContextLost(function() {
              return o.initAsync();
            }));
          });
        }, function(a) {
          q.Error("Could not retrieve a WebGPU device."), q.Error(a);
        }).then(function() {
          o._bufferManager = new mD(o._device), o._textureHelper = new kr(o._device, o._glslang, o._tintWASM, o._bufferManager, o._deviceEnabledExtensions), o._cacheSampler = new Jf(o._device), o._cacheBindGroups = new cy(o._device, o._cacheSampler, o), o._timestampQuery = new DD(o._device, o._bufferManager), o._occlusionQuery = o._device.createQuerySet ? new FD(o, o._device, o._bufferManager) : void 0, o._bundleList = new OD(o._device), o._snapshotRendering = new LD(o, o._snapshotRenderingMode, o._bundleList), o._ubInvertY = o._bufferManager.createBuffer(new Float32Array([-1, 0]), $t.Uniform | $t.CopyDst, "UBInvertY"), o._ubDontInvertY = o._bufferManager.createBuffer(new Float32Array([1, 0]), $t.Uniform | $t.CopyDst, "UBDontInvertY"), o.dbgVerboseLogsForFirstFrames && o._count === void 0 && (o._count = 0, console.log("%c frame #" + o._count + " - begin", "background: #ffff00")), o._uploadEncoder = o._device.createCommandEncoder(o._uploadEncoderDescriptor), o._renderEncoder = o._device.createCommandEncoder(o._renderEncoderDescriptor), o._initializeLimits(), o._emptyVertexBuffer = new P(o, [0], "", !1, !1, 1, !1, 0, 1), o._cacheRenderPipeline = new e_(o._device, o._emptyVertexBuffer), o._depthCullingState = new ED(o._cacheRenderPipeline), o._stencilStateComposer = new TD(o._cacheRenderPipeline), o._stencilStateComposer.stencilGlobal = o._stencilState, o._depthCullingState.depthTest = !0, o._depthCullingState.depthFunc = _.LEQUAL, o._depthCullingState.depthMask = !0, o._textureHelper.setCommandEncoder(o._uploadEncoder), o._clearQuad = new xD(o._device, o, o._emptyVertexBuffer), o._defaultDrawContext = o.createDrawContext(), o._currentDrawContext = o._defaultDrawContext, o._defaultMaterialContext = o.createMaterialContext(), o._currentMaterialContext = o._defaultMaterialContext, o._initializeContextAndSwapChain(), o._initializeMainAttachments(), o.resize();
        }).catch(function(a) {
          q.Error("Can not create WebGPU Device and/or context."), q.Error(a), console.trace && console.trace();
        });
      }, t.prototype._initGlslang = function(e) {
        return e = e || {}, (e = je(je({}, t._GLSLslangDefaultOptions), e)).glslang ? Promise.resolve(e.glslang) : self.glslang ? self.glslang(e.wasmPath) : e.jsPath && e.wasmPath ? de.LoadBabylonScriptAsync(e.jsPath).then(function() {
          return self.glslang(de.GetBabylonScriptURL(e.wasmPath));
        }) : Promise.reject("gslang is not available.");
      }, t.prototype._initializeLimits = function() {
        this._caps = { maxTexturesImageUnits: this._deviceLimits.maxSampledTexturesPerShaderStage, maxVertexTextureImageUnits: this._deviceLimits.maxSampledTexturesPerShaderStage, maxCombinedTexturesImageUnits: 2 * this._deviceLimits.maxSampledTexturesPerShaderStage, maxTextureSize: this._deviceLimits.maxTextureDimension2D, maxCubemapTextureSize: this._deviceLimits.maxTextureDimension2D, maxRenderTextureSize: this._deviceLimits.maxTextureDimension2D, maxVertexAttribs: this._deviceLimits.maxVertexAttributes, maxVaryingVectors: this._deviceLimits.maxInterStageShaderVariables, maxFragmentUniformVectors: Math.floor(this._deviceLimits.maxUniformBufferBindingSize / 4), maxVertexUniformVectors: Math.floor(this._deviceLimits.maxUniformBufferBindingSize / 4), standardDerivatives: !0, astc: this._deviceEnabledExtensions.indexOf(Lo.TextureCompressionASTC) >= 0 || void 0, s3tc: this._deviceEnabledExtensions.indexOf(Lo.TextureCompressionBC) >= 0 || void 0, pvrtc: null, etc1: null, etc2: this._deviceEnabledExtensions.indexOf(Lo.TextureCompressionETC2) >= 0 || void 0, bptc: this._deviceEnabledExtensions.indexOf(Lo.TextureCompressionBC) >= 0 || void 0, maxAnisotropy: 16, uintIndices: !0, fragmentDepthSupported: !0, highPrecisionShaderSupported: !0, colorBufferFloat: !0, supportFloatTexturesResolve: !1, textureFloat: !0, textureFloatLinearFiltering: this._deviceEnabledExtensions.indexOf(Lo.Float32Filterable) >= 0, textureFloatRender: !0, textureHalfFloat: !0, textureHalfFloatLinearFiltering: !0, textureHalfFloatRender: !0, textureLOD: !0, texelFetch: !0, drawBuffersExtension: !0, depthTextureExtension: !0, vertexArrayObject: !1, instancedArrays: !0, timerQuery: typeof BigUint64Array < "u" && this._deviceEnabledExtensions.indexOf(Lo.TimestampQuery) !== -1 || void 0, supportOcclusionQuery: typeof BigUint64Array < "u", canUseTimestampForTimerQuery: !0, multiview: !1, oculusMultiview: !1, parallelShaderCompile: void 0, blendMinMax: !0, maxMSAASamples: 4, canUseGLInstanceID: !0, canUseGLVertexID: !0, supportComputeShaders: !0, supportSRGBBuffers: !0, supportTransformFeedbacks: !1, textureMaxLevel: !0, texture2DArrayMaxLayerCount: this._deviceLimits.maxTextureArrayLayers, disableMorphTargetTexture: !1 }, this._caps.parallelShaderCompile = null, this._features = { forceBitmapOverHTMLImageElement: !0, supportRenderAndCopyToLodForFloatTextures: !0, supportDepthStencilTexture: !0, supportShadowSamplers: !0, uniformBufferHardCheckMatrix: !1, allowTexturePrefiltering: !0, trackUbosInFrame: !0, checkUbosContentBeforeUpload: !0, supportCSM: !0, basisNeedsPOT: !1, support3DTextures: !0, needTypeSuffixInShaderConstants: !0, supportMSAA: !0, supportSSAO2: !0, supportExtendedTextureFormats: !0, supportSwitchCaseInShader: !0, supportSyncTextureRead: !1, needsInvertingBitmap: !1, useUBOBindingCache: !1, needShaderCodeInlining: !0, needToAlwaysBindUniformBuffers: !0, supportRenderPasses: !0, supportSpriteInstancing: !0, forceVertexBufferStrideMultiple4Bytes: !0, _collectUbosUpdatedInFrame: !1 };
      }, t.prototype._initializeContextAndSwapChain = function() {
        if (!this._renderingCanvas)
          throw "The rendering canvas has not been set!";
        this._context = this._renderingCanvas.getContext("webgpu"), this._configureContext(), this._colorFormat = this._options.swapChainFormat, this._mainRenderPassWrapper.colorAttachmentGPUTextures = [new Zf()], this._mainRenderPassWrapper.colorAttachmentGPUTextures[0].format = this._colorFormat, this._setColorFormat(this._mainRenderPassWrapper);
      }, t.prototype._initializeMainAttachments = function() {
        if (this._bufferManager) {
          this.flushFramebuffer(), this._mainTextureExtends = { width: this.getRenderWidth(!0), height: this.getRenderHeight(!0), depthOrArrayLayers: 1 };
          var e, i = new Float32Array([this.getRenderHeight(!0)]);
          if (this._bufferManager.setSubData(this._ubInvertY, 4, i), this._bufferManager.setSubData(this._ubDontInvertY, 4, i), this._options.antialias) {
            var r = { label: "Texture_MainColor_".concat(this._mainTextureExtends.width, "x").concat(this._mainTextureExtends.height, "_antialiasing"), size: this._mainTextureExtends, mipLevelCount: 1, sampleCount: this._mainPassSampleCount, dimension: Ir.E2d, format: this._options.swapChainFormat, usage: fi.RenderAttachment };
            this._mainTexture && this._textureHelper.releaseTexture(this._mainTexture), this._mainTexture = this._device.createTexture(r), e = [{ view: this._mainTexture.createView({ label: "TextureView_MainColor_antialiasing", dimension: Ir.E2d, format: this._options.swapChainFormat, mipLevelCount: 1, arrayLayerCount: 1 }), clearValue: new Ie(0, 0, 0, 1), loadOp: ji.Clear, storeOp: pr.Store }];
          } else
            e = [{ view: void 0, clearValue: new Ie(0, 0, 0, 1), loadOp: ji.Clear, storeOp: pr.Store }];
          this._mainRenderPassWrapper.depthTextureFormat = this.isStencilEnable ? U.Depth24PlusStencil8 : U.Depth32Float, this._setDepthTextureFormat(this._mainRenderPassWrapper), this._setColorFormat(this._mainRenderPassWrapper);
          var o = { label: "Texture_MainDepthStencil_".concat(this._mainTextureExtends.width, "x").concat(this._mainTextureExtends.height), size: this._mainTextureExtends, mipLevelCount: 1, sampleCount: this._mainPassSampleCount, dimension: Ir.E2d, format: this._mainRenderPassWrapper.depthTextureFormat, usage: fi.RenderAttachment };
          this._depthTexture && this._textureHelper.releaseTexture(this._depthTexture), this._depthTexture = this._device.createTexture(o);
          var a = { view: this._depthTexture.createView({ label: "TextureView_MainDepthStencil_".concat(this._mainTextureExtends.width, "x").concat(this._mainTextureExtends.height), dimension: Ir.E2d, format: this._depthTexture.format, mipLevelCount: 1, arrayLayerCount: 1 }), depthClearValue: this._clearDepthValue, depthLoadOp: ji.Clear, depthStoreOp: pr.Store, stencilClearValue: this._clearStencilValue, stencilLoadOp: this.isStencilEnable ? ji.Clear : void 0, stencilStoreOp: this.isStencilEnable ? pr.Store : void 0 };
          this._mainRenderPassWrapper.renderPassDescriptor = { label: "MainRenderPass", colorAttachments: e, depthStencilAttachment: a };
        }
      }, t.prototype._configureContext = function() {
        this._context.configure({ device: this._device, format: this._options.swapChainFormat, usage: fi.RenderAttachment | fi.CopySrc, alphaMode: this.premultipliedAlpha ? Gc.Premultiplied : Gc.Opaque });
      }, t.prototype.setSize = function(e, i, r) {
        return r === void 0 && (r = !1), !!n.prototype.setSize.call(this, e, i, r) && (this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0), (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - setSize -", e, i)), this._initializeMainAttachments(), this.snapshotRendering && this.snapshotRenderingReset(), !0);
      }, t.prototype._getShaderProcessor = function(e) {
        return e === li.WGSL ? this._shaderProcessorWGSL : this._shaderProcessor;
      }, t.prototype._getShaderProcessingContext = function(e) {
        return new kh(e);
      }, t.prototype._currentPassIsMainPass = function() {
        return this._currentRenderTarget === null;
      }, t.prototype._getCurrentRenderPass = function() {
        return this._currentRenderTarget && !this._currentRenderPass ? this._startRenderTargetRenderPass(this._currentRenderTarget, !1, null, !1, !1) : this._currentRenderPass || this._startMainRenderPass(!1), this._currentRenderPass;
      }, t.prototype._getCurrentRenderPassWrapper = function() {
        return this._currentRenderTarget ? this._rttRenderPassWrapper : this._mainRenderPassWrapper;
      }, t.prototype.applyStates = function() {
        this._stencilStateComposer.apply(), this._cacheRenderPipeline.setAlphaBlendEnabled(this._alphaState.alphaBlend);
      }, t.prototype.wipeCaches = function(e) {
        this.preventCacheWipeBetweenFrames && !e || (this._forceEnableEffect = !0, this._currentIndexBuffer = null, this._currentOverrideVertexBuffers = null, this._cacheRenderPipeline.setBuffers(null, null, null), e && (this._stencilStateComposer.reset(), this._depthCullingState.reset(), this._depthCullingState.depthFunc = _.LEQUAL, this._alphaState.reset(), this._alphaMode = _.ALPHA_ADD, this._alphaEquation = _.ALPHA_DISABLE, this._cacheRenderPipeline.setAlphaBlendFactors(this._alphaState._blendFunctionParameters, this._alphaState._blendEquationParameters), this._cacheRenderPipeline.setAlphaBlendEnabled(!1), this.setColorWrite(!0)), this._cachedVertexBuffers = null, this._cachedIndexBuffer = null, this._cachedEffectForVertexBuffers = null);
      }, t.prototype.setColorWrite = function(e) {
        this._colorWriteLocal = e, this._cacheRenderPipeline.setWriteMask(e ? 15 : 0);
      }, t.prototype.getColorWrite = function() {
        return this._colorWriteLocal;
      }, t.prototype._mustUpdateViewport = function() {
        var e = this._viewportCached.x, i = this._viewportCached.y, r = this._viewportCached.z, o = this._viewportCached.w, a = this._viewportsCurrent.x !== e || this._viewportsCurrent.y !== i || this._viewportsCurrent.w !== r || this._viewportsCurrent.h !== o;
        return a && (this._viewportsCurrent.x = this._viewportCached.x, this._viewportsCurrent.y = this._viewportCached.y, this._viewportsCurrent.w = this._viewportCached.z, this._viewportsCurrent.h = this._viewportCached.w), a;
      }, t.prototype._applyViewport = function(e) {
        var i = Math.floor(this._viewportCached.x), r = Math.floor(this._viewportCached.z), o = Math.floor(this._viewportCached.w), a = Math.floor(this._viewportCached.y);
        this._currentRenderTarget || (a = this.getRenderHeight(!0) - a - o), e ? e.addItem(new AD(i, a, r, o)) : this._getCurrentRenderPass().setViewport(i, a, r, o, 0, 1), this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0), (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - viewport applied - (", this._viewportCached.x, this._viewportCached.y, this._viewportCached.z, this._viewportCached.w, ") current pass is main pass=" + this._currentPassIsMainPass()));
      }, t.prototype._viewport = function(e, i, r, o) {
        this._viewportCached.x = e, this._viewportCached.y = i, this._viewportCached.z = r, this._viewportCached.w = o;
      }, t.prototype._mustUpdateScissor = function() {
        var e = this._scissorCached.x, i = this._scissorCached.y, r = this._scissorCached.z, o = this._scissorCached.w, a = this._scissorsCurrent.x !== e || this._scissorsCurrent.y !== i || this._scissorsCurrent.w !== r || this._scissorsCurrent.h !== o;
        return a && (this._scissorsCurrent.x = this._scissorCached.x, this._scissorsCurrent.y = this._scissorCached.y, this._scissorsCurrent.w = this._scissorCached.z, this._scissorsCurrent.h = this._scissorCached.w), a;
      }, t.prototype._applyScissor = function(e) {
        var i = this._currentRenderTarget ? this._scissorCached.y : this.getRenderHeight() - this._scissorCached.w - this._scissorCached.y;
        e ? e.addItem(new RD(this._scissorCached.x, i, this._scissorCached.z, this._scissorCached.w)) : this._getCurrentRenderPass().setScissorRect(this._scissorCached.x, i, this._scissorCached.z, this._scissorCached.w), this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0), (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - scissor applied - (", this._scissorCached.x, this._scissorCached.y, this._scissorCached.z, this._scissorCached.w, ") current pass is main pass=" + this._currentPassIsMainPass()));
      }, t.prototype._scissorIsActive = function() {
        return this._scissorCached.x !== 0 || this._scissorCached.y !== 0 || this._scissorCached.z !== 0 || this._scissorCached.w !== 0;
      }, t.prototype.enableScissor = function(e, i, r, o) {
        this._scissorCached.x = e, this._scissorCached.y = i, this._scissorCached.z = r, this._scissorCached.w = o;
      }, t.prototype.disableScissor = function() {
        this._scissorCached.x = this._scissorCached.y = this._scissorCached.z = this._scissorCached.w = 0, this._scissorsCurrent.x = this._scissorsCurrent.y = this._scissorsCurrent.w = this._scissorsCurrent.h = 0;
      }, t.prototype._mustUpdateStencilRef = function() {
        var e = this._stencilStateComposer.funcRef !== this._stencilRefsCurrent;
        return e && (this._stencilRefsCurrent = this._stencilStateComposer.funcRef), e;
      }, t.prototype._applyStencilRef = function(e) {
        var i, r;
        e ? e.addItem(new RC((i = this._stencilStateComposer.funcRef) !== null && i !== void 0 ? i : 0)) : this._getCurrentRenderPass().setStencilReference((r = this._stencilStateComposer.funcRef) !== null && r !== void 0 ? r : 0);
      }, t.prototype._mustUpdateBlendColor = function() {
        var e = this._alphaState._blendConstants, i = e[0] !== this._blendColorsCurrent[0] || e[1] !== this._blendColorsCurrent[1] || e[2] !== this._blendColorsCurrent[2] || e[3] !== this._blendColorsCurrent[3];
        return i && (this._blendColorsCurrent[0] = e[0], this._blendColorsCurrent[1] = e[1], this._blendColorsCurrent[2] = e[2], this._blendColorsCurrent[3] = e[3]), i;
      }, t.prototype._applyBlendColor = function(e) {
        e ? e.addItem(new CD(this._alphaState._blendConstants.slice())) : this._getCurrentRenderPass().setBlendConstant(this._alphaState._blendConstants);
      }, t.prototype._resetRenderPassStates = function() {
        this._viewportsCurrent.x = this._viewportsCurrent.y = this._viewportsCurrent.w = this._viewportsCurrent.h = 0, this._scissorsCurrent.x = this._scissorsCurrent.y = this._scissorsCurrent.w = this._scissorsCurrent.h = 0, this._stencilRefsCurrent = -1, this._blendColorsCurrent[0] = this._blendColorsCurrent[1] = this._blendColorsCurrent[2] = this._blendColorsCurrent[3] = null;
      }, t.prototype.clear = function(e, i, r, o) {
        o === void 0 && (o = !1), e && e.a === void 0 && (e.a = 1);
        var a = this._scissorIsActive();
        this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0), (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - clear - backBuffer=", i, " depth=", r, " stencil=", o, " scissor is active=", a)), this._currentRenderTarget ? a ? (this._currentRenderPass || this._startRenderTargetRenderPass(this._currentRenderTarget, !1, i ? e : null, r, o), this._applyScissor(this.compatibilityMode ? null : this._bundleList), this._clearFullQuad(i ? e : null, r, o)) : (this._currentRenderPass && this._endCurrentRenderPass(), this._startRenderTargetRenderPass(this._currentRenderTarget, !0, i ? e : null, r, o)) : (this._currentRenderPass && a || this._startMainRenderPass(!a, i ? e : null, r, o), a && (this._applyScissor(this.compatibilityMode ? null : this._bundleList), this._clearFullQuad(i ? e : null, r, o)));
      }, t.prototype._clearFullQuad = function(e, i, r) {
        var o, a, s = this.compatibilityMode ? this._getCurrentRenderPass() : null;
        this._clearQuad.setColorFormat(this._colorFormat), this._clearQuad.setDepthStencilFormat(this._depthTextureFormat), this._clearQuad.setMRTAttachments((o = this._cacheRenderPipeline.mrtAttachments) !== null && o !== void 0 ? o : [], (a = this._cacheRenderPipeline.mrtTextureArray) !== null && a !== void 0 ? a : [], this._cacheRenderPipeline.mrtTextureCount), this.compatibilityMode ? s.setStencilReference(this._clearStencilValue) : this._bundleList.addItem(new RC(this._clearStencilValue));
        var l = this._clearQuad.clear(s, e, i, r, this.currentSampleCount);
        this.compatibilityMode ? this._applyStencilRef(null) : (this._bundleList.addBundle(l), this._applyStencilRef(this._bundleList), this._reportDrawCall());
      }, t.prototype.createVertexBuffer = function(e, i, r) {
        var o;
        return o = e instanceof Array ? new Float32Array(e) : e instanceof ArrayBuffer ? new Uint8Array(e) : e, this._bufferManager.createBuffer(o, $t.Vertex | $t.CopyDst, r);
      }, t.prototype.createDynamicVertexBuffer = function(e, i) {
        return this.createVertexBuffer(e, void 0, i);
      }, t.prototype.createIndexBuffer = function(e, i, r) {
        var o, a = !0;
        e instanceof Uint32Array || e instanceof Int32Array ? o = e : e instanceof Uint16Array ? (o = e, a = !1) : e.length > 65535 ? o = new Uint32Array(e) : (o = new Uint16Array(e), a = !1);
        var s = this._bufferManager.createBuffer(o, $t.Index | $t.CopyDst, r);
        return s.is32Bits = a, s;
      }, t.prototype._createBuffer = function(e, i, r) {
        var o;
        o = e instanceof Array ? new Float32Array(e) : e instanceof ArrayBuffer ? new Uint8Array(e) : e;
        var a = 0;
        return i & _.BUFFER_CREATIONFLAG_READ && (a |= $t.CopySrc), i & _.BUFFER_CREATIONFLAG_WRITE && (a |= $t.CopyDst), i & _.BUFFER_CREATIONFLAG_UNIFORM && (a |= $t.Uniform), i & _.BUFFER_CREATIONFLAG_VERTEX && (a |= $t.Vertex), i & _.BUFFER_CREATIONFLAG_INDEX && (a |= $t.Index), i & _.BUFFER_CREATIONFLAG_STORAGE && (a |= $t.Storage), this._bufferManager.createBuffer(o, a, r);
      }, t.prototype.bindBuffersDirectly = function() {
        throw "Not implemented on WebGPU";
      }, t.prototype.updateAndBindInstancesBuffer = function() {
        throw "Not implemented on WebGPU";
      }, t.prototype.bindBuffers = function(e, i, r, o) {
        this._currentIndexBuffer = i, this._currentOverrideVertexBuffers = o ?? null, this._cacheRenderPipeline.setBuffers(e, i, this._currentOverrideVertexBuffers);
      }, t.prototype._releaseBuffer = function(e) {
        return this._bufferManager.releaseBuffer(e);
      }, t.prototype.createEffect = function(e, i, r, o, a, s, l, c, u, h) {
        var d;
        h === void 0 && (h = li.GLSL);
        var p = e.vertexElement || e.vertex || e.vertexToken || e.vertexSource || e, f = e.fragmentElement || e.fragment || e.fragmentToken || e.fragmentSource || e, m = this._getGlobalDefines(), g = (d = a ?? i.defines) !== null && d !== void 0 ? d : "";
        m && (g += `
` + m);
        var y = p + "+" + f + "@" + g;
        if (this._compiledEffects[y]) {
          var b = this._compiledEffects[y];
          return l && b.isReady() && l(b), b;
        }
        var T = new Jt(e, i, r, o, this, a, s, l, c, u, y, h);
        return this._compiledEffects[y] = T, T;
      }, t.prototype._compileRawShaderToSpirV = function(e, i) {
        return this._glslang.compileGLSL(e, i);
      }, t.prototype._compileShaderToSpirV = function(e, i, r, o) {
        return this._compileRawShaderToSpirV(o + (r ? r + `
` : "") + e, i);
      }, t.prototype._getWGSLShader = function(e, i, r) {
        return (r = r ? "//" + r.split(`
`).join(`
//`) + `
` : "") + e;
      }, t.prototype._createPipelineStageDescriptor = function(e, i, r, o, a) {
        return this._tintWASM && r === li.GLSL && (e = this._tintWASM.convertSpirV2WGSL(e, o), i = this._tintWASM.convertSpirV2WGSL(i, a)), { vertexStage: { module: this._device.createShaderModule({ code: e }), entryPoint: "main" }, fragmentStage: { module: this._device.createShaderModule({ code: i }), entryPoint: "main" } };
      }, t.prototype._compileRawPipelineStageDescriptor = function(e, i, r) {
        var o = e.indexOf(n_) >= 0, a = i.indexOf(n_) >= 0, s = r === li.GLSL ? this._compileRawShaderToSpirV(e, "vertex") : e, l = r === li.GLSL ? this._compileRawShaderToSpirV(i, "fragment") : i;
        return this._createPipelineStageDescriptor(s, l, r, o, a);
      }, t.prototype._compilePipelineStageDescriptor = function(e, i, r, o) {
        this.onBeforeShaderCompilationObservable.notifyObservers(this);
        var a = e.indexOf(n_) >= 0, s = i.indexOf(n_) >= 0, l = `#version 450
`, c = o === li.GLSL ? this._compileShaderToSpirV(e, "vertex", r, l) : this._getWGSLShader(e, "vertex", r), u = o === li.GLSL ? this._compileShaderToSpirV(i, "fragment", r, l) : this._getWGSLShader(i, "fragment", r), h = this._createPipelineStageDescriptor(c, u, o, a, s);
        return this.onAfterShaderCompilationObservable.notifyObservers(this), h;
      }, t.prototype.createRawShaderProgram = function() {
        throw "Not available on WebGPU";
      }, t.prototype.createShaderProgram = function() {
        throw "Not available on WebGPU";
      }, t.prototype.inlineShaderCode = function(e) {
        var i = new Bc(e);
        return i.debug = !1, i.processCode(), i.code;
      }, t.prototype.createPipelineContext = function(e) {
        return new hD(e, this);
      }, t.prototype.createMaterialContext = function() {
        return new SD();
      }, t.prototype.createDrawContext = function() {
        return new ly(this._bufferManager);
      }, t.prototype._preparePipelineContext = function(e, i, r, o, a, s, l, c) {
        var u = e, h = u.shaderProcessingContext.shaderLanguage;
        this.dbgShowShaderCode && (console.log(c), console.log(i), console.log(r), console.log("***********************************************")), u.sources = { fragment: r, vertex: i, rawVertex: a, rawFragment: s }, u.stages = o ? this._compileRawPipelineStageDescriptor(i, r, h) : this._compilePipelineStageDescriptor(i, r, c, h);
      }, t.prototype.getAttributes = function(e, i) {
        for (var r = new Array(i.length), o = e, a = 0; a < i.length; a++) {
          var s = i[a], l = o.shaderProcessingContext.availableAttributes[s];
          l !== void 0 && (r[a] = l);
        }
        return r;
      }, t.prototype.enableEffect = function(e) {
        if (e) {
          var i = !0;
          if (Ei.IsWrapper(e)) {
            if (!e.effect || e.effect === this._currentEffect && e.materialContext === this._currentMaterialContext && e.drawContext === this._currentDrawContext && !this._forceEnableEffect) {
              if (!e.effect && this.dbgShowEmptyEnableEffectCalls)
                throw console.error("drawWrapper=", e), "Invalid call to enableEffect: the effect property is empty!";
              return;
            }
            if (i = e.effect !== this._currentEffect, this._currentEffect = e.effect, this._currentMaterialContext = e.materialContext, this._currentDrawContext = e.drawContext, this._counters.numEnableDrawWrapper++, !this._currentMaterialContext)
              throw console.error("drawWrapper=", e), "Invalid call to enableEffect: the materialContext property is empty!";
          } else
            i = e !== this._currentEffect, this._currentEffect = e, this._currentMaterialContext = this._defaultMaterialContext, this._currentDrawContext = this._defaultDrawContext, this._counters.numEnableEffects++, this.dbgLogIfNotDrawWrapper && q.Warn("enableEffect has been called with an Effect and not a Wrapper! effect.uniqueId=".concat(e.uniqueId, ", effect.name=").concat(e.name, ", effect.name.vertex=").concat(e.name.vertex, ", effect.name.fragment=").concat(e.name.fragment), 10);
          this._stencilStateComposer.stencilMaterial = void 0, this._forceEnableEffect = !i && !this._forceEnableEffect && this._forceEnableEffect, i && (this._currentEffect.onBind && this._currentEffect.onBind(this._currentEffect), this._currentEffect._onBindObservable && this._currentEffect._onBindObservable.notifyObservers(this._currentEffect));
        }
      }, t.prototype._releaseEffect = function(e) {
        this._compiledEffects[e._key] && (delete this._compiledEffects[e._key], this._deletePipelineContext(e.getPipelineContext()));
      }, t.prototype.releaseEffects = function() {
        for (var e in this._compiledEffects) {
          var i = this._compiledEffects[e].getPipelineContext();
          this._deletePipelineContext(i);
        }
        this._compiledEffects = {};
      }, t.prototype._deletePipelineContext = function(e) {
        e && e.dispose();
      }, Object.defineProperty(t.prototype, "needPOTTextures", { get: function() {
        return !1;
      }, enumerable: !1, configurable: !0 }), t.prototype._createHardwareTexture = function() {
        return new Zf();
      }, t.prototype._releaseTexture = function(e) {
        var i = this._internalTexturesCache.indexOf(e);
        i !== -1 && this._internalTexturesCache.splice(i, 1), this._textureHelper.releaseTexture(e);
      }, t.prototype._getRGBABufferInternalSizedFormat = function() {
        return _.TEXTUREFORMAT_RGBA;
      }, t.prototype.updateTextureComparisonFunction = function(e, i) {
        e._comparisonFunction = i;
      }, t.prototype._createInternalTexture = function(e, i, r, o) {
        var a, s, l;
        r === void 0 && (r = !0), o === void 0 && (o = ut.Unknown);
        var c = {};
        i !== void 0 && typeof i == "object" ? (c.generateMipMaps = i.generateMipMaps, c.type = i.type === void 0 ? _.TEXTURETYPE_UNSIGNED_INT : i.type, c.samplingMode = i.samplingMode === void 0 ? _.TEXTURE_TRILINEAR_SAMPLINGMODE : i.samplingMode, c.format = i.format === void 0 ? _.TEXTUREFORMAT_RGBA : i.format, c.samples = (a = i.samples) !== null && a !== void 0 ? a : 1, c.creationFlags = (s = i.creationFlags) !== null && s !== void 0 ? s : 0, c.useSRGBBuffer = (l = i.useSRGBBuffer) !== null && l !== void 0 && l, c.label = i.label) : (c.generateMipMaps = i, c.type = _.TEXTURETYPE_UNSIGNED_INT, c.samplingMode = _.TEXTURE_TRILINEAR_SAMPLINGMODE, c.format = _.TEXTUREFORMAT_RGBA, c.samples = 1, c.creationFlags = 0, c.useSRGBBuffer = !1), (c.type !== _.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (c.type !== _.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (c.samplingMode = _.TEXTURE_NEAREST_SAMPLINGMODE), c.type !== _.TEXTURETYPE_FLOAT || this._caps.textureFloat || (c.type = _.TEXTURETYPE_UNSIGNED_INT, q.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));
        var u = new Ut(this, o), h = e.width || e, d = e.height || e, p = e.layers || 0;
        return u.baseWidth = h, u.baseHeight = d, u.width = h, u.height = d, u.depth = p, u.isReady = !0, u.samples = c.samples, u.generateMipMaps = !!c.generateMipMaps, u.samplingMode = c.samplingMode, u.type = c.type, u.format = c.format, u.is2DArray = p > 0, u._cachedWrapU = _.TEXTURE_CLAMP_ADDRESSMODE, u._cachedWrapV = _.TEXTURE_CLAMP_ADDRESSMODE, u._useSRGBBuffer = c.useSRGBBuffer, u.label = c.label, this._internalTexturesCache.push(u), r || this._textureHelper.createGPUTextureForInternalTexture(u, h, d, p || 1, c.creationFlags), u;
      }, t.prototype.createTexture = function(e, i, r, o, a, s, l, c, u, h, d, p, f, m, g) {
        var y = this;
        return a === void 0 && (a = _.TEXTURE_TRILINEAR_SAMPLINGMODE), s === void 0 && (s = null), l === void 0 && (l = null), c === void 0 && (c = null), u === void 0 && (u = null), h === void 0 && (h = null), d === void 0 && (d = null), this._createTextureBase(e, i, r, o, a, s, l, function(b, T, S, E, A, R, C, L) {
          var I, O = E;
          if (b.baseWidth = O.width, b.baseHeight = O.height, b.width = O.width, b.height = O.height, b.format = b.format !== -1 ? b.format : h ?? _.TEXTUREFORMAT_RGBA, b.type = b.type !== -1 ? b.type : _.TEXTURETYPE_UNSIGNED_BYTE, L(b.width, b.height, O, T, b, function() {
          }), (I = b._hardwareTexture) === null || I === void 0 ? void 0 : I.underlyingResource)
            R || C || y._generateMipmaps(b, y._uploadEncoder);
          else {
            var w = y._textureHelper.createGPUTextureForInternalTexture(b, O.width, O.height, void 0, m);
            kr.IsImageBitmap(O) && (y._textureHelper.updateTexture(O, b, O.width, O.height, b.depth, w.format, 0, 0, A, !1, 0, 0), R || C || y._generateMipmaps(b, y._uploadEncoder));
          }
          S && S.removePendingData(b), b.isReady = !0, b.onLoadedObservable.notifyObservers(b), b.onLoadedObservable.clear();
        }, function() {
          return !1;
        }, c, u, h, d, p, f, g);
      }, t.prototype.wrapWebGPUTexture = function(e) {
        var i = new Zf(e), r = new Ut(this, ut.Unknown, !0);
        return r._hardwareTexture = i, r.isReady = !0, r;
      }, t.prototype.wrapWebGLTexture = function() {
        throw new Error("wrapWebGLTexture is not supported, use wrapWebGPUTexture instead.");
      }, t.prototype.generateMipMapsForCubemap = function(e) {
        var i;
        e.generateMipMaps && (!((i = e._hardwareTexture) === null || i === void 0) && i.underlyingResource || this._textureHelper.createGPUTextureForInternalTexture(e), this._generateMipmaps(e));
      }, t.prototype.updateTextureSamplingMode = function(e, i, r) {
        r === void 0 && (r = !1), r && (i.generateMipMaps = !0, this._generateMipmaps(i)), i.samplingMode = e;
      }, t.prototype.updateTextureWrappingMode = function(e, i, r, o) {
        r === void 0 && (r = null), o === void 0 && (o = null), i !== null && (e._cachedWrapU = i), r !== null && (e._cachedWrapV = r), (e.is2DArray || e.is3D) && o !== null && (e._cachedWrapR = o);
      }, t.prototype.updateTextureDimensions = function(e, i, r, o) {
        if (o === void 0 && (o = 1), e._hardwareTexture && (e.width !== i || e.height !== r || e.depth !== o)) {
          var a = e._hardwareTexture.textureAdditionalUsages;
          e._hardwareTexture.release(), this._textureHelper.createGPUTextureForInternalTexture(e, i, r, o, a);
        }
      }, t.prototype._setInternalTexture = function(e, i, r) {
        if (r = r ?? e, this._currentEffect) {
          var o = this._currentEffect._pipelineContext.shaderProcessingContext.availableTextures[r];
          if (this._currentMaterialContext.setTexture(e, i), o && o.autoBindSampler) {
            var a = r + Rn.AutoSamplerSuffix;
            this._currentMaterialContext.setSampler(a, i);
          }
        }
      }, t.prototype.setTexture = function(e, i, r, o) {
        this._setTexture(e, r, !1, !1, o, o);
      }, t.prototype.setTextureArray = function(e, i, r, o) {
        for (var a = 0; a < r.length; a++)
          this._setTexture(-1, r[a], !0, !1, o + a.toString(), o);
      }, t.prototype._setTexture = function(e, i, r, o, a, s) {
        if (o === void 0 && (o = !1), a === void 0 && (a = ""), s = s ?? a, this._currentEffect) {
          if (!i)
            return this._currentMaterialContext.setTexture(a, null), !1;
          if (i.video)
            i.update();
          else if (i.delayLoadState === _.DELAYLOADSTATE_NOTLOADED)
            return i.delayLoad(), !1;
          var l = null;
          if ((l = o ? i.depthStencilTexture : i.isReady() ? i.getInternalTexture() : i.isCube ? this.emptyCubeTexture : i.is3D ? this.emptyTexture3D : i.is2DArray ? this.emptyTexture2DArray : this.emptyTexture) && !l.isMultiview) {
            if (l.isCube && l._cachedCoordinatesMode !== i.coordinatesMode) {
              l._cachedCoordinatesMode = i.coordinatesMode;
              var c = i.coordinatesMode !== _.TEXTURE_CUBIC_MODE && i.coordinatesMode !== _.TEXTURE_SKYBOX_MODE ? _.TEXTURE_WRAP_ADDRESSMODE : _.TEXTURE_CLAMP_ADDRESSMODE;
              i.wrapU = c, i.wrapV = c;
            }
            l._cachedWrapU = i.wrapU, l._cachedWrapV = i.wrapV, l.is3D && (l._cachedWrapR = i.wrapR), this._setAnisotropicLevel(0, l, i.anisotropicFilteringLevel);
          }
          this._setInternalTexture(a, l, s);
        } else
          this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0), (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - _setTexture called with a null _currentEffect! texture=", i));
        return !0;
      }, t.prototype._setAnisotropicLevel = function(e, i, r) {
        i._cachedAnisotropicFilteringLevel !== r && (i._cachedAnisotropicFilteringLevel = Math.min(r, this._caps.maxAnisotropy));
      }, t.prototype._bindTexture = function(e, i, r) {
        e !== void 0 && this._setInternalTexture(r, i);
      }, t.prototype.generateMipmaps = function(e) {
        this._generateMipmaps(e);
      }, t.prototype._generateMipmaps = function(e, i) {
        i = i ?? this._renderEncoder;
        var r = e._hardwareTexture;
        if (r) {
          i === this._renderEncoder && this._endCurrentRenderPass();
          var o = e._hardwareTexture.format, a = kr.ComputeNumMipmapLevels(e.width, e.height);
          this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0), (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - generate mipmaps - width=" + e.width + ", height=" + e.height + ", isCube=" + e.isCube + ", command encoder=" + (i === this._renderEncoder ? "render" : "copy"))), e.isCube ? this._textureHelper.generateCubeMipmaps(r, o, a, i) : this._textureHelper.generateMipmaps(r, o, a, 0, i);
        }
      }, t.prototype.updateTextureData = function(e, i, r, o, a, s, l, c, u) {
        var h;
        l === void 0 && (l = 0), c === void 0 && (c = 0), u === void 0 && (u = !1);
        var d = e._hardwareTexture;
        !((h = e._hardwareTexture) === null || h === void 0) && h.underlyingResource || (d = this._textureHelper.createGPUTextureForInternalTexture(e));
        var p = new Uint8Array(i.buffer, i.byteOffset, i.byteLength);
        this._textureHelper.updateTexture(p, e, a, s, e.depth, d.format, l, c, e.invertY, !1, r, o), u && this._generateMipmaps(e);
      }, t.prototype._uploadCompressedDataToTextureDirectly = function(e, i, r, o, a, s, l) {
        var c;
        s === void 0 && (s = 0), l === void 0 && (l = 0);
        var u = e._hardwareTexture;
        !((c = e._hardwareTexture) === null || c === void 0) && c.underlyingResource || (e.format = i, u = this._textureHelper.createGPUTextureForInternalTexture(e, r, o));
        var h = new Uint8Array(a.buffer, a.byteOffset, a.byteLength);
        this._textureHelper.updateTexture(h, e, r, o, e.depth, u.format, s, l, !1, !1, 0, 0);
      }, t.prototype._uploadDataToTextureDirectly = function(e, i, r, o, a, s) {
        var l;
        r === void 0 && (r = 0), o === void 0 && (o = 0), s === void 0 && (s = !1);
        var c = Math.round(Math.log(e.width) * Math.LOG2E), u = Math.round(Math.log(e.height) * Math.LOG2E), h = s ? e.width : Math.pow(2, Math.max(c - o, 0)), d = s ? e.height : Math.pow(2, Math.max(u - o, 0)), p = e._hardwareTexture;
        !((l = e._hardwareTexture) === null || l === void 0) && l.underlyingResource || (p = this._textureHelper.createGPUTextureForInternalTexture(e, h, d));
        var f = new Uint8Array(i.buffer, i.byteOffset, i.byteLength);
        this._textureHelper.updateTexture(f, e, h, d, e.depth, p.format, r, o, e.invertY, !1, 0, 0);
      }, t.prototype._uploadArrayBufferViewToTexture = function(e, i, r, o) {
        r === void 0 && (r = 0), o === void 0 && (o = 0), this._uploadDataToTextureDirectly(e, i, r, o);
      }, t.prototype._uploadImageToTexture = function(e, i, r, o) {
        var a;
        r === void 0 && (r = 0), o === void 0 && (o = 0);
        var s = e._hardwareTexture;
        if (!((a = e._hardwareTexture) === null || a === void 0) && a.underlyingResource || (s = this._textureHelper.createGPUTextureForInternalTexture(e)), i instanceof HTMLImageElement)
          throw "WebGPU engine: HTMLImageElement not supported in _uploadImageToTexture!";
        var l = i, c = Math.ceil(e.width / (1 << o)), u = Math.ceil(e.height / (1 << o));
        this._textureHelper.updateTexture(l, e, c, u, e.depth, s.format, r, o, e.invertY, !1, 0, 0);
      }, t.prototype.readPixels = function(e, i, r, o, a, s) {
        s === void 0 && (s = !0);
        var l = this._getCurrentRenderPassWrapper().colorAttachmentGPUTextures[0];
        if (!l)
          return Promise.resolve(new Uint8Array(0));
        var c = l.underlyingResource, u = l.format;
        return c ? (s && this.flushFramebuffer(), this._textureHelper.readPixels(c, e, i, r, o, u)) : Promise.resolve(new Uint8Array(0));
      }, t.prototype.beginFrame = function() {
        n.prototype.beginFrame.call(this);
      }, t.prototype.endFrame = function() {
        if (this._endCurrentRenderPass(), this._snapshotRendering.endFrame(), this._timestampQuery.endFrame(this._renderEncoder), this.flushFramebuffer(), this._textureHelper.destroyDeferredTextures(), this._bufferManager.destroyDeferredBuffers(), this._features._collectUbosUpdatedInFrame) {
          if (this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0), !this._count || this._count < this.dbgVerboseLogsNumFrames)) {
            var e = [];
            for (var i in Er._UpdatedUbosInFrame)
              e.push(i + ":" + Er._UpdatedUbosInFrame[i]);
            console.log("frame #" + this._count + " - updated ubos -", e.join(", "));
          }
          Er._UpdatedUbosInFrame = {};
        }
        this.countersLastFrame.numEnableEffects = this._counters.numEnableEffects, this.countersLastFrame.numEnableDrawWrapper = this._counters.numEnableDrawWrapper, this.countersLastFrame.numBundleCreationNonCompatMode = this._counters.numBundleCreationNonCompatMode, this.countersLastFrame.numBundleReuseNonCompatMode = this._counters.numBundleReuseNonCompatMode, this._counters.numEnableEffects = 0, this._counters.numEnableDrawWrapper = 0, this._counters.numBundleCreationNonCompatMode = 0, this._counters.numBundleReuseNonCompatMode = 0, this._cacheRenderPipeline.endFrame(), this._cacheBindGroups.endFrame(), this._pendingDebugCommands.length = 0, n.prototype.endFrame.call(this), this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0), this._count < this.dbgVerboseLogsNumFrames && console.log("%c frame #" + this._count + " - end", "background: #ffff00"), this._count < this.dbgVerboseLogsNumFrames && (this._count++, this._count !== this.dbgVerboseLogsNumFrames && console.log("%c frame #" + this._count + " - begin", "background: #ffff00")));
      }, t.prototype.flushFramebuffer = function() {
        this._endCurrentRenderPass(), this._commandBuffers[0] = this._uploadEncoder.finish(), this._commandBuffers[1] = this._renderEncoder.finish(), this._device.queue.submit(this._commandBuffers), this._uploadEncoder = this._device.createCommandEncoder(this._uploadEncoderDescriptor), this._renderEncoder = this._device.createCommandEncoder(this._renderEncoderDescriptor), this._timestampQuery.startFrame(this._uploadEncoder), this._textureHelper.setCommandEncoder(this._uploadEncoder), this._bundleList.reset();
      }, t.prototype._currentFrameBufferIsDefaultFrameBuffer = function() {
        return this._currentPassIsMainPass();
      }, t.prototype._startRenderTargetRenderPass = function(e, i, r, o, a) {
        var s, l, c, u, h, d, p, f;
        this._endCurrentRenderPass();
        var m = e, g = m._depthStencilTexture, y = g == null ? void 0 : g._hardwareTexture, b = y == null ? void 0 : y.underlyingResource, T = y == null ? void 0 : y.getMSAATexture(), S = b == null ? void 0 : b.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor), E = T == null ? void 0 : T.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor), A = !!y && kr.HasStencilAspect(y.format), R = [];
        this.useReverseDepthBuffer && this.setDepthFunctionToGreaterOrEqual();
        var C = wD;
        r && (C.r = 255 * r.r, C.g = 255 * r.g, C.b = 255 * r.b, C.a = 255 * r.a);
        var L = i && r, I = i && o, O = i && a;
        if (m._attachments && m.isMulti) {
          this._mrtAttachments && this._mrtAttachments.length !== 0 || (this._mrtAttachments = m._defaultAttachments);
          for (var w = 0; w < this._mrtAttachments.length; ++w) {
            var z = this._mrtAttachments[w], V = m.textures[w], Y = V == null ? void 0 : V._hardwareTexture, ee = Y == null ? void 0 : Y.underlyingResource;
            if (Y && ee) {
              var J = Y.getMSAATexture(w), X = (l = (s = m.layerIndices) === null || s === void 0 ? void 0 : s[w]) !== null && l !== void 0 ? l : 0, K = (u = (c = m.faceIndices) === null || c === void 0 ? void 0 : c[w]) !== null && u !== void 0 ? u : 0, te = je(je({}, this._rttRenderPassWrapper.colorAttachmentViewDescriptor), { format: Y.format, baseArrayLayer: V.isCube ? 6 * X + K : X }), se = je(je({}, this._rttRenderPassWrapper.colorAttachmentViewDescriptor), { format: Y.format, baseArrayLayer: 0 }), _e = V.type === _.TEXTURETYPE_UNSIGNED_INTEGER || V.type === _.TEXTURETYPE_UNSIGNED_SHORT, xe = ee.createView(te), Te = J == null ? void 0 : J.createView(se);
              R.push({ view: Te || xe, resolveTarget: J ? xe : void 0, clearValue: z !== 0 && L ? _e ? C : r : void 0, loadOp: z !== 0 && L ? ji.Clear : ji.Load, storeOp: pr.Store });
            }
          }
          this._cacheRenderPipeline.setMRT(m.textures, this._mrtAttachments.length), this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments);
        } else if (Fe = m.texture) {
          var he = Fe._hardwareTexture, me = he.underlyingResource;
          J = he.getMSAATexture(), xe = me.createView(this._rttRenderPassWrapper.colorAttachmentViewDescriptor), Te = J == null ? void 0 : J.createView(this._rttRenderPassWrapper.colorAttachmentViewDescriptor), _e = Fe.type === _.TEXTURETYPE_UNSIGNED_INTEGER || Fe.type === _.TEXTURETYPE_UNSIGNED_SHORT, R.push({ view: Te || xe, resolveTarget: J ? xe : void 0, clearValue: L ? _e ? C : r : void 0, loadOp: L ? ji.Clear : ji.Load, storeOp: pr.Store });
        } else
          R.push(null);
        if ((h = this._debugPushGroup) === null || h === void 0 || h.call(this, "render target pass", 1), this._rttRenderPassWrapper.renderPassDescriptor = { label: ((d = e.label) !== null && d !== void 0 ? d : "RTT") + "RenderPass", colorAttachments: R, depthStencilAttachment: g && b ? { view: E || S, depthClearValue: I ? this.useReverseDepthBuffer ? this._clearReverseDepthValue : this._clearDepthValue : void 0, depthLoadOp: I ? ji.Clear : ji.Load, depthStoreOp: pr.Store, stencilClearValue: m._depthStencilTextureWithStencil && O ? this._clearStencilValue : void 0, stencilLoadOp: A ? m._depthStencilTextureWithStencil && O ? ji.Clear : ji.Load : void 0, stencilStoreOp: A ? pr.Store : void 0 } : void 0, occlusionQuerySet: !((p = this._occlusionQuery) === null || p === void 0) && p.hasQueries ? this._occlusionQuery.querySet : void 0 }, this._currentRenderPass = this._renderEncoder.beginRenderPass(this._rttRenderPassWrapper.renderPassDescriptor), this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0), !this._count || this._count < this.dbgVerboseLogsNumFrames)) {
          var Fe = m.texture;
          console.log("frame #" + this._count + " - render target begin pass - rtt name=" + e.label + ", internalTexture.uniqueId=" + Fe.uniqueId + ", width=" + Fe.width + ", height=" + Fe.height + ", setClearStates=" + i, "renderPassDescriptor=", this._rttRenderPassWrapper.renderPassDescriptor);
        }
        (f = this._debugFlushPendingCommands) === null || f === void 0 || f.call(this), this._resetRenderPassStates(), y && kr.HasStencilAspect(y.format) || (this._stencilStateComposer.enabled = !1);
      }, t.prototype._startMainRenderPass = function(e, i, r, o) {
        var a, s, l;
        this._endCurrentRenderPass(), this.useReverseDepthBuffer && this.setDepthFunctionToGreaterOrEqual();
        var c = e && i, u = e && r, h = e && o;
        this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].clearValue = c ? i : void 0, this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].loadOp = c ? ji.Clear : ji.Load, this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.depthClearValue = u ? this.useReverseDepthBuffer ? this._clearReverseDepthValue : this._clearDepthValue : void 0, this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.depthLoadOp = u ? ji.Clear : ji.Load, this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.stencilClearValue = h ? this._clearStencilValue : void 0, this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.stencilLoadOp = this.isStencilEnable ? h ? ji.Clear : ji.Load : void 0, this._mainRenderPassWrapper.renderPassDescriptor.occlusionQuerySet = !((a = this._occlusionQuery) === null || a === void 0) && a.hasQueries ? this._occlusionQuery.querySet : void 0;
        var d = this._context.getCurrentTexture();
        this._mainRenderPassWrapper.colorAttachmentGPUTextures[0].set(d), this._options.antialias ? (PC.format = d.format, this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].resolveTarget = d.createView(PC)) : (IC.format = d.format, this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].view = d.createView(IC)), this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0), (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - main begin pass - texture width=" + this._mainTextureExtends.width, " height=" + this._mainTextureExtends.height + ", setClearStates=" + e, "renderPassDescriptor=", this._mainRenderPassWrapper.renderPassDescriptor)), (s = this._debugPushGroup) === null || s === void 0 || s.call(this, "main pass", 0), this._currentRenderPass = this._renderEncoder.beginRenderPass(this._mainRenderPassWrapper.renderPassDescriptor), this._setDepthTextureFormat(this._mainRenderPassWrapper), this._setColorFormat(this._mainRenderPassWrapper), (l = this._debugFlushPendingCommands) === null || l === void 0 || l.call(this), this._resetRenderPassStates(), this._isStencilEnable || (this._stencilStateComposer.enabled = !1);
      }, t.prototype._endCurrentRenderPass = function() {
        var e, i, r;
        if (!this._currentRenderPass)
          return 0;
        var o = this._currentPassIsMainPass() ? 2 : 1;
        return this._snapshotRendering.endRenderPass(this._currentRenderPass) || this.compatibilityMode || (this._bundleList.run(this._currentRenderPass), this._bundleList.reset()), this._currentRenderPass.end(), this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0), (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - " + (o === 2 ? "main" : "render target") + " end pass" + (o === 1 ? " - internalTexture.uniqueId=" + ((i = (e = this._currentRenderTarget) === null || e === void 0 ? void 0 : e.texture) === null || i === void 0 ? void 0 : i.uniqueId) : ""))), (r = this._debugPopGroup) === null || r === void 0 || r.call(this, 0), this._currentRenderPass = null, o;
      }, t.prototype.bindFramebuffer = function(e, i, r, o, a, s, l) {
        var c, u;
        i === void 0 && (i = 0), s === void 0 && (s = 0), l === void 0 && (l = 0);
        var h = (c = e.texture) === null || c === void 0 ? void 0 : c._hardwareTexture;
        this._currentRenderTarget ? this.unBindFramebuffer(this._currentRenderTarget) : this._endCurrentRenderPass(), this._currentRenderTarget = e, this._rttRenderPassWrapper.colorAttachmentGPUTextures[0] = h, this._rttRenderPassWrapper.depthTextureFormat = this._currentRenderTarget._depthStencilTexture ? kr.GetWebGPUTextureFormat(-1, this._currentRenderTarget._depthStencilTexture.format) : void 0, this._setDepthTextureFormat(this._rttRenderPassWrapper), this._setColorFormat(this._rttRenderPassWrapper), this._rttRenderPassWrapper.colorAttachmentViewDescriptor = { format: this._colorFormat, dimension: ei.E2d, mipLevelCount: 1, baseArrayLayer: e.isCube ? 6 * l + i : l, baseMipLevel: s, arrayLayerCount: 1, aspect: no.All }, this._rttRenderPassWrapper.depthAttachmentViewDescriptor = { format: this._depthTextureFormat, dimension: ei.E2d, mipLevelCount: 1, baseArrayLayer: e.isCube ? 6 * l + i : l, baseMipLevel: 0, arrayLayerCount: 1, aspect: no.All }, this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0), (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - bindFramebuffer - rtt name=" + e.label + ", internalTexture.uniqueId=" + ((u = e.texture) === null || u === void 0 ? void 0 : u.uniqueId) + ", face=" + i + ", lodLevel=" + s + ", layer=" + l, "colorAttachmentViewDescriptor=", this._rttRenderPassWrapper.colorAttachmentViewDescriptor, "depthAttachmentViewDescriptor=", this._rttRenderPassWrapper.depthAttachmentViewDescriptor)), this._cachedViewport && !a ? this.setViewport(this._cachedViewport, r, o) : (r || (r = e.width, s && (r /= Math.pow(2, s))), o || (o = e.height, s && (o /= Math.pow(2, s))), this._viewport(0, 0, r, o)), this.wipeCaches();
      }, t.prototype.unBindFramebuffer = function(e, i, r) {
        var o, a;
        i === void 0 && (i = !1);
        var s = this._currentRenderTarget;
        this._currentRenderTarget = null, r && r(), this._currentRenderTarget = s, this._endCurrentRenderPass(), !(!((o = e.texture) === null || o === void 0) && o.generateMipMaps) || i || e.isCube || this._generateMipmaps(e.texture), this._currentRenderTarget = null, this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0), (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - unBindFramebuffer - rtt name=" + e.label + ", internalTexture.uniqueId=", (a = e.texture) === null || a === void 0 ? void 0 : a.uniqueId)), this._mrtAttachments = [], this._cacheRenderPipeline.setMRT([]), this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments);
      }, t.prototype.restoreDefaultFramebuffer = function() {
        this._currentRenderTarget ? this.unBindFramebuffer(this._currentRenderTarget) : this._currentRenderPass || this._startMainRenderPass(!1), this._cachedViewport && this.setViewport(this._cachedViewport), this.wipeCaches();
      }, t.prototype._setColorFormat = function(e) {
        var i, r, o = (r = (i = e.colorAttachmentGPUTextures[0]) === null || i === void 0 ? void 0 : i.format) !== null && r !== void 0 ? r : null;
        this._cacheRenderPipeline.setColorFormat(o), this._colorFormat !== o && (this._colorFormat = o);
      }, t.prototype._setDepthTextureFormat = function(e) {
        this._cacheRenderPipeline.setDepthStencilFormat(e.depthTextureFormat), this._depthTextureFormat !== e.depthTextureFormat && (this._depthTextureFormat = e.depthTextureFormat);
      }, t.prototype.setDitheringState = function() {
      }, t.prototype.setRasterizerState = function() {
      }, t.prototype.setState = function(e, i, r, o, a, s, l) {
        var c, u;
        i === void 0 && (i = 0), o === void 0 && (o = !1), l === void 0 && (l = 0), (this._depthCullingState.cull !== e || r) && (this._depthCullingState.cull = e);
        var h = (u = (c = this.cullBackFaces) !== null && c !== void 0 ? c : a) === null || u === void 0 || u ? 1 : 2;
        (this._depthCullingState.cullFace !== h || r) && (this._depthCullingState.cullFace = h), this.setZOffset(i), this.setZOffsetUnits(l);
        var d = o ? this._currentRenderTarget ? 1 : 2 : this._currentRenderTarget ? 2 : 1;
        (this._depthCullingState.frontFace !== d || r) && (this._depthCullingState.frontFace = d), this._stencilStateComposer.stencilMaterial = s;
      }, t.prototype._applyRenderPassChanges = function(e) {
        var i = !!this._stencilStateComposer.enabled && this._mustUpdateStencilRef(), r = !!this._alphaState.alphaBlend && this._mustUpdateBlendColor();
        this._mustUpdateViewport() && this._applyViewport(e), this._mustUpdateScissor() && this._applyScissor(e), i && this._applyStencilRef(e), r && this._applyBlendColor(e);
      }, t.prototype._draw = function(e, i, r, o, a) {
        var s, l = this._getCurrentRenderPass(), c = this._bundleList;
        this.applyStates();
        var u = this._currentEffect._pipelineContext;
        if (this.bindUniformBufferBase(this._currentRenderTarget ? this._ubInvertY : this._ubDontInvertY, 0, Rn.InternalsUBOName), u.uniformBuffer && (u.uniformBuffer.update(), this.bindUniformBufferBase(u.uniformBuffer.getBuffer(), 0, Rn.LeftOvertUBOName)), this._snapshotRendering.play)
          this._reportDrawCall();
        else {
          !this.compatibilityMode && (this._currentDrawContext.isDirty(this._currentMaterialContext.updateId) || this._currentMaterialContext.isDirty || this._currentMaterialContext.forceBindGroupCreation) && (this._currentDrawContext.fastBundle = void 0);
          var h = l;
          if (!this.compatibilityMode && this._currentDrawContext.fastBundle || this._snapshotRendering.record) {
            if (this._applyRenderPassChanges(c), !this._snapshotRendering.record)
              return this._counters.numBundleReuseNonCompatMode++, this._currentDrawContext.indirectDrawBuffer && this._currentDrawContext.setIndirectData(o, a || 1, r), c.addBundle(this._currentDrawContext.fastBundle), void this._reportDrawCall();
            h = c.getBundleEncoder(this._cacheRenderPipeline.colorFormats, this._depthTextureFormat, this.currentSampleCount), c.numDrawCalls++;
          }
          var d = 0;
          if (this._currentMaterialContext.hasFloatOrDepthTextures)
            for (var p = 1, f = 0; f < u.shaderProcessingContext.textureNames.length; ++f) {
              var m = u.shaderProcessingContext.textureNames[f], g = (s = this._currentMaterialContext.textures[m]) === null || s === void 0 ? void 0 : s.texture, y = g && g.format >= _.TEXTUREFORMAT_DEPTH24_STENCIL8 && g.format <= _.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8;
              ((g == null ? void 0 : g.type) === _.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering || y) && (d |= p), p <<= 1;
            }
          this._currentMaterialContext.textureState = d;
          var b = this._cacheRenderPipeline.getRenderPipeline(i, this._currentEffect, this.currentSampleCount, d), T = this._cacheBindGroups.getBindGroups(u, this._currentDrawContext, this._currentMaterialContext);
          this._snapshotRendering.record || (this._applyRenderPassChanges(this.compatibilityMode ? null : c), this.compatibilityMode || (this._counters.numBundleCreationNonCompatMode++, h = this._device.createRenderBundleEncoder({ colorFormats: this._cacheRenderPipeline.colorFormats, depthStencilFormat: this._depthTextureFormat, sampleCount: kr.GetSample(this.currentSampleCount) }))), h.setPipeline(b), this._currentIndexBuffer && h.setIndexBuffer(this._currentIndexBuffer.underlyingResource, this._currentIndexBuffer.is32Bits ? ya.Uint32 : ya.Uint16, 0);
          for (var S = this._cacheRenderPipeline.vertexBuffers, E = 0; E < S.length; E++) {
            var A = S[E], R = A.effectiveBuffer;
            R && h.setVertexBuffer(E, R.underlyingResource, A._validOffsetRange ? 0 : A.byteOffset);
          }
          for (f = 0; f < T.length; f++)
            h.setBindGroup(f, T[f]);
          var C = !this.compatibilityMode && !this._snapshotRendering.record;
          C && this._currentDrawContext.indirectDrawBuffer ? (this._currentDrawContext.setIndirectData(o, a || 1, r), e === 0 ? h.drawIndexedIndirect(this._currentDrawContext.indirectDrawBuffer, 0) : h.drawIndirect(this._currentDrawContext.indirectDrawBuffer, 0)) : e === 0 ? h.drawIndexed(o, a || 1, r, 0, 0) : h.draw(o, a || 1, r, 0), C && (this._currentDrawContext.fastBundle = h.finish(), c.addBundle(this._currentDrawContext.fastBundle)), this._reportDrawCall();
        }
      }, t.prototype.drawElementsType = function(e, i, r, o) {
        o === void 0 && (o = 1), this._draw(0, e, i, r, o);
      }, t.prototype.drawArraysType = function(e, i, r, o) {
        o === void 0 && (o = 1), this._currentIndexBuffer = null, this._draw(1, e, i, r, o);
      }, t.prototype.dispose = function() {
        var e, i;
        this._isDisposed = !0, (e = this._mainTexture) === null || e === void 0 || e.destroy(), (i = this._depthTexture) === null || i === void 0 || i.destroy(), this._device.destroy(), n.prototype.dispose.call(this);
      }, t.prototype.getRenderWidth = function(e) {
        var i, r;
        return e === void 0 && (e = !1), !e && this._currentRenderTarget ? this._currentRenderTarget.width : (r = (i = this._renderingCanvas) === null || i === void 0 ? void 0 : i.width) !== null && r !== void 0 ? r : 0;
      }, t.prototype.getRenderHeight = function(e) {
        var i, r;
        return e === void 0 && (e = !1), !e && this._currentRenderTarget ? this._currentRenderTarget.height : (r = (i = this._renderingCanvas) === null || i === void 0 ? void 0 : i.height) !== null && r !== void 0 ? r : 0;
      }, t.prototype.getError = function() {
        return 0;
      }, t.prototype.bindSamplers = function() {
      }, t.prototype._bindTextureDirectly = function() {
        return !1;
      }, t.prototype.areAllEffectsReady = function() {
        return !0;
      }, t.prototype._executeWhenRenderingStateIsCompiled = function(e, i) {
        i();
      }, t.prototype._isRenderingStateCompiled = function() {
        return !0;
      }, t.prototype._getUnpackAlignement = function() {
        return 1;
      }, t.prototype._unpackFlipY = function() {
      }, t.prototype._bindUnboundFramebuffer = function() {
        throw "_bindUnboundFramebuffer is not implementedin WebGPU! You probably want to use restoreDefaultFramebuffer or unBindFramebuffer instead";
      }, t.prototype._getSamplingParameters = function() {
        throw "_getSamplingParameters is not available in WebGPU";
      }, t.prototype.getUniforms = function() {
        return [];
      }, t.prototype.setIntArray = function() {
        return !1;
      }, t.prototype.setIntArray2 = function() {
        return !1;
      }, t.prototype.setIntArray3 = function() {
        return !1;
      }, t.prototype.setIntArray4 = function() {
        return !1;
      }, t.prototype.setArray = function() {
        return !1;
      }, t.prototype.setArray2 = function() {
        return !1;
      }, t.prototype.setArray3 = function() {
        return !1;
      }, t.prototype.setArray4 = function() {
        return !1;
      }, t.prototype.setMatrices = function() {
        return !1;
      }, t.prototype.setMatrix3x3 = function() {
        return !1;
      }, t.prototype.setMatrix2x2 = function() {
        return !1;
      }, t.prototype.setFloat = function() {
        return !1;
      }, t.prototype.setFloat2 = function() {
        return !1;
      }, t.prototype.setFloat3 = function() {
        return !1;
      }, t.prototype.setFloat4 = function() {
        return !1;
      }, t._GLSLslangDefaultOptions = { jsPath: "".concat(de._DefaultCdnUrl, "/glslang/glslang.js"), wasmPath: "".concat(de._DefaultCdnUrl, "/glslang/glslang.wasm") }, t.UseTWGSL = !0, t;
    }(ve);
    st.prototype.setAlphaMode = function(n, t) {
      if (t === void 0 && (t = !1), this._alphaMode === n && (n === _.ALPHA_DISABLE && !this._alphaState.alphaBlend || n !== _.ALPHA_DISABLE && this._alphaState.alphaBlend)) {
        if (!t) {
          var e = n === _.ALPHA_DISABLE;
          this.depthCullingState.depthMask !== e && (this.setDepthWrite(e), this._cacheRenderPipeline.setDepthWriteEnabled(e));
        }
      } else {
        switch (n) {
          case _.ALPHA_DISABLE:
            this._alphaState.alphaBlend = !1;
            break;
          case _.ALPHA_PREMULTIPLIED:
            this._alphaState.setAlphaBlendFunctionParameters(1, _.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA, 1, 1), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_PREMULTIPLIED_PORTERDUFF:
            this._alphaState.setAlphaBlendFunctionParameters(1, _.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA, 1, _.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_COMBINE:
            this._alphaState.setAlphaBlendFunctionParameters(_.GL_ALPHA_FUNCTION_SRC_ALPHA, _.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA, 1, 1), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_ONEONE:
            this._alphaState.setAlphaBlendFunctionParameters(1, 1, 0, 1), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_ADD:
            this._alphaState.setAlphaBlendFunctionParameters(_.GL_ALPHA_FUNCTION_SRC_ALPHA, 1, 0, 1), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_SUBTRACT:
            this._alphaState.setAlphaBlendFunctionParameters(0, _.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR, 1, 1), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_MULTIPLY:
            this._alphaState.setAlphaBlendFunctionParameters(_.GL_ALPHA_FUNCTION_DST_COLOR, 0, 1, 1), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_MAXIMIZED:
            this._alphaState.setAlphaBlendFunctionParameters(_.GL_ALPHA_FUNCTION_SRC_ALPHA, _.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR, 1, 1), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_INTERPOLATE:
            this._alphaState.setAlphaBlendFunctionParameters(_.GL_ALPHA_FUNCTION_CONSTANT_COLOR, _.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR, _.GL_ALPHA_FUNCTION_CONSTANT_ALPHA, _.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_SCREENMODE:
            this._alphaState.setAlphaBlendFunctionParameters(1, _.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR, 1, _.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_ONEONE_ONEONE:
            this._alphaState.setAlphaBlendFunctionParameters(1, 1, 1, 1), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_ALPHATOCOLOR:
            this._alphaState.setAlphaBlendFunctionParameters(_.GL_ALPHA_FUNCTION_DST_ALPHA, 1, 0, 0), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_REVERSEONEMINUS:
            this._alphaState.setAlphaBlendFunctionParameters(_.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR, _.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR, _.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA, _.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_SRC_DSTONEMINUSSRCALPHA:
            this._alphaState.setAlphaBlendFunctionParameters(1, _.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA, 1, _.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_ONEONE_ONEZERO:
            this._alphaState.setAlphaBlendFunctionParameters(1, 1, 1, 0), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_EXCLUSION:
            this._alphaState.setAlphaBlendFunctionParameters(_.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR, _.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR, 0, 1), this._alphaState.alphaBlend = !0;
            break;
          case _.ALPHA_LAYER_ACCUMULATE:
            this._alphaState.setAlphaBlendFunctionParameters(_.GL_ALPHA_FUNCTION_SRC_ALPHA, _.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA, 1, _.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA), this._alphaState.alphaBlend = !0;
        }
        t || (this.setDepthWrite(n === ve.ALPHA_DISABLE), this._cacheRenderPipeline.setDepthWriteEnabled(n === ve.ALPHA_DISABLE)), this._alphaMode = n, this._cacheRenderPipeline.setAlphaBlendEnabled(this._alphaState.alphaBlend), this._cacheRenderPipeline.setAlphaBlendFactors(this._alphaState._blendFunctionParameters, this._alphaState._blendEquationParameters);
      }
    }, st.prototype.setAlphaEquation = function(n) {
      ve.prototype.setAlphaEquation.call(this, n), this._cacheRenderPipeline.setAlphaBlendFactors(this._alphaState._blendFunctionParameters, this._alphaState._blendEquationParameters);
    };
    var BD = function() {
      function n(t, e) {
        this._device = t, this._cacheSampler = e, this.uniqueId = n._Counter++, this._bindGroupEntries = [], this.clear();
      }
      return n.prototype.getBindGroups = function(t, e, i) {
        if (!i)
          throw new Error("WebGPUComputeContext.getBindGroups: bindingsMapping is required until browsers support reflection for wgsl shaders!");
        if (this._bindGroups.length === 0) {
          var r = this._bindGroupEntries.length > 0;
          for (var o in t) {
            var a = t[o], s = i[o], l = s.group, c = s.binding, u = a.type, h = a.object, d = a.indexInGroupEntries;
            switch ((S = this._bindGroupEntries[l]) || (S = this._bindGroupEntries[l] = []), u) {
              case di.Sampler:
                var p = h;
                d !== void 0 && r ? S[d].resource = this._cacheSampler.getSampler(p) : (a.indexInGroupEntries = S.length, S.push({ binding: c, resource: this._cacheSampler.getSampler(p) }));
                break;
              case di.Texture:
              case di.TextureWithoutSampler:
                var f = (m = h)._texture._hardwareTexture;
                d !== void 0 && r ? (u === di.Texture && (S[d++].resource = this._cacheSampler.getSampler(m._texture)), S[d].resource = f.view) : (a.indexInGroupEntries = S.length, u === di.Texture && S.push({ binding: c - 1, resource: this._cacheSampler.getSampler(m._texture) }), S.push({ binding: c, resource: f.view }));
                break;
              case di.StorageTexture:
                !((f = (m = h)._texture._hardwareTexture).textureAdditionalUsages & fi.StorageBinding) && q.Error("computeDispatch: The texture (name=".concat(m.name, ", uniqueId=").concat(m.uniqueId, ") is not a storage texture!"), 50), d !== void 0 && r ? S[d].resource = f.viewForWriting : (a.indexInGroupEntries = S.length, S.push({ binding: c, resource: f.viewForWriting }));
                break;
              case di.ExternalTexture:
                var m, g = (m = h).underlyingResource;
                d !== void 0 && r ? S[d].resource = this._device.importExternalTexture({ source: g }) : (a.indexInGroupEntries = S.length, S.push({ binding: c, resource: this._device.importExternalTexture({ source: g }) }));
                break;
              case di.UniformBuffer:
              case di.StorageBuffer:
                var y = (di.UniformBuffer, h).getBuffer(), b = y.underlyingResource;
                d !== void 0 && r ? (S[d].resource.buffer = b, S[d].resource.size = y.capacity) : (a.indexInGroupEntries = S.length, S.push({ binding: c, resource: { buffer: b, offset: 0, size: y.capacity } }));
            }
          }
          for (var T = 0; T < this._bindGroupEntries.length; ++T) {
            var S;
            (S = this._bindGroupEntries[T]) ? this._bindGroups[T] = this._device.createBindGroup({ layout: e.getBindGroupLayout(T), entries: S }) : this._bindGroups[T] = void 0;
          }
          this._bindGroups.length = this._bindGroupEntries.length;
        }
        return this._bindGroups;
      }, n.prototype.clear = function() {
        this._bindGroups = [];
      }, n._Counter = 0, n;
    }(), UD = function() {
      function n(t) {
        this._name = "unnamed", this.engine = t;
      }
      return Object.defineProperty(n.prototype, "isAsync", { get: function() {
        return !1;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isReady", { get: function() {
        return !!this.stage;
      }, enumerable: !1, configurable: !0 }), n.prototype._getComputeShaderCode = function() {
        var t;
        return (t = this.sources) === null || t === void 0 ? void 0 : t.compute;
      }, n.prototype.dispose = function() {
      }, n;
    }();
    st.prototype.createComputeContext = function() {
      return new BD(this._device, this._cacheSampler);
    }, st.prototype.createComputeEffect = function(n, t) {
      var e = (n.computeElement || n.compute || n.computeToken || n.computeSource || n) + "@" + t.defines;
      if (this._compiledComputeEffects[e]) {
        var i = this._compiledComputeEffects[e];
        return t.onCompiled && i.isReady() && t.onCompiled(i), i;
      }
      var r = new Pv(n, t, this, e);
      return this._compiledComputeEffects[e] = r, r;
    }, st.prototype.createComputePipelineContext = function() {
      return new UD(this);
    }, st.prototype.areAllComputeEffectsReady = function() {
      for (var n in this._compiledComputeEffects)
        if (!this._compiledComputeEffects[n].isReady())
          return !1;
      return !0;
    }, st.prototype.computeDispatch = function(n, t, e, i, r, o, a) {
      this._endCurrentRenderPass();
      var s = n._pipelineContext, l = t;
      s.computePipeline || (s.computePipeline = this._device.createComputePipeline({ layout: xl.Auto, compute: s.stage }));
      var c = this._renderEncoder.beginComputePass();
      c.setPipeline(s.computePipeline);
      for (var u = l.getBindGroups(e, s.computePipeline, a), h = 0; h < u.length; ++h) {
        var d = u[h];
        d && c.setBindGroup(h, d);
      }
      c.dispatchWorkgroups(i, r, o), c.end();
    }, st.prototype.releaseComputeEffects = function() {
      for (var n in this._compiledComputeEffects) {
        var t = this._compiledComputeEffects[n].getPipelineContext();
        this._deleteComputePipelineContext(t);
      }
      this._compiledComputeEffects = {};
    }, st.prototype._prepareComputePipelineContext = function(n, t, e, i, r) {
      var o = n;
      this.dbgShowShaderCode && (console.log(i), console.log(t)), o.sources = { compute: t, rawCompute: e }, o.stage = this._createComputePipelineStageDescriptor(t, i, r);
    }, st.prototype._releaseComputeEffect = function(n) {
      this._compiledComputeEffects[n._key] && (delete this._compiledComputeEffects[n._key], this._deleteComputePipelineContext(n.getPipelineContext()));
    }, st.prototype._rebuildComputeEffects = function() {
      for (var n in this._compiledComputeEffects) {
        var t = this._compiledComputeEffects[n];
        t._pipelineContext = null, t._wasPreviouslyReady = !1, t._prepareEffect();
      }
    }, st.prototype._deleteComputePipelineContext = function(n) {
      n && n.dispose();
    }, st.prototype._createComputePipelineStageDescriptor = function(n, t, e) {
      return t = t ? "//" + t.split(`
`).join(`
//`) + `
` : "", { module: this._device.createShaderModule({ code: t + n }), entryPoint: e };
    }, st.prototype._createDepthStencilCubeTexture = function(n, t) {
      var e = new Ut(this, ut.DepthStencil);
      e.isCube = !0;
      var i = je({ bilinearFiltering: !1, comparisonFunction: 0, generateStencil: !1, samples: 1 }, t);
      return e.format = i.generateStencil ? _.TEXTUREFORMAT_DEPTH24_STENCIL8 : _.TEXTUREFORMAT_DEPTH32_FLOAT, this._setupDepthStencilTexture(e, n, i.generateStencil, i.bilinearFiltering, i.comparisonFunction, i.samples), this._textureHelper.createGPUTextureForInternalTexture(e), this._internalTexturesCache.push(e), e;
    }, st.prototype.createCubeTexture = function(n, t, e, i, r, o, a, s, l, c, u, h, d) {
      var p = this;
      return r === void 0 && (r = null), o === void 0 && (o = null), s === void 0 && (s = null), l === void 0 && (l = !1), c === void 0 && (c = 0), u === void 0 && (u = 0), h === void 0 && (h = null), d === void 0 && (d = !1), this.createCubeTextureBase(n, t, e, !!i, r, o, a, s, l, c, u, h, null, function(f, m) {
        var g = m, y = g[0].width, b = y;
        p._setCubeMapTextureParams(f, !i), f.format = a ?? -1;
        var T = p._textureHelper.createGPUTextureForInternalTexture(f, y, b);
        p._textureHelper.updateCubeTextures(g, T.underlyingResource, y, b, T.format, !1, !1, 0, 0), i || p._generateMipmaps(f, p._uploadEncoder), f.isReady = !0, f.onLoadedObservable.notifyObservers(f), f.onLoadedObservable.clear(), r && r();
      }, !!d);
    }, st.prototype._setCubeMapTextureParams = function(n, t, e) {
      n.samplingMode = t ? _.TEXTURE_TRILINEAR_SAMPLINGMODE : _.TEXTURE_BILINEAR_SAMPLINGMODE, n._cachedWrapU = _.TEXTURE_CLAMP_ADDRESSMODE, n._cachedWrapV = _.TEXTURE_CLAMP_ADDRESSMODE, e && (n._maxLodLevel = e);
    }, st.prototype._debugPushGroup = function(n, t) {
      this._options.enableGPUDebugMarkers && (t === 0 || t === 1 ? this._renderEncoder.pushDebugGroup(n) : this._currentRenderPass ? this._currentRenderPass.pushDebugGroup(n) : this._pendingDebugCommands.push(["push", n]));
    }, st.prototype._debugPopGroup = function(n) {
      this._options.enableGPUDebugMarkers && (n === 0 || n === 1 ? this._renderEncoder.popDebugGroup() : this._currentRenderPass ? this._currentRenderPass.popDebugGroup() : this._pendingDebugCommands.push(["pop", null]));
    }, st.prototype._debugInsertMarker = function(n, t) {
      this._options.enableGPUDebugMarkers && (t === 0 || t === 1 ? this._renderEncoder.insertDebugMarker(n) : this._currentRenderPass ? this._currentRenderPass.insertDebugMarker(n) : this._pendingDebugCommands.push(["insert", n]));
    }, st.prototype._debugFlushPendingCommands = function() {
      for (var n = 0; n < this._pendingDebugCommands.length; ++n) {
        var t = this._pendingDebugCommands[n], e = t[0], i = t[1];
        switch (e) {
          case "push":
            this._debugPushGroup(i);
            break;
          case "pop":
            this._debugPopGroup();
            break;
          case "insert":
            this._debugInsertMarker(i);
        }
      }
      this._pendingDebugCommands.length = 0;
    }, st.prototype.updateDynamicIndexBuffer = function(n, t, e) {
      e === void 0 && (e = 0);
      var i, r = n;
      i = n.is32Bits ? t instanceof Uint32Array ? t : new Uint32Array(t) : t instanceof Uint16Array ? t : new Uint16Array(t), this._bufferManager.setSubData(r, e, i);
    }, st.prototype.updateDynamicVertexBuffer = function(n, t, e, i) {
      var r, o = n;
      e === void 0 && (e = 0), i === void 0 ? i = (r = t instanceof Array ? new Float32Array(t) : t instanceof ArrayBuffer ? new Uint8Array(t) : t).byteLength : r = t instanceof Array ? new Float32Array(t) : t instanceof ArrayBuffer ? new Uint8Array(t) : t, this._bufferManager.setSubData(o, e, r, 0, i);
    }, st.prototype.updateDynamicTexture = function(n, t, e, i, r, o, a) {
      var s;
      if (i === void 0 && (i = !1), n) {
        var l = t.width, c = t.height, u = n._hardwareTexture;
        !((s = n._hardwareTexture) === null || s === void 0) && s.underlyingResource || (u = this._textureHelper.createGPUTextureForInternalTexture(n, l, c)), this._textureHelper.updateTexture(t, n, l, c, n.depth, u.format, 0, 0, e, i, 0, 0, a), n.generateMipMaps && this._generateMipmaps(n), n.isReady = !0;
      }
    };
    var VD = function(n) {
      function t(e) {
        return n.call(this, e) || this;
      }
      return D(t, n), t;
    }(t_);
    function Gh(n, t, e, i) {
      var r, o = 1;
      i === _.TEXTURETYPE_FLOAT ? r = new Float32Array(t * e * 4) : i === _.TEXTURETYPE_HALF_FLOAT ? (r = new Uint16Array(t * e * 4), o = 15360) : r = i === _.TEXTURETYPE_UNSIGNED_INTEGER ? new Uint32Array(t * e * 4) : new Uint8Array(t * e * 4);
      for (var a = 0; a < t; a++)
        for (var s = 0; s < e; s++) {
          var l = 3 * (s * t + a), c = 4 * (s * t + a);
          r[c + 0] = n[l + 0], r[c + 1] = n[l + 1], r[c + 2] = n[l + 2], r[c + 3] = o;
        }
      return r;
    }
    Jt.prototype.setExternalTexture = function(n, t) {
      this._engine.setExternalTexture(n, t);
    }, st.prototype.createExternalTexture = function(n) {
      return new VD(n);
    }, st.prototype.setExternalTexture = function(n, t) {
      t ? this._setInternalTexture(n, t) : this._currentMaterialContext.setTexture(n, null);
    }, st.prototype.unBindMultiColorAttachmentFramebuffer = function(n, t, e) {
      t === void 0 && (t = !1), e && e();
      var i = n._attachments.length;
      this._endCurrentRenderPass();
      for (var r = 0; r < i; r++) {
        var o = n.textures[r];
        !o.generateMipMaps || t || o.isCube || this._generateMipmaps(o);
      }
      this._currentRenderTarget = null, this._mrtAttachments = [], this._cacheRenderPipeline.setMRT([]), this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments);
    }, st.prototype.createMultipleRenderTarget = function(n, t, e) {
      var i, r, o, a = !1, s = !0, l = !1, c = !1, u = _.TEXTUREFORMAT_DEPTH16, h = 1, d = _.TEXTURETYPE_UNSIGNED_INT, p = _.TEXTURE_TRILINEAR_SAMPLINGMODE, f = _.TEXTUREFORMAT_RGBA, m = _.TEXTURE_2D, g = [], y = [], b = [], T = [], S = [], E = [], A = [], R = [], C = [], L = this._createHardwareRenderTargetWrapper(!0, !1, n);
      t !== void 0 && (a = t.generateMipMaps !== void 0 && t.generateMipMaps, s = t.generateDepthBuffer === void 0 || t.generateDepthBuffer, l = t.generateStencilBuffer !== void 0 && t.generateStencilBuffer, c = t.generateDepthTexture !== void 0 && t.generateDepthTexture, h = t.textureCount || 1, u = (i = t.depthTextureFormat) !== null && i !== void 0 ? i : _.TEXTUREFORMAT_DEPTH16, t.types && (g = t.types), t.samplingModes && (y = t.samplingModes), t.useSRGBBuffers && (b = t.useSRGBBuffers), t.formats && (T = t.formats), t.targetTypes && (S = t.targetTypes), t.faceIndex && (E = t.faceIndex), t.layerIndex && (A = t.layerIndex), t.layerCounts && (R = t.layerCounts), C = (r = t.labels) !== null && r !== void 0 ? r : C);
      var I = n.width || n, O = n.height || n, w = null;
      (s || l || c) && (c || (u = s && l ? _.TEXTUREFORMAT_DEPTH24_STENCIL8 : s ? _.TEXTUREFORMAT_DEPTH32_FLOAT : _.TEXTUREFORMAT_STENCIL8), w = L.createDepthStencilTexture(0, !1, l, 1, u, "MultipleRenderTargetDepthStencil"));
      var z = [], V = [], Y = [];
      L._generateDepthBuffer = s, L._generateStencilBuffer = l, L._attachments = V, L._defaultAttachments = Y;
      for (var ee = 0; ee < h; ee++) {
        var J = y[ee] || p, X = g[ee] || d, K = T[ee] || f, te = !!b[ee] && this._caps.supportSRGBBuffers, se = S[ee] || m, _e = (o = R[ee]) !== null && o !== void 0 ? o : 1;
        if ((X !== _.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (X !== _.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (J = _.TEXTURE_NEAREST_SAMPLINGMODE), X !== _.TEXTURETYPE_FLOAT || this._caps.textureFloat || (X = _.TEXTURETYPE_UNSIGNED_INT, q.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")), V.push(ee + 1), Y.push(e ? ee + 1 : ee === 0 ? 1 : 0), se !== -1) {
          var xe = new Ut(this, ut.MultiRenderTarget);
          switch (z[ee] = xe, se) {
            case _.TEXTURE_CUBE_MAP:
              xe.isCube = !0;
              break;
            case _.TEXTURE_3D:
              xe.is3D = !0, xe.baseDepth = xe.depth = _e;
              break;
            case _.TEXTURE_2D_ARRAY:
              xe.is2DArray = !0, xe.baseDepth = xe.depth = _e;
          }
          xe.baseWidth = I, xe.baseHeight = O, xe.width = I, xe.height = O, xe.isReady = !0, xe.samples = 1, xe.generateMipMaps = a, xe.samplingMode = J, xe.type = X, xe._cachedWrapU = _.TEXTURE_CLAMP_ADDRESSMODE, xe._cachedWrapV = _.TEXTURE_CLAMP_ADDRESSMODE, xe._useSRGBBuffer = te, xe.format = K, xe.label = C[ee], this._internalTexturesCache.push(xe), this._textureHelper.createGPUTextureForInternalTexture(xe);
        }
      }
      return w && (w.incrementReferences(), z[h] = w, this._internalTexturesCache.push(w)), L.setTextures(z), L.setLayerAndFaceIndices(A, E), L;
    }, st.prototype.updateMultipleRenderTargetTextureSampleCount = function(n, t) {
      if (!n || !n.textures || n.textures[0].samples === t)
        return t;
      var e = n.textures.length;
      if (e === 0)
        return 1;
      t = Math.min(t, this.getCaps().maxMSAASamples);
      for (var i = 0; i < e; ++i) {
        var r = (a = n.textures[i])._hardwareTexture;
        r == null || r.releaseMSAATexture();
      }
      var o = n._depthStencilTexture === n.textures[e - 1];
      for (i = 0; i < e; ++i) {
        var a = n.textures[i];
        this._textureHelper.createMSAATexture(a, t, !1, i === e - 1 && o ? 0 : i), a.samples = t;
      }
      return n._depthStencilTexture && !o && (this._textureHelper.createMSAATexture(n._depthStencilTexture, t), n._depthStencilTexture.samples = t), t;
    }, st.prototype.bindAttachments = function(n) {
      n.length !== 0 && this._currentRenderTarget && (this._mrtAttachments = n, this._currentRenderPass && this._cacheRenderPipeline.setMRTAttachments(n));
    }, st.prototype.buildTextureLayout = function(n) {
      for (var t = [], e = 0; e < n.length; e++)
        n[e] ? t.push(e + 1) : t.push(0);
      return t;
    }, st.prototype.restoreSingleAttachment = function() {
    }, st.prototype.restoreSingleAttachmentForRenderTarget = function() {
    }, st.prototype.getGPUFrameTimeCounter = function() {
      return this._timestampQuery.gpuFrameTimeCounter;
    }, st.prototype.captureGPUFrameTime = function(n) {
      this._timestampQuery.enable = n && !!this._caps.timerQuery;
    }, st.prototype.createQuery = function() {
      return this._occlusionQuery.createQuery();
    }, st.prototype.deleteQuery = function(n) {
      return this._occlusionQuery.deleteQuery(n), this;
    }, st.prototype.isQueryResultAvailable = function(n) {
      return this._occlusionQuery.isQueryResultAvailable(n);
    }, st.prototype.getQueryResult = function(n) {
      return this._occlusionQuery.getQueryResult(n);
    }, st.prototype.beginOcclusionQuery = function(n, t) {
      var e;
      return this.compatibilityMode ? !!this._occlusionQuery.canBeginQuery(t) && ((e = this._currentRenderPass) === null || e === void 0 || e.beginOcclusionQuery(t), !0) : (this._bundleList.addItem(new PD(t)), !0);
    }, st.prototype.endOcclusionQuery = function() {
      var n;
      return this.compatibilityMode ? (n = this._currentRenderPass) === null || n === void 0 || n.endOcclusionQuery() : this._bundleList.addItem(new ID()), this;
    }, st.prototype.createRawTexture = function(n, t, e, i, r, o, a, s, l, c, u) {
      s === void 0 && (s = null), l === void 0 && (l = _.TEXTURETYPE_UNSIGNED_INT), c === void 0 && (c = 0), u === void 0 && (u = !1);
      var h = new Ut(this, ut.Raw);
      return h.baseWidth = t, h.baseHeight = e, h.width = t, h.height = e, h.format = i, h.generateMipMaps = r, h.samplingMode = a, h.invertY = o, h._compression = s, h.type = l, h._useSRGBBuffer = u, this._doNotHandleContextLost || (h._bufferView = n), this._textureHelper.createGPUTextureForInternalTexture(h, t, e, void 0, c), this.updateRawTexture(h, n, i, o, s, l, u), this._internalTexturesCache.push(h), h;
    }, st.prototype.updateRawTexture = function(n, t, e, i, r, o, a) {
      if (r === void 0 && (r = null), o === void 0 && (o = _.TEXTURETYPE_UNSIGNED_INT), a === void 0 && (a = !1), n) {
        if (this._doNotHandleContextLost || (n._bufferView = t, n.invertY = i, n._compression = r, n._useSRGBBuffer = a), t) {
          var s = n._hardwareTexture;
          e === _.TEXTUREFORMAT_RGB && (t = Gh(t, n.width, n.height, o));
          var l = new Uint8Array(t.buffer, t.byteOffset, t.byteLength);
          this._textureHelper.updateTexture(l, n, n.width, n.height, n.depth, s.format, 0, 0, i, !1, 0, 0), n.generateMipMaps && this._generateMipmaps(n, this._uploadEncoder);
        }
        n.isReady = !0;
      }
    }, st.prototype.createRawCubeTexture = function(n, t, e, i, r, o, a, s) {
      s === void 0 && (s = null);
      var l = new Ut(this, ut.CubeRaw);
      return i !== _.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering ? i !== _.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering ? i !== _.TEXTURETYPE_FLOAT || this._caps.textureFloatRender ? i !== _.TEXTURETYPE_HALF_FLOAT || this._caps.colorBufferFloat || (r = !1, q.Warn("Render to half float textures is not supported. Mipmap generation forced to false.")) : (r = !1, q.Warn("Render to float textures is not supported. Mipmap generation forced to false.")) : (r = !1, a = _.TEXTURE_NEAREST_SAMPLINGMODE, q.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")) : (r = !1, a = _.TEXTURE_NEAREST_SAMPLINGMODE, q.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")), l.isCube = !0, l.format = e === _.TEXTUREFORMAT_RGB ? _.TEXTUREFORMAT_RGBA : e, l.type = i, l.generateMipMaps = r, l.width = t, l.height = t, l.samplingMode = a, this._doNotHandleContextLost || (l._bufferViewArray = n), l.invertY = o, l._compression = s, l._cachedWrapU = _.TEXTURE_CLAMP_ADDRESSMODE, l._cachedWrapV = _.TEXTURE_CLAMP_ADDRESSMODE, this._textureHelper.createGPUTextureForInternalTexture(l), n && this.updateRawCubeTexture(l, n, e, i, o, s), l.isReady = !0, l;
    }, st.prototype.updateRawCubeTexture = function(n, t, e, i, r, o) {
      o === void 0 && (o = null), n._bufferViewArray = t, n.invertY = r, n._compression = o;
      for (var a = n._hardwareTexture, s = e === _.TEXTUREFORMAT_RGB, l = [], c = 0; c < t.length; ++c) {
        var u = t[c];
        s && (u = Gh(t[c], n.width, n.height, i)), l.push(new Uint8Array(u.buffer, u.byteOffset, u.byteLength));
      }
      this._textureHelper.updateCubeTextures(l, a.underlyingResource, n.width, n.height, a.format, r, !1, 0, 0), n.generateMipMaps && this._generateMipmaps(n, this._uploadEncoder), n.isReady = !0;
    }, st.prototype.createRawCubeTextureFromUrl = function(n, t, e, i, r, o, a, s, l, c, u, h) {
      var d = this;
      l === void 0 && (l = null), c === void 0 && (c = null), u === void 0 && (u = _.TEXTURE_TRILINEAR_SAMPLINGMODE), h === void 0 && (h = !1);
      var p = this.createRawCubeTexture(null, e, i, r, !o, h, u, null);
      return t == null || t.addPendingData(p), p.url = n, this._internalTexturesCache.push(p), this._loadFile(n, function(f) {
        (function(m) {
          var g = p.width, y = a(m);
          if (y) {
            var b = [0, 2, 4, 1, 3, 5];
            if (s)
              for (var T = i === _.TEXTUREFORMAT_RGB, S = s(y), E = p._hardwareTexture, A = [0, 1, 2, 3, 4, 5], R = 0; R < S.length; R++) {
                for (var C = g >> R, L = [], I = 0; I < 6; I++) {
                  var O = S[R][A[I]];
                  T && (O = Gh(O, C, C, r)), L.push(new Uint8Array(O.buffer, O.byteOffset, O.byteLength));
                }
                d._textureHelper.updateCubeTextures(L, E.underlyingResource, C, C, E.format, h, !1, 0, 0);
              }
            else {
              for (L = [], I = 0; I < 6; I++)
                L.push(y[b[I]]);
              d.updateRawCubeTexture(p, L, i, r, h);
            }
            p.isReady = !0, t == null || t.removePendingData(p), l && l();
          }
        })(f);
      }, void 0, t == null ? void 0 : t.offlineProvider, !0, function(f, m) {
        t == null || t.removePendingData(p), c && f && c(f.status + " " + f.statusText, m);
      }), p;
    }, st.prototype.createRawTexture3D = function(n, t, e, i, r, o, a, s, l, c, u) {
      l === void 0 && (l = null), c === void 0 && (c = _.TEXTURETYPE_UNSIGNED_INT), u === void 0 && (u = 0);
      var h = ut.Raw3D, d = new Ut(this, h);
      return d.baseWidth = t, d.baseHeight = e, d.baseDepth = i, d.width = t, d.height = e, d.depth = i, d.format = r, d.type = c, d.generateMipMaps = o, d.samplingMode = s, d.is3D = !0, this._doNotHandleContextLost || (d._bufferView = n), this._textureHelper.createGPUTextureForInternalTexture(d, t, e, void 0, u), this.updateRawTexture3D(d, n, r, a, l, c), this._internalTexturesCache.push(d), d;
    }, st.prototype.updateRawTexture3D = function(n, t, e, i, r, o) {
      if (r === void 0 && (r = null), o === void 0 && (o = _.TEXTURETYPE_UNSIGNED_INT), this._doNotHandleContextLost || (n._bufferView = t, n.format = e, n.invertY = i, n._compression = r), t) {
        var a = n._hardwareTexture;
        e === _.TEXTUREFORMAT_RGB && (t = Gh(t, n.width, n.height, o));
        var s = new Uint8Array(t.buffer, t.byteOffset, t.byteLength);
        this._textureHelper.updateTexture(s, n, n.width, n.height, n.depth, a.format, 0, 0, i, !1, 0, 0), n.generateMipMaps && this._generateMipmaps(n, this._uploadEncoder);
      }
      n.isReady = !0;
    }, st.prototype.createRawTexture2DArray = function(n, t, e, i, r, o, a, s, l, c, u) {
      l === void 0 && (l = null), c === void 0 && (c = _.TEXTURETYPE_UNSIGNED_INT), u === void 0 && (u = 0);
      var h = ut.Raw2DArray, d = new Ut(this, h);
      return d.baseWidth = t, d.baseHeight = e, d.baseDepth = i, d.width = t, d.height = e, d.depth = i, d.format = r, d.type = c, d.generateMipMaps = o, d.samplingMode = s, d.is2DArray = !0, this._doNotHandleContextLost || (d._bufferView = n), this._textureHelper.createGPUTextureForInternalTexture(d, t, e, i, u), this.updateRawTexture2DArray(d, n, r, a, l, c), this._internalTexturesCache.push(d), d;
    }, st.prototype.updateRawTexture2DArray = function(n, t, e, i, r, o) {
      if (r === void 0 && (r = null), o === void 0 && (o = _.TEXTURETYPE_UNSIGNED_INT), this._doNotHandleContextLost || (n._bufferView = t, n.format = e, n.invertY = i, n._compression = r), t) {
        var a = n._hardwareTexture;
        e === _.TEXTUREFORMAT_RGB && (t = Gh(t, n.width, n.height, o));
        var s = new Uint8Array(t.buffer, t.byteOffset, t.byteLength);
        this._textureHelper.updateTexture(s, n, n.width, n.height, n.depth, a.format, 0, 0, i, !1, 0, 0), n.generateMipMaps && this._generateMipmaps(n, this._uploadEncoder);
      }
      n.isReady = !0;
    }, st.prototype._readTexturePixels = function(n, t, e, i, r, o, a, s, l, c) {
      i === void 0 && (i = -1), r === void 0 && (r = 0), o === void 0 && (o = null), a === void 0 && (a = !0), s === void 0 && (s = !1), l === void 0 && (l = 0), c === void 0 && (c = 0);
      var u = n._hardwareTexture;
      return a && this.flushFramebuffer(), this._textureHelper.readPixels(u.underlyingResource, l, c, t, e, u.format, i, r, o, s);
    }, st.prototype._readTexturePixelsSync = function() {
      throw "_readTexturePixelsSync is unsupported in WebGPU!";
    };
    var kD = function(n) {
      function t() {
        return n !== null && n.apply(this, arguments) || this;
      }
      return D(t, n), t;
    }(dc);
    st.prototype._createHardwareRenderTargetWrapper = function(n, t, e) {
      var i = new kD(n, t, e, this);
      return this._renderTargetWrapperCache.push(i), i;
    }, st.prototype.createRenderTargetTexture = function(n, t) {
      var e, i, r, o = this._createHardwareRenderTargetWrapper(!1, !1, n), a = {};
      t !== void 0 && typeof t == "object" ? (a.generateMipMaps = t.generateMipMaps, a.generateDepthBuffer = t.generateDepthBuffer === void 0 || t.generateDepthBuffer, a.generateStencilBuffer = a.generateDepthBuffer && t.generateStencilBuffer, a.samplingMode = t.samplingMode === void 0 ? _.TEXTURE_TRILINEAR_SAMPLINGMODE : t.samplingMode, a.creationFlags = (e = t.creationFlags) !== null && e !== void 0 ? e : 0, a.noColorAttachment = !!t.noColorAttachment, a.samples = t.samples, a.label = t.label) : (a.generateMipMaps = t, a.generateDepthBuffer = !0, a.generateStencilBuffer = !1, a.samplingMode = _.TEXTURE_TRILINEAR_SAMPLINGMODE, a.creationFlags = 0, a.noColorAttachment = !1);
      var s = a.noColorAttachment ? null : this._createInternalTexture(n, t, !0, ut.RenderTarget);
      return o.label = (i = a.label) !== null && i !== void 0 ? i : "RenderTargetWrapper", o._samples = (r = a.samples) !== null && r !== void 0 ? r : 1, o._generateDepthBuffer = a.generateDepthBuffer, o._generateStencilBuffer = !!a.generateStencilBuffer, o.setTextures(s), (o._generateDepthBuffer || o._generateStencilBuffer) && o.createDepthStencilTexture(0, !1, o._generateStencilBuffer, o.samples, a.generateStencilBuffer ? _.TEXTUREFORMAT_DEPTH24_STENCIL8 : _.TEXTUREFORMAT_DEPTH32_FLOAT, a.label ? a.label + "-DepthStencil" : void 0), s && (t !== void 0 && typeof t == "object" && t.createMipMaps && !a.generateMipMaps && (s.generateMipMaps = !0), this._textureHelper.createGPUTextureForInternalTexture(s, void 0, void 0, void 0, a.creationFlags), t !== void 0 && typeof t == "object" && t.createMipMaps && !a.generateMipMaps && (s.generateMipMaps = !1)), o;
    }, st.prototype._createDepthStencilTexture = function(n, t) {
      var e = new Ut(this, ut.DepthStencil);
      e.label = t.label;
      var i = je({ bilinearFiltering: !1, comparisonFunction: 0, generateStencil: !1, samples: 1, depthTextureFormat: t.generateStencil ? _.TEXTUREFORMAT_DEPTH24_STENCIL8 : _.TEXTUREFORMAT_DEPTH32_FLOAT }, t);
      e.format = i.depthTextureFormat, this._setupDepthStencilTexture(e, n, i.generateStencil, i.bilinearFiltering, i.comparisonFunction, i.samples), this._textureHelper.createGPUTextureForInternalTexture(e);
      var r = e._hardwareTexture;
      return e.type = kr.GetTextureTypeFromFormat(r.format), this._internalTexturesCache.push(e), e;
    }, st.prototype._setupDepthStencilTexture = function(n, t, e, i, r, o) {
      o === void 0 && (o = 1);
      var a = t.width || t, s = t.height || t, l = t.layers || 0;
      n.baseWidth = a, n.baseHeight = s, n.width = a, n.height = s, n.is2DArray = l > 0, n.depth = l, n.isReady = !0, n.samples = o, n.generateMipMaps = !1, n.samplingMode = i ? _.TEXTURE_BILINEAR_SAMPLINGMODE : _.TEXTURE_NEAREST_SAMPLINGMODE, n.type = _.TEXTURETYPE_FLOAT, n._comparisonFunction = r, n._cachedWrapU = _.TEXTURE_CLAMP_ADDRESSMODE, n._cachedWrapV = _.TEXTURE_CLAMP_ADDRESSMODE;
    }, st.prototype.updateRenderTargetTextureSampleCount = function(n, t) {
      return n && n.texture && n.samples !== t && (t = Math.min(t, this.getCaps().maxMSAASamples), this._textureHelper.createMSAATexture(n.texture, t), n._depthStencilTexture && (this._textureHelper.createMSAATexture(n._depthStencilTexture, t), n._depthStencilTexture.samples = t), n._samples = t, n.texture.samples = t), t;
    }, st.prototype.createRenderTargetCubeTexture = function(n, t) {
      var e, i = this._createHardwareRenderTargetWrapper(!1, !0, n), r = je({ generateMipMaps: !0, generateDepthBuffer: !0, generateStencilBuffer: !1, type: _.TEXTURETYPE_UNSIGNED_INT, samplingMode: _.TEXTURE_TRILINEAR_SAMPLINGMODE, format: _.TEXTUREFORMAT_RGBA, samples: 1 }, t);
      r.generateStencilBuffer = r.generateDepthBuffer && r.generateStencilBuffer, i.label = (e = r.label) !== null && e !== void 0 ? e : "RenderTargetWrapper", i._generateDepthBuffer = r.generateDepthBuffer, i._generateStencilBuffer = r.generateStencilBuffer;
      var o = new Ut(this, ut.RenderTarget);
      return o.width = n, o.height = n, o.depth = 0, o.isReady = !0, o.isCube = !0, o.samples = r.samples, o.generateMipMaps = r.generateMipMaps, o.samplingMode = r.samplingMode, o.type = r.type, o.format = r.format, this._internalTexturesCache.push(o), i.setTextures(o), (i._generateDepthBuffer || i._generateStencilBuffer) && i.createDepthStencilTexture(0, r.samplingMode === void 0 || r.samplingMode === _.TEXTURE_BILINEAR_SAMPLINGMODE || r.samplingMode === _.TEXTURE_LINEAR_LINEAR || r.samplingMode === _.TEXTURE_TRILINEAR_SAMPLINGMODE || r.samplingMode === _.TEXTURE_LINEAR_LINEAR_MIPLINEAR || r.samplingMode === _.TEXTURE_NEAREST_LINEAR_MIPNEAREST || r.samplingMode === _.TEXTURE_NEAREST_LINEAR_MIPLINEAR || r.samplingMode === _.TEXTURE_NEAREST_LINEAR || r.samplingMode === _.TEXTURE_LINEAR_LINEAR_MIPNEAREST, i._generateStencilBuffer, i.samples), t && t.createMipMaps && !r.generateMipMaps && (o.generateMipMaps = !0), this._textureHelper.createGPUTextureForInternalTexture(o), t && t.createMipMaps && !r.generateMipMaps && (o.generateMipMaps = !1), i;
    }, Jt.prototype.setTextureSampler = function(n, t) {
      this._engine.setTextureSampler(n, t);
    }, st.prototype.setTextureSampler = function(n, t) {
      var e;
      (e = this._currentMaterialContext) === null || e === void 0 || e.setSampler(n, t);
    }, Jt.prototype.setStorageBuffer = function(n, t) {
      this._engine.setStorageBuffer(n, t);
    }, st.prototype.createStorageBuffer = function(n, t, e) {
      return this._createBuffer(n, t | _.BUFFER_CREATIONFLAG_STORAGE, e);
    }, st.prototype.updateStorageBuffer = function(n, t, e, i) {
      var r, o = n;
      e === void 0 && (e = 0), i === void 0 ? i = (r = t instanceof Array ? new Float32Array(t) : t instanceof ArrayBuffer ? new Uint8Array(t) : t).byteLength : r = t instanceof Array ? new Float32Array(t) : t instanceof ArrayBuffer ? new Uint8Array(t) : t, this._bufferManager.setSubData(o, e, r, 0, i);
    }, st.prototype.readFromStorageBuffer = function(n, t, e, i) {
      var r = this;
      e = e || n.capacity;
      var o = this._bufferManager.createRawBuffer(e, $t.MapRead | $t.CopyDst, void 0, "TempReadFromStorageBuffer");
      return this._renderEncoder.copyBufferToBuffer(n.underlyingResource, t ?? 0, o, 0, e), new Promise(function(a, s) {
        r.onEndFrameObservable.addOnce(function() {
          o.mapAsync(Ya.Read, 0, e).then(function() {
            var l = o.getMappedRange(0, e), c = i;
            if (c === void 0)
              (c = new Uint8Array(e)).set(new Uint8Array(l));
            else {
              var u = c.constructor;
              (c = new u(c.buffer)).set(new u(l));
            }
            o.unmap(), r._bufferManager.releaseBuffer(o), a(c);
          }, function(l) {
            return s(l);
          });
        });
      });
    }, st.prototype.setStorageBuffer = function(n, t) {
      var e, i;
      (e = this._currentDrawContext) === null || e === void 0 || e.setBuffer(n, (i = t == null ? void 0 : t.getBuffer()) !== null && i !== void 0 ? i : null);
    }, st.prototype.createUniformBuffer = function(n, t) {
      var e;
      return e = n instanceof Array ? new Float32Array(n) : n, this._bufferManager.createBuffer(e, $t.Uniform | $t.CopyDst, t);
    }, st.prototype.createDynamicUniformBuffer = function(n, t) {
      return this.createUniformBuffer(n, t);
    }, st.prototype.updateUniformBuffer = function(n, t, e, i) {
      e === void 0 && (e = 0);
      var r, o = n;
      i === void 0 ? i = (r = t instanceof Float32Array ? t : new Float32Array(t)).byteLength : r = t instanceof Float32Array ? t : new Float32Array(t), this._bufferManager.setSubData(o, e, r, 0, i);
    }, st.prototype.bindUniformBufferBase = function(n, t, e) {
      this._currentDrawContext.setBuffer(e, n);
    }, st.prototype.bindUniformBlock = function() {
    }, st.prototype.updateVideoTexture = function(n, t, e) {
      var i, r = this;
      if (n && !n._isDisabled) {
        this._videoTextureSupported === void 0 && (this._videoTextureSupported = !0);
        var o = n._hardwareTexture;
        !((i = n._hardwareTexture) === null || i === void 0) && i.underlyingResource || (o = this._textureHelper.createGPUTextureForInternalTexture(n)), function(a) {
          return !(!a || a.underlyingResource === void 0);
        }(t) ? (this._textureHelper.copyVideoToTexture(t, n, o.format, !e), n.generateMipMaps && this._generateMipmaps(n), n.isReady = !0) : t && this.createImageBitmap(t).then(function(a) {
          r._textureHelper.updateTexture(a, n, n.width, n.height, n.depth, o.format, 0, 0, !e, !1, 0, 0), n.generateMipMaps && r._generateMipmaps(n), n.isReady = !0;
        }).catch(function() {
          n.isReady = !0;
        });
      }
    };
    var MC = function() {
      function n() {
      }
      return n.CreateAsync = function(t, e) {
        return Ft(this, void 0, void 0, function() {
          return Bt(this, function(i) {
            switch (i.label) {
              case 0:
                return [4, st.IsSupportedAsync];
              case 1:
                return i.sent() ? [2, st.CreateAsync(t, e)] : ve.IsSupported ? [2, new ve(t, void 0, e)] : [2, new zv(e)];
            }
          });
        });
      }, n;
    }(), zh = function() {
      function n() {
      }
      return n.COPY = 1, n.CUT = 2, n.PASTE = 3, n;
    }(), OC = function() {
      function n(t, e) {
        this.type = t, this.event = e;
      }
      return n.GetTypeFromCharacter = function(t) {
        switch (t) {
          case 67:
            return zh.COPY;
          case 86:
            return zh.PASTE;
          case 88:
            return zh.CUT;
          default:
            return -1;
        }
      }, n;
    }(), Hc = function(n) {
      function t(e, i, r, o, a, s, l) {
        i === void 0 && (i = ne.Gray()), r === void 0 && (r = Fi.DefaultUtilityLayer), o === void 0 && (o = null), a === void 0 && (a = 1), s === void 0 && (s = ne.Yellow()), l === void 0 && (l = ne.Gray());
        var c, u, h, d, p, f, m, g = this;
        (g = n.call(this, r) || this)._pointerObserver = null, g.snapDistance = 0, g.onSnapObservable = new H(), g.uniformScaling = !1, g.sensitivity = 1, g.dragScale = 1, g._isEnabled = !0, g._parent = null, g._dragging = !1, g._tmpVector = new v(0, 0, 0), g._parent = o, g._coloredMaterial = new Gt("", r.utilityLayerScene), g._coloredMaterial.diffuseColor = i, g._coloredMaterial.specularColor = i.subtract(new ne(0.1, 0.1, 0.1)), g._hoverMaterial = new Gt("", r.utilityLayerScene), g._hoverMaterial.diffuseColor = s, g._disableMaterial = new Gt("", r.utilityLayerScene), g._disableMaterial.diffuseColor = l, g._disableMaterial.alpha = 0.4, g._gizmoMesh = new ie("axis", r.utilityLayerScene);
        var y = g._createGizmoMesh(g._gizmoMesh, a), b = y.arrowMesh, T = y.arrowTail, S = g._createGizmoMesh(g._gizmoMesh, a + 4, !0);
        g._gizmoMesh.lookAt(g._rootMesh.position.add(e)), g._rootMesh.addChild(g._gizmoMesh, vn.PreserveScaling), g._gizmoMesh.scaling.scaleInPlace(1 / 3);
        var E = b.position.clone(), A = T.position.clone(), R = T.scaling.clone(), C = function(V) {
          var Y = V * (3 / g._rootMesh.scaling.length()) * 6;
          b.position.z += Y / 3.5, T.scaling.y += Y, g.dragScale = T.scaling.y, T.position.z = b.position.z / 2;
        }, L = function() {
          b.position.set(E.x, E.y, E.z), T.position.set(A.x, A.y, A.z), T.scaling.set(R.x, R.y, R.z), g.dragScale = T.scaling.y, g._dragging = !1;
        };
        g.dragBehavior = new Co({ dragAxis: e }), g.dragBehavior.moveAttached = !1, g.dragBehavior.updateDragPlane = !1, g._rootMesh.addBehavior(g.dragBehavior);
        var I = 0, O = { snapDistance: 0 };
        g.dragBehavior.onDragObservable.add(function(V) {
          if (g.attachedNode) {
            var Y = g.sensitivity * V.dragDistance * (3 * g.scaleRatio / g._rootMesh.scaling.length()), ee = g._tmpVector, J = !1, X = 0;
            g.uniformScaling ? ee.setAll(0.57735) : ee.copyFrom(e), g.snapDistance == 0 ? ee.scaleToRef(Y, ee) : (I += Y, Math.abs(I) > g.snapDistance ? (X = Math.floor(Math.abs(I) / g.snapDistance), I < 0 && (X *= -1), I %= g.snapDistance, ee.scaleToRef(g.snapDistance * X, ee), J = !0) : ee.scaleInPlace(0)), B.ScalingToRef(1 + ee.x, 1 + ee.y, 1 + ee.z, F.Matrix[2]), F.Matrix[2].multiplyToRef(g.attachedNode.getWorldMatrix(), F.Matrix[1]);
            var K = g.attachedNode._isMesh ? g.attachedNode : void 0;
            F.Matrix[1].decompose(F.Vector3[1], void 0, void 0, vn.PreserveScaling ? K : void 0);
            var te = 1e5;
            Math.abs(F.Vector3[1].x) < te && Math.abs(F.Vector3[1].y) < te && Math.abs(F.Vector3[1].z) < te && g.attachedNode.getWorldMatrix().copyFrom(F.Matrix[1]), J && (O.snapDistance = g.snapDistance * X, g.onSnapObservable.notifyObservers(O)), g._matrixChanged();
          }
        }), g.dragBehavior.onDragStartObservable.add(function() {
          g._dragging = !0;
        }), g.dragBehavior.onDragObservable.add(function(V) {
          return C(V.dragDistance);
        }), g.dragBehavior.onDragEndObservable.add(L), (h = (u = (c = o == null ? void 0 : o.uniformScaleGizmo) === null || c === void 0 ? void 0 : c.dragBehavior) === null || u === void 0 ? void 0 : u.onDragObservable) === null || h === void 0 || h.add(function(V) {
          return C(V.delta.y);
        }), (f = (p = (d = o == null ? void 0 : o.uniformScaleGizmo) === null || d === void 0 ? void 0 : d.dragBehavior) === null || p === void 0 ? void 0 : p.onDragEndObservable) === null || f === void 0 || f.add(L);
        var w = { gizmoMeshes: [b, T], colliderMeshes: [S.arrowMesh, S.arrowTail], material: g._coloredMaterial, hoverMaterial: g._hoverMaterial, disableMaterial: g._disableMaterial, active: !1, dragBehavior: g.dragBehavior };
        (m = g._parent) === null || m === void 0 || m.addToAxisCache(g._gizmoMesh, w), g._pointerObserver = r.utilityLayerScene.onPointerObservable.add(function(V) {
          var Y;
          if (!g._customMeshSet && (g._isHovered = w.colliderMeshes.indexOf((Y = V == null ? void 0 : V.pickInfo) === null || Y === void 0 ? void 0 : Y.pickedMesh) != -1, !g._parent)) {
            var ee = g.dragBehavior.enabled ? g._isHovered || g._dragging ? g._hoverMaterial : g._coloredMaterial : g._disableMaterial;
            g._setGizmoMeshMaterial(w.gizmoMeshes, ee);
          }
        }), g.dragBehavior.onEnabledObservable.add(function(V) {
          g._setGizmoMeshMaterial(w.gizmoMeshes, V ? g._coloredMaterial : g._disableMaterial);
        });
        var z = r._getSharedGizmoLight();
        return z.includedOnlyMeshes = z.includedOnlyMeshes.concat(g._rootMesh.getChildMeshes()), g;
      }
      return D(t, n), Object.defineProperty(t.prototype, "coloredMaterial", { get: function() {
        return this._coloredMaterial;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hoverMaterial", { get: function() {
        return this._hoverMaterial;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "disableMaterial", { get: function() {
        return this._disableMaterial;
      }, enumerable: !1, configurable: !0 }), t.prototype._createGizmoMesh = function(e, i, r) {
        r === void 0 && (r = !1);
        var o = Ur("yPosMesh", { size: 0.4 * (1 + (i - 1) / 4) }, this.gizmoLayer.utilityLayerScene), a = Fn("cylinder", { diameterTop: 5e-3 * i, height: 0.275, diameterBottom: 5e-3 * i, tessellation: 96 }, this.gizmoLayer.utilityLayerScene);
        return o.scaling.scaleInPlace(0.1), o.material = this._coloredMaterial, o.rotation.x = Math.PI / 2, o.position.z += 0.3, a.material = this._coloredMaterial, a.position.z += 0.1375, a.rotation.x = Math.PI / 2, r && (o.visibility = 0, a.visibility = 0), e.addChild(o), e.addChild(a), { arrowMesh: o, arrowTail: a };
      }, t.prototype._attachedNodeChanged = function(e) {
        this.dragBehavior && (this.dragBehavior.enabled = !!e);
      }, Object.defineProperty(t.prototype, "isEnabled", { get: function() {
        return this._isEnabled;
      }, set: function(e) {
        this._isEnabled = e, e ? this._parent && (this.attachedMesh = this._parent.attachedMesh, this.attachedNode = this._parent.attachedNode) : (this.attachedMesh = null, this.attachedNode = null);
      }, enumerable: !1, configurable: !0 }), t.prototype.dispose = function() {
        this.onSnapObservable.clear(), this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver), this.dragBehavior.detach(), this._gizmoMesh && this._gizmoMesh.dispose(), [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach(function(e) {
          e && e.dispose();
        }), n.prototype.dispose.call(this);
      }, t.prototype.setCustomMesh = function(e, i) {
        var r = this;
        i === void 0 && (i = !1), n.prototype.setCustomMesh.call(this, e), i && (this._rootMesh.getChildMeshes().forEach(function(o) {
          o.material = r._coloredMaterial, o.color && (o.color = r._coloredMaterial.diffuseColor);
        }), this._customMeshSet = !1);
      }, t;
    }(vn), hy = function(n) {
      function t(e, i) {
        e === void 0 && (e = ne.Gray()), i === void 0 && (i = Fi.DefaultKeepDepthUtilityLayer);
        var r = n.call(this, i) || this;
        r._boundingDimensions = new v(1, 1, 1), r._renderObserver = null, r._pointerObserver = null, r._scaleDragSpeed = 0.2, r._tmpQuaternion = new oe(), r._tmpVector = new v(0, 0, 0), r._tmpRotationMatrix = new B(), r.ignoreChildren = !1, r.includeChildPredicate = null, r.rotationSphereSize = 0.1, r.scaleBoxSize = 0.1, r.fixedDragMeshScreenSize = !1, r.fixedDragMeshBoundsSize = !1, r.fixedDragMeshScreenSizeDistanceFactor = 10, r.scalingSnapDistance = 0, r.rotationSnapDistance = 0, r.onDragStartObservable = new H(), r.onScaleBoxDragObservable = new H(), r.onScaleBoxDragEndObservable = new H(), r.onRotationSphereDragObservable = new H(), r.onRotationSphereDragEndObservable = new H(), r.scalePivot = null, r._axisFactor = new v(1, 1, 1), r._existingMeshScale = new v(), r._dragMesh = null, r._pointerDragBehavior = new Co(), r.updateScale = !1, r._anchorMesh = new Dt("anchor", i.utilityLayerScene), r._coloredMaterial = new Gt("", i.utilityLayerScene), r._coloredMaterial.disableLighting = !0, r._hoverColoredMaterial = new Gt("", i.utilityLayerScene), r._hoverColoredMaterial.disableLighting = !0, r._lineBoundingBox = new Dt("", i.utilityLayerScene), r._lineBoundingBox.rotationQuaternion = new oe();
        var o = [];
        o.push(si("lines", { points: [new v(0, 0, 0), new v(r._boundingDimensions.x, 0, 0)] }, i.utilityLayerScene)), o.push(si("lines", { points: [new v(0, 0, 0), new v(0, r._boundingDimensions.y, 0)] }, i.utilityLayerScene)), o.push(si("lines", { points: [new v(0, 0, 0), new v(0, 0, r._boundingDimensions.z)] }, i.utilityLayerScene)), o.push(si("lines", { points: [new v(r._boundingDimensions.x, 0, 0), new v(r._boundingDimensions.x, r._boundingDimensions.y, 0)] }, i.utilityLayerScene)), o.push(si("lines", { points: [new v(r._boundingDimensions.x, 0, 0), new v(r._boundingDimensions.x, 0, r._boundingDimensions.z)] }, i.utilityLayerScene)), o.push(si("lines", { points: [new v(0, r._boundingDimensions.y, 0), new v(r._boundingDimensions.x, r._boundingDimensions.y, 0)] }, i.utilityLayerScene)), o.push(si("lines", { points: [new v(0, r._boundingDimensions.y, 0), new v(0, r._boundingDimensions.y, r._boundingDimensions.z)] }, i.utilityLayerScene)), o.push(si("lines", { points: [new v(0, 0, r._boundingDimensions.z), new v(r._boundingDimensions.x, 0, r._boundingDimensions.z)] }, i.utilityLayerScene)), o.push(si("lines", { points: [new v(0, 0, r._boundingDimensions.z), new v(0, r._boundingDimensions.y, r._boundingDimensions.z)] }, i.utilityLayerScene)), o.push(si("lines", { points: [new v(r._boundingDimensions.x, r._boundingDimensions.y, r._boundingDimensions.z), new v(0, r._boundingDimensions.y, r._boundingDimensions.z)] }, i.utilityLayerScene)), o.push(si("lines", { points: [new v(r._boundingDimensions.x, r._boundingDimensions.y, r._boundingDimensions.z), new v(r._boundingDimensions.x, 0, r._boundingDimensions.z)] }, i.utilityLayerScene)), o.push(si("lines", { points: [new v(r._boundingDimensions.x, r._boundingDimensions.y, r._boundingDimensions.z), new v(r._boundingDimensions.x, r._boundingDimensions.y, 0)] }, i.utilityLayerScene)), o.forEach(function(f) {
          f.color = e, f.position.addInPlace(new v(-r._boundingDimensions.x / 2, -r._boundingDimensions.y / 2, -r._boundingDimensions.z / 2)), f.isPickable = !1, r._lineBoundingBox.addChild(f);
        }), r._rootMesh.addChild(r._lineBoundingBox), r.setColor(e), r._rotateSpheresParent = new Dt("", i.utilityLayerScene), r._rotateSpheresParent.rotationQuaternion = new oe();
        for (var a = function(f) {
          var m = yn("", { diameter: 1 }, i.utilityLayerScene);
          m.rotationQuaternion = new oe(), m.material = s._coloredMaterial, m.isNearGrabbable = !0;
          var g = new Co({});
          g.moveAttached = !1, g.updateDragPlane = !1, m.addBehavior(g);
          var y = new v(1, 0, 0), b = 0, T = 0;
          g.onDragStartObservable.add(function() {
            y.copyFrom(m.forward), b = 0, T = 0;
          }), g.onDragObservable.add(function(S) {
            if (r.onRotationSphereDragObservable.notifyObservers({}), r.attachedMesh) {
              var E = r.attachedMesh.parent;
              if (E && E.scaling && E.scaling.isNonUniformWithinEpsilon(1e-3))
                return void q.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
              tr._RemoveAndStorePivotPoint(r.attachedMesh);
              var A = y, R = S.dragPlaneNormal.scale(v.Dot(S.dragPlaneNormal, A)), C = A.subtract(R).normalizeToNew(), L = v.Dot(C, S.delta) < 0 ? Math.abs(S.delta.length()) : -Math.abs(S.delta.length());
              if (L = L / r._boundingDimensions.length() * r._anchorMesh.scaling.length(), r.attachedMesh.rotationQuaternion || (r.attachedMesh.rotationQuaternion = oe.RotationYawPitchRoll(r.attachedMesh.rotation.y, r.attachedMesh.rotation.x, r.attachedMesh.rotation.z)), r._anchorMesh.rotationQuaternion || (r._anchorMesh.rotationQuaternion = oe.RotationYawPitchRoll(r._anchorMesh.rotation.y, r._anchorMesh.rotation.x, r._anchorMesh.rotation.z)), b += L, Math.abs(b) <= 2 * Math.PI) {
                if (r.rotationSnapDistance > 0) {
                  var I = Math.floor(Math.abs(b) / r.rotationSnapDistance) * (b < 0 ? -1 : 1), O = r.rotationSnapDistance * I;
                  L = O - T, T = O;
                }
                f >= 8 ? oe.RotationYawPitchRollToRef(0, 0, L, r._tmpQuaternion) : f >= 4 ? oe.RotationYawPitchRollToRef(L, 0, 0, r._tmpQuaternion) : oe.RotationYawPitchRollToRef(0, L, 0, r._tmpQuaternion), r.attachedMesh.isUsingPivotMatrix() && r._anchorMesh.position.copyFrom(r.attachedMesh.position), r._anchorMesh.addChild(r.attachedMesh), r._anchorMesh.getScene().useRightHandedSystem && r._tmpQuaternion.conjugateInPlace(), r._tmpQuaternion.normalize(), r._anchorMesh.rotationQuaternion.multiplyToRef(r._tmpQuaternion, r._anchorMesh.rotationQuaternion), r._anchorMesh.rotationQuaternion.normalize(), r._anchorMesh.removeChild(r.attachedMesh), r.attachedMesh.setParent(E);
              }
              r.updateBoundingBox(), tr._RestorePivotPoint(r.attachedMesh);
            }
            r._updateDummy();
          }), g.onDragStartObservable.add(function() {
            r.onDragStartObservable.notifyObservers({}), r._selectNode(m);
          }), g.onDragEndObservable.add(function(S) {
            r.onRotationSphereDragEndObservable.notifyObservers({}), r._selectNode(null), r._updateDummy(), r._unhoverMeshOnTouchUp(S.pointerInfo, m);
          }), s._rotateSpheresParent.addChild(m);
        }, s = this, l = 0; l < 12; l++)
          a(l);
        for (r._rootMesh.addChild(r._rotateSpheresParent), r._scaleBoxesParent = new Dt("", i.utilityLayerScene), r._scaleBoxesParent.rotationQuaternion = new oe(), l = 0; l < 3; l++)
          for (var c = 0; c < 3; c++)
            for (var u = function(f) {
              var m = (l === 1 ? 1 : 0) + (c === 1 ? 1 : 0) + (f === 1 ? 1 : 0);
              if (m === 1 || m === 3)
                return "continue";
              var g = Ur("", { size: 1 }, i.utilityLayerScene);
              g.material = h._coloredMaterial, g._internalMetadata = m === 2, g.isNearGrabbable = !0;
              var y = new v(l - 1, c - 1, f - 1).normalize(), b = new Co({ dragAxis: y });
              b.updateDragPlane = !1, b.moveAttached = !1;
              var T = 0, S = 0;
              g.addBehavior(b), b.onDragObservable.add(function(E) {
                if (r.onScaleBoxDragObservable.notifyObservers({}), r.attachedMesh) {
                  var A = r.attachedMesh.parent;
                  if (A && A.scaling && A.scaling.isNonUniformWithinEpsilon(1e-3))
                    return void q.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
                  tr._RemoveAndStorePivotPoint(r.attachedMesh);
                  var R = E.dragDistance / r._boundingDimensions.length() * r._anchorMesh.scaling.length();
                  if (T += R, r.scalingSnapDistance > 0) {
                    var C = Math.floor(Math.abs(T) / r.scalingSnapDistance) * (T < 0 ? -1 : 1), L = r.scalingSnapDistance * C;
                    R = L - S, S = L;
                  }
                  var I = new v(R, R, R);
                  m === 2 && (I.x *= Math.abs(y.x), I.y *= Math.abs(y.y), I.z *= Math.abs(y.z)), I.scaleInPlace(r._scaleDragSpeed), I.multiplyInPlace(r._axisFactor), r.updateBoundingBox(), r.scalePivot ? (r.attachedMesh.getWorldMatrix().getRotationMatrixToRef(r._tmpRotationMatrix), r._boundingDimensions.scaleToRef(0.5, r._tmpVector), v.TransformCoordinatesToRef(r._tmpVector, r._tmpRotationMatrix, r._tmpVector), r._anchorMesh.position.subtractInPlace(r._tmpVector), r._boundingDimensions.multiplyToRef(r.scalePivot, r._tmpVector), v.TransformCoordinatesToRef(r._tmpVector, r._tmpRotationMatrix, r._tmpVector), r._anchorMesh.position.addInPlace(r._tmpVector)) : (g.absolutePosition.subtractToRef(r._anchorMesh.position, r._tmpVector), r._anchorMesh.position.subtractInPlace(r._tmpVector), r.attachedMesh.isUsingPivotMatrix() && r._anchorMesh.position.subtractInPlace(r.attachedMesh.getPivotPoint())), r._anchorMesh.addChild(r.attachedMesh), r._anchorMesh.scaling.addInPlace(I), (r._anchorMesh.scaling.x < 0 || r._anchorMesh.scaling.y < 0 || r._anchorMesh.scaling.z < 0) && r._anchorMesh.scaling.subtractInPlace(I), r._anchorMesh.removeChild(r.attachedMesh), r.attachedMesh.setParent(A), tr._RestorePivotPoint(r.attachedMesh);
                }
                r._updateDummy();
              }), b.onDragStartObservable.add(function() {
                r.onDragStartObservable.notifyObservers({}), r._selectNode(g), T = 0, S = 0;
              }), b.onDragEndObservable.add(function(E) {
                r.onScaleBoxDragEndObservable.notifyObservers({}), r._selectNode(null), r._updateDummy(), r._unhoverMeshOnTouchUp(E.pointerInfo, g);
              }), h._scaleBoxesParent.addChild(g);
            }, h = this, d = 0; d < 3; d++)
              u(d);
        r._rootMesh.addChild(r._scaleBoxesParent);
        var p = [];
        return r._pointerObserver = i.utilityLayerScene.onPointerObservable.add(function(f) {
          p[f.event.pointerId] ? f.pickInfo && f.pickInfo.pickedMesh != p[f.event.pointerId] && (p[f.event.pointerId].material = r._coloredMaterial, delete p[f.event.pointerId], r._isHovered = !1) : r._rotateSpheresParent.getChildMeshes().concat(r._scaleBoxesParent.getChildMeshes()).forEach(function(m) {
            f.pickInfo && f.pickInfo.pickedMesh == m && (p[f.event.pointerId] = m, m.material = r._hoverColoredMaterial, r._isHovered = !0);
          });
        }), r._renderObserver = r.gizmoLayer.originalScene.onBeforeRenderObservable.add(function() {
          r.attachedMesh && !r._existingMeshScale.equals(r.attachedMesh.scaling) ? r.updateBoundingBox() : (r.fixedDragMeshScreenSize || r.fixedDragMeshBoundsSize) && (r._updateRotationSpheres(), r._updateScaleBoxes()), r._dragMesh && r.attachedMesh && r._pointerDragBehavior.dragging && (r._lineBoundingBox.position.rotateByQuaternionToRef(r._rootMesh.rotationQuaternion, r._tmpVector), r.attachedMesh.setAbsolutePosition(r._dragMesh.position.add(r._tmpVector.scale(-1))));
        }), r.updateBoundingBox(), r;
      }
      return D(t, n), Object.defineProperty(t.prototype, "axisFactor", { get: function() {
        return this._axisFactor;
      }, set: function(e) {
        this._axisFactor = e;
        for (var i = this._scaleBoxesParent.getChildMeshes(), r = 0, o = 0; o < 3; o++)
          for (var a = 0; a < 3; a++)
            for (var s = 0; s < 3; s++) {
              var l = (o === 1 ? 1 : 0) + (a === 1 ? 1 : 0) + (s === 1 ? 1 : 0);
              if (l !== 1 && l !== 3) {
                if (i[r]) {
                  var c = new v(o - 1, a - 1, s - 1);
                  c.multiplyInPlace(this._axisFactor), i[r].setEnabled(c.lengthSquared() > Ge);
                }
                r++;
              }
            }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "scaleDragSpeed", { get: function() {
        return this._scaleDragSpeed;
      }, set: function(e) {
        this._scaleDragSpeed = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "coloredMaterial", { get: function() {
        return this._coloredMaterial;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hoverMaterial", { get: function() {
        return this._hoverColoredMaterial;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "pointerDragBehavior", { get: function() {
        return this._pointerDragBehavior;
      }, enumerable: !1, configurable: !0 }), t.prototype.setColor = function(e) {
        this._coloredMaterial.emissiveColor = e, this._hoverColoredMaterial.emissiveColor = e.clone().add(new ne(0.3, 0.3, 0.3)), this._lineBoundingBox.getChildren().forEach(function(i) {
          i.color && (i.color = e);
        });
      }, t.prototype._attachedNodeChanged = function(e) {
        var i = this;
        if (e) {
          this._anchorMesh.scaling.setAll(1), tr._RemoveAndStorePivotPoint(e);
          var r = e.parent;
          this._anchorMesh.addChild(e), this._anchorMesh.removeChild(e), e.setParent(r), tr._RestorePivotPoint(e), this.updateBoundingBox(), e.getChildMeshes(!1).forEach(function(o) {
            o.markAsDirty("scaling");
          }), this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(function() {
            i._updateDummy();
          });
        }
      }, t.prototype._selectNode = function(e) {
        this._rotateSpheresParent.getChildMeshes().concat(this._scaleBoxesParent.getChildMeshes()).forEach(function(i) {
          i.isVisible = !e || i == e;
        });
      }, t.prototype._unhoverMeshOnTouchUp = function(e, i) {
        (e == null ? void 0 : e.event) instanceof PointerEvent && (e == null ? void 0 : e.event.pointerType) === "touch" && (i.material = this._coloredMaterial);
      }, t.prototype.getScaleBoxes = function() {
        return this._scaleBoxesParent.getChildMeshes();
      }, t.prototype.updateBoundingBox = function() {
        if (this.attachedMesh) {
          tr._RemoveAndStorePivotPoint(this.attachedMesh);
          var e = this.attachedMesh.parent;
          this.attachedMesh.setParent(null), this._update(), this.attachedMesh.rotationQuaternion || (this.attachedMesh.rotationQuaternion = oe.RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z)), this._anchorMesh.rotationQuaternion || (this._anchorMesh.rotationQuaternion = oe.RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z)), this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion), this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion), this._tmpVector.copyFrom(this.attachedMesh.position), this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1), this.attachedMesh.position.set(0, 0, 0);
          var i = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);
          i.max.subtractToRef(i.min, this._boundingDimensions), this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions), this._lineBoundingBox.position.set((i.max.x + i.min.x) / 2, (i.max.y + i.min.y) / 2, (i.max.z + i.min.z) / 2), this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position), this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position), this._lineBoundingBox.computeWorldMatrix(), this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition), this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion), this.attachedMesh.position.copyFrom(this._tmpVector), this.attachedMesh.setParent(e);
        }
        this._updateRotationSpheres(), this._updateScaleBoxes(), this.attachedMesh && (this._existingMeshScale.copyFrom(this.attachedMesh.scaling), tr._RestorePivotPoint(this.attachedMesh));
      }, t.prototype._updateRotationSpheres = function() {
        for (var e = this._rotateSpheresParent.getChildMeshes(), i = 0; i < 3; i++)
          for (var r = 0; r < 2; r++)
            for (var o = 0; o < 2; o++) {
              var a = 4 * i + 2 * r + o;
              if (i == 0 && (e[a].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * r, this._boundingDimensions.z * o), e[a].position.addInPlace(new v(-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2)), e[a].lookAt(v.Cross(e[a].position.normalizeToNew(), v.Right()).normalizeToNew().add(e[a].position))), i == 1 && (e[a].position.set(this._boundingDimensions.x * r, this._boundingDimensions.y / 2, this._boundingDimensions.z * o), e[a].position.addInPlace(new v(-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2)), e[a].lookAt(v.Cross(e[a].position.normalizeToNew(), v.Up()).normalizeToNew().add(e[a].position))), i == 2 && (e[a].position.set(this._boundingDimensions.x * r, this._boundingDimensions.y * o, this._boundingDimensions.z / 2), e[a].position.addInPlace(new v(-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2)), e[a].lookAt(v.Cross(e[a].position.normalizeToNew(), v.Forward()).normalizeToNew().add(e[a].position))), this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
                e[a].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
                var s = this.rotationSphereSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
                e[a].scaling.set(s, s, s);
              } else
                this.fixedDragMeshBoundsSize ? e[a].scaling.set(this.rotationSphereSize * this._boundingDimensions.x, this.rotationSphereSize * this._boundingDimensions.y, this.rotationSphereSize * this._boundingDimensions.z) : e[a].scaling.set(this.rotationSphereSize, this.rotationSphereSize, this.rotationSphereSize);
            }
      }, t.prototype._updateScaleBoxes = function() {
        for (var e = this._scaleBoxesParent.getChildMeshes(), i = 0, r = 0; r < 3; r++)
          for (var o = 0; o < 3; o++)
            for (var a = 0; a < 3; a++) {
              var s = (r === 1 ? 1 : 0) + (o === 1 ? 1 : 0) + (a === 1 ? 1 : 0);
              if (s !== 1 && s !== 3) {
                if (e[i])
                  if (e[i].position.set(this._boundingDimensions.x * (r / 2), this._boundingDimensions.y * (o / 2), this._boundingDimensions.z * (a / 2)), e[i].position.addInPlace(new v(-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2)), this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
                    e[i].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
                    var l = this.scaleBoxSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
                    e[i].scaling.set(l, l, l);
                  } else
                    this.fixedDragMeshBoundsSize ? e[i].scaling.set(this.scaleBoxSize * this._boundingDimensions.x, this.scaleBoxSize * this._boundingDimensions.y, this.scaleBoxSize * this._boundingDimensions.z) : e[i].scaling.set(this.scaleBoxSize, this.scaleBoxSize, this.scaleBoxSize);
                i++;
              }
            }
      }, t.prototype.setEnabledRotationAxis = function(e) {
        this._rotateSpheresParent.getChildMeshes().forEach(function(i, r) {
          r < 4 ? i.setEnabled(e.indexOf("x") != -1) : r < 8 ? i.setEnabled(e.indexOf("y") != -1) : i.setEnabled(e.indexOf("z") != -1);
        });
      }, t.prototype.setEnabledScaling = function(e, i) {
        i === void 0 && (i = !1), this._scaleBoxesParent.getChildMeshes().forEach(function(r) {
          var o = e;
          i && r._internalMetadata === !0 && (o = !1), r.setEnabled(o);
        });
      }, t.prototype._updateDummy = function() {
        this._dragMesh && (this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition()), this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling), this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion));
      }, t.prototype.enableDragBehavior = function() {
        this._dragMesh = Ur("dummy", { size: 1 }, this.gizmoLayer.utilityLayerScene), this._dragMesh.visibility = 0, this._dragMesh.rotationQuaternion = new oe(), this._pointerDragBehavior.useObjectOrientationForDragging = !1, this._dragMesh.addBehavior(this._pointerDragBehavior);
      }, t.prototype.dispose = function() {
        this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver), this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver), this._lineBoundingBox.dispose(), this._rotateSpheresParent.dispose(), this._scaleBoxesParent.dispose(), this._dragMesh && this._dragMesh.dispose(), n.prototype.dispose.call(this);
      }, t.MakeNotPickableAndWrapInBoundingBox = function(e) {
        var i = function(l) {
          l.isPickable = !1, l.getChildMeshes().forEach(function(c) {
            i(c);
          });
        };
        i(e), e.rotationQuaternion || (e.rotationQuaternion = oe.RotationYawPitchRoll(e.rotation.y, e.rotation.x, e.rotation.z));
        var r = e.position.clone(), o = e.rotationQuaternion.clone();
        e.rotationQuaternion.set(0, 0, 0, 1), e.position.set(0, 0, 0);
        var a = Ur("box", { size: 1 }, e.getScene()), s = e.getHierarchyBoundingVectors();
        return s.max.subtractToRef(s.min, a.scaling), a.scaling.y === 0 && (a.scaling.y = Ge), a.scaling.x === 0 && (a.scaling.x = Ge), a.scaling.z === 0 && (a.scaling.z = Ge), a.position.set((s.max.x + s.min.x) / 2, (s.max.y + s.min.y) / 2, (s.max.z + s.min.z) / 2), e.addChild(a), e.rotationQuaternion.copyFrom(o), e.position.copyFrom(r), e.removeChild(a), a.addChild(e), a.visibility = 0, a;
      }, t.prototype.setCustomMesh = function() {
        q.Error("Custom meshes are not supported on this gizmo");
      }, t;
    }(vn), Wh = function(n) {
      function t(e, i, r, o, a, s, l, c, u) {
        var h;
        i === void 0 && (i = ne.Gray()), r === void 0 && (r = Fi.DefaultUtilityLayer), o === void 0 && (o = 32), a === void 0 && (a = null), l === void 0 && (l = 1), c === void 0 && (c = ne.Yellow()), u === void 0 && (u = ne.Gray());
        var d, p = this;
        (p = n.call(this, r) || this)._pointerObserver = null, p.snapDistance = 0, p.onSnapObservable = new H(), p.angle = 0, p.sensitivity = 1, p._isEnabled = !0, p._parent = null, p._dragging = !1, p._angles = new v(), p._parent = a, p._coloredMaterial = new Gt("", r.utilityLayerScene), p._coloredMaterial.diffuseColor = i, p._coloredMaterial.specularColor = i.subtract(new ne(0.1, 0.1, 0.1)), p._hoverMaterial = new Gt("", r.utilityLayerScene), p._hoverMaterial.diffuseColor = c, p._hoverMaterial.specularColor = c, p._disableMaterial = new Gt("", r.utilityLayerScene), p._disableMaterial.diffuseColor = u, p._disableMaterial.alpha = 0.4, p._gizmoMesh = new ie("", r.utilityLayerScene);
        var f = (h = p._createGizmoMesh(p._gizmoMesh, l, o)).rotationMesh, m = h.collider;
        p._rotationDisplayPlane = Ro("rotationDisplay", { size: 0.6, updatable: !1 }, p.gizmoLayer.utilityLayerScene), p._rotationDisplayPlane.rotation.z = 0.5 * Math.PI, p._rotationDisplayPlane.parent = p._gizmoMesh, p._rotationDisplayPlane.setEnabled(!1), Jt.ShadersStore.rotationGizmoVertexShader = t._RotationGizmoVertexShader, Jt.ShadersStore.rotationGizmoFragmentShader = t._RotationGizmoFragmentShader, p._rotationShaderMaterial = new dr("shader", p.gizmoLayer.utilityLayerScene, { vertex: "rotationGizmo", fragment: "rotationGizmo" }, { attributes: ["position", "uv"], uniforms: ["worldViewProjection", "angles", "rotationColor"] }), p._rotationShaderMaterial.backFaceCulling = !1, p.rotationColor = c, p._rotationDisplayPlane.material = p._rotationShaderMaterial, p._rotationDisplayPlane.visibility = 0.999, p._gizmoMesh.lookAt(p._rootMesh.position.add(e)), p._rootMesh.addChild(p._gizmoMesh, vn.PreserveScaling), p._gizmoMesh.scaling.scaleInPlace(1 / 3), p.dragBehavior = new Co({ dragPlaneNormal: e }), p.dragBehavior.moveAttached = !1, p.dragBehavior.maxDragAngle = t.MaxDragAngle, p.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = !0, p._rootMesh.addBehavior(p.dragBehavior);
        var g = new v(), y = new B(), b = new v(), T = new v();
        p.dragBehavior.onDragStartObservable.add(function(I) {
          p.attachedNode && (g.copyFrom(I.dragPlanePoint), p._rotationDisplayPlane.setEnabled(!0), p._rotationDisplayPlane.getWorldMatrix().invertToRef(y), v.TransformCoordinatesToRef(I.dragPlanePoint, y, g), p._angles.x = Math.atan2(g.y, g.x) + Math.PI, p._angles.y = 0, p._angles.z = p.updateGizmoRotationToMatchAttachedMesh ? 1 : 0, p._dragging = !0, g.copyFrom(I.dragPlanePoint), p._rotationShaderMaterial.setVector3("angles", p._angles), p.angle = 0);
        }), p.dragBehavior.onDragEndObservable.add(function() {
          p._dragging = !1, p._rotationDisplayPlane.setEnabled(!1);
        });
        var S = { snapDistance: 0 }, E = 0, A = new B(), R = new oe();
        p.dragBehavior.onDragObservable.add(function(I) {
          if (p.attachedNode) {
            var O = new v(1, 1, 1), w = new oe(0, 0, 0, 1), z = new v(0, 0, 0);
            if (p.attachedNode.getWorldMatrix().decompose(O, w, z), !(Math.abs(Math.abs(O.x) - Math.abs(O.y)) <= Ge && Math.abs(Math.abs(O.x) - Math.abs(O.z)) <= Ge) && p.updateGizmoRotationToMatchAttachedMesh)
              return void q.Warn("Unable to use a rotation gizmo matching mesh rotation with non uniform scaling. Use uniform scaling or set updateGizmoRotationToMatchAttachedMesh to false.");
            w.normalize();
            var V = p.updateGizmoPositionToMatchAttachedMesh ? z : p._rootMesh.absolutePosition, Y = I.dragPlanePoint.subtract(V).normalize(), ee = g.subtract(V).normalize(), J = v.Cross(Y, ee), X = v.Dot(Y, ee), K = Math.atan2(J.length(), X) * p.sensitivity;
            b.copyFrom(e), T.copyFrom(e), p.updateGizmoRotationToMatchAttachedMesh && (w.toRotationMatrix(y), T = v.TransformCoordinates(b, y));
            var te = !1;
            if (r.utilityLayerScene.activeCamera) {
              var se = r.utilityLayerScene.activeCamera.position.subtract(V).normalize();
              v.Dot(se, T) > 0 && (b.scaleInPlace(-1), T.scaleInPlace(-1), te = !0);
            }
            v.Dot(T, J) > 0 && (K = -K), F.Vector3[0].set(K, 0, 0), p.dragBehavior.validateDrag(F.Vector3[0]) || (K = 0);
            var _e = !1;
            if (p.snapDistance != 0)
              if (E += K, Math.abs(E) > p.snapDistance) {
                var xe = Math.floor(Math.abs(E) / p.snapDistance);
                E < 0 && (xe *= -1), E %= p.snapDistance, K = p.snapDistance * xe, _e = !0;
              } else
                K = 0;
            var Te = Math.sin(K / 2);
            if (R.set(b.x * Te, b.y * Te, b.z * Te, Math.cos(K / 2)), A.determinant() > 0) {
              var he = new v();
              R.toEulerAnglesToRef(he), oe.RotationYawPitchRollToRef(he.y, -he.x, -he.z, R);
            }
            if (p.updateGizmoRotationToMatchAttachedMesh)
              w.multiplyToRef(R, w), w.normalize(), B.ComposeToRef(O, w, z, p.attachedNode.getWorldMatrix());
            else {
              R.toRotationMatrix(F.Matrix[0]);
              var me = p.attachedNode.getWorldMatrix().getTranslation();
              p.attachedNode.getWorldMatrix().multiplyToRef(F.Matrix[0], p.attachedNode.getWorldMatrix()), p.attachedNode.getWorldMatrix().setTranslation(me);
            }
            g.copyFrom(I.dragPlanePoint), _e && (S.snapDistance = K, p.onSnapObservable.notifyObservers(S)), p._angles.y += K, p.angle += te ? -K : K, p._rotationShaderMaterial.setVector3("angles", p._angles), p._matrixChanged();
          }
        });
        var C = r._getSharedGizmoLight();
        C.includedOnlyMeshes = C.includedOnlyMeshes.concat(p._rootMesh.getChildMeshes(!1));
        var L = { colliderMeshes: [m], gizmoMeshes: [f], material: p._coloredMaterial, hoverMaterial: p._hoverMaterial, disableMaterial: p._disableMaterial, active: !1, dragBehavior: p.dragBehavior };
        return (d = p._parent) === null || d === void 0 || d.addToAxisCache(p._gizmoMesh, L), p._pointerObserver = r.utilityLayerScene.onPointerObservable.add(function(I) {
          var O;
          if (!p._customMeshSet && (p.dragBehavior.maxDragAngle = t.MaxDragAngle, p._isHovered = L.colliderMeshes.indexOf((O = I == null ? void 0 : I.pickInfo) === null || O === void 0 ? void 0 : O.pickedMesh) != -1, !p._parent)) {
            var w = L.dragBehavior.enabled ? p._isHovered || p._dragging ? p._hoverMaterial : p._coloredMaterial : p._disableMaterial;
            p._setGizmoMeshMaterial(L.gizmoMeshes, w);
          }
        }), p.dragBehavior.onEnabledObservable.add(function(I) {
          p._setGizmoMeshMaterial(L.gizmoMeshes, I ? p._coloredMaterial : p._disableMaterial);
        }), p;
      }
      return D(t, n), Object.defineProperty(t.prototype, "coloredMaterial", { get: function() {
        return this._coloredMaterial;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hoverMaterial", { get: function() {
        return this._hoverMaterial;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rotationColor", { set: function(e) {
        this._rotationShaderMaterial.setColor3("rotationColor", e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "disableMaterial", { get: function() {
        return this._disableMaterial;
      }, enumerable: !1, configurable: !0 }), t.prototype._createGizmoMesh = function(e, i, r) {
        var o = eo("ignore", { diameter: 0.6, thickness: 0.03 * i, tessellation: r }, this.gizmoLayer.utilityLayerScene);
        o.visibility = 0;
        var a = eo("", { diameter: 0.6, thickness: 5e-3 * i, tessellation: r }, this.gizmoLayer.utilityLayerScene);
        return a.material = this._coloredMaterial, a.rotation.x = Math.PI / 2, o.rotation.x = Math.PI / 2, e.addChild(a, vn.PreserveScaling), e.addChild(o, vn.PreserveScaling), { rotationMesh: a, collider: o };
      }, t.prototype._attachedNodeChanged = function(e) {
        this.dragBehavior && (this.dragBehavior.enabled = !!e);
      }, Object.defineProperty(t.prototype, "isEnabled", { get: function() {
        return this._isEnabled;
      }, set: function(e) {
        this._isEnabled = e, e ? this._parent && (this.attachedMesh = this._parent.attachedMesh) : this.attachedMesh = null;
      }, enumerable: !1, configurable: !0 }), t.prototype.dispose = function() {
        this.onSnapObservable.clear(), this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver), this.dragBehavior.detach(), this._gizmoMesh && this._gizmoMesh.dispose(), this._rotationDisplayPlane && this._rotationDisplayPlane.dispose(), this._rotationShaderMaterial && this._rotationShaderMaterial.dispose(), [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach(function(e) {
          e && e.dispose();
        }), n.prototype.dispose.call(this);
      }, t.MaxDragAngle = 9 * Math.PI / 20, t._RotationGizmoVertexShader = `
        precision highp float;
        attribute vec3 position;
        attribute vec2 uv;
        uniform mat4 worldViewProjection;
        varying vec3 vPosition;
        varying vec2 vUV;

        void main(void) {
            gl_Position = worldViewProjection * vec4(position, 1.0);
            vUV = uv;
        }`, t._RotationGizmoFragmentShader = `
        precision highp float;
        varying vec2 vUV;
        varying vec3 vPosition;
        uniform vec3 angles;
        uniform vec3 rotationColor;

        #define twopi 6.283185307

        void main(void) {
            vec2 uv = vUV - vec2(0.5);
            float angle = atan(uv.y, uv.x) + 3.141592;
            float delta = gl_FrontFacing ? angles.y : -angles.y;
            float begin = angles.x - delta * angles.z;
            float start = (begin < (begin + delta)) ? begin : (begin + delta);
            float end = (begin > (begin + delta)) ? begin : (begin + delta);
            float len = sqrt(dot(uv,uv));
            float opacity = 1. - step(0.5, len);

            float base = abs(floor(start / twopi)) * twopi;
            start += base;
            end += base;

            float intensity = 0.;
            for (int i = 0; i < 5; i++)
            {
                intensity += max(step(start, angle) - step(end, angle), 0.);
                angle += twopi;
            }
            gl_FragColor = vec4(rotationColor, min(intensity * 0.25, 0.8)) * opacity;
        }
    `, t;
    }(vn), dy = function(n) {
      function t(e, i, r, o, a, s) {
        e === void 0 && (e = Fi.DefaultUtilityLayer), i === void 0 && (i = 32), r === void 0 && (r = !1), o === void 0 && (o = 1);
        var l = n.call(this, e) || this;
        l.onDragStartObservable = new H(), l.onDragObservable = new H(), l.onDragEndObservable = new H(), l._observables = [], l._sensitivity = 1, l._gizmoAxisCache = /* @__PURE__ */ new Map();
        var c = s && s.xOptions && s.xOptions.color ? s.xOptions.color : ne.Red().scale(0.5), u = s && s.yOptions && s.yOptions.color ? s.yOptions.color : ne.Green().scale(0.5), h = s && s.zOptions && s.zOptions.color ? s.zOptions.color : ne.Blue().scale(0.5);
        return l.xGizmo = new Wh(new v(1, 0, 0), c, e, i, l, r, o), l.yGizmo = new Wh(new v(0, 1, 0), u, e, i, l, r, o), l.zGizmo = new Wh(new v(0, 0, 1), h, e, i, l, r, o), [l.xGizmo, l.yGizmo, l.zGizmo].forEach(function(d) {
          s && s.updateScale != null && (d.updateScale = s.updateScale), d.dragBehavior.onDragStartObservable.add(function() {
            l.onDragStartObservable.notifyObservers({});
          }), d.dragBehavior.onDragObservable.add(function() {
            l.onDragObservable.notifyObservers({});
          }), d.dragBehavior.onDragEndObservable.add(function() {
            l.onDragEndObservable.notifyObservers({});
          });
        }), l.attachedMesh = null, l.attachedNode = null, a ? a.addToAxisCache(l._gizmoAxisCache) : vn.GizmoAxisPointerObserver(e, l._gizmoAxisCache), l;
      }
      return D(t, n), Object.defineProperty(t.prototype, "attachedMesh", { get: function() {
        return this._meshAttached;
      }, set: function(e) {
        this._meshAttached = e, this._nodeAttached = e, this._checkBillboardTransform(), [this.xGizmo, this.yGizmo, this.zGizmo].forEach(function(i) {
          i.isEnabled ? i.attachedMesh = e : i.attachedMesh = null;
        });
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "attachedNode", { get: function() {
        return this._nodeAttached;
      }, set: function(e) {
        this._meshAttached = null, this._nodeAttached = e, this._checkBillboardTransform(), [this.xGizmo, this.yGizmo, this.zGizmo].forEach(function(i) {
          i.isEnabled ? i.attachedNode = e : i.attachedNode = null;
        });
      }, enumerable: !1, configurable: !0 }), t.prototype._checkBillboardTransform = function() {
        this._nodeAttached && this._nodeAttached.billboardMode && console.log("Rotation Gizmo will not work with transforms in billboard mode.");
      }, Object.defineProperty(t.prototype, "sensitivity", { get: function() {
        return this._sensitivity;
      }, set: function(e) {
        this._sensitivity = e, [this.xGizmo, this.yGizmo, this.zGizmo].forEach(function(i) {
          i && (i.sensitivity = e);
        });
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isHovered", { get: function() {
        var e = !1;
        return [this.xGizmo, this.yGizmo, this.zGizmo].forEach(function(i) {
          e = e || i.isHovered;
        }), e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "updateGizmoRotationToMatchAttachedMesh", { get: function() {
        return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
      }, set: function(e) {
        this.xGizmo && (this.xGizmo.updateGizmoRotationToMatchAttachedMesh = e, this.yGizmo.updateGizmoRotationToMatchAttachedMesh = e, this.zGizmo.updateGizmoRotationToMatchAttachedMesh = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "updateGizmoPositionToMatchAttachedMesh", { get: function() {
        return this.xGizmo.updateGizmoPositionToMatchAttachedMesh;
      }, set: function(e) {
        this.xGizmo && (this.xGizmo.updateGizmoPositionToMatchAttachedMesh = e, this.yGizmo.updateGizmoPositionToMatchAttachedMesh = e, this.zGizmo.updateGizmoPositionToMatchAttachedMesh = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "anchorPoint", { get: function() {
        return this._anchorPoint;
      }, set: function(e) {
        this._anchorPoint = e, [this.xGizmo, this.yGizmo, this.zGizmo].forEach(function(i) {
          i.anchorPoint = e;
        });
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "coordinatesMode", { set: function(e) {
        [this.xGizmo, this.yGizmo, this.zGizmo].forEach(function(i) {
          i.coordinatesMode = e;
        });
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "updateScale", { get: function() {
        return this.xGizmo.updateScale;
      }, set: function(e) {
        this.xGizmo && (this.xGizmo.updateScale = e, this.yGizmo.updateScale = e, this.zGizmo.updateScale = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "snapDistance", { get: function() {
        return this.xGizmo.snapDistance;
      }, set: function(e) {
        this.xGizmo && (this.xGizmo.snapDistance = e, this.yGizmo.snapDistance = e, this.zGizmo.snapDistance = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "scaleRatio", { get: function() {
        return this.xGizmo.scaleRatio;
      }, set: function(e) {
        this.xGizmo && (this.xGizmo.scaleRatio = e, this.yGizmo.scaleRatio = e, this.zGizmo.scaleRatio = e);
      }, enumerable: !1, configurable: !0 }), t.prototype.addToAxisCache = function(e, i) {
        this._gizmoAxisCache.set(e, i);
      }, t.prototype.dispose = function() {
        var e = this;
        this.xGizmo.dispose(), this.yGizmo.dispose(), this.zGizmo.dispose(), this.onDragStartObservable.clear(), this.onDragObservable.clear(), this.onDragEndObservable.clear(), this._observables.forEach(function(i) {
          e.gizmoLayer.utilityLayerScene.onPointerObservable.remove(i);
        });
      }, t.prototype.setCustomMesh = function() {
        q.Error("Custom meshes are not supported on this gizmo, please set the custom meshes on the gizmos contained within this one (gizmo.xGizmo, gizmo.yGizmo, gizmo.zGizmo)");
      }, t;
    }(vn), Hh = function(n) {
      function t(e, i, r, o, a, s) {
        i === void 0 && (i = ne.Gray()), r === void 0 && (r = Fi.DefaultUtilityLayer), o === void 0 && (o = null), a === void 0 && (a = ne.Yellow()), s === void 0 && (s = ne.Gray());
        var l, c = this;
        (c = n.call(this, r) || this)._pointerObserver = null, c.snapDistance = 0, c.onSnapObservable = new H(), c._isEnabled = !1, c._parent = null, c._dragging = !1, c._parent = o, c._coloredMaterial = new Gt("", r.utilityLayerScene), c._coloredMaterial.diffuseColor = i, c._coloredMaterial.specularColor = i.subtract(new ne(0.1, 0.1, 0.1)), c._hoverMaterial = new Gt("", r.utilityLayerScene), c._hoverMaterial.diffuseColor = a, c._disableMaterial = new Gt("", r.utilityLayerScene), c._disableMaterial.diffuseColor = s, c._disableMaterial.alpha = 0.4, c._gizmoMesh = t._CreatePlane(r.utilityLayerScene, c._coloredMaterial), c._gizmoMesh.lookAt(c._rootMesh.position.add(e)), c._gizmoMesh.scaling.scaleInPlace(1 / 3), c._gizmoMesh.parent = c._rootMesh;
        var u = 0, h = new v(), d = { snapDistance: 0 };
        c.dragBehavior = new Co({ dragPlaneNormal: e }), c.dragBehavior.moveAttached = !1, c._rootMesh.addBehavior(c.dragBehavior), c.dragBehavior.onDragObservable.add(function(m) {
          if (c.attachedNode) {
            if (c.snapDistance == 0)
              c.attachedNode.getWorldMatrix().getTranslationToRef(F.Vector3[0]), F.Vector3[0].addToRef(m.delta, F.Vector3[0]), c.dragBehavior.validateDrag(F.Vector3[0]) && c.attachedNode.getWorldMatrix().addTranslationFromFloats(m.delta.x, m.delta.y, m.delta.z);
            else if (u += m.dragDistance, Math.abs(u) > c.snapDistance) {
              var g = Math.floor(Math.abs(u) / c.snapDistance);
              u %= c.snapDistance, m.delta.normalizeToRef(h), h.scaleInPlace(c.snapDistance * g), c.attachedNode.getWorldMatrix().getTranslationToRef(F.Vector3[0]), F.Vector3[0].addToRef(h, F.Vector3[0]), c.dragBehavior.validateDrag(F.Vector3[0]) && (c.attachedNode.getWorldMatrix().addTranslationFromFloats(h.x, h.y, h.z), d.snapDistance = c.snapDistance * g, c.onSnapObservable.notifyObservers(d));
            }
            c._matrixChanged();
          }
        }), c.dragBehavior.onDragStartObservable.add(function() {
          c._dragging = !0;
        }), c.dragBehavior.onDragEndObservable.add(function() {
          c._dragging = !1;
        });
        var p = r._getSharedGizmoLight();
        p.includedOnlyMeshes = p.includedOnlyMeshes.concat(c._rootMesh.getChildMeshes(!1));
        var f = { gizmoMeshes: c._gizmoMesh.getChildMeshes(), colliderMeshes: c._gizmoMesh.getChildMeshes(), material: c._coloredMaterial, hoverMaterial: c._hoverMaterial, disableMaterial: c._disableMaterial, active: !1, dragBehavior: c.dragBehavior };
        return (l = c._parent) === null || l === void 0 || l.addToAxisCache(c._gizmoMesh, f), c._pointerObserver = r.utilityLayerScene.onPointerObservable.add(function(m) {
          var g;
          if (!c._customMeshSet && (c._isHovered = f.colliderMeshes.indexOf((g = m == null ? void 0 : m.pickInfo) === null || g === void 0 ? void 0 : g.pickedMesh) != -1, !c._parent)) {
            var y = f.dragBehavior.enabled ? c._isHovered || c._dragging ? c._hoverMaterial : c._coloredMaterial : c._disableMaterial;
            c._setGizmoMeshMaterial(f.gizmoMeshes, y);
          }
        }), c.dragBehavior.onEnabledObservable.add(function(m) {
          c._setGizmoMeshMaterial(f.gizmoMeshes, m ? c._coloredMaterial : c._disableMaterial);
        }), c;
      }
      return D(t, n), Object.defineProperty(t.prototype, "coloredMaterial", { get: function() {
        return this._coloredMaterial;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hoverMaterial", { get: function() {
        return this._hoverMaterial;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "disableMaterial", { get: function() {
        return this._disableMaterial;
      }, enumerable: !1, configurable: !0 }), t._CreatePlane = function(e, i) {
        var r = new ai("plane", e), o = Ro("dragPlane", { width: 0.1375, height: 0.1375, sideOrientation: 2 }, e);
        return o.material = i, o.parent = r, r;
      }, t.prototype._attachedNodeChanged = function(e) {
        this.dragBehavior && (this.dragBehavior.enabled = !!e);
      }, Object.defineProperty(t.prototype, "isEnabled", { get: function() {
        return this._isEnabled;
      }, set: function(e) {
        this._isEnabled = e, e ? this._parent && (this.attachedNode = this._parent.attachedNode) : this.attachedNode = null;
      }, enumerable: !1, configurable: !0 }), t.prototype.dispose = function() {
        this.onSnapObservable.clear(), this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver), this.dragBehavior.detach(), n.prototype.dispose.call(this), this._gizmoMesh && this._gizmoMesh.dispose(), [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach(function(e) {
          e && e.dispose();
        });
      }, t;
    }(vn), py = function(n) {
      function t(e, i, r) {
        e === void 0 && (e = Fi.DefaultUtilityLayer), i === void 0 && (i = 1);
        var o = n.call(this, e) || this;
        return o._meshAttached = null, o._nodeAttached = null, o._observables = [], o._gizmoAxisCache = /* @__PURE__ */ new Map(), o.onDragStartObservable = new H(), o.onDragObservable = new H(), o.onDragEndObservable = new H(), o._planarGizmoEnabled = !1, o.xGizmo = new Fo(new v(1, 0, 0), ne.Red().scale(0.5), e, o, i), o.yGizmo = new Fo(new v(0, 1, 0), ne.Green().scale(0.5), e, o, i), o.zGizmo = new Fo(new v(0, 0, 1), ne.Blue().scale(0.5), e, o, i), o.xPlaneGizmo = new Hh(new v(1, 0, 0), ne.Red().scale(0.5), o.gizmoLayer, o), o.yPlaneGizmo = new Hh(new v(0, 1, 0), ne.Green().scale(0.5), o.gizmoLayer, o), o.zPlaneGizmo = new Hh(new v(0, 0, 1), ne.Blue().scale(0.5), o.gizmoLayer, o), [o.xGizmo, o.yGizmo, o.zGizmo, o.xPlaneGizmo, o.yPlaneGizmo, o.zPlaneGizmo].forEach(function(a) {
          a.dragBehavior.onDragStartObservable.add(function() {
            o.onDragStartObservable.notifyObservers({});
          }), a.dragBehavior.onDragObservable.add(function() {
            o.onDragObservable.notifyObservers({});
          }), a.dragBehavior.onDragEndObservable.add(function() {
            o.onDragEndObservable.notifyObservers({});
          });
        }), o.attachedMesh = null, r ? r.addToAxisCache(o._gizmoAxisCache) : vn.GizmoAxisPointerObserver(e, o._gizmoAxisCache), o;
      }
      return D(t, n), Object.defineProperty(t.prototype, "attachedMesh", { get: function() {
        return this._meshAttached;
      }, set: function(e) {
        this._meshAttached = e, this._nodeAttached = e, [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(i) {
          i.isEnabled ? i.attachedMesh = e : i.attachedMesh = null;
        });
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "attachedNode", { get: function() {
        return this._nodeAttached;
      }, set: function(e) {
        this._meshAttached = null, this._nodeAttached = e, [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(i) {
          i.isEnabled ? i.attachedNode = e : i.attachedNode = null;
        });
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isHovered", { get: function() {
        var e = !1;
        return [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(i) {
          e = e || i.isHovered;
        }), e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "planarGizmoEnabled", { get: function() {
        return this._planarGizmoEnabled;
      }, set: function(e) {
        var i = this;
        this._planarGizmoEnabled = e, [this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(r) {
          r && (r.isEnabled = e, e && (r.attachedMesh ? r.attachedMesh = i.attachedMesh : r.attachedNode = i.attachedNode));
        }, this);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "updateGizmoRotationToMatchAttachedMesh", { get: function() {
        return this._updateGizmoRotationToMatchAttachedMesh;
      }, set: function(e) {
        this._updateGizmoRotationToMatchAttachedMesh = e, [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(i) {
          i && (i.updateGizmoRotationToMatchAttachedMesh = e);
        });
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "updateGizmoPositionToMatchAttachedMesh", { get: function() {
        return this._updateGizmoPositionToMatchAttachedMesh;
      }, set: function(e) {
        this._updateGizmoPositionToMatchAttachedMesh = e, [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(i) {
          i && (i.updateGizmoPositionToMatchAttachedMesh = e);
        });
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "anchorPoint", { get: function() {
        return this._anchorPoint;
      }, set: function(e) {
        this._anchorPoint = e, [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(i) {
          i.anchorPoint = e;
        });
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "coordinatesMode", { set: function(e) {
        [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(i) {
          i.coordinatesMode = e;
        });
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "updateScale", { get: function() {
        return this.xGizmo.updateScale;
      }, set: function(e) {
        this.xGizmo && (this.xGizmo.updateScale = e, this.yGizmo.updateScale = e, this.zGizmo.updateScale = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "snapDistance", { get: function() {
        return this._snapDistance;
      }, set: function(e) {
        this._snapDistance = e, [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(i) {
          i && (i.snapDistance = e);
        });
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "scaleRatio", { get: function() {
        return this._scaleRatio;
      }, set: function(e) {
        this._scaleRatio = e, [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(i) {
          i && (i.scaleRatio = e);
        });
      }, enumerable: !1, configurable: !0 }), t.prototype.addToAxisCache = function(e, i) {
        this._gizmoAxisCache.set(e, i);
      }, t.prototype.dispose = function() {
        var e = this;
        [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(i) {
          i && i.dispose();
        }), this._observables.forEach(function(i) {
          e.gizmoLayer.utilityLayerScene.onPointerObservable.remove(i);
        }), this.onDragStartObservable.clear(), this.onDragObservable.clear(), this.onDragEndObservable.clear();
      }, t.prototype.setCustomMesh = function() {
        q.Error("Custom meshes are not supported on this gizmo, please set the custom meshes on the gizmos contained within this one (gizmo.xGizmo, gizmo.yGizmo, gizmo.zGizmo,gizmo.xPlaneGizmo, gizmo.yPlaneGizmo, gizmo.zPlaneGizmo)");
      }, t;
    }(vn), fy = function(n) {
      function t(e, i, r) {
        e === void 0 && (e = Fi.DefaultUtilityLayer), i === void 0 && (i = 1);
        var o = n.call(this, e) || this;
        return o._meshAttached = null, o._nodeAttached = null, o._sensitivity = 1, o._observables = [], o._gizmoAxisCache = /* @__PURE__ */ new Map(), o.onDragStartObservable = new H(), o.onDragObservable = new H(), o.onDragEndObservable = new H(), o.uniformScaleGizmo = o._createUniformScaleMesh(), o.xGizmo = new Hc(new v(1, 0, 0), ne.Red().scale(0.5), e, o, i), o.yGizmo = new Hc(new v(0, 1, 0), ne.Green().scale(0.5), e, o, i), o.zGizmo = new Hc(new v(0, 0, 1), ne.Blue().scale(0.5), e, o, i), [o.xGizmo, o.yGizmo, o.zGizmo, o.uniformScaleGizmo].forEach(function(a) {
          a.dragBehavior.onDragStartObservable.add(function() {
            o.onDragStartObservable.notifyObservers({});
          }), a.dragBehavior.onDragObservable.add(function() {
            o.onDragObservable.notifyObservers({});
          }), a.dragBehavior.onDragEndObservable.add(function() {
            o.onDragEndObservable.notifyObservers({});
          });
        }), o.attachedMesh = null, o.attachedNode = null, r ? r.addToAxisCache(o._gizmoAxisCache) : vn.GizmoAxisPointerObserver(e, o._gizmoAxisCache), o;
      }
      return D(t, n), Object.defineProperty(t.prototype, "coloredMaterial", { get: function() {
        return this._coloredMaterial;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hoverMaterial", { get: function() {
        return this._hoverMaterial;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "disableMaterial", { get: function() {
        return this._disableMaterial;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "attachedMesh", { get: function() {
        return this._meshAttached;
      }, set: function(e) {
        this._meshAttached = e, this._nodeAttached = e, [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(i) {
          i.isEnabled ? i.attachedMesh = e : i.attachedMesh = null;
        });
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "attachedNode", { get: function() {
        return this._nodeAttached;
      }, set: function(e) {
        this._meshAttached = null, this._nodeAttached = e, [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(i) {
          i.isEnabled ? i.attachedNode = e : i.attachedNode = null;
        });
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "updateScale", { get: function() {
        return this.xGizmo.updateScale;
      }, set: function(e) {
        this.xGizmo && (this.xGizmo.updateScale = e, this.yGizmo.updateScale = e, this.zGizmo.updateScale = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isHovered", { get: function() {
        var e = !1;
        return [this.xGizmo, this.yGizmo, this.zGizmo].forEach(function(i) {
          e = e || i.isHovered;
        }), e;
      }, enumerable: !1, configurable: !0 }), t.prototype._createUniformScaleMesh = function() {
        this._coloredMaterial = new Gt("", this.gizmoLayer.utilityLayerScene), this._coloredMaterial.diffuseColor = ne.Gray(), this._hoverMaterial = new Gt("", this.gizmoLayer.utilityLayerScene), this._hoverMaterial.diffuseColor = ne.Yellow(), this._disableMaterial = new Gt("", this.gizmoLayer.utilityLayerScene), this._disableMaterial.diffuseColor = ne.Gray(), this._disableMaterial.alpha = 0.4;
        var e = new Hc(new v(0, 1, 0), ne.Gray().scale(0.5), this.gizmoLayer, this);
        e.updateGizmoRotationToMatchAttachedMesh = !1, e.uniformScaling = !0, this._uniformScalingMesh = xs("uniform", { type: 1 }, e.gizmoLayer.utilityLayerScene), this._uniformScalingMesh.scaling.scaleInPlace(0.01), this._uniformScalingMesh.visibility = 0, this._octahedron = xs("", { type: 1 }, e.gizmoLayer.utilityLayerScene), this._octahedron.scaling.scaleInPlace(7e-3), this._uniformScalingMesh.addChild(this._octahedron), e.setCustomMesh(this._uniformScalingMesh, !0);
        var i = this.gizmoLayer._getSharedGizmoLight();
        i.includedOnlyMeshes = i.includedOnlyMeshes.concat(this._octahedron);
        var r = { gizmoMeshes: [this._octahedron, this._uniformScalingMesh], colliderMeshes: [this._uniformScalingMesh], material: this._coloredMaterial, hoverMaterial: this._hoverMaterial, disableMaterial: this._disableMaterial, active: !1, dragBehavior: e.dragBehavior };
        return this.addToAxisCache(e._rootMesh, r), e;
      }, Object.defineProperty(t.prototype, "updateGizmoRotationToMatchAttachedMesh", { get: function() {
        return this._updateGizmoRotationToMatchAttachedMesh;
      }, set: function(e) {
        e ? (this._updateGizmoRotationToMatchAttachedMesh = e, [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(i) {
          i && (i.updateGizmoRotationToMatchAttachedMesh = e);
        })) : q.Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.");
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "anchorPoint", { get: function() {
        return this._anchorPoint;
      }, set: function(e) {
        this._anchorPoint = e, [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(i) {
          i && (i.anchorPoint = e);
        });
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "coordinatesMode", { set: function(e) {
        e == Ha.World && q.Warn("Setting coordinates Mode to world on scaling gizmo is not supported."), [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(i) {
          i.coordinatesMode = Ha.Local;
        });
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "snapDistance", { get: function() {
        return this._snapDistance;
      }, set: function(e) {
        this._snapDistance = e, [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(i) {
          i && (i.snapDistance = e);
        });
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "scaleRatio", { get: function() {
        return this._scaleRatio;
      }, set: function(e) {
        this._scaleRatio = e, [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(i) {
          i && (i.scaleRatio = e);
        });
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "sensitivity", { get: function() {
        return this._sensitivity;
      }, set: function(e) {
        this._sensitivity = e, [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(i) {
          i && (i.sensitivity = e);
        });
      }, enumerable: !1, configurable: !0 }), t.prototype.addToAxisCache = function(e, i) {
        this._gizmoAxisCache.set(e, i);
      }, t.prototype.dispose = function() {
        var e = this;
        [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(i) {
          i && i.dispose();
        }), this._observables.forEach(function(i) {
          e.gizmoLayer.utilityLayerScene.onPointerObservable.remove(i);
        }), this.onDragStartObservable.clear(), this.onDragObservable.clear(), this.onDragEndObservable.clear(), [this._uniformScalingMesh, this._octahedron].forEach(function(i) {
          i && i.dispose();
        }), [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach(function(i) {
          i && i.dispose();
        });
      }, t;
    }(vn), DC = function() {
      function n(t, e, i, r) {
        e === void 0 && (e = 1), i === void 0 && (i = Fi.DefaultUtilityLayer), r === void 0 && (r = Fi.DefaultKeepDepthUtilityLayer), this._scene = t, this.clearGizmoOnEmptyPointerEvent = !1, this.enableAutoPicking = !0, this.onAttachedToMeshObservable = new H(), this.onAttachedToNodeObservable = new H(), this._gizmosEnabled = { positionGizmo: !1, rotationGizmo: !1, scaleGizmo: !1, boundingBoxGizmo: !1 }, this._pointerObservers = [], this._attachedMesh = null, this._attachedNode = null, this._boundingBoxColor = ne.FromHexString("#0984e3"), this._thickness = 1, this._scaleRatio = 1, this._coordinatesMode = Ha.Local, this._gizmoAxisCache = /* @__PURE__ */ new Map(), this.boundingBoxDragBehavior = new Ng(), this.attachableMeshes = null, this.attachableNodes = null, this.usePointerToAttachGizmos = !0, this._defaultUtilityLayer = i, this._defaultKeepDepthUtilityLayer = r, this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = !1, this._thickness = e, this.gizmos = { positionGizmo: null, rotationGizmo: null, scaleGizmo: null, boundingBoxGizmo: null };
        var o = this._attachToMeshPointerObserver(t), a = vn.GizmoAxisPointerObserver(this._defaultUtilityLayer, this._gizmoAxisCache);
        this._pointerObservers = [o, a];
      }
      return Object.defineProperty(n.prototype, "keepDepthUtilityLayer", { get: function() {
        return this._defaultKeepDepthUtilityLayer;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "utilityLayer", { get: function() {
        return this._defaultUtilityLayer;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isHovered", { get: function() {
        var t = !1;
        for (var e in this.gizmos) {
          var i = this.gizmos[e];
          if (i && i.isHovered) {
            t = !0;
            break;
          }
        }
        return t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "scaleRatio", { get: function() {
        return this._scaleRatio;
      }, set: function(t) {
        this._scaleRatio = t, [this.gizmos.positionGizmo, this.gizmos.rotationGizmo, this.gizmos.scaleGizmo].forEach(function(e) {
          e && (e.scaleRatio = t);
        });
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "coordinatesMode", { get: function() {
        return this._coordinatesMode;
      }, set: function(t) {
        this._coordinatesMode = t, [this.gizmos.positionGizmo, this.gizmos.rotationGizmo, this.gizmos.scaleGizmo].forEach(function(e) {
          e && (e.coordinatesMode = t);
        });
      }, enumerable: !1, configurable: !0 }), n.prototype._attachToMeshPointerObserver = function(t) {
        var e = this;
        return t.onPointerObservable.add(function(i) {
          if (e.usePointerToAttachGizmos && i.type == Le.POINTERDOWN)
            if (i.pickInfo && i.pickInfo.pickedMesh) {
              if (e.enableAutoPicking) {
                var r = i.pickInfo.pickedMesh;
                if (e.attachableMeshes == null)
                  for (; r && r.parent != null; )
                    r = r.parent;
                else {
                  var o = !1;
                  e.attachableMeshes.forEach(function(a) {
                    r && (r == a || r.isDescendantOf(a)) && (r = a, o = !0);
                  }), o || (r = null);
                }
                r instanceof Dt ? e._attachedMesh != r && e.attachToMesh(r) : e.clearGizmoOnEmptyPointerEvent && e.attachToMesh(null);
              }
            } else
              e.clearGizmoOnEmptyPointerEvent && e.attachToMesh(null);
        });
      }, n.prototype.attachToMesh = function(t) {
        for (var e in this._attachedMesh && this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior), this._attachedNode && this._attachedNode.removeBehavior(this.boundingBoxDragBehavior), this._attachedMesh = t, this._attachedNode = null, this.gizmos) {
          var i = this.gizmos[e];
          i && this._gizmosEnabled[e] && (i.attachedMesh = t);
        }
        this.boundingBoxGizmoEnabled && this._attachedMesh && this._attachedMesh.addBehavior(this.boundingBoxDragBehavior), this.onAttachedToMeshObservable.notifyObservers(t);
      }, n.prototype.attachToNode = function(t) {
        for (var e in this._attachedMesh && this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior), this._attachedNode && this._attachedNode.removeBehavior(this.boundingBoxDragBehavior), this._attachedMesh = null, this._attachedNode = t, this.gizmos) {
          var i = this.gizmos[e];
          i && this._gizmosEnabled[e] && (i.attachedNode = t);
        }
        this.boundingBoxGizmoEnabled && this._attachedNode && this._attachedNode.addBehavior(this.boundingBoxDragBehavior), this.onAttachedToNodeObservable.notifyObservers(t);
      }, Object.defineProperty(n.prototype, "positionGizmoEnabled", { get: function() {
        return this._gizmosEnabled.positionGizmo;
      }, set: function(t) {
        t ? (this.gizmos.positionGizmo || (this.gizmos.positionGizmo = new py(this._defaultUtilityLayer, this._thickness, this)), this._attachedNode ? this.gizmos.positionGizmo.attachedNode = this._attachedNode : this.gizmos.positionGizmo.attachedMesh = this._attachedMesh) : this.gizmos.positionGizmo && (this.gizmos.positionGizmo.attachedNode = null), this._gizmosEnabled.positionGizmo = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "rotationGizmoEnabled", { get: function() {
        return this._gizmosEnabled.rotationGizmo;
      }, set: function(t) {
        t ? (this.gizmos.rotationGizmo || (this.gizmos.rotationGizmo = new dy(this._defaultUtilityLayer, 32, !1, this._thickness, this)), this._attachedNode ? this.gizmos.rotationGizmo.attachedNode = this._attachedNode : this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh) : this.gizmos.rotationGizmo && (this.gizmos.rotationGizmo.attachedNode = null), this._gizmosEnabled.rotationGizmo = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "scaleGizmoEnabled", { get: function() {
        return this._gizmosEnabled.scaleGizmo;
      }, set: function(t) {
        t ? (this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new fy(this._defaultUtilityLayer, this._thickness, this), this._attachedNode ? this.gizmos.scaleGizmo.attachedNode = this._attachedNode : this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh) : this.gizmos.scaleGizmo && (this.gizmos.scaleGizmo.attachedNode = null), this._gizmosEnabled.scaleGizmo = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "boundingBoxGizmoEnabled", { get: function() {
        return this._gizmosEnabled.boundingBoxGizmo;
      }, set: function(t) {
        t ? (this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new hy(this._boundingBoxColor, this._defaultKeepDepthUtilityLayer), this._attachedMesh ? this.gizmos.boundingBoxGizmo.attachedMesh = this._attachedMesh : this.gizmos.boundingBoxGizmo.attachedNode = this._attachedNode, this._attachedMesh ? (this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior), this._attachedMesh.addBehavior(this.boundingBoxDragBehavior)) : this._attachedNode && (this._attachedNode.removeBehavior(this.boundingBoxDragBehavior), this._attachedNode.addBehavior(this.boundingBoxDragBehavior))) : this.gizmos.boundingBoxGizmo && (this._attachedMesh ? this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior) : this._attachedNode && this._attachedNode.removeBehavior(this.boundingBoxDragBehavior), this.gizmos.boundingBoxGizmo.attachedNode = null), this._gizmosEnabled.boundingBoxGizmo = t;
      }, enumerable: !1, configurable: !0 }), n.prototype.addToAxisCache = function(t) {
        var e = this;
        t.size > 0 && t.forEach(function(i, r) {
          e._gizmoAxisCache.set(r, i);
        });
      }, n.prototype.dispose = function() {
        var t, e, i = this;
        for (var r in this._pointerObservers.forEach(function(a) {
          i._scene.onPointerObservable.remove(a);
        }), this.gizmos) {
          var o = this.gizmos[r];
          o && o.dispose();
        }
        this._defaultKeepDepthUtilityLayer !== Fi._DefaultKeepDepthUtilityLayer && ((t = this._defaultKeepDepthUtilityLayer) === null || t === void 0 || t.dispose()), this._defaultUtilityLayer !== Fi._DefaultUtilityLayer && ((e = this._defaultUtilityLayer) === null || e === void 0 || e.dispose()), this.boundingBoxDragBehavior.detach(), this.onAttachedToMeshObservable.clear();
      }, n;
    }(), Xh = function(n) {
      function t() {
        var e = n !== null && n.apply(this, arguments) || this;
        return e._needProjectionMatrixCompute = !0, e;
      }
      return D(t, n), t.prototype._setPosition = function(e) {
        this._position = e;
      }, Object.defineProperty(t.prototype, "position", { get: function() {
        return this._position;
      }, set: function(e) {
        this._setPosition(e);
      }, enumerable: !1, configurable: !0 }), t.prototype._setDirection = function(e) {
        this._direction = e;
      }, Object.defineProperty(t.prototype, "direction", { get: function() {
        return this._direction;
      }, set: function(e) {
        this._setDirection(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "shadowMinZ", { get: function() {
        return this._shadowMinZ;
      }, set: function(e) {
        this._shadowMinZ = e, this.forceProjectionMatrixCompute();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "shadowMaxZ", { get: function() {
        return this._shadowMaxZ;
      }, set: function(e) {
        this._shadowMaxZ = e, this.forceProjectionMatrixCompute();
      }, enumerable: !1, configurable: !0 }), t.prototype.computeTransformedInformation = function() {
        return !(!this.parent || !this.parent.getWorldMatrix || (this.transformedPosition || (this.transformedPosition = v.Zero()), v.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition), this.direction && (this.transformedDirection || (this.transformedDirection = v.Zero()), v.TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this.transformedDirection)), 0));
      }, t.prototype.getDepthScale = function() {
        return 50;
      }, t.prototype.getShadowDirection = function(e) {
        return this.transformedDirection ? this.transformedDirection : this.direction;
      }, t.prototype.getAbsolutePosition = function() {
        return this.transformedPosition ? this.transformedPosition : this.position;
      }, t.prototype.setDirectionToTarget = function(e) {
        return this.direction = v.Normalize(e.subtract(this.position)), this.direction;
      }, t.prototype.getRotation = function() {
        this.direction.normalize();
        var e = v.Cross(this.direction, qi.Y), i = v.Cross(e, this.direction);
        return v.RotationFromAxis(e, i, this.direction);
      }, t.prototype.needCube = function() {
        return !1;
      }, t.prototype.needProjectionMatrixCompute = function() {
        return this._needProjectionMatrixCompute;
      }, t.prototype.forceProjectionMatrixCompute = function() {
        this._needProjectionMatrixCompute = !0;
      }, t.prototype._initCache = function() {
        n.prototype._initCache.call(this), this._cache.position = v.Zero();
      }, t.prototype._isSynchronized = function() {
        return !!this._cache.position.equals(this.position);
      }, t.prototype.computeWorldMatrix = function(e) {
        return !e && this.isSynchronized() ? (this._currentRenderId = this.getScene().getRenderId(), this._worldMatrix) : (this._updateCache(), this._cache.position.copyFrom(this.position), this._worldMatrix || (this._worldMatrix = B.Identity()), B.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix), this.parent && this.parent.getWorldMatrix && (this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix), this._markSyncedWithParent()), this._worldMatrixDeterminantIsDirty = !0, this._worldMatrix);
      }, t.prototype.getDepthMinZ = function(e) {
        return this.shadowMinZ !== void 0 ? this.shadowMinZ : e.minZ;
      }, t.prototype.getDepthMaxZ = function(e) {
        return this.shadowMaxZ !== void 0 ? this.shadowMaxZ : e.maxZ;
      }, t.prototype.setShadowProjectionMatrix = function(e, i, r) {
        return this.customProjectionMatrixBuilder ? this.customProjectionMatrixBuilder(i, r, e) : this._setDefaultShadowProjectionMatrix(e, i, r), this;
      }, t.prototype._syncParentEnabledState = function() {
        n.prototype._syncParentEnabledState.call(this), this.parent && this.parent.getWorldMatrix || (this.transformedPosition = null, this.transformedDirection = null);
      }, x([ki()], t.prototype, "position", null), x([ki()], t.prototype, "direction", null), x([N()], t.prototype, "shadowMinZ", null), x([N()], t.prototype, "shadowMaxZ", null), t;
    }(Kn);
    oi.AddNodeConstructor("Light_Type_1", function(n, t) {
      return function() {
        return new jh(n, v.Zero(), t);
      };
    });
    var jh = function(n) {
      function t(e, i, r) {
        var o = n.call(this, e, r) || this;
        return o._shadowFrustumSize = 0, o._shadowOrthoScale = 0.1, o.autoUpdateExtends = !0, o.autoCalcShadowZBounds = !1, o._orthoLeft = Number.MAX_VALUE, o._orthoRight = Number.MIN_VALUE, o._orthoTop = Number.MIN_VALUE, o._orthoBottom = Number.MAX_VALUE, o.position = i.scale(-1), o.direction = i, o;
      }
      return D(t, n), Object.defineProperty(t.prototype, "shadowFrustumSize", { get: function() {
        return this._shadowFrustumSize;
      }, set: function(e) {
        this._shadowFrustumSize = e, this.forceProjectionMatrixCompute();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "shadowOrthoScale", { get: function() {
        return this._shadowOrthoScale;
      }, set: function(e) {
        this._shadowOrthoScale = e, this.forceProjectionMatrixCompute();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "orthoLeft", { get: function() {
        return this._orthoLeft;
      }, set: function(e) {
        this._orthoLeft = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "orthoRight", { get: function() {
        return this._orthoRight;
      }, set: function(e) {
        this._orthoRight = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "orthoTop", { get: function() {
        return this._orthoTop;
      }, set: function(e) {
        this._orthoTop = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "orthoBottom", { get: function() {
        return this._orthoBottom;
      }, set: function(e) {
        this._orthoBottom = e;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "DirectionalLight";
      }, t.prototype.getTypeID = function() {
        return Kn.LIGHTTYPEID_DIRECTIONALLIGHT;
      }, t.prototype._setDefaultShadowProjectionMatrix = function(e, i, r) {
        this.shadowFrustumSize > 0 ? this._setDefaultFixedFrustumShadowProjectionMatrix(e) : this._setDefaultAutoExtendShadowProjectionMatrix(e, i, r);
      }, t.prototype._setDefaultFixedFrustumShadowProjectionMatrix = function(e) {
        var i = this.getScene().activeCamera;
        i && B.OrthoLHToRef(this.shadowFrustumSize, this.shadowFrustumSize, this.shadowMinZ !== void 0 ? this.shadowMinZ : i.minZ, this.shadowMaxZ !== void 0 ? this.shadowMaxZ : i.maxZ, e, this.getScene().getEngine().isNDCHalfZRange);
      }, t.prototype._setDefaultAutoExtendShadowProjectionMatrix = function(e, i, r) {
        var o = this.getScene().activeCamera;
        if (o) {
          if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
            var a = v.Zero();
            this._orthoLeft = Number.MAX_VALUE, this._orthoRight = -Number.MAX_VALUE, this._orthoTop = -Number.MAX_VALUE, this._orthoBottom = Number.MAX_VALUE;
            for (var s = Number.MAX_VALUE, l = -Number.MAX_VALUE, c = 0; c < r.length; c++) {
              var u = r[c];
              if (u)
                for (var h = u.getBoundingInfo().boundingBox, d = 0; d < h.vectorsWorld.length; d++)
                  v.TransformCoordinatesToRef(h.vectorsWorld[d], i, a), a.x < this._orthoLeft && (this._orthoLeft = a.x), a.y < this._orthoBottom && (this._orthoBottom = a.y), a.x > this._orthoRight && (this._orthoRight = a.x), a.y > this._orthoTop && (this._orthoTop = a.y), this.autoCalcShadowZBounds && (a.z < s && (s = a.z), a.z > l && (l = a.z));
            }
            this.autoCalcShadowZBounds && (this._shadowMinZ = s, this._shadowMaxZ = l);
          }
          var p = this._orthoRight - this._orthoLeft, f = this._orthoTop - this._orthoBottom, m = this.shadowMinZ !== void 0 ? this.shadowMinZ : o.minZ, g = this.shadowMaxZ !== void 0 ? this.shadowMaxZ : o.maxZ, y = this.getScene().getEngine().useReverseDepthBuffer;
          B.OrthoOffCenterLHToRef(this._orthoLeft - p * this.shadowOrthoScale, this._orthoRight + p * this.shadowOrthoScale, this._orthoBottom - f * this.shadowOrthoScale, this._orthoTop + f * this.shadowOrthoScale, y ? g : m, y ? m : g, e, this.getScene().getEngine().isNDCHalfZRange);
        }
      }, t.prototype._buildUniformLayout = function() {
        this._uniformBuffer.addUniform("vLightData", 4), this._uniformBuffer.addUniform("vLightDiffuse", 4), this._uniformBuffer.addUniform("vLightSpecular", 4), this._uniformBuffer.addUniform("shadowsInfo", 3), this._uniformBuffer.addUniform("depthValues", 2), this._uniformBuffer.create();
      }, t.prototype.transferToEffect = function(e, i) {
        return this.computeTransformedInformation() ? (this._uniformBuffer.updateFloat4("vLightData", this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z, 1, i), this) : (this._uniformBuffer.updateFloat4("vLightData", this.direction.x, this.direction.y, this.direction.z, 1, i), this);
      }, t.prototype.transferToNodeMaterialEffect = function(e, i) {
        return this.computeTransformedInformation() ? (e.setFloat3(i, this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z), this) : (e.setFloat3(i, this.direction.x, this.direction.y, this.direction.z), this);
      }, t.prototype.getDepthMinZ = function(e) {
        var i = this._scene.getEngine();
        return !i.useReverseDepthBuffer && i.isNDCHalfZRange ? 0 : 1;
      }, t.prototype.getDepthMaxZ = function(e) {
        var i = this._scene.getEngine();
        return i.useReverseDepthBuffer && i.isNDCHalfZRange ? 0 : 1;
      }, t.prototype.prepareLightSpecificDefines = function(e, i) {
        e["DIRLIGHT" + i] = !0;
      }, x([N()], t.prototype, "shadowFrustumSize", null), x([N()], t.prototype, "shadowOrthoScale", null), x([N()], t.prototype, "autoUpdateExtends", void 0), x([N()], t.prototype, "autoCalcShadowZBounds", void 0), x([N("orthoLeft")], t.prototype, "_orthoLeft", void 0), x([N("orthoRight")], t.prototype, "_orthoRight", void 0), x([N("orthoTop")], t.prototype, "_orthoTop", void 0), x([N("orthoBottom")], t.prototype, "_orthoBottom", void 0), t;
    }(Xh);
    function Xc(n, t, e) {
      t === void 0 && (t = {}), t.diameter || (t.diameter = 1), t.segments || (t.segments = 16);
      var i = yn("", { slice: 0.5, diameter: t.diameter, segments: t.segments }, e), r = bl("", { radius: t.diameter / 2, tessellation: 3 * t.segments + (4 - t.segments) }, e);
      r.rotation.x = -Math.PI / 2, r.parent = i;
      var o = ie.MergeMeshes([r, i], !0);
      return o.name = n, o;
    }
    var NC = { CreateHemisphere: Xc };
    ie.CreateHemisphere = function(n, t, e, i) {
      return Xc(n, { segments: t, diameter: e }, i);
    }, oi.AddNodeConstructor("Light_Type_2", function(n, t) {
      return function() {
        return new r_(n, v.Zero(), v.Zero(), 0, 0, t);
      };
    });
    var r_ = function(n) {
      function t(e, i, r, o, a, s) {
        var l = n.call(this, e, s) || this;
        return l._innerAngle = 0, l._projectionTextureMatrix = B.Zero(), l._projectionTextureLightNear = 1e-6, l._projectionTextureLightFar = 1e3, l._projectionTextureUpDirection = v.Up(), l._projectionTextureViewLightDirty = !0, l._projectionTextureProjectionLightDirty = !0, l._projectionTextureDirty = !0, l._projectionTextureViewTargetVector = v.Zero(), l._projectionTextureViewLightMatrix = B.Zero(), l._projectionTextureProjectionLightMatrix = B.Zero(), l._projectionTextureScalingMatrix = B.FromValues(0.5, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 0.5, 0, 0.5, 0.5, 0.5, 1), l.position = i, l.direction = r, l.angle = o, l.exponent = a, l;
      }
      return D(t, n), Object.defineProperty(t.prototype, "angle", { get: function() {
        return this._angle;
      }, set: function(e) {
        this._angle = e, this._cosHalfAngle = Math.cos(0.5 * e), this._projectionTextureProjectionLightDirty = !0, this.forceProjectionMatrixCompute(), this._computeAngleValues();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "innerAngle", { get: function() {
        return this._innerAngle;
      }, set: function(e) {
        this._innerAngle = e, this._computeAngleValues();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "shadowAngleScale", { get: function() {
        return this._shadowAngleScale;
      }, set: function(e) {
        this._shadowAngleScale = e, this.forceProjectionMatrixCompute();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "projectionTextureMatrix", { get: function() {
        return this._projectionTextureMatrix;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "projectionTextureLightNear", { get: function() {
        return this._projectionTextureLightNear;
      }, set: function(e) {
        this._projectionTextureLightNear = e, this._projectionTextureProjectionLightDirty = !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "projectionTextureLightFar", { get: function() {
        return this._projectionTextureLightFar;
      }, set: function(e) {
        this._projectionTextureLightFar = e, this._projectionTextureProjectionLightDirty = !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "projectionTextureUpDirection", { get: function() {
        return this._projectionTextureUpDirection;
      }, set: function(e) {
        this._projectionTextureUpDirection = e, this._projectionTextureProjectionLightDirty = !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "projectionTexture", { get: function() {
        return this._projectionTexture;
      }, set: function(e) {
        var i = this;
        this._projectionTexture !== e && (this._projectionTexture = e, this._projectionTextureDirty = !0, this._projectionTexture && !this._projectionTexture.isReady() && (t._IsProceduralTexture(this._projectionTexture) ? this._projectionTexture.getEffect().executeWhenCompiled(function() {
          i._markMeshesAsLightDirty();
        }) : t._IsTexture(this._projectionTexture) && this._projectionTexture.onLoadObservable.addOnce(function() {
          i._markMeshesAsLightDirty();
        })));
      }, enumerable: !1, configurable: !0 }), t._IsProceduralTexture = function(e) {
        return e.onGeneratedObservable !== void 0;
      }, t._IsTexture = function(e) {
        return e.onLoadObservable !== void 0;
      }, Object.defineProperty(t.prototype, "projectionTextureProjectionLightMatrix", { get: function() {
        return this._projectionTextureProjectionLightMatrix;
      }, set: function(e) {
        this._projectionTextureProjectionLightMatrix = e, this._projectionTextureProjectionLightDirty = !1, this._projectionTextureDirty = !0;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "SpotLight";
      }, t.prototype.getTypeID = function() {
        return Kn.LIGHTTYPEID_SPOTLIGHT;
      }, t.prototype._setDirection = function(e) {
        n.prototype._setDirection.call(this, e), this._projectionTextureViewLightDirty = !0;
      }, t.prototype._setPosition = function(e) {
        n.prototype._setPosition.call(this, e), this._projectionTextureViewLightDirty = !0;
      }, t.prototype._setDefaultShadowProjectionMatrix = function(e, i, r) {
        var o = this.getScene().activeCamera;
        if (o) {
          this._shadowAngleScale = this._shadowAngleScale || 1;
          var a = this._shadowAngleScale * this._angle, s = this.shadowMinZ !== void 0 ? this.shadowMinZ : o.minZ, l = this.shadowMaxZ !== void 0 ? this.shadowMaxZ : o.maxZ, c = this.getScene().getEngine().useReverseDepthBuffer;
          B.PerspectiveFovLHToRef(a, 1, c ? l : s, c ? s : l, e, !0, this._scene.getEngine().isNDCHalfZRange, void 0, c);
        }
      }, t.prototype._computeProjectionTextureViewLightMatrix = function() {
        this._projectionTextureViewLightDirty = !1, this._projectionTextureDirty = !0, this.getAbsolutePosition().addToRef(this.direction, this._projectionTextureViewTargetVector), B.LookAtLHToRef(this.getAbsolutePosition(), this._projectionTextureViewTargetVector, this._projectionTextureUpDirection, this._projectionTextureViewLightMatrix);
      }, t.prototype._computeProjectionTextureProjectionLightMatrix = function() {
        this._projectionTextureProjectionLightDirty = !1, this._projectionTextureDirty = !0;
        var e = this.projectionTextureLightFar, i = this.projectionTextureLightNear, r = e / (e - i), o = -r * i, a = 1 / Math.tan(this._angle / 2);
        B.FromValuesToRef(a / 1, 0, 0, 0, 0, a, 0, 0, 0, 0, r, 1, 0, 0, o, 0, this._projectionTextureProjectionLightMatrix);
      }, t.prototype._computeProjectionTextureMatrix = function() {
        if (this._projectionTextureDirty = !1, this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix), this._projectionTexture instanceof ae) {
          var e = this._projectionTexture.uScale / 2, i = this._projectionTexture.vScale / 2;
          B.FromValuesToRef(e, 0, 0, 0, 0, i, 0, 0, 0, 0, 0.5, 0, 0.5, 0.5, 0.5, 1, this._projectionTextureScalingMatrix);
        }
        this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix, this._projectionTextureMatrix);
      }, t.prototype._buildUniformLayout = function() {
        this._uniformBuffer.addUniform("vLightData", 4), this._uniformBuffer.addUniform("vLightDiffuse", 4), this._uniformBuffer.addUniform("vLightSpecular", 4), this._uniformBuffer.addUniform("vLightDirection", 3), this._uniformBuffer.addUniform("vLightFalloff", 4), this._uniformBuffer.addUniform("shadowsInfo", 3), this._uniformBuffer.addUniform("depthValues", 2), this._uniformBuffer.create();
      }, t.prototype._computeAngleValues = function() {
        this._lightAngleScale = 1 / Math.max(1e-3, Math.cos(0.5 * this._innerAngle) - this._cosHalfAngle), this._lightAngleOffset = -this._cosHalfAngle * this._lightAngleScale;
      }, t.prototype.transferTexturesToEffect = function(e, i) {
        return this.projectionTexture && this.projectionTexture.isReady() && (this._projectionTextureViewLightDirty && this._computeProjectionTextureViewLightMatrix(), this._projectionTextureProjectionLightDirty && this._computeProjectionTextureProjectionLightMatrix(), this._projectionTextureDirty && this._computeProjectionTextureMatrix(), e.setMatrix("textureProjectionMatrix" + i, this._projectionTextureMatrix), e.setTexture("projectionLightSampler" + i, this.projectionTexture)), this;
      }, t.prototype.transferToEffect = function(e, i) {
        var r;
        return this.computeTransformedInformation() ? (this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent, i), r = v.Normalize(this.transformedDirection)) : (this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, this.exponent, i), r = v.Normalize(this.direction)), this._uniformBuffer.updateFloat4("vLightDirection", r.x, r.y, r.z, this._cosHalfAngle, i), this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, this._lightAngleScale, this._lightAngleOffset, i), this;
      }, t.prototype.transferToNodeMaterialEffect = function(e, i) {
        var r;
        return r = this.computeTransformedInformation() ? v.Normalize(this.transformedDirection) : v.Normalize(this.direction), this.getScene().useRightHandedSystem ? e.setFloat3(i, -r.x, -r.y, -r.z) : e.setFloat3(i, r.x, r.y, r.z), this;
      }, t.prototype.dispose = function() {
        n.prototype.dispose.call(this), this._projectionTexture && this._projectionTexture.dispose();
      }, t.prototype.getDepthMinZ = function(e) {
        var i = this._scene.getEngine(), r = this.shadowMinZ !== void 0 ? this.shadowMinZ : e.minZ;
        return i.useReverseDepthBuffer && i.isNDCHalfZRange ? r : this._scene.getEngine().isNDCHalfZRange ? 0 : r;
      }, t.prototype.getDepthMaxZ = function(e) {
        var i = this._scene.getEngine(), r = this.shadowMaxZ !== void 0 ? this.shadowMaxZ : e.maxZ;
        return i.useReverseDepthBuffer && i.isNDCHalfZRange ? 0 : r;
      }, t.prototype.prepareLightSpecificDefines = function(e, i) {
        e["SPOTLIGHT" + i] = !0, e["PROJECTEDLIGHTTEXTURE" + i] = !(!this.projectionTexture || !this.projectionTexture.isReady());
      }, x([N()], t.prototype, "angle", null), x([N()], t.prototype, "innerAngle", null), x([N()], t.prototype, "shadowAngleScale", null), x([N()], t.prototype, "exponent", void 0), x([N()], t.prototype, "projectionTextureLightNear", null), x([N()], t.prototype, "projectionTextureLightFar", null), x([N()], t.prototype, "projectionTextureUpDirection", null), x([St("projectedLightTexture")], t.prototype, "_projectionTexture", void 0), t;
    }(Xh), FC = function(n) {
      function t(e) {
        e === void 0 && (e = Fi.DefaultUtilityLayer);
        var i = n.call(this, e) || this;
        return i._cachedPosition = new v(), i._cachedForward = new v(0, 0, 1), i._pointerObserver = null, i.onClickedObservable = new H(), i._light = null, i.attachedMesh = new Dt("", i.gizmoLayer.utilityLayerScene), i._attachedMeshParent = new ai("parent", i.gizmoLayer.utilityLayerScene), i.attachedMesh.parent = i._attachedMeshParent, i._material = new Gt("light", i.gizmoLayer.utilityLayerScene), i._material.diffuseColor = new ne(0.5, 0.5, 0.5), i._material.specularColor = new ne(0.1, 0.1, 0.1), i._pointerObserver = e.utilityLayerScene.onPointerObservable.add(function(r) {
          i._light && (i._isHovered = !(!r.pickInfo || i._rootMesh.getChildMeshes().indexOf(r.pickInfo.pickedMesh) == -1), i._isHovered && r.event.button === 0 && i.onClickedObservable.notifyObservers(i._light));
        }, Le.POINTERDOWN), i;
      }
      return D(t, n), Object.defineProperty(t.prototype, "attachedNode", { get: function() {
        return this.attachedMesh;
      }, set: function(e) {
        console.warn("Nodes cannot be attached to LightGizmo. Attach to a mesh instead.");
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "light", { get: function() {
        return this._light;
      }, set: function(e) {
        var i = this;
        if (this._light = e, e) {
          this._lightMesh && this._lightMesh.dispose(), this._lightMesh = e instanceof Pc ? t._CreateHemisphericLightMesh(this.gizmoLayer.utilityLayerScene) : e instanceof jh ? t._CreateDirectionalLightMesh(this.gizmoLayer.utilityLayerScene) : e instanceof r_ ? t._CreateSpotLightMesh(this.gizmoLayer.utilityLayerScene) : t._CreatePointLightMesh(this.gizmoLayer.utilityLayerScene), this._lightMesh.getChildMeshes(!1).forEach(function(a) {
            a.material = i._material;
          }), this._lightMesh.parent = this._rootMesh;
          var r = this.gizmoLayer._getSharedGizmoLight();
          if (r.includedOnlyMeshes = r.includedOnlyMeshes.concat(this._lightMesh.getChildMeshes(!1)), this._lightMesh.rotationQuaternion = new oe(), this.attachedMesh.reservedDataStore || (this.attachedMesh.reservedDataStore = {}), this.attachedMesh.reservedDataStore.lightGizmo = this, e.parent && this._attachedMeshParent.freezeWorldMatrix(e.parent.getWorldMatrix()), e.position && (this.attachedMesh.position.copyFrom(e.position), this.attachedMesh.computeWorldMatrix(!0), this._cachedPosition.copyFrom(this.attachedMesh.position)), e.direction) {
            this.attachedMesh.setDirection(e.direction), this.attachedMesh.computeWorldMatrix(!0);
            var o = this._getMeshForward();
            this._cachedForward.copyFrom(o);
          }
          this._update();
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "material", { get: function() {
        return this._material;
      }, enumerable: !1, configurable: !0 }), t.prototype._getMeshForward = function() {
        var e = this.attachedMesh.forward;
        return this.attachedMesh.getScene().useRightHandedSystem && (e.negateToRef(F.Vector3[0]), e = F.Vector3[0]), e;
      }, t.prototype._update = function() {
        if (n.prototype._update.call(this), this._light) {
          if (this._light.parent && this._attachedMeshParent.freezeWorldMatrix(this._light.parent.getWorldMatrix()), this._light.position)
            if (this.attachedMesh.position.equals(this._cachedPosition))
              this.attachedMesh.position.copyFrom(this._light.position), this.attachedMesh.computeWorldMatrix(!0), this._cachedPosition.copyFrom(this.attachedMesh.position);
            else {
              var e = this.attachedMesh.position;
              this._light.position = new v(e.x, e.y, e.z), this._cachedPosition.copyFrom(this.attachedMesh.position);
            }
          if (this._light.direction) {
            var i = this._getMeshForward();
            if (v.DistanceSquared(i, this._cachedForward) > 1e-4) {
              var r = i;
              this._light.direction = new v(r.x, r.y, r.z), this._cachedForward.copyFrom(i);
            } else
              v.DistanceSquared(i, this._light.direction) > 1e-4 && (this.attachedMesh.setDirection(this._light.direction), this.attachedMesh.computeWorldMatrix(!0), this._cachedForward.copyFrom(i));
          }
        }
      }, t.prototype.dispose = function() {
        this.onClickedObservable.clear(), this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver), this._material.dispose(), n.prototype.dispose.call(this), this._attachedMeshParent.dispose();
      }, t._CreateHemisphericLightMesh = function(e) {
        var i = new ie("hemisphereLight", e), r = Xc(i.name, { segments: 10, diameter: 1 }, e);
        return r.position.z = -0.15, r.rotation.x = Math.PI / 2, r.parent = i, this._CreateLightLines(3, e).parent = i, i.scaling.scaleInPlace(t._Scale), i.rotation.x = Math.PI / 2, i;
      }, t._CreatePointLightMesh = function(e) {
        var i = new ie("pointLight", e), r = yn(i.name, { segments: 10, diameter: 1 }, e);
        return r.rotation.x = Math.PI / 2, r.parent = i, this._CreateLightLines(5, e).parent = i, i.scaling.scaleInPlace(t._Scale), i.rotation.x = Math.PI / 2, i;
      }, t._CreateSpotLightMesh = function(e) {
        var i = new ie("spotLight", e);
        yn(i.name, { segments: 10, diameter: 1 }, e).parent = i;
        var r = Xc(i.name, { segments: 10, diameter: 2 }, e);
        return r.parent = i, r.rotation.x = -Math.PI / 2, this._CreateLightLines(2, e).parent = i, i.scaling.scaleInPlace(t._Scale), i.rotation.x = Math.PI / 2, i;
      }, t._CreateDirectionalLightMesh = function(e) {
        var i = new ie("directionalLight", e), r = new ie(i.name, e);
        r.parent = i, yn(i.name, { diameter: 1.2, segments: 10 }, e).parent = r;
        var o = Fn(i.name, { updatable: !1, height: 6, diameterTop: 0.3, diameterBottom: 0.3, tessellation: 6, subdivisions: 1 }, e);
        o.parent = r;
        var a = o.clone(i.name);
        a.scaling.y = 0.5, a.position.x += 1.25;
        var s = o.clone(i.name);
        s.scaling.y = 0.5, s.position.x += -1.25;
        var l = Fn(i.name, { updatable: !1, height: 1, diameterTop: 0, diameterBottom: 0.6, tessellation: 6, subdivisions: 1 }, e);
        return l.position.y += 3, l.parent = r, (a = l.clone(i.name)).position.y = 1.5, a.position.x += 1.25, (s = l.clone(i.name)).position.y = 1.5, s.position.x += -1.25, r.scaling.scaleInPlace(t._Scale), r.rotation.z = Math.PI / 2, r.rotation.y = Math.PI / 2, i;
      }, t._Scale = 7e-3, t._CreateLightLines = function(e, i) {
        var r = new ie("root", i);
        r.rotation.x = Math.PI / 2;
        var o = new ie("linePivot", i);
        o.parent = r;
        var a = Fn("line", { updatable: !1, height: 2, diameterTop: 0.2, diameterBottom: 0.3, tessellation: 6, subdivisions: 1 }, i);
        if (a.position.y = a.scaling.y / 2 + 1.2, a.parent = o, e < 2)
          return o;
        for (var s = 0; s < 4; s++) {
          var l = o.clone("lineParentClone");
          l.rotation.z = Math.PI / 4, l.rotation.y = Math.PI / 2 + Math.PI / 2 * s, l.getChildMeshes()[0].scaling.y = 0.5, l.getChildMeshes()[0].scaling.x = l.getChildMeshes()[0].scaling.z = 0.8, l.getChildMeshes()[0].position.y = l.getChildMeshes()[0].scaling.y / 2 + 1.2;
        }
        if (e < 3)
          return r;
        for (s = 0; s < 4; s++) {
          var c = o.clone("linePivotClone");
          c.rotation.z = Math.PI / 2, c.rotation.y = Math.PI / 2 * s;
        }
        if (e < 4)
          return r;
        for (s = 0; s < 4; s++) {
          var u = o.clone("linePivotClone");
          u.rotation.z = Math.PI + Math.PI / 4, u.rotation.y = Math.PI / 2 + Math.PI / 2 * s, u.getChildMeshes()[0].scaling.y = 0.5, u.getChildMeshes()[0].scaling.x = u.getChildMeshes()[0].scaling.z = 0.8, u.getChildMeshes()[0].position.y = u.getChildMeshes()[0].scaling.y / 2 + 1.2;
        }
        return e < 5 || (o.clone("linePivotClone").rotation.z = Math.PI), r;
      }, t;
    }(vn), LC = function(n) {
      function t(e, i) {
        e === void 0 && (e = Fi.DefaultUtilityLayer);
        var r = n.call(this, e) || this;
        return r._pointerObserver = null, r.onClickedObservable = new H(), r._camera = null, r._invProjection = new B(), r._material = new Gt("cameraGizmoMaterial", r.gizmoLayer.utilityLayerScene), r._gizmoColor = i, r._material.diffuseColor = i ?? new ne(0.5, 0.5, 0.5), r._material.specularColor = new ne(0.1, 0.1, 0.1), r._pointerObserver = e.utilityLayerScene.onPointerObservable.add(function(o) {
          r._camera && (r._isHovered = !(!o.pickInfo || r._rootMesh.getChildMeshes().indexOf(o.pickInfo.pickedMesh) == -1), r._isHovered && o.event.button === 0 && r.onClickedObservable.notifyObservers(r._camera));
        }, Le.POINTERDOWN), r;
      }
      return D(t, n), Object.defineProperty(t.prototype, "displayFrustum", { get: function() {
        return this._cameraLinesMesh.isEnabled();
      }, set: function(e) {
        this._cameraLinesMesh.setEnabled(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "camera", { get: function() {
        return this._camera;
      }, set: function(e) {
        var i, r, o = this;
        if (this._camera = e, this.attachedNode = e, e) {
          this._cameraMesh && this._cameraMesh.dispose(), this._cameraLinesMesh && this._cameraLinesMesh.dispose(), this._cameraMesh = t._CreateCameraMesh(this.gizmoLayer.utilityLayerScene);
          var a = (r = (i = this._gizmoColor) === null || i === void 0 ? void 0 : i.toColor4(1)) !== null && r !== void 0 ? r : new Ie(1, 1, 1, 1);
          this._cameraLinesMesh = t._CreateCameraFrustum(this.gizmoLayer.utilityLayerScene, a), this._cameraMesh.getChildMeshes(!1).forEach(function(l) {
            l.material = o._material;
          }), this._cameraMesh.parent = this._rootMesh, this._cameraLinesMesh.parent = this._rootMesh, this.gizmoLayer.utilityLayerScene.activeCamera && this.gizmoLayer.utilityLayerScene.activeCamera.maxZ < 1.5 * e.maxZ && (this.gizmoLayer.utilityLayerScene.activeCamera.maxZ = 1.5 * e.maxZ), this.attachedNode.reservedDataStore || (this.attachedNode.reservedDataStore = {}), this.attachedNode.reservedDataStore.cameraGizmo = this;
          var s = this.gizmoLayer._getSharedGizmoLight();
          s.includedOnlyMeshes = s.includedOnlyMeshes.concat(this._cameraMesh.getChildMeshes(!1)), this._update();
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "material", { get: function() {
        return this._material;
      }, enumerable: !1, configurable: !0 }), t.prototype._update = function() {
        n.prototype._update.call(this), this._camera && (this._camera.getProjectionMatrix().invertToRef(this._invProjection), this._cameraLinesMesh.setPivotMatrix(this._invProjection, !1), this._cameraLinesMesh.scaling.x = 1 / this._rootMesh.scaling.x, this._cameraLinesMesh.scaling.y = 1 / this._rootMesh.scaling.y, this._cameraLinesMesh.scaling.z = 1 / this._rootMesh.scaling.z, this._cameraMesh.parent = null, this._cameraMesh.rotation.y = 0.5 * Math.PI * (this._camera.getScene().useRightHandedSystem ? 1 : -1), this._cameraMesh.parent = this._rootMesh);
      }, t.prototype.dispose = function() {
        this.onClickedObservable.clear(), this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver), this._cameraMesh && this._cameraMesh.dispose(), this._cameraLinesMesh && this._cameraLinesMesh.dispose(), this._material.dispose(), n.prototype.dispose.call(this);
      }, t._CreateCameraMesh = function(e) {
        var i = new ie("rootCameraGizmo", e), r = new ie(i.name, e);
        r.parent = i, Ur(i.name, { width: 1, height: 0.8, depth: 0.5 }, e).parent = r;
        var o = Fn(i.name, { height: 0.5, diameterTop: 0.8, diameterBottom: 0.8 }, e);
        o.parent = r, o.position.y = 0.3, o.position.x = -0.6, o.rotation.x = 0.5 * Math.PI;
        var a = Fn(i.name, { height: 0.5, diameterTop: 0.6, diameterBottom: 0.6 }, e);
        a.parent = r, a.position.y = 0.5, a.position.x = 0.4, a.rotation.x = 0.5 * Math.PI;
        var s = Fn(i.name, { height: 0.5, diameterTop: 0.5, diameterBottom: 0.5 }, e);
        return s.parent = r, s.position.y = 0, s.position.x = 0.6, s.rotation.z = 0.5 * Math.PI, i.scaling.scaleInPlace(t._Scale), r.position.x = -0.9, i;
      }, t._CreateCameraFrustum = function(e, i) {
        var r = new ie("rootCameraGizmo", e), o = new ie(r.name, e);
        o.parent = r;
        for (var a = 0; a < 4; a += 2)
          for (var s = 0; s < 4; s += 2) {
            var l = si("lines", { points: [new v(-1 + s, -1 + a, -1), new v(-1 + s, -1 + a, 1)], colors: [i, i] }, e);
            l.parent = o, l.alwaysSelectAsActiveMesh = !0, l.isPickable = !1, (l = si("lines", { points: [new v(-1, -1 + s, -1 + a), new v(1, -1 + s, -1 + a)], colors: [i, i] }, e)).parent = o, l.alwaysSelectAsActiveMesh = !0, l.isPickable = !1, (l = si("lines", { points: [new v(-1 + s, -1, -1 + a), new v(-1 + s, 1, -1 + a)], colors: [i, i] }, e)).parent = o, l.alwaysSelectAsActiveMesh = !0, l.isPickable = !1;
          }
        return r;
      }, t._Scale = 0.05, t;
    }(vn);
    re.IncludesShadersStore.kernelBlurVaryingDeclaration = "varying vec2 sampleCoord{X};", re.IncludesShadersStore.packingFunctions = `vec4 pack(float depth)
{const vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}
float unpack(vec4 color)
{const vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(color,bit_shift);}`, re.IncludesShadersStore.kernelBlurFragment = `#ifdef DOF
factor=sampleCoC(sampleCoord{X}); 
computedWeight=KERNEL_WEIGHT{X}*factor;sumOfWeights+=computedWeight;
#else
computedWeight=KERNEL_WEIGHT{X};
#endif
#ifdef PACKEDFLOAT
blend+=unpack(texture2D(textureSampler,sampleCoord{X}))*computedWeight;
#else
blend+=texture2D(textureSampler,sampleCoord{X})*computedWeight;
#endif
`, re.IncludesShadersStore.kernelBlurFragment2 = `#ifdef DOF
factor=sampleCoC(sampleCenter+delta*KERNEL_DEP_OFFSET{X});computedWeight=KERNEL_DEP_WEIGHT{X}*factor;sumOfWeights+=computedWeight;
#else
computedWeight=KERNEL_DEP_WEIGHT{X};
#endif
#ifdef PACKEDFLOAT
blend+=unpack(texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X}))*computedWeight;
#else
blend+=texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X})*computedWeight;
#endif
`, re.ShadersStore.kernelBlurPixelShader = `uniform sampler2D textureSampler;uniform vec2 delta;varying vec2 sampleCenter;
#ifdef DOF
uniform sampler2D circleOfConfusionSampler;float sampleCoC(in vec2 offset) {float coc=texture2D(circleOfConfusionSampler,offset).r;return coc; }
#endif
#include<kernelBlurVaryingDeclaration>[0..varyingCount]
#ifdef PACKEDFLOAT
#include<packingFunctions>
#endif
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void)
{float computedWeight=0.0;
#ifdef PACKEDFLOAT
float blend=0.;
#else
vec4 blend=vec4(0.);
#endif
#ifdef DOF
float sumOfWeights=CENTER_WEIGHT; 
float factor=0.0;
#ifdef PACKEDFLOAT
blend+=unpack(texture2D(textureSampler,sampleCenter))*CENTER_WEIGHT;
#else
blend+=texture2D(textureSampler,sampleCenter)*CENTER_WEIGHT;
#endif
#endif
#include<kernelBlurFragment>[0..varyingCount]
#include<kernelBlurFragment2>[0..depCount]
#ifdef PACKEDFLOAT
gl_FragColor=pack(blend);
#else
gl_FragColor=blend;
#endif
#ifdef DOF
gl_FragColor/=sumOfWeights;
#endif
}`, re.IncludesShadersStore.kernelBlurVertex = "sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};", re.ShadersStore.kernelBlurVertexShader = `attribute vec2 position;uniform vec2 delta;varying vec2 sampleCenter;
#include<kernelBlurVaryingDeclaration>[0..varyingCount]
const vec2 madd=vec2(0.5,0.5);
#define CUSTOM_VERTEX_DEFINITIONS
void main(void) {
#define CUSTOM_VERTEX_MAIN_BEGIN
sampleCenter=(position*madd+madd);
#include<kernelBlurVertex>[0..varyingCount]
gl_Position=vec4(position,0.0,1.0);
#define CUSTOM_VERTEX_MAIN_END
}`;
    var Cn = function(n) {
      function t(e, i, r, o, a, s, l, c, u, h, d, p) {
        s === void 0 && (s = ae.BILINEAR_SAMPLINGMODE), u === void 0 && (u = _.TEXTURETYPE_UNSIGNED_INT), h === void 0 && (h = ""), d === void 0 && (d = !1), p === void 0 && (p = _.TEXTUREFORMAT_RGBA);
        var f = n.call(this, e, "kernelBlur", ["delta", "direction"], ["circleOfConfusionSampler"], o, a, s, l, c, null, u, "kernelBlur", { varyingCount: 0, depCount: 0 }, !0, p) || this;
        return f._blockCompilation = d, f._packedFloat = !1, f._staticDefines = "", f._staticDefines = h, f.direction = i, f.onApplyObservable.add(function(m) {
          f._outputTexture ? m.setFloat2("delta", 1 / f._outputTexture.width * f.direction.x, 1 / f._outputTexture.height * f.direction.y) : m.setFloat2("delta", 1 / f.width * f.direction.x, 1 / f.height * f.direction.y);
        }), f.kernel = r, f;
      }
      return D(t, n), Object.defineProperty(t.prototype, "kernel", { get: function() {
        return this._idealKernel;
      }, set: function(e) {
        this._idealKernel !== e && (e = Math.max(e, 1), this._idealKernel = e, this._kernel = this._nearestBestKernel(e), this._blockCompilation || this._updateParameters());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "packedFloat", { get: function() {
        return this._packedFloat;
      }, set: function(e) {
        this._packedFloat !== e && (this._packedFloat = e, this._blockCompilation || this._updateParameters());
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "BlurPostProcess";
      }, t.prototype.updateEffect = function(e, i, r, o, a, s) {
        this._updateParameters(a, s);
      }, t.prototype._updateParameters = function(e, i) {
        for (var r = this._kernel, o = (r - 1) / 2, a = [], s = [], l = 0, c = 0; c < r; c++) {
          var u = c / (r - 1), h = this._gaussianWeight(2 * u - 1);
          a[c] = c - o, s[c] = h, l += h;
        }
        for (c = 0; c < s.length; c++)
          s[c] /= l;
        var d = [], p = [], f = [];
        for (c = 0; c <= o; c += 2) {
          var m = Math.min(c + 1, Math.floor(o));
          if (c === m)
            f.push({ o: a[c], w: s[c] });
          else {
            var g = m === o, y = s[c] + s[m] * (g ? 0.5 : 1), b = a[c] + 1 / (1 + s[c] / s[m]);
            b === 0 ? (f.push({ o: a[c], w: s[c] }), f.push({ o: a[c + 1], w: s[c + 1] })) : (f.push({ o: b, w: y }), f.push({ o: -b, w: y }));
          }
        }
        for (c = 0; c < f.length; c++)
          p[c] = f[c].o, d[c] = f[c].w;
        a = p, s = d;
        var T = this.getEngine().getCaps().maxVaryingVectors, S = Math.max(T, 0) - 1, E = Math.min(a.length, S), A = "";
        for (A += this._staticDefines, this._staticDefines.indexOf("DOF") != -1 && (A += "#define CENTER_WEIGHT ".concat(this._glslFloat(s[E - 1]), `
`), E--), c = 0; c < E; c++)
          A += "#define KERNEL_OFFSET".concat(c, " ").concat(this._glslFloat(a[c]), `
`), A += "#define KERNEL_WEIGHT".concat(c, " ").concat(this._glslFloat(s[c]), `
`);
        var R = 0;
        for (c = S; c < a.length; c++)
          A += "#define KERNEL_DEP_OFFSET".concat(R, " ").concat(this._glslFloat(a[c]), `
`), A += "#define KERNEL_DEP_WEIGHT".concat(R, " ").concat(this._glslFloat(s[c]), `
`), R++;
        this.packedFloat && (A += "#define PACKEDFLOAT 1"), this._blockCompilation = !1, n.prototype.updateEffect.call(this, A, null, null, { varyingCount: E, depCount: R }, e, i);
      }, t.prototype._nearestBestKernel = function(e) {
        for (var i = Math.round(e), r = 0, o = [i, i - 1, i + 1, i - 2, i + 2]; r < o.length; r++) {
          var a = o[r];
          if (a % 2 != 0 && Math.floor(a / 2) % 2 == 0 && a > 0)
            return Math.max(a, 3);
        }
        return Math.max(i, 3);
      }, t.prototype._gaussianWeight = function(e) {
        var i = 0.3333333333333333, r = -e * e / (2 * i * i);
        return 1 / (Math.sqrt(2 * Math.PI) * i) * Math.exp(r);
      }, t.prototype._glslFloat = function(e, i) {
        return i === void 0 && (i = 8), e.toFixed(i).replace(/0+$/, "");
      }, t._Parse = function(e, i, r, o) {
        return Ne.Parse(function() {
          return new t(e.name, e.direction, e.kernel, e.options, i, e.renderTargetSamplingMode, r.getEngine(), e.reusable, e.textureType, void 0, !1);
        }, e, r, o);
      }, x([N("kernel")], t.prototype, "_kernel", void 0), x([N("packedFloat")], t.prototype, "_packedFloat", void 0), x([ss()], t.prototype, "direction", void 0), t;
    }(nt);
    j("BABYLON.BlurPostProcess", Cn);
    var o_ = function(n) {
      function t(e, i, r, o, a, s, l) {
        a === void 0 && (a = _.TEXTURETYPE_UNSIGNED_INT), s === void 0 && (s = ae.BILINEAR_SAMPLINGMODE), l === void 0 && (l = !0);
        var c = n.call(this, e, i, r, o, !0, a, !1, s, l) || this;
        if (c.mirrorPlane = new xo(0, 1, 0, 1), c._transformMatrix = B.Zero(), c._mirrorMatrix = B.Zero(), c._adaptiveBlurKernel = 0, c._blurKernelX = 0, c._blurKernelY = 0, c._blurRatio = 1, !(r = c.getScene()))
          return c;
        c.ignoreCameraViewport = !0, c._updateGammaSpace(), c._imageProcessingConfigChangeObserver = r.imageProcessingConfiguration.onUpdateParameters.add(function() {
          c._updateGammaSpace();
        });
        var u, h = r.getEngine();
        return h.supportsUniformBuffers && (c._sceneUBO = r.createSceneUniformBuffer('Scene for Mirror Texture (name "'.concat(e, '")'))), c.onBeforeBindObservable.add(function() {
          var d;
          (d = h._debugPushGroup) === null || d === void 0 || d.call(h, "mirror generation for ".concat(e), 1);
        }), c.onAfterUnbindObservable.add(function() {
          var d;
          (d = h._debugPopGroup) === null || d === void 0 || d.call(h, 1);
        }), c.onBeforeRenderObservable.add(function() {
          c._sceneUBO && (c._currentSceneUBO = r.getSceneUniformBuffer(), r.setSceneUniformBuffer(c._sceneUBO), r.getSceneUniformBuffer().unbindEffect()), B.ReflectionToRef(c.mirrorPlane, c._mirrorMatrix), c._mirrorMatrix.multiplyToRef(r.getViewMatrix(), c._transformMatrix), r.setTransformMatrix(c._transformMatrix, r.getProjectionMatrix()), u = r.clipPlane, r.clipPlane = c.mirrorPlane, r._mirroredCameraPosition = v.TransformCoordinates(r.activeCamera.globalPosition, c._mirrorMatrix);
        }), c.onAfterRenderObservable.add(function() {
          c._sceneUBO && r.setSceneUniformBuffer(c._currentSceneUBO), r.updateTransformMatrix(), r._mirroredCameraPosition = null, r.clipPlane = u;
        }), c;
      }
      return D(t, n), Object.defineProperty(t.prototype, "blurRatio", { get: function() {
        return this._blurRatio;
      }, set: function(e) {
        this._blurRatio !== e && (this._blurRatio = e, this._preparePostProcesses());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "adaptiveBlurKernel", { set: function(e) {
        this._adaptiveBlurKernel = e, this._autoComputeBlurKernel();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "blurKernel", { set: function(e) {
        this.blurKernelX = e, this.blurKernelY = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "blurKernelX", { get: function() {
        return this._blurKernelX;
      }, set: function(e) {
        this._blurKernelX !== e && (this._blurKernelX = e, this._preparePostProcesses());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "blurKernelY", { get: function() {
        return this._blurKernelY;
      }, set: function(e) {
        this._blurKernelY !== e && (this._blurKernelY = e, this._preparePostProcesses());
      }, enumerable: !1, configurable: !0 }), t.prototype._autoComputeBlurKernel = function() {
        var e = this.getScene().getEngine(), i = this.getRenderWidth() / e.getRenderWidth(), r = this.getRenderHeight() / e.getRenderHeight();
        this.blurKernelX = this._adaptiveBlurKernel * i, this.blurKernelY = this._adaptiveBlurKernel * r;
      }, t.prototype._onRatioRescale = function() {
        this._sizeRatio && (this.resize(this._initialSizeParameter), this._adaptiveBlurKernel || this._preparePostProcesses()), this._adaptiveBlurKernel && this._autoComputeBlurKernel();
      }, t.prototype._updateGammaSpace = function() {
        var e = this.getScene();
        e && (this.gammaSpace = !e.imageProcessingConfiguration.isEnabled || !e.imageProcessingConfiguration.applyByPostProcess);
      }, t.prototype._preparePostProcesses = function() {
        if (this.clearPostProcesses(!0), this._blurKernelX && this._blurKernelY) {
          var e = this.getScene().getEngine(), i = e.getCaps().textureFloatRender && e.getCaps().textureFloatLinearFiltering ? _.TEXTURETYPE_FLOAT : _.TEXTURETYPE_HALF_FLOAT;
          this._blurX = new Cn("horizontal blur", new fe(1, 0), this._blurKernelX, this._blurRatio, null, ae.BILINEAR_SAMPLINGMODE, e, !1, i), this._blurX.autoClear = !1, this._blurRatio === 1 && this.samples < 2 && this._texture ? this._blurX.inputTexture = this._renderTarget : this._blurX.alwaysForcePOT = !0, this._blurY = new Cn("vertical blur", new fe(0, 1), this._blurKernelY, this._blurRatio, null, ae.BILINEAR_SAMPLINGMODE, e, !1, i), this._blurY.autoClear = !1, this._blurY.alwaysForcePOT = this._blurRatio !== 1, this.addPostProcess(this._blurX), this.addPostProcess(this._blurY);
        } else
          this._blurY && (this.removePostProcess(this._blurY), this._blurY.dispose(), this._blurY = null), this._blurX && (this.removePostProcess(this._blurX), this._blurX.dispose(), this._blurX = null);
      }, t.prototype.clone = function() {
        var e = this.getScene();
        if (!e)
          return this;
        var i = this.getSize(), r = new t(this.name, i.width, e, this._renderTargetOptions.generateMipMaps, this._renderTargetOptions.type, this._renderTargetOptions.samplingMode, this._renderTargetOptions.generateDepthBuffer);
        return r.hasAlpha = this.hasAlpha, r.level = this.level, r.mirrorPlane = this.mirrorPlane.clone(), this.renderList && (r.renderList = this.renderList.slice(0)), r;
      }, t.prototype.serialize = function() {
        if (!this.name)
          return null;
        var e = n.prototype.serialize.call(this);
        return e.mirrorPlane = this.mirrorPlane.asArray(), e;
      }, t.prototype.dispose = function() {
        var e;
        n.prototype.dispose.call(this);
        var i = this.getScene();
        i && i.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver), (e = this._sceneUBO) === null || e === void 0 || e.dispose();
      }, t;
    }(Mi);
    ae._CreateMirror = function(n, t, e, i) {
      return new o_(n, t, e, i);
    };
    var Gr = function(n) {
      function t(e, i, r, o, a, s, l, c, u, h, d, p, f, m, g) {
        r === void 0 && (r = null), o === void 0 && (o = !1), a === void 0 && (a = null), s === void 0 && (s = null), l === void 0 && (l = null), c === void 0 && (c = _.TEXTUREFORMAT_RGBA), u === void 0 && (u = !1), h === void 0 && (h = null), d === void 0 && (d = !1), p === void 0 && (p = 0.8), f === void 0 && (f = 0);
        var y, b = this;
        return (b = n.call(this, i) || this)._lodScale = 0.8, b._lodOffset = 0, b.onLoadObservable = new H(), b.boundingBoxPosition = v.Zero(), b._rotationY = 0, b._files = null, b._forcedExtension = null, b._extensions = null, b._textureMatrixRefraction = new B(), b.name = e, b.url = e, b._noMipmap = o, b.hasAlpha = !1, b._format = c, b.isCube = !0, b._textureMatrix = B.Identity(), b._createPolynomials = d, b.coordinatesMode = ae.CUBIC_MODE, b._extensions = r, b._files = a, b._forcedExtension = h, b._loaderOptions = m, b._useSRGBBuffer = g, b._lodScale = p, b._lodOffset = f, (e || a) && b.updateURL(e, h, s, u, l, r, (y = b.getScene()) === null || y === void 0 ? void 0 : y.useDelayedTextureLoading, a), b;
      }
      return D(t, n), Object.defineProperty(t.prototype, "boundingBoxSize", { get: function() {
        return this._boundingBoxSize;
      }, set: function(e) {
        if (!this._boundingBoxSize || !this._boundingBoxSize.equals(e)) {
          this._boundingBoxSize = e;
          var i = this.getScene();
          i && i.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag);
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rotationY", { get: function() {
        return this._rotationY;
      }, set: function(e) {
        this._rotationY = e, this.setReflectionTextureMatrix(B.RotationY(this._rotationY));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "noMipmap", { get: function() {
        return this._noMipmap;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "forcedExtension", { get: function() {
        return this._forcedExtension;
      }, enumerable: !1, configurable: !0 }), t.CreateFromImages = function(e, i, r) {
        var o = "";
        return e.forEach(function(a) {
          return o += a;
        }), new t(o, i, null, r, e);
      }, t.CreateFromPrefilteredData = function(e, i, r, o) {
        r === void 0 && (r = null), o === void 0 && (o = !0);
        var a = i.useDelayedTextureLoading;
        i.useDelayedTextureLoading = !1;
        var s = new t(e, i, null, !1, null, null, null, void 0, !0, r, o);
        return i.useDelayedTextureLoading = a, s;
      }, t.prototype.getClassName = function() {
        return "CubeTexture";
      }, t.prototype.updateURL = function(e, i, r, o, a, s, l, c) {
        r === void 0 && (r = null), o === void 0 && (o = !1), a === void 0 && (a = null), s === void 0 && (s = null), l === void 0 && (l = !1), c === void 0 && (c = null), this.name && !this.name.startsWith("data:") || (this.name = e), this.url = e, i && (this._forcedExtension = i);
        var u = e.lastIndexOf("."), h = i || (u > -1 ? e.substring(u).toLowerCase() : ""), d = h.indexOf(".dds") === 0, p = h.indexOf(".env") === 0, f = h.indexOf(".basis") === 0;
        if (p ? (this.gammaSpace = !1, this._prefiltered = !1, this.anisotropicFilteringLevel = 1) : (this._prefiltered = o, o && (this.gammaSpace = !1, this.anisotropicFilteringLevel = 1)), c)
          this._files = c;
        else if (f || p || d || s || (s = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"]), this._files = this._files || [], this._files.length = 0, s) {
          for (var m = 0; m < s.length; m++)
            this._files.push(e + s[m]);
          this._extensions = s;
        }
        l ? (this.delayLoadState = _.DELAYLOADSTATE_NOTLOADED, this._delayedOnLoad = r, this._delayedOnError = a) : this._loadTexture(r, a);
      }, t.prototype.delayLoad = function(e) {
        this.delayLoadState === _.DELAYLOADSTATE_NOTLOADED && (e && (this._forcedExtension = e), this.delayLoadState = _.DELAYLOADSTATE_LOADED, this._loadTexture(this._delayedOnLoad, this._delayedOnError));
      }, t.prototype.getReflectionTextureMatrix = function() {
        return this._textureMatrix;
      }, t.prototype.setReflectionTextureMatrix = function(e) {
        var i, r, o = this;
        if (e.updateFlag !== this._textureMatrix.updateFlag && (e.isIdentity() !== this._textureMatrix.isIdentity() && ((i = this.getScene()) === null || i === void 0 || i.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag, function(c) {
          return c.getActiveTextures().indexOf(o) !== -1;
        })), this._textureMatrix = e, (r = this.getScene()) === null || r === void 0 ? void 0 : r.useRightHandedSystem)) {
          var a = F.Vector3[0], s = F.Quaternion[0], l = F.Vector3[1];
          this._textureMatrix.decompose(a, s, l), s.z *= -1, s.w *= -1, B.ComposeToRef(a, s, l, this._textureMatrixRefraction);
        }
      }, t.prototype.getRefractionTextureMatrix = function() {
        var e;
        return !((e = this.getScene()) === null || e === void 0) && e.useRightHandedSystem ? this._textureMatrixRefraction : this._textureMatrix;
      }, t.prototype._loadTexture = function(e, i) {
        var r, o = this;
        e === void 0 && (e = null), i === void 0 && (i = null);
        var a = this.getScene(), s = this._texture;
        this._texture = this._getFromCache(this.url, this._noMipmap, void 0, void 0, this._useSRGBBuffer, this.isCube);
        var l = function() {
          var u;
          o.onLoadObservable.notifyObservers(o), s && (s.dispose(), (u = o.getScene()) === null || u === void 0 || u.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag)), e && e();
        }, c = function(u, h) {
          o._loadingError = !0, o._errorObject = { message: u, exception: h }, i && i(u, h), ae.OnTextureLoadErrorObservable.notifyObservers(o);
        };
        this._texture ? this._texture.isReady ? de.SetImmediate(function() {
          return l();
        }) : this._texture.onLoadedObservable.add(function() {
          return l();
        }) : (this._prefiltered ? this._texture = this._getEngine().createPrefilteredCubeTexture(this.url, a, this._lodScale, this._lodOffset, e, c, this._format, this._forcedExtension, this._createPolynomials) : this._texture = this._getEngine().createCubeTexture(this.url, a, this._files, this._noMipmap, e, c, this._format, this._forcedExtension, !1, this._lodScale, this._lodOffset, null, this._loaderOptions, !!this._useSRGBBuffer), (r = this._texture) === null || r === void 0 || r.onLoadedObservable.add(function() {
          return o.onLoadObservable.notifyObservers(o);
        }));
      }, t.Parse = function(e, i, r) {
        var o = Ne.Parse(function() {
          var c, u = !1;
          return e.prefiltered && (u = e.prefiltered), new t(r + ((c = e.url) !== null && c !== void 0 ? c : e.name), i, e.extensions, !1, e.files || null, null, null, void 0, u, e.forcedExtension);
        }, e, i);
        if (e.boundingBoxPosition && (o.boundingBoxPosition = v.FromArray(e.boundingBoxPosition)), e.boundingBoxSize && (o.boundingBoxSize = v.FromArray(e.boundingBoxSize)), e.animations)
          for (var a = 0; a < e.animations.length; a++) {
            var s = e.animations[a], l = Kt("BABYLON.Animation");
            l && o.animations.push(l.Parse(s));
          }
        return o;
      }, t.prototype.clone = function() {
        var e = this, i = 0, r = Ne.Clone(function() {
          var o = new t(e.url, e.getScene() || e._getEngine(), e._extensions, e._noMipmap, e._files);
          return i = o.uniqueId, o;
        }, this);
        return r.uniqueId = i, r;
      }, x([N()], t.prototype, "url", void 0), x([ki()], t.prototype, "boundingBoxPosition", void 0), x([ki()], t.prototype, "boundingBoxSize", null), x([N("rotationY")], t.prototype, "rotationY", null), x([N("files")], t.prototype, "_files", void 0), x([N("forcedExtension")], t.prototype, "_forcedExtension", void 0), x([N("extensions")], t.prototype, "_extensions", void 0), x([cs("textureMatrix")], t.prototype, "_textureMatrix", void 0), x([cs("textureMatrixRefraction")], t.prototype, "_textureMatrixRefraction", void 0), t;
    }(Vn);
    ae._CubeTextureParser = Gr.Parse, j("BABYLON.CubeTexture", Gr), re.IncludesShadersStore.backgroundFragmentDeclaration = `uniform vec4 vEyePosition;uniform vec4 vPrimaryColor;
#ifdef USEHIGHLIGHTANDSHADOWCOLORS
uniform vec4 vPrimaryColorShadow;
#endif
uniform float shadowLevel;uniform float alpha;
#ifdef DIFFUSE
uniform vec2 vDiffuseInfos;
#endif
#ifdef REFLECTION
uniform vec2 vReflectionInfos;uniform mat4 reflectionMatrix;uniform vec3 vReflectionMicrosurfaceInfos;
#endif
#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)
uniform vec3 vBackgroundCenter;
#endif
#ifdef REFLECTIONFRESNEL
uniform vec4 vReflectionControl;
#endif
#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)
uniform mat4 view;
#endif
#ifdef PROJECTED_GROUND
uniform vec2 projectedGroundInfos;
#endif
`, re.IncludesShadersStore.backgroundUboDeclaration = `layout(std140,column_major) uniform;uniform Material
{uniform vec4 vPrimaryColor;uniform vec4 vPrimaryColorShadow;uniform vec2 vDiffuseInfos;uniform vec2 vReflectionInfos;uniform mat4 diffuseMatrix;uniform mat4 reflectionMatrix;uniform vec3 vReflectionMicrosurfaceInfos;uniform float fFovMultiplier;uniform float pointSize;uniform float shadowLevel;uniform float alpha;uniform vec3 vBackgroundCenter;uniform vec4 vReflectionControl;uniform vec2 projectedGroundInfos;};
#include<sceneUboDeclaration>
`, re.ShadersStore.backgroundPixelShader = `#ifdef TEXTURELODSUPPORT
#extension GL_EXT_shader_texture_lod : enable
#endif
precision highp float;
#include<__decl__backgroundFragment>
#include<helperFunctions>
varying vec3 vPositionW;
#ifdef MAINUV1
varying vec2 vMainUV1;
#endif 
#ifdef MAINUV2 
varying vec2 vMainUV2; 
#endif 
#ifdef NORMAL
varying vec3 vNormalW;
#endif
#ifdef DIFFUSE
#if DIFFUSEDIRECTUV==1
#define vDiffuseUV vMainUV1
#elif DIFFUSEDIRECTUV==2
#define vDiffuseUV vMainUV2
#else
varying vec2 vDiffuseUV;
#endif
uniform sampler2D diffuseSampler;
#endif
#ifdef REFLECTION
#ifdef REFLECTIONMAP_3D
#define sampleReflection(s,c) textureCube(s,c)
uniform samplerCube reflectionSampler;
#ifdef TEXTURELODSUPPORT
#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)
#else
uniform samplerCube reflectionSamplerLow;uniform samplerCube reflectionSamplerHigh;
#endif
#else
#define sampleReflection(s,c) texture2D(s,c)
uniform sampler2D reflectionSampler;
#ifdef TEXTURELODSUPPORT
#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)
#else
uniform samplerCube reflectionSamplerLow;uniform samplerCube reflectionSamplerHigh;
#endif
#endif
#ifdef REFLECTIONMAP_SKYBOX
varying vec3 vPositionUVW;
#else
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
varying vec3 vDirectionW;
#endif
#endif
#include<reflectionFunction>
#endif
#ifndef FROMLINEARSPACE
#define FROMLINEARSPACE;
#endif
#ifndef SHADOWONLY
#define SHADOWONLY;
#endif
#include<imageProcessingDeclaration>
#include<__decl__lightFragment>[0..maxSimultaneousLights]
#include<lightsFragmentFunctions>
#include<shadowsFragmentFunctions>
#include<imageProcessingFunctions>
#include<clipPlaneFragmentDeclaration>
#include<fogFragmentDeclaration>
#ifdef REFLECTIONFRESNEL
#define FRESNEL_MAXIMUM_ON_ROUGH 0.25
vec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)
{float weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);return reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));}
#endif
#ifdef PROJECTED_GROUND
float diskIntersectWithBackFaceCulling(vec3 ro,vec3 rd,vec3 c,float r) {float d=rd.y;if(d>0.0) { return 1e6; }
vec3 o=ro-c;float t=-o.y/d;vec3 q=o+rd*t;return (dot(q,q)<r*r) ? t : 1e6;}
float sphereIntersect(vec3 ro,vec3 rd,float ra) {float b=dot(ro,rd);float c=dot(ro,ro)-ra*ra;float h=b*b-c;if(h<0.0) { return -1.0; }
h=sqrt(h);return-b+h;}
vec3 project(vec3 viewDirectionW,vec3 eyePosition) {float radius=projectedGroundInfos.x;float height=projectedGroundInfos.y;vec3 camDir=-viewDirectionW;float skySphereDistance=sphereIntersect(eyePosition,camDir,radius);vec3 skySpherePositionW=eyePosition+camDir*skySphereDistance;vec3 p=normalize(skySpherePositionW);eyePosition.y-=height;float sIntersection=sphereIntersect(eyePosition,p,radius);vec3 h=vec3(0.0,-height,0.0);float dIntersection=diskIntersectWithBackFaceCulling(eyePosition,p,h,radius);p=(eyePosition+min(sIntersection,dIntersection)*p);return p;}
#endif
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void) {
#define CUSTOM_FRAGMENT_MAIN_BEGIN
#include<clipPlaneFragment>
vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);
#ifdef NORMAL
vec3 normalW=normalize(vNormalW);
#else
vec3 normalW=vec3(0.0,1.0,0.0);
#endif
float shadow=1.;float globalShadow=0.;float shadowLightCount=0.;float aggShadow=0.;float numLights=0.;
#include<lightFragment>[0..maxSimultaneousLights]
#ifdef SHADOWINUSE
globalShadow/=shadowLightCount;
#else
globalShadow=1.0;
#endif
#ifndef BACKMAT_SHADOWONLY
vec4 reflectionColor=vec4(1.,1.,1.,1.);
#ifdef REFLECTION
#ifdef PROJECTED_GROUND
vec3 reflectionVector=project(viewDirectionW,vEyePosition.xyz);reflectionVector=vec3(reflectionMatrix*vec4(reflectionVector,1.));
#else
vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);
#endif
#ifdef REFLECTIONMAP_OPPOSITEZ
reflectionVector.z*=-1.0;
#endif
#ifdef REFLECTIONMAP_3D
vec3 reflectionCoords=reflectionVector;
#else
vec2 reflectionCoords=reflectionVector.xy;
#ifdef REFLECTIONMAP_PROJECTION
reflectionCoords/=reflectionVector.z;
#endif
reflectionCoords.y=1.0-reflectionCoords.y;
#endif
#ifdef REFLECTIONBLUR
float reflectionLOD=vReflectionInfos.y;
#ifdef TEXTURELODSUPPORT
reflectionLOD=reflectionLOD*log2(vReflectionMicrosurfaceInfos.x)*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;reflectionColor=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);
#else
float lodReflectionNormalized=saturate(reflectionLOD);float lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;vec4 reflectionSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);if(lodReflectionNormalizedDoubled<1.0){reflectionColor=mix(
sampleReflection(reflectionSamplerHigh,reflectionCoords),
reflectionSpecularMid,
lodReflectionNormalizedDoubled
);} else {reflectionColor=mix(
reflectionSpecularMid,
sampleReflection(reflectionSamplerLow,reflectionCoords),
lodReflectionNormalizedDoubled-1.0
);}
#endif
#else
vec4 reflectionSample=sampleReflection(reflectionSampler,reflectionCoords);reflectionColor=reflectionSample;
#endif
#ifdef RGBDREFLECTION
reflectionColor.rgb=fromRGBD(reflectionColor);
#endif
#ifdef GAMMAREFLECTION
reflectionColor.rgb=toLinearSpace(reflectionColor.rgb);
#endif
#ifdef REFLECTIONBGR
reflectionColor.rgb=reflectionColor.bgr;
#endif
reflectionColor.rgb*=vReflectionInfos.x;
#endif
vec3 diffuseColor=vec3(1.,1.,1.);float finalAlpha=alpha;
#ifdef DIFFUSE
vec4 diffuseMap=texture2D(diffuseSampler,vDiffuseUV);
#ifdef GAMMADIFFUSE
diffuseMap.rgb=toLinearSpace(diffuseMap.rgb);
#endif
diffuseMap.rgb*=vDiffuseInfos.y;
#ifdef DIFFUSEHASALPHA
finalAlpha*=diffuseMap.a;
#endif
diffuseColor=diffuseMap.rgb;
#endif
#ifdef REFLECTIONFRESNEL
vec3 colorBase=diffuseColor;
#else
vec3 colorBase=reflectionColor.rgb*diffuseColor;
#endif
colorBase=max(colorBase,0.0);
#ifdef USERGBCOLOR
vec3 finalColor=colorBase;
#else
#ifdef USEHIGHLIGHTANDSHADOWCOLORS
vec3 mainColor=mix(vPrimaryColorShadow.rgb,vPrimaryColor.rgb,colorBase);
#else
vec3 mainColor=vPrimaryColor.rgb;
#endif
vec3 finalColor=colorBase*mainColor;
#endif
#ifdef REFLECTIONFRESNEL
vec3 reflectionAmount=vReflectionControl.xxx;vec3 reflectionReflectance0=vReflectionControl.yyy;vec3 reflectionReflectance90=vReflectionControl.zzz;float VdotN=dot(normalize(vEyePosition.xyz),normalW);vec3 planarReflectionFresnel=fresnelSchlickEnvironmentGGX(saturate(VdotN),reflectionReflectance0,reflectionReflectance90,1.0);reflectionAmount*=planarReflectionFresnel;
#ifdef REFLECTIONFALLOFF
float reflectionDistanceFalloff=1.0-saturate(length(vPositionW.xyz-vBackgroundCenter)*vReflectionControl.w);reflectionDistanceFalloff*=reflectionDistanceFalloff;reflectionAmount*=reflectionDistanceFalloff;
#endif
finalColor=mix(finalColor,reflectionColor.rgb,saturate(reflectionAmount));
#endif
#ifdef OPACITYFRESNEL
float viewAngleToFloor=dot(normalW,normalize(vEyePosition.xyz-vBackgroundCenter));const float startAngle=0.1;float fadeFactor=saturate(viewAngleToFloor/startAngle);finalAlpha*=fadeFactor*fadeFactor;
#endif
#ifdef SHADOWINUSE
finalColor=mix(finalColor*shadowLevel,finalColor,globalShadow);
#endif
vec4 color=vec4(finalColor,finalAlpha);
#else
vec4 color=vec4(vPrimaryColor.rgb,(1.0-clamp(globalShadow,0.,1.))*alpha);
#endif
#include<fogFragment>
#ifdef IMAGEPROCESSINGPOSTPROCESS
#if !defined(SKIPFINALCOLORCLAMP)
color.rgb=clamp(color.rgb,0.,30.0);
#endif
#else
color=applyImageProcessing(color);
#endif
#ifdef PREMULTIPLYALPHA
color.rgb*=color.a;
#endif
#ifdef NOISE
color.rgb+=dither(vPositionW.xy,0.5);color=max(color,0.0);
#endif
gl_FragColor=color;
#define CUSTOM_FRAGMENT_MAIN_END
}
`, re.IncludesShadersStore.backgroundVertexDeclaration = `uniform mat4 view;uniform mat4 viewProjection;uniform float shadowLevel;
#ifdef DIFFUSE
uniform mat4 diffuseMatrix;uniform vec2 vDiffuseInfos;
#endif
#ifdef REFLECTION
uniform vec2 vReflectionInfos;uniform mat4 reflectionMatrix;uniform vec3 vReflectionMicrosurfaceInfos;uniform float fFovMultiplier;
#endif
#ifdef POINTSIZE
uniform float pointSize;
#endif
`, re.ShadersStore.backgroundVertexShader = `precision highp float;
#include<__decl__backgroundVertex>
#include<helperFunctions>
attribute vec3 position;
#ifdef NORMAL
attribute vec3 normal;
#endif
#include<bonesDeclaration>
#include<bakedVertexAnimationDeclaration>
#include<instancesDeclaration>
varying vec3 vPositionW;
#ifdef NORMAL
varying vec3 vNormalW;
#endif
#ifdef UV1
attribute vec2 uv;
#endif
#ifdef UV2
attribute vec2 uv2;
#endif
#ifdef MAINUV1
varying vec2 vMainUV1;
#endif
#ifdef MAINUV2
varying vec2 vMainUV2;
#endif
#if defined(DIFFUSE) && DIFFUSEDIRECTUV==0
varying vec2 vDiffuseUV;
#endif
#include<clipPlaneVertexDeclaration>
#include<fogVertexDeclaration>
#include<__decl__lightVxFragment>[0..maxSimultaneousLights]
#ifdef REFLECTIONMAP_SKYBOX
varying vec3 vPositionUVW;
#endif
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
varying vec3 vDirectionW;
#endif
#define CUSTOM_VERTEX_DEFINITIONS
void main(void) {
#define CUSTOM_VERTEX_MAIN_BEGIN
#ifdef REFLECTIONMAP_SKYBOX
vPositionUVW=position;
#endif
#include<instancesVertex>
#include<bonesVertex>
#include<bakedVertexAnimation>
#ifdef MULTIVIEW
if (gl_ViewID_OVR==0u) {gl_Position=viewProjection*finalWorld*vec4(position,1.0);} else {gl_Position=viewProjectionR*finalWorld*vec4(position,1.0);}
#else
gl_Position=viewProjection*finalWorld*vec4(position,1.0);
#endif
vec4 worldPos=finalWorld*vec4(position,1.0);vPositionW=vec3(worldPos);
#ifdef NORMAL
mat3 normalWorld=mat3(finalWorld);
#ifdef NONUNIFORMSCALING
normalWorld=transposeMat3(inverseMat3(normalWorld));
#endif
vNormalW=normalize(normalWorld*normal);
#endif
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
vDirectionW=normalize(vec3(finalWorld*vec4(position,0.0)));
#ifdef EQUIRECTANGULAR_RELFECTION_FOV
mat3 screenToWorld=inverseMat3(mat3(finalWorld*viewProjection));vec3 segment=mix(vDirectionW,screenToWorld*vec3(0.0,0.0,1.0),abs(fFovMultiplier-1.0));if (fFovMultiplier<=1.0) {vDirectionW=normalize(segment);} else {vDirectionW=normalize(vDirectionW+(vDirectionW-segment));}
#endif
#endif
#ifndef UV1
vec2 uv=vec2(0.,0.);
#endif
#ifndef UV2
vec2 uv2=vec2(0.,0.);
#endif
#ifdef MAINUV1
vMainUV1=uv;
#endif
#ifdef MAINUV2
vMainUV2=uv2;
#endif
#if defined(DIFFUSE) && DIFFUSEDIRECTUV==0
if (vDiffuseInfos.x==0.)
{vDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));}
else
{vDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));}
#endif
#include<clipPlaneVertex>
#include<fogVertex>
#include<shadowsVertex>[0..maxSimultaneousLights]
#ifdef VERTEXCOLOR
vColor=color;
#endif
#if defined(POINTSIZE) && !defined(WEBGPU)
gl_PointSize=pointSize;
#endif
#define CUSTOM_VERTEX_MAIN_END
}
`;
    var GD = function(n) {
      function t() {
        var e = n.call(this) || this;
        return e.DIFFUSE = !1, e.DIFFUSEDIRECTUV = 0, e.GAMMADIFFUSE = !1, e.DIFFUSEHASALPHA = !1, e.OPACITYFRESNEL = !1, e.REFLECTIONBLUR = !1, e.REFLECTIONFRESNEL = !1, e.REFLECTIONFALLOFF = !1, e.TEXTURELODSUPPORT = !1, e.PREMULTIPLYALPHA = !1, e.USERGBCOLOR = !1, e.USEHIGHLIGHTANDSHADOWCOLORS = !1, e.BACKMAT_SHADOWONLY = !1, e.NOISE = !1, e.REFLECTIONBGR = !1, e.PROJECTED_GROUND = !1, e.IMAGEPROCESSING = !1, e.VIGNETTE = !1, e.VIGNETTEBLENDMODEMULTIPLY = !1, e.VIGNETTEBLENDMODEOPAQUE = !1, e.TONEMAPPING = !1, e.TONEMAPPING_ACES = !1, e.CONTRAST = !1, e.COLORCURVES = !1, e.COLORGRADING = !1, e.COLORGRADING3D = !1, e.SAMPLER3DGREENDEPTH = !1, e.SAMPLER3DBGRMAP = !1, e.DITHER = !1, e.IMAGEPROCESSINGPOSTPROCESS = !1, e.SKIPFINALCOLORCLAMP = !1, e.EXPOSURE = !1, e.MULTIVIEW = !1, e.REFLECTION = !1, e.REFLECTIONMAP_3D = !1, e.REFLECTIONMAP_SPHERICAL = !1, e.REFLECTIONMAP_PLANAR = !1, e.REFLECTIONMAP_CUBIC = !1, e.REFLECTIONMAP_PROJECTION = !1, e.REFLECTIONMAP_SKYBOX = !1, e.REFLECTIONMAP_EXPLICIT = !1, e.REFLECTIONMAP_EQUIRECTANGULAR = !1, e.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1, e.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1, e.INVERTCUBICMAP = !1, e.REFLECTIONMAP_OPPOSITEZ = !1, e.LODINREFLECTIONALPHA = !1, e.GAMMAREFLECTION = !1, e.RGBDREFLECTION = !1, e.EQUIRECTANGULAR_RELFECTION_FOV = !1, e.MAINUV1 = !1, e.MAINUV2 = !1, e.UV1 = !1, e.UV2 = !1, e.CLIPPLANE = !1, e.CLIPPLANE2 = !1, e.CLIPPLANE3 = !1, e.CLIPPLANE4 = !1, e.CLIPPLANE5 = !1, e.CLIPPLANE6 = !1, e.POINTSIZE = !1, e.FOG = !1, e.NORMAL = !1, e.NUM_BONE_INFLUENCERS = 0, e.BonesPerMesh = 0, e.INSTANCES = !1, e.SHADOWFLOAT = !1, e.LOGARITHMICDEPTH = !1, e.NONUNIFORMSCALING = !1, e.ALPHATEST = !1, e.rebuild(), e;
      }
      return D(t, n), t;
    }(jn), jc = function(n) {
      function t(e, i) {
        var r = n.call(this, e, i) || this;
        return r.primaryColor = ne.White(), r._primaryColorShadowLevel = 0, r._primaryColorHighlightLevel = 0, r.reflectionTexture = null, r.reflectionBlur = 0, r.diffuseTexture = null, r._shadowLights = null, r.shadowLights = null, r.shadowLevel = 0, r.sceneCenter = v.Zero(), r.opacityFresnel = !0, r.reflectionFresnel = !1, r.reflectionFalloffDistance = 0, r.reflectionAmount = 1, r.reflectionReflectance0 = 0.05, r.reflectionReflectance90 = 0.5, r.useRGBColor = !0, r.enableNoise = !1, r._fovMultiplier = 1, r.useEquirectangularFOV = !1, r._maxSimultaneousLights = 4, r.maxSimultaneousLights = 4, r._shadowOnly = !1, r.shadowOnly = !1, r._imageProcessingObserver = null, r.switchToBGR = !1, r._enableGroundProjection = !1, r.enableGroundProjection = !1, r.projectedGroundRadius = 1e3, r.projectedGroundHeight = 10, r._renderTargets = new en(16), r._reflectionControls = lt.Zero(), r._white = ne.White(), r._primaryShadowColor = ne.Black(), r._primaryHighlightColor = ne.Black(), r._attachImageProcessingConfiguration(null), r.getRenderTargetTextures = function() {
          return r._renderTargets.reset(), r._diffuseTexture && r._diffuseTexture.isRenderTarget && r._renderTargets.push(r._diffuseTexture), r._reflectionTexture && r._reflectionTexture.isRenderTarget && r._renderTargets.push(r._reflectionTexture), r._renderTargets;
        }, r;
      }
      return D(t, n), Object.defineProperty(t.prototype, "_perceptualColor", { get: function() {
        return this.__perceptualColor;
      }, set: function(e) {
        this.__perceptualColor = e, this._computePrimaryColorFromPerceptualColor(), this._markAllSubMeshesAsLightsDirty();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "primaryColorShadowLevel", { get: function() {
        return this._primaryColorShadowLevel;
      }, set: function(e) {
        this._primaryColorShadowLevel = e, this._computePrimaryColors(), this._markAllSubMeshesAsLightsDirty();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "primaryColorHighlightLevel", { get: function() {
        return this._primaryColorHighlightLevel;
      }, set: function(e) {
        this._primaryColorHighlightLevel = e, this._computePrimaryColors(), this._markAllSubMeshesAsLightsDirty();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "reflectionStandardFresnelWeight", { set: function(e) {
        var i = e;
        i < 0.5 ? (i *= 2, this.reflectionReflectance0 = t.StandardReflectance0 * i, this.reflectionReflectance90 = t.StandardReflectance90 * i) : (i = 2 * i - 1, this.reflectionReflectance0 = t.StandardReflectance0 + (1 - t.StandardReflectance0) * i, this.reflectionReflectance90 = t.StandardReflectance90 + (1 - t.StandardReflectance90) * i);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "fovMultiplier", { get: function() {
        return this._fovMultiplier;
      }, set: function(e) {
        isNaN(e) && (e = 1), this._fovMultiplier = Math.max(0, Math.min(2, e));
      }, enumerable: !1, configurable: !0 }), t.prototype._attachImageProcessingConfiguration = function(e) {
        var i = this;
        e !== this._imageProcessingConfiguration && (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver), this._imageProcessingConfiguration = e || this.getScene().imageProcessingConfiguration, this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function() {
          i._computePrimaryColorFromPerceptualColor(), i._markAllSubMeshesAsImageProcessingDirty();
        })));
      }, Object.defineProperty(t.prototype, "imageProcessingConfiguration", { get: function() {
        return this._imageProcessingConfiguration;
      }, set: function(e) {
        this._attachImageProcessingConfiguration(e), this._markAllSubMeshesAsTexturesDirty();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraColorCurvesEnabled", { get: function() {
        return this.imageProcessingConfiguration.colorCurvesEnabled;
      }, set: function(e) {
        this.imageProcessingConfiguration.colorCurvesEnabled = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraColorGradingEnabled", { get: function() {
        return this.imageProcessingConfiguration.colorGradingEnabled;
      }, set: function(e) {
        this.imageProcessingConfiguration.colorGradingEnabled = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraToneMappingEnabled", { get: function() {
        return this._imageProcessingConfiguration.toneMappingEnabled;
      }, set: function(e) {
        this._imageProcessingConfiguration.toneMappingEnabled = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraExposure", { get: function() {
        return this._imageProcessingConfiguration.exposure;
      }, set: function(e) {
        this._imageProcessingConfiguration.exposure = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraContrast", { get: function() {
        return this._imageProcessingConfiguration.contrast;
      }, set: function(e) {
        this._imageProcessingConfiguration.contrast = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraColorGradingTexture", { get: function() {
        return this._imageProcessingConfiguration.colorGradingTexture;
      }, set: function(e) {
        this.imageProcessingConfiguration.colorGradingTexture = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraColorCurves", { get: function() {
        return this.imageProcessingConfiguration.colorCurves;
      }, set: function(e) {
        this.imageProcessingConfiguration.colorCurves = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hasRenderTargetTextures", { get: function() {
        return !(!this._diffuseTexture || !this._diffuseTexture.isRenderTarget) || !(!this._reflectionTexture || !this._reflectionTexture.isRenderTarget);
      }, enumerable: !1, configurable: !0 }), t.prototype.needAlphaTesting = function() {
        return !0;
      }, t.prototype.needAlphaBlending = function() {
        return this.alpha < 1 || this._diffuseTexture != null && this._diffuseTexture.hasAlpha || this._shadowOnly;
      }, t.prototype.isReadyForSubMesh = function(e, i, r) {
        if (r === void 0 && (r = !1), i.effect && this.isFrozen && i.effect._wasPreviouslyReady && i.effect._wasPreviouslyUsingInstances === r)
          return !0;
        i.materialDefines || (i.materialDefines = new GD());
        var o = this.getScene(), a = i.materialDefines;
        if (this._isReadyForSubMesh(i))
          return !0;
        var s = o.getEngine();
        if (Se.PrepareDefinesForLights(o, e, a, !1, this._maxSimultaneousLights), a._needNormals = !0, Se.PrepareDefinesForMultiview(o, a), a._areTexturesDirty) {
          if (a._needUVs = !1, o.texturesEnabled) {
            if (o.getEngine().getCaps().textureLOD && (a.TEXTURELODSUPPORT = !0), this._diffuseTexture && Pe.DiffuseTextureEnabled) {
              if (!this._diffuseTexture.isReadyOrNotBlocking())
                return !1;
              Se.PrepareDefinesForMergedUV(this._diffuseTexture, a, "DIFFUSE"), a.DIFFUSEHASALPHA = this._diffuseTexture.hasAlpha, a.GAMMADIFFUSE = this._diffuseTexture.gammaSpace, a.OPACITYFRESNEL = this._opacityFresnel;
            } else
              a.DIFFUSE = !1, a.DIFFUSEDIRECTUV = 0, a.DIFFUSEHASALPHA = !1, a.GAMMADIFFUSE = !1, a.OPACITYFRESNEL = !1;
            var l = this._reflectionTexture;
            if (l && Pe.ReflectionTextureEnabled) {
              if (!l.isReadyOrNotBlocking())
                return !1;
              switch (a.REFLECTION = !0, a.GAMMAREFLECTION = l.gammaSpace, a.RGBDREFLECTION = l.isRGBD, a.REFLECTIONBLUR = this._reflectionBlur > 0, a.LODINREFLECTIONALPHA = l.lodLevelInAlpha, a.EQUIRECTANGULAR_RELFECTION_FOV = this.useEquirectangularFOV, a.REFLECTIONBGR = this.switchToBGR, l.coordinatesMode === ae.INVCUBIC_MODE && (a.INVERTCUBICMAP = !0), a.REFLECTIONMAP_3D = l.isCube, a.REFLECTIONMAP_OPPOSITEZ = a.REFLECTIONMAP_3D && this.getScene().useRightHandedSystem ? !l.invertZ : l.invertZ, l.coordinatesMode) {
                case ae.EXPLICIT_MODE:
                  a.REFLECTIONMAP_EXPLICIT = !0;
                  break;
                case ae.PLANAR_MODE:
                  a.REFLECTIONMAP_PLANAR = !0;
                  break;
                case ae.PROJECTION_MODE:
                  a.REFLECTIONMAP_PROJECTION = !0;
                  break;
                case ae.SKYBOX_MODE:
                  a.REFLECTIONMAP_SKYBOX = !0;
                  break;
                case ae.SPHERICAL_MODE:
                  a.REFLECTIONMAP_SPHERICAL = !0;
                  break;
                case ae.EQUIRECTANGULAR_MODE:
                  a.REFLECTIONMAP_EQUIRECTANGULAR = !0;
                  break;
                case ae.FIXED_EQUIRECTANGULAR_MODE:
                  a.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !0;
                  break;
                case ae.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
                  a.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !0;
                  break;
                case ae.CUBIC_MODE:
                case ae.INVCUBIC_MODE:
                default:
                  a.REFLECTIONMAP_CUBIC = !0;
              }
              this.reflectionFresnel ? (a.REFLECTIONFRESNEL = !0, a.REFLECTIONFALLOFF = this.reflectionFalloffDistance > 0, this._reflectionControls.x = this.reflectionAmount, this._reflectionControls.y = this.reflectionReflectance0, this._reflectionControls.z = this.reflectionReflectance90, this._reflectionControls.w = 1 / this.reflectionFalloffDistance) : (a.REFLECTIONFRESNEL = !1, a.REFLECTIONFALLOFF = !1);
            } else
              a.REFLECTION = !1, a.REFLECTIONFRESNEL = !1, a.REFLECTIONFALLOFF = !1, a.REFLECTIONBLUR = !1, a.REFLECTIONMAP_3D = !1, a.REFLECTIONMAP_SPHERICAL = !1, a.REFLECTIONMAP_PLANAR = !1, a.REFLECTIONMAP_CUBIC = !1, a.REFLECTIONMAP_PROJECTION = !1, a.REFLECTIONMAP_SKYBOX = !1, a.REFLECTIONMAP_EXPLICIT = !1, a.REFLECTIONMAP_EQUIRECTANGULAR = !1, a.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1, a.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1, a.INVERTCUBICMAP = !1, a.REFLECTIONMAP_OPPOSITEZ = !1, a.LODINREFLECTIONALPHA = !1, a.GAMMAREFLECTION = !1, a.RGBDREFLECTION = !1;
          }
          a.PREMULTIPLYALPHA = this.alphaMode === _.ALPHA_PREMULTIPLIED || this.alphaMode === _.ALPHA_PREMULTIPLIED_PORTERDUFF, a.USERGBCOLOR = this._useRGBColor, a.NOISE = this._enableNoise;
        }
        if (a._areLightsDirty && (a.USEHIGHLIGHTANDSHADOWCOLORS = !this._useRGBColor && (this._primaryColorShadowLevel !== 0 || this._primaryColorHighlightLevel !== 0), a.BACKMAT_SHADOWONLY = this._shadowOnly), a._areImageProcessingDirty && this._imageProcessingConfiguration) {
          if (!this._imageProcessingConfiguration.isReady())
            return !1;
          this._imageProcessingConfiguration.prepareDefines(a);
        }
        if (a._areMiscDirty && (a.REFLECTIONMAP_3D && this._enableGroundProjection ? (a.PROJECTED_GROUND = !0, a.REFLECTIONMAP_SKYBOX = !0) : a.PROJECTED_GROUND = !1), Se.PrepareDefinesForMisc(e, o, !1, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(e), a), Se.PrepareDefinesForFrameBoundValues(o, s, this, a, r, null, i.getRenderingMesh().hasThinInstances), Se.PrepareDefinesForAttributes(e, a, !1, !0, !1) && e && (o.getEngine().getCaps().standardDerivatives || e.isVerticesDataPresent(P.NormalKind) || (e.createNormals(!0), q.Warn("BackgroundMaterial: Normals have been created for the mesh: " + e.name))), a.isDirty) {
          a.markAsProcessed(), o.resetCachedMaterial();
          var c = new Va();
          a.FOG && c.addFallback(0, "FOG"), a.POINTSIZE && c.addFallback(1, "POINTSIZE"), a.MULTIVIEW && c.addFallback(0, "MULTIVIEW"), Se.HandleFallbacksForShadows(a, c, this._maxSimultaneousLights);
          var u = [P.PositionKind];
          a.NORMAL && u.push(P.NormalKind), a.UV1 && u.push(P.UVKind), a.UV2 && u.push(P.UV2Kind), Se.PrepareAttributesForBones(u, e, a, c), Se.PrepareAttributesForInstances(u, a);
          var h = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vFogInfos", "vFogColor", "pointSize", "mBones", "vPrimaryColor", "vPrimaryColorShadow", "vReflectionInfos", "reflectionMatrix", "vReflectionMicrosurfaceInfos", "fFovMultiplier", "shadowLevel", "alpha", "vBackgroundCenter", "vReflectionControl", "vDiffuseInfos", "diffuseMatrix", "projectedGroundInfos"];
          Br(h);
          var d = ["diffuseSampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh"], p = ["Material", "Scene"];
          tn && (tn.PrepareUniforms(h, a), tn.PrepareSamplers(d, a)), Se.PrepareUniformsAndSamplersList({ uniformsNames: h, uniformBuffersNames: p, samplers: d, defines: a, maxSimultaneousLights: this._maxSimultaneousLights });
          var f = a.toString(), m = o.getEngine().createEffect("background", { attributes: u, uniformsNames: h, uniformBuffersNames: p, samplers: d, defines: f, fallbacks: c, onCompiled: this.onCompiled, onError: this.onError, indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights } }, s);
          i.setEffect(m, a, this._materialContext), this.buildUniformLayout();
        }
        return !(!i.effect || !i.effect.isReady() || (a._renderId = o.getRenderId(), i.effect._wasPreviouslyReady = !0, i.effect._wasPreviouslyUsingInstances = r, this._checkScenePerformancePriority(), 0));
      }, t.prototype._computePrimaryColorFromPerceptualColor = function() {
        this.__perceptualColor && (this._primaryColor.copyFrom(this.__perceptualColor), this._primaryColor.toLinearSpaceToRef(this._primaryColor, this.getScene().getEngine().useExactSrgbConversions), this._imageProcessingConfiguration && this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor), this._computePrimaryColors());
      }, t.prototype._computePrimaryColors = function() {
        this._primaryColorShadowLevel === 0 && this._primaryColorHighlightLevel === 0 || (this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor), this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor), this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor), this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor), this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor));
      }, t.prototype.buildUniformLayout = function() {
        this._uniformBuffer.addUniform("vPrimaryColor", 4), this._uniformBuffer.addUniform("vPrimaryColorShadow", 4), this._uniformBuffer.addUniform("vDiffuseInfos", 2), this._uniformBuffer.addUniform("vReflectionInfos", 2), this._uniformBuffer.addUniform("diffuseMatrix", 16), this._uniformBuffer.addUniform("reflectionMatrix", 16), this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3), this._uniformBuffer.addUniform("fFovMultiplier", 1), this._uniformBuffer.addUniform("pointSize", 1), this._uniformBuffer.addUniform("shadowLevel", 1), this._uniformBuffer.addUniform("alpha", 1), this._uniformBuffer.addUniform("vBackgroundCenter", 3), this._uniformBuffer.addUniform("vReflectionControl", 4), this._uniformBuffer.addUniform("projectedGroundInfos", 2), this._uniformBuffer.create();
      }, t.prototype.unbind = function() {
        this._diffuseTexture && this._diffuseTexture.isRenderTarget && this._uniformBuffer.setTexture("diffuseSampler", null), this._reflectionTexture && this._reflectionTexture.isRenderTarget && this._uniformBuffer.setTexture("reflectionSampler", null), n.prototype.unbind.call(this);
      }, t.prototype.bindOnlyWorldMatrix = function(e) {
        this._activeEffect.setMatrix("world", e);
      }, t.prototype.bindForSubMesh = function(e, i, r) {
        var o = this.getScene(), a = r.materialDefines;
        if (a) {
          var s = r.effect;
          if (s) {
            this._activeEffect = s, this.bindOnlyWorldMatrix(e), Se.BindBonesParameters(i, this._activeEffect);
            var l = this._mustRebind(o, s, i.visibility);
            if (l) {
              this._uniformBuffer.bindToEffect(s, "Material"), this.bindViewProjection(s);
              var c = this._reflectionTexture;
              this._uniformBuffer.useUbo && this.isFrozen && this._uniformBuffer.isSync || (o.texturesEnabled && (this._diffuseTexture && Pe.DiffuseTextureEnabled && (this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level), Se.BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse")), c && Pe.ReflectionTextureEnabled && (this._uniformBuffer.updateMatrix("reflectionMatrix", c.getReflectionTextureMatrix()), this._uniformBuffer.updateFloat2("vReflectionInfos", c.level, this._reflectionBlur), this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", c.getSize().width, c.lodGenerationScale, c.lodGenerationOffset))), this.shadowLevel > 0 && this._uniformBuffer.updateFloat("shadowLevel", this.shadowLevel), this._uniformBuffer.updateFloat("alpha", this.alpha), this.pointsCloud && this._uniformBuffer.updateFloat("pointSize", this.pointSize), a.USEHIGHLIGHTANDSHADOWCOLORS ? (this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryHighlightColor, 1), this._uniformBuffer.updateColor4("vPrimaryColorShadow", this._primaryShadowColor, 1)) : this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryColor, 1)), this._uniformBuffer.updateFloat("fFovMultiplier", this._fovMultiplier), o.texturesEnabled && (this._diffuseTexture && Pe.DiffuseTextureEnabled && this._uniformBuffer.setTexture("diffuseSampler", this._diffuseTexture), c && Pe.ReflectionTextureEnabled && (a.REFLECTIONBLUR && a.TEXTURELODSUPPORT ? this._uniformBuffer.setTexture("reflectionSampler", c) : a.REFLECTIONBLUR ? (this._uniformBuffer.setTexture("reflectionSampler", c._lodTextureMid || c), this._uniformBuffer.setTexture("reflectionSamplerLow", c._lodTextureLow || c), this._uniformBuffer.setTexture("reflectionSamplerHigh", c._lodTextureHigh || c)) : this._uniformBuffer.setTexture("reflectionSampler", c), a.REFLECTIONFRESNEL && (this._uniformBuffer.updateFloat3("vBackgroundCenter", this.sceneCenter.x, this.sceneCenter.y, this.sceneCenter.z), this._uniformBuffer.updateFloat4("vReflectionControl", this._reflectionControls.x, this._reflectionControls.y, this._reflectionControls.z, this._reflectionControls.w))), a.PROJECTED_GROUND && this._uniformBuffer.updateFloat2("projectedGroundInfos", this.projectedGroundRadius, this.projectedGroundHeight)), Ar(this._activeEffect, this, o), o.bindEyePosition(s);
            } else
              o.getEngine()._features.needToAlwaysBindUniformBuffers && (this._uniformBuffer.bindToEffect(s, "Material"), this._needToBindSceneUbo = !0);
            !l && this.isFrozen || (o.lightsEnabled && Se.BindLights(o, i, this._activeEffect, a, this._maxSimultaneousLights), this.bindView(s), Se.BindFogParameters(o, i, this._activeEffect, !0), this._imageProcessingConfiguration && this._imageProcessingConfiguration.bind(this._activeEffect)), this._afterBind(i, this._activeEffect), this._uniformBuffer.update();
          }
        }
      }, t.prototype.hasTexture = function(e) {
        return !!n.prototype.hasTexture.call(this, e) || this._reflectionTexture === e || this._diffuseTexture === e;
      }, t.prototype.dispose = function(e, i) {
        e === void 0 && (e = !1), i === void 0 && (i = !1), i && (this.diffuseTexture && this.diffuseTexture.dispose(), this.reflectionTexture && this.reflectionTexture.dispose()), this._renderTargets.dispose(), this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver), n.prototype.dispose.call(this, e);
      }, t.prototype.clone = function(e) {
        var i = this;
        return Ne.Clone(function() {
          return new t(e, i.getScene());
        }, this);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.customType = "BABYLON.BackgroundMaterial", e;
      }, t.prototype.getClassName = function() {
        return "BackgroundMaterial";
      }, t.Parse = function(e, i, r) {
        return Ne.Parse(function() {
          return new t(e.name, i);
        }, e, i, r);
      }, t.StandardReflectance0 = 0.05, t.StandardReflectance90 = 0.5, x([ri()], t.prototype, "_primaryColor", void 0), x([ye("_markAllSubMeshesAsLightsDirty")], t.prototype, "primaryColor", void 0), x([ri()], t.prototype, "__perceptualColor", void 0), x([N()], t.prototype, "_primaryColorShadowLevel", void 0), x([N()], t.prototype, "_primaryColorHighlightLevel", void 0), x([ye("_markAllSubMeshesAsLightsDirty")], t.prototype, "primaryColorHighlightLevel", null), x([St()], t.prototype, "_reflectionTexture", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionTexture", void 0), x([N()], t.prototype, "_reflectionBlur", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionBlur", void 0), x([St()], t.prototype, "_diffuseTexture", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "diffuseTexture", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "shadowLights", void 0), x([N()], t.prototype, "_shadowLevel", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "shadowLevel", void 0), x([ki()], t.prototype, "_sceneCenter", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "sceneCenter", void 0), x([N()], t.prototype, "_opacityFresnel", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "opacityFresnel", void 0), x([N()], t.prototype, "_reflectionFresnel", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionFresnel", void 0), x([N()], t.prototype, "_reflectionFalloffDistance", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionFalloffDistance", void 0), x([N()], t.prototype, "_reflectionAmount", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionAmount", void 0), x([N()], t.prototype, "_reflectionReflectance0", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionReflectance0", void 0), x([N()], t.prototype, "_reflectionReflectance90", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionReflectance90", void 0), x([N()], t.prototype, "_useRGBColor", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRGBColor", void 0), x([N()], t.prototype, "_enableNoise", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "enableNoise", void 0), x([N()], t.prototype, "_maxSimultaneousLights", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "maxSimultaneousLights", void 0), x([N()], t.prototype, "_shadowOnly", void 0), x([ye("_markAllSubMeshesAsLightsDirty")], t.prototype, "shadowOnly", void 0), x([$s()], t.prototype, "_imageProcessingConfiguration", void 0), x([N(), ye("_markAllSubMeshesAsMiscDirty")], t.prototype, "enableGroundProjection", void 0), x([N()], t.prototype, "projectedGroundRadius", void 0), x([N()], t.prototype, "projectedGroundHeight", void 0), t;
    }(pl);
    j("BABYLON.BackgroundMaterial", jc);
    var a_ = function() {
      function n(t, e) {
        var i = this;
        this._errorHandler = function(r, o) {
          i.onErrorObservable.notifyObservers({ message: r, exception: o });
        }, this._options = je(je({}, n._GetDefaultOptions(e)), t), this._scene = e, this.onErrorObservable = new H(), this._setupBackground(), this._setupImageProcessing();
      }
      return n._GetDefaultOptions = function(t) {
        return { createGround: !0, groundSize: 15, groundTexture: this._GroundTextureCDNUrl, groundColor: new ne(0.2, 0.2, 0.3).toLinearSpace(t.getEngine().useExactSrgbConversions).scale(3), groundOpacity: 0.9, enableGroundShadow: !0, groundShadowLevel: 0.5, enableGroundMirror: !1, groundMirrorSizeRatio: 0.3, groundMirrorBlurKernel: 64, groundMirrorAmount: 1, groundMirrorFresnelWeight: 1, groundMirrorFallOffDistance: 0, groundMirrorTextureType: _.TEXTURETYPE_UNSIGNED_INT, groundYBias: 1e-5, createSkybox: !0, skyboxSize: 20, skyboxTexture: this._SkyboxTextureCDNUrl, skyboxColor: new ne(0.2, 0.2, 0.3).toLinearSpace(t.getEngine().useExactSrgbConversions).scale(3), backgroundYRotation: 0, sizeAuto: !0, rootPosition: v.Zero(), setupImageProcessing: !0, environmentTexture: this._EnvironmentTextureCDNUrl, cameraExposure: 0.8, cameraContrast: 1.2, toneMappingEnabled: !0 };
      }, Object.defineProperty(n.prototype, "rootMesh", { get: function() {
        return this._rootMesh;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "skybox", { get: function() {
        return this._skybox;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "skyboxTexture", { get: function() {
        return this._skyboxTexture;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "skyboxMaterial", { get: function() {
        return this._skyboxMaterial;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "ground", { get: function() {
        return this._ground;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "groundTexture", { get: function() {
        return this._groundTexture;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "groundMirror", { get: function() {
        return this._groundMirror;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "groundMirrorRenderList", { get: function() {
        return this._groundMirror ? this._groundMirror.renderList : null;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "groundMaterial", { get: function() {
        return this._groundMaterial;
      }, enumerable: !1, configurable: !0 }), n.prototype.updateOptions = function(t) {
        var e = je(je({}, this._options), t);
        this._ground && !e.createGround && (this._ground.dispose(), this._ground = null), this._groundMaterial && !e.createGround && (this._groundMaterial.dispose(), this._groundMaterial = null), this._groundTexture && this._options.groundTexture != e.groundTexture && (this._groundTexture.dispose(), this._groundTexture = null), this._skybox && !e.createSkybox && (this._skybox.dispose(), this._skybox = null), this._skyboxMaterial && !e.createSkybox && (this._skyboxMaterial.dispose(), this._skyboxMaterial = null), this._skyboxTexture && this._options.skyboxTexture != e.skyboxTexture && (this._skyboxTexture.dispose(), this._skyboxTexture = null), this._groundMirror && !e.enableGroundMirror && (this._groundMirror.dispose(), this._groundMirror = null), this._scene.environmentTexture && this._options.environmentTexture != e.environmentTexture && this._scene.environmentTexture.dispose(), this._options = e, this._setupBackground(), this._setupImageProcessing();
      }, n.prototype.setMainColor = function(t) {
        this.groundMaterial && (this.groundMaterial.primaryColor = t), this.skyboxMaterial && (this.skyboxMaterial.primaryColor = t), this.groundMirror && (this.groundMirror.clearColor = new Ie(t.r, t.g, t.b, 1));
      }, n.prototype._setupImageProcessing = function() {
        this._options.setupImageProcessing && (this._scene.imageProcessingConfiguration.contrast = this._options.cameraContrast, this._scene.imageProcessingConfiguration.exposure = this._options.cameraExposure, this._scene.imageProcessingConfiguration.toneMappingEnabled = this._options.toneMappingEnabled, this._setupEnvironmentTexture());
      }, n.prototype._setupEnvironmentTexture = function() {
        if (!this._scene.environmentTexture)
          if (this._options.environmentTexture instanceof Vn)
            this._scene.environmentTexture = this._options.environmentTexture;
          else {
            var t = Gr.CreateFromPrefilteredData(this._options.environmentTexture, this._scene);
            this._scene.environmentTexture = t;
          }
      }, n.prototype._setupBackground = function() {
        this._rootMesh || (this._rootMesh = new ie("BackgroundHelper", this._scene)), this._rootMesh.rotation.y = this._options.backgroundYRotation;
        var t = this._getSceneSize();
        this._options.createGround && (this._setupGround(t), this._setupGroundMaterial(), this._setupGroundDiffuseTexture(), this._options.enableGroundMirror && this._setupGroundMirrorTexture(t), this._setupMirrorInGroundMaterial()), this._options.createSkybox && (this._setupSkybox(t), this._setupSkyboxMaterial(), this._setupSkyboxReflectionTexture()), this._rootMesh.position.x = t.rootPosition.x, this._rootMesh.position.z = t.rootPosition.z, this._rootMesh.position.y = t.rootPosition.y;
      }, n.prototype._getSceneSize = function() {
        var t = this, e = this._options.groundSize, i = this._options.skyboxSize, r = this._options.rootPosition;
        if (!this._scene.meshes || this._scene.meshes.length === 1)
          return { groundSize: e, skyboxSize: i, rootPosition: r };
        var o = this._scene.getWorldExtends(function(l) {
          return l !== t._ground && l !== t._rootMesh && l !== t._skybox;
        }), a = o.max.subtract(o.min);
        if (this._options.sizeAuto) {
          this._scene.activeCamera instanceof gs && this._scene.activeCamera.upperRadiusLimit && (i = e = 2 * this._scene.activeCamera.upperRadiusLimit);
          var s = a.length();
          s > e && (i = e = 2 * s), e *= 1.1, i *= 1.5, (r = o.min.add(a.scale(0.5))).y = o.min.y - this._options.groundYBias;
        }
        return { groundSize: e, skyboxSize: i, rootPosition: r };
      }, n.prototype._setupGround = function(t) {
        var e = this;
        this._ground && !this._ground.isDisposed() || (this._ground = Ro("BackgroundPlane", { size: t.groundSize }, this._scene), this._ground.rotation.x = Math.PI / 2, this._ground.parent = this._rootMesh, this._ground.onDisposeObservable.add(function() {
          e._ground = null;
        })), this._ground.receiveShadows = this._options.enableGroundShadow;
      }, n.prototype._setupGroundMaterial = function() {
        this._groundMaterial || (this._groundMaterial = new jc("BackgroundPlaneMaterial", this._scene)), this._groundMaterial.alpha = this._options.groundOpacity, this._groundMaterial.alphaMode = _.ALPHA_PREMULTIPLIED_PORTERDUFF, this._groundMaterial.shadowLevel = this._options.groundShadowLevel, this._groundMaterial.primaryColor = this._options.groundColor, this._groundMaterial.useRGBColor = !1, this._groundMaterial.enableNoise = !0, this._ground && (this._ground.material = this._groundMaterial);
      }, n.prototype._setupGroundDiffuseTexture = function() {
        this._groundMaterial && (this._groundTexture || (this._options.groundTexture instanceof Vn ? this._groundMaterial.diffuseTexture = this._options.groundTexture : (this._groundTexture = new ae(this._options.groundTexture, this._scene, void 0, void 0, void 0, void 0, this._errorHandler), this._groundTexture.gammaSpace = !1, this._groundTexture.hasAlpha = !0, this._groundMaterial.diffuseTexture = this._groundTexture)));
      }, n.prototype._setupGroundMirrorTexture = function(t) {
        var e = ae.CLAMP_ADDRESSMODE;
        if (!this._groundMirror && (this._groundMirror = new o_("BackgroundPlaneMirrorTexture", { ratio: this._options.groundMirrorSizeRatio }, this._scene, !1, this._options.groundMirrorTextureType, ae.BILINEAR_SAMPLINGMODE, !0), this._groundMirror.mirrorPlane = new xo(0, -1, 0, t.rootPosition.y), this._groundMirror.anisotropicFilteringLevel = 1, this._groundMirror.wrapU = e, this._groundMirror.wrapV = e, this._groundMirror.renderList))
          for (var i = 0; i < this._scene.meshes.length; i++) {
            var r = this._scene.meshes[i];
            r !== this._ground && r !== this._skybox && r !== this._rootMesh && this._groundMirror.renderList.push(r);
          }
        var o = this._options.groundColor.toGammaSpace(this._scene.getEngine().useExactSrgbConversions);
        this._groundMirror.clearColor = new Ie(o.r, o.g, o.b, 1), this._groundMirror.adaptiveBlurKernel = this._options.groundMirrorBlurKernel;
      }, n.prototype._setupMirrorInGroundMaterial = function() {
        this._groundMaterial && (this._groundMaterial.reflectionTexture = this._groundMirror, this._groundMaterial.reflectionFresnel = !0, this._groundMaterial.reflectionAmount = this._options.groundMirrorAmount, this._groundMaterial.reflectionStandardFresnelWeight = this._options.groundMirrorFresnelWeight, this._groundMaterial.reflectionFalloffDistance = this._options.groundMirrorFallOffDistance);
      }, n.prototype._setupSkybox = function(t) {
        var e = this;
        this._skybox && !this._skybox.isDisposed() || (this._skybox = Ur("BackgroundSkybox", { size: t.skyboxSize, sideOrientation: ie.BACKSIDE }, this._scene), this._skybox.onDisposeObservable.add(function() {
          e._skybox = null;
        })), this._skybox.parent = this._rootMesh;
      }, n.prototype._setupSkyboxMaterial = function() {
        this._skybox && (this._skyboxMaterial || (this._skyboxMaterial = new jc("BackgroundSkyboxMaterial", this._scene)), this._skyboxMaterial.useRGBColor = !1, this._skyboxMaterial.primaryColor = this._options.skyboxColor, this._skyboxMaterial.enableNoise = !0, this._skybox.material = this._skyboxMaterial);
      }, n.prototype._setupSkyboxReflectionTexture = function() {
        this._skyboxMaterial && (this._skyboxTexture || (this._options.skyboxTexture instanceof Vn ? this._skyboxMaterial.reflectionTexture = this._options.skyboxTexture : (this._skyboxTexture = new Gr(this._options.skyboxTexture, this._scene, void 0, void 0, void 0, void 0, this._errorHandler), this._skyboxTexture.coordinatesMode = ae.SKYBOX_MODE, this._skyboxTexture.gammaSpace = !1, this._skyboxMaterial.reflectionTexture = this._skyboxTexture)));
      }, n.prototype.dispose = function() {
        this._groundMaterial && this._groundMaterial.dispose(!0, !0), this._skyboxMaterial && this._skyboxMaterial.dispose(!0, !0), this._rootMesh.dispose(!1);
      }, n._GroundTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundGround.png", n._SkyboxTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundSkybox.dds", n._EnvironmentTextureCDNUrl = "https://assets.babylonjs.com/environments/environmentSpecular.env", n;
    }(), Rs = function(n) {
      function t(e, i, r, o, a) {
        a === void 0 && (a = null);
        var s = n.call(this, e, o) || this;
        s.onError = a, s._halfDome = !1, s._crossEye = !1, s._useDirectMapping = !1, s._textureMode = t.MODE_MONOSCOPIC, s._onBeforeCameraRenderObserver = null, s.onLoadErrorObservable = new H(), s.onLoadObservable = new H(), o = s.getScene(), e = e || "textureDome", r.resolution = 0 | Math.abs(r.resolution) || 32, r.clickToPlay = !!r.clickToPlay, r.autoPlay = r.autoPlay === void 0 || !!r.autoPlay, r.loop = r.loop === void 0 || !!r.loop, r.size = Math.abs(r.size) || (o.activeCamera ? 0.48 * o.activeCamera.maxZ : 1e3), r.useDirectMapping === void 0 ? s._useDirectMapping = !0 : s._useDirectMapping = r.useDirectMapping, r.faceForward === void 0 && (r.faceForward = !0), s._setReady(!1), r.mesh ? s._mesh = r.mesh : s._mesh = yn(e + "_mesh", { segments: r.resolution, diameter: r.size, updatable: !1, sideOrientation: ie.BACKSIDE }, o);
        var l = s._material = new jc(e + "_material", o);
        l.useEquirectangularFOV = !0, l.fovMultiplier = 1, l.opacityFresnel = !1;
        var c = s._initTexture(i, o, r);
        if (s.texture = c, s._mesh.material = l, s._mesh.parent = s, s._halfDomeMask = yn("", { slice: 0.5, diameter: 0.98 * r.size, segments: 2 * r.resolution, sideOrientation: ie.BACKSIDE }, o), s._halfDomeMask.rotate(qi.X, -Math.PI / 2), s._halfDomeMask.parent = s._mesh, s._halfDome = !!r.halfDomeMode, s._halfDomeMask.setEnabled(s._halfDome), s._crossEye = !!r.crossEyeMode, s._texture.anisotropicFilteringLevel = 1, s._texture.onLoadObservable.addOnce(function() {
          s._setReady(!0);
        }), r.faceForward && o.activeCamera) {
          var u = o.activeCamera, h = v.Forward(), d = v.TransformNormal(h, u.getViewMatrix());
          d.normalize(), s.rotation.y = Math.acos(v.Dot(h, d));
        }
        return s._changeTextureMode(s._textureMode), s;
      }
      return D(t, n), Object.defineProperty(t.prototype, "texture", { get: function() {
        return this._texture;
      }, set: function(e) {
        this._texture !== e && (this._texture = e, this._useDirectMapping ? (this._texture.wrapU = ae.CLAMP_ADDRESSMODE, this._texture.wrapV = ae.CLAMP_ADDRESSMODE, this._material.diffuseTexture = this._texture) : (this._texture.coordinatesMode = ae.FIXED_EQUIRECTANGULAR_MIRRORED_MODE, this._texture.wrapV = ae.CLAMP_ADDRESSMODE, this._material.reflectionTexture = this._texture), this._changeTextureMode(this._textureMode));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "mesh", { get: function() {
        return this._mesh;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "fovMultiplier", { get: function() {
        return this._material.fovMultiplier;
      }, set: function(e) {
        this._material.fovMultiplier = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "textureMode", { get: function() {
        return this._textureMode;
      }, set: function(e) {
        this._textureMode !== e && this._changeTextureMode(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "halfDome", { get: function() {
        return this._halfDome;
      }, set: function(e) {
        this._halfDome = e, this._halfDomeMask.setEnabled(e), this._changeTextureMode(this._textureMode);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "crossEye", { get: function() {
        return this._crossEye;
      }, set: function(e) {
        this._crossEye = e, this._changeTextureMode(this._textureMode);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "material", { get: function() {
        return this._material;
      }, enumerable: !1, configurable: !0 }), t.prototype._changeTextureMode = function(e) {
        var i = this;
        switch (this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver), this._textureMode = e, this._texture.uScale = 1, this._texture.vScale = 1, this._texture.uOffset = 0, this._texture.vOffset = 0, this._texture.vAng = 0, e) {
          case t.MODE_MONOSCOPIC:
            this._halfDome && (this._texture.uScale = 2, this._texture.uOffset = -1);
            break;
          case t.MODE_SIDEBYSIDE:
            this._texture.uScale = this._halfDome ? 0.99999 : 0.5;
            var r = this._halfDome ? 0 : 0.5, o = this._halfDome ? -0.5 : 0;
            this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add(function(a) {
              var s = a.isRightCamera;
              i._crossEye && (s = !s), i._texture.uOffset = s ? r : o;
            });
            break;
          case t.MODE_TOPBOTTOM:
            this._texture.vScale = this._halfDome ? 0.99999 : 0.5, this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add(function(a) {
              var s = a.isRightCamera;
              i._crossEye && (s = !s), i._texture.vOffset = s ? 0.5 : 0;
            });
        }
      }, t.prototype.dispose = function(e, i) {
        i === void 0 && (i = !1), this._texture.dispose(), this._mesh.dispose(), this._material.dispose(), this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver), this.onLoadErrorObservable.clear(), this.onLoadObservable.clear(), n.prototype.dispose.call(this, e, i);
      }, t.MODE_MONOSCOPIC = 0, t.MODE_TOPBOTTOM = 1, t.MODE_SIDEBYSIDE = 2, t;
    }(ai), wC = function(n) {
      function t() {
        return n !== null && n.apply(this, arguments) || this;
      }
      return D(t, n), Object.defineProperty(t.prototype, "photoTexture", { get: function() {
        return this.texture;
      }, set: function(e) {
        this.texture = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "imageMode", { get: function() {
        return this.textureMode;
      }, set: function(e) {
        this.textureMode = e;
      }, enumerable: !1, configurable: !0 }), t.prototype._initTexture = function(e, i, r) {
        var o = this;
        return new ae(e, i, !r.generateMipMaps, !this._useDirectMapping, void 0, function() {
          o.onLoadObservable.notifyObservers();
        }, function(a, s) {
          o.onLoadErrorObservable.notifyObservers(a || "Unknown error occured"), o.onError && o.onError(a, s);
        });
      }, t.MODE_MONOSCOPIC = Rs.MODE_MONOSCOPIC, t.MODE_TOPBOTTOM = Rs.MODE_TOPBOTTOM, t.MODE_SIDEBYSIDE = Rs.MODE_SIDEBYSIDE, t;
    }(Rs), zD = 0, Yc = function(n) {
      if (!n.environmentBRDFTexture) {
        var t = n.useDelayedTextureLoading;
        n.useDelayedTextureLoading = !1;
        var e = n._blockEntityCollection;
        n._blockEntityCollection = !1;
        var i = ae.CreateFromBase64String("data:image/png;base64, ", "EnvironmentBRDFTexture" + zD++, n, !0, !1, ae.BILINEAR_SAMPLINGMODE);
        n._blockEntityCollection = e;
        var r = n.getEngine().getLoadedTexturesCache(), o = r.indexOf(i.getInternalTexture());
        o !== -1 && r.splice(o, 1), i.isRGBD = !0, i.wrapU = ae.CLAMP_ADDRESSMODE, i.wrapV = ae.CLAMP_ADDRESSMODE, n.environmentBRDFTexture = i, n.useDelayedTextureLoading = t, Dh.ExpandRGBDTexture(i);
        var a = n.getEngine().onContextRestoredObservable.add(function() {
          i.isRGBD = !0;
          var s = function() {
            i.isReady() ? Dh.ExpandRGBDTexture(i) : de.SetImmediate(s);
          };
          s();
        });
        n.onDisposeObservable.add(function() {
          n.getEngine().onContextRestoredObservable.remove(a);
        });
      }
      return n.environmentBRDFTexture;
    }, BC = { GetEnvironmentBRDFTexture: Yc }, WD = function(n) {
      function t() {
        var e = n !== null && n.apply(this, arguments) || this;
        return e.BRDF_V_HEIGHT_CORRELATED = !1, e.MS_BRDF_ENERGY_CONSERVATION = !1, e.SPHERICAL_HARMONICS = !1, e.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION = !1, e;
      }
      return D(t, n), t;
    }(jn), UC = function(n) {
      function t(e, i) {
        i === void 0 && (i = !0);
        var r = n.call(this, e, "PBRBRDF", 90, new WD(), i) || this;
        return r._useEnergyConservation = t.DEFAULT_USE_ENERGY_CONSERVATION, r.useEnergyConservation = t.DEFAULT_USE_ENERGY_CONSERVATION, r._useSmithVisibilityHeightCorrelated = t.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED, r.useSmithVisibilityHeightCorrelated = t.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED, r._useSphericalHarmonics = t.DEFAULT_USE_SPHERICAL_HARMONICS, r.useSphericalHarmonics = t.DEFAULT_USE_SPHERICAL_HARMONICS, r._useSpecularGlossinessInputEnergyConservation = t.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION, r.useSpecularGlossinessInputEnergyConservation = t.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION, r._internalMarkAllSubMeshesAsMiscDirty = e._dirtyCallbacks[_.MATERIAL_MiscDirtyFlag], r._enable(!0), r;
      }
      return D(t, n), t.prototype._markAllSubMeshesAsMiscDirty = function() {
        this._internalMarkAllSubMeshesAsMiscDirty();
      }, t.prototype.prepareDefines = function(e) {
        e.BRDF_V_HEIGHT_CORRELATED = this._useSmithVisibilityHeightCorrelated, e.MS_BRDF_ENERGY_CONSERVATION = this._useEnergyConservation && this._useSmithVisibilityHeightCorrelated, e.SPHERICAL_HARMONICS = this._useSphericalHarmonics, e.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION = this._useSpecularGlossinessInputEnergyConservation;
      }, t.prototype.getClassName = function() {
        return "PBRBRDFConfiguration";
      }, t.DEFAULT_USE_ENERGY_CONSERVATION = !0, t.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED = !0, t.DEFAULT_USE_SPHERICAL_HARMONICS = !0, t.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION = !0, x([N(), ye("_markAllSubMeshesAsMiscDirty")], t.prototype, "useEnergyConservation", void 0), x([N(), ye("_markAllSubMeshesAsMiscDirty")], t.prototype, "useSmithVisibilityHeightCorrelated", void 0), x([N(), ye("_markAllSubMeshesAsMiscDirty")], t.prototype, "useSphericalHarmonics", void 0), x([N(), ye("_markAllSubMeshesAsMiscDirty")], t.prototype, "useSpecularGlossinessInputEnergyConservation", void 0), t;
    }($r);
    re.IncludesShadersStore.pbrFragmentDeclaration = `uniform vec4 vEyePosition;uniform vec3 vReflectionColor;uniform vec4 vAlbedoColor;uniform vec4 vLightingIntensity;uniform vec4 vReflectivityColor;uniform vec4 vMetallicReflectanceFactors;uniform vec3 vEmissiveColor;uniform float visibility;uniform vec3 vAmbientColor;
#ifdef ALBEDO
uniform vec2 vAlbedoInfos;
#endif
#ifdef AMBIENT
uniform vec4 vAmbientInfos;
#endif
#ifdef BUMP
uniform vec3 vBumpInfos;uniform vec2 vTangentSpaceParams;
#endif
#ifdef OPACITY
uniform vec2 vOpacityInfos;
#endif
#ifdef EMISSIVE
uniform vec2 vEmissiveInfos;
#endif
#ifdef LIGHTMAP
uniform vec2 vLightmapInfos;
#endif
#ifdef REFLECTIVITY
uniform vec3 vReflectivityInfos;
#endif
#ifdef MICROSURFACEMAP
uniform vec2 vMicroSurfaceSamplerInfos;
#endif
#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(SS_REFRACTION) || defined(PREPASS)
uniform mat4 view;
#endif
#ifdef REFLECTION
uniform vec2 vReflectionInfos;
#ifdef REALTIME_FILTERING
uniform vec2 vReflectionFilteringInfo;
#endif
uniform mat4 reflectionMatrix;uniform vec3 vReflectionMicrosurfaceInfos;
#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)
uniform vec3 vReflectionPosition;uniform vec3 vReflectionSize; 
#endif
#endif
#if defined(SS_REFRACTION) && defined(SS_USE_LOCAL_REFRACTIONMAP_CUBIC)
uniform vec3 vRefractionPosition;uniform vec3 vRefractionSize; 
#endif
#ifdef CLEARCOAT
uniform vec2 vClearCoatParams;uniform vec4 vClearCoatRefractionParams;
#if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS)
uniform vec4 vClearCoatInfos;
#endif
#ifdef CLEARCOAT_TEXTURE
uniform mat4 clearCoatMatrix;
#endif
#ifdef CLEARCOAT_TEXTURE_ROUGHNESS
uniform mat4 clearCoatRoughnessMatrix;
#endif
#ifdef CLEARCOAT_BUMP
uniform vec2 vClearCoatBumpInfos;uniform vec2 vClearCoatTangentSpaceParams;uniform mat4 clearCoatBumpMatrix;
#endif
#ifdef CLEARCOAT_TINT
uniform vec4 vClearCoatTintParams;uniform float clearCoatColorAtDistance;
#ifdef CLEARCOAT_TINT_TEXTURE
uniform vec2 vClearCoatTintInfos;uniform mat4 clearCoatTintMatrix;
#endif
#endif
#endif
#ifdef IRIDESCENCE
uniform vec4 vIridescenceParams;
#if defined(IRIDESCENCE_TEXTURE) || defined(IRIDESCENCE_THICKNESS_TEXTURE)
uniform vec4 vIridescenceInfos;
#endif
#ifdef IRIDESCENCE_TEXTURE
uniform mat4 iridescenceMatrix;
#endif
#ifdef IRIDESCENCE_THICKNESS_TEXTURE
uniform mat4 iridescenceThicknessMatrix;
#endif
#endif
#ifdef ANISOTROPIC
uniform vec3 vAnisotropy;
#ifdef ANISOTROPIC_TEXTURE
uniform vec2 vAnisotropyInfos;uniform mat4 anisotropyMatrix;
#endif
#endif
#ifdef SHEEN
uniform vec4 vSheenColor;
#ifdef SHEEN_ROUGHNESS
uniform float vSheenRoughness;
#endif
#if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS)
uniform vec4 vSheenInfos;
#endif
#ifdef SHEEN_TEXTURE
uniform mat4 sheenMatrix;
#endif
#ifdef SHEEN_TEXTURE_ROUGHNESS
uniform mat4 sheenRoughnessMatrix;
#endif
#endif
#ifdef SUBSURFACE
#ifdef SS_REFRACTION
uniform vec4 vRefractionMicrosurfaceInfos;uniform vec4 vRefractionInfos;uniform mat4 refractionMatrix;
#ifdef REALTIME_FILTERING
uniform vec2 vRefractionFilteringInfo;
#endif
#endif
#ifdef SS_THICKNESSANDMASK_TEXTURE
uniform vec2 vThicknessInfos;uniform mat4 thicknessMatrix;
#endif
#ifdef SS_REFRACTIONINTENSITY_TEXTURE
uniform vec2 vRefractionIntensityInfos;uniform mat4 refractionIntensityMatrix;
#endif
#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
uniform vec2 vTranslucencyIntensityInfos;uniform mat4 translucencyIntensityMatrix;
#endif
uniform vec2 vThicknessParam;uniform vec3 vDiffusionDistance;uniform vec4 vTintColor;uniform vec3 vSubSurfaceIntensity;
#endif
#ifdef PREPASS
#ifdef SS_SCATTERING
uniform float scatteringDiffusionProfile;
#endif
#endif
#if DEBUGMODE>0
uniform vec2 vDebugMode;
#endif
#ifdef DETAIL
uniform vec4 vDetailInfos;
#endif
#include<decalFragmentDeclaration>
#ifdef USESPHERICALFROMREFLECTIONMAP
#ifdef SPHERICAL_HARMONICS
uniform vec3 vSphericalL00;uniform vec3 vSphericalL1_1;uniform vec3 vSphericalL10;uniform vec3 vSphericalL11;uniform vec3 vSphericalL2_2;uniform vec3 vSphericalL2_1;uniform vec3 vSphericalL20;uniform vec3 vSphericalL21;uniform vec3 vSphericalL22;
#else
uniform vec3 vSphericalX;uniform vec3 vSphericalY;uniform vec3 vSphericalZ;uniform vec3 vSphericalXX_ZZ;uniform vec3 vSphericalYY_ZZ;uniform vec3 vSphericalZZ;uniform vec3 vSphericalXY;uniform vec3 vSphericalYZ;uniform vec3 vSphericalZX;
#endif
#endif
#define ADDITIONAL_FRAGMENT_DECLARATION
`, re.IncludesShadersStore.pbrUboDeclaration = `layout(std140,column_major) uniform;uniform Material {vec2 vAlbedoInfos;vec4 vAmbientInfos;vec2 vOpacityInfos;vec2 vEmissiveInfos;vec2 vLightmapInfos;vec3 vReflectivityInfos;vec2 vMicroSurfaceSamplerInfos;vec2 vReflectionInfos;vec2 vReflectionFilteringInfo;vec3 vReflectionPosition;vec3 vReflectionSize;vec3 vBumpInfos;mat4 albedoMatrix;mat4 ambientMatrix;mat4 opacityMatrix;mat4 emissiveMatrix;mat4 lightmapMatrix;mat4 reflectivityMatrix;mat4 microSurfaceSamplerMatrix;mat4 bumpMatrix;vec2 vTangentSpaceParams;mat4 reflectionMatrix;vec3 vReflectionColor;vec4 vAlbedoColor;vec4 vLightingIntensity;vec3 vReflectionMicrosurfaceInfos;float pointSize;vec4 vReflectivityColor;vec3 vEmissiveColor;vec3 vAmbientColor;vec2 vDebugMode;vec4 vMetallicReflectanceFactors;vec2 vMetallicReflectanceInfos;mat4 metallicReflectanceMatrix;vec2 vReflectanceInfos;mat4 reflectanceMatrix;vec3 vSphericalL00;vec3 vSphericalL1_1;vec3 vSphericalL10;vec3 vSphericalL11;vec3 vSphericalL2_2;vec3 vSphericalL2_1;vec3 vSphericalL20;vec3 vSphericalL21;vec3 vSphericalL22;vec3 vSphericalX;vec3 vSphericalY;vec3 vSphericalZ;vec3 vSphericalXX_ZZ;vec3 vSphericalYY_ZZ;vec3 vSphericalZZ;vec3 vSphericalXY;vec3 vSphericalYZ;vec3 vSphericalZX;
#define ADDITIONAL_UBO_DECLARATION
};
#include<sceneUboDeclaration>
#include<meshUboDeclaration>
`, re.IncludesShadersStore.pbrFragmentExtraDeclaration = `varying vec3 vPositionW;
#if DEBUGMODE>0
varying vec4 vClipSpacePosition;
#endif
#include<mainUVVaryingDeclaration>[1..7]
#ifdef NORMAL
varying vec3 vNormalW;
#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
varying vec3 vEnvironmentIrradiance;
#endif
#endif
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
varying vec4 vColor;
#endif
`, re.IncludesShadersStore.samplerFragmentAlternateDeclaration = `#ifdef _DEFINENAME_
#if _DEFINENAME_DIRECTUV==1
#define v_VARYINGNAME_UV vMainUV1
#elif _DEFINENAME_DIRECTUV==2
#define v_VARYINGNAME_UV vMainUV2
#elif _DEFINENAME_DIRECTUV==3
#define v_VARYINGNAME_UV vMainUV3
#elif _DEFINENAME_DIRECTUV==4
#define v_VARYINGNAME_UV vMainUV4
#elif _DEFINENAME_DIRECTUV==5
#define v_VARYINGNAME_UV vMainUV5
#elif _DEFINENAME_DIRECTUV==6
#define v_VARYINGNAME_UV vMainUV6
#else
varying vec2 v_VARYINGNAME_UV;
#endif
#endif
`, re.IncludesShadersStore.pbrFragmentSamplersDeclaration = `#include<samplerFragmentDeclaration>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_SAMPLERNAME_,albedo)
#include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)
#include<samplerFragmentDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)
#include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)
#include<samplerFragmentDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)
#include<samplerFragmentDeclaration>(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_SAMPLERNAME_,reflectivity)
#include<samplerFragmentDeclaration>(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_SAMPLERNAME_,microSurface)
#include<samplerFragmentDeclaration>(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_SAMPLERNAME_,metallicReflectance)
#include<samplerFragmentDeclaration>(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_SAMPLERNAME_,reflectance)
#include<samplerFragmentDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal)
#ifdef CLEARCOAT
#include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_SAMPLERNAME_,clearCoat)
#include<samplerFragmentAlternateDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness)
#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL)
uniform sampler2D clearCoatRoughnessSampler;
#endif
#include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_SAMPLERNAME_,clearCoatBump)
#include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_SAMPLERNAME_,clearCoatTint)
#endif
#ifdef IRIDESCENCE
#include<samplerFragmentDeclaration>(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence,_SAMPLERNAME_,iridescence)
#include<samplerFragmentDeclaration>(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness,_SAMPLERNAME_,iridescenceThickness)
#endif
#ifdef SHEEN
#include<samplerFragmentDeclaration>(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_SAMPLERNAME_,sheen)
#include<samplerFragmentAlternateDeclaration>(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness)
#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL)
uniform sampler2D sheenRoughnessSampler;
#endif
#endif
#ifdef ANISOTROPIC
#include<samplerFragmentDeclaration>(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_SAMPLERNAME_,anisotropy)
#endif
#ifdef REFLECTION
#ifdef REFLECTIONMAP_3D
#define sampleReflection(s,c) textureCube(s,c)
uniform samplerCube reflectionSampler;
#ifdef LODBASEDMICROSFURACE
#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)
#else
uniform samplerCube reflectionSamplerLow;uniform samplerCube reflectionSamplerHigh;
#endif
#ifdef USEIRRADIANCEMAP
uniform samplerCube irradianceSampler;
#endif
#else
#define sampleReflection(s,c) texture2D(s,c)
uniform sampler2D reflectionSampler;
#ifdef LODBASEDMICROSFURACE
#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)
#else
uniform sampler2D reflectionSamplerLow;uniform sampler2D reflectionSamplerHigh;
#endif
#ifdef USEIRRADIANCEMAP
uniform sampler2D irradianceSampler;
#endif
#endif
#ifdef REFLECTIONMAP_SKYBOX
varying vec3 vPositionUVW;
#else
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
varying vec3 vDirectionW;
#endif
#endif
#endif
#ifdef ENVIRONMENTBRDF
uniform sampler2D environmentBrdfSampler;
#endif
#ifdef SUBSURFACE
#ifdef SS_REFRACTION
#ifdef SS_REFRACTIONMAP_3D
#define sampleRefraction(s,c) textureCube(s,c)
uniform samplerCube refractionSampler;
#ifdef LODBASEDMICROSFURACE
#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)
#else
uniform samplerCube refractionSamplerLow;uniform samplerCube refractionSamplerHigh;
#endif
#else
#define sampleRefraction(s,c) texture2D(s,c)
uniform sampler2D refractionSampler;
#ifdef LODBASEDMICROSFURACE
#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)
#else
uniform sampler2D refractionSamplerLow;uniform sampler2D refractionSamplerHigh;
#endif
#endif
#endif
#include<samplerFragmentDeclaration>(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_SAMPLERNAME_,thickness)
#include<samplerFragmentDeclaration>(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_SAMPLERNAME_,refractionIntensity)
#include<samplerFragmentDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_SAMPLERNAME_,translucencyIntensity)
#endif
`, re.IncludesShadersStore.subSurfaceScatteringFunctions = `bool testLightingForSSS(float diffusionProfile)
{return diffusionProfile<1.;}`, re.IncludesShadersStore.importanceSampling = `vec3 hemisphereCosSample(vec2 u) {float phi=2.*PI*u.x;float cosTheta2=1.-u.y;float cosTheta=sqrt(cosTheta2);float sinTheta=sqrt(1.-cosTheta2);return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);}
vec3 hemisphereImportanceSampleDggx(vec2 u,float a) {float phi=2.*PI*u.x;float cosTheta2=(1.-u.y)/(1.+(a+1.)*((a-1.)*u.y));float cosTheta=sqrt(cosTheta2);float sinTheta=sqrt(1.-cosTheta2);return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);}
vec3 hemisphereImportanceSampleDCharlie(vec2 u,float a) { 
float phi=2.*PI*u.x;float sinTheta=pow(u.y,a/(2.*a+1.));float cosTheta=sqrt(1.-sinTheta*sinTheta);return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);}`, re.IncludesShadersStore.pbrHelperFunctions = `#define MINIMUMVARIANCE 0.0005
float convertRoughnessToAverageSlope(float roughness)
{return square(roughness)+MINIMUMVARIANCE;}
float fresnelGrazingReflectance(float reflectance0) {float reflectance90=saturate(reflectance0*25.0);return reflectance90;}
vec2 getAARoughnessFactors(vec3 normalVector) {
#ifdef SPECULARAA
vec3 nDfdx=dFdx(normalVector.xyz);vec3 nDfdy=dFdy(normalVector.xyz);float slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));float geometricRoughnessFactor=pow(saturate(slopeSquare),0.333);float geometricAlphaGFactor=sqrt(slopeSquare);geometricAlphaGFactor*=0.75;return vec2(geometricRoughnessFactor,geometricAlphaGFactor);
#else
return vec2(0.);
#endif
}
#ifdef ANISOTROPIC
#ifdef ANISOTROPIC_LEGACY
vec2 getAnisotropicRoughness(float alphaG,float anisotropy) {float alphaT=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE);float alphaB=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE);return vec2(alphaT,alphaB);}
vec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy,float roughness) {vec3 anisotropicFrameDirection=anisotropy>=0.0 ? B : T;vec3 anisotropicFrameTangent=cross(normalize(anisotropicFrameDirection),V);vec3 anisotropicFrameNormal=cross(anisotropicFrameTangent,anisotropicFrameDirection);vec3 anisotropicNormal=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));return anisotropicNormal;}
#else
vec2 getAnisotropicRoughness(float alphaG,float anisotropy) {float alphaT=max(mix(alphaG,1.0,anisotropy*anisotropy),MINIMUMVARIANCE);float alphaB=max(alphaG,MINIMUMVARIANCE);return vec2(alphaT,alphaB);}
vec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy,float roughness) {vec3 bentNormal=cross(B,V);bentNormal=normalize(cross(bentNormal,B));float a=square(square(1.0-anisotropy*(1.0-roughness)));bentNormal=normalize(mix(bentNormal,N,a));return bentNormal;}
#endif
#endif
#if defined(CLEARCOAT) || defined(SS_REFRACTION)
vec3 cocaLambert(vec3 alpha,float distance) {return exp(-alpha*distance);}
vec3 cocaLambert(float NdotVRefract,float NdotLRefract,vec3 alpha,float thickness) {return cocaLambert(alpha,(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));}
vec3 computeColorAtDistanceInMedia(vec3 color,float distance) {return -log(color)/distance;}
vec3 computeClearCoatAbsorption(float NdotVRefract,float NdotLRefract,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {vec3 clearCoatAbsorption=mix(vec3(1.0),
cocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness),
clearCoatIntensity);return clearCoatAbsorption;}
#endif
#ifdef MICROSURFACEAUTOMATIC
float computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)
{const float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;float reflectivityLuminance=getLuminance(reflectivityColor);float reflectivityLuma=sqrt(reflectivityLuminance);microSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;return microSurface;}
#endif
`, re.IncludesShadersStore.harmonicsFunctions = `#ifdef USESPHERICALFROMREFLECTIONMAP
#ifdef SPHERICAL_HARMONICS
vec3 computeEnvironmentIrradiance(vec3 normal) {return vSphericalL00
+ vSphericalL1_1*(normal.y)
+ vSphericalL10*(normal.z)
+ vSphericalL11*(normal.x)
+ vSphericalL2_2*(normal.y*normal.x)
+ vSphericalL2_1*(normal.y*normal.z)
+ vSphericalL20*((3.0*normal.z*normal.z)-1.0)
+ vSphericalL21*(normal.z*normal.x)
+ vSphericalL22*(normal.x*normal.x-(normal.y*normal.y));}
#else
vec3 computeEnvironmentIrradiance(vec3 normal) {float Nx=normal.x;float Ny=normal.y;float Nz=normal.z;vec3 C1=vSphericalZZ.rgb;vec3 Cx=vSphericalX.rgb;vec3 Cy=vSphericalY.rgb;vec3 Cz=vSphericalZ.rgb;vec3 Cxx_zz=vSphericalXX_ZZ.rgb;vec3 Cyy_zz=vSphericalYY_ZZ.rgb;vec3 Cxy=vSphericalXY.rgb;vec3 Cyz=vSphericalYZ.rgb;vec3 Czx=vSphericalZX.rgb;vec3 a1=Cyy_zz*Ny+Cy;vec3 a2=Cyz*Nz+a1;vec3 b1=Czx*Nz+Cx;vec3 b2=Cxy*Ny+b1;vec3 b3=Cxx_zz*Nx+b2;vec3 t1=Cz *Nz+C1;vec3 t2=a2 *Ny+t1;vec3 t3=b3 *Nx+t2;return t3;}
#endif
#endif
`, re.IncludesShadersStore.pbrDirectLightingSetupFunctions = `struct preLightingInfo
{vec3 lightOffset;float lightDistanceSquared;float lightDistance;float attenuation;vec3 L;vec3 H;float NdotV;float NdotLUnclamped;float NdotL;float VdotH;float roughness;
#ifdef IRIDESCENCE
float iridescenceIntensity;
#endif
};preLightingInfo computePointAndSpotPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {preLightingInfo result;result.lightOffset=lightData.xyz-vPositionW;result.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);result.lightDistance=sqrt(result.lightDistanceSquared);result.L=normalize(result.lightOffset);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H));result.NdotLUnclamped=dot(N,result.L);result.NdotL=saturateEps(result.NdotLUnclamped);return result;}
preLightingInfo computeDirectionalPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {preLightingInfo result;result.lightDistance=length(-lightData.xyz);result.L=normalize(-lightData.xyz);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H));result.NdotLUnclamped=dot(N,result.L);result.NdotL=saturateEps(result.NdotLUnclamped);return result;}
preLightingInfo computeHemisphericPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {preLightingInfo result;result.NdotL=dot(N,lightData.xyz)*0.5+0.5;result.NdotL=saturateEps(result.NdotL);result.NdotLUnclamped=result.NdotL;
#ifdef SPECULARTERM
result.L=normalize(lightData.xyz);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H));
#endif
return result;}`, re.IncludesShadersStore.pbrDirectLightingFalloffFunctions = `float computeDistanceLightFalloff_Standard(vec3 lightOffset,float range)
{return max(0.,1.0-length(lightOffset)/range);}
float computeDistanceLightFalloff_Physical(float lightDistanceSquared)
{return 1.0/maxEps(lightDistanceSquared);}
float computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange)
{float lightDistanceFalloff=1.0/maxEps(lightDistanceSquared);float factor=lightDistanceSquared*inverseSquaredRange;float attenuation=saturate(1.0-factor*factor);attenuation*=attenuation;lightDistanceFalloff*=attenuation;return lightDistanceFalloff;}
float computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range,float inverseSquaredRange)
{
#ifdef USEPHYSICALLIGHTFALLOFF
return computeDistanceLightFalloff_Physical(lightDistanceSquared);
#elif defined(USEGLTFLIGHTFALLOFF)
return computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);
#else
return computeDistanceLightFalloff_Standard(lightOffset,range);
#endif
}
float computeDirectionalLightFalloff_Standard(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent)
{float falloff=0.0;float cosAngle=maxEps(dot(-lightDirection,directionToLightCenterW));if (cosAngle>=cosHalfAngle)
{falloff=max(0.,pow(cosAngle,exponent));}
return falloff;}
float computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle)
{const float kMinusLog2ConeAngleIntensityRatio=6.64385618977; 
float concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);vec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);float falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));return falloff;}
float computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset)
{float cd=dot(-lightDirection,directionToLightCenterW);float falloff=saturate(cd*lightAngleScale+lightAngleOffset);falloff*=falloff;return falloff;}
float computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent,float lightAngleScale,float lightAngleOffset)
{
#ifdef USEPHYSICALLIGHTFALLOFF
return computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);
#elif defined(USEGLTFLIGHTFALLOFF)
return computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);
#else
return computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);
#endif
}`, re.IncludesShadersStore.pbrBRDFFunctions = `#define FRESNEL_MAXIMUM_ON_ROUGH 0.25
#ifdef MS_BRDF_ENERGY_CONSERVATION
vec3 getEnergyConservationFactor(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {return 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0);}
#endif
#ifdef ENVIRONMENTBRDF
vec3 getBRDFLookup(float NdotV,float perceptualRoughness) {vec2 UV=vec2(NdotV,perceptualRoughness);vec4 brdfLookup=texture2D(environmentBrdfSampler,UV);
#ifdef ENVIRONMENTBRDF_RGBD
brdfLookup.rgb=fromRGBD(brdfLookup.rgba);
#endif
return brdfLookup.rgb;}
vec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 specularEnvironmentR90,const vec3 environmentBrdf) {
#ifdef BRDF_V_HEIGHT_CORRELATED
vec3 reflectance=(specularEnvironmentR90-specularEnvironmentR0)*environmentBrdf.x+specularEnvironmentR0*environmentBrdf.y;
#else
vec3 reflectance=specularEnvironmentR0*environmentBrdf.x+specularEnvironmentR90*environmentBrdf.y;
#endif
return reflectance;}
vec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {
#ifdef BRDF_V_HEIGHT_CORRELATED
vec3 reflectance=mix(environmentBrdf.xxx,environmentBrdf.yyy,specularEnvironmentR0);
#else
vec3 reflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;
#endif
return reflectance;}
#endif
/* NOT USED
#if defined(SHEEN) && defined(SHEEN_SOFTER)
float getBRDFLookupCharlieSheen(float NdotV,float perceptualRoughness)
{float c=1.0-NdotV;float c3=c*c*c;return 0.65584461*c3+1.0/(4.16526551+exp(-7.97291361*perceptualRoughness+6.33516894));}
#endif
*/
#if !defined(ENVIRONMENTBRDF) || defined(REFLECTIONMAP_SKYBOX) || defined(ALPHAFRESNEL)
vec3 getReflectanceFromAnalyticalBRDFLookup_Jones(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)
{float weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);return reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));}
#endif
#if defined(SHEEN) && defined(ENVIRONMENTBRDF)
/**
* The sheen BRDF not containing F can be easily stored in the blue channel of the BRDF texture.
* The blue channel contains DCharlie*VAshikhmin*NdotL as a lokkup table
*/
vec3 getSheenReflectanceFromBRDFLookup(const vec3 reflectance0,const vec3 environmentBrdf) {vec3 sheenEnvironmentReflectance=reflectance0*environmentBrdf.b;return sheenEnvironmentReflectance;}
#endif
vec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)
{return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);}
float fresnelSchlickGGX(float VdotH,float reflectance0,float reflectance90)
{return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);}
#ifdef CLEARCOAT
vec3 getR0RemappedForClearCoat(vec3 f0) {
#ifdef CLEARCOAT_DEFAULTIOR
#ifdef MOBILE
return saturate(f0*(f0*0.526868+0.529324)-0.0482256);
#else
return saturate(f0*(f0*(0.941892-0.263008*f0)+0.346479)-0.0285998);
#endif
#else
vec3 s=sqrt(f0);vec3 t=(vClearCoatRefractionParams.z+vClearCoatRefractionParams.w*s)/(vClearCoatRefractionParams.w+vClearCoatRefractionParams.z*s);return square(t);
#endif
}
#endif
#ifdef 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 getIORTfromAirToSurfaceR0(vec3 f0) {vec3 sqrtF0=sqrt(f0);return (1.+sqrtF0)/(1.-sqrtF0);}
vec3 getR0fromIORs(vec3 iorT,float iorI) {return square((iorT-vec3(iorI))/(iorT+vec3(iorI)));}
float getR0fromIORs(float iorT,float iorI) {return square((iorT-iorI)/(iorT+iorI));}
vec3 evalSensitivity(float opd,vec3 shift) {float phase=2.0*PI*opd*1.0e-9;const vec3 val=vec3(5.4856e-13,4.4201e-13,5.2481e-13);const vec3 pos=vec3(1.6810e+06,1.7953e+06,2.2084e+06);const 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(-square(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*square(phase));xyz/=1.0685e-7;vec3 srgb=XYZ_TO_REC709*xyz;return srgb;}
vec3 evalIridescence(float outsideIOR,float eta2,float cosTheta1,float thinFilmThickness,vec3 baseF0) {vec3 I=vec3(1.0);float iridescenceIOR=mix(outsideIOR,eta2,smoothstep(0.0,0.03,thinFilmThickness));float sinTheta2Sq=square(outsideIOR/iridescenceIOR)*(1.0-square(cosTheta1));float cosTheta2Sq=1.0-sinTheta2Sq;if (cosTheta2Sq<0.0) {return I;}
float cosTheta2=sqrt(cosTheta2Sq);float R0=getR0fromIORs(iridescenceIOR,outsideIOR);float R12=fresnelSchlickGGX(cosTheta1,R0,1.);float R21=R12;float T121=1.0-R12;float phi12=0.0;if (iridescenceIOR<outsideIOR) phi12=PI;float phi21=PI-phi12;vec3 baseIOR=getIORTfromAirToSurfaceR0(clamp(baseF0,0.0,0.9999)); 
vec3 R1=getR0fromIORs(baseIOR,iridescenceIOR);vec3 R23=fresnelSchlickGGX(cosTheta2,R1,vec3(1.));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=square(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
float normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)
{float a2=square(alphaG);float d=NdotH*NdotH*(a2-1.0)+1.0;return a2/(PI*d*d);}
#ifdef SHEEN
float normalDistributionFunction_CharlieSheen(float NdotH,float alphaG)
{float invR=1./alphaG;float cos2h=NdotH*NdotH;float sin2h=1.-cos2h;return (2.+invR)*pow(sin2h,invR*.5)/(2.*PI);}
#endif
#ifdef ANISOTROPIC
float normalDistributionFunction_BurleyGGX_Anisotropic(float NdotH,float TdotH,float BdotH,const vec2 alphaTB) {float a2=alphaTB.x*alphaTB.y;vec3 v=vec3(alphaTB.y*TdotH,alphaTB.x *BdotH,a2*NdotH);float v2=dot(v,v);float w2=a2/v2;return a2*w2*w2*RECIPROCAL_PI;}
#endif
#ifdef BRDF_V_HEIGHT_CORRELATED
float smithVisibility_GGXCorrelated(float NdotL,float NdotV,float alphaG) {
#ifdef MOBILE
float GGXV=NdotL*(NdotV*(1.0-alphaG)+alphaG);float GGXL=NdotV*(NdotL*(1.0-alphaG)+alphaG);return 0.5/(GGXV+GGXL);
#else
float a2=alphaG*alphaG;float GGXV=NdotL*sqrt(NdotV*(NdotV-a2*NdotV)+a2);float GGXL=NdotV*sqrt(NdotL*(NdotL-a2*NdotL)+a2);return 0.5/(GGXV+GGXL);
#endif
}
#else
float smithVisibilityG1_TrowbridgeReitzGGXFast(float dot,float alphaG)
{
#ifdef MOBILE
return 1.0/(dot+alphaG+(1.0-alphaG)*dot ));
#else
float alphaSquared=alphaG*alphaG;return 1.0/(dot+sqrt(alphaSquared+(1.0-alphaSquared)*dot*dot));
#endif
}
float smithVisibility_TrowbridgeReitzGGXFast(float NdotL,float NdotV,float alphaG)
{float visibility=smithVisibilityG1_TrowbridgeReitzGGXFast(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGXFast(NdotV,alphaG);return visibility;}
#endif
#ifdef ANISOTROPIC
float smithVisibility_GGXCorrelated_Anisotropic(float NdotL,float NdotV,float TdotV,float BdotV,float TdotL,float BdotL,const vec2 alphaTB) {float lambdaV=NdotL*length(vec3(alphaTB.x*TdotV,alphaTB.y*BdotV,NdotV));float lambdaL=NdotV*length(vec3(alphaTB.x*TdotL,alphaTB.y*BdotL,NdotL));float v=0.5/(lambdaV+lambdaL);return v;}
#endif
#ifdef CLEARCOAT
float visibility_Kelemen(float VdotH) {return 0.25/(VdotH*VdotH); }
#endif
#ifdef SHEEN
float visibility_Ashikhmin(float NdotL,float NdotV)
{return 1./(4.*(NdotL+NdotV-NdotL*NdotV));}
/* NOT USED
#ifdef SHEEN_SOFTER
float l(float x,float alphaG)
{float oneMinusAlphaSq=(1.0-alphaG)*(1.0-alphaG);float a=mix(21.5473,25.3245,oneMinusAlphaSq);float b=mix(3.82987,3.32435,oneMinusAlphaSq);float c=mix(0.19823,0.16801,oneMinusAlphaSq);float d=mix(-1.97760,-1.27393,oneMinusAlphaSq);float e=mix(-4.32054,-4.85967,oneMinusAlphaSq);return a/(1.0+b*pow(x,c))+d*x+e;}
float lambdaSheen(float cosTheta,float alphaG)
{return abs(cosTheta)<0.5 ? exp(l(cosTheta,alphaG)) : exp(2.0*l(0.5,alphaG)-l(1.0-cosTheta,alphaG));}
float visibility_CharlieSheen(float NdotL,float NdotV,float alphaG)
{float G=1.0/(1.0+lambdaSheen(NdotV,alphaG)+lambdaSheen(NdotL,alphaG));return G/(4.0*NdotV*NdotL);}
#endif
*/
#endif
float diffuseBRDF_Burley(float NdotL,float NdotV,float VdotH,float roughness) {float diffuseFresnelNV=pow5(saturateEps(1.0-NdotL));float diffuseFresnelNL=pow5(saturateEps(1.0-NdotV));float diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;float fresnel =
(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *
(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);return fresnel/PI;}
#ifdef SS_TRANSLUCENCY
vec3 transmittanceBRDF_Burley(const vec3 tintColor,const vec3 diffusionDistance,float thickness) {vec3 S=1./maxEps(diffusionDistance);vec3 temp=exp((-0.333333333*thickness)*S);return tintColor.rgb*0.25*(temp*temp*temp+3.0*temp);}
float computeWrappedDiffuseNdotL(float NdotL,float w) {float t=1.0+w;float invt2=1.0/square(t);return saturate((NdotL+w)*invt2);}
#endif
`, re.IncludesShadersStore.hdrFilteringFunctions = `#ifdef NUM_SAMPLES
#if NUM_SAMPLES>0
#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
float radicalInverse_VdC(uint bits) 
{bits=(bits<<16u) | (bits>>16u);bits=((bits & 0x55555555u)<<1u) | ((bits & 0xAAAAAAAAu)>>1u);bits=((bits & 0x33333333u)<<2u) | ((bits & 0xCCCCCCCCu)>>2u);bits=((bits & 0x0F0F0F0Fu)<<4u) | ((bits & 0xF0F0F0F0u)>>4u);bits=((bits & 0x00FF00FFu)<<8u) | ((bits & 0xFF00FF00u)>>8u);return float(bits)*2.3283064365386963e-10; }
vec2 hammersley(uint i,uint N)
{return vec2(float(i)/float(N),radicalInverse_VdC(i));}
#else
float vanDerCorpus(int n,int base)
{float invBase=1.0/float(base);float denom =1.0;float result =0.0;for(int i=0; i<32; ++i)
{if(n>0)
{denom =mod(float(n),2.0);result+=denom*invBase;invBase=invBase/2.0;n =int(float(n)/2.0);}}
return result;}
vec2 hammersley(int i,int N)
{return vec2(float(i)/float(N),vanDerCorpus(i,2));}
#endif
float log4(float x) {return log2(x)/2.;}
const float NUM_SAMPLES_FLOAT=float(NUM_SAMPLES);const float NUM_SAMPLES_FLOAT_INVERSED=1./NUM_SAMPLES_FLOAT;const float K=4.;
#define inline
vec3 irradiance(samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)
{vec3 n=normalize(inputN);vec3 result=vec3(0.0);vec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);tangent=normalize(cross(tangent,n));vec3 bitangent=cross(n,tangent);mat3 tbn=mat3(tangent,bitangent,n);float maxLevel=filteringInfo.y;float dim0=filteringInfo.x;float omegaP=(4.*PI)/(6.*dim0*dim0);
#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
for(uint i=0u; i<NUM_SAMPLES; ++i)
#else
for(int i=0; i<NUM_SAMPLES; ++i)
#endif
{vec2 Xi=hammersley(i,NUM_SAMPLES);vec3 Ls=hemisphereCosSample(Xi);Ls=normalize(Ls);vec3 Ns=vec3(0.,0.,1.);float NoL=dot(Ns,Ls);if (NoL>0.) {float pdf_inversed=PI/NoL;float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;float l=log4(omegaS)-log4(omegaP)+log4(K);float mipLevel=clamp(l,0.0,maxLevel);vec3 c=textureCubeLodEXT(inputTexture,tbn*Ls,mipLevel).rgb;
#ifdef GAMMA_INPUT
c=toLinearSpace(c);
#endif
result+=c;}}
result=result*NUM_SAMPLES_FLOAT_INVERSED;return result;}
#define inline
vec3 radiance(float alphaG,samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)
{vec3 n=normalize(inputN);vec3 c=textureCube(inputTexture,n).rgb; 
if (alphaG==0.) {
#ifdef GAMMA_INPUT
c=toLinearSpace(c);
#endif
return c;} else {vec3 result=vec3(0.);vec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);tangent=normalize(cross(tangent,n));vec3 bitangent=cross(n,tangent);mat3 tbn=mat3(tangent,bitangent,n);float maxLevel=filteringInfo.y;float dim0=filteringInfo.x;float omegaP=(4.*PI)/(6.*dim0*dim0);float weight=0.;
#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
for(uint i=0u; i<NUM_SAMPLES; ++i)
#else
for(int i=0; i<NUM_SAMPLES; ++i)
#endif
{vec2 Xi=hammersley(i,NUM_SAMPLES);vec3 H=hemisphereImportanceSampleDggx(Xi,alphaG);float NoV=1.;float NoH=H.z;float NoH2=H.z*H.z;float NoL=2.*NoH2-1.;vec3 L=vec3(2.*NoH*H.x,2.*NoH*H.y,NoL);L=normalize(L);if (NoL>0.) {float pdf_inversed=4./normalDistributionFunction_TrowbridgeReitzGGX(NoH,alphaG);float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;float l=log4(omegaS)-log4(omegaP)+log4(K);float mipLevel=clamp(float(l),0.0,maxLevel);weight+=NoL;vec3 c=textureCubeLodEXT(inputTexture,tbn*L,mipLevel).rgb;
#ifdef GAMMA_INPUT
c=toLinearSpace(c);
#endif
result+=c*NoL;}}
result=result/weight;return result;}}
#endif
#endif
`, re.IncludesShadersStore.pbrDirectLightingFunctions = `#define CLEARCOATREFLECTANCE90 1.0
struct lightingInfo
{vec3 diffuse;
#ifdef SPECULARTERM
vec3 specular;
#endif
#ifdef CLEARCOAT
vec4 clearCoat;
#endif
#ifdef SHEEN
vec3 sheen;
#endif
};float adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance) {
#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)
float lightRoughness=lightRadius/lightDistance;float totalRoughness=saturate(lightRoughness+roughness);return totalRoughness;
#else
return roughness;
#endif
}
vec3 computeHemisphericDiffuseLighting(preLightingInfo info,vec3 lightColor,vec3 groundColor) {return mix(groundColor,lightColor,info.NdotL);}
vec3 computeDiffuseLighting(preLightingInfo info,vec3 lightColor) {float diffuseTerm=diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness);return diffuseTerm*info.attenuation*info.NdotL*lightColor;}
#define inline
vec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){vec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);strq/=strq.w;vec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;return toLinearSpace(textureColor);}
#ifdef SS_TRANSLUCENCY
vec3 computeDiffuseAndTransmittedLighting(preLightingInfo info,vec3 lightColor,vec3 transmittance) {float NdotL=absEps(info.NdotLUnclamped);float wrapNdotL=computeWrappedDiffuseNdotL(NdotL,0.02);float trAdapt=step(0.,info.NdotLUnclamped);vec3 transmittanceNdotL=mix(transmittance*wrapNdotL,vec3(wrapNdotL),trAdapt);float diffuseTerm=diffuseBRDF_Burley(NdotL,info.NdotV,info.VdotH,info.roughness);return diffuseTerm*transmittanceNdotL*info.attenuation*lightColor;}
#endif
#ifdef SPECULARTERM
vec3 computeSpecularLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {float NdotH=saturateEps(dot(N,info.H));float roughness=max(info.roughness,geometricRoughnessFactor);float alphaG=convertRoughnessToAverageSlope(roughness);vec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);
#ifdef IRIDESCENCE
fresnel=mix(fresnel,reflectance0,info.iridescenceIntensity);
#endif
float distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);
#ifdef BRDF_V_HEIGHT_CORRELATED
float smithVisibility=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG);
#else
float smithVisibility=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG);
#endif
vec3 specTerm=fresnel*distribution*smithVisibility;return specTerm*info.attenuation*info.NdotL*lightColor;}
#endif
#ifdef ANISOTROPIC
vec3 computeAnisotropicSpecularLighting(preLightingInfo info,vec3 V,vec3 N,vec3 T,vec3 B,float anisotropy,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {float NdotH=saturateEps(dot(N,info.H));float TdotH=dot(T,info.H);float BdotH=dot(B,info.H);float TdotV=dot(T,V);float BdotV=dot(B,V);float TdotL=dot(T,info.L);float BdotL=dot(B,info.L);float alphaG=convertRoughnessToAverageSlope(info.roughness);vec2 alphaTB=getAnisotropicRoughness(alphaG,anisotropy);alphaTB=max(alphaTB,square(geometricRoughnessFactor));vec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);
#ifdef IRIDESCENCE
fresnel=mix(fresnel,reflectance0,info.iridescenceIntensity);
#endif
float distribution=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);float smithVisibility=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);vec3 specTerm=fresnel*distribution*smithVisibility;return specTerm*info.attenuation*info.NdotL*lightColor;}
#endif
#ifdef CLEARCOAT
vec4 computeClearCoatLighting(preLightingInfo info,vec3 Ncc,float geometricRoughnessFactor,float clearCoatIntensity,vec3 lightColor) {float NccdotL=saturateEps(dot(Ncc,info.L));float NccdotH=saturateEps(dot(Ncc,info.H));float clearCoatRoughness=max(info.roughness,geometricRoughnessFactor);float alphaG=convertRoughnessToAverageSlope(clearCoatRoughness);float fresnel=fresnelSchlickGGX(info.VdotH,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);fresnel*=clearCoatIntensity;float distribution=normalDistributionFunction_TrowbridgeReitzGGX(NccdotH,alphaG);float kelemenVisibility=visibility_Kelemen(info.VdotH);float clearCoatTerm=fresnel*distribution*kelemenVisibility;return vec4(
clearCoatTerm*info.attenuation*NccdotL*lightColor,
1.0-fresnel
);}
vec3 computeClearCoatLightingAbsorption(float NdotVRefract,vec3 L,vec3 Ncc,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {vec3 LRefract=-refract(L,Ncc,vClearCoatRefractionParams.y);float NdotLRefract=saturateEps(dot(Ncc,LRefract));vec3 absorption=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);return absorption;}
#endif
#ifdef SHEEN
vec3 computeSheenLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {float NdotH=saturateEps(dot(N,info.H));float roughness=max(info.roughness,geometricRoughnessFactor);float alphaG=convertRoughnessToAverageSlope(roughness);float fresnel=1.;float distribution=normalDistributionFunction_CharlieSheen(NdotH,alphaG);/*#ifdef SHEEN_SOFTER
float visibility=visibility_CharlieSheen(info.NdotL,info.NdotV,alphaG);
#else */
float visibility=visibility_Ashikhmin(info.NdotL,info.NdotV);/* #endif */
float sheenTerm=fresnel*distribution*visibility;return sheenTerm*info.attenuation*info.NdotL*lightColor;}
#endif
`, re.IncludesShadersStore.pbrIBLFunctions = `#if defined(REFLECTION) || defined(SS_REFRACTION)
float getLodFromAlphaG(float cubeMapDimensionPixels,float microsurfaceAverageSlope) {float microsurfaceAverageSlopeTexels=cubeMapDimensionPixels*microsurfaceAverageSlope;float lod=log2(microsurfaceAverageSlopeTexels);return lod;}
float getLinearLodFromRoughness(float cubeMapDimensionPixels,float roughness) {float lod=log2(cubeMapDimensionPixels)*roughness;return lod;}
#endif
#if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION)
float environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {float temp=NdotVUnclamped+ambientOcclusion;return saturate(square(temp)-1.0+ambientOcclusion);}
#endif
#if defined(ENVIRONMENTBRDF) && defined(HORIZONOCCLUSION)
float environmentHorizonOcclusion(vec3 view,vec3 normal,vec3 geometricNormal) {vec3 reflection=reflect(view,normal);float temp=saturate(1.0+1.1*dot(reflection,geometricNormal));return square(temp);}
#endif
#if defined(LODINREFLECTIONALPHA) || defined(SS_LODINREFRACTIONALPHA)
#define UNPACK_LOD(x) (1.0-x)*255.0
float getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {float microsurfaceAverageSlope=alphaG;microsurfaceAverageSlope*=sqrt(abs(NdotV));return getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope);}
#endif
`, re.IncludesShadersStore.pbrBlockAlbedoOpacity = `struct albedoOpacityOutParams
{vec3 surfaceAlbedo;float alpha;};
#define pbr_inline
void albedoOpacityBlock(
in vec4 vAlbedoColor,
#ifdef ALBEDO
in vec4 albedoTexture,
in vec2 albedoInfos,
#endif
#ifdef OPACITY
in vec4 opacityMap,
in vec2 vOpacityInfos,
#endif
#ifdef DETAIL
in vec4 detailColor,
in vec4 vDetailInfos,
#endif
#ifdef DECAL
in vec4 decalColor,
in vec4 vDecalInfos,
#endif
out albedoOpacityOutParams outParams
)
{vec3 surfaceAlbedo=vAlbedoColor.rgb;float alpha=vAlbedoColor.a;
#ifdef ALBEDO
#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)
alpha*=albedoTexture.a;
#endif
#ifdef GAMMAALBEDO
surfaceAlbedo*=toLinearSpace(albedoTexture.rgb);
#else
surfaceAlbedo*=albedoTexture.rgb;
#endif
surfaceAlbedo*=albedoInfos.y;
#endif
#ifndef DECAL_AFTER_DETAIL
#include<decalFragment>
#endif
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
surfaceAlbedo*=vColor.rgb;
#endif
#ifdef DETAIL
float detailAlbedo=2.0*mix(0.5,detailColor.r,vDetailInfos.y);surfaceAlbedo.rgb=surfaceAlbedo.rgb*detailAlbedo*detailAlbedo; 
#endif
#ifdef DECAL_AFTER_DETAIL
#include<decalFragment>
#endif
#define CUSTOM_FRAGMENT_UPDATE_ALBEDO
#ifdef OPACITY
#ifdef OPACITYRGB
alpha=getLuminance(opacityMap.rgb);
#else
alpha*=opacityMap.a;
#endif
alpha*=vOpacityInfos.y;
#endif
#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)
alpha*=vColor.a;
#endif
#if !defined(SS_LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)
#ifdef ALPHATEST 
#if DEBUGMODE != 88
if (alpha<ALPHATESTVALUE)
discard;
#endif
#ifndef ALPHABLEND
alpha=1.0;
#endif
#endif
#endif
outParams.surfaceAlbedo=surfaceAlbedo;outParams.alpha=alpha;}
`, re.IncludesShadersStore.pbrBlockReflectivity = `struct reflectivityOutParams
{float microSurface;float roughness;vec3 surfaceReflectivityColor;
#ifdef METALLICWORKFLOW
vec3 surfaceAlbedo;
#endif
#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
vec3 ambientOcclusionColor;
#endif
#if DEBUGMODE>0
#ifdef METALLICWORKFLOW
vec2 metallicRoughness;
#ifdef REFLECTIVITY
vec4 surfaceMetallicColorMap;
#endif
#ifndef FROSTBITE_REFLECTANCE
vec3 metallicF0;
#endif
#else
#ifdef REFLECTIVITY
vec4 surfaceReflectivityColorMap;
#endif
#endif
#endif
};
#define pbr_inline
void reflectivityBlock(
in vec4 vReflectivityColor,
#ifdef METALLICWORKFLOW
in vec3 surfaceAlbedo,
in vec4 metallicReflectanceFactors,
#endif
#ifdef REFLECTIVITY
in vec3 reflectivityInfos,
in vec4 surfaceMetallicOrReflectivityColorMap,
#endif
#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
in vec3 ambientOcclusionColorIn,
#endif
#ifdef MICROSURFACEMAP
in vec4 microSurfaceTexel,
#endif
#ifdef DETAIL
in vec4 detailColor,
in vec4 vDetailInfos,
#endif
out reflectivityOutParams outParams
)
{float microSurface=vReflectivityColor.a;vec3 surfaceReflectivityColor=vReflectivityColor.rgb;
#ifdef METALLICWORKFLOW
vec2 metallicRoughness=surfaceReflectivityColor.rg;
#ifdef REFLECTIVITY
#if DEBUGMODE>0
outParams.surfaceMetallicColorMap=surfaceMetallicOrReflectivityColorMap;
#endif
#ifdef AOSTOREINMETALMAPRED
vec3 aoStoreInMetalMap=vec3(surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r);outParams.ambientOcclusionColor=mix(ambientOcclusionColorIn,aoStoreInMetalMap,reflectivityInfos.z);
#endif
#ifdef METALLNESSSTOREINMETALMAPBLUE
metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.b;
#else
metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.r;
#endif
#ifdef ROUGHNESSSTOREINMETALMAPALPHA
metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.a;
#else
#ifdef ROUGHNESSSTOREINMETALMAPGREEN
metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.g;
#endif
#endif
#endif
#ifdef DETAIL
float detailRoughness=mix(0.5,detailColor.b,vDetailInfos.w);float loLerp=mix(0.,metallicRoughness.g,detailRoughness*2.);float hiLerp=mix(metallicRoughness.g,1.,(detailRoughness-0.5)*2.);metallicRoughness.g=mix(loLerp,hiLerp,step(detailRoughness,0.5));
#endif
#ifdef MICROSURFACEMAP
metallicRoughness.g*=microSurfaceTexel.r;
#endif
#if DEBUGMODE>0
outParams.metallicRoughness=metallicRoughness;
#endif
#define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS
microSurface=1.0-metallicRoughness.g;vec3 baseColor=surfaceAlbedo;
#ifdef FROSTBITE_REFLECTANCE
outParams.surfaceAlbedo=baseColor.rgb*(1.0-metallicRoughness.r);surfaceReflectivityColor=mix(0.16*reflectance*reflectance,baseColor,metallicRoughness.r);
#else
vec3 metallicF0=metallicReflectanceFactors.rgb;
#if DEBUGMODE>0
outParams.metallicF0=metallicF0;
#endif
outParams.surfaceAlbedo=mix(baseColor.rgb*(1.0-metallicF0),vec3(0.,0.,0.),metallicRoughness.r);surfaceReflectivityColor=mix(metallicF0,baseColor,metallicRoughness.r);
#endif
#else
#ifdef REFLECTIVITY
surfaceReflectivityColor*=surfaceMetallicOrReflectivityColorMap.rgb;
#if DEBUGMODE>0
outParams.surfaceReflectivityColorMap=surfaceMetallicOrReflectivityColorMap;
#endif
#ifdef MICROSURFACEFROMREFLECTIVITYMAP
microSurface*=surfaceMetallicOrReflectivityColorMap.a;microSurface*=reflectivityInfos.z;
#else
#ifdef MICROSURFACEAUTOMATIC
microSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);
#endif
#ifdef MICROSURFACEMAP
microSurface*=microSurfaceTexel.r;
#endif
#define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE
#endif
#endif
#endif
microSurface=saturate(microSurface);float roughness=1.-microSurface;outParams.microSurface=microSurface;outParams.roughness=roughness;outParams.surfaceReflectivityColor=surfaceReflectivityColor;}
`, re.IncludesShadersStore.pbrBlockAmbientOcclusion = `struct ambientOcclusionOutParams
{vec3 ambientOcclusionColor;
#if DEBUGMODE>0 && defined(AMBIENT)
vec3 ambientOcclusionColorMap;
#endif
};
#define pbr_inline
void ambientOcclusionBlock(
#ifdef AMBIENT
in vec3 ambientOcclusionColorMap_,
in vec4 vAmbientInfos,
#endif
out ambientOcclusionOutParams outParams
)
{vec3 ambientOcclusionColor=vec3(1.,1.,1.);
#ifdef AMBIENT
vec3 ambientOcclusionColorMap=ambientOcclusionColorMap_*vAmbientInfos.y;
#ifdef AMBIENTINGRAYSCALE
ambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);
#endif
ambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);
#if DEBUGMODE>0
outParams.ambientOcclusionColorMap=ambientOcclusionColorMap;
#endif
#endif
outParams.ambientOcclusionColor=ambientOcclusionColor;}
`, re.IncludesShadersStore.pbrBlockAlphaFresnel = `#ifdef ALPHAFRESNEL
#if defined(ALPHATEST) || defined(ALPHABLEND)
struct alphaFresnelOutParams
{float alpha;};
#define pbr_inline
void alphaFresnelBlock(
in vec3 normalW,
in vec3 viewDirectionW,
in float alpha,
in float microSurface,
out alphaFresnelOutParams outParams
)
{float opacityPerceptual=alpha;
#ifdef LINEARALPHAFRESNEL
float opacity0=opacityPerceptual;
#else
float opacity0=opacityPerceptual*opacityPerceptual;
#endif
float opacity90=fresnelGrazingReflectance(opacity0);vec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);outParams.alpha=getReflectanceFromAnalyticalBRDFLookup_Jones(saturate(dot(viewDirectionW,normalForward)),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;
#ifdef ALPHATEST
if (outParams.alpha<ALPHATESTVALUE)
discard;
#ifndef ALPHABLEND
outParams.alpha=1.0;
#endif
#endif
}
#endif
#endif
`, re.IncludesShadersStore.pbrBlockAnisotropic = `#ifdef ANISOTROPIC
struct anisotropicOutParams
{float anisotropy;vec3 anisotropicTangent;vec3 anisotropicBitangent;vec3 anisotropicNormal;
#if DEBUGMODE>0 && defined(ANISOTROPIC_TEXTURE)
vec3 anisotropyMapData;
#endif
};
#define pbr_inline
void anisotropicBlock(
in vec3 vAnisotropy,
in float roughness,
#ifdef ANISOTROPIC_TEXTURE
in vec3 anisotropyMapData,
#endif
in mat3 TBN,
in vec3 normalW,
in vec3 viewDirectionW,
out anisotropicOutParams outParams
)
{float anisotropy=vAnisotropy.b;vec3 anisotropyDirection=vec3(vAnisotropy.xy,0.);
#ifdef ANISOTROPIC_TEXTURE
anisotropy*=anisotropyMapData.b;
#if DEBUGMODE>0
outParams.anisotropyMapData=anisotropyMapData;
#endif
anisotropyMapData.rg=anisotropyMapData.rg*2.0-1.0;
#ifdef ANISOTROPIC_LEGACY
anisotropyDirection.rg*=anisotropyMapData.rg;
#else
anisotropyDirection.xy=mat2(anisotropyDirection.x,anisotropyDirection.y,-anisotropyDirection.y,anisotropyDirection.x)*normalize(anisotropyMapData.rg);
#endif
#endif
mat3 anisoTBN=mat3(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));vec3 anisotropicTangent=normalize(anisoTBN*anisotropyDirection);vec3 anisotropicBitangent=normalize(cross(anisoTBN[2],anisotropicTangent));outParams.anisotropy=anisotropy;outParams.anisotropicTangent=anisotropicTangent;outParams.anisotropicBitangent=anisotropicBitangent;outParams.anisotropicNormal=getAnisotropicBentNormals(anisotropicTangent,anisotropicBitangent,normalW,viewDirectionW,anisotropy,roughness);}
#endif
`, re.IncludesShadersStore.pbrBlockReflection = `#ifdef REFLECTION
struct reflectionOutParams
{vec4 environmentRadiance;vec3 environmentIrradiance;
#ifdef REFLECTIONMAP_3D
vec3 reflectionCoords;
#else
vec2 reflectionCoords;
#endif
#ifdef SS_TRANSLUCENCY
#ifdef USESPHERICALFROMREFLECTIONMAP
#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
vec3 irradianceVector;
#endif
#endif
#endif
};
#define pbr_inline
void createReflectionCoords(
in vec3 vPositionW,
in vec3 normalW,
#ifdef ANISOTROPIC
in anisotropicOutParams anisotropicOut,
#endif
#ifdef REFLECTIONMAP_3D
out vec3 reflectionCoords
#else
out vec2 reflectionCoords
#endif
)
{
#ifdef ANISOTROPIC
vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),anisotropicOut.anisotropicNormal);
#else
vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);
#endif
#ifdef REFLECTIONMAP_OPPOSITEZ
reflectionVector.z*=-1.0;
#endif
#ifdef REFLECTIONMAP_3D
reflectionCoords=reflectionVector;
#else
reflectionCoords=reflectionVector.xy;
#ifdef REFLECTIONMAP_PROJECTION
reflectionCoords/=reflectionVector.z;
#endif
reflectionCoords.y=1.0-reflectionCoords.y;
#endif
}
#define pbr_inline
#define inline
void sampleReflectionTexture(
in float alphaG,
in vec3 vReflectionMicrosurfaceInfos,
in vec2 vReflectionInfos,
in vec3 vReflectionColor,
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
in float NdotVUnclamped,
#endif
#ifdef LINEARSPECULARREFLECTION
in float roughness,
#endif
#ifdef REFLECTIONMAP_3D
in samplerCube reflectionSampler,
const vec3 reflectionCoords,
#else
in sampler2D reflectionSampler,
const vec2 reflectionCoords,
#endif
#ifndef LODBASEDMICROSFURACE
#ifdef REFLECTIONMAP_3D
in samplerCube reflectionSamplerLow,
in samplerCube reflectionSamplerHigh,
#else
in sampler2D reflectionSamplerLow,
in sampler2D reflectionSamplerHigh,
#endif
#endif
#ifdef REALTIME_FILTERING
in vec2 vReflectionFilteringInfo,
#endif
out vec4 environmentRadiance
)
{
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);
#elif defined(LINEARSPECULARREFLECTION)
float reflectionLOD=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness);
#else
float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);
#endif
#ifdef LODBASEDMICROSFURACE
reflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;
#ifdef LODINREFLECTIONALPHA
float automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);float requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);
#else
float requestedReflectionLOD=reflectionLOD;
#endif
#ifdef REALTIME_FILTERING
environmentRadiance=vec4(radiance(alphaG,reflectionSampler,reflectionCoords,vReflectionFilteringInfo),1.0);
#else
environmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);
#endif
#else
float lodReflectionNormalized=saturate(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x));float lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;vec4 environmentMid=sampleReflection(reflectionSampler,reflectionCoords);if (lodReflectionNormalizedDoubled<1.0){environmentRadiance=mix(
sampleReflection(reflectionSamplerHigh,reflectionCoords),
environmentMid,
lodReflectionNormalizedDoubled
);} else {environmentRadiance=mix(
environmentMid,
sampleReflection(reflectionSamplerLow,reflectionCoords),
lodReflectionNormalizedDoubled-1.0
);}
#endif
#ifdef RGBDREFLECTION
environmentRadiance.rgb=fromRGBD(environmentRadiance);
#endif
#ifdef GAMMAREFLECTION
environmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);
#endif
environmentRadiance.rgb*=vReflectionInfos.x;environmentRadiance.rgb*=vReflectionColor.rgb;}
#define pbr_inline
#define inline
void reflectionBlock(
in vec3 vPositionW,
in vec3 normalW,
in float alphaG,
in vec3 vReflectionMicrosurfaceInfos,
in vec2 vReflectionInfos,
in vec3 vReflectionColor,
#ifdef ANISOTROPIC
in anisotropicOutParams anisotropicOut,
#endif
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
in float NdotVUnclamped,
#endif
#ifdef LINEARSPECULARREFLECTION
in float roughness,
#endif
#ifdef REFLECTIONMAP_3D
in samplerCube reflectionSampler,
#else
in sampler2D reflectionSampler,
#endif
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
in vec3 vEnvironmentIrradiance,
#endif
#ifdef USESPHERICALFROMREFLECTIONMAP
#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
in mat4 reflectionMatrix,
#endif
#endif
#ifdef USEIRRADIANCEMAP
#ifdef REFLECTIONMAP_3D
in samplerCube irradianceSampler,
#else
in sampler2D irradianceSampler,
#endif
#endif
#ifndef LODBASEDMICROSFURACE
#ifdef REFLECTIONMAP_3D
in samplerCube reflectionSamplerLow,
in samplerCube reflectionSamplerHigh,
#else
in sampler2D reflectionSamplerLow,
in sampler2D reflectionSamplerHigh,
#endif
#endif
#ifdef REALTIME_FILTERING
in vec2 vReflectionFilteringInfo,
#endif
out reflectionOutParams outParams
)
{vec4 environmentRadiance=vec4(0.,0.,0.,0.);
#ifdef REFLECTIONMAP_3D
vec3 reflectionCoords=vec3(0.);
#else
vec2 reflectionCoords=vec2(0.);
#endif
createReflectionCoords(
vPositionW,
normalW,
#ifdef ANISOTROPIC
anisotropicOut,
#endif
reflectionCoords
);sampleReflectionTexture(
alphaG,
vReflectionMicrosurfaceInfos,
vReflectionInfos,
vReflectionColor,
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
NdotVUnclamped,
#endif
#ifdef LINEARSPECULARREFLECTION
roughness,
#endif
#ifdef REFLECTIONMAP_3D
reflectionSampler,
reflectionCoords,
#else
reflectionSampler,
reflectionCoords,
#endif
#ifndef LODBASEDMICROSFURACE
reflectionSamplerLow,
reflectionSamplerHigh,
#endif
#ifdef REALTIME_FILTERING
vReflectionFilteringInfo,
#endif
environmentRadiance
);vec3 environmentIrradiance=vec3(0.,0.,0.);
#ifdef USESPHERICALFROMREFLECTIONMAP
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
environmentIrradiance=vEnvironmentIrradiance;
#else
#ifdef ANISOTROPIC
vec3 irradianceVector=vec3(reflectionMatrix*vec4(anisotropicOut.anisotropicNormal,0)).xyz;
#else
vec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;
#endif
#ifdef REFLECTIONMAP_OPPOSITEZ
irradianceVector.z*=-1.0;
#endif
#ifdef INVERTCUBICMAP
irradianceVector.y*=-1.0;
#endif
#if defined(REALTIME_FILTERING)
environmentIrradiance=irradiance(reflectionSampler,irradianceVector,vReflectionFilteringInfo);
#else
environmentIrradiance=computeEnvironmentIrradiance(irradianceVector);
#endif
#ifdef SS_TRANSLUCENCY
outParams.irradianceVector=irradianceVector;
#endif
#endif
#elif defined(USEIRRADIANCEMAP)
vec4 environmentIrradiance4=sampleReflection(irradianceSampler,reflectionCoords);environmentIrradiance=environmentIrradiance4.rgb;
#ifdef RGBDREFLECTION
environmentIrradiance.rgb=fromRGBD(environmentIrradiance4);
#endif
#ifdef GAMMAREFLECTION
environmentIrradiance.rgb=toLinearSpace(environmentIrradiance.rgb);
#endif
#endif
environmentIrradiance*=vReflectionColor.rgb;outParams.environmentRadiance=environmentRadiance;outParams.environmentIrradiance=environmentIrradiance;outParams.reflectionCoords=reflectionCoords;}
#endif
`, re.IncludesShadersStore.pbrBlockSheen = `#ifdef SHEEN
struct sheenOutParams
{float sheenIntensity;vec3 sheenColor;float sheenRoughness;
#ifdef SHEEN_LINKWITHALBEDO
vec3 surfaceAlbedo;
#endif
#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
float sheenAlbedoScaling;
#endif
#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
vec3 finalSheenRadianceScaled;
#endif
#if DEBUGMODE>0
#ifdef SHEEN_TEXTURE
vec4 sheenMapData;
#endif
#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
vec3 sheenEnvironmentReflectance;
#endif
#endif
};
#define pbr_inline
#define inline
void sheenBlock(
in vec4 vSheenColor,
#ifdef SHEEN_ROUGHNESS
in float vSheenRoughness,
#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
in vec4 sheenMapRoughnessData,
#endif
#endif
in float roughness,
#ifdef SHEEN_TEXTURE
in vec4 sheenMapData,
in float sheenMapLevel,
#endif
in float reflectance,
#ifdef SHEEN_LINKWITHALBEDO
in vec3 baseColor,
in vec3 surfaceAlbedo,
#endif
#ifdef ENVIRONMENTBRDF
in float NdotV,
in vec3 environmentBrdf,
#endif
#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
in vec2 AARoughnessFactors,
in vec3 vReflectionMicrosurfaceInfos,
in vec2 vReflectionInfos,
in vec3 vReflectionColor,
in vec4 vLightingIntensity,
#ifdef REFLECTIONMAP_3D
in samplerCube reflectionSampler,
in vec3 reflectionCoords,
#else
in sampler2D reflectionSampler,
in vec2 reflectionCoords,
#endif
in float NdotVUnclamped,
#ifndef LODBASEDMICROSFURACE
#ifdef REFLECTIONMAP_3D
in samplerCube reflectionSamplerLow,
in samplerCube reflectionSamplerHigh,
#else
in sampler2D reflectionSamplerLow,
in sampler2D reflectionSamplerHigh,
#endif
#endif
#ifdef REALTIME_FILTERING
in vec2 vReflectionFilteringInfo,
#endif
#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
in float seo,
#endif
#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
in float eho,
#endif
#endif
out sheenOutParams outParams
)
{float sheenIntensity=vSheenColor.a;
#ifdef SHEEN_TEXTURE
#if DEBUGMODE>0
outParams.sheenMapData=sheenMapData;
#endif
#endif
#ifdef SHEEN_LINKWITHALBEDO
float sheenFactor=pow5(1.0-sheenIntensity);vec3 sheenColor=baseColor.rgb*(1.0-sheenFactor);float sheenRoughness=sheenIntensity;outParams.surfaceAlbedo=surfaceAlbedo*sheenFactor;
#ifdef SHEEN_TEXTURE
sheenIntensity*=sheenMapData.a;
#endif
#else
vec3 sheenColor=vSheenColor.rgb;
#ifdef SHEEN_TEXTURE
#ifdef SHEEN_GAMMATEXTURE
sheenColor.rgb*=toLinearSpace(sheenMapData.rgb);
#else
sheenColor.rgb*=sheenMapData.rgb;
#endif
sheenColor.rgb*=sheenMapLevel;
#endif
#ifdef SHEEN_ROUGHNESS
float sheenRoughness=vSheenRoughness;
#ifdef SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE
#if defined(SHEEN_TEXTURE)
sheenRoughness*=sheenMapData.a;
#endif
#elif defined(SHEEN_TEXTURE_ROUGHNESS)
#ifdef SHEEN_TEXTURE_ROUGHNESS_IDENTICAL
sheenRoughness*=sheenMapData.a;
#else
sheenRoughness*=sheenMapRoughnessData.a;
#endif
#endif
#else
float sheenRoughness=roughness;
#ifdef SHEEN_TEXTURE
sheenIntensity*=sheenMapData.a;
#endif
#endif
#if !defined(SHEEN_ALBEDOSCALING)
sheenIntensity*=(1.-reflectance);
#endif
sheenColor*=sheenIntensity;
#endif
#ifdef ENVIRONMENTBRDF
/*#ifdef SHEEN_SOFTER
vec3 environmentSheenBrdf=vec3(0.,0.,getBRDFLookupCharlieSheen(NdotV,sheenRoughness));
#else*/
#ifdef SHEEN_ROUGHNESS
vec3 environmentSheenBrdf=getBRDFLookup(NdotV,sheenRoughness);
#else
vec3 environmentSheenBrdf=environmentBrdf;
#endif
/*#endif*/
#endif
#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
float sheenAlphaG=convertRoughnessToAverageSlope(sheenRoughness);
#ifdef SPECULARAA
sheenAlphaG+=AARoughnessFactors.y;
#endif
vec4 environmentSheenRadiance=vec4(0.,0.,0.,0.);sampleReflectionTexture(
sheenAlphaG,
vReflectionMicrosurfaceInfos,
vReflectionInfos,
vReflectionColor,
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
NdotVUnclamped,
#endif
#ifdef LINEARSPECULARREFLECTION
sheenRoughness,
#endif
reflectionSampler,
reflectionCoords,
#ifndef LODBASEDMICROSFURACE
reflectionSamplerLow,
reflectionSamplerHigh,
#endif
#ifdef REALTIME_FILTERING
vReflectionFilteringInfo,
#endif
environmentSheenRadiance
);vec3 sheenEnvironmentReflectance=getSheenReflectanceFromBRDFLookup(sheenColor,environmentSheenBrdf);
#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
sheenEnvironmentReflectance*=seo;
#endif
#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
sheenEnvironmentReflectance*=eho;
#endif
#if DEBUGMODE>0
outParams.sheenEnvironmentReflectance=sheenEnvironmentReflectance;
#endif
outParams.finalSheenRadianceScaled=
environmentSheenRadiance.rgb *
sheenEnvironmentReflectance *
vLightingIntensity.z;
#endif
#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
outParams.sheenAlbedoScaling=1.0-sheenIntensity*max(max(sheenColor.r,sheenColor.g),sheenColor.b)*environmentSheenBrdf.b;
#endif
outParams.sheenIntensity=sheenIntensity;outParams.sheenColor=sheenColor;outParams.sheenRoughness=sheenRoughness;}
#endif
`, re.IncludesShadersStore.pbrBlockClearcoat = `struct clearcoatOutParams
{vec3 specularEnvironmentR0;float conservationFactor;vec3 clearCoatNormalW;vec2 clearCoatAARoughnessFactors;float clearCoatIntensity;float clearCoatRoughness;
#ifdef REFLECTION
vec3 finalClearCoatRadianceScaled;
#endif
#ifdef CLEARCOAT_TINT
vec3 absorption;float clearCoatNdotVRefract;vec3 clearCoatColor;float clearCoatThickness;
#endif
#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
vec3 energyConservationFactorClearCoat;
#endif
#if DEBUGMODE>0
#ifdef CLEARCOAT_BUMP
mat3 TBNClearCoat;
#endif
#ifdef CLEARCOAT_TEXTURE
vec2 clearCoatMapData;
#endif
#if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
vec4 clearCoatTintMapData;
#endif
#ifdef REFLECTION
vec4 environmentClearCoatRadiance;vec3 clearCoatEnvironmentReflectance;
#endif
float clearCoatNdotV;
#endif
};
#ifdef CLEARCOAT
#define pbr_inline
#define inline
void clearcoatBlock(
in vec3 vPositionW,
in vec3 geometricNormalW,
in vec3 viewDirectionW,
in vec2 vClearCoatParams,
#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
in vec4 clearCoatMapRoughnessData,
#endif
in vec3 specularEnvironmentR0,
#ifdef CLEARCOAT_TEXTURE
in vec2 clearCoatMapData,
#endif
#ifdef CLEARCOAT_TINT
in vec4 vClearCoatTintParams,
in float clearCoatColorAtDistance,
in vec4 vClearCoatRefractionParams,
#ifdef CLEARCOAT_TINT_TEXTURE
in vec4 clearCoatTintMapData,
#endif
#endif
#ifdef CLEARCOAT_BUMP
in vec2 vClearCoatBumpInfos,
in vec4 clearCoatBumpMapData,
in vec2 vClearCoatBumpUV,
#if defined(TANGENT) && defined(NORMAL)
in mat3 vTBN,
#else
in vec2 vClearCoatTangentSpaceParams,
#endif
#ifdef OBJECTSPACE_NORMALMAP
in mat4 normalMatrix,
#endif
#endif
#if defined(FORCENORMALFORWARD) && defined(NORMAL)
in vec3 faceNormal,
#endif
#ifdef REFLECTION
in vec3 vReflectionMicrosurfaceInfos,
in vec2 vReflectionInfos,
in vec3 vReflectionColor,
in vec4 vLightingIntensity,
#ifdef REFLECTIONMAP_3D
in samplerCube reflectionSampler,
#else
in sampler2D reflectionSampler,
#endif
#ifndef LODBASEDMICROSFURACE
#ifdef REFLECTIONMAP_3D
in samplerCube reflectionSamplerLow,
in samplerCube reflectionSamplerHigh,
#else
in sampler2D reflectionSamplerLow,
in sampler2D reflectionSamplerHigh,
#endif
#endif
#ifdef REALTIME_FILTERING
in vec2 vReflectionFilteringInfo,
#endif
#endif
#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
#ifdef RADIANCEOCCLUSION
in float ambientMonochrome,
#endif
#endif
#if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
in float frontFacingMultiplier,
#endif
out clearcoatOutParams outParams
)
{float clearCoatIntensity=vClearCoatParams.x;float clearCoatRoughness=vClearCoatParams.y;
#ifdef CLEARCOAT_TEXTURE
clearCoatIntensity*=clearCoatMapData.x;
#ifdef CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE
clearCoatRoughness*=clearCoatMapData.y;
#endif
#if DEBUGMODE>0
outParams.clearCoatMapData=clearCoatMapData;
#endif
#endif
#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
#ifdef CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL
clearCoatRoughness*=clearCoatMapData.y;
#else
clearCoatRoughness*=clearCoatMapRoughnessData.y;
#endif
#endif
outParams.clearCoatIntensity=clearCoatIntensity;outParams.clearCoatRoughness=clearCoatRoughness;
#ifdef CLEARCOAT_TINT
vec3 clearCoatColor=vClearCoatTintParams.rgb;float clearCoatThickness=vClearCoatTintParams.a;
#ifdef CLEARCOAT_TINT_TEXTURE
#ifdef CLEARCOAT_TINT_GAMMATEXTURE
clearCoatColor*=toLinearSpace(clearCoatTintMapData.rgb);
#else
clearCoatColor*=clearCoatTintMapData.rgb;
#endif
clearCoatThickness*=clearCoatTintMapData.a;
#if DEBUGMODE>0
outParams.clearCoatTintMapData=clearCoatTintMapData;
#endif
#endif
outParams.clearCoatColor=computeColorAtDistanceInMedia(clearCoatColor,clearCoatColorAtDistance);outParams.clearCoatThickness=clearCoatThickness;
#endif
#ifdef CLEARCOAT_REMAP_F0
vec3 specularEnvironmentR0Updated=getR0RemappedForClearCoat(specularEnvironmentR0);
#else
vec3 specularEnvironmentR0Updated=specularEnvironmentR0;
#endif
outParams.specularEnvironmentR0=mix(specularEnvironmentR0,specularEnvironmentR0Updated,clearCoatIntensity);vec3 clearCoatNormalW=geometricNormalW;
#ifdef CLEARCOAT_BUMP
#ifdef NORMALXYSCALE
float clearCoatNormalScale=1.0;
#else
float clearCoatNormalScale=vClearCoatBumpInfos.y;
#endif
#if defined(TANGENT) && defined(NORMAL)
mat3 TBNClearCoat=vTBN;
#else
vec2 TBNClearCoatUV=vClearCoatBumpUV*frontFacingMultiplier;mat3 TBNClearCoat=cotangent_frame(clearCoatNormalW*clearCoatNormalScale,vPositionW,TBNClearCoatUV,vClearCoatTangentSpaceParams);
#endif
#if DEBUGMODE>0
outParams.TBNClearCoat=TBNClearCoat;
#endif
#ifdef OBJECTSPACE_NORMALMAP
clearCoatNormalW=normalize(clearCoatBumpMapData.xyz *2.0-1.0);clearCoatNormalW=normalize(mat3(normalMatrix)*clearCoatNormalW);
#else
clearCoatNormalW=perturbNormal(TBNClearCoat,clearCoatBumpMapData.xyz,vClearCoatBumpInfos.y);
#endif
#endif
#if defined(FORCENORMALFORWARD) && defined(NORMAL)
clearCoatNormalW*=sign(dot(clearCoatNormalW,faceNormal));
#endif
#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
clearCoatNormalW=clearCoatNormalW*frontFacingMultiplier;
#endif
outParams.clearCoatNormalW=clearCoatNormalW;outParams.clearCoatAARoughnessFactors=getAARoughnessFactors(clearCoatNormalW.xyz);float clearCoatNdotVUnclamped=dot(clearCoatNormalW,viewDirectionW);float clearCoatNdotV=absEps(clearCoatNdotVUnclamped);
#if DEBUGMODE>0
outParams.clearCoatNdotV=clearCoatNdotV;
#endif
#ifdef CLEARCOAT_TINT
vec3 clearCoatVRefract=refract(-viewDirectionW,clearCoatNormalW,vClearCoatRefractionParams.y);outParams.clearCoatNdotVRefract=absEps(dot(clearCoatNormalW,clearCoatVRefract));
#endif
#if defined(ENVIRONMENTBRDF) && (!defined(REFLECTIONMAP_SKYBOX) || defined(MS_BRDF_ENERGY_CONSERVATION))
vec3 environmentClearCoatBrdf=getBRDFLookup(clearCoatNdotV,clearCoatRoughness);
#endif
#if defined(REFLECTION)
float clearCoatAlphaG=convertRoughnessToAverageSlope(clearCoatRoughness);
#ifdef SPECULARAA
clearCoatAlphaG+=outParams.clearCoatAARoughnessFactors.y;
#endif
vec4 environmentClearCoatRadiance=vec4(0.,0.,0.,0.);vec3 clearCoatReflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),clearCoatNormalW);
#ifdef REFLECTIONMAP_OPPOSITEZ
clearCoatReflectionVector.z*=-1.0;
#endif
#ifdef REFLECTIONMAP_3D
vec3 clearCoatReflectionCoords=clearCoatReflectionVector;
#else
vec2 clearCoatReflectionCoords=clearCoatReflectionVector.xy;
#ifdef REFLECTIONMAP_PROJECTION
clearCoatReflectionCoords/=clearCoatReflectionVector.z;
#endif
clearCoatReflectionCoords.y=1.0-clearCoatReflectionCoords.y;
#endif
sampleReflectionTexture(
clearCoatAlphaG,
vReflectionMicrosurfaceInfos,
vReflectionInfos,
vReflectionColor,
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
clearCoatNdotVUnclamped,
#endif
#ifdef LINEARSPECULARREFLECTION
clearCoatRoughness,
#endif
reflectionSampler,
clearCoatReflectionCoords,
#ifndef LODBASEDMICROSFURACE
reflectionSamplerLow,
reflectionSamplerHigh,
#endif
#ifdef REALTIME_FILTERING
vReflectionFilteringInfo,
#endif
environmentClearCoatRadiance
);
#if DEBUGMODE>0
outParams.environmentClearCoatRadiance=environmentClearCoatRadiance;
#endif
#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
vec3 clearCoatEnvironmentReflectance=getReflectanceFromBRDFLookup(vec3(vClearCoatRefractionParams.x),environmentClearCoatBrdf);
#ifdef HORIZONOCCLUSION
#ifdef BUMP
#ifdef REFLECTIONMAP_3D
float clearCoatEho=environmentHorizonOcclusion(-viewDirectionW,clearCoatNormalW,geometricNormalW);clearCoatEnvironmentReflectance*=clearCoatEho;
#endif
#endif
#endif
#else
vec3 clearCoatEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(clearCoatNdotV,vec3(1.),vec3(1.),sqrt(1.-clearCoatRoughness));
#endif
clearCoatEnvironmentReflectance*=clearCoatIntensity;
#if DEBUGMODE>0
outParams.clearCoatEnvironmentReflectance=clearCoatEnvironmentReflectance;
#endif
outParams.finalClearCoatRadianceScaled=
environmentClearCoatRadiance.rgb *
clearCoatEnvironmentReflectance *
vLightingIntensity.z;
#endif
#if defined(CLEARCOAT_TINT)
outParams.absorption=computeClearCoatAbsorption(outParams.clearCoatNdotVRefract,outParams.clearCoatNdotVRefract,outParams.clearCoatColor,clearCoatThickness,clearCoatIntensity);
#endif
float fresnelIBLClearCoat=fresnelSchlickGGX(clearCoatNdotV,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);fresnelIBLClearCoat*=clearCoatIntensity;outParams.conservationFactor=(1.-fresnelIBLClearCoat);
#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
outParams.energyConservationFactorClearCoat=getEnergyConservationFactor(outParams.specularEnvironmentR0,environmentClearCoatBrdf);
#endif
}
#endif
`, re.IncludesShadersStore.pbrBlockIridescence = `struct iridescenceOutParams
{float iridescenceIntensity;float iridescenceIOR;float iridescenceThickness;vec3 specularEnvironmentR0;};
#ifdef IRIDESCENCE
#define pbr_inline
#define inline
void iridescenceBlock(
in vec4 vIridescenceParams,
in float viewAngle,
in vec3 specularEnvironmentR0,
#ifdef IRIDESCENCE_TEXTURE
in vec2 iridescenceMapData,
#endif
#ifdef IRIDESCENCE_THICKNESS_TEXTURE
in vec2 iridescenceThicknessMapData,
#endif
#ifdef CLEARCOAT
in float NdotVUnclamped,
#ifdef CLEARCOAT_TEXTURE
in vec2 clearCoatMapData,
#endif
#endif
out iridescenceOutParams outParams
)
{float iridescenceIntensity=vIridescenceParams.x;float iridescenceIOR=vIridescenceParams.y;float iridescenceThicknessMin=vIridescenceParams.z;float iridescenceThicknessMax=vIridescenceParams.w;float iridescenceThicknessWeight=1.;
#ifdef IRIDESCENCE_TEXTURE
iridescenceIntensity*=iridescenceMapData.x;
#ifdef IRIDESCENCE_USE_THICKNESS_FROM_MAINTEXTURE
iridescenceThicknessWeight=iridescenceMapData.g;
#endif
#endif
#if defined(IRIDESCENCE_THICKNESS_TEXTURE)
iridescenceThicknessWeight=iridescenceThicknessMapData.g;
#endif
float iridescenceThickness=mix(iridescenceThicknessMin,iridescenceThicknessMax,iridescenceThicknessWeight);float topIor=1.; 
#ifdef CLEARCOAT
float clearCoatIntensity=vClearCoatParams.x;
#ifdef CLEARCOAT_TEXTURE
clearCoatIntensity*=clearCoatMapData.x;
#endif
topIor=mix(1.0,vClearCoatRefractionParams.w-1.,clearCoatIntensity);viewAngle=sqrt(1.0+square(1.0/topIor)*(square(NdotVUnclamped)-1.0));
#endif
vec3 iridescenceFresnel=evalIridescence(topIor,iridescenceIOR,viewAngle,iridescenceThickness,specularEnvironmentR0);outParams.specularEnvironmentR0=mix(specularEnvironmentR0,iridescenceFresnel,iridescenceIntensity);outParams.iridescenceIntensity=iridescenceIntensity;outParams.iridescenceThickness=iridescenceThickness;outParams.iridescenceIOR=iridescenceIOR;}
#endif
`, re.IncludesShadersStore.pbrBlockSubSurface = `struct subSurfaceOutParams
{vec3 specularEnvironmentReflectance;
#ifdef SS_REFRACTION
vec3 finalRefraction;vec3 surfaceAlbedo;
#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
float alpha;
#endif
#ifdef REFLECTION
float refractionFactorForIrradiance;
#endif
#endif
#ifdef SS_TRANSLUCENCY
vec3 transmittance;float translucencyIntensity;
#ifdef REFLECTION
vec3 refractionIrradiance;
#endif
#endif
#if DEBUGMODE>0
#ifdef SS_THICKNESSANDMASK_TEXTURE
vec4 thicknessMap;
#endif
#ifdef SS_REFRACTION
vec4 environmentRefraction;vec3 refractionTransmittance;
#endif
#endif
};
#ifdef SUBSURFACE
#define pbr_inline
#define inline
void subSurfaceBlock(
in vec3 vSubSurfaceIntensity,
in vec2 vThicknessParam,
in vec4 vTintColor,
in vec3 normalW,
in vec3 specularEnvironmentReflectance,
#ifdef SS_THICKNESSANDMASK_TEXTURE
in vec4 thicknessMap,
#endif
#ifdef SS_REFRACTIONINTENSITY_TEXTURE
in vec4 refractionIntensityMap,
#endif
#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
in vec4 translucencyIntensityMap,
#endif
#ifdef REFLECTION
#ifdef SS_TRANSLUCENCY
in mat4 reflectionMatrix,
#ifdef USESPHERICALFROMREFLECTIONMAP
#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
in vec3 irradianceVector_,
#endif
#if defined(REALTIME_FILTERING)
in samplerCube reflectionSampler,
in vec2 vReflectionFilteringInfo,
#endif
#endif
#ifdef USEIRRADIANCEMAP
#ifdef REFLECTIONMAP_3D
in samplerCube irradianceSampler,
#else
in sampler2D irradianceSampler,
#endif
#endif
#endif
#endif
#if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)
in vec3 surfaceAlbedo,
#endif
#ifdef SS_REFRACTION
in vec3 vPositionW,
in vec3 viewDirectionW,
in mat4 view,
in vec4 vRefractionInfos,
in mat4 refractionMatrix,
in vec4 vRefractionMicrosurfaceInfos,
in vec4 vLightingIntensity,
#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
in float alpha,
#endif
#ifdef SS_LODINREFRACTIONALPHA
in float NdotVUnclamped,
#endif
#ifdef SS_LINEARSPECULARREFRACTION
in float roughness,
#endif
in float alphaG,
#ifdef SS_REFRACTIONMAP_3D
in samplerCube refractionSampler,
#ifndef LODBASEDMICROSFURACE
in samplerCube refractionSamplerLow,
in samplerCube refractionSamplerHigh,
#endif
#else
in sampler2D refractionSampler,
#ifndef LODBASEDMICROSFURACE
in sampler2D refractionSamplerLow,
in sampler2D refractionSamplerHigh,
#endif
#endif
#ifdef ANISOTROPIC
in anisotropicOutParams anisotropicOut,
#endif
#ifdef REALTIME_FILTERING
in vec2 vRefractionFilteringInfo,
#endif
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
in vec3 refractionPosition,
in vec3 refractionSize,
#endif
#endif
#ifdef SS_TRANSLUCENCY
in vec3 vDiffusionDistance,
#endif
out subSurfaceOutParams outParams
)
{outParams.specularEnvironmentReflectance=specularEnvironmentReflectance;
#ifdef SS_REFRACTION
float refractionIntensity=vSubSurfaceIntensity.x;
#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
refractionIntensity*=(1.0-alpha);outParams.alpha=1.0;
#endif
#endif
#ifdef SS_TRANSLUCENCY
float translucencyIntensity=vSubSurfaceIntensity.y;
#endif
#ifdef SS_THICKNESSANDMASK_TEXTURE
#if defined(SS_USE_GLTF_TEXTURES)
float thickness=thicknessMap.g*vThicknessParam.y+vThicknessParam.x;
#else
float thickness=thicknessMap.r*vThicknessParam.y+vThicknessParam.x;
#endif
#if DEBUGMODE>0
outParams.thicknessMap=thicknessMap;
#endif
#ifdef SS_MASK_FROM_THICKNESS_TEXTURE
#if defined(SS_REFRACTION) && defined(SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE)
#if defined(SS_USE_GLTF_TEXTURES)
refractionIntensity*=thicknessMap.r;
#else
refractionIntensity*=thicknessMap.g;
#endif
#endif
#if defined(SS_TRANSLUCENCY) && defined(SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE)
translucencyIntensity*=thicknessMap.b;
#endif
#endif
#else
float thickness=vThicknessParam.y;
#endif
#ifdef SS_REFRACTIONINTENSITY_TEXTURE
#ifdef SS_USE_GLTF_TEXTURES
refractionIntensity*=refractionIntensityMap.r;
#else
refractionIntensity*=refractionIntensityMap.g;
#endif
#endif
#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
translucencyIntensity*=translucencyIntensityMap.b;
#endif
#ifdef SS_TRANSLUCENCY
thickness=maxEps(thickness);vec3 transmittance=transmittanceBRDF_Burley(vTintColor.rgb,vDiffusionDistance,thickness);transmittance*=translucencyIntensity;outParams.transmittance=transmittance;outParams.translucencyIntensity=translucencyIntensity;
#endif
#ifdef SS_REFRACTION
vec4 environmentRefraction=vec4(0.,0.,0.,0.);
#ifdef ANISOTROPIC
vec3 refractionVector=refract(-viewDirectionW,anisotropicOut.anisotropicNormal,vRefractionInfos.y);
#else
vec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);
#endif
#ifdef SS_REFRACTIONMAP_OPPOSITEZ
refractionVector.z*=-1.0;
#endif
#ifdef SS_REFRACTIONMAP_3D
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
refractionVector=parallaxCorrectNormal(vPositionW,refractionVector,refractionSize,refractionPosition);
#endif
refractionVector.y=refractionVector.y*vRefractionInfos.w;vec3 refractionCoords=refractionVector;refractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));
#else
#ifdef SS_USE_THICKNESS_AS_DEPTH
vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*thickness,1.0)));
#else
vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));
#endif
vec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;refractionCoords.y=1.0-refractionCoords.y;
#endif
#ifdef SS_HAS_THICKNESS
float ior=vRefractionInfos.y;
#else
float ior=vRefractionMicrosurfaceInfos.w;
#endif
#ifdef SS_LODINREFRACTIONALPHA
float refractionAlphaG=alphaG;refractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));float refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,refractionAlphaG,NdotVUnclamped);
#elif defined(SS_LINEARSPECULARREFRACTION)
float refractionRoughness=alphaG;refractionRoughness=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));float refractionLOD=getLinearLodFromRoughness(vRefractionMicrosurfaceInfos.x,refractionRoughness);
#else
float refractionAlphaG=alphaG;refractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));float refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,refractionAlphaG);
#endif
#ifdef LODBASEDMICROSFURACE
refractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;
#ifdef SS_LODINREFRACTIONALPHA
float automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);float requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);
#else
float requestedRefractionLOD=refractionLOD;
#endif
#if defined(REALTIME_FILTERING) && defined(SS_REFRACTIONMAP_3D)
environmentRefraction=vec4(radiance(alphaG,refractionSampler,refractionCoords,vRefractionFilteringInfo),1.0);
#else
environmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD);
#endif
#else
float lodRefractionNormalized=saturate(refractionLOD/log2(vRefractionMicrosurfaceInfos.x));float lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;vec4 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords);if (lodRefractionNormalizedDoubled<1.0){environmentRefraction=mix(
sampleRefraction(refractionSamplerHigh,refractionCoords),
environmentRefractionMid,
lodRefractionNormalizedDoubled
);} else {environmentRefraction=mix(
environmentRefractionMid,
sampleRefraction(refractionSamplerLow,refractionCoords),
lodRefractionNormalizedDoubled-1.0
);}
#endif
#ifdef SS_RGBDREFRACTION
environmentRefraction.rgb=fromRGBD(environmentRefraction);
#endif
#ifdef SS_GAMMAREFRACTION
environmentRefraction.rgb=toLinearSpace(environmentRefraction.rgb);
#endif
environmentRefraction.rgb*=vRefractionInfos.x;
#endif
#ifdef SS_REFRACTION
vec3 refractionTransmittance=vec3(refractionIntensity);
#ifdef SS_THICKNESSANDMASK_TEXTURE
vec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);refractionTransmittance*=cocaLambert(volumeAlbedo,thickness);
#elif defined(SS_LINKREFRACTIONTOTRANSPARENCY)
float maxChannel=max(max(surfaceAlbedo.r,surfaceAlbedo.g),surfaceAlbedo.b);vec3 volumeAlbedo=saturate(maxChannel*surfaceAlbedo);environmentRefraction.rgb*=volumeAlbedo;
#else
vec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);refractionTransmittance*=cocaLambert(volumeAlbedo,vThicknessParam.y);
#endif
#ifdef SS_ALBEDOFORREFRACTIONTINT
environmentRefraction.rgb*=surfaceAlbedo.rgb;
#endif
outParams.surfaceAlbedo=surfaceAlbedo*(1.-refractionIntensity);
#ifdef REFLECTION
outParams.refractionFactorForIrradiance=(1.-refractionIntensity);
#endif
#ifdef UNUSED_MULTIPLEBOUNCES
vec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);outParams.specularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,refractionIntensity);
#endif
refractionTransmittance*=1.0-outParams.specularEnvironmentReflectance;
#if DEBUGMODE>0
outParams.refractionTransmittance=refractionTransmittance;
#endif
outParams.finalRefraction=environmentRefraction.rgb*refractionTransmittance*vLightingIntensity.z;
#if DEBUGMODE>0
outParams.environmentRefraction=environmentRefraction;
#endif
#endif
#if defined(REFLECTION) && defined(SS_TRANSLUCENCY)
#if defined(NORMAL) && defined(USESPHERICALINVERTEX) || !defined(USESPHERICALFROMREFLECTIONMAP)
vec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;
#ifdef REFLECTIONMAP_OPPOSITEZ
irradianceVector.z*=-1.0;
#endif
#ifdef INVERTCUBICMAP
irradianceVector.y*=-1.0;
#endif
#else
vec3 irradianceVector=irradianceVector_;
#endif
#if defined(USESPHERICALFROMREFLECTIONMAP)
#if defined(REALTIME_FILTERING)
vec3 refractionIrradiance=irradiance(reflectionSampler,-irradianceVector,vReflectionFilteringInfo);
#else
vec3 refractionIrradiance=computeEnvironmentIrradiance(-irradianceVector);
#endif
#elif defined(USEIRRADIANCEMAP)
#ifdef REFLECTIONMAP_3D
vec3 irradianceCoords=irradianceVector;
#else
vec2 irradianceCoords=irradianceVector.xy;
#ifdef REFLECTIONMAP_PROJECTION
irradianceCoords/=irradianceVector.z;
#endif
irradianceCoords.y=1.0-irradianceCoords.y;
#endif
vec4 refractionIrradiance=sampleReflection(irradianceSampler,-irradianceCoords);
#ifdef RGBDREFLECTION
refractionIrradiance.rgb=fromRGBD(refractionIrradiance);
#endif
#ifdef GAMMAREFLECTION
refractionIrradiance.rgb=toLinearSpace(refractionIrradiance.rgb);
#endif
#else
vec4 refractionIrradiance=vec4(0.);
#endif
refractionIrradiance.rgb*=transmittance;
#ifdef SS_ALBEDOFORTRANSLUCENCYTINT
refractionIrradiance.rgb*=surfaceAlbedo.rgb;
#endif
outParams.refractionIrradiance=refractionIrradiance.rgb;
#endif
}
#endif
`, re.IncludesShadersStore.pbrBlockNormalGeometric = `vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);
#ifdef NORMAL
vec3 normalW=normalize(vNormalW);
#else
vec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;
#endif
vec3 geometricNormalW=normalW;
#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
geometricNormalW=gl_FrontFacing ? geometricNormalW : -geometricNormalW;
#endif
`, re.IncludesShadersStore.pbrBlockNormalFinal = `#if defined(FORCENORMALFORWARD) && defined(NORMAL)
vec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;
#if defined(TWOSIDEDLIGHTING)
faceNormal=gl_FrontFacing ? faceNormal : -faceNormal;
#endif
normalW*=sign(dot(normalW,faceNormal));
#endif
#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
normalW=gl_FrontFacing ? normalW : -normalW;
#endif
`, re.IncludesShadersStore.pbrBlockLightmapInit = `#ifdef LIGHTMAP
vec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset);
#ifdef RGBDLIGHTMAP
lightmapColor.rgb=fromRGBD(lightmapColor);
#endif
#ifdef GAMMALIGHTMAP
lightmapColor.rgb=toLinearSpace(lightmapColor.rgb);
#endif
lightmapColor.rgb*=vLightmapInfos.y;
#endif
`, re.IncludesShadersStore.pbrBlockGeometryInfo = `float NdotVUnclamped=dot(normalW,viewDirectionW);float NdotV=absEps(NdotVUnclamped);float alphaG=convertRoughnessToAverageSlope(roughness);vec2 AARoughnessFactors=getAARoughnessFactors(normalW.xyz);
#ifdef SPECULARAA
alphaG+=AARoughnessFactors.y;
#endif
#if defined(ENVIRONMENTBRDF)
vec3 environmentBrdf=getBRDFLookup(NdotV,roughness);
#endif
#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
#ifdef RADIANCEOCCLUSION
#ifdef AMBIENTINGRAYSCALE
float ambientMonochrome=aoOut.ambientOcclusionColor.r;
#else
float ambientMonochrome=getLuminance(aoOut.ambientOcclusionColor);
#endif
float seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);
#endif
#ifdef HORIZONOCCLUSION
#ifdef BUMP
#ifdef REFLECTIONMAP_3D
float eho=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW);
#endif
#endif
#endif
#endif
`, re.IncludesShadersStore.pbrBlockReflectance0 = `float reflectance=max(max(reflectivityOut.surfaceReflectivityColor.r,reflectivityOut.surfaceReflectivityColor.g),reflectivityOut.surfaceReflectivityColor.b);vec3 specularEnvironmentR0=reflectivityOut.surfaceReflectivityColor.rgb;
#ifdef METALLICWORKFLOW
vec3 specularEnvironmentR90=vec3(metallicReflectanceFactors.a);
#else 
vec3 specularEnvironmentR90=vec3(1.0,1.0,1.0);
#endif
#ifdef ALPHAFRESNEL
float reflectance90=fresnelGrazingReflectance(reflectance);specularEnvironmentR90=specularEnvironmentR90*reflectance90;
#endif
`, re.IncludesShadersStore.pbrBlockReflectance = `#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
vec3 specularEnvironmentReflectance=getReflectanceFromBRDFLookup(clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,environmentBrdf);
#ifdef RADIANCEOCCLUSION
specularEnvironmentReflectance*=seo;
#endif
#ifdef HORIZONOCCLUSION
#ifdef BUMP
#ifdef REFLECTIONMAP_3D
specularEnvironmentReflectance*=eho;
#endif
#endif
#endif
#else
vec3 specularEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));
#endif
#ifdef CLEARCOAT
specularEnvironmentReflectance*=clearcoatOut.conservationFactor;
#if defined(CLEARCOAT_TINT)
specularEnvironmentReflectance*=clearcoatOut.absorption;
#endif
#endif
`, re.IncludesShadersStore.pbrBlockDirectLighting = `vec3 diffuseBase=vec3(0.,0.,0.);
#ifdef SPECULARTERM
vec3 specularBase=vec3(0.,0.,0.);
#endif
#ifdef CLEARCOAT
vec3 clearCoatBase=vec3(0.,0.,0.);
#endif
#ifdef SHEEN
vec3 sheenBase=vec3(0.,0.,0.);
#endif
preLightingInfo preInfo;lightingInfo info;float shadow=1.; 
float aggShadow=0.;float numLights=0.;
#if defined(CLEARCOAT) && defined(CLEARCOAT_TINT)
vec3 absorption=vec3(0.);
#endif
`, re.IncludesShadersStore.pbrBlockFinalLitComponents = `aggShadow=aggShadow/numLights;
#if defined(ENVIRONMENTBRDF)
#ifdef MS_BRDF_ENERGY_CONSERVATION
vec3 energyConservationFactor=getEnergyConservationFactor(clearcoatOut.specularEnvironmentR0,environmentBrdf);
#endif
#endif
#ifndef METALLICWORKFLOW
#ifdef SPECULAR_GLOSSINESS_ENERGY_CONSERVATION
surfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;
#endif
#endif
#if defined(SHEEN) && defined(SHEEN_ALBEDOSCALING) && defined(ENVIRONMENTBRDF)
surfaceAlbedo.rgb=sheenOut.sheenAlbedoScaling*surfaceAlbedo.rgb;
#endif
#ifdef REFLECTION
vec3 finalIrradiance=reflectionOut.environmentIrradiance;
#if defined(CLEARCOAT)
finalIrradiance*=clearcoatOut.conservationFactor;
#if defined(CLEARCOAT_TINT)
finalIrradiance*=clearcoatOut.absorption;
#endif
#endif
#if defined(SS_REFRACTION)
finalIrradiance*=subSurfaceOut.refractionFactorForIrradiance;
#endif
#if defined(SS_TRANSLUCENCY)
finalIrradiance*=(1.0-subSurfaceOut.translucencyIntensity);finalIrradiance+=subSurfaceOut.refractionIrradiance;
#endif
finalIrradiance*=surfaceAlbedo.rgb;finalIrradiance*=vLightingIntensity.z;finalIrradiance*=aoOut.ambientOcclusionColor;
#endif
#ifdef SPECULARTERM
vec3 finalSpecular=specularBase;finalSpecular=max(finalSpecular,0.0);vec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;
#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
finalSpecularScaled*=energyConservationFactor;
#endif
#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
finalSpecularScaled*=sheenOut.sheenAlbedoScaling;
#endif
#endif
#ifdef REFLECTION
vec3 finalRadiance=reflectionOut.environmentRadiance.rgb;finalRadiance*=subSurfaceOut.specularEnvironmentReflectance;vec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;
#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
finalRadianceScaled*=energyConservationFactor;
#endif
#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
finalRadianceScaled*=sheenOut.sheenAlbedoScaling;
#endif
#endif
#ifdef SHEEN
vec3 finalSheen=sheenBase*sheenOut.sheenColor;finalSheen=max(finalSheen,0.0);vec3 finalSheenScaled=finalSheen*vLightingIntensity.x*vLightingIntensity.w;
#if defined(CLEARCOAT) && defined(REFLECTION) && defined(ENVIRONMENTBRDF)
sheenOut.finalSheenRadianceScaled*=clearcoatOut.conservationFactor;
#if defined(CLEARCOAT_TINT)
sheenOut.finalSheenRadianceScaled*=clearcoatOut.absorption;
#endif
#endif
#endif
#ifdef CLEARCOAT
vec3 finalClearCoat=clearCoatBase;finalClearCoat=max(finalClearCoat,0.0);vec3 finalClearCoatScaled=finalClearCoat*vLightingIntensity.x*vLightingIntensity.w;
#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
finalClearCoatScaled*=clearcoatOut.energyConservationFactorClearCoat;
#endif
#ifdef SS_REFRACTION
subSurfaceOut.finalRefraction*=clearcoatOut.conservationFactor;
#ifdef CLEARCOAT_TINT
subSurfaceOut.finalRefraction*=clearcoatOut.absorption;
#endif
#endif
#endif
#ifdef ALPHABLEND
float luminanceOverAlpha=0.0;
#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)
luminanceOverAlpha+=getLuminance(finalRadianceScaled);
#if defined(CLEARCOAT)
luminanceOverAlpha+=getLuminance(clearcoatOut.finalClearCoatRadianceScaled);
#endif
#endif
#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)
luminanceOverAlpha+=getLuminance(finalSpecularScaled);
#endif
#if defined(CLEARCOAT) && defined(CLEARCOATOVERALPHA)
luminanceOverAlpha+=getLuminance(finalClearCoatScaled);
#endif
#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA) || defined(CLEARCOATOVERALPHA)
alpha=saturate(alpha+luminanceOverAlpha*luminanceOverAlpha);
#endif
#endif
`, re.IncludesShadersStore.pbrBlockFinalUnlitComponents = `vec3 finalDiffuse=diffuseBase;finalDiffuse*=surfaceAlbedo.rgb;finalDiffuse=max(finalDiffuse,0.0);finalDiffuse*=vLightingIntensity.x;vec3 finalAmbient=vAmbientColor;finalAmbient*=surfaceAlbedo.rgb;vec3 finalEmissive=vEmissiveColor;
#ifdef EMISSIVE
vec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;
#ifdef GAMMAEMISSIVE
finalEmissive*=toLinearSpace(emissiveColorTex.rgb);
#else
finalEmissive*=emissiveColorTex.rgb;
#endif
finalEmissive*= vEmissiveInfos.y;
#endif
finalEmissive*=vLightingIntensity.y;
#ifdef AMBIENT
vec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),aoOut.ambientOcclusionColor,vAmbientInfos.w);
#else
vec3 ambientOcclusionForDirectDiffuse=aoOut.ambientOcclusionColor;
#endif
finalAmbient*=aoOut.ambientOcclusionColor;finalDiffuse*=ambientOcclusionForDirectDiffuse;
`, re.IncludesShadersStore.pbrBlockFinalColorComposition = `vec4 finalColor=vec4(
#ifndef UNLIT
#ifdef REFLECTION
finalIrradiance +
#endif
#ifdef SPECULARTERM
finalSpecularScaled +
#endif
#ifdef SHEEN
finalSheenScaled +
#endif
#ifdef CLEARCOAT
finalClearCoatScaled +
#endif
#ifdef REFLECTION
finalRadianceScaled +
#if defined(SHEEN) && defined(ENVIRONMENTBRDF)
sheenOut.finalSheenRadianceScaled +
#endif
#ifdef CLEARCOAT
clearcoatOut.finalClearCoatRadianceScaled +
#endif
#endif
#ifdef SS_REFRACTION
subSurfaceOut.finalRefraction +
#endif
#endif
finalAmbient +
finalDiffuse,
alpha);
#ifdef LIGHTMAP
#ifndef LIGHTMAPEXCLUDED
#ifdef USELIGHTMAPASSHADOWMAP
finalColor.rgb*=lightmapColor.rgb;
#else
finalColor.rgb+=lightmapColor.rgb;
#endif
#endif
#endif
finalColor.rgb+=finalEmissive;
#define CUSTOM_FRAGMENT_BEFORE_FOG
finalColor=max(finalColor,0.0);
`, re.IncludesShadersStore.pbrBlockImageProcessing = `#if defined(IMAGEPROCESSINGPOSTPROCESS) || defined(SS_SCATTERING)
#if !defined(SKIPFINALCOLORCLAMP)
finalColor.rgb=clamp(finalColor.rgb,0.,30.0);
#endif
#else
finalColor=applyImageProcessing(finalColor);
#endif
finalColor.a*=visibility;
#ifdef PREMULTIPLYALPHA
finalColor.rgb*=finalColor.a;
#endif
`, re.IncludesShadersStore.pbrDebug = `#if DEBUGMODE>0
if (vClipSpacePosition.x/vClipSpacePosition.w>=vDebugMode.x) {
#if DEBUGMODE==1
gl_FragColor.rgb=vPositionW.rgb;
#define DEBUGMODE_NORMALIZE
#elif DEBUGMODE==2 && defined(NORMAL)
gl_FragColor.rgb=vNormalW.rgb;
#define DEBUGMODE_NORMALIZE
#elif DEBUGMODE==3 && defined(BUMP) || DEBUGMODE==3 && defined(PARALLAX) || DEBUGMODE==3 && defined(ANISOTROPIC)
gl_FragColor.rgb=TBN[0];
#define DEBUGMODE_NORMALIZE
#elif DEBUGMODE==4 && defined(BUMP) || DEBUGMODE==4 && defined(PARALLAX) || DEBUGMODE==4 && defined(ANISOTROPIC)
gl_FragColor.rgb=TBN[1];
#define DEBUGMODE_NORMALIZE
#elif DEBUGMODE==5
gl_FragColor.rgb=normalW;
#define DEBUGMODE_NORMALIZE
#elif DEBUGMODE==6 && defined(MAINUV1)
gl_FragColor.rgb=vec3(vMainUV1,0.0);
#elif DEBUGMODE==7 && defined(MAINUV2)
gl_FragColor.rgb=vec3(vMainUV2,0.0);
#elif DEBUGMODE==8 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)
gl_FragColor.rgb=clearcoatOut.TBNClearCoat[0];
#define DEBUGMODE_NORMALIZE
#elif DEBUGMODE==9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)
gl_FragColor.rgb=clearcoatOut.TBNClearCoat[1];
#define DEBUGMODE_NORMALIZE
#elif DEBUGMODE==10 && defined(CLEARCOAT)
gl_FragColor.rgb=clearcoatOut.clearCoatNormalW;
#define DEBUGMODE_NORMALIZE
#elif DEBUGMODE==11 && defined(ANISOTROPIC)
gl_FragColor.rgb=anisotropicOut.anisotropicNormal;
#define DEBUGMODE_NORMALIZE
#elif DEBUGMODE==12 && defined(ANISOTROPIC)
gl_FragColor.rgb=anisotropicOut.anisotropicTangent;
#define DEBUGMODE_NORMALIZE
#elif DEBUGMODE==13 && defined(ANISOTROPIC)
gl_FragColor.rgb=anisotropicOut.anisotropicBitangent;
#define DEBUGMODE_NORMALIZE
#elif DEBUGMODE==20 && defined(ALBEDO)
gl_FragColor.rgb=albedoTexture.rgb;
#ifndef GAMMAALBEDO
#define DEBUGMODE_GAMMA
#endif
#elif DEBUGMODE==21 && defined(AMBIENT)
gl_FragColor.rgb=aoOut.ambientOcclusionColorMap.rgb;
#elif DEBUGMODE==22 && defined(OPACITY)
gl_FragColor.rgb=opacityMap.rgb;
#elif DEBUGMODE==23 && defined(EMISSIVE)
gl_FragColor.rgb=emissiveColorTex.rgb;
#ifndef GAMMAEMISSIVE
#define DEBUGMODE_GAMMA
#endif
#elif DEBUGMODE==24 && defined(LIGHTMAP)
gl_FragColor.rgb=lightmapColor.rgb;
#ifndef GAMMALIGHTMAP
#define DEBUGMODE_GAMMA
#endif
#elif DEBUGMODE==25 && defined(REFLECTIVITY) && defined(METALLICWORKFLOW)
gl_FragColor.rgb=reflectivityOut.surfaceMetallicColorMap.rgb;
#elif DEBUGMODE==26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW)
gl_FragColor.rgb=reflectivityOut.surfaceReflectivityColorMap.rgb;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE==27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE)
gl_FragColor.rgb=vec3(clearcoatOut.clearCoatMapData.rg,0.0);
#elif DEBUGMODE==28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
gl_FragColor.rgb=clearcoatOut.clearCoatTintMapData.rgb;
#elif DEBUGMODE==29 && defined(SHEEN) && defined(SHEEN_TEXTURE)
gl_FragColor.rgb=sheenOut.sheenMapData.rgb;
#elif DEBUGMODE==30 && defined(ANISOTROPIC) && defined(ANISOTROPIC_TEXTURE)
gl_FragColor.rgb=anisotropicOut.anisotropyMapData.rgb;
#elif DEBUGMODE==31 && defined(SUBSURFACE) && defined(SS_THICKNESSANDMASK_TEXTURE)
gl_FragColor.rgb=subSurfaceOut.thicknessMap.rgb;
#elif DEBUGMODE==32 && defined(BUMP)
gl_FragColor.rgb=texture2D(bumpSampler,vBumpUV).rgb;
#elif DEBUGMODE==40 && defined(SS_REFRACTION)
gl_FragColor.rgb=subSurfaceOut.environmentRefraction.rgb;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE==41 && defined(REFLECTION)
gl_FragColor.rgb=reflectionOut.environmentRadiance.rgb;
#ifndef GAMMAREFLECTION
#define DEBUGMODE_GAMMA
#endif
#elif DEBUGMODE==42 && defined(CLEARCOAT) && defined(REFLECTION)
gl_FragColor.rgb=clearcoatOut.environmentClearCoatRadiance.rgb;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE==50
gl_FragColor.rgb=diffuseBase.rgb;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE==51 && defined(SPECULARTERM)
gl_FragColor.rgb=specularBase.rgb;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE==52 && defined(CLEARCOAT)
gl_FragColor.rgb=clearCoatBase.rgb;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE==53 && defined(SHEEN)
gl_FragColor.rgb=sheenBase.rgb;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE==54 && defined(REFLECTION)
gl_FragColor.rgb=reflectionOut.environmentIrradiance.rgb;
#ifndef GAMMAREFLECTION
#define DEBUGMODE_GAMMA
#endif
#elif DEBUGMODE==60
gl_FragColor.rgb=surfaceAlbedo.rgb;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE==61
gl_FragColor.rgb=clearcoatOut.specularEnvironmentR0;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE==62 && defined(METALLICWORKFLOW)
gl_FragColor.rgb=vec3(reflectivityOut.metallicRoughness.r);
#elif DEBUGMODE==71 && defined(METALLICWORKFLOW)
gl_FragColor.rgb=reflectivityOut.metallicF0;
#elif DEBUGMODE==63
gl_FragColor.rgb=vec3(roughness);
#elif DEBUGMODE==64
gl_FragColor.rgb=vec3(alphaG);
#elif DEBUGMODE==65
gl_FragColor.rgb=vec3(NdotV);
#elif DEBUGMODE==66 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT)
gl_FragColor.rgb=clearcoatOut.clearCoatColor.rgb;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE==67 && defined(CLEARCOAT)
gl_FragColor.rgb=vec3(clearcoatOut.clearCoatRoughness);
#elif DEBUGMODE==68 && defined(CLEARCOAT)
gl_FragColor.rgb=vec3(clearcoatOut.clearCoatNdotV);
#elif DEBUGMODE==69 && defined(SUBSURFACE) && defined(SS_TRANSLUCENCY)
gl_FragColor.rgb=subSurfaceOut.transmittance;
#elif DEBUGMODE==70 && defined(SUBSURFACE) && defined(SS_REFRACTION)
gl_FragColor.rgb=subSurfaceOut.refractionTransmittance;
#elif DEBUGMODE==72
gl_FragColor.rgb=vec3(microSurface);
#elif DEBUGMODE==73
gl_FragColor.rgb=vAlbedoColor.rgb;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE==74 && !defined(METALLICWORKFLOW)
gl_FragColor.rgb=vReflectivityColor.rgb;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE==75
gl_FragColor.rgb=vEmissiveColor.rgb;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE==80 && defined(RADIANCEOCCLUSION)
gl_FragColor.rgb=vec3(seo);
#elif DEBUGMODE==81 && defined(HORIZONOCCLUSION)
gl_FragColor.rgb=vec3(eho);
#elif DEBUGMODE==82 && defined(MS_BRDF_ENERGY_CONSERVATION)
gl_FragColor.rgb=vec3(energyConservationFactor);
#elif DEBUGMODE==83 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
gl_FragColor.rgb=specularEnvironmentReflectance;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE==84 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
gl_FragColor.rgb=clearcoatOut.clearCoatEnvironmentReflectance;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE==85 && defined(SHEEN) && defined(REFLECTION)
gl_FragColor.rgb=sheenOut.sheenEnvironmentReflectance;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE==86 && defined(ALPHABLEND)
gl_FragColor.rgb=vec3(luminanceOverAlpha);
#elif DEBUGMODE==87
gl_FragColor.rgb=vec3(alpha);
#elif DEBUGMODE==88 && defined(ALBEDO)
gl_FragColor.rgb=vec3(albedoTexture.a);
#else
float stripeWidth=30.;float stripePos=floor((gl_FragCoord.x+gl_FragCoord.y)/stripeWidth);float whichColor=mod(stripePos,2.);vec3 color1=vec3(.6,.2,.2);vec3 color2=vec3(.3,.1,.1);gl_FragColor.rgb=mix(color1,color2,whichColor);
#endif
gl_FragColor.rgb*=vDebugMode.y;
#ifdef DEBUGMODE_NORMALIZE
gl_FragColor.rgb=normalize(gl_FragColor.rgb)*0.5+0.5;
#endif
#ifdef DEBUGMODE_GAMMA
gl_FragColor.rgb=toGammaSpace(gl_FragColor.rgb);
#endif
gl_FragColor.a=1.0;
#ifdef PREPASS
gl_FragData[0]=toLinearSpace(gl_FragColor); 
gl_FragData[1]=vec4(0.,0.,0.,0.); 
#endif
#ifdef DEBUGMODE_FORCERETURN
return;
#endif
}
#endif
`, re.ShadersStore.pbrPixelShader = `#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)
#extension GL_OES_standard_derivatives : enable
#endif
#ifdef LODBASEDMICROSFURACE
#extension GL_EXT_shader_texture_lod : enable
#endif
#define CUSTOM_FRAGMENT_BEGIN
#ifdef LOGARITHMICDEPTH
#extension GL_EXT_frag_depth : enable
#endif
#include<prePassDeclaration>[SCENE_MRT_COUNT]
precision highp float;
#include<oitDeclaration>
#ifndef FROMLINEARSPACE
#define FROMLINEARSPACE
#endif
#include<__decl__pbrFragment>
#include<pbrFragmentExtraDeclaration>
#include<__decl__lightFragment>[0..maxSimultaneousLights]
#include<pbrFragmentSamplersDeclaration>
#include<imageProcessingDeclaration>
#include<clipPlaneFragmentDeclaration>
#include<logDepthDeclaration>
#include<fogFragmentDeclaration>
#include<helperFunctions>
#include<subSurfaceScatteringFunctions>
#include<importanceSampling>
#include<pbrHelperFunctions>
#include<imageProcessingFunctions>
#include<shadowsFragmentFunctions>
#include<harmonicsFunctions>
#include<pbrDirectLightingSetupFunctions>
#include<pbrDirectLightingFalloffFunctions>
#include<pbrBRDFFunctions>
#include<hdrFilteringFunctions>
#include<pbrDirectLightingFunctions>
#include<pbrIBLFunctions>
#include<bumpFragmentMainFunctions>
#include<bumpFragmentFunctions>
#ifdef REFLECTION
#include<reflectionFunction>
#endif
#define CUSTOM_FRAGMENT_DEFINITIONS
#include<pbrBlockAlbedoOpacity>
#include<pbrBlockReflectivity>
#include<pbrBlockAmbientOcclusion>
#include<pbrBlockAlphaFresnel>
#include<pbrBlockAnisotropic>
#include<pbrBlockReflection>
#include<pbrBlockSheen>
#include<pbrBlockClearcoat>
#include<pbrBlockIridescence>
#include<pbrBlockSubSurface>
void main(void) {
#define CUSTOM_FRAGMENT_MAIN_BEGIN
#include<clipPlaneFragment>
#include<pbrBlockNormalGeometric>
#include<bumpFragment>
#include<pbrBlockNormalFinal>
albedoOpacityOutParams albedoOpacityOut;
#ifdef ALBEDO
vec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);
#endif
#ifdef OPACITY
vec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);
#endif
#ifdef DECAL
vec4 decalColor=texture2D(decalSampler,vDecalUV+uvOffset);
#endif
albedoOpacityBlock(
vAlbedoColor,
#ifdef ALBEDO
albedoTexture,
vAlbedoInfos,
#endif
#ifdef OPACITY
opacityMap,
vOpacityInfos,
#endif
#ifdef DETAIL
detailColor,
vDetailInfos,
#endif
#ifdef DECAL
decalColor,
vDecalInfos,
#endif
albedoOpacityOut
);vec3 surfaceAlbedo=albedoOpacityOut.surfaceAlbedo;float alpha=albedoOpacityOut.alpha;
#define CUSTOM_FRAGMENT_UPDATE_ALPHA
#include<depthPrePass>
#define CUSTOM_FRAGMENT_BEFORE_LIGHTS
ambientOcclusionOutParams aoOut;
#ifdef AMBIENT
vec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb;
#endif
ambientOcclusionBlock(
#ifdef AMBIENT
ambientOcclusionColorMap,
vAmbientInfos,
#endif
aoOut
);
#include<pbrBlockLightmapInit>
#ifdef UNLIT
vec3 diffuseBase=vec3(1.,1.,1.);
#else
vec3 baseColor=surfaceAlbedo;reflectivityOutParams reflectivityOut;
#if defined(REFLECTIVITY)
vec4 surfaceMetallicOrReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);vec4 baseReflectivity=surfaceMetallicOrReflectivityColorMap;
#ifndef METALLICWORKFLOW
#ifdef REFLECTIVITY_GAMMA
surfaceMetallicOrReflectivityColorMap=toLinearSpace(surfaceMetallicOrReflectivityColorMap);
#endif
surfaceMetallicOrReflectivityColorMap.rgb*=vReflectivityInfos.y;
#endif
#endif
#if defined(MICROSURFACEMAP)
vec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;
#endif
#ifdef METALLICWORKFLOW
vec4 metallicReflectanceFactors=vMetallicReflectanceFactors;
#ifdef REFLECTANCE
vec4 reflectanceFactorsMap=texture2D(reflectanceSampler,vReflectanceUV+uvOffset);
#ifdef REFLECTANCE_GAMMA
reflectanceFactorsMap=toLinearSpace(reflectanceFactorsMap);
#endif
metallicReflectanceFactors.rgb*=reflectanceFactorsMap.rgb;
#endif
#ifdef METALLIC_REFLECTANCE
vec4 metallicReflectanceFactorsMap=texture2D(metallicReflectanceSampler,vMetallicReflectanceUV+uvOffset);
#ifdef METALLIC_REFLECTANCE_GAMMA
metallicReflectanceFactorsMap=toLinearSpace(metallicReflectanceFactorsMap);
#endif
#ifndef METALLIC_REFLECTANCE_USE_ALPHA_ONLY
metallicReflectanceFactors.rgb*=metallicReflectanceFactorsMap.rgb;
#endif
metallicReflectanceFactors*=metallicReflectanceFactorsMap.a;
#endif
#endif
reflectivityBlock(
vReflectivityColor,
#ifdef METALLICWORKFLOW
surfaceAlbedo,
metallicReflectanceFactors,
#endif
#ifdef REFLECTIVITY
vReflectivityInfos,
surfaceMetallicOrReflectivityColorMap,
#endif
#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
aoOut.ambientOcclusionColor,
#endif
#ifdef MICROSURFACEMAP
microSurfaceTexel,
#endif
#ifdef DETAIL
detailColor,
vDetailInfos,
#endif
reflectivityOut
);float microSurface=reflectivityOut.microSurface;float roughness=reflectivityOut.roughness;
#ifdef METALLICWORKFLOW
surfaceAlbedo=reflectivityOut.surfaceAlbedo;
#endif
#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
aoOut.ambientOcclusionColor=reflectivityOut.ambientOcclusionColor;
#endif
#ifdef ALPHAFRESNEL
#if defined(ALPHATEST) || defined(ALPHABLEND)
alphaFresnelOutParams alphaFresnelOut;alphaFresnelBlock(
normalW,
viewDirectionW,
alpha,
microSurface,
alphaFresnelOut
);alpha=alphaFresnelOut.alpha;
#endif
#endif
#include<pbrBlockGeometryInfo>
#ifdef ANISOTROPIC
anisotropicOutParams anisotropicOut;
#ifdef ANISOTROPIC_TEXTURE
vec3 anisotropyMapData=texture2D(anisotropySampler,vAnisotropyUV+uvOffset).rgb*vAnisotropyInfos.y;
#endif
anisotropicBlock(
vAnisotropy,
roughness,
#ifdef ANISOTROPIC_TEXTURE
anisotropyMapData,
#endif
TBN,
normalW,
viewDirectionW,
anisotropicOut
);
#endif
#ifdef REFLECTION
reflectionOutParams reflectionOut;
#ifndef USE_CUSTOM_REFLECTION
reflectionBlock(
vPositionW,
normalW,
alphaG,
vReflectionMicrosurfaceInfos,
vReflectionInfos,
vReflectionColor,
#ifdef ANISOTROPIC
anisotropicOut,
#endif
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
NdotVUnclamped,
#endif
#ifdef LINEARSPECULARREFLECTION
roughness,
#endif
reflectionSampler,
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
vEnvironmentIrradiance,
#endif
#ifdef USESPHERICALFROMREFLECTIONMAP
#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
reflectionMatrix,
#endif
#endif
#ifdef USEIRRADIANCEMAP
irradianceSampler,
#endif
#ifndef LODBASEDMICROSFURACE
reflectionSamplerLow,
reflectionSamplerHigh,
#endif
#ifdef REALTIME_FILTERING
vReflectionFilteringInfo,
#endif
reflectionOut
);
#else
#define CUSTOM_REFLECTION
#endif
#endif
#include<pbrBlockReflectance0>
#ifdef SHEEN
sheenOutParams sheenOut;
#ifdef SHEEN_TEXTURE
vec4 sheenMapData=texture2D(sheenSampler,vSheenUV+uvOffset);
#endif
#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
vec4 sheenMapRoughnessData=texture2D(sheenRoughnessSampler,vSheenRoughnessUV+uvOffset)*vSheenInfos.w;
#endif
sheenBlock(
vSheenColor,
#ifdef SHEEN_ROUGHNESS
vSheenRoughness,
#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
sheenMapRoughnessData,
#endif
#endif
roughness,
#ifdef SHEEN_TEXTURE
sheenMapData,
vSheenInfos.y,
#endif
reflectance,
#ifdef SHEEN_LINKWITHALBEDO
baseColor,
surfaceAlbedo,
#endif
#ifdef ENVIRONMENTBRDF
NdotV,
environmentBrdf,
#endif
#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
AARoughnessFactors,
vReflectionMicrosurfaceInfos,
vReflectionInfos,
vReflectionColor,
vLightingIntensity,
reflectionSampler,
reflectionOut.reflectionCoords,
NdotVUnclamped,
#ifndef LODBASEDMICROSFURACE
reflectionSamplerLow,
reflectionSamplerHigh,
#endif
#ifdef REALTIME_FILTERING
vReflectionFilteringInfo,
#endif
#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
seo,
#endif
#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
eho,
#endif
#endif
sheenOut
);
#ifdef SHEEN_LINKWITHALBEDO
surfaceAlbedo=sheenOut.surfaceAlbedo;
#endif
#endif
#ifdef CLEARCOAT
#ifdef CLEARCOAT_TEXTURE
vec2 clearCoatMapData=texture2D(clearCoatSampler,vClearCoatUV+uvOffset).rg*vClearCoatInfos.y;
#endif
#endif
#ifdef IRIDESCENCE
iridescenceOutParams iridescenceOut;
#ifdef IRIDESCENCE_TEXTURE
vec2 iridescenceMapData=texture2D(iridescenceSampler,vIridescenceUV+uvOffset).rg*vIridescenceInfos.y;
#endif
#ifdef IRIDESCENCE_THICKNESS_TEXTURE
vec2 iridescenceThicknessMapData=texture2D(iridescenceThicknessSampler,vIridescenceThicknessUV+uvOffset).rg*vIridescenceInfos.w;
#endif
iridescenceBlock(
vIridescenceParams,
NdotV,
specularEnvironmentR0,
#ifdef IRIDESCENCE_TEXTURE
iridescenceMapData,
#endif
#ifdef IRIDESCENCE_THICKNESS_TEXTURE
iridescenceThicknessMapData,
#endif
#ifdef CLEARCOAT
NdotVUnclamped,
#ifdef CLEARCOAT_TEXTURE
clearCoatMapData,
#endif
#endif
iridescenceOut
);float iridescenceIntensity=iridescenceOut.iridescenceIntensity;specularEnvironmentR0=iridescenceOut.specularEnvironmentR0;
#endif
clearcoatOutParams clearcoatOut;
#ifdef CLEARCOAT
#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
vec4 clearCoatMapRoughnessData=texture2D(clearCoatRoughnessSampler,vClearCoatRoughnessUV+uvOffset)*vClearCoatInfos.w;
#endif
#if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
vec4 clearCoatTintMapData=texture2D(clearCoatTintSampler,vClearCoatTintUV+uvOffset);
#endif
#ifdef CLEARCOAT_BUMP
vec4 clearCoatBumpMapData=texture2D(clearCoatBumpSampler,vClearCoatBumpUV+uvOffset);
#endif
clearcoatBlock(
vPositionW,
geometricNormalW,
viewDirectionW,
vClearCoatParams,
#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
clearCoatMapRoughnessData,
#endif
specularEnvironmentR0,
#ifdef CLEARCOAT_TEXTURE
clearCoatMapData,
#endif
#ifdef CLEARCOAT_TINT
vClearCoatTintParams,
clearCoatColorAtDistance,
vClearCoatRefractionParams,
#ifdef CLEARCOAT_TINT_TEXTURE
clearCoatTintMapData,
#endif
#endif
#ifdef CLEARCOAT_BUMP
vClearCoatBumpInfos,
clearCoatBumpMapData,
vClearCoatBumpUV,
#if defined(TANGENT) && defined(NORMAL)
vTBN,
#else
vClearCoatTangentSpaceParams,
#endif
#ifdef OBJECTSPACE_NORMALMAP
normalMatrix,
#endif
#endif
#if defined(FORCENORMALFORWARD) && defined(NORMAL)
faceNormal,
#endif
#ifdef REFLECTION
vReflectionMicrosurfaceInfos,
vReflectionInfos,
vReflectionColor,
vLightingIntensity,
reflectionSampler,
#ifndef LODBASEDMICROSFURACE
reflectionSamplerLow,
reflectionSamplerHigh,
#endif
#ifdef REALTIME_FILTERING
vReflectionFilteringInfo,
#endif
#endif
#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
#ifdef RADIANCEOCCLUSION
ambientMonochrome,
#endif
#endif
#if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
(gl_FrontFacing ? 1. : -1.),
#endif
clearcoatOut
);
#else
clearcoatOut.specularEnvironmentR0=specularEnvironmentR0;
#endif
#include<pbrBlockReflectance>
subSurfaceOutParams subSurfaceOut;
#ifdef SUBSURFACE
#ifdef SS_THICKNESSANDMASK_TEXTURE
vec4 thicknessMap=texture2D(thicknessSampler,vThicknessUV+uvOffset);
#endif
#ifdef SS_REFRACTIONINTENSITY_TEXTURE
vec4 refractionIntensityMap=texture2D(refractionIntensitySampler,vRefractionIntensityUV+uvOffset);
#endif
#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
vec4 translucencyIntensityMap=texture2D(translucencyIntensitySampler,vTranslucencyIntensityUV+uvOffset);
#endif
subSurfaceBlock(
vSubSurfaceIntensity,
vThicknessParam,
vTintColor,
normalW,
specularEnvironmentReflectance,
#ifdef SS_THICKNESSANDMASK_TEXTURE
thicknessMap,
#endif
#ifdef SS_REFRACTIONINTENSITY_TEXTURE
refractionIntensityMap,
#endif
#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
translucencyIntensityMap,
#endif
#ifdef REFLECTION
#ifdef SS_TRANSLUCENCY
reflectionMatrix,
#ifdef USESPHERICALFROMREFLECTIONMAP
#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
reflectionOut.irradianceVector,
#endif
#if defined(REALTIME_FILTERING)
reflectionSampler,
vReflectionFilteringInfo,
#endif
#endif
#ifdef USEIRRADIANCEMAP
irradianceSampler,
#endif
#endif
#endif
#if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)
surfaceAlbedo,
#endif
#ifdef SS_REFRACTION
vPositionW,
viewDirectionW,
view,
vRefractionInfos,
refractionMatrix,
vRefractionMicrosurfaceInfos,
vLightingIntensity,
#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
alpha,
#endif
#ifdef SS_LODINREFRACTIONALPHA
NdotVUnclamped,
#endif
#ifdef SS_LINEARSPECULARREFRACTION
roughness,
#endif
alphaG,
refractionSampler,
#ifndef LODBASEDMICROSFURACE
refractionSamplerLow,
refractionSamplerHigh,
#endif
#ifdef ANISOTROPIC
anisotropicOut,
#endif
#ifdef REALTIME_FILTERING
vRefractionFilteringInfo,
#endif
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
vRefractionPosition,
vRefractionSize,
#endif
#endif
#ifdef SS_TRANSLUCENCY
vDiffusionDistance,
#endif
subSurfaceOut
);
#ifdef SS_REFRACTION
surfaceAlbedo=subSurfaceOut.surfaceAlbedo;
#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
alpha=subSurfaceOut.alpha;
#endif
#endif
#else
subSurfaceOut.specularEnvironmentReflectance=specularEnvironmentReflectance;
#endif
#include<pbrBlockDirectLighting>
#include<lightFragment>[0..maxSimultaneousLights]
#include<pbrBlockFinalLitComponents>
#endif 
#include<pbrBlockFinalUnlitComponents>
#define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION
#include<pbrBlockFinalColorComposition>
#include<logDepthFragment>
#include<fogFragment>(color,finalColor)
#include<pbrBlockImageProcessing>
#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
#ifdef PREPASS
float writeGeometryInfo=finalColor.a>0.4 ? 1.0 : 0.0;
#ifdef PREPASS_POSITION
gl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo);
#endif
#ifdef PREPASS_VELOCITY
vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;vec2 velocity=abs(a-b);velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;gl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,writeGeometryInfo);
#endif
#ifdef PREPASS_ALBEDO_SQRT
vec3 sqAlbedo=sqrt(surfaceAlbedo); 
#endif
#ifdef PREPASS_IRRADIANCE
vec3 irradiance=finalDiffuse;
#ifndef UNLIT
#ifdef REFLECTION
irradiance+=finalIrradiance;
#endif
#endif
#ifdef SS_SCATTERING
gl_FragData[0]=vec4(finalColor.rgb-irradiance,finalColor.a); 
irradiance/=sqAlbedo;
#else
gl_FragData[0]=finalColor; 
float scatteringDiffusionProfile=255.;
#endif
gl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(clamp(irradiance,vec3(0.),vec3(1.)),writeGeometryInfo*scatteringDiffusionProfile/255.); 
#else
gl_FragData[0]=vec4(finalColor.rgb,finalColor.a);
#endif
#ifdef PREPASS_DEPTH
gl_FragData[PREPASS_DEPTH_INDEX]=vec4(vViewPos.z,0.0,0.0,writeGeometryInfo); 
#endif
#ifdef PREPASS_NORMAL
#ifdef PREPASS_NORMAL_WORLDSPACE
gl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalW,writeGeometryInfo); 
#else
gl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalize((view*vec4(normalW,0.0)).rgb),writeGeometryInfo); 
#endif
#endif
#ifdef PREPASS_ALBEDO_SQRT
gl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(sqAlbedo,writeGeometryInfo); 
#endif
#ifdef PREPASS_REFLECTIVITY
#ifndef UNLIT
gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(specularEnvironmentR0,microSurface)*writeGeometryInfo;
#else
gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4( 0.0,0.0,0.0,1.0 )*writeGeometryInfo;
#endif
#endif
#endif
#if !defined(PREPASS) || defined(WEBGL2)
gl_FragColor=finalColor;
#endif
#include<oitFragment>
#if ORDER_INDEPENDENT_TRANSPARENCY
if (fragDepth==nearestDepth) {frontColor.rgb+=finalColor.rgb*finalColor.a*alphaMultiplier;frontColor.a=1.0-alphaMultiplier*(1.0-finalColor.a);} else {backColor+=finalColor;}
#endif
#include<pbrDebug>
#define CUSTOM_FRAGMENT_MAIN_END
}
`, re.IncludesShadersStore.pbrVertexDeclaration = `uniform mat4 view;uniform mat4 viewProjection;
#ifdef ALBEDO
uniform mat4 albedoMatrix;uniform vec2 vAlbedoInfos;
#endif
#ifdef AMBIENT
uniform mat4 ambientMatrix;uniform vec4 vAmbientInfos;
#endif
#ifdef OPACITY
uniform mat4 opacityMatrix;uniform vec2 vOpacityInfos;
#endif
#ifdef EMISSIVE
uniform vec2 vEmissiveInfos;uniform mat4 emissiveMatrix;
#endif
#ifdef LIGHTMAP
uniform vec2 vLightmapInfos;uniform mat4 lightmapMatrix;
#endif
#ifdef REFLECTIVITY 
uniform vec3 vReflectivityInfos;uniform mat4 reflectivityMatrix;
#endif
#ifdef METALLIC_REFLECTANCE
uniform vec2 vMetallicReflectanceInfos;uniform mat4 metallicReflectanceMatrix;
#endif
#ifdef REFLECTANCE
uniform vec2 vReflectanceInfos;uniform mat4 reflectanceMatrix;
#endif
#ifdef MICROSURFACEMAP
uniform vec2 vMicroSurfaceSamplerInfos;uniform mat4 microSurfaceSamplerMatrix;
#endif
#ifdef BUMP
uniform vec3 vBumpInfos;uniform mat4 bumpMatrix;
#endif
#ifdef POINTSIZE
uniform float pointSize;
#endif
#ifdef REFLECTION
uniform vec2 vReflectionInfos;uniform mat4 reflectionMatrix;
#endif
#ifdef CLEARCOAT
#if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS)
uniform vec4 vClearCoatInfos;
#endif
#ifdef CLEARCOAT_TEXTURE
uniform mat4 clearCoatMatrix;
#endif
#ifdef CLEARCOAT_TEXTURE_ROUGHNESS
uniform mat4 clearCoatRoughnessMatrix;
#endif
#ifdef CLEARCOAT_BUMP
uniform vec2 vClearCoatBumpInfos;uniform mat4 clearCoatBumpMatrix;
#endif
#ifdef CLEARCOAT_TINT_TEXTURE
uniform vec2 vClearCoatTintInfos;uniform mat4 clearCoatTintMatrix;
#endif
#endif
#ifdef IRIDESCENCE
#if defined(IRIDESCENCE_TEXTURE) || defined(IRIDESCENCE_THICKNESS_TEXTURE)
uniform vec4 vIridescenceInfos;
#endif
#ifdef IRIDESCENCE_TEXTURE
uniform mat4 iridescenceMatrix;
#endif
#ifdef IRIDESCENCE_THICKNESS_TEXTURE
uniform mat4 iridescenceThicknessMatrix;
#endif
#endif
#ifdef ANISOTROPIC
#ifdef ANISOTROPIC_TEXTURE
uniform vec2 vAnisotropyInfos;uniform mat4 anisotropyMatrix;
#endif
#endif
#ifdef SHEEN
#if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS)
uniform vec4 vSheenInfos;
#endif
#ifdef SHEEN_TEXTURE
uniform mat4 sheenMatrix;
#endif
#ifdef SHEEN_TEXTURE_ROUGHNESS
uniform mat4 sheenRoughnessMatrix;
#endif
#endif
#ifdef SUBSURFACE
#ifdef SS_REFRACTION
uniform vec4 vRefractionInfos;uniform mat4 refractionMatrix;
#endif
#ifdef SS_THICKNESSANDMASK_TEXTURE
uniform vec2 vThicknessInfos;uniform mat4 thicknessMatrix;
#endif
#ifdef SS_REFRACTIONINTENSITY_TEXTURE
uniform vec2 vRefractionIntensityInfos;uniform mat4 refractionIntensityMatrix;
#endif
#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
uniform vec2 vTranslucencyIntensityInfos;uniform mat4 translucencyIntensityMatrix;
#endif
#endif
#ifdef NORMAL
#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
#ifdef USESPHERICALFROMREFLECTIONMAP
#ifdef SPHERICAL_HARMONICS
uniform vec3 vSphericalL00;uniform vec3 vSphericalL1_1;uniform vec3 vSphericalL10;uniform vec3 vSphericalL11;uniform vec3 vSphericalL2_2;uniform vec3 vSphericalL2_1;uniform vec3 vSphericalL20;uniform vec3 vSphericalL21;uniform vec3 vSphericalL22;
#else
uniform vec3 vSphericalX;uniform vec3 vSphericalY;uniform vec3 vSphericalZ;uniform vec3 vSphericalXX_ZZ;uniform vec3 vSphericalYY_ZZ;uniform vec3 vSphericalZZ;uniform vec3 vSphericalXY;uniform vec3 vSphericalYZ;uniform vec3 vSphericalZX;
#endif
#endif
#endif
#endif
#ifdef DETAIL
uniform vec4 vDetailInfos;uniform mat4 detailMatrix;
#endif
#include<decalVertexDeclaration>
#define ADDITIONAL_VERTEX_DECLARATION
`, re.ShadersStore.pbrVertexShader = `precision highp float;
#include<__decl__pbrVertex>
#define CUSTOM_VERTEX_BEGIN
attribute vec3 position;
#ifdef NORMAL
attribute vec3 normal;
#endif
#ifdef TANGENT
attribute vec4 tangent;
#endif
#ifdef UV1
attribute vec2 uv;
#endif
#include<uvAttributeDeclaration>[2..7]
#include<mainUVVaryingDeclaration>[1..7]
#ifdef VERTEXCOLOR
attribute vec4 color;
#endif
#include<helperFunctions>
#include<bonesDeclaration>
#include<bakedVertexAnimationDeclaration>
#include<instancesDeclaration>
#include<prePassVertexDeclaration>
#include<samplerVertexDeclaration>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo)
#include<samplerVertexDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail)
#include<samplerVertexDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient)
#include<samplerVertexDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity)
#include<samplerVertexDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive)
#include<samplerVertexDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap)
#include<samplerVertexDeclaration>(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity)
#include<samplerVertexDeclaration>(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler)
#include<samplerVertexDeclaration>(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance)
#include<samplerVertexDeclaration>(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance)
#include<samplerVertexDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump)
#include<samplerVertexDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal)
#ifdef CLEARCOAT
#include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat)
#include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness)
#include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump)
#include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint)
#endif
#ifdef IRIDESCENCE
#include<samplerVertexDeclaration>(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence)
#include<samplerVertexDeclaration>(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness)
#endif
#ifdef SHEEN
#include<samplerVertexDeclaration>(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen)
#include<samplerVertexDeclaration>(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness)
#endif
#ifdef ANISOTROPIC
#include<samplerVertexDeclaration>(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy)
#endif
#ifdef SUBSURFACE
#include<samplerVertexDeclaration>(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness)
#include<samplerVertexDeclaration>(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity)
#include<samplerVertexDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity)
#endif
varying vec3 vPositionW;
#if DEBUGMODE>0
varying vec4 vClipSpacePosition;
#endif
#ifdef NORMAL
varying vec3 vNormalW;
#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
varying vec3 vEnvironmentIrradiance;
#include<harmonicsFunctions>
#endif
#endif
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
varying vec4 vColor;
#endif
#include<bumpVertexDeclaration>
#include<clipPlaneVertexDeclaration>
#include<fogVertexDeclaration>
#include<__decl__lightVxFragment>[0..maxSimultaneousLights]
#include<morphTargetsVertexGlobalDeclaration>
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
#ifdef REFLECTIONMAP_SKYBOX
varying vec3 vPositionUVW;
#endif
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
varying vec3 vDirectionW;
#endif
#include<logDepthDeclaration>
#define CUSTOM_VERTEX_DEFINITIONS
void main(void) {
#define CUSTOM_VERTEX_MAIN_BEGIN
vec3 positionUpdated=position;
#ifdef NORMAL
vec3 normalUpdated=normal;
#endif
#ifdef TANGENT
vec4 tangentUpdated=tangent;
#endif
#ifdef UV1
vec2 uvUpdated=uv;
#endif
#include<morphTargetsVertexGlobal>
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
#ifdef REFLECTIONMAP_SKYBOX
vPositionUVW=positionUpdated;
#endif
#define CUSTOM_VERTEX_UPDATE_POSITION
#define CUSTOM_VERTEX_UPDATE_NORMAL
#include<instancesVertex>
#if defined(PREPASS) && defined(PREPASS_VELOCITY) && !defined(BONES_VELOCITY_ENABLED)
vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);
#endif
#include<bonesVertex>
#include<bakedVertexAnimation>
vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);vPositionW=vec3(worldPos);
#include<prePassVertex>
#ifdef NORMAL
mat3 normalWorld=mat3(finalWorld);
#if defined(INSTANCES) && defined(THIN_INSTANCES)
vNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));vNormalW=normalize(normalWorld*vNormalW);
#else
#ifdef NONUNIFORMSCALING
normalWorld=transposeMat3(inverseMat3(normalWorld));
#endif
vNormalW=normalize(normalWorld*normalUpdated);
#endif
#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
vec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;
#ifdef REFLECTIONMAP_OPPOSITEZ
reflectionVector.z*=-1.0;
#endif
vEnvironmentIrradiance=computeEnvironmentIrradiance(reflectionVector);
#endif
#endif
#define CUSTOM_VERTEX_UPDATE_WORLDPOS
#ifdef MULTIVIEW
if (gl_ViewID_OVR==0u) {gl_Position=viewProjection*worldPos;} else {gl_Position=viewProjectionR*worldPos;}
#else
gl_Position=viewProjection*worldPos;
#endif
#if DEBUGMODE>0
vClipSpacePosition=gl_Position;
#endif
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
vDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));
#endif
#ifndef UV1
vec2 uvUpdated=vec2(0.,0.);
#endif
#ifdef MAINUV1
vMainUV1=uvUpdated;
#endif
#include<uvVariableDeclaration>[2..7]
#include<samplerVertexImplementation>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_MATRIXNAME_,albedo,_INFONAME_,AlbedoInfos.x)
#include<samplerVertexImplementation>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x)
#include<samplerVertexImplementation>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_MATRIXNAME_,ambient,_INFONAME_,AmbientInfos.x)
#include<samplerVertexImplementation>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_MATRIXNAME_,opacity,_INFONAME_,OpacityInfos.x)
#include<samplerVertexImplementation>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_MATRIXNAME_,emissive,_INFONAME_,EmissiveInfos.x)
#include<samplerVertexImplementation>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x)
#include<samplerVertexImplementation>(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_MATRIXNAME_,reflectivity,_INFONAME_,ReflectivityInfos.x)
#include<samplerVertexImplementation>(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_MATRIXNAME_,microSurfaceSampler,_INFONAME_,MicroSurfaceSamplerInfos.x)
#include<samplerVertexImplementation>(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_MATRIXNAME_,metallicReflectance,_INFONAME_,MetallicReflectanceInfos.x)
#include<samplerVertexImplementation>(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_MATRIXNAME_,reflectance,_INFONAME_,ReflectanceInfos.x)
#include<samplerVertexImplementation>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_MATRIXNAME_,bump,_INFONAME_,BumpInfos.x)
#include<samplerVertexImplementation>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_MATRIXNAME_,decal,_INFONAME_,DecalInfos.x)
#ifdef CLEARCOAT
#include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_MATRIXNAME_,clearCoat,_INFONAME_,ClearCoatInfos.x)
#include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness,_MATRIXNAME_,clearCoatRoughness,_INFONAME_,ClearCoatInfos.z)
#include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_MATRIXNAME_,clearCoatBump,_INFONAME_,ClearCoatBumpInfos.x)
#include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_MATRIXNAME_,clearCoatTint,_INFONAME_,ClearCoatTintInfos.x)
#endif
#ifdef IRIDESCENCE
#include<samplerVertexImplementation>(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence,_MATRIXNAME_,iridescence,_INFONAME_,IridescenceInfos.x)
#include<samplerVertexImplementation>(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness,_MATRIXNAME_,iridescenceThickness,_INFONAME_,IridescenceInfos.z)
#endif
#ifdef SHEEN
#include<samplerVertexImplementation>(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_MATRIXNAME_,sheen,_INFONAME_,SheenInfos.x)
#include<samplerVertexImplementation>(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness,_MATRIXNAME_,sheen,_INFONAME_,SheenInfos.z)
#endif
#ifdef ANISOTROPIC
#include<samplerVertexImplementation>(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_MATRIXNAME_,anisotropy,_INFONAME_,AnisotropyInfos.x)
#endif
#ifdef SUBSURFACE
#include<samplerVertexImplementation>(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_MATRIXNAME_,thickness,_INFONAME_,ThicknessInfos.x)
#include<samplerVertexImplementation>(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_MATRIXNAME_,refractionIntensity,_INFONAME_,RefractionIntensityInfos.x)
#include<samplerVertexImplementation>(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_MATRIXNAME_,translucencyIntensity,_INFONAME_,TranslucencyIntensityInfos.x)
#endif
#include<bumpVertex>
#include<clipPlaneVertex>
#include<fogVertex>
#include<shadowsVertex>[0..maxSimultaneousLights]
#include<vertexColorMixing>
#if defined(POINTSIZE) && !defined(WEBGPU)
gl_PointSize=pointSize;
#endif
#include<logDepthVertex>
#define CUSTOM_VERTEX_MAIN_END
}`;
    var _y = function(n) {
      function t() {
        var e = n !== null && n.apply(this, arguments) || this;
        return e.CLEARCOAT = !1, e.CLEARCOAT_DEFAULTIOR = !1, e.CLEARCOAT_TEXTURE = !1, e.CLEARCOAT_TEXTURE_ROUGHNESS = !1, e.CLEARCOAT_TEXTUREDIRECTUV = 0, e.CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV = 0, e.CLEARCOAT_BUMP = !1, e.CLEARCOAT_BUMPDIRECTUV = 0, e.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE = !1, e.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL = !1, e.CLEARCOAT_REMAP_F0 = !1, e.CLEARCOAT_TINT = !1, e.CLEARCOAT_TINT_TEXTURE = !1, e.CLEARCOAT_TINT_TEXTUREDIRECTUV = 0, e.CLEARCOAT_TINT_GAMMATEXTURE = !1, e;
      }
      return D(t, n), t;
    }(jn), Kc = function(n) {
      function t(e, i) {
        i === void 0 && (i = !0);
        var r = n.call(this, e, "PBRClearCoat", 100, new _y(), i) || this;
        return r._isEnabled = !1, r.isEnabled = !1, r.intensity = 1, r.roughness = 0, r._indexOfRefraction = t._DefaultIndexOfRefraction, r.indexOfRefraction = t._DefaultIndexOfRefraction, r._texture = null, r.texture = null, r._useRoughnessFromMainTexture = !0, r.useRoughnessFromMainTexture = !0, r._textureRoughness = null, r.textureRoughness = null, r._remapF0OnInterfaceChange = !0, r.remapF0OnInterfaceChange = !0, r._bumpTexture = null, r.bumpTexture = null, r._isTintEnabled = !1, r.isTintEnabled = !1, r.tintColor = ne.White(), r.tintColorAtDistance = 1, r.tintThickness = 1, r._tintTexture = null, r.tintTexture = null, r._internalMarkAllSubMeshesAsTexturesDirty = e._dirtyCallbacks[_.MATERIAL_TextureDirtyFlag], r;
      }
      return D(t, n), t.prototype._markAllSubMeshesAsTexturesDirty = function() {
        this._enable(this._isEnabled), this._internalMarkAllSubMeshesAsTexturesDirty();
      }, t.prototype.isReadyForSubMesh = function(e, i, r) {
        if (!this._isEnabled)
          return !0;
        var o = this._material._disableBumpMap;
        return !(e._areTexturesDirty && i.texturesEnabled && (this._texture && Pe.ClearCoatTextureEnabled && !this._texture.isReadyOrNotBlocking() || this._textureRoughness && Pe.ClearCoatTextureEnabled && !this._textureRoughness.isReadyOrNotBlocking() || r.getCaps().standardDerivatives && this._bumpTexture && Pe.ClearCoatBumpTextureEnabled && !o && !this._bumpTexture.isReady() || this._isTintEnabled && this._tintTexture && Pe.ClearCoatTintTextureEnabled && !this._tintTexture.isReadyOrNotBlocking()));
      }, t.prototype.prepareDefinesBeforeAttributes = function(e, i) {
        var r;
        this._isEnabled ? (e.CLEARCOAT = !0, e.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE = this._useRoughnessFromMainTexture, e.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL = this._texture !== null && this._texture._texture === ((r = this._textureRoughness) === null || r === void 0 ? void 0 : r._texture) && this._texture.checkTransformsAreIdentical(this._textureRoughness), e.CLEARCOAT_REMAP_F0 = this._remapF0OnInterfaceChange, e._areTexturesDirty && i.texturesEnabled && (this._texture && Pe.ClearCoatTextureEnabled ? Se.PrepareDefinesForMergedUV(this._texture, e, "CLEARCOAT_TEXTURE") : e.CLEARCOAT_TEXTURE = !1, this._textureRoughness && Pe.ClearCoatTextureEnabled ? Se.PrepareDefinesForMergedUV(this._textureRoughness, e, "CLEARCOAT_TEXTURE_ROUGHNESS") : e.CLEARCOAT_TEXTURE_ROUGHNESS = !1, this._bumpTexture && Pe.ClearCoatBumpTextureEnabled ? Se.PrepareDefinesForMergedUV(this._bumpTexture, e, "CLEARCOAT_BUMP") : e.CLEARCOAT_BUMP = !1, e.CLEARCOAT_DEFAULTIOR = this._indexOfRefraction === t._DefaultIndexOfRefraction, this._isTintEnabled ? (e.CLEARCOAT_TINT = !0, this._tintTexture && Pe.ClearCoatTintTextureEnabled ? (Se.PrepareDefinesForMergedUV(this._tintTexture, e, "CLEARCOAT_TINT_TEXTURE"), e.CLEARCOAT_TINT_GAMMATEXTURE = this._tintTexture.gammaSpace) : e.CLEARCOAT_TINT_TEXTURE = !1) : (e.CLEARCOAT_TINT = !1, e.CLEARCOAT_TINT_TEXTURE = !1))) : (e.CLEARCOAT = !1, e.CLEARCOAT_TEXTURE = !1, e.CLEARCOAT_TEXTURE_ROUGHNESS = !1, e.CLEARCOAT_BUMP = !1, e.CLEARCOAT_TINT = !1, e.CLEARCOAT_TINT_TEXTURE = !1, e.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE = !1, e.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL = !1, e.CLEARCOAT_DEFAULTIOR = !1, e.CLEARCOAT_TEXTUREDIRECTUV = 0, e.CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV = 0, e.CLEARCOAT_BUMPDIRECTUV = 0, e.CLEARCOAT_REMAP_F0 = !1, e.CLEARCOAT_TINT_TEXTUREDIRECTUV = 0, e.CLEARCOAT_TINT_GAMMATEXTURE = !1);
      }, t.prototype.bindForSubMesh = function(e, i, r, o) {
        var a, s, l, c, u, h, d, p;
        if (this._isEnabled) {
          var f = o.materialDefines, m = this._material.isFrozen, g = this._material._disableBumpMap, y = this._material._invertNormalMapX, b = this._material._invertNormalMapY, T = f.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL;
          if (!e.useUbo || !m || !e.isSync) {
            T && Pe.ClearCoatTextureEnabled ? (e.updateFloat4("vClearCoatInfos", this._texture.coordinatesIndex, this._texture.level, -1, -1), Se.BindTextureMatrix(this._texture, e, "clearCoat")) : (this._texture || this._textureRoughness) && Pe.ClearCoatTextureEnabled && (e.updateFloat4("vClearCoatInfos", (s = (a = this._texture) === null || a === void 0 ? void 0 : a.coordinatesIndex) !== null && s !== void 0 ? s : 0, (c = (l = this._texture) === null || l === void 0 ? void 0 : l.level) !== null && c !== void 0 ? c : 0, (h = (u = this._textureRoughness) === null || u === void 0 ? void 0 : u.coordinatesIndex) !== null && h !== void 0 ? h : 0, (p = (d = this._textureRoughness) === null || d === void 0 ? void 0 : d.level) !== null && p !== void 0 ? p : 0), this._texture && Se.BindTextureMatrix(this._texture, e, "clearCoat"), !this._textureRoughness || T || f.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE || Se.BindTextureMatrix(this._textureRoughness, e, "clearCoatRoughness")), this._bumpTexture && r.getCaps().standardDerivatives && Pe.ClearCoatTextureEnabled && !g && (e.updateFloat2("vClearCoatBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level), Se.BindTextureMatrix(this._bumpTexture, e, "clearCoatBump"), i._mirroredCameraPosition ? e.updateFloat2("vClearCoatTangentSpaceParams", y ? 1 : -1, b ? 1 : -1) : e.updateFloat2("vClearCoatTangentSpaceParams", y ? -1 : 1, b ? -1 : 1)), this._tintTexture && Pe.ClearCoatTintTextureEnabled && (e.updateFloat2("vClearCoatTintInfos", this._tintTexture.coordinatesIndex, this._tintTexture.level), Se.BindTextureMatrix(this._tintTexture, e, "clearCoatTint")), e.updateFloat2("vClearCoatParams", this.intensity, this.roughness);
            var S = 1 - this._indexOfRefraction, E = 1 + this._indexOfRefraction, A = Math.pow(-S / E, 2), R = 1 / this._indexOfRefraction;
            e.updateFloat4("vClearCoatRefractionParams", A, R, S, E), this._isTintEnabled && (e.updateFloat4("vClearCoatTintParams", this.tintColor.r, this.tintColor.g, this.tintColor.b, Math.max(1e-5, this.tintThickness)), e.updateFloat("clearCoatColorAtDistance", Math.max(1e-5, this.tintColorAtDistance)));
          }
          i.texturesEnabled && (this._texture && Pe.ClearCoatTextureEnabled && e.setTexture("clearCoatSampler", this._texture), this._textureRoughness && !T && !f.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE && Pe.ClearCoatTextureEnabled && e.setTexture("clearCoatRoughnessSampler", this._textureRoughness), this._bumpTexture && r.getCaps().standardDerivatives && Pe.ClearCoatBumpTextureEnabled && !g && e.setTexture("clearCoatBumpSampler", this._bumpTexture), this._isTintEnabled && this._tintTexture && Pe.ClearCoatTintTextureEnabled && e.setTexture("clearCoatTintSampler", this._tintTexture));
        }
      }, t.prototype.hasTexture = function(e) {
        return this._texture === e || this._textureRoughness === e || this._bumpTexture === e || this._tintTexture === e;
      }, t.prototype.getActiveTextures = function(e) {
        this._texture && e.push(this._texture), this._textureRoughness && e.push(this._textureRoughness), this._bumpTexture && e.push(this._bumpTexture), this._tintTexture && e.push(this._tintTexture);
      }, t.prototype.getAnimatables = function(e) {
        this._texture && this._texture.animations && this._texture.animations.length > 0 && e.push(this._texture), this._textureRoughness && this._textureRoughness.animations && this._textureRoughness.animations.length > 0 && e.push(this._textureRoughness), this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0 && e.push(this._bumpTexture), this._tintTexture && this._tintTexture.animations && this._tintTexture.animations.length > 0 && e.push(this._tintTexture);
      }, t.prototype.dispose = function(e) {
        var i, r, o, a;
        e && ((i = this._texture) === null || i === void 0 || i.dispose(), (r = this._textureRoughness) === null || r === void 0 || r.dispose(), (o = this._bumpTexture) === null || o === void 0 || o.dispose(), (a = this._tintTexture) === null || a === void 0 || a.dispose());
      }, t.prototype.getClassName = function() {
        return "PBRClearCoatConfiguration";
      }, t.prototype.addFallbacks = function(e, i, r) {
        return e.CLEARCOAT_BUMP && i.addFallback(r++, "CLEARCOAT_BUMP"), e.CLEARCOAT_TINT && i.addFallback(r++, "CLEARCOAT_TINT"), e.CLEARCOAT && i.addFallback(r++, "CLEARCOAT"), r;
      }, t.prototype.getSamplers = function(e) {
        e.push("clearCoatSampler", "clearCoatRoughnessSampler", "clearCoatBumpSampler", "clearCoatTintSampler");
      }, t.prototype.getUniforms = function() {
        return { ubo: [{ name: "vClearCoatParams", size: 2, type: "vec2" }, { name: "vClearCoatRefractionParams", size: 4, type: "vec4" }, { name: "vClearCoatInfos", size: 4, type: "vec4" }, { name: "clearCoatMatrix", size: 16, type: "mat4" }, { name: "clearCoatRoughnessMatrix", size: 16, type: "mat4" }, { name: "vClearCoatBumpInfos", size: 2, type: "vec2" }, { name: "vClearCoatTangentSpaceParams", size: 2, type: "vec2" }, { name: "clearCoatBumpMatrix", size: 16, type: "mat4" }, { name: "vClearCoatTintParams", size: 4, type: "vec4" }, { name: "clearCoatColorAtDistance", size: 1, type: "float" }, { name: "vClearCoatTintInfos", size: 2, type: "vec2" }, { name: "clearCoatTintMatrix", size: 16, type: "mat4" }] };
      }, t._DefaultIndexOfRefraction = 1.5, x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isEnabled", void 0), x([N()], t.prototype, "intensity", void 0), x([N()], t.prototype, "roughness", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "indexOfRefraction", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "texture", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRoughnessFromMainTexture", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "textureRoughness", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "remapF0OnInterfaceChange", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "bumpTexture", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isTintEnabled", void 0), x([ri()], t.prototype, "tintColor", void 0), x([N()], t.prototype, "tintColorAtDistance", void 0), x([N()], t.prototype, "tintThickness", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "tintTexture", void 0), t;
    }($r), my = function(n) {
      function t() {
        var e = n !== null && n.apply(this, arguments) || this;
        return e.IRIDESCENCE = !1, e.IRIDESCENCE_TEXTURE = !1, e.IRIDESCENCE_TEXTUREDIRECTUV = 0, e.IRIDESCENCE_THICKNESS_TEXTURE = !1, e.IRIDESCENCE_THICKNESS_TEXTUREDIRECTUV = 0, e.IRIDESCENCE_USE_THICKNESS_FROM_MAINTEXTURE = !1, e;
      }
      return D(t, n), t;
    }(jn), qc = function(n) {
      function t(e, i) {
        i === void 0 && (i = !0);
        var r = n.call(this, e, "PBRIridescence", 110, new my(), i) || this;
        return r._isEnabled = !1, r.isEnabled = !1, r.intensity = 1, r.minimumThickness = t._DefaultMinimumThickness, r.maximumThickness = t._DefaultMaximumThickness, r.indexOfRefraction = t._DefaultIndexOfRefraction, r._texture = null, r.texture = null, r._thicknessTexture = null, r.thicknessTexture = null, r._internalMarkAllSubMeshesAsTexturesDirty = e._dirtyCallbacks[_.MATERIAL_TextureDirtyFlag], r;
      }
      return D(t, n), t.prototype._markAllSubMeshesAsTexturesDirty = function() {
        this._enable(this._isEnabled), this._internalMarkAllSubMeshesAsTexturesDirty();
      }, t.prototype.isReadyForSubMesh = function(e, i) {
        return this._isEnabled ? !(e._areTexturesDirty && i.texturesEnabled && (this._texture && Pe.IridescenceTextureEnabled && !this._texture.isReadyOrNotBlocking() || this._thicknessTexture && Pe.IridescenceTextureEnabled && !this._thicknessTexture.isReadyOrNotBlocking())) : !0;
      }, t.prototype.prepareDefinesBeforeAttributes = function(e, i) {
        var r;
        this._isEnabled ? (e.IRIDESCENCE = !0, e.IRIDESCENCE_USE_THICKNESS_FROM_MAINTEXTURE = this._texture !== null && this._texture._texture === ((r = this._thicknessTexture) === null || r === void 0 ? void 0 : r._texture) && this._texture.checkTransformsAreIdentical(this._thicknessTexture), e._areTexturesDirty && i.texturesEnabled && (this._texture && Pe.IridescenceTextureEnabled ? Se.PrepareDefinesForMergedUV(this._texture, e, "IRIDESCENCE_TEXTURE") : e.IRIDESCENCE_TEXTURE = !1, !e.IRIDESCENCE_USE_THICKNESS_FROM_MAINTEXTURE && this._thicknessTexture && Pe.IridescenceTextureEnabled ? Se.PrepareDefinesForMergedUV(this._thicknessTexture, e, "IRIDESCENCE_THICKNESS_TEXTURE") : e.IRIDESCENCE_THICKNESS_TEXTURE = !1)) : (e.IRIDESCENCE = !1, e.IRIDESCENCE_TEXTURE = !1, e.IRIDESCENCE_THICKNESS_TEXTURE = !1, e.IRIDESCENCE_USE_THICKNESS_FROM_MAINTEXTURE = !1, e.IRIDESCENCE_TEXTUREDIRECTUV = 0, e.IRIDESCENCE_THICKNESS_TEXTUREDIRECTUV = 0);
      }, t.prototype.bindForSubMesh = function(e, i, r, o) {
        var a, s, l, c, u, h, d, p;
        if (this._isEnabled) {
          var f = o.materialDefines, m = this._material.isFrozen, g = f.IRIDESCENCE_USE_THICKNESS_FROM_MAINTEXTURE;
          e.useUbo && m && e.isSync || (g && Pe.IridescenceTextureEnabled ? (e.updateFloat4("vIridescenceInfos", this._texture.coordinatesIndex, this._texture.level, -1, -1), Se.BindTextureMatrix(this._texture, e, "iridescence")) : (this._texture || this._thicknessTexture) && Pe.IridescenceTextureEnabled && (e.updateFloat4("vIridescenceInfos", (s = (a = this._texture) === null || a === void 0 ? void 0 : a.coordinatesIndex) !== null && s !== void 0 ? s : 0, (c = (l = this._texture) === null || l === void 0 ? void 0 : l.level) !== null && c !== void 0 ? c : 0, (h = (u = this._thicknessTexture) === null || u === void 0 ? void 0 : u.coordinatesIndex) !== null && h !== void 0 ? h : 0, (p = (d = this._thicknessTexture) === null || d === void 0 ? void 0 : d.level) !== null && p !== void 0 ? p : 0), this._texture && Se.BindTextureMatrix(this._texture, e, "iridescence"), !this._thicknessTexture || g || f.IRIDESCENCE_USE_THICKNESS_FROM_MAINTEXTURE || Se.BindTextureMatrix(this._thicknessTexture, e, "iridescenceThickness")), e.updateFloat4("vIridescenceParams", this.intensity, this.indexOfRefraction, this.minimumThickness, this.maximumThickness)), i.texturesEnabled && (this._texture && Pe.IridescenceTextureEnabled && e.setTexture("iridescenceSampler", this._texture), this._thicknessTexture && !g && !f.IRIDESCENCE_USE_THICKNESS_FROM_MAINTEXTURE && Pe.IridescenceTextureEnabled && e.setTexture("iridescenceThicknessSampler", this._thicknessTexture));
        }
      }, t.prototype.hasTexture = function(e) {
        return this._texture === e || this._thicknessTexture === e;
      }, t.prototype.getActiveTextures = function(e) {
        this._texture && e.push(this._texture), this._thicknessTexture && e.push(this._thicknessTexture);
      }, t.prototype.getAnimatables = function(e) {
        this._texture && this._texture.animations && this._texture.animations.length > 0 && e.push(this._texture), this._thicknessTexture && this._thicknessTexture.animations && this._thicknessTexture.animations.length > 0 && e.push(this._thicknessTexture);
      }, t.prototype.dispose = function(e) {
        var i, r;
        e && ((i = this._texture) === null || i === void 0 || i.dispose(), (r = this._thicknessTexture) === null || r === void 0 || r.dispose());
      }, t.prototype.getClassName = function() {
        return "PBRIridescenceConfiguration";
      }, t.prototype.addFallbacks = function(e, i, r) {
        return e.IRIDESCENCE && i.addFallback(r++, "IRIDESCENCE"), r;
      }, t.prototype.getSamplers = function(e) {
        e.push("iridescenceSampler", "iridescenceThicknessSampler");
      }, t.prototype.getUniforms = function() {
        return { ubo: [{ name: "vIridescenceParams", size: 4, type: "vec4" }, { name: "vIridescenceInfos", size: 4, type: "vec4" }, { name: "iridescenceMatrix", size: 16, type: "mat4" }, { name: "iridescenceThicknessMatrix", size: 16, type: "mat4" }] };
      }, t._DefaultMinimumThickness = 100, t._DefaultMaximumThickness = 400, t._DefaultIndexOfRefraction = 1.3, x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isEnabled", void 0), x([N()], t.prototype, "intensity", void 0), x([N()], t.prototype, "minimumThickness", void 0), x([N()], t.prototype, "maximumThickness", void 0), x([N()], t.prototype, "indexOfRefraction", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "texture", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "thicknessTexture", void 0), t;
    }($r), gy = function(n) {
      function t() {
        var e = n !== null && n.apply(this, arguments) || this;
        return e.ANISOTROPIC = !1, e.ANISOTROPIC_TEXTURE = !1, e.ANISOTROPIC_TEXTUREDIRECTUV = 0, e.ANISOTROPIC_LEGACY = !1, e.MAINUV1 = !1, e;
      }
      return D(t, n), t;
    }(jn), s_ = function(n) {
      function t(e, i) {
        i === void 0 && (i = !0);
        var r = n.call(this, e, "PBRAnisotropic", 110, new gy(), i) || this;
        return r._isEnabled = !1, r.isEnabled = !1, r.intensity = 1, r.direction = new fe(1, 0), r._texture = null, r.texture = null, r._legacy = !1, r.legacy = !1, r._internalMarkAllSubMeshesAsTexturesDirty = e._dirtyCallbacks[_.MATERIAL_TextureDirtyFlag], r._internalMarkAllSubMeshesAsMiscDirty = e._dirtyCallbacks[_.MATERIAL_MiscDirtyFlag], r;
      }
      return D(t, n), Object.defineProperty(t.prototype, "angle", { get: function() {
        return Math.atan2(this.direction.y, this.direction.x);
      }, set: function(e) {
        this.direction.x = Math.cos(e), this.direction.y = Math.sin(e);
      }, enumerable: !1, configurable: !0 }), t.prototype._markAllSubMeshesAsTexturesDirty = function() {
        this._enable(this._isEnabled), this._internalMarkAllSubMeshesAsTexturesDirty();
      }, t.prototype._markAllSubMeshesAsMiscDirty = function() {
        this._enable(this._isEnabled), this._internalMarkAllSubMeshesAsMiscDirty();
      }, t.prototype.isReadyForSubMesh = function(e, i) {
        return !this._isEnabled || !(e._areTexturesDirty && i.texturesEnabled && this._texture && Pe.AnisotropicTextureEnabled && !this._texture.isReadyOrNotBlocking());
      }, t.prototype.prepareDefinesBeforeAttributes = function(e, i, r) {
        this._isEnabled ? (e.ANISOTROPIC = this._isEnabled, this._isEnabled && !r.isVerticesDataPresent(P.TangentKind) && (e._needUVs = !0, e.MAINUV1 = !0), e._areTexturesDirty && i.texturesEnabled && (this._texture && Pe.AnisotropicTextureEnabled ? Se.PrepareDefinesForMergedUV(this._texture, e, "ANISOTROPIC_TEXTURE") : e.ANISOTROPIC_TEXTURE = !1), e._areMiscDirty && (e.ANISOTROPIC_LEGACY = this._legacy)) : (e.ANISOTROPIC = !1, e.ANISOTROPIC_TEXTURE = !1, e.ANISOTROPIC_TEXTUREDIRECTUV = 0, e.ANISOTROPIC_LEGACY = !1);
      }, t.prototype.bindForSubMesh = function(e, i) {
        if (this._isEnabled) {
          var r = this._material.isFrozen;
          e.useUbo && r && e.isSync || (this._texture && Pe.AnisotropicTextureEnabled && (e.updateFloat2("vAnisotropyInfos", this._texture.coordinatesIndex, this._texture.level), Se.BindTextureMatrix(this._texture, e, "anisotropy")), e.updateFloat3("vAnisotropy", this.direction.x, this.direction.y, this.intensity)), i.texturesEnabled && this._texture && Pe.AnisotropicTextureEnabled && e.setTexture("anisotropySampler", this._texture);
        }
      }, t.prototype.hasTexture = function(e) {
        return this._texture === e;
      }, t.prototype.getActiveTextures = function(e) {
        this._texture && e.push(this._texture);
      }, t.prototype.getAnimatables = function(e) {
        this._texture && this._texture.animations && this._texture.animations.length > 0 && e.push(this._texture);
      }, t.prototype.dispose = function(e) {
        e && this._texture && this._texture.dispose();
      }, t.prototype.getClassName = function() {
        return "PBRAnisotropicConfiguration";
      }, t.prototype.addFallbacks = function(e, i, r) {
        return e.ANISOTROPIC && i.addFallback(r++, "ANISOTROPIC"), r;
      }, t.prototype.getSamplers = function(e) {
        e.push("anisotropySampler");
      }, t.prototype.getUniforms = function() {
        return { ubo: [{ name: "vAnisotropy", size: 3, type: "vec3" }, { name: "vAnisotropyInfos", size: 2, type: "vec2" }, { name: "anisotropyMatrix", size: 16, type: "mat4" }] };
      }, t.prototype.parse = function(e, i, r) {
        n.prototype.parse.call(this, e, i, r), e.legacy === void 0 && (this.legacy = !0);
      }, x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isEnabled", void 0), x([N()], t.prototype, "intensity", void 0), x([ss()], t.prototype, "direction", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "texture", void 0), x([N(), ye("_markAllSubMeshesAsMiscDirty")], t.prototype, "legacy", void 0), t;
    }($r), vy = function(n) {
      function t() {
        var e = n !== null && n.apply(this, arguments) || this;
        return e.SHEEN = !1, e.SHEEN_TEXTURE = !1, e.SHEEN_GAMMATEXTURE = !1, e.SHEEN_TEXTURE_ROUGHNESS = !1, e.SHEEN_TEXTUREDIRECTUV = 0, e.SHEEN_TEXTURE_ROUGHNESSDIRECTUV = 0, e.SHEEN_LINKWITHALBEDO = !1, e.SHEEN_ROUGHNESS = !1, e.SHEEN_ALBEDOSCALING = !1, e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE = !1, e.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL = !1, e;
      }
      return D(t, n), t;
    }(jn), l_ = function(n) {
      function t(e, i) {
        i === void 0 && (i = !0);
        var r = n.call(this, e, "Sheen", 120, new vy(), i) || this;
        return r._isEnabled = !1, r.isEnabled = !1, r._linkSheenWithAlbedo = !1, r.linkSheenWithAlbedo = !1, r.intensity = 1, r.color = ne.White(), r._texture = null, r.texture = null, r._useRoughnessFromMainTexture = !0, r.useRoughnessFromMainTexture = !0, r._roughness = null, r.roughness = null, r._textureRoughness = null, r.textureRoughness = null, r._albedoScaling = !1, r.albedoScaling = !1, r._internalMarkAllSubMeshesAsTexturesDirty = e._dirtyCallbacks[_.MATERIAL_TextureDirtyFlag], r;
      }
      return D(t, n), t.prototype._markAllSubMeshesAsTexturesDirty = function() {
        this._enable(this._isEnabled), this._internalMarkAllSubMeshesAsTexturesDirty();
      }, t.prototype.isReadyForSubMesh = function(e, i) {
        return this._isEnabled ? !(e._areTexturesDirty && i.texturesEnabled && (this._texture && Pe.SheenTextureEnabled && !this._texture.isReadyOrNotBlocking() || this._textureRoughness && Pe.SheenTextureEnabled && !this._textureRoughness.isReadyOrNotBlocking())) : !0;
      }, t.prototype.prepareDefinesBeforeAttributes = function(e, i) {
        var r;
        this._isEnabled ? (e.SHEEN = !0, e.SHEEN_LINKWITHALBEDO = this._linkSheenWithAlbedo, e.SHEEN_ROUGHNESS = this._roughness !== null, e.SHEEN_ALBEDOSCALING = this._albedoScaling, e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE = this._useRoughnessFromMainTexture, e.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL = this._texture !== null && this._texture._texture === ((r = this._textureRoughness) === null || r === void 0 ? void 0 : r._texture) && this._texture.checkTransformsAreIdentical(this._textureRoughness), e._areTexturesDirty && i.texturesEnabled && (this._texture && Pe.SheenTextureEnabled ? (Se.PrepareDefinesForMergedUV(this._texture, e, "SHEEN_TEXTURE"), e.SHEEN_GAMMATEXTURE = this._texture.gammaSpace) : e.SHEEN_TEXTURE = !1, this._textureRoughness && Pe.SheenTextureEnabled ? Se.PrepareDefinesForMergedUV(this._textureRoughness, e, "SHEEN_TEXTURE_ROUGHNESS") : e.SHEEN_TEXTURE_ROUGHNESS = !1)) : (e.SHEEN = !1, e.SHEEN_TEXTURE = !1, e.SHEEN_TEXTURE_ROUGHNESS = !1, e.SHEEN_LINKWITHALBEDO = !1, e.SHEEN_ROUGHNESS = !1, e.SHEEN_ALBEDOSCALING = !1, e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE = !1, e.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL = !1, e.SHEEN_GAMMATEXTURE = !1, e.SHEEN_TEXTUREDIRECTUV = 0, e.SHEEN_TEXTURE_ROUGHNESSDIRECTUV = 0);
      }, t.prototype.bindForSubMesh = function(e, i, r, o) {
        var a, s, l, c, u, h, d, p;
        if (this._isEnabled) {
          var f = o.materialDefines, m = this._material.isFrozen, g = f.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL;
          e.useUbo && m && e.isSync || (g && Pe.SheenTextureEnabled ? (e.updateFloat4("vSheenInfos", this._texture.coordinatesIndex, this._texture.level, -1, -1), Se.BindTextureMatrix(this._texture, e, "sheen")) : (this._texture || this._textureRoughness) && Pe.SheenTextureEnabled && (e.updateFloat4("vSheenInfos", (s = (a = this._texture) === null || a === void 0 ? void 0 : a.coordinatesIndex) !== null && s !== void 0 ? s : 0, (c = (l = this._texture) === null || l === void 0 ? void 0 : l.level) !== null && c !== void 0 ? c : 0, (h = (u = this._textureRoughness) === null || u === void 0 ? void 0 : u.coordinatesIndex) !== null && h !== void 0 ? h : 0, (p = (d = this._textureRoughness) === null || d === void 0 ? void 0 : d.level) !== null && p !== void 0 ? p : 0), this._texture && Se.BindTextureMatrix(this._texture, e, "sheen"), !this._textureRoughness || g || f.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE || Se.BindTextureMatrix(this._textureRoughness, e, "sheenRoughness")), e.updateFloat4("vSheenColor", this.color.r, this.color.g, this.color.b, this.intensity), this._roughness !== null && e.updateFloat("vSheenRoughness", this._roughness)), i.texturesEnabled && (this._texture && Pe.SheenTextureEnabled && e.setTexture("sheenSampler", this._texture), this._textureRoughness && !g && !f.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE && Pe.SheenTextureEnabled && e.setTexture("sheenRoughnessSampler", this._textureRoughness));
        }
      }, t.prototype.hasTexture = function(e) {
        return this._texture === e || this._textureRoughness === e;
      }, t.prototype.getActiveTextures = function(e) {
        this._texture && e.push(this._texture), this._textureRoughness && e.push(this._textureRoughness);
      }, t.prototype.getAnimatables = function(e) {
        this._texture && this._texture.animations && this._texture.animations.length > 0 && e.push(this._texture), this._textureRoughness && this._textureRoughness.animations && this._textureRoughness.animations.length > 0 && e.push(this._textureRoughness);
      }, t.prototype.dispose = function(e) {
        var i, r;
        e && ((i = this._texture) === null || i === void 0 || i.dispose(), (r = this._textureRoughness) === null || r === void 0 || r.dispose());
      }, t.prototype.getClassName = function() {
        return "PBRSheenConfiguration";
      }, t.prototype.addFallbacks = function(e, i, r) {
        return e.SHEEN && i.addFallback(r++, "SHEEN"), r;
      }, t.prototype.getSamplers = function(e) {
        e.push("sheenSampler", "sheenRoughnessSampler");
      }, t.prototype.getUniforms = function() {
        return { ubo: [{ name: "vSheenColor", size: 4, type: "vec4" }, { name: "vSheenRoughness", size: 1, type: "float" }, { name: "vSheenInfos", size: 4, type: "vec4" }, { name: "sheenMatrix", size: 16, type: "mat4" }, { name: "sheenRoughnessMatrix", size: 16, type: "mat4" }] };
      }, x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isEnabled", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "linkSheenWithAlbedo", void 0), x([N()], t.prototype, "intensity", void 0), x([ri()], t.prototype, "color", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "texture", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRoughnessFromMainTexture", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "roughness", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "textureRoughness", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "albedoScaling", void 0), t;
    }($r), yy = function(n) {
      function t() {
        var e = n !== null && n.apply(this, arguments) || this;
        return e.SUBSURFACE = !1, e.SS_REFRACTION = !1, e.SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE = !1, e.SS_TRANSLUCENCY = !1, e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE = !1, e.SS_SCATTERING = !1, e.SS_THICKNESSANDMASK_TEXTURE = !1, e.SS_THICKNESSANDMASK_TEXTUREDIRECTUV = 0, e.SS_HAS_THICKNESS = !1, e.SS_REFRACTIONINTENSITY_TEXTURE = !1, e.SS_REFRACTIONINTENSITY_TEXTUREDIRECTUV = 0, e.SS_TRANSLUCENCYINTENSITY_TEXTURE = !1, e.SS_TRANSLUCENCYINTENSITY_TEXTUREDIRECTUV = 0, e.SS_REFRACTIONMAP_3D = !1, e.SS_REFRACTIONMAP_OPPOSITEZ = !1, e.SS_LODINREFRACTIONALPHA = !1, e.SS_GAMMAREFRACTION = !1, e.SS_RGBDREFRACTION = !1, e.SS_LINEARSPECULARREFRACTION = !1, e.SS_LINKREFRACTIONTOTRANSPARENCY = !1, e.SS_ALBEDOFORREFRACTIONTINT = !1, e.SS_ALBEDOFORTRANSLUCENCYTINT = !1, e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC = !1, e.SS_USE_THICKNESS_AS_DEPTH = !1, e.SS_MASK_FROM_THICKNESS_TEXTURE = !1, e.SS_USE_GLTF_TEXTURES = !1, e;
      }
      return D(t, n), t;
    }(jn), c_ = function(n) {
      function t(e, i) {
        i === void 0 && (i = !0);
        var r = n.call(this, e, "PBRSubSurface", 130, new yy(), i) || this;
        return r._isRefractionEnabled = !1, r.isRefractionEnabled = !1, r._isTranslucencyEnabled = !1, r.isTranslucencyEnabled = !1, r._isScatteringEnabled = !1, r.isScatteringEnabled = !1, r._scatteringDiffusionProfileIndex = 0, r.refractionIntensity = 1, r.translucencyIntensity = 1, r.useAlbedoToTintRefraction = !1, r.useAlbedoToTintTranslucency = !1, r._thicknessTexture = null, r.thicknessTexture = null, r._refractionTexture = null, r.refractionTexture = null, r._indexOfRefraction = 1.5, r.indexOfRefraction = 1.5, r._volumeIndexOfRefraction = -1, r._invertRefractionY = !1, r.invertRefractionY = !1, r._linkRefractionWithTransparency = !1, r.linkRefractionWithTransparency = !1, r.minimumThickness = 0, r.maximumThickness = 1, r.useThicknessAsDepth = !1, r.tintColor = ne.White(), r.tintColorAtDistance = 1, r.diffusionDistance = ne.White(), r._useMaskFromThicknessTexture = !1, r.useMaskFromThicknessTexture = !1, r._refractionIntensityTexture = null, r.refractionIntensityTexture = null, r._translucencyIntensityTexture = null, r.translucencyIntensityTexture = null, r._useGltfStyleTextures = !1, r.useGltfStyleTextures = !1, r._scene = e.getScene(), r.registerForExtraEvents = !0, r._internalMarkAllSubMeshesAsTexturesDirty = e._dirtyCallbacks[_.MATERIAL_TextureDirtyFlag], r._internalMarkScenePrePassDirty = e._dirtyCallbacks[_.MATERIAL_PrePassDirtyFlag], r;
      }
      return D(t, n), Object.defineProperty(t.prototype, "scatteringDiffusionProfile", { get: function() {
        return this._scene.subSurfaceConfiguration ? this._scene.subSurfaceConfiguration.ssDiffusionProfileColors[this._scatteringDiffusionProfileIndex] : null;
      }, set: function(e) {
        this._scene.enableSubSurfaceForPrePass() && e && (this._scatteringDiffusionProfileIndex = this._scene.subSurfaceConfiguration.addDiffusionProfile(e));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "volumeIndexOfRefraction", { get: function() {
        return this._volumeIndexOfRefraction >= 1 ? this._volumeIndexOfRefraction : this._indexOfRefraction;
      }, set: function(e) {
        this._volumeIndexOfRefraction = e >= 1 ? e : -1;
      }, enumerable: !1, configurable: !0 }), t.prototype._markAllSubMeshesAsTexturesDirty = function() {
        this._enable(this._isRefractionEnabled || this._isTranslucencyEnabled || this._isScatteringEnabled), this._internalMarkAllSubMeshesAsTexturesDirty();
      }, t.prototype._markScenePrePassDirty = function() {
        this._internalMarkAllSubMeshesAsTexturesDirty(), this._internalMarkScenePrePassDirty();
      }, t.prototype.isReadyForSubMesh = function(e, i) {
        if (!this._isRefractionEnabled && !this._isTranslucencyEnabled && !this._isScatteringEnabled)
          return !0;
        if (e._areTexturesDirty && i.texturesEnabled) {
          if (this._thicknessTexture && Pe.ThicknessTextureEnabled && !this._thicknessTexture.isReadyOrNotBlocking())
            return !1;
          var r = this._getRefractionTexture(i);
          if (r && Pe.RefractionTextureEnabled && !r.isReadyOrNotBlocking())
            return !1;
        }
        return !0;
      }, t.prototype.prepareDefinesBeforeAttributes = function(e, i) {
        if (!this._isRefractionEnabled && !this._isTranslucencyEnabled && !this._isScatteringEnabled)
          return e.SUBSURFACE = !1, e.SS_TRANSLUCENCY = !1, e.SS_SCATTERING = !1, e.SS_REFRACTION = !1, e.SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE = !1, e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE = !1, e.SS_THICKNESSANDMASK_TEXTURE = !1, e.SS_THICKNESSANDMASK_TEXTUREDIRECTUV = 0, e.SS_HAS_THICKNESS = !1, e.SS_REFRACTIONINTENSITY_TEXTURE = !1, e.SS_REFRACTIONINTENSITY_TEXTUREDIRECTUV = 0, e.SS_TRANSLUCENCYINTENSITY_TEXTURE = !1, e.SS_TRANSLUCENCYINTENSITY_TEXTUREDIRECTUV = 0, e.SS_REFRACTIONMAP_3D = !1, e.SS_REFRACTIONMAP_OPPOSITEZ = !1, e.SS_LODINREFRACTIONALPHA = !1, e.SS_GAMMAREFRACTION = !1, e.SS_RGBDREFRACTION = !1, e.SS_LINEARSPECULARREFRACTION = !1, e.SS_LINKREFRACTIONTOTRANSPARENCY = !1, e.SS_ALBEDOFORREFRACTIONTINT = !1, e.SS_ALBEDOFORTRANSLUCENCYTINT = !1, e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC = !1, e.SS_USE_THICKNESS_AS_DEPTH = !1, e.SS_MASK_FROM_THICKNESS_TEXTURE = !1, void (e.SS_USE_GLTF_TEXTURES = !1);
        if (e._areTexturesDirty) {
          e.SUBSURFACE = !0, e.SS_TRANSLUCENCY = this._isTranslucencyEnabled, e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE = !1, e.SS_SCATTERING = this._isScatteringEnabled, e.SS_THICKNESSANDMASK_TEXTURE = !1, e.SS_REFRACTIONINTENSITY_TEXTURE = !1, e.SS_TRANSLUCENCYINTENSITY_TEXTURE = !1, e.SS_HAS_THICKNESS = !1, e.SS_MASK_FROM_THICKNESS_TEXTURE = !1, e.SS_USE_GLTF_TEXTURES = !1, e.SS_REFRACTION = !1, e.SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE = !1, e.SS_REFRACTIONMAP_3D = !1, e.SS_GAMMAREFRACTION = !1, e.SS_RGBDREFRACTION = !1, e.SS_LINEARSPECULARREFRACTION = !1, e.SS_REFRACTIONMAP_OPPOSITEZ = !1, e.SS_LODINREFRACTIONALPHA = !1, e.SS_LINKREFRACTIONTOTRANSPARENCY = !1, e.SS_ALBEDOFORREFRACTIONTINT = !1, e.SS_ALBEDOFORTRANSLUCENCYTINT = !1, e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC = !1, e.SS_USE_THICKNESS_AS_DEPTH = !1;
          var r = !!this._thicknessTexture && !!this._refractionIntensityTexture && this._refractionIntensityTexture.checkTransformsAreIdentical(this._thicknessTexture) && this._refractionIntensityTexture._texture === this._thicknessTexture._texture, o = !!this._thicknessTexture && !!this._translucencyIntensityTexture && this._translucencyIntensityTexture.checkTransformsAreIdentical(this._thicknessTexture) && this._translucencyIntensityTexture._texture === this._thicknessTexture._texture, a = (r || !this._refractionIntensityTexture) && (o || !this._translucencyIntensityTexture);
          if (e._areTexturesDirty && i.texturesEnabled && (this._thicknessTexture && Pe.ThicknessTextureEnabled && Se.PrepareDefinesForMergedUV(this._thicknessTexture, e, "SS_THICKNESSANDMASK_TEXTURE"), this._refractionIntensityTexture && Pe.RefractionIntensityTextureEnabled && !a && Se.PrepareDefinesForMergedUV(this._refractionIntensityTexture, e, "SS_REFRACTIONINTENSITY_TEXTURE"), this._translucencyIntensityTexture && Pe.TranslucencyIntensityTextureEnabled && !a && Se.PrepareDefinesForMergedUV(this._translucencyIntensityTexture, e, "SS_TRANSLUCENCYINTENSITY_TEXTURE")), e.SS_HAS_THICKNESS = this.maximumThickness - this.minimumThickness != 0, e.SS_MASK_FROM_THICKNESS_TEXTURE = (this._useMaskFromThicknessTexture || !!this._refractionIntensityTexture || !!this._translucencyIntensityTexture) && a, e.SS_USE_GLTF_TEXTURES = this._useGltfStyleTextures, e.SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE = (this._useMaskFromThicknessTexture || !!this._refractionIntensityTexture) && a, e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE = (this._useMaskFromThicknessTexture || !!this._translucencyIntensityTexture) && a, this._isRefractionEnabled && i.texturesEnabled) {
            var s = this._getRefractionTexture(i);
            s && Pe.RefractionTextureEnabled && (e.SS_REFRACTION = !0, e.SS_REFRACTIONMAP_3D = s.isCube, e.SS_GAMMAREFRACTION = s.gammaSpace, e.SS_RGBDREFRACTION = s.isRGBD, e.SS_LINEARSPECULARREFRACTION = s.linearSpecularLOD, e.SS_REFRACTIONMAP_OPPOSITEZ = this._scene.useRightHandedSystem && s.isCube ? !s.invertZ : s.invertZ, e.SS_LODINREFRACTIONALPHA = s.lodLevelInAlpha, e.SS_LINKREFRACTIONTOTRANSPARENCY = this._linkRefractionWithTransparency, e.SS_ALBEDOFORREFRACTIONTINT = this.useAlbedoToTintRefraction, e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC = s.isCube && s.boundingBoxSize, e.SS_USE_THICKNESS_AS_DEPTH = this.useThicknessAsDepth);
          }
          this._isTranslucencyEnabled && (e.SS_ALBEDOFORTRANSLUCENCYTINT = this.useAlbedoToTintTranslucency);
        }
      }, t.prototype.hardBindForSubMesh = function(e, i, r, o) {
        if (this._isRefractionEnabled || this._isTranslucencyEnabled || this._isScatteringEnabled) {
          o.getRenderingMesh().getWorldMatrix().decompose(F.Vector3[0]);
          var a = Math.max(Math.abs(F.Vector3[0].x), Math.abs(F.Vector3[0].y), Math.abs(F.Vector3[0].z));
          e.updateFloat2("vThicknessParam", this.minimumThickness * a, (this.maximumThickness - this.minimumThickness) * a);
        }
      }, t.prototype.bindForSubMesh = function(e, i, r, o) {
        if (this._isRefractionEnabled || this._isTranslucencyEnabled || this._isScatteringEnabled) {
          var a = o.materialDefines, s = this._material.isFrozen, l = this._material.realTimeFiltering, c = a.LODBASEDMICROSFURACE, u = this._getRefractionTexture(i);
          if (!e.useUbo || !s || !e.isSync) {
            if (this._thicknessTexture && Pe.ThicknessTextureEnabled && (e.updateFloat2("vThicknessInfos", this._thicknessTexture.coordinatesIndex, this._thicknessTexture.level), Se.BindTextureMatrix(this._thicknessTexture, e, "thickness")), this._refractionIntensityTexture && Pe.RefractionIntensityTextureEnabled && a.SS_REFRACTIONINTENSITY_TEXTURE && (e.updateFloat2("vRefractionIntensityInfos", this._refractionIntensityTexture.coordinatesIndex, this._refractionIntensityTexture.level), Se.BindTextureMatrix(this._refractionIntensityTexture, e, "refractionIntensity")), this._translucencyIntensityTexture && Pe.TranslucencyIntensityTextureEnabled && a.SS_TRANSLUCENCYINTENSITY_TEXTURE && (e.updateFloat2("vTranslucencyIntensityInfos", this._translucencyIntensityTexture.coordinatesIndex, this._translucencyIntensityTexture.level), Se.BindTextureMatrix(this._translucencyIntensityTexture, e, "translucencyIntensity")), u && Pe.RefractionTextureEnabled) {
              e.updateMatrix("refractionMatrix", u.getRefractionTextureMatrix());
              var h = 1;
              u.isCube || u.depth && (h = u.depth);
              var d = u.getSize().width, p = this.volumeIndexOfRefraction;
              if (e.updateFloat4("vRefractionInfos", u.level, 1 / p, h, this._invertRefractionY ? -1 : 1), e.updateFloat4("vRefractionMicrosurfaceInfos", d, u.lodGenerationScale, u.lodGenerationOffset, 1 / this.indexOfRefraction), l && e.updateFloat2("vRefractionFilteringInfo", d, ue.Log2(d)), u.boundingBoxSize) {
                var f = u;
                e.updateVector3("vRefractionPosition", f.boundingBoxPosition), e.updateVector3("vRefractionSize", f.boundingBoxSize);
              }
            }
            this._isScatteringEnabled && e.updateFloat("scatteringDiffusionProfile", this._scatteringDiffusionProfileIndex), e.updateColor3("vDiffusionDistance", this.diffusionDistance), e.updateFloat4("vTintColor", this.tintColor.r, this.tintColor.g, this.tintColor.b, Math.max(1e-5, this.tintColorAtDistance)), e.updateFloat3("vSubSurfaceIntensity", this.refractionIntensity, this.translucencyIntensity, 0);
          }
          i.texturesEnabled && (this._thicknessTexture && Pe.ThicknessTextureEnabled && e.setTexture("thicknessSampler", this._thicknessTexture), this._refractionIntensityTexture && Pe.RefractionIntensityTextureEnabled && a.SS_REFRACTIONINTENSITY_TEXTURE && e.setTexture("refractionIntensitySampler", this._refractionIntensityTexture), this._translucencyIntensityTexture && Pe.TranslucencyIntensityTextureEnabled && a.SS_TRANSLUCENCYINTENSITY_TEXTURE && e.setTexture("translucencyIntensitySampler", this._translucencyIntensityTexture), u && Pe.RefractionTextureEnabled && (c ? e.setTexture("refractionSampler", u) : (e.setTexture("refractionSampler", u._lodTextureMid || u), e.setTexture("refractionSamplerLow", u._lodTextureLow || u), e.setTexture("refractionSamplerHigh", u._lodTextureHigh || u))));
        }
      }, t.prototype._getRefractionTexture = function(e) {
        return this._refractionTexture ? this._refractionTexture : this._isRefractionEnabled ? e.environmentTexture : null;
      }, Object.defineProperty(t.prototype, "disableAlphaBlending", { get: function() {
        return this._isRefractionEnabled && this._linkRefractionWithTransparency;
      }, enumerable: !1, configurable: !0 }), t.prototype.fillRenderTargetTextures = function(e) {
        Pe.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget && e.push(this._refractionTexture);
      }, t.prototype.hasTexture = function(e) {
        return this._thicknessTexture === e || this._refractionTexture === e;
      }, t.prototype.hasRenderTargetTextures = function() {
        return !!(Pe.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget);
      }, t.prototype.getActiveTextures = function(e) {
        this._thicknessTexture && e.push(this._thicknessTexture), this._refractionTexture && e.push(this._refractionTexture);
      }, t.prototype.getAnimatables = function(e) {
        this._thicknessTexture && this._thicknessTexture.animations && this._thicknessTexture.animations.length > 0 && e.push(this._thicknessTexture), this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0 && e.push(this._refractionTexture);
      }, t.prototype.dispose = function(e) {
        e && (this._thicknessTexture && this._thicknessTexture.dispose(), this._refractionTexture && this._refractionTexture.dispose());
      }, t.prototype.getClassName = function() {
        return "PBRSubSurfaceConfiguration";
      }, t.prototype.addFallbacks = function(e, i, r) {
        return e.SS_SCATTERING && i.addFallback(r++, "SS_SCATTERING"), e.SS_TRANSLUCENCY && i.addFallback(r++, "SS_TRANSLUCENCY"), r;
      }, t.prototype.getSamplers = function(e) {
        e.push("thicknessSampler", "refractionIntensitySampler", "translucencyIntensitySampler", "refractionSampler", "refractionSamplerLow", "refractionSamplerHigh");
      }, t.prototype.getUniforms = function() {
        return { ubo: [{ name: "vRefractionMicrosurfaceInfos", size: 4, type: "vec4" }, { name: "vRefractionFilteringInfo", size: 2, type: "vec2" }, { name: "vTranslucencyIntensityInfos", size: 2, type: "vec2" }, { name: "vRefractionInfos", size: 4, type: "vec4" }, { name: "refractionMatrix", size: 16, type: "mat4" }, { name: "vThicknessInfos", size: 2, type: "vec2" }, { name: "vRefractionIntensityInfos", size: 2, type: "vec2" }, { name: "thicknessMatrix", size: 16, type: "mat4" }, { name: "refractionIntensityMatrix", size: 16, type: "mat4" }, { name: "translucencyIntensityMatrix", size: 16, type: "mat4" }, { name: "vThicknessParam", size: 2, type: "vec2" }, { name: "vDiffusionDistance", size: 3, type: "vec3" }, { name: "vTintColor", size: 4, type: "vec4" }, { name: "vSubSurfaceIntensity", size: 3, type: "vec3" }, { name: "vRefractionPosition", size: 3, type: "vec3" }, { name: "vRefractionSize", size: 3, type: "vec3" }, { name: "scatteringDiffusionProfile", size: 1, type: "float" }] };
      }, x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isRefractionEnabled", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isTranslucencyEnabled", void 0), x([N(), ye("_markScenePrePassDirty")], t.prototype, "isScatteringEnabled", void 0), x([N()], t.prototype, "_scatteringDiffusionProfileIndex", void 0), x([N()], t.prototype, "refractionIntensity", void 0), x([N()], t.prototype, "translucencyIntensity", void 0), x([N()], t.prototype, "useAlbedoToTintRefraction", void 0), x([N()], t.prototype, "useAlbedoToTintTranslucency", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "thicknessTexture", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "refractionTexture", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "indexOfRefraction", void 0), x([N()], t.prototype, "_volumeIndexOfRefraction", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "volumeIndexOfRefraction", null), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertRefractionY", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "linkRefractionWithTransparency", void 0), x([N()], t.prototype, "minimumThickness", void 0), x([N()], t.prototype, "maximumThickness", void 0), x([N()], t.prototype, "useThicknessAsDepth", void 0), x([ri()], t.prototype, "tintColor", void 0), x([N()], t.prototype, "tintColorAtDistance", void 0), x([ri()], t.prototype, "diffusionDistance", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useMaskFromThicknessTexture", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "refractionIntensityTexture", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "translucencyIntensityTexture", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useGltfStyleTextures", void 0), t;
    }($r), Qc = { effect: null, subMesh: null }, u_ = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.PBR = !0, i.NUM_SAMPLES = "0", i.REALTIME_FILTERING = !1, i.MAINUV1 = !1, i.MAINUV2 = !1, i.MAINUV3 = !1, i.MAINUV4 = !1, i.MAINUV5 = !1, i.MAINUV6 = !1, i.UV1 = !1, i.UV2 = !1, i.UV3 = !1, i.UV4 = !1, i.UV5 = !1, i.UV6 = !1, i.ALBEDO = !1, i.GAMMAALBEDO = !1, i.ALBEDODIRECTUV = 0, i.VERTEXCOLOR = !1, i.BAKED_VERTEX_ANIMATION_TEXTURE = !1, i.AMBIENT = !1, i.AMBIENTDIRECTUV = 0, i.AMBIENTINGRAYSCALE = !1, i.OPACITY = !1, i.VERTEXALPHA = !1, i.OPACITYDIRECTUV = 0, i.OPACITYRGB = !1, i.ALPHATEST = !1, i.DEPTHPREPASS = !1, i.ALPHABLEND = !1, i.ALPHAFROMALBEDO = !1, i.ALPHATESTVALUE = "0.5", i.SPECULAROVERALPHA = !1, i.RADIANCEOVERALPHA = !1, i.ALPHAFRESNEL = !1, i.LINEARALPHAFRESNEL = !1, i.PREMULTIPLYALPHA = !1, i.EMISSIVE = !1, i.EMISSIVEDIRECTUV = 0, i.GAMMAEMISSIVE = !1, i.REFLECTIVITY = !1, i.REFLECTIVITY_GAMMA = !1, i.REFLECTIVITYDIRECTUV = 0, i.SPECULARTERM = !1, i.MICROSURFACEFROMREFLECTIVITYMAP = !1, i.MICROSURFACEAUTOMATIC = !1, i.LODBASEDMICROSFURACE = !1, i.MICROSURFACEMAP = !1, i.MICROSURFACEMAPDIRECTUV = 0, i.METALLICWORKFLOW = !1, i.ROUGHNESSSTOREINMETALMAPALPHA = !1, i.ROUGHNESSSTOREINMETALMAPGREEN = !1, i.METALLNESSSTOREINMETALMAPBLUE = !1, i.AOSTOREINMETALMAPRED = !1, i.METALLIC_REFLECTANCE = !1, i.METALLIC_REFLECTANCE_GAMMA = !1, i.METALLIC_REFLECTANCEDIRECTUV = 0, i.METALLIC_REFLECTANCE_USE_ALPHA_ONLY = !1, i.REFLECTANCE = !1, i.REFLECTANCE_GAMMA = !1, i.REFLECTANCEDIRECTUV = 0, i.ENVIRONMENTBRDF = !1, i.ENVIRONMENTBRDF_RGBD = !1, i.NORMAL = !1, i.TANGENT = !1, i.BUMP = !1, i.BUMPDIRECTUV = 0, i.OBJECTSPACE_NORMALMAP = !1, i.PARALLAX = !1, i.PARALLAX_RHS = !1, i.PARALLAXOCCLUSION = !1, i.NORMALXYSCALE = !0, i.LIGHTMAP = !1, i.LIGHTMAPDIRECTUV = 0, i.USELIGHTMAPASSHADOWMAP = !1, i.GAMMALIGHTMAP = !1, i.RGBDLIGHTMAP = !1, i.REFLECTION = !1, i.REFLECTIONMAP_3D = !1, i.REFLECTIONMAP_SPHERICAL = !1, i.REFLECTIONMAP_PLANAR = !1, i.REFLECTIONMAP_CUBIC = !1, i.USE_LOCAL_REFLECTIONMAP_CUBIC = !1, i.REFLECTIONMAP_PROJECTION = !1, i.REFLECTIONMAP_SKYBOX = !1, i.REFLECTIONMAP_EXPLICIT = !1, i.REFLECTIONMAP_EQUIRECTANGULAR = !1, i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1, i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1, i.INVERTCUBICMAP = !1, i.USESPHERICALFROMREFLECTIONMAP = !1, i.USEIRRADIANCEMAP = !1, i.USESPHERICALINVERTEX = !1, i.REFLECTIONMAP_OPPOSITEZ = !1, i.LODINREFLECTIONALPHA = !1, i.GAMMAREFLECTION = !1, i.RGBDREFLECTION = !1, i.LINEARSPECULARREFLECTION = !1, i.RADIANCEOCCLUSION = !1, i.HORIZONOCCLUSION = !1, i.INSTANCES = !1, i.THIN_INSTANCES = !1, i.INSTANCESCOLOR = !1, i.PREPASS = !1, i.PREPASS_IRRADIANCE = !1, i.PREPASS_IRRADIANCE_INDEX = -1, i.PREPASS_ALBEDO_SQRT = !1, i.PREPASS_ALBEDO_SQRT_INDEX = -1, i.PREPASS_DEPTH = !1, i.PREPASS_DEPTH_INDEX = -1, i.PREPASS_NORMAL = !1, i.PREPASS_NORMAL_INDEX = -1, i.PREPASS_NORMAL_WORLDSPACE = !1, i.PREPASS_POSITION = !1, i.PREPASS_POSITION_INDEX = -1, i.PREPASS_VELOCITY = !1, i.PREPASS_VELOCITY_INDEX = -1, i.PREPASS_REFLECTIVITY = !1, i.PREPASS_REFLECTIVITY_INDEX = -1, i.SCENE_MRT_COUNT = 0, i.NUM_BONE_INFLUENCERS = 0, i.BonesPerMesh = 0, i.BONETEXTURE = !1, i.BONES_VELOCITY_ENABLED = !1, i.NONUNIFORMSCALING = !1, i.MORPHTARGETS = !1, i.MORPHTARGETS_NORMAL = !1, i.MORPHTARGETS_TANGENT = !1, i.MORPHTARGETS_UV = !1, i.NUM_MORPH_INFLUENCERS = 0, i.MORPHTARGETS_TEXTURE = !1, i.IMAGEPROCESSING = !1, i.VIGNETTE = !1, i.VIGNETTEBLENDMODEMULTIPLY = !1, i.VIGNETTEBLENDMODEOPAQUE = !1, i.TONEMAPPING = !1, i.TONEMAPPING_ACES = !1, i.CONTRAST = !1, i.COLORCURVES = !1, i.COLORGRADING = !1, i.COLORGRADING3D = !1, i.SAMPLER3DGREENDEPTH = !1, i.SAMPLER3DBGRMAP = !1, i.DITHER = !1, i.IMAGEPROCESSINGPOSTPROCESS = !1, i.SKIPFINALCOLORCLAMP = !1, i.EXPOSURE = !1, i.MULTIVIEW = !1, i.ORDER_INDEPENDENT_TRANSPARENCY = !1, i.ORDER_INDEPENDENT_TRANSPARENCY_16BITS = !1, i.USEPHYSICALLIGHTFALLOFF = !1, i.USEGLTFLIGHTFALLOFF = !1, i.TWOSIDEDLIGHTING = !1, i.SHADOWFLOAT = !1, i.CLIPPLANE = !1, i.CLIPPLANE2 = !1, i.CLIPPLANE3 = !1, i.CLIPPLANE4 = !1, i.CLIPPLANE5 = !1, i.CLIPPLANE6 = !1, i.POINTSIZE = !1, i.FOG = !1, i.LOGARITHMICDEPTH = !1, i.CAMERA_ORTHOGRAPHIC = !1, i.CAMERA_PERSPECTIVE = !1, i.FORCENORMALFORWARD = !1, i.SPECULARAA = !1, i.UNLIT = !1, i.DECAL_AFTER_DETAIL = !1, i.DEBUGMODE = 0, i.rebuild(), i;
      }
      return D(t, n), t.prototype.reset = function() {
        n.prototype.reset.call(this), this.ALPHATESTVALUE = "0.5", this.PBR = !0, this.NORMALXYSCALE = !0;
      }, t;
    }(jn), Si = function(n) {
      function t(e, i) {
        var r = n.call(this, e, i) || this;
        return r._directIntensity = 1, r._emissiveIntensity = 1, r._environmentIntensity = 1, r._specularIntensity = 1, r._lightingInfos = new lt(r._directIntensity, r._emissiveIntensity, r._environmentIntensity, r._specularIntensity), r._disableBumpMap = !1, r._albedoTexture = null, r._ambientTexture = null, r._ambientTextureStrength = 1, r._ambientTextureImpactOnAnalyticalLights = t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS, r._opacityTexture = null, r._reflectionTexture = null, r._emissiveTexture = null, r._reflectivityTexture = null, r._metallicTexture = null, r._metallic = null, r._roughness = null, r._metallicF0Factor = 1, r._metallicReflectanceColor = ne.White(), r._useOnlyMetallicFromMetallicReflectanceTexture = !1, r._metallicReflectanceTexture = null, r._reflectanceTexture = null, r._microSurfaceTexture = null, r._bumpTexture = null, r._lightmapTexture = null, r._ambientColor = new ne(0, 0, 0), r._albedoColor = new ne(1, 1, 1), r._reflectivityColor = new ne(1, 1, 1), r._reflectionColor = new ne(1, 1, 1), r._emissiveColor = new ne(0, 0, 0), r._microSurface = 0.9, r._useLightmapAsShadowmap = !1, r._useHorizonOcclusion = !0, r._useRadianceOcclusion = !0, r._useAlphaFromAlbedoTexture = !1, r._useSpecularOverAlpha = !0, r._useMicroSurfaceFromReflectivityMapAlpha = !1, r._useRoughnessFromMetallicTextureAlpha = !0, r._useRoughnessFromMetallicTextureGreen = !1, r._useMetallnessFromMetallicTextureBlue = !1, r._useAmbientOcclusionFromMetallicTextureRed = !1, r._useAmbientInGrayScale = !1, r._useAutoMicroSurfaceFromReflectivityMap = !1, r._lightFalloff = t.LIGHTFALLOFF_PHYSICAL, r._useRadianceOverAlpha = !0, r._useObjectSpaceNormalMap = !1, r._useParallax = !1, r._useParallaxOcclusion = !1, r._parallaxScaleBias = 0.05, r._disableLighting = !1, r._maxSimultaneousLights = 4, r._invertNormalMapX = !1, r._invertNormalMapY = !1, r._twoSidedLighting = !1, r._alphaCutOff = 0.4, r._forceAlphaTest = !1, r._useAlphaFresnel = !1, r._useLinearAlphaFresnel = !1, r._environmentBRDFTexture = null, r._forceIrradianceInFragment = !1, r._realTimeFiltering = !1, r._realTimeFilteringQuality = _.TEXTURE_FILTERING_QUALITY_LOW, r._forceNormalForward = !1, r._enableSpecularAntiAliasing = !1, r._imageProcessingObserver = null, r._renderTargets = new en(16), r._globalAmbientColor = new ne(0, 0, 0), r._useLogarithmicDepth = !1, r._unlit = !1, r._applyDecalMapAfterDetailMap = !1, r._debugMode = 0, r.debugMode = 0, r.debugLimit = -1, r.debugFactor = 1, r._cacheHasRenderTargetTextures = !1, r.brdf = new UC(r), r.clearCoat = new Kc(r), r.iridescence = new qc(r), r.anisotropy = new s_(r), r.sheen = new l_(r), r.subSurface = new c_(r), r.detailMap = new dh(r), r._attachImageProcessingConfiguration(null), r.getRenderTargetTextures = function() {
          return r._renderTargets.reset(), Pe.ReflectionTextureEnabled && r._reflectionTexture && r._reflectionTexture.isRenderTarget && r._renderTargets.push(r._reflectionTexture), r._eventInfo.renderTargets = r._renderTargets, r._callbackPluginEventFillRenderTargetTextures(r._eventInfo), r._renderTargets;
        }, r._environmentBRDFTexture = Yc(r.getScene()), r.prePassConfiguration = new xc(), r;
      }
      return D(t, n), Object.defineProperty(t.prototype, "realTimeFiltering", { get: function() {
        return this._realTimeFiltering;
      }, set: function(e) {
        this._realTimeFiltering = e, this.markAsDirty(_.MATERIAL_TextureDirtyFlag);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "realTimeFilteringQuality", { get: function() {
        return this._realTimeFilteringQuality;
      }, set: function(e) {
        this._realTimeFilteringQuality = e, this.markAsDirty(_.MATERIAL_TextureDirtyFlag);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "canRenderToMRT", { get: function() {
        return !0;
      }, enumerable: !1, configurable: !0 }), t.prototype._attachImageProcessingConfiguration = function(e) {
        var i = this;
        e !== this._imageProcessingConfiguration && (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver), this._imageProcessingConfiguration = e || this.getScene().imageProcessingConfiguration, this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function() {
          i._markAllSubMeshesAsImageProcessingDirty();
        })));
      }, Object.defineProperty(t.prototype, "hasRenderTargetTextures", { get: function() {
        return !!(Pe.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) || this._cacheHasRenderTargetTextures;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isPrePassCapable", { get: function() {
        return !this.disableDepthWrite;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "PBRBaseMaterial";
      }, Object.defineProperty(t.prototype, "useLogarithmicDepth", { get: function() {
        return this._useLogarithmicDepth;
      }, set: function(e) {
        this._useLogarithmicDepth = e && this.getScene().getEngine().getCaps().fragmentDepthSupported;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "_disableAlphaBlending", { get: function() {
        var e;
        return this._transparencyMode === t.PBRMATERIAL_OPAQUE || this._transparencyMode === t.PBRMATERIAL_ALPHATEST || ((e = this.subSurface) === null || e === void 0 ? void 0 : e.disableAlphaBlending);
      }, enumerable: !1, configurable: !0 }), t.prototype.needAlphaBlending = function() {
        return !this._disableAlphaBlending && (this.alpha < 1 || this._opacityTexture != null || this._shouldUseAlphaFromAlbedoTexture());
      }, t.prototype.needAlphaTesting = function() {
        var e;
        return !!this._forceAlphaTest || !(!((e = this.subSurface) === null || e === void 0) && e.disableAlphaBlending) && this._hasAlphaChannel() && (this._transparencyMode == null || this._transparencyMode === t.PBRMATERIAL_ALPHATEST);
      }, t.prototype._shouldUseAlphaFromAlbedoTexture = function() {
        return this._albedoTexture != null && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== t.PBRMATERIAL_OPAQUE;
      }, t.prototype._hasAlphaChannel = function() {
        return this._albedoTexture != null && this._albedoTexture.hasAlpha || this._opacityTexture != null;
      }, t.prototype.getAlphaTestTexture = function() {
        return this._albedoTexture;
      }, t.prototype.isReadyForSubMesh = function(e, i, r) {
        var o;
        if (this._uniformBufferLayoutBuilt || this.buildUniformLayout(), i.effect && this.isFrozen && i.effect._wasPreviouslyReady && i.effect._wasPreviouslyUsingInstances === r)
          return !0;
        i.materialDefines || (this._callbackPluginEventGeneric(rn.GetDefineNames, this._eventInfo), i.materialDefines = new u_(this._eventInfo.defineNames));
        var a = i.materialDefines;
        if (this._isReadyForSubMesh(i))
          return !0;
        var s = this.getScene(), l = s.getEngine();
        if (a._areTexturesDirty && (this._eventInfo.hasRenderTargetTextures = !1, this._callbackPluginEventHasRenderTargetTextures(this._eventInfo), this._cacheHasRenderTargetTextures = this._eventInfo.hasRenderTargetTextures, s.texturesEnabled)) {
          if (this._albedoTexture && Pe.DiffuseTextureEnabled && !this._albedoTexture.isReadyOrNotBlocking() || this._ambientTexture && Pe.AmbientTextureEnabled && !this._ambientTexture.isReadyOrNotBlocking() || this._opacityTexture && Pe.OpacityTextureEnabled && !this._opacityTexture.isReadyOrNotBlocking())
            return !1;
          var c = this._getReflectionTexture();
          if (c && Pe.ReflectionTextureEnabled) {
            if (!c.isReadyOrNotBlocking())
              return !1;
            if (c.irradianceTexture) {
              if (!c.irradianceTexture.isReadyOrNotBlocking())
                return !1;
            } else if (!c.sphericalPolynomial && (!((o = c.getInternalTexture()) === null || o === void 0) && o._sphericalPolynomialPromise))
              return !1;
          }
          if (this._lightmapTexture && Pe.LightmapTextureEnabled && !this._lightmapTexture.isReadyOrNotBlocking() || this._emissiveTexture && Pe.EmissiveTextureEnabled && !this._emissiveTexture.isReadyOrNotBlocking())
            return !1;
          if (Pe.SpecularTextureEnabled) {
            if (this._metallicTexture) {
              if (!this._metallicTexture.isReadyOrNotBlocking())
                return !1;
            } else if (this._reflectivityTexture && !this._reflectivityTexture.isReadyOrNotBlocking())
              return !1;
            if (this._metallicReflectanceTexture && !this._metallicReflectanceTexture.isReadyOrNotBlocking() || this._reflectanceTexture && !this._reflectanceTexture.isReadyOrNotBlocking() || this._microSurfaceTexture && !this._microSurfaceTexture.isReadyOrNotBlocking())
              return !1;
          }
          if (l.getCaps().standardDerivatives && this._bumpTexture && Pe.BumpTextureEnabled && !this._disableBumpMap && !this._bumpTexture.isReady() || this._environmentBRDFTexture && Pe.ReflectionTextureEnabled && !this._environmentBRDFTexture.isReady())
            return !1;
        }
        if (this._eventInfo.isReadyForSubMesh = !0, this._eventInfo.defines = a, this._eventInfo.subMesh = i, this._callbackPluginEventIsReadyForSubMesh(this._eventInfo), !this._eventInfo.isReadyForSubMesh || a._areImageProcessingDirty && this._imageProcessingConfiguration && !this._imageProcessingConfiguration.isReady())
          return !1;
        l.getCaps().standardDerivatives || e.isVerticesDataPresent(P.NormalKind) || (e.createNormals(!0), q.Warn("PBRMaterial: Normals have been created for the mesh: " + e.name));
        var u = i.effect, h = a._areLightsDisposed, d = this._prepareEffect(e, a, this.onCompiled, this.onError, r, null, i.getRenderingMesh().hasThinInstances), p = !1;
        if (d)
          if (this._onEffectCreatedObservable && (Qc.effect = d, Qc.subMesh = i, this._onEffectCreatedObservable.notifyObservers(Qc)), this.allowShaderHotSwapping && u && !d.isReady()) {
            if (d = u, a.markAsUnprocessed(), p = this.isFrozen, h)
              return a._areLightsDisposed = !0, !1;
          } else
            s.resetCachedMaterial(), i.setEffect(d, a, this._materialContext);
        return !(!i.effect || !i.effect.isReady() || (a._renderId = s.getRenderId(), i.effect._wasPreviouslyReady = !p, i.effect._wasPreviouslyUsingInstances = !!r, this._checkScenePerformancePriority(), 0));
      }, t.prototype.isMetallicWorkflow = function() {
        return !(this._metallic == null && this._roughness == null && !this._metallicTexture);
      }, t.prototype._prepareEffect = function(e, i, r, o, a, s, l) {
        if (r === void 0 && (r = null), o === void 0 && (o = null), a === void 0 && (a = null), s === void 0 && (s = null), this._prepareDefines(e, i, a, s, l), !i.isDirty)
          return null;
        i.markAsProcessed();
        var c = this.getScene().getEngine(), u = new Va(), h = 0;
        i.USESPHERICALINVERTEX && u.addFallback(h++, "USESPHERICALINVERTEX"), i.FOG && u.addFallback(h, "FOG"), i.SPECULARAA && u.addFallback(h, "SPECULARAA"), i.POINTSIZE && u.addFallback(h, "POINTSIZE"), i.LOGARITHMICDEPTH && u.addFallback(h, "LOGARITHMICDEPTH"), i.PARALLAX && u.addFallback(h, "PARALLAX"), i.PARALLAX_RHS && u.addFallback(h, "PARALLAX_RHS"), i.PARALLAXOCCLUSION && u.addFallback(h++, "PARALLAXOCCLUSION"), i.ENVIRONMENTBRDF && u.addFallback(h++, "ENVIRONMENTBRDF"), i.TANGENT && u.addFallback(h++, "TANGENT"), i.BUMP && u.addFallback(h++, "BUMP"), h = Se.HandleFallbacksForShadows(i, u, this._maxSimultaneousLights, h++), i.SPECULARTERM && u.addFallback(h++, "SPECULARTERM"), i.USESPHERICALFROMREFLECTIONMAP && u.addFallback(h++, "USESPHERICALFROMREFLECTIONMAP"), i.USEIRRADIANCEMAP && u.addFallback(h++, "USEIRRADIANCEMAP"), i.LIGHTMAP && u.addFallback(h++, "LIGHTMAP"), i.NORMAL && u.addFallback(h++, "NORMAL"), i.AMBIENT && u.addFallback(h++, "AMBIENT"), i.EMISSIVE && u.addFallback(h++, "EMISSIVE"), i.VERTEXCOLOR && u.addFallback(h++, "VERTEXCOLOR"), i.MORPHTARGETS && u.addFallback(h++, "MORPHTARGETS"), i.MULTIVIEW && u.addFallback(0, "MULTIVIEW");
        var d = [P.PositionKind];
        i.NORMAL && d.push(P.NormalKind), i.TANGENT && d.push(P.TangentKind);
        for (var p = 1; p <= _.MAX_SUPPORTED_UV_SETS; ++p)
          i["UV" + p] && d.push("uv".concat(p === 1 ? "" : p));
        i.VERTEXCOLOR && d.push(P.ColorKind), i.INSTANCESCOLOR && d.push(P.ColorInstanceKind), Se.PrepareAttributesForBones(d, e, i, u), Se.PrepareAttributesForInstances(d, i), Se.PrepareAttributesForMorphTargets(d, e, i), Se.PrepareAttributesForBakedVertexAnimation(d, e, i);
        var f = "pbr", m = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vAlbedoColor", "vReflectivityColor", "vMetallicReflectanceFactors", "vEmissiveColor", "visibility", "vReflectionColor", "vFogInfos", "vFogColor", "pointSize", "vAlbedoInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vReflectionPosition", "vReflectionSize", "vEmissiveInfos", "vReflectivityInfos", "vReflectionFilteringInfo", "vMetallicReflectanceInfos", "vReflectanceInfos", "vMicroSurfaceSamplerInfos", "vBumpInfos", "vLightmapInfos", "mBones", "albedoMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "reflectivityMatrix", "normalMatrix", "microSurfaceSamplerMatrix", "bumpMatrix", "lightmapMatrix", "metallicReflectanceMatrix", "reflectanceMatrix", "vLightingIntensity", "logarithmicDepthConstant", "vSphericalX", "vSphericalY", "vSphericalZ", "vSphericalXX_ZZ", "vSphericalYY_ZZ", "vSphericalZZ", "vSphericalXY", "vSphericalYZ", "vSphericalZX", "vSphericalL00", "vSphericalL1_1", "vSphericalL10", "vSphericalL11", "vSphericalL2_2", "vSphericalL2_1", "vSphericalL20", "vSphericalL21", "vSphericalL22", "vReflectionMicrosurfaceInfos", "vTangentSpaceParams", "boneTextureWidth", "vDebugMode", "morphTargetTextureInfo", "morphTargetTextureIndices"], g = ["albedoSampler", "reflectivitySampler", "ambientSampler", "emissiveSampler", "bumpSampler", "lightmapSampler", "opacitySampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh", "irradianceSampler", "microSurfaceSampler", "environmentBrdfSampler", "boneSampler", "metallicReflectanceSampler", "reflectanceSampler", "morphTargets", "oitDepthSampler", "oitFrontColorSampler"], y = ["Material", "Scene", "Mesh"], b = { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: i.NUM_MORPH_INFLUENCERS };
        this._eventInfo.fallbacks = u, this._eventInfo.fallbackRank = h, this._eventInfo.defines = i, this._eventInfo.uniforms = m, this._eventInfo.attributes = d, this._eventInfo.samplers = g, this._eventInfo.uniformBuffersNames = y, this._eventInfo.customCode = void 0, this._eventInfo.mesh = e, this._eventInfo.indexParameters = b, this._callbackPluginEventGeneric(rn.PrepareEffect, this._eventInfo), xc.AddUniforms(m), xc.AddSamplers(g), Br(m), tn && (tn.PrepareUniforms(m, i), tn.PrepareSamplers(g, i)), Se.PrepareUniformsAndSamplersList({ uniformsNames: m, uniformBuffersNames: y, samplers: g, defines: i, maxSimultaneousLights: this._maxSimultaneousLights });
        var T = {};
        this.customShaderNameResolve && (f = this.customShaderNameResolve(f, m, y, g, i, d, T));
        var S = i.toString(), E = c.createEffect(f, { attributes: d, uniformsNames: m, uniformBuffersNames: y, samplers: g, defines: S, fallbacks: u, onCompiled: r, onError: o, indexParameters: b, processFinalCode: T.processFinalCode, processCodeAfterIncludes: this._eventInfo.customCode, multiTarget: i.PREPASS }, c);
        return this._eventInfo.customCode = void 0, E;
      }, t.prototype._prepareDefines = function(e, i, r, o, a) {
        var s;
        r === void 0 && (r = null), o === void 0 && (o = null), a === void 0 && (a = !1);
        var l = this.getScene(), c = l.getEngine();
        Se.PrepareDefinesForLights(l, e, i, !0, this._maxSimultaneousLights, this._disableLighting), i._needNormals = !0, Se.PrepareDefinesForMultiview(l, i);
        var u = this.needAlphaBlendingForMesh(e) && this.getScene().useOrderIndependentTransparency;
        if (Se.PrepareDefinesForPrePass(l, i, this.canRenderToMRT && !u), Se.PrepareDefinesForOIT(l, i, u), i.METALLICWORKFLOW = this.isMetallicWorkflow(), i._areTexturesDirty) {
          i._needUVs = !1;
          for (var h = 1; h <= _.MAX_SUPPORTED_UV_SETS; ++h)
            i["MAINUV" + h] = !1;
          if (l.texturesEnabled) {
            i.ALBEDODIRECTUV = 0, i.AMBIENTDIRECTUV = 0, i.OPACITYDIRECTUV = 0, i.EMISSIVEDIRECTUV = 0, i.REFLECTIVITYDIRECTUV = 0, i.MICROSURFACEMAPDIRECTUV = 0, i.METALLIC_REFLECTANCEDIRECTUV = 0, i.REFLECTANCEDIRECTUV = 0, i.BUMPDIRECTUV = 0, i.LIGHTMAPDIRECTUV = 0, c.getCaps().textureLOD && (i.LODBASEDMICROSFURACE = !0), this._albedoTexture && Pe.DiffuseTextureEnabled ? (Se.PrepareDefinesForMergedUV(this._albedoTexture, i, "ALBEDO"), i.GAMMAALBEDO = this._albedoTexture.gammaSpace) : i.ALBEDO = !1, this._ambientTexture && Pe.AmbientTextureEnabled ? (Se.PrepareDefinesForMergedUV(this._ambientTexture, i, "AMBIENT"), i.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale) : i.AMBIENT = !1, this._opacityTexture && Pe.OpacityTextureEnabled ? (Se.PrepareDefinesForMergedUV(this._opacityTexture, i, "OPACITY"), i.OPACITYRGB = this._opacityTexture.getAlphaFromRGB) : i.OPACITY = !1;
            var d = this._getReflectionTexture();
            if (d && Pe.ReflectionTextureEnabled) {
              switch (i.REFLECTION = !0, i.GAMMAREFLECTION = d.gammaSpace, i.RGBDREFLECTION = d.isRGBD, i.LODINREFLECTIONALPHA = d.lodLevelInAlpha, i.LINEARSPECULARREFLECTION = d.linearSpecularLOD, this.realTimeFiltering && this.realTimeFilteringQuality > 0 ? (i.NUM_SAMPLES = "" + this.realTimeFilteringQuality, c._features.needTypeSuffixInShaderConstants && (i.NUM_SAMPLES = i.NUM_SAMPLES + "u"), i.REALTIME_FILTERING = !0) : i.REALTIME_FILTERING = !1, i.INVERTCUBICMAP = d.coordinatesMode === ae.INVCUBIC_MODE, i.REFLECTIONMAP_3D = d.isCube, i.REFLECTIONMAP_OPPOSITEZ = i.REFLECTIONMAP_3D && this.getScene().useRightHandedSystem ? !d.invertZ : d.invertZ, i.REFLECTIONMAP_CUBIC = !1, i.REFLECTIONMAP_EXPLICIT = !1, i.REFLECTIONMAP_PLANAR = !1, i.REFLECTIONMAP_PROJECTION = !1, i.REFLECTIONMAP_SKYBOX = !1, i.REFLECTIONMAP_SPHERICAL = !1, i.REFLECTIONMAP_EQUIRECTANGULAR = !1, i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1, i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1, d.coordinatesMode) {
                case ae.EXPLICIT_MODE:
                  i.REFLECTIONMAP_EXPLICIT = !0;
                  break;
                case ae.PLANAR_MODE:
                  i.REFLECTIONMAP_PLANAR = !0;
                  break;
                case ae.PROJECTION_MODE:
                  i.REFLECTIONMAP_PROJECTION = !0;
                  break;
                case ae.SKYBOX_MODE:
                  i.REFLECTIONMAP_SKYBOX = !0;
                  break;
                case ae.SPHERICAL_MODE:
                  i.REFLECTIONMAP_SPHERICAL = !0;
                  break;
                case ae.EQUIRECTANGULAR_MODE:
                  i.REFLECTIONMAP_EQUIRECTANGULAR = !0;
                  break;
                case ae.FIXED_EQUIRECTANGULAR_MODE:
                  i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !0;
                  break;
                case ae.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
                  i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !0;
                  break;
                case ae.CUBIC_MODE:
                case ae.INVCUBIC_MODE:
                default:
                  i.REFLECTIONMAP_CUBIC = !0, i.USE_LOCAL_REFLECTIONMAP_CUBIC = !!d.boundingBoxSize;
              }
              d.coordinatesMode !== ae.SKYBOX_MODE && (d.irradianceTexture ? (i.USEIRRADIANCEMAP = !0, i.USESPHERICALFROMREFLECTIONMAP = !1) : d.isCube && (i.USESPHERICALFROMREFLECTIONMAP = !0, i.USEIRRADIANCEMAP = !1, this._forceIrradianceInFragment || this.realTimeFiltering || this._twoSidedLighting || c.getCaps().maxVaryingVectors <= 8 ? i.USESPHERICALINVERTEX = !1 : i.USESPHERICALINVERTEX = !0));
            } else
              i.REFLECTION = !1, i.REFLECTIONMAP_3D = !1, i.REFLECTIONMAP_SPHERICAL = !1, i.REFLECTIONMAP_PLANAR = !1, i.REFLECTIONMAP_CUBIC = !1, i.USE_LOCAL_REFLECTIONMAP_CUBIC = !1, i.REFLECTIONMAP_PROJECTION = !1, i.REFLECTIONMAP_SKYBOX = !1, i.REFLECTIONMAP_EXPLICIT = !1, i.REFLECTIONMAP_EQUIRECTANGULAR = !1, i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1, i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1, i.INVERTCUBICMAP = !1, i.USESPHERICALFROMREFLECTIONMAP = !1, i.USEIRRADIANCEMAP = !1, i.USESPHERICALINVERTEX = !1, i.REFLECTIONMAP_OPPOSITEZ = !1, i.LODINREFLECTIONALPHA = !1, i.GAMMAREFLECTION = !1, i.RGBDREFLECTION = !1, i.LINEARSPECULARREFLECTION = !1;
            if (this._lightmapTexture && Pe.LightmapTextureEnabled ? (Se.PrepareDefinesForMergedUV(this._lightmapTexture, i, "LIGHTMAP"), i.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap, i.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace, i.RGBDLIGHTMAP = this._lightmapTexture.isRGBD) : i.LIGHTMAP = !1, this._emissiveTexture && Pe.EmissiveTextureEnabled ? (Se.PrepareDefinesForMergedUV(this._emissiveTexture, i, "EMISSIVE"), i.GAMMAEMISSIVE = this._emissiveTexture.gammaSpace) : i.EMISSIVE = !1, Pe.SpecularTextureEnabled) {
              if (this._metallicTexture ? (Se.PrepareDefinesForMergedUV(this._metallicTexture, i, "REFLECTIVITY"), i.ROUGHNESSSTOREINMETALMAPALPHA = this._useRoughnessFromMetallicTextureAlpha, i.ROUGHNESSSTOREINMETALMAPGREEN = !this._useRoughnessFromMetallicTextureAlpha && this._useRoughnessFromMetallicTextureGreen, i.METALLNESSSTOREINMETALMAPBLUE = this._useMetallnessFromMetallicTextureBlue, i.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed, i.REFLECTIVITY_GAMMA = !1) : this._reflectivityTexture ? (Se.PrepareDefinesForMergedUV(this._reflectivityTexture, i, "REFLECTIVITY"), i.MICROSURFACEFROMREFLECTIVITYMAP = this._useMicroSurfaceFromReflectivityMapAlpha, i.MICROSURFACEAUTOMATIC = this._useAutoMicroSurfaceFromReflectivityMap, i.REFLECTIVITY_GAMMA = this._reflectivityTexture.gammaSpace) : i.REFLECTIVITY = !1, this._metallicReflectanceTexture || this._reflectanceTexture) {
                var p = this._metallicReflectanceTexture !== null && this._metallicReflectanceTexture._texture === ((s = this._reflectanceTexture) === null || s === void 0 ? void 0 : s._texture) && this._metallicReflectanceTexture.checkTransformsAreIdentical(this._reflectanceTexture);
                i.METALLIC_REFLECTANCE_USE_ALPHA_ONLY = this._useOnlyMetallicFromMetallicReflectanceTexture && !p, this._metallicReflectanceTexture ? (Se.PrepareDefinesForMergedUV(this._metallicReflectanceTexture, i, "METALLIC_REFLECTANCE"), i.METALLIC_REFLECTANCE_GAMMA = this._metallicReflectanceTexture.gammaSpace) : i.METALLIC_REFLECTANCE = !1, this._reflectanceTexture && !p && (!this._metallicReflectanceTexture || this._metallicReflectanceTexture && this._useOnlyMetallicFromMetallicReflectanceTexture) ? (Se.PrepareDefinesForMergedUV(this._reflectanceTexture, i, "REFLECTANCE"), i.REFLECTANCE_GAMMA = this._reflectanceTexture.gammaSpace) : i.REFLECTANCE = !1;
              } else
                i.METALLIC_REFLECTANCE = !1, i.REFLECTANCE = !1;
              this._microSurfaceTexture ? Se.PrepareDefinesForMergedUV(this._microSurfaceTexture, i, "MICROSURFACEMAP") : i.MICROSURFACEMAP = !1;
            } else
              i.REFLECTIVITY = !1, i.MICROSURFACEMAP = !1;
            c.getCaps().standardDerivatives && this._bumpTexture && Pe.BumpTextureEnabled && !this._disableBumpMap ? (Se.PrepareDefinesForMergedUV(this._bumpTexture, i, "BUMP"), this._useParallax && this._albedoTexture && Pe.DiffuseTextureEnabled ? (i.PARALLAX = !0, i.PARALLAX_RHS = l.useRightHandedSystem, i.PARALLAXOCCLUSION = !!this._useParallaxOcclusion) : i.PARALLAX = !1, i.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap) : (i.BUMP = !1, i.PARALLAX = !1, i.PARALLAX_RHS = !1, i.PARALLAXOCCLUSION = !1, i.OBJECTSPACE_NORMALMAP = !1), this._environmentBRDFTexture && Pe.ReflectionTextureEnabled ? (i.ENVIRONMENTBRDF = !0, i.ENVIRONMENTBRDF_RGBD = this._environmentBRDFTexture.isRGBD) : (i.ENVIRONMENTBRDF = !1, i.ENVIRONMENTBRDF_RGBD = !1), this._shouldUseAlphaFromAlbedoTexture() ? i.ALPHAFROMALBEDO = !0 : i.ALPHAFROMALBEDO = !1;
          }
          i.SPECULAROVERALPHA = this._useSpecularOverAlpha, this._lightFalloff === t.LIGHTFALLOFF_STANDARD ? (i.USEPHYSICALLIGHTFALLOFF = !1, i.USEGLTFLIGHTFALLOFF = !1) : this._lightFalloff === t.LIGHTFALLOFF_GLTF ? (i.USEPHYSICALLIGHTFALLOFF = !1, i.USEGLTFLIGHTFALLOFF = !0) : (i.USEPHYSICALLIGHTFALLOFF = !0, i.USEGLTFLIGHTFALLOFF = !1), i.RADIANCEOVERALPHA = this._useRadianceOverAlpha, !this.backFaceCulling && this._twoSidedLighting ? i.TWOSIDEDLIGHTING = !0 : i.TWOSIDEDLIGHTING = !1, i.SPECULARAA = c.getCaps().standardDerivatives && this._enableSpecularAntiAliasing;
        }
        (i._areTexturesDirty || i._areMiscDirty) && (i.ALPHATESTVALUE = "".concat(this._alphaCutOff).concat(this._alphaCutOff % 1 == 0 ? "." : ""), i.PREMULTIPLYALPHA = this.alphaMode === _.ALPHA_PREMULTIPLIED || this.alphaMode === _.ALPHA_PREMULTIPLIED_PORTERDUFF, i.ALPHABLEND = this.needAlphaBlendingForMesh(e), i.ALPHAFRESNEL = this._useAlphaFresnel || this._useLinearAlphaFresnel, i.LINEARALPHAFRESNEL = this._useLinearAlphaFresnel), i._areImageProcessingDirty && this._imageProcessingConfiguration && this._imageProcessingConfiguration.prepareDefines(i), i.FORCENORMALFORWARD = this._forceNormalForward, i.RADIANCEOCCLUSION = this._useRadianceOcclusion, i.HORIZONOCCLUSION = this._useHorizonOcclusion, i._areMiscDirty && (Se.PrepareDefinesForMisc(e, l, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(e) || this._forceAlphaTest, i, this._applyDecalMapAfterDetailMap), i.UNLIT = this._unlit || (this.pointsCloud || this.wireframe) && !e.isVerticesDataPresent(P.NormalKind), i.DEBUGMODE = this._debugMode), Se.PrepareDefinesForFrameBoundValues(l, c, this, i, !!r, o, a), this._eventInfo.defines = i, this._eventInfo.mesh = e, this._callbackPluginEventPrepareDefinesBeforeAttributes(this._eventInfo), Se.PrepareDefinesForAttributes(e, i, !0, !0, !0, this._transparencyMode !== t.PBRMATERIAL_OPAQUE), this._callbackPluginEventPrepareDefines(this._eventInfo);
      }, t.prototype.forceCompilation = function(e, i, r) {
        var o = this, a = je({ clipPlane: !1, useInstances: !1 }, r);
        this._uniformBufferLayoutBuilt || this.buildUniformLayout(), this._callbackPluginEventGeneric(rn.GetDefineNames, this._eventInfo);
        var s = new u_(this._eventInfo.defineNames), l = this._prepareEffect(e, s, void 0, void 0, a.useInstances, a.clipPlane, e.hasThinInstances);
        this._onEffectCreatedObservable && (Qc.effect = l, Qc.subMesh = null, this._onEffectCreatedObservable.notifyObservers(Qc)), l.isReady() ? i && i(this) : l.onCompileObservable.add(function() {
          i && i(o);
        });
      }, t.prototype.buildUniformLayout = function() {
        var e = this._uniformBuffer;
        e.addUniform("vAlbedoInfos", 2), e.addUniform("vAmbientInfos", 4), e.addUniform("vOpacityInfos", 2), e.addUniform("vEmissiveInfos", 2), e.addUniform("vLightmapInfos", 2), e.addUniform("vReflectivityInfos", 3), e.addUniform("vMicroSurfaceSamplerInfos", 2), e.addUniform("vReflectionInfos", 2), e.addUniform("vReflectionFilteringInfo", 2), e.addUniform("vReflectionPosition", 3), e.addUniform("vReflectionSize", 3), e.addUniform("vBumpInfos", 3), e.addUniform("albedoMatrix", 16), e.addUniform("ambientMatrix", 16), e.addUniform("opacityMatrix", 16), e.addUniform("emissiveMatrix", 16), e.addUniform("lightmapMatrix", 16), e.addUniform("reflectivityMatrix", 16), e.addUniform("microSurfaceSamplerMatrix", 16), e.addUniform("bumpMatrix", 16), e.addUniform("vTangentSpaceParams", 2), e.addUniform("reflectionMatrix", 16), e.addUniform("vReflectionColor", 3), e.addUniform("vAlbedoColor", 4), e.addUniform("vLightingIntensity", 4), e.addUniform("vReflectionMicrosurfaceInfos", 3), e.addUniform("pointSize", 1), e.addUniform("vReflectivityColor", 4), e.addUniform("vEmissiveColor", 3), e.addUniform("vAmbientColor", 3), e.addUniform("vDebugMode", 2), e.addUniform("vMetallicReflectanceFactors", 4), e.addUniform("vMetallicReflectanceInfos", 2), e.addUniform("metallicReflectanceMatrix", 16), e.addUniform("vReflectanceInfos", 2), e.addUniform("reflectanceMatrix", 16), e.addUniform("vSphericalL00", 3), e.addUniform("vSphericalL1_1", 3), e.addUniform("vSphericalL10", 3), e.addUniform("vSphericalL11", 3), e.addUniform("vSphericalL2_2", 3), e.addUniform("vSphericalL2_1", 3), e.addUniform("vSphericalL20", 3), e.addUniform("vSphericalL21", 3), e.addUniform("vSphericalL22", 3), e.addUniform("vSphericalX", 3), e.addUniform("vSphericalY", 3), e.addUniform("vSphericalZ", 3), e.addUniform("vSphericalXX_ZZ", 3), e.addUniform("vSphericalYY_ZZ", 3), e.addUniform("vSphericalZZ", 3), e.addUniform("vSphericalXY", 3), e.addUniform("vSphericalYZ", 3), e.addUniform("vSphericalZX", 3), n.prototype.buildUniformLayout.call(this);
      }, t.prototype.bindForSubMesh = function(e, i, r) {
        var o, a, s, l, c = this.getScene(), u = r.materialDefines;
        if (u) {
          var h = r.effect;
          if (h) {
            this._activeEffect = h, i.getMeshUniformBuffer().bindToEffect(h, "Mesh"), i.transferToEffect(e);
            var d = c.getEngine();
            this._uniformBuffer.bindToEffect(h, "Material"), this.prePassConfiguration.bindForSubMesh(this._activeEffect, c, i, e, this.isFrozen), this._eventInfo.subMesh = r, this._callbackPluginEventHardBindForSubMesh(this._eventInfo), u.OBJECTSPACE_NORMALMAP && (e.toNormalMatrix(this._normalMatrix), this.bindOnlyNormalMatrix(this._normalMatrix));
            var p = h._forceRebindOnNextCall || this._mustRebind(c, h, i.visibility);
            Se.BindBonesParameters(i, this._activeEffect, this.prePassConfiguration);
            var f = null, m = this._uniformBuffer;
            if (p) {
              if (this.bindViewProjection(h), f = this._getReflectionTexture(), !m.useUbo || !this.isFrozen || !m.isSync || h._forceRebindOnNextCall) {
                if (c.texturesEnabled) {
                  if (this._albedoTexture && Pe.DiffuseTextureEnabled && (m.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level), Se.BindTextureMatrix(this._albedoTexture, m, "albedo")), this._ambientTexture && Pe.AmbientTextureEnabled && (m.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights), Se.BindTextureMatrix(this._ambientTexture, m, "ambient")), this._opacityTexture && Pe.OpacityTextureEnabled && (m.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level), Se.BindTextureMatrix(this._opacityTexture, m, "opacity")), f && Pe.ReflectionTextureEnabled) {
                    if (m.updateMatrix("reflectionMatrix", f.getReflectionTextureMatrix()), m.updateFloat2("vReflectionInfos", f.level, 0), f.boundingBoxSize) {
                      var g = f;
                      m.updateVector3("vReflectionPosition", g.boundingBoxPosition), m.updateVector3("vReflectionSize", g.boundingBoxSize);
                    }
                    if (this.realTimeFiltering) {
                      var y = f.getSize().width;
                      m.updateFloat2("vReflectionFilteringInfo", y, ue.Log2(y));
                    }
                    if (!u.USEIRRADIANCEMAP) {
                      var b = f.sphericalPolynomial;
                      if (u.USESPHERICALFROMREFLECTIONMAP && b)
                        if (u.SPHERICAL_HARMONICS) {
                          var T = b.preScaledHarmonics;
                          m.updateVector3("vSphericalL00", T.l00), m.updateVector3("vSphericalL1_1", T.l1_1), m.updateVector3("vSphericalL10", T.l10), m.updateVector3("vSphericalL11", T.l11), m.updateVector3("vSphericalL2_2", T.l2_2), m.updateVector3("vSphericalL2_1", T.l2_1), m.updateVector3("vSphericalL20", T.l20), m.updateVector3("vSphericalL21", T.l21), m.updateVector3("vSphericalL22", T.l22);
                        } else
                          m.updateFloat3("vSphericalX", b.x.x, b.x.y, b.x.z), m.updateFloat3("vSphericalY", b.y.x, b.y.y, b.y.z), m.updateFloat3("vSphericalZ", b.z.x, b.z.y, b.z.z), m.updateFloat3("vSphericalXX_ZZ", b.xx.x - b.zz.x, b.xx.y - b.zz.y, b.xx.z - b.zz.z), m.updateFloat3("vSphericalYY_ZZ", b.yy.x - b.zz.x, b.yy.y - b.zz.y, b.yy.z - b.zz.z), m.updateFloat3("vSphericalZZ", b.zz.x, b.zz.y, b.zz.z), m.updateFloat3("vSphericalXY", b.xy.x, b.xy.y, b.xy.z), m.updateFloat3("vSphericalYZ", b.yz.x, b.yz.y, b.yz.z), m.updateFloat3("vSphericalZX", b.zx.x, b.zx.y, b.zx.z);
                    }
                    m.updateFloat3("vReflectionMicrosurfaceInfos", f.getSize().width, f.lodGenerationScale, f.lodGenerationOffset);
                  }
                  this._emissiveTexture && Pe.EmissiveTextureEnabled && (m.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level), Se.BindTextureMatrix(this._emissiveTexture, m, "emissive")), this._lightmapTexture && Pe.LightmapTextureEnabled && (m.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level), Se.BindTextureMatrix(this._lightmapTexture, m, "lightmap")), Pe.SpecularTextureEnabled && (this._metallicTexture ? (m.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength), Se.BindTextureMatrix(this._metallicTexture, m, "reflectivity")) : this._reflectivityTexture && (m.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1), Se.BindTextureMatrix(this._reflectivityTexture, m, "reflectivity")), this._metallicReflectanceTexture && (m.updateFloat2("vMetallicReflectanceInfos", this._metallicReflectanceTexture.coordinatesIndex, this._metallicReflectanceTexture.level), Se.BindTextureMatrix(this._metallicReflectanceTexture, m, "metallicReflectance")), this._reflectanceTexture && u.REFLECTANCE && (m.updateFloat2("vReflectanceInfos", this._reflectanceTexture.coordinatesIndex, this._reflectanceTexture.level), Se.BindTextureMatrix(this._reflectanceTexture, m, "reflectance")), this._microSurfaceTexture && (m.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level), Se.BindTextureMatrix(this._microSurfaceTexture, m, "microSurfaceSampler"))), this._bumpTexture && d.getCaps().standardDerivatives && Pe.BumpTextureEnabled && !this._disableBumpMap && (m.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias), Se.BindTextureMatrix(this._bumpTexture, m, "bump"), c._mirroredCameraPosition ? m.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1 : -1, this._invertNormalMapY ? 1 : -1) : m.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1 : 1, this._invertNormalMapY ? -1 : 1));
                }
                if (this.pointsCloud && m.updateFloat("pointSize", this.pointSize), u.METALLICWORKFLOW) {
                  Ot.Color3[0].r = this._metallic === void 0 || this._metallic === null ? 1 : this._metallic, Ot.Color3[0].g = this._roughness === void 0 || this._roughness === null ? 1 : this._roughness, m.updateColor4("vReflectivityColor", Ot.Color3[0], 1);
                  var S = (a = (o = this.subSurface) === null || o === void 0 ? void 0 : o._indexOfRefraction) !== null && a !== void 0 ? a : 1.5, E = Math.pow((S - 1) / (S + 1), 2);
                  this._metallicReflectanceColor.scaleToRef(E * this._metallicF0Factor, Ot.Color3[0]);
                  var A = this._metallicF0Factor;
                  m.updateColor4("vMetallicReflectanceFactors", Ot.Color3[0], A);
                } else
                  m.updateColor4("vReflectivityColor", this._reflectivityColor, this._microSurface);
                m.updateColor3("vEmissiveColor", Pe.EmissiveTextureEnabled ? this._emissiveColor : ne.BlackReadOnly), m.updateColor3("vReflectionColor", this._reflectionColor), !u.SS_REFRACTION && (!((s = this.subSurface) === null || s === void 0) && s._linkRefractionWithTransparency) ? m.updateColor4("vAlbedoColor", this._albedoColor, 1) : m.updateColor4("vAlbedoColor", this._albedoColor, this.alpha), this._lightingInfos.x = this._directIntensity, this._lightingInfos.y = this._emissiveIntensity, this._lightingInfos.z = this._environmentIntensity * c.environmentIntensity, this._lightingInfos.w = this._specularIntensity, m.updateVector4("vLightingIntensity", this._lightingInfos), c.ambientColor.multiplyToRef(this._ambientColor, this._globalAmbientColor), m.updateColor3("vAmbientColor", this._globalAmbientColor), m.updateFloat2("vDebugMode", this.debugLimit, this.debugFactor);
              }
              c.texturesEnabled && (this._albedoTexture && Pe.DiffuseTextureEnabled && m.setTexture("albedoSampler", this._albedoTexture), this._ambientTexture && Pe.AmbientTextureEnabled && m.setTexture("ambientSampler", this._ambientTexture), this._opacityTexture && Pe.OpacityTextureEnabled && m.setTexture("opacitySampler", this._opacityTexture), f && Pe.ReflectionTextureEnabled && (u.LODBASEDMICROSFURACE ? m.setTexture("reflectionSampler", f) : (m.setTexture("reflectionSampler", f._lodTextureMid || f), m.setTexture("reflectionSamplerLow", f._lodTextureLow || f), m.setTexture("reflectionSamplerHigh", f._lodTextureHigh || f)), u.USEIRRADIANCEMAP && m.setTexture("irradianceSampler", f.irradianceTexture)), u.ENVIRONMENTBRDF && m.setTexture("environmentBrdfSampler", this._environmentBRDFTexture), this._emissiveTexture && Pe.EmissiveTextureEnabled && m.setTexture("emissiveSampler", this._emissiveTexture), this._lightmapTexture && Pe.LightmapTextureEnabled && m.setTexture("lightmapSampler", this._lightmapTexture), Pe.SpecularTextureEnabled && (this._metallicTexture ? m.setTexture("reflectivitySampler", this._metallicTexture) : this._reflectivityTexture && m.setTexture("reflectivitySampler", this._reflectivityTexture), this._metallicReflectanceTexture && m.setTexture("metallicReflectanceSampler", this._metallicReflectanceTexture), this._reflectanceTexture && u.REFLECTANCE && m.setTexture("reflectanceSampler", this._reflectanceTexture), this._microSurfaceTexture && m.setTexture("microSurfaceSampler", this._microSurfaceTexture)), this._bumpTexture && d.getCaps().standardDerivatives && Pe.BumpTextureEnabled && !this._disableBumpMap && m.setTexture("bumpSampler", this._bumpTexture)), this.getScene().useOrderIndependentTransparency && this.needAlphaBlendingForMesh(i) && this.getScene().depthPeelingRenderer.bind(h), this._eventInfo.subMesh = r, this._callbackPluginEventBindForSubMesh(this._eventInfo), Ar(this._activeEffect, this, c), this.bindEyePosition(h);
            } else
              c.getEngine()._features.needToAlwaysBindUniformBuffers && (this._needToBindSceneUbo = !0);
            !p && this.isFrozen || (c.lightsEnabled && !this._disableLighting && Se.BindLights(c, i, this._activeEffect, u, this._maxSimultaneousLights), (c.fogEnabled && i.applyFog && c.fogMode !== Ue.FOGMODE_NONE || f || this.subSurface.refractionTexture || i.receiveShadows || u.PREPASS) && this.bindView(h), Se.BindFogParameters(c, i, this._activeEffect, !0), u.NUM_MORPH_INFLUENCERS && Se.BindMorphTargetParameters(i, this._activeEffect), u.BAKED_VERTEX_ANIMATION_TEXTURE && ((l = i.bakedVertexAnimationManager) === null || l === void 0 || l.bind(h, u.INSTANCES)), this._imageProcessingConfiguration.bind(this._activeEffect), Se.BindLogDepth(u, this._activeEffect, c)), this._afterBind(i, this._activeEffect), m.update();
          }
        }
      }, t.prototype.getAnimatables = function() {
        var e = n.prototype.getAnimatables.call(this);
        return this._albedoTexture && this._albedoTexture.animations && this._albedoTexture.animations.length > 0 && e.push(this._albedoTexture), this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0 && e.push(this._ambientTexture), this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0 && e.push(this._opacityTexture), this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0 && e.push(this._reflectionTexture), this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0 && e.push(this._emissiveTexture), this._metallicTexture && this._metallicTexture.animations && this._metallicTexture.animations.length > 0 ? e.push(this._metallicTexture) : this._reflectivityTexture && this._reflectivityTexture.animations && this._reflectivityTexture.animations.length > 0 && e.push(this._reflectivityTexture), this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0 && e.push(this._bumpTexture), this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0 && e.push(this._lightmapTexture), this._metallicReflectanceTexture && this._metallicReflectanceTexture.animations && this._metallicReflectanceTexture.animations.length > 0 && e.push(this._metallicReflectanceTexture), this._reflectanceTexture && this._reflectanceTexture.animations && this._reflectanceTexture.animations.length > 0 && e.push(this._reflectanceTexture), this._microSurfaceTexture && this._microSurfaceTexture.animations && this._microSurfaceTexture.animations.length > 0 && e.push(this._microSurfaceTexture), e;
      }, t.prototype._getReflectionTexture = function() {
        return this._reflectionTexture ? this._reflectionTexture : this.getScene().environmentTexture;
      }, t.prototype.getActiveTextures = function() {
        var e = n.prototype.getActiveTextures.call(this);
        return this._albedoTexture && e.push(this._albedoTexture), this._ambientTexture && e.push(this._ambientTexture), this._opacityTexture && e.push(this._opacityTexture), this._reflectionTexture && e.push(this._reflectionTexture), this._emissiveTexture && e.push(this._emissiveTexture), this._reflectivityTexture && e.push(this._reflectivityTexture), this._metallicTexture && e.push(this._metallicTexture), this._metallicReflectanceTexture && e.push(this._metallicReflectanceTexture), this._reflectanceTexture && e.push(this._reflectanceTexture), this._microSurfaceTexture && e.push(this._microSurfaceTexture), this._bumpTexture && e.push(this._bumpTexture), this._lightmapTexture && e.push(this._lightmapTexture), e;
      }, t.prototype.hasTexture = function(e) {
        return !!n.prototype.hasTexture.call(this, e) || this._albedoTexture === e || this._ambientTexture === e || this._opacityTexture === e || this._reflectionTexture === e || this._emissiveTexture === e || this._reflectivityTexture === e || this._metallicTexture === e || this._metallicReflectanceTexture === e || this._reflectanceTexture === e || this._microSurfaceTexture === e || this._bumpTexture === e || this._lightmapTexture === e;
      }, t.prototype.setPrePassRenderer = function() {
        var e;
        if (!(!((e = this.subSurface) === null || e === void 0) && e.isScatteringEnabled))
          return !1;
        var i = this.getScene().enableSubSurfaceForPrePass();
        return i && (i.enabled = !0), !0;
      }, t.prototype.dispose = function(e, i) {
        var r, o, a, s, l, c, u, h, d, p, f, m;
        i && (this._environmentBRDFTexture && this.getScene().environmentBRDFTexture !== this._environmentBRDFTexture && this._environmentBRDFTexture.dispose(), (r = this._albedoTexture) === null || r === void 0 || r.dispose(), (o = this._ambientTexture) === null || o === void 0 || o.dispose(), (a = this._opacityTexture) === null || a === void 0 || a.dispose(), (s = this._reflectionTexture) === null || s === void 0 || s.dispose(), (l = this._emissiveTexture) === null || l === void 0 || l.dispose(), (c = this._metallicTexture) === null || c === void 0 || c.dispose(), (u = this._reflectivityTexture) === null || u === void 0 || u.dispose(), (h = this._bumpTexture) === null || h === void 0 || h.dispose(), (d = this._lightmapTexture) === null || d === void 0 || d.dispose(), (p = this._metallicReflectanceTexture) === null || p === void 0 || p.dispose(), (f = this._reflectanceTexture) === null || f === void 0 || f.dispose(), (m = this._microSurfaceTexture) === null || m === void 0 || m.dispose()), this._renderTargets.dispose(), this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver), n.prototype.dispose.call(this, e, i);
      }, t.PBRMATERIAL_OPAQUE = Et.MATERIAL_OPAQUE, t.PBRMATERIAL_ALPHATEST = Et.MATERIAL_ALPHATEST, t.PBRMATERIAL_ALPHABLEND = Et.MATERIAL_ALPHABLEND, t.PBRMATERIAL_ALPHATESTANDBLEND = Et.MATERIAL_ALPHATESTANDBLEND, t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 0, t.LIGHTFALLOFF_PHYSICAL = 0, t.LIGHTFALLOFF_GLTF = 1, t.LIGHTFALLOFF_STANDARD = 2, x([$s()], t.prototype, "_imageProcessingConfiguration", void 0), x([ye("_markAllSubMeshesAsMiscDirty")], t.prototype, "debugMode", void 0), x([N()], t.prototype, "useLogarithmicDepth", null), t;
    }(pl), Yh = function(n) {
      function t(e, i) {
        var r = n.call(this, e, i) || this;
        return r.directIntensity = 1, r.emissiveIntensity = 1, r.environmentIntensity = 1, r.specularIntensity = 1, r.disableBumpMap = !1, r.ambientTextureStrength = 1, r.ambientTextureImpactOnAnalyticalLights = t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS, r.metallicF0Factor = 1, r.metallicReflectanceColor = ne.White(), r.useOnlyMetallicFromMetallicReflectanceTexture = !1, r.ambientColor = new ne(0, 0, 0), r.albedoColor = new ne(1, 1, 1), r.reflectivityColor = new ne(1, 1, 1), r.reflectionColor = new ne(1, 1, 1), r.emissiveColor = new ne(0, 0, 0), r.microSurface = 1, r.useLightmapAsShadowmap = !1, r.useAlphaFromAlbedoTexture = !1, r.forceAlphaTest = !1, r.alphaCutOff = 0.4, r.useSpecularOverAlpha = !0, r.useMicroSurfaceFromReflectivityMapAlpha = !1, r.useRoughnessFromMetallicTextureAlpha = !0, r.useRoughnessFromMetallicTextureGreen = !1, r.useMetallnessFromMetallicTextureBlue = !1, r.useAmbientOcclusionFromMetallicTextureRed = !1, r.useAmbientInGrayScale = !1, r.useAutoMicroSurfaceFromReflectivityMap = !1, r.useRadianceOverAlpha = !0, r.useObjectSpaceNormalMap = !1, r.useParallax = !1, r.useParallaxOcclusion = !1, r.parallaxScaleBias = 0.05, r.disableLighting = !1, r.forceIrradianceInFragment = !1, r.maxSimultaneousLights = 4, r.invertNormalMapX = !1, r.invertNormalMapY = !1, r.twoSidedLighting = !1, r.useAlphaFresnel = !1, r.useLinearAlphaFresnel = !1, r.environmentBRDFTexture = null, r.forceNormalForward = !1, r.enableSpecularAntiAliasing = !1, r.useHorizonOcclusion = !0, r.useRadianceOcclusion = !0, r.unlit = !1, r.applyDecalMapAfterDetailMap = !1, r._environmentBRDFTexture = Yc(r.getScene()), r;
      }
      return D(t, n), Object.defineProperty(t.prototype, "refractionTexture", { get: function() {
        return this.subSurface.refractionTexture;
      }, set: function(e) {
        this.subSurface.refractionTexture = e, e ? this.subSurface.isRefractionEnabled = !0 : this.subSurface.linkRefractionWithTransparency || (this.subSurface.isRefractionEnabled = !1);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "indexOfRefraction", { get: function() {
        return this.subSurface.indexOfRefraction;
      }, set: function(e) {
        this.subSurface.indexOfRefraction = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "invertRefractionY", { get: function() {
        return this.subSurface.invertRefractionY;
      }, set: function(e) {
        this.subSurface.invertRefractionY = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "linkRefractionWithTransparency", { get: function() {
        return this.subSurface.linkRefractionWithTransparency;
      }, set: function(e) {
        this.subSurface.linkRefractionWithTransparency = e, e && (this.subSurface.isRefractionEnabled = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "usePhysicalLightFalloff", { get: function() {
        return this._lightFalloff === Si.LIGHTFALLOFF_PHYSICAL;
      }, set: function(e) {
        e !== this.usePhysicalLightFalloff && (this._markAllSubMeshesAsTexturesDirty(), this._lightFalloff = e ? Si.LIGHTFALLOFF_PHYSICAL : Si.LIGHTFALLOFF_STANDARD);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "useGLTFLightFalloff", { get: function() {
        return this._lightFalloff === Si.LIGHTFALLOFF_GLTF;
      }, set: function(e) {
        e !== this.useGLTFLightFalloff && (this._markAllSubMeshesAsTexturesDirty(), this._lightFalloff = e ? Si.LIGHTFALLOFF_GLTF : Si.LIGHTFALLOFF_STANDARD);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "imageProcessingConfiguration", { get: function() {
        return this._imageProcessingConfiguration;
      }, set: function(e) {
        this._attachImageProcessingConfiguration(e), this._markAllSubMeshesAsTexturesDirty();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraColorCurvesEnabled", { get: function() {
        return this.imageProcessingConfiguration.colorCurvesEnabled;
      }, set: function(e) {
        this.imageProcessingConfiguration.colorCurvesEnabled = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraColorGradingEnabled", { get: function() {
        return this.imageProcessingConfiguration.colorGradingEnabled;
      }, set: function(e) {
        this.imageProcessingConfiguration.colorGradingEnabled = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraToneMappingEnabled", { get: function() {
        return this._imageProcessingConfiguration.toneMappingEnabled;
      }, set: function(e) {
        this._imageProcessingConfiguration.toneMappingEnabled = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraExposure", { get: function() {
        return this._imageProcessingConfiguration.exposure;
      }, set: function(e) {
        this._imageProcessingConfiguration.exposure = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraContrast", { get: function() {
        return this._imageProcessingConfiguration.contrast;
      }, set: function(e) {
        this._imageProcessingConfiguration.contrast = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraColorGradingTexture", { get: function() {
        return this._imageProcessingConfiguration.colorGradingTexture;
      }, set: function(e) {
        this._imageProcessingConfiguration.colorGradingTexture = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraColorCurves", { get: function() {
        return this._imageProcessingConfiguration.colorCurves;
      }, set: function(e) {
        this._imageProcessingConfiguration.colorCurves = e;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "PBRMaterial";
      }, t.prototype.clone = function(e, i, r) {
        var o = this;
        i === void 0 && (i = !0), r === void 0 && (r = "");
        var a = Ne.Clone(function() {
          return new t(e, o.getScene());
        }, this, { cloneTexturesOnlyOnce: i });
        return a.id = e, a.name = e, this.stencil.copyTo(a.stencil), this._clonePlugins(a, r), a;
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.customType = "BABYLON.PBRMaterial", e;
      }, t.Parse = function(e, i, r) {
        var o = Ne.Parse(function() {
          return new t(e.name, i);
        }, e, i, r);
        return e.stencil && o.stencil.parse(e.stencil, i, r), Et._parsePlugins(e, o, i, r), e.clearCoat && o.clearCoat.parse(e.clearCoat, i, r), e.anisotropy && o.anisotropy.parse(e.anisotropy, i, r), e.brdf && o.brdf.parse(e.brdf, i, r), e.sheen && o.sheen.parse(e.sheen, i, r), e.subSurface && o.subSurface.parse(e.subSurface, i, r), e.iridescence && o.iridescence.parse(e.iridescence, i, r), o;
      }, t.PBRMATERIAL_OPAQUE = Si.PBRMATERIAL_OPAQUE, t.PBRMATERIAL_ALPHATEST = Si.PBRMATERIAL_ALPHATEST, t.PBRMATERIAL_ALPHABLEND = Si.PBRMATERIAL_ALPHABLEND, t.PBRMATERIAL_ALPHATESTANDBLEND = Si.PBRMATERIAL_ALPHATESTANDBLEND, t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = Si.DEFAULT_AO_ON_ANALYTICAL_LIGHTS, x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "directIntensity", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveIntensity", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "environmentIntensity", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "specularIntensity", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "disableBumpMap", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "albedoTexture", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientTexture", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientTextureStrength", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientTextureImpactOnAnalyticalLights", void 0), x([St(), ye("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "opacityTexture", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionTexture", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveTexture", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectivityTexture", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallicTexture", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallic", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "roughness", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallicF0Factor", void 0), x([ri(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallicReflectanceColor", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useOnlyMetallicFromMetallicReflectanceTexture", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallicReflectanceTexture", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectanceTexture", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "microSurfaceTexture", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "bumpTexture", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty", null)], t.prototype, "lightmapTexture", void 0), x([ri("ambient"), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientColor", void 0), x([ri("albedo"), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "albedoColor", void 0), x([ri("reflectivity"), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectivityColor", void 0), x([ri("reflection"), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionColor", void 0), x([ri("emissive"), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveColor", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "microSurface", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useLightmapAsShadowmap", void 0), x([N(), ye("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "useAlphaFromAlbedoTexture", void 0), x([N(), ye("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "forceAlphaTest", void 0), x([N(), ye("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "alphaCutOff", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useSpecularOverAlpha", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useMicroSurfaceFromReflectivityMapAlpha", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRoughnessFromMetallicTextureAlpha", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRoughnessFromMetallicTextureGreen", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useMetallnessFromMetallicTextureBlue", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useAmbientOcclusionFromMetallicTextureRed", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useAmbientInGrayScale", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useAutoMicroSurfaceFromReflectivityMap", void 0), x([N()], t.prototype, "usePhysicalLightFalloff", null), x([N()], t.prototype, "useGLTFLightFalloff", null), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRadianceOverAlpha", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useObjectSpaceNormalMap", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useParallax", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useParallaxOcclusion", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "parallaxScaleBias", void 0), x([N(), ye("_markAllSubMeshesAsLightsDirty")], t.prototype, "disableLighting", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "forceIrradianceInFragment", void 0), x([N(), ye("_markAllSubMeshesAsLightsDirty")], t.prototype, "maxSimultaneousLights", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapX", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapY", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "twoSidedLighting", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useAlphaFresnel", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useLinearAlphaFresnel", void 0), x([ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "environmentBRDFTexture", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "forceNormalForward", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "enableSpecularAntiAliasing", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useHorizonOcclusion", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRadianceOcclusion", void 0), x([N(), ye("_markAllSubMeshesAsMiscDirty")], t.prototype, "unlit", void 0), x([N(), ye("_markAllSubMeshesAsMiscDirty")], t.prototype, "applyDecalMapAfterDetailMap", void 0), t;
    }(Si);
    j("BABYLON.PBRMaterial", Yh);
    var VC = 131072, kC = 131072;
    function h_(n) {
      return n.charCodeAt(0) + (n.charCodeAt(1) << 8) + (n.charCodeAt(2) << 16) + (n.charCodeAt(3) << 24);
    }
    var GC = h_("DXT1"), zC = h_("DXT3"), WC = h_("DXT5"), by = h_("DX10"), Ka = function() {
      function n() {
      }
      return n.GetDDSInfo = function(t) {
        var e = new Int32Array(t.buffer, t.byteOffset, 31), i = new Int32Array(t.buffer, t.byteOffset, 35), r = 1;
        e[2] & VC && (r = Math.max(1, e[7]));
        var o = e[21], a = o === by ? i[32] : 0, s = _.TEXTURETYPE_UNSIGNED_INT;
        switch (o) {
          case 113:
            s = _.TEXTURETYPE_HALF_FLOAT;
            break;
          case 116:
            s = _.TEXTURETYPE_FLOAT;
            break;
          case by:
            if (a === 10) {
              s = _.TEXTURETYPE_HALF_FLOAT;
              break;
            }
            if (a === 2) {
              s = _.TEXTURETYPE_FLOAT;
              break;
            }
        }
        return { width: e[4], height: e[3], mipmapCount: r, isFourCC: (4 & e[20]) == 4, isRGB: (64 & e[20]) == 64, isLuminance: (e[20] & kC) === kC, isCube: (512 & e[28]) == 512, isCompressed: o === GC || o === zC || o === WC, dxgiFormat: a, textureType: s };
      }, n._GetHalfFloatAsFloatRGBAArrayBuffer = function(t, e, i, r, o, a) {
        for (var s = new Float32Array(r), l = new Uint16Array(o, i), c = 0, u = 0; u < e; u++)
          for (var h = 0; h < t; h++) {
            var d = 4 * (h + u * t);
            s[c] = io(l[d]), s[c + 1] = io(l[d + 1]), s[c + 2] = io(l[d + 2]), n.StoreLODInAlphaChannel ? s[c + 3] = a : s[c + 3] = io(l[d + 3]), c += 4;
          }
        return s;
      }, n._GetHalfFloatRGBAArrayBuffer = function(t, e, i, r, o, a) {
        if (n.StoreLODInAlphaChannel) {
          for (var s = new Uint16Array(r), l = new Uint16Array(o, i), c = 0, u = 0; u < e; u++)
            for (var h = 0; h < t; h++) {
              var d = 4 * (h + u * t);
              s[c] = l[d], s[c + 1] = l[d + 1], s[c + 2] = l[d + 2], s[c + 3] = to(a), c += 4;
            }
          return s;
        }
        return new Uint16Array(o, i, r);
      }, n._GetFloatRGBAArrayBuffer = function(t, e, i, r, o, a) {
        if (n.StoreLODInAlphaChannel) {
          for (var s = new Float32Array(r), l = new Float32Array(o, i), c = 0, u = 0; u < e; u++)
            for (var h = 0; h < t; h++) {
              var d = 4 * (h + u * t);
              s[c] = l[d], s[c + 1] = l[d + 1], s[c + 2] = l[d + 2], s[c + 3] = a, c += 4;
            }
          return s;
        }
        return new Float32Array(o, i, r);
      }, n._GetFloatAsHalfFloatRGBAArrayBuffer = function(t, e, i, r, o, a) {
        for (var s = new Uint16Array(r), l = new Float32Array(o, i), c = 0, u = 0; u < e; u++)
          for (var h = 0; h < t; h++)
            s[c] = to(l[c]), s[c + 1] = to(l[c + 1]), s[c + 2] = to(l[c + 2]), n.StoreLODInAlphaChannel ? s[c + 3] = to(a) : s[c + 3] = to(l[c + 3]), c += 4;
        return s;
      }, n._GetFloatAsUIntRGBAArrayBuffer = function(t, e, i, r, o, a) {
        for (var s = new Uint8Array(r), l = new Float32Array(o, i), c = 0, u = 0; u < e; u++)
          for (var h = 0; h < t; h++) {
            var d = 4 * (h + u * t);
            s[c] = 255 * ue.Clamp(l[d]), s[c + 1] = 255 * ue.Clamp(l[d + 1]), s[c + 2] = 255 * ue.Clamp(l[d + 2]), n.StoreLODInAlphaChannel ? s[c + 3] = a : s[c + 3] = 255 * ue.Clamp(l[d + 3]), c += 4;
          }
        return s;
      }, n._GetHalfFloatAsUIntRGBAArrayBuffer = function(t, e, i, r, o, a) {
        for (var s = new Uint8Array(r), l = new Uint16Array(o, i), c = 0, u = 0; u < e; u++)
          for (var h = 0; h < t; h++) {
            var d = 4 * (h + u * t);
            s[c] = 255 * ue.Clamp(io(l[d])), s[c + 1] = 255 * ue.Clamp(io(l[d + 1])), s[c + 2] = 255 * ue.Clamp(io(l[d + 2])), n.StoreLODInAlphaChannel ? s[c + 3] = a : s[c + 3] = 255 * ue.Clamp(io(l[d + 3])), c += 4;
          }
        return s;
      }, n._GetRGBAArrayBuffer = function(t, e, i, r, o, a, s, l, c) {
        for (var u = new Uint8Array(r), h = new Uint8Array(o, i), d = 0, p = 0; p < e; p++)
          for (var f = 0; f < t; f++) {
            var m = 4 * (f + p * t);
            u[d] = h[m + a], u[d + 1] = h[m + s], u[d + 2] = h[m + l], u[d + 3] = h[m + c], d += 4;
          }
        return u;
      }, n._ExtractLongWordOrder = function(t) {
        return t === 0 || t === 255 || t === -16777216 ? 0 : 1 + n._ExtractLongWordOrder(t >> 8);
      }, n._GetRGBArrayBuffer = function(t, e, i, r, o, a, s, l) {
        for (var c = new Uint8Array(r), u = new Uint8Array(o, i), h = 0, d = 0; d < e; d++)
          for (var p = 0; p < t; p++) {
            var f = 3 * (p + d * t);
            c[h] = u[f + a], c[h + 1] = u[f + s], c[h + 2] = u[f + l], h += 3;
          }
        return c;
      }, n._GetLuminanceArrayBuffer = function(t, e, i, r, o) {
        for (var a = new Uint8Array(r), s = new Uint8Array(o, i), l = 0, c = 0; c < e; c++)
          for (var u = 0; u < t; u++) {
            var h = u + c * t;
            a[l] = s[h], l++;
          }
        return a;
      }, n.UploadDDSLevels = function(t, e, i, r, o, a, s, l, c) {
        s === void 0 && (s = -1), c === void 0 && (c = !0);
        var u = null;
        r.sphericalPolynomial && (u = []);
        var h = !!t.getCaps().s3tc;
        e.generateMipMaps = o;
        var d, p, f, m, g, y, b, T = new Int32Array(i.buffer, i.byteOffset, 31), S = 0, E = 0, A = 1;
        if (T[0] === 542327876)
          if (r.isFourCC || r.isRGB || r.isLuminance)
            if (!r.isCompressed || h) {
              var R = T[22];
              m = T[1] + 4;
              var C, L = !1;
              if (r.isFourCC)
                switch (d = T[21]) {
                  case GC:
                    A = 8, E = _.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1;
                    break;
                  case zC:
                    A = 16, E = _.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3;
                    break;
                  case WC:
                    A = 16, E = _.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5;
                    break;
                  case 113:
                    L = !0, R = 64;
                    break;
                  case 116:
                    L = !0, R = 128;
                    break;
                  case by:
                    m += 20;
                    var I = !1;
                    switch (r.dxgiFormat) {
                      case 10:
                        L = !0, R = 64, I = !0;
                        break;
                      case 2:
                        L = !0, R = 128, I = !0;
                        break;
                      case 88:
                        r.isRGB = !0, r.isFourCC = !1, R = 32, I = !0;
                    }
                    if (I)
                      break;
                  default:
                    return void console.error("Unsupported FourCC code:", (C = d, String.fromCharCode(255 & C, C >> 8 & 255, C >> 16 & 255, C >> 24 & 255)));
                }
              var O = n._ExtractLongWordOrder(T[23]), w = n._ExtractLongWordOrder(T[24]), z = n._ExtractLongWordOrder(T[25]), V = n._ExtractLongWordOrder(T[26]);
              L && (E = t._getRGBABufferInternalSizedFormat(r.textureType)), y = 1, T[2] & VC && o !== !1 && (y = Math.max(1, T[7]));
              for (var Y = l || 0, ee = t.getCaps(), J = Y; J < a; J++) {
                for (p = T[4], f = T[3], b = 0; b < y; ++b) {
                  if (s === -1 || s === b) {
                    var X = s === -1 ? b : 0;
                    if (!r.isCompressed && r.isFourCC) {
                      e.format = _.TEXTUREFORMAT_RGBA, S = p * f * 4;
                      var K = null;
                      if (t._badOS || t._badDesktopOS || !ee.textureHalfFloat && !ee.textureFloat)
                        R === 128 ? (K = n._GetFloatAsUIntRGBAArrayBuffer(p, f, i.byteOffset + m, S, i.buffer, X), u && X == 0 && u.push(n._GetFloatRGBAArrayBuffer(p, f, i.byteOffset + m, S, i.buffer, X))) : R === 64 && (K = n._GetHalfFloatAsUIntRGBAArrayBuffer(p, f, i.byteOffset + m, S, i.buffer, X), u && X == 0 && u.push(n._GetHalfFloatAsFloatRGBAArrayBuffer(p, f, i.byteOffset + m, S, i.buffer, X))), e.type = _.TEXTURETYPE_UNSIGNED_INT;
                      else {
                        var te = ee.textureFloat && (c && ee.textureFloatLinearFiltering || !c), se = ee.textureHalfFloat && (c && ee.textureHalfFloatLinearFiltering || !c), _e = (R === 128 || R === 64 && !se) && te ? _.TEXTURETYPE_FLOAT : (R === 64 || R === 128 && !te) && se ? _.TEXTURETYPE_HALF_FLOAT : _.TEXTURETYPE_UNSIGNED_BYTE, xe = void 0, Te = null;
                        if (R === 128)
                          switch (_e) {
                            case _.TEXTURETYPE_FLOAT:
                              xe = n._GetFloatRGBAArrayBuffer, Te = null;
                              break;
                            case _.TEXTURETYPE_HALF_FLOAT:
                              xe = n._GetFloatAsHalfFloatRGBAArrayBuffer, Te = n._GetFloatRGBAArrayBuffer;
                              break;
                            case _.TEXTURETYPE_UNSIGNED_BYTE:
                              xe = n._GetFloatAsUIntRGBAArrayBuffer, Te = n._GetFloatRGBAArrayBuffer;
                          }
                        else
                          switch (_e) {
                            case _.TEXTURETYPE_FLOAT:
                              xe = n._GetHalfFloatAsFloatRGBAArrayBuffer, Te = null;
                              break;
                            case _.TEXTURETYPE_HALF_FLOAT:
                              xe = n._GetHalfFloatRGBAArrayBuffer, Te = n._GetHalfFloatAsFloatRGBAArrayBuffer;
                              break;
                            case _.TEXTURETYPE_UNSIGNED_BYTE:
                              xe = n._GetHalfFloatAsUIntRGBAArrayBuffer, Te = n._GetHalfFloatAsFloatRGBAArrayBuffer;
                          }
                        e.type = _e, K = xe(p, f, i.byteOffset + m, S, i.buffer, X), u && X == 0 && u.push(Te ? Te(p, f, i.byteOffset + m, S, i.buffer, X) : K);
                      }
                      K && t._uploadDataToTextureDirectly(e, K, J, X);
                    } else if (r.isRGB)
                      e.type = _.TEXTURETYPE_UNSIGNED_INT, R === 24 ? (e.format = _.TEXTUREFORMAT_RGB, S = p * f * 3, g = n._GetRGBArrayBuffer(p, f, i.byteOffset + m, S, i.buffer, O, w, z), t._uploadDataToTextureDirectly(e, g, J, X)) : (e.format = _.TEXTUREFORMAT_RGBA, S = p * f * 4, g = n._GetRGBAArrayBuffer(p, f, i.byteOffset + m, S, i.buffer, O, w, z, V), t._uploadDataToTextureDirectly(e, g, J, X));
                    else if (r.isLuminance) {
                      var he = t._getUnpackAlignement(), me = p;
                      S = Math.floor((p + he - 1) / he) * he * (f - 1) + me, g = n._GetLuminanceArrayBuffer(p, f, i.byteOffset + m, S, i.buffer), e.format = _.TEXTUREFORMAT_LUMINANCE, e.type = _.TEXTURETYPE_UNSIGNED_INT, t._uploadDataToTextureDirectly(e, g, J, X);
                    } else
                      S = Math.max(4, p) / 4 * Math.max(4, f) / 4 * A, g = new Uint8Array(i.buffer, i.byteOffset + m, S), e.type = _.TEXTURETYPE_UNSIGNED_INT, t._uploadCompressedDataToTextureDirectly(e, E, p, f, g, J, X);
                  }
                  m += R ? p * f * (R / 8) : S, p *= 0.5, f *= 0.5, p = Math.max(1, p), f = Math.max(1, f);
                }
                if (l !== void 0)
                  break;
              }
              u && u.length > 0 ? r.sphericalPolynomial = Nh.ConvertCubeMapToSphericalPolynomial({ size: T[4], right: u[0], left: u[1], up: u[2], down: u[3], front: u[4], back: u[5], format: _.TEXTUREFORMAT_RGBA, type: _.TEXTURETYPE_FLOAT, gammaSpace: !1 }) : r.sphericalPolynomial = void 0;
            } else
              q.Error("Compressed textures are not supported on this platform.");
          else
            q.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");
        else
          q.Error("Invalid magic number in DDS header");
      }, n.StoreLODInAlphaChannel = !1, n;
    }();
    Qe.prototype.createPrefilteredCubeTexture = function(n, t, e, i, r, o, a, s, l) {
      var c = this;
      return r === void 0 && (r = null), o === void 0 && (o = null), s === void 0 && (s = null), l === void 0 && (l = !0), this.createCubeTexture(n, t, null, !1, function(u) {
        if (u) {
          var h = u.texture;
          if (l ? u.info.sphericalPolynomial && (h._sphericalPolynomial = u.info.sphericalPolynomial) : h._sphericalPolynomial = new Sl(), h._source = ut.CubePrefiltered, c.getCaps().textureLOD)
            r && r(h);
          else {
            var d = c._gl, p = u.width;
            if (p) {
              for (var f = [], m = 0; m < 3; m++) {
                var g = 1 - m / 2, y = i, b = ue.Log2(p) * e + i, T = y + (b - y) * g, S = Math.round(Math.min(Math.max(T, 0), b)), E = new Ut(c, ut.Temp);
                if (E.type = h.type, E.format = h.format, E.width = Math.pow(2, Math.max(ue.Log2(p) - S, 0)), E.height = E.width, E.isCube = !0, E._cachedWrapU = _.TEXTURE_CLAMP_ADDRESSMODE, E._cachedWrapV = _.TEXTURE_CLAMP_ADDRESSMODE, c._bindTextureDirectly(d.TEXTURE_CUBE_MAP, E, !0), E.samplingMode = _.TEXTURE_LINEAR_LINEAR, d.texParameteri(d.TEXTURE_CUBE_MAP, d.TEXTURE_MAG_FILTER, d.LINEAR), d.texParameteri(d.TEXTURE_CUBE_MAP, d.TEXTURE_MIN_FILTER, d.LINEAR), d.texParameteri(d.TEXTURE_CUBE_MAP, d.TEXTURE_WRAP_S, d.CLAMP_TO_EDGE), d.texParameteri(d.TEXTURE_CUBE_MAP, d.TEXTURE_WRAP_T, d.CLAMP_TO_EDGE), u.isDDS) {
                  var A = u.info, R = u.data;
                  c._unpackFlipY(A.isCompressed), Ka.UploadDDSLevels(c, E, R, A, !0, 6, S);
                } else
                  q.Warn("DDS is the only prefiltered cube map supported so far.");
                c._bindTextureDirectly(d.TEXTURE_CUBE_MAP, null);
                var C = new Vn(t);
                C._isCube = !0, C._texture = E, E.isReady = !0, f.push(C);
              }
              h._lodTextureHigh = f[2], h._lodTextureMid = f[1], h._lodTextureLow = f[0], r && r(h);
            }
          }
        } else
          r && r(null);
      }, o, a, s, l, e, i);
    };
    var Ty = function() {
      function n() {
        this.supportCascades = !0;
      }
      return n.prototype.canLoad = function(t) {
        return t.endsWith(".dds");
      }, n.prototype.loadCubeData = function(t, e, i, r) {
        var o, a = e.getEngine(), s = !1, l = 1e3;
        if (Array.isArray(t))
          for (var c = 0; c < t.length; c++) {
            var u = t[c];
            o = Ka.GetDDSInfo(u), e.width = o.width, e.height = o.height, s = (o.isRGB || o.isLuminance || o.mipmapCount > 1) && e.generateMipMaps, a._unpackFlipY(o.isCompressed), Ka.UploadDDSLevels(a, e, u, o, s, 6, -1, c), o.isFourCC || o.mipmapCount !== 1 ? l = o.mipmapCount - 1 : a.generateMipMapsForCubemap(e);
          }
        else
          u = t, o = Ka.GetDDSInfo(u), e.width = o.width, e.height = o.height, i && (o.sphericalPolynomial = new Sl()), s = (o.isRGB || o.isLuminance || o.mipmapCount > 1) && e.generateMipMaps, a._unpackFlipY(o.isCompressed), Ka.UploadDDSLevels(a, e, u, o, s, 6), o.isFourCC || o.mipmapCount !== 1 ? l = o.mipmapCount - 1 : a.generateMipMapsForCubemap(e, !1);
        a._setCubeMapTextureParams(e, s, l), e.isReady = !0, e.onLoadedObservable.notifyObservers(e), e.onLoadedObservable.clear(), r && r({ isDDS: !0, width: e.width, info: o, data: t, texture: e });
      }, n.prototype.loadData = function(t, e, i) {
        var r = Ka.GetDDSInfo(t), o = (r.isRGB || r.isLuminance || r.mipmapCount > 1) && e.generateMipMaps && r.width >> r.mipmapCount - 1 == 1;
        i(r.width, r.height, o, r.isFourCC, function() {
          Ka.UploadDDSLevels(e.getEngine(), e, t, r, o, 1);
        });
      }, n;
    }();
    ve._TextureLoaders.push(new Ty());
    var Ey = function() {
      function n() {
        this.supportCascades = !1;
      }
      return n.prototype.canLoad = function(t) {
        return t.endsWith(".env");
      }, n.prototype.loadCubeData = function(t, e, i, r, o) {
        if (!Array.isArray(t)) {
          var a = Lh(t);
          if (a) {
            e.width = a.width, e.height = a.width;
            try {
              Bh(e, a), Uf(e, t, a).then(function() {
                e.isReady = !0, e.onLoadedObservable.notifyObservers(e), e.onLoadedObservable.clear(), r && r();
              }, function(s) {
                o == null || o("Can not upload environment levels", s);
              });
            } catch (s) {
              o == null || o("Can not upload environment file", s);
            }
          } else
            o && o("Can not parse the environment file", null);
        }
      }, n.prototype.loadData = function() {
        throw ".env not supported in 2d.";
      }, n;
    }();
    ve._TextureLoaders.push(new Ey());
    var d_, Rl, Kh, qh = function() {
      function n(t, e) {
        if (this.data = t, this.isInvalid = !1, !n.IsValid(t))
          return this.isInvalid = !0, void q.Error("texture missing KTX identifier");
        var i = Uint32Array.BYTES_PER_ELEMENT, r = new DataView(this.data.buffer, this.data.byteOffset + 12, 13 * i), o = r.getUint32(0, !0) === 67305985;
        return this.glType = r.getUint32(1 * i, o), this.glTypeSize = r.getUint32(2 * i, o), this.glFormat = r.getUint32(3 * i, o), this.glInternalFormat = r.getUint32(4 * i, o), this.glBaseInternalFormat = r.getUint32(5 * i, o), this.pixelWidth = r.getUint32(6 * i, o), this.pixelHeight = r.getUint32(7 * i, o), this.pixelDepth = r.getUint32(8 * i, o), this.numberOfArrayElements = r.getUint32(9 * i, o), this.numberOfFaces = r.getUint32(10 * i, o), this.numberOfMipmapLevels = r.getUint32(11 * i, o), this.bytesOfKeyValueData = r.getUint32(12 * i, o), this.glType !== 0 ? (q.Error("only compressed formats currently supported"), void (this.isInvalid = !0)) : (this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels), this.pixelHeight === 0 || this.pixelDepth !== 0 ? (q.Error("only 2D textures currently supported"), void (this.isInvalid = !0)) : this.numberOfArrayElements !== 0 ? (q.Error("texture arrays not currently supported"), void (this.isInvalid = !0)) : this.numberOfFaces !== e ? (q.Error("number of faces expected" + e + ", but found " + this.numberOfFaces), void (this.isInvalid = !0)) : void (this.loadType = n.COMPRESSED_2D));
      }
      return n.prototype.uploadLevels = function(t, e) {
        switch (this.loadType) {
          case n.COMPRESSED_2D:
            this._upload2DCompressedLevels(t, e);
          case n.TEX_2D:
          case n.COMPRESSED_3D:
          case n.TEX_3D:
        }
      }, n.prototype._upload2DCompressedLevels = function(t, e) {
        for (var i = n.HEADER_LEN + this.bytesOfKeyValueData, r = this.pixelWidth, o = this.pixelHeight, a = e ? this.numberOfMipmapLevels : 1, s = 0; s < a; s++) {
          var l = new Int32Array(this.data.buffer, this.data.byteOffset + i, 1)[0];
          i += 4;
          for (var c = 0; c < this.numberOfFaces; c++) {
            var u = new Uint8Array(this.data.buffer, this.data.byteOffset + i, l);
            t.getEngine()._uploadCompressedDataToTextureDirectly(t, t.format, r, o, u, c, s), i += l, i += 3 - (l + 3) % 4;
          }
          r = Math.max(1, 0.5 * r), o = Math.max(1, 0.5 * o);
        }
      }, n.IsValid = function(t) {
        if (t.byteLength >= 12) {
          var e = new Uint8Array(t.buffer, t.byteOffset, 12);
          if (e[0] === 171 && e[1] === 75 && e[2] === 84 && e[3] === 88 && e[4] === 32 && e[5] === 49 && e[6] === 49 && e[7] === 187 && e[8] === 13 && e[9] === 10 && e[10] === 26 && e[11] === 10)
            return !0;
        }
        return !1;
      }, n.HEADER_LEN = 64, n.COMPRESSED_2D = 0, n.COMPRESSED_3D = 1, n.TEX_2D = 2, n.TEX_3D = 3, n;
    }(), Sy = function() {
      function n(t) {
        this._pendingActions = new Array(), this._workerInfos = t.map(function(e) {
          return { workerPromise: Promise.resolve(e), idle: !0 };
        });
      }
      return n.prototype.dispose = function() {
        for (var t = 0, e = this._workerInfos; t < e.length; t++)
          e[t].workerPromise.then(function(i) {
            i.terminate();
          });
        this._workerInfos.length = 0, this._pendingActions.length = 0;
      }, n.prototype.push = function(t) {
        this._executeOnIdleWorker(t) || this._pendingActions.push(t);
      }, n.prototype._executeOnIdleWorker = function(t) {
        for (var e = 0, i = this._workerInfos; e < i.length; e++) {
          var r = i[e];
          if (r.idle)
            return this._execute(r, t), !0;
        }
        return !1;
      }, n.prototype._execute = function(t, e) {
        var i = this;
        t.idle = !1, t.workerPromise.then(function(r) {
          e(r, function() {
            var o = i._pendingActions.shift();
            o ? i._execute(t, o) : t.idle = !0;
          });
        });
      }, n;
    }(), p_ = function(n) {
      function t(e, i, r) {
        r === void 0 && (r = t.DefaultOptions);
        var o = n.call(this, []) || this;
        return o._maxWorkers = e, o._createWorkerAsync = i, o._options = r, o;
      }
      return D(t, n), t.prototype.push = function(e) {
        if (!this._executeOnIdleWorker(e))
          if (this._workerInfos.length < this._maxWorkers) {
            var i = { workerPromise: this._createWorkerAsync(), idle: !1 };
            this._workerInfos.push(i), this._execute(i, e);
          } else
            this._pendingActions.push(e);
      }, t.prototype._execute = function(e, i) {
        var r = this;
        e.timeoutId && (clearTimeout(e.timeoutId), delete e.timeoutId), n.prototype._execute.call(this, e, function(o, a) {
          i(o, function() {
            a(), e.idle && (e.timeoutId = setTimeout(function() {
              e.workerPromise.then(function(l) {
                l.terminate();
              });
              var s = r._workerInfos.indexOf(e);
              s !== -1 && r._workerInfos.splice(s, 1);
            }, r._options.idleTimeElapsedBeforeRelease));
          });
        });
      }, t.DefaultOptions = { idleTimeElapsedBeforeRelease: 1e3 }, t;
    }(Sy);
    function xy(n) {
      n.wasmUASTCToASTC && (KTX2DECODER.LiteTranscoder_UASTC_ASTC.WasmModuleURL = n.wasmUASTCToASTC), n.wasmUASTCToBC7 && (KTX2DECODER.LiteTranscoder_UASTC_BC7.WasmModuleURL = n.wasmUASTCToBC7), n.wasmUASTCToRGBA_UNORM && (KTX2DECODER.LiteTranscoder_UASTC_RGBA_UNORM.WasmModuleURL = n.wasmUASTCToRGBA_UNORM), n.wasmUASTCToRGBA_SRGB && (KTX2DECODER.LiteTranscoder_UASTC_RGBA_SRGB.WasmModuleURL = n.wasmUASTCToRGBA_SRGB), n.wasmUASTCToR8_UNORM && (KTX2DECODER.LiteTranscoder_UASTC_R8_UNORM.WasmModuleURL = n.wasmUASTCToR8_UNORM), n.wasmUASTCToRG8_UNORM && (KTX2DECODER.LiteTranscoder_UASTC_RG8_UNORM.WasmModuleURL = n.wasmUASTCToRG8_UNORM), n.jsMSCTranscoder && (KTX2DECODER.MSCTranscoder.JSModuleURL = n.jsMSCTranscoder), n.wasmMSCTranscoder && (KTX2DECODER.MSCTranscoder.WasmModuleURL = n.wasmMSCTranscoder), n.wasmZSTDDecoder && (KTX2DECODER.ZSTDDecoder.WasmModuleURL = n.wasmZSTDDecoder);
    }
    (function(n) {
      n[n.ETC1S = 0] = "ETC1S", n[n.UASTC4x4 = 1] = "UASTC4x4";
    })(d_ || (d_ = {})), function(n) {
      n[n.ASTC_4X4_RGBA = 0] = "ASTC_4X4_RGBA", n[n.BC7_RGBA = 1] = "BC7_RGBA", n[n.BC3_RGBA = 2] = "BC3_RGBA", n[n.BC1_RGB = 3] = "BC1_RGB", n[n.PVRTC1_4_RGBA = 4] = "PVRTC1_4_RGBA", n[n.PVRTC1_4_RGB = 5] = "PVRTC1_4_RGB", n[n.ETC2_RGBA = 6] = "ETC2_RGBA", n[n.ETC1_RGB = 7] = "ETC1_RGB", n[n.RGBA32 = 8] = "RGBA32", n[n.R8 = 9] = "R8", n[n.RG8 = 10] = "RG8";
    }(Rl || (Rl = {})), function(n) {
      n[n.COMPRESSED_RGBA_BPTC_UNORM_EXT = 36492] = "COMPRESSED_RGBA_BPTC_UNORM_EXT", n[n.COMPRESSED_RGBA_ASTC_4X4_KHR = 37808] = "COMPRESSED_RGBA_ASTC_4X4_KHR", n[n.COMPRESSED_RGB_S3TC_DXT1_EXT = 33776] = "COMPRESSED_RGB_S3TC_DXT1_EXT", n[n.COMPRESSED_RGBA_S3TC_DXT5_EXT = 33779] = "COMPRESSED_RGBA_S3TC_DXT5_EXT", n[n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 35842] = "COMPRESSED_RGBA_PVRTC_4BPPV1_IMG", n[n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 35840] = "COMPRESSED_RGB_PVRTC_4BPPV1_IMG", n[n.COMPRESSED_RGBA8_ETC2_EAC = 37496] = "COMPRESSED_RGBA8_ETC2_EAC", n[n.COMPRESSED_RGB8_ETC2 = 37492] = "COMPRESSED_RGB8_ETC2", n[n.COMPRESSED_RGB_ETC1_WEBGL = 36196] = "COMPRESSED_RGB_ETC1_WEBGL", n[n.RGBA8Format = 32856] = "RGBA8Format", n[n.R8Format = 33321] = "R8Format", n[n.RG8Format = 33323] = "RG8Format";
    }(Kh || (Kh = {}));
    var Ay = function() {
      function n() {
        this._isDirty = !0, this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC = !0, this._ktx2DecoderOptions = {};
      }
      return Object.defineProperty(n.prototype, "isDirty", { get: function() {
        return this._isDirty;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "useRGBAIfASTCBC7NotAvailableWhenUASTC", { get: function() {
        return this._useRGBAIfASTCBC7NotAvailableWhenUASTC;
      }, set: function(t) {
        this._useRGBAIfASTCBC7NotAvailableWhenUASTC !== t && (this._useRGBAIfASTCBC7NotAvailableWhenUASTC = t, this._isDirty = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "useRGBAIfOnlyBC1BC3AvailableWhenUASTC", { get: function() {
        return this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC;
      }, set: function(t) {
        this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC !== t && (this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC = t, this._isDirty = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "forceRGBA", { get: function() {
        return this._forceRGBA;
      }, set: function(t) {
        this._forceRGBA !== t && (this._forceRGBA = t, this._isDirty = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "forceR8", { get: function() {
        return this._forceR8;
      }, set: function(t) {
        this._forceR8 !== t && (this._forceR8 = t, this._isDirty = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "forceRG8", { get: function() {
        return this._forceRG8;
      }, set: function(t) {
        this._forceRG8 !== t && (this._forceRG8 = t, this._isDirty = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "bypassTranscoders", { get: function() {
        return this._bypassTranscoders;
      }, set: function(t) {
        this._bypassTranscoders !== t && (this._bypassTranscoders = t, this._isDirty = !0);
      }, enumerable: !1, configurable: !0 }), n.prototype._getKTX2DecoderOptions = function() {
        if (!this._isDirty)
          return this._ktx2DecoderOptions;
        this._isDirty = !1;
        var t = { useRGBAIfASTCBC7NotAvailableWhenUASTC: this._useRGBAIfASTCBC7NotAvailableWhenUASTC, forceRGBA: this._forceRGBA, forceR8: this._forceR8, forceRG8: this._forceRG8, bypassTranscoders: this._bypassTranscoders };
        return this.useRGBAIfOnlyBC1BC3AvailableWhenUASTC && (t.transcodeFormatDecisionTree = { UASTC: { transcodeFormat: [Rl.BC1_RGB, Rl.BC3_RGBA], yes: { transcodeFormat: Rl.RGBA32, engineFormat: Kh.RGBA8Format, roundToMultiple4: !1 } } }), this._ktx2DecoderOptions = t, t;
      }, n;
    }(), f_ = function() {
      function n(t, e) {
        e === void 0 && (e = n.DefaultNumWorkers), this._engine = t, n._Initialize(e);
      }
      return n.GetDefaultNumWorkers = function() {
        return typeof navigator == "object" && navigator.hardwareConcurrency ? Math.min(Math.floor(0.5 * navigator.hardwareConcurrency), 4) : 1;
      }, n._Initialize = function(t) {
        if (!n._WorkerPoolPromise && !n._DecoderModulePromise) {
          var e = { jsDecoderModule: de.GetBabylonScriptURL(this.URLConfig.jsDecoderModule, !0), wasmUASTCToASTC: de.GetBabylonScriptURL(this.URLConfig.wasmUASTCToASTC, !0), wasmUASTCToBC7: de.GetBabylonScriptURL(this.URLConfig.wasmUASTCToBC7, !0), wasmUASTCToRGBA_UNORM: de.GetBabylonScriptURL(this.URLConfig.wasmUASTCToRGBA_UNORM, !0), wasmUASTCToRGBA_SRGB: de.GetBabylonScriptURL(this.URLConfig.wasmUASTCToRGBA_SRGB, !0), wasmUASTCToR8_UNORM: de.GetBabylonScriptURL(this.URLConfig.wasmUASTCToR8_UNORM, !0), wasmUASTCToRG8_UNORM: de.GetBabylonScriptURL(this.URLConfig.wasmUASTCToRG8_UNORM, !0), jsMSCTranscoder: de.GetBabylonScriptURL(this.URLConfig.jsMSCTranscoder, !0), wasmMSCTranscoder: de.GetBabylonScriptURL(this.URLConfig.wasmMSCTranscoder, !0), wasmZSTDDecoder: de.GetBabylonScriptURL(this.URLConfig.wasmZSTDDecoder, !0) };
          t && typeof Worker == "function" && typeof URL < "u" ? n._WorkerPoolPromise = new Promise(function(i) {
            var r = "".concat(xy, "(").concat(HD, ")()"), o = URL.createObjectURL(new Blob([r], { type: "application/javascript" }));
            i(new p_(t, function() {
              return new Promise(function(a, s) {
                var l = new Worker(o), c = function(h) {
                  l.removeEventListener("error", c), l.removeEventListener("message", u), s(h);
                }, u = function(h) {
                  h.data.action === "init" && (l.removeEventListener("error", c), l.removeEventListener("message", u), a(l));
                };
                l.addEventListener("error", c), l.addEventListener("message", u), l.postMessage({ action: "init", urls: e });
              });
            }));
          }) : typeof KTX2DECODER > "u" ? n._DecoderModulePromise = de.LoadBabylonScriptAsync(e.jsDecoderModule).then(function() {
            return KTX2DECODER.MSCTranscoder.UseFromWorkerThread = !1, KTX2DECODER.WASMMemoryManager.LoadBinariesFromCurrentThread = !0, xy(e), new KTX2DECODER.KTX2Decoder();
          }) : (KTX2DECODER.MSCTranscoder.UseFromWorkerThread = !1, KTX2DECODER.WASMMemoryManager.LoadBinariesFromCurrentThread = !0, n._DecoderModulePromise = Promise.resolve(new KTX2DECODER.KTX2Decoder()));
        }
      }, n.prototype.uploadAsync = function(t, e, i) {
        var r = this, o = this._engine.getCaps(), a = { astc: !!o.astc, bptc: !!o.bptc, s3tc: !!o.s3tc, pvrtc: !!o.pvrtc, etc2: !!o.etc2, etc1: !!o.etc1 };
        if (n._WorkerPoolPromise)
          return n._WorkerPoolPromise.then(function(s) {
            return new Promise(function(l, c) {
              s.push(function(u, h) {
                var d = function(m) {
                  u.removeEventListener("error", d), u.removeEventListener("message", p), c(m), h();
                }, p = function(m) {
                  if (m.data.action === "decoded") {
                    if (u.removeEventListener("error", d), u.removeEventListener("message", p), m.data.success)
                      try {
                        r._createTexture(m.data.decodedData, e, i), l();
                      } catch (g) {
                        c({ message: g });
                      }
                    else
                      c({ message: m.data.msg });
                    h();
                  }
                };
                u.addEventListener("error", d), u.addEventListener("message", p), u.postMessage({ action: "setDefaultDecoderOptions", options: n.DefaultDecoderOptions._getKTX2DecoderOptions() });
                var f = new Uint8Array(t.byteLength);
                f.set(new Uint8Array(t.buffer, t.byteOffset, t.byteLength)), u.postMessage({ action: "decode", data: f, caps: a, options: i }, [f.buffer]);
              });
            });
          });
        if (n._DecoderModulePromise)
          return n._DecoderModulePromise.then(function(s) {
            return n.DefaultDecoderOptions.isDirty && (KTX2DECODER.KTX2Decoder.DefaultDecoderOptions = n.DefaultDecoderOptions._getKTX2DecoderOptions()), new Promise(function(l, c) {
              s.decode(t, o).then(function(u) {
                r._createTexture(u, e), l();
              }).catch(function(u) {
                c({ message: u });
              });
            });
          });
        throw new Error("KTX2 decoder module is not available");
      }, n.prototype._createTexture = function(t, e, i) {
        this._engine._bindTextureDirectly(3553, e), i && (i.transcodedFormat = t.transcodedFormat, i.isInGammaSpace = t.isInGammaSpace, i.hasAlpha = t.hasAlpha, i.transcoderName = t.transcoderName);
        var r = !0;
        switch (t.transcodedFormat) {
          case 32856:
            e.type = _.TEXTURETYPE_UNSIGNED_BYTE, e.format = _.TEXTUREFORMAT_RGBA;
            break;
          case 33321:
            e.type = _.TEXTURETYPE_UNSIGNED_BYTE, e.format = _.TEXTUREFORMAT_R;
            break;
          case 33323:
            e.type = _.TEXTURETYPE_UNSIGNED_BYTE, e.format = _.TEXTUREFORMAT_RG;
            break;
          default:
            e.format = t.transcodedFormat, r = !1;
        }
        if (e._gammaSpace = t.isInGammaSpace, e.generateMipMaps = t.mipmaps.length > 1, t.errors)
          throw new Error("KTX2 container - could not transcode the data. " + t.errors);
        for (var o = 0; o < t.mipmaps.length; ++o) {
          var a = t.mipmaps[o];
          if (!a || !a.data)
            throw new Error("KTX2 container - could not transcode one of the image");
          r ? (e.width = a.width, e.height = a.height, this._engine._uploadDataToTextureDirectly(e, a.data, 0, o, void 0, !0)) : this._engine._uploadCompressedDataToTextureDirectly(e, t.transcodedFormat, a.width, a.height, a.data, 0, o);
        }
        e._extension = ".ktx2", e.width = t.mipmaps[0].width, e.height = t.mipmaps[0].height, e.isReady = !0, this._engine._bindTextureDirectly(3553, null);
      }, n.IsValid = function(t) {
        if (t.byteLength >= 12) {
          var e = new Uint8Array(t.buffer, t.byteOffset, 12);
          if (e[0] === 171 && e[1] === 75 && e[2] === 84 && e[3] === 88 && e[4] === 32 && e[5] === 50 && e[6] === 48 && e[7] === 187 && e[8] === 13 && e[9] === 10 && e[10] === 26 && e[11] === 10)
            return !0;
        }
        return !1;
      }, n.URLConfig = { jsDecoderModule: "https://cdn.babylonjs.com/babylon.ktx2Decoder.js", wasmUASTCToASTC: null, wasmUASTCToBC7: null, wasmUASTCToRGBA_UNORM: null, wasmUASTCToRGBA_SRGB: null, wasmUASTCToR8_UNORM: null, wasmUASTCToRG8_UNORM: null, jsMSCTranscoder: null, wasmMSCTranscoder: null, wasmZSTDDecoder: null }, n.DefaultNumWorkers = n.GetDefaultNumWorkers(), n.DefaultDecoderOptions = new Ay(), n;
    }();
    function HD() {
      var n;
      onmessage = function(t) {
        if (t.data)
          switch (t.data.action) {
            case "init":
              var e = t.data.urls;
              importScripts(e.jsDecoderModule), xy(e), n = new KTX2DECODER.KTX2Decoder(), postMessage({ action: "init" });
              break;
            case "setDefaultDecoderOptions":
              KTX2DECODER.KTX2Decoder.DefaultDecoderOptions = t.data.options;
              break;
            case "decode":
              n.decode(t.data.data, t.data.caps, t.data.options).then(function(i) {
                for (var r = [], o = 0; o < i.mipmaps.length; ++o) {
                  var a = i.mipmaps[o];
                  a && a.data && r.push(a.data.buffer);
                }
                postMessage({ action: "decoded", success: !0, decodedData: i }, r);
              }).catch(function(i) {
                postMessage({ action: "decoded", success: !1, msg: i });
              });
          }
      };
    }
    var Ry = function() {
      function n() {
        this.supportCascades = !1;
      }
      return n.prototype.canLoad = function(t, e) {
        return t.endsWith(".ktx") || t.endsWith(".ktx2") || e === "image/ktx" || e === "image/ktx2";
      }, n.prototype.loadCubeData = function(t, e, i, r) {
        if (!Array.isArray(t)) {
          e._invertVScale = !e.invertY;
          var o = e.getEngine(), a = new qh(t, 6), s = a.numberOfMipmapLevels > 1 && e.generateMipMaps;
          o._unpackFlipY(!0), a.uploadLevels(e, e.generateMipMaps), e.width = a.pixelWidth, e.height = a.pixelHeight, o._setCubeMapTextureParams(e, s, a.numberOfMipmapLevels - 1), e.isReady = !0, e.onLoadedObservable.notifyObservers(e), e.onLoadedObservable.clear(), r && r();
        }
      }, n.prototype.loadData = function(t, e, i, r) {
        if (qh.IsValid(t)) {
          e._invertVScale = !e.invertY;
          var o = new qh(t, 1), a = function(s) {
            switch (s) {
              case _.TEXTUREFORMAT_COMPRESSED_SRGB_S3TC_DXT1_EXT:
                return _.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1;
              case _.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
                return _.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3;
              case _.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
                return _.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5;
              case _.TEXTUREFORMAT_COMPRESSED_SRGB8_ETC2:
                return _.TEXTUREFORMAT_COMPRESSED_RGB8_ETC2;
              case _.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
                return _.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC;
              case _.TEXTUREFORMAT_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
                return _.TEXTUREFORMAT_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;
              case _.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:
                return _.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4;
              case _.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_BPTC_UNORM:
                return _.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM;
            }
            return null;
          }(o.glInternalFormat);
          a ? (e.format = a, e._useSRGBBuffer = e.getEngine()._getUseSRGBBuffer(!0, e.generateMipMaps), e._gammaSpace = !0) : e.format = o.glInternalFormat, i(o.pixelWidth, o.pixelHeight, e.generateMipMaps, !0, function() {
            o.uploadLevels(e, e.generateMipMaps);
          }, o.isInvalid);
        } else
          f_.IsValid(t) ? new f_(e.getEngine()).uploadAsync(t, e, r).then(function() {
            i(e.width, e.height, e.generateMipMaps, !0, function() {
            }, !1);
          }, function(s) {
            q.Warn("Failed to load KTX2 texture data: ".concat(s.message)), i(0, 0, !1, !1, function() {
            }, !0);
          }) : (q.Error("texture missing KTX identifier"), i(0, 0, !1, !1, function() {
          }, !0));
      }, n;
    }();
    ve._TextureLoaders.unshift(new Ry());
    var Cy = function(n) {
      function t(e, i, r) {
        var o = n.call(this, e, v.Zero(), i) || this;
        return o._xrSessionManager = r, o._firstFrame = !1, o._referenceQuaternion = oe.Identity(), o._referencedPosition = new v(), o._trackingState = Ts.NOT_TRACKING, o.onXRCameraInitializedObservable = new H(), o.onBeforeCameraTeleport = new H(), o.onAfterCameraTeleport = new H(), o.onTrackingStateChanged = new H(), o.compensateOnFirstFrame = !0, o._rotate180 = new oe(0, 1, 0, 0), o.minZ = 0.1, o.rotationQuaternion = new oe(), o.cameraRigMode = dt.RIG_MODE_CUSTOM, o.updateUpVectorFromRotation = !0, o._updateNumberOfRigCameras(1), o.freezeProjectionMatrix(), o._deferOnly = !0, o._xrSessionManager.onXRSessionInit.add(function() {
          o._referencedPosition.copyFromFloats(0, 0, 0), o._referenceQuaternion.copyFromFloats(0, 0, 0, 1), o._firstFrame = o.compensateOnFirstFrame;
        }), o._xrSessionManager.onXRFrameObservable.add(function() {
          o._firstFrame && o._updateFromXRSession(), o.onXRCameraInitializedObservable.hasObservers() && (o.onXRCameraInitializedObservable.notifyObservers(o), o.onXRCameraInitializedObservable.clear()), o._deferredUpdated && (o.position.copyFrom(o._deferredPositionUpdate), o.rotationQuaternion.copyFrom(o._deferredRotationQuaternionUpdate)), o._updateReferenceSpace(), o._updateFromXRSession();
        }, void 0, !0), o;
      }
      return D(t, n), Object.defineProperty(t.prototype, "trackingState", { get: function() {
        return this._trackingState;
      }, enumerable: !1, configurable: !0 }), t.prototype._setTrackingState = function(e) {
        this._trackingState !== e && (this._trackingState = e, this.onTrackingStateChanged.notifyObservers(e));
      }, Object.defineProperty(t.prototype, "realWorldHeight", { get: function() {
        var e = this._xrSessionManager.currentFrame && this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.baseReferenceSpace);
        return e && e.transform ? e.transform.position.y : 0;
      }, enumerable: !1, configurable: !0 }), t.prototype._updateForDualEyeDebugging = function() {
        this._updateNumberOfRigCameras(2), this.rigCameras[0].viewport = new xr(0, 0, 0.5, 1), this.rigCameras[0].outputRenderTarget = null, this.rigCameras[1].viewport = new xr(0.5, 0, 0.5, 1), this.rigCameras[1].outputRenderTarget = null;
      }, t.prototype.setTransformationFromNonVRCamera = function(e, i) {
        e === void 0 && (e = this.getScene().activeCamera), i === void 0 && (i = !0), e && e !== this && (e.computeWorldMatrix().decompose(void 0, this.rotationQuaternion, this.position), this.position.y = 0, oe.FromEulerAnglesToRef(0, this.rotationQuaternion.toEulerAngles().y, 0, this.rotationQuaternion), this._firstFrame = !0, i && this._xrSessionManager.resetReferenceSpace());
      }, t.prototype.getClassName = function() {
        return "WebXRCamera";
      }, t.prototype.setTarget = function(e) {
        var i = F.Vector3[1];
        e.subtractToRef(this.position, i), i.y = 0, i.normalize();
        var r = Math.atan2(i.x, i.z);
        this.rotationQuaternion.toEulerAnglesToRef(i), oe.FromEulerAnglesToRef(i.x, r, i.z, this.rotationQuaternion);
      }, t.prototype.dispose = function() {
        n.prototype.dispose.call(this), this._lastXRViewerPose = void 0;
      }, t.prototype._updateFromXRSession = function() {
        var e = this, i = this._xrSessionManager.currentFrame && this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.referenceSpace);
        if (this._lastXRViewerPose = i || void 0, i) {
          var r = i.emulatedPosition ? Ts.TRACKING_LOST : Ts.TRACKING;
          if (this._setTrackingState(r), this.minZ !== this._cache.minZ || this.maxZ !== this._cache.maxZ) {
            var o = { depthFar: this.maxZ || 1e4, depthNear: this.minZ };
            this._xrSessionManager.updateRenderState(o), this._cache.minZ = this.minZ, this._cache.maxZ = this.maxZ;
          }
          if (i.transform) {
            var a = i.transform.orientation;
            if (i.transform.orientation.x === void 0)
              return;
            var s = i.transform.position;
            this._referencedPosition.set(s.x, s.y, s.z), this._referenceQuaternion.set(a.x, a.y, a.z, a.w), this._scene.useRightHandedSystem || (this._referencedPosition.z *= -1, this._referenceQuaternion.z *= -1, this._referenceQuaternion.w *= -1), this._firstFrame ? (this._firstFrame = !1, this.position.y += this._referencedPosition.y, this._referenceQuaternion.copyFromFloats(0, 0, 0, 1)) : (this.rotationQuaternion.copyFrom(this._referenceQuaternion), this.position.copyFrom(this._referencedPosition));
          }
          this.rigCameras.length !== i.views.length && this._updateNumberOfRigCameras(i.views.length), i.views.forEach(function(l, c) {
            var u, h = e.rigCameras[c];
            h.isLeftCamera || h.isRightCamera || (l.eye === "right" ? h._isRightCamera = !0 : l.eye === "left" && (h._isLeftCamera = !0));
            var d = l.transform.position, p = l.transform.orientation;
            h.parent = e.parent, h.position.set(d.x, d.y, d.z), h.rotationQuaternion.set(p.x, p.y, p.z, p.w), e._scene.useRightHandedSystem ? h.rotationQuaternion.multiplyInPlace(e._rotate180) : (h.position.z *= -1, h.rotationQuaternion.z *= -1, h.rotationQuaternion.w *= -1), B.FromFloat32ArrayToRefScaled(l.projectionMatrix, 0, 1, h._projectionMatrix), e._scene.useRightHandedSystem || h._projectionMatrix.toggleProjectionMatrixHandInPlace(), c === 0 && e._projectionMatrix.copyFrom(h._projectionMatrix);
            var f = e._xrSessionManager.getRenderTargetTextureForView(l);
            e._renderingMultiview = ((u = f == null ? void 0 : f._texture) === null || u === void 0 ? void 0 : u.isMultiview) || !1, e._renderingMultiview ? c == 0 && (e._xrSessionManager.trySetViewportForView(e.viewport, l), e.outputRenderTarget = f) : (e._xrSessionManager.trySetViewportForView(h.viewport, l), h.outputRenderTarget = f || e._xrSessionManager.getRenderTargetTextureForView(l)), h.layerMask = e.layerMask;
          });
        } else
          this._setTrackingState(Ts.NOT_TRACKING);
      }, t.prototype._updateNumberOfRigCameras = function(e) {
        for (e === void 0 && (e = 1); this.rigCameras.length < e; ) {
          var i = new ha("XR-RigCamera: " + this.rigCameras.length, v.Zero(), this.getScene());
          i.minZ = 0.1, i.rotationQuaternion = new oe(), i.updateUpVectorFromRotation = !0, i.isRigCamera = !0, i.rigParent = this, i.freezeProjectionMatrix(), this.rigCameras.push(i);
        }
        for (; this.rigCameras.length > e; ) {
          var r = this.rigCameras.pop();
          r && r.dispose();
        }
      }, t.prototype._updateReferenceSpace = function() {
        if (!this.position.equals(this._referencedPosition) || !this.rotationQuaternion.equals(this._referenceQuaternion)) {
          var e = F.Matrix[0], i = F.Matrix[1], r = F.Matrix[2];
          B.ComposeToRef(t._ScaleReadOnly, this._referenceQuaternion, this._referencedPosition, e), B.ComposeToRef(t._ScaleReadOnly, this.rotationQuaternion, this.position, i), e.invert().multiplyToRef(i, r), r.invert(), this._scene.useRightHandedSystem || r.toggleModelMatrixHandInPlace(), r.decompose(void 0, this._referenceQuaternion, this._referencedPosition);
          var o = new XRRigidTransform({ x: this._referencedPosition.x, y: this._referencedPosition.y, z: this._referencedPosition.z }, { x: this._referenceQuaternion.x, y: this._referenceQuaternion.y, z: this._referenceQuaternion.z, w: this._referenceQuaternion.w });
          this._xrSessionManager.referenceSpace = this._xrSessionManager.referenceSpace.getOffsetReferenceSpace(o);
        }
      }, t._ScaleReadOnly = v.One(), t;
    }(Oo), Py = function() {
      function n(t) {
        var e = this;
        this._scene = t, this._nonVRCamera = null, this._attachedToElement = !1, this._spectatorCamera = null, this._originalSceneAutoClear = !0, this._supported = !1, this._spectatorMode = !1, this._lastTimestamp = 0, this.onInitialXRPoseSetObservable = new H(), this.onStateChangedObservable = new H(), this.state = Xi.NOT_IN_XR, this.sessionManager = new ff(t), this.camera = new Cy("webxr", t, this.sessionManager), this.featuresManager = new Wi(this.sessionManager), t.onDisposeObservable.addOnce(function() {
          e.dispose();
        });
      }
      return n.CreateAsync = function(t) {
        var e = new n(t);
        return e.sessionManager.initializeAsync().then(function() {
          return e._supported = !0, e;
        }).catch(function(i) {
          throw e._setState(Xi.NOT_IN_XR), e.dispose(), i;
        });
      }, n.prototype.dispose = function() {
        var t;
        this.exitXRAsync(), this.camera.dispose(), this.onStateChangedObservable.clear(), this.onInitialXRPoseSetObservable.clear(), this.sessionManager.dispose(), (t = this._spectatorCamera) === null || t === void 0 || t.dispose(), this._nonVRCamera && (this._scene.activeCamera = this._nonVRCamera);
      }, n.prototype.enterXRAsync = function(t, e, i, r) {
        var o, a, s;
        return i === void 0 && (i = this.sessionManager.getWebXRRenderTarget()), r === void 0 && (r = {}), Ft(this, void 0, void 0, function() {
          var l, c, u, h = this;
          return Bt(this, function(d) {
            switch (d.label) {
              case 0:
                if (!this._supported)
                  throw "WebXR not supported in this browser or environment";
                return this._setState(Xi.ENTERING_XR), e !== "viewer" && e !== "local" && (r.optionalFeatures = r.optionalFeatures || [], r.optionalFeatures.push(e)), [4, this.featuresManager._extendXRSessionInitObject(r)];
              case 1:
                r = d.sent(), t === "immersive-ar" && e !== "unbounded" && q.Warn("We recommend using 'unbounded' reference space type when using 'immersive-ar' session mode"), d.label = 2;
              case 2:
                return d.trys.push([2, 6, , 7]), [4, this.sessionManager.initializeSessionAsync(t, r)];
              case 3:
                return d.sent(), [4, this.sessionManager.setReferenceSpaceTypeAsync(e)];
              case 4:
                return d.sent(), [4, i.initializeXRLayerAsync(this.sessionManager.session)];
              case 5:
                return l = d.sent(), c = { depthFar: this.camera.maxZ || 1e4, depthNear: this.camera.minZ }, this.featuresManager.getEnabledFeature(vi.LAYERS) || (c.baseLayer = l), this.sessionManager.updateRenderState(c), this.sessionManager.runXRRenderLoop(), this._originalSceneAutoClear = this._scene.autoClear, this._nonVRCamera = this._scene.activeCamera, this._attachedToElement = !!(!((a = (o = this._nonVRCamera) === null || o === void 0 ? void 0 : o.inputs) === null || a === void 0) && a.attachedToElement), (s = this._nonVRCamera) === null || s === void 0 || s.detachControl(), this._scene.activeCamera = this.camera, t !== "immersive-ar" ? this._nonXRToXRCamera() : (this._scene.autoClear = !1, this.camera.compensateOnFirstFrame = !1, this.camera.position.set(0, 0, 0), this.camera.rotationQuaternion.set(0, 0, 0, 1), this.onInitialXRPoseSetObservable.notifyObservers(this.camera)), this.sessionManager.onXRSessionEnded.addOnce(function() {
                  h.state !== Xi.EXITING_XR && h._setState(Xi.EXITING_XR), h.camera.rigCameras.forEach(function(p) {
                    p.outputRenderTarget = null;
                  }), h._scene.autoClear = h._originalSceneAutoClear, h._scene.activeCamera = h._nonVRCamera, h._attachedToElement && h._nonVRCamera && h._nonVRCamera.attachControl(!!h._nonVRCamera.inputs.noPreventDefault), t !== "immersive-ar" && h.camera.compensateOnFirstFrame && (h._nonVRCamera.setPosition ? h._nonVRCamera.setPosition(h.camera.position) : h._nonVRCamera.position.copyFrom(h.camera.position)), h._setState(Xi.NOT_IN_XR);
                }), this.sessionManager.onXRFrameObservable.addOnce(function() {
                  h._setState(Xi.IN_XR);
                }), [2, this.sessionManager];
              case 6:
                throw u = d.sent(), console.log(u), console.log(u.message), this._setState(Xi.NOT_IN_XR), u;
              case 7:
                return [2];
            }
          });
        });
      }, n.prototype.exitXRAsync = function() {
        return this.state !== Xi.IN_XR ? Promise.resolve() : (this._setState(Xi.EXITING_XR), this.sessionManager.exitXRAsync());
      }, n.prototype.enableSpectatorMode = function(t) {
        this._spectatorMode || (this._spectatorMode = !0, this._switchSpectatorMode(t));
      }, n.prototype.disableSpecatatorMode = function() {
        this._spectatorMode && (this._spectatorMode = !1, this._switchSpectatorMode());
      }, n.prototype._switchSpectatorMode = function(t) {
        var e = this, i = 1 / (t != null && t.fps ? t.fps : 1e3) * 1e3, r = t != null && t.preferredCameraIndex ? t == null ? void 0 : t.preferredCameraIndex : 0, o = function() {
          e._spectatorCamera && e.sessionManager.currentTimestamp - e._lastTimestamp >= i && (e._lastTimestamp = e.sessionManager.currentTimestamp, e._spectatorCamera.position.copyFrom(e.camera.rigCameras[r].globalPosition), e._spectatorCamera.rotationQuaternion.copyFrom(e.camera.rigCameras[r].absoluteRotation));
        };
        if (this._spectatorMode) {
          if (r >= this.camera.rigCameras.length)
            throw new Error("the preferred camera index is beyond the length of rig camera array.");
          var a = function() {
            e.state === Xi.IN_XR ? (e._spectatorCamera = new Wa("webxr-spectator", v.Zero(), e._scene), e._spectatorCamera.rotationQuaternion = new oe(), e._scene.activeCameras = [e.camera, e._spectatorCamera], e.sessionManager.onXRFrameObservable.add(o), e._scene.onAfterRenderCameraObservable.add(function(s) {
              s === e.camera && (e._scene.getEngine().framebufferDimensionsObject = null);
            })) : e.state === Xi.EXITING_XR && (e.sessionManager.onXRFrameObservable.removeCallback(o), e._scene.activeCameras = null);
          };
          this.onStateChangedObservable.add(a), a();
        } else
          this.sessionManager.onXRFrameObservable.removeCallback(o), this._scene.activeCameras = [this.camera];
      }, n.prototype._nonXRToXRCamera = function() {
        this.camera.setTransformationFromNonVRCamera(this._nonVRCamera), this.onInitialXRPoseSetObservable.notifyObservers(this.camera);
      }, n.prototype._setState = function(t) {
        this.state !== t && (this.state = t, this.onStateChangedObservable.notifyObservers(this.state));
      }, n;
    }(), wo = function() {
      function n(t, e, i, r) {
        i === void 0 && (i = -1), r === void 0 && (r = []), this.id = t, this.type = e, this._buttonIndex = i, this._axesIndices = r, this._axes = { x: 0, y: 0 }, this._changes = {}, this._currentValue = 0, this._hasChanges = !1, this._pressed = !1, this._touched = !1, this.onAxisValueChangedObservable = new H(), this.onButtonStateChangedObservable = new H();
      }
      return Object.defineProperty(n.prototype, "axes", { get: function() {
        return this._axes;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "changes", { get: function() {
        return this._changes;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "hasChanges", { get: function() {
        return this._hasChanges;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "pressed", { get: function() {
        return this._pressed;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "touched", { get: function() {
        return this._touched;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "value", { get: function() {
        return this._currentValue;
      }, enumerable: !1, configurable: !0 }), n.prototype.dispose = function() {
        this.onAxisValueChangedObservable.clear(), this.onButtonStateChangedObservable.clear();
      }, n.prototype.isAxes = function() {
        return this._axesIndices.length !== 0;
      }, n.prototype.isButton = function() {
        return this._buttonIndex !== -1;
      }, n.prototype.update = function(t) {
        var e = !1, i = !1;
        if (this._hasChanges = !1, this._changes = {}, this.isButton()) {
          var r = t.buttons[this._buttonIndex];
          if (!r)
            return;
          this._currentValue !== r.value && (this.changes.value = { current: r.value, previous: this._currentValue }, e = !0, this._currentValue = r.value), this._touched !== r.touched && (this.changes.touched = { current: r.touched, previous: this._touched }, e = !0, this._touched = r.touched), this._pressed !== r.pressed && (this.changes.pressed = { current: r.pressed, previous: this._pressed }, e = !0, this._pressed = r.pressed);
        }
        this.isAxes() && (this._axes.x !== t.axes[this._axesIndices[0]] && (this.changes.axes = { current: { x: t.axes[this._axesIndices[0]], y: this._axes.y }, previous: { x: this._axes.x, y: this._axes.y } }, this._axes.x = t.axes[this._axesIndices[0]], i = !0), this._axes.y !== t.axes[this._axesIndices[1]] && (this.changes.axes ? this.changes.axes.current.y = t.axes[this._axesIndices[1]] : this.changes.axes = { current: { x: this._axes.x, y: t.axes[this._axesIndices[1]] }, previous: { x: this._axes.x, y: this._axes.y } }, this._axes.y = t.axes[this._axesIndices[1]], i = !0)), e && (this._hasChanges = !0, this.onButtonStateChangedObservable.notifyObservers(this)), i && (this._hasChanges = !0, this.onAxisValueChangedObservable.notifyObservers(this._axes));
      }, n.BUTTON_TYPE = "button", n.SQUEEZE_TYPE = "squeeze", n.THUMBSTICK_TYPE = "thumbstick", n.TOUCHPAD_TYPE = "touchpad", n.TRIGGER_TYPE = "trigger", n;
    }(), Cs = function() {
      function n(t, e, i, r, o, a) {
        o === void 0 && (o = !1);
        var s = this;
        this.scene = t, this.layout = e, this.gamepadObject = i, this.handedness = r, this._doNotLoadControllerMesh = o, this._controllerCache = a, this._initComponent = function(l) {
          if (l) {
            var c = s.layout.components[l], u = c.type, h = c.gamepadIndices.button, d = [];
            c.gamepadIndices.xAxis !== void 0 && c.gamepadIndices.yAxis !== void 0 && d.push(c.gamepadIndices.xAxis, c.gamepadIndices.yAxis), s.components[l] = new wo(l, u, h, d);
          }
        }, this._modelReady = !1, this.components = {}, this.disableAnimation = !1, this.onModelLoadedObservable = new H(), e.components && Object.keys(e.components).forEach(this._initComponent);
      }
      return n.prototype.dispose = function() {
        var t = this;
        this.getComponentIds().forEach(function(e) {
          return t.getComponent(e).dispose();
        }), this.rootMesh && (this.rootMesh.getChildren(void 0, !0).forEach(function(e) {
          e.setEnabled(!1);
        }), this.rootMesh.dispose(!!this._controllerCache, !this._controllerCache));
      }, n.prototype.getAllComponentsOfType = function(t) {
        var e = this;
        return this.getComponentIds().map(function(i) {
          return e.components[i];
        }).filter(function(i) {
          return i.type === t;
        });
      }, n.prototype.getComponent = function(t) {
        return this.components[t];
      }, n.prototype.getComponentIds = function() {
        return Object.keys(this.components);
      }, n.prototype.getComponentOfType = function(t) {
        return this.getAllComponentsOfType(t)[0] || null;
      }, n.prototype.getMainComponent = function() {
        return this.getComponent(this.layout.selectComponentId);
      }, n.prototype.loadModel = function() {
        return Ft(this, void 0, void 0, function() {
          var t, e, i = this;
          return Bt(this, function(r) {
            return t = !this._getModelLoadingConstraints(), e = this._getGenericFilenameAndPath(), t ? q.Warn("Falling back to generic models") : e = this._getFilenameAndPath(), [2, new Promise(function(o, a) {
              var s = function(c) {
                t ? i._getGenericParentMesh(c) : i._setRootMesh(c), i._processLoadedModel(c), i._modelReady = !0, i.onModelLoadedObservable.notifyObservers(i), o(!0);
              };
              if (i._controllerCache) {
                var l = i._controllerCache.filter(function(c) {
                  return c.filename === e.filename && c.path === e.path;
                });
                if (l[0])
                  return l[0].meshes.forEach(function(c) {
                    return c.setEnabled(!0);
                  }), void s(l[0].meshes);
              }
              yi.ImportMesh("", e.path, e.filename, i.scene, function(c) {
                i._controllerCache && i._controllerCache.push(je(je({}, e), { meshes: c })), s(c);
              }, null, function(c, u) {
                q.Log(u), q.Warn("Failed to retrieve controller model of type ".concat(i.profileId, " from the remote server: ").concat(e.path).concat(e.filename)), a(u);
              });
            })];
          });
        });
      }, n.prototype.updateFromXRFrame = function(t) {
        var e = this;
        this.getComponentIds().forEach(function(i) {
          return e.getComponent(i).update(e.gamepadObject);
        }), this.updateModel(t);
      }, Object.defineProperty(n.prototype, "handness", { get: function() {
        return this.handedness;
      }, enumerable: !1, configurable: !0 }), n.prototype.pulse = function(t, e, i) {
        return i === void 0 && (i = 0), this.gamepadObject.hapticActuators && this.gamepadObject.hapticActuators[i] ? this.gamepadObject.hapticActuators[i].pulse(t, e) : Promise.resolve(!1);
      }, n.prototype._getChildByName = function(t, e) {
        return t.getChildren(function(i) {
          return i.name === e;
        }, !1)[0];
      }, n.prototype._getImmediateChildByName = function(t, e) {
        return t.getChildren(function(i) {
          return i.name == e;
        }, !0)[0];
      }, n.prototype._lerpTransform = function(t, e, i) {
        if (t.minMesh && t.maxMesh && t.valueMesh && t.minMesh.rotationQuaternion && t.maxMesh.rotationQuaternion && t.valueMesh.rotationQuaternion) {
          var r = i ? 0.5 * e + 0.5 : e;
          oe.SlerpToRef(t.minMesh.rotationQuaternion, t.maxMesh.rotationQuaternion, r, t.valueMesh.rotationQuaternion), v.LerpToRef(t.minMesh.position, t.maxMesh.position, r, t.valueMesh.position);
        }
      }, n.prototype.updateModel = function(t) {
        this._modelReady && this._updateModel(t);
      }, n.prototype._getGenericFilenameAndPath = function() {
        return { filename: "generic.babylon", path: "https://controllers.babylonjs.com/generic/" };
      }, n.prototype._getGenericParentMesh = function(t) {
        var e = this;
        this.rootMesh = new ie(this.profileId + " " + this.handedness, this.scene), t.forEach(function(i) {
          i.parent || (i.isPickable = !1, i.setParent(e.rootMesh));
        }), this.rootMesh.rotationQuaternion = oe.FromEulerAngles(0, Math.PI, 0);
      }, n;
    }(), __ = function(n) {
      function t(e, i, r) {
        var o = n.call(this, e, XD[r], i, r) || this;
        return o.profileId = t.ProfileId, o;
      }
      return D(t, n), t.prototype._getFilenameAndPath = function() {
        return { filename: "generic.babylon", path: "https://controllers.babylonjs.com/generic/" };
      }, t.prototype._getModelLoadingConstraints = function() {
        return !0;
      }, t.prototype._processLoadedModel = function(e) {
      }, t.prototype._setRootMesh = function(e) {
        var i = this;
        this.rootMesh = new ie(this.profileId + " " + this.handedness, this.scene), e.forEach(function(r) {
          r.isPickable = !1, r.parent || r.setParent(i.rootMesh);
        }), this.rootMesh.rotationQuaternion = oe.FromEulerAngles(0, Math.PI, 0);
      }, t.prototype._updateModel = function() {
      }, t.ProfileId = "generic-trigger", t;
    }(Cs), XD = { left: { selectComponentId: "xr-standard-trigger", components: { "xr-standard-trigger": { type: "trigger", gamepadIndices: { button: 0 }, rootNodeName: "xr_standard_trigger", visualResponses: {} } }, gamepadMapping: "xr-standard", rootNodeName: "generic-trigger-left", assetPath: "left.glb" }, right: { selectComponentId: "xr-standard-trigger", components: { "xr-standard-trigger": { type: "trigger", gamepadIndices: { button: 0 }, rootNodeName: "xr_standard_trigger", visualResponses: {} } }, gamepadMapping: "xr-standard", rootNodeName: "generic-trigger-right", assetPath: "right.glb" }, none: { selectComponentId: "xr-standard-trigger", components: { "xr-standard-trigger": { type: "trigger", gamepadIndices: { button: 0 }, rootNodeName: "xr_standard_trigger", visualResponses: {} } }, gamepadMapping: "xr-standard", rootNodeName: "generic-trigger-none", assetPath: "none.glb" } }, Iy = function(n) {
      function t(e, i, r, o, a) {
        var s = n.call(this, e, r.layouts[i.handedness || "none"], i.gamepad, i.handedness, void 0, a) || this;
        return s._repositoryUrl = o, s.controllerCache = a, s._buttonMeshMapping = {}, s._touchDots = {}, s.profileId = r.profileId, s;
      }
      return D(t, n), t.prototype.dispose = function() {
        var e = this;
        n.prototype.dispose.call(this), this.controllerCache || Object.keys(this._touchDots).forEach(function(i) {
          e._touchDots[i].dispose();
        });
      }, t.prototype._getFilenameAndPath = function() {
        return { filename: this.layout.assetPath, path: "".concat(this._repositoryUrl, "/profiles/").concat(this.profileId, "/") };
      }, t.prototype._getModelLoadingConstraints = function() {
        var e = yi.IsPluginForExtensionAvailable(".glb");
        return e || q.Warn("glTF / glb loader was not registered, using generic controller instead"), e;
      }, t.prototype._processLoadedModel = function(e) {
        var i = this;
        this.getComponentIds().forEach(function(r) {
          var o = i.layout.components[r];
          i._buttonMeshMapping[r] = { mainMesh: i._getChildByName(i.rootMesh, o.rootNodeName), states: {} }, Object.keys(o.visualResponses).forEach(function(a) {
            var s = o.visualResponses[a];
            if (s.valueNodeProperty === "transform")
              i._buttonMeshMapping[r].states[a] = { valueMesh: i._getChildByName(i.rootMesh, s.valueNodeName), minMesh: i._getChildByName(i.rootMesh, s.minNodeName), maxMesh: i._getChildByName(i.rootMesh, s.maxNodeName) };
            else {
              var l = o.type === wo.TOUCHPAD_TYPE && o.touchPointNodeName ? o.touchPointNodeName : s.valueNodeName;
              if (i._buttonMeshMapping[r].states[a] = { valueMesh: i._getChildByName(i.rootMesh, l) }, o.type === wo.TOUCHPAD_TYPE && !i._touchDots[a]) {
                var c = yn(a + "dot", { diameter: 15e-4, segments: 8 }, i.scene);
                c.material = new Gt(a + "mat", i.scene), c.material.diffuseColor = ne.Red(), c.parent = i._buttonMeshMapping[r].states[a].valueMesh || null, c.isVisible = !1, i._touchDots[a] = c;
              }
            }
          });
        });
      }, t.prototype._setRootMesh = function(e) {
        var i;
        this.rootMesh = new ie(this.profileId + "-" + this.handedness, this.scene), this.rootMesh.isPickable = !1;
        for (var r = 0; r < e.length; r++) {
          var o = e[r];
          o.isPickable = !1, o.parent || (i = o);
        }
        i && i.setParent(this.rootMesh), this.scene.useRightHandedSystem || this.rootMesh.rotate(qi.Y, Math.PI, ht.WORLD);
      }, t.prototype._updateModel = function(e) {
        var i = this;
        this.disableAnimation || this.getComponentIds().forEach(function(r) {
          var o = i.getComponent(r);
          if (o.hasChanges) {
            var a = i._buttonMeshMapping[r], s = i.layout.components[r];
            Object.keys(s.visualResponses).forEach(function(l) {
              var c = s.visualResponses[l], u = o.value;
              if (c.componentProperty === "xAxis" ? u = o.axes.x : c.componentProperty === "yAxis" && (u = o.axes.y), c.valueNodeProperty === "transform")
                i._lerpTransform(a.states[l], u, c.componentProperty !== "button");
              else {
                var h = a.states[l].valueMesh;
                h && (h.isVisible = o.touched || o.pressed), i._touchDots[l] && (i._touchDots[l].isVisible = o.touched || o.pressed);
              }
            });
          }
        });
      }, t;
    }(Cs), My = [], Qn = function() {
      function n() {
      }
      return n.ClearProfilesCache = function() {
        this._ProfilesList = null, this._ProfileLoadingPromises = {};
      }, n.DefaultFallbacks = function() {
        this.RegisterFallbacksForProfileId("google-daydream", ["generic-touchpad"]), this.RegisterFallbacksForProfileId("htc-vive-focus", ["generic-trigger-touchpad"]), this.RegisterFallbacksForProfileId("htc-vive", ["generic-trigger-squeeze-touchpad"]), this.RegisterFallbacksForProfileId("magicleap-one", ["generic-trigger-squeeze-touchpad"]), this.RegisterFallbacksForProfileId("windows-mixed-reality", ["generic-trigger-squeeze-touchpad-thumbstick"]), this.RegisterFallbacksForProfileId("microsoft-mixed-reality", ["windows-mixed-reality", "generic-trigger-squeeze-touchpad-thumbstick"]), this.RegisterFallbacksForProfileId("oculus-go", ["generic-trigger-touchpad"]), this.RegisterFallbacksForProfileId("oculus-touch-v2", ["oculus-touch", "generic-trigger-squeeze-thumbstick"]), this.RegisterFallbacksForProfileId("oculus-touch", ["generic-trigger-squeeze-thumbstick"]), this.RegisterFallbacksForProfileId("samsung-gearvr", ["windows-mixed-reality", "generic-trigger-squeeze-touchpad-thumbstick"]), this.RegisterFallbacksForProfileId("samsung-odyssey", ["generic-touchpad"]), this.RegisterFallbacksForProfileId("valve-index", ["generic-trigger-squeeze-touchpad-thumbstick"]), this.RegisterFallbacksForProfileId("generic-hand-select", ["generic-trigger"]);
      }, n.FindFallbackWithProfileId = function(t) {
        var e = this._Fallbacks[t] || [];
        return e.unshift(t), e;
      }, n.GetMotionControllerWithXRInput = function(t, e, i) {
        var r = this, o = [];
        i && o.push(i), o.push.apply(o, t.profiles || []), o.length && !o[0] && o.pop(), t.gamepad && t.gamepad.id && t.gamepad.id === (t.gamepad.id.match(/oculus touch/gi) ? t.gamepad.id : void 0) && o.push("oculus-touch-v2");
        var a = o.indexOf("windows-mixed-reality");
        if (a !== -1 && o.splice(a, 0, "microsoft-mixed-reality"), o.length || o.push("generic-trigger"), this.UseOnlineRepository) {
          var s = this.PrioritizeOnlineRepository ? this._LoadProfileFromRepository : this._LoadProfilesFromAvailableControllers, l = this.PrioritizeOnlineRepository ? this._LoadProfilesFromAvailableControllers : this._LoadProfileFromRepository;
          return s.call(this, o, t, e).catch(function() {
            return l.call(r, o, t, e);
          });
        }
        return this._LoadProfilesFromAvailableControllers(o, t, e);
      }, n.RegisterController = function(t, e) {
        this._AvailableControllers[t] = e;
      }, n.RegisterFallbacksForProfileId = function(t, e) {
        var i;
        this._Fallbacks[t] ? (i = this._Fallbacks[t]).push.apply(i, e) : this._Fallbacks[t] = e;
      }, n.UpdateProfilesList = function() {
        return this._ProfilesList = de.LoadFileAsync(this.BaseRepositoryUrl + "/profiles/profilesList.json", !1).then(function(t) {
          return JSON.parse(t.toString());
        }), this._ProfilesList;
      }, n.ClearControllerCache = function() {
        My.forEach(function(t) {
          t.meshes.forEach(function(e) {
            e.dispose(!1, !0);
          });
        }), My.length = 0;
      }, n._LoadProfileFromRepository = function(t, e, i) {
        var r = this;
        return Promise.resolve().then(function() {
          return r._ProfilesList ? r._ProfilesList : r.UpdateProfilesList();
        }).then(function(o) {
          for (var a = 0; a < t.length; ++a)
            if (t[a] && o[t[a]])
              return t[a];
          throw new Error("neither controller ".concat(t[0], " nor all fallbacks were found in the repository,"));
        }).then(function(o) {
          return r._ProfileLoadingPromises[o] || (r._ProfileLoadingPromises[o] = de.LoadFileAsync("".concat(r.BaseRepositoryUrl, "/profiles/").concat(o, "/profile.json"), !1).then(function(a) {
            return JSON.parse(a);
          })), r._ProfileLoadingPromises[o];
        }).then(function(o) {
          return new Iy(i, e, o, r.BaseRepositoryUrl, r.DisableControllerCache ? void 0 : My);
        });
      }, n._LoadProfilesFromAvailableControllers = function(t, e, i) {
        for (var r = 0; r < t.length; ++r)
          if (t[r])
            for (var o = this.FindFallbackWithProfileId(t[r]), a = 0; a < o.length; ++a) {
              var s = this._AvailableControllers[o[a]];
              if (s)
                return Promise.resolve(s(e, i));
            }
        throw new Error("no controller requested was found in the available controllers list");
      }, n._AvailableControllers = {}, n._Fallbacks = {}, n._ProfileLoadingPromises = {}, n.BaseRepositoryUrl = "https://immersive-web.github.io/webxr-input-profiles/packages/viewer/dist", n.PrioritizeOnlineRepository = !0, n.UseOnlineRepository = !0, n.DisableControllerCache = !0, n;
    }();
    Qn.RegisterController(__.ProfileId, function(n, t) {
      return new __(t, n.gamepad, n.handedness);
    }), Qn.DefaultFallbacks();
    var Mr, qa, jD = 0, Oy = function() {
      function n(t, e, i) {
        i === void 0 && (i = {});
        var r = this;
        this._scene = t, this.inputSource = e, this._options = i, this._tmpVector = new v(), this._disposed = !1, this.onDisposeObservable = new H(), this.onMeshLoadedObservable = new H(), this.onMotionControllerInitObservable = new H(), this._uniqueId = "controller-".concat(jD++, "-").concat(e.targetRayMode, "-").concat(e.handedness), this.pointer = new Dt("".concat(this._uniqueId, "-pointer"), t), this.pointer.rotationQuaternion = new oe(), this.inputSource.gripSpace && (this.grip = new Dt("".concat(this._uniqueId, "-grip"), this._scene), this.grip.rotationQuaternion = new oe()), this._tmpVector.set(0, 0, this._scene.useRightHandedSystem ? -1 : 1), this.inputSource.gamepad && this.inputSource.targetRayMode === "tracked-pointer" && Qn.GetMotionControllerWithXRInput(e, t, this._options.forceControllerProfile).then(function(o) {
          r.motionController = o, r.onMotionControllerInitObservable.notifyObservers(o), r._options.doNotLoadControllerMesh || r.motionController._doNotLoadControllerMesh || r.motionController.loadModel().then(function(a) {
            var s;
            a && r.motionController && r.motionController.rootMesh && (r._options.renderingGroupId && (r.motionController.rootMesh.renderingGroupId = r._options.renderingGroupId, r.motionController.rootMesh.getChildMeshes(!1).forEach(function(l) {
              return l.renderingGroupId = r._options.renderingGroupId;
            })), r.onMeshLoadedObservable.notifyObservers(r.motionController.rootMesh), r.motionController.rootMesh.parent = r.grip || r.pointer, r.motionController.disableAnimation = !!r._options.disableMotionControllerAnimation), r._disposed && ((s = r.motionController) === null || s === void 0 || s.dispose());
          });
        }, function() {
          de.Warn("Could not find a matching motion controller for the registered input source");
        });
      }
      return Object.defineProperty(n.prototype, "uniqueId", { get: function() {
        return this._uniqueId;
      }, enumerable: !1, configurable: !0 }), n.prototype.dispose = function() {
        this.grip && this.grip.dispose(!0), this.motionController && this.motionController.dispose(), this.pointer.dispose(!0), this.onMotionControllerInitObservable.clear(), this.onMeshLoadedObservable.clear(), this.onDisposeObservable.notifyObservers(this), this.onDisposeObservable.clear(), this._disposed = !0;
      }, n.prototype.getWorldPointerRayToRef = function(t, e) {
        e === void 0 && (e = !1);
        var i = e && this.grip ? this.grip : this.pointer;
        v.TransformNormalToRef(this._tmpVector, i.getWorldMatrix(), t.direction), t.direction.normalize(), t.origin.copyFrom(i.absolutePosition), t.length = 1e3;
      }, n.prototype.updateFromXRFrame = function(t, e, i) {
        var r = t.getPose(this.inputSource.targetRaySpace, e);
        if (this._lastXRPose = r, r) {
          var o = r.transform.position;
          this.pointer.position.set(o.x, o.y, o.z);
          var a = r.transform.orientation;
          this.pointer.rotationQuaternion.set(a.x, a.y, a.z, a.w), this._scene.useRightHandedSystem || (this.pointer.position.z *= -1, this.pointer.rotationQuaternion.z *= -1, this.pointer.rotationQuaternion.w *= -1), this.pointer.parent = i.parent;
        }
        if (this.inputSource.gripSpace && this.grip) {
          var s = t.getPose(this.inputSource.gripSpace, e);
          if (s) {
            o = s.transform.position;
            var l = s.transform.orientation;
            this.grip.position.set(o.x, o.y, o.z), this.grip.rotationQuaternion.set(l.x, l.y, l.z, l.w), this._scene.useRightHandedSystem || (this.grip.position.z *= -1, this.grip.rotationQuaternion.z *= -1, this.grip.rotationQuaternion.w *= -1);
          }
          this.grip.parent = i.parent;
        }
        this.motionController && this.motionController.updateFromXRFrame(t);
      }, n;
    }(), Dy = function() {
      function n(t, e, i) {
        i === void 0 && (i = {});
        var r = this;
        if (this.xrSessionManager = t, this.xrCamera = e, this._options = i, this.controllers = [], this.onControllerAddedObservable = new H(), this.onControllerRemovedObservable = new H(), this._onInputSourcesChange = function(o) {
          r._addAndRemoveControllers(o.added, o.removed);
        }, this._sessionEndedObserver = this.xrSessionManager.onXRSessionEnded.add(function() {
          r._addAndRemoveControllers([], r.controllers.map(function(o) {
            return o.inputSource;
          }));
        }), this._sessionInitObserver = this.xrSessionManager.onXRSessionInit.add(function(o) {
          o.addEventListener("inputsourceschange", r._onInputSourcesChange);
        }), this._frameObserver = this.xrSessionManager.onXRFrameObservable.add(function(o) {
          r.controllers.forEach(function(a) {
            a.updateFromXRFrame(o, r.xrSessionManager.referenceSpace, r.xrCamera);
          });
        }), this._options.customControllersRepositoryURL && (Qn.BaseRepositoryUrl = this._options.customControllersRepositoryURL), Qn.UseOnlineRepository = !this._options.disableOnlineControllerRepository, Qn.UseOnlineRepository)
          try {
            Qn.UpdateProfilesList().catch(function() {
              Qn.UseOnlineRepository = !1;
            });
          } catch {
            Qn.UseOnlineRepository = !1;
          }
      }
      return n.prototype._addAndRemoveControllers = function(t, e) {
        for (var i = this, r = this.controllers.map(function(h) {
          return h.inputSource;
        }), o = 0, a = t; o < a.length; o++) {
          var s = a[o];
          if (r.indexOf(s) === -1) {
            var l = new Oy(this.xrSessionManager.scene, s, je(je({}, this._options.controllerOptions || {}), { forceControllerProfile: this._options.forceInputProfile, doNotLoadControllerMesh: this._options.doNotLoadControllerMeshes, disableMotionControllerAnimation: this._options.disableControllerAnimation }));
            this.controllers.push(l), this.onControllerAddedObservable.notifyObservers(l);
          }
        }
        var c = [], u = [];
        this.controllers.forEach(function(h) {
          e.indexOf(h.inputSource) === -1 ? c.push(h) : u.push(h);
        }), this.controllers = c, u.forEach(function(h) {
          i.onControllerRemovedObservable.notifyObservers(h), h.dispose();
        });
      }, n.prototype.dispose = function() {
        this.controllers.forEach(function(t) {
          t.dispose();
        }), this.xrSessionManager.onXRFrameObservable.remove(this._frameObserver), this.xrSessionManager.onXRSessionInit.remove(this._sessionInitObserver), this.xrSessionManager.onXRSessionEnded.remove(this._sessionEndedObserver), this.onControllerAddedObservable.clear(), this.onControllerRemovedObservable.clear(), Qn.ClearControllerCache();
      }, n;
    }(), Zc = function(n) {
      function t(e, i) {
        var r = n.call(this, e) || this;
        return r._options = i, r._attachController = function(o) {
          var a;
          if (!r._controllers[o.uniqueId]) {
            var s = (a = r._generateNewMeshPair(o.pointer)).laserPointer, l = a.selectionMesh;
            switch (r._controllers[o.uniqueId] = { xrController: o, laserPointer: s, selectionMesh: l, meshUnderPointer: null, pick: null, tmpRay: new gi(new v(), new v()), disabledByNearInteraction: !1, id: t._IdCounter++ }, r._attachedController ? !r._options.enablePointerSelectionOnAllControllers && r._options.preferredHandedness && o.inputSource.handedness === r._options.preferredHandedness && (r._attachedController = o.uniqueId) : r._options.enablePointerSelectionOnAllControllers || (r._attachedController = o.uniqueId), o.inputSource.targetRayMode) {
              case "tracked-pointer":
                return r._attachTrackedPointerRayMode(o);
              case "gaze":
                return r._attachGazeMode(o);
              case "screen":
                return r._attachScreenRayMode(o);
            }
          }
        }, r._controllers = {}, r._tmpVectorForPickCompare = new v(), r.disablePointerLighting = !0, r.disableSelectionMeshLighting = !0, r.displayLaserPointer = !0, r.displaySelectionMesh = !0, r.laserPointerPickedColor = new ne(0.9, 0.9, 0.9), r.laserPointerDefaultColor = new ne(0.7, 0.7, 0.7), r.selectionMeshDefaultColor = new ne(0.8, 0.8, 0.8), r.selectionMeshPickedColor = new ne(0.3, 0.3, 1), r._identityMatrix = B.Identity(), r._screenCoordinatesRef = v.Zero(), r._viewportRef = new xr(0, 0, 0, 0), r._scene = r._xrSessionManager.scene, r;
      }
      return D(t, n), t.prototype.attach = function() {
        var e, i = this;
        if (!n.prototype.attach.call(this))
          return !1;
        if (this._options.xrInput.controllers.forEach(this._attachController), this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable, this._attachController), this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable, function(s) {
          i._detachController(s.uniqueId);
        }), this._scene.constantlyUpdateMeshUnderPointer = !0, this._options.gazeCamera) {
          var r = this._options.gazeCamera, o = (e = this._generateNewMeshPair(r)).laserPointer, a = e.selectionMesh;
          this._controllers.camera = { webXRCamera: r, laserPointer: o, selectionMesh: a, meshUnderPointer: null, pick: null, tmpRay: new gi(new v(), new v()), disabledByNearInteraction: !1, id: t._IdCounter++ }, this._attachGazeMode();
        }
        return !0;
      }, t.prototype.detach = function() {
        var e = this;
        return !!n.prototype.detach.call(this) && (Object.keys(this._controllers).forEach(function(i) {
          e._detachController(i);
        }), !0);
      }, t.prototype.getMeshUnderPointer = function(e) {
        return this._controllers[e] ? this._controllers[e].meshUnderPointer : null;
      }, t.prototype.getXRControllerByPointerId = function(e) {
        for (var i = Object.keys(this._controllers), r = 0; r < i.length; ++r)
          if (this._controllers[i[r]].id === e)
            return this._controllers[i[r]].xrController || null;
        return null;
      }, t.prototype._getPointerSelectionDisabledByPointerId = function(e) {
        for (var i = Object.keys(this._controllers), r = 0; r < i.length; ++r)
          if (this._controllers[i[r]].id === e)
            return this._controllers[i[r]].disabledByNearInteraction;
        return !0;
      }, t.prototype._setPointerSelectionDisabledByPointerId = function(e, i) {
        for (var r = Object.keys(this._controllers), o = 0; o < r.length; ++o)
          if (this._controllers[r[o]].id === e)
            return void (this._controllers[r[o]].disabledByNearInteraction = i);
      }, t.prototype._onXRFrame = function(e) {
        var i = this;
        Object.keys(this._controllers).forEach(function(r) {
          var o, a = i._controllers[r];
          if (!i._options.enablePointerSelectionOnAllControllers && r !== i._attachedController || a.disabledByNearInteraction)
            return a.selectionMesh.isVisible = !1, a.laserPointer.isVisible = !1, void (a.pick = null);
          if (a.laserPointer.isVisible = i.displayLaserPointer, a.xrController)
            o = a.xrController.pointer.position, a.xrController.getWorldPointerRayToRef(a.tmpRay);
          else {
            if (!a.webXRCamera)
              return;
            o = a.webXRCamera.position, a.webXRCamera.getForwardRayToRef(a.tmpRay);
          }
          if (i._options.maxPointerDistance && (a.tmpRay.length = i._options.maxPointerDistance), !i._options.disableScenePointerVectorUpdate && o) {
            var s = i._xrSessionManager.scene, l = i._options.xrInput.xrCamera;
            l && (l.viewport.toGlobalToRef(s.getEngine().getRenderWidth(), s.getEngine().getRenderHeight(), i._viewportRef), v.ProjectToRef(o, i._identityMatrix, s.getTransformMatrix(), i._viewportRef, i._screenCoordinatesRef), typeof i._screenCoordinatesRef.x != "number" || typeof i._screenCoordinatesRef.y != "number" || isNaN(i._screenCoordinatesRef.x) || isNaN(i._screenCoordinatesRef.y) || (s.pointerX = i._screenCoordinatesRef.x, s.pointerY = i._screenCoordinatesRef.y, a.screenCoordinates = { x: i._screenCoordinatesRef.x, y: i._screenCoordinatesRef.y }));
          }
          var c = null;
          i._utilityLayerScene && (c = i._utilityLayerScene.pickWithRay(a.tmpRay, i._utilityLayerScene.pointerMovePredicate || i.raySelectionPredicate));
          var u = i._scene.pickWithRay(a.tmpRay, i._scene.pointerMovePredicate || i.raySelectionPredicate);
          c && c.hit ? u && u.hit ? c.distance < u.distance ? a.pick = c : a.pick = u : a.pick = c : a.pick = u, a.pick && a.xrController && (a.pick.aimTransform = a.xrController.pointer, a.pick.gripTransform = a.xrController.grip || null);
          var h = a.pick;
          if (h && h.pickedPoint && h.hit) {
            i._updatePointerDistance(a.laserPointer, h.distance), a.selectionMesh.position.copyFrom(h.pickedPoint), a.selectionMesh.scaling.x = Math.sqrt(h.distance), a.selectionMesh.scaling.y = Math.sqrt(h.distance), a.selectionMesh.scaling.z = Math.sqrt(h.distance);
            var d = i._convertNormalToDirectionOfRay(h.getNormal(!0), a.tmpRay);
            if (a.selectionMesh.position.copyFrom(h.pickedPoint), d) {
              var p = v.Cross(qi.Y, d), f = v.Cross(d, p);
              v.RotationFromAxisToRef(f, d, p, a.selectionMesh.rotation), a.selectionMesh.position.addInPlace(d.scale(1e-3));
            }
            a.selectionMesh.isVisible = i.displaySelectionMesh, a.meshUnderPointer = h.pickedMesh;
          } else
            a.selectionMesh.isVisible = !1, i._updatePointerDistance(a.laserPointer, 1), a.meshUnderPointer = null;
        });
      }, Object.defineProperty(t.prototype, "_utilityLayerScene", { get: function() {
        return this._options.customUtilityLayerScene || Fi.DefaultUtilityLayer.utilityLayerScene;
      }, enumerable: !1, configurable: !0 }), t.prototype._attachGazeMode = function(e) {
        var i = this, r = this._controllers[e && e.uniqueId || "camera"], o = this._options.timeToSelect || 3e3, a = this._options.useUtilityLayer ? this._utilityLayerScene : this._scene, s = new Ki(), l = eo("selection", { diameter: 0.0525, thickness: 0.015, tessellation: 20 }, a);
        l.isVisible = !1, l.isPickable = !1, l.parent = r.selectionMesh;
        var c = 0, u = !1, h = { pointerId: r.id, pointerType: "xr" };
        r.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add(function() {
          if (r.pick) {
            if (i._augmentPointerInit(h, r.id, r.screenCoordinates), r.laserPointer.material.alpha = 0, l.isVisible = !1, r.pick.hit)
              if (i._pickingMoved(s, r.pick))
                u && (i._options.disablePointerUpOnTouchOut || i._scene.simulatePointerUp(r.pick, h)), u = !1, c = 0;
              else if (c > o / 10 && (l.isVisible = !0), (c += i._scene.getEngine().getDeltaTime()) >= o)
                i._scene.simulatePointerDown(r.pick, h), u = !0, i._options.disablePointerUpOnTouchOut && i._scene.simulatePointerUp(r.pick, h), l.isVisible = !1;
              else {
                var d = 1 - c / o;
                l.scaling.set(d, d, d);
              }
            else
              u = !1, c = 0;
            i._scene.simulatePointerMove(r.pick, h), s = r.pick;
          }
        }), this._options.renderingGroupId !== void 0 && (l.renderingGroupId = this._options.renderingGroupId), e && e.onDisposeObservable.addOnce(function() {
          r.pick && !i._options.disablePointerUpOnTouchOut && u && (i._scene.simulatePointerUp(r.pick, h), r.finalPointerUpTriggered = !0), l.dispose();
        });
      }, t.prototype._attachScreenRayMode = function(e) {
        var i = this, r = this._controllers[e.uniqueId], o = !1, a = { pointerId: r.id, pointerType: "xr" };
        r.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add(function() {
          i._augmentPointerInit(a, r.id, r.screenCoordinates), !r.pick || i._options.disablePointerUpOnTouchOut && o || (o ? i._scene.simulatePointerMove(r.pick, a) : (i._scene.simulatePointerDown(r.pick, a), r.pointerDownTriggered = !0, o = !0, i._options.disablePointerUpOnTouchOut && i._scene.simulatePointerUp(r.pick, a)));
        }), e.onDisposeObservable.addOnce(function() {
          i._augmentPointerInit(a, r.id, r.screenCoordinates), i._xrSessionManager.runInXRFrame(function() {
            r.pick && !r.finalPointerUpTriggered && o && !i._options.disablePointerUpOnTouchOut && (i._scene.simulatePointerUp(r.pick, a), r.finalPointerUpTriggered = !0);
          });
        });
      }, t.prototype._attachTrackedPointerRayMode = function(e) {
        var i = this, r = this._controllers[e.uniqueId];
        if (this._options.forceGazeMode)
          return this._attachGazeMode(e);
        var o = { pointerId: r.id, pointerType: "xr" };
        if (r.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add(function() {
          r.laserPointer.material.disableLighting = i.disablePointerLighting, r.selectionMesh.material.disableLighting = i.disableSelectionMeshLighting, r.pick && (i._augmentPointerInit(o, r.id, r.screenCoordinates), i._scene.simulatePointerMove(r.pick, o));
        }), e.inputSource.gamepad) {
          var a = function(c) {
            i._options.overrideButtonId && (r.selectionComponent = c.getComponent(i._options.overrideButtonId)), r.selectionComponent || (r.selectionComponent = c.getMainComponent()), r.onButtonChangedObserver = r.selectionComponent.onButtonStateChangedObservable.add(function(u) {
              if (u.changes.pressed) {
                var h = u.changes.pressed.current;
                r.pick ? (i._options.enablePointerSelectionOnAllControllers || e.uniqueId === i._attachedController) && (i._augmentPointerInit(o, r.id, r.screenCoordinates), h ? (i._scene.simulatePointerDown(r.pick, o), r.pointerDownTriggered = !0, r.selectionMesh.material.emissiveColor = i.selectionMeshPickedColor, r.laserPointer.material.emissiveColor = i.laserPointerPickedColor) : (i._scene.simulatePointerUp(r.pick, o), r.selectionMesh.material.emissiveColor = i.selectionMeshDefaultColor, r.laserPointer.material.emissiveColor = i.laserPointerDefaultColor)) : !h || i._options.enablePointerSelectionOnAllControllers || i._options.disableSwitchOnClick || (i._attachedController = e.uniqueId);
              }
            });
          };
          e.motionController ? a(e.motionController) : e.onMotionControllerInitObservable.add(a);
        } else {
          var s = function(c) {
            i._augmentPointerInit(o, r.id, r.screenCoordinates), r.xrController && c.inputSource === r.xrController.inputSource && r.pick && (i._scene.simulatePointerDown(r.pick, o), r.pointerDownTriggered = !0, r.selectionMesh.material.emissiveColor = i.selectionMeshPickedColor, r.laserPointer.material.emissiveColor = i.laserPointerPickedColor);
          }, l = function(c) {
            i._augmentPointerInit(o, r.id, r.screenCoordinates), r.xrController && c.inputSource === r.xrController.inputSource && r.pick && (i._scene.simulatePointerUp(r.pick, o), r.selectionMesh.material.emissiveColor = i.selectionMeshDefaultColor, r.laserPointer.material.emissiveColor = i.laserPointerDefaultColor);
          };
          r.eventListeners = { selectend: l, selectstart: s }, this._xrSessionManager.session.addEventListener("selectstart", s), this._xrSessionManager.session.addEventListener("selectend", l);
        }
      }, t.prototype._convertNormalToDirectionOfRay = function(e, i) {
        return e && Math.acos(v.Dot(e, i.direction)) < Math.PI / 2 && e.scaleInPlace(-1), e;
      }, t.prototype._detachController = function(e) {
        var i = this, r = this._controllers[e];
        if (r) {
          if (r.selectionComponent && r.onButtonChangedObserver && r.selectionComponent.onButtonStateChangedObservable.remove(r.onButtonChangedObserver), r.onFrameObserver && this._xrSessionManager.onXRFrameObservable.remove(r.onFrameObserver), r.eventListeners && Object.keys(r.eventListeners).forEach(function(a) {
            var s = r.eventListeners && r.eventListeners[a];
            s && i._xrSessionManager.session.removeEventListener(a, s);
          }), !r.finalPointerUpTriggered && r.pointerDownTriggered) {
            var o = { pointerId: r.id, pointerType: "xr" };
            this._xrSessionManager.runInXRFrame(function() {
              i._augmentPointerInit(o, r.id, r.screenCoordinates), i._scene.simulatePointerUp(r.pick || new Ki(), o), r.finalPointerUpTriggered = !0;
            });
          }
          this._xrSessionManager.scene.onBeforeRenderObservable.addOnce(function() {
            try {
              if (r.selectionMesh.dispose(), r.laserPointer.dispose(), delete i._controllers[e], i._attachedController === e) {
                var a = Object.keys(i._controllers);
                a.length ? i._attachedController = a[0] : i._attachedController = "";
              }
            } catch {
              de.Warn("controller already detached.");
            }
          });
        }
      }, t.prototype._generateNewMeshPair = function(e) {
        var i = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || Fi.DefaultUtilityLayer.utilityLayerScene : this._scene, r = this._options.customLasterPointerMeshGenerator ? this._options.customLasterPointerMeshGenerator() : Fn("laserPointer", { height: 1, diameterTop: 2e-4, diameterBottom: 4e-3, tessellation: 20, subdivisions: 1 }, i);
        r.parent = e;
        var o = new Gt("laserPointerMat", i);
        o.emissiveColor = this.laserPointerDefaultColor, o.alpha = 0.7, r.material = o, r.rotation.x = Math.PI / 2, this._updatePointerDistance(r, 1), r.isPickable = !1, r.isVisible = !1;
        var a = this._options.customSelectionMeshGenerator ? this._options.customSelectionMeshGenerator() : eo("gazeTracker", { diameter: 0.0105, thickness: 75e-4, tessellation: 20 }, i);
        a.bakeCurrentTransformIntoVertices(), a.isPickable = !1, a.isVisible = !1;
        var s = new Gt("targetMat", i);
        return s.specularColor = ne.Black(), s.emissiveColor = this.selectionMeshDefaultColor, s.backFaceCulling = !1, a.material = s, this._options.renderingGroupId !== void 0 && (r.renderingGroupId = this._options.renderingGroupId, a.renderingGroupId = this._options.renderingGroupId), { laserPointer: r, selectionMesh: a };
      }, t.prototype._pickingMoved = function(e, i) {
        var r;
        if (!e.hit || !i.hit || !(e.pickedMesh && e.pickedPoint && i.pickedMesh && i.pickedPoint) || e.pickedMesh !== i.pickedMesh)
          return !0;
        (r = e.pickedPoint) === null || r === void 0 || r.subtractToRef(i.pickedPoint, this._tmpVectorForPickCompare), this._tmpVectorForPickCompare.set(Math.abs(this._tmpVectorForPickCompare.x), Math.abs(this._tmpVectorForPickCompare.y), Math.abs(this._tmpVectorForPickCompare.z));
        var o = 0.01 * (this._options.gazeModePointerMovedFactor || 1) * i.distance;
        return this._tmpVectorForPickCompare.length() > o;
      }, t.prototype._updatePointerDistance = function(e, i) {
        i === void 0 && (i = 100), e.scaling.y = i, this._scene.useRightHandedSystem && (i *= -1), e.position.z = i / 2 + 0.05;
      }, t.prototype._augmentPointerInit = function(e, i, r) {
        e.pointerId = i, e.pointerType = "xr", r && (e.screenX = r.x, e.screenY = r.y);
      }, Object.defineProperty(t.prototype, "lasterPointerDefaultColor", { get: function() {
        return this.laserPointerDefaultColor;
      }, enumerable: !1, configurable: !0 }), t._IdCounter = 200, t.Name = vi.POINTER_SELECTION, t.Version = 1, t;
    }(Qi);
    Wi.AddWebXRFeature(Zc.Name, function(n, t) {
      return function() {
        return new Zc(n, t);
      };
    }, Zc.Version, !0), Yn.prototype._projectOnTrianglesToRef = function(n, t, e, i, r, o) {
      for (var a = F.Vector3[0], s = F.Vector3[1], l = 1 / 0, c = this.indexStart; c < this.indexStart + this.indexCount - (3 - i); c += i) {
        var u = e[c], h = e[c + 1], d = e[c + 2];
        if (r && d === 4294967295)
          c += 2;
        else {
          var p = t[u], f = t[h], m = t[d];
          if (p && f && m) {
            var g = v.ProjectOnTriangleToRef(n, p, f, m, s);
            g < l && (a.copyFrom(s), l = g);
          }
        }
      }
      return o.copyFrom(a), l;
    }, Yn.prototype._projectOnUnIndexedTrianglesToRef = function(n, t, e, i) {
      for (var r = F.Vector3[0], o = F.Vector3[1], a = 1 / 0, s = this.verticesStart; s < this.verticesStart + this.verticesCount; s += 3) {
        var l = t[s], c = t[s + 1], u = t[s + 2], h = v.ProjectOnTriangleToRef(n, l, c, u, o);
        h < a && (r.copyFrom(o), a = h);
      }
      return i.copyFrom(r), a;
    }, Yn.prototype.projectToRef = function(n, t, e, i) {
      var r = this.getMaterial();
      if (!r)
        return -1;
      var o = 3, a = !1;
      switch (r.fillMode) {
        case _.MATERIAL_PointListDrawMode:
        case _.MATERIAL_LineLoopDrawMode:
        case _.MATERIAL_LineStripDrawMode:
        case _.MATERIAL_TriangleFanDrawMode:
          return -1;
        case _.MATERIAL_TriangleStripDrawMode:
          o = 1, a = !0;
      }
      return r.fillMode === _.MATERIAL_LineListDrawMode ? -1 : !e.length && this._mesh._unIndexed ? this._projectOnUnIndexedTrianglesToRef(n, t, e, i) : this._projectOnTrianglesToRef(n, t, e, o, a, i);
    }, function(n) {
      n[n.DEHYDRATED = 0] = "DEHYDRATED", n[n.HOVER = 1] = "HOVER", n[n.TOUCH = 2] = "TOUCH";
    }(Mr || (Mr = {})), function(n) {
      n[n.DISABLED = 0] = "DISABLED", n[n.CENTERED_ON_CONTROLLER = 1] = "CENTERED_ON_CONTROLLER", n[n.CENTERED_IN_FRONT = 2] = "CENTERED_IN_FRONT";
    }(qa || (qa = {}));
    var Jc = function(n) {
      function t(e, i) {
        var r = n.call(this, e) || this;
        return r._options = i, r._tmpRay = new gi(new v(), new v()), r._attachController = function(o) {
          var a;
          if (!r._controllers[o.uniqueId]) {
            var s = (a = r._generateNewTouchPointMesh()).touchCollisionMesh, l = a.touchCollisionMeshFunction, c = a.hydrateCollisionMeshFunction, u = r._generateVisualCue();
            switch (r._controllers[o.uniqueId] = { xrController: o, meshUnderPointer: null, nearInteractionTargetMesh: null, pick: null, stalePick: null, touchCollisionMesh: s, touchCollisionMeshFunction: l, hydrateCollisionMeshFunction: c, currentAnimationState: Mr.DEHYDRATED, grabRay: new gi(new v(), new v()), hoverInteraction: !1, nearInteraction: !1, grabInteraction: !1, id: t._IdCounter++, pickedPointVisualCue: u }, r._attachedController ? !r._options.enableNearInteractionOnAllControllers && r._options.preferredHandedness && o.inputSource.handedness === r._options.preferredHandedness && (r._attachedController = o.uniqueId) : r._options.enableNearInteractionOnAllControllers || (r._attachedController = o.uniqueId), o.inputSource.targetRayMode) {
              case "tracked-pointer":
                return r._attachNearInteractionMode(o);
              case "gaze":
              case "screen":
                return null;
            }
          }
        }, r._controllers = {}, r._farInteractionFeature = null, r.selectionMeshDefaultColor = new ne(0.8, 0.8, 0.8), r.selectionMeshPickedColor = new ne(0.3, 0.3, 1), r._hoverRadius = 0.1, r._pickRadius = 0.02, r._controllerPickRadius = 0.03, r._nearGrabLengthScale = 5, r._scene = r._xrSessionManager.scene, r._options.nearInteractionControllerMode === void 0 && (r._options.nearInteractionControllerMode = qa.CENTERED_IN_FRONT), r._options.farInteractionFeature && (r._farInteractionFeature = r._options.farInteractionFeature), r;
      }
      return D(t, n), t.prototype.attach = function() {
        var e = this;
        return !!n.prototype.attach.call(this) && (this._options.xrInput.controllers.forEach(this._attachController), this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable, this._attachController), this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable, function(i) {
          e._detachController(i.uniqueId);
        }), this._scene.constantlyUpdateMeshUnderPointer = !0, !0);
      }, t.prototype.detach = function() {
        var e = this;
        return !!n.prototype.detach.call(this) && (Object.keys(this._controllers).forEach(function(i) {
          e._detachController(i);
        }), !0);
      }, t.prototype.getMeshUnderPointer = function(e) {
        return this._controllers[e] ? this._controllers[e].meshUnderPointer : null;
      }, t.prototype.getXRControllerByPointerId = function(e) {
        for (var i = Object.keys(this._controllers), r = 0; r < i.length; ++r)
          if (this._controllers[i[r]].id === e)
            return this._controllers[i[r]].xrController || null;
        return null;
      }, t.prototype.setFarInteractionFeature = function(e) {
        this._farInteractionFeature = e;
      }, t.prototype._nearPickPredicate = function(e) {
        return e.isEnabled() && e.isVisible && e.isPickable && e.isNearPickable;
      }, t.prototype._nearGrabPredicate = function(e) {
        return e.isEnabled() && e.isVisible && e.isPickable && e.isNearGrabbable;
      }, t.prototype._nearInteractionPredicate = function(e) {
        return e.isEnabled() && e.isVisible && e.isPickable && (e.isNearPickable || e.isNearGrabbable);
      }, t.prototype._controllerAvailablePredicate = function(e, i) {
        for (var r = e; r; ) {
          if (r.reservedDataStore && r.reservedDataStore.nearInteraction && r.reservedDataStore.nearInteraction.excludedControllerId === i)
            return !1;
          r = r.parent;
        }
        return !0;
      }, t.prototype._handleTransitionAnimation = function(e, i) {
        var r;
        if (e.currentAnimationState !== i && this._options.nearInteractionControllerMode === qa.CENTERED_IN_FRONT && !(!((r = e.xrController) === null || r === void 0) && r.inputSource.hand)) {
          if (i > e.currentAnimationState)
            switch (e.currentAnimationState) {
              case Mr.DEHYDRATED:
                if (e.hydrateCollisionMeshFunction(!0), i === Mr.HOVER)
                  break;
              case Mr.HOVER:
                if (e.touchCollisionMeshFunction(!0), i === Mr.TOUCH)
                  break;
            }
          else
            switch (e.currentAnimationState) {
              case Mr.TOUCH:
                if (e.touchCollisionMeshFunction(!1), i === Mr.HOVER)
                  break;
              case Mr.HOVER:
                if (e.hydrateCollisionMeshFunction(!1), i === Mr.DEHYDRATED)
                  break;
            }
          e.currentAnimationState = i;
        }
      }, t.prototype._processTouchPoint = function(e, i, r) {
        var o, a = this._controllers[e];
        a.grabRay.origin.copyFrom(i), r.toEulerAnglesToRef(F.Vector3[0]), a.grabRay.direction.copyFrom(F.Vector3[0]), this._options.nearInteractionControllerMode !== qa.CENTERED_IN_FRONT || !((o = a.xrController) === null || o === void 0) && o.inputSource.hand || (a.xrController.getWorldPointerRayToRef(this._tmpRay), a.grabRay.origin.addInPlace(this._tmpRay.direction.scale(0.05))), a.grabRay.length = this._nearGrabLengthScale * this._hoverRadius, a.touchCollisionMesh.position.copyFrom(a.grabRay.origin);
      }, t.prototype._onXRFrame = function(e) {
        var i = this;
        Object.keys(this._controllers).forEach(function(r) {
          var o, a = i._controllers[r], s = (o = a.xrController) === null || o === void 0 ? void 0 : o.inputSource.hand;
          if ((i._options.enableNearInteractionOnAllControllers || r === i._attachedController) && a.xrController && (s || i._options.nearInteractionControllerMode && a.xrController.inputSource.gamepad)) {
            if (a.hoverInteraction = !1, a.nearInteraction = !1, a.xrController) {
              if (s) {
                var l = s.get("index-finger-tip");
                if (l) {
                  var c = e.getJointPose(l, i._xrSessionManager.referenceSpace);
                  if (c && c.transform) {
                    var u = i._scene.useRightHandedSystem ? 1 : -1;
                    F.Vector3[0].set(c.transform.position.x, c.transform.position.y, c.transform.position.z * u), F.Quaternion[0].set(c.transform.orientation.x, c.transform.orientation.y, c.transform.orientation.z * u, c.transform.orientation.w * u), i._processTouchPoint(r, F.Vector3[0], F.Quaternion[0]);
                  }
                }
              } else if (a.xrController.inputSource.gamepad && i._options.nearInteractionControllerMode !== qa.DISABLED) {
                var h = a.xrController.pointer;
                a.xrController.grip && i._options.nearInteractionControllerMode === qa.CENTERED_ON_CONTROLLER && (h = a.xrController.grip), i._processTouchPoint(r, h.position, h.rotationQuaternion);
              }
              var d = function(E, A) {
                return A && A.hit ? E && E.hit ? A.distance < E.distance ? A : E : A : E;
              }, p = function(E) {
                var A = new Ki(), R = !1, C = E && E.pickedPoint && E.hit;
                return E != null && E.pickedPoint && (R = E.pickedPoint.x === 0 && E.pickedPoint.y === 0 && E.pickedPoint.z === 0), C && !R && (A = E), A;
              };
              if (!a.grabInteraction) {
                var f = null, m = null;
                i._options.useUtilityLayer && i._utilityLayerScene && (m = i._pickWithSphere(a, i._hoverRadius, i._utilityLayerScene, function(E) {
                  return i._nearInteractionPredicate(E);
                }));
                var g = d(i._pickWithSphere(a, i._hoverRadius, i._scene, function(E) {
                  return i._nearInteractionPredicate(E);
                }), m);
                if (g && g.hit && (f = p(g)).hit && (a.hoverInteraction = !0), a.hoverInteraction) {
                  var y = null, b = s ? i._pickRadius : i._controllerPickRadius;
                  i._options.useUtilityLayer && i._utilityLayerScene && (y = i._pickWithSphere(a, b, i._utilityLayerScene, function(E) {
                    return i._nearPickPredicate(E);
                  }));
                  var T = p(d(i._pickWithSphere(a, b, i._scene, function(E) {
                    return i._nearPickPredicate(E);
                  }), y));
                  T.hit && (f = T, a.nearInteraction = !0);
                }
                a.stalePick = a.pick, a.pick = f, a.pick && a.pick.pickedPoint && a.pick.hit ? (a.meshUnderPointer = a.pick.pickedMesh, a.pickedPointVisualCue.position.copyFrom(a.pick.pickedPoint), a.pickedPointVisualCue.isVisible = !0, i._farInteractionFeature && i._farInteractionFeature.attached && i._farInteractionFeature._setPointerSelectionDisabledByPointerId(a.id, !0)) : (a.meshUnderPointer = null, a.pickedPointVisualCue.isVisible = !1, i._farInteractionFeature && i._farInteractionFeature.attached && i._farInteractionFeature._setPointerSelectionDisabledByPointerId(a.id, !1));
              }
              var S = Mr.DEHYDRATED;
              a.grabInteraction || a.nearInteraction ? S = Mr.TOUCH : a.hoverInteraction && (S = Mr.HOVER), i._handleTransitionAnimation(a, S);
            }
          } else
            a.pick = null;
        });
      }, Object.defineProperty(t.prototype, "_utilityLayerScene", { get: function() {
        return this._options.customUtilityLayerScene || Fi.DefaultUtilityLayer.utilityLayerScene;
      }, enumerable: !1, configurable: !0 }), t.prototype._generateVisualCue = function() {
        var e = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || Fi.DefaultUtilityLayer.utilityLayerScene : this._scene, i = yn("nearInteraction", { diameter: 0.0105 }, e);
        i.bakeCurrentTransformIntoVertices(), i.isPickable = !1, i.isVisible = !1, i.rotationQuaternion = oe.Identity();
        var r = new Gt("targetMat", e);
        return r.specularColor = ne.Black(), r.emissiveColor = this.selectionMeshDefaultColor, r.backFaceCulling = !1, i.material = r, i;
      }, t.prototype._isControllerReadyForNearInteraction = function(e) {
        return !this._farInteractionFeature || this._farInteractionFeature._getPointerSelectionDisabledByPointerId(e);
      }, t.prototype._attachNearInteractionMode = function(e) {
        var i = this, r = this._controllers[e.uniqueId], o = { pointerId: r.id, pointerType: "xr-near" };
        r.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add(function() {
          (i._options.enableNearInteractionOnAllControllers || e.uniqueId === i._attachedController) && r.xrController && (r.xrController.inputSource.hand || i._options.nearInteractionControllerMode && r.xrController.inputSource.gamepad) && (r.pick && (r.pick.ray = r.grabRay), r.pick && i._isControllerReadyForNearInteraction(r.id) && i._scene.simulatePointerMove(r.pick, o), r.nearInteraction && r.pick && r.pick.hit ? r.nearInteractionTargetMesh || (i._scene.simulatePointerDown(r.pick, o), r.nearInteractionTargetMesh = r.meshUnderPointer) : r.nearInteractionTargetMesh && r.stalePick && (i._scene.simulatePointerUp(r.stalePick, o), r.nearInteractionTargetMesh = null));
        });
        var a = function(u) {
          i._options.enableNearInteractionOnAllControllers || e.uniqueId === i._attachedController && i._isControllerReadyForNearInteraction(r.id) ? (r.pick && (r.pick.ray = r.grabRay), u && r.pick && r.meshUnderPointer && i._nearGrabPredicate(r.meshUnderPointer) ? (r.grabInteraction = !0, r.pickedPointVisualCue.isVisible = !1, i._scene.simulatePointerDown(r.pick, o)) : !u && r.pick && r.grabInteraction && (i._scene.simulatePointerUp(r.pick, o), r.grabInteraction = !1, r.pickedPointVisualCue.isVisible = !0)) : !u || i._options.enableNearInteractionOnAllControllers || i._options.disableSwitchOnClick || (i._attachedController = e.uniqueId);
        };
        if (e.inputSource.gamepad) {
          var s = function(u) {
            r.squeezeComponent = u.getComponent("grasp"), r.squeezeComponent ? r.onSqueezeButtonChangedObserver = r.squeezeComponent.onButtonStateChangedObservable.add(function(h) {
              if (h.changes.pressed) {
                var d = h.changes.pressed.current;
                a(d);
              }
            }) : (r.selectionComponent = u.getMainComponent(), r.onButtonChangedObserver = r.selectionComponent.onButtonStateChangedObservable.add(function(h) {
              if (h.changes.pressed) {
                var d = h.changes.pressed.current;
                a(d);
              }
            }));
          };
          e.motionController ? s(e.motionController) : e.onMotionControllerInitObservable.add(s);
        } else {
          var l = function(u) {
            r.xrController && u.inputSource === r.xrController.inputSource && r.pick && i._isControllerReadyForNearInteraction(r.id) && r.meshUnderPointer && i._nearGrabPredicate(r.meshUnderPointer) && (r.grabInteraction = !0, r.pickedPointVisualCue.isVisible = !1, i._scene.simulatePointerDown(r.pick, o));
          }, c = function(u) {
            r.xrController && u.inputSource === r.xrController.inputSource && r.pick && i._isControllerReadyForNearInteraction(r.id) && (i._scene.simulatePointerUp(r.pick, o), r.grabInteraction = !1, r.pickedPointVisualCue.isVisible = !0);
          };
          r.eventListeners = { selectend: c, selectstart: l }, this._xrSessionManager.session.addEventListener("selectstart", l), this._xrSessionManager.session.addEventListener("selectend", c);
        }
      }, t.prototype._detachController = function(e) {
        var i = this, r = this._controllers[e];
        if (r && (r.squeezeComponent && r.onSqueezeButtonChangedObserver && r.squeezeComponent.onButtonStateChangedObservable.remove(r.onSqueezeButtonChangedObserver), r.selectionComponent && r.onButtonChangedObserver && r.selectionComponent.onButtonStateChangedObservable.remove(r.onButtonChangedObserver), r.onFrameObserver && this._xrSessionManager.onXRFrameObservable.remove(r.onFrameObserver), r.eventListeners && Object.keys(r.eventListeners).forEach(function(a) {
          var s = r.eventListeners && r.eventListeners[a];
          s && i._xrSessionManager.session.removeEventListener(a, s);
        }), r.touchCollisionMesh.dispose(), r.pickedPointVisualCue.dispose(), this._xrSessionManager.runInXRFrame(function() {
          var a = { pointerId: r.id, pointerType: "xr-near" };
          i._scene.simulatePointerUp(new Ki(), a);
        }), delete this._controllers[e], this._attachedController === e)) {
          var o = Object.keys(this._controllers);
          o.length ? this._attachedController = o[0] : this._attachedController = "";
        }
      }, t.prototype._generateNewTouchPointMesh = function() {
        var e = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || Fi.DefaultUtilityLayer.utilityLayerScene : this._scene, i = yn("PickSphere", { diameter: 1 }, e);
        i.isVisible = !1, this._options.motionControllerOrbMaterial ? i.material = this._options.motionControllerOrbMaterial : ka.ParseFromSnippetAsync("8RUNKL#3", e).then(function(E) {
          i.material = E;
        });
        var r = new hg();
        r.setEasingMode(xn.EASINGMODE_EASEINOUT);
        var o = new v(this._controllerPickRadius, this._controllerPickRadius, this._controllerPickRadius), a = this._controllerPickRadius * (4 / 3), s = new v(a, a, a), l = this._controllerPickRadius * (7 / 6), c = new v(l, l, l), u = 0.8 * this._controllerPickRadius, h = new v(u, u, u), d = 1.5 * this._controllerPickRadius, p = [{ frame: 0, value: o }, { frame: 10, value: new v(d, d, d) }, { frame: 18, value: s }], f = [{ frame: 0, value: s }, { frame: 10, value: h }, { frame: 18, value: o }], m = [{ frame: 0, value: v.ZeroReadOnly }, { frame: 12, value: c }, { frame: 15, value: o }], g = [{ frame: 0, value: o }, { frame: 10, value: v.ZeroReadOnly }, { frame: 15, value: v.ZeroReadOnly }], y = new Je("touch", "scaling", 60, Je.ANIMATIONTYPE_VECTOR3, Je.ANIMATIONLOOPMODE_CONSTANT), b = new Je("release", "scaling", 60, Je.ANIMATIONTYPE_VECTOR3, Je.ANIMATIONLOOPMODE_CONSTANT), T = new Je("hydrate", "scaling", 60, Je.ANIMATIONTYPE_VECTOR3, Je.ANIMATIONLOOPMODE_CONSTANT), S = new Je("dehydrate", "scaling", 60, Je.ANIMATIONTYPE_VECTOR3, Je.ANIMATIONLOOPMODE_CONSTANT);
        return y.setEasingFunction(r), b.setEasingFunction(r), T.setEasingFunction(r), S.setEasingFunction(r), y.setKeys(p), b.setKeys(f), T.setKeys(m), S.setKeys(g), { touchCollisionMesh: i, touchCollisionMeshFunction: function(E) {
          var A = E ? y : b;
          e.beginDirectAnimation(i, [A], 0, 18, !1, 1);
        }, hydrateCollisionMeshFunction: function(E) {
          var A = E ? T : S;
          E && (i.isVisible = !0), e.beginDirectAnimation(i, [A], 0, 15, !1, 1, function() {
            E || (i.isVisible = !1);
          });
        } };
      }, t.prototype._pickWithSphere = function(e, i, r, o) {
        var a = new Ki();
        if (a.distance = 1 / 0, e.touchCollisionMesh && e.xrController)
          for (var s = e.touchCollisionMesh.position, l = ul.CreateFromCenterAndRadius(s, i), c = 0; c < r.meshes.length; c++) {
            var u = r.meshes[c];
            if (o(u) && this._controllerAvailablePredicate(u, e.xrController.uniqueId)) {
              var h = t.PickMeshWithSphere(u, l);
              h && h.hit && h.distance < a.distance && (a.hit = h.hit, a.pickedMesh = u, a.pickedPoint = h.pickedPoint, a.aimTransform = e.xrController.pointer, a.gripTransform = e.xrController.grip || null, a.originMesh = e.touchCollisionMesh, a.distance = h.distance);
            }
          }
        return a;
      }, t.PickMeshWithSphere = function(e, i, r) {
        r === void 0 && (r = !1);
        var o = e.subMeshes, a = new Ki(), s = e.getBoundingInfo();
        if (!e._generatePointsArray() || !e.subMeshes || !s || !r && !ul.Intersects(s.boundingSphere, i))
          return a;
        var l, c, u, h = F.Vector3[0], d = F.Vector3[1], p = 1 / 0, f = F.Vector3[2], m = F.Matrix[0];
        m.copyFrom(e.getWorldMatrix()), m.invert(), v.TransformCoordinatesToRef(i.center, m, f);
        for (var g = 0; g < o.length; g++)
          o[g].projectToRef(f, e._positions, e.getIndices(), d), v.TransformCoordinatesToRef(d, e.getWorldMatrix(), d), l = v.Distance(d, i.center), u = v.Distance(d, e.getAbsolutePosition()), (c = v.Distance(i.center, e.getAbsolutePosition())) !== -1 && u !== -1 && u > c && (l = 0, d.copyFrom(i.center)), l !== -1 && l < p && (p = l, h.copyFrom(d));
        return p < i.radius && (a.hit = !0, a.distance = p, a.pickedMesh = e, a.pickedPoint = h.clone()), a;
      }, t._IdCounter = 200, t.Name = vi.NEAR_INTERACTION, t.Version = 1, t;
    }(Qi);
    Wi.AddWebXRFeature(Jc.Name, function(n, t) {
      return function() {
        return new Jc(n, t);
      };
    }, Jc.Version, !0);
    var Qa, Ny = function() {
      function n(t, e, i) {
        this.element = t, this.sessionMode = e, this.referenceSpaceType = i;
      }
      return n.prototype.update = function(t) {
      }, n;
    }(), HC = function() {
    }, Fy = function() {
      function n(t, e) {
        var i = this;
        if (this._scene = t, this.options = e, this._activeButton = null, this._buttons = [], this.activeButtonChangedObservable = new H(), this._onSessionGranted = function(u) {
          i._helper && i._enterXRWithButtonIndex(0);
        }, this.overlay = document.createElement("div"), this.overlay.classList.add("xr-button-overlay"), !e.ignoreSessionGrantedEvent && navigator.xr && navigator.xr.addEventListener("sessiongranted", this._onSessionGranted), typeof window < "u" && window.location && window.location.protocol === "http:" && window.location.hostname !== "localhost")
          throw de.Warn("WebXR can only be served over HTTPS"), new Error("WebXR can only be served over HTTPS");
        if (e.customButtons)
          this._buttons = e.customButtons;
        else {
          this.overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;";
          var r = e.sessionMode || "immersive-vr", o = e.referenceSpaceType || "local-floor", a = ".babylonVRicon { color: #868686; border-color: #868686; border-style: solid; margin-left: 10px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-image: url(" + (typeof SVGSVGElement > "u" ? "https://cdn.babylonjs.com/Assets/vrButton.png" : "data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%222048%22%20height%3D%221152%22%20viewBox%3D%220%200%202048%201152%22%20version%3D%221.1%22%3E%3Cpath%20transform%3D%22rotate%28180%201024%2C576.0000000000001%29%22%20d%3D%22m1109%2C896q17%2C0%2030%2C-12t13%2C-30t-12.5%2C-30.5t-30.5%2C-12.5l-170%2C0q-18%2C0%20-30.5%2C12.5t-12.5%2C30.5t13%2C30t30%2C12l170%2C0zm-85%2C256q59%2C0%20132.5%2C-1.5t154.5%2C-5.5t164.5%2C-11.5t163%2C-20t150%2C-30t124.5%2C-41.5q23%2C-11%2042%2C-24t38%2C-30q27%2C-25%2041%2C-61.5t14%2C-72.5l0%2C-257q0%2C-123%20-47%2C-232t-128%2C-190t-190%2C-128t-232%2C-47l-81%2C0q-37%2C0%20-68.5%2C14t-60.5%2C34.5t-55.5%2C45t-53%2C45t-53%2C34.5t-55.5%2C14t-55.5%2C-14t-53%2C-34.5t-53%2C-45t-55.5%2C-45t-60.5%2C-34.5t-68.5%2C-14l-81%2C0q-123%2C0%20-232%2C47t-190%2C128t-128%2C190t-47%2C232l0%2C257q0%2C68%2038%2C115t97%2C73q54%2C24%20124.5%2C41.5t150%2C30t163%2C20t164.5%2C11.5t154.5%2C5.5t132.5%2C1.5zm939%2C-298q0%2C39%20-24.5%2C67t-58.5%2C42q-54%2C23%20-122%2C39.5t-143.5%2C28t-155.5%2C19t-157%2C11t-148.5%2C5t-129.5%2C1.5q-59%2C0%20-130%2C-1.5t-148%2C-5t-157%2C-11t-155.5%2C-19t-143.5%2C-28t-122%2C-39.5q-34%2C-14%20-58.5%2C-42t-24.5%2C-67l0%2C-257q0%2C-106%2040.5%2C-199t110%2C-162.5t162.5%2C-109.5t199%2C-40l81%2C0q27%2C0%2052%2C14t50%2C34.5t51%2C44.5t55.5%2C44.5t63.5%2C34.5t74%2C14t74%2C-14t63.5%2C-34.5t55.5%2C-44.5t51%2C-44.5t50%2C-34.5t52%2C-14l14%2C0q37%2C0%2070%2C0.5t64.5%2C4.5t63.5%2C12t68%2C23q71%2C30%20128.5%2C78.5t98.5%2C110t63.5%2C133.5t22.5%2C149l0%2C257z%22%20fill%3D%22white%22%20/%3E%3C/svg%3E%0A") + "); background-size: 80%; background-repeat:no-repeat; background-position: center; border: none; outline: none; transition: transform 0.125s ease-out } .babylonVRicon:hover { transform: scale(1.05) } .babylonVRicon:active {background-color: rgba(51,51,51,1) } .babylonVRicon:focus {background-color: rgba(51,51,51,1) }";
          a += '.babylonVRicon.vrdisplaypresenting { background-image: none;} .vrdisplaypresenting::after { content: "EXIT"} .xr-error::after { content: "ERROR"}';
          var s = document.createElement("style");
          s.appendChild(document.createTextNode(a)), document.getElementsByTagName("head")[0].appendChild(s);
          var l = document.createElement("button");
          l.className = "babylonVRicon", l.title = "".concat(r, " - ").concat(o), this._buttons.push(new Ny(l, r, o)), this._buttons[this._buttons.length - 1].update = function(u) {
            this.element.style.display = u === null || u === this ? "" : "none", l.className = "babylonVRicon" + (u === this ? " vrdisplaypresenting" : "");
          }, this._updateButtons(null);
        }
        var c = t.getEngine().getInputElement();
        c && c.parentNode && (c.parentNode.appendChild(this.overlay), t.onDisposeObservable.addOnce(function() {
          i.dispose();
        }));
      }
      return n.prototype.setHelperAsync = function(t, e) {
        return Ft(this, void 0, void 0, function() {
          var i, r = this;
          return Bt(this, function(o) {
            switch (o.label) {
              case 0:
                return this._helper = t, this._renderTarget = e, i = this._buttons.map(function(a) {
                  return t.sessionManager.isSessionSupportedAsync(a.sessionMode);
                }), t.onStateChangedObservable.add(function(a) {
                  a == Xi.NOT_IN_XR && r._updateButtons(null);
                }), [4, Promise.all(i)];
              case 1:
                return o.sent().forEach(function(a, s) {
                  a ? (r.overlay.appendChild(r._buttons[s].element), r._buttons[s].element.onclick = r._enterXRWithButtonIndex.bind(r, s)) : de.Warn('Session mode "'.concat(r._buttons[s].sessionMode, '" not supported in browser'));
                }), [2];
            }
          });
        });
      }, n.CreateAsync = function(t, e, i) {
        return Ft(this, void 0, void 0, function() {
          var r;
          return Bt(this, function(o) {
            switch (o.label) {
              case 0:
                return [4, (r = new n(t, i)).setHelperAsync(e, i.renderTarget || void 0)];
              case 1:
                return o.sent(), [2, r];
            }
          });
        });
      }, n.prototype._enterXRWithButtonIndex = function(t) {
        return t === void 0 && (t = 0), Ft(this, void 0, void 0, function() {
          var e, i, r;
          return Bt(this, function(o) {
            switch (o.label) {
              case 0:
                return this._helper.state != Xi.IN_XR ? [3, 2] : [4, this._helper.exitXRAsync()];
              case 1:
                return o.sent(), this._updateButtons(null), [3, 6];
              case 2:
                if (this._helper.state != Xi.NOT_IN_XR)
                  return [3, 6];
                o.label = 3;
              case 3:
                return o.trys.push([3, 5, , 6]), [4, this._helper.enterXRAsync(this._buttons[t].sessionMode, this._buttons[t].referenceSpaceType, this._renderTarget, { optionalFeatures: this.options.optionalFeatures, requiredFeatures: this.options.requiredFeatures })];
              case 4:
                return o.sent(), this._updateButtons(this._buttons[t]), [3, 6];
              case 5:
                return e = o.sent(), this._updateButtons(null), i = this._buttons[t].element, r = i.title, i.title = "Error entering XR session : " + r, i.classList.add("xr-error"), this.options.onError && this.options.onError(e), [3, 6];
              case 6:
                return [2];
            }
          });
        });
      }, n.prototype.dispose = function() {
        var t = this._scene.getEngine().getInputElement();
        t && t.parentNode && t.parentNode.contains(this.overlay) && t.parentNode.removeChild(this.overlay), this.activeButtonChangedObservable.clear(), navigator.xr.removeEventListener("sessiongranted", this._onSessionGranted);
      }, n.prototype._updateButtons = function(t) {
        var e = this;
        this._activeButton = t, this._buttons.forEach(function(i) {
          i.update(e._activeButton);
        }), this.activeButtonChangedObservable.notifyObservers(this._activeButton);
      }, n;
    }();
    function m_(n) {
      var t, e = 0, i = Date.now();
      n.observableParameters = (t = n.observableParameters) !== null && t !== void 0 ? t : {};
      var r = n.contextObservable.add(function(o) {
        var a = Date.now(), s = { startTime: i, currentTime: a, deltaTime: e = a - i, completeRate: e / n.timeout, payload: o };
        n.onTick && n.onTick(s), n.breakCondition && n.breakCondition() && (n.contextObservable.remove(r), n.onAborted && n.onAborted(s)), e >= n.timeout && (n.contextObservable.remove(r), n.onEnded && n.onEnded(s));
      }, n.observableParameters.mask, n.observableParameters.insertFirst, n.observableParameters.scope);
      return r;
    }
    (function(n) {
      n[n.INIT = 0] = "INIT", n[n.STARTED = 1] = "STARTED", n[n.ENDED = 2] = "ENDED";
    })(Qa || (Qa = {}));
    var Ly = function() {
      function n(t) {
        var e, i, r = this;
        this.onEachCountObservable = new H(), this.onTimerAbortedObservable = new H(), this.onTimerEndedObservable = new H(), this.onStateChangedObservable = new H(), this._observer = null, this._breakOnNextTick = !1, this._tick = function(o) {
          var a = Date.now();
          r._timer = a - r._startTime;
          var s = { startTime: r._startTime, currentTime: a, deltaTime: r._timer, completeRate: r._timer / r._timeToEnd, payload: o }, l = r._breakOnNextTick || r._breakCondition(s);
          l || r._timer >= r._timeToEnd ? r._stop(s, l) : r.onEachCountObservable.notifyObservers(s);
        }, this._setState(Qa.INIT), this._contextObservable = t.contextObservable, this._observableParameters = (e = t.observableParameters) !== null && e !== void 0 ? e : {}, this._breakCondition = (i = t.breakCondition) !== null && i !== void 0 ? i : function() {
          return !1;
        }, this._timeToEnd = t.timeout, t.onEnded && this.onTimerEndedObservable.add(t.onEnded), t.onTick && this.onEachCountObservable.add(t.onTick), t.onAborted && this.onTimerAbortedObservable.add(t.onAborted);
      }
      return Object.defineProperty(n.prototype, "breakCondition", { set: function(t) {
        this._breakCondition = t;
      }, enumerable: !1, configurable: !0 }), n.prototype.clearObservables = function() {
        this.onEachCountObservable.clear(), this.onTimerAbortedObservable.clear(), this.onTimerEndedObservable.clear(), this.onStateChangedObservable.clear();
      }, n.prototype.start = function(t) {
        if (t === void 0 && (t = this._timeToEnd), this._state === Qa.STARTED)
          throw new Error("Timer already started. Please stop it before starting again");
        this._timeToEnd = t, this._startTime = Date.now(), this._timer = 0, this._observer = this._contextObservable.add(this._tick, this._observableParameters.mask, this._observableParameters.insertFirst, this._observableParameters.scope), this._setState(Qa.STARTED);
      }, n.prototype.stop = function() {
        this._state === Qa.STARTED && (this._breakOnNextTick = !0);
      }, n.prototype.dispose = function() {
        this._observer && this._contextObservable.remove(this._observer), this.clearObservables();
      }, n.prototype._setState = function(t) {
        this._state = t, this.onStateChangedObservable.notifyObservers(this._state);
      }, n.prototype._stop = function(t, e) {
        e === void 0 && (e = !1), this._contextObservable.remove(this._observer), this._setState(Qa.ENDED), e ? this.onTimerAbortedObservable.notifyObservers(t) : this.onTimerEndedObservable.notifyObservers(t);
      }, n;
    }(), $c = function(n) {
      function t(e, i) {
        var r = n.call(this, e) || this;
        return r._options = i, r._controllers = {}, r._snappedToPoint = !1, r._cachedColor4White = new Ie(1, 1, 1, 1), r._tmpRay = new gi(new v(), new v()), r._tmpVector = new v(), r._tmpQuaternion = new oe(), r.skipNextTeleportation = !1, r.backwardsMovementEnabled = !0, r.backwardsTeleportationDistance = 0.7, r.parabolicCheckRadius = 5, r.parabolicRayEnabled = !0, r.straightRayEnabled = !0, r.rotationAngle = Math.PI / 8, r.onTargetMeshPositionUpdatedObservable = new H(), r.teleportationEnabled = !0, r._rotationEnabled = !0, r._attachController = function(o) {
          if (!(r._controllers[o.uniqueId] || r._options.forceHandedness && o.inputSource.handedness !== r._options.forceHandedness)) {
            r._controllers[o.uniqueId] = { xrController: o, teleportationState: { forward: !1, backwards: !1, rotating: !1, currentRotation: 0, baseRotation: 0, blocked: !1 } };
            var a = r._controllers[o.uniqueId];
            if (a.xrController.inputSource.targetRayMode === "tracked-pointer" && a.xrController.inputSource.gamepad) {
              var s = function() {
                if (o.motionController) {
                  var l = o.motionController.getComponentOfType(wo.THUMBSTICK_TYPE) || o.motionController.getComponentOfType(wo.TOUCHPAD_TYPE);
                  if (!l || r._options.useMainComponentOnly) {
                    var c = o.motionController.getMainComponent();
                    if (!c)
                      return;
                    a.teleportationComponent = c, a.onButtonChangedObserver = c.onButtonStateChangedObservable.add(function() {
                      r.teleportationEnabled && c.changes.pressed && (c.changes.pressed.current ? (a.teleportationState.forward = !0, r._currentTeleportationControllerId = a.xrController.uniqueId, a.teleportationState.baseRotation = r._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y, a.teleportationState.currentRotation = 0, m_({ timeout: r._options.timeToTeleport || 3e3, contextObservable: r._xrSessionManager.onXRFrameObservable, breakCondition: function() {
                        return !c.pressed;
                      }, onEnded: function() {
                        r._currentTeleportationControllerId === a.xrController.uniqueId && a.teleportationState.forward && r._teleportForward(o.uniqueId);
                      } })) : (a.teleportationState.forward = !1, r._currentTeleportationControllerId = ""));
                    });
                  } else
                    a.teleportationComponent = l, a.onAxisChangedObserver = l.onAxisValueChangedObservable.add(function(u) {
                      if (u.y <= 0.7 && a.teleportationState.backwards && (a.teleportationState.backwards = !1), u.y > 0.7 && !a.teleportationState.forward && r.backwardsMovementEnabled && !r.snapPointsOnly && !a.teleportationState.backwards) {
                        a.teleportationState.backwards = !0, r._tmpQuaternion.copyFrom(r._options.xrInput.xrCamera.rotationQuaternion), r._tmpQuaternion.toEulerAnglesToRef(r._tmpVector), r._tmpVector.x = 0, r._tmpVector.z = 0, oe.FromEulerVectorToRef(r._tmpVector, r._tmpQuaternion), r._tmpVector.set(0, 0, r.backwardsTeleportationDistance * (r._xrSessionManager.scene.useRightHandedSystem ? 1 : -1)), r._tmpVector.rotateByQuaternionToRef(r._tmpQuaternion, r._tmpVector), r._tmpVector.addInPlace(r._options.xrInput.xrCamera.position), r._tmpRay.origin.copyFrom(r._tmpVector), r._tmpRay.length = r._options.xrInput.xrCamera.realWorldHeight + 0.1, r._tmpRay.direction.set(0, -1, 0);
                        var h = r._xrSessionManager.scene.pickWithRay(r._tmpRay, function(p) {
                          return r._floorMeshes.indexOf(p) !== -1;
                        });
                        h && h.pickedPoint && (r._options.xrInput.xrCamera.position.x = h.pickedPoint.x, r._options.xrInput.xrCamera.position.z = h.pickedPoint.z);
                      }
                      if (u.y < -0.7 && !r._currentTeleportationControllerId && !a.teleportationState.rotating && r.teleportationEnabled && (a.teleportationState.forward = !0, r._currentTeleportationControllerId = a.xrController.uniqueId, a.teleportationState.baseRotation = r._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y), u.x) {
                        if (a.teleportationState.forward)
                          r._currentTeleportationControllerId === a.xrController.uniqueId && (r.rotationEnabled ? setTimeout(function() {
                            a.teleportationState.currentRotation = Math.atan2(u.x, u.y * (r._xrSessionManager.scene.useRightHandedSystem ? 1 : -1));
                          }) : a.teleportationState.currentRotation = 0);
                        else if (!a.teleportationState.rotating && Math.abs(u.x) > 0.7) {
                          a.teleportationState.rotating = !0;
                          var d = r.rotationAngle * (u.x > 0 ? 1 : -1) * (r._xrSessionManager.scene.useRightHandedSystem ? -1 : 1);
                          oe.FromEulerAngles(0, d, 0).multiplyToRef(r._options.xrInput.xrCamera.rotationQuaternion, r._options.xrInput.xrCamera.rotationQuaternion);
                        }
                      } else
                        a.teleportationState.rotating = !1;
                      u.x === 0 && u.y === 0 && (a.teleportationState.blocked && (a.teleportationState.blocked = !1, r._setTargetMeshVisibility(!1)), a.teleportationState.forward && r._teleportForward(o.uniqueId));
                    });
                }
              };
              o.motionController ? s() : o.onMotionControllerInitObservable.addOnce(function() {
                s();
              });
            } else
              r._xrSessionManager.scene.onPointerObservable.add(function(l) {
                l.type === Le.POINTERDOWN ? (a.teleportationState.forward = !0, r._currentTeleportationControllerId = a.xrController.uniqueId, a.teleportationState.baseRotation = r._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y, a.teleportationState.currentRotation = 0, m_({ timeout: r._options.timeToTeleport || 3e3, contextObservable: r._xrSessionManager.onXRFrameObservable, onEnded: function() {
                  r._currentTeleportationControllerId === a.xrController.uniqueId && a.teleportationState.forward && r._teleportForward(o.uniqueId);
                } })) : l.type === Le.POINTERUP && (a.teleportationState.forward = !1, r._currentTeleportationControllerId = "");
              });
          }
        }, r._options.teleportationTargetMesh || r._createDefaultTargetMesh(), r._floorMeshes = r._options.floorMeshes || [], r._snapToPositions = r._options.snapPositions || [], r._blockedRayColor = r._options.blockedRayColor || new Ie(1, 0, 0, 0.75), r._setTargetMeshVisibility(!1), r;
      }
      return D(t, n), Object.defineProperty(t.prototype, "rotationEnabled", { get: function() {
        return this._rotationEnabled;
      }, set: function(e) {
        if (this._rotationEnabled = e, this._options.teleportationTargetMesh) {
          var i = this._options.teleportationTargetMesh.getChildMeshes(!1, function(r) {
            return r.name === "rotationCone";
          });
          i[0] && i[0].setEnabled(e);
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "teleportationTargetMesh", { get: function() {
        return this._options.teleportationTargetMesh || null;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "snapPointsOnly", { get: function() {
        return !!this._options.snapPointsOnly;
      }, set: function(e) {
        this._options.snapPointsOnly = e;
      }, enumerable: !1, configurable: !0 }), t.prototype.addFloorMesh = function(e) {
        this._floorMeshes.push(e);
      }, t.prototype.addBlockerMesh = function(e) {
        this._options.pickBlockerMeshes = this._options.pickBlockerMeshes || [], this._options.pickBlockerMeshes.push(e);
      }, t.prototype.addSnapPoint = function(e) {
        this._snapToPositions.push(e);
      }, t.prototype.attach = function() {
        var e = this;
        return !!n.prototype.attach.call(this) && (this._currentTeleportationControllerId = "", this._options.xrInput.controllers.forEach(this._attachController), this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable, this._attachController), this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable, function(i) {
          e._detachController(i.uniqueId);
        }), !0);
      }, t.prototype.detach = function() {
        var e = this;
        return !!n.prototype.detach.call(this) && (Object.keys(this._controllers).forEach(function(i) {
          e._detachController(i);
        }), this._setTargetMeshVisibility(!1), this._currentTeleportationControllerId = "", this._controllers = {}, !0);
      }, t.prototype.dispose = function() {
        n.prototype.dispose.call(this), this._options.teleportationTargetMesh && this._options.teleportationTargetMesh.dispose(!1, !0);
      }, t.prototype.removeFloorMesh = function(e) {
        var i = this._floorMeshes.indexOf(e);
        i !== -1 && this._floorMeshes.splice(i, 1);
      }, t.prototype.removeBlockerMesh = function(e) {
        this._options.pickBlockerMeshes = this._options.pickBlockerMeshes || [];
        var i = this._options.pickBlockerMeshes.indexOf(e);
        i !== -1 && this._options.pickBlockerMeshes.splice(i, 1);
      }, t.prototype.removeFloorMeshByName = function(e) {
        var i = this._xrSessionManager.scene.getMeshByName(e);
        i && this.removeFloorMesh(i);
      }, t.prototype.removeSnapPoint = function(e) {
        var i = this._snapToPositions.indexOf(e);
        if (i === -1) {
          for (var r = 0; r < this._snapToPositions.length; ++r)
            if (this._snapToPositions[r].equals(e)) {
              i = r;
              break;
            }
        }
        return i !== -1 && (this._snapToPositions.splice(i, 1), !0);
      }, t.prototype.setSelectionFeature = function(e) {
        this._selectionFeature = e;
      }, t.prototype._onXRFrame = function(e) {
        var i = this, r = this._xrSessionManager.currentFrame, o = this._xrSessionManager.scene;
        if (this.attach && r) {
          var a = this._options.teleportationTargetMesh;
          if (this._currentTeleportationControllerId) {
            if (!a)
              return;
            a.rotationQuaternion = a.rotationQuaternion || new oe();
            var s = this._controllers[this._currentTeleportationControllerId];
            if (s && s.teleportationState.forward) {
              oe.RotationYawPitchRollToRef(s.teleportationState.currentRotation + s.teleportationState.baseRotation, 0, 0, a.rotationQuaternion);
              var l = !1;
              if (s.xrController.getWorldPointerRayToRef(this._tmpRay), this.straightRayEnabled) {
                if ((c = o.pickWithRay(this._tmpRay, function(p) {
                  if (i._options.pickBlockerMeshes && i._options.pickBlockerMeshes.indexOf(p) !== -1)
                    return !0;
                  var f = i._floorMeshes.indexOf(p);
                  return f !== -1 && i._floorMeshes[f].absolutePosition.y < i._options.xrInput.xrCamera.globalPosition.y;
                })) && c.pickedMesh && this._options.pickBlockerMeshes && this._options.pickBlockerMeshes.indexOf(c.pickedMesh) !== -1)
                  return s.teleportationState.blocked = !0, this._setTargetMeshVisibility(!1), void this._showParabolicPath(c);
                c && c.pickedPoint && (s.teleportationState.blocked = !1, l = !0, this._setTargetMeshPosition(c), this._setTargetMeshVisibility(!0), this._showParabolicPath(c));
              }
              if (this.parabolicRayEnabled && !l) {
                var c, u = s.xrController.pointer.rotationQuaternion.toEulerAngles().x, h = Math.PI / 2 - Math.abs(u) + 1, d = this.parabolicCheckRadius * h;
                if (this._tmpRay.origin.addToRef(this._tmpRay.direction.scale(2 * d), this._tmpVector), this._tmpVector.y = this._tmpRay.origin.y, this._tmpRay.origin.addInPlace(this._tmpRay.direction.scale(d)), this._tmpVector.subtractToRef(this._tmpRay.origin, this._tmpRay.direction), this._tmpRay.direction.normalize(), (c = o.pickWithRay(this._tmpRay, function(p) {
                  return !(!i._options.pickBlockerMeshes || i._options.pickBlockerMeshes.indexOf(p) === -1) || i._floorMeshes.indexOf(p) !== -1;
                })) && c.pickedMesh && this._options.pickBlockerMeshes && this._options.pickBlockerMeshes.indexOf(c.pickedMesh) !== -1)
                  return s.teleportationState.blocked = !0, this._setTargetMeshVisibility(!1), void this._showParabolicPath(c);
                c && c.pickedPoint && (s.teleportationState.blocked = !1, l = !0, this._setTargetMeshPosition(c), this._setTargetMeshVisibility(!0), this._showParabolicPath(c));
              }
              this._setTargetMeshVisibility(l);
            } else
              this._setTargetMeshVisibility(!1);
          } else
            this._disposeBezierCurve(), this._setTargetMeshVisibility(!1);
        }
      }, t.prototype._createDefaultTargetMesh = function() {
        this._options.defaultTargetMeshOptions = this._options.defaultTargetMeshOptions || {};
        var e = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || Fi.DefaultUtilityLayer.utilityLayerScene : this._xrSessionManager.scene, i = vl("teleportationTarget", { width: 2, height: 2, subdivisions: 2 }, e);
        if (i.isPickable = !1, this._options.defaultTargetMeshOptions.teleportationCircleMaterial)
          i.material = this._options.defaultTargetMeshOptions.teleportationCircleMaterial;
        else {
          var r = new Es("teleportationPlaneDynamicTexture", 512, e, !0);
          r.hasAlpha = !0;
          var o = r.getContext();
          o.beginPath(), o.arc(256, 256, 200, 0, 2 * Math.PI, !1), o.fillStyle = this._options.defaultTargetMeshOptions.teleportationFillColor || "#444444", o.fill(), o.lineWidth = 10, o.strokeStyle = this._options.defaultTargetMeshOptions.teleportationBorderColor || "#FFFFFF", o.stroke(), o.closePath(), r.update();
          var a = new Gt("teleportationPlaneMaterial", e);
          a.diffuseTexture = r, i.material = a;
        }
        var s = eo("torusTeleportation", { diameter: 0.75, thickness: 0.1, tessellation: 20 }, e);
        if (s.isPickable = !1, s.parent = i, !this._options.defaultTargetMeshOptions.disableAnimation) {
          var l = new Je("animationInnerCircle", "position.y", 30, Je.ANIMATIONTYPE_FLOAT, Je.ANIMATIONLOOPMODE_CYCLE), c = [];
          c.push({ frame: 0, value: 0 }), c.push({ frame: 30, value: 0.4 }), c.push({ frame: 60, value: 0 }), l.setKeys(c);
          var u = new Sp();
          u.setEasingMode(xn.EASINGMODE_EASEINOUT), l.setEasingFunction(u), s.animations = [], s.animations.push(l), e.beginAnimation(s, 0, 60, !0);
        }
        var h = Fn("rotationCone", { diameterTop: 0, tessellation: 4 }, e);
        if (h.isPickable = !1, h.scaling.set(0.5, 0.12, 0.2), h.rotate(qi.X, Math.PI / 2), h.position.z = 0.6, h.parent = s, this._options.defaultTargetMeshOptions.torusArrowMaterial)
          s.material = this._options.defaultTargetMeshOptions.torusArrowMaterial, h.material = this._options.defaultTargetMeshOptions.torusArrowMaterial;
        else {
          var d = new Gt("torusConsMat", e);
          d.disableLighting = !!this._options.defaultTargetMeshOptions.disableLighting, d.disableLighting ? d.emissiveColor = new ne(0.3, 0.3, 1) : d.diffuseColor = new ne(0.3, 0.3, 1), d.alpha = 0.9, s.material = d, h.material = d, this._teleportationRingMaterial = d;
        }
        this._options.renderingGroupId !== void 0 && (i.renderingGroupId = this._options.renderingGroupId, s.renderingGroupId = this._options.renderingGroupId, h.renderingGroupId = this._options.renderingGroupId), this._options.teleportationTargetMesh = i, this._setTargetMeshVisibility(!1);
      }, t.prototype._detachController = function(e) {
        var i = this._controllers[e];
        i && (i.teleportationComponent && (i.onAxisChangedObserver && i.teleportationComponent.onAxisValueChangedObservable.remove(i.onAxisChangedObserver), i.onButtonChangedObserver && i.teleportationComponent.onButtonStateChangedObservable.remove(i.onButtonChangedObserver)), delete this._controllers[e]);
      }, t.prototype._findClosestSnapPointWithRadius = function(e, i) {
        i === void 0 && (i = this._options.snapToPositionRadius || 0.8);
        var r = null, o = Number.MAX_VALUE;
        if (this._snapToPositions.length) {
          var a = i * i;
          this._snapToPositions.forEach(function(s) {
            var l = v.DistanceSquared(s, e);
            l <= a && l < o && (o = l, r = s);
          });
        }
        return r;
      }, t.prototype._setTargetMeshPosition = function(e) {
        var i = e.pickedPoint;
        if (this._options.teleportationTargetMesh && i) {
          var r = this._findClosestSnapPointWithRadius(i);
          this._snappedToPoint = !!r, this.snapPointsOnly && !this._snappedToPoint && this._teleportationRingMaterial ? this._teleportationRingMaterial.diffuseColor.set(1, 0.3, 0.3) : this.snapPointsOnly && this._snappedToPoint && this._teleportationRingMaterial && this._teleportationRingMaterial.diffuseColor.set(0.3, 0.3, 1), this._options.teleportationTargetMesh.position.copyFrom(r || i), this._options.teleportationTargetMesh.position.y += 0.01, this.onTargetMeshPositionUpdatedObservable.notifyObservers(e);
        }
      }, t.prototype._setTargetMeshVisibility = function(e, i) {
        this._options.teleportationTargetMesh && (this._options.teleportationTargetMesh.isVisible !== e || i) && (this._options.teleportationTargetMesh.isVisible = e, this._options.teleportationTargetMesh.getChildren(void 0, !1).forEach(function(r) {
          r.isVisible = e;
        }), e ? this._selectionFeature && this._selectionFeature.detach() : (this._quadraticBezierCurve && (this._quadraticBezierCurve.dispose(), this._quadraticBezierCurve = null), this._selectionFeature && this._selectionFeature.attach()));
      }, t.prototype._disposeBezierCurve = function() {
        this._quadraticBezierCurve && (this._quadraticBezierCurve.dispose(), this._quadraticBezierCurve = null);
      }, t.prototype._showParabolicPath = function(e) {
        if (e.pickedPoint && this._currentTeleportationControllerId) {
          var i = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || Fi.DefaultUtilityLayer.utilityLayerScene : this._xrSessionManager.scene, r = this._controllers[this._currentTeleportationControllerId], o = Ep.CreateQuadraticBezier(r.xrController.pointer.absolutePosition, e.ray.origin, e.pickedPoint, 25), a = r.teleportationState.blocked ? this._blockedRayColor : void 0, s = new Array(26).fill(a || this._cachedColor4White);
          this._options.generateRayPathMesh ? this._quadraticBezierCurve = this._options.generateRayPathMesh(o.getPoints(), e) : this._quadraticBezierCurve = si("teleportation path line", { points: o.getPoints(), instance: this._quadraticBezierCurve, updatable: !0, colors: s }, i), this._quadraticBezierCurve.isPickable = !1, this._options.renderingGroupId !== void 0 && (this._quadraticBezierCurve.renderingGroupId = this._options.renderingGroupId);
        }
      }, t.prototype._teleportForward = function(e) {
        var i = this._controllers[e];
        if (i && i.teleportationState.forward && this.teleportationEnabled && (i.teleportationState.forward = !1, this._currentTeleportationControllerId = "", !this.snapPointsOnly || this._snappedToPoint)) {
          if (this.skipNextTeleportation)
            this.skipNextTeleportation = !1;
          else if (this._options.teleportationTargetMesh && this._options.teleportationTargetMesh.isVisible) {
            var r = this._options.xrInput.xrCamera.realWorldHeight;
            this._options.xrInput.xrCamera.onBeforeCameraTeleport.notifyObservers(this._options.xrInput.xrCamera.position), this._options.xrInput.xrCamera.position.copyFrom(this._options.teleportationTargetMesh.position), this._options.xrInput.xrCamera.position.y += r, oe.FromEulerAngles(0, i.teleportationState.currentRotation - (this._xrSessionManager.scene.useRightHandedSystem ? Math.PI : 0), 0).multiplyToRef(this._options.xrInput.xrCamera.rotationQuaternion, this._options.xrInput.xrCamera.rotationQuaternion), this._options.xrInput.xrCamera.onAfterCameraTeleport.notifyObservers(this._options.xrInput.xrCamera.position);
          }
        }
      }, t.Name = vi.TELEPORTATION, t.Version = 1, t;
    }(Qi);
    Wi.AddWebXRFeature($c.Name, function(n, t) {
      return function() {
        return new $c(n, t);
      };
    }, $c.Version, !0);
    var XC = function() {
    }, wy = function() {
      function n() {
      }
      return n.CreateAsync = function(t, e) {
        e === void 0 && (e = {});
        var i = new n();
        if (t.onDisposeObservable.addOnce(function() {
          i.dispose();
        }), !e.disableDefaultUI) {
          var r = je({ renderTarget: i.renderTarget }, e.uiOptions || {});
          e.optionalFeatures && (typeof e.optionalFeatures == "boolean" ? r.optionalFeatures = ["hit-test", "anchors", "plane-detection", "hand-tracking"] : r.optionalFeatures = e.optionalFeatures), i.enterExitUI = new Fy(t, r);
        }
        return Py.CreateAsync(t).then(function(o) {
          if (i.baseExperience = o, e.ignoreNativeCameraTransformation && (i.baseExperience.camera.compensateOnFirstFrame = !1), i.input = new Dy(o.sessionManager, o.camera, je({ controllerOptions: { renderingGroupId: e.renderingGroupId } }, e.inputOptions || {})), !e.disablePointerSelection) {
            var a = je(je({}, e.pointerSelectionOptions), { xrInput: i.input, renderingGroupId: e.renderingGroupId });
            i.pointerSelection = i.baseExperience.featuresManager.enableFeature(Zc.Name, e.useStablePlugins ? "stable" : "latest", a), e.disableTeleportation || (i.teleportation = i.baseExperience.featuresManager.enableFeature($c.Name, e.useStablePlugins ? "stable" : "latest", je({ floorMeshes: e.floorMeshes, xrInput: i.input, renderingGroupId: e.renderingGroupId }, e.teleportationOptions)), i.teleportation.setSelectionFeature(i.pointerSelection));
          }
          return e.disableNearInteraction || (i.nearInteraction = i.baseExperience.featuresManager.enableFeature(Jc.Name, e.useStablePlugins ? "stable" : "latest", je({ xrInput: i.input, farInteractionFeature: i.pointerSelection, renderingGroupId: e.renderingGroupId, useUtilityLayer: !0, enableNearInteractionOnAllControllers: !0 }, e.nearInteractionOptions))), i.renderTarget = i.baseExperience.sessionManager.getWebXRRenderTarget(e.outputCanvasOptions), e.disableDefaultUI ? void 0 : i.enterExitUI.setHelperAsync(i.baseExperience, i.renderTarget);
        }).then(function() {
          return i;
        }).catch(function(o) {
          return q.Error("Error initializing XR"), q.Error(o), i;
        });
      }, n.prototype.dispose = function() {
        this.baseExperience && this.baseExperience.dispose(), this.input && this.input.dispose(), this.enterExitUI && this.enterExitUI.dispose(), this.renderTarget && this.renderTarget.dispose();
      }, n;
    }(), jC = !0;
    function YC(n) {
      for (; n.firstChild; )
        n.removeChild(n.firstChild);
      n.srcObject = null, n.src = "", n.removeAttribute("src");
    }
    Ue.prototype.createDefaultLight = function(n) {
      if (n === void 0 && (n = !1), n && this.lights)
        for (var t = 0; t < this.lights.length; t++)
          this.lights[t].dispose();
      this.lights.length === 0 && new Pc("default light", v.Up(), this);
    }, Ue.prototype.createDefaultCamera = function(n, t, e) {
      if (n === void 0 && (n = !1), t === void 0 && (t = !1), e === void 0 && (e = !1), t && this.activeCamera && (this.activeCamera.dispose(), this.activeCamera = null), !this.activeCamera) {
        var i = this.getWorldExtends(function(u) {
          return u.isVisible && u.isEnabled();
        }), r = i.max.subtract(i.min), o = i.min.add(r.scale(0.5)), a = void 0, s = 1.5 * r.length();
        if (isFinite(s) || (s = 1, o.copyFromFloats(0, 0, 0)), n) {
          var l = new gs("default camera", -Math.PI / 2, Math.PI / 2, s, o, this);
          l.lowerRadiusLimit = 0.01 * s, l.wheelPrecision = 100 / s, a = l;
        } else {
          var c = new Oo("default camera", new v(o.x, o.y, -s), this);
          c.setTarget(o), a = c;
        }
        a.minZ = 0.01 * s, a.maxZ = 1e3 * s, a.speed = 0.2 * s, this.activeCamera = a, e && a.attachControl();
      }
    }, Ue.prototype.createDefaultCameraOrLight = function(n, t, e) {
      n === void 0 && (n = !1), t === void 0 && (t = !1), e === void 0 && (e = !1), this.createDefaultLight(t), this.createDefaultCamera(n, t, e);
    }, Ue.prototype.createDefaultSkybox = function(n, t, e, i, r) {
      if (t === void 0 && (t = !1), e === void 0 && (e = 1e3), i === void 0 && (i = 0), r === void 0 && (r = !0), !n)
        return q.Warn("Can not create default skybox without environment texture."), null;
      r && n && (this.environmentTexture = n);
      var o = Ur("hdrSkyBox", { size: e }, this);
      if (t) {
        var a = new Yh("skyBox", this);
        a.backFaceCulling = !1, a.reflectionTexture = n.clone(), a.reflectionTexture && (a.reflectionTexture.coordinatesMode = ae.SKYBOX_MODE), a.microSurface = 1 - i, a.disableLighting = !0, a.twoSidedLighting = !0, o.material = a;
      } else {
        var s = new Gt("skyBox", this);
        s.backFaceCulling = !1, s.reflectionTexture = n.clone(), s.reflectionTexture && (s.reflectionTexture.coordinatesMode = ae.SKYBOX_MODE), s.disableLighting = !0, o.material = s;
      }
      return o.isPickable = !1, o.infiniteDistance = !0, o.ignoreCameraMaxZ = !0, o;
    }, Ue.prototype.createDefaultEnvironment = function(n) {
      return a_ ? new a_(n, this) : null;
    }, Ue.prototype.createDefaultVRExperience = function(n) {
      return n === void 0 && (n = {}), new Av(this, n);
    }, Ue.prototype.createDefaultXRExperienceAsync = function(n) {
      return n === void 0 && (n = {}), wy.CreateAsync(this, n).then(function(t) {
        return t;
      });
    };
    var Qh = function(n) {
      function t(e, i, r, o, a, s, l, c, u) {
        o === void 0 && (o = !1), a === void 0 && (a = !1), s === void 0 && (s = ae.TRILINEAR_SAMPLINGMODE), l === void 0 && (l = {}), u === void 0 && (u = _.TEXTUREFORMAT_RGBA);
        var h, d, p = this;
        (p = n.call(this, null, r, !o, a) || this)._onUserActionRequestedObservable = null, p._stillImageCaptured = !1, p._displayingPosterTexture = !1, p._frameId = -1, p._currentSrc = null, p._errorFound = !1, p.isVideo = !0, p._resizeInternalTexture = function() {
          var m;
          p._texture != null && p._texture.dispose(), !p._getEngine().needPOTTextures || de.IsExponentOfTwo(p.video.videoWidth) && de.IsExponentOfTwo(p.video.videoHeight) ? (p.wrapU = ae.WRAP_ADDRESSMODE, p.wrapV = ae.WRAP_ADDRESSMODE) : (p.wrapU = ae.CLAMP_ADDRESSMODE, p.wrapV = ae.CLAMP_ADDRESSMODE, p._generateMipMaps = !1), p._texture = p._getEngine().createDynamicTexture(p.video.videoWidth, p.video.videoHeight, p._generateMipMaps, p.samplingMode), p._texture.format = (m = p._format) !== null && m !== void 0 ? m : _.TEXTUREFORMAT_RGBA, p._frameId = -1, p._updateInternalTexture();
        }, p._createInternalTexture = function() {
          if (p._texture != null) {
            if (!p._displayingPosterTexture)
              return;
            p._displayingPosterTexture = !1;
          }
          if (p.video.addEventListener("resize", p._resizeInternalTexture), p._resizeInternalTexture(), p.video.autoplay || p._settings.poster || p._settings.independentVideoSource)
            p._updateInternalTexture(), p.onLoadObservable.hasObservers() && p.onLoadObservable.notifyObservers(p);
          else {
            var m = p.video.onplaying, g = p.video.muted;
            p.video.muted = !0, p.video.onplaying = function() {
              p.video.muted = g, p.video.onplaying = m, p._updateInternalTexture(), p._errorFound || p.video.pause(), p.onLoadObservable.hasObservers() && p.onLoadObservable.notifyObservers(p);
            }, p._handlePlay();
          }
        }, p._reset = function() {
          p._texture != null && (p._displayingPosterTexture || (p._texture.dispose(), p._texture = null));
        }, p._updateInternalTexture = function() {
          if (p._texture != null && !(p.video.readyState < p.video.HAVE_CURRENT_DATA || p._displayingPosterTexture)) {
            var m = p.getScene().getFrameId();
            p._frameId !== m && (p._frameId = m, p._getEngine().updateVideoTexture(p._texture, p._externalTexture ? p._externalTexture : p.video, p._invertY));
          }
        }, p._settings = je({ autoPlay: !0, loop: !0, autoUpdateTexture: !0 }, l), p._onError = c, p._generateMipMaps = o, p._initialSamplingMode = s, p.autoUpdateTexture = p._settings.autoUpdateTexture, p._currentSrc = i, p.name = e || p._getName(i), p.video = p._getVideo(i), p._externalTexture = (d = (h = p._engine) === null || h === void 0 ? void 0 : h.createExternalTexture(p.video)) !== null && d !== void 0 ? d : null, p._settings.independentVideoSource || (p._settings.poster && (p.video.poster = p._settings.poster), p._settings.autoPlay !== void 0 && (p.video.autoplay = p._settings.autoPlay), p._settings.loop !== void 0 && (p.video.loop = p._settings.loop), p._settings.muted !== void 0 && (p.video.muted = p._settings.muted), p.video.setAttribute("playsinline", ""), p.video.addEventListener("paused", p._updateInternalTexture), p.video.addEventListener("seeked", p._updateInternalTexture), p.video.addEventListener("emptied", p._reset), p._settings.autoPlay && p._handlePlay()), p._createInternalTextureOnEvent = p._settings.poster && !p._settings.autoPlay ? "play" : "canplay", p.video.addEventListener(p._createInternalTextureOnEvent, p._createInternalTexture), p._format = u;
        var f = p.video.readyState >= p.video.HAVE_CURRENT_DATA;
        return !p._settings.poster || p._settings.autoPlay && f ? f && p._createInternalTexture() : (p._texture = p._getEngine().createTexture(p._settings.poster, !1, !p.invertY, r), p._displayingPosterTexture = !0), p;
      }
      return D(t, n), Object.defineProperty(t.prototype, "onUserActionRequestedObservable", { get: function() {
        return this._onUserActionRequestedObservable || (this._onUserActionRequestedObservable = new H()), this._onUserActionRequestedObservable;
      }, enumerable: !1, configurable: !0 }), t.prototype._processError = function(e) {
        this._errorFound = !0, this._onError ? this._onError(e == null ? void 0 : e.message) : q.Error(e == null ? void 0 : e.message);
      }, t.prototype._handlePlay = function() {
        var e = this;
        this._errorFound = !1, this.video.play().catch(function(i) {
          if ((i == null ? void 0 : i.name) === "NotAllowedError") {
            if (e._onUserActionRequestedObservable && e._onUserActionRequestedObservable.hasObservers())
              return void e._onUserActionRequestedObservable.notifyObservers(e);
            if (!e.video.muted)
              return q.Warn("Unable to autoplay a video with sound. Trying again with muted turned true"), e.video.muted = !0, e._errorFound = !1, void e.video.play().catch(function(r) {
                e._processError(r);
              });
          }
          e._processError(i);
        });
      }, t.prototype.getClassName = function() {
        return "VideoTexture";
      }, t.prototype._getName = function(e) {
        return e instanceof HTMLVideoElement ? e.currentSrc : typeof e == "object" ? e.toString() : e;
      }, t.prototype._getVideo = function(e) {
        if (e.isNative)
          return e;
        if (e instanceof HTMLVideoElement)
          return de.SetCorsBehavior(e.currentSrc, e), e;
        var i = document.createElement("video");
        return typeof e == "string" ? (de.SetCorsBehavior(e, i), i.src = e) : (de.SetCorsBehavior(e[0], i), e.forEach(function(r) {
          var o = document.createElement("source");
          o.src = r, i.appendChild(o);
        })), this.onDisposeObservable.addOnce(function() {
          YC(i);
        }), i;
      }, t.prototype._rebuild = function() {
        this.update();
      }, t.prototype.update = function() {
        this.autoUpdateTexture && this.updateTexture(!0);
      }, t.prototype.updateTexture = function(e) {
        e && (this.video.paused && this._stillImageCaptured || (this._stillImageCaptured = !0, this._updateInternalTexture()));
      }, Object.defineProperty(t.prototype, "externalTexture", { get: function() {
        return this._externalTexture;
      }, enumerable: !1, configurable: !0 }), t.prototype.updateURL = function(e) {
        this.video.src = e, this._currentSrc = e;
      }, t.prototype.clone = function() {
        return new t(this.name, this._currentSrc, this.getScene(), this._generateMipMaps, this.invertY, this.samplingMode, this._settings);
      }, t.prototype.dispose = function() {
        var e;
        n.prototype.dispose.call(this), this._currentSrc = null, this._onUserActionRequestedObservable && (this._onUserActionRequestedObservable.clear(), this._onUserActionRequestedObservable = null), this.video.removeEventListener(this._createInternalTextureOnEvent, this._createInternalTexture), this._settings.independentVideoSource || (this.video.removeEventListener("paused", this._updateInternalTexture), this.video.removeEventListener("seeked", this._updateInternalTexture), this.video.removeEventListener("emptied", this._reset), this.video.removeEventListener("resize", this._resizeInternalTexture), this.video.pause()), (e = this._externalTexture) === null || e === void 0 || e.dispose();
      }, t.CreateFromStreamAsync = function(e, i, r, o) {
        o === void 0 && (o = !0);
        var a = e.getEngine().createVideoElement(r);
        return e.getEngine()._badOS && (document.body.appendChild(a), a.style.transform = "scale(0.0001, 0.0001)", a.style.opacity = "0", a.style.position = "fixed", a.style.bottom = "0px", a.style.right = "0px"), a.setAttribute("autoplay", ""), a.setAttribute("muted", "true"), a.setAttribute("playsinline", ""), a.muted = !0, a.isNative || (a.mozSrcObject !== void 0 ? a.mozSrcObject = i : typeof a.srcObject == "object" ? a.srcObject = i : a.src = window.URL && window.URL.createObjectURL(i)), new Promise(function(s) {
          var l = function() {
            var c = new t("video", a, e, !0, o, void 0, void 0, void 0, _.TEXTUREFORMAT_RGB);
            e.getEngine()._badOS && c.onDisposeObservable.addOnce(function() {
              a.remove();
            }), c.onDisposeObservable.addOnce(function() {
              YC(a);
            }), s(c), a.removeEventListener("playing", l);
          };
          a.addEventListener("playing", l), a.play();
        });
      }, t.CreateFromWebCamAsync = function(e, i, r, o) {
        return r === void 0 && (r = !1), o === void 0 && (o = !0), Ft(this, void 0, void 0, function() {
          var a, s;
          return Bt(this, function(l) {
            switch (l.label) {
              case 0:
                return navigator.mediaDevices ? [4, navigator.mediaDevices.getUserMedia({ video: i, audio: r })] : [3, 3];
              case 1:
                return a = l.sent(), [4, this.CreateFromStreamAsync(e, a, i, o)];
              case 2:
                return (s = l.sent()).onDisposeObservable.addOnce(function() {
                  a.getTracks().forEach(function(c) {
                    c.stop();
                  });
                }), [2, s];
              case 3:
                return [2, Promise.reject("No support for userMedia on this device")];
            }
          });
        });
      }, t.CreateFromWebCam = function(e, i, r, o, a) {
        o === void 0 && (o = !1), a === void 0 && (a = !0), this.CreateFromWebCamAsync(e, r, o, a).then(function(s) {
          i && i(s);
        }).catch(function(s) {
          q.Error(s.name);
        });
      }, x([N("settings")], t.prototype, "_settings", void 0), x([N("src")], t.prototype, "_currentSrc", void 0), x([N()], t.prototype, "isVideo", void 0), t;
    }(ae);
    ae._CreateVideoTexture = function(n, t, e, i, r, o, a, s, l) {
      return i === void 0 && (i = !1), r === void 0 && (r = !1), o === void 0 && (o = ae.TRILINEAR_SAMPLINGMODE), a === void 0 && (a = {}), l === void 0 && (l = _.TEXTUREFORMAT_RGBA), new Qh(n, t, e, i, r, o, a, s, l);
    }, j("BABYLON.VideoTexture", Qh);
    var KC = function(n) {
      function t() {
        return n !== null && n.apply(this, arguments) || this;
      }
      return D(t, n), Object.defineProperty(t.prototype, "videoTexture", { get: function() {
        return this._texture;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "videoMode", { get: function() {
        return this.textureMode;
      }, set: function(e) {
        this.textureMode = e;
      }, enumerable: !1, configurable: !0 }), t.prototype._initTexture = function(e, i, r) {
        var o = this, a = { loop: r.loop, autoPlay: r.autoPlay, autoUpdateTexture: !0, poster: r.poster }, s = new Qh((this.name || "videoDome") + "_texture", e, i, r.generateMipMaps, this._useDirectMapping, ae.TRILINEAR_SAMPLINGMODE, a);
        return r.clickToPlay && (this._pointerObserver = i.onPointerObservable.add(function(l) {
          var c;
          ((c = l.pickInfo) === null || c === void 0 ? void 0 : c.pickedMesh) === o.mesh && o._texture.video.play();
        }, Le.POINTERDOWN)), this._textureObserver = s.onLoadObservable.add(function() {
          o.onLoadObservable.notifyObservers();
        }), s;
      }, t.prototype.dispose = function(e, i) {
        i === void 0 && (i = !1), this._texture.onLoadObservable.remove(this._textureObserver), this._scene.onPointerObservable.remove(this._pointerObserver), n.prototype.dispose.call(this, e, i);
      }, t.MODE_MONOSCOPIC = Rs.MODE_MONOSCOPIC, t.MODE_TOPBOTTOM = Rs.MODE_TOPBOTTOM, t.MODE_SIDEBYSIDE = Rs.MODE_SIDEBYSIDE, t;
    }(Rs), By = function() {
      function n(t) {
        this.engine = t, this._captureGPUFrameTime = !1, this._captureShaderCompilationTime = !1, this._shaderCompilationTime = new Sn(), this._onBeginFrameObserver = null, this._onEndFrameObserver = null, this._onBeforeShaderCompilationObserver = null, this._onAfterShaderCompilationObserver = null;
      }
      return Object.defineProperty(n.prototype, "gpuFrameTimeCounter", { get: function() {
        return this.engine.getGPUFrameTimeCounter();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "captureGPUFrameTime", { get: function() {
        return this._captureGPUFrameTime;
      }, set: function(t) {
        t !== this._captureGPUFrameTime && (this._captureGPUFrameTime = t, this.engine.captureGPUFrameTime(t));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "shaderCompilationTimeCounter", { get: function() {
        return this._shaderCompilationTime;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "captureShaderCompilationTime", { get: function() {
        return this._captureShaderCompilationTime;
      }, set: function(t) {
        var e = this;
        t !== this._captureShaderCompilationTime && (this._captureShaderCompilationTime = t, t ? (this._onBeforeShaderCompilationObserver = this.engine.onBeforeShaderCompilationObservable.add(function() {
          e._shaderCompilationTime.fetchNewFrame(), e._shaderCompilationTime.beginMonitoring();
        }), this._onAfterShaderCompilationObserver = this.engine.onAfterShaderCompilationObservable.add(function() {
          e._shaderCompilationTime.endMonitoring();
        })) : (this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver), this._onBeforeShaderCompilationObserver = null, this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver), this._onAfterShaderCompilationObserver = null));
      }, enumerable: !1, configurable: !0 }), n.prototype.dispose = function() {
        this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver), this._onBeginFrameObserver = null, this.engine.onEndFrameObservable.remove(this._onEndFrameObserver), this._onEndFrameObserver = null, this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver), this._onBeforeShaderCompilationObserver = null, this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver), this._onAfterShaderCompilationObserver = null, this.engine = null;
      }, n;
    }(), Uy = function() {
      function n(t) {
        var e = this;
        this.scene = t, this._captureActiveMeshesEvaluationTime = !1, this._activeMeshesEvaluationTime = new Sn(), this._captureRenderTargetsRenderTime = !1, this._renderTargetsRenderTime = new Sn(), this._captureFrameTime = !1, this._frameTime = new Sn(), this._captureRenderTime = !1, this._renderTime = new Sn(), this._captureInterFrameTime = !1, this._interFrameTime = new Sn(), this._captureParticlesRenderTime = !1, this._particlesRenderTime = new Sn(), this._captureSpritesRenderTime = !1, this._spritesRenderTime = new Sn(), this._capturePhysicsTime = !1, this._physicsTime = new Sn(), this._captureAnimationsTime = !1, this._animationsTime = new Sn(), this._captureCameraRenderTime = !1, this._cameraRenderTime = new Sn(), this._onBeforeActiveMeshesEvaluationObserver = null, this._onAfterActiveMeshesEvaluationObserver = null, this._onBeforeRenderTargetsRenderObserver = null, this._onAfterRenderTargetsRenderObserver = null, this._onAfterRenderObserver = null, this._onBeforeDrawPhaseObserver = null, this._onAfterDrawPhaseObserver = null, this._onBeforeAnimationsObserver = null, this._onBeforeParticlesRenderingObserver = null, this._onAfterParticlesRenderingObserver = null, this._onBeforeSpritesRenderingObserver = null, this._onAfterSpritesRenderingObserver = null, this._onBeforePhysicsObserver = null, this._onAfterPhysicsObserver = null, this._onAfterAnimationsObserver = null, this._onBeforeCameraRenderObserver = null, this._onAfterCameraRenderObserver = null, this._onBeforeAnimationsObserver = t.onBeforeAnimationsObservable.add(function() {
          e._captureActiveMeshesEvaluationTime && e._activeMeshesEvaluationTime.fetchNewFrame(), e._captureRenderTargetsRenderTime && e._renderTargetsRenderTime.fetchNewFrame(), e._captureFrameTime && (de.StartPerformanceCounter("Scene rendering"), e._frameTime.beginMonitoring()), e._captureInterFrameTime && e._interFrameTime.endMonitoring(), e._captureParticlesRenderTime && e._particlesRenderTime.fetchNewFrame(), e._captureSpritesRenderTime && e._spritesRenderTime.fetchNewFrame(), e._captureAnimationsTime && e._animationsTime.beginMonitoring(), e._captureRenderTime && e._renderTime.fetchNewFrame(), e._captureCameraRenderTime && e._cameraRenderTime.fetchNewFrame(), e.scene.getEngine()._drawCalls.fetchNewFrame();
        }), this._onAfterRenderObserver = t.onAfterRenderObservable.add(function() {
          e._captureFrameTime && (de.EndPerformanceCounter("Scene rendering"), e._frameTime.endMonitoring()), e._captureRenderTime && e._renderTime.endMonitoring(!1), e._captureInterFrameTime && e._interFrameTime.beginMonitoring(), e._captureActiveMeshesEvaluationTime && e._activeMeshesEvaluationTime.endFrame(), e._captureRenderTargetsRenderTime && e._renderTargetsRenderTime.endFrame(), e._captureParticlesRenderTime && e._particlesRenderTime.endFrame(), e._captureSpritesRenderTime && e._spritesRenderTime.endFrame(), e._captureRenderTime && e._renderTime.endFrame(), e._captureCameraRenderTime && e._cameraRenderTime.endFrame();
        });
      }
      return Object.defineProperty(n.prototype, "activeMeshesEvaluationTimeCounter", { get: function() {
        return this._activeMeshesEvaluationTime;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "captureActiveMeshesEvaluationTime", { get: function() {
        return this._captureActiveMeshesEvaluationTime;
      }, set: function(t) {
        var e = this;
        t !== this._captureActiveMeshesEvaluationTime && (this._captureActiveMeshesEvaluationTime = t, t ? (this._onBeforeActiveMeshesEvaluationObserver = this.scene.onBeforeActiveMeshesEvaluationObservable.add(function() {
          de.StartPerformanceCounter("Active meshes evaluation"), e._activeMeshesEvaluationTime.beginMonitoring();
        }), this._onAfterActiveMeshesEvaluationObserver = this.scene.onAfterActiveMeshesEvaluationObservable.add(function() {
          de.EndPerformanceCounter("Active meshes evaluation"), e._activeMeshesEvaluationTime.endMonitoring(!1);
        })) : (this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver), this._onBeforeActiveMeshesEvaluationObserver = null, this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver), this._onAfterActiveMeshesEvaluationObserver = null));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "renderTargetsRenderTimeCounter", { get: function() {
        return this._renderTargetsRenderTime;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "captureRenderTargetsRenderTime", { get: function() {
        return this._captureRenderTargetsRenderTime;
      }, set: function(t) {
        var e = this;
        t !== this._captureRenderTargetsRenderTime && (this._captureRenderTargetsRenderTime = t, t ? (this._onBeforeRenderTargetsRenderObserver = this.scene.onBeforeRenderTargetsRenderObservable.add(function() {
          de.StartPerformanceCounter("Render targets rendering"), e._renderTargetsRenderTime.beginMonitoring();
        }), this._onAfterRenderTargetsRenderObserver = this.scene.onAfterRenderTargetsRenderObservable.add(function() {
          de.EndPerformanceCounter("Render targets rendering"), e._renderTargetsRenderTime.endMonitoring(!1);
        })) : (this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver), this._onBeforeRenderTargetsRenderObserver = null, this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver), this._onAfterRenderTargetsRenderObserver = null));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "particlesRenderTimeCounter", { get: function() {
        return this._particlesRenderTime;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "captureParticlesRenderTime", { get: function() {
        return this._captureParticlesRenderTime;
      }, set: function(t) {
        var e = this;
        t !== this._captureParticlesRenderTime && (this._captureParticlesRenderTime = t, t ? (this._onBeforeParticlesRenderingObserver = this.scene.onBeforeParticlesRenderingObservable.add(function() {
          de.StartPerformanceCounter("Particles"), e._particlesRenderTime.beginMonitoring();
        }), this._onAfterParticlesRenderingObserver = this.scene.onAfterParticlesRenderingObservable.add(function() {
          de.EndPerformanceCounter("Particles"), e._particlesRenderTime.endMonitoring(!1);
        })) : (this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver), this._onBeforeParticlesRenderingObserver = null, this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver), this._onAfterParticlesRenderingObserver = null));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "spritesRenderTimeCounter", { get: function() {
        return this._spritesRenderTime;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "captureSpritesRenderTime", { get: function() {
        return this._captureSpritesRenderTime;
      }, set: function(t) {
        var e = this;
        t !== this._captureSpritesRenderTime && (this._captureSpritesRenderTime = t, this.scene.spriteManagers && (t ? (this._onBeforeSpritesRenderingObserver = this.scene.onBeforeSpritesRenderingObservable.add(function() {
          de.StartPerformanceCounter("Sprites"), e._spritesRenderTime.beginMonitoring();
        }), this._onAfterSpritesRenderingObserver = this.scene.onAfterSpritesRenderingObservable.add(function() {
          de.EndPerformanceCounter("Sprites"), e._spritesRenderTime.endMonitoring(!1);
        })) : (this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver), this._onBeforeSpritesRenderingObserver = null, this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver), this._onAfterSpritesRenderingObserver = null)));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "physicsTimeCounter", { get: function() {
        return this._physicsTime;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "capturePhysicsTime", { get: function() {
        return this._capturePhysicsTime;
      }, set: function(t) {
        var e = this;
        t !== this._capturePhysicsTime && this.scene.onBeforePhysicsObservable && (this._capturePhysicsTime = t, t ? (this._onBeforePhysicsObserver = this.scene.onBeforePhysicsObservable.add(function() {
          de.StartPerformanceCounter("Physics"), e._physicsTime.beginMonitoring();
        }), this._onAfterPhysicsObserver = this.scene.onAfterPhysicsObservable.add(function() {
          de.EndPerformanceCounter("Physics"), e._physicsTime.endMonitoring();
        })) : (this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver), this._onBeforePhysicsObserver = null, this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver), this._onAfterPhysicsObserver = null));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "animationsTimeCounter", { get: function() {
        return this._animationsTime;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "captureAnimationsTime", { get: function() {
        return this._captureAnimationsTime;
      }, set: function(t) {
        var e = this;
        t !== this._captureAnimationsTime && (this._captureAnimationsTime = t, t ? this._onAfterAnimationsObserver = this.scene.onAfterAnimationsObservable.add(function() {
          e._animationsTime.endMonitoring();
        }) : (this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver), this._onAfterAnimationsObserver = null));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "frameTimeCounter", { get: function() {
        return this._frameTime;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "captureFrameTime", { get: function() {
        return this._captureFrameTime;
      }, set: function(t) {
        this._captureFrameTime = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "interFrameTimeCounter", { get: function() {
        return this._interFrameTime;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "captureInterFrameTime", { get: function() {
        return this._captureInterFrameTime;
      }, set: function(t) {
        this._captureInterFrameTime = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "renderTimeCounter", { get: function() {
        return this._renderTime;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "captureRenderTime", { get: function() {
        return this._captureRenderTime;
      }, set: function(t) {
        var e = this;
        t !== this._captureRenderTime && (this._captureRenderTime = t, t ? (this._onBeforeDrawPhaseObserver = this.scene.onBeforeDrawPhaseObservable.add(function() {
          e._renderTime.beginMonitoring(), de.StartPerformanceCounter("Main render");
        }), this._onAfterDrawPhaseObserver = this.scene.onAfterDrawPhaseObservable.add(function() {
          e._renderTime.endMonitoring(!1), de.EndPerformanceCounter("Main render");
        })) : (this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver), this._onBeforeDrawPhaseObserver = null, this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver), this._onAfterDrawPhaseObserver = null));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "cameraRenderTimeCounter", { get: function() {
        return this._cameraRenderTime;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "captureCameraRenderTime", { get: function() {
        return this._captureCameraRenderTime;
      }, set: function(t) {
        var e = this;
        t !== this._captureCameraRenderTime && (this._captureCameraRenderTime = t, t ? (this._onBeforeCameraRenderObserver = this.scene.onBeforeCameraRenderObservable.add(function(i) {
          e._cameraRenderTime.beginMonitoring(), de.StartPerformanceCounter("Rendering camera ".concat(i.name));
        }), this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add(function(i) {
          e._cameraRenderTime.endMonitoring(!1), de.EndPerformanceCounter("Rendering camera ".concat(i.name));
        })) : (this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver), this._onBeforeCameraRenderObserver = null, this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver), this._onAfterCameraRenderObserver = null));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "drawCallsCounter", { get: function() {
        return this.scene.getEngine()._drawCalls;
      }, enumerable: !1, configurable: !0 }), n.prototype.dispose = function() {
        this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver), this._onAfterRenderObserver = null, this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver), this._onBeforeActiveMeshesEvaluationObserver = null, this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver), this._onAfterActiveMeshesEvaluationObserver = null, this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver), this._onBeforeRenderTargetsRenderObserver = null, this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver), this._onAfterRenderTargetsRenderObserver = null, this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver), this._onBeforeAnimationsObserver = null, this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver), this._onBeforeParticlesRenderingObserver = null, this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver), this._onAfterParticlesRenderingObserver = null, this._onBeforeSpritesRenderingObserver && (this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver), this._onBeforeSpritesRenderingObserver = null), this._onAfterSpritesRenderingObserver && (this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver), this._onAfterSpritesRenderingObserver = null), this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver), this._onBeforeDrawPhaseObserver = null, this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver), this._onAfterDrawPhaseObserver = null, this._onBeforePhysicsObserver && (this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver), this._onBeforePhysicsObserver = null), this._onAfterPhysicsObserver && (this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver), this._onAfterPhysicsObserver = null), this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver), this._onAfterAnimationsObserver = null, this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver), this._onBeforeCameraRenderObserver = null, this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver), this._onAfterCameraRenderObserver = null, this.scene = null;
      }, n;
    }();
    re.ShadersStore.glowMapGenerationPixelShader = `#if defined(DIFFUSE_ISLINEAR) || defined(EMISSIVE_ISLINEAR)
#include<helperFunctions>
#endif
#ifdef DIFFUSE
varying vec2 vUVDiffuse;uniform sampler2D diffuseSampler;
#endif
#ifdef OPACITY
varying vec2 vUVOpacity;uniform sampler2D opacitySampler;uniform float opacityIntensity;
#endif
#ifdef EMISSIVE
varying vec2 vUVEmissive;uniform sampler2D emissiveSampler;
#endif
#ifdef VERTEXALPHA
varying vec4 vColor;
#endif
uniform vec4 glowColor;uniform float glowIntensity;
#include<clipPlaneFragmentDeclaration>
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void)
{
#include<clipPlaneFragment>
vec4 finalColor=glowColor;
#ifdef DIFFUSE
vec4 albedoTexture=texture2D(diffuseSampler,vUVDiffuse);
#ifdef DIFFUSE_ISLINEAR
albedoTexture=toGammaSpace(albedoTexture);
#endif
#ifdef GLOW
finalColor.a*=albedoTexture.a;
#endif
#ifdef HIGHLIGHT
finalColor.a=albedoTexture.a;
#endif
#endif
#ifdef OPACITY
vec4 opacityMap=texture2D(opacitySampler,vUVOpacity);
#ifdef OPACITYRGB
finalColor.a*=getLuminance(opacityMap.rgb);
#else
finalColor.a*=opacityMap.a;
#endif
finalColor.a*=opacityIntensity;
#endif
#ifdef VERTEXALPHA
finalColor.a*=vColor.a;
#endif
#ifdef ALPHATEST
if (finalColor.a<ALPHATESTVALUE)
discard;
#endif
#ifdef EMISSIVE
vec4 emissive=texture2D(emissiveSampler,vUVEmissive);
#ifdef EMISSIVE_ISLINEAR
emissive=toGammaSpace(emissive);
#endif
gl_FragColor=emissive*finalColor*glowIntensity;
#else
gl_FragColor=finalColor*glowIntensity;
#endif
#ifdef HIGHLIGHT
gl_FragColor.a=glowColor.a;
#endif
}`, re.ShadersStore.glowMapGenerationVertexShader = `attribute vec3 position;
#include<bonesDeclaration>
#include<bakedVertexAnimationDeclaration>
#include<morphTargetsVertexGlobalDeclaration>
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
#include<clipPlaneVertexDeclaration>
#include<instancesDeclaration>
uniform mat4 viewProjection;varying vec4 vPosition;
#ifdef UV1
attribute vec2 uv;
#endif
#ifdef UV2
attribute vec2 uv2;
#endif
#ifdef DIFFUSE
varying vec2 vUVDiffuse;uniform mat4 diffuseMatrix;
#endif
#ifdef OPACITY
varying vec2 vUVOpacity;uniform mat4 opacityMatrix;
#endif
#ifdef EMISSIVE
varying vec2 vUVEmissive;uniform mat4 emissiveMatrix;
#endif
#ifdef VERTEXALPHA
attribute vec4 color;varying vec4 vColor;
#endif
#define CUSTOM_VERTEX_DEFINITIONS
void main(void)
{vec3 positionUpdated=position;
#ifdef UV1
vec2 uvUpdated=uv;
#endif
#include<morphTargetsVertexGlobal>
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
#include<instancesVertex>
#include<bonesVertex>
#include<bakedVertexAnimation>
vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);
#ifdef CUBEMAP
vPosition=worldPos;gl_Position=viewProjection*finalWorld*vec4(position,1.0);
#else
vPosition=viewProjection*worldPos;gl_Position=vPosition;
#endif
#ifdef DIFFUSE
#ifdef DIFFUSEUV1
vUVDiffuse=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
#endif
#ifdef DIFFUSEUV2
vUVDiffuse=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
#endif
#endif
#ifdef OPACITY
#ifdef OPACITYUV1
vUVOpacity=vec2(opacityMatrix*vec4(uvUpdated,1.0,0.0));
#endif
#ifdef OPACITYUV2
vUVOpacity=vec2(opacityMatrix*vec4(uv2,1.0,0.0));
#endif
#endif
#ifdef EMISSIVE
#ifdef EMISSIVEUV1
vUVEmissive=vec2(emissiveMatrix*vec4(uvUpdated,1.0,0.0));
#endif
#ifdef EMISSIVEUV2
vUVEmissive=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));
#endif
#endif
#ifdef VERTEXALPHA
vColor=color;
#endif
#include<clipPlaneVertex>
}`;
    var eu = function() {
      function n(t, e) {
        this._vertexBuffers = {}, this._maxSize = 0, this._mainTextureDesiredSize = { width: 0, height: 0 }, this._shouldRender = !0, this._postProcesses = [], this._textures = [], this._emissiveTextureAndColor = { texture: null, color: new Ie() }, this._effectIntensity = {}, this.neutralColor = new Ie(), this.isEnabled = !0, this.disableBoundingBoxesFromEffectLayer = !1, this.onDisposeObservable = new H(), this.onBeforeRenderMainTextureObservable = new H(), this.onBeforeComposeObservable = new H(), this.onBeforeRenderMeshToEffect = new H(), this.onAfterRenderMeshToEffect = new H(), this.onAfterComposeObservable = new H(), this.onSizeChangedObservable = new H(), this._materialForRendering = {}, this.name = t, this._scene = e || Me.LastCreatedScene, n._SceneComponentInitialization(this._scene), this._engine = this._scene.getEngine(), this._maxSize = this._engine.getCaps().maxTextureSize, this._scene.effectLayers.push(this), this._mergeDrawWrapper = [], this._generateIndexBuffer(), this._generateVertexBuffer();
      }
      return Object.defineProperty(n.prototype, "camera", { get: function() {
        return this._effectLayerOptions.camera;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "renderingGroupId", { get: function() {
        return this._effectLayerOptions.renderingGroupId;
      }, set: function(t) {
        this._effectLayerOptions.renderingGroupId = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "mainTexture", { get: function() {
        return this._mainTexture;
      }, enumerable: !1, configurable: !0 }), n.prototype.setMaterialForRendering = function(t, e) {
        if (this._mainTexture.setMaterialForRendering(t, e), Array.isArray(t))
          for (var i = 0; i < t.length; ++i) {
            var r = t[i];
            e ? this._materialForRendering[r.uniqueId] = [r, e] : delete this._materialForRendering[r.uniqueId];
          }
        else
          e ? this._materialForRendering[t.uniqueId] = [t, e] : delete this._materialForRendering[t.uniqueId];
      }, n.prototype.getEffectIntensity = function(t) {
        var e;
        return (e = this._effectIntensity[t.uniqueId]) !== null && e !== void 0 ? e : 1;
      }, n.prototype.setEffectIntensity = function(t, e) {
        this._effectIntensity[t.uniqueId] = e;
      }, n.prototype._numInternalDraws = function() {
        return 1;
      }, n.prototype._init = function(t) {
        this._effectLayerOptions = je({ mainTextureRatio: 0.5, alphaBlendingMode: _.ALPHA_COMBINE, camera: null, renderingGroupId: -1, mainTextureType: _.TEXTURETYPE_UNSIGNED_INT, generateStencilBuffer: !1 }, t), this._setMainTextureSize(), this._createMainTexture(), this._createTextureAndPostProcesses();
      }, n.prototype._generateIndexBuffer = function() {
        var t = [];
        t.push(0), t.push(1), t.push(2), t.push(0), t.push(2), t.push(3), this._indexBuffer = this._engine.createIndexBuffer(t);
      }, n.prototype._generateVertexBuffer = function() {
        var t = [];
        t.push(1, 1), t.push(-1, 1), t.push(-1, -1), t.push(1, -1);
        var e = new P(this._engine, t, P.PositionKind, !1, !1, 2);
        this._vertexBuffers[P.PositionKind] = e;
      }, n.prototype._setMainTextureSize = function() {
        this._effectLayerOptions.mainTextureFixedSize ? (this._mainTextureDesiredSize.width = this._effectLayerOptions.mainTextureFixedSize, this._mainTextureDesiredSize.height = this._effectLayerOptions.mainTextureFixedSize) : (this._mainTextureDesiredSize.width = this._engine.getRenderWidth() * this._effectLayerOptions.mainTextureRatio, this._mainTextureDesiredSize.height = this._engine.getRenderHeight() * this._effectLayerOptions.mainTextureRatio, this._mainTextureDesiredSize.width = this._engine.needPOTTextures ? ve.GetExponentOfTwo(this._mainTextureDesiredSize.width, this._maxSize) : this._mainTextureDesiredSize.width, this._mainTextureDesiredSize.height = this._engine.needPOTTextures ? ve.GetExponentOfTwo(this._mainTextureDesiredSize.height, this._maxSize) : this._mainTextureDesiredSize.height), this._mainTextureDesiredSize.width = Math.floor(this._mainTextureDesiredSize.width), this._mainTextureDesiredSize.height = Math.floor(this._mainTextureDesiredSize.height);
      }, n.prototype._createMainTexture = function() {
        var t, e = this;
        for (var i in this._mainTexture = new Mi("EffectLayerMainRTT", { width: this._mainTextureDesiredSize.width, height: this._mainTextureDesiredSize.height }, this._scene, !1, !0, this._effectLayerOptions.mainTextureType, !1, ae.TRILINEAR_SAMPLINGMODE, !0, this._effectLayerOptions.generateStencilBuffer), this._mainTexture.activeCamera = this._effectLayerOptions.camera, this._mainTexture.wrapU = ae.CLAMP_ADDRESSMODE, this._mainTexture.wrapV = ae.CLAMP_ADDRESSMODE, this._mainTexture.anisotropicFilteringLevel = 1, this._mainTexture.updateSamplingMode(ae.BILINEAR_SAMPLINGMODE), this._mainTexture.renderParticles = !1, this._mainTexture.renderList = null, this._mainTexture.ignoreCameraViewport = !0, this._materialForRendering) {
          var r = (t = this._materialForRendering[i])[0], o = t[1];
          this._mainTexture.setMaterialForRendering(r, o);
        }
        if (this._mainTexture.customIsReadyFunction = function(s, l, c) {
          if ((c || l === 0) && s.subMeshes)
            for (var u = 0; u < s.subMeshes.length; ++u) {
              var h = s.subMeshes[u], d = h.getMaterial(), p = h.getRenderingMesh();
              if (d) {
                var f = p._getInstancesRenderList(h._id, !!h.getReplacementMesh()).hardwareInstancedRendering[h._id] || p.hasThinInstances;
                if (e._setEmissiveTextureAndColor(p, h, d), !e._isReady(h, f, e._emissiveTextureAndColor.texture))
                  return !1;
              }
            }
          return !0;
        }, this._mainTexture.customRenderFunction = function(s, l, c, u) {
          var h;
          e.onBeforeRenderMainTextureObservable.notifyObservers(e);
          var d = e._scene.getEngine();
          if (u.length) {
            for (d.setColorWrite(!1), h = 0; h < u.length; h++)
              e._renderSubMesh(u.data[h]);
            d.setColorWrite(!0);
          }
          for (h = 0; h < s.length; h++)
            e._renderSubMesh(s.data[h]);
          for (h = 0; h < l.length; h++)
            e._renderSubMesh(l.data[h]);
          var p = d.getAlphaMode();
          for (h = 0; h < c.length; h++)
            e._renderSubMesh(c.data[h], !0);
          d.setAlphaMode(p);
        }, this._mainTexture.onClearObservable.add(function(s) {
          s.clear(e.neutralColor, !0, !0, !0);
        }), this._scene.getBoundingBoxRenderer) {
          var a = this._scene.getBoundingBoxRenderer().enabled;
          this._mainTexture.onBeforeBindObservable.add(function() {
            e._scene.getBoundingBoxRenderer().enabled = !e.disableBoundingBoxesFromEffectLayer && a;
          }), this._mainTexture.onAfterUnbindObservable.add(function() {
            e._scene.getBoundingBoxRenderer().enabled = a;
          });
        }
      }, n.prototype._addCustomEffectDefines = function(t) {
      }, n.prototype._isReady = function(t, e, i) {
        var r, o = this._scene.getEngine(), a = t.getMesh(), s = (r = a._internalAbstractMeshDataInfo._materialForRenderPass) === null || r === void 0 ? void 0 : r[o.currentRenderPassId];
        if (s)
          return s.isReadyForSubMesh(a, t, e);
        var l = t.getMaterial();
        if (!l)
          return !1;
        if (this._useMeshMaterial(t.getRenderingMesh()))
          return l.isReadyForSubMesh(t.getMesh(), t, e);
        var c = [], u = [P.PositionKind], h = !1, d = !1;
        if (l) {
          var p = l.needAlphaTesting(), f = l.getAlphaTestTexture(), m = f && f.hasAlpha && (l.useAlphaFromDiffuseTexture || l._useAlphaFromAlbedoTexture);
          f && (p || m) && (c.push("#define DIFFUSE"), a.isVerticesDataPresent(P.UV2Kind) && f.coordinatesIndex === 1 ? (c.push("#define DIFFUSEUV2"), d = !0) : a.isVerticesDataPresent(P.UVKind) && (c.push("#define DIFFUSEUV1"), h = !0), p && (c.push("#define ALPHATEST"), c.push("#define ALPHATESTVALUE 0.4")), f.gammaSpace || c.push("#define DIFFUSE_ISLINEAR"));
          var g = l.opacityTexture;
          g && (c.push("#define OPACITY"), a.isVerticesDataPresent(P.UV2Kind) && g.coordinatesIndex === 1 ? (c.push("#define OPACITYUV2"), d = !0) : a.isVerticesDataPresent(P.UVKind) && (c.push("#define OPACITYUV1"), h = !0));
        }
        i && (c.push("#define EMISSIVE"), a.isVerticesDataPresent(P.UV2Kind) && i.coordinatesIndex === 1 ? (c.push("#define EMISSIVEUV2"), d = !0) : a.isVerticesDataPresent(P.UVKind) && (c.push("#define EMISSIVEUV1"), h = !0), i.gammaSpace || c.push("#define EMISSIVE_ISLINEAR")), a.useVertexColors && a.isVerticesDataPresent(P.ColorKind) && a.hasVertexAlpha && l.transparencyMode !== Et.MATERIAL_OPAQUE && (u.push(P.ColorKind), c.push("#define VERTEXALPHA")), h && (u.push(P.UVKind), c.push("#define UV1")), d && (u.push(P.UV2Kind), c.push("#define UV2"));
        var y = new Va();
        if (a.useBones && a.computeBonesUsingShaders) {
          u.push(P.MatricesIndicesKind), u.push(P.MatricesWeightsKind), a.numBoneInfluencers > 4 && (u.push(P.MatricesIndicesExtraKind), u.push(P.MatricesWeightsExtraKind)), c.push("#define NUM_BONE_INFLUENCERS " + a.numBoneInfluencers);
          var b = a.skeleton;
          b && b.isUsingTextureForMatrices ? c.push("#define BONETEXTURE") : c.push("#define BonesPerMesh " + (b ? b.bones.length + 1 : 0)), a.numBoneInfluencers > 0 && y.addCPUSkinningFallback(0, a);
        } else
          c.push("#define NUM_BONE_INFLUENCERS 0");
        var T = a.morphTargetManager, S = 0;
        T && T.numInfluencers > 0 && (c.push("#define MORPHTARGETS"), S = T.numInfluencers, c.push("#define NUM_MORPH_INFLUENCERS " + S), T.isUsingTextureForTargets && c.push("#define MORPHTARGETS_TEXTURE"), Se.PrepareAttributesForMorphTargetsInfluencers(u, a, S)), e && (c.push("#define INSTANCES"), Se.PushAttributesForInstances(u), t.getRenderingMesh().hasThinInstances && c.push("#define THIN_INSTANCES")), aa(l, this._scene, c), this._addCustomEffectDefines(c);
        var E = t._getDrawWrapper(void 0, !0), A = E.defines, R = c.join(`
`);
        if (A !== R) {
          var C = ["world", "mBones", "viewProjection", "glowColor", "morphTargetInfluences", "boneTextureWidth", "diffuseMatrix", "emissiveMatrix", "opacityMatrix", "opacityIntensity", "morphTargetTextureInfo", "morphTargetTextureIndices", "glowIntensity"];
          Br(C), E.setEffect(this._engine.createEffect("glowMapGeneration", u, C, ["diffuseSampler", "emissiveSampler", "opacitySampler", "boneSampler", "morphTargets"], R, y, void 0, void 0, { maxSimultaneousMorphTargets: S }), R);
        }
        return E.effect.isReady();
      }, n.prototype.render = function() {
        for (var t = 0; t < this._postProcesses.length; t++)
          if (!this._postProcesses[t].isReady())
            return;
        var e = this._scene.getEngine(), i = this._numInternalDraws(), r = !0;
        for (t = 0; t < i; ++t)
          (a = this._mergeDrawWrapper[t]) || (a = this._mergeDrawWrapper[t] = new Ei(this._engine)).setEffect(this._createMergeEffect()), r = r && a.effect.isReady();
        if (r) {
          this.onBeforeComposeObservable.notifyObservers(this);
          var o = e.getAlphaMode();
          for (t = 0; t < i; ++t) {
            var a = this._mergeDrawWrapper[t];
            e.enableEffect(a), e.setState(!1), e.bindBuffers(this._vertexBuffers, this._indexBuffer, a.effect), e.setAlphaMode(this._effectLayerOptions.alphaBlendingMode), this._internalRender(a.effect, t);
          }
          e.setAlphaMode(o), this.onAfterComposeObservable.notifyObservers(this);
          var s = this._mainTexture.getSize();
          this._setMainTextureSize(), s.width === this._mainTextureDesiredSize.width && s.height === this._mainTextureDesiredSize.height || this._mainTextureDesiredSize.width === 0 || this._mainTextureDesiredSize.height === 0 || (this.onSizeChangedObservable.notifyObservers(this), this._disposeTextureAndPostProcesses(), this._createMainTexture(), this._createTextureAndPostProcesses());
        }
      }, n.prototype.hasMesh = function(t) {
        return this.renderingGroupId === -1 || t.renderingGroupId === this.renderingGroupId;
      }, n.prototype.shouldRender = function() {
        return this.isEnabled && this._shouldRender;
      }, n.prototype._shouldRenderMesh = function(t) {
        return !0;
      }, n.prototype._canRenderMesh = function(t, e) {
        return !e.needAlphaBlendingForMesh(t);
      }, n.prototype._shouldRenderEmissiveTextureForMesh = function() {
        return !0;
      }, n.prototype._renderSubMesh = function(t, e) {
        var i, r;
        if (e === void 0 && (e = !1), this.shouldRender()) {
          var o = t.getMaterial(), a = t.getMesh(), s = t.getReplacementMesh(), l = t.getRenderingMesh(), c = t.getEffectiveMesh(), u = this._scene, h = u.getEngine();
          if (c._internalAbstractMeshDataInfo._isActiveIntermediate = !1, o && this._canRenderMesh(l, o)) {
            var d = (i = l.overrideMaterialSideOrientation) !== null && i !== void 0 ? i : o.sideOrientation;
            c._getWorldMatrixDeterminant() < 0 && (d = d === Et.ClockWiseSideOrientation ? Et.CounterClockWiseSideOrientation : Et.ClockWiseSideOrientation);
            var p = d === Et.ClockWiseSideOrientation;
            h.setState(o.backFaceCulling, o.zOffset, void 0, p, o.cullBackFaces, void 0, o.zOffsetUnits);
            var f = l._getInstancesRenderList(t._id, !!s);
            if (!f.mustReturn && this._shouldRenderMesh(l)) {
              var m = f.hardwareInstancedRendering[t._id] || l.hasThinInstances;
              if (this._setEmissiveTextureAndColor(l, t, o), this.onBeforeRenderMeshToEffect.notifyObservers(a), this._useMeshMaterial(l))
                l.render(t, e, s || void 0);
              else if (this._isReady(t, m, this._emissiveTextureAndColor.texture)) {
                var g = (r = c._internalAbstractMeshDataInfo._materialForRenderPass) === null || r === void 0 ? void 0 : r[h.currentRenderPassId], y = t._getDrawWrapper();
                if (!y && g && (y = g._getDrawWrapper()), !y)
                  return;
                var b = y.effect;
                if (h.enableEffect(y), m || l._bind(t, b, o.fillMode), g ? g.bindForSubMesh(c.getWorldMatrix(), c, t) : (b.setMatrix("viewProjection", u.getTransformMatrix()), b.setMatrix("world", c.getWorldMatrix()), b.setFloat4("glowColor", this._emissiveTextureAndColor.color.r, this._emissiveTextureAndColor.color.g, this._emissiveTextureAndColor.color.b, this._emissiveTextureAndColor.color.a)), !g) {
                  var T = o.needAlphaTesting(), S = o.getAlphaTestTexture(), E = S && S.hasAlpha && (o.useAlphaFromDiffuseTexture || o._useAlphaFromAlbedoTexture);
                  S && (T || E) && (b.setTexture("diffuseSampler", S), (A = S.getTextureMatrix()) && b.setMatrix("diffuseMatrix", A));
                  var A, R = o.opacityTexture;
                  if (R && (b.setTexture("opacitySampler", R), b.setFloat("opacityIntensity", R.level), (A = R.getTextureMatrix()) && b.setMatrix("opacityMatrix", A)), this._emissiveTextureAndColor.texture && (b.setTexture("emissiveSampler", this._emissiveTextureAndColor.texture), b.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix())), l.useBones && l.computeBonesUsingShaders && l.skeleton) {
                    var C = l.skeleton;
                    if (C.isUsingTextureForMatrices) {
                      var L = C.getTransformMatrixTexture(l);
                      if (!L)
                        return;
                      b.setTexture("boneSampler", L), b.setFloat("boneTextureWidth", 4 * (C.bones.length + 1));
                    } else
                      b.setMatrices("mBones", C.getTransformMatrices(l));
                  }
                  Se.BindMorphTargetParameters(l, b), l.morphTargetManager && l.morphTargetManager.isUsingTextureForTargets && l.morphTargetManager._bind(b), e && h.setAlphaMode(o.alphaMode), b.setFloat("glowIntensity", this.getEffectIntensity(l)), Ar(b, o, u);
                }
                l._processRendering(c, t, b, o.fillMode, f, m, function(I, O) {
                  return b.setMatrix("world", O);
                });
              } else
                this._mainTexture.resetRefreshCounter();
              this.onAfterRenderMeshToEffect.notifyObservers(a);
            }
          }
        }
      }, n.prototype._useMeshMaterial = function(t) {
        return !1;
      }, n.prototype._rebuild = function() {
        var t = this._vertexBuffers[P.PositionKind];
        t && t._rebuild(), this._generateIndexBuffer();
      }, n.prototype._disposeTextureAndPostProcesses = function() {
        this._mainTexture.dispose();
        for (var t = 0; t < this._postProcesses.length; t++)
          this._postProcesses[t] && this._postProcesses[t].dispose();
        for (this._postProcesses = [], t = 0; t < this._textures.length; t++)
          this._textures[t] && this._textures[t].dispose();
        this._textures = [];
      }, n.prototype.dispose = function() {
        var t = this._vertexBuffers[P.PositionKind];
        t && (t.dispose(), this._vertexBuffers[P.PositionKind] = null), this._indexBuffer && (this._scene.getEngine()._releaseBuffer(this._indexBuffer), this._indexBuffer = null);
        for (var e = 0, i = this._mergeDrawWrapper; e < i.length; e++)
          i[e].dispose();
        this._mergeDrawWrapper = [], this._disposeTextureAndPostProcesses();
        var r = this._scene.effectLayers.indexOf(this, 0);
        r > -1 && this._scene.effectLayers.splice(r, 1), this.onDisposeObservable.notifyObservers(this), this.onDisposeObservable.clear(), this.onBeforeRenderMainTextureObservable.clear(), this.onBeforeComposeObservable.clear(), this.onBeforeRenderMeshToEffect.clear(), this.onAfterRenderMeshToEffect.clear(), this.onAfterComposeObservable.clear(), this.onSizeChangedObservable.clear();
      }, n.prototype.getClassName = function() {
        return "EffectLayer";
      }, n.Parse = function(t, e, i) {
        return de.Instantiate(t.customType).Parse(t, e, i);
      }, n._SceneComponentInitialization = function(t) {
        throw et("EffectLayerSceneComponent");
      }, x([N()], n.prototype, "name", void 0), x([ls()], n.prototype, "neutralColor", void 0), x([N()], n.prototype, "isEnabled", void 0), x([Ql()], n.prototype, "camera", null), x([N()], n.prototype, "renderingGroupId", null), x([N()], n.prototype, "disableBoundingBoxesFromEffectLayer", void 0), n;
    }();
    pe.AddParser(we.NAME_EFFECTLAYER, function(n, t, e, i) {
      if (n.effectLayers) {
        e.effectLayers || (e.effectLayers = []);
        for (var r = 0; r < n.effectLayers.length; r++) {
          var o = eu.Parse(n.effectLayers[r], t, i);
          e.effectLayers.push(o);
        }
      }
    }), pe.prototype.removeEffectLayer = function(n) {
      var t = this.effectLayers.indexOf(n);
      return t !== -1 && this.effectLayers.splice(t, 1), t;
    }, pe.prototype.addEffectLayer = function(n) {
      this.effectLayers.push(n);
    };
    var Vy = function() {
      function n(t) {
        this.name = we.NAME_EFFECTLAYER, this._renderEffects = !1, this._needStencil = !1, this._previousStencilState = !1, this.scene = t || Me.LastCreatedScene, this.scene && (this._engine = this.scene.getEngine(), this.scene.effectLayers = []);
      }
      return n.prototype.register = function() {
        this.scene._isReadyForMeshStage.registerStep(we.STEP_ISREADYFORMESH_EFFECTLAYER, this, this._isReadyForMesh), this.scene._cameraDrawRenderTargetStage.registerStep(we.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER, this, this._renderMainTexture), this.scene._beforeCameraDrawStage.registerStep(we.STEP_BEFORECAMERADRAW_EFFECTLAYER, this, this._setStencil), this.scene._afterRenderingGroupDrawStage.registerStep(we.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW, this, this._drawRenderingGroup), this.scene._afterCameraDrawStage.registerStep(we.STEP_AFTERCAMERADRAW_EFFECTLAYER, this, this._setStencilBack), this.scene._afterCameraDrawStage.registerStep(we.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW, this, this._drawCamera);
      }, n.prototype.rebuild = function() {
        for (var t = 0, e = this.scene.effectLayers; t < e.length; t++)
          e[t]._rebuild();
      }, n.prototype.serialize = function(t) {
        t.effectLayers = [];
        for (var e = 0, i = this.scene.effectLayers; e < i.length; e++) {
          var r = i[e];
          r.serialize && t.effectLayers.push(r.serialize());
        }
      }, n.prototype.addFromContainer = function(t) {
        var e = this;
        t.effectLayers && t.effectLayers.forEach(function(i) {
          e.scene.addEffectLayer(i);
        });
      }, n.prototype.removeFromContainer = function(t, e) {
        var i = this;
        t.effectLayers && t.effectLayers.forEach(function(r) {
          i.scene.removeEffectLayer(r), e && r.dispose();
        });
      }, n.prototype.dispose = function() {
        for (var t = this.scene.effectLayers; t.length; )
          t[0].dispose();
      }, n.prototype._isReadyForMesh = function(t, e) {
        for (var i = this._engine.currentRenderPassId, r = 0, o = this.scene.effectLayers; r < o.length; r++) {
          var a = o[r];
          if (a.hasMesh(t)) {
            var s = a._mainTexture;
            this._engine.currentRenderPassId = s.renderPassId;
            for (var l = 0, c = t.subMeshes; l < c.length; l++) {
              var u = c[l];
              if (!a.isReady(u, e))
                return this._engine.currentRenderPassId = i, !1;
            }
          }
        }
        return this._engine.currentRenderPassId = i, !0;
      }, n.prototype._renderMainTexture = function(t) {
        this._renderEffects = !1, this._needStencil = !1;
        var e = !1, i = this.scene.effectLayers;
        if (i && i.length > 0) {
          this._previousStencilState = this._engine.getStencilBuffer();
          for (var r = 0, o = i; r < o.length; r++) {
            var a = o[r];
            if (a.shouldRender() && (!a.camera || a.camera.cameraRigMode === dt.RIG_MODE_NONE && t === a.camera || a.camera.cameraRigMode !== dt.RIG_MODE_NONE && a.camera._rigCameras.indexOf(t) > -1)) {
              this._renderEffects = !0, this._needStencil = this._needStencil || a.needStencil();
              var s = a._mainTexture;
              s._shouldRender() && (this.scene.incrementRenderId(), s.render(!1, !1), e = !0);
            }
          }
          this.scene.incrementRenderId();
        }
        return e;
      }, n.prototype._setStencil = function() {
        this._needStencil && this._engine.setStencilBuffer(!0);
      }, n.prototype._setStencilBack = function() {
        this._needStencil && this._engine.setStencilBuffer(this._previousStencilState);
      }, n.prototype._draw = function(t) {
        if (this._renderEffects) {
          this._engine.setDepthBuffer(!1);
          for (var e = this.scene.effectLayers, i = 0; i < e.length; i++) {
            var r = e[i];
            r.renderingGroupId === t && r.shouldRender() && r.render();
          }
          this._engine.setDepthBuffer(!0);
        }
      }, n.prototype._drawCamera = function() {
        this._renderEffects && this._draw(-1);
      }, n.prototype._drawRenderingGroup = function(t) {
        !this.scene._isInIntermediateRendering() && this._renderEffects && this._draw(t);
      }, n;
    }();
    eu._SceneComponentInitialization = function(n) {
      var t = n._getComponent(we.NAME_EFFECTLAYER);
      t || (t = new Vy(n), n._addComponent(t));
    }, re.ShadersStore.glowMapMergePixelShader = `varying vec2 vUV;uniform sampler2D textureSampler;
#ifdef EMISSIVE
uniform sampler2D textureSampler2;
#endif
uniform float offset;
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void) {
#define CUSTOM_FRAGMENT_MAIN_BEGIN
vec4 baseColor=texture2D(textureSampler,vUV);
#ifdef EMISSIVE
baseColor+=texture2D(textureSampler2,vUV);baseColor*=offset;
#else
baseColor.a=abs(offset-baseColor.a);
#ifdef STROKE
float alpha=smoothstep(.0,.1,baseColor.a);baseColor.a=alpha;baseColor.rgb=baseColor.rgb*alpha;
#endif
#endif
#if LDR
baseColor=clamp(baseColor,0.,1.0);
#endif
gl_FragColor=baseColor;
#define CUSTOM_FRAGMENT_MAIN_END
}`, re.ShadersStore.glowMapMergeVertexShader = `attribute vec2 position;varying vec2 vUV;const vec2 madd=vec2(0.5,0.5);
#define CUSTOM_VERTEX_DEFINITIONS
void main(void) {
#define CUSTOM_VERTEX_MAIN_BEGIN
vUV=position*madd+madd;gl_Position=vec4(position,0.0,1.0);
#define CUSTOM_VERTEX_MAIN_END
}`, pe.prototype.getGlowLayerByName = function(n) {
      for (var t, e = 0; e < ((t = this.effectLayers) === null || t === void 0 ? void 0 : t.length); e++)
        if (this.effectLayers[e].name === n && this.effectLayers[e].getEffectName() === Zh.EffectName)
          return this.effectLayers[e];
      return null;
    };
    var Zh = function(n) {
      function t(e, i, r) {
        var o = n.call(this, e, i) || this;
        return o._intensity = 1, o._includedOnlyMeshes = [], o._excludedMeshes = [], o._meshesUsingTheirOwnMaterials = [], o.neutralColor = new Ie(0, 0, 0, 1), o._options = je({ mainTextureRatio: t.DefaultTextureRatio, blurKernelSize: 32, mainTextureFixedSize: void 0, camera: null, mainTextureSamples: 1, renderingGroupId: -1, ldrMerge: !1, alphaBlendingMode: _.ALPHA_ADD, mainTextureType: _.TEXTURETYPE_UNSIGNED_INT, generateStencilBuffer: !1 }, r), o._init({ alphaBlendingMode: o._options.alphaBlendingMode, camera: o._options.camera, mainTextureFixedSize: o._options.mainTextureFixedSize, mainTextureRatio: o._options.mainTextureRatio, renderingGroupId: o._options.renderingGroupId, mainTextureType: o._options.mainTextureType, generateStencilBuffer: o._options.generateStencilBuffer }), o;
      }
      return D(t, n), Object.defineProperty(t.prototype, "blurKernelSize", { get: function() {
        return this._options.blurKernelSize;
      }, set: function(e) {
        if (e !== this._options.blurKernelSize) {
          this._options.blurKernelSize = e;
          var i = this._getEffectiveBlurKernelSize();
          this._horizontalBlurPostprocess1.kernel = i, this._verticalBlurPostprocess1.kernel = i, this._horizontalBlurPostprocess2.kernel = i, this._verticalBlurPostprocess2.kernel = i;
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "intensity", { get: function() {
        return this._intensity;
      }, set: function(e) {
        this._intensity = e;
      }, enumerable: !1, configurable: !0 }), t.prototype.getEffectName = function() {
        return t.EffectName;
      }, t.prototype._createMergeEffect = function() {
        var e = `#define EMISSIVE 
`;
        return this._options.ldrMerge && (e += `#define LDR 
`), this._engine.createEffect("glowMapMerge", [P.PositionKind], ["offset"], ["textureSampler", "textureSampler2"], e);
      }, t.prototype._createTextureAndPostProcesses = function() {
        var e = this, i = this._mainTextureDesiredSize.width, r = this._mainTextureDesiredSize.height;
        i = this._engine.needPOTTextures ? ve.GetExponentOfTwo(i, this._maxSize) : i, r = this._engine.needPOTTextures ? ve.GetExponentOfTwo(r, this._maxSize) : r;
        var o;
        o = this._engine.getCaps().textureHalfFloatRender ? _.TEXTURETYPE_HALF_FLOAT : _.TEXTURETYPE_UNSIGNED_INT, this._blurTexture1 = new Mi("GlowLayerBlurRTT", { width: i, height: r }, this._scene, !1, !0, o), this._blurTexture1.wrapU = ae.CLAMP_ADDRESSMODE, this._blurTexture1.wrapV = ae.CLAMP_ADDRESSMODE, this._blurTexture1.updateSamplingMode(ae.BILINEAR_SAMPLINGMODE), this._blurTexture1.renderParticles = !1, this._blurTexture1.ignoreCameraViewport = !0;
        var a = Math.floor(i / 2), s = Math.floor(r / 2);
        this._blurTexture2 = new Mi("GlowLayerBlurRTT2", { width: a, height: s }, this._scene, !1, !0, o), this._blurTexture2.wrapU = ae.CLAMP_ADDRESSMODE, this._blurTexture2.wrapV = ae.CLAMP_ADDRESSMODE, this._blurTexture2.updateSamplingMode(ae.BILINEAR_SAMPLINGMODE), this._blurTexture2.renderParticles = !1, this._blurTexture2.ignoreCameraViewport = !0, this._textures = [this._blurTexture1, this._blurTexture2];
        var l = this._getEffectiveBlurKernelSize();
        this._horizontalBlurPostprocess1 = new Cn("GlowLayerHBP1", new fe(1, 0), l, { width: i, height: r }, null, ae.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, o), this._horizontalBlurPostprocess1.width = i, this._horizontalBlurPostprocess1.height = r, this._horizontalBlurPostprocess1.externalTextureSamplerBinding = !0, this._horizontalBlurPostprocess1.onApplyObservable.add(function(c) {
          c.setTexture("textureSampler", e._mainTexture);
        }), this._verticalBlurPostprocess1 = new Cn("GlowLayerVBP1", new fe(0, 1), l, { width: i, height: r }, null, ae.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, o), this._horizontalBlurPostprocess2 = new Cn("GlowLayerHBP2", new fe(1, 0), l, { width: a, height: s }, null, ae.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, o), this._horizontalBlurPostprocess2.width = a, this._horizontalBlurPostprocess2.height = s, this._horizontalBlurPostprocess2.externalTextureSamplerBinding = !0, this._horizontalBlurPostprocess2.onApplyObservable.add(function(c) {
          c.setTexture("textureSampler", e._blurTexture1);
        }), this._verticalBlurPostprocess2 = new Cn("GlowLayerVBP2", new fe(0, 1), l, { width: a, height: s }, null, ae.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, o), this._postProcesses = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1, this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2], this._postProcesses1 = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1], this._postProcesses2 = [this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2], this._mainTexture.samples = this._options.mainTextureSamples, this._mainTexture.onAfterUnbindObservable.add(function() {
          var c = e._blurTexture1.renderTarget;
          if (c) {
            e._scene.postProcessManager.directRender(e._postProcesses1, c, !0);
            var u = e._blurTexture2.renderTarget;
            u && e._scene.postProcessManager.directRender(e._postProcesses2, u, !0), e._engine.unBindFramebuffer(u ?? c, !0);
          }
        }), this._postProcesses.map(function(c) {
          c.autoClear = !1;
        });
      }, t.prototype._getEffectiveBlurKernelSize = function() {
        return this._options.blurKernelSize / 2;
      }, t.prototype.isReady = function(e, i) {
        var r = e.getMaterial(), o = e.getRenderingMesh();
        if (!r || !o)
          return !1;
        var a = r.emissiveTexture;
        return n.prototype._isReady.call(this, e, i, a);
      }, t.prototype.needStencil = function() {
        return !1;
      }, t.prototype._canRenderMesh = function(e, i) {
        return !0;
      }, t.prototype._internalRender = function(e) {
        e.setTexture("textureSampler", this._blurTexture1), e.setTexture("textureSampler2", this._blurTexture2), e.setFloat("offset", this._intensity);
        var i = this._engine, r = i.getStencilBuffer();
        i.setStencilBuffer(!1), i.drawElementsType(Et.TriangleFillMode, 0, 6), i.setStencilBuffer(r);
      }, t.prototype._setEmissiveTextureAndColor = function(e, i, r) {
        var o, a = 1;
        this.customEmissiveTextureSelector ? this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(e, i, r) : r ? (this._emissiveTextureAndColor.texture = r.emissiveTexture, this._emissiveTextureAndColor.texture && (a = this._emissiveTextureAndColor.texture.level)) : this._emissiveTextureAndColor.texture = null, this.customEmissiveColorSelector ? this.customEmissiveColorSelector(e, i, r, this._emissiveTextureAndColor.color) : r.emissiveColor ? (a *= (o = r.emissiveIntensity) !== null && o !== void 0 ? o : 1, this._emissiveTextureAndColor.color.set(r.emissiveColor.r * a, r.emissiveColor.g * a, r.emissiveColor.b * a, r.alpha)) : this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
      }, t.prototype._shouldRenderMesh = function(e) {
        return this.hasMesh(e);
      }, t.prototype._addCustomEffectDefines = function(e) {
        e.push("#define GLOW");
      }, t.prototype.addExcludedMesh = function(e) {
        this._excludedMeshes.indexOf(e.uniqueId) === -1 && this._excludedMeshes.push(e.uniqueId);
      }, t.prototype.removeExcludedMesh = function(e) {
        var i = this._excludedMeshes.indexOf(e.uniqueId);
        i !== -1 && this._excludedMeshes.splice(i, 1);
      }, t.prototype.addIncludedOnlyMesh = function(e) {
        this._includedOnlyMeshes.indexOf(e.uniqueId) === -1 && this._includedOnlyMeshes.push(e.uniqueId);
      }, t.prototype.removeIncludedOnlyMesh = function(e) {
        var i = this._includedOnlyMeshes.indexOf(e.uniqueId);
        i !== -1 && this._includedOnlyMeshes.splice(i, 1);
      }, t.prototype.hasMesh = function(e) {
        return !!n.prototype.hasMesh.call(this, e) && (this._includedOnlyMeshes.length ? this._includedOnlyMeshes.indexOf(e.uniqueId) !== -1 : !this._excludedMeshes.length || this._excludedMeshes.indexOf(e.uniqueId) === -1);
      }, t.prototype._useMeshMaterial = function(e) {
        return this._meshesUsingTheirOwnMaterials.length != 0 && this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId) > -1;
      }, t.prototype.referenceMeshToUseItsOwnMaterial = function(e) {
        var i = this;
        e.resetDrawCache(this._mainTexture.renderPassId), this._meshesUsingTheirOwnMaterials.push(e.uniqueId), e.onDisposeObservable.add(function() {
          i._disposeMesh(e);
        });
      }, t.prototype.unReferenceMeshFromUsingItsOwnMaterial = function(e) {
        for (var i = this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId); i >= 0; )
          this._meshesUsingTheirOwnMaterials.splice(i, 1), i = this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId);
        e.resetDrawCache(this._mainTexture.renderPassId);
      }, t.prototype._disposeMesh = function(e) {
        this.removeIncludedOnlyMesh(e), this.removeExcludedMesh(e);
      }, t.prototype.getClassName = function() {
        return "GlowLayer";
      }, t.prototype.serialize = function() {
        var e, i = Ne.Serialize(this);
        if (i.customType = "BABYLON.GlowLayer", i.includedMeshes = [], this._includedOnlyMeshes.length)
          for (e = 0; e < this._includedOnlyMeshes.length; e++)
            (r = this._scene.getMeshByUniqueId(this._includedOnlyMeshes[e])) && i.includedMeshes.push(r.id);
        if (i.excludedMeshes = [], this._excludedMeshes.length)
          for (e = 0; e < this._excludedMeshes.length; e++) {
            var r;
            (r = this._scene.getMeshByUniqueId(this._excludedMeshes[e])) && i.excludedMeshes.push(r.id);
          }
        return i;
      }, t.Parse = function(e, i, r) {
        var o, a = Ne.Parse(function() {
          return new t(e.name, i, e.options);
        }, e, i, r);
        for (o = 0; o < e.excludedMeshes.length; o++)
          (s = i.getMeshById(e.excludedMeshes[o])) && a.addExcludedMesh(s);
        for (o = 0; o < e.includedMeshes.length; o++) {
          var s;
          (s = i.getMeshById(e.includedMeshes[o])) && a.addIncludedOnlyMesh(s);
        }
        return a;
      }, t.EffectName = "GlowLayer", t.DefaultBlurKernelSize = 32, t.DefaultTextureRatio = 0.5, x([N()], t.prototype, "blurKernelSize", null), x([N()], t.prototype, "intensity", null), x([N("options")], t.prototype, "_options", void 0), t;
    }(eu);
    j("BABYLON.GlowLayer", Zh), re.ShadersStore.glowBlurPostProcessPixelShader = `varying vec2 vUV;uniform sampler2D textureSampler;uniform vec2 screenSize;uniform vec2 direction;uniform float blurWidth;float getLuminance(vec3 color)
{return dot(color,vec3(0.2126,0.7152,0.0722));}
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void)
{float weights[7];weights[0]=0.05;weights[1]=0.1;weights[2]=0.2;weights[3]=0.3;weights[4]=0.2;weights[5]=0.1;weights[6]=0.05;vec2 texelSize=vec2(1.0/screenSize.x,1.0/screenSize.y);vec2 texelStep=texelSize*direction*blurWidth;vec2 start=vUV-3.0*texelStep;vec4 baseColor=vec4(0.,0.,0.,0.);vec2 texelOffset=vec2(0.,0.);for (int i=0; i<7; i++)
{vec4 texel=texture2D(textureSampler,start+texelOffset);baseColor.a+=texel.a*weights[i];float luminance=getLuminance(baseColor.rgb);float luminanceTexel=getLuminance(texel.rgb);float choice=step(luminanceTexel,luminance);baseColor.rgb=choice*baseColor.rgb+(1.0-choice)*texel.rgb;texelOffset+=texelStep;}
gl_FragColor=baseColor;}`, pe.prototype.getHighlightLayerByName = function(n) {
      for (var t, e = 0; e < ((t = this.effectLayers) === null || t === void 0 ? void 0 : t.length); e++)
        if (this.effectLayers[e].name === n && this.effectLayers[e].getEffectName() === g_.EffectName)
          return this.effectLayers[e];
      return null;
    };
    var qC = function(n) {
      function t(e, i, r, o, a, s, l, c) {
        s === void 0 && (s = ae.BILINEAR_SAMPLINGMODE);
        var u = n.call(this, e, "glowBlurPostProcess", ["screenSize", "direction", "blurWidth"], null, o, a, s, l, c) || this;
        return u.direction = i, u.kernel = r, u.onApplyObservable.add(function(h) {
          h.setFloat2("screenSize", u.width, u.height), h.setVector2("direction", u.direction), h.setFloat("blurWidth", u.kernel);
        }), u;
      }
      return D(t, n), t;
    }(nt), g_ = function(n) {
      function t(e, i, r) {
        var o = n.call(this, e, i) || this;
        return o.name = e, o.innerGlow = !0, o.outerGlow = !0, o.onBeforeBlurObservable = new H(), o.onAfterBlurObservable = new H(), o._instanceGlowingMeshStencilReference = t.GlowingMeshStencilReference++, o._meshes = {}, o._excludedMeshes = {}, o.neutralColor = t.NeutralColor, o._engine.isStencilEnable || q.Warn("Rendering the Highlight Layer requires the stencil to be active on the canvas. var engine = new Engine(canvas, antialias, { stencil: true }"), o._options = je({ mainTextureRatio: 0.5, blurTextureSizeRatio: 0.5, blurHorizontalSize: 1, blurVerticalSize: 1, alphaBlendingMode: _.ALPHA_COMBINE, camera: null, renderingGroupId: -1, mainTextureType: _.TEXTURETYPE_UNSIGNED_INT }, r), o._init({ alphaBlendingMode: o._options.alphaBlendingMode, camera: o._options.camera, mainTextureFixedSize: o._options.mainTextureFixedSize, mainTextureRatio: o._options.mainTextureRatio, renderingGroupId: o._options.renderingGroupId, mainTextureType: o._options.mainTextureType }), o._shouldRender = !1, o;
      }
      return D(t, n), Object.defineProperty(t.prototype, "blurHorizontalSize", { get: function() {
        return this._horizontalBlurPostprocess.kernel;
      }, set: function(e) {
        this._horizontalBlurPostprocess.kernel = e, this._options.blurHorizontalSize = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "blurVerticalSize", { get: function() {
        return this._verticalBlurPostprocess.kernel;
      }, set: function(e) {
        this._verticalBlurPostprocess.kernel = e, this._options.blurVerticalSize = e;
      }, enumerable: !1, configurable: !0 }), t.prototype.getEffectName = function() {
        return t.EffectName;
      }, t.prototype._numInternalDraws = function() {
        return 2;
      }, t.prototype._createMergeEffect = function() {
        return this._engine.createEffect("glowMapMerge", [P.PositionKind], ["offset"], ["textureSampler"], this._options.isStroke ? `#define STROKE 
` : void 0);
      }, t.prototype._createTextureAndPostProcesses = function() {
        var e = this, i = this._mainTextureDesiredSize.width * this._options.blurTextureSizeRatio, r = this._mainTextureDesiredSize.height * this._options.blurTextureSizeRatio;
        i = this._engine.needPOTTextures ? ve.GetExponentOfTwo(i, this._maxSize) : i, r = this._engine.needPOTTextures ? ve.GetExponentOfTwo(r, this._maxSize) : r;
        var o;
        o = this._engine.getCaps().textureHalfFloatRender ? _.TEXTURETYPE_HALF_FLOAT : _.TEXTURETYPE_UNSIGNED_INT, this._blurTexture = new Mi("HighlightLayerBlurRTT", { width: i, height: r }, this._scene, !1, !0, o), this._blurTexture.wrapU = ae.CLAMP_ADDRESSMODE, this._blurTexture.wrapV = ae.CLAMP_ADDRESSMODE, this._blurTexture.anisotropicFilteringLevel = 16, this._blurTexture.updateSamplingMode(ae.TRILINEAR_SAMPLINGMODE), this._blurTexture.renderParticles = !1, this._blurTexture.ignoreCameraViewport = !0, this._textures = [this._blurTexture], this._options.alphaBlendingMode === _.ALPHA_COMBINE ? (this._downSamplePostprocess = new da("HighlightLayerPPP", this._options.blurTextureSizeRatio, null, ae.BILINEAR_SAMPLINGMODE, this._scene.getEngine()), this._downSamplePostprocess.externalTextureSamplerBinding = !0, this._downSamplePostprocess.onApplyObservable.add(function(a) {
          a.setTexture("textureSampler", e._mainTexture);
        }), this._horizontalBlurPostprocess = new qC("HighlightLayerHBP", new fe(1, 0), this._options.blurHorizontalSize, 1, null, ae.BILINEAR_SAMPLINGMODE, this._scene.getEngine()), this._horizontalBlurPostprocess.onApplyObservable.add(function(a) {
          a.setFloat2("screenSize", i, r);
        }), this._verticalBlurPostprocess = new qC("HighlightLayerVBP", new fe(0, 1), this._options.blurVerticalSize, 1, null, ae.BILINEAR_SAMPLINGMODE, this._scene.getEngine()), this._verticalBlurPostprocess.onApplyObservable.add(function(a) {
          a.setFloat2("screenSize", i, r);
        }), this._postProcesses = [this._downSamplePostprocess, this._horizontalBlurPostprocess, this._verticalBlurPostprocess]) : (this._horizontalBlurPostprocess = new Cn("HighlightLayerHBP", new fe(1, 0), this._options.blurHorizontalSize / 2, { width: i, height: r }, null, ae.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, o), this._horizontalBlurPostprocess.width = i, this._horizontalBlurPostprocess.height = r, this._horizontalBlurPostprocess.externalTextureSamplerBinding = !0, this._horizontalBlurPostprocess.onApplyObservable.add(function(a) {
          a.setTexture("textureSampler", e._mainTexture);
        }), this._verticalBlurPostprocess = new Cn("HighlightLayerVBP", new fe(0, 1), this._options.blurVerticalSize / 2, { width: i, height: r }, null, ae.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, o), this._postProcesses = [this._horizontalBlurPostprocess, this._verticalBlurPostprocess]), this._mainTexture.onAfterUnbindObservable.add(function() {
          e.onBeforeBlurObservable.notifyObservers(e);
          var a = e._blurTexture.renderTarget;
          a && (e._scene.postProcessManager.directRender(e._postProcesses, a, !0), e._engine.unBindFramebuffer(a, !0)), e.onAfterBlurObservable.notifyObservers(e);
        }), this._postProcesses.map(function(a) {
          a.autoClear = !1;
        });
      }, t.prototype.needStencil = function() {
        return !0;
      }, t.prototype.isReady = function(e, i) {
        var r = e.getMaterial(), o = e.getRenderingMesh();
        if (!r || !o || !this._meshes)
          return !1;
        var a = null, s = this._meshes[o.uniqueId];
        return s && s.glowEmissiveOnly && r && (a = r.emissiveTexture), n.prototype._isReady.call(this, e, i, a);
      }, t.prototype._internalRender = function(e, i) {
        e.setTexture("textureSampler", this._blurTexture);
        var r = this._engine;
        r.cacheStencilState(), r.setStencilOperationPass(_.REPLACE), r.setStencilOperationFail(_.KEEP), r.setStencilOperationDepthFail(_.KEEP), r.setStencilMask(0), r.setStencilBuffer(!0), r.setStencilFunctionReference(this._instanceGlowingMeshStencilReference), this.outerGlow && i === 0 && (e.setFloat("offset", 0), r.setStencilFunction(_.NOTEQUAL), r.drawElementsType(Et.TriangleFillMode, 0, 6)), this.innerGlow && i === 1 && (e.setFloat("offset", 1), r.setStencilFunction(_.EQUAL), r.drawElementsType(Et.TriangleFillMode, 0, 6)), r.restoreStencilState();
      }, t.prototype.shouldRender = function() {
        return !!n.prototype.shouldRender.call(this) && !!this._meshes;
      }, t.prototype._shouldRenderMesh = function(e) {
        return !(this._excludedMeshes && this._excludedMeshes[e.uniqueId] || !n.prototype.hasMesh.call(this, e));
      }, t.prototype._canRenderMesh = function(e, i) {
        return !0;
      }, t.prototype._addCustomEffectDefines = function(e) {
        e.push("#define HIGHLIGHT");
      }, t.prototype._setEmissiveTextureAndColor = function(e, i, r) {
        var o = this._meshes[e.uniqueId];
        o ? this._emissiveTextureAndColor.color.set(o.color.r, o.color.g, o.color.b, 1) : this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a), o && o.glowEmissiveOnly && r ? (this._emissiveTextureAndColor.texture = r.emissiveTexture, this._emissiveTextureAndColor.color.set(1, 1, 1, 1)) : this._emissiveTextureAndColor.texture = null;
      }, t.prototype.addExcludedMesh = function(e) {
        if (this._excludedMeshes && !this._excludedMeshes[e.uniqueId]) {
          var i = { mesh: e, beforeBind: null, afterRender: null, stencilState: !1 };
          i.beforeBind = e.onBeforeBindObservable.add(function(r) {
            i.stencilState = r.getEngine().getStencilBuffer(), r.getEngine().setStencilBuffer(!1);
          }), i.afterRender = e.onAfterRenderObservable.add(function(r) {
            r.getEngine().setStencilBuffer(i.stencilState);
          }), this._excludedMeshes[e.uniqueId] = i;
        }
      }, t.prototype.removeExcludedMesh = function(e) {
        if (this._excludedMeshes) {
          var i = this._excludedMeshes[e.uniqueId];
          i && (i.beforeBind && e.onBeforeBindObservable.remove(i.beforeBind), i.afterRender && e.onAfterRenderObservable.remove(i.afterRender)), this._excludedMeshes[e.uniqueId] = null;
        }
      }, t.prototype.hasMesh = function(e) {
        return !!this._meshes && !!n.prototype.hasMesh.call(this, e) && this._meshes[e.uniqueId] !== void 0 && this._meshes[e.uniqueId] !== null;
      }, t.prototype.addMesh = function(e, i, r) {
        var o = this;
        if (r === void 0 && (r = !1), this._meshes) {
          var a = this._meshes[e.uniqueId];
          a ? a.color = i : (this._meshes[e.uniqueId] = { mesh: e, color: i, observerHighlight: e.onBeforeBindObservable.add(function(s) {
            o.isEnabled && (o._excludedMeshes && o._excludedMeshes[s.uniqueId] ? o._defaultStencilReference(s) : s.getScene().getEngine().setStencilFunctionReference(o._instanceGlowingMeshStencilReference));
          }), observerDefault: e.onAfterRenderObservable.add(function(s) {
            o.isEnabled && o._defaultStencilReference(s);
          }), glowEmissiveOnly: r }, e.onDisposeObservable.add(function() {
            o._disposeMesh(e);
          })), this._shouldRender = !0;
        }
      }, t.prototype.removeMesh = function(e) {
        if (this._meshes) {
          var i = this._meshes[e.uniqueId];
          for (var r in i && (i.observerHighlight && e.onBeforeBindObservable.remove(i.observerHighlight), i.observerDefault && e.onAfterRenderObservable.remove(i.observerDefault), delete this._meshes[e.uniqueId]), this._shouldRender = !1, this._meshes)
            if (this._meshes[r]) {
              this._shouldRender = !0;
              break;
            }
        }
      }, t.prototype.removeAllMeshes = function() {
        if (this._meshes) {
          for (var e in this._meshes)
            if (Object.prototype.hasOwnProperty.call(this._meshes, e)) {
              var i = this._meshes[e];
              i && this.removeMesh(i.mesh);
            }
        }
      }, t.prototype._defaultStencilReference = function(e) {
        e.getScene().getEngine().setStencilFunctionReference(t.NormalMeshStencilReference);
      }, t.prototype._disposeMesh = function(e) {
        this.removeMesh(e), this.removeExcludedMesh(e);
      }, t.prototype.dispose = function() {
        if (this._meshes) {
          for (var e in this._meshes)
            (i = this._meshes[e]) && i.mesh && (i.observerHighlight && i.mesh.onBeforeBindObservable.remove(i.observerHighlight), i.observerDefault && i.mesh.onAfterRenderObservable.remove(i.observerDefault));
          this._meshes = null;
        }
        if (this._excludedMeshes) {
          for (var e in this._excludedMeshes) {
            var i;
            (i = this._excludedMeshes[e]) && (i.beforeBind && i.mesh.onBeforeBindObservable.remove(i.beforeBind), i.afterRender && i.mesh.onAfterRenderObservable.remove(i.afterRender));
          }
          this._excludedMeshes = null;
        }
        n.prototype.dispose.call(this);
      }, t.prototype.getClassName = function() {
        return "HighlightLayer";
      }, t.prototype.serialize = function() {
        var e = Ne.Serialize(this);
        if (e.customType = "BABYLON.HighlightLayer", e.meshes = [], this._meshes)
          for (var i in this._meshes) {
            var r = this._meshes[i];
            r && e.meshes.push({ glowEmissiveOnly: r.glowEmissiveOnly, color: r.color.asArray(), meshId: r.mesh.id });
          }
        if (e.excludedMeshes = [], this._excludedMeshes)
          for (var o in this._excludedMeshes) {
            var a = this._excludedMeshes[o];
            a && e.excludedMeshes.push(a.mesh.id);
          }
        return e;
      }, t.Parse = function(e, i, r) {
        var o, a = Ne.Parse(function() {
          return new t(e.name, i, e.options);
        }, e, i, r);
        for (o = 0; o < e.excludedMeshes.length; o++)
          (s = i.getMeshById(e.excludedMeshes[o])) && a.addExcludedMesh(s);
        for (o = 0; o < e.meshes.length; o++) {
          var s, l = e.meshes[o];
          (s = i.getMeshById(l.meshId)) && a.addMesh(s, ne.FromArray(l.color), l.glowEmissiveOnly);
        }
        return a;
      }, t.EffectName = "HighlightLayer", t.NeutralColor = new Ie(0, 0, 0, 0), t.GlowingMeshStencilReference = 2, t.NormalMeshStencilReference = 1, x([N()], t.prototype, "innerGlow", void 0), x([N()], t.prototype, "outerGlow", void 0), x([N()], t.prototype, "blurHorizontalSize", null), x([N()], t.prototype, "blurVerticalSize", null), x([N("options")], t.prototype, "_options", void 0), t;
    }(eu);
    j("BABYLON.HighlightLayer", g_);
    var ky = function() {
      function n(t) {
        this.name = we.NAME_LAYER, this.scene = t || Me.LastCreatedScene, this.scene && (this._engine = this.scene.getEngine(), this.scene.layers = []);
      }
      return n.prototype.register = function() {
        this.scene._beforeCameraDrawStage.registerStep(we.STEP_BEFORECAMERADRAW_LAYER, this, this._drawCameraBackground), this.scene._afterCameraDrawStage.registerStep(we.STEP_AFTERCAMERADRAW_LAYER, this, this._drawCameraForegroundWithPostProcessing), this.scene._afterCameraPostProcessStage.registerStep(we.STEP_AFTERCAMERAPOSTPROCESS_LAYER, this, this._drawCameraForegroundWithoutPostProcessing), this.scene._beforeRenderTargetDrawStage.registerStep(we.STEP_BEFORERENDERTARGETDRAW_LAYER, this, this._drawRenderTargetBackground), this.scene._afterRenderTargetDrawStage.registerStep(we.STEP_AFTERRENDERTARGETDRAW_LAYER, this, this._drawRenderTargetForegroundWithPostProcessing), this.scene._afterRenderTargetPostProcessStage.registerStep(we.STEP_AFTERRENDERTARGETPOSTPROCESS_LAYER, this, this._drawRenderTargetForegroundWithoutPostProcessing);
      }, n.prototype.rebuild = function() {
        for (var t = 0, e = this.scene.layers; t < e.length; t++)
          e[t]._rebuild();
      }, n.prototype.dispose = function() {
        for (var t = this.scene.layers; t.length; )
          t[0].dispose();
      }, n.prototype._draw = function(t) {
        var e = this.scene.layers;
        if (e.length) {
          this._engine.setDepthBuffer(!1);
          for (var i = 0, r = e; i < r.length; i++) {
            var o = r[i];
            t(o) && o.render();
          }
          this._engine.setDepthBuffer(!0);
        }
      }, n.prototype._drawCameraPredicate = function(t, e, i, r) {
        return !t.renderOnlyInRenderTargetTextures && t.isBackground === e && t.applyPostProcess === i && (t.layerMask & r) != 0;
      }, n.prototype._drawCameraBackground = function(t) {
        var e = this;
        this._draw(function(i) {
          return e._drawCameraPredicate(i, !0, !0, t.layerMask);
        });
      }, n.prototype._drawCameraForegroundWithPostProcessing = function(t) {
        var e = this;
        this._draw(function(i) {
          return e._drawCameraPredicate(i, !1, !0, t.layerMask);
        });
      }, n.prototype._drawCameraForegroundWithoutPostProcessing = function(t) {
        var e = this;
        this._draw(function(i) {
          return e._drawCameraPredicate(i, !1, !1, t.layerMask);
        });
      }, n.prototype._drawRenderTargetPredicate = function(t, e, i, r, o) {
        return t.renderTargetTextures.length > 0 && t.isBackground === e && t.applyPostProcess === i && t.renderTargetTextures.indexOf(o) > -1 && (t.layerMask & r) != 0;
      }, n.prototype._drawRenderTargetBackground = function(t) {
        var e = this;
        this._draw(function(i) {
          return e._drawRenderTargetPredicate(i, !0, !0, e.scene.activeCamera.layerMask, t);
        });
      }, n.prototype._drawRenderTargetForegroundWithPostProcessing = function(t) {
        var e = this;
        this._draw(function(i) {
          return e._drawRenderTargetPredicate(i, !1, !0, e.scene.activeCamera.layerMask, t);
        });
      }, n.prototype._drawRenderTargetForegroundWithoutPostProcessing = function(t) {
        var e = this;
        this._draw(function(i) {
          return e._drawRenderTargetPredicate(i, !1, !1, e.scene.activeCamera.layerMask, t);
        });
      }, n.prototype.addFromContainer = function(t) {
        var e = this;
        t.layers && t.layers.forEach(function(i) {
          e.scene.layers.push(i);
        });
      }, n.prototype.removeFromContainer = function(t, e) {
        var i = this;
        e === void 0 && (e = !1), t.layers && t.layers.forEach(function(r) {
          var o = i.scene.layers.indexOf(r);
          o !== -1 && i.scene.layers.splice(o, 1), e && r.dispose();
        });
      }, n;
    }();
    re.ShadersStore.layerPixelShader = `varying vec2 vUV;uniform sampler2D textureSampler;uniform vec4 color;
#include<helperFunctions>
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void) {
#define CUSTOM_FRAGMENT_MAIN_BEGIN
vec4 baseColor=texture2D(textureSampler,vUV);
#ifdef LINEAR
baseColor.rgb=toGammaSpace(baseColor.rgb);
#endif
#ifdef ALPHATEST
if (baseColor.a<0.4)
discard;
#endif
gl_FragColor=baseColor*color;
#define CUSTOM_FRAGMENT_MAIN_END
}`, re.ShadersStore.layerVertexShader = `attribute vec2 position;uniform vec2 scale;uniform vec2 offset;uniform mat4 textureMatrix;varying vec2 vUV;const vec2 madd=vec2(0.5,0.5);
#define CUSTOM_VERTEX_DEFINITIONS
void main(void) {
#define CUSTOM_VERTEX_MAIN_BEGIN
vec2 shiftedPosition=position*scale+offset;vUV=vec2(textureMatrix*vec4(shiftedPosition*madd+madd,1.0,0.0));gl_Position=vec4(shiftedPosition,0.0,1.0);
#define CUSTOM_VERTEX_MAIN_END
}`;
    var QC = function() {
      function n(t, e, i, r, o) {
        this.name = t, this._applyPostProcess = !0, this.scale = new fe(1, 1), this.offset = new fe(0, 0), this.alphaBlendingMode = _.ALPHA_COMBINE, this.layerMask = 268435455, this.renderTargetTextures = [], this.renderOnlyInRenderTargetTextures = !1, this.isEnabled = !0, this._vertexBuffers = {}, this.onDisposeObservable = new H(), this.onBeforeRenderObservable = new H(), this.onAfterRenderObservable = new H(), this.texture = e ? new ae(e, i, !0) : null, this.isBackground = r === void 0 || r, this.color = o === void 0 ? new Ie(1, 1, 1, 1) : o, this._scene = i || Me.LastCreatedScene;
        var a = this._scene._getComponent(we.NAME_LAYER);
        a || (a = new ky(this._scene), this._scene._addComponent(a)), this._scene.layers.push(this);
        var s = this._scene.getEngine();
        this._drawWrapper = new Ei(s);
        var l = [];
        l.push(1, 1), l.push(-1, 1), l.push(-1, -1), l.push(1, -1);
        var c = new P(s, l, P.PositionKind, !1, !1, 2);
        this._vertexBuffers[P.PositionKind] = c, this._createIndexBuffer();
      }
      return Object.defineProperty(n.prototype, "applyPostProcess", { get: function() {
        return this.isBackground || this._applyPostProcess;
      }, set: function(t) {
        this._applyPostProcess = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "onDispose", { set: function(t) {
        this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver), this._onDisposeObserver = this.onDisposeObservable.add(t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "onBeforeRender", { set: function(t) {
        this._onBeforeRenderObserver && this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver), this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "onAfterRender", { set: function(t) {
        this._onAfterRenderObserver && this.onAfterRenderObservable.remove(this._onAfterRenderObserver), this._onAfterRenderObserver = this.onAfterRenderObservable.add(t);
      }, enumerable: !1, configurable: !0 }), n.prototype._createIndexBuffer = function() {
        var t = this._scene.getEngine(), e = [];
        e.push(0), e.push(1), e.push(2), e.push(0), e.push(2), e.push(3), this._indexBuffer = t.createIndexBuffer(e);
      }, n.prototype._rebuild = function() {
        var t = this._vertexBuffers[P.PositionKind];
        t && t._rebuild(), this._createIndexBuffer();
      }, n.prototype.isReady = function() {
        var t, e = this._scene.getEngine(), i = "";
        this.alphaTest && (i = "#define ALPHATEST"), this.texture && !this.texture.gammaSpace && (i += `
#define LINEAR`), this._previousDefines !== i && (this._previousDefines = i, this._drawWrapper.effect = e.createEffect("layer", [P.PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], i));
        var r = this._drawWrapper.effect;
        return (r == null ? void 0 : r.isReady()) && ((t = this.texture) === null || t === void 0 ? void 0 : t.isReady());
      }, n.prototype.render = function() {
        if (this.isEnabled) {
          var t = this._scene.getEngine();
          if (this.isReady()) {
            var e = this._drawWrapper.effect;
            this.onBeforeRenderObservable.notifyObservers(this), t.enableEffect(this._drawWrapper), t.setState(!1), e.setTexture("textureSampler", this.texture), e.setMatrix("textureMatrix", this.texture.getTextureMatrix()), e.setFloat4("color", this.color.r, this.color.g, this.color.b, this.color.a), e.setVector2("offset", this.offset), e.setVector2("scale", this.scale), t.bindBuffers(this._vertexBuffers, this._indexBuffer, e), this.alphaTest ? t.drawElementsType(Et.TriangleFillMode, 0, 6) : (t.setAlphaMode(this.alphaBlendingMode), t.drawElementsType(Et.TriangleFillMode, 0, 6), t.setAlphaMode(_.ALPHA_DISABLE)), this.onAfterRenderObservable.notifyObservers(this);
          }
        }
      }, n.prototype.dispose = function() {
        var t = this._vertexBuffers[P.PositionKind];
        t && (t.dispose(), this._vertexBuffers[P.PositionKind] = null), this._indexBuffer && (this._scene.getEngine()._releaseBuffer(this._indexBuffer), this._indexBuffer = null), this.texture && (this.texture.dispose(), this.texture = null), this.renderTargetTextures = [];
        var e = this._scene.layers.indexOf(this);
        this._scene.layers.splice(e, 1), this.onDisposeObservable.notifyObservers(this), this.onDisposeObservable.clear(), this.onAfterRenderObservable.clear(), this.onBeforeRenderObservable.clear();
      }, n;
    }(), Gy = function() {
      function n(t, e, i, r, o) {
        this.size = t, this.position = e, this.alphaMode = _.ALPHA_ONEONE, this.color = i || new ne(1, 1, 1), this.texture = r ? new ae(r, o.getScene(), !0) : null, this._system = o;
        var a = o.scene.getEngine();
        this._drawWrapper = new Ei(a), this._drawWrapper.effect = a.createEffect("lensFlare", [P.PositionKind], ["color", "viewportMatrix"], ["textureSampler"], ""), o.lensFlares.push(this);
      }
      return n.AddFlare = function(t, e, i, r, o) {
        return new n(t, e, i, r, o);
      }, n.prototype.dispose = function() {
        this.texture && this.texture.dispose();
        var t = this._system.lensFlares.indexOf(this);
        this._system.lensFlares.splice(t, 1);
      }, n;
    }();
    re.ShadersStore.lensFlarePixelShader = `varying vec2 vUV;uniform sampler2D textureSampler;uniform vec4 color;
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void) {
#define CUSTOM_FRAGMENT_MAIN_BEGIN
vec4 baseColor=texture2D(textureSampler,vUV);gl_FragColor=baseColor*color;
#define CUSTOM_FRAGMENT_MAIN_END
}`, re.ShadersStore.lensFlareVertexShader = `attribute vec2 position;uniform mat4 viewportMatrix;varying vec2 vUV;const vec2 madd=vec2(0.5,0.5);
#define CUSTOM_VERTEX_DEFINITIONS
void main(void) {
#define CUSTOM_VERTEX_MAIN_BEGIN
vUV=position*madd+madd;gl_Position=viewportMatrix*vec4(position,0.0,1.0);
#define CUSTOM_VERTEX_MAIN_END
}`;
    var v_ = function() {
      function n(t, e, i) {
        this.name = t, this.lensFlares = [], this.borderLimit = 300, this.viewportBorder = 0, this.layerMask = 268435455, this._vertexBuffers = {}, this._isEnabled = !0, this._scene = i || Me.LastCreatedScene, n._SceneComponentInitialization(this._scene), this._emitter = e, this.id = t, i.lensFlareSystems.push(this), this.meshesSelectionPredicate = function(a) {
          return i.activeCamera && a.material && a.isVisible && a.isEnabled() && a.isBlocker && (a.layerMask & i.activeCamera.layerMask) != 0;
        };
        var r = i.getEngine(), o = [];
        o.push(1, 1), o.push(-1, 1), o.push(-1, -1), o.push(1, -1), this._vertexBuffers[P.PositionKind] = new P(r, o, P.PositionKind, !1, !1, 2), this._createIndexBuffer();
      }
      return Object.defineProperty(n.prototype, "scene", { get: function() {
        return this._scene;
      }, enumerable: !1, configurable: !0 }), n.prototype._createIndexBuffer = function() {
        var t = [];
        t.push(0), t.push(1), t.push(2), t.push(0), t.push(2), t.push(3), this._indexBuffer = this._scene.getEngine().createIndexBuffer(t);
      }, Object.defineProperty(n.prototype, "isEnabled", { get: function() {
        return this._isEnabled;
      }, set: function(t) {
        this._isEnabled = t;
      }, enumerable: !1, configurable: !0 }), n.prototype.getScene = function() {
        return this._scene;
      }, n.prototype.getEmitter = function() {
        return this._emitter;
      }, n.prototype.setEmitter = function(t) {
        this._emitter = t;
      }, n.prototype.getEmitterPosition = function() {
        return this._emitter.getAbsolutePosition ? this._emitter.getAbsolutePosition() : this._emitter.position;
      }, n.prototype.computeEffectivePosition = function(t) {
        var e = this.getEmitterPosition();
        e = v.Project(e, B.Identity(), this._scene.getTransformMatrix(), t), this._positionX = e.x, this._positionY = e.y, e = v.TransformCoordinates(this.getEmitterPosition(), this._scene.getViewMatrix()), this.viewportBorder > 0 && (t.x -= this.viewportBorder, t.y -= this.viewportBorder, t.width += 2 * this.viewportBorder, t.height += 2 * this.viewportBorder, e.x += this.viewportBorder, e.y += this.viewportBorder, this._positionX += this.viewportBorder, this._positionY += this.viewportBorder);
        var i = this._scene.useRightHandedSystem;
        return !!(e.z > 0 && !i || e.z < 0 && i) && (this._positionX > t.x && this._positionX < t.x + t.width && this._positionY > t.y && (this._positionY, t.y, t.height), !0);
      }, n.prototype._isVisible = function() {
        if (!this._isEnabled || !this._scene.activeCamera)
          return !1;
        var t = this.getEmitterPosition().subtract(this._scene.activeCamera.globalPosition), e = t.length();
        t.normalize();
        var i = new gi(this._scene.activeCamera.globalPosition, t), r = this._scene.pickWithRay(i, this.meshesSelectionPredicate, !0);
        return !r || !r.hit || r.distance > e;
      }, n.prototype.render = function() {
        if (!this._scene.activeCamera)
          return !1;
        var t, e, i = this._scene.getEngine(), r = this._scene.activeCamera.viewport.toGlobal(i.getRenderWidth(!0), i.getRenderHeight(!0));
        if (!this.computeEffectivePosition(r) || !this._isVisible())
          return !1;
        var o = (t = this._positionX < this.borderLimit + r.x ? this.borderLimit + r.x - this._positionX : this._positionX > r.x + r.width - this.borderLimit ? this._positionX - r.x - r.width + this.borderLimit : 0) > (e = this._positionY < this.borderLimit + r.y ? this.borderLimit + r.y - this._positionY : this._positionY > r.y + r.height - this.borderLimit ? this._positionY - r.y - r.height + this.borderLimit : 0) ? t : e;
        (o -= this.viewportBorder) > this.borderLimit && (o = this.borderLimit);
        var a = 1 - ue.Clamp(o / this.borderLimit, 0, 1);
        if (a < 0)
          return !1;
        a > 1 && (a = 1), this.viewportBorder > 0 && (r.x += this.viewportBorder, r.y += this.viewportBorder, r.width -= 2 * this.viewportBorder, r.height -= 2 * this.viewportBorder, this._positionX -= this.viewportBorder, this._positionY -= this.viewportBorder);
        var s = r.x + r.width / 2, l = r.y + r.height / 2, c = s - this._positionX, u = l - this._positionY;
        i.setState(!1), i.setDepthBuffer(!1);
        for (var h = 0; h < this.lensFlares.length; h++) {
          var d = this.lensFlares[h];
          if (d._drawWrapper.effect.isReady() && (!d.texture || d.texture.isReady())) {
            i.enableEffect(d._drawWrapper), i.bindBuffers(this._vertexBuffers, this._indexBuffer, d._drawWrapper.effect), i.setAlphaMode(d.alphaMode);
            var p = s - c * d.position, f = l - u * d.position, m = d.size, g = d.size * i.getAspectRatio(this._scene.activeCamera, !0), y = p / (r.width + 2 * r.x) * 2 - 1, b = 1 - f / (r.height + 2 * r.y) * 2, T = B.FromValues(m / 2, 0, 0, 0, 0, g / 2, 0, 0, 0, 0, 1, 0, y, b, 0, 1);
            d._drawWrapper.effect.setMatrix("viewportMatrix", T), d._drawWrapper.effect.setTexture("textureSampler", d.texture), d._drawWrapper.effect.setFloat4("color", d.color.r * a, d.color.g * a, d.color.b * a, 1), i.drawElementsType(Et.TriangleFillMode, 0, 6);
          }
        }
        return i.setDepthBuffer(!0), i.setAlphaMode(_.ALPHA_DISABLE), !0;
      }, n.prototype.rebuild = function() {
        var t;
        for (var e in this._createIndexBuffer(), this._vertexBuffers)
          (t = this._vertexBuffers[e]) === null || t === void 0 || t._rebuild();
      }, n.prototype.dispose = function() {
        var t = this._vertexBuffers[P.PositionKind];
        for (t && (t.dispose(), this._vertexBuffers[P.PositionKind] = null), this._indexBuffer && (this._scene.getEngine()._releaseBuffer(this._indexBuffer), this._indexBuffer = null); this.lensFlares.length; )
          this.lensFlares[0].dispose();
        var e = this._scene.lensFlareSystems.indexOf(this);
        this._scene.lensFlareSystems.splice(e, 1);
      }, n.Parse = function(t, e, i) {
        var r = e.getLastEntryById(t.emitterId), o = t.name || "lensFlareSystem#" + t.emitterId, a = new n(o, r, e);
        a.id = t.id || o, a.borderLimit = t.borderLimit;
        for (var s = 0; s < t.flares.length; s++) {
          var l = t.flares[s];
          Gy.AddFlare(l.size, l.position, ne.FromArray(l.color), l.textureName ? i + l.textureName : "", a);
        }
        return a;
      }, n.prototype.serialize = function() {
        var t = {};
        t.id = this.id, t.name = this.name, t.emitterId = this.getEmitter().id, t.borderLimit = this.borderLimit, t.flares = [];
        for (var e = 0; e < this.lensFlares.length; e++) {
          var i = this.lensFlares[e];
          t.flares.push({ size: i.size, position: i.position, color: i.color.asArray(), textureName: de.GetFilename(i.texture ? i.texture.name : "") });
        }
        return t;
      }, n._SceneComponentInitialization = function(t) {
        throw et("LensFlareSystemSceneComponent");
      }, n;
    }();
    pe.AddParser(we.NAME_LENSFLARESYSTEM, function(n, t, e, i) {
      if (n.lensFlareSystems !== void 0 && n.lensFlareSystems !== null) {
        e.lensFlareSystems || (e.lensFlareSystems = []);
        for (var r = 0, o = n.lensFlareSystems.length; r < o; r++) {
          var a = n.lensFlareSystems[r], s = v_.Parse(a, t, i);
          e.lensFlareSystems.push(s);
        }
      }
    }), pe.prototype.getLensFlareSystemByName = function(n) {
      for (var t = 0; t < this.lensFlareSystems.length; t++)
        if (this.lensFlareSystems[t].name === n)
          return this.lensFlareSystems[t];
      return null;
    }, pe.prototype.getLensFlareSystemById = function(n) {
      for (var t = 0; t < this.lensFlareSystems.length; t++)
        if (this.lensFlareSystems[t].id === n)
          return this.lensFlareSystems[t];
      return null;
    }, pe.prototype.getLensFlareSystemByID = function(n) {
      return this.getLensFlareSystemById(n);
    }, pe.prototype.removeLensFlareSystem = function(n) {
      var t = this.lensFlareSystems.indexOf(n);
      return t !== -1 && this.lensFlareSystems.splice(t, 1), t;
    }, pe.prototype.addLensFlareSystem = function(n) {
      this.lensFlareSystems.push(n);
    };
    var zy = function() {
      function n(t) {
        this.name = we.NAME_LENSFLARESYSTEM, this.scene = t, t.lensFlareSystems = [];
      }
      return n.prototype.register = function() {
        this.scene._afterCameraDrawStage.registerStep(we.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM, this, this._draw);
      }, n.prototype.rebuild = function() {
        for (var t = 0; t < this.scene.lensFlareSystems.length; t++)
          this.scene.lensFlareSystems[t].rebuild();
      }, n.prototype.addFromContainer = function(t) {
        var e = this;
        t.lensFlareSystems && t.lensFlareSystems.forEach(function(i) {
          e.scene.addLensFlareSystem(i);
        });
      }, n.prototype.removeFromContainer = function(t, e) {
        var i = this;
        t.lensFlareSystems && t.lensFlareSystems.forEach(function(r) {
          i.scene.removeLensFlareSystem(r), e && r.dispose();
        });
      }, n.prototype.serialize = function(t) {
        t.lensFlareSystems = [];
        for (var e = 0, i = this.scene.lensFlareSystems; e < i.length; e++) {
          var r = i[e];
          t.lensFlareSystems.push(r.serialize());
        }
      }, n.prototype.dispose = function() {
        for (var t = this.scene.lensFlareSystems; t.length; )
          t[0].dispose();
      }, n.prototype._draw = function(t) {
        if (this.scene.lensFlaresEnabled) {
          var e = this.scene.lensFlareSystems;
          de.StartPerformanceCounter("Lens flares", e.length > 0);
          for (var i = 0, r = e; i < r.length; i++) {
            var o = r[i];
            t.layerMask & o.layerMask && o.render();
          }
          de.EndPerformanceCounter("Lens flares", e.length > 0);
        }
      }, n;
    }();
    v_._SceneComponentInitialization = function(n) {
      var t = n._getComponent(we.NAME_LENSFLARESYSTEM);
      t || (t = new zy(n), n._addComponent(t));
    }, re.IncludesShadersStore.bayerDitherFunctions = `float bayerDither2(vec2 _P) {return mod(2.0*_P.y+_P.x+1.0,4.0);}
float bayerDither4(vec2 _P) {vec2 P1=mod(_P,2.0); 
vec2 P2=floor(0.5*mod(_P,4.0)); 
return 4.0*bayerDither2(P1)+bayerDither2(P2);}
float bayerDither8(vec2 _P) {vec2 P1=mod(_P,2.0); 
vec2 P2=floor(0.5 *mod(_P,4.0)); 
vec2 P4=floor(0.25*mod(_P,8.0)); 
return 4.0*(4.0*bayerDither2(P1)+bayerDither2(P2))+bayerDither2(P4);}
`, re.IncludesShadersStore.shadowMapFragmentExtraDeclaration = `#if SM_FLOAT==0
#include<packingFunctions>
#endif
#if SM_SOFTTRANSPARENTSHADOW==1
#include<bayerDitherFunctions>
uniform float softTransparentShadowSM;
#endif
varying float vDepthMetricSM;
#if SM_USEDISTANCE==1
uniform vec3 lightDataSM;varying vec3 vPositionWSM;
#endif
uniform vec3 biasAndScaleSM;uniform vec2 depthValuesSM;
#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1
varying float zSM;
#endif
`, re.IncludesShadersStore.shadowMapFragment = `float depthSM=vDepthMetricSM;
#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1
#if SM_USEDISTANCE==1
depthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
#else
#ifdef USE_REVERSE_DEPTHBUFFER
depthSM=(-zSM+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
#else
depthSM=(zSM+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
#endif
#endif
#ifdef USE_REVERSE_DEPTHBUFFER
gl_FragDepth=clamp(1.0-depthSM,0.0,1.0);
#else
gl_FragDepth=clamp(depthSM,0.0,1.0); 
#endif
#elif SM_USEDISTANCE==1
depthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
#endif
#if SM_ESM==1
depthSM=clamp(exp(-min(87.,biasAndScaleSM.z*depthSM)),0.,1.);
#endif
#if SM_FLOAT==1
gl_FragColor=vec4(depthSM,1.0,1.0,1.0);
#else
gl_FragColor=pack(depthSM);
#endif
return;`, re.ShadersStore.shadowMapPixelShader = `#include<shadowMapFragmentExtraDeclaration>
#ifdef ALPHATEXTURE
varying vec2 vUV;uniform sampler2D diffuseSampler;
#endif
#include<clipPlaneFragmentDeclaration>
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void)
{
#include<clipPlaneFragment>
#ifdef ALPHATEXTURE
float alphaFromAlphaTexture=texture2D(diffuseSampler,vUV).a;
#ifdef ALPHATESTVALUE
if (alphaFromAlphaTexture<ALPHATESTVALUE)
discard;
#endif
#endif
#if SM_SOFTTRANSPARENTSHADOW==1
#ifdef ALPHATEXTURE
if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alphaFromAlphaTexture) discard;
#else
if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM) discard;
#endif
#endif
#include<shadowMapFragment>
}`, re.IncludesShadersStore.sceneVertexDeclaration = `uniform mat4 viewProjection;
#ifdef MULTIVIEW
uniform mat4 viewProjectionR;
#endif
uniform mat4 view;uniform mat4 projection;uniform vec4 vEyePosition;
`, re.IncludesShadersStore.meshVertexDeclaration = `uniform mat4 world;uniform float visibility;
`, re.IncludesShadersStore.shadowMapVertexDeclaration = `#include<sceneVertexDeclaration>
#include<meshVertexDeclaration>
`, re.IncludesShadersStore.shadowMapUboDeclaration = `layout(std140,column_major) uniform;
#include<sceneUboDeclaration>
#include<meshUboDeclaration>
`, re.IncludesShadersStore.shadowMapVertexExtraDeclaration = `#if SM_NORMALBIAS==1
uniform vec3 lightDataSM;
#endif
uniform vec3 biasAndScaleSM;uniform vec2 depthValuesSM;varying float vDepthMetricSM;
#if SM_USEDISTANCE==1
varying vec3 vPositionWSM;
#endif
#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1
varying float zSM;
#endif
`, re.IncludesShadersStore.shadowMapVertexNormalBias = `#if SM_NORMALBIAS==1
#if SM_DIRECTIONINLIGHTDATA==1
vec3 worldLightDirSM=normalize(-lightDataSM.xyz);
#else
vec3 directionToLightSM=lightDataSM.xyz-worldPos.xyz;vec3 worldLightDirSM=normalize(directionToLightSM);
#endif
float ndlSM=dot(vNormalW,worldLightDirSM);float sinNLSM=sqrt(1.0-ndlSM*ndlSM);float normalBiasSM=biasAndScaleSM.y*sinNLSM;worldPos.xyz-=vNormalW*normalBiasSM;
#endif
`, re.IncludesShadersStore.shadowMapVertexMetric = `#if SM_USEDISTANCE==1
vPositionWSM=worldPos.xyz;
#endif
#if SM_DEPTHTEXTURE==1
#ifdef IS_NDC_HALF_ZRANGE
#define BIASFACTOR 0.5
#else
#define BIASFACTOR 1.0
#endif
#ifdef USE_REVERSE_DEPTHBUFFER
gl_Position.z-=biasAndScaleSM.x*gl_Position.w*BIASFACTOR;
#else
gl_Position.z+=biasAndScaleSM.x*gl_Position.w*BIASFACTOR;
#endif
#endif
#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1
zSM=gl_Position.z;gl_Position.z=0.0;
#elif SM_USEDISTANCE==0
#ifdef USE_REVERSE_DEPTHBUFFER
vDepthMetricSM=(-gl_Position.z+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
#else
vDepthMetricSM=(gl_Position.z+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
#endif
#endif
`, re.ShadersStore.shadowMapVertexShader = `attribute vec3 position;
#ifdef NORMAL
attribute vec3 normal;
#endif
#include<bonesDeclaration>
#include<bakedVertexAnimationDeclaration>
#include<morphTargetsVertexGlobalDeclaration>
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
#ifdef INSTANCES
attribute vec4 world0;attribute vec4 world1;attribute vec4 world2;attribute vec4 world3;
#endif
#include<helperFunctions>
#include<__decl__shadowMapVertex>
#ifdef ALPHATEXTURE
varying vec2 vUV;uniform mat4 diffuseMatrix;
#ifdef UV1
attribute vec2 uv;
#endif
#ifdef UV2
attribute vec2 uv2;
#endif
#endif
#include<shadowMapVertexExtraDeclaration>
#include<clipPlaneVertexDeclaration>
#define CUSTOM_VERTEX_DEFINITIONS
void main(void)
{vec3 positionUpdated=position;
#ifdef UV1
vec2 uvUpdated=uv;
#endif
#ifdef NORMAL
vec3 normalUpdated=normal;
#endif
#include<morphTargetsVertexGlobal>
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
#include<instancesVertex>
#include<bonesVertex>
#include<bakedVertexAnimation>
vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);
#ifdef NORMAL
mat3 normWorldSM=mat3(finalWorld);
#if defined(INSTANCES) && defined(THIN_INSTANCES)
vec3 vNormalW=normalUpdated/vec3(dot(normWorldSM[0],normWorldSM[0]),dot(normWorldSM[1],normWorldSM[1]),dot(normWorldSM[2],normWorldSM[2]));vNormalW=normalize(normWorldSM*vNormalW);
#else
#ifdef NONUNIFORMSCALING
normWorldSM=transposeMat3(inverseMat3(normWorldSM));
#endif
vec3 vNormalW=normalize(normWorldSM*normalUpdated);
#endif
#endif
#include<shadowMapVertexNormalBias>
gl_Position=viewProjection*worldPos;
#include<shadowMapVertexMetric>
#ifdef ALPHATEXTURE
#ifdef UV1
vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
#endif
#ifdef UV2
vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
#endif
#endif
#include<clipPlaneVertex>
}`, re.ShadersStore.depthBoxBlurPixelShader = `varying vec2 vUV;uniform sampler2D textureSampler;uniform vec2 screenSize;
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void)
{vec4 colorDepth=vec4(0.0);for (int x=-OFFSET; x<=OFFSET; x++)
for (int y=-OFFSET; y<=OFFSET; y++)
colorDepth+=texture2D(textureSampler,vUV+vec2(x,y)/screenSize);gl_FragColor=(colorDepth/float((OFFSET*2+1)*(OFFSET*2+1)));}`, re.IncludesShadersStore.shadowMapFragmentSoftTransparentShadow = `#if SM_SOFTTRANSPARENTSHADOW==1
if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alpha) discard;
#endif
`;
    var ar = function() {
      function n(t, e, i, r, o) {
        this.onBeforeShadowMapRenderObservable = new H(), this.onAfterShadowMapRenderObservable = new H(), this.onBeforeShadowMapRenderMeshObservable = new H(), this.onAfterShadowMapRenderMeshObservable = new H(), this._bias = 5e-5, this._normalBias = 0, this._blurBoxOffset = 1, this._blurScale = 2, this._blurKernel = 1, this._useKernelBlur = !1, this._filter = n.FILTER_NONE, this._filteringQuality = n.QUALITY_HIGH, this._contactHardeningLightSizeUVRatio = 0.1, this._darkness = 0, this._transparencyShadow = !1, this.enableSoftTransparentShadow = !1, this.useOpacityTextureForTransparentShadow = !1, this.frustumEdgeFalloff = 0, this.forceBackFacesOnly = !1, this._lightDirection = v.Zero(), this._viewMatrix = B.Zero(), this._projectionMatrix = B.Zero(), this._transformMatrix = B.Zero(), this._cachedPosition = new v(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), this._cachedDirection = new v(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), this._currentFaceIndex = 0, this._currentFaceIndexCache = 0, this._defaultTextureMatrix = B.Identity(), this._mapSize = t, this._light = e, this._scene = e.getScene(), this._camera = r ?? null, this._useRedTextureType = !!o;
        var a = e._shadowGenerators;
        a || (a = e._shadowGenerators = /* @__PURE__ */ new Map()), a.set(this._camera, this), this.id = e.id, this._useUBO = this._scene.getEngine().supportsUniformBuffers, this._useUBO && (this._sceneUBOs = [], this._sceneUBOs.push(this._scene.createSceneUniformBuffer('Scene for Shadow Generator (light "'.concat(this._light.name, '")')))), n._SceneComponentInitialization(this._scene);
        var s = this._scene.getEngine().getCaps();
        i ? s.textureFloatRender && s.textureFloatLinearFiltering ? this._textureType = _.TEXTURETYPE_FLOAT : s.textureHalfFloatRender && s.textureHalfFloatLinearFiltering ? this._textureType = _.TEXTURETYPE_HALF_FLOAT : this._textureType = _.TEXTURETYPE_UNSIGNED_INT : s.textureHalfFloatRender && s.textureHalfFloatLinearFiltering ? this._textureType = _.TEXTURETYPE_HALF_FLOAT : s.textureFloatRender && s.textureFloatLinearFiltering ? this._textureType = _.TEXTURETYPE_FLOAT : this._textureType = _.TEXTURETYPE_UNSIGNED_INT, this._initializeGenerator(), this._applyFilterValues();
      }
      return Object.defineProperty(n.prototype, "bias", { get: function() {
        return this._bias;
      }, set: function(t) {
        this._bias = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "normalBias", { get: function() {
        return this._normalBias;
      }, set: function(t) {
        this._normalBias = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "blurBoxOffset", { get: function() {
        return this._blurBoxOffset;
      }, set: function(t) {
        this._blurBoxOffset !== t && (this._blurBoxOffset = t, this._disposeBlurPostProcesses());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "blurScale", { get: function() {
        return this._blurScale;
      }, set: function(t) {
        this._blurScale !== t && (this._blurScale = t, this._disposeBlurPostProcesses());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "blurKernel", { get: function() {
        return this._blurKernel;
      }, set: function(t) {
        this._blurKernel !== t && (this._blurKernel = t, this._disposeBlurPostProcesses());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "useKernelBlur", { get: function() {
        return this._useKernelBlur;
      }, set: function(t) {
        this._useKernelBlur !== t && (this._useKernelBlur = t, this._disposeBlurPostProcesses());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "depthScale", { get: function() {
        return this._depthScale !== void 0 ? this._depthScale : this._light.getDepthScale();
      }, set: function(t) {
        this._depthScale = t;
      }, enumerable: !1, configurable: !0 }), n.prototype._validateFilter = function(t) {
        return t;
      }, Object.defineProperty(n.prototype, "filter", { get: function() {
        return this._filter;
      }, set: function(t) {
        if (t = this._validateFilter(t), this._light.needCube()) {
          if (t === n.FILTER_BLUREXPONENTIALSHADOWMAP)
            return void (this.useExponentialShadowMap = !0);
          if (t === n.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)
            return void (this.useCloseExponentialShadowMap = !0);
          if (t === n.FILTER_PCF || t === n.FILTER_PCSS)
            return void (this.usePoissonSampling = !0);
        }
        t !== n.FILTER_PCF && t !== n.FILTER_PCSS || this._scene.getEngine()._features.supportShadowSamplers ? this._filter !== t && (this._filter = t, this._disposeBlurPostProcesses(), this._applyFilterValues(), this._light._markMeshesAsLightDirty()) : this.usePoissonSampling = !0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "usePoissonSampling", { get: function() {
        return this.filter === n.FILTER_POISSONSAMPLING;
      }, set: function(t) {
        var e = this._validateFilter(n.FILTER_POISSONSAMPLING);
        (t || this.filter === n.FILTER_POISSONSAMPLING) && (this.filter = t ? e : n.FILTER_NONE);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "useExponentialShadowMap", { get: function() {
        return this.filter === n.FILTER_EXPONENTIALSHADOWMAP;
      }, set: function(t) {
        var e = this._validateFilter(n.FILTER_EXPONENTIALSHADOWMAP);
        (t || this.filter === n.FILTER_EXPONENTIALSHADOWMAP) && (this.filter = t ? e : n.FILTER_NONE);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "useBlurExponentialShadowMap", { get: function() {
        return this.filter === n.FILTER_BLUREXPONENTIALSHADOWMAP;
      }, set: function(t) {
        var e = this._validateFilter(n.FILTER_BLUREXPONENTIALSHADOWMAP);
        (t || this.filter === n.FILTER_BLUREXPONENTIALSHADOWMAP) && (this.filter = t ? e : n.FILTER_NONE);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "useCloseExponentialShadowMap", { get: function() {
        return this.filter === n.FILTER_CLOSEEXPONENTIALSHADOWMAP;
      }, set: function(t) {
        var e = this._validateFilter(n.FILTER_CLOSEEXPONENTIALSHADOWMAP);
        (t || this.filter === n.FILTER_CLOSEEXPONENTIALSHADOWMAP) && (this.filter = t ? e : n.FILTER_NONE);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "useBlurCloseExponentialShadowMap", { get: function() {
        return this.filter === n.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP;
      }, set: function(t) {
        var e = this._validateFilter(n.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP);
        (t || this.filter === n.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) && (this.filter = t ? e : n.FILTER_NONE);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "usePercentageCloserFiltering", { get: function() {
        return this.filter === n.FILTER_PCF;
      }, set: function(t) {
        var e = this._validateFilter(n.FILTER_PCF);
        (t || this.filter === n.FILTER_PCF) && (this.filter = t ? e : n.FILTER_NONE);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "filteringQuality", { get: function() {
        return this._filteringQuality;
      }, set: function(t) {
        this._filteringQuality !== t && (this._filteringQuality = t, this._disposeBlurPostProcesses(), this._applyFilterValues(), this._light._markMeshesAsLightDirty());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "useContactHardeningShadow", { get: function() {
        return this.filter === n.FILTER_PCSS;
      }, set: function(t) {
        var e = this._validateFilter(n.FILTER_PCSS);
        (t || this.filter === n.FILTER_PCSS) && (this.filter = t ? e : n.FILTER_NONE);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "contactHardeningLightSizeUVRatio", { get: function() {
        return this._contactHardeningLightSizeUVRatio;
      }, set: function(t) {
        this._contactHardeningLightSizeUVRatio = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "darkness", { get: function() {
        return this._darkness;
      }, set: function(t) {
        this.setDarkness(t);
      }, enumerable: !1, configurable: !0 }), n.prototype.getDarkness = function() {
        return this._darkness;
      }, n.prototype.setDarkness = function(t) {
        return this._darkness = t >= 1 ? 1 : t <= 0 ? 0 : t, this;
      }, Object.defineProperty(n.prototype, "transparencyShadow", { get: function() {
        return this._transparencyShadow;
      }, set: function(t) {
        this.setTransparencyShadow(t);
      }, enumerable: !1, configurable: !0 }), n.prototype.setTransparencyShadow = function(t) {
        return this._transparencyShadow = t, this;
      }, n.prototype.getShadowMap = function() {
        return this._shadowMap;
      }, n.prototype.getShadowMapForRendering = function() {
        return this._shadowMap2 ? this._shadowMap2 : this._shadowMap;
      }, n.prototype.getClassName = function() {
        return n.CLASSNAME;
      }, n.prototype.addShadowCaster = function(t, e) {
        if (e === void 0 && (e = !0), !this._shadowMap)
          return this;
        if (this._shadowMap.renderList || (this._shadowMap.renderList = []), this._shadowMap.renderList.indexOf(t) === -1 && this._shadowMap.renderList.push(t), e)
          for (var i = 0, r = t.getChildMeshes(); i < r.length; i++) {
            var o = r[i];
            this._shadowMap.renderList.indexOf(o) === -1 && this._shadowMap.renderList.push(o);
          }
        return this;
      }, n.prototype.removeShadowCaster = function(t, e) {
        if (e === void 0 && (e = !0), !this._shadowMap || !this._shadowMap.renderList)
          return this;
        var i = this._shadowMap.renderList.indexOf(t);
        if (i !== -1 && this._shadowMap.renderList.splice(i, 1), e)
          for (var r = 0, o = t.getChildren(); r < o.length; r++) {
            var a = o[r];
            this.removeShadowCaster(a);
          }
        return this;
      }, n.prototype.getLight = function() {
        return this._light;
      }, n.prototype._getCamera = function() {
        var t;
        return (t = this._camera) !== null && t !== void 0 ? t : this._scene.activeCamera;
      }, Object.defineProperty(n.prototype, "mapSize", { get: function() {
        return this._mapSize;
      }, set: function(t) {
        this._mapSize = t, this._light._markMeshesAsLightDirty(), this.recreateShadowMap();
      }, enumerable: !1, configurable: !0 }), n.prototype._initializeGenerator = function() {
        this._light._markMeshesAsLightDirty(), this._initializeShadowMap();
      }, n.prototype._createTargetRenderTexture = function() {
        var t = this._scene.getEngine();
        t._features.supportDepthStencilTexture ? (this._shadowMap = new Mi(this._light.name + "_shadowMap", this._mapSize, this._scene, !1, !0, this._textureType, this._light.needCube(), void 0, !1, !1, void 0, this._useRedTextureType ? _.TEXTUREFORMAT_RED : _.TEXTUREFORMAT_RGBA), this._shadowMap.createDepthStencilTexture(t.useReverseDepthBuffer ? _.GREATER : _.LESS, !0)) : this._shadowMap = new Mi(this._light.name + "_shadowMap", this._mapSize, this._scene, !1, !0, this._textureType, this._light.needCube()), this._shadowMap.noPrePassRenderer = !0;
      }, n.prototype._initializeShadowMap = function() {
        var t = this;
        if (this._createTargetRenderTexture(), this._shadowMap !== null) {
          this._shadowMap.wrapU = ae.CLAMP_ADDRESSMODE, this._shadowMap.wrapV = ae.CLAMP_ADDRESSMODE, this._shadowMap.anisotropicFilteringLevel = 1, this._shadowMap.updateSamplingMode(ae.BILINEAR_SAMPLINGMODE), this._shadowMap.renderParticles = !1, this._shadowMap.ignoreCameraViewport = !0, this._storedUniqueId && (this._shadowMap.uniqueId = this._storedUniqueId), this._shadowMap.customRenderFunction = function(a, s, l, c) {
            return t._renderForShadowMap(a, s, l, c);
          }, this._shadowMap.customIsReadyFunction = function() {
            return !0;
          };
          var e = this._scene.getEngine();
          this._shadowMap.onBeforeBindObservable.add(function() {
            var a;
            t._currentSceneUBO = t._scene.getSceneUniformBuffer(), (a = e._debugPushGroup) === null || a === void 0 || a.call(e, "shadow map generation for pass id ".concat(e.currentRenderPassId), 1);
          }), this._shadowMap.onBeforeRenderObservable.add(function(a) {
            t._sceneUBOs && t._scene.setSceneUniformBuffer(t._sceneUBOs[0]), t._currentFaceIndex = a, t._filter === n.FILTER_PCF && e.setColorWrite(!1), t.getTransformMatrix(), t._scene.setTransformMatrix(t._viewMatrix, t._projectionMatrix), t._useUBO && (t._scene.getSceneUniformBuffer().unbindEffect(), t._scene.finalizeSceneUbo());
          }), this._shadowMap.onAfterUnbindObservable.add(function() {
            var a, s;
            if (t._sceneUBOs && t._scene.setSceneUniformBuffer(t._currentSceneUBO), t._scene.updateTransformMatrix(), t._filter === n.FILTER_PCF && e.setColorWrite(!0), t.useBlurExponentialShadowMap || t.useBlurCloseExponentialShadowMap) {
              var l = t.getShadowMapForRendering();
              l && (t._scene.postProcessManager.directRender(t._blurPostProcesses, l.renderTarget, !0), e.unBindFramebuffer(l.renderTarget, !0), (s = e._debugPopGroup) === null || s === void 0 || s.call(e, 1));
            } else
              (a = e._debugPopGroup) === null || a === void 0 || a.call(e, 1);
          });
          var i = new Ie(0, 0, 0, 0), r = new Ie(1, 1, 1, 1);
          this._shadowMap.onClearObservable.add(function(a) {
            t._filter === n.FILTER_PCF ? a.clear(r, !1, !0, !1) : t.useExponentialShadowMap || t.useBlurExponentialShadowMap ? a.clear(i, !0, !0, !1) : a.clear(r, !0, !0, !1);
          }), this._shadowMap.onResizeObservable.add(function(a) {
            t._storedUniqueId = t._shadowMap.uniqueId, t._mapSize = a.getRenderSize(), t._light._markMeshesAsLightDirty(), t.recreateShadowMap();
          });
          for (var o = rc.MIN_RENDERINGGROUPS; o < rc.MAX_RENDERINGGROUPS; o++)
            this._shadowMap.setRenderingAutoClearDepthStencil(o, !1);
        }
      }, n.prototype._initializeBlurRTTAndPostProcesses = function() {
        var t = this, e = this._scene.getEngine(), i = this._mapSize / this.blurScale;
        this.useKernelBlur && this.blurScale === 1 || (this._shadowMap2 = new Mi(this._light.name + "_shadowMap2", i, this._scene, !1, !0, this._textureType, void 0, void 0, !1), this._shadowMap2.wrapU = ae.CLAMP_ADDRESSMODE, this._shadowMap2.wrapV = ae.CLAMP_ADDRESSMODE, this._shadowMap2.updateSamplingMode(ae.BILINEAR_SAMPLINGMODE)), this.useKernelBlur ? (this._kernelBlurXPostprocess = new Cn(this._light.name + "KernelBlurX", new fe(1, 0), this.blurKernel, 1, null, ae.BILINEAR_SAMPLINGMODE, e, !1, this._textureType), this._kernelBlurXPostprocess.width = i, this._kernelBlurXPostprocess.height = i, this._kernelBlurXPostprocess.externalTextureSamplerBinding = !0, this._kernelBlurXPostprocess.onApplyObservable.add(function(r) {
          r.setTexture("textureSampler", t._shadowMap);
        }), this._kernelBlurYPostprocess = new Cn(this._light.name + "KernelBlurY", new fe(0, 1), this.blurKernel, 1, null, ae.BILINEAR_SAMPLINGMODE, e, !1, this._textureType), this._kernelBlurXPostprocess.autoClear = !1, this._kernelBlurYPostprocess.autoClear = !1, this._textureType === _.TEXTURETYPE_UNSIGNED_INT && (this._kernelBlurXPostprocess.packedFloat = !0, this._kernelBlurYPostprocess.packedFloat = !0), this._blurPostProcesses = [this._kernelBlurXPostprocess, this._kernelBlurYPostprocess]) : (this._boxBlurPostprocess = new nt(this._light.name + "DepthBoxBlur", "depthBoxBlur", ["screenSize", "boxOffset"], [], 1, null, ae.BILINEAR_SAMPLINGMODE, e, !1, "#define OFFSET " + this._blurBoxOffset, this._textureType), this._boxBlurPostprocess.externalTextureSamplerBinding = !0, this._boxBlurPostprocess.onApplyObservable.add(function(r) {
          r.setFloat2("screenSize", i, i), r.setTexture("textureSampler", t._shadowMap);
        }), this._boxBlurPostprocess.autoClear = !1, this._blurPostProcesses = [this._boxBlurPostprocess]);
      }, n.prototype._renderForShadowMap = function(t, e, i, r) {
        var o;
        if (r.length)
          for (o = 0; o < r.length; o++)
            this._renderSubMeshForShadowMap(r.data[o]);
        for (o = 0; o < t.length; o++)
          this._renderSubMeshForShadowMap(t.data[o]);
        for (o = 0; o < e.length; o++)
          this._renderSubMeshForShadowMap(e.data[o]);
        if (this._transparencyShadow)
          for (o = 0; o < i.length; o++)
            this._renderSubMeshForShadowMap(i.data[o], !0);
        else
          for (o = 0; o < i.length; o++)
            i.data[o].getEffectiveMesh()._internalAbstractMeshDataInfo._isActiveIntermediate = !1;
      }, n.prototype._bindCustomEffectForRenderSubMeshForShadowMap = function(t, e, i) {
        e.setMatrix("viewProjection", this.getTransformMatrix());
      }, n.prototype._renderSubMeshForShadowMap = function(t, e) {
        var i, r;
        e === void 0 && (e = !1);
        var o = t.getRenderingMesh(), a = t.getEffectiveMesh(), s = this._scene, l = s.getEngine(), c = t.getMaterial();
        if (a._internalAbstractMeshDataInfo._isActiveIntermediate = !1, c && t.verticesCount !== 0 && t._renderId !== s.getRenderId()) {
          var u = a._getWorldMatrixDeterminant() < 0, h = (i = o.overrideMaterialSideOrientation) !== null && i !== void 0 ? i : c.sideOrientation;
          u && (h = h === _.MATERIAL_ClockWiseSideOrientation ? _.MATERIAL_CounterClockWiseSideOrientation : _.MATERIAL_ClockWiseSideOrientation);
          var d = h === _.MATERIAL_ClockWiseSideOrientation;
          l.setState(c.backFaceCulling, void 0, void 0, d, c.cullBackFaces);
          var p = o._getInstancesRenderList(t._id, !!t.getReplacementMesh());
          if (!p.mustReturn) {
            var f = l.getCaps().instancedArrays && (p.visibleInstances[t._id] !== null && p.visibleInstances[t._id] !== void 0 || o.hasThinInstances);
            if (!this.customAllowRendering || this.customAllowRendering(t))
              if (this.isReady(t, f, e)) {
                t._renderId = s.getRenderId();
                var m = c.shadowDepthWrapper, g = (r = m == null ? void 0 : m.getEffect(t, this, l.currentRenderPassId)) !== null && r !== void 0 ? r : t._getDrawWrapper(), y = Ei.GetEffect(g);
                l.enableEffect(g), f || o._bind(t, y, c.fillMode), this.getTransformMatrix(), y.setFloat3("biasAndScaleSM", this.bias, this.normalBias, this.depthScale), this.getLight().getTypeID() === Kn.LIGHTTYPEID_DIRECTIONALLIGHT ? y.setVector3("lightDataSM", this._cachedDirection) : y.setVector3("lightDataSM", this._cachedPosition);
                var b = this._getCamera();
                if (b && y.setFloat2("depthValuesSM", this.getLight().getDepthMinZ(b), this.getLight().getDepthMinZ(b) + this.getLight().getDepthMaxZ(b)), e && this.enableSoftTransparentShadow && y.setFloat("softTransparentShadowSM", a.visibility * c.alpha), m)
                  t._setMainDrawWrapperOverride(g), m.standalone ? m.baseMaterial.bindForSubMesh(a.getWorldMatrix(), o, t) : c.bindForSubMesh(a.getWorldMatrix(), o, t), t._setMainDrawWrapperOverride(null);
                else {
                  if (this._opacityTexture && (y.setTexture("diffuseSampler", this._opacityTexture), y.setMatrix("diffuseMatrix", this._opacityTexture.getTextureMatrix() || this._defaultTextureMatrix)), o.useBones && o.computeBonesUsingShaders && o.skeleton) {
                    var T = o.skeleton;
                    if (T.isUsingTextureForMatrices) {
                      var S = T.getTransformMatrixTexture(o);
                      if (!S)
                        return;
                      y.setTexture("boneSampler", S), y.setFloat("boneTextureWidth", 4 * (T.bones.length + 1));
                    } else
                      y.setMatrices("mBones", T.getTransformMatrices(o));
                  }
                  Se.BindMorphTargetParameters(o, y), o.morphTargetManager && o.morphTargetManager.isUsingTextureForTargets && o.morphTargetManager._bind(y), Ar(y, c, s);
                }
                this._useUBO || m || this._bindCustomEffectForRenderSubMeshForShadowMap(t, y, a), Se.BindSceneUniformBuffer(y, this._scene.getSceneUniformBuffer()), this._scene.getSceneUniformBuffer().bindUniformBuffer();
                var E = a.getWorldMatrix();
                f && (a.getMeshUniformBuffer().bindToEffect(y, "Mesh"), a.transferToEffect(E)), this.forceBackFacesOnly && l.setState(!0, 0, !1, !0, c.cullBackFaces), this.onBeforeShadowMapRenderMeshObservable.notifyObservers(o), this.onBeforeShadowMapRenderObservable.notifyObservers(y), o._processRendering(a, t, y, c.fillMode, p, f, function(A, R) {
                  a === o || A ? (a.getMeshUniformBuffer().bindToEffect(y, "Mesh"), a.transferToEffect(A ? R : E)) : (o.getMeshUniformBuffer().bindToEffect(y, "Mesh"), o.transferToEffect(R));
                }), this.forceBackFacesOnly && l.setState(!0, 0, !1, !1, c.cullBackFaces), this.onAfterShadowMapRenderObservable.notifyObservers(y), this.onAfterShadowMapRenderMeshObservable.notifyObservers(o);
              } else
                this._shadowMap && this._shadowMap.resetRefreshCounter();
          }
        }
      }, n.prototype._applyFilterValues = function() {
        this._shadowMap && (this.filter === n.FILTER_NONE || this.filter === n.FILTER_PCSS ? this._shadowMap.updateSamplingMode(ae.NEAREST_SAMPLINGMODE) : this._shadowMap.updateSamplingMode(ae.BILINEAR_SAMPLINGMODE));
      }, n.prototype.forceCompilation = function(t, e) {
        var i = this, r = je({ useInstances: !1 }, e), o = this.getShadowMap();
        if (o) {
          var a = o.renderList;
          if (a) {
            for (var s = [], l = 0, c = a; l < c.length; l++) {
              var u = c[l];
              s.push.apply(s, u.subMeshes);
            }
            if (s.length !== 0) {
              var h = 0, d = function() {
                var p, f;
                if (i._scene && i._scene.getEngine()) {
                  for (; i.isReady(s[h], r.useInstances, (f = (p = s[h].getMaterial()) === null || p === void 0 ? void 0 : p.needAlphaBlendingForMesh(s[h].getMesh())) !== null && f !== void 0 && f); )
                    if (++h >= s.length)
                      return void (t && t(i));
                  setTimeout(d, 16);
                }
              };
              d();
            } else
              t && t(this);
          } else
            t && t(this);
        } else
          t && t(this);
      }, n.prototype.forceCompilationAsync = function(t) {
        var e = this;
        return new Promise(function(i) {
          e.forceCompilation(function() {
            i();
          }, t);
        });
      }, n.prototype._isReadyCustomDefines = function(t, e, i) {
      }, n.prototype._prepareShadowDefines = function(t, e, i, r) {
        i.push("#define SM_LIGHTTYPE_" + this._light.getClassName().toUpperCase()), i.push("#define SM_FLOAT " + (this._textureType !== _.TEXTURETYPE_UNSIGNED_INT ? "1" : "0")), i.push("#define SM_ESM " + (this.useExponentialShadowMap || this.useBlurExponentialShadowMap ? "1" : "0")), i.push("#define SM_DEPTHTEXTURE " + (this.usePercentageCloserFiltering || this.useContactHardeningShadow ? "1" : "0"));
        var o = t.getMesh();
        return i.push("#define SM_NORMALBIAS " + (this.normalBias && o.isVerticesDataPresent(P.NormalKind) ? "1" : "0")), i.push("#define SM_DIRECTIONINLIGHTDATA " + (this.getLight().getTypeID() === Kn.LIGHTTYPEID_DIRECTIONALLIGHT ? "1" : "0")), i.push("#define SM_USEDISTANCE " + (this._light.needCube() ? "1" : "0")), i.push("#define SM_SOFTTRANSPARENTSHADOW " + (this.enableSoftTransparentShadow && r ? "1" : "0")), this._isReadyCustomDefines(i, t, e), i;
      }, n.prototype.isReady = function(t, e, i) {
        var r, o = t.getMaterial(), a = o == null ? void 0 : o.shadowDepthWrapper;
        if (this._opacityTexture = null, !o)
          return !1;
        var s = [];
        if (this._prepareShadowDefines(t, e, s, i), a) {
          if (!a.isReadyForSubMesh(t, s, this, e, this._scene.getEngine().currentRenderPassId))
            return !1;
        } else {
          var l = t._getDrawWrapper(void 0, !0), c = l.effect, u = l.defines, h = [P.PositionKind], d = t.getMesh();
          this.normalBias && d.isVerticesDataPresent(P.NormalKind) && (h.push(P.NormalKind), s.push("#define NORMAL"), d.nonUniformScaling && s.push("#define NONUNIFORMSCALING"));
          var p = o.needAlphaTesting();
          if ((p || o.needAlphaBlending()) && (this.useOpacityTextureForTransparentShadow ? this._opacityTexture = o.opacityTexture : this._opacityTexture = o.getAlphaTestTexture(), this._opacityTexture)) {
            if (!this._opacityTexture.isReady())
              return !1;
            var f = (r = o.alphaCutOff) !== null && r !== void 0 ? r : n.DEFAULT_ALPHA_CUTOFF;
            s.push("#define ALPHATEXTURE"), p && s.push("#define ALPHATESTVALUE ".concat(f).concat(f % 1 == 0 ? "." : "")), d.isVerticesDataPresent(P.UVKind) && (h.push(P.UVKind), s.push("#define UV1")), d.isVerticesDataPresent(P.UV2Kind) && this._opacityTexture.coordinatesIndex === 1 && (h.push(P.UV2Kind), s.push("#define UV2"));
          }
          var m = new Va();
          if (d.useBones && d.computeBonesUsingShaders && d.skeleton) {
            h.push(P.MatricesIndicesKind), h.push(P.MatricesWeightsKind), d.numBoneInfluencers > 4 && (h.push(P.MatricesIndicesExtraKind), h.push(P.MatricesWeightsExtraKind));
            var g = d.skeleton;
            s.push("#define NUM_BONE_INFLUENCERS " + d.numBoneInfluencers), d.numBoneInfluencers > 0 && m.addCPUSkinningFallback(0, d), g.isUsingTextureForMatrices ? s.push("#define BONETEXTURE") : s.push("#define BonesPerMesh " + (g.bones.length + 1));
          } else
            s.push("#define NUM_BONE_INFLUENCERS 0");
          var y = d.morphTargetManager, b = 0;
          if (y && y.numInfluencers > 0 && (s.push("#define MORPHTARGETS"), b = y.numInfluencers, s.push("#define NUM_MORPH_INFLUENCERS " + b), y.isUsingTextureForTargets && s.push("#define MORPHTARGETS_TEXTURE"), Se.PrepareAttributesForMorphTargetsInfluencers(h, d, b)), aa(o, this._scene, s), e && (s.push("#define INSTANCES"), Se.PushAttributesForInstances(h), t.getRenderingMesh().hasThinInstances && s.push("#define THIN_INSTANCES")), this.customShaderOptions && this.customShaderOptions.defines)
            for (var T = 0, S = this.customShaderOptions.defines; T < S.length; T++) {
              var E = S[T];
              s.indexOf(E) === -1 && s.push(E);
            }
          var A = s.join(`
`);
          if (u !== A) {
            u = A;
            var R = "shadowMap", C = ["world", "mBones", "viewProjection", "diffuseMatrix", "lightDataSM", "depthValuesSM", "biasAndScaleSM", "morphTargetInfluences", "boneTextureWidth", "softTransparentShadowSM", "morphTargetTextureInfo", "morphTargetTextureIndices"], L = ["diffuseSampler", "boneSampler", "morphTargets"];
            if (Br(C), this.customShaderOptions) {
              if (R = this.customShaderOptions.shaderName, this.customShaderOptions.attributes)
                for (var I = 0, O = this.customShaderOptions.attributes; I < O.length; I++) {
                  var w = O[I];
                  h.indexOf(w) === -1 && h.push(w);
                }
              if (this.customShaderOptions.uniforms)
                for (var z = 0, V = this.customShaderOptions.uniforms; z < V.length; z++) {
                  var Y = V[z];
                  C.indexOf(Y) === -1 && C.push(Y);
                }
              if (this.customShaderOptions.samplers)
                for (var ee = 0, J = this.customShaderOptions.samplers; ee < J.length; ee++) {
                  var X = J[ee];
                  L.indexOf(X) === -1 && L.push(X);
                }
            }
            var K = this._scene.getEngine();
            c = K.createEffect(R, { attributes: h, uniformsNames: C, uniformBuffersNames: ["Scene", "Mesh"], samplers: L, defines: A, fallbacks: m, onCompiled: null, onError: null, indexParameters: { maxSimultaneousMorphTargets: b } }, K), l.setEffect(c, u);
          }
          if (!c.isReady())
            return !1;
        }
        return (this.useBlurExponentialShadowMap || this.useBlurCloseExponentialShadowMap) && (this._blurPostProcesses && this._blurPostProcesses.length || this._initializeBlurRTTAndPostProcesses()), !(this._kernelBlurXPostprocess && !this._kernelBlurXPostprocess.isReady() || this._kernelBlurYPostprocess && !this._kernelBlurYPostprocess.isReady() || this._boxBlurPostprocess && !this._boxBlurPostprocess.isReady());
      }, n.prototype.prepareDefines = function(t, e) {
        var i = this._scene, r = this._light;
        i.shadowsEnabled && r.shadowEnabled && (t["SHADOW" + e] = !0, this.useContactHardeningShadow ? (t["SHADOWPCSS" + e] = !0, this._filteringQuality === n.QUALITY_LOW ? t["SHADOWLOWQUALITY" + e] = !0 : this._filteringQuality === n.QUALITY_MEDIUM && (t["SHADOWMEDIUMQUALITY" + e] = !0)) : this.usePercentageCloserFiltering ? (t["SHADOWPCF" + e] = !0, this._filteringQuality === n.QUALITY_LOW ? t["SHADOWLOWQUALITY" + e] = !0 : this._filteringQuality === n.QUALITY_MEDIUM && (t["SHADOWMEDIUMQUALITY" + e] = !0)) : this.usePoissonSampling ? t["SHADOWPOISSON" + e] = !0 : this.useExponentialShadowMap || this.useBlurExponentialShadowMap ? t["SHADOWESM" + e] = !0 : (this.useCloseExponentialShadowMap || this.useBlurCloseExponentialShadowMap) && (t["SHADOWCLOSEESM" + e] = !0), r.needCube() && (t["SHADOWCUBE" + e] = !0));
      }, n.prototype.bindShadowLight = function(t, e) {
        var i = this._light;
        if (this._scene.shadowsEnabled && i.shadowEnabled) {
          var r = this._getCamera();
          if (r) {
            var o = this.getShadowMap();
            o && (i.needCube() || e.setMatrix("lightMatrix" + t, this.getTransformMatrix()), this._filter === n.FILTER_PCF ? (e.setDepthStencilTexture("shadowSampler" + t, this.getShadowMapForRendering()), i._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), o.getSize().width, 1 / o.getSize().width, this.frustumEdgeFalloff, t)) : this._filter === n.FILTER_PCSS ? (e.setDepthStencilTexture("shadowSampler" + t, this.getShadowMapForRendering()), e.setTexture("depthSampler" + t, this.getShadowMapForRendering()), i._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / o.getSize().width, this._contactHardeningLightSizeUVRatio * o.getSize().width, this.frustumEdgeFalloff, t)) : (e.setTexture("shadowSampler" + t, this.getShadowMapForRendering()), i._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), this.blurScale / o.getSize().width, this.depthScale, this.frustumEdgeFalloff, t)), i._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(r), this.getLight().getDepthMinZ(r) + this.getLight().getDepthMaxZ(r), t));
          }
        }
      }, Object.defineProperty(n.prototype, "viewMatrix", { get: function() {
        return this._viewMatrix;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "projectionMatrix", { get: function() {
        return this._projectionMatrix;
      }, enumerable: !1, configurable: !0 }), n.prototype.getTransformMatrix = function() {
        var t = this._scene;
        if (this._currentRenderId === t.getRenderId() && this._currentFaceIndexCache === this._currentFaceIndex)
          return this._transformMatrix;
        this._currentRenderId = t.getRenderId(), this._currentFaceIndexCache = this._currentFaceIndex;
        var e = this._light.position;
        if (this._light.computeTransformedInformation() && (e = this._light.transformedPosition), v.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex), this._lightDirection), Math.abs(v.Dot(this._lightDirection, v.Up())) === 1 && (this._lightDirection.z = 1e-13), this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !e.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
          this._cachedPosition.copyFrom(e), this._cachedDirection.copyFrom(this._lightDirection), B.LookAtLHToRef(e, e.add(this._lightDirection), v.Up(), this._viewMatrix);
          var i = this.getShadowMap();
          if (i) {
            var r = i.renderList;
            r && this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, r);
          }
          this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
        }
        return this._transformMatrix;
      }, n.prototype.recreateShadowMap = function() {
        var t = this._shadowMap;
        if (t) {
          var e = t.renderList;
          if (this._disposeRTTandPostProcesses(), this._initializeGenerator(), this.filter = this._filter, this._applyFilterValues(), e) {
            this._shadowMap.renderList || (this._shadowMap.renderList = []);
            for (var i = 0, r = e; i < r.length; i++) {
              var o = r[i];
              this._shadowMap.renderList.push(o);
            }
          } else
            this._shadowMap.renderList = null;
        }
      }, n.prototype._disposeBlurPostProcesses = function() {
        this._shadowMap2 && (this._shadowMap2.dispose(), this._shadowMap2 = null), this._boxBlurPostprocess && (this._boxBlurPostprocess.dispose(), this._boxBlurPostprocess = null), this._kernelBlurXPostprocess && (this._kernelBlurXPostprocess.dispose(), this._kernelBlurXPostprocess = null), this._kernelBlurYPostprocess && (this._kernelBlurYPostprocess.dispose(), this._kernelBlurYPostprocess = null), this._blurPostProcesses = [];
      }, n.prototype._disposeRTTandPostProcesses = function() {
        this._shadowMap && (this._shadowMap.dispose(), this._shadowMap = null), this._disposeBlurPostProcesses();
      }, n.prototype._disposeSceneUBOs = function() {
        if (this._sceneUBOs) {
          for (var t = 0, e = this._sceneUBOs; t < e.length; t++)
            e[t].dispose();
          this._sceneUBOs = [];
        }
      }, n.prototype.dispose = function() {
        var t;
        if (this._disposeRTTandPostProcesses(), this._disposeSceneUBOs(), this._light) {
          if (this._light._shadowGenerators) {
            for (var e = this._light._shadowGenerators.entries(), i = e.next(); i.done !== !0; i = e.next()) {
              var r = (t = i.value)[0];
              t[1] === this && this._light._shadowGenerators.delete(r);
            }
            this._light._shadowGenerators.size === 0 && (this._light._shadowGenerators = null);
          }
          this._light._markMeshesAsLightDirty();
        }
        this.onBeforeShadowMapRenderMeshObservable.clear(), this.onBeforeShadowMapRenderObservable.clear(), this.onAfterShadowMapRenderMeshObservable.clear(), this.onAfterShadowMapRenderObservable.clear();
      }, n.prototype.serialize = function() {
        var t, e = {}, i = this.getShadowMap();
        if (!i)
          return e;
        if (e.className = this.getClassName(), e.lightId = this._light.id, e.cameraId = (t = this._camera) === null || t === void 0 ? void 0 : t.id, e.id = this.id, e.mapSize = i.getRenderSize(), e.forceBackFacesOnly = this.forceBackFacesOnly, e.darkness = this.getDarkness(), e.transparencyShadow = this._transparencyShadow, e.frustumEdgeFalloff = this.frustumEdgeFalloff, e.bias = this.bias, e.normalBias = this.normalBias, e.usePercentageCloserFiltering = this.usePercentageCloserFiltering, e.useContactHardeningShadow = this.useContactHardeningShadow, e.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio, e.filteringQuality = this.filteringQuality, e.useExponentialShadowMap = this.useExponentialShadowMap, e.useBlurExponentialShadowMap = this.useBlurExponentialShadowMap, e.useCloseExponentialShadowMap = this.useBlurExponentialShadowMap, e.useBlurCloseExponentialShadowMap = this.useBlurExponentialShadowMap, e.usePoissonSampling = this.usePoissonSampling, e.depthScale = this.depthScale, e.blurBoxOffset = this.blurBoxOffset, e.blurKernel = this.blurKernel, e.blurScale = this.blurScale, e.useKernelBlur = this.useKernelBlur, e.renderList = [], i.renderList)
          for (var r = 0; r < i.renderList.length; r++) {
            var o = i.renderList[r];
            e.renderList.push(o.id);
          }
        return e;
      }, n.Parse = function(t, e, i) {
        for (var r = e.getLightById(t.lightId), o = t.cameraId !== void 0 ? e.getCameraById(t.cameraId) : null, a = i ? i(t.mapSize, r, o) : new n(t.mapSize, r, void 0, o), s = a.getShadowMap(), l = 0; l < t.renderList.length; l++)
          e.getMeshesById(t.renderList[l]).forEach(function(c) {
            s && (s.renderList || (s.renderList = []), s.renderList.push(c));
          });
        return t.id !== void 0 && (a.id = t.id), a.forceBackFacesOnly = !!t.forceBackFacesOnly, t.darkness !== void 0 && a.setDarkness(t.darkness), t.transparencyShadow && a.setTransparencyShadow(!0), t.frustumEdgeFalloff !== void 0 && (a.frustumEdgeFalloff = t.frustumEdgeFalloff), t.bias !== void 0 && (a.bias = t.bias), t.normalBias !== void 0 && (a.normalBias = t.normalBias), t.usePercentageCloserFiltering ? a.usePercentageCloserFiltering = !0 : t.useContactHardeningShadow ? a.useContactHardeningShadow = !0 : t.usePoissonSampling ? a.usePoissonSampling = !0 : t.useExponentialShadowMap ? a.useExponentialShadowMap = !0 : t.useBlurExponentialShadowMap ? a.useBlurExponentialShadowMap = !0 : t.useCloseExponentialShadowMap ? a.useCloseExponentialShadowMap = !0 : t.useBlurCloseExponentialShadowMap ? a.useBlurCloseExponentialShadowMap = !0 : t.useVarianceShadowMap ? a.useExponentialShadowMap = !0 : t.useBlurVarianceShadowMap && (a.useBlurExponentialShadowMap = !0), t.contactHardeningLightSizeUVRatio !== void 0 && (a.contactHardeningLightSizeUVRatio = t.contactHardeningLightSizeUVRatio), t.filteringQuality !== void 0 && (a.filteringQuality = t.filteringQuality), t.depthScale && (a.depthScale = t.depthScale), t.blurScale && (a.blurScale = t.blurScale), t.blurBoxOffset && (a.blurBoxOffset = t.blurBoxOffset), t.useKernelBlur && (a.useKernelBlur = t.useKernelBlur), t.blurKernel && (a.blurKernel = t.blurKernel), a;
      }, n.CLASSNAME = "ShadowGenerator", n.FILTER_NONE = 0, n.FILTER_EXPONENTIALSHADOWMAP = 1, n.FILTER_POISSONSAMPLING = 2, n.FILTER_BLUREXPONENTIALSHADOWMAP = 3, n.FILTER_CLOSEEXPONENTIALSHADOWMAP = 4, n.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP = 5, n.FILTER_PCF = 6, n.FILTER_PCSS = 7, n.QUALITY_HIGH = 0, n.QUALITY_MEDIUM = 1, n.QUALITY_LOW = 2, n.DEFAULT_ALPHA_CUTOFF = 0.5, n._SceneComponentInitialization = function(t) {
        throw et("ShadowGeneratorSceneComponent");
      }, n;
    }();
    re.ShadersStore.depthPixelShader = `#ifdef ALPHATEST
varying vec2 vUV;uniform sampler2D diffuseSampler;
#endif
#include<clipPlaneFragmentDeclaration>
varying float vDepthMetric;
#ifdef PACKED
#include<packingFunctions>
#endif
#ifdef STORE_CAMERASPACE_Z
varying vec4 vViewPos;
#endif
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void)
{
#include<clipPlaneFragment>
#ifdef ALPHATEST
if (texture2D(diffuseSampler,vUV).a<0.4)
discard;
#endif
#ifdef STORE_CAMERASPACE_Z
#ifdef PACKED
gl_FragColor=pack(vViewPos.z);
#else
gl_FragColor=vec4(vViewPos.z,0.0,0.0,1.0);
#endif
#else
#ifdef NONLINEARDEPTH
#ifdef PACKED
gl_FragColor=pack(gl_FragCoord.z);
#else
gl_FragColor=vec4(gl_FragCoord.z,0.0,0.0,0.0);
#endif
#else
#ifdef PACKED
gl_FragColor=pack(vDepthMetric);
#else
gl_FragColor=vec4(vDepthMetric,0.0,0.0,1.0);
#endif
#endif
#endif
}`, re.IncludesShadersStore.pointCloudVertexDeclaration = `#ifdef POINTSIZE
uniform float pointSize;
#endif
`, re.ShadersStore.depthVertexShader = `attribute vec3 position;
#include<bonesDeclaration>
#include<bakedVertexAnimationDeclaration>
#include<morphTargetsVertexGlobalDeclaration>
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
#include<clipPlaneVertexDeclaration>
#include<instancesDeclaration>
uniform mat4 viewProjection;uniform vec2 depthValues;
#if defined(ALPHATEST) || defined(NEED_UV)
varying vec2 vUV;uniform mat4 diffuseMatrix;
#ifdef UV1
attribute vec2 uv;
#endif
#ifdef UV2
attribute vec2 uv2;
#endif
#endif
#ifdef STORE_CAMERASPACE_Z
uniform mat4 view;varying vec4 vViewPos;
#endif
#include<pointCloudVertexDeclaration>
varying float vDepthMetric;
#define CUSTOM_VERTEX_DEFINITIONS
void main(void)
{vec3 positionUpdated=position;
#ifdef UV1
vec2 uvUpdated=uv;
#endif
#include<morphTargetsVertexGlobal>
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
#include<instancesVertex>
#include<bonesVertex>
#include<bakedVertexAnimation>
vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);
#include<clipPlaneVertex>
gl_Position=viewProjection*worldPos;
#ifdef STORE_CAMERASPACE_Z
vViewPos=view*worldPos;
#else
#ifdef USE_REVERSE_DEPTHBUFFER
vDepthMetric=((-gl_Position.z+depthValues.x)/(depthValues.y));
#else
vDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y));
#endif
#endif
#if defined(ALPHATEST) || defined(BASIC_RENDER)
#ifdef UV1
vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
#endif
#ifdef UV2
vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
#endif
#endif
#include<pointCloudVertex>
}
`;
    var tu = function() {
      function n(t, e, i, r, o, a, s) {
        e === void 0 && (e = _.TEXTURETYPE_FLOAT), i === void 0 && (i = null), r === void 0 && (r = !1), o === void 0 && (o = ae.TRILINEAR_SAMPLINGMODE), a === void 0 && (a = !1);
        var l = this;
        this.enabled = !0, this.forceDepthWriteTransparentMeshes = !1, this.useOnlyInActiveCamera = !1, this.reverseCulling = !1, this._scene = t, this._storeNonLinearDepth = r, this._storeCameraSpaceZ = a, this.isPacked = e === _.TEXTURETYPE_UNSIGNED_BYTE, this.isPacked ? this.clearColor = new Ie(1, 1, 1, 1) : this.clearColor = new Ie(a ? 1e8 : 1, 0, 0, 1), n._SceneComponentInitialization(this._scene);
        var c = t.getEngine();
        this._camera = i, o !== ae.NEAREST_SAMPLINGMODE && (e !== _.TEXTURETYPE_FLOAT || c._caps.textureFloatLinearFiltering || (o = ae.NEAREST_SAMPLINGMODE), e !== _.TEXTURETYPE_HALF_FLOAT || c._caps.textureHalfFloatLinearFiltering || (o = ae.NEAREST_SAMPLINGMODE));
        var u = this.isPacked || !c._features.supportExtendedTextureFormats ? _.TEXTUREFORMAT_RGBA : _.TEXTUREFORMAT_R;
        this._depthMap = new Mi(s ?? "DepthRenderer", { width: c.getRenderWidth(), height: c.getRenderHeight() }, this._scene, !1, !0, e, !1, o, void 0, void 0, void 0, u), this._depthMap.wrapU = ae.CLAMP_ADDRESSMODE, this._depthMap.wrapV = ae.CLAMP_ADDRESSMODE, this._depthMap.refreshRate = 1, this._depthMap.renderParticles = !1, this._depthMap.renderList = null, this._depthMap.noPrePassRenderer = !0, this._depthMap.activeCamera = this._camera, this._depthMap.ignoreCameraViewport = !0, this._depthMap.useCameraPostProcesses = !1, this._depthMap.onClearObservable.add(function(d) {
          d.clear(l.clearColor, !0, !0, !0);
        }), this._depthMap.onBeforeBindObservable.add(function() {
          var d;
          (d = c._debugPushGroup) === null || d === void 0 || d.call(c, "depth renderer", 1);
        }), this._depthMap.onAfterUnbindObservable.add(function() {
          var d;
          (d = c._debugPopGroup) === null || d === void 0 || d.call(c, 1);
        }), this._depthMap.customIsReadyFunction = function(d, p, f) {
          if ((f || p === 0) && d.subMeshes)
            for (var m = 0; m < d.subMeshes.length; ++m) {
              var g = d.subMeshes[m], y = g.getRenderingMesh(), b = y._getInstancesRenderList(g._id, !!g.getReplacementMesh()), T = c.getCaps().instancedArrays && (b.visibleInstances[g._id] !== null && b.visibleInstances[g._id] !== void 0 || y.hasThinInstances);
              if (!l.isReady(g, T))
                return !1;
            }
          return !0;
        };
        var h = function(d) {
          var p, f, m = d.getRenderingMesh(), g = d.getEffectiveMesh(), y = l._scene, b = y.getEngine(), T = d.getMaterial();
          if (g._internalAbstractMeshDataInfo._isActiveIntermediate = !1, T && !g.infiniteDistance && !T.disableDepthWrite && d.verticesCount !== 0 && d._renderId !== y.getRenderId()) {
            var S = g._getWorldMatrixDeterminant() < 0, E = (p = m.overrideMaterialSideOrientation) !== null && p !== void 0 ? p : T.sideOrientation;
            S && (E = E === _.MATERIAL_ClockWiseSideOrientation ? _.MATERIAL_CounterClockWiseSideOrientation : _.MATERIAL_ClockWiseSideOrientation);
            var A = E === _.MATERIAL_ClockWiseSideOrientation;
            b.setState(T.backFaceCulling, 0, !1, A, l.reverseCulling ? !T.cullBackFaces : T.cullBackFaces);
            var R = m._getInstancesRenderList(d._id, !!d.getReplacementMesh());
            if (!R.mustReturn) {
              var C = b.getCaps().instancedArrays && (R.visibleInstances[d._id] !== null && R.visibleInstances[d._id] !== void 0 || m.hasThinInstances), L = l._camera || y.activeCamera;
              if (l.isReady(d, C) && L) {
                d._renderId = y.getRenderId();
                var I = (f = g._internalAbstractMeshDataInfo._materialForRenderPass) === null || f === void 0 ? void 0 : f[b.currentRenderPassId], O = d._getDrawWrapper();
                !O && I && (O = I._getDrawWrapper());
                var w = L.mode === dt.ORTHOGRAPHIC_CAMERA;
                if (!O)
                  return;
                var z = O.effect;
                b.enableEffect(O), C || m._bind(d, z, T.fillMode), I ? I.bindForSubMesh(g.getWorldMatrix(), g, d) : (z.setMatrix("viewProjection", y.getTransformMatrix()), z.setMatrix("world", g.getWorldMatrix()), l._storeCameraSpaceZ && z.setMatrix("view", y.getViewMatrix()));
                var V = void 0, Y = void 0;
                if (w ? (V = !b.useReverseDepthBuffer && b.isNDCHalfZRange ? 0 : 1, Y = b.useReverseDepthBuffer && b.isNDCHalfZRange ? 0 : 1) : (V = b.useReverseDepthBuffer && b.isNDCHalfZRange ? L.minZ : b.isNDCHalfZRange ? 0 : L.minZ, Y = b.useReverseDepthBuffer && b.isNDCHalfZRange ? 0 : L.maxZ), z.setFloat2("depthValues", V, V + Y), !I) {
                  if (T.needAlphaTesting()) {
                    var ee = T.getAlphaTestTexture();
                    ee && (z.setTexture("diffuseSampler", ee), z.setMatrix("diffuseMatrix", ee.getTextureMatrix()));
                  }
                  if (m.useBones && m.computeBonesUsingShaders && m.skeleton) {
                    var J = m.skeleton;
                    if (J.isUsingTextureForMatrices) {
                      var X = J.getTransformMatrixTexture(m);
                      if (!X)
                        return;
                      z.setTexture("boneSampler", X), z.setFloat("boneTextureWidth", 4 * (J.bones.length + 1));
                    } else
                      z.setMatrices("mBones", J.getTransformMatrices(m));
                  }
                  Ar(z, T, y), Se.BindMorphTargetParameters(m, z), m.morphTargetManager && m.morphTargetManager.isUsingTextureForTargets && m.morphTargetManager._bind(z), T.pointsCloud && z.setFloat("pointSize", T.pointSize);
                }
                m._processRendering(g, d, z, T.fillMode, R, C, function(K, te) {
                  return z.setMatrix("world", te);
                });
              }
            }
          }
        };
        this._depthMap.customRenderFunction = function(d, p, f, m) {
          var g;
          if (m.length)
            for (g = 0; g < m.length; g++)
              h(m.data[g]);
          for (g = 0; g < d.length; g++)
            h(d.data[g]);
          for (g = 0; g < p.length; g++)
            h(p.data[g]);
          if (l.forceDepthWriteTransparentMeshes)
            for (g = 0; g < f.length; g++)
              h(f.data[g]);
          else
            for (g = 0; g < f.length; g++)
              f.data[g].getEffectiveMesh()._internalAbstractMeshDataInfo._isActiveIntermediate = !1;
        };
      }
      return n.prototype.setMaterialForRendering = function(t, e) {
        this._depthMap.setMaterialForRendering(t, e);
      }, n.prototype.isReady = function(t, e) {
        var i, r = this._scene.getEngine(), o = t.getMesh(), a = o.getScene(), s = (i = o._internalAbstractMeshDataInfo._materialForRenderPass) === null || i === void 0 ? void 0 : i[r.currentRenderPassId];
        if (s)
          return s.isReadyForSubMesh(o, t, e);
        var l = t.getMaterial();
        if (!l || l.disableDepthWrite)
          return !1;
        var c = [], u = [P.PositionKind];
        if (l && l.needAlphaTesting() && l.getAlphaTestTexture() && (c.push("#define ALPHATEST"), o.isVerticesDataPresent(P.UVKind) && (u.push(P.UVKind), c.push("#define UV1")), o.isVerticesDataPresent(P.UV2Kind) && (u.push(P.UV2Kind), c.push("#define UV2"))), o.useBones && o.computeBonesUsingShaders) {
          u.push(P.MatricesIndicesKind), u.push(P.MatricesWeightsKind), o.numBoneInfluencers > 4 && (u.push(P.MatricesIndicesExtraKind), u.push(P.MatricesWeightsExtraKind)), c.push("#define NUM_BONE_INFLUENCERS " + o.numBoneInfluencers), c.push("#define BonesPerMesh " + (o.skeleton ? o.skeleton.bones.length + 1 : 0));
          var h = t.getRenderingMesh().skeleton;
          h != null && h.isUsingTextureForMatrices && c.push("#define BONETEXTURE");
        } else
          c.push("#define NUM_BONE_INFLUENCERS 0");
        var d = o.morphTargetManager, p = 0;
        d && d.numInfluencers > 0 && (p = d.numInfluencers, c.push("#define MORPHTARGETS"), c.push("#define NUM_MORPH_INFLUENCERS " + p), d.isUsingTextureForTargets && c.push("#define MORPHTARGETS_TEXTURE"), Se.PrepareAttributesForMorphTargetsInfluencers(u, o, p)), l.pointsCloud && c.push("#define POINTSIZE"), e && (c.push("#define INSTANCES"), Se.PushAttributesForInstances(u), t.getRenderingMesh().hasThinInstances && c.push("#define THIN_INSTANCES")), this._storeNonLinearDepth && c.push("#define NONLINEARDEPTH"), this._storeCameraSpaceZ && c.push("#define STORE_CAMERASPACE_Z"), this.isPacked && c.push("#define PACKED"), aa(l, a, c);
        var f = t._getDrawWrapper(void 0, !0), m = f.defines, g = c.join(`
`);
        if (m !== g) {
          var y = ["world", "mBones", "boneTextureWidth", "pointSize", "viewProjection", "view", "diffuseMatrix", "depthValues", "morphTargetInfluences", "morphTargetTextureInfo", "morphTargetTextureIndices"];
          Br(y), f.setEffect(r.createEffect("depth", u, y, ["diffuseSampler", "morphTargets", "boneSampler"], g, void 0, void 0, void 0, { maxSimultaneousMorphTargets: p }), g);
        }
        return f.effect.isReady();
      }, n.prototype.getDepthMap = function() {
        return this._depthMap;
      }, n.prototype.dispose = function() {
        var t = [];
        for (var e in this._scene._depthRenderer)
          this._scene._depthRenderer[e] === this && t.push(e);
        if (t.length > 0) {
          this._depthMap.dispose();
          for (var i = 0, r = t; i < r.length; i++)
            e = r[i], delete this._scene._depthRenderer[e];
        }
      }, n._SceneComponentInitialization = function(t) {
        throw et("DepthRendererSceneComponent");
      }, n;
    }();
    re.ShadersStore.minmaxReduxPixelShader = `varying vec2 vUV;uniform sampler2D textureSampler;
#if defined(INITIAL)
uniform sampler2D sourceTexture;uniform vec2 texSize;void main(void)
{ivec2 coord=ivec2(vUV*(texSize-1.0));float f1=texelFetch(sourceTexture,coord,0).r;float f2=texelFetch(sourceTexture,coord+ivec2(1,0),0).r;float f3=texelFetch(sourceTexture,coord+ivec2(1,1),0).r;float f4=texelFetch(sourceTexture,coord+ivec2(0,1),0).r;float minz=min(min(min(f1,f2),f3),f4);
#ifdef DEPTH_REDUX
float maxz=max(max(max(sign(1.0-f1)*f1,sign(1.0-f2)*f2),sign(1.0-f3)*f3),sign(1.0-f4)*f4);
#else
float maxz=max(max(max(f1,f2),f3),f4);
#endif
glFragColor=vec4(minz,maxz,0.,0.);}
#elif defined(MAIN)
uniform vec2 texSize;void main(void)
{ivec2 coord=ivec2(vUV*(texSize-1.0));vec2 f1=texelFetch(textureSampler,coord,0).rg;vec2 f2=texelFetch(textureSampler,coord+ivec2(1,0),0).rg;vec2 f3=texelFetch(textureSampler,coord+ivec2(1,1),0).rg;vec2 f4=texelFetch(textureSampler,coord+ivec2(0,1),0).rg;float minz=min(min(min(f1.x,f2.x),f3.x),f4.x);float maxz=max(max(max(f1.y,f2.y),f3.y),f4.y);glFragColor=vec4(minz,maxz,0.,0.);}
#elif defined(ONEBEFORELAST)
uniform ivec2 texSize;void main(void)
{ivec2 coord=ivec2(vUV*vec2(texSize-1));vec2 f1=texelFetch(textureSampler,coord % texSize,0).rg;vec2 f2=texelFetch(textureSampler,(coord+ivec2(1,0)) % texSize,0).rg;vec2 f3=texelFetch(textureSampler,(coord+ivec2(1,1)) % texSize,0).rg;vec2 f4=texelFetch(textureSampler,(coord+ivec2(0,1)) % texSize,0).rg;float minz=min(f1.x,f2.x);float maxz=max(f1.y,f2.y);glFragColor=vec4(minz,maxz,0.,0.);}
#elif defined(LAST)
void main(void)
{glFragColor=vec4(0.);if (true) { 
discard;}}
#endif
`;
    var Wy = function() {
      function n(t) {
        var e = this;
        this.onAfterReductionPerformed = new H(), this._forceFullscreenViewport = !0, this._activated = !1, this._camera = t, this._postProcessManager = new nc(t.getScene()), this._onContextRestoredObserver = t.getEngine().onContextRestoredObservable.add(function() {
          e._postProcessManager._rebuild();
        });
      }
      return Object.defineProperty(n.prototype, "sourceTexture", { get: function() {
        return this._sourceTexture;
      }, enumerable: !1, configurable: !0 }), n.prototype.setSourceTexture = function(t, e, i, r) {
        var o = this;
        if (i === void 0 && (i = _.TEXTURETYPE_HALF_FLOAT), r === void 0 && (r = !0), t !== this._sourceTexture) {
          this.dispose(!1), this._sourceTexture = t, this._reductionSteps = [], this._forceFullscreenViewport = r;
          var a = this._camera.getScene(), s = new nt("Initial reduction phase", "minmaxRedux", ["texSize"], ["sourceTexture"], 1, null, _.TEXTURE_NEAREST_NEAREST, a.getEngine(), !1, "#define INITIAL" + (e ? `
#define DEPTH_REDUX` : ""), i, void 0, void 0, void 0, _.TEXTUREFORMAT_RG);
          s.autoClear = !1, s.forceFullscreenViewport = r;
          var l = this._sourceTexture.getRenderWidth(), c = this._sourceTexture.getRenderHeight();
          s.onApply = function(d, p) {
            return function(f) {
              f.setTexture("sourceTexture", o._sourceTexture), f.setFloat2("texSize", d, p);
            };
          }(l, c), this._reductionSteps.push(s);
          for (var u = 1; l > 1 || c > 1; ) {
            l = Math.max(Math.round(l / 2), 1), c = Math.max(Math.round(c / 2), 1);
            var h = new nt("Reduction phase " + u, "minmaxRedux", ["texSize"], null, { width: l, height: c }, null, _.TEXTURE_NEAREST_NEAREST, a.getEngine(), !1, "#define " + (l == 1 && c == 1 ? "LAST" : l == 1 || c == 1 ? "ONEBEFORELAST" : "MAIN"), i, void 0, void 0, void 0, _.TEXTUREFORMAT_RG);
            h.autoClear = !1, h.forceFullscreenViewport = r, h.onApply = function(d, p) {
              return function(f) {
                d == 1 || p == 1 ? f.setInt2("texSize", d, p) : f.setFloat2("texSize", d, p);
              };
            }(l, c), this._reductionSteps.push(h), u++, l == 1 && c == 1 && h.onAfterRenderObservable.add(function(d, p, f) {
              var m = new Float32Array(4 * d * p), g = { min: 0, max: 0 };
              return function() {
                a.getEngine()._readTexturePixels(f.inputTexture.texture, d, p, -1, 0, m, !1), g.min = m[0], g.max = m[1], o.onAfterReductionPerformed.notifyObservers(g);
              };
            }(l, c, h));
          }
        }
      }, Object.defineProperty(n.prototype, "refreshRate", { get: function() {
        return this._sourceTexture ? this._sourceTexture.refreshRate : -1;
      }, set: function(t) {
        this._sourceTexture && (this._sourceTexture.refreshRate = t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "activated", { get: function() {
        return this._activated;
      }, enumerable: !1, configurable: !0 }), n.prototype.activate = function() {
        var t = this;
        !this._onAfterUnbindObserver && this._sourceTexture && (this._onAfterUnbindObserver = this._sourceTexture.onAfterUnbindObservable.add(function() {
          var e, i, r = t._camera.getScene().getEngine();
          (e = r._debugPushGroup) === null || e === void 0 || e.call(r, "min max reduction", 1), t._reductionSteps[0].activate(t._camera), t._postProcessManager.directRender(t._reductionSteps, t._reductionSteps[0].inputTexture, t._forceFullscreenViewport), r.unBindFramebuffer(t._reductionSteps[0].inputTexture, !1), (i = r._debugPopGroup) === null || i === void 0 || i.call(r, 1);
        }), this._activated = !0);
      }, n.prototype.deactivate = function() {
        this._onAfterUnbindObserver && this._sourceTexture && (this._sourceTexture.onAfterUnbindObservable.remove(this._onAfterUnbindObserver), this._onAfterUnbindObserver = null, this._activated = !1);
      }, n.prototype.dispose = function(t) {
        if (t === void 0 && (t = !0), t && (this.onAfterReductionPerformed.clear(), this._onContextRestoredObserver && (this._camera.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver), this._onContextRestoredObserver = null)), this.deactivate(), this._reductionSteps) {
          for (var e = 0; e < this._reductionSteps.length; ++e)
            this._reductionSteps[e].dispose();
          this._reductionSteps = null;
        }
        this._postProcessManager && t && this._postProcessManager.dispose(), this._sourceTexture = null;
      }, n;
    }(), Hy = function(n) {
      function t(e) {
        return n.call(this, e) || this;
      }
      return D(t, n), Object.defineProperty(t.prototype, "depthRenderer", { get: function() {
        return this._depthRenderer;
      }, enumerable: !1, configurable: !0 }), t.prototype.setDepthRenderer = function(e, i, r) {
        e === void 0 && (e = null), i === void 0 && (i = _.TEXTURETYPE_HALF_FLOAT), r === void 0 && (r = !0);
        var o = this._camera.getScene();
        this._depthRenderer && (delete o._depthRenderer[this._depthRendererId], this._depthRenderer.dispose(), this._depthRenderer = null), e === null && (o._depthRenderer || (o._depthRenderer = {}), (e = this._depthRenderer = new tu(o, i, this._camera, !1, _.TEXTURE_NEAREST_SAMPLINGMODE)).enabled = !1, this._depthRendererId = "minmax" + this._camera.id, o._depthRenderer[this._depthRendererId] = e), n.prototype.setSourceTexture.call(this, e.getDepthMap(), !0, i, r);
      }, t.prototype.setSourceTexture = function(e, i, r, o) {
        r === void 0 && (r = _.TEXTURETYPE_HALF_FLOAT), o === void 0 && (o = !0), n.prototype.setSourceTexture.call(this, e, i, r, o);
      }, t.prototype.activate = function() {
        this._depthRenderer && (this._depthRenderer.enabled = !0), n.prototype.activate.call(this);
      }, t.prototype.deactivate = function() {
        n.prototype.deactivate.call(this), this._depthRenderer && (this._depthRenderer.enabled = !1);
      }, t.prototype.dispose = function(e) {
        if (e === void 0 && (e = !0), n.prototype.dispose.call(this, e), this._depthRenderer && e) {
          var i = this._depthRenderer.getDepthMap().getScene();
          i && delete i._depthRenderer[this._depthRendererId], this._depthRenderer.dispose(), this._depthRenderer = null;
        }
      }, t;
    }(Wy), ZC = v.Up(), YD = v.Zero(), sn = new v(), iu = new v(), y_ = new B(), b_ = function(n) {
      function t(e, i, r, o, a) {
        a === void 0 && (a = !0);
        var s = this;
        return t.IsSupported ? ((s = n.call(this, e, i, r, o, a) || this).usePercentageCloserFiltering = !0, s) : (q.Error("CascadedShadowMap is not supported by the current engine."), s);
      }
      return D(t, n), t.prototype._validateFilter = function(e) {
        return e === ar.FILTER_NONE || e === ar.FILTER_PCF || e === ar.FILTER_PCSS ? e : (console.error('Unsupported filter "' + e + '"!'), ar.FILTER_NONE);
      }, Object.defineProperty(t.prototype, "numCascades", { get: function() {
        return this._numCascades;
      }, set: function(e) {
        (e = Math.min(Math.max(e, t.MIN_CASCADES_COUNT), t.MAX_CASCADES_COUNT)) !== this._numCascades && (this._numCascades = e, this.recreateShadowMap(), this._recreateSceneUBOs());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "freezeShadowCastersBoundingInfo", { get: function() {
        return this._freezeShadowCastersBoundingInfo;
      }, set: function(e) {
        var i = this;
        this._freezeShadowCastersBoundingInfoObservable && e && (this._scene.onBeforeRenderObservable.remove(this._freezeShadowCastersBoundingInfoObservable), this._freezeShadowCastersBoundingInfoObservable = null), this._freezeShadowCastersBoundingInfoObservable || e || (this._freezeShadowCastersBoundingInfoObservable = this._scene.onBeforeRenderObservable.add(function() {
          return i._computeShadowCastersBoundingInfo();
        })), this._freezeShadowCastersBoundingInfo = e, e && this._computeShadowCastersBoundingInfo();
      }, enumerable: !1, configurable: !0 }), t.prototype._computeShadowCastersBoundingInfo = function() {
        if (this._scbiMin.copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), this._scbiMax.copyFromFloats(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE), this._shadowMap && this._shadowMap.renderList) {
          for (var e = this._shadowMap.renderList, i = 0; i < e.length; i++)
            if (a = e[i]) {
              var r = a.getBoundingInfo().boundingBox;
              this._scbiMin.minimizeInPlace(r.minimumWorld), this._scbiMax.maximizeInPlace(r.maximumWorld);
            }
          var o = this._scene.meshes;
          for (i = 0; i < o.length; i++) {
            var a;
            (a = o[i]) && a.isVisible && a.isEnabled && a.receiveShadows && (r = a.getBoundingInfo().boundingBox, this._scbiMin.minimizeInPlace(r.minimumWorld), this._scbiMax.maximizeInPlace(r.maximumWorld));
          }
        }
        this._shadowCastersBoundingInfo.reConstruct(this._scbiMin, this._scbiMax);
      }, Object.defineProperty(t.prototype, "shadowCastersBoundingInfo", { get: function() {
        return this._shadowCastersBoundingInfo;
      }, set: function(e) {
        this._shadowCastersBoundingInfo = e;
      }, enumerable: !1, configurable: !0 }), t.prototype.setMinMaxDistance = function(e, i) {
        this._minDistance === e && this._maxDistance === i || (e > i && (e = 0, i = 1), e < 0 && (e = 0), i > 1 && (i = 1), this._minDistance = e, this._maxDistance = i, this._breaksAreDirty = !0);
      }, Object.defineProperty(t.prototype, "minDistance", { get: function() {
        return this._minDistance;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "maxDistance", { get: function() {
        return this._maxDistance;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return t.CLASSNAME;
      }, t.prototype.getCascadeMinExtents = function(e) {
        return e >= 0 && e < this._numCascades ? this._cascadeMinExtents[e] : null;
      }, t.prototype.getCascadeMaxExtents = function(e) {
        return e >= 0 && e < this._numCascades ? this._cascadeMaxExtents[e] : null;
      }, Object.defineProperty(t.prototype, "shadowMaxZ", { get: function() {
        return this._getCamera() ? this._shadowMaxZ : 0;
      }, set: function(e) {
        var i = this._getCamera();
        i ? this._shadowMaxZ === e || e < i.minZ || e > i.maxZ && i.maxZ !== 0 || (this._shadowMaxZ = e, this._light._markMeshesAsLightDirty(), this._breaksAreDirty = !0) : this._shadowMaxZ = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "debug", { get: function() {
        return this._debug;
      }, set: function(e) {
        this._debug = e, this._light._markMeshesAsLightDirty();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "depthClamp", { get: function() {
        return this._depthClamp;
      }, set: function(e) {
        this._depthClamp = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cascadeBlendPercentage", { get: function() {
        return this._cascadeBlendPercentage;
      }, set: function(e) {
        this._cascadeBlendPercentage = e, this._light._markMeshesAsLightDirty();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "lambda", { get: function() {
        return this._lambda;
      }, set: function(e) {
        var i = Math.min(Math.max(e, 0), 1);
        this._lambda != i && (this._lambda = i, this._breaksAreDirty = !0);
      }, enumerable: !1, configurable: !0 }), t.prototype.getCascadeViewMatrix = function(e) {
        return e >= 0 && e < this._numCascades ? this._viewMatrices[e] : null;
      }, t.prototype.getCascadeProjectionMatrix = function(e) {
        return e >= 0 && e < this._numCascades ? this._projectionMatrices[e] : null;
      }, t.prototype.getCascadeTransformMatrix = function(e) {
        return e >= 0 && e < this._numCascades ? this._transformMatrices[e] : null;
      }, t.prototype.setDepthRenderer = function(e) {
        this._depthRenderer = e, this._depthReducer && this._depthReducer.setDepthRenderer(this._depthRenderer);
      }, Object.defineProperty(t.prototype, "autoCalcDepthBounds", { get: function() {
        return this._autoCalcDepthBounds;
      }, set: function(e) {
        var i = this, r = this._getCamera();
        if (r) {
          if (this._autoCalcDepthBounds = e, !e)
            return this._depthReducer && this._depthReducer.deactivate(), void this.setMinMaxDistance(0, 1);
          this._depthReducer || (this._depthReducer = new Hy(r), this._depthReducer.onAfterReductionPerformed.add(function(o) {
            var a = o.min, s = o.max;
            a >= s && (a = 0, s = 1), a == i._minDistance && s == i._maxDistance || i.setMinMaxDistance(a, s);
          }), this._depthReducer.setDepthRenderer(this._depthRenderer)), this._depthReducer.activate();
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "autoCalcDepthBoundsRefreshRate", { get: function() {
        var e, i, r;
        return (r = (i = (e = this._depthReducer) === null || e === void 0 ? void 0 : e.depthRenderer) === null || i === void 0 ? void 0 : i.getDepthMap().refreshRate) !== null && r !== void 0 ? r : -1;
      }, set: function(e) {
        var i;
        !((i = this._depthReducer) === null || i === void 0) && i.depthRenderer && (this._depthReducer.depthRenderer.getDepthMap().refreshRate = e);
      }, enumerable: !1, configurable: !0 }), t.prototype.splitFrustum = function() {
        this._breaksAreDirty = !0;
      }, t.prototype._splitFrustum = function() {
        var e = this._getCamera();
        if (e) {
          for (var i = e.minZ, r = e.maxZ || this._shadowMaxZ, o = r - i, a = this._minDistance, s = i + a * o, l = i + (this._shadowMaxZ < r && this._shadowMaxZ >= i ? Math.min((this._shadowMaxZ - i) / (r - i), this._maxDistance) : this._maxDistance) * o, c = l - s, u = l / s, h = 0; h < this._cascades.length; ++h) {
            var d = (h + 1) / this._numCascades, p = s * Math.pow(u, d), f = s + c * d, m = this._lambda * (p - f) + f;
            this._cascades[h].prevBreakDistance = h === 0 ? a : this._cascades[h - 1].breakDistance, this._cascades[h].breakDistance = (m - i) / o, this._viewSpaceFrustumsZ[h] = m, this._frustumLengths[h] = (this._cascades[h].breakDistance - this._cascades[h].prevBreakDistance) * o;
          }
          this._breaksAreDirty = !1;
        }
      }, t.prototype._computeMatrices = function() {
        var e = this._scene;
        if (this._getCamera()) {
          v.NormalizeToRef(this._light.getShadowDirection(0), this._lightDirection), Math.abs(v.Dot(this._lightDirection, v.Up())) === 1 && (this._lightDirection.z = 1e-13), this._cachedDirection.copyFrom(this._lightDirection);
          for (var i = e.getEngine().useReverseDepthBuffer, r = 0; r < this._numCascades; ++r) {
            this._computeFrustumInWorldSpace(r), this._computeCascadeFrustum(r), this._cascadeMaxExtents[r].subtractToRef(this._cascadeMinExtents[r], sn), this._frustumCenter[r].addToRef(this._lightDirection.scale(this._cascadeMinExtents[r].z), this._shadowCameraPos[r]), B.LookAtLHToRef(this._shadowCameraPos[r], this._frustumCenter[r], ZC, this._viewMatrices[r]);
            var o = 0, a = sn.z, s = this._shadowCastersBoundingInfo;
            s.update(this._viewMatrices[r]), a = Math.min(a, s.boundingBox.maximumWorld.z), o = this._depthClamp && this.filter !== ar.FILTER_PCSS ? Math.max(o, s.boundingBox.minimumWorld.z) : Math.min(o, s.boundingBox.minimumWorld.z), B.OrthoOffCenterLHToRef(this._cascadeMinExtents[r].x, this._cascadeMaxExtents[r].x, this._cascadeMinExtents[r].y, this._cascadeMaxExtents[r].y, i ? a : o, i ? o : a, this._projectionMatrices[r], e.getEngine().isNDCHalfZRange), this._cascadeMinExtents[r].z = o, this._cascadeMaxExtents[r].z = a, this._viewMatrices[r].multiplyToRef(this._projectionMatrices[r], this._transformMatrices[r]), v.TransformCoordinatesToRef(YD, this._transformMatrices[r], sn), sn.scaleInPlace(this._mapSize / 2), iu.copyFromFloats(Math.round(sn.x), Math.round(sn.y), Math.round(sn.z)), iu.subtractInPlace(sn).scaleInPlace(2 / this._mapSize), B.TranslationToRef(iu.x, iu.y, 0, y_), this._projectionMatrices[r].multiplyToRef(y_, this._projectionMatrices[r]), this._viewMatrices[r].multiplyToRef(this._projectionMatrices[r], this._transformMatrices[r]), this._transformMatrices[r].copyToArray(this._transformMatricesAsArray, 16 * r);
          }
        }
      }, t.prototype._computeFrustumInWorldSpace = function(e) {
        var i = this._getCamera();
        if (i) {
          var r = this._cascades[e].prevBreakDistance, o = this._cascades[e].breakDistance, a = this._scene.getEngine().isNDCHalfZRange;
          i.getViewMatrix();
          var s = i.maxZ === 0, l = i.maxZ;
          s && (i.maxZ = this._shadowMaxZ, i.getProjectionMatrix(!0));
          var c = B.Invert(i.getTransformationMatrix());
          s && (i.maxZ = l, i.getProjectionMatrix(!0));
          for (var u = this._scene.getEngine().useReverseDepthBuffer ? 4 : 0, h = 0; h < t._FrustumCornersNDCSpace.length; ++h)
            sn.copyFrom(t._FrustumCornersNDCSpace[(h + u) % t._FrustumCornersNDCSpace.length]), a && sn.z === -1 && (sn.z = 0), v.TransformCoordinatesToRef(sn, c, this._frustumCornersWorldSpace[e][h]);
          for (h = 0; h < t._FrustumCornersNDCSpace.length / 2; ++h)
            sn.copyFrom(this._frustumCornersWorldSpace[e][h + 4]).subtractInPlace(this._frustumCornersWorldSpace[e][h]), iu.copyFrom(sn).scaleInPlace(r), sn.scaleInPlace(o), sn.addInPlace(this._frustumCornersWorldSpace[e][h]), this._frustumCornersWorldSpace[e][h + 4].copyFrom(sn), this._frustumCornersWorldSpace[e][h].addInPlace(iu);
        }
      }, t.prototype._computeCascadeFrustum = function(e) {
        if (this._cascadeMinExtents[e].copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), this._cascadeMaxExtents[e].copyFromFloats(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE), this._frustumCenter[e].copyFromFloats(0, 0, 0), this._getCamera()) {
          for (var i = 0; i < this._frustumCornersWorldSpace[e].length; ++i)
            this._frustumCenter[e].addInPlace(this._frustumCornersWorldSpace[e][i]);
          if (this._frustumCenter[e].scaleInPlace(1 / this._frustumCornersWorldSpace[e].length), this.stabilizeCascades) {
            var r = 0;
            for (i = 0; i < this._frustumCornersWorldSpace[e].length; ++i) {
              var o = this._frustumCornersWorldSpace[e][i].subtractToRef(this._frustumCenter[e], sn).length();
              r = Math.max(r, o);
            }
            r = Math.ceil(16 * r) / 16, this._cascadeMaxExtents[e].copyFromFloats(r, r, r), this._cascadeMinExtents[e].copyFromFloats(-r, -r, -r);
          } else {
            var a = this._frustumCenter[e];
            for (this._frustumCenter[e].addToRef(this._lightDirection, sn), B.LookAtLHToRef(a, sn, ZC, y_), i = 0; i < this._frustumCornersWorldSpace[e].length; ++i)
              v.TransformCoordinatesToRef(this._frustumCornersWorldSpace[e][i], y_, sn), this._cascadeMinExtents[e].minimizeInPlace(sn), this._cascadeMaxExtents[e].maximizeInPlace(sn);
          }
        }
      }, t.prototype._recreateSceneUBOs = function() {
        if (this._disposeSceneUBOs(), this._sceneUBOs)
          for (var e = 0; e < this._numCascades; ++e)
            this._sceneUBOs.push(this._scene.createSceneUniformBuffer('Scene for CSM Shadow Generator (light "'.concat(this._light.name, '" cascade #').concat(e, ")")));
      }, Object.defineProperty(t, "IsSupported", { get: function() {
        var e = Me.LastCreatedEngine;
        return !!e && e._features.supportCSM;
      }, enumerable: !1, configurable: !0 }), t.prototype._initializeGenerator = function() {
        var e, i, r, o, a, s, l, c, u, h, d, p, f, m, g, y, b, T, S, E;
        this.penumbraDarkness = (e = this.penumbraDarkness) !== null && e !== void 0 ? e : 1, this._numCascades = (i = this._numCascades) !== null && i !== void 0 ? i : t.DEFAULT_CASCADES_COUNT, this.stabilizeCascades = (r = this.stabilizeCascades) !== null && r !== void 0 && r, this._freezeShadowCastersBoundingInfoObservable = (o = this._freezeShadowCastersBoundingInfoObservable) !== null && o !== void 0 ? o : null, this.freezeShadowCastersBoundingInfo = (a = this.freezeShadowCastersBoundingInfo) !== null && a !== void 0 && a, this._scbiMin = (s = this._scbiMin) !== null && s !== void 0 ? s : new v(0, 0, 0), this._scbiMax = (l = this._scbiMax) !== null && l !== void 0 ? l : new v(0, 0, 0), this._shadowCastersBoundingInfo = (c = this._shadowCastersBoundingInfo) !== null && c !== void 0 ? c : new wr(new v(0, 0, 0), new v(0, 0, 0)), this._breaksAreDirty = (u = this._breaksAreDirty) === null || u === void 0 || u, this._minDistance = (h = this._minDistance) !== null && h !== void 0 ? h : 0, this._maxDistance = (d = this._maxDistance) !== null && d !== void 0 ? d : 1, this._currentLayer = (p = this._currentLayer) !== null && p !== void 0 ? p : 0, this._shadowMaxZ = (g = (f = this._shadowMaxZ) !== null && f !== void 0 ? f : (m = this._getCamera()) === null || m === void 0 ? void 0 : m.maxZ) !== null && g !== void 0 ? g : 1e4, this._debug = (y = this._debug) !== null && y !== void 0 && y, this._depthClamp = (b = this._depthClamp) === null || b === void 0 || b, this._cascadeBlendPercentage = (T = this._cascadeBlendPercentage) !== null && T !== void 0 ? T : 0.1, this._lambda = (S = this._lambda) !== null && S !== void 0 ? S : 0.5, this._autoCalcDepthBounds = (E = this._autoCalcDepthBounds) !== null && E !== void 0 && E, this._recreateSceneUBOs(), n.prototype._initializeGenerator.call(this);
      }, t.prototype._createTargetRenderTexture = function() {
        var e = this._scene.getEngine(), i = { width: this._mapSize, height: this._mapSize, layers: this.numCascades };
        this._shadowMap = new Mi(this._light.name + "_CSMShadowMap", i, this._scene, !1, !0, this._textureType, !1, void 0, !1, !1, void 0, this._useRedTextureType ? _.TEXTUREFORMAT_RED : _.TEXTUREFORMAT_RGBA), this._shadowMap.createDepthStencilTexture(e.useReverseDepthBuffer ? _.GREATER : _.LESS, !0), this._shadowMap.noPrePassRenderer = !0;
      }, t.prototype._initializeShadowMap = function() {
        var e = this;
        if (n.prototype._initializeShadowMap.call(this), this._shadowMap !== null) {
          this._transformMatricesAsArray = new Float32Array(16 * this._numCascades), this._viewSpaceFrustumsZ = new Array(this._numCascades), this._frustumLengths = new Array(this._numCascades), this._lightSizeUVCorrection = new Array(2 * this._numCascades), this._depthCorrection = new Array(this._numCascades), this._cascades = [], this._viewMatrices = [], this._projectionMatrices = [], this._transformMatrices = [], this._cascadeMinExtents = [], this._cascadeMaxExtents = [], this._frustumCenter = [], this._shadowCameraPos = [], this._frustumCornersWorldSpace = [];
          for (var i = 0; i < this._numCascades; ++i) {
            this._cascades[i] = { prevBreakDistance: 0, breakDistance: 0 }, this._viewMatrices[i] = B.Zero(), this._projectionMatrices[i] = B.Zero(), this._transformMatrices[i] = B.Zero(), this._cascadeMinExtents[i] = new v(), this._cascadeMaxExtents[i] = new v(), this._frustumCenter[i] = new v(), this._shadowCameraPos[i] = new v(), this._frustumCornersWorldSpace[i] = new Array(t._FrustumCornersNDCSpace.length);
            for (var r = 0; r < t._FrustumCornersNDCSpace.length; ++r)
              this._frustumCornersWorldSpace[i][r] = new v();
          }
          var o = this._scene.getEngine();
          this._shadowMap.onBeforeBindObservable.clear(), this._shadowMap.onBeforeRenderObservable.clear(), this._shadowMap.onBeforeRenderObservable.add(function(a) {
            e._sceneUBOs && e._scene.setSceneUniformBuffer(e._sceneUBOs[a]), e._currentLayer = a, e._filter === ar.FILTER_PCF && o.setColorWrite(!1), e._scene.setTransformMatrix(e.getCascadeViewMatrix(a), e.getCascadeProjectionMatrix(a)), e._useUBO && (e._scene.getSceneUniformBuffer().unbindEffect(), e._scene.finalizeSceneUbo());
          }), this._shadowMap.onBeforeBindObservable.add(function() {
            var a;
            e._currentSceneUBO = e._scene.getSceneUniformBuffer(), (a = o._debugPushGroup) === null || a === void 0 || a.call(o, "cascaded shadow map generation for pass id ".concat(o.currentRenderPassId), 1), e._breaksAreDirty && e._splitFrustum(), e._computeMatrices();
          }), this._splitFrustum();
        }
      }, t.prototype._bindCustomEffectForRenderSubMeshForShadowMap = function(e, i) {
        i.setMatrix("viewProjection", this.getCascadeTransformMatrix(this._currentLayer));
      }, t.prototype._isReadyCustomDefines = function(e) {
        e.push("#define SM_DEPTHCLAMP " + (this._depthClamp && this._filter !== ar.FILTER_PCSS ? "1" : "0"));
      }, t.prototype.prepareDefines = function(e, i) {
        n.prototype.prepareDefines.call(this, e, i);
        var r = this._scene, o = this._light;
        if (r.shadowsEnabled && o.shadowEnabled) {
          e["SHADOWCSM" + i] = !0, e["SHADOWCSMDEBUG" + i] = this.debug, e["SHADOWCSMNUM_CASCADES" + i] = this.numCascades, e["SHADOWCSM_RIGHTHANDED" + i] = r.useRightHandedSystem;
          var a = this._getCamera();
          a && this._shadowMaxZ <= (a.maxZ || this._shadowMaxZ) && (e["SHADOWCSMUSESHADOWMAXZ" + i] = !0), this.cascadeBlendPercentage === 0 && (e["SHADOWCSMNOBLEND" + i] = !0);
        }
      }, t.prototype.bindShadowLight = function(e, i) {
        var r = this._light;
        if (this._scene.shadowsEnabled && r.shadowEnabled) {
          var o = this._getCamera();
          if (o) {
            var a = this.getShadowMap();
            if (a) {
              var s = a.getSize().width;
              if (i.setMatrices("lightMatrix" + e, this._transformMatricesAsArray), i.setArray("viewFrustumZ" + e, this._viewSpaceFrustumsZ), i.setFloat("cascadeBlendFactor" + e, this.cascadeBlendPercentage === 0 ? 1e4 : 1 / this.cascadeBlendPercentage), i.setArray("frustumLengths" + e, this._frustumLengths), this._filter === ar.FILTER_PCF)
                i.setDepthStencilTexture("shadowSampler" + e, a), r._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), s, 1 / s, this.frustumEdgeFalloff, e);
              else if (this._filter === ar.FILTER_PCSS) {
                for (var l = 0; l < this._numCascades; ++l)
                  this._lightSizeUVCorrection[2 * l + 0] = l === 0 ? 1 : (this._cascadeMaxExtents[0].x - this._cascadeMinExtents[0].x) / (this._cascadeMaxExtents[l].x - this._cascadeMinExtents[l].x), this._lightSizeUVCorrection[2 * l + 1] = l === 0 ? 1 : (this._cascadeMaxExtents[0].y - this._cascadeMinExtents[0].y) / (this._cascadeMaxExtents[l].y - this._cascadeMinExtents[l].y), this._depthCorrection[l] = l === 0 ? 1 : (this._cascadeMaxExtents[l].z - this._cascadeMinExtents[l].z) / (this._cascadeMaxExtents[0].z - this._cascadeMinExtents[0].z);
                i.setDepthStencilTexture("shadowSampler" + e, a), i.setTexture("depthSampler" + e, a), i.setArray2("lightSizeUVCorrection" + e, this._lightSizeUVCorrection), i.setArray("depthCorrection" + e, this._depthCorrection), i.setFloat("penumbraDarkness" + e, this.penumbraDarkness), r._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / s, this._contactHardeningLightSizeUVRatio * s, this.frustumEdgeFalloff, e);
              } else
                i.setTexture("shadowSampler" + e, a), r._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), s, 1 / s, this.frustumEdgeFalloff, e);
              r._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(o), this.getLight().getDepthMinZ(o) + this.getLight().getDepthMaxZ(o), e);
            }
          }
        }
      }, t.prototype.getTransformMatrix = function() {
        return this.getCascadeTransformMatrix(0);
      }, t.prototype.dispose = function() {
        n.prototype.dispose.call(this), this._freezeShadowCastersBoundingInfoObservable && (this._scene.onBeforeRenderObservable.remove(this._freezeShadowCastersBoundingInfoObservable), this._freezeShadowCastersBoundingInfoObservable = null), this._depthReducer && (this._depthReducer.dispose(), this._depthReducer = null);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this), i = this.getShadowMap();
        if (!i)
          return e;
        if (e.numCascades = this._numCascades, e.debug = this._debug, e.stabilizeCascades = this.stabilizeCascades, e.lambda = this._lambda, e.cascadeBlendPercentage = this.cascadeBlendPercentage, e.depthClamp = this._depthClamp, e.autoCalcDepthBounds = this.autoCalcDepthBounds, e.shadowMaxZ = this._shadowMaxZ, e.penumbraDarkness = this.penumbraDarkness, e.freezeShadowCastersBoundingInfo = this._freezeShadowCastersBoundingInfo, e.minDistance = this.minDistance, e.maxDistance = this.maxDistance, e.renderList = [], i.renderList)
          for (var r = 0; r < i.renderList.length; r++) {
            var o = i.renderList[r];
            e.renderList.push(o.id);
          }
        return e;
      }, t.Parse = function(e, i) {
        var r = ar.Parse(e, i, function(o, a, s) {
          return new t(o, a, void 0, s);
        });
        return e.numCascades !== void 0 && (r.numCascades = e.numCascades), e.debug !== void 0 && (r.debug = e.debug), e.stabilizeCascades !== void 0 && (r.stabilizeCascades = e.stabilizeCascades), e.lambda !== void 0 && (r.lambda = e.lambda), e.cascadeBlendPercentage !== void 0 && (r.cascadeBlendPercentage = e.cascadeBlendPercentage), e.depthClamp !== void 0 && (r.depthClamp = e.depthClamp), e.autoCalcDepthBounds !== void 0 && (r.autoCalcDepthBounds = e.autoCalcDepthBounds), e.shadowMaxZ !== void 0 && (r.shadowMaxZ = e.shadowMaxZ), e.penumbraDarkness !== void 0 && (r.penumbraDarkness = e.penumbraDarkness), e.freezeShadowCastersBoundingInfo !== void 0 && (r.freezeShadowCastersBoundingInfo = e.freezeShadowCastersBoundingInfo), e.minDistance !== void 0 && e.maxDistance !== void 0 && r.setMinMaxDistance(e.minDistance, e.maxDistance), r;
      }, t._FrustumCornersNDCSpace = [new v(-1, 1, -1), new v(1, 1, -1), new v(1, -1, -1), new v(-1, -1, -1), new v(-1, 1, 1), new v(1, 1, 1), new v(1, -1, 1), new v(-1, -1, 1)], t.CLASSNAME = "CascadedShadowGenerator", t.DEFAULT_CASCADES_COUNT = 4, t.MIN_CASCADES_COUNT = 2, t.MAX_CASCADES_COUNT = 4, t._SceneComponentInitialization = function(e) {
        throw et("ShadowGeneratorSceneComponent");
      }, t;
    }(ar);
    pe.AddParser(we.NAME_SHADOWGENERATOR, function(n, t) {
      if (n.shadowGenerators !== void 0 && n.shadowGenerators !== null)
        for (var e = 0, i = n.shadowGenerators.length; e < i; e++) {
          var r = n.shadowGenerators[e];
          r.className === b_.CLASSNAME ? b_.Parse(r, t) : ar.Parse(r, t);
        }
    });
    var Xy = function() {
      function n(t) {
        this.name = we.NAME_SHADOWGENERATOR, this.scene = t;
      }
      return n.prototype.register = function() {
        this.scene._gatherRenderTargetsStage.registerStep(we.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR, this, this._gatherRenderTargets);
      }, n.prototype.rebuild = function() {
      }, n.prototype.serialize = function(t) {
        t.shadowGenerators = [];
        for (var e = 0, i = this.scene.lights; e < i.length; e++) {
          var r = i[e].getShadowGenerators();
          if (r)
            for (var o = r.values(), a = o.next(); a.done !== !0; a = o.next()) {
              var s = a.value;
              t.shadowGenerators.push(s.serialize());
            }
        }
      }, n.prototype.addFromContainer = function(t) {
      }, n.prototype.removeFromContainer = function(t, e) {
      }, n.prototype.dispose = function() {
      }, n.prototype._gatherRenderTargets = function(t) {
        var e = this.scene;
        if (this.scene.shadowsEnabled)
          for (var i = 0; i < e.lights.length; i++) {
            var r = e.lights[i], o = r.getShadowGenerators();
            if (r.isEnabled() && r.shadowEnabled && o)
              for (var a = o.values(), s = a.next(); s.done !== !0; s = a.next()) {
                var l = s.value.getShadowMap();
                e.textures.indexOf(l) !== -1 && t.push(l);
              }
          }
      }, n;
    }();
    ar._SceneComponentInitialization = function(n) {
      var t = n._getComponent(we.NAME_SHADOWGENERATOR);
      t || (t = new Xy(n), n._addComponent(t));
    }, oi.AddNodeConstructor("Light_Type_0", function(n, t) {
      return function() {
        return new T_(n, v.Zero(), t);
      };
    });
    var T_ = function(n) {
      function t(e, i, r) {
        var o = n.call(this, e, r) || this;
        return o._shadowAngle = Math.PI / 2, o.position = i, o;
      }
      return D(t, n), Object.defineProperty(t.prototype, "shadowAngle", { get: function() {
        return this._shadowAngle;
      }, set: function(e) {
        this._shadowAngle = e, this.forceProjectionMatrixCompute();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "direction", { get: function() {
        return this._direction;
      }, set: function(e) {
        var i = this.needCube();
        if (this._direction = e, this.needCube() !== i && this._shadowGenerators)
          for (var r = this._shadowGenerators.values(), o = r.next(); o.done !== !0; o = r.next())
            o.value.recreateShadowMap();
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "PointLight";
      }, t.prototype.getTypeID = function() {
        return Kn.LIGHTTYPEID_POINTLIGHT;
      }, t.prototype.needCube = function() {
        return !this.direction;
      }, t.prototype.getShadowDirection = function(e) {
        if (this.direction)
          return n.prototype.getShadowDirection.call(this, e);
        switch (e) {
          case 0:
            return new v(1, 0, 0);
          case 1:
            return new v(-1, 0, 0);
          case 2:
            return new v(0, -1, 0);
          case 3:
            return new v(0, 1, 0);
          case 4:
            return new v(0, 0, 1);
          case 5:
            return new v(0, 0, -1);
        }
        return v.Zero();
      }, t.prototype._setDefaultShadowProjectionMatrix = function(e, i, r) {
        var o = this.getScene().activeCamera;
        if (o) {
          var a = this.shadowMinZ !== void 0 ? this.shadowMinZ : o.minZ, s = this.shadowMaxZ !== void 0 ? this.shadowMaxZ : o.maxZ, l = this.getScene().getEngine().useReverseDepthBuffer;
          B.PerspectiveFovLHToRef(this.shadowAngle, 1, l ? s : a, l ? a : s, e, !0, this._scene.getEngine().isNDCHalfZRange, void 0, l);
        }
      }, t.prototype._buildUniformLayout = function() {
        this._uniformBuffer.addUniform("vLightData", 4), this._uniformBuffer.addUniform("vLightDiffuse", 4), this._uniformBuffer.addUniform("vLightSpecular", 4), this._uniformBuffer.addUniform("vLightFalloff", 4), this._uniformBuffer.addUniform("shadowsInfo", 3), this._uniformBuffer.addUniform("depthValues", 2), this._uniformBuffer.create();
      }, t.prototype.transferToEffect = function(e, i) {
        return this.computeTransformedInformation() ? this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, 0, i) : this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, 0, i), this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, 0, 0, i), this;
      }, t.prototype.transferToNodeMaterialEffect = function(e, i) {
        return this.computeTransformedInformation() ? e.setFloat3(i, this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z) : e.setFloat3(i, this.position.x, this.position.y, this.position.z), this;
      }, t.prototype.prepareLightSpecificDefines = function(e, i) {
        e["POINTLIGHT" + i] = !0;
      }, x([N()], t.prototype, "shadowAngle", null), t;
    }(Xh), jy = function() {
      function n(t, e, i) {
        e === void 0 && (e = ""), i === void 0 && (i = "black");
        var r = this;
        this._renderingCanvas = t, this._loadingText = e, this._loadingDivBackgroundColor = i, this._resizeLoadingUI = function() {
          var o = r._renderingCanvas.getBoundingClientRect(), a = window.getComputedStyle(r._renderingCanvas).position;
          r._loadingDiv && (r._loadingDiv.style.position = a === "fixed" ? "fixed" : "absolute", r._loadingDiv.style.left = o.left + "px", r._loadingDiv.style.top = o.top + "px", r._loadingDiv.style.width = o.width + "px", r._loadingDiv.style.height = o.height + "px");
        };
      }
      return n.prototype.displayLoadingUI = function() {
        if (!this._loadingDiv) {
          this._loadingDiv = document.createElement("div"), this._loadingDiv.id = "babylonjsLoadingDiv", this._loadingDiv.style.opacity = "0", this._loadingDiv.style.transition = "opacity 1.5s ease", this._loadingDiv.style.pointerEvents = "none", this._loadingDiv.style.display = "grid", this._loadingDiv.style.gridTemplateRows = "100%", this._loadingDiv.style.gridTemplateColumns = "100%", this._loadingDiv.style.justifyItems = "center", this._loadingDiv.style.alignItems = "center", this._loadingTextDiv = document.createElement("div"), this._loadingTextDiv.style.position = "absolute", this._loadingTextDiv.style.left = "0", this._loadingTextDiv.style.top = "50%", this._loadingTextDiv.style.marginTop = "80px", this._loadingTextDiv.style.width = "100%", this._loadingTextDiv.style.height = "20px", this._loadingTextDiv.style.fontFamily = "Arial", this._loadingTextDiv.style.fontSize = "14px", this._loadingTextDiv.style.color = "white", this._loadingTextDiv.style.textAlign = "center", this._loadingTextDiv.style.zIndex = "1", this._loadingTextDiv.innerHTML = "Loading", this._loadingDiv.appendChild(this._loadingTextDiv), this._loadingTextDiv.innerHTML = this._loadingText, this._style = document.createElement("style"), this._style.type = "text/css", this._style.innerHTML = `@-webkit-keyframes spin1 {                    0% { -webkit-transform: rotate(0deg);}
                    100% { -webkit-transform: rotate(360deg);}
                }                @keyframes spin1 {                    0% { transform: rotate(0deg);}
                    100% { transform: rotate(360deg);}
                }`, document.getElementsByTagName("head")[0].appendChild(this._style);
          var t = !!window.SVGSVGElement, e = new Image();
          n.DefaultLogoUrl ? e.src = n.DefaultLogoUrl : e.src = t ? "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxODAuMTcgMjA4LjA0Ij48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2ZmZjt9LmNscy0ye2ZpbGw6I2UwNjg0Yjt9LmNscy0ze2ZpbGw6I2JiNDY0Yjt9LmNscy00e2ZpbGw6I2UwZGVkODt9LmNscy01e2ZpbGw6I2Q1ZDJjYTt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPkJhYnlsb25Mb2dvPC90aXRsZT48ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj48ZyBpZD0iUGFnZV9FbGVtZW50cyIgZGF0YS1uYW1lPSJQYWdlIEVsZW1lbnRzIj48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik05MC4wOSwwLDAsNTJWMTU2bDkwLjA5LDUyLDkwLjA4LTUyVjUyWiIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtMiIgcG9pbnRzPSIxODAuMTcgNTIuMDEgMTUxLjk3IDM1LjczIDEyNC44NSA1MS4zOSAxNTMuMDUgNjcuNjcgMTgwLjE3IDUyLjAxIi8+PHBvbHlnb24gY2xhc3M9ImNscy0yIiBwb2ludHM9IjI3LjEyIDY3LjY3IDExNy4yMSAxNS42NiA5MC4wOCAwIDAgNTIuMDEgMjcuMTIgNjcuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTIiIHBvaW50cz0iNjEuODkgMTIwLjMgOTAuMDggMTM2LjU4IDExOC4yOCAxMjAuMyA5MC4wOCAxMDQuMDIgNjEuODkgMTIwLjMiLz48cG9seWdvbiBjbGFzcz0iY2xzLTMiIHBvaW50cz0iMTUzLjA1IDY3LjY3IDE1My4wNSAxNDAuMzcgOTAuMDggMTc2LjcyIDI3LjEyIDE0MC4zNyAyNy4xMiA2Ny42NyAwIDUyLjAxIDAgMTU2LjAzIDkwLjA4IDIwOC4wNCAxODAuMTcgMTU2LjAzIDE4MC4xNyA1Mi4wMSAxNTMuMDUgNjcuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTMiIHBvaW50cz0iOTAuMDggNzEuNDYgNjEuODkgODcuNzQgNjEuODkgMTIwLjMgOTAuMDggMTA0LjAyIDExOC4yOCAxMjAuMyAxMTguMjggODcuNzQgOTAuMDggNzEuNDYiLz48cG9seWdvbiBjbGFzcz0iY2xzLTQiIHBvaW50cz0iMTUzLjA1IDY3LjY3IDExOC4yOCA4Ny43NCAxMTguMjggMTIwLjMgOTAuMDggMTM2LjU4IDkwLjA4IDE3Ni43MiAxNTMuMDUgMTQwLjM3IDE1My4wNSA2Ny42NyIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtNSIgcG9pbnRzPSIyNy4xMiA2Ny42NyA2MS44OSA4Ny43NCA2MS44OSAxMjAuMyA5MC4wOCAxMzYuNTggOTAuMDggMTc2LjcyIDI3LjEyIDE0MC4zNyAyNy4xMiA2Ny42NyIvPjwvZz48L2c+PC9zdmc+" : "https://cdn.babylonjs.com/Assets/babylonLogo.png", e.style.width = "150px", e.style.gridColumn = "1", e.style.gridRow = "1", e.style.top = "50%", e.style.left = "50%", e.style.transform = "translate(-50%, -50%)", e.style.position = "absolute";
          var i = document.createElement("div");
          i.style.width = "300px", i.style.gridColumn = "1", i.style.gridRow = "1", i.style.top = "50%", i.style.left = "50%", i.style.transform = "translate(-50%, -50%)", i.style.position = "absolute";
          var r = new Image();
          if (n.DefaultSpinnerUrl ? r.src = n.DefaultSpinnerUrl : r.src = t ? "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzOTIgMzkyIj48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2UwNjg0Yjt9LmNscy0ye2ZpbGw6bm9uZTt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPlNwaW5uZXJJY29uPC90aXRsZT48ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj48ZyBpZD0iU3Bpbm5lciI+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJNNDAuMjEsMTI2LjQzYzMuNy03LjMxLDcuNjctMTQuNDQsMTItMjEuMzJsMy4zNi01LjEsMy41Mi01YzEuMjMtMS42MywyLjQxLTMuMjksMy42NS00LjkxczIuNTMtMy4yMSwzLjgyLTQuNzlBMTg1LjIsMTg1LjIsMCwwLDEsODMuNCw2Ny40M2EyMDgsMjA4LDAsMCwxLDE5LTE1LjY2YzMuMzUtMi40MSw2Ljc0LTQuNzgsMTAuMjUtN3M3LjExLTQuMjgsMTAuNzUtNi4zMmM3LjI5LTQsMTQuNzMtOCwyMi41My0xMS40OSwzLjktMS43Miw3Ljg4LTMuMywxMi00LjY0YTEwNC4yMiwxMDQuMjIsMCwwLDEsMTIuNDQtMy4yMyw2Mi40NCw2Mi40NCwwLDAsMSwxMi43OC0xLjM5QTI1LjkyLDI1LjkyLDAsMCwxLDE5NiwyMS40NGE2LjU1LDYuNTUsMCwwLDEsMi4wNSw5LDYuNjYsNi42NiwwLDAsMS0xLjY0LDEuNzhsLS40MS4yOWEyMi4wNywyMi4wNywwLDAsMS01Ljc4LDMsMzAuNDIsMzAuNDIsMCwwLDEtNS42NywxLjYyLDM3LjgyLDM3LjgyLDAsMCwxLTUuNjkuNzFjLTEsMC0xLjkuMTgtMi44NS4yNmwtMi44NS4yNHEtNS43Mi41MS0xMS40OCwxLjFjLTMuODQuNC03LjcxLjgyLTExLjU4LDEuNGExMTIuMzQsMTEyLjM0LDAsMCwwLTIyLjk0LDUuNjFjLTMuNzIsMS4zNS03LjM0LDMtMTAuOTQsNC42NHMtNy4xNCwzLjUxLTEwLjYsNS41MUExNTEuNiwxNTEuNiwwLDAsMCw2OC41Niw4N0M2Ny4yMyw4OC40OCw2Niw5MCw2NC42NCw5MS41NnMtMi41MSwzLjE1LTMuNzUsNC43M2wtMy41NCw0LjljLTEuMTMsMS42Ni0yLjIzLDMuMzUtMy4zMyw1YTEyNywxMjcsMCwwLDAtMTAuOTMsMjEuNDksMS41OCwxLjU4LDAsMSwxLTMtMS4xNVM0MC4xOSwxMjYuNDcsNDAuMjEsMTI2LjQzWiIvPjxyZWN0IGNsYXNzPSJjbHMtMiIgd2lkdGg9IjM5MiIgaGVpZ2h0PSIzOTIiLz48L2c+PC9nPjwvc3ZnPg==" : "https://cdn.babylonjs.com/Assets/loadingIcon.png", r.style.animation = "spin1 0.75s infinite linear", r.style.webkitAnimation = "spin1 0.75s infinite linear", r.style.transformOrigin = "50% 50%", r.style.webkitTransformOrigin = "50% 50%", !t) {
            var o = { w: 16, h: 18.5 }, a = { w: 30, h: 30 };
            e.style.width = "".concat(o.w, "vh"), e.style.height = "".concat(o.h, "vh"), e.style.left = "calc(50% - ".concat(o.w / 2, "vh)"), e.style.top = "calc(50% - ".concat(o.h / 2, "vh)"), r.style.width = "".concat(a.w, "vh"), r.style.height = "".concat(a.h, "vh"), r.style.left = "calc(50% - ".concat(a.w / 2, "vh)"), r.style.top = "calc(50% - ".concat(a.h / 2, "vh)");
          }
          i.appendChild(r), this._loadingDiv.appendChild(e), this._loadingDiv.appendChild(i), this._resizeLoadingUI(), window.addEventListener("resize", this._resizeLoadingUI), this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor, document.body.appendChild(this._loadingDiv), this._loadingDiv.style.opacity = "1";
        }
      }, n.prototype.hideLoadingUI = function() {
        var t = this;
        this._loadingDiv && (this._loadingDiv.style.opacity = "0", this._loadingDiv.addEventListener("transitionend", function() {
          t._loadingTextDiv && (t._loadingTextDiv.remove(), t._loadingTextDiv = null), t._loadingDiv && (t._loadingDiv.remove(), t._loadingDiv = null), t._style && (t._style.remove(), t._style = null), window.removeEventListener("resize", t._resizeLoadingUI);
        }));
      }, Object.defineProperty(n.prototype, "loadingUIText", { get: function() {
        return this._loadingText;
      }, set: function(t) {
        this._loadingText = t, this._loadingTextDiv && (this._loadingTextDiv.innerHTML = this._loadingText);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "loadingUIBackgroundColor", { get: function() {
        return this._loadingDivBackgroundColor;
      }, set: function(t) {
        this._loadingDivBackgroundColor = t, this._loadingDiv && (this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor);
      }, enumerable: !1, configurable: !0 }), n.DefaultLogoUrl = "", n.DefaultSpinnerUrl = "", n;
    }();
    ve.DefaultLoadingScreenFactory = function(n) {
      return new jy(n);
    };
    var E_ = function() {
      function n() {
      }
      return n.ConvertPanoramaToCubemap = function(t, e, i, r, o) {
        if (o === void 0 && (o = !1), !t)
          throw "ConvertPanoramaToCubemap: input cannot be null";
        if (t.length != e * i * 3)
          throw "ConvertPanoramaToCubemap: input size is wrong";
        return { front: this.CreateCubemapTexture(r, this.FACE_FRONT, t, e, i, o), back: this.CreateCubemapTexture(r, this.FACE_BACK, t, e, i, o), left: this.CreateCubemapTexture(r, this.FACE_LEFT, t, e, i, o), right: this.CreateCubemapTexture(r, this.FACE_RIGHT, t, e, i, o), up: this.CreateCubemapTexture(r, this.FACE_UP, t, e, i, o), down: this.CreateCubemapTexture(r, this.FACE_DOWN, t, e, i, o), size: r, type: _.TEXTURETYPE_FLOAT, format: _.TEXTUREFORMAT_RGB, gammaSpace: !1 };
      }, n.CreateCubemapTexture = function(t, e, i, r, o, a) {
        a === void 0 && (a = !1);
        for (var s = new ArrayBuffer(t * t * 4 * 3), l = new Float32Array(s), c = a ? Math.max(1, Math.round(r / 4 / t)) : 1, u = 1 / c, h = u * u, d = e[1].subtract(e[0]).scale(u / t), p = e[3].subtract(e[2]).scale(u / t), f = 1 / t, m = 0, g = 0; g < t; g++)
          for (var y = 0; y < c; y++) {
            for (var b = e[0], T = e[2], S = 0; S < t; S++)
              for (var E = 0; E < c; E++) {
                var A = T.subtract(b).scale(m).add(b);
                A.normalize();
                var R = this.CalcProjectionSpherical(A, i, r, o);
                l[g * t * 3 + 3 * S + 0] += R.r * h, l[g * t * 3 + 3 * S + 1] += R.g * h, l[g * t * 3 + 3 * S + 2] += R.b * h, b = b.add(d), T = T.add(p);
              }
            m += f * u;
          }
        return l;
      }, n.CalcProjectionSpherical = function(t, e, i, r) {
        for (var o = Math.atan2(t.z, t.x), a = Math.acos(t.y); o < -Math.PI; )
          o += 2 * Math.PI;
        for (; o > Math.PI; )
          o -= 2 * Math.PI;
        var s = o / Math.PI, l = a / Math.PI;
        s = 0.5 * s + 0.5;
        var c = Math.round(s * i);
        c < 0 ? c = 0 : c >= i && (c = i - 1);
        var u = Math.round(l * r);
        u < 0 ? u = 0 : u >= r && (u = r - 1);
        var h = r - u - 1;
        return { r: e[h * i * 3 + 3 * c + 0], g: e[h * i * 3 + 3 * c + 1], b: e[h * i * 3 + 3 * c + 2] };
      }, n.FACE_LEFT = [new v(-1, -1, -1), new v(1, -1, -1), new v(-1, 1, -1), new v(1, 1, -1)], n.FACE_RIGHT = [new v(1, -1, 1), new v(-1, -1, 1), new v(1, 1, 1), new v(-1, 1, 1)], n.FACE_FRONT = [new v(1, -1, -1), new v(1, -1, 1), new v(1, 1, -1), new v(1, 1, 1)], n.FACE_BACK = [new v(-1, -1, 1), new v(-1, -1, -1), new v(-1, 1, 1), new v(-1, 1, -1)], n.FACE_DOWN = [new v(1, 1, -1), new v(1, 1, 1), new v(-1, 1, -1), new v(-1, 1, 1)], n.FACE_UP = [new v(-1, -1, -1), new v(-1, -1, 1), new v(1, -1, -1), new v(1, -1, 1)], n;
    }(), Jh = function() {
      function n() {
      }
      return n._Ldexp = function(t, e) {
        return e > 1023 ? t * Math.pow(2, 1023) * Math.pow(2, e - 1023) : e < -1074 ? t * Math.pow(2, -1074) * Math.pow(2, e + 1074) : t * Math.pow(2, e);
      }, n._Rgbe2float = function(t, e, i, r, o, a) {
        o > 0 ? (o = this._Ldexp(1, o - 136), t[a + 0] = e * o, t[a + 1] = i * o, t[a + 2] = r * o) : (t[a + 0] = 0, t[a + 1] = 0, t[a + 2] = 0);
      }, n._ReadStringLine = function(t, e) {
        for (var i = "", r = "", o = e; o < t.length - e && (r = String.fromCharCode(t[o])) != `
`; o++)
          i += r;
        return i;
      }, n.RGBE_ReadHeader = function(t) {
        var e, i, r = this._ReadStringLine(t, 0);
        if (r[0] != "#" || r[1] != "?")
          throw "Bad HDR Format.";
        var o = !1, a = !1, s = 0;
        do
          s += r.length + 1, (r = this._ReadStringLine(t, s)) == "FORMAT=32-bit_rle_rgbe" ? a = !0 : r.length == 0 && (o = !0);
        while (!o);
        if (!a)
          throw "HDR Bad header format, unsupported FORMAT";
        s += r.length + 1, r = this._ReadStringLine(t, s);
        var l = /^-Y (.*) \+X (.*)$/g.exec(r);
        if (!l || l.length < 3)
          throw "HDR Bad header format, no size";
        if (i = parseInt(l[2]), e = parseInt(l[1]), i < 8 || i > 32767)
          throw "HDR Bad header format, unsupported size";
        return { height: e, width: i, dataPosition: s += r.length + 1 };
      }, n.GetCubeMapTextureData = function(t, e, i) {
        i === void 0 && (i = !1);
        var r = new Uint8Array(t), o = this.RGBE_ReadHeader(r), a = this.RGBE_ReadPixels(r, o);
        return E_.ConvertPanoramaToCubemap(a, o.width, o.height, e, i);
      }, n.RGBE_ReadPixels = function(t, e) {
        return this._RGBEReadPixelsRLE(t, e);
      }, n._RGBEReadPixelsRLE = function(t, e) {
        for (var i, r, o, a, s, l = e.height, c = e.width, u = e.dataPosition, h = 0, d = 0, p = 0, f = new ArrayBuffer(4 * c), m = new Uint8Array(f), g = new ArrayBuffer(e.width * e.height * 4 * 3), y = new Float32Array(g); l > 0; ) {
          if (i = t[u++], r = t[u++], o = t[u++], a = t[u++], i != 2 || r != 2 || 128 & o || e.width < 8 || e.width > 32767)
            return this._RGBEReadPixelsNOTRLE(t, e);
          if ((o << 8 | a) != c)
            throw "HDR Bad header format, wrong scan line width";
          for (h = 0, p = 0; p < 4; p++)
            for (d = (p + 1) * c; h < d; )
              if (i = t[u++], r = t[u++], i > 128) {
                if ((s = i - 128) == 0 || s > d - h)
                  throw "HDR Bad Format, bad scanline data (run)";
                for (; s-- > 0; )
                  m[h++] = r;
              } else {
                if ((s = i) == 0 || s > d - h)
                  throw "HDR Bad Format, bad scanline data (non-run)";
                if (m[h++] = r, --s > 0)
                  for (var b = 0; b < s; b++)
                    m[h++] = t[u++];
              }
          for (p = 0; p < c; p++)
            i = m[p], r = m[p + c], o = m[p + 2 * c], a = m[p + 3 * c], this._Rgbe2float(y, i, r, o, a, (e.height - l) * c * 3 + 3 * p);
          l--;
        }
        return y;
      }, n._RGBEReadPixelsNOTRLE = function(t, e) {
        for (var i, r, o, a, s, l = e.height, c = e.width, u = e.dataPosition, h = new ArrayBuffer(e.width * e.height * 4 * 3), d = new Float32Array(h); l > 0; ) {
          for (s = 0; s < e.width; s++)
            i = t[u++], r = t[u++], o = t[u++], a = t[u++], this._Rgbe2float(d, i, r, o, a, (e.height - l) * c * 3 + 3 * s);
          l--;
        }
        return d;
      }, n;
    }();
    re.ShadersStore.hdrFilteringVertexShader = `attribute vec2 position;varying vec3 direction;uniform vec3 up;uniform vec3 right;uniform vec3 front;
#define CUSTOM_VERTEX_DEFINITIONS
void main(void) {
#define CUSTOM_VERTEX_MAIN_BEGIN
mat3 view=mat3(up,right,front);direction=view*vec3(position,1.0);gl_Position=vec4(position,0.0,1.0);
#define CUSTOM_VERTEX_MAIN_END
}`, re.ShadersStore.hdrFilteringPixelShader = `#include<helperFunctions>
#include<importanceSampling>
#include<pbrBRDFFunctions>
#include<hdrFilteringFunctions>
uniform float alphaG;uniform samplerCube inputTexture;uniform vec2 vFilteringInfo;uniform float hdrScale;varying vec3 direction;void main() {vec3 color=radiance(alphaG,inputTexture,direction,vFilteringInfo);gl_FragColor=vec4(color*hdrScale,1.0);}`;
    var S_ = function() {
      function n(t, e) {
        e === void 0 && (e = {}), this._lodGenerationOffset = 0, this._lodGenerationScale = 0.8, this.quality = _.TEXTURE_FILTERING_QUALITY_OFFLINE, this.hdrScale = 1, this._engine = t, this.hdrScale = e.hdrScale || this.hdrScale, this.quality = e.quality || this.quality;
      }
      return n.prototype._createRenderTarget = function(t) {
        var e = _.TEXTURETYPE_UNSIGNED_BYTE;
        this._engine.getCaps().textureHalfFloatRender ? e = _.TEXTURETYPE_HALF_FLOAT : this._engine.getCaps().textureFloatRender && (e = _.TEXTURETYPE_FLOAT);
        var i = this._engine.createRenderTargetCubeTexture(t, { format: _.TEXTUREFORMAT_RGBA, type: e, createMipMaps: !0, generateMipMaps: !1, generateDepthBuffer: !1, generateStencilBuffer: !1, samplingMode: _.TEXTURE_NEAREST_SAMPLINGMODE });
        return this._engine.updateTextureWrappingMode(i.texture, _.TEXTURE_CLAMP_ADDRESSMODE, _.TEXTURE_CLAMP_ADDRESSMODE, _.TEXTURE_CLAMP_ADDRESSMODE), this._engine.updateTextureSamplingMode(_.TEXTURE_TRILINEAR_SAMPLINGMODE, i.texture, !0), i;
      }, n.prototype._prefilterInternal = function(t) {
        var e = t.getSize().width, i = ue.ILog2(e) + 1, r = this._effectWrapper.effect, o = this._createRenderTarget(e);
        this._effectRenderer.saveStates(), this._effectRenderer.setViewport();
        var a = t.getInternalTexture();
        a && this._engine.updateTextureSamplingMode(_.TEXTURE_TRILINEAR_SAMPLINGMODE, a, !0), this._effectRenderer.applyEffectWrapper(this._effectWrapper);
        var s = [[new v(0, 0, -1), new v(0, -1, 0), new v(1, 0, 0)], [new v(0, 0, 1), new v(0, -1, 0), new v(-1, 0, 0)], [new v(1, 0, 0), new v(0, 0, 1), new v(0, 1, 0)], [new v(1, 0, 0), new v(0, 0, -1), new v(0, -1, 0)], [new v(1, 0, 0), new v(0, -1, 0), new v(0, 0, 1)], [new v(-1, 0, 0), new v(0, -1, 0), new v(0, 0, -1)]];
        r.setFloat("hdrScale", this.hdrScale), r.setFloat2("vFilteringInfo", t.getSize().width, i), r.setTexture("inputTexture", t);
        for (var l = 0; l < 6; l++) {
          r.setVector3("up", s[l][0]), r.setVector3("right", s[l][1]), r.setVector3("front", s[l][2]);
          for (var c = 0; c < i; c++) {
            this._engine.bindFramebuffer(o, l, void 0, void 0, !0, c), this._effectRenderer.applyEffectWrapper(this._effectWrapper);
            var u = Math.pow(2, (c - this._lodGenerationOffset) / this._lodGenerationScale) / e;
            c === 0 && (u = 0), r.setFloat("alphaG", u), this._effectRenderer.draw();
          }
        }
        this._effectRenderer.restoreStates(), this._engine.restoreDefaultFramebuffer(), this._engine._releaseTexture(t._texture);
        var h = o.texture.type, d = o.texture.format;
        return o._swapAndDie(t._texture), t._texture.type = h, t._texture.format = d, t.gammaSpace = !1, t.lodGenerationOffset = this._lodGenerationOffset, t.lodGenerationScale = this._lodGenerationScale, t._prefiltered = !0, t;
      }, n.prototype._createEffect = function(t, e) {
        var i = [];
        return t.gammaSpace && i.push("#define GAMMA_INPUT"), i.push("#define NUM_SAMPLES " + this.quality + "u"), new Io({ engine: this._engine, name: "hdrFiltering", vertexShader: "hdrFiltering", fragmentShader: "hdrFiltering", samplerNames: ["inputTexture"], uniformNames: ["vSampleDirections", "vWeights", "up", "right", "front", "vFilteringInfo", "hdrScale", "alphaG"], useShaderStore: !0, defines: i, onCompiled: e });
      }, n.prototype.isReady = function(t) {
        return t.isReady() && this._effectWrapper.effect.isReady();
      }, n.prototype.prefilter = function(t, e) {
        var i = this;
        return e === void 0 && (e = null), this._engine._features.allowTexturePrefiltering ? new Promise(function(r) {
          i._effectRenderer = new _c(i._engine), i._effectWrapper = i._createEffect(t), i._effectWrapper.effect.executeWhenCompiled(function() {
            i._prefilterInternal(t), i._effectRenderer.dispose(), i._effectWrapper.dispose(), r(), e && e();
          });
        }) : (q.Warn("HDR prefiltering is not available in WebGL 1., you can use real time filtering instead."), Promise.reject("HDR prefiltering is not available in WebGL 1., you can use real time filtering instead."));
      }, n;
    }(), $h = function(n) {
      function t(e, i, r, o, a, s, l, c, u, h) {
        o === void 0 && (o = !1), a === void 0 && (a = !0), s === void 0 && (s = !1), l === void 0 && (l = !1), c === void 0 && (c = null), u === void 0 && (u = null), h === void 0 && (h = !1);
        var d, p = this;
        return (p = n.call(this, i) || this)._generateHarmonics = !0, p._onError = null, p._isBlocking = !0, p._rotationY = 0, p.boundingBoxPosition = v.Zero(), p.onLoadObservable = new H(), e && (p._coordinatesMode = ae.CUBIC_MODE, p.name = e, p.url = e, p.hasAlpha = !1, p.isCube = !0, p._textureMatrix = B.Identity(), p._prefilterOnLoad = l, p._onLoad = function() {
          p.onLoadObservable.notifyObservers(p), c && c();
        }, p._onError = u, p.gammaSpace = s, p._noMipmap = o, p._size = r, p._supersample = h, p._generateHarmonics = a, p._texture = p._getFromCache(e, p._noMipmap, void 0, void 0, void 0, p.isCube), p._texture ? p._texture.isReady ? de.SetImmediate(function() {
          return p._onLoad();
        }) : p._texture.onLoadedObservable.add(p._onLoad) : !((d = p.getScene()) === null || d === void 0) && d.useDelayedTextureLoading ? p.delayLoadState = _.DELAYLOADSTATE_NOTLOADED : p._loadTexture()), p;
      }
      return D(t, n), Object.defineProperty(t.prototype, "isBlocking", { get: function() {
        return this._isBlocking;
      }, set: function(e) {
        this._isBlocking = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rotationY", { get: function() {
        return this._rotationY;
      }, set: function(e) {
        this._rotationY = e, this.setReflectionTextureMatrix(B.RotationY(this._rotationY));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "boundingBoxSize", { get: function() {
        return this._boundingBoxSize;
      }, set: function(e) {
        if (!this._boundingBoxSize || !this._boundingBoxSize.equals(e)) {
          this._boundingBoxSize = e;
          var i = this.getScene();
          i && i.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag);
        }
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "HDRCubeTexture";
      }, t.prototype._loadTexture = function() {
        var e = this, i = this._getEngine(), r = i.getCaps(), o = _.TEXTURETYPE_UNSIGNED_BYTE;
        if (r.textureFloat && r.textureFloatLinearFiltering ? o = _.TEXTURETYPE_FLOAT : r.textureHalfFloat && r.textureHalfFloatLinearFiltering && (o = _.TEXTURETYPE_HALF_FLOAT), i._features.allowTexturePrefiltering && this._prefilterOnLoad) {
          var a = this._onLoad, s = new S_(i);
          this._onLoad = function() {
            s.prefilter(e, a);
          };
        }
        this._texture = i.createRawCubeTextureFromUrl(this.url, this.getScene(), this._size, _.TEXTUREFORMAT_RGB, o, this._noMipmap, function(l) {
          e.lodGenerationOffset = 0, e.lodGenerationScale = 0.8;
          var c = Jh.GetCubeMapTextureData(l, e._size, e._supersample);
          if (e._generateHarmonics) {
            var u = Nh.ConvertCubeMapToSphericalPolynomial(c);
            e.sphericalPolynomial = u;
          }
          for (var h = [], d = null, p = null, f = 0; f < 6; f++) {
            o === _.TEXTURETYPE_HALF_FLOAT ? p = new Uint16Array(e._size * e._size * 3) : o === _.TEXTURETYPE_UNSIGNED_BYTE && (d = new Uint8Array(e._size * e._size * 3));
            var m = c[t._FacesMapping[f]];
            if (e.gammaSpace || p || d) {
              for (var g = 0; g < e._size * e._size; g++)
                if (e.gammaSpace && (m[3 * g + 0] = Math.pow(m[3 * g + 0], ct), m[3 * g + 1] = Math.pow(m[3 * g + 1], ct), m[3 * g + 2] = Math.pow(m[3 * g + 2], ct)), p && (p[3 * g + 0] = to(m[3 * g + 0]), p[3 * g + 1] = to(m[3 * g + 1]), p[3 * g + 2] = to(m[3 * g + 2])), d) {
                  var y = Math.max(255 * m[3 * g + 0], 0), b = Math.max(255 * m[3 * g + 1], 0), T = Math.max(255 * m[3 * g + 2], 0), S = Math.max(Math.max(y, b), T);
                  if (S > 255) {
                    var E = 255 / S;
                    y *= E, b *= E, T *= E;
                  }
                  d[3 * g + 0] = y, d[3 * g + 1] = b, d[3 * g + 2] = T;
                }
            }
            p ? h.push(p) : d ? h.push(d) : h.push(m);
          }
          return h;
        }, null, this._onLoad, this._onError);
      }, t.prototype.clone = function() {
        var e = new t(this.url, this.getScene() || this._getEngine(), this._size, this._noMipmap, this._generateHarmonics, this.gammaSpace);
        return e.level = this.level, e.wrapU = this.wrapU, e.wrapV = this.wrapV, e.coordinatesIndex = this.coordinatesIndex, e.coordinatesMode = this.coordinatesMode, e;
      }, t.prototype.delayLoad = function() {
        this.delayLoadState === _.DELAYLOADSTATE_NOTLOADED && (this.delayLoadState = _.DELAYLOADSTATE_LOADED, this._texture = this._getFromCache(this.url, this._noMipmap), this._texture || this._loadTexture());
      }, t.prototype.getReflectionTextureMatrix = function() {
        return this._textureMatrix;
      }, t.prototype.setReflectionTextureMatrix = function(e) {
        var i, r = this;
        this._textureMatrix = e, e.updateFlag !== this._textureMatrix.updateFlag && e.isIdentity() !== this._textureMatrix.isIdentity() && ((i = this.getScene()) === null || i === void 0 || i.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag, function(o) {
          return o.getActiveTextures().indexOf(r) !== -1;
        }));
      }, t.prototype.dispose = function() {
        this.onLoadObservable.clear(), n.prototype.dispose.call(this);
      }, t.Parse = function(e, i, r) {
        var o = null;
        return e.name && !e.isRenderTarget && ((o = new t(r + e.name, i, e.size, e.noMipmap, e.generateHarmonics, e.useInGammaSpace)).name = e.name, o.hasAlpha = e.hasAlpha, o.level = e.level, o.coordinatesMode = e.coordinatesMode, o.isBlocking = e.isBlocking), o && (e.boundingBoxPosition && (o.boundingBoxPosition = v.FromArray(e.boundingBoxPosition)), e.boundingBoxSize && (o.boundingBoxSize = v.FromArray(e.boundingBoxSize)), e.rotationY && (o.rotationY = e.rotationY)), o;
      }, t.prototype.serialize = function() {
        if (!this.name)
          return null;
        var e = {};
        return e.name = this.name, e.hasAlpha = this.hasAlpha, e.isCube = !0, e.level = this.level, e.size = this._size, e.coordinatesMode = this.coordinatesMode, e.useInGammaSpace = this.gammaSpace, e.generateHarmonics = this._generateHarmonics, e.customType = "BABYLON.HDRCubeTexture", e.noMipmap = this._noMipmap, e.isBlocking = this._isBlocking, e.rotationY = this._rotationY, e;
      }, t._FacesMapping = ["right", "left", "up", "down", "front", "back"], t;
    }(Vn);
    j("BABYLON.HDRCubeTexture", $h);
    var Yy = function() {
      function n(t, e, i) {
        e === void 0 && (e = 0), i === void 0 && (i = null), this.name = t, this.animations = [], this._positions = null, this._normals = null, this._tangents = null, this._uvs = null, this._uniqueId = 0, this.onInfluenceChanged = new H(), this._onDataLayoutChanged = new H(), this._animationPropertiesOverride = null, this._scene = i || Me.LastCreatedScene, this.influence = e, this._scene && (this._uniqueId = this._scene.getUniqueId());
      }
      return Object.defineProperty(n.prototype, "influence", { get: function() {
        return this._influence;
      }, set: function(t) {
        if (this._influence !== t) {
          var e = this._influence;
          this._influence = t, this.onInfluenceChanged.hasObservers() && this.onInfluenceChanged.notifyObservers(e === 0 || t === 0);
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "animationPropertiesOverride", { get: function() {
        return !this._animationPropertiesOverride && this._scene ? this._scene.animationPropertiesOverride : this._animationPropertiesOverride;
      }, set: function(t) {
        this._animationPropertiesOverride = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "uniqueId", { get: function() {
        return this._uniqueId;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "hasPositions", { get: function() {
        return !!this._positions;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "hasNormals", { get: function() {
        return !!this._normals;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "hasTangents", { get: function() {
        return !!this._tangents;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "hasUVs", { get: function() {
        return !!this._uvs;
      }, enumerable: !1, configurable: !0 }), n.prototype.setPositions = function(t) {
        var e = this.hasPositions;
        this._positions = t, e !== this.hasPositions && this._onDataLayoutChanged.notifyObservers(void 0);
      }, n.prototype.getPositions = function() {
        return this._positions;
      }, n.prototype.setNormals = function(t) {
        var e = this.hasNormals;
        this._normals = t, e !== this.hasNormals && this._onDataLayoutChanged.notifyObservers(void 0);
      }, n.prototype.getNormals = function() {
        return this._normals;
      }, n.prototype.setTangents = function(t) {
        var e = this.hasTangents;
        this._tangents = t, e !== this.hasTangents && this._onDataLayoutChanged.notifyObservers(void 0);
      }, n.prototype.getTangents = function() {
        return this._tangents;
      }, n.prototype.setUVs = function(t) {
        var e = this.hasUVs;
        this._uvs = t, e !== this.hasUVs && this._onDataLayoutChanged.notifyObservers(void 0);
      }, n.prototype.getUVs = function() {
        return this._uvs;
      }, n.prototype.clone = function() {
        var t = this, e = Ne.Clone(function() {
          return new n(t.name, t.influence, t._scene);
        }, this);
        return e._positions = this._positions, e._normals = this._normals, e._tangents = this._tangents, e._uvs = this._uvs, e;
      }, n.prototype.serialize = function() {
        var t = {};
        return t.name = this.name, t.influence = this.influence, t.positions = Array.prototype.slice.call(this.getPositions()), this.id != null && (t.id = this.id), this.hasNormals && (t.normals = Array.prototype.slice.call(this.getNormals())), this.hasTangents && (t.tangents = Array.prototype.slice.call(this.getTangents())), this.hasUVs && (t.uvs = Array.prototype.slice.call(this.getUVs())), Ne.AppendSerializedAnimations(this, t), t;
      }, n.prototype.getClassName = function() {
        return "MorphTarget";
      }, n.Parse = function(t, e) {
        var i = new n(t.name, t.influence);
        if (i.setPositions(t.positions), t.id != null && (i.id = t.id), t.normals && i.setNormals(t.normals), t.tangents && i.setTangents(t.tangents), t.uvs && i.setUVs(t.uvs), t.animations) {
          for (var r = 0; r < t.animations.length; r++) {
            var o = t.animations[r], a = Kt("BABYLON.Animation");
            a && i.animations.push(a.Parse(o));
          }
          t.autoAnimate && e && e.beginAnimation(i, t.autoAnimateFrom, t.autoAnimateTo, t.autoAnimateLoop, t.autoAnimateSpeed || 1);
        }
        return i;
      }, n.FromMesh = function(t, e, i) {
        e || (e = t.name);
        var r = new n(e, i, t.getScene());
        return r.setPositions(t.getVerticesData(P.PositionKind)), t.isVerticesDataPresent(P.NormalKind) && r.setNormals(t.getVerticesData(P.NormalKind)), t.isVerticesDataPresent(P.TangentKind) && r.setTangents(t.getVerticesData(P.TangentKind)), t.isVerticesDataPresent(P.UVKind) && r.setUVs(t.getVerticesData(P.UVKind)), r;
      }, x([N()], n.prototype, "id", void 0), n;
    }(), Ky = function(n) {
      function t(e, i, r, o, a, s, l, c, u, h, d) {
        l === void 0 && (l = !0), c === void 0 && (c = !1), u === void 0 && (u = ae.TRILINEAR_SAMPLINGMODE), h === void 0 && (h = _.TEXTURETYPE_UNSIGNED_INT);
        var p = n.call(this, null, s, !l, c) || this;
        return p.format = a, p._texture = s.getEngine().createRawTexture2DArray(e, i, r, o, a, l, c, u, null, h, d), p._depth = o, p.is2DArray = !0, p;
      }
      return D(t, n), Object.defineProperty(t.prototype, "depth", { get: function() {
        return this._depth;
      }, enumerable: !1, configurable: !0 }), t.prototype.update = function(e) {
        this._texture && this._getEngine().updateRawTexture2DArray(this._texture, e, this._texture.format, this._texture.invertY, null, this._texture.type);
      }, t.CreateRGBATexture = function(e, i, r, o, a, s, l, c, u) {
        return s === void 0 && (s = !0), l === void 0 && (l = !1), c === void 0 && (c = _.TEXTURE_TRILINEAR_SAMPLINGMODE), u === void 0 && (u = _.TEXTURETYPE_UNSIGNED_INT), new t(e, i, r, o, _.TEXTUREFORMAT_RGBA, a, s, l, c, u);
      }, t;
    }(ae), ed = function() {
      function n(t) {
        if (t === void 0 && (t = null), this._targets = new Array(), this._targetInfluenceChangedObservers = new Array(), this._targetDataLayoutChangedObservers = new Array(), this._activeTargets = new en(16), this._supportsNormals = !1, this._supportsTangents = !1, this._supportsUVs = !1, this._vertexCount = 0, this._textureVertexStride = 0, this._textureWidth = 0, this._textureHeight = 1, this._uniqueId = 0, this._tempInfluences = new Array(), this._canUseTextureForTargets = !1, this._blockCounter = 0, this._parentContainer = null, this.optimizeInfluencers = !0, this.enableNormalMorphing = !0, this.enableTangentMorphing = !0, this.enableUVMorphing = !0, this._useTextureToStoreTargets = !0, t || (t = Me.LastCreatedScene), this._scene = t, this._scene) {
          this._scene.addMorphTargetManager(this), this._uniqueId = this._scene.getUniqueId();
          var e = this._scene.getEngine().getCaps();
          this._canUseTextureForTargets = e.canUseGLVertexID && e.textureFloat && e.maxVertexTextureImageUnits > 0 && e.texture2DArrayMaxLayerCount > 1;
        }
      }
      return Object.defineProperty(n.prototype, "areUpdatesFrozen", { get: function() {
        return this._blockCounter > 0;
      }, set: function(t) {
        t ? this._blockCounter++ : (this._blockCounter--, this._blockCounter <= 0 && (this._blockCounter = 0, this._syncActiveTargets(!0)));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "uniqueId", { get: function() {
        return this._uniqueId;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "vertexCount", { get: function() {
        return this._vertexCount;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "supportsNormals", { get: function() {
        return this._supportsNormals && this.enableNormalMorphing;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "supportsTangents", { get: function() {
        return this._supportsTangents && this.enableTangentMorphing;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "supportsUVs", { get: function() {
        return this._supportsUVs && this.enableUVMorphing;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "numTargets", { get: function() {
        return this._targets.length;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "numInfluencers", { get: function() {
        return this._activeTargets.length;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "influences", { get: function() {
        return this._influences;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "useTextureToStoreTargets", { get: function() {
        return this._useTextureToStoreTargets;
      }, set: function(t) {
        this._useTextureToStoreTargets = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isUsingTextureForTargets", { get: function() {
        var t;
        return n.EnableTextureStorage && this.useTextureToStoreTargets && this._canUseTextureForTargets && !(!((t = this._scene) === null || t === void 0) && t.getEngine().getCaps().disableMorphTargetTexture);
      }, enumerable: !1, configurable: !0 }), n.prototype.getActiveTarget = function(t) {
        return this._activeTargets.data[t];
      }, n.prototype.getTarget = function(t) {
        return this._targets[t];
      }, n.prototype.addTarget = function(t) {
        var e = this;
        this._targets.push(t), this._targetInfluenceChangedObservers.push(t.onInfluenceChanged.add(function(i) {
          e._syncActiveTargets(i);
        })), this._targetDataLayoutChangedObservers.push(t._onDataLayoutChanged.add(function() {
          e._syncActiveTargets(!0);
        })), this._syncActiveTargets(!0);
      }, n.prototype.removeTarget = function(t) {
        var e = this._targets.indexOf(t);
        e >= 0 && (this._targets.splice(e, 1), t.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(e, 1)[0]), t._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(e, 1)[0]), this._syncActiveTargets(!0)), this._scene && this._scene.stopAnimation(t);
      }, n.prototype._bind = function(t) {
        t.setFloat3("morphTargetTextureInfo", this._textureVertexStride, this._textureWidth, this._textureHeight), t.setFloatArray("morphTargetTextureIndices", this._morphTargetTextureIndices), t.setTexture("morphTargets", this._targetStoreTexture);
      }, n.prototype.clone = function() {
        for (var t = new n(this._scene), e = 0, i = this._targets; e < i.length; e++) {
          var r = i[e];
          t.addTarget(r.clone());
        }
        return t.enableNormalMorphing = this.enableNormalMorphing, t.enableTangentMorphing = this.enableTangentMorphing, t.enableUVMorphing = this.enableUVMorphing, t;
      }, n.prototype.serialize = function() {
        var t = {};
        t.id = this.uniqueId, t.targets = [];
        for (var e = 0, i = this._targets; e < i.length; e++) {
          var r = i[e];
          t.targets.push(r.serialize());
        }
        return t;
      }, n.prototype._syncActiveTargets = function(t) {
        if (!this.areUpdatesFrozen) {
          var e = 0;
          this._activeTargets.reset(), this._supportsNormals = !0, this._supportsTangents = !0, this._supportsUVs = !0, this._vertexCount = 0, this._scene && this._targets.length > this._scene.getEngine().getCaps().texture2DArrayMaxLayerCount && (this.useTextureToStoreTargets = !1), this._morphTargetTextureIndices && this._morphTargetTextureIndices.length === this._targets.length || (this._morphTargetTextureIndices = new Float32Array(this._targets.length));
          for (var i = -1, r = 0, o = this._targets; r < o.length; r++) {
            var a = o[r];
            if (i++, a.influence !== 0 || !this.optimizeInfluencers) {
              if (this._activeTargets.length >= n.MaxActiveMorphTargetsInVertexAttributeMode && !this.isUsingTextureForTargets)
                break;
              this._activeTargets.push(a), this._morphTargetTextureIndices[e] = i, this._tempInfluences[e++] = a.influence, this._supportsNormals = this._supportsNormals && a.hasNormals, this._supportsTangents = this._supportsTangents && a.hasTangents, this._supportsUVs = this._supportsUVs && a.hasUVs;
              var s = a.getPositions();
              if (s) {
                var l = s.length / 3;
                if (this._vertexCount === 0)
                  this._vertexCount = l;
                else if (this._vertexCount !== l)
                  return void q.Error("Incompatible target. Targets must all have the same vertices count.");
              }
            }
          }
          this._morphTargetTextureIndices.length !== e && (this._morphTargetTextureIndices = this._morphTargetTextureIndices.slice(0, e)), this._influences && this._influences.length === e || (this._influences = new Float32Array(e));
          for (var c = 0; c < e; c++)
            this._influences[c] = this._tempInfluences[c];
          t && this.synchronize();
        }
      }, n.prototype.synchronize = function() {
        if (this._scene && !this.areUpdatesFrozen) {
          if (this.isUsingTextureForTargets && this._vertexCount) {
            this._textureVertexStride = 1, this._supportsNormals && this._textureVertexStride++, this._supportsTangents && this._textureVertexStride++, this._supportsUVs && this._textureVertexStride++, this._textureWidth = this._vertexCount * this._textureVertexStride, this._textureHeight = 1;
            var t = this._scene.getEngine().getCaps().maxTextureSize;
            this._textureWidth > t && (this._textureHeight = Math.ceil(this._textureWidth / t), this._textureWidth = t);
            var e = !0;
            if (this._targetStoreTexture) {
              var i = this._targetStoreTexture.getSize();
              i.width === this._textureWidth && i.height === this._textureHeight && this._targetStoreTexture.depth === this._targets.length && (e = !1);
            }
            if (e) {
              this._targetStoreTexture && this._targetStoreTexture.dispose();
              for (var r = this._targets.length, o = new Float32Array(r * this._textureWidth * this._textureHeight * 4), a = 0, s = 0; s < r; s++) {
                var l = this._targets[s], c = l.getPositions(), u = l.getNormals(), h = l.getUVs(), d = l.getTangents();
                if (!c)
                  return void (s === 0 && q.Error("Invalid morph target. Target must have positions."));
                a = s * this._textureWidth * this._textureHeight * 4;
                for (var p = 0; p < this._vertexCount; p++)
                  o[a] = c[3 * p], o[a + 1] = c[3 * p + 1], o[a + 2] = c[3 * p + 2], a += 4, this._supportsNormals && u && (o[a] = u[3 * p], o[a + 1] = u[3 * p + 1], o[a + 2] = u[3 * p + 2], a += 4), this._supportsUVs && h && (o[a] = h[2 * p], o[a + 1] = h[2 * p + 1], a += 4), this._supportsTangents && d && (o[a] = d[3 * p], o[a + 1] = d[3 * p + 1], o[a + 2] = d[3 * p + 2], a += 4);
              }
              this._targetStoreTexture = Ky.CreateRGBATexture(o, this._textureWidth, this._textureHeight, r, this._scene, !1, !1, _.TEXTURE_NEAREST_SAMPLINGMODE, _.TEXTURETYPE_FLOAT);
            }
          }
          for (var f = 0, m = this._scene.meshes; f < m.length; f++) {
            var g = m[f];
            g.morphTargetManager === this && g._syncGeometryWithMorphTargetManager();
          }
        }
      }, n.prototype.dispose = function() {
        if (this._targetStoreTexture && this._targetStoreTexture.dispose(), this._targetStoreTexture = null, this._scene) {
          if (this._scene.removeMorphTargetManager(this), this._parentContainer) {
            var t = this._parentContainer.morphTargetManagers.indexOf(this);
            t > -1 && this._parentContainer.morphTargetManagers.splice(t, 1), this._parentContainer = null;
          }
          for (var e = 0, i = this._targets; e < i.length; e++) {
            var r = i[e];
            this._scene.stopAnimation(r);
          }
        }
      }, n.Parse = function(t, e) {
        var i = new n(e);
        i._uniqueId = t.id;
        for (var r = 0, o = t.targets; r < o.length; r++) {
          var a = o[r];
          i.addTarget(Yy.Parse(a, e));
        }
        return i;
      }, n.EnableTextureStorage = !0, n.MaxActiveMorphTargetsInVertexAttributeMode = 8, n;
    }(), nu = function() {
      function n() {
        this._hasHit = !1, this._hitDistance = 0, this._hitNormalWorld = v.Zero(), this._hitPointWorld = v.Zero(), this._rayFromWorld = v.Zero(), this._rayToWorld = v.Zero(), this._triangleIndex = -1;
      }
      return Object.defineProperty(n.prototype, "hasHit", { get: function() {
        return this._hasHit;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "hitDistance", { get: function() {
        return this._hitDistance;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "hitNormalWorld", { get: function() {
        return this._hitNormalWorld;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "hitPointWorld", { get: function() {
        return this._hitPointWorld;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "rayFromWorld", { get: function() {
        return this._rayFromWorld;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "rayToWorld", { get: function() {
        return this._rayToWorld;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "triangleIndex", { get: function() {
        return this._triangleIndex;
      }, enumerable: !1, configurable: !0 }), n.prototype.setHitData = function(t, e, i) {
        this._hasHit = !0, this._hitNormalWorld.set(t.x, t.y, t.z), this._hitPointWorld.set(e.x, e.y, e.z), this._triangleIndex = i ?? -1;
      }, n.prototype.setHitDistance = function(t) {
        this._hitDistance = t;
      }, n.prototype.calculateHitDistance = function() {
        this._hitDistance = v.Distance(this._rayFromWorld, this._hitPointWorld);
      }, n.prototype.reset = function(t, e) {
        t === void 0 && (t = v.Zero()), e === void 0 && (e = v.Zero()), this._rayFromWorld.copyFrom(t), this._rayToWorld.copyFrom(e), this._hasHit = !1, this._hitDistance = 0, this._hitNormalWorld.setAll(0), this._hitPointWorld.setAll(0), this._triangleIndex = -1, this.body = void 0, this.bodyIndex = void 0;
      }, n;
    }(), x_ = function() {
      function n(t, e) {
        if (e === void 0 && (e = n.DefaultPluginFactory()), this._physicsPlugin = e, this._impostors = [], this._joints = [], this._subTimeStep = 0, this._uniqueIdCounter = 0, !this._physicsPlugin.isSupported())
          throw new Error("Physics Engine " + this._physicsPlugin.name + " cannot be found. Please make sure it is included.");
        t = t || new v(0, -9.807, 0), this.setGravity(t), this.setTimeStep();
      }
      return n.prototype.getPluginVersion = function() {
        return this._physicsPlugin.getPluginVersion();
      }, n.DefaultPluginFactory = function() {
        throw et("CannonJSPlugin");
      }, n.prototype.setGravity = function(t) {
        this.gravity = t, this._physicsPlugin.setGravity(this.gravity);
      }, n.prototype.setTimeStep = function(t) {
        t === void 0 && (t = 1 / 60), this._physicsPlugin.setTimeStep(t);
      }, n.prototype.getTimeStep = function() {
        return this._physicsPlugin.getTimeStep();
      }, n.prototype.setSubTimeStep = function(t) {
        t === void 0 && (t = 0), this._subTimeStep = t;
      }, n.prototype.getSubTimeStep = function() {
        return this._subTimeStep;
      }, n.prototype.dispose = function() {
        this._impostors.forEach(function(t) {
          t.dispose();
        }), this._physicsPlugin.dispose();
      }, n.prototype.getPhysicsPluginName = function() {
        return this._physicsPlugin.name;
      }, n.prototype.addImpostor = function(t) {
        this._impostors.push(t), t.uniqueId = this._uniqueIdCounter++, t.parent || this._physicsPlugin.generatePhysicsBody(t);
      }, n.prototype.removeImpostor = function(t) {
        var e = this._impostors.indexOf(t);
        e > -1 && this._impostors.splice(e, 1).length && this.getPhysicsPlugin().removePhysicsBody(t);
      }, n.prototype.addJoint = function(t, e, i) {
        var r = { mainImpostor: t, connectedImpostor: e, joint: i };
        i.physicsPlugin = this._physicsPlugin, this._joints.push(r), this._physicsPlugin.generateJoint(r);
      }, n.prototype.removeJoint = function(t, e, i) {
        var r = this._joints.filter(function(o) {
          return o.connectedImpostor === e && o.joint === i && o.mainImpostor === t;
        });
        r.length && this._physicsPlugin.removeJoint(r[0]);
      }, n.prototype._step = function(t) {
        var e = this;
        this._impostors.forEach(function(i) {
          i.isBodyInitRequired() && e._physicsPlugin.generatePhysicsBody(i);
        }), t > 0.1 ? t = 0.1 : t <= 0 && (t = 1 / 60), this._physicsPlugin.executeStep(t, this._impostors);
      }, n.prototype.getPhysicsPlugin = function() {
        return this._physicsPlugin;
      }, n.prototype.getImpostors = function() {
        return this._impostors;
      }, n.prototype.getImpostorForPhysicsObject = function(t) {
        for (var e = 0; e < this._impostors.length; ++e)
          if (this._impostors[e].object === t)
            return this._impostors[e];
        return null;
      }, n.prototype.getImpostorWithPhysicsBody = function(t) {
        for (var e = 0; e < this._impostors.length; ++e)
          if (this._impostors[e].physicsBody === t)
            return this._impostors[e];
        return null;
      }, n.prototype.raycast = function(t, e) {
        return this._physicsPlugin.raycast(t, e);
      }, n.prototype.raycastToRef = function(t, e, i) {
        return this._physicsPlugin.raycastToRef(t, e, i);
      }, n;
    }(), td = function() {
      function n(t, e, i) {
        t === void 0 && (t = !0), e === void 0 && (e = 10), i === void 0 && (i = CANNON), this._useDeltaForWorldStep = t, this.name = "CannonJSPlugin", this._physicsMaterials = new Array(), this._fixedTimeStep = 1 / 60, this._physicsBodiesToRemoveAfterStep = new Array(), this._firstFrame = !0, this._tmpQuaternion = new oe(), this._minus90X = new oe(-0.7071067811865475, 0, 0, 0.7071067811865475), this._plus90X = new oe(0.7071067811865475, 0, 0, 0.7071067811865475), this._tmpPosition = v.Zero(), this._tmpDeltaPosition = v.Zero(), this._tmpUnityRotation = new oe(), this.BJSCANNON = i, this.isSupported() ? (this._extendNamespace(), this.world = new this.BJSCANNON.World(), this.world.broadphase = new this.BJSCANNON.NaiveBroadphase(), this.world.solver.iterations = e, this._cannonRaycastResult = new this.BJSCANNON.RaycastResult(), this._raycastResult = new nu()) : q.Error("CannonJS is not available. Please make sure you included the js file.");
      }
      return n.prototype.getPluginVersion = function() {
        return 1;
      }, n.prototype.setGravity = function(t) {
        var e = t;
        this.world.gravity.set(e.x, e.y, e.z);
      }, n.prototype.setTimeStep = function(t) {
        this._fixedTimeStep = t;
      }, n.prototype.getTimeStep = function() {
        return this._fixedTimeStep;
      }, n.prototype.executeStep = function(t, e) {
        if (this._firstFrame) {
          this._firstFrame = !1;
          for (var i = 0, r = e; i < r.length; i++) {
            var o = r[i];
            o.type != bt.HeightmapImpostor && o.type !== bt.PlaneImpostor && o.beforeStep();
          }
        }
        this.world.step(this._useDeltaForWorldStep ? t : this._fixedTimeStep), this._removeMarkedPhysicsBodiesFromWorld();
      }, n.prototype._removeMarkedPhysicsBodiesFromWorld = function() {
        var t = this;
        this._physicsBodiesToRemoveAfterStep.length > 0 && (this._physicsBodiesToRemoveAfterStep.forEach(function(e) {
          typeof t.world.removeBody == "function" ? t.world.removeBody(e) : t.world.remove(e);
        }), this._physicsBodiesToRemoveAfterStep.length = 0);
      }, n.prototype.applyImpulse = function(t, e, i) {
        var r = new this.BJSCANNON.Vec3(i.x, i.y, i.z), o = new this.BJSCANNON.Vec3(e.x, e.y, e.z);
        t.physicsBody.applyImpulse(o, r);
      }, n.prototype.applyForce = function(t, e, i) {
        var r = new this.BJSCANNON.Vec3(i.x, i.y, i.z), o = new this.BJSCANNON.Vec3(e.x, e.y, e.z);
        t.physicsBody.applyForce(o, r);
      }, n.prototype.generatePhysicsBody = function(t) {
        if (this._removeMarkedPhysicsBodiesFromWorld(), t.parent)
          t.physicsBody && (this.removePhysicsBody(t), t.forceUpdate());
        else {
          if (t.isBodyInitRequired()) {
            var e = this._createShape(t);
            if (!e)
              return void q.Warn("It was not possible to create a physics body for this object.");
            var i = t.physicsBody;
            i && this.removePhysicsBody(t);
            var r = this._addMaterial("mat-" + t.uniqueId, t.getParam("friction"), t.getParam("restitution")), o = { mass: t.getParam("mass"), material: r }, a = t.getParam("nativeOptions");
            for (var s in a)
              Object.prototype.hasOwnProperty.call(a, s) && (o[s] = a[s]);
            t.physicsBody = new this.BJSCANNON.Body(o), t.physicsBody.addEventListener("collide", t.onCollide), this.world.addEventListener("preStep", t.beforeStep), this.world.addEventListener("postStep", t.afterStep), t.physicsBody.addShape(e), typeof this.world.addBody == "function" ? this.world.addBody(t.physicsBody) : this.world.add(t.physicsBody), i && ["force", "torque", "velocity", "angularVelocity"].forEach(function(l) {
              var c = i[l];
              t.physicsBody[l].set(c.x, c.y, c.z);
            }), this._processChildMeshes(t);
          }
          this._updatePhysicsBodyTransformation(t);
        }
      }, n.prototype._processChildMeshes = function(t) {
        var e = this, i = t.object.getChildMeshes ? t.object.getChildMeshes(!0) : [], r = t.object.rotationQuaternion;
        if (r ? r.conjugateToRef(this._tmpQuaternion) : this._tmpQuaternion.set(0, 0, 0, 1), i.length) {
          var o = function(a) {
            if (a.rotationQuaternion) {
              var s = a.getPhysicsImpostor();
              if (s && s.parent !== t && a.parent) {
                var l = a.getAbsolutePosition().subtract(a.parent.getAbsolutePosition()), c = a.rotationQuaternion.multiply(e._tmpQuaternion);
                s.physicsBody && (e.removePhysicsBody(s), s.physicsBody = null), s.parent = t, s.resetUpdateFlags(), t.physicsBody.addShape(e._createShape(s), new e.BJSCANNON.Vec3(l.x, l.y, l.z), new e.BJSCANNON.Quaternion(c.x, c.y, c.z, c.w)), t.physicsBody.mass += s.getParam("mass");
              }
              a.getChildMeshes(!0).filter(function(u) {
                return !!u.physicsImpostor;
              }).forEach(o);
            }
          };
          i.filter(function(a) {
            return !!a.physicsImpostor;
          }).forEach(o);
        }
      }, n.prototype.removePhysicsBody = function(t) {
        t.physicsBody.removeEventListener("collide", t.onCollide), this.world.removeEventListener("preStep", t.beforeStep), this.world.removeEventListener("postStep", t.afterStep), this._physicsBodiesToRemoveAfterStep.indexOf(t.physicsBody) === -1 && this._physicsBodiesToRemoveAfterStep.push(t.physicsBody);
      }, n.prototype.generateJoint = function(t) {
        var e = t.mainImpostor.physicsBody, i = t.connectedImpostor.physicsBody;
        if (e && i) {
          var r, o = t.joint.jointData, a = { pivotA: o.mainPivot ? new this.BJSCANNON.Vec3().set(o.mainPivot.x, o.mainPivot.y, o.mainPivot.z) : null, pivotB: o.connectedPivot ? new this.BJSCANNON.Vec3().set(o.connectedPivot.x, o.connectedPivot.y, o.connectedPivot.z) : null, axisA: o.mainAxis ? new this.BJSCANNON.Vec3().set(o.mainAxis.x, o.mainAxis.y, o.mainAxis.z) : null, axisB: o.connectedAxis ? new this.BJSCANNON.Vec3().set(o.connectedAxis.x, o.connectedAxis.y, o.connectedAxis.z) : null, maxForce: o.nativeParams.maxForce, collideConnected: !!o.collision };
          switch (t.joint.type) {
            case Ii.HingeJoint:
            case Ii.Hinge2Joint:
              r = new this.BJSCANNON.HingeConstraint(e, i, a);
              break;
            case Ii.DistanceJoint:
              r = new this.BJSCANNON.DistanceConstraint(e, i, o.maxDistance || 2);
              break;
            case Ii.SpringJoint:
              var s = o;
              r = new this.BJSCANNON.Spring(e, i, { restLength: s.length, stiffness: s.stiffness, damping: s.damping, localAnchorA: a.pivotA, localAnchorB: a.pivotB });
              break;
            case Ii.LockJoint:
              r = new this.BJSCANNON.LockConstraint(e, i, a);
              break;
            case Ii.PointToPointJoint:
            case Ii.BallAndSocketJoint:
            default:
              r = new this.BJSCANNON.PointToPointConstraint(e, a.pivotA, i, a.pivotB, a.maxForce);
          }
          r.collideConnected = !!o.collision, t.joint.physicsJoint = r, t.joint.type !== Ii.SpringJoint ? this.world.addConstraint(r) : (t.joint.jointData.forceApplicationCallback = t.joint.jointData.forceApplicationCallback || function() {
            r.applyForce();
          }, t.mainImpostor.registerAfterPhysicsStep(t.joint.jointData.forceApplicationCallback));
        }
      }, n.prototype.removeJoint = function(t) {
        t.joint.type !== Ii.SpringJoint ? this.world.removeConstraint(t.joint.physicsJoint) : t.mainImpostor.unregisterAfterPhysicsStep(t.joint.jointData.forceApplicationCallback);
      }, n.prototype._addMaterial = function(t, e, i) {
        var r, o;
        for (r = 0; r < this._physicsMaterials.length; r++)
          if ((o = this._physicsMaterials[r]).friction === e && o.restitution === i)
            return o;
        var a = new this.BJSCANNON.Material(t);
        return a.friction = e, a.restitution = i, this._physicsMaterials.push(a), a;
      }, n.prototype._checkWithEpsilon = function(t) {
        return t < Ge ? Ge : t;
      }, n.prototype._createShape = function(t) {
        var e, i = t.object, r = t.getObjectExtents();
        switch (t.type) {
          case bt.SphereImpostor:
            var o = r.x, a = r.y, s = r.z;
            e = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(o), this._checkWithEpsilon(a), this._checkWithEpsilon(s)) / 2);
            break;
          case bt.CylinderImpostor:
            var l = t.getParam("nativeOptions");
            l || (l = {});
            var c = l.radiusTop !== void 0 ? l.radiusTop : this._checkWithEpsilon(r.x) / 2, u = l.radiusBottom !== void 0 ? l.radiusBottom : this._checkWithEpsilon(r.x) / 2, h = l.height !== void 0 ? l.height : this._checkWithEpsilon(r.y), d = l.numSegments !== void 0 ? l.numSegments : 16;
            e = new this.BJSCANNON.Cylinder(c, u, h, d);
            var p = new this.BJSCANNON.Quaternion();
            p.setFromAxisAngle(new this.BJSCANNON.Vec3(1, 0, 0), -Math.PI / 2);
            var f = new this.BJSCANNON.Vec3(0, 0, 0);
            e.transformAllPoints(f, p);
            break;
          case bt.BoxImpostor:
            var m = r.scale(0.5);
            e = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(m.x), this._checkWithEpsilon(m.y), this._checkWithEpsilon(m.z)));
            break;
          case bt.PlaneImpostor:
            q.Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead"), e = new this.BJSCANNON.Plane();
            break;
          case bt.MeshImpostor:
            var g = i.getVerticesData ? i.getVerticesData(P.PositionKind) : [], y = i.getIndices ? i.getIndices() : [];
            if (!g)
              return void q.Warn("Tried to create a MeshImpostor for an object without vertices. This will fail.");
            var b = i.position.clone(), T = i.rotation && i.rotation.clone(), S = i.rotationQuaternion && i.rotationQuaternion.clone();
            i.position.copyFromFloats(0, 0, 0), i.rotation && i.rotation.copyFromFloats(0, 0, 0), i.rotationQuaternion && i.rotationQuaternion.copyFrom(t.getParentsRotation()), i.rotationQuaternion && i.parent && i.rotationQuaternion.conjugateInPlace();
            var E = i.computeWorldMatrix(!0), A = [], R = void 0;
            for (R = 0; R < g.length; R += 3)
              v.TransformCoordinates(v.FromArray(g, R), E).toArray(A, R);
            q.Warn("MeshImpostor only collides against spheres."), e = new this.BJSCANNON.Trimesh(A, y), i.position.copyFrom(b), T && i.rotation && i.rotation.copyFrom(T), S && i.rotationQuaternion && i.rotationQuaternion.copyFrom(S);
            break;
          case bt.HeightmapImpostor:
            var C = i.position.clone(), L = i.rotation && i.rotation.clone(), I = i.rotationQuaternion && i.rotationQuaternion.clone();
            i.position.copyFromFloats(0, 0, 0), i.rotation && i.rotation.copyFromFloats(0, 0, 0), i.rotationQuaternion && i.rotationQuaternion.copyFrom(t.getParentsRotation()), i.rotationQuaternion && i.parent && i.rotationQuaternion.conjugateInPlace(), i.rotationQuaternion && i.rotationQuaternion.multiplyInPlace(this._minus90X), e = this._createHeightmap(i), i.position.copyFrom(C), L && i.rotation && i.rotation.copyFrom(L), I && i.rotationQuaternion && i.rotationQuaternion.copyFrom(I), i.computeWorldMatrix(!0);
            break;
          case bt.ParticleImpostor:
            e = new this.BJSCANNON.Particle();
            break;
          case bt.NoImpostor:
            e = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0, 0, 0));
        }
        return e;
      }, n.prototype._createHeightmap = function(t, e) {
        var i, r = t.getVerticesData(P.PositionKind), o = t.computeWorldMatrix(!0), a = [];
        for (i = 0; i < r.length; i += 3)
          v.TransformCoordinates(v.FromArray(r, i), o).toArray(a, i);
        r = a;
        for (var s = new Array(), l = e || ~~(Math.sqrt(r.length / 3) - 1), c = t.getBoundingInfo(), u = Math.min(c.boundingBox.extendSizeWorld.x, c.boundingBox.extendSizeWorld.y), h = c.boundingBox.extendSizeWorld.z, d = 2 * u / l, p = 0; p < r.length; p += 3) {
          var f = Math.round(r[p + 0] / d + l / 2), m = Math.round(-1 * (r[p + 1] / d - l / 2)), g = -r[p + 2] + h;
          s[f] || (s[f] = []), s[f][m] || (s[f][m] = g), s[f][m] = Math.max(g, s[f][m]);
        }
        for (f = 0; f <= l; ++f) {
          if (!s[f]) {
            for (var y = 1; !s[(f + y) % l]; )
              y++;
            s[f] = s[(f + y) % l].slice();
          }
          for (m = 0; m <= l; ++m)
            if (!s[f][m]) {
              y = 1;
              for (var b = void 0; b === void 0; )
                b = s[f][(m + y++) % l];
              s[f][m] = b;
            }
        }
        var T = new this.BJSCANNON.Heightfield(s, { elementSize: d });
        return T.minY = h, T;
      }, n.prototype._updatePhysicsBodyTransformation = function(t) {
        var e = t.object;
        if (e.computeWorldMatrix && e.computeWorldMatrix(!0), e.getBoundingInfo()) {
          var i = t.getObjectCenter();
          this._tmpDeltaPosition.copyFrom(e.getAbsolutePivotPoint().subtract(i)), this._tmpDeltaPosition.divideInPlace(t.object.scaling), this._tmpPosition.copyFrom(i);
          var r = e.rotationQuaternion;
          if (r) {
            if (t.type !== bt.PlaneImpostor && t.type !== bt.HeightmapImpostor || (r = r.multiply(this._minus90X), t.setDeltaRotation(this._plus90X)), t.type === bt.HeightmapImpostor) {
              var o = e, a = o.getBoundingInfo(), s = o.rotationQuaternion;
              o.rotationQuaternion = this._tmpUnityRotation, o.computeWorldMatrix(!0);
              var l = i.clone(), c = o.getPivotMatrix();
              c = c ? c.clone() : B.Identity();
              var u = B.Translation(a.boundingBox.extendSizeWorld.x, 0, -a.boundingBox.extendSizeWorld.z);
              o.setPreTransformMatrix(u), o.computeWorldMatrix(!0);
              var h = (a = o.getBoundingInfo()).boundingBox.centerWorld.subtract(i).subtract(o.position).negate();
              this._tmpPosition.copyFromFloats(h.x, h.y - a.boundingBox.extendSizeWorld.y, h.z), this._tmpDeltaPosition.copyFrom(a.boundingBox.centerWorld.subtract(l)), this._tmpDeltaPosition.y += a.boundingBox.extendSizeWorld.y, o.rotationQuaternion = s, o.setPreTransformMatrix(c), o.computeWorldMatrix(!0);
            } else
              t.type === bt.MeshImpostor && this._tmpDeltaPosition.copyFromFloats(0, 0, 0);
            t.setDeltaPosition(this._tmpDeltaPosition), t.physicsBody.position.set(this._tmpPosition.x, this._tmpPosition.y, this._tmpPosition.z), t.physicsBody.quaternion.set(r.x, r.y, r.z, r.w);
          }
        }
      }, n.prototype.setTransformationFromPhysicsBody = function(t) {
        if (t.object.position.set(t.physicsBody.position.x, t.physicsBody.position.y, t.physicsBody.position.z), t.object.rotationQuaternion) {
          var e = t.physicsBody.quaternion;
          t.object.rotationQuaternion.set(e.x, e.y, e.z, e.w);
        }
      }, n.prototype.setPhysicsBodyTransformation = function(t, e, i) {
        t.physicsBody.position.set(e.x, e.y, e.z), t.physicsBody.quaternion.set(i.x, i.y, i.z, i.w);
      }, n.prototype.isSupported = function() {
        return this.BJSCANNON !== void 0;
      }, n.prototype.setLinearVelocity = function(t, e) {
        t.physicsBody.velocity.set(e.x, e.y, e.z);
      }, n.prototype.setAngularVelocity = function(t, e) {
        t.physicsBody.angularVelocity.set(e.x, e.y, e.z);
      }, n.prototype.getLinearVelocity = function(t) {
        var e = t.physicsBody.velocity;
        return e ? new v(e.x, e.y, e.z) : null;
      }, n.prototype.getAngularVelocity = function(t) {
        var e = t.physicsBody.angularVelocity;
        return e ? new v(e.x, e.y, e.z) : null;
      }, n.prototype.setBodyMass = function(t, e) {
        t.physicsBody.mass = e, t.physicsBody.updateMassProperties();
      }, n.prototype.getBodyMass = function(t) {
        return t.physicsBody.mass;
      }, n.prototype.getBodyFriction = function(t) {
        return t.physicsBody.material.friction;
      }, n.prototype.setBodyFriction = function(t, e) {
        t.physicsBody.material.friction = e;
      }, n.prototype.getBodyRestitution = function(t) {
        return t.physicsBody.material.restitution;
      }, n.prototype.setBodyRestitution = function(t, e) {
        t.physicsBody.material.restitution = e;
      }, n.prototype.sleepBody = function(t) {
        t.physicsBody.sleep();
      }, n.prototype.wakeUpBody = function(t) {
        t.physicsBody.wakeUp();
      }, n.prototype.updateDistanceJoint = function(t, e) {
        t.physicsJoint.distance = e;
      }, n.prototype.setMotor = function(t, e, i, r) {
        r || (t.physicsJoint.enableMotor(), t.physicsJoint.setMotorSpeed(e), i && this.setLimit(t, i));
      }, n.prototype.setLimit = function(t, e, i) {
        t.physicsJoint.motorEquation.maxForce = i, t.physicsJoint.motorEquation.minForce = e === void 0 ? -e : e;
      }, n.prototype.syncMeshWithImpostor = function(t, e) {
        var i = e.physicsBody;
        t.position.x = i.position.x, t.position.y = i.position.y, t.position.z = i.position.z, t.rotationQuaternion && (t.rotationQuaternion.x = i.quaternion.x, t.rotationQuaternion.y = i.quaternion.y, t.rotationQuaternion.z = i.quaternion.z, t.rotationQuaternion.w = i.quaternion.w);
      }, n.prototype.getRadius = function(t) {
        return t.physicsBody.shapes[0].boundingSphereRadius;
      }, n.prototype.getBoxSizeToRef = function(t, e) {
        var i = t.physicsBody.shapes[0];
        e.x = 2 * i.halfExtents.x, e.y = 2 * i.halfExtents.y, e.z = 2 * i.halfExtents.z;
      }, n.prototype.dispose = function() {
      }, n.prototype._extendNamespace = function() {
        var t = new this.BJSCANNON.Vec3(), e = this.BJSCANNON;
        this.BJSCANNON.World.prototype.step = function(i, r, o) {
          if (o = o || 10, (r = r || 0) === 0)
            this.internalStep(i), this.time += i;
          else {
            var a = Math.floor((this.time + r) / i) - Math.floor(this.time / i);
            a = Math.min(a, o) || 1;
            for (var s = performance.now(), l = 0; l !== a && (this.internalStep(i), !(performance.now() - s > 1e3 * i)); l++)
              ;
            this.time += r;
            for (var c = this.time % i / i, u = t, h = this.bodies, d = 0; d !== h.length; d++) {
              var p = h[d];
              p.type !== e.Body.STATIC && p.sleepState !== e.Body.SLEEPING ? (p.position.vsub(p.previousPosition, u), u.scale(c, u), p.position.vadd(u, p.interpolatedPosition)) : (p.interpolatedPosition.set(p.position.x, p.position.y, p.position.z), p.interpolatedQuaternion.set(p.quaternion.x, p.quaternion.y, p.quaternion.z, p.quaternion.w));
            }
          }
        };
      }, n.prototype.raycast = function(t, e) {
        return this._raycastResult.reset(t, e), this.raycastToRef(t, e, this._raycastResult), this._raycastResult;
      }, n.prototype.raycastToRef = function(t, e, i) {
        this._cannonRaycastResult.reset(), this.world.raycastClosest(t, e, {}, this._cannonRaycastResult), i.reset(t, e), this._cannonRaycastResult.hasHit && (i.setHitData({ x: this._cannonRaycastResult.hitNormalWorld.x, y: this._cannonRaycastResult.hitNormalWorld.y, z: this._cannonRaycastResult.hitNormalWorld.z }, { x: this._cannonRaycastResult.hitPointWorld.x, y: this._cannonRaycastResult.hitPointWorld.y, z: this._cannonRaycastResult.hitPointWorld.z }), i.setHitDistance(this._cannonRaycastResult.distance));
      }, n;
    }();
    x_.DefaultPluginFactory = function() {
      return new td();
    };
    var A_ = function() {
      function n(t, e, i) {
        t === void 0 && (t = !0), i === void 0 && (i = OIMO), this._useDeltaForWorldStep = t, this.name = "OimoJSPlugin", this._fixedTimeStep = 1 / 60, this._tmpImpostorsArray = [], this._tmpPositionVector = v.Zero(), this.BJSOIMO = i, this.world = new this.BJSOIMO.World({ iterations: e }), this.world.clear(), this._raycastResult = new nu();
      }
      return n.prototype.getPluginVersion = function() {
        return 1;
      }, n.prototype.setGravity = function(t) {
        this.world.gravity.set(t.x, t.y, t.z);
      }, n.prototype.setTimeStep = function(t) {
        this.world.timeStep = t;
      }, n.prototype.getTimeStep = function() {
        return this.world.timeStep;
      }, n.prototype.executeStep = function(t, e) {
        var i = this;
        e.forEach(function(s) {
          s.beforeStep();
        }), this.world.timeStep = this._useDeltaForWorldStep ? t : this._fixedTimeStep, this.world.step(), e.forEach(function(s) {
          s.afterStep(), i._tmpImpostorsArray[s.uniqueId] = s;
        });
        for (var r = this.world.contacts; r !== null; )
          if (!r.touching || r.body1.sleeping || r.body2.sleeping) {
            var o = this._tmpImpostorsArray[+r.body1.name], a = this._tmpImpostorsArray[+r.body2.name];
            o && a && (o.onCollide({ body: a.physicsBody, point: null, distance: 0, impulse: 0, normal: null }), a.onCollide({ body: o.physicsBody, point: null, distance: 0, impulse: 0, normal: null })), r = r.next;
          } else
            r = r.next;
      }, n.prototype.applyImpulse = function(t, e, i) {
        var r = t.physicsBody.mass;
        t.physicsBody.applyImpulse(i.scale(this.world.invScale), e.scale(this.world.invScale * r));
      }, n.prototype.applyForce = function(t, e, i) {
        q.Warn("Oimo doesn't support applying force. Using impulse instead."), this.applyImpulse(t, e, i);
      }, n.prototype.generatePhysicsBody = function(t) {
        var e = this;
        if (t.parent)
          t.physicsBody && (this.removePhysicsBody(t), t.forceUpdate());
        else {
          if (t.isBodyInitRequired()) {
            var i = { name: t.uniqueId, config: [t.getParam("mass") || 1e-3, t.getParam("friction"), t.getParam("restitution")], size: [], type: [], pos: [], posShape: [], rot: [], rotShape: [], move: t.getParam("mass") !== 0, density: t.getParam("mass"), friction: t.getParam("friction"), restitution: t.getParam("restitution"), world: this.world }, r = [t];
            (s = t.object).getChildMeshes && s.getChildMeshes().forEach(function(l) {
              l.physicsImpostor && r.push(l.physicsImpostor);
            });
            var o = function(l) {
              return Math.max(l, Ge);
            }, a = new oe();
            r.forEach(function(l) {
              if (l.object.rotationQuaternion) {
                var c = l.object.rotationQuaternion;
                a.copyFrom(c), l.object.rotationQuaternion.set(0, 0, 0, 1), l.object.computeWorldMatrix(!0);
                var u = a.toEulerAngles(), h = l.getObjectExtents(), d = 57.29577951308232;
                if (l === t) {
                  var p = t.getObjectCenter();
                  t.object.getAbsolutePivotPoint().subtractToRef(p, e._tmpPositionVector), e._tmpPositionVector.divideInPlace(t.object.scaling), i.pos.push(p.x), i.pos.push(p.y), i.pos.push(p.z), i.posShape.push(0, 0, 0), i.rotShape.push(0, 0, 0);
                } else {
                  var f = l.object.position.clone();
                  i.posShape.push(f.x), i.posShape.push(f.y), i.posShape.push(f.z), i.rotShape.push(u.x * d, u.y * d, u.z * d);
                }
                switch (l.object.rotationQuaternion.copyFrom(a), l.type) {
                  case bt.ParticleImpostor:
                    q.Warn("No Particle support in OIMO.js. using SphereImpostor instead");
                  case bt.SphereImpostor:
                    var m = h.x, g = h.y, y = h.z, b = Math.max(o(m), o(g), o(y)) / 2;
                    i.type.push("sphere"), i.size.push(b), i.size.push(b), i.size.push(b);
                    break;
                  case bt.CylinderImpostor:
                    var T = o(h.x) / 2, S = o(h.y);
                    i.type.push("cylinder"), i.size.push(T), i.size.push(S), i.size.push(S);
                    break;
                  case bt.PlaneImpostor:
                  case bt.BoxImpostor:
                  default:
                    T = o(h.x), S = o(h.y);
                    var E = o(h.z);
                    i.type.push("box"), i.size.push(T), i.size.push(S), i.size.push(E);
                }
                l.object.rotationQuaternion = c;
              }
            }), t.physicsBody = this.world.add(i), t.physicsBody.resetQuaternion(a), t.physicsBody.updatePosition(0);
          } else
            this._tmpPositionVector.copyFromFloats(0, 0, 0);
          var s;
          t.setDeltaPosition(this._tmpPositionVector);
        }
      }, n.prototype.removePhysicsBody = function(t) {
        this.world.removeRigidBody(t.physicsBody);
      }, n.prototype.generateJoint = function(t) {
        var e = t.mainImpostor.physicsBody, i = t.connectedImpostor.physicsBody;
        if (e && i) {
          var r, o = t.joint.jointData, a = o.nativeParams || {}, s = { body1: e, body2: i, axe1: a.axe1 || (o.mainAxis ? o.mainAxis.asArray() : null), axe2: a.axe2 || (o.connectedAxis ? o.connectedAxis.asArray() : null), pos1: a.pos1 || (o.mainPivot ? o.mainPivot.asArray() : null), pos2: a.pos2 || (o.connectedPivot ? o.connectedPivot.asArray() : null), min: a.min, max: a.max, collision: a.collision || o.collision, spring: a.spring, world: this.world };
          switch (t.joint.type) {
            case Ii.BallAndSocketJoint:
              r = "jointBall";
              break;
            case Ii.SpringJoint:
              q.Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
              var l = o;
              s.min = l.length || s.min, s.max = Math.max(s.min, s.max);
            case Ii.DistanceJoint:
              r = "jointDistance", s.max = o.maxDistance;
              break;
            case Ii.PrismaticJoint:
              r = "jointPrisme";
              break;
            case Ii.SliderJoint:
              r = "jointSlide";
              break;
            case Ii.WheelJoint:
              r = "jointWheel";
              break;
            case Ii.HingeJoint:
            default:
              r = "jointHinge";
          }
          s.type = r, t.joint.physicsJoint = this.world.add(s);
        }
      }, n.prototype.removeJoint = function(t) {
        try {
          this.world.removeJoint(t.joint.physicsJoint);
        } catch (e) {
          q.Warn(e);
        }
      }, n.prototype.isSupported = function() {
        return this.BJSOIMO !== void 0;
      }, n.prototype.setTransformationFromPhysicsBody = function(t) {
        if (!t.physicsBody.sleeping) {
          if (t.physicsBody.shapes.next) {
            for (var e = t.physicsBody.shapes; e.next; )
              e = e.next;
            t.object.position.set(e.position.x, e.position.y, e.position.z);
          } else {
            var i = t.physicsBody.getPosition();
            t.object.position.set(i.x, i.y, i.z);
          }
          if (t.object.rotationQuaternion) {
            var r = t.physicsBody.getQuaternion();
            t.object.rotationQuaternion.set(r.x, r.y, r.z, r.w);
          }
        }
      }, n.prototype.setPhysicsBodyTransformation = function(t, e, i) {
        var r = t.physicsBody;
        t.physicsBody.shapes.next || (r.position.set(e.x, e.y, e.z), r.orientation.set(i.x, i.y, i.z, i.w), r.syncShapes(), r.awake());
      }, n.prototype.setLinearVelocity = function(t, e) {
        t.physicsBody.linearVelocity.set(e.x, e.y, e.z);
      }, n.prototype.setAngularVelocity = function(t, e) {
        t.physicsBody.angularVelocity.set(e.x, e.y, e.z);
      }, n.prototype.getLinearVelocity = function(t) {
        var e = t.physicsBody.linearVelocity;
        return e ? new v(e.x, e.y, e.z) : null;
      }, n.prototype.getAngularVelocity = function(t) {
        var e = t.physicsBody.angularVelocity;
        return e ? new v(e.x, e.y, e.z) : null;
      }, n.prototype.setBodyMass = function(t, e) {
        var i = e === 0;
        t.physicsBody.shapes.density = i ? 1 : e, t.physicsBody.setupMass(i ? 2 : 1);
      }, n.prototype.getBodyMass = function(t) {
        return t.physicsBody.shapes.density;
      }, n.prototype.getBodyFriction = function(t) {
        return t.physicsBody.shapes.friction;
      }, n.prototype.setBodyFriction = function(t, e) {
        t.physicsBody.shapes.friction = e;
      }, n.prototype.getBodyRestitution = function(t) {
        return t.physicsBody.shapes.restitution;
      }, n.prototype.setBodyRestitution = function(t, e) {
        t.physicsBody.shapes.restitution = e;
      }, n.prototype.sleepBody = function(t) {
        t.physicsBody.sleep();
      }, n.prototype.wakeUpBody = function(t) {
        t.physicsBody.awake();
      }, n.prototype.updateDistanceJoint = function(t, e, i) {
        t.physicsJoint.limitMotor.upperLimit = e, i !== void 0 && (t.physicsJoint.limitMotor.lowerLimit = i);
      }, n.prototype.setMotor = function(t, e, i, r) {
        i !== void 0 ? q.Warn("OimoJS plugin currently has unexpected behavior when using setMotor with force parameter") : i = 1e6, e *= -1;
        var o = r ? t.physicsJoint.rotationalLimitMotor2 : t.physicsJoint.rotationalLimitMotor1 || t.physicsJoint.rotationalLimitMotor || t.physicsJoint.limitMotor;
        o && o.setMotor(e, i);
      }, n.prototype.setLimit = function(t, e, i, r) {
        var o = r ? t.physicsJoint.rotationalLimitMotor2 : t.physicsJoint.rotationalLimitMotor1 || t.physicsJoint.rotationalLimitMotor || t.physicsJoint.limitMotor;
        o && o.setLimit(e, i === void 0 ? -e : i);
      }, n.prototype.syncMeshWithImpostor = function(t, e) {
        var i = e.physicsBody;
        t.position.x = i.position.x, t.position.y = i.position.y, t.position.z = i.position.z, t.rotationQuaternion && (t.rotationQuaternion.x = i.orientation.x, t.rotationQuaternion.y = i.orientation.y, t.rotationQuaternion.z = i.orientation.z, t.rotationQuaternion.w = i.orientation.w);
      }, n.prototype.getRadius = function(t) {
        return t.physicsBody.shapes.radius;
      }, n.prototype.getBoxSizeToRef = function(t, e) {
        var i = t.physicsBody.shapes;
        e.x = 2 * i.halfWidth, e.y = 2 * i.halfHeight, e.z = 2 * i.halfDepth;
      }, n.prototype.dispose = function() {
        this.world.clear();
      }, n.prototype.raycast = function(t, e) {
        return q.Warn("raycast is not currently supported by the Oimo physics plugin"), this._raycastResult.reset(t, e), this._raycastResult;
      }, n.prototype.raycastToRef = function(t, e, i) {
        q.Warn("raycast is not currently supported by the Oimo physics plugin"), i.reset(t, e);
      }, n;
    }(), R_ = function() {
      function n(t, e, i) {
        t === void 0 && (t = !0), e === void 0 && (e = Ammo), i === void 0 && (i = null);
        var r = this;
        this._useDeltaForWorldStep = t, this.bjsAMMO = {}, this.name = "AmmoJSPlugin", this._timeStep = 1 / 60, this._fixedTimeStep = 1 / 60, this._maxSteps = 5, this._tmpQuaternion = new oe(), this._tmpContactCallbackResult = !1, this._tmpContactPoint = new v(), this._tmpContactNormal = new v(), this._tmpVec3 = new v(), this._tmpMatrix = new B(), typeof e != "function" ? (this.bjsAMMO = e, this.isSupported() ? (this._collisionConfiguration = new this.bjsAMMO.btSoftBodyRigidBodyCollisionConfiguration(), this._dispatcher = new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration), this._overlappingPairCache = i || new this.bjsAMMO.btDbvtBroadphase(), this._solver = new this.bjsAMMO.btSequentialImpulseConstraintSolver(), this._softBodySolver = new this.bjsAMMO.btDefaultSoftBodySolver(), this.world = new this.bjsAMMO.btSoftRigidDynamicsWorld(this._dispatcher, this._overlappingPairCache, this._solver, this._collisionConfiguration, this._softBodySolver), this._tmpAmmoConcreteContactResultCallback = new this.bjsAMMO.ConcreteContactResultCallback(), this._tmpAmmoConcreteContactResultCallback.addSingleResult = function(o) {
          var a = (o = r.bjsAMMO.wrapPointer(o, r.bjsAMMO.btManifoldPoint)).getPositionWorldOnA(), s = o.m_normalWorldOnB;
          r._tmpContactPoint.x = a.x(), r._tmpContactPoint.y = a.y(), r._tmpContactPoint.z = a.z(), r._tmpContactNormal.x = s.x(), r._tmpContactNormal.y = s.y(), r._tmpContactNormal.z = s.z(), r._tmpContactImpulse = o.getAppliedImpulse(), r._tmpContactDistance = o.getDistance(), r._tmpContactCallbackResult = !0;
        }, this._raycastResult = new nu(), this._tmpAmmoTransform = new this.bjsAMMO.btTransform(), this._tmpAmmoTransform.setIdentity(), this._tmpAmmoQuaternion = new this.bjsAMMO.btQuaternion(0, 0, 0, 1), this._tmpAmmoVectorA = new this.bjsAMMO.btVector3(0, 0, 0), this._tmpAmmoVectorB = new this.bjsAMMO.btVector3(0, 0, 0), this._tmpAmmoVectorC = new this.bjsAMMO.btVector3(0, 0, 0), this._tmpAmmoVectorD = new this.bjsAMMO.btVector3(0, 0, 0)) : q.Error("AmmoJS is not available. Please make sure you included the js file.")) : q.Error("AmmoJS is not ready. Please make sure you await Ammo() before using the plugin.");
      }
      return n.prototype.getPluginVersion = function() {
        return 1;
      }, n.prototype.setGravity = function(t) {
        this._tmpAmmoVectorA.setValue(t.x, t.y, t.z), this.world.setGravity(this._tmpAmmoVectorA), this.world.getWorldInfo().set_m_gravity(this._tmpAmmoVectorA);
      }, n.prototype.setTimeStep = function(t) {
        this._timeStep = t;
      }, n.prototype.setFixedTimeStep = function(t) {
        this._fixedTimeStep = t;
      }, n.prototype.setMaxSteps = function(t) {
        this._maxSteps = t;
      }, n.prototype.getTimeStep = function() {
        return this._timeStep;
      }, n.prototype._isImpostorInContact = function(t) {
        return this._tmpContactCallbackResult = !1, this.world.contactTest(t.physicsBody, this._tmpAmmoConcreteContactResultCallback), this._tmpContactCallbackResult;
      }, n.prototype._isImpostorPairInContact = function(t, e) {
        return this._tmpContactCallbackResult = !1, this.world.contactPairTest(t.physicsBody, e.physicsBody, this._tmpAmmoConcreteContactResultCallback), this._tmpContactCallbackResult;
      }, n.prototype._stepSimulation = function(t, e, i) {
        if (t === void 0 && (t = 1 / 60), e === void 0 && (e = 10), i === void 0 && (i = 1 / 60), e == 0)
          this.world.stepSimulation(t, 0);
        else
          for (; e > 0 && t > 0; )
            t - i < i ? (this.world.stepSimulation(t, 0), t = 0) : (t -= i, this.world.stepSimulation(i, 0)), e--;
      }, n.prototype.executeStep = function(t, e) {
        for (var i = 0, r = e; i < r.length; i++) {
          var o = r[i];
          o.soft || o.beforeStep();
        }
        this._stepSimulation(this._useDeltaForWorldStep ? t : this._timeStep, this._maxSteps, this._fixedTimeStep);
        for (var a = 0, s = e; a < s.length; a++) {
          var l = s[a];
          if (l.soft ? this._afterSoftStep(l) : l.afterStep(), l._onPhysicsCollideCallbacks.length > 0 && this._isImpostorInContact(l))
            for (var c = 0, u = l._onPhysicsCollideCallbacks; c < u.length; c++)
              for (var h = 0, d = u[c].otherImpostors; h < d.length; h++) {
                var p = d[h];
                (l.physicsBody.isActive() || p.physicsBody.isActive()) && this._isImpostorPairInContact(l, p) && (l.onCollide({ body: p.physicsBody, point: this._tmpContactPoint, distance: this._tmpContactDistance, impulse: this._tmpContactImpulse, normal: this._tmpContactNormal }), p.onCollide({ body: l.physicsBody, point: this._tmpContactPoint, distance: this._tmpContactDistance, impulse: this._tmpContactImpulse, normal: this._tmpContactNormal }));
              }
        }
      }, n.prototype._afterSoftStep = function(t) {
        t.type === bt.RopeImpostor ? this._ropeStep(t) : this._softbodyOrClothStep(t);
      }, n.prototype._ropeStep = function(t) {
        for (var e, i, r, o, a = t.physicsBody.get_m_nodes(), s = a.size(), l = new Array(), c = 0; c < s; c++)
          i = (e = a.at(c).get_m_x()).x(), r = e.y(), o = e.z(), l.push(new v(i, r, o));
        var u = t.object, h = t.getParam("shape");
        t._isFromLine ? t.object = si("lines", { points: l, instance: u }) : t.object = Dc("ext", { shape: h, path: l, instance: u });
      }, n.prototype._softbodyOrClothStep = function(t) {
        var e = t.type === bt.ClothImpostor ? 1 : -1, i = t.object, r = i.getVerticesData(P.PositionKind);
        r || (r = []);
        var o = i.getVerticesData(P.NormalKind);
        o || (o = []);
        for (var a, s, l, c, u, h, d, p, f = r.length / 3, m = t.physicsBody.get_m_nodes(), g = 0; g < f; g++) {
          l = (s = (a = m.at(g)).get_m_x()).x(), c = s.y(), u = s.z() * e;
          var y = a.get_m_n();
          h = y.x(), d = y.y(), p = y.z() * e, r[3 * g] = l, r[3 * g + 1] = c, r[3 * g + 2] = u, o[3 * g] = h, o[3 * g + 1] = d, o[3 * g + 2] = p;
        }
        var b = new Oe();
        b.positions = r, b.normals = o, b.uvs = i.getVerticesData(P.UVKind), b.colors = i.getVerticesData(P.ColorKind), i && i.getIndices && (b.indices = i.getIndices()), b.applyToMesh(i);
      }, n.prototype.applyImpulse = function(t, e, i) {
        if (t.soft)
          q.Warn("Cannot be applied to a soft body");
        else {
          t.physicsBody.activate();
          var r = this._tmpAmmoVectorA, o = this._tmpAmmoVectorB;
          t.object && t.object.getWorldMatrix && i.subtractInPlace(t.object.getWorldMatrix().getTranslation()), r.setValue(i.x, i.y, i.z), o.setValue(e.x, e.y, e.z), t.physicsBody.applyImpulse(o, r);
        }
      }, n.prototype.applyForce = function(t, e, i) {
        if (t.soft)
          q.Warn("Cannot be applied to a soft body");
        else {
          t.physicsBody.activate();
          var r = this._tmpAmmoVectorA, o = this._tmpAmmoVectorB;
          if (t.object && t.object.getWorldMatrix) {
            var a = t.object.getWorldMatrix().getTranslation();
            r.setValue(i.x - a.x, i.y - a.y, i.z - a.z);
          } else
            r.setValue(i.x, i.y, i.z);
          o.setValue(e.x, e.y, e.z), t.physicsBody.applyForce(o, r);
        }
      }, n.prototype.generatePhysicsBody = function(t) {
        if (t._pluginData.toDispose = [], t.parent)
          t.physicsBody && (this.removePhysicsBody(t), t.forceUpdate());
        else if (t.isBodyInitRequired()) {
          var e = this._createShape(t), i = t.getParam("mass");
          if (t._pluginData.mass = i, t.soft)
            e.get_m_cfg().set_collisions(17), e.get_m_cfg().set_kDP(t.getParam("damping")), this.bjsAMMO.castObject(e, this.bjsAMMO.btCollisionObject).getCollisionShape().setMargin(t.getParam("margin")), e.setActivationState(n._DISABLE_DEACTIVATION_FLAG), this.world.addSoftBody(e, 1, -1), t.physicsBody = e, t._pluginData.toDispose.push(e), this.setBodyPressure(t, 0), t.type === bt.SoftbodyImpostor && this.setBodyPressure(t, t.getParam("pressure")), this.setBodyStiffness(t, t.getParam("stiffness")), this.setBodyVelocityIterations(t, t.getParam("velocityIterations")), this.setBodyPositionIterations(t, t.getParam("positionIterations"));
          else {
            var r = new this.bjsAMMO.btVector3(0, 0, 0), o = new this.bjsAMMO.btTransform();
            t.object.computeWorldMatrix(!0), o.setIdentity(), i !== 0 && e.calculateLocalInertia(i, r), this._tmpAmmoVectorA.setValue(t.object.position.x, t.object.position.y, t.object.position.z), this._tmpAmmoQuaternion.setValue(t.object.rotationQuaternion.x, t.object.rotationQuaternion.y, t.object.rotationQuaternion.z, t.object.rotationQuaternion.w), o.setOrigin(this._tmpAmmoVectorA), o.setRotation(this._tmpAmmoQuaternion);
            var a = new this.bjsAMMO.btDefaultMotionState(o), s = new this.bjsAMMO.btRigidBodyConstructionInfo(i, a, e, r), l = new this.bjsAMMO.btRigidBody(s);
            if (i === 0 && (l.setCollisionFlags(l.getCollisionFlags() | n._KINEMATIC_FLAG), l.setActivationState(n._DISABLE_DEACTIVATION_FLAG)), t.type != bt.NoImpostor || e.getChildShape || l.setCollisionFlags(l.getCollisionFlags() | n._DISABLE_COLLISION_FLAG), t.type !== bt.MeshImpostor && t.type !== bt.NoImpostor) {
              var c = t.object.getBoundingInfo();
              this._tmpVec3.copyFrom(t.object.getAbsolutePosition()), this._tmpVec3.subtractInPlace(c.boundingBox.centerWorld), this._tmpVec3.x /= t.object.scaling.x, this._tmpVec3.y /= t.object.scaling.y, this._tmpVec3.z /= t.object.scaling.z, t.setDeltaPosition(this._tmpVec3);
            }
            var u = t.getParam("group"), h = t.getParam("mask");
            u && h ? this.world.addRigidBody(l, u, h) : this.world.addRigidBody(l), t.physicsBody = l, t._pluginData.toDispose = t._pluginData.toDispose.concat([l, s, a, o, r, e]);
          }
          this.setBodyRestitution(t, t.getParam("restitution")), this.setBodyFriction(t, t.getParam("friction"));
        }
      }, n.prototype.removePhysicsBody = function(t) {
        var e = this;
        this.world && (t.soft ? this.world.removeSoftBody(t.physicsBody) : this.world.removeRigidBody(t.physicsBody), t._pluginData && (t._pluginData.toDispose.forEach(function(i) {
          e.bjsAMMO.destroy(i);
        }), t._pluginData.toDispose = []));
      }, n.prototype.generateJoint = function(t) {
        var e = t.mainImpostor.physicsBody, i = t.connectedImpostor.physicsBody;
        if (e && i) {
          var r, o = t.joint.jointData;
          switch (o.mainPivot || (o.mainPivot = new v(0, 0, 0)), o.connectedPivot || (o.connectedPivot = new v(0, 0, 0)), t.joint.type) {
            case Ii.DistanceJoint:
              var a = o.maxDistance;
              a && (o.mainPivot = new v(0, -a / 2, 0), o.connectedPivot = new v(0, a / 2, 0)), r = new this.bjsAMMO.btPoint2PointConstraint(e, i, new this.bjsAMMO.btVector3(o.mainPivot.x, o.mainPivot.y, o.mainPivot.z), new this.bjsAMMO.btVector3(o.connectedPivot.x, o.connectedPivot.y, o.connectedPivot.z));
              break;
            case Ii.HingeJoint:
              o.mainAxis || (o.mainAxis = new v(0, 0, 0)), o.connectedAxis || (o.connectedAxis = new v(0, 0, 0));
              var s = new this.bjsAMMO.btVector3(o.mainAxis.x, o.mainAxis.y, o.mainAxis.z), l = new this.bjsAMMO.btVector3(o.connectedAxis.x, o.connectedAxis.y, o.connectedAxis.z);
              r = new this.bjsAMMO.btHingeConstraint(e, i, new this.bjsAMMO.btVector3(o.mainPivot.x, o.mainPivot.y, o.mainPivot.z), new this.bjsAMMO.btVector3(o.connectedPivot.x, o.connectedPivot.y, o.connectedPivot.z), s, l);
              break;
            case Ii.BallAndSocketJoint:
              r = new this.bjsAMMO.btPoint2PointConstraint(e, i, new this.bjsAMMO.btVector3(o.mainPivot.x, o.mainPivot.y, o.mainPivot.z), new this.bjsAMMO.btVector3(o.connectedPivot.x, o.connectedPivot.y, o.connectedPivot.z));
              break;
            default:
              q.Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint"), r = new this.bjsAMMO.btPoint2PointConstraint(e, i, new this.bjsAMMO.btVector3(o.mainPivot.x, o.mainPivot.y, o.mainPivot.z), new this.bjsAMMO.btVector3(o.connectedPivot.x, o.connectedPivot.y, o.connectedPivot.z));
          }
          this.world.addConstraint(r, !t.joint.jointData.collision), t.joint.physicsJoint = r;
        }
      }, n.prototype.removeJoint = function(t) {
        this.world && this.world.removeConstraint(t.joint.physicsJoint);
      }, n.prototype._addMeshVerts = function(t, e, i) {
        var r = this, o = 0;
        if (i && i.getIndices && i.getWorldMatrix && i.getChildMeshes) {
          var a = i.getIndices();
          a || (a = []);
          var s = i.getVerticesData(P.PositionKind);
          s || (s = []);
          var l = void 0;
          if (e && e !== i) {
            var c;
            c = e.rotationQuaternion ? e.rotationQuaternion : e.rotation ? oe.FromEulerAngles(e.rotation.x, e.rotation.y, e.rotation.z) : oe.Identity(), B.Compose(v.One(), c, e.position).invertToRef(this._tmpMatrix), l = i.computeWorldMatrix(!1).multiply(this._tmpMatrix);
          } else
            B.ScalingToRef(i.scaling.x, i.scaling.y, i.scaling.z, this._tmpMatrix), l = this._tmpMatrix;
          for (var u = a.length / 3, h = 0; h < u; h++) {
            for (var d = [], p = 0; p < 3; p++) {
              var f = new v(s[3 * a[3 * h + p] + 0], s[3 * a[3 * h + p] + 1], s[3 * a[3 * h + p] + 2]);
              f = v.TransformCoordinates(f, l);
              var m = void 0;
              (m = p == 0 ? this._tmpAmmoVectorA : p == 1 ? this._tmpAmmoVectorB : this._tmpAmmoVectorC).setValue(f.x, f.y, f.z), d.push(m);
            }
            t.addTriangle(d[0], d[1], d[2]), o++;
          }
          i.getChildMeshes().forEach(function(g) {
            o += r._addMeshVerts(t, e, g);
          });
        }
        return o;
      }, n.prototype._softVertexData = function(t) {
        var e = t.object;
        if (e && e.getIndices && e.getWorldMatrix && e.getChildMeshes) {
          e.getIndices();
          var i = e.getVerticesData(P.PositionKind);
          i || (i = []);
          var r = e.getVerticesData(P.NormalKind);
          r || (r = []), e.computeWorldMatrix(!1);
          for (var o = [], a = [], s = 0; s < i.length; s += 3) {
            var l = new v(i[s], i[s + 1], i[s + 2]), c = new v(r[s], r[s + 1], r[s + 2]);
            l = v.TransformCoordinates(l, e.getWorldMatrix()), c = v.TransformNormal(c, e.getWorldMatrix()), o.push(l.x, l.y, l.z), a.push(c.x, c.y, c.z);
          }
          var u = new Oe();
          return u.positions = o, u.normals = a, u.uvs = e.getVerticesData(P.UVKind), u.colors = e.getVerticesData(P.ColorKind), e && e.getIndices && (u.indices = e.getIndices()), u.applyToMesh(e), e.position = v.Zero(), e.rotationQuaternion = null, e.rotation = v.Zero(), e.computeWorldMatrix(!0), u;
        }
        return Oe.ExtractFromMesh(e);
      }, n.prototype._createSoftbody = function(t) {
        var e = t.object;
        if (e && e.getIndices) {
          var i = e.getIndices();
          i || (i = []);
          var r = this._softVertexData(t), o = r.positions, a = r.normals;
          if (o === null || a === null)
            return new this.bjsAMMO.btCompoundShape();
          for (var s = [], l = [], c = 0; c < o.length; c += 3) {
            var u = new v(o[c], o[c + 1], o[c + 2]), h = new v(a[c], a[c + 1], a[c + 2]);
            s.push(u.x, u.y, -u.z), l.push(h.x, h.y, -h.z);
          }
          var d = new this.bjsAMMO.btSoftBodyHelpers().CreateFromTriMesh(this.world.getWorldInfo(), s, e.getIndices(), i.length / 3, !0), p = o.length / 3, f = d.get_m_nodes(), m = void 0;
          for (c = 0; c < p; c++)
            (m = f.at(c).get_m_n()).setX(l[3 * c]), m.setY(l[3 * c + 1]), m.setZ(l[3 * c + 2]);
          return d;
        }
      }, n.prototype._createCloth = function(t) {
        var e = t.object;
        if (e && e.getIndices) {
          e.getIndices();
          var i = this._softVertexData(t), r = i.positions, o = i.normals;
          if (r === null || o === null)
            return new this.bjsAMMO.btCompoundShape();
          var a = r.length, s = Math.sqrt(a / 3);
          t.segments = s;
          var l = s - 1;
          return this._tmpAmmoVectorA.setValue(r[0], r[1], r[2]), this._tmpAmmoVectorB.setValue(r[3 * l], r[3 * l + 1], r[3 * l + 2]), this._tmpAmmoVectorD.setValue(r[a - 3], r[a - 2], r[a - 1]), this._tmpAmmoVectorC.setValue(r[a - 3 - 3 * l], r[a - 2 - 3 * l], r[a - 1 - 3 * l]), new this.bjsAMMO.btSoftBodyHelpers().CreatePatch(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, this._tmpAmmoVectorC, this._tmpAmmoVectorD, s, s, t.getParam("fixedPoints"), !0);
        }
      }, n.prototype._createRope = function(t) {
        var e, i, r = this._softVertexData(t), o = r.positions, a = r.normals;
        if (o === null || a === null)
          return new this.bjsAMMO.btCompoundShape();
        if (r.applyToMesh(t.object, !0), t._isFromLine = !0, a.map(function(u) {
          return u * u;
        }).reduce(function(u, h) {
          return u + h;
        }) === 0)
          i = (e = o.length) / 3 - 1, this._tmpAmmoVectorA.setValue(o[0], o[1], o[2]), this._tmpAmmoVectorB.setValue(o[e - 3], o[e - 2], o[e - 1]);
        else {
          t._isFromLine = !1;
          var s = t.getParam("path");
          if (t.getParam("shape") === null)
            return q.Warn("No shape available for extruded mesh"), new this.bjsAMMO.btCompoundShape();
          i = (e = s.length) - 1, this._tmpAmmoVectorA.setValue(s[0].x, s[0].y, s[0].z), this._tmpAmmoVectorB.setValue(s[e - 1].x, s[e - 1].y, s[e - 1].z);
        }
        t.segments = i;
        var l = t.getParam("fixedPoints");
        l = l > 3 ? 3 : l;
        var c = new this.bjsAMMO.btSoftBodyHelpers().CreateRope(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, i - 1, l);
        return c.get_m_cfg().set_collisions(17), c;
      }, n.prototype._createCustom = function(t) {
        var e = null;
        return this.onCreateCustomShape && (e = this.onCreateCustomShape(t)), e == null && (e = new this.bjsAMMO.btCompoundShape()), e;
      }, n.prototype._addHullVerts = function(t, e, i) {
        var r = this, o = 0;
        if (i && i.getIndices && i.getWorldMatrix && i.getChildMeshes) {
          var a = i.getIndices();
          a || (a = []);
          var s = i.getVerticesData(P.PositionKind);
          s || (s = []), i.computeWorldMatrix(!1);
          for (var l = a.length / 3, c = 0; c < l; c++) {
            for (var u = [], h = 0; h < 3; h++) {
              var d = new v(s[3 * a[3 * c + h] + 0], s[3 * a[3 * c + h] + 1], s[3 * a[3 * c + h] + 2]);
              B.ScalingToRef(i.scaling.x, i.scaling.y, i.scaling.z, this._tmpMatrix), d = v.TransformCoordinates(d, this._tmpMatrix);
              var p = void 0;
              (p = h == 0 ? this._tmpAmmoVectorA : h == 1 ? this._tmpAmmoVectorB : this._tmpAmmoVectorC).setValue(d.x, d.y, d.z), u.push(p);
            }
            t.addPoint(u[0], !0), t.addPoint(u[1], !0), t.addPoint(u[2], !0), o++;
          }
          i.getChildMeshes().forEach(function(f) {
            o += r._addHullVerts(t, e, f);
          });
        }
        return o;
      }, n.prototype._createShape = function(t, e) {
        var i = this;
        e === void 0 && (e = !1);
        var r, o = t.object, a = t.getObjectExtents();
        if (!e) {
          var s = t.object.getChildMeshes ? t.object.getChildMeshes(!0) : [];
          r = new this.bjsAMMO.btCompoundShape();
          var l = 0;
          if (s.forEach(function(m) {
            var g = m.getPhysicsImpostor();
            if (g) {
              if (g.type == bt.MeshImpostor)
                throw "A child MeshImpostor is not supported. Only primitive impostors are supported as children (eg. box or sphere)";
              var y = i._createShape(g), b = m.parent.getWorldMatrix().clone(), T = new v();
              b.decompose(T), i._tmpAmmoTransform.getOrigin().setValue(m.position.x * T.x, m.position.y * T.y, m.position.z * T.z), i._tmpAmmoQuaternion.setValue(m.rotationQuaternion.x, m.rotationQuaternion.y, m.rotationQuaternion.z, m.rotationQuaternion.w), i._tmpAmmoTransform.setRotation(i._tmpAmmoQuaternion), r.addChildShape(i._tmpAmmoTransform, y), g.dispose(), l++;
            }
          }), l > 0) {
            if (t.type != bt.NoImpostor) {
              var c = this._createShape(t, !0);
              c && (this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0), this._tmpAmmoQuaternion.setValue(0, 0, 0, 1), this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion), r.addChildShape(this._tmpAmmoTransform, c));
            }
            return r;
          }
          this.bjsAMMO.destroy(r), r = null;
        }
        switch (t.type) {
          case bt.SphereImpostor:
            if (ue.WithinEpsilon(a.x, a.y, 1e-4) && ue.WithinEpsilon(a.x, a.z, 1e-4))
              r = new this.bjsAMMO.btSphereShape(a.x / 2);
            else {
              var u = [new this.bjsAMMO.btVector3(0, 0, 0)];
              (r = new this.bjsAMMO.btMultiSphereShape(u, [1], 1)).setLocalScaling(new this.bjsAMMO.btVector3(a.x / 2, a.y / 2, a.z / 2));
            }
            break;
          case bt.CapsuleImpostor:
            var h = a.x / 2;
            r = new this.bjsAMMO.btCapsuleShape(h, a.y - 2 * h);
            break;
          case bt.CylinderImpostor:
            this._tmpAmmoVectorA.setValue(a.x / 2, a.y / 2, a.z / 2), r = new this.bjsAMMO.btCylinderShape(this._tmpAmmoVectorA);
            break;
          case bt.PlaneImpostor:
          case bt.BoxImpostor:
            this._tmpAmmoVectorA.setValue(a.x / 2, a.y / 2, a.z / 2), r = new this.bjsAMMO.btBoxShape(this._tmpAmmoVectorA);
            break;
          case bt.MeshImpostor:
            if (t.getParam("mass") == 0) {
              if (this.onCreateCustomMeshImpostor)
                r = this.onCreateCustomMeshImpostor(t);
              else {
                var d = new this.bjsAMMO.btTriangleMesh();
                t._pluginData.toDispose.push(d);
                var p = this._addMeshVerts(d, o, o);
                r = p == 0 ? new this.bjsAMMO.btCompoundShape() : new this.bjsAMMO.btBvhTriangleMeshShape(d);
              }
              break;
            }
          case bt.ConvexHullImpostor:
            if (this.onCreateCustomConvexHullImpostor)
              r = this.onCreateCustomConvexHullImpostor(t);
            else {
              var f = new this.bjsAMMO.btConvexHullShape();
              (p = this._addHullVerts(f, o, o)) == 0 ? (t._pluginData.toDispose.push(f), r = new this.bjsAMMO.btCompoundShape()) : r = f;
            }
            break;
          case bt.NoImpostor:
            r = new this.bjsAMMO.btSphereShape(a.x / 2);
            break;
          case bt.CustomImpostor:
            r = this._createCustom(t);
            break;
          case bt.SoftbodyImpostor:
            r = this._createSoftbody(t);
            break;
          case bt.ClothImpostor:
            r = this._createCloth(t);
            break;
          case bt.RopeImpostor:
            r = this._createRope(t);
            break;
          default:
            q.Warn("The impostor type is not currently supported by the ammo plugin.");
        }
        return r;
      }, n.prototype.setTransformationFromPhysicsBody = function(t) {
        t.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform), t.object.position.set(this._tmpAmmoTransform.getOrigin().x(), this._tmpAmmoTransform.getOrigin().y(), this._tmpAmmoTransform.getOrigin().z()), t.object.rotationQuaternion ? t.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w()) : t.object.rotation && (this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w()), this._tmpQuaternion.toEulerAnglesToRef(t.object.rotation));
      }, n.prototype.setPhysicsBodyTransformation = function(t, e, i) {
        var r = t.physicsBody.getWorldTransform();
        if (Math.abs(r.getOrigin().x() - e.x) > Ge || Math.abs(r.getOrigin().y() - e.y) > Ge || Math.abs(r.getOrigin().z() - e.z) > Ge || Math.abs(r.getRotation().x() - i.x) > Ge || Math.abs(r.getRotation().y() - i.y) > Ge || Math.abs(r.getRotation().z() - i.z) > Ge || Math.abs(r.getRotation().w() - i.w) > Ge)
          if (this._tmpAmmoVectorA.setValue(e.x, e.y, e.z), r.setOrigin(this._tmpAmmoVectorA), this._tmpAmmoQuaternion.setValue(i.x, i.y, i.z, i.w), r.setRotation(this._tmpAmmoQuaternion), t.physicsBody.setWorldTransform(r), t.mass == 0) {
            var o = t.physicsBody.getMotionState();
            o && o.setWorldTransform(r);
          } else
            t.physicsBody.activate();
      }, n.prototype.isSupported = function() {
        return this.bjsAMMO !== void 0;
      }, n.prototype.setLinearVelocity = function(t, e) {
        this._tmpAmmoVectorA.setValue(e.x, e.y, e.z), t.soft ? t.physicsBody.linearVelocity(this._tmpAmmoVectorA) : t.physicsBody.setLinearVelocity(this._tmpAmmoVectorA);
      }, n.prototype.setAngularVelocity = function(t, e) {
        this._tmpAmmoVectorA.setValue(e.x, e.y, e.z), t.soft ? t.physicsBody.angularVelocity(this._tmpAmmoVectorA) : t.physicsBody.setAngularVelocity(this._tmpAmmoVectorA);
      }, n.prototype.getLinearVelocity = function(t) {
        var e;
        if (!(e = t.soft ? t.physicsBody.linearVelocity() : t.physicsBody.getLinearVelocity()))
          return null;
        var i = new v(e.x(), e.y(), e.z());
        return this.bjsAMMO.destroy(e), i;
      }, n.prototype.getAngularVelocity = function(t) {
        var e;
        if (!(e = t.soft ? t.physicsBody.angularVelocity() : t.physicsBody.getAngularVelocity()))
          return null;
        var i = new v(e.x(), e.y(), e.z());
        return this.bjsAMMO.destroy(e), i;
      }, n.prototype.setBodyMass = function(t, e) {
        t.soft ? t.physicsBody.setTotalMass(e, !1) : t.physicsBody.setMassProps(e), t._pluginData.mass = e;
      }, n.prototype.getBodyMass = function(t) {
        return t._pluginData.mass || 0;
      }, n.prototype.getBodyFriction = function(t) {
        return t._pluginData.friction || 0;
      }, n.prototype.setBodyFriction = function(t, e) {
        t.soft ? t.physicsBody.get_m_cfg().set_kDF(e) : t.physicsBody.setFriction(e), t._pluginData.friction = e;
      }, n.prototype.getBodyRestitution = function(t) {
        return t._pluginData.restitution || 0;
      }, n.prototype.setBodyRestitution = function(t, e) {
        t.physicsBody.setRestitution(e), t._pluginData.restitution = e;
      }, n.prototype.getBodyPressure = function(t) {
        return t.soft ? t._pluginData.pressure || 0 : (q.Warn("Pressure is not a property of a rigid body"), 0);
      }, n.prototype.setBodyPressure = function(t, e) {
        t.soft ? t.type === bt.SoftbodyImpostor ? (t.physicsBody.get_m_cfg().set_kPR(e), t._pluginData.pressure = e) : (t.physicsBody.get_m_cfg().set_kPR(0), t._pluginData.pressure = 0) : q.Warn("Pressure can only be applied to a softbody");
      }, n.prototype.getBodyStiffness = function(t) {
        return t.soft ? t._pluginData.stiffness || 0 : (q.Warn("Stiffness is not a property of a rigid body"), 0);
      }, n.prototype.setBodyStiffness = function(t, e) {
        t.soft ? (e = (e = e < 0 ? 0 : e) > 1 ? 1 : e, t.physicsBody.get_m_materials().at(0).set_m_kLST(e), t._pluginData.stiffness = e) : q.Warn("Stiffness cannot be applied to a rigid body");
      }, n.prototype.getBodyVelocityIterations = function(t) {
        return t.soft ? t._pluginData.velocityIterations || 0 : (q.Warn("Velocity iterations is not a property of a rigid body"), 0);
      }, n.prototype.setBodyVelocityIterations = function(t, e) {
        t.soft ? (e = e < 0 ? 0 : e, t.physicsBody.get_m_cfg().set_viterations(e), t._pluginData.velocityIterations = e) : q.Warn("Velocity iterations cannot be applied to a rigid body");
      }, n.prototype.getBodyPositionIterations = function(t) {
        return t.soft ? t._pluginData.positionIterations || 0 : (q.Warn("Position iterations is not a property of a rigid body"), 0);
      }, n.prototype.setBodyPositionIterations = function(t, e) {
        t.soft ? (e = e < 0 ? 0 : e, t.physicsBody.get_m_cfg().set_piterations(e), t._pluginData.positionIterations = e) : q.Warn("Position iterations cannot be applied to a rigid body");
      }, n.prototype.appendAnchor = function(t, e, i, r, o, a) {
        o === void 0 && (o = 1), a === void 0 && (a = !1);
        var s = t.segments, l = Math.round((s - 1) * i) + s * (s - 1 - Math.round((s - 1) * r));
        t.physicsBody.appendAnchor(l, e.physicsBody, a, o);
      }, n.prototype.appendHook = function(t, e, i, r, o) {
        r === void 0 && (r = 1), o === void 0 && (o = !1);
        var a = Math.round(t.segments * i);
        t.physicsBody.appendAnchor(a, e.physicsBody, o, r);
      }, n.prototype.sleepBody = function(t) {
        t.physicsBody.forceActivationState(0);
      }, n.prototype.wakeUpBody = function(t) {
        t.physicsBody.activate();
      }, n.prototype.updateDistanceJoint = function() {
        q.Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin");
      }, n.prototype.setMotor = function(t, e, i) {
        t.physicsJoint.enableAngularMotor(!0, e, i);
      }, n.prototype.setLimit = function() {
        q.Warn("setLimit is not currently supported by the Ammo physics plugin");
      }, n.prototype.syncMeshWithImpostor = function(t, e) {
        e.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform), t.position.x = this._tmpAmmoTransform.getOrigin().x(), t.position.y = this._tmpAmmoTransform.getOrigin().y(), t.position.z = this._tmpAmmoTransform.getOrigin().z(), t.rotationQuaternion && (t.rotationQuaternion.x = this._tmpAmmoTransform.getRotation().x(), t.rotationQuaternion.y = this._tmpAmmoTransform.getRotation().y(), t.rotationQuaternion.z = this._tmpAmmoTransform.getRotation().z(), t.rotationQuaternion.w = this._tmpAmmoTransform.getRotation().w());
      }, n.prototype.getRadius = function(t) {
        return t.getObjectExtents().x / 2;
      }, n.prototype.getBoxSizeToRef = function(t, e) {
        var i = t.getObjectExtents();
        e.x = i.x, e.y = i.y, e.z = i.z;
      }, n.prototype.dispose = function() {
        this.bjsAMMO.destroy(this.world), this.bjsAMMO.destroy(this._solver), this.bjsAMMO.destroy(this._overlappingPairCache), this.bjsAMMO.destroy(this._dispatcher), this.bjsAMMO.destroy(this._collisionConfiguration), this.bjsAMMO.destroy(this._tmpAmmoVectorA), this.bjsAMMO.destroy(this._tmpAmmoVectorB), this.bjsAMMO.destroy(this._tmpAmmoVectorC), this.bjsAMMO.destroy(this._tmpAmmoTransform), this.bjsAMMO.destroy(this._tmpAmmoQuaternion), this.bjsAMMO.destroy(this._tmpAmmoConcreteContactResultCallback), this.world = null;
      }, n.prototype.raycast = function(t, e) {
        return this.raycastToRef(t, e, this._raycastResult), this._raycastResult;
      }, n.prototype.raycastToRef = function(t, e, i) {
        this._tmpAmmoVectorRCA = new this.bjsAMMO.btVector3(t.x, t.y, t.z), this._tmpAmmoVectorRCB = new this.bjsAMMO.btVector3(e.x, e.y, e.z);
        var r = new this.bjsAMMO.ClosestRayResultCallback(this._tmpAmmoVectorRCA, this._tmpAmmoVectorRCB);
        this.world.rayTest(this._tmpAmmoVectorRCA, this._tmpAmmoVectorRCB, r), i.reset(t, e), r.hasHit() && (i.setHitData({ x: r.get_m_hitNormalWorld().x(), y: r.get_m_hitNormalWorld().y(), z: r.get_m_hitNormalWorld().z() }, { x: r.get_m_hitPointWorld().x(), y: r.get_m_hitPointWorld().y(), z: r.get_m_hitPointWorld().z() }), i.calculateHitDistance()), this.bjsAMMO.destroy(r), this.bjsAMMO.destroy(this._tmpAmmoVectorRCA), this.bjsAMMO.destroy(this._tmpAmmoVectorRCB);
      }, n._DISABLE_COLLISION_FLAG = 4, n._KINEMATIC_FLAG = 2, n._DISABLE_DEACTIVATION_FLAG = 4, n;
    }();
    pe.prototype.removeReflectionProbe = function(n) {
      if (!this.reflectionProbes)
        return -1;
      var t = this.reflectionProbes.indexOf(n);
      return t !== -1 && this.reflectionProbes.splice(t, 1), t;
    }, pe.prototype.addReflectionProbe = function(n) {
      this.reflectionProbes || (this.reflectionProbes = []), this.reflectionProbes.push(n);
    };
    var C_ = function() {
      function n(t, e, i, r, o, a) {
        r === void 0 && (r = !0), o === void 0 && (o = !1), a === void 0 && (a = !1);
        var s = this;
        if (this.name = t, this._viewMatrix = B.Identity(), this._target = v.Zero(), this._add = v.Zero(), this._invertYAxis = !1, this.position = v.Zero(), this.metadata = null, this._parentContainer = null, this._scene = i, i.getEngine().supportsUniformBuffers) {
          this._sceneUBOs = [];
          for (var l = 0; l < 6; ++l)
            this._sceneUBOs.push(i.createSceneUniformBuffer('Scene for Reflection Probe (name "'.concat(t, '") face #').concat(l)));
        }
        this._scene.reflectionProbes || (this._scene.reflectionProbes = []), this._scene.reflectionProbes.push(this);
        var c = _.TEXTURETYPE_UNSIGNED_BYTE;
        if (o) {
          var u = this._scene.getEngine().getCaps();
          u.textureHalfFloatRender ? c = _.TEXTURETYPE_HALF_FLOAT : u.textureFloatRender && (c = _.TEXTURETYPE_FLOAT);
        }
        this._renderTargetTexture = new Mi(t, e, i, r, !0, c, !0), this._renderTargetTexture.gammaSpace = !a, this._renderTargetTexture.invertZ = i.useRightHandedSystem;
        var h, d = i.getEngine().useReverseDepthBuffer;
        this._renderTargetTexture.onBeforeRenderObservable.add(function(p) {
          switch (s._sceneUBOs && (i.setSceneUniformBuffer(s._sceneUBOs[p]), i.getSceneUniformBuffer().unbindEffect()), p) {
            case 0:
              s._add.copyFromFloats(1, 0, 0);
              break;
            case 1:
              s._add.copyFromFloats(-1, 0, 0);
              break;
            case 2:
              s._add.copyFromFloats(0, s._invertYAxis ? 1 : -1, 0);
              break;
            case 3:
              s._add.copyFromFloats(0, s._invertYAxis ? -1 : 1, 0);
              break;
            case 4:
              s._add.copyFromFloats(0, 0, i.useRightHandedSystem ? -1 : 1);
              break;
            case 5:
              s._add.copyFromFloats(0, 0, i.useRightHandedSystem ? 1 : -1);
          }
          s._attachedMesh && s.position.copyFrom(s._attachedMesh.getAbsolutePosition()), s.position.addToRef(s._add, s._target);
          var f = i.useRightHandedSystem ? B.LookAtRHToRef : B.LookAtLHToRef, m = i.useRightHandedSystem ? B.PerspectiveFovRH : B.PerspectiveFovLH;
          f(s.position, s._target, v.Up(), s._viewMatrix), i.activeCamera && (s._projectionMatrix = m(Math.PI / 2, 1, d ? i.activeCamera.maxZ : i.activeCamera.minZ, d ? i.activeCamera.minZ : i.activeCamera.maxZ, s._scene.getEngine().isNDCHalfZRange), i.setTransformMatrix(s._viewMatrix, s._projectionMatrix), i.activeCamera.isRigCamera && !s._renderTargetTexture.activeCamera && (s._renderTargetTexture.activeCamera = i.activeCamera.rigParent || null)), i._forcedViewPosition = s.position;
        }), this._renderTargetTexture.onBeforeBindObservable.add(function() {
          var p, f;
          s._currentSceneUBO = i.getSceneUniformBuffer(), (f = (p = i.getEngine())._debugPushGroup) === null || f === void 0 || f.call(p, "reflection probe generation for ".concat(t), 1), h = s._scene.imageProcessingConfiguration.applyByPostProcess, a && (i.imageProcessingConfiguration.applyByPostProcess = !0);
        }), this._renderTargetTexture.onAfterUnbindObservable.add(function() {
          var p, f;
          i.imageProcessingConfiguration.applyByPostProcess = h, i._forcedViewPosition = null, s._sceneUBOs && i.setSceneUniformBuffer(s._currentSceneUBO), i.updateTransformMatrix(!0), (f = (p = i.getEngine())._debugPopGroup) === null || f === void 0 || f.call(p, 1);
        });
      }
      return Object.defineProperty(n.prototype, "samples", { get: function() {
        return this._renderTargetTexture.samples;
      }, set: function(t) {
        this._renderTargetTexture.samples = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "refreshRate", { get: function() {
        return this._renderTargetTexture.refreshRate;
      }, set: function(t) {
        this._renderTargetTexture.refreshRate = t;
      }, enumerable: !1, configurable: !0 }), n.prototype.getScene = function() {
        return this._scene;
      }, Object.defineProperty(n.prototype, "cubeTexture", { get: function() {
        return this._renderTargetTexture;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "renderList", { get: function() {
        return this._renderTargetTexture.renderList;
      }, set: function(t) {
        this._renderTargetTexture.renderList = t;
      }, enumerable: !1, configurable: !0 }), n.prototype.attachToMesh = function(t) {
        this._attachedMesh = t;
      }, n.prototype.setRenderingAutoClearDepthStencil = function(t, e) {
        this._renderTargetTexture.setRenderingAutoClearDepthStencil(t, e);
      }, n.prototype.dispose = function() {
        var t = this._scene.reflectionProbes.indexOf(this);
        if (t !== -1 && this._scene.reflectionProbes.splice(t, 1), this._parentContainer) {
          var e = this._parentContainer.reflectionProbes.indexOf(this);
          e > -1 && this._parentContainer.reflectionProbes.splice(e, 1), this._parentContainer = null;
        }
        if (this._renderTargetTexture && (this._renderTargetTexture.dispose(), this._renderTargetTexture = null), this._sceneUBOs) {
          for (var i = 0, r = this._sceneUBOs; i < r.length; i++)
            r[i].dispose();
          this._sceneUBOs = [];
        }
      }, n.prototype.toString = function(t) {
        var e = "Name: " + this.name;
        return t && (e += ", position: " + this.position.toString(), this._attachedMesh && (e += ", attached mesh: " + this._attachedMesh.name)), e;
      }, n.prototype.getClassName = function() {
        return "ReflectionProbe";
      }, n.prototype.serialize = function() {
        var t = Ne.Serialize(this, this._renderTargetTexture.serialize());
        return t.isReflectionProbe = !0, t.metadata = this.metadata, t;
      }, n.Parse = function(t, e, i) {
        var r = null;
        if (e.reflectionProbes)
          for (var o = 0; o < e.reflectionProbes.length; o++) {
            var a = e.reflectionProbes[o];
            if (a.name === t.name) {
              r = a;
              break;
            }
          }
        return (r = Ne.Parse(function() {
          return r || new n(t.name, t.renderTargetSize, e, t._generateMipMaps);
        }, t, e, i)).cubeTexture._waitingRenderList = t.renderList, t._attachedMesh && r.attachToMesh(e.getMeshById(t._attachedMesh)), t.metadata && (r.metadata = t.metadata), r;
      }, x([$o()], n.prototype, "_attachedMesh", void 0), x([ki()], n.prototype, "position", void 0), n;
    }(), JC = !0, id = function() {
      function n() {
      }
      return n.LoaderInjectedPhysicsEngine = void 0, n;
    }(), ru = {}, Ps = {}, $C = function(n, t, e, i) {
      if (!t.materials)
        return null;
      for (var r = 0, o = t.materials.length; r < o; r++) {
        var a = t.materials[r];
        if (n(a))
          return { parsedMaterial: a, material: Et.Parse(a, e, i) };
      }
      return null;
    }, ou = function(n, t) {
      return n + " of " + (t ? t.file + " from " + t.name + " version: " + t.version + ", exporter version: " + t.exporter_version : "unknown");
    }, eP = function(n, t) {
      var e = t;
      if (t._waitingData.lods) {
        if (t._waitingData.lods.ids && t._waitingData.lods.ids.length > 0) {
          var i = t._waitingData.lods.ids, r = e.isEnabled(!1);
          if (t._waitingData.lods.distances) {
            var o = t._waitingData.lods.distances;
            if (o.length >= i.length) {
              var a = o.length > i.length ? o[o.length - 1] : 0;
              e.setEnabled(!1);
              for (var s = 0; s < i.length; s++) {
                var l = i[s], c = n.getMeshById(l);
                c != null && e.addLODLevel(o[s], c);
              }
              a > 0 && e.addLODLevel(a, null), r === !0 && e.setEnabled(!0);
            } else
              de.Warn("Invalid level of detail distances for " + t.name);
          }
        }
        t._waitingData.lods = null;
      }
    }, P_ = function(n, t, e) {
      if (typeof n != "number") {
        var i = e.getLastEntryById(n);
        return i && t != null ? i.instances[parseInt(t)] : i;
      }
      var r = ru[n];
      return r && t != null ? r.instances[parseInt(t)] : r;
    }, I_ = function(n, t) {
      return typeof n != "number" ? t.getLastMaterialById(n, !0) : Ps[n];
    }, tP = function(n, t, e, i, r) {
      r === void 0 && (r = !1);
      var o = new Rg(n), a = "importScene has failed JSON parse";
      try {
        var s = JSON.parse(t);
        a = "";
        var l = yi.loggingLevel === yi.DETAILED_LOGGING, c = void 0, u = void 0;
        if (s.environmentTexture !== void 0 && s.environmentTexture !== null) {
          var h = s.isPBR === void 0 || s.isPBR;
          if (s.environmentTextureType && s.environmentTextureType === "BABYLON.HDRCubeTexture") {
            var d = s.environmentTextureSize ? s.environmentTextureSize : 128, p = new $h((s.environmentTexture.match(/https?:\/\//g) ? "" : e) + s.environmentTexture, n, d, !0, !h, void 0, s.environmentTexturePrefilterOnLoad);
            s.environmentTextureRotationY && (p.rotationY = s.environmentTextureRotationY), n.environmentTexture = p;
          } else if (typeof s.environmentTexture == "object") {
            var f = Gr.Parse(s.environmentTexture, n, e);
            n.environmentTexture = f;
          } else if (s.environmentTexture.endsWith(".env")) {
            var m = new Gr((s.environmentTexture.match(/https?:\/\//g) ? "" : e) + s.environmentTexture, n, s.environmentTextureForcedExtension);
            s.environmentTextureRotationY && (m.rotationY = s.environmentTextureRotationY), n.environmentTexture = m;
          } else {
            var g = Gr.CreateFromPrefilteredData((s.environmentTexture.match(/https?:\/\//g) ? "" : e) + s.environmentTexture, n, s.environmentTextureForcedExtension);
            s.environmentTextureRotationY && (g.rotationY = s.environmentTextureRotationY), n.environmentTexture = g;
          }
          if (s.createDefaultSkybox === !0) {
            var y = n.activeCamera !== void 0 && n.activeCamera !== null ? (n.activeCamera.maxZ - n.activeCamera.minZ) / 2 : 1e3, b = s.skyboxBlurLevel || 0;
            n.createDefaultSkybox(n.environmentTexture, h, y, b);
          }
          o.environmentTexture = n.environmentTexture;
        }
        if (s.environmentIntensity !== void 0 && s.environmentIntensity !== null && (n.environmentIntensity = s.environmentIntensity), s.lights !== void 0 && s.lights !== null)
          for (c = 0, u = s.lights.length; c < u; c++) {
            var T = s.lights[c];
            (ke = Kn.Parse(T, n)) && (ru[T.uniqueId] = ke, o.lights.push(ke), ke._parentContainer = o, a += c === 0 ? `
	Lights:` : "", a += `
		` + ke.toString(l));
          }
        if (s.reflectionProbes !== void 0 && s.reflectionProbes !== null)
          for (c = 0, u = s.reflectionProbes.length; c < u; c++) {
            var S = s.reflectionProbes[c], E = C_.Parse(S, n, e);
            E && (o.reflectionProbes.push(E), E._parentContainer = o, a += c === 0 ? `
	Reflection Probes:` : "", a += `
		` + E.toString(l));
          }
        if (s.animations !== void 0 && s.animations !== null)
          for (c = 0, u = s.animations.length; c < u; c++) {
            var A = s.animations[c], R = Kt("BABYLON.Animation");
            if (R) {
              var C = R.Parse(A);
              n.animations.push(C), o.animations.push(C), a += c === 0 ? `
	Animations:` : "", a += `
		` + C.toString(l);
            }
          }
        if (s.materials !== void 0 && s.materials !== null)
          for (c = 0, u = s.materials.length; c < u; c++) {
            var L = s.materials[c], I = Et.Parse(L, n, e);
            I && (Ps[L.uniqueId || L.id] = I, o.materials.push(I), I._parentContainer = o, a += c === 0 ? `
	Materials:` : "", a += `
		` + I.toString(l), I.getActiveTextures().forEach(function(_t) {
              o.textures.indexOf(_t) == -1 && (o.textures.push(_t), _t._parentContainer = o);
            }));
          }
        if (s.multiMaterials !== void 0 && s.multiMaterials !== null)
          for (c = 0, u = s.multiMaterials.length; c < u; c++) {
            var O = s.multiMaterials[c], w = Ao.ParseMultiMaterial(O, n);
            Ps[O.uniqueId || O.id] = w, o.multiMaterials.push(w), w._parentContainer = o, a += c === 0 ? `
	MultiMaterials:` : "", a += `
		` + w.toString(l), w.getActiveTextures().forEach(function(_t) {
              o.textures.indexOf(_t) == -1 && (o.textures.push(_t), _t._parentContainer = o);
            });
          }
        if (s.morphTargetManagers !== void 0 && s.morphTargetManagers !== null)
          for (var z = 0, V = s.morphTargetManagers; z < V.length; z++) {
            var Y = V[z], ee = ed.Parse(Y, n);
            o.morphTargetManagers.push(ee), ee._parentContainer = o;
          }
        if (s.skeletons !== void 0 && s.skeletons !== null)
          for (c = 0, u = s.skeletons.length; c < u; c++) {
            var J = s.skeletons[c], X = oh.Parse(J, n);
            o.skeletons.push(X), X._parentContainer = o, a += c === 0 ? `
	Skeletons:` : "", a += `
		` + X.toString(l);
          }
        var K = s.geometries;
        if (K != null) {
          var te = new Array(), se = K.vertexData;
          if (se != null)
            for (c = 0, u = se.length; c < u; c++) {
              var _e = se[c];
              te.push(er.Parse(_e, n, e));
            }
          te.forEach(function(_t) {
            _t && (o.geometries.push(_t), _t._parentContainer = o);
          });
        }
        if (s.transformNodes !== void 0 && s.transformNodes !== null)
          for (c = 0, u = s.transformNodes.length; c < u; c++) {
            var xe = s.transformNodes[c], Te = ai.Parse(xe, n, e);
            ru[xe.uniqueId] = Te, o.transformNodes.push(Te), Te._parentContainer = o;
          }
        if (s.meshes !== void 0 && s.meshes !== null)
          for (c = 0, u = s.meshes.length; c < u; c++) {
            var he = s.meshes[c], me = ie.Parse(he, n, e);
            if (ru[he.uniqueId] = me, o.meshes.push(me), me._parentContainer = o, me.hasInstances)
              for (var Fe = 0, Ce = me.instances; Fe < Ce.length; Fe++) {
                var Re = Ce[Fe];
                o.meshes.push(Re), Re._parentContainer = o;
              }
            a += c === 0 ? `
	Meshes:` : "", a += `
		` + me.toString(l);
          }
        if (s.cameras !== void 0 && s.cameras !== null)
          for (c = 0, u = s.cameras.length; c < u; c++) {
            var Be = s.cameras[c], De = dt.Parse(Be, n);
            ru[Be.uniqueId] = De, o.cameras.push(De), De._parentContainer = o, a += c === 0 ? `
	Cameras:` : "", a += `
		` + De.toString(l);
          }
        if (s.postProcesses !== void 0 && s.postProcesses !== null)
          for (c = 0, u = s.postProcesses.length; c < u; c++) {
            var Ke = s.postProcesses[c], ge = nt.Parse(Ke, n, e);
            ge && (o.postProcesses.push(ge), ge._parentContainer = o, a += c === 0 ? `
Postprocesses:` : "", a += `
		` + ge.toString());
          }
        if (s.animationGroups !== void 0 && s.animationGroups !== null)
          for (c = 0, u = s.animationGroups.length; c < u; c++) {
            var rt = s.animationGroups[c], it = pg.Parse(rt, n);
            o.animationGroups.push(it), it._parentContainer = o, a += c === 0 ? `
	AnimationGroups:` : "", a += `
		` + it.toString(l);
          }
        for (c = 0, u = n.cameras.length; c < u; c++)
          (De = n.cameras[c])._waitingParentId !== null && (De.parent = P_(De._waitingParentId, De._waitingParentInstanceIndex, n), De._waitingParentId = null, De._waitingParentInstanceIndex = null);
        for (c = 0, u = n.lights.length; c < u; c++)
          (ke = n.lights[c]) && ke._waitingParentId !== null && (ke.parent = P_(ke._waitingParentId, ke._waitingParentInstanceIndex, n), ke._waitingParentId = null, ke._waitingParentInstanceIndex = null);
        for (c = 0, u = n.transformNodes.length; c < u; c++) {
          var He = n.transformNodes[c];
          He._waitingParentId !== null && (He.parent = P_(He._waitingParentId, He._waitingParentInstanceIndex, n), He._waitingParentId = null, He._waitingParentInstanceIndex = null);
        }
        for (c = 0, u = n.meshes.length; c < u; c++)
          (me = n.meshes[c])._waitingParentId !== null && (me.parent = P_(me._waitingParentId, me._waitingParentInstanceIndex, n), me._waitingParentId = null, me._waitingParentInstanceIndex = null), me._waitingData.lods && eP(n, me);
        for (n.multiMaterials.forEach(function(_t) {
          _t._waitingSubMaterialsUniqueIds.forEach(function(Pi) {
            _t.subMaterials.push(I_(Pi, n));
          }), _t._waitingSubMaterialsUniqueIds = [];
        }), n.meshes.forEach(function(_t) {
          _t._waitingMaterialId !== null && (_t.material = I_(_t._waitingMaterialId, n), _t._waitingMaterialId = null);
        }), c = 0, u = n.skeletons.length; c < u; c++)
          (X = n.skeletons[c])._hasWaitingData && (X.bones != null && X.bones.forEach(function(_t) {
            if (_t._waitingTransformNodeId) {
              var Pi = n.getLastEntryById(_t._waitingTransformNodeId);
              Pi && _t.linkTransformNode(Pi), _t._waitingTransformNodeId = null;
            }
          }), X._hasWaitingData = null);
        for (c = 0, u = n.meshes.length; c < u; c++) {
          var Pt = n.meshes[c];
          Pt._waitingData.freezeWorldMatrix ? (Pt.freezeWorldMatrix(), Pt._waitingData.freezeWorldMatrix = null) : Pt.computeWorldMatrix(!0);
        }
        for (c = 0, u = n.lights.length; c < u; c++) {
          var ke;
          if ((ke = n.lights[c])._excludedMeshesIds.length > 0) {
            for (var xt = 0; xt < ke._excludedMeshesIds.length; xt++) {
              var Nt = n.getMeshById(ke._excludedMeshesIds[xt]);
              Nt && ke.excludedMeshes.push(Nt);
            }
            ke._excludedMeshesIds = [];
          }
          if (ke._includedOnlyMeshesIds.length > 0) {
            for (var $e = 0; $e < ke._includedOnlyMeshesIds.length; $e++) {
              var Rt = n.getMeshById(ke._includedOnlyMeshesIds[$e]);
              Rt && ke.includedOnlyMeshes.push(Rt);
            }
            ke._includedOnlyMeshesIds = [];
          }
        }
        for (n.geometries.forEach(function(_t) {
          _t._loadedUniqueId = "";
        }), pe.Parse(s, n, o, e), c = 0, u = n.meshes.length; c < u; c++)
          (me = n.meshes[c])._waitingData.actions && (Qs.Parse(me._waitingData.actions, me, n), me._waitingData.actions = null);
        s.actions !== void 0 && s.actions !== null && Qs.Parse(s.actions, null, n);
      } catch (_t) {
        var kt = ou("loadAssets", s ? s.producer : "Unknown") + a;
        if (!i)
          throw q.Log(kt), _t;
        i(kt, _t);
      } finally {
        ru = {}, Ps = {}, r || o.removeAllFromScene(), a !== null && yi.loggingLevel !== yi.NO_LOGGING && q.Log(ou("loadAssets", s ? s.producer : "Unknown") + (yi.loggingLevel !== yi.MINIMAL_LOGGING ? a : ""));
      }
      return o;
    };
    yi.RegisterPlugin({ name: "babylon.js", extensions: ".babylon", canDirectLoad: function(n) {
      return n.indexOf("babylon") !== -1;
    }, importMesh: function(n, t, e, i, r, o, a, s) {
      var l, c = "importMesh has failed JSON parse";
      try {
        var u = JSON.parse(e);
        c = "";
        var h = yi.loggingLevel === yi.DETAILED_LOGGING;
        n ? Array.isArray(n) || (n = [n]) : n = null;
        var d = [], p = /* @__PURE__ */ new Map(), f = [];
        if (u.transformNodes !== void 0 && u.transformNodes !== null)
          for (var m = 0, g = u.transformNodes.length; m < g; m++) {
            var y = u.transformNodes[m], b = ai.Parse(y, t, i);
            f.push(b), p.set(b._waitingParsedUniqueId, b), b._waitingParsedUniqueId = null;
          }
        if (u.meshes !== void 0 && u.meshes !== null) {
          var T = [], S = [], E = [], A = [], R = function(te, se) {
            var _e = u.meshes[te];
            if (n === null || function($e, Rt, kt) {
              for (var _t in Rt)
                if ($e.name === Rt[_t])
                  return kt.push($e.id), !0;
              return $e.parentId !== void 0 && kt.indexOf($e.parentId) !== -1 && (kt.push($e.id), !0);
            }(_e, n, d)) {
              if (n !== null && delete n[n.indexOf(_e.name)], _e.geometryId !== void 0 && _e.geometryId !== null && u.geometries !== void 0 && u.geometries !== null) {
                var xe = !1;
                ["boxes", "spheres", "cylinders", "toruses", "grounds", "planes", "torusKnots", "vertexData"].forEach(function($e) {
                  xe !== !0 && u.geometries[$e] && Array.isArray(u.geometries[$e]) && u.geometries[$e].forEach(function(Rt) {
                    Rt.id === _e.geometryId && ($e === "vertexData" && er.Parse(Rt, t, i), xe = !0);
                  });
                }), xe === !1 && q.Warn("Geometry not found for mesh " + _e.id);
              }
              if (_e.materialUniqueId || _e.materialId) {
                var Te = _e.materialUniqueId ? E : S, he = Te.indexOf(_e.materialUniqueId || _e.materialId) !== -1;
                if (he === !1 && u.multiMaterials !== void 0 && u.multiMaterials !== null)
                  for (var me = function($e, Rt) {
                    Te.push($e);
                    var kt = $C(Rt, u, t, i);
                    kt && kt.material && (Ps[kt.parsedMaterial.uniqueId || kt.parsedMaterial.id] = kt.material, c += `
	Material ` + kt.material.toString(h));
                  }, Fe = 0, Ce = u.multiMaterials.length; Fe < Ce; Fe++) {
                    var Re = u.multiMaterials[Fe];
                    if (_e.materialUniqueId && Re.uniqueId === _e.materialUniqueId || Re.id === _e.materialId) {
                      Re.materialsUniqueIds ? Re.materialsUniqueIds.forEach(function($e) {
                        return me($e, function(Rt) {
                          return Rt.uniqueId === $e;
                        });
                      }) : Re.materials.forEach(function($e) {
                        return me($e, function(Rt) {
                          return Rt.id === $e;
                        });
                      }), Te.push(Re.uniqueId || Re.id);
                      var Be = Ao.ParseMultiMaterial(Re, t);
                      Ps[Re.uniqueId || Re.id] = Be, Be && (he = !0, c += `
	Multi-Material ` + Be.toString(h));
                      break;
                    }
                  }
                if (he === !1) {
                  Te.push(_e.materialUniqueId || _e.materialId);
                  var De = $C(function($e) {
                    return _e.materialUniqueId && $e.uniqueId === _e.materialUniqueId || $e.id === _e.materialId;
                  }, u, t, i);
                  De && De.material ? (Ps[De.parsedMaterial.uniqueId || De.parsedMaterial.id] = De.material, c += `
	Material ` + De.material.toString(h)) : q.Warn("Material not found for mesh " + _e.id);
                }
              }
              if (_e.skeletonId !== null && _e.skeletonId !== void 0 && u.skeletonId !== -1 && u.skeletons !== void 0 && u.skeletons !== null && !(T.indexOf(_e.skeletonId) > -1))
                for (var Ke = 0, ge = u.skeletons.length; Ke < ge; Ke++) {
                  var rt = u.skeletons[Ke];
                  if (rt.id === _e.skeletonId) {
                    var it = oh.Parse(rt, t);
                    a.push(it), T.push(rt.id), c += `
	Skeleton ` + it.toString(h);
                  }
                }
              if (_e.morphTargetManagerId > -1 && u.morphTargetManagers !== void 0 && u.morphTargetManagers !== null && !(A.indexOf(_e.morphTargetManagerId) > -1))
                for (var He = 0, Pt = u.morphTargetManagers.length; He < Pt; He++) {
                  var ke = u.morphTargetManagers[He];
                  if (ke.id === _e.morphTargetManagerId) {
                    var xt = ed.Parse(ke, t);
                    A.push(xt.uniqueId), c += `
Morph target ` + xt.toString();
                  }
                }
              var Nt = ie.Parse(_e, t, i);
              r.push(Nt), p.set(Nt._waitingParsedUniqueId, Nt), Nt._waitingParsedUniqueId = null, c += `
	Mesh ` + Nt.toString(h);
            }
          };
          for (m = 0, g = u.meshes.length; m < g; m++)
            R(m);
          for (t.multiMaterials.forEach(function(te) {
            te._waitingSubMaterialsUniqueIds.forEach(function(se) {
              te.subMaterials.push(I_(se, t));
            }), te._waitingSubMaterialsUniqueIds = [];
          }), t.meshes.forEach(function(te) {
            te._waitingMaterialId !== null && (te.material = I_(te._waitingMaterialId, t), te._waitingMaterialId = null);
          }), m = 0, g = t.transformNodes.length; m < g; m++)
            if ((Y = t.transformNodes[m])._waitingParentId !== null) {
              var C = p.get(parseInt(Y._waitingParentId)) || null;
              C === null && (C = t.getLastEntryById(Y._waitingParentId));
              var L = C;
              Y._waitingParentInstanceIndex && (L = C.instances[parseInt(Y._waitingParentInstanceIndex)], Y._waitingParentInstanceIndex = null), Y.parent = L, Y._waitingParentId = null;
            }
          var I = void 0;
          for (m = 0, g = t.meshes.length; m < g; m++) {
            if ((I = t.meshes[m])._waitingParentId) {
              var O = p.get(parseInt(I._waitingParentId)) || null;
              if (O === null && (O = t.getLastEntryById(I._waitingParentId)), L = O, I._waitingParentInstanceIndex && (L = O.instances[parseInt(I._waitingParentInstanceIndex)], I._waitingParentInstanceIndex = null), I.parent = L, ((l = I.parent) === null || l === void 0 ? void 0 : l.getClassName()) === "TransformNode") {
                var w = f.indexOf(I.parent);
                w > -1 && f.splice(w, 1);
              }
              I._waitingParentId = null;
            }
            I._waitingData.lods && eP(t, I);
          }
          for (var z = 0, V = f; z < V.length; z++) {
            var Y;
            (Y = V[z]).dispose();
          }
          for (m = 0, g = t.skeletons.length; m < g; m++) {
            var ee = t.skeletons[m];
            ee._hasWaitingData && (ee.bones != null && ee.bones.forEach(function(te) {
              if (te._waitingTransformNodeId) {
                var se = t.getLastEntryById(te._waitingTransformNodeId);
                se && te.linkTransformNode(se), te._waitingTransformNodeId = null;
              }
            }), ee._hasWaitingData = null);
          }
          for (m = 0, g = t.meshes.length; m < g; m++)
            (I = t.meshes[m])._waitingData.freezeWorldMatrix ? (I.freezeWorldMatrix(), I._waitingData.freezeWorldMatrix = null) : I.computeWorldMatrix(!0);
        }
        if (u.particleSystems !== void 0 && u.particleSystems !== null) {
          var J = pe.GetIndividualParser(we.NAME_PARTICLESYSTEM);
          if (J)
            for (m = 0, g = u.particleSystems.length; m < g; m++) {
              var X = u.particleSystems[m];
              d.indexOf(X.emitterId) !== -1 && o.push(J(X, t, i));
            }
        }
        return t.geometries.forEach(function(te) {
          te._loadedUniqueId = "";
        }), !0;
      } catch (te) {
        var K = ou("importMesh", u ? u.producer : "Unknown") + c;
        if (!s)
          throw q.Log(K), te;
        s(K, te);
      } finally {
        c !== null && yi.loggingLevel !== yi.NO_LOGGING && q.Log(ou("importMesh", u ? u.producer : "Unknown") + (yi.loggingLevel !== yi.MINIMAL_LOGGING ? c : "")), Ps = {};
      }
      return !1;
    }, load: function(n, t, e, i) {
      var r = "importScene has failed JSON parse";
      try {
        var o = JSON.parse(t);
        if (r = "", o.useDelayedTextureLoading !== void 0 && o.useDelayedTextureLoading !== null && (n.useDelayedTextureLoading = o.useDelayedTextureLoading && !yi.ForceFullSceneLoadingForIncremental), o.autoClear !== void 0 && o.autoClear !== null && (n.autoClear = o.autoClear), o.clearColor !== void 0 && o.clearColor !== null && (n.clearColor = Ie.FromArray(o.clearColor)), o.ambientColor !== void 0 && o.ambientColor !== null && (n.ambientColor = ne.FromArray(o.ambientColor)), o.gravity !== void 0 && o.gravity !== null && (n.gravity = v.FromArray(o.gravity)), o.useRightHandedSystem !== void 0 && (n.useRightHandedSystem = !!o.useRightHandedSystem), o.fogMode && o.fogMode !== 0)
          switch (n.fogMode = o.fogMode, n.fogColor = ne.FromArray(o.fogColor), n.fogStart = o.fogStart, n.fogEnd = o.fogEnd, n.fogDensity = o.fogDensity, r += "	Fog mode for scene:  ", n.fogMode) {
            case 1:
              r += `exp
`;
              break;
            case 2:
              r += `exp2
`;
              break;
            case 3:
              r += `linear
`;
          }
        if (o.physicsEnabled) {
          var a = void 0;
          o.physicsEngine === "cannon" || o.physicsEngine === td.name ? a = new td(void 0, void 0, id.LoaderInjectedPhysicsEngine) : o.physicsEngine === "oimo" || o.physicsEngine === A_.name ? a = new A_(void 0, id.LoaderInjectedPhysicsEngine) : o.physicsEngine !== "ammo" && o.physicsEngine !== R_.name || (a = new R_(void 0, id.LoaderInjectedPhysicsEngine, void 0)), r = "	Physics engine " + (o.physicsEngine ? o.physicsEngine : "oimo") + ` enabled
`;
          var s = o.physicsGravity ? v.FromArray(o.physicsGravity) : null;
          n.enablePhysics(s, a);
        }
        return o.metadata !== void 0 && o.metadata !== null && (n.metadata = o.metadata), o.collisionsEnabled !== void 0 && o.collisionsEnabled !== null && (n.collisionsEnabled = o.collisionsEnabled), !!tP(n, t, e, i, !0) && (o.autoAnimate && n.beginAnimation(n, o.autoAnimateFrom, o.autoAnimateTo, o.autoAnimateLoop, o.autoAnimateSpeed || 1), o.activeCameraID !== void 0 && o.activeCameraID !== null && n.setActiveCameraById(o.activeCameraID), !0);
      } catch (c) {
        var l = ou("importScene", o ? o.producer : "Unknown") + r;
        if (!i)
          throw q.Log(l), c;
        i(l, c);
      } finally {
        r !== null && yi.loggingLevel !== yi.NO_LOGGING && q.Log(ou("importScene", o ? o.producer : "Unknown") + (yi.loggingLevel !== yi.MINIMAL_LOGGING ? r : ""));
      }
      return !1;
    }, loadAssetContainer: function(n, t, e, i) {
      return tP(n, t, e, i);
    } });
    var qy = function() {
      function n(t) {
        t === void 0 && (t = {}), this._isEnabled = !0, this.bias = t.bias === void 0 ? 0 : t.bias, this.power = t.power === void 0 ? 1 : t.power, this.leftColor = t.leftColor || ne.White(), this.rightColor = t.rightColor || ne.Black(), t.isEnabled === !1 && (this.isEnabled = !1);
      }
      return Object.defineProperty(n.prototype, "isEnabled", { get: function() {
        return this._isEnabled;
      }, set: function(t) {
        this._isEnabled !== t && (this._isEnabled = t, ve.MarkAllMaterialsAsDirty(_.MATERIAL_FresnelDirtyFlag | _.MATERIAL_MiscDirtyFlag));
      }, enumerable: !1, configurable: !0 }), n.prototype.clone = function() {
        var t = new n();
        return Ui.DeepCopy(this, t), t;
      }, n.prototype.equals = function(t) {
        return t && this.bias === t.bias && this.power === t.power && this.leftColor.equals(t.leftColor) && this.rightColor.equals(t.rightColor) && this.isEnabled === t.isEnabled;
      }, n.prototype.serialize = function() {
        return { isEnabled: this.isEnabled, leftColor: this.leftColor.asArray(), rightColor: this.rightColor.asArray(), bias: this.bias, power: this.power };
      }, n.Parse = function(t) {
        return new n({ isEnabled: t.isEnabled, leftColor: ne.FromArray(t.leftColor), rightColor: ne.FromArray(t.rightColor), bias: t.bias, power: t.power || 1 });
      }, n;
    }();
    Ne._FresnelParametersParser = qy.Parse;
    var iP = function(n) {
      function t(e, i) {
        var r = n.call(this, e, i, "color", { attributes: ["position"], uniforms: ["world", "viewProjection", "color"] }) || this;
        return r.disableColorWrite = !0, r.forceDepthWrite = !0, r.setColor4("color", new Ie(0, 0, 0, 1)), r;
      }
      return D(t, n), t;
    }(dr), M_ = function(n) {
      function t(e, i) {
        var r = n.call(this, e, i) || this;
        return r.maxSimultaneousLights = 4, r.disableLighting = !1, r.invertNormalMapX = !1, r.invertNormalMapY = !1, r.emissiveColor = new ne(0, 0, 0), r.occlusionStrength = 1, r.useLightmapAsShadowmap = !1, r._useAlphaFromAlbedoTexture = !0, r._useAmbientInGrayScale = !0, r;
      }
      return D(t, n), Object.defineProperty(t.prototype, "doubleSided", { get: function() {
        return this._twoSidedLighting;
      }, set: function(e) {
        this._twoSidedLighting !== e && (this._twoSidedLighting = e, this.backFaceCulling = !e, this._markAllSubMeshesAsTexturesDirty());
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "PBRBaseSimpleMaterial";
      }, x([N(), ye("_markAllSubMeshesAsLightsDirty")], t.prototype, "maxSimultaneousLights", void 0), x([N(), ye("_markAllSubMeshesAsLightsDirty")], t.prototype, "disableLighting", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty", "_reflectionTexture")], t.prototype, "environmentTexture", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapX", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapY", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty", "_bumpTexture")], t.prototype, "normalTexture", void 0), x([ri("emissive"), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveColor", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveTexture", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty", "_ambientTextureStrength")], t.prototype, "occlusionStrength", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty", "_ambientTexture")], t.prototype, "occlusionTexture", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty", "_alphaCutOff")], t.prototype, "alphaCutOff", void 0), x([N()], t.prototype, "doubleSided", null), x([St(), ye("_markAllSubMeshesAsTexturesDirty", null)], t.prototype, "lightmapTexture", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useLightmapAsShadowmap", void 0), t;
    }(Si), Qy = function(n) {
      function t(e, i) {
        var r = n.call(this, e, i) || this;
        return r._useRoughnessFromMetallicTextureAlpha = !1, r._useRoughnessFromMetallicTextureGreen = !0, r._useMetallnessFromMetallicTextureBlue = !0, r.metallic = 1, r.roughness = 1, r;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "PBRMetallicRoughnessMaterial";
      }, t.prototype.clone = function(e) {
        var i = this, r = Ne.Clone(function() {
          return new t(e, i.getScene());
        }, this);
        return r.id = e, r.name = e, this.clearCoat.copyTo(r.clearCoat), this.anisotropy.copyTo(r.anisotropy), this.brdf.copyTo(r.brdf), this.sheen.copyTo(r.sheen), this.subSurface.copyTo(r.subSurface), r;
      }, t.prototype.serialize = function() {
        var e = Ne.Serialize(this);
        return e.customType = "BABYLON.PBRMetallicRoughnessMaterial", e.clearCoat = this.clearCoat.serialize(), e.anisotropy = this.anisotropy.serialize(), e.brdf = this.brdf.serialize(), e.sheen = this.sheen.serialize(), e.subSurface = this.subSurface.serialize(), e.iridescence = this.iridescence.serialize(), e;
      }, t.Parse = function(e, i, r) {
        var o = Ne.Parse(function() {
          return new t(e.name, i);
        }, e, i, r);
        return e.clearCoat && o.clearCoat.parse(e.clearCoat, i, r), e.anisotropy && o.anisotropy.parse(e.anisotropy, i, r), e.brdf && o.brdf.parse(e.brdf, i, r), e.sheen && o.sheen.parse(e.sheen, i, r), e.subSurface && o.subSurface.parse(e.subSurface, i, r), e.iridescence && o.iridescence.parse(e.iridescence, i, r), o;
      }, x([ri(), ye("_markAllSubMeshesAsTexturesDirty", "_albedoColor")], t.prototype, "baseColor", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")], t.prototype, "baseTexture", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallic", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "roughness", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty", "_metallicTexture")], t.prototype, "metallicRoughnessTexture", void 0), t;
    }(M_);
    j("BABYLON.PBRMetallicRoughnessMaterial", Qy);
    var Zy = function(n) {
      function t(e, i) {
        var r = n.call(this, e, i) || this;
        return r._useMicroSurfaceFromReflectivityMapAlpha = !0, r;
      }
      return D(t, n), Object.defineProperty(t.prototype, "useMicroSurfaceFromReflectivityMapAlpha", { get: function() {
        return this._useMicroSurfaceFromReflectivityMapAlpha;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "PBRSpecularGlossinessMaterial";
      }, t.prototype.clone = function(e) {
        var i = this, r = Ne.Clone(function() {
          return new t(e, i.getScene());
        }, this);
        return r.id = e, r.name = e, this.clearCoat.copyTo(r.clearCoat), this.anisotropy.copyTo(r.anisotropy), this.brdf.copyTo(r.brdf), this.sheen.copyTo(r.sheen), this.subSurface.copyTo(r.subSurface), r;
      }, t.prototype.serialize = function() {
        var e = Ne.Serialize(this);
        return e.customType = "BABYLON.PBRSpecularGlossinessMaterial", e.clearCoat = this.clearCoat.serialize(), e.anisotropy = this.anisotropy.serialize(), e.brdf = this.brdf.serialize(), e.sheen = this.sheen.serialize(), e.subSurface = this.subSurface.serialize(), e.iridescence = this.iridescence.serialize(), e;
      }, t.Parse = function(e, i, r) {
        var o = Ne.Parse(function() {
          return new t(e.name, i);
        }, e, i, r);
        return e.clearCoat && o.clearCoat.parse(e.clearCoat, i, r), e.anisotropy && o.anisotropy.parse(e.anisotropy, i, r), e.brdf && o.brdf.parse(e.brdf, i, r), e.sheen && o.sheen.parse(e.sheen, i, r), e.subSurface && o.subSurface.parse(e.subSurface, i, r), e.iridescence && o.iridescence.parse(e.iridescence, i, r), o;
      }, x([ri("diffuse"), ye("_markAllSubMeshesAsTexturesDirty", "_albedoColor")], t.prototype, "diffuseColor", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")], t.prototype, "diffuseTexture", void 0), x([ri("specular"), ye("_markAllSubMeshesAsTexturesDirty", "_reflectivityColor")], t.prototype, "specularColor", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty", "_microSurface")], t.prototype, "glossiness", void 0), x([St(), ye("_markAllSubMeshesAsTexturesDirty", "_reflectivityTexture")], t.prototype, "specularGlossinessTexture", void 0), t;
    }(M_);
    j("BABYLON.PBRSpecularGlossinessMaterial", Zy);
    var Jy = function(n) {
      function t(e, i, r) {
        r === void 0 && (r = null);
        var o = n.call(this, i) || this;
        if (!e)
          return o;
        if (o._textureMatrix = B.Identity(), o.name = e, o.url = e, o._onLoad = r, o._texture = o._getFromCache(e, !0), o._texture)
          o._triggerOnLoad();
        else {
          var a = o.getScene();
          a && a.useDelayedTextureLoading ? o.delayLoadState = _.DELAYLOADSTATE_NOTLOADED : o._loadTexture();
        }
        return o;
      }
      return D(t, n), t.prototype._triggerOnLoad = function() {
        this._onLoad && this._onLoad();
      }, t.prototype.getTextureMatrix = function() {
        return this._textureMatrix;
      }, t.prototype._load3dlTexture = function() {
        var e, i = this, r = this._getEngine();
        e = r._features.support3DTextures ? r.createRawTexture3D(null, 1, 1, 1, _.TEXTUREFORMAT_RGBA, !1, !1, _.TEXTURE_BILINEAR_SAMPLINGMODE, null, _.TEXTURETYPE_UNSIGNED_INT) : r.createRawTexture(null, 1, 1, _.TEXTUREFORMAT_RGBA, !1, !1, _.TEXTURE_BILINEAR_SAMPLINGMODE, null, _.TEXTURETYPE_UNSIGNED_INT), this._texture = e, this._texture.isReady = !1, this.isCube = !1, this.is3D = r._features.support3DTextures, this.wrapU = _.TEXTURE_CLAMP_ADDRESSMODE, this.wrapV = _.TEXTURE_CLAMP_ADDRESSMODE, this.wrapR = _.TEXTURE_CLAMP_ADDRESSMODE, this.anisotropicFilteringLevel = 1;
        var o = function(s) {
          if (typeof s == "string") {
            for (var l, c = null, u = null, h = s.split(`
`), d = 0, p = 0, f = 0, m = 0, g = 0, y = 0; y < h.length; y++)
              if (l = h[y], t._NoneEmptyLineRegex.test(l) && l.indexOf("#") !== 0) {
                var b = l.split(" ");
                if (d !== 0) {
                  if (d != 0) {
                    var T = Math.max(parseInt(b[0]), 0), S = Math.max(parseInt(b[1]), 0), E = Math.max(parseInt(b[2]), 0);
                    g = Math.max(T, g), g = Math.max(S, g), g = Math.max(E, g);
                    var A = 4 * (p + m * d + f * d * d);
                    u && (u[A + 0] = T, u[A + 1] = S, u[A + 2] = E), ++f % d == 0 && (f = 0, ++m % d == 0 && (p++, m = 0));
                  }
                } else
                  d = b.length, c = new Uint8Array(d * d * d * 4), u = new Float32Array(d * d * d * 4);
              }
            if (u && c)
              for (y = 0; y < u.length; y++)
                if (y > 0 && (y + 1) % 4 == 0)
                  c[y] = 255;
                else {
                  var R = u[y];
                  c[y] = R / g * 255;
                }
            e.is3D ? (e.updateSize(d, d, d), r.updateRawTexture3D(e, c, _.TEXTUREFORMAT_RGBA, !1)) : (e.updateSize(d * d, d), r.updateRawTexture(e, c, _.TEXTUREFORMAT_RGBA, !1)), e.isReady = !0, i._triggerOnLoad();
          }
        }, a = this.getScene();
        return a ? a._loadFile(this.url, o) : r._loadFile(this.url, o), this._texture;
      }, t.prototype._loadTexture = function() {
        this.url && this.url.toLocaleLowerCase().indexOf(".3dl") == this.url.length - 4 && this._load3dlTexture();
      }, t.prototype.clone = function() {
        var e = new t(this.url, this.getScene() || this._getEngine());
        return e.level = this.level, e;
      }, t.prototype.delayLoad = function() {
        this.delayLoadState === _.DELAYLOADSTATE_NOTLOADED && (this.delayLoadState = _.DELAYLOADSTATE_LOADED, this._texture = this._getFromCache(this.url, !0), this._texture || this._loadTexture());
      }, t.Parse = function(e, i) {
        var r = null;
        return e.name && !e.isRenderTarget && ((r = new t(e.name, i)).name = e.name, r.level = e.level), r;
      }, t.prototype.serialize = function() {
        if (!this.name)
          return null;
        var e = {};
        return e.name = this.name, e.level = this.level, e.customType = "BABYLON.ColorGradingTexture", e;
      }, t._NoneEmptyLineRegex = /\S+/, t;
    }(Vn);
    j("BABYLON.ColorGradingTexture", Jy);
    var $y = function(n) {
      function t(e, i, r, o, a, s, l, c) {
        o === void 0 && (o = !1), a === void 0 && (a = !0), s === void 0 && (s = null), l === void 0 && (l = null), c === void 0 && (c = !1);
        var u = n.call(this, i) || this;
        if (u._onLoad = null, u._onError = null, !e)
          throw new Error("Image url is not set");
        return u._coordinatesMode = ae.CUBIC_MODE, u.name = e, u.url = e, u._size = r, u._supersample = c, u._noMipmap = o, u.gammaSpace = a, u._onLoad = s, u._onError = l, u.hasAlpha = !1, u.isCube = !0, u._texture = u._getFromCache(e, u._noMipmap, void 0, void 0, void 0, u.isCube), u._texture ? s && (u._texture.isReady ? de.SetImmediate(function() {
          return s();
        }) : u._texture.onLoadedObservable.add(s)) : i.useDelayedTextureLoading ? u.delayLoadState = _.DELAYLOADSTATE_NOTLOADED : u._loadImage(function() {
          return u._loadTexture();
        }, u._onError), u;
      }
      return D(t, n), t.prototype._loadImage = function(e, i) {
        var r = this, o = this.getScene();
        if (o) {
          var a = o.getEngine().createRawCubeTexture(null, this._size, _.TEXTUREFORMAT_RGB, o.getEngine().getCaps().textureFloat ? _.TEXTURETYPE_FLOAT : _.TEXTURETYPE_UNSIGNED_INTEGER, this._noMipmap, !1, _.TEXTURE_TRILINEAR_SAMPLINGMODE);
          a.generateMipMaps = !this._noMipmap, o.addPendingData(a), a.url = this.url, a.isReady = !1, o.getEngine()._internalTexturesCache.push(a), this._texture = a;
          var s = document.createElement("canvas");
          rl(this.url, function(l) {
            r._width = l.width, r._height = l.height, s.width = r._width, s.height = r._height;
            var c = s.getContext("2d");
            c.drawImage(l, 0, 0);
            var u = c.getImageData(0, 0, l.width, l.height);
            r._buffer = u.data.buffer, s.remove(), e();
          }, function(l, c) {
            o.removePendingData(a), i && i("".concat(r.getClassName(), " could not be loaded"), c);
          }, o ? o.offlineProvider : null);
        }
      }, t.prototype._loadTexture = function() {
        var e = this, i = this.getScene();
        if (i) {
          var r = function() {
            for (var a = e._getFloat32ArrayFromArrayBuffer(e._buffer), s = E_.ConvertPanoramaToCubemap(a, e._width, e._height, e._size, e._supersample), l = [], c = 0; c < 6; c++) {
              var u = s[t._FacesMapping[c]];
              l.push(u);
            }
            return l;
          }(), o = this._texture;
          i.getEngine().updateRawCubeTexture(o, r, o.format, o.type, o.invertY), o.isReady = !0, i.removePendingData(o), o.onLoadedObservable.notifyObservers(o), o.onLoadedObservable.clear(), this._onLoad && this._onLoad();
        }
      }, t.prototype._getFloat32ArrayFromArrayBuffer = function(e) {
        for (var i = new DataView(e), r = new Float32Array(3 * e.byteLength / 4), o = 0, a = 0; a < e.byteLength; a++)
          (a + 1) % 4 != 0 && (r[o++] = i.getUint8(a) / 255);
        return r;
      }, t.prototype.getClassName = function() {
        return "EquiRectangularCubeTexture";
      }, t.prototype.clone = function() {
        var e = this.getScene();
        if (!e)
          return this;
        var i = new t(this.url, e, this._size, this._noMipmap, this.gammaSpace);
        return i.level = this.level, i.wrapU = this.wrapU, i.wrapV = this.wrapV, i.coordinatesIndex = this.coordinatesIndex, i.coordinatesMode = this.coordinatesMode, i;
      }, t._FacesMapping = ["right", "left", "up", "down", "front", "back"], t;
    }(Vn), nP = function(n) {
      function t(e, i, r) {
        var o, a, s = this;
        return (s = n.call(this, r.scene || r.engine) || this).onLoadObservable = new H(), i && (r.engine || r.scene) && (r = je(je({}, t._DefaultOptions), r), s._generateMipMaps = r.generateMipMaps, s._samplingMode = r.samplingMode, s._textureMatrix = B.Identity(), s._format = r.format, s.name = e, s.element = i, s._isVideo = !!i.getVideoPlaybackQuality, s._externalTexture = s._isVideo && (a = (o = s._engine) === null || o === void 0 ? void 0 : o.createExternalTexture(i)) !== null && a !== void 0 ? a : null, s.anisotropicFilteringLevel = 1, s._createInternalTexture()), s;
      }
      return D(t, n), t.prototype._createInternalTexture = function() {
        var e = 0, i = 0;
        this._isVideo ? (e = this.element.videoWidth, i = this.element.videoHeight) : (e = this.element.width, i = this.element.height);
        var r = this._getEngine();
        r && (this._texture = r.createDynamicTexture(e, i, this._generateMipMaps, this._samplingMode), this._texture.format = this._format), this.update();
      }, t.prototype.getTextureMatrix = function() {
        return this._textureMatrix;
      }, t.prototype.update = function(e) {
        e === void 0 && (e = null);
        var i = this._getEngine();
        if (this._texture != null && i != null) {
          var r = this.isReady();
          if (this._isVideo) {
            var o = this.element;
            if (o.readyState < o.HAVE_CURRENT_DATA)
              return;
            i.updateVideoTexture(this._texture, this._externalTexture ? this._externalTexture : o, e === null || e);
          } else {
            var a = this.element;
            i.updateDynamicTexture(this._texture, a, e === null || e, !1, this._format);
          }
          !r && this.isReady() && this.onLoadObservable.notifyObservers(this);
        }
      }, t.prototype.dispose = function() {
        this.onLoadObservable.clear(), n.prototype.dispose.call(this);
      }, t._DefaultOptions = { generateMipMaps: !1, samplingMode: _.TEXTURE_BILINEAR_SAMPLINGMODE, format: _.TEXTUREFORMAT_RGBA, engine: null, scene: null }, t;
    }(Vn), KD = 1, qD = 2, QD = 3, ZD = 9, JD = 10, $D = 11, eN = 48, tN = 4, iN = 0, nN = 1, rN = 2, oN = 3;
    function au(n) {
      var t = 0;
      return { id_length: n[t++], colormap_type: n[t++], image_type: n[t++], colormap_index: n[t++] | n[t++] << 8, colormap_length: n[t++] | n[t++] << 8, colormap_size: n[t++], origin: [n[t++] | n[t++] << 8, n[t++] | n[t++] << 8], width: n[t++] | n[t++] << 8, height: n[t++] | n[t++] << 8, pixel_size: n[t++], flags: n[t++] };
    }
    function O_(n, t) {
      if (t.length < 19)
        q.Error("Unable to load TGA file - Not enough data to contain header");
      else {
        var e = 18, i = au(t);
        if (i.id_length + e > t.length)
          q.Error("Unable to load TGA file - Not enough data");
        else {
          e += i.id_length;
          var r, o = !1, a = !1, s = !1;
          switch (i.image_type) {
            case ZD:
              o = !0;
            case KD:
              a = !0;
              break;
            case JD:
              o = !0;
            case qD:
              break;
            case $D:
              o = !0;
            case QD:
              s = !0;
          }
          var l, c, u, h, d, p, f, m = i.pixel_size >> 3, g = i.width * i.height * m;
          if (a && (l = t.subarray(e, e += i.colormap_length * (i.colormap_size >> 3))), o) {
            r = new Uint8Array(g);
            for (var y = void 0, b = void 0, T = void 0, S = 0, E = new Uint8Array(m); e < g && S < g; )
              if (b = 1 + (127 & (y = t[e++])), 128 & y) {
                for (T = 0; T < m; ++T)
                  E[T] = t[e++];
                for (T = 0; T < b; ++T)
                  r.set(E, S + T * m);
                S += m * b;
              } else {
                for (b *= m, T = 0; T < b; ++T)
                  r[S + T] = t[e++];
                S += b;
              }
          } else
            r = t.subarray(e, e += a ? i.width * i.height : g);
          switch ((i.flags & eN) >> tN) {
            default:
            case rN:
              c = 0, h = 1, f = i.width, u = 0, d = 1, p = i.height;
              break;
            case iN:
              c = 0, h = 1, f = i.width, u = i.height - 1, d = -1, p = -1;
              break;
            case oN:
              c = i.width - 1, h = -1, f = -1, u = 0, d = 1, p = i.height;
              break;
            case nN:
              c = i.width - 1, h = -1, f = -1, u = i.height - 1, d = -1, p = -1;
          }
          var A = "_getImageData" + (s ? "Grey" : "") + i.pixel_size + "bits", R = eb[A](i, l, r, u, d, p, c, h, f);
          n.getEngine()._uploadDataToTextureDirectly(n, R);
        }
      }
    }
    var eb = { GetTGAHeader: au, UploadContent: O_, _getImageData8bits: function(n, t, e, i, r, o, a, s, l) {
      var c, u, h, d = e, p = t, f = n.width, m = n.height, g = 0, y = new Uint8Array(f * m * 4);
      for (h = i; h !== o; h += r)
        for (u = a; u !== l; u += s, g++)
          c = d[g], y[4 * (u + f * h) + 3] = 255, y[4 * (u + f * h) + 2] = p[3 * c + 0], y[4 * (u + f * h) + 1] = p[3 * c + 1], y[4 * (u + f * h) + 0] = p[3 * c + 2];
      return y;
    }, _getImageData16bits: function(n, t, e, i, r, o, a, s, l) {
      var c, u, h, d = e, p = n.width, f = n.height, m = 0, g = new Uint8Array(p * f * 4);
      for (h = i; h !== o; h += r)
        for (u = a; u !== l; u += s, m += 2) {
          var y = 255 * ((31744 & (c = d[m + 0] + (d[m + 1] << 8))) >> 10) / 31 | 0, b = 255 * ((992 & c) >> 5) / 31 | 0, T = 255 * (31 & c) / 31 | 0;
          g[4 * (u + p * h) + 0] = y, g[4 * (u + p * h) + 1] = b, g[4 * (u + p * h) + 2] = T, g[4 * (u + p * h) + 3] = 32768 & c ? 0 : 255;
        }
      return g;
    }, _getImageData24bits: function(n, t, e, i, r, o, a, s, l) {
      var c, u, h = e, d = n.width, p = n.height, f = 0, m = new Uint8Array(d * p * 4);
      for (u = i; u !== o; u += r)
        for (c = a; c !== l; c += s, f += 3)
          m[4 * (c + d * u) + 3] = 255, m[4 * (c + d * u) + 2] = h[f + 0], m[4 * (c + d * u) + 1] = h[f + 1], m[4 * (c + d * u) + 0] = h[f + 2];
      return m;
    }, _getImageData32bits: function(n, t, e, i, r, o, a, s, l) {
      var c, u, h = e, d = n.width, p = n.height, f = 0, m = new Uint8Array(d * p * 4);
      for (u = i; u !== o; u += r)
        for (c = a; c !== l; c += s, f += 4)
          m[4 * (c + d * u) + 2] = h[f + 0], m[4 * (c + d * u) + 1] = h[f + 1], m[4 * (c + d * u) + 0] = h[f + 2], m[4 * (c + d * u) + 3] = h[f + 3];
      return m;
    }, _getImageDataGrey8bits: function(n, t, e, i, r, o, a, s, l) {
      var c, u, h, d = e, p = n.width, f = n.height, m = 0, g = new Uint8Array(p * f * 4);
      for (h = i; h !== o; h += r)
        for (u = a; u !== l; u += s, m++)
          c = d[m], g[4 * (u + p * h) + 0] = c, g[4 * (u + p * h) + 1] = c, g[4 * (u + p * h) + 2] = c, g[4 * (u + p * h) + 3] = 255;
      return g;
    }, _getImageDataGrey16bits: function(n, t, e, i, r, o, a, s, l) {
      var c, u, h = e, d = n.width, p = n.height, f = 0, m = new Uint8Array(d * p * 4);
      for (u = i; u !== o; u += r)
        for (c = a; c !== l; c += s, f += 2)
          m[4 * (c + d * u) + 0] = h[f + 0], m[4 * (c + d * u) + 1] = h[f + 0], m[4 * (c + d * u) + 2] = h[f + 0], m[4 * (c + d * u) + 3] = h[f + 1];
      return m;
    } }, tb = function() {
      function n() {
        this.supportCascades = !1;
      }
      return n.prototype.canLoad = function(t) {
        return t.endsWith(".tga");
      }, n.prototype.loadCubeData = function() {
        throw ".env not supported in Cube.";
      }, n.prototype.loadData = function(t, e, i) {
        var r = new Uint8Array(t.buffer, t.byteOffset, t.byteLength), o = au(r);
        i(o.width, o.height, e.generateMipMaps, !1, function() {
          O_(e, r);
        });
      }, n;
    }();
    ve._TextureLoaders.push(new tb());
    var ib = function() {
      function n() {
        this.supportCascades = !1;
      }
      return n.prototype.canLoad = function(t) {
        return t.endsWith(".hdr");
      }, n.prototype.loadCubeData = function() {
        throw ".env not supported in Cube.";
      }, n.prototype.loadData = function(t, e, i) {
        for (var r = new Uint8Array(t.buffer, t.byteOffset, t.byteLength), o = Jh.RGBE_ReadHeader(r), a = Jh.RGBE_ReadPixels(r, o), s = o.width * o.height, l = new Float32Array(4 * s), c = 0; c < s; c += 1)
          l[4 * c] = a[3 * c], l[4 * c + 1] = a[3 * c + 1], l[4 * c + 2] = a[3 * c + 2], l[4 * c + 3] = 1;
        i(o.width, o.height, e.generateMipMaps, !1, function() {
          var u = e.getEngine();
          e.type = _.TEXTURETYPE_FLOAT, e.format = _.TEXTUREFORMAT_RGBA, e._gammaSpace = !1, u._uploadDataToTextureDirectly(e, l);
        });
      }, n;
    }();
    ve._TextureLoaders.push(new ib());
    var Za, rP = function() {
    };
    (function(n) {
      n[n.cTFETC1 = 0] = "cTFETC1", n[n.cTFETC2 = 1] = "cTFETC2", n[n.cTFBC1 = 2] = "cTFBC1", n[n.cTFBC3 = 3] = "cTFBC3", n[n.cTFBC4 = 4] = "cTFBC4", n[n.cTFBC5 = 5] = "cTFBC5", n[n.cTFBC7 = 6] = "cTFBC7", n[n.cTFPVRTC1_4_RGB = 8] = "cTFPVRTC1_4_RGB", n[n.cTFPVRTC1_4_RGBA = 9] = "cTFPVRTC1_4_RGBA", n[n.cTFASTC_4x4 = 10] = "cTFASTC_4x4", n[n.cTFATC_RGB = 11] = "cTFATC_RGB", n[n.cTFATC_RGBA_INTERPOLATED_ALPHA = 12] = "cTFATC_RGBA_INTERPOLATED_ALPHA", n[n.cTFRGBA32 = 13] = "cTFRGBA32", n[n.cTFRGB565 = 14] = "cTFRGB565", n[n.cTFBGR565 = 15] = "cTFBGR565", n[n.cTFRGBA4444 = 16] = "cTFRGBA4444", n[n.cTFFXT1_RGB = 17] = "cTFFXT1_RGB", n[n.cTFPVRTC2_4_RGB = 18] = "cTFPVRTC2_4_RGB", n[n.cTFPVRTC2_4_RGBA = 19] = "cTFPVRTC2_4_RGBA", n[n.cTFETC2_EAC_R11 = 20] = "cTFETC2_EAC_R11", n[n.cTFETC2_EAC_RG11 = 21] = "cTFETC2_EAC_RG11";
    })(Za || (Za = {}));
    var Ta = { JSModuleURL: "".concat(de._DefaultCdnUrl, "/basisTranscoder/1/basis_transcoder.js"), WasmModuleURL: "".concat(de._DefaultCdnUrl, "/basisTranscoder/1/basis_transcoder.wasm") }, nb = function(n, t) {
      var e;
      switch (n) {
        case Za.cTFETC1:
          e = _.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL;
          break;
        case Za.cTFBC1:
          e = _.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1;
          break;
        case Za.cTFBC4:
          e = _.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5;
          break;
        case Za.cTFASTC_4x4:
          e = _.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4;
          break;
        case Za.cTFETC2:
          e = _.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC;
          break;
        case Za.cTFBC7:
          e = _.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM;
      }
      if (e === void 0)
        throw "The chosen Basis transcoder format is not currently supported";
      return e;
    }, rb = null, Ea = null, aN = 0, nd = function(n, t) {
      var e = n instanceof ArrayBuffer ? new Uint8Array(n) : n;
      return new Promise(function(i, r) {
        (rb || (rb = new Promise(function(o, a) {
          Ea ? o(Ea) : de.LoadFileAsync(de.GetBabylonScriptURL(Ta.WasmModuleURL)).then(function(s) {
            if (typeof URL != "function")
              return a("Basis transcoder requires an environment with a URL constructor");
            var l = URL.createObjectURL(new Blob(["(".concat(sN, ")()")], { type: "application/javascript" }));
            Ea = new Worker(l);
            var c = function(u) {
              u.data.action === "init" ? (Ea.removeEventListener("message", c), o(Ea)) : u.data.action === "error" && a(u.data.error || "error initializing worker");
            };
            Ea.addEventListener("message", c), Ea.postMessage({ action: "init", url: de.GetBabylonScriptURL(Ta.JSModuleURL), wasmBinary: s });
          }).catch(a);
        })), rb).then(function() {
          var o = aN++, a = function(l) {
            l.data.action === "transcode" && l.data.id === o && (Ea.removeEventListener("message", a), l.data.success ? i(l.data) : r("Transcode is not supported on this device"));
          };
          Ea.addEventListener("message", a);
          var s = new Uint8Array(e.byteLength);
          s.set(new Uint8Array(e.buffer, e.byteOffset, e.byteLength)), Ea.postMessage({ action: "transcode", id: o, imageData: s, config: t, ignoreSupportedFormats: !1 }, [s.buffer]);
        }, function(o) {
          r(o);
        });
      });
    }, D_ = function(n, t) {
      var e, i, r = (e = t._gl) === null || e === void 0 ? void 0 : e.TEXTURE_2D;
      n.isCube && (r = (i = t._gl) === null || i === void 0 ? void 0 : i.TEXTURE_CUBE_MAP), t._bindTextureDirectly(r, n, !0);
    }, rd = function(n, t) {
      for (var e = n.getEngine(), i = function(o) {
        var a = t.fileInfo.images[o].levels[0];
        if (n._invertVScale = n.invertY, t.format === -1 || t.format === Za.cTFRGB565)
          if (n.type = _.TEXTURETYPE_UNSIGNED_SHORT_5_6_5, n.format = _.TEXTUREFORMAT_RGB, !e._features.basisNeedsPOT || ue.Log2(a.width) % 1 == 0 && ue.Log2(a.height) % 1 == 0)
            n._invertVScale = !n.invertY, n.width = a.width + 3 & -4, n.height = a.height + 3 & -4, n.samplingMode = _.TEXTURE_LINEAR_LINEAR, D_(n, e), e._uploadDataToTextureDirectly(n, new Uint16Array(a.transcodedPixels.buffer), o, 0, _.TEXTUREFORMAT_RGB, !0);
          else {
            var s = new Ut(e, ut.Temp);
            n._invertVScale = n.invertY, s.type = _.TEXTURETYPE_UNSIGNED_SHORT_5_6_5, s.format = _.TEXTUREFORMAT_RGB, s.width = a.width + 3 & -4, s.height = a.height + 3 & -4, D_(s, e), e._uploadDataToTextureDirectly(s, new Uint16Array(a.transcodedPixels.buffer), o, 0, _.TEXTUREFORMAT_RGB, !0), e._rescaleTexture(s, n, e.scenes[0], e._getInternalFormat(_.TEXTUREFORMAT_RGB), function() {
              e._releaseTexture(s), D_(n, e);
            });
          }
        else {
          n.width = a.width, n.height = a.height, n.generateMipMaps = t.fileInfo.images[o].levels.length > 1;
          var l = od.GetInternalFormatFromBasisFormat(t.format, e);
          n.format = l, D_(n, e), t.fileInfo.images[o].levels.forEach(function(c, u) {
            e._uploadCompressedDataToTextureDirectly(n, l, c.width, c.height, c.transcodedPixels, o, u);
          }), !e._features.basisNeedsPOT || ue.Log2(n.width) % 1 == 0 && ue.Log2(n.height) % 1 == 0 || (de.Warn("Loaded .basis texture width and height are not a power of two. Texture wrapping will be set to Texture.CLAMP_ADDRESSMODE as other modes are not supported with non power of two dimensions in webGL 1."), n._cachedWrapU = ae.CLAMP_ADDRESSMODE, n._cachedWrapV = ae.CLAMP_ADDRESSMODE);
        }
      }, r = 0; r < t.fileInfo.images.length; r++)
        i(r);
    }, od = { JSModuleURL: Ta.JSModuleURL, WasmModuleURL: Ta.WasmModuleURL, GetInternalFormatFromBasisFormat: nb, TranscodeAsync: nd, LoadTextureFromTranscodeResult: rd };
    function sN() {
      var n = null;
      function t(e, i, r, o, a) {
        var s = e.getImageTranscodedSizeInBytes(i, r, o), l = new Uint8Array(s);
        return e.transcodeImage(l, i, r, o, 1, 0) ? (a && (l = function(c, u, h, d) {
          for (var p = new Uint16Array(4), f = new Uint16Array(h * d), m = h / 4, g = d / 4, y = 0; y < g; y++)
            for (var b = 0; b < m; b++) {
              var T = 0 + 8 * (y * m + b);
              p[0] = c[T] | c[T + 1] << 8, p[1] = c[T + 2] | c[T + 3] << 8, p[2] = (2 * (31 & p[0]) + 1 * (31 & p[1])) / 3 | (2 * (2016 & p[0]) + 1 * (2016 & p[1])) / 3 & 2016 | (2 * (63488 & p[0]) + 1 * (63488 & p[1])) / 3 & 63488, p[3] = (2 * (31 & p[1]) + 1 * (31 & p[0])) / 3 | (2 * (2016 & p[1]) + 1 * (2016 & p[0])) / 3 & 2016 | (2 * (63488 & p[1]) + 1 * (63488 & p[0])) / 3 & 63488;
              for (var S = 0; S < 4; S++) {
                var E = c[T + 4 + S], A = (4 * y + S) * h + 4 * b;
                f[A++] = p[3 & E], f[A++] = p[E >> 2 & 3], f[A++] = p[E >> 4 & 3], f[A++] = p[E >> 6 & 3];
              }
            }
          return f;
        }(l, 0, e.getImageWidth(i, r) + 3 & -4, e.getImageHeight(i, r) + 3 & -4)), l) : null;
      }
      onmessage = function(e) {
        if (e.data.action === "init") {
          if (!n) {
            try {
              importScripts(e.data.url);
            } catch (y) {
              postMessage({ action: "error", error: y });
            }
            n = BASIS({ wasmBinary: e.data.wasmBinary });
          }
          n !== null && n.then(function(y) {
            BASIS = y, y.initializeBasis(), postMessage({ action: "init" });
          });
        } else if (e.data.action === "transcode") {
          var i = e.data.config, r = e.data.imageData, o = new BASIS.BasisFile(r), a = function(y) {
            for (var b = y.getHasAlpha(), T = y.getNumImages(), S = [], E = 0; E < T; E++) {
              for (var A = { levels: [] }, R = y.getNumLevels(E), C = 0; C < R; C++) {
                var L = { width: y.getImageWidth(E, C), height: y.getImageHeight(E, C) };
                A.levels.push(L);
              }
              S.push(A);
            }
            return { hasAlpha: b, images: S };
          }(o), s = e.data.ignoreSupportedFormats ? null : function(y, b) {
            var T = null;
            return y.supportedCompressionFormats && (T = y.supportedCompressionFormats.astc ? 10 : y.supportedCompressionFormats.bc7 ? 6 : y.supportedCompressionFormats.s3tc ? b.hasAlpha ? 3 : 2 : y.supportedCompressionFormats.pvrtc ? b.hasAlpha ? 9 : 8 : y.supportedCompressionFormats.etc2 ? 1 : y.supportedCompressionFormats.etc1 ? 0 : 14), T;
          }(e.data.config, a), l = !1;
          s === null && (l = !0, s = a.hasAlpha ? 3 : 2);
          var c = !0;
          o.startTranscoding() || (c = !1);
          for (var u = [], h = 0; h < a.images.length && c; h++) {
            var d = a.images[h];
            if (i.loadSingleImage === void 0 || i.loadSingleImage === h) {
              var p = d.levels.length;
              i.loadMipmapLevels === !1 && (p = 1);
              for (var f = 0; f < p; f++) {
                var m = d.levels[f], g = t(o, h, f, s, l);
                if (!g) {
                  c = !1;
                  break;
                }
                m.transcodedPixels = g, u.push(m.transcodedPixels.buffer);
              }
            }
          }
          o.close(), o.delete(), l && (s = -1), c ? postMessage({ action: "transcode", success: c, id: e.data.id, fileInfo: a, format: s }, u) : postMessage({ action: "transcode", success: c, id: e.data.id });
        }
      };
    }
    Object.defineProperty(od, "JSModuleURL", { get: function() {
      return Ta.JSModuleURL;
    }, set: function(n) {
      Ta.JSModuleURL = n;
    } }), Object.defineProperty(od, "WasmModuleURL", { get: function() {
      return Ta.WasmModuleURL;
    }, set: function(n) {
      Ta.WasmModuleURL = n;
    } });
    var ob = function() {
      function n() {
        this.supportCascades = !1;
      }
      return n.prototype.canLoad = function(t) {
        return t.endsWith(".basis");
      }, n.prototype.loadCubeData = function(t, e, i, r, o) {
        if (!Array.isArray(t)) {
          var a = e.getEngine().getCaps(), s = { supportedCompressionFormats: { etc1: !!a.etc1, s3tc: !!a.s3tc, pvrtc: !!a.pvrtc, etc2: !!a.etc2, astc: !!a.astc, bc7: !!a.bptc } };
          nd(t, s).then(function(l) {
            var c = l.fileInfo.images[0].levels.length > 1 && e.generateMipMaps;
            rd(e, l), e.getEngine()._setCubeMapTextureParams(e, c), e.isReady = !0, e.onLoadedObservable.notifyObservers(e), e.onLoadedObservable.clear(), r && r();
          }).catch(function(l) {
            de.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"), e.isReady = !0, o && o(l);
          });
        }
      }, n.prototype.loadData = function(t, e, i) {
        var r = e.getEngine().getCaps(), o = { supportedCompressionFormats: { etc1: !!r.etc1, s3tc: !!r.s3tc, pvrtc: !!r.pvrtc, etc2: !!r.etc2, astc: !!r.astc, bc7: !!r.bptc } };
        nd(t, o).then(function(a) {
          var s = a.fileInfo.images[0].levels[0], l = a.fileInfo.images[0].levels.length > 1 && e.generateMipMaps;
          i(s.width, s.height, l, a.format !== -1, function() {
            rd(e, a);
          });
        }).catch(function(a) {
          de.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"), de.Warn("Failed to transcode Basis file: ".concat(a)), i(0, 0, !1, !1, function() {
          }, !0);
        });
      }, n;
    }();
    ve._TextureLoaders.push(new ob());
    var Ja = function(n) {
      function t(e, i, r, o, a, s) {
        var l = this, c = !(!a || !a.generateMipMaps) && a.generateMipMaps, u = !(!a || !a.generateDepthTexture) && a.generateDepthTexture, h = a && a.depthTextureFormat ? a.depthTextureFormat : _.TEXTUREFORMAT_DEPTH16, d = !a || a.doNotChangeAspectRatio === void 0 || a.doNotChangeAspectRatio, p = !(!a || !a.drawOnlyOnFirstAttachmentByDefault) && a.drawOnlyOnFirstAttachmentByDefault;
        if (!(l = n.call(this, e, i, o, c, d, void 0, void 0, void 0, void 0, void 0, void 0, void 0, !0) || this).isSupported)
          return l.dispose(), l;
        l._textureNames = s;
        var f = [], m = [], g = [], y = [], b = [], T = [], S = [], E = [];
        l._initTypes(r, f, m, g, y, b, T, S, E, a);
        var A = !a || a.generateDepthBuffer === void 0 || a.generateDepthBuffer, R = !(!a || a.generateStencilBuffer === void 0) && a.generateStencilBuffer;
        return l._multiRenderTargetOptions = { samplingModes: m, generateMipMaps: c, generateDepthBuffer: A, generateStencilBuffer: R, generateDepthTexture: u, depthTextureFormat: h, types: f, textureCount: r, useSRGBBuffers: g, formats: y, targetTypes: b, faceIndex: T, layerIndex: S, layerCounts: E, labels: s }, l._count = r, l._drawOnlyOnFirstAttachmentByDefault = p, r > 0 && (l._createInternalTextures(), l._createTextures(s)), l;
      }
      return D(t, n), Object.defineProperty(t.prototype, "isSupported", { get: function() {
        var e, i;
        return (i = (e = this._engine) === null || e === void 0 ? void 0 : e.getCaps().drawBuffersExtension) !== null && i !== void 0 && i;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "textures", { get: function() {
        return this._textures;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "count", { get: function() {
        return this._count;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "depthTexture", { get: function() {
        return this._textures[this._textures.length - 1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wrapU", { set: function(e) {
        if (this._textures)
          for (var i = 0; i < this._textures.length; i++)
            this._textures[i].wrapU = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wrapV", { set: function(e) {
        if (this._textures)
          for (var i = 0; i < this._textures.length; i++)
            this._textures[i].wrapV = e;
      }, enumerable: !1, configurable: !0 }), t.prototype._initTypes = function(e, i, r, o, a, s, l, c, u, h) {
        for (var d = 0; d < e; d++)
          h && h.types && h.types[d] !== void 0 ? i.push(h.types[d]) : i.push(h && h.defaultType ? h.defaultType : _.TEXTURETYPE_UNSIGNED_INT), h && h.samplingModes && h.samplingModes[d] !== void 0 ? r.push(h.samplingModes[d]) : r.push(ae.BILINEAR_SAMPLINGMODE), h && h.useSRGBBuffers && h.useSRGBBuffers[d] !== void 0 ? o.push(h.useSRGBBuffers[d]) : o.push(!1), h && h.formats && h.formats[d] !== void 0 ? a.push(h.formats[d]) : a.push(_.TEXTUREFORMAT_RGBA), h && h.targetTypes && h.targetTypes[d] !== void 0 ? s.push(h.targetTypes[d]) : s.push(_.TEXTURE_2D), h && h.faceIndex && h.faceIndex[d] !== void 0 ? l.push(h.faceIndex[d]) : l.push(0), h && h.layerIndex && h.layerIndex[d] !== void 0 ? c.push(h.layerIndex[d]) : c.push(0), h && h.layerCounts && h.layerCounts[d] !== void 0 ? u.push(h.layerCounts[d]) : u.push(1);
      }, t.prototype._createInternaTextureIndexMapping = function() {
        var e = {}, i = [];
        if (!this._renderTarget)
          return i;
        for (var r = this._renderTarget.textures, o = 0; o < r.length; o++) {
          var a = r[o];
          if (a) {
            var s = e[a.uniqueId];
            s !== void 0 ? i[o] = s : e[a.uniqueId] = o;
          }
        }
        return i;
      }, t.prototype._rebuild = function(e, i) {
        if (e === void 0 && (e = !1), !(this._count < 1)) {
          var r = this._createInternaTextureIndexMapping();
          this.releaseInternalTextures(), this._createInternalTextures(), e && (this._releaseTextures(), this._createTextures(i));
          for (var o = this._renderTarget.textures, a = 0; a < o.length; a++) {
            var s = this._textures[a];
            r[a] !== void 0 && this._renderTarget.setTexture(o[r[a]], a), s._texture = o[a], s._texture && (s._noMipmap = !s._texture.useMipMaps, s._useSRGBBuffer = s._texture._useSRGBBuffer);
          }
          this.samples !== 1 && this._renderTarget.setSamples(this.samples, !this._drawOnlyOnFirstAttachmentByDefault, !0);
        }
      }, t.prototype._createInternalTextures = function() {
        this._renderTarget = this._getEngine().createMultipleRenderTarget(this._size, this._multiRenderTargetOptions, !this._drawOnlyOnFirstAttachmentByDefault), this._texture = this._renderTarget.texture;
      }, t.prototype._releaseTextures = function() {
        if (this._textures)
          for (var e = 0; e < this._textures.length; e++)
            this._textures[e]._texture = null, this._textures[e].dispose();
      }, t.prototype._createTextures = function(e) {
        var i = this._renderTarget.textures;
        this._textures = [];
        for (var r = 0; r < i.length; r++) {
          var o = new ae(null, this.getScene());
          e != null && e[r] && (o.name = e[r]), o._texture = i[r], o._texture && (o._noMipmap = !o._texture.useMipMaps, o._useSRGBBuffer = o._texture._useSRGBBuffer), this._textures.push(o);
        }
      }, t.prototype.setInternalTexture = function(e, i, r) {
        var o, a;
        if (r === void 0 && (r = !0), this.renderTarget && (i === 0 && (this._texture = e), this.renderTarget.setTexture(e, i, r), this.textures[i] || (this.textures[i] = new ae(null, this.getScene()), this.textures[i].name = (a = (o = this._textureNames) === null || o === void 0 ? void 0 : o[i]) !== null && a !== void 0 ? a : this.textures[i].name), this.textures[i]._texture = e, this.textures[i]._noMipmap = !e.useMipMaps, this.textures[i]._useSRGBBuffer = e._useSRGBBuffer, this._count = this.renderTarget.textures ? this.renderTarget.textures.length : 0, this._multiRenderTargetOptions.types && (this._multiRenderTargetOptions.types[i] = e.type), this._multiRenderTargetOptions.samplingModes && (this._multiRenderTargetOptions.samplingModes[i] = e.samplingMode), this._multiRenderTargetOptions.useSRGBBuffers && (this._multiRenderTargetOptions.useSRGBBuffers[i] = e._useSRGBBuffer), this._multiRenderTargetOptions.targetTypes && this._multiRenderTargetOptions.targetTypes[i] !== -1)) {
          var s;
          s = e.is2DArray ? _.TEXTURE_2D_ARRAY : e.isCube ? _.TEXTURE_CUBE_MAP : e.is3D ? _.TEXTURE_3D : _.TEXTURE_2D, this._multiRenderTargetOptions.targetTypes[i] = s;
        }
      }, t.prototype.setLayerAndFaceIndex = function(e, i, r) {
        i === void 0 && (i = -1), r === void 0 && (r = -1), this.textures[e] && this.renderTarget && (this._multiRenderTargetOptions.layerIndex && (this._multiRenderTargetOptions.layerIndex[e] = i), this._multiRenderTargetOptions.faceIndex && (this._multiRenderTargetOptions.faceIndex[e] = r), this.renderTarget.setLayerAndFaceIndex(e, i, r));
      }, t.prototype.setLayerAndFaceIndices = function(e, i) {
        this.renderTarget && (this._multiRenderTargetOptions.layerIndex = e, this._multiRenderTargetOptions.faceIndex = i, this.renderTarget.setLayerAndFaceIndices(e, i));
      }, Object.defineProperty(t.prototype, "samples", { get: function() {
        return this._samples;
      }, set: function(e) {
        this._renderTarget ? this._samples = this._renderTarget.setSamples(e) : this._samples = e;
      }, enumerable: !1, configurable: !0 }), t.prototype.resize = function(e) {
        this._processSizeParameter(e, !1), this._rebuild(void 0, this._textureNames);
      }, t.prototype.updateCount = function(e, i, r) {
        this._multiRenderTargetOptions.textureCount = e, this._count = e;
        var o = [], a = [], s = [], l = [], c = [], u = [], h = [], d = [];
        this._textureNames = r, this._initTypes(e, o, a, s, l, c, u, h, d, i), this._multiRenderTargetOptions.types = o, this._multiRenderTargetOptions.samplingModes = a, this._multiRenderTargetOptions.useSRGBBuffers = s, this._multiRenderTargetOptions.formats = l, this._multiRenderTargetOptions.targetTypes = c, this._multiRenderTargetOptions.faceIndex = u, this._multiRenderTargetOptions.layerIndex = h, this._multiRenderTargetOptions.layerCounts = d, this._multiRenderTargetOptions.labels = r, this._rebuild(!0, r);
      }, t.prototype._unbindFrameBuffer = function(e, i) {
        var r = this;
        this._renderTarget && e.unBindMultiColorAttachmentFramebuffer(this._renderTarget, this.isCube, function() {
          r.onAfterRenderObservable.notifyObservers(i);
        });
      }, t.prototype.dispose = function(e) {
        e === void 0 && (e = !1), this._releaseTextures(), e ? this._texture = null : this.releaseInternalTextures(), n.prototype.dispose.call(this);
      }, t.prototype.releaseInternalTextures = function() {
        var e, i, r = (e = this._renderTarget) === null || e === void 0 ? void 0 : e.textures;
        if (r) {
          for (var o = r.length - 1; o >= 0; o--)
            this._textures[o]._texture = null;
          (i = this._renderTarget) === null || i === void 0 || i.dispose(), this._renderTarget = null;
        }
      }, t;
    }(Mi), N_ = function(n, t, e) {
      this.id = n, this.scale = t, this.offset = e;
    }, oP = function() {
      function n(t, e, i, r) {
        var o, a, s, l, c, u, h, d, p, f, m, g, y;
        return this.name = t, this.meshes = e, this.scene = r, this.options = i, this.options.map = (o = this.options.map) !== null && o !== void 0 ? o : ["ambientTexture", "bumpTexture", "diffuseTexture", "emissiveTexture", "lightmapTexture", "opacityTexture", "reflectionTexture", "refractionTexture", "specularTexture"], this.options.uvsIn = (a = this.options.uvsIn) !== null && a !== void 0 ? a : P.UVKind, this.options.uvsOut = (s = this.options.uvsOut) !== null && s !== void 0 ? s : P.UVKind, this.options.layout = (l = this.options.layout) !== null && l !== void 0 ? l : n.LAYOUT_STRIP, this.options.layout === n.LAYOUT_COLNUM && (this.options.colnum = (c = this.options.colnum) !== null && c !== void 0 ? c : 8), this.options.updateInputMeshes = (u = this.options.updateInputMeshes) === null || u === void 0 || u, this.options.disposeSources = (h = this.options.disposeSources) === null || h === void 0 || h, this._expecting = 0, this.options.fillBlanks = (d = this.options.fillBlanks) === null || d === void 0 || d, this.options.fillBlanks === !0 && (this.options.customFillColor = (p = this.options.customFillColor) !== null && p !== void 0 ? p : "black"), this.options.frameSize = (f = this.options.frameSize) !== null && f !== void 0 ? f : 256, this.options.paddingRatio = (m = this.options.paddingRatio) !== null && m !== void 0 ? m : 0.0115, this._paddingValue = Math.ceil(this.options.frameSize * this.options.paddingRatio), this._paddingValue % 2 != 0 && this._paddingValue++, this.options.paddingMode = (g = this.options.paddingMode) !== null && g !== void 0 ? g : n.SUBUV_WRAP, this.options.paddingMode === n.SUBUV_COLOR && (this.options.paddingColor = (y = this.options.paddingColor) !== null && y !== void 0 ? y : new Ie(0, 0, 0, 1)), this.sets = {}, this.frames = [], this;
      }
      return n.prototype._createFrames = function(t) {
        for (var e = this, i = this._calculateSize(), r = new fe(1, 1).divide(i), o = 0, a = this._expecting, s = this.meshes.length, l = Object.keys(this.sets), c = 0; c < l.length; c++) {
          var u = l[c], h = new Es(this.name + ".TexturePack." + u + "Set", { width: i.x, height: i.y }, this.scene, !0, ae.TRILINEAR_SAMPLINGMODE, ve.TEXTUREFORMAT_RGBA), d = h.getContext();
          d.fillStyle = "rgba(0,0,0,0)", d.fillRect(0, 0, i.x, i.y), h.update(!1), this.sets[u] = h;
        }
        var p = this.options.frameSize || 256, f = this._paddingValue, m = p + 2 * f;
        for (c = 0; c < s; c++)
          for (var g = this.meshes[c].material, y = function(S) {
            var E = new Es("temp", m, b.scene, !0), A = E.getContext(), R = b._getFrameOffset(c), C = function() {
              o++, E.update(!1);
              var w = A.getImageData(0, 0, m, m), z = e.sets[L];
              if (z.getContext().putImageData(w, i.x * R.x, i.y * R.y), E.dispose(), z.update(!1), o == a)
                return e._calculateMeshUVFrames(p, f, i, r, e.options.updateInputMeshes || !1), void t();
            }, L = l[S] || "_blank";
            if (g && g[L] !== null) {
              var I = g[L], O = new Image();
              O.src = I instanceof Es ? I.getContext().canvas.toDataURL("image/png") : I.url, de.SetCorsBehavior(O.src, O), O.onload = function() {
                A.fillStyle = "rgba(0,0,0,0)", A.fillRect(0, 0, m, m), E.update(!1), A.setTransform(1, 0, 0, -1, 0, 0);
                var w = [0, 0, 1, 0, 1, 1, 0, 1, -1, 1, -1, 0, -2, 0, -1, 1, -1];
                switch (e.options.paddingMode) {
                  case 0:
                    for (var z = 0; z < 9; z++)
                      A.drawImage(O, 0, 0, O.width, O.height, f + p * w[z], f + p * w[z + 1] - m, p, p);
                    break;
                  case 1:
                    for (var V = 0; V < f; V++)
                      A.drawImage(O, 0, 0, O.width, O.height, V + p * w[0], f - m, p, p), A.drawImage(O, 0, 0, O.width, O.height, 2 * f - V, f - m, p, p), A.drawImage(O, 0, 0, O.width, O.height, f, V - m, p, p), A.drawImage(O, 0, 0, O.width, O.height, f, 2 * f - V - m, p, p);
                    A.drawImage(O, 0, 0, O.width, O.height, f + p * w[0], f + p * w[1] - m, p, p);
                    break;
                  case 2:
                    A.fillStyle = (e.options.paddingColor || ne.Black()).toHexString(), A.fillRect(0, 0, m, -m), A.clearRect(f, f, p, p), A.drawImage(O, 0, 0, O.width, O.height, f + p * w[0], f + p * w[1] - m, p, p);
                }
                A.setTransform(1, 0, 0, 1, 0, 0), C();
              };
            } else
              A.fillStyle = "rgba(0,0,0,0)", b.options.fillBlanks && (A.fillStyle = b.options.customFillColor), A.fillRect(0, 0, m, m), C();
          }, b = this, T = 0; T < l.length; T++)
            y(T);
      }, n.prototype._calculateSize = function() {
        var t = this.meshes.length || 0, e = this.options.frameSize || 0, i = this._paddingValue || 0;
        switch (this.options.layout) {
          case 0:
            return new fe(e * t + 2 * i * t, e + 2 * i);
          case 1:
            var r = Math.max(2, Math.ceil(Math.sqrt(t))), o = e * r + 2 * i * r;
            return new fe(o, o);
          case 2:
            var a = this.options.colnum || 1, s = Math.max(1, Math.ceil(t / a));
            return new fe(e * a + 2 * i * a, e * s + 2 * i * s);
        }
        return fe.Zero();
      }, n.prototype._calculateMeshUVFrames = function(t, e, i, r, o) {
        for (var a = this.meshes.length, s = 0; s < a; s++) {
          var l = this.meshes[s], c = new fe(t / i.x, t / i.y), u = r.clone().scale(e), h = this._getFrameOffset(s).add(u), d = new N_(s, c, h);
          this.frames.push(d), o && (this._updateMeshUV(l, s), this._updateTextureReferences(l));
        }
      }, n.prototype._getFrameOffset = function(t) {
        var e, i, r, o = this.meshes.length;
        switch (this.options.layout) {
          case 0:
            return new fe(t * (e = 1 / o), 0);
          case 1:
            var a = Math.max(2, Math.ceil(Math.sqrt(o)));
            return i = Math.floor(t / a), new fe((r = t - i * a) * (e = 1 / a), i * e);
          case 2:
            var s = this.options.colnum || 1, l = Math.max(1, Math.ceil(o / s));
            return i = t - (r = Math.floor(t / l)) * l, e = new fe(1 / s, 1 / l), new fe(r * e.x, i * e.y);
        }
        return fe.Zero();
      }, n.prototype._updateMeshUV = function(t, e) {
        var i = this.frames[e], r = t.getVerticesData(this.options.uvsIn || P.UVKind), o = [], a = 0;
        r.length && (a = r.length || 0);
        for (var s = 0; s < a; s += 2)
          o.push(r[s] * i.scale.x + i.offset.x, r[s + 1] * i.scale.y + i.offset.y);
        t.setVerticesData(this.options.uvsOut || P.UVKind, o);
      }, n.prototype._updateTextureReferences = function(t, e) {
        e === void 0 && (e = !1);
        for (var i = t.material, r = Object.keys(this.sets), o = function(l) {
          l.dispose && l.dispose();
        }, a = 0; a < r.length; a++) {
          var s = r[a];
          if (e)
            i[s] !== null && o(i[s]), i[s] = this.sets[s];
          else {
            if (!i)
              return;
            i[s] !== null && (o(i[s]), i[s] = this.sets[s]);
          }
        }
      }, n.prototype.setMeshToFrame = function(t, e, i) {
        i === void 0 && (i = !1), this._updateMeshUV(t, e), i && this._updateTextureReferences(t, !0);
      }, n.prototype.processAsync = function() {
        var t = this;
        return new Promise(function(e, i) {
          try {
            if (t.meshes.length === 0)
              return void e();
            for (var r = 0, o = function(l) {
              var c = t.meshes[l], u = c.material;
              if (!u)
                return ++r === t.meshes.length ? { value: t._createFrames(e) } : "continue";
              u.forceCompilationAsync(c).then(function() {
                (function(h) {
                  if (r++, t.options.map) {
                    for (var d = 0; d < t.options.map.length; d++)
                      h[t.options.map[d]] !== null && (t.sets[t.options.map[d]] || (t.sets[t.options.map[d]] = !0), t._expecting++);
                    r === t.meshes.length && t._createFrames(e);
                  }
                })(u);
              });
            }, a = 0; a < t.meshes.length; a++) {
              var s = o(a);
              if (typeof s == "object")
                return s.value;
            }
          } catch (l) {
            return i(l);
          }
        });
      }, n.prototype.dispose = function() {
        for (var t = Object.keys(this.sets), e = 0; e < t.length; e++) {
          var i = t[e];
          this.sets[i].dispose();
        }
      }, n.prototype.download = function(t, e) {
        var i = this;
        t === void 0 && (t = "png"), e === void 0 && (e = 1), setTimeout(function() {
          var r = { name: i.name, sets: {}, options: {}, frames: [] }, o = Object.keys(i.sets), a = Object.keys(i.options);
          try {
            for (var s = 0; s < o.length; s++) {
              var l = o[s], c = i.sets[l];
              r.sets[l] = c.getContext().canvas.toDataURL("image/" + t, e);
            }
            for (s = 0; s < a.length; s++) {
              var u = a[s];
              r.options[u] = i.options[u];
            }
            for (s = 0; s < i.frames.length; s++) {
              var h = i.frames[s];
              r.frames.push(h.scale.x, h.scale.y, h.offset.x, h.offset.y);
            }
          } catch (f) {
            return void q.Warn("Unable to download: " + f);
          }
          var d = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(r, null, 4)), p = document.createElement("a");
          p.setAttribute("href", d), p.setAttribute("download", i.name + "_texurePackage.json"), document.body.appendChild(p), p.click(), p.remove();
        }, 0);
      }, n.prototype.updateFromJSON = function(t) {
        try {
          var e = JSON.parse(t);
          this.name = e.name;
          for (var i = Object.keys(e.options), r = 0; r < i.length; r++)
            this.options[i[r]] = e.options[i[r]];
          for (r = 0; r < e.frames.length; r += 4) {
            var o = new N_(r / 4, new fe(e.frames[r], e.frames[r + 1]), new fe(e.frames[r + 2], e.frames[r + 3]));
            this.frames.push(o);
          }
          var a = Object.keys(e.sets);
          for (r = 0; r < a.length; r++) {
            var s = new ae(e.sets[a[r]], this.scene, !1, !1);
            this.sets[a[r]] = s;
          }
        } catch (l) {
          q.Warn("Unable to update from JSON: " + l);
        }
      }, n.LAYOUT_STRIP = 0, n.LAYOUT_POWER2 = 1, n.LAYOUT_COLNUM = 2, n.SUBUV_WRAP = 0, n.SUBUV_EXTEND = 1, n.SUBUV_COLOR = 2, n;
    }(), ab = function(n) {
      function t(e, i, r, o, a, s, l) {
        var c = n.call(this, e, r, null, o, a, s) || this;
        return c._animate = !0, c._time = 0, c._texturePath = i, l ? c.setFragment(c._texturePath) : c._loadJson(i), c.refreshRate = 1, c;
      }
      return D(t, n), t.prototype._loadJson = function(e) {
        var i = this, r = function() {
          try {
            i.setFragment(i._texturePath);
          } catch {
            q.Log("No json or ShaderStore or DOM element found for CustomProceduralTexture");
          }
        }, o = e + "/config.json", a = new _n();
        a.open("GET", o), a.addEventListener("load", function() {
          if (a.status === 200 || a.responseText && a.responseText.length > 0)
            try {
              i._config = JSON.parse(a.response), i.updateShaderUniforms(), i.updateTextures(), i.setFragment(i._texturePath + "/custom"), i._animate = i._config.animate, i.refreshRate = i._config.refreshrate;
            } catch {
              r();
            }
          else
            r();
        }, !1), a.addEventListener("error", function() {
          r();
        }, !1);
        try {
          a.send();
        } catch {
          q.Error("CustomProceduralTexture: Error on XHR send request.");
        }
      }, t.prototype.isReady = function() {
        if (!n.prototype.isReady.call(this))
          return !1;
        for (var e in this._textures)
          if (!this._textures[e].isReady())
            return !1;
        return !0;
      }, t.prototype.render = function(e) {
        var i = this.getScene();
        this._animate && i && (this._time += 0.03 * i.getAnimationRatio(), this.updateShaderUniforms()), n.prototype.render.call(this, e);
      }, t.prototype.updateTextures = function() {
        for (var e = 0; e < this._config.sampler2Ds.length; e++)
          this.setTexture(this._config.sampler2Ds[e].sample2Dname, new ae(this._texturePath + "/" + this._config.sampler2Ds[e].textureRelativeUrl, this.getScene()));
      }, t.prototype.updateShaderUniforms = function() {
        if (this._config)
          for (var e = 0; e < this._config.uniforms.length; e++) {
            var i = this._config.uniforms[e];
            switch (i.type) {
              case "float":
                this.setFloat(i.name, i.value);
                break;
              case "color3":
                this.setColor3(i.name, new ne(i.r, i.g, i.b));
                break;
              case "color4":
                this.setColor4(i.name, new Ie(i.r, i.g, i.b, i.a));
                break;
              case "vector2":
                this.setVector2(i.name, new fe(i.x, i.y));
                break;
              case "vector3":
                this.setVector3(i.name, new v(i.x, i.y, i.z));
            }
          }
        this.setFloat("time", this._time);
      }, Object.defineProperty(t.prototype, "animate", { get: function() {
        return this._animate;
      }, set: function(e) {
        this._animate = e;
      }, enumerable: !1, configurable: !0 }), t;
    }(mc);
    re.ShadersStore.noisePixelShader = `uniform float brightness;uniform float persistence;uniform float timeScale;varying vec2 vUV;vec2 hash22(vec2 p)
{p=p*mat2(127.1,311.7,269.5,183.3);p=-1.0+2.0*fract(sin(p)*43758.5453123);return sin(p*6.283+timeScale);}
float interpolationNoise(vec2 p)
{vec2 pi=floor(p);vec2 pf=p-pi;vec2 w=pf*pf*(3.-2.*pf);float f00=dot(hash22(pi+vec2(.0,.0)),pf-vec2(.0,.0));float f01=dot(hash22(pi+vec2(.0,1.)),pf-vec2(.0,1.));float f10=dot(hash22(pi+vec2(1.0,0.)),pf-vec2(1.0,0.));float f11=dot(hash22(pi+vec2(1.0,1.)),pf-vec2(1.0,1.));float xm1=mix(f00,f10,w.x);float xm2=mix(f01,f11,w.x);float ym=mix(xm1,xm2,w.y); 
return ym;}
float perlinNoise2D(float x,float y)
{float sum=0.0;float frequency=0.0;float amplitude=0.0;for(int i=0; i<OCTAVES; i++)
{frequency=pow(2.0,float(i));amplitude=pow(persistence,float(i));sum=sum+interpolationNoise(vec2(x*frequency,y*frequency))*amplitude;}
return sum;}
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void)
{float x=abs(vUV.x);float y=abs(vUV.y);float noise=brightness+(1.0-brightness)*perlinNoise2D(x,y);gl_FragColor=vec4(noise,noise,noise,1.0);}
`;
    var sb = function(n) {
      function t(e, i, r, o, a) {
        i === void 0 && (i = 256), r === void 0 && (r = Me.LastCreatedScene);
        var s = n.call(this, e, i, "noise", r, o, a) || this;
        return s.time = 0, s.brightness = 0.2, s.octaves = 3, s.persistence = 0.8, s.animationSpeedFactor = 1, s.autoClear = !1, s._updateShaderUniforms(), s;
      }
      return D(t, n), t.prototype._updateShaderUniforms = function() {
        var e = this.getScene();
        e && (this.time += e.getAnimationRatio() * this.animationSpeedFactor * 0.01, this.setFloat("brightness", this.brightness), this.setFloat("persistence", this.persistence), this.setFloat("timeScale", this.time));
      }, t.prototype._getDefines = function() {
        return "#define OCTAVES " + (0 | this.octaves);
      }, t.prototype.render = function(e) {
        this._updateShaderUniforms(), n.prototype.render.call(this, e);
      }, t.prototype.serialize = function() {
        var e = { customType: "BABYLON.NoiseProceduralTexture" };
        return e.brightness = this.brightness, e.octaves = this.octaves, e.persistence = this.persistence, e.animationSpeedFactor = this.animationSpeedFactor, e.size = this.getSize().width, e.generateMipMaps = this._generateMipMaps, e.time = this.time, e;
      }, t.prototype.clone = function() {
        var e = this.getSize(), i = new t(this.name, e.width, this.getScene(), this._fallbackTexture ? this._fallbackTexture : void 0, this._generateMipMaps);
        return i.hasAlpha = this.hasAlpha, i.level = this.level, i.coordinatesMode = this.coordinatesMode, i.brightness = this.brightness, i.octaves = this.octaves, i.persistence = this.persistence, i.animationSpeedFactor = this.animationSpeedFactor, i.time = this.time, i;
      }, t.Parse = function(e, i) {
        var r, o = new t(e.name, e.size, i, void 0, e.generateMipMaps);
        return o.brightness = e.brightness, o.octaves = e.octaves, o.persistence = e.persistence, o.animationSpeedFactor = e.animationSpeedFactor, o.time = (r = e.time) !== null && r !== void 0 ? r : 0, o;
      }, t;
    }(mc);
    j("BABYLON.NoiseProceduralTexture", sb);
    var aP = function(n) {
      function t(e, i, r, o, a, s, l, c, u) {
        o === void 0 && (o = _.TEXTUREFORMAT_RGBA), a === void 0 && (a = _.TEXTURETYPE_UNSIGNED_INT), s === void 0 && (s = !1), l === void 0 && (l = !1), c === void 0 && (c = _.TEXTURE_TRILINEAR_SAMPLINGMODE), u === void 0 && (u = null);
        var h = n.call(this, "", e) || this;
        return h._texture = e.getEngine().createRawCubeTexture(i, r, o, a, s, l, c, u), h;
      }
      return D(t, n), t.prototype.update = function(e, i, r, o, a) {
        a === void 0 && (a = null), this._texture.getEngine().updateRawCubeTexture(this._texture, e, i, r, o, a);
      }, t.prototype.updateRGBDAsync = function(e, i, r, o) {
        return i === void 0 && (i = null), r === void 0 && (r = 0.8), o === void 0 && (o = 0), Zv(this._texture, e, i, r, o).then(function() {
        });
      }, t.prototype.clone = function() {
        var e = this;
        return Ne.Clone(function() {
          var i = e.getScene(), r = e._texture, o = new t(i, r._bufferViewArray, r.width, r.format, r.type, r.generateMipMaps, r.invertY, r.samplingMode, r._compression);
          return r.source === ut.CubeRawRGBD && o.updateRGBDAsync(r._bufferViewArrayArray, r._sphericalPolynomial, r._lodGenerationScale, r._lodGenerationOffset), o;
        }, this);
      }, t;
    }(Gr), sP = function(n) {
      function t(e, i, r, o, a, s, l, c, u, h, d) {
        l === void 0 && (l = !0), c === void 0 && (c = !1), u === void 0 && (u = ae.TRILINEAR_SAMPLINGMODE), h === void 0 && (h = _.TEXTURETYPE_UNSIGNED_INT);
        var p = n.call(this, null, s, !l, c) || this;
        return p.format = a, p._texture = s.getEngine().createRawTexture3D(e, i, r, o, a, l, c, u, null, h, d), p.is3D = !0, p;
      }
      return D(t, n), t.prototype.update = function(e) {
        this._texture && this._getEngine().updateRawTexture3D(this._texture, e, this._texture.format, this._texture.invertY, null, this._texture.type);
      }, t;
    }(ae), lP = function(n) {
      function t(e, i, r, o) {
        var a = n.call(this, e, i, r, o, !0) || this;
        return a.refractionPlane = new xo(0, 1, 0, 1), a.depth = 2, a.onBeforeRenderObservable.add(function() {
          a.getScene().clipPlane = a.refractionPlane;
        }), a.onAfterRenderObservable.add(function() {
          a.getScene().clipPlane = null;
        }), a;
      }
      return D(t, n), t.prototype.clone = function() {
        var e = this.getScene();
        if (!e)
          return this;
        var i = this.getSize(), r = new t(this.name, i.width, e, this._generateMipMaps);
        return r.hasAlpha = this.hasAlpha, r.level = this.level, r.refractionPlane = this.refractionPlane.clone(), this.renderList && (r.renderList = this.renderList.slice(0)), r.depth = this.depth, r;
      }, t.prototype.serialize = function() {
        if (!this.name)
          return null;
        var e = n.prototype.serialize.call(this);
        return e.mirrorPlane = this.refractionPlane.asArray(), e.depth = this.depth, e;
      }, t;
    }(Mi), cP = function(n) {
      function t(e, i, r) {
        var o = n.call(this, null) || this;
        return o._renderTarget = null, o._engine = e, o._renderTargetOptions = r, o.resize(i), o;
      }
      return D(t, n), Object.defineProperty(t.prototype, "renderTarget", { get: function() {
        return this._renderTarget;
      }, enumerable: !1, configurable: !0 }), t.prototype.resize = function(e) {
        var i;
        (i = this._renderTarget) === null || i === void 0 || i.dispose(), this._renderTarget = null, this._texture = null, this._size = e, this._engine && (this._renderTarget = this._engine.createRenderTargetTexture(this._size, this._renderTargetOptions)), this._texture = this.renderTarget.texture;
      }, t.prototype.getInternalTexture = function() {
        return this._texture;
      }, t.prototype.getClassName = function() {
        return "ThinRenderTargetTexture";
      }, t.prototype.dispose = function(e) {
        var i;
        e === void 0 && (e = !1), (i = this._renderTarget) === null || i === void 0 || i.dispose(!0), this._renderTarget = null, e || n.prototype.dispose.call(this);
      }, t;
    }(ms), xi = function(n) {
      function t(e, i, r, o, a) {
        var s = n.call(this, e, i, r) || this;
        return s._blockType = o, s._blockName = a, s.needDualDirectionValidation = !0, s;
      }
      return D(t, n), t.prototype.checkCompatibilityState = function(e) {
        return e instanceof t && e._blockName === this._blockName ? Cr.Compatible : Cr.TypeIncompatible;
      }, t.prototype.createCustomInputBlock = function() {
        return [new this._blockType(this._blockName), this.name];
      }, t;
    }(Ju), lb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Vertex) || this;
        return i.registerInput("matricesIndices", M.Vector4), i.registerInput("matricesWeights", M.Vector4), i.registerInput("matricesIndicesExtra", M.Vector4, !0), i.registerInput("matricesWeightsExtra", M.Vector4, !0), i.registerInput("world", M.Matrix), i.registerOutput("output", M.Matrix), i;
      }
      return D(t, n), t.prototype.initialize = function(e) {
        e._excludeVariableName("boneSampler"), e._excludeVariableName("boneTextureWidth"), e._excludeVariableName("mBones"), e._excludeVariableName("BonesPerMesh");
      }, t.prototype.getClassName = function() {
        return "BonesBlock";
      }, Object.defineProperty(t.prototype, "matricesIndices", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "matricesWeights", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "matricesIndicesExtra", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "matricesWeightsExtra", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "world", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function(e, i) {
        if (i === void 0 && (i = function() {
          return !0;
        }), !this.matricesIndices.isConnected) {
          var r = e.getInputBlockByPredicate(function(s) {
            return s.isAttribute && s.name === "matricesIndices" && i(s);
          });
          r || (r = new vt("matricesIndices")).setAsAttribute("matricesIndices"), r.output.connectTo(this.matricesIndices);
        }
        if (!this.matricesWeights.isConnected) {
          var o = e.getInputBlockByPredicate(function(s) {
            return s.isAttribute && s.name === "matricesWeights" && i(s);
          });
          o || (o = new vt("matricesWeights")).setAsAttribute("matricesWeights"), o.output.connectTo(this.matricesWeights);
        }
        if (!this.world.isConnected) {
          var a = e.getInputBlockByPredicate(function(s) {
            return s.systemValue === Tt.World && i(s);
          });
          a || (a = new vt("world")).setAsSystemValue(Tt.World), a.output.connectTo(this.world);
        }
      }, t.prototype.provideFallbacks = function(e, i) {
        e && e.useBones && e.computeBonesUsingShaders && e.skeleton && i.addCPUSkinningFallback(0, e);
      }, t.prototype.bind = function(e, i, r) {
        Se.BindBonesParameters(r, e);
      }, t.prototype.prepareDefines = function(e, i, r) {
        r._areAttributesDirty && Se.PrepareDefinesForBones(e, r);
      }, t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e), e.sharedData.blocksWithFallbacks.push(this), e.sharedData.forcedBindableBlocks.push(this), e.sharedData.blocksWithDefines.push(this), e.uniforms.push("boneTextureWidth"), e.uniforms.push("mBones"), e.samplers.push("boneSampler");
        var i = "//".concat(this.name);
        e._emitFunctionFromInclude("bonesDeclaration", i, { removeAttributes: !0, removeUniforms: !1, removeVaryings: !0, removeIfDef: !1 });
        var r = e._getFreeVariableName("influence");
        e.compilationString += e._emitCodeFromInclude("bonesVertex", i, { replaceStrings: [{ search: /finalWorld=finalWorld\*influence;/, replace: "" }, { search: /influence/gm, replace: r }] });
        var o = this._outputs[0], a = this.world;
        return e.compilationString += `#if NUM_BONE_INFLUENCERS>0
`, e.compilationString += this._declareOutput(o, e) + " = ".concat(a.associatedVariableName, " * ").concat(r, `;
`), e.compilationString += `#else
`, e.compilationString += this._declareOutput(o, e) + " = ".concat(a.associatedVariableName, `;
`), e.compilationString += `#endif
`, this;
      }, t;
    }(We);
    j("BABYLON.BonesBlock", lb);
    var cb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Vertex) || this;
        return i.registerInput("world0", M.Vector4), i.registerInput("world1", M.Vector4), i.registerInput("world2", M.Vector4), i.registerInput("world3", M.Vector4), i.registerInput("world", M.Matrix, !0), i.registerOutput("output", M.Matrix), i.registerOutput("instanceID", M.Float), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "InstancesBlock";
      }, Object.defineProperty(t.prototype, "world0", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "world1", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "world2", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "world3", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "world", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "instanceID", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function(e, i) {
        if (i === void 0 && (i = function() {
          return !0;
        }), !this.world0.connectedPoint) {
          var r = e.getInputBlockByPredicate(function(c) {
            return c.isAttribute && c.name === "world0" && i(c);
          });
          r || (r = new vt("world0")).setAsAttribute("world0"), r.output.connectTo(this.world0);
        }
        if (!this.world1.connectedPoint) {
          var o = e.getInputBlockByPredicate(function(c) {
            return c.isAttribute && c.name === "world1" && i(c);
          });
          o || (o = new vt("world1")).setAsAttribute("world1"), o.output.connectTo(this.world1);
        }
        if (!this.world2.connectedPoint) {
          var a = e.getInputBlockByPredicate(function(c) {
            return c.isAttribute && c.name === "world2" && i(c);
          });
          a || (a = new vt("world2")).setAsAttribute("world2"), a.output.connectTo(this.world2);
        }
        if (!this.world3.connectedPoint) {
          var s = e.getInputBlockByPredicate(function(c) {
            return c.isAttribute && c.name === "world3" && i(c);
          });
          s || (s = new vt("world3")).setAsAttribute("world3"), s.output.connectTo(this.world3);
        }
        if (!this.world.connectedPoint) {
          var l = e.getInputBlockByPredicate(function(c) {
            return c.isAttribute && c.name === "world" && i(c);
          });
          l || (l = new vt("world")).setAsSystemValue(Tt.World), l.output.connectTo(this.world);
        }
        this.world.define = "!INSTANCES || THIN_INSTANCES";
      }, t.prototype.prepareDefines = function(e, i, r, o, a) {
        o === void 0 && (o = !1);
        var s = !1;
        r.INSTANCES !== o && (r.setValue("INSTANCES", o), s = !0), a && r.THIN_INSTANCES !== !!(a != null && a.getRenderingMesh().hasThinInstances) && (r.setValue("THIN_INSTANCES", !!(a != null && a.getRenderingMesh().hasThinInstances)), s = !0), s && r.markAsUnprocessed();
      }, t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = e.sharedData.scene.getEngine();
        e.sharedData.blocksWithDefines.push(this);
        var r = this._outputs[0], o = this._outputs[1], a = this.world0, s = this.world1, l = this.world2, c = this.world3;
        return e.compilationString += `#ifdef INSTANCES
`, e.compilationString += this._declareOutput(r, e) + " = mat4(".concat(a.associatedVariableName, ", ").concat(s.associatedVariableName, ", ").concat(l.associatedVariableName, ", ").concat(c.associatedVariableName, `);
`), e.compilationString += `#ifdef THIN_INSTANCES
`, e.compilationString += "".concat(r.associatedVariableName, " = ").concat(this.world.associatedVariableName, " * ").concat(r.associatedVariableName, `;
`), e.compilationString += `#endif
`, i._caps.canUseGLInstanceID ? e.compilationString += this._declareOutput(o, e) + ` = float(gl_InstanceID);
` : e.compilationString += this._declareOutput(o, e) + ` = 0.0;
`, e.compilationString += `#else
`, e.compilationString += this._declareOutput(r, e) + " = ".concat(this.world.associatedVariableName, `;
`), e.compilationString += this._declareOutput(o, e) + ` = 0.0;
`, e.compilationString += `#endif
`, this;
      }, t;
    }(We);
    j("BABYLON.InstancesBlock", cb);
    var F_ = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Vertex) || this;
        return i.registerInput("position", M.Vector3), i.registerInput("normal", M.Vector3), i.registerInput("tangent", M.AutoDetect), i.tangent.addExcludedConnectionPointFromAllowedTypes(M.Color4 | M.Vector4 | M.Vector3), i.registerInput("uv", M.Vector2), i.registerOutput("positionOutput", M.Vector3), i.registerOutput("normalOutput", M.Vector3), i.registerOutput("tangentOutput", M.Vector4), i.registerOutput("uvOutput", M.Vector2), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "MorphTargetsBlock";
      }, Object.defineProperty(t.prototype, "position", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "normal", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tangent", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "uv", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "positionOutput", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "normalOutput", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tangentOutput", { get: function() {
        return this._outputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "uvOutput", { get: function() {
        return this._outputs[3];
      }, enumerable: !1, configurable: !0 }), t.prototype.initialize = function(e) {
        e._excludeVariableName("morphTargetInfluences");
      }, t.prototype.autoConfigure = function(e, i) {
        if (i === void 0 && (i = function() {
          return !0;
        }), !this.position.isConnected) {
          var r = e.getInputBlockByPredicate(function(l) {
            return l.isAttribute && l.name === "position" && i(l);
          });
          r || (r = new vt("position")).setAsAttribute(), r.output.connectTo(this.position);
        }
        if (!this.normal.isConnected) {
          var o = e.getInputBlockByPredicate(function(l) {
            return l.isAttribute && l.name === "normal" && i(l);
          });
          o || (o = new vt("normal")).setAsAttribute("normal"), o.output.connectTo(this.normal);
        }
        if (!this.tangent.isConnected) {
          var a = e.getInputBlockByPredicate(function(l) {
            return l.isAttribute && l.name === "tangent" && i(l);
          });
          a || (a = new vt("tangent")).setAsAttribute("tangent"), a.output.connectTo(this.tangent);
        }
        if (!this.uv.isConnected) {
          var s = e.getInputBlockByPredicate(function(l) {
            return l.isAttribute && l.name === "uv" && i(l);
          });
          s || (s = new vt("uv")).setAsAttribute("uv"), s.output.connectTo(this.uv);
        }
      }, t.prototype.prepareDefines = function(e, i, r) {
        if (e.morphTargetManager) {
          var o = e.morphTargetManager;
          o != null && o.isUsingTextureForTargets && o.numInfluencers !== r.NUM_MORPH_INFLUENCERS && r.markAsAttributesDirty();
        }
        r._areAttributesDirty && Se.PrepareDefinesForMorphTargets(e, r);
      }, t.prototype.bind = function(e, i, r) {
        r && r.morphTargetManager && r.morphTargetManager.numInfluencers > 0 && (Se.BindMorphTargetParameters(r, e), r.morphTargetManager.isUsingTextureForTargets && r.morphTargetManager._bind(e));
      }, t.prototype.replaceRepeatableContent = function(e, i, r, o) {
        var a = this.position, s = this.normal, l = this.tangent, c = this.uv, u = this.positionOutput, h = this.normalOutput, d = this.tangentOutput, p = this.uvOutput, f = e, m = o.NUM_MORPH_INFLUENCERS, g = r.morphTargetManager, y = g && g.supportsNormals && o.NORMAL, b = g && g.supportsTangents && o.TANGENT, T = g && g.supportsUVs && o.UV1, S = "";
        g != null && g.isUsingTextureForTargets && m > 0 && (S += `float vertexID;
`);
        for (var E = 0; E < m; E++)
          S += `#ifdef MORPHTARGETS
`, g != null && g.isUsingTextureForTargets ? (S += `vertexID = float(gl_VertexID) * morphTargetTextureInfo.x;
`, S += "".concat(u.associatedVariableName, " += (readVector3FromRawSampler(").concat(E, ", vertexID) - ").concat(a.associatedVariableName, ") * morphTargetInfluences[").concat(E, `];
`), S += `vertexID += 1.0;
`) : S += "".concat(u.associatedVariableName, " += (position").concat(E, " - ").concat(a.associatedVariableName, ") * morphTargetInfluences[").concat(E, `];
`), y && (S += `#ifdef MORPHTARGETS_NORMAL
`, g != null && g.isUsingTextureForTargets ? (S += "".concat(h.associatedVariableName, " += (readVector3FromRawSampler(").concat(E, ", vertexID) - ").concat(s.associatedVariableName, ") * morphTargetInfluences[").concat(E, `];
`), S += `vertexID += 1.0;
`) : S += "".concat(h.associatedVariableName, " += (normal").concat(E, " - ").concat(s.associatedVariableName, ") * morphTargetInfluences[").concat(E, `];
`), S += `#endif
`), T && (S += `#ifdef MORPHTARGETS_UV
`, g != null && g.isUsingTextureForTargets ? (S += "".concat(p.associatedVariableName, " += (readVector3FromRawSampler(").concat(E, ", vertexID).xy - ").concat(c.associatedVariableName, ") * morphTargetInfluences[").concat(E, `];
`), S += `vertexID += 1.0;
`) : S += "".concat(p.associatedVariableName, ".xy += (uv_").concat(E, " - ").concat(c.associatedVariableName, ".xy) * morphTargetInfluences[").concat(E, `];
`), S += `#endif
`), b && (S += `#ifdef MORPHTARGETS_TANGENT
`, g != null && g.isUsingTextureForTargets ? S += "".concat(d.associatedVariableName, ".xyz += (readVector3FromRawSampler(").concat(E, ", vertexID) - ").concat(l.associatedVariableName, ".xyz) * morphTargetInfluences[").concat(E, `];
`) : S += "".concat(d.associatedVariableName, ".xyz += (tangent").concat(E, " - ").concat(l.associatedVariableName, ".xyz) * morphTargetInfluences[").concat(E, `];
`), l.type === M.Vector4 ? S += "".concat(d.associatedVariableName, ".w = ").concat(l.associatedVariableName, `.w;
`) : S += "".concat(d.associatedVariableName, `.w = 1.;
`), S += `#endif
`), S += `#endif
`;
        if (f.compilationString = f.compilationString.replace(this._repeatableContentAnchor, S), m > 0)
          for (E = 0; E < m; E++)
            f.attributes.push(P.PositionKind + E), y && f.attributes.push(P.NormalKind + E), b && f.attributes.push(P.TangentKind + E), T && f.attributes.push(P.UVKind + "_" + E);
      }, t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e), e.sharedData.blocksWithDefines.push(this), e.sharedData.bindableBlocks.push(this), e.sharedData.repeatableContentBlocks.push(this);
        var i = this.position, r = this.normal, o = this.tangent, a = this.uv, s = this.positionOutput, l = this.normalOutput, c = this.tangentOutput, u = this.uvOutput, h = "//".concat(this.name);
        return e.uniforms.push("morphTargetInfluences"), e.uniforms.push("morphTargetTextureInfo"), e.uniforms.push("morphTargetTextureIndices"), e.samplers.push("morphTargets"), e._emitFunctionFromInclude("morphTargetsVertexGlobalDeclaration", h), e._emitFunctionFromInclude("morphTargetsVertexDeclaration", h, { repeatKey: "maxSimultaneousMorphTargets" }), e.compilationString += "".concat(this._declareOutput(s, e), " = ").concat(i.associatedVariableName, `;
`), e.compilationString += `#ifdef NORMAL
`, e.compilationString += "".concat(this._declareOutput(l, e), " = ").concat(r.associatedVariableName, `;
`), e.compilationString += `#else
`, e.compilationString += "".concat(this._declareOutput(l, e), ` = vec3(0., 0., 0.);
`), e.compilationString += `#endif
`, e.compilationString += `#ifdef TANGENT
`, e.compilationString += "".concat(this._declareOutput(c, e), " = ").concat(o.associatedVariableName, `;
`), e.compilationString += `#else
`, e.compilationString += "".concat(this._declareOutput(c, e), ` = vec4(0., 0., 0., 0.);
`), e.compilationString += `#endif
`, e.compilationString += `#ifdef UV1
`, e.compilationString += "".concat(this._declareOutput(u, e), " = ").concat(a.associatedVariableName, `;
`), e.compilationString += `#else
`, e.compilationString += "".concat(this._declareOutput(u, e), ` = vec2(0., 0.);
`), e.compilationString += `#endif
`, this._repeatableContentAnchor = e._repeatableContentAnchor, e.compilationString += this._repeatableContentAnchor, this;
      }, t;
    }(We);
    j("BABYLON.MorphTargetsBlock", F_);
    var ub = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Vertex) || this;
        return i.registerInput("worldPosition", M.Vector4, !1, W.Vertex), i.registerOutput("direction", M.Vector3), i.registerOutput("color", M.Color3), i.registerOutput("intensity", M.Float), i.registerOutput("shadowBias", M.Float), i.registerOutput("shadowNormalBias", M.Float), i.registerOutput("shadowDepthScale", M.Float), i.registerOutput("shadowDepthRange", M.Vector2), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "LightInformationBlock";
      }, Object.defineProperty(t.prototype, "worldPosition", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "direction", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "color", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "intensity", { get: function() {
        return this._outputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "shadowBias", { get: function() {
        return this._outputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "shadowNormalBias", { get: function() {
        return this._outputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "shadowDepthScale", { get: function() {
        return this._outputs[5];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "shadowDepthRange", { get: function() {
        return this._outputs[6];
      }, enumerable: !1, configurable: !0 }), t.prototype.bind = function(e, i, r) {
        if (r) {
          this.light && this.light.isDisposed() && (this.light = null);
          var o = this.light, a = i.getScene();
          if (!o && a.lights.length && (o = this.light = a.lights[0], this._forcePrepareDefines = !0), !o || !o.isEnabled)
            return e.setFloat3(this._lightDataUniformName, 0, 0, 0), void e.setFloat4(this._lightColorUniformName, 0, 0, 0, 0);
          o.transferToNodeMaterialEffect(e, this._lightDataUniformName), e.setColor4(this._lightColorUniformName, o.diffuse, o.intensity);
          var s = o.getShadowGenerator();
          if ((this.shadowBias.hasEndpoints || this.shadowNormalBias.hasEndpoints || this.shadowDepthScale.hasEndpoints) && (s ? e.setFloat3(this._lightShadowUniformName, s.bias, s.normalBias, s.depthScale) : e.setFloat3(this._lightShadowUniformName, 0, 0, 0)), this.shadowDepthRange)
            if (s && a.activeCamera) {
              var l = o;
              e.setFloat2(this._lightShadowExtraUniformName, l.getDepthMinZ(a.activeCamera), l.getDepthMinZ(a.activeCamera) + l.getDepthMaxZ(a.activeCamera));
            } else
              e.setFloat2(this._lightShadowExtraUniformName, 0, 0);
        }
      }, t.prototype.prepareDefines = function(e, i, r) {
        if (r._areLightsDirty || this._forcePrepareDefines) {
          this._forcePrepareDefines = !1;
          var o = this.light;
          r.setValue(this._lightTypeDefineName, !!(o && o instanceof T_), !0);
        }
      }, t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e), e.sharedData.bindableBlocks.push(this), e.sharedData.blocksWithDefines.push(this);
        var i = this.direction, r = this.color, o = this.intensity, a = this.shadowBias, s = this.shadowNormalBias, l = this.shadowDepthScale, c = this.shadowDepthRange;
        return this._lightDataUniformName = e._getFreeVariableName("lightData"), this._lightColorUniformName = e._getFreeVariableName("lightColor"), this._lightShadowUniformName = e._getFreeVariableName("shadowData"), this._lightShadowExtraUniformName = e._getFreeVariableName("shadowExtraData"), this._lightTypeDefineName = e._getFreeDefineName("LIGHTPOINTTYPE"), e._emitUniformFromString(this._lightDataUniformName, "vec3"), e._emitUniformFromString(this._lightColorUniformName, "vec4"), e.compilationString += "#ifdef ".concat(this._lightTypeDefineName, `
`), e.compilationString += this._declareOutput(i, e) + " = normalize(".concat(this.worldPosition.associatedVariableName, ".xyz - ").concat(this._lightDataUniformName, `);
`), e.compilationString += `#else
`, e.compilationString += this._declareOutput(i, e) + " = ".concat(this._lightDataUniformName, `;
`), e.compilationString += `#endif
`, e.compilationString += this._declareOutput(r, e) + " = ".concat(this._lightColorUniformName, `.rgb;
`), e.compilationString += this._declareOutput(o, e) + " = ".concat(this._lightColorUniformName, `.a;
`), (a.hasEndpoints || s.hasEndpoints || l.hasEndpoints) && (e._emitUniformFromString(this._lightShadowUniformName, "vec3"), a.hasEndpoints && (e.compilationString += this._declareOutput(a, e) + " = ".concat(this._lightShadowUniformName, `.x;
`)), s.hasEndpoints && (e.compilationString += this._declareOutput(s, e) + " = ".concat(this._lightShadowUniformName, `.y;
`)), l.hasEndpoints && (e.compilationString += this._declareOutput(l, e) + " = ".concat(this._lightShadowUniformName, `.z;
`))), c.hasEndpoints && (e._emitUniformFromString(this._lightShadowExtraUniformName, "vec2"), e.compilationString += this._declareOutput(c, e) + " = ".concat(this._lightShadowUniformName, `;
`)), this;
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return this.light && (e.lightId = this.light.id), e;
      }, t.prototype._deserialize = function(e, i, r) {
        n.prototype._deserialize.call(this, e, i, r), e.lightId && (this.light = i.getLightById(e.lightId));
      }, t;
    }(We);
    j("BABYLON.LightInformationBlock", ub);
    var hb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Fragment) || this;
        return i.convertInputToLinearSpace = !0, i.registerInput("color", M.AutoDetect), i.registerOutput("output", M.Color4), i.registerOutput("rgb", M.Color3), i._inputs[0].addExcludedConnectionPointFromAllowedTypes(M.Color3 | M.Color4 | M.Vector3 | M.Vector4), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ImageProcessingBlock";
      }, Object.defineProperty(t.prototype, "color", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgb", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), t.prototype.initialize = function(e) {
        e._excludeVariableName("exposureLinear"), e._excludeVariableName("contrast"), e._excludeVariableName("vInverseScreenSize"), e._excludeVariableName("vignetteSettings1"), e._excludeVariableName("vignetteSettings2"), e._excludeVariableName("vCameraColorCurveNegative"), e._excludeVariableName("vCameraColorCurveNeutral"), e._excludeVariableName("vCameraColorCurvePositive"), e._excludeVariableName("txColorTransform"), e._excludeVariableName("colorTransformSettings"), e._excludeVariableName("ditherIntensity");
      }, t.prototype.isReady = function(e, i, r) {
        return !(r._areImageProcessingDirty && i.imageProcessingConfiguration && !i.imageProcessingConfiguration.isReady());
      }, t.prototype.prepareDefines = function(e, i, r) {
        r._areImageProcessingDirty && i.imageProcessingConfiguration && i.imageProcessingConfiguration.prepareDefines(r);
      }, t.prototype.bind = function(e, i, r) {
        r && i.imageProcessingConfiguration && i.imageProcessingConfiguration.bind(e);
      }, t.prototype._buildBlock = function(e) {
        var i;
        n.prototype._buildBlock.call(this, e), e.sharedData.blocksWithDefines.push(this), e.sharedData.blockingBlocks.push(this), e.sharedData.bindableBlocks.push(this), e.uniforms.push("exposureLinear"), e.uniforms.push("contrast"), e.uniforms.push("vInverseScreenSize"), e.uniforms.push("vignetteSettings1"), e.uniforms.push("vignetteSettings2"), e.uniforms.push("vCameraColorCurveNegative"), e.uniforms.push("vCameraColorCurveNeutral"), e.uniforms.push("vCameraColorCurvePositive"), e.uniforms.push("txColorTransform"), e.uniforms.push("colorTransformSettings"), e.uniforms.push("ditherIntensity");
        var r = this.color, o = this._outputs[0], a = "//".concat(this.name);
        return e._emitFunctionFromInclude("helperFunctions", a), e._emitFunctionFromInclude("imageProcessingDeclaration", a), e._emitFunctionFromInclude("imageProcessingFunctions", a), !((i = r.connectedPoint) === null || i === void 0) && i.isConnected && (r.connectedPoint.type === M.Color4 || r.connectedPoint.type === M.Vector4 ? e.compilationString += "".concat(this._declareOutput(o, e), " = ").concat(r.associatedVariableName, `;
`) : e.compilationString += "".concat(this._declareOutput(o, e), " = vec4(").concat(r.associatedVariableName, `, 1.0);
`), e.compilationString += `#ifdef IMAGEPROCESSINGPOSTPROCESS
`, this.convertInputToLinearSpace && (e.compilationString += "".concat(o.associatedVariableName, ".rgb = toLinearSpace(").concat(r.associatedVariableName, `.rgb);
`)), e.compilationString += `#else
`, e.compilationString += `#ifdef IMAGEPROCESSING
`, this.convertInputToLinearSpace && (e.compilationString += "".concat(o.associatedVariableName, ".rgb = toLinearSpace(").concat(r.associatedVariableName, `.rgb);
`)), e.compilationString += "".concat(o.associatedVariableName, " = applyImageProcessing(").concat(o.associatedVariableName, `);
`), e.compilationString += `#endif
`, e.compilationString += `#endif
`, this.rgb.hasEndpoints && (e.compilationString += this._declareOutput(this.rgb, e) + " = ".concat(this.output.associatedVariableName, `.xyz;
`))), this;
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".convertInputToLinearSpace = ").concat(this.convertInputToLinearSpace, `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.convertInputToLinearSpace = this.convertInputToLinearSpace, e;
      }, t.prototype._deserialize = function(e, i, r) {
        var o;
        n.prototype._deserialize.call(this, e, i, r), this.convertInputToLinearSpace = (o = e.convertInputToLinearSpace) === null || o === void 0 || o;
      }, x([qe("Convert input to linear space", Ye.Boolean, "ADVANCED")], t.prototype, "convertInputToLinearSpace", void 0), t;
    }(We);
    j("BABYLON.ImageProcessingBlock", hb);
    var su = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Fragment, !0) || this;
        return i.registerInput("normal", M.AutoDetect, !1), i.normal.addExcludedConnectionPointFromAllowedTypes(M.Color4 | M.Vector4 | M.Vector3), i.registerInput("tangent", M.Vector4, !1), i.registerInput("world", M.Matrix, !1), i.registerOutput("TBN", M.Object, W.Fragment, new xi("TBN", i, ui.Output, t, "TBNBlock")), i.registerOutput("row0", M.Vector3, W.Fragment), i.registerOutput("row1", M.Vector3, W.Fragment), i.registerOutput("row2", M.Vector3, W.Fragment), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "TBNBlock";
      }, t.prototype.initialize = function(e) {
        e._excludeVariableName("tbnNormal"), e._excludeVariableName("tbnTangent"), e._excludeVariableName("tbnBitangent"), e._excludeVariableName("TBN");
      }, Object.defineProperty(t.prototype, "normal", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tangent", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "world", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "TBN", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "row0", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "row1", { get: function() {
        return this._outputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "row2", { get: function() {
        return this._outputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "target", { get: function() {
        return W.Fragment;
      }, set: function(e) {
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function(e, i) {
        if (i === void 0 && (i = function() {
          return !0;
        }), !this.world.isConnected) {
          var r = e.getInputBlockByPredicate(function(s) {
            return s.isSystemValue && s.systemValue === Tt.World && i(s);
          });
          r || (r = new vt("world")).setAsSystemValue(Tt.World), r.output.connectTo(this.world);
        }
        if (!this.normal.isConnected) {
          var o = e.getInputBlockByPredicate(function(s) {
            return s.isAttribute && s.name === "normal" && i(s);
          });
          o || (o = new vt("normal")).setAsAttribute("normal"), o.output.connectTo(this.normal);
        }
        if (!this.tangent.isConnected) {
          var a = e.getInputBlockByPredicate(function(s) {
            return s.isAttribute && s.name === "tangent" && s.type === M.Vector4 && i(s);
          });
          a || (a = new vt("tangent")).setAsAttribute("tangent"), a.output.connectTo(this.tangent);
        }
      }, t.prototype.prepareDefines = function(e, i, r) {
        var o, a, s, l, c = this.normal, u = this.tangent, h = c.isConnected;
        !((o = c.connectInputBlock) === null || o === void 0) && o.isAttribute && !e.isVerticesDataPresent((a = c.connectInputBlock) === null || a === void 0 ? void 0 : a.name) && (h = !1);
        var d = u.isConnected;
        !((s = u.connectInputBlock) === null || s === void 0) && s.isAttribute && !e.isVerticesDataPresent((l = u.connectInputBlock) === null || l === void 0 ? void 0 : l.name) && (d = !1);
        var p = h && d;
        r.setValue("TBNBLOCK", p, !0);
      }, t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this.normal, r = this.tangent, o = this.world, a = this.TBN, s = this.row0, l = this.row1, c = this.row2;
        return e.target === W.Fragment && (e.compilationString += `
                // `.concat(this.name, `
                vec3 tbnNormal = normalize(`).concat(i.associatedVariableName, `).xyz;
                vec3 tbnTangent = normalize(`).concat(r.associatedVariableName, `.xyz);
                vec3 tbnBitangent = cross(tbnNormal, tbnTangent) * `).concat(r.associatedVariableName, `.w;
                mat3 `).concat(a.associatedVariableName, " = mat3(").concat(o.associatedVariableName, `) * mat3(tbnTangent, tbnBitangent, tbnNormal);
            `), s.hasEndpoints && (e.compilationString += this._declareOutput(s, e) + " = vec3(".concat(a.associatedVariableName, "[0][0], ").concat(a.associatedVariableName, "[0][1], ").concat(a.associatedVariableName, `[0][2]);
`)), l.hasEndpoints && (e.compilationString += this._declareOutput(l, e) + " = vec3(".concat(a.associatedVariableName, "[1[0], ").concat(a.associatedVariableName, "[1][1], ").concat(a.associatedVariableName, `[1][2]);
`)), c.hasEndpoints && (e.compilationString += this._declareOutput(c, e) + " = vec3(".concat(a.associatedVariableName, "[2][0], ").concat(a.associatedVariableName, "[2][1], ").concat(a.associatedVariableName, `[2][2]);
`)), e.sharedData.blocksWithDefines.push(this)), this;
      }, t;
    }(We);
    j("BABYLON.TBNBlock", su);
    var db = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Fragment) || this;
        return i._tangentSpaceParameterName = "", i._tangentCorrectionFactorName = "", i._worldMatrixName = "", i.invertX = !1, i.invertY = !1, i.useParallaxOcclusion = !1, i.useObjectSpaceNormalMap = !1, i._isUnique = !0, i.registerInput("worldPosition", M.Vector4, !1), i.registerInput("worldNormal", M.Vector4, !1), i.registerInput("worldTangent", M.Vector4, !0), i.registerInput("uv", M.Vector2, !1), i.registerInput("normalMapColor", M.Color3, !1), i.registerInput("strength", M.Float, !1), i.registerInput("viewDirection", M.Vector3, !0), i.registerInput("parallaxScale", M.Float, !0), i.registerInput("parallaxHeight", M.Float, !0), i.registerInput("TBN", M.Object, !0, W.VertexAndFragment, new xi("TBN", i, ui.Input, su, "TBNBlock")), i.registerInput("world", M.Matrix, !0), i.registerOutput("output", M.Vector4), i.registerOutput("uvOffset", M.Vector2), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "PerturbNormalBlock";
      }, Object.defineProperty(t.prototype, "worldPosition", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldNormal", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldTangent", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "uv", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "normalMapColor", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "strength", { get: function() {
        return this._inputs[5];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "viewDirection", { get: function() {
        return this._inputs[6];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "parallaxScale", { get: function() {
        return this._inputs[7];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "parallaxHeight", { get: function() {
        return this._inputs[8];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "TBN", { get: function() {
        return this._inputs[9];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "world", { get: function() {
        return this._inputs[10];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "uvOffset", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), t.prototype.prepareDefines = function(e, i, r) {
        var o = this.normalMapColor.connectedPoint._ownerBlock.samplerName, a = this.viewDirection.isConnected && (this.useParallaxOcclusion && o || !this.useParallaxOcclusion && this.parallaxHeight.isConnected);
        r.setValue("BUMP", !0), r.setValue("PARALLAX", a, !0), r.setValue("PARALLAX_RHS", i.getScene().useRightHandedSystem, !0), r.setValue("PARALLAXOCCLUSION", this.useParallaxOcclusion, !0), r.setValue("OBJECTSPACE_NORMALMAP", this.useObjectSpaceNormalMap, !0);
      }, t.prototype.bind = function(e, i, r) {
        i.getScene()._mirroredCameraPosition ? e.setFloat2(this._tangentSpaceParameterName, this.invertX ? 1 : -1, this.invertY ? 1 : -1) : e.setFloat2(this._tangentSpaceParameterName, this.invertX ? -1 : 1, this.invertY ? -1 : 1), r && (e.setFloat(this._tangentCorrectionFactorName, r.getWorldMatrix().determinant() < 0 ? -1 : 1), this.useObjectSpaceNormalMap && !this.world.isConnected && e.setMatrix(this._worldMatrixName, r.getWorldMatrix()));
      }, t.prototype.autoConfigure = function(e, i) {
        if (i === void 0 && (i = function() {
          return !0;
        }), !this.uv.isConnected) {
          var r = e.getInputBlockByPredicate(function(a) {
            return a.isAttribute && a.name === "uv" && i(a);
          });
          r || (r = new vt("uv")).setAsAttribute(), r.output.connectTo(this.uv);
        }
        if (!this.strength.isConnected) {
          var o = new vt("strength");
          o.value = 1, o.output.connectTo(this.strength);
        }
      }, t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = "//".concat(this.name), r = this.uv, o = this.worldPosition, a = this.worldNormal, s = this.worldTangent;
        e.sharedData.blocksWithDefines.push(this), e.sharedData.bindableBlocks.push(this), this._tangentSpaceParameterName = e._getFreeDefineName("tangentSpaceParameter"), e._emitUniformFromString(this._tangentSpaceParameterName, "vec2"), this._tangentCorrectionFactorName = e._getFreeDefineName("tangentCorrectionFactor"), e._emitUniformFromString(this._tangentCorrectionFactorName, "float"), this._worldMatrixName = e._getFreeDefineName("perturbNormalWorldMatrix"), e._emitUniformFromString(this._worldMatrixName, "mat4");
        var l = null;
        this.normalMapColor.connectedPoint && (l = this.normalMapColor.connectedPoint._ownerBlock.samplerName);
        var c = this.viewDirection.isConnected && (this.useParallaxOcclusion && l || !this.useParallaxOcclusion && this.parallaxHeight.isConnected), u = this.parallaxScale.isConnectedToInputBlock ? this.parallaxScale.connectInputBlock.isConstant ? e._emitFloat(this.parallaxScale.connectInputBlock.value) : this.parallaxScale.associatedVariableName : "0.05", h = this.strength.isConnectedToInputBlock && this.strength.connectInputBlock.isConstant ? `
#if !defined(NORMALXYSCALE)
1.0/
#endif
`.concat(e._emitFloat(this.strength.connectInputBlock.value)) : `
#if !defined(NORMALXYSCALE)
1.0/
#endif
`.concat(this.strength.associatedVariableName);
        e._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable");
        var d = { search: /defined\(TANGENT\)/g, replace: s.isConnected ? "defined(TANGENT)" : "defined(IGNORE)" }, p = this.TBN;
        p.isConnected ? e.compilationString += `
            #ifdef TBNBLOCK
            mat3 vTBN = `.concat(p.associatedVariableName, `;
            #endif
            `) : s.isConnected && (e.compilationString += "vec3 tbnNormal = normalize(".concat(a.associatedVariableName, `.xyz);
`), e.compilationString += "vec3 tbnTangent = normalize(".concat(s.associatedVariableName, `.xyz);
`), e.compilationString += "vec3 tbnBitangent = cross(tbnNormal, tbnTangent) * ".concat(this._tangentCorrectionFactorName, `;
`), e.compilationString += `mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);
`), e._emitFunctionFromInclude("bumpFragmentMainFunctions", i, { replaceStrings: [d, { search: /varying mat3 vTBN;/g, replace: "" }, { search: /uniform mat4 normalMatrix;/g, replace: "" }] }), e._emitFunctionFromInclude("bumpFragmentFunctions", i, { replaceStrings: [{ search: /#include<samplerFragmentDeclaration>\(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump\)/g, replace: "" }, { search: /uniform sampler2D bumpSampler;/g, replace: "" }, { search: /vec2 parallaxOcclusion\(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale\)/g, replace: `#define inline
vec2 parallaxOcclusion(vec3 vViewDirCoT, vec3 vNormalCoT, vec2 texCoord, float parallaxScale, sampler2D bumpSampler)` }, { search: /vec2 parallaxOffset\(vec3 viewDir,float heightScale\)/g, replace: "vec2 parallaxOffset(vec3 viewDir, float heightScale, float height_)" }, { search: /texture2D\(bumpSampler,vBumpUV\)\.w/g, replace: "height_" }] });
        var f = c && l ? "texture2D(".concat(l, ", ").concat(r.associatedVariableName, " + uvOffset).xyz") : this.normalMapColor.associatedVariableName;
        return e.compilationString += this._declareOutput(this.output, e) + ` = vec4(0.);
`, e.compilationString += e._emitCodeFromInclude("bumpFragment", i, { replaceStrings: [{ search: /texture2D\(bumpSampler,vBumpUV\)/g, replace: "".concat(f) }, { search: /#define CUSTOM_FRAGMENT_BUMP_FRAGMENT/g, replace: "mat4 normalMatrix = toNormalMatrix(".concat(this.world.isConnected ? this.world.associatedVariableName : this._worldMatrixName, ");") }, { search: /perturbNormal\(TBN,texture2D\(bumpSampler,vBumpUV\+uvOffset\).xyz,vBumpInfos.y\)/g, replace: "perturbNormal(TBN, ".concat(f, ", vBumpInfos.y)") }, { search: /parallaxOcclusion\(invTBN\*-viewDirectionW,invTBN\*normalW,vBumpUV,vBumpInfos.z\)/g, replace: "parallaxOcclusion((invTBN * -viewDirectionW), (invTBN * normalW), vBumpUV, vBumpInfos.z, ".concat(c && this.useParallaxOcclusion ? l : "bumpSampler", ")") }, { search: /parallaxOffset\(invTBN\*viewDirectionW,vBumpInfos\.z\)/g, replace: "parallaxOffset(invTBN * viewDirectionW, vBumpInfos.z, ".concat(c ? this.parallaxHeight.associatedVariableName : "0.", ")") }, { search: /vTangentSpaceParams/g, replace: this._tangentSpaceParameterName }, { search: /vBumpInfos.y/g, replace: h }, { search: /vBumpInfos.z/g, replace: u }, { search: /vBumpUV/g, replace: r.associatedVariableName }, { search: /vPositionW/g, replace: o.associatedVariableName + ".xyz" }, { search: /normalW=/g, replace: this.output.associatedVariableName + ".xyz = " }, { search: /mat3\(normalMatrix\)\*normalW/g, replace: "mat3(normalMatrix) * " + this.output.associatedVariableName + ".xyz" }, { search: /normalW/g, replace: a.associatedVariableName + ".xyz" }, { search: /viewDirectionW/g, replace: c ? this.viewDirection.associatedVariableName : "vec3(0.)" }, d] }), this;
      }, t.prototype._dumpPropertiesCode = function() {
        var e = n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".invertX = ").concat(this.invertX, `;
`);
        return e += "".concat(this._codeVariableName, ".invertY = ").concat(this.invertY, `;
`), (e += "".concat(this._codeVariableName, ".useParallaxOcclusion = ").concat(this.useParallaxOcclusion, `;
`)) + "".concat(this._codeVariableName, ".useObjectSpaceNormalMap = ").concat(this.useObjectSpaceNormalMap, `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.invertX = this.invertX, e.invertY = this.invertY, e.useParallaxOcclusion = this.useParallaxOcclusion, e.useObjectSpaceNormalMap = this.useObjectSpaceNormalMap, e;
      }, t.prototype._deserialize = function(e, i, r) {
        n.prototype._deserialize.call(this, e, i, r), this.invertX = e.invertX, this.invertY = e.invertY, this.useParallaxOcclusion = !!e.useParallaxOcclusion, this.useObjectSpaceNormalMap = !!e.useObjectSpaceNormalMap;
      }, x([qe("Invert X axis", Ye.Boolean, "PROPERTIES", { notifiers: { update: !1 } })], t.prototype, "invertX", void 0), x([qe("Invert Y axis", Ye.Boolean, "PROPERTIES", { notifiers: { update: !1 } })], t.prototype, "invertY", void 0), x([qe("Use parallax occlusion", Ye.Boolean)], t.prototype, "useParallaxOcclusion", void 0), x([qe("Object Space Mode", Ye.Boolean, "PROPERTIES", { notifiers: { update: !1 } })], t.prototype, "useObjectSpaceNormalMap", void 0), t;
    }(We);
    j("BABYLON.PerturbNormalBlock", db);
    var pb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Fragment, !0) || this;
        return i.registerInput("value", M.Float, !0), i.registerInput("cutoff", M.Float, !0), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "DiscardBlock";
      }, Object.defineProperty(t.prototype, "value", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cutoff", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        if (n.prototype._buildBlock.call(this, e), e.sharedData.hints.needAlphaTesting = !0, this.cutoff.isConnected && this.value.isConnected)
          return e.compilationString += "if (".concat(this.value.associatedVariableName, " < ").concat(this.cutoff.associatedVariableName, `) discard;
`), this;
      }, t;
    }(We);
    j("BABYLON.DiscardBlock", pb);
    var fb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Fragment) || this;
        return i.registerOutput("output", M.Float, W.Fragment), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "FrontFacingBlock";
      }, Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        if (n.prototype._buildBlock.call(this, e), e.target === W.Vertex)
          throw "FrontFacingBlock must only be used in a fragment shader";
        var i = this._outputs[0];
        return e.compilationString += this._declareOutput(i, e) + ` = gl_FrontFacing ? 1.0 : 0.0;
`, this;
      }, t;
    }(We);
    j("BABYLON.FrontFacingBlock", fb);
    var _b = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Fragment) || this;
        return i.registerInput("input", M.AutoDetect, !1), i.registerOutput("dx", M.BasedOnInput), i.registerOutput("dy", M.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._outputs[1]._typeConnectionSource = i._inputs[0], i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "DerivativeBlock";
      }, Object.defineProperty(t.prototype, "input", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dx", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dy", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0], r = this._outputs[1];
        return e._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable"), i.hasEndpoints && (e.compilationString += this._declareOutput(i, e) + " = dFdx(".concat(this.input.associatedVariableName, `);
`)), r.hasEndpoints && (e.compilationString += this._declareOutput(r, e) + " = dFdy(".concat(this.input.associatedVariableName, `);
`)), this;
      }, t;
    }(We);
    j("BABYLON.DerivativeBlock", _b);
    var mb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Fragment) || this;
        return i.registerOutput("xy", M.Vector2, W.Fragment), i.registerOutput("xyz", M.Vector3, W.Fragment), i.registerOutput("xyzw", M.Vector4, W.Fragment), i.registerOutput("x", M.Float, W.Fragment), i.registerOutput("y", M.Float, W.Fragment), i.registerOutput("z", M.Float, W.Fragment), i.registerOutput("w", M.Float, W.Fragment), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "FragCoordBlock";
      }, Object.defineProperty(t.prototype, "xy", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyz", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyzw", { get: function() {
        return this._outputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "x", { get: function() {
        return this._outputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "y", { get: function() {
        return this._outputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "z", { get: function() {
        return this._outputs[5];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[6];
      }, enumerable: !1, configurable: !0 }), t.prototype.writeOutputs = function(e) {
        for (var i = "", r = 0, o = this._outputs; r < o.length; r++) {
          var a = o[r];
          a.hasEndpoints && (i += "".concat(this._declareOutput(a, e), " = gl_FragCoord.").concat(a.name, `;
`));
        }
        return i;
      }, t.prototype._buildBlock = function(e) {
        if (n.prototype._buildBlock.call(this, e), e.target === W.Vertex)
          throw "FragCoordBlock must only be used in a fragment shader";
        return e.compilationString += this.writeOutputs(e), this;
      }, t;
    }(We);
    j("BABYLON.FragCoordBlock", mb);
    var gb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Fragment) || this;
        return i.registerOutput("xy", M.Vector2, W.Fragment), i.registerOutput("x", M.Float, W.Fragment), i.registerOutput("y", M.Float, W.Fragment), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ScreenSizeBlock";
      }, Object.defineProperty(t.prototype, "xy", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "x", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "y", { get: function() {
        return this._outputs[2];
      }, enumerable: !1, configurable: !0 }), t.prototype.bind = function(e) {
        var i = this._scene.getEngine();
        e.setFloat2(this._varName, i.getRenderWidth(), i.getRenderHeight());
      }, t.prototype.writeOutputs = function(e, i) {
        for (var r = "", o = 0, a = this._outputs; o < a.length; o++) {
          var s = a[o];
          s.hasEndpoints && (r += "".concat(this._declareOutput(s, e), " = ").concat(i, ".").concat(s.name, `;
`));
        }
        return r;
      }, t.prototype._buildBlock = function(e) {
        if (n.prototype._buildBlock.call(this, e), this._scene = e.sharedData.scene, e.target === W.Vertex)
          throw "ScreenSizeBlock must only be used in a fragment shader";
        return e.sharedData.bindableBlocks.push(this), this._varName = e._getFreeVariableName("screenSize"), e._emitUniformFromString(this._varName, "vec2"), e.compilationString += this.writeOutputs(e, this._varName), this;
      }, t;
    }(We);
    j("BABYLON.ScreenSizeBlock", gb);
    var vb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Fragment) || this;
        return i.registerInput("vector", M.AutoDetect), i.registerInput("worldViewProjection", M.Matrix), i.registerOutput("output", M.Vector2), i.registerOutput("x", M.Float), i.registerOutput("y", M.Float), i.inputs[0].addExcludedConnectionPointFromAllowedTypes(M.Color3 | M.Vector3 | M.Vector4), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ScreenSpaceBlock";
      }, Object.defineProperty(t.prototype, "vector", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldViewProjection", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "x", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "y", { get: function() {
        return this._outputs[2];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function(e, i) {
        if (i === void 0 && (i = function() {
          return !0;
        }), !this.worldViewProjection.isConnected) {
          var r = e.getInputBlockByPredicate(function(o) {
            return o.systemValue === Tt.WorldViewProjection && i(o);
          });
          r || (r = new vt("worldViewProjection")).setAsSystemValue(Tt.WorldViewProjection), r.output.connectTo(this.worldViewProjection);
        }
      }, t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this.vector, r = this.worldViewProjection;
        if (i.connectedPoint) {
          var o = r.associatedVariableName, a = e._getFreeVariableName("screenSpaceTemp");
          switch (i.connectedPoint.type) {
            case M.Vector3:
              e.compilationString += "vec4 ".concat(a, " = ").concat(o, " * vec4(").concat(i.associatedVariableName, `, 1.0);
`);
              break;
            case M.Vector4:
              e.compilationString += "vec4 ".concat(a, " = ").concat(o, " * ").concat(i.associatedVariableName, `;
`);
          }
          return e.compilationString += "".concat(a, ".xy /= ").concat(a, ".w;"), e.compilationString += "".concat(a, ".xy = ").concat(a, ".xy * 0.5 + vec2(0.5, 0.5);"), this.output.hasEndpoints && (e.compilationString += this._declareOutput(this.output, e) + " = ".concat(a, `.xy;
`)), this.x.hasEndpoints && (e.compilationString += this._declareOutput(this.x, e) + " = ".concat(a, `.x;
`)), this.y.hasEndpoints && (e.compilationString += this._declareOutput(this.y, e) + " = ".concat(a, `.y;
`)), this;
        }
      }, t;
    }(We);
    j("BABYLON.ScreenSpaceBlock", vb);
    var yb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Fragment) || this;
        return i.registerInput("input", M.Vector2), i.registerInput("strength", M.Float), i.registerInput("center", M.Vector2), i.registerInput("offset", M.Vector2), i.registerOutput("output", M.Vector2), i.registerOutput("x", M.Float), i.registerOutput("y", M.Float), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "TwirlBlock";
      }, Object.defineProperty(t.prototype, "input", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "strength", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "center", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "offset", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "x", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "y", { get: function() {
        return this._outputs[2];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function() {
        if (!this.center.isConnected) {
          var e = new vt("center");
          e.value = new fe(0.5, 0.5), e.output.connectTo(this.center);
        }
        if (!this.strength.isConnected) {
          var i = new vt("strength");
          i.value = 1, i.output.connectTo(this.strength);
        }
        if (!this.offset.isConnected) {
          var r = new vt("offset");
          r.value = new fe(0, 0), r.output.connectTo(this.offset);
        }
      }, t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = e._getFreeVariableName("delta"), r = e._getFreeVariableName("angle"), o = e._getFreeVariableName("x"), a = e._getFreeVariableName("y"), s = e._getFreeVariableName("result");
        return e.compilationString += `
            vec2 `.concat(i, " = ").concat(this.input.associatedVariableName, " - ").concat(this.center.associatedVariableName, `;
            float `).concat(r, " = ").concat(this.strength.associatedVariableName, " * length(").concat(i, `);
            float `).concat(o, " = cos(").concat(r, ") * ").concat(i, ".x - sin(").concat(r, ") * ").concat(i, `.y;
            float `).concat(a, " = sin(").concat(r, ") * ").concat(i, ".x + cos(").concat(r, ") * ").concat(i, `.y;
            vec2 `).concat(s, " = vec2(").concat(o, " + ").concat(this.center.associatedVariableName, ".x + ").concat(this.offset.associatedVariableName, ".x, ").concat(a, " + ").concat(this.center.associatedVariableName, ".y + ").concat(this.offset.associatedVariableName, `.y);
        `), this.output.hasEndpoints && (e.compilationString += this._declareOutput(this.output, e) + " = ".concat(s, `;
`)), this.x.hasEndpoints && (e.compilationString += this._declareOutput(this.x, e) + " = ".concat(s, `.x;
`)), this.y.hasEndpoints && (e.compilationString += this._declareOutput(this.y, e) + " = ".concat(s, `.y;
`)), this;
      }, t;
    }(We);
    j("BABYLON.TwirlBlock", yb);
    var bb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Fragment) || this;
        return i.generateInWorldSpace = !1, i.automaticNormalizationNormal = !0, i.automaticNormalizationTangent = !0, i.registerInput("input", M.Float), i.registerInput("worldPosition", M.Vector3), i.registerInput("worldNormal", M.Vector3), i.registerInput("worldTangent", M.AutoDetect, !0), i.registerOutput("output", M.Vector4), i.registerOutput("xyz", M.Vector3), i._inputs[3].addExcludedConnectionPointFromAllowedTypes(M.Color3 | M.Vector3 | M.Vector4), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "HeightToNormalBlock";
      }, Object.defineProperty(t.prototype, "input", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldPosition", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldNormal", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldTangent", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyz", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        this.generateInWorldSpace || this.worldTangent.isConnected || console.error("You must connect the 'worldTangent' input of the ".concat(this.name, " block!"));
        var r = this.generateInWorldSpace ? "" : `
            vec3 biTangent = cross(normal, tangent);
            mat3 TBN = mat3(tangent, biTangent, normal);
            `, o = this.generateInWorldSpace ? "" : `
            result = TBN * result;
            result = result * vec3(0.5) + vec3(0.5);
            `, a = `
            vec4 heightToNormal(in float height, in vec3 position, in vec3 tangent, in vec3 normal) {
                `.concat(r, `
                `).concat(this.automaticNormalizationTangent ? "tangent = normalize(tangent);" : "", `
                `).concat(this.automaticNormalizationNormal ? "normal = normalize(normal);" : "", `
                vec3 worlddX = dFdx(position);
                vec3 worlddY = dFdy(position);
                vec3 crossX = cross(normal, worlddX);
                vec3 crossY = cross(normal, worlddY);
                float d = abs(dot(crossY, worlddX));
                vec3 inToNormal = vec3(((((height + dFdx(height)) - height) * crossY) + (((height + dFdy(height)) - height) * crossX)) * sign(d));
                inToNormal.y *= -1.0;
                vec3 result = normalize((d * normal) - inToNormal);
                `).concat(o, `
                return vec4(result, 0.);
            }`);
        return e._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable"), e._emitFunction("heightToNormal", a, "// heightToNormal"), e.compilationString += this._declareOutput(i, e) + " = heightToNormal(".concat(this.input.associatedVariableName, ", ").concat(this.worldPosition.associatedVariableName, ", ").concat(this.worldTangent.isConnected ? this.worldTangent.associatedVariableName : "vec3(0.)", ".xyz, ").concat(this.worldNormal.associatedVariableName, `);
`), this.xyz.hasEndpoints && (e.compilationString += this._declareOutput(this.xyz, e) + " = ".concat(this.output.associatedVariableName, `.xyz;
`)), this;
      }, t.prototype._dumpPropertiesCode = function() {
        var e = n.prototype._dumpPropertiesCode.call(this);
        return e += "".concat(this._codeVariableName, ".generateInWorldSpace = ").concat(this.generateInWorldSpace, `;
`), (e += "".concat(this._codeVariableName, ".automaticNormalizationNormal = ").concat(this.automaticNormalizationNormal, `;
`)) + "".concat(this._codeVariableName, ".automaticNormalizationTangent = ").concat(this.automaticNormalizationTangent, `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.generateInWorldSpace = this.generateInWorldSpace, e.automaticNormalizationNormal = this.automaticNormalizationNormal, e.automaticNormalizationTangent = this.automaticNormalizationTangent, e;
      }, t.prototype._deserialize = function(e, i, r) {
        n.prototype._deserialize.call(this, e, i, r), this.generateInWorldSpace = e.generateInWorldSpace, this.automaticNormalizationNormal = e.automaticNormalizationNormal, this.automaticNormalizationTangent = e.automaticNormalizationTangent;
      }, x([qe("Generate in world space instead of tangent space", Ye.Boolean, "PROPERTIES", { notifiers: { update: !0 } })], t.prototype, "generateInWorldSpace", void 0), x([qe("Force normalization for the worldNormal input", Ye.Boolean, "PROPERTIES", { notifiers: { update: !0 } })], t.prototype, "automaticNormalizationNormal", void 0), x([qe("Force normalization for the worldTangent input", Ye.Boolean, "PROPERTIES", { notifiers: { update: !0 } })], t.prototype, "automaticNormalizationTangent", void 0), t;
    }(We);
    j("BABYLON.HeightToNormalBlock", bb);
    var Tb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Fragment, !0) || this;
        return i.registerInput("depth", M.Float, !0), i.registerInput("worldPos", M.Vector4, !0), i.registerInput("viewProjection", M.Matrix, !0), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "FragDepthBlock";
      }, Object.defineProperty(t.prototype, "depth", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldPos", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "viewProjection", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        return n.prototype._buildBlock.call(this, e), this.depth.isConnected ? e.compilationString += "gl_FragDepth = ".concat(this.depth.associatedVariableName, `;
`) : this.worldPos.isConnected && this.viewProjection.isConnected ? e.compilationString += `
                vec4 p = `.concat(this.viewProjection.associatedVariableName, " * ").concat(this.worldPos.associatedVariableName, `;
                float v = p.z / p.w;
                #ifndef IS_NDC_HALF_ZRANGE
                    v = v * 0.5 + 0.5;
                #endif
                gl_FragDepth = v;
    
            `) : console.warn("FragDepthBlock: either the depth input or both the worldPos and viewProjection inputs must be connected!"), this;
      }, t;
    }(We);
    j("BABYLON.FragDepthBlock", Tb);
    var Eb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Fragment) || this;
        return i.registerInput("worldPosition", M.Vector4, !1), i.registerInput("viewProjection", M.Matrix, !1), i.registerInput("worldNormal", M.AutoDetect, !0), i.registerOutput("depth", M.Vector3), i.worldNormal.addExcludedConnectionPointFromAllowedTypes(M.Color3 | M.Vector3 | M.Vector4), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ShadowMapBlock";
      }, t.prototype.initialize = function(e) {
        e._excludeVariableName("vPositionWSM"), e._excludeVariableName("lightDataSM"), e._excludeVariableName("biasAndScaleSM"), e._excludeVariableName("depthValuesSM"), e._excludeVariableName("clipPos"), e._excludeVariableName("worldPos"), e._excludeVariableName("zSM");
      }, Object.defineProperty(t.prototype, "worldPosition", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "viewProjection", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldNormal", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "depth", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = "//".concat(this.name);
        return e._emitUniformFromString("biasAndScaleSM", "vec3"), e._emitUniformFromString("lightDataSM", "vec3"), e._emitUniformFromString("depthValuesSM", "vec2"), e._emitFunctionFromInclude("packingFunctions", i), e.compilationString += "vec4 worldPos = ".concat(this.worldPosition.associatedVariableName, `;
`), e.compilationString += `vec3 vPositionWSM;
`, e.compilationString += `float vDepthMetricSM = 0.0;
`, e.compilationString += `float zSM;
`, this.worldNormal.isConnected && (e.compilationString += "vec3 vNormalW = ".concat(this.worldNormal.associatedVariableName, `.xyz;
`), e.compilationString += e._emitCodeFromInclude("shadowMapVertexNormalBias", i)), e.compilationString += "vec4 clipPos = ".concat(this.viewProjection.associatedVariableName, ` * worldPos;
`), e.compilationString += e._emitCodeFromInclude("shadowMapVertexMetric", i, { replaceStrings: [{ search: /gl_Position/g, replace: "clipPos" }] }), e.compilationString += e._emitCodeFromInclude("shadowMapFragment", i, { replaceStrings: [{ search: /return;/g, replace: "" }] }), e.compilationString += `
            #if SM_DEPTHTEXTURE == 1
                #ifdef IS_NDC_HALF_ZRANGE
                    gl_FragDepth = (clipPos.z / clipPos.w);
                #else
                    gl_FragDepth = (clipPos.z / clipPos.w) * 0.5 + 0.5;
                #endif
            #endif
        `, e.compilationString += "".concat(this._declareOutput(this.depth, e), ` = vec3(depthSM, 1., 1.);
`), this;
      }, t;
    }(We);
    j("BABYLON.ShadowMapBlock", Eb);
    var Sb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Fragment, !0) || this;
        return i.registerInput("viewDepth", M.Float, !0), i.registerInput("worldPosition", M.AutoDetect, !0), i.registerInput("viewNormal", M.AutoDetect, !0), i.registerInput("reflectivity", M.AutoDetect, !0), i.inputs[1].addExcludedConnectionPointFromAllowedTypes(M.Vector3 | M.Vector4), i.inputs[2].addExcludedConnectionPointFromAllowedTypes(M.Vector3 | M.Vector4), i.inputs[3].addExcludedConnectionPointFromAllowedTypes(M.Vector3 | M.Vector4 | M.Color3 | M.Color4), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "PrePassOutputBlock";
      }, Object.defineProperty(t.prototype, "viewDepth", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldPosition", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "viewNormal", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "reflectivity", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this.worldPosition, r = this.viewNormal, o = this.viewDepth, a = this.reflectivity;
        e.sharedData.blocksWithDefines.push(this);
        var s = "//".concat(this.name);
        return e._emitFunctionFromInclude("helperFunctions", s), e.compilationString += `#if defined(PREPASS)\r
`, e.compilationString += `#ifdef PREPASS_DEPTH\r
`, o.connectedPoint ? e.compilationString += " gl_FragData[PREPASS_DEPTH_INDEX] = vec4(".concat(o.associatedVariableName, `, 0.0, 0.0, 1.0);\r
`) : e.compilationString += ` gl_FragData[PREPASS_DEPTH_INDEX] = vec4(0.0, 0.0, 0.0, 0.0);\r
`, e.compilationString += `#endif\r
`, e.compilationString += `#ifdef PREPASS_POSITION\r
`, i.connectedPoint ? e.compilationString += " gl_FragData[PREPASS_POSITION_INDEX] = vec4(".concat(i.associatedVariableName, ".rgb, ").concat(i.connectedPoint.type === M.Vector4 ? i.associatedVariableName + ".a" : "1.0", `);\r
`) : e.compilationString += ` gl_FragData[PREPASS_POSITION_INDEX] = vec4(0.0, 0.0, 0.0, 0.0);\r
`, e.compilationString += `#endif\r
`, e.compilationString += `#ifdef PREPASS_NORMAL\r
`, r.connectedPoint ? e.compilationString += " gl_FragData[PREPASS_NORMAL_INDEX] = vec4(".concat(r.associatedVariableName, ".rgb, ").concat(r.connectedPoint.type === M.Vector4 ? r.associatedVariableName + ".a" : "1.0", `);\r
`) : e.compilationString += ` gl_FragData[PREPASS_NORMAL_INDEX] = vec4(0.0, 0.0, 0.0, 0.0);\r
`, e.compilationString += `#endif\r
`, e.compilationString += `#ifdef PREPASS_REFLECTIVITY\r
`, a.connectedPoint ? e.compilationString += " gl_FragData[PREPASS_REFLECTIVITY_INDEX] = vec4(".concat(a.associatedVariableName, ".rgb, ").concat(a.connectedPoint.type === M.Vector4 ? a.associatedVariableName + ".a" : "1.0", `);\r
`) : e.compilationString += ` gl_FragData[PREPASS_REFLECTIVITY_INDEX] = vec4(0.0, 0.0, 0.0, 1.0);\r
`, e.compilationString += `#endif\r
`, e.compilationString += `#endif\r
`, this;
      }, t;
    }(We);
    j("BABYLON.PrePassOutputBlock", Sb);
    var xb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.VertexAndFragment, !1) || this;
        return i.registerInput("worldPosition", M.Vector4, !1, W.Vertex), i.registerInput("view", M.Matrix, !1, W.Vertex), i.registerInput("input", M.AutoDetect, !1, W.Fragment), i.registerInput("fogColor", M.AutoDetect, !1, W.Fragment), i.registerOutput("output", M.Color3, W.Fragment), i.input.addExcludedConnectionPointFromAllowedTypes(M.Color3 | M.Vector3 | M.Color4), i.fogColor.addExcludedConnectionPointFromAllowedTypes(M.Color3 | M.Vector3 | M.Color4), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "FogBlock";
      }, Object.defineProperty(t.prototype, "worldPosition", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "view", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "input", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "fogColor", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function(e, i) {
        if (i === void 0 && (i = function() {
          return !0;
        }), !this.view.isConnected) {
          var r = e.getInputBlockByPredicate(function(a) {
            return a.systemValue === Tt.View && i(a);
          });
          r || (r = new vt("view")).setAsSystemValue(Tt.View), r.output.connectTo(this.view);
        }
        if (!this.fogColor.isConnected) {
          var o = e.getInputBlockByPredicate(function(a) {
            return a.systemValue === Tt.FogColor && i(a);
          });
          o || (o = new vt("fogColor", void 0, M.Color3)).setAsSystemValue(Tt.FogColor), o.output.connectTo(this.fogColor);
        }
      }, t.prototype.prepareDefines = function(e, i, r) {
        var o = e.getScene();
        r.setValue("FOG", i.fogEnabled && Se.GetFogState(e, o));
      }, t.prototype.bind = function(e, i, r) {
        if (r) {
          var o = r.getScene();
          e.setFloat4(this._fogParameters, o.fogMode, o.fogStart, o.fogEnd, o.fogDensity);
        }
      }, t.prototype._buildBlock = function(e) {
        if (n.prototype._buildBlock.call(this, e), e.target === W.Fragment) {
          e.sharedData.blocksWithDefines.push(this), e.sharedData.bindableBlocks.push(this), e._emitFunctionFromInclude("fogFragmentDeclaration", "//".concat(this.name), { removeUniforms: !0, removeVaryings: !0, removeIfDef: !1, replaceStrings: [{ search: /float CalcFogFactor\(\)/, replace: "float CalcFogFactor(vec3 vFogDistance, vec4 vFogInfos)" }] });
          var i = e._getFreeVariableName("fog"), r = this.input, o = this.fogColor;
          this._fogParameters = e._getFreeVariableName("fogParameters");
          var a = this._outputs[0];
          e._emitUniformFromString(this._fogParameters, "vec4"), e.compilationString += `#ifdef FOG
`, e.compilationString += "float ".concat(i, " = CalcFogFactor(").concat(this._fogDistanceName, ", ").concat(this._fogParameters, `);
`), e.compilationString += this._declareOutput(a, e) + " = ".concat(i, " * ").concat(r.associatedVariableName, ".rgb + (1.0 - ").concat(i, ") * ").concat(o.associatedVariableName, `.rgb;
`), e.compilationString += `#else
`.concat(this._declareOutput(a, e), " =  ").concat(r.associatedVariableName, `.rgb;
`), e.compilationString += `#endif
`;
        } else {
          var s = this.worldPosition, l = this.view;
          this._fogDistanceName = e._getFreeVariableName("vFogDistance"), e._emitVaryingFromString(this._fogDistanceName, "vec3"), e.compilationString += "".concat(this._fogDistanceName, " = (").concat(l.associatedVariableName, " * ").concat(s.associatedVariableName, `).xyz;
`);
        }
        return this;
      }, t;
    }(We);
    j("BABYLON.FogBlock", xb);
    var Ab = function(n) {
      function t(e) {
        var i = n.call(this, e, W.VertexAndFragment) || this;
        return i._lightId = 0, i.generateOnlyFragmentCode = !1, i._isUnique = !0, i.registerInput("worldPosition", M.Vector4, !1, W.Vertex), i.registerInput("worldNormal", M.Vector4, !1, W.Fragment), i.registerInput("cameraPosition", M.Vector3, !1, W.Fragment), i.registerInput("glossiness", M.Float, !0, W.Fragment), i.registerInput("glossPower", M.Float, !0, W.Fragment), i.registerInput("diffuseColor", M.Color3, !0, W.Fragment), i.registerInput("specularColor", M.Color3, !0, W.Fragment), i.registerInput("view", M.Matrix, !0), i.registerOutput("diffuseOutput", M.Color3, W.Fragment), i.registerOutput("specularOutput", M.Color3, W.Fragment), i.registerOutput("shadow", M.Float, W.Fragment), i;
      }
      return D(t, n), t._OnGenerateOnlyFragmentCodeChanged = function(e, i) {
        var r = e;
        return r.worldPosition.isConnected ? (r.generateOnlyFragmentCode = !r.generateOnlyFragmentCode, console.error("The worldPosition input must not be connected to be able to switch!"), !1) : (r._setTarget(), !0);
      }, t.prototype._setTarget = function() {
        this._setInitialTarget(this.generateOnlyFragmentCode ? W.Fragment : W.VertexAndFragment), this.getInputByName("worldPosition").target = this.generateOnlyFragmentCode ? W.Fragment : W.Vertex;
      }, t.prototype.getClassName = function() {
        return "LightBlock";
      }, Object.defineProperty(t.prototype, "worldPosition", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldNormal", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraPosition", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "glossiness", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "glossPower", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "diffuseColor", { get: function() {
        return this._inputs[5];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "specularColor", { get: function() {
        return this._inputs[6];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "view", { get: function() {
        return this._inputs[7];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "diffuseOutput", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "specularOutput", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "shadow", { get: function() {
        return this._outputs[2];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function(e, i) {
        if (i === void 0 && (i = function() {
          return !0;
        }), !this.cameraPosition.isConnected) {
          var r = e.getInputBlockByPredicate(function(o) {
            return o.systemValue === Tt.CameraPosition && i(o);
          });
          r || (r = new vt("cameraPosition")).setAsSystemValue(Tt.CameraPosition), r.output.connectTo(this.cameraPosition);
        }
      }, t.prototype.prepareDefines = function(e, i, r) {
        if (r._areLightsDirty) {
          var o = e.getScene();
          if (this.light) {
            var a = { needNormals: !1, needRebuild: !1, lightmapMode: !1, shadowEnabled: !1, specularEnabled: !1 };
            Se.PrepareDefinesForLight(o, e, this.light, this._lightId, r, !0, a), a.needRebuild && r.rebuild();
          } else
            Se.PrepareDefinesForLights(o, e, r, !0, i.maxSimultaneousLights);
        }
      }, t.prototype.updateUniformsAndSamples = function(e, i, r, o) {
        for (var a = 0; a < i.maxSimultaneousLights && r["LIGHT" + a]; a++) {
          var s = e.uniforms.indexOf("vLightData" + a) >= 0;
          Se.PrepareUniformsAndSamplersForLight(a, e.uniforms, e.samplers, r["PROJECTEDLIGHTTEXTURE" + a], o, s);
        }
      }, t.prototype.bind = function(e, i, r) {
        if (r) {
          var o = r.getScene();
          this.light ? Se.BindLight(this.light, this._lightId, o, e, !0) : Se.BindLights(o, r, e, !0, i.maxSimultaneousLights);
        }
      }, t.prototype._injectVertexCode = function(e) {
        var i = this.worldPosition, r = "//".concat(this.name);
        this.light ? (this._lightId = (e.counters.lightCounter !== void 0 ? e.counters.lightCounter : -1) + 1, e.counters.lightCounter = this._lightId, e._emitFunctionFromInclude(e.supportUniformBuffers ? "lightVxUboDeclaration" : "lightVxFragmentDeclaration", r, { replaceStrings: [{ search: /{X}/g, replace: this._lightId.toString() }] }, this._lightId.toString())) : (e._emitFunctionFromInclude(e.supportUniformBuffers ? "lightVxUboDeclaration" : "lightVxFragmentDeclaration", r, { repeatKey: "maxSimultaneousLights" }), this._lightId = 0, e.sharedData.dynamicUniformBlocks.push(this));
        var o = "v_" + i.associatedVariableName;
        e._emitVaryingFromString(o, "vec4") && (e.compilationString += "".concat(o, " = ").concat(i.associatedVariableName, `;
`)), this.light ? e.compilationString += e._emitCodeFromInclude("shadowsVertex", r, { replaceStrings: [{ search: /{X}/g, replace: this._lightId.toString() }, { search: /worldPos/g, replace: i.associatedVariableName }] }) : (e.compilationString += "vec4 worldPos = ".concat(i.associatedVariableName, `;
`), this.view.isConnected && (e.compilationString += "mat4 view = ".concat(this.view.associatedVariableName, `;
`)), e.compilationString += e._emitCodeFromInclude("shadowsVertex", r, { repeatKey: "maxSimultaneousLights" }));
      }, t.prototype._buildBlock = function(e) {
        if (n.prototype._buildBlock.call(this, e), e.target === W.Fragment) {
          this.generateOnlyFragmentCode && e.sharedData.dynamicUniformBlocks.push(this), e.sharedData.forcedBindableBlocks.push(this), e.sharedData.blocksWithDefines.push(this);
          var i = "//".concat(this.name), r = this.worldPosition, o = r.associatedVariableName;
          this.generateOnlyFragmentCode ? (o = e._getFreeVariableName("globalWorldPos"), e._emitFunction("light_globalworldpos", "vec3 ".concat(o, `;
`), i), e.compilationString += "".concat(o, " = ").concat(r.associatedVariableName, `.xyz;
`), e.compilationString += e._emitCodeFromInclude("shadowsVertex", i, { repeatKey: "maxSimultaneousLights", substitutionVars: this.generateOnlyFragmentCode ? "worldPos,".concat(r.associatedVariableName) : void 0 })) : o = "v_" + o + ".xyz", e._emitFunctionFromInclude("helperFunctions", i), e._emitFunctionFromInclude("lightsFragmentFunctions", i, { replaceStrings: [{ search: /vPositionW/g, replace: o }] }), e._emitFunctionFromInclude("shadowsFragmentFunctions", i, { replaceStrings: [{ search: /vPositionW/g, replace: o }] }), this.light ? e._emitFunctionFromInclude(e.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", i, { replaceStrings: [{ search: /{X}/g, replace: this._lightId.toString() }] }, this._lightId.toString()) : e._emitFunctionFromInclude(e.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", i, { repeatKey: "maxSimultaneousLights", substitutionVars: this.generateOnlyFragmentCode ? "varying," : void 0 }), this._lightId === 0 && (e._registerTempVariable("viewDirectionW") && (e.compilationString += "vec3 viewDirectionW = normalize(".concat(this.cameraPosition.associatedVariableName, " - ").concat(o, `);
`)), e.compilationString += `lightingInfo info;
`, e.compilationString += `float shadow = 1.;
`, e.compilationString += `float aggShadow = 0.;
`, e.compilationString += `float numLights = 0.;
`, e.compilationString += "float glossiness = ".concat(this.glossiness.isConnected ? this.glossiness.associatedVariableName : "1.0", " * ").concat(this.glossPower.isConnected ? this.glossPower.associatedVariableName : "1024.0", `;
`), e.compilationString += `vec3 diffuseBase = vec3(0., 0., 0.);
`, e.compilationString += `vec3 specularBase = vec3(0., 0., 0.);
`, e.compilationString += "vec3 normalW = ".concat(this.worldNormal.associatedVariableName, `.xyz;
`)), this.light ? e.compilationString += e._emitCodeFromInclude("lightFragment", i, { replaceStrings: [{ search: /{X}/g, replace: this._lightId.toString() }, { search: /vPositionW/g, replace: o + ".xyz" }] }) : e.compilationString += e._emitCodeFromInclude("lightFragment", i, { repeatKey: "maxSimultaneousLights", substitutionVars: "vPositionW,".concat(o, ".xyz") }), this._lightId === 0 && (e.compilationString += `aggShadow = aggShadow / numLights;
`);
          var a = this.diffuseOutput, s = this.specularOutput;
          return e.compilationString += this._declareOutput(a, e) + " = diffuseBase".concat(this.diffuseColor.isConnected ? " * " + this.diffuseColor.associatedVariableName : "", `;
`), s.hasEndpoints && (e.compilationString += this._declareOutput(s, e) + " = specularBase".concat(this.specularColor.isConnected ? " * " + this.specularColor.associatedVariableName : "", `;
`)), this.shadow.hasEndpoints && (e.compilationString += this._declareOutput(this.shadow, e) + ` = aggShadow;
`), this;
        }
        this._injectVertexCode(e);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.generateOnlyFragmentCode = this.generateOnlyFragmentCode, this.light && (e.lightId = this.light.id), e;
      }, t.prototype._deserialize = function(e, i, r) {
        n.prototype._deserialize.call(this, e, i, r), e.lightId && (this.light = i.getLightById(e.lightId)), this.generateOnlyFragmentCode = e.generateOnlyFragmentCode, this._setTarget();
      }, x([qe("Generate only fragment code", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0, update: !0, onValidation: t._OnGenerateOnlyFragmentCodeChanged } })], t.prototype, "generateOnlyFragmentCode", void 0), t;
    }(We);
    j("BABYLON.LightBlock", Ab);
    var Bo = function(n) {
      function t(e) {
        var i = n.call(this, e, W.VertexAndFragment) || this;
        return i.registerOutput("source", M.Object, W.VertexAndFragment, new xi("source", i, ui.Output, t, "ImageSourceBlock")), i;
      }
      return D(t, n), Object.defineProperty(t.prototype, "texture", { get: function() {
        return this._texture;
      }, set: function(e) {
        var i, r = this;
        if (this._texture !== e) {
          var o = (i = e == null ? void 0 : e.getScene()) !== null && i !== void 0 ? i : Me.LastCreatedScene;
          !e && o && o.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag, function(a) {
            return a.hasTexture(r._texture);
          }), this._texture = e, e && o && o.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag, function(a) {
            return a.hasTexture(e);
          });
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "samplerName", { get: function() {
        return this._samplerName;
      }, enumerable: !1, configurable: !0 }), t.prototype.bind = function(e) {
        this.texture && e.setTexture(this._samplerName, this.texture);
      }, t.prototype.isReady = function() {
        return !(this.texture && !this.texture.isReadyOrNotBlocking());
      }, t.prototype.getClassName = function() {
        return "ImageSourceBlock";
      }, Object.defineProperty(t.prototype, "source", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        return n.prototype._buildBlock.call(this, e), e.target === W.Vertex && (this._samplerName = e._getFreeVariableName(this.name + "Sampler"), e.sharedData.blockingBlocks.push(this), e.sharedData.textureBlocks.push(this), e.sharedData.bindableBlocks.push(this)), e._emit2DSampler(this._samplerName), this;
      }, t.prototype._dumpPropertiesCode = function() {
        var e = n.prototype._dumpPropertiesCode.call(this);
        return this.texture ? (e += "".concat(this._codeVariableName, '.texture = new BABYLON.Texture("').concat(this.texture.name, '", null, ').concat(this.texture.noMipmap, ", ").concat(this.texture.invertY, ", ").concat(this.texture.samplingMode, `);
`), e += "".concat(this._codeVariableName, ".texture.wrapU = ").concat(this.texture.wrapU, `;
`), e += "".concat(this._codeVariableName, ".texture.wrapV = ").concat(this.texture.wrapV, `;
`), e += "".concat(this._codeVariableName, ".texture.uAng = ").concat(this.texture.uAng, `;
`), e += "".concat(this._codeVariableName, ".texture.vAng = ").concat(this.texture.vAng, `;
`), e += "".concat(this._codeVariableName, ".texture.wAng = ").concat(this.texture.wAng, `;
`), e += "".concat(this._codeVariableName, ".texture.uOffset = ").concat(this.texture.uOffset, `;
`), e += "".concat(this._codeVariableName, ".texture.vOffset = ").concat(this.texture.vOffset, `;
`), e += "".concat(this._codeVariableName, ".texture.uScale = ").concat(this.texture.uScale, `;
`), e += "".concat(this._codeVariableName, ".texture.vScale = ").concat(this.texture.vScale, `;
`), e += "".concat(this._codeVariableName, ".texture.coordinatesMode = ").concat(this.texture.coordinatesMode, `;
`)) : e;
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return this.texture && !this.texture.isRenderTarget && this.texture.getClassName() !== "VideoTexture" && (e.texture = this.texture.serialize()), e;
      }, t.prototype._deserialize = function(e, i, r) {
        n.prototype._deserialize.call(this, e, i, r), e.texture && !ka.IgnoreTexturesAtLoadTime && e.texture.url !== void 0 && (r = e.texture.url.indexOf("data:") === 0 ? "" : r, this.texture = ae.Parse(e.texture, i, r));
      }, t;
    }(We);
    j("BABYLON.ImageSourceBlock", Bo);
    var Rb = function(n) {
      function t(e, i) {
        i === void 0 && (i = !1);
        var r = n.call(this, e, i ? W.Fragment : W.VertexAndFragment) || this;
        return r._convertToGammaSpace = !1, r._convertToLinearSpace = !1, r.disableLevelMultiplication = !1, r._fragmentOnly = i, r.registerInput("uv", M.AutoDetect, !1, W.VertexAndFragment), r.registerInput("source", M.Object, !0, W.VertexAndFragment, new xi("source", r, ui.Input, Bo, "ImageSourceBlock")), r.registerInput("layer", M.Float, !0), r.registerInput("lod", M.Float, !0), r.registerOutput("rgba", M.Color4, W.Neutral), r.registerOutput("rgb", M.Color3, W.Neutral), r.registerOutput("r", M.Float, W.Neutral), r.registerOutput("g", M.Float, W.Neutral), r.registerOutput("b", M.Float, W.Neutral), r.registerOutput("a", M.Float, W.Neutral), r.registerOutput("level", M.Float, W.Neutral), r._inputs[0].addExcludedConnectionPointFromAllowedTypes(M.Vector2 | M.Vector3 | M.Vector4), r._inputs[0]._prioritizeVertex = !i, r;
      }
      return D(t, n), Object.defineProperty(t.prototype, "texture", { get: function() {
        var e;
        return this.source.isConnected ? ((e = this.source.connectedPoint) === null || e === void 0 ? void 0 : e.ownerBlock).texture : this._texture;
      }, set: function(e) {
        var i, r = this;
        if (this._texture !== e) {
          var o = (i = e == null ? void 0 : e.getScene()) !== null && i !== void 0 ? i : Me.LastCreatedScene;
          !e && o && o.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag, function(a) {
            return a.hasTexture(r._texture);
          }), this._texture = e, e && o && o.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag, function(a) {
            return a.hasTexture(e);
          });
        }
      }, enumerable: !1, configurable: !0 }), t._IsPrePassTextureBlock = function(e) {
        return (e == null ? void 0 : e.getClassName()) === "PrePassTextureBlock";
      }, Object.defineProperty(t.prototype, "_isSourcePrePass", { get: function() {
        return t._IsPrePassTextureBlock(this._imageSource);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "samplerName", { get: function() {
        if (this._imageSource) {
          if (!t._IsPrePassTextureBlock(this._imageSource))
            return this._imageSource.samplerName;
          if (this.source.connectedPoint)
            return this._imageSource.getSamplerName(this.source.connectedPoint);
        }
        return this._samplerName;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hasImageSource", { get: function() {
        return this.source.isConnected;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "convertToGammaSpace", { get: function() {
        return this._convertToGammaSpace;
      }, set: function(e) {
        var i, r = this;
        if (e !== this._convertToGammaSpace && (this._convertToGammaSpace = e, this.texture)) {
          var o = (i = this.texture.getScene()) !== null && i !== void 0 ? i : Me.LastCreatedScene;
          o == null || o.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag, function(a) {
            return a.hasTexture(r.texture);
          });
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "convertToLinearSpace", { get: function() {
        return this._convertToLinearSpace;
      }, set: function(e) {
        var i, r = this;
        if (e !== this._convertToLinearSpace && (this._convertToLinearSpace = e, this.texture)) {
          var o = (i = this.texture.getScene()) !== null && i !== void 0 ? i : Me.LastCreatedScene;
          o == null || o.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag, function(a) {
            return a.hasTexture(r.texture);
          });
        }
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "TextureBlock";
      }, Object.defineProperty(t.prototype, "uv", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "source", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "layer", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "lod", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgba", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgb", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "r", { get: function() {
        return this._outputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "g", { get: function() {
        return this._outputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "b", { get: function() {
        return this._outputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "a", { get: function() {
        return this._outputs[5];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "level", { get: function() {
        return this._outputs[6];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "target", { get: function() {
        if (this._fragmentOnly)
          return W.Fragment;
        if (!this.uv.isConnected || this.uv.sourceBlock.isInput)
          return W.VertexAndFragment;
        for (var e = this.uv.connectedPoint; e; ) {
          if (e.target === W.Fragment)
            return W.Fragment;
          if (e.target === W.Vertex)
            return W.VertexAndFragment;
          if (e.target === W.Neutral || e.target === W.VertexAndFragment) {
            var i = e.ownerBlock;
            if (i.target === W.Fragment)
              return W.Fragment;
            e = null;
            for (var r = 0, o = i.inputs; r < o.length; r++) {
              var a = o[r];
              if (a.connectedPoint) {
                e = a.connectedPoint;
                break;
              }
            }
          }
        }
        return W.VertexAndFragment;
      }, set: function(e) {
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function(e, i) {
        if (i === void 0 && (i = function() {
          return !0;
        }), !this.uv.isConnected)
          if (e.mode === kn.PostProcess)
            (r = e.getBlockByPredicate(function(a) {
              return a.name === "uv" && i(a);
            })) && r.connectTo(this);
          else {
            var r, o = e.mode === kn.Particle ? "particle_uv" : "uv";
            (r = e.getInputBlockByPredicate(function(a) {
              return a.isAttribute && a.name === o && i(a);
            })) || (r = new vt("uv")).setAsAttribute(o), r.output.connectTo(this.uv);
          }
      }, t.prototype.initializeDefines = function(e, i, r) {
        r._areTexturesDirty && this._mainUVDefineName !== void 0 && r.setValue(this._mainUVDefineName, !1, !0);
      }, t.prototype.prepareDefines = function(e, i, r) {
        if (r._areTexturesDirty)
          if (this.texture && this.texture.getTextureMatrix) {
            var o = this.convertToGammaSpace && this.texture && !this.texture.gammaSpace, a = this.convertToLinearSpace && this.texture && this.texture.gammaSpace;
            r.setValue(this._linearDefineName, o, !0), r.setValue(this._gammaDefineName, a, !0), this._isMixed && (this.texture.getTextureMatrix().isIdentityAs3x2() ? (r.setValue(this._defineName, !1, !0), r.setValue(this._mainUVDefineName, !0, !0)) : (r.setValue(this._defineName, !0), r[this._mainUVDefineName] == null && r.setValue(this._mainUVDefineName, !1, !0)));
          } else
            this._isMixed && (r.setValue(this._defineName, !1, !0), r.setValue(this._mainUVDefineName, !0, !0));
      }, t.prototype.isReady = function() {
        return !!this._isSourcePrePass || !(this.texture && !this.texture.isReadyOrNotBlocking());
      }, t.prototype.bind = function(e) {
        this._isSourcePrePass && e.setFloat(this._textureInfoName, 1), this.texture && (this._isMixed && (e.setFloat(this._textureInfoName, this.texture.level), e.setMatrix(this._textureTransformName, this.texture.getTextureMatrix())), this._imageSource || e.setTexture(this._samplerName, this.texture));
      }, Object.defineProperty(t.prototype, "_isMixed", { get: function() {
        return this.target !== W.Fragment;
      }, enumerable: !1, configurable: !0 }), t.prototype._injectVertexCode = function(e) {
        var i = this.uv;
        if (this._defineName = e._getFreeDefineName("UVTRANSFORM"), this._mainUVDefineName = "VMAIN" + i.associatedVariableName.toUpperCase(), this._mainUVName = "vMain" + i.associatedVariableName, this._transformedUVName = e._getFreeVariableName("transformedUV"), this._textureTransformName = e._getFreeVariableName("textureTransform"), this._textureInfoName = e._getFreeVariableName("textureInfoName"), this.level.associatedVariableName = this._textureInfoName, e._emitVaryingFromString(this._transformedUVName, "vec2", this._defineName), e._emitVaryingFromString(this._mainUVName, "vec2", this._mainUVDefineName), e._emitUniformFromString(this._textureTransformName, "mat4", this._defineName), e.compilationString += "#ifdef ".concat(this._defineName, `
`), e.compilationString += "".concat(this._transformedUVName, " = vec2(").concat(this._textureTransformName, " * vec4(").concat(i.associatedVariableName, `.xy, 1.0, 0.0));
`), e.compilationString += "#elif defined(".concat(this._mainUVDefineName, `)
`), e.compilationString += "".concat(this._mainUVName, " = ").concat(i.associatedVariableName, `.xy;
`), e.compilationString += `#endif
`, this._outputs.some(function(s) {
          return s.isConnectedInVertexShader;
        })) {
          this._writeTextureRead(e, !0);
          for (var r = 0, o = this._outputs; r < o.length; r++) {
            var a = o[r];
            a.hasEndpoints && a.name !== "level" && this._writeOutput(e, a, a.name, !0);
          }
        }
      }, t.prototype._getUVW = function(e) {
        var i, r, o, a = e;
        if ((o = (r = (i = this._texture) === null || i === void 0 ? void 0 : i._texture) === null || r === void 0 ? void 0 : r.is2DArray) !== null && o !== void 0 && o) {
          var s = this.layer.isConnected ? this.layer.associatedVariableName : "0";
          a = "vec3(".concat(e, ", ").concat(s, ")");
        }
        return a;
      }, Object.defineProperty(t.prototype, "_samplerFunc", { get: function() {
        return this.lod.isConnected ? "texture2DLodEXT" : "texture2D";
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "_samplerLodSuffix", { get: function() {
        return this.lod.isConnected ? ", ".concat(this.lod.associatedVariableName) : "";
      }, enumerable: !1, configurable: !0 }), t.prototype._generateTextureLookup = function(e) {
        var i = this.samplerName;
        e.compilationString += "#ifdef ".concat(this._defineName, `
`), e.compilationString += "vec4 ".concat(this._tempTextureRead, " = ").concat(this._samplerFunc, "(").concat(i, ", ").concat(this._getUVW(this._transformedUVName)).concat(this._samplerLodSuffix, `);
`), e.compilationString += "#elif defined(".concat(this._mainUVDefineName, `)
`), e.compilationString += "vec4 ".concat(this._tempTextureRead, " = ").concat(this._samplerFunc, "(").concat(i, ", ").concat(this._getUVW(this._mainUVName ? this._mainUVName : this.uv.associatedVariableName)).concat(this._samplerLodSuffix, `);
`), e.compilationString += `#endif
`;
      }, t.prototype._writeTextureRead = function(e, i) {
        i === void 0 && (i = !1);
        var r = this.uv;
        if (i) {
          if (e.target === W.Fragment)
            return;
          this._generateTextureLookup(e);
        } else
          this.uv.ownerBlock.target !== W.Fragment ? this._generateTextureLookup(e) : e.compilationString += "vec4 ".concat(this._tempTextureRead, " = ").concat(this._samplerFunc, "(").concat(this.samplerName, ", ").concat(this._getUVW(r.associatedVariableName)).concat(this._samplerLodSuffix, `);
`);
      }, t.prototype._generateConversionCode = function(e, i, r) {
        r !== "a" && (this.texture && this.texture.gammaSpace || (e.compilationString += "#ifdef ".concat(this._linearDefineName, `
                    `).concat(i.associatedVariableName, " = toGammaSpace(").concat(i.associatedVariableName, `);
                    #endif
                `)), e.compilationString += "#ifdef ".concat(this._gammaDefineName, `
                `).concat(i.associatedVariableName, " = toLinearSpace(").concat(i.associatedVariableName, `);
                #endif
            `));
      }, t.prototype._writeOutput = function(e, i, r, o) {
        if (o === void 0 && (o = !1), o)
          return e.target === W.Fragment ? void 0 : (e.compilationString += "".concat(this._declareOutput(i, e), " = ").concat(this._tempTextureRead, ".").concat(r, `;
`), void this._generateConversionCode(e, i, r));
        if (this.uv.ownerBlock.target === W.Fragment)
          return e.compilationString += "".concat(this._declareOutput(i, e), " = ").concat(this._tempTextureRead, ".").concat(r, `;
`), void this._generateConversionCode(e, i, r);
        var a = "";
        this.disableLevelMultiplication || (a = " * ".concat(this._textureInfoName)), e.compilationString += "".concat(this._declareOutput(i, e), " = ").concat(this._tempTextureRead, ".").concat(r).concat(a, `;
`), this._generateConversionCode(e, i, r);
      }, t.prototype._buildBlock = function(e) {
        var i, r, o, a;
        if (n.prototype._buildBlock.call(this, e), this.source.isConnected ? this._imageSource = this.source.connectedPoint.ownerBlock : this._imageSource = null, (e.target === W.Vertex || this._fragmentOnly || e.target === W.Fragment) && (this._tempTextureRead = e._getFreeVariableName("tempTextureRead"), this._linearDefineName = e._getFreeDefineName("ISLINEAR"), this._gammaDefineName = e._getFreeDefineName("ISGAMMA")), (!this._isMixed && e.target === W.Fragment || this._isMixed && e.target === W.Vertex) && (this._imageSource || (this._samplerName = e._getFreeVariableName(this.name + "Sampler"), !((r = (i = this._texture) === null || i === void 0 ? void 0 : i._texture) === null || r === void 0) && r.is2DArray ? e._emit2DArraySampler(this._samplerName) : e._emit2DSampler(this._samplerName)), e.sharedData.blockingBlocks.push(this), e.sharedData.textureBlocks.push(this), e.sharedData.blocksWithDefines.push(this), e.sharedData.bindableBlocks.push(this)), e.target === W.Fragment) {
          if (this._outputs.some(function(h) {
            return h.isConnectedInFragmentShader;
          })) {
            this._isMixed && !this._imageSource && (!((a = (o = this._texture) === null || o === void 0 ? void 0 : o._texture) === null || a === void 0) && a.is2DArray ? e._emit2DArraySampler(this._samplerName) : e._emit2DSampler(this._samplerName));
            var s = "//".concat(this.name);
            e._emitFunctionFromInclude("helperFunctions", s), this._isMixed && e._emitUniformFromString(this._textureInfoName, "float"), this._writeTextureRead(e);
            for (var l = 0, c = this._outputs; l < c.length; l++) {
              var u = c[l];
              u.hasEndpoints && u.name !== "level" && this._writeOutput(e, u, u.name);
            }
            return this;
          }
        } else
          this._injectVertexCode(e);
      }, t.prototype._dumpPropertiesCode = function() {
        var e = n.prototype._dumpPropertiesCode.call(this);
        return e += "".concat(this._codeVariableName, ".convertToGammaSpace = ").concat(this.convertToGammaSpace, `;
`), e += "".concat(this._codeVariableName, ".convertToLinearSpace = ").concat(this.convertToLinearSpace, `;
`), e += "".concat(this._codeVariableName, ".disableLevelMultiplication = ").concat(this.disableLevelMultiplication, `;
`), this.texture ? (e += "".concat(this._codeVariableName, '.texture = new BABYLON.Texture("').concat(this.texture.name, '", null, ').concat(this.texture.noMipmap, ", ").concat(this.texture.invertY, ", ").concat(this.texture.samplingMode, `);
`), e += "".concat(this._codeVariableName, ".texture.wrapU = ").concat(this.texture.wrapU, `;
`), e += "".concat(this._codeVariableName, ".texture.wrapV = ").concat(this.texture.wrapV, `;
`), e += "".concat(this._codeVariableName, ".texture.uAng = ").concat(this.texture.uAng, `;
`), e += "".concat(this._codeVariableName, ".texture.vAng = ").concat(this.texture.vAng, `;
`), e += "".concat(this._codeVariableName, ".texture.wAng = ").concat(this.texture.wAng, `;
`), e += "".concat(this._codeVariableName, ".texture.uOffset = ").concat(this.texture.uOffset, `;
`), e += "".concat(this._codeVariableName, ".texture.vOffset = ").concat(this.texture.vOffset, `;
`), e += "".concat(this._codeVariableName, ".texture.uScale = ").concat(this.texture.uScale, `;
`), e += "".concat(this._codeVariableName, ".texture.vScale = ").concat(this.texture.vScale, `;
`), e += "".concat(this._codeVariableName, ".texture.coordinatesMode = ").concat(this.texture.coordinatesMode, `;
`)) : e;
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.convertToGammaSpace = this.convertToGammaSpace, e.convertToLinearSpace = this.convertToLinearSpace, e.fragmentOnly = this._fragmentOnly, e.disableLevelMultiplication = this.disableLevelMultiplication, this.hasImageSource || !this.texture || this.texture.isRenderTarget || this.texture.getClassName() === "VideoTexture" || (e.texture = this.texture.serialize()), e;
      }, t.prototype._deserialize = function(e, i, r) {
        n.prototype._deserialize.call(this, e, i, r), this.convertToGammaSpace = e.convertToGammaSpace, this.convertToLinearSpace = !!e.convertToLinearSpace, this._fragmentOnly = !!e.fragmentOnly, this.disableLevelMultiplication = !!e.disableLevelMultiplication, e.texture && !ka.IgnoreTexturesAtLoadTime && e.texture.url !== void 0 && (r = e.texture.url.indexOf("data:") === 0 ? "" : r, this.texture = ae.Parse(e.texture, i, r));
      }, t;
    }(We);
    j("BABYLON.TextureBlock", Rb);
    var Cb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.VertexAndFragment) || this;
        return i.generateOnlyFragmentCode = !1, i;
      }
      return D(t, n), Object.defineProperty(t.prototype, "texture", { get: function() {
        return this._texture;
      }, set: function(e) {
        var i, r = this;
        if (this._texture !== e) {
          var o = (i = e == null ? void 0 : e.getScene()) !== null && i !== void 0 ? i : Me.LastCreatedScene;
          !e && o && o.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag, function(a) {
            return a.hasTexture(r._texture);
          }), this._texture = e, e && o && o.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag, function(a) {
            return a.hasTexture(e);
          });
        }
      }, enumerable: !1, configurable: !0 }), t._OnGenerateOnlyFragmentCodeChanged = function(e, i) {
        return e._onGenerateOnlyFragmentCodeChanged();
      }, t.prototype._onGenerateOnlyFragmentCodeChanged = function() {
        return this._setTarget(), !0;
      }, t.prototype._setTarget = function() {
        this._setInitialTarget(this.generateOnlyFragmentCode ? W.Fragment : W.VertexAndFragment);
      }, t.prototype.getClassName = function() {
        return "ReflectionTextureBaseBlock";
      }, t.prototype._getTexture = function() {
        return this.texture;
      }, t.prototype.autoConfigure = function(e, i) {
        if (i === void 0 && (i = function() {
          return !0;
        }), !this.position.isConnected) {
          var r = e.getInputBlockByPredicate(function(s) {
            return s.isAttribute && s.name === "position" && i(s);
          });
          r || (r = new vt("position")).setAsAttribute(), r.output.connectTo(this.position);
        }
        if (!this.world.isConnected) {
          var o = e.getInputBlockByPredicate(function(s) {
            return s.systemValue === Tt.World && i(s);
          });
          o || (o = new vt("world")).setAsSystemValue(Tt.World), o.output.connectTo(this.world);
        }
        if (this.view && !this.view.isConnected) {
          var a = e.getInputBlockByPredicate(function(s) {
            return s.systemValue === Tt.View && i(s);
          });
          a || (a = new vt("view")).setAsSystemValue(Tt.View), a.output.connectTo(this.view);
        }
      }, t.prototype.prepareDefines = function(e, i, r) {
        if (r._areTexturesDirty) {
          var o = this._getTexture();
          o && o.getTextureMatrix && (r.setValue(this._define3DName, o.isCube, !0), r.setValue(this._defineLocalCubicName, !!o.boundingBoxSize, !0), r.setValue(this._defineExplicitName, o.coordinatesMode === _.TEXTURE_EXPLICIT_MODE, !0), r.setValue(this._defineSkyboxName, o.coordinatesMode === _.TEXTURE_SKYBOX_MODE, !0), r.setValue(this._defineCubicName, o.coordinatesMode === _.TEXTURE_CUBIC_MODE || o.coordinatesMode === _.TEXTURE_INVCUBIC_MODE, !0), r.setValue("INVERTCUBICMAP", o.coordinatesMode === _.TEXTURE_INVCUBIC_MODE, !0), r.setValue(this._defineSphericalName, o.coordinatesMode === _.TEXTURE_SPHERICAL_MODE, !0), r.setValue(this._definePlanarName, o.coordinatesMode === _.TEXTURE_PLANAR_MODE, !0), r.setValue(this._defineProjectionName, o.coordinatesMode === _.TEXTURE_PROJECTION_MODE, !0), r.setValue(this._defineEquirectangularName, o.coordinatesMode === _.TEXTURE_EQUIRECTANGULAR_MODE, !0), r.setValue(this._defineEquirectangularFixedName, o.coordinatesMode === _.TEXTURE_FIXED_EQUIRECTANGULAR_MODE, !0), r.setValue(this._defineMirroredEquirectangularFixedName, o.coordinatesMode === _.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE, !0));
        }
      }, t.prototype.isReady = function() {
        var e = this._getTexture();
        return !(e && !e.isReadyOrNotBlocking());
      }, t.prototype.bind = function(e, i, r) {
        var o = this._getTexture();
        if (r && o && (e.setMatrix(this._reflectionMatrixName, o.getReflectionTextureMatrix()), o.isCube ? e.setTexture(this._cubeSamplerName, o) : e.setTexture(this._2DSamplerName, o), o.boundingBoxSize)) {
          var a = o;
          e.setVector3(this._reflectionPositionName, a.boundingBoxPosition), e.setVector3(this._reflectionSizeName, a.boundingBoxSize);
        }
      }, t.prototype.handleVertexSide = function(e) {
        if (this.generateOnlyFragmentCode && e.target === W.Vertex)
          return "";
        this._define3DName = e._getFreeDefineName("REFLECTIONMAP_3D"), this._defineCubicName = e._getFreeDefineName("REFLECTIONMAP_CUBIC"), this._defineSphericalName = e._getFreeDefineName("REFLECTIONMAP_SPHERICAL"), this._definePlanarName = e._getFreeDefineName("REFLECTIONMAP_PLANAR"), this._defineProjectionName = e._getFreeDefineName("REFLECTIONMAP_PROJECTION"), this._defineExplicitName = e._getFreeDefineName("REFLECTIONMAP_EXPLICIT"), this._defineEquirectangularName = e._getFreeDefineName("REFLECTIONMAP_EQUIRECTANGULAR"), this._defineLocalCubicName = e._getFreeDefineName("USE_LOCAL_REFLECTIONMAP_CUBIC"), this._defineMirroredEquirectangularFixedName = e._getFreeDefineName("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"), this._defineEquirectangularFixedName = e._getFreeDefineName("REFLECTIONMAP_EQUIRECTANGULAR_FIXED"), this._defineSkyboxName = e._getFreeDefineName("REFLECTIONMAP_SKYBOX"), this._defineOppositeZ = e._getFreeDefineName("REFLECTIONMAP_OPPOSITEZ"), this._reflectionMatrixName = e._getFreeVariableName("reflectionMatrix"), e._emitUniformFromString(this._reflectionMatrixName, "mat4");
        var i = "";
        this._worldPositionNameInFragmentOnlyMode = e._getFreeVariableName("worldPosition");
        var r = this.generateOnlyFragmentCode ? this._worldPositionNameInFragmentOnlyMode : "v_" + this.worldPosition.associatedVariableName;
        return (this.generateOnlyFragmentCode || e._emitVaryingFromString(r, "vec4")) && (i += "".concat(this.generateOnlyFragmentCode ? "vec4 " : "").concat(r, " = ").concat(this.worldPosition.associatedVariableName, `;
`)), this._positionUVWName = e._getFreeVariableName("positionUVW"), this._directionWName = e._getFreeVariableName("directionW"), (this.generateOnlyFragmentCode || e._emitVaryingFromString(this._positionUVWName, "vec3", this._defineSkyboxName)) && (i += "#ifdef ".concat(this._defineSkyboxName, `
`), i += "".concat(this.generateOnlyFragmentCode ? "vec3 " : "").concat(this._positionUVWName, " = ").concat(this.position.associatedVariableName, `.xyz;
`), i += `#endif
`), (this.generateOnlyFragmentCode || e._emitVaryingFromString(this._directionWName, "vec3", "defined(".concat(this._defineEquirectangularFixedName, ") || defined(").concat(this._defineMirroredEquirectangularFixedName, ")"))) && (i += "#if defined(".concat(this._defineEquirectangularFixedName, ") || defined(").concat(this._defineMirroredEquirectangularFixedName, `)
`), i += "".concat(this.generateOnlyFragmentCode ? "vec3 " : "").concat(this._directionWName, " = normalize(vec3(").concat(this.world.associatedVariableName, " * vec4(").concat(this.position.associatedVariableName, `.xyz, 0.0)));
`), i += `#endif
`), i;
      }, t.prototype.handleFragmentSideInits = function(e) {
        e.sharedData.blockingBlocks.push(this), e.sharedData.textureBlocks.push(this), this._cubeSamplerName = e._getFreeVariableName(this.name + "CubeSampler"), e.samplers.push(this._cubeSamplerName), this._2DSamplerName = e._getFreeVariableName(this.name + "2DSampler"), e.samplers.push(this._2DSamplerName), e._samplerDeclaration += "#ifdef ".concat(this._define3DName, `
`), e._samplerDeclaration += "uniform samplerCube ".concat(this._cubeSamplerName, `;
`), e._samplerDeclaration += `#else
`, e._samplerDeclaration += "uniform sampler2D ".concat(this._2DSamplerName, `;
`), e._samplerDeclaration += `#endif
`, e.sharedData.blocksWithDefines.push(this), e.sharedData.bindableBlocks.push(this);
        var i = "//".concat(this.name);
        e._emitFunctionFromInclude("helperFunctions", i), e._emitFunctionFromInclude("reflectionFunction", i, { replaceStrings: [{ search: /vec3 computeReflectionCoords/g, replace: "void DUMMYFUNC" }] }), this._reflectionColorName = e._getFreeVariableName("reflectionColor"), this._reflectionVectorName = e._getFreeVariableName("reflectionUVW"), this._reflectionCoordsName = e._getFreeVariableName("reflectionCoords"), this._reflectionPositionName = e._getFreeVariableName("vReflectionPosition"), e._emitUniformFromString(this._reflectionPositionName, "vec3"), this._reflectionSizeName = e._getFreeVariableName("vReflectionPosition"), e._emitUniformFromString(this._reflectionSizeName, "vec3");
      }, t.prototype.handleFragmentSideCodeReflectionCoords = function(e, i, r, o) {
        r === void 0 && (r = !1), o === void 0 && (o = !1), i || (i = this.generateOnlyFragmentCode ? this._worldPositionNameInFragmentOnlyMode : "v_".concat(this.worldPosition.associatedVariableName));
        var a = this._reflectionMatrixName, s = "normalize(".concat(this._directionWName, ")"), l = "".concat(this._positionUVWName), c = "".concat(this.cameraPosition.associatedVariableName), u = "".concat(this.view.associatedVariableName);
        e += ".xyz";
        var h = `
            #ifdef `.concat(this._defineMirroredEquirectangularFixedName, `
                vec3 `).concat(this._reflectionVectorName, " = computeMirroredFixedEquirectangularCoords(").concat(i, ", ").concat(e, ", ").concat(s, `);
            #endif

            #ifdef `).concat(this._defineEquirectangularFixedName, `
                vec3 `).concat(this._reflectionVectorName, " = computeFixedEquirectangularCoords(").concat(i, ", ").concat(e, ", ").concat(s, `);
            #endif

            #ifdef `).concat(this._defineEquirectangularName, `
                vec3 `).concat(this._reflectionVectorName, " = computeEquirectangularCoords(").concat(i, ", ").concat(e, ", ").concat(c, ".xyz, ").concat(a, `);
            #endif

            #ifdef `).concat(this._defineSphericalName, `
                vec3 `).concat(this._reflectionVectorName, " = computeSphericalCoords(").concat(i, ", ").concat(e, ", ").concat(u, ", ").concat(a, `);
            #endif

            #ifdef `).concat(this._definePlanarName, `
                vec3 `).concat(this._reflectionVectorName, " = computePlanarCoords(").concat(i, ", ").concat(e, ", ").concat(c, ".xyz, ").concat(a, `);
            #endif

            #ifdef `).concat(this._defineCubicName, `
                #ifdef `).concat(this._defineLocalCubicName, `
                    vec3 `).concat(this._reflectionVectorName, " = computeCubicLocalCoords(").concat(i, ", ").concat(e, ", ").concat(c, ".xyz, ").concat(a, ", ").concat(this._reflectionSizeName, ", ").concat(this._reflectionPositionName, `);
                #else
                vec3 `).concat(this._reflectionVectorName, " = computeCubicCoords(").concat(i, ", ").concat(e, ", ").concat(c, ".xyz, ").concat(a, `);
                #endif
            #endif

            #ifdef `).concat(this._defineProjectionName, `
                vec3 `).concat(this._reflectionVectorName, " = computeProjectionCoords(").concat(i, ", ").concat(u, ", ").concat(a, `);
            #endif

            #ifdef `).concat(this._defineSkyboxName, `
                vec3 `).concat(this._reflectionVectorName, " = computeSkyBoxCoords(").concat(l, ", ").concat(a, `);
            #endif

            #ifdef `).concat(this._defineExplicitName, `
                vec3 `).concat(this._reflectionVectorName, ` = vec3(0, 0, 0);
            #endif
`);
        return o || (h += "#ifdef ".concat(this._defineOppositeZ, `
                `).concat(this._reflectionVectorName, `.z *= -1.0;
            #endif
`)), r || (h += `
                #ifdef `.concat(this._define3DName, `
                    vec3 `).concat(this._reflectionCoordsName, " = ").concat(this._reflectionVectorName, `;
                #else
                    vec2 `).concat(this._reflectionCoordsName, " = ").concat(this._reflectionVectorName, `.xy;
                    #ifdef `).concat(this._defineProjectionName, `
                        `).concat(this._reflectionCoordsName, " /= ").concat(this._reflectionVectorName, `.z;
                    #endif
                    `).concat(this._reflectionCoordsName, ".y = 1.0 - ").concat(this._reflectionCoordsName, `.y;
                #endif
`)), h;
      }, t.prototype.handleFragmentSideCodeReflectionColor = function(e, i) {
        i === void 0 && (i = ".rgb");
        var r = "vec" + (i.length === 0 ? "4" : i.length - 1), o = "".concat(r, " ").concat(this._reflectionColorName, `;
            #ifdef `).concat(this._define3DName, `
`);
        return o += e ? "".concat(this._reflectionColorName, " = textureCubeLodEXT(").concat(this._cubeSamplerName, ", ").concat(this._reflectionVectorName, ", ").concat(e, ")").concat(i, `;
`) : "".concat(this._reflectionColorName, " = textureCube(").concat(this._cubeSamplerName, ", ").concat(this._reflectionVectorName, ")").concat(i, `;
`), o += `
            #else
`, (o += e ? "".concat(this._reflectionColorName, " = texture2DLodEXT(").concat(this._2DSamplerName, ", ").concat(this._reflectionCoordsName, ", ").concat(e, ")").concat(i, `;
`) : "".concat(this._reflectionColorName, " = texture2D(").concat(this._2DSamplerName, ", ").concat(this._reflectionCoordsName, ")").concat(i, `;
`)) + `#endif
`;
      }, t.prototype.writeOutputs = function(e, i) {
        var r = "";
        if (e.target === W.Fragment)
          for (var o = 0, a = this._outputs; o < a.length; o++) {
            var s = a[o];
            s.hasEndpoints && (r += "".concat(this._declareOutput(s, e), " = ").concat(i, ".").concat(s.name, `;
`));
          }
        return r;
      }, t.prototype._buildBlock = function(e) {
        return n.prototype._buildBlock.call(this, e), this;
      }, t.prototype._dumpPropertiesCode = function() {
        var e = n.prototype._dumpPropertiesCode.call(this);
        if (!this.texture)
          return e;
        if (this.texture.isCube) {
          var i = this.texture.forcedExtension;
          e += "".concat(this._codeVariableName, '.texture = new BABYLON.CubeTexture("').concat(this.texture.name, '", undefined, undefined, ').concat(this.texture.noMipmap, ", null, undefined, undefined, undefined, ").concat(this.texture._prefiltered, ", ").concat(i ? '"' + i + '"' : "null", `);
`);
        } else
          e += "".concat(this._codeVariableName, '.texture = new BABYLON.Texture("').concat(this.texture.name, `", null);
`);
        return e + "".concat(this._codeVariableName, ".texture.coordinatesMode = ").concat(this.texture.coordinatesMode, `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return this.texture && !this.texture.isRenderTarget && (e.texture = this.texture.serialize()), e.generateOnlyFragmentCode = this.generateOnlyFragmentCode, e;
      }, t.prototype._deserialize = function(e, i, r) {
        n.prototype._deserialize.call(this, e, i, r), e.texture && !ka.IgnoreTexturesAtLoadTime && (r = e.texture.url.indexOf("data:") === 0 ? "" : r, e.texture.isCube ? this.texture = Gr.Parse(e.texture, i, r) : this.texture = ae.Parse(e.texture, i, r)), this.generateOnlyFragmentCode = e.generateOnlyFragmentCode, this._setTarget();
      }, x([qe("Generate only fragment code", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0, update: !0, onValidation: t._OnGenerateOnlyFragmentCodeChanged } })], t.prototype, "generateOnlyFragmentCode", void 0), t;
    }(We);
    j("BABYLON.ReflectionTextureBaseBlock", Cb);
    var Pb = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.registerInput("position", M.AutoDetect, !1, W.Vertex), i.registerInput("worldPosition", M.Vector4, !1, W.Vertex), i.registerInput("worldNormal", M.Vector4, !1, W.Fragment), i.registerInput("world", M.Matrix, !1, W.Vertex), i.registerInput("cameraPosition", M.Vector3, !1, W.Fragment), i.registerInput("view", M.Matrix, !1, W.Fragment), i.registerOutput("rgb", M.Color3, W.Fragment), i.registerOutput("rgba", M.Color4, W.Fragment), i.registerOutput("r", M.Float, W.Fragment), i.registerOutput("g", M.Float, W.Fragment), i.registerOutput("b", M.Float, W.Fragment), i.registerOutput("a", M.Float, W.Fragment), i._inputs[0].addExcludedConnectionPointFromAllowedTypes(M.Color3 | M.Vector3 | M.Vector4), i;
      }
      return D(t, n), t.prototype._onGenerateOnlyFragmentCodeChanged = function() {
        return this.position.isConnected ? (this.generateOnlyFragmentCode = !this.generateOnlyFragmentCode, console.error("The position input must not be connected to be able to switch!"), !1) : this.worldPosition.isConnected ? (this.generateOnlyFragmentCode = !this.generateOnlyFragmentCode, console.error("The worldPosition input must not be connected to be able to switch!"), !1) : (this._setTarget(), !0);
      }, t.prototype._setTarget = function() {
        n.prototype._setTarget.call(this), this.getInputByName("position").target = this.generateOnlyFragmentCode ? W.Fragment : W.Vertex, this.getInputByName("worldPosition").target = this.generateOnlyFragmentCode ? W.Fragment : W.Vertex;
      }, t.prototype.getClassName = function() {
        return "ReflectionTextureBlock";
      }, Object.defineProperty(t.prototype, "position", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldPosition", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldNormal", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "world", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraPosition", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "view", { get: function() {
        return this._inputs[5];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgb", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgba", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "r", { get: function() {
        return this._outputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "g", { get: function() {
        return this._outputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "b", { get: function() {
        return this._outputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "a", { get: function() {
        return this._outputs[5];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function(e, i) {
        if (i === void 0 && (i = function() {
          return !0;
        }), n.prototype.autoConfigure.call(this, e), !this.cameraPosition.isConnected) {
          var r = e.getInputBlockByPredicate(function(o) {
            return o.systemValue === Tt.CameraPosition && i(o);
          });
          r || (r = new vt("cameraPosition")).setAsSystemValue(Tt.CameraPosition), r.output.connectTo(this.cameraPosition);
        }
      }, t.prototype._buildBlock = function(e) {
        if (n.prototype._buildBlock.call(this, e), !this.texture)
          return e.compilationString += this.writeOutputs(e, "vec4(0.)"), this;
        if (e.target !== W.Fragment)
          return e.compilationString += this.handleVertexSide(e), this;
        this.generateOnlyFragmentCode && (e.compilationString += this.handleVertexSide(e)), this.handleFragmentSideInits(e);
        var i = e._getFreeVariableName("normalWUnit");
        return e.compilationString += "vec4 ".concat(i, " = normalize(").concat(this.worldNormal.associatedVariableName, `);
`), e.compilationString += this.handleFragmentSideCodeReflectionCoords(i), e.compilationString += this.handleFragmentSideCodeReflectionColor(void 0, ""), e.compilationString += this.writeOutputs(e, this._reflectionColorName), this;
      }, t;
    }(Cb);
    j("BABYLON.ReflectionTextureBlock", Pb);
    var Ib = function(n) {
      function t(e) {
        var i = n.call(this, e, W.VertexAndFragment) || this;
        return i.useNonLinearDepth = !1, i.storeCameraSpaceZ = !1, i.force32itsFloat = !1, i._isUnique = !0, i.registerInput("uv", M.AutoDetect, !1, W.VertexAndFragment), i.registerOutput("depth", M.Float, W.Neutral), i._inputs[0].addExcludedConnectionPointFromAllowedTypes(M.Vector2 | M.Vector3 | M.Vector4), i._inputs[0]._prioritizeVertex = !1, i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "SceneDepthBlock";
      }, Object.defineProperty(t.prototype, "uv", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "depth", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.initialize = function(e) {
        e._excludeVariableName("textureSampler");
      }, Object.defineProperty(t.prototype, "target", { get: function() {
        return this.uv.isConnected ? this.uv.sourceBlock.isInput ? W.VertexAndFragment : W.Fragment : W.VertexAndFragment;
      }, enumerable: !1, configurable: !0 }), t.prototype._getTexture = function(e) {
        return e.enableDepthRenderer(void 0, this.useNonLinearDepth, this.force32itsFloat, void 0, this.storeCameraSpaceZ).getDepthMap();
      }, t.prototype.bind = function(e, i) {
        var r = this._getTexture(i.getScene());
        e.setTexture(this._samplerName, r);
      }, t.prototype._injectVertexCode = function(e) {
        var i = this.uv;
        if (i.connectedPoint.ownerBlock.isInput && (i.connectedPoint.ownerBlock.isAttribute || e._emitUniformFromString(i.associatedVariableName, "vec" + (i.type === M.Vector3 ? "3" : i.type === M.Vector4 ? "4" : "2"))), this._mainUVName = "vMain" + i.associatedVariableName, e._emitVaryingFromString(this._mainUVName, "vec2"), e.compilationString += "".concat(this._mainUVName, " = ").concat(i.associatedVariableName, `.xy;
`), this._outputs.some(function(s) {
          return s.isConnectedInVertexShader;
        })) {
          this._writeTextureRead(e, !0);
          for (var r = 0, o = this._outputs; r < o.length; r++) {
            var a = o[r];
            a.hasEndpoints && this._writeOutput(e, a, "r", !0);
          }
        }
      }, t.prototype._writeTextureRead = function(e, i) {
        i === void 0 && (i = !1);
        var r = this.uv;
        if (i) {
          if (e.target === W.Fragment)
            return;
          e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(r.associatedVariableName, `.xy);
`);
        } else
          this.uv.ownerBlock.target !== W.Fragment ? e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(this._mainUVName, `);
`) : e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(r.associatedVariableName, `.xy);
`);
      }, t.prototype._writeOutput = function(e, i, r, o) {
        if (o === void 0 && (o = !1), o) {
          if (e.target === W.Fragment)
            return;
          e.compilationString += "".concat(this._declareOutput(i, e), " = ").concat(this._tempTextureRead, ".").concat(r, `;
`);
        } else
          this.uv.ownerBlock.target, W.Fragment, e.compilationString += "".concat(this._declareOutput(i, e), " = ").concat(this._tempTextureRead, ".").concat(r, `;
`);
      }, t.prototype._buildBlock = function(e) {
        if (n.prototype._buildBlock.call(this, e), this._samplerName = e._getFreeVariableName(this.name + "Sampler"), this._tempTextureRead = e._getFreeVariableName("tempTextureRead"), e.sharedData.bindableBlocks.indexOf(this) < 0 && e.sharedData.bindableBlocks.push(this), e.target !== W.Fragment)
          return e._emit2DSampler(this._samplerName), void this._injectVertexCode(e);
        if (this._outputs.some(function(a) {
          return a.isConnectedInFragmentShader;
        })) {
          e._emit2DSampler(this._samplerName), this._writeTextureRead(e);
          for (var i = 0, r = this._outputs; i < r.length; i++) {
            var o = r[i];
            o.hasEndpoints && this._writeOutput(e, o, "r");
          }
          return this;
        }
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.useNonLinearDepth = this.useNonLinearDepth, e.storeCameraSpaceZ = this.storeCameraSpaceZ, e.force32itsFloat = this.force32itsFloat, e;
      }, t.prototype._deserialize = function(e, i, r) {
        n.prototype._deserialize.call(this, e, i, r), this.useNonLinearDepth = e.useNonLinearDepth, this.storeCameraSpaceZ = !!e.storeCameraSpaceZ, this.force32itsFloat = e.force32itsFloat;
      }, x([qe("Use non linear depth", Ye.Boolean, "ADVANCED", { notifiers: { activatePreviewCommand: !0, callback: function(e, i) {
        var r = i, o = !1;
        return r.useNonLinearDepth && (r.storeCameraSpaceZ = !1, o = !0), e && e.disableDepthRenderer(), o;
      } } })], t.prototype, "useNonLinearDepth", void 0), x([qe("Store Camera space Z", Ye.Boolean, "ADVANCED", { notifiers: { activatePreviewCommand: !0, callback: function(e, i) {
        var r = i, o = !1;
        return r.storeCameraSpaceZ && (r.useNonLinearDepth = !1, o = !0), e && e.disableDepthRenderer(), o;
      } } })], t.prototype, "storeCameraSpaceZ", void 0), x([qe("Force 32 bits float", Ye.Boolean, "ADVANCED", { notifiers: { activatePreviewCommand: !0, callback: function(e) {
        return e == null ? void 0 : e.disableDepthRenderer();
      } } })], t.prototype, "force32itsFloat", void 0), t;
    }(We);
    j("BABYLON.SceneDepthBlock", Ib);
    var Mb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.VertexAndFragment, !0) || this;
        return i.registerInput("worldPosition", M.Vector4, !1), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ClipPlanesBlock";
      }, t.prototype.initialize = function(e) {
        e._excludeVariableName("vClipPlane"), e._excludeVariableName("fClipDistance"), e._excludeVariableName("vClipPlane2"), e._excludeVariableName("fClipDistance2"), e._excludeVariableName("vClipPlane3"), e._excludeVariableName("fClipDistance3"), e._excludeVariableName("vClipPlane4"), e._excludeVariableName("fClipDistance4"), e._excludeVariableName("vClipPlane5"), e._excludeVariableName("fClipDistance5"), e._excludeVariableName("vClipPlane6"), e._excludeVariableName("fClipDistance6");
      }, Object.defineProperty(t.prototype, "worldPosition", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "target", { get: function() {
        return W.VertexAndFragment;
      }, set: function(e) {
      }, enumerable: !1, configurable: !0 }), t.prototype.prepareDefines = function(e, i, r) {
        var o, a, s, l, c, u, h = e.getScene(), d = !!((o = i.clipPlane) !== null && o !== void 0 ? o : h.clipPlane), p = !!((a = i.clipPlane2) !== null && a !== void 0 ? a : h.clipPlane2), f = !!((s = i.clipPlane3) !== null && s !== void 0 ? s : h.clipPlane3), m = !!((l = i.clipPlane4) !== null && l !== void 0 ? l : h.clipPlane4), g = !!((c = i.clipPlane5) !== null && c !== void 0 ? c : h.clipPlane5), y = !!((u = i.clipPlane6) !== null && u !== void 0 ? u : h.clipPlane6);
        r.setValue("CLIPPLANE", d, !0), r.setValue("CLIPPLANE2", p, !0), r.setValue("CLIPPLANE3", f, !0), r.setValue("CLIPPLANE4", m, !0), r.setValue("CLIPPLANE5", g, !0), r.setValue("CLIPPLANE6", y, !0);
      }, t.prototype.bind = function(e, i, r) {
        r && Ar(e, i, r.getScene());
      }, t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = "//".concat(this.name);
        if (e.target !== W.Fragment) {
          var r = this.worldPosition;
          return e._emitFunctionFromInclude("clipPlaneVertexDeclaration", i, { replaceStrings: [{ search: /uniform vec4 vClipPlane\d*;/g, replace: "" }] }), e.compilationString += e._emitCodeFromInclude("clipPlaneVertex", i, { replaceStrings: [{ search: /worldPos/g, replace: r.associatedVariableName }] }), e._emitUniformFromString("vClipPlane", "vec4"), e._emitUniformFromString("vClipPlane2", "vec4"), e._emitUniformFromString("vClipPlane3", "vec4"), e._emitUniformFromString("vClipPlane4", "vec4"), e._emitUniformFromString("vClipPlane5", "vec4"), void e._emitUniformFromString("vClipPlane6", "vec4");
        }
        return e.sharedData.bindableBlocks.push(this), e.sharedData.blocksWithDefines.push(this), e._emitFunctionFromInclude("clipPlaneFragmentDeclaration", i), e.compilationString += e._emitCodeFromInclude("clipPlaneFragment", i), this;
      }, t;
    }(We);
    j("BABYLON.ClipPlanesBlock", Mb);
    var Ob = function(n) {
      function t(e, i) {
        i === void 0 && (i = W.VertexAndFragment);
        var r = n.call(this, e, i, !1) || this;
        return r.registerOutput("position", M.Object, W.VertexAndFragment, new xi("position", r, ui.Output, Bo, "ImageSourceBlock")), r.registerOutput("depth", M.Object, W.VertexAndFragment, new xi("depth", r, ui.Output, Bo, "ImageSourceBlock")), r.registerOutput("normal", M.Object, W.VertexAndFragment, new xi("normal", r, ui.Output, Bo, "ImageSourceBlock")), r;
      }
      return D(t, n), Object.defineProperty(t.prototype, "texture", { get: function() {
        return null;
      }, set: function(e) {
      }, enumerable: !1, configurable: !0 }), t.prototype.getSamplerName = function(e) {
        return e === this._outputs[0] ? this._positionSamplerName : e === this._outputs[1] ? this._depthSamplerName : e === this._outputs[2] ? this._normalSamplerName : "";
      }, Object.defineProperty(t.prototype, "position", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "depth", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "normal", { get: function() {
        return this._outputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "positionSamplerName", { get: function() {
        return this._positionSamplerName;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "normalSamplerName", { get: function() {
        return this._normalSamplerName;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "depthSamplerName", { get: function() {
        return this._depthSamplerName;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "PrePassTextureBlock";
      }, t.prototype._buildBlock = function(e) {
        if (n.prototype._buildBlock.call(this, e), e.target !== W.Vertex)
          return this._positionSamplerName = "prepassPositionSampler", this._depthSamplerName = "prepassDepthSampler", this._normalSamplerName = "prepassNormalSampler", e.sharedData.variableNames.prepassPositionSampler = 0, e.sharedData.variableNames.prepassDepthSampler = 0, e.sharedData.variableNames.prepassNormalSampler = 0, e.sharedData.textureBlocks.push(this), e.sharedData.bindableBlocks.push(this), e._emit2DSampler(this._positionSamplerName), e._emit2DSampler(this._depthSamplerName), e._emit2DSampler(this._normalSamplerName), this;
      }, t.prototype.bind = function(e, i) {
        var r = i.getScene().enablePrePassRenderer();
        if (r) {
          var o = r.defaultRT;
          o.textures && (this.position.isConnected && e.setTexture(this._positionSamplerName, o.textures[r.getIndex(_.PREPASS_POSITION_TEXTURE_TYPE)]), this.depth.isConnected && e.setTexture(this._depthSamplerName, o.textures[r.getIndex(_.PREPASS_DEPTH_TEXTURE_TYPE)]), this.normal.isConnected && e.setTexture(this._normalSamplerName, o.textures[r.getIndex(_.PREPASS_NORMAL_TEXTURE_TYPE)]));
        }
      }, t;
    }(We);
    j("BABYLON.PrePassTextureBlock", Ob);
    var Db = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i._endpoints = [], i.registerInput("input", M.AutoDetect), i;
      }
      return D(t, n), Object.defineProperty(t.prototype, "endpoints", { get: function() {
        return this._endpoints;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "target", { get: function() {
        var e = this._inputs[0];
        if (e.isConnected) {
          var i = e.connectedPoint.ownerBlock;
          if (i.target !== W.VertexAndFragment)
            return i.target;
          if (e.connectedPoint.target !== W.VertexAndFragment)
            return e.connectedPoint.target;
        }
        return this._target;
      }, set: function(e) {
        !(this._target & e) && (this._target = e);
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "NodeMaterialTeleportInBlock";
      }, Object.defineProperty(t.prototype, "input", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.isConnectedInFragmentShader = function() {
        return this.endpoints.some(function(e) {
          return e.output.isConnectedInFragmentShader;
        });
      }, t.prototype._dumpCode = function(e, i) {
        for (var r = n.prototype._dumpCode.call(this, e, i), o = 0, a = this.endpoints; o < a.length; o++) {
          var s = a[o];
          i.indexOf(s) === -1 && (r += s._dumpCode(e, i));
        }
        return r;
      }, t.prototype.isAnAncestorOf = function(e) {
        for (var i = 0, r = this.endpoints; i < r.length; i++) {
          var o = r[i];
          if (o === e || o.isAnAncestorOf(e))
            return !0;
        }
        return !1;
      }, t.prototype.attachToEndpoint = function(e) {
        e.detach(), this._endpoints.push(e), e._entryPoint = this, e._outputs[0]._typeConnectionSource = this._inputs[0], e._tempEntryPointUniqueId = null, e.name = "> " + this.name;
      }, t.prototype.detachFromEndpoint = function(e) {
        var i = this._endpoints.indexOf(e);
        i !== -1 && (this._endpoints.splice(i, 1), e._outputs[0]._typeConnectionSource = null, e._entryPoint = null);
      }, t.prototype.dispose = function() {
        n.prototype.dispose.call(this);
        for (var e = 0, i = this._endpoints; e < i.length; e++) {
          var r = i[e];
          this.detachFromEndpoint(r);
        }
        this._endpoints = [];
      }, t;
    }(We);
    j("BABYLON.NodeMaterialTeleportInBlock", Db);
    var Nb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i._entryPoint = null, i._tempEntryPointUniqueId = null, i.registerOutput("output", M.BasedOnInput), i;
      }
      return D(t, n), Object.defineProperty(t.prototype, "entryPoint", { get: function() {
        return this._entryPoint;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "NodeMaterialTeleportOutBlock";
      }, Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "target", { get: function() {
        return this._entryPoint ? this._entryPoint.target : this._target;
      }, set: function(e) {
        !(this._target & e) && (this._target = e);
      }, enumerable: !1, configurable: !0 }), t.prototype.detach = function() {
        this._entryPoint && this._entryPoint.detachFromEndpoint(this);
      }, t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e), this.entryPoint && (e.compilationString += this._declareOutput(this.output, e) + " = ".concat(this.entryPoint.input.associatedVariableName, `;
`));
      }, t.prototype.clone = function(e, i) {
        i === void 0 && (i = "");
        var r = n.prototype.clone.call(this, e, i);
        return this.entryPoint && this.entryPoint.attachToEndpoint(r), r;
      }, t.prototype._customBuildStep = function(e, i) {
        this.entryPoint && this.entryPoint.build(e, i);
      }, t.prototype._dumpCode = function(e, i) {
        var r = "";
        return this.entryPoint && i.indexOf(this.entryPoint) === -1 && (r += this.entryPoint._dumpCode(e, i)), r + n.prototype._dumpCode.call(this, e, i);
      }, t.prototype._dumpCodeForOutputConnections = function(e) {
        var i = n.prototype._dumpCodeForOutputConnections.call(this, e);
        return this.entryPoint && (i += this.entryPoint._dumpCodeForOutputConnections(e)), i;
      }, t.prototype._dumpPropertiesCode = function() {
        var e = n.prototype._dumpPropertiesCode.call(this);
        return this.entryPoint && (e += "".concat(this.entryPoint._codeVariableName, ".attachToEndpoint(").concat(this._codeVariableName, `);
`)), e;
      }, t.prototype.serialize = function() {
        var e, i, r = n.prototype.serialize.call(this);
        return r.entryPoint = (i = (e = this.entryPoint) === null || e === void 0 ? void 0 : e.uniqueId) !== null && i !== void 0 ? i : "", r;
      }, t.prototype._deserialize = function(e, i, r) {
        n.prototype._deserialize.call(this, e, i, r), this._tempEntryPointUniqueId = e.entryPoint;
      }, t;
    }(We);
    j("BABYLON.NodeMaterialTeleportOutBlock", Nb);
    var Fb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("left", M.AutoDetect), i.registerInput("right", M.AutoDetect), i.registerOutput("output", M.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._linkConnectionTypes(0, 1), i._inputs[0].acceptedConnectionPointTypes.push(M.Float), i._inputs[1].acceptedConnectionPointTypes.push(M.Float), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "AddBlock";
      }, Object.defineProperty(t.prototype, "left", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        return e.compilationString += this._declareOutput(i, e) + " = ".concat(this.left.associatedVariableName, " + ").concat(this.right.associatedVariableName, `;
`), this;
      }, t;
    }(We);
    j("BABYLON.AddBlock", Fb);
    var Lb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("input", M.AutoDetect), i.registerInput("factor", M.Float), i.registerOutput("output", M.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ScaleBlock";
      }, Object.defineProperty(t.prototype, "input", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "factor", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        return e.compilationString += this._declareOutput(i, e) + " = ".concat(this.input.associatedVariableName, " * ").concat(this.factor.associatedVariableName, `;
`), this;
      }, t;
    }(We);
    j("BABYLON.ScaleBlock", Lb);
    var wb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.minimum = 0, i.maximum = 1, i.registerInput("value", M.AutoDetect), i.registerOutput("output", M.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ClampBlock";
      }, Object.defineProperty(t.prototype, "value", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        return e.compilationString += this._declareOutput(i, e) + " = clamp(".concat(this.value.associatedVariableName, ", ").concat(this._writeFloat(this.minimum), ", ").concat(this._writeFloat(this.maximum), `);
`), this;
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".minimum = ").concat(this.minimum, `;
`) + "".concat(this._codeVariableName, ".maximum = ").concat(this.maximum, `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.minimum = this.minimum, e.maximum = this.maximum, e;
      }, t.prototype._deserialize = function(e, i, r) {
        n.prototype._deserialize.call(this, e, i, r), this.minimum = e.minimum, this.maximum = e.maximum;
      }, x([qe("Minimum", Ye.Float)], t.prototype, "minimum", void 0), x([qe("Maximum", Ye.Float)], t.prototype, "maximum", void 0), t;
    }(We);
    j("BABYLON.ClampBlock", wb);
    var Bb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("left", M.AutoDetect), i.registerInput("right", M.AutoDetect), i.registerOutput("output", M.Vector3), i._linkConnectionTypes(0, 1), i._inputs[0].excludedConnectionPointTypes.push(M.Float), i._inputs[0].excludedConnectionPointTypes.push(M.Matrix), i._inputs[0].excludedConnectionPointTypes.push(M.Vector2), i._inputs[1].excludedConnectionPointTypes.push(M.Float), i._inputs[1].excludedConnectionPointTypes.push(M.Matrix), i._inputs[1].excludedConnectionPointTypes.push(M.Vector2), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "CrossBlock";
      }, Object.defineProperty(t.prototype, "left", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        return e.compilationString += this._declareOutput(i, e) + " = cross(".concat(this.left.associatedVariableName, ".xyz, ").concat(this.right.associatedVariableName, `.xyz);
`), this;
      }, t;
    }(We);
    j("BABYLON.CrossBlock", Bb);
    var Ub = function(n) {
      function t(e) {
        return n.call(this, e) || this;
      }
      return D(t, n), Object.defineProperty(t.prototype, "options", { get: function() {
        return this._options;
      }, set: function(e) {
        this._deserializeOptions(e);
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "CustomBlock";
      }, t.prototype._buildBlock = function(e) {
        var i = this;
        n.prototype._buildBlock.call(this, e);
        var r = this._code, o = this._options.functionName;
        this._inputs.forEach(function(s) {
          var l = new RegExp("\\{TYPE_" + s.name + "\\}", "gm"), c = e._getGLType(s.type);
          r = r.replace(l, c), o = o.replace(l, c);
        }), this._outputs.forEach(function(s) {
          var l = new RegExp("\\{TYPE_" + s.name + "\\}", "gm"), c = e._getGLType(s.type);
          r = r.replace(l, c), o = o.replace(l, c);
        }), e._emitFunction(o, r, ""), this._outputs.forEach(function(s) {
          e.compilationString += i._declareOutput(s, e) + `;
`;
        }), e.compilationString += o + "(";
        var a = !1;
        return this._inputs.forEach(function(s, l) {
          var c, u, h;
          l > 0 && (e.compilationString += ", "), i._inputSamplers && i._inputSamplers.indexOf(s.name) !== -1 ? e.compilationString += (h = (u = (c = s.connectedPoint) === null || c === void 0 ? void 0 : c.ownerBlock) === null || u === void 0 ? void 0 : u.samplerName) !== null && h !== void 0 ? h : s.associatedVariableName : e.compilationString += s.associatedVariableName, a = !0;
        }), this._outputs.forEach(function(s, l) {
          (l > 0 || a) && (e.compilationString += ", "), e.compilationString += s.associatedVariableName;
        }), e.compilationString += `);
`, this;
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".options = ").concat(JSON.stringify(this._options), `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.options = this._options, e;
      }, t.prototype._deserialize = function(e, i, r) {
        this._deserializeOptions(e.options), n.prototype._deserialize.call(this, e, i, r);
      }, t.prototype._deserializeOptions = function(e) {
        var i, r, o, a = this;
        this._options = e, this._code = e.code.join(`
`) + `
`, this.name = this.name || e.name, this.target = W[e.target], (i = e.inParameters) === null || i === void 0 || i.forEach(function(s, l) {
          var c = M[s.type];
          s.type === "sampler2D" || s.type === "samplerCube" ? (a._inputSamplers = a._inputSamplers || [], a._inputSamplers.push(s.name), a.registerInput(s.name, M.Object, !0, W.VertexAndFragment, new xi(s.name, a, ui.Input, Bo, "ImageSourceBlock"))) : a.registerInput(s.name, c), Object.defineProperty(a, s.name, { get: function() {
            return this._inputs[l];
          }, enumerable: !0, configurable: !0 });
        }), (r = e.outParameters) === null || r === void 0 || r.forEach(function(s, l) {
          a.registerOutput(s.name, M[s.type]), Object.defineProperty(a, s.name, { get: function() {
            return this._outputs[l];
          }, enumerable: !0, configurable: !0 }), s.type === "BasedOnInput" && (a._outputs[l]._typeConnectionSource = a._findInputByName(s.typeFromInput)[0]);
        }), (o = e.inLinkedConnectionTypes) === null || o === void 0 || o.forEach(function(s) {
          a._linkConnectionTypes(a._findInputByName(s.input1)[1], a._findInputByName(s.input2)[1]);
        });
      }, t.prototype._findInputByName = function(e) {
        if (!e)
          return null;
        for (var i = 0; i < this._inputs.length; i++)
          if (this._inputs[i].name === e)
            return [this._inputs[i], i];
        return null;
      }, t;
    }(We);
    j("BABYLON.CustomBlock", Ub);
    var Vb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("left", M.AutoDetect), i.registerInput("right", M.AutoDetect), i.registerOutput("output", M.Float), i._linkConnectionTypes(0, 1), i._inputs[0].excludedConnectionPointTypes.push(M.Float), i._inputs[0].excludedConnectionPointTypes.push(M.Matrix), i._inputs[1].excludedConnectionPointTypes.push(M.Float), i._inputs[1].excludedConnectionPointTypes.push(M.Matrix), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "DotBlock";
      }, Object.defineProperty(t.prototype, "left", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        return e.compilationString += this._declareOutput(i, e) + " = dot(".concat(this.left.associatedVariableName, ", ").concat(this.right.associatedVariableName, `);
`), this;
      }, t;
    }(We);
    j("BABYLON.DotBlock", Vb);
    var kb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("input", M.AutoDetect), i.registerOutput("output", M.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._inputs[0].excludedConnectionPointTypes.push(M.Float), i._inputs[0].excludedConnectionPointTypes.push(M.Matrix), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "NormalizeBlock";
      }, Object.defineProperty(t.prototype, "input", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0], r = this._inputs[0];
        return e.compilationString += this._declareOutput(i, e) + " = normalize(".concat(r.associatedVariableName, `);
`), this;
      }, t;
    }(We);
    j("BABYLON.NormalizeBlock", kb);
    var Gb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.rSwizzle = "r", i.gSwizzle = "g", i.bSwizzle = "b", i.aSwizzle = "a", i.registerInput("rgb ", M.Color3, !0), i.registerInput("r", M.Float, !0), i.registerInput("g", M.Float, !0), i.registerInput("b", M.Float, !0), i.registerInput("a", M.Float, !0), i.registerOutput("rgba", M.Color4), i.registerOutput("rgb", M.Color3), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ColorMergerBlock";
      }, Object.defineProperty(t.prototype, "rgbIn", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "r", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "g", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "b", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "a", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgba", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgbOut", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgb", { get: function() {
        return this.rgbOut;
      }, enumerable: !1, configurable: !0 }), t.prototype._inputRename = function(e) {
        return e === "rgb " ? "rgbIn" : e;
      }, t.prototype._buildSwizzle = function(e) {
        return "." + (this.rSwizzle + this.gSwizzle + this.bSwizzle + this.aSwizzle).substr(0, e);
      }, t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this.r, r = this.g, o = this.b, a = this.a, s = this.rgbIn, l = this._outputs[0], c = this._outputs[1];
        return s.isConnected ? (l.hasEndpoints && (e.compilationString += this._declareOutput(l, e) + " = vec4(".concat(s.associatedVariableName, ", ").concat(a.isConnected ? this._writeVariable(a) : "0.0", ")").concat(this._buildSwizzle(4), `;
`)), c.hasEndpoints && (e.compilationString += this._declareOutput(c, e) + " = ".concat(s.associatedVariableName).concat(this._buildSwizzle(3), `;
`))) : (l.hasEndpoints && (e.compilationString += this._declareOutput(l, e) + " = vec4(".concat(i.isConnected ? this._writeVariable(i) : "0.0", ", ").concat(r.isConnected ? this._writeVariable(r) : "0.0", ", ").concat(o.isConnected ? this._writeVariable(o) : "0.0", ", ").concat(a.isConnected ? this._writeVariable(a) : "0.0", ")").concat(this._buildSwizzle(4), `;
`)), c.hasEndpoints && (e.compilationString += this._declareOutput(c, e) + " = vec3(".concat(i.isConnected ? this._writeVariable(i) : "0.0", ", ").concat(r.isConnected ? this._writeVariable(r) : "0.0", ", ").concat(o.isConnected ? this._writeVariable(o) : "0.0", ")").concat(this._buildSwizzle(3), `;
`))), this;
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.rSwizzle = this.rSwizzle, e.gSwizzle = this.gSwizzle, e.bSwizzle = this.bSwizzle, e.aSwizzle = this.aSwizzle, e;
      }, t.prototype._deserialize = function(e, i, r) {
        var o, a, s, l;
        n.prototype._deserialize.call(this, e, i, r), this.rSwizzle = (o = e.rSwizzle) !== null && o !== void 0 ? o : "r", this.gSwizzle = (a = e.gSwizzle) !== null && a !== void 0 ? a : "g", this.bSwizzle = (s = e.bSwizzle) !== null && s !== void 0 ? s : "b", this.aSwizzle = (l = e.aSwizzle) !== null && l !== void 0 ? l : "a";
      }, t.prototype._dumpPropertiesCode = function() {
        var e = n.prototype._dumpPropertiesCode.call(this);
        return e += "".concat(this._codeVariableName, '.rSwizzle = "').concat(this.rSwizzle, `";
`), e += "".concat(this._codeVariableName, '.gSwizzle = "').concat(this.gSwizzle, `";
`), (e += "".concat(this._codeVariableName, '.bSwizzle = "').concat(this.bSwizzle, `";
`)) + "".concat(this._codeVariableName, '.aSwizzle = "').concat(this.aSwizzle, `";
`);
      }, t;
    }(We);
    j("BABYLON.ColorMergerBlock", Gb);
    var zb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("xyzw", M.Vector4, !0), i.registerInput("xyz ", M.Vector3, !0), i.registerInput("xy ", M.Vector2, !0), i.registerOutput("xyz", M.Vector3), i.registerOutput("xy", M.Vector2), i.registerOutput("zw", M.Vector2), i.registerOutput("x", M.Float), i.registerOutput("y", M.Float), i.registerOutput("z", M.Float), i.registerOutput("w", M.Float), i.inputsAreExclusive = !0, i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "VectorSplitterBlock";
      }, Object.defineProperty(t.prototype, "xyzw", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyzIn", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyIn", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyzOut", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyOut", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "zw", { get: function() {
        return this._outputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "x", { get: function() {
        return this._outputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "y", { get: function() {
        return this._outputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "z", { get: function() {
        return this._outputs[5];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "w", { get: function() {
        return this._outputs[6];
      }, enumerable: !1, configurable: !0 }), t.prototype._inputRename = function(e) {
        switch (e) {
          case "xy ":
            return "xyIn";
          case "xyz ":
            return "xyzIn";
          default:
            return e;
        }
      }, t.prototype._outputRename = function(e) {
        switch (e) {
          case "xy":
            return "xyOut";
          case "xyz":
            return "xyzOut";
          default:
            return e;
        }
      }, t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this.xyzw.isConnected ? this.xyzw : this.xyzIn.isConnected ? this.xyzIn : this.xyIn, r = this._outputs[0], o = this._outputs[1], a = this._outputs[2], s = this._outputs[3], l = this._outputs[4], c = this._outputs[5], u = this._outputs[6];
        return r.hasEndpoints && (i === this.xyIn ? e.compilationString += this._declareOutput(r, e) + " = vec3(".concat(i.associatedVariableName, `, 0.0);
`) : e.compilationString += this._declareOutput(r, e) + " = ".concat(i.associatedVariableName, `.xyz;
`)), a.hasEndpoints && this.xyzw.isConnected && (e.compilationString += this._declareOutput(a, e) + " = ".concat(this.xyzw.associatedVariableName, `.zw;
`)), o.hasEndpoints && (e.compilationString += this._declareOutput(o, e) + " = ".concat(i.associatedVariableName, `.xy;
`)), s.hasEndpoints && (e.compilationString += this._declareOutput(s, e) + " = ".concat(i.associatedVariableName, `.x;
`)), l.hasEndpoints && (e.compilationString += this._declareOutput(l, e) + " = ".concat(i.associatedVariableName, `.y;
`)), c.hasEndpoints && (e.compilationString += this._declareOutput(c, e) + " = ".concat(i.associatedVariableName, `.z;
`)), u.hasEndpoints && (e.compilationString += this._declareOutput(u, e) + " = ".concat(i.associatedVariableName, `.w;
`)), this;
      }, t;
    }(We);
    j("BABYLON.VectorSplitterBlock", zb);
    var Wb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("left", M.AutoDetect), i.registerInput("right", M.AutoDetect), i.registerInput("gradient", M.AutoDetect), i.registerOutput("output", M.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._linkConnectionTypes(0, 1), i._linkConnectionTypes(1, 2, !0), i._inputs[2].acceptedConnectionPointTypes.push(M.Float), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "LerpBlock";
      }, Object.defineProperty(t.prototype, "left", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "gradient", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        return e.compilationString += this._declareOutput(i, e) + " = mix(".concat(this.left.associatedVariableName, " , ").concat(this.right.associatedVariableName, ", ").concat(this.gradient.associatedVariableName, `);
`), this;
      }, t;
    }(We);
    j("BABYLON.LerpBlock", Wb);
    var Hb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("left", M.AutoDetect), i.registerInput("right", M.AutoDetect), i.registerOutput("output", M.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._linkConnectionTypes(0, 1), i._inputs[0].acceptedConnectionPointTypes.push(M.Float), i._inputs[1].acceptedConnectionPointTypes.push(M.Float), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "DivideBlock";
      }, Object.defineProperty(t.prototype, "left", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        return e.compilationString += this._declareOutput(i, e) + " = ".concat(this.left.associatedVariableName, " / ").concat(this.right.associatedVariableName, `;
`), this;
      }, t;
    }(We);
    j("BABYLON.DivideBlock", Hb);
    var Xb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("left", M.AutoDetect), i.registerInput("right", M.AutoDetect), i.registerOutput("output", M.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._linkConnectionTypes(0, 1), i._inputs[0].acceptedConnectionPointTypes.push(M.Float), i._inputs[1].acceptedConnectionPointTypes.push(M.Float), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "SubtractBlock";
      }, Object.defineProperty(t.prototype, "left", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        return e.compilationString += this._declareOutput(i, e) + " = ".concat(this.left.associatedVariableName, " - ").concat(this.right.associatedVariableName, `;
`), this;
      }, t;
    }(We);
    j("BABYLON.SubtractBlock", Xb);
    var jb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("value", M.Float), i.registerInput("edge", M.Float), i.registerOutput("output", M.Float), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "StepBlock";
      }, Object.defineProperty(t.prototype, "value", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "edge", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        return e.compilationString += this._declareOutput(i, e) + " = step(".concat(this.edge.associatedVariableName, ", ").concat(this.value.associatedVariableName, `);
`), this;
      }, t;
    }(We);
    j("BABYLON.StepBlock", jb);
    var L_ = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("input", M.AutoDetect), i.registerOutput("output", M.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._outputs[0].excludedConnectionPointTypes.push(M.Matrix), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "OneMinusBlock";
      }, Object.defineProperty(t.prototype, "input", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        return e.compilationString += this._declareOutput(i, e) + " = 1. - ".concat(this.input.associatedVariableName, `;
`), this;
      }, t;
    }(We);
    j("BABYLON.OneMinusBlock", L_), j("BABYLON.OppositeBlock", L_);
    var w_ = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("worldPosition", M.Vector4), i.registerInput("cameraPosition", M.Vector3), i.registerOutput("output", M.Vector3), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ViewDirectionBlock";
      }, Object.defineProperty(t.prototype, "worldPosition", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraPosition", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function(e, i) {
        if (i === void 0 && (i = function() {
          return !0;
        }), !this.cameraPosition.isConnected) {
          var r = e.getInputBlockByPredicate(function(o) {
            return o.systemValue === Tt.CameraPosition && i(o);
          });
          r || (r = new vt("cameraPosition")).setAsSystemValue(Tt.CameraPosition), r.output.connectTo(this.cameraPosition);
        }
      }, t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        return e.compilationString += this._declareOutput(i, e) + " = normalize(".concat(this.cameraPosition.associatedVariableName, " - ").concat(this.worldPosition.associatedVariableName, `.xyz);
`), this;
      }, t;
    }(We);
    j("BABYLON.ViewDirectionBlock", w_);
    var Yb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("worldNormal", M.Vector4), i.registerInput("viewDirection", M.Vector3), i.registerInput("bias", M.Float), i.registerInput("power", M.Float), i.registerOutput("fresnel", M.Float), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "FresnelBlock";
      }, Object.defineProperty(t.prototype, "worldNormal", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "viewDirection", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "bias", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "power", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "fresnel", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function(e) {
        if (!this.viewDirection.isConnected) {
          var i = new w_("View direction");
          i.output.connectTo(this.viewDirection), i.autoConfigure(e);
        }
        if (!this.bias.isConnected) {
          var r = new vt("bias");
          r.value = 0, r.output.connectTo(this.bias);
        }
        if (!this.power.isConnected) {
          var o = new vt("power");
          o.value = 1, o.output.connectTo(this.power);
        }
      }, t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = "//".concat(this.name);
        return e._emitFunctionFromInclude("fresnelFunction", i, { removeIfDef: !0 }), e.compilationString += this._declareOutput(this.fresnel, e) + " = computeFresnelTerm(".concat(this.viewDirection.associatedVariableName, ".xyz, ").concat(this.worldNormal.associatedVariableName, ".xyz, ").concat(this.bias.associatedVariableName, ", ").concat(this.power.associatedVariableName, `);
`), this;
      }, t;
    }(We);
    j("BABYLON.FresnelBlock", Yb);
    var Kb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("left", M.AutoDetect), i.registerInput("right", M.AutoDetect), i.registerOutput("output", M.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._linkConnectionTypes(0, 1), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "MaxBlock";
      }, Object.defineProperty(t.prototype, "left", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        return e.compilationString += this._declareOutput(i, e) + " = max(".concat(this.left.associatedVariableName, ", ").concat(this.right.associatedVariableName, `);
`), this;
      }, t;
    }(We);
    j("BABYLON.MaxBlock", Kb);
    var qb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("left", M.AutoDetect), i.registerInput("right", M.AutoDetect), i.registerOutput("output", M.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._linkConnectionTypes(0, 1), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "MinBlock";
      }, Object.defineProperty(t.prototype, "left", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        return e.compilationString += this._declareOutput(i, e) + " = min(".concat(this.left.associatedVariableName, ", ").concat(this.right.associatedVariableName, `);
`), this;
      }, t;
    }(We);
    j("BABYLON.MinBlock", qb);
    var Qb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("left", M.AutoDetect), i.registerInput("right", M.AutoDetect), i.registerOutput("output", M.Float), i._linkConnectionTypes(0, 1), i._inputs[0].excludedConnectionPointTypes.push(M.Float), i._inputs[0].excludedConnectionPointTypes.push(M.Matrix), i._inputs[1].excludedConnectionPointTypes.push(M.Float), i._inputs[1].excludedConnectionPointTypes.push(M.Matrix), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "DistanceBlock";
      }, Object.defineProperty(t.prototype, "left", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        return e.compilationString += this._declareOutput(i, e) + " = length(".concat(this.left.associatedVariableName, " - ").concat(this.right.associatedVariableName, `);
`), this;
      }, t;
    }(We);
    j("BABYLON.DistanceBlock", Qb);
    var Zb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("value", M.AutoDetect), i.registerOutput("output", M.Float), i._inputs[0].excludedConnectionPointTypes.push(M.Float), i._inputs[0].excludedConnectionPointTypes.push(M.Matrix), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "LengthBlock";
      }, Object.defineProperty(t.prototype, "value", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        return e.compilationString += this._declareOutput(i, e) + " = length(".concat(this.value.associatedVariableName, `);
`), this;
      }, t;
    }(We);
    j("BABYLON.LengthBlock", Zb);
    var Jb = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("value", M.AutoDetect), i.registerOutput("output", M.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "NegateBlock";
      }, Object.defineProperty(t.prototype, "value", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        return e.compilationString += this._declareOutput(i, e) + " = -1.0 * ".concat(this.value.associatedVariableName, `;
`), this;
      }, t;
    }(We);
    j("BABYLON.NegateBlock", Jb);
    var $b = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("value", M.AutoDetect), i.registerInput("power", M.AutoDetect), i.registerOutput("output", M.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._linkConnectionTypes(0, 1), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "PowBlock";
      }, Object.defineProperty(t.prototype, "value", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "power", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        return e.compilationString += this._declareOutput(i, e) + " = pow(".concat(this.value.associatedVariableName, ", ").concat(this.power.associatedVariableName, `);
`), this;
      }, t;
    }(We);
    j("BABYLON.PowBlock", $b);
    var eT = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("seed", M.AutoDetect), i.registerOutput("output", M.Float), i._inputs[0].addExcludedConnectionPointFromAllowedTypes(M.Vector2 | M.Vector3 | M.Vector4 | M.Color3 | M.Color4), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "RandomNumberBlock";
      }, Object.defineProperty(t.prototype, "seed", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0], r = "//".concat(this.name);
        return e._emitFunctionFromInclude("helperFunctions", r), e.compilationString += this._declareOutput(i, e) + " = getRand(".concat(this.seed.associatedVariableName, `.xy);
`), this;
      }, t;
    }(We);
    j("BABYLON.RandomNumberBlock", eT);
    var tT = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("x", M.Float), i.registerInput("y", M.Float), i.registerOutput("output", M.Float), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ArcTan2Block";
      }, Object.defineProperty(t.prototype, "x", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "y", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        return e.compilationString += this._declareOutput(i, e) + " = atan(".concat(this.x.associatedVariableName, ", ").concat(this.y.associatedVariableName, `);
`), this;
      }, t;
    }(We);
    j("BABYLON.ArcTan2Block", tT);
    var iT = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("value", M.AutoDetect), i.registerInput("edge0", M.Float), i.registerInput("edge1", M.Float), i.registerOutput("output", M.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "SmoothStepBlock";
      }, Object.defineProperty(t.prototype, "value", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "edge0", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "edge1", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        return e.compilationString += this._declareOutput(i, e) + " = smoothstep(".concat(this.edge0.associatedVariableName, ", ").concat(this.edge1.associatedVariableName, ", ").concat(this.value.associatedVariableName, `);
`), this;
      }, t;
    }(We);
    j("BABYLON.SmoothStepBlock", iT);
    var nT = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("input", M.AutoDetect), i.registerOutput("output", M.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ReciprocalBlock";
      }, Object.defineProperty(t.prototype, "input", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        return this.input.type === M.Matrix ? e.compilationString += this._declareOutput(i, e) + " = inverse(".concat(this.input.associatedVariableName, `);
`) : e.compilationString += this._declareOutput(i, e) + " = 1. / ".concat(this.input.associatedVariableName, `;
`), this;
      }, t;
    }(We);
    j("BABYLON.ReciprocalBlock", nT);
    var rT = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("value", M.AutoDetect), i.registerInput("reference", M.AutoDetect), i.registerInput("distance", M.Float), i.registerInput("replacement", M.AutoDetect), i.registerOutput("output", M.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._linkConnectionTypes(0, 1), i._linkConnectionTypes(0, 3), i._inputs[0].excludedConnectionPointTypes.push(M.Float), i._inputs[0].excludedConnectionPointTypes.push(M.Matrix), i._inputs[1].excludedConnectionPointTypes.push(M.Float), i._inputs[1].excludedConnectionPointTypes.push(M.Matrix), i._inputs[3].excludedConnectionPointTypes.push(M.Float), i._inputs[3].excludedConnectionPointTypes.push(M.Matrix), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ReplaceColorBlock";
      }, Object.defineProperty(t.prototype, "value", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "reference", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "distance", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "replacement", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        return e.compilationString += this._declareOutput(i, e) + `;
`, e.compilationString += "if (length(".concat(this.value.associatedVariableName, " - ").concat(this.reference.associatedVariableName, ") < ").concat(this.distance.associatedVariableName, `) {
`), e.compilationString += "".concat(i.associatedVariableName, " = ").concat(this.replacement.associatedVariableName, `;
`), e.compilationString += `} else {
`, e.compilationString += "".concat(i.associatedVariableName, " = ").concat(this.value.associatedVariableName, `;
`), e.compilationString += `}
`, this;
      }, t;
    }(We);
    j("BABYLON.ReplaceColorBlock", rT);
    var Is, oT = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("value", M.AutoDetect), i.registerInput("steps", M.AutoDetect), i.registerOutput("output", M.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._linkConnectionTypes(0, 1), i._inputs[0].excludedConnectionPointTypes.push(M.Matrix), i._inputs[1].excludedConnectionPointTypes.push(M.Matrix), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "PosterizeBlock";
      }, Object.defineProperty(t.prototype, "value", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "steps", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        return e.compilationString += this._declareOutput(i, e) + " = floor(".concat(this.value.associatedVariableName, " / (1.0 / ").concat(this.steps.associatedVariableName, ")) * (1.0 / ").concat(this.steps.associatedVariableName, `);
`), this;
      }, t;
    }(We);
    j("BABYLON.PosterizeBlock", oT), function(n) {
      n[n.SawTooth = 0] = "SawTooth", n[n.Square = 1] = "Square", n[n.Triangle = 2] = "Triangle";
    }(Is || (Is = {}));
    var aT = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.kind = Is.SawTooth, i.registerInput("input", M.AutoDetect), i.registerOutput("output", M.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._inputs[0].excludedConnectionPointTypes.push(M.Matrix), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "WaveBlock";
      }, Object.defineProperty(t.prototype, "input", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        switch (this.kind) {
          case Is.SawTooth:
            e.compilationString += this._declareOutput(i, e) + " = ".concat(this.input.associatedVariableName, " - floor(0.5 + ").concat(this.input.associatedVariableName, `);
`);
            break;
          case Is.Square:
            e.compilationString += this._declareOutput(i, e) + " = 1.0 - 2.0 * round(fract(".concat(this.input.associatedVariableName, `));
`);
            break;
          case Is.Triangle:
            e.compilationString += this._declareOutput(i, e) + " = 2.0 * abs(2.0 * (".concat(this.input.associatedVariableName, " - floor(0.5 + ").concat(this.input.associatedVariableName, `))) - 1.0;
`);
        }
        return this;
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.kind = this.kind, e;
      }, t.prototype._deserialize = function(e, i, r) {
        n.prototype._deserialize.call(this, e, i, r), this.kind = e.kind;
      }, t;
    }(We);
    j("BABYLON.WaveBlock", aT);
    var ad = function() {
      function n(t, e) {
        this.step = t, this.color = e;
      }
      return Object.defineProperty(n.prototype, "step", { get: function() {
        return this._step;
      }, set: function(t) {
        this._step = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "color", { get: function() {
        return this._color;
      }, set: function(t) {
        this._color = t;
      }, enumerable: !1, configurable: !0 }), n;
    }(), sT = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.colorSteps = [new ad(0, ne.Black()), new ad(1, ne.White())], i.onValueChangedObservable = new H(), i.registerInput("gradient", M.AutoDetect), i.registerOutput("output", M.Color3), i._inputs[0].addExcludedConnectionPointFromAllowedTypes(M.Float | M.Vector2 | M.Vector3 | M.Vector4 | M.Color3 | M.Color4), i;
      }
      return D(t, n), t.prototype.colorStepsUpdated = function() {
        this.onValueChangedObservable.notifyObservers(this);
      }, t.prototype.getClassName = function() {
        return "GradientBlock";
      }, Object.defineProperty(t.prototype, "gradient", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._writeColorConstant = function(e) {
        var i = this.colorSteps[e];
        return "vec3(".concat(i.color.r, ", ").concat(i.color.g, ", ").concat(i.color.b, ")");
      }, t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        if (this.colorSteps.length && this.gradient.connectedPoint) {
          var r = e._getFreeVariableName("gradientTempColor"), o = e._getFreeVariableName("gradientTempPosition");
          e.compilationString += "vec3 ".concat(r, " = ").concat(this._writeColorConstant(0), `;
`), e.compilationString += "float ".concat(o, `;
`);
          var a = this.gradient.associatedVariableName;
          this.gradient.connectedPoint.type !== M.Float && (a += ".x");
          for (var s = 1; s < this.colorSteps.length; s++) {
            var l = this.colorSteps[s], c = this.colorSteps[s - 1];
            e.compilationString += "".concat(o, " = clamp((").concat(a, " - ").concat(e._emitFloat(c.step), ") / (").concat(e._emitFloat(l.step), " -  ").concat(e._emitFloat(c.step), "), 0.0, 1.0) * step(").concat(e._emitFloat(s), ", ").concat(e._emitFloat(this.colorSteps.length - 1), `);
`), e.compilationString += "".concat(r, " = mix(").concat(r, ", ").concat(this._writeColorConstant(s), ", ").concat(o, `);
`);
          }
          return e.compilationString += this._declareOutput(i, e) + " = ".concat(r, `;
`), this;
        }
        e.compilationString += this._declareOutput(i, e) + ` = vec3(0., 0., 0.);
`;
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        e.colorSteps = [];
        for (var i = 0, r = this.colorSteps; i < r.length; i++) {
          var o = r[i];
          e.colorSteps.push({ step: o.step, color: { r: o.color.r, g: o.color.g, b: o.color.b } });
        }
        return e;
      }, t.prototype._deserialize = function(e, i, r) {
        n.prototype._deserialize.call(this, e, i, r), this.colorSteps.length = 0;
        for (var o = 0, a = e.colorSteps; o < a.length; o++) {
          var s = a[o];
          this.colorSteps.push(new ad(s.step, new ne(s.color.r, s.color.g, s.color.b)));
        }
      }, t.prototype._dumpPropertiesCode = function() {
        var e = n.prototype._dumpPropertiesCode.call(this);
        e += "".concat(this._codeVariableName, `.colorSteps = [];
`);
        for (var i = 0, r = this.colorSteps; i < r.length; i++) {
          var o = r[i];
          e += "".concat(this._codeVariableName, ".colorSteps.push(new BABYLON.GradientBlockColorStep(").concat(o.step, ", new BABYLON.Color3(").concat(o.color.r, ", ").concat(o.color.g, ", ").concat(o.color.b, `)));
`);
        }
        return e;
      }, t;
    }(We);
    j("BABYLON.GradientBlock", sT);
    var lT = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("left", M.AutoDetect), i.registerInput("right", M.AutoDetect), i.registerInput("gradient", M.AutoDetect), i.registerOutput("output", M.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._linkConnectionTypes(0, 1), i._linkConnectionTypes(1, 2, !0), i._inputs[2].acceptedConnectionPointTypes.push(M.Float), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "NLerpBlock";
      }, Object.defineProperty(t.prototype, "left", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "gradient", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        return e.compilationString += this._declareOutput(i, e) + " = normalize(mix(".concat(this.left.associatedVariableName, " , ").concat(this.right.associatedVariableName, ", ").concat(this.gradient.associatedVariableName, `));
`), this;
      }, t;
    }(We);
    j("BABYLON.NLerpBlock", lT);
    var cT = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.manhattanDistance = !1, i.registerInput("seed", M.Vector3), i.registerInput("jitter", M.Float), i.registerOutput("output", M.Vector2), i.registerOutput("x", M.Float), i.registerOutput("y", M.Float), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "WorleyNoise3DBlock";
      }, Object.defineProperty(t.prototype, "seed", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "jitter", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "x", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "y", { get: function() {
        return this._outputs[2];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        if (n.prototype._buildBlock.call(this, e), this.seed.isConnected && (this.output.hasEndpoints || this.x.hasEndpoints || this.y.hasEndpoints)) {
          e._emitFunction("worley3D", `vec3 permute(vec3 x){
    return mod((34.0 * x + 1.0) * x, 289.0);
}

vec3 dist(vec3 x, vec3 y, vec3 z,  bool manhattanDistance){
    return manhattanDistance ?  abs(x) + abs(y) + abs(z) :  (x * x + y * y + z * z);
}

vec2 worley(vec3 P, float jitter, bool manhattanDistance){
    float K = 0.142857142857; // 1/7
    float Ko = 0.428571428571; // 1/2-K/2
    float  K2 = 0.020408163265306; // 1/(7*7)
    float Kz = 0.166666666667; // 1/6
    float Kzo = 0.416666666667; // 1/2-1/6*2

    vec3 Pi = mod(floor(P), 289.0);
    vec3 Pf = fract(P) - 0.5;

    vec3 Pfx = Pf.x + vec3(1.0, 0.0, -1.0);
    vec3 Pfy = Pf.y + vec3(1.0, 0.0, -1.0);
    vec3 Pfz = Pf.z + vec3(1.0, 0.0, -1.0);

    vec3 p = permute(Pi.x + vec3(-1.0, 0.0, 1.0));
    vec3 p1 = permute(p + Pi.y - 1.0);
    vec3 p2 = permute(p + Pi.y);
    vec3 p3 = permute(p + Pi.y + 1.0);

    vec3 p11 = permute(p1 + Pi.z - 1.0);
    vec3 p12 = permute(p1 + Pi.z);
    vec3 p13 = permute(p1 + Pi.z + 1.0);

    vec3 p21 = permute(p2 + Pi.z - 1.0);
    vec3 p22 = permute(p2 + Pi.z);
    vec3 p23 = permute(p2 + Pi.z + 1.0);

    vec3 p31 = permute(p3 + Pi.z - 1.0);
    vec3 p32 = permute(p3 + Pi.z);
    vec3 p33 = permute(p3 + Pi.z + 1.0);

    vec3 ox11 = fract(p11*K) - Ko;
    vec3 oy11 = mod(floor(p11*K), 7.0)*K - Ko;
    vec3 oz11 = floor(p11*K2)*Kz - Kzo; // p11 < 289 guaranteed

    vec3 ox12 = fract(p12*K) - Ko;
    vec3 oy12 = mod(floor(p12*K), 7.0)*K - Ko;
    vec3 oz12 = floor(p12*K2)*Kz - Kzo;

    vec3 ox13 = fract(p13*K) - Ko;
    vec3 oy13 = mod(floor(p13*K), 7.0)*K - Ko;
    vec3 oz13 = floor(p13*K2)*Kz - Kzo;

    vec3 ox21 = fract(p21*K) - Ko;
    vec3 oy21 = mod(floor(p21*K), 7.0)*K - Ko;
    vec3 oz21 = floor(p21*K2)*Kz - Kzo;

    vec3 ox22 = fract(p22*K) - Ko;
    vec3 oy22 = mod(floor(p22*K), 7.0)*K - Ko;
    vec3 oz22 = floor(p22*K2)*Kz - Kzo;

    vec3 ox23 = fract(p23*K) - Ko;
    vec3 oy23 = mod(floor(p23*K), 7.0)*K - Ko;
    vec3 oz23 = floor(p23*K2)*Kz - Kzo;

    vec3 ox31 = fract(p31*K) - Ko;
    vec3 oy31 = mod(floor(p31*K), 7.0)*K - Ko;
    vec3 oz31 = floor(p31*K2)*Kz - Kzo;

    vec3 ox32 = fract(p32*K) - Ko;
    vec3 oy32 = mod(floor(p32*K), 7.0)*K - Ko;
    vec3 oz32 = floor(p32*K2)*Kz - Kzo;

    vec3 ox33 = fract(p33*K) - Ko;
    vec3 oy33 = mod(floor(p33*K), 7.0)*K - Ko;
    vec3 oz33 = floor(p33*K2)*Kz - Kzo;

    vec3 dx11 = Pfx + jitter*ox11;
    vec3 dy11 = Pfy.x + jitter*oy11;
    vec3 dz11 = Pfz.x + jitter*oz11;

    vec3 dx12 = Pfx + jitter*ox12;
    vec3 dy12 = Pfy.x + jitter*oy12;
    vec3 dz12 = Pfz.y + jitter*oz12;

    vec3 dx13 = Pfx + jitter*ox13;
    vec3 dy13 = Pfy.x + jitter*oy13;
    vec3 dz13 = Pfz.z + jitter*oz13;

    vec3 dx21 = Pfx + jitter*ox21;
    vec3 dy21 = Pfy.y + jitter*oy21;
    vec3 dz21 = Pfz.x + jitter*oz21;

    vec3 dx22 = Pfx + jitter*ox22;
    vec3 dy22 = Pfy.y + jitter*oy22;
    vec3 dz22 = Pfz.y + jitter*oz22;

    vec3 dx23 = Pfx + jitter*ox23;
    vec3 dy23 = Pfy.y + jitter*oy23;
    vec3 dz23 = Pfz.z + jitter*oz23;

    vec3 dx31 = Pfx + jitter*ox31;
    vec3 dy31 = Pfy.z + jitter*oy31;
    vec3 dz31 = Pfz.x + jitter*oz31;

    vec3 dx32 = Pfx + jitter*ox32;
    vec3 dy32 = Pfy.z + jitter*oy32;
    vec3 dz32 = Pfz.y + jitter*oz32;

    vec3 dx33 = Pfx + jitter*ox33;
    vec3 dy33 = Pfy.z + jitter*oy33;
    vec3 dz33 = Pfz.z + jitter*oz33;

    vec3 d11 = dist(dx11, dy11, dz11, manhattanDistance);
    vec3 d12 =dist(dx12, dy12, dz12, manhattanDistance);
    vec3 d13 = dist(dx13, dy13, dz13, manhattanDistance);
    vec3 d21 = dist(dx21, dy21, dz21, manhattanDistance);
    vec3 d22 = dist(dx22, dy22, dz22, manhattanDistance);
    vec3 d23 = dist(dx23, dy23, dz23, manhattanDistance);
    vec3 d31 = dist(dx31, dy31, dz31, manhattanDistance);
    vec3 d32 = dist(dx32, dy32, dz32, manhattanDistance);
    vec3 d33 = dist(dx33, dy33, dz33, manhattanDistance);

    vec3 d1a = min(d11, d12);
    d12 = max(d11, d12);
    d11 = min(d1a, d13); // Smallest now not in d12 or d13
    d13 = max(d1a, d13);
    d12 = min(d12, d13); // 2nd smallest now not in d13
    vec3 d2a = min(d21, d22);
    d22 = max(d21, d22);
    d21 = min(d2a, d23); // Smallest now not in d22 or d23
    d23 = max(d2a, d23);
    d22 = min(d22, d23); // 2nd smallest now not in d23
    vec3 d3a = min(d31, d32);
    d32 = max(d31, d32);
    d31 = min(d3a, d33); // Smallest now not in d32 or d33
    d33 = max(d3a, d33);
    d32 = min(d32, d33); // 2nd smallest now not in d33
    vec3 da = min(d11, d21);
    d21 = max(d11, d21);
    d11 = min(da, d31); // Smallest now in d11
    d31 = max(da, d31); // 2nd smallest now not in d31
    d11.xy = (d11.x < d11.y) ? d11.xy : d11.yx;
    d11.xz = (d11.x < d11.z) ? d11.xz : d11.zx; // d11.x now smallest
    d12 = min(d12, d21); // 2nd smallest now not in d21
    d12 = min(d12, d22); // nor in d22
    d12 = min(d12, d31); // nor in d31
    d12 = min(d12, d32); // nor in d32
    d11.yz = min(d11.yz,d12.xy); // nor in d12.yz
    d11.y = min(d11.y,d12.z); // Only two more to go
    d11.y = min(d11.y,d11.z); // Done! (Phew!)
    return sqrt(d11.xy); // F1, F2
}

`, "// Worley3D");
          var i = e._getFreeVariableName("worleyTemp");
          return e.compilationString += "vec2 ".concat(i, " = worley(").concat(this.seed.associatedVariableName, ", ").concat(this.jitter.associatedVariableName, ", ").concat(this.manhattanDistance, `);
`), this.output.hasEndpoints && (e.compilationString += this._declareOutput(this.output, e) + " = ".concat(i, `;
`)), this.x.hasEndpoints && (e.compilationString += this._declareOutput(this.x, e) + " = ".concat(i, `.x;
`)), this.y.hasEndpoints && (e.compilationString += this._declareOutput(this.y, e) + " = ".concat(i, `.y;
`)), this;
        }
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".manhattanDistance = ").concat(this.manhattanDistance, `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.manhattanDistance = this.manhattanDistance, e;
      }, t.prototype._deserialize = function(e, i, r) {
        n.prototype._deserialize.call(this, e, i, r), this.manhattanDistance = e.manhattanDistance;
      }, x([qe("Use Manhattan Distance", Ye.Boolean, "PROPERTIES", { notifiers: { update: !1 } })], t.prototype, "manhattanDistance", void 0), t;
    }(We);
    j("BABYLON.WorleyNoise3DBlock", cT);
    var uT = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("seed", M.Vector3), i.registerOutput("output", M.Float), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "SimplexPerlin3DBlock";
      }, Object.defineProperty(t.prototype, "seed", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        if (n.prototype._buildBlock.call(this, e), this.seed.isConnected && this._outputs[0].hasEndpoints)
          return e._emitFunction("SimplexPerlin3D", `const float SKEWFACTOR = 1.0/3.0;
const float UNSKEWFACTOR = 1.0/6.0;
const float SIMPLEX_CORNER_POS = 0.5;
const float SIMPLEX_TETRAHADRON_HEIGHT = 0.70710678118654752440084436210485;
float SimplexPerlin3D( vec3 P ){
    P.x = P == vec3(0., 0., 0.) ? 0.00001 : P.x;
    P *= SIMPLEX_TETRAHADRON_HEIGHT;
    vec3 Pi = floor( P + dot( P, vec3( SKEWFACTOR) ) );    vec3 x0 = P - Pi + dot(Pi, vec3( UNSKEWFACTOR ) );
    vec3 g = step(x0.yzx, x0.xyz);
    vec3 l = 1.0 - g;
    vec3 Pi_1 = min( g.xyz, l.zxy );
    vec3 Pi_2 = max( g.xyz, l.zxy );
    vec3 x1 = x0 - Pi_1 + UNSKEWFACTOR;
    vec3 x2 = x0 - Pi_2 + SKEWFACTOR;
    vec3 x3 = x0 - SIMPLEX_CORNER_POS;
    vec4 v1234_x = vec4( x0.x, x1.x, x2.x, x3.x );
    vec4 v1234_y = vec4( x0.y, x1.y, x2.y, x3.y );
    vec4 v1234_z = vec4( x0.z, x1.z, x2.z, x3.z );
    Pi.xyz = Pi.xyz - floor(Pi.xyz * ( 1.0 / 69.0 )) * 69.0;
    vec3 Pi_inc1 = step( Pi, vec3( 69.0 - 1.5 ) ) * ( Pi + 1.0 );
    vec4 Pt = vec4( Pi.xy, Pi_inc1.xy ) + vec2( 50.0, 161.0 ).xyxy;
    Pt *= Pt;
    vec4 V1xy_V2xy = mix( Pt.xyxy, Pt.zwzw, vec4( Pi_1.xy, Pi_2.xy ) );
    Pt = vec4( Pt.x, V1xy_V2xy.xz, Pt.z ) * vec4( Pt.y, V1xy_V2xy.yw, Pt.w );
    const vec3 SOMELARGEFLOATS = vec3( 635.298681, 682.357502, 668.926525 );
    const vec3 ZINC = vec3( 48.500388, 65.294118, 63.934599 );
    vec3 lowz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi.zzz * ZINC.xyz ) );
    vec3 highz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi_inc1.zzz * ZINC.xyz ) );
    Pi_1 = ( Pi_1.z < 0.5 ) ? lowz_mods : highz_mods;
    Pi_2 = ( Pi_2.z < 0.5 ) ? lowz_mods : highz_mods;
    vec4 hash_0 = fract( Pt * vec4( lowz_mods.x, Pi_1.x, Pi_2.x, highz_mods.x ) ) - 0.49999;
    vec4 hash_1 = fract( Pt * vec4( lowz_mods.y, Pi_1.y, Pi_2.y, highz_mods.y ) ) - 0.49999;
    vec4 hash_2 = fract( Pt * vec4( lowz_mods.z, Pi_1.z, Pi_2.z, highz_mods.z ) ) - 0.49999;
    vec4 grad_results = inversesqrt( hash_0 * hash_0 + hash_1 * hash_1 + hash_2 * hash_2 ) * ( hash_0 * v1234_x + hash_1 * v1234_y + hash_2 * v1234_z );
    const float FINAL_NORMALIZATION = 37.837227241611314102871574478976;
    vec4 kernel_weights = v1234_x * v1234_x + v1234_y * v1234_y + v1234_z * v1234_z;
    kernel_weights = max(0.5 - kernel_weights, 0.0);
    kernel_weights = kernel_weights*kernel_weights*kernel_weights;
    return dot( kernel_weights, grad_results ) * FINAL_NORMALIZATION;
}
`, "// SimplexPerlin3D"), e.compilationString += this._declareOutput(this._outputs[0], e) + " = SimplexPerlin3D(".concat(this.seed.associatedVariableName, `);
`), this;
      }, t;
    }(We);
    j("BABYLON.SimplexPerlin3DBlock", uT);
    var hT = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("normalMap0", M.AutoDetect), i.registerInput("normalMap1", M.AutoDetect), i.registerOutput("output", M.Vector3), i._inputs[0].addExcludedConnectionPointFromAllowedTypes(M.Color3 | M.Color4 | M.Vector3 | M.Vector4), i._inputs[1].addExcludedConnectionPointFromAllowedTypes(M.Color3 | M.Color4 | M.Vector3 | M.Vector4), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "NormalBlendBlock";
      }, Object.defineProperty(t.prototype, "normalMap0", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "normalMap1", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0], r = this._inputs[0], o = this._inputs[1], a = e._getFreeVariableName("stepR"), s = e._getFreeVariableName("stepG");
        return e.compilationString += "float ".concat(a, " = step(0.5, ").concat(r.associatedVariableName, `.r);
`), e.compilationString += "float ".concat(s, " = step(0.5, ").concat(r.associatedVariableName, `.g);
`), e.compilationString += this._declareOutput(i, e) + `;
`, e.compilationString += "".concat(i.associatedVariableName, ".r = (1.0 - ").concat(a, ") * ").concat(r.associatedVariableName, ".r * ").concat(o.associatedVariableName, ".r * 2.0 + ").concat(a, " * (1.0 - (1.0 - ").concat(r.associatedVariableName, ".r) * (1.0 - ").concat(o.associatedVariableName, `.r) * 2.0);
`), e.compilationString += "".concat(i.associatedVariableName, ".g = (1.0 - ").concat(s, ") * ").concat(r.associatedVariableName, ".g * ").concat(o.associatedVariableName, ".g * 2.0 + ").concat(s, " * (1.0 - (1.0 - ").concat(r.associatedVariableName, ".g) * (1.0 - ").concat(o.associatedVariableName, `.g) * 2.0);
`), e.compilationString += "".concat(i.associatedVariableName, ".b = ").concat(r.associatedVariableName, ".b * ").concat(o.associatedVariableName, `.b;
`), this;
      }, t;
    }(We);
    j("BABYLON.NormalBlendBlock", hT);
    var dT = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("input", M.Vector2), i.registerInput("angle", M.Float), i.registerOutput("output", M.Vector2), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "Rotate2dBlock";
      }, Object.defineProperty(t.prototype, "input", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "angle", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function() {
        if (!this.angle.isConnected) {
          var e = new vt("angle");
          e.value = 0, e.output.connectTo(this.angle);
        }
      }, t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0], r = this.angle, o = this.input;
        return e.compilationString += this._declareOutput(i, e) + " = vec2(cos(".concat(r.associatedVariableName, ") * ").concat(o.associatedVariableName, ".x - sin(").concat(r.associatedVariableName, ") * ").concat(o.associatedVariableName, ".y, sin(").concat(r.associatedVariableName, ") * ").concat(o.associatedVariableName, ".x + cos(").concat(r.associatedVariableName, ") * ").concat(o.associatedVariableName, `.y);
`), this;
      }, t;
    }(We);
    j("BABYLON.Rotate2dBlock", dT);
    var pT = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("incident", M.AutoDetect), i.registerInput("normal", M.AutoDetect), i.registerOutput("output", M.Vector3), i._inputs[0].addExcludedConnectionPointFromAllowedTypes(M.Vector3 | M.Vector4 | M.Color3 | M.Color4), i._inputs[1].addExcludedConnectionPointFromAllowedTypes(M.Vector3 | M.Vector4 | M.Color3 | M.Color4), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ReflectBlock";
      }, Object.defineProperty(t.prototype, "incident", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "normal", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        return e.compilationString += this._declareOutput(i, e) + " = reflect(".concat(this.incident.associatedVariableName, ".xyz, ").concat(this.normal.associatedVariableName, `.xyz);
`), this;
      }, t;
    }(We);
    j("BABYLON.ReflectBlock", pT);
    var fT = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("incident", M.AutoDetect), i.registerInput("normal", M.AutoDetect), i.registerInput("ior", M.Float), i.registerOutput("output", M.Vector3), i._inputs[0].addExcludedConnectionPointFromAllowedTypes(M.Vector3 | M.Vector4 | M.Color3 | M.Color4), i._inputs[1].addExcludedConnectionPointFromAllowedTypes(M.Vector3 | M.Vector4 | M.Color3 | M.Color4), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "RefractBlock";
      }, Object.defineProperty(t.prototype, "incident", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "normal", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "ior", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        return e.compilationString += this._declareOutput(i, e) + " = refract(".concat(this.incident.associatedVariableName, ".xyz, ").concat(this.normal.associatedVariableName, ".xyz, ").concat(this.ior.associatedVariableName, `);
`), this;
      }, t;
    }(We);
    j("BABYLON.RefractBlock", fT);
    var _T = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("color", M.Color3), i.registerInput("level", M.Float), i.registerOutput("output", M.Color3), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "DesaturateBlock";
      }, Object.defineProperty(t.prototype, "color", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "level", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0], r = this.color.associatedVariableName, o = e._getFreeVariableName("colorMin"), a = e._getFreeVariableName("colorMax"), s = e._getFreeVariableName("colorMerge");
        return e.compilationString += "float ".concat(o, " = min(min(").concat(r, ".x, ").concat(r, ".y), ").concat(r, `.z);
`), e.compilationString += "float ".concat(a, " = max(max(").concat(r, ".x, ").concat(r, ".y), ").concat(r, `.z);
`), e.compilationString += "float ".concat(s, " = 0.5 * (").concat(o, " + ").concat(a, `);
`), e.compilationString += this._declareOutput(i, e) + " = mix(".concat(r, ", vec3(").concat(s, ", ").concat(s, ", ").concat(s, "), ").concat(this.level.associatedVariableName, `);
`), this;
      }, t;
    }(We);
    j("BABYLON.DesaturateBlock", _T);
    var B_ = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Fragment) || this;
        return i.albedoScaling = !1, i.linkSheenWithAlbedo = !1, i._isUnique = !0, i.registerInput("intensity", M.Float, !0, W.Fragment), i.registerInput("color", M.Color3, !0, W.Fragment), i.registerInput("roughness", M.Float, !0, W.Fragment), i.registerOutput("sheen", M.Object, W.Fragment, new xi("sheen", i, ui.Output, t, "SheenBlock")), i;
      }
      return D(t, n), t.prototype.initialize = function(e) {
        e._excludeVariableName("sheenOut"), e._excludeVariableName("sheenMapData"), e._excludeVariableName("vSheenColor"), e._excludeVariableName("vSheenRoughness");
      }, t.prototype.getClassName = function() {
        return "SheenBlock";
      }, Object.defineProperty(t.prototype, "intensity", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "color", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "roughness", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "sheen", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.prepareDefines = function(e, i, r) {
        n.prototype.prepareDefines.call(this, e, i, r), r.setValue("SHEEN", !0), r.setValue("SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE", !0, !0), r.setValue("SHEEN_LINKWITHALBEDO", this.linkSheenWithAlbedo, !0), r.setValue("SHEEN_ROUGHNESS", this.roughness.isConnected, !0), r.setValue("SHEEN_ALBEDOSCALING", this.albedoScaling, !0);
      }, t.prototype.getCode = function(e) {
        var i = this.color.isConnected ? this.color.associatedVariableName : "vec3(1.)", r = this.intensity.isConnected ? this.intensity.associatedVariableName : "1.", o = this.roughness.isConnected ? this.roughness.associatedVariableName : "0.";
        return `#ifdef SHEEN
            sheenOutParams sheenOut;

            vec4 vSheenColor = vec4(`.concat(i, ", ").concat(r, `);

            sheenBlock(
                vSheenColor,
            #ifdef SHEEN_ROUGHNESS
                `).concat(o, `,
            #endif
                roughness,
            #ifdef SHEEN_TEXTURE
                `).concat("vec4(0.)", `,
                1.0,
            #endif
                reflectance,
            #ifdef SHEEN_LINKWITHALBEDO
                baseColor,
                surfaceAlbedo,
            #endif
            #ifdef ENVIRONMENTBRDF
                NdotV,
                environmentBrdf,
            #endif
            #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
                AARoughnessFactors,
                `).concat(e == null ? void 0 : e._vReflectionMicrosurfaceInfosName, `,
                `).concat(e == null ? void 0 : e._vReflectionInfosName, `,
                `).concat(e == null ? void 0 : e.reflectionColor, `,
                vLightingIntensity,
                #ifdef `).concat(e == null ? void 0 : e._define3DName, `
                    `).concat(e == null ? void 0 : e._cubeSamplerName, `,
                #else
                    `).concat(e == null ? void 0 : e._2DSamplerName, `,
                #endif
                reflectionOut.reflectionCoords,
                NdotVUnclamped,
                #ifndef LODBASEDMICROSFURACE
                    #ifdef `).concat(e == null ? void 0 : e._define3DName, `
                        `).concat(e == null ? void 0 : e._cubeSamplerName, `,
                        `).concat(e == null ? void 0 : e._cubeSamplerName, `,
                    #else
                        `).concat(e == null ? void 0 : e._2DSamplerName, `,
                        `).concat(e == null ? void 0 : e._2DSamplerName, `,
                    #endif
                #endif
                #if !defined(`).concat(e == null ? void 0 : e._defineSkyboxName, `) && defined(RADIANCEOCCLUSION)
                    seo,
                #endif
                #if !defined(`).concat(e == null ? void 0 : e._defineSkyboxName, ") && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(").concat(e == null ? void 0 : e._define3DName, `)
                    eho,
                #endif
            #endif
                sheenOut
            );

            #ifdef SHEEN_LINKWITHALBEDO
                surfaceAlbedo = sheenOut.surfaceAlbedo;
            #endif
        #endif
`);
      }, t.prototype._buildBlock = function(e) {
        return e.target === W.Fragment && e.sharedData.blocksWithDefines.push(this), this;
      }, t.prototype._dumpPropertiesCode = function() {
        var e = n.prototype._dumpPropertiesCode.call(this);
        return (e += "".concat(this._codeVariableName, ".albedoScaling = ").concat(this.albedoScaling, `;
`)) + "".concat(this._codeVariableName, ".linkSheenWithAlbedo = ").concat(this.linkSheenWithAlbedo, `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.albedoScaling = this.albedoScaling, e.linkSheenWithAlbedo = this.linkSheenWithAlbedo, e;
      }, t.prototype._deserialize = function(e, i, r) {
        n.prototype._deserialize.call(this, e, i, r), this.albedoScaling = e.albedoScaling, this.linkSheenWithAlbedo = e.linkSheenWithAlbedo;
      }, x([qe("Albedo scaling", Ye.Boolean, "PROPERTIES", { notifiers: { update: !0 } })], t.prototype, "albedoScaling", void 0), x([qe("Link sheen with albedo", Ye.Boolean, "PROPERTIES", { notifiers: { update: !0 } })], t.prototype, "linkSheenWithAlbedo", void 0), t;
    }(We);
    j("BABYLON.SheenBlock", B_);
    var U_ = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Fragment) || this;
        return i._tangentCorrectionFactorName = "", i._isUnique = !0, i.registerInput("intensity", M.Float, !0, W.Fragment), i.registerInput("direction", M.Vector2, !0, W.Fragment), i.registerInput("uv", M.Vector2, !0), i.registerInput("worldTangent", M.Vector4, !0), i.registerInput("TBN", M.Object, !0, W.VertexAndFragment, new xi("TBN", i, ui.Input, su, "TBNBlock")), i.registerInput("roughness", M.Float, !0, W.Fragment), i.registerOutput("anisotropy", M.Object, W.Fragment, new xi("anisotropy", i, ui.Output, t, "AnisotropyBlock")), i;
      }
      return D(t, n), t.prototype.initialize = function(e) {
        e._excludeVariableName("anisotropicOut"), e._excludeVariableName("TBN");
      }, t.prototype.getClassName = function() {
        return "AnisotropyBlock";
      }, Object.defineProperty(t.prototype, "intensity", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "direction", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "uv", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldTangent", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "TBN", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "roughness", { get: function() {
        return this._inputs[5];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "anisotropy", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._generateTBNSpace = function(e) {
        var i = "", r = "//".concat(this.name), o = this.uv, a = this.worldPositionConnectionPoint, s = this.worldNormalConnectionPoint, l = this.worldTangent;
        o.isConnected || console.error("You must connect the 'uv' input of the Anisotropy block!"), e._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable");
        var c = { search: /defined\(TANGENT\)/g, replace: l.isConnected ? "defined(TANGENT)" : "defined(IGNORE)" }, u = this.TBN;
        return u.isConnected ? e.compilationString += `
            #ifdef TBNBLOCK
            mat3 vTBN = `.concat(u.associatedVariableName, `;
            #endif
            `) : l.isConnected && (i += "vec3 tbnNormal = normalize(".concat(s.associatedVariableName, `.xyz);
`), i += "vec3 tbnTangent = normalize(".concat(l.associatedVariableName, `.xyz);
`), i += "vec3 tbnBitangent = cross(tbnNormal, tbnTangent) * ".concat(this._tangentCorrectionFactorName, `;
`), i += `mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);
`), i += `
            #if defined(`.concat(l.isConnected ? "TANGENT" : "IGNORE", `) && defined(NORMAL)
                mat3 TBN = vTBN;
            #else
                mat3 TBN = cotangent_frame(`).concat(s.associatedVariableName + ".xyz", ", ").concat("v_" + a.associatedVariableName + ".xyz", ", ").concat(o.isConnected ? o.associatedVariableName : "vec2(0.)", `, vec2(1., 1.));
            #endif
`), e._emitFunctionFromInclude("bumpFragmentMainFunctions", r, { replaceStrings: [c] }), i;
      }, t.prototype.getCode = function(e, i) {
        i === void 0 && (i = !1);
        var r = "";
        i && (r += this._generateTBNSpace(e));
        var o = this.intensity.isConnected ? this.intensity.associatedVariableName : "1.0", a = this.direction.isConnected ? this.direction.associatedVariableName : "vec2(1., 0.)", s = this.roughness.isConnected ? this.roughness.associatedVariableName : "0.";
        return r + `anisotropicOutParams anisotropicOut;
            anisotropicBlock(
                vec3(`.concat(a, ", ").concat(o, `),
                `).concat(s, `,
            #ifdef ANISOTROPIC_TEXTURE
                vec3(0.),
            #endif
                TBN,
                normalW,
                viewDirectionW,
                anisotropicOut
            );
`);
      }, t.prototype.prepareDefines = function(e, i, r) {
        n.prototype.prepareDefines.call(this, e, i, r), r.setValue("ANISOTROPIC", !0), r.setValue("ANISOTROPIC_TEXTURE", !1, !0), r.setValue("ANISOTROPIC_LEGACY", !this.roughness.isConnected);
      }, t.prototype.bind = function(e, i, r) {
        n.prototype.bind.call(this, e, i, r), r && e.setFloat(this._tangentCorrectionFactorName, r.getWorldMatrix().determinant() < 0 ? -1 : 1);
      }, t.prototype._buildBlock = function(e) {
        return e.target === W.Fragment && (e.sharedData.blocksWithDefines.push(this), e.sharedData.bindableBlocks.push(this), this._tangentCorrectionFactorName = e._getFreeDefineName("tangentCorrectionFactor"), e._emitUniformFromString(this._tangentCorrectionFactorName, "float")), this;
      }, t;
    }(We);
    j("BABYLON.AnisotropyBlock", U_);
    var V_ = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.useSphericalHarmonics = !0, i.forceIrradianceInFragment = !1, i._isUnique = !0, i.registerInput("position", M.AutoDetect, !1, W.Vertex), i.registerInput("world", M.Matrix, !1, W.Vertex), i.registerInput("color", M.Color3, !0, W.Fragment), i.registerOutput("reflection", M.Object, W.Fragment, new xi("reflection", i, ui.Output, t, "ReflectionBlock")), i.position.addExcludedConnectionPointFromAllowedTypes(M.Color3 | M.Vector3 | M.Vector4), i;
      }
      return D(t, n), t.prototype._onGenerateOnlyFragmentCodeChanged = function() {
        return this.position.isConnected ? (this.generateOnlyFragmentCode = !this.generateOnlyFragmentCode, console.error("The position input must not be connected to be able to switch!"), !1) : (this._setTarget(), !0);
      }, t.prototype._setTarget = function() {
        n.prototype._setTarget.call(this), this.getInputByName("position").target = this.generateOnlyFragmentCode ? W.Fragment : W.Vertex, this.generateOnlyFragmentCode && (this.forceIrradianceInFragment = !0);
      }, t.prototype.getClassName = function() {
        return "ReflectionBlock";
      }, Object.defineProperty(t.prototype, "position", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldPosition", { get: function() {
        return this.worldPositionConnectionPoint;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldNormal", { get: function() {
        return this.worldNormalConnectionPoint;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "world", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraPosition", { get: function() {
        return this.cameraPositionConnectionPoint;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "view", { get: function() {
        return this.viewConnectionPoint;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "color", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "reflection", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hasTexture", { get: function() {
        return !!this._getTexture();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "reflectionColor", { get: function() {
        return this.color.isConnected ? this.color.associatedVariableName : "vec3(1., 1., 1.)";
      }, enumerable: !1, configurable: !0 }), t.prototype._getTexture = function() {
        return this.texture ? this.texture : this._scene.environmentTexture;
      }, t.prototype.prepareDefines = function(e, i, r) {
        n.prototype.prepareDefines.call(this, e, i, r);
        var o = this._getTexture(), a = o && o.getTextureMatrix;
        r.setValue("REFLECTION", a, !0), a && (r.setValue(this._defineLODReflectionAlpha, o.lodLevelInAlpha, !0), r.setValue(this._defineLinearSpecularReflection, o.linearSpecularLOD, !0), r.setValue(this._defineOppositeZ, this._scene.useRightHandedSystem ? !o.invertZ : o.invertZ, !0), r.setValue("SPHERICAL_HARMONICS", this.useSphericalHarmonics, !0), r.setValue("GAMMAREFLECTION", o.gammaSpace, !0), r.setValue("RGBDREFLECTION", o.isRGBD, !0), o && o.coordinatesMode !== ae.SKYBOX_MODE && o.isCube && (r.setValue("USESPHERICALFROMREFLECTIONMAP", !0), r.setValue("USEIRRADIANCEMAP", !1), this.forceIrradianceInFragment || this._scene.getEngine().getCaps().maxVaryingVectors <= 8 ? r.setValue("USESPHERICALINVERTEX", !1) : r.setValue("USESPHERICALINVERTEX", !0)));
      }, t.prototype.bind = function(e, i, r, o) {
        n.prototype.bind.call(this, e, i, r);
        var a = this._getTexture();
        if (a && o) {
          a.isCube ? e.setTexture(this._cubeSamplerName, a) : e.setTexture(this._2DSamplerName, a);
          var s = a.getSize().width;
          e.setFloat3(this._vReflectionMicrosurfaceInfosName, s, a.lodGenerationScale, a.lodGenerationOffset), e.setFloat2(this._vReflectionFilteringInfoName, s, ue.Log2(s));
          var l = o.materialDefines, c = a.sphericalPolynomial;
          if (l.USESPHERICALFROMREFLECTIONMAP && c)
            if (l.SPHERICAL_HARMONICS) {
              var u = c.preScaledHarmonics;
              e.setVector3("vSphericalL00", u.l00), e.setVector3("vSphericalL1_1", u.l1_1), e.setVector3("vSphericalL10", u.l10), e.setVector3("vSphericalL11", u.l11), e.setVector3("vSphericalL2_2", u.l2_2), e.setVector3("vSphericalL2_1", u.l2_1), e.setVector3("vSphericalL20", u.l20), e.setVector3("vSphericalL21", u.l21), e.setVector3("vSphericalL22", u.l22);
            } else
              e.setFloat3("vSphericalX", c.x.x, c.x.y, c.x.z), e.setFloat3("vSphericalY", c.y.x, c.y.y, c.y.z), e.setFloat3("vSphericalZ", c.z.x, c.z.y, c.z.z), e.setFloat3("vSphericalXX_ZZ", c.xx.x - c.zz.x, c.xx.y - c.zz.y, c.xx.z - c.zz.z), e.setFloat3("vSphericalYY_ZZ", c.yy.x - c.zz.x, c.yy.y - c.zz.y, c.yy.z - c.zz.z), e.setFloat3("vSphericalZZ", c.zz.x, c.zz.y, c.zz.z), e.setFloat3("vSphericalXY", c.xy.x, c.xy.y, c.xy.z), e.setFloat3("vSphericalYZ", c.yz.x, c.yz.y, c.yz.z), e.setFloat3("vSphericalZX", c.zx.x, c.zx.y, c.zx.z);
        }
      }, t.prototype.handleVertexSide = function(e) {
        var i = n.prototype.handleVertexSide.call(this, e);
        e._emitFunctionFromInclude("harmonicsFunctions", "//".concat(this.name), { replaceStrings: [{ search: /uniform vec3 vSphericalL00;[\s\S]*?uniform vec3 vSphericalL22;/g, replace: "" }, { search: /uniform vec3 vSphericalX;[\s\S]*?uniform vec3 vSphericalZX;/g, replace: "" }] });
        var r = e._getFreeVariableName("reflectionVector");
        return this._vEnvironmentIrradianceName = e._getFreeVariableName("vEnvironmentIrradiance"), e._emitVaryingFromString(this._vEnvironmentIrradianceName, "vec3", "defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)"), e._emitUniformFromString("vSphericalL00", "vec3", "SPHERICAL_HARMONICS"), e._emitUniformFromString("vSphericalL1_1", "vec3", "SPHERICAL_HARMONICS"), e._emitUniformFromString("vSphericalL10", "vec3", "SPHERICAL_HARMONICS"), e._emitUniformFromString("vSphericalL11", "vec3", "SPHERICAL_HARMONICS"), e._emitUniformFromString("vSphericalL2_2", "vec3", "SPHERICAL_HARMONICS"), e._emitUniformFromString("vSphericalL2_1", "vec3", "SPHERICAL_HARMONICS"), e._emitUniformFromString("vSphericalL20", "vec3", "SPHERICAL_HARMONICS"), e._emitUniformFromString("vSphericalL21", "vec3", "SPHERICAL_HARMONICS"), e._emitUniformFromString("vSphericalL22", "vec3", "SPHERICAL_HARMONICS"), e._emitUniformFromString("vSphericalX", "vec3", "SPHERICAL_HARMONICS", !0), e._emitUniformFromString("vSphericalY", "vec3", "SPHERICAL_HARMONICS", !0), e._emitUniformFromString("vSphericalZ", "vec3", "SPHERICAL_HARMONICS", !0), e._emitUniformFromString("vSphericalXX_ZZ", "vec3", "SPHERICAL_HARMONICS", !0), e._emitUniformFromString("vSphericalYY_ZZ", "vec3", "SPHERICAL_HARMONICS", !0), e._emitUniformFromString("vSphericalZZ", "vec3", "SPHERICAL_HARMONICS", !0), e._emitUniformFromString("vSphericalXY", "vec3", "SPHERICAL_HARMONICS", !0), e._emitUniformFromString("vSphericalYZ", "vec3", "SPHERICAL_HARMONICS", !0), e._emitUniformFromString("vSphericalZX", "vec3", "SPHERICAL_HARMONICS", !0), i + `#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
                vec3 `.concat(r, " = vec3(").concat(this._reflectionMatrixName, " * vec4(normalize(").concat(this.worldNormal.associatedVariableName, `).xyz, 0)).xyz;
                #ifdef `).concat(this._defineOppositeZ, `
                    `).concat(r, `.z *= -1.0;
                #endif
                `).concat(this._vEnvironmentIrradianceName, " = computeEnvironmentIrradiance(").concat(r, `);
            #endif
`);
      }, t.prototype.getCode = function(e, i) {
        var r = "";
        this.handleFragmentSideInits(e), e._emitFunctionFromInclude("harmonicsFunctions", "//".concat(this.name), { replaceStrings: [{ search: /uniform vec3 vSphericalL00;[\s\S]*?uniform vec3 vSphericalL22;/g, replace: "" }, { search: /uniform vec3 vSphericalX;[\s\S]*?uniform vec3 vSphericalZX;/g, replace: "" }] }), e._emitFunction("sampleReflection", `
            #ifdef `.concat(this._define3DName, `
                #define sampleReflection(s, c) textureCube(s, c)
            #else
                #define sampleReflection(s, c) texture2D(s, c)
            #endif
`), "//".concat(this.name)), e._emitFunction("sampleReflectionLod", `
            #ifdef `.concat(this._define3DName, `
                #define sampleReflectionLod(s, c, l) textureCubeLodEXT(s, c, l)
            #else
                #define sampleReflectionLod(s, c, l) texture2DLodEXT(s, c, l)
            #endif
`), "//".concat(this.name));
        var o = `
            vec3 computeReflectionCoordsPBR(vec4 worldPos, vec3 worldNormal) {
                `.concat(this.handleFragmentSideCodeReflectionCoords("worldNormal", "worldPos", !0, !0), `
                return `).concat(this._reflectionVectorName, `;
            }
`);
        return e._emitFunction("computeReflectionCoordsPBR", o, "//".concat(this.name)), this._vReflectionMicrosurfaceInfosName = e._getFreeVariableName("vReflectionMicrosurfaceInfos"), e._emitUniformFromString(this._vReflectionMicrosurfaceInfosName, "vec3"), this._vReflectionInfosName = e._getFreeVariableName("vReflectionInfos"), this._vReflectionFilteringInfoName = e._getFreeVariableName("vReflectionFilteringInfo"), e._emitUniformFromString(this._vReflectionFilteringInfoName, "vec2"), r + `#ifdef REFLECTION
            vec2 `.concat(this._vReflectionInfosName, ` = vec2(1., 0.);

            reflectionOutParams reflectionOut;

            reflectionBlock(
                `).concat(this.generateOnlyFragmentCode ? this._worldPositionNameInFragmentOnlyMode : "v_" + this.worldPosition.associatedVariableName, `.xyz,
                `).concat(i, `,
                alphaG,
                `).concat(this._vReflectionMicrosurfaceInfosName, `,
                `).concat(this._vReflectionInfosName, `,
                `).concat(this.reflectionColor, `,
            #ifdef ANISOTROPIC
                anisotropicOut,
            #endif
            #if defined(`).concat(this._defineLODReflectionAlpha, ") && !defined(").concat(this._defineSkyboxName, `)
                NdotVUnclamped,
            #endif
            #ifdef `).concat(this._defineLinearSpecularReflection, `
                roughness,
            #endif
            #ifdef `).concat(this._define3DName, `
                `).concat(this._cubeSamplerName, `,
            #else
                `).concat(this._2DSamplerName, `,
            #endif
            #if defined(NORMAL) && defined(USESPHERICALINVERTEX)
                `).concat(this._vEnvironmentIrradianceName, `,
            #endif
            #ifdef USESPHERICALFROMREFLECTIONMAP
                #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
                    `).concat(this._reflectionMatrixName, `,
                #endif
            #endif
            #ifdef USEIRRADIANCEMAP
                irradianceSampler, // ** not handled **
            #endif
            #ifndef LODBASEDMICROSFURACE
                #ifdef `).concat(this._define3DName, `
                    `).concat(this._cubeSamplerName, `,
                    `).concat(this._cubeSamplerName, `,
                #else
                    `).concat(this._2DSamplerName, `,
                    `).concat(this._2DSamplerName, `,
                #endif
            #endif
            #ifdef REALTIME_FILTERING
                `).concat(this._vReflectionFilteringInfoName, `,
            #endif
                reflectionOut
            );
        #endif
`);
      }, t.prototype._buildBlock = function(e) {
        return this._scene = e.sharedData.scene, e.target !== W.Fragment && (this._defineLODReflectionAlpha = e._getFreeDefineName("LODINREFLECTIONALPHA"), this._defineLinearSpecularReflection = e._getFreeDefineName("LINEARSPECULARREFLECTION")), this;
      }, t.prototype._dumpPropertiesCode = function() {
        var e = n.prototype._dumpPropertiesCode.call(this);
        return this.texture && (e += "".concat(this._codeVariableName, ".texture.gammaSpace = ").concat(this.texture.gammaSpace, `;
`)), (e += "".concat(this._codeVariableName, ".useSphericalHarmonics = ").concat(this.useSphericalHarmonics, `;
`)) + "".concat(this._codeVariableName, ".forceIrradianceInFragment = ").concat(this.forceIrradianceInFragment, `;
`);
      }, t.prototype.serialize = function() {
        var e, i, r = n.prototype.serialize.call(this);
        return r.useSphericalHarmonics = this.useSphericalHarmonics, r.forceIrradianceInFragment = this.forceIrradianceInFragment, r.gammaSpace = (i = (e = this.texture) === null || e === void 0 ? void 0 : e.gammaSpace) === null || i === void 0 || i, r;
      }, t.prototype._deserialize = function(e, i, r) {
        n.prototype._deserialize.call(this, e, i, r), this.useSphericalHarmonics = e.useSphericalHarmonics, this.forceIrradianceInFragment = e.forceIrradianceInFragment, this.texture && (this.texture.gammaSpace = e.gammaSpace);
      }, x([qe("Spherical Harmonics", Ye.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "useSphericalHarmonics", void 0), x([qe("Force irradiance in fragment", Ye.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "forceIrradianceInFragment", void 0), t;
    }(Cb);
    j("BABYLON.ReflectionBlock", V_);
    var sd = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Fragment) || this;
        return i._tangentCorrectionFactorName = "", i.remapF0OnInterfaceChange = !0, i._isUnique = !0, i.registerInput("intensity", M.Float, !1, W.Fragment), i.registerInput("roughness", M.Float, !0, W.Fragment), i.registerInput("indexOfRefraction", M.Float, !0, W.Fragment), i.registerInput("normalMapColor", M.Color3, !0, W.Fragment), i.registerInput("uv", M.Vector2, !0, W.Fragment), i.registerInput("tintColor", M.Color3, !0, W.Fragment), i.registerInput("tintAtDistance", M.Float, !0, W.Fragment), i.registerInput("tintThickness", M.Float, !0, W.Fragment), i.registerInput("worldTangent", M.Vector4, !0), i.registerInput("worldNormal", M.AutoDetect, !0), i.worldNormal.addExcludedConnectionPointFromAllowedTypes(M.Color4 | M.Vector4 | M.Vector3), i.registerInput("TBN", M.Object, !0, W.VertexAndFragment, new xi("TBN", i, ui.Input, su, "TBNBlock")), i.registerOutput("clearcoat", M.Object, W.Fragment, new xi("clearcoat", i, ui.Output, t, "ClearCoatBlock")), i;
      }
      return D(t, n), t.prototype.initialize = function(e) {
        e._excludeVariableName("clearcoatOut"), e._excludeVariableName("vClearCoatParams"), e._excludeVariableName("vClearCoatTintParams"), e._excludeVariableName("vClearCoatRefractionParams"), e._excludeVariableName("vClearCoatTangentSpaceParams"), e._excludeVariableName("vGeometricNormaClearCoatW");
      }, t.prototype.getClassName = function() {
        return "ClearCoatBlock";
      }, Object.defineProperty(t.prototype, "intensity", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "roughness", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "indexOfRefraction", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "normalMapColor", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "uv", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tintColor", { get: function() {
        return this._inputs[5];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tintAtDistance", { get: function() {
        return this._inputs[6];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tintThickness", { get: function() {
        return this._inputs[7];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldTangent", { get: function() {
        return this._inputs[8];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldNormal", { get: function() {
        return this._inputs[9];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "TBN", { get: function() {
        return this._inputs[10];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "clearcoat", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function() {
        if (!this.intensity.isConnected) {
          var e = new vt("ClearCoat intensity", W.Fragment, M.Float);
          e.value = 1, e.output.connectTo(this.intensity);
        }
      }, t.prototype.prepareDefines = function(e, i, r) {
        n.prototype.prepareDefines.call(this, e, i, r), r.setValue("CLEARCOAT", !0), r.setValue("CLEARCOAT_TEXTURE", !1, !0), r.setValue("CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE", !0, !0), r.setValue("CLEARCOAT_TINT", this.tintColor.isConnected || this.tintThickness.isConnected || this.tintAtDistance.isConnected, !0), r.setValue("CLEARCOAT_BUMP", this.normalMapColor.isConnected, !0), r.setValue("CLEARCOAT_DEFAULTIOR", !this.indexOfRefraction.isConnected || this.indexOfRefraction.connectInputBlock.value === Kc._DefaultIndexOfRefraction, !0), r.setValue("CLEARCOAT_REMAP_F0", this.remapF0OnInterfaceChange, !0);
      }, t.prototype.bind = function(e, i, r) {
        var o, a;
        n.prototype.bind.call(this, e, i, r);
        var s = (a = (o = this.indexOfRefraction.connectInputBlock) === null || o === void 0 ? void 0 : o.value) !== null && a !== void 0 ? a : Kc._DefaultIndexOfRefraction, l = 1 - s, c = 1 + s, u = Math.pow(-l / c, 2), h = 1 / s;
        e.setFloat4("vClearCoatRefractionParams", u, h, l, c);
        var d = this.clearcoat.hasEndpoints ? this.clearcoat.endpoints[0].ownerBlock : null, p = d != null && d.perturbedNormal.isConnected ? d.perturbedNormal.connectedPoint.ownerBlock : null;
        this._scene._mirroredCameraPosition ? e.setFloat2("vClearCoatTangentSpaceParams", p != null && p.invertX ? 1 : -1, p != null && p.invertY ? 1 : -1) : e.setFloat2("vClearCoatTangentSpaceParams", p != null && p.invertX ? -1 : 1, p != null && p.invertY ? -1 : 1), r && e.setFloat(this._tangentCorrectionFactorName, r.getWorldMatrix().determinant() < 0 ? -1 : 1);
      }, t.prototype._generateTBNSpace = function(e, i, r) {
        var o = "", a = "//".concat(this.name), s = this.worldTangent;
        e._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable");
        var l = { search: /defined\(TANGENT\)/g, replace: s.isConnected ? "defined(TANGENT)" : "defined(IGNORE)" }, c = this.TBN;
        return c.isConnected ? e.compilationString += `
            #ifdef TBNBLOCK
            mat3 vTBN = `.concat(c.associatedVariableName, `;
            #endif
            `) : s.isConnected && (o += "vec3 tbnNormal = normalize(".concat(r, `.xyz);
`), o += "vec3 tbnTangent = normalize(".concat(s.associatedVariableName, `.xyz);
`), o += "vec3 tbnBitangent = cross(tbnNormal, tbnTangent) * ".concat(this._tangentCorrectionFactorName, `;
`), o += `mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);
`), e._emitFunctionFromInclude("bumpFragmentMainFunctions", a, { replaceStrings: [l] }), o;
      }, t.GetCode = function(e, i, r, o, a, s, l) {
        var c = "", u = i != null && i.intensity.isConnected ? i.intensity.associatedVariableName : "1.", h = i != null && i.roughness.isConnected ? i.roughness.associatedVariableName : "0.", d = i != null && i.normalMapColor.isConnected ? i.normalMapColor.associatedVariableName : "vec3(0.)", p = i != null && i.uv.isConnected ? i.uv.associatedVariableName : "vec2(0.)", f = i != null && i.tintColor.isConnected ? i.tintColor.associatedVariableName : "vec3(1.)", m = i != null && i.tintThickness.isConnected ? i.tintThickness.associatedVariableName : "1.", g = i != null && i.tintAtDistance.isConnected ? i.tintAtDistance.associatedVariableName : "1.";
        if (i) {
          e._emitUniformFromString("vClearCoatRefractionParams", "vec4"), e._emitUniformFromString("vClearCoatTangentSpaceParams", "vec2");
          var y = i.worldNormal;
          c += "vec3 vGeometricNormaClearCoatW = ".concat(y.isConnected ? "normalize(" + y.associatedVariableName + ".xyz)" : "geometricNormalW", `;
`);
        } else
          c += `vec3 vGeometricNormaClearCoatW = geometricNormalW;
`;
        return a && i && (c += i._generateTBNSpace(e, o, l), s = i.worldTangent.isConnected), c + `clearcoatOutParams clearcoatOut;

        #ifdef CLEARCOAT
            vec2 vClearCoatParams = vec2(`.concat(u, ", ").concat(h, `);
            vec4 vClearCoatTintParams = vec4(`).concat(f, ", ").concat(m, `);

            clearcoatBlock(
                `).concat(o, `.xyz,
                vGeometricNormaClearCoatW,
                viewDirectionW,
                vClearCoatParams,
                specularEnvironmentR0,
            #ifdef CLEARCOAT_TEXTURE
                vec2(0.),
            #endif
            #ifdef CLEARCOAT_TINT
                vClearCoatTintParams,
                `).concat(g, `,
                vClearCoatRefractionParams,
                #ifdef CLEARCOAT_TINT_TEXTURE
                    `).concat("vec4(0.)", `,
                #endif
            #endif
            #ifdef CLEARCOAT_BUMP
                vec2(0., 1.),
                vec4(`).concat(d, `, 0.),
                `).concat(p, `,
                #if defined(`).concat(s ? "TANGENT" : "IGNORE", `) && defined(NORMAL)
                    vTBN,
                #else
                    vClearCoatTangentSpaceParams,
                #endif
                #ifdef OBJECTSPACE_NORMALMAP
                    normalMatrix,
                #endif
            #endif
            #if defined(FORCENORMALFORWARD) && defined(NORMAL)
                faceNormal,
            #endif
            #ifdef REFLECTION
                `).concat(r == null ? void 0 : r._vReflectionMicrosurfaceInfosName, `,
                `).concat(r == null ? void 0 : r._vReflectionInfosName, `,
                `).concat(r == null ? void 0 : r.reflectionColor, `,
                vLightingIntensity,
                #ifdef `).concat(r == null ? void 0 : r._define3DName, `
                    `).concat(r == null ? void 0 : r._cubeSamplerName, `,
                #else
                    `).concat(r == null ? void 0 : r._2DSamplerName, `,
                #endif
                #ifndef LODBASEDMICROSFURACE
                    #ifdef `).concat(r == null ? void 0 : r._define3DName, `
                        `).concat(r == null ? void 0 : r._cubeSamplerName, `,
                        `).concat(r == null ? void 0 : r._cubeSamplerName, `,
                    #else
                        `).concat(r == null ? void 0 : r._2DSamplerName, `,
                        `).concat(r == null ? void 0 : r._2DSamplerName, `,
                    #endif
                #endif
            #endif
            #if defined(ENVIRONMENTBRDF) && !defined(`).concat(r == null ? void 0 : r._defineSkyboxName, `)
                #ifdef RADIANCEOCCLUSION
                    ambientMonochrome,
                #endif
            #endif
            #if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
                (gl_FrontFacing ? 1. : -1.),
            #endif
                clearcoatOut
            );
        #else
            clearcoatOut.specularEnvironmentR0 = specularEnvironmentR0;
        #endif
`);
      }, t.prototype._buildBlock = function(e) {
        return this._scene = e.sharedData.scene, e.target === W.Fragment && (e.sharedData.bindableBlocks.push(this), e.sharedData.blocksWithDefines.push(this), this._tangentCorrectionFactorName = e._getFreeDefineName("tangentCorrectionFactor"), e._emitUniformFromString(this._tangentCorrectionFactorName, "float")), this;
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".remapF0OnInterfaceChange = ").concat(this.remapF0OnInterfaceChange, `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.remapF0OnInterfaceChange = this.remapF0OnInterfaceChange, e;
      }, t.prototype._deserialize = function(e, i, r) {
        var o;
        n.prototype._deserialize.call(this, e, i, r), this.remapF0OnInterfaceChange = (o = e.remapF0OnInterfaceChange) === null || o === void 0 || o;
      }, x([qe("Remap F0 on interface change", Ye.Boolean, "ADVANCED")], t.prototype, "remapF0OnInterfaceChange", void 0), t;
    }(We);
    j("BABYLON.ClearCoatBlock", sd);
    var mT = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Fragment) || this;
        return i._isUnique = !0, i.registerInput("intensity", M.Float, !0, W.Fragment), i.registerInput("indexOfRefraction", M.Float, !0, W.Fragment), i.registerInput("thickness", M.Float, !0, W.Fragment), i.registerOutput("iridescence", M.Object, W.Fragment, new xi("iridescence", i, ui.Output, t, "IridescenceBlock")), i;
      }
      return D(t, n), t.prototype.initialize = function(e) {
        e._excludeVariableName("iridescenceOut"), e._excludeVariableName("vIridescenceParams");
      }, t.prototype.getClassName = function() {
        return "IridescenceBlock";
      }, Object.defineProperty(t.prototype, "intensity", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "indexOfRefraction", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "thickness", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "iridescence", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function() {
        if (!this.intensity.isConnected) {
          var e = new vt("Iridescence intensity", W.Fragment, M.Float);
          e.value = 1, e.output.connectTo(this.intensity);
          var i = new vt("Iridescence ior", W.Fragment, M.Float);
          i.value = 1.3, i.output.connectTo(this.indexOfRefraction);
          var r = new vt("Iridescence thickness", W.Fragment, M.Float);
          r.value = 400, r.output.connectTo(this.thickness);
        }
      }, t.prototype.prepareDefines = function(e, i, r) {
        n.prototype.prepareDefines.call(this, e, i, r), r.setValue("IRIDESCENCE", !0, !0), r.setValue("IRIDESCENCE_TEXTURE", !1, !0), r.setValue("IRIDESCENCE_THICKNESS_TEXTURE", !1, !0);
      }, t.GetCode = function(e) {
        var i = "", r = e != null && e.intensity.isConnected ? e.intensity.associatedVariableName : "1.", o = e != null && e.indexOfRefraction.isConnected ? e.indexOfRefraction.associatedVariableName : qc._DefaultIndexOfRefraction, a = e != null && e.thickness.isConnected ? e.thickness.associatedVariableName : qc._DefaultMaximumThickness;
        return i + `iridescenceOutParams iridescenceOut;

        #ifdef IRIDESCENCE
            iridescenceBlock(
                vec4(`.concat(r, ", ").concat(o, ", 1., ").concat(a, `),
                NdotV,
                specularEnvironmentR0,
                #ifdef CLEARCOAT
                    NdotVUnclamped,
                #endif
                iridescenceOut
            );

            float iridescenceIntensity = iridescenceOut.iridescenceIntensity;
            specularEnvironmentR0 = iridescenceOut.specularEnvironmentR0;
        #endif
`);
      }, t.prototype._buildBlock = function(e) {
        return e.target === W.Fragment && (e.sharedData.bindableBlocks.push(this), e.sharedData.blocksWithDefines.push(this)), this;
      }, t.prototype.serialize = function() {
        return n.prototype.serialize.call(this);
      }, t.prototype._deserialize = function(e, i, r) {
        n.prototype._deserialize.call(this, e, i, r);
      }, t;
    }(We);
    j("BABYLON.IridescenceBlock", mT);
    var k_ = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Fragment) || this;
        return i.linkRefractionWithTransparency = !1, i.invertRefractionY = !1, i.useThicknessAsDepth = !1, i._isUnique = !0, i.registerInput("intensity", M.Float, !1, W.Fragment), i.registerInput("tintAtDistance", M.Float, !0, W.Fragment), i.registerInput("volumeIndexOfRefraction", M.Float, !0, W.Fragment), i.registerOutput("refraction", M.Object, W.Fragment, new xi("refraction", i, ui.Output, t, "RefractionBlock")), i;
      }
      return D(t, n), t.prototype.initialize = function(e) {
        e._excludeVariableName("vRefractionPosition"), e._excludeVariableName("vRefractionSize");
      }, t.prototype.getClassName = function() {
        return "RefractionBlock";
      }, Object.defineProperty(t.prototype, "intensity", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tintAtDistance", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "volumeIndexOfRefraction", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "view", { get: function() {
        return this.viewConnectionPoint;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "refraction", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hasTexture", { get: function() {
        return !!this._getTexture();
      }, enumerable: !1, configurable: !0 }), t.prototype._getTexture = function() {
        return this.texture ? this.texture : this._scene.environmentTexture;
      }, t.prototype.autoConfigure = function(e, i) {
        if (i === void 0 && (i = function() {
          return !0;
        }), !this.intensity.isConnected) {
          var r = new vt("Refraction intensity", W.Fragment, M.Float);
          r.value = 1, r.output.connectTo(this.intensity);
        }
        if (this.view && !this.view.isConnected) {
          var o = e.getInputBlockByPredicate(function(a) {
            return a.systemValue === Tt.View && i(a);
          });
          o || (o = new vt("view")).setAsSystemValue(Tt.View), o.output.connectTo(this.view);
        }
      }, t.prototype.prepareDefines = function(e, i, r) {
        n.prototype.prepareDefines.call(this, e, i, r);
        var o = this._getTexture(), a = o && o.getTextureMatrix;
        r.setValue("SS_REFRACTION", a, !0), a && (r.setValue(this._define3DName, o.isCube, !0), r.setValue(this._defineLODRefractionAlpha, o.lodLevelInAlpha, !0), r.setValue(this._defineLinearSpecularRefraction, o.linearSpecularLOD, !0), r.setValue(this._defineOppositeZ, this._scene.useRightHandedSystem && o.isCube ? !o.invertZ : o.invertZ, !0), r.setValue("SS_LINKREFRACTIONTOTRANSPARENCY", this.linkRefractionWithTransparency, !0), r.setValue("SS_GAMMAREFRACTION", o.gammaSpace, !0), r.setValue("SS_RGBDREFRACTION", o.isRGBD, !0), r.setValue("SS_USE_LOCAL_REFRACTIONMAP_CUBIC", !!o.boundingBoxSize, !0), r.setValue("SS_USE_THICKNESS_AS_DEPTH", this.useThicknessAsDepth, !0));
      }, t.prototype.isReady = function() {
        var e = this._getTexture();
        return !(e && !e.isReadyOrNotBlocking());
      }, t.prototype.bind = function(e, i, r) {
        var o, a, s, l;
        n.prototype.bind.call(this, e, i, r);
        var c = this._getTexture();
        if (c) {
          c.isCube ? e.setTexture(this._cubeSamplerName, c) : e.setTexture(this._2DSamplerName, c), e.setMatrix(this._refractionMatrixName, c.getRefractionTextureMatrix());
          var u = 1;
          c.isCube || c.depth && (u = c.depth);
          var h = (l = (a = (o = this.volumeIndexOfRefraction.connectInputBlock) === null || o === void 0 ? void 0 : o.value) !== null && a !== void 0 ? a : (s = this.indexOfRefractionConnectionPoint.connectInputBlock) === null || s === void 0 ? void 0 : s.value) !== null && l !== void 0 ? l : 1.5;
          e.setFloat4(this._vRefractionInfosName, c.level, 1 / h, u, this.invertRefractionY ? -1 : 1), e.setFloat4(this._vRefractionMicrosurfaceInfosName, c.getSize().width, c.lodGenerationScale, c.lodGenerationOffset, 1 / h);
          var d = c.getSize().width;
          if (e.setFloat2(this._vRefractionFilteringInfoName, d, ue.Log2(d)), c.boundingBoxSize) {
            var p = c;
            e.setVector3("vRefractionPosition", p.boundingBoxPosition), e.setVector3("vRefractionSize", p.boundingBoxSize);
          }
        }
      }, t.prototype.getCode = function(e) {
        return e.sharedData.blockingBlocks.push(this), e.sharedData.textureBlocks.push(this), this._cubeSamplerName = e._getFreeVariableName(this.name + "CubeSampler"), e.samplers.push(this._cubeSamplerName), this._2DSamplerName = e._getFreeVariableName(this.name + "2DSampler"), e.samplers.push(this._2DSamplerName), this._define3DName = e._getFreeDefineName("SS_REFRACTIONMAP_3D"), e._samplerDeclaration += "#ifdef ".concat(this._define3DName, `
`), e._samplerDeclaration += "uniform samplerCube ".concat(this._cubeSamplerName, `;
`), e._samplerDeclaration += `#else
`, e._samplerDeclaration += "uniform sampler2D ".concat(this._2DSamplerName, `;
`), e._samplerDeclaration += `#endif
`, e.sharedData.blocksWithDefines.push(this), e.sharedData.bindableBlocks.push(this), this._defineLODRefractionAlpha = e._getFreeDefineName("SS_LODINREFRACTIONALPHA"), this._defineLinearSpecularRefraction = e._getFreeDefineName("SS_LINEARSPECULARREFRACTION"), this._defineOppositeZ = e._getFreeDefineName("SS_REFRACTIONMAP_OPPOSITEZ"), this._refractionMatrixName = e._getFreeVariableName("refractionMatrix"), e._emitUniformFromString(this._refractionMatrixName, "mat4"), e._emitFunction("sampleRefraction", `
            #ifdef `.concat(this._define3DName, `
                #define sampleRefraction(s, c) textureCube(s, c)
            #else
                #define sampleRefraction(s, c) texture2D(s, c)
            #endif
`), "//".concat(this.name)), e._emitFunction("sampleRefractionLod", `
            #ifdef `.concat(this._define3DName, `
                #define sampleRefractionLod(s, c, l) textureCubeLodEXT(s, c, l)
            #else
                #define sampleRefractionLod(s, c, l) texture2DLodEXT(s, c, l)
            #endif
`), "//".concat(this.name)), this._vRefractionMicrosurfaceInfosName = e._getFreeVariableName("vRefractionMicrosurfaceInfos"), e._emitUniformFromString(this._vRefractionMicrosurfaceInfosName, "vec4"), this._vRefractionInfosName = e._getFreeVariableName("vRefractionInfos"), e._emitUniformFromString(this._vRefractionInfosName, "vec4"), this._vRefractionFilteringInfoName = e._getFreeVariableName("vRefractionFilteringInfo"), e._emitUniformFromString(this._vRefractionFilteringInfoName, "vec2"), e._emitUniformFromString("vRefractionPosition", "vec3"), e._emitUniformFromString("vRefractionSize", "vec3"), "";
      }, t.prototype._buildBlock = function(e) {
        return this._scene = e.sharedData.scene, this;
      }, t.prototype._dumpPropertiesCode = function() {
        var e = n.prototype._dumpPropertiesCode.call(this);
        return this.texture && (e = this.texture.isCube ? "".concat(this._codeVariableName, '.texture = new BABYLON.CubeTexture("').concat(this.texture.name, `");
`) : "".concat(this._codeVariableName, '.texture = new BABYLON.Texture("').concat(this.texture.name, `");
`), e += "".concat(this._codeVariableName, ".texture.coordinatesMode = ").concat(this.texture.coordinatesMode, `;
`)), e += "".concat(this._codeVariableName, ".linkRefractionWithTransparency = ").concat(this.linkRefractionWithTransparency, `;
`), (e += "".concat(this._codeVariableName, ".invertRefractionY = ").concat(this.invertRefractionY, `;
`)) + "".concat(this._codeVariableName, ".useThicknessAsDepth = ").concat(this.useThicknessAsDepth, `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return this.texture && !this.texture.isRenderTarget && (e.texture = this.texture.serialize()), e.linkRefractionWithTransparency = this.linkRefractionWithTransparency, e.invertRefractionY = this.invertRefractionY, e.useThicknessAsDepth = this.useThicknessAsDepth, e;
      }, t.prototype._deserialize = function(e, i, r) {
        n.prototype._deserialize.call(this, e, i, r), e.texture && (r = e.texture.url.indexOf("data:") === 0 ? "" : r, e.texture.isCube ? this.texture = Gr.Parse(e.texture, i, r) : this.texture = ae.Parse(e.texture, i, r)), this.linkRefractionWithTransparency = e.linkRefractionWithTransparency, this.invertRefractionY = e.invertRefractionY, this.useThicknessAsDepth = !!e.useThicknessAsDepth;
      }, x([qe("Link refraction to transparency", Ye.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "linkRefractionWithTransparency", void 0), x([qe("Invert refraction Y", Ye.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "invertRefractionY", void 0), x([qe("Use thickness as depth", Ye.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "useThicknessAsDepth", void 0), t;
    }(We);
    j("BABYLON.RefractionBlock", k_);
    var ld = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Fragment) || this;
        return i._isUnique = !0, i.registerInput("thickness", M.Float, !1, W.Fragment), i.registerInput("tintColor", M.Color3, !0, W.Fragment), i.registerInput("translucencyIntensity", M.Float, !0, W.Fragment), i.registerInput("translucencyDiffusionDist", M.Color3, !0, W.Fragment), i.registerInput("refraction", M.Object, !0, W.Fragment, new xi("refraction", i, ui.Input, k_, "RefractionBlock")), i.registerOutput("subsurface", M.Object, W.Fragment, new xi("subsurface", i, ui.Output, t, "SubSurfaceBlock")), i;
      }
      return D(t, n), t.prototype.initialize = function(e) {
        e._excludeVariableName("subSurfaceOut"), e._excludeVariableName("vThicknessParam"), e._excludeVariableName("vTintColor"), e._excludeVariableName("vSubSurfaceIntensity");
      }, t.prototype.getClassName = function() {
        return "SubSurfaceBlock";
      }, Object.defineProperty(t.prototype, "thickness", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tintColor", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "translucencyIntensity", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "translucencyDiffusionDist", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "refraction", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subsurface", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function() {
        if (!this.thickness.isConnected) {
          var e = new vt("SubSurface thickness", W.Fragment, M.Float);
          e.value = 0, e.output.connectTo(this.thickness);
        }
      }, t.prototype.prepareDefines = function(e, i, r) {
        n.prototype.prepareDefines.call(this, e, i, r);
        var o = this.translucencyDiffusionDist.isConnected || this.translucencyIntensity.isConnected;
        r.setValue("SUBSURFACE", o || this.refraction.isConnected, !0), r.setValue("SS_TRANSLUCENCY", o, !0), r.setValue("SS_THICKNESSANDMASK_TEXTURE", !1, !0), r.setValue("SS_REFRACTIONINTENSITY_TEXTURE", !1, !0), r.setValue("SS_TRANSLUCENCYINTENSITY_TEXTURE", !1, !0), r.setValue("SS_MASK_FROM_THICKNESS_TEXTURE", !1, !0), r.setValue("SS_USE_GLTF_TEXTURES", !1, !0);
      }, t.GetCode = function(e, i, r, o) {
        var a, s, l, c, u, h, d, p, f, m, g, y, b, T, S, E, A = "", R = i != null && i.thickness.isConnected ? i.thickness.associatedVariableName : "0.", C = i != null && i.tintColor.isConnected ? i.tintColor.associatedVariableName : "vec3(1.)", L = i != null && i.translucencyIntensity.isConnected ? i == null ? void 0 : i.translucencyIntensity.associatedVariableName : "1.", I = i != null && i.translucencyDiffusionDist.isConnected ? i == null ? void 0 : i.translucencyDiffusionDist.associatedVariableName : "vec3(1.)", O = i != null && i.refraction.isConnected ? (a = i == null ? void 0 : i.refraction.connectedPoint) === null || a === void 0 ? void 0 : a.ownerBlock : null, w = O != null && O.tintAtDistance.isConnected ? O.tintAtDistance.associatedVariableName : "1.", z = O != null && O.intensity.isConnected ? O.intensity.associatedVariableName : "1.", V = O != null && O.view.isConnected ? O.view.associatedVariableName : "";
        return (A += (s = O == null ? void 0 : O.getCode(e)) !== null && s !== void 0 ? s : "") + `subSurfaceOutParams subSurfaceOut;

        #ifdef SUBSURFACE
            vec2 vThicknessParam = vec2(0., `.concat(R, `);
            vec4 vTintColor = vec4(`).concat(C, ", ").concat(w, `);
            vec3 vSubSurfaceIntensity = vec3(`).concat(z, ", ").concat(L, `, 0.);

            subSurfaceBlock(
                vSubSurfaceIntensity,
                vThicknessParam,
                vTintColor,
                normalW,
                specularEnvironmentReflectance,
            #ifdef SS_THICKNESSANDMASK_TEXTURE
                vec4(0.),
            #endif
            #ifdef REFLECTION
                #ifdef SS_TRANSLUCENCY
                    `).concat(r == null ? void 0 : r._reflectionMatrixName, `,
                    #ifdef USESPHERICALFROMREFLECTIONMAP
                        #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
                            reflectionOut.irradianceVector,
                        #endif
                        #if defined(REALTIME_FILTERING)
                            `).concat(r == null ? void 0 : r._cubeSamplerName, `,
                            `).concat(r == null ? void 0 : r._vReflectionFilteringInfoName, `,
                        #endif
                        #endif
                    #ifdef USEIRRADIANCEMAP
                        irradianceSampler,
                    #endif
                #endif
            #endif
            #if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)
                surfaceAlbedo,
            #endif
            #ifdef SS_REFRACTION
                `).concat(o, `.xyz,
                viewDirectionW,
                `).concat(V, `,
                `).concat((l = O == null ? void 0 : O._vRefractionInfosName) !== null && l !== void 0 ? l : "", `,
                `).concat((c = O == null ? void 0 : O._refractionMatrixName) !== null && c !== void 0 ? c : "", `,
                `).concat((u = O == null ? void 0 : O._vRefractionMicrosurfaceInfosName) !== null && u !== void 0 ? u : "", `,
                vLightingIntensity,
                #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
                    alpha,
                #endif
                #ifdef `).concat((h = O == null ? void 0 : O._defineLODRefractionAlpha) !== null && h !== void 0 ? h : "IGNORE", `
                    NdotVUnclamped,
                #endif
                #ifdef `).concat((d = O == null ? void 0 : O._defineLinearSpecularRefraction) !== null && d !== void 0 ? d : "IGNORE", `
                    roughness,
                #endif
                alphaG,
                #ifdef `).concat((p = O == null ? void 0 : O._define3DName) !== null && p !== void 0 ? p : "IGNORE", `
                    `).concat((f = O == null ? void 0 : O._cubeSamplerName) !== null && f !== void 0 ? f : "", `,
                #else
                    `).concat((m = O == null ? void 0 : O._2DSamplerName) !== null && m !== void 0 ? m : "", `,
                #endif
                #ifndef LODBASEDMICROSFURACE
                    #ifdef `).concat((g = O == null ? void 0 : O._define3DName) !== null && g !== void 0 ? g : "IGNORE", `
                        `).concat((y = O == null ? void 0 : O._cubeSamplerName) !== null && y !== void 0 ? y : "", `,
                        `).concat((b = O == null ? void 0 : O._cubeSamplerName) !== null && b !== void 0 ? b : "", `,
                    #else
                        `).concat((T = O == null ? void 0 : O._2DSamplerName) !== null && T !== void 0 ? T : "", `,
                        `).concat((S = O == null ? void 0 : O._2DSamplerName) !== null && S !== void 0 ? S : "", `,
                    #endif
                #endif
                #ifdef ANISOTROPIC
                    anisotropicOut,
                #endif
                #ifdef REALTIME_FILTERING
                    `).concat((E = O == null ? void 0 : O._vRefractionFilteringInfoName) !== null && E !== void 0 ? E : "", `,
                #endif
                #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
                    vRefractionPosition,
                    vRefractionSize,
                #endif
            #endif
            #ifdef SS_TRANSLUCENCY
                `).concat(I, `,
            #endif
                subSurfaceOut
            );

            #ifdef SS_REFRACTION
                surfaceAlbedo = subSurfaceOut.surfaceAlbedo;
                #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
                    alpha = subSurfaceOut.alpha;
                #endif
            #endif
        #else
            subSurfaceOut.specularEnvironmentReflectance = specularEnvironmentReflectance;
        #endif
`);
      }, t.prototype._buildBlock = function(e) {
        return e.target === W.Fragment && e.sharedData.blocksWithDefines.push(this), this;
      }, t;
    }(We);
    j("BABYLON.SubSurfaceBlock", ld);
    var lN = { ambientClr: ["finalAmbient", ""], diffuseDir: ["finalDiffuse", ""], specularDir: ["finalSpecularScaled", "!defined(UNLIT) && defined(SPECULARTERM)"], clearcoatDir: ["finalClearCoatScaled", "!defined(UNLIT) && defined(CLEARCOAT)"], sheenDir: ["finalSheenScaled", "!defined(UNLIT) && defined(SHEEN)"], diffuseInd: ["finalIrradiance", "!defined(UNLIT) && defined(REFLECTION)"], specularInd: ["finalRadianceScaled", "!defined(UNLIT) && defined(REFLECTION)"], clearcoatInd: ["clearcoatOut.finalClearCoatRadianceScaled", "!defined(UNLIT) && defined(REFLECTION) && defined(CLEARCOAT)"], sheenInd: ["sheenOut.finalSheenRadianceScaled", "!defined(UNLIT) && defined(REFLECTION) && defined(SHEEN) && defined(ENVIRONMENTBRDF)"], refraction: ["subSurfaceOut.finalRefraction", "!defined(UNLIT) && defined(SS_REFRACTION)"], lighting: ["finalColor.rgb", ""], shadow: ["aggShadow", ""], alpha: ["alpha", ""] }, gT = function(n) {
      function t(e) {
        var i = n.call(this, e, W.VertexAndFragment) || this;
        return i._environmentBRDFTexture = null, i._metallicReflectanceColor = ne.White(), i._metallicF0Factor = 1, i.directIntensity = 1, i.environmentIntensity = 1, i.specularIntensity = 1, i.lightFalloff = 0, i.useAlphaTest = !1, i.alphaTestCutoff = 0.5, i.useAlphaBlending = !1, i.useRadianceOverAlpha = !0, i.useSpecularOverAlpha = !0, i.enableSpecularAntiAliasing = !1, i.realTimeFiltering = !1, i.realTimeFilteringQuality = _.TEXTURE_FILTERING_QUALITY_LOW, i.useEnergyConservation = !0, i.useRadianceOcclusion = !0, i.useHorizonOcclusion = !0, i.unlit = !1, i.forceNormalForward = !1, i.generateOnlyFragmentCode = !1, i.debugMode = 0, i.debugLimit = 0, i.debugFactor = 1, i._isUnique = !0, i.registerInput("worldPosition", M.Vector4, !1, W.Vertex), i.registerInput("worldNormal", M.Vector4, !1, W.Fragment), i.registerInput("view", M.Matrix, !1), i.registerInput("cameraPosition", M.Vector3, !1, W.Fragment), i.registerInput("perturbedNormal", M.Vector4, !0, W.Fragment), i.registerInput("baseColor", M.Color3, !0, W.Fragment), i.registerInput("metallic", M.Float, !1, W.Fragment), i.registerInput("roughness", M.Float, !1, W.Fragment), i.registerInput("ambientOcc", M.Float, !0, W.Fragment), i.registerInput("opacity", M.Float, !0, W.Fragment), i.registerInput("indexOfRefraction", M.Float, !0, W.Fragment), i.registerInput("ambientColor", M.Color3, !0, W.Fragment), i.registerInput("reflection", M.Object, !0, W.Fragment, new xi("reflection", i, ui.Input, V_, "ReflectionBlock")), i.registerInput("clearcoat", M.Object, !0, W.Fragment, new xi("clearcoat", i, ui.Input, sd, "ClearCoatBlock")), i.registerInput("sheen", M.Object, !0, W.Fragment, new xi("sheen", i, ui.Input, B_, "SheenBlock")), i.registerInput("subsurface", M.Object, !0, W.Fragment, new xi("subsurface", i, ui.Input, ld, "SubSurfaceBlock")), i.registerInput("anisotropy", M.Object, !0, W.Fragment, new xi("anisotropy", i, ui.Input, U_, "AnisotropyBlock")), i.registerInput("iridescence", M.Object, !0, W.Fragment, new xi("iridescence", i, ui.Input, mT, "IridescenceBlock")), i.registerOutput("ambientClr", M.Color3, W.Fragment), i.registerOutput("diffuseDir", M.Color3, W.Fragment), i.registerOutput("specularDir", M.Color3, W.Fragment), i.registerOutput("clearcoatDir", M.Color3, W.Fragment), i.registerOutput("sheenDir", M.Color3, W.Fragment), i.registerOutput("diffuseInd", M.Color3, W.Fragment), i.registerOutput("specularInd", M.Color3, W.Fragment), i.registerOutput("clearcoatInd", M.Color3, W.Fragment), i.registerOutput("sheenInd", M.Color3, W.Fragment), i.registerOutput("refraction", M.Color3, W.Fragment), i.registerOutput("lighting", M.Color3, W.Fragment), i.registerOutput("shadow", M.Float, W.Fragment), i.registerOutput("alpha", M.Float, W.Fragment), i;
      }
      return D(t, n), t._OnGenerateOnlyFragmentCodeChanged = function(e, i) {
        var r = e;
        return r.worldPosition.isConnected ? (r.generateOnlyFragmentCode = !r.generateOnlyFragmentCode, console.error("The worldPosition input must not be connected to be able to switch!"), !1) : (r._setTarget(), !0);
      }, t.prototype._setTarget = function() {
        this._setInitialTarget(this.generateOnlyFragmentCode ? W.Fragment : W.VertexAndFragment), this.getInputByName("worldPosition").target = this.generateOnlyFragmentCode ? W.Fragment : W.Vertex;
      }, t.prototype.initialize = function(e) {
        e._excludeVariableName("vLightingIntensity"), e._excludeVariableName("geometricNormalW"), e._excludeVariableName("normalW"), e._excludeVariableName("faceNormal"), e._excludeVariableName("albedoOpacityOut"), e._excludeVariableName("surfaceAlbedo"), e._excludeVariableName("alpha"), e._excludeVariableName("aoOut"), e._excludeVariableName("baseColor"), e._excludeVariableName("reflectivityOut"), e._excludeVariableName("microSurface"), e._excludeVariableName("roughness"), e._excludeVariableName("NdotVUnclamped"), e._excludeVariableName("NdotV"), e._excludeVariableName("alphaG"), e._excludeVariableName("AARoughnessFactors"), e._excludeVariableName("environmentBrdf"), e._excludeVariableName("ambientMonochrome"), e._excludeVariableName("seo"), e._excludeVariableName("eho"), e._excludeVariableName("environmentRadiance"), e._excludeVariableName("irradianceVector"), e._excludeVariableName("environmentIrradiance"), e._excludeVariableName("diffuseBase"), e._excludeVariableName("specularBase"), e._excludeVariableName("preInfo"), e._excludeVariableName("info"), e._excludeVariableName("shadow"), e._excludeVariableName("finalDiffuse"), e._excludeVariableName("finalAmbient"), e._excludeVariableName("ambientOcclusionForDirectDiffuse"), e._excludeVariableName("finalColor"), e._excludeVariableName("vClipSpacePosition"), e._excludeVariableName("vDebugMode");
      }, t.prototype.getClassName = function() {
        return "PBRMetallicRoughnessBlock";
      }, Object.defineProperty(t.prototype, "worldPosition", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldNormal", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "view", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraPosition", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "perturbedNormal", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "baseColor", { get: function() {
        return this._inputs[5];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "metallic", { get: function() {
        return this._inputs[6];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "roughness", { get: function() {
        return this._inputs[7];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "ambientOcc", { get: function() {
        return this._inputs[8];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "opacity", { get: function() {
        return this._inputs[9];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "indexOfRefraction", { get: function() {
        return this._inputs[10];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "ambientColor", { get: function() {
        return this._inputs[11];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "reflection", { get: function() {
        return this._inputs[12];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "clearcoat", { get: function() {
        return this._inputs[13];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "sheen", { get: function() {
        return this._inputs[14];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subsurface", { get: function() {
        return this._inputs[15];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "anisotropy", { get: function() {
        return this._inputs[16];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "iridescence", { get: function() {
        return this._inputs[17];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "ambientClr", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "diffuseDir", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "specularDir", { get: function() {
        return this._outputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "clearcoatDir", { get: function() {
        return this._outputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "sheenDir", { get: function() {
        return this._outputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "diffuseInd", { get: function() {
        return this._outputs[5];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "specularInd", { get: function() {
        return this._outputs[6];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "clearcoatInd", { get: function() {
        return this._outputs[7];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "sheenInd", { get: function() {
        return this._outputs[8];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "refraction", { get: function() {
        return this._outputs[9];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "lighting", { get: function() {
        return this._outputs[10];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "shadow", { get: function() {
        return this._outputs[11];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "alpha", { get: function() {
        return this._outputs[12];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function(e, i) {
        if (i === void 0 && (i = function() {
          return !0;
        }), !this.cameraPosition.isConnected) {
          var r = e.getInputBlockByPredicate(function(a) {
            return a.systemValue === Tt.CameraPosition && i(a);
          });
          r || (r = new vt("cameraPosition")).setAsSystemValue(Tt.CameraPosition), r.output.connectTo(this.cameraPosition);
        }
        if (!this.view.isConnected) {
          var o = e.getInputBlockByPredicate(function(a) {
            return a.systemValue === Tt.View && i(a);
          });
          o || (o = new vt("view")).setAsSystemValue(Tt.View), o.output.connectTo(this.view);
        }
      }, t.prototype.prepareDefines = function(e, i, r) {
        r.setValue("PBR", !0), r.setValue("METALLICWORKFLOW", !0), r.setValue("DEBUGMODE", this.debugMode, !0), r.setValue("DEBUGMODE_FORCERETURN", !0), r.setValue("NORMALXYSCALE", !0), r.setValue("BUMP", this.perturbedNormal.isConnected, !0), r.setValue("LODBASEDMICROSFURACE", this._scene.getEngine().getCaps().textureLOD), r.setValue("ALBEDO", !1, !0), r.setValue("OPACITY", this.opacity.isConnected, !0), r.setValue("AMBIENT", !0, !0), r.setValue("AMBIENTINGRAYSCALE", !1, !0), r.setValue("REFLECTIVITY", !1, !0), r.setValue("AOSTOREINMETALMAPRED", !1, !0), r.setValue("METALLNESSSTOREINMETALMAPBLUE", !1, !0), r.setValue("ROUGHNESSSTOREINMETALMAPALPHA", !1, !0), r.setValue("ROUGHNESSSTOREINMETALMAPGREEN", !1, !0), this.lightFalloff === Si.LIGHTFALLOFF_STANDARD ? (r.setValue("USEPHYSICALLIGHTFALLOFF", !1), r.setValue("USEGLTFLIGHTFALLOFF", !1)) : this.lightFalloff === Si.LIGHTFALLOFF_GLTF ? (r.setValue("USEPHYSICALLIGHTFALLOFF", !1), r.setValue("USEGLTFLIGHTFALLOFF", !0)) : (r.setValue("USEPHYSICALLIGHTFALLOFF", !0), r.setValue("USEGLTFLIGHTFALLOFF", !1));
        var o = this.alphaTestCutoff.toString();
        r.setValue("ALPHABLEND", this.useAlphaBlending, !0), r.setValue("ALPHAFROMALBEDO", !1, !0), r.setValue("ALPHATEST", this.useAlphaTest, !0), r.setValue("ALPHATESTVALUE", o.indexOf(".") < 0 ? o + "." : o, !0), r.setValue("OPACITYRGB", !1, !0), r.setValue("RADIANCEOVERALPHA", this.useRadianceOverAlpha, !0), r.setValue("SPECULAROVERALPHA", this.useSpecularOverAlpha, !0), r.setValue("SPECULARAA", this._scene.getEngine().getCaps().standardDerivatives && this.enableSpecularAntiAliasing, !0), r.setValue("REALTIME_FILTERING", this.realTimeFiltering, !0);
        var a = e.getScene();
        if (a.getEngine()._features.needTypeSuffixInShaderConstants ? r.setValue("NUM_SAMPLES", this.realTimeFilteringQuality + "u", !0) : r.setValue("NUM_SAMPLES", "" + this.realTimeFilteringQuality, !0), r.setValue("BRDF_V_HEIGHT_CORRELATED", !0), r.setValue("MS_BRDF_ENERGY_CONSERVATION", this.useEnergyConservation, !0), r.setValue("RADIANCEOCCLUSION", this.useRadianceOcclusion, !0), r.setValue("HORIZONOCCLUSION", this.useHorizonOcclusion, !0), r.setValue("UNLIT", this.unlit, !0), r.setValue("FORCENORMALFORWARD", this.forceNormalForward, !0), this._environmentBRDFTexture && Pe.ReflectionTextureEnabled ? (r.setValue("ENVIRONMENTBRDF", !0), r.setValue("ENVIRONMENTBRDF_RGBD", this._environmentBRDFTexture.isRGBD, !0)) : (r.setValue("ENVIRONMENTBRDF", !1), r.setValue("ENVIRONMENTBRDF_RGBD", !1)), r._areImageProcessingDirty && i.imageProcessingConfiguration && i.imageProcessingConfiguration.prepareDefines(r), r._areLightsDirty)
          if (this.light) {
            var s = { needNormals: !1, needRebuild: !1, lightmapMode: !1, shadowEnabled: !1, specularEnabled: !1 };
            Se.PrepareDefinesForLight(a, e, this.light, this._lightId, r, !0, s), s.needRebuild && r.rebuild();
          } else
            Se.PrepareDefinesForLights(a, e, r, !0, i.maxSimultaneousLights), r._needNormals = !0, Se.PrepareDefinesForMultiview(a, r);
      }, t.prototype.updateUniformsAndSamples = function(e, i, r, o) {
        for (var a = 0; a < i.maxSimultaneousLights && r["LIGHT" + a]; a++) {
          var s = e.uniforms.indexOf("vLightData" + a) >= 0;
          Se.PrepareUniformsAndSamplersForLight(a, e.uniforms, e.samplers, r["PROJECTEDLIGHTTEXTURE" + a], o, s);
        }
      }, t.prototype.isReady = function(e, i, r) {
        return !(this._environmentBRDFTexture && !this._environmentBRDFTexture.isReady() || r._areImageProcessingDirty && i.imageProcessingConfiguration && !i.imageProcessingConfiguration.isReady());
      }, t.prototype.bind = function(e, i, r) {
        var o, a;
        if (r) {
          var s = r.getScene();
          this.light ? Se.BindLight(this.light, this._lightId, s, e, !0) : Se.BindLights(s, r, e, !0, i.maxSimultaneousLights), e.setTexture(this._environmentBrdfSamplerName, this._environmentBRDFTexture), e.setFloat2("vDebugMode", this.debugLimit, this.debugFactor);
          var l = this._scene.ambientColor;
          l && e.setColor3("ambientFromScene", l);
          var c = s.useRightHandedSystem === (s._mirroredCameraPosition != null);
          e.setFloat(this._invertNormalName, c ? -1 : 1), e.setFloat4("vLightingIntensity", this.directIntensity, 1, this.environmentIntensity * this._scene.environmentIntensity, this.specularIntensity);
          var u = (a = (o = this.indexOfRefraction.connectInputBlock) === null || o === void 0 ? void 0 : o.value) !== null && a !== void 0 ? a : 1.5, h = Math.pow((u - 1) / (u + 1), 2);
          this._metallicReflectanceColor.scaleToRef(h * this._metallicF0Factor, Ot.Color3[0]);
          var d = this._metallicF0Factor;
          e.setColor4(this._vMetallicReflectanceFactorsName, Ot.Color3[0], d), i.imageProcessingConfiguration && i.imageProcessingConfiguration.bind(e);
        }
      }, t.prototype._injectVertexCode = function(e) {
        var i, r, o = this.worldPosition, a = "//".concat(this.name);
        this.light ? (this._lightId = (e.counters.lightCounter !== void 0 ? e.counters.lightCounter : -1) + 1, e.counters.lightCounter = this._lightId, e._emitFunctionFromInclude(e.supportUniformBuffers ? "lightVxUboDeclaration" : "lightVxFragmentDeclaration", a, { replaceStrings: [{ search: /{X}/g, replace: this._lightId.toString() }] }, this._lightId.toString())) : (e._emitFunctionFromInclude(e.supportUniformBuffers ? "lightVxUboDeclaration" : "lightVxFragmentDeclaration", a, { repeatKey: "maxSimultaneousLights" }), this._lightId = 0, e.sharedData.dynamicUniformBlocks.push(this));
        var s = "v_" + o.associatedVariableName;
        e._emitVaryingFromString(s, "vec4") && (e.compilationString += "".concat(s, " = ").concat(o.associatedVariableName, `;
`));
        var l = this.reflection.isConnected ? (i = this.reflection.connectedPoint) === null || i === void 0 ? void 0 : i.ownerBlock : null;
        l && (l.viewConnectionPoint = this.view), e.compilationString += (r = l == null ? void 0 : l.handleVertexSide(e)) !== null && r !== void 0 ? r : "", e._emitVaryingFromString("vClipSpacePosition", "vec4", "defined(IGNORE) || DEBUGMODE > 0") && (e._injectAtEnd += `#if DEBUGMODE > 0
`, e._injectAtEnd += `vClipSpacePosition = gl_Position;
`, e._injectAtEnd += `#endif
`), this.light ? e.compilationString += e._emitCodeFromInclude("shadowsVertex", a, { replaceStrings: [{ search: /{X}/g, replace: this._lightId.toString() }, { search: /worldPos/g, replace: o.associatedVariableName }] }) : (e.compilationString += "vec4 worldPos = ".concat(o.associatedVariableName, `;
`), this.view.isConnected && (e.compilationString += "mat4 view = ".concat(this.view.associatedVariableName, `;
`)), e.compilationString += e._emitCodeFromInclude("shadowsVertex", a, { repeatKey: "maxSimultaneousLights" }));
      }, t.prototype._getAlbedoOpacityCode = function() {
        var e = `albedoOpacityOutParams albedoOpacityOut;
`, i = this.baseColor.isConnected ? this.baseColor.associatedVariableName : "vec3(1.)", r = this.opacity.isConnected ? this.opacity.associatedVariableName : "1.";
        return e + `albedoOpacityBlock(
                vec4(`.concat(i, `, 1.),
            #ifdef ALBEDO
                vec4(1.),
                vec2(1., 1.),
            #endif
            #ifdef OPACITY
                vec4(`).concat(r, `),
                vec2(1., 1.),
            #endif
                albedoOpacityOut
            );

            vec3 surfaceAlbedo = albedoOpacityOut.surfaceAlbedo;
            float alpha = albedoOpacityOut.alpha;
`);
      }, t.prototype._getAmbientOcclusionCode = function() {
        var e = `ambientOcclusionOutParams aoOut;
`, i = this.ambientOcc.isConnected ? this.ambientOcc.associatedVariableName : "1.";
        return e + `ambientOcclusionBlock(
            #ifdef AMBIENT
                vec3(`.concat(i, `),
                vec4(0., 1.0, 1.0, 0.),
            #endif
                aoOut
            );
`);
      }, t.prototype._getReflectivityCode = function(e) {
        var i = `reflectivityOutParams reflectivityOut;
`;
        return this._vMetallicReflectanceFactorsName = e._getFreeVariableName("vMetallicReflectanceFactors"), e._emitUniformFromString(this._vMetallicReflectanceFactorsName, "vec4"), i + `vec3 baseColor = surfaceAlbedo;

            reflectivityBlock(
                vec4(`.concat(this.metallic.associatedVariableName, ", ").concat(this.roughness.associatedVariableName, `, 0., 0.),
            #ifdef METALLICWORKFLOW
                surfaceAlbedo,
                `).concat(this._vMetallicReflectanceFactorsName, `,
            #endif
            #ifdef REFLECTIVITY
                vec3(0., 0., `).concat("1.", `),
                vec4(1.),
            #endif
            #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY)  && defined(AOSTOREINMETALMAPRED)
                aoOut.ambientOcclusionColor,
            #endif
            #ifdef MICROSURFACEMAP
                microSurfaceTexel, <== not handled!
            #endif
                reflectivityOut
            );

            float microSurface = reflectivityOut.microSurface;
            float roughness = reflectivityOut.roughness;

            #ifdef METALLICWORKFLOW
                surfaceAlbedo = reflectivityOut.surfaceAlbedo;
            #endif
            #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
                aoOut.ambientOcclusionColor = reflectivityOut.ambientOcclusionColor;
            #endif
`);
      }, t.prototype._buildBlock = function(e) {
        var i, r, o, a, s, l, c, u, h, d, p, f, m, g, y, b, T, S, E, A, R, C, L, I, O, w, z, V, Y, ee, J, X, K, te, se, _e, xe, Te, he, me, Fe;
        n.prototype._buildBlock.call(this, e), this._scene = e.sharedData.scene, this._environmentBRDFTexture || (this._environmentBRDFTexture = Yc(this._scene));
        var Ce = this.reflection.isConnected ? (i = this.reflection.connectedPoint) === null || i === void 0 ? void 0 : i.ownerBlock : null;
        if (Ce && (Ce.worldPositionConnectionPoint = this.worldPosition, Ce.cameraPositionConnectionPoint = this.cameraPosition, Ce.worldNormalConnectionPoint = this.worldNormal, Ce.viewConnectionPoint = this.view), e.target !== W.Fragment)
          return this._injectVertexCode(e), this;
        e.sharedData.forcedBindableBlocks.push(this), e.sharedData.blocksWithDefines.push(this), e.sharedData.blockingBlocks.push(this), this.generateOnlyFragmentCode && e.sharedData.dynamicUniformBlocks.push(this);
        var Re = "//".concat(this.name), Be = this.perturbedNormal, De = this.worldPosition.associatedVariableName;
        this.generateOnlyFragmentCode ? (De = e._getFreeVariableName("globalWorldPos"), e._emitFunction("pbr_globalworldpos", "vec3 ".concat(De, `;
`), Re), e.compilationString += "".concat(De, " = ").concat(this.worldPosition.associatedVariableName, `.xyz;
`), e.compilationString += e._emitCodeFromInclude("shadowsVertex", Re, { repeatKey: "maxSimultaneousLights", substitutionVars: this.generateOnlyFragmentCode ? "worldPos,".concat(this.worldPosition.associatedVariableName) : void 0 }), e.compilationString += `#if DEBUGMODE > 0
`, e.compilationString += `vec4 vClipSpacePosition = vec4((vec2(gl_FragCoord.xy) / vec2(1.0)) * 2.0 - 1.0, 0.0, 1.0);
`, e.compilationString += `#endif
`) : De = "v_" + De, this._environmentBrdfSamplerName = e._getFreeVariableName("environmentBrdfSampler"), e._emit2DSampler(this._environmentBrdfSamplerName), e.sharedData.hints.needAlphaBlending = e.sharedData.hints.needAlphaBlending || this.useAlphaBlending, e.sharedData.hints.needAlphaTesting = e.sharedData.hints.needAlphaTesting || this.useAlphaTest, e._emitExtension("lod", "#extension GL_EXT_shader_texture_lod : enable", "defined(LODBASEDMICROSFURACE)"), e._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable"), e._emitUniformFromString("vDebugMode", "vec2", "defined(IGNORE) || DEBUGMODE > 0"), e._emitUniformFromString("ambientFromScene", "vec3"), e.uniforms.push("exposureLinear"), e.uniforms.push("contrast"), e.uniforms.push("vInverseScreenSize"), e.uniforms.push("vignetteSettings1"), e.uniforms.push("vignetteSettings2"), e.uniforms.push("vCameraColorCurveNegative"), e.uniforms.push("vCameraColorCurveNeutral"), e.uniforms.push("vCameraColorCurvePositive"), e.uniforms.push("txColorTransform"), e.uniforms.push("colorTransformSettings"), e.uniforms.push("ditherIntensity"), this.light ? e._emitFunctionFromInclude(e.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", Re, { replaceStrings: [{ search: /{X}/g, replace: this._lightId.toString() }] }, this._lightId.toString()) : e._emitFunctionFromInclude(e.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", Re, { repeatKey: "maxSimultaneousLights", substitutionVars: this.generateOnlyFragmentCode ? "varying," : void 0 }), e._emitFunctionFromInclude("helperFunctions", Re), e._emitFunctionFromInclude("importanceSampling", Re), e._emitFunctionFromInclude("pbrHelperFunctions", Re), e._emitFunctionFromInclude("imageProcessingDeclaration", Re), e._emitFunctionFromInclude("imageProcessingFunctions", Re), e._emitFunctionFromInclude("shadowsFragmentFunctions", Re), e._emitFunctionFromInclude("pbrDirectLightingSetupFunctions", Re, { replaceStrings: [{ search: /vPositionW/g, replace: De + ".xyz" }] }), e._emitFunctionFromInclude("pbrDirectLightingFalloffFunctions", Re), e._emitFunctionFromInclude("pbrBRDFFunctions", Re, { replaceStrings: [{ search: /REFLECTIONMAP_SKYBOX/g, replace: (r = Ce == null ? void 0 : Ce._defineSkyboxName) !== null && r !== void 0 ? r : "REFLECTIONMAP_SKYBOX" }] }), e._emitFunctionFromInclude("hdrFilteringFunctions", Re), e._emitFunctionFromInclude("pbrDirectLightingFunctions", Re, { replaceStrings: [{ search: /vPositionW/g, replace: De + ".xyz" }] }), e._emitFunctionFromInclude("pbrIBLFunctions", Re), e._emitFunctionFromInclude("pbrBlockAlbedoOpacity", Re), e._emitFunctionFromInclude("pbrBlockReflectivity", Re), e._emitFunctionFromInclude("pbrBlockAmbientOcclusion", Re), e._emitFunctionFromInclude("pbrBlockAlphaFresnel", Re), e._emitFunctionFromInclude("pbrBlockAnisotropic", Re), e._emitUniformFromString("vLightingIntensity", "vec4"), Ce != null && Ce.generateOnlyFragmentCode && (e.compilationString += Ce.handleVertexSide(e)), this._vNormalWName = e._getFreeVariableName("vNormalW"), e.compilationString += "vec4 ".concat(this._vNormalWName, " = normalize(").concat(this.worldNormal.associatedVariableName, `);
`), e._registerTempVariable("viewDirectionW") && (e.compilationString += "vec3 viewDirectionW = normalize(".concat(this.cameraPosition.associatedVariableName, " - ").concat(De, `.xyz);
`)), e.compilationString += "vec3 geometricNormalW = ".concat(this._vNormalWName, `.xyz;
`), e.compilationString += "vec3 normalW = ".concat(Be.isConnected ? "normalize(" + Be.associatedVariableName + ".xyz)" : "geometricNormalW", `;
`), this._invertNormalName = e._getFreeVariableName("invertNormal"), e._emitUniformFromString(this._invertNormalName, "float"), e.compilationString += e._emitCodeFromInclude("pbrBlockNormalFinal", Re, { replaceStrings: [{ search: /vPositionW/g, replace: De + ".xyz" }, { search: /vEyePosition.w/g, replace: this._invertNormalName }] }), e.compilationString += this._getAlbedoOpacityCode(), e.compilationString += e._emitCodeFromInclude("depthPrePass", Re), e.compilationString += this._getAmbientOcclusionCode(), e.compilationString += e._emitCodeFromInclude("pbrBlockLightmapInit", Re), e.compilationString += `#ifdef UNLIT
                vec3 diffuseBase = vec3(1., 1., 1.);
            #else
`, e.compilationString += this._getReflectivityCode(e), e.compilationString += e._emitCodeFromInclude("pbrBlockGeometryInfo", Re, { replaceStrings: [{ search: /REFLECTIONMAP_SKYBOX/g, replace: (o = Ce == null ? void 0 : Ce._defineSkyboxName) !== null && o !== void 0 ? o : "REFLECTIONMAP_SKYBOX" }, { search: /REFLECTIONMAP_3D/g, replace: (a = Ce == null ? void 0 : Ce._define3DName) !== null && a !== void 0 ? a : "REFLECTIONMAP_3D" }] });
        var Ke = this.anisotropy.isConnected ? (s = this.anisotropy.connectedPoint) === null || s === void 0 ? void 0 : s.ownerBlock : null;
        Ke && (Ke.worldPositionConnectionPoint = this.worldPosition, Ke.worldNormalConnectionPoint = this.worldNormal, e.compilationString += Ke.getCode(e, !this.perturbedNormal.isConnected)), Ce && Ce.hasTexture && (e.compilationString += Ce.getCode(e, Ke ? "anisotropicOut.anisotropicNormal" : "normalW")), e._emitFunctionFromInclude("pbrBlockReflection", Re, { replaceStrings: [{ search: /computeReflectionCoords/g, replace: "computeReflectionCoordsPBR" }, { search: /REFLECTIONMAP_3D/g, replace: (l = Ce == null ? void 0 : Ce._define3DName) !== null && l !== void 0 ? l : "REFLECTIONMAP_3D" }, { search: /REFLECTIONMAP_OPPOSITEZ/g, replace: (c = Ce == null ? void 0 : Ce._defineOppositeZ) !== null && c !== void 0 ? c : "REFLECTIONMAP_OPPOSITEZ" }, { search: /REFLECTIONMAP_PROJECTION/g, replace: (u = Ce == null ? void 0 : Ce._defineProjectionName) !== null && u !== void 0 ? u : "REFLECTIONMAP_PROJECTION" }, { search: /REFLECTIONMAP_SKYBOX/g, replace: (h = Ce == null ? void 0 : Ce._defineSkyboxName) !== null && h !== void 0 ? h : "REFLECTIONMAP_SKYBOX" }, { search: /LODINREFLECTIONALPHA/g, replace: (d = Ce == null ? void 0 : Ce._defineLODReflectionAlpha) !== null && d !== void 0 ? d : "LODINREFLECTIONALPHA" }, { search: /LINEARSPECULARREFLECTION/g, replace: (p = Ce == null ? void 0 : Ce._defineLinearSpecularReflection) !== null && p !== void 0 ? p : "LINEARSPECULARREFLECTION" }, { search: /vReflectionFilteringInfo/g, replace: (f = Ce == null ? void 0 : Ce._vReflectionFilteringInfoName) !== null && f !== void 0 ? f : "vReflectionFilteringInfo" }] }), e.compilationString += e._emitCodeFromInclude("pbrBlockReflectance0", Re, { replaceStrings: [{ search: /metallicReflectanceFactors/g, replace: this._vMetallicReflectanceFactorsName }] });
        var ge = this.sheen.isConnected ? (m = this.sheen.connectedPoint) === null || m === void 0 ? void 0 : m.ownerBlock : null;
        ge && (e.compilationString += ge.getCode(Ce)), e._emitFunctionFromInclude("pbrBlockSheen", Re, { replaceStrings: [{ search: /REFLECTIONMAP_3D/g, replace: (g = Ce == null ? void 0 : Ce._define3DName) !== null && g !== void 0 ? g : "REFLECTIONMAP_3D" }, { search: /REFLECTIONMAP_SKYBOX/g, replace: (y = Ce == null ? void 0 : Ce._defineSkyboxName) !== null && y !== void 0 ? y : "REFLECTIONMAP_SKYBOX" }, { search: /LODINREFLECTIONALPHA/g, replace: (b = Ce == null ? void 0 : Ce._defineLODReflectionAlpha) !== null && b !== void 0 ? b : "LODINREFLECTIONALPHA" }, { search: /LINEARSPECULARREFLECTION/g, replace: (T = Ce == null ? void 0 : Ce._defineLinearSpecularReflection) !== null && T !== void 0 ? T : "LINEARSPECULARREFLECTION" }] });
        var rt = this.iridescence.isConnected ? (S = this.iridescence.connectedPoint) === null || S === void 0 ? void 0 : S.ownerBlock : null;
        e.compilationString += mT.GetCode(rt), e._emitFunctionFromInclude("pbrBlockIridescence", Re, { replaceStrings: [] });
        var it = this.clearcoat.isConnected ? (E = this.clearcoat.connectedPoint) === null || E === void 0 ? void 0 : E.ownerBlock : null, He = !this.perturbedNormal.isConnected && !this.anisotropy.isConnected, Pt = this.perturbedNormal.isConnected && ((R = ((A = this.perturbedNormal.connectedPoint) === null || A === void 0 ? void 0 : A.ownerBlock).worldTangent) === null || R === void 0 ? void 0 : R.isConnected), ke = this.anisotropy.isConnected && ((C = this.anisotropy.connectedPoint) === null || C === void 0 ? void 0 : C.ownerBlock).worldTangent.isConnected, xt = Pt || !this.perturbedNormal.isConnected && ke;
        e.compilationString += sd.GetCode(e, it, Ce, De, He, xt, this.worldNormal.associatedVariableName), He && (xt = (L = it == null ? void 0 : it.worldTangent.isConnected) !== null && L !== void 0 && L), e._emitFunctionFromInclude("pbrBlockClearcoat", Re, { replaceStrings: [{ search: /computeReflectionCoords/g, replace: "computeReflectionCoordsPBR" }, { search: /REFLECTIONMAP_3D/g, replace: (I = Ce == null ? void 0 : Ce._define3DName) !== null && I !== void 0 ? I : "REFLECTIONMAP_3D" }, { search: /REFLECTIONMAP_OPPOSITEZ/g, replace: (O = Ce == null ? void 0 : Ce._defineOppositeZ) !== null && O !== void 0 ? O : "REFLECTIONMAP_OPPOSITEZ" }, { search: /REFLECTIONMAP_PROJECTION/g, replace: (w = Ce == null ? void 0 : Ce._defineProjectionName) !== null && w !== void 0 ? w : "REFLECTIONMAP_PROJECTION" }, { search: /REFLECTIONMAP_SKYBOX/g, replace: (z = Ce == null ? void 0 : Ce._defineSkyboxName) !== null && z !== void 0 ? z : "REFLECTIONMAP_SKYBOX" }, { search: /LODINREFLECTIONALPHA/g, replace: (V = Ce == null ? void 0 : Ce._defineLODReflectionAlpha) !== null && V !== void 0 ? V : "LODINREFLECTIONALPHA" }, { search: /LINEARSPECULARREFLECTION/g, replace: (Y = Ce == null ? void 0 : Ce._defineLinearSpecularReflection) !== null && Y !== void 0 ? Y : "LINEARSPECULARREFLECTION" }, { search: /defined\(TANGENT\)/g, replace: xt ? "defined(TANGENT)" : "defined(IGNORE)" }] }), e.compilationString += e._emitCodeFromInclude("pbrBlockReflectance", Re, { replaceStrings: [{ search: /REFLECTIONMAP_SKYBOX/g, replace: (ee = Ce == null ? void 0 : Ce._defineSkyboxName) !== null && ee !== void 0 ? ee : "REFLECTIONMAP_SKYBOX" }, { search: /REFLECTIONMAP_3D/g, replace: (J = Ce == null ? void 0 : Ce._define3DName) !== null && J !== void 0 ? J : "REFLECTIONMAP_3D" }] });
        var Nt = this.subsurface.isConnected ? (X = this.subsurface.connectedPoint) === null || X === void 0 ? void 0 : X.ownerBlock : null, $e = this.subsurface.isConnected ? (te = ((K = this.subsurface.connectedPoint) === null || K === void 0 ? void 0 : K.ownerBlock).refraction.connectedPoint) === null || te === void 0 ? void 0 : te.ownerBlock : null;
        $e && ($e.viewConnectionPoint = this.view, $e.indexOfRefractionConnectionPoint = this.indexOfRefraction), e.compilationString += ld.GetCode(e, Nt, Ce, De), e._emitFunctionFromInclude("pbrBlockSubSurface", Re, { replaceStrings: [{ search: /REFLECTIONMAP_3D/g, replace: (se = Ce == null ? void 0 : Ce._define3DName) !== null && se !== void 0 ? se : "REFLECTIONMAP_3D" }, { search: /REFLECTIONMAP_OPPOSITEZ/g, replace: (_e = Ce == null ? void 0 : Ce._defineOppositeZ) !== null && _e !== void 0 ? _e : "REFLECTIONMAP_OPPOSITEZ" }, { search: /REFLECTIONMAP_PROJECTION/g, replace: (xe = Ce == null ? void 0 : Ce._defineProjectionName) !== null && xe !== void 0 ? xe : "REFLECTIONMAP_PROJECTION" }, { search: /SS_REFRACTIONMAP_3D/g, replace: (Te = $e == null ? void 0 : $e._define3DName) !== null && Te !== void 0 ? Te : "SS_REFRACTIONMAP_3D" }, { search: /SS_LODINREFRACTIONALPHA/g, replace: (he = $e == null ? void 0 : $e._defineLODRefractionAlpha) !== null && he !== void 0 ? he : "SS_LODINREFRACTIONALPHA" }, { search: /SS_LINEARSPECULARREFRACTION/g, replace: (me = $e == null ? void 0 : $e._defineLinearSpecularRefraction) !== null && me !== void 0 ? me : "SS_LINEARSPECULARREFRACTION" }, { search: /SS_REFRACTIONMAP_OPPOSITEZ/g, replace: (Fe = $e == null ? void 0 : $e._defineOppositeZ) !== null && Fe !== void 0 ? Fe : "SS_REFRACTIONMAP_OPPOSITEZ" }] }), e.compilationString += e._emitCodeFromInclude("pbrBlockDirectLighting", Re), this.light ? e.compilationString += e._emitCodeFromInclude("lightFragment", Re, { replaceStrings: [{ search: /{X}/g, replace: this._lightId.toString() }, { search: /vPositionW/g, replace: De + ".xyz" }] }) : e.compilationString += e._emitCodeFromInclude("lightFragment", Re, { repeatKey: "maxSimultaneousLights", substitutionVars: "vPositionW,".concat(De, ".xyz") }), e.compilationString += e._emitCodeFromInclude("pbrBlockFinalLitComponents", Re), e.compilationString += `#endif
`;
        var Rt = this.ambientColor.isConnected ? this.ambientColor.associatedVariableName : "vec3(0., 0., 0.)", kt = Si.DEFAULT_AO_ON_ANALYTICAL_LIGHTS.toString();
        kt.indexOf(".") === -1 && (kt += "."), e.compilationString += e._emitCodeFromInclude("pbrBlockFinalUnlitComponents", Re, { replaceStrings: [{ search: /vec3 finalEmissive[\s\S]*?finalEmissive\*=vLightingIntensity\.y;/g, replace: "" }, { search: /vAmbientColor/g, replace: Rt + " * ambientFromScene" }, { search: /vAmbientInfos\.w/g, replace: kt }] }), e.compilationString += e._emitCodeFromInclude("pbrBlockFinalColorComposition", Re, { replaceStrings: [{ search: /finalEmissive/g, replace: "vec3(0.)" }] }), e.compilationString += e._emitCodeFromInclude("pbrBlockImageProcessing", Re, { replaceStrings: [{ search: /visibility/g, replace: "1." }] }), e.compilationString += e._emitCodeFromInclude("pbrDebug", Re, { replaceStrings: [{ search: /vNormalW/g, replace: this._vNormalWName }, { search: /vPositionW/g, replace: De }, { search: /albedoTexture\.rgb;/g, replace: `vec3(1.);
gl_FragColor.rgb = toGammaSpace(gl_FragColor.rgb);
` }] });
        for (var _t = 0, Pi = this._outputs; _t < Pi.length; _t++) {
          var Hn = Pi[_t];
          if (Hn.hasEndpoints) {
            var Xr = lN[Hn.name];
            if (Xr) {
              var fo = Xr[0], Ln = Xr[1];
              Ln && (e.compilationString += "#if ".concat(Ln, `
`)), e.compilationString += "".concat(this._declareOutput(Hn, e), " = ").concat(fo, `;
`), Ln && (e.compilationString += `#else
`, e.compilationString += "".concat(this._declareOutput(Hn, e), ` = vec3(0.);
`), e.compilationString += `#endif
`);
            } else
              console.error("There's no remapping for the ".concat(Hn.name, " end point! No code generated"));
          }
        }
        return this;
      }, t.prototype._dumpPropertiesCode = function() {
        var e = n.prototype._dumpPropertiesCode.call(this);
        return e += "".concat(this._codeVariableName, ".lightFalloff = ").concat(this.lightFalloff, `;
`), e += "".concat(this._codeVariableName, ".useAlphaTest = ").concat(this.useAlphaTest, `;
`), e += "".concat(this._codeVariableName, ".alphaTestCutoff = ").concat(this.alphaTestCutoff, `;
`), e += "".concat(this._codeVariableName, ".useAlphaBlending = ").concat(this.useAlphaBlending, `;
`), e += "".concat(this._codeVariableName, ".useRadianceOverAlpha = ").concat(this.useRadianceOverAlpha, `;
`), e += "".concat(this._codeVariableName, ".useSpecularOverAlpha = ").concat(this.useSpecularOverAlpha, `;
`), e += "".concat(this._codeVariableName, ".enableSpecularAntiAliasing = ").concat(this.enableSpecularAntiAliasing, `;
`), e += "".concat(this._codeVariableName, ".realTimeFiltering = ").concat(this.realTimeFiltering, `;
`), e += "".concat(this._codeVariableName, ".realTimeFilteringQuality = ").concat(this.realTimeFilteringQuality, `;
`), e += "".concat(this._codeVariableName, ".useEnergyConservation = ").concat(this.useEnergyConservation, `;
`), e += "".concat(this._codeVariableName, ".useRadianceOcclusion = ").concat(this.useRadianceOcclusion, `;
`), e += "".concat(this._codeVariableName, ".useHorizonOcclusion = ").concat(this.useHorizonOcclusion, `;
`), e += "".concat(this._codeVariableName, ".unlit = ").concat(this.unlit, `;
`), e += "".concat(this._codeVariableName, ".forceNormalForward = ").concat(this.forceNormalForward, `;
`), e += "".concat(this._codeVariableName, ".debugMode = ").concat(this.debugMode, `;
`), (e += "".concat(this._codeVariableName, ".debugLimit = ").concat(this.debugLimit, `;
`)) + "".concat(this._codeVariableName, ".debugFactor = ").concat(this.debugFactor, `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return this.light && (e.lightId = this.light.id), e.lightFalloff = this.lightFalloff, e.useAlphaTest = this.useAlphaTest, e.alphaTestCutoff = this.alphaTestCutoff, e.useAlphaBlending = this.useAlphaBlending, e.useRadianceOverAlpha = this.useRadianceOverAlpha, e.useSpecularOverAlpha = this.useSpecularOverAlpha, e.enableSpecularAntiAliasing = this.enableSpecularAntiAliasing, e.realTimeFiltering = this.realTimeFiltering, e.realTimeFilteringQuality = this.realTimeFilteringQuality, e.useEnergyConservation = this.useEnergyConservation, e.useRadianceOcclusion = this.useRadianceOcclusion, e.useHorizonOcclusion = this.useHorizonOcclusion, e.unlit = this.unlit, e.forceNormalForward = this.forceNormalForward, e.debugMode = this.debugMode, e.debugLimit = this.debugLimit, e.debugFactor = this.debugFactor, e.generateOnlyFragmentCode = this.generateOnlyFragmentCode, e;
      }, t.prototype._deserialize = function(e, i, r) {
        var o, a;
        n.prototype._deserialize.call(this, e, i, r), e.lightId && (this.light = i.getLightById(e.lightId)), this.lightFalloff = (o = e.lightFalloff) !== null && o !== void 0 ? o : 0, this.useAlphaTest = e.useAlphaTest, this.alphaTestCutoff = e.alphaTestCutoff, this.useAlphaBlending = e.useAlphaBlending, this.useRadianceOverAlpha = e.useRadianceOverAlpha, this.useSpecularOverAlpha = e.useSpecularOverAlpha, this.enableSpecularAntiAliasing = e.enableSpecularAntiAliasing, this.realTimeFiltering = !!e.realTimeFiltering, this.realTimeFilteringQuality = (a = e.realTimeFilteringQuality) !== null && a !== void 0 ? a : _.TEXTURE_FILTERING_QUALITY_LOW, this.useEnergyConservation = e.useEnergyConservation, this.useRadianceOcclusion = e.useRadianceOcclusion, this.useHorizonOcclusion = e.useHorizonOcclusion, this.unlit = e.unlit, this.forceNormalForward = !!e.forceNormalForward, this.debugMode = e.debugMode, this.debugLimit = e.debugLimit, this.debugFactor = e.debugFactor, this.generateOnlyFragmentCode = !!e.generateOnlyFragmentCode, this._setTarget();
      }, x([qe("Direct lights", Ye.Float, "INTENSITY", { min: 0, max: 1, notifiers: { update: !0 } })], t.prototype, "directIntensity", void 0), x([qe("Environment lights", Ye.Float, "INTENSITY", { min: 0, max: 1, notifiers: { update: !0 } })], t.prototype, "environmentIntensity", void 0), x([qe("Specular highlights", Ye.Float, "INTENSITY", { min: 0, max: 1, notifiers: { update: !0 } })], t.prototype, "specularIntensity", void 0), x([qe("Light falloff", Ye.List, "LIGHTING & COLORS", { notifiers: { update: !0 }, options: [{ label: "Physical", value: Si.LIGHTFALLOFF_PHYSICAL }, { label: "GLTF", value: Si.LIGHTFALLOFF_GLTF }, { label: "Standard", value: Si.LIGHTFALLOFF_STANDARD }] })], t.prototype, "lightFalloff", void 0), x([qe("Alpha Testing", Ye.Boolean, "OPACITY")], t.prototype, "useAlphaTest", void 0), x([qe("Alpha CutOff", Ye.Float, "OPACITY", { min: 0, max: 1, notifiers: { update: !0 } })], t.prototype, "alphaTestCutoff", void 0), x([qe("Alpha blending", Ye.Boolean, "OPACITY")], t.prototype, "useAlphaBlending", void 0), x([qe("Radiance over alpha", Ye.Boolean, "RENDERING", { notifiers: { update: !0 } })], t.prototype, "useRadianceOverAlpha", void 0), x([qe("Specular over alpha", Ye.Boolean, "RENDERING", { notifiers: { update: !0 } })], t.prototype, "useSpecularOverAlpha", void 0), x([qe("Specular anti-aliasing", Ye.Boolean, "RENDERING", { notifiers: { update: !0 } })], t.prototype, "enableSpecularAntiAliasing", void 0), x([qe("Realtime filtering", Ye.Boolean, "RENDERING", { notifiers: { update: !0 } })], t.prototype, "realTimeFiltering", void 0), x([qe("Realtime filtering quality", Ye.List, "RENDERING", { notifiers: { update: !0 }, options: [{ label: "Low", value: _.TEXTURE_FILTERING_QUALITY_LOW }, { label: "Medium", value: _.TEXTURE_FILTERING_QUALITY_MEDIUM }, { label: "High", value: _.TEXTURE_FILTERING_QUALITY_HIGH }] })], t.prototype, "realTimeFilteringQuality", void 0), x([qe("Energy Conservation", Ye.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "useEnergyConservation", void 0), x([qe("Radiance occlusion", Ye.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "useRadianceOcclusion", void 0), x([qe("Horizon occlusion", Ye.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "useHorizonOcclusion", void 0), x([qe("Unlit", Ye.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "unlit", void 0), x([qe("Force normal forward", Ye.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "forceNormalForward", void 0), x([qe("Generate only fragment code", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0, update: !0, onValidation: t._OnGenerateOnlyFragmentCodeChanged } })], t.prototype, "generateOnlyFragmentCode", void 0), x([qe("Debug mode", Ye.List, "DEBUG", { notifiers: { update: !0 }, options: [{ label: "None", value: 0 }, { label: "Normalized position", value: 1 }, { label: "Normals", value: 2 }, { label: "Tangents", value: 3 }, { label: "Bitangents", value: 4 }, { label: "Bump Normals", value: 5 }, { label: "ClearCoat Normals", value: 8 }, { label: "ClearCoat Tangents", value: 9 }, { label: "ClearCoat Bitangents", value: 10 }, { label: "Anisotropic Normals", value: 11 }, { label: "Anisotropic Tangents", value: 12 }, { label: "Anisotropic Bitangents", value: 13 }, { label: "Env Refraction", value: 40 }, { label: "Env Reflection", value: 41 }, { label: "Env Clear Coat", value: 42 }, { label: "Direct Diffuse", value: 50 }, { label: "Direct Specular", value: 51 }, { label: "Direct Clear Coat", value: 52 }, { label: "Direct Sheen", value: 53 }, { label: "Env Irradiance", value: 54 }, { label: "Surface Albedo", value: 60 }, { label: "Reflectance 0", value: 61 }, { label: "Metallic", value: 62 }, { label: "Metallic F0", value: 71 }, { label: "Roughness", value: 63 }, { label: "AlphaG", value: 64 }, { label: "NdotV", value: 65 }, { label: "ClearCoat Color", value: 66 }, { label: "ClearCoat Roughness", value: 67 }, { label: "ClearCoat NdotV", value: 68 }, { label: "Transmittance", value: 69 }, { label: "Refraction Transmittance", value: 70 }, { label: "SEO", value: 80 }, { label: "EHO", value: 81 }, { label: "Energy Factor", value: 82 }, { label: "Specular Reflectance", value: 83 }, { label: "Clear Coat Reflectance", value: 84 }, { label: "Sheen Reflectance", value: 85 }, { label: "Luminance Over Alpha", value: 86 }, { label: "Alpha", value: 87 }] })], t.prototype, "debugMode", void 0), x([qe("Split position", Ye.Float, "DEBUG", { min: -1, max: 1, notifiers: { update: !0 } })], t.prototype, "debugLimit", void 0), x([qe("Output factor", Ye.Float, "DEBUG", { min: 0, max: 5, notifiers: { update: !0 } })], t.prototype, "debugFactor", void 0), t;
    }(We);
    j("BABYLON.PBRMetallicRoughnessBlock", gT);
    var vT = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("left", M.AutoDetect), i.registerInput("right", M.AutoDetect), i.registerOutput("output", M.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._linkConnectionTypes(0, 1), i._inputs[1].acceptedConnectionPointTypes.push(M.Float), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ModBlock";
      }, Object.defineProperty(t.prototype, "left", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0];
        return e.compilationString += this._declareOutput(i, e) + " = mod(".concat(this.left.associatedVariableName, ", ").concat(this.right.associatedVariableName, `);
`), this;
      }, t;
    }(We);
    j("BABYLON.ModBlock", vT);
    var fr, yT = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("row0", M.Vector4), i.registerInput("row1", M.Vector4), i.registerInput("row2", M.Vector4), i.registerInput("row3", M.Vector4), i.registerOutput("output", M.Matrix), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "MatrixBuilder";
      }, Object.defineProperty(t.prototype, "row0", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "row1", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "row2", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "row3", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function() {
        if (!this.row0.isConnected) {
          var e = new vt("row0");
          e.value = new lt(1, 0, 0, 0), e.output.connectTo(this.row0);
        }
        if (!this.row1.isConnected) {
          var i = new vt("row1");
          i.value = new lt(0, 1, 0, 0), i.output.connectTo(this.row1);
        }
        if (!this.row2.isConnected) {
          var r = new vt("row2");
          r.value = new lt(0, 0, 1, 0), r.output.connectTo(this.row2);
        }
        if (!this.row3.isConnected) {
          var o = new vt("row3");
          o.value = new lt(0, 0, 0, 1), o.output.connectTo(this.row3);
        }
      }, t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0], r = this.row0, o = this.row1, a = this.row2, s = this.row3;
        return e.compilationString += this._declareOutput(i, e) + " = mat4(".concat(r.associatedVariableName, ", ").concat(o.associatedVariableName, ", ").concat(a.associatedVariableName, ", ").concat(s.associatedVariableName, `);
`), this;
      }, t;
    }(We);
    j("BABYLON.MatrixBuilder", yT), function(n) {
      n[n.Equal = 0] = "Equal", n[n.NotEqual = 1] = "NotEqual", n[n.LessThan = 2] = "LessThan", n[n.GreaterThan = 3] = "GreaterThan", n[n.LessOrEqual = 4] = "LessOrEqual", n[n.GreaterOrEqual = 5] = "GreaterOrEqual", n[n.Xor = 6] = "Xor", n[n.Or = 7] = "Or", n[n.And = 8] = "And";
    }(fr || (fr = {}));
    var bT = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.condition = fr.LessThan, i.registerInput("a", M.Float), i.registerInput("b", M.Float), i.registerInput("true", M.AutoDetect, !0), i.registerInput("false", M.AutoDetect, !0), i.registerOutput("output", M.BasedOnInput), i._linkConnectionTypes(2, 3), i._outputs[0]._typeConnectionSource = i._inputs[2], i._outputs[0]._defaultConnectionPointType = M.Float, i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ConditionalBlock";
      }, Object.defineProperty(t.prototype, "a", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "b", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "true", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "false", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0], r = this.true.isConnected ? this.true.associatedVariableName : "1.0", o = this.false.isConnected ? this.false.associatedVariableName : "0.0";
        switch (this.condition) {
          case fr.Equal:
            e.compilationString += this._declareOutput(i, e) + " = ".concat(this.a.associatedVariableName, " == ").concat(this.b.associatedVariableName, " ? ").concat(r, " : ").concat(o, `;
`);
            break;
          case fr.NotEqual:
            e.compilationString += this._declareOutput(i, e) + " = ".concat(this.a.associatedVariableName, " != ").concat(this.b.associatedVariableName, " ? ").concat(r, " : ").concat(o, `;
`);
            break;
          case fr.LessThan:
            e.compilationString += this._declareOutput(i, e) + " = ".concat(this.a.associatedVariableName, " < ").concat(this.b.associatedVariableName, " ? ").concat(r, " : ").concat(o, `;
`);
            break;
          case fr.LessOrEqual:
            e.compilationString += this._declareOutput(i, e) + " = ".concat(this.a.associatedVariableName, " <= ").concat(this.b.associatedVariableName, " ? ").concat(r, " : ").concat(o, `;
`);
            break;
          case fr.GreaterThan:
            e.compilationString += this._declareOutput(i, e) + " = ".concat(this.a.associatedVariableName, " > ").concat(this.b.associatedVariableName, " ? ").concat(r, " : ").concat(o, `;
`);
            break;
          case fr.GreaterOrEqual:
            e.compilationString += this._declareOutput(i, e) + " = ".concat(this.a.associatedVariableName, " >= ").concat(this.b.associatedVariableName, " ? ").concat(r, " : ").concat(o, `;
`);
            break;
          case fr.Xor:
            e.compilationString += this._declareOutput(i, e) + " = (mod(".concat(this.a.associatedVariableName, " + ").concat(this.b.associatedVariableName, ", 2.0) > 0.0) ? ").concat(r, " : ").concat(o, `;
`);
            break;
          case fr.Or:
            e.compilationString += this._declareOutput(i, e) + " = (min(".concat(this.a.associatedVariableName, " + ").concat(this.b.associatedVariableName, ", 1.0) > 0.0) ? ").concat(r, " : ").concat(o, `;
`);
            break;
          case fr.And:
            e.compilationString += this._declareOutput(i, e) + " = (".concat(this.a.associatedVariableName, " * ").concat(this.b.associatedVariableName, " > 0.0)  ? ").concat(r, " : ").concat(o, `;
`);
        }
        return this;
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.condition = this.condition, e;
      }, t.prototype._deserialize = function(e, i, r) {
        n.prototype._deserialize.call(this, e, i, r), this.condition = e.condition;
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".condition = BABYLON.ConditionalBlockConditions.").concat(fr[this.condition], `;
`);
      }, t;
    }(We);
    j("BABYLON.ConditionalBlock", bT);
    var TT = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.octaves = 6, i.registerInput("seed", M.AutoDetect), i.registerInput("chaos", M.AutoDetect, !0), i.registerInput("offsetX", M.Float, !0), i.registerInput("offsetY", M.Float, !0), i.registerInput("offsetZ", M.Float, !0), i.registerOutput("output", M.Float), i._inputs[0].acceptedConnectionPointTypes.push(M.Vector2), i._inputs[0].acceptedConnectionPointTypes.push(M.Vector3), i._linkConnectionTypes(0, 1), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "CloudBlock";
      }, Object.defineProperty(t.prototype, "seed", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "chaos", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "offsetX", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "offsetY", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "offsetZ", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        var i, r;
        if (n.prototype._buildBlock.call(this, e), this.seed.isConnected && this._outputs[0].hasEndpoints) {
          var o = "fbm".concat(this.octaves);
          e._emitFunction("CloudBlockCode", `

        float cloudRandom(in float p) { p = fract(p * 0.011); p *= p + 7.5; p *= p + p; return fract(p); }

        // Based on Morgan McGuire @morgan3d
        // https://www.shadertoy.com/view/4dS3Wd
        float cloudNoise(in vec2 x, in vec2 chaos) {
            vec2 step = chaos * vec2(75., 120.) + vec2(75., 120.);

            vec2 i = floor(x);
            vec2 f = fract(x);

            float n = dot(i, step);

            vec2 u = f * f * (3.0 - 2.0 * f);
            return mix(
                    mix(cloudRandom(n + dot(step, vec2(0, 0))), cloudRandom(n + dot(step, vec2(1, 0))), u.x),
                    mix(cloudRandom(n + dot(step, vec2(0, 1))), cloudRandom(n + dot(step, vec2(1, 1))), u.x),
                    u.y
                );
        }

        float cloudNoise(in vec3 x, in vec3 chaos) {
            vec3 step = chaos * vec3(60., 120., 75.) + vec3(60., 120., 75.);

            vec3 i = floor(x);
            vec3 f = fract(x);

            float n = dot(i, step);

            vec3 u = f * f * (3.0 - 2.0 * f);
            return mix(mix(mix( cloudRandom(n + dot(step, vec3(0, 0, 0))), cloudRandom(n + dot(step, vec3(1, 0, 0))), u.x),
                           mix( cloudRandom(n + dot(step, vec3(0, 1, 0))), cloudRandom(n + dot(step, vec3(1, 1, 0))), u.x), u.y),
                       mix(mix( cloudRandom(n + dot(step, vec3(0, 0, 1))), cloudRandom(n + dot(step, vec3(1, 0, 1))), u.x),
                           mix( cloudRandom(n + dot(step, vec3(0, 1, 1))), cloudRandom(n + dot(step, vec3(1, 1, 1))), u.x), u.y), u.z);
        }`, "// CloudBlockCode"), e._emitFunction("CloudBlockCodeFBM" + this.octaves, `
        float fbm(in vec2 st, in vec2 chaos) {
            // Initial values
            float value = 0.0;
            float amplitude = .5;
            float frequency = 0.;

            // Loop of octaves
            for (int i = 0; i < OCTAVES; i++) {
                value += amplitude * cloudNoise(st, chaos);
                st *= 2.0;
                amplitude *= 0.5;
            }
            return value;
        }

        float fbm(in vec3 x, in vec3 chaos) {
            // Initial values
            float value = 0.0;
            float amplitude = 0.5;
            for (int i = 0; i < OCTAVES; ++i) {
                value += amplitude * cloudNoise(x, chaos);
                x = x * 2.0;
                amplitude *= 0.5;
            }
            return value;
        }`.replace(/fbm/gi, o).replace(/OCTAVES/gi, (0 | this.octaves).toString()), "// CloudBlockCode FBM");
          var a = e._getFreeVariableName("st"), s = ((i = this.seed.connectedPoint) === null || i === void 0 ? void 0 : i.type) === M.Vector2 ? "vec2" : "vec3";
          e.compilationString += "".concat(s, " ").concat(a, " = ").concat(this.seed.associatedVariableName, `;
`), this.offsetX.isConnected && (e.compilationString += "".concat(a, ".x += 0.1 * ").concat(this.offsetX.associatedVariableName, `;
`)), this.offsetY.isConnected && (e.compilationString += "".concat(a, ".y += 0.1 * ").concat(this.offsetY.associatedVariableName, `;
`)), this.offsetZ.isConnected && s === "vec3" && (e.compilationString += "".concat(a, ".z += 0.1 * ").concat(this.offsetZ.associatedVariableName, `;
`));
          var l;
          return l = this.chaos.isConnected ? this.chaos.associatedVariableName : ((r = this.seed.connectedPoint) === null || r === void 0 ? void 0 : r.type) === M.Vector2 ? "vec2(0., 0.)" : "vec3(0., 0., 0.)", e.compilationString += this._declareOutput(this._outputs[0], e) + " = ".concat(o, "(").concat(a, ", ").concat(l, `);
`), this;
        }
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".octaves = ").concat(this.octaves, `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.octaves = this.octaves, e;
      }, t.prototype._deserialize = function(e, i, r) {
        n.prototype._deserialize.call(this, e, i, r), this.octaves = e.octaves;
      }, x([qe("Octaves", Ye.Int)], t.prototype, "octaves", void 0), t;
    }(We);
    j("BABYLON.CloudBlock", TT);
    var ET = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("seed", M.Vector2), i.registerInput("offset", M.Float), i.registerInput("density", M.Float), i.registerOutput("output", M.Float), i.registerOutput("cells", M.Float), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "VoronoiNoiseBlock";
      }, Object.defineProperty(t.prototype, "seed", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "offset", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "density", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cells", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        if (n.prototype._buildBlock.call(this, e), this.seed.isConnected) {
          var i = `vec2 voronoiRandom(vec2 seed, float offset){
            mat2 m = mat2(15.27, 47.63, 99.41, 89.98);
            vec2 uv = fract(sin(m * seed) * 46839.32);
            return vec2(sin(uv.y * offset) * 0.5 + 0.5, cos(uv.x * offset) * 0.5 + 0.5);
        }
        `;
          e._emitFunction("voronoiRandom", i, "// Voronoi random generator"), i = `void voronoi(vec2 seed, float offset, float density, out float outValue, out float cells){
            vec2 g = floor(seed * density);
            vec2 f = fract(seed * density);
            float t = 8.0;
            vec3 res = vec3(8.0, 0.0, 0.0);

            for(int y=-1; y<=1; y++)
            {
                for(int x=-1; x<=1; x++)
                {
                    vec2 lattice = vec2(x,y);
                    vec2 randomOffset = voronoiRandom(lattice + g, offset);
                    float d = distance(lattice + randomOffset, f);
                    if(d < res.x)
                    {
                        res = vec3(d, randomOffset.x, randomOffset.y);
                        outValue = res.x;
                        cells = res.y;
                    }
                }
            }
        }
        `, e._emitFunction("voronoi", i, "// Voronoi");
          var r = e._getFreeVariableName("tempOutput"), o = e._getFreeVariableName("tempCells");
          return e.compilationString += "float ".concat(r, ` = 0.0;
`), e.compilationString += "float ".concat(o, ` = 0.0;
`), e.compilationString += "voronoi(".concat(this.seed.associatedVariableName, ", ").concat(this.offset.associatedVariableName, ", ").concat(this.density.associatedVariableName, ", ").concat(r, ", ").concat(o, `);
`), this.output.hasEndpoints && (e.compilationString += this._declareOutput(this.output, e) + " = ".concat(r, `;
`)), this.cells.hasEndpoints && (e.compilationString += this._declareOutput(this.cells, e) + " = ".concat(o, `;
`)), this;
        }
      }, t;
    }(We);
    j("BABYLON.VoronoiNoiseBlock", ET);
    var ST = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("input", M.AutoDetect), i.registerOutput("output", M.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ElbowBlock";
      }, Object.defineProperty(t.prototype, "input", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "target", { get: function() {
        var e = this._inputs[0];
        if (e.isConnected) {
          var i = e.connectedPoint.ownerBlock;
          if (i.target !== W.VertexAndFragment)
            return i.target;
          if (e.connectedPoint.target !== W.VertexAndFragment)
            return e.connectedPoint.target;
        }
        return this._target;
      }, set: function(e) {
        !(this._target & e) && (this._target = e);
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0], r = this._inputs[0];
        return e.compilationString += this._declareOutput(i, e) + " = ".concat(r.associatedVariableName, `;
`), this;
      }, t;
    }(We);
    j("BABYLON.ElbowBlock", ST);
    var G_ = function(n) {
      function t(e, i) {
        i === void 0 && (i = !1);
        var r = n.call(this, e, W.Neutral) || this;
        return r.projectAsCube = !1, r._convertToGammaSpace = !1, r._convertToLinearSpace = !1, r.disableLevelMultiplication = !1, r.registerInput("position", M.AutoDetect, !1), r.registerInput("normal", M.AutoDetect, !1), r.registerInput("sharpness", M.Float, !0), r.registerInput("source", M.Object, !0, W.VertexAndFragment, new xi("source", r, ui.Input, Bo, "ImageSourceBlock")), r.registerInput("sourceY", M.Object, !0, W.VertexAndFragment, new xi("sourceY", r, ui.Input, Bo, "ImageSourceBlock")), i || r.registerInput("sourceZ", M.Object, !0, W.VertexAndFragment, new xi("sourceZ", r, ui.Input, Bo, "ImageSourceBlock")), r.registerOutput("rgba", M.Color4, W.Neutral), r.registerOutput("rgb", M.Color3, W.Neutral), r.registerOutput("r", M.Float, W.Neutral), r.registerOutput("g", M.Float, W.Neutral), r.registerOutput("b", M.Float, W.Neutral), r.registerOutput("a", M.Float, W.Neutral), r.registerOutput("level", M.Float, W.Neutral), r._inputs[0].addExcludedConnectionPointFromAllowedTypes(M.Color3 | M.Vector3 | M.Vector4), r._inputs[1].addExcludedConnectionPointFromAllowedTypes(M.Color3 | M.Vector3 | M.Vector4), r;
      }
      return D(t, n), Object.defineProperty(t.prototype, "texture", { get: function() {
        var e;
        return this.source.isConnected ? ((e = this.source.connectedPoint) === null || e === void 0 ? void 0 : e.ownerBlock).texture : this._texture;
      }, set: function(e) {
        var i, r = this;
        if (this._texture !== e) {
          var o = (i = e == null ? void 0 : e.getScene()) !== null && i !== void 0 ? i : Me.LastCreatedScene;
          !e && o && o.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag, function(a) {
            return a.hasTexture(r._texture);
          }), this._texture = e, e && o && o.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag, function(a) {
            return a.hasTexture(e);
          });
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "textureY", { get: function() {
        var e;
        return this.sourceY.isConnected ? ((e = this.sourceY.connectedPoint) === null || e === void 0 ? void 0 : e.ownerBlock).texture : null;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "textureZ", { get: function() {
        var e, i;
        return !((e = this.sourceZ) === null || e === void 0) && e.isConnected ? ((i = this.sourceY.connectedPoint) === null || i === void 0 ? void 0 : i.ownerBlock).texture : null;
      }, enumerable: !1, configurable: !0 }), t.prototype._getImageSourceBlock = function(e) {
        return e != null && e.isConnected ? e.connectedPoint.ownerBlock : null;
      }, Object.defineProperty(t.prototype, "samplerName", { get: function() {
        var e = this._getImageSourceBlock(this.source);
        return e ? e.samplerName : this._samplerName;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "samplerYName", { get: function() {
        var e, i;
        return (i = (e = this._getImageSourceBlock(this.sourceY)) === null || e === void 0 ? void 0 : e.samplerName) !== null && i !== void 0 ? i : null;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "samplerZName", { get: function() {
        var e, i;
        return (i = (e = this._getImageSourceBlock(this.sourceZ)) === null || e === void 0 ? void 0 : e.samplerName) !== null && i !== void 0 ? i : null;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hasImageSource", { get: function() {
        return this.source.isConnected;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "convertToGammaSpace", { get: function() {
        return this._convertToGammaSpace;
      }, set: function(e) {
        var i, r = this;
        if (e !== this._convertToGammaSpace && (this._convertToGammaSpace = e, this.texture)) {
          var o = (i = this.texture.getScene()) !== null && i !== void 0 ? i : Me.LastCreatedScene;
          o == null || o.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag, function(a) {
            return a.hasTexture(r.texture);
          });
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "convertToLinearSpace", { get: function() {
        return this._convertToLinearSpace;
      }, set: function(e) {
        var i, r = this;
        if (e !== this._convertToLinearSpace && (this._convertToLinearSpace = e, this.texture)) {
          var o = (i = this.texture.getScene()) !== null && i !== void 0 ? i : Me.LastCreatedScene;
          o == null || o.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag, function(a) {
            return a.hasTexture(r.texture);
          });
        }
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "TriPlanarBlock";
      }, Object.defineProperty(t.prototype, "position", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "normal", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "sharpness", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "source", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "sourceY", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "sourceZ", { get: function() {
        return this._inputs[5];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgba", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgb", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "r", { get: function() {
        return this._outputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "g", { get: function() {
        return this._outputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "b", { get: function() {
        return this._outputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "a", { get: function() {
        return this._outputs[5];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "level", { get: function() {
        return this._outputs[6];
      }, enumerable: !1, configurable: !0 }), t.prototype.prepareDefines = function(e, i, r) {
        if (r._areTexturesDirty) {
          var o = this.convertToGammaSpace && this.texture && !this.texture.gammaSpace, a = this.convertToLinearSpace && this.texture && this.texture.gammaSpace;
          r.setValue(this._linearDefineName, o, !0), r.setValue(this._gammaDefineName, a, !0);
        }
      }, t.prototype.isReady = function() {
        return !(this.texture && !this.texture.isReadyOrNotBlocking());
      }, t.prototype.bind = function(e) {
        this.texture && (e.setFloat(this._textureInfoName, this.texture.level), this._imageSource || e.setTexture(this._samplerName, this.texture));
      }, t.prototype._generateTextureLookup = function(e) {
        var i, r, o = this.samplerName, a = (i = this.samplerYName) !== null && i !== void 0 ? i : o, s = (r = this.samplerZName) !== null && r !== void 0 ? r : o, l = this.sharpness.isConnected ? this.sharpness.associatedVariableName : "1.0", c = e._getFreeVariableName("x"), u = e._getFreeVariableName("y"), h = e._getFreeVariableName("z"), d = e._getFreeVariableName("w"), p = e._getFreeVariableName("n"), f = e._getFreeVariableName("uvx"), m = e._getFreeVariableName("uvy"), g = e._getFreeVariableName("uvz");
        e.compilationString += `
            vec3 `.concat(p, " = ").concat(this.normal.associatedVariableName, `.xyz;

            vec2 `).concat(f, " = ").concat(this.position.associatedVariableName, `.yz;
            vec2 `).concat(m, " = ").concat(this.position.associatedVariableName, `.zx;
            vec2 `).concat(g, " = ").concat(this.position.associatedVariableName, `.xy;
        `), this.projectAsCube && (e.compilationString += `
                `.concat(f, ".xy = ").concat(f, `.yx;

                if (`).concat(p, `.x >= 0.0) {
                    `).concat(f, ".x = -").concat(f, `.x;
                }
                if (`).concat(p, `.y < 0.0) {
                    `).concat(m, ".y = -").concat(m, `.y;
                }
                if (`).concat(p, `.z < 0.0) {
                    `).concat(g, ".x = -").concat(g, `.x;
                }
            `)), e.compilationString += `
            vec4 `.concat(c, " = texture2D(").concat(o, ", ").concat(f, `);
            vec4 `).concat(u, " = texture2D(").concat(a, ", ").concat(m, `);
            vec4 `).concat(h, " = texture2D(").concat(s, ", ").concat(g, `);
           
            // blend weights
            vec3 `).concat(d, " = pow(abs(").concat(p, "), vec3(").concat(l, `));

            // blend and return
            vec4 `).concat(this._tempTextureRead, " = (").concat(c, "*").concat(d, ".x + ").concat(u, "*").concat(d, ".y + ").concat(h, "*").concat(d, ".z) / (").concat(d, ".x + ").concat(d, ".y + ").concat(d, `.z);        
        `);
      }, t.prototype._generateConversionCode = function(e, i, r) {
        r !== "a" && (this.texture && this.texture.gammaSpace || (e.compilationString += "#ifdef ".concat(this._linearDefineName, `
                    `).concat(i.associatedVariableName, " = toGammaSpace(").concat(i.associatedVariableName, `);
                    #endif
                `)), e.compilationString += "#ifdef ".concat(this._gammaDefineName, `
                `).concat(i.associatedVariableName, " = toLinearSpace(").concat(i.associatedVariableName, `);
                #endif
            `));
      }, t.prototype._writeOutput = function(e, i, r) {
        var o = "";
        this.disableLevelMultiplication || (o = " * ".concat(this._textureInfoName)), e.compilationString += "".concat(this._declareOutput(i, e), " = ").concat(this._tempTextureRead, ".").concat(r).concat(o, `;
`), this._generateConversionCode(e, i, r);
      }, t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e), this.source.isConnected ? this._imageSource = this.source.connectedPoint.ownerBlock : this._imageSource = null, this._textureInfoName = e._getFreeVariableName("textureInfoName"), this.level.associatedVariableName = this._textureInfoName, this._tempTextureRead = e._getFreeVariableName("tempTextureRead"), this._linearDefineName = e._getFreeDefineName("ISLINEAR"), this._gammaDefineName = e._getFreeDefineName("ISGAMMA"), this._imageSource || (this._samplerName = e._getFreeVariableName(this.name + "Sampler"), e._emit2DSampler(this._samplerName)), e.sharedData.blockingBlocks.push(this), e.sharedData.textureBlocks.push(this), e.sharedData.blocksWithDefines.push(this), e.sharedData.bindableBlocks.push(this);
        var i = "//".concat(this.name);
        e._emitFunctionFromInclude("helperFunctions", i), e._emitUniformFromString(this._textureInfoName, "float"), this._generateTextureLookup(e);
        for (var r = 0, o = this._outputs; r < o.length; r++) {
          var a = o[r];
          a.hasEndpoints && a.name !== "level" && this._writeOutput(e, a, a.name);
        }
        return this;
      }, t.prototype._dumpPropertiesCode = function() {
        var e = n.prototype._dumpPropertiesCode.call(this);
        return e += "".concat(this._codeVariableName, ".convertToGammaSpace = ").concat(this.convertToGammaSpace, `;
`), e += "".concat(this._codeVariableName, ".convertToLinearSpace = ").concat(this.convertToLinearSpace, `;
`), e += "".concat(this._codeVariableName, ".disableLevelMultiplication = ").concat(this.disableLevelMultiplication, `;
`), e += "".concat(this._codeVariableName, ".projectAsCube = ").concat(this.projectAsCube, `;
`), this.texture ? (e += "".concat(this._codeVariableName, '.texture = new BABYLON.Texture("').concat(this.texture.name, '", null, ').concat(this.texture.noMipmap, ", ").concat(this.texture.invertY, ", ").concat(this.texture.samplingMode, `);
`), e += "".concat(this._codeVariableName, ".texture.wrapU = ").concat(this.texture.wrapU, `;
`), e += "".concat(this._codeVariableName, ".texture.wrapV = ").concat(this.texture.wrapV, `;
`), e += "".concat(this._codeVariableName, ".texture.uAng = ").concat(this.texture.uAng, `;
`), e += "".concat(this._codeVariableName, ".texture.vAng = ").concat(this.texture.vAng, `;
`), e += "".concat(this._codeVariableName, ".texture.wAng = ").concat(this.texture.wAng, `;
`), e += "".concat(this._codeVariableName, ".texture.uOffset = ").concat(this.texture.uOffset, `;
`), e += "".concat(this._codeVariableName, ".texture.vOffset = ").concat(this.texture.vOffset, `;
`), e += "".concat(this._codeVariableName, ".texture.uScale = ").concat(this.texture.uScale, `;
`), e += "".concat(this._codeVariableName, ".texture.vScale = ").concat(this.texture.vScale, `;
`), e += "".concat(this._codeVariableName, ".texture.coordinatesMode = ").concat(this.texture.coordinatesMode, `;
`)) : e;
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.convertToGammaSpace = this.convertToGammaSpace, e.convertToLinearSpace = this.convertToLinearSpace, e.disableLevelMultiplication = this.disableLevelMultiplication, e.projectAsCube = this.projectAsCube, this.hasImageSource || !this.texture || this.texture.isRenderTarget || this.texture.getClassName() === "VideoTexture" || (e.texture = this.texture.serialize()), e;
      }, t.prototype._deserialize = function(e, i, r) {
        n.prototype._deserialize.call(this, e, i, r), this.convertToGammaSpace = e.convertToGammaSpace, this.convertToLinearSpace = !!e.convertToLinearSpace, this.disableLevelMultiplication = !!e.disableLevelMultiplication, this.projectAsCube = !!e.projectAsCube, e.texture && !ka.IgnoreTexturesAtLoadTime && e.texture.url !== void 0 && (r = e.texture.url.indexOf("data:") === 0 ? "" : r, this.texture = ae.Parse(e.texture, i, r));
      }, x([qe("Project as cube", Ye.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "projectAsCube", void 0), t;
    }(We);
    j("BABYLON.TriPlanarBlock", G_);
    var xT = function(n) {
      function t(e) {
        return n.call(this, e, !0) || this;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "BiPlanarBlock";
      }, t.prototype._generateTextureLookup = function(e) {
        var i, r = this.samplerName, o = (i = this.samplerYName) !== null && i !== void 0 ? i : this.samplerName, a = this.sharpness.isConnected ? this.sharpness.associatedVariableName : "1.0", s = e._getFreeVariableName("dpdx"), l = e._getFreeVariableName("dpdy"), c = e._getFreeVariableName("n"), u = e._getFreeVariableName("ma"), h = e._getFreeVariableName("mi"), d = e._getFreeVariableName("me"), p = e._getFreeVariableName("x"), f = e._getFreeVariableName("y"), m = e._getFreeVariableName("y");
        e.compilationString += `
            // grab coord derivatives for texturing
            vec3 `.concat(s, " = dFdx(").concat(this.position.associatedVariableName, `.xyz);
            vec3 `).concat(l, " = dFdy(").concat(this.position.associatedVariableName, `.xyz);
            vec3 `).concat(c, " = abs(").concat(this.normal.associatedVariableName, `.xyz);
        
            // determine major axis (in x; yz are following axis)
            ivec3 `).concat(u, " = (").concat(c, ".x>").concat(c, ".y && ").concat(c, ".x>").concat(c, `.z) ? ivec3(0,1,2) :
                    (`).concat(c, ".y>").concat(c, `.z)            ? ivec3(1,2,0) :
                                            ivec3(2,0,1) ;
            // determine minor axis (in x; yz are following axis)
            ivec3 `).concat(h, " = (").concat(c, ".x<").concat(c, ".y && ").concat(c, ".x<").concat(c, `.z) ? ivec3(0,1,2) :
                    (`).concat(c, ".y<").concat(c, `.z)            ? ivec3(1,2,0) :
                                            ivec3(2,0,1) ;
            // determine median axis (in x;  yz are following axis)
            ivec3 `).concat(d, " = ivec3(3) - ").concat(h, " - ").concat(u, `;
            
            // project+fetch
            vec4 `).concat(p, " = textureGrad( ").concat(r, ", vec2(   ").concat(this.position.associatedVariableName, "[").concat(u, ".y],   ").concat(this.position.associatedVariableName, "[").concat(u, `.z]), 
                                    vec2(`).concat(s, "[").concat(u, ".y],").concat(s, "[").concat(u, `.z]), 
                                    vec2(`).concat(l, "[").concat(u, ".y],").concat(l, "[").concat(u, `.z]) );
            vec4 `).concat(f, " = textureGrad( ").concat(o, ", vec2(   ").concat(this.position.associatedVariableName, "[").concat(d, ".y],   ").concat(this.position.associatedVariableName, "[").concat(d, `.z]), 
                                    vec2(`).concat(s, "[").concat(d, ".y],").concat(s, "[").concat(d, `.z]),
                                    vec2(`).concat(l, "[").concat(d, ".y],").concat(l, "[").concat(d, `.z]) );
            
            // blend factors
            vec2 `).concat(m, " = vec2(").concat(c, "[").concat(u, ".x],").concat(c, "[").concat(d, `.x]);
            // make local support
            `).concat(m, " = clamp( (").concat(m, `-0.5773)/(1.0-0.5773), 0.0, 1.0 );
            // shape transition
            `).concat(m, " = pow( ").concat(m, ", vec2(").concat(a, `/8.0) );
            // blend and return
            vec4 `).concat(this._tempTextureRead, " = (").concat(p, "*").concat(m, ".x + ").concat(f, "*").concat(m, ".y) / (").concat(m, ".x + ").concat(m, `.y);
        `);
      }, t;
    }(G_);
    j("BABYLON.BiPlanarBlock", xT);
    var AT = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("input", M.Matrix), i.registerOutput("output", M.Float), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "MatrixDeterminantBlock";
      }, Object.defineProperty(t.prototype, "input", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this.output, r = this.input;
        return e.compilationString += this._declareOutput(i, e) + "".concat(i.associatedVariableName, " = determinant(").concat(r.associatedVariableName, `);
`), this;
      }, t;
    }(We);
    j("BABYLON.MatrixDeterminantBlock", AT);
    var ti, RT = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.registerInput("input", M.Matrix), i.registerOutput("output", M.Matrix), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "MatrixTransposeBlock";
      }, Object.defineProperty(t.prototype, "input", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this.output, r = this.input;
        return e.compilationString += this._declareOutput(i, e) + "".concat(i.associatedVariableName, " = transpose(").concat(r.associatedVariableName, `);
`), this;
      }, t;
    }(We);
    j("BABYLON.MatrixTransposeBlock", RT), function(n) {
      n[n.None = 0] = "None", n[n.Normal = 1] = "Normal", n[n.Tangent = 2] = "Tangent", n[n.VertexColor = 3] = "VertexColor", n[n.UV1 = 4] = "UV1", n[n.UV2 = 5] = "UV2", n[n.UV3 = 6] = "UV3", n[n.UV4 = 7] = "UV4", n[n.UV5 = 8] = "UV5", n[n.UV6 = 9] = "UV6";
    }(ti || (ti = {}));
    var pi, CT = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.attributeType = ti.None, i.registerInput("input", M.AutoDetect), i.registerInput("fallback", M.AutoDetect), i.registerOutput("output", M.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._linkConnectionTypes(0, 1), i._inputs[0].onConnectionObservable.add(function(r) {
          var o;
          if (!i.attributeType) {
            var a = r.ownerBlock;
            if (a instanceof vt && a.isAttribute)
              switch (a.name) {
                case "color":
                  i.attributeType = ti.VertexColor;
                  break;
                case "normal":
                  i.attributeType = ti.Normal;
                  break;
                case "tangent":
                  i.attributeType = ti.Tangent;
                  break;
                case "uv":
                  i.attributeType = ti.UV1;
                  break;
                case "uv2":
                  i.attributeType = ti.UV2;
                  break;
                case "uv3":
                  i.attributeType = ti.UV3;
                  break;
                case "uv4":
                  i.attributeType = ti.UV4;
                  break;
                case "uv5":
                  i.attributeType = ti.UV5;
                  break;
                case "uv6":
                  i.attributeType = ti.UV6;
              }
            else if (a instanceof F_)
              switch ((o = i.input.connectedPoint) === null || o === void 0 ? void 0 : o.name) {
                case "normalOutput":
                  i.attributeType = ti.Normal;
                  break;
                case "tangentOutput":
                  i.attributeType = ti.Tangent;
                  break;
                case "uvOutput":
                  i.attributeType = ti.UV1;
              }
          }
        }), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "MeshAttributeExistsBlock";
      }, Object.defineProperty(t.prototype, "input", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "fallback", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = null;
        switch (this.attributeType) {
          case ti.VertexColor:
            i = "VERTEXCOLOR_NME";
            break;
          case ti.Normal:
            i = "NORMAL";
            break;
          case ti.Tangent:
            i = "TANGENT";
            break;
          case ti.UV1:
            i = "UV1";
            break;
          case ti.UV2:
            i = "UV2";
            break;
          case ti.UV3:
            i = "UV3";
            break;
          case ti.UV4:
            i = "UV4";
            break;
          case ti.UV5:
            i = "UV5";
            break;
          case ti.UV6:
            i = "UV6";
        }
        var r = this._declareOutput(this.output, e);
        return i && (e.compilationString += "#ifdef ".concat(i, `
`)), e.compilationString += "".concat(r, " = ").concat(this.input.associatedVariableName, `;
`), i && (e.compilationString += `#else
`, e.compilationString += "".concat(r, " = ").concat(this.fallback.associatedVariableName, `;
`), e.compilationString += `#endif
`), this;
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.attributeType = this.attributeType, e;
      }, t.prototype._deserialize = function(e, i, r) {
        var o;
        n.prototype._deserialize.call(this, e, i, r), this.attributeType = (o = e.attributeType) !== null && o !== void 0 ? o : ti.None;
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".attributeType = ").concat(this.attributeType, `;
`);
      }, x([qe("Attribute lookup", Ye.List, void 0, { notifiers: { update: !0 }, options: [{ label: "(None)", value: ti.None }, { label: "Normal", value: ti.Normal }, { label: "Tangent", value: ti.Tangent }, { label: "Vertex Color", value: ti.VertexColor }, { label: "UV1", value: ti.UV1 }, { label: "UV2", value: ti.UV2 }, { label: "UV3", value: ti.UV3 }, { label: "UV4", value: ti.UV4 }, { label: "UV5", value: ti.UV5 }, { label: "UV6", value: ti.UV6 }] })], t.prototype, "attributeType", void 0), t;
    }(We);
    j("BABYLON.MeshAttributeExistsBlock", CT), function(n) {
      n[n.EaseInSine = 0] = "EaseInSine", n[n.EaseOutSine = 1] = "EaseOutSine", n[n.EaseInOutSine = 2] = "EaseInOutSine", n[n.EaseInQuad = 3] = "EaseInQuad", n[n.EaseOutQuad = 4] = "EaseOutQuad", n[n.EaseInOutQuad = 5] = "EaseInOutQuad", n[n.EaseInCubic = 6] = "EaseInCubic", n[n.EaseOutCubic = 7] = "EaseOutCubic", n[n.EaseInOutCubic = 8] = "EaseInOutCubic", n[n.EaseInQuart = 9] = "EaseInQuart", n[n.EaseOutQuart = 10] = "EaseOutQuart", n[n.EaseInOutQuart = 11] = "EaseInOutQuart", n[n.EaseInQuint = 12] = "EaseInQuint", n[n.EaseOutQuint = 13] = "EaseOutQuint", n[n.EaseInOutQuint = 14] = "EaseInOutQuint", n[n.EaseInExpo = 15] = "EaseInExpo", n[n.EaseOutExpo = 16] = "EaseOutExpo", n[n.EaseInOutExpo = 17] = "EaseInOutExpo", n[n.EaseInCirc = 18] = "EaseInCirc", n[n.EaseOutCirc = 19] = "EaseOutCirc", n[n.EaseInOutCirc = 20] = "EaseInOutCirc", n[n.EaseInBack = 21] = "EaseInBack", n[n.EaseOutBack = 22] = "EaseOutBack", n[n.EaseInOutBack = 23] = "EaseInOutBack", n[n.EaseInElastic = 24] = "EaseInElastic", n[n.EaseOutElastic = 25] = "EaseOutElastic", n[n.EaseInOutElastic = 26] = "EaseInOutElastic";
    }(pi || (pi = {}));
    var PT = function(n) {
      function t(e) {
        var i = n.call(this, e, W.Neutral) || this;
        return i.type = pi.EaseInOutSine, i.registerInput("input", M.AutoDetect), i.registerOutput("output", M.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._inputs[0].excludedConnectionPointTypes.push(M.Matrix), i._inputs[0].excludedConnectionPointTypes.push(M.Object), i._inputs[0].excludedConnectionPointTypes.push(M.Int), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "CurveBlock";
      }, Object.defineProperty(t.prototype, "input", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._duplicateEntry = function(e, i) {
        return "ret.".concat(i, " = ").concat(e.replace(/VAL/g, "v." + i));
      }, t.prototype._duplicateEntryDirect = function(e) {
        return "return ".concat(e.replace(/VAL/g, "v"));
      }, t.prototype._duplicateVector = function(e, i) {
        if (i === "float")
          return this._duplicateEntryDirect(e);
        for (var r = parseInt(i.replace("vec", "")), o = `
            vec`.concat(r, " ret = vec").concat(r, `(0.0);
        `), a = 1; a <= r; a++)
          o += this._duplicateEntry(e, a === 1 ? "x" : a === 2 ? "y" : a === 3 ? "z" : "w") + `;
`;
        return o + `return ret;
`;
      }, t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i, r = this._outputs[0], o = "", a = "";
        switch (this.input.type) {
          case M.Float:
            a = "float";
            break;
          case M.Vector2:
            a = "vec2";
            break;
          case M.Vector3:
          case M.Color3:
            a = "vec3";
            break;
          case M.Vector4:
          case M.Color4:
            a = "vec4";
        }
        switch (i = pi[this.type] + "_" + a, this.type) {
          case pi.EaseInSine:
            o = "return 1.0 - cos((v * 3.1415) / 2.0)";
            break;
          case pi.EaseOutSine:
            o = "return sin((v * 3.1415) / 2.0)";
            break;
          case pi.EaseInOutSine:
            o = "return -(cos(v * 3.1415) - 1.0) / 2.0";
            break;
          case pi.EaseInQuad:
            o = "return v * v";
            break;
          case pi.EaseOutQuad:
            o = "return (1.0 - v) * (1.0 - v)";
            break;
          case pi.EaseInOutQuad:
            var s = "VAL < 0.5 ? 2.0 * VAL * VAL : 1.0 - pow(-2.0 * VAL + 2.0, 2.0) / 2.0";
            o = this._duplicateVector(s, a);
            break;
          case pi.EaseInCubic:
            o = "return v * v * v";
            break;
          case pi.EaseOutCubic:
            s = "1.0 - pow(1.0 - VAL, 3.0)", o = this._duplicateVector(s, a);
            break;
          case pi.EaseInOutCubic:
            s = "VAL < 0.5 ? 4.0 * VAL * VAL * VAL : 1.0 - pow(-2.0 * VAL + 2.0, 3.0) / 2.0", o = this._duplicateVector(s, a);
            break;
          case pi.EaseInQuart:
            o = "return v * v * v * v";
            break;
          case pi.EaseOutQuart:
            s = "1.0 - pow(1.0 - VAL, 4.0)", o = this._duplicateVector(s, a);
            break;
          case pi.EaseInOutQuart:
            s = "VAL < 0.5 ? 8.0 * VAL * VAL * VAL * VAL : 1.0 - pow(-2.0 * VAL + 2.0, 4.0) / 2.0", o = this._duplicateVector(s, a);
            break;
          case pi.EaseInQuint:
            o = "return v * v * v * v * v";
            break;
          case pi.EaseOutQuint:
            s = "1.0 - pow(1.0 - VAL, 5.0)", o = this._duplicateVector(s, a);
            break;
          case pi.EaseInOutQuint:
            s = "VAL < 0.5 ? 16.0 * VAL * VAL * VAL * VAL * VAL : 1.0 - pow(-2.0 * VAL + 2.0, 5.0) / 2.0", o = this._duplicateVector(s, a);
            break;
          case pi.EaseInExpo:
            s = "VAL == 0.0 ? 0.0 : pow(2.0, 10.0 * VAL - 10.0)", o = this._duplicateVector(s, a);
            break;
          case pi.EaseOutExpo:
            s = "VAL == 1.0 ? 1.0 : 1.0 - pow(2.0, -10.0 * VAL)", o = this._duplicateVector(s, a);
            break;
          case pi.EaseInOutExpo:
            s = "VAL == 0.0 ? 0.0 : VAL == 1.0 ? 1.0 : VAL < 0.5 ? pow(2.0, 20.0 * VAL - 10.0) / 2.0 : (2.0 - pow(2.0, -20.0 * VAL + 10.0)) / 2.0", o = this._duplicateVector(s, a);
            break;
          case pi.EaseInCirc:
            s = "1.0 - sqrt(1.0 - pow(VAL, 2.0))", o = this._duplicateVector(s, a);
            break;
          case pi.EaseOutCirc:
            s = "sqrt(1.0 - pow(VAL - 1.0, 2.0))", o = this._duplicateVector(s, a);
            break;
          case pi.EaseInOutCirc:
            s = "VAL < 0.5 ? (1.0 - sqrt(1.0 - pow(2.0 * VAL, 2.0))) / 2.0 : (sqrt(1.0 - pow(-2.0 * VAL + 2.0, 2.0)) + 1.0) / 2.0", o = this._duplicateVector(s, a);
            break;
          case pi.EaseInBack:
            o = "return 2.70158 * v * v * v - 1.70158 * v * v";
            break;
          case pi.EaseOutBack:
            s = "2.70158 * pow(VAL - 1.0, 3.0) + 1.70158 * pow(VAL - 1.0, 2.0)", o = this._duplicateVector(s, a);
            break;
          case pi.EaseInOutBack:
            s = "VAL < 0.5 ? (pow(2.0 * VAL, 2.0) * ((3.5949095) * 2.0 * VAL - 2.5949095)) / 2.0 : (pow(2.0 * VAL - 2.0, 2.0) * (3.5949095 * (VAL * 2.0 - 2.0) + 3.5949095) + 2.0) / 2.0", o = this._duplicateVector(s, a);
            break;
          case pi.EaseInElastic:
            s = "VAL == 0.0 ? 0.0 : VAL == 1.0 ? 1.0 : -pow(2.0, 10.0 * VAL - 10.0) * sin((VAL * 10.0 - 10.75) * ((2.0 * 3.1415) / 3.0))", o = this._duplicateVector(s, a);
            break;
          case pi.EaseOutElastic:
            s = "VAL == 0.0 ? 0.0 : VAL == 1.0 ? 1.0 : pow(2.0, -10.0 * VAL) * sin((VAL * 10.0 - 0.75) * ((2.0 * 3.1415) / 3.0)) + 1.0", o = this._duplicateVector(s, a);
            break;
          case pi.EaseInOutElastic:
            s = "VAL == 0.0 ? 0.0 : VAL == 1.0 ? 1.0 : VAL < 0.5 ? -(pow(2.0, 20.0 * VAL - 10.0) * sin((20.0 * VAL - 11.125) * ((2.0 * 3.1415) / 4.5))) / 2.0 : (pow(2.0, -20.0 * VAL + 10.0) * sin((20.0 * VAL - 11.125) * ((2.0 * 3.1415) / 4.5))) / 2.0 + 1.0", o = this._duplicateVector(s, a);
        }
        return e._emitFunction(i, "".concat(a, " ").concat(i, "(").concat(a, " v) {").concat(o, `;}
`), ""), e.compilationString += this._declareOutput(r, e) + " = ".concat(i, "(").concat(this.input.associatedVariableName, `);
`), this;
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.curveType = this.type, e;
      }, t.prototype._deserialize = function(e, i, r) {
        n.prototype._deserialize.call(this, e, i, r), this.type = e.curveType;
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".type = BABYLON.CurveBlockTypes.").concat(pi[this.type], `;
`);
      }, t;
    }(We);
    j("BABYLON.CurveBlock", PT);
    var Cl, _r, Uo, uP = function() {
      function n() {
      }
      return n.prototype.optimize = function(t, e) {
      }, n;
    }(), cN = function() {
      function n() {
        this.mm = /* @__PURE__ */ new Map();
      }
      return n.prototype.get = function(t, e) {
        var i = this.mm.get(t);
        if (i !== void 0)
          return i.get(e);
      }, n.prototype.set = function(t, e, i) {
        var r = this.mm.get(t);
        r === void 0 && this.mm.set(t, r = /* @__PURE__ */ new Map()), r.set(e, i);
      }, n;
    }(), hP = function() {
      function n(t, e, i) {
        var r = this;
        this._baseMaterial = t, this._scene = e ?? Me.LastCreatedScene, this._options = i, this._subMeshToEffect = /* @__PURE__ */ new Map(), this._subMeshToDepthWrapper = new cN(), this._meshes = /* @__PURE__ */ new Map(), this._onEffectCreatedObserver = this._baseMaterial.onEffectCreatedObservable.add(function(o) {
          var a, s, l = (a = o.subMesh) === null || a === void 0 ? void 0 : a.getMesh();
          l && !r._meshes.has(l) && r._meshes.set(l, l.onDisposeObservable.add(function(c) {
            for (var u = r._subMeshToEffect.keys(), h = u.next(); h.done !== !0; h = u.next()) {
              var d = h.value;
              (d == null ? void 0 : d.getMesh()) === c && (r._subMeshToEffect.delete(d), r._deleteDepthWrapperEffect(d));
            }
          })), ((s = r._subMeshToEffect.get(o.subMesh)) === null || s === void 0 ? void 0 : s[0]) !== o.effect && (r._subMeshToEffect.set(o.subMesh, [o.effect, r._scene.getEngine().currentRenderPassId]), r._deleteDepthWrapperEffect(o.subMesh));
        });
      }
      return Object.defineProperty(n.prototype, "standalone", { get: function() {
        var t, e;
        return (e = (t = this._options) === null || t === void 0 ? void 0 : t.standalone) !== null && e !== void 0 && e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "baseMaterial", { get: function() {
        return this._baseMaterial;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "doNotInjectCode", { get: function() {
        var t, e;
        return (e = (t = this._options) === null || t === void 0 ? void 0 : t.doNotInjectCode) !== null && e !== void 0 && e;
      }, enumerable: !1, configurable: !0 }), n.prototype._deleteDepthWrapperEffect = function(t) {
        var e = this._subMeshToDepthWrapper.mm.get(t);
        e && (e.forEach(function(i) {
          var r;
          (r = i.mainDrawWrapper.effect) === null || r === void 0 || r.dispose();
        }), this._subMeshToDepthWrapper.mm.delete(t));
      }, n.prototype.getEffect = function(t, e, i) {
        var r, o = (r = this._subMeshToDepthWrapper.mm.get(t)) === null || r === void 0 ? void 0 : r.get(e);
        if (!o)
          return null;
        var a = o.drawWrapper[i];
        return a || (a = o.drawWrapper[i] = new Ei(this._scene.getEngine())).setEffect(o.mainDrawWrapper.effect, o.mainDrawWrapper.defines), a;
      }, n.prototype.isReadyForSubMesh = function(t, e, i, r, o) {
        var a, s;
        return !(this.standalone && !this._baseMaterial.isReadyForSubMesh(t.getMesh(), t, r)) && (s = (a = this._makeEffect(t, e, i, o)) === null || a === void 0 ? void 0 : a.isReady()) !== null && s !== void 0 && s;
      }, n.prototype.dispose = function() {
        this._baseMaterial.onEffectCreatedObservable.remove(this._onEffectCreatedObserver), this._onEffectCreatedObserver = null;
        for (var t = this._meshes.entries(), e = t.next(); e.done !== !0; e = t.next()) {
          var i = e.value, r = i[0], o = i[1];
          r.onDisposeObservable.remove(o);
        }
      }, n.prototype._makeEffect = function(t, e, i, r) {
        var o, a, s, l = this._scene.getEngine(), c = this._subMeshToEffect.get(t);
        if (!c)
          return null;
        var u = c[0], h = c[1], d = this._subMeshToDepthWrapper.get(t, i);
        if (!d) {
          var p = new Ei(l);
          p.defines = (a = (o = t._getDrawWrapper(h)) === null || o === void 0 ? void 0 : o.defines) !== null && a !== void 0 ? a : null, (d = { drawWrapper: [], mainDrawWrapper: p, depthDefines: "", token: ra() }).drawWrapper[r] = p, this._subMeshToDepthWrapper.set(t, i, d);
        }
        var f = e.join(`
`);
        if (d.mainDrawWrapper.effect && f === d.depthDefines)
          return d.mainDrawWrapper.effect;
        d.depthDefines = f;
        var m = u.getUniformNames().slice(), g = u.vertexSourceCodeBeforeMigration, y = u.fragmentSourceCodeBeforeMigration;
        if (!this.doNotInjectCode) {
          var b = this._options && this._options.remappedVariables ? "#include<shadowMapVertexNormalBias>(".concat(this._options.remappedVariables.join(","), ")") : Jt.IncludesShadersStore.shadowMapVertexNormalBias, T = this._options && this._options.remappedVariables ? "#include<shadowMapVertexMetric>(".concat(this._options.remappedVariables.join(","), ")") : Jt.IncludesShadersStore.shadowMapVertexMetric, S = this._options && this._options.remappedVariables ? "#include<shadowMapFragmentSoftTransparentShadow>(".concat(this._options.remappedVariables.join(","), ")") : Jt.IncludesShadersStore.shadowMapFragmentSoftTransparentShadow, E = Jt.IncludesShadersStore.shadowMapFragment;
          g = (g = (g = (g = g.replace(/void\s+?main/g, Jt.IncludesShadersStore.shadowMapVertexExtraDeclaration + `
void main`)).replace(/#define SHADOWDEPTH_NORMALBIAS|#define CUSTOM_VERTEX_UPDATE_WORLDPOS/g, b)).indexOf("#define SHADOWDEPTH_METRIC") !== -1 ? g.replace(/#define SHADOWDEPTH_METRIC/g, T) : g.replace(/}\s*$/g, T + `
}`)).replace(/#define SHADER_NAME.*?\n|out vec4 glFragColor;\n/g, "");
          var A = y.indexOf("#define SHADOWDEPTH_SOFTTRANSPARENTSHADOW") >= 0 || y.indexOf("#define CUSTOM_FRAGMENT_BEFORE_FOG") >= 0, R = y.indexOf("#define SHADOWDEPTH_FRAGMENT") !== -1, C = "";
          A ? y = y.replace(/#define SHADOWDEPTH_SOFTTRANSPARENTSHADOW|#define CUSTOM_FRAGMENT_BEFORE_FOG/g, S) : C = S + `
`, y = y.replace(/void\s+?main/g, Jt.IncludesShadersStore.shadowMapFragmentExtraDeclaration + `
void main`), R ? y = y.replace(/#define SHADOWDEPTH_FRAGMENT/g, E) : C += E + `
`, C && (y = y.replace(/}\s*$/g, C + "}")), m.push("biasAndScaleSM", "depthValuesSM", "lightDataSM", "softTransparentShadowSM");
        }
        d.mainDrawWrapper.effect = l.createEffect({ vertexSource: g, fragmentSource: y, vertexToken: d.token, fragmentToken: d.token }, { attributes: u.getAttributesNames(), uniformsNames: m, uniformBuffersNames: u.getUniformBuffersNames(), samplers: u.getSamplers(), defines: f + `
` + u.defines.replace("#define SHADOWS", "").replace(/#define SHADOW\d/g, ""), indexParameters: u.getIndexParameters() }, l);
        for (var L = 0; L < d.drawWrapper.length; ++L)
          L !== r && ((s = d.drawWrapper[L]) === null || s === void 0 || s.setEffect(d.mainDrawWrapper.effect, d.mainDrawWrapper.defines));
        return d.mainDrawWrapper.effect;
      }, n;
    }(), IT = function(n) {
      function t() {
        var e = n !== null && n.apply(this, arguments) || this;
        return e.DECAL = !1, e.DECALDIRECTUV = 0, e.DECAL_SMOOTHALPHA = !1, e.GAMMADECAL = !1, e;
      }
      return D(t, n), t;
    }(jn), cd = function(n) {
      function t(e, i) {
        i === void 0 && (i = !0);
        var r = n.call(this, e, "DecalMap", 150, new IT(), i) || this;
        return r._isEnabled = !1, r.isEnabled = !1, r._smoothAlpha = !1, r.smoothAlpha = !1, r.registerForExtraEvents = !0, r._internalMarkAllSubMeshesAsTexturesDirty = e._dirtyCallbacks[_.MATERIAL_TextureDirtyFlag], r;
      }
      return D(t, n), t.prototype._markAllSubMeshesAsTexturesDirty = function() {
        this._enable(this._isEnabled), this._internalMarkAllSubMeshesAsTexturesDirty();
      }, t.prototype.isReadyForSubMesh = function(e, i, r, o) {
        var a = o.getMesh().decalMap;
        return !(this._isEnabled && (a != null && a.texture) && Pe.DecalMapEnabled && i.texturesEnabled) || a.isReady();
      }, t.prototype.prepareDefines = function(e, i, r) {
        var o = r.decalMap;
        this._isEnabled && (o != null && o.texture) && Pe.DecalMapEnabled && i.texturesEnabled ? ((!e.DECAL || e.GAMMADECAL !== o.texture.gammaSpace) && e.markAsTexturesDirty(), e.DECAL = !0, e.GAMMADECAL = o.texture.gammaSpace, e.DECAL_SMOOTHALPHA = this._smoothAlpha, Se.PrepareDefinesForMergedUV(o.texture, e, "DECAL")) : (e.DECAL && e.markAsTexturesDirty(), e.DECAL = !1);
      }, t.prototype.hardBindForSubMesh = function(e, i, r, o) {
        var a = o.getMesh().decalMap;
        if (this._isEnabled && (a != null && a.texture) && Pe.DecalMapEnabled && i.texturesEnabled) {
          var s = this._material.isFrozen, l = a.texture;
          e.useUbo && s && e.isSync || (e.updateFloat4("vDecalInfos", l.coordinatesIndex, 0, 0, 0), Se.BindTextureMatrix(l, e, "decal")), e.setTexture("decalSampler", l);
        }
      }, t.prototype.getClassName = function() {
        return "DecalMapConfiguration";
      }, t.prototype.getSamplers = function(e) {
        e.push("decalSampler");
      }, t.prototype.getUniforms = function() {
        return { ubo: [{ name: "vDecalInfos", size: 4, type: "vec4" }, { name: "decalMatrix", size: 16, type: "mat4" }] };
      }, x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isEnabled", void 0), x([N(), ye("_markAllSubMeshesAsTexturesDirty")], t.prototype, "smoothAlpha", void 0), t;
    }($r);
    function dP(n) {
      return n instanceof Si ? new s_(n) : null;
    }
    function pP(n) {
      return n instanceof Si ? new UC(n) : null;
    }
    function fP(n) {
      return n instanceof Si ? new Kc(n) : null;
    }
    function _P(n) {
      return n instanceof Si ? new qc(n) : null;
    }
    function mP(n) {
      return n instanceof Si ? new l_(n) : null;
    }
    function gP(n) {
      return n instanceof Si ? new c_(n) : null;
    }
    function vP(n) {
      return n instanceof Si || n instanceof Gt ? new dh(n) : null;
    }
    j("BABYLON.DecalMapConfiguration", cd), function(n) {
      n[n.MATERIAL_TYPE_STANDARD = 0] = "MATERIAL_TYPE_STANDARD", n[n.MATERIAL_TYPE_PBR = 1] = "MATERIAL_TYPE_PBR", n[n.MATERIAL_TYPE_SIMPLE = 2] = "MATERIAL_TYPE_SIMPLE";
    }(Cl || (Cl = {})), function(n) {
      n[n.COLOR_MODE_SET = 0] = "COLOR_MODE_SET", n[n.COLOR_MODE_ADD = 1] = "COLOR_MODE_ADD", n[n.COLOR_MODE_MULTIPLY = 2] = "COLOR_MODE_MULTIPLY";
    }(_r || (_r = {})), function(n) {
      n[n.COLOR_DISTRIBUTION_TYPE_SEGMENT = 0] = "COLOR_DISTRIBUTION_TYPE_SEGMENT", n[n.COLOR_DISTRIBUTION_TYPE_LINE = 1] = "COLOR_DISTRIBUTION_TYPE_LINE";
    }(Uo || (Uo = {}));
    var Pn = function() {
      function n() {
      }
      return n.DEFAULT_COLOR = ne.White(), n.DEFAULT_WIDTH_ATTENUATED = 1, n.DEFAULT_WIDTH = 0.1, n;
    }(), Oi = function() {
      function n() {
      }
      return n.ConvertPoints = function(t) {
        if (t.length && Array.isArray(t) && typeof t[0] == "number")
          return [t];
        if (t.length && Array.isArray(t[0]) && typeof t[0][0] == "number")
          return t;
        if (t.length && !Array.isArray(t[0]) && t[0] instanceof v) {
          for (var e = [], i = 0; i < t.length; i++) {
            var r = t[i];
            e.push(r.x, r.y, r.z);
          }
          return [e];
        }
        if (t.length > 0 && Array.isArray(t[0]) && t[0].length > 0 && t[0][0] instanceof v) {
          var o = [];
          return t.forEach(function(s) {
            o.push(s.flatMap(function(l) {
              return [l.x, l.y, l.z];
            }));
          }), o;
        }
        if (t instanceof Float32Array)
          return [Array.from(t)];
        if (t.length && t[0] instanceof Float32Array) {
          var a = [];
          return t.forEach(function(s) {
            a.push(Array.from(s));
          }), a;
        }
        return [];
      }, n.OmitZeroLengthPredicate = function(t, e, i) {
        var r = [];
        return e.subtract(t).lengthSquared() > 0 && r.push([t, e]), i.subtract(e).lengthSquared() > 0 && r.push([e, i]), t.subtract(i).lengthSquared() > 0 && r.push([i, t]), r.length === 0 ? null : r;
      }, n.OmitDuplicatesPredicate = function(t, e, i, r) {
        var o = [];
        return n._SearchInPoints(t, e, r) || o.push([t, e]), n._SearchInPoints(e, i, r) || o.push([e, i]), n._SearchInPoints(i, t, r) || o.push([i, t]), o.length === 0 ? null : o;
      }, n._SearchInPoints = function(t, e, i) {
        for (var r, o, a, s = 0, l = i; s < l.length; s++)
          for (var c = l[s], u = 0; u < c.length; u++)
            if (!((r = c[u]) === null || r === void 0) && r.equals(t) && (!((o = c[u + 1]) === null || o === void 0) && o.equals(e) || !((a = c[u - 1]) === null || a === void 0) && a.equals(e)))
              return !0;
        return !1;
      }, n.MeshesToLines = function(t, e) {
        var i = [];
        return t.forEach(function(r, o) {
          var a = r.getVerticesData(P.PositionKind), s = r.getIndices();
          if (a && s)
            for (var l = 0, c = 0; l < s.length; l++) {
              var u = 3 * s[c++], h = 3 * s[c++], d = 3 * s[c++], p = new v(a[u], a[u + 1], a[u + 2]), f = new v(a[h], a[h + 1], a[h + 2]), m = new v(a[d], a[d + 1], a[d + 2]);
              if (e) {
                var g = e(p, f, m, i, l, u, r, o, a, s);
                if (g)
                  for (var y = 0, b = g; y < b.length; y++) {
                    var T = b[y];
                    i.push(T);
                  }
              } else
                i.push([p, f], [f, m], [m, p]);
            }
        }), i;
      }, n.ToVector3Array = function(t) {
        if (Array.isArray(t[0])) {
          for (var e = [], i = 0, r = t; i < r.length; i++) {
            for (var o = r[i], a = [], s = 0; s < o.length; s += 3)
              a.push(new v(o[s], o[s + 1], o[s + 2]));
            e.push(a);
          }
          return e;
        }
        var l = t, c = [];
        for (s = 0; s < l.length; s += 3)
          c.push(new v(l[s], l[s + 1], l[s + 2]));
        return c;
      }, n.ToNumberArray = function(t) {
        return t.flatMap(function(e) {
          return [e.x, e.y, e.z];
        });
      }, n.GetPointsCountInfo = function(t) {
        for (var e = new Array(t.length), i = 0, r = t.length; r--; )
          e[r] = t[r].length / 3, i += e[r];
        return { total: i, counts: e };
      }, n.GetLineLength = function(t) {
        if (t.length === 0)
          return 0;
        var e;
        e = typeof t[0] == "number" ? n.ToVector3Array(t) : t;
        for (var i = F.Vector3[0], r = 0, o = 0; o < e.length - 1; o++) {
          var a = e[o];
          r += e[o + 1].subtractToRef(a, i).length();
        }
        return r;
      }, n.SegmentizeSegmentByCount = function(t, e, i) {
        var r = [], o = e.subtract(t), a = F.Vector3[0];
        a.setAll(i);
        var s = F.Vector3[1];
        o.divideToRef(a, s);
        var l = t.clone();
        r.push(l);
        for (var c = 0; c < i; c++)
          l = l.clone(), r.push(l.addInPlace(s));
        return r;
      }, n.SegmentizeLineBySegmentLength = function(t, e) {
        var i = t[0] instanceof v ? n.GetLineSegments(t) : typeof t[0] == "number" ? n.GetLineSegments(n.ToVector3Array(t)) : t, r = [];
        return i.forEach(function(o) {
          o.length > e ? n.SegmentizeSegmentByCount(o.point1, o.point2, Math.ceil(o.length / e)).forEach(function(a) {
            r.push(a);
          }) : (r.push(o.point1), r.push(o.point2));
        }), r;
      }, n.SegmentizeLineBySegmentCount = function(t, e) {
        var i = typeof t[0] == "number" ? n.ToVector3Array(t) : t, r = n.GetLineLength(i) / e;
        return n.SegmentizeLineBySegmentLength(i, r);
      }, n.GetLineSegments = function(t) {
        for (var e = [], i = 0; i < t.length - 1; i++) {
          var r = t[i], o = t[i + 1], a = o.subtract(r).length();
          e.push({ point1: r, point2: o, length: a });
        }
        return e;
      }, n.GetMinMaxSegmentLength = function(t) {
        var e = n.GetLineSegments(t).sort(function(i) {
          return i.length;
        });
        return { min: e[0].length, max: e[e.length - 1].length };
      }, n.GetPositionOnLineByVisibility = function(t, e, i, r) {
        r === void 0 && (r = !1);
        for (var o = e * i, a = 0, s = 0, l = t.length, c = 0; c < l; c++) {
          if (o <= a + t[c].length) {
            s = c;
            break;
          }
          a += t[c].length;
        }
        var u = (o - a) / t[s].length;
        return t[s].point2.subtractToRef(t[s].point1, F.Vector3[0]), F.Vector3[1] = F.Vector3[0].multiplyByFloats(u, u, u), r || F.Vector3[1].addInPlace(t[s].point1), F.Vector3[1].clone();
      }, n.GetCircleLinePoints = function(t, e, i, r, o) {
        i === void 0 && (i = 0), r === void 0 && (r = t), o === void 0 && (o = 2 * Math.PI / e);
        for (var a = [], s = 0; s <= e; s++)
          a.push(new v(Math.cos(s * o) * t, Math.sin(s * o) * r, i));
        return a;
      }, n.GetBezierLinePoints = function(t, e, i, r) {
        return Ep.CreateQuadraticBezier(t, e, i, r).getPoints().flatMap(function(o) {
          return [o.x, o.y, o.z];
        });
      }, n.GetArrowCap = function(t, e, i, r, o, a, s) {
        return a === void 0 && (a = 0), s === void 0 && (s = 0), { points: [t.clone(), t.add(e.multiplyByFloats(i, i, i))], widths: [r, o, a, s] };
      }, n.GetPointsFromText = function(t, e, i, r, o, a) {
        o === void 0 && (o = 0), a === void 0 && (a = !0);
        for (var s = [], l = 0, c = Ff(t, e, i, r); l < c.length; l++) {
          for (var u = c[l], h = 0, d = u.paths; h < d.length; h++) {
            for (var p = [], f = 0, m = d[h].getPoints(); f < m.length; f++) {
              var g = m[f];
              p.push(g.x, g.y, o);
            }
            s.push(p);
          }
          if (a)
            for (var y = 0, b = u.holes; y < b.length; y++) {
              for (var T = [], S = 0, E = b[y].getPoints(); S < E.length; S++)
                g = E[S], T.push(g.x, g.y, o);
              s.push(T);
            }
        }
        return s;
      }, n.Color3toRGBAUint8 = function(t) {
        for (var e = new Uint8Array(4 * t.length), i = 0, r = 0; i < t.length; i++)
          e[r++] = 255 * t[i].r, e[r++] = 255 * t[i].g, e[r++] = 255 * t[i].b, e[r++] = 255;
        return e;
      }, n.CreateColorsTexture = function(t, e, i, r) {
        var o = n.Color3toRGBAUint8(e), a = new on(o, e.length, 1, ve.TEXTUREFORMAT_RGBA, r, !1, !0, i);
        return a.name = t, a;
      }, n.PrepareEmptyColorsTexture = function(t) {
        if (!Pn.EmptyColorsTexture) {
          var e = new Uint8Array(4);
          Pn.EmptyColorsTexture = new on(e, 1, 1, ve.TEXTUREFORMAT_RGBA, t, !1, !1, on.NEAREST_NEAREST), Pn.EmptyColorsTexture.name = "grlEmptyColorsTexture";
        }
        return Pn.EmptyColorsTexture;
      }, n.DisposeEmptyColorsTexture = function() {
        var t;
        (t = Pn.EmptyColorsTexture) === null || t === void 0 || t.dispose(), Pn.EmptyColorsTexture = null;
      }, n.BooleanToNumber = function(t) {
        return t ? 1 : 0;
      }, n;
    }(), MT = function(n) {
      function t() {
        var e = n !== null && n.apply(this, arguments) || this;
        return e.GREASED_LINE_HAS_COLOR = !1, e.GREASED_LINE_SIZE_ATTENUATION = !1, e.GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE = !1, e.GREASED_LINE_RIGHT_HANDED_COORDINATE_SYSTEM = !1, e.GREASED_LINE_CAMERA_FACING = !0, e;
      }
      return D(t, n), t;
    }(jn), Pl = function(n) {
      function t(e, i, r) {
        var o, a, s, l, c, u, h, d, p, f, m, g, y, b, T, S, E, A = this;
        r = r || { color: Pn.DEFAULT_COLOR };
        var R = new MT();
        return R.GREASED_LINE_HAS_COLOR = !!r.color && !r.useColors, R.GREASED_LINE_SIZE_ATTENUATION = (o = r.sizeAttenuation) !== null && o !== void 0 && o, R.GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE = r.colorDistributionType === Uo.COLOR_DISTRIBUTION_TYPE_LINE, R.GREASED_LINE_RIGHT_HANDED_COORDINATE_SYSTEM = (i ?? e.getScene()).useRightHandedSystem, R.GREASED_LINE_CAMERA_FACING = (a = r.cameraFacing) === null || a === void 0 || a, (A = n.call(this, e, t.GREASED_LINE_MATERIAL_NAME, 200, R) || this).colorsTexture = null, A._scene = i ?? e.getScene(), A._engine = A._scene.getEngine(), A._cameraFacing = (s = r.cameraFacing) === null || s === void 0 || s, A.visibility = (l = r.visibility) !== null && l !== void 0 ? l : 1, A.useDash = (c = r.useDash) !== null && c !== void 0 && c, A.dashRatio = (u = r.dashRatio) !== null && u !== void 0 ? u : 0.5, A.dashOffset = (h = r.dashOffset) !== null && h !== void 0 ? h : 0, A.width = r.width ? r.width : r.sizeAttenuation ? Pn.DEFAULT_WIDTH_ATTENUATED : Pn.DEFAULT_WIDTH, A._sizeAttenuation = (d = r.sizeAttenuation) !== null && d !== void 0 && d, A.colorMode = (p = r.colorMode) !== null && p !== void 0 ? p : _r.COLOR_MODE_SET, A._color = (f = r.color) !== null && f !== void 0 ? f : null, A.useColors = (m = r.useColors) !== null && m !== void 0 && m, A._colorsDistributionType = (g = r.colorDistributionType) !== null && g !== void 0 ? g : Uo.COLOR_DISTRIBUTION_TYPE_SEGMENT, A.colorsSampling = (y = r.colorsSampling) !== null && y !== void 0 ? y : on.NEAREST_NEAREST, A._colors = (b = r.colors) !== null && b !== void 0 ? b : null, A.dashCount = (T = r.dashCount) !== null && T !== void 0 ? T : 1, A.resolution = (S = r.resolution) !== null && S !== void 0 ? S : new fe(A._engine.getRenderWidth(), A._engine.getRenderHeight()), r.colorsTexture ? A.colorsTexture = r.colorsTexture : A._colors ? A.colorsTexture = Oi.CreateColorsTexture("".concat(e.name, "-colors-texture"), A._colors, A.colorsSampling, A._scene) : (A._color = (E = A._color) !== null && E !== void 0 ? E : Pn.DEFAULT_COLOR, Oi.PrepareEmptyColorsTexture(A._scene)), A._engine.onDisposeObservable.add(function() {
          Oi.DisposeEmptyColorsTexture();
        }), A._enable(!0), A;
      }
      return D(t, n), t.prototype.getAttributes = function(e) {
        e.push("grl_offsets"), e.push("grl_widths"), e.push("grl_colorPointers"), e.push("grl_counters"), this._cameraFacing ? (e.push("grl_previousAndSide"), e.push("grl_nextAndCounters")) : e.push("grl_slopes");
      }, t.prototype.getSamplers = function(e) {
        e.push("grl_colors");
      }, t.prototype.getActiveTextures = function(e) {
        this.colorsTexture && e.push(this.colorsTexture);
      }, t.prototype.getUniforms = function() {
        var e = [{ name: "grl_singleColor", size: 3, type: "vec3" }, { name: "grl_dashOptions", size: 4, type: "vec4" }, { name: "grl_colorMode_visibility_colorsWidth_useColors", size: 4, type: "vec4" }];
        return this._cameraFacing && e.push({ name: "grl_projection", size: 16, type: "mat4" }, { name: "grl_aspect_resolution_lineWidth", size: 4, type: "vec4" }), { ubo: e, vertex: this._cameraFacing ? `
                uniform vec4 grl_aspect_resolution_lineWidth;
                uniform mat4 grl_projection;
                ` : "", fragment: `
                uniform vec4 grl_dashOptions;
                uniform vec4 grl_colorMode_visibility_colorsWidth_useColors;
                uniform vec3 grl_singleColor;
                ` };
      }, Object.defineProperty(t.prototype, "isEnabled", { get: function() {
        return !0;
      }, enumerable: !1, configurable: !0 }), t.prototype.bindForSubMesh = function(e) {
        var i;
        if (this._cameraFacing) {
          var r = this._scene.activeCamera;
          if (!r)
            throw Error("GreasedLinePluginMaterial requires an active camera.");
          var o = r.getProjectionMatrix();
          e.updateMatrix("grl_projection", o);
          var a = F.Vector4[0];
          a.x = this._aspect, a.y = this._resolution.x, a.z = this._resolution.y, a.w = this.width, e.updateVector4("grl_aspect_resolution_lineWidth", a);
        }
        var s = F.Vector4[0];
        s.x = Oi.BooleanToNumber(this.useDash), s.y = this._dashArray, s.z = this.dashOffset, s.w = this.dashRatio, e.updateVector4("grl_dashOptions", s);
        var l = F.Vector4[1];
        l.x = this.colorMode, l.y = this.visibility, l.z = this.colorsTexture ? this.colorsTexture.getSize().width : 0, l.w = Oi.BooleanToNumber(this.useColors), e.updateVector4("grl_colorMode_visibility_colorsWidth_useColors", l), this._color && e.updateColor3("grl_singleColor", this._color), e.setTexture("grl_colors", (i = this.colorsTexture) !== null && i !== void 0 ? i : Pn.EmptyColorsTexture);
      }, t.prototype.prepareDefines = function(e, i, r) {
        e.GREASED_LINE_HAS_COLOR = !!this.color && !this.useColors, e.GREASED_LINE_SIZE_ATTENUATION = this._sizeAttenuation, e.GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE = this._colorsDistributionType === Uo.COLOR_DISTRIBUTION_TYPE_LINE, e.GREASED_LINE_RIGHT_HANDED_COORDINATE_SYSTEM = i.useRightHandedSystem, e.GREASED_LINE_CAMERA_FACING = this._cameraFacing;
      }, t.prototype.getClassName = function() {
        return t.GREASED_LINE_MATERIAL_NAME;
      }, t.prototype.getCustomCode = function(e) {
        if (e === "vertex") {
          var i = { CUSTOM_VERTEX_DEFINITIONS: `
                attribute float grl_widths;
                attribute vec3 grl_offsets;
                attribute float grl_colorPointers;

                varying float grlCounters;
                varying float grlColorPointer;

                #ifdef GREASED_LINE_CAMERA_FACING
                    attribute vec4 grl_previousAndSide;
                    attribute vec4 grl_nextAndCounters;

                    vec2 grlFix( vec4 i, float aspect ) {
                        vec2 res = i.xy / i.w;
                        res.x *= aspect;
                        return res;
                    }
                #else
                    attribute vec3 grl_slopes;
                    attribute float grl_counters;
                #endif
                `, CUSTOM_VERTEX_UPDATE_POSITION: `
                #ifdef GREASED_LINE_CAMERA_FACING
                    vec3 grlPositionOffset = grl_offsets;
                    positionUpdated += grlPositionOffset;
                #else
                    positionUpdated = (positionUpdated + grl_offsets) + (grl_slopes * grl_widths);
                #endif
                `, CUSTOM_VERTEX_MAIN_END: `
                grlColorPointer = grl_colorPointers;

                #ifdef GREASED_LINE_CAMERA_FACING

                    float grlAspect = grl_aspect_resolution_lineWidth.x;
                    float grlBaseWidth = grl_aspect_resolution_lineWidth.w;


                    vec3 grlPrevious = grl_previousAndSide.xyz;
                    float grlSide = grl_previousAndSide.w;

                    vec3 grlNext = grl_nextAndCounters.xyz;
                    grlCounters = grl_nextAndCounters.w;

                    mat4 grlMatrix = viewProjection * finalWorld;
                    vec4 grlFinalPosition = grlMatrix * vec4( positionUpdated , 1.0 );
                    vec4 grlPrevPos = grlMatrix * vec4( grlPrevious + grlPositionOffset, 1.0 );
                    vec4 grlNextPos = grlMatrix * vec4( grlNext + grlPositionOffset, 1.0 );

                    vec2 grlCurrentP = grlFix( grlFinalPosition, grlAspect );
                    vec2 grlPrevP = grlFix( grlPrevPos, grlAspect );
                    vec2 grlNextP = grlFix( grlNextPos, grlAspect );

                    float grlWidth = grlBaseWidth * grl_widths;

                    vec2 grlDir;
                    if( grlNextP == grlCurrentP ) grlDir = normalize( grlCurrentP - grlPrevP );
                    else if( grlPrevP == grlCurrentP ) grlDir = normalize( grlNextP - grlCurrentP );
                    else {
                        vec2 grlDir1 = normalize( grlCurrentP - grlPrevP );
                        vec2 grlDir2 = normalize( grlNextP - grlCurrentP );
                        grlDir = normalize( grlDir1 + grlDir2 );
                    }
                    vec4 grlNormal = vec4( -grlDir.y, grlDir.x, 0., 1. );
                    #ifdef GREASED_LINE_RIGHT_HANDED_COORDINATE_SYSTEM
                        grlNormal.xy *= -.5 * grlWidth;
                    #else
                        grlNormal.xy *= .5 * grlWidth;
                    #endif

                    grlNormal *= grl_projection;

                    #ifdef GREASED_LINE_SIZE_ATTENUATION
                        grlNormal.xy *= grlFinalPosition.w;
                        grlNormal.xy /= ( vec4( grl_aspect_resolution_lineWidth.yz, 0., 1. ) * grl_projection ).xy;
                    #endif

                    grlFinalPosition.xy += grlNormal.xy * grlSide;
                    gl_Position = grlFinalPosition;

                    vPositionW = vec3(grlFinalPosition);
                #else
                    grlCounters = grl_counters;
                #endif
                ` };
          return this._cameraFacing && (i["!gl_Position\\=viewProjection\\*worldPos;"] = "//"), i;
        }
        return e === "fragment" ? { CUSTOM_FRAGMENT_DEFINITIONS: `
                    varying float grlCounters;
                    varying float grlColorPointer;
                    uniform sampler2D grl_colors;
                `, CUSTOM_FRAGMENT_MAIN_END: `
                    float grlColorMode = grl_colorMode_visibility_colorsWidth_useColors.x;
                    float grlVisibility = grl_colorMode_visibility_colorsWidth_useColors.y;
                    float grlColorsWidth = grl_colorMode_visibility_colorsWidth_useColors.z;
                    float grlUseColors = grl_colorMode_visibility_colorsWidth_useColors.w;

                    float grlUseDash = grl_dashOptions.x;
                    float grlDashArray = grl_dashOptions.y;
                    float grlDashOffset = grl_dashOptions.z;
                    float grlDashRatio = grl_dashOptions.w;

                    gl_FragColor.a *= step(grlCounters, grlVisibility);
                    if( gl_FragColor.a == 0. ) discard;

                    if(grlUseDash == 1.){
                        gl_FragColor.a *= ceil(mod(grlCounters + grlDashOffset, grlDashArray) - (grlDashArray * grlDashRatio));
                        if (gl_FragColor.a == 0.) discard;
                    }

                    #ifdef GREASED_LINE_HAS_COLOR
                        if (grlColorMode == `.concat(_r.COLOR_MODE_SET, `.) {
                            gl_FragColor.rgb = grl_singleColor;
                        } else if (grlColorMode == `).concat(_r.COLOR_MODE_ADD, `.) {
                            gl_FragColor.rgb += grl_singleColor;
                        } else if (grlColorMode == `).concat(_r.COLOR_MODE_MULTIPLY, `.) {
                            gl_FragColor.rgb *= grl_singleColor;
                        }
                    #else
                        if (grlUseColors == 1.) {
                            #ifdef GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE
                                vec4 grlColor = texture2D(grl_colors, vec2(grlCounters, 0.), 0.);
                            #else
                                vec4 grlColor = texture2D(grl_colors, vec2(grlColorPointer/grlColorsWidth, 0.), 0.);
                            #endif
                            if (grlColorMode == `).concat(_r.COLOR_MODE_SET, `.) {
                                gl_FragColor = grlColor;
                            } else if (grlColorMode == `).concat(_r.COLOR_MODE_ADD, `.) {
                                gl_FragColor += grlColor;
                            } else if (grlColorMode == `).concat(_r.COLOR_MODE_MULTIPLY, `.) {
                                gl_FragColor *= grlColor;
                            }
                        }
                    #endif

                `) } : null;
      }, t.prototype.dispose = function() {
        var e;
        (e = this.colorsTexture) === null || e === void 0 || e.dispose(), n.prototype.dispose.call(this);
      }, Object.defineProperty(t.prototype, "colors", { get: function() {
        return this._colors;
      }, set: function(e) {
        this.setColors(e);
      }, enumerable: !1, configurable: !0 }), t.prototype.setColors = function(e, i, r) {
        var o, a, s, l;
        i === void 0 && (i = !1), r === void 0 && (r = !1);
        var c = (a = (o = this._colors) === null || o === void 0 ? void 0 : o.length) !== null && a !== void 0 ? a : 0;
        if (this._colors = e, e !== null && e.length !== 0) {
          if (!i || r)
            if (this.colorsTexture && c === e.length && !r) {
              var u = Oi.Color3toRGBAUint8(e);
              this.colorsTexture.update(u);
            } else
              (l = this.colorsTexture) === null || l === void 0 || l.dispose(), this.colorsTexture = Oi.CreateColorsTexture("".concat(this._material.name, "-colors-texture"), e, this.colorsSampling, this._scene);
        } else
          (s = this.colorsTexture) === null || s === void 0 || s.dispose();
      }, t.prototype.updateLazy = function() {
        this._colors && this.setColors(this._colors, !1, !0);
      }, Object.defineProperty(t.prototype, "dashCount", { get: function() {
        return this._dashCount;
      }, set: function(e) {
        this._dashCount = e, this._dashArray = 1 / e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "sizeAttenuation", { get: function() {
        return this._sizeAttenuation;
      }, set: function(e) {
        this._sizeAttenuation = e, this.markAllDefinesAsDirty();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "color", { get: function() {
        return this._color;
      }, set: function(e) {
        this.setColor(e);
      }, enumerable: !1, configurable: !0 }), t.prototype.setColor = function(e, i) {
        i === void 0 && (i = !1), this._color === null && e !== null || this._color !== null && e === null ? (this._color = e, !i && this.markAllDefinesAsDirty()) : this._color = e;
      }, Object.defineProperty(t.prototype, "colorsDistributionType", { get: function() {
        return this._colorsDistributionType;
      }, set: function(e) {
        this._colorsDistributionType = e, this.markAllDefinesAsDirty();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "resolution", { get: function() {
        return this._resolution;
      }, set: function(e) {
        this._aspect = e.x / e.y, this._resolution = e;
      }, enumerable: !1, configurable: !0 }), t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this), i = { colorDistributionType: this._colorsDistributionType, colorsSampling: this.colorsSampling, colorMode: this.colorMode, dashCount: this._dashCount, dashOffset: this.dashOffset, dashRatio: this.dashRatio, resolution: this._resolution, sizeAttenuation: this._sizeAttenuation, useColors: this.useColors, useDash: this.useDash, visibility: this.visibility, width: this.width };
        return this._colors && (i.colors = this._colors), this._color && (i.color = this._color), e.greasedLineMaterialOptions = i, e;
      }, t.prototype.parse = function(e, i, r) {
        var o;
        n.prototype.parse.call(this, e, i, r);
        var a = e.greasedLineMaterialOptions;
        (o = this.colorsTexture) === null || o === void 0 || o.dispose(), a.color && this.setColor(a.color, !0), a.colorDistributionType && (this.colorsDistributionType = a.colorDistributionType), a.colors && (this.colors = a.colors), a.colorsSampling && (this.colorsSampling = a.colorsSampling), a.colorMode && (this.colorMode = a.colorMode), a.useColors && (this.useColors = a.useColors), a.visibility && (this.visibility = a.visibility), a.useDash && (this.useDash = a.useDash), a.dashCount && (this.dashCount = a.dashCount), a.dashRatio && (this.dashRatio = a.dashRatio), a.dashOffset && (this.dashOffset = a.dashOffset), a.width && (this.width = a.width), a.sizeAttenuation && (this.sizeAttenuation = a.sizeAttenuation), a.resolution && (this.resolution = a.resolution), this.colors ? this.colorsTexture = Oi.CreateColorsTexture("".concat(this._material.name, "-colors-texture"), this.colors, this.colorsSampling, i) : Oi.PrepareEmptyColorsTexture(i), this.markAllDefinesAsDirty();
      }, t.prototype.copyTo = function(e) {
        var i, r = e;
        (i = r.colorsTexture) === null || i === void 0 || i.dispose(), this._colors && (r.colorsTexture = Oi.CreateColorsTexture("".concat(r._material.name, "-colors-texture"), this._colors, r.colorsSampling, this._scene)), r.setColor(this.color, !0), r.colorsDistributionType = this.colorsDistributionType, r.colorsSampling = this.colorsSampling, r.colorMode = this.colorMode, r.useColors = this.useColors, r.visibility = this.visibility, r.useDash = this.useDash, r.dashCount = this.dashCount, r.dashRatio = this.dashRatio, r.dashOffset = this.dashOffset, r.width = this.width, r.sizeAttenuation = this.sizeAttenuation, r.resolution = this.resolution, r.markAllDefinesAsDirty();
      }, t.GREASED_LINE_MATERIAL_NAME = "GreasedLinePluginMaterial", t;
    }($r);
    j("BABYLON.".concat(Pl.GREASED_LINE_MATERIAL_NAME), Pl), re.ShadersStore.greasedLinePixelShader = `precision highp float;uniform sampler2D grlColors;uniform float grlUseColors;uniform float grlUseDash;uniform float grlDashArray;uniform float grlDashOffset;uniform float grlDashRatio;uniform float grlVisibility;uniform float grlColorsWidth;uniform vec2 grl_colorModeAndColorDistributionType;uniform vec3 grlColor;varying float grlCounters;varying float grlColorPointer;void main() {float grlColorMode=grl_colorModeAndColorDistributionType.x;float grlColorDistributionType=grl_colorModeAndColorDistributionType.y;gl_FragColor=vec4(grlColor,1.);gl_FragColor.a=step(grlCounters,grlVisibility);if (gl_FragColor.a==0.) discard;if( grlUseDash==1. ){gl_FragColor.a=ceil(mod(grlCounters+grlDashOffset,grlDashArray)-(grlDashArray*grlDashRatio));if (gl_FragColor.a==0.) discard;}
if (grlUseColors==1.) {vec4 textureColor;if (grlColorDistributionType==COLOR_DISTRIBUTION_TYPE_LINE) { 
textureColor=texture2D(grlColors,vec2(grlCounters,0.),0.);} else {textureColor=texture2D(grlColors,vec2(grlColorPointer/grlColorsWidth,0.),0.);}
if (grlColorMode==COLOR_MODE_SET) {gl_FragColor=textureColor;} else if (grlColorMode==COLOR_MODE_ADD) {gl_FragColor+=textureColor;} else if (grlColorMode==COLOR_MODE_MULTIPLY) {gl_FragColor*=textureColor;}}}
`, re.ShadersStore.greasedLineVertexShader = `precision highp float;
#include<instancesDeclaration>
attribute float grl_widths;attribute vec3 grl_offsets;attribute float grl_colorPointers;attribute vec3 position;uniform mat4 viewProjection;uniform mat4 projection;varying float grlCounters;varying float grlColorPointer;
#ifdef GREASED_LINE_CAMERA_FACING
attribute vec4 grl_nextAndCounters;attribute vec4 grl_previousAndSide;uniform vec2 grlResolution;uniform float grlAspect;uniform float grlWidth;uniform float grlSizeAttenuation;vec2 grlFix( vec4 i,float aspect ) {vec2 res=i.xy/i.w;res.x*=aspect;return res;}
#else
attribute vec3 grl_slopes;attribute float grl_counters;
#endif
void main() {
#include<instancesVertex>
grlColorPointer=grl_colorPointers;
#ifdef GREASED_LINE_CAMERA_FACING
float grlBaseWidth=grlWidth;vec3 grlPrevious=grl_previousAndSide.xyz;float grlSide=grl_previousAndSide.w;vec3 grlNext=grl_nextAndCounters.xyz;grlCounters=grl_nextAndCounters.w;mat4 grlMatrix=viewProjection*finalWorld ;vec3 grlPositionOffset=grl_offsets;vec4 grlFinalPosition=grlMatrix*vec4( position+grlPositionOffset ,1.0 );vec4 grlPrevPos=grlMatrix*vec4( grlPrevious+grlPositionOffset,1.0 );vec4 grlNextPos=grlMatrix*vec4( grlNext+grlPositionOffset,1.0 );vec2 grlCurrentP=grlFix( grlFinalPosition,grlAspect );vec2 grlPrevP=grlFix( grlPrevPos,grlAspect );vec2 grlNextP=grlFix( grlNextPos,grlAspect );float grlWidth=grlBaseWidth*grl_widths;vec2 grlDir;if( grlNextP==grlCurrentP ) grlDir=normalize( grlCurrentP-grlPrevP );else if( grlPrevP==grlCurrentP ) grlDir=normalize( grlNextP-grlCurrentP );else {vec2 grlDir1=normalize( grlCurrentP-grlPrevP );vec2 grlDir2=normalize( grlNextP-grlCurrentP );grlDir=normalize( grlDir1+grlDir2 );}
vec4 grlNormal=vec4( -grlDir.y,grlDir.x,0.,1. );
#ifdef GREASED_LINE_RIGHT_HANDED_COORDINATE_SYSTEM
grlNormal.xy*=-.5*grlWidth;
#else
grlNormal.xy*=.5*grlWidth;
#endif
grlNormal*=projection;if (grlSizeAttenuation==1.) {grlNormal.xy*=grlFinalPosition.w;grlNormal.xy/=( vec4( grlResolution,0.,1. )*projection ).xy;}
grlFinalPosition.xy+=grlNormal.xy*grlSide;gl_Position=grlFinalPosition;
#else
grlCounters=grl_counters;vec4 grlFinalPosition=worldViewProjection*vec4( (position+grl_offsets)+grl_slopes*grl_widths ,1.0 ) ;gl_Position=grlFinalPosition;
#endif
}
`;
    var Ms, z_ = function(n) {
      function t(e, i, r) {
        var o, a, s, l, c, u, h, d, p, f, m, g, y, b, T = this, S = ["COLOR_DISTRIBUTION_TYPE_LINE ".concat(Uo.COLOR_DISTRIBUTION_TYPE_LINE, "."), "COLOR_DISTRIBUTION_TYPE_SEGMENT ".concat(Uo.COLOR_DISTRIBUTION_TYPE_SEGMENT, "."), "COLOR_MODE_SET ".concat(_r.COLOR_MODE_SET, "."), "COLOR_MODE_ADD ".concat(_r.COLOR_MODE_ADD, "."), "COLOR_MODE_MULTIPLY ".concat(_r.COLOR_MODE_MULTIPLY, ".")], E = ["position", "grl_widths", "grl_offsets", "grl_colorPointers"];
        i.useRightHandedSystem && S.push("GREASED_LINE_RIGHT_HANDED_COORDINATE_SYSTEM"), r.cameraFacing ? (S.push("GREASED_LINE_CAMERA_FACING"), E.push("grl_previousAndSide", "grl_nextAndCounters")) : (E.push("grl_slopes"), E.push("grl_counters")), (T = n.call(this, e, i, { vertex: "greasedLine", fragment: "greasedLine" }, { attributes: E, uniforms: ["world", "viewProjection", "view", "projection", "grlColorsWidth", "grlUseColors", "grlWidth", "grlColor", "grl_colorModeAndColorDistributionType", "grlResolution", "grlAspect", "grlAizeAttenuation", "grlDashArray", "grlDashOffset", "grlDashRatio", "grlUseDash", "grlVisibility"], samplers: ["grlColors"], defines: S }) || this)._color = ne.White(), T._colorsDistributionType = Uo.COLOR_DISTRIBUTION_TYPE_SEGMENT, T._colorsTexture = null, r = r || { color: Pn.DEFAULT_COLOR };
        var A = i.getEngine();
        return T.visibility = (o = r.visibility) !== null && o !== void 0 ? o : 1, T.useDash = (a = r.useDash) !== null && a !== void 0 && a, T.dashRatio = (s = r.dashRatio) !== null && s !== void 0 ? s : 0.5, T.dashOffset = (l = r.dashOffset) !== null && l !== void 0 ? l : 0, T.dashCount = (c = r.dashCount) !== null && c !== void 0 ? c : 1, T.width = r.width ? r.width : r.sizeAttenuation && r.cameraFacing ? Pn.DEFAULT_WIDTH_ATTENUATED : Pn.DEFAULT_WIDTH, T.sizeAttenuation = (u = r.sizeAttenuation) !== null && u !== void 0 && u, T.color = (h = r.color) !== null && h !== void 0 ? h : ne.White(), T.useColors = (d = r.useColors) !== null && d !== void 0 && d, T.colorsDistributionType = (p = r.colorDistributionType) !== null && p !== void 0 ? p : Uo.COLOR_DISTRIBUTION_TYPE_SEGMENT, T.colorsSampling = (f = r.colorsSampling) !== null && f !== void 0 ? f : on.NEAREST_NEAREST, T.colorMode = (m = r.colorMode) !== null && m !== void 0 ? m : _r.COLOR_MODE_SET, T._colors = (g = r.colors) !== null && g !== void 0 ? g : null, T._cameraFacing = (y = r.cameraFacing) === null || y === void 0 || y, T.resolution = (b = r.resolution) !== null && b !== void 0 ? b : new fe(A.getRenderWidth(), A.getRenderHeight()), r.colorsTexture ? T.colorsTexture = r.colorsTexture : T.colorsTexture = Oi.PrepareEmptyColorsTexture(i), T._colors && T.setColors(T._colors), A.onDisposeObservable.add(function() {
          Oi.DisposeEmptyColorsTexture();
        }), T;
      }
      return D(t, n), t.prototype.dispose = function() {
        var e;
        (e = this._colorsTexture) === null || e === void 0 || e.dispose(), n.prototype.dispose.call(this);
      }, t.prototype._setColorModeAndColorDistributionType = function() {
        this.setVector2("grl_colorModeAndColorDistributionType", new fe(this._colorMode, this._colorsDistributionType));
      }, t.prototype.updateLazy = function() {
        this._colors && this.setColors(this._colors, !1, !0);
      }, Object.defineProperty(t.prototype, "colors", { get: function() {
        return this._colors;
      }, set: function(e) {
        this.setColors(e);
      }, enumerable: !1, configurable: !0 }), t.prototype.setColors = function(e, i, r) {
        var o, a, s, l;
        i === void 0 && (i = !1), r === void 0 && (r = !1);
        var c = (a = (o = this._colors) === null || o === void 0 ? void 0 : o.length) !== null && a !== void 0 ? a : 0;
        if (this._colors = e, e !== null && e.length !== 0) {
          if (!i || r)
            if (this._colorsTexture && c === e.length && !r) {
              var u = Oi.Color3toRGBAUint8(e);
              this._colorsTexture.update(u);
            } else
              (l = this._colorsTexture) === null || l === void 0 || l.dispose(), this.colorsTexture = Oi.CreateColorsTexture("".concat(this.name, "-colors-texture"), e, this.colorsSampling, this.getScene());
        } else
          (s = this._colorsTexture) === null || s === void 0 || s.dispose();
      }, Object.defineProperty(t.prototype, "colorsTexture", { get: function() {
        var e;
        return (e = this._colorsTexture) !== null && e !== void 0 ? e : null;
      }, set: function(e) {
        this._colorsTexture = e, this.setFloat("grlColorsWidth", this._colorsTexture.getSize().width), this.setTexture("grlColors", this._colorsTexture);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "width", { get: function() {
        return this._width;
      }, set: function(e) {
        this._width = e, this.setFloat("grlWidth", e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "useColors", { get: function() {
        return this._useColors;
      }, set: function(e) {
        this._useColors = e, this.setFloat("grlUseColors", Oi.BooleanToNumber(e));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "colorsSampling", { get: function() {
        return this._colorsSampling;
      }, set: function(e) {
        this._colorsSampling = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "visibility", { get: function() {
        return this._visibility;
      }, set: function(e) {
        this._visibility = e, this.setFloat("grlVisibility", e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "useDash", { get: function() {
        return this._useDash;
      }, set: function(e) {
        this._useDash = e, this.setFloat("grlUseDash", Oi.BooleanToNumber(e));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dashOffset", { get: function() {
        return this._dashOffset;
      }, set: function(e) {
        this._dashOffset = e, this.setFloat("grlDashOffset", e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dashRatio", { get: function() {
        return this._dashRatio;
      }, set: function(e) {
        this._dashRatio = e, this.setFloat("grlDashRatio", e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dashCount", { get: function() {
        return this._dashCount;
      }, set: function(e) {
        this._dashCount = e, this._dashArray = 1 / e, this.setFloat("grlDashArray", this._dashArray);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "sizeAttenuation", { get: function() {
        return this._sizeAttenuation;
      }, set: function(e) {
        this._sizeAttenuation = e, this.setFloat("grlSizeAttenuation", Oi.BooleanToNumber(e));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "color", { get: function() {
        return this.color;
      }, set: function(e) {
        this.setColor(e);
      }, enumerable: !1, configurable: !0 }), t.prototype.setColor = function(e) {
        e = e ?? Pn.DEFAULT_COLOR, this._color = e, this.setColor3("grlColor", e);
      }, Object.defineProperty(t.prototype, "colorsDistributionType", { get: function() {
        return this._colorsDistributionType;
      }, set: function(e) {
        this._colorsDistributionType = e, this._setColorModeAndColorDistributionType();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "colorMode", { get: function() {
        return this._colorMode;
      }, set: function(e) {
        this._colorMode = e, this._setColorModeAndColorDistributionType();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "resolution", { get: function() {
        return this._resolution;
      }, set: function(e) {
        this._resolution = e, this.setVector2("grlResolution", e), this.setFloat("grlAspect", e.x / e.y);
      }, enumerable: !1, configurable: !0 }), t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this), i = { colorDistributionType: this._colorsDistributionType, colorsSampling: this._colorsSampling, colorMode: this._colorMode, color: this._color, dashCount: this._dashCount, dashOffset: this._dashOffset, dashRatio: this._dashRatio, resolution: this._resolution, sizeAttenuation: this._sizeAttenuation, useColors: this._useColors, useDash: this._useDash, visibility: this._visibility, width: this._width, cameraFacing: this._cameraFacing };
        return this._colors && (i.colors = this._colors), e.greasedLineMaterialOptions = i, e;
      }, t.prototype.parse = function(e, i, r) {
        var o, a, s = e.greasedLineMaterialOptions;
        (o = this._colorsTexture) === null || o === void 0 || o.dispose(), s.color && (this.color = s.color), s.colorDistributionType && (this.colorsDistributionType = s.colorDistributionType), s.colorsSampling && (this.colorsSampling = s.colorsSampling), s.colorMode && (this.colorMode = s.colorMode), s.useColors && (this.useColors = s.useColors), s.visibility && (this.visibility = s.visibility), s.useDash && (this.useDash = s.useDash), s.dashCount && (this.dashCount = s.dashCount), s.dashRatio && (this.dashRatio = s.dashRatio), s.dashOffset && (this.dashOffset = s.dashOffset), s.width && (this.width = s.width), s.sizeAttenuation && (this.sizeAttenuation = s.sizeAttenuation), s.resolution && (this.resolution = s.resolution), s.colors ? this.colorsTexture = Oi.CreateColorsTexture("".concat(this.name, "-colors-texture"), s.colors, this.colorsSampling, this.getScene()) : this.colorsTexture = Oi.PrepareEmptyColorsTexture(i), this._cameraFacing = (a = s.cameraFacing) === null || a === void 0 || a, this.setDefine("GREASED_LINE_CAMERA_FACING", this._cameraFacing);
      }, t;
    }(dr), yP = [new ne(0.98, 0.26, 0.38), new ne(0.47, 0.75, 0.3), new ne(0, 0.26, 0.77), new ne(0.97, 0.6, 0.76), new ne(0.19, 0.63, 0.78), new ne(0.98, 0.8, 0.6), new ne(0.65, 0.43, 0.15), new ne(0.15, 0.47, 0.22), new ne(0.67, 0.71, 0.86), new ne(0.09, 0.46, 0.56), new ne(0.8, 0.98, 0.02), new ne(0.39, 0.29, 0.13), new ne(0.53, 0.63, 0.06), new ne(0.95, 0.96, 0.41), new ne(1, 0.72, 0.94), new ne(0.63, 0.08, 0.31), new ne(0.66, 0.96, 0.95), new ne(0.22, 0.14, 0.19), new ne(0.14, 0.65, 0.59), new ne(0.93, 1, 0.68), new ne(0.93, 0.14, 0.44), new ne(0.47, 0.86, 0.67), new ne(0.85, 0.07, 0.78), new ne(0.53, 0.64, 0.98), new ne(0.43, 0.37, 0.56), new ne(0.71, 0.65, 0.25), new ne(0.66, 0.19, 0.01), new ne(0.94, 0.53, 0.12), new ne(0.41, 0.44, 0.44), new ne(0.24, 0.71, 0.96), new ne(0.57, 0.28, 0.56), new ne(0.44, 0.98, 0.42)];
    (function(n) {
      n[n.NONE = 0] = "NONE", n[n.TRIANGLES = 1] = "TRIANGLES", n[n.VERTICES = 2] = "VERTICES", n[n.TRIANGLES_VERTICES = 3] = "TRIANGLES_VERTICES", n[n.UV0 = 4] = "UV0", n[n.UV1 = 5] = "UV1", n[n.VERTEXCOLORS = 6] = "VERTEXCOLORS", n[n.MATERIALIDS = 7] = "MATERIALIDS";
    })(Ms || (Ms = {}));
    var uN = function(n) {
      function t() {
        var e = n !== null && n.apply(this, arguments) || this;
        return e.DBG_MODE = Ms.NONE, e.DBG_MULTIPLY = !0, e.DBG_ENABLED = !0, e;
      }
      return D(t, n), t;
    }(jn), OT = function(n) {
      function t(e, i) {
        i === void 0 && (i = {});
        var r, o, a, s, l, c, u, h, d, p, f, m, g, y = this, b = new uN();
        return b.DBG_MODE = (r = i.mode) !== null && r !== void 0 ? r : b.DBG_MODE, b.DBG_MULTIPLY = (o = i.multiply) !== null && o !== void 0 ? o : b.DBG_MULTIPLY, (y = n.call(this, e, "MeshDebug", 200, b, !0, !0) || this)._mode = b.DBG_MODE, y._multiply = b.DBG_MULTIPLY, y.shadedDiffuseColor = (a = i.shadedDiffuseColor) !== null && a !== void 0 ? a : new ne(1, 1, 1), y.shadedSpecularColor = (s = i.shadedSpecularColor) !== null && s !== void 0 ? s : new ne(0.8, 0.8, 0.8), y.shadedSpecularPower = (l = i.shadedSpecularPower) !== null && l !== void 0 ? l : 10, y.wireframeThickness = (c = i.wireframeThickness) !== null && c !== void 0 ? c : 0.7, y.wireframeTrianglesColor = (u = i.wireframeTrianglesColor) !== null && u !== void 0 ? u : new ne(0, 0, 0), y.wireframeVerticesColor = (h = i.wireframeVerticesColor) !== null && h !== void 0 ? h : new ne(0.8, 0.8, 0.8), y.vertexColor = (d = i.vertexColor) !== null && d !== void 0 ? d : new ne(0, 0, 0), y.vertexRadius = (p = i.vertexRadius) !== null && p !== void 0 ? p : 1.2, y.uvScale = (f = i.uvScale) !== null && f !== void 0 ? f : 20, y.uvPrimaryColor = (m = i.uvPrimaryColor) !== null && m !== void 0 ? m : new ne(1, 1, 1), y.uvSecondaryColor = (g = i.uvSecondaryColor) !== null && g !== void 0 ? g : new ne(0.5, 0.5, 0.5), y._materialColor = t.MaterialColors[t._PluginCount++ % t.MaterialColors.length], y.isEnabled = !0, y;
      }
      return D(t, n), t.prototype._markAllDefinesAsDirty = function() {
        this._enable(this._isEnabled), this.markAllDefinesAsDirty();
      }, t.prototype.getClassName = function() {
        return "MeshDebugPluginMaterial";
      }, Object.defineProperty(t.prototype, "isEnabled", { get: function() {
        return this._isEnabled;
      }, set: function(e) {
        if (this._isEnabled !== e) {
          if (!this._material.getScene().getEngine().isWebGPU && this._material.getScene().getEngine().webGLVersion == 1)
            return q.Error("MeshDebugPluginMaterial is not supported on WebGL 1.0."), void (this._isEnabled = !1);
          this._isEnabled = e, this._markAllDefinesAsDirty();
        }
      }, enumerable: !1, configurable: !0 }), t.prototype.prepareDefines = function(e, i, r) {
        this._mode != Ms.VERTICES && this._mode != Ms.TRIANGLES && this._mode != Ms.TRIANGLES_VERTICES || r.isVerticesDataPresent("dbg_initialPass") || q.Warn("For best results with TRIANGLES, TRIANGLES_VERTICES, or VERTICES modes, please use MeshDebugPluginMaterial.PrepareMeshForTrianglesAndVerticesMode() on mesh.", 1), e.DBG_MODE = this._mode, e.DBG_MULTIPLY = this._multiply, e.DBG_ENABLED = this._isEnabled;
      }, t.prototype.getAttributes = function(e) {
        e.push("dbg_initialPass");
      }, t.prototype.getUniforms = function() {
        return { ubo: [{ name: "dbg_shadedDiffuseColor", size: 3, type: "vec3" }, { name: "dbg_shadedSpecularColorPower", size: 4, type: "vec4" }, { name: "dbg_thicknessRadiusScale", size: 3, type: "vec3" }, { name: "dbg_wireframeTrianglesColor", size: 3, type: "vec3" }, { name: "dbg_wireframeVerticesColor", size: 3, type: "vec3" }, { name: "dbg_vertexColor", size: 3, type: "vec3" }, { name: "dbg_uvPrimaryColor", size: 3, type: "vec3" }, { name: "dbg_uvSecondaryColor", size: 3, type: "vec3" }, { name: "dbg_materialColor", size: 3, type: "vec3" }], fragment: `#if defined(DBG_ENABLED)
uniform vec3 dbg_shadedDiffuseColor;
uniform vec4 dbg_shadedSpecularColorPower;
uniform vec3 dbg_thicknessRadiusScale;

#if DBG_MODE == 2 || DBG_MODE == 3
    uniform vec3 dbg_vertexColor;
#endif

#if DBG_MODE == 1
    uniform vec3 dbg_wireframeTrianglesColor;
#elif DBG_MODE == 3
    uniform vec3 dbg_wireframeVerticesColor;
#elif DBG_MODE == 4 || DBG_MODE == 5
    uniform vec3 dbg_uvPrimaryColor;
    uniform vec3 dbg_uvSecondaryColor;
#elif DBG_MODE == 7
    uniform vec3 dbg_materialColor;
#endif
#endif` };
      }, t.prototype.bindForSubMesh = function(e) {
        this._isEnabled && (e.updateFloat3("dbg_shadedDiffuseColor", this.shadedDiffuseColor.r, this.shadedDiffuseColor.g, this.shadedDiffuseColor.b), e.updateFloat4("dbg_shadedSpecularColorPower", this.shadedSpecularColor.r, this.shadedSpecularColor.g, this.shadedSpecularColor.b, this.shadedSpecularPower), e.updateFloat3("dbg_thicknessRadiusScale", this.wireframeThickness, this.vertexRadius, this.uvScale), e.updateColor3("dbg_wireframeTrianglesColor", this.wireframeTrianglesColor), e.updateColor3("dbg_wireframeVerticesColor", this.wireframeVerticesColor), e.updateColor3("dbg_vertexColor", this.vertexColor), e.updateColor3("dbg_uvPrimaryColor", this.uvPrimaryColor), e.updateColor3("dbg_uvSecondaryColor", this.uvSecondaryColor), e.updateColor3("dbg_materialColor", this._materialColor));
      }, t.prototype.getCustomCode = function(e) {
        return e === "vertex" ? { CUSTOM_VERTEX_DEFINITIONS: `#if defined(DBG_ENABLED)
attribute float dbg_initialPass;
varying vec3 dbg_vBarycentric;
flat varying vec3 dbg_vVertexWorldPos;
flat varying float dbg_vPass;
#endif`, CUSTOM_VERTEX_MAIN_END: `#if defined(DBG_ENABLED)
float dbg_vertexIndex = mod(float(gl_VertexID), 3.);
if (dbg_vertexIndex == 0.0) { 
    dbg_vBarycentric = vec3(1.,0.,0.); 
}
else if (dbg_vertexIndex == 1.0) { 
    dbg_vBarycentric = vec3(0.,1.,0.); 
}
else { 
    dbg_vBarycentric = vec3(0.,0.,1.); 
}

dbg_vVertexWorldPos = vPositionW;
dbg_vPass = dbg_initialPass;
#endif` } : { CUSTOM_FRAGMENT_DEFINITIONS: `#if defined(DBG_ENABLED)
varying vec3 dbg_vBarycentric;
flat varying vec3 dbg_vVertexWorldPos;
flat varying float dbg_vPass;

#if !defined(DBG_MULTIPLY)
    vec3 dbg_applyShading(vec3 color) {
        vec3 N = vNormalW.xyz;
        vec3 L = normalize(vEyePosition.xyz - vPositionW.xyz);
        vec3 H = normalize(L + L);
        float LdotN = clamp(dot(L,N), 0., 1.);
        float HdotN = clamp(dot(H,N), 0., 1.);
        float specTerm = pow(HdotN, dbg_shadedSpecularColorPower.w);
        color *= (LdotN / PI);
        color += dbg_shadedSpecularColorPower.rgb * (specTerm / PI);
        return color;
    }
#endif

#if DBG_MODE == 1 || DBG_MODE == 3
    float dbg_edgeFactor() {
        vec3 d = fwidth(dbg_vBarycentric);
        vec3 a3 = smoothstep(vec3(0.), d * dbg_thicknessRadiusScale.x, dbg_vBarycentric);
        return min(min(a3.x, a3.y), a3.z);
    }
#endif

#if DBG_MODE == 2 || DBG_MODE == 3
    float dbg_cornerFactor() {
        vec3 worldPos = vPositionW;
        float dist = length(worldPos - dbg_vVertexWorldPos);
        float camDist = length(worldPos - vEyePosition.xyz);
        float d = sqrt(camDist) * .001;
        return smoothstep((dbg_thicknessRadiusScale.y * d), ((dbg_thicknessRadiusScale.y * 1.01) * d), dist);
    }
#endif

#if (DBG_MODE == 4 && defined(UV1)) || (DBG_MODE == 5 && defined(UV2))
    float dbg_checkerboardFactor(vec2 uv) {
        vec2 f = fract(uv * dbg_thicknessRadiusScale.z);
        f -= .5;
        return (f.x * f.y) > 0. ? 1. : 0.;
    }
#endif
#endif`, CUSTOM_FRAGMENT_MAIN_END: `#if defined(DBG_ENABLED)
vec3 dbg_color = vec3(1.);
#if DBG_MODE == 1
    dbg_color = mix(dbg_wireframeTrianglesColor, vec3(1.), dbg_edgeFactor());
#elif DBG_MODE == 2 || DBG_MODE == 3
    float dbg_cornerFactor = dbg_cornerFactor();
    if (dbg_vPass == 0. && dbg_cornerFactor == 1.) discard;
    dbg_color = mix(dbg_vertexColor, vec3(1.), dbg_cornerFactor);
    #if DBG_MODE == 3
        dbg_color *= mix(dbg_wireframeVerticesColor, vec3(1.), dbg_edgeFactor());
    #endif
#elif DBG_MODE == 4 && defined(UV1)
    dbg_color = mix(dbg_uvPrimaryColor, dbg_uvSecondaryColor, dbg_checkerboardFactor(vMainUV1));
#elif DBG_MODE == 5 && defined(UV2)
    dbg_color = mix(dbg_uvPrimaryColor, dbg_uvSecondaryColor, dbg_checkerboardFactor(vMainUV2));
#elif DBG_MODE == 6 && defined(VERTEXCOLOR)
    dbg_color = vColor.rgb;
#elif DBG_MODE == 7
    dbg_color = dbg_materialColor;
#endif

#if defined(DBG_MULTIPLY)
    gl_FragColor *= vec4(dbg_color, 1.);
#else
    #if DBG_MODE != 6
        gl_FragColor = vec4(dbg_applyShading(dbg_shadedDiffuseColor) * dbg_color, 1.);
    #else
        gl_FragColor = vec4(dbg_color, 1.);
    #endif
#endif
#endif` };
      }, t.Reset = function() {
        this._PluginCount = 0, this.MaterialColors = yP;
      }, t.PrepareMeshForTrianglesAndVerticesMode = function(e, i) {
        i === void 0 && (i = !1);
        var r = function() {
        };
        if (e.getTotalIndices() == 0)
          return r;
        if (i) {
          for (var o = e.getVerticesDataKinds(), a = e.getIndices(), s = {}, l = 0, c = o; l < c.length; l++) {
            var u = c[l];
            s[u] = e.getVerticesData(u);
          }
          r = function() {
            e.setIndices(a);
            for (var b = 0, T = o; b < T.length; b++) {
              var S = T[b], E = e.getVertexBuffer(S).getStrideSize();
              e.setVerticesData(S, s[S], void 0, E);
            }
            e.removeVerticesData("dbg_initialPass");
          };
        }
        for (var h = Array.from(e.getIndices()), d = [], p = 0; p < h.length; p += 3)
          d.push(h[p + 1], h[p + 2], h[p + 0]);
        e.setIndices(h.concat(d)), e.convertToUnIndexedMesh(), e.isUnIndexed = !1;
        var f = [];
        for (p = (h = Array.from(e.getIndices())).length / 2; p < h.length; p += 3)
          f.push(h[p + 1], h[p + 2], h[p + 0]);
        e.setIndices(h.concat(f));
        var m = e.getTotalVertices(), g = m / 2, y = new Array(m).fill(1, 0, g).fill(0, g, m);
        return e.setVerticesData("dbg_initialPass", y, !1, 1), r;
      }, t._PluginCount = 0, t.MaterialColors = yP, x([ri()], t.prototype, "_materialColor", void 0), x([N()], t.prototype, "_isEnabled", void 0), x([N(), ye("_markAllDefinesAsDirty")], t.prototype, "mode", void 0), x([N(), ye("_markAllDefinesAsDirty")], t.prototype, "multiply", void 0), x([ri()], t.prototype, "shadedDiffuseColor", void 0), x([ri()], t.prototype, "shadedSpecularColor", void 0), x([N()], t.prototype, "shadedSpecularPower", void 0), x([N()], t.prototype, "wireframeThickness", void 0), x([ri()], t.prototype, "wireframeTrianglesColor", void 0), x([ri()], t.prototype, "wireframeVerticesColor", void 0), x([ri()], t.prototype, "vertexColor", void 0), x([N()], t.prototype, "vertexRadius", void 0), x([N()], t.prototype, "uvScale", void 0), x([ri()], t.prototype, "uvPrimaryColor", void 0), x([ri()], t.prototype, "uvSecondaryColor", void 0), t;
    }($r);
    j("BABYLON.MeshDebugPluginMaterial", OT), Object.defineProperty(Gt.prototype, "decalMap", { get: function() {
      if (!this._decalMap) {
        if (this._uniformBufferLayoutBuilt)
          return null;
        this._decalMap = new cd(this);
      }
      return this._decalMap;
    }, enumerable: !0, configurable: !0 }), Object.defineProperty(Si.prototype, "decalMap", { get: function() {
      if (!this._decalMap) {
        if (this._uniformBufferLayoutBuilt)
          return null;
        this._decalMap = new cd(this);
      }
      return this._decalMap;
    }, enumerable: !0, configurable: !0 }), Object.defineProperty(Dt.prototype, "decalMap", { get: function() {
      return this._decalMap;
    }, set: function(n) {
      this._decalMap = n;
    }, enumerable: !0, configurable: !0 });
    var bP = function() {
      function n(t, e) {
        this.radius = t, this.theta = e;
      }
      return n.prototype.getClassName = function() {
        return "Polar";
      }, n.prototype.toString = function() {
        return JSON.stringify(this);
      }, n.prototype.asArray = function() {
        return [this.radius, this.theta];
      }, n.prototype.addToRef = function(t, e) {
        return e.radius = this.radius + t.radius, e.theta = this.theta + t.theta, e;
      }, n.prototype.add = function(t) {
        var e = new n(0, 0);
        return this.addToRef(t, e), e;
      }, n.prototype.addInPlace = function(t) {
        return this.addToRef(t, this), this;
      }, n.prototype.addInPlaceFromFloats = function(t, e) {
        return this.radius += t, this.theta += e, this;
      }, n.prototype.subtractToRef = function(t, e) {
        return e.radius = this.radius - t.radius, e.theta = this.theta - t.theta, e;
      }, n.prototype.subtract = function(t) {
        var e = new n(0, 0);
        return this.subtractToRef(t, e), e;
      }, n.prototype.subtractInPlace = function(t) {
        return this.subtractToRef(t, this), this;
      }, n.prototype.subtractFromFloatsToRef = function(t, e, i) {
        return i.radius = this.radius - t, i.theta = this.theta - e, i;
      }, n.prototype.subtractFromFloats = function(t, e) {
        var i = new n(0, 0);
        return this.subtractFromFloatsToRef(t, e, i), i;
      }, n.prototype.multiplyToRef = function(t, e) {
        return e.radius = this.radius * t.radius, e.theta = this.theta * t.theta, e;
      }, n.prototype.multiply = function(t) {
        var e = new n(0, 0);
        return this.multiplyToRef(t, e), e;
      }, n.prototype.multiplyInPlace = function(t) {
        return this.multiplyToRef(t, this), this;
      }, n.prototype.divideToRef = function(t, e) {
        return e.radius = this.radius / t.radius, e.theta = this.theta / t.theta, e;
      }, n.prototype.divide = function(t) {
        var e = new n(0, 0);
        return this.divideToRef(t, e), e;
      }, n.prototype.divideInPlace = function(t) {
        return this.divideToRef(t, this), this;
      }, n.prototype.clone = function() {
        return new n(this.radius, this.theta);
      }, n.prototype.copyFrom = function(t) {
        return this.radius = t.radius, this.theta = t.theta, this;
      }, n.prototype.copyFromFloats = function(t, e) {
        return this.radius = t, this.theta = e, this;
      }, n.prototype.scaleToRef = function(t, e) {
        return e.radius = this.radius * t, e.theta = this.theta * t, e;
      }, n.prototype.scale = function(t) {
        var e = new n(0, 0);
        return this.scaleToRef(t, e), e;
      }, n.prototype.scaleInPlace = function(t) {
        return this.scaleToRef(t, this), this;
      }, n.prototype.set = function(t, e) {
        return this.radius = t, this.theta = e, this;
      }, n.prototype.setAll = function(t) {
        return this.set(t, t), this;
      }, n.prototype.toVector2ToRef = function(t) {
        var e = this.radius * Math.cos(this.theta), i = this.radius * Math.sin(this.theta);
        return t.set(e, i), t;
      }, n.prototype.toVector2 = function() {
        var t = new fe(0, 0);
        return this.toVector2ToRef(t);
      }, n.FromVector2ToRef = function(t, e) {
        var i = Math.sign(t.y) * Math.acos(t.x / t.length());
        return e.radius = t.length(), e.theta = i, e;
      }, n.FromVector2 = function(t) {
        var e = new n(0, 0);
        return n.FromVector2ToRef(t, e), e;
      }, n.FromArray = function(t) {
        return new n(t[0], t[1]);
      }, n;
    }(), TP = function() {
      function n(t, e, i) {
        this.radius = t, this.theta = e, this.phi = i;
      }
      return n.prototype.getClassName = function() {
        return "Spherical";
      }, n.prototype.toString = function() {
        return JSON.stringify(this);
      }, n.prototype.asArray = function() {
        return [this.radius, this.theta, this.phi];
      }, n.prototype.addToRef = function(t, e) {
        return e.radius = this.radius + t.radius, e.theta = this.theta + t.theta, e.phi = this.phi + t.phi, e;
      }, n.prototype.add = function(t) {
        var e = new n(0, 0, 0);
        return this.addToRef(t, e), e;
      }, n.prototype.addInPlace = function(t) {
        return this.addToRef(t, this), this;
      }, n.prototype.addInPlaceFromFloats = function(t, e, i) {
        return this.radius += t, this.theta += e, this.phi += i, this;
      }, n.prototype.subtractToRef = function(t, e) {
        return e.radius = this.radius - t.radius, e.theta = this.theta - t.theta, e.phi = this.phi - t.phi, e;
      }, n.prototype.subtract = function(t) {
        var e = new n(0, 0, 0);
        return this.subtractToRef(t, e), e;
      }, n.prototype.subtractInPlace = function(t) {
        return this.subtractToRef(t, this), this;
      }, n.prototype.subtractFromFloatsToRef = function(t, e, i, r) {
        return r.radius = this.radius - t, r.theta = this.theta - e, r.phi = this.phi - i, r;
      }, n.prototype.subtractFromFloats = function(t, e, i) {
        var r = new n(0, 0, 0);
        return this.subtractFromFloatsToRef(t, e, i, r), r;
      }, n.prototype.multiplyToRef = function(t, e) {
        return e.radius = this.radius * t.radius, e.theta = this.theta * t.theta, e.phi = this.phi * t.phi, e;
      }, n.prototype.multiply = function(t) {
        var e = new n(0, 0, 0);
        return this.multiplyToRef(t, e), e;
      }, n.prototype.multiplyInPlace = function(t) {
        return this.multiplyToRef(t, this), this;
      }, n.prototype.divideToRef = function(t, e) {
        return e.radius = this.radius / t.radius, e.theta = this.theta / t.theta, e.phi = this.phi / t.phi, e;
      }, n.prototype.divide = function(t) {
        var e = new n(0, 0, 0);
        return this.divideToRef(t, e), e;
      }, n.prototype.divideInPlace = function(t) {
        return this.divideToRef(t, this), this;
      }, n.prototype.clone = function() {
        return new n(this.radius, this.theta, this.phi);
      }, n.prototype.copyFrom = function(t) {
        return this.radius = t.radius, this.theta = t.theta, this.phi = t.phi, this;
      }, n.prototype.copyFromFloats = function(t, e, i) {
        return this.radius = t, this.theta = e, this.phi = i, this;
      }, n.prototype.scaleToRef = function(t, e) {
        return e.radius = this.radius * t, e.theta = this.theta * t, e.phi = this.phi * t, e;
      }, n.prototype.scale = function(t) {
        var e = new n(0, 0, 0);
        return this.scaleToRef(t, e), e;
      }, n.prototype.scaleInPlace = function(t) {
        return this.scaleToRef(t, this), this;
      }, n.prototype.set = function(t, e, i) {
        return this.radius = t, this.theta = e, this.phi = i, this;
      }, n.prototype.setAll = function(t) {
        return this.set(t, t, t), this;
      }, n.prototype.toVector3ToRef = function(t) {
        var e = this.radius * Math.sin(this.theta) * Math.cos(this.phi), i = this.radius * Math.cos(this.theta), r = this.radius * Math.sin(this.theta) * Math.sin(this.phi);
        return t.set(e, i, r), t;
      }, n.prototype.toVector3 = function() {
        var t = new v(0, 0, 0);
        return this.toVector3ToRef(t);
      }, n.FromVector3ToRef = function(t, e) {
        return e.radius = t.length(), e.theta = Math.acos(t.y / e.radius), e.phi = Math.atan2(t.z, t.x), e;
      }, n.FromVector3 = function(t) {
        var e = new n(0, 0, 0);
        return n.FromVector3ToRef(t, e), e;
      }, n.FromArray = function(t) {
        return new n(t[0], t[1], t[2]);
      }, n;
    }();
    function DT(n, t, e, i, r) {
      var o = null, a = null, s = null;
      try {
        var l;
        o = new n.Decoder(), (a = new n.DecoderBuffer()).Init(t, t.byteLength);
        var c = o.GetEncodedGeometryType(a);
        switch (c) {
          case n.TRIANGULAR_MESH:
            var u = new n.Mesh();
            if (!(l = o.DecodeBufferToMesh(a, u)).ok() || u.ptr === 0)
              throw new Error(l.error_msg());
            var h = 3 * u.num_faces(), d = 4 * h, p = n._malloc(d);
            try {
              o.GetTrianglesUInt32Array(u, d, p);
              var f = new Uint32Array(h);
              f.set(new Uint32Array(n.HEAPF32.buffer, p, h)), i(f);
            } finally {
              n._free(p);
            }
            s = u;
            break;
          case n.POINT_CLOUD:
            var m = new n.PointCloud();
            if (!(l = o.DecodeBufferToPointCloud(a, m)).ok() || !m.ptr)
              throw new Error(l.error_msg());
            s = m;
            break;
          default:
            throw new Error("Invalid geometry type ".concat(c));
        }
        var g = s.num_points(), y = function(A, R, C, L) {
          var I, O = L.data_type(), w = L.num_components(), z = L.normalized(), V = L.byte_stride(), Y = L.byte_offset(), ee = ((I = {})[n.DT_FLOAT32] = { typedArrayConstructor: Float32Array, heap: n.HEAPF32 }, I[n.DT_INT8] = { typedArrayConstructor: Int8Array, heap: n.HEAP8 }, I[n.DT_INT16] = { typedArrayConstructor: Int16Array, heap: n.HEAP16 }, I[n.DT_INT32] = { typedArrayConstructor: Int32Array, heap: n.HEAP32 }, I[n.DT_UINT8] = { typedArrayConstructor: Uint8Array, heap: n.HEAPU8 }, I[n.DT_UINT16] = { typedArrayConstructor: Uint16Array, heap: n.HEAPU16 }, I[n.DT_UINT32] = { typedArrayConstructor: Uint32Array, heap: n.HEAPU32 }, I)[O];
          if (!ee)
            throw new Error("Invalid data type ".concat(O));
          var J = g * w, X = J * ee.typedArrayConstructor.BYTES_PER_ELEMENT, K = n._malloc(X);
          try {
            A.GetAttributeDataArrayForAllPoints(R, L, O, X, K);
            var te = new ee.typedArrayConstructor(ee.heap.buffer, K, J);
            r(C, te.slice(), w, Y, V, z);
          } finally {
            n._free(K);
          }
        };
        if (e)
          for (var b in e) {
            var T = e[b], S = o.GetAttributeByUniqueId(s, T);
            y(o, s, b, S);
          }
        else {
          var E = { position: n.POSITION, normal: n.NORMAL, color: n.COLOR, uv: n.TEX_COORD };
          for (var b in E)
            (T = o.GetAttributeId(s, E[b])) !== -1 && (S = o.GetAttribute(s, T), y(o, s, b, S));
        }
        return g;
      } finally {
        s && n.destroy(s), a && n.destroy(a), o && n.destroy(o);
      }
    }
    function hN() {
      var n;
      onmessage = function(t) {
        var e = t.data;
        switch (e.id) {
          case "init":
            var i = e.decoder;
            i.url && (importScripts(i.url), n = DracoDecoderModule({ wasmBinary: i.wasmBinary })), postMessage({ id: "initDone" });
            break;
          case "decodeMesh":
            if (!n)
              throw new Error("Draco decoder module is not available");
            n.then(function(r) {
              var o = DT(r, e.dataView, e.attributes, function(a) {
                postMessage({ id: "indices", data: a }, [a.buffer]);
              }, function(a, s, l, c, u, h) {
                postMessage({ id: "attribute", kind: a, data: s, size: l, byteOffset: c, byteStride: u, normalized: h }, [s.buffer]);
              });
              postMessage({ id: "decodeMeshDone", totalVertices: o });
            });
        }
      };
    }
    var EP = function() {
      function n(t) {
        t === void 0 && (t = n.DefaultNumWorkers);
        var e = n.Configuration.decoder, i = e.wasmUrl && e.wasmBinaryUrl && typeof WebAssembly == "object" ? { url: de.GetBabylonScriptURL(e.wasmUrl, !0), wasmBinaryPromise: de.LoadFileAsync(de.GetBabylonScriptURL(e.wasmBinaryUrl, !0)) } : { url: de.GetBabylonScriptURL(e.fallbackUrl), wasmBinaryPromise: Promise.resolve(void 0) };
        t && typeof Worker == "function" && typeof URL == "function" ? this._workerPoolPromise = i.wasmBinaryPromise.then(function(r) {
          var o = "".concat(DT, "(").concat(hN, ")()"), a = URL.createObjectURL(new Blob([o], { type: "application/javascript" }));
          return new p_(t, function() {
            return new Promise(function(s, l) {
              var c = new Worker(a), u = function(d) {
                c.removeEventListener("error", u), c.removeEventListener("message", h), l(d);
              }, h = function(d) {
                d.data.id === "initDone" && (c.removeEventListener("error", u), c.removeEventListener("message", h), s(c));
              };
              c.addEventListener("error", u), c.addEventListener("message", h), c.postMessage({ id: "init", decoder: { url: i.url, wasmBinary: r } });
            });
          });
        }) : this._decoderModulePromise = i.wasmBinaryPromise.then(function(r) {
          if (!i.url)
            throw new Error("Draco decoder module is not available");
          return de.LoadBabylonScriptAsync(i.url).then(function() {
            return o = r, new Promise(function(a) {
              DracoDecoderModule({ wasmBinary: o }).then(function(s) {
                a({ module: s });
              });
            });
            var o;
          });
        });
      }
      return Object.defineProperty(n, "DecoderAvailable", { get: function() {
        var t = n.Configuration.decoder;
        return !!(t.wasmUrl && t.wasmBinaryUrl && typeof WebAssembly == "object" || t.fallbackUrl);
      }, enumerable: !1, configurable: !0 }), n.GetDefaultNumWorkers = function() {
        return typeof navigator == "object" && navigator.hardwareConcurrency ? Math.min(Math.floor(0.5 * navigator.hardwareConcurrency), 4) : 1;
      }, Object.defineProperty(n, "Default", { get: function() {
        return n._Default || (n._Default = new n()), n._Default;
      }, enumerable: !1, configurable: !0 }), n.prototype.dispose = function() {
        this._workerPoolPromise && this._workerPoolPromise.then(function(t) {
          t.dispose();
        }), delete this._workerPoolPromise, delete this._decoderModulePromise;
      }, n.prototype.whenReadyAsync = function() {
        return this._workerPoolPromise ? this._workerPoolPromise.then(function() {
        }) : this._decoderModulePromise ? this._decoderModulePromise.then(function() {
        }) : Promise.resolve();
      }, n.prototype._decodeMeshAsync = function(t, e, i) {
        var r = t instanceof ArrayBuffer ? new Int8Array(t) : new Int8Array(t.buffer, t.byteOffset, t.byteLength);
        if (this._workerPoolPromise)
          return this._workerPoolPromise.then(function(o) {
            return new Promise(function(a, s) {
              o.push(function(l, c) {
                var u = null, h = [], d = function(m) {
                  l.removeEventListener("error", d), l.removeEventListener("message", p), s(m), c();
                }, p = function(m) {
                  var g, y, b = m.data;
                  switch (b.id) {
                    case "decodeMeshDone":
                      l.removeEventListener("error", d), l.removeEventListener("message", p), a({ indices: u, attributes: h, totalVertices: b.totalVertices }), c();
                      break;
                    case "indices":
                      u = b.data;
                      break;
                    case "attribute":
                      h.push({ kind: b.kind, data: b.data, size: b.size, byteOffset: b.byteOffset, byteStride: b.byteStride, normalized: (g = b.kind, y = b.normalized, i && i[g] !== void 0 ? (y !== i[g] && q.Warn("Normalized flag from Draco data (".concat(y, ") does not match normalized flag from glTF accessor (").concat(i[g], "). Using flag from glTF accessor.")), i[g]) : y) });
                  }
                };
                l.addEventListener("error", d), l.addEventListener("message", p);
                var f = r.slice();
                l.postMessage({ id: "decodeMesh", dataView: f, attributes: e }, [f.buffer]);
              });
            });
          });
        if (this._decoderModulePromise)
          return this._decoderModulePromise.then(function(o) {
            var a = null, s = [], l = DT(o.module, r, e, function(c) {
              a = c;
            }, function(c, u, h, d, p, f) {
              s.push({ kind: c, data: u, size: h, byteOffset: d, byteStride: p, normalized: f });
            });
            return { indices: a, attributes: s, totalVertices: l };
          });
        throw new Error("Draco decoder module is not available");
      }, n.prototype.decodeMeshToGeometryAsync = function(t, e, i, r) {
        return this._decodeMeshAsync(i, r).then(function(o) {
          var a = new er(t, e);
          o.indices && a.setIndices(o.indices);
          for (var s = 0, l = o.attributes; s < l.length; s++) {
            var c = l[s];
            a.setVerticesBuffer(new P(e.getEngine(), c.data, c.kind, !1, void 0, c.byteStride, void 0, c.byteOffset, c.size, void 0, c.normalized, !0), o.totalVertices);
          }
          return a;
        });
      }, n.prototype._decodeMeshToGeometryForGltfAsync = function(t, e, i, r, o) {
        return this._decodeMeshAsync(i, r, o).then(function(a) {
          var s = new er(t, e);
          a.indices && s.setIndices(a.indices);
          for (var l = 0, c = a.attributes; l < c.length; l++) {
            var u = c[l];
            s.setVerticesBuffer(new P(e.getEngine(), u.data, u.kind, !1, void 0, u.byteStride, void 0, u.byteOffset, u.size, void 0, u.normalized, !0), a.totalVertices);
          }
          return s;
        });
      }, n.prototype.decodeMeshAsync = function(t, e) {
        return this._decodeMeshAsync(t, e).then(function(i) {
          var r = new Oe();
          i.indices && (r.indices = i.indices);
          for (var o = 0, a = i.attributes; o < a.length; o++) {
            var s = a[o], l = P.GetFloatData(s.data, s.size, P.GetDataType(s.data), s.byteOffset, s.byteStride, s.normalized, i.totalVertices);
            r.set(l, s.kind);
          }
          return r;
        });
      }, n.Configuration = { decoder: { wasmUrl: "".concat(de._DefaultCdnUrl, "/draco_wasm_wrapper_gltf.js"), wasmBinaryUrl: "".concat(de._DefaultCdnUrl, "/draco_decoder_gltf.wasm"), fallbackUrl: "".concat(de._DefaultCdnUrl, "/draco_decoder_gltf.js") } }, n.DefaultNumWorkers = n.GetDefaultNumWorkers(), n._Default = null, n;
    }(), SP = function() {
      function n() {
        var t = n.Configuration.decoder;
        this._decoderModulePromise = de.LoadBabylonScriptAsync(t.url).then(function() {
          return MeshoptDecoder.ready;
        });
      }
      return Object.defineProperty(n, "Default", { get: function() {
        return n._Default || (n._Default = new n()), n._Default;
      }, enumerable: !1, configurable: !0 }), n.prototype.dispose = function() {
        delete this._decoderModulePromise;
      }, n.prototype.decodeGltfBufferAsync = function(t, e, i, r, o) {
        return this._decoderModulePromise.then(function() {
          var a = new Uint8Array(e * i);
          return MeshoptDecoder.decodeGltfBuffer(a, e, i, t, r, o), a;
        });
      }, n.Configuration = { decoder: { url: "".concat(de._DefaultCdnUrl, "/meshopt_decoder.js") } }, n._Default = null, n;
    }(), W_ = 0, xP = function() {
      function n(t, e, i, r) {
        this.pos = t, this.normal = e, this.uv = i, this.vertColor = r;
      }
      return n.prototype.clone = function() {
        var t, e;
        return new n(this.pos.clone(), this.normal.clone(), (t = this.uv) === null || t === void 0 ? void 0 : t.clone(), (e = this.vertColor) === null || e === void 0 ? void 0 : e.clone());
      }, n.prototype.flip = function() {
        this.normal = this.normal.scale(-1);
      }, n.prototype.interpolate = function(t, e) {
        return new n(v.Lerp(this.pos, t.pos, e), v.Lerp(this.normal, t.normal, e), this.uv && t.uv ? fe.Lerp(this.uv, t.uv, e) : void 0, this.vertColor && t.vertColor ? Ie.Lerp(this.vertColor, t.vertColor, e) : void 0);
      }, n;
    }(), dN = function() {
      function n(t, e) {
        this.normal = t, this.w = e;
      }
      return n.FromPoints = function(t, e, i) {
        var r = i.subtract(t), o = e.subtract(t);
        if (r.lengthSquared() === 0 || o.lengthSquared() === 0)
          return null;
        var a = v.Normalize(v.Cross(r, o));
        return new n(a, v.Dot(a, t));
      }, n.prototype.clone = function() {
        return new n(this.normal.clone(), this.w);
      }, n.prototype.flip = function() {
        this.normal.scaleInPlace(-1), this.w = -this.w;
      }, n.prototype.splitPolygon = function(t, e, i, r, o) {
        var a, s, l = 0, c = [];
        for (a = 0; a < t.vertices.length; a++) {
          var u = (s = v.Dot(this.normal, t.vertices[a].pos) - this.w) < -n.EPSILON ? 2 : s > n.EPSILON ? 1 : 0;
          l |= u, c.push(u);
        }
        switch (l) {
          case 0:
            (v.Dot(this.normal, t.plane.normal) > 0 ? e : i).push(t);
            break;
          case 1:
            r.push(t);
            break;
          case 2:
            o.push(t);
            break;
          case 3:
            var h = [], d = [];
            for (a = 0; a < t.vertices.length; a++) {
              var p = (a + 1) % t.vertices.length, f = c[a], m = c[p], g = t.vertices[a], y = t.vertices[p];
              if (f !== 2 && h.push(g), f !== 1 && d.push(f !== 2 ? g.clone() : g), (f | m) == 3) {
                s = (this.w - v.Dot(this.normal, g.pos)) / v.Dot(this.normal, y.pos.subtract(g.pos));
                var b = g.interpolate(y, s);
                h.push(b), d.push(b.clone());
              }
            }
            var T = void 0;
            h.length >= 3 && (T = new H_(h, t.shared)).plane && r.push(T), d.length >= 3 && (T = new H_(d, t.shared)).plane && o.push(T);
        }
      }, n.EPSILON = 1e-5, n;
    }(), H_ = function() {
      function n(t, e) {
        this.vertices = t, this.shared = e, this.plane = dN.FromPoints(t[0].pos, t[1].pos, t[2].pos);
      }
      return n.prototype.clone = function() {
        return new n(this.vertices.map(function(t) {
          return t.clone();
        }), this.shared);
      }, n.prototype.flip = function() {
        this.vertices.reverse().map(function(t) {
          t.flip();
        }), this.plane.flip();
      }, n;
    }(), oo = function() {
      function n(t) {
        this._plane = null, this._front = null, this._back = null, this._polygons = new Array(), t && this.build(t);
      }
      return n.prototype.clone = function() {
        var t = new n();
        return t._plane = this._plane && this._plane.clone(), t._front = this._front && this._front.clone(), t._back = this._back && this._back.clone(), t._polygons = this._polygons.map(function(e) {
          return e.clone();
        }), t;
      }, n.prototype.invert = function() {
        for (var t = 0; t < this._polygons.length; t++)
          this._polygons[t].flip();
        this._plane && this._plane.flip(), this._front && this._front.invert(), this._back && this._back.invert();
        var e = this._front;
        this._front = this._back, this._back = e;
      }, n.prototype.clipPolygons = function(t) {
        if (!this._plane)
          return t.slice();
        for (var e = [], i = [], r = 0; r < t.length; r++)
          this._plane.splitPolygon(t[r], e, i, e, i);
        return this._front && (e = this._front.clipPolygons(e)), i = this._back ? this._back.clipPolygons(i) : [], e.concat(i);
      }, n.prototype.clipTo = function(t) {
        this._polygons = t.clipPolygons(this._polygons), this._front && this._front.clipTo(t), this._back && this._back.clipTo(t);
      }, n.prototype.allPolygons = function() {
        var t = this._polygons.slice();
        return this._front && (t = t.concat(this._front.allPolygons())), this._back && (t = t.concat(this._back.allPolygons())), t;
      }, n.prototype.build = function(t) {
        if (t.length) {
          this._plane || (this._plane = t[0].plane.clone());
          for (var e = [], i = [], r = 0; r < t.length; r++)
            this._plane.splitPolygon(t[r], this._polygons, this._polygons, e, i);
          e.length && (this._front || (this._front = new n()), this._front.build(e)), i.length && (this._back || (this._back = new n()), this._back.build(i));
        }
      }, n;
    }(), X_ = function() {
      function n() {
        this._polygons = new Array();
      }
      return n.FromVertexData = function(t) {
        var e, i, r, o = [], a = t.indices, s = t.positions, l = t.normals, c = t.uvs, u = t.colors;
        if (!a || !s)
          throw "BABYLON.CSG: VertexData must at least contain positions and indices";
        for (var h = 0; h < a.length; h += 3) {
          r = [];
          for (var d = 0; d < 3; d++) {
            var p = a[h + d], f = l ? v.FromArray(l, 3 * p) : v.Zero(), m = c ? fe.FromArray(c, 2 * p) : void 0, g = u ? Ie.FromArray(u, 4 * p) : void 0, y = v.FromArray(s, 3 * p);
            e = new xP(y, f, m, g), r.push(e);
          }
          (i = new H_(r, { subMeshId: 0, meshId: W_, materialIndex: 0 })).plane && o.push(i);
        }
        var b = n._FromPolygons(o);
        return b.matrix = B.Identity(), b.position = v.Zero(), b.rotation = v.Zero(), b.scaling = v.One(), b.rotationQuaternion = oe.Identity(), W_++, b;
      }, n.FromMesh = function(t, e) {
        e === void 0 && (e = !1);
        var i, r, o, a, s, l, c, u, h, d = void 0, p = void 0, f = [], m = null, g = !1;
        if (!(t instanceof ie))
          throw "BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh";
        t.computeWorldMatrix(!0), l = t.getWorldMatrix(), c = t.position.clone(), u = t.rotation.clone(), t.rotationQuaternion && (m = t.rotationQuaternion.clone()), h = t.scaling.clone(), t.material && e && (g = t.material.sideOrientation === _.MATERIAL_ClockWiseSideOrientation);
        for (var y = t.getIndices(), b = t.getVerticesData(P.PositionKind), T = t.getVerticesData(P.NormalKind), S = t.getVerticesData(P.UVKind), E = t.getVerticesData(P.ColorKind), A = t.subMeshes, R = 0, C = A.length; R < C; R++)
          for (var L = A[R].indexStart, I = A[R].indexCount + A[R].indexStart; L < I; L += 3) {
            s = [];
            for (var O = 0; O < 3; O++) {
              var w = O === 0 ? L + O : g ? L + 3 - O : L + O, z = new v(T[3 * y[w]], T[3 * y[w] + 1], T[3 * y[w] + 2]);
              S && (d = new fe(S[2 * y[w]], S[2 * y[w] + 1])), E && (p = new Ie(E[4 * y[w]], E[4 * y[w] + 1], E[4 * y[w] + 2], E[4 * y[w] + 3]));
              var V = new v(b[3 * y[w]], b[3 * y[w] + 1], b[3 * y[w] + 2]);
              o = v.TransformCoordinates(V, l), r = v.TransformNormal(z, l), i = new xP(o, r, d, p), s.push(i);
            }
            (a = new H_(s, { subMeshId: R, meshId: W_, materialIndex: A[R].materialIndex })).plane && f.push(a);
          }
        var Y = n._FromPolygons(f);
        return Y.matrix = e ? B.Identity() : l, Y.position = e ? v.Zero() : c, Y.rotation = e ? v.Zero() : u, Y.scaling = e ? v.One() : h, Y.rotationQuaternion = e && m ? oe.Identity() : m, W_++, Y;
      }, n._FromPolygons = function(t) {
        var e = new n();
        return e._polygons = t, e;
      }, n.prototype.clone = function() {
        var t = new n();
        return t._polygons = this._polygons.map(function(e) {
          return e.clone();
        }), t.copyTransformAttributes(this), t;
      }, n.prototype.union = function(t) {
        var e = new oo(this.clone()._polygons), i = new oo(t.clone()._polygons);
        return e.clipTo(i), i.clipTo(e), i.invert(), i.clipTo(e), i.invert(), e.build(i.allPolygons()), n._FromPolygons(e.allPolygons()).copyTransformAttributes(this);
      }, n.prototype.unionInPlace = function(t) {
        var e = new oo(this._polygons), i = new oo(t._polygons);
        e.clipTo(i), i.clipTo(e), i.invert(), i.clipTo(e), i.invert(), e.build(i.allPolygons()), this._polygons = e.allPolygons();
      }, n.prototype.subtract = function(t) {
        var e = new oo(this.clone()._polygons), i = new oo(t.clone()._polygons);
        return e.invert(), e.clipTo(i), i.clipTo(e), i.invert(), i.clipTo(e), i.invert(), e.build(i.allPolygons()), e.invert(), n._FromPolygons(e.allPolygons()).copyTransformAttributes(this);
      }, n.prototype.subtractInPlace = function(t) {
        var e = new oo(this._polygons), i = new oo(t._polygons);
        e.invert(), e.clipTo(i), i.clipTo(e), i.invert(), i.clipTo(e), i.invert(), e.build(i.allPolygons()), e.invert(), this._polygons = e.allPolygons();
      }, n.prototype.intersect = function(t) {
        var e = new oo(this.clone()._polygons), i = new oo(t.clone()._polygons);
        return e.invert(), i.clipTo(e), i.invert(), e.clipTo(i), i.clipTo(e), e.build(i.allPolygons()), e.invert(), n._FromPolygons(e.allPolygons()).copyTransformAttributes(this);
      }, n.prototype.intersectInPlace = function(t) {
        var e = new oo(this._polygons), i = new oo(t._polygons);
        e.invert(), i.clipTo(e), i.invert(), e.clipTo(i), i.clipTo(e), e.build(i.allPolygons()), e.invert(), this._polygons = e.allPolygons();
      }, n.prototype.inverse = function() {
        var t = this.clone();
        return t.inverseInPlace(), t;
      }, n.prototype.inverseInPlace = function() {
        this._polygons.map(function(t) {
          t.flip();
        });
      }, n.prototype.copyTransformAttributes = function(t) {
        return this.matrix = t.matrix, this.position = t.position, this.rotation = t.rotation, this.scaling = t.scaling, this.rotationQuaternion = t.rotationQuaternion, this;
      }, n.prototype.toVertexData = function(t, e) {
        t === void 0 && (t = null), e === void 0 && (e = null);
        var i = this.matrix.clone();
        i.invert();
        for (var r, o = this._polygons, a = [], s = [], l = [], c = null, u = null, h = v.Zero(), d = v.Zero(), p = fe.Zero(), f = new Ie(0, 0, 0, 0), m = [0, 0, 0], g = {}, y = 0, b = o.length; y < b; y++) {
          var T = o[y];
          t && t(T);
          for (var S = 2, E = T.vertices.length; S < E; S++) {
            m[0] = 0, m[1] = S - 1, m[2] = S;
            for (var A = 0; A < 3; A++) {
              h.copyFrom(T.vertices[m[A]].pos), d.copyFrom(T.vertices[m[A]].normal), T.vertices[m[A]].uv && (c || (c = []), p.copyFrom(T.vertices[m[A]].uv)), T.vertices[m[A]].vertColor && (u || (u = []), f.copyFrom(T.vertices[m[A]].vertColor));
              var R = v.TransformCoordinates(h, i), C = v.TransformNormal(d, i);
              r = g[R.x + "," + R.y + "," + R.z];
              var L = !1;
              c && c[2 * r] !== p.x && c[2 * r + 1] !== p.y && (L = !0);
              var I = !1;
              u && u[4 * r] !== f.r && u[4 * r + 1] !== f.g && u[4 * r + 2] !== f.b && u[4 * r + 3] !== f.a && (I = !0), (r === void 0 || l[3 * r] !== C.x || l[3 * r + 1] !== C.y || l[3 * r + 2] !== C.z || L || I) && (a.push(R.x, R.y, R.z), c && c.push(p.x, p.y), l.push(d.x, d.y, d.z), u && u.push(f.r, f.g, f.b, f.a), r = g[R.x + "," + R.y + "," + R.z] = a.length / 3 - 1), s.push(r), e && e();
            }
          }
        }
        var O = new Oe();
        return O.positions = a, O.normals = l, c && (O.uvs = c), u && (O.colors = u), O.indices = s, O;
      }, n.prototype.buildMeshGeometry = function(t, e, i) {
        var r, o = new ie(t, e), a = this._polygons, s = 0, l = {};
        if (i && a.sort(function(p, f) {
          return p.shared.meshId === f.shared.meshId ? p.shared.subMeshId - f.shared.subMeshId : p.shared.meshId - f.shared.meshId;
        }), this.toVertexData(function(p) {
          l[p.shared.meshId] || (l[p.shared.meshId] = {}), l[p.shared.meshId][p.shared.subMeshId] || (l[p.shared.meshId][p.shared.subMeshId] = { indexStart: 1 / 0, indexEnd: -1 / 0, materialIndex: p.shared.materialIndex }), r = l[p.shared.meshId][p.shared.subMeshId];
        }, function() {
          r.indexStart = Math.min(s, r.indexStart), r.indexEnd = Math.max(s, r.indexEnd), s++;
        }).applyToMesh(o), i) {
          var c = 0, u = void 0;
          for (var h in o.subMeshes = [], l) {
            for (var d in u = -1, l[h])
              r = l[h][d], Yn.CreateFromIndices(r.materialIndex + c, r.indexStart, r.indexEnd - r.indexStart + 1, o), u = Math.max(r.materialIndex, u);
            c += ++u;
          }
        }
        return o;
      }, n.prototype.toMesh = function(t, e, i, r) {
        e === void 0 && (e = null);
        var o = this.buildMeshGeometry(t, i, r);
        return o.material = e, o.position.copyFrom(this.position), o.rotation.copyFrom(this.rotation), this.rotationQuaternion && (o.rotationQuaternion = this.rotationQuaternion.clone()), o.scaling.copyFrom(this.scaling), o.computeWorldMatrix(!0), o;
      }, n;
    }();
    re.ShadersStore.meshUVSpaceRendererVertexShader = `precision highp float;attribute vec3 position;attribute vec3 normal;attribute vec2 uv;uniform mat4 projMatrix;varying vec2 vDecalTC;
#include<bonesDeclaration>
#include<bakedVertexAnimationDeclaration>
#include<morphTargetsVertexGlobalDeclaration>
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
#include<instancesDeclaration>
void main(void) {vec3 positionUpdated=position;vec3 normalUpdated=normal;
#include<morphTargetsVertexGlobal>
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
#include<instancesVertex>
#include<bonesVertex>
#include<bakedVertexAnimation>
vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);mat3 normWorldSM=mat3(finalWorld);vec3 vNormalW;
#if defined(INSTANCES) && defined(THIN_INSTANCES)
vNormalW=normalUpdated/vec3(dot(normWorldSM[0],normWorldSM[0]),dot(normWorldSM[1],normWorldSM[1]),dot(normWorldSM[2],normWorldSM[2]));vNormalW=normalize(normWorldSM*vNormalW);
#else
#ifdef NONUNIFORMSCALING
normWorldSM=transposeMat3(inverseMat3(normWorldSM));
#endif
vNormalW=normalize(normWorldSM*normalUpdated);
#endif
vec3 normalView=normalize((projMatrix*vec4(vNormalW,0.0)).xyz);vec3 decalTC=(projMatrix*worldPos).xyz;vDecalTC=decalTC.xy;gl_Position=vec4(uv*2.0-1.0,normalView.z>0.0 ? 2. : decalTC.z,1.0);}
`, re.ShadersStore.meshUVSpaceRendererPixelShader = `precision highp float;varying vec2 vDecalTC;uniform sampler2D textureSampler;void main(void) {if (vDecalTC.x<0. || vDecalTC.x>1. || vDecalTC.y<0. || vDecalTC.y>1.) {discard;}
gl_FragColor=texture2D(textureSampler,vDecalTC);}
`;
    var AP = function() {
      function n(t, e, i) {
        this._textureCreatedInternally = !1, this.clearColor = new Ie(0, 0, 0, 0), this._mesh = t, this._scene = e, this._options = je({ width: 1024, height: 1024, textureType: _.TEXTURETYPE_UNSIGNED_BYTE, generateMipMaps: !0, optimizeUVAllocation: !0 }, i);
      }
      return n._GetShader = function(t) {
        if (!t._meshUVSpaceRendererShader) {
          var e = new dr("meshUVSpaceRendererShader", t, { vertex: "meshUVSpaceRenderer", fragment: "meshUVSpaceRenderer" }, { attributes: ["position", "normal", "uv"], uniforms: ["world", "projMatrix"], samplers: ["textureSampler"], needAlphaBlending: !0 });
          e.backFaceCulling = !1, e.alphaMode = _.ALPHA_COMBINE, t.onDisposeObservable.add(function() {
            var i;
            (i = t._meshUVSpaceRendererShader) === null || i === void 0 || i.dispose(), t._meshUVSpaceRendererShader = null;
          }), t._meshUVSpaceRendererShader = e;
        }
        return t._meshUVSpaceRendererShader;
      }, n._IsRenderTargetTexture = function(t) {
        return t.renderList !== void 0;
      }, n.prototype.isReady = function() {
        return this.texture || this._createDiffuseRTT(), n._IsRenderTargetTexture(this.texture) ? this.texture.isReadyForRendering() : this.texture.isReady();
      }, n.prototype.renderTexture = function(t, e, i, r, o) {
        if (o === void 0 && (o = 0), this.texture || this._createDiffuseRTT(), n._IsRenderTargetTexture(this.texture)) {
          var a = this._createProjectionMatrix(e, i, r, o), s = n._GetShader(this._scene);
          s.setTexture("textureSampler", t), s.setMatrix("projMatrix", a), this.texture.render();
        }
      }, n.prototype.clear = function() {
        if (n._IsRenderTargetTexture(this.texture) && this.texture.renderTarget) {
          var t = this._scene.getEngine();
          t.bindFramebuffer(this.texture.renderTarget), t.clear(this.clearColor, !0, !0, !0), t.unBindFramebuffer(this.texture.renderTarget);
        }
      }, n.prototype.dispose = function() {
        this._textureCreatedInternally && (this.texture.dispose(), this._textureCreatedInternally = !1);
      }, n.prototype._createDiffuseRTT = function() {
        this._textureCreatedInternally = !0;
        var t = this._createRenderTargetTexture(this._options.width, this._options.height);
        t.setMaterialForRendering(this._mesh, n._GetShader(this._scene)), this.texture = t;
      }, n.prototype._createRenderTargetTexture = function(t, e) {
        var i = this, r = new Mi(this._mesh.name + "_uvspaceTexture", { width: t, height: e }, this._scene, this._options.generateMipMaps, !0, this._options.textureType, !1, this._options.generateMipMaps ? _.TEXTURE_TRILINEAR_SAMPLINGMODE : _.TEXTURE_BILINEAR_SAMPLINGMODE, !1, !1, !1, _.TEXTUREFORMAT_RGBA);
        return r.renderParticles = !1, r.optimizeUVAllocation = !!this._options.optimizeUVAllocation, r.onClearObservable.addOnce(function() {
          i._scene.getEngine().clear(i.clearColor, !0, !0, !0), r.onClearObservable.add(function() {
          });
        }), r.renderList = [this._mesh], r;
      }, n.prototype._createProjectionMatrix = function(t, e, i, r) {
        r === void 0 && (r = 0);
        var o = -Math.atan2(e.z, e.x) - Math.PI / 2, a = Math.sqrt(e.x * e.x + e.z * e.z), s = Math.atan2(e.y, a), l = t.add(e.scale(0.5 * i.z)), c = B.RotationYawPitchRoll(o, s, r).multiply(B.Translation(l.x, l.y, l.z)), u = B.Invert(c), h = B.FromArray([2 / i.x, 0, 0, 0, 0, 2 / i.y, 0, 0, 0, 0, 1 / i.z, 0, 0, 0, 0, 1]), d = B.FromArray([0.5, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0, 1]);
        return u.multiply(h).multiply(d);
      }, n;
    }();
    ie._TrailMeshParser = function(n, t) {
      return NT.Parse(n, t);
    };
    var lu, NT = function(n) {
      function t(e, i, r, o, a, s) {
        o === void 0 && (o = 1), a === void 0 && (a = 60), s === void 0 && (s = !0);
        var l = n.call(this, e, r) || this;
        l._sectionPolygonPointsCount = 4, l._running = !1, l._autoStart = s, l._generator = i, l.diameter = o, l._length = a, l._sectionVectors = [], l._sectionNormalVectors = [];
        for (var c = 0; c < l._sectionPolygonPointsCount; c++)
          l._sectionVectors[c] = v.Zero(), l._sectionNormalVectors[c] = v.Zero();
        return l._createMesh(), l;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "TrailMesh";
      }, t.prototype._createMesh = function() {
        var e = new Oe(), i = [], r = [], o = [], a = v.Zero();
        a = this._generator instanceof Dt && this._generator.hasBoundingInfo ? this._generator.getBoundingInfo().boundingBox.centerWorld : this._generator.position;
        for (var s = 2 * Math.PI / this._sectionPolygonPointsCount, l = 0; l < this._sectionPolygonPointsCount; l++)
          i.push(a.x + Math.cos(l * s) * this.diameter, a.y + Math.sin(l * s) * this.diameter, a.z);
        for (l = 1; l <= this._length; l++) {
          for (var c = 0; c < this._sectionPolygonPointsCount; c++)
            i.push(a.x + Math.cos(c * s) * this.diameter, a.y + Math.sin(c * s) * this.diameter, a.z);
          var u = i.length / 3 - 2 * this._sectionPolygonPointsCount;
          for (c = 0; c < this._sectionPolygonPointsCount - 1; c++)
            o.push(u + c, u + c + this._sectionPolygonPointsCount, u + c + this._sectionPolygonPointsCount + 1), o.push(u + c, u + c + this._sectionPolygonPointsCount + 1, u + c + 1);
          o.push(u + this._sectionPolygonPointsCount - 1, u + this._sectionPolygonPointsCount - 1 + this._sectionPolygonPointsCount, u + this._sectionPolygonPointsCount), o.push(u + this._sectionPolygonPointsCount - 1, u + this._sectionPolygonPointsCount, u);
        }
        Oe.ComputeNormals(i, o, r), e.positions = i, e.normals = r, e.indices = o, e.applyToMesh(this, !0), this._autoStart && this.start();
      }, t.prototype.start = function() {
        var e = this;
        this._running || (this._running = !0, this._beforeRenderObserver = this.getScene().onBeforeRenderObservable.add(function() {
          e.update();
        }));
      }, t.prototype.stop = function() {
        this._beforeRenderObserver && this._running && (this._running = !1, this.getScene().onBeforeRenderObservable.remove(this._beforeRenderObserver));
      }, t.prototype.update = function() {
        var e = this.getVerticesData(P.PositionKind), i = this.getVerticesData(P.NormalKind), r = this._generator.getWorldMatrix();
        if (e && i) {
          for (var o = 3 * this._sectionPolygonPointsCount; o < e.length; o++)
            e[o - 3 * this._sectionPolygonPointsCount] = e[o] - i[o] / this._length * this.diameter;
          for (o = 3 * this._sectionPolygonPointsCount; o < i.length; o++)
            i[o - 3 * this._sectionPolygonPointsCount] = i[o];
          var a = e.length - 3 * this._sectionPolygonPointsCount, s = 2 * Math.PI / this._sectionPolygonPointsCount;
          for (o = 0; o < this._sectionPolygonPointsCount; o++)
            this._sectionVectors[o].copyFromFloats(Math.cos(o * s) * this.diameter, Math.sin(o * s) * this.diameter, 0), this._sectionNormalVectors[o].copyFromFloats(Math.cos(o * s), Math.sin(o * s), 0), v.TransformCoordinatesToRef(this._sectionVectors[o], r, this._sectionVectors[o]), v.TransformNormalToRef(this._sectionNormalVectors[o], r, this._sectionNormalVectors[o]);
          for (o = 0; o < this._sectionPolygonPointsCount; o++)
            e[a + 3 * o] = this._sectionVectors[o].x, e[a + 3 * o + 1] = this._sectionVectors[o].y, e[a + 3 * o + 2] = this._sectionVectors[o].z, i[a + 3 * o] = this._sectionNormalVectors[o].x, i[a + 3 * o + 1] = this._sectionNormalVectors[o].y, i[a + 3 * o + 2] = this._sectionNormalVectors[o].z;
          this.updateVerticesData(P.PositionKind, e, !0, !1), this.updateVerticesData(P.NormalKind, i, !0, !1);
        }
      }, t.prototype.clone = function(e, i) {
        return e === void 0 && (e = ""), new t(e, i === void 0 ? this._generator : i, this.getScene(), this.diameter, this._length, this._autoStart);
      }, t.prototype.serialize = function(e) {
        n.prototype.serialize.call(this, e), e.generatorId = this._generator.id;
      }, t.Parse = function(e, i) {
        var r, o, a = (r = i.getLastMeshById(e.generatorId)) !== null && r !== void 0 ? r : i.getLastTransformNodeById(e.generatorId);
        if (!a)
          throw new Error("TrailMesh: generator not found with ID " + e.generatorId);
        return new t(e.name, a, i, (o = e.diameter) !== null && o !== void 0 ? o : e._diameter, e._length, e._autoStart);
      }, t;
    }(ie), RP = function(n, t, e) {
      this.quality = n, this.distance = t, this.optimizeMesh = e;
    }, FT = function() {
      function n() {
        this.running = !1, this._simplificationArray = [];
      }
      return n.prototype.addTask = function(t) {
        this._simplificationArray.push(t);
      }, n.prototype.executeNext = function() {
        var t = this._simplificationArray.pop();
        t ? (this.running = !0, this.runSimplification(t)) : this.running = !1;
      }, n.prototype.runSimplification = function(t) {
        var e = this;
        if (t.parallelProcessing)
          t.settings.forEach(function(r) {
            e._getSimplifier(t).simplify(r, function(o) {
              r.distance !== void 0 && t.mesh.addLODLevel(r.distance, o), o.isVisible = !0, r.quality === t.settings[t.settings.length - 1].quality && t.successCallback && t.successCallback(), e.executeNext();
            });
          });
        else {
          var i = this._getSimplifier(t);
          So.Run(t.settings.length, function(r) {
            var o, a;
            o = t.settings[r.index], a = function() {
              r.executeNext();
            }, i.simplify(o, function(s) {
              o.distance !== void 0 && t.mesh.addLODLevel(o.distance, s), s.isVisible = !0, a();
            });
          }, function() {
            t.successCallback && t.successCallback(), e.executeNext();
          });
        }
      }, n.prototype._getSimplifier = function(t) {
        return t.simplificationType, lu.QUADRATIC, new LT(t.mesh);
      }, n;
    }();
    (function(n) {
      n[n.QUADRATIC = 0] = "QUADRATIC";
    })(lu || (lu = {}));
    var pN = function(n) {
      this._vertices = n, this.error = new Array(4), this.deleted = !1, this.isDirty = !1, this.deletePending = !1, this.borderFactor = 0;
    }, fN = function() {
      function n(t, e) {
        this.position = t, this.id = e, this.isBorder = !0, this.q = new CP(), this.triangleCount = 0, this.triangleStart = 0, this.originalOffsets = [];
      }
      return n.prototype.updatePosition = function(t) {
        this.position.copyFrom(t);
      }, n;
    }(), CP = function() {
      function n(t) {
        this.data = new Array(10);
        for (var e = 0; e < 10; ++e)
          t && t[e] ? this.data[e] = t[e] : this.data[e] = 0;
      }
      return n.prototype.det = function(t, e, i, r, o, a, s, l, c) {
        return this.data[t] * this.data[o] * this.data[c] + this.data[i] * this.data[r] * this.data[l] + this.data[e] * this.data[a] * this.data[s] - this.data[i] * this.data[o] * this.data[s] - this.data[t] * this.data[a] * this.data[l] - this.data[e] * this.data[r] * this.data[c];
      }, n.prototype.addInPlace = function(t) {
        for (var e = 0; e < 10; ++e)
          this.data[e] += t.data[e];
      }, n.prototype.addArrayInPlace = function(t) {
        for (var e = 0; e < 10; ++e)
          this.data[e] += t[e];
      }, n.prototype.add = function(t) {
        for (var e = new n(), i = 0; i < 10; ++i)
          e.data[i] = this.data[i] + t.data[i];
        return e;
      }, n.FromData = function(t, e, i, r) {
        return new n(n.DataFromNumbers(t, e, i, r));
      }, n.DataFromNumbers = function(t, e, i, r) {
        return [t * t, t * e, t * i, t * r, e * e, e * i, e * r, i * i, i * r, r * r];
      }, n;
    }(), _N = function(n, t) {
      this.vertexId = n, this.triangleId = t;
    }, LT = function() {
      function n(t) {
        this._mesh = t, this.syncIterations = 5e3, this.aggressiveness = 7, this.decimationIterations = 100, this.boundingBoxEpsilon = Ge;
      }
      return n.prototype.simplify = function(t, e) {
        var i = this;
        this._initDecimatedMesh(), So.Run(this._mesh.subMeshes.length, function(r) {
          i._initWithMesh(r.index, function() {
            i._runDecimation(t, r.index, function() {
              r.executeNext();
            });
          }, t.optimizeMesh);
        }, function() {
          setTimeout(function() {
            e(i._reconstructedMesh);
          }, 0);
        });
      }, n.prototype._runDecimation = function(t, e, i) {
        var r = this, o = ~~(this._triangles.length * t.quality), a = 0, s = this._triangles.length;
        So.Run(this.decimationIterations, function(l) {
          var c, u;
          s - a <= o ? l.breakLoop() : (c = l.index, u = function() {
            l.executeNext();
          }, setTimeout(function() {
            c % 5 == 0 && r._updateMesh(c === 0);
            for (var h = 0; h < r._triangles.length; ++h)
              r._triangles[h].isDirty = !1;
            var d = 1e-9 * Math.pow(c + 3, r.aggressiveness);
            So.SyncAsyncForLoop(r._triangles.length, r.syncIterations, function(p) {
              var f = ~~((r._triangles.length / 2 + p) % r._triangles.length), m = r._triangles[f];
              if (m && !(m.error[3] > d || m.deleted || m.isDirty))
                for (var g = function(b) {
                  if (m.error[b] < d) {
                    var T = [], S = [], E = m._vertices[b], A = m._vertices[(b + 1) % 3];
                    if (E.isBorder || A.isBorder)
                      return "continue";
                    var R = v.Zero();
                    r._calculateError(E, A, R);
                    var C = [];
                    if (r._isFlipped(E, A, R, T, C) || r._isFlipped(A, E, R, S, C) || T.indexOf(!0) < 0 || S.indexOf(!0) < 0)
                      return "continue";
                    var L = [];
                    if (C.forEach(function(z) {
                      L.indexOf(z) === -1 && (z.deletePending = !0, L.push(z));
                    }), L.length % 2 != 0)
                      return "continue";
                    E.q = A.q.add(E.q), E.updatePosition(R);
                    var I = r._references.length;
                    a = r._updateTriangles(E, E, T, a), a = r._updateTriangles(E, A, S, a);
                    var O = r._references.length - I;
                    if (O <= E.triangleCount) {
                      if (O)
                        for (var w = 0; w < O; w++)
                          r._references[E.triangleStart + w] = r._references[I + w];
                    } else
                      E.triangleStart = I;
                    return E.triangleCount = O, "break";
                  }
                }, y = 0; y < 3 && g(y) !== "break"; ++y)
                  ;
            }, u, function() {
              return s - a <= o;
            });
          }, 0));
        }, function() {
          setTimeout(function() {
            r._reconstructMesh(e), i();
          }, 0);
        });
      }, n.prototype._initWithMesh = function(t, e, i) {
        var r = this;
        this._vertices = [], this._triangles = [];
        var o = this._mesh.getVerticesData(P.PositionKind), a = this._mesh.getIndices(), s = this._mesh.subMeshes[t], l = [], c = s.verticesCount;
        So.SyncAsyncForLoop(c, this.syncIterations / 4 >> 0, function(u) {
          if (o) {
            var h = u + s.verticesStart, d = v.FromArray(o, 3 * h), p = function(f) {
              if (i) {
                for (var m = 0; m < r._vertices.length; ++m)
                  if (r._vertices[m].position.equalsWithEpsilon(f, 1e-4))
                    return r._vertices[m];
              }
              return null;
            }(d) || new fN(d, r._vertices.length);
            p.originalOffsets.push(h), p.id === r._vertices.length && r._vertices.push(p), l.push(p.id);
          }
        }, function() {
          So.SyncAsyncForLoop(s.indexCount / 3, r.syncIterations, function(u) {
            if (a) {
              var h = 3 * (s.indexStart / 3 + u), d = a[h + 0], p = a[h + 1], f = a[h + 2], m = r._vertices[l[d - s.verticesStart]], g = r._vertices[l[p - s.verticesStart]], y = r._vertices[l[f - s.verticesStart]], b = new pN([m, g, y]);
              b.originalOffset = h, r._triangles.push(b);
            }
          }, function() {
            r._init(e);
          });
        });
      }, n.prototype._init = function(t) {
        var e = this;
        So.SyncAsyncForLoop(this._triangles.length, this.syncIterations, function(i) {
          var r = e._triangles[i];
          r.normal = v.Cross(r._vertices[1].position.subtract(r._vertices[0].position), r._vertices[2].position.subtract(r._vertices[0].position)).normalize();
          for (var o = 0; o < 3; o++)
            r._vertices[o].q.addArrayInPlace(CP.DataFromNumbers(r.normal.x, r.normal.y, r.normal.z, -v.Dot(r.normal, r._vertices[0].position)));
        }, function() {
          So.SyncAsyncForLoop(e._triangles.length, e.syncIterations, function(i) {
            for (var r = e._triangles[i], o = 0; o < 3; ++o)
              r.error[o] = e._calculateError(r._vertices[o], r._vertices[(o + 1) % 3]);
            r.error[3] = Math.min(r.error[0], r.error[1], r.error[2]);
          }, function() {
            t();
          });
        });
      }, n.prototype._reconstructMesh = function(t) {
        var e, i, r, o = [];
        for (e = 0; e < this._vertices.length; ++e)
          this._vertices[e].triangleCount = 0;
        for (e = 0; e < this._triangles.length; ++e)
          if (!this._triangles[e].deleted) {
            for (i = this._triangles[e], r = 0; r < 3; ++r)
              i._vertices[r].triangleCount = 1;
            o.push(i);
          }
        var a = this._reconstructedMesh.getVerticesData(P.PositionKind) || [], s = this._reconstructedMesh.getVerticesData(P.NormalKind) || [], l = this._reconstructedMesh.getVerticesData(P.UVKind) || [], c = this._reconstructedMesh.getVerticesData(P.ColorKind) || [], u = this._mesh.getVerticesData(P.NormalKind), h = this._mesh.getVerticesData(P.UVKind), d = this._mesh.getVerticesData(P.ColorKind), p = 0, f = function() {
          var A = m._vertices[e];
          A.id = p, A.triangleCount && A.originalOffsets.forEach(function(R) {
            a.push(A.position.x), a.push(A.position.y), a.push(A.position.z), u && u.length && (s.push(u[3 * R]), s.push(u[3 * R + 1]), s.push(u[3 * R + 2])), h && h.length && (l.push(h[2 * R]), l.push(h[2 * R + 1])), d && d.length && (c.push(d[4 * R]), c.push(d[4 * R + 1]), c.push(d[4 * R + 2]), c.push(d[4 * R + 3])), ++p;
          });
        }, m = this;
        for (e = 0; e < this._vertices.length; ++e)
          f();
        var g = this._reconstructedMesh.getTotalIndices(), y = this._reconstructedMesh.getTotalVertices(), b = this._reconstructedMesh.subMeshes;
        this._reconstructedMesh.subMeshes = [];
        var T = this._reconstructedMesh.getIndices(), S = this._mesh.getIndices();
        for (e = 0; e < o.length; ++e)
          i = o[e], [0, 1, 2].forEach(function(A) {
            var R = S[i.originalOffset + A], C = i._vertices[A].originalOffsets.indexOf(R);
            C < 0 && (C = 0), T.push(i._vertices[A].id + C + y);
          });
        this._reconstructedMesh.setIndices(T), this._reconstructedMesh.setVerticesData(P.PositionKind, a), s.length > 0 && this._reconstructedMesh.setVerticesData(P.NormalKind, s), l.length > 0 && this._reconstructedMesh.setVerticesData(P.UVKind, l), c.length > 0 && this._reconstructedMesh.setVerticesData(P.ColorKind, c);
        var E = this._mesh.subMeshes[t];
        t > 0 && (this._reconstructedMesh.subMeshes = [], b.forEach(function(A) {
          Yn.AddToMesh(A.materialIndex, A.verticesStart, A.verticesCount, A.indexStart, A.indexCount, A.getMesh());
        }), Yn.AddToMesh(E.materialIndex, y, p, g, 3 * o.length, this._reconstructedMesh));
      }, n.prototype._initDecimatedMesh = function() {
        this._reconstructedMesh = new ie(this._mesh.name + "Decimated", this._mesh.getScene()), this._reconstructedMesh.material = this._mesh.material, this._reconstructedMesh.parent = this._mesh.parent, this._reconstructedMesh.isVisible = !1, this._reconstructedMesh.renderingGroupId = this._mesh.renderingGroupId;
      }, n.prototype._isFlipped = function(t, e, i, r, o) {
        for (var a = 0; a < t.triangleCount; ++a) {
          var s = this._triangles[this._references[t.triangleStart + a].triangleId];
          if (!s.deleted) {
            var l = this._references[t.triangleStart + a].vertexId, c = s._vertices[(l + 1) % 3], u = s._vertices[(l + 2) % 3];
            if (c !== e && u !== e) {
              var h = c.position.subtract(i);
              h = h.normalize();
              var d = u.position.subtract(i);
              if (d = d.normalize(), Math.abs(v.Dot(h, d)) > 0.999)
                return !0;
              var p = v.Cross(h, d).normalize();
              if (r[a] = !1, v.Dot(p, s.normal) < 0.2)
                return !0;
            } else
              r[a] = !0, o.push(s);
          }
        }
        return !1;
      }, n.prototype._updateTriangles = function(t, e, i, r) {
        for (var o = r, a = 0; a < e.triangleCount; ++a) {
          var s = this._references[e.triangleStart + a], l = this._triangles[s.triangleId];
          l.deleted || (i[a] && l.deletePending ? (l.deleted = !0, o++) : (l._vertices[s.vertexId] = t, l.isDirty = !0, l.error[0] = this._calculateError(l._vertices[0], l._vertices[1]) + l.borderFactor / 2, l.error[1] = this._calculateError(l._vertices[1], l._vertices[2]) + l.borderFactor / 2, l.error[2] = this._calculateError(l._vertices[2], l._vertices[0]) + l.borderFactor / 2, l.error[3] = Math.min(l.error[0], l.error[1], l.error[2]), this._references.push(s)));
        }
        return o;
      }, n.prototype._identifyBorder = function() {
        for (var t = 0; t < this._vertices.length; ++t) {
          var e = [], i = [], r = this._vertices[t], o = void 0;
          for (o = 0; o < r.triangleCount; ++o)
            for (var a = this._triangles[this._references[r.triangleStart + o].triangleId], s = 0; s < 3; s++) {
              for (var l = 0, c = a._vertices[s]; l < e.length && i[l] !== c.id; )
                ++l;
              l === e.length ? (e.push(1), i.push(c.id)) : e[l]++;
            }
          for (o = 0; o < e.length; ++o)
            e[o] === 1 ? this._vertices[i[o]].isBorder = !0 : this._vertices[i[o]].isBorder = !1;
        }
      }, n.prototype._updateMesh = function(t) {
        var e, i, r, o;
        if (t === void 0 && (t = !1), !t) {
          var a = [];
          for (e = 0; e < this._triangles.length; ++e)
            this._triangles[e].deleted || a.push(this._triangles[e]);
          this._triangles = a;
        }
        for (e = 0; e < this._vertices.length; ++e)
          this._vertices[e].triangleCount = 0, this._vertices[e].triangleStart = 0;
        for (e = 0; e < this._triangles.length; ++e)
          for (i = this._triangles[e], r = 0; r < 3; ++r)
            (o = i._vertices[r]).triangleCount++;
        var s = 0;
        for (e = 0; e < this._vertices.length; ++e)
          this._vertices[e].triangleStart = s, s += this._vertices[e].triangleCount, this._vertices[e].triangleCount = 0;
        var l = new Array(3 * this._triangles.length);
        for (e = 0; e < this._triangles.length; ++e)
          for (i = this._triangles[e], r = 0; r < 3; ++r)
            l[(o = i._vertices[r]).triangleStart + o.triangleCount] = new _N(r, e), o.triangleCount++;
        this._references = l, t && this._identifyBorder();
      }, n.prototype._vertexError = function(t, e) {
        var i = e.x, r = e.y, o = e.z;
        return t.data[0] * i * i + 2 * t.data[1] * i * r + 2 * t.data[2] * i * o + 2 * t.data[3] * i + t.data[4] * r * r + 2 * t.data[5] * r * o + 2 * t.data[6] * r + t.data[7] * o * o + 2 * t.data[8] * o + t.data[9];
      }, n.prototype._calculateError = function(t, e, i) {
        var r = t.q.add(e.q), o = t.isBorder && e.isBorder, a = 0, s = r.det(0, 1, 2, 1, 4, 5, 2, 5, 7);
        if (s === 0 || o) {
          var l = t.position.add(e.position).divide(new v(2, 2, 2)), c = this._vertexError(r, t.position), u = this._vertexError(r, e.position), h = this._vertexError(r, l);
          (a = Math.min(c, u, h)) === c ? i && i.copyFrom(t.position) : a === u ? i && i.copyFrom(e.position) : i && i.copyFrom(l);
        } else
          i || (i = v.Zero()), i.x = -1 / s * r.det(1, 2, 3, 4, 5, 6, 5, 7, 8), i.y = 1 / s * r.det(0, 2, 3, 1, 5, 6, 2, 7, 8), i.z = -1 / s * r.det(0, 1, 3, 1, 4, 6, 2, 5, 8), a = this._vertexError(r, i);
        return a;
      }, n;
    }();
    Object.defineProperty(Ue.prototype, "simplificationQueue", { get: function() {
      if (!this._simplificationQueue) {
        this._simplificationQueue = new FT();
        var n = this._getComponent(we.NAME_SIMPLIFICATIONQUEUE);
        n || (n = new wT(this), this._addComponent(n));
      }
      return this._simplificationQueue;
    }, set: function(n) {
      this._simplificationQueue = n;
    }, enumerable: !0, configurable: !0 }), ie.prototype.simplify = function(n, t, e, i) {
      return t === void 0 && (t = !0), e === void 0 && (e = lu.QUADRATIC), this.getScene().simplificationQueue.addTask({ settings: n, parallelProcessing: t, mesh: this, simplificationType: e, successCallback: i }), this;
    };
    var zr, Il, $a, wT = function() {
      function n(t) {
        this.name = we.NAME_SIMPLIFICATIONQUEUE, this.scene = t;
      }
      return n.prototype.register = function() {
        this.scene._beforeCameraUpdateStage.registerStep(we.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE, this, this._beforeCameraUpdate);
      }, n.prototype.rebuild = function() {
      }, n.prototype.dispose = function() {
      }, n.prototype._beforeCameraUpdate = function() {
        this.scene._simplificationQueue && !this.scene._simplificationQueue.running && this.scene._simplificationQueue.executeNext();
      }, n;
    }();
    (function(n) {
      n[n.POINTS_MODE_POINTS = 0] = "POINTS_MODE_POINTS", n[n.POINTS_MODE_PATHS = 1] = "POINTS_MODE_PATHS";
    })(zr || (zr = {})), function(n) {
      n[n.FACES_MODE_SINGLE_SIDED = 0] = "FACES_MODE_SINGLE_SIDED", n[n.FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING = 1] = "FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING", n[n.FACES_MODE_DOUBLE_SIDED = 2] = "FACES_MODE_DOUBLE_SIDED";
    }(Il || (Il = {})), function(n) {
      n[n.AUTO_DIRECTIONS_FROM_FIRST_SEGMENT = 0] = "AUTO_DIRECTIONS_FROM_FIRST_SEGMENT", n[n.AUTO_DIRECTIONS_FROM_ALL_SEGMENTS = 1] = "AUTO_DIRECTIONS_FROM_ALL_SEGMENTS", n[n.AUTO_DIRECTIONS_ENHANCED = 2] = "AUTO_DIRECTIONS_ENHANCED", n[n.AUTO_DIRECTIONS_NONE = 99] = "AUTO_DIRECTIONS_NONE";
    }($a || ($a = {}));
    var j_ = function(n) {
      function t(e, i, r) {
        var o, a, s, l, c = this;
        return (c = n.call(this, e, i, null, null, !1, !1) || this).name = e, c._options = r, c._lazy = !1, c._updatable = !1, c._engine = i.getEngine(), c._lazy = (o = r.lazy) !== null && o !== void 0 && o, c._updatable = (a = r.updatable) !== null && a !== void 0 && a, c._vertexPositions = [], c._indices = [], c._uvs = [], c._points = [], c._colorPointers = (s = r.colorPointers) !== null && s !== void 0 ? s : [], c._widths = (l = r.widths) !== null && l !== void 0 ? l : new Array(r.points.length).fill(1), c;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "GreasedLineMesh";
      }, t.prototype._updateWidthsWithValue = function(e) {
        for (var i = 0, r = 0, o = this._points; r < o.length; r++)
          i += o[r].length;
        for (var a = i / 3 * 2 - this._widths.length, s = 0; s < a; s++)
          this._widths.push(e);
      }, t.prototype.updateLazy = function() {
        var e, i;
        this._setPoints(this._points), this._options.colorPointers || this._updateColorPointers(), this._createVertexBuffers((e = this._options.ribbonOptions) === null || e === void 0 ? void 0 : e.smoothShading), this.refreshBoundingInfo(), (i = this.greasedLineMaterial) === null || i === void 0 || i.updateLazy();
      }, t.prototype.addPoints = function(e, i) {
        for (var r = 0, o = e; r < o.length; r++) {
          var a = o[r];
          this._points.push(a);
        }
        this._lazy || this.setPoints(this._points, i);
      }, t.prototype.dispose = function() {
        n.prototype.dispose.call(this);
      }, t.prototype.isLazy = function() {
        return this._lazy;
      }, Object.defineProperty(t.prototype, "offsets", { get: function() {
        return this._offsets;
      }, set: function(e) {
        this._offsets = e, this._offsetsBuffer ? this._offsetsBuffer.update(e) : this._createOffsetsBuffer(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "widths", { get: function() {
        return this._widths;
      }, set: function(e) {
        this._widths = e, this._lazy || this._widthsBuffer && this._widthsBuffer.update(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "colorPointers", { get: function() {
        return this._colorPointers;
      }, set: function(e) {
        this._colorPointers = e, this._lazy || this._colorPointersBuffer && this._colorPointersBuffer.update(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "greasedLineMaterial", { get: function() {
        var e, i;
        return this.material && this.material instanceof z_ ? this.material : ((i = (e = this.material) === null || e === void 0 ? void 0 : e.pluginManager) === null || i === void 0 ? void 0 : i.getPlugin(Pl.GREASED_LINE_MATERIAL_NAME)) || void 0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "points", { get: function() {
        var e = [];
        return Ui.DeepCopy(this._points, e), e;
      }, enumerable: !1, configurable: !0 }), t.prototype.setPoints = function(e, i) {
        this._points = e, this._updateWidths(), i != null && i.colorPointers || this._updateColorPointers(), this._setPoints(e, i);
      }, t.prototype._initGreasedLine = function() {
        this._vertexPositions = [], this._indices = [], this._uvs = [];
      }, t.prototype._createLineOptions = function() {
        return { points: this._points, colorPointers: this._colorPointers, lazy: this._lazy, updatable: this._updatable, uvs: this._uvs, widths: this._widths, ribbonOptions: this._options.ribbonOptions };
      }, t.prototype.serialize = function(e) {
        n.prototype.serialize.call(this, e), e.type = this.getClassName(), e.lineOptions = this._createLineOptions();
      }, t.prototype._createVertexBuffers = function(e) {
        e === void 0 && (e = !1);
        var i = new Oe();
        return i.positions = this._vertexPositions, i.indices = this._indices, i.uvs = this._uvs, e && (i.normals = [], Oe.ComputeNormals(this._vertexPositions, this._indices, i.normals)), i.applyToMesh(this, this._options.updatable), i;
      }, t.prototype._createOffsetsBuffer = function(e) {
        var i = this._scene.getEngine(), r = new Yi(i, e, this._updatable, 3);
        this.setVerticesBuffer(r.createVertexBuffer("grl_offsets", 0, 3)), this._offsetsBuffer = r;
      }, t;
    }(ie);
    ie._GreasedLineMeshParser = function(n, t) {
      return Y_.Parse(n, t);
    };
    var Y_ = function(n) {
      function t(e, i, r) {
        var o = n.call(this, e, i, r) || this;
        return o.name = e, o.intersectionThreshold = 0.1, o._previousAndSide = [], o._nextAndCounters = [], r.points && o.addPoints(Oi.ConvertPoints(r.points)), o;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "GreasedLineMesh";
      }, t.prototype._updateColorPointers = function() {
        var e = this;
        if (!this._options.colorPointers) {
          var i = 0;
          this._colorPointers = [], this._points.forEach(function(r) {
            for (var o = 0; o < r.length; o += 3)
              e._colorPointers.push(i), e._colorPointers.push(i++);
          });
        }
      }, t.prototype._updateWidths = function() {
        n.prototype._updateWidthsWithValue.call(this, 0);
      }, t.prototype._setPoints = function(e) {
        var i = this;
        this._points = e, this._options.points = e, this._initGreasedLine();
        var r = 0;
        e.forEach(function(o) {
          for (var a, s = [], l = [], c = [], u = Oi.GetLineLength(o), h = 0, d = 0; d < o.length; h++, d += 3) {
            var p = o.slice(0, d + 3), f = Oi.GetLineLength(p) / u;
            if (l.push(o[d], o[d + 1], o[d + 2]), l.push(o[d], o[d + 1], o[d + 2]), s.push(f), s.push(f), d < o.length - 3) {
              var m = 2 * h + r;
              c.push(m, m + 1, m + 2), c.push(m + 2, m + 1, m + 3);
            }
          }
          r += o.length / 3 * 2;
          var g = [], y = [], b = [], T = [];
          i._preprocess(l, g, y, b, T);
          for (var S = 0, E = l; S < E.length; S++) {
            var A = E[S];
            i._vertexPositions.push(A);
          }
          for (var R = 0, C = c; R < C.length; R++) {
            var L = C[R];
            i._indices.push(L);
          }
          for (L = 0; L < b.length; L++)
            i._previousAndSide.push(g[3 * L], g[3 * L + 1], g[3 * L + 2], b[L]), i._nextAndCounters.push(y[3 * L], y[3 * L + 1], y[3 * L + 2], s[L]);
          for (var I = 0, O = T = (a = i._options.uvs) !== null && a !== void 0 ? a : T; I < O.length; I++) {
            var w = O[I];
            i._uvs.push(w);
          }
        }), this._lazy || (this._options.colorPointers || this._updateColorPointers(), this._createVertexBuffers(), this.refreshBoundingInfo());
      }, t.prototype.clone = function(e, i) {
        e === void 0 && (e = "".concat(this.name, "-cloned"));
        var r = this._createLineOptions(), o = {};
        Ui.DeepCopy(r, o, ["instance"], void 0, !0);
        var a = new t(e, this._scene, o);
        return i && (a.parent = i), a.material = this.material, a;
      }, t.prototype.serialize = function(e) {
        n.prototype.serialize.call(this, e), e.type = this.getClassName(), e.lineOptions = this._createLineOptions();
      }, t.Parse = function(e, i) {
        var r = e.lineOptions;
        return new t(e.name, i, r);
      }, t.prototype._initGreasedLine = function() {
        n.prototype._initGreasedLine.call(this), this._previousAndSide = [], this._nextAndCounters = [];
      }, t.prototype.intersects = function(e, i, r, o, a, s) {
        o === void 0 && (o = !1), s === void 0 && (s = !1);
        var l = new Ki(), c = this.findAllIntersections(e, i, r, o, a, s, !0);
        if ((c == null ? void 0 : c.length) === 1) {
          var u = c[0];
          l.hit = !0, l.distance = u.distance, l.ray = e, l.pickedMesh = this, l.pickedPoint = u.point;
        }
        return l;
      }, t.prototype.findAllIntersections = function(e, i, r, o, a, s, l) {
        var c, u;
        if (o === void 0 && (o = !1), s === void 0 && (s = !1), l === void 0 && (l = !1), !o || s || e.intersectsSphere(this._boundingSphere, this.intersectionThreshold) !== !1) {
          var h = this.getIndices(), d = this.getVerticesData(P.PositionKind), p = this._widths, f = (u = (c = this.greasedLineMaterial) === null || c === void 0 ? void 0 : c.width) !== null && u !== void 0 ? u : 1, m = [];
          if (h && d && p) {
            var g, y = 0;
            for (y = 0, g = h.length - 1; y < g; y += 3) {
              var b = h[y], T = h[y + 1];
              t._V_START.fromArray(d, 3 * b), t._V_END.fromArray(d, 3 * T), this._offsets && (t._V_OFFSET_START.fromArray(this._offsets, 3 * b), t._V_OFFSET_END.fromArray(this._offsets, 3 * T), t._V_START.addInPlace(t._V_OFFSET_START), t._V_END.addInPlace(t._V_OFFSET_END));
              var S = Math.floor(y / 3), E = p[S] !== void 0 ? p[S] : 1, A = this.intersectionThreshold * (f * E) / 2, R = e.intersectionSegment(t._V_START, t._V_END, A);
              if (R !== -1 && (m.push({ distance: R, point: e.direction.normalize().multiplyByFloats(R, R, R).add(e.origin) }), l))
                return m;
            }
            y = g;
          }
          return m;
        }
      }, Object.defineProperty(t.prototype, "_boundingSphere", { get: function() {
        return this.getBoundingInfo().boundingSphere;
      }, enumerable: !1, configurable: !0 }), t._CompareV3 = function(e, i, r) {
        var o = 6 * e, a = 6 * i;
        return r[o] === r[a] && r[o + 1] === r[a + 1] && r[o + 2] === r[a + 2];
      }, t._CopyV3 = function(e, i) {
        var r = 6 * e;
        return [i[r], i[r + 1], i[r + 2]];
      }, t.prototype._preprocess = function(e, i, r, o, a) {
        var s = e.length / 6, l = [];
        l = t._CompareV3(0, s - 1, e) ? t._CopyV3(s - 2, e) : t._CopyV3(0, e), i.push(l[0], l[1], l[2]), i.push(l[0], l[1], l[2]);
        for (var c = 0; c < s; c++)
          o.push(1), o.push(-1), this._options.uvs || (a.push(c / (s - 1), 0), a.push(c / (s - 1), 1)), c < s - 1 && (l = t._CopyV3(c, e), i.push(l[0], l[1], l[2]), i.push(l[0], l[1], l[2])), c > 0 && (l = t._CopyV3(c, e), r.push(l[0], l[1], l[2]), r.push(l[0], l[1], l[2]));
        return l = t._CompareV3(s - 1, 0, e) ? t._CopyV3(1, e) : t._CopyV3(s - 1, e), r.push(l[0], l[1], l[2]), r.push(l[0], l[1], l[2]), { previous: i, next: r, uvs: a, side: o };
      }, t.prototype._createVertexBuffers = function() {
        var e = n.prototype._createVertexBuffers.call(this), i = this._scene.getEngine(), r = new Yi(i, this._previousAndSide, !1, 4);
        this.setVerticesBuffer(r.createVertexBuffer("grl_previousAndSide", 0, 4));
        var o = new Yi(i, this._nextAndCounters, !1, 4);
        this.setVerticesBuffer(o.createVertexBuffer("grl_nextAndCounters", 0, 4));
        var a = new Yi(i, this._widths, this._updatable, 1);
        this.setVerticesBuffer(a.createVertexBuffer("grl_widths", 0, 1)), this._widthsBuffer = a;
        var s = new Yi(i, this._colorPointers, this._updatable, 1);
        return this.setVerticesBuffer(s.createVertexBuffer("grl_colorPointers", 0, 1)), this._colorPointersBuffer = s, e;
      }, t._V_START = new v(), t._V_END = new v(), t._V_OFFSET_START = new v(), t._V_OFFSET_END = new v(), t;
    }(j_);
    ie._GreasedLineRibbonMeshParser = function(n, t) {
      return ud.Parse(n, t);
    };
    var Vo, Sa, Q, xa, Ml, ud = function(n) {
      function t(e, i, r, o) {
        var a, s = this;
        if ((s = n.call(this, e, i, r) || this).name = e, !r.ribbonOptions)
          throw "'GreasedLineMeshOptions.ribbonOptions' is not set.";
        return s._paths = [], s._counters = [], s._slopes = [], s._widths = (a = r.widths) !== null && a !== void 0 ? a : [], s._ribbonWidths = [], s._pathsOptions = o ?? [], r.points && s.addPoints(Oi.ConvertPoints(r.points), r, !!o), s;
      }
      return D(t, n), t.prototype.addPoints = function(e, i, r) {
        if (r === void 0 && (r = !1), !i.ribbonOptions)
          throw "addPoints() on GreasedLineRibbonMesh instance requires 'GreasedLineMeshOptions.ribbonOptions'.";
        r || this._pathsOptions.push({ options: i, pathCount: e.length }), n.prototype.addPoints.call(this, e, i);
      }, t.prototype.getClassName = function() {
        return "GreasedLineRibbonMesh";
      }, Object.defineProperty(t.prototype, "isFlatLine", { get: function() {
        return this._paths.length < 3;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "slopes", { get: function() {
        return this._slopes;
      }, set: function(e) {
        this._slopes = e;
      }, enumerable: !1, configurable: !0 }), t.prototype._updateColorPointers = function() {
        var e;
        if (!this._options.colorPointers) {
          var i = 0;
          this._colorPointers = [];
          for (var r = 0; r < this._pathsOptions.length; r++) {
            var o = (e = this._pathsOptions[r]).options, a = e.pathCount, s = this._points[r];
            if (o.ribbonOptions.pointsMode === zr.POINTS_MODE_POINTS)
              for (var l = 0; l < a; l++)
                for (var c = 0; c < s.length; c += 3)
                  this._colorPointers.push(i), this._colorPointers.push(i++);
            else
              for (c = 0; c < s.length; c += 3) {
                for (l = 0; l < a; l++)
                  this._colorPointers.push(i);
                i++;
              }
          }
        }
      }, t.prototype._updateWidths = function() {
        n.prototype._updateWidthsWithValue.call(this, 1);
      }, t.prototype._setPoints = function(e, i) {
        var r, o, a = this;
        if (!this._options.ribbonOptions)
          throw "No 'GreasedLineMeshOptions.ribbonOptions' provided.";
        this._points = e, this._options.points = e, this._initGreasedLine();
        for (var s, l, c = 0, u = function(f, m) {
          var g, y = (g = h._pathsOptions[f]).options, b = g.pathCount, T = e.slice(m, m + b);
          if (m += b, ((r = y.ribbonOptions) === null || r === void 0 ? void 0 : r.pointsMode) === zr.POINTS_MODE_PATHS)
            c = h._preprocess(Oi.ToVector3Array(T), c, y);
          else {
            if (((o = y.ribbonOptions) === null || o === void 0 ? void 0 : o.directionsAutoMode) === $a.AUTO_DIRECTIONS_NONE) {
              if (!y.ribbonOptions.directions)
                throw "In GreasedLineRibbonAutoDirectionMode.AUTO_DIRECTIONS_NONE 'GreasedLineMeshOptions.ribbonOptions.directions' must be defined.";
              s = t._GetDirectionPlanesFromDirectionsOption(T.length, y.ribbonOptions.directions);
            }
            T.forEach(function(S, E) {
              var A = t._ConvertToRibbonPath(S, y.ribbonOptions, a._scene.useRightHandedSystem, s && s[E]);
              c = a._preprocess(A, c, y);
            });
          }
          l = m;
        }, h = this, d = 0, p = 0; d < this._pathsOptions.length; d++)
          u(d, p), p = l;
        this._lazy || (this._createVertexBuffers(), this.refreshBoundingInfo());
      }, t._GetDirectionPlanesFromDirectionsOption = function(e, i) {
        return Array.isArray(i) ? i : new Array(e).fill(i);
      }, t._CreateRibbonVertexData = function(e, i) {
        var r, o, a, s = e.length;
        if (s < 2)
          throw "Minimum of two paths are required to create a GreasedLineRibbonMesh.";
        for (var l = [], c = [], u = e[0], h = 0; h < u.length; h++)
          for (var d = 0; d < e.length; d++) {
            var p = e[d][h];
            l.push(p.x, p.y, p.z);
          }
        var f = [1, 0, s], m = (o = ((r = i.ribbonOptions) === null || r === void 0 ? void 0 : r.facesMode) === Il.FACES_MODE_DOUBLE_SIDED) !== null && o !== void 0 && o, g = ((a = i.ribbonOptions) === null || a === void 0 ? void 0 : a.pointsMode) === zr.POINTS_MODE_PATHS && i.ribbonOptions.closePath;
        if (s > 2)
          for (h = 0; h < u.length - 1; h++)
            for (f[0] = 1 + s * h, f[1] = s * h, f[2] = (h + 1) * s, d = 0; d < 2 * (s - 1); d++)
              d % 2 != 0 && (f[2] += 1), d % 2 == 0 && d > 0 && (f[0] += 1, f[1] += 1), c.push(f[1] + (d % 2 != 0 ? s : 0), f[0], f[2]), m && c.push(f[0], f[1] + (d % 2 != 0 ? s : 0), f[2]);
        else
          for (h = 0; h < l.length / 3 - 3; h += 2)
            c.push(h, h + 1, h + 2), c.push(h + 2, h + 1, h + 3), m && (c.push(h + 1, h, h + 2), c.push(h + 1, h + 2, h + 3));
        if (g) {
          var y = s * (u.length - 1);
          for (d = 0; d < s - 1; d++)
            c.push(y, d + 1, d), c.push(y + 1, d + 1, y), m && (c.push(d, d + 1, y), c.push(y, d + 1, y + 1)), y++;
        }
        return { positions: l, indices: c };
      }, t.prototype._preprocess = function(e, i, r) {
        var o, a, s, l;
        this._paths = e;
        var c = t._CreateRibbonVertexData(e, r), u = c.positions;
        if (!this._options.widths)
          throw "No 'GreasedLineMeshOptions.widths' table is specified.";
        for (var h = 0, d = u; h < d.length; h++) {
          var p = d[h];
          this._vertexPositions.push(p);
        }
        var f = e;
        if (((o = r.ribbonOptions) === null || o === void 0 ? void 0 : o.pointsMode) === zr.POINTS_MODE_PATHS && r.ribbonOptions.closePath) {
          f = [];
          for (var m = 0; m < e.length; m++) {
            var g = e[m].slice();
            g.push(e[m][0].clone()), f.push(g);
          }
        }
        this._calculateSegmentLengths(f);
        var y = f.length, b = new Array(y).fill(0);
        for (m = 0; m < f[0].length; m++)
          for (var T = 0, S = 0; S < y; S++) {
            var E = b[S] + this._vSegmentLengths[S][m] / this._vTotalLengths[S];
            this._counters.push(E), this._uvs.push(E, T), b[S] = E, T += this._uSegmentLengths[m][S] / this._uTotalLengths[m];
          }
        m = 0;
        for (var A = 0; m < f[0].length; m++) {
          var R = this._uSegmentLengths[m][0] / 2, C = this._uSegmentLengths[m][y - 1] / 2;
          for (this._ribbonWidths.push((((a = this._widths[A++]) !== null && a !== void 0 ? a : 1) - 1) * R), S = 0; S < y - 2; S++)
            this._ribbonWidths.push(0);
          this._ribbonWidths.push((((s = this._widths[A++]) !== null && s !== void 0 ? s : 1) - 1) * C);
        }
        for (var L = 0, I = ((l = r.ribbonOptions) === null || l === void 0 ? void 0 : l.pointsMode) === zr.POINTS_MODE_PATHS ? new Array(f[0].length * f.length * 6).fill(0) : t._CalculateSlopes(f); L < I.length; L++) {
          var O = I[L];
          this._slopes.push(O);
        }
        if (c.indices)
          for (m = 0; m < c.indices.length; m++)
            this._indices.push(c.indices[m] + i);
        return i + u.length / 3;
      }, t._ConvertToRibbonPath = function(e, i, r, o) {
        if (i.pointsMode === zr.POINTS_MODE_POINTS && !i.width)
          throw "'GreasedLineMeshOptions.ribbonOptiosn.width' must be specified in GreasedLineRibbonPointsMode.POINTS_MODE_POINTS.";
        var a = [], s = [];
        if (i.pointsMode === zr.POINTS_MODE_POINTS) {
          var l = i.width / 2, c = Oi.ToVector3Array(e), u = null, h = null;
          i.directionsAutoMode === $a.AUTO_DIRECTIONS_FROM_FIRST_SEGMENT && (o = t._GetDirectionFromPoints(c[0], c[1], null));
          for (var d = 0; d < c.length - (o ? 0 : 1); d++) {
            var p = c[d], f = c[d + 1];
            if (o)
              u = o;
            else if (i.directionsAutoMode === $a.AUTO_DIRECTIONS_FROM_ALL_SEGMENTS)
              u = t._GetDirectionFromPoints(p, f, u);
            else {
              var m = f.subtract(p);
              m.applyRotationQuaternionInPlace(m.x > m.y && m.x > m.z ? r ? t._RightHandedForwardReadOnlyQuaternion : t._LeftHandedForwardReadOnlyQuaternion : t._LeftReadOnlyQuaternion), u = m.normalize();
            }
            h = u.multiplyByFloats(l, l, l), a.push(p.add(h)), s.push(p.subtract(h));
          }
          o || (a.push(c[c.length - 1].add(h)), s.push(c[c.length - 1].subtract(h)));
        }
        return [a, s];
      }, t._GetDirectionFromPoints = function(e, i, r) {
        return e.x !== i.x || r && (r == null ? void 0 : r.x) !== 1 ? e.y === i.y ? t.DIRECTION_XZ : e.z === i.z ? t.DIRECTION_XY : t.DIRECTION_XZ : t.DIRECTION_YZ;
      }, t.prototype.clone = function(e, i) {
        e === void 0 && (e = "".concat(this.name, "-cloned"));
        var r = this._createLineOptions(), o = {}, a = [];
        Ui.DeepCopy(this._pathsOptions, a, void 0, void 0, !0), Ui.DeepCopy(r, o, ["instance"], void 0, !0);
        var s = new t(e, this._scene, o, a);
        return i && (s.parent = i), s.material = this.material, s;
      }, t.prototype.serialize = function(e) {
        n.prototype.serialize.call(this, e), e.type = this.getClassName(), e.lineOptions = this._createLineOptions(), e.pathsOptions = this._pathsOptions;
      }, t.Parse = function(e, i) {
        var r = e.lineOptions;
        return new t(e.name, i, r, e.pathOptions);
      }, t.prototype._initGreasedLine = function() {
        n.prototype._initGreasedLine.call(this), this._paths = [], this._counters = [], this._slopes = [], this._ribbonWidths = [];
      }, t.prototype._calculateSegmentLengths = function(e) {
        var i = e.length;
        this._vSegmentLengths = new Array(i), this._vTotalLengths = new Array(i);
        for (var r = 0, o = 0; o < i; o++) {
          var a = e[o];
          this._vSegmentLengths[o] = [0], r = 0;
          for (var s = 0; s < a.length - 1; s++)
            r += u = Math.abs(a[s].subtract(a[s + 1]).lengthSquared()), this._vSegmentLengths[o].push(u);
          this._vTotalLengths[o] = r;
        }
        var l = e[0].length;
        this._uSegmentLengths = new Array(l).fill([]), this._uTotalLengths = new Array(l).fill([]);
        var c = new v();
        for (s = 0; s < l; s++) {
          for (r = 0, o = 1; o < i; o++) {
            var u;
            e[o][s].subtractToRef(e[o - 1][s], c), r += u = c.length(), this._uSegmentLengths[s].push(u);
          }
          this._uTotalLengths[s] = r;
        }
      }, t._CalculateSlopes = function(e) {
        for (var i = e[0], r = e.length === 2 ? e[1] : e[e.length - 1], o = [], a = new v(), s = 0; s < i.length; s++)
          for (var l = 0; l < e.length; l++)
            l === 0 || l === e.length - 1 ? (i[s].subtract(r[s]).normalizeToRef(a), o.push(a.x, a.y, a.z), o.push(-a.x, -a.y, -a.z)) : o.push(0, 0, 0, 0, 0, 0);
        return o;
      }, t.prototype._createVertexBuffers = function() {
        var e, i;
        this._uvs = (e = this._options.uvs) !== null && e !== void 0 ? e : this._uvs;
        var r = n.prototype._createVertexBuffers.call(this, (i = this._options.ribbonOptions) === null || i === void 0 ? void 0 : i.smoothShading), o = new Yi(this._engine, this._counters, this._updatable, 1);
        this.setVerticesBuffer(o.createVertexBuffer("grl_counters", 0, 1));
        var a = new Yi(this._engine, this._colorPointers, this._updatable, 1);
        this.setVerticesBuffer(a.createVertexBuffer("grl_colorPointers", 0, 1));
        var s = new Yi(this._engine, this._slopes, this._updatable, 3);
        this.setVerticesBuffer(s.createVertexBuffer("grl_slopes", 0, 3));
        var l = new Yi(this._engine, this._ribbonWidths, this._updatable, 1);
        return this.setVerticesBuffer(l.createVertexBuffer("grl_widths", 0, 1)), this._widthsBuffer = l, r;
      }, t.DEFAULT_WIDTH = 0.1, t._RightHandedForwardReadOnlyQuaternion = oe.RotationAxis(v.RightHandedForwardReadOnly, Math.PI / 2), t._LeftHandedForwardReadOnlyQuaternion = oe.RotationAxis(v.LeftHandedForwardReadOnly, Math.PI / 2), t._LeftReadOnlyQuaternion = oe.RotationAxis(v.LeftReadOnly, Math.PI / 2), t.DIRECTION_XY = v.LeftHandedForwardReadOnly, t.DIRECTION_XZ = v.UpReadOnly, t.DIRECTION_YZ = v.LeftReadOnly, t;
    }(j_);
    function BT(n, t, e) {
      var i;
      switch (e = e ?? Me.LastCreatedScene, t.materialType) {
        case Cl.MATERIAL_TYPE_PBR:
          i = new Yh(n, e), new Pl(i, e, t);
          break;
        case Cl.MATERIAL_TYPE_SIMPLE:
          i = new z_(n, e, t);
          break;
        default:
          i = new Gt(n, e), new Pl(i, e, t);
      }
      return i;
    }
    function PP(n, t, e, i) {
      var r, o, a, s, l, c, u, h, d, p, f, m, g;
      i = i ?? Me.LastCreatedScene;
      var y = Oi.ConvertPoints(t.points);
      t.widthDistribution = (r = t.widthDistribution) !== null && r !== void 0 ? r : Sa.WIDTH_DISTRIBUTION_START, t.ribbonOptions && (t.ribbonOptions.facesMode = (o = t.ribbonOptions.facesMode) !== null && o !== void 0 ? o : Il.FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING, t.ribbonOptions.pointsMode = (a = t.ribbonOptions.pointsMode) !== null && a !== void 0 ? a : zr.POINTS_MODE_POINTS, t.ribbonOptions.directionsAutoMode = (s = t.ribbonOptions.directionsAutoMode) !== null && s !== void 0 ? s : t.ribbonOptions.directions ? $a.AUTO_DIRECTIONS_NONE : $a.AUTO_DIRECTIONS_FROM_FIRST_SEGMENT), (e = e ?? { color: Pn.DEFAULT_COLOR }).createAndAssignMaterial = (l = e.createAndAssignMaterial) === null || l === void 0 || l, e.colorDistribution = (c = e == null ? void 0 : e.colorDistribution) !== null && c !== void 0 ? c : Vo.COLOR_DISTRIBUTION_START, e.materialType = (u = e.materialType) !== null && u !== void 0 ? u : Cl.MATERIAL_TYPE_STANDARD;
      var b = 0;
      Array.isArray(y[0]) && y.forEach(function(Y) {
        b += Y.length / 3;
      });
      var T = UT(b, (h = t.widths) !== null && h !== void 0 ? h : [], t.widthDistribution), S = e != null && e.colors ? VT(b, e.colors, e.colorDistribution, (d = e.color) !== null && d !== void 0 ? d : Pn.DEFAULT_COLOR) : void 0, E = { points: y, updatable: t.updatable, widths: T, lazy: t.lazy, ribbonOptions: t.ribbonOptions, uvs: t.uvs, colorPointers: t.colorPointers };
      if (E.ribbonOptions && E.ribbonOptions.pointsMode === zr.POINTS_MODE_POINTS && (E.ribbonOptions.width = (f = (p = e.width) !== null && p !== void 0 ? p : E.ribbonOptions.width) !== null && f !== void 0 ? f : Pn.DEFAULT_WIDTH), t.instance)
        if ((g = t.instance) instanceof ud)
          g.addPoints(y, E);
        else {
          var A = g.widths;
          if (A) {
            for (var R = A.slice(), C = 0, L = T; C < L.length; C++) {
              var I = L[C];
              R.push(I);
            }
            g.widths = R;
          } else
            g.widths = T;
          g.addPoints(y);
        }
      else if (g = E.ribbonOptions ? new ud(n, i, E) : new Y_(n, i, E), e) {
        var O = { materialType: e.materialType, dashCount: e.dashCount, dashOffset: e.dashOffset, dashRatio: e.dashRatio, resolution: e.resolution, sizeAttenuation: e.sizeAttenuation, useColors: e.useColors, useDash: e.useDash, visibility: e.visibility, width: e.width, color: e.color, colorMode: e.colorMode, colorsSampling: e.colorsSampling, colorDistributionType: e.colorDistributionType, colors: S, cameraFacing: !t.ribbonOptions, colorsTexture: e.colorsTexture };
        if (e.createAndAssignMaterial) {
          var w = BT(n, O, i);
          g.material = w, ((m = t.ribbonOptions) === null || m === void 0 ? void 0 : m.facesMode) === Il.FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING && (w.backFaceCulling = !1);
        }
      }
      if (S && t.instance && t.instance.greasedLineMaterial) {
        var z = t.instance.greasedLineMaterial.colors;
        if (z) {
          var V = z.concat(S);
          t.instance.greasedLineMaterial.setColors(V, g.isLazy());
        }
      }
      return g;
    }
    function UT(n, t, e, i, r) {
      i === void 0 && (i = 1), r === void 0 && (r = 1);
      var o = n - t.length / 2, a = [];
      if (o < 0)
        return t.slice(0, 2 * n);
      if (o > 0) {
        if (t.length % 2 != 0 && t.push(i), e === Sa.WIDTH_DISTRIBUTION_START_END) {
          for (var s = Math.floor(t.length / 2), l = 0, c = 0; l < s - 1; l++)
            a.push(t[c++]), a.push(t[c++]);
          var u = t[s / 2], h = t[s / 2 + 1];
          for (l = 0; l < o; l++)
            a.push(h), a.push(u);
          for (l = s; l < t.length; l += 2)
            a.push(t[l]), a.push(t[l + 1]);
        } else if (e === Sa.WIDTH_DISTRIBUTION_START) {
          for (l = 0; l < t.length; l += 2)
            a.push(t[l]), a.push(t[l + 1]);
          for (l = 0; l < o; l++)
            a.push(i), a.push(r);
        } else if (e === Sa.WIDTH_DISTRIBUTION_END) {
          for (l = 0; l < o; l++)
            a.push(i), a.push(r);
          for (l = 0; l < t.length; l += 2)
            a.push(t[l]), a.push(t[l + 1]);
        } else if (e === Sa.WIDTH_DISTRIBUTION_REPEAT) {
          l = 0;
          for (var d = 0; d < n; d++)
            a.push(t[l++]), a.push(t[l++]), l === t.length && (l = 0);
        } else if (e === Sa.WIDTH_DISTRIBUTION_EVEN) {
          c = 0;
          var p = t.length / (2 * (n - 1));
          for (d = 0; d < n; d++)
            l = Math.floor(c), a.push(t[l]), a.push(t[l + 1]), c += p;
        }
      } else
        for (l = 0; l < t.length; l++)
          a.push(t[l]);
      return a;
    }
    function VT(n, t, e, i) {
      var r = (n = Math.max(t.length, n)) - t.length;
      if (r < 0)
        return t.slice(0, n);
      var o = [];
      if (r > 0) {
        if (e === Vo.COLOR_DISTRIBUTION_START_END) {
          for (var a = Math.floor(t.length / 2), s = 0; s < a; s++)
            o.push(t[s]);
          for (s = 0; s < r - 1; s++)
            o.push(i);
          for (s = a; s < t.length; s++)
            o.push(t[s]);
        } else if (e === Vo.COLOR_DISTRIBUTION_START) {
          for (s = 0; s < t.length; s++)
            o.push(t[s]);
          for (s = 0; s < r; s++)
            o.push(i);
        } else if (e === Vo.COLOR_DISTRIBUTION_END) {
          for (s = 0; s < r - 1; s++)
            o.push(i);
          for (s = 0; s < t.length; s++)
            o.push(t[s]);
        } else if (e === Vo.COLOR_DISTRIBUTION_REPEAT) {
          s = 0;
          for (var l = 0; l < n; l++)
            o.push(t[s]), ++s === t.length && (s = 0);
        } else if (e === Vo.COLOR_DISTRIBUTION_EVEN) {
          var c = 0, u = t.length / (n - 1);
          for (l = 0; l < n - 1; l++)
            s = Math.floor(c), o.push(t[s]), c += u;
        } else if (e === Vo.COLOR_DISTRIBUTION_NONE)
          for (s = 0; s < t.length; s++)
            o.push(t[s]);
      } else
        for (s = 0; s < n; s++)
          o.push(t[s]);
      return o;
    }
    (function(n) {
      n[n.COLOR_DISTRIBUTION_NONE = 0] = "COLOR_DISTRIBUTION_NONE", n[n.COLOR_DISTRIBUTION_REPEAT = 1] = "COLOR_DISTRIBUTION_REPEAT", n[n.COLOR_DISTRIBUTION_EVEN = 2] = "COLOR_DISTRIBUTION_EVEN", n[n.COLOR_DISTRIBUTION_START = 3] = "COLOR_DISTRIBUTION_START", n[n.COLOR_DISTRIBUTION_END = 4] = "COLOR_DISTRIBUTION_END", n[n.COLOR_DISTRIBUTION_START_END = 5] = "COLOR_DISTRIBUTION_START_END";
    })(Vo || (Vo = {})), function(n) {
      n[n.WIDTH_DISTRIBUTION_NONE = 0] = "WIDTH_DISTRIBUTION_NONE", n[n.WIDTH_DISTRIBUTION_REPEAT = 1] = "WIDTH_DISTRIBUTION_REPEAT", n[n.WIDTH_DISTRIBUTION_EVEN = 2] = "WIDTH_DISTRIBUTION_EVEN", n[n.WIDTH_DISTRIBUTION_START = 3] = "WIDTH_DISTRIBUTION_START", n[n.WIDTH_DISTRIBUTION_END = 4] = "WIDTH_DISTRIBUTION_END", n[n.WIDTH_DISTRIBUTION_START_END = 5] = "WIDTH_DISTRIBUTION_START_END";
    }(Sa || (Sa = {})), ie.prototype.thinInstanceAdd = function(n, t) {
      if (t === void 0 && (t = !0), !this.getScene().getEngine().getCaps().instancedArrays)
        return q.Error("Thin Instances are not supported on this device as Instanced Array extension not supported"), -1;
      this._thinInstanceUpdateBufferSize("matrix", Array.isArray(n) ? n.length : 1);
      var e = this._thinInstanceDataStorage.instancesCount;
      if (Array.isArray(n))
        for (var i = 0; i < n.length; ++i)
          this.thinInstanceSetMatrixAt(this._thinInstanceDataStorage.instancesCount++, n[i], i === n.length - 1 && t);
      else
        this.thinInstanceSetMatrixAt(this._thinInstanceDataStorage.instancesCount++, n, t);
      return e;
    }, ie.prototype.thinInstanceAddSelf = function(n) {
      return n === void 0 && (n = !0), this.thinInstanceAdd(B.IdentityReadOnly, n);
    }, ie.prototype.thinInstanceRegisterAttribute = function(n, t) {
      n === P.ColorKind && (n = P.ColorInstanceKind), this.removeVerticesData(n), this._thinInstanceInitializeUserStorage(), this._userThinInstanceBuffersStorage.strides[n] = t, this._userThinInstanceBuffersStorage.sizes[n] = t * Math.max(32, this._thinInstanceDataStorage.instancesCount), this._userThinInstanceBuffersStorage.data[n] = new Float32Array(this._userThinInstanceBuffersStorage.sizes[n]), this._userThinInstanceBuffersStorage.vertexBuffers[n] = new P(this.getEngine(), this._userThinInstanceBuffersStorage.data[n], n, !0, !1, t, !0), this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[n]);
    }, ie.prototype.thinInstanceSetMatrixAt = function(n, t, e) {
      if (e === void 0 && (e = !0), !this._thinInstanceDataStorage.matrixData || n >= this._thinInstanceDataStorage.instancesCount)
        return !1;
      var i = this._thinInstanceDataStorage.matrixData;
      return t.copyToArray(i, 16 * n), this._thinInstanceDataStorage.worldMatrices && (this._thinInstanceDataStorage.worldMatrices[n] = t), e && (this.thinInstanceBufferUpdated("matrix"), this.doNotSyncBoundingInfo || this.thinInstanceRefreshBoundingInfo(!1)), !0;
    }, ie.prototype.thinInstanceSetAttributeAt = function(n, t, e, i) {
      return i === void 0 && (i = !0), n === P.ColorKind && (n = P.ColorInstanceKind), !(!this._userThinInstanceBuffersStorage || !this._userThinInstanceBuffersStorage.data[n] || t >= this._thinInstanceDataStorage.instancesCount || (this._thinInstanceUpdateBufferSize(n, 0), this._userThinInstanceBuffersStorage.data[n].set(e, t * this._userThinInstanceBuffersStorage.strides[n]), i && this.thinInstanceBufferUpdated(n), 0));
    }, Object.defineProperty(ie.prototype, "thinInstanceCount", { get: function() {
      return this._thinInstanceDataStorage.instancesCount;
    }, set: function(n) {
      var t, e, i = (t = this._thinInstanceDataStorage.matrixData) !== null && t !== void 0 ? t : (e = this.source) === null || e === void 0 ? void 0 : e._thinInstanceDataStorage.matrixData;
      n <= (i ? i.length / 16 : 0) && (this._thinInstanceDataStorage.instancesCount = n);
    }, enumerable: !0, configurable: !0 }), ie.prototype._thinInstanceCreateMatrixBuffer = function(n, t, e) {
      e === void 0 && (e = !1), n === P.ColorKind && (n = P.ColorInstanceKind);
      for (var i = new Yi(this.getEngine(), t, !e, 16, !1, !0), r = 0; r < 4; r++)
        this.setVerticesBuffer(i.createVertexBuffer(n + r, 4 * r, 4));
      return i;
    }, ie.prototype.thinInstanceSetBuffer = function(n, t, e, i) {
      var r, o, a;
      e === void 0 && (e = 0), i === void 0 && (i = !1), e = e || 16, n === "matrix" ? ((r = this._thinInstanceDataStorage.matrixBuffer) === null || r === void 0 || r.dispose(), this._thinInstanceDataStorage.matrixBuffer = null, this._thinInstanceDataStorage.matrixBufferSize = t ? t.length : 32 * e, this._thinInstanceDataStorage.matrixData = t, this._thinInstanceDataStorage.worldMatrices = null, t !== null ? (this._thinInstanceDataStorage.instancesCount = t.length / e, this._thinInstanceDataStorage.matrixBuffer = this._thinInstanceCreateMatrixBuffer("world", t, i), this.doNotSyncBoundingInfo || this.thinInstanceRefreshBoundingInfo(!1)) : (this._thinInstanceDataStorage.instancesCount = 0, this.doNotSyncBoundingInfo || this.refreshBoundingInfo())) : n === "previousMatrix" ? ((o = this._thinInstanceDataStorage.previousMatrixBuffer) === null || o === void 0 || o.dispose(), this._thinInstanceDataStorage.previousMatrixBuffer = null, this._thinInstanceDataStorage.previousMatrixData = t, t !== null && (this._thinInstanceDataStorage.previousMatrixBuffer = this._thinInstanceCreateMatrixBuffer("previousWorld", t, i))) : (n === P.ColorKind && (n = P.ColorInstanceKind), t === null ? !((a = this._userThinInstanceBuffersStorage) === null || a === void 0) && a.data[n] && (this.removeVerticesData(n), delete this._userThinInstanceBuffersStorage.data[n], delete this._userThinInstanceBuffersStorage.strides[n], delete this._userThinInstanceBuffersStorage.sizes[n], delete this._userThinInstanceBuffersStorage.vertexBuffers[n]) : (this._thinInstanceInitializeUserStorage(), this._userThinInstanceBuffersStorage.data[n] = t, this._userThinInstanceBuffersStorage.strides[n] = e, this._userThinInstanceBuffersStorage.sizes[n] = t.length, this._userThinInstanceBuffersStorage.vertexBuffers[n] = new P(this.getEngine(), t, n, !i, !1, e, !0), this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[n])));
    }, ie.prototype.thinInstanceBufferUpdated = function(n) {
      var t, e, i;
      n === "matrix" ? (t = this._thinInstanceDataStorage.matrixBuffer) === null || t === void 0 || t.updateDirectly(this._thinInstanceDataStorage.matrixData, 0, this._thinInstanceDataStorage.instancesCount) : n === "previousMatrix" ? (e = this._thinInstanceDataStorage.previousMatrixBuffer) === null || e === void 0 || e.updateDirectly(this._thinInstanceDataStorage.previousMatrixData, 0, this._thinInstanceDataStorage.instancesCount) : (n === P.ColorKind && (n = P.ColorInstanceKind), !((i = this._userThinInstanceBuffersStorage) === null || i === void 0) && i.vertexBuffers[n] && this._userThinInstanceBuffersStorage.vertexBuffers[n].updateDirectly(this._userThinInstanceBuffersStorage.data[n], 0));
    }, ie.prototype.thinInstancePartialBufferUpdate = function(n, t, e) {
      var i;
      n === "matrix" ? this._thinInstanceDataStorage.matrixBuffer && this._thinInstanceDataStorage.matrixBuffer.updateDirectly(t, e) : (n === P.ColorKind && (n = P.ColorInstanceKind), !((i = this._userThinInstanceBuffersStorage) === null || i === void 0) && i.vertexBuffers[n] && this._userThinInstanceBuffersStorage.vertexBuffers[n].updateDirectly(t, e));
    }, ie.prototype.thinInstanceGetWorldMatrices = function() {
      if (!this._thinInstanceDataStorage.matrixData || !this._thinInstanceDataStorage.matrixBuffer)
        return [];
      var n = this._thinInstanceDataStorage.matrixData;
      if (!this._thinInstanceDataStorage.worldMatrices) {
        this._thinInstanceDataStorage.worldMatrices = [];
        for (var t = 0; t < this._thinInstanceDataStorage.instancesCount; ++t)
          this._thinInstanceDataStorage.worldMatrices[t] = B.FromArray(n, 16 * t);
      }
      return this._thinInstanceDataStorage.worldMatrices;
    }, ie.prototype.thinInstanceRefreshBoundingInfo = function(n, t, e) {
      if (n === void 0 && (n = !1), t === void 0 && (t = !1), e === void 0 && (e = !1), this._thinInstanceDataStorage.matrixData && this._thinInstanceDataStorage.matrixBuffer) {
        var i = this._thinInstanceDataStorage.boundingVectors;
        if (n || !this.rawBoundingInfo) {
          i.length = 0, this.refreshBoundingInfo(t, e);
          var r = this.getBoundingInfo();
          this.rawBoundingInfo = new wr(r.minimum, r.maximum);
        }
        var o = this.getBoundingInfo(), a = this._thinInstanceDataStorage.matrixData;
        if (i.length === 0)
          for (var s = 0; s < o.boundingBox.vectors.length; ++s)
            i.push(o.boundingBox.vectors[s].clone());
        F.Vector3[0].setAll(Number.POSITIVE_INFINITY), F.Vector3[1].setAll(Number.NEGATIVE_INFINITY);
        for (var l = 0; l < this._thinInstanceDataStorage.instancesCount; ++l)
          for (B.FromArrayToRef(a, 16 * l, F.Matrix[0]), s = 0; s < i.length; ++s)
            v.TransformCoordinatesToRef(i[s], F.Matrix[0], F.Vector3[2]), F.Vector3[0].minimizeInPlace(F.Vector3[2]), F.Vector3[1].maximizeInPlace(F.Vector3[2]);
        o.reConstruct(F.Vector3[0], F.Vector3[1]), this._updateBoundingInfo();
      }
    }, ie.prototype._thinInstanceUpdateBufferSize = function(n, t) {
      var e, i, r;
      t === void 0 && (t = 1), n === P.ColorKind && (n = P.ColorInstanceKind);
      var o = n === "matrix";
      if (o || this._userThinInstanceBuffersStorage && this._userThinInstanceBuffersStorage.strides[n]) {
        for (var a = o ? 16 : this._userThinInstanceBuffersStorage.strides[n], s = o ? this._thinInstanceDataStorage.matrixBufferSize : this._userThinInstanceBuffersStorage.sizes[n], l = o ? this._thinInstanceDataStorage.matrixData : this._userThinInstanceBuffersStorage.data[n], c = (this._thinInstanceDataStorage.instancesCount + t) * a, u = s; u < c; )
          u *= 2;
        if (!l || s != u) {
          if (l) {
            var h = new Float32Array(u);
            h.set(l, 0), l = h;
          } else
            l = new Float32Array(u);
          o ? ((e = this._thinInstanceDataStorage.matrixBuffer) === null || e === void 0 || e.dispose(), this._thinInstanceDataStorage.matrixBuffer = this._thinInstanceCreateMatrixBuffer("world", l, !1), this._thinInstanceDataStorage.matrixData = l, this._thinInstanceDataStorage.matrixBufferSize = u, this._scene.needsPreviousWorldMatrices && !this._thinInstanceDataStorage.previousMatrixData && ((i = this._thinInstanceDataStorage.previousMatrixBuffer) === null || i === void 0 || i.dispose(), this._thinInstanceDataStorage.previousMatrixBuffer = this._thinInstanceCreateMatrixBuffer("previousWorld", l, !1))) : ((r = this._userThinInstanceBuffersStorage.vertexBuffers[n]) === null || r === void 0 || r.dispose(), this._userThinInstanceBuffersStorage.data[n] = l, this._userThinInstanceBuffersStorage.sizes[n] = u, this._userThinInstanceBuffersStorage.vertexBuffers[n] = new P(this.getEngine(), l, n, !0, !1, a, !0), this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[n]));
        }
      }
    }, ie.prototype._thinInstanceInitializeUserStorage = function() {
      this._userThinInstanceBuffersStorage || (this._userThinInstanceBuffersStorage = { data: {}, sizes: {}, vertexBuffers: {}, strides: {} });
    }, ie.prototype._disposeThinInstanceSpecificData = function() {
      var n;
      !((n = this._thinInstanceDataStorage) === null || n === void 0) && n.matrixBuffer && (this._thinInstanceDataStorage.matrixBuffer.dispose(), this._thinInstanceDataStorage.matrixBuffer = null);
    }, function(n) {
      n[n.Int = 1] = "Int", n[n.Float = 2] = "Float", n[n.Vector2 = 4] = "Vector2", n[n.Vector3 = 8] = "Vector3", n[n.Vector4 = 16] = "Vector4", n[n.Matrix = 32] = "Matrix", n[n.Geometry = 64] = "Geometry", n[n.Texture = 128] = "Texture", n[n.AutoDetect = 1024] = "AutoDetect", n[n.BasedOnInput = 2048] = "BasedOnInput", n[n.Undefined = 4096] = "Undefined", n[n.All = 4095] = "All";
    }(Q || (Q = {})), function(n) {
      n[n.Compatible = 0] = "Compatible", n[n.TypeIncompatible = 1] = "TypeIncompatible", n[n.HierarchyIssue = 2] = "HierarchyIssue";
    }(xa || (xa = {})), function(n) {
      n[n.Input = 0] = "Input", n[n.Output = 1] = "Output";
    }(Ml || (Ml = {}));
    var zt, K_ = function() {
      function n(t, e, i) {
        this._connectedPoint = null, this._storedValue = null, this._storedFunction = null, this._acceptedConnectionPointType = null, this._endpoints = new Array(), this._type = Q.Geometry, this._linkedConnectionSource = null, this._typeConnectionSource = null, this._defaultConnectionPointType = null, this.acceptedConnectionPointTypes = [], this.excludedConnectionPointTypes = [], this.onConnectionObservable = new H(), this.isExposedOnFrame = !1, this.exposedPortPosition = -1, this.defaultValue = null, this.value = null, this.valueMin = null, this.valueMax = null, this._callCount = 0, this._executionCount = 0, this._ownerBlock = e, this.name = t, this._direction = i;
      }
      return Object.defineProperty(n.prototype, "direction", { get: function() {
        return this._direction;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "type", { get: function() {
        if (this._type === Q.AutoDetect) {
          if (this._ownerBlock.isInput)
            return this._ownerBlock.type;
          if (this._connectedPoint)
            return this._connectedPoint.type;
          if (this._linkedConnectionSource && this._linkedConnectionSource.isConnected)
            return this._linkedConnectionSource.type;
        }
        if (this._type === Q.BasedOnInput) {
          if (this._typeConnectionSource)
            return !this._typeConnectionSource.isConnected && this._defaultConnectionPointType ? this._defaultConnectionPointType : this._typeConnectionSource.type;
          if (this._defaultConnectionPointType)
            return this._defaultConnectionPointType;
        }
        return this._type;
      }, set: function(t) {
        this._type = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isConnected", { get: function() {
        return this.connectedPoint !== null || this.hasEndpoints;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "connectedPoint", { get: function() {
        return this._connectedPoint;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "ownerBlock", { get: function() {
        return this._ownerBlock;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "sourceBlock", { get: function() {
        return this._connectedPoint ? this._connectedPoint.ownerBlock : null;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "connectedBlocks", { get: function() {
        return this._endpoints.length === 0 ? [] : this._endpoints.map(function(t) {
          return t.ownerBlock;
        });
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "endpoints", { get: function() {
        return this._endpoints;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "hasEndpoints", { get: function() {
        return this._endpoints && this._endpoints.length > 0;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "innerType", { get: function() {
        return this._linkedConnectionSource && this._linkedConnectionSource.isConnected ? this.type : this._type;
      }, enumerable: !1, configurable: !0 }), n.prototype._resetCounters = function() {
        this._callCount = 0, this._executionCount = 0;
      }, Object.defineProperty(n.prototype, "callCount", { get: function() {
        return this._callCount;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "executionCount", { get: function() {
        return this._executionCount;
      }, enumerable: !1, configurable: !0 }), n.prototype.getConnectedValue = function(t) {
        var e;
        return this.isConnected ? !((e = this._connectedPoint) === null || e === void 0) && e._storedFunction ? (this._connectedPoint._callCount++, this._connectedPoint._executionCount++, this._connectedPoint._storedFunction(t)) : (this._connectedPoint._callCount++, this._connectedPoint._executionCount = 1, this._connectedPoint._storedValue) : (this._callCount++, this._executionCount = 1, this.value);
      }, n.prototype.getClassName = function() {
        return "NodeGeometryConnectionPoint";
      }, n.prototype.canConnectTo = function(t) {
        return this.checkCompatibilityState(t) === xa.Compatible;
      }, n.prototype.checkCompatibilityState = function(t) {
        var e = this._ownerBlock, i = t.ownerBlock;
        if (this.type !== t.type && t.innerType !== Q.AutoDetect)
          return t.acceptedConnectionPointTypes && t.acceptedConnectionPointTypes.indexOf(this.type) !== -1 ? xa.Compatible : xa.TypeIncompatible;
        if (t.excludedConnectionPointTypes && t.excludedConnectionPointTypes.indexOf(this.type) !== -1)
          return xa.TypeIncompatible;
        var r = i, o = e;
        return this.direction === Ml.Input && (r = e, o = i), r.isAnAncestorOf(o) ? xa.HierarchyIssue : xa.Compatible;
      }, n.prototype.connectTo = function(t, e) {
        if (e === void 0 && (e = !1), !e && !this.canConnectTo(t))
          throw "Cannot connect these two connectors.";
        return this._endpoints.push(t), t._connectedPoint = this, this.onConnectionObservable.notifyObservers(t), t.onConnectionObservable.notifyObservers(this), this;
      }, n.prototype.disconnectFrom = function(t) {
        var e = this._endpoints.indexOf(t);
        return e === -1 || (this._endpoints.splice(e, 1), t._connectedPoint = null), this;
      }, n.prototype.addExcludedConnectionPointFromAllowedTypes = function(t) {
        for (var e = 1; e < Q.All; )
          t & e || this.excludedConnectionPointTypes.push(e), e <<= 1;
      }, n.prototype.serialize = function(t) {
        t === void 0 && (t = !0);
        var e = {};
        return e.name = this.name, e.displayName = this.displayName, this.value !== void 0 && this.value !== null && (this.value.asArray ? (e.valueType = "BABYLON." + this.value.getClassName(), e.value = this.value.asArray()) : (e.valueType = "number", e.value = this.value)), t && this.connectedPoint && (e.inputName = this.name, e.targetBlockId = this.connectedPoint.ownerBlock.uniqueId, e.targetConnectionName = this.connectedPoint.name), e;
      }, n.prototype.dispose = function() {
        this.onConnectionObservable.clear();
      }, n;
    }(), At = function() {
      function n(t) {
        this._name = "", this._isInput = !1, this._isTeleportOut = !1, this._isTeleportIn = !1, this._isDebug = !1, this._isUnique = !1, this._buildExecutionTime = 0, this.onBuildObservable = new H(), this._inputs = new Array(), this._outputs = new Array(), this._codeVariableName = "", this.visibleOnFrame = !1, this._name = t, this.uniqueId = bp.UniqueId;
      }
      return Object.defineProperty(n.prototype, "buildExecutionTime", { get: function() {
        return this._buildExecutionTime;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "inputs", { get: function() {
        return this._inputs;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "outputs", { get: function() {
        return this._outputs;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "name", { get: function() {
        return this._name;
      }, set: function(t) {
        this._name = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isInput", { get: function() {
        return this._isInput;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isTeleportOut", { get: function() {
        return this._isTeleportOut;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isTeleportIn", { get: function() {
        return this._isTeleportIn;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isDebug", { get: function() {
        return this._isDebug;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isUnique", { get: function() {
        return this._isUnique;
      }, enumerable: !1, configurable: !0 }), n.prototype.getClassName = function() {
        return "NodeGeometryBlock";
      }, n.prototype._inputRename = function(t) {
        return t;
      }, n.prototype._outputRename = function(t) {
        return t;
      }, n.prototype.isAnAncestorOf = function(t) {
        for (var e = 0, i = this._outputs; e < i.length; e++) {
          var r = i[e];
          if (r.hasEndpoints)
            for (var o = 0, a = r.endpoints; o < a.length; o++) {
              var s = a[o];
              if (s.ownerBlock === t || s.ownerBlock.isAnAncestorOf(t))
                return !0;
            }
        }
        return !1;
      }, n.prototype.isAnAncestorOfType = function(t) {
        if (this.getClassName() === t)
          return !0;
        for (var e = 0, i = this._outputs; e < i.length; e++) {
          var r = i[e];
          if (r.hasEndpoints) {
            for (var o = 0, a = r.endpoints; o < a.length; o++)
              if (a[o].ownerBlock.isAnAncestorOfType(t))
                return !0;
          }
        }
        return !1;
      }, n.prototype.getDescendantOfPredicate = function(t) {
        if (t(this))
          return this;
        for (var e = 0, i = this._outputs; e < i.length; e++) {
          var r = i[e];
          if (r.hasEndpoints)
            for (var o = 0, a = r.endpoints; o < a.length; o++) {
              var s = a[o].ownerBlock.getDescendantOfPredicate(t);
              if (s)
                return s;
            }
        }
        return null;
      }, n.prototype.registerInput = function(t, e, i, r, o, a) {
        i === void 0 && (i = !1);
        var s = new K_(t, this, Ml.Input);
        return s.type = e, s.isOptional = i, s.defaultValue = r, s.value = r, s.valueMin = o, s.valueMax = a, this._inputs.push(s), this;
      }, n.prototype.registerOutput = function(t, e, i) {
        return (i = i ?? new K_(t, this, Ml.Output)).type = e, this._outputs.push(i), this;
      }, n.prototype._buildBlock = function(t) {
      }, n.prototype._customBuildStep = function(t) {
      }, n.prototype.build = function(t) {
        if (this._buildId === t.buildId)
          return !0;
        if (this._outputs.length > 0) {
          if (!this._outputs.some(function(h) {
            return h.hasEndpoints;
          }) && !this.isDebug)
            return !1;
          this.outputs.forEach(function(h) {
            return h._resetCounters();
          });
        }
        this._buildId = t.buildId;
        for (var e = 0, i = this._inputs; e < i.length; e++) {
          var r = i[e];
          r.connectedPoint ? (u = r.connectedPoint.ownerBlock) && u !== this && u.build(t) : r.isOptional || t.notConnectedNonOptionalInputs.push(r);
        }
        this._customBuildStep(t), t.verbose && console.log("Building ".concat(this.name, " [").concat(this.getClassName(), "]"));
        var o = It.Now;
        this._buildBlock(t), this._buildExecutionTime = It.Now - o;
        for (var a = 0, s = this._outputs; a < s.length; a++)
          for (var l = 0, c = s[a].endpoints; l < c.length; l++) {
            var u;
            (u = c[l].ownerBlock) && u.build(t);
          }
        return this.onBuildObservable.notifyObservers(this), !1;
      }, n.prototype._linkConnectionTypes = function(t, e, i) {
        i === void 0 && (i = !1), i ? this._inputs[e]._acceptedConnectionPointType = this._inputs[t] : this._inputs[t]._linkedConnectionSource = this._inputs[e], this._inputs[e]._linkedConnectionSource = this._inputs[t];
      }, n.prototype.initialize = function() {
      }, n.prototype.autoConfigure = function() {
      }, n.prototype.getInputByName = function(t) {
        var e = this._inputs.filter(function(i) {
          return i.name === t;
        });
        return e.length ? e[0] : null;
      }, n.prototype.getOutputByName = function(t) {
        var e = this._outputs.filter(function(i) {
          return i.name === t;
        });
        return e.length ? e[0] : null;
      }, n.prototype.serialize = function() {
        var t = {};
        t.customType = "BABYLON." + this.getClassName(), t.id = this.uniqueId, t.name = this.name, t.inputs = [], t.outputs = [];
        for (var e = 0, i = this.inputs; e < i.length; e++) {
          var r = i[e];
          t.inputs.push(r.serialize());
        }
        for (var o = 0, a = this.outputs; o < a.length; o++) {
          var s = a[o];
          t.outputs.push(s.serialize(!1));
        }
        return t;
      }, n.prototype._deserialize = function(t) {
        this._name = t.name, this.comments = t.comments, this.visibleOnFrame = !!t.visibleOnFrame, this._deserializePortDisplayNamesAndExposedOnFrame(t);
      }, n.prototype._deserializePortDisplayNamesAndExposedOnFrame = function(t) {
        var e = this, i = t.inputs, r = t.outputs;
        i && i.forEach(function(o) {
          var a = e.inputs.find(function(l) {
            return l.name === o.name;
          });
          if (a && (o.displayName && (a.displayName = o.displayName), o.isExposedOnFrame && (a.isExposedOnFrame = o.isExposedOnFrame, a.exposedPortPosition = o.exposedPortPosition), o.value !== void 0 && o.value !== null))
            if (o.valueType === "number")
              a.value = o.value;
            else {
              var s = Kt(o.valueType);
              s && (a.value = s.FromArray(o.value));
            }
        }), r && r.forEach(function(o, a) {
          o.displayName && (e.outputs[a].displayName = o.displayName), o.isExposedOnFrame && (e.outputs[a].isExposedOnFrame = o.isExposedOnFrame, e.outputs[a].exposedPortPosition = o.exposedPortPosition);
        });
      }, n.prototype._dumpPropertiesCode = function() {
        var t = this._codeVariableName;
        return "".concat(t, ".visibleOnFrame = ").concat(this.visibleOnFrame, `;
`);
      }, n.prototype._dumpCodeForOutputConnections = function(t) {
        var e = "";
        if (t.indexOf(this) !== -1)
          return e;
        t.push(this);
        for (var i = 0, r = this.inputs; i < r.length; i++) {
          var o = r[i];
          if (o.isConnected) {
            var a = o.connectedPoint, s = a.ownerBlock;
            e += s._dumpCodeForOutputConnections(t), e += "".concat(s._codeVariableName, ".").concat(s._outputRename(a.name), ".connectTo(").concat(this._codeVariableName, ".").concat(this._inputRename(o.name), `);
`);
          }
        }
        return e;
      }, n.prototype._dumpCode = function(t, e) {
        e.push(this);
        var i = this.name.replace(/[^A-Za-z_]+/g, "");
        if (this._codeVariableName = i || "".concat(this.getClassName(), "_").concat(this.uniqueId), t.indexOf(this._codeVariableName) !== -1) {
          var r = 0;
          do
            r++, this._codeVariableName = i + r;
          while (t.indexOf(this._codeVariableName) !== -1);
        }
        t.push(this._codeVariableName);
        var o = `
// `.concat(this.getClassName(), `
`);
        this.comments && (o += "// ".concat(this.comments, `
`)), o += "var ".concat(this._codeVariableName, " = new BABYLON.").concat(this.getClassName(), '("').concat(this.name, `");
`), o += this._dumpPropertiesCode();
        for (var a = 0, s = this.inputs; a < s.length; a++) {
          var l = s[a];
          if (l.isConnected) {
            var c = l.connectedPoint.ownerBlock;
            e.indexOf(c) === -1 && (o += c._dumpCode(t, e));
          }
        }
        for (var u = 0, h = this.outputs; u < h.length; u++) {
          var d = h[u];
          if (d.hasEndpoints)
            for (var p = 0, f = d.endpoints; p < f.length; p++)
              (c = f[p].ownerBlock) && e.indexOf(c) === -1 && (o += c._dumpCode(t, e));
        }
        return o;
      }, n.prototype.clone = function() {
        var t = this.serialize(), e = Kt(t.customType);
        if (e) {
          var i = new e();
          return i._deserialize(t), i;
        }
        return null;
      }, n.prototype.dispose = function() {
        for (var t = 0, e = this.inputs; t < e.length; t++)
          e[t].dispose();
        for (var i = 0, r = this.outputs; i < r.length; i++)
          r[i].dispose();
        this.onBuildObservable.clear();
      }, x([N("comment")], n.prototype, "comments", void 0), n;
    }(), q_ = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i._vertexData = null, i._isUnique = !0, i.registerInput("geometry", Q.Geometry), i;
      }
      return D(t, n), Object.defineProperty(t.prototype, "currentVertexData", { get: function() {
        return this._vertexData;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "GeometryOutputBlock";
      }, Object.defineProperty(t.prototype, "geometry", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        e.vertexData = this.geometry.getConnectedValue(e), this._vertexData = e.vertexData;
      }, t;
    }(At);
    j("BABYLON.GeometryOutputBlock", q_), function(n) {
      n[n.None = 0] = "None", n[n.Positions = 1] = "Positions", n[n.Normals = 2] = "Normals", n[n.Tangents = 3] = "Tangents", n[n.UV = 4] = "UV", n[n.UV2 = 5] = "UV2", n[n.UV3 = 6] = "UV3", n[n.UV4 = 7] = "UV4", n[n.UV5 = 8] = "UV5", n[n.UV6 = 9] = "UV6", n[n.Colors = 10] = "Colors", n[n.VertexID = 11] = "VertexID", n[n.FaceID = 12] = "FaceID", n[n.GeometryID = 13] = "GeometryID", n[n.CollectionID = 14] = "CollectionID", n[n.LoopID = 15] = "LoopID", n[n.InstanceID = 16] = "InstanceID";
    }(zt || (zt = {}));
    var kT = function() {
      function n() {
        this._rotationMatrix = new B(), this._scalingMatrix = new B(), this._positionMatrix = new B(), this._scalingRotationMatrix = new B(), this._transformMatrix = new B(), this._tempVector3 = new v(), this.notConnectedNonOptionalInputs = [], this.noContextualData = [], this.vertexData = null, this._geometryContext = null, this._executionContext = null, this._instancingContext = null, this._geometryContextStack = [], this._executionContextStack = [], this._instancingContextStack = [];
      }
      return Object.defineProperty(n.prototype, "geometryContext", { get: function() {
        return this._geometryContext;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "executionContext", { get: function() {
        return this._executionContext;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "instancingContext", { get: function() {
        return this._instancingContext;
      }, enumerable: !1, configurable: !0 }), n.prototype.pushGeometryContext = function(t) {
        this._geometryContext = t, this._geometryContextStack.push(this._geometryContext);
      }, n.prototype.pushExecutionContext = function(t) {
        this._executionContext = t, this._executionContextStack.push(this._executionContext);
      }, n.prototype.pushInstancingContext = function(t) {
        this._instancingContext = t, this._instancingContextStack.push(this._instancingContext);
      }, n.prototype.restoreGeometryContext = function() {
        this._geometryContextStack.pop(), this._geometryContext = this._geometryContextStack.length > 0 ? this._geometryContextStack[this._geometryContextStack.length - 1] : null;
      }, n.prototype.restoreExecutionContext = function() {
        this._executionContextStack.pop(), this._executionContext = this._executionContextStack.length > 0 ? this._executionContextStack[this._executionContextStack.length - 1] : null;
      }, n.prototype.restoreInstancingContext = function() {
        this._instancingContextStack.pop(), this._instancingContext = this._instancingContextStack.length > 0 ? this._instancingContextStack[this._instancingContextStack.length - 1] : null;
      }, n.prototype.getContextualValue = function(t, e) {
        if (e === void 0 && (e = !1), !this.executionContext)
          return e || this.noContextualData.push(t), null;
        var i = this.executionContext.getExecutionIndex();
        switch (t) {
          case zt.Positions:
            return this.executionContext.getOverridePositionsContextualValue ? this.executionContext.getOverridePositionsContextualValue() : this.geometryContext && this.geometryContext.positions ? v.FromArray(this.geometryContext.positions, 3 * i) : v.Zero();
          case zt.Normals:
            return this.executionContext.getOverrideNormalsContextualValue ? this.executionContext.getOverrideNormalsContextualValue() : this.geometryContext && this.geometryContext.normals ? v.FromArray(this.geometryContext.normals, 3 * i) : v.Zero();
          case zt.Colors:
            return this.geometryContext && this.geometryContext.colors ? lt.FromArray(this.geometryContext.colors, 4 * i) : lt.Zero();
          case zt.Tangents:
            return this.geometryContext && this.geometryContext.tangents ? lt.FromArray(this.geometryContext.tangents, 4 * i) : lt.Zero();
          case zt.UV:
            return this.executionContext.getOverrideUVs1ContextualValue ? this.executionContext.getOverrideUVs1ContextualValue() : this.geometryContext && this.geometryContext.uvs ? fe.FromArray(this.geometryContext.uvs, 2 * i) : fe.Zero();
          case zt.UV2:
            return this.geometryContext && this.geometryContext.uvs2 ? fe.FromArray(this.geometryContext.uvs2, 2 * i) : fe.Zero();
          case zt.UV3:
            return this.geometryContext && this.geometryContext.uvs3 ? fe.FromArray(this.geometryContext.uvs3, 2 * i) : fe.Zero();
          case zt.UV4:
            return this.geometryContext && this.geometryContext.uvs4 ? fe.FromArray(this.geometryContext.uvs4, 2 * i) : fe.Zero();
          case zt.UV5:
            return this.geometryContext && this.geometryContext.uvs5 ? fe.FromArray(this.geometryContext.uvs5, 2 * i) : fe.Zero();
          case zt.UV6:
            return this.geometryContext && this.geometryContext.uvs6 ? fe.FromArray(this.geometryContext.uvs6, 2 * i) : fe.Zero();
          case zt.VertexID:
            return i;
          case zt.FaceID:
            return this.executionContext.getExecutionFaceIndex();
          case zt.LoopID:
            return this.executionContext.getExecutionLoopIndex();
          case zt.InstanceID:
            return this.instancingContext ? this.instancingContext.getInstanceIndex() : 0;
          case zt.GeometryID:
            return this.geometryContext ? this.geometryContext.uniqueId : 0;
          case zt.CollectionID:
            return this.geometryContext && this.geometryContext.metadata && this.geometryContext.metadata.collectionId || 0;
        }
        return null;
      }, n.prototype.adapt = function(t, e) {
        var i = t.getConnectedValue(this) || 0;
        if (t.type === e)
          return i;
        switch (e) {
          case Q.Vector2:
            return new fe(i, i);
          case Q.Vector3:
            return new v(i, i, i);
          case Q.Vector4:
            return new lt(i, i, i, i);
        }
        return null;
      }, n.prototype.adaptInput = function(t, e, i) {
        var r;
        if (!t.isConnected)
          return t.value || i;
        var o = t.getConnectedValue(this);
        if (((r = t._connectedPoint) === null || r === void 0 ? void 0 : r.type) === e)
          return o;
        switch (e) {
          case Q.Vector2:
            return new fe(o, o);
          case Q.Vector3:
            return new v(o, o, o);
          case Q.Vector4:
            return new lt(o, o, o, o);
        }
        return null;
      }, n.prototype.emitErrors = function() {
        for (var t = "", e = 0, i = this.notConnectedNonOptionalInputs; e < i.length; e++) {
          var r = i[e];
          t += "input ".concat(r.name, " from block ").concat(r.ownerBlock.name, "[").concat(r.ownerBlock.getClassName(), `] is not connected and is not optional.
`);
        }
        for (var o = 0, a = this.noContextualData; o < a.length; o++) {
          var s = a[o];
          t += "Contextual input ".concat(zt[s], ` has no context to pull data from (must be connected to a setXXX block or a instantiateXXX block).
`);
        }
        if (t)
          throw `Build of NodeGeometry failed:
` + t;
      }, n.prototype._instantiate = function(t, e, i, r, o) {
        B.ScalingToRef(r.x, r.y, r.z, this._scalingMatrix), B.RotationYawPitchRollToRef(i.y, i.x, i.z, this._rotationMatrix), B.TranslationToRef(e.x, e.y, e.z, this._positionMatrix), this._scalingMatrix.multiplyToRef(this._rotationMatrix, this._scalingRotationMatrix), this._scalingRotationMatrix.multiplyToRef(this._positionMatrix, this._transformMatrix);
        for (var a = 0; a < t.positions.length; a += 3)
          this._tempVector3.fromArray(t.positions, a), v.TransformCoordinatesToRef(this._tempVector3, this._transformMatrix, this._tempVector3), this._tempVector3.toArray(t.positions, a), t.normals && (this._tempVector3.fromArray(t.normals, a), v.TransformNormalToRef(this._tempVector3, this._scalingRotationMatrix, this._tempVector3), this._tempVector3.toArray(t.normals, a));
        o.push(t);
      }, n.prototype._instantiateWithMatrix = function(t, e, i) {
        for (var r = 0; r < t.positions.length; r += 3)
          this._tempVector3.fromArray(t.positions, r), v.TransformCoordinatesToRef(this._tempVector3, e, this._tempVector3), this._tempVector3.toArray(t.positions, r), t.normals && (this._tempVector3.fromArray(t.normals, r), v.TransformNormalToRef(this._tempVector3, e, this._tempVector3), this._tempVector3.toArray(t.normals, r));
        i.push(t);
      }, n.prototype._instantiateWithPositionAndMatrix = function(t, e, i, r) {
        B.TranslationToRef(e.x, e.y, e.z, this._positionMatrix), i.multiplyToRef(this._positionMatrix, this._transformMatrix);
        for (var o = 0; o < t.positions.length; o += 3)
          this._tempVector3.fromArray(t.positions, o), v.TransformCoordinatesToRef(this._tempVector3, this._transformMatrix, this._tempVector3), this._tempVector3.toArray(t.positions, o), t.normals && (this._tempVector3.fromArray(t.normals, o), v.TransformNormalToRef(this._tempVector3, this._transformMatrix, this._tempVector3), this._tempVector3.toArray(t.normals, o));
        r.push(t);
      }, n;
    }(), Di = function(n) {
      function t(e, i) {
        i === void 0 && (i = Q.AutoDetect);
        var r = n.call(this, e) || this;
        return r._type = Q.Undefined, r._contextualSource = zt.None, r.min = 0, r.max = 0, r.groupInInspector = "", r.onValueChangedObservable = new H(), r._type = i, r._isInput = !0, r.setDefaultValue(), r.registerOutput("output", i), r;
      }
      return D(t, n), Object.defineProperty(t.prototype, "type", { get: function() {
        if (this._type === Q.AutoDetect && this.value != null) {
          if (!isNaN(this.value))
            return this._type = Q.Float, this._type;
          switch (this.value.getClassName()) {
            case "Vector2":
              return this._type = Q.Vector2, this._type;
            case "Vector3":
              return this._type = Q.Vector3, this._type;
            case "Vector4":
              return this._type = Q.Vector4, this._type;
            case "Matrix":
              return this._type = Q.Matrix, this._type;
          }
        }
        return this._type;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isContextual", { get: function() {
        return this._contextualSource !== zt.None;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "contextualValue", { get: function() {
        return this._contextualSource;
      }, set: function(e) {
        switch (this._contextualSource = e, e) {
          case zt.Positions:
          case zt.Normals:
            this._type = Q.Vector3;
            break;
          case zt.Colors:
          case zt.Tangents:
            this._type = Q.Vector4;
            break;
          case zt.UV:
          case zt.UV2:
          case zt.UV3:
          case zt.UV4:
          case zt.UV5:
          case zt.UV6:
            this._type = Q.Vector2;
            break;
          case zt.VertexID:
          case zt.GeometryID:
          case zt.CollectionID:
          case zt.FaceID:
          case zt.LoopID:
          case zt.InstanceID:
            this._type = Q.Int;
        }
        this.output && (this.output.type = this._type);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "value", { get: function() {
        return this._storedValue;
      }, set: function(e) {
        this.type === Q.Float && this.min !== this.max && (e = Math.max(this.min, e), e = Math.min(this.max, e)), this._storedValue = e, this.onValueChangedObservable.notifyObservers(this);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "valueCallback", { get: function() {
        return this._valueCallback;
      }, set: function(e) {
        this._valueCallback = e;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "GeometryInputBlock";
      }, Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.setDefaultValue = function() {
        switch (this.contextualValue = zt.None, this.type) {
          case Q.Int:
          case Q.Float:
            this.value = 0;
            break;
          case Q.Vector2:
            this.value = fe.Zero();
            break;
          case Q.Vector3:
            this.value = v.Zero();
            break;
          case Q.Vector4:
            this.value = lt.Zero();
            break;
          case Q.Matrix:
            this.value = B.Identity();
        }
      }, t.prototype._buildBlock = function(e) {
        var i = this;
        n.prototype._buildBlock.call(this, e), this.isContextual ? (this.output._storedValue = null, this.output._storedFunction = function(r) {
          return r.getContextualValue(i._contextualSource);
        }) : (this.output._storedFunction = null, this.output._storedValue = this.value);
      }, t.prototype.dispose = function() {
        this.onValueChangedObservable.clear(), n.prototype.dispose.call(this);
      }, t.prototype._dumpPropertiesCode = function() {
        var e = this._codeVariableName;
        if (this.isContextual)
          return n.prototype._dumpPropertiesCode.call(this) + "".concat(e, ".contextualValue = BABYLON.NodeGeometryContextualSources.").concat(zt[this._contextualSource], `;
`);
        var i = [], r = "";
        switch (this.type) {
          case Q.Float:
          case Q.Int:
            r = "".concat(this.value);
            break;
          case Q.Vector2:
            r = "new BABYLON.Vector2(".concat(this.value.x, ", ").concat(this.value.y, ")");
            break;
          case Q.Vector3:
            r = "new BABYLON.Vector3(".concat(this.value.x, ", ").concat(this.value.y, ", ").concat(this.value.z, ")");
            break;
          case Q.Vector4:
            r = "new BABYLON.Vector4(".concat(this.value.x, ", ").concat(this.value.y, ", ").concat(this.value.z, ", ").concat(this.value.w, ")");
        }
        return i.push("".concat(e, ".value = ").concat(r)), this.type !== Q.Float && this.type !== Q.Int || i.push("".concat(e, ".min = ").concat(this.min), "".concat(e, ".max = ").concat(this.max)), i.push(""), n.prototype._dumpPropertiesCode.call(this) + i.join(`;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.type = this.type, e.contextualValue = this.contextualValue, e.min = this.min, e.max = this.max, e.groupInInspector = this.groupInInspector, this._storedValue === null || this.isContextual || (this._storedValue.asArray ? (e.valueType = "BABYLON." + this._storedValue.getClassName(), e.value = this._storedValue.asArray()) : (e.valueType = "number", e.value = this._storedValue)), e;
      }, t.prototype._deserialize = function(e) {
        if (n.prototype._deserialize.call(this, e), this._type = e.type, this.contextualValue = e.contextualValue, this.min = e.min || 0, this.max = e.max || 0, this.groupInInspector = e.groupInInspector || "", e.valueType)
          if (e.valueType === "number")
            this._storedValue = e.value;
          else {
            var i = Kt(e.valueType);
            i && (this._storedValue = i.FromArray(e.value));
          }
      }, t;
    }(At);
    j("BABYLON.GeometryInputBlock", Di);
    var Q_ = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.evaluateContext = !1, i.registerInput("size", Q.Float, !0, 1), i.registerInput("width", Q.Float, !0, 0), i.registerInput("height", Q.Float, !0, 0), i.registerInput("depth", Q.Float, !0, 0), i.registerInput("subdivisions", Q.Int, !0, 1), i.registerInput("subdivisionsX", Q.Int, !0, 0), i.registerInput("subdivisionsY", Q.Int, !0, 0), i.registerInput("subdivisionsZ", Q.Int, !0, 0), i.registerOutput("geometry", Q.Geometry), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "BoxBlock";
      }, Object.defineProperty(t.prototype, "size", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "width", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "height", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "depth", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subdivisions", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subdivisionsX", { get: function() {
        return this._inputs[5];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subdivisionsY", { get: function() {
        return this._inputs[6];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subdivisionsZ", { get: function() {
        return this._inputs[7];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function() {
        if (!this.size.isConnected) {
          if (!this.width.isConnected && !this.height.isConnected && !this.depth.isConnected) {
            var e = new Di("Size");
            return e.value = 1, void e.output.connectTo(this.size);
          }
          if (!this.width.isConnected) {
            var i = new Di("Width");
            i.value = 1, i.output.connectTo(this.width);
          }
          if (!this.height.isConnected) {
            var r = new Di("Height");
            r.value = 1, r.output.connectTo(this.height);
          }
          if (!this.depth.isConnected) {
            var o = new Di("Depth");
            o.value = 1, o.output.connectTo(this.depth);
          }
        }
      }, t.prototype._buildBlock = function(e) {
        var i = this, r = {}, o = function(s) {
          r.size = i.size.getConnectedValue(s), r.width = i.width.getConnectedValue(s), r.height = i.height.getConnectedValue(s), r.depth = i.depth.getConnectedValue(s);
          var l = i.subdivisions.getConnectedValue(s), c = i.subdivisionsX.getConnectedValue(s), u = i.subdivisionsY.getConnectedValue(s), h = i.subdivisionsZ.getConnectedValue(s);
          return l && (r.segments = l), c && (r.widthSegments = c), u && (r.heightSegments = u), h && (r.depthSegments = h), Mv(r);
        };
        if (this.evaluateContext)
          this.geometry._storedFunction = o;
        else {
          var a = o(e);
          this.geometry._storedFunction = function() {
            return i.geometry._executionCount = 1, a.clone();
          };
        }
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".evaluateContext = ").concat(this.evaluateContext ? "true" : "false", `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.evaluateContext = this.evaluateContext, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), this.evaluateContext = e.evaluateContext;
      }, x([qe("Evaluate context", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t;
    }(At);
    j("BABYLON.BoxBlock", Q_);
    var IP = function() {
      function n(t) {
        this._buildId = n._BuildIdGenerator++, this._buildWasSuccessful = !1, this._vertexData = null, this._buildExecutionTime = 0, this.BJSNODEGEOMETRYEDITOR = this._getGlobalNodeGeometryEditor(), this.editorData = null, this.attachedBlocks = [], this.onBuildObservable = new H(), this.outputBlock = null, this.name = t;
      }
      return n.prototype._getGlobalNodeGeometryEditor = function() {
        return typeof NODEGEOMETRYEDITOR < "u" ? NODEGEOMETRYEDITOR : typeof BABYLON < "u" && BABYLON.NodeGeometryEditor !== void 0 ? BABYLON : void 0;
      }, Object.defineProperty(n.prototype, "buildExecutionTime", { get: function() {
        return this._buildExecutionTime;
      }, enumerable: !1, configurable: !0 }), n.prototype.getClassName = function() {
        return "NodeGeometry";
      }, n.prototype.getBlockByName = function(t) {
        for (var e = null, i = 0, r = this.attachedBlocks; i < r.length; i++) {
          var o = r[i];
          if (o.name === t) {
            if (e)
              return de.Warn("More than one block was found with the name `" + t + "`"), e;
            e = o;
          }
        }
        return e;
      }, n.prototype.getBlockByPredicate = function(t) {
        for (var e = 0, i = this.attachedBlocks; e < i.length; e++) {
          var r = i[e];
          if (t(r))
            return r;
        }
        return null;
      }, n.prototype.getInputBlocks = function() {
        for (var t = [], e = 0, i = this.attachedBlocks; e < i.length; e++) {
          var r = i[e];
          r.isInput && t.push(r);
        }
        return t;
      }, n.prototype.edit = function(t) {
        var e = this;
        return new Promise(function(i) {
          if (e.BJSNODEGEOMETRYEDITOR = e.BJSNODEGEOMETRYEDITOR || e._getGlobalNodeGeometryEditor(), e.BJSNODEGEOMETRYEDITOR === void 0) {
            var r = t && t.editorURL ? t.editorURL : n.EditorURL;
            de.LoadBabylonScript(r, function() {
              e.BJSNODEGEOMETRYEDITOR = e.BJSNODEGEOMETRYEDITOR || e._getGlobalNodeGeometryEditor(), e._createNodeEditor(t == null ? void 0 : t.nodeGeometryEditorConfig), i();
            });
          } else
            e._createNodeEditor(t == null ? void 0 : t.nodeGeometryEditorConfig), i();
        });
      }, n.prototype._createNodeEditor = function(t) {
        var e = je({ nodeGeometry: this }, t);
        this.BJSNODEGEOMETRYEDITOR.NodeGeometryEditor.Show(e);
      }, n.prototype.build = function(t, e, i) {
        if (t === void 0 && (t = !1), e === void 0 && (e = !0), i === void 0 && (i = !1), this._buildWasSuccessful = !1, !this.outputBlock)
          throw "You must define the outputBlock property before building the geometry";
        var r = It.Now;
        this._initializeBlock(this.outputBlock, i);
        var o = new kT();
        o.buildId = this._buildId, o.verbose = t, this.outputBlock.build(o), e && (this._buildId = n._BuildIdGenerator++), this._buildExecutionTime = It.Now - r, o.emitErrors(), this._buildWasSuccessful = !0, this._vertexData = o.vertexData, this.onBuildObservable.notifyObservers(this);
      }, n.prototype.createMesh = function(t, e) {
        if (e === void 0 && (e = null), this._buildWasSuccessful || this.build(), !this._vertexData)
          return null;
        var i = new ie(t, e);
        return this._vertexData.applyToMesh(i), i._internalMetadata = i._internalMetadata || {}, i._internalMetadata.nodeGeometry = this, i;
      }, n.prototype.updateMesh = function(t) {
        return this._buildWasSuccessful || this.build(), !!this._vertexData && (this._vertexData.applyToMesh(t), t._internalMetadata = t._internalMetadata || {}, t._internalMetadata.nodeGeometry = this, t);
      }, n.prototype._initializeBlock = function(t, e) {
        e === void 0 && (e = !0), t.initialize(), e && t.autoConfigure(), t._preparationId = this._buildId, this.attachedBlocks.indexOf(t) === -1 && this.attachedBlocks.push(t);
        for (var i = 0, r = t.inputs; i < r.length; i++) {
          var o = r[i].connectedPoint;
          if (o) {
            var a = o.ownerBlock;
            a !== t && this._initializeBlock(a, e);
          }
        }
      }, n.prototype.clear = function() {
        this.outputBlock = null, this.attachedBlocks.length = 0;
      }, n.prototype.removeBlock = function(t) {
        var e = this.attachedBlocks.indexOf(t);
        e > -1 && this.attachedBlocks.splice(e, 1), t === this.outputBlock && (this.outputBlock = null);
      }, n.prototype.parseSerializedObject = function(t, e) {
        e === void 0 && (e = !1), e || this.clear();
        for (var i = {}, r = 0, o = t.blocks; r < o.length; r++) {
          var a = Kt((p = o[r]).customType);
          a && ((f = new a())._deserialize(p), i[p.id] = f, this.attachedBlocks.push(f));
        }
        for (var s = 0, l = this.attachedBlocks; s < l.length; s++)
          if ((f = l[s]).isTeleportOut) {
            var c = f, u = c._tempEntryPointUniqueId;
            if (u) {
              var h = i[u];
              h && h.attachToEndpoint(c);
            }
          }
        for (var d = 0; d < t.blocks.length; d++) {
          var p, f;
          (f = i[(p = t.blocks[d]).id]) && (f.inputs.length && p.inputs.some(function(E) {
            return E.targetConnectionName;
          }) && !e || this._restoreConnections(f, t, i));
        }
        if (t.outputNodeId && (this.outputBlock = i[t.outputNodeId]), t.locations || t.editorData && t.editorData.locations) {
          for (var m = t.locations || t.editorData.locations, g = 0, y = m; g < y.length; g++) {
            var b = y[g];
            i[b.blockId] && (b.blockId = i[b.blockId].uniqueId);
          }
          e && this.editorData && this.editorData.locations && m.concat(this.editorData.locations), t.locations ? this.editorData = { locations: m } : (this.editorData = t.editorData, this.editorData.locations = m);
          var T = [];
          for (var S in i)
            T[S] = i[S].uniqueId;
          this.editorData.map = T;
        }
        this.comment = t.comment;
      }, n.prototype._restoreConnections = function(t, e, i) {
        for (var r = 0, o = t.outputs; r < o.length; r++)
          for (var a = o[r], s = 0, l = e.blocks; s < l.length; s++) {
            var c = l[s], u = i[c.id];
            if (u)
              for (var h = 0, d = c.inputs; h < d.length; h++) {
                var p = d[h];
                if (!(i[p.targetBlockId] !== t || p.targetConnectionName !== a.name)) {
                  var f = u.getInputByName(p.inputName);
                  if (!f || f.isConnected)
                    continue;
                  a.connectTo(f, !0), this._restoreConnections(u, e, i);
                }
              }
          }
      }, n.prototype.generateCode = function() {
        var t = [], e = [], i = ["const", "var", "let"];
        this.outputBlock && this._gatherBlocks(this.outputBlock, e);
        for (var r = 'let nodeGeometry = new BABYLON.NodeGeometry("'.concat(this.name || "node geometry", `");
`), o = 0, a = e; o < a.length; o++) {
          var s = a[o];
          s.isInput && t.indexOf(s) === -1 && (r += s._dumpCode(i, t));
        }
        return this.outputBlock && (t = [], r += `// Connections
`, r += this.outputBlock._dumpCodeForOutputConnections(t), r += `// Output nodes
`, r += "nodeGeometry.outputBlock = ".concat(this.outputBlock._codeVariableName, `;
`), r += `nodeGeometry.build();
`), r;
      }, n.prototype._gatherBlocks = function(t, e) {
        if (e.indexOf(t) === -1) {
          e.push(t);
          for (var i = 0, r = t.inputs; i < r.length; i++) {
            var o = r[i].connectedPoint;
            o && (a = o.ownerBlock) !== t && this._gatherBlocks(a, e);
          }
          var a;
          t.isTeleportOut && (a = t).entryPoint && this._gatherBlocks(a.entryPoint, e);
        }
      }, n.prototype.setToDefault = function() {
        this.clear(), this.editorData = null;
        var t = new Q_("Box");
        t.autoConfigure();
        var e = new q_("Geometry Output");
        t.geometry.connectTo(e.geometry), this.outputBlock = e;
      }, n.prototype.clone = function(t) {
        var e = this.serialize(), i = Ne.Clone(function() {
          return new n(t);
        }, this);
        return i.name = t, i.parseSerializedObject(e), i._buildId = this._buildId, i.build(!1), i;
      }, n.prototype.serialize = function(t) {
        var e = t ? {} : Ne.Serialize(this);
        e.editorData = JSON.parse(JSON.stringify(this.editorData));
        var i = [];
        t ? i = t : (e.customType = "BABYLON.NodeGeometry", this.outputBlock && (e.outputNodeId = this.outputBlock.uniqueId)), e.blocks = [];
        for (var r = 0, o = i; r < o.length; r++) {
          var a = o[r];
          e.blocks.push(a.serialize());
        }
        if (!t)
          for (var s = 0, l = this.attachedBlocks; s < l.length; s++)
            a = l[s], i.indexOf(a) === -1 && e.blocks.push(a.serialize());
        return e;
      }, n.prototype.dispose = function() {
        for (var t = 0, e = this.attachedBlocks; t < e.length; t++)
          e[t].dispose();
        this.attachedBlocks.length = 0, this.onBuildObservable.clear();
      }, n.CreateDefault = function(t) {
        var e = new n(t);
        return e.setToDefault(), e.build(), e;
      }, n.Parse = function(t) {
        var e = Ne.Parse(function() {
          return new n(t.name);
        }, t, null);
        return e.parseSerializedObject(t), e.build(), e;
      }, n.ParseFromSnippetAsync = function(t, e, i) {
        var r = this;
        return i === void 0 && (i = !1), t === "_BLANK" ? Promise.resolve(n.CreateDefault("blank")) : new Promise(function(o, a) {
          var s = new _n();
          s.addEventListener("readystatechange", function() {
            if (s.readyState == 4)
              if (s.status == 200) {
                var l = JSON.parse(JSON.parse(s.responseText).jsonPayload), c = JSON.parse(l.nodeGeometry);
                e || (e = Ne.Parse(function() {
                  return new n(t);
                }, c, null)), e.parseSerializedObject(c), e.snippetId = t;
                try {
                  i || e.build(), o(e);
                } catch (u) {
                  a(u);
                }
              } else
                a("Unable to load the snippet " + t);
          }), s.open("GET", r.SnippetUrl + "/" + t.replace(/#/g, "/")), s.send();
        });
      }, n._BuildIdGenerator = 0, n.EditorURL = "".concat(de._DefaultCdnUrl, "/v").concat(ve.Version, "/nodeGeometryEditor/babylon.nodeGeometryEditor.js"), n.SnippetUrl = _.SnippetUrl, x([N()], n.prototype, "name", void 0), x([N("comment")], n.prototype, "comment", void 0), n;
    }(), GT = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.evaluateContext = !0, i.epsilon = Ge, i.registerInput("geometry", Q.Geometry), i.registerOutput("output", Q.Geometry), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "GeometryOptimizeBlock";
      }, Object.defineProperty(t.prototype, "geometry", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        var i = this, r = function(o) {
          if (!i.geometry.isConnected)
            return null;
          for (var a = i.geometry.getConnectedValue(o), s = [], l = {}, c = 0; c < a.positions.length; c += 3) {
            for (var u = a.positions[c], h = a.positions[c + 1], d = a.positions[c + 2], p = !1, f = 0; f < s.length; f += 3)
              ue.WithinEpsilon(u, s[f], i.epsilon) && ue.WithinEpsilon(h, s[f + 1], i.epsilon) && ue.WithinEpsilon(d, s[f + 2], i.epsilon) && (l[c / 3] = f / 3, p = !0);
            p || (l[c / 3] = s.length / 3, s.push(u, h, d));
          }
          var m = new Oe();
          return m.positions = s, m.indices = a.indices.map(function(g) {
            return l[g];
          }), m;
        };
        this.evaluateContext ? this.output._storedFunction = r : (this.output._storedFunction = null, this.output._storedValue = r(e));
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".evaluateContext = ").concat(this.evaluateContext ? "true" : "false", `;
`) + "".concat(this._codeVariableName, ".epsilon = ").concat(this.epsilon, `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.evaluateContext = this.evaluateContext, e.epsilon = this.epsilon, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), this.evaluateContext = e.evaluateContext, this.epsilon = e.epsilon;
      }, x([qe("Evaluate context", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), x([qe("Epsilon", Ye.Float, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "epsilon", void 0), t;
    }(At);
    j("BABYLON.GeometryOptimizeBlock", GT);
    var zT = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.evaluateContext = !1, i.registerInput("size", Q.Float, !0, 1), i.registerInput("width", Q.Float, !0, 0), i.registerInput("height", Q.Float, !0, 0), i.registerOutput("geometry", Q.Geometry), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "PlaneBlock";
      }, Object.defineProperty(t.prototype, "size", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "width", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "height", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function() {
        if (!this.size.isConnected) {
          if (!this.width.isConnected && !this.height.isConnected) {
            var e = new Di("Size");
            return e.value = 1, void e.output.connectTo(this.size);
          }
          if (!this.width.isConnected) {
            var i = new Di("Width");
            i.value = 1, i.output.connectTo(this.width);
          }
          if (!this.height.isConnected) {
            var r = new Di("Height");
            r.value = 1, r.output.connectTo(this.height);
          }
        }
      }, t.prototype._buildBlock = function(e) {
        var i = this, r = {}, o = function(s) {
          return r.size = i.size.getConnectedValue(s), r.width = i.width.getConnectedValue(s), r.height = i.height.getConnectedValue(s), Zu(r);
        };
        if (this.evaluateContext)
          this.geometry._storedFunction = o;
        else {
          var a = o(e);
          this.geometry._storedFunction = function() {
            return i.geometry._executionCount = 1, a.clone();
          };
        }
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".evaluateContext = ").concat(this.evaluateContext ? "true" : "false", `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.evaluateContext = this.evaluateContext, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), this.evaluateContext = e.evaluateContext;
      }, x([qe("Evaluate context", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t;
    }(At);
    j("BABYLON.PlaneBlock", zT);
    var WT = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i._cachedVertexData = null, i.reverseWindingOrder = !1, i.serializedCachedData = !1, i.registerOutput("geometry", Q.Geometry), i;
      }
      return D(t, n), Object.defineProperty(t.prototype, "mesh", { get: function() {
        return this._mesh;
      }, set: function(e) {
        this._mesh = e;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "MeshBlock";
      }, Object.defineProperty(t.prototype, "isUsingCachedData", { get: function() {
        return !this.mesh && !!this._cachedVertexData;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.cleanData = function() {
        this._mesh = null, this._cachedVertexData = null;
      }, t.prototype._buildBlock = function() {
        if (this._mesh) {
          var e = Oe.ExtractFromMesh(this._mesh, !1, !0);
          if (this._cachedVertexData = null, this.reverseWindingOrder && e.indices)
            for (var i = 0; i < e.indices.length; i += 3) {
              var r = e.indices[i];
              e.indices[i] = e.indices[i + 2], e.indices[i + 2] = r;
            }
          this.geometry._storedFunction = function() {
            return e.clone();
          };
        } else
          this._cachedVertexData ? this.geometry._storedValue = this._cachedVertexData.clone() : this.geometry._storedValue = null;
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.serializedCachedData = this.serializedCachedData, this.serializedCachedData && (this._mesh ? e.cachedVertexData = Oe.ExtractFromMesh(this._mesh, !1, !0).serialize() : this._cachedVertexData && (e.cachedVertexData = this._cachedVertexData.serialize())), e.reverseWindingOrder = this.reverseWindingOrder, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), e.cachedVertexData && (this._cachedVertexData = Oe.Parse(e.cachedVertexData)), this.serializedCachedData = !!e.serializedCachedData, this.reverseWindingOrder = e.reverseWindingOrder;
      }, x([qe("Serialize cached data", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "serializedCachedData", void 0), t;
    }(At);
    j("BABYLON.MeshBlock", WT);
    var HT = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.evaluateContext = !1, i.registerInput("radius", Q.Float, !0, 1), i.registerInput("radiusX", Q.Float, !0, 0), i.registerInput("radiusY", Q.Float, !0, 0), i.registerInput("radiusZ", Q.Float, !0, 0), i.registerInput("subdivisions", Q.Int, !0, 4), i.registerOutput("geometry", Q.Geometry), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "IcoSphereBlock";
      }, Object.defineProperty(t.prototype, "radius", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "radiusX", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "radiusY", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "radiusZ", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subdivisions", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function() {
        if (!this.radius.isConnected) {
          var e = new Di("Radius");
          e.value = 0.2, e.output.connectTo(this.radius);
        }
      }, t.prototype._buildBlock = function(e) {
        var i = this, r = {}, o = function(s) {
          return r.radius = i.radius.getConnectedValue(s), r.subdivisions = i.subdivisions.getConnectedValue(s), r.radiusX = i.radiusX.getConnectedValue(s), r.radiusY = i.radiusY.getConnectedValue(s), r.radiusZ = i.radiusZ.getConnectedValue(s), nh(r);
        };
        if (this.evaluateContext)
          this.geometry._storedFunction = o;
        else {
          var a = o(e);
          this.geometry._storedFunction = function() {
            return i.geometry._executionCount = 1, a.clone();
          };
        }
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".evaluateContext = ").concat(this.evaluateContext ? "true" : "false", `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.evaluateContext = this.evaluateContext, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), this.evaluateContext = e.evaluateContext;
      }, x([qe("Evaluate context", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t;
    }(At);
    j("BABYLON.IcoSphereBlock", HT);
    var XT = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.evaluateContext = !1, i.registerInput("segments", Q.Int, !0, 32), i.registerInput("diameter", Q.Float, !0, 1), i.registerInput("diameterX", Q.Float, !0, 0), i.registerInput("diameterY", Q.Float, !0, 0), i.registerInput("diameterZ", Q.Float, !0, 0), i.registerInput("arc", Q.Float, !0, 1), i.registerInput("slice", Q.Float, !0, 1), i.registerOutput("geometry", Q.Geometry), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "SphereBlock";
      }, Object.defineProperty(t.prototype, "segments", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "diameter", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "diameterX", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "diameterY", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "diameterZ", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "arc", { get: function() {
        return this._inputs[5];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "slice", { get: function() {
        return this._inputs[6];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function() {
        if (!this.diameter.isConnected) {
          var e = new Di("Diameter");
          e.value = 1, e.output.connectTo(this.diameter);
        }
      }, t.prototype._buildBlock = function(e) {
        var i = this, r = {}, o = function(s) {
          return r.segments = i.segments.getConnectedValue(s), r.diameter = i.diameter.getConnectedValue(s), r.diameterX = i.diameterX.getConnectedValue(s), r.diameterY = i.diameterY.getConnectedValue(s), r.diameterZ = i.diameterZ.getConnectedValue(s), r.arc = i.arc.getConnectedValue(s), r.slice = i.slice.getConnectedValue(s), bh(r);
        };
        if (this.evaluateContext)
          this.geometry._storedFunction = o;
        else {
          var a = o(e);
          this.geometry._storedFunction = function() {
            return i.geometry._executionCount = 1, a.clone();
          };
        }
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".evaluateContext = ").concat(this.evaluateContext ? "true" : "false", `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.evaluateContext = this.evaluateContext, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), this.evaluateContext = e.evaluateContext;
      }, x([qe("Evaluate context", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t;
    }(At);
    j("BABYLON.SphereBlock", XT);
    var jT = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.evaluateContext = !1, i.registerInput("width", Q.Float, !0, 1), i.registerInput("height", Q.Float, !0, 1), i.registerInput("subdivisions", Q.Int, !0, 1), i.registerInput("subdivisionsX", Q.Int, !0, 0), i.registerInput("subdivisionsY", Q.Int, !0, 0), i.registerOutput("geometry", Q.Geometry), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "GridBlock";
      }, Object.defineProperty(t.prototype, "width", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "height", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subdivisions", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subdivisionsX", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subdivisionsY", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function() {
        if (!this.width.isConnected) {
          var e = new Di("Width");
          e.value = 1, e.output.connectTo(this.width);
        }
        if (!this.height.isConnected) {
          var i = new Di("Height");
          i.value = 1, i.output.connectTo(this.height);
        }
      }, t.prototype._buildBlock = function(e) {
        var i = this, r = {}, o = function(s) {
          return r.width = i.width.getConnectedValue(s), r.height = i.height.getConnectedValue(s), r.subdivisions = i.subdivisions.getConnectedValue(s), r.subdivisionsX = i.subdivisionsX.getConnectedValue(s), r.subdivisionsY = i.subdivisionsY.getConnectedValue(s), Do(r);
        };
        if (this.evaluateContext)
          this.geometry._storedFunction = o;
        else {
          var a = o(e);
          this.geometry._storedFunction = function() {
            return i.geometry._executionCount = 1, a.clone();
          };
        }
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".evaluateContext = ").concat(this.evaluateContext ? "true" : "false", `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.evaluateContext = this.evaluateContext, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), this.evaluateContext = e.evaluateContext;
      }, x([qe("Evaluate context", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t;
    }(At);
    j("BABYLON.GridBlock", jT);
    var YT = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.evaluateContext = !1, i.registerInput("diameter", Q.Float, !0, 1), i.registerInput("thickness", Q.Float, !0, 0.5), i.registerInput("tessellation", Q.Int, !0, 16), i.registerOutput("geometry", Q.Geometry), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "TorusBlock";
      }, Object.defineProperty(t.prototype, "diameter", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "thickness", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tessellation", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function() {
        if (!this.diameter.isConnected) {
          var e = new Di("Diameter");
          e.value = 1, e.output.connectTo(this.diameter);
        }
      }, t.prototype._buildBlock = function(e) {
        var i = this, r = {}, o = function(s) {
          return r.thickness = i.thickness.getConnectedValue(s), r.diameter = i.diameter.getConnectedValue(s), r.tessellation = i.tessellation.getConnectedValue(s), mh(r);
        };
        if (this.evaluateContext)
          this.geometry._storedFunction = o;
        else {
          var a = o(e);
          this.geometry._storedFunction = function() {
            return i.geometry._executionCount = 1, a.clone();
          };
        }
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".evaluateContext = ").concat(this.evaluateContext ? "true" : "false", `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.evaluateContext = this.evaluateContext, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), this.evaluateContext = e.evaluateContext;
      }, x([qe("Evaluate context", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t;
    }(At);
    j("BABYLON.TorusBlock", YT);
    var KT = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.evaluateContext = !1, i.registerInput("height", Q.Float, !0, 25), i.registerInput("diameter", Q.Float, !0, 1), i.registerInput("diameterTop", Q.Float, !0, -1), i.registerInput("diameterBottom", Q.Float, !0, -1), i.registerInput("subdivisions", Q.Int, !0, 1), i.registerInput("tessellation", Q.Int, !0, 24), i.registerInput("arc", Q.Float, !0, 1), i.registerOutput("geometry", Q.Geometry), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "CylinderBlock";
      }, Object.defineProperty(t.prototype, "height", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "diameter", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "diameterTop", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "diameterBottom", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subdivisions", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tessellation", { get: function() {
        return this._inputs[5];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "arc", { get: function() {
        return this._inputs[6];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function() {
        if (!this.diameter.isConnected) {
          var e = new Di("Diameter");
          e.value = 1, e.output.connectTo(this.diameter);
        }
        if (!this.height.isConnected) {
          var i = new Di("Height");
          i.value = 1, i.output.connectTo(this.height);
        }
      }, t.prototype._buildBlock = function(e) {
        var i = this, r = {}, o = function(s) {
          return r.height = i.height.getConnectedValue(s), r.diameter = i.diameter.getConnectedValue(s), r.diameterTop = i.diameterTop.getConnectedValue(s), r.diameterBottom = i.diameterBottom.getConnectedValue(s), r.diameterTop === -1 && (r.diameterTop = r.diameter), r.diameterBottom === -1 && (r.diameterBottom = r.diameter), r.tessellation = i.tessellation.getConnectedValue(s), r.subdivisions = i.subdivisions.getConnectedValue(s), r.arc = i.arc.getConnectedValue(s), gh(r);
        };
        if (this.evaluateContext)
          this.geometry._storedFunction = o;
        else {
          var a = o(e);
          this.geometry._storedFunction = function() {
            return i.geometry._executionCount = 1, a.clone();
          };
        }
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".evaluateContext = ").concat(this.evaluateContext ? "true" : "false", `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.evaluateContext = this.evaluateContext, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), this.evaluateContext = e.evaluateContext;
      }, x([qe("Evaluate context", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t;
    }(At);
    j("BABYLON.CylinderBlock", KT);
    var qT = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.evaluateContext = !1, i.registerInput("height", Q.Float, !0, 1), i.registerInput("radius", Q.Float, !0, 0.25), i.registerInput("tessellation", Q.Int, !0, 16), i.registerInput("subdivisions", Q.Int, !0, 2), i.registerOutput("geometry", Q.Geometry), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "CapsuleBlock";
      }, Object.defineProperty(t.prototype, "height", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "radius", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tessellation", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subdivisions", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function() {
        if (!this.height.isConnected) {
          var e = new Di("Height");
          e.value = 1, e.output.connectTo(this.height);
        }
        if (!this.radius.isConnected) {
          var i = new Di("Radius");
          i.value = 0.2, i.output.connectTo(this.radius);
        }
      }, t.prototype._buildBlock = function(e) {
        var i = this, r = {}, o = function(s) {
          return r.height = i.height.getConnectedValue(s), r.radius = i.radius.getConnectedValue(s), r.tessellation = i.tessellation.getConnectedValue(s), r.subdivisions = i.subdivisions.getConnectedValue(s), Th(r);
        };
        if (this.evaluateContext)
          this.geometry._storedFunction = o;
        else {
          var a = o(e);
          this.geometry._storedFunction = function() {
            return i.geometry._executionCount = 1, a.clone();
          };
        }
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".evaluateContext = ").concat(this.evaluateContext ? "true" : "false", `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.evaluateContext = this.evaluateContext, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), this.evaluateContext = e.evaluateContext;
      }, x([qe("Evaluate context", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t;
    }(At);
    j("BABYLON.CapsuleBlock", qT);
    var QT = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.evaluateContext = !1, i.registerInput("radius", Q.Float, !0, 0.5), i.registerInput("tessellation", Q.Int, !0, 64), i.registerInput("arc", Q.Float, !0, 1), i.registerOutput("geometry", Q.Geometry), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "DiscBlock";
      }, Object.defineProperty(t.prototype, "radius", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tessellation", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "arc", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function() {
        if (!this.radius.isConnected) {
          var e = new Di("Radius");
          e.value = 0.2, e.output.connectTo(this.radius);
        }
      }, t.prototype._buildBlock = function(e) {
        var i = this, r = {}, o = function(s) {
          return r.radius = i.radius.getConnectedValue(s), r.tessellation = i.tessellation.getConnectedValue(s), r.arc = i.arc.getConnectedValue(s), Eh(r);
        };
        if (this.evaluateContext)
          this.geometry._storedFunction = o;
        else {
          var a = o(e);
          this.geometry._storedFunction = function() {
            return i.geometry._executionCount = 1, a.clone();
          };
        }
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".evaluateContext = ").concat(this.evaluateContext ? "true" : "false", `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.evaluateContext = this.evaluateContext, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), this.evaluateContext = e.evaluateContext;
      }, x([qe("Evaluate context", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t;
    }(At);
    j("BABYLON.DiscBlock", QT);
    var ZT = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.registerOutput("geometry", Q.Geometry), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "NullBlock";
      }, Object.defineProperty(t.prototype, "geometry", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function() {
        this.geometry._storedValue = null;
      }, t;
    }(At);
    j("BABYLON.NullBlock", ZT);
    var JT = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.evaluateContext = !0, i.registerInput("geometry", Q.Geometry), i.registerInput("positions", Q.Vector3), i.registerOutput("output", Q.Geometry), i;
      }
      return D(t, n), t.prototype.getExecutionIndex = function() {
        return this._currentIndex;
      }, t.prototype.getExecutionLoopIndex = function() {
        return this._currentIndex;
      }, t.prototype.getExecutionFaceIndex = function() {
        return 0;
      }, t.prototype.getClassName = function() {
        return "SetPositionsBlock";
      }, Object.defineProperty(t.prototype, "geometry", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "positions", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        var i = this, r = function(o) {
          if (o.pushExecutionContext(i), i._vertexData = i.geometry.getConnectedValue(o), o.pushGeometryContext(i._vertexData), !i._vertexData || !i._vertexData.positions || !i.positions.isConnected)
            return o.restoreGeometryContext(), o.restoreExecutionContext(), void (i.output._storedValue = null);
          var a = i._vertexData.positions.length / 3;
          for (i._currentIndex = 0; i._currentIndex < a; i._currentIndex++) {
            var s = i.positions.getConnectedValue(o);
            s && s.toArray(i._vertexData.positions, 3 * i._currentIndex);
          }
          return o.restoreGeometryContext(), o.restoreExecutionContext(), i._vertexData;
        };
        this.evaluateContext ? this.output._storedFunction = r : (this.output._storedFunction = null, this.output._storedValue = r(e));
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".evaluateContext = ").concat(this.evaluateContext ? "true" : "false", `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.evaluateContext = this.evaluateContext, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), e.evaluateContext !== void 0 && (this.evaluateContext = e.evaluateContext);
      }, x([qe("Evaluate context", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t;
    }(At);
    j("BABYLON.SetPositionsBlock", JT);
    var $T = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.evaluateContext = !0, i.registerInput("geometry", Q.Geometry), i.registerInput("normals", Q.Vector3), i.registerOutput("output", Q.Geometry), i;
      }
      return D(t, n), t.prototype.getExecutionIndex = function() {
        return this._currentIndex;
      }, t.prototype.getExecutionLoopIndex = function() {
        return this._currentIndex;
      }, t.prototype.getExecutionFaceIndex = function() {
        return 0;
      }, t.prototype.getClassName = function() {
        return "SetNormalsBlock";
      }, Object.defineProperty(t.prototype, "geometry", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "normals", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        var i = this, r = function(o) {
          if (o.pushExecutionContext(i), i._vertexData = i.geometry.getConnectedValue(o), o.pushGeometryContext(i._vertexData), !i._vertexData || !i._vertexData.positions)
            return o.restoreGeometryContext(), o.restoreExecutionContext(), void (i.output._storedValue = null);
          if (!i.normals.isConnected)
            return o.restoreGeometryContext(), o.restoreExecutionContext(), void (i.output._storedValue = i._vertexData);
          i._vertexData.normals || (i._vertexData.normals = []);
          var a = i._vertexData.positions.length / 3;
          for (i._currentIndex = 0; i._currentIndex < a; i._currentIndex++) {
            var s = i.normals.getConnectedValue(o);
            s && s.toArray(i._vertexData.normals, 3 * i._currentIndex);
          }
          return o.restoreGeometryContext(), o.restoreExecutionContext(), i._vertexData;
        };
        this.evaluateContext ? this.output._storedFunction = r : (this.output._storedFunction = null, this.output._storedValue = r(e));
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".evaluateContext = ").concat(this.evaluateContext ? "true" : "false", `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.evaluateContext = this.evaluateContext, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), e.evaluateContext !== void 0 && (this.evaluateContext = e.evaluateContext);
      }, x([qe("Evaluate context", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t;
    }(At);
    j("BABYLON.SetNormalsBlock", $T);
    var e0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.evaluateContext = !0, i.textureCoordinateIndex = 0, i.registerInput("geometry", Q.Geometry), i.registerInput("uvs", Q.Vector2), i.registerOutput("output", Q.Geometry), i;
      }
      return D(t, n), t.prototype.getExecutionIndex = function() {
        return this._currentIndex;
      }, t.prototype.getExecutionLoopIndex = function() {
        return this._currentIndex;
      }, t.prototype.getExecutionFaceIndex = function() {
        return 0;
      }, t.prototype.getClassName = function() {
        return "SetUVsBlock";
      }, Object.defineProperty(t.prototype, "geometry", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "uvs", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        var i = this, r = function(o) {
          if (o.pushExecutionContext(i), i._vertexData = i.geometry.getConnectedValue(o), o.pushGeometryContext(i._vertexData), !i._vertexData || !i._vertexData.positions)
            return o.restoreGeometryContext(), o.restoreExecutionContext(), void (i.output._storedValue = null);
          if (!i.uvs.isConnected)
            return o.restoreGeometryContext(), o.restoreExecutionContext(), void (i.output._storedValue = i._vertexData);
          var a = [], s = i._vertexData.positions.length / 3;
          for (i._currentIndex = 0; i._currentIndex < s; i._currentIndex++) {
            var l = i.uvs.getConnectedValue(o);
            l && l.toArray(a, 2 * i._currentIndex);
          }
          switch (i.textureCoordinateIndex) {
            case 0:
              i._vertexData.uvs = a;
              break;
            case 1:
              i._vertexData.uvs2 = a;
              break;
            case 2:
              i._vertexData.uvs3 = a;
              break;
            case 3:
              i._vertexData.uvs4 = a;
              break;
            case 4:
              i._vertexData.uvs5 = a;
              break;
            case 5:
              i._vertexData.uvs6 = a;
          }
          return o.restoreGeometryContext(), o.restoreExecutionContext(), i._vertexData;
        };
        this.evaluateContext ? this.output._storedFunction = r : (this.output._storedFunction = null, this.output._storedValue = r(e));
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, `.textureCoordinateIndex};
`) + "".concat(this._codeVariableName, ".evaluateContext = ").concat(this.evaluateContext ? "true" : "false", `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.evaluateContext = this.evaluateContext, e.textureCoordinateIndex = this.textureCoordinateIndex, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), this.textureCoordinateIndex = e.textureCoordinateIndex, e.evaluateContext !== void 0 && (this.evaluateContext = e.evaluateContext);
      }, x([qe("Evaluate context", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), x([qe("Texture coordinates index", Ye.List, "ADVANCED", { notifiers: { update: !0 }, options: [{ label: "UV1", value: 0 }, { label: "UV2", value: 1 }, { label: "UV3", value: 2 }, { label: "UV4", value: 3 }, { label: "UV5", value: 4 }, { label: "UV6", value: 5 }] })], t.prototype, "textureCoordinateIndex", void 0), t;
    }(At);
    j("BABYLON.SetUVsBlock", e0);
    var t0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.evaluateContext = !0, i.registerInput("geometry", Q.Geometry), i.registerInput("colors", Q.Vector4), i.registerOutput("output", Q.Geometry), i;
      }
      return D(t, n), t.prototype.getExecutionIndex = function() {
        return this._currentIndex;
      }, t.prototype.getExecutionLoopIndex = function() {
        return this._currentIndex;
      }, t.prototype.getExecutionFaceIndex = function() {
        return 0;
      }, t.prototype.getClassName = function() {
        return "SetColorsBlock";
      }, Object.defineProperty(t.prototype, "geometry", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "colors", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        var i = this, r = function(o) {
          if (o.pushExecutionContext(i), i._vertexData = i.geometry.getConnectedValue(o), o.pushGeometryContext(i._vertexData), !i._vertexData || !i._vertexData.positions)
            return o.restoreGeometryContext(), o.restoreExecutionContext(), void (i.output._storedValue = null);
          if (!i.colors.isConnected)
            return o.restoreGeometryContext(), o.restoreExecutionContext(), void (i.output._storedValue = i._vertexData);
          i._vertexData.colors || (i._vertexData.colors = []);
          var a = i._vertexData.positions.length / 3;
          for (i._currentIndex = 0; i._currentIndex < a; i._currentIndex++) {
            var s = i.colors.getConnectedValue(o);
            s && s.toArray(i._vertexData.colors, 4 * i._currentIndex);
          }
          return o.restoreGeometryContext(), o.restoreExecutionContext(), i._vertexData;
        };
        this.evaluateContext ? this.output._storedFunction = r : (this.output._storedFunction = null, this.output._storedValue = r(e));
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".evaluateContext = ").concat(this.evaluateContext ? "true" : "false", `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.evaluateContext = this.evaluateContext, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), e.evaluateContext !== void 0 && (this.evaluateContext = e.evaluateContext);
      }, x([qe("Evaluate context", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t;
    }(At);
    j("BABYLON.SetColorsBlock", t0);
    var Gn, i0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.evaluateContext = !0, i.registerInput("geometry", Q.Geometry), i.registerInput("tangents", Q.Vector4), i.registerOutput("output", Q.Geometry), i;
      }
      return D(t, n), t.prototype.getExecutionIndex = function() {
        return this._currentIndex;
      }, t.prototype.getExecutionLoopIndex = function() {
        return this._currentIndex;
      }, t.prototype.getExecutionFaceIndex = function() {
        return 0;
      }, t.prototype.getClassName = function() {
        return "SetTangentsBlock";
      }, Object.defineProperty(t.prototype, "geometry", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tangents", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        var i = this, r = function(o) {
          if (o.pushExecutionContext(i), i._vertexData = i.geometry.getConnectedValue(o), o.pushGeometryContext(i._vertexData), !i._vertexData || !i._vertexData.positions)
            return o.restoreGeometryContext(), o.restoreExecutionContext(), void (i.output._storedValue = null);
          if (!i.tangents.isConnected)
            return o.restoreGeometryContext(), o.restoreExecutionContext(), void (i.output._storedValue = i._vertexData);
          i._vertexData.tangents || (i._vertexData.tangents = []);
          var a = i._vertexData.positions.length / 3;
          for (i._currentIndex = 0; i._currentIndex < a; i._currentIndex++) {
            var s = i.tangents.getConnectedValue(o);
            s && s.toArray(i._vertexData.tangents, 4 * i._currentIndex);
          }
          return o.restoreGeometryContext(), o.restoreExecutionContext(), i._vertexData;
        };
        this.evaluateContext ? this.output._storedFunction = r : (this.output._storedFunction = null, this.output._storedValue = r(e));
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".evaluateContext = ").concat(this.evaluateContext ? "true" : "false", `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.evaluateContext = this.evaluateContext, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), e.evaluateContext !== void 0 && (this.evaluateContext = e.evaluateContext);
      }, x([qe("Evaluate context", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t;
    }(At);
    j("BABYLON.SetTangentsBlock", i0), function(n) {
      n[n.Add = 0] = "Add", n[n.Subtract = 1] = "Subtract", n[n.Multiply = 2] = "Multiply", n[n.Divide = 3] = "Divide", n[n.Max = 4] = "Max", n[n.Min = 5] = "Min";
    }(Gn || (Gn = {}));
    var n0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.operation = Gn.Add, i.registerInput("left", Q.AutoDetect), i.registerInput("right", Q.AutoDetect), i.registerOutput("output", Q.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._inputs[0].excludedConnectionPointTypes.push(Q.Matrix), i._inputs[0].excludedConnectionPointTypes.push(Q.Geometry), i._inputs[0].excludedConnectionPointTypes.push(Q.Texture), i._inputs[1].excludedConnectionPointTypes.push(Q.Matrix), i._inputs[1].excludedConnectionPointTypes.push(Q.Geometry), i._inputs[1].excludedConnectionPointTypes.push(Q.Texture), i._inputs[1].acceptedConnectionPointTypes.push(Q.Float), i._linkConnectionTypes(0, 1), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "MathBlock";
      }, Object.defineProperty(t.prototype, "left", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function() {
        var e, i = this.left, r = this.right;
        if (!i.isConnected || !r.isConnected)
          return this.output._storedFunction = null, void (this.output._storedValue = null);
        var o = i.type === Q.Float || i.type === Q.Int;
        switch (this.operation) {
          case Gn.Add:
            e = o ? function(a) {
              return i.getConnectedValue(a) + r.getConnectedValue(a);
            } : function(a) {
              return i.getConnectedValue(a).add(a.adapt(r, i.type));
            };
            break;
          case Gn.Subtract:
            e = o ? function(a) {
              return i.getConnectedValue(a) - r.getConnectedValue(a);
            } : function(a) {
              return i.getConnectedValue(a).subtract(a.adapt(r, i.type));
            };
            break;
          case Gn.Multiply:
            e = o ? function(a) {
              return i.getConnectedValue(a) * r.getConnectedValue(a);
            } : function(a) {
              return i.getConnectedValue(a).multiply(a.adapt(r, i.type));
            };
            break;
          case Gn.Divide:
            e = o ? function(a) {
              return i.getConnectedValue(a) / r.getConnectedValue(a);
            } : function(a) {
              return i.getConnectedValue(a).divide(a.adapt(r, i.type));
            };
            break;
          case Gn.Min:
            if (o)
              e = function(a) {
                return Math.min(i.getConnectedValue(a), r.getConnectedValue(a));
              };
            else
              switch (i.type) {
                case Q.Vector2:
                  e = function(a) {
                    return fe.Minimize(i.getConnectedValue(a), a.adapt(r, i.type));
                  };
                  break;
                case Q.Vector3:
                  e = function(a) {
                    return v.Minimize(i.getConnectedValue(a), a.adapt(r, i.type));
                  };
                  break;
                case Q.Vector4:
                  e = function(a) {
                    return lt.Minimize(i.getConnectedValue(a), a.adapt(r, i.type));
                  };
              }
            break;
          case Gn.Max:
            if (!o) {
              switch (i.type) {
                case Q.Vector2:
                  e = function(a) {
                    return fe.Maximize(i.getConnectedValue(a), a.adapt(r, i.type));
                  };
                  break;
                case Q.Vector3:
                  e = function(a) {
                    return v.Maximize(i.getConnectedValue(a), a.adapt(r, i.type));
                  };
                  break;
                case Q.Vector4:
                  e = function(a) {
                    return lt.Maximize(i.getConnectedValue(a), a.adapt(r, i.type));
                  };
              }
              break;
            }
            e = function(a) {
              return Math.max(i.getConnectedValue(a), r.getConnectedValue(a));
            };
        }
        this.output._storedFunction = function(a) {
          return i.type === Q.Int ? 0 | e(a) : e(a);
        };
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".operation = BABYLON.MathBlockOperations.").concat(Gn[this.operation], `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.operation = this.operation, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), this.operation = e.operation;
      }, x([qe("Operation", Ye.List, "ADVANCED", { notifiers: { rebuild: !0 }, options: [{ label: "Add", value: Gn.Add }, { label: "Subtract", value: Gn.Subtract }, { label: "Multiply", value: Gn.Multiply }, { label: "Divide", value: Gn.Divide }, { label: "Max", value: Gn.Max }, { label: "Min", value: Gn.Min }] })], t.prototype, "operation", void 0), t;
    }(At);
    j("BABYLON.MathBlock", n0);
    var Ji, r0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.registerInput("value", Q.AutoDetect), i.registerInput("fromMin", Q.Float, !0, 0), i.registerInput("fromMax", Q.Float, !0, 1), i.registerInput("toMin", Q.Float, !0, 0), i.registerInput("toMax", Q.Float, !0, 1), i.registerOutput("output", Q.BasedOnInput), i._inputs[0].excludedConnectionPointTypes.push(Q.Vector2), i._inputs[0].excludedConnectionPointTypes.push(Q.Vector3), i._inputs[0].excludedConnectionPointTypes.push(Q.Vector4), i._inputs[0].excludedConnectionPointTypes.push(Q.Matrix), i._inputs[0].excludedConnectionPointTypes.push(Q.Geometry), i._inputs[0].excludedConnectionPointTypes.push(Q.Texture), i._outputs[0]._typeConnectionSource = i._inputs[0], i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "MapRangeBlock";
      }, Object.defineProperty(t.prototype, "value", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "fromMin", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "fromMax", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "toMin", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "toMax", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function() {
        var e = this;
        if (!this.value.isConnected)
          return this.output._storedFunction = null, void (this.output._storedValue = null);
        this.output._storedFunction = function(i) {
          var r = e.value.getConnectedValue(i), o = e.fromMin.getConnectedValue(i), a = e.fromMax.getConnectedValue(i), s = e.toMin.getConnectedValue(i), l = (r - o) / (a - o) * (e.toMax.getConnectedValue(i) - s) + s;
          return e.output.type === Q.Int ? Math.floor(l) : l;
        };
      }, t;
    }(At);
    j("BABYLON.MapRangeBlock", r0), function(n) {
      n[n.Equal = 0] = "Equal", n[n.NotEqual = 1] = "NotEqual", n[n.LessThan = 2] = "LessThan", n[n.GreaterThan = 3] = "GreaterThan", n[n.LessOrEqual = 4] = "LessOrEqual", n[n.GreaterOrEqual = 5] = "GreaterOrEqual", n[n.Xor = 6] = "Xor", n[n.Or = 7] = "Or", n[n.And = 8] = "And";
    }(Ji || (Ji = {}));
    var ao, o0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.test = Ji.Equal, i.registerInput("left", Q.Float), i.registerInput("right", Q.Float, !0, 0), i.registerInput("ifTrue", Q.AutoDetect, !0, 1), i.registerInput("ifFalse", Q.AutoDetect, !0, 0), i.registerOutput("output", Q.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[2], i._outputs[0]._defaultConnectionPointType = Q.Float, i._inputs[0].acceptedConnectionPointTypes.push(Q.Int), i._inputs[1].acceptedConnectionPointTypes.push(Q.Int), i._linkConnectionTypes(2, 3), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ConditionBlock";
      }, Object.defineProperty(t.prototype, "left", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "ifTrue", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "ifFalse", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function() {
        var e = this;
        if (!this.left.isConnected)
          return this.output._storedFunction = null, void (this.output._storedValue = null);
        this.output._storedFunction = function(i) {
          return function(r) {
            var o = e.left.getConnectedValue(r), a = e.right.getConnectedValue(r), s = !1;
            switch (e.test) {
              case Ji.Equal:
                s = ue.WithinEpsilon(o, a, Ge);
                break;
              case Ji.NotEqual:
                s = o !== a;
                break;
              case Ji.LessThan:
                s = o < a;
                break;
              case Ji.GreaterThan:
                s = o > a;
                break;
              case Ji.LessOrEqual:
                s = o <= a;
                break;
              case Ji.GreaterOrEqual:
                s = o >= a;
                break;
              case Ji.Xor:
                s = !!o && !a || !o && !!a;
                break;
              case Ji.Or:
                s = !!o || !!a;
                break;
              case Ji.And:
                s = !!o && !!a;
            }
            return s;
          }(i) ? e.ifTrue.getConnectedValue(i) : e.ifFalse.getConnectedValue(i);
        };
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".test = BABYLON.ConditionBlockTests.").concat(Ji[this.test], `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.test = this.test, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), this.test = e.test;
      }, x([qe("Test", Ye.List, "ADVANCED", { notifiers: { rebuild: !0 }, options: [{ label: "Equal", value: Ji.Equal }, { label: "NotEqual", value: Ji.NotEqual }, { label: "LessThan", value: Ji.LessThan }, { label: "GreaterThan", value: Ji.GreaterThan }, { label: "LessOrEqual", value: Ji.LessOrEqual }, { label: "GreaterOrEqual", value: Ji.GreaterOrEqual }, { label: "Xor", value: Ji.Xor }, { label: "Or", value: Ji.Or }, { label: "And", value: Ji.And }] })], t.prototype, "test", void 0), t;
    }(At);
    j("BABYLON.ConditionBlock", o0), function(n) {
      n[n.None = 0] = "None", n[n.LoopID = 1] = "LoopID", n[n.InstanceID = 2] = "InstanceID";
    }(ao || (ao = {}));
    var a0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i._currentLockId = -1, i.lockMode = ao.None, i.registerInput("min", Q.AutoDetect), i.registerInput("max", Q.AutoDetect), i.registerOutput("output", Q.BasedOnInput), i._inputs[0].excludedConnectionPointTypes.push(Q.Matrix), i._inputs[0].excludedConnectionPointTypes.push(Q.Geometry), i._inputs[0].excludedConnectionPointTypes.push(Q.Texture), i._inputs[1].excludedConnectionPointTypes.push(Q.Matrix), i._inputs[1].excludedConnectionPointTypes.push(Q.Geometry), i._inputs[1].excludedConnectionPointTypes.push(Q.Texture), i._outputs[0]._typeConnectionSource = i._inputs[0], i._linkConnectionTypes(0, 1), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "RandomBlock";
      }, Object.defineProperty(t.prototype, "min", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "max", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function() {
        if (!this.min.isConnected) {
          var e = new Di("Min");
          e.value = 0, e.output.connectTo(this.min);
        }
        if (!this.max.isConnected) {
          var i = new Di("Max");
          i.value = 1, i.output.connectTo(this.max);
        }
      }, t.prototype._buildBlock = function() {
        var e = this, i = null;
        switch (this._currentLockId = -1, this.min.type) {
          case Q.Int:
          case Q.Float:
            i = function(r) {
              var o = e.min.getConnectedValue(r) || 0, a = e.max.getConnectedValue(r) || 0;
              return o + Math.random() * (a - o);
            };
            break;
          case Q.Vector2:
            i = function(r) {
              var o = e.min.getConnectedValue(r) || fe.Zero(), a = e.max.getConnectedValue(r) || fe.Zero();
              return new fe(o.x + Math.random() * (a.x - o.x), o.y + Math.random() * (a.y - o.y));
            };
            break;
          case Q.Vector3:
            i = function(r) {
              var o = e.min.getConnectedValue(r) || v.Zero(), a = e.max.getConnectedValue(r) || v.Zero();
              return new v(o.x + Math.random() * (a.x - o.x), o.y + Math.random() * (a.y - o.y), o.z + Math.random() * (a.z - o.z));
            };
            break;
          case Q.Vector4:
            i = function(r) {
              var o = e.min.getConnectedValue(r) || lt.Zero(), a = e.max.getConnectedValue(r) || lt.Zero();
              return new lt(o.x + Math.random() * (a.x - o.x), o.y + Math.random() * (a.y - o.y), o.z + Math.random() * (a.z - o.z), o.w + Math.random() * (a.w - o.w));
            };
        }
        this.lockMode !== ao.None && i ? this.output._storedFunction = function(r) {
          var o = 0;
          switch (e.lockMode) {
            case ao.InstanceID:
              o = r.getContextualValue(zt.InstanceID, !0) || 0;
              break;
            case ao.LoopID:
              o = r.getContextualValue(zt.LoopID, !0) || 0;
          }
          return e._currentLockId !== o && (e._currentLockId = o, e.output._storedValue = i(r)), e.output._storedValue;
        } : this.output._storedFunction = i;
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".lockMode = BABYLON.RandomBlockLocks.").concat(ao[this.lockMode], `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.lockMode = this.lockMode, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), this.lockMode = e.lockMode;
      }, x([qe("LockMode", Ye.List, "ADVANCED", { notifiers: { rebuild: !0 }, options: [{ label: "None", value: ao.None }, { label: "LoopID", value: ao.LoopID }, { label: "InstanceID", value: ao.InstanceID }] })], t.prototype, "lockMode", void 0), t;
    }(At);
    j("BABYLON.RandomBlock", a0);
    var s0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.registerInput("offset", Q.Vector3, !0, v.Zero()), i.registerInput("scale", Q.Float, !0, 1), i.registerInput("octaves", Q.Float, !0, 2, 0, 16), i.registerInput("roughness", Q.Float, !0, 0.5, 0, 1), i.registerOutput("output", Q.Float), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "NoiseBlock";
      }, Object.defineProperty(t.prototype, "offset", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "scale", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "octaves", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "roughness", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._negateIf = function(e, i) {
        return i !== 0 ? -e : e;
      }, t.prototype._noiseGrad = function(e, i, r, o) {
        var a = 15 & e, s = a < 8 ? i : r, l = a < 4 ? r : a === 12 || a == 14 ? i : o;
        return this._negateIf(s, a & s) + this._negateIf(l, 2 & a);
      }, t.prototype._fade = function(e) {
        return e * e * e * (e * (6 * e - 15) + 10);
      }, t.prototype._hashBitRotate = function(e, i) {
        return e << i | e >> 32 - i;
      }, t.prototype._hash = function(e, i, r) {
        var o, a, s;
        return o = a = s = 3735928584, s += r, o += e, s ^= a += i, o ^= s -= this._hashBitRotate(a, 14), a ^= o -= this._hashBitRotate(s, 11), s ^= a -= this._hashBitRotate(o, 25), o ^= s -= this._hashBitRotate(a, 16), a ^= o -= this._hashBitRotate(s, 4), (s ^= a -= this._hashBitRotate(o, 14)) - this._hashBitRotate(a, 24);
      }, t.prototype._mix = function(e, i, r, o, a, s, l, c, u, h, d) {
        var p = 1 - u, f = 1 - h;
        return (1 - d) * (f * (e * p + i * u) + h * (r * p + o * u)) + d * (f * (a * p + s * u) + h * (l * p + c * u));
      }, t.prototype._perlinNoise = function(e) {
        var i = (0 | e.x) - (e.x < 0 ? 1 : 0), r = (0 | e.y) - (e.y < 0 ? 1 : 0), o = (0 | e.z) - (e.z < 0 ? 1 : 0), a = e.x - i, s = e.y - r, l = e.z - o, c = this._fade(a), u = this._fade(s), h = this._fade(l);
        return this._mix(this._noiseGrad(this._hash(i, r, o), a, s, l), this._noiseGrad(this._hash(i + 1, r, o), a - 1, s, l), this._noiseGrad(this._hash(i, r + 1, o), a, s - 1, l), this._noiseGrad(this._hash(i + 1, r + 1, o), a - 1, s - 1, l), this._noiseGrad(this._hash(i, r, o + 1), a, s, l - 1), this._noiseGrad(this._hash(i + 1, r, o + 1), a - 1, s, l - 1), this._noiseGrad(this._hash(i, r + 1, o + 1), a, s - 1, l - 1), this._noiseGrad(this._hash(i + 1, r + 1, o + 1), a - 1, s - 1, l - 1), c, u, h);
      }, t.prototype._perlinSigned = function(e) {
        return 0.982 * this._perlinNoise(e);
      }, t.prototype._perlin = function(e) {
        return this._perlinSigned(e) / 2 + 0.5;
      }, t.prototype.noise = function(e, i, r, o, a) {
        for (var s = new v(r.x * a + o.x, r.y * a + o.y, r.z * a + o.z), l = 1, c = 1, u = 0, h = 0, d = 0 | (e = ue.Clamp(e, 0, 15)), p = 0; p <= d; p++)
          h += this._perlin(s.scale(l)) * c, u += c, c *= ue.Clamp(i, 0, 1), l *= 2;
        var f = e - Math.floor(e);
        if (f == 0)
          return h / u;
        var m = h + this._perlin(s.scale(l)) * c;
        return (1 - f) * (h /= u) + f * (m / (u + c));
      }, t.prototype._buildBlock = function() {
        var e = this;
        this.output._storedFunction = function(i) {
          var r = i.getContextualValue(zt.Positions), o = e.octaves.getConnectedValue(i), a = e.roughness.getConnectedValue(i), s = e.offset.getConnectedValue(i), l = e.scale.getConnectedValue(i);
          return e.noise(o, a, r, s, l);
        };
      }, t;
    }(At);
    j("BABYLON.NoiseBlock", s0);
    var l0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.evaluateContext = !1, i.registerInput("geometry0", Q.Geometry), i.registerInput("geometry1", Q.Geometry, !0), i.registerInput("geometry2", Q.Geometry, !0), i.registerInput("geometry3", Q.Geometry, !0), i.registerInput("geometry4", Q.Geometry, !0), i.registerOutput("output", Q.Geometry), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "MergeGeometryBlock";
      }, Object.defineProperty(t.prototype, "geometry0", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry1", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry2", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry3", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry4", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        var i = this, r = function(o) {
          var a, s = i.geometry0.getConnectedValue(o), l = [];
          return i.geometry1.isConnected && (a = i.geometry1.getConnectedValue(o)) && l.push(a), i.geometry2.isConnected && (a = i.geometry2.getConnectedValue(o)) && l.push(a), i.geometry3.isConnected && (a = i.geometry3.getConnectedValue(o)) && l.push(a), i.geometry4.isConnected && (a = i.geometry4.getConnectedValue(o)) && l.push(a), l.length && s && (s = s.merge(l, !0, !1, !0, !0)), s;
        };
        this.evaluateContext ? this.output._storedFunction = r : (this.output._storedFunction = null, this.output._storedValue = r(e));
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".evaluateContext = ").concat(this.evaluateContext ? "true" : "false", `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.evaluateContext = this.evaluateContext, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), this.evaluateContext = e.evaluateContext;
      }, x([qe("Evaluate context", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t;
    }(At);
    j("BABYLON.MergeGeometryBlock", l0);
    var c0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.evaluateContext = !0, i.registerInput("geometry0", Q.Geometry, !0), i.registerInput("geometry1", Q.Geometry, !0), i.registerInput("geometry2", Q.Geometry, !0), i.registerInput("geometry3", Q.Geometry, !0), i.registerInput("geometry4", Q.Geometry, !0), i.registerInput("geometry5", Q.Geometry, !0), i.registerInput("geometry6", Q.Geometry, !0), i.registerInput("geometry7", Q.Geometry, !0), i.registerInput("geometry8", Q.Geometry, !0), i.registerInput("geometry9", Q.Geometry, !0), i.registerOutput("output", Q.Geometry), i._outputs[0]._typeConnectionSource = i._inputs[0], i._linkConnectionTypes(0, 1), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "GeometryCollectionBlock";
      }, Object.defineProperty(t.prototype, "geometry0", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry1", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry2", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry3", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry4", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry5", { get: function() {
        return this._inputs[5];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry6", { get: function() {
        return this._inputs[6];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry7", { get: function() {
        return this._inputs[7];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry8", { get: function() {
        return this._inputs[8];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry9", { get: function() {
        return this._inputs[9];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._storeGeometry = function(e, i, r, o) {
        if (e.isConnected) {
          var a = e.getConnectedValue(i);
          if (!a)
            return;
          a.metadata = a.metadata || {}, a.metadata.collectionId = r, o.push(a);
        }
      }, t.prototype._buildBlock = function(e) {
        var i = this, r = function(o) {
          var a = [];
          return i._storeGeometry(i.geometry0, o, 0, a), i._storeGeometry(i.geometry1, o, 1, a), i._storeGeometry(i.geometry2, o, 2, a), i._storeGeometry(i.geometry3, o, 3, a), i._storeGeometry(i.geometry4, o, 4, a), i._storeGeometry(i.geometry5, o, 5, a), i._storeGeometry(i.geometry6, o, 6, a), i._storeGeometry(i.geometry7, o, 7, a), i._storeGeometry(i.geometry8, o, 8, a), i._storeGeometry(i.geometry9, o, 9, a), a.length ? a[Math.round(Math.random() * (a.length - 1))] : null;
        };
        this.evaluateContext ? this.output._storedFunction = r : (this.output._storedFunction = null, this.output._storedValue = r(e));
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".evaluateContext = ").concat(this.evaluateContext ? "true" : "false", `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.evaluateContext = this.evaluateContext, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), this.evaluateContext = e.evaluateContext;
      }, x([qe("Evaluate context", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t;
    }(At);
    j("BABYLON.GeometryCollectionBlock", c0);
    var u0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.registerInput("input", Q.AutoDetect), i.registerOutput("output", Q.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i;
      }
      return D(t, n), Object.defineProperty(t.prototype, "buildExecutionTime", { get: function() {
        return 0;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "GeometryElbowBlock";
      }, Object.defineProperty(t.prototype, "input", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this._outputs[0], r = this._inputs[0];
        i._storedFunction = function(o) {
          return r.getConnectedValue(o);
        };
      }, t;
    }(At);
    j("BABYLON.GeometryElbowBlock", u0);
    var h0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.registerInput("geometry", Q.Geometry), i.registerOutput("output", Q.Geometry), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ComputeNormalsBlock";
      }, Object.defineProperty(t.prototype, "geometry", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function() {
        var e = this;
        this.output._storedFunction = function(i) {
          if (!e.geometry.isConnected)
            return null;
          var r = e.geometry.getConnectedValue(i);
          return r.normals || (r.normals = []), Oe.ComputeNormals(r.positions, r.indices, r.normals), r;
        };
      }, t;
    }(At);
    j("BABYLON.ComputeNormalsBlock", h0);
    var d0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.registerInput("xyzw ", Q.Vector4, !0), i.registerInput("xyz ", Q.Vector3, !0), i.registerInput("xy ", Q.Vector2, !0), i.registerInput("zw ", Q.Vector2, !0), i.registerInput("x ", Q.Float, !0), i.registerInput("y ", Q.Float, !0), i.registerInput("z ", Q.Float, !0), i.registerInput("w ", Q.Float, !0), i.registerOutput("xyzw", Q.Vector4), i.registerOutput("xyz", Q.Vector3), i.registerOutput("xy", Q.Vector2), i.registerOutput("zw", Q.Vector2), i.registerOutput("x", Q.Float), i.registerOutput("y", Q.Float), i.registerOutput("z", Q.Float), i.registerOutput("w", Q.Float), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "VectorConverterBlock";
      }, Object.defineProperty(t.prototype, "xyzwIn", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyzIn", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyIn", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "zwIn", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xIn", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "yIn", { get: function() {
        return this._inputs[5];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "zIn", { get: function() {
        return this._inputs[6];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wIn", { get: function() {
        return this._inputs[7];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyzwOut", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyzOut", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyOut", { get: function() {
        return this._outputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "zwOut", { get: function() {
        return this._outputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xOut", { get: function() {
        return this._outputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "yOut", { get: function() {
        return this._outputs[5];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "zOut", { get: function() {
        return this._outputs[6];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wOut", { get: function() {
        return this._outputs[7];
      }, enumerable: !1, configurable: !0 }), t.prototype._inputRename = function(e) {
        return e === "xyzw " ? "xyzwIn" : e === "xyz " ? "xyzIn" : e === "xy " ? "xyIn" : e === "zw " ? "zwIn" : e === "x " ? "xIn" : e === "y " ? "yIn" : e === "z " ? "zIn" : e === "w " ? "wIn" : e;
      }, t.prototype._outputRename = function(e) {
        switch (e) {
          case "x":
            return "xOut";
          case "y":
            return "yOut";
          case "z":
            return "zOut";
          case "w":
            return "wOut";
          case "xy":
            return "xyOut";
          case "zw":
            return "zwOut";
          case "xyz":
            return "xyzOut";
          case "xyzw":
            return "xyzwOut";
          default:
            return e;
        }
      }, t.prototype._buildBlock = function(e) {
        n.prototype._buildBlock.call(this, e);
        var i = this.xIn, r = this.yIn, o = this.zIn, a = this.wIn, s = this.xyIn, l = this.zwIn, c = this.xyzIn, u = this.xyzwIn, h = this.xyzwOut, d = this.xyzOut, p = this.xyOut, f = this.zwOut, m = this.xOut, g = this.yOut, y = this.zOut, b = this.wOut, T = function(S) {
          if (u.isConnected)
            return u.getConnectedValue(S);
          var E, A = 0, R = 0, C = 0, L = 0;
          return i.isConnected && (A = i.getConnectedValue(S)), r.isConnected && (R = r.getConnectedValue(S)), o.isConnected && (C = o.getConnectedValue(S)), a.isConnected && (L = a.getConnectedValue(S)), s.isConnected && (E = s.getConnectedValue(S)) && (A = E.x, R = E.y), l.isConnected && (E = l.getConnectedValue(S)) && (C = E.x, L = E.y), c.isConnected && (E = c.getConnectedValue(S)) && (A = E.x, R = E.y, C = E.z), new lt(A, R, C, L);
        };
        h._storedFunction = function(S) {
          return T(S);
        }, d._storedFunction = function(S) {
          var E = T(S);
          return new v(E.x, E.y, E.z);
        }, p._storedFunction = function(S) {
          var E = T(S);
          return new fe(E.x, E.y);
        }, f._storedFunction = function(S) {
          var E = T(S);
          return new fe(E.z, E.w);
        }, m._storedFunction = function(S) {
          return T(S).x;
        }, g._storedFunction = function(S) {
          return T(S).y;
        }, y._storedFunction = function(S) {
          return T(S).z;
        }, b._storedFunction = function(S) {
          return T(S).w;
        };
      }, t;
    }(At);
    j("BABYLON.VectorConverterBlock", d0);
    var p0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.registerInput("input", Q.AutoDetect), i.registerOutput("output", Q.BasedOnInput), i._inputs[0].excludedConnectionPointTypes.push(Q.Float), i._inputs[0].excludedConnectionPointTypes.push(Q.Matrix), i._inputs[0].excludedConnectionPointTypes.push(Q.Geometry), i._inputs[0].excludedConnectionPointTypes.push(Q.Texture), i._outputs[0]._typeConnectionSource = i._inputs[0], i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "NormalizeVectorBlock";
      }, Object.defineProperty(t.prototype, "input", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        var i = this;
        n.prototype._buildBlock.call(this, e), this.output._storedFunction = null, this.input.isConnected ? this.output._storedFunction = function(r) {
          return i.input.getConnectedValue(r).normalize();
        } : this.output._storedValue = null;
      }, t;
    }(At);
    j("BABYLON.NormalizeVectorBlock", p0);
    var Wt, f0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.evaluateContext = !0, i.registerInput("geometry", Q.Geometry), i.registerInput("id", Q.Int, !0, 0), i.registerOutput("output", Q.Geometry), i.id.acceptedConnectionPointTypes.push(Q.Float), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "SetMaterialIDBlock";
      }, Object.defineProperty(t.prototype, "geometry", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "id", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        var i = this;
        if (!this.geometry.isConnected)
          return this.output._storedFunction = null, void (this.output._storedValue = null);
        var r = function(o) {
          var a = i.geometry.getConnectedValue(o);
          if (!a || !a.indices || !a.positions)
            return a;
          var s = new lc();
          return s.materialIndex = 0 | i.id.getConnectedValue(o), s.indexStart = 0, s.indexCount = a.indices.length, s.verticesStart = 0, s.verticesCount = a.positions.length / 3, a.materialInfos = [s], a;
        };
        this.evaluateContext ? this.output._storedFunction = r : (this.output._storedFunction = null, this.output._storedValue = r(e));
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".evaluateContext = ").concat(this.evaluateContext ? "true" : "false", `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.evaluateContext = this.evaluateContext, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), e.evaluateContext !== void 0 && (this.evaluateContext = e.evaluateContext);
      }, x([qe("Evaluate context", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t;
    }(At);
    j("BABYLON.SetMaterialIDBlock", f0), function(n) {
      n[n.Cos = 0] = "Cos", n[n.Sin = 1] = "Sin", n[n.Abs = 2] = "Abs", n[n.Exp = 3] = "Exp", n[n.Round = 4] = "Round", n[n.Floor = 5] = "Floor", n[n.Ceiling = 6] = "Ceiling", n[n.Sqrt = 7] = "Sqrt", n[n.Log = 8] = "Log", n[n.Tan = 9] = "Tan", n[n.ArcTan = 10] = "ArcTan", n[n.ArcCos = 11] = "ArcCos", n[n.ArcSin = 12] = "ArcSin", n[n.Sign = 13] = "Sign", n[n.Negate = 14] = "Negate", n[n.OneMinus = 15] = "OneMinus", n[n.Reciprocal = 16] = "Reciprocal", n[n.ToDegrees = 17] = "ToDegrees", n[n.ToRadians = 18] = "ToRadians";
    }(Wt || (Wt = {}));
    var _0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.operation = Wt.Cos, i.registerInput("input", Q.AutoDetect), i.registerOutput("output", Q.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._inputs[0].excludedConnectionPointTypes.push(Q.Matrix), i._inputs[0].excludedConnectionPointTypes.push(Q.Geometry), i._inputs[0].excludedConnectionPointTypes.push(Q.Texture), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "GeometryTrigonometryBlock";
      }, Object.defineProperty(t.prototype, "input", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        var i = this;
        n.prototype._buildBlock.call(this, e);
        var r = null;
        switch (this.operation) {
          case Wt.Cos:
            r = function(o) {
              return Math.cos(o);
            };
            break;
          case Wt.Sin:
            r = function(o) {
              return Math.sin(o);
            };
            break;
          case Wt.Abs:
            r = function(o) {
              return Math.abs(o);
            };
            break;
          case Wt.Exp:
            r = function(o) {
              return Math.exp(o);
            };
            break;
          case Wt.Round:
            r = function(o) {
              return Math.round(o);
            };
            break;
          case Wt.Floor:
            r = function(o) {
              return Math.floor(o);
            };
            break;
          case Wt.Ceiling:
            r = function(o) {
              return Math.ceil(o);
            };
            break;
          case Wt.Sqrt:
            r = function(o) {
              return Math.sqrt(o);
            };
            break;
          case Wt.Log:
            r = function(o) {
              return Math.log(o);
            };
            break;
          case Wt.Tan:
            r = function(o) {
              return Math.tan(o);
            };
            break;
          case Wt.ArcTan:
            r = function(o) {
              return Math.atan(o);
            };
            break;
          case Wt.ArcCos:
            r = function(o) {
              return Math.acos(o);
            };
            break;
          case Wt.ArcSin:
            r = function(o) {
              return Math.asin(o);
            };
            break;
          case Wt.Sign:
            r = function(o) {
              return Math.sign(o);
            };
            break;
          case Wt.Negate:
            r = function(o) {
              return -o;
            };
            break;
          case Wt.OneMinus:
            r = function(o) {
              return 1 - o;
            };
            break;
          case Wt.Reciprocal:
            r = function(o) {
              return 1 / o;
            };
            break;
          case Wt.ToRadians:
            r = function(o) {
              return o * Math.PI / 180;
            };
            break;
          case Wt.ToDegrees:
            r = function(o) {
              return 180 * o / Math.PI;
            };
        }
        if (!r)
          return this.input._storedFunction = null, void (this.input._storedValue = null);
        switch (this.input.type) {
          case Q.Int:
          case Q.Float:
            this.output._storedFunction = function(o) {
              var a = i.input.getConnectedValue(o);
              return r(a);
            };
            break;
          case Q.Vector2:
            this.output._storedFunction = function(o) {
              var a = i.input.getConnectedValue(o);
              return new fe(r(a.x), r(a.y));
            };
            break;
          case Q.Vector3:
            this.output._storedFunction = function(o) {
              var a = i.input.getConnectedValue(o);
              return new v(r(a.x), r(a.y), r(a.z));
            };
            break;
          case Q.Vector4:
            this.output._storedFunction = function(o) {
              var a = i.input.getConnectedValue(o);
              return new lt(r(a.x), r(a.y), r(a.z), r(a.w));
            };
        }
        return this;
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.operation = this.operation, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), this.operation = e.operation;
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".operation = BABYLON.GeometryTrigonometryBlockOperations.").concat(Wt[this.operation], `;
`);
      }, x([qe("Operation", Ye.List, "ADVANCED", { notifiers: { rebuild: !0 }, options: [{ label: "Cos", value: Wt.Cos }, { label: "Sin", value: Wt.Sin }, { label: "Abs", value: Wt.Abs }, { label: "Exp", value: Wt.Exp }, { label: "Round", value: Wt.Round }, { label: "Floor", value: Wt.Floor }, { label: "Ceiling", value: Wt.Ceiling }, { label: "Sqrt", value: Wt.Sqrt }, { label: "Log", value: Wt.Log }, { label: "Tan", value: Wt.Tan }, { label: "ArcTan", value: Wt.ArcTan }, { label: "ArcCos", value: Wt.ArcCos }, { label: "ArcSin", value: Wt.ArcSin }, { label: "Sign", value: Wt.Sign }, { label: "Negate", value: Wt.Negate }, { label: "OneMinus", value: Wt.OneMinus }, { label: "Reciprocal", value: Wt.Reciprocal }, { label: "ToDegrees", value: Wt.ToDegrees }, { label: "ToRadians", value: Wt.ToRadians }] })], t.prototype, "operation", void 0), t;
    }(At);
    j("BABYLON.GeometryTrigonometryBlock", _0);
    var m0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i._rotationMatrix = new B(), i._scalingMatrix = new B(), i._translationMatrix = new B(), i._scalingRotationMatrix = new B(), i._transformMatrix = new B(), i.evaluateContext = !0, i.registerInput("value", Q.AutoDetect), i.registerInput("matrix", Q.Matrix, !0), i.registerInput("translation", Q.Vector3, !0, v.Zero()), i.registerInput("rotation", Q.Vector3, !0, v.Zero()), i.registerInput("scaling", Q.Vector3, !0, v.One()), i.registerOutput("output", Q.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._inputs[0].excludedConnectionPointTypes.push(Q.Float), i._inputs[0].excludedConnectionPointTypes.push(Q.Matrix), i._inputs[0].excludedConnectionPointTypes.push(Q.Texture), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "GeometryTransformBlock";
      }, Object.defineProperty(t.prototype, "value", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "matrix", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "translation", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rotation", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "scaling", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        var i = this;
        if (!this.value.isConnected)
          return this.output._storedFunction = null, void (this.output._storedValue = null);
        var r = function(o) {
          var a, s = i.value.getConnectedValue(o);
          if (!s)
            return null;
          if (i.matrix.isConnected)
            a = i.matrix.getConnectedValue(o);
          else {
            var l = i.scaling.getConnectedValue(o), c = i.rotation.getConnectedValue(o), u = i.translation.getConnectedValue(o);
            B.ScalingToRef(l.x, l.y, l.z, i._scalingMatrix), B.RotationYawPitchRollToRef(c.y, c.x, c.z, i._rotationMatrix), B.TranslationToRef(u.x, u.y, u.z, i._translationMatrix), i._scalingMatrix.multiplyToRef(i._rotationMatrix, i._scalingRotationMatrix), i._scalingRotationMatrix.multiplyToRef(i._translationMatrix, i._transformMatrix), a = i._transformMatrix;
          }
          switch (i.value.type) {
            case Q.Geometry:
              var h = s.clone();
              return h.transform(a), h;
            case Q.Vector2:
              return fe.Transform(s, a);
            case Q.Vector3:
              return v.TransformCoordinates(s, a);
            case Q.Vector4:
              return lt.TransformCoordinates(s, a);
          }
          return null;
        };
        this.evaluateContext ? this.output._storedFunction = r : (this.output._storedFunction = null, this.output._storedValue = r(e));
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".evaluateContext = ").concat(this.evaluateContext ? "true" : "false", `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.evaluateContext = this.evaluateContext, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), e.evaluateContext !== void 0 && (this.evaluateContext = e.evaluateContext);
      }, x([qe("Evaluate context", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t;
    }(At);
    j("BABYLON.GeometryTransformBlock", m0);
    var g0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.registerInput("angle", Q.Float, !1, 0), i.registerOutput("matrix", Q.Matrix), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "RotationXBlock";
      }, Object.defineProperty(t.prototype, "angle", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "matrix", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function() {
        if (!this.angle.isConnected) {
          var e = new Di("Angle");
          e.value = 0, e.output.connectTo(this.angle);
        }
      }, t.prototype._buildBlock = function(e) {
        var i = this;
        n.prototype._buildBlock.call(this, e), this.matrix._storedFunction = function(r) {
          return B.RotationX(i.angle.getConnectedValue(r));
        };
      }, t;
    }(At);
    j("BABYLON.RotationXBlock", g0);
    var v0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.registerInput("angle", Q.Float, !1, 0), i.registerOutput("matrix", Q.Matrix), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "RotationYBlock";
      }, Object.defineProperty(t.prototype, "angle", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "matrix", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function() {
        if (!this.angle.isConnected) {
          var e = new Di("Angle");
          e.value = 0, e.output.connectTo(this.angle);
        }
      }, t.prototype._buildBlock = function(e) {
        var i = this;
        n.prototype._buildBlock.call(this, e), this.matrix._storedFunction = function(r) {
          return B.RotationY(i.angle.getConnectedValue(r));
        };
      }, t;
    }(At);
    j("BABYLON.RotationYBlock", v0);
    var y0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.registerInput("angle", Q.Float, !1, 0), i.registerOutput("matrix", Q.Matrix), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "RotationZBlock";
      }, Object.defineProperty(t.prototype, "angle", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "matrix", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function() {
        if (!this.angle.isConnected) {
          var e = new Di("Angle");
          e.value = 0, e.output.connectTo(this.angle);
        }
      }, t.prototype._buildBlock = function(e) {
        var i = this;
        n.prototype._buildBlock.call(this, e), this.matrix._storedFunction = function(r) {
          return B.RotationZ(i.angle.getConnectedValue(r));
        };
      }, t;
    }(At);
    j("BABYLON.RotationZBlock", y0);
    var b0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.registerInput("scale", Q.Vector3, !1, v.One()), i.registerOutput("matrix", Q.Matrix), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ScalingBlock";
      }, Object.defineProperty(t.prototype, "scale", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "matrix", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function() {
        if (!this.scale.isConnected) {
          var e = new Di("Scale");
          e.value = new v(1, 1, 1), e.output.connectTo(this.scale);
        }
      }, t.prototype._buildBlock = function(e) {
        var i = this;
        n.prototype._buildBlock.call(this, e), this.matrix._storedFunction = function(r) {
          var o = i.scale.getConnectedValue(r);
          return B.Scaling(o.x, o.y, o.z);
        };
      }, t;
    }(At);
    j("BABYLON.ScalingBlock", b0);
    var T0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.registerInput("source", Q.Vector3, !0, v.Up()), i.registerInput("target", Q.Vector3, !0, v.Left()), i.registerOutput("matrix", Q.Matrix), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "AlignBlock";
      }, Object.defineProperty(t.prototype, "source", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "target", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "matrix", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        var i = this;
        n.prototype._buildBlock.call(this, e), this.matrix._storedFunction = function(r) {
          var o = i.source.getConnectedValue(r).clone(), a = i.target.getConnectedValue(r).clone(), s = new B();
          return o.normalize(), a.normalize(), B.RotationAlignToRef(o, a, s, !0), s;
        };
      }, t;
    }(At);
    j("BABYLON.AlignBlock", T0);
    var E0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.registerInput("translation", Q.Vector3, !1, v.Zero()), i.registerOutput("matrix", Q.Matrix), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "TranslationBlock";
      }, Object.defineProperty(t.prototype, "translation", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "matrix", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function() {
        if (!this.translation.isConnected) {
          var e = new Di("Translation");
          e.value = new v(0, 0, 0), e.output.connectTo(this.translation);
        }
      }, t.prototype._buildBlock = function(e) {
        var i = this;
        n.prototype._buildBlock.call(this, e), this.matrix._storedFunction = function(r) {
          var o = i.translation.getConnectedValue(r);
          return B.Translation(o.x, o.y, o.z);
        };
      }, t;
    }(At);
    j("BABYLON.TranslationBlock", E0);
    var S0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i._indexTranslation = null, i.evaluateContext = !0, i.removeDuplicatedPositions = !0, i.registerInput("geometry", Q.Geometry), i.registerInput("instance", Q.Geometry, !0), i.registerInput("density", Q.Float, !0, 1, 0, 1), i.registerInput("matrix", Q.Matrix, !0), i.registerInput("rotation", Q.Vector3, !0, v.Zero()), i.registerInput("scaling", Q.Vector3, !0, v.One()), i.scaling.acceptedConnectionPointTypes.push(Q.Float), i.registerOutput("output", Q.Geometry), i;
      }
      return D(t, n), t.prototype.getInstanceIndex = function() {
        return this._currentLoopIndex;
      }, t.prototype.getExecutionIndex = function() {
        return this._indexTranslation ? this._indexTranslation[this._currentIndex] : this._currentIndex;
      }, t.prototype.getExecutionLoopIndex = function() {
        return this._currentLoopIndex;
      }, t.prototype.getExecutionFaceIndex = function() {
        return 0;
      }, t.prototype.getClassName = function() {
        return "InstantiateOnVerticesBlock";
      }, Object.defineProperty(t.prototype, "geometry", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "instance", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "density", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "matrix", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rotation", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "scaling", { get: function() {
        return this._inputs[5];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        var i = this, r = function(o) {
          if (o.pushExecutionContext(i), o.pushInstancingContext(i), i._vertexData = i.geometry.getConnectedValue(o), o.pushGeometryContext(i._vertexData), !i._vertexData || !i._vertexData.positions || !i.instance.isConnected)
            return o.restoreExecutionContext(), o.restoreInstancingContext(), o.restoreGeometryContext(), void (i.output._storedValue = null);
          var a = i._vertexData.positions.length / 3, s = [], l = new v(), c = [], u = i._vertexData.positions;
          if (i._currentLoopIndex = 0, i.removeDuplicatedPositions) {
            for (i._indexTranslation = {}, i._currentIndex = 0; i._currentIndex < a; i._currentIndex++) {
              for (var h = u[3 * i._currentIndex], d = u[3 * i._currentIndex + 1], p = u[3 * i._currentIndex + 2], f = !1, m = 0; m < c.length; m += 3)
                if (Math.abs(c[m] - h) < Ge && Math.abs(c[m + 1] - d) < Ge && Math.abs(c[m + 2] - p) < Ge) {
                  f = !0;
                  break;
                }
              f || (i._indexTranslation[c.length / 3] = i._currentIndex, c.push(h, d, p));
            }
            a = (u = c).length / 3;
          } else
            i._indexTranslation = null;
          for (i._currentIndex = 0; i._currentIndex < a; i._currentIndex++) {
            var g = i.instance.getConnectedValue(o);
            if (g && g.positions && g.positions.length !== 0) {
              var y = i.density.getConnectedValue(o);
              if (!(y < 1 && Math.random() > y)) {
                l.fromArray(u, 3 * i._currentIndex);
                var b = g.clone();
                if (i.matrix.isConnected) {
                  var T = i.matrix.getConnectedValue(o);
                  o._instantiateWithPositionAndMatrix(b, l, T, s);
                } else {
                  var S = o.adaptInput(i.scaling, Q.Vector3, v.OneReadOnly), E = i.rotation.getConnectedValue(o) || v.ZeroReadOnly;
                  o._instantiate(b, l, E, S, s);
                }
                i._currentLoopIndex++;
              }
            }
          }
          if (o.restoreGeometryContext(), o.restoreExecutionContext(), o.restoreInstancingContext(), !s.length)
            return null;
          if (s.length === 1)
            i._vertexData = s[0];
          else {
            var A = s.splice(0, 1)[0];
            i._vertexData = A.merge(s, !0, !1, !0, !0);
          }
          return i._vertexData;
        };
        this.evaluateContext ? this.output._storedFunction = r : (this.output._storedFunction = null, this.output._storedValue = r(e));
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".removeDuplicatedPositions = ").concat(this.removeDuplicatedPositions ? "true" : "false", `;
`) + "".concat(this._codeVariableName, ".evaluateContext = ").concat(this.evaluateContext ? "true" : "false", `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.removeDuplicatedPositions = this.removeDuplicatedPositions, e.evaluateContext = this.evaluateContext, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), this.removeDuplicatedPositions = e.removeDuplicatedPositions, e.evaluateContext !== void 0 && (this.evaluateContext = e.evaluateContext);
      }, x([qe("Evaluate context", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), x([qe("Remove duplicated positions", Ye.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "removeDuplicatedPositions", void 0), t;
    }(At);
    j("BABYLON.InstantiateOnVerticesBlock", S0);
    var x0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i._currentPosition = new v(), i._currentUV = new fe(), i._vertex0 = new v(), i._vertex1 = new v(), i._vertex2 = new v(), i._tempVector0 = new v(), i._tempVector1 = new v(), i._uv0 = new fe(), i._uv1 = new fe(), i._uv2 = new fe(), i.evaluateContext = !0, i.registerInput("geometry", Q.Geometry), i.registerInput("instance", Q.Geometry, !0), i.registerInput("count", Q.Int, !0, 256), i.registerInput("matrix", Q.Matrix, !0), i.registerInput("rotation", Q.Vector3, !0, v.Zero()), i.registerInput("scaling", Q.Vector3, !0, v.One()), i.scaling.acceptedConnectionPointTypes.push(Q.Float), i.registerOutput("output", Q.Geometry), i;
      }
      return D(t, n), t.prototype.getInstanceIndex = function() {
        return this._currentLoopIndex;
      }, t.prototype.getExecutionIndex = function() {
        return 0;
      }, t.prototype.getExecutionFaceIndex = function() {
        return this._currentFaceIndex;
      }, t.prototype.getExecutionLoopIndex = function() {
        return this._currentLoopIndex;
      }, t.prototype.getOverridePositionsContextualValue = function() {
        return this._currentPosition;
      }, t.prototype.getOverrideNormalsContextualValue = function() {
        return this._vertex1.subtractToRef(this._vertex0, this._tempVector0), this._vertex2.subtractToRef(this._vertex1, this._tempVector1), this._tempVector0.normalize(), this._tempVector1.normalize(), v.Cross(this._tempVector1, this._tempVector0);
      }, t.prototype.getOverrideUVs1ContextualValue = function() {
        return this._currentUV;
      }, t.prototype.getClassName = function() {
        return "InstantiateOnFacesBlock";
      }, Object.defineProperty(t.prototype, "geometry", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "instance", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "count", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "matrix", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rotation", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "scaling", { get: function() {
        return this._inputs[5];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        var i = this, r = function(o) {
          if (o.pushExecutionContext(i), o.pushInstancingContext(i), i._vertexData = i.geometry.getConnectedValue(o), o.pushGeometryContext(i._vertexData), !(i._vertexData && i._vertexData.positions && i._vertexData.indices && i.instance.isConnected))
            return o.restoreExecutionContext(), o.restoreInstancingContext(), o.restoreGeometryContext(), void (i.output._storedValue = null);
          var a = null, s = i.count.getConnectedValue(o), l = i._vertexData.indices.length / 3, c = s / l, u = 0, h = [], d = 0;
          for (i._currentLoopIndex = 0, i._currentFaceIndex = 0; i._currentFaceIndex < l; i._currentFaceIndex++) {
            var p = (0 | (u += c)) - d;
            if (!(p < 1)) {
              var f = i._vertexData.indices[3 * i._currentFaceIndex], m = i._vertexData.indices[3 * i._currentFaceIndex + 1], g = i._vertexData.indices[3 * i._currentFaceIndex + 2];
              i._vertex0.fromArray(i._vertexData.positions, 3 * f), i._vertex1.fromArray(i._vertexData.positions, 3 * m), i._vertex2.fromArray(i._vertexData.positions, 3 * g), i._vertexData.uvs && (i._uv0.fromArray(i._vertexData.uvs, 2 * f), i._uv1.fromArray(i._vertexData.uvs, 2 * m), i._uv2.fromArray(i._vertexData.uvs, 2 * g));
              for (var y = 0; y < p && !(d >= s); y++) {
                var b = Math.random(), T = Math.random();
                if (b > T) {
                  var S = b;
                  b = T, T = S;
                }
                var E = b, A = T - b, R = 1 - E - A;
                if (i._currentPosition.set(E * i._vertex0.x + A * i._vertex1.x + R * i._vertex2.x, E * i._vertex0.y + A * i._vertex1.y + R * i._vertex2.y, E * i._vertex0.z + A * i._vertex1.z + R * i._vertex2.z), i._vertexData.uvs && i._currentUV.set(E * i._uv0.x + A * i._uv1.x + R * i._uv2.x, E * i._uv0.y + A * i._uv1.y + R * i._uv2.y), (a = i.instance.getConnectedValue(o)) && a.positions && a.positions.length !== 0) {
                  var C = a.clone();
                  if (i.matrix.isConnected) {
                    var L = i.matrix.getConnectedValue(o);
                    o._instantiateWithPositionAndMatrix(C, i._currentPosition, L, h);
                  } else {
                    var I = o.adaptInput(i.scaling, Q.Vector3, v.OneReadOnly), O = i.rotation.getConnectedValue(o) || v.ZeroReadOnly;
                    o._instantiate(C, i._currentPosition, O, I, h);
                  }
                  d++, i._currentLoopIndex++;
                } else
                  u -= c;
              }
            }
          }
          if (h.length)
            if (h.length === 1)
              i._vertexData = h[0];
            else {
              var w = h.splice(0, 1)[0];
              i._vertexData = w.merge(h, !0, !1, !0, !0);
            }
          return o.restoreExecutionContext(), o.restoreInstancingContext(), o.restoreGeometryContext(), i._vertexData;
        };
        this.evaluateContext ? this.output._storedFunction = r : (this.output._storedFunction = null, this.output._storedValue = r(e));
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".evaluateContext = ").concat(this.evaluateContext ? "true" : "false", `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.evaluateContext = this.evaluateContext, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), e.evaluateContext !== void 0 && (this.evaluateContext = e.evaluateContext);
      }, x([qe("Evaluate context", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t;
    }(At);
    j("BABYLON.InstantiateOnFacesBlock", x0);
    var A0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i._currentPosition = new v(), i._vertex0 = new v(), i._vertex1 = new v(), i._vertex2 = new v(), i.evaluateContext = !0, i.registerInput("geometry", Q.Geometry), i.registerInput("instance", Q.Geometry, !0), i.registerInput("count", Q.Int, !0, 256), i.registerInput("matrix", Q.Matrix, !0), i.registerInput("rotation", Q.Vector3, !0, v.Zero()), i.registerInput("scaling", Q.Vector3, !0, v.One()), i.scaling.acceptedConnectionPointTypes.push(Q.Float), i.registerOutput("output", Q.Geometry), i;
      }
      return D(t, n), t.prototype.getInstanceIndex = function() {
        return this._currentLoopIndex;
      }, t.prototype.getExecutionIndex = function() {
        return 0;
      }, t.prototype.getExecutionFaceIndex = function() {
        return 0;
      }, t.prototype.getExecutionLoopIndex = function() {
        return this._currentLoopIndex;
      }, t.prototype.getOverridePositionsContextualValue = function() {
        return this._currentPosition;
      }, t.prototype.getClassName = function() {
        return "InstantiateOnVolumeBlock";
      }, Object.defineProperty(t.prototype, "geometry", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "instance", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "count", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "matrix", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rotation", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "scaling", { get: function() {
        return this._inputs[5];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        var i = this, r = function(o) {
          if (o.pushExecutionContext(i), o.pushInstancingContext(i), i._vertexData = i.geometry.getConnectedValue(o), o.pushGeometryContext(i._vertexData), !(i._vertexData && i._vertexData.positions && i._vertexData.indices && i.instance.isConnected))
            return o.restoreExecutionContext(), o.restoreInstancingContext(), o.restoreGeometryContext(), void (i.output._storedValue = null);
          var a = null, s = i.count.getConnectedValue(o), l = [], c = hl(i._vertexData.positions, 0, i._vertexData.positions.length / 3), u = c.minimum, h = c.maximum, d = new v(1, 0, 0), p = i._vertexData.indices.length / 3;
          i._currentLoopIndex = 0;
          for (var f = 0; f < s; f++) {
            i._currentPosition.set(Math.random() * (h.x - u.x) + u.x, Math.random() * (h.y - u.y) + u.y, Math.random() * (h.z - u.z) + u.z);
            for (var m = new gi(i._currentPosition, d), g = 0, y = 0; y < p; y++) {
              i._vertex0.fromArray(i._vertexData.positions, 3 * i._vertexData.indices[3 * y]), i._vertex1.fromArray(i._vertexData.positions, 3 * i._vertexData.indices[3 * y + 1]), i._vertex2.fromArray(i._vertexData.positions, 3 * i._vertexData.indices[3 * y + 2]);
              var b = m.intersectsTriangle(i._vertex0, i._vertex1, i._vertex2);
              b && b.distance > 0 && g++;
            }
            if (g % 2 != 0) {
              if ((a = i.instance.getConnectedValue(o)) && a.positions && a.positions.length !== 0) {
                var T = a.clone();
                if (i.matrix.isConnected) {
                  var S = i.matrix.getConnectedValue(o);
                  o._instantiateWithPositionAndMatrix(T, i._currentPosition, S, l);
                } else {
                  var E = o.adaptInput(i.scaling, Q.Vector3, v.OneReadOnly), A = i.rotation.getConnectedValue(o) || v.ZeroReadOnly;
                  o._instantiate(T, i._currentPosition, A, E, l);
                }
                i._currentLoopIndex++;
              }
            } else
              f--;
          }
          if (l.length)
            if (l.length === 1)
              i._vertexData = l[0];
            else {
              var R = l.splice(0, 1)[0];
              i._vertexData = R.merge(l, !0, !1, !0, !0);
            }
          return o.restoreGeometryContext(), o.restoreExecutionContext(), o.restoreInstancingContext(), i._vertexData;
        };
        this.evaluateContext ? this.output._storedFunction = r : (this.output._storedFunction = null, this.output._storedValue = r(e));
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".evaluateContext = ").concat(this.evaluateContext ? "true" : "false", `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.evaluateContext = this.evaluateContext, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), e.evaluateContext !== void 0 && (this.evaluateContext = e.evaluateContext);
      }, x([qe("Evaluate context", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t;
    }(At);
    j("BABYLON.InstantiateOnVolumeBlock", A0);
    var R0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.evaluateContext = !0, i.registerInput("instance", Q.Geometry, !0), i.registerInput("count", Q.Int, !0, 1), i.registerOutput("output", Q.Geometry), i;
      }
      return D(t, n), t.prototype.getInstanceIndex = function() {
        return this._currentIndex;
      }, t.prototype.getExecutionIndex = function() {
        return this._currentIndex;
      }, t.prototype.getExecutionLoopIndex = function() {
        return this._currentIndex;
      }, t.prototype.getExecutionFaceIndex = function() {
        return 0;
      }, t.prototype.getClassName = function() {
        return "InstantiateBaseBlock";
      }, Object.defineProperty(t.prototype, "instance", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "count", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".evaluateContext = ").concat(this.evaluateContext ? "true" : "false", `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.evaluateContext = this.evaluateContext, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), e.evaluateContext !== void 0 && (this.evaluateContext = e.evaluateContext);
      }, x([qe("Evaluate context", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t;
    }(At), C0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.registerInput("matrix", Q.Matrix, !0), i.registerInput("position", Q.Vector3, !0, v.Zero()), i.registerInput("rotation", Q.Vector3, !0, v.Zero()), i.registerInput("scaling", Q.Vector3, !0, v.One()), i.scaling.acceptedConnectionPointTypes.push(Q.Float), i;
      }
      return D(t, n), t.prototype.getInstanceIndex = function() {
        return this._currentIndex;
      }, t.prototype.getExecutionIndex = function() {
        return this._currentIndex;
      }, t.prototype.getExecutionLoopIndex = function() {
        return this._currentIndex;
      }, t.prototype.getExecutionFaceIndex = function() {
        return 0;
      }, t.prototype.getClassName = function() {
        return "InstantiateBlock";
      }, Object.defineProperty(t.prototype, "matrix", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "position", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rotation", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "scaling", { get: function() {
        return this._inputs[5];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        var i = this, r = function(o) {
          o.pushExecutionContext(i), o.pushInstancingContext(i);
          var a = i.count.getConnectedValue(o), s = [];
          for (i._currentIndex = 0; i._currentIndex < a; i._currentIndex++) {
            var l = i.instance.getConnectedValue(o);
            if (l && l.positions && l.positions.length !== 0) {
              var c = l.clone();
              if (i.matrix.isConnected) {
                var u = i.matrix.getConnectedValue(o);
                o._instantiateWithMatrix(c, u, s);
              } else {
                var h = i.position.getConnectedValue(o) || v.ZeroReadOnly, d = o.adaptInput(i.scaling, Q.Vector3, v.OneReadOnly), p = i.rotation.getConnectedValue(o) || v.ZeroReadOnly;
                o._instantiate(c, h, p, d, s);
              }
            }
          }
          if (s.length)
            if (s.length === 1)
              i._vertexData = s[0];
            else {
              var f = s.splice(0, 1)[0];
              i._vertexData = f.merge(s, !0, !1, !0, !0);
            }
          return o.restoreExecutionContext(), o.restoreInstancingContext(), i._vertexData;
        };
        this.evaluateContext ? this.output._storedFunction = r : (this.output._storedFunction = null, this.output._storedValue = r(e));
      }, t;
    }(R0);
    j("BABYLON.InstantiateBlock", C0);
    var P0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.registerInput("direction", Q.Vector3, !0, new v(1, 0, 0)), i.registerInput("rotation", Q.Vector3, !0, new v(0, 0, 0)), i.registerInput("scaling", Q.Vector3, !0, new v(0, 0, 0)), i.scaling.acceptedConnectionPointTypes.push(Q.Float), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "InstantiateLinearBlock";
      }, Object.defineProperty(t.prototype, "direction", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rotation", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "scaling", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        var i = this, r = function(o) {
          o.pushExecutionContext(i), o.pushInstancingContext(i);
          var a = i.count.getConnectedValue(o), s = [], l = B.Identity(), c = v.Zero(), u = v.Zero(), h = v.Zero();
          for (i._currentIndex = 0; i._currentIndex < a; i._currentIndex++) {
            var d = i.instance.getConnectedValue(o);
            if (d && d.positions && d.positions.length !== 0) {
              var p = d.clone(), f = i.direction.getConnectedValue(o), m = i.rotation.getConnectedValue(o), g = o.adaptInput(i.scaling, Q.Vector3, v.OneReadOnly);
              c.copyFrom(f.clone().scale(i._currentIndex)), u.copyFrom(m.clone().scale(i._currentIndex)), h.copyFrom(g.clone().scale(i._currentIndex)), h.addInPlaceFromFloats(1, 1, 1), B.ComposeToRef(h, oe.FromEulerAngles(u.x, u.y, u.z), c, l), o._instantiateWithMatrix(p, l, s);
            }
          }
          if (s.length)
            if (s.length === 1)
              i._vertexData = s[0];
            else {
              var y = s.splice(0, 1)[0];
              i._vertexData = y.merge(s, !0, !1, !0, !0);
            }
          return o.restoreExecutionContext(), o.restoreInstancingContext(), i._vertexData;
        };
        this.evaluateContext ? this.output._storedFunction = r : (this.output._storedFunction = null, this.output._storedValue = r(e));
      }, t;
    }(R0);
    j("BABYLON.InstantiateLinearBlock", P0);
    var I0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.registerInput("radius", Q.Int, !0, 0, 0), i.registerInput("angleStart", Q.Float, !0, 0), i.registerInput("angleEnd", Q.Float, !0, 2 * Math.PI), i.registerInput("transform", Q.Vector3, !0, new v(0, 0, 0)), i.registerInput("rotation", Q.Vector3, !0, new v(0, 0, 0)), i.registerInput("scaling", Q.Vector3, !0, new v(0, 0, 0)), i.scaling.acceptedConnectionPointTypes.push(Q.Float), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "InstantiateRadialBlock";
      }, Object.defineProperty(t.prototype, "radius", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "angleStart", { get: function() {
        return this._inputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "angleEnd", { get: function() {
        return this._inputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "transform", { get: function() {
        return this._inputs[5];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rotation", { get: function() {
        return this._inputs[6];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "scaling", { get: function() {
        return this._inputs[7];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        var i = this, r = function(o) {
          o.pushExecutionContext(i), o.pushInstancingContext(i);
          var a = i.count.getConnectedValue(o), s = [], l = B.Identity(), c = B.Identity(), u = B.Identity(), h = v.Zero(), d = v.Zero(), p = v.Zero();
          for (i._currentIndex = 0; i._currentIndex < a; i._currentIndex++) {
            var f = i.instance.getConnectedValue(o);
            if (f && f.positions && f.positions.length !== 0) {
              var m = f.clone(), g = i.radius.getConnectedValue(o), y = i.angleStart.getConnectedValue(o), b = i.angleEnd.getConnectedValue(o), T = i.transform.getConnectedValue(o), S = i.rotation.getConnectedValue(o), E = o.adaptInput(i.scaling, Q.Vector3, v.OneReadOnly), A = y + (b - y) / a * i._currentIndex, R = oe.FromEulerAngles(0, A, 0);
              h.copyFrom(T.clone().scale(i._currentIndex)), d.copyFrom(S.clone().scale(i._currentIndex)), p.copyFrom(E.clone().scale(i._currentIndex)), p.addInPlaceFromFloats(1, 1, 1), B.RotationYawPitchRollToRef(d.y, d.x, d.z, l), c.setTranslationFromFloats(0, 0, g), B.ComposeToRef(p, R, h, u), l.multiplyToRef(c, c), c.multiplyToRef(u, u), o._instantiateWithMatrix(m, u, s);
            }
          }
          if (s.length)
            if (s.length === 1)
              i._vertexData = s[0];
            else {
              var C = s.splice(0, 1)[0];
              i._vertexData = C.merge(s, !0, !1, !0, !0);
            }
          return o.restoreExecutionContext(), o.restoreInstancingContext(), i._vertexData;
        };
        this.evaluateContext ? this.output._storedFunction = r : (this.output._storedFunction = null, this.output._storedValue = r(e));
      }, t;
    }(R0);
    j("BABYLON.InstantiateRadialBlock", I0);
    var M0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.registerInput("float ", Q.Float, !0), i.registerInput("int ", Q.Int, !0), i.registerOutput("float", Q.Float), i.registerOutput("int", Q.Int), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "IntFloatConverterBlock";
      }, Object.defineProperty(t.prototype, "floatIn", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "intIn", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "floatOut", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "intOut", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), t.prototype._inputRename = function(e) {
        return e === "float " ? "floatIn" : e === "int " ? "intIn" : e;
      }, t.prototype._buildBlock = function() {
        var e = this;
        this.floatOut._storedFunction = function(i) {
          return e.floatIn.isConnected ? e.floatIn.getConnectedValue(i) : e.intIn.isConnected ? e.intIn.getConnectedValue(i) : 0;
        }, this.intOut._storedFunction = function(i) {
          return e.floatIn.isConnected ? Math.floor(e.floatIn.getConnectedValue(i)) : e.intIn.isConnected ? Math.floor(e.intIn.getConnectedValue(i)) : 0;
        };
      }, t;
    }(At);
    j("BABYLON.IntFloatConverterBlock", M0);
    var O0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.log = [], i._isDebug = !0, i.registerInput("input", Q.AutoDetect), i.registerOutput("output", Q.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._inputs[0].excludedConnectionPointTypes.push(Q.Geometry), i._inputs[0].excludedConnectionPointTypes.push(Q.Texture), i;
      }
      return D(t, n), Object.defineProperty(t.prototype, "buildExecutionTime", { get: function() {
        return 0;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "DebugBlock";
      }, Object.defineProperty(t.prototype, "input", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        var i = this;
        if (!this.input.isConnected)
          return this.output._storedFunction = null, void (this.output._storedValue = null);
        this.log = [];
        var r = function(o) {
          var a = i.input.getConnectedValue(o);
          return a == null ? (i.log.push("null"), a) : (i.log.push(a.toString()), a);
        };
        this.output.isConnected ? this.output._storedFunction = r : this.output._storedValue = r(e);
      }, t;
    }(At);
    j("BABYLON.DebugBlock", O0);
    var so, D0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.registerInput("geometry", Q.Geometry), i.registerOutput("output", Q.Geometry), i.registerOutput("id", Q.Int), i.registerOutput("collectionId", Q.Int), i.registerOutput("verticesCount", Q.Int), i.registerOutput("facesCount", Q.Int), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "GeometryInfoBlock";
      }, Object.defineProperty(t.prototype, "geometry", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "id", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "collectionId", { get: function() {
        return this._outputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "verticesCount", { get: function() {
        return this._outputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "facesCount", { get: function() {
        return this._outputs[4];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function() {
        var e = this;
        if (!this.geometry.isConnected)
          return this.id._storedValue = 0, this.collectionId._storedValue = 0, this.verticesCount._storedValue = 0, this.facesCount._storedValue = 0, this.output._storedValue = 0, this.id._storedFunction = null, this.collectionId._storedFunction = null, this.verticesCount._storedFunction = null, this.facesCount._storedFunction = null, void (this.output._storedFunction = null);
        this.output._storedFunction = function(i) {
          return e._currentVertexData = e.geometry.getConnectedValue(i), e._currentVertexData;
        }, this.id._storedFunction = function(i) {
          return e._currentVertexData = e._currentVertexData || e.geometry.getConnectedValue(i), e._currentVertexData.uniqueId;
        }, this.collectionId._storedFunction = function(i) {
          return e._currentVertexData = e._currentVertexData || e.geometry.getConnectedValue(i), e._currentVertexData.metadata ? e._currentVertexData.metadata.collectionId : 0;
        }, this.verticesCount._storedFunction = function(i) {
          return e._currentVertexData = e._currentVertexData || e.geometry.getConnectedValue(i), e._currentVertexData.positions ? e._currentVertexData.positions.length / 3 : 0;
        }, this.facesCount._storedFunction = function(i) {
          return e._currentVertexData = e._currentVertexData || e.geometry.getConnectedValue(i), e._currentVertexData.indices ? e._currentVertexData.indices.length / 3 : 0;
        };
      }, t;
    }(At);
    j("BABYLON.GeometryInfoBlock", D0), function(n) {
      n[n.Spherical = 0] = "Spherical", n[n.Cylindrical = 1] = "Cylindrical", n[n.Cubic = 2] = "Cubic";
    }(so || (so = {}));
    var N0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.mapping = so.Spherical, i.registerInput("position", Q.Vector3), i.registerInput("normal", Q.Vector3), i.registerInput("center", Q.Vector3, !0, v.Zero()), i.registerOutput("uv", Q.Vector2), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "MappingBlock";
      }, Object.defineProperty(t.prototype, "position", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "normal", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "center", { get: function() {
        return this._inputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "uv", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function() {
        var e = this;
        if (!this.position.isConnected)
          return this.uv._storedFunction = null, void (this.uv._storedValue = null);
        var i = v.Zero();
        this.uv._storedFunction = function(r) {
          return function(o) {
            var a = e.position.getConnectedValue(o) || v.Zero(), s = e.normal.getConnectedValue(o) || v.Zero(), l = e.center.getConnectedValue(o), c = fe.Zero();
            switch (e.mapping) {
              case so.Spherical:
                a.subtractToRef(l, i), (u = i.length()) > 0 && (c.x = Math.acos(i.y / u) / Math.PI, i.x === 0 && i.z === 0 || (c.y = Math.atan2(i.x, i.z) / (2 * Math.PI)));
                break;
              case so.Cylindrical:
                var u;
                a.subtractToRef(l, i), (u = i.length()) > 0 && (c.x = Math.atan2(i.x / u, i.z / u) / (2 * Math.PI), c.y = (i.y + 1) / 2);
                break;
              case so.Cubic:
                var h = Math.abs(s.x), d = Math.abs(s.y), p = Math.abs(s.z), f = Math.max(Math.abs(a.x), Math.abs(a.y), Math.abs(a.z)), m = 0, g = 0;
                h >= d && h >= p ? (m = a.y / f - l.y, g = a.z / f - l.z) : d >= h && d >= p ? (m = a.x / f - l.x, g = a.z / f - l.z) : (m = a.x / f - l.x, g = a.y / f - l.y), c.x = (m + 1) / 2, c.y = (g + 1) / 2;
            }
            return c;
          }(r);
        };
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".mapping = BABYLON.MappingTypes.").concat(so[this.mapping], `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.mapping = this.mapping, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), this.mapping = e.mapping;
      }, x([qe("Mapping", Ye.List, "ADVANCED", { notifiers: { rebuild: !0 }, options: [{ label: "Spherical", value: so.Spherical }, { label: "Cylindrical", value: so.Cylindrical }, { label: "Cubic", value: so.Cubic }] })], t.prototype, "mapping", void 0), t;
    }(At);
    j("BABYLON.MappingBlock", N0);
    var F0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.registerInput("matrix0", Q.Matrix), i.registerInput("matrix1", Q.Matrix), i.registerOutput("output", Q.Matrix), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "MatrixComposeBlock";
      }, Object.defineProperty(t.prototype, "matrix0", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "matrix1", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function() {
        var e = this;
        this.output._storedFunction = function(i) {
          if (!e.matrix0.isConnected || !e.matrix1.isConnected)
            return null;
          var r = e.matrix0.getConnectedValue(i), o = e.matrix1.getConnectedValue(i);
          return r && o ? r.multiply(o) : null;
        };
      }, t;
    }(At);
    j("BABYLON.MatrixComposeBlock", F0);
    var L0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i._endpoints = [], i._isTeleportIn = !0, i.registerInput("input", Q.AutoDetect), i;
      }
      return D(t, n), Object.defineProperty(t.prototype, "endpoints", { get: function() {
        return this._endpoints;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "TeleportInBlock";
      }, Object.defineProperty(t.prototype, "input", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._dumpCode = function(e, i) {
        for (var r = n.prototype._dumpCode.call(this, e, i), o = 0, a = this.endpoints; o < a.length; o++) {
          var s = a[o];
          i.indexOf(s) === -1 && (r += s._dumpCode(e, i));
        }
        return r;
      }, t.prototype.isAnAncestorOfType = function(e) {
        if (this.getClassName() === e)
          return !0;
        for (var i = 0, r = this.endpoints; i < r.length; i++)
          if (r[i].isAnAncestorOfType(e))
            return !0;
        return !1;
      }, t.prototype.isAnAncestorOf = function(e) {
        for (var i = 0, r = this.endpoints; i < r.length; i++) {
          var o = r[i];
          if (o === e || o.isAnAncestorOf(e))
            return !0;
        }
        return !1;
      }, t.prototype.getDescendantOfPredicate = function(e) {
        if (e(this))
          return this;
        for (var i = 0, r = this.endpoints; i < r.length; i++) {
          var o = r[i].getDescendantOfPredicate(e);
          if (o)
            return o;
        }
        return null;
      }, t.prototype.attachToEndpoint = function(e) {
        e.detach(), this._endpoints.push(e), e._entryPoint = this, e._outputs[0]._typeConnectionSource = this._inputs[0], e._tempEntryPointUniqueId = null, e.name = "> " + this.name;
      }, t.prototype.detachFromEndpoint = function(e) {
        var i = this._endpoints.indexOf(e);
        i !== -1 && (this._endpoints.splice(i, 1), e._outputs[0]._typeConnectionSource = null, e._entryPoint = null);
      }, t.prototype._buildBlock = function() {
        for (var e = this, i = 0, r = this._endpoints; i < r.length; i++)
          r[i].output._storedFunction = function(o) {
            return e.input.getConnectedValue(o);
          };
      }, t;
    }(At);
    j("BABYLON.TeleportInBlock", L0);
    var w0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i._entryPoint = null, i._tempEntryPointUniqueId = null, i._isTeleportOut = !0, i.registerOutput("output", Q.BasedOnInput), i;
      }
      return D(t, n), Object.defineProperty(t.prototype, "entryPoint", { get: function() {
        return this._entryPoint;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "TeleportOutBlock";
      }, Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype.detach = function() {
        this._entryPoint && this._entryPoint.detachFromEndpoint(this);
      }, t.prototype._buildBlock = function() {
      }, t.prototype._customBuildStep = function(e) {
        this.entryPoint && this.entryPoint.build(e);
      }, t.prototype._dumpCode = function(e, i) {
        var r = "";
        return this.entryPoint && i.indexOf(this.entryPoint) === -1 && (r += this.entryPoint._dumpCode(e, i)), r + n.prototype._dumpCode.call(this, e, i);
      }, t.prototype._dumpCodeForOutputConnections = function(e) {
        var i = n.prototype._dumpCodeForOutputConnections.call(this, e);
        return this.entryPoint && (i += this.entryPoint._dumpCodeForOutputConnections(e)), i;
      }, t.prototype.clone = function() {
        var e = n.prototype.clone.call(this);
        return this.entryPoint && this.entryPoint.attachToEndpoint(e), e;
      }, t.prototype._dumpPropertiesCode = function() {
        var e = n.prototype._dumpPropertiesCode.call(this);
        return this.entryPoint && (e += "".concat(this.entryPoint._codeVariableName, ".attachToEndpoint(").concat(this._codeVariableName, `);
`)), e;
      }, t.prototype.serialize = function() {
        var e, i, r = n.prototype.serialize.call(this);
        return r.entryPoint = (i = (e = this.entryPoint) === null || e === void 0 ? void 0 : e.uniqueId) !== null && i !== void 0 ? i : "", r;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), this._tempEntryPointUniqueId = e.entryPoint;
      }, t;
    }(At);
    j("BABYLON.TeleportOutBlock", w0);
    var B0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i._data = null, i.serializedCachedData = !1, i.registerOutput("texture", Q.Texture), i;
      }
      return D(t, n), Object.defineProperty(t.prototype, "textureData", { get: function() {
        return this._data;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "textureWidth", { get: function() {
        return this._width;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "textureHeight", { get: function() {
        return this._height;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "GeometryTextureBlock";
      }, Object.defineProperty(t.prototype, "texture", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._prepareImgToLoadAsync = function(e) {
        var i = this;
        return new Promise(function(r, o) {
          var a = new Image(), s = document.createElement("canvas"), l = s.getContext("2d");
          a.onload = function() {
            s.width = a.width, s.height = a.height, l.drawImage(a, 0, 0);
            for (var c = l.getImageData(0, 0, a.width, a.height).data, u = new Float32Array(c.length), h = 0; h < c.length; h++)
              u[h] = c[h] / 255;
            i._data = u, i._width = a.width, i._height = a.height, r();
          }, a.onerror = function() {
            i._data = null, o();
          }, a.src = e;
        });
      }, t.prototype.cleanData = function() {
        this._data = null;
      }, t.prototype.loadTextureFromFileAsync = function(e) {
        return this._prepareImgToLoadAsync(URL.createObjectURL(e));
      }, t.prototype.loadTextureFromUrlAsync = function(e) {
        return this._prepareImgToLoadAsync(e);
      }, t.prototype.extractFromTextureAsync = function(e) {
        var i = this;
        return new Promise(function(r, o) {
          if (e.isReady()) {
            var a = e.getSize();
            Yv.GetTextureDataAsync(e, a.width, a.height).then(function(s) {
              return Ft(i, void 0, void 0, function() {
                var l, c;
                return Bt(this, function(u) {
                  for (l = new Float32Array(s.length), c = 0; c < s.length; c++)
                    l[c] = s[c] / 255;
                  return this._data = l, this._width = a.width, this._height = a.height, r(), [2];
                });
              });
            }).catch(o);
          } else
            e.onLoadObservable.addOnce(function() {
              return i.extractFromTextureAsync(e).then(r).catch(o);
            });
        });
      }, t.prototype._buildBlock = function() {
        if (this._data) {
          var e = { data: this._data, width: this._width, height: this._height };
          this.texture._storedValue = e;
        } else
          this.texture._storedValue = null;
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.width = this._width, e.height = this._height, e.serializedCachedData = this.serializedCachedData, this._data && this.serializedCachedData && (e.data = Array.from(this._data)), e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), this._width = e.width, this._height = e.height, e.data ? (this._data = new Float32Array(e.data), this.serializedCachedData = !0) : this.serializedCachedData = !!e.serializedCachedData;
      }, x([qe("Serialize cached data", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "serializedCachedData", void 0), t;
    }(At);
    j("BABYLON.GeometryTextureBlock", B0);
    var U0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.clampCoordinates = !0, i.registerInput("texture", Q.Texture), i.registerInput("coordinates", Q.Vector2), i.registerOutput("rgba", Q.Vector4), i.registerOutput("rgb", Q.Vector3), i.registerOutput("r", Q.Float), i.registerOutput("g", Q.Float), i.registerOutput("b", Q.Float), i.registerOutput("a", Q.Float), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "GeometryTextureFetchBlock";
      }, Object.defineProperty(t.prototype, "texture", { get: function() {
        return this.inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "coordinates", { get: function() {
        return this.inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgba", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgb", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "r", { get: function() {
        return this._outputs[2];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "g", { get: function() {
        return this._outputs[3];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "b", { get: function() {
        return this._outputs[4];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "a", { get: function() {
        return this._outputs[5];
      }, enumerable: !1, configurable: !0 }), t.prototype._repeatClamp = function(e) {
        return e >= 0 ? e % 1 : 1 - Math.abs(e) % 1;
      }, t.prototype._buildBlock = function() {
        var e = this, i = function(r) {
          var o = e.texture.getConnectedValue(r);
          if (!o || !o.data)
            return null;
          var a = e.coordinates.getConnectedValue(r);
          if (!a)
            return null;
          var s = e.clampCoordinates ? Math.max(0, Math.min(a.x, 1)) : e._repeatClamp(a.x), l = e.clampCoordinates ? Math.max(0, Math.min(a.y, 1)) : e._repeatClamp(a.y), c = Math.floor(s * (o.width - 1)), u = Math.floor(l * (o.height - 1)), h = c + o.width * u;
          return lt.FromArray(o.data, 4 * h);
        };
        this.rgba._storedFunction = function(r) {
          return i(r);
        }, this.rgb._storedFunction = function(r) {
          var o = i(r);
          return o ? o.toVector3() : null;
        }, this.r._storedFunction = function(r) {
          var o = i(r);
          return o ? o.x : null;
        }, this.g._storedFunction = function(r) {
          var o = i(r);
          return o ? o.y : null;
        }, this.b._storedFunction = function(r) {
          var o = i(r);
          return o ? o.z : null;
        }, this.a._storedFunction = function(r) {
          var o = i(r);
          return o ? o.w : null;
        };
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".clampCoordinates = ").concat(this.clampCoordinates, `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.clampCoordinates = this.clampCoordinates, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), this.clampCoordinates = e.clampCoordinates;
      }, x([qe("Clamp Coordinates", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "clampCoordinates", void 0), t;
    }(At);
    j("BABYLON.GeometryTextureFetchBlock", U0);
    var lo, V0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.registerInput("geometry", Q.Geometry), i.registerOutput("min", Q.Vector3), i.registerOutput("max", Q.Vector3), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "BoundingBlock";
      }, Object.defineProperty(t.prototype, "geometry", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "min", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "max", { get: function() {
        return this._outputs[1];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function() {
        var e = this;
        this.min._storedFunction = function(i) {
          var r = e.geometry.getConnectedValue(i);
          return r ? hl(r.positions, 0, r.positions.length / 3).minimum : null;
        }, this.max._storedFunction = function(i) {
          var r = e.geometry.getConnectedValue(i);
          return r ? hl(r.positions, 0, r.positions.length / 3).maximum : null;
        };
      }, t;
    }(At);
    j("BABYLON.BoundingBlock", V0), function(n) {
      n[n.Intersect = 0] = "Intersect", n[n.Subtract = 1] = "Subtract", n[n.Union = 2] = "Union";
    }(lo || (lo = {}));
    var k0 = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.evaluateContext = !1, i.operation = lo.Intersect, i.registerInput("geometry0", Q.Geometry), i.registerInput("geometry1", Q.Geometry), i.registerOutput("output", Q.Geometry), i;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "BooleanGeometryBlock";
      }, Object.defineProperty(t.prototype, "geometry0", { get: function() {
        return this._inputs[0];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry1", { get: function() {
        return this._inputs[1];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
        return this._outputs[0];
      }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
        var i = this, r = function(o) {
          var a = i.geometry0.getConnectedValue(o), s = i.geometry1.getConnectedValue(o);
          if (!a || !s)
            return null;
          var l = a.positions.length / 3;
          !a.normals && s.normals && (a.normals = new Array(a.positions.length)), !s.normals && a.normals && (s.normals = new Array(s.positions.length)), !a.uvs && s.uvs && (a.uvs = new Array(2 * l)), !s.uvs && a.uvs && (s.uvs = new Array(2 * l)), !a.colors && s.colors && (a.colors = new Array(4 * l)), !s.colors && a.colors && (s.colors = new Array(4 * l));
          var c, u = X_.FromVertexData(a), h = X_.FromVertexData(s);
          switch (i.operation) {
            case lo.Intersect:
              c = u.intersect(h);
              break;
            case lo.Subtract:
              c = u.subtract(h);
              break;
            case lo.Union:
              c = u.union(h);
          }
          return c.toVertexData();
        };
        this.evaluateContext ? this.output._storedFunction = r : (this.output._storedFunction = null, this.output._storedValue = r(e));
      }, t.prototype._dumpPropertiesCode = function() {
        return n.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".evaluateContext = ").concat(this.evaluateContext ? "true" : "false", `;
`) + "".concat(this._codeVariableName, ".operation = BABYLON.BooleanGeometryOperations.").concat(lo[this.operation], `;
`);
      }, t.prototype.serialize = function() {
        var e = n.prototype.serialize.call(this);
        return e.evaluateContext = this.evaluateContext, e.operation = this.operation, e;
      }, t.prototype._deserialize = function(e) {
        n.prototype._deserialize.call(this, e), this.evaluateContext = e.evaluateContext, e.operation && (this.operation = e.operation);
      }, x([qe("Evaluate context", Ye.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), x([qe("Operation", Ye.List, "ADVANCED", { notifiers: { rebuild: !0 }, options: [{ label: "Intersect", value: lo.Intersect }, { label: "Subtract", value: lo.Subtract }, { label: "Union", value: lo.Union }] })], t.prototype, "operation", void 0), t;
    }(At);
    j("BABYLON.BooleanGeometryBlock", k0);
    var MP = function() {
      function n(t) {
        t === void 0 && (t = Recast), this.bjsRECAST = {}, this.name = "RecastJSPlugin", this._maximumSubStepCount = 10, this._timeStep = 1 / 60, this._timeFactor = 1, this._worker = null, typeof t == "function" ? q.Error("RecastJS is not ready. Please make sure you await Recast() before using the plugin.") : this.bjsRECAST = t, this.isSupported() ? (this.setTimeStep(), this._tempVec1 = new this.bjsRECAST.Vec3(), this._tempVec2 = new this.bjsRECAST.Vec3()) : q.Error("RecastJS is not available. Please make sure you included the js file.");
      }
      return n.prototype.setWorkerURL = function(t) {
        return !(!window || !window.Worker || (this._worker = new Worker(t), 0));
      }, n.prototype.setTimeStep = function(t) {
        t === void 0 && (t = 1 / 60), this._timeStep = t;
      }, n.prototype.getTimeStep = function() {
        return this._timeStep;
      }, n.prototype.setMaximumSubStepCount = function(t) {
        t === void 0 && (t = 10), this._maximumSubStepCount = t;
      }, n.prototype.getMaximumSubStepCount = function() {
        return this._maximumSubStepCount;
      }, Object.defineProperty(n.prototype, "timeFactor", { get: function() {
        return this._timeFactor;
      }, set: function(t) {
        this._timeFactor = Math.max(t, 0);
      }, enumerable: !1, configurable: !0 }), n.prototype.createNavMesh = function(t, e, i) {
        var r, o, a;
        this._worker && !i ? console.warn("A worker is avaible but no completion callback. Defaulting to blocking navmesh creation") : !this._worker && i && console.warn("A completion callback is avaible but no worker. Defaulting to blocking navmesh creation"), this.navMesh = new this.bjsRECAST.NavMesh();
        var s = [], l = [], c = 0;
        for (r = 0; r < t.length; r++)
          if (t[r]) {
            var u = t[r], h = u.getIndices();
            if (!h)
              continue;
            var d = u.getVerticesData(P.PositionKind, !1, !1);
            if (!d)
              continue;
            var p = [], f = u.computeWorldMatrix(!0);
            if (u.hasThinInstances)
              for (var m = u.thinInstanceGetWorldMatrices(), g = 0; g < m.length; g++) {
                var y = new B();
                m[g].multiplyToRef(f, y), p.push(y);
              }
            else
              p.push(f);
            for (var b = 0; b < p.length; b++) {
              var T = p[b];
              for (o = 0; o < h.length; o++)
                s.push(h[o] + c);
              var S = v.Zero(), E = v.Zero();
              for (a = 0; a < d.length; a += 3)
                v.FromArrayToRef(d, a, E), v.TransformCoordinatesToRef(E, T, S), l.push(S.x, S.y, S.z);
              c += d.length / 3;
            }
          }
        if (this._worker && i)
          this._worker.postMessage([l, c, s, s.length, e]), this._worker.onmessage = function(R) {
            i(R.data);
          };
        else {
          var A = new this.bjsRECAST.rcConfig();
          A.cs = e.cs, A.ch = e.ch, A.borderSize = e.borderSize ? e.borderSize : 0, A.tileSize = e.tileSize ? e.tileSize : 0, A.walkableSlopeAngle = e.walkableSlopeAngle, A.walkableHeight = e.walkableHeight, A.walkableClimb = e.walkableClimb, A.walkableRadius = e.walkableRadius, A.maxEdgeLen = e.maxEdgeLen, A.maxSimplificationError = e.maxSimplificationError, A.minRegionArea = e.minRegionArea, A.mergeRegionArea = e.mergeRegionArea, A.maxVertsPerPoly = e.maxVertsPerPoly, A.detailSampleDist = e.detailSampleDist, A.detailSampleMaxError = e.detailSampleMaxError, this.navMesh.build(l, c, s, s.length, A);
        }
      }, n.prototype.createDebugNavMesh = function(t) {
        var e, i, r = this.navMesh.getDebugNavMesh(), o = r.getTriangleCount(), a = [], s = [];
        for (e = 0; e < 3 * o; e++)
          a.push(e);
        for (e = 0; e < o; e++)
          for (i = 0; i < 3; i++) {
            var l = r.getTriangle(e).getPoint(i);
            s.push(l.x, l.y, l.z);
          }
        var c = new ie("NavMeshDebug", t), u = new Oe();
        return u.indices = a, u.positions = s, u.applyToMesh(c, !1), c;
      }, n.prototype.getClosestPoint = function(t) {
        this._tempVec1.x = t.x, this._tempVec1.y = t.y, this._tempVec1.z = t.z;
        var e = this.navMesh.getClosestPoint(this._tempVec1);
        return new v(e.x, e.y, e.z);
      }, n.prototype.getClosestPointToRef = function(t, e) {
        this._tempVec1.x = t.x, this._tempVec1.y = t.y, this._tempVec1.z = t.z;
        var i = this.navMesh.getClosestPoint(this._tempVec1);
        e.set(i.x, i.y, i.z);
      }, n.prototype.getRandomPointAround = function(t, e) {
        this._tempVec1.x = t.x, this._tempVec1.y = t.y, this._tempVec1.z = t.z;
        var i = this.navMesh.getRandomPointAround(this._tempVec1, e);
        return new v(i.x, i.y, i.z);
      }, n.prototype.getRandomPointAroundToRef = function(t, e, i) {
        this._tempVec1.x = t.x, this._tempVec1.y = t.y, this._tempVec1.z = t.z;
        var r = this.navMesh.getRandomPointAround(this._tempVec1, e);
        i.set(r.x, r.y, r.z);
      }, n.prototype.moveAlong = function(t, e) {
        this._tempVec1.x = t.x, this._tempVec1.y = t.y, this._tempVec1.z = t.z, this._tempVec2.x = e.x, this._tempVec2.y = e.y, this._tempVec2.z = e.z;
        var i = this.navMesh.moveAlong(this._tempVec1, this._tempVec2);
        return new v(i.x, i.y, i.z);
      }, n.prototype.moveAlongToRef = function(t, e, i) {
        this._tempVec1.x = t.x, this._tempVec1.y = t.y, this._tempVec1.z = t.z, this._tempVec2.x = e.x, this._tempVec2.y = e.y, this._tempVec2.z = e.z;
        var r = this.navMesh.moveAlong(this._tempVec1, this._tempVec2);
        i.set(r.x, r.y, r.z);
      }, n.prototype.computePath = function(t, e) {
        var i;
        this._tempVec1.x = t.x, this._tempVec1.y = t.y, this._tempVec1.z = t.z, this._tempVec2.x = e.x, this._tempVec2.y = e.y, this._tempVec2.z = e.z;
        var r = this.navMesh.computePath(this._tempVec1, this._tempVec2), o = r.getPointCount(), a = [];
        for (i = 0; i < o; i++) {
          var s = r.getPoint(i);
          a.push(new v(s.x, s.y, s.z));
        }
        return a;
      }, n.prototype.createCrowd = function(t, e, i) {
        return new G0(this, t, e, i);
      }, n.prototype.setDefaultQueryExtent = function(t) {
        this._tempVec1.x = t.x, this._tempVec1.y = t.y, this._tempVec1.z = t.z, this.navMesh.setDefaultQueryExtent(this._tempVec1);
      }, n.prototype.getDefaultQueryExtent = function() {
        var t = this.navMesh.getDefaultQueryExtent();
        return new v(t.x, t.y, t.z);
      }, n.prototype.buildFromNavmeshData = function(t) {
        var e = t.length * t.BYTES_PER_ELEMENT, i = this.bjsRECAST._malloc(e), r = new Uint8Array(this.bjsRECAST.HEAPU8.buffer, i, e);
        r.set(t);
        var o = new this.bjsRECAST.NavmeshData();
        o.dataPointer = r.byteOffset, o.size = t.length, this.navMesh = new this.bjsRECAST.NavMesh(), this.navMesh.buildFromNavmeshData(o), this.bjsRECAST._free(r.byteOffset);
      }, n.prototype.getNavmeshData = function() {
        var t = this.navMesh.getNavmeshData(), e = new Uint8Array(this.bjsRECAST.HEAPU8.buffer, t.dataPointer, t.size), i = new Uint8Array(t.size);
        return i.set(e), this.navMesh.freeNavmeshData(t), i;
      }, n.prototype.getDefaultQueryExtentToRef = function(t) {
        var e = this.navMesh.getDefaultQueryExtent();
        t.set(e.x, e.y, e.z);
      }, n.prototype.dispose = function() {
      }, n.prototype.addCylinderObstacle = function(t, e, i) {
        return this._tempVec1.x = t.x, this._tempVec1.y = t.y, this._tempVec1.z = t.z, this.navMesh.addCylinderObstacle(this._tempVec1, e, i);
      }, n.prototype.addBoxObstacle = function(t, e, i) {
        return this._tempVec1.x = t.x, this._tempVec1.y = t.y, this._tempVec1.z = t.z, this._tempVec2.x = e.x, this._tempVec2.y = e.y, this._tempVec2.z = e.z, this.navMesh.addBoxObstacle(this._tempVec1, this._tempVec2, i);
      }, n.prototype.removeObstacle = function(t) {
        this.navMesh.removeObstacle(t);
      }, n.prototype.isSupported = function() {
        return this.bjsRECAST !== void 0;
      }, n;
    }(), G0 = function() {
      function n(t, e, i, r) {
        var o = this;
        this.recastCrowd = {}, this.transforms = new Array(), this.agents = new Array(), this.reachRadii = new Array(), this._agentDestinationArmed = new Array(), this._agentDestination = new Array(), this._onBeforeAnimationsObserver = null, this.onReachTargetObservable = new H(), this.bjsRECASTPlugin = t, this.recastCrowd = new this.bjsRECASTPlugin.bjsRECAST.Crowd(e, i, this.bjsRECASTPlugin.navMesh.getNavMesh()), this._scene = r, this._onBeforeAnimationsObserver = r.onBeforeAnimationsObservable.add(function() {
          o.update(1e-3 * r.getEngine().getDeltaTime() * t.timeFactor);
        });
      }
      return n.prototype.addAgent = function(t, e, i) {
        var r = new this.bjsRECASTPlugin.bjsRECAST.dtCrowdAgentParams();
        r.radius = e.radius, r.height = e.height, r.maxAcceleration = e.maxAcceleration, r.maxSpeed = e.maxSpeed, r.collisionQueryRange = e.collisionQueryRange, r.pathOptimizationRange = e.pathOptimizationRange, r.separationWeight = e.separationWeight, r.updateFlags = 7, r.obstacleAvoidanceType = 0, r.queryFilterType = 0, r.userData = 0;
        var o = this.recastCrowd.addAgent(new this.bjsRECASTPlugin.bjsRECAST.Vec3(t.x, t.y, t.z), r);
        return this.transforms.push(i), this.agents.push(o), this.reachRadii.push(e.reachRadius ? e.reachRadius : e.radius), this._agentDestinationArmed.push(!1), this._agentDestination.push(new v(0, 0, 0)), o;
      }, n.prototype.getAgentPosition = function(t) {
        var e = this.recastCrowd.getAgentPosition(t);
        return new v(e.x, e.y, e.z);
      }, n.prototype.getAgentPositionToRef = function(t, e) {
        var i = this.recastCrowd.getAgentPosition(t);
        e.set(i.x, i.y, i.z);
      }, n.prototype.getAgentVelocity = function(t) {
        var e = this.recastCrowd.getAgentVelocity(t);
        return new v(e.x, e.y, e.z);
      }, n.prototype.getAgentVelocityToRef = function(t, e) {
        var i = this.recastCrowd.getAgentVelocity(t);
        e.set(i.x, i.y, i.z);
      }, n.prototype.getAgentNextTargetPath = function(t) {
        var e = this.recastCrowd.getAgentNextTargetPath(t);
        return new v(e.x, e.y, e.z);
      }, n.prototype.getAgentNextTargetPathToRef = function(t, e) {
        var i = this.recastCrowd.getAgentNextTargetPath(t);
        e.set(i.x, i.y, i.z);
      }, n.prototype.getAgentState = function(t) {
        return this.recastCrowd.getAgentState(t);
      }, n.prototype.overOffmeshConnection = function(t) {
        return this.recastCrowd.overOffmeshConnection(t);
      }, n.prototype.agentGoto = function(t, e) {
        this.recastCrowd.agentGoto(t, new this.bjsRECASTPlugin.bjsRECAST.Vec3(e.x, e.y, e.z));
        var i = this.agents.indexOf(t);
        i > -1 && (this._agentDestinationArmed[i] = !0, this._agentDestination[i].set(e.x, e.y, e.z));
      }, n.prototype.agentTeleport = function(t, e) {
        this.recastCrowd.agentTeleport(t, new this.bjsRECASTPlugin.bjsRECAST.Vec3(e.x, e.y, e.z));
      }, n.prototype.updateAgentParameters = function(t, e) {
        var i = this.recastCrowd.getAgentParameters(t);
        e.radius !== void 0 && (i.radius = e.radius), e.height !== void 0 && (i.height = e.height), e.maxAcceleration !== void 0 && (i.maxAcceleration = e.maxAcceleration), e.maxSpeed !== void 0 && (i.maxSpeed = e.maxSpeed), e.collisionQueryRange !== void 0 && (i.collisionQueryRange = e.collisionQueryRange), e.pathOptimizationRange !== void 0 && (i.pathOptimizationRange = e.pathOptimizationRange), e.separationWeight !== void 0 && (i.separationWeight = e.separationWeight), this.recastCrowd.setAgentParameters(t, i);
      }, n.prototype.removeAgent = function(t) {
        this.recastCrowd.removeAgent(t);
        var e = this.agents.indexOf(t);
        e > -1 && (this.agents.splice(e, 1), this.transforms.splice(e, 1), this.reachRadii.splice(e, 1), this._agentDestinationArmed.splice(e, 1), this._agentDestination.splice(e, 1));
      }, n.prototype.getAgents = function() {
        return this.agents;
      }, n.prototype.update = function(t) {
        if (this.bjsRECASTPlugin.navMesh.update(), !(t <= Ge)) {
          var e = this.bjsRECASTPlugin.getTimeStep(), i = this.bjsRECASTPlugin.getMaximumSubStepCount();
          if (e <= Ge)
            this.recastCrowd.update(t);
          else {
            var r = Math.floor(t / e);
            i && r > i && (r = i), r < 1 && (r = 1);
            for (var o = t / r, a = 0; a < r; a++)
              this.recastCrowd.update(o);
          }
          for (var s = 0; s < this.agents.length; s++) {
            var l = this.agents[s], c = this.getAgentPosition(l);
            if (this.transforms[s].position = c, this._agentDestinationArmed[s]) {
              var u = c.x - this._agentDestination[s].x, h = c.z - this._agentDestination[s].z, d = this.reachRadii[s], p = this._agentDestination[s].y - this.reachRadii[s], f = this._agentDestination[s].y + this.reachRadii[s], m = u * u + h * h;
              c.y > p && c.y < f && m < d * d && (this.onReachTargetObservable.notifyObservers({ agentIndex: l, destination: this._agentDestination[s] }), this._agentDestinationArmed[s] = !1);
            }
          }
        }
      }, n.prototype.setDefaultQueryExtent = function(t) {
        var e = new this.bjsRECASTPlugin.bjsRECAST.Vec3(t.x, t.y, t.z);
        this.recastCrowd.setDefaultQueryExtent(e);
      }, n.prototype.getDefaultQueryExtent = function() {
        var t = this.recastCrowd.getDefaultQueryExtent();
        return new v(t.x, t.y, t.z);
      }, n.prototype.getDefaultQueryExtentToRef = function(t) {
        var e = this.recastCrowd.getDefaultQueryExtent();
        t.set(e.x, e.y, e.z);
      }, n.prototype.getCorners = function(t) {
        var e, i = this.recastCrowd.getCorners(t), r = i.getPointCount(), o = [];
        for (e = 0; e < r; e++) {
          var a = i.getPoint(e);
          o.push(new v(a.x, a.y, a.z));
        }
        return o;
      }, n.prototype.dispose = function() {
        this.recastCrowd.destroy(), this._scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver), this._onBeforeAnimationsObserver = null, this.onReachTargetObservable.clear();
      }, n;
    }();
    ve.OfflineProviderFactory = function(n, t, e) {
      return e === void 0 && (e = !1), new z0(n, t, e);
    };
    var z0 = function() {
      function n(t, e, i) {
        i === void 0 && (i = !1), this._idbFactory = typeof indexedDB < "u" ? indexedDB : void 0, this._currentSceneUrl = n._ReturnFullUrlLocation(t), this._db = null, this._enableSceneOffline = !1, this._enableTexturesOffline = !1, this._manifestVersionFound = 0, this._mustUpdateRessources = !1, this._hasReachedQuota = !1, n.IDBStorageEnabled ? i ? (this._enableSceneOffline = !0, this._enableTexturesOffline = !0, this._manifestVersionFound = 1, de.SetImmediate(function() {
          e(!0);
        })) : this._checkManifestFile(e) : e(!0);
      }
      return Object.defineProperty(n.prototype, "enableSceneOffline", { get: function() {
        return this._enableSceneOffline;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "enableTexturesOffline", { get: function() {
        return this._enableTexturesOffline;
      }, enumerable: !1, configurable: !0 }), n.prototype._checkManifestFile = function(t) {
        var e = this, i = function() {
          e._enableSceneOffline = !1, e._enableTexturesOffline = !1, t(!1);
        }, r = function() {
          try {
            if (typeof URL == "function" && e._currentSceneUrl.indexOf("http") === 0) {
              var l = new URL(e._currentSceneUrl);
              return l.pathname += ".manifest", l.toString();
            }
          } catch {
          }
          return "".concat(e._currentSceneUrl, ".manifest");
        }, o = !1, a = r(), s = new _n();
        navigator.onLine && (o = !0, a = a + (a.match(/\?/) == null ? "?" : "&") + Date.now()), s.open("GET", a), s.addEventListener("load", function() {
          if (s.status === 200 || n._ValidateXHRData(s, 1))
            try {
              var l = JSON.parse(s.response);
              e._enableSceneOffline = l.enableSceneOffline, e._enableTexturesOffline = l.enableTexturesOffline && n._IsUASupportingBlobStorage, l.version && !isNaN(parseInt(l.version)) && (e._manifestVersionFound = l.version), t(!0);
            } catch {
              i();
            }
          else
            i();
        }, !1), s.addEventListener("error", function() {
          if (o) {
            o = !1;
            var l = r();
            s.open("GET", l), s.send();
          } else
            i();
        }, !1);
        try {
          s.send();
        } catch {
          q.Error("Error on XHR send request."), t(!1);
        }
      }, n.prototype.open = function(t, e) {
        var i = this, r = function() {
          i._isSupported = !1, e && e();
        };
        if (this._idbFactory && (this._enableSceneOffline || this._enableTexturesOffline))
          if (this._db)
            t && t();
          else {
            this._hasReachedQuota = !1, this._isSupported = !0;
            var o = this._idbFactory.open("babylonjs", 1);
            o.onerror = function() {
              r();
            }, o.onblocked = function() {
              q.Error("IDB request blocked. Please reload the page."), r();
            }, o.onsuccess = function() {
              i._db = o.result, t();
            }, o.onupgradeneeded = function(a) {
              if (i._db = a.target.result, i._db)
                try {
                  i._db.createObjectStore("scenes", { keyPath: "sceneUrl" }), i._db.createObjectStore("versions", { keyPath: "sceneUrl" }), i._db.createObjectStore("textures", { keyPath: "textureUrl" });
                } catch (s) {
                  q.Error("Error while creating object stores. Exception: " + s.message), r();
                }
            };
          }
        else
          this._isSupported = !1, e && e();
      }, n.prototype.loadImage = function(t, e) {
        var i = this, r = n._ReturnFullUrlLocation(t), o = function() {
          i._hasReachedQuota || i._db === null ? e.src = t : i._saveImageIntoDBAsync(r, e);
        };
        this._mustUpdateRessources ? o() : this._loadImageFromDBAsync(r, e, o);
      }, n.prototype._loadImageFromDBAsync = function(t, e, i) {
        if (this._isSupported && this._db !== null) {
          var r, o = this._db.transaction(["textures"]);
          o.onabort = function() {
            e.src = t;
          }, o.oncomplete = function() {
            var s;
            r && typeof URL == "function" ? (s = URL.createObjectURL(r.data), e.onerror = function() {
              q.Error("Error loading image from blob URL: " + s + " switching back to web url: " + t), e.src = t;
            }, e.src = s) : i();
          };
          var a = o.objectStore("textures").get(t);
          a.onsuccess = function(s) {
            r = s.target.result;
          }, a.onerror = function() {
            q.Error("Error loading texture " + t + " from DB."), e.src = t;
          };
        } else
          q.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."), e.src = t;
      }, n.prototype._saveImageIntoDBAsync = function(t, e) {
        var i, r = this;
        if (this._isSupported) {
          var o = function() {
            var s;
            if (i && typeof URL == "function")
              try {
                s = URL.createObjectURL(i);
              } catch {
                s = URL.createObjectURL(i);
              }
            s && (e.src = s);
          };
          if (n._IsUASupportingBlobStorage) {
            var a = new _n();
            a.open("GET", t), a.responseType = "blob", a.addEventListener("load", function() {
              if (a.status === 200 && r._db) {
                i = a.response;
                var s = r._db.transaction(["textures"], "readwrite");
                s.onabort = function(u) {
                  try {
                    var h = u.target.error;
                    h && h.name === "QuotaExceededError" && (r._hasReachedQuota = !0);
                  } catch {
                  }
                  o();
                }, s.oncomplete = function() {
                  o();
                };
                var l = { textureUrl: t, data: i };
                try {
                  var c = s.objectStore("textures").put(l);
                  c.onsuccess = function() {
                  }, c.onerror = function() {
                    o();
                  };
                } catch (u) {
                  u.code === 25 && (n._IsUASupportingBlobStorage = !1, r._enableTexturesOffline = !1), e.src = t;
                }
              } else
                e.src = t;
            }, !1), a.addEventListener("error", function() {
              q.Error("Error in XHR request in BABYLON.Database."), e.src = t;
            }, !1), a.send();
          } else
            e.src = t;
        } else
          q.Error("Error: IndexedDB not supported by your browser or Babylon.js database is not open."), e.src = t;
      }, n.prototype._checkVersionFromDB = function(t, e) {
        var i = this;
        this._loadVersionFromDBAsync(t, e, function() {
          i._saveVersionIntoDBAsync(t, e);
        });
      }, n.prototype._loadVersionFromDBAsync = function(t, e, i) {
        var r, o = this;
        if (this._isSupported && this._db)
          try {
            var a = this._db.transaction(["versions"]);
            a.oncomplete = function() {
              r ? o._manifestVersionFound !== r.data ? (o._mustUpdateRessources = !0, i()) : e(r.data) : (o._mustUpdateRessources = !0, i());
            }, a.onabort = function() {
              e(-1);
            };
            var s = a.objectStore("versions").get(t);
            s.onsuccess = function(l) {
              r = l.target.result;
            }, s.onerror = function() {
              q.Error("Error loading version for scene " + t + " from DB."), e(-1);
            };
          } catch (l) {
            q.Error("Error while accessing 'versions' object store (READ OP). Exception: " + l.message), e(-1);
          }
        else
          q.Error("Error: IndexedDB not supported by your browser or Babylon.js database is not open."), e(-1);
      }, n.prototype._saveVersionIntoDBAsync = function(t, e) {
        var i = this;
        if (this._isSupported && !this._hasReachedQuota && this._db)
          try {
            var r = this._db.transaction(["versions"], "readwrite");
            r.onabort = function(s) {
              try {
                var l = s.target.error;
                l && l.name === "QuotaExceededError" && (i._hasReachedQuota = !0);
              } catch {
              }
              e(-1);
            }, r.oncomplete = function() {
              e(i._manifestVersionFound);
            };
            var o = { sceneUrl: t, data: this._manifestVersionFound }, a = r.objectStore("versions").put(o);
            a.onsuccess = function() {
            }, a.onerror = function() {
              q.Error("Error in DB add version request in BABYLON.Database.");
            };
          } catch (s) {
            q.Error("Error while accessing 'versions' object store (WRITE OP). Exception: " + s.message), e(-1);
          }
        else
          e(-1);
      }, n.prototype.loadFile = function(t, e, i, r, o) {
        var a = this, s = n._ReturnFullUrlLocation(t), l = function() {
          a._saveFileAsync(s, e, i, o, r);
        };
        this._checkVersionFromDB(s, function(c) {
          c !== -1 ? a._mustUpdateRessources ? a._saveFileAsync(s, e, i, o, r) : a._loadFileAsync(s, e, l) : r && r();
        });
      }, n.prototype._loadFileAsync = function(t, e, i) {
        if (this._isSupported && this._db) {
          var r, o;
          o = t.indexOf(".babylon") !== -1 ? "scenes" : "textures";
          var a = this._db.transaction([o]);
          a.oncomplete = function() {
            r ? e(r.data) : i();
          }, a.onabort = function() {
            i();
          };
          var s = a.objectStore(o).get(t);
          s.onsuccess = function(l) {
            r = l.target.result;
          }, s.onerror = function() {
            q.Error("Error loading file " + t + " from DB."), i();
          };
        } else
          q.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."), e();
      }, n.prototype._saveFileAsync = function(t, e, i, r, o) {
        var a = this;
        if (this._isSupported) {
          var s;
          s = t.indexOf(".babylon") !== -1 ? "scenes" : "textures";
          var l, c = new _n();
          c.open("GET", t + (t.match(/\?/) == null ? "?" : "&") + Date.now()), r && (c.responseType = "arraybuffer"), i && (c.onprogress = i), c.addEventListener("load", function() {
            if (c.status === 200 || c.status < 400 && n._ValidateXHRData(c, r ? 6 : 1))
              if (l = r ? c.response : c.responseText, !a._hasReachedQuota && a._db) {
                var u = a._db.transaction([s], "readwrite");
                u.onabort = function(p) {
                  try {
                    var f = p.target.error;
                    f && f.name === "QuotaExceededError" && (a._hasReachedQuota = !0);
                  } catch {
                  }
                  e(l);
                }, u.oncomplete = function() {
                  e(l);
                };
                var h;
                h = s === "scenes" ? { sceneUrl: t, data: l, version: a._manifestVersionFound } : { textureUrl: t, data: l };
                try {
                  var d = u.objectStore(s).put(h);
                  d.onsuccess = function() {
                  }, d.onerror = function() {
                    q.Error("Error in DB add file request in BABYLON.Database.");
                  };
                } catch {
                  e(l);
                }
              } else
                e(l);
            else
              c.status >= 400 && o ? o(c) : e();
          }, !1), c.addEventListener("error", function() {
            q.Error("error on XHR request."), o && o();
          }, !1), c.send();
        } else
          q.Error("Error: IndexedDB not supported by your browser or Babylon.js database is not open."), o && o();
      }, n._ValidateXHRData = function(t, e) {
        e === void 0 && (e = 7);
        try {
          if (1 & e) {
            if (t.responseText && t.responseText.length > 0)
              return !0;
            if (e === 1)
              return !1;
          }
          if (2 & e) {
            var i = au(t.response);
            if (i.width && i.height && i.width > 0 && i.height > 0)
              return !0;
            if (e === 2)
              return !1;
          }
          if (4 & e) {
            var r = new Uint8Array(t.response, 0, 3);
            return r[0] === 68 && r[1] === 68 && r[2] === 83;
          }
        } catch {
        }
        return !1;
      }, n._IsUASupportingBlobStorage = !0, n.IDBStorageEnabled = !1, n._ParseURL = function(t) {
        document.createElement("a").href = t;
        var e = t.substring(0, t.lastIndexOf("#")), i = t.substring(e.lastIndexOf("/") + 1, t.length);
        return t.substring(0, t.indexOf(i, 0));
      }, n._ReturnFullUrlLocation = function(t) {
        return t.indexOf("http:/") === -1 && t.indexOf("https:/") === -1 && typeof window < "u" ? n._ParseURL(window.location.href) + t : t;
      }, n;
    }(), OP = function() {
      function n(t) {
        this._isUbo(t) ? (this.setMatrix3x3 = t.updateMatrix3x3.bind(t), this.setMatrix2x2 = t.updateMatrix2x2.bind(t), this.setFloat = t.updateFloat.bind(t), this.setFloat2 = t.updateFloat2.bind(t), this.setFloat3 = t.updateFloat3.bind(t), this.setFloat4 = t.updateFloat4.bind(t), this.setFloatArray = t.updateFloatArray.bind(t), this.setArray = t.updateArray.bind(t), this.setIntArray = t.updateIntArray.bind(t), this.setMatrix = t.updateMatrix.bind(t), this.setMatrices = t.updateMatrices.bind(t), this.setVector3 = t.updateVector3.bind(t), this.setVector4 = t.updateVector4.bind(t), this.setColor3 = t.updateColor3.bind(t), this.setColor4 = t.updateColor4.bind(t), this.setDirectColor4 = t.updateDirectColor4.bind(t), this.setInt = t.updateInt.bind(t), this.setInt2 = t.updateInt2.bind(t), this.setInt3 = t.updateInt3.bind(t), this.setInt4 = t.updateInt4.bind(t)) : (this.setMatrix3x3 = t.setMatrix3x3.bind(t), this.setMatrix2x2 = t.setMatrix2x2.bind(t), this.setFloat = t.setFloat.bind(t), this.setFloat2 = t.setFloat2.bind(t), this.setFloat3 = t.setFloat3.bind(t), this.setFloat4 = t.setFloat4.bind(t), this.setFloatArray = t.setFloatArray.bind(t), this.setArray = t.setArray.bind(t), this.setIntArray = t.setIntArray.bind(t), this.setMatrix = t.setMatrix.bind(t), this.setMatrices = t.setMatrices.bind(t), this.setVector3 = t.setVector3.bind(t), this.setVector4 = t.setVector4.bind(t), this.setColor3 = t.setColor3.bind(t), this.setColor4 = t.setColor4.bind(t), this.setDirectColor4 = t.setDirectColor4.bind(t), this.setInt = t.setInt.bind(t), this.setInt2 = t.setInt2.bind(t), this.setInt3 = t.setInt3.bind(t), this.setInt4 = t.setInt4.bind(t));
      }
      return n.prototype._isUbo = function(t) {
        return t.addUniform !== void 0;
      }, n;
    }();
    re.ShadersStore.gpuUpdateParticlesPixelShader = `#version 300 es
void main() {discard;}
`, re.ShadersStore.gpuUpdateParticlesVertexShader = `#version 300 es
#define PI 3.14159
uniform float currentCount;uniform float timeDelta;uniform float stopFactor;
#ifndef LOCAL
uniform mat4 emitterWM;
#endif
uniform vec2 lifeTime;uniform vec2 emitPower;uniform vec2 sizeRange;uniform vec4 scaleRange;
#ifndef COLORGRADIENTS
uniform vec4 color1;uniform vec4 color2;
#endif
uniform vec3 gravity;uniform sampler2D randomSampler;uniform sampler2D randomSampler2;uniform vec4 angleRange;
#ifdef BOXEMITTER
uniform vec3 direction1;uniform vec3 direction2;uniform vec3 minEmitBox;uniform vec3 maxEmitBox;
#endif
#ifdef POINTEMITTER
uniform vec3 direction1;uniform vec3 direction2;
#endif
#ifdef HEMISPHERICEMITTER
uniform float radius;uniform float radiusRange;uniform float directionRandomizer;
#endif
#ifdef SPHEREEMITTER
uniform float radius;uniform float radiusRange;
#ifdef DIRECTEDSPHEREEMITTER
uniform vec3 direction1;uniform vec3 direction2;
#else
uniform float directionRandomizer;
#endif
#endif
#ifdef CYLINDEREMITTER
uniform float radius;uniform float height;uniform float radiusRange;
#ifdef DIRECTEDCYLINDEREMITTER
uniform vec3 direction1;uniform vec3 direction2;
#else
uniform float directionRandomizer;
#endif
#endif
#ifdef CONEEMITTER
uniform vec2 radius;uniform float coneAngle;uniform vec2 height;uniform float directionRandomizer;
#endif
in vec3 position;
#ifdef CUSTOMEMITTER
in vec3 initialPosition;
#endif
in float age;in float life;in vec4 seed;in vec3 size;
#ifndef COLORGRADIENTS
in vec4 color;
#endif
in vec3 direction;
#ifndef BILLBOARD
in vec3 initialDirection;
#endif
#ifdef ANGULARSPEEDGRADIENTS
in float angle;
#else
in vec2 angle;
#endif
#ifdef ANIMATESHEET
in float cellIndex;
#ifdef ANIMATESHEETRANDOMSTART
in float cellStartOffset;
#endif
#endif
#ifdef NOISE
in vec3 noiseCoordinates1;in vec3 noiseCoordinates2;
#endif
out vec3 outPosition;
#ifdef CUSTOMEMITTER
out vec3 outInitialPosition;
#endif
out float outAge;out float outLife;out vec4 outSeed;out vec3 outSize;
#ifndef COLORGRADIENTS
out vec4 outColor;
#endif
out vec3 outDirection;
#ifndef BILLBOARD
out vec3 outInitialDirection;
#endif
#ifdef ANGULARSPEEDGRADIENTS
out float outAngle;
#else
out vec2 outAngle;
#endif
#ifdef ANIMATESHEET
out float outCellIndex;
#ifdef ANIMATESHEETRANDOMSTART
out float outCellStartOffset;
#endif
#endif
#ifdef NOISE
out vec3 outNoiseCoordinates1;out vec3 outNoiseCoordinates2;
#endif
#ifdef SIZEGRADIENTS
uniform sampler2D sizeGradientSampler;
#endif 
#ifdef ANGULARSPEEDGRADIENTS
uniform sampler2D angularSpeedGradientSampler;
#endif 
#ifdef VELOCITYGRADIENTS
uniform sampler2D velocityGradientSampler;
#endif
#ifdef LIMITVELOCITYGRADIENTS
uniform sampler2D limitVelocityGradientSampler;uniform float limitVelocityDamping;
#endif
#ifdef DRAGGRADIENTS
uniform sampler2D dragGradientSampler;
#endif
#ifdef NOISE
uniform vec3 noiseStrength;uniform sampler2D noiseSampler;
#endif
#ifdef ANIMATESHEET
uniform vec4 cellInfos;
#endif
vec3 getRandomVec3(float offset) {return texture(randomSampler2,vec2(float(gl_VertexID)*offset/currentCount,0)).rgb;}
vec4 getRandomVec4(float offset) {return texture(randomSampler,vec2(float(gl_VertexID)*offset/currentCount,0));}
void main() {float newAge=age+timeDelta; 
if (newAge>=life && stopFactor != 0.) {vec3 newPosition;vec3 newDirection;vec4 randoms=getRandomVec4(seed.x);outLife=lifeTime.x+(lifeTime.y-lifeTime.x)*randoms.r;outAge=newAge-life;outSeed=seed;
#ifdef SIZEGRADIENTS 
outSize.x=texture(sizeGradientSampler,vec2(0,0)).r;
#else
outSize.x=sizeRange.x+(sizeRange.y-sizeRange.x)*randoms.g;
#endif
outSize.y=scaleRange.x+(scaleRange.y-scaleRange.x)*randoms.b;outSize.z=scaleRange.z+(scaleRange.w-scaleRange.z)*randoms.a; 
#ifndef COLORGRADIENTS
outColor=color1+(color2-color1)*randoms.b;
#endif
#ifndef ANGULARSPEEDGRADIENTS 
outAngle.y=angleRange.x+(angleRange.y-angleRange.x)*randoms.a;outAngle.x=angleRange.z+(angleRange.w-angleRange.z)*randoms.r;
#else
outAngle=angleRange.z+(angleRange.w-angleRange.z)*randoms.r;
#endif 
#ifdef POINTEMITTER
vec3 randoms2=getRandomVec3(seed.y);vec3 randoms3=getRandomVec3(seed.z);newPosition=vec3(0,0,0);newDirection=direction1+(direction2-direction1)*randoms3;
#elif defined(BOXEMITTER)
vec3 randoms2=getRandomVec3(seed.y);vec3 randoms3=getRandomVec3(seed.z);newPosition=minEmitBox+(maxEmitBox-minEmitBox)*randoms2;newDirection=direction1+(direction2-direction1)*randoms3; 
#elif defined(HEMISPHERICEMITTER)
vec3 randoms2=getRandomVec3(seed.y);vec3 randoms3=getRandomVec3(seed.z);float phi=2.0*PI*randoms2.x;float theta=acos(2.0*randoms2.y-1.0);float randX=cos(phi)*sin(theta);float randY=cos(theta);float randZ=sin(phi)*sin(theta);newPosition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,abs(randY),randZ);newDirection=newPosition+directionRandomizer*randoms3; 
#elif defined(SPHEREEMITTER)
vec3 randoms2=getRandomVec3(seed.y);vec3 randoms3=getRandomVec3(seed.z);float phi=2.0*PI*randoms2.x;float theta=acos(2.0*randoms2.y-1.0);float randX=cos(phi)*sin(theta);float randY=cos(theta);float randZ=sin(phi)*sin(theta);newPosition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,randY,randZ);
#ifdef DIRECTEDSPHEREEMITTER
newDirection=normalize(direction1+(direction2-direction1)*randoms3);
#else
newDirection=normalize(newPosition+directionRandomizer*randoms3);
#endif
#elif defined(CYLINDEREMITTER)
vec3 randoms2=getRandomVec3(seed.y);vec3 randoms3=getRandomVec3(seed.z);float yPos=(randoms2.x-0.5)*height;float angle=randoms2.y*PI*2.;float inverseRadiusRangeSquared=((1.-radiusRange)*(1.-radiusRange));float positionRadius=radius*sqrt(inverseRadiusRangeSquared+(randoms2.z*(1.-inverseRadiusRangeSquared)));float xPos=positionRadius*cos(angle);float zPos=positionRadius*sin(angle);newPosition=vec3(xPos,yPos,zPos);
#ifdef DIRECTEDCYLINDEREMITTER
newDirection=direction1+(direction2-direction1)*randoms3;
#else
angle=angle+((randoms3.x-0.5)*PI)*directionRandomizer;newDirection=vec3(cos(angle),(randoms3.y-0.5)*directionRandomizer,sin(angle));newDirection=normalize(newDirection);
#endif
#elif defined(CONEEMITTER)
vec3 randoms2=getRandomVec3(seed.y);float s=2.0*PI*randoms2.x;
#ifdef CONEEMITTERSPAWNPOINT
float h=0.0001;
#else
float h=randoms2.y*height.y;h=1.-h*h; 
#endif
float lRadius=radius.x-radius.x*randoms2.z*radius.y;lRadius=lRadius*h;float randX=lRadius*sin(s);float randZ=lRadius*cos(s);float randY=h *height.x;newPosition=vec3(randX,randY,randZ); 
if (abs(cos(coneAngle))==1.0) {newDirection=vec3(0.,1.0,0.);} else {vec3 randoms3=getRandomVec3(seed.z);newDirection=normalize(newPosition+directionRandomizer*randoms3); }
#elif defined(CUSTOMEMITTER)
newPosition=initialPosition;outInitialPosition=initialPosition;
#else 
newPosition=vec3(0.,0.,0.);newDirection=2.0*(getRandomVec3(seed.w)-vec3(0.5,0.5,0.5));
#endif
float power=emitPower.x+(emitPower.y-emitPower.x)*randoms.a;
#ifdef LOCAL
outPosition=newPosition;
#else
outPosition=(emitterWM*vec4(newPosition,1.)).xyz;
#endif
#ifdef CUSTOMEMITTER
outDirection=direction;
#ifndef BILLBOARD 
outInitialDirection=direction;
#endif
#else
#ifdef LOCAL
vec3 initial=newDirection;
#else 
vec3 initial=(emitterWM*vec4(newDirection,0.)).xyz;
#endif
outDirection=initial*power;
#ifndef BILLBOARD 
outInitialDirection=initial;
#endif
#endif
#ifdef ANIMATESHEET 
outCellIndex=cellInfos.x;
#ifdef ANIMATESHEETRANDOMSTART
outCellStartOffset=randoms.a*outLife;
#endif 
#endif
#ifdef NOISE
outNoiseCoordinates1=noiseCoordinates1;outNoiseCoordinates2=noiseCoordinates2;
#endif
} else {float directionScale=timeDelta;outAge=newAge;float ageGradient=newAge/life;
#ifdef VELOCITYGRADIENTS
directionScale*=texture(velocityGradientSampler,vec2(ageGradient,0)).r;
#endif
#ifdef DRAGGRADIENTS
directionScale*=1.0-texture(dragGradientSampler,vec2(ageGradient,0)).r;
#endif
#if defined(CUSTOMEMITTER)
outPosition=position+(direction-position)*ageGradient; 
outInitialPosition=initialPosition;
#else
outPosition=position+direction*directionScale;
#endif
outLife=life;outSeed=seed;
#ifndef COLORGRADIENTS 
outColor=color;
#endif
#ifdef SIZEGRADIENTS
outSize.x=texture(sizeGradientSampler,vec2(ageGradient,0)).r;outSize.yz=size.yz;
#else
outSize=size;
#endif 
#ifndef BILLBOARD 
outInitialDirection=initialDirection;
#endif
#ifdef CUSTOMEMITTER
outDirection=direction;
#else
vec3 updatedDirection=direction+gravity*timeDelta;
#ifdef LIMITVELOCITYGRADIENTS
float limitVelocity=texture(limitVelocityGradientSampler,vec2(ageGradient,0)).r;float currentVelocity=length(updatedDirection);if (currentVelocity>limitVelocity) {updatedDirection=updatedDirection*limitVelocityDamping;}
#endif
outDirection=updatedDirection;
#ifdef NOISE
float fetchedR=texture(noiseSampler,vec2(noiseCoordinates1.x,noiseCoordinates1.y)*vec2(0.5)+vec2(0.5)).r;float fetchedG=texture(noiseSampler,vec2(noiseCoordinates1.z,noiseCoordinates2.x)*vec2(0.5)+vec2(0.5)).r;float fetchedB=texture(noiseSampler,vec2(noiseCoordinates2.y,noiseCoordinates2.z)*vec2(0.5)+vec2(0.5)).r;vec3 force=vec3(2.*fetchedR-1.,2.*fetchedG-1.,2.*fetchedB-1.)*noiseStrength;outDirection=outDirection+force*timeDelta;outNoiseCoordinates1=noiseCoordinates1;outNoiseCoordinates2=noiseCoordinates2;
#endif 
#endif 
#ifdef ANGULARSPEEDGRADIENTS
float angularSpeed=texture(angularSpeedGradientSampler,vec2(ageGradient,0)).r;outAngle=angle+angularSpeed*timeDelta;
#else
outAngle=vec2(angle.x+angle.y*timeDelta,angle.y);
#endif
#ifdef ANIMATESHEET 
float offsetAge=outAge;float dist=cellInfos.y-cellInfos.x;
#ifdef ANIMATESHEETRANDOMSTART
outCellStartOffset=cellStartOffset;offsetAge+=cellStartOffset;
#else
float cellStartOffset=0.;
#endif 
float ratio=0.;if (cellInfos.w==1.0) {ratio=clamp(mod(cellStartOffset+cellInfos.z*offsetAge,life)/life,0.,1.0);}
else {ratio=clamp(cellStartOffset+cellInfos.z*offsetAge/life,0.,1.0);}
outCellIndex=float(int(cellInfos.x+ratio*dist));
#endif
}}`;
    var W0 = function() {
      function n(t, e) {
        this._renderVAO = [], this._updateVAO = [], this.alignDataInBuffer = !1, this._parent = t, this._engine = e, this._updateEffectOptions = { attributes: ["position", "initialPosition", "age", "life", "seed", "size", "color", "direction", "initialDirection", "angle", "cellIndex", "cellStartOffset", "noiseCoordinates1", "noiseCoordinates2"], uniformsNames: ["currentCount", "timeDelta", "emitterWM", "lifeTime", "color1", "color2", "sizeRange", "scaleRange", "gravity", "emitPower", "direction1", "direction2", "minEmitBox", "maxEmitBox", "radius", "directionRandomizer", "height", "coneAngle", "stopFactor", "angleRange", "radiusRange", "cellInfos", "noiseStrength", "limitVelocityDamping"], uniformBuffersNames: [], samplers: ["randomSampler", "randomSampler2", "sizeGradientSampler", "angularSpeedGradientSampler", "velocityGradientSampler", "limitVelocityGradientSampler", "noiseSampler", "dragGradientSampler"], defines: "", fallbacks: null, onCompiled: null, onError: null, indexParameters: null, maxSimultaneousLights: 0, transformFeedbackVaryings: [] };
      }
      return n.prototype.contextLost = function() {
        this._updateEffect = void 0, this._renderVAO.length = 0, this._updateVAO.length = 0;
      }, n.prototype.isUpdateBufferCreated = function() {
        return !!this._updateEffect;
      }, n.prototype.isUpdateBufferReady = function() {
        var t, e;
        return (e = (t = this._updateEffect) === null || t === void 0 ? void 0 : t.isReady()) !== null && e !== void 0 && e;
      }, n.prototype.createUpdateBuffer = function(t) {
        return this._updateEffectOptions.transformFeedbackVaryings = ["outPosition"], this._updateEffectOptions.transformFeedbackVaryings.push("outAge"), this._updateEffectOptions.transformFeedbackVaryings.push("outSize"), this._updateEffectOptions.transformFeedbackVaryings.push("outLife"), this._updateEffectOptions.transformFeedbackVaryings.push("outSeed"), this._updateEffectOptions.transformFeedbackVaryings.push("outDirection"), this._parent.particleEmitterType instanceof ml && this._updateEffectOptions.transformFeedbackVaryings.push("outInitialPosition"), this._parent._colorGradientsTexture || this._updateEffectOptions.transformFeedbackVaryings.push("outColor"), this._parent._isBillboardBased || this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection"), this._parent.noiseTexture && (this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1"), this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2")), this._updateEffectOptions.transformFeedbackVaryings.push("outAngle"), this._parent.isAnimationSheetEnabled && (this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex"), this._parent.spriteRandomStartCell && this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset")), this._updateEffectOptions.defines = t, this._updateEffect = new Jt("gpuUpdateParticles", this._updateEffectOptions, this._engine), new OP(this._updateEffect);
      }, n.prototype.createVertexBuffers = function(t, e) {
        this._updateVAO.push(this._createUpdateVAO(t)), this._renderVAO.push(this._engine.recordVertexArrayObject(e, null, this._parent._getWrapper(this._parent.blendMode).effect)), this._engine.bindArrayBuffer(null), this._renderVertexBuffers = e;
      }, n.prototype.createParticleBuffer = function(t) {
        return t;
      }, n.prototype.bindDrawBuffers = function(t, e, i) {
        i ? this._engine.bindBuffers(this._renderVertexBuffers, i, e) : this._engine.bindVertexArrayObject(this._renderVAO[t], null);
      }, n.prototype.preUpdateParticleBuffer = function() {
        var t = this._engine;
        if (this._engine.enableEffect(this._updateEffect), !t.setState)
          throw new Error("GPU particles cannot work without a full Engine. ThinEngine is not supported");
      }, n.prototype.updateParticleBuffer = function(t, e, i) {
        this._updateEffect.setTexture("randomSampler", this._parent._randomTexture), this._updateEffect.setTexture("randomSampler2", this._parent._randomTexture2), this._parent._sizeGradientsTexture && this._updateEffect.setTexture("sizeGradientSampler", this._parent._sizeGradientsTexture), this._parent._angularSpeedGradientsTexture && this._updateEffect.setTexture("angularSpeedGradientSampler", this._parent._angularSpeedGradientsTexture), this._parent._velocityGradientsTexture && this._updateEffect.setTexture("velocityGradientSampler", this._parent._velocityGradientsTexture), this._parent._limitVelocityGradientsTexture && this._updateEffect.setTexture("limitVelocityGradientSampler", this._parent._limitVelocityGradientsTexture), this._parent._dragGradientsTexture && this._updateEffect.setTexture("dragGradientSampler", this._parent._dragGradientsTexture), this._parent.noiseTexture && this._updateEffect.setTexture("noiseSampler", this._parent.noiseTexture), this._engine.bindVertexArrayObject(this._updateVAO[t], null);
        var r = this._engine;
        r.bindTransformFeedbackBuffer(e.getBuffer()), r.setRasterizerState(!1), r.beginTransformFeedback(!0), r.drawArraysType(_.MATERIAL_PointListDrawMode, 0, i), r.endTransformFeedback(), r.setRasterizerState(!0), r.bindTransformFeedbackBuffer(null);
      }, n.prototype.releaseBuffers = function() {
      }, n.prototype.releaseVertexBuffers = function() {
        for (var t = 0; t < this._updateVAO.length; t++)
          this._engine.releaseVertexArrayObject(this._updateVAO[t]);
        for (this._updateVAO.length = 0, t = 0; t < this._renderVAO.length; t++)
          this._engine.releaseVertexArrayObject(this._renderVAO[t]);
        this._renderVAO.length = 0;
      }, n.prototype._createUpdateVAO = function(t) {
        var e = {};
        e.position = t.createVertexBuffer("position", 0, 3);
        var i = 3;
        e.age = t.createVertexBuffer("age", i, 1), i += 1, e.size = t.createVertexBuffer("size", i, 3), i += 3, e.life = t.createVertexBuffer("life", i, 1), i += 1, e.seed = t.createVertexBuffer("seed", i, 4), i += 4, e.direction = t.createVertexBuffer("direction", i, 3), i += 3, this._parent.particleEmitterType instanceof ml && (e.initialPosition = t.createVertexBuffer("initialPosition", i, 3), i += 3), this._parent._colorGradientsTexture || (e.color = t.createVertexBuffer("color", i, 4), i += 4), this._parent._isBillboardBased || (e.initialDirection = t.createVertexBuffer("initialDirection", i, 3), i += 3), this._parent.noiseTexture && (e.noiseCoordinates1 = t.createVertexBuffer("noiseCoordinates1", i, 3), i += 3, e.noiseCoordinates2 = t.createVertexBuffer("noiseCoordinates2", i, 3), i += 3), this._parent._angularSpeedGradientsTexture ? (e.angle = t.createVertexBuffer("angle", i, 1), i += 1) : (e.angle = t.createVertexBuffer("angle", i, 2), i += 2), this._parent._isAnimationSheetEnabled && (e.cellIndex = t.createVertexBuffer("cellIndex", i, 1), i += 1, this._parent.spriteRandomStartCell && (e.cellStartOffset = t.createVertexBuffer("cellStartOffset", i, 1), i += 1));
        var r = this._engine.recordVertexArrayObject(e, null, this._updateEffect);
        return this._engine.bindArrayBuffer(null), r;
      }, n;
    }();
    j("BABYLON.WebGL2ParticleSystem", W0), re.ShadersStoreWGSL.gpuUpdateParticlesComputeShader = `struct Particle {position : vec3<f32>,
age : f32,
size : vec3<f32>,
life : f32,
seed : vec4<f32>,
direction : vec3<f32>,
dummy0: f32,
#ifdef CUSTOMEMITTER
initialPosition : vec3<f32>,
dummy1: f32,
#endif
#ifndef COLORGRADIENTS
color : vec4<f32>,
#endif
#ifndef BILLBOARD
initialDirection : vec3<f32>,
dummy2: f32,
#endif
#ifdef NOISE
noiseCoordinates1 : vec3<f32>,
dummy3: f32,
noiseCoordinates2 : vec3<f32>,
dummy4: f32,
#endif
#ifdef ANGULARSPEEDGRADIENTS
angle : f32,
#else
angle : vec2<f32>,
#endif
#ifdef ANIMATESHEET
cellIndex : f32,
#ifdef ANIMATESHEETRANDOMSTART
cellStartOffset : f32,
#endif
#endif
};struct Particles {particles : array<Particle>,};struct SimParams {currentCount : f32,
timeDelta : f32,
stopFactor : f32,
randomTextureSize: i32,
lifeTime : vec2<f32>,
emitPower : vec2<f32>,
#ifndef COLORGRADIENTS
color1 : vec4<f32>,
color2 : vec4<f32>,
#endif
sizeRange : vec2<f32>,
scaleRange : vec4<f32>,
angleRange : vec4<f32>,
gravity : vec3<f32>,
#ifdef LIMITVELOCITYGRADIENTS
limitVelocityDamping : f32,
#endif
#ifdef ANIMATESHEET
cellInfos : vec4<f32>,
#endif
#ifdef NOISE
noiseStrength : vec3<f32>,
#endif
#ifndef LOCAL
emitterWM : mat4x4<f32>,
#endif
#ifdef BOXEMITTER
direction1 : vec3<f32>,
direction2 : vec3<f32>,
minEmitBox : vec3<f32>,
maxEmitBox : vec3<f32>,
#endif
#ifdef CONEEMITTER
radius : vec2<f32>,
coneAngle : f32,
height : vec2<f32>,
directionRandomizer : f32,
#endif
#ifdef CYLINDEREMITTER
radius : f32,
height : f32,
radiusRange : f32,
#ifdef DIRECTEDCYLINDEREMITTER
direction1 : vec3<f32>,
direction2 : vec3<f32>,
#else
directionRandomizer : f32,
#endif
#endif
#ifdef HEMISPHERICEMITTER
radius : f32,
radiusRange : f32,
directionRandomizer : f32,
#endif
#ifdef POINTEMITTER
direction1 : vec3<f32>,
direction2 : vec3<f32>,
#endif
#ifdef SPHEREEMITTER
radius : f32,
radiusRange : f32,
#ifdef DIRECTEDSPHEREEMITTER
direction1 : vec3<f32>,
direction2 : vec3<f32>,
#else
directionRandomizer : f32,
#endif
#endif
};@binding(0) @group(0) var<uniform> params : SimParams;@binding(1) @group(0) var<storage,read> particlesIn : Particles;@binding(2) @group(0) var<storage,read_write> particlesOut : Particles;@binding(3) @group(0) var randomTexture : texture_2d<f32>;@binding(4) @group(0) var randomTexture2 : texture_2d<f32>;
#ifdef SIZEGRADIENTS
@binding(0) @group(1) var sizeGradientSampler : sampler;@binding(1) @group(1) var sizeGradientTexture : texture_2d<f32>;
#endif 
#ifdef ANGULARSPEEDGRADIENTS
@binding(2) @group(1) var angularSpeedGradientSampler : sampler;@binding(3) @group(1) var angularSpeedGradientTexture : texture_2d<f32>;
#endif 
#ifdef VELOCITYGRADIENTS
@binding(4) @group(1) var velocityGradientSampler : sampler;@binding(5) @group(1) var velocityGradientTexture : texture_2d<f32>;
#endif
#ifdef LIMITVELOCITYGRADIENTS
@binding(6) @group(1) var limitVelocityGradientSampler : sampler;@binding(7) @group(1) var limitVelocityGradientTexture : texture_2d<f32>;
#endif
#ifdef DRAGGRADIENTS
@binding(8) @group(1) var dragGradientSampler : sampler;@binding(9) @group(1) var dragGradientTexture : texture_2d<f32>;
#endif
#ifdef NOISE
@binding(10) @group(1) var noiseSampler : sampler;@binding(11) @group(1) var noiseTexture : texture_2d<f32>;
#endif
fn getRandomVec3(offset : f32,vertexID : f32)->vec3<f32> {return textureLoad(randomTexture2,vec2<i32>(i32(vertexID*offset/params.currentCount*f32(params.randomTextureSize)) % params.randomTextureSize,0),0).rgb;}
fn getRandomVec4(offset : f32,vertexID : f32)->vec4<f32> {return textureLoad(randomTexture,vec2<i32>(i32(vertexID*offset/params.currentCount*f32(params.randomTextureSize)) % params.randomTextureSize,0),0);}
@compute @workgroup_size(64)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {let index : u32=GlobalInvocationID.x;let vertexID : f32=f32(index);if (index>=u32(params.currentCount)) {return;}
let PI : f32=3.14159;let timeDelta : f32=params.timeDelta;let newAge : f32=particlesIn.particles[index].age+timeDelta;let life : f32=particlesIn.particles[index].life;let seed : vec4<f32>=particlesIn.particles[index].seed;let direction : vec3<f32>=particlesIn.particles[index].direction;if (newAge>=life && params.stopFactor != 0.) {var newPosition : vec3<f32>;var newDirection : vec3<f32>;let randoms : vec4<f32>=getRandomVec4(seed.x,vertexID);let outLife : f32=params.lifeTime.x+(params.lifeTime.y-params.lifeTime.x)*randoms.r;particlesOut.particles[index].life=outLife;particlesOut.particles[index].age=newAge-life;particlesOut.particles[index].seed=seed;var sizex : f32;
#ifdef SIZEGRADIENTS 
sizex=textureSampleLevel(sizeGradientTexture,sizeGradientSampler,vec2<f32>(0.,0.),0.).r;
#else
sizex=params.sizeRange.x+(params.sizeRange.y-params.sizeRange.x)*randoms.g;
#endif
particlesOut.particles[index].size=vec3<f32>(
sizex,
params.scaleRange.x+(params.scaleRange.y-params.scaleRange.x)*randoms.b,
params.scaleRange.z+(params.scaleRange.w-params.scaleRange.z)*randoms.a);
#ifndef COLORGRADIENTS
particlesOut.particles[index].color=params.color1+(params.color2-params.color1)*randoms.b;
#endif
#ifndef ANGULARSPEEDGRADIENTS 
particlesOut.particles[index].angle=vec2<f32>(
params.angleRange.z+(params.angleRange.w-params.angleRange.z)*randoms.r,
params.angleRange.x+(params.angleRange.y-params.angleRange.x)*randoms.a);
#else
particlesOut.particles[index].angle=params.angleRange.z+(params.angleRange.w-params.angleRange.z)*randoms.r;
#endif 
#if defined(POINTEMITTER)
let randoms2 : vec3<f32>=getRandomVec3(seed.y,vertexID);let randoms3 : vec3<f32>=getRandomVec3(seed.z,vertexID);newPosition=vec3<f32>(0.,0.,0.);newDirection=params.direction1+(params.direction2-params.direction1)*randoms3;
#elif defined(BOXEMITTER)
let randoms2 : vec3<f32>=getRandomVec3(seed.y,vertexID);let randoms3 : vec3<f32>=getRandomVec3(seed.z,vertexID);newPosition=params.minEmitBox+(params.maxEmitBox-params.minEmitBox)*randoms2;newDirection=params.direction1+(params.direction2-params.direction1)*randoms3; 
#elif defined(HEMISPHERICEMITTER)
let randoms2 : vec3<f32>=getRandomVec3(seed.y,vertexID);let randoms3 : vec3<f32>=getRandomVec3(seed.z,vertexID);let phi : f32=2.0*PI*randoms2.x;let theta : f32=acos(-1.0+2.0*randoms2.y);let randX : f32=cos(phi)*sin(theta);let randY : f32=cos(theta);let randZ : f32=sin(phi)*sin(theta);newPosition=(params.radius-(params.radius*params.radiusRange*randoms2.z))*vec3<f32>(randX,abs(randY),randZ);newDirection=normalize(newPosition+params.directionRandomizer*randoms3);
#elif defined(SPHEREEMITTER)
let randoms2 : vec3<f32>=getRandomVec3(seed.y,vertexID);let randoms3 : vec3<f32>=getRandomVec3(seed.z,vertexID);let phi : f32=2.0*PI*randoms2.x;let theta : f32=acos(-1.0+2.0*randoms2.y);let randX : f32=cos(phi)*sin(theta);let randY : f32=cos(theta);let randZ : f32=sin(phi)*sin(theta);newPosition=(params.radius-(params.radius*params.radiusRange*randoms2.z))*vec3<f32>(randX,randY,randZ);
#ifdef DIRECTEDSPHEREEMITTER
newDirection=normalize(params.direction1+(params.direction2-params.direction1)*randoms3);
#else
newDirection=normalize(newPosition+params.directionRandomizer*randoms3);
#endif
#elif defined(CYLINDEREMITTER)
let randoms2 : vec3<f32>=getRandomVec3(seed.y,vertexID);let randoms3 : vec3<f32>=getRandomVec3(seed.z,vertexID);let yPos : f32=(-0.5+randoms2.x)*params.height;var angle : f32=randoms2.y*PI*2.;let inverseRadiusRangeSquared : f32=(1.-params.radiusRange)*(1.-params.radiusRange);let positionRadius : f32=params.radius*sqrt(inverseRadiusRangeSquared+randoms2.z*(1.-inverseRadiusRangeSquared));let xPos : f32=positionRadius*cos(angle);let zPos : f32=positionRadius*sin(angle);newPosition=vec3<f32>(xPos,yPos,zPos);
#ifdef DIRECTEDCYLINDEREMITTER
newDirection=params.direction1+(params.direction2-params.direction1)*randoms3;
#else
angle=angle+(-0.5+randoms3.x)*PI*params.directionRandomizer;newDirection=vec3<f32>(cos(angle),(-0.5+randoms3.y)*params.directionRandomizer,sin(angle));newDirection=normalize(newDirection);
#endif
#elif defined(CONEEMITTER)
let randoms2 : vec3<f32>=getRandomVec3(seed.y,vertexID);let s : f32=2.0*PI*randoms2.x;
#ifdef CONEEMITTERSPAWNPOINT
let h : f32=0.0001;
#else
var h : f32=randoms2.y*params.height.y;h=1.-h*h; 
#endif
var lRadius : f32=params.radius.x-params.radius.x*randoms2.z*params.radius.y;lRadius=lRadius*h;let randX : f32=lRadius*sin(s);let randZ : f32=lRadius*cos(s);let randY : f32=h *params.height.x;newPosition=vec3<f32>(randX,randY,randZ); 
if (abs(cos(params.coneAngle))==1.0) {newDirection=vec3<f32>(0.,1.0,0.);} else {let randoms3 : vec3<f32>=getRandomVec3(seed.z,vertexID);newDirection=normalize(newPosition+params.directionRandomizer*randoms3); }
#elif defined(CUSTOMEMITTER)
newPosition=particlesIn.particles[index].initialPosition;particlesOut.particles[index].initialPosition=newPosition;
#else 
newPosition=vec3<f32>(0.,0.,0.);newDirection=2.0*(getRandomVec3(seed.w,vertexID)-vec3<f32>(0.5,0.5,0.5));
#endif
let power : f32=params.emitPower.x+(params.emitPower.y-params.emitPower.x)*randoms.a;
#ifdef LOCAL
particlesOut.particles[index].position=newPosition;
#else
particlesOut.particles[index].position=(params.emitterWM*vec4<f32>(newPosition,1.)).xyz;
#endif
#ifdef CUSTOMEMITTER
particlesOut.particles[index].direction=direction;
#ifndef BILLBOARD 
particlesOut.particles[index].initialDirection=direction;
#endif
#else
#ifdef LOCAL
let initial : vec3<f32>=newDirection;
#else 
let initial : vec3<f32>=(params.emitterWM*vec4<f32>(newDirection,0.)).xyz;
#endif
particlesOut.particles[index].direction=initial*power;
#ifndef BILLBOARD 
particlesOut.particles[index].initialDirection=initial;
#endif
#endif
#ifdef ANIMATESHEET 
particlesOut.particles[index].cellIndex=params.cellInfos.x;
#ifdef ANIMATESHEETRANDOMSTART
particlesOut.particles[index].cellStartOffset=randoms.a*outLife;
#endif 
#endif
#ifdef NOISE
particlesOut.particles[index].noiseCoordinates1=particlesIn.particles[index].noiseCoordinates1;particlesOut.particles[index].noiseCoordinates2=particlesIn.particles[index].noiseCoordinates2;
#endif
} else {var directionScale : f32=timeDelta;particlesOut.particles[index].age=newAge;let ageGradient : f32=newAge/life;
#ifdef VELOCITYGRADIENTS
directionScale=directionScale*textureSampleLevel(velocityGradientTexture,velocityGradientSampler,vec2<f32>(ageGradient,0.),0.).r;
#endif
#ifdef DRAGGRADIENTS
directionScale=directionScale*(1.0-textureSampleLevel(dragGradientTexture,dragGradientSampler,vec2<f32>(ageGradient,0.),0.).r);
#endif
let position : vec3<f32>=particlesIn.particles[index].position;
#if defined(CUSTOMEMITTER)
particlesOut.particles[index].position=position+(direction-position)*ageGradient; 
particlesOut.particles[index].initialPosition=particlesIn.particles[index].initialPosition;
#else
particlesOut.particles[index].position=position+direction*directionScale;
#endif
particlesOut.particles[index].life=life;particlesOut.particles[index].seed=seed;
#ifndef COLORGRADIENTS 
particlesOut.particles[index].color=particlesIn.particles[index].color;
#endif
#ifdef SIZEGRADIENTS
particlesOut.particles[index].size=vec3<f32>(
textureSampleLevel(sizeGradientTexture,sizeGradientSampler,vec2<f32>(ageGradient,0.),0.).r,
particlesIn.particles[index].size.yz);
#else
particlesOut.particles[index].size=particlesIn.particles[index].size;
#endif 
#ifndef BILLBOARD 
particlesOut.particles[index].initialDirection=particlesIn.particles[index].initialDirection;
#endif
#ifdef CUSTOMEMITTER
particlesOut.particles[index].direction=direction;
#else
var updatedDirection : vec3<f32>=direction+params.gravity*timeDelta;
#ifdef LIMITVELOCITYGRADIENTS
let limitVelocity : f32=textureSampleLevel(limitVelocityGradientTexture,limitVelocityGradientSampler,vec2<f32>(ageGradient,0.),0.).r;let currentVelocity : f32=length(updatedDirection);if (currentVelocity>limitVelocity) {updatedDirection=updatedDirection*params.limitVelocityDamping;}
#endif
particlesOut.particles[index].direction=updatedDirection;
#ifdef NOISE
let noiseCoordinates1 : vec3<f32>=particlesIn.particles[index].noiseCoordinates1;let noiseCoordinates2 : vec3<f32>=particlesIn.particles[index].noiseCoordinates2;let fetchedR : f32=textureSampleLevel(noiseTexture,noiseSampler,vec2<f32>(noiseCoordinates1.x,noiseCoordinates1.y)*vec2<f32>(0.5,0.5)+vec2<f32>(0.5,0.5),0.).r;let fetchedG : f32=textureSampleLevel(noiseTexture,noiseSampler,vec2<f32>(noiseCoordinates1.z,noiseCoordinates2.x)*vec2<f32>(0.5,0.5)+vec2<f32>(0.5,0.5),0.).r;let fetchedB : f32=textureSampleLevel(noiseTexture,noiseSampler,vec2<f32>(noiseCoordinates2.y,noiseCoordinates2.z)*vec2<f32>(0.5,0.5)+vec2<f32>(0.5,0.5),0.).r;let force : vec3<f32>=vec3<f32>(-1.+2.*fetchedR,-1.+2.*fetchedG,-1.+2.*fetchedB)*params.noiseStrength;particlesOut.particles[index].direction=particlesOut.particles[index].direction+force*timeDelta;particlesOut.particles[index].noiseCoordinates1=noiseCoordinates1;particlesOut.particles[index].noiseCoordinates2=noiseCoordinates2;
#endif 
#endif 
#ifdef ANGULARSPEEDGRADIENTS
let angularSpeed : f32=textureSampleLevel(angularSpeedGradientTexture,angularSpeedGradientSampler,vec2<f32>(ageGradient,0.),0.).r;particlesOut.particles[index].angle=particlesIn.particles[index].angle+angularSpeed*timeDelta;
#else
let angle : vec2<f32>=particlesIn.particles[index].angle;particlesOut.particles[index].angle=vec2<f32>(angle.x+angle.y*timeDelta,angle.y);
#endif
#ifdef ANIMATESHEET 
var offsetAge : f32=particlesOut.particles[index].age;let dist : f32=params.cellInfos.y-params.cellInfos.x;
#ifdef ANIMATESHEETRANDOMSTART
let cellStartOffset : f32=particlesIn.particles[index].cellStartOffset;particlesOut.particles[index].cellStartOffset=cellStartOffset;offsetAge=offsetAge+cellStartOffset;
#else
let cellStartOffset : f32=0.;
#endif 
var ratio : f32;if (params.cellInfos.w==1.0) {ratio=clamp(((cellStartOffset+params.cellInfos.z*offsetAge) % life)/life,0.,1.0);}
else {ratio=clamp((cellStartOffset+params.cellInfos.z*offsetAge)/life,0.,1.0);}
particlesOut.particles[index].cellIndex=f32(i32(params.cellInfos.x+ratio*dist));
#endif
}}
`;
    var H0 = function() {
      function n(t, e) {
        this._bufferComputeShader = [], this._renderVertexBuffers = [], this.alignDataInBuffer = !0, this._parent = t, this._engine = e;
      }
      return n.prototype.contextLost = function() {
        this._updateComputeShader = void 0, this._bufferComputeShader.length = 0, this._renderVertexBuffers.length = 0;
      }, n.prototype.isUpdateBufferCreated = function() {
        return !!this._updateComputeShader;
      }, n.prototype.isUpdateBufferReady = function() {
        var t, e;
        return (e = (t = this._updateComputeShader) === null || t === void 0 ? void 0 : t.isReady()) !== null && e !== void 0 && e;
      }, n.prototype.createUpdateBuffer = function(t) {
        var e, i = { params: { group: 0, binding: 0 }, particlesIn: { group: 0, binding: 1 }, particlesOut: { group: 0, binding: 2 }, randomTexture: { group: 0, binding: 3 }, randomTexture2: { group: 0, binding: 4 } };
        return this._parent._sizeGradientsTexture && (i.sizeGradientTexture = { group: 1, binding: 1 }), this._parent._angularSpeedGradientsTexture && (i.angularSpeedGradientTexture = { group: 1, binding: 3 }), this._parent._velocityGradientsTexture && (i.velocityGradientTexture = { group: 1, binding: 5 }), this._parent._limitVelocityGradientsTexture && (i.limitVelocityGradientTexture = { group: 1, binding: 7 }), this._parent._dragGradientsTexture && (i.dragGradientTexture = { group: 1, binding: 9 }), this._parent.noiseTexture && (i.noiseTexture = { group: 1, binding: 11 }), this._updateComputeShader = new gf("updateParticles", this._engine, "gpuUpdateParticles", { bindingsMapping: i, defines: t.split(`
`) }), (e = this._simParamsComputeShader) === null || e === void 0 || e.dispose(), this._simParamsComputeShader = new Er(this._engine), this._simParamsComputeShader.addUniform("currentCount", 1), this._simParamsComputeShader.addUniform("timeDelta", 1), this._simParamsComputeShader.addUniform("stopFactor", 1), this._simParamsComputeShader.addUniform("randomTextureSize", 1), this._simParamsComputeShader.addUniform("lifeTime", 2), this._simParamsComputeShader.addUniform("emitPower", 2), this._parent._colorGradientsTexture || (this._simParamsComputeShader.addUniform("color1", 4), this._simParamsComputeShader.addUniform("color2", 4)), this._simParamsComputeShader.addUniform("sizeRange", 2), this._simParamsComputeShader.addUniform("scaleRange", 4), this._simParamsComputeShader.addUniform("angleRange", 4), this._simParamsComputeShader.addUniform("gravity", 3), this._parent._limitVelocityGradientsTexture && this._simParamsComputeShader.addUniform("limitVelocityDamping", 1), this._parent.isAnimationSheetEnabled && this._simParamsComputeShader.addUniform("cellInfos", 4), this._parent.noiseTexture && this._simParamsComputeShader.addUniform("noiseStrength", 3), this._parent.isLocal || this._simParamsComputeShader.addUniform("emitterWM", 16), this._parent.particleEmitterType && this._parent.particleEmitterType.buildUniformLayout(this._simParamsComputeShader), this._updateComputeShader.setUniformBuffer("params", this._simParamsComputeShader), new OP(this._simParamsComputeShader);
      }, n.prototype.createVertexBuffers = function(t, e) {
        this._renderVertexBuffers.push(e);
      }, n.prototype.createParticleBuffer = function(t) {
        var e = new Gg(this._engine, 4 * t.length, _.BUFFER_CREATIONFLAG_READWRITE | _.BUFFER_CREATIONFLAG_VERTEX);
        return e.update(t), this._bufferComputeShader.push(e), e.getBuffer();
      }, n.prototype.bindDrawBuffers = function(t, e, i) {
        this._engine.bindBuffers(this._renderVertexBuffers[t], i, e);
      }, n.prototype.preUpdateParticleBuffer = function() {
      }, n.prototype.updateParticleBuffer = function(t, e, i) {
        this._simParamsComputeShader.update(), this._updateComputeShader.setTexture("randomTexture", this._parent._randomTexture, !1), this._updateComputeShader.setTexture("randomTexture2", this._parent._randomTexture2, !1), this._parent._sizeGradientsTexture && this._updateComputeShader.setTexture("sizeGradientTexture", this._parent._sizeGradientsTexture), this._parent._angularSpeedGradientsTexture && this._updateComputeShader.setTexture("angularSpeedGradientTexture", this._parent._angularSpeedGradientsTexture), this._parent._velocityGradientsTexture && this._updateComputeShader.setTexture("velocityGradientTexture", this._parent._velocityGradientsTexture), this._parent._limitVelocityGradientsTexture && this._updateComputeShader.setTexture("limitVelocityGradientTexture", this._parent._limitVelocityGradientsTexture), this._parent._dragGradientsTexture && this._updateComputeShader.setTexture("dragGradientTexture", this._parent._dragGradientsTexture), this._parent.noiseTexture && this._updateComputeShader.setTexture("noiseTexture", this._parent.noiseTexture), this._updateComputeShader.setStorageBuffer("particlesIn", this._bufferComputeShader[t]), this._updateComputeShader.setStorageBuffer("particlesOut", this._bufferComputeShader[1 ^ t]), this._updateComputeShader.dispatch(Math.ceil(i / 64));
      }, n.prototype.releaseBuffers = function() {
        for (var t, e = 0; e < this._bufferComputeShader.length; ++e)
          this._bufferComputeShader[e].dispose();
        this._bufferComputeShader.length = 0, (t = this._simParamsComputeShader) === null || t === void 0 || t.dispose(), this._simParamsComputeShader = null, this._updateComputeShader = null;
      }, n.prototype.releaseVertexBuffers = function() {
        this._renderVertexBuffers.length = 0;
      }, n;
    }();
    j("BABYLON.ComputeShaderParticleSystem", H0);
    var Ol, Z_ = function() {
      function n(t, e, i) {
        this.gradient = t, this.color1 = e, this.color2 = i;
      }
      return n.prototype.getColorToRef = function(t) {
        this.color2 ? Ie.LerpToRef(this.color1, this.color2, Math.random(), t) : t.copyFrom(this.color1);
      }, n;
    }(), X0 = function(n, t) {
      this.gradient = n, this.color = t;
    }, J_ = function() {
      function n(t, e, i) {
        this.gradient = t, this.factor1 = e, this.factor2 = i;
      }
      return n.prototype.getFactor = function() {
        return this.factor2 === void 0 || this.factor2 === this.factor1 ? this.factor1 : this.factor1 + (this.factor2 - this.factor1) * Math.random();
      }, n;
    }(), sr = function() {
      function n() {
      }
      return n.GetCurrentGradient = function(t, e, i) {
        if (e[0].gradient > t)
          i(e[0], e[0], 1);
        else {
          for (var r = 0; r < e.length - 1; r++) {
            var o = e[r], a = e[r + 1];
            if (t >= o.gradient && t <= a.gradient)
              return void i(o, a, (t - o.gradient) / (a.gradient - o.gradient));
          }
          var s = e.length - 1;
          i(e[s], e[s], 1);
        }
      }, n;
    }(), j0 = function() {
      function n(t) {
        this.particleSystem = t, this.position = v.Zero(), this.direction = v.Zero(), this.color = new Ie(0, 0, 0, 0), this.colorStep = new Ie(0, 0, 0, 0), this.lifeTime = 1, this.age = 0, this.size = 0, this.scale = new fe(1, 1), this.angle = 0, this.angularSpeed = 0, this.cellIndex = 0, this._attachedSubEmitters = null, this._currentColor1 = new Ie(0, 0, 0, 0), this._currentColor2 = new Ie(0, 0, 0, 0), this._currentSize1 = 0, this._currentSize2 = 0, this._currentAngularSpeed1 = 0, this._currentAngularSpeed2 = 0, this._currentVelocity1 = 0, this._currentVelocity2 = 0, this._currentLimitVelocity1 = 0, this._currentLimitVelocity2 = 0, this._currentDrag1 = 0, this._currentDrag2 = 0, this.id = n._Count++, this.particleSystem.isAnimationSheetEnabled && this._updateCellInfoFromSystem();
      }
      return n.prototype._updateCellInfoFromSystem = function() {
        this.cellIndex = this.particleSystem.startSpriteCellID;
      }, n.prototype.updateCellIndex = function() {
        var t = this.age, e = this.particleSystem.spriteCellChangeSpeed;
        this.particleSystem.spriteRandomStartCell && (this._randomCellOffset === void 0 && (this._randomCellOffset = Math.random() * this.lifeTime), e === 0 ? (e = 1, t = this._randomCellOffset) : t += this._randomCellOffset);
        var i, r = this._initialEndSpriteCellID - this._initialStartSpriteCellID;
        i = this._initialSpriteCellLoop ? ue.Clamp(t * e % this.lifeTime / this.lifeTime) : ue.Clamp(t * e / this.lifeTime), this.cellIndex = this._initialStartSpriteCellID + i * r | 0;
      }, n.prototype._inheritParticleInfoToSubEmitter = function(t) {
        if (t.particleSystem.emitter.position) {
          var e = t.particleSystem.emitter;
          if (e.position.copyFrom(this.position), t.inheritDirection) {
            var i = F.Vector3[0];
            this.direction.normalizeToRef(i), e.setDirection(i, 0, Math.PI / 2);
          }
        } else
          t.particleSystem.emitter.copyFrom(this.position);
        this.direction.scaleToRef(t.inheritedVelocityAmount / 2, F.Vector3[0]), t.particleSystem._inheritedVelocityOffset.copyFrom(F.Vector3[0]);
      }, n.prototype._inheritParticleInfoToSubEmitters = function() {
        var t = this;
        this._attachedSubEmitters && this._attachedSubEmitters.length > 0 && this._attachedSubEmitters.forEach(function(e) {
          t._inheritParticleInfoToSubEmitter(e);
        });
      }, n.prototype._reset = function() {
        this.age = 0, this.id = n._Count++, this._currentColorGradient = null, this._currentSizeGradient = null, this._currentAngularSpeedGradient = null, this._currentVelocityGradient = null, this._currentLimitVelocityGradient = null, this._currentDragGradient = null, this.cellIndex = this.particleSystem.startSpriteCellID, this._randomCellOffset = void 0;
      }, n.prototype.copyTo = function(t) {
        t.position.copyFrom(this.position), this._initialDirection ? t._initialDirection ? t._initialDirection.copyFrom(this._initialDirection) : t._initialDirection = this._initialDirection.clone() : t._initialDirection = null, t.direction.copyFrom(this.direction), this._localPosition && (t._localPosition ? t._localPosition.copyFrom(this._localPosition) : t._localPosition = this._localPosition.clone()), t.color.copyFrom(this.color), t.colorStep.copyFrom(this.colorStep), t.lifeTime = this.lifeTime, t.age = this.age, t._randomCellOffset = this._randomCellOffset, t.size = this.size, t.scale.copyFrom(this.scale), t.angle = this.angle, t.angularSpeed = this.angularSpeed, t.particleSystem = this.particleSystem, t.cellIndex = this.cellIndex, t.id = this.id, t._attachedSubEmitters = this._attachedSubEmitters, this._currentColorGradient && (t._currentColorGradient = this._currentColorGradient, t._currentColor1.copyFrom(this._currentColor1), t._currentColor2.copyFrom(this._currentColor2)), this._currentSizeGradient && (t._currentSizeGradient = this._currentSizeGradient, t._currentSize1 = this._currentSize1, t._currentSize2 = this._currentSize2), this._currentAngularSpeedGradient && (t._currentAngularSpeedGradient = this._currentAngularSpeedGradient, t._currentAngularSpeed1 = this._currentAngularSpeed1, t._currentAngularSpeed2 = this._currentAngularSpeed2), this._currentVelocityGradient && (t._currentVelocityGradient = this._currentVelocityGradient, t._currentVelocity1 = this._currentVelocity1, t._currentVelocity2 = this._currentVelocity2), this._currentLimitVelocityGradient && (t._currentLimitVelocityGradient = this._currentLimitVelocityGradient, t._currentLimitVelocity1 = this._currentLimitVelocity1, t._currentLimitVelocity2 = this._currentLimitVelocity2), this._currentDragGradient && (t._currentDragGradient = this._currentDragGradient, t._currentDrag1 = this._currentDrag1, t._currentDrag2 = this._currentDrag2), this.particleSystem.isAnimationSheetEnabled && (t._initialStartSpriteCellID = this._initialStartSpriteCellID, t._initialEndSpriteCellID = this._initialEndSpriteCellID, t._initialSpriteCellLoop = this._initialSpriteCellLoop), this.particleSystem.useRampGradients && (t.remapData && this.remapData ? t.remapData.copyFrom(this.remapData) : t.remapData = new lt(0, 0, 0, 0)), this._randomNoiseCoordinates1 && (t._randomNoiseCoordinates1 ? (t._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1), t._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2)) : (t._randomNoiseCoordinates1 = this._randomNoiseCoordinates1.clone(), t._randomNoiseCoordinates2 = this._randomNoiseCoordinates2.clone()));
      }, n._Count = 0, n;
    }();
    (function(n) {
      n[n.ATTACHED = 0] = "ATTACHED", n[n.END = 1] = "END";
    })(Ol || (Ol = {}));
    var cu = function() {
      function n(t) {
        if (this.particleSystem = t, this.type = Ol.END, this.inheritDirection = !1, this.inheritedVelocityAmount = 0, !t.emitter || !t.emitter.dispose) {
          var e = Kt("BABYLON.AbstractMesh");
          t.emitter = new e("SubemitterSystemEmitter", t.getScene()), t._disposeEmitterOnDispose = !0;
        }
      }
      return n.prototype.clone = function() {
        var t = this.particleSystem.emitter;
        t ? t instanceof v ? t = t.clone() : t.getClassName().indexOf("Mesh") !== -1 && ((t = new (Kt("BABYLON.Mesh"))("", t.getScene())).isVisible = !1) : t = new v();
        var e = new n(this.particleSystem.clone(this.particleSystem.name, t));
        return e.particleSystem.name += "Clone", e.type = this.type, e.inheritDirection = this.inheritDirection, e.inheritedVelocityAmount = this.inheritedVelocityAmount, e.particleSystem._disposeEmitterOnDispose = !0, e.particleSystem.disposeOnStop = !0, e;
      }, n.prototype.serialize = function(t) {
        t === void 0 && (t = !1);
        var e = {};
        return e.type = this.type, e.inheritDirection = this.inheritDirection, e.inheritedVelocityAmount = this.inheritedVelocityAmount, e.particleSystem = this.particleSystem.serialize(t), e;
      }, n._ParseParticleSystem = function(t, e, i, r) {
        throw et("ParseParticle");
      }, n.Parse = function(t, e, i) {
        var r = t.particleSystem, o = new n(n._ParseParticleSystem(r, e, i, !0));
        return o.type = t.type, o.inheritDirection = t.inheritDirection, o.inheritedVelocityAmount = t.inheritedVelocityAmount, o.particleSystem._isSubEmitter = !0, o;
      }, n.prototype.dispose = function() {
        this.particleSystem.dispose();
      }, n;
    }();
    re.ShadersStore.particlesPixelShader = `#ifdef LOGARITHMICDEPTH
#extension GL_EXT_frag_depth : enable
#endif
varying vec2 vUV;varying vec4 vColor;uniform vec4 textureMask;uniform sampler2D diffuseSampler;
#include<clipPlaneFragmentDeclaration>
#include<imageProcessingDeclaration>
#include<logDepthDeclaration>
#include<helperFunctions>
#include<imageProcessingFunctions>
#ifdef RAMPGRADIENT
varying vec4 remapRanges;uniform sampler2D rampSampler;
#endif
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void) {
#define CUSTOM_FRAGMENT_MAIN_BEGIN
#include<clipPlaneFragment>
vec4 textureColor=texture2D(diffuseSampler,vUV);vec4 baseColor=(textureColor*textureMask+(vec4(1.,1.,1.,1.)-textureMask))*vColor;
#ifdef RAMPGRADIENT
float alpha=baseColor.a;float remappedColorIndex=clamp((alpha-remapRanges.x)/remapRanges.y,0.0,1.0);vec4 rampColor=texture2D(rampSampler,vec2(1.0-remappedColorIndex,0.));baseColor.rgb*=rampColor.rgb;float finalAlpha=baseColor.a;baseColor.a=clamp((alpha*rampColor.a-remapRanges.z)/remapRanges.w,0.0,1.0);
#endif
#ifdef BLENDMULTIPLYMODE
float sourceAlpha=vColor.a*textureColor.a;baseColor.rgb=baseColor.rgb*sourceAlpha+vec3(1.0)*(1.0-sourceAlpha);
#endif
#include<logDepthFragment>
#ifdef IMAGEPROCESSINGPOSTPROCESS
baseColor.rgb=toLinearSpace(baseColor.rgb);
#else
#ifdef IMAGEPROCESSING
baseColor.rgb=toLinearSpace(baseColor.rgb);baseColor=applyImageProcessing(baseColor);
#endif
#endif
gl_FragColor=baseColor;
#define CUSTOM_FRAGMENT_MAIN_END
}`, re.ShadersStore.particlesVertexShader = `attribute vec3 position;attribute vec4 color;attribute float angle;attribute vec2 size;
#ifdef ANIMATESHEET
attribute float cellIndex;
#endif
#ifndef BILLBOARD
attribute vec3 direction;
#endif
#ifdef BILLBOARDSTRETCHED
attribute vec3 direction;
#endif
#ifdef RAMPGRADIENT
attribute vec4 remapData;
#endif
attribute vec2 offset;uniform mat4 view;uniform mat4 projection;uniform vec2 translationPivot;
#ifdef ANIMATESHEET
uniform vec3 particlesInfos; 
#endif
varying vec2 vUV;varying vec4 vColor;varying vec3 vPositionW;
#ifdef RAMPGRADIENT
varying vec4 remapRanges;
#endif
#if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED)
uniform mat4 invView;
#endif
#include<clipPlaneVertexDeclaration>
#include<logDepthDeclaration>
#ifdef BILLBOARD
uniform vec3 eyePosition;
#endif
vec3 rotate(vec3 yaxis,vec3 rotatedCorner) {vec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));vec3 zaxis=normalize(cross(yaxis,xaxis));vec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);vec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);vec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);mat3 rotMatrix= mat3(row0,row1,row2);vec3 alignedCorner=rotMatrix*rotatedCorner;return position+alignedCorner;}
#ifdef BILLBOARDSTRETCHED
vec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {vec3 normalizedToCamera=normalize(toCamera);vec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));vec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);vec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);
#ifdef BILLBOARDSTRETCHED_LOCAL
vec3 row1=direction;
#else
vec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));vec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);
#endif
mat3 rotMatrix= mat3(row0,row1,row2);vec3 alignedCorner=rotMatrix*rotatedCorner;return position+alignedCorner;}
#endif
#define CUSTOM_VERTEX_DEFINITIONS
void main(void) {
#define CUSTOM_VERTEX_MAIN_BEGIN
vec2 cornerPos;cornerPos=(vec2(offset.x-0.5,offset.y -0.5)-translationPivot)*size;
#ifdef BILLBOARD
vec3 rotatedCorner;
#ifdef BILLBOARDY
rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.y=0.;rotatedCorner.xz+=translationPivot;vec3 yaxis=position-eyePosition;yaxis.y=0.;vPositionW=rotate(normalize(yaxis),rotatedCorner);vec3 viewPos=(view*vec4(vPositionW,1.0)).xyz;
#elif defined(BILLBOARDSTRETCHED)
rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.z=0.;rotatedCorner.xy+=translationPivot;vec3 toCamera=position-eyePosition;vPositionW=rotateAlign(toCamera,rotatedCorner);vec3 viewPos=(view*vec4(vPositionW,1.0)).xyz;
#else
rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.z=0.;rotatedCorner.xy+=translationPivot;vec3 viewPos=(view*vec4(position,1.0)).xyz+rotatedCorner;vPositionW=(invView*vec4(viewPos,1)).xyz;
#endif
#ifdef RAMPGRADIENT
remapRanges=remapData;
#endif
gl_Position=projection*vec4(viewPos,1.0);
#else
vec3 rotatedCorner;rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.y=0.;rotatedCorner.xz+=translationPivot;vec3 yaxis=normalize(direction);vPositionW=rotate(yaxis,rotatedCorner);gl_Position=projection*view*vec4(vPositionW,1.0);
#endif
vColor=color;
#ifdef ANIMATESHEET
float rowOffset=floor(cellIndex*particlesInfos.z);float columnOffset=cellIndex-rowOffset/particlesInfos.z;vec2 uvScale=particlesInfos.xy;vec2 uvOffset=vec2(offset.x ,1.0-offset.y);vUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;
#else
vUV=offset;
#endif
#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
vec4 worldPos=vec4(vPositionW,1.0);
#endif
#include<clipPlaneVertex>
#include<logDepthVertex>
#define CUSTOM_VERTEX_MAIN_END
}`;
    var Ai = function(n) {
      function t(e, i, r, o, a, s) {
        o === void 0 && (o = null), a === void 0 && (a = !1), s === void 0 && (s = 0.01);
        var l = n.call(this, e) || this;
        l._emitterInverseWorldMatrix = B.Identity(), l._inheritedVelocityOffset = new v(), l.onDisposeObservable = new H(), l.onStoppedObservable = new H(), l._particles = new Array(), l._stockParticles = new Array(), l._newPartsExcess = 0, l._vertexBuffers = {}, l._scaledColorStep = new Ie(0, 0, 0, 0), l._colorDiff = new Ie(0, 0, 0, 0), l._scaledDirection = v.Zero(), l._scaledGravity = v.Zero(), l._currentRenderId = -1, l._useInstancing = !1, l._started = !1, l._stopped = !1, l._actualFrame = 0, l._currentEmitRate1 = 0, l._currentEmitRate2 = 0, l._currentStartSize1 = 0, l._currentStartSize2 = 0, l.updateInAnimate = !0, l._rawTextureWidth = 256, l._useRampGradients = !1, l._disposeEmitterOnDispose = !1, l.isLocal = !1, l.isGPU = !1, l._onBeforeDrawParticlesObservable = null, l.recycleParticle = function(u) {
          var h = l._particles.pop();
          h !== u && h.copyTo(u), l._stockParticles.push(h);
        }, l._createParticle = function() {
          var u;
          if (l._stockParticles.length !== 0 ? (u = l._stockParticles.pop())._reset() : u = new j0(l), l._subEmitters && l._subEmitters.length > 0) {
            var h = l._subEmitters[Math.floor(Math.random() * l._subEmitters.length)];
            u._attachedSubEmitters = [], h.forEach(function(d) {
              if (d.type === Ol.ATTACHED) {
                var p = d.clone();
                u._attachedSubEmitters.push(p), p.particleSystem.start();
              }
            });
          }
          return u;
        }, l._emitFromParticle = function(u) {
          if (l._subEmitters && l._subEmitters.length !== 0) {
            var h = Math.floor(Math.random() * l._subEmitters.length);
            l._subEmitters[h].forEach(function(d) {
              if (d.type === Ol.END) {
                var p = d.clone();
                u._inheritParticleInfoToSubEmitter(p), p.particleSystem._rootParticleSystem = l, l.activeSubSystems.push(p.particleSystem), p.particleSystem.start();
              }
            });
          }
        }, l._capacity = i, l._epsilon = s, l._isAnimationSheetEnabled = a, r && r.getClassName() !== "Scene" ? (l._engine = r, l.defaultProjectionMatrix = B.PerspectiveFovLH(0.8, 1, 0.1, 100, l._engine.isNDCHalfZRange)) : (l._scene = r || Me.LastCreatedScene, l._engine = l._scene.getEngine(), l.uniqueId = l._scene.getUniqueId(), l._scene.particleSystems.push(l)), l._engine.getCaps().vertexArrayObject && (l._vertexArrayObject = null), l._attachImageProcessingConfiguration(null), l._customWrappers = { 0: new Ei(l._engine) }, l._customWrappers[0].effect = o, l._drawWrappers = [], l._useInstancing = l._engine.getCaps().instancedArrays, l._createIndexBuffer(), l._createVertexBuffers(), l.particleEmitterType = new _l();
        var c = null;
        return l.updateFunction = function(u) {
          var h, d = null;
          l.noiseTexture && (d = l.noiseTexture.getSize(), (h = l.noiseTexture.getContent()) === null || h === void 0 || h.then(function(y) {
            c = y;
          }));
          for (var p, f = u === l._particles, m = function(y) {
            var b = u[y], T = l._scaledUpdateSpeed, S = b.age;
            if (b.age += T, b.age > b.lifeTime) {
              var E = b.age - S;
              T = (b.lifeTime - S) * T / E, b.age = b.lifeTime;
            }
            var A = b.age / b.lifeTime;
            l._colorGradients && l._colorGradients.length > 0 ? sr.GetCurrentGradient(A, l._colorGradients, function(z, V, Y) {
              z !== b._currentColorGradient && (b._currentColor1.copyFrom(b._currentColor2), V.getColorToRef(b._currentColor2), b._currentColorGradient = z), Ie.LerpToRef(b._currentColor1, b._currentColor2, Y, b.color);
            }) : (b.colorStep.scaleToRef(T, l._scaledColorStep), b.color.addInPlace(l._scaledColorStep), b.color.a < 0 && (b.color.a = 0)), l._angularSpeedGradients && l._angularSpeedGradients.length > 0 && sr.GetCurrentGradient(A, l._angularSpeedGradients, function(z, V, Y) {
              z !== b._currentAngularSpeedGradient && (b._currentAngularSpeed1 = b._currentAngularSpeed2, b._currentAngularSpeed2 = V.getFactor(), b._currentAngularSpeedGradient = z), b.angularSpeed = ue.Lerp(b._currentAngularSpeed1, b._currentAngularSpeed2, Y);
            }), b.angle += b.angularSpeed * T;
            var R = T;
            if (l._velocityGradients && l._velocityGradients.length > 0 && sr.GetCurrentGradient(A, l._velocityGradients, function(z, V, Y) {
              z !== b._currentVelocityGradient && (b._currentVelocity1 = b._currentVelocity2, b._currentVelocity2 = V.getFactor(), b._currentVelocityGradient = z), R *= ue.Lerp(b._currentVelocity1, b._currentVelocity2, Y);
            }), b.direction.scaleToRef(R, l._scaledDirection), l._limitVelocityGradients && l._limitVelocityGradients.length > 0 && sr.GetCurrentGradient(A, l._limitVelocityGradients, function(z, V, Y) {
              z !== b._currentLimitVelocityGradient && (b._currentLimitVelocity1 = b._currentLimitVelocity2, b._currentLimitVelocity2 = V.getFactor(), b._currentLimitVelocityGradient = z);
              var ee = ue.Lerp(b._currentLimitVelocity1, b._currentLimitVelocity2, Y);
              b.direction.length() > ee && b.direction.scaleInPlace(l.limitVelocityDamping);
            }), l._dragGradients && l._dragGradients.length > 0 && sr.GetCurrentGradient(A, l._dragGradients, function(z, V, Y) {
              z !== b._currentDragGradient && (b._currentDrag1 = b._currentDrag2, b._currentDrag2 = V.getFactor(), b._currentDragGradient = z);
              var ee = ue.Lerp(b._currentDrag1, b._currentDrag2, Y);
              l._scaledDirection.scaleInPlace(1 - ee);
            }), l.isLocal && b._localPosition ? (b._localPosition.addInPlace(l._scaledDirection), v.TransformCoordinatesToRef(b._localPosition, l._emitterWorldMatrix, b.position)) : b.position.addInPlace(l._scaledDirection), c && d && b._randomNoiseCoordinates1) {
              var C = l._fetchR(b._randomNoiseCoordinates1.x, b._randomNoiseCoordinates1.y, d.width, d.height, c), L = l._fetchR(b._randomNoiseCoordinates1.z, b._randomNoiseCoordinates2.x, d.width, d.height, c), I = l._fetchR(b._randomNoiseCoordinates2.y, b._randomNoiseCoordinates2.z, d.width, d.height, c), O = F.Vector3[0], w = F.Vector3[1];
              O.copyFromFloats((2 * C - 1) * l.noiseStrength.x, (2 * L - 1) * l.noiseStrength.y, (2 * I - 1) * l.noiseStrength.z), O.scaleToRef(T, w), b.direction.addInPlace(w);
            }
            if (l.gravity.scaleToRef(T, l._scaledGravity), b.direction.addInPlace(l._scaledGravity), l._sizeGradients && l._sizeGradients.length > 0 && sr.GetCurrentGradient(A, l._sizeGradients, function(z, V, Y) {
              z !== b._currentSizeGradient && (b._currentSize1 = b._currentSize2, b._currentSize2 = V.getFactor(), b._currentSizeGradient = z), b.size = ue.Lerp(b._currentSize1, b._currentSize2, Y);
            }), l._useRampGradients && (l._colorRemapGradients && l._colorRemapGradients.length > 0 && sr.GetCurrentGradient(A, l._colorRemapGradients, function(z, V, Y) {
              var ee = ue.Lerp(z.factor1, V.factor1, Y), J = ue.Lerp(z.factor2, V.factor2, Y);
              b.remapData.x = ee, b.remapData.y = J - ee;
            }), l._alphaRemapGradients && l._alphaRemapGradients.length > 0 && sr.GetCurrentGradient(A, l._alphaRemapGradients, function(z, V, Y) {
              var ee = ue.Lerp(z.factor1, V.factor1, Y), J = ue.Lerp(z.factor2, V.factor2, Y);
              b.remapData.z = ee, b.remapData.w = J - ee;
            })), l._isAnimationSheetEnabled && b.updateCellIndex(), b._inheritParticleInfoToSubEmitters(), b.age >= b.lifeTime)
              return l._emitFromParticle(b), b._attachedSubEmitters && (b._attachedSubEmitters.forEach(function(z) {
                z.particleSystem.disposeOnStop = !0, z.particleSystem.stop();
              }), b._attachedSubEmitters = null), l.recycleParticle(b), f && y--, p = y, "continue";
            p = y;
          }, g = 0; g < u.length; g++)
            m(g), g = p;
        }, l;
      }
      return D(t, n), Object.defineProperty(t.prototype, "onDispose", { set: function(e) {
        this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver), this._onDisposeObserver = this.onDisposeObservable.add(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "useRampGradients", { get: function() {
        return this._useRampGradients;
      }, set: function(e) {
        this._useRampGradients !== e && (this._useRampGradients = e, this._resetEffect());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "particles", { get: function() {
        return this._particles;
      }, enumerable: !1, configurable: !0 }), t.prototype.getActiveCount = function() {
        return this._particles.length;
      }, t.prototype.getClassName = function() {
        return "ParticleSystem";
      }, t.prototype.isStopping = function() {
        return this._stopped && this.isAlive();
      }, t.prototype.getCustomEffect = function(e) {
        var i, r;
        return e === void 0 && (e = 0), (r = (i = this._customWrappers[e]) === null || i === void 0 ? void 0 : i.effect) !== null && r !== void 0 ? r : this._customWrappers[0].effect;
      }, t.prototype._getCustomDrawWrapper = function(e) {
        var i;
        return e === void 0 && (e = 0), (i = this._customWrappers[e]) !== null && i !== void 0 ? i : this._customWrappers[0];
      }, t.prototype.setCustomEffect = function(e, i) {
        i === void 0 && (i = 0), this._customWrappers[i] = new Ei(this._engine), this._customWrappers[i].effect = e, this._customWrappers[i].drawContext && (this._customWrappers[i].drawContext.useInstancing = this._useInstancing);
      }, Object.defineProperty(t.prototype, "onBeforeDrawParticlesObservable", { get: function() {
        return this._onBeforeDrawParticlesObservable || (this._onBeforeDrawParticlesObservable = new H()), this._onBeforeDrawParticlesObservable;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "vertexShaderName", { get: function() {
        return "particles";
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "vertexBuffers", { get: function() {
        return this._vertexBuffers;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "indexBuffer", { get: function() {
        return this._indexBuffer;
      }, enumerable: !1, configurable: !0 }), t.prototype._addFactorGradient = function(e, i, r, o) {
        var a = new J_(i, r, o);
        e.push(a), e.sort(function(s, l) {
          return s.gradient < l.gradient ? -1 : s.gradient > l.gradient ? 1 : 0;
        });
      }, t.prototype._removeFactorGradient = function(e, i) {
        if (e)
          for (var r = 0, o = 0, a = e; o < a.length; o++) {
            if (a[o].gradient === i) {
              e.splice(r, 1);
              break;
            }
            r++;
          }
      }, t.prototype.addLifeTimeGradient = function(e, i, r) {
        return this._lifeTimeGradients || (this._lifeTimeGradients = []), this._addFactorGradient(this._lifeTimeGradients, e, i, r), this;
      }, t.prototype.removeLifeTimeGradient = function(e) {
        return this._removeFactorGradient(this._lifeTimeGradients, e), this;
      }, t.prototype.addSizeGradient = function(e, i, r) {
        return this._sizeGradients || (this._sizeGradients = []), this._addFactorGradient(this._sizeGradients, e, i, r), this;
      }, t.prototype.removeSizeGradient = function(e) {
        return this._removeFactorGradient(this._sizeGradients, e), this;
      }, t.prototype.addColorRemapGradient = function(e, i, r) {
        return this._colorRemapGradients || (this._colorRemapGradients = []), this._addFactorGradient(this._colorRemapGradients, e, i, r), this;
      }, t.prototype.removeColorRemapGradient = function(e) {
        return this._removeFactorGradient(this._colorRemapGradients, e), this;
      }, t.prototype.addAlphaRemapGradient = function(e, i, r) {
        return this._alphaRemapGradients || (this._alphaRemapGradients = []), this._addFactorGradient(this._alphaRemapGradients, e, i, r), this;
      }, t.prototype.removeAlphaRemapGradient = function(e) {
        return this._removeFactorGradient(this._alphaRemapGradients, e), this;
      }, t.prototype.addAngularSpeedGradient = function(e, i, r) {
        return this._angularSpeedGradients || (this._angularSpeedGradients = []), this._addFactorGradient(this._angularSpeedGradients, e, i, r), this;
      }, t.prototype.removeAngularSpeedGradient = function(e) {
        return this._removeFactorGradient(this._angularSpeedGradients, e), this;
      }, t.prototype.addVelocityGradient = function(e, i, r) {
        return this._velocityGradients || (this._velocityGradients = []), this._addFactorGradient(this._velocityGradients, e, i, r), this;
      }, t.prototype.removeVelocityGradient = function(e) {
        return this._removeFactorGradient(this._velocityGradients, e), this;
      }, t.prototype.addLimitVelocityGradient = function(e, i, r) {
        return this._limitVelocityGradients || (this._limitVelocityGradients = []), this._addFactorGradient(this._limitVelocityGradients, e, i, r), this;
      }, t.prototype.removeLimitVelocityGradient = function(e) {
        return this._removeFactorGradient(this._limitVelocityGradients, e), this;
      }, t.prototype.addDragGradient = function(e, i, r) {
        return this._dragGradients || (this._dragGradients = []), this._addFactorGradient(this._dragGradients, e, i, r), this;
      }, t.prototype.removeDragGradient = function(e) {
        return this._removeFactorGradient(this._dragGradients, e), this;
      }, t.prototype.addEmitRateGradient = function(e, i, r) {
        return this._emitRateGradients || (this._emitRateGradients = []), this._addFactorGradient(this._emitRateGradients, e, i, r), this;
      }, t.prototype.removeEmitRateGradient = function(e) {
        return this._removeFactorGradient(this._emitRateGradients, e), this;
      }, t.prototype.addStartSizeGradient = function(e, i, r) {
        return this._startSizeGradients || (this._startSizeGradients = []), this._addFactorGradient(this._startSizeGradients, e, i, r), this;
      }, t.prototype.removeStartSizeGradient = function(e) {
        return this._removeFactorGradient(this._startSizeGradients, e), this;
      }, t.prototype._createRampGradientTexture = function() {
        if (this._rampGradients && this._rampGradients.length && !this._rampGradientsTexture && this._scene) {
          for (var e = new Uint8Array(4 * this._rawTextureWidth), i = Ot.Color3[0], r = function(s) {
            var l = s / o._rawTextureWidth;
            sr.GetCurrentGradient(l, o._rampGradients, function(c, u, h) {
              ne.LerpToRef(c.color, u.color, h, i), e[4 * s] = 255 * i.r, e[4 * s + 1] = 255 * i.g, e[4 * s + 2] = 255 * i.b, e[4 * s + 3] = 255;
            });
          }, o = this, a = 0; a < this._rawTextureWidth; a++)
            r(a);
          this._rampGradientsTexture = on.CreateRGBATexture(e, this._rawTextureWidth, 1, this._scene, !1, !1, _.TEXTURE_NEAREST_SAMPLINGMODE);
        }
      }, t.prototype.getRampGradients = function() {
        return this._rampGradients;
      }, t.prototype.forceRefreshGradients = function() {
        this._syncRampGradientTexture();
      }, t.prototype._syncRampGradientTexture = function() {
        this._rampGradients && (this._rampGradients.sort(function(e, i) {
          return e.gradient < i.gradient ? -1 : e.gradient > i.gradient ? 1 : 0;
        }), this._rampGradientsTexture && (this._rampGradientsTexture.dispose(), this._rampGradientsTexture = null), this._createRampGradientTexture());
      }, t.prototype.addRampGradient = function(e, i) {
        this._rampGradients || (this._rampGradients = []);
        var r = new X0(e, i);
        return this._rampGradients.push(r), this._syncRampGradientTexture(), this;
      }, t.prototype.removeRampGradient = function(e) {
        return this._removeGradientAndTexture(e, this._rampGradients, this._rampGradientsTexture), this._rampGradientsTexture = null, this._rampGradients && this._rampGradients.length > 0 && this._createRampGradientTexture(), this;
      }, t.prototype.addColorGradient = function(e, i, r) {
        this._colorGradients || (this._colorGradients = []);
        var o = new Z_(e, i, r);
        return this._colorGradients.push(o), this._colorGradients.sort(function(a, s) {
          return a.gradient < s.gradient ? -1 : a.gradient > s.gradient ? 1 : 0;
        }), this;
      }, t.prototype.removeColorGradient = function(e) {
        if (!this._colorGradients)
          return this;
        for (var i = 0, r = 0, o = this._colorGradients; r < o.length; r++) {
          if (o[r].gradient === e) {
            this._colorGradients.splice(i, 1);
            break;
          }
          i++;
        }
        return this;
      }, t.prototype.resetDrawCache = function() {
        for (var e = 0, i = this._drawWrappers; e < i.length; e++) {
          var r = i[e];
          if (r)
            for (var o = 0, a = r; o < a.length; o++) {
              var s = a[o];
              s == null || s.dispose();
            }
        }
        this._drawWrappers = [];
      }, t.prototype._fetchR = function(e, i, r, o, a) {
        return a[4 * (((e = 0.5 * Math.abs(e) + 0.5) * r % r | 0) + ((i = 0.5 * Math.abs(i) + 0.5) * o % o | 0) * r)] / 255;
      }, t.prototype._reset = function() {
        this._resetEffect();
      }, t.prototype._resetEffect = function() {
        this._vertexBuffer && (this._vertexBuffer.dispose(), this._vertexBuffer = null), this._spriteBuffer && (this._spriteBuffer.dispose(), this._spriteBuffer = null), this._vertexArrayObject && (this._engine.releaseVertexArrayObject(this._vertexArrayObject), this._vertexArrayObject = null), this._createVertexBuffers();
      }, t.prototype._createVertexBuffers = function() {
        this._vertexBufferSize = this._useInstancing ? 10 : 12, this._isAnimationSheetEnabled && (this._vertexBufferSize += 1), this._isBillboardBased && this.billboardMode !== t.BILLBOARDMODE_STRETCHED && this.billboardMode !== t.BILLBOARDMODE_STRETCHED_LOCAL || (this._vertexBufferSize += 3), this._useRampGradients && (this._vertexBufferSize += 4);
        var e = this._engine, i = this._vertexBufferSize * (this._useInstancing ? 1 : 4);
        this._vertexData = new Float32Array(this._capacity * i), this._vertexBuffer = new Yi(e, this._vertexData, !0, i);
        var r = 0, o = this._vertexBuffer.createVertexBuffer(P.PositionKind, r, 3, this._vertexBufferSize, this._useInstancing);
        this._vertexBuffers[P.PositionKind] = o, r += 3;
        var a = this._vertexBuffer.createVertexBuffer(P.ColorKind, r, 4, this._vertexBufferSize, this._useInstancing);
        this._vertexBuffers[P.ColorKind] = a, r += 4;
        var s = this._vertexBuffer.createVertexBuffer("angle", r, 1, this._vertexBufferSize, this._useInstancing);
        this._vertexBuffers.angle = s, r += 1;
        var l, c = this._vertexBuffer.createVertexBuffer("size", r, 2, this._vertexBufferSize, this._useInstancing);
        if (this._vertexBuffers.size = c, r += 2, this._isAnimationSheetEnabled) {
          var u = this._vertexBuffer.createVertexBuffer("cellIndex", r, 1, this._vertexBufferSize, this._useInstancing);
          this._vertexBuffers.cellIndex = u, r += 1;
        }
        if (!this._isBillboardBased || this.billboardMode === t.BILLBOARDMODE_STRETCHED || this.billboardMode === t.BILLBOARDMODE_STRETCHED_LOCAL) {
          var h = this._vertexBuffer.createVertexBuffer("direction", r, 3, this._vertexBufferSize, this._useInstancing);
          this._vertexBuffers.direction = h, r += 3;
        }
        if (this._useRampGradients) {
          var d = this._vertexBuffer.createVertexBuffer("remapData", r, 4, this._vertexBufferSize, this._useInstancing);
          this._vertexBuffers.remapData = d, r += 4;
        }
        if (this._useInstancing) {
          var p = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]);
          this._spriteBuffer = new Yi(e, p, !1, 2), l = this._spriteBuffer.createVertexBuffer("offset", 0, 2);
        } else
          l = this._vertexBuffer.createVertexBuffer("offset", r, 2, this._vertexBufferSize, this._useInstancing), r += 2;
        this._vertexBuffers.offset = l, this.resetDrawCache();
      }, t.prototype._createIndexBuffer = function() {
        if (this._useInstancing)
          this._linesIndexBufferUseInstancing = this._engine.createIndexBuffer(new Uint32Array([0, 1, 1, 3, 3, 2, 2, 0, 0, 3]));
        else {
          for (var e = [], i = [], r = 0, o = 0; o < this._capacity; o++)
            e.push(r), e.push(r + 1), e.push(r + 2), e.push(r), e.push(r + 2), e.push(r + 3), i.push(r, r + 1, r + 1, r + 2, r + 2, r + 3, r + 3, r, r, r + 3), r += 4;
          this._indexBuffer = this._engine.createIndexBuffer(e), this._linesIndexBuffer = this._engine.createIndexBuffer(i);
        }
      }, t.prototype.getCapacity = function() {
        return this._capacity;
      }, t.prototype.isAlive = function() {
        return this._alive;
      }, t.prototype.isStarted = function() {
        return this._started;
      }, t.prototype._prepareSubEmitterInternalArray = function() {
        var e = this;
        this._subEmitters = new Array(), this.subEmitters && this.subEmitters.forEach(function(i) {
          i instanceof t ? e._subEmitters.push([new cu(i)]) : i instanceof cu ? e._subEmitters.push([i]) : i instanceof Array && e._subEmitters.push(i);
        });
      }, t.prototype.start = function(e) {
        var i, r = this;
        if (e === void 0 && (e = this.startDelay), !this.targetStopDuration && this._hasTargetStopDurationDependantGradient())
          throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
        if (e)
          setTimeout(function() {
            r.start(0);
          }, e);
        else {
          if (this._prepareSubEmitterInternalArray(), this._started = !0, this._stopped = !1, this._actualFrame = 0, this._subEmitters && this._subEmitters.length != 0 && (this.activeSubSystems = []), this._emitRateGradients && (this._emitRateGradients.length > 0 && (this._currentEmitRateGradient = this._emitRateGradients[0], this._currentEmitRate1 = this._currentEmitRateGradient.getFactor(), this._currentEmitRate2 = this._currentEmitRate1), this._emitRateGradients.length > 1 && (this._currentEmitRate2 = this._emitRateGradients[1].getFactor())), this._startSizeGradients && (this._startSizeGradients.length > 0 && (this._currentStartSizeGradient = this._startSizeGradients[0], this._currentStartSize1 = this._currentStartSizeGradient.getFactor(), this._currentStartSize2 = this._currentStartSize1), this._startSizeGradients.length > 1 && (this._currentStartSize2 = this._startSizeGradients[1].getFactor())), this.preWarmCycles) {
            ((i = this.emitter) === null || i === void 0 ? void 0 : i.getClassName().indexOf("Mesh")) !== -1 && this.emitter.computeWorldMatrix(!0);
            var o = this.noiseTexture;
            if (o && o.onGeneratedObservable)
              o.onGeneratedObservable.addOnce(function() {
                setTimeout(function() {
                  for (var s = 0; s < r.preWarmCycles; s++)
                    r.animate(!0), o.render();
                });
              });
            else
              for (var a = 0; a < this.preWarmCycles; a++)
                this.animate(!0);
          }
          this.beginAnimationOnStart && this.animations && this.animations.length > 0 && this._scene && this._scene.beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
        }
      }, t.prototype.stop = function(e) {
        e === void 0 && (e = !0), this._stopped || (this.onStoppedObservable.notifyObservers(this), this._stopped = !0, e && this._stopSubEmitters());
      }, t.prototype.reset = function() {
        this._stockParticles.length = 0, this._particles.length = 0;
      }, t.prototype._appendParticleVertex = function(e, i, r, o) {
        var a = e * this._vertexBufferSize;
        if (this._vertexData[a++] = i.position.x + this.worldOffset.x, this._vertexData[a++] = i.position.y + this.worldOffset.y, this._vertexData[a++] = i.position.z + this.worldOffset.z, this._vertexData[a++] = i.color.r, this._vertexData[a++] = i.color.g, this._vertexData[a++] = i.color.b, this._vertexData[a++] = i.color.a, this._vertexData[a++] = i.angle, this._vertexData[a++] = i.scale.x * i.size, this._vertexData[a++] = i.scale.y * i.size, this._isAnimationSheetEnabled && (this._vertexData[a++] = i.cellIndex), this._isBillboardBased)
          this.billboardMode !== t.BILLBOARDMODE_STRETCHED && this.billboardMode !== t.BILLBOARDMODE_STRETCHED_LOCAL || (this._vertexData[a++] = i.direction.x, this._vertexData[a++] = i.direction.y, this._vertexData[a++] = i.direction.z);
        else if (i._initialDirection) {
          var s = i._initialDirection;
          this.isLocal && (v.TransformNormalToRef(s, this._emitterWorldMatrix, F.Vector3[0]), s = F.Vector3[0]), s.x === 0 && s.z === 0 && (s.x = 1e-3), this._vertexData[a++] = s.x, this._vertexData[a++] = s.y, this._vertexData[a++] = s.z;
        } else {
          var l = i.direction;
          this.isLocal && (v.TransformNormalToRef(l, this._emitterWorldMatrix, F.Vector3[0]), l = F.Vector3[0]), l.x === 0 && l.z === 0 && (l.x = 1e-3), this._vertexData[a++] = l.x, this._vertexData[a++] = l.y, this._vertexData[a++] = l.z;
        }
        this._useRampGradients && i.remapData && (this._vertexData[a++] = i.remapData.x, this._vertexData[a++] = i.remapData.y, this._vertexData[a++] = i.remapData.z, this._vertexData[a++] = i.remapData.w), this._useInstancing || (this._isAnimationSheetEnabled && (r === 0 ? r = this._epsilon : r === 1 && (r = 1 - this._epsilon), o === 0 ? o = this._epsilon : o === 1 && (o = 1 - this._epsilon)), this._vertexData[a++] = r, this._vertexData[a++] = o);
      }, t.prototype._stopSubEmitters = function() {
        this.activeSubSystems && (this.activeSubSystems.forEach(function(e) {
          e.stop(!0);
        }), this.activeSubSystems = []);
      }, t.prototype._removeFromRoot = function() {
        if (this._rootParticleSystem) {
          var e = this._rootParticleSystem.activeSubSystems.indexOf(this);
          e !== -1 && this._rootParticleSystem.activeSubSystems.splice(e, 1), this._rootParticleSystem = null;
        }
      }, t.prototype._update = function(e) {
        var i, r = this;
        if (this._alive = this._particles.length > 0, this.emitter.position) {
          var o = this.emitter;
          this._emitterWorldMatrix = o.getWorldMatrix();
        } else {
          var a = this.emitter;
          this._emitterWorldMatrix = B.Translation(a.x, a.y, a.z);
        }
        this._emitterWorldMatrix.invertToRef(this._emitterInverseWorldMatrix), this.updateFunction(this._particles);
        for (var s = function(u) {
          if (l._particles.length === l._capacity)
            return "break";
          if (i = l._createParticle(), l._particles.push(i), l.targetStopDuration && l._lifeTimeGradients && l._lifeTimeGradients.length > 0) {
            var h = ue.Clamp(l._actualFrame / l.targetStopDuration);
            sr.GetCurrentGradient(h, l._lifeTimeGradients, function(m, g) {
              var y = m, b = g, T = y.getFactor(), S = b.getFactor(), E = (h - y.gradient) / (b.gradient - y.gradient);
              i.lifeTime = ue.Lerp(T, S, E);
            });
          } else
            i.lifeTime = ue.RandomRange(l.minLifeTime, l.maxLifeTime);
          var d = ue.RandomRange(l.minEmitPower, l.maxEmitPower);
          if (l.startPositionFunction ? l.startPositionFunction(l._emitterWorldMatrix, i.position, i, l.isLocal) : l.particleEmitterType.startPositionFunction(l._emitterWorldMatrix, i.position, i, l.isLocal), l.isLocal && (i._localPosition ? i._localPosition.copyFrom(i.position) : i._localPosition = i.position.clone(), v.TransformCoordinatesToRef(i._localPosition, l._emitterWorldMatrix, i.position)), l.startDirectionFunction ? l.startDirectionFunction(l._emitterWorldMatrix, i.direction, i, l.isLocal) : l.particleEmitterType.startDirectionFunction(l._emitterWorldMatrix, i.direction, i, l.isLocal, l._emitterInverseWorldMatrix), d === 0 ? i._initialDirection ? i._initialDirection.copyFrom(i.direction) : i._initialDirection = i.direction.clone() : i._initialDirection = null, i.direction.scaleInPlace(d), l._sizeGradients && l._sizeGradients.length !== 0 ? (i._currentSizeGradient = l._sizeGradients[0], i._currentSize1 = i._currentSizeGradient.getFactor(), i.size = i._currentSize1, l._sizeGradients.length > 1 ? i._currentSize2 = l._sizeGradients[1].getFactor() : i._currentSize2 = i._currentSize1) : i.size = ue.RandomRange(l.minSize, l.maxSize), i.scale.copyFromFloats(ue.RandomRange(l.minScaleX, l.maxScaleX), ue.RandomRange(l.minScaleY, l.maxScaleY)), l._startSizeGradients && l._startSizeGradients[0] && l.targetStopDuration) {
            var p = l._actualFrame / l.targetStopDuration;
            sr.GetCurrentGradient(p, l._startSizeGradients, function(m, g, y) {
              m !== r._currentStartSizeGradient && (r._currentStartSize1 = r._currentStartSize2, r._currentStartSize2 = g.getFactor(), r._currentStartSizeGradient = m);
              var b = ue.Lerp(r._currentStartSize1, r._currentStartSize2, y);
              i.scale.scaleInPlace(b);
            });
          }
          if (l._angularSpeedGradients && l._angularSpeedGradients.length !== 0 ? (i._currentAngularSpeedGradient = l._angularSpeedGradients[0], i.angularSpeed = i._currentAngularSpeedGradient.getFactor(), i._currentAngularSpeed1 = i.angularSpeed, l._angularSpeedGradients.length > 1 ? i._currentAngularSpeed2 = l._angularSpeedGradients[1].getFactor() : i._currentAngularSpeed2 = i._currentAngularSpeed1) : i.angularSpeed = ue.RandomRange(l.minAngularSpeed, l.maxAngularSpeed), i.angle = ue.RandomRange(l.minInitialRotation, l.maxInitialRotation), l._velocityGradients && l._velocityGradients.length > 0 && (i._currentVelocityGradient = l._velocityGradients[0], i._currentVelocity1 = i._currentVelocityGradient.getFactor(), l._velocityGradients.length > 1 ? i._currentVelocity2 = l._velocityGradients[1].getFactor() : i._currentVelocity2 = i._currentVelocity1), l._limitVelocityGradients && l._limitVelocityGradients.length > 0 && (i._currentLimitVelocityGradient = l._limitVelocityGradients[0], i._currentLimitVelocity1 = i._currentLimitVelocityGradient.getFactor(), l._limitVelocityGradients.length > 1 ? i._currentLimitVelocity2 = l._limitVelocityGradients[1].getFactor() : i._currentLimitVelocity2 = i._currentLimitVelocity1), l._dragGradients && l._dragGradients.length > 0 && (i._currentDragGradient = l._dragGradients[0], i._currentDrag1 = i._currentDragGradient.getFactor(), l._dragGradients.length > 1 ? i._currentDrag2 = l._dragGradients[1].getFactor() : i._currentDrag2 = i._currentDrag1), l._colorGradients && l._colorGradients.length !== 0)
            i._currentColorGradient = l._colorGradients[0], i._currentColorGradient.getColorToRef(i.color), i._currentColor1.copyFrom(i.color), l._colorGradients.length > 1 ? l._colorGradients[1].getColorToRef(i._currentColor2) : i._currentColor2.copyFrom(i.color);
          else {
            var f = ue.RandomRange(0, 1);
            Ie.LerpToRef(l.color1, l.color2, f, i.color), l.colorDead.subtractToRef(i.color, l._colorDiff), l._colorDiff.scaleToRef(1 / i.lifeTime, i.colorStep);
          }
          l._isAnimationSheetEnabled && (i._initialStartSpriteCellID = l.startSpriteCellID, i._initialEndSpriteCellID = l.endSpriteCellID, i._initialSpriteCellLoop = l.spriteCellLoop), i.direction.addInPlace(l._inheritedVelocityOffset), l._useRampGradients && (i.remapData = new lt(0, 1, 0, 1)), l.noiseTexture && (i._randomNoiseCoordinates1 ? (i._randomNoiseCoordinates1.copyFromFloats(Math.random(), Math.random(), Math.random()), i._randomNoiseCoordinates2.copyFromFloats(Math.random(), Math.random(), Math.random())) : (i._randomNoiseCoordinates1 = new v(Math.random(), Math.random(), Math.random()), i._randomNoiseCoordinates2 = new v(Math.random(), Math.random(), Math.random()))), i._inheritParticleInfoToSubEmitters();
        }, l = this, c = 0; c < e && s() !== "break"; c++)
          ;
      }, t._GetAttributeNamesOrOptions = function(e, i, r) {
        e === void 0 && (e = !1), i === void 0 && (i = !1), r === void 0 && (r = !1);
        var o = [P.PositionKind, P.ColorKind, "angle", "offset", "size"];
        return e && o.push("cellIndex"), i || o.push("direction"), r && o.push("remapData"), o;
      }, t._GetEffectCreationOptions = function(e, i) {
        e === void 0 && (e = !1), i === void 0 && (i = !1);
        var r = ["invView", "view", "projection", "textureMask", "translationPivot", "eyePosition"];
        return Br(r), e && r.push("particlesInfos"), i && r.push("logarithmicDepthConstant"), r;
      }, t.prototype.fillDefines = function(e, i) {
        if (this._scene && aa(this, this._scene, e), this._isAnimationSheetEnabled && e.push("#define ANIMATESHEET"), this.useLogarithmicDepth && e.push("#define LOGARITHMICDEPTH"), i === t.BLENDMODE_MULTIPLY && e.push("#define BLENDMULTIPLYMODE"), this._useRampGradients && e.push("#define RAMPGRADIENT"), this._isBillboardBased)
          switch (e.push("#define BILLBOARD"), this.billboardMode) {
            case t.BILLBOARDMODE_Y:
              e.push("#define BILLBOARDY");
              break;
            case t.BILLBOARDMODE_STRETCHED:
            case t.BILLBOARDMODE_STRETCHED_LOCAL:
              e.push("#define BILLBOARDSTRETCHED"), this.billboardMode === t.BILLBOARDMODE_STRETCHED_LOCAL && e.push("#define BILLBOARDSTRETCHED_LOCAL");
              break;
            case t.BILLBOARDMODE_ALL:
              e.push("#define BILLBOARDMODE_ALL");
          }
        this._imageProcessingConfiguration && (this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines), e.push(this._imageProcessingConfigurationDefines.toString()));
      }, t.prototype.fillUniformsAttributesAndSamplerNames = function(e, i, r) {
        i.push.apply(i, t._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled, this._isBillboardBased && this.billboardMode !== t.BILLBOARDMODE_STRETCHED && this.billboardMode !== t.BILLBOARDMODE_STRETCHED_LOCAL, this._useRampGradients)), e.push.apply(e, t._GetEffectCreationOptions(this._isAnimationSheetEnabled, this.useLogarithmicDepth)), r.push("diffuseSampler", "rampSampler"), this._imageProcessingConfiguration && (tn.PrepareUniforms(e, this._imageProcessingConfigurationDefines), tn.PrepareSamplers(r, this._imageProcessingConfigurationDefines));
      }, t.prototype._getWrapper = function(e) {
        var i = this._getCustomDrawWrapper(e);
        if (i != null && i.effect)
          return i;
        var r = [];
        this.fillDefines(r, e);
        var o = this._engine._features.supportRenderPasses ? this._engine.currentRenderPassId : _.RENDERPASS_MAIN, a = this._drawWrappers[o];
        a || (a = this._drawWrappers[o] = []);
        var s = a[e];
        s || ((s = new Ei(this._engine)).drawContext && (s.drawContext.useInstancing = this._useInstancing), a[e] = s);
        var l = r.join(`
`);
        if (s.defines !== l) {
          var c = [], u = [], h = [];
          this.fillUniformsAttributesAndSamplerNames(u, c, h), s.setEffect(this._engine.createEffect("particles", c, u, h, l), l);
        }
        return s;
      }, t.prototype.animate = function(e) {
        var i, r = this;
        if (e === void 0 && (e = !1), this._started) {
          if (!e && this._scene) {
            if (!this.isReady() || this._currentRenderId === this._scene.getFrameId())
              return;
            this._currentRenderId = this._scene.getFrameId();
          }
          var o;
          if (this._scaledUpdateSpeed = this.updateSpeed * (e ? this.preWarmStepOffset : ((i = this._scene) === null || i === void 0 ? void 0 : i.getAnimationRatio()) || 1), this.manualEmitCount > -1)
            o = this.manualEmitCount, this._newPartsExcess = 0, this.manualEmitCount = 0;
          else {
            var a = this.emitRate;
            if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
              var s = this._actualFrame / this.targetStopDuration;
              sr.GetCurrentGradient(s, this._emitRateGradients, function(h, d, p) {
                h !== r._currentEmitRateGradient && (r._currentEmitRate1 = r._currentEmitRate2, r._currentEmitRate2 = d.getFactor(), r._currentEmitRateGradient = h), a = ue.Lerp(r._currentEmitRate1, r._currentEmitRate2, p);
              });
            }
            o = a * this._scaledUpdateSpeed >> 0, this._newPartsExcess += a * this._scaledUpdateSpeed - o;
          }
          if (this._newPartsExcess > 1 && (o += this._newPartsExcess >> 0, this._newPartsExcess -= this._newPartsExcess >> 0), this._alive = !1, this._stopped ? o = 0 : (this._actualFrame += this._scaledUpdateSpeed, this.targetStopDuration && this._actualFrame >= this.targetStopDuration && this.stop()), this._update(o), this._stopped && (this._alive || (this._started = !1, this.onAnimationEnd && this.onAnimationEnd(), this.disposeOnStop && this._scene && this._scene._toBeDisposed.push(this))), !e) {
            for (var l = 0, c = 0; c < this._particles.length; c++) {
              var u = this._particles[c];
              this._appendParticleVertices(l, u), l += this._useInstancing ? 1 : 4;
            }
            this._vertexBuffer && this._vertexBuffer.updateDirectly(this._vertexData, 0, this._particles.length);
          }
          this.manualEmitCount === 0 && this.disposeOnStop && this.stop();
        }
      }, t.prototype._appendParticleVertices = function(e, i) {
        this._appendParticleVertex(e++, i, 0, 0), this._useInstancing || (this._appendParticleVertex(e++, i, 1, 0), this._appendParticleVertex(e++, i, 1, 1), this._appendParticleVertex(e++, i, 0, 1));
      }, t.prototype.rebuild = function() {
        var e, i;
        for (var r in this._engine.getCaps().vertexArrayObject && (this._vertexArrayObject = null), this._createIndexBuffer(), (e = this._spriteBuffer) === null || e === void 0 || e._rebuild(), (i = this._vertexBuffer) === null || i === void 0 || i._rebuild(), this._vertexBuffers)
          this._vertexBuffers[r]._rebuild();
        this.resetDrawCache();
      }, t.prototype.isReady = function() {
        if (!this.emitter || this._imageProcessingConfiguration && !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady())
          return !1;
        if (this.blendMode !== t.BLENDMODE_MULTIPLYADD) {
          if (!this._getWrapper(this.blendMode).effect.isReady())
            return !1;
        } else if (!this._getWrapper(t.BLENDMODE_MULTIPLY).effect.isReady() || !this._getWrapper(t.BLENDMODE_ADD).effect.isReady())
          return !1;
        return !0;
      }, t.prototype._render = function(e) {
        var i, r, o, a, s, l, c, u, h = this._getWrapper(e), d = h.effect, p = this._engine;
        p.enableEffect(h);
        var f = (i = this.defaultViewMatrix) !== null && i !== void 0 ? i : this._scene.getViewMatrix();
        if (d.setTexture("diffuseSampler", this.particleTexture), d.setMatrix("view", f), d.setMatrix("projection", (r = this.defaultProjectionMatrix) !== null && r !== void 0 ? r : this._scene.getProjectionMatrix()), this._isAnimationSheetEnabled && this.particleTexture) {
          var m = this.particleTexture.getBaseSize();
          d.setFloat3("particlesInfos", this.spriteCellWidth / m.width, this.spriteCellHeight / m.height, this.spriteCellWidth / m.width);
        }
        if (d.setVector2("translationPivot", this.translationPivot), d.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a), this._isBillboardBased && this._scene) {
          var g = this._scene.activeCamera;
          d.setVector3("eyePosition", g.globalPosition);
        }
        this._rampGradientsTexture && (this._rampGradients && this._rampGradients.length || (this._rampGradientsTexture.dispose(), this._rampGradientsTexture = null), d.setTexture("rampSampler", this._rampGradientsTexture));
        var y = d.defines;
        switch (this._scene && Ar(d, this, this._scene), y.indexOf("#define BILLBOARDMODE_ALL") >= 0 && (f.invertToRef(F.Matrix[0]), d.setMatrix("invView", F.Matrix[0])), this._vertexArrayObject !== void 0 ? !((o = this._scene) === null || o === void 0) && o.forceWireframe ? p.bindBuffers(this._vertexBuffers, this._linesIndexBufferUseInstancing, d) : (this._vertexArrayObject || (this._vertexArrayObject = this._engine.recordVertexArrayObject(this._vertexBuffers, null, d)), this._engine.bindVertexArrayObject(this._vertexArrayObject, !((a = this._scene) === null || a === void 0) && a.forceWireframe ? this._linesIndexBufferUseInstancing : this._indexBuffer)) : this._indexBuffer ? p.bindBuffers(this._vertexBuffers, !((l = this._scene) === null || l === void 0) && l.forceWireframe ? this._linesIndexBuffer : this._indexBuffer, d) : p.bindBuffers(this._vertexBuffers, !((s = this._scene) === null || s === void 0) && s.forceWireframe ? this._linesIndexBufferUseInstancing : null, d), this.useLogarithmicDepth && this._scene && Se.BindLogDepth(y, d, this._scene), this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess && this._imageProcessingConfiguration.bind(d), e) {
          case t.BLENDMODE_ADD:
            p.setAlphaMode(_.ALPHA_ADD);
            break;
          case t.BLENDMODE_ONEONE:
            p.setAlphaMode(_.ALPHA_ONEONE);
            break;
          case t.BLENDMODE_STANDARD:
            p.setAlphaMode(_.ALPHA_COMBINE);
            break;
          case t.BLENDMODE_MULTIPLY:
            p.setAlphaMode(_.ALPHA_MULTIPLY);
        }
        return this._onBeforeDrawParticlesObservable && this._onBeforeDrawParticlesObservable.notifyObservers(d), this._useInstancing ? !((c = this._scene) === null || c === void 0) && c.forceWireframe ? p.drawElementsType(_.MATERIAL_LineStripDrawMode, 0, 10, this._particles.length) : p.drawArraysType(_.MATERIAL_TriangleStripDrawMode, 0, 4, this._particles.length) : !((u = this._scene) === null || u === void 0) && u.forceWireframe ? p.drawElementsType(_.MATERIAL_WireFrameFillMode, 0, 10 * this._particles.length) : p.drawElementsType(_.MATERIAL_TriangleFillMode, 0, 6 * this._particles.length), this._particles.length;
      }, t.prototype.render = function() {
        if (!this.isReady() || !this._particles.length)
          return 0;
        var e = this._engine;
        e.setState && (e.setState(!1), this.forceDepthWrite && e.setDepthWrite(!0));
        var i;
        return i = this.blendMode === t.BLENDMODE_MULTIPLYADD ? this._render(t.BLENDMODE_MULTIPLY) + this._render(t.BLENDMODE_ADD) : this._render(this.blendMode), this._engine.unbindInstanceAttributes(), this._engine.setAlphaMode(_.ALPHA_DISABLE), i;
      }, t.prototype.dispose = function(e) {
        if (e === void 0 && (e = !0), this.resetDrawCache(), this._vertexBuffer && (this._vertexBuffer.dispose(), this._vertexBuffer = null), this._spriteBuffer && (this._spriteBuffer.dispose(), this._spriteBuffer = null), this._indexBuffer && (this._engine._releaseBuffer(this._indexBuffer), this._indexBuffer = null), this._linesIndexBuffer && (this._engine._releaseBuffer(this._linesIndexBuffer), this._linesIndexBuffer = null), this._linesIndexBufferUseInstancing && (this._engine._releaseBuffer(this._linesIndexBufferUseInstancing), this._linesIndexBufferUseInstancing = null), this._vertexArrayObject && (this._engine.releaseVertexArrayObject(this._vertexArrayObject), this._vertexArrayObject = null), e && this.particleTexture && (this.particleTexture.dispose(), this.particleTexture = null), e && this.noiseTexture && (this.noiseTexture.dispose(), this.noiseTexture = null), this._rampGradientsTexture && (this._rampGradientsTexture.dispose(), this._rampGradientsTexture = null), this._removeFromRoot(), this.subEmitters && !this._subEmitters && this._prepareSubEmitterInternalArray(), this._subEmitters && this._subEmitters.length) {
          for (var i = 0; i < this._subEmitters.length; i++)
            for (var r = 0, o = this._subEmitters[i]; r < o.length; r++)
              o[r].dispose();
          this._subEmitters = [], this.subEmitters = [];
        }
        this._disposeEmitterOnDispose && this.emitter && this.emitter.dispose && this.emitter.dispose(!0), this._onBeforeDrawParticlesObservable && this._onBeforeDrawParticlesObservable.clear(), this._scene && ((i = this._scene.particleSystems.indexOf(this)) > -1 && this._scene.particleSystems.splice(i, 1), this._scene._activeParticleSystems.dispose()), this.onDisposeObservable.notifyObservers(this), this.onDisposeObservable.clear(), this.onStoppedObservable.clear(), this.reset();
      }, t.prototype.clone = function(e, i, r) {
        r === void 0 && (r = !1);
        var o = je({}, this._customWrappers), a = null, s = this._engine;
        if (s.createEffectForParticles && this.customShader != null) {
          var l = (a = this.customShader).shaderOptions.defines.length > 0 ? a.shaderOptions.defines.join(`
`) : "", c = s.createEffectForParticles(a.shaderPath.fragmentElement, a.shaderOptions.uniforms, a.shaderOptions.samplers, l);
          o[0] ? o[0].effect = c : this.setCustomEffect(c, 0);
        }
        var u = this.serialize(r), h = t.Parse(u, this._scene || this._engine, this._rootUrl);
        return h.name = e, h.customShader = a, h._customWrappers = o, i === void 0 && (i = this.emitter), this.noiseTexture && (h.noiseTexture = this.noiseTexture.clone()), h.emitter = i, this.preventAutoStart || h.start(), h;
      }, t.prototype.serialize = function(e) {
        e === void 0 && (e = !1);
        var i = {};
        if (t._Serialize(i, this, e), i.textureMask = this.textureMask.asArray(), i.customShader = this.customShader, i.preventAutoStart = this.preventAutoStart, this.subEmitters) {
          i.subEmitters = [], this._subEmitters || this._prepareSubEmitterInternalArray();
          for (var r = 0, o = this._subEmitters; r < o.length; r++) {
            for (var a = [], s = 0, l = o[r]; s < l.length; s++) {
              var c = l[s];
              a.push(c.serialize(e));
            }
            i.subEmitters.push(a);
          }
        }
        return i;
      }, t._Serialize = function(e, i, r) {
        if (e.name = i.name, e.id = i.id, e.capacity = i.getCapacity(), e.disposeOnStop = i.disposeOnStop, e.manualEmitCount = i.manualEmitCount, i.emitter.position) {
          var o = i.emitter;
          e.emitterId = o.id;
        } else {
          var a = i.emitter;
          e.emitter = a.asArray();
        }
        i.particleEmitterType && (e.particleEmitterType = i.particleEmitterType.serialize()), i.particleTexture && (r ? e.texture = i.particleTexture.serialize() : (e.textureName = i.particleTexture.name, e.invertY = !!i.particleTexture._invertY)), e.isLocal = i.isLocal, Ne.AppendSerializedAnimations(i, e), e.beginAnimationOnStart = i.beginAnimationOnStart, e.beginAnimationFrom = i.beginAnimationFrom, e.beginAnimationTo = i.beginAnimationTo, e.beginAnimationLoop = i.beginAnimationLoop, e.startDelay = i.startDelay, e.renderingGroupId = i.renderingGroupId, e.isBillboardBased = i.isBillboardBased, e.billboardMode = i.billboardMode, e.minAngularSpeed = i.minAngularSpeed, e.maxAngularSpeed = i.maxAngularSpeed, e.minSize = i.minSize, e.maxSize = i.maxSize, e.minScaleX = i.minScaleX, e.maxScaleX = i.maxScaleX, e.minScaleY = i.minScaleY, e.maxScaleY = i.maxScaleY, e.minEmitPower = i.minEmitPower, e.maxEmitPower = i.maxEmitPower, e.minLifeTime = i.minLifeTime, e.maxLifeTime = i.maxLifeTime, e.emitRate = i.emitRate, e.gravity = i.gravity.asArray(), e.noiseStrength = i.noiseStrength.asArray(), e.color1 = i.color1.asArray(), e.color2 = i.color2.asArray(), e.colorDead = i.colorDead.asArray(), e.updateSpeed = i.updateSpeed, e.targetStopDuration = i.targetStopDuration, e.blendMode = i.blendMode, e.preWarmCycles = i.preWarmCycles, e.preWarmStepOffset = i.preWarmStepOffset, e.minInitialRotation = i.minInitialRotation, e.maxInitialRotation = i.maxInitialRotation, e.startSpriteCellID = i.startSpriteCellID, e.spriteCellLoop = i.spriteCellLoop, e.endSpriteCellID = i.endSpriteCellID, e.spriteCellChangeSpeed = i.spriteCellChangeSpeed, e.spriteCellWidth = i.spriteCellWidth, e.spriteCellHeight = i.spriteCellHeight, e.spriteRandomStartCell = i.spriteRandomStartCell, e.isAnimationSheetEnabled = i.isAnimationSheetEnabled, e.useLogarithmicDepth = i.useLogarithmicDepth;
        var s = i.getColorGradients();
        if (s) {
          e.colorGradients = [];
          for (var l = 0, c = s; l < c.length; l++) {
            var u = c[l], h = { gradient: u.gradient, color1: u.color1.asArray() };
            u.color2 ? h.color2 = u.color2.asArray() : h.color2 = u.color1.asArray(), e.colorGradients.push(h);
          }
        }
        var d = i.getRampGradients();
        if (d) {
          e.rampGradients = [];
          for (var p = 0, f = d; p < f.length; p++) {
            var m = f[p];
            h = { gradient: m.gradient, color: m.color.asArray() }, e.rampGradients.push(h);
          }
          e.useRampGradients = i.useRampGradients;
        }
        var g = i.getColorRemapGradients();
        if (g) {
          e.colorRemapGradients = [];
          for (var y = 0, b = g; y < b.length; y++) {
            var T = b[y];
            h = { gradient: T.gradient, factor1: T.factor1 }, T.factor2 !== void 0 ? h.factor2 = T.factor2 : h.factor2 = T.factor1, e.colorRemapGradients.push(h);
          }
        }
        var S = i.getAlphaRemapGradients();
        if (S) {
          e.alphaRemapGradients = [];
          for (var E = 0, A = S; E < A.length; E++) {
            var R = A[E];
            h = { gradient: R.gradient, factor1: R.factor1 }, R.factor2 !== void 0 ? h.factor2 = R.factor2 : h.factor2 = R.factor1, e.alphaRemapGradients.push(h);
          }
        }
        var C = i.getSizeGradients();
        if (C) {
          e.sizeGradients = [];
          for (var L = 0, I = C; L < I.length; L++) {
            var O = I[L];
            h = { gradient: O.gradient, factor1: O.factor1 }, O.factor2 !== void 0 ? h.factor2 = O.factor2 : h.factor2 = O.factor1, e.sizeGradients.push(h);
          }
        }
        var w = i.getAngularSpeedGradients();
        if (w) {
          e.angularSpeedGradients = [];
          for (var z = 0, V = w; z < V.length; z++) {
            var Y = V[z];
            h = { gradient: Y.gradient, factor1: Y.factor1 }, Y.factor2 !== void 0 ? h.factor2 = Y.factor2 : h.factor2 = Y.factor1, e.angularSpeedGradients.push(h);
          }
        }
        var ee = i.getVelocityGradients();
        if (ee) {
          e.velocityGradients = [];
          for (var J = 0, X = ee; J < X.length; J++) {
            var K = X[J];
            h = { gradient: K.gradient, factor1: K.factor1 }, K.factor2 !== void 0 ? h.factor2 = K.factor2 : h.factor2 = K.factor1, e.velocityGradients.push(h);
          }
        }
        var te = i.getDragGradients();
        if (te) {
          e.dragGradients = [];
          for (var se = 0, _e = te; se < _e.length; se++) {
            var xe = _e[se];
            h = { gradient: xe.gradient, factor1: xe.factor1 }, xe.factor2 !== void 0 ? h.factor2 = xe.factor2 : h.factor2 = xe.factor1, e.dragGradients.push(h);
          }
        }
        var Te = i.getEmitRateGradients();
        if (Te) {
          e.emitRateGradients = [];
          for (var he = 0, me = Te; he < me.length; he++) {
            var Fe = me[he];
            h = { gradient: Fe.gradient, factor1: Fe.factor1 }, Fe.factor2 !== void 0 ? h.factor2 = Fe.factor2 : h.factor2 = Fe.factor1, e.emitRateGradients.push(h);
          }
        }
        var Ce = i.getStartSizeGradients();
        if (Ce) {
          e.startSizeGradients = [];
          for (var Re = 0, Be = Ce; Re < Be.length; Re++) {
            var De = Be[Re];
            h = { gradient: De.gradient, factor1: De.factor1 }, De.factor2 !== void 0 ? h.factor2 = De.factor2 : h.factor2 = De.factor1, e.startSizeGradients.push(h);
          }
        }
        var Ke = i.getLifeTimeGradients();
        if (Ke) {
          e.lifeTimeGradients = [];
          for (var ge = 0, rt = Ke; ge < rt.length; ge++) {
            var it = rt[ge];
            h = { gradient: it.gradient, factor1: it.factor1 }, it.factor2 !== void 0 ? h.factor2 = it.factor2 : h.factor2 = it.factor1, e.lifeTimeGradients.push(h);
          }
        }
        var He = i.getLimitVelocityGradients();
        if (He) {
          e.limitVelocityGradients = [];
          for (var Pt = 0, ke = He; Pt < ke.length; Pt++) {
            var xt = ke[Pt];
            h = { gradient: xt.gradient, factor1: xt.factor1 }, xt.factor2 !== void 0 ? h.factor2 = xt.factor2 : h.factor2 = xt.factor1, e.limitVelocityGradients.push(h);
          }
          e.limitVelocityDamping = i.limitVelocityDamping;
        }
        i.noiseTexture && (e.noiseTexture = i.noiseTexture.serialize());
      }, t._Parse = function(e, i, r, o) {
        var a, s, l, c;
        c = r instanceof Qe ? null : r;
        var u, h = Kt("BABYLON.Texture");
        if (h && c && (e.texture ? i.particleTexture = h.Parse(e.texture, c, o) : e.textureName && (i.particleTexture = new h(o + e.textureName, c, !1, e.invertY === void 0 || e.invertY), i.particleTexture.name = e.textureName)), e.emitterId || e.emitterId === 0 || e.emitter !== void 0 ? e.emitterId && c ? i.emitter = c.getLastMeshById(e.emitterId) : i.emitter = v.FromArray(e.emitter) : i.emitter = v.Zero(), i.isLocal = !!e.isLocal, e.renderingGroupId !== void 0 && (i.renderingGroupId = e.renderingGroupId), e.isBillboardBased !== void 0 && (i.isBillboardBased = e.isBillboardBased), e.billboardMode !== void 0 && (i.billboardMode = e.billboardMode), e.useLogarithmicDepth !== void 0 && (i.useLogarithmicDepth = e.useLogarithmicDepth), e.animations) {
          for (var d = 0; d < e.animations.length; d++) {
            var p = e.animations[d], f = Kt("BABYLON.Animation");
            f && i.animations.push(f.Parse(p));
          }
          i.beginAnimationOnStart = e.beginAnimationOnStart, i.beginAnimationFrom = e.beginAnimationFrom, i.beginAnimationTo = e.beginAnimationTo, i.beginAnimationLoop = e.beginAnimationLoop;
        }
        if (e.autoAnimate && c && c.beginAnimation(i, e.autoAnimateFrom, e.autoAnimateTo, e.autoAnimateLoop, e.autoAnimateSpeed || 1), i.startDelay = 0 | e.startDelay, i.minAngularSpeed = e.minAngularSpeed, i.maxAngularSpeed = e.maxAngularSpeed, i.minSize = e.minSize, i.maxSize = e.maxSize, e.minScaleX && (i.minScaleX = e.minScaleX, i.maxScaleX = e.maxScaleX, i.minScaleY = e.minScaleY, i.maxScaleY = e.maxScaleY), e.preWarmCycles !== void 0 && (i.preWarmCycles = e.preWarmCycles, i.preWarmStepOffset = e.preWarmStepOffset), e.minInitialRotation !== void 0 && (i.minInitialRotation = e.minInitialRotation, i.maxInitialRotation = e.maxInitialRotation), i.minLifeTime = e.minLifeTime, i.maxLifeTime = e.maxLifeTime, i.minEmitPower = e.minEmitPower, i.maxEmitPower = e.maxEmitPower, i.emitRate = e.emitRate, i.gravity = v.FromArray(e.gravity), e.noiseStrength && (i.noiseStrength = v.FromArray(e.noiseStrength)), i.color1 = Ie.FromArray(e.color1), i.color2 = Ie.FromArray(e.color2), i.colorDead = Ie.FromArray(e.colorDead), i.updateSpeed = e.updateSpeed, i.targetStopDuration = e.targetStopDuration, i.blendMode = e.blendMode, e.colorGradients)
          for (var m = 0, g = e.colorGradients; m < g.length; m++) {
            var y = g[m];
            i.addColorGradient(y.gradient, Ie.FromArray(y.color1), y.color2 ? Ie.FromArray(y.color2) : void 0);
          }
        if (e.rampGradients) {
          for (var b = 0, T = e.rampGradients; b < T.length; b++) {
            var S = T[b];
            i.addRampGradient(S.gradient, ne.FromArray(S.color));
          }
          i.useRampGradients = e.useRampGradients;
        }
        if (e.colorRemapGradients)
          for (var E = 0, A = e.colorRemapGradients; E < A.length; E++) {
            var R = A[E];
            i.addColorRemapGradient(R.gradient, R.factor1 !== void 0 ? R.factor1 : R.factor, R.factor2);
          }
        if (e.alphaRemapGradients)
          for (var C = 0, L = e.alphaRemapGradients; C < L.length; C++) {
            var I = L[C];
            i.addAlphaRemapGradient(I.gradient, I.factor1 !== void 0 ? I.factor1 : I.factor, I.factor2);
          }
        if (e.sizeGradients)
          for (var O = 0, w = e.sizeGradients; O < w.length; O++) {
            var z = w[O];
            i.addSizeGradient(z.gradient, z.factor1 !== void 0 ? z.factor1 : z.factor, z.factor2);
          }
        if (e.angularSpeedGradients)
          for (var V = 0, Y = e.angularSpeedGradients; V < Y.length; V++) {
            var ee = Y[V];
            i.addAngularSpeedGradient(ee.gradient, ee.factor1 !== void 0 ? ee.factor1 : ee.factor, ee.factor2);
          }
        if (e.velocityGradients)
          for (var J = 0, X = e.velocityGradients; J < X.length; J++) {
            var K = X[J];
            i.addVelocityGradient(K.gradient, K.factor1 !== void 0 ? K.factor1 : K.factor, K.factor2);
          }
        if (e.dragGradients)
          for (var te = 0, se = e.dragGradients; te < se.length; te++) {
            var _e = se[te];
            i.addDragGradient(_e.gradient, _e.factor1 !== void 0 ? _e.factor1 : _e.factor, _e.factor2);
          }
        if (e.emitRateGradients)
          for (var xe = 0, Te = e.emitRateGradients; xe < Te.length; xe++) {
            var he = Te[xe];
            i.addEmitRateGradient(he.gradient, he.factor1 !== void 0 ? he.factor1 : he.factor, he.factor2);
          }
        if (e.startSizeGradients)
          for (var me = 0, Fe = e.startSizeGradients; me < Fe.length; me++) {
            var Ce = Fe[me];
            i.addStartSizeGradient(Ce.gradient, Ce.factor1 !== void 0 ? Ce.factor1 : Ce.factor, Ce.factor2);
          }
        if (e.lifeTimeGradients)
          for (var Re = 0, Be = e.lifeTimeGradients; Re < Be.length; Re++) {
            var De = Be[Re];
            i.addLifeTimeGradient(De.gradient, De.factor1 !== void 0 ? De.factor1 : De.factor, De.factor2);
          }
        if (e.limitVelocityGradients) {
          for (var Ke = 0, ge = e.limitVelocityGradients; Ke < ge.length; Ke++) {
            var rt = ge[Ke];
            i.addLimitVelocityGradient(rt.gradient, rt.factor1 !== void 0 ? rt.factor1 : rt.factor, rt.factor2);
          }
          i.limitVelocityDamping = e.limitVelocityDamping;
        }
        if (e.noiseTexture && c) {
          var it = Kt("BABYLON.ProceduralTexture");
          i.noiseTexture = it.Parse(e.noiseTexture, c, o);
        }
        if (e.particleEmitterType) {
          switch (e.particleEmitterType.type) {
            case "SphereParticleEmitter":
              u = new ih();
              break;
            case "SphereDirectedParticleEmitter":
              u = new kp();
              break;
            case "ConeEmitter":
            case "ConeParticleEmitter":
              u = new wp();
              break;
            case "CylinderParticleEmitter":
              u = new th();
              break;
            case "CylinderDirectedParticleEmitter":
              u = new Bp();
              break;
            case "HemisphericParticleEmitter":
              u = new Up();
              break;
            case "PointParticleEmitter":
              u = new Vp();
              break;
            case "MeshParticleEmitter":
              u = new Lg();
              break;
            default:
              u = new _l();
          }
          u.parse(e.particleEmitterType, c);
        } else
          (u = new _l()).parse(e, c);
        i.particleEmitterType = u, i.startSpriteCellID = e.startSpriteCellID, i.endSpriteCellID = e.endSpriteCellID, i.spriteCellLoop = (a = e.spriteCellLoop) === null || a === void 0 || a, i.spriteCellWidth = e.spriteCellWidth, i.spriteCellHeight = e.spriteCellHeight, i.spriteCellChangeSpeed = e.spriteCellChangeSpeed, i.spriteRandomStartCell = e.spriteRandomStartCell, i.disposeOnStop = (s = e.disposeOnStop) !== null && s !== void 0 && s, i.manualEmitCount = (l = e.manualEmitCount) !== null && l !== void 0 ? l : -1;
      }, t.Parse = function(e, i, r, o, a) {
        o === void 0 && (o = !1);
        var s, l = e.name, c = null, u = null;
        if (s = i instanceof Qe ? i : i.getEngine(), e.customShader && s.createEffectForParticles) {
          var h = (u = e.customShader).shaderOptions.defines.length > 0 ? u.shaderOptions.defines.join(`
`) : "";
          c = s.createEffectForParticles(u.shaderPath.fragmentElement, u.shaderOptions.uniforms, u.shaderOptions.samplers, h);
        }
        var d = new t(l, a || e.capacity, i, c, e.isAnimationSheetEnabled);
        if (d.customShader = u, d._rootUrl = r, e.id && (d.id = e.id), e.subEmitters) {
          d.subEmitters = [];
          for (var p = 0, f = e.subEmitters; p < f.length; p++) {
            for (var m = [], g = 0, y = f[p]; g < y.length; g++) {
              var b = y[g];
              m.push(cu.Parse(b, i, r));
            }
            d.subEmitters.push(m);
          }
        }
        return t._Parse(e, d, i, r), e.textureMask && (d.textureMask = Ie.FromArray(e.textureMask)), e.preventAutoStart && (d.preventAutoStart = e.preventAutoStart), o || d.preventAutoStart || d.start(), d;
      }, t.BILLBOARDMODE_Y = _.PARTICLES_BILLBOARDMODE_Y, t.BILLBOARDMODE_ALL = _.PARTICLES_BILLBOARDMODE_ALL, t.BILLBOARDMODE_STRETCHED = _.PARTICLES_BILLBOARDMODE_STRETCHED, t.BILLBOARDMODE_STRETCHED_LOCAL = _.PARTICLES_BILLBOARDMODE_STRETCHED_LOCAL, t;
    }(fc);
    cu._ParseParticleSystem = Ai.Parse, re.IncludesShadersStore.clipPlaneFragmentDeclaration2 = `#ifdef CLIPPLANE
in float fClipDistance;
#endif
#ifdef CLIPPLANE2
in float fClipDistance2;
#endif
#ifdef CLIPPLANE3
in float fClipDistance3;
#endif
#ifdef CLIPPLANE4
in float fClipDistance4;
#endif
#ifdef CLIPPLANE5
in float fClipDistance5;
#endif
#ifdef CLIPPLANE6
in float fClipDistance6;
#endif
`, re.ShadersStore.gpuRenderParticlesPixelShader = `precision highp float;
#ifdef LOGARITHMICDEPTH
#extension GL_EXT_frag_depth : enable
#endif
uniform sampler2D diffuseSampler;varying vec2 vUV;varying vec4 vColor;
#include<clipPlaneFragmentDeclaration2> 
#include<imageProcessingDeclaration>
#include<logDepthDeclaration>
#include<helperFunctions>
#include<imageProcessingFunctions>
void main() {
#include<clipPlaneFragment> 
vec4 textureColor=texture2D(diffuseSampler,vUV);gl_FragColor=textureColor*vColor;
#ifdef BLENDMULTIPLYMODE
float alpha=vColor.a*textureColor.a;gl_FragColor.rgb=gl_FragColor.rgb*alpha+vec3(1.0)*(1.0-alpha);
#endif 
#include<logDepthFragment>
#ifdef IMAGEPROCESSINGPOSTPROCESS
gl_FragColor.rgb=toLinearSpace(gl_FragColor.rgb);
#else
#ifdef IMAGEPROCESSING
gl_FragColor.rgb=toLinearSpace(gl_FragColor.rgb);gl_FragColor=applyImageProcessing(gl_FragColor);
#endif
#endif
}
`, re.IncludesShadersStore.clipPlaneVertexDeclaration2 = `#ifdef CLIPPLANE
uniform vec4 vClipPlane;out float fClipDistance;
#endif
#ifdef CLIPPLANE2
uniform vec4 vClipPlane2;out float fClipDistance2;
#endif
#ifdef CLIPPLANE3
uniform vec4 vClipPlane3;out float fClipDistance3;
#endif
#ifdef CLIPPLANE4
uniform vec4 vClipPlane4;out float fClipDistance4;
#endif
#ifdef CLIPPLANE5
uniform vec4 vClipPlane5;out float fClipDistance5;
#endif
#ifdef CLIPPLANE6
uniform vec4 vClipPlane6;out float fClipDistance6;
#endif
`, re.ShadersStore.gpuRenderParticlesVertexShader = `precision highp float;uniform mat4 view;uniform mat4 projection;uniform vec2 translationPivot;uniform vec3 worldOffset;
#ifdef LOCAL
uniform mat4 emitterWM;
#endif
attribute vec3 position;attribute float age;attribute float life;attribute vec3 size;
#ifndef BILLBOARD
attribute vec3 initialDirection;
#endif
#ifdef BILLBOARDSTRETCHED
attribute vec3 direction;
#endif
attribute float angle;
#ifdef ANIMATESHEET
attribute float cellIndex;
#endif
attribute vec2 offset;attribute vec2 uv;varying vec2 vUV;varying vec4 vColor;varying vec3 vPositionW;
#if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED)
uniform mat4 invView;
#endif
#include<clipPlaneVertexDeclaration2>
#include<logDepthDeclaration>
#ifdef COLORGRADIENTS
uniform sampler2D colorGradientSampler;
#else
uniform vec4 colorDead;attribute vec4 color;
#endif
#ifdef ANIMATESHEET
uniform vec3 sheetInfos;
#endif
#ifdef BILLBOARD
uniform vec3 eyePosition;
#endif
vec3 rotate(vec3 yaxis,vec3 rotatedCorner) {vec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));vec3 zaxis=normalize(cross(yaxis,xaxis));vec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);vec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);vec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);mat3 rotMatrix= mat3(row0,row1,row2);vec3 alignedCorner=rotMatrix*rotatedCorner;
#ifdef LOCAL
return ((emitterWM*vec4(position,1.0)).xyz+worldOffset)+alignedCorner;
#else
return (position+worldOffset)+alignedCorner;
#endif
}
#ifdef BILLBOARDSTRETCHED
vec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {vec3 normalizedToCamera=normalize(toCamera);vec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));vec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));vec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);vec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);vec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);mat3 rotMatrix= mat3(row0,row1,row2);vec3 alignedCorner=rotMatrix*rotatedCorner;
#ifdef LOCAL
return ((emitterWM*vec4(position,1.0)).xyz+worldOffset)+alignedCorner;
#else
return (position+worldOffset)+alignedCorner;
#endif
}
#endif
void main() {
#ifdef ANIMATESHEET
float rowOffset=floor(cellIndex/sheetInfos.z);float columnOffset=cellIndex-rowOffset*sheetInfos.z;vec2 uvScale=sheetInfos.xy;vec2 uvOffset=vec2(uv.x ,1.0-uv.y);vUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;
#else
vUV=uv;
#endif
float ratio=age/life;
#ifdef COLORGRADIENTS
vColor=texture2D(colorGradientSampler,vec2(ratio,0));
#else
vColor=color*vec4(1.0-ratio)+colorDead*vec4(ratio);
#endif
vec2 cornerPos=(offset-translationPivot)*size.yz*size.x;
#ifdef BILLBOARD
vec4 rotatedCorner;rotatedCorner.w=0.;
#ifdef BILLBOARDY
rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.y=0.;rotatedCorner.xz+=translationPivot;vec3 yaxis=(position+worldOffset)-eyePosition;yaxis.y=0.;vPositionW=rotate(normalize(yaxis),rotatedCorner.xyz);vec4 viewPosition=(view*vec4(vPositionW,1.0));
#elif defined(BILLBOARDSTRETCHED)
rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.z=0.;rotatedCorner.xy+=translationPivot;vec3 toCamera=(position+worldOffset)-eyePosition;vPositionW=rotateAlign(toCamera,rotatedCorner.xyz);vec4 viewPosition=(view*vec4(vPositionW,1.0));
#else
rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.z=0.;rotatedCorner.xy+=translationPivot;
#ifdef LOCAL
vec4 viewPosition=view*vec4(((emitterWM*vec4(position,1.0)).xyz+worldOffset),1.0)+rotatedCorner;
#else
vec4 viewPosition=view*vec4((position+worldOffset),1.0)+rotatedCorner;
#endif
vPositionW=(invView*viewPosition).xyz;
#endif
#else
vec3 rotatedCorner;rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.y=0.;rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.xz+=translationPivot;vec3 yaxis=normalize(initialDirection);vPositionW=rotate(yaxis,rotatedCorner);vec4 viewPosition=view*vec4(vPositionW,1.0);
#endif
gl_Position=projection*viewPosition;
#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
vec4 worldPos=vec4(vPositionW,1.0);
#endif
#include<clipPlaneVertex>
#include<logDepthVertex>
}`;
    var Os = function(n) {
      function t(e, i, r, o, a) {
        o === void 0 && (o = null), a === void 0 && (a = !1);
        var s = n.call(this, e) || this;
        if (s.layerMask = 268435455, s._accumulatedCount = 0, s._renderVertexBuffers = [], s._targetIndex = 0, s._currentRenderId = -1, s._currentRenderingCameraUniqueId = -1, s._started = !1, s._stopped = !1, s._timeDelta = 0, s.updateInAnimate = !1, s._actualFrame = 0, s._rawTextureWidth = 256, s.onDisposeObservable = new H(), s.onStoppedObservable = new H(), s.forceDepthWrite = !1, s._preWarmDone = !1, s.isLocal = !1, s.isGPU = !0, s._onBeforeDrawParticlesObservable = null, r && r.getClassName() !== "Scene" ? (s._engine = r, s.defaultProjectionMatrix = B.PerspectiveFovLH(0.8, 1, 0.1, 100, s._engine.isNDCHalfZRange)) : (s._scene = r || Me.LastCreatedScene, s._engine = s._scene.getEngine(), s.uniqueId = s._scene.getUniqueId(), s._scene.particleSystems.push(s)), s._engine.getCaps().supportComputeShaders) {
          if (!Kt("BABYLON.ComputeShaderParticleSystem"))
            throw new Error("The ComputeShaderParticleSystem class is not available! Make sure you have imported it.");
          s._platform = new (Kt("BABYLON.ComputeShaderParticleSystem"))(s, s._engine);
        } else {
          if (!Kt("BABYLON.WebGL2ParticleSystem"))
            throw new Error("The WebGL2ParticleSystem class is not available! Make sure you have imported it.");
          s._platform = new (Kt("BABYLON.WebGL2ParticleSystem"))(s, s._engine);
        }
        s._customWrappers = { 0: new Ei(s._engine) }, s._customWrappers[0].effect = o, s._drawWrappers = { 0: new Ei(s._engine) }, s._drawWrappers[0].drawContext && (s._drawWrappers[0].drawContext.useInstancing = !0), s._createIndexBuffer(), s._attachImageProcessingConfiguration(null), (i = i ?? {}).randomTextureSize || delete i.randomTextureSize;
        var l = je({ capacity: 5e4, randomTextureSize: s._engine.getCaps().maxTextureSize }, i), c = i;
        isFinite(c) && (l.capacity = c), s._capacity = l.capacity, s._maxActiveParticleCount = l.capacity, s._currentActiveCount = 0, s._isAnimationSheetEnabled = a, s.particleEmitterType = new _l();
        for (var u = Math.min(s._engine.getCaps().maxTextureSize, l.randomTextureSize), h = [], d = 0; d < u; ++d)
          h.push(Math.random()), h.push(Math.random()), h.push(Math.random()), h.push(Math.random());
        for (s._randomTexture = new on(new Float32Array(h), u, 1, _.TEXTUREFORMAT_RGBA, r, !1, !1, _.TEXTURE_NEAREST_SAMPLINGMODE, _.TEXTURETYPE_FLOAT), s._randomTexture.name = "GPUParticleSystem_random1", s._randomTexture.wrapU = _.TEXTURE_WRAP_ADDRESSMODE, s._randomTexture.wrapV = _.TEXTURE_WRAP_ADDRESSMODE, h = [], d = 0; d < u; ++d)
          h.push(Math.random()), h.push(Math.random()), h.push(Math.random()), h.push(Math.random());
        return s._randomTexture2 = new on(new Float32Array(h), u, 1, _.TEXTUREFORMAT_RGBA, r, !1, !1, _.TEXTURE_NEAREST_SAMPLINGMODE, _.TEXTURETYPE_FLOAT), s._randomTexture2.name = "GPUParticleSystem_random2", s._randomTexture2.wrapU = _.TEXTURE_WRAP_ADDRESSMODE, s._randomTexture2.wrapV = _.TEXTURE_WRAP_ADDRESSMODE, s._randomTextureSize = u, s;
      }
      return D(t, n), Object.defineProperty(t, "IsSupported", { get: function() {
        if (!Me.LastCreatedEngine)
          return !1;
        var e = Me.LastCreatedEngine.getCaps();
        return e.supportTransformFeedbacks || e.supportComputeShaders;
      }, enumerable: !1, configurable: !0 }), t.prototype._createIndexBuffer = function() {
        this._linesIndexBufferUseInstancing = this._engine.createIndexBuffer(new Uint32Array([0, 1, 1, 3, 3, 2, 2, 0, 0, 3]));
      }, t.prototype.getCapacity = function() {
        return this._capacity;
      }, Object.defineProperty(t.prototype, "maxActiveParticleCount", { get: function() {
        return this._maxActiveParticleCount;
      }, set: function(e) {
        this._maxActiveParticleCount = Math.min(e, this._capacity);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "activeParticleCount", { get: function() {
        return this.maxActiveParticleCount;
      }, set: function(e) {
        this.maxActiveParticleCount = e;
      }, enumerable: !1, configurable: !0 }), t.prototype.isReady = function() {
        if (!this.emitter || this._imageProcessingConfiguration && !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady())
          return !1;
        if (this.blendMode !== Ai.BLENDMODE_MULTIPLYADD) {
          if (!this._getWrapper(this.blendMode).effect.isReady())
            return !1;
        } else if (!this._getWrapper(Ai.BLENDMODE_MULTIPLY).effect.isReady() || !this._getWrapper(Ai.BLENDMODE_ADD).effect.isReady())
          return !1;
        return this._platform.isUpdateBufferCreated() ? this._platform.isUpdateBufferReady() : (this._recreateUpdateEffect(), !1);
      }, t.prototype.isStarted = function() {
        return this._started;
      }, t.prototype.isStopped = function() {
        return this._stopped;
      }, t.prototype.isStopping = function() {
        return !1;
      }, t.prototype.getActiveCount = function() {
        return this._currentActiveCount;
      }, t.prototype.start = function(e) {
        var i = this;
        if (e === void 0 && (e = this.startDelay), !this.targetStopDuration && this._hasTargetStopDurationDependantGradient())
          throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
        e ? setTimeout(function() {
          i.start(0);
        }, e) : (this._started = !0, this._stopped = !1, this._preWarmDone = !1, this.beginAnimationOnStart && this.animations && this.animations.length > 0 && this._scene && this._scene.beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop));
      }, t.prototype.stop = function() {
        this._stopped || (this._stopped = !0);
      }, t.prototype.reset = function() {
        this._releaseBuffers(), this._platform.releaseVertexBuffers(), this._currentActiveCount = 0, this._targetIndex = 0;
      }, t.prototype.getClassName = function() {
        return "GPUParticleSystem";
      }, t.prototype.getCustomEffect = function(e) {
        var i, r;
        return e === void 0 && (e = 0), (r = (i = this._customWrappers[e]) === null || i === void 0 ? void 0 : i.effect) !== null && r !== void 0 ? r : this._customWrappers[0].effect;
      }, t.prototype._getCustomDrawWrapper = function(e) {
        var i;
        return e === void 0 && (e = 0), (i = this._customWrappers[e]) !== null && i !== void 0 ? i : this._customWrappers[0];
      }, t.prototype.setCustomEffect = function(e, i) {
        i === void 0 && (i = 0), this._customWrappers[i] = new Ei(this._engine), this._customWrappers[i].effect = e;
      }, Object.defineProperty(t.prototype, "onBeforeDrawParticlesObservable", { get: function() {
        return this._onBeforeDrawParticlesObservable || (this._onBeforeDrawParticlesObservable = new H()), this._onBeforeDrawParticlesObservable;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "vertexShaderName", { get: function() {
        return "gpuRenderParticles";
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "vertexBuffers", { get: function() {
        return this._renderVertexBuffers[1 ^ this._targetIndex];
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "indexBuffer", { get: function() {
        return null;
      }, enumerable: !1, configurable: !0 }), t.prototype._removeGradientAndTexture = function(e, i, r) {
        return n.prototype._removeGradientAndTexture.call(this, e, i, r), this._releaseBuffers(), this;
      }, t.prototype.addColorGradient = function(e, i) {
        this._colorGradients || (this._colorGradients = []);
        var r = new Z_(e, i);
        return this._colorGradients.push(r), this._refreshColorGradient(!0), this._releaseBuffers(), this;
      }, t.prototype._refreshColorGradient = function(e) {
        e === void 0 && (e = !1), this._colorGradients && (e && this._colorGradients.sort(function(i, r) {
          return i.gradient < r.gradient ? -1 : i.gradient > r.gradient ? 1 : 0;
        }), this._colorGradientsTexture && (this._colorGradientsTexture.dispose(), this._colorGradientsTexture = null));
      }, t.prototype.forceRefreshGradients = function() {
        this._refreshColorGradient(), this._refreshFactorGradient(this._sizeGradients, "_sizeGradientsTexture"), this._refreshFactorGradient(this._angularSpeedGradients, "_angularSpeedGradientsTexture"), this._refreshFactorGradient(this._velocityGradients, "_velocityGradientsTexture"), this._refreshFactorGradient(this._limitVelocityGradients, "_limitVelocityGradientsTexture"), this._refreshFactorGradient(this._dragGradients, "_dragGradientsTexture"), this.reset();
      }, t.prototype.removeColorGradient = function(e) {
        return this._removeGradientAndTexture(e, this._colorGradients, this._colorGradientsTexture), this._colorGradientsTexture = null, this;
      }, t.prototype.resetDrawCache = function() {
        var e;
        for (var i in this._drawWrappers)
          (e = this._drawWrappers[i].drawContext) === null || e === void 0 || e.reset();
      }, t.prototype._addFactorGradient = function(e, i, r) {
        var o = new J_(i, r);
        e.push(o), this._releaseBuffers();
      }, t.prototype.addSizeGradient = function(e, i) {
        return this._sizeGradients || (this._sizeGradients = []), this._addFactorGradient(this._sizeGradients, e, i), this._refreshFactorGradient(this._sizeGradients, "_sizeGradientsTexture", !0), this._releaseBuffers(), this;
      }, t.prototype.removeSizeGradient = function(e) {
        return this._removeGradientAndTexture(e, this._sizeGradients, this._sizeGradientsTexture), this._sizeGradientsTexture = null, this;
      }, t.prototype._refreshFactorGradient = function(e, i, r) {
        if (r === void 0 && (r = !1), e) {
          r && e.sort(function(a, s) {
            return a.gradient < s.gradient ? -1 : a.gradient > s.gradient ? 1 : 0;
          });
          var o = this;
          o[i] && (o[i].dispose(), o[i] = null);
        }
      }, t.prototype.addAngularSpeedGradient = function(e, i) {
        return this._angularSpeedGradients || (this._angularSpeedGradients = []), this._addFactorGradient(this._angularSpeedGradients, e, i), this._refreshFactorGradient(this._angularSpeedGradients, "_angularSpeedGradientsTexture", !0), this._releaseBuffers(), this;
      }, t.prototype.removeAngularSpeedGradient = function(e) {
        return this._removeGradientAndTexture(e, this._angularSpeedGradients, this._angularSpeedGradientsTexture), this._angularSpeedGradientsTexture = null, this;
      }, t.prototype.addVelocityGradient = function(e, i) {
        return this._velocityGradients || (this._velocityGradients = []), this._addFactorGradient(this._velocityGradients, e, i), this._refreshFactorGradient(this._velocityGradients, "_velocityGradientsTexture", !0), this._releaseBuffers(), this;
      }, t.prototype.removeVelocityGradient = function(e) {
        return this._removeGradientAndTexture(e, this._velocityGradients, this._velocityGradientsTexture), this._velocityGradientsTexture = null, this;
      }, t.prototype.addLimitVelocityGradient = function(e, i) {
        return this._limitVelocityGradients || (this._limitVelocityGradients = []), this._addFactorGradient(this._limitVelocityGradients, e, i), this._refreshFactorGradient(this._limitVelocityGradients, "_limitVelocityGradientsTexture", !0), this._releaseBuffers(), this;
      }, t.prototype.removeLimitVelocityGradient = function(e) {
        return this._removeGradientAndTexture(e, this._limitVelocityGradients, this._limitVelocityGradientsTexture), this._limitVelocityGradientsTexture = null, this;
      }, t.prototype.addDragGradient = function(e, i) {
        return this._dragGradients || (this._dragGradients = []), this._addFactorGradient(this._dragGradients, e, i), this._refreshFactorGradient(this._dragGradients, "_dragGradientsTexture", !0), this._releaseBuffers(), this;
      }, t.prototype.removeDragGradient = function(e) {
        return this._removeGradientAndTexture(e, this._dragGradients, this._dragGradientsTexture), this._dragGradientsTexture = null, this;
      }, t.prototype.addEmitRateGradient = function() {
        return this;
      }, t.prototype.removeEmitRateGradient = function() {
        return this;
      }, t.prototype.addStartSizeGradient = function() {
        return this;
      }, t.prototype.removeStartSizeGradient = function() {
        return this;
      }, t.prototype.addColorRemapGradient = function() {
        return this;
      }, t.prototype.removeColorRemapGradient = function() {
        return this;
      }, t.prototype.addAlphaRemapGradient = function() {
        return this;
      }, t.prototype.removeAlphaRemapGradient = function() {
        return this;
      }, t.prototype.addRampGradient = function() {
        return this;
      }, t.prototype.removeRampGradient = function() {
        return this;
      }, t.prototype.getRampGradients = function() {
        return null;
      }, Object.defineProperty(t.prototype, "useRampGradients", { get: function() {
        return !1;
      }, set: function(e) {
      }, enumerable: !1, configurable: !0 }), t.prototype.addLifeTimeGradient = function() {
        return this;
      }, t.prototype.removeLifeTimeGradient = function() {
        return this;
      }, t.prototype._reset = function() {
        this._releaseBuffers();
      }, t.prototype._createVertexBuffers = function(e, i, r) {
        var o = {};
        o.position = i.createVertexBuffer("position", 0, 3, this._attributesStrideSize, !0);
        var a = 3;
        o.age = i.createVertexBuffer("age", a, 1, this._attributesStrideSize, !0), a += 1, o.size = i.createVertexBuffer("size", a, 3, this._attributesStrideSize, !0), a += 3, o.life = i.createVertexBuffer("life", a, 1, this._attributesStrideSize, !0), a += 1, a += 4, this.billboardMode === Ai.BILLBOARDMODE_STRETCHED && (o.direction = i.createVertexBuffer("direction", a, 3, this._attributesStrideSize, !0)), a += 3, this._platform.alignDataInBuffer && (a += 1), this.particleEmitterType instanceof ml && (a += 3, this._platform.alignDataInBuffer && (a += 1)), this._colorGradientsTexture || (o.color = i.createVertexBuffer("color", a, 4, this._attributesStrideSize, !0), a += 4), this._isBillboardBased || (o.initialDirection = i.createVertexBuffer("initialDirection", a, 3, this._attributesStrideSize, !0), a += 3, this._platform.alignDataInBuffer && (a += 1)), this.noiseTexture && (o.noiseCoordinates1 = i.createVertexBuffer("noiseCoordinates1", a, 3, this._attributesStrideSize, !0), a += 3, this._platform.alignDataInBuffer && (a += 1), o.noiseCoordinates2 = i.createVertexBuffer("noiseCoordinates2", a, 3, this._attributesStrideSize, !0), a += 3, this._platform.alignDataInBuffer && (a += 1)), o.angle = i.createVertexBuffer("angle", a, 1, this._attributesStrideSize, !0), this._angularSpeedGradientsTexture ? a++ : a += 2, this._isAnimationSheetEnabled && (o.cellIndex = i.createVertexBuffer("cellIndex", a, 1, this._attributesStrideSize, !0), a += 1, this.spriteRandomStartCell && (o.cellStartOffset = i.createVertexBuffer("cellStartOffset", a, 1, this._attributesStrideSize, !0), a += 1)), o.offset = r.createVertexBuffer("offset", 0, 2), o.uv = r.createVertexBuffer("uv", 2, 2), this._renderVertexBuffers.push(o), this._platform.createVertexBuffers(e, o), this.resetDrawCache();
      }, t.prototype._initialize = function(e) {
        if (e === void 0 && (e = !1), !this._buffer0 || e) {
          var i = this._engine, r = [];
          this._attributesStrideSize = 21, this._targetIndex = 0, this._platform.alignDataInBuffer && (this._attributesStrideSize += 1), this.particleEmitterType instanceof ml && (this._attributesStrideSize += 3, this._platform.alignDataInBuffer && (this._attributesStrideSize += 1)), this.isBillboardBased || (this._attributesStrideSize += 3, this._platform.alignDataInBuffer && (this._attributesStrideSize += 1)), this._colorGradientsTexture && (this._attributesStrideSize -= 4), this._angularSpeedGradientsTexture && (this._attributesStrideSize -= 1), this._isAnimationSheetEnabled && (this._attributesStrideSize += 1, this.spriteRandomStartCell && (this._attributesStrideSize += 1)), this.noiseTexture && (this._attributesStrideSize += 6, this._platform.alignDataInBuffer && (this._attributesStrideSize += 2)), this._platform.alignDataInBuffer && (this._attributesStrideSize += 3 - (this._attributesStrideSize + 3 & 3));
          for (var o = this.particleEmitterType instanceof ml, a = F.Vector3[0], s = 0, l = 0; l < this._capacity; l++)
            if (r.push(0), r.push(0), r.push(0), r.push(0), r.push(0), r.push(0), r.push(0), r.push(0), r.push(Math.random()), r.push(Math.random()), r.push(Math.random()), r.push(Math.random()), o ? (this.particleEmitterType.particleDestinationGenerator(l, null, a), r.push(a.x), r.push(a.y), r.push(a.z)) : (r.push(0), r.push(0), r.push(0)), this._platform.alignDataInBuffer && r.push(0), s += 16, o && (this.particleEmitterType.particlePositionGenerator(l, null, a), r.push(a.x), r.push(a.y), r.push(a.z), this._platform.alignDataInBuffer && r.push(0), s += 4), this._colorGradientsTexture || (r.push(0), r.push(0), r.push(0), r.push(0), s += 4), this.isBillboardBased || (r.push(0), r.push(0), r.push(0), this._platform.alignDataInBuffer && r.push(0), s += 4), this.noiseTexture && (r.push(Math.random()), r.push(Math.random()), r.push(Math.random()), this._platform.alignDataInBuffer && r.push(0), r.push(Math.random()), r.push(Math.random()), r.push(Math.random()), this._platform.alignDataInBuffer && r.push(0), s += 8), r.push(0), s += 1, this._angularSpeedGradientsTexture || (r.push(0), s += 1), this._isAnimationSheetEnabled && (r.push(0), s += 1, this.spriteRandomStartCell && (r.push(0), s += 1)), this._platform.alignDataInBuffer) {
              var c = 3 - (s + 3 & 3);
              for (s += c; c-- > 0; )
                r.push(0);
            }
          var u = new Float32Array([0.5, 0.5, 1, 1, -0.5, 0.5, 0, 1, 0.5, -0.5, 1, 0, -0.5, -0.5, 0, 0]), h = this._platform.createParticleBuffer(r), d = this._platform.createParticleBuffer(r);
          this._buffer0 = new Yi(i, h, !1, this._attributesStrideSize), this._buffer1 = new Yi(i, d, !1, this._attributesStrideSize), this._spriteBuffer = new Yi(i, u, !1, 4), this._renderVertexBuffers = [], this._createVertexBuffers(this._buffer0, this._buffer1, this._spriteBuffer), this._createVertexBuffers(this._buffer1, this._buffer0, this._spriteBuffer), this._sourceBuffer = this._buffer0, this._targetBuffer = this._buffer1;
        }
      }, t.prototype._recreateUpdateEffect = function() {
        this._createColorGradientTexture(), this._createSizeGradientTexture(), this._createAngularSpeedGradientTexture(), this._createVelocityGradientTexture(), this._createLimitVelocityGradientTexture(), this._createDragGradientTexture();
        var e = this.particleEmitterType ? this.particleEmitterType.getEffectDefines() : "";
        return this._isBillboardBased && (e += `
#define BILLBOARD`), this._colorGradientsTexture && (e += `
#define COLORGRADIENTS`), this._sizeGradientsTexture && (e += `
#define SIZEGRADIENTS`), this._angularSpeedGradientsTexture && (e += `
#define ANGULARSPEEDGRADIENTS`), this._velocityGradientsTexture && (e += `
#define VELOCITYGRADIENTS`), this._limitVelocityGradientsTexture && (e += `
#define LIMITVELOCITYGRADIENTS`), this._dragGradientsTexture && (e += `
#define DRAGGRADIENTS`), this.isAnimationSheetEnabled && (e += `
#define ANIMATESHEET`, this.spriteRandomStartCell && (e += `
#define ANIMATESHEETRANDOMSTART`)), this.noiseTexture && (e += `
#define NOISE`), this.isLocal && (e += `
#define LOCAL`), !(!this._platform.isUpdateBufferCreated() || this._cachedUpdateDefines !== e) || (this._cachedUpdateDefines = e, this._updateBuffer = this._platform.createUpdateBuffer(e), this._platform.isUpdateBufferReady());
      }, t.prototype._getWrapper = function(e) {
        var i = this._getCustomDrawWrapper(e);
        if (i != null && i.effect)
          return i;
        var r = [];
        this.fillDefines(r, e);
        var o = this._drawWrappers[e];
        o || ((o = new Ei(this._engine)).drawContext && (o.drawContext.useInstancing = !0), this._drawWrappers[e] = o);
        var a = r.join(`
`);
        if (o.defines !== a) {
          var s = [], l = [], c = [];
          this.fillUniformsAttributesAndSamplerNames(l, s, c), o.setEffect(this._engine.createEffect("gpuRenderParticles", s, l, c, a), a);
        }
        return o;
      }, t._GetAttributeNamesOrOptions = function(e, i, r, o) {
        e === void 0 && (e = !1), i === void 0 && (i = !1), r === void 0 && (r = !1), o === void 0 && (o = !1);
        var a = [P.PositionKind, "age", "life", "size", "angle"];
        return e || a.push(P.ColorKind), i && a.push("cellIndex"), r || a.push("initialDirection"), o && a.push("direction"), a.push("offset", P.UVKind), a;
      }, t._GetEffectCreationOptions = function(e, i) {
        e === void 0 && (e = !1), i === void 0 && (i = !1);
        var r = ["emitterWM", "worldOffset", "view", "projection", "colorDead", "invView", "translationPivot", "eyePosition"];
        return Br(r), e && r.push("sheetInfos"), i && r.push("logarithmicDepthConstant"), r;
      }, t.prototype.fillDefines = function(e, i) {
        if (i === void 0 && (i = 0), this._scene && aa(this, this._scene, e), i === Ai.BLENDMODE_MULTIPLY && e.push("#define BLENDMULTIPLYMODE"), this.isLocal && e.push("#define LOCAL"), this.useLogarithmicDepth && e.push("#define LOGARITHMICDEPTH"), this._isBillboardBased)
          switch (e.push("#define BILLBOARD"), this.billboardMode) {
            case Ai.BILLBOARDMODE_Y:
              e.push("#define BILLBOARDY");
              break;
            case Ai.BILLBOARDMODE_STRETCHED:
              e.push("#define BILLBOARDSTRETCHED");
              break;
            case Ai.BILLBOARDMODE_ALL:
              e.push("#define BILLBOARDMODE_ALL");
          }
        this._colorGradientsTexture && e.push("#define COLORGRADIENTS"), this.isAnimationSheetEnabled && e.push("#define ANIMATESHEET"), this._imageProcessingConfiguration && (this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines), e.push("" + this._imageProcessingConfigurationDefines.toString()));
      }, t.prototype.fillUniformsAttributesAndSamplerNames = function(e, i, r) {
        i.push.apply(i, t._GetAttributeNamesOrOptions(!!this._colorGradientsTexture, this._isAnimationSheetEnabled, this._isBillboardBased, this._isBillboardBased && this.billboardMode === Ai.BILLBOARDMODE_STRETCHED)), e.push.apply(e, t._GetEffectCreationOptions(this._isAnimationSheetEnabled, this.useLogarithmicDepth)), r.push("diffuseSampler", "colorGradientSampler"), this._imageProcessingConfiguration && (tn.PrepareUniforms(e, this._imageProcessingConfigurationDefines), tn.PrepareSamplers(r, this._imageProcessingConfigurationDefines));
      }, t.prototype.animate = function(e) {
        var i;
        e === void 0 && (e = !1), this._timeDelta = this.updateSpeed * (e ? this.preWarmStepOffset : ((i = this._scene) === null || i === void 0 ? void 0 : i.getAnimationRatio()) || 1), this._actualFrame += this._timeDelta, this._stopped || this.targetStopDuration && this._actualFrame >= this.targetStopDuration && this.stop(), this.updateInAnimate && this._update();
      }, t.prototype._createFactorGradientTexture = function(e, i) {
        var r = this[i];
        if (e && e.length && !r) {
          for (var o = new Float32Array(this._rawTextureWidth), a = function(c) {
            var u = c / s._rawTextureWidth;
            sr.GetCurrentGradient(u, e, function(h, d, p) {
              o[c] = ue.Lerp(h.factor1, d.factor1, p);
            });
          }, s = this, l = 0; l < this._rawTextureWidth; l++)
            a(l);
          this[i] = on.CreateRTexture(o, this._rawTextureWidth, 1, this._scene || this._engine, !1, !1, _.TEXTURE_NEAREST_SAMPLINGMODE), this[i].name = i.substring(1);
        }
      }, t.prototype._createSizeGradientTexture = function() {
        this._createFactorGradientTexture(this._sizeGradients, "_sizeGradientsTexture");
      }, t.prototype._createAngularSpeedGradientTexture = function() {
        this._createFactorGradientTexture(this._angularSpeedGradients, "_angularSpeedGradientsTexture");
      }, t.prototype._createVelocityGradientTexture = function() {
        this._createFactorGradientTexture(this._velocityGradients, "_velocityGradientsTexture");
      }, t.prototype._createLimitVelocityGradientTexture = function() {
        this._createFactorGradientTexture(this._limitVelocityGradients, "_limitVelocityGradientsTexture");
      }, t.prototype._createDragGradientTexture = function() {
        this._createFactorGradientTexture(this._dragGradients, "_dragGradientsTexture");
      }, t.prototype._createColorGradientTexture = function() {
        if (this._colorGradients && this._colorGradients.length && !this._colorGradientsTexture) {
          for (var e = new Uint8Array(4 * this._rawTextureWidth), i = Ot.Color4[0], r = function(s) {
            var l = s / o._rawTextureWidth;
            sr.GetCurrentGradient(l, o._colorGradients, function(c, u, h) {
              Ie.LerpToRef(c.color1, u.color1, h, i), e[4 * s] = 255 * i.r, e[4 * s + 1] = 255 * i.g, e[4 * s + 2] = 255 * i.b, e[4 * s + 3] = 255 * i.a;
            });
          }, o = this, a = 0; a < this._rawTextureWidth; a++)
            r(a);
          this._colorGradientsTexture = on.CreateRGBATexture(e, this._rawTextureWidth, 1, this._scene, !1, !1, _.TEXTURE_NEAREST_SAMPLINGMODE), this._colorGradientsTexture.name = "colorGradients";
        }
      }, t.prototype._render = function(e, i) {
        var r, o, a, s, l, c = this._getWrapper(e), u = c.effect;
        this._engine.enableEffect(c);
        var h = ((r = this._scene) === null || r === void 0 ? void 0 : r.getViewMatrix()) || B.IdentityReadOnly;
        if (u.setMatrix("view", h), u.setMatrix("projection", (o = this.defaultProjectionMatrix) !== null && o !== void 0 ? o : this._scene.getProjectionMatrix()), u.setTexture("diffuseSampler", this.particleTexture), u.setVector2("translationPivot", this.translationPivot), u.setVector3("worldOffset", this.worldOffset), this.isLocal && u.setMatrix("emitterWM", i), this._colorGradientsTexture ? u.setTexture("colorGradientSampler", this._colorGradientsTexture) : u.setDirectColor4("colorDead", this.colorDead), this._isAnimationSheetEnabled && this.particleTexture) {
          var d = this.particleTexture.getBaseSize();
          u.setFloat3("sheetInfos", this.spriteCellWidth / d.width, this.spriteCellHeight / d.height, d.width / this.spriteCellWidth);
        }
        if (this._isBillboardBased && this._scene) {
          var p = this._scene.activeCamera;
          u.setVector3("eyePosition", p.globalPosition);
        }
        var f = u.defines;
        if (this._scene && Ar(u, this, this._scene), f.indexOf("#define BILLBOARDMODE_ALL") >= 0) {
          var m = h.clone();
          m.invert(), u.setMatrix("invView", m);
        }
        switch (this.useLogarithmicDepth && this._scene && Se.BindLogDepth(f, u, this._scene), this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess && this._imageProcessingConfiguration.bind(u), e) {
          case Ai.BLENDMODE_ADD:
            this._engine.setAlphaMode(_.ALPHA_ADD);
            break;
          case Ai.BLENDMODE_ONEONE:
            this._engine.setAlphaMode(_.ALPHA_ONEONE);
            break;
          case Ai.BLENDMODE_STANDARD:
            this._engine.setAlphaMode(_.ALPHA_COMBINE);
            break;
          case Ai.BLENDMODE_MULTIPLY:
            this._engine.setAlphaMode(_.ALPHA_MULTIPLY);
        }
        return this._platform.bindDrawBuffers(this._targetIndex, u, !((a = this._scene) === null || a === void 0) && a.forceWireframe ? this._linesIndexBufferUseInstancing : null), this._onBeforeDrawParticlesObservable && this._onBeforeDrawParticlesObservable.notifyObservers(u), !((s = this._scene) === null || s === void 0) && s.forceWireframe ? this._engine.drawElementsType(_.MATERIAL_LineStripDrawMode, 0, 10, this._currentActiveCount) : this._engine.drawArraysType(_.MATERIAL_TriangleStripDrawMode, 0, 4, this._currentActiveCount), this._engine.setAlphaMode(_.ALPHA_DISABLE), !((l = this._scene) === null || l === void 0) && l.forceWireframe && this._engine.unbindInstanceAttributes(), this._currentActiveCount;
      }, t.prototype._update = function(e) {
        if (this.emitter && this._targetBuffer && this._recreateUpdateEffect()) {
          if (!e)
            if (this.emitter.position)
              e = this.emitter.getWorldMatrix();
            else {
              var i = this.emitter;
              e = F.Matrix[0], B.TranslationToRef(i.x, i.y, i.z, e);
            }
          this._platform.preUpdateParticleBuffer(), this._updateBuffer.setFloat("currentCount", this._currentActiveCount), this._updateBuffer.setFloat("timeDelta", this._timeDelta), this._updateBuffer.setFloat("stopFactor", this._stopped ? 0 : 1), this._updateBuffer.setInt("randomTextureSize", this._randomTextureSize), this._updateBuffer.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime), this._updateBuffer.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower), this._colorGradientsTexture || (this._updateBuffer.setDirectColor4("color1", this.color1), this._updateBuffer.setDirectColor4("color2", this.color2)), this._updateBuffer.setFloat2("sizeRange", this.minSize, this.maxSize), this._updateBuffer.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY), this._updateBuffer.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation), this._updateBuffer.setVector3("gravity", this.gravity), this._limitVelocityGradientsTexture && this._updateBuffer.setFloat("limitVelocityDamping", this.limitVelocityDamping), this.particleEmitterType && this.particleEmitterType.applyToShader(this._updateBuffer), this._isAnimationSheetEnabled && this._updateBuffer.setFloat4("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed, this.spriteCellLoop ? 1 : 0), this.noiseTexture && this._updateBuffer.setVector3("noiseStrength", this.noiseStrength), this.isLocal || this._updateBuffer.setMatrix("emitterWM", e), this._platform.updateParticleBuffer(this._targetIndex, this._targetBuffer, this._currentActiveCount), this._targetIndex++, this._targetIndex === 2 && (this._targetIndex = 0);
          var r = this._sourceBuffer;
          this._sourceBuffer = this._targetBuffer, this._targetBuffer = r;
        }
      }, t.prototype.render = function(e, i) {
        if (e === void 0 && (e = !1), i === void 0 && (i = !1), !this._started || !this.isReady())
          return 0;
        if (!e && this._scene) {
          if (!this._preWarmDone && this.preWarmCycles) {
            for (var r = 0; r < this.preWarmCycles; r++)
              this.animate(!0), this.render(!0, !0);
            this._preWarmDone = !0;
          }
          if (this._currentRenderId === this._scene.getRenderId() && (!this._scene.activeCamera || this._scene.activeCamera && this._currentRenderingCameraUniqueId === this._scene.activeCamera.uniqueId))
            return 0;
          this._currentRenderId = this._scene.getRenderId(), this._scene.activeCamera && (this._currentRenderingCameraUniqueId = this._scene.activeCamera.uniqueId);
        }
        if (this._initialize(), this._accumulatedCount += this.emitRate * this._timeDelta, this._accumulatedCount > 1) {
          var o = 0 | this._accumulatedCount;
          this._accumulatedCount -= o, this._currentActiveCount += o;
        }
        if (this._currentActiveCount = Math.min(this._maxActiveParticleCount, this._currentActiveCount), !this._currentActiveCount)
          return 0;
        var a;
        if (this.emitter.position)
          a = this.emitter.getWorldMatrix();
        else {
          var s = this.emitter;
          a = F.Matrix[0], B.TranslationToRef(s.x, s.y, s.z, a);
        }
        var l = this._engine;
        this.updateInAnimate || this._update(a);
        var c = 0;
        return e || i || (l.setState(!1), this.forceDepthWrite && l.setDepthWrite(!0), c = this.blendMode === Ai.BLENDMODE_MULTIPLYADD ? this._render(Ai.BLENDMODE_MULTIPLY, a) + this._render(Ai.BLENDMODE_ADD, a) : this._render(this.blendMode, a), this._engine.setAlphaMode(_.ALPHA_DISABLE)), c;
      }, t.prototype.rebuild = function() {
        var e = this, i = function() {
          e._recreateUpdateEffect() && e._platform.isUpdateBufferReady() ? e._initialize(!0) : setTimeout(i, 10);
        };
        this._createIndexBuffer(), this._cachedUpdateDefines = "", this._platform.contextLost(), i();
      }, t.prototype._releaseBuffers = function() {
        this._buffer0 && (this._buffer0.dispose(), this._buffer0 = null), this._buffer1 && (this._buffer1.dispose(), this._buffer1 = null), this._spriteBuffer && (this._spriteBuffer.dispose(), this._spriteBuffer = null), this._platform.releaseBuffers();
      }, t.prototype.dispose = function(e) {
        for (var i in e === void 0 && (e = !0), this._drawWrappers)
          this._drawWrappers[i].dispose();
        if (this._drawWrappers = {}, this._scene) {
          var r = this._scene.particleSystems.indexOf(this);
          r > -1 && this._scene.particleSystems.splice(r, 1);
        }
        this._releaseBuffers(), this._platform.releaseVertexBuffers();
        for (var o = 0; o < this._renderVertexBuffers.length; ++o) {
          var a = this._renderVertexBuffers[o];
          for (var s in a)
            a[s].dispose();
        }
        this._renderVertexBuffers = [], this._colorGradientsTexture && (this._colorGradientsTexture.dispose(), this._colorGradientsTexture = null), this._sizeGradientsTexture && (this._sizeGradientsTexture.dispose(), this._sizeGradientsTexture = null), this._angularSpeedGradientsTexture && (this._angularSpeedGradientsTexture.dispose(), this._angularSpeedGradientsTexture = null), this._velocityGradientsTexture && (this._velocityGradientsTexture.dispose(), this._velocityGradientsTexture = null), this._limitVelocityGradientsTexture && (this._limitVelocityGradientsTexture.dispose(), this._limitVelocityGradientsTexture = null), this._dragGradientsTexture && (this._dragGradientsTexture.dispose(), this._dragGradientsTexture = null), this._randomTexture && (this._randomTexture.dispose(), this._randomTexture = null), this._randomTexture2 && (this._randomTexture2.dispose(), this._randomTexture2 = null), e && this.particleTexture && (this.particleTexture.dispose(), this.particleTexture = null), e && this.noiseTexture && (this.noiseTexture.dispose(), this.noiseTexture = null), this.onStoppedObservable.clear(), this.onDisposeObservable.notifyObservers(this), this.onDisposeObservable.clear();
      }, t.prototype.clone = function(e, i, r) {
        r === void 0 && (r = !1);
        var o = je({}, this._customWrappers), a = null, s = this._engine;
        if (s.createEffectForParticles && this.customShader != null) {
          var l = (a = this.customShader).shaderOptions.defines.length > 0 ? a.shaderOptions.defines.join(`
`) : "";
          o[0] = s.createEffectForParticles(a.shaderPath.fragmentElement, a.shaderOptions.uniforms, a.shaderOptions.samplers, l, void 0, void 0, void 0, this);
        }
        var c = this.serialize(r), u = t.Parse(c, this._scene || this._engine, this._rootUrl);
        return u.name = e, u.customShader = a, u._customWrappers = o, i === void 0 && (i = this.emitter), this.noiseTexture && (u.noiseTexture = this.noiseTexture.clone()), u.emitter = i, u;
      }, t.prototype.serialize = function(e) {
        e === void 0 && (e = !1);
        var i = {};
        return Ai._Serialize(i, this, e), i.activeParticleCount = this.activeParticleCount, i.randomTextureSize = this._randomTextureSize, i.customShader = this.customShader, i;
      }, t.Parse = function(e, i, r, o, a) {
        o === void 0 && (o = !1);
        var s, l = e.name;
        s = i instanceof Qe ? i : i.getEngine();
        var c = new t(l, { capacity: a || e.capacity, randomTextureSize: e.randomTextureSize }, i, null, e.isAnimationSheetEnabled);
        if (c._rootUrl = r, e.customShader && s.createEffectForParticles) {
          var u = e.customShader, h = u.shaderOptions.defines.length > 0 ? u.shaderOptions.defines.join(`
`) : "", d = s.createEffectForParticles(u.shaderPath.fragmentElement, u.shaderOptions.uniforms, u.shaderOptions.samplers, h, void 0, void 0, void 0, c);
          c.setCustomEffect(d, 0), c.customShader = u;
        }
        return e.id && (c.id = e.id), e.activeParticleCount && (c.activeParticleCount = e.activeParticleCount), Ai._Parse(e, c, i, r), e.preventAutoStart && (c.preventAutoStart = e.preventAutoStart), o || c.preventAutoStart || c.start(), c;
      }, t;
    }(fc), hd = function() {
      function n() {
        this._emitterNodeIsOwned = !0, this.systems = [];
      }
      return Object.defineProperty(n.prototype, "emitterNode", { get: function() {
        return this._emitterNode;
      }, set: function(t) {
        this._emitterNodeIsOwned && this._emitterNode && (this._emitterNode.dispose && this._emitterNode.dispose(), this._emitterNodeIsOwned = !1);
        for (var e = 0, i = this.systems; e < i.length; e++)
          i[e].emitter = t;
        this._emitterNode = t;
      }, enumerable: !1, configurable: !0 }), n.prototype.setEmitterAsSphere = function(t, e, i) {
        this._emitterNodeIsOwned && this._emitterNode && this._emitterNode.dispose && this._emitterNode.dispose(), this._emitterNodeIsOwned = !0, this._emitterCreationOptions = { kind: "Sphere", options: t, renderingGroupId: e };
        var r = yn("emitterSphere", { diameter: t.diameter, segments: t.segments }, i);
        r.renderingGroupId = e;
        var o = new Gt("emitterSphereMaterial", i);
        o.emissiveColor = t.color, r.material = o;
        for (var a = 0, s = this.systems; a < s.length; a++)
          s[a].emitter = r;
        this._emitterNode = r;
      }, n.prototype.start = function(t) {
        for (var e = 0, i = this.systems; e < i.length; e++) {
          var r = i[e];
          t && (r.emitter = t), r.start();
        }
      }, n.prototype.dispose = function() {
        for (var t = 0, e = this.systems; t < e.length; t++)
          e[t].dispose();
        this.systems.length = 0, this._emitterNode && (this._emitterNode.dispose && this._emitterNode.dispose(), this._emitterNode = null);
      }, n.prototype.serialize = function(t) {
        t === void 0 && (t = !1);
        for (var e = { systems: [] }, i = 0, r = this.systems; i < r.length; i++) {
          var o = r[i];
          e.systems.push(o.serialize(t));
        }
        return this._emitterNode && (e.emitter = this._emitterCreationOptions), e;
      }, n.Parse = function(t, e, i, r) {
        i === void 0 && (i = !1);
        var o = new n(), a = this.BaseAssetsUrl + "/textures/";
        e = e || Me.LastCreatedScene;
        for (var s = 0, l = t.systems; s < l.length; s++) {
          var c = l[s];
          o.systems.push(i ? Os.Parse(c, e, a, !0, r) : Ai.Parse(c, e, a, !0, r));
        }
        if (t.emitter) {
          var u = t.emitter.options;
          t.emitter.kind === "Sphere" && o.setEmitterAsSphere({ diameter: u.diameter, segments: u.segments, color: ne.FromArray(u.color) }, t.emitter.renderingGroupId, e);
        }
        return o;
      }, n.BaseAssetsUrl = "https://assets.babylonjs.com/particles", n;
    }(), DP = function() {
      function n() {
      }
      return n.CreateDefault = function(t, e, i, r) {
        var o;
        return e === void 0 && (e = 500), r === void 0 && (r = !1), (o = r ? new Os("default system", { capacity: e }, i) : new Ai("default system", e, i)).emitter = t, o.particleTexture = new ae("https://assets.babylonjs.com/textures/flare.png", o.getScene()), o.createConeEmitter(0.1, Math.PI / 4), o.color1 = new Ie(1, 1, 1, 1), o.color2 = new Ie(1, 1, 1, 1), o.colorDead = new Ie(1, 1, 1, 0), o.minSize = 0.1, o.maxSize = 0.1, o.minEmitPower = 2, o.maxEmitPower = 2, o.updateSpeed = 1 / 60, o.emitRate = 30, o;
      }, n.CreateAsync = function(t, e, i, r) {
        i === void 0 && (i = !1), e || (e = Me.LastCreatedScene);
        var o = {};
        return e.addPendingData(o), new Promise(function(a, s) {
          if (i && !Os.IsSupported)
            return e.removePendingData(o), s("Particle system with GPU is not supported.");
          de.LoadFile("".concat(n.BaseAssetsUrl, "/systems/").concat(t, ".json"), function(l) {
            e.removePendingData(o);
            var c = JSON.parse(l.toString());
            return a(hd.Parse(c, e, i, r));
          }, void 0, void 0, void 0, function() {
            return e.removePendingData(o), s("An error occurred with the creation of your particle system. Check if your type '".concat(t, "' exists."));
          });
        });
      }, n.ExportSet = function(t) {
        for (var e = new hd(), i = 0, r = t; i < r.length; i++) {
          var o = r[i];
          e.systems.push(o);
        }
        return e;
      }, n.ParseFromFileAsync = function(t, e, i, r, o, a) {
        return r === void 0 && (r = !1), o === void 0 && (o = ""), new Promise(function(s, l) {
          var c = new _n();
          c.addEventListener("readystatechange", function() {
            if (c.readyState == 4)
              if (c.status == 200) {
                var u = JSON.parse(c.responseText), h = void 0;
                h = r ? Os.Parse(u, i, o, !1, a) : Ai.Parse(u, i, o, !1, a), t && (h.name = t), s(h);
              } else
                l("Unable to load the particle system");
          }), c.open("GET", e), c.send();
        });
      }, n.ParseFromSnippetAsync = function(t, e, i, r, o) {
        var a = this;
        if (i === void 0 && (i = !1), r === void 0 && (r = ""), t === "_BLANK") {
          var s = this.CreateDefault(null);
          return s.start(), Promise.resolve(s);
        }
        return new Promise(function(l, c) {
          var u = new _n();
          u.addEventListener("readystatechange", function() {
            if (u.readyState == 4)
              if (u.status == 200) {
                var h = JSON.parse(JSON.parse(u.responseText).jsonPayload), d = JSON.parse(h.particleSystem), p = void 0;
                (p = i ? Os.Parse(d, e, r, !1, o) : Ai.Parse(d, e, r, !1, o)).snippetId = t, l(p);
              } else
                c("Unable to load the snippet " + t);
          }), u.open("GET", a.SnippetUrl + "/" + t.replace(/#/g, "/")), u.send();
        });
      }, n.BaseAssetsUrl = hd.BaseAssetsUrl, n.SnippetUrl = _.SnippetUrl, n.CreateFromSnippetAsync = n.ParseFromSnippetAsync, n;
    }();
    pe.AddParser(we.NAME_PARTICLESYSTEM, function(n, t, e, i) {
      var r = pe.GetIndividualParser(we.NAME_PARTICLESYSTEM);
      if (r && n.particleSystems !== void 0 && n.particleSystems !== null)
        for (var o = 0, a = n.particleSystems.length; o < a; o++) {
          var s = n.particleSystems[o];
          e.particleSystems.push(r(s, t, i));
        }
    }), pe.AddIndividualParser(we.NAME_PARTICLESYSTEM, function(n, t, e) {
      return n.activeParticleCount ? Os.Parse(n, t, e) : Ai.Parse(n, t, e);
    }), ve.prototype.createEffectForParticles = function(n, t, e, i, r, o, a, s) {
      var l;
      t === void 0 && (t = []), e === void 0 && (e = []), i === void 0 && (i = "");
      var c = [], u = [], h = [];
      return s ? s.fillUniformsAttributesAndSamplerNames(u, c, h) : (c = Ai._GetAttributeNamesOrOptions(), u = Ai._GetEffectCreationOptions()), i.indexOf(" BILLBOARD") === -1 && (i += `
#define BILLBOARD
`), s != null && s.isAnimationSheetEnabled && i.indexOf(" ANIMATESHEET") === -1 && (i += `
#define ANIMATESHEET
`), e.indexOf("diffuseSampler") === -1 && e.push("diffuseSampler"), this.createEffect({ vertex: (l = s == null ? void 0 : s.vertexShaderName) !== null && l !== void 0 ? l : "particles", fragmentElement: n }, c, u.concat(t), h.concat(e), i, r, o, a);
    }, ie.prototype.getEmittedParticleSystems = function() {
      for (var n = [], t = 0; t < this.getScene().particleSystems.length; t++) {
        var e = this.getScene().particleSystems[t];
        e.emitter === this && n.push(e);
      }
      return n;
    }, ie.prototype.getHierarchyEmittedParticleSystems = function() {
      var n = [], t = this.getDescendants();
      t.push(this);
      for (var e = 0; e < this.getScene().particleSystems.length; e++) {
        var i = this.getScene().particleSystems[e], r = i.emitter;
        r.position && t.indexOf(r) !== -1 && n.push(i);
      }
      return n;
    };
    var zn, $_ = function() {
      function n(t, e, i, r, o, a, s, l, c, u) {
        c === void 0 && (c = null), u === void 0 && (u = null), this.idx = 0, this.id = 0, this.color = new Ie(1, 1, 1, 1), this.position = v.Zero(), this.rotation = v.Zero(), this.scaling = v.One(), this.uvs = new lt(0, 0, 1, 1), this.velocity = v.Zero(), this.pivot = v.Zero(), this.translateFromPivot = !1, this.alive = !0, this.isVisible = !0, this._pos = 0, this._ind = 0, this.shapeId = 0, this.idxInShape = 0, this._stillInvisible = !1, this._rotationMatrix = [1, 0, 0, 0, 1, 0, 0, 0, 1], this.parentId = null, this.materialIndex = null, this.props = null, this.cullingStrategy = Dt.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY, this._globalPosition = v.Zero(), this.idx = t, this.id = e, this._pos = i, this._ind = r, this._model = o, this.shapeId = a, this.idxInShape = s, this._sps = l, c && (this._modelBoundingInfo = c, this._boundingInfo = new wr(c.minimum, c.maximum)), u !== null && (this.materialIndex = u);
      }
      return n.prototype.getBoundingInfo = function() {
        return this._boundingInfo;
      }, Object.defineProperty(n.prototype, "hasBoundingInfo", { get: function() {
        return this._boundingInfo !== null;
      }, enumerable: !1, configurable: !0 }), n.prototype.copyToRef = function(t) {
        return t.position.copyFrom(this.position), t.rotation.copyFrom(this.rotation), this.rotationQuaternion && (t.rotationQuaternion ? t.rotationQuaternion.copyFrom(this.rotationQuaternion) : t.rotationQuaternion = this.rotationQuaternion.clone()), t.scaling.copyFrom(this.scaling), this.color && (t.color ? t.color.copyFrom(this.color) : t.color = this.color.clone()), t.uvs.copyFrom(this.uvs), t.velocity.copyFrom(this.velocity), t.pivot.copyFrom(this.pivot), t.translateFromPivot = this.translateFromPivot, t.alive = this.alive, t.isVisible = this.isVisible, t.parentId = this.parentId, t.cullingStrategy = this.cullingStrategy, this.materialIndex !== null && (t.materialIndex = this.materialIndex), this;
      }, Object.defineProperty(n.prototype, "scale", { get: function() {
        return this.scaling;
      }, set: function(t) {
        this.scaling = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "quaternion", { get: function() {
        return this.rotationQuaternion;
      }, set: function(t) {
        this.rotationQuaternion = t;
      }, enumerable: !1, configurable: !0 }), n.prototype.intersectsMesh = function(t) {
        return !(!this._boundingInfo || !t.hasBoundingInfo) && (this._sps._bSphereOnly ? ul.Intersects(this._boundingInfo.boundingSphere, t.getBoundingInfo().boundingSphere) : this._boundingInfo.intersects(t.getBoundingInfo(), !1));
      }, n.prototype.isInFrustum = function(t) {
        return this._boundingInfo !== null && this._boundingInfo.isInFrustum(t, this.cullingStrategy);
      }, n.prototype.getRotationMatrix = function(t) {
        var e;
        if (this.rotationQuaternion)
          e = this.rotationQuaternion;
        else {
          e = F.Quaternion[0];
          var i = this.rotation;
          oe.RotationYawPitchRollToRef(i.y, i.x, i.z, e);
        }
        e.toRotationMatrix(t);
      }, n;
    }(), em = function() {
      function n(t, e, i, r, o, a, s, l, c) {
        this._indicesLength = 0, this.shapeId = t, this._shape = e, this._indices = i, this._indicesLength = i.length, this._shapeUV = a, this._shapeColors = o, this._normals = r, this._positionFunction = s, this._vertexFunction = l, this._material = c;
      }
      return Object.defineProperty(n.prototype, "shapeID", { get: function() {
        return this.shapeId;
      }, set: function(t) {
        this.shapeId = t;
      }, enumerable: !1, configurable: !0 }), n;
    }(), Y0 = function(n, t, e, i) {
      this.idx = 0, this.ind = 0, this.indicesLength = 0, this.sqDistance = 0, this.materialIndex = 0, this.idx = n, this.ind = t, this.indicesLength = e, this.materialIndex = i;
    }, K0 = function() {
      function n() {
        this.position = v.Zero(), this.color = new Ie(1, 1, 1, 1), this.uv = fe.Zero();
      }
      return Object.defineProperty(n.prototype, "x", { get: function() {
        return this.position.x;
      }, set: function(t) {
        this.position.x = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "y", { get: function() {
        return this.position.y;
      }, set: function(t) {
        this.position.y = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "z", { get: function() {
        return this.position.z;
      }, set: function(t) {
        this.position.z = t;
      }, enumerable: !1, configurable: !0 }), n;
    }(), NP = function() {
      function n(t, e, i) {
        this.particles = new Array(), this.nbParticles = 0, this.billboard = !1, this.recomputeNormals = !1, this.counter = 0, this.vars = {}, this._bSphereOnly = !1, this._bSphereRadiusFactor = 1, this._positions = new Array(), this._indices = new Array(), this._normals = new Array(), this._colors = new Array(), this._uvs = new Array(), this._index = 0, this._updatable = !0, this._pickable = !1, this._isVisibilityBoxLocked = !1, this._alwaysVisible = !1, this._depthSort = !1, this._expandable = !1, this._shapeCounter = 0, this._copy = new $_(0, 0, 0, 0, null, 0, 0, this), this._color = new Ie(0, 0, 0, 0), this._computeParticleColor = !0, this._computeParticleTexture = !0, this._computeParticleRotation = !0, this._computeParticleVertex = !1, this._computeBoundingBox = !1, this._autoFixFaceOrientation = !1, this._depthSortParticles = !0, this._mustUnrotateFixedNormals = !1, this._particlesIntersect = !1, this._needs32Bits = !1, this._isNotBuilt = !0, this._lastParticleId = 0, this._idxOfId = [], this._multimaterialEnabled = !1, this._useModelMaterial = !1, this._depthSortFunction = function(r, o) {
          return o.sqDistance - r.sqDistance;
        }, this._materialSortFunction = function(r, o) {
          return r.materialIndex - o.materialIndex;
        }, this._autoUpdateSubMeshes = !1, this._recomputeInvisibles = !1, this.name = t, this._scene = e || Me.LastCreatedScene, this._camera = e.activeCamera, this._pickable = !!i && i.isPickable, this._depthSort = !!i && i.enableDepthSort, this._multimaterialEnabled = !!i && i.enableMultiMaterial, this._useModelMaterial = !!i && i.useModelMaterial, this._multimaterialEnabled = !!this._useModelMaterial || this._multimaterialEnabled, this._expandable = !!i && i.expandable, this._particlesIntersect = !!i && i.particleIntersection, this._bSphereOnly = !!i && i.boundingSphereOnly, this._bSphereRadiusFactor = i && i.bSphereRadiusFactor ? i.bSphereRadiusFactor : 1, this._computeBoundingBox = !!(i != null && i.computeBoundingBox) && i.computeBoundingBox, this._autoFixFaceOrientation = !!(i != null && i.autoFixFaceOrientation) && i.autoFixFaceOrientation, i && i.updatable !== void 0 ? this._updatable = i.updatable : this._updatable = !0, this._pickable && (this.pickedBySubMesh = [[]], this.pickedParticles = this.pickedBySubMesh[0]), (this._depthSort || this._multimaterialEnabled) && (this.depthSortedParticles = []), this._multimaterialEnabled && (this._multimaterial = new Ao(this.name + "MultiMaterial", this._scene), this._materials = [], this._materialIndexesById = {}), this._tmpVertex = new K0();
      }
      return n.prototype.buildMesh = function() {
        if (!this._isNotBuilt && this.mesh)
          return this.mesh;
        if (this.nbParticles === 0 && !this.mesh) {
          var t = bl("", { radius: 1, tessellation: 3 }, this._scene);
          this.addShape(t, 1), t.dispose();
        }
        if (this._indices32 = this._needs32Bits ? new Uint32Array(this._indices) : new Uint16Array(this._indices), this._positions32 = new Float32Array(this._positions), this._uvs32 = new Float32Array(this._uvs), this._colors32 = new Float32Array(this._colors), !this.mesh) {
          var e = new ie(this.name, this._scene);
          this.mesh = e;
        }
        !this._updatable && this._multimaterialEnabled && this._sortParticlesByMaterial(), this.recomputeNormals && Oe.ComputeNormals(this._positions32, this._indices32, this._normals), this._normals32 = new Float32Array(this._normals), this._fixedNormal32 = new Float32Array(this._normals), this._mustUnrotateFixedNormals && this._unrotateFixedNormals();
        var i = new Oe();
        if (i.indices = this._depthSort ? this._indices : this._indices32, i.set(this._positions32, P.PositionKind), i.set(this._normals32, P.NormalKind), this._uvs32.length > 0 && i.set(this._uvs32, P.UVKind), this._colors32.length > 0 && i.set(this._colors32, P.ColorKind), i.applyToMesh(this.mesh, this._updatable), this.mesh.isPickable = this._pickable, this._pickable) {
          for (var r = 0, o = 0; o < this.nbParticles; o++)
            for (var a = this.particles[o], s = a._model._indicesLength, l = 0; l < s; l++)
              if (l % 3 == 0) {
                var c = { idx: a.idx, faceId: r };
                this.pickedParticles[r] = c, r++;
              }
        }
        return this._multimaterialEnabled && this.setMultiMaterial(this._materials), this._expandable || (this._depthSort || this._multimaterialEnabled || this._autoFixFaceOrientation || (this._indices = null), this._positions = null, this._normals = null, this._uvs = null, this._colors = null, this._updatable || (this.particles.length = 0)), this._isNotBuilt = !1, this.recomputeNormals = !1, this._recomputeInvisibles = !0, this.mesh;
      }, n.prototype._getUVKind = function(t, e) {
        var i, r;
        return e === -1 && (!((i = t.material) === null || i === void 0) && i.diffuseTexture ? e = t.material.diffuseTexture.coordinatesIndex : !((r = t.material) === null || r === void 0) && r.albedoTexture && (e = t.material.albedoTexture.coordinatesIndex)), "uv" + (e ? e + 1 : "");
      }, n.prototype.digest = function(t, e) {
        var i, r = e && e.facetNb || 1, o = e && e.number || 0, a = e && e.delta || 0, s = t.getVerticesData(P.PositionKind), l = t.getIndices(), c = t.getVerticesData(this._getUVKind(t, (i = e == null ? void 0 : e.uvKind) !== null && i !== void 0 ? i : 0)), u = t.getVerticesData(P.ColorKind), h = t.getVerticesData(P.NormalKind), d = e && e.storage ? e.storage : null, p = 0, f = l.length / 3;
        o ? (o = o > f ? f : o, r = Math.round(f / o), a = 0) : r = r > f ? f : r;
        for (var m = [], g = [], y = [], b = [], T = [], S = v.Zero(), E = r; p < f; ) {
          p > f - (r = E + Math.floor((1 + a) * Math.random())) && (r = f - p), m.length = 0, g.length = 0, y.length = 0, b.length = 0, T.length = 0;
          for (var A = 0, R = 3 * p; R < 3 * (p + r); R++) {
            y.push(A);
            var C = l[R], L = 3 * C;
            if (m.push(s[L], s[L + 1], s[L + 2]), g.push(h[L], h[L + 1], h[L + 2]), c) {
              var I = 2 * C;
              b.push(c[I], c[I + 1]);
            }
            if (u) {
              var O = 4 * C;
              T.push(u[O], u[O + 1], u[O + 2], u[O + 3]);
            }
            A++;
          }
          var w = this.nbParticles, z = this._posToShape(m), V = this._uvsToShapeUV(b), Y = y.slice(), ee = T.slice(), J = g.slice();
          S.copyFromFloats(0, 0, 0);
          var X = void 0;
          for (X = 0; X < z.length; X++)
            S.addInPlace(z[X]);
          S.scaleInPlace(1 / z.length);
          var K = new v(1 / 0, 1 / 0, 1 / 0), te = new v(-1 / 0, -1 / 0, -1 / 0);
          for (X = 0; X < z.length; X++)
            z[X].subtractInPlace(S), K.minimizeInPlaceFromFloats(z[X].x, z[X].y, z[X].z), te.maximizeInPlaceFromFloats(z[X].x, z[X].y, z[X].z);
          var se = void 0;
          this._particlesIntersect && (se = new wr(K, te));
          var _e = null;
          this._useModelMaterial && (_e = t.material ? t.material : this._setDefaultMaterial());
          var xe = new em(this._shapeCounter, z, Y, J, ee, V, null, null, _e), Te = this._positions.length, he = this._indices.length;
          this._meshBuilder(this._index, he, z, this._positions, Y, this._indices, b, this._uvs, ee, this._colors, J, this._normals, w, 0, null, xe), this._addParticle(w, this._lastParticleId, Te, he, xe, this._shapeCounter, 0, se, d), this.particles[this.nbParticles].position.addInPlace(S), d || (this._index += z.length, w++, this.nbParticles++, this._lastParticleId++), this._shapeCounter++, p += r;
        }
        return this._isNotBuilt = !0, this;
      }, n.prototype._unrotateFixedNormals = function() {
        for (var t = 0, e = 0, i = F.Vector3[0], r = F.Quaternion[0], o = F.Matrix[0], a = 0; a < this.particles.length; a++) {
          var s = this.particles[a], l = s._model._shape;
          if (s.rotationQuaternion)
            s.rotationQuaternion.conjugateToRef(r);
          else {
            var c = s.rotation;
            oe.RotationYawPitchRollToRef(c.y, c.x, c.z, r), r.conjugateInPlace();
          }
          r.toRotationMatrix(o);
          for (var u = 0; u < l.length; u++)
            e = t + 3 * u, v.TransformNormalFromFloatsToRef(this._normals32[e], this._normals32[e + 1], this._normals32[e + 2], o, i), i.toArray(this._fixedNormal32, e);
          t = e + 3;
        }
      }, n.prototype._resetCopy = function() {
        var t = this._copy;
        t.position.setAll(0), t.rotation.setAll(0), t.rotationQuaternion = null, t.scaling.setAll(1), t.uvs.copyFromFloats(0, 0, 1, 1), t.color = null, t.translateFromPivot = !1, t.shapeId = 0, t.materialIndex = null;
      }, n.prototype._meshBuilder = function(t, e, i, r, o, a, s, l, c, u, h, d, p, f, m, g) {
        var y, b = 0, T = 0, S = 0;
        this._resetCopy();
        var E = this._copy, A = !(!m || !m.storage);
        if (E.idx = p, E.idxInShape = f, E.shapeId = g.shapeId, this._useModelMaterial) {
          var R = g._material.uniqueId, C = this._materialIndexesById;
          Object.prototype.hasOwnProperty.call(C, R) || (C[R] = this._materials.length, this._materials.push(g._material));
          var L = C[R];
          E.materialIndex = L;
        }
        if (m && m.positionFunction && (m.positionFunction(E, p, f), this._mustUnrotateFixedNormals = !0), A)
          return E;
        var I = F.Matrix[0], O = this._tmpVertex, w = O.position, z = O.color, V = O.uv, Y = F.Vector3[1], ee = F.Vector3[2], J = F.Vector3[3];
        B.IdentityToRef(I), E.getRotationMatrix(I), E.pivot.multiplyToRef(E.scaling, J), E.translateFromPivot ? ee.setAll(0) : ee.copyFrom(J);
        var X = m && m.vertexFunction;
        for (y = 0; y < i.length; y++) {
          if (w.copyFrom(i[y]), E.color && z.copyFrom(E.color), s && V.copyFromFloats(s[b], s[b + 1]), X && m.vertexFunction(E, O, y), w.multiplyInPlace(E.scaling).subtractInPlace(J), v.TransformCoordinatesToRef(w, I, Y), Y.addInPlace(ee).addInPlace(E.position), r.push(Y.x, Y.y, Y.z), s) {
            var K = E.uvs;
            l.push((K.z - K.x) * V.x + K.x, (K.w - K.y) * V.y + K.y), b += 2;
          }
          if (E.color)
            this._color.copyFrom(z);
          else {
            var te = this._color;
            c && c[T] !== void 0 ? (te.r = c[T], te.g = c[T + 1], te.b = c[T + 2], te.a = c[T + 3]) : (te.r = 1, te.g = 1, te.b = 1, te.a = 1);
          }
          u.push(this._color.r, this._color.g, this._color.b, this._color.a), T += 4, !this.recomputeNormals && h && (v.TransformNormalFromFloatsToRef(h[S], h[S + 1], h[S + 2], I, w), d.push(w.x, w.y, w.z), S += 3);
        }
        for (y = 0; y < o.length; y++) {
          var se = t + o[y];
          a.push(se), se > 65535 && (this._needs32Bits = !0);
        }
        if (this._depthSort || this._multimaterialEnabled) {
          var _e = E.materialIndex !== null ? E.materialIndex : 0;
          this.depthSortedParticles.push(new Y0(p, e, o.length, _e));
        }
        return E;
      }, n.prototype._posToShape = function(t) {
        for (var e = [], i = 0; i < t.length; i += 3)
          e.push(v.FromArray(t, i));
        return e;
      }, n.prototype._uvsToShapeUV = function(t) {
        var e = [];
        if (t)
          for (var i = 0; i < t.length; i++)
            e.push(t[i]);
        return e;
      }, n.prototype._addParticle = function(t, e, i, r, o, a, s, l, c) {
        l === void 0 && (l = null), c === void 0 && (c = null);
        var u = new $_(t, e, i, r, o, a, s, this, l);
        return (c || this.particles).push(u), u;
      }, n.prototype.addShape = function(t, e, i) {
        var r = t.getVerticesData(P.PositionKind), o = t.getIndices(), a = t.getVerticesData(P.UVKind), s = t.getVerticesData(P.ColorKind), l = t.getVerticesData(P.NormalKind);
        this.recomputeNormals = !l;
        var c = Array.from(o), u = l ? Array.from(l) : [], h = s ? Array.from(s) : [], d = i && i.storage ? i.storage : null, p = null;
        this._particlesIntersect && (p = t.getBoundingInfo());
        var f = this._posToShape(r), m = this._uvsToShapeUV(a), g = i ? i.positionFunction : null, y = i ? i.vertexFunction : null, b = null;
        this._useModelMaterial && (b = t.material ? t.material : this._setDefaultMaterial());
        for (var T = new em(this._shapeCounter, f, c, u, h, m, g, y, b), S = 0; S < e; S++)
          this._insertNewParticle(this.nbParticles, S, T, f, o, a, s, l, p, d, i);
        return this._shapeCounter++, this._isNotBuilt = !0, this._shapeCounter - 1;
      }, n.prototype._rebuildParticle = function(t, e) {
        e === void 0 && (e = !1), this._resetCopy();
        var i = this._copy;
        t._model._positionFunction && t._model._positionFunction(i, t.idx, t.idxInShape);
        var r = F.Matrix[0], o = F.Vector3[0], a = F.Vector3[1], s = F.Vector3[2], l = F.Vector3[3];
        i.getRotationMatrix(r), t.pivot.multiplyToRef(t.scaling, l), i.translateFromPivot ? s.copyFromFloats(0, 0, 0) : s.copyFrom(l);
        for (var c = t._model._shape, u = 0; u < c.length; u++)
          o.copyFrom(c[u]), t._model._vertexFunction && t._model._vertexFunction(i, o, u), o.multiplyInPlace(i.scaling).subtractInPlace(l), v.TransformCoordinatesToRef(o, r, a), a.addInPlace(s).addInPlace(i.position).toArray(this._positions32, t._pos + 3 * u);
        e && (t.position.setAll(0), t.rotation.setAll(0), t.rotationQuaternion = null, t.scaling.setAll(1), t.uvs.setAll(0), t.pivot.setAll(0), t.translateFromPivot = !1, t.parentId = null);
      }, n.prototype.rebuildMesh = function(t) {
        t === void 0 && (t = !1);
        for (var e = 0; e < this.particles.length; e++)
          this._rebuildParticle(this.particles[e], t);
        return this.mesh.updateVerticesData(P.PositionKind, this._positions32, !1, !1), this;
      }, n.prototype.removeParticles = function(t, e) {
        var i = e - t + 1;
        if (!this._expandable || i <= 0 || i >= this.nbParticles || !this._updatable)
          return [];
        var r = this.particles, o = this.nbParticles;
        if (e < o - 1)
          for (var a = e + 1, s = r[a]._pos - r[t]._pos, l = r[a]._ind - r[t]._ind, c = a; c < o; c++) {
            var u = r[c];
            u._pos -= s, u._ind -= l;
          }
        var h = r.splice(t, i);
        this._positions.length = 0, this._indices.length = 0, this._colors.length = 0, this._uvs.length = 0, this._normals.length = 0, this._index = 0, this._idxOfId.length = 0, (this._depthSort || this._multimaterialEnabled) && (this.depthSortedParticles = []);
        for (var d = 0, p = r.length, f = 0; f < p; f++) {
          var m = r[f], g = m._model, y = g._shape, b = g._indices, T = g._normals, S = g._shapeColors, E = g._shapeUV;
          m.idx = f, this._idxOfId[m.id] = f, this._meshBuilder(this._index, d, y, this._positions, b, this._indices, E, this._uvs, S, this._colors, T, this._normals, m.idx, m.idxInShape, null, g), this._index += y.length, d += b.length;
        }
        return this.nbParticles -= i, this._isNotBuilt = !0, h;
      }, n.prototype.insertParticlesFromArray = function(t) {
        if (!this._expandable)
          return this;
        for (var e = 0, i = t[0].shapeId, r = t.length, o = 0; o < r; o++) {
          var a = t[o], s = a._model, l = s._shape, c = s._indices, u = s._shapeUV, h = s._shapeColors, d = s._normals, p = !d;
          this.recomputeNormals = p || this.recomputeNormals;
          var f = a.getBoundingInfo(), m = this._insertNewParticle(this.nbParticles, e, s, l, c, u, h, d, f, null, null);
          a.copyToRef(m), e++, i != a.shapeId && (i = a.shapeId, e = 0);
        }
        return this._isNotBuilt = !0, this;
      }, n.prototype._insertNewParticle = function(t, e, i, r, o, a, s, l, c, u, h) {
        var d = this._positions.length, p = this._indices.length, f = this._meshBuilder(this._index, p, r, this._positions, o, this._indices, a, this._uvs, s, this._colors, l, this._normals, t, e, h, i), m = null;
        return this._updatable && ((m = this._addParticle(this.nbParticles, this._lastParticleId, d, p, i, this._shapeCounter, e, c, u)).position.copyFrom(f.position), m.rotation.copyFrom(f.rotation), f.rotationQuaternion && (m.rotationQuaternion ? m.rotationQuaternion.copyFrom(f.rotationQuaternion) : m.rotationQuaternion = f.rotationQuaternion.clone()), f.color && (m.color ? m.color.copyFrom(f.color) : m.color = f.color.clone()), m.scaling.copyFrom(f.scaling), m.uvs.copyFrom(f.uvs), f.materialIndex !== null && (m.materialIndex = f.materialIndex), this.expandable && (this._idxOfId[m.id] = m.idx)), u || (this._index += r.length, this.nbParticles++, this._lastParticleId++), m;
      }, n.prototype.setParticles = function(t, e, i) {
        if (t === void 0 && (t = 0), e === void 0 && (e = this.nbParticles - 1), i === void 0 && (i = !0), !this._updatable || this._isNotBuilt)
          return this;
        this.beforeUpdateParticles(t, e, i);
        var r = F.Matrix[0], o = F.Matrix[1], a = this.mesh, s = this._colors32, l = this._positions32, c = this._normals32, u = this._uvs32, h = this._indices32, d = this._indices, p = this._fixedNormal32, f = this._depthSort && this._depthSortParticles, m = F.Vector3, g = m[5].copyFromFloats(1, 0, 0), y = m[6].copyFromFloats(0, 1, 0), b = m[7].copyFromFloats(0, 0, 1), T = m[8].setAll(Number.MAX_VALUE), S = m[9].setAll(-Number.MAX_VALUE), E = m[10].setAll(0), A = this._tmpVertex, R = A.position, C = A.color, L = A.uv;
        if ((this.billboard || this._depthSort) && (this.mesh.computeWorldMatrix(!0), this.mesh._worldMatrix.invertToRef(o)), this.billboard) {
          var I = m[0];
          this._camera.getDirectionToRef(qi.Z, I), v.TransformNormalToRef(I, o, b), b.normalize();
          var O = this._camera.getViewMatrix(!0);
          v.TransformNormalFromFloatsToRef(O.m[1], O.m[5], O.m[9], o, y), v.CrossToRef(y, b, g), y.normalize(), g.normalize();
        }
        this._depthSort && v.TransformCoordinatesToRef(this._camera.globalPosition, o, E), B.IdentityToRef(r);
        var w = 0, z = 0, V = 0, Y = 0, ee = 0, J = 0, X = 0;
        if (this.mesh.isFacetDataEnabled && (this._computeBoundingBox = !0), e = e >= this.nbParticles ? this.nbParticles - 1 : e, this._computeBoundingBox && (t != 0 || e != this.nbParticles - 1)) {
          var K = this.mesh.getBoundingInfo();
          K && (T.copyFrom(K.minimum), S.copyFrom(K.maximum));
        }
        var te = (z = this.particles[t]._pos) / 3 | 0;
        Y = 4 * te, J = 2 * te;
        for (var se = t; se <= e; se++) {
          var _e = this.particles[se];
          this.updateParticle(_e);
          var xe = _e._model._shape, Te = _e._model._shapeUV, he = _e._rotationMatrix, me = _e.position, Fe = _e.rotation, Ce = _e.scaling, Re = _e._globalPosition;
          if (f) {
            var Be = this.depthSortedParticles[se];
            Be.idx = _e.idx, Be.ind = _e._ind, Be.indicesLength = _e._model._indicesLength, Be.sqDistance = v.DistanceSquared(_e.position, E);
          }
          if (_e.alive && (!_e._stillInvisible || _e.isVisible || this._recomputeInvisibles)) {
            if (_e.isVisible) {
              _e._stillInvisible = !1;
              var De = m[12];
              if (_e.pivot.multiplyToRef(Ce, De), this.billboard && (Fe.x = 0, Fe.y = 0), (this._computeParticleRotation || this.billboard) && _e.getRotationMatrix(r), _e.parentId !== null) {
                var Ke = this.getParticleById(_e.parentId);
                if (Ke) {
                  var ge = Ke._rotationMatrix, rt = Ke._globalPosition, it = me.x * ge[1] + me.y * ge[4] + me.z * ge[7], He = me.x * ge[0] + me.y * ge[3] + me.z * ge[6], Pt = me.x * ge[2] + me.y * ge[5] + me.z * ge[8];
                  if (Re.x = rt.x + He, Re.y = rt.y + it, Re.z = rt.z + Pt, this._computeParticleRotation || this.billboard) {
                    var ke = r.m;
                    he[0] = ke[0] * ge[0] + ke[1] * ge[3] + ke[2] * ge[6], he[1] = ke[0] * ge[1] + ke[1] * ge[4] + ke[2] * ge[7], he[2] = ke[0] * ge[2] + ke[1] * ge[5] + ke[2] * ge[8], he[3] = ke[4] * ge[0] + ke[5] * ge[3] + ke[6] * ge[6], he[4] = ke[4] * ge[1] + ke[5] * ge[4] + ke[6] * ge[7], he[5] = ke[4] * ge[2] + ke[5] * ge[5] + ke[6] * ge[8], he[6] = ke[8] * ge[0] + ke[9] * ge[3] + ke[10] * ge[6], he[7] = ke[8] * ge[1] + ke[9] * ge[4] + ke[10] * ge[7], he[8] = ke[8] * ge[2] + ke[9] * ge[5] + ke[10] * ge[8];
                  }
                } else
                  _e.parentId = null;
              } else
                Re.x = me.x, Re.y = me.y, Re.z = me.z, (this._computeParticleRotation || this.billboard) && (ke = r.m, he[0] = ke[0], he[1] = ke[1], he[2] = ke[2], he[3] = ke[4], he[4] = ke[5], he[5] = ke[6], he[6] = ke[8], he[7] = ke[9], he[8] = ke[10]);
              var xt = m[11];
              for (_e.translateFromPivot ? xt.setAll(0) : xt.copyFrom(De), X = 0; X < xe.length; X++) {
                w = z + 3 * X, V = Y + 4 * X, ee = J + 2 * X;
                var Nt = 2 * X, $e = Nt + 1;
                R.copyFrom(xe[X]), this._computeParticleColor && _e.color && C.copyFrom(_e.color), this._computeParticleTexture && L.copyFromFloats(Te[Nt], Te[$e]), this._computeParticleVertex && this.updateParticleVertex(_e, A, X);
                var Rt = R.x * Ce.x - De.x, kt = R.y * Ce.y - De.y, _t = R.z * Ce.z - De.z;
                He = Rt * he[0] + kt * he[3] + _t * he[6], it = Rt * he[1] + kt * he[4] + _t * he[7], Pt = Rt * he[2] + kt * he[5] + _t * he[8], He += xt.x, it += xt.y, Pt += xt.z;
                var Pi = l[w] = Re.x + g.x * He + y.x * it + b.x * Pt, Hn = l[w + 1] = Re.y + g.y * He + y.y * it + b.y * Pt, Xr = l[w + 2] = Re.z + g.z * He + y.z * it + b.z * Pt;
                if (this._computeBoundingBox && (T.minimizeInPlaceFromFloats(Pi, Hn, Xr), S.maximizeInPlaceFromFloats(Pi, Hn, Xr)), !this._computeParticleVertex) {
                  var fo = p[w], Ln = p[w + 1], ni = p[w + 2], ci = fo * he[0] + Ln * he[3] + ni * he[6], qt = fo * he[1] + Ln * he[4] + ni * he[7], jr = fo * he[2] + Ln * he[5] + ni * he[8];
                  c[w] = g.x * ci + y.x * qt + b.x * jr, c[w + 1] = g.y * ci + y.y * qt + b.y * jr, c[w + 2] = g.z * ci + y.z * qt + b.z * jr;
                }
                if (this._computeParticleColor && _e.color) {
                  var Zn = this._colors32;
                  Zn[V] = C.r, Zn[V + 1] = C.g, Zn[V + 2] = C.b, Zn[V + 3] = C.a;
                }
                if (this._computeParticleTexture) {
                  var In = _e.uvs;
                  u[ee] = L.x * (In.z - In.x) + In.x, u[ee + 1] = L.y * (In.w - In.y) + In.y;
                }
              }
            } else
              for (_e._stillInvisible = !0, X = 0; X < xe.length; X++) {
                if (V = Y + 4 * X, ee = J + 2 * X, l[w = z + 3 * X] = l[w + 1] = l[w + 2] = 0, c[w] = c[w + 1] = c[w + 2] = 0, this._computeParticleColor && _e.color) {
                  var yr = _e.color;
                  s[V] = yr.r, s[V + 1] = yr.g, s[V + 2] = yr.b, s[V + 3] = yr.a;
                }
                this._computeParticleTexture && (In = _e.uvs, u[ee] = Te[2 * X] * (In.z - In.x) + In.x, u[ee + 1] = Te[2 * X + 1] * (In.w - In.y) + In.y);
              }
            if (this._particlesIntersect) {
              var ns = _e.getBoundingInfo(), Bs = ns.boundingBox, Us = ns.boundingSphere, _o = _e._modelBoundingInfo;
              if (!this._bSphereOnly) {
                var mo = _o.boundingBox.vectors, cr = m[1], Xo = m[2];
                cr.setAll(Number.MAX_VALUE), Xo.setAll(-Number.MAX_VALUE);
                for (var go = 0; go < 8; go++) {
                  var Pa = mo[go].x * Ce.x, Ia = mo[go].y * Ce.y, Ma = mo[go].z * Ce.z, Mn = (He = Pa * he[0] + Ia * he[3] + Ma * he[6], it = Pa * he[1] + Ia * he[4] + Ma * he[7], Pt = Pa * he[2] + Ia * he[5] + Ma * he[8], me.x + g.x * He + y.x * it + b.x * Pt), Yr = me.y + g.y * He + y.y * it + b.y * Pt, wn = me.z + g.z * He + y.z * it + b.z * Pt;
                  cr.minimizeInPlaceFromFloats(Mn, Yr, wn), Xo.maximizeInPlaceFromFloats(Mn, Yr, wn);
                }
                Bs.reConstruct(cr, Xo, a._worldMatrix);
              }
              var jo = _o.minimum.multiplyToRef(Ce, m[1]), Yo = _o.maximum.multiplyToRef(Ce, m[2]), vo = Yo.addToRef(jo, m[3]).scaleInPlace(0.5).addInPlace(Re), Bn = Yo.subtractToRef(jo, m[4]).scaleInPlace(0.5 * this._bSphereRadiusFactor), Vs = vo.subtractToRef(Bn, m[1]), Pm = vo.addToRef(Bn, m[2]);
              Us.reConstruct(Vs, Pm, a._worldMatrix);
            }
            z = w + 3, Y = V + 4, J = ee + 2;
          } else
            z += 3 * (X = xe.length), Y += 4 * X, J += 2 * X;
        }
        if (i) {
          this._computeParticleColor && ((rs = a.getVertexBuffer(P.ColorKind)) && !a.isPickable ? rs.updateDirectly(s, 0) : a.updateVerticesData(P.ColorKind, s, !1, !1)), this._computeParticleTexture && ((rs = a.getVertexBuffer(P.UVKind)) && !a.isPickable ? rs.updateDirectly(u, 0) : a.updateVerticesData(P.UVKind, u, !1, !1));
          var Oa = a.getVertexBuffer(P.PositionKind);
          if (Oa && !a.isPickable ? Oa.updateDirectly(l, 0) : a.updateVerticesData(P.PositionKind, l, !1, !1), !a.areNormalsFrozen || a.isFacetDataEnabled) {
            if (this._computeParticleVertex || a.isFacetDataEnabled) {
              var Kr = a.isFacetDataEnabled ? a.getFacetDataParameters() : null;
              Oe.ComputeNormals(l, h, c, Kr);
              for (var yo = 0; yo < c.length; yo++)
                p[yo] = c[yo];
            }
            var rs;
            a.areNormalsFrozen || ((rs = a.getVertexBuffer(P.NormalKind)) && !a.isPickable ? rs.updateDirectly(c, 0) : a.updateVerticesData(P.NormalKind, c, !1, !1));
          }
          if (f) {
            var ks = this.depthSortedParticles;
            ks.sort(this._depthSortFunction);
            for (var Im = ks.length, Gd = 0, vu = 0, zd = 0; zd < Im; zd++) {
              var Wd = ks[zd], CA = Wd.indicesLength, Mm = Wd.ind;
              for (yo = 0; yo < CA; yo++)
                if (h[Gd] = d[Mm + yo], Gd++, this._pickable && yo % 3 == 0) {
                  var Hd = this.pickedParticles[vu];
                  Hd.idx = Wd.idx, Hd.faceId = vu, vu++;
                }
            }
          }
          if (this._autoFixFaceOrientation)
            for (var yu = 0, Gs = 0; Gs < this.particles.length; Gs++) {
              if ((_e = f ? this.particles[this.depthSortedParticles[Gs].idx] : this.particles[Gs]).scale.x * _e.scale.y * _e.scale.z < 0)
                for (var Da = 0; Da < _e._model._indicesLength; Da += 3) {
                  var Xd = d[_e._ind + Da];
                  h[yu + Da] = d[_e._ind + Da + 1], h[yu + Da + 1] = Xd;
                }
              yu += _e._model._indicesLength;
            }
          (f || this._autoFixFaceOrientation) && a.updateIndices(h);
        }
        return this._computeBoundingBox && (a.hasBoundingInfo ? a.getBoundingInfo().reConstruct(T, S, a._worldMatrix) : a.buildBoundingInfo(T, S, a._worldMatrix)), this._autoUpdateSubMeshes && this.computeSubMeshes(), this._recomputeInvisibles = !1, this.afterUpdateParticles(t, e, i), this;
      }, n.prototype.dispose = function() {
        this.mesh.dispose(), this.vars = null, this._positions = null, this._indices = null, this._normals = null, this._uvs = null, this._colors = null, this._indices32 = null, this._positions32 = null, this._normals32 = null, this._fixedNormal32 = null, this._uvs32 = null, this._colors32 = null, this.pickedParticles = null, this.pickedBySubMesh = null, this._materials = null, this._materialIndexes = null, this._indicesByMaterial = null, this._idxOfId = null;
      }, n.prototype.pickedParticle = function(t) {
        if (t.hit) {
          var e = t.subMeshId, i = t.faceId - this.mesh.subMeshes[e].indexStart / 3, r = this.pickedBySubMesh;
          if (r[e] && r[e][i])
            return r[e][i];
        }
        return null;
      }, n.prototype.getParticleById = function(t) {
        var e = this.particles[t];
        if (e && e.id == t)
          return e;
        var i = this.particles, r = this._idxOfId[t];
        if (r !== void 0)
          return i[r];
        for (var o = 0, a = this.nbParticles; o < a; ) {
          var s = i[o];
          if (s.id == t)
            return s;
          o++;
        }
        return null;
      }, n.prototype.getParticlesByShapeId = function(t) {
        var e = [];
        return this.getParticlesByShapeIdToRef(t, e), e;
      }, n.prototype.getParticlesByShapeIdToRef = function(t, e) {
        e.length = 0;
        for (var i = 0; i < this.nbParticles; i++) {
          var r = this.particles[i];
          r.shapeId == t && e.push(r);
        }
        return this;
      }, n.prototype.computeSubMeshes = function() {
        if (!this.mesh || !this._multimaterialEnabled)
          return this;
        var t = this.depthSortedParticles;
        if (this.particles.length > 0)
          for (var e = 0; e < this.particles.length; e++) {
            var i = this.particles[e];
            i.materialIndex || (i.materialIndex = 0);
            var r = t[e];
            r.materialIndex = i.materialIndex, r.ind = i._ind, r.indicesLength = i._model._indicesLength, r.idx = i.idx;
          }
        this._sortParticlesByMaterial();
        var o = this._indicesByMaterial, a = this._materialIndexes, s = this.mesh;
        s.subMeshes = [];
        for (var l = s.getTotalVertices(), c = 0; c < a.length; c++) {
          var u = o[c], h = o[c + 1] - u, d = a[c];
          new Yn(d, 0, l, u, h, s);
        }
        return this;
      }, n.prototype._sortParticlesByMaterial = function() {
        var t = [0];
        this._indicesByMaterial = t;
        var e = [];
        this._materialIndexes = e;
        var i = this.depthSortedParticles;
        i.sort(this._materialSortFunction);
        var r = i.length, o = this._indices32, a = this._indices, s = 0, l = 0, c = 0, u = i[0].materialIndex;
        e.push(u), this._pickable && (this.pickedBySubMesh = [[]], this.pickedParticles = this.pickedBySubMesh[0]);
        for (var h = 0; h < r; h++) {
          var d = i[h], p = d.indicesLength, f = d.ind;
          d.materialIndex !== u && (u = d.materialIndex, t.push(c), e.push(u), this._pickable && (s++, this.pickedBySubMesh[s] = [], l = 0));
          for (var m = 0, g = 0; g < p; g++) {
            if (o[c] = a[f + g], this._pickable && g % 3 == 0) {
              var y = this.pickedBySubMesh[s][l];
              y ? (y.idx = d.idx, y.faceId = m) : this.pickedBySubMesh[s][l] = { idx: d.idx, faceId: m }, l++, m++;
            }
            c++;
          }
        }
        return t.push(o.length), this._updatable && this.mesh.updateIndices(o), this;
      }, n.prototype._setMaterialIndexesById = function() {
        this._materialIndexesById = {};
        for (var t = 0; t < this._materials.length; t++) {
          var e = this._materials[t].uniqueId;
          this._materialIndexesById[e] = t;
        }
      }, n.prototype._filterUniqueMaterialId = function(t) {
        return t.filter(function(e, i, r) {
          return r.indexOf(e) === i;
        });
      }, n.prototype._setDefaultMaterial = function() {
        return this._defaultMaterial || (this._defaultMaterial = new Gt(this.name + "DefaultMaterial", this._scene)), this._defaultMaterial;
      }, n.prototype.refreshVisibleSize = function() {
        return this._isVisibilityBoxLocked || this.mesh.refreshBoundingInfo(), this;
      }, n.prototype.setVisibilityBox = function(t) {
        var e = t / 2;
        this.mesh.buildBoundingInfo(new v(-e, -e, -e), new v(e, e, e));
      }, Object.defineProperty(n.prototype, "isAlwaysVisible", { get: function() {
        return this._alwaysVisible;
      }, set: function(t) {
        this._alwaysVisible = t, this.mesh.alwaysSelectAsActiveMesh = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isVisibilityBoxLocked", { get: function() {
        return this._isVisibilityBoxLocked;
      }, set: function(t) {
        this._isVisibilityBoxLocked = t, this.mesh.getBoundingInfo().isLocked = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "computeParticleRotation", { get: function() {
        return this._computeParticleRotation;
      }, set: function(t) {
        this._computeParticleRotation = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "computeParticleColor", { get: function() {
        return this._computeParticleColor;
      }, set: function(t) {
        this._computeParticleColor = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "computeParticleTexture", { get: function() {
        return this._computeParticleTexture;
      }, set: function(t) {
        this._computeParticleTexture = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "computeParticleVertex", { get: function() {
        return this._computeParticleVertex;
      }, set: function(t) {
        this._computeParticleVertex = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "computeBoundingBox", { get: function() {
        return this._computeBoundingBox;
      }, set: function(t) {
        this._computeBoundingBox = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "depthSortParticles", { get: function() {
        return this._depthSortParticles;
      }, set: function(t) {
        this._depthSortParticles = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "expandable", { get: function() {
        return this._expandable;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "multimaterialEnabled", { get: function() {
        return this._multimaterialEnabled;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "useModelMaterial", { get: function() {
        return this._useModelMaterial;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "materials", { get: function() {
        return this._materials;
      }, enumerable: !1, configurable: !0 }), n.prototype.setMultiMaterial = function(t) {
        this._materials = this._filterUniqueMaterialId(t), this._setMaterialIndexesById(), this._multimaterial && this._multimaterial.dispose(), this._multimaterial = new Ao(this.name + "MultiMaterial", this._scene);
        for (var e = 0; e < this._materials.length; e++)
          this._multimaterial.subMaterials.push(this._materials[e]);
        this.computeSubMeshes(), this.mesh.material = this._multimaterial;
      }, Object.defineProperty(n.prototype, "multimaterial", { get: function() {
        return this._multimaterial;
      }, set: function(t) {
        this._multimaterial = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "autoUpdateSubMeshes", { get: function() {
        return this._autoUpdateSubMeshes;
      }, set: function(t) {
        this._autoUpdateSubMeshes = t;
      }, enumerable: !1, configurable: !0 }), n.prototype.initParticles = function() {
      }, n.prototype.recycleParticle = function(t) {
        return t;
      }, n.prototype.updateParticle = function(t) {
        return t;
      }, n.prototype.updateParticleVertex = function(t, e, i) {
        return this;
      }, n.prototype.beforeUpdateParticles = function(t, e, i) {
      }, n.prototype.afterUpdateParticles = function(t, e, i) {
      }, n;
    }(), q0 = function() {
      function n(t, e, i, r, o) {
        this.idx = 0, this.color = new Ie(1, 1, 1, 1), this.position = v.Zero(), this.rotation = v.Zero(), this.uv = new fe(0, 0), this.velocity = v.Zero(), this.pivot = v.Zero(), this.translateFromPivot = !1, this._pos = 0, this._ind = 0, this.groupId = 0, this.idxInGroup = 0, this._stillInvisible = !1, this._rotationMatrix = [1, 0, 0, 0, 1, 0, 0, 0, 1], this.parentId = null, this._globalPosition = v.Zero(), this.idx = t, this._group = e, this.groupId = i, this.idxInGroup = r, this._pcs = o;
      }
      return Object.defineProperty(n.prototype, "size", { get: function() {
        return this.size;
      }, set: function(t) {
        this.size = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "quaternion", { get: function() {
        return this.rotationQuaternion;
      }, set: function(t) {
        this.rotationQuaternion = t;
      }, enumerable: !1, configurable: !0 }), n.prototype.intersectsMesh = function(t, e) {
        if (!t.hasBoundingInfo)
          return !1;
        if (!this._pcs.mesh)
          throw new Error("Point Cloud System doesnt contain the Mesh");
        if (e)
          return t.getBoundingInfo().boundingSphere.intersectsPoint(this.position.add(this._pcs.mesh.position));
        var i = t.getBoundingInfo().boundingBox, r = i.maximumWorld.x, o = i.minimumWorld.x, a = i.maximumWorld.y, s = i.minimumWorld.y, l = i.maximumWorld.z, c = i.minimumWorld.z, u = this.position.x + this._pcs.mesh.position.x, h = this.position.y + this._pcs.mesh.position.y, d = this.position.z + this._pcs.mesh.position.z;
        return o <= u && u <= r && s <= h && h <= a && c <= d && d <= l;
      }, n.prototype.getRotationMatrix = function(t) {
        var e;
        if (this.rotationQuaternion)
          e = this.rotationQuaternion;
        else {
          e = F.Quaternion[0];
          var i = this.rotation;
          oe.RotationYawPitchRollToRef(i.y, i.x, i.z, e);
        }
        e.toRotationMatrix(t);
      }, n;
    }(), dd = function() {
      function n(t, e) {
        this.groupId = t, this._positionFunction = e;
      }
      return Object.defineProperty(n.prototype, "groupID", { get: function() {
        return this.groupId;
      }, set: function(t) {
        this.groupId = t;
      }, enumerable: !1, configurable: !0 }), n;
    }();
    (function(n) {
      n[n.Color = 2] = "Color", n[n.UV = 1] = "UV", n[n.Random = 0] = "Random", n[n.Stated = 3] = "Stated";
    })(zn || (zn = {}));
    var FP = function() {
      function n(t, e, i, r) {
        this.particles = new Array(), this.nbParticles = 0, this.counter = 0, this.vars = {}, this._promises = [], this._positions = new Array(), this._indices = new Array(), this._normals = new Array(), this._colors = new Array(), this._uvs = new Array(), this._updatable = !0, this._isVisibilityBoxLocked = !1, this._alwaysVisible = !1, this._groups = new Array(), this._groupCounter = 0, this._computeParticleColor = !0, this._computeParticleTexture = !0, this._computeParticleRotation = !0, this._computeBoundingBox = !1, this._isReady = !1, this.name = t, this._size = e, this._scene = i || Me.LastCreatedScene, r && r.updatable !== void 0 ? this._updatable = r.updatable : this._updatable = !0;
      }
      return Object.defineProperty(n.prototype, "positions", { get: function() {
        return this._positions32;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "colors", { get: function() {
        return this._colors32;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "uvs", { get: function() {
        return this._uvs32;
      }, enumerable: !1, configurable: !0 }), n.prototype.buildMeshAsync = function(t) {
        var e = this;
        return Promise.all(this._promises).then(function() {
          return e._isReady = !0, e._buildMesh(t);
        });
      }, n.prototype._buildMesh = function(t) {
        this.nbParticles === 0 && this.addPoints(1), this._positions32 = new Float32Array(this._positions), this._uvs32 = new Float32Array(this._uvs), this._colors32 = new Float32Array(this._colors);
        var e = new Oe();
        e.set(this._positions32, P.PositionKind), this._uvs32.length > 0 && e.set(this._uvs32, P.UVKind);
        var i = 0;
        this._colors32.length > 0 && (i = 1, e.set(this._colors32, P.ColorKind));
        var r = new ie(this.name, this._scene);
        e.applyToMesh(r, this._updatable), this.mesh = r, this._positions = null, this._uvs = null, this._colors = null, this._updatable || (this.particles.length = 0);
        var o = t;
        return o || ((o = new Gt("point cloud material", this._scene)).emissiveColor = new ne(i, i, i), o.disableLighting = !0, o.pointsCloud = !0, o.pointSize = this._size), r.material = o, new Promise(function(a) {
          return a(r);
        });
      }, n.prototype._addParticle = function(t, e, i, r) {
        var o = new q0(t, e, i, r, this);
        return this.particles.push(o), o;
      }, n.prototype._randomUnitVector = function(t) {
        t.position = new v(Math.random(), Math.random(), Math.random()), t.color = new Ie(1, 1, 1, 1);
      }, n.prototype._getColorIndicesForCoord = function(t, e, i, r) {
        var o = t._groupImageData, a = i * (4 * r) + 4 * e, s = [a, a + 1, a + 2, a + 3], l = s[1], c = s[2], u = s[3], h = o[s[0]], d = o[l], p = o[c], f = o[u];
        return new Ie(h / 255, d / 255, p / 255, f);
      }, n.prototype._setPointsColorOrUV = function(t, e, i, r, o, a, s, l) {
        l = l ?? 0, i && t.updateFacetData();
        var c = 2 * t.getBoundingInfo().boundingSphere.radius, u = t.getVerticesData(P.PositionKind), h = t.getIndices(), d = t.getVerticesData(P.UVKind + (l ? l + 1 : "")), p = t.getVerticesData(P.ColorKind), f = v.Zero();
        t.computeWorldMatrix();
        var m = t.getWorldMatrix();
        if (!m.isIdentity()) {
          u = u.slice(0);
          for (var g = 0; g < u.length / 3; g++)
            v.TransformCoordinatesFromFloatsToRef(u[3 * g], u[3 * g + 1], u[3 * g + 2], m, f), u[3 * g] = f.x, u[3 * g + 1] = f.y, u[3 * g + 2] = f.z;
        }
        var y, b, T = 0, S = 0, E = 0, A = 0, R = 0, C = 0, L = 0, I = 0, O = 0, w = 0, z = 0, V = 0, Y = 0, ee = v.Zero(), J = v.Zero(), X = v.Zero(), K = v.Zero(), te = v.Zero(), se = 0, _e = 0, xe = 0, Te = 0, he = 0, me = 0, Fe = fe.Zero(), Ce = fe.Zero(), Re = fe.Zero(), Be = fe.Zero(), De = fe.Zero(), Ke = 0, ge = 0, rt = 0, it = 0, He = 0, Pt = 0, ke = 0, xt = 0, Nt = 0, $e = 0, Rt = 0, kt = 0, _t = lt.Zero(), Pi = lt.Zero(), Hn = lt.Zero(), Xr = lt.Zero(), fo = lt.Zero(), Ln = 0, ni = 0;
        s = s || 0;
        for (var ci, qt = new lt(0, 0, 0, 0), jr = v.Zero(), Zn = v.Zero(), In = v.Zero(), yr = 0, ns = v.Zero(), Bs = 0, Us = 0, _o = new gi(v.Zero(), new v(1, 0, 0)), mo = v.Zero(), cr = 0; cr < h.length / 3; cr++) {
          S = h[3 * cr], E = h[3 * cr + 1], A = h[3 * cr + 2], R = u[3 * S], C = u[3 * S + 1], L = u[3 * S + 2], I = u[3 * E], O = u[3 * E + 1], w = u[3 * E + 2], z = u[3 * A], V = u[3 * A + 1], Y = u[3 * A + 2], ee.set(R, C, L), J.set(I, O, w), X.set(z, V, Y), J.subtractToRef(ee, K), X.subtractToRef(J, te), d && (se = d[2 * S], _e = d[2 * S + 1], xe = d[2 * E], Te = d[2 * E + 1], he = d[2 * A], me = d[2 * A + 1], Fe.set(se, _e), Ce.set(xe, Te), Re.set(he, me), Ce.subtractToRef(Fe, Be), Re.subtractToRef(Ce, De)), p && r && (Ke = p[4 * S], ge = p[4 * S + 1], rt = p[4 * S + 2], it = p[4 * S + 3], He = p[4 * E], Pt = p[4 * E + 1], ke = p[4 * E + 2], xt = p[4 * E + 3], Nt = p[4 * A], $e = p[4 * A + 1], Rt = p[4 * A + 2], kt = p[4 * A + 3], _t.set(Ke, ge, rt, it), Pi.set(He, Pt, ke, xt), Hn.set(Nt, $e, Rt, kt), Pi.subtractToRef(_t, Xr), Hn.subtractToRef(Pi, fo));
          for (var Xo = void 0, go = void 0, Pa = void 0, Ia = void 0, Ma = void 0, Mn = void 0, Yr = void 0, wn = void 0, jo = new ne(0, 0, 0), Yo = new ne(0, 0, 0), vo = void 0, Bn = void 0, Vs = 0; Vs < e._groupDensity[cr]; Vs++)
            T = this.particles.length, this._addParticle(T, e, this._groupCounter, cr + Vs), Bn = this.particles[T], Ln = ue.RandomRange(0, 1), ni = ue.RandomRange(0, 1), y = ee.add(K.scale(Ln)).add(te.scale(Ln * ni)), i && (jr = t.getFacetNormal(cr).normalize().scale(-1), Zn = K.clone().normalize(), In = v.Cross(jr, Zn), yr = ue.RandomRange(0, 2 * Math.PI), ns = Zn.scale(Math.cos(yr)).add(In.scale(Math.sin(yr))), yr = ue.RandomRange(0.1, Math.PI / 2), mo = ns.scale(Math.cos(yr)).add(jr.scale(Math.sin(yr))), _o.origin = y.add(mo.scale(1e-5)), _o.direction = mo, _o.length = c, (ci = _o.intersectsMesh(t)).hit && (Us = ci.pickedPoint.subtract(y).length(), Bs = ue.RandomRange(0, 1) * Us, y.addInPlace(mo.scale(Bs)))), Bn.position = y.clone(), this._positions.push(Bn.position.x, Bn.position.y, Bn.position.z), r !== void 0 ? d && (b = Fe.add(Be.scale(Ln)).add(De.scale(Ln * ni)), r ? o && e._groupImageData !== null ? (Xo = e._groupImgWidth, go = e._groupImgHeight, vo = this._getColorIndicesForCoord(e, Math.round(b.x * Xo), Math.round(b.y * go), Xo), Bn.color = vo, this._colors.push(vo.r, vo.g, vo.b, vo.a)) : p ? (qt = _t.add(Xr.scale(Ln)).add(fo.scale(Ln * ni)), Bn.color = new Ie(qt.x, qt.y, qt.z, qt.w), this._colors.push(qt.x, qt.y, qt.z, qt.w)) : (qt = _t.set(Math.random(), Math.random(), Math.random(), 1), Bn.color = new Ie(qt.x, qt.y, qt.z, qt.w), this._colors.push(qt.x, qt.y, qt.z, qt.w)) : (Bn.uv = b.clone(), this._uvs.push(Bn.uv.x, Bn.uv.y))) : (a ? (jo.set(a.r, a.g, a.b), Pa = ue.RandomRange(-s, s), Ia = ue.RandomRange(-s, s), Ma = (wn = jo.toHSV()).r, (Mn = wn.g + Pa) < 0 && (Mn = 0), Mn > 1 && (Mn = 1), (Yr = wn.b + Ia) < 0 && (Yr = 0), Yr > 1 && (Yr = 1), ne.HSVtoRGBToRef(Ma, Mn, Yr, Yo), qt.set(Yo.r, Yo.g, Yo.b, 1)) : qt = _t.set(Math.random(), Math.random(), Math.random(), 1), Bn.color = new Ie(qt.x, qt.y, qt.z, qt.w), this._colors.push(qt.x, qt.y, qt.z, qt.w));
        }
      }, n.prototype._colorFromTexture = function(t, e, i) {
        var r = this;
        if (t.material === null)
          return q.Warn(t.name + "has no material."), e._groupImageData = null, void this._setPointsColorOrUV(t, e, i, !0, !1);
        var o = t.material.getActiveTextures();
        if (o.length === 0)
          return q.Warn(t.name + "has no usable texture."), e._groupImageData = null, void this._setPointsColorOrUV(t, e, i, !0, !1);
        var a = t.clone();
        a.setEnabled(!1), this._promises.push(new Promise(function(s) {
          Vn.WhenAllReady(o, function() {
            var l = e._textureNb;
            l < 0 && (l = 0), l > o.length - 1 && (l = o.length - 1);
            var c = function() {
              e._groupImgWidth = o[l].getSize().width, e._groupImgHeight = o[l].getSize().height, r._setPointsColorOrUV(a, e, i, !0, !0, void 0, void 0, o[l].coordinatesIndex), a.dispose(), s();
            };
            e._groupImageData = null;
            var u = o[l].readPixels();
            u ? u.then(function(h) {
              e._groupImageData = h, c();
            }) : c();
          });
        }));
      }, n.prototype._calculateDensity = function(t, e, i) {
        for (var r, o, a, s, l, c, u, h, d, p, f, m, g, y, b, T, S, E = new Array(), A = v.Zero(), R = v.Zero(), C = v.Zero(), L = v.Zero(), I = v.Zero(), O = v.Zero(), w = new Array(), z = 0, V = i.length / 3, Y = 0; Y < V; Y++)
          r = i[3 * Y], o = i[3 * Y + 1], a = i[3 * Y + 2], s = e[3 * r], l = e[3 * r + 1], c = e[3 * r + 2], u = e[3 * o], h = e[3 * o + 1], d = e[3 * o + 2], p = e[3 * a], f = e[3 * a + 1], m = e[3 * a + 2], A.set(s, l, c), R.set(u, h, d), C.set(p, f, m), R.subtractToRef(A, L), C.subtractToRef(R, I), C.subtractToRef(A, O), T = ((g = L.length()) + (y = I.length()) + (b = O.length())) / 2, z += S = Math.sqrt(T * (T - g) * (T - y) * (T - b)), w[Y] = S;
        var ee = 0;
        for (Y = 0; Y < V; Y++)
          E[Y] = Math.floor(t * w[Y] / z), ee += E[Y];
        var J = t - ee, X = Math.floor(J / V), K = J % V;
        for (X > 0 && (E = E.map(function(te) {
          return te + X;
        })), Y = 0; Y < K; Y++)
          E[Y] += 1;
        return E;
      }, n.prototype.addPoints = function(t, e) {
        e === void 0 && (e = this._randomUnitVector);
        for (var i, r = new dd(this._groupCounter, e), o = this.nbParticles, a = 0; a < t; a++)
          i = this._addParticle(o, r, this._groupCounter, a), r && r._positionFunction && r._positionFunction(i, o, a), this._positions.push(i.position.x, i.position.y, i.position.z), i.color && this._colors.push(i.color.r, i.color.g, i.color.b, i.color.a), i.uv && this._uvs.push(i.uv.x, i.uv.y), o++;
        return this.nbParticles += t, this._groupCounter++, this._groupCounter;
      }, n.prototype.addSurfacePoints = function(t, e, i, r, o) {
        var a = i || zn.Random;
        (isNaN(a) || a < 0 || a > 3) && (a = zn.Random);
        var s = t.getVerticesData(P.PositionKind), l = t.getIndices();
        this._groups.push(this._groupCounter);
        var c = new dd(this._groupCounter, null);
        switch (c._groupDensity = this._calculateDensity(e, s, l), a === zn.Color ? c._textureNb = r || 0 : r = r || new Ie(1, 1, 1, 1), a) {
          case zn.Color:
            this._colorFromTexture(t, c, !1);
            break;
          case zn.UV:
            this._setPointsColorOrUV(t, c, !1, !1, !1);
            break;
          case zn.Random:
            this._setPointsColorOrUV(t, c, !1);
            break;
          case zn.Stated:
            this._setPointsColorOrUV(t, c, !1, void 0, void 0, r, o);
        }
        return this.nbParticles += e, this._groupCounter++, this._groupCounter - 1;
      }, n.prototype.addVolumePoints = function(t, e, i, r, o) {
        var a = i || zn.Random;
        (isNaN(a) || a < 0 || a > 3) && (a = zn.Random);
        var s = t.getVerticesData(P.PositionKind), l = t.getIndices();
        this._groups.push(this._groupCounter);
        var c = new dd(this._groupCounter, null);
        switch (c._groupDensity = this._calculateDensity(e, s, l), a === zn.Color ? c._textureNb = r || 0 : r = r || new Ie(1, 1, 1, 1), a) {
          case zn.Color:
            this._colorFromTexture(t, c, !0);
            break;
          case zn.UV:
            this._setPointsColorOrUV(t, c, !0, !1, !1);
            break;
          case zn.Random:
            this._setPointsColorOrUV(t, c, !0);
            break;
          case zn.Stated:
            this._setPointsColorOrUV(t, c, !0, void 0, void 0, r, o);
        }
        return this.nbParticles += e, this._groupCounter++, this._groupCounter - 1;
      }, n.prototype.setParticles = function(t, e, i) {
        var r, o;
        if (t === void 0 && (t = 0), e === void 0 && (e = this.nbParticles - 1), i === void 0 && (i = !0), !this._updatable || !this._isReady)
          return this;
        this.beforeUpdateParticles(t, e, i);
        var a = F.Matrix[0], s = this.mesh, l = this._colors32, c = this._positions32, u = this._uvs32, h = F.Vector3, d = h[5].copyFromFloats(1, 0, 0), p = h[6].copyFromFloats(0, 1, 0), f = h[7].copyFromFloats(0, 0, 1), m = h[8].setAll(Number.MAX_VALUE), g = h[9].setAll(-Number.MAX_VALUE);
        B.IdentityToRef(a);
        var y = 0;
        if (!((r = this.mesh) === null || r === void 0) && r.isFacetDataEnabled && (this._computeBoundingBox = !0), e = e >= this.nbParticles ? this.nbParticles - 1 : e, this._computeBoundingBox && (t != 0 || e != this.nbParticles - 1)) {
          var b = (o = this.mesh) === null || o === void 0 ? void 0 : o.getBoundingInfo();
          b && (m.copyFrom(b.minimum), g.copyFrom(b.maximum));
        }
        y = 0;
        for (var T = 0, S = 0, E = 0, A = t; A <= e; A++) {
          var R = this.particles[A];
          T = 3 * (y = R.idx), S = 4 * y, E = 2 * y, this.updateParticle(R);
          var C = R._rotationMatrix, L = R.position, I = R._globalPosition;
          if (this._computeParticleRotation && R.getRotationMatrix(a), R.parentId !== null) {
            var O = this.particles[R.parentId], w = O._rotationMatrix, z = O._globalPosition, V = L.x * w[1] + L.y * w[4] + L.z * w[7], Y = L.x * w[0] + L.y * w[3] + L.z * w[6], ee = L.x * w[2] + L.y * w[5] + L.z * w[8];
            if (I.x = z.x + Y, I.y = z.y + V, I.z = z.z + ee, this._computeParticleRotation) {
              var J = a.m;
              C[0] = J[0] * w[0] + J[1] * w[3] + J[2] * w[6], C[1] = J[0] * w[1] + J[1] * w[4] + J[2] * w[7], C[2] = J[0] * w[2] + J[1] * w[5] + J[2] * w[8], C[3] = J[4] * w[0] + J[5] * w[3] + J[6] * w[6], C[4] = J[4] * w[1] + J[5] * w[4] + J[6] * w[7], C[5] = J[4] * w[2] + J[5] * w[5] + J[6] * w[8], C[6] = J[8] * w[0] + J[9] * w[3] + J[10] * w[6], C[7] = J[8] * w[1] + J[9] * w[4] + J[10] * w[7], C[8] = J[8] * w[2] + J[9] * w[5] + J[10] * w[8];
            }
          } else
            I.x = 0, I.y = 0, I.z = 0, this._computeParticleRotation && (J = a.m, C[0] = J[0], C[1] = J[1], C[2] = J[2], C[3] = J[4], C[4] = J[5], C[5] = J[6], C[6] = J[8], C[7] = J[9], C[8] = J[10]);
          var X = h[11];
          R.translateFromPivot ? X.setAll(0) : X.copyFrom(R.pivot);
          var K = h[0];
          K.copyFrom(R.position);
          var te = K.x - R.pivot.x, se = K.y - R.pivot.y, _e = K.z - R.pivot.z, xe = te * C[0] + se * C[3] + _e * C[6], Te = te * C[1] + se * C[4] + _e * C[7], he = te * C[2] + se * C[5] + _e * C[8];
          xe += X.x, Te += X.y, he += X.z;
          var me = c[T] = I.x + d.x * xe + p.x * Te + f.x * he, Fe = c[T + 1] = I.y + d.y * xe + p.y * Te + f.y * he, Ce = c[T + 2] = I.z + d.z * xe + p.z * Te + f.z * he;
          if (this._computeBoundingBox && (m.minimizeInPlaceFromFloats(me, Fe, Ce), g.maximizeInPlaceFromFloats(me, Fe, Ce)), this._computeParticleColor && R.color) {
            var Re = R.color, Be = this._colors32;
            Be[S] = Re.r, Be[S + 1] = Re.g, Be[S + 2] = Re.b, Be[S + 3] = Re.a;
          }
          if (this._computeParticleTexture && R.uv) {
            var De = R.uv, Ke = this._uvs32;
            Ke[E] = De.x, Ke[E + 1] = De.y;
          }
        }
        return s && (i && (this._computeParticleColor && s.updateVerticesData(P.ColorKind, l, !1, !1), this._computeParticleTexture && s.updateVerticesData(P.UVKind, u, !1, !1), s.updateVerticesData(P.PositionKind, c, !1, !1)), this._computeBoundingBox && (s.hasBoundingInfo ? s.getBoundingInfo().reConstruct(m, g, s._worldMatrix) : s.buildBoundingInfo(m, g, s._worldMatrix))), this.afterUpdateParticles(t, e, i), this;
      }, n.prototype.dispose = function() {
        var t;
        (t = this.mesh) === null || t === void 0 || t.dispose(), this.vars = null, this._positions = null, this._indices = null, this._normals = null, this._uvs = null, this._colors = null, this._indices32 = null, this._positions32 = null, this._uvs32 = null, this._colors32 = null;
      }, n.prototype.refreshVisibleSize = function() {
        var t;
        return this._isVisibilityBoxLocked || (t = this.mesh) === null || t === void 0 || t.refreshBoundingInfo(), this;
      }, n.prototype.setVisibilityBox = function(t) {
        if (this.mesh) {
          var e = t / 2;
          this.mesh.buildBoundingInfo(new v(-e, -e, -e), new v(e, e, e));
        }
      }, Object.defineProperty(n.prototype, "isAlwaysVisible", { get: function() {
        return this._alwaysVisible;
      }, set: function(t) {
        this.mesh && (this._alwaysVisible = t, this.mesh.alwaysSelectAsActiveMesh = t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "computeParticleRotation", { set: function(t) {
        this._computeParticleRotation = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "computeParticleColor", { get: function() {
        return this._computeParticleColor;
      }, set: function(t) {
        this._computeParticleColor = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "computeParticleTexture", { get: function() {
        return this._computeParticleTexture;
      }, set: function(t) {
        this._computeParticleTexture = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "computeBoundingBox", { get: function() {
        return this._computeBoundingBox;
      }, set: function(t) {
        this._computeBoundingBox = t;
      }, enumerable: !1, configurable: !0 }), n.prototype.initParticles = function() {
      }, n.prototype.recycleParticle = function(t) {
        return t;
      }, n.prototype.updateParticle = function(t) {
        return t;
      }, n.prototype.beforeUpdateParticles = function(t, e, i) {
      }, n.prototype.afterUpdateParticles = function(t, e, i) {
      }, n;
    }();
    Object.defineProperty(Dt.prototype, "physicsImpostor", { get: function() {
      return this._physicsImpostor;
    }, set: function(n) {
      var t = this;
      this._physicsImpostor !== n && (this._disposePhysicsObserver && this.onDisposeObservable.remove(this._disposePhysicsObserver), this._physicsImpostor = n, n && (this._disposePhysicsObserver = this.onDisposeObservable.add(function() {
        t.physicsImpostor && (t.physicsImpostor.dispose(), t.physicsImpostor = null);
      })));
    }, enumerable: !0, configurable: !0 }), Dt.prototype.getPhysicsImpostor = function() {
      return this.physicsImpostor;
    }, Dt.prototype.applyImpulse = function(n, t) {
      return this.physicsImpostor ? (this.physicsImpostor.applyImpulse(n, t), this) : this;
    }, Dt.prototype.setPhysicsLinkWith = function(n, t, e, i) {
      return this.physicsImpostor && n.physicsImpostor ? (this.physicsImpostor.createJoint(n.physicsImpostor, Ii.HingeJoint, { mainPivot: t, connectedPivot: e, nativeParams: i }), this) : this;
    };
    var ko, co, Wn, Bi, es, Wr, Hr, Q0 = function() {
      function n(t, e) {
        e === void 0 && (e = n.DefaultPluginFactory()), this._physicsPlugin = e, this._physicsBodies = [], this._subTimeStep = 0, t = t || new v(0, -9.807, 0), this.setGravity(t), this.setTimeStep();
      }
      return n.prototype.getPluginVersion = function() {
        return this._physicsPlugin.getPluginVersion();
      }, n.DefaultPluginFactory = function() {
        throw et("");
      }, n.prototype.setGravity = function(t) {
        this.gravity = t, this._physicsPlugin.setGravity(this.gravity);
      }, n.prototype.setTimeStep = function(t) {
        t === void 0 && (t = 1 / 60), this._physicsPlugin.setTimeStep(t);
      }, n.prototype.getTimeStep = function() {
        return this._physicsPlugin.getTimeStep();
      }, n.prototype.setSubTimeStep = function(t) {
        t === void 0 && (t = 0), this._subTimeStep = t;
      }, n.prototype.getSubTimeStep = function() {
        return this._subTimeStep;
      }, n.prototype.dispose = function() {
        this._physicsPlugin.dispose();
      }, n.prototype.getPhysicsPluginName = function() {
        return this._physicsPlugin.name;
      }, n.prototype._step = function(t) {
        t > 0.1 ? t = 0.1 : t <= 0 && (t = 1 / 60), this._physicsPlugin.executeStep(t, this._physicsBodies);
      }, n.prototype.addBody = function(t) {
        this._physicsBodies.push(t);
      }, n.prototype.removeBody = function(t) {
        var e = this._physicsBodies.indexOf(t);
        e > -1 && this._physicsBodies.splice(e, 1);
      }, n.prototype.getBodies = function() {
        return this._physicsBodies;
      }, n.prototype.getPhysicsPlugin = function() {
        return this._physicsPlugin;
      }, n.prototype.raycastToRef = function(t, e, i, r) {
        this._physicsPlugin.raycast(t, e, i, r);
      }, n.prototype.raycast = function(t, e, i) {
        var r = new nu();
        return this._physicsPlugin.raycast(t, e, r, i), r;
      }, n;
    }(), Z0 = function() {
      function n(t, e, i, r) {
        var o = this;
        if (this._pluginData = void 0, this._pluginDataInstances = [], this._collisionCBEnabled = !1, this._collisionEndedCBEnabled = !1, this.disablePreStep = !0, this._isDisposed = !1, r) {
          var a = r.getPhysicsEngine();
          if (!a)
            throw new Error("No Physics Engine available.");
          if (this._physicsEngine = a, a.getPluginVersion() != 2)
            throw new Error("Plugin version is incorrect. Expected version 2.");
          var s = a.getPhysicsPlugin();
          if (!s)
            throw new Error("No Physics Plugin available.");
          this._physicsPlugin = s, t.rotationQuaternion || (t.rotationQuaternion = oe.FromEulerAngles(t.rotation.x, t.rotation.y, t.rotation.z)), this.startAsleep = i;
          var l = t;
          l.hasThinInstances ? this._physicsPlugin.initBodyInstances(this, e, l) : (t.parent && t.computeWorldMatrix(!0), this._physicsPlugin.initBody(this, e, t.absolutePosition, t.absoluteRotationQuaternion)), this.transformNode = t, t.physicsBody = this, a.addBody(this), this._nodeDisposeObserver = t.onDisposeObservable.add(function() {
            o.dispose();
          });
        }
      }
      return n.prototype.getClassName = function() {
        return "PhysicsBody";
      }, n.prototype.clone = function(t) {
        var e = new n(t, this.getMotionType(), this.startAsleep, this.transformNode.getScene());
        return e.shape = this.shape, e.setMassProperties(this.getMassProperties()), e.setLinearDamping(this.getLinearDamping()), e.setAngularDamping(this.getAngularDamping()), e;
      }, n.prototype.updateBodyInstances = function() {
        var t = this.transformNode;
        t.hasThinInstances && this._physicsPlugin.updateBodyInstances(this, t);
      }, Object.defineProperty(n.prototype, "numInstances", { get: function() {
        return this._pluginDataInstances.length;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "shape", { get: function() {
        return this._physicsPlugin.getShape(this);
      }, set: function(t) {
        this._physicsPlugin.setShape(this, t);
      }, enumerable: !1, configurable: !0 }), n.prototype.setEventMask = function(t, e) {
        this._physicsPlugin.setEventMask(this, t, e);
      }, n.prototype.getEventMask = function(t) {
        return this._physicsPlugin.getEventMask(this, t);
      }, n.prototype.setMotionType = function(t, e) {
        this._physicsPlugin.setMotionType(this, t, e);
      }, n.prototype.getMotionType = function(t) {
        return this._physicsPlugin.getMotionType(this, t);
      }, n.prototype.computeMassProperties = function(t) {
        return this._physicsPlugin.computeMassProperties(this, t);
      }, n.prototype.setMassProperties = function(t, e) {
        this._physicsPlugin.setMassProperties(this, t, e);
      }, n.prototype.getMassProperties = function(t) {
        return this._physicsPlugin.getMassProperties(this, t);
      }, n.prototype.setLinearDamping = function(t, e) {
        this._physicsPlugin.setLinearDamping(this, t, e);
      }, n.prototype.getLinearDamping = function(t) {
        return this._physicsPlugin.getLinearDamping(this, t);
      }, n.prototype.setAngularDamping = function(t, e) {
        this._physicsPlugin.setAngularDamping(this, t, e);
      }, n.prototype.getAngularDamping = function(t) {
        return this._physicsPlugin.getAngularDamping(this, t);
      }, n.prototype.setLinearVelocity = function(t, e) {
        this._physicsPlugin.setLinearVelocity(this, t, e);
      }, n.prototype.getLinearVelocityToRef = function(t, e) {
        return this._physicsPlugin.getLinearVelocityToRef(this, t, e);
      }, n.prototype.getLinearVelocity = function(t) {
        var e = new v();
        return this.getLinearVelocityToRef(e, t), e;
      }, n.prototype.setAngularVelocity = function(t, e) {
        this._physicsPlugin.setAngularVelocity(this, t, e);
      }, n.prototype.getAngularVelocityToRef = function(t, e) {
        return this._physicsPlugin.getAngularVelocityToRef(this, t, e);
      }, n.prototype.getAngularVelocity = function(t) {
        var e = new v();
        return this.getAngularVelocityToRef(e, t), e;
      }, n.prototype.applyImpulse = function(t, e, i) {
        this._physicsPlugin.applyImpulse(this, t, e, i);
      }, n.prototype.applyForce = function(t, e, i) {
        this._physicsPlugin.applyForce(this, t, e, i);
      }, n.prototype.getGeometry = function() {
        return this._physicsPlugin.getBodyGeometry(this);
      }, n.prototype.getCollisionObservable = function() {
        return this._physicsPlugin.getCollisionObservable(this);
      }, n.prototype.getCollisionEndedObservable = function() {
        return this._physicsPlugin.getCollisionEndedObservable(this);
      }, n.prototype.setCollisionCallbackEnabled = function(t) {
        this._collisionCBEnabled = t, this._physicsPlugin.setCollisionCallbackEnabled(this, t);
      }, n.prototype.setCollisionEndedCallbackEnabled = function(t) {
        this._collisionEndedCBEnabled = t, this._physicsPlugin.setCollisionEndedCallbackEnabled(this, t);
      }, n.prototype.getObjectCenterWorld = function(t) {
        var e = new v();
        return this.getObjectCenterWorldToRef(e, t);
      }, n.prototype.getObjectCenterWorldToRef = function(t, e) {
        var i;
        if (((i = this._pluginDataInstances) === null || i === void 0 ? void 0 : i.length) > 0) {
          var r = e || 0, o = this.transformNode._thinInstanceDataStorage.matrixData;
          o && t.set(o[16 * r + 12], o[16 * r + 13], o[16 * r + 14]);
        } else
          t.copyFrom(this.transformNode.position);
        return t;
      }, n.prototype.addConstraint = function(t, e, i, r) {
        this._physicsPlugin.addConstraint(this, t, e, i, r);
      }, n.prototype.syncWithBone = function(t, e, i, r, o, a) {
        var s = this.transformNode;
        if (s.rotationQuaternion)
          if (o) {
            var l = F.Quaternion[0];
            t.getRotationQuaternionToRef(ht.WORLD, e, l), l.multiplyToRef(o, s.rotationQuaternion);
          } else
            t.getRotationQuaternionToRef(ht.WORLD, e, s.rotationQuaternion);
        var c = F.Vector3[0], u = F.Vector3[1];
        a || ((a = F.Vector3[2]).x = 0, a.y = 1, a.z = 0), t.getDirectionToRef(a, e, u), t.getAbsolutePositionToRef(e, c), r == null && i && (r = i.length()), r != null && (c.x += u.x * r, c.y += u.y * r, c.z += u.z * r), s.setAbsolutePosition(c);
      }, n.prototype.iterateOverAllInstances = function(t) {
        var e;
        if (((e = this._pluginDataInstances) === null || e === void 0 ? void 0 : e.length) > 0)
          for (var i = 0; i < this._pluginDataInstances.length; i++)
            t(this, i);
        else
          t(this, void 0);
      }, n.prototype.setGravityFactor = function(t, e) {
        this._physicsPlugin.setGravityFactor(this, t, e);
      }, n.prototype.getGravityFactor = function(t) {
        return this._physicsPlugin.getGravityFactor(this, t);
      }, n.prototype.setTargetTransform = function(t, e, i) {
        this._physicsPlugin.setTargetTransform(this, t, e, i);
      }, n.prototype.dispose = function() {
        this._isDisposed || (this._collisionCBEnabled && this.setCollisionCallbackEnabled(!1), this._collisionEndedCBEnabled && this.setCollisionEndedCallbackEnabled(!1), this._nodeDisposeObserver && (this.transformNode.onDisposeObservable.remove(this._nodeDisposeObserver), this._nodeDisposeObserver = null), this._physicsEngine.removeBody(this), this._physicsPlugin.removeBody(this), this._physicsPlugin.disposeBody(this), this.transformNode.physicsBody = null, this._pluginData = null, this._pluginDataInstances.length = 0, this._isDisposed = !0);
      }, n;
    }();
    (function(n) {
      n[n.FREE = 0] = "FREE", n[n.LIMITED = 1] = "LIMITED", n[n.LOCKED = 2] = "LOCKED";
    })(ko || (ko = {})), function(n) {
      n[n.LINEAR_X = 0] = "LINEAR_X", n[n.LINEAR_Y = 1] = "LINEAR_Y", n[n.LINEAR_Z = 2] = "LINEAR_Z", n[n.ANGULAR_X = 3] = "ANGULAR_X", n[n.ANGULAR_Y = 4] = "ANGULAR_Y", n[n.ANGULAR_Z = 5] = "ANGULAR_Z", n[n.LINEAR_DISTANCE = 6] = "LINEAR_DISTANCE";
    }(co || (co = {})), function(n) {
      n[n.BALL_AND_SOCKET = 1] = "BALL_AND_SOCKET", n[n.DISTANCE = 2] = "DISTANCE", n[n.HINGE = 3] = "HINGE", n[n.SLIDER = 4] = "SLIDER", n[n.LOCK = 5] = "LOCK", n[n.PRISMATIC = 6] = "PRISMATIC", n[n.SIX_DOF = 7] = "SIX_DOF";
    }(Wn || (Wn = {})), function(n) {
      n[n.SPHERE = 0] = "SPHERE", n[n.CAPSULE = 1] = "CAPSULE", n[n.CYLINDER = 2] = "CYLINDER", n[n.BOX = 3] = "BOX", n[n.CONVEX_HULL = 4] = "CONVEX_HULL", n[n.CONTAINER = 5] = "CONTAINER", n[n.MESH = 6] = "MESH", n[n.HEIGHTFIELD = 7] = "HEIGHTFIELD";
    }(Bi || (Bi = {})), function(n) {
      n[n.NONE = 0] = "NONE", n[n.VELOCITY = 1] = "VELOCITY", n[n.POSITION = 2] = "POSITION";
    }(es || (es = {})), function(n) {
      n.COLLISION_STARTED = "COLLISION_STARTED", n.COLLISION_CONTINUED = "COLLISION_CONTINUED", n.COLLISION_FINISHED = "COLLISION_FINISHED", n.TRIGGER_ENTERED = "TRIGGER_ENTERED", n.TRIGGER_EXITED = "TRIGGER_EXITED";
    }(Wr || (Wr = {})), function(n) {
      n[n.STATIC = 0] = "STATIC", n[n.ANIMATED = 1] = "ANIMATED", n[n.DYNAMIC = 2] = "DYNAMIC";
    }(Hr || (Hr = {}));
    var Go, zo = function() {
      function n(t, e) {
        var i;
        if (this._pluginData = void 0, this._isTrigger = !1, this._isDisposed = !1, e) {
          var r = e.getPhysicsEngine();
          if (!r)
            throw new Error("No Physics Engine available.");
          if (r.getPluginVersion() != 2)
            throw new Error("Plugin version is incorrect. Expected version 2.");
          var o = r.getPhysicsPlugin();
          if (!o)
            throw new Error("No Physics Plugin available.");
          if (this._physicsPlugin = o, t.pluginData !== void 0 && t.pluginData !== null)
            this._pluginData = t.pluginData, this._type = this._physicsPlugin.getShapeType(this);
          else if (t.type !== void 0 && t.type !== null) {
            this._type = t.type;
            var a = (i = t.parameters) !== null && i !== void 0 ? i : {};
            this._physicsPlugin.initShape(this, t.type, a);
          }
        }
      }
      return n.prototype.getClassName = function() {
        return "PhysicsShape";
      }, Object.defineProperty(n.prototype, "type", { get: function() {
        return this._type;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "filterMembershipMask", { get: function() {
        return this._physicsPlugin.getShapeFilterMembershipMask(this);
      }, set: function(t) {
        this._physicsPlugin.setShapeFilterMembershipMask(this, t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "filterCollideMask", { get: function() {
        return this._physicsPlugin.getShapeFilterCollideMask(this);
      }, set: function(t) {
        this._physicsPlugin.setShapeFilterCollideMask(this, t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "material", { get: function() {
        return this._material;
      }, set: function(t) {
        this._physicsPlugin.setMaterial(this, t), this._material = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "density", { get: function() {
        return this._physicsPlugin.getDensity(this);
      }, set: function(t) {
        this._physicsPlugin.setDensity(this, t);
      }, enumerable: !1, configurable: !0 }), n.prototype.addChildFromParent = function(t, e, i) {
        var r = i.computeWorldMatrix(!0), o = t.computeWorldMatrix(!0), a = F.Matrix[0];
        r.multiplyToRef(B.Invert(o), a);
        var s = F.Vector3[0], l = F.Quaternion[0], c = F.Vector3[1];
        a.decompose(c, l, s), this._physicsPlugin.addChild(this, e, s, l, c);
      }, n.prototype.addChild = function(t, e, i, r) {
        this._physicsPlugin.addChild(this, t, e, i, r);
      }, n.prototype.removeChild = function(t) {
        this._physicsPlugin.removeChild(this, t);
      }, n.prototype.getNumChildren = function() {
        return this._physicsPlugin.getNumChildren(this);
      }, n.prototype.getBoundingBox = function() {
        return this._physicsPlugin.getBoundingBox(this);
      }, Object.defineProperty(n.prototype, "isTrigger", { get: function() {
        return this._isTrigger;
      }, set: function(t) {
        this._isTrigger !== t && (this._isTrigger = t, this._physicsPlugin.setTrigger(this, t));
      }, enumerable: !1, configurable: !0 }), n.prototype.dispose = function() {
        this._isDisposed || (this._physicsPlugin.disposeShape(this), this._isDisposed = !0);
      }, n;
    }(), LP = function(n) {
      function t(e, i, r) {
        return n.call(this, { type: Bi.SPHERE, parameters: { center: e, radius: i } }, r) || this;
      }
      return D(t, n), t.FromMesh = function(e) {
        var i = e.getBoundingInfo(), r = i.boundingSphere.center, o = i.boundingBox.extendSize;
        return new t(r, Math.max(o.x, o.y, o.z), e.getScene());
      }, t;
    }(zo), wP = function(n) {
      function t(e, i, r, o) {
        return n.call(this, { type: Bi.CAPSULE, parameters: { pointA: e, pointB: i, radius: r } }, o) || this;
      }
      return D(t, n), t.FromMesh = function(e) {
        var i = e.getBoundingInfo(), r = i.boundingBox.extendSize.x, o = new v(0, i.boundingBox.extendSize.y - r, 0);
        return new t(i.boundingBox.center.add(o), i.boundingBox.center.subtract(o), r, e.getScene());
      }, t;
    }(zo), BP = function(n) {
      function t(e, i, r, o) {
        return n.call(this, { type: Bi.CYLINDER, parameters: { pointA: e, pointB: i, radius: r } }, o) || this;
      }
      return D(t, n), t.FromMesh = function(e) {
        var i = e.getBoundingInfo(), r = i.boundingBox.extendSize.x, o = new v(0, i.boundingBox.extendSize.y, 0);
        return new t(i.boundingBox.center.add(o), i.boundingBox.center.subtract(o), r, e.getScene());
      }, t;
    }(zo), UP = function(n) {
      function t(e, i, r, o) {
        return n.call(this, { type: Bi.BOX, parameters: { center: e, rotation: i, extents: r } }, o) || this;
      }
      return D(t, n), t.FromMesh = function(e) {
        var i = e.getBoundingInfo(), r = i.boundingBox.center, o = i.boundingBox.extendSize.scale(2);
        return new t(r, oe.Identity(), o, e.getScene());
      }, t;
    }(zo), VP = function(n) {
      function t(e, i) {
        return n.call(this, { type: Bi.CONVEX_HULL, parameters: { mesh: e } }, i) || this;
      }
      return D(t, n), t;
    }(zo), kP = function(n) {
      function t(e, i) {
        return n.call(this, { type: Bi.MESH, parameters: { mesh: e } }, i) || this;
      }
      return D(t, n), t;
    }(zo), GP = function(n) {
      function t(e) {
        return n.call(this, { type: Bi.CONTAINER, parameters: {} }, e) || this;
      }
      return D(t, n), t;
    }(zo), ts = function() {
      function n(t, e, i) {
        if (this._pluginData = void 0, !i)
          throw new Error("Missing scene parameter for constraint constructor.");
        var r = i.getPhysicsEngine();
        if (!r)
          throw new Error("No Physics Engine available.");
        if (r.getPluginVersion() != 2)
          throw new Error("Plugin version is incorrect. Expected version 2.");
        var o = r.getPhysicsPlugin();
        if (!o)
          throw new Error("No Physics Plugin available.");
        this._physicsPlugin = o, this._options = e, this._type = t;
      }
      return Object.defineProperty(n.prototype, "type", { get: function() {
        return this._type;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "options", { get: function() {
        return this._options;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isEnabled", { get: function() {
        return this._physicsPlugin.getEnabled(this);
      }, set: function(t) {
        this._physicsPlugin.setEnabled(this, t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isCollisionsEnabled", { get: function() {
        return this._physicsPlugin.getCollisionsEnabled(this);
      }, set: function(t) {
        this._physicsPlugin.setCollisionsEnabled(this, t);
      }, enumerable: !1, configurable: !0 }), n.prototype.getBodiesUsingConstraint = function() {
        return this._physicsPlugin.getBodiesUsingConstraint(this);
      }, n.prototype.dispose = function() {
        this._physicsPlugin.disposeConstraint(this);
      }, n;
    }(), zP = function() {
    }, J0 = function(n) {
      function t(e, i, r) {
        var o = n.call(this, Wn.SIX_DOF, e, r) || this;
        return o.limits = i, o;
      }
      return D(t, n), t.prototype.setAxisFriction = function(e, i) {
        this._physicsPlugin.setAxisFriction(this, e, i);
      }, t.prototype.getAxisFriction = function(e) {
        return this._physicsPlugin.getAxisFriction(this, e);
      }, t.prototype.setAxisMode = function(e, i) {
        this._physicsPlugin.setAxisMode(this, e, i);
      }, t.prototype.getAxisMode = function(e) {
        return this._physicsPlugin.getAxisMode(this, e);
      }, t.prototype.setAxisMinLimit = function(e, i) {
        this._physicsPlugin.setAxisMinLimit(this, e, i);
      }, t.prototype.getAxisMinLimit = function(e) {
        return this._physicsPlugin.getAxisMinLimit(this, e);
      }, t.prototype.setAxisMaxLimit = function(e, i) {
        this._physicsPlugin.setAxisMaxLimit(this, e, i);
      }, t.prototype.getAxisMaxLimit = function(e) {
        return this._physicsPlugin.getAxisMaxLimit(this, e);
      }, t.prototype.setAxisMotorType = function(e, i) {
        this._physicsPlugin.setAxisMotorType(this, e, i);
      }, t.prototype.getAxisMotorType = function(e) {
        return this._physicsPlugin.getAxisMotorType(this, e);
      }, t.prototype.setAxisMotorTarget = function(e, i) {
        this._physicsPlugin.setAxisMotorTarget(this, e, i);
      }, t.prototype.getAxisMotorTarget = function(e) {
        return this._physicsPlugin.getAxisMotorTarget(this, e);
      }, t.prototype.setAxisMotorMaxForce = function(e, i) {
        this._physicsPlugin.setAxisMotorMaxForce(this, e, i);
      }, t.prototype.getAxisMotorMaxForce = function(e) {
        return this._physicsPlugin.getAxisMotorMaxForce(this, e);
      }, t;
    }(ts), WP = function(n) {
      function t(e, i, r, o, a) {
        return n.call(this, Wn.BALL_AND_SOCKET, { pivotA: e, pivotB: i, axisA: r, axisB: o }, a) || this;
      }
      return D(t, n), t;
    }(ts), HP = function(n) {
      function t(e, i) {
        return n.call(this, Wn.DISTANCE, { maxDistance: e }, i) || this;
      }
      return D(t, n), t;
    }(ts), XP = function(n) {
      function t(e, i, r, o, a) {
        return n.call(this, Wn.HINGE, { pivotA: e, pivotB: i, axisA: r, axisB: o }, a) || this;
      }
      return D(t, n), t;
    }(ts), jP = function(n) {
      function t(e, i, r, o, a) {
        return n.call(this, Wn.SLIDER, { pivotA: e, pivotB: i, axisA: r, axisB: o }, a) || this;
      }
      return D(t, n), t;
    }(ts), YP = function(n) {
      function t(e, i, r, o, a) {
        return n.call(this, Wn.LOCK, { pivotA: e, pivotB: i, axisA: r, axisB: o }, a) || this;
      }
      return D(t, n), t;
    }(ts), KP = function(n) {
      function t(e, i, r, o, a) {
        return n.call(this, Wn.PRISMATIC, { pivotA: e, pivotB: i, axisA: r, axisB: o }, a) || this;
      }
      return D(t, n), t;
    }(ts), qP = function(n) {
      function t(e, i, r, o, a, s, l, c, u) {
        return n.call(this, { pivotA: e, pivotB: i, axisA: r, axisB: o }, [{ axis: co.LINEAR_DISTANCE, minLimit: a, maxLimit: s, stiffness: l, damping: c }], u) || this;
      }
      return D(t, n), t;
    }(J0);
    (function(n) {
      n[n.GEOMETRIC_MEAN = 0] = "GEOMETRIC_MEAN", n[n.MINIMUM = 1] = "MINIMUM", n[n.MAXIMUM = 2] = "MAXIMUM", n[n.ARITHMETIC_MEAN = 3] = "ARITHMETIC_MEAN", n[n.MULTIPLY = 4] = "MULTIPLY";
    })(Go || (Go = {}));
    var QP = function() {
      function n(t, e, i, r) {
        i === void 0 && (i = { mass: 0 });
        var o, a = this;
        if (this.transformNode = t, this.type = e, this._options = i, this._scene = r, this._disposeShapeWhenDisposed = !0, this.transformNode) {
          var s = t;
          if (this.transformNode.parent && this._options.mass !== 0 && s.hasThinInstances && q.Warn("A physics body has been created for an object which has a parent and thin instances. Babylon physics currently works in local space so unexpected issues may occur."), !this._scene && t.getScene && (this._scene = t.getScene()), this._scene) {
            this._options.mass = i.mass === void 0 ? 0 : i.mass, this._options.friction = i.friction === void 0 ? 0.2 : i.friction, this._options.restitution = i.restitution === void 0 ? 0.2 : i.restitution;
            var l = this._options.mass === 0 ? Hr.STATIC : Hr.DYNAMIC, c = (o = this._options.startAsleep) !== null && o !== void 0 && o;
            this.body = new Z0(t, l, c, this._scene), this._addSizeOptions(), e.getClassName && e.getClassName() === "PhysicsShape" ? (this.shape = e, this._disposeShapeWhenDisposed = !1) : this.shape = new zo({ type: e, parameters: this._options }, this._scene), this._options.isTriggerShape && (this.shape.isTrigger = !0), this.material = { friction: this._options.friction, restitution: this._options.restitution }, this.body.shape = this.shape, this.shape.material = this.material, this.body.setMassProperties({ mass: this._options.mass }), this._nodeDisposeObserver = this.transformNode.onDisposeObservable.add(function() {
              a.dispose();
            });
          }
        } else
          q.Error("No object was provided. A physics object is obligatory");
      }
      return n.prototype._getObjectBoundingBox = function() {
        return this.transformNode.getRawBoundingInfo ? this.transformNode.getRawBoundingInfo().boundingBox : new cl(new v(-0.5, -0.5, -0.5), new v(0.5, 0.5, 0.5));
      }, n.prototype._hasVertices = function(t) {
        return (t == null ? void 0 : t.getTotalVertices()) > 0;
      }, n.prototype._addSizeOptions = function() {
        var t, e, i, r, o, a, s, l;
        this.transformNode.computeWorldMatrix(!0);
        var c = this._getObjectBoundingBox(), u = F.Vector3[0];
        u.copyFrom(c.extendSize), u.scaleInPlace(2), u.multiplyInPlace(this.transformNode.scaling), u.x = Math.abs(u.x), u.y = Math.abs(u.y), u.z = Math.abs(u.z);
        var h = F.Vector3[1];
        if (h.copyFrom(c.minimum), h.multiplyInPlace(this.transformNode.scaling), !this._options.center) {
          var d = new v();
          d.copyFrom(c.center), d.multiplyInPlace(this.transformNode.scaling), this._options.center = d;
        }
        switch (this.type) {
          case Bi.SPHERE:
            !this._options.radius && ue.WithinEpsilon(u.x, u.y, 1e-4) && ue.WithinEpsilon(u.x, u.z, 1e-4) ? this._options.radius = u.x / 2 : this._options.radius || (q.Warn("Non uniform scaling is unsupported for sphere shapes. Setting the radius to the biggest bounding box extent."), this._options.radius = Math.max(u.x, u.y, u.z) / 2);
            break;
          case Bi.CAPSULE:
            var p = u.x / 2;
            this._options.radius = (t = this._options.radius) !== null && t !== void 0 ? t : p, this._options.pointA = (e = this._options.pointA) !== null && e !== void 0 ? e : new v(0, h.y + p, 0), this._options.pointB = (i = this._options.pointB) !== null && i !== void 0 ? i : new v(0, h.y + u.y - p, 0);
            break;
          case Bi.CYLINDER:
            p = u.x / 2, this._options.radius = (r = this._options.radius) !== null && r !== void 0 ? r : p, this._options.pointA = (o = this._options.pointA) !== null && o !== void 0 ? o : new v(0, h.y, 0), this._options.pointB = (a = this._options.pointB) !== null && a !== void 0 ? a : new v(0, h.y + u.y, 0);
            break;
          case Bi.MESH:
          case Bi.CONVEX_HULL:
            if (!this._options.mesh && this._hasVertices(this.transformNode))
              this._options.mesh = this.transformNode;
            else if (!this._options.mesh || !this._hasVertices(this._options.mesh))
              throw new Error("No valid mesh was provided for mesh or convex hull shape parameter. Please provide a mesh with valid geometry (number of vertices greater than 0).");
            break;
          case Bi.BOX:
            this._options.extents = (s = this._options.extents) !== null && s !== void 0 ? s : new v(u.x, u.y, u.z), this._options.rotation = (l = this._options.rotation) !== null && l !== void 0 ? l : oe.Identity();
        }
      }, n.prototype.dispose = function() {
        this._nodeDisposeObserver && (this.body.transformNode.onDisposeObservable.remove(this._nodeDisposeObserver), this._nodeDisposeObserver = null), this.body.dispose(), this._disposeShapeWhenDisposed && this.shape.dispose();
      }, n;
    }(), mN = function() {
      function n(t, e, i) {
        this._vertices = [], this._indices = [], this._isRightHanded = i.useRightHandedSystem, this._collectIndices = e;
      }
      return n.prototype.addNodeMeshes = function(t, e) {
        var i = this;
        t.computeWorldMatrix(!0);
        var r = F.Matrix[0];
        if (B.ScalingToRef(t.absoluteScaling.x, t.absoluteScaling.y, t.absoluteScaling.z, r), t instanceof ie ? this._addMesh(t, r) : t instanceof dl && this._addMesh(t.sourceMesh, r), e) {
          var o = F.Matrix[1];
          t.computeWorldMatrix().invertToRef(o);
          var a = F.Matrix[2];
          o.multiplyToRef(r, a), t.getChildMeshes(!1).filter(function(s) {
            return !s.physicsBody;
          }).forEach(function(s) {
            var l = s.computeWorldMatrix(), c = F.Matrix[3];
            l.multiplyToRef(a, c), s instanceof ie ? i._addMesh(s, c) : s instanceof dl && i._addMesh(s.sourceMesh, c);
          });
        }
      }, n.prototype._addMesh = function(t, e) {
        for (var i = t.getVerticesData(P.PositionKind) || [], r = i.length / 3, o = this._vertices.length, a = 0; a < r; a++) {
          var s = new v(i[3 * a + 0], i[3 * a + 1], i[3 * a + 2]);
          this._vertices.push(v.TransformCoordinates(s, e));
        }
        if (this._collectIndices) {
          var l = t.getIndices();
          if (l)
            for (var c = 0; c < l.length; c += 3)
              this._isRightHanded ? (this._indices.push(l[c + 0] + o), this._indices.push(l[c + 1] + o), this._indices.push(l[c + 2] + o)) : (this._indices.push(l[c + 2] + o), this._indices.push(l[c + 1] + o), this._indices.push(l[c + 0] + o));
        }
      }, n.prototype.getVertices = function(t) {
        for (var e = 3 * this._vertices.length, i = 4 * e, r = t._malloc(i), o = new Float32Array(t.HEAPU8.buffer, r, e), a = 0; a < this._vertices.length; a++)
          o[3 * a + 0] = this._vertices[a].x, o[3 * a + 1] = this._vertices[a].y, o[3 * a + 2] = this._vertices[a].z;
        return { offset: r, numObjects: e };
      }, n.prototype.freeBuffer = function(t, e) {
        t._free(e.offset);
      }, n.prototype.getTriangles = function(t) {
        for (var e = 4 * this._indices.length, i = t._malloc(e), r = new Int32Array(t.HEAPU8.buffer, i, this._indices.length), o = 0; o < this._indices.length; o++)
          r[o] = this._indices[o];
        return { offset: i, numObjects: this._indices.length };
      }, n;
    }(), ZP = function(n) {
      this.hpBodyId = n, this.userMassProps = { centerOfMass: void 0, mass: void 0, inertia: void 0, inertiaOrientation: void 0 };
    }, JP = function() {
      this.bodyId = BigInt(0), this.position = new v(), this.normal = new v();
    }, $P = function() {
      function n() {
        this.contactOnA = new JP(), this.contactOnB = new JP(), this.impulseApplied = 0, this.type = 0;
      }
      return n.readToRef = function(t, e, i) {
        var r = new Int32Array(t, e), o = new Float32Array(t, e);
        i.contactOnA.bodyId = BigInt(r[2]), i.contactOnA.position.set(o[10], o[11], o[12]), i.contactOnA.normal.set(o[13], o[14], o[15]), i.contactOnB.bodyId = BigInt(r[18]), i.contactOnB.position.set(o[26], o[27], o[28]), i.contactOnB.normal.set(o[29], o[30], o[31]), i.impulseApplied = o[34], i.type = r[0];
      }, n;
    }(), eI = function() {
      function n() {
        this.bodyIdA = BigInt(0), this.bodyIdB = BigInt(0), this.type = 0;
      }
      return n.readToRef = function(t, e, i) {
        var r = new Int32Array(t, e);
        i.type = r[0], i.bodyIdA = BigInt(r[2]), i.bodyIdB = BigInt(r[6]);
      }, n;
    }(), tI = function() {
      function n(t, e) {
        t === void 0 && (t = !0), e === void 0 && (e = HK), this._useDeltaForWorldStep = t, this._hknp = {}, this.name = "HavokPlugin", this._fixedTimeStep = 1 / 60, this._timeStep = 1 / 60, this._tmpVec3 = pt.BuildArray(3, v.Zero), this._bodies = /* @__PURE__ */ new Map(), this._bodyCollisionObservable = /* @__PURE__ */ new Map(), this._constraintToBodyIdPair = /* @__PURE__ */ new Map(), this._bodyCollisionEndedObservable = /* @__PURE__ */ new Map(), this.onCollisionObservable = new H(), this.onCollisionEndedObservable = new H(), this.onTriggerCollisionObservable = new H(), typeof e != "function" ? (this._hknp = e, this.isSupported() ? (this.world = this._hknp.HP_World_Create()[1], this._queryCollector = this._hknp.HP_QueryCollector_Create(1)[1]) : q.Error("Havok is not available. Please make sure you included the js file.")) : q.Error("Havok is not ready. Please make sure you await HK() before using the plugin.");
      }
      return n.prototype.isSupported = function() {
        return this._hknp !== void 0;
      }, n.prototype.setGravity = function(t) {
        this._hknp.HP_World_SetGravity(this.world, this._bVecToV3(t));
      }, n.prototype.setTimeStep = function(t) {
        this._fixedTimeStep = t;
      }, n.prototype.getTimeStep = function() {
        return this._fixedTimeStep;
      }, n.prototype.executeStep = function(t, e) {
        for (var i = 0, r = e; i < r.length; i++)
          (s = r[i]).disablePreStep || this.setPhysicsBodyTransformation(s, s.transformNode);
        this._hknp.HP_World_Step(this.world, this._useDeltaForWorldStep ? t : this._timeStep), this._bodyBuffer = this._hknp.HP_World_GetBodyBuffer(this.world)[1];
        for (var o = 0, a = e; o < a.length; o++) {
          var s = a[o];
          this.sync(s);
        }
        this._notifyCollisions(), this._notifyTriggers();
      }, n.prototype.getPluginVersion = function() {
        return 2;
      }, n.prototype.initBody = function(t, e, i, r) {
        t._pluginData = new ZP(this._hknp.HP_Body_Create()[1]), this._internalSetMotionType(t._pluginData, e);
        var o = [this._bVecToV3(i), this._bQuatToV4(r)];
        this._hknp.HP_Body_SetQTransform(t._pluginData.hpBodyId, o), this._hknp.HP_World_AddBody(this.world, t._pluginData.hpBodyId, t.startAsleep), this._bodies.set(t._pluginData.hpBodyId[0], { body: t, index: 0 });
      }, n.prototype.removeBody = function(t) {
        if (t._pluginDataInstances && t._pluginDataInstances.length > 0)
          for (var e = 0, i = t._pluginDataInstances; e < i.length; e++) {
            var r = i[e];
            this._bodyCollisionObservable.delete(r.hpBodyId[0]), this._hknp.HP_World_RemoveBody(this.world, r.hpBodyId), this._bodies.delete(r.hpBodyId[0]);
          }
        t._pluginData && (this._bodyCollisionObservable.delete(t._pluginData.hpBodyId[0]), this._hknp.HP_World_RemoveBody(this.world, t._pluginData.hpBodyId), this._bodies.delete(t._pluginData.hpBodyId[0]));
      }, n.prototype.initBodyInstances = function(t, e, i) {
        var r, o, a = this, s = (o = (r = i._thinInstanceDataStorage) === null || r === void 0 ? void 0 : r.instancesCount) !== null && o !== void 0 ? o : 0, l = i._thinInstanceDataStorage.matrixData;
        l && (this._createOrUpdateBodyInstances(t, e, l, 0, s, !1), t._pluginDataInstances.forEach(function(c, u) {
          a._bodies.set(c.hpBodyId[0], { body: t, index: u });
        }));
      }, n.prototype._createOrUpdateBodyInstances = function(t, e, i, r, o, a) {
        for (var s = F.Quaternion[0], l = B.Identity(), c = r; c < o; c++) {
          var u, h = [i[16 * c + 12], i[16 * c + 13], i[16 * c + 14]];
          u = a ? t._pluginDataInstances[c].hpBodyId : this._hknp.HP_Body_Create()[1], l.setRowFromFloats(0, i[16 * c + 0], i[16 * c + 1], i[16 * c + 2], 0), l.setRowFromFloats(1, i[16 * c + 4], i[16 * c + 5], i[16 * c + 6], 0), l.setRowFromFloats(2, i[16 * c + 8], i[16 * c + 9], i[16 * c + 10], 0), oe.FromRotationMatrixToRef(l, s);
          var d = [h, [s.x, s.y, s.z, s.w]];
          if (this._hknp.HP_Body_SetQTransform(u, d), !a) {
            var p = new ZP(u);
            t._pluginDataInstances.length && (p.userMassProps = t._pluginDataInstances[0].userMassProps), this._internalSetMotionType(p, e), this._internalUpdateMassProperties(p), t._pluginDataInstances.push(p), this._hknp.HP_World_AddBody(this.world, u, t.startAsleep), p.worldTransformOffset = this._hknp.HP_Body_GetWorldTransformOffset(u)[1];
          }
        }
      }, n.prototype.updateBodyInstances = function(t, e) {
        var i, r, o = (r = (i = e._thinInstanceDataStorage) === null || i === void 0 ? void 0 : i.instancesCount) !== null && r !== void 0 ? r : 0, a = e._thinInstanceDataStorage.matrixData;
        if (a) {
          var s = t._pluginDataInstances.length, l = this.getMotionType(t);
          if (o > s) {
            this._createOrUpdateBodyInstances(t, l, a, s, o, !1);
            for (var c = this._hknp.HP_Body_GetShape(t._pluginDataInstances[0].hpBodyId)[1], u = s; u < o; u++)
              this._hknp.HP_Body_SetShape(t._pluginDataInstances[u].hpBodyId, c), this._internalUpdateMassProperties(t._pluginDataInstances[u]), this._bodies.set(t._pluginDataInstances[u].hpBodyId[0], { body: t, index: u });
          } else if (o < s) {
            var h = s - o;
            for (u = 0; u < h; u++) {
              var d = t._pluginDataInstances.pop();
              this._bodies.delete(d.hpBodyId[0]), this._hknp.HP_World_RemoveBody(this.world, d.hpBodyId), this._hknp.HP_Body_Release(d.hpBodyId);
            }
            this._createOrUpdateBodyInstances(t, l, a, 0, o, !0);
          }
        }
      }, n.prototype.sync = function(t) {
        this.syncTransform(t, t.transformNode);
      }, n.prototype.syncTransform = function(t, e) {
        var i;
        if (t._pluginDataInstances.length) {
          var r = e, o = r._thinInstanceDataStorage.matrixData;
          if (!o)
            return;
          for (var a = t._pluginDataInstances.length, s = 0; s < a; s++) {
            for (var l = t._pluginDataInstances[s].worldTransformOffset, c = new Float32Array(this._hknp.HEAPU8.buffer, this._bodyBuffer + l, 16), u = 16 * s, h = 0; h < 15; h++)
              (3 & h) != 3 && (o[u + h] = c[h]);
            o[u + 15] = 1;
          }
          r.thinInstanceBufferUpdated("matrix");
        } else
          try {
            var d = this._hknp.HP_Body_GetQTransform(t._pluginData.hpBodyId)[1], p = d[0], f = d[1], m = F.Quaternion[0];
            m.set(f[0], f[1], f[2], f[3]);
            var g = e.parent;
            if (g && !g.getWorldMatrix().isIdentity()) {
              g.computeWorldMatrix(!0), m.normalize();
              var y = F.Matrix[0], b = F.Vector3[0];
              b.copyFromFloats(p[0], p[1], p[2]), B.ComposeToRef(e.absoluteScaling, m, b, y);
              var T = F.Matrix[1];
              g.getWorldMatrix().invertToRef(T);
              var S = F.Matrix[2];
              y.multiplyToRef(T, S), S.decomposeToTransformNode(e), (i = e.rotationQuaternion) === null || i === void 0 || i.normalize();
            } else
              e.position.set(p[0], p[1], p[2]), e.rotationQuaternion ? e.rotationQuaternion.copyFrom(m) : m.toEulerAnglesToRef(e.rotation);
          } catch (E) {
            console.log("Syncing transform failed for node ".concat(e.name, ": ").concat(E.message, "..."));
          }
      }, n.prototype.setShape = function(t, e) {
        var i, r, o, a = e && e._pluginData ? e._pluginData : BigInt(0);
        if (!(t.transformNode instanceof ie && (!((i = t.transformNode._thinInstanceDataStorage) === null || i === void 0) && i.matrixData)))
          return this._hknp.HP_Body_SetShape(t._pluginData.hpBodyId, a), void this._internalUpdateMassProperties(t._pluginData);
        for (var s = (o = (r = t.transformNode._thinInstanceDataStorage) === null || r === void 0 ? void 0 : r.instancesCount) !== null && o !== void 0 ? o : 0, l = 0; l < s; l++)
          this._hknp.HP_Body_SetShape(t._pluginDataInstances[l].hpBodyId, a), this._internalUpdateMassProperties(t._pluginDataInstances[l]);
      }, n.prototype._getPluginReference = function(t, e) {
        var i;
        return !((i = t._pluginDataInstances) === null || i === void 0) && i.length ? t._pluginDataInstances[e ?? 0] : t._pluginData;
      }, n.prototype.getShape = function(t) {
        var e = this._getPluginReference(t), i = this._hknp.HP_Body_GetShape(e.hpBodyId)[1];
        if (i != 0) {
          var r = t.transformNode.getScene();
          return new zo({ pluginData: i }, r);
        }
        return null;
      }, n.prototype.getShapeType = function(t) {
        return t.type ? t.type : this._hknp.HP_Shape_GetType(t._pluginData);
      }, n.prototype.setEventMask = function(t, e, i) {
        var r = this;
        this._applyToBodyOrInstances(t, function(o) {
          r._hknp.HP_Body_SetEventMask(o.hpBodyId, e);
        }, i);
      }, n.prototype.getEventMask = function(t, e) {
        var i = this._getPluginReference(t, e);
        return this._hknp.HP_Body_GetEventMask(i.hpBodyId)[1];
      }, n.prototype._fromMassPropertiesTuple = function(t) {
        return { centerOfMass: v.FromArray(t[0]), mass: t[1], inertia: v.FromArray(t[2]), inertiaOrientation: oe.FromArray(t[3]) };
      }, n.prototype._internalUpdateMassProperties = function(t) {
        var e = this._internalComputeMassProperties(t), i = t.userMassProps;
        i.centerOfMass && (e[0] = i.centerOfMass.asArray()), i.mass != null && (e[1] = i.mass), i.inertia && (e[2] = i.inertia.asArray()), i.inertiaOrientation && (e[3] = i.inertiaOrientation.asArray()), this._hknp.HP_Body_SetMassProperties(t.hpBodyId, e);
      }, n.prototype._internalSetMotionType = function(t, e) {
        switch (e) {
          case Hr.STATIC:
            this._hknp.HP_Body_SetMotionType(t.hpBodyId, this._hknp.MotionType.STATIC);
            break;
          case Hr.ANIMATED:
            this._hknp.HP_Body_SetMotionType(t.hpBodyId, this._hknp.MotionType.KINEMATIC);
            break;
          case Hr.DYNAMIC:
            this._hknp.HP_Body_SetMotionType(t.hpBodyId, this._hknp.MotionType.DYNAMIC);
        }
      }, n.prototype.setMotionType = function(t, e, i) {
        var r = this;
        this._applyToBodyOrInstances(t, function(o) {
          r._internalSetMotionType(o, e);
        }, i);
      }, n.prototype.getMotionType = function(t, e) {
        var i = this._getPluginReference(t, e), r = this._hknp.HP_Body_GetMotionType(i.hpBodyId)[1];
        switch (r) {
          case this._hknp.MotionType.STATIC:
            return Hr.STATIC;
          case this._hknp.MotionType.KINEMATIC:
            return Hr.ANIMATED;
          case this._hknp.MotionType.DYNAMIC:
            return Hr.DYNAMIC;
        }
        throw new Error("Unknown motion type: " + r);
      }, n.prototype._internalComputeMassProperties = function(t) {
        var e = this._hknp.HP_Body_GetShape(t.hpBodyId);
        if (e[0] == this._hknp.Result.RESULT_OK) {
          var i = this._hknp.HP_Shape_BuildMassProperties(e[1]);
          if (i[0] == this._hknp.Result.RESULT_OK)
            return i[1];
        }
        return [[0, 0, 0], 1, [1, 1, 1], [0, 0, 0, 1]];
      }, n.prototype.computeMassProperties = function(t, e) {
        var i = this._getPluginReference(t, e), r = this._internalComputeMassProperties(i);
        return this._fromMassPropertiesTuple(r);
      }, n.prototype.setMassProperties = function(t, e, i) {
        var r = this;
        this._applyToBodyOrInstances(t, function(o) {
          o.userMassProps = e, r._internalUpdateMassProperties(o);
        }, i);
      }, n.prototype.getMassProperties = function(t, e) {
        var i = this._getPluginReference(t, e), r = this._hknp.HP_Body_GetMassProperties(i.hpBodyId)[1];
        return this._fromMassPropertiesTuple(r);
      }, n.prototype.setLinearDamping = function(t, e, i) {
        var r = this;
        this._applyToBodyOrInstances(t, function(o) {
          r._hknp.HP_Body_SetLinearDamping(o.hpBodyId, e);
        }, i);
      }, n.prototype.getLinearDamping = function(t, e) {
        var i = this._getPluginReference(t, e);
        return this._hknp.HP_Body_GetLinearDamping(i.hpBodyId)[1];
      }, n.prototype.setAngularDamping = function(t, e, i) {
        var r = this;
        this._applyToBodyOrInstances(t, function(o) {
          r._hknp.HP_Body_SetAngularDamping(o.hpBodyId, e);
        }, i);
      }, n.prototype.getAngularDamping = function(t, e) {
        var i = this._getPluginReference(t, e);
        return this._hknp.HP_Body_GetAngularDamping(i.hpBodyId)[1];
      }, n.prototype.setLinearVelocity = function(t, e, i) {
        var r = this;
        this._applyToBodyOrInstances(t, function(o) {
          r._hknp.HP_Body_SetLinearVelocity(o.hpBodyId, r._bVecToV3(e));
        }, i);
      }, n.prototype.getLinearVelocityToRef = function(t, e, i) {
        var r = this._getPluginReference(t, i), o = this._hknp.HP_Body_GetLinearVelocity(r.hpBodyId)[1];
        this._v3ToBvecRef(o, e);
      }, n.prototype._applyToBodyOrInstances = function(t, e, i) {
        var r;
        if (((r = t._pluginDataInstances) === null || r === void 0 ? void 0 : r.length) > 0 && i === void 0)
          for (var o = 0; o < t._pluginDataInstances.length; o++)
            e(t._pluginDataInstances[o]);
        else
          e(this._getPluginReference(t, i));
      }, n.prototype.applyImpulse = function(t, e, i, r) {
        var o = this;
        this._applyToBodyOrInstances(t, function(a) {
          o._hknp.HP_Body_ApplyImpulse(a.hpBodyId, o._bVecToV3(i), o._bVecToV3(e));
        }, r);
      }, n.prototype.applyForce = function(t, e, i, r) {
        e.scaleToRef(this.getTimeStep(), this._tmpVec3[0]), this.applyImpulse(t, this._tmpVec3[0], i, r);
      }, n.prototype.setAngularVelocity = function(t, e, i) {
        var r = this;
        this._applyToBodyOrInstances(t, function(o) {
          r._hknp.HP_Body_SetAngularVelocity(o.hpBodyId, r._bVecToV3(e));
        }, i);
      }, n.prototype.getAngularVelocityToRef = function(t, e, i) {
        var r = this._getPluginReference(t, i), o = this._hknp.HP_Body_GetAngularVelocity(r.hpBodyId)[1];
        this._v3ToBvecRef(o, e);
      }, n.prototype.setPhysicsBodyTransformation = function(t, e) {
        var i = t.transformNode;
        if (t.numInstances > 0) {
          var r = i._thinInstanceDataStorage.matrixData;
          if (!r)
            return;
          var o = t.numInstances;
          this._createOrUpdateBodyInstances(t, t.getMotionType(), r, 0, o, !0);
        } else
          this._hknp.HP_Body_SetQTransform(t._pluginData.hpBodyId, this._getTransformInfos(e));
      }, n.prototype.setTargetTransform = function(t, e, i, r) {
        var o = this;
        this._applyToBodyOrInstances(t, function(a) {
          o._hknp.HP_Body_SetTargetQTransform(a.hpBodyId, [o._bVecToV3(e), o._bQuatToV4(i)]);
        }, r);
      }, n.prototype.setGravityFactor = function(t, e, i) {
        var r = this;
        this._applyToBodyOrInstances(t, function(o) {
          r._hknp.HP_Body_SetGravityFactor(o.hpBodyId, e);
        }, i);
      }, n.prototype.getGravityFactor = function(t, e) {
        var i = this._getPluginReference(t, e);
        return this._hknp.HP_Body_GetGravityFactor(i.hpBodyId)[1];
      }, n.prototype.disposeBody = function(t) {
        if (t._pluginDataInstances && t._pluginDataInstances.length > 0)
          for (var e = 0, i = t._pluginDataInstances; e < i.length; e++) {
            var r = i[e];
            this._hknp.HP_Body_Release(r.hpBodyId), r.hpBodyId = void 0;
          }
        t._pluginData && (this._hknp.HP_Body_Release(t._pluginData.hpBodyId), t._pluginData.hpBodyId = void 0);
      }, n.prototype.initShape = function(t, e, i) {
        switch (e) {
          case Bi.SPHERE:
            var r = i.radius || 1, o = i.center ? this._bVecToV3(i.center) : [0, 0, 0];
            t._pluginData = this._hknp.HP_Shape_CreateSphere(o, r)[1];
            break;
          case Bi.BOX:
            var a = i.rotation ? this._bQuatToV4(i.rotation) : [0, 0, 0, 1], s = i.extents ? this._bVecToV3(i.extents) : [1, 1, 1];
            o = i.center ? this._bVecToV3(i.center) : [0, 0, 0], t._pluginData = this._hknp.HP_Shape_CreateBox(o, a, s)[1];
            break;
          case Bi.CAPSULE:
            var l = i.pointA ? this._bVecToV3(i.pointA) : [0, 0, 0], c = i.pointB ? this._bVecToV3(i.pointB) : [0, 1, 0];
            r = i.radius || 0, t._pluginData = this._hknp.HP_Shape_CreateCapsule(l, c, r)[1];
            break;
          case Bi.CONTAINER:
            t._pluginData = this._hknp.HP_Shape_CreateContainer()[1];
            break;
          case Bi.CYLINDER:
            l = i.pointA ? this._bVecToV3(i.pointA) : [0, 0, 0], c = i.pointB ? this._bVecToV3(i.pointB) : [0, 1, 0], r = i.radius || 0, t._pluginData = this._hknp.HP_Shape_CreateCylinder(l, c, r)[1];
            break;
          case Bi.CONVEX_HULL:
          case Bi.MESH:
            var u = i.mesh;
            if (!u)
              throw new Error("No mesh provided to create physics shape.");
            var h = !!i.includeChildMeshes, d = e != Bi.CONVEX_HULL, p = new mN(u, d, u == null ? void 0 : u.getScene());
            p.addNodeMeshes(u, h);
            var f = p.getVertices(this._hknp), m = f.numObjects / 3;
            if (e == Bi.CONVEX_HULL)
              t._pluginData = this._hknp.HP_Shape_CreateConvexHull(f.offset, m)[1];
            else {
              var g = p.getTriangles(this._hknp), y = g.numObjects / 3;
              t._pluginData = this._hknp.HP_Shape_CreateMesh(f.offset, m, g.offset, y)[1], p.freeBuffer(this._hknp, g);
            }
            p.freeBuffer(this._hknp, f);
            break;
          default:
            throw new Error("Unsupported Shape Type.");
        }
      }, n.prototype.setShapeFilterMembershipMask = function(t, e) {
        var i = this._hknp.HP_Shape_GetFilterInfo(t._pluginData)[1][1];
        this._hknp.HP_Shape_SetFilterInfo(t._pluginData, [e, i]);
      }, n.prototype.getShapeFilterMembershipMask = function(t) {
        return this._hknp.HP_Shape_GetFilterInfo(t._pluginData)[1][0];
      }, n.prototype.setShapeFilterCollideMask = function(t, e) {
        var i = this._hknp.HP_Shape_GetFilterInfo(t._pluginData)[1][0];
        this._hknp.HP_Shape_SetFilterInfo(t._pluginData, [i, e]);
      }, n.prototype.getShapeFilterCollideMask = function(t) {
        return this._hknp.HP_Shape_GetFilterInfo(t._pluginData)[1][1];
      }, n.prototype.setMaterial = function(t, e) {
        var i, r, o, a, s, l = (i = e.friction) !== null && i !== void 0 ? i : 0.5, c = (r = e.staticFriction) !== null && r !== void 0 ? r : l, u = (o = e.restitution) !== null && o !== void 0 ? o : 0, h = (a = e.frictionCombine) !== null && a !== void 0 ? a : Go.MINIMUM, d = (s = e.restitutionCombine) !== null && s !== void 0 ? s : Go.MAXIMUM, p = [c, l, u, this._materialCombineToNative(h), this._materialCombineToNative(d)];
        this._hknp.HP_Shape_SetMaterial(t._pluginData, p);
      }, n.prototype.setDensity = function(t, e) {
        this._hknp.HP_Shape_SetDensity(t._pluginData, e);
      }, n.prototype.getDensity = function(t) {
        return this._hknp.HP_Shape_GetDensity(t._pluginData)[1];
      }, n.prototype._getTransformInfos = function(t) {
        if (t.parent)
          return t.computeWorldMatrix(!0), [this._bVecToV3(t.absolutePosition), this._bQuatToV4(t.absoluteRotationQuaternion)];
        var e = F.Quaternion[0];
        if (t.rotationQuaternion)
          e = t.rotationQuaternion;
        else {
          var i = t.rotation;
          oe.FromEulerAnglesToRef(i.x, i.y, i.z, e);
        }
        return [this._bVecToV3(t.position), this._bQuatToV4(e)];
      }, n.prototype.addChild = function(t, e, i, r, o) {
        var a = [i ? this._bVecToV3(i) : [0, 0, 0], r ? this._bQuatToV4(r) : [0, 0, 0, 1], o ? this._bVecToV3(o) : [1, 1, 1]];
        this._hknp.HP_Shape_AddChild(t._pluginData, e._pluginData, a);
      }, n.prototype.removeChild = function(t, e) {
        this._hknp.HP_Shape_RemoveChild(t._pluginData, e);
      }, n.prototype.getNumChildren = function(t) {
        return this._hknp.HP_Shape_GetNumChildren(t._pluginData)[1];
      }, n.prototype.setTrigger = function(t, e) {
        this._hknp.HP_Shape_SetTrigger(t._pluginData, e);
      }, n.prototype.getBoundingBox = function(t) {
        return {};
      }, n.prototype.getBodyGeometry = function(t) {
        var e, i = ((e = t._pluginDataInstances) === null || e === void 0 ? void 0 : e.length) > 0 ? t._pluginDataInstances[0] : t._pluginData, r = this._hknp.HP_Body_GetShape(i.hpBodyId)[1], o = this._hknp.HP_Shape_CreateDebugDisplayGeometry(r);
        if (o[0] != this._hknp.Result.RESULT_OK)
          return { positions: [], indices: [] };
        var a = this._hknp.HP_DebugGeometry_GetInfo(o[1])[1], s = new Float32Array(this._hknp.HEAPU8.buffer, a[0], 3 * a[1]), l = new Uint32Array(this._hknp.HEAPU8.buffer, a[2], 3 * a[3]), c = s.slice(0), u = l.slice(0);
        return this._hknp.HP_DebugGeometry_Release(o[1]), { positions: c, indices: u };
      }, n.prototype.disposeShape = function(t) {
        this._hknp.HP_Shape_Release(t._pluginData), t._pluginData = void 0;
      }, n.prototype.initConstraint = function(t, e, i, r, o) {
        var a, s, l, c, u, h = t.type, d = t.options;
        if (h && d)
          if (e._pluginDataInstances.length > 0 && r === void 0 || i._pluginDataInstances.length > 0 && o === void 0)
            q.Warn("Body is instanced but no instance index was specified. Constraint will not be applied.");
          else {
            t._pluginData = (a = t._pluginData) !== null && a !== void 0 ? a : [];
            var p = this._hknp.HP_Constraint_Create()[1];
            t._pluginData.push(p);
            var f = this._getPluginReference(e, r).hpBodyId, m = this._getPluginReference(i, o).hpBodyId;
            this._hknp.HP_Constraint_SetParentBody(p, f), this._hknp.HP_Constraint_SetChildBody(p, m), this._constraintToBodyIdPair.set(p[0], [f[0], m[0]]);
            var g = d.pivotA ? this._bVecToV3(d.pivotA) : this._bVecToV3(v.Zero()), y = (s = d.axisA) !== null && s !== void 0 ? s : new v(1, 0, 0), b = this._tmpVec3[0];
            d.perpAxisA ? b.copyFrom(d.perpAxisA) : y.getNormalToRef(b), this._hknp.HP_Constraint_SetAnchorInParent(p, g, this._bVecToV3(y), this._bVecToV3(b));
            var T = d.pivotB ? this._bVecToV3(d.pivotB) : this._bVecToV3(v.Zero()), S = (l = d.axisB) !== null && l !== void 0 ? l : new v(1, 0, 0), E = this._tmpVec3[0];
            if (d.perpAxisB ? E.copyFrom(d.perpAxisB) : S.getNormalToRef(E), this._hknp.HP_Constraint_SetAnchorInChild(p, T, this._bVecToV3(S), this._bVecToV3(E)), t._initOptions || (t._initOptions = { axisA: y.clone(), axisB: S.clone(), perpAxisA: b.clone(), perpAxisB: E.clone(), pivotA: new v(g[0], g[1], g[2]), pivotB: new v(T[0], T[1], T[2]) }), h == Wn.LOCK)
              this._hknp.HP_Constraint_SetAxisMode(p, this._hknp.ConstraintAxis.LINEAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(p, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(p, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(p, this._hknp.ConstraintAxis.ANGULAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(p, this._hknp.ConstraintAxis.ANGULAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(p, this._hknp.ConstraintAxis.ANGULAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);
            else if (h == Wn.DISTANCE) {
              var A = d.maxDistance || 0, R = this._hknp.ConstraintAxis.LINEAR_DISTANCE;
              this._hknp.HP_Constraint_SetAxisMode(p, R, this._hknp.ConstraintAxisLimitMode.LIMITED), this._hknp.HP_Constraint_SetAxisMinLimit(p, R, A), this._hknp.HP_Constraint_SetAxisMaxLimit(p, R, A);
            } else if (h == Wn.HINGE)
              this._hknp.HP_Constraint_SetAxisMode(p, this._hknp.ConstraintAxis.LINEAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(p, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(p, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(p, this._hknp.ConstraintAxis.ANGULAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(p, this._hknp.ConstraintAxis.ANGULAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);
            else if (h == Wn.PRISMATIC)
              this._hknp.HP_Constraint_SetAxisMode(p, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(p, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(p, this._hknp.ConstraintAxis.ANGULAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(p, this._hknp.ConstraintAxis.ANGULAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(p, this._hknp.ConstraintAxis.ANGULAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);
            else if (h == Wn.SLIDER)
              this._hknp.HP_Constraint_SetAxisMode(p, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(p, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(p, this._hknp.ConstraintAxis.ANGULAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(p, this._hknp.ConstraintAxis.ANGULAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);
            else if (h == Wn.BALL_AND_SOCKET)
              this._hknp.HP_Constraint_SetAxisMode(p, this._hknp.ConstraintAxis.LINEAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(p, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(p, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);
            else {
              if (h != Wn.SIX_DOF)
                throw new Error("Unsupported Constraint Type.");
              for (var C = 0, L = t.limits; C < L.length; C++) {
                var I = L[C], O = this._constraintAxisToNative(I.axis);
                ((c = I.minLimit) !== null && c !== void 0 ? c : -1) == 0 && ((u = I.maxLimit) !== null && u !== void 0 ? u : -1) == 0 ? this._hknp.HP_Constraint_SetAxisMode(p, O, this._hknp.ConstraintAxisLimitMode.LOCKED) : (I.minLimit != null && (this._hknp.HP_Constraint_SetAxisMode(p, O, this._hknp.ConstraintAxisLimitMode.LIMITED), this._hknp.HP_Constraint_SetAxisMinLimit(p, O, I.minLimit)), I.maxLimit != null && (this._hknp.HP_Constraint_SetAxisMode(p, O, this._hknp.ConstraintAxisLimitMode.LIMITED), this._hknp.HP_Constraint_SetAxisMaxLimit(p, O, I.maxLimit))), I.stiffness && this._hknp.HP_Constraint_SetAxisStiffness(p, O, I.stiffness), I.damping && this._hknp.HP_Constraint_SetAxisDamping(p, O, I.damping);
              }
            }
            var w = !!d.collision;
            this._hknp.HP_Constraint_SetCollisionsEnabled(p, w), this._hknp.HP_Constraint_SetEnabled(p, !0);
          }
        else
          q.Warn("No constraint type or options. Constraint is invalid.");
      }, n.prototype.getBodiesUsingConstraint = function(t) {
        for (var e = [], i = 0, r = t._pluginData; i < r.length; i++) {
          var o = r[i], a = this._constraintToBodyIdPair.get(o[0]);
          if (a) {
            var s = this._bodies.get(a[0]), l = this._bodies.get(a[1]);
            s && l && e.push({ parentBody: s.body, parentBodyIndex: s.index, childBody: l.body, childBodyIndex: l.index });
          }
        }
        return e;
      }, n.prototype.addConstraint = function(t, e, i, r, o) {
        this.initConstraint(i, t, e, r, o);
      }, n.prototype.setEnabled = function(t, e) {
        for (var i = 0, r = t._pluginData; i < r.length; i++) {
          var o = r[i];
          this._hknp.HP_Constraint_SetEnabled(o, e);
        }
      }, n.prototype.getEnabled = function(t) {
        var e = t._pluginData && t._pluginData[0];
        return !!e && this._hknp.HP_Constraint_GetEnabled(e)[1];
      }, n.prototype.setCollisionsEnabled = function(t, e) {
        for (var i = 0, r = t._pluginData; i < r.length; i++) {
          var o = r[i];
          this._hknp.HP_Constraint_SetCollisionsEnabled(o, e);
        }
      }, n.prototype.getCollisionsEnabled = function(t) {
        var e = t._pluginData && t._pluginData[0];
        return !!e && this._hknp.HP_Constraint_GetCollisionsEnabled(e)[1];
      }, n.prototype.setAxisFriction = function(t, e, i) {
        for (var r = 0, o = t._pluginData; r < o.length; r++) {
          var a = o[r];
          this._hknp.HP_Constraint_SetAxisFriction(a, this._constraintAxisToNative(e), i);
        }
      }, n.prototype.getAxisFriction = function(t, e) {
        var i = t._pluginData && t._pluginData[0];
        return i ? this._hknp.HP_Constraint_GetAxisFriction(i, this._constraintAxisToNative(e))[1] : null;
      }, n.prototype.setAxisMode = function(t, e, i) {
        for (var r = 0, o = t._pluginData; r < o.length; r++) {
          var a = o[r];
          this._hknp.HP_Constraint_SetAxisMode(a, this._constraintAxisToNative(e), this._limitModeToNative(i));
        }
      }, n.prototype.getAxisMode = function(t, e) {
        var i = t._pluginData && t._pluginData[0];
        if (i) {
          var r = this._hknp.HP_Constraint_GetAxisMode(i, this._constraintAxisToNative(e))[1];
          return this._nativeToLimitMode(r);
        }
        return null;
      }, n.prototype.setAxisMinLimit = function(t, e, i) {
        for (var r = 0, o = t._pluginData; r < o.length; r++) {
          var a = o[r];
          this._hknp.HP_Constraint_SetAxisMinLimit(a, this._constraintAxisToNative(e), i);
        }
      }, n.prototype.getAxisMinLimit = function(t, e) {
        var i = t._pluginData && t._pluginData[0];
        return i ? this._hknp.HP_Constraint_GetAxisMinLimit(i, this._constraintAxisToNative(e))[1] : null;
      }, n.prototype.setAxisMaxLimit = function(t, e, i) {
        for (var r = 0, o = t._pluginData; r < o.length; r++) {
          var a = o[r];
          this._hknp.HP_Constraint_SetAxisMaxLimit(a, this._constraintAxisToNative(e), i);
        }
      }, n.prototype.getAxisMaxLimit = function(t, e) {
        var i = t._pluginData && t._pluginData[0];
        return i ? this._hknp.HP_Constraint_GetAxisMaxLimit(i, this._constraintAxisToNative(e))[1] : null;
      }, n.prototype.setAxisMotorType = function(t, e, i) {
        for (var r = 0, o = t._pluginData; r < o.length; r++) {
          var a = o[r];
          this._hknp.HP_Constraint_SetAxisMotorType(a, this._constraintAxisToNative(e), this._constraintMotorTypeToNative(i));
        }
      }, n.prototype.getAxisMotorType = function(t, e) {
        var i = t._pluginData && t._pluginData[0];
        return i ? this._nativeToMotorType(this._hknp.HP_Constraint_GetAxisMotorType(i, this._constraintAxisToNative(e))[1]) : null;
      }, n.prototype.setAxisMotorTarget = function(t, e, i) {
        for (var r = 0, o = t._pluginData; r < o.length; r++) {
          var a = o[r];
          this._hknp.HP_Constraint_SetAxisMotorTarget(a, this._constraintAxisToNative(e), i);
        }
      }, n.prototype.getAxisMotorTarget = function(t, e) {
        return t._pluginData && t._pluginData[0] ? this._hknp.HP_Constraint_GetAxisMotorTarget(t._pluginData, this._constraintAxisToNative(e))[1] : null;
      }, n.prototype.setAxisMotorMaxForce = function(t, e, i) {
        for (var r = 0, o = t._pluginData; r < o.length; r++) {
          var a = o[r];
          this._hknp.HP_Constraint_SetAxisMotorMaxForce(a, this._constraintAxisToNative(e), i);
        }
      }, n.prototype.getAxisMotorMaxForce = function(t, e) {
        var i = t._pluginData && t._pluginData[0];
        return i ? this._hknp.HP_Constraint_GetAxisMotorMaxForce(i, this._constraintAxisToNative(e))[1] : null;
      }, n.prototype.disposeConstraint = function(t) {
        for (var e = 0, i = t._pluginData; e < i.length; e++) {
          var r = i[e];
          this._hknp.HP_Constraint_SetEnabled(r, !1), this._hknp.HP_Constraint_Release(r);
        }
        t._pluginData.length = 0;
      }, n.prototype.raycast = function(t, e, i, r) {
        var o, a, s = (o = r == null ? void 0 : r.membership) !== null && o !== void 0 ? o : -1, l = (a = r == null ? void 0 : r.collideWith) !== null && a !== void 0 ? a : -1;
        i.reset(t, e);
        var c = [BigInt(0)], u = [this._bVecToV3(t), this._bVecToV3(e), [s, l], !1, c];
        if (this._hknp.HP_World_CastRayWithCollector(this.world, this._queryCollector, u), this._hknp.HP_QueryCollector_GetNumHits(this._queryCollector)[1] > 0) {
          var h = this._hknp.HP_QueryCollector_GetCastRayResult(this._queryCollector, 0)[1], d = h[1][3], p = h[1][4], f = h[1][5];
          i.setHitData({ x: p[0], y: p[1], z: p[2] }, { x: d[0], y: d[1], z: d[2] }, f), i.calculateHitDistance();
          var m = this._bodies.get(h[1][0][0]);
          i.body = m == null ? void 0 : m.body, i.bodyIndex = m == null ? void 0 : m.index;
        }
      }, n.prototype.getCollisionObservable = function(t) {
        var e = t._pluginData.hpBodyId[0], i = this._bodyCollisionObservable.get(e);
        return i || (i = new H(), this._bodyCollisionObservable.set(e, i)), i;
      }, n.prototype.getCollisionEndedObservable = function(t) {
        var e = t._pluginData.hpBodyId[0], i = this._bodyCollisionEndedObservable.get(e);
        return i || (i = new H(), this._bodyCollisionEndedObservable.set(e, i)), i;
      }, n.prototype.setCollisionCallbackEnabled = function(t, e) {
        var i = this, r = this._hknp.EventType.COLLISION_STARTED.value | this._hknp.EventType.COLLISION_CONTINUED.value | this._hknp.EventType.COLLISION_FINISHED.value;
        t._pluginDataInstances && t._pluginDataInstances.length ? t._pluginDataInstances.forEach(function(o) {
          i._hknp.HP_Body_SetEventMask(o.hpBodyId, e ? r : 0);
        }) : t._pluginData && this._hknp.HP_Body_SetEventMask(t._pluginData.hpBodyId, e ? r : 0);
      }, n.prototype.setCollisionEndedCallbackEnabled = function(t, e) {
        var i = this, r = this._getPluginReference(t), o = this._hknp.HP_Body_GetEventMask(r.hpBodyId)[1];
        o = e ? o | this._hknp.EventType.COLLISION_FINISHED.value : o & ~this._hknp.EventType.COLLISION_FINISHED.value, t._pluginDataInstances && t._pluginDataInstances.length ? t._pluginDataInstances.forEach(function(a) {
          i._hknp.HP_Body_SetEventMask(a.hpBodyId, o);
        }) : t._pluginData && this._hknp.HP_Body_SetEventMask(t._pluginData.hpBodyId, o);
      }, n.prototype._notifyTriggers = function() {
        for (var t = this._hknp.HP_World_GetTriggerEvents(this.world)[1], e = new eI(); t; ) {
          eI.readToRef(this._hknp.HEAPU8.buffer, t, e);
          var i = this._bodies.get(e.bodyIdA), r = this._bodies.get(e.bodyIdB);
          if (i && r) {
            var o = { collider: i.body, colliderIndex: i.index, collidedAgainst: r.body, collidedAgainstIndex: r.index, type: this._nativeTriggerCollisionValueToCollisionType(e.type) };
            this.onTriggerCollisionObservable.notifyObservers(o);
          }
          t = this._hknp.HP_World_GetNextTriggerEvent(this.world, t);
        }
      }, n.prototype._notifyCollisions = function() {
        for (var t = this._hknp.HP_World_GetCollisionEvents(this.world)[1], e = new $P(), i = Number(this.world); t; ) {
          $P.readToRef(this._hknp.HEAPU8.buffer, t, e);
          var r = this._bodies.get(e.contactOnA.bodyId), o = this._bodies.get(e.contactOnB.bodyId);
          if (r && o) {
            var a = { collider: r.body, colliderIndex: r.index, collidedAgainst: o.body, collidedAgainstIndex: o.index, type: this._nativeCollisionValueToCollisionType(e.type) };
            if (a.type === Wr.COLLISION_FINISHED)
              this.onCollisionEndedObservable.notifyObservers(a);
            else {
              e.contactOnB.position.subtractToRef(e.contactOnA.position, this._tmpVec3[0]);
              var s = v.Dot(this._tmpVec3[0], e.contactOnA.normal);
              a.point = e.contactOnA.position, a.distance = s, a.impulse = e.impulseApplied, a.normal = e.contactOnA.normal, this.onCollisionObservable.notifyObservers(a);
            }
            if (this._bodyCollisionObservable.size && a.type !== Wr.COLLISION_FINISHED) {
              var l = this._bodyCollisionObservable.get(e.contactOnA.bodyId), c = this._bodyCollisionObservable.get(e.contactOnB.bodyId);
              l ? l.notifyObservers(a) : c && (a.collider = o.body, a.colliderIndex = o.index, a.collidedAgainst = r.body, a.collidedAgainstIndex = r.index, a.normal = e.contactOnB.normal, c.notifyObservers(a));
            } else
              this._bodyCollisionEndedObservable.size && (l = this._bodyCollisionEndedObservable.get(e.contactOnA.bodyId), c = this._bodyCollisionEndedObservable.get(e.contactOnB.bodyId), l ? l.notifyObservers(a) : c && (a.collider = o.body, a.colliderIndex = o.index, a.collidedAgainst = r.body, a.collidedAgainstIndex = r.index, a.normal = e.contactOnB.normal, c.notifyObservers(a)));
          }
          t = this._hknp.HP_World_GetNextCollisionEvent(i, t);
        }
      }, Object.defineProperty(n.prototype, "numBodies", { get: function() {
        return this._hknp.HP_World_GetNumBodies(this.world)[1];
      }, enumerable: !1, configurable: !0 }), n.prototype.dispose = function() {
        this._hknp.HP_QueryCollector_Release(this._queryCollector), this._queryCollector = BigInt(0), this._hknp.HP_World_Release(this.world), this.world = void 0;
      }, n.prototype._v3ToBvecRef = function(t, e) {
        e.set(t[0], t[1], t[2]);
      }, n.prototype._bVecToV3 = function(t) {
        return [t._x, t._y, t._z];
      }, n.prototype._bQuatToV4 = function(t) {
        return [t._x, t._y, t._z, t._w];
      }, n.prototype._constraintMotorTypeToNative = function(t) {
        switch (t) {
          case es.POSITION:
            return this._hknp.ConstraintMotorType.POSITION;
          case es.VELOCITY:
            return this._hknp.ConstraintMotorType.VELOCITY;
        }
        return this._hknp.ConstraintMotorType.NONE;
      }, n.prototype._nativeToMotorType = function(t) {
        switch (t) {
          case this._hknp.ConstraintMotorType.POSITION:
            return es.POSITION;
          case this._hknp.ConstraintMotorType.VELOCITY:
            return es.VELOCITY;
        }
        return es.NONE;
      }, n.prototype._materialCombineToNative = function(t) {
        switch (t) {
          case Go.GEOMETRIC_MEAN:
            return this._hknp.MaterialCombine.GEOMETRIC_MEAN;
          case Go.MINIMUM:
            return this._hknp.MaterialCombine.MINIMUM;
          case Go.MAXIMUM:
            return this._hknp.MaterialCombine.MAXIMUM;
          case Go.ARITHMETIC_MEAN:
            return this._hknp.MaterialCombine.ARITHMETIC_MEAN;
          case Go.MULTIPLY:
            return this._hknp.MaterialCombine.MULTIPLY;
        }
      }, n.prototype._constraintAxisToNative = function(t) {
        switch (t) {
          case co.LINEAR_X:
            return this._hknp.ConstraintAxis.LINEAR_X;
          case co.LINEAR_Y:
            return this._hknp.ConstraintAxis.LINEAR_Y;
          case co.LINEAR_Z:
            return this._hknp.ConstraintAxis.LINEAR_Z;
          case co.ANGULAR_X:
            return this._hknp.ConstraintAxis.ANGULAR_X;
          case co.ANGULAR_Y:
            return this._hknp.ConstraintAxis.ANGULAR_Y;
          case co.ANGULAR_Z:
            return this._hknp.ConstraintAxis.ANGULAR_Z;
          case co.LINEAR_DISTANCE:
            return this._hknp.ConstraintAxis.LINEAR_DISTANCE;
        }
      }, n.prototype._nativeToLimitMode = function(t) {
        switch (t) {
          case this._hknp.ConstraintAxisLimitMode.FREE:
            return ko.FREE;
          case this._hknp.ConstraintAxisLimitMode.LIMITED:
            return ko.LIMITED;
          case this._hknp.ConstraintAxisLimitMode.LOCKED:
            return ko.LOCKED;
        }
        return ko.FREE;
      }, n.prototype._limitModeToNative = function(t) {
        switch (t) {
          case ko.FREE:
            return this._hknp.ConstraintAxisLimitMode.FREE;
          case ko.LIMITED:
            return this._hknp.ConstraintAxisLimitMode.LIMITED;
          case ko.LOCKED:
            return this._hknp.ConstraintAxisLimitMode.LOCKED;
        }
      }, n.prototype._nativeCollisionValueToCollisionType = function(t) {
        switch (t) {
          case this._hknp.EventType.COLLISION_STARTED.value:
            return Wr.COLLISION_STARTED;
          case this._hknp.EventType.COLLISION_FINISHED.value:
            return Wr.COLLISION_FINISHED;
          case this._hknp.EventType.COLLISION_CONTINUED.value:
            return Wr.COLLISION_CONTINUED;
        }
        return Wr.COLLISION_STARTED;
      }, n.prototype._nativeTriggerCollisionValueToCollisionType = function(t) {
        switch (t) {
          case 8:
            return Wr.TRIGGER_ENTERED;
          case 16:
            return Wr.TRIGGER_EXITED;
        }
        return Wr.TRIGGER_ENTERED;
      }, n;
    }();
    Ue.prototype.getPhysicsEngine = function() {
      return this._physicsEngine;
    }, Ue.prototype.enablePhysics = function(n, t) {
      if (n === void 0 && (n = null), this._physicsEngine)
        return !0;
      var e = this._getComponent(we.NAME_PHYSICSENGINE);
      e || (e = new gN(this), this._addComponent(e));
      try {
        if (t && (t == null ? void 0 : t.getPluginVersion()) !== 1) {
          if ((t == null ? void 0 : t.getPluginVersion()) !== 2)
            throw new Error("Unsupported Physics plugin version.");
          this._physicsEngine = new Q0(n, t);
        } else
          this._physicsEngine = new x_(n, t);
        return this._physicsTimeAccumulator = 0, !0;
      } catch (i) {
        return q.Error(i.message), !1;
      }
    }, Ue.prototype.disablePhysicsEngine = function() {
      this._physicsEngine && (this._physicsEngine.dispose(), this._physicsEngine = null);
    }, Ue.prototype.isPhysicsEnabled = function() {
      return this._physicsEngine !== void 0;
    }, Ue.prototype.deleteCompoundImpostor = function(n) {
      var t = n.parts[0].mesh;
      t.physicsImpostor && (t.physicsImpostor.dispose(), t.physicsImpostor = null);
    }, Ue.prototype._advancePhysicsEngineStep = function(n) {
      if (this._physicsEngine) {
        var t = this._physicsEngine.getSubTimeStep();
        if (t > 0)
          for (this._physicsTimeAccumulator += n; this._physicsTimeAccumulator > t; )
            this.onBeforePhysicsObservable.notifyObservers(this), this._physicsEngine._step(t / 1e3), this.onAfterPhysicsObservable.notifyObservers(this), this._physicsTimeAccumulator -= t;
        else
          this.onBeforePhysicsObservable.notifyObservers(this), this._physicsEngine._step(n / 1e3), this.onAfterPhysicsObservable.notifyObservers(this);
      }
    };
    var gN = function() {
      function n(t) {
        var e = this;
        this.name = we.NAME_PHYSICSENGINE, this.scene = t, this.scene.onBeforePhysicsObservable = new H(), this.scene.onAfterPhysicsObservable = new H(), this.scene.getDeterministicFrameTime = function() {
          return e.scene._physicsEngine ? 1e3 * e.scene._physicsEngine.getTimeStep() : 1e3 / 60;
        };
      }
      return n.prototype.register = function() {
      }, n.prototype.rebuild = function() {
      }, n.prototype.dispose = function() {
        this.scene.onBeforePhysicsObservable.clear(), this.scene.onAfterPhysicsObservable.clear(), this.scene._physicsEngine && this.scene.disablePhysicsEngine();
      }, n;
    }();
    Object.defineProperty(ai.prototype, "physicsBody", { get: function() {
      return this._physicsBody;
    }, set: function(n) {
      var t = this;
      this._physicsBody !== n && (this._disposePhysicsObserver && this.onDisposeObservable.remove(this._disposePhysicsObserver), this._physicsBody = n, n && (this._disposePhysicsObserver = this.onDisposeObservable.add(function() {
        t.physicsBody && (t.physicsBody.dispose(), t.physicsBody = null);
      })));
    }, enumerable: !0, configurable: !0 }), ai.prototype.getPhysicsBody = function() {
      return this.physicsBody;
    }, ai.prototype.applyImpulse = function(n, t) {
      if (!this.physicsBody)
        throw new Error("No Physics Body for TransformNode");
      return this.physicsBody.applyImpulse(n, t), this;
    };
    var uu, Dl, Nl = function() {
      function n() {
      }
      return n.GetContactPointToRef = function(t, e, i, r, o) {
        var a = t.getScene().getPhysicsEngine(), s = a == null ? void 0 : a.getPluginVersion();
        if (s === 1) {
          var l = new gi(e, i).intersectsMesh(t);
          if (l.hit && l.pickedPoint)
            return r.copyFrom(l.pickedPoint), !0;
        } else if (s === 2)
          return t.physicsBody.getObjectCenterWorldToRef(r, o), !0;
        return !1;
      }, n.HasAppliedForces = function(t, e) {
        var i, r, o;
        return t.getMotionType(e) === Hr.STATIC || ((r = (i = t.getMassProperties(e)) === null || i === void 0 ? void 0 : i.mass) !== null && r !== void 0 ? r : 0) === 0 || ((o = t.transformNode) === null || o === void 0 ? void 0 : o.getTotalVertices()) === 0;
      }, n.IsInsideCylinder = function(t, e, i, r) {
        var o = F.Vector3[0];
        return t.subtractToRef(e, o), Math.abs(o.x) <= i && Math.abs(o.z) <= i && o.y >= 0 && o.y <= r;
      }, n;
    }(), iI = function() {
      function n(t) {
        this._hitData = { force: new v(), contactPoint: new v(), distanceFromOrigin: 0 }, this._scene = t, this._physicsEngine = this._scene.getPhysicsEngine(), this._physicsEngine || q.Warn("Physics engine not enabled. Please enable the physics before you can use the methods.");
      }
      return n.prototype.applyRadialExplosionImpulse = function(t, e, i, r) {
        var o = this;
        if (!this._physicsEngine)
          return q.Warn("Physics engine not enabled. Please enable the physics before you call this method."), null;
        if (this._physicsEngine.getPluginVersion() === 1 && this._physicsEngine.getImpostors().length === 0 || this._physicsEngine.getPluginVersion() === 2 && this._physicsEngine.getBodies().length === 0)
          return null;
        var a = !1;
        if (typeof e == "number") {
          var s = e;
          (e = new Fl()).radius = s, e.strength = i ?? e.strength, e.falloff = r ?? e.falloff;
        } else
          a = !(!e.affectedImpostorsCallback && !e.affectedBodiesCallback);
        var l = new nI(this._scene, e), c = this._hitData;
        if (this._physicsEngine.getPluginVersion() === 1) {
          var u = Array();
          this._physicsEngine.getImpostors().forEach(function(h) {
            l.getImpostorHitData(h, t, c) && (h.applyImpulse(c.force, c.contactPoint), a && u.push({ impostor: h, hitData: o._copyPhysicsHitData(c) }));
          }), l.triggerAffectedImpostorsCallback(u);
        } else
          this._applicationForBodies(l, t, c, a, function(h, d) {
            h.applyImpulse(d.force, d.contactPoint, d.instanceIndex);
          });
        return l.dispose(!1), l;
      }, n.prototype.applyRadialExplosionForce = function(t, e, i, r) {
        var o = this;
        if (!this._physicsEngine)
          return q.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."), null;
        if (this._physicsEngine.getPluginVersion() === 1 && this._physicsEngine.getImpostors().length === 0 || this._physicsEngine.getPluginVersion() === 2 && this._physicsEngine.getBodies().length === 0)
          return null;
        var a = !1;
        if (typeof e == "number") {
          var s = e;
          (e = new Fl()).radius = s, e.strength = i ?? e.strength, e.falloff = r ?? e.falloff;
        } else
          a = !(!e.affectedImpostorsCallback && !e.affectedBodiesCallback);
        var l = new nI(this._scene, e), c = this._hitData;
        if (this._physicsEngine.getPluginVersion() === 1) {
          var u = Array();
          this._physicsEngine.getImpostors().forEach(function(h) {
            l.getImpostorHitData(h, t, c) && (h.applyForce(c.force, c.contactPoint), a && u.push({ impostor: h, hitData: o._copyPhysicsHitData(c) }));
          }), l.triggerAffectedImpostorsCallback(u);
        } else
          this._applicationForBodies(l, t, c, a, function(h, d) {
            h.applyForce(d.force, d.contactPoint, d.instanceIndex);
          });
        return l.dispose(!1), l;
      }, n.prototype._applicationForBodies = function(t, e, i, r, o) {
        for (var a = this, s = Array(), l = 0, c = this._physicsEngine.getBodies(); l < c.length; l++)
          c[l].iterateOverAllInstances(function(u, h) {
            t.getBodyHitData(u, e, i, h) && (o(u, i), r && s.push({ body: u, hitData: a._copyPhysicsHitData(i) }));
          });
        t.triggerAffectedBodiesCallback(s);
      }, n.prototype.gravitationalField = function(t, e, i, r) {
        if (!this._physicsEngine)
          return q.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."), null;
        if (this._physicsEngine.getPluginVersion() === 1 && this._physicsEngine.getImpostors().length === 0 || this._physicsEngine.getPluginVersion() === 2 && this._physicsEngine.getBodies().length === 0)
          return null;
        if (typeof e == "number") {
          var o = e;
          (e = new Fl()).radius = o, e.strength = i ?? e.strength, e.falloff = r ?? e.falloff;
        }
        var a = new vN(this, this._scene, t, e);
        return a.dispose(!1), a;
      }, n.prototype.updraft = function(t, e, i, r, o) {
        if (!this._physicsEngine)
          return q.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."), null;
        if (this._physicsEngine.getPluginVersion() === 1 && this._physicsEngine.getImpostors().length === 0 || this._physicsEngine.getPluginVersion() === 2 && this._physicsEngine.getBodies().length === 0)
          return null;
        if (typeof e == "number") {
          var a = e;
          (e = new tm()).radius = a, e.strength = i ?? e.strength, e.height = r ?? e.height, e.updraftMode = o ?? e.updraftMode;
        }
        var s = new yN(this._scene, t, e);
        return s.dispose(!1), s;
      }, n.prototype.vortex = function(t, e, i, r) {
        if (!this._physicsEngine)
          return q.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."), null;
        if (this._physicsEngine.getPluginVersion() === 1 && this._physicsEngine.getImpostors().length === 0 || this._physicsEngine.getPluginVersion() === 2 && this._physicsEngine.getBodies().length === 0)
          return null;
        if (typeof e == "number") {
          var o = e;
          (e = new im()).radius = o, e.strength = i ?? e.strength, e.height = r ?? e.height;
        }
        var a = new bN(this._scene, t, e);
        return a.dispose(!1), a;
      }, n.prototype._copyPhysicsHitData = function(t) {
        return { force: t.force.clone(), contactPoint: t.contactPoint.clone(), distanceFromOrigin: t.distanceFromOrigin, instanceIndex: t.instanceIndex };
      }, n;
    }(), nI = function() {
      function n(t, e) {
        this._scene = t, this._options = e, this._dataFetched = !1, this._options = je(je({}, new Fl()), this._options);
      }
      return n.prototype.getData = function() {
        return this._dataFetched = !0, { sphere: this._sphere };
      }, n.prototype._getHitData = function(t, e, i, r) {
        var o = F.Vector3[0];
        o.copyFrom(e).subtractInPlace(i);
        var a = F.Vector3[1];
        if (!Nl.GetContactPointToRef(t, i, o, a, r.instanceIndex))
          return !1;
        var s = v.Distance(i, a);
        if (s > this._options.radius)
          return !1;
        var l = this._options.falloff === uu.Constant ? this._options.strength : this._options.strength * (1 - s / this._options.radius);
        return o.scaleInPlace(l), r.force.copyFrom(o), r.contactPoint.copyFrom(a), r.distanceFromOrigin = s, !0;
      }, n.prototype.getBodyHitData = function(t, e, i, r) {
        if (Nl.HasAppliedForces(t, r))
          return !1;
        var o = t.transformNode, a = t.getObjectCenterWorld(r);
        return i.instanceIndex = r, this._getHitData(o, a, e, i);
      }, n.prototype.getImpostorHitData = function(t, e, i) {
        if (t.mass === 0 || t.object.getClassName() !== "Mesh" && t.object.getClassName() !== "InstancedMesh")
          return !1;
        var r = t.object;
        if (!this._intersectsWithSphere(r, e, this._options.radius))
          return !1;
        var o = t.getObjectCenter();
        return this._getHitData(r, o, e, i), !0;
      }, n.prototype.triggerAffectedImpostorsCallback = function(t) {
        this._options.affectedImpostorsCallback && this._options.affectedImpostorsCallback(t);
      }, n.prototype.triggerAffectedBodiesCallback = function(t) {
        this._options.affectedBodiesCallback && this._options.affectedBodiesCallback(t);
      }, n.prototype.dispose = function(t) {
        var e = this;
        t === void 0 && (t = !0), this._sphere && (t ? this._sphere.dispose() : setTimeout(function() {
          e._dataFetched || e._sphere.dispose();
        }, 0));
      }, n.prototype._prepareSphere = function() {
        this._sphere || (this._sphere = yn("radialExplosionEventSphere", this._options.sphere, this._scene), this._sphere.isVisible = !1);
      }, n.prototype._intersectsWithSphere = function(t, e, i) {
        return this._prepareSphere(), this._sphere.position = e, this._sphere.scaling.setAll(2 * i), this._sphere._updateBoundingInfo(), this._sphere.computeWorldMatrix(!0), this._sphere.intersectsMesh(t, !0);
      }, n;
    }(), vN = function() {
      function n(t, e, i, r) {
        var o = this;
        this._physicsHelper = t, this._scene = e, this._origin = i, this._options = r, this._dataFetched = !1, this._options = je(je({}, new Fl()), this._options), this._tickCallback = function() {
          return o._tick();
        }, this._options.strength = -1 * this._options.strength;
      }
      return n.prototype.getData = function() {
        return this._dataFetched = !0, { sphere: this._sphere };
      }, n.prototype.enable = function() {
        this._tickCallback.call(this), this._scene.registerBeforeRender(this._tickCallback);
      }, n.prototype.disable = function() {
        this._scene.unregisterBeforeRender(this._tickCallback);
      }, n.prototype.dispose = function(t) {
        var e = this;
        t === void 0 && (t = !0), this._sphere && (t ? this._sphere.dispose() : setTimeout(function() {
          e._dataFetched || e._sphere.dispose();
        }, 0));
      }, n.prototype._tick = function() {
        var t;
        if (this._sphere)
          this._physicsHelper.applyRadialExplosionForce(this._origin, this._options);
        else {
          var e = this._physicsHelper.applyRadialExplosionForce(this._origin, this._options);
          e && (this._sphere = (t = e.getData().sphere) === null || t === void 0 ? void 0 : t.clone("radialExplosionEventSphereClone"));
        }
      }, n;
    }(), yN = function() {
      function n(t, e, i) {
        var r = this;
        this._scene = t, this._origin = e, this._options = i, this._originTop = v.Zero(), this._originDirection = v.Zero(), this._cylinderPosition = v.Zero(), this._dataFetched = !1, this._physicsEngine = this._scene.getPhysicsEngine(), this._options = je(je({}, new tm()), this._options), this._origin.addToRef(new v(0, this._options.height / 2, 0), this._cylinderPosition), this._origin.addToRef(new v(0, this._options.height, 0), this._originTop), this._options.updraftMode === Dl.Perpendicular && (this._originDirection = this._origin.subtract(this._originTop).normalize()), this._tickCallback = function() {
          return r._tick();
        }, this._physicsEngine.getPluginVersion() === 1 && this._prepareCylinder();
      }
      return n.prototype.getData = function() {
        return this._dataFetched = !0, { cylinder: this._cylinder };
      }, n.prototype.enable = function() {
        this._tickCallback.call(this), this._scene.registerBeforeRender(this._tickCallback);
      }, n.prototype.disable = function() {
        this._scene.unregisterBeforeRender(this._tickCallback);
      }, n.prototype.dispose = function(t) {
        var e = this;
        t === void 0 && (t = !0), this._cylinder && (t ? (this._cylinder.dispose(), this._cylinder = void 0) : setTimeout(function() {
          !e._dataFetched && e._cylinder && (e._cylinder.dispose(), e._cylinder = void 0);
        }, 0));
      }, n.prototype._getHitData = function(t, e) {
        var i;
        i = this._options.updraftMode === Dl.Perpendicular ? this._originDirection : t.subtract(this._originTop);
        var r = v.Distance(this._origin, t), o = -1 * this._options.strength, a = i.multiplyByFloats(o, o, o);
        e.force.copyFrom(a), e.contactPoint.copyFrom(t), e.distanceFromOrigin = r;
      }, n.prototype._getBodyHitData = function(t, e, i) {
        if (Nl.HasAppliedForces(t))
          return !1;
        var r = t.getObjectCenterWorld(i);
        return !!Nl.IsInsideCylinder(r, this._origin, this._options.radius, this._options.height) && (e.instanceIndex = i, this._getHitData(r, e), !0);
      }, n.prototype._getImpostorHitData = function(t, e) {
        if (t.mass === 0)
          return !1;
        var i = t.object;
        if (!this._intersectsWithCylinder(i))
          return !1;
        var r = t.getObjectCenter();
        return this._getHitData(r, e), !0;
      }, n.prototype._tick = function() {
        var t = this, e = n._HitData;
        this._physicsEngine.getPluginVersion() === 1 ? this._physicsEngine.getImpostors().forEach(function(i) {
          t._getImpostorHitData(i, e) && i.applyForce(e.force, e.contactPoint);
        }) : this._physicsEngine.getBodies().forEach(function(i) {
          i.iterateOverAllInstances(function(r, o) {
            t._getBodyHitData(r, e, o) && r.applyForce(e.force, e.contactPoint, e.instanceIndex);
          });
        });
      }, n.prototype._prepareCylinder = function() {
        this._cylinder || (this._cylinder = Fn("updraftEventCylinder", { height: this._options.height, diameter: 2 * this._options.radius }, this._scene), this._cylinder.isVisible = !1);
      }, n.prototype._intersectsWithCylinder = function(t) {
        return !!this._cylinder && (this._cylinder.position = this._cylinderPosition, this._cylinder.intersectsMesh(t, !0));
      }, n._HitData = { force: new v(), contactPoint: new v(), distanceFromOrigin: 0 }, n;
    }(), bN = function() {
      function n(t, e, i) {
        var r = this;
        this._scene = t, this._origin = e, this._options = i, this._originTop = v.Zero(), this._cylinderPosition = v.Zero(), this._dataFetched = !1, this._physicsEngine = this._scene.getPhysicsEngine(), this._options = je(je({}, new im()), this._options), this._origin.addToRef(new v(0, this._options.height / 2, 0), this._cylinderPosition), this._origin.addToRef(new v(0, this._options.height, 0), this._originTop), this._tickCallback = function() {
          return r._tick();
        }, this._physicsEngine.getPluginVersion() === 1 && this._prepareCylinder();
      }
      return n.prototype.getData = function() {
        return this._dataFetched = !0, { cylinder: this._cylinder };
      }, n.prototype.enable = function() {
        this._tickCallback.call(this), this._scene.registerBeforeRender(this._tickCallback);
      }, n.prototype.disable = function() {
        this._scene.unregisterBeforeRender(this._tickCallback);
      }, n.prototype.dispose = function(t) {
        var e = this;
        t === void 0 && (t = !0), this._cylinder && (t ? this._cylinder.dispose() : setTimeout(function() {
          e._dataFetched || e._cylinder.dispose();
        }, 0));
      }, n.prototype._getHitData = function(t, e, i) {
        var r = n.originOnPlane;
        r.set(this._origin.x, e.y, this._origin.z);
        var o = F.Vector3[0];
        e.subtractToRef(r, o);
        var a = F.Vector3[1];
        if (!Nl.GetContactPointToRef(t, r, o, a, i.instanceIndex))
          return !1;
        var s, l, c, u = v.Distance(a, r) / this._options.radius, h = F.Vector3[2];
        if (a.normalizeToRef(h), u > this._options.centripetalForceThreshold && h.negateInPlace(), u > this._options.centripetalForceThreshold)
          s = h.x * this._options.centripetalForceMultiplier, l = h.y * this._options.updraftForceMultiplier, c = h.z * this._options.centripetalForceMultiplier;
        else {
          var d = v.Cross(r, e).normalize();
          s = (d.x + h.x) * this._options.centrifugalForceMultiplier, l = this._originTop.y * this._options.updraftForceMultiplier, c = (d.z + h.z) * this._options.centrifugalForceMultiplier;
        }
        var p = F.Vector3[3];
        return p.set(s, l, c), p.scaleInPlace(this._options.strength), i.force.copyFrom(p), i.contactPoint.copyFrom(e), i.distanceFromOrigin = u, !0;
      }, n.prototype._getBodyHitData = function(t, e, i) {
        if (Nl.HasAppliedForces(t, i))
          return !1;
        var r = t.transformNode, o = t.getObjectCenterWorld(i);
        return !!Nl.IsInsideCylinder(o, this._origin, this._options.radius, this._options.height) && (e.instanceIndex = i, this._getHitData(r, o, e));
      }, n.prototype._getImpostorHitData = function(t, e) {
        if (t.mass === 0 || t.object.getClassName() !== "Mesh" && t.object.getClassName() !== "InstancedMesh")
          return !1;
        var i = t.object;
        if (!this._intersectsWithCylinder(i))
          return !1;
        var r = t.getObjectCenter();
        return this._getHitData(i, r, e), !0;
      }, n.prototype._tick = function() {
        var t = this, e = n.hitData;
        this._physicsEngine.getPluginVersion() === 1 ? this._physicsEngine.getImpostors().forEach(function(i) {
          t._getImpostorHitData(i, e) && i.applyForce(e.force, e.contactPoint);
        }) : this._physicsEngine.getBodies().forEach(function(i) {
          i.iterateOverAllInstances(function(r, o) {
            t._getBodyHitData(r, e, o) && r.applyForce(e.force, e.contactPoint, e.instanceIndex);
          });
        });
      }, n.prototype._prepareCylinder = function() {
        this._cylinder || (this._cylinder = Fn("vortexEventCylinder", { height: this._options.height, diameter: 2 * this._options.radius }, this._scene), this._cylinder.isVisible = !1);
      }, n.prototype._intersectsWithCylinder = function(t) {
        return this._cylinder.position = this._cylinderPosition, this._cylinder.intersectsMesh(t, !0);
      }, n.originOnPlane = v.Zero(), n.hitData = { force: new v(), contactPoint: new v(), distanceFromOrigin: 0 }, n;
    }(), Fl = function() {
      this.radius = 5, this.strength = 10, this.falloff = uu.Constant, this.sphere = { segments: 32, diameter: 1 };
    }, tm = function() {
      this.radius = 5, this.strength = 10, this.height = 10, this.updraftMode = Dl.Center;
    }, im = function() {
      this.radius = 5, this.strength = 10, this.height = 10, this.centripetalForceThreshold = 0.7, this.centripetalForceMultiplier = 5, this.centrifugalForceMultiplier = 0.5, this.updraftForceMultiplier = 0.02;
    };
    (function(n) {
      n[n.Constant = 0] = "Constant", n[n.Linear = 1] = "Linear";
    })(uu || (uu = {})), function(n) {
      n[n.Center = 0] = "Center", n[n.Perpendicular = 1] = "Perpendicular";
    }(Dl || (Dl = {})), re.ShadersStore.blackAndWhitePixelShader = `varying vec2 vUV;uniform sampler2D textureSampler;uniform float degree;
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void) 
{vec3 color=texture2D(textureSampler,vUV).rgb;float luminance=dot(color,vec3(0.3,0.59,0.11)); 
vec3 blackAndWhite=vec3(luminance,luminance,luminance);gl_FragColor=vec4(color-((color-blackAndWhite)*degree),1.0);}`;
    var $0 = function(n) {
      function t(e, i, r, o, a, s) {
        var l = n.call(this, e, "blackAndWhite", ["degree"], null, i, r, o, a, s) || this;
        return l.degree = 1, l.onApplyObservable.add(function(c) {
          c.setFloat("degree", l.degree);
        }), l;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "BlackAndWhitePostProcess";
      }, t._Parse = function(e, i, r, o) {
        return Ne.Parse(function() {
          return new t(e.name, e.options, i, e.renderTargetSamplingMode, r.getEngine(), e.reusable);
        }, e, r, o);
      }, x([N()], t.prototype, "degree", void 0), t;
    }(nt);
    j("BABYLON.BlackAndWhitePostProcess", $0);
    var Vt = function() {
      function n(t, e, i, r) {
        this._name = e, this._singleInstance = r || !0, this._getPostProcesses = i, this._cameras = {}, this._indicesForCamera = {}, this._postProcesses = {};
      }
      return Object.defineProperty(n.prototype, "isSupported", { get: function() {
        for (var t in this._postProcesses)
          if (Object.prototype.hasOwnProperty.call(this._postProcesses, t)) {
            for (var e = this._postProcesses[t], i = 0; i < e.length; i++)
              if (!e[i].isSupported)
                return !1;
          }
        return !0;
      }, enumerable: !1, configurable: !0 }), n.prototype._update = function() {
      }, n.prototype._attachCameras = function(t) {
        var e, i = this, r = de.MakeArray(t || this._cameras);
        if (r)
          for (var o = function(l) {
            var c = r[l];
            if (!c)
              return "continue";
            var u = c.name;
            if (e = a._singleInstance ? 0 : u, !a._postProcesses[e]) {
              var h = a._getPostProcesses();
              h && (a._postProcesses[e] = Array.isArray(h) ? h : [h]);
            }
            a._indicesForCamera[u] || (a._indicesForCamera[u] = []), a._postProcesses[e].forEach(function(d) {
              var p = c.attachPostProcess(d);
              i._indicesForCamera[u].push(p);
            }), a._cameras[u] || (a._cameras[u] = c);
          }, a = this, s = 0; s < r.length; s++)
            o(s);
      }, n.prototype._detachCameras = function(t) {
        var e = de.MakeArray(t || this._cameras);
        if (e)
          for (var i = function(a) {
            var s = e[a], l = s.name, c = r._postProcesses[r._singleInstance ? 0 : l];
            c && c.forEach(function(u) {
              s.detachPostProcess(u);
            }), r._cameras[l] && (r._cameras[l] = null), delete r._indicesForCamera[l];
          }, r = this, o = 0; o < e.length; o++)
            i(o);
      }, n.prototype._enable = function(t) {
        var e = de.MakeArray(t || this._cameras);
        if (e)
          for (var i = 0; i < e.length; i++)
            for (var r = e[i], o = r.name, a = this._singleInstance ? 0 : o, s = 0; s < this._indicesForCamera[o].length; s++) {
              var l = this._indicesForCamera[o][s];
              r._postProcesses[l] == null && e[i].attachPostProcess(this._postProcesses[a][s], l);
            }
      }, n.prototype._disable = function(t) {
        var e = de.MakeArray(t || this._cameras);
        if (e)
          for (var i = function(a) {
            var s = e[a], l = s.name;
            r._postProcesses[r._singleInstance ? 0 : l].forEach(function(c) {
              s.detachPostProcess(c);
            });
          }, r = this, o = 0; o < e.length; o++)
            i(o);
      }, n.prototype.getPostProcesses = function(t) {
        return this._singleInstance ? this._postProcesses[0] : t ? this._postProcesses[t.name] : null;
      }, n;
    }();
    re.ShadersStore.extractHighlightsPixelShader = `#include<helperFunctions>
varying vec2 vUV;uniform sampler2D textureSampler;uniform float threshold;uniform float exposure;
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void) 
{gl_FragColor=texture2D(textureSampler,vUV);float luma=dot(LuminanceEncodeApprox,gl_FragColor.rgb*exposure);gl_FragColor.rgb=step(threshold,luma)*gl_FragColor.rgb;}`;
    var nm = function(n) {
      function t(e, i, r, o, a, s, l, c) {
        l === void 0 && (l = _.TEXTURETYPE_UNSIGNED_INT), c === void 0 && (c = !1);
        var u = n.call(this, e, "extractHighlights", ["threshold", "exposure"], null, i, r, o, a, s, null, l, void 0, null, c) || this;
        return u.threshold = 0.9, u._exposure = 1, u._inputPostProcess = null, u.onApplyObservable.add(function(h) {
          u.externalTextureSamplerBinding = !!u._inputPostProcess, u._inputPostProcess && h.setTextureFromPostProcess("textureSampler", u._inputPostProcess), h.setFloat("threshold", Math.pow(u.threshold, ct)), h.setFloat("exposure", u._exposure);
        }), u;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ExtractHighlightsPostProcess";
      }, x([N()], t.prototype, "threshold", void 0), t;
    }(nt);
    j("BABYLON.ExtractHighlightsPostProcess", nm), re.ShadersStore.bloomMergePixelShader = `uniform sampler2D textureSampler;uniform sampler2D bloomBlur;varying vec2 vUV;uniform float bloomWeight;
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void)
{gl_FragColor=texture2D(textureSampler,vUV);vec3 blurred=texture2D(bloomBlur,vUV).rgb;gl_FragColor.rgb=gl_FragColor.rgb+(blurred.rgb*bloomWeight); }
`;
    var rm = function(n) {
      function t(e, i, r, o, a, s, l, c, u, h, d) {
        h === void 0 && (h = _.TEXTURETYPE_UNSIGNED_INT), d === void 0 && (d = !1);
        var p = n.call(this, e, "bloomMerge", ["bloomWeight"], ["bloomBlur"], a, s, l, c, u, null, h, void 0, null, !0) || this;
        return p.weight = 1, p.weight = o, p.externalTextureSamplerBinding = !0, p.onApplyObservable.add(function(f) {
          f.setTextureFromPostProcess("textureSampler", i), f.setTextureFromPostProcessOutput("bloomBlur", r), f.setFloat("bloomWeight", p.weight);
        }), d || p.updateEffect(), p;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "BloomMergePostProcess";
      }, x([N()], t.prototype, "weight", void 0), t;
    }(nt);
    j("BABYLON.BloomMergePostProcess", rm);
    var om = function(n) {
      function t(e, i, r, o, a, s) {
        a === void 0 && (a = 0), s === void 0 && (s = !1);
        var l = n.call(this, e.getEngine(), "bloom", function() {
          return l._effects;
        }, !0) || this;
        return l._bloomScale = i, l._effects = [], l._downscale = new nm("highlights", 1, null, ae.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, a, s), l._blurX = new Cn("horizontal blur", new fe(1, 0), 10, i, null, ae.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, a, void 0, s), l._blurX.alwaysForcePOT = !0, l._blurX.autoClear = !1, l._blurY = new Cn("vertical blur", new fe(0, 1), 10, i, null, ae.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, a, void 0, s), l._blurY.alwaysForcePOT = !0, l._blurY.autoClear = !1, l.kernel = o, l._effects = [l._downscale, l._blurX, l._blurY], l._merge = new rm("bloomMerge", l._downscale, l._blurY, r, i, null, ae.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, a, s), l._merge.autoClear = !1, l._effects.push(l._merge), l;
      }
      return D(t, n), Object.defineProperty(t.prototype, "threshold", { get: function() {
        return this._downscale.threshold;
      }, set: function(e) {
        this._downscale.threshold = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "weight", { get: function() {
        return this._merge.weight;
      }, set: function(e) {
        this._merge.weight = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "kernel", { get: function() {
        return this._blurX.kernel / this._bloomScale;
      }, set: function(e) {
        this._blurX.kernel = e * this._bloomScale, this._blurY.kernel = e * this._bloomScale;
      }, enumerable: !1, configurable: !0 }), t.prototype.disposeEffects = function(e) {
        for (var i = 0; i < this._effects.length; i++)
          this._effects[i].dispose(e);
      }, t.prototype._updateEffects = function() {
        for (var e = 0; e < this._effects.length; e++)
          this._effects[e].updateEffect();
      }, t.prototype._isReady = function() {
        for (var e = 0; e < this._effects.length; e++)
          if (!this._effects[e].isReady())
            return !1;
        return !0;
      }, t;
    }(Vt);
    re.ShadersStore.chromaticAberrationPixelShader = `uniform sampler2D textureSampler; 
uniform float chromatic_aberration;uniform float radialIntensity;uniform vec2 direction;uniform vec2 centerPosition;uniform float screen_width;uniform float screen_height;varying vec2 vUV;
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void)
{vec2 centered_screen_pos=vec2(vUV.x-centerPosition.x,vUV.y-centerPosition.y);vec2 directionOfEffect=direction;if(directionOfEffect.x==0. && directionOfEffect.y==0.){directionOfEffect=normalize(centered_screen_pos);}
float radius2=centered_screen_pos.x*centered_screen_pos.x
+ centered_screen_pos.y*centered_screen_pos.y;float radius=sqrt(radius2);vec4 original=texture2D(textureSampler,vUV);vec3 ref_indices=vec3(-0.3,0.0,0.3);float ref_shiftX=chromatic_aberration*pow(radius,radialIntensity)*directionOfEffect.x/screen_width;float ref_shiftY=chromatic_aberration*pow(radius,radialIntensity)*directionOfEffect.y/screen_height;vec2 ref_coords_r=vec2(vUV.x+ref_indices.r*ref_shiftX,vUV.y+ref_indices.r*ref_shiftY*0.5);vec2 ref_coords_g=vec2(vUV.x+ref_indices.g*ref_shiftX,vUV.y+ref_indices.g*ref_shiftY*0.5);vec2 ref_coords_b=vec2(vUV.x+ref_indices.b*ref_shiftX,vUV.y+ref_indices.b*ref_shiftY*0.5);original.r=texture2D(textureSampler,ref_coords_r).r;original.g=texture2D(textureSampler,ref_coords_g).g;original.b=texture2D(textureSampler,ref_coords_b).b;original.a=clamp(texture2D(textureSampler,ref_coords_r).a+texture2D(textureSampler,ref_coords_g).a+texture2D(textureSampler,ref_coords_b).a,0.,1.);gl_FragColor=original;}`;
    var am = function(n) {
      function t(e, i, r, o, a, s, l, c, u, h) {
        u === void 0 && (u = _.TEXTURETYPE_UNSIGNED_INT), h === void 0 && (h = !1);
        var d = n.call(this, e, "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], [], o, a, s, l, c, null, u, void 0, null, h) || this;
        return d.aberrationAmount = 30, d.radialIntensity = 0, d.direction = new fe(0.707, 0.707), d.centerPosition = new fe(0.5, 0.5), d.screenWidth = i, d.screenHeight = r, d.onApplyObservable.add(function(p) {
          p.setFloat("chromatic_aberration", d.aberrationAmount), p.setFloat("screen_width", i), p.setFloat("screen_height", r), p.setFloat("radialIntensity", d.radialIntensity), p.setFloat2("direction", d.direction.x, d.direction.y), p.setFloat2("centerPosition", d.centerPosition.x, d.centerPosition.y);
        }), d;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ChromaticAberrationPostProcess";
      }, t._Parse = function(e, i, r, o) {
        return Ne.Parse(function() {
          return new t(e.name, e.screenWidth, e.screenHeight, e.options, i, e.renderTargetSamplingMode, r.getEngine(), e.reusable, e.textureType, !1);
        }, e, r, o);
      }, x([N()], t.prototype, "aberrationAmount", void 0), x([N()], t.prototype, "radialIntensity", void 0), x([N()], t.prototype, "direction", void 0), x([N()], t.prototype, "centerPosition", void 0), x([N()], t.prototype, "screenWidth", void 0), x([N()], t.prototype, "screenHeight", void 0), t;
    }(nt);
    j("BABYLON.ChromaticAberrationPostProcess", am), re.ShadersStore.circleOfConfusionPixelShader = `uniform sampler2D depthSampler;varying vec2 vUV;uniform vec2 cameraMinMaxZ;uniform float focusDistance;uniform float cocPrecalculation;
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void)
{float depth=texture2D(depthSampler,vUV).r;
#define CUSTOM_COC_DEPTH
float pixelDistance=(cameraMinMaxZ.x+cameraMinMaxZ.y*depth)*1000.0; 
#define CUSTOM_COC_PIXELDISTANCE
float coc=abs(cocPrecalculation*((focusDistance-pixelDistance)/pixelDistance));coc=clamp(coc,0.0,1.0);gl_FragColor=vec4(coc,coc,coc,1.0);}
`;
    var sm = function(n) {
      function t(e, i, r, o, a, s, l, c, u) {
        c === void 0 && (c = _.TEXTURETYPE_UNSIGNED_INT), u === void 0 && (u = !1);
        var h = n.call(this, e, "circleOfConfusion", ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"], ["depthSampler"], r, o, a, s, l, null, c, void 0, null, u) || this;
        return h.lensSize = 50, h.fStop = 1.4, h.focusDistance = 2e3, h.focalLength = 50, h._depthTexture = null, h._depthTexture = i, h.onApplyObservable.add(function(d) {
          if (h._depthTexture) {
            d.setTexture("depthSampler", h._depthTexture);
            var p = h.lensSize / h.fStop * h.focalLength / (h.focusDistance - h.focalLength);
            d.setFloat("focusDistance", h.focusDistance), d.setFloat("cocPrecalculation", p);
            var f = h._depthTexture.activeCamera;
            d.setFloat2("cameraMinMaxZ", f.minZ, f.maxZ - f.minZ);
          } else
            q.Warn("No depth texture set on CircleOfConfusionPostProcess");
        }), h;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "CircleOfConfusionPostProcess";
      }, Object.defineProperty(t.prototype, "depthTexture", { set: function(e) {
        this._depthTexture = e;
      }, enumerable: !1, configurable: !0 }), x([N()], t.prototype, "lensSize", void 0), x([N()], t.prototype, "fStop", void 0), x([N()], t.prototype, "focusDistance", void 0), x([N()], t.prototype, "focalLength", void 0), t;
    }(nt);
    j("BABYLON.CircleOfConfusionPostProcess", sm), re.ShadersStore.colorCorrectionPixelShader = `uniform sampler2D textureSampler; 
uniform sampler2D colorTable; 
varying vec2 vUV;const float SLICE_COUNT=16.0; 
vec4 sampleAs3DTexture(sampler2D textureSampler,vec3 uv,float width) {float sliceSize=1.0/width; 
float slicePixelSize=sliceSize/width; 
float sliceInnerSize=slicePixelSize*(width-1.0); 
float zSlice0=min(floor(uv.z*width),width-1.0);float zSlice1=min(zSlice0+1.0,width-1.0);float xOffset=slicePixelSize*0.5+uv.x*sliceInnerSize;float s0=xOffset+(zSlice0*sliceSize);float s1=xOffset+(zSlice1*sliceSize);vec4 slice0Color=texture2D(textureSampler,vec2(s0,uv.y));vec4 slice1Color=texture2D(textureSampler,vec2(s1,uv.y));float zOffset=mod(uv.z*width,1.0);vec4 result=mix(slice0Color,slice1Color,zOffset);return result;}
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void)
{vec4 screen_color=texture2D(textureSampler,vUV);gl_FragColor=sampleAs3DTexture(colorTable,screen_color.rgb,SLICE_COUNT);}`;
    var eE = function(n) {
      function t(e, i, r, o, a, s, l) {
        var c = n.call(this, e, "colorCorrection", null, ["colorTable"], r, o, a, s, l) || this, u = (o == null ? void 0 : o.getScene()) || null;
        return c._colorTableTexture = new ae(i, u, !0, !1, ae.TRILINEAR_SAMPLINGMODE), c._colorTableTexture.anisotropicFilteringLevel = 1, c._colorTableTexture.wrapU = ae.CLAMP_ADDRESSMODE, c._colorTableTexture.wrapV = ae.CLAMP_ADDRESSMODE, c.colorTableUrl = i, c.onApply = function(h) {
          h.setTexture("colorTable", c._colorTableTexture);
        }, c;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ColorCorrectionPostProcess";
      }, t._Parse = function(e, i, r, o) {
        return Ne.Parse(function() {
          return new t(e.name, e.colorTableUrl, e.options, i, e.renderTargetSamplingMode, r.getEngine(), e.reusable);
        }, e, r, o);
      }, x([N()], t.prototype, "colorTableUrl", void 0), t;
    }(nt);
    j("BABYLON.ColorCorrectionPostProcess", eE), re.ShadersStore.convolutionPixelShader = `varying vec2 vUV;uniform sampler2D textureSampler;uniform vec2 screenSize;uniform float kernel[9];
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void)
{vec2 onePixel=vec2(1.0,1.0)/screenSize;vec4 colorSum =
texture2D(textureSampler,vUV+onePixel*vec2(-1,-1))*kernel[0] +
texture2D(textureSampler,vUV+onePixel*vec2(0,-1))*kernel[1] +
texture2D(textureSampler,vUV+onePixel*vec2(1,-1))*kernel[2] +
texture2D(textureSampler,vUV+onePixel*vec2(-1,0))*kernel[3] +
texture2D(textureSampler,vUV+onePixel*vec2(0,0))*kernel[4] +
texture2D(textureSampler,vUV+onePixel*vec2(1,0))*kernel[5] +
texture2D(textureSampler,vUV+onePixel*vec2(-1,1))*kernel[6] +
texture2D(textureSampler,vUV+onePixel*vec2(0,1))*kernel[7] +
texture2D(textureSampler,vUV+onePixel*vec2(1,1))*kernel[8];float kernelWeight =
kernel[0] +
kernel[1] +
kernel[2] +
kernel[3] +
kernel[4] +
kernel[5] +
kernel[6] +
kernel[7] +
kernel[8];if (kernelWeight<=0.0) {kernelWeight=1.0;}
gl_FragColor=vec4((colorSum/kernelWeight).rgb,1);}`;
    var tE = function(n) {
      function t(e, i, r, o, a, s, l, c) {
        c === void 0 && (c = _.TEXTURETYPE_UNSIGNED_INT);
        var u = n.call(this, e, "convolution", ["kernel", "screenSize"], null, r, o, a, s, l, null, c) || this;
        return u.kernel = i, u.onApply = function(h) {
          h.setFloat2("screenSize", u.width, u.height), h.setArray("kernel", u.kernel);
        }, u;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ConvolutionPostProcess";
      }, t._Parse = function(e, i, r, o) {
        return Ne.Parse(function() {
          return new t(e.name, e.kernel, e.options, i, e.renderTargetSamplingMode, r.getEngine(), e.reusable, e.textureType);
        }, e, r, o);
      }, t.EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1], t.EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0], t.EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1], t.SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0], t.EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2], t.GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0], x([N()], t.prototype, "kernel", void 0), t;
    }(nt);
    j("BABYLON.ConvolutionPostProcess", tE);
    var pd = function(n) {
      function t(e, i, r, o, a, s, l, c, u, h, d, p, f, m) {
        c === void 0 && (c = null), u === void 0 && (u = ae.BILINEAR_SAMPLINGMODE), p === void 0 && (p = _.TEXTURETYPE_UNSIGNED_INT), f === void 0 && (f = !1), m === void 0 && (m = _.TEXTUREFORMAT_RGBA);
        var g = n.call(this, e, r, o, a, s, u = _.TEXTURE_BILINEAR_SAMPLINGMODE, h, d, p, `#define DOF 1
`, f, m) || this;
        return g.direction = r, g.externalTextureSamplerBinding = !!c, g.onApplyObservable.add(function(y) {
          c != null && y.setTextureFromPostProcess("textureSampler", c), y.setTextureFromPostProcessOutput("circleOfConfusionSampler", l);
        }), g;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "DepthOfFieldBlurPostProcess";
      }, x([N()], t.prototype, "direction", void 0), t;
    }(Cn);
    j("BABYLON.DepthOfFieldBlurPostProcess", pd), re.ShadersStore.depthOfFieldMergePixelShader = `#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
#define TEXTUREFUNC(s,c,lod) texture2DLodEXT(s,c,lod)
#else
#define TEXTUREFUNC(s,c,bias) texture2D(s,c,bias)
#endif
uniform sampler2D textureSampler;varying vec2 vUV;uniform sampler2D circleOfConfusionSampler;uniform sampler2D blurStep0;
#if BLUR_LEVEL>0
uniform sampler2D blurStep1;
#endif
#if BLUR_LEVEL>1
uniform sampler2D blurStep2;
#endif
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void)
{float coc=TEXTUREFUNC(circleOfConfusionSampler,vUV,0.0).r;
#if BLUR_LEVEL==0
vec4 original=TEXTUREFUNC(textureSampler,vUV,0.0);vec4 blurred0=TEXTUREFUNC(blurStep0,vUV,0.0);gl_FragColor=mix(original,blurred0,coc);
#endif
#if BLUR_LEVEL==1
if(coc<0.5){vec4 original=TEXTUREFUNC(textureSampler,vUV,0.0);vec4 blurred1=TEXTUREFUNC(blurStep1,vUV,0.0);gl_FragColor=mix(original,blurred1,coc/0.5);}else{vec4 blurred0=TEXTUREFUNC(blurStep0,vUV,0.0);vec4 blurred1=TEXTUREFUNC(blurStep1,vUV,0.0);gl_FragColor=mix(blurred1,blurred0,(coc-0.5)/0.5);}
#endif
#if BLUR_LEVEL==2
if(coc<0.33){vec4 original=TEXTUREFUNC(textureSampler,vUV,0.0);vec4 blurred2=TEXTUREFUNC(blurStep2,vUV,0.0);gl_FragColor=mix(original,blurred2,coc/0.33);}else if(coc<0.66){vec4 blurred1=TEXTUREFUNC(blurStep1,vUV,0.0);vec4 blurred2=TEXTUREFUNC(blurStep2,vUV,0.0);gl_FragColor=mix(blurred2,blurred1,(coc-0.33)/0.33);}else{vec4 blurred0=TEXTUREFUNC(blurStep0,vUV,0.0);vec4 blurred1=TEXTUREFUNC(blurStep1,vUV,0.0);gl_FragColor=mix(blurred1,blurred0,(coc-0.66)/0.34);}
#endif
}
`;
    var Ds, iE = function(n) {
      function t(e, i, r, o, a, s, l, c, u, h, d) {
        h === void 0 && (h = _.TEXTURETYPE_UNSIGNED_INT), d === void 0 && (d = !1);
        var p = n.call(this, e, "depthOfFieldMerge", [], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2"], a, s, l, c, u, null, h, void 0, null, !0) || this;
        return p._blurSteps = o, p.externalTextureSamplerBinding = !0, p.onApplyObservable.add(function(f) {
          f.setTextureFromPostProcess("textureSampler", i), f.setTextureFromPostProcessOutput("circleOfConfusionSampler", r), o.forEach(function(m, g) {
            f.setTextureFromPostProcessOutput("blurStep" + (o.length - g - 1), m);
          });
        }), d || p.updateEffect(), p;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "DepthOfFieldMergePostProcess";
      }, t.prototype.updateEffect = function(e, i, r, o, a, s) {
        e === void 0 && (e = null), i === void 0 && (i = null), r === void 0 && (r = null), e || (e = "", e += "#define BLUR_LEVEL " + (this._blurSteps.length - 1) + `
`), n.prototype.updateEffect.call(this, e, i, r, o, a, s);
      }, t;
    }(nt);
    (function(n) {
      n[n.Low = 0] = "Low", n[n.Medium = 1] = "Medium", n[n.High = 2] = "High";
    })(Ds || (Ds = {}));
    var lm = function(n) {
      function t(e, i, r, o, a) {
        r === void 0 && (r = Ds.Low), o === void 0 && (o = 0), a === void 0 && (a = !1);
        var s = n.call(this, e.getEngine(), "depth of field", function() {
          return s._effects;
        }, !0) || this;
        s._effects = [];
        var l = e.getEngine(), c = l.isWebGPU || l.webGLVersion > 1 ? _.TEXTUREFORMAT_RED : _.TEXTUREFORMAT_RGBA;
        s._circleOfConfusion = new sm("circleOfConfusion", i, 1, null, ae.BILINEAR_SAMPLINGMODE, l, !1, o, a), s._depthOfFieldBlurY = [], s._depthOfFieldBlurX = [];
        var u = 1, h = 15;
        switch (r) {
          case Ds.High:
            u = 3, h = 51;
            break;
          case Ds.Medium:
            u = 2, h = 31;
            break;
          default:
            h = 15, u = 1;
        }
        for (var d = h / Math.pow(2, u - 1), p = 1, f = 0; f < u; f++) {
          var m = new pd("vertical blur", e, new fe(0, 1), d, p, null, s._circleOfConfusion, f == 0 ? s._circleOfConfusion : null, ae.BILINEAR_SAMPLINGMODE, l, !1, o, a, f == 0 ? c : _.TEXTUREFORMAT_RGBA);
          m.autoClear = !1, p = 0.75 / Math.pow(2, f);
          var g = new pd("horizontal blur", e, new fe(1, 0), d, p, null, s._circleOfConfusion, null, ae.BILINEAR_SAMPLINGMODE, l, !1, o, a);
          g.autoClear = !1, s._depthOfFieldBlurY.push(m), s._depthOfFieldBlurX.push(g);
        }
        for (s._effects = [s._circleOfConfusion], f = 0; f < s._depthOfFieldBlurX.length; f++)
          s._effects.push(s._depthOfFieldBlurY[f]), s._effects.push(s._depthOfFieldBlurX[f]);
        return s._dofMerge = new iE("dofMerge", s._circleOfConfusion, s._circleOfConfusion, s._depthOfFieldBlurX, p, null, ae.BILINEAR_SAMPLINGMODE, l, !1, o, a), s._dofMerge.autoClear = !1, s._effects.push(s._dofMerge), s;
      }
      return D(t, n), Object.defineProperty(t.prototype, "focalLength", { get: function() {
        return this._circleOfConfusion.focalLength;
      }, set: function(e) {
        this._circleOfConfusion.focalLength = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "fStop", { get: function() {
        return this._circleOfConfusion.fStop;
      }, set: function(e) {
        this._circleOfConfusion.fStop = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "focusDistance", { get: function() {
        return this._circleOfConfusion.focusDistance;
      }, set: function(e) {
        this._circleOfConfusion.focusDistance = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "lensSize", { get: function() {
        return this._circleOfConfusion.lensSize;
      }, set: function(e) {
        this._circleOfConfusion.lensSize = e;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "DepthOfFieldEffect";
      }, Object.defineProperty(t.prototype, "depthTexture", { set: function(e) {
        this._circleOfConfusion.depthTexture = e;
      }, enumerable: !1, configurable: !0 }), t.prototype.disposeEffects = function(e) {
        for (var i = 0; i < this._effects.length; i++)
          this._effects[i].dispose(e);
      }, t.prototype._updateEffects = function() {
        for (var e = 0; e < this._effects.length; e++)
          this._effects[e].updateEffect();
      }, t.prototype._isReady = function() {
        for (var e = 0; e < this._effects.length; e++)
          if (!this._effects[e].isReady())
            return !1;
        return !0;
      }, t;
    }(Vt);
    re.ShadersStore.displayPassPixelShader = `varying vec2 vUV;uniform sampler2D textureSampler;uniform sampler2D passSampler;
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void)
{gl_FragColor=texture2D(passSampler,vUV);}`;
    var nE = function(n) {
      function t(e, i, r, o, a, s) {
        return n.call(this, e, "displayPass", ["passSampler"], ["passSampler"], i, r, o, a, s) || this;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "DisplayPassPostProcess";
      }, t._Parse = function(e, i, r, o) {
        return Ne.Parse(function() {
          return new t(e.name, e.options, i, e.renderTargetSamplingMode, r.getEngine(), e.reusable);
        }, e, r, o);
      }, t;
    }(nt);
    j("BABYLON.DisplayPassPostProcess", nE), re.ShadersStore.filterPixelShader = `varying vec2 vUV;uniform sampler2D textureSampler;uniform mat4 kernelMatrix;
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void)
{vec3 baseColor=texture2D(textureSampler,vUV).rgb;vec3 updatedColor=(kernelMatrix*vec4(baseColor,1.0)).rgb;gl_FragColor=vec4(updatedColor,1.0);}`;
    var rE = function(n) {
      function t(e, i, r, o, a, s, l) {
        var c = n.call(this, e, "filter", ["kernelMatrix"], null, r, o, a, s, l) || this;
        return c.kernelMatrix = i, c.onApply = function(u) {
          u.setMatrix("kernelMatrix", c.kernelMatrix);
        }, c;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "FilterPostProcess";
      }, t._Parse = function(e, i, r, o) {
        return Ne.Parse(function() {
          return new t(e.name, e.kernelMatrix, e.options, i, e.renderTargetSamplingMode, r.getEngine(), e.reusable);
        }, e, r, o);
      }, x([cs()], t.prototype, "kernelMatrix", void 0), t;
    }(nt);
    j("BABYLON.FilterPostProcess", rE), re.ShadersStore.fxaaPixelShader = `#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
#define TEXTUREFUNC(s,c,l) texture2DLodEXT(s,c,l)
#else
#define TEXTUREFUNC(s,c,b) texture2D(s,c,b)
#endif
uniform sampler2D textureSampler;uniform vec2 texelSize;varying vec2 vUV;varying vec2 sampleCoordS;varying vec2 sampleCoordE;varying vec2 sampleCoordN;varying vec2 sampleCoordW;varying vec2 sampleCoordNW;varying vec2 sampleCoordSE;varying vec2 sampleCoordNE;varying vec2 sampleCoordSW;const float fxaaQualitySubpix=1.0;const float fxaaQualityEdgeThreshold=0.166;const float fxaaQualityEdgeThresholdMin=0.0833;const vec3 kLumaCoefficients=vec3(0.2126,0.7152,0.0722);
#define FxaaLuma(rgba) dot(rgba.rgb,kLumaCoefficients)
void main(){vec2 posM;posM.x=vUV.x;posM.y=vUV.y;vec4 rgbyM=TEXTUREFUNC(textureSampler,vUV,0.0);float lumaM=FxaaLuma(rgbyM);float lumaS=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordS,0.0));float lumaE=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordE,0.0));float lumaN=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordN,0.0));float lumaW=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordW,0.0));float maxSM=max(lumaS,lumaM);float minSM=min(lumaS,lumaM);float maxESM=max(lumaE,maxSM);float minESM=min(lumaE,minSM);float maxWN=max(lumaN,lumaW);float minWN=min(lumaN,lumaW);float rangeMax=max(maxWN,maxESM);float rangeMin=min(minWN,minESM);float rangeMaxScaled=rangeMax*fxaaQualityEdgeThreshold;float range=rangeMax-rangeMin;float rangeMaxClamped=max(fxaaQualityEdgeThresholdMin,rangeMaxScaled);
#ifndef MALI
if(range<rangeMaxClamped) 
{gl_FragColor=rgbyM;return;}
#endif
float lumaNW=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordNW,0.0));float lumaSE=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordSE,0.0));float lumaNE=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordNE,0.0));float lumaSW=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordSW,0.0));float lumaNS=lumaN+lumaS;float lumaWE=lumaW+lumaE;float subpixRcpRange=1.0/range;float subpixNSWE=lumaNS+lumaWE;float edgeHorz1=(-2.0*lumaM)+lumaNS;float edgeVert1=(-2.0*lumaM)+lumaWE;float lumaNESE=lumaNE+lumaSE;float lumaNWNE=lumaNW+lumaNE;float edgeHorz2=(-2.0*lumaE)+lumaNESE;float edgeVert2=(-2.0*lumaN)+lumaNWNE;float lumaNWSW=lumaNW+lumaSW;float lumaSWSE=lumaSW+lumaSE;float edgeHorz4=(abs(edgeHorz1)*2.0)+abs(edgeHorz2);float edgeVert4=(abs(edgeVert1)*2.0)+abs(edgeVert2);float edgeHorz3=(-2.0*lumaW)+lumaNWSW;float edgeVert3=(-2.0*lumaS)+lumaSWSE;float edgeHorz=abs(edgeHorz3)+edgeHorz4;float edgeVert=abs(edgeVert3)+edgeVert4;float subpixNWSWNESE=lumaNWSW+lumaNESE;float lengthSign=texelSize.x;bool horzSpan=edgeHorz>=edgeVert;float subpixA=subpixNSWE*2.0+subpixNWSWNESE;if (!horzSpan)
{lumaN=lumaW;}
if (!horzSpan) 
{lumaS=lumaE;}
if (horzSpan) 
{lengthSign=texelSize.y;}
float subpixB=(subpixA*(1.0/12.0))-lumaM;float gradientN=lumaN-lumaM;float gradientS=lumaS-lumaM;float lumaNN=lumaN+lumaM;float lumaSS=lumaS+lumaM;bool pairN=abs(gradientN)>=abs(gradientS);float gradient=max(abs(gradientN),abs(gradientS));if (pairN)
{lengthSign=-lengthSign;}
float subpixC=clamp(abs(subpixB)*subpixRcpRange,0.0,1.0);vec2 posB;posB.x=posM.x;posB.y=posM.y;vec2 offNP;offNP.x=(!horzSpan) ? 0.0 : texelSize.x;offNP.y=(horzSpan) ? 0.0 : texelSize.y;if (!horzSpan) 
{posB.x+=lengthSign*0.5;}
if (horzSpan)
{posB.y+=lengthSign*0.5;}
vec2 posN;posN.x=posB.x-offNP.x*1.5;posN.y=posB.y-offNP.y*1.5;vec2 posP;posP.x=posB.x+offNP.x*1.5;posP.y=posB.y+offNP.y*1.5;float subpixD=((-2.0)*subpixC)+3.0;float lumaEndN=FxaaLuma(TEXTUREFUNC(textureSampler,posN,0.0));float subpixE=subpixC*subpixC;float lumaEndP=FxaaLuma(TEXTUREFUNC(textureSampler,posP,0.0));if (!pairN) 
{lumaNN=lumaSS;}
float gradientScaled=gradient*1.0/4.0;float lumaMM=lumaM-lumaNN*0.5;float subpixF=subpixD*subpixE;bool lumaMLTZero=lumaMM<0.0;lumaEndN-=lumaNN*0.5;lumaEndP-=lumaNN*0.5;bool doneN=abs(lumaEndN)>=gradientScaled;bool doneP=abs(lumaEndP)>=gradientScaled;if (!doneN) 
{posN.x-=offNP.x*3.0;}
if (!doneN) 
{posN.y-=offNP.y*3.0;}
bool doneNP=(!doneN) || (!doneP);if (!doneP) 
{posP.x+=offNP.x*3.0;}
if (!doneP)
{posP.y+=offNP.y*3.0;}
if (doneNP)
{if (!doneN) lumaEndN=FxaaLuma(TEXTUREFUNC(textureSampler,posN.xy,0.0));if (!doneP) lumaEndP=FxaaLuma(TEXTUREFUNC(textureSampler,posP.xy,0.0));if (!doneN) lumaEndN=lumaEndN-lumaNN*0.5;if (!doneP) lumaEndP=lumaEndP-lumaNN*0.5;doneN=abs(lumaEndN)>=gradientScaled;doneP=abs(lumaEndP)>=gradientScaled;if (!doneN) posN.x-=offNP.x*12.0;if (!doneN) posN.y-=offNP.y*12.0;doneNP=(!doneN) || (!doneP);if (!doneP) posP.x+=offNP.x*12.0;if (!doneP) posP.y+=offNP.y*12.0;}
float dstN=posM.x-posN.x;float dstP=posP.x-posM.x;if (!horzSpan)
{dstN=posM.y-posN.y;}
if (!horzSpan) 
{dstP=posP.y-posM.y;}
bool goodSpanN=(lumaEndN<0.0) != lumaMLTZero;float spanLength=(dstP+dstN);bool goodSpanP=(lumaEndP<0.0) != lumaMLTZero;float spanLengthRcp=1.0/spanLength;bool directionN=dstN<dstP;float dst=min(dstN,dstP);bool goodSpan=directionN ? goodSpanN : goodSpanP;float subpixG=subpixF*subpixF;float pixelOffset=(dst*(-spanLengthRcp))+0.5;float subpixH=subpixG*fxaaQualitySubpix;float pixelOffsetGood=goodSpan ? pixelOffset : 0.0;float pixelOffsetSubpix=max(pixelOffsetGood,subpixH);if (!horzSpan)
{posM.x+=pixelOffsetSubpix*lengthSign;}
if (horzSpan)
{posM.y+=pixelOffsetSubpix*lengthSign;}
#ifdef MALI
if(range<rangeMaxClamped) 
{gl_FragColor=rgbyM;}
else
{gl_FragColor=TEXTUREFUNC(textureSampler,posM,0.0);}
#else
gl_FragColor=TEXTUREFUNC(textureSampler,posM,0.0);
#endif
}`, re.ShadersStore.fxaaVertexShader = `attribute vec2 position;uniform vec2 texelSize;varying vec2 vUV;varying vec2 sampleCoordS;varying vec2 sampleCoordE;varying vec2 sampleCoordN;varying vec2 sampleCoordW;varying vec2 sampleCoordNW;varying vec2 sampleCoordSE;varying vec2 sampleCoordNE;varying vec2 sampleCoordSW;const vec2 madd=vec2(0.5,0.5);
#define CUSTOM_VERTEX_DEFINITIONS
void main(void) {
#define CUSTOM_VERTEX_MAIN_BEGIN
vUV=(position*madd+madd);sampleCoordS=vUV+vec2( 0.0,1.0)*texelSize;sampleCoordE=vUV+vec2( 1.0,0.0)*texelSize;sampleCoordN=vUV+vec2( 0.0,-1.0)*texelSize;sampleCoordW=vUV+vec2(-1.0,0.0)*texelSize;sampleCoordNW=vUV+vec2(-1.0,-1.0)*texelSize;sampleCoordSE=vUV+vec2( 1.0,1.0)*texelSize;sampleCoordNE=vUV+vec2( 1.0,-1.0)*texelSize;sampleCoordSW=vUV+vec2(-1.0,1.0)*texelSize;gl_Position=vec4(position,0.0,1.0);
#define CUSTOM_VERTEX_MAIN_END
}`;
    var hu = function(n) {
      function t(e, i, r, o, a, s, l) {
        r === void 0 && (r = null), l === void 0 && (l = _.TEXTURETYPE_UNSIGNED_INT);
        var c = n.call(this, e, "fxaa", ["texelSize"], null, i, r, o || ae.BILINEAR_SAMPLINGMODE, a, s, null, l, "fxaa", void 0, !0) || this, u = c._getDefines();
        return c.updateEffect(u), c.onApplyObservable.add(function(h) {
          var d = c.texelSize;
          h.setFloat2("texelSize", d.x, d.y);
        }), c;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "FxaaPostProcess";
      }, t.prototype._getDefines = function() {
        var e = this.getEngine();
        if (!e)
          return null;
        var i = e.getGlInfo();
        return i && i.renderer && i.renderer.toLowerCase().indexOf("mali") > -1 ? `#define MALI 1
` : null;
      }, t._Parse = function(e, i, r, o) {
        return Ne.Parse(function() {
          return new t(e.name, e.options, i, e.renderTargetSamplingMode, r.getEngine(), e.reusable);
        }, e, r, o);
      }, t;
    }(nt);
    j("BABYLON.FxaaPostProcess", hu), re.ShadersStore.grainPixelShader = `#include<helperFunctions>
uniform sampler2D textureSampler; 
uniform float intensity;uniform float animatedSeed;varying vec2 vUV;
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void)
{gl_FragColor=texture2D(textureSampler,vUV);vec2 seed=vUV*(animatedSeed);float grain=dither(seed,intensity);float lum=getLuminance(gl_FragColor.rgb);float grainAmount=(cos(-PI+(lum*PI*2.))+1.)/2.;gl_FragColor.rgb+=grain*grainAmount;gl_FragColor.rgb=max(gl_FragColor.rgb,0.0);}`;
    var cm = function(n) {
      function t(e, i, r, o, a, s, l, c) {
        l === void 0 && (l = _.TEXTURETYPE_UNSIGNED_INT), c === void 0 && (c = !1);
        var u = n.call(this, e, "grain", ["intensity", "animatedSeed"], [], i, r, o, a, s, null, l, void 0, null, c) || this;
        return u.intensity = 30, u.animated = !1, u.onApplyObservable.add(function(h) {
          h.setFloat("intensity", u.intensity), h.setFloat("animatedSeed", u.animated ? Math.random() + 1 : 1);
        }), u;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "GrainPostProcess";
      }, t._Parse = function(e, i, r, o) {
        return Ne.Parse(function() {
          return new t(e.name, e.options, i, e.renderTargetSamplingMode, r.getEngine(), e.reusable);
        }, e, r, o);
      }, x([N()], t.prototype, "intensity", void 0), x([N()], t.prototype, "animated", void 0), t;
    }(nt);
    j("BABYLON.GrainPostProcess", cm), re.ShadersStore.highlightsPixelShader = `varying vec2 vUV;uniform sampler2D textureSampler;const vec3 RGBLuminanceCoefficients=vec3(0.2126,0.7152,0.0722);
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void) 
{vec4 tex=texture2D(textureSampler,vUV);vec3 c=tex.rgb;float luma=dot(c.rgb,RGBLuminanceCoefficients);gl_FragColor=vec4(pow(c,vec3(25.0-luma*15.0)),tex.a); }`;
    var rI = function(n) {
      function t(e, i, r, o, a, s, l) {
        return l === void 0 && (l = _.TEXTURETYPE_UNSIGNED_INT), n.call(this, e, "highlights", null, null, i, r, o, a, s, null, l) || this;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "HighlightsPostProcess";
      }, t;
    }(nt);
    re.ShadersStore.imageProcessingPixelShader = `varying vec2 vUV;uniform sampler2D textureSampler;
#include<imageProcessingDeclaration>
#include<helperFunctions>
#include<imageProcessingFunctions>
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void)
{vec4 result=texture2D(textureSampler,vUV);
#ifdef IMAGEPROCESSING
#ifndef FROMLINEARSPACE
result.rgb=toLinearSpace(result.rgb);
#endif
result=applyImageProcessing(result);
#else
#ifdef FROMLINEARSPACE
result=applyImageProcessing(result);
#endif
#endif
gl_FragColor=result;}`;
    var um = function(n) {
      function t(e, i, r, o, a, s, l, c) {
        r === void 0 && (r = null), l === void 0 && (l = _.TEXTURETYPE_UNSIGNED_INT);
        var u = n.call(this, e, "imageProcessing", [], [], i, r, o, a, s, null, l, "postprocess", null, !0) || this;
        return u._fromLinearSpace = !0, u._defines = { IMAGEPROCESSING: !1, VIGNETTE: !1, VIGNETTEBLENDMODEMULTIPLY: !1, VIGNETTEBLENDMODEOPAQUE: !1, TONEMAPPING: !1, TONEMAPPING_ACES: !1, CONTRAST: !1, COLORCURVES: !1, COLORGRADING: !1, COLORGRADING3D: !1, FROMLINEARSPACE: !1, SAMPLER3DGREENDEPTH: !1, SAMPLER3DBGRMAP: !1, DITHER: !1, IMAGEPROCESSINGPOSTPROCESS: !1, EXPOSURE: !1, SKIPFINALCOLORCLAMP: !1 }, c ? (c.applyByPostProcess = !0, u._attachImageProcessingConfiguration(c, !0), u._updateParameters()) : (u._attachImageProcessingConfiguration(null, !0), u.imageProcessingConfiguration.applyByPostProcess = !0), u.onApply = function(h) {
          u.imageProcessingConfiguration.bind(h, u.aspectRatio);
        }, u;
      }
      return D(t, n), Object.defineProperty(t.prototype, "imageProcessingConfiguration", { get: function() {
        return this._imageProcessingConfiguration;
      }, set: function(e) {
        e.applyByPostProcess = !0, this._attachImageProcessingConfiguration(e);
      }, enumerable: !1, configurable: !0 }), t.prototype._attachImageProcessingConfiguration = function(e, i) {
        var r = this;
        if (i === void 0 && (i = !1), e !== this._imageProcessingConfiguration) {
          if (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver), e)
            this._imageProcessingConfiguration = e;
          else {
            var o = null, a = this.getEngine(), s = this.getCamera();
            if (s)
              o = s.getScene();
            else if (a && a.scenes) {
              var l = a.scenes;
              o = l[l.length - 1];
            } else
              o = Me.LastCreatedScene;
            this._imageProcessingConfiguration = o ? o.imageProcessingConfiguration : new tn();
          }
          this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function() {
            r._updateParameters();
          })), i || this._updateParameters();
        }
      }, Object.defineProperty(t.prototype, "isSupported", { get: function() {
        var e = this.getEffect();
        return !e || e.isSupported;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "colorCurves", { get: function() {
        return this.imageProcessingConfiguration.colorCurves;
      }, set: function(e) {
        this.imageProcessingConfiguration.colorCurves = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "colorCurvesEnabled", { get: function() {
        return this.imageProcessingConfiguration.colorCurvesEnabled;
      }, set: function(e) {
        this.imageProcessingConfiguration.colorCurvesEnabled = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "colorGradingTexture", { get: function() {
        return this.imageProcessingConfiguration.colorGradingTexture;
      }, set: function(e) {
        this.imageProcessingConfiguration.colorGradingTexture = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "colorGradingEnabled", { get: function() {
        return this.imageProcessingConfiguration.colorGradingEnabled;
      }, set: function(e) {
        this.imageProcessingConfiguration.colorGradingEnabled = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "exposure", { get: function() {
        return this.imageProcessingConfiguration.exposure;
      }, set: function(e) {
        this.imageProcessingConfiguration.exposure = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "toneMappingEnabled", { get: function() {
        return this._imageProcessingConfiguration.toneMappingEnabled;
      }, set: function(e) {
        this._imageProcessingConfiguration.toneMappingEnabled = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "toneMappingType", { get: function() {
        return this._imageProcessingConfiguration.toneMappingType;
      }, set: function(e) {
        this._imageProcessingConfiguration.toneMappingType = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "contrast", { get: function() {
        return this.imageProcessingConfiguration.contrast;
      }, set: function(e) {
        this.imageProcessingConfiguration.contrast = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "vignetteStretch", { get: function() {
        return this.imageProcessingConfiguration.vignetteStretch;
      }, set: function(e) {
        this.imageProcessingConfiguration.vignetteStretch = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "vignetteCentreX", { get: function() {
        return this.imageProcessingConfiguration.vignetteCenterX;
      }, set: function(e) {
        this.imageProcessingConfiguration.vignetteCenterX = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "vignetteCentreY", { get: function() {
        return this.imageProcessingConfiguration.vignetteCenterY;
      }, set: function(e) {
        this.imageProcessingConfiguration.vignetteCenterY = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "vignetteCenterY", { get: function() {
        return this.imageProcessingConfiguration.vignetteCenterY;
      }, set: function(e) {
        this.imageProcessingConfiguration.vignetteCenterY = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "vignetteCenterX", { get: function() {
        return this.imageProcessingConfiguration.vignetteCenterX;
      }, set: function(e) {
        this.imageProcessingConfiguration.vignetteCenterX = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "vignetteWeight", { get: function() {
        return this.imageProcessingConfiguration.vignetteWeight;
      }, set: function(e) {
        this.imageProcessingConfiguration.vignetteWeight = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "vignetteColor", { get: function() {
        return this.imageProcessingConfiguration.vignetteColor;
      }, set: function(e) {
        this.imageProcessingConfiguration.vignetteColor = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "vignetteCameraFov", { get: function() {
        return this.imageProcessingConfiguration.vignetteCameraFov;
      }, set: function(e) {
        this.imageProcessingConfiguration.vignetteCameraFov = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "vignetteBlendMode", { get: function() {
        return this.imageProcessingConfiguration.vignetteBlendMode;
      }, set: function(e) {
        this.imageProcessingConfiguration.vignetteBlendMode = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "vignetteEnabled", { get: function() {
        return this.imageProcessingConfiguration.vignetteEnabled;
      }, set: function(e) {
        this.imageProcessingConfiguration.vignetteEnabled = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "ditheringIntensity", { get: function() {
        return this.imageProcessingConfiguration.ditheringIntensity;
      }, set: function(e) {
        this.imageProcessingConfiguration.ditheringIntensity = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "ditheringEnabled", { get: function() {
        return this.imageProcessingConfiguration.ditheringEnabled;
      }, set: function(e) {
        this.imageProcessingConfiguration.ditheringEnabled = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "fromLinearSpace", { get: function() {
        return this._fromLinearSpace;
      }, set: function(e) {
        this._fromLinearSpace !== e && (this._fromLinearSpace = e, this._updateParameters());
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "ImageProcessingPostProcess";
      }, t.prototype._updateParameters = function() {
        this._defines.FROMLINEARSPACE = this._fromLinearSpace, this.imageProcessingConfiguration.prepareDefines(this._defines, !0);
        var e = "";
        for (var i in this._defines)
          this._defines[i] && (e += "#define ".concat(i, `;
`));
        var r = ["textureSampler"], o = ["scale"];
        tn && (tn.PrepareSamplers(r, this._defines), tn.PrepareUniforms(o, this._defines)), this.updateEffect(e, o, r);
      }, t.prototype.dispose = function(e) {
        n.prototype.dispose.call(this, e), this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver), this._imageProcessingConfiguration && (this.imageProcessingConfiguration.applyByPostProcess = !1);
      }, x([N()], t.prototype, "_fromLinearSpace", void 0), t;
    }(nt);
    re.IncludesShadersStore.mrtFragmentDeclaration = `#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
layout(location=0) out vec4 glFragData[{X}];
#endif
`, re.ShadersStore.geometryPixelShader = `#extension GL_EXT_draw_buffers : require
#if defined(BUMP) || !defined(NORMAL)
#extension GL_OES_standard_derivatives : enable
#endif
precision highp float;
#ifdef BUMP
varying mat4 vWorldView;varying vec3 vNormalW;
#else
varying vec3 vNormalV;
#endif
varying vec4 vViewPos;
#if defined(POSITION) || defined(BUMP)
varying vec3 vPositionW;
#endif
#ifdef VELOCITY
varying vec4 vCurrentPosition;varying vec4 vPreviousPosition;
#endif
#ifdef NEED_UV
varying vec2 vUV;
#endif
#ifdef BUMP
uniform vec3 vBumpInfos;uniform vec2 vTangentSpaceParams;
#endif
#if defined(REFLECTIVITY)
#if defined(ORMTEXTURE) || defined(SPECULARGLOSSINESSTEXTURE) || defined(REFLECTIVITYTEXTURE)
uniform sampler2D reflectivitySampler;varying vec2 vReflectivityUV;
#endif
#ifdef ALBEDOTEXTURE
varying vec2 vAlbedoUV;uniform sampler2D albedoSampler;
#endif
#ifdef REFLECTIVITYCOLOR
uniform vec3 reflectivityColor;
#endif
#ifdef ALBEDOCOLOR
uniform vec3 albedoColor;
#endif
#ifdef METALLIC
uniform float metallic;
#endif
#if defined(ROUGHNESS) || defined(GLOSSINESS)
uniform float glossiness;
#endif
#endif
#if defined(ALPHATEST) && defined(NEED_UV)
uniform sampler2D diffuseSampler;
#endif
#include<clipPlaneFragmentDeclaration>
#include<mrtFragmentDeclaration>[RENDER_TARGET_COUNT]
#include<bumpFragmentMainFunctions>
#include<bumpFragmentFunctions>
#include<helperFunctions>
void main() {
#include<clipPlaneFragment>
#ifdef ALPHATEST
if (texture2D(diffuseSampler,vUV).a<0.4)
discard;
#endif
vec3 normalOutput;
#ifdef BUMP
vec3 normalW=normalize(vNormalW);
#include<bumpFragment>
#ifdef NORMAL_WORLDSPACE
normalOutput=normalW;
#else
normalOutput=normalize(vec3(vWorldView*vec4(normalW,0.0)));
#endif
#else
normalOutput=normalize(vNormalV);
#endif
#ifdef PREPASS
#ifdef PREPASS_DEPTH
gl_FragData[DEPTH_INDEX]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);
#endif
#ifdef PREPASS_NORMAL
gl_FragData[NORMAL_INDEX]=vec4(normalOutput,1.0);
#endif
#else
gl_FragData[0]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);gl_FragData[1]=vec4(normalOutput,1.0);
#endif
#ifdef POSITION
gl_FragData[POSITION_INDEX]=vec4(vPositionW,1.0);
#endif
#ifdef VELOCITY
vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;vec2 velocity=abs(a-b);velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;gl_FragData[VELOCITY_INDEX]=vec4(velocity,0.0,1.0);
#endif
#ifdef REFLECTIVITY
vec4 reflectivity=vec4(0.0,0.0,0.0,1.0);
#ifdef METALLICWORKFLOW
float metal=1.0;float roughness=1.0;
#ifdef ORMTEXTURE
metal*=texture2D(reflectivitySampler,vReflectivityUV).b;roughness*=texture2D(reflectivitySampler,vReflectivityUV).g;
#endif
#ifdef METALLIC
metal*=metallic;
#endif
#ifdef ROUGHNESS
roughness*=(1.0-glossiness); 
#endif
reflectivity.a-=roughness;vec3 color=vec3(1.0);
#ifdef ALBEDOTEXTURE
color=texture2D(albedoSampler,vAlbedoUV).rgb;
#ifdef GAMMAALBEDO
color=toLinearSpace(color);
#endif
#endif
#ifdef ALBEDOCOLOR
color*=albedoColor.xyz;
#endif
reflectivity.rgb=mix(vec3(0.04),color,metal);
#else
#if defined(SPECULARGLOSSINESSTEXTURE) || defined(REFLECTIVITYTEXTURE)
reflectivity=texture2D(reflectivitySampler,vReflectivityUV);
#ifdef GAMMAREFLECTIVITYTEXTURE
reflectivity.rgb=toLinearSpace(reflectivity.rgb);
#endif
#else 
#ifdef REFLECTIVITYCOLOR
reflectivity.rgb=toLinearSpace(reflectivityColor.xyz);reflectivity.a=1.0;
#endif
#endif
#ifdef GLOSSINESSS
reflectivity.a*=glossiness; 
#endif
#endif
gl_FragData[REFLECTIVITY_INDEX]=reflectivity;
#endif
}
`, re.IncludesShadersStore.geometryVertexDeclaration = "uniform mat4 viewProjection;uniform mat4 view;", re.IncludesShadersStore.geometryUboDeclaration = `#include<sceneUboDeclaration>
`, re.ShadersStore.geometryVertexShader = `precision highp float;
#include<bonesDeclaration>
#include<bakedVertexAnimationDeclaration>
#include<morphTargetsVertexGlobalDeclaration>
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
#include<instancesDeclaration>
#include<__decl__geometryVertex>
#include<clipPlaneVertexDeclaration>
attribute vec3 position;attribute vec3 normal;
#ifdef NEED_UV
varying vec2 vUV;
#ifdef ALPHATEST
uniform mat4 diffuseMatrix;
#endif
#ifdef BUMP
uniform mat4 bumpMatrix;varying vec2 vBumpUV;
#endif
#ifdef REFLECTIVITY
uniform mat4 reflectivityMatrix;uniform mat4 albedoMatrix;varying vec2 vReflectivityUV;varying vec2 vAlbedoUV;
#endif
#ifdef UV1
attribute vec2 uv;
#endif
#ifdef UV2
attribute vec2 uv2;
#endif
#endif
#ifdef BUMP
varying mat4 vWorldView;
#endif
#ifdef BUMP
varying vec3 vNormalW;
#else
varying vec3 vNormalV;
#endif
varying vec4 vViewPos;
#if defined(POSITION) || defined(BUMP)
varying vec3 vPositionW;
#endif
#ifdef VELOCITY
uniform mat4 previousViewProjection;varying vec4 vCurrentPosition;varying vec4 vPreviousPosition;
#endif
#define CUSTOM_VERTEX_DEFINITIONS
void main(void)
{vec3 positionUpdated=position;vec3 normalUpdated=normal;
#ifdef UV1
vec2 uvUpdated=uv;
#endif
#include<morphTargetsVertexGlobal>
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
#include<instancesVertex>
#if defined(VELOCITY) && !defined(BONES_VELOCITY_ENABLED)
vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);
#endif
#include<bonesVertex>
#include<bakedVertexAnimation>
vec4 worldPos=vec4(finalWorld*vec4(positionUpdated,1.0));
#ifdef BUMP
vWorldView=view*finalWorld;vNormalW=normalUpdated;
#else
#ifdef NORMAL_WORLDSPACE
vNormalV=normalize(vec3(finalWorld*vec4(normalUpdated,0.0)));
#else
vNormalV=normalize(vec3((view*finalWorld)*vec4(normalUpdated,0.0)));
#endif
#endif
vViewPos=view*worldPos;
#if defined(VELOCITY) && defined(BONES_VELOCITY_ENABLED)
vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);
#if NUM_BONE_INFLUENCERS>0
mat4 previousInfluence;previousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];
#if NUM_BONE_INFLUENCERS>1
previousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];
#endif
#if NUM_BONE_INFLUENCERS>2
previousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];
#endif
#if NUM_BONE_INFLUENCERS>3
previousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];
#endif
#if NUM_BONE_INFLUENCERS>4
previousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];
#endif
#if NUM_BONE_INFLUENCERS>5
previousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];
#endif
#if NUM_BONE_INFLUENCERS>6
previousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];
#endif
#if NUM_BONE_INFLUENCERS>7
previousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];
#endif
vPreviousPosition=previousViewProjection*finalPreviousWorld*previousInfluence*vec4(positionUpdated,1.0);
#else
vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);
#endif
#endif
#if defined(POSITION) || defined(BUMP)
vPositionW=worldPos.xyz/worldPos.w;
#endif
gl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);
#include<clipPlaneVertex>
#ifdef NEED_UV
#ifdef UV1
#if defined(ALPHATEST) && defined(ALPHATEST_UV1)
vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
#else
vUV=uv;
#endif
#ifdef BUMP_UV1
vBumpUV=vec2(bumpMatrix*vec4(uvUpdated,1.0,0.0));
#endif
#ifdef REFLECTIVITY_UV1
vReflectivityUV=vec2(reflectivityMatrix*vec4(uvUpdated,1.0,0.0));
#endif
#ifdef ALBEDO_UV1
vAlbedoUV=vec2(albedoMatrix*vec4(uvUpdated,1.0,0.0));
#endif
#endif
#ifdef UV2
#if defined(ALPHATEST) && defined(ALPHATEST_UV2)
vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
#else
vUV=uv2;
#endif
#ifdef BUMP_UV2
vBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));
#endif
#ifdef REFLECTIVITY_UV2
vReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));
#endif
#ifdef ALBEDO_UV2
vAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));
#endif
#endif
#endif
#include<bumpVertex>
}
`;
    var oI = ["world", "mBones", "viewProjection", "diffuseMatrix", "view", "previousWorld", "previousViewProjection", "mPreviousBones", "bumpMatrix", "reflectivityMatrix", "albedoMatrix", "reflectivityColor", "albedoColor", "metallic", "glossiness", "vTangentSpaceParams", "vBumpInfos", "morphTargetInfluences", "morphTargetTextureInfo", "morphTargetTextureIndices", "boneTextureWidth"];
    Br(oI);
    var mr = function() {
      function n(t, e, i) {
        e === void 0 && (e = 1), i === void 0 && (i = _.TEXTUREFORMAT_DEPTH16), this._previousTransformationMatrices = {}, this._previousBonesTransformationMatrices = {}, this.excludedSkinnedMeshesFromVelocity = [], this.renderTransparentMeshes = !0, this.generateNormalsInWorldSpace = !1, this._resizeObserver = null, this._enablePosition = !1, this._enableVelocity = !1, this._enableReflectivity = !1, this._clearColor = new Ie(0, 0, 0, 0), this._clearDepthColor = new Ie(1e8, 0, 0, 1), this._positionIndex = -1, this._velocityIndex = -1, this._reflectivityIndex = -1, this._depthIndex = -1, this._normalIndex = -1, this._linkedWithPrePass = !1, this.useSpecificClearForDepthTexture = !1, this._scene = t, this._ratioOrDimensions = e, this._useUbo = t.getEngine().supportsUniformBuffers, this._depthFormat = i, n._SceneComponentInitialization(this._scene), this._createRenderTargets();
      }
      return n.prototype._linkPrePassRenderer = function(t) {
        this._linkedWithPrePass = !0, this._prePassRenderer = t, this._multiRenderTarget && (this._multiRenderTarget.onClearObservable.clear(), this._multiRenderTarget.onClearObservable.add(function() {
        }));
      }, n.prototype._unlinkPrePassRenderer = function() {
        this._linkedWithPrePass = !1, this._createRenderTargets();
      }, n.prototype._resetLayout = function() {
        this._enablePosition = !1, this._enableReflectivity = !1, this._enableVelocity = !1, this._attachmentsFromPrePass = [];
      }, n.prototype._forceTextureType = function(t, e) {
        t === n.POSITION_TEXTURE_TYPE ? (this._positionIndex = e, this._enablePosition = !0) : t === n.VELOCITY_TEXTURE_TYPE ? (this._velocityIndex = e, this._enableVelocity = !0) : t === n.REFLECTIVITY_TEXTURE_TYPE ? (this._reflectivityIndex = e, this._enableReflectivity = !0) : t === n.DEPTH_TEXTURE_TYPE ? this._depthIndex = e : t === n.NORMAL_TEXTURE_TYPE && (this._normalIndex = e);
      }, n.prototype._setAttachments = function(t) {
        this._attachmentsFromPrePass = t;
      }, n.prototype._linkInternalTexture = function(t) {
        this._multiRenderTarget.setInternalTexture(t, 0, !1);
      }, Object.defineProperty(n.prototype, "renderList", { get: function() {
        return this._multiRenderTarget.renderList;
      }, set: function(t) {
        this._multiRenderTarget.renderList = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isSupported", { get: function() {
        return this._multiRenderTarget.isSupported;
      }, enumerable: !1, configurable: !0 }), n.prototype.getTextureIndex = function(t) {
        switch (t) {
          case n.POSITION_TEXTURE_TYPE:
            return this._positionIndex;
          case n.VELOCITY_TEXTURE_TYPE:
            return this._velocityIndex;
          case n.REFLECTIVITY_TEXTURE_TYPE:
            return this._reflectivityIndex;
          case n.DEPTH_TEXTURE_TYPE:
            return this._linkedWithPrePass ? this._depthIndex : 0;
          case n.NORMAL_TEXTURE_TYPE:
            return this._linkedWithPrePass ? this._normalIndex : 1;
          default:
            return -1;
        }
      }, Object.defineProperty(n.prototype, "enablePosition", { get: function() {
        return this._enablePosition;
      }, set: function(t) {
        this._enablePosition = t, this._linkedWithPrePass || (this.dispose(), this._createRenderTargets());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "enableVelocity", { get: function() {
        return this._enableVelocity;
      }, set: function(t) {
        this._enableVelocity = t, t || (this._previousTransformationMatrices = {}), this._linkedWithPrePass || (this.dispose(), this._createRenderTargets()), this._scene.needsPreviousWorldMatrices = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "enableReflectivity", { get: function() {
        return this._enableReflectivity;
      }, set: function(t) {
        this._enableReflectivity = t, this._linkedWithPrePass || (this.dispose(), this._createRenderTargets());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "scene", { get: function() {
        return this._scene;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "ratio", { get: function() {
        return typeof this._ratioOrDimensions == "object" ? 1 : this._ratioOrDimensions;
      }, enumerable: !1, configurable: !0 }), n.prototype.isReady = function(t, e) {
        var i = t.getMaterial();
        if (i && i.disableDepthWrite)
          return !1;
        var r = [], o = [P.PositionKind, P.NormalKind], a = t.getMesh();
        if (i) {
          var s = !1;
          if (i.needAlphaTesting() && i.getAlphaTestTexture() && (r.push("#define ALPHATEST"), r.push("#define ALPHATEST_UV".concat(i.getAlphaTestTexture().coordinatesIndex + 1)), s = !0), i.bumpTexture && Pe.BumpTextureEnabled && (r.push("#define BUMP"), r.push("#define BUMP_UV".concat(i.bumpTexture.coordinatesIndex + 1)), s = !0), this._enableReflectivity) {
            var l = !1;
            i.getClassName() === "PBRMetallicRoughnessMaterial" ? (i.metallicRoughnessTexture !== null && (r.push("#define ORMTEXTURE"), r.push("#define REFLECTIVITY_UV".concat(i.metallicRoughnessTexture.coordinatesIndex + 1)), r.push("#define METALLICWORKFLOW"), s = !0, l = !0), i.metallic !== null && (r.push("#define METALLIC"), r.push("#define METALLICWORKFLOW"), l = !0), i.roughness !== null && (r.push("#define ROUGHNESS"), r.push("#define METALLICWORKFLOW"), l = !0), l && (i.baseTexture !== null && (r.push("#define ALBEDOTEXTURE"), r.push("#define ALBEDO_UV".concat(i.baseTexture.coordinatesIndex + 1)), i.baseTexture.gammaSpace && r.push("#define GAMMAALBEDO"), s = !0), i.baseColor !== null && r.push("#define ALBEDOCOLOR"))) : i.getClassName() === "PBRSpecularGlossinessMaterial" ? (i.specularGlossinessTexture !== null ? (r.push("#define SPECULARGLOSSINESSTEXTURE"), r.push("#define REFLECTIVITY_UV".concat(i.specularGlossinessTexture.coordinatesIndex + 1)), s = !0, i.specularGlossinessTexture.gammaSpace && r.push("#define GAMMAREFLECTIVITYTEXTURE")) : i.specularColor !== null && r.push("#define REFLECTIVITYCOLOR"), i.glossiness !== null && r.push("#define GLOSSINESS")) : i.getClassName() === "PBRMaterial" ? (i.metallicTexture !== null && (r.push("#define ORMTEXTURE"), r.push("#define REFLECTIVITY_UV".concat(i.metallicTexture.coordinatesIndex + 1)), r.push("#define METALLICWORKFLOW"), s = !0, l = !0), i.metallic !== null && (r.push("#define METALLIC"), r.push("#define METALLICWORKFLOW"), l = !0), i.roughness !== null && (r.push("#define ROUGHNESS"), r.push("#define METALLICWORKFLOW"), l = !0), l ? (i.albedoTexture !== null && (r.push("#define ALBEDOTEXTURE"), r.push("#define ALBEDO_UV".concat(i.albedoTexture.coordinatesIndex + 1)), i.albedoTexture.gammaSpace && r.push("#define GAMMAALBEDO"), s = !0), i.albedoColor !== null && r.push("#define ALBEDOCOLOR")) : (i.reflectivityTexture !== null ? (r.push("#define SPECULARGLOSSINESSTEXTURE"), r.push("#define REFLECTIVITY_UV".concat(i.reflectivityTexture.coordinatesIndex + 1)), i.reflectivityTexture.gammaSpace && r.push("#define GAMMAREFLECTIVITYTEXTURE"), s = !0) : i.reflectivityColor !== null && r.push("#define REFLECTIVITYCOLOR"), i.microSurface !== null && r.push("#define GLOSSINESS"))) : i.getClassName() === "StandardMaterial" && (i.specularTexture !== null && (r.push("#define REFLECTIVITYTEXTURE"), r.push("#define REFLECTIVITY_UV".concat(i.specularTexture.coordinatesIndex + 1)), i.specularTexture.gammaSpace && r.push("#define GAMMAREFLECTIVITYTEXTURE"), s = !0), i.specularColor !== null && r.push("#define REFLECTIVITYCOLOR"));
          }
          s && (r.push("#define NEED_UV"), a.isVerticesDataPresent(P.UVKind) && (o.push(P.UVKind), r.push("#define UV1")), a.isVerticesDataPresent(P.UV2Kind) && (o.push(P.UV2Kind), r.push("#define UV2")));
        }
        this._linkedWithPrePass && (r.push("#define PREPASS"), this._depthIndex !== -1 && (r.push("#define DEPTH_INDEX " + this._depthIndex), r.push("#define PREPASS_DEPTH")), this._normalIndex !== -1 && (r.push("#define NORMAL_INDEX " + this._normalIndex), r.push("#define PREPASS_NORMAL"))), this._enablePosition && (r.push("#define POSITION"), r.push("#define POSITION_INDEX " + this._positionIndex)), this._enableVelocity && (r.push("#define VELOCITY"), r.push("#define VELOCITY_INDEX " + this._velocityIndex), this.excludedSkinnedMeshesFromVelocity.indexOf(a) === -1 && r.push("#define BONES_VELOCITY_ENABLED")), this._enableReflectivity && (r.push("#define REFLECTIVITY"), r.push("#define REFLECTIVITY_INDEX " + this._reflectivityIndex)), this.generateNormalsInWorldSpace && r.push("#define NORMAL_WORLDSPACE"), a.useBones && a.computeBonesUsingShaders && a.skeleton ? (o.push(P.MatricesIndicesKind), o.push(P.MatricesWeightsKind), a.numBoneInfluencers > 4 && (o.push(P.MatricesIndicesExtraKind), o.push(P.MatricesWeightsExtraKind)), r.push("#define NUM_BONE_INFLUENCERS " + a.numBoneInfluencers), r.push("#define BONETEXTURE " + a.skeleton.isUsingTextureForMatrices), r.push("#define BonesPerMesh " + (a.skeleton.bones.length + 1))) : (r.push("#define NUM_BONE_INFLUENCERS 0"), r.push("#define BONETEXTURE false"), r.push("#define BonesPerMesh 0"));
        var c = a.morphTargetManager, u = 0;
        c && c.numInfluencers > 0 && (u = c.numInfluencers, r.push("#define MORPHTARGETS"), r.push("#define NUM_MORPH_INFLUENCERS " + u), c.isUsingTextureForTargets && r.push("#define MORPHTARGETS_TEXTURE"), Se.PrepareAttributesForMorphTargetsInfluencers(o, a, u)), e && (r.push("#define INSTANCES"), Se.PushAttributesForInstances(o, this._enableVelocity), t.getRenderingMesh().hasThinInstances && r.push("#define THIN_INSTANCES")), this._linkedWithPrePass ? r.push("#define RENDER_TARGET_COUNT " + this._attachmentsFromPrePass.length) : r.push("#define RENDER_TARGET_COUNT " + this._multiRenderTarget.textures.length), aa(i, this._scene, r);
        var h = this._scene.getEngine(), d = t._getDrawWrapper(void 0, !0), p = d.defines, f = r.join(`
`);
        return p !== f && d.setEffect(h.createEffect("geometry", { attributes: o, uniformsNames: oI, samplers: ["diffuseSampler", "bumpSampler", "reflectivitySampler", "albedoSampler", "morphTargets", "boneSampler"], defines: f, onCompiled: null, fallbacks: null, onError: null, uniformBuffersNames: ["Scene"], indexParameters: { buffersCount: this._multiRenderTarget.textures.length - 1, maxSimultaneousMorphTargets: u } }, h), f), d.effect.isReady();
      }, n.prototype.getGBuffer = function() {
        return this._multiRenderTarget;
      }, Object.defineProperty(n.prototype, "samples", { get: function() {
        return this._multiRenderTarget.samples;
      }, set: function(t) {
        this._multiRenderTarget.samples = t;
      }, enumerable: !1, configurable: !0 }), n.prototype.dispose = function() {
        this._resizeObserver && (this._scene.getEngine().onResizeObservable.remove(this._resizeObserver), this._resizeObserver = null), this.getGBuffer().dispose();
      }, n.prototype._assignRenderTargetIndices = function() {
        var t = [], e = 2;
        return t.push("gBuffer_Depth", "gBuffer_Normal"), this._enablePosition && (this._positionIndex = e, e++, t.push("gBuffer_Position")), this._enableVelocity && (this._velocityIndex = e, e++, t.push("gBuffer_Velocity")), this._enableReflectivity && (this._reflectivityIndex = e, e++, t.push("gBuffer_Reflectivity")), [e, t];
      }, n.prototype._createRenderTargets = function() {
        var t, e = this, i = this._scene.getEngine(), r = (t = this._assignRenderTargetIndices())[0], o = t[1], a = _.TEXTURETYPE_UNSIGNED_BYTE;
        i._caps.textureFloat && i._caps.textureFloatLinearFiltering ? a = _.TEXTURETYPE_FLOAT : i._caps.textureHalfFloat && i._caps.textureHalfFloatLinearFiltering && (a = _.TEXTURETYPE_HALF_FLOAT);
        var s = this._ratioOrDimensions.width !== void 0 ? this._ratioOrDimensions : { width: i.getRenderWidth() * this._ratioOrDimensions, height: i.getRenderHeight() * this._ratioOrDimensions };
        if (this._multiRenderTarget = new Ja("gBuffer", s, r, this._scene, { generateMipMaps: !1, generateDepthTexture: !0, defaultType: a, depthTextureFormat: this._depthFormat }, o.concat("gBuffer_DepthBuffer")), this.isSupported) {
          this._multiRenderTarget.wrapU = ae.CLAMP_ADDRESSMODE, this._multiRenderTarget.wrapV = ae.CLAMP_ADDRESSMODE, this._multiRenderTarget.refreshRate = 1, this._multiRenderTarget.renderParticles = !1, this._multiRenderTarget.renderList = null;
          for (var l = [!0], c = [!1], u = [!0], h = 1; h < r; ++h)
            l.push(!0), u.push(!1), c.push(!0);
          var d = i.buildTextureLayout(l), p = i.buildTextureLayout(c), f = i.buildTextureLayout(u);
          this._multiRenderTarget.onClearObservable.add(function(g) {
            g.bindAttachments(e.useSpecificClearForDepthTexture ? p : d), g.clear(e._clearColor, !0, !0, !0), e.useSpecificClearForDepthTexture && (g.bindAttachments(f), g.clear(e._clearDepthColor, !0, !0, !0)), g.bindAttachments(d);
          }), this._resizeObserver = i.onResizeObservable.add(function() {
            if (e._multiRenderTarget) {
              var g = e._ratioOrDimensions.width !== void 0 ? e._ratioOrDimensions : { width: i.getRenderWidth() * e._ratioOrDimensions, height: i.getRenderHeight() * e._ratioOrDimensions };
              e._multiRenderTarget.resize(g);
            }
          });
          var m = function(g) {
            var y = g.getRenderingMesh(), b = g.getEffectiveMesh(), T = e._scene, S = T.getEngine(), E = g.getMaterial();
            if (E) {
              if (b._internalAbstractMeshDataInfo._isActiveIntermediate = !1, e._enableVelocity && !e._previousTransformationMatrices[b.uniqueId] && (e._previousTransformationMatrices[b.uniqueId] = { world: B.Identity(), viewProjection: T.getTransformMatrix() }, y.skeleton)) {
                var A = y.skeleton.getTransformMatrices(y);
                e._previousBonesTransformationMatrices[y.uniqueId] = e._copyBonesTransformationMatrices(A, new Float32Array(A.length));
              }
              var R = y._getInstancesRenderList(g._id, !!g.getReplacementMesh());
              if (!R.mustReturn) {
                var C = S.getCaps().instancedArrays && (R.visibleInstances[g._id] !== null || y.hasThinInstances), L = b.getWorldMatrix();
                if (e.isReady(g, C)) {
                  var I = g._getDrawWrapper();
                  if (!I)
                    return;
                  var O = I.effect;
                  S.enableEffect(I), C || y._bind(g, O, E.fillMode), e._useUbo ? (Se.BindSceneUniformBuffer(O, e._scene.getSceneUniformBuffer()), e._scene.finalizeSceneUbo()) : (O.setMatrix("viewProjection", T.getTransformMatrix()), O.setMatrix("view", T.getViewMatrix()));
                  var w = void 0, z = y._instanceDataStorage;
                  if (z.isFrozen || !E.backFaceCulling && y.overrideMaterialSideOrientation === null)
                    w = z.sideOrientation;
                  else {
                    var V = b._getWorldMatrixDeterminant();
                    (w = y.overrideMaterialSideOrientation) === null && (w = E.sideOrientation), V < 0 && (w = w === Et.ClockWiseSideOrientation ? Et.CounterClockWiseSideOrientation : Et.ClockWiseSideOrientation);
                  }
                  if (E._preBind(I, w), E.needAlphaTesting()) {
                    var Y = E.getAlphaTestTexture();
                    Y && (O.setTexture("diffuseSampler", Y), O.setMatrix("diffuseMatrix", Y.getTextureMatrix()));
                  }
                  if (E.bumpTexture && T.getEngine().getCaps().standardDerivatives && Pe.BumpTextureEnabled && (O.setFloat3("vBumpInfos", E.bumpTexture.coordinatesIndex, 1 / E.bumpTexture.level, E.parallaxScaleBias), O.setMatrix("bumpMatrix", E.bumpTexture.getTextureMatrix()), O.setTexture("bumpSampler", E.bumpTexture), O.setFloat2("vTangentSpaceParams", E.invertNormalMapX ? -1 : 1, E.invertNormalMapY ? -1 : 1)), e._enableReflectivity && (E.getClassName() === "PBRMetallicRoughnessMaterial" ? (E.metallicRoughnessTexture !== null && (O.setTexture("reflectivitySampler", E.metallicRoughnessTexture), O.setMatrix("reflectivityMatrix", E.metallicRoughnessTexture.getTextureMatrix())), E.metallic !== null && O.setFloat("metallic", E.metallic), E.roughness !== null && O.setFloat("glossiness", 1 - E.roughness), E.baseTexture !== null && (O.setTexture("albedoSampler", E.baseTexture), O.setMatrix("albedoMatrix", E.baseTexture.getTextureMatrix())), E.baseColor !== null && O.setColor3("albedoColor", E.baseColor)) : E.getClassName() === "PBRSpecularGlossinessMaterial" ? (E.specularGlossinessTexture !== null ? (O.setTexture("reflectivitySampler", E.specularGlossinessTexture), O.setMatrix("reflectivityMatrix", E.specularGlossinessTexture.getTextureMatrix())) : E.specularColor !== null && O.setColor3("reflectivityColor", E.specularColor), E.glossiness !== null && O.setFloat("glossiness", E.glossiness)) : E.getClassName() === "PBRMaterial" ? (E.metallicTexture !== null && (O.setTexture("reflectivitySampler", E.metallicTexture), O.setMatrix("reflectivityMatrix", E.metallicTexture.getTextureMatrix())), E.metallic !== null && O.setFloat("metallic", E.metallic), E.roughness !== null && O.setFloat("glossiness", 1 - E.roughness), E.roughness !== null || E.metallic !== null || E.metallicTexture !== null ? (E.albedoTexture !== null && (O.setTexture("albedoSampler", E.albedoTexture), O.setMatrix("albedoMatrix", E.albedoTexture.getTextureMatrix())), E.albedoColor !== null && O.setColor3("albedoColor", E.albedoColor)) : (E.reflectivityTexture !== null ? (O.setTexture("reflectivitySampler", E.reflectivityTexture), O.setMatrix("reflectivityMatrix", E.reflectivityTexture.getTextureMatrix())) : E.reflectivityColor !== null && O.setColor3("reflectivityColor", E.reflectivityColor), E.microSurface !== null && O.setFloat("glossiness", E.microSurface))) : E.getClassName() === "StandardMaterial" && (E.specularTexture !== null && (O.setTexture("reflectivitySampler", E.specularTexture), O.setMatrix("reflectivityMatrix", E.specularTexture.getTextureMatrix())), E.specularColor !== null && O.setColor3("reflectivityColor", E.specularColor))), Ar(O, E, e._scene), y.useBones && y.computeBonesUsingShaders && y.skeleton) {
                    var ee = y.skeleton;
                    if (ee.isUsingTextureForMatrices && O.getUniformIndex("boneTextureWidth") > -1) {
                      var J = ee.getTransformMatrixTexture(y);
                      O.setTexture("boneSampler", J), O.setFloat("boneTextureWidth", 4 * (ee.bones.length + 1));
                    } else
                      O.setMatrices("mBones", y.skeleton.getTransformMatrices(y));
                    e._enableVelocity && O.setMatrices("mPreviousBones", e._previousBonesTransformationMatrices[y.uniqueId]);
                  }
                  Se.BindMorphTargetParameters(y, O), y.morphTargetManager && y.morphTargetManager.isUsingTextureForTargets && y.morphTargetManager._bind(O), e._enableVelocity && (O.setMatrix("previousWorld", e._previousTransformationMatrices[b.uniqueId].world), O.setMatrix("previousViewProjection", e._previousTransformationMatrices[b.uniqueId].viewProjection)), C && y.hasThinInstances && O.setMatrix("world", L), y._processRendering(b, g, O, E.fillMode, R, C, function(X, K) {
                    X || O.setMatrix("world", K);
                  });
                }
                e._enableVelocity && (e._previousTransformationMatrices[b.uniqueId].world = L.clone(), e._previousTransformationMatrices[b.uniqueId].viewProjection = e._scene.getTransformMatrix().clone(), y.skeleton && e._copyBonesTransformationMatrices(y.skeleton.getTransformMatrices(y), e._previousBonesTransformationMatrices[b.uniqueId]));
              }
            }
          };
          this._multiRenderTarget.customIsReadyFunction = function(g, y, b) {
            if ((b || y === 0) && g.subMeshes)
              for (var T = 0; T < g.subMeshes.length; ++T) {
                var S = g.subMeshes[T], E = S.getMaterial(), A = S.getRenderingMesh();
                if (E) {
                  var R = A._getInstancesRenderList(S._id, !!S.getReplacementMesh()), C = i.getCaps().instancedArrays && (R.visibleInstances[S._id] !== null || A.hasThinInstances);
                  if (!e.isReady(S, C))
                    return !1;
                }
              }
            return !0;
          }, this._multiRenderTarget.customRenderFunction = function(g, y, b, T) {
            var S;
            if (e._linkedWithPrePass) {
              if (!e._prePassRenderer.enabled)
                return;
              e._scene.getEngine().bindAttachments(e._attachmentsFromPrePass);
            }
            if (T.length) {
              for (i.setColorWrite(!1), S = 0; S < T.length; S++)
                m(T.data[S]);
              i.setColorWrite(!0);
            }
            for (S = 0; S < g.length; S++)
              m(g.data[S]);
            for (i.setDepthWrite(!1), S = 0; S < y.length; S++)
              m(y.data[S]);
            if (e.renderTransparentMeshes)
              for (S = 0; S < b.length; S++)
                m(b.data[S]);
            i.setDepthWrite(!0);
          };
        }
      }, n.prototype._copyBonesTransformationMatrices = function(t, e) {
        for (var i = 0; i < t.length; i++)
          e[i] = t[i];
        return e;
      }, n.DEPTH_TEXTURE_TYPE = 0, n.NORMAL_TEXTURE_TYPE = 1, n.POSITION_TEXTURE_TYPE = 2, n.VELOCITY_TEXTURE_TYPE = 3, n.REFLECTIVITY_TEXTURE_TYPE = 4, n._SceneComponentInitialization = function(t) {
        throw et("GeometryBufferRendererSceneComponent");
      }, n;
    }(), TN = function() {
      this.enabled = !1, this.name = "motionBlur", this.texturesRequired = [_.PREPASS_VELOCITY_TEXTURE_TYPE];
    };
    Object.defineProperty(Ue.prototype, "geometryBufferRenderer", { get: function() {
      return this._geometryBufferRenderer;
    }, set: function(n) {
      n && n.isSupported && (this._geometryBufferRenderer = n);
    }, enumerable: !0, configurable: !0 }), Ue.prototype.enableGeometryBufferRenderer = function(n, t) {
      return n === void 0 && (n = 1), t === void 0 && (t = _.TEXTUREFORMAT_DEPTH16), this._geometryBufferRenderer || (this._geometryBufferRenderer = new mr(this, n, t), this._geometryBufferRenderer.isSupported || (this._geometryBufferRenderer = null)), this._geometryBufferRenderer;
    }, Ue.prototype.disableGeometryBufferRenderer = function() {
      this._geometryBufferRenderer && (this._geometryBufferRenderer.dispose(), this._geometryBufferRenderer = null);
    };
    var oE = function() {
      function n(t) {
        this.name = we.NAME_GEOMETRYBUFFERRENDERER, this.scene = t;
      }
      return n.prototype.register = function() {
        this.scene._gatherRenderTargetsStage.registerStep(we.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER, this, this._gatherRenderTargets);
      }, n.prototype.rebuild = function() {
      }, n.prototype.dispose = function() {
      }, n.prototype._gatherRenderTargets = function(t) {
        this.scene._geometryBufferRenderer && t.push(this.scene._geometryBufferRenderer.getGBuffer());
      }, n;
    }();
    mr._SceneComponentInitialization = function(n) {
      var t = n._getComponent(we.NAME_GEOMETRYBUFFERRENDERER);
      t || (t = new oE(n), n._addComponent(t));
    }, re.ShadersStore.motionBlurPixelShader = `varying vec2 vUV;uniform sampler2D textureSampler;uniform float motionStrength;uniform float motionScale;uniform vec2 screenSize;
#ifdef OBJECT_BASED
uniform sampler2D velocitySampler;
#else
uniform sampler2D depthSampler;uniform mat4 inverseViewProjection;uniform mat4 prevViewProjection;uniform mat4 projection;
#endif
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void)
{
#ifdef GEOMETRY_SUPPORTED
#ifdef OBJECT_BASED
vec2 texelSize=1.0/screenSize;vec4 velocityColor=texture2D(velocitySampler,vUV);velocityColor.rg=velocityColor.rg*2.0-vec2(1.0);vec2 velocity=vec2(pow(velocityColor.r,3.0),pow(velocityColor.g,3.0))*velocityColor.a;velocity*=motionScale*motionStrength;float speed=length(velocity/texelSize);int samplesCount=int(clamp(speed,1.0,SAMPLES));velocity=normalize(velocity)*texelSize;float hlim=float(-samplesCount)*0.5+0.5;vec4 result=texture2D(textureSampler,vUV);for (int i=1; i<int(SAMPLES); ++i)
{if (i>=samplesCount)
break;vec2 offset=vUV+velocity*(hlim+float(i));
#if defined(WEBGPU)
result+=texture2DLodEXT(textureSampler,offset,0.0);
#else
result+=texture2D(textureSampler,offset);
#endif
}
gl_FragColor=result/float(samplesCount);gl_FragColor.a=1.0;
#else
vec2 texelSize=1.0/screenSize;float depth=texture2D(depthSampler,vUV).r;depth=projection[2].z+projection[3].z/depth; 
vec4 cpos=vec4(vUV*2.0-1.0,depth,1.0);cpos=inverseViewProjection*cpos;cpos/=cpos.w;vec4 ppos=prevViewProjection*cpos;ppos/=ppos.w;ppos.xy=ppos.xy*0.5+0.5;vec2 velocity=(ppos.xy-vUV)*motionScale*motionStrength;float speed=length(velocity/texelSize);int nSamples=int(clamp(speed,1.0,SAMPLES));vec4 result=texture2D(textureSampler,vUV);for (int i=1; i<int(SAMPLES); ++i) {if (i>=nSamples)
break;vec2 offset1=vUV+velocity*(float(i)/float(nSamples-1)-0.5);
#if defined(WEBGPU)
result+=texture2DLodEXT(textureSampler,offset1,0.0);
#else
result+=texture2D(textureSampler,offset1);
#endif
}
gl_FragColor=result/float(nSamples);
#endif
#else
gl_FragColor=texture2D(textureSampler,vUV);
#endif
}
`;
    var hm = function(n) {
      function t(e, i, r, o, a, s, l, c, u, h) {
        c === void 0 && (c = _.TEXTURETYPE_UNSIGNED_INT), u === void 0 && (u = !1), h === void 0 && (h = !1);
        var d = n.call(this, e, "motionBlur", ["motionStrength", "motionScale", "screenSize", "inverseViewProjection", "prevViewProjection", "projection"], ["velocitySampler", "depthSampler"], r, o, a, s, l, `#define GEOMETRY_SUPPORTED
#define SAMPLES 64.0
#define OBJECT_BASED`, c, void 0, null, u) || this;
        return d.motionStrength = 1, d._motionBlurSamples = 32, d._isObjectBased = !0, d._forceGeometryBuffer = !1, d._invViewProjection = null, d._previousViewProjection = null, d._forceGeometryBuffer = h, d._forceGeometryBuffer ? (i.enableGeometryBufferRenderer(), d._geometryBufferRenderer && (d._geometryBufferRenderer.enableVelocity = d._isObjectBased)) : (i.enablePrePassRenderer(), d._prePassRenderer && (d._prePassRenderer.markAsDirty(), d._prePassEffectConfiguration = new TN())), d._applyMode(), d;
      }
      return D(t, n), Object.defineProperty(t.prototype, "motionBlurSamples", { get: function() {
        return this._motionBlurSamples;
      }, set: function(e) {
        this._motionBlurSamples = e, this._updateEffect();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isObjectBased", { get: function() {
        return this._isObjectBased;
      }, set: function(e) {
        this._isObjectBased !== e && (this._isObjectBased = e, this._applyMode());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "_geometryBufferRenderer", { get: function() {
        return this._forceGeometryBuffer ? this._scene.geometryBufferRenderer : null;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "_prePassRenderer", { get: function() {
        return this._forceGeometryBuffer ? null : this._scene.prePassRenderer;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "MotionBlurPostProcess";
      }, t.prototype.excludeSkinnedMesh = function(e) {
        if (e.skeleton) {
          var i = void 0;
          if (this._geometryBufferRenderer)
            i = this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity;
          else {
            if (!this._prePassRenderer)
              return;
            i = this._prePassRenderer.excludedSkinnedMesh;
          }
          i.push(e);
        }
      }, t.prototype.removeExcludedSkinnedMesh = function(e) {
        if (e.skeleton) {
          var i = void 0;
          if (this._geometryBufferRenderer)
            i = this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity;
          else {
            if (!this._prePassRenderer)
              return;
            i = this._prePassRenderer.excludedSkinnedMesh;
          }
          var r = i.indexOf(e);
          r !== -1 && i.splice(r, 1);
        }
      }, t.prototype.dispose = function(e) {
        this._geometryBufferRenderer && (this._geometryBufferRenderer._previousTransformationMatrices = {}, this._geometryBufferRenderer._previousBonesTransformationMatrices = {}, this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity = []), n.prototype.dispose.call(this, e);
      }, t.prototype._applyMode = function() {
        var e = this;
        if (!this._geometryBufferRenderer && !this._prePassRenderer)
          return q.Warn("Multiple Render Target support needed to compute object based motion blur"), this.updateEffect();
        this._geometryBufferRenderer && (this._geometryBufferRenderer.enableVelocity = this._isObjectBased), this._updateEffect(), this._invViewProjection = null, this._previousViewProjection = null, this.isObjectBased ? (this._prePassRenderer && this._prePassEffectConfiguration && (this._prePassEffectConfiguration.texturesRequired[0] = _.PREPASS_VELOCITY_TEXTURE_TYPE), this.onApply = function(i) {
          return e._onApplyObjectBased(i);
        }) : (this._invViewProjection = B.Identity(), this._previousViewProjection = this._scene.getTransformMatrix().clone(), this._prePassRenderer && this._prePassEffectConfiguration && (this._prePassEffectConfiguration.texturesRequired[0] = _.PREPASS_DEPTH_TEXTURE_TYPE), this.onApply = function(i) {
          return e._onApplyScreenBased(i);
        });
      }, t.prototype._onApplyObjectBased = function(e) {
        if (e.setVector2("screenSize", new fe(this.width, this.height)), e.setFloat("motionScale", this._scene.getAnimationRatio()), e.setFloat("motionStrength", this.motionStrength), this._geometryBufferRenderer) {
          var i = this._geometryBufferRenderer.getTextureIndex(mr.VELOCITY_TEXTURE_TYPE);
          e.setTexture("velocitySampler", this._geometryBufferRenderer.getGBuffer().textures[i]);
        } else
          this._prePassRenderer && (i = this._prePassRenderer.getIndex(_.PREPASS_VELOCITY_TEXTURE_TYPE), e.setTexture("velocitySampler", this._prePassRenderer.getRenderTarget().textures[i]));
      }, t.prototype._onApplyScreenBased = function(e) {
        var i = F.Matrix[0];
        if (i.copyFrom(this._scene.getTransformMatrix()), i.invertToRef(this._invViewProjection), e.setMatrix("inverseViewProjection", this._invViewProjection), e.setMatrix("prevViewProjection", this._previousViewProjection), this._previousViewProjection.copyFrom(i), e.setMatrix("projection", this._scene.getProjectionMatrix()), e.setVector2("screenSize", new fe(this.width, this.height)), e.setFloat("motionScale", this._scene.getAnimationRatio()), e.setFloat("motionStrength", this.motionStrength), this._geometryBufferRenderer) {
          var r = this._geometryBufferRenderer.getTextureIndex(mr.DEPTH_TEXTURE_TYPE);
          e.setTexture("depthSampler", this._geometryBufferRenderer.getGBuffer().textures[r]);
        } else
          this._prePassRenderer && (r = this._prePassRenderer.getIndex(_.PREPASS_DEPTH_TEXTURE_TYPE), e.setTexture("depthSampler", this._prePassRenderer.getRenderTarget().textures[r]));
      }, t.prototype._updateEffect = function() {
        if (this._geometryBufferRenderer || this._prePassRenderer) {
          var e = ["#define GEOMETRY_SUPPORTED", "#define SAMPLES " + this._motionBlurSamples.toFixed(1), this._isObjectBased ? "#define OBJECT_BASED" : "#define SCREEN_BASED"];
          this.updateEffect(e.join(`
`));
        }
      }, t._Parse = function(e, i, r, o) {
        return Ne.Parse(function() {
          return new t(e.name, r, e.options, i, e.renderTargetSamplingMode, r.getEngine(), e.reusable, e.textureType, !1);
        }, e, r, o);
      }, x([N()], t.prototype, "motionStrength", void 0), x([N()], t.prototype, "motionBlurSamples", null), x([N()], t.prototype, "isObjectBased", null), t;
    }(nt);
    j("BABYLON.MotionBlurPostProcess", hm), re.ShadersStore.refractionPixelShader = "varying vec2 vUV;uniform sampler2D textureSampler;uniform sampler2D refractionSampler;uniform vec3 baseColor;uniform float depth;uniform float colorLevel;void main() {float ref=1.0-texture2D(refractionSampler,vUV).r;vec2 uv=vUV-vec2(0.5);vec2 offset=uv*depth*ref;vec3 sourceColor=texture2D(textureSampler,vUV-offset).rgb;gl_FragColor=vec4(sourceColor+sourceColor*ref*colorLevel,1.0);}";
    var aE = function(n) {
      function t(e, i, r, o, a, s, l, c, u, h) {
        var d = n.call(this, e, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], s, l, c, u, h) || this;
        return d._ownRefractionTexture = !0, d.color = r, d.depth = o, d.colorLevel = a, d.refractionTextureUrl = i, d.onActivateObservable.add(function(p) {
          d._refTexture = d._refTexture || new ae(i, p.getScene());
        }), d.onApplyObservable.add(function(p) {
          p.setColor3("baseColor", d.color), p.setFloat("depth", d.depth), p.setFloat("colorLevel", d.colorLevel), p.setTexture("refractionSampler", d._refTexture);
        }), d;
      }
      return D(t, n), Object.defineProperty(t.prototype, "refractionTexture", { get: function() {
        return this._refTexture;
      }, set: function(e) {
        this._refTexture && this._ownRefractionTexture && this._refTexture.dispose(), this._refTexture = e, this._ownRefractionTexture = !1;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "RefractionPostProcess";
      }, t.prototype.dispose = function(e) {
        this._refTexture && this._ownRefractionTexture && (this._refTexture.dispose(), this._refTexture = null), n.prototype.dispose.call(this, e);
      }, t._Parse = function(e, i, r, o) {
        return Ne.Parse(function() {
          return new t(e.name, e.refractionTextureUrl, e.color, e.depth, e.colorLevel, e.options, i, e.renderTargetSamplingMode, r.getEngine(), e.reusable);
        }, e, r, o);
      }, x([N()], t.prototype, "color", void 0), x([N()], t.prototype, "depth", void 0), x([N()], t.prototype, "colorLevel", void 0), x([N()], t.prototype, "refractionTextureUrl", void 0), t;
    }(nt);
    j("BABYLON.RefractionPostProcess", aE), re.ShadersStore.sharpenPixelShader = `varying vec2 vUV;uniform sampler2D textureSampler;uniform vec2 screenSize;uniform vec2 sharpnessAmounts;
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void)
{vec2 onePixel=vec2(1.0,1.0)/screenSize;vec4 color=texture2D(textureSampler,vUV);vec4 edgeDetection=texture2D(textureSampler,vUV+onePixel*vec2(0,-1)) +
texture2D(textureSampler,vUV+onePixel*vec2(-1,0)) +
texture2D(textureSampler,vUV+onePixel*vec2(1,0)) +
texture2D(textureSampler,vUV+onePixel*vec2(0,1)) -
color*4.0;gl_FragColor=max(vec4(color.rgb*sharpnessAmounts.y,color.a)-(sharpnessAmounts.x*vec4(edgeDetection.rgb,0)),0.);}`;
    var dm = function(n) {
      function t(e, i, r, o, a, s, l, c) {
        l === void 0 && (l = _.TEXTURETYPE_UNSIGNED_INT), c === void 0 && (c = !1);
        var u = n.call(this, e, "sharpen", ["sharpnessAmounts", "screenSize"], null, i, r, o, a, s, null, l, void 0, null, c) || this;
        return u.colorAmount = 1, u.edgeAmount = 0.3, u.onApply = function(h) {
          h.setFloat2("screenSize", u.width, u.height), h.setFloat2("sharpnessAmounts", u.edgeAmount, u.colorAmount);
        }, u;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "SharpenPostProcess";
      }, t._Parse = function(e, i, r, o) {
        return Ne.Parse(function() {
          return new t(e.name, e.options, i, e.renderTargetSamplingMode, r.getEngine(), e.textureType, e.reusable);
        }, e, r, o);
      }, x([N()], t.prototype, "colorAmount", void 0), x([N()], t.prototype, "edgeAmount", void 0), t;
    }(nt);
    j("BABYLON.SharpenPostProcess", dm);
    var Ns = function() {
      function n(t, e) {
        this._engine = t, this._name = e, this._renderEffects = {}, this._renderEffectsForIsolatedPass = new Array(), this._cameras = [];
      }
      return Object.defineProperty(n.prototype, "name", { get: function() {
        return this._name;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "cameras", { get: function() {
        return this._cameras;
      }, enumerable: !1, configurable: !0 }), n.prototype.getClassName = function() {
        return "PostProcessRenderPipeline";
      }, Object.defineProperty(n.prototype, "isSupported", { get: function() {
        for (var t in this._renderEffects)
          if (Object.prototype.hasOwnProperty.call(this._renderEffects, t) && !this._renderEffects[t].isSupported)
            return !1;
        return !0;
      }, enumerable: !1, configurable: !0 }), n.prototype.addEffect = function(t) {
        this._renderEffects[t._name] = t;
      }, n.prototype._rebuild = function() {
      }, n.prototype._enableEffect = function(t, e) {
        var i = this._renderEffects[t];
        i && i._enable(de.MakeArray(e || this._cameras));
      }, n.prototype._disableEffect = function(t, e) {
        var i = this._renderEffects[t];
        i && i._disable(de.MakeArray(e || this._cameras));
      }, n.prototype._attachCameras = function(t, e) {
        var i = de.MakeArray(t || this._cameras);
        if (i) {
          var r, o = [];
          for (r = 0; r < i.length; r++) {
            var a = i[r];
            a && (this._cameras.indexOf(a) === -1 ? this._cameras.push(a) : e && o.push(r));
          }
          for (r = 0; r < o.length; r++)
            i.splice(o[r], 1);
          for (var s in this._renderEffects)
            Object.prototype.hasOwnProperty.call(this._renderEffects, s) && this._renderEffects[s]._attachCameras(i);
        }
      }, n.prototype._detachCameras = function(t) {
        var e = de.MakeArray(t || this._cameras);
        if (e) {
          for (var i in this._renderEffects)
            Object.prototype.hasOwnProperty.call(this._renderEffects, i) && this._renderEffects[i]._detachCameras(e);
          for (var r = 0; r < e.length; r++)
            this._cameras.splice(this._cameras.indexOf(e[r]), 1);
        }
      }, n.prototype._update = function() {
        for (var t in this._renderEffects)
          Object.prototype.hasOwnProperty.call(this._renderEffects, t) && this._renderEffects[t]._update();
        for (var e = 0; e < this._cameras.length; e++)
          if (this._cameras[e]) {
            var i = this._cameras[e].name;
            this._renderEffectsForIsolatedPass[i] && this._renderEffectsForIsolatedPass[i]._update();
          }
      }, n.prototype._reset = function() {
        this._renderEffects = {}, this._renderEffectsForIsolatedPass = new Array();
      }, n.prototype._enableMSAAOnFirstPostProcess = function(t) {
        if (!this._engine._features.supportMSAA)
          return !1;
        var e = Object.keys(this._renderEffects);
        if (e.length > 0) {
          var i = this._renderEffects[e[0]].getPostProcesses();
          i && (i[0].samples = t);
        }
        return !0;
      }, n.prototype._adaptPostProcessesToViewPort = function() {
        for (var t = 0, e = Object.keys(this._renderEffects); t < e.length; t++) {
          var i = e[t], r = this._renderEffects[i].getPostProcesses();
          if (r)
            for (var o = 0, a = r; o < a.length; o++)
              a[o].adaptScaleToCurrentViewport = !0;
        }
      }, n.prototype.setPrePassRenderer = function(t) {
        return !1;
      }, n.prototype.dispose = function() {
      }, x([N()], n.prototype, "_name", void 0), n;
    }(), sE = function() {
      function n() {
        this._renderPipelines = {};
      }
      return Object.defineProperty(n.prototype, "supportedPipelines", { get: function() {
        var t = [];
        for (var e in this._renderPipelines)
          if (Object.prototype.hasOwnProperty.call(this._renderPipelines, e)) {
            var i = this._renderPipelines[e];
            i.isSupported && t.push(i);
          }
        return t;
      }, enumerable: !1, configurable: !0 }), n.prototype.addPipeline = function(t) {
        this._renderPipelines[t._name] = t;
      }, n.prototype.removePipeline = function(t) {
        delete this._renderPipelines[t];
      }, n.prototype.attachCamerasToRenderPipeline = function(t, e, i) {
        i === void 0 && (i = !1);
        var r = this._renderPipelines[t];
        r && r._attachCameras(e, i);
      }, n.prototype.detachCamerasFromRenderPipeline = function(t, e) {
        var i = this._renderPipelines[t];
        i && i._detachCameras(e);
      }, n.prototype.enableEffectInPipeline = function(t, e, i) {
        var r = this._renderPipelines[t];
        r && r._enableEffect(e, i);
      }, n.prototype.disableEffectInPipeline = function(t, e, i) {
        var r = this._renderPipelines[t];
        r && r._disableEffect(e, i);
      }, n.prototype.update = function() {
        for (var t in this._renderPipelines)
          if (Object.prototype.hasOwnProperty.call(this._renderPipelines, t)) {
            var e = this._renderPipelines[t];
            e.isSupported ? e._update() : (e.dispose(), delete this._renderPipelines[t]);
          }
      }, n.prototype._rebuild = function() {
        for (var t in this._renderPipelines)
          Object.prototype.hasOwnProperty.call(this._renderPipelines, t) && this._renderPipelines[t]._rebuild();
      }, n.prototype.dispose = function() {
        for (var t in this._renderPipelines)
          Object.prototype.hasOwnProperty.call(this._renderPipelines, t) && this._renderPipelines[t].dispose();
      }, n;
    }();
    Object.defineProperty(Ue.prototype, "postProcessRenderPipelineManager", { get: function() {
      if (!this._postProcessRenderPipelineManager) {
        var n = this._getComponent(we.NAME_POSTPROCESSRENDERPIPELINEMANAGER);
        n || (n = new lE(this), this._addComponent(n)), this._postProcessRenderPipelineManager = new sE();
      }
      return this._postProcessRenderPipelineManager;
    }, enumerable: !0, configurable: !0 });
    var lE = function() {
      function n(t) {
        this.name = we.NAME_POSTPROCESSRENDERPIPELINEMANAGER, this.scene = t;
      }
      return n.prototype.register = function() {
        this.scene._gatherRenderTargetsStage.registerStep(we.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER, this, this._gatherRenderTargets);
      }, n.prototype.rebuild = function() {
        this.scene._postProcessRenderPipelineManager && this.scene._postProcessRenderPipelineManager._rebuild();
      }, n.prototype.dispose = function() {
        this.scene._postProcessRenderPipelineManager && this.scene._postProcessRenderPipelineManager.dispose();
      }, n.prototype._gatherRenderTargets = function() {
        this.scene._postProcessRenderPipelineManager && this.scene._postProcessRenderPipelineManager.update();
      }, n;
    }(), cE = function(n) {
      function t(e, i, r, o, a) {
        e === void 0 && (e = ""), i === void 0 && (i = !0), r === void 0 && (r = Me.LastCreatedScene), a === void 0 && (a = !0);
        var s = n.call(this, r.getEngine(), e) || this;
        s._camerasToBeAttached = [], s.SharpenPostProcessId = "SharpenPostProcessEffect", s.ImageProcessingPostProcessId = "ImageProcessingPostProcessEffect", s.FxaaPostProcessId = "FxaaPostProcessEffect", s.ChromaticAberrationPostProcessId = "ChromaticAberrationPostProcessEffect", s.GrainPostProcessId = "GrainPostProcessEffect", s._glowLayer = null, s.animations = [], s._imageProcessingConfigurationObserver = null, s._sharpenEnabled = !1, s._bloomEnabled = !1, s._depthOfFieldEnabled = !1, s._depthOfFieldBlurLevel = Ds.Low, s._fxaaEnabled = !1, s._imageProcessingEnabled = !0, s._bloomScale = 0.5, s._chromaticAberrationEnabled = !1, s._grainEnabled = !1, s._buildAllowed = !0, s.onBuildObservable = new H(), s._resizeObserver = null, s._hardwareScaleLevel = 1, s._bloomKernel = 64, s._bloomWeight = 0.15, s._bloomThreshold = 0.9, s._samples = 1, s._hasCleared = !1, s._prevPostProcess = null, s._prevPrevPostProcess = null, s._depthOfFieldSceneObserver = null, s._activeCameraChangedObserver = null, s._activeCamerasChangedObserver = null, s._cameras = o || r.cameras, s._cameras = s._cameras.slice(), s._camerasToBeAttached = s._cameras.slice(), s._buildAllowed = a, s._scene = r;
        var l = s._scene.getEngine().getCaps();
        s._hdr = i && (l.textureHalfFloatRender || l.textureFloatRender), s._hdr ? l.textureHalfFloatRender ? s._defaultPipelineTextureType = _.TEXTURETYPE_HALF_FLOAT : l.textureFloatRender && (s._defaultPipelineTextureType = _.TEXTURETYPE_FLOAT) : s._defaultPipelineTextureType = _.TEXTURETYPE_UNSIGNED_INT, r.postProcessRenderPipelineManager.addPipeline(s);
        var c = s._scene.getEngine();
        s.sharpen = new dm("sharpen", 1, null, ae.BILINEAR_SAMPLINGMODE, c, !1, s._defaultPipelineTextureType, !0), s._sharpenEffect = new Vt(c, s.SharpenPostProcessId, function() {
          return s.sharpen;
        }, !0), s.depthOfField = new lm(s._scene, null, s._depthOfFieldBlurLevel, s._defaultPipelineTextureType, !0), s._hardwareScaleLevel = c.getHardwareScalingLevel(), s._resizeObserver = c.onResizeObservable.add(function() {
          s._hardwareScaleLevel = c.getHardwareScalingLevel(), s.bloomKernel = s._bloomKernel;
        }), s.bloom = new om(s._scene, s._bloomScale, s._bloomWeight, s.bloomKernel / s._hardwareScaleLevel, s._defaultPipelineTextureType, !0), s.chromaticAberration = new am("ChromaticAberration", c.getRenderWidth(), c.getRenderHeight(), 1, null, ae.BILINEAR_SAMPLINGMODE, c, !1, s._defaultPipelineTextureType, !0), s._chromaticAberrationEffect = new Vt(c, s.ChromaticAberrationPostProcessId, function() {
          return s.chromaticAberration;
        }, !0), s.grain = new cm("Grain", 1, null, ae.BILINEAR_SAMPLINGMODE, c, !1, s._defaultPipelineTextureType, !0), s._grainEffect = new Vt(c, s.GrainPostProcessId, function() {
          return s.grain;
        }, !0);
        var u = !0;
        return s._imageProcessingConfigurationObserver = s._scene.imageProcessingConfiguration.onUpdateParameters.add(function() {
          s.bloom._downscale._exposure = s._scene.imageProcessingConfiguration.exposure, s.imageProcessingEnabled !== s._scene.imageProcessingConfiguration.isEnabled && (s._imageProcessingEnabled = s._scene.imageProcessingConfiguration.isEnabled, u ? de.SetImmediate(function() {
            s._buildPipeline();
          }) : s._buildPipeline());
        }), s._buildPipeline(), u = !1, s;
      }
      return D(t, n), Object.defineProperty(t.prototype, "automaticBuild", { get: function() {
        return this._buildAllowed;
      }, set: function(e) {
        this._buildAllowed = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "scene", { get: function() {
        return this._scene;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "sharpenEnabled", { get: function() {
        return this._sharpenEnabled;
      }, set: function(e) {
        this._sharpenEnabled !== e && (this._sharpenEnabled = e, this._buildPipeline());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "bloomKernel", { get: function() {
        return this._bloomKernel;
      }, set: function(e) {
        this._bloomKernel = e, this.bloom.kernel = e / this._hardwareScaleLevel;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "bloomWeight", { get: function() {
        return this._bloomWeight;
      }, set: function(e) {
        this._bloomWeight !== e && (this.bloom.weight = e, this._bloomWeight = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "bloomThreshold", { get: function() {
        return this._bloomThreshold;
      }, set: function(e) {
        this._bloomThreshold !== e && (this.bloom.threshold = e, this._bloomThreshold = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "bloomScale", { get: function() {
        return this._bloomScale;
      }, set: function(e) {
        this._bloomScale !== e && (this._bloomScale = e, this._rebuildBloom(), this._buildPipeline());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "bloomEnabled", { get: function() {
        return this._bloomEnabled;
      }, set: function(e) {
        this._bloomEnabled !== e && (this._bloomEnabled = e, this._buildPipeline());
      }, enumerable: !1, configurable: !0 }), t.prototype._rebuildBloom = function() {
        var e = this.bloom;
        this.bloom = new om(this._scene, this.bloomScale, this._bloomWeight, this.bloomKernel / this._hardwareScaleLevel, this._defaultPipelineTextureType, !1), this.bloom.threshold = e.threshold;
        for (var i = 0; i < this._cameras.length; i++)
          e.disposeEffects(this._cameras[i]);
      }, Object.defineProperty(t.prototype, "depthOfFieldEnabled", { get: function() {
        return this._depthOfFieldEnabled;
      }, set: function(e) {
        this._depthOfFieldEnabled !== e && (this._depthOfFieldEnabled = e, this._buildPipeline());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "depthOfFieldBlurLevel", { get: function() {
        return this._depthOfFieldBlurLevel;
      }, set: function(e) {
        if (this._depthOfFieldBlurLevel !== e) {
          this._depthOfFieldBlurLevel = e;
          var i = this.depthOfField;
          this.depthOfField = new lm(this._scene, null, this._depthOfFieldBlurLevel, this._defaultPipelineTextureType, !1), this.depthOfField.focalLength = i.focalLength, this.depthOfField.focusDistance = i.focusDistance, this.depthOfField.fStop = i.fStop, this.depthOfField.lensSize = i.lensSize;
          for (var r = 0; r < this._cameras.length; r++)
            i.disposeEffects(this._cameras[r]);
          this._buildPipeline();
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "fxaaEnabled", { get: function() {
        return this._fxaaEnabled;
      }, set: function(e) {
        this._fxaaEnabled !== e && (this._fxaaEnabled = e, this._buildPipeline());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "samples", { get: function() {
        return this._samples;
      }, set: function(e) {
        this._samples !== e && (this._samples = e, this._buildPipeline());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "imageProcessingEnabled", { get: function() {
        return this._imageProcessingEnabled;
      }, set: function(e) {
        this._imageProcessingEnabled !== e && (this._scene.imageProcessingConfiguration.isEnabled = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "glowLayerEnabled", { get: function() {
        return this._glowLayer != null;
      }, set: function(e) {
        e && !this._glowLayer ? this._glowLayer = new Zh("", this._scene) : !e && this._glowLayer && (this._glowLayer.dispose(), this._glowLayer = null);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "glowLayer", { get: function() {
        return this._glowLayer;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "chromaticAberrationEnabled", { get: function() {
        return this._chromaticAberrationEnabled;
      }, set: function(e) {
        this._chromaticAberrationEnabled !== e && (this._chromaticAberrationEnabled = e, this._buildPipeline());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "grainEnabled", { get: function() {
        return this._grainEnabled;
      }, set: function(e) {
        this._grainEnabled !== e && (this._grainEnabled = e, this._buildPipeline());
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "DefaultRenderingPipeline";
      }, t.prototype.prepare = function() {
        var e = this._buildAllowed;
        this._buildAllowed = !0, this._buildPipeline(), this._buildAllowed = e;
      }, t.prototype._setAutoClearAndTextureSharing = function(e, i) {
        i === void 0 && (i = !1), this._hasCleared ? e.autoClear = !1 : (e.autoClear = !0, this._scene.autoClear = !1, this._hasCleared = !0), i || (this._prevPrevPostProcess ? e.shareOutputWith(this._prevPrevPostProcess) : e.useOwnOutput(), this._prevPostProcess && (this._prevPrevPostProcess = this._prevPostProcess), this._prevPostProcess = e);
      }, t.prototype._buildPipeline = function() {
        var e = this;
        if (this._buildAllowed) {
          this._scene.autoClear = !0;
          var i = this._scene.getEngine();
          if (this._disposePostProcesses(), this._cameras !== null && (this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras), this._cameras = this._camerasToBeAttached.slice()), this._reset(), this._prevPostProcess = null, this._prevPrevPostProcess = null, this._hasCleared = !1, this.depthOfFieldEnabled) {
            if (this._cameras.length > 1) {
              for (var r = 0, o = this._cameras; r < o.length; r++) {
                var a = o[r];
                (s = this._scene.enableDepthRenderer(a)).useOnlyInActiveCamera = !0;
              }
              this._depthOfFieldSceneObserver = this._scene.onAfterRenderTargetsRenderObservable.add(function(l) {
                e._cameras.indexOf(l.activeCamera) > -1 && (e.depthOfField.depthTexture = l.enableDepthRenderer(l.activeCamera).getDepthMap());
              });
            } else {
              this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
              var s = this._scene.enableDepthRenderer(this._cameras[0]);
              this.depthOfField.depthTexture = s.getDepthMap();
            }
            this.depthOfField._isReady() || this.depthOfField._updateEffects(), this.addEffect(this.depthOfField), this._setAutoClearAndTextureSharing(this.depthOfField._effects[0], !0);
          } else
            this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
          this.bloomEnabled && (this.bloom._isReady() || this.bloom._updateEffects(), this.addEffect(this.bloom), this._setAutoClearAndTextureSharing(this.bloom._effects[0], !0)), this._imageProcessingEnabled && (this.imageProcessing = new um("imageProcessing", 1, null, ae.BILINEAR_SAMPLINGMODE, i, !1, this._defaultPipelineTextureType, this.scene.imageProcessingConfiguration), this._hdr ? (this.addEffect(new Vt(i, this.ImageProcessingPostProcessId, function() {
            return e.imageProcessing;
          }, !0)), this._setAutoClearAndTextureSharing(this.imageProcessing)) : this._scene.imageProcessingConfiguration.applyByPostProcess = !1, this._cameras && this._cameras.length !== 0 || (this._scene.imageProcessingConfiguration.applyByPostProcess = !1), this.imageProcessing.getEffect() || this.imageProcessing._updateParameters()), this.sharpenEnabled && (this.sharpen.isReady() || this.sharpen.updateEffect(), this.addEffect(this._sharpenEffect), this._setAutoClearAndTextureSharing(this.sharpen)), this.grainEnabled && (this.grain.isReady() || this.grain.updateEffect(), this.addEffect(this._grainEffect), this._setAutoClearAndTextureSharing(this.grain)), this.chromaticAberrationEnabled && (this.chromaticAberration.isReady() || this.chromaticAberration.updateEffect(), this.addEffect(this._chromaticAberrationEffect), this._setAutoClearAndTextureSharing(this.chromaticAberration)), this.fxaaEnabled && (this.fxaa = new hu("fxaa", 1, null, ae.BILINEAR_SAMPLINGMODE, i, !1, this._defaultPipelineTextureType), this.addEffect(new Vt(i, this.FxaaPostProcessId, function() {
            return e.fxaa;
          }, !0)), this._setAutoClearAndTextureSharing(this.fxaa, !0)), this._cameras !== null && this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras), (this._scene.activeCameras && this._scene.activeCameras.length > 1 || this._scene.activeCamera && this._cameras.indexOf(this._scene.activeCamera) === -1) && (this._scene.autoClear = !0), this._activeCameraChangedObserver || (this._activeCameraChangedObserver = this._scene.onActiveCameraChanged.add(function() {
            e._scene.activeCamera && e._cameras.indexOf(e._scene.activeCamera) === -1 && (e._scene.autoClear = !0);
          })), this._activeCamerasChangedObserver || (this._activeCamerasChangedObserver = this._scene.onActiveCamerasChanged.add(function() {
            e._scene.activeCameras && e._scene.activeCameras.length > 1 && (e._scene.autoClear = !0);
          })), this._adaptPostProcessesToViewPort(), !this._enableMSAAOnFirstPostProcess(this.samples) && this.samples > 1 && q.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0"), this.onBuildObservable.notifyObservers(this);
        }
      }, t.prototype._disposePostProcesses = function(e) {
        e === void 0 && (e = !1);
        for (var i = 0; i < this._cameras.length; i++) {
          var r = this._cameras[i];
          this.imageProcessing && this.imageProcessing.dispose(r), this.fxaa && this.fxaa.dispose(r), e && (this.sharpen && this.sharpen.dispose(r), this.depthOfField && (this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver), this.depthOfField.disposeEffects(r)), this.bloom && this.bloom.disposeEffects(r), this.chromaticAberration && this.chromaticAberration.dispose(r), this.grain && this.grain.dispose(r), this._glowLayer && this._glowLayer.dispose());
        }
        this.imageProcessing = null, this.fxaa = null, e && (this.sharpen = null, this._sharpenEffect = null, this.depthOfField = null, this.bloom = null, this.chromaticAberration = null, this._chromaticAberrationEffect = null, this.grain = null, this._grainEffect = null, this._glowLayer = null);
      }, t.prototype.addCamera = function(e) {
        this._camerasToBeAttached.push(e), this._buildPipeline();
      }, t.prototype.removeCamera = function(e) {
        var i = this._camerasToBeAttached.indexOf(e);
        this._camerasToBeAttached.splice(i, 1), this._buildPipeline();
      }, t.prototype.dispose = function() {
        this._buildAllowed = !1, this.onBuildObservable.clear(), this._disposePostProcesses(!0), this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras), this._scene._postProcessRenderPipelineManager.removePipeline(this.name), this._scene.autoClear = !0, this._resizeObserver && (this._scene.getEngine().onResizeObservable.remove(this._resizeObserver), this._resizeObserver = null), this._scene.onActiveCameraChanged.remove(this._activeCameraChangedObserver), this._scene.onActiveCamerasChanged.remove(this._activeCamerasChangedObserver), this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver), n.prototype.dispose.call(this);
      }, t.prototype.serialize = function() {
        var e = Ne.Serialize(this);
        return e.customType = "DefaultRenderingPipeline", e;
      }, t.Parse = function(e, i, r) {
        return Ne.Parse(function() {
          return new t(e._name, e._name._hdr, i);
        }, e, i, r);
      }, x([N()], t.prototype, "sharpenEnabled", null), x([N()], t.prototype, "bloomKernel", null), x([N()], t.prototype, "_bloomWeight", void 0), x([N()], t.prototype, "_bloomThreshold", void 0), x([N()], t.prototype, "_hdr", void 0), x([N()], t.prototype, "bloomWeight", null), x([N()], t.prototype, "bloomThreshold", null), x([N()], t.prototype, "bloomScale", null), x([N()], t.prototype, "bloomEnabled", null), x([N()], t.prototype, "depthOfFieldEnabled", null), x([N()], t.prototype, "depthOfFieldBlurLevel", null), x([N()], t.prototype, "fxaaEnabled", null), x([N()], t.prototype, "samples", null), x([N()], t.prototype, "imageProcessingEnabled", null), x([N()], t.prototype, "glowLayerEnabled", null), x([N()], t.prototype, "chromaticAberrationEnabled", null), x([N()], t.prototype, "grainEnabled", null), t;
    }(Ns);
    j("BABYLON.DefaultRenderingPipeline", cE), re.ShadersStore.lensHighlightsPixelShader = `uniform sampler2D textureSampler; 
uniform float gain;uniform float threshold;uniform float screen_width;uniform float screen_height;varying vec2 vUV;vec4 highlightColor(vec4 color) {vec4 highlight=color;float luminance=dot(highlight.rgb,vec3(0.2125,0.7154,0.0721));float lum_threshold;if (threshold>1.0) { lum_threshold=0.94+0.01*threshold; }
else { lum_threshold=0.5+0.44*threshold; }
luminance=clamp((luminance-lum_threshold)*(1.0/(1.0-lum_threshold)),0.0,1.0);highlight*=luminance*gain;highlight.a=1.0;return highlight;}
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void)
{vec4 original=texture2D(textureSampler,vUV);if (gain==-1.0) {gl_FragColor=vec4(0.0,0.0,0.0,1.0);return;}
float w=2.0/screen_width;float h=2.0/screen_height;float weight=1.0;vec4 blurred=vec4(0.0,0.0,0.0,0.0);
#ifdef PENTAGON
blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.84*w,0.43*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.48*w,-1.29*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.61*w,1.51*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.55*w,-0.74*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.71*w,-0.52*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.94*w,1.59*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.40*w,-1.87*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.62*w,1.16*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.09*w,0.25*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.46*w,-1.71*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.08*w,2.42*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.85*w,-1.89*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.89*w,0.16*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.29*w,1.88*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.40*w,-2.81*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.54*w,2.26*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.60*w,-0.61*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.31*w,-1.30*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.83*w,2.53*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.12*w,-2.48*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.60*w,1.11*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.99*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.50*w,-2.81*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.85*w,3.33*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.94*w,-1.92*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.27*w,-0.53*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.95*w,2.48*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.23*w,-3.04*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.17*w,2.05*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.97*w,-0.04*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.25*w,-2.00*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.31*w,3.08*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.94*w,-2.59*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.37*w,0.64*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.13*w,1.93*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.03*w,-3.65*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.60*w,3.17*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.14*w,-1.19*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.00*w,-1.19*h)));
#else
blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.85*w,0.36*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.52*w,-1.14*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.46*w,1.42*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.46*w,-0.83*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.79*w,-0.42*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.11*w,1.62*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.29*w,-2.07*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.69*w,1.39*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.28*w,0.12*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.65*w,-1.69*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.08*w,2.44*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.63*w,-1.90*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.55*w,0.31*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.13*w,1.52*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.56*w,-2.61*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.38*w,2.34*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.64*w,-0.81*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.53*w,-1.21*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.06*w,2.63*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.00*w,-2.69*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.59*w,1.32*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.78*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.57*w,-2.50*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.54*w,2.93*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.39*w,-1.81*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,-0.28*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.04*w,2.25*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.02*w,-3.05*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.09*w,2.25*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.07*w,-0.25*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.44*w,-1.90*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.52*w,3.05*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.68*w,-2.61*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,0.79*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.76*w,1.46*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.05*w,-2.94*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.21*w,2.88*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.84*w,-1.30*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.98*w,-0.96*h)));
#endif
blurred/=39.0;gl_FragColor=blurred;}`, re.ShadersStore.depthOfFieldPixelShader = `uniform sampler2D textureSampler;uniform sampler2D highlightsSampler;uniform sampler2D depthSampler;uniform sampler2D grainSampler;uniform float grain_amount;uniform bool blur_noise;uniform float screen_width;uniform float screen_height;uniform float distortion;uniform bool dof_enabled;uniform float screen_distance; 
uniform float aperture;uniform float darken;uniform float edge_blur;uniform bool highlights;uniform float near;uniform float far;varying vec2 vUV;
#define PI 3.14159265
#define TWOPI 6.28318530
#define inverse_focal_length 0.1 
vec2 centered_screen_pos;vec2 distorted_coords;float radius2;float radius;vec2 rand(vec2 co)
{float noise1=(fract(sin(dot(co,vec2(12.9898,78.233)))*43758.5453));float noise2=(fract(sin(dot(co,vec2(12.9898,78.233)*2.0))*43758.5453));return clamp(vec2(noise1,noise2),0.0,1.0);}
vec2 getDistortedCoords(vec2 coords) {if (distortion==0.0) { return coords; }
vec2 direction=1.0*normalize(centered_screen_pos);vec2 dist_coords=vec2(0.5,0.5);dist_coords.x=0.5+direction.x*radius2*1.0;dist_coords.y=0.5+direction.y*radius2*1.0;float dist_amount=clamp(distortion*0.23,0.0,1.0);dist_coords=mix(coords,dist_coords,dist_amount);return dist_coords;}
float sampleScreen(inout vec4 color,in vec2 offset,in float weight) {vec2 coords=distorted_coords;float angle=rand(coords*100.0).x*TWOPI;coords+=vec2(offset.x*cos(angle)-offset.y*sin(angle),offset.x*sin(angle)+offset.y*cos(angle));color+=texture2D(textureSampler,coords)*weight;return weight;}
float getBlurLevel(float size) {return min(3.0,ceil(size/1.0));}
vec4 getBlurColor(float size) {vec4 col=texture2D(textureSampler,distorted_coords);float blur_level=getBlurLevel(size);float w=(size/screen_width);float h=(size/screen_height);float total_weight=1.0;vec2 sample_coords;total_weight+=sampleScreen(col,vec2(-0.50*w,0.24*h),0.93);total_weight+=sampleScreen(col,vec2(0.30*w,-0.75*h),0.90);total_weight+=sampleScreen(col,vec2(0.36*w,0.96*h),0.87);total_weight+=sampleScreen(col,vec2(-1.08*w,-0.55*h),0.85);total_weight+=sampleScreen(col,vec2(1.33*w,-0.37*h),0.83);total_weight+=sampleScreen(col,vec2(-0.82*w,1.31*h),0.80);total_weight+=sampleScreen(col,vec2(-0.31*w,-1.67*h),0.78);total_weight+=sampleScreen(col,vec2(1.47*w,1.11*h),0.76);total_weight+=sampleScreen(col,vec2(-1.97*w,0.19*h),0.74);total_weight+=sampleScreen(col,vec2(1.42*w,-1.57*h),0.72);if (blur_level>1.0) {total_weight+=sampleScreen(col,vec2(0.01*w,2.25*h),0.70);total_weight+=sampleScreen(col,vec2(-1.62*w,-1.74*h),0.67);total_weight+=sampleScreen(col,vec2(2.49*w,0.20*h),0.65);total_weight+=sampleScreen(col,vec2(-2.07*w,1.61*h),0.63);total_weight+=sampleScreen(col,vec2(0.46*w,-2.70*h),0.61);total_weight+=sampleScreen(col,vec2(1.55*w,2.40*h),0.59);total_weight+=sampleScreen(col,vec2(-2.88*w,-0.75*h),0.56);total_weight+=sampleScreen(col,vec2(2.73*w,-1.44*h),0.54);total_weight+=sampleScreen(col,vec2(-1.08*w,3.02*h),0.52);total_weight+=sampleScreen(col,vec2(-1.28*w,-3.05*h),0.49);}
if (blur_level>2.0) {total_weight+=sampleScreen(col,vec2(3.11*w,1.43*h),0.46);total_weight+=sampleScreen(col,vec2(-3.36*w,1.08*h),0.44);total_weight+=sampleScreen(col,vec2(1.80*w,-3.16*h),0.41);total_weight+=sampleScreen(col,vec2(0.83*w,3.65*h),0.38);total_weight+=sampleScreen(col,vec2(-3.16*w,-2.19*h),0.34);total_weight+=sampleScreen(col,vec2(3.92*w,-0.53*h),0.31);total_weight+=sampleScreen(col,vec2(-2.59*w,3.12*h),0.26);total_weight+=sampleScreen(col,vec2(-0.20*w,-4.15*h),0.22);total_weight+=sampleScreen(col,vec2(3.02*w,3.00*h),0.15);}
col/=total_weight; 
if (darken>0.0) {col.rgb*=clamp(0.3,1.0,1.05-size*0.5*darken);}
return col;}
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void)
{centered_screen_pos=vec2(vUV.x-0.5,vUV.y-0.5);radius2=centered_screen_pos.x*centered_screen_pos.x+centered_screen_pos.y*centered_screen_pos.y;radius=sqrt(radius2);distorted_coords=getDistortedCoords(vUV); 
vec2 texels_coords=vec2(vUV.x*screen_width,vUV.y*screen_height); 
float depth=texture2D(depthSampler,distorted_coords).r; 
float distance=near+(far-near)*depth; 
vec4 color=texture2D(textureSampler,vUV); 
float coc=abs(aperture*(screen_distance*(inverse_focal_length-1.0/distance)-1.0));if (dof_enabled==false || coc<0.07) { coc=0.0; }
float edge_blur_amount=0.0;if (edge_blur>0.0) {edge_blur_amount=clamp((radius*2.0-1.0+0.15*edge_blur)*1.5,0.0,1.0)*1.3;}
float blur_amount=max(edge_blur_amount,coc);if (blur_amount==0.0) {gl_FragColor=texture2D(textureSampler,distorted_coords);}
else {gl_FragColor=getBlurColor(blur_amount*1.7);if (highlights) {gl_FragColor.rgb+=clamp(coc,0.0,1.0)*texture2D(highlightsSampler,distorted_coords).rgb;}
if (blur_noise) {vec2 noise=rand(distorted_coords)*0.01*blur_amount;vec2 blurred_coord=vec2(distorted_coords.x+noise.x,distorted_coords.y+noise.y);gl_FragColor=0.04*texture2D(textureSampler,blurred_coord)+0.96*gl_FragColor;}}
if (grain_amount>0.0) {vec4 grain_color=texture2D(grainSampler,texels_coords*0.003);gl_FragColor.rgb+=(-0.5+grain_color.rgb)*0.30*grain_amount;}}
`;
    var aI = function(n) {
      function t(e, i, r, o, a) {
        o === void 0 && (o = 1);
        var s = n.call(this, r.getEngine(), e) || this;
        return s.LensChromaticAberrationEffect = "LensChromaticAberrationEffect", s.HighlightsEnhancingEffect = "HighlightsEnhancingEffect", s.LensDepthOfFieldEffect = "LensDepthOfFieldEffect", s._pentagonBokehIsEnabled = !1, s._scene = r, s._depthTexture = r.enableDepthRenderer().getDepthMap(), i.grain_texture ? s._grainTexture = i.grain_texture : s._createGrainTexture(), s._edgeBlur = i.edge_blur ? i.edge_blur : 0, s._grainAmount = i.grain_amount ? i.grain_amount : 0, s._chromaticAberration = i.chromatic_aberration ? i.chromatic_aberration : 0, s._distortion = i.distortion ? i.distortion : 0, s._highlightsGain = i.dof_gain !== void 0 ? i.dof_gain : -1, s._highlightsThreshold = i.dof_threshold ? i.dof_threshold : 1, s._dofDistance = i.dof_focus_distance !== void 0 ? i.dof_focus_distance : -1, s._dofAperture = i.dof_aperture ? i.dof_aperture : 1, s._dofDarken = i.dof_darken ? i.dof_darken : 0, s._dofPentagon = i.dof_pentagon === void 0 || i.dof_pentagon, s._blurNoise = i.blur_noise === void 0 || i.blur_noise, s._createChromaticAberrationPostProcess(o), s._createHighlightsPostProcess(o), s._createDepthOfFieldPostProcess(o / 4), s.addEffect(new Vt(r.getEngine(), s.LensChromaticAberrationEffect, function() {
          return s._chromaticAberrationPostProcess;
        }, !0)), s.addEffect(new Vt(r.getEngine(), s.HighlightsEnhancingEffect, function() {
          return s._highlightsPostProcess;
        }, !0)), s.addEffect(new Vt(r.getEngine(), s.LensDepthOfFieldEffect, function() {
          return s._depthOfFieldPostProcess;
        }, !0)), s._highlightsGain === -1 && s._disableEffect(s.HighlightsEnhancingEffect, null), r.postProcessRenderPipelineManager.addPipeline(s), a && r.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(e, a), s;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "LensRenderingPipeline";
      }, Object.defineProperty(t.prototype, "scene", { get: function() {
        return this._scene;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "edgeBlur", { get: function() {
        return this._edgeBlur;
      }, set: function(e) {
        this.setEdgeBlur(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "grainAmount", { get: function() {
        return this._grainAmount;
      }, set: function(e) {
        this.setGrainAmount(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "chromaticAberration", { get: function() {
        return this._chromaticAberration;
      }, set: function(e) {
        this.setChromaticAberration(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dofAperture", { get: function() {
        return this._dofAperture;
      }, set: function(e) {
        this.setAperture(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "edgeDistortion", { get: function() {
        return this._distortion;
      }, set: function(e) {
        this.setEdgeDistortion(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dofDistortion", { get: function() {
        return this._dofDistance;
      }, set: function(e) {
        this.setFocusDistance(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "darkenOutOfFocus", { get: function() {
        return this._dofDarken;
      }, set: function(e) {
        this.setDarkenOutOfFocus(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "blurNoise", { get: function() {
        return this._blurNoise;
      }, set: function(e) {
        this._blurNoise = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "pentagonBokeh", { get: function() {
        return this._pentagonBokehIsEnabled;
      }, set: function(e) {
        e ? this.enablePentagonBokeh() : this.disablePentagonBokeh();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "highlightsGain", { get: function() {
        return this._highlightsGain;
      }, set: function(e) {
        this.setHighlightsGain(e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "highlightsThreshold", { get: function() {
        return this._highlightsThreshold;
      }, set: function(e) {
        this.setHighlightsThreshold(e);
      }, enumerable: !1, configurable: !0 }), t.prototype.setEdgeBlur = function(e) {
        this._edgeBlur = e;
      }, t.prototype.disableEdgeBlur = function() {
        this._edgeBlur = 0;
      }, t.prototype.setGrainAmount = function(e) {
        this._grainAmount = e;
      }, t.prototype.disableGrain = function() {
        this._grainAmount = 0;
      }, t.prototype.setChromaticAberration = function(e) {
        this._chromaticAberration = e;
      }, t.prototype.disableChromaticAberration = function() {
        this._chromaticAberration = 0;
      }, t.prototype.setEdgeDistortion = function(e) {
        this._distortion = e;
      }, t.prototype.disableEdgeDistortion = function() {
        this._distortion = 0;
      }, t.prototype.setFocusDistance = function(e) {
        this._dofDistance = e;
      }, t.prototype.disableDepthOfField = function() {
        this._dofDistance = -1;
      }, t.prototype.setAperture = function(e) {
        this._dofAperture = e;
      }, t.prototype.setDarkenOutOfFocus = function(e) {
        this._dofDarken = e;
      }, t.prototype.enablePentagonBokeh = function() {
        this._highlightsPostProcess.updateEffect(`#define PENTAGON
`), this._pentagonBokehIsEnabled = !0;
      }, t.prototype.disablePentagonBokeh = function() {
        this._pentagonBokehIsEnabled = !1, this._highlightsPostProcess.updateEffect();
      }, t.prototype.enableNoiseBlur = function() {
        this._blurNoise = !0;
      }, t.prototype.disableNoiseBlur = function() {
        this._blurNoise = !1;
      }, t.prototype.setHighlightsGain = function(e) {
        this._highlightsGain = e;
      }, t.prototype.setHighlightsThreshold = function(e) {
        this._highlightsGain === -1 && (this._highlightsGain = 1), this._highlightsThreshold = e;
      }, t.prototype.disableHighlights = function() {
        this._highlightsGain = -1;
      }, t.prototype.dispose = function(e) {
        e === void 0 && (e = !1), this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras), this._chromaticAberrationPostProcess = null, this._highlightsPostProcess = null, this._depthOfFieldPostProcess = null, this._grainTexture.dispose(), e && this._scene.disableDepthRenderer();
      }, t.prototype._createChromaticAberrationPostProcess = function(e) {
        var i = this;
        this._chromaticAberrationPostProcess = new nt("LensChromaticAberration", "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], [], e, null, ae.TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1), this._chromaticAberrationPostProcess.onApply = function(r) {
          r.setFloat("chromatic_aberration", i._chromaticAberration), r.setFloat("screen_width", i._scene.getEngine().getRenderWidth()), r.setFloat("screen_height", i._scene.getEngine().getRenderHeight()), r.setFloat("radialIntensity", 1), r.setFloat2("direction", 17, 17), r.setFloat2("centerPosition", 0.5, 0.5);
        };
      }, t.prototype._createHighlightsPostProcess = function(e) {
        var i = this;
        this._highlightsPostProcess = new nt("LensHighlights", "lensHighlights", ["gain", "threshold", "screen_width", "screen_height"], [], e, null, ae.TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, this._dofPentagon ? `#define PENTAGON
` : ""), this._highlightsPostProcess.externalTextureSamplerBinding = !0, this._highlightsPostProcess.onApply = function(r) {
          r.setFloat("gain", i._highlightsGain), r.setFloat("threshold", i._highlightsThreshold), r.setTextureFromPostProcess("textureSampler", i._chromaticAberrationPostProcess), r.setFloat("screen_width", i._scene.getEngine().getRenderWidth()), r.setFloat("screen_height", i._scene.getEngine().getRenderHeight());
        };
      }, t.prototype._createDepthOfFieldPostProcess = function(e) {
        var i = this;
        this._depthOfFieldPostProcess = new nt("LensDepthOfField", "depthOfField", ["grain_amount", "blur_noise", "screen_width", "screen_height", "distortion", "dof_enabled", "screen_distance", "aperture", "darken", "edge_blur", "highlights", "near", "far"], ["depthSampler", "grainSampler", "highlightsSampler"], e, null, ae.TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1), this._depthOfFieldPostProcess.externalTextureSamplerBinding = !0, this._depthOfFieldPostProcess.onApply = function(r) {
          r.setTexture("depthSampler", i._depthTexture), r.setTexture("grainSampler", i._grainTexture), r.setTextureFromPostProcess("textureSampler", i._highlightsPostProcess), r.setTextureFromPostProcess("highlightsSampler", i._depthOfFieldPostProcess), r.setFloat("grain_amount", i._grainAmount), r.setBool("blur_noise", i._blurNoise), r.setFloat("screen_width", i._scene.getEngine().getRenderWidth()), r.setFloat("screen_height", i._scene.getEngine().getRenderHeight()), r.setFloat("distortion", i._distortion), r.setBool("dof_enabled", i._dofDistance !== -1), r.setFloat("screen_distance", 1 / (0.1 - 1 / i._dofDistance)), r.setFloat("aperture", i._dofAperture), r.setFloat("darken", i._dofDarken), r.setFloat("edge_blur", i._edgeBlur), r.setBool("highlights", i._highlightsGain !== -1), i._scene.activeCamera && (r.setFloat("near", i._scene.activeCamera.minZ), r.setFloat("far", i._scene.activeCamera.maxZ));
        };
      }, t.prototype._createGrainTexture = function() {
        for (var e = new Uint8Array(1048576), i = 0; i < e.length; ) {
          var r = Math.floor(255 * ue.RandomRange(0.42, 0.58));
          e[i++] = r, e[i++] = r, e[i++] = r, e[i++] = 255;
        }
        var o = on.CreateRGBATexture(e, 512, 512, this._scene, !1, !1, _.TEXTURE_BILINEAR_SAMPLINGMODE);
        o.name = "LensNoiseTexture", o.wrapU = ae.WRAP_ADDRESSMODE, o.wrapV = ae.WRAP_ADDRESSMODE, this._grainTexture = o;
      }, t;
    }(Ns), EN = function() {
      this.enabled = !1, this.name = "ssao2", this.texturesRequired = [_.PREPASS_NORMAL_TEXTURE_TYPE, _.PREPASS_DEPTH_TEXTURE_TYPE];
    };
    re.ShadersStore.ssao2PixelShader = `precision highp float;uniform sampler2D textureSampler;varying vec2 vUV;
#ifdef SSAO
float scales[16]=float[16](
0.1,
0.11406250000000001,
0.131640625,
0.15625,
0.187890625,
0.2265625,
0.272265625,
0.325,
0.384765625,
0.4515625,
0.525390625,
0.60625,
0.694140625,
0.7890625,
0.891015625,
1.0
);uniform float near;uniform float radius;uniform sampler2D depthSampler;uniform sampler2D randomSampler;uniform sampler2D normalSampler;uniform float randTextureTiles;uniform float samplesFactor;uniform vec3 sampleSphere[SAMPLES];uniform float totalStrength;uniform float base;uniform float xViewport;uniform float yViewport;uniform mat3 depthProjection;uniform float maxZ;uniform float minZAspect;uniform vec2 texelSize;uniform mat4 projection;void main()
{vec3 random=textureLod(randomSampler,vUV*randTextureTiles,0.0).rgb;float depth=textureLod(depthSampler,vUV,0.0).r;float depthSign=depth/abs(depth);depth=depth*depthSign;vec3 normal=textureLod(normalSampler,vUV,0.0).rgb;float occlusion=0.0;float correctedRadius=min(radius,minZAspect*depth/near);vec3 vViewRay=vec3((vUV.x*2.0-1.0)*xViewport,(vUV.y*2.0-1.0)*yViewport,depthSign);vec3 vDepthFactor=depthProjection*vec3(1.0,1.0,depth);vec3 origin=vViewRay*vDepthFactor;vec3 rvec=random*2.0-1.0;rvec.z=0.0;float dotProduct=dot(rvec,normal);rvec=1.0-abs(dotProduct)>1e-2 ? rvec : vec3(-rvec.y,0.0,rvec.x);vec3 tangent=normalize(rvec-normal*dot(rvec,normal));vec3 bitangent=cross(normal,tangent);mat3 tbn=mat3(tangent,bitangent,normal);float difference;for (int i=0; i<SAMPLES; ++i) {vec3 samplePosition=scales[(i+int(random.x*16.0)) % 16]*tbn*sampleSphere[(i+int(random.y*16.0)) % 16];samplePosition=samplePosition*correctedRadius+origin;vec4 offset=vec4(samplePosition,1.0);offset=projection*offset;offset.xyz/=offset.w;offset.xy=offset.xy*0.5+0.5;if (offset.x<0.0 || offset.y<0.0 || offset.x>1.0 || offset.y>1.0) {continue;}
float sampleDepth=abs(textureLod(depthSampler,offset.xy,0.0).r);difference=depthSign*samplePosition.z-sampleDepth;float rangeCheck=1.0-smoothstep(correctedRadius*0.5,correctedRadius,difference);occlusion+=step(EPSILON,difference)*rangeCheck;}
occlusion=occlusion*(1.0-smoothstep(maxZ*0.75,maxZ,depth));float ao=1.0-totalStrength*occlusion*samplesFactor;float result=clamp(ao+base,0.0,1.0);gl_FragColor=vec4(vec3(result),1.0);}
#endif
#ifdef BLUR
uniform float outSize;uniform float soften;uniform float tolerance;uniform int samples;
#ifndef BLUR_BYPASS
uniform sampler2D depthSampler;
#ifdef BLUR_LEGACY
#define inline
float blur13Bilateral(sampler2D image,vec2 uv,vec2 step) {float result=0.0;vec2 off1=vec2(1.411764705882353)*step;vec2 off2=vec2(3.2941176470588234)*step;vec2 off3=vec2(5.176470588235294)*step;float compareDepth=abs(textureLod(depthSampler,uv,0.0).r);float sampleDepth;float weight;float weightSum=30.0;result+=textureLod(image,uv,0.0).r*30.0;sampleDepth=abs(textureLod(depthSampler,uv+off1,0.0).r);weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);weightSum+= weight;result+=textureLod(image,uv+off1,0.0).r*weight;sampleDepth=abs(textureLod(depthSampler,uv-off1,0.0).r);weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);weightSum+= weight;result+=textureLod(image,uv-off1,0.0).r*weight;sampleDepth=abs(textureLod(depthSampler,uv+off2,0.0).r);weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);weightSum+=weight;result+=textureLod(image,uv+off2,0.0).r*weight;sampleDepth=abs(textureLod(depthSampler,uv-off2,0.0).r);weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);weightSum+=weight;result+=textureLod(image,uv-off2,0.0).r*weight;sampleDepth=abs(textureLod(depthSampler,uv+off3,0.0).r);weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);weightSum+=weight;result+=textureLod(image,uv+off3,0.0).r*weight;sampleDepth=abs(textureLod(depthSampler,uv-off3,0.0).r);weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);weightSum+=weight;result+=textureLod(image,uv-off3,0.0).r*weight;return result/weightSum;}
#endif
#endif
void main()
{float result=0.0;
#ifdef BLUR_BYPASS
result=textureLod(textureSampler,vUV,0.0).r;
#else
#ifdef BLUR_H
vec2 step=vec2(1.0/outSize,0.0);
#else
vec2 step=vec2(0.0,1.0/outSize);
#endif
#ifdef BLUR_LEGACY
result=blur13Bilateral(textureSampler,vUV,step);
#else
float compareDepth=abs(textureLod(depthSampler,vUV,0.0).r);float weightSum=0.0;for (int i=-samples; i<samples; i+=2)
{vec2 samplePos=vUV+step*(float(i)+0.5);float sampleDepth=abs(textureLod(depthSampler,samplePos,0.0).r);float falloff=smoothstep(0.0,
float(samples),
float(samples)-abs(float(i))*soften);float minDivider=tolerance*0.5+0.003;float weight=falloff/( minDivider+abs(compareDepth-sampleDepth));result+=textureLod(textureSampler,samplePos,0.0).r*weight;weightSum+=weight;}
result/=weightSum;
#endif
#endif
gl_FragColor.rgb=vec3(result);gl_FragColor.a=1.0;}
#endif
`, re.ShadersStore.ssaoCombinePixelShader = `uniform sampler2D textureSampler;uniform sampler2D originalColor;uniform vec4 viewport;varying vec2 vUV;
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void) {
#define CUSTOM_FRAGMENT_MAIN_BEGIN
vec4 ssaoColor=texture2D(textureSampler,viewport.xy+vUV*viewport.zw);vec4 sceneColor=texture2D(originalColor,vUV);gl_FragColor=sceneColor*ssaoColor;
#define CUSTOM_FRAGMENT_MAIN_END
}
`;
    var uE = function(n) {
      function t(e, i, r, o, a, s) {
        a === void 0 && (a = !1), s === void 0 && (s = _.TEXTURETYPE_UNSIGNED_INT);
        var l, c, u = this;
        if ((u = n.call(this, i.getEngine(), e) || this).SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect", u.SSAORenderEffect = "SSAORenderEffect", u.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect", u.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect", u.SSAOCombineRenderEffect = "SSAOCombineRenderEffect", u.totalStrength = 1, u.maxZ = 100, u.minZAspect = 0.2, u._epsilon = 0.02, u._samples = 8, u._textureSamples = 1, u._forceGeometryBuffer = !1, u.radius = 2, u.base = 0, u._bypassBlur = !1, u._expensiveBlur = !0, u.bilateralSamples = 16, u.bilateralSoften = 0, u.bilateralTolerance = 0, u._bits = new Uint32Array(1), u._scene = i, u._ratio = r, u._textureType = s, u._forceGeometryBuffer = a, !u.isSupported)
          return q.Error("The current engine does not support SSAO 2."), u;
        var h = u._ratio.ssaoRatio || r, d = u._ratio.blurRatio || r;
        return u._forceGeometryBuffer ? (i.enableGeometryBufferRenderer(), !((l = i.geometryBufferRenderer) === null || l === void 0) && l.generateNormalsInWorldSpace && console.error("SSAO2RenderingPipeline does not support generateNormalsInWorldSpace=true for the geometry buffer renderer!")) : (i.enablePrePassRenderer(), !((c = i.prePassRenderer) === null || c === void 0) && c.generateNormalsInWorldSpace && console.error("SSAO2RenderingPipeline does not support generateNormalsInWorldSpace=true for the prepass renderer!")), u._createRandomTexture(), u._originalColorPostProcess = new da("SSAOOriginalSceneColor", 1, null, ae.BILINEAR_SAMPLINGMODE, i.getEngine(), void 0, u._textureType), u._originalColorPostProcess.samples = u.textureSamples, u._createSSAOPostProcess(1, s), u._createBlurPostProcess(h, d, u._textureType), u._createSSAOCombinePostProcess(d, u._textureType), u.addEffect(new Vt(i.getEngine(), u.SSAOOriginalSceneColorEffect, function() {
          return u._originalColorPostProcess;
        }, !0)), u.addEffect(new Vt(i.getEngine(), u.SSAORenderEffect, function() {
          return u._ssaoPostProcess;
        }, !0)), u.addEffect(new Vt(i.getEngine(), u.SSAOBlurHRenderEffect, function() {
          return u._blurHPostProcess;
        }, !0)), u.addEffect(new Vt(i.getEngine(), u.SSAOBlurVRenderEffect, function() {
          return u._blurVPostProcess;
        }, !0)), u.addEffect(new Vt(i.getEngine(), u.SSAOCombineRenderEffect, function() {
          return u._ssaoCombinePostProcess;
        }, !0)), i.postProcessRenderPipelineManager.addPipeline(u), o && i.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(e, o), u;
      }
      return D(t, n), Object.defineProperty(t.prototype, "epsilon", { get: function() {
        return this._epsilon;
      }, set: function(e) {
        this._epsilon = e, this._ssaoPostProcess.updateEffect(this._getDefinesForSSAO());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "samples", { get: function() {
        return this._samples;
      }, set: function(e) {
        this._samples = e, this._ssaoPostProcess.updateEffect(this._getDefinesForSSAO()), this._sampleSphere = this._generateHemisphere();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "textureSamples", { get: function() {
        return this._textureSamples;
      }, set: function(e) {
        this._textureSamples = e, this._prePassRenderer ? this._prePassRenderer.samples = e : this._originalColorPostProcess.samples = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "_geometryBufferRenderer", { get: function() {
        return this._forceGeometryBuffer ? this._scene.geometryBufferRenderer : null;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "_prePassRenderer", { get: function() {
        return this._forceGeometryBuffer ? null : this._scene.prePassRenderer;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "bypassBlur", { get: function() {
        return this._bypassBlur;
      }, set: function(e) {
        var i = this._getDefinesForBlur(this.expensiveBlur, e), r = this._getSamplersForBlur(e);
        this._blurHPostProcess.updateEffect(i.h, null, r), this._blurVPostProcess.updateEffect(i.v, null, r), this._bypassBlur = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "expensiveBlur", { get: function() {
        return this._expensiveBlur;
      }, set: function(e) {
        var i = this._getDefinesForBlur(e, this._bypassBlur);
        this._blurHPostProcess.updateEffect(i.h), this._blurVPostProcess.updateEffect(i.v), this._expensiveBlur = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "IsSupported", { get: function() {
        var e = Me.LastCreatedEngine;
        return !!e && e._features.supportSSAO2;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "scene", { get: function() {
        return this._scene;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "SSAO2RenderingPipeline";
      }, t.prototype.dispose = function(e) {
        e === void 0 && (e = !1);
        for (var i = 0; i < this._scene.cameras.length; i++) {
          var r = this._scene.cameras[i];
          this._originalColorPostProcess.dispose(r), this._ssaoPostProcess.dispose(r), this._blurHPostProcess.dispose(r), this._blurVPostProcess.dispose(r), this._ssaoCombinePostProcess.dispose(r);
        }
        this._randomTexture.dispose(), e && this._scene.disableGeometryBufferRenderer(), this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras), n.prototype.dispose.call(this);
      }, t.prototype._rebuild = function() {
        n.prototype._rebuild.call(this);
      }, t.prototype._getSamplersForBlur = function(e) {
        return e ? ["textureSampler"] : ["textureSampler", "depthSampler"];
      }, t.prototype._getDefinesForBlur = function(e, i) {
        var r = `#define BLUR
`;
        return i && (r += `#define BLUR_BYPASS
`), e || (r += `#define BLUR_LEGACY
`), { h: r + `#define BLUR_H
`, v: r };
      }, t.prototype._createBlurPostProcess = function(e, i, r) {
        var o = this._getDefinesForBlur(this.expensiveBlur, this.bypassBlur), a = this._getSamplersForBlur(this.bypassBlur);
        this._blurHPostProcess = this._createBlurFilter("BlurH", a, e, o.h, r, !0), this._blurVPostProcess = this._createBlurFilter("BlurV", a, i, o.v, r, !1);
      }, t.prototype._createBlurFilter = function(e, i, r, o, a, s) {
        var l = this, c = new nt(e, "ssao2", ["outSize", "samples", "soften", "tolerance"], i, r, null, ae.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, o, a);
        return c.onApply = function(u) {
          if (l._scene.activeCamera) {
            var h = s ? l._ssaoCombinePostProcess.width : l._ssaoCombinePostProcess.height, d = s ? l._originalColorPostProcess.width : l._originalColorPostProcess.height;
            u.setFloat("outSize", h > 0 ? h : d), u.setInt("samples", l.bilateralSamples), u.setFloat("soften", l.bilateralSoften), u.setFloat("tolerance", l.bilateralTolerance), l._geometryBufferRenderer ? u.setTexture("depthSampler", l._geometryBufferRenderer.getGBuffer().textures[0]) : l._prePassRenderer && u.setTexture("depthSampler", l._prePassRenderer.getRenderTarget().textures[l._prePassRenderer.getIndex(_.PREPASS_DEPTH_TEXTURE_TYPE)]);
          }
        }, c.samples = this.textureSamples, c;
      }, t.prototype._radicalInverse_VdC = function(e) {
        return this._bits[0] = e, this._bits[0] = (this._bits[0] << 16 | this._bits[0] >> 16) >>> 0, this._bits[0] = (1431655765 & this._bits[0]) << 1 | (2863311530 & this._bits[0]) >>> 1 >>> 0, this._bits[0] = (858993459 & this._bits[0]) << 2 | (3435973836 & this._bits[0]) >>> 2 >>> 0, this._bits[0] = (252645135 & this._bits[0]) << 4 | (4042322160 & this._bits[0]) >>> 4 >>> 0, this._bits[0] = (16711935 & this._bits[0]) << 8 | (4278255360 & this._bits[0]) >>> 8 >>> 0, 23283064365386963e-26 * this._bits[0];
      }, t.prototype._hammersley = function(e, i) {
        return [e / i, this._radicalInverse_VdC(e)];
      }, t.prototype._hemisphereSample_uniform = function(e, i) {
        var r = 2 * i * Math.PI, o = 1 - 0.85 * e, a = Math.sqrt(1 - o * o);
        return new v(Math.cos(r) * a, Math.sin(r) * a, o);
      }, t.prototype._generateHemisphere = function() {
        for (var e, i = this.samples, r = [], o = 0; o < i; ) {
          if (i < 16)
            e = this._hemisphereSample_uniform(Math.random(), Math.random());
          else {
            var a = this._hammersley(o, i);
            e = this._hemisphereSample_uniform(a[0], a[1]);
          }
          r.push(e.x, e.y, e.z), o++;
        }
        return r;
      }, t.prototype._getDefinesForSSAO = function() {
        return `#define SSAO
#define SAMPLES `.concat(this.samples, `
#define EPSILON `).concat(this.epsilon.toFixed(4));
      }, t.prototype._createSSAOPostProcess = function(e, i) {
        var r = this;
        this._sampleSphere = this._generateHemisphere();
        var o = this._getDefinesForSSAO();
        this._ssaoPostProcess = new nt("ssao2", "ssao2", ["sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius", "base", "range", "projection", "near", "texelSize", "xViewport", "yViewport", "maxZ", "minZAspect", "depthProjection"], ["randomSampler", "depthSampler", "normalSampler"], e, null, ae.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, o, i), this._ssaoPostProcess.onApply = function(a) {
          var s, l, c, u;
          if (r._scene.activeCamera) {
            if (a.setArray3("sampleSphere", r._sampleSphere), a.setFloat("randTextureTiles", 32), a.setFloat("samplesFactor", 1 / r.samples), a.setFloat("totalStrength", r.totalStrength), a.setFloat2("texelSize", 1 / r._ssaoPostProcess.width, 1 / r._ssaoPostProcess.height), a.setFloat("radius", r.radius), a.setFloat("maxZ", r.maxZ), a.setFloat("minZAspect", r.minZAspect), a.setFloat("base", r.base), a.setFloat("near", r._scene.activeCamera.minZ), r._scene.activeCamera.mode === dt.PERSPECTIVE_CAMERA)
              a.setMatrix3x3("depthProjection", t.PERSPECTIVE_DEPTH_PROJECTION), a.setFloat("xViewport", Math.tan(r._scene.activeCamera.fov / 2) * r._scene.getEngine().getAspectRatio(r._scene.activeCamera, !0)), a.setFloat("yViewport", Math.tan(r._scene.activeCamera.fov / 2));
            else {
              var h = r._scene.getEngine().getRenderWidth() / 2, d = r._scene.getEngine().getRenderHeight() / 2, p = (s = r._scene.activeCamera.orthoLeft) !== null && s !== void 0 ? s : -h, f = (l = r._scene.activeCamera.orthoRight) !== null && l !== void 0 ? l : h, m = (c = r._scene.activeCamera.orthoBottom) !== null && c !== void 0 ? c : -d, g = (u = r._scene.activeCamera.orthoTop) !== null && u !== void 0 ? u : d;
              a.setMatrix3x3("depthProjection", t.ORTHO_DEPTH_PROJECTION), a.setFloat("xViewport", 0.5 * (f - p)), a.setFloat("yViewport", 0.5 * (g - m));
            }
            a.setMatrix("projection", r._scene.getProjectionMatrix()), r._geometryBufferRenderer ? (a.setTexture("depthSampler", r._geometryBufferRenderer.getGBuffer().textures[0]), a.setTexture("normalSampler", r._geometryBufferRenderer.getGBuffer().textures[1])) : r._prePassRenderer && (a.setTexture("depthSampler", r._prePassRenderer.getRenderTarget().textures[r._prePassRenderer.getIndex(_.PREPASS_DEPTH_TEXTURE_TYPE)]), a.setTexture("normalSampler", r._prePassRenderer.getRenderTarget().textures[r._prePassRenderer.getIndex(_.PREPASS_NORMAL_TEXTURE_TYPE)])), a.setTexture("randomSampler", r._randomTexture);
          }
        }, this._ssaoPostProcess.samples = this.textureSamples, this._forceGeometryBuffer || (this._ssaoPostProcess._prePassEffectConfiguration = new EN());
      }, t.prototype._createSSAOCombinePostProcess = function(e, i) {
        var r = this;
        this._ssaoCombinePostProcess = new nt("ssaoCombine", "ssaoCombine", [], ["originalColor", "viewport"], e, null, ae.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, void 0, i), this._ssaoCombinePostProcess.onApply = function(o) {
          var a = r._scene.activeCamera.viewport;
          o.setVector4("viewport", F.Vector4[0].copyFromFloats(a.x, a.y, a.width, a.height)), o.setTextureFromPostProcessOutput("originalColor", r._originalColorPostProcess);
        }, this._ssaoCombinePostProcess.samples = this.textureSamples;
      }, t.prototype._createRandomTexture = function() {
        for (var e = new Uint8Array(65536), i = fe.Zero(), r = 0; r < e.length; )
          i.set(ue.RandomRange(0, 1), ue.RandomRange(0, 1)).normalize().scaleInPlace(255), e[r++] = Math.floor(i.x), e[r++] = Math.floor(i.y), e[r++] = 0, e[r++] = 255;
        var o = on.CreateRGBATexture(e, 128, 128, this._scene, !1, !1, _.TEXTURE_BILINEAR_SAMPLINGMODE);
        o.name = "SSAORandomTexture", o.wrapU = ae.WRAP_ADDRESSMODE, o.wrapV = ae.WRAP_ADDRESSMODE, this._randomTexture = o;
      }, t.prototype.serialize = function() {
        var e = Ne.Serialize(this);
        return e.customType = "SSAO2RenderingPipeline", e;
      }, t.Parse = function(e, i, r) {
        return Ne.Parse(function() {
          return new t(e._name, i, e._ratio, void 0, e._forceGeometryBuffer, e._textureType);
        }, e, i, r);
      }, t.ORTHO_DEPTH_PROJECTION = [1, 0, 0, 0, 1, 0, 0, 0, 1], t.PERSPECTIVE_DEPTH_PROJECTION = [0, 0, 0, 0, 0, 0, 1, 1, 1], x([N()], t.prototype, "totalStrength", void 0), x([N()], t.prototype, "maxZ", void 0), x([N()], t.prototype, "minZAspect", void 0), x([N("epsilon")], t.prototype, "_epsilon", void 0), x([N("samples")], t.prototype, "_samples", void 0), x([N("textureSamples")], t.prototype, "_textureSamples", void 0), x([N()], t.prototype, "_forceGeometryBuffer", void 0), x([N()], t.prototype, "_ratio", void 0), x([N()], t.prototype, "_textureType", void 0), x([N()], t.prototype, "radius", void 0), x([N()], t.prototype, "base", void 0), x([N("bypassBlur")], t.prototype, "_bypassBlur", void 0), x([N("expensiveBlur")], t.prototype, "_expensiveBlur", void 0), x([N()], t.prototype, "bilateralSamples", void 0), x([N()], t.prototype, "bilateralSoften", void 0), x([N()], t.prototype, "bilateralTolerance", void 0), t;
    }(Ns);
    j("BABYLON.SSAO2RenderingPipeline", uE), re.ShadersStore.ssaoPixelShader = `uniform sampler2D textureSampler;varying vec2 vUV;
#ifdef SSAO
uniform sampler2D randomSampler;uniform float randTextureTiles;uniform float samplesFactor;uniform vec3 sampleSphere[SAMPLES];uniform float totalStrength;uniform float radius;uniform float area;uniform float fallOff;uniform float base;vec3 normalFromDepth(float depth,vec2 coords)
{vec2 offset1=vec2(0.0,radius);vec2 offset2=vec2(radius,0.0);float depth1=texture2D(textureSampler,coords+offset1).r;float depth2=texture2D(textureSampler,coords+offset2).r;vec3 p1=vec3(offset1,depth1-depth);vec3 p2=vec3(offset2,depth2-depth);vec3 normal=cross(p1,p2);normal.z=-normal.z;return normalize(normal);}
void main()
{vec3 random=normalize(texture2D(randomSampler,vUV*randTextureTiles).rgb);float depth=texture2D(textureSampler,vUV).r;vec3 position=vec3(vUV,depth);vec3 normal=normalFromDepth(depth,vUV);float radiusDepth=radius/depth;float occlusion=0.0;vec3 ray;vec3 hemiRay;float occlusionDepth;float difference;for (int i=0; i<SAMPLES; i++)
{ray=radiusDepth*reflect(sampleSphere[i],random);hemiRay=position+sign(dot(ray,normal))*ray;occlusionDepth=texture2D(textureSampler,clamp(hemiRay.xy,vec2(0.001,0.001),vec2(0.999,0.999))).r;difference=depth-occlusionDepth;occlusion+=step(fallOff,difference)*(1.0-smoothstep(fallOff,area,difference));}
float ao=1.0-totalStrength*occlusion*samplesFactor;float result=clamp(ao+base,0.0,1.0);gl_FragColor.r=result;gl_FragColor.g=result;gl_FragColor.b=result;gl_FragColor.a=1.0;}
#endif
`;
    var sI = function(n) {
      function t(e, i, r, o) {
        var a = n.call(this, i.getEngine(), e) || this;
        a.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect", a.SSAORenderEffect = "SSAORenderEffect", a.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect", a.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect", a.SSAOCombineRenderEffect = "SSAOCombineRenderEffect", a.totalStrength = 1, a.radius = 1e-4, a.area = 75e-4, a.fallOff = 1e-6, a.base = 0.5, a._firstUpdate = !0, a._scene = i, a._createRandomTexture();
        var s = r.ssaoRatio || r, l = r.combineRatio || r;
        return a._originalColorPostProcess = new da("SSAOOriginalSceneColor", l, null, ae.BILINEAR_SAMPLINGMODE, i.getEngine(), !1), a._createSSAOPostProcess(s), a._createBlurPostProcess(s), a._createSSAOCombinePostProcess(l), a.addEffect(new Vt(i.getEngine(), a.SSAOOriginalSceneColorEffect, function() {
          return a._originalColorPostProcess;
        }, !0)), a.addEffect(new Vt(i.getEngine(), a.SSAORenderEffect, function() {
          return a._ssaoPostProcess;
        }, !0)), a.addEffect(new Vt(i.getEngine(), a.SSAOBlurHRenderEffect, function() {
          return a._blurHPostProcess;
        }, !0)), a.addEffect(new Vt(i.getEngine(), a.SSAOBlurVRenderEffect, function() {
          return a._blurVPostProcess;
        }, !0)), a.addEffect(new Vt(i.getEngine(), a.SSAOCombineRenderEffect, function() {
          return a._ssaoCombinePostProcess;
        }, !0)), i.postProcessRenderPipelineManager.addPipeline(a), o && i.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(e, o), a;
      }
      return D(t, n), Object.defineProperty(t.prototype, "scene", { get: function() {
        return this._scene;
      }, enumerable: !1, configurable: !0 }), t.prototype._attachCameras = function(e, i) {
        n.prototype._attachCameras.call(this, e, i);
        for (var r = 0, o = this._cameras; r < o.length; r++) {
          var a = o[r];
          this._scene.enableDepthRenderer(a).getDepthMap();
        }
      }, t.prototype.getClassName = function() {
        return "SSAORenderingPipeline";
      }, t.prototype.dispose = function(e) {
        e === void 0 && (e = !1);
        for (var i = 0; i < this._scene.cameras.length; i++) {
          var r = this._scene.cameras[i];
          this._originalColorPostProcess.dispose(r), this._ssaoPostProcess.dispose(r), this._blurHPostProcess.dispose(r), this._blurVPostProcess.dispose(r), this._ssaoCombinePostProcess.dispose(r);
        }
        this._randomTexture.dispose(), e && this._scene.disableDepthRenderer(), this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras), n.prototype.dispose.call(this);
      }, t.prototype._createBlurPostProcess = function(e) {
        var i = this;
        this._blurHPostProcess = new Cn("BlurH", new fe(1, 0), 16, e, null, ae.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, _.TEXTURETYPE_UNSIGNED_INT), this._blurVPostProcess = new Cn("BlurV", new fe(0, 1), 16, e, null, ae.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, _.TEXTURETYPE_UNSIGNED_INT), this._blurHPostProcess.onActivateObservable.add(function() {
          var r = i._blurHPostProcess.width / i._scene.getEngine().getRenderWidth();
          i._blurHPostProcess.kernel = 16 * r;
        }), this._blurVPostProcess.onActivateObservable.add(function() {
          var r = i._blurVPostProcess.height / i._scene.getEngine().getRenderHeight();
          i._blurVPostProcess.kernel = 16 * r;
        });
      }, t.prototype._rebuild = function() {
        this._firstUpdate = !0, n.prototype._rebuild.call(this);
      }, t.prototype._createSSAOPostProcess = function(e) {
        var i = this, r = [0.5381, 0.1856, -0.4319, 0.1379, 0.2486, 0.443, 0.3371, 0.5679, -57e-4, -0.6999, -0.0451, -19e-4, 0.0689, -0.1598, -0.8547, 0.056, 69e-4, -0.1843, -0.0146, 0.1402, 0.0762, 0.01, -0.1924, -0.0344, -0.3577, -0.5301, -0.4358, -0.3169, 0.1063, 0.0158, 0.0103, -0.5869, 46e-4, -0.0897, -0.494, 0.3287, 0.7119, -0.0154, -0.0918, -0.0533, 0.0596, -0.5411, 0.0352, -0.0631, 0.546, -0.4776, 0.2847, -0.0271];
        this._ssaoPostProcess = new nt("ssao", "ssao", ["sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius", "area", "fallOff", "base", "range", "viewport"], ["randomSampler"], e, null, ae.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, `#define SAMPLES 16
#define SSAO`), this._ssaoPostProcess.externalTextureSamplerBinding = !0, this._ssaoPostProcess.onApply = function(o) {
          i._firstUpdate && (o.setArray3("sampleSphere", r), o.setFloat("samplesFactor", 0.0625), o.setFloat("randTextureTiles", 4)), o.setFloat("totalStrength", i.totalStrength), o.setFloat("radius", i.radius), o.setFloat("area", i.area), o.setFloat("fallOff", i.fallOff), o.setFloat("base", i.base), o.setTexture("textureSampler", i._scene.enableDepthRenderer(i._scene.activeCamera).getDepthMap()), o.setTexture("randomSampler", i._randomTexture);
        };
      }, t.prototype._createSSAOCombinePostProcess = function(e) {
        var i = this;
        this._ssaoCombinePostProcess = new nt("ssaoCombine", "ssaoCombine", [], ["originalColor", "viewport"], e, null, ae.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1), this._ssaoCombinePostProcess.onApply = function(r) {
          r.setVector4("viewport", F.Vector4[0].copyFromFloats(0, 0, 1, 1)), r.setTextureFromPostProcess("originalColor", i._originalColorPostProcess);
        };
      }, t.prototype._createRandomTexture = function() {
        for (var e = new Uint8Array(1048576), i = 0; i < e.length; )
          e[i++] = Math.floor(255 * Math.max(0, ue.RandomRange(-1, 1))), e[i++] = Math.floor(255 * Math.max(0, ue.RandomRange(-1, 1))), e[i++] = Math.floor(255 * Math.max(0, ue.RandomRange(-1, 1))), e[i++] = 255;
        var r = on.CreateRGBATexture(e, 512, 512, this._scene, !1, !1, _.TEXTURE_BILINEAR_SAMPLINGMODE);
        r.name = "SSAORandomTexture", r.wrapU = ae.WRAP_ADDRESSMODE, r.wrapV = ae.WRAP_ADDRESSMODE, this._randomTexture = r;
      }, x([N()], t.prototype, "totalStrength", void 0), x([N()], t.prototype, "radius", void 0), x([N()], t.prototype, "area", void 0), x([N()], t.prototype, "fallOff", void 0), x([N()], t.prototype, "base", void 0), t;
    }(Ns), SN = function() {
      this.enabled = !1, this.name = "screenSpaceReflections", this.texturesRequired = [_.PREPASS_NORMAL_TEXTURE_TYPE, _.PREPASS_REFLECTIVITY_TEXTURE_TYPE, _.PREPASS_POSITION_TEXTURE_TYPE];
    };
    re.ShadersStore.screenSpaceReflectionPixelShader = `uniform sampler2D textureSampler;
#ifdef SSR_SUPPORTED
uniform sampler2D reflectivitySampler;uniform sampler2D normalSampler;uniform sampler2D positionSampler;
#endif
uniform mat4 view;uniform mat4 projection;uniform float stepSize;uniform float strength;uniform float threshold;uniform float roughnessFactor;uniform float reflectionSpecularFalloffExponent;varying vec2 vUV;
#ifdef SSR_SUPPORTED
struct ReflectionInfo {vec3 color;vec4 coords;};/**
* According to specular,see https:
*/
vec3 fresnelSchlick(float cosTheta,vec3 F0)
{return F0+(1.0-F0)*pow(1.0-cosTheta,5.0);}
/**
* Once the pixel's coordinates has been found,let's adjust (smooth) a little bit
* by sampling multiple reflection pixels.
*/
ReflectionInfo smoothReflectionInfo(vec3 dir,vec3 hitCoord)
{ReflectionInfo info;info.color=vec3(0.0);vec4 projectedCoord;float sampledDepth;for(int i=0; i<SMOOTH_STEPS; i++)
{projectedCoord=projection*vec4(hitCoord,1.0);projectedCoord.xy/=projectedCoord.w;projectedCoord.xy=0.5*projectedCoord.xy+vec2(0.5);sampledDepth=(view*texture2D(positionSampler,projectedCoord.xy)).z;float depth=sampledDepth-hitCoord.z;dir*=0.5;if(depth>0.0)
hitCoord-=dir;else
hitCoord+=dir;info.color+=texture2D(textureSampler,projectedCoord.xy).rgb;}
projectedCoord=projection*vec4(hitCoord,1.0);projectedCoord.xy/=projectedCoord.w;projectedCoord.xy=0.5*projectedCoord.xy+vec2(0.5);info.coords=vec4(projectedCoord.xy,sampledDepth,1.0);info.color+=texture2D(textureSampler,projectedCoord.xy).rgb;info.color/=float(SMOOTH_STEPS+1);return info;}
/**
* Tests the given world position (hitCoord) according to the given reflection vector (dir)
* until it finds a collision (means that depth is enough close to say "it's the pixel to sample!").
*/
ReflectionInfo getReflectionInfo(vec3 dir,vec3 hitCoord)
{ReflectionInfo info;vec4 projectedCoord;float sampledDepth;dir*=stepSize;for(int i=0; i<REFLECTION_SAMPLES; i++)
{hitCoord+=dir;projectedCoord=projection*vec4(hitCoord,1.0);projectedCoord.xy/=projectedCoord.w;projectedCoord.xy=0.5*projectedCoord.xy+vec2(0.5);sampledDepth=(view*texture2D(positionSampler,projectedCoord.xy)).z;float depth=sampledDepth-hitCoord.z;
#ifdef RIGHT_HANDED_SCENE
depth*=-1.0;
#endif
if(((depth-dir.z)<threshold) && depth<=0.0)
{
#ifdef ENABLE_SMOOTH_REFLECTIONS
return smoothReflectionInfo(dir,hitCoord);
#else
info.color=texture2D(textureSampler,projectedCoord.xy).rgb;info.coords=vec4(projectedCoord.xy,sampledDepth,0.0);return info;
#endif
}}
info.color=texture2D(textureSampler,projectedCoord.xy).rgb;info.coords=vec4(projectedCoord.xy,sampledDepth,0.0);return info;}
vec3 hash(vec3 a)
{a=fract(a*0.8);a+=dot(a,a.yxz+19.19);return fract((a.xxy+a.yxx)*a.zyx);}
#endif
void main()
{
#ifdef SSR_SUPPORTED
vec4 albedoFull=texture2D(textureSampler,vUV);vec3 albedo=albedoFull.rgb;float spec=texture2D(reflectivitySampler,vUV).r;if (spec==0.0) {gl_FragColor=albedoFull;return;}
vec3 normal=(texture2D(normalSampler,vUV)).xyz;vec3 position=(view*texture2D(positionSampler,vUV)).xyz;vec3 reflected=normalize(reflect(normalize(position),normalize(normal)));float roughness=1.0-texture2D(reflectivitySampler,vUV).a;vec3 jitt=mix(vec3(0.0),hash(position),roughness)*roughnessFactor;ReflectionInfo info=getReflectionInfo(jitt+reflected,position);vec2 dCoords=smoothstep(0.2,0.6,abs(vec2(0.5,0.5)-info.coords.xy));float screenEdgefactor=clamp(1.0-(dCoords.x+dCoords.y),0.0,1.0);vec3 F0=vec3(0.04);F0 =mix(F0,albedo,spec);vec3 fresnel=fresnelSchlick(max(dot(normalize(normal),normalize(position)),0.0),F0);
#ifdef RIGHT_HANDED_SCENE
reflected.z*=-1.0;
#endif
float reflectionMultiplier=clamp(pow(spec*strength,reflectionSpecularFalloffExponent)*screenEdgefactor*reflected.z,0.0,0.9);float albedoMultiplier=1.0-reflectionMultiplier;vec3 SSR=info.color*fresnel;gl_FragColor=vec4((albedo*albedoMultiplier)+(SSR*reflectionMultiplier),albedoFull.a);
#else
gl_FragColor=texture2D(textureSampler,vUV);
#endif
}
`;
    var pm = function(n) {
      function t(e, i, r, o, a, s, l, c, u, h) {
        c === void 0 && (c = _.TEXTURETYPE_UNSIGNED_INT), u === void 0 && (u = !1), h === void 0 && (h = !1);
        var d = n.call(this, e, "screenSpaceReflection", ["projection", "view", "threshold", "reflectionSpecularFalloffExponent", "strength", "stepSize", "roughnessFactor"], ["textureSampler", "normalSampler", "positionSampler", "reflectivitySampler"], r, o, a, s, l, `#define SSR_SUPPORTED
#define REFLECTION_SAMPLES 64
#define SMOOTH_STEPS 5
`, c, void 0, null, u) || this;
        if (d.threshold = 1.2, d.strength = 1, d.reflectionSpecularFalloffExponent = 3, d.step = 1, d.roughnessFactor = 0.2, d._forceGeometryBuffer = !1, d._enableSmoothReflections = !1, d._reflectionSamples = 64, d._smoothSteps = 5, d._forceGeometryBuffer = h, d._forceGeometryBuffer) {
          var p = i.enableGeometryBufferRenderer();
          p && p.isSupported && (p.enablePosition = !0, p.enableReflectivity = !0, p.generateNormalsInWorldSpace && console.error("ScreenSpaceReflectionPostProcess does not support generateNormalsInWorldSpace=true for the geometry buffer renderer!"));
        } else {
          var f = i.enablePrePassRenderer();
          f == null || f.markAsDirty(), f != null && f.generateNormalsInWorldSpace && console.error("ScreenSpaceReflectionPostProcess does not support generateNormalsInWorldSpace=true for the prepass renderer!"), d._prePassEffectConfiguration = new SN();
        }
        return d._updateEffectDefines(), d.onApply = function(m) {
          var g = d._geometryBufferRenderer, y = d._prePassRenderer;
          if (y || g) {
            if (g) {
              var b = g.getTextureIndex(mr.POSITION_TEXTURE_TYPE), T = g.getTextureIndex(mr.REFLECTIVITY_TEXTURE_TYPE);
              m.setTexture("normalSampler", g.getGBuffer().textures[1]), m.setTexture("positionSampler", g.getGBuffer().textures[b]), m.setTexture("reflectivitySampler", g.getGBuffer().textures[T]);
            } else if (y) {
              b = y.getIndex(_.PREPASS_POSITION_TEXTURE_TYPE), T = y.getIndex(_.PREPASS_REFLECTIVITY_TEXTURE_TYPE);
              var S = y.getIndex(_.PREPASS_NORMAL_TEXTURE_TYPE);
              m.setTexture("normalSampler", y.getRenderTarget().textures[S]), m.setTexture("positionSampler", y.getRenderTarget().textures[b]), m.setTexture("reflectivitySampler", y.getRenderTarget().textures[T]);
            }
            var E = i.activeCamera;
            if (E) {
              var A = E.getViewMatrix(!0), R = E.getProjectionMatrix(!0);
              m.setMatrix("projection", R), m.setMatrix("view", A), m.setFloat("threshold", d.threshold), m.setFloat("reflectionSpecularFalloffExponent", d.reflectionSpecularFalloffExponent), m.setFloat("strength", d.strength), m.setFloat("stepSize", d.step), m.setFloat("roughnessFactor", d.roughnessFactor);
            }
          }
        }, d._isSceneRightHanded = i.useRightHandedSystem, d;
      }
      return D(t, n), Object.defineProperty(t.prototype, "_geometryBufferRenderer", { get: function() {
        return this._forceGeometryBuffer ? this._scene.geometryBufferRenderer : null;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "_prePassRenderer", { get: function() {
        return this._forceGeometryBuffer ? null : this._scene.prePassRenderer;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "ScreenSpaceReflectionPostProcess";
      }, Object.defineProperty(t.prototype, "enableSmoothReflections", { get: function() {
        return this._enableSmoothReflections;
      }, set: function(e) {
        e !== this._enableSmoothReflections && (this._enableSmoothReflections = e, this._updateEffectDefines());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "reflectionSamples", { get: function() {
        return this._reflectionSamples;
      }, set: function(e) {
        e !== this._reflectionSamples && (this._reflectionSamples = e, this._updateEffectDefines());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "smoothSteps", { get: function() {
        return this._smoothSteps;
      }, set: function(e) {
        e !== this._smoothSteps && (this._smoothSteps = e, this._updateEffectDefines());
      }, enumerable: !1, configurable: !0 }), t.prototype._updateEffectDefines = function() {
        var e = [];
        (this._geometryBufferRenderer || this._prePassRenderer) && e.push("#define SSR_SUPPORTED"), this._enableSmoothReflections && e.push("#define ENABLE_SMOOTH_REFLECTIONS"), this._isSceneRightHanded && e.push("#define RIGHT_HANDED_SCENE"), e.push("#define REFLECTION_SAMPLES " + (this._reflectionSamples >> 0)), e.push("#define SMOOTH_STEPS " + (this._smoothSteps >> 0)), this.updateEffect(e.join(`
`));
      }, t._Parse = function(e, i, r, o) {
        return Ne.Parse(function() {
          return new t(e.name, r, e.options, i, e.renderTargetSamplingMode, r.getEngine(), e.textureType, e.reusable);
        }, e, r, o);
      }, x([N()], t.prototype, "threshold", void 0), x([N()], t.prototype, "strength", void 0), x([N()], t.prototype, "reflectionSpecularFalloffExponent", void 0), x([N()], t.prototype, "step", void 0), x([N()], t.prototype, "roughnessFactor", void 0), x([N()], t.prototype, "enableSmoothReflections", null), x([N()], t.prototype, "reflectionSamples", null), x([N()], t.prototype, "smoothSteps", null), t;
    }(nt);
    j("BABYLON.ScreenSpaceReflectionPostProcess", pm), re.ShadersStore.standardPixelShader = `uniform sampler2D textureSampler;varying vec2 vUV;
#define CUSTOM_FRAGMENT_DEFINITIONS
#if defined(PASS_POST_PROCESS)
void main(void)
{vec4 color=texture2D(textureSampler,vUV);gl_FragColor=color;}
#endif
#if defined(DOWN_SAMPLE_X4)
uniform vec2 dsOffsets[16];void main(void)
{vec4 average=vec4(0.0,0.0,0.0,0.0);average=texture2D(textureSampler,vUV+dsOffsets[0]);average+=texture2D(textureSampler,vUV+dsOffsets[1]);average+=texture2D(textureSampler,vUV+dsOffsets[2]);average+=texture2D(textureSampler,vUV+dsOffsets[3]);average+=texture2D(textureSampler,vUV+dsOffsets[4]);average+=texture2D(textureSampler,vUV+dsOffsets[5]);average+=texture2D(textureSampler,vUV+dsOffsets[6]);average+=texture2D(textureSampler,vUV+dsOffsets[7]);average+=texture2D(textureSampler,vUV+dsOffsets[8]);average+=texture2D(textureSampler,vUV+dsOffsets[9]);average+=texture2D(textureSampler,vUV+dsOffsets[10]);average+=texture2D(textureSampler,vUV+dsOffsets[11]);average+=texture2D(textureSampler,vUV+dsOffsets[12]);average+=texture2D(textureSampler,vUV+dsOffsets[13]);average+=texture2D(textureSampler,vUV+dsOffsets[14]);average+=texture2D(textureSampler,vUV+dsOffsets[15]);average/=16.0;gl_FragColor=average;}
#endif
#if defined(BRIGHT_PASS)
uniform vec2 dsOffsets[4];uniform float brightThreshold;void main(void)
{vec4 average=vec4(0.0,0.0,0.0,0.0);average=texture2D(textureSampler,vUV+vec2(dsOffsets[0].x,dsOffsets[0].y));average+=texture2D(textureSampler,vUV+vec2(dsOffsets[1].x,dsOffsets[1].y));average+=texture2D(textureSampler,vUV+vec2(dsOffsets[2].x,dsOffsets[2].y));average+=texture2D(textureSampler,vUV+vec2(dsOffsets[3].x,dsOffsets[3].y));average*=0.25;float luminance=length(average.rgb);if (luminance<brightThreshold) {average=vec4(0.0,0.0,0.0,1.0);}
gl_FragColor=average;}
#endif
#if defined(TEXTURE_ADDER)
uniform sampler2D otherSampler;uniform sampler2D lensSampler;uniform float exposure;void main(void)
{vec3 colour=texture2D(textureSampler,vUV).rgb;colour*=exposure;vec3 X=max(vec3(0.0,0.0,0.0),colour-0.004);vec3 retColor=(X*(6.2*X+0.5))/(X*(6.2*X+1.7)+0.06);colour=retColor*retColor;colour+=colour*texture2D(lensSampler,vUV).rgb;vec4 finalColor=vec4(colour.rgb,1.0)+texture2D(otherSampler,vUV);gl_FragColor=finalColor;}
#endif
#if defined(VLS)
#define PI 3.1415926535897932384626433832795
uniform mat4 shadowViewProjection;uniform mat4 lightWorld;uniform vec3 cameraPosition;uniform vec3 sunDirection;uniform vec3 sunColor;uniform vec2 depthValues;uniform float scatteringCoefficient;uniform float scatteringPower;uniform sampler2D shadowMapSampler;uniform sampler2D positionSampler;float computeScattering(float lightDotView)
{float result=1.0-scatteringCoefficient*scatteringCoefficient;result/=(4.0*PI*pow(1.0+scatteringCoefficient*scatteringCoefficient-(2.0*scatteringCoefficient)*lightDotView,1.5));return result;}
void main(void)
{vec3 worldPos=texture2D(positionSampler,vUV).rgb;vec3 startPosition=cameraPosition;vec3 rayVector=worldPos-startPosition;float rayLength=length(rayVector);vec3 rayDirection=rayVector/rayLength;float stepLength=rayLength/NB_STEPS;vec3 stepL=rayDirection*stepLength;vec3 currentPosition=startPosition;vec3 accumFog=vec3(0.0);for (int i=0; i<int(NB_STEPS); i++)
{vec4 worldInShadowCameraSpace=shadowViewProjection*vec4(currentPosition,1.0);float depthMetric= (worldInShadowCameraSpace.z+depthValues.x)/(depthValues.y);float shadowPixelDepth=clamp(depthMetric,0.0,1.0);worldInShadowCameraSpace.xyz/=worldInShadowCameraSpace.w;worldInShadowCameraSpace.xyz=0.5*worldInShadowCameraSpace.xyz+vec3(0.5);float shadowMapValue=texture2D(shadowMapSampler,worldInShadowCameraSpace.xy).r;if (shadowMapValue>shadowPixelDepth)
accumFog+=sunColor*computeScattering(dot(rayDirection,sunDirection));currentPosition+=stepL;}
accumFog/=NB_STEPS;vec3 color=accumFog*scatteringPower;gl_FragColor=vec4(color*exp(color) ,1.0);}
#endif
#if defined(VLSMERGE)
uniform sampler2D originalSampler;void main(void)
{gl_FragColor=texture2D(originalSampler,vUV)+texture2D(textureSampler,vUV);}
#endif
#if defined(LUMINANCE)
uniform vec2 lumOffsets[4];void main()
{float average=0.0;vec4 color=vec4(0.0);float maximum=-1e20;vec3 weight=vec3(0.299,0.587,0.114);for (int i=0; i<4; i++)
{color=texture2D(textureSampler,vUV+ lumOffsets[i]);float GreyValue=dot(color.rgb,vec3(0.33,0.33,0.33));
#ifdef WEIGHTED_AVERAGE
float GreyValue=dot(color.rgb,weight);
#endif
#ifdef BRIGHTNESS
float GreyValue=max(color.r,max(color.g,color.b));
#endif
#ifdef HSL_COMPONENT
float GreyValue=0.5*(max(color.r,max(color.g,color.b))+min(color.r,min(color.g,color.b)));
#endif
#ifdef MAGNITUDE
float GreyValue=length(color.rgb);
#endif
maximum=max(maximum,GreyValue);average+=(0.25*log(1e-5+GreyValue));}
average=exp(average);gl_FragColor=vec4(average,maximum,0.0,1.0);}
#endif
#if defined(LUMINANCE_DOWN_SAMPLE)
uniform vec2 dsOffsets[9];uniform float halfDestPixelSize;
#ifdef FINAL_DOWN_SAMPLER
#include<packingFunctions>
#endif
void main()
{vec4 color=vec4(0.0);float average=0.0;for (int i=0; i<9; i++)
{color=texture2D(textureSampler,vUV+vec2(halfDestPixelSize,halfDestPixelSize)+dsOffsets[i]);average+=color.r;}
average/=9.0;
#ifdef FINAL_DOWN_SAMPLER
gl_FragColor=pack(average);
#else
gl_FragColor=vec4(average,average,0.0,1.0);
#endif
}
#endif
#if defined(HDR)
uniform sampler2D textureAdderSampler;uniform float averageLuminance;void main()
{vec4 color=texture2D(textureAdderSampler,vUV);
#ifndef AUTO_EXPOSURE
vec4 adjustedColor=color/averageLuminance;color=adjustedColor;color.a=1.0;
#endif
gl_FragColor=color;}
#endif
#if defined(LENS_FLARE)
#define GHOSTS 3
uniform sampler2D lensColorSampler;uniform float strength;uniform float ghostDispersal;uniform float haloWidth;uniform vec2 resolution;uniform float distortionStrength;float hash(vec2 p)
{float h=dot(p,vec2(127.1,311.7));return -1.0+2.0*fract(sin(h)*43758.5453123);}
float noise(in vec2 p)
{vec2 i=floor(p);vec2 f=fract(p);vec2 u=f*f*(3.0-2.0*f);return mix(mix(hash(i+vec2(0.0,0.0)),
hash(i+vec2(1.0,0.0)),u.x),
mix(hash(i+vec2(0.0,1.0)),
hash(i+vec2(1.0,1.0)),u.x),u.y);}
float fbm(vec2 p)
{float f=0.0;f+=0.5000*noise(p); p*=2.02;f+=0.2500*noise(p); p*=2.03;f+=0.1250*noise(p); p*=2.01;f+=0.0625*noise(p); p*=2.04;f/=0.9375;return f;}
vec3 pattern(vec2 uv)
{vec2 p=-1.0+2.0*uv;float p2=dot(p,p);float f=fbm(vec2(15.0*p2))/2.0;float r=0.2+0.6*sin(12.5*length(uv-vec2(0.5)));float g=0.2+0.6*sin(20.5*length(uv-vec2(0.5)));float b=0.2+0.6*sin(17.2*length(uv-vec2(0.5)));return (1.0-f)*vec3(r,g,b);}
float luminance(vec3 color)
{return dot(color.rgb,vec3(0.2126,0.7152,0.0722));}
vec4 textureDistorted(sampler2D tex,vec2 texcoord,vec2 direction,vec3 distortion)
{return vec4(
texture2D(tex,texcoord+direction*distortion.r).r,
texture2D(tex,texcoord+direction*distortion.g).g,
texture2D(tex,texcoord+direction*distortion.b).b,
1.0
);}
void main(void)
{vec2 uv=-vUV+vec2(1.0);vec2 ghostDir=(vec2(0.5)-uv)*ghostDispersal;vec2 texelSize=1.0/resolution;vec3 distortion=vec3(-texelSize.x*distortionStrength,0.0,texelSize.x*distortionStrength);vec4 result=vec4(0.0);float ghostIndice=1.0;for (int i=0; i<GHOSTS; ++i)
{vec2 offset=fract(uv+ghostDir*ghostIndice);float weight=length(vec2(0.5)-offset)/length(vec2(0.5));weight=pow(1.0-weight,10.0);result+=textureDistorted(textureSampler,offset,normalize(ghostDir),distortion)*weight*strength;ghostIndice+=1.0;}
vec2 haloVec=normalize(ghostDir)*haloWidth;float weight=length(vec2(0.5)-fract(uv+haloVec))/length(vec2(0.5));weight=pow(1.0-weight,10.0);result+=textureDistorted(textureSampler,fract(uv+haloVec),normalize(ghostDir),distortion)*weight*strength;result*=texture2D(lensColorSampler,vec2(length(vec2(0.5)-uv)/length(vec2(0.5))));gl_FragColor=result;}
#endif
#if defined(LENS_FLARE_COMPOSE)
uniform sampler2D otherSampler;uniform sampler2D lensDirtSampler;uniform sampler2D lensStarSampler;uniform mat4 lensStarMatrix;void main(void)
{vec2 lensFlareCoords=(lensStarMatrix*vec4(vUV,1.0,1.0)).xy;vec4 lensMod=texture2D(lensDirtSampler,vUV);lensMod+=texture2D(lensStarSampler,vUV/*lensFlareCoords*/);vec4 result=texture2D(textureSampler,vUV)*lensMod;gl_FragColor=texture2D(otherSampler,vUV)+result;}
#endif
#if defined(DEPTH_OF_FIELD)
uniform sampler2D otherSampler;uniform sampler2D depthSampler;uniform float distance;void main(void)
{vec4 sharp=texture2D(otherSampler,vUV);vec4 blur=texture2D(textureSampler,vUV);float dist=clamp(texture2D(depthSampler,vUV).r*distance,0.0,1.0);float factor=0.0;if (dist<0.05)
factor=1.0;else if (dist<0.1)
factor=20.0*(0.1-dist);else if (dist<0.5)
factor=0.0;else
factor=2.0*(dist-0.5);factor=clamp(factor,0.0,0.90);gl_FragColor=mix(sharp,blur,factor);}
#endif
#if defined(MOTION_BLUR)
uniform mat4 inverseViewProjection;uniform mat4 prevViewProjection;uniform vec2 screenSize;uniform float motionScale;uniform float motionStrength;uniform sampler2D depthSampler;void main(void)
{vec2 texelSize=1.0/screenSize;float depth=texture2D(depthSampler,vUV).r;vec4 cpos=vec4(vUV*2.0-1.0,depth,1.0);cpos=cpos*inverseViewProjection;vec4 ppos=cpos*prevViewProjection;ppos.xyz/=ppos.w;ppos.xy=ppos.xy*0.5+0.5;vec2 velocity=(ppos.xy-vUV)*motionScale*motionStrength;float speed=length(velocity/texelSize);int nSamples=int(clamp(speed,1.0,MAX_MOTION_SAMPLES));vec4 result=texture2D(textureSampler,vUV);for (int i=1; i<int(MAX_MOTION_SAMPLES); ++i) {if (i>=nSamples)
break;vec2 offset1=vUV+velocity*(float(i)/float(nSamples-1)-0.5);result+=texture2D(textureSampler,offset1);}
gl_FragColor=result/float(nSamples);}
#endif
`;
    var hE = function(n) {
      function t(e, i, r, o, a) {
        o === void 0 && (o = null);
        var s = n.call(this, i.getEngine(), e) || this;
        return s.downSampleX4PostProcess = null, s.brightPassPostProcess = null, s.blurHPostProcesses = [], s.blurVPostProcesses = [], s.textureAdderPostProcess = null, s.volumetricLightPostProcess = null, s.volumetricLightSmoothXPostProcess = null, s.volumetricLightSmoothYPostProcess = null, s.volumetricLightMergePostProces = null, s.volumetricLightFinalPostProcess = null, s.luminancePostProcess = null, s.luminanceDownSamplePostProcesses = [], s.hdrPostProcess = null, s.textureAdderFinalPostProcess = null, s.lensFlareFinalPostProcess = null, s.hdrFinalPostProcess = null, s.lensFlarePostProcess = null, s.lensFlareComposePostProcess = null, s.motionBlurPostProcess = null, s.depthOfFieldPostProcess = null, s.fxaaPostProcess = null, s.screenSpaceReflectionPostProcess = null, s.brightThreshold = 1, s.blurWidth = 512, s.horizontalBlur = !1, s.lensTexture = null, s.volumetricLightCoefficient = 0.2, s.volumetricLightPower = 4, s.volumetricLightBlurScale = 64, s.sourceLight = null, s.hdrMinimumLuminance = 1, s.hdrDecreaseRate = 0.5, s.hdrIncreaseRate = 0.5, s.lensColorTexture = null, s.lensFlareStrength = 20, s.lensFlareGhostDispersal = 1.4, s.lensFlareHaloWidth = 0.7, s.lensFlareDistortionStrength = 16, s.lensFlareBlurWidth = 512, s.lensStarTexture = null, s.lensFlareDirtTexture = null, s.depthOfFieldDistance = 10, s.depthOfFieldBlurWidth = 64, s.animations = [], s._currentDepthOfFieldSource = null, s._fixedExposure = 1, s._currentExposure = 1, s._hdrAutoExposure = !1, s._hdrCurrentLuminance = 1, s._motionStrength = 1, s._isObjectBasedMotionBlur = !1, s._camerasToBeAttached = [], s._bloomEnabled = !1, s._depthOfFieldEnabled = !1, s._vlsEnabled = !1, s._lensFlareEnabled = !1, s._hdrEnabled = !1, s._motionBlurEnabled = !1, s._fxaaEnabled = !1, s._screenSpaceReflectionsEnabled = !1, s._motionBlurSamples = 64, s._volumetricLightStepsCount = 50, s._samples = 1, s._cameras = a || i.cameras, s._cameras = s._cameras.slice(), s._camerasToBeAttached = s._cameras.slice(), s._scene = i, s._basePostProcess = o, s._ratio = r, s._floatTextureType = i.getEngine().getCaps().textureFloatRender ? _.TEXTURETYPE_FLOAT : _.TEXTURETYPE_HALF_FLOAT, i.postProcessRenderPipelineManager.addPipeline(s), s._buildPipeline(), s;
      }
      return D(t, n), Object.defineProperty(t.prototype, "exposure", { get: function() {
        return this._fixedExposure;
      }, set: function(e) {
        this._fixedExposure = e, this._currentExposure = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hdrAutoExposure", { get: function() {
        return this._hdrAutoExposure;
      }, set: function(e) {
        if (this._hdrAutoExposure = e, this.hdrPostProcess) {
          var i = ["#define HDR"];
          e && i.push("#define AUTO_EXPOSURE"), this.hdrPostProcess.updateEffect(i.join(`
`));
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "motionStrength", { get: function() {
        return this._motionStrength;
      }, set: function(e) {
        this._motionStrength = e, this._isObjectBasedMotionBlur && this.motionBlurPostProcess && (this.motionBlurPostProcess.motionStrength = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "objectBasedMotionBlur", { get: function() {
        return this._isObjectBasedMotionBlur;
      }, set: function(e) {
        var i = this._isObjectBasedMotionBlur !== e;
        this._isObjectBasedMotionBlur = e, i && this._buildPipeline();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "BloomEnabled", { get: function() {
        return this._bloomEnabled;
      }, set: function(e) {
        this._bloomEnabled !== e && (this._bloomEnabled = e, this._buildPipeline());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "DepthOfFieldEnabled", { get: function() {
        return this._depthOfFieldEnabled;
      }, set: function(e) {
        this._depthOfFieldEnabled !== e && (this._depthOfFieldEnabled = e, this._buildPipeline());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "LensFlareEnabled", { get: function() {
        return this._lensFlareEnabled;
      }, set: function(e) {
        this._lensFlareEnabled !== e && (this._lensFlareEnabled = e, this._buildPipeline());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "HDREnabled", { get: function() {
        return this._hdrEnabled;
      }, set: function(e) {
        this._hdrEnabled !== e && (this._hdrEnabled = e, this._buildPipeline());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "VLSEnabled", { get: function() {
        return this._vlsEnabled;
      }, set: function(e) {
        if (this._vlsEnabled !== e) {
          if (e && !this._scene.enableGeometryBufferRenderer())
            return void q.Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");
          this._vlsEnabled = e, this._buildPipeline();
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "MotionBlurEnabled", { get: function() {
        return this._motionBlurEnabled;
      }, set: function(e) {
        this._motionBlurEnabled !== e && (this._motionBlurEnabled = e, this._buildPipeline());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "fxaaEnabled", { get: function() {
        return this._fxaaEnabled;
      }, set: function(e) {
        this._fxaaEnabled !== e && (this._fxaaEnabled = e, this._buildPipeline());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "screenSpaceReflectionsEnabled", { get: function() {
        return this._screenSpaceReflectionsEnabled;
      }, set: function(e) {
        this._screenSpaceReflectionsEnabled !== e && (this._screenSpaceReflectionsEnabled = e, this._buildPipeline());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "volumetricLightStepsCount", { get: function() {
        return this._volumetricLightStepsCount;
      }, set: function(e) {
        this.volumetricLightPostProcess && this.volumetricLightPostProcess.updateEffect(`#define VLS
#define NB_STEPS ` + e.toFixed(1)), this._volumetricLightStepsCount = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "motionBlurSamples", { get: function() {
        return this._motionBlurSamples;
      }, set: function(e) {
        this.motionBlurPostProcess && (this._isObjectBasedMotionBlur ? this.motionBlurPostProcess.motionBlurSamples = e : this.motionBlurPostProcess.updateEffect(`#define MOTION_BLUR
#define MAX_MOTION_SAMPLES ` + e.toFixed(1))), this._motionBlurSamples = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "samples", { get: function() {
        return this._samples;
      }, set: function(e) {
        this._samples !== e && (this._samples = e, this._buildPipeline());
      }, enumerable: !1, configurable: !0 }), t.prototype._buildPipeline = function() {
        var e = this, i = this._ratio, r = this._scene;
        this._disposePostProcesses(), this._cameras !== null && (this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras), this._cameras = this._camerasToBeAttached.slice()), this._reset(), this._screenSpaceReflectionsEnabled && (this.screenSpaceReflectionPostProcess = new pm("HDRPass", r, i, null, ae.BILINEAR_SAMPLINGMODE, r.getEngine(), !1, this._floatTextureType), this.screenSpaceReflectionPostProcess.onApplyObservable.add(function() {
          e._currentDepthOfFieldSource = e.screenSpaceReflectionPostProcess;
        }), this.addEffect(new Vt(r.getEngine(), "HDRScreenSpaceReflections", function() {
          return e.screenSpaceReflectionPostProcess;
        }, !0))), this._basePostProcess ? this.originalPostProcess = this._basePostProcess : this.originalPostProcess = new nt("HDRPass", "standard", [], [], i, null, ae.BILINEAR_SAMPLINGMODE, r.getEngine(), !1, "#define PASS_POST_PROCESS", this._floatTextureType), this.originalPostProcess.autoClear = !this.screenSpaceReflectionPostProcess, this.originalPostProcess.onApplyObservable.add(function() {
          e._currentDepthOfFieldSource = e.originalPostProcess;
        }), this.addEffect(new Vt(r.getEngine(), "HDRPassPostProcess", function() {
          return e.originalPostProcess;
        }, !0)), this._bloomEnabled && (this._createDownSampleX4PostProcess(r, i / 4), this._createBrightPassPostProcess(r, i / 4), this._createBlurPostProcesses(r, i / 4, 1), this._createTextureAdderPostProcess(r, i), this.textureAdderFinalPostProcess = new nt("HDRDepthOfFieldSource", "standard", [], [], i, null, ae.BILINEAR_SAMPLINGMODE, r.getEngine(), !1, "#define PASS_POST_PROCESS", _.TEXTURETYPE_UNSIGNED_INT), this.addEffect(new Vt(r.getEngine(), "HDRBaseDepthOfFieldSource", function() {
          return e.textureAdderFinalPostProcess;
        }, !0))), this._vlsEnabled && (this._createVolumetricLightPostProcess(r, i), this.volumetricLightFinalPostProcess = new nt("HDRVLSFinal", "standard", [], [], i, null, ae.BILINEAR_SAMPLINGMODE, r.getEngine(), !1, "#define PASS_POST_PROCESS", _.TEXTURETYPE_UNSIGNED_INT), this.addEffect(new Vt(r.getEngine(), "HDRVLSFinal", function() {
          return e.volumetricLightFinalPostProcess;
        }, !0))), this._lensFlareEnabled && (this._createLensFlarePostProcess(r, i), this.lensFlareFinalPostProcess = new nt("HDRPostLensFlareDepthOfFieldSource", "standard", [], [], i, null, ae.BILINEAR_SAMPLINGMODE, r.getEngine(), !1, "#define PASS_POST_PROCESS", _.TEXTURETYPE_UNSIGNED_INT), this.addEffect(new Vt(r.getEngine(), "HDRPostLensFlareDepthOfFieldSource", function() {
          return e.lensFlareFinalPostProcess;
        }, !0))), this._hdrEnabled && (this._createLuminancePostProcesses(r, this._floatTextureType), this._createHdrPostProcess(r, i), this.hdrFinalPostProcess = new nt("HDRPostHDReDepthOfFieldSource", "standard", [], [], i, null, ae.BILINEAR_SAMPLINGMODE, r.getEngine(), !1, "#define PASS_POST_PROCESS", _.TEXTURETYPE_UNSIGNED_INT), this.addEffect(new Vt(r.getEngine(), "HDRPostHDReDepthOfFieldSource", function() {
          return e.hdrFinalPostProcess;
        }, !0))), this._depthOfFieldEnabled && (this._createBlurPostProcesses(r, i / 2, 3, "depthOfFieldBlurWidth"), this._createDepthOfFieldPostProcess(r, i)), this._motionBlurEnabled && this._createMotionBlurPostProcess(r, i), this._fxaaEnabled && (this.fxaaPostProcess = new hu("fxaa", 1, null, ae.BILINEAR_SAMPLINGMODE, r.getEngine(), !1, _.TEXTURETYPE_UNSIGNED_INT), this.addEffect(new Vt(r.getEngine(), "HDRFxaa", function() {
          return e.fxaaPostProcess;
        }, !0))), this._cameras !== null && this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras), !this._enableMSAAOnFirstPostProcess(this._samples) && this._samples > 1 && q.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
      }, t.prototype._createDownSampleX4PostProcess = function(e, i) {
        var r = this, o = new Array(32);
        this.downSampleX4PostProcess = new nt("HDRDownSampleX4", "standard", ["dsOffsets"], [], i, null, ae.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, "#define DOWN_SAMPLE_X4", this._floatTextureType), this.downSampleX4PostProcess.onApply = function(a) {
          for (var s = 0, l = r.downSampleX4PostProcess.width, c = r.downSampleX4PostProcess.height, u = -2; u < 2; u++)
            for (var h = -2; h < 2; h++)
              o[s] = (u + 0.5) * (1 / l), o[s + 1] = (h + 0.5) * (1 / c), s += 2;
          a.setArray2("dsOffsets", o);
        }, this.addEffect(new Vt(e.getEngine(), "HDRDownSampleX4", function() {
          return r.downSampleX4PostProcess;
        }, !0));
      }, t.prototype._createBrightPassPostProcess = function(e, i) {
        var r = this, o = new Array(8);
        this.brightPassPostProcess = new nt("HDRBrightPass", "standard", ["dsOffsets", "brightThreshold"], [], i, null, ae.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, "#define BRIGHT_PASS", this._floatTextureType), this.brightPassPostProcess.onApply = function(a) {
          var s = 1 / r.brightPassPostProcess.width, l = 1 / r.brightPassPostProcess.height;
          o[0] = -0.5 * s, o[1] = 0.5 * l, o[2] = 0.5 * s, o[3] = 0.5 * l, o[4] = -0.5 * s, o[5] = -0.5 * l, o[6] = 0.5 * s, o[7] = -0.5 * l, a.setArray2("dsOffsets", o), a.setFloat("brightThreshold", r.brightThreshold);
        }, this.addEffect(new Vt(e.getEngine(), "HDRBrightPass", function() {
          return r.brightPassPostProcess;
        }, !0));
      }, t.prototype._createBlurPostProcesses = function(e, i, r, o) {
        var a = this;
        o === void 0 && (o = "blurWidth");
        var s = e.getEngine(), l = new Cn("HDRBlurH_" + r, new fe(1, 0), this[o], i, null, ae.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, this._floatTextureType), c = new Cn("HDRBlurV_" + r, new fe(0, 1), this[o], i, null, ae.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, this._floatTextureType);
        l.onActivateObservable.add(function() {
          var u = l.width / s.getRenderWidth();
          l.kernel = a[o] * u;
        }), c.onActivateObservable.add(function() {
          var u = c.height / s.getRenderHeight();
          c.kernel = a.horizontalBlur ? 64 * u : a[o] * u;
        }), this.addEffect(new Vt(e.getEngine(), "HDRBlurH" + r, function() {
          return l;
        }, !0)), this.addEffect(new Vt(e.getEngine(), "HDRBlurV" + r, function() {
          return c;
        }, !0)), this.blurHPostProcesses.push(l), this.blurVPostProcesses.push(c);
      }, t.prototype._createTextureAdderPostProcess = function(e, i) {
        var r = this;
        this.textureAdderPostProcess = new nt("HDRTextureAdder", "standard", ["exposure"], ["otherSampler", "lensSampler"], i, null, ae.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, "#define TEXTURE_ADDER", this._floatTextureType), this.textureAdderPostProcess.onApply = function(o) {
          o.setTextureFromPostProcess("otherSampler", r._vlsEnabled ? r._currentDepthOfFieldSource : r.originalPostProcess), o.setTexture("lensSampler", r.lensTexture), o.setFloat("exposure", r._currentExposure), r._currentDepthOfFieldSource = r.textureAdderFinalPostProcess;
        }, this.addEffect(new Vt(e.getEngine(), "HDRTextureAdder", function() {
          return r.textureAdderPostProcess;
        }, !0));
      }, t.prototype._createVolumetricLightPostProcess = function(e, i) {
        var r = this, o = e.enableGeometryBufferRenderer();
        o.enablePosition = !0;
        var a = o.getGBuffer();
        this.volumetricLightPostProcess = new nt("HDRVLS", "standard", ["shadowViewProjection", "cameraPosition", "sunDirection", "sunColor", "scatteringCoefficient", "scatteringPower", "depthValues"], ["shadowMapSampler", "positionSampler"], i / 8, null, ae.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, `#define VLS
#define NB_STEPS ` + this._volumetricLightStepsCount.toFixed(1));
        var s = fe.Zero();
        this.volumetricLightPostProcess.onApply = function(l) {
          if (r.sourceLight && r.sourceLight.getShadowGenerator() && r._scene.activeCamera) {
            var c = r.sourceLight.getShadowGenerator();
            l.setTexture("shadowMapSampler", c.getShadowMap()), l.setTexture("positionSampler", a.textures[2]), l.setColor3("sunColor", r.sourceLight.diffuse), l.setVector3("sunDirection", r.sourceLight.getShadowDirection()), l.setVector3("cameraPosition", r._scene.activeCamera.globalPosition), l.setMatrix("shadowViewProjection", c.getTransformMatrix()), l.setFloat("scatteringCoefficient", r.volumetricLightCoefficient), l.setFloat("scatteringPower", r.volumetricLightPower), s.x = r.sourceLight.getDepthMinZ(r._scene.activeCamera), s.y = r.sourceLight.getDepthMaxZ(r._scene.activeCamera), l.setVector2("depthValues", s);
          }
        }, this.addEffect(new Vt(e.getEngine(), "HDRVLS", function() {
          return r.volumetricLightPostProcess;
        }, !0)), this._createBlurPostProcesses(e, i / 4, 0, "volumetricLightBlurScale"), this.volumetricLightMergePostProces = new nt("HDRVLSMerge", "standard", [], ["originalSampler"], i, null, ae.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, "#define VLSMERGE"), this.volumetricLightMergePostProces.onApply = function(l) {
          l.setTextureFromPostProcess("originalSampler", r._bloomEnabled ? r.textureAdderFinalPostProcess : r.originalPostProcess), r._currentDepthOfFieldSource = r.volumetricLightFinalPostProcess;
        }, this.addEffect(new Vt(e.getEngine(), "HDRVLSMerge", function() {
          return r.volumetricLightMergePostProces;
        }, !0));
      }, t.prototype._createLuminancePostProcesses = function(e, i) {
        var r = this, o = Math.pow(3, t.LuminanceSteps);
        this.luminancePostProcess = new nt("HDRLuminance", "standard", ["lumOffsets"], [], { width: o, height: o }, null, ae.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, "#define LUMINANCE", i);
        var a = [];
        this.luminancePostProcess.onApply = function(h) {
          var d = 1 / r.luminancePostProcess.width, p = 1 / r.luminancePostProcess.height;
          a[0] = -0.5 * d, a[1] = 0.5 * p, a[2] = 0.5 * d, a[3] = 0.5 * p, a[4] = -0.5 * d, a[5] = -0.5 * p, a[6] = 0.5 * d, a[7] = -0.5 * p, h.setArray2("lumOffsets", a);
        }, this.addEffect(new Vt(e.getEngine(), "HDRLuminance", function() {
          return r.luminancePostProcess;
        }, !0));
        for (var s = t.LuminanceSteps - 1; s >= 0; s--) {
          o = Math.pow(3, s);
          var l = `#define LUMINANCE_DOWN_SAMPLE
`;
          s === 0 && (l += "#define FINAL_DOWN_SAMPLER");
          var c = new nt("HDRLuminanceDownSample" + s, "standard", ["dsOffsets", "halfDestPixelSize"], [], { width: o, height: o }, null, ae.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, l, i);
          this.luminanceDownSamplePostProcesses.push(c);
        }
        var u = this.luminancePostProcess;
        this.luminanceDownSamplePostProcesses.forEach(function(h, d) {
          var p = new Array(18);
          h.onApply = function(f) {
            if (u) {
              for (var m = 0, g = -1; g < 2; g++)
                for (var y = -1; y < 2; y++)
                  p[m] = g / u.width, p[m + 1] = y / u.height, m += 2;
              f.setArray2("dsOffsets", p), f.setFloat("halfDestPixelSize", 0.5 / u.width), u = d === r.luminanceDownSamplePostProcesses.length - 1 ? r.luminancePostProcess : h;
            }
          }, d === r.luminanceDownSamplePostProcesses.length - 1 && (h.onAfterRender = function() {
            var f = e.getEngine().readPixels(0, 0, 1, 1), m = new lt(1 / 16581375, 1 / 65025, 1 / 255, 1);
            f.then(function(g) {
              var y = new Uint8Array(g.buffer);
              r._hdrCurrentLuminance = (y[0] * m.x + y[1] * m.y + y[2] * m.z + y[3] * m.w) / 100;
            });
          }), r.addEffect(new Vt(e.getEngine(), "HDRLuminanceDownSample" + d, function() {
            return h;
          }, !0));
        });
      }, t.prototype._createHdrPostProcess = function(e, i) {
        var r = this, o = ["#define HDR"];
        this._hdrAutoExposure && o.push("#define AUTO_EXPOSURE"), this.hdrPostProcess = new nt("HDR", "standard", ["averageLuminance"], ["textureAdderSampler"], i, null, ae.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, o.join(`
`), _.TEXTURETYPE_UNSIGNED_INT);
        var a = 1, s = 0, l = 0;
        this.hdrPostProcess.onApply = function(c) {
          if (c.setTextureFromPostProcess("textureAdderSampler", r._currentDepthOfFieldSource), s += e.getEngine().getDeltaTime(), a < 0)
            a = r._hdrCurrentLuminance;
          else {
            var u = (l - s) / 1e3;
            r._hdrCurrentLuminance < a + r.hdrDecreaseRate * u ? a += r.hdrDecreaseRate * u : r._hdrCurrentLuminance > a - r.hdrIncreaseRate * u ? a -= r.hdrIncreaseRate * u : a = r._hdrCurrentLuminance;
          }
          r.hdrAutoExposure ? r._currentExposure = r._fixedExposure / a : (a = ue.Clamp(a, r.hdrMinimumLuminance, 1e20), c.setFloat("averageLuminance", a)), l = s, r._currentDepthOfFieldSource = r.hdrFinalPostProcess;
        }, this.addEffect(new Vt(e.getEngine(), "HDR", function() {
          return r.hdrPostProcess;
        }, !0));
      }, t.prototype._createLensFlarePostProcess = function(e, i) {
        var r = this;
        this.lensFlarePostProcess = new nt("HDRLensFlare", "standard", ["strength", "ghostDispersal", "haloWidth", "resolution", "distortionStrength"], ["lensColorSampler"], i / 2, null, ae.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, "#define LENS_FLARE", _.TEXTURETYPE_UNSIGNED_INT), this.addEffect(new Vt(e.getEngine(), "HDRLensFlare", function() {
          return r.lensFlarePostProcess;
        }, !0)), this._createBlurPostProcesses(e, i / 4, 2, "lensFlareBlurWidth"), this.lensFlareComposePostProcess = new nt("HDRLensFlareCompose", "standard", ["lensStarMatrix"], ["otherSampler", "lensDirtSampler", "lensStarSampler"], i, null, ae.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, "#define LENS_FLARE_COMPOSE", _.TEXTURETYPE_UNSIGNED_INT), this.addEffect(new Vt(e.getEngine(), "HDRLensFlareCompose", function() {
          return r.lensFlareComposePostProcess;
        }, !0));
        var o = new fe(0, 0);
        this.lensFlarePostProcess.externalTextureSamplerBinding = !0, this.lensFlarePostProcess.onApply = function(l) {
          l.setTextureFromPostProcess("textureSampler", r._bloomEnabled ? r.blurHPostProcesses[0] : r.originalPostProcess), l.setTexture("lensColorSampler", r.lensColorTexture), l.setFloat("strength", r.lensFlareStrength), l.setFloat("ghostDispersal", r.lensFlareGhostDispersal), l.setFloat("haloWidth", r.lensFlareHaloWidth), o.x = r.lensFlarePostProcess.width, o.y = r.lensFlarePostProcess.height, l.setVector2("resolution", o), l.setFloat("distortionStrength", r.lensFlareDistortionStrength);
        };
        var a = B.FromValues(2, 0, -1, 0, 0, 2, -1, 0, 0, 0, 1, 0, 0, 0, 0, 1), s = B.FromValues(0.5, 0, 0.5, 0, 0, 0.5, 0.5, 0, 0, 0, 1, 0, 0, 0, 0, 1);
        this.lensFlareComposePostProcess.onApply = function(l) {
          if (r._scene.activeCamera) {
            l.setTextureFromPostProcess("otherSampler", r.lensFlarePostProcess), l.setTexture("lensDirtSampler", r.lensFlareDirtTexture), l.setTexture("lensStarSampler", r.lensStarTexture);
            var c = r._scene.activeCamera.getViewMatrix().getRow(0), u = r._scene.activeCamera.getViewMatrix().getRow(2), h = v.Dot(c.toVector3(), new v(1, 0, 0)) + v.Dot(u.toVector3(), new v(0, 0, 1));
            h *= 4;
            var d = B.FromValues(0.5 * Math.cos(h), -Math.sin(h), 0, 0, Math.sin(h), 0.5 * Math.cos(h), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), p = s.multiply(d).multiply(a);
            l.setMatrix("lensStarMatrix", p), r._currentDepthOfFieldSource = r.lensFlareFinalPostProcess;
          }
        };
      }, t.prototype._createDepthOfFieldPostProcess = function(e, i) {
        var r = this;
        this.depthOfFieldPostProcess = new nt("HDRDepthOfField", "standard", ["distance"], ["otherSampler", "depthSampler"], i, null, ae.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, "#define DEPTH_OF_FIELD", _.TEXTURETYPE_UNSIGNED_INT), this.depthOfFieldPostProcess.onApply = function(o) {
          o.setTextureFromPostProcess("otherSampler", r._currentDepthOfFieldSource), o.setTexture("depthSampler", r._getDepthTexture()), o.setFloat("distance", r.depthOfFieldDistance);
        }, this.addEffect(new Vt(e.getEngine(), "HDRDepthOfField", function() {
          return r.depthOfFieldPostProcess;
        }, !0));
      }, t.prototype._createMotionBlurPostProcess = function(e, i) {
        var r = this;
        if (this._isObjectBasedMotionBlur) {
          var o = new hm("HDRMotionBlur", e, i, null, ae.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, _.TEXTURETYPE_UNSIGNED_INT);
          o.motionStrength = this.motionStrength, o.motionBlurSamples = this.motionBlurSamples, this.motionBlurPostProcess = o;
        } else {
          this.motionBlurPostProcess = new nt("HDRMotionBlur", "standard", ["inverseViewProjection", "prevViewProjection", "screenSize", "motionScale", "motionStrength"], ["depthSampler"], i, null, ae.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, `#define MOTION_BLUR
#define MAX_MOTION_SAMPLES ` + this.motionBlurSamples.toFixed(1), _.TEXTURETYPE_UNSIGNED_INT);
          var a = 0, s = B.Identity(), l = B.Identity(), c = B.Identity(), u = fe.Zero();
          this.motionBlurPostProcess.onApply = function(h) {
            (c = e.getProjectionMatrix().multiply(e.getViewMatrix())).invertToRef(l), h.setMatrix("inverseViewProjection", l), h.setMatrix("prevViewProjection", s), s = c, u.x = r.motionBlurPostProcess.width, u.y = r.motionBlurPostProcess.height, h.setVector2("screenSize", u), a = e.getEngine().getFps() / 60, h.setFloat("motionScale", a), h.setFloat("motionStrength", r.motionStrength), h.setTexture("depthSampler", r._getDepthTexture());
          };
        }
        this.addEffect(new Vt(e.getEngine(), "HDRMotionBlur", function() {
          return r.motionBlurPostProcess;
        }, !0));
      }, t.prototype._getDepthTexture = function() {
        return this._scene.getEngine().getCaps().drawBuffersExtension ? this._scene.enableGeometryBufferRenderer().getGBuffer().textures[0] : this._scene.enableDepthRenderer().getDepthMap();
      }, t.prototype._disposePostProcesses = function() {
        for (var e = 0; e < this._cameras.length; e++) {
          var i = this._cameras[e];
          this.originalPostProcess && this.originalPostProcess.dispose(i), this.screenSpaceReflectionPostProcess && this.screenSpaceReflectionPostProcess.dispose(i), this.downSampleX4PostProcess && this.downSampleX4PostProcess.dispose(i), this.brightPassPostProcess && this.brightPassPostProcess.dispose(i), this.textureAdderPostProcess && this.textureAdderPostProcess.dispose(i), this.volumetricLightPostProcess && this.volumetricLightPostProcess.dispose(i), this.volumetricLightSmoothXPostProcess && this.volumetricLightSmoothXPostProcess.dispose(i), this.volumetricLightSmoothYPostProcess && this.volumetricLightSmoothYPostProcess.dispose(i), this.volumetricLightMergePostProces && this.volumetricLightMergePostProces.dispose(i), this.volumetricLightFinalPostProcess && this.volumetricLightFinalPostProcess.dispose(i), this.lensFlarePostProcess && this.lensFlarePostProcess.dispose(i), this.lensFlareComposePostProcess && this.lensFlareComposePostProcess.dispose(i);
          for (var r = 0; r < this.luminanceDownSamplePostProcesses.length; r++)
            this.luminanceDownSamplePostProcesses[r].dispose(i);
          for (this.luminancePostProcess && this.luminancePostProcess.dispose(i), this.hdrPostProcess && this.hdrPostProcess.dispose(i), this.hdrFinalPostProcess && this.hdrFinalPostProcess.dispose(i), this.depthOfFieldPostProcess && this.depthOfFieldPostProcess.dispose(i), this.motionBlurPostProcess && this.motionBlurPostProcess.dispose(i), this.fxaaPostProcess && this.fxaaPostProcess.dispose(i), r = 0; r < this.blurHPostProcesses.length; r++)
            this.blurHPostProcesses[r].dispose(i);
          for (r = 0; r < this.blurVPostProcesses.length; r++)
            this.blurVPostProcesses[r].dispose(i);
        }
        this.originalPostProcess = null, this.downSampleX4PostProcess = null, this.brightPassPostProcess = null, this.textureAdderPostProcess = null, this.textureAdderFinalPostProcess = null, this.volumetricLightPostProcess = null, this.volumetricLightSmoothXPostProcess = null, this.volumetricLightSmoothYPostProcess = null, this.volumetricLightMergePostProces = null, this.volumetricLightFinalPostProcess = null, this.lensFlarePostProcess = null, this.lensFlareComposePostProcess = null, this.luminancePostProcess = null, this.hdrPostProcess = null, this.hdrFinalPostProcess = null, this.depthOfFieldPostProcess = null, this.motionBlurPostProcess = null, this.fxaaPostProcess = null, this.screenSpaceReflectionPostProcess = null, this.luminanceDownSamplePostProcesses.length = 0, this.blurHPostProcesses.length = 0, this.blurVPostProcesses.length = 0;
      }, t.prototype.dispose = function() {
        this._disposePostProcesses(), this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras), n.prototype.dispose.call(this);
      }, t.prototype.serialize = function() {
        var e = Ne.Serialize(this);
        return this.sourceLight && (e.sourceLightId = this.sourceLight.id), this.screenSpaceReflectionPostProcess && (e.screenSpaceReflectionPostProcess = Ne.Serialize(this.screenSpaceReflectionPostProcess)), e.customType = "StandardRenderingPipeline", e;
      }, t.Parse = function(e, i, r) {
        var o = Ne.Parse(function() {
          return new t(e._name, i, e._ratio);
        }, e, i, r);
        return e.sourceLightId && (o.sourceLight = i.getLightById(e.sourceLightId)), e.screenSpaceReflectionPostProcess && Ne.Parse(function() {
          return o.screenSpaceReflectionPostProcess;
        }, e.screenSpaceReflectionPostProcess, i, r), o;
      }, t.LuminanceSteps = 6, x([N()], t.prototype, "brightThreshold", void 0), x([N()], t.prototype, "blurWidth", void 0), x([N()], t.prototype, "horizontalBlur", void 0), x([N()], t.prototype, "exposure", null), x([St("lensTexture")], t.prototype, "lensTexture", void 0), x([N()], t.prototype, "volumetricLightCoefficient", void 0), x([N()], t.prototype, "volumetricLightPower", void 0), x([N()], t.prototype, "volumetricLightBlurScale", void 0), x([N()], t.prototype, "hdrMinimumLuminance", void 0), x([N()], t.prototype, "hdrDecreaseRate", void 0), x([N()], t.prototype, "hdrIncreaseRate", void 0), x([N()], t.prototype, "hdrAutoExposure", null), x([St("lensColorTexture")], t.prototype, "lensColorTexture", void 0), x([N()], t.prototype, "lensFlareStrength", void 0), x([N()], t.prototype, "lensFlareGhostDispersal", void 0), x([N()], t.prototype, "lensFlareHaloWidth", void 0), x([N()], t.prototype, "lensFlareDistortionStrength", void 0), x([N()], t.prototype, "lensFlareBlurWidth", void 0), x([St("lensStarTexture")], t.prototype, "lensStarTexture", void 0), x([St("lensFlareDirtTexture")], t.prototype, "lensFlareDirtTexture", void 0), x([N()], t.prototype, "depthOfFieldDistance", void 0), x([N()], t.prototype, "depthOfFieldBlurWidth", void 0), x([N()], t.prototype, "motionStrength", null), x([N()], t.prototype, "objectBasedMotionBlur", null), x([N()], t.prototype, "_ratio", void 0), x([N()], t.prototype, "BloomEnabled", null), x([N()], t.prototype, "DepthOfFieldEnabled", null), x([N()], t.prototype, "LensFlareEnabled", null), x([N()], t.prototype, "HDREnabled", null), x([N()], t.prototype, "VLSEnabled", null), x([N()], t.prototype, "MotionBlurEnabled", null), x([N()], t.prototype, "fxaaEnabled", null), x([N()], t.prototype, "screenSpaceReflectionsEnabled", null), x([N()], t.prototype, "volumetricLightStepsCount", null), x([N()], t.prototype, "motionBlurSamples", null), x([N()], t.prototype, "samples", null), t;
    }(Ns);
    j("BABYLON.StandardRenderingPipeline", hE);
    var xN = function() {
      this.enabled = !1, this.name = "screenSpaceReflections2", this.texturesRequired = [_.PREPASS_NORMAL_TEXTURE_TYPE, _.PREPASS_REFLECTIVITY_TEXTURE_TYPE, _.PREPASS_DEPTH_TEXTURE_TYPE];
    };
    re.IncludesShadersStore.screenSpaceRayTrace = `float distanceSquared(vec2 a,vec2 b) { a-=b; return dot(a,a); }
/**
param csOrigin Camera-space ray origin,which must be 
within the view volume and must have z>0.01 and project within the valid screen rectangle
param csDirection Unit length camera-space ray direction
param projectToPixelMatrix A projection matrix that maps to **pixel** coordinates 
(**not** [-1,+1] normalized device coordinates).
param csZBuffer The camera-space Z buffer
param csZBufferSize Dimensions of csZBuffer
param csZThickness Camera space csZThickness to ascribe to each pixel in the depth buffer
param nearPlaneZ Positive number. Doesn't have to be THE actual near plane,just a reasonable value
for clipping rays headed towards the camera
param stride Step in horizontal or vertical pixels between samples. This is a float
because integer math is slow on GPUs,but should be set to an integer>=1
param jitterFraction Number between 0 and 1 for how far to bump the ray in stride units
to conceal banding artifacts,plus the stride ray offset.
param maxSteps Maximum number of iterations. Higher gives better images but may be slow
param maxRayTraceDistance Maximum camera-space distance to trace before returning a miss
param selfCollisionNumSkip Number of steps to skip at start when raytracing to avoid self collisions.
1 is a reasonable value,depending on the scene you may need to set this value to 2
param hitPixel Pixel coordinates of the first intersection with the scene
param numIterations number of iterations performed
param csHitPoint Camera space location of the ray hit
*/
#define inline
bool traceScreenSpaceRay1(
vec3 csOrigin,
vec3 csDirection,
mat4 projectToPixelMatrix,
sampler2D csZBuffer,
vec2 csZBufferSize,
#ifdef SSRAYTRACE_USE_BACK_DEPTHBUFFER
sampler2D csZBackBuffer,
float csZBackSizeFactor,
#endif
float csZThickness,
float nearPlaneZ,
float stride,
float jitterFraction,
float maxSteps,
float maxRayTraceDistance,
float selfCollisionNumSkip,
out vec2 startPixel,
out vec2 hitPixel,
out vec3 csHitPoint,
out float numIterations
#ifdef SSRAYTRACE_DEBUG
,out vec3 debugColor
#endif
)
{
#ifdef SSRAYTRACE_RIGHT_HANDED_SCENE
float rayLength=(csOrigin.z+csDirection.z*maxRayTraceDistance)>-nearPlaneZ ? (-nearPlaneZ-csOrigin.z)/csDirection.z : maxRayTraceDistance;
#else
float rayLength=(csOrigin.z+csDirection.z*maxRayTraceDistance)<nearPlaneZ ? (nearPlaneZ-csOrigin.z)/csDirection.z : maxRayTraceDistance;
#endif
vec3 csEndPoint=csOrigin+csDirection*rayLength;hitPixel=vec2(-1.0,-1.0);vec4 H0=projectToPixelMatrix*vec4(csOrigin,1.0);vec4 H1=projectToPixelMatrix*vec4(csEndPoint,1.0);float k0=1.0/H0.w;float k1=1.0/H1.w;vec3 Q0=csOrigin*k0;vec3 Q1=csEndPoint*k1;vec2 P0=H0.xy*k0;vec2 P1=H1.xy*k1;
#ifdef SSRAYTRACE_CLIP_TO_FRUSTUM
float xMax=csZBufferSize.x-0.5,xMin=0.5,yMax=csZBufferSize.y-0.5,yMin=0.5;float alpha=0.0;if ((P1.y>yMax) || (P1.y<yMin)) {alpha=(P1.y-((P1.y>yMax) ? yMax : yMin))/(P1.y-P0.y);}
if ((P1.x>xMax) || (P1.x<xMin)) {alpha=max(alpha,(P1.x-((P1.x>xMax) ? xMax : xMin))/(P1.x-P0.x));}
P1=mix(P1,P0,alpha); k1=mix(k1,k0,alpha); Q1=mix(Q1,Q0,alpha);
#endif
P1+=vec2((distanceSquared(P0,P1)<0.0001) ? 0.01 : 0.0);vec2 delta=P1-P0;bool permute=false;if (abs(delta.x)<abs(delta.y)) { 
permute=true;delta=delta.yx;P0=P0.yx;P1=P1.yx; }
float stepDirection=sign(delta.x);float invdx=stepDirection/delta.x;vec2 dP=vec2(stepDirection,delta.y*invdx);vec3 dQ=(Q1-Q0)*invdx;float dk=(k1-k0)*invdx;float zMin=min(csEndPoint.z,csOrigin.z);float zMax=max(csEndPoint.z,csOrigin.z);dP*=stride; dQ*=stride; dk*=stride;P0+=dP*jitterFraction; Q0+=dQ*jitterFraction; k0+=dk*jitterFraction;vec4 pqk=vec4(P0,Q0.z,k0);vec4 dPQK=vec4(dP,dQ.z,dk);startPixel=permute ? P0.yx : P0.xy;float prevZMaxEstimate=csOrigin.z;float rayZMin=prevZMaxEstimate,rayZMax=prevZMaxEstimate;float sceneZMax=rayZMax+1e4;float end=P1.x*stepDirection;bool hit=false;float stepCount;for (stepCount=0.0;stepCount<=selfCollisionNumSkip ||
(pqk.x*stepDirection)<=end &&
stepCount<maxSteps &&
!hit &&
sceneZMax != 0.0; 
pqk+=dPQK,++stepCount)
{hitPixel=permute ? pqk.yx : pqk.xy;rayZMin=prevZMaxEstimate;rayZMax=(dPQK.z*0.5+pqk.z)/(dPQK.w*0.5+pqk.w);rayZMax=clamp(rayZMax,zMin,zMax);prevZMaxEstimate=rayZMax;if (rayZMin>rayZMax) { 
float t=rayZMin; rayZMin=rayZMax; rayZMax=t;}
sceneZMax=texelFetch(csZBuffer,ivec2(hitPixel),0).r;
#ifdef SSRAYTRACE_RIGHT_HANDED_SCENE
#ifdef SSRAYTRACE_USE_BACK_DEPTHBUFFER
float sceneBackZ=texelFetch(csZBackBuffer,ivec2(hitPixel/csZBackSizeFactor),0).r;hit=(rayZMax>=sceneBackZ-csZThickness) && (rayZMin<=sceneZMax);
#else
hit=(rayZMax>=sceneZMax-csZThickness) && (rayZMin<=sceneZMax);
#endif
#else
#ifdef SSRAYTRACE_USE_BACK_DEPTHBUFFER
float sceneBackZ=texelFetch(csZBackBuffer,ivec2(hitPixel/csZBackSizeFactor),0).r;hit=(rayZMin<=sceneBackZ+csZThickness) && (rayZMax>=sceneZMax) && (sceneZMax != 0.0);
#else
hit=(rayZMin<=sceneZMax+csZThickness) && (rayZMax>=sceneZMax);
#endif
#endif
}
pqk-=dPQK;stepCount-=1.0;if (((pqk.x+dPQK.x)*stepDirection)>end || (stepCount+1.0)>=maxSteps || sceneZMax==0.0) {hit=false;}
#ifdef SSRAYTRACE_ENABLE_REFINEMENT
if (stride>1.0 && hit) {pqk-=dPQK;stepCount-=1.0;float invStride=1.0/stride;dPQK*=invStride;float refinementStepCount=0.0;prevZMaxEstimate=pqk.z/pqk.w;rayZMax=prevZMaxEstimate;sceneZMax=rayZMax+1e7;for (;refinementStepCount<=1.0 ||
(refinementStepCount<=stride*1.4) &&
(rayZMax<sceneZMax) && (sceneZMax != 0.0);pqk+=dPQK,refinementStepCount+=1.0)
{rayZMin=prevZMaxEstimate;rayZMax=(dPQK.z*0.5+pqk.z)/(dPQK.w*0.5+pqk.w);rayZMax=clamp(rayZMax,zMin,zMax);prevZMaxEstimate=rayZMax;rayZMax=max(rayZMax,rayZMin);hitPixel=permute ? pqk.yx : pqk.xy;sceneZMax=texelFetch(csZBuffer,ivec2(hitPixel),0).r;}
pqk-=dPQK;refinementStepCount-=1.0;stepCount+=refinementStepCount/stride;}
#endif
Q0.xy+=dQ.xy*stepCount;Q0.z=pqk.z;csHitPoint=Q0/pqk.w;numIterations=stepCount+1.0;
#ifdef SSRAYTRACE_DEBUG
if (((pqk.x+dPQK.x)*stepDirection)>end) {debugColor=vec3(0,0,1);} else if ((stepCount+1.0)>=maxSteps) {debugColor=vec3(1,0,0);} else if (sceneZMax==0.0) {debugColor=vec3(1,1,0);} else {debugColor=vec3(0,stepCount/maxSteps,0);}
#endif
return hit;}
/**
texCoord: in the [0,1] range
depth: depth in view space (range [znear,zfar]])
*/
vec3 computeViewPosFromUVDepth(vec2 texCoord,float depth,mat4 projection,mat4 invProjectionMatrix) {vec4 ndc;ndc.xy=texCoord*2.0-1.0;
#ifdef SSRAYTRACE_RIGHT_HANDED_SCENE
ndc.z=-projection[2].z-projection[3].z/depth;
#else
ndc.z=projection[2].z+projection[3].z/depth;
#endif
ndc.w=1.0;vec4 eyePos=invProjectionMatrix*ndc;eyePos.xyz/=eyePos.w;return eyePos.xyz;}
`, re.ShadersStore.screenSpaceReflection2PixelShader = `#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
#define TEXTUREFUNC(s,c,lod) texture2DLodEXT(s,c,lod)
#define TEXTURECUBEFUNC(s,c,lod) textureLod(s,c,lod)
#else
#define TEXTUREFUNC(s,c,bias) texture2D(s,c,bias)
#define TEXTURECUBEFUNC(s,c,bias) textureCube(s,c,bias)
#endif
uniform sampler2D textureSampler;varying vec2 vUV;
#ifdef SSR_SUPPORTED
uniform sampler2D reflectivitySampler;uniform sampler2D normalSampler;uniform sampler2D depthSampler;
#ifdef SSRAYTRACE_USE_BACK_DEPTHBUFFER
uniform sampler2D backDepthSampler;uniform float backSizeFactor;
#endif
#ifdef SSR_USE_ENVIRONMENT_CUBE
uniform samplerCube envCubeSampler;
#ifdef SSR_USE_LOCAL_REFLECTIONMAP_CUBIC
uniform vec3 vReflectionPosition;uniform vec3 vReflectionSize;
#endif
#endif
uniform mat4 view;uniform mat4 invView;uniform mat4 projection;uniform mat4 invProjectionMatrix;uniform mat4 projectionPixel;uniform float nearPlaneZ;uniform float stepSize;uniform float maxSteps;uniform float strength;uniform float thickness;uniform float roughnessFactor;uniform float reflectionSpecularFalloffExponent;uniform float maxDistance;uniform float selfCollisionNumSkip;uniform float reflectivityThreshold;
#include<helperFunctions>
#include<pbrBRDFFunctions>
#include<screenSpaceRayTrace>
vec3 hash(vec3 a)
{a=fract(a*0.8);a+=dot(a,a.yxz+19.19);return fract((a.xxy+a.yxx)*a.zyx);}
float computeAttenuationForIntersection(ivec2 hitPixel,vec2 hitUV,vec3 vsRayOrigin,vec3 vsHitPoint,vec3 reflectionVector,float maxRayDistance,float numIterations) {float attenuation=1.0;
#ifdef SSR_ATTENUATE_SCREEN_BORDERS
vec2 dCoords=smoothstep(0.2,0.6,abs(vec2(0.5,0.5)-hitUV.xy));attenuation*=clamp(1.0-(dCoords.x+dCoords.y),0.0,1.0);
#endif
#ifdef SSR_ATTENUATE_INTERSECTION_DISTANCE
attenuation*=1.0-clamp(distance(vsRayOrigin,vsHitPoint)/maxRayDistance,0.0,1.0);
#endif
#ifdef SSR_ATTENUATE_INTERSECTION_NUMITERATIONS
attenuation*=1.0-(numIterations/maxSteps);
#endif
#ifdef SSR_ATTENUATE_BACKFACE_REFLECTION
vec3 reflectionNormal=texelFetch(normalSampler,hitPixel,0).xyz;float directionBasedAttenuation=smoothstep(-0.17,0.0,dot(reflectionNormal,-reflectionVector));attenuation*=directionBasedAttenuation;
#endif
return attenuation;}
#endif
void main()
{
#ifdef SSR_SUPPORTED
vec4 colorFull=TEXTUREFUNC(textureSampler,vUV,0.0);vec3 color=colorFull.rgb;vec4 reflectivity=TEXTUREFUNC(reflectivitySampler,vUV,0.0);
#ifndef SSR_DISABLE_REFLECTIVITY_TEST
if (max(reflectivity.r,max(reflectivity.g,reflectivity.b))<=reflectivityThreshold) {
#ifdef SSR_USE_BLUR
gl_FragColor=vec4(0.);
#else
gl_FragColor=colorFull;
#endif
return;}
#endif
#ifdef SSR_INPUT_IS_GAMMA_SPACE
color=toLinearSpace(color);
#endif
vec2 texSize=vec2(textureSize(depthSampler,0));vec3 csNormal=texelFetch(normalSampler,ivec2(vUV*texSize),0).xyz; 
float depth=texelFetch(depthSampler,ivec2(vUV*texSize),0).r;vec3 csPosition=computeViewPosFromUVDepth(vUV,depth,projection,invProjectionMatrix);vec3 csViewDirection=normalize(csPosition);vec3 csReflectedVector=reflect(csViewDirection,csNormal);
#ifdef SSR_USE_ENVIRONMENT_CUBE
vec3 wReflectedVector=vec3(invView*vec4(csReflectedVector,0.0));
#ifdef SSR_USE_LOCAL_REFLECTIONMAP_CUBIC
vec4 worldPos=invView*vec4(csPosition,1.0);wReflectedVector=parallaxCorrectNormal(worldPos.xyz,normalize(wReflectedVector),vReflectionSize,vReflectionPosition);
#endif
#ifdef SSR_INVERTCUBICMAP
wReflectedVector.y*=-1.0;
#endif
#ifdef SSRAYTRACE_RIGHT_HANDED_SCENE
wReflectedVector.z*=-1.0;
#endif
vec3 envColor=TEXTURECUBEFUNC(envCubeSampler,wReflectedVector,0.0).xyz;
#ifdef SSR_ENVIRONMENT_CUBE_IS_GAMMASPACE
envColor=toLinearSpace(envColor);
#endif
#else
vec3 envColor=color;
#endif
float reflectionAttenuation=1.0;bool rayHasHit=false;vec2 startPixel;vec2 hitPixel;vec3 hitPoint;float numIterations;
#ifdef SSRAYTRACE_DEBUG
vec3 debugColor;
#endif
#ifdef SSR_ATTENUATE_FACING_CAMERA
reflectionAttenuation*=1.0-smoothstep(0.25,0.5,dot(-csViewDirection,csReflectedVector));
#endif
if (reflectionAttenuation>0.0) {
#ifdef SSR_USE_BLUR
vec3 jitt=vec3(0.);
#else
float roughness=1.0-reflectivity.a;vec3 jitt=mix(vec3(0.0),hash(csPosition)-vec3(0.5),roughness)*roughnessFactor; 
#endif
vec2 uv2=vUV*texSize;float c=(uv2.x+uv2.y)*0.25;float jitter=mod(c,1.0); 
rayHasHit=traceScreenSpaceRay1(
csPosition,
normalize(csReflectedVector+jitt),
projectionPixel,
depthSampler,
texSize,
#ifdef SSRAYTRACE_USE_BACK_DEPTHBUFFER
backDepthSampler,
backSizeFactor,
#endif
thickness,
nearPlaneZ,
stepSize,
jitter,
maxSteps,
maxDistance,
selfCollisionNumSkip,
startPixel,
hitPixel,
hitPoint,
numIterations
#ifdef SSRAYTRACE_DEBUG
,debugColor
#endif
);}
#ifdef SSRAYTRACE_DEBUG
gl_FragColor=vec4(debugColor,1.);return;
#endif
vec3 F0=reflectivity.rgb;vec3 fresnel=fresnelSchlickGGX(max(dot(csNormal,-csViewDirection),0.0),F0,vec3(1.));vec3 SSR=envColor;if (rayHasHit) {vec3 reflectedColor=texelFetch(textureSampler,ivec2(hitPixel),0).rgb;
#ifdef SSR_INPUT_IS_GAMMA_SPACE
reflectedColor=toLinearSpace(reflectedColor);
#endif
reflectionAttenuation*=computeAttenuationForIntersection(ivec2(hitPixel),hitPixel/texSize,csPosition,hitPoint,csReflectedVector,maxDistance,numIterations);SSR=reflectedColor*reflectionAttenuation+(1.0-reflectionAttenuation)*envColor;}
#ifndef SSR_BLEND_WITH_FRESNEL
SSR*=fresnel;
#endif
#ifdef SSR_USE_BLUR
float blur_radius=0.0;float roughness=1.0-reflectivity.a*(1.0-roughnessFactor);if (roughness>0.001) {float cone_angle=min(roughness,0.999)*3.14159265*0.5;float cone_len=distance(startPixel,hitPixel);float op_len=2.0*tan(cone_angle)*cone_len; 
float a=op_len;float h=cone_len;float a2=a*a;float fh2=4.0f*h*h;blur_radius=(a*(sqrt(a2+fh2)-a))/(4.0f*h);}
gl_FragColor=vec4(SSR,blur_radius/255.0); 
#else
#ifdef SSR_BLEND_WITH_FRESNEL
vec3 reflectionMultiplier=clamp(pow(fresnel*strength,vec3(reflectionSpecularFalloffExponent)),0.0,1.0);
#else
vec3 reflectionMultiplier=clamp(pow(reflectivity.rgb*strength,vec3(reflectionSpecularFalloffExponent)),0.0,1.0);
#endif
vec3 colorMultiplier=1.0-reflectionMultiplier;vec3 finalColor=(color*colorMultiplier)+(SSR*reflectionMultiplier);
#ifdef SSR_OUTPUT_IS_GAMMA_SPACE
finalColor=toGammaSpace(finalColor);
#endif
gl_FragColor=vec4(finalColor,colorFull.a);
#endif
#else
gl_FragColor=TEXTUREFUNC(textureSampler,vUV,0.0);
#endif
}
`, re.ShadersStore.screenSpaceReflection2BlurPixelShader = `#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
#define TEXTUREFUNC(s,c,lod) texture2DLodEXT(s,c,lod)
#else
#define TEXTUREFUNC(s,c,bias) texture2D(s,c,bias)
#endif
uniform sampler2D textureSampler;varying vec2 vUV;uniform vec2 texelOffsetScale;const float weights[8]=float[8] (0.071303,0.131514,0.189879,0.321392,0.452906, 0.584419,0.715932,0.847445);void processSample(vec2 uv,float i,vec2 stepSize,inout vec4 accumulator,inout float denominator)
{vec2 offsetUV=stepSize*i+uv;float coefficient=weights[int(2.0-abs(i))];accumulator+=TEXTUREFUNC(textureSampler,offsetUV,0.0)*coefficient;denominator+=coefficient;}
void main()
{vec4 colorFull=TEXTUREFUNC(textureSampler,vUV,0.0);if (dot(colorFull,vec4(1.0))==0.0) {gl_FragColor=colorFull;return;}
float blurRadius=colorFull.a*255.0; 
vec2 stepSize=texelOffsetScale.xy*blurRadius;vec4 accumulator=TEXTUREFUNC(textureSampler,vUV,0.0)*0.214607;float denominator=0.214607;processSample(vUV,1.0,stepSize,accumulator,denominator);processSample(vUV,1.0*0.2,stepSize,accumulator,denominator);processSample(vUV,1.0*0.4,stepSize,accumulator,denominator);processSample(vUV,1.0*0.6,stepSize,accumulator,denominator);processSample(vUV,1.0*0.8,stepSize,accumulator,denominator);processSample(vUV,1.0*1.2,stepSize,accumulator,denominator);processSample(vUV,1.0*1.4,stepSize,accumulator,denominator);processSample(vUV,1.0*1.6,stepSize,accumulator,denominator);processSample(vUV,1.0*1.8,stepSize,accumulator,denominator);processSample(vUV,1.0*2.0,stepSize,accumulator,denominator);processSample(vUV,-1.0,stepSize,accumulator,denominator);processSample(vUV,-1.0*0.2,stepSize,accumulator,denominator);processSample(vUV,-1.0*0.4,stepSize,accumulator,denominator);processSample(vUV,-1.0*0.6,stepSize,accumulator,denominator);processSample(vUV,-1.0*0.8,stepSize,accumulator,denominator);processSample(vUV,-1.0*1.2,stepSize,accumulator,denominator);processSample(vUV,-1.0*1.4,stepSize,accumulator,denominator);processSample(vUV,-1.0*1.6,stepSize,accumulator,denominator);processSample(vUV,-1.0*1.8,stepSize,accumulator,denominator);processSample(vUV,-1.0*2.0,stepSize,accumulator,denominator);gl_FragColor=vec4(accumulator.rgb/denominator,colorFull.a);}
`, re.ShadersStore.screenSpaceReflection2BlurCombinerPixelShader = `uniform sampler2D textureSampler; 
uniform sampler2D mainSampler;uniform sampler2D reflectivitySampler;uniform float strength;uniform float reflectionSpecularFalloffExponent;uniform float reflectivityThreshold;varying vec2 vUV;
#include<helperFunctions>
#ifdef SSR_BLEND_WITH_FRESNEL
#include<pbrBRDFFunctions>
#include<screenSpaceRayTrace>
uniform mat4 projection;uniform mat4 invProjectionMatrix;uniform sampler2D normalSampler;uniform sampler2D depthSampler;
#endif
void main()
{
#ifdef SSRAYTRACE_DEBUG
gl_FragColor=texture2D(textureSampler,vUV);
#else
vec3 SSR=texture2D(textureSampler,vUV).rgb;vec4 color=texture2D(mainSampler,vUV);vec4 reflectivity=texture2D(reflectivitySampler,vUV);
#ifndef SSR_DISABLE_REFLECTIVITY_TEST
if (max(reflectivity.r,max(reflectivity.g,reflectivity.b))<=reflectivityThreshold) {gl_FragColor=color;return;}
#endif
#ifdef SSR_INPUT_IS_GAMMA_SPACE
color=toLinearSpace(color);
#endif
#ifdef SSR_BLEND_WITH_FRESNEL
vec2 texSize=vec2(textureSize(depthSampler,0));vec3 csNormal=texelFetch(normalSampler,ivec2(vUV*texSize),0).xyz;float depth=texelFetch(depthSampler,ivec2(vUV*texSize),0).r;vec3 csPosition=computeViewPosFromUVDepth(vUV,depth,projection,invProjectionMatrix);vec3 csViewDirection=normalize(csPosition);vec3 F0=reflectivity.rgb;vec3 fresnel=fresnelSchlickGGX(max(dot(csNormal,-csViewDirection),0.0),F0,vec3(1.));vec3 reflectionMultiplier=clamp(pow(fresnel*strength,vec3(reflectionSpecularFalloffExponent)),0.0,1.0);
#else
vec3 reflectionMultiplier=clamp(pow(reflectivity.rgb*strength,vec3(reflectionSpecularFalloffExponent)),0.0,1.0);
#endif
vec3 colorMultiplier=1.0-reflectionMultiplier;vec3 finalColor=(color.rgb*colorMultiplier)+(SSR*reflectionMultiplier);
#ifdef SSR_OUTPUT_IS_GAMMA_SPACE
finalColor=toGammaSpace(finalColor);
#endif
gl_FragColor=vec4(finalColor,color.a);
#endif
}
`;
    var AN = B.Compose(new v(0.5, 0.5, 0.5), oe.Identity(), new v(0.5, 0.5, 0.5)), RN = B.Compose(new v(0.5, 0.5, 1), oe.Identity(), new v(0.5, 0.5, 0)), dE = function(n) {
      function t(e, i, r, o, a) {
        o === void 0 && (o = !1), a === void 0 && (a = _.TEXTURETYPE_UNSIGNED_BYTE);
        var s = n.call(this, i.getEngine(), e) || this;
        if (s.SSRRenderEffect = "SSRRenderEffect", s.SSRBlurRenderEffect = "SSRBlurRenderEffect", s.SSRCombineRenderEffect = "SSRCombineRenderEffect", s._samples = 1, s.maxDistance = 1e3, s.step = 1, s.thickness = 0.5, s.strength = 1, s.reflectionSpecularFalloffExponent = 1, s.maxSteps = 1e3, s.roughnessFactor = 0.2, s.selfCollisionNumSkip = 1, s._reflectivityThreshold = 0.04, s._ssrDownsample = 0, s._blurDispersionStrength = 0.03, s._blurDownsample = 0, s._enableSmoothReflections = !1, s._environmentTextureIsProbe = !1, s._attenuateScreenBorders = !0, s._attenuateIntersectionDistance = !0, s._attenuateIntersectionIterations = !0, s._attenuateFacingCamera = !1, s._attenuateBackfaceReflection = !1, s._clipToFrustum = !0, s._useFresnel = !1, s._enableAutomaticThicknessComputation = !1, s._backfaceDepthTextureDownsample = 0, s._backfaceForceDepthWriteTransparentMeshes = !0, s._isEnabled = !0, s._inputTextureColorIsInGammaSpace = !0, s._generateOutputInGammaSpace = !0, s._debug = !1, s._forceGeometryBuffer = !1, s._isDirty = !1, s._camerasToBeAttached = [], s._cameras = r || i.cameras, s._cameras = s._cameras.slice(), s._camerasToBeAttached = s._cameras.slice(), s._scene = i, s._textureType = a, s._forceGeometryBuffer = o, s.isSupported) {
          if (i.postProcessRenderPipelineManager.addPipeline(s), s._forceGeometryBuffer) {
            var l = i.enableGeometryBufferRenderer();
            l && (l.enableReflectivity = !0, l.useSpecificClearForDepthTexture = !0, l.generateNormalsInWorldSpace && console.error("SSRRenderingPipeline does not support generateNormalsInWorldSpace=true for the geometry buffer renderer!"));
          } else {
            var c = i.enablePrePassRenderer();
            c && (c.useSpecificClearForDepthTexture = !0, c.markAsDirty(), c.generateNormalsInWorldSpace && console.error("SSRRenderingPipeline does not support generateNormalsInWorldSpace=true for the prepass renderer!"));
          }
          s._buildPipeline();
        }
        return s;
      }
      return D(t, n), Object.defineProperty(t.prototype, "samples", { get: function() {
        return this._samples;
      }, set: function(e) {
        this._samples !== e && (this._samples = e, this._buildPipeline());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "reflectivityThreshold", { get: function() {
        return this._reflectivityThreshold;
      }, set: function(e) {
        e !== this._reflectivityThreshold && (e === 0 && this._reflectivityThreshold !== 0 || e !== 0 && this._reflectivityThreshold === 0 ? (this._reflectivityThreshold = e, this._buildPipeline()) : this._reflectivityThreshold = e);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "ssrDownsample", { get: function() {
        return this._ssrDownsample;
      }, set: function(e) {
        e !== this._ssrDownsample && (this._ssrDownsample = e, this._buildPipeline());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "blurDispersionStrength", { get: function() {
        return this._blurDispersionStrength;
      }, set: function(e) {
        if (e !== this._blurDispersionStrength) {
          var i = e === 0 && this._blurDispersionStrength !== 0 || e !== 0 && this._blurDispersionStrength === 0;
          this._blurDispersionStrength = e, i && this._buildPipeline();
        }
      }, enumerable: !1, configurable: !0 }), t.prototype._useBlur = function() {
        return this._blurDispersionStrength > 0;
      }, Object.defineProperty(t.prototype, "blurDownsample", { get: function() {
        return this._blurDownsample;
      }, set: function(e) {
        e !== this._blurDownsample && (this._blurDownsample = e, this._buildPipeline());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "enableSmoothReflections", { get: function() {
        return this._enableSmoothReflections;
      }, set: function(e) {
        e !== this._enableSmoothReflections && (this._enableSmoothReflections = e, this._updateEffectDefines());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "environmentTexture", { get: function() {
        return this._environmentTexture;
      }, set: function(e) {
        this._environmentTexture = e, this._updateEffectDefines();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "environmentTextureIsProbe", { get: function() {
        return this._environmentTextureIsProbe;
      }, set: function(e) {
        this._environmentTextureIsProbe = e, this._updateEffectDefines();
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "attenuateScreenBorders", { get: function() {
        return this._attenuateScreenBorders;
      }, set: function(e) {
        this._attenuateScreenBorders !== e && (this._attenuateScreenBorders = e, this._updateEffectDefines());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "attenuateIntersectionDistance", { get: function() {
        return this._attenuateIntersectionDistance;
      }, set: function(e) {
        this._attenuateIntersectionDistance !== e && (this._attenuateIntersectionDistance = e, this._updateEffectDefines());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "attenuateIntersectionIterations", { get: function() {
        return this._attenuateIntersectionIterations;
      }, set: function(e) {
        this._attenuateIntersectionIterations !== e && (this._attenuateIntersectionIterations = e, this._updateEffectDefines());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "attenuateFacingCamera", { get: function() {
        return this._attenuateFacingCamera;
      }, set: function(e) {
        this._attenuateFacingCamera !== e && (this._attenuateFacingCamera = e, this._updateEffectDefines());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "attenuateBackfaceReflection", { get: function() {
        return this._attenuateBackfaceReflection;
      }, set: function(e) {
        this._attenuateBackfaceReflection !== e && (this._attenuateBackfaceReflection = e, this._updateEffectDefines());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "clipToFrustum", { get: function() {
        return this._clipToFrustum;
      }, set: function(e) {
        this._clipToFrustum !== e && (this._clipToFrustum = e, this._updateEffectDefines());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "useFresnel", { get: function() {
        return this._useFresnel;
      }, set: function(e) {
        this._useFresnel !== e && (this._useFresnel = e, this._buildPipeline());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "enableAutomaticThicknessComputation", { get: function() {
        return this._enableAutomaticThicknessComputation;
      }, set: function(e) {
        this._enableAutomaticThicknessComputation !== e && (this._enableAutomaticThicknessComputation = e, this._buildPipeline());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "backfaceDepthRenderer", { get: function() {
        return this._depthRenderer;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "backfaceDepthTextureDownsample", { get: function() {
        return this._backfaceDepthTextureDownsample;
      }, set: function(e) {
        this._backfaceDepthTextureDownsample !== e && (this._backfaceDepthTextureDownsample = e, this._resizeDepthRenderer());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "backfaceForceDepthWriteTransparentMeshes", { get: function() {
        return this._backfaceForceDepthWriteTransparentMeshes;
      }, set: function(e) {
        this._backfaceForceDepthWriteTransparentMeshes !== e && (this._backfaceForceDepthWriteTransparentMeshes = e, this._depthRenderer && (this._depthRenderer.forceDepthWriteTransparentMeshes = e));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isEnabled", { get: function() {
        return this._isEnabled;
      }, set: function(e) {
        this._isEnabled !== e && (this._isEnabled = e, e ? e && (this._isDirty ? this._buildPipeline() : this._cameras !== null && this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras)) : this._cameras !== null && (this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras), this._cameras = this._camerasToBeAttached.slice()));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "inputTextureColorIsInGammaSpace", { get: function() {
        return this._inputTextureColorIsInGammaSpace;
      }, set: function(e) {
        this._inputTextureColorIsInGammaSpace !== e && (this._inputTextureColorIsInGammaSpace = e, this._buildPipeline());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "generateOutputInGammaSpace", { get: function() {
        return this._generateOutputInGammaSpace;
      }, set: function(e) {
        this._generateOutputInGammaSpace !== e && (this._generateOutputInGammaSpace = e, this._buildPipeline());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "debug", { get: function() {
        return this._debug;
      }, set: function(e) {
        this._debug !== e && (this._debug = e, this._buildPipeline());
      }, enumerable: !1, configurable: !0 }), t.prototype.getScene = function() {
        return this._scene;
      }, Object.defineProperty(t.prototype, "_geometryBufferRenderer", { get: function() {
        return this._forceGeometryBuffer ? this._scene.geometryBufferRenderer : null;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "_prePassRenderer", { get: function() {
        return this._forceGeometryBuffer ? null : this._scene.prePassRenderer;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "scene", { get: function() {
        return this._scene;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isSupported", { get: function() {
        var e = this._scene.getEngine().getCaps();
        return e.drawBuffersExtension && e.texelFetch;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "SSRRenderingPipeline";
      }, t.prototype.addCamera = function(e) {
        this._camerasToBeAttached.push(e), this._buildPipeline();
      }, t.prototype.removeCamera = function(e) {
        var i = this._camerasToBeAttached.indexOf(e);
        this._camerasToBeAttached.splice(i, 1), this._buildPipeline();
      }, t.prototype.dispose = function(e) {
        e === void 0 && (e = !1), this._disposeDepthRenderer(), this._disposePostProcesses(), e && this._scene.disableGeometryBufferRenderer(), this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras), n.prototype.dispose.call(this);
      }, t.prototype._getTextureSize = function() {
        var e, i, r = this._scene.getEngine(), o = this._prePassRenderer, a = { width: r.getRenderWidth(), height: r.getRenderHeight() };
        if (o && ((e = this._scene.activeCamera) === null || e === void 0 ? void 0 : e._getFirstPostProcess()) === this._ssrPostProcess) {
          var s = o.getRenderTarget();
          s && s.textures && (a = s.textures[o.getIndex(_.PREPASS_COLOR_TEXTURE_TYPE)].getSize());
        } else
          !((i = this._ssrPostProcess) === null || i === void 0) && i.inputTexture && (a.width = this._ssrPostProcess.inputTexture.width, a.height = this._ssrPostProcess.inputTexture.height);
        return a;
      }, t.prototype._updateEffectDefines = function() {
        var e, i = [];
        (this._geometryBufferRenderer || this._prePassRenderer) && i.push("#define SSR_SUPPORTED"), this._enableSmoothReflections && i.push("#define SSRAYTRACE_ENABLE_REFINEMENT"), this._scene.useRightHandedSystem && i.push("#define SSRAYTRACE_RIGHT_HANDED_SCENE"), this._environmentTexture && (i.push("#define SSR_USE_ENVIRONMENT_CUBE"), this._environmentTexture.boundingBoxSize && i.push("#define SSR_USE_LOCAL_REFLECTIONMAP_CUBIC"), this._environmentTexture.gammaSpace && i.push("#define SSR_ENVIRONMENT_CUBE_IS_GAMMASPACE")), this._environmentTextureIsProbe && i.push("#define SSR_INVERTCUBICMAP"), this._enableAutomaticThicknessComputation && i.push("#define SSRAYTRACE_USE_BACK_DEPTHBUFFER"), this._attenuateScreenBorders && i.push("#define SSR_ATTENUATE_SCREEN_BORDERS"), this._attenuateIntersectionDistance && i.push("#define SSR_ATTENUATE_INTERSECTION_DISTANCE"), this._attenuateIntersectionIterations && i.push("#define SSR_ATTENUATE_INTERSECTION_NUMITERATIONS"), this._attenuateFacingCamera && i.push("#define SSR_ATTENUATE_FACING_CAMERA"), this._attenuateBackfaceReflection && i.push("#define SSR_ATTENUATE_BACKFACE_REFLECTION"), this._clipToFrustum && i.push("#define SSRAYTRACE_CLIP_TO_FRUSTUM"), this._useBlur() && i.push("#define SSR_USE_BLUR"), this._debug && i.push("#define SSRAYTRACE_DEBUG"), this._inputTextureColorIsInGammaSpace && i.push("#define SSR_INPUT_IS_GAMMA_SPACE"), this._generateOutputInGammaSpace && i.push("#define SSR_OUTPUT_IS_GAMMA_SPACE"), this._useFresnel && i.push("#define SSR_BLEND_WITH_FRESNEL"), this._reflectivityThreshold === 0 && i.push("#define SSR_DISABLE_REFLECTIVITY_TEST"), (e = this._ssrPostProcess) === null || e === void 0 || e.updateEffect(i.join(`
`));
      }, t.prototype._buildPipeline = function() {
        var e, i = this;
        if (this.isSupported)
          if (this._isEnabled) {
            this._isDirty = !1;
            var r = this._scene.getEngine();
            if (this._disposeDepthRenderer(), this._disposePostProcesses(), this._cameras !== null && (this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras), this._cameras = this._camerasToBeAttached.slice()), this._reset(), this._enableAutomaticThicknessComputation) {
              var o = (e = this._cameras) === null || e === void 0 ? void 0 : e[0];
              o && (this._depthRendererCamera = o, this._depthRenderer = new tu(this._scene, void 0, void 0, void 0, _.TEXTURE_NEAREST_SAMPLINGMODE, !0, "SSRBackDepth"), this._depthRenderer.clearColor.r = 1e8, this._depthRenderer.reverseCulling = !0, this._depthRenderer.forceDepthWriteTransparentMeshes = this._backfaceForceDepthWriteTransparentMeshes, this._resizeDepthRenderer(), o.customRenderTargets.push(this._depthRenderer.getDepthMap()));
            }
            this._createSSRPostProcess(), this.addEffect(new Vt(r, this.SSRRenderEffect, function() {
              return i._ssrPostProcess;
            }, !0)), this._useBlur() && (this._createBlurAndCombinerPostProcesses(), this.addEffect(new Vt(r, this.SSRBlurRenderEffect, function() {
              return [i._blurPostProcessX, i._blurPostProcessY];
            }, !0)), this.addEffect(new Vt(r, this.SSRCombineRenderEffect, function() {
              return i._blurCombinerPostProcess;
            }, !0))), this._cameras !== null && this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
          } else
            this._isDirty = !0;
      }, t.prototype._resizeDepthRenderer = function() {
        if (this._depthRenderer) {
          var e = this._getTextureSize(), i = this._depthRenderer.getDepthMap().getSize(), r = Math.floor(e.width / (this._backfaceDepthTextureDownsample + 1)), o = Math.floor(e.height / (this._backfaceDepthTextureDownsample + 1));
          i.width === r && i.height === o || this._depthRenderer.getDepthMap().resize({ width: r, height: o });
        }
      }, t.prototype._disposeDepthRenderer = function() {
        var e;
        if (this._depthRenderer) {
          if (this._depthRendererCamera) {
            var i = (e = this._depthRendererCamera.customRenderTargets.indexOf(this._depthRenderer.getDepthMap())) !== null && e !== void 0 ? e : -1;
            i !== -1 && this._depthRendererCamera.customRenderTargets.splice(i, 1);
          }
          this._depthRendererCamera = null, this._depthRenderer.getDepthMap().dispose();
        }
        this._depthRenderer = null;
      }, t.prototype._disposePostProcesses = function() {
        for (var e, i, r, o, a = 0; a < this._cameras.length; a++) {
          var s = this._cameras[a];
          (e = this._ssrPostProcess) === null || e === void 0 || e.dispose(s), (i = this._blurPostProcessX) === null || i === void 0 || i.dispose(s), (r = this._blurPostProcessY) === null || r === void 0 || r.dispose(s), (o = this._blurCombinerPostProcess) === null || o === void 0 || o.dispose(s);
        }
        this._ssrPostProcess = null, this._blurPostProcessX = null, this._blurPostProcessY = null, this._blurCombinerPostProcess = null;
      }, t.prototype._createSSRPostProcess = function() {
        var e = this;
        this._ssrPostProcess = new nt("ssr", "screenSpaceReflection2", ["projection", "invProjectionMatrix", "view", "invView", "thickness", "reflectionSpecularFalloffExponent", "strength", "stepSize", "maxSteps", "roughnessFactor", "projectionPixel", "nearPlaneZ", "maxDistance", "selfCollisionNumSkip", "vReflectionPosition", "vReflectionSize", "backSizeFactor", "reflectivityThreshold"], ["textureSampler", "normalSampler", "reflectivitySampler", "depthSampler", "envCubeSampler", "backDepthSampler"], 1, null, this._textureType, this._scene.getEngine(), !1, "", this._textureType), this._updateEffectDefines(), this._ssrPostProcess.onApply = function(i) {
          e._resizeDepthRenderer();
          var r = e._geometryBufferRenderer, o = e._prePassRenderer;
          if (o || r) {
            if (r) {
              var a = r.getTextureIndex(mr.REFLECTIVITY_TEXTURE_TYPE);
              i.setTexture("normalSampler", r.getGBuffer().textures[1]), i.setTexture("reflectivitySampler", r.getGBuffer().textures[a]), i.setTexture("depthSampler", r.getGBuffer().textures[0]);
            } else if (o) {
              var s = o.getIndex(_.PREPASS_DEPTH_TEXTURE_TYPE), l = (a = o.getIndex(_.PREPASS_REFLECTIVITY_TEXTURE_TYPE), o.getIndex(_.PREPASS_NORMAL_TEXTURE_TYPE));
              i.setTexture("normalSampler", o.getRenderTarget().textures[l]), i.setTexture("depthSampler", o.getRenderTarget().textures[s]), i.setTexture("reflectivitySampler", o.getRenderTarget().textures[a]);
            }
            e._enableAutomaticThicknessComputation && e._depthRenderer && (i.setTexture("backDepthSampler", e._depthRenderer.getDepthMap()), i.setFloat("backSizeFactor", e._backfaceDepthTextureDownsample + 1));
            var c = e._scene.activeCamera;
            if (c) {
              var u = c.getViewMatrix(!0), h = c.getProjectionMatrix(!0);
              h.invertToRef(F.Matrix[0]), u.invertToRef(F.Matrix[1]), i.setMatrix("projection", h), i.setMatrix("view", u), i.setMatrix("invView", F.Matrix[1]), i.setMatrix("invProjectionMatrix", F.Matrix[0]), i.setFloat("thickness", e.thickness), i.setFloat("reflectionSpecularFalloffExponent", e.reflectionSpecularFalloffExponent), i.setFloat("strength", e.strength), i.setFloat("stepSize", e.step), i.setFloat("maxSteps", e.maxSteps), i.setFloat("roughnessFactor", e.roughnessFactor), i.setFloat("nearPlaneZ", c.minZ), i.setFloat("maxDistance", e.maxDistance), i.setFloat("selfCollisionNumSkip", e.selfCollisionNumSkip), i.setFloat("reflectivityThreshold", e._reflectivityThreshold);
              var d = e._getTextureSize();
              B.ScalingToRef(d.width, d.height, 1, F.Matrix[2]), h.multiplyToRef(e._scene.getEngine().isWebGPU ? RN : AN, F.Matrix[3]), F.Matrix[3].multiplyToRef(F.Matrix[2], F.Matrix[4]), i.setMatrix("projectionPixel", F.Matrix[4]), e._environmentTexture && (i.setTexture("envCubeSampler", e._environmentTexture), e._environmentTexture.boundingBoxSize && (i.setVector3("vReflectionPosition", e._environmentTexture.boundingBoxPosition), i.setVector3("vReflectionSize", e._environmentTexture.boundingBoxSize)));
            }
          }
        }, this._ssrPostProcess.samples = this.samples, this._forceGeometryBuffer || (this._ssrPostProcess._prePassEffectConfiguration = new xN());
      }, t.prototype._createBlurAndCombinerPostProcesses = function() {
        var e = this, i = this._scene.getEngine();
        this._blurPostProcessX = new nt("SSRblurX", "screenSpaceReflection2Blur", ["texelOffsetScale"], ["textureSampler"], this._useBlur() ? 1 / (this._ssrDownsample + 1) : 1, null, _.TEXTURE_BILINEAR_SAMPLINGMODE, i, !1, "", this._textureType), this._blurPostProcessX.autoClear = !1, this._blurPostProcessX.onApplyObservable.add(function(s) {
          var l, c, u = (c = (l = e._blurPostProcessX) === null || l === void 0 ? void 0 : l.inputTexture.width) !== null && c !== void 0 ? c : e._scene.getEngine().getRenderWidth();
          s.setFloat2("texelOffsetScale", e._blurDispersionStrength / u, 0);
        }), this._blurPostProcessY = new nt("SSRblurY", "screenSpaceReflection2Blur", ["texelOffsetScale"], ["textureSampler"], this._useBlur() ? 1 / (this._blurDownsample + 1) : 1, null, _.TEXTURE_BILINEAR_SAMPLINGMODE, i, !1, "", this._textureType), this._blurPostProcessY.autoClear = !1, this._blurPostProcessY.onApplyObservable.add(function(s) {
          var l, c, u = (c = (l = e._blurPostProcessY) === null || l === void 0 ? void 0 : l.inputTexture.height) !== null && c !== void 0 ? c : e._scene.getEngine().getRenderHeight();
          s.setFloat2("texelOffsetScale", 0, e._blurDispersionStrength / u);
        });
        var r = ["strength", "reflectionSpecularFalloffExponent", "reflectivityThreshold"], o = ["textureSampler", "mainSampler", "reflectivitySampler"], a = "";
        this._debug && (a += `#define SSRAYTRACE_DEBUG
`), this._inputTextureColorIsInGammaSpace && (a += `#define SSR_INPUT_IS_GAMMA_SPACE
`), this._generateOutputInGammaSpace && (a += `#define SSR_OUTPUT_IS_GAMMA_SPACE
`), this.useFresnel && (a += `#define SSR_BLEND_WITH_FRESNEL
`, r.push("projection", "invProjectionMatrix"), o.push("depthSampler", "normalSampler")), this._reflectivityThreshold === 0 && (a += "#define SSR_DISABLE_REFLECTIVITY_TEST"), this._blurCombinerPostProcess = new nt("SSRblurCombiner", "screenSpaceReflection2BlurCombiner", r, o, this._useBlur() ? 1 / (this._blurDownsample + 1) : 1, null, _.TEXTURE_NEAREST_SAMPLINGMODE, i, !1, a, this._textureType), this._blurCombinerPostProcess.autoClear = !1, this._blurCombinerPostProcess.onApplyObservable.add(function(s) {
          var l, c = e._geometryBufferRenderer, u = e._prePassRenderer;
          if (u || c) {
            if (u && ((l = e._scene.activeCamera) === null || l === void 0 ? void 0 : l._getFirstPostProcess()) === e._ssrPostProcess) {
              var h = u.getRenderTarget();
              h && h.textures && s.setTexture("mainSampler", h.textures[u.getIndex(_.PREPASS_COLOR_TEXTURE_TYPE)]);
            } else
              s.setTextureFromPostProcess("mainSampler", e._ssrPostProcess);
            if (c) {
              var d = c.getTextureIndex(mr.REFLECTIVITY_TEXTURE_TYPE);
              s.setTexture("reflectivitySampler", c.getGBuffer().textures[d]), e.useFresnel && (s.setTexture("normalSampler", c.getGBuffer().textures[1]), s.setTexture("depthSampler", c.getGBuffer().textures[0]));
            } else if (u && (d = u.getIndex(_.PREPASS_REFLECTIVITY_TEXTURE_TYPE), s.setTexture("reflectivitySampler", u.getRenderTarget().textures[d]), e.useFresnel)) {
              var p = u.getIndex(_.PREPASS_DEPTH_TEXTURE_TYPE), f = u.getIndex(_.PREPASS_NORMAL_TEXTURE_TYPE);
              s.setTexture("normalSampler", u.getRenderTarget().textures[f]), s.setTexture("depthSampler", u.getRenderTarget().textures[p]);
            }
            if (s.setFloat("strength", e.strength), s.setFloat("reflectionSpecularFalloffExponent", e.reflectionSpecularFalloffExponent), s.setFloat("reflectivityThreshold", e._reflectivityThreshold), e.useFresnel) {
              var m = e._scene.activeCamera;
              if (m) {
                var g = m.getProjectionMatrix();
                g.invertToRef(F.Matrix[0]), s.setMatrix("projection", g), s.setMatrix("invProjectionMatrix", F.Matrix[0]);
              }
            }
          }
        });
      }, t.prototype.serialize = function() {
        var e = Ne.Serialize(this);
        return e.customType = "SSRRenderingPipeline", e;
      }, t.Parse = function(e, i, r) {
        return Ne.Parse(function() {
          return new t(e._name, i, e._ratio);
        }, e, i, r);
      }, x([N()], t.prototype, "samples", null), x([N()], t.prototype, "maxDistance", void 0), x([N()], t.prototype, "step", void 0), x([N()], t.prototype, "thickness", void 0), x([N()], t.prototype, "strength", void 0), x([N()], t.prototype, "reflectionSpecularFalloffExponent", void 0), x([N()], t.prototype, "maxSteps", void 0), x([N()], t.prototype, "roughnessFactor", void 0), x([N()], t.prototype, "selfCollisionNumSkip", void 0), x([N()], t.prototype, "_reflectivityThreshold", void 0), x([N("_ssrDownsample")], t.prototype, "_ssrDownsample", void 0), x([N()], t.prototype, "ssrDownsample", null), x([N("blurDispersionStrength")], t.prototype, "_blurDispersionStrength", void 0), x([N("blurDownsample")], t.prototype, "_blurDownsample", void 0), x([N("enableSmoothReflections")], t.prototype, "_enableSmoothReflections", void 0), x([N("environmentTexture")], t.prototype, "_environmentTexture", void 0), x([N("environmentTextureIsProbe")], t.prototype, "_environmentTextureIsProbe", void 0), x([N("attenuateScreenBorders")], t.prototype, "_attenuateScreenBorders", void 0), x([N("attenuateIntersectionDistance")], t.prototype, "_attenuateIntersectionDistance", void 0), x([N("attenuateIntersectionIterations")], t.prototype, "_attenuateIntersectionIterations", void 0), x([N("attenuateFacingCamera")], t.prototype, "_attenuateFacingCamera", void 0), x([N("attenuateBackfaceReflection")], t.prototype, "_attenuateBackfaceReflection", void 0), x([N("clipToFrustum")], t.prototype, "_clipToFrustum", void 0), x([N("useFresnel")], t.prototype, "_useFresnel", void 0), x([N("enableAutomaticThicknessComputation")], t.prototype, "_enableAutomaticThicknessComputation", void 0), x([N("backfaceDepthTextureDownsample")], t.prototype, "_backfaceDepthTextureDownsample", void 0), x([N("backfaceForceDepthWriteTransparentMeshes")], t.prototype, "_backfaceForceDepthWriteTransparentMeshes", void 0), x([N("isEnabled")], t.prototype, "_isEnabled", void 0), x([N("inputTextureColorIsInGammaSpace")], t.prototype, "_inputTextureColorIsInGammaSpace", void 0), x([N("generateOutputInGammaSpace")], t.prototype, "_generateOutputInGammaSpace", void 0), x([N("debug")], t.prototype, "_debug", void 0), t;
    }(Ns);
    j("BABYLON.SSRRenderingPipeline", dE);
    var Fs;
    re.ShadersStore.tonemapPixelShader = `varying vec2 vUV;uniform sampler2D textureSampler;uniform float _ExposureAdjustment;
#if defined(HABLE_TONEMAPPING)
const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;const float W=11.2;
#endif
float Luminance(vec3 c)
{return dot(c,vec3(0.22,0.707,0.071));}
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void) 
{vec3 colour=texture2D(textureSampler,vUV).rgb;
#if defined(REINHARD_TONEMAPPING)
float lum=Luminance(colour.rgb); 
float lumTm=lum*_ExposureAdjustment;float scale=lumTm/(1.0+lumTm); 
colour*=scale/lum;
#elif defined(HABLE_TONEMAPPING)
colour*=_ExposureAdjustment;const float ExposureBias=2.0;vec3 x=ExposureBias*colour;vec3 curr=((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;x=vec3(W,W,W);vec3 whiteScale=1.0/(((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F);colour=curr*whiteScale;
#elif defined(OPTIMIZED_HEJIDAWSON_TONEMAPPING)
colour*=_ExposureAdjustment;vec3 X=max(vec3(0.0,0.0,0.0),colour-0.004);vec3 retColor=(X*(6.2*X+0.5))/(X*(6.2*X+1.7)+0.06);colour=retColor*retColor;
#elif defined(PHOTOGRAPHIC_TONEMAPPING)
colour= vec3(1.0,1.0,1.0)-exp2(-_ExposureAdjustment*colour);
#endif
gl_FragColor=vec4(colour.rgb,1.0);}`, function(n) {
      n[n.Hable = 0] = "Hable", n[n.Reinhard = 1] = "Reinhard", n[n.HejiDawson = 2] = "HejiDawson", n[n.Photographic = 3] = "Photographic";
    }(Fs || (Fs = {}));
    var lI = function(n) {
      function t(e, i, r, o, a, s, l, c) {
        a === void 0 && (a = _.TEXTURE_BILINEAR_SAMPLINGMODE), l === void 0 && (l = _.TEXTURETYPE_UNSIGNED_INT);
        var u = n.call(this, e, "tonemap", ["_ExposureAdjustment"], null, 1, o, a, s, c, null, l) || this;
        u._operator = i, u.exposureAdjustment = r;
        var h = "#define ";
        return u._operator === Fs.Hable ? h += "HABLE_TONEMAPPING" : u._operator === Fs.Reinhard ? h += "REINHARD_TONEMAPPING" : u._operator === Fs.HejiDawson ? h += "OPTIMIZED_HEJIDAWSON_TONEMAPPING" : u._operator === Fs.Photographic && (h += "PHOTOGRAPHIC_TONEMAPPING"), u.updateEffect(h), u.onApply = function(d) {
          d.setFloat("_ExposureAdjustment", u.exposureAdjustment);
        }, u;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "TonemapPostProcess";
      }, t;
    }(nt);
    re.ShadersStore.volumetricLightScatteringPixelShader = `uniform sampler2D textureSampler;uniform sampler2D lightScatteringSampler;uniform float decay;uniform float exposure;uniform float weight;uniform float density;uniform vec2 meshPositionOnScreen;varying vec2 vUV;
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void) {
#define CUSTOM_FRAGMENT_MAIN_BEGIN
vec2 tc=vUV;vec2 deltaTexCoord=(tc-meshPositionOnScreen.xy);deltaTexCoord*=1.0/float(NUM_SAMPLES)*density;float illuminationDecay=1.0;vec4 color=texture2D(lightScatteringSampler,tc)*0.4;for(int i=0; i<NUM_SAMPLES; i++) {tc-=deltaTexCoord;vec4 dataSample=texture2D(lightScatteringSampler,tc)*0.4;dataSample*=illuminationDecay*weight;color+=dataSample;illuminationDecay*=decay;}
vec4 realColor=texture2D(textureSampler,vUV);gl_FragColor=((vec4((vec3(color.r,color.g,color.b)*exposure),1))+(realColor*(1.5-0.4)));
#define CUSTOM_FRAGMENT_MAIN_END
}
`, re.ShadersStore.volumetricLightScatteringPassVertexShader = `attribute vec3 position;
#include<bonesDeclaration>
#include<bakedVertexAnimationDeclaration>
#include<morphTargetsVertexGlobalDeclaration>
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
#include<instancesDeclaration>
uniform mat4 viewProjection;uniform vec2 depthValues;
#if defined(ALPHATEST) || defined(NEED_UV)
varying vec2 vUV;uniform mat4 diffuseMatrix;
#ifdef UV1
attribute vec2 uv;
#endif
#ifdef UV2
attribute vec2 uv2;
#endif
#endif
#define CUSTOM_VERTEX_DEFINITIONS
void main(void)
{vec3 positionUpdated=position;
#if (defined(ALPHATEST) || defined(NEED_UV)) && defined(UV1)
vec2 uvUpdated=uv;
#endif
#include<morphTargetsVertexGlobal>
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
#include<instancesVertex>
#include<bonesVertex>
#include<bakedVertexAnimation>
gl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);
#if defined(ALPHATEST) || defined(BASIC_RENDER)
#ifdef UV1
vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
#endif
#ifdef UV2
vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
#endif
#endif
}
`, re.ShadersStore.volumetricLightScatteringPassPixelShader = `#if defined(ALPHATEST) || defined(NEED_UV)
varying vec2 vUV;
#endif
#if defined(ALPHATEST)
uniform sampler2D diffuseSampler;
#endif
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void)
{
#if defined(ALPHATEST)
vec4 diffuseColor=texture2D(diffuseSampler,vUV);if (diffuseColor.a<0.4)
discard;
#endif
gl_FragColor=vec4(0.0,0.0,0.0,1.0);}
`;
    var pE = function(n) {
      function t(e, i, r, o, a, s, l, c, u) {
        a === void 0 && (a = 100), s === void 0 && (s = ae.BILINEAR_SAMPLINGMODE);
        var h, d, p = this;
        return (p = n.call(this, e, "volumetricLightScattering", ["decay", "exposure", "weight", "meshPositionOnScreen", "density"], ["lightScatteringSampler"], i.postProcessRatio || i, r, s, l, c, "#define NUM_SAMPLES " + a) || this)._screenCoordinates = fe.Zero(), p.customMeshPosition = v.Zero(), p.useCustomMeshPosition = !1, p.invert = !0, p.excludedMeshes = [], p.includedMeshes = [], p.exposure = 0.3, p.decay = 0.96815, p.weight = 0.58767, p.density = 0.926, l = (u = (d = (h = r == null ? void 0 : r.getScene()) !== null && h !== void 0 ? h : u) !== null && d !== void 0 ? d : p._scene).getEngine(), p._viewPort = new xr(0, 0, 1, 1).toGlobal(l.getRenderWidth(), l.getRenderHeight()), p.mesh = o ?? t.CreateDefaultMesh("VolumetricLightScatteringMesh", u), p._createPass(u, i.passRatio || i), p.onActivate = function(f) {
          p.isSupported || p.dispose(f), p.onActivate = null;
        }, p.onApplyObservable.add(function(f) {
          p._updateMeshScreenCoordinates(u), f.setTexture("lightScatteringSampler", p._volumetricLightScatteringRTT), f.setFloat("exposure", p.exposure), f.setFloat("decay", p.decay), f.setFloat("weight", p.weight), f.setFloat("density", p.density), f.setVector2("meshPositionOnScreen", p._screenCoordinates);
        }), p;
      }
      return D(t, n), Object.defineProperty(t.prototype, "useDiffuseColor", { get: function() {
        return q.Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead"), !1;
      }, set: function(e) {
        q.Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "VolumetricLightScatteringPostProcess";
      }, t.prototype._isReady = function(e, i) {
        var r, o = e.getMesh();
        if (o === this.mesh && o.material)
          return o.material.isReady(o);
        var a = (r = o._internalAbstractMeshDataInfo._materialForRenderPass) === null || r === void 0 ? void 0 : r[this._scene.getEngine().currentRenderPassId];
        if (a)
          return a.isReadyForSubMesh(o, e, i);
        var s = [], l = [P.PositionKind], c = e.getMaterial();
        c && (c.needAlphaTesting() && s.push("#define ALPHATEST"), o.isVerticesDataPresent(P.UVKind) && (l.push(P.UVKind), s.push("#define UV1")), o.isVerticesDataPresent(P.UV2Kind) && (l.push(P.UV2Kind), s.push("#define UV2"))), o.useBones && o.computeBonesUsingShaders ? (l.push(P.MatricesIndicesKind), l.push(P.MatricesWeightsKind), s.push("#define NUM_BONE_INFLUENCERS " + o.numBoneInfluencers), s.push("#define BonesPerMesh " + (o.skeleton ? o.skeleton.bones.length + 1 : 0))) : s.push("#define NUM_BONE_INFLUENCERS 0"), i && (s.push("#define INSTANCES"), Se.PushAttributesForInstances(l), e.getRenderingMesh().hasThinInstances && s.push("#define THIN_INSTANCES"));
        var u = e._getDrawWrapper(void 0, !0), h = u.defines, d = s.join(`
`);
        return h !== d && u.setEffect(o.getScene().getEngine().createEffect("volumetricLightScatteringPass", l, ["world", "mBones", "viewProjection", "diffuseMatrix"], ["diffuseSampler"], d, void 0, void 0, void 0, { maxSimultaneousMorphTargets: o.numBoneInfluencers }), d), u.effect.isReady();
      }, t.prototype.setCustomMeshPosition = function(e) {
        this.customMeshPosition = e;
      }, t.prototype.getCustomMeshPosition = function() {
        return this.customMeshPosition;
      }, t.prototype.dispose = function(e) {
        var i = e.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);
        i !== -1 && e.getScene().customRenderTargets.splice(i, 1), this._volumetricLightScatteringRTT.dispose(), n.prototype.dispose.call(this, e);
      }, t.prototype.getPass = function() {
        return this._volumetricLightScatteringRTT;
      }, t.prototype._meshExcluded = function(e) {
        return this.includedMeshes.length > 0 && this.includedMeshes.indexOf(e) === -1 || this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(e) !== -1;
      }, t.prototype._createPass = function(e, i) {
        var r = this, o = e.getEngine();
        this._volumetricLightScatteringRTT = new Mi("volumetricLightScatteringMap", { width: o.getRenderWidth() * i, height: o.getRenderHeight() * i }, e, !1, !0, _.TEXTURETYPE_UNSIGNED_INT), this._volumetricLightScatteringRTT.wrapU = ae.CLAMP_ADDRESSMODE, this._volumetricLightScatteringRTT.wrapV = ae.CLAMP_ADDRESSMODE, this._volumetricLightScatteringRTT.renderList = null, this._volumetricLightScatteringRTT.renderParticles = !1, this._volumetricLightScatteringRTT.ignoreCameraViewport = !0;
        var a = this.getCamera();
        a ? a.customRenderTargets.push(this._volumetricLightScatteringRTT) : e.customRenderTargets.push(this._volumetricLightScatteringRTT);
        var s, l = function(u) {
          var h, d = u.getRenderingMesh(), p = u.getEffectiveMesh();
          if (!r._meshExcluded(d)) {
            p._internalAbstractMeshDataInfo._isActiveIntermediate = !1;
            var f = u.getMaterial();
            if (f) {
              var m = d.getScene(), g = m.getEngine();
              g.setState(f.backFaceCulling, void 0, void 0, void 0, f.cullBackFaces);
              var y = d._getInstancesRenderList(u._id, !!u.getReplacementMesh());
              if (!y.mustReturn) {
                var b = g.getCaps().instancedArrays && (y.visibleInstances[u._id] !== null || d.hasThinInstances);
                if (r._isReady(u, b)) {
                  var T = (h = p._internalAbstractMeshDataInfo._materialForRenderPass) === null || h === void 0 ? void 0 : h[g.currentRenderPassId], S = u._getDrawWrapper();
                  if (d !== r.mesh || S || (S = f._getDrawWrapper()), !S)
                    return;
                  var E = S.effect;
                  if (g.enableEffect(S), b || d._bind(u, E, f.fillMode), d === r.mesh)
                    f.bind(p.getWorldMatrix(), d);
                  else if (T)
                    T.bindForSubMesh(p.getWorldMatrix(), p, u);
                  else {
                    if (E.setMatrix("viewProjection", m.getTransformMatrix()), f && f.needAlphaTesting()) {
                      var A = f.getAlphaTestTexture();
                      E.setTexture("diffuseSampler", A), A && E.setMatrix("diffuseMatrix", A.getTextureMatrix());
                    }
                    d.useBones && d.computeBonesUsingShaders && d.skeleton && E.setMatrices("mBones", d.skeleton.getTransformMatrices(d));
                  }
                  b && d.hasThinInstances && E.setMatrix("world", p.getWorldMatrix()), d._processRendering(p, u, E, Et.TriangleFillMode, y, b, function(R, C) {
                    R || E.setMatrix("world", C);
                  });
                }
              }
            }
          }
        }, c = new Ie(0, 0, 0, 1);
        this._volumetricLightScatteringRTT.onBeforeRenderObservable.add(function() {
          s = e.clearColor, e.clearColor = c;
        }), this._volumetricLightScatteringRTT.onAfterRenderObservable.add(function() {
          e.clearColor = s;
        }), this._volumetricLightScatteringRTT.customIsReadyFunction = function(u, h, d) {
          if ((d || h === 0) && u.subMeshes)
            for (var p = 0; p < u.subMeshes.length; ++p) {
              var f = u.subMeshes[p], m = f.getMaterial(), g = f.getRenderingMesh();
              if (m) {
                var y = g._getInstancesRenderList(f._id, !!f.getReplacementMesh()), b = o.getCaps().instancedArrays && (y.visibleInstances[f._id] !== null || g.hasThinInstances);
                if (!r._isReady(f, b))
                  return !1;
              }
            }
          return !0;
        }, this._volumetricLightScatteringRTT.customRenderFunction = function(u, h, d, p) {
          var f, m = e.getEngine();
          if (p.length) {
            for (m.setColorWrite(!1), f = 0; f < p.length; f++)
              l(p.data[f]);
            m.setColorWrite(!0);
          }
          for (f = 0; f < u.length; f++)
            l(u.data[f]);
          for (f = 0; f < h.length; f++)
            l(h.data[f]);
          if (d.length) {
            for (f = 0; f < d.length; f++) {
              var g = d.data[f], y = g.getBoundingInfo();
              y && e.activeCamera && (g._alphaIndex = g.getMesh().alphaIndex, g._distanceToCamera = y.boundingSphere.centerWorld.subtract(e.activeCamera.position).length());
            }
            var b = d.data.slice(0, d.length);
            for (b.sort(function(T, S) {
              return T._alphaIndex > S._alphaIndex ? 1 : T._alphaIndex < S._alphaIndex ? -1 : T._distanceToCamera < S._distanceToCamera ? 1 : T._distanceToCamera > S._distanceToCamera ? -1 : 0;
            }), m.setAlphaMode(_.ALPHA_COMBINE), f = 0; f < b.length; f++)
              l(b[f]);
            m.setAlphaMode(_.ALPHA_DISABLE);
          }
        };
      }, t.prototype._updateMeshScreenCoordinates = function(e) {
        var i, r = e.getTransformMatrix();
        i = this.useCustomMeshPosition ? this.customMeshPosition : this.attachedNode ? this.attachedNode.position : this.mesh.parent ? this.mesh.getAbsolutePosition() : this.mesh.position;
        var o = v.Project(i, B.Identity(), r, this._viewPort);
        this._screenCoordinates.x = o.x / this._viewPort.width, this._screenCoordinates.y = o.y / this._viewPort.height, this.invert && (this._screenCoordinates.y = 1 - this._screenCoordinates.y);
      }, t.CreateDefaultMesh = function(e, i) {
        var r = Ro(e, { size: 1 }, i);
        r.billboardMode = Dt.BILLBOARDMODE_ALL;
        var o = new Gt(e + "Material", i);
        return o.emissiveColor = new ne(1, 1, 1), r.material = o, r;
      }, x([ki()], t.prototype, "customMeshPosition", void 0), x([N()], t.prototype, "useCustomMeshPosition", void 0), x([N()], t.prototype, "invert", void 0), x([$o()], t.prototype, "mesh", void 0), x([N()], t.prototype, "excludedMeshes", void 0), x([N()], t.prototype, "includedMeshes", void 0), x([N()], t.prototype, "exposure", void 0), x([N()], t.prototype, "decay", void 0), x([N()], t.prototype, "weight", void 0), x([N()], t.prototype, "density", void 0), t;
    }(nt);
    j("BABYLON.VolumetricLightScatteringPostProcess", pE), re.ShadersStore.screenSpaceCurvaturePixelShader = `precision highp float;varying vec2 vUV;uniform sampler2D textureSampler;uniform sampler2D normalSampler;uniform float curvature_ridge;uniform float curvature_valley;
#ifndef CURVATURE_OFFSET
#define CURVATURE_OFFSET 1
#endif
float curvature_soft_clamp(float curvature,float control)
{if (curvature<0.5/control)
return curvature*(1.0-curvature*control);return 0.25/control;}
float calculate_curvature(ivec2 texel,float ridge,float valley)
{vec2 normal_up =texelFetch(normalSampler,texel+ivec2(0, CURVATURE_OFFSET),0).rb;vec2 normal_down =texelFetch(normalSampler,texel+ivec2(0,-CURVATURE_OFFSET),0).rb;vec2 normal_left =texelFetch(normalSampler,texel+ivec2(-CURVATURE_OFFSET,0),0).rb;vec2 normal_right=texelFetch(normalSampler,texel+ivec2( CURVATURE_OFFSET,0),0).rb;float normal_diff=((normal_up.g-normal_down.g)+(normal_right.r-normal_left.r));if (normal_diff<0.0)
return -2.0*curvature_soft_clamp(-normal_diff,valley);return 2.0*curvature_soft_clamp(normal_diff,ridge);}
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void) 
{ivec2 texel=ivec2(gl_FragCoord.xy);vec4 baseColor=texture2D(textureSampler,vUV);float curvature=calculate_curvature(texel,curvature_ridge,curvature_valley);baseColor.rgb*=curvature+1.0;gl_FragColor=baseColor;}`;
    var fE = function(n) {
      function t(e, i, r, o, a, s, l, c, u) {
        c === void 0 && (c = _.TEXTURETYPE_UNSIGNED_INT), u === void 0 && (u = !1);
        var h = n.call(this, e, "screenSpaceCurvature", ["curvature_ridge", "curvature_valley"], ["textureSampler", "normalSampler"], r, o, a, s, l, void 0, c, void 0, null, u) || this;
        return h.ridge = 1, h.valley = 1, h._geometryBufferRenderer = i.enableGeometryBufferRenderer(), h._geometryBufferRenderer ? (h._geometryBufferRenderer.generateNormalsInWorldSpace && console.error("ScreenSpaceCurvaturePostProcess does not support generateNormalsInWorldSpace=true for the geometry buffer renderer!"), h.onApply = function(d) {
          d.setFloat("curvature_ridge", 0.5 / Math.max(h.ridge * h.ridge, 1e-4)), d.setFloat("curvature_valley", 0.7 / Math.max(h.valley * h.valley, 1e-4));
          var p = h._geometryBufferRenderer.getGBuffer().textures[1];
          d.setTexture("normalSampler", p);
        }) : q.Error("Multiple Render Target support needed for screen space curvature post process. Please use IsSupported test first."), h;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "ScreenSpaceCurvaturePostProcess";
      }, Object.defineProperty(t, "IsSupported", { get: function() {
        var e = Me.LastCreatedEngine;
        return !!e && e.getCaps().drawBuffersExtension;
      }, enumerable: !1, configurable: !0 }), t._Parse = function(e, i, r, o) {
        return Ne.Parse(function() {
          return new t(e.name, r, e.options, i, e.renderTargetSamplingMode, r.getEngine(), e.textureType, e.reusable);
        }, e, r, o);
      }, x([N()], t.prototype, "ridge", void 0), x([N()], t.prototype, "valley", void 0), t;
    }(nt);
    j("BABYLON.ScreenSpaceCurvaturePostProcess", fE), re.IncludesShadersStore.boundingBoxRendererFragmentDeclaration = `uniform vec4 color;
`, re.IncludesShadersStore.boundingBoxRendererUboDeclaration = `#ifdef WEBGL2
uniform vec4 color;uniform mat4 world;uniform mat4 viewProjection;
#ifdef MULTIVIEW
uniform mat4 viewProjectionR;
#endif
#else
layout(std140,column_major) uniform;uniform BoundingBoxRenderer {vec4 color;mat4 world;mat4 viewProjection;mat4 viewProjectionR;};
#endif
`, re.ShadersStore.boundingBoxRendererPixelShader = `#include<__decl__boundingBoxRendererFragment>
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void) {
#define CUSTOM_FRAGMENT_MAIN_BEGIN
gl_FragColor=color;
#define CUSTOM_FRAGMENT_MAIN_END
}`, re.IncludesShadersStore.boundingBoxRendererVertexDeclaration = `uniform mat4 world;uniform mat4 viewProjection;
#ifdef MULTIVIEW
uniform mat4 viewProjectionR;
#endif
`, re.ShadersStore.boundingBoxRendererVertexShader = `attribute vec3 position;
#include<__decl__boundingBoxRendererVertex>
#define CUSTOM_VERTEX_DEFINITIONS
void main(void) {
#define CUSTOM_VERTEX_MAIN_BEGIN
vec4 worldPos=world*vec4(position,1.0);
#ifdef MULTIVIEW
if (gl_ViewID_OVR==0u) {gl_Position=viewProjection*worldPos;} else {gl_Position=viewProjectionR*worldPos;}
#else
gl_Position=viewProjection*worldPos;
#endif
#define CUSTOM_VERTEX_MAIN_END
}
`, Object.defineProperty(Ue.prototype, "forceShowBoundingBoxes", { get: function() {
      return this._forceShowBoundingBoxes || !1;
    }, set: function(n) {
      this._forceShowBoundingBoxes = n, n && this.getBoundingBoxRenderer();
    }, enumerable: !0, configurable: !0 }), Ue.prototype.getBoundingBoxRenderer = function() {
      return this._boundingBoxRenderer || (this._boundingBoxRenderer = new _E(this)), this._boundingBoxRenderer;
    }, Object.defineProperty(Dt.prototype, "showBoundingBox", { get: function() {
      return this._showBoundingBox || !1;
    }, set: function(n) {
      this._showBoundingBox = n, n && this.getScene().getBoundingBoxRenderer();
    }, enumerable: !0, configurable: !0 });
    var _E = function() {
      function n(t) {
        this.name = we.NAME_BOUNDINGBOXRENDERER, this.frontColor = new ne(1, 1, 1), this.backColor = new ne(0.1, 0.1, 0.1), this.showBackLines = !0, this.onBeforeBoxRenderingObservable = new H(), this.onAfterBoxRenderingObservable = new H(), this.onResourcesReadyObservable = new H(), this.enabled = !0, this.renderList = new en(32), this._vertexBuffers = {}, this._fillIndexBuffer = null, this._fillIndexData = null, this.scene = t, t._addComponent(this), this._uniformBufferFront = new Er(this.scene.getEngine(), void 0, void 0, "BoundingBoxRendererFront", !this.scene.getEngine().isWebGPU), this._buildUniformLayout(this._uniformBufferFront), this._uniformBufferBack = new Er(this.scene.getEngine(), void 0, void 0, "BoundingBoxRendererBack", !this.scene.getEngine().isWebGPU), this._buildUniformLayout(this._uniformBufferBack);
      }
      return n.prototype._buildUniformLayout = function(t) {
        t.addUniform("color", 4), t.addUniform("world", 16), t.addUniform("viewProjection", 16), t.addUniform("viewProjectionR", 16), t.create();
      }, n.prototype.register = function() {
        this.scene._beforeEvaluateActiveMeshStage.registerStep(we.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset), this.scene._preActiveMeshStage.registerStep(we.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER, this, this._preActiveMesh), this.scene._evaluateSubMeshStage.registerStep(we.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh), this.scene._afterRenderingGroupDrawStage.registerStep(we.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER, this, this.render);
      }, n.prototype._evaluateSubMesh = function(t, e) {
        if (t.showSubMeshesBoundingBox) {
          var i = e.getBoundingInfo();
          i != null && (i.boundingBox._tag = t.renderingGroupId, this.renderList.push(i.boundingBox));
        }
      }, n.prototype._preActiveMesh = function(t) {
        if (t.showBoundingBox || this.scene.forceShowBoundingBoxes) {
          var e = t.getBoundingInfo();
          e.boundingBox._tag = t.renderingGroupId, this.renderList.push(e.boundingBox);
        }
      }, n.prototype._prepareResources = function() {
        if (!this._colorShader) {
          this._colorShader = new dr("colorShader", this.scene, "boundingBoxRenderer", { attributes: [P.PositionKind], uniforms: ["world", "viewProjection", "viewProjectionR", "color"], uniformBuffers: ["BoundingBoxRenderer"] }, !1), this._colorShader.doNotSerialize = !0, this._colorShader.reservedDataStore = { hidden: !0 }, this._colorShaderForOcclusionQuery = new dr("colorShaderOccQuery", this.scene, "boundingBoxRenderer", { attributes: [P.PositionKind], uniforms: ["world", "viewProjection", "viewProjectionR", "color"], uniformBuffers: ["BoundingBoxRenderer"] }, !0), this._colorShaderForOcclusionQuery.doNotSerialize = !0, this._colorShaderForOcclusionQuery.reservedDataStore = { hidden: !0 };
          var t = this.scene.getEngine(), e = yh({ size: 1 });
          this._vertexBuffers[P.PositionKind] = new P(t, e.positions, P.PositionKind, !1), this._createIndexBuffer(), this._fillIndexData = e.indices, this.onResourcesReadyObservable.notifyObservers(this);
        }
      }, n.prototype._createIndexBuffer = function() {
        var t = this.scene.getEngine();
        this._indexBuffer = t.createIndexBuffer([0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 7, 1, 6, 2, 5, 3, 4]);
      }, n.prototype.rebuild = function() {
        var t = this._vertexBuffers[P.PositionKind];
        t && t._rebuild(), this._createIndexBuffer();
      }, n.prototype.reset = function() {
        this.renderList.reset();
      }, n.prototype.render = function(t) {
        var e, i;
        if (this.renderList.length !== 0 && this.enabled && (this._prepareResources(), this._colorShader.isReady())) {
          var r = this.scene.getEngine();
          r.setDepthWrite(!1);
          for (var o = this.scene.getTransformMatrix(), a = 0; a < this.renderList.length; a++) {
            var s = this.renderList.data[a];
            if (s._tag === t) {
              this._createWrappersForBoundingBox(s), this.onBeforeBoxRenderingObservable.notifyObservers(s);
              var l = s.minimum, c = s.maximum.subtract(l), u = l.add(c.scale(0.5)), h = B.Scaling(c.x, c.y, c.z).multiply(B.Translation(u.x, u.y, u.z)).multiply(s.getWorldMatrix()), d = r.useReverseDepthBuffer;
              if (this.showBackLines) {
                var p = (e = s._drawWrapperBack) !== null && e !== void 0 ? e : this._colorShader._getDrawWrapper();
                this._colorShader._preBind(p), r.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect()), d ? r.setDepthFunctionToLessOrEqual() : r.setDepthFunctionToGreaterOrEqual(), this._uniformBufferBack.bindToEffect(p.effect, "BoundingBoxRenderer"), this._uniformBufferBack.updateColor4("color", this.backColor, 1), this._uniformBufferBack.updateMatrix("world", h), this._uniformBufferBack.updateMatrix("viewProjection", o), this._uniformBufferBack.update(), r.drawElementsType(Et.LineListDrawMode, 0, 24);
              }
              var f = (i = s._drawWrapperFront) !== null && i !== void 0 ? i : this._colorShader._getDrawWrapper();
              this._colorShader._preBind(f), r.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect()), d ? r.setDepthFunctionToGreater() : r.setDepthFunctionToLess(), this._uniformBufferFront.bindToEffect(f.effect, "BoundingBoxRenderer"), this._uniformBufferFront.updateColor4("color", this.frontColor, 1), this._uniformBufferFront.updateMatrix("world", h), this._uniformBufferFront.updateMatrix("viewProjection", o), this._uniformBufferFront.update(), r.drawElementsType(Et.LineListDrawMode, 0, 24), this.onAfterBoxRenderingObservable.notifyObservers(s);
            }
          }
          this._colorShader.unbind(), r.setDepthFunctionToLessOrEqual(), r.setDepthWrite(!0);
        }
      }, n.prototype._createWrappersForBoundingBox = function(t) {
        if (!t._drawWrapperFront) {
          var e = this.scene.getEngine();
          t._drawWrapperFront = new Ei(e), t._drawWrapperBack = new Ei(e), t._drawWrapperFront.setEffect(this._colorShader.getEffect()), t._drawWrapperBack.setEffect(this._colorShader.getEffect());
        }
      }, n.prototype.renderOcclusionBoundingBox = function(t) {
        var e = this.scene.getEngine();
        this._renderPassIdForOcclusionQuery === void 0 && (this._renderPassIdForOcclusionQuery = e.createRenderPassId("Render pass for occlusion query"));
        var i = e.currentRenderPassId;
        e.currentRenderPassId = this._renderPassIdForOcclusionQuery, this._prepareResources();
        var r = t.subMeshes[0];
        if (this._colorShaderForOcclusionQuery.isReady(t, void 0, r) && t.hasBoundingInfo) {
          this._fillIndexBuffer || (this._fillIndexBuffer = e.createIndexBuffer(this._fillIndexData));
          var o = e.useReverseDepthBuffer;
          e.setDepthWrite(!1), e.setColorWrite(!1);
          var a = t.getBoundingInfo().boundingBox, s = a.minimum, l = a.maximum.subtract(s), c = s.add(l.scale(0.5)), u = B.Scaling(l.x, l.y, l.z).multiply(B.Translation(c.x, c.y, c.z)).multiply(a.getWorldMatrix()), h = r._drawWrapper;
          this._colorShaderForOcclusionQuery._preBind(h), e.bindBuffers(this._vertexBuffers, this._fillIndexBuffer, h.effect), o ? e.setDepthFunctionToGreater() : e.setDepthFunctionToLess(), this.scene.resetCachedMaterial(), this._uniformBufferFront.bindToEffect(h.effect, "BoundingBoxRenderer"), this._uniformBufferFront.updateMatrix("world", u), this._uniformBufferFront.updateMatrix("viewProjection", this.scene.getTransformMatrix()), this._uniformBufferFront.update(), e.drawElementsType(Et.TriangleFillMode, 0, 36), this._colorShaderForOcclusionQuery.unbind(), e.setDepthFunctionToLessOrEqual(), e.setDepthWrite(!0), e.setColorWrite(!0), e.currentRenderPassId = i;
        } else
          e.currentRenderPassId = i;
      }, n.prototype.dispose = function() {
        if (this._renderPassIdForOcclusionQuery !== void 0 && (this.scene.getEngine().releaseRenderPassId(this._renderPassIdForOcclusionQuery), this._renderPassIdForOcclusionQuery = void 0), this._colorShader) {
          this.onBeforeBoxRenderingObservable.clear(), this.onAfterBoxRenderingObservable.clear(), this.onResourcesReadyObservable.clear(), this.renderList.dispose(), this._colorShader.dispose(), this._colorShaderForOcclusionQuery.dispose(), this._uniformBufferFront.dispose(), this._uniformBufferBack.dispose();
          var t = this._vertexBuffers[P.PositionKind];
          t && (t.dispose(), this._vertexBuffers[P.PositionKind] = null), this.scene.getEngine()._releaseBuffer(this._indexBuffer), this._fillIndexBuffer && (this.scene.getEngine()._releaseBuffer(this._fillIndexBuffer), this._fillIndexBuffer = null);
        }
      }, n;
    }();
    Ue.prototype.enableDepthRenderer = function(n, t, e, i, r) {
      if (t === void 0 && (t = !1), e === void 0 && (e = !1), i === void 0 && (i = _.TEXTURE_TRILINEAR_SAMPLINGMODE), r === void 0 && (r = !1), !(n = n || this.activeCamera))
        throw "No camera available to enable depth renderer";
      if (this._depthRenderer || (this._depthRenderer = {}), !this._depthRenderer[n.id]) {
        var o, a = !!this.getEngine().getCaps().textureFloatRender;
        o = !this.getEngine().getCaps().textureHalfFloatRender || e && a ? a ? _.TEXTURETYPE_FLOAT : _.TEXTURETYPE_UNSIGNED_BYTE : _.TEXTURETYPE_HALF_FLOAT, this._depthRenderer[n.id] = new tu(this, o, n, t, i, r);
      }
      return this._depthRenderer[n.id];
    }, Ue.prototype.disableDepthRenderer = function(n) {
      (n = n || this.activeCamera) && this._depthRenderer && this._depthRenderer[n.id] && this._depthRenderer[n.id].dispose();
    };
    var mE = function() {
      function n(t) {
        this.name = we.NAME_DEPTHRENDERER, this.scene = t;
      }
      return n.prototype.register = function() {
        this.scene._gatherRenderTargetsStage.registerStep(we.STEP_GATHERRENDERTARGETS_DEPTHRENDERER, this, this._gatherRenderTargets), this.scene._gatherActiveCameraRenderTargetsStage.registerStep(we.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER, this, this._gatherActiveCameraRenderTargets);
      }, n.prototype.rebuild = function() {
      }, n.prototype.dispose = function() {
        for (var t in this.scene._depthRenderer)
          this.scene._depthRenderer[t].dispose();
      }, n.prototype._gatherRenderTargets = function(t) {
        if (this.scene._depthRenderer)
          for (var e in this.scene._depthRenderer) {
            var i = this.scene._depthRenderer[e];
            i.enabled && !i.useOnlyInActiveCamera && t.push(i.getDepthMap());
          }
      }, n.prototype._gatherActiveCameraRenderTargets = function(t) {
        if (this.scene._depthRenderer)
          for (var e in this.scene._depthRenderer) {
            var i = this.scene._depthRenderer[e];
            i.enabled && i.useOnlyInActiveCamera && this.scene.activeCamera.id === e && t.push(i.getDepthMap());
          }
      }, n;
    }();
    tu._SceneComponentInitialization = function(n) {
      var t = n._getComponent(we.NAME_DEPTHRENDERER);
      t || (t = new mE(n), n._addComponent(t));
    }, re.ShadersStore.oitFinalPixelShader = `precision highp float;uniform sampler2D uFrontColor;uniform sampler2D uBackColor;void main() {ivec2 fragCoord=ivec2(gl_FragCoord.xy);vec4 frontColor=texelFetch(uFrontColor,fragCoord,0);vec4 backColor=texelFetch(uBackColor,fragCoord,0);float alphaMultiplier=1.0-frontColor.a;glFragColor=vec4(
frontColor.rgb+alphaMultiplier*backColor.rgb,
frontColor.a+backColor.a
);}`, re.ShadersStore.oitBackBlendPixelShader = `precision highp float;uniform sampler2D uBackColor;void main() {glFragColor=texelFetch(uBackColor,ivec2(gl_FragCoord.xy),0);if (glFragColor.a==0.0) { 
discard;}}`;
    var CN = function() {
      this.enabled = !0, this.name = "depthPeeling", this.texturesRequired = [_.PREPASS_COLOR_TEXTURE_TYPE];
    }, gE = function() {
      function n(t, e) {
        if (e === void 0 && (e = 5), this._thinTextures = [], this._currentPingPongState = 0, this._layoutCacheFormat = [[!0], [!0, !0], [!0, !0, !0]], this._layoutCache = [], this._candidateSubMeshes = new en(10), this._excludedSubMeshes = new en(10), this._excludedMeshes = [], this._colorCache = [new Ie(n._DEPTH_CLEAR_VALUE, n._DEPTH_CLEAR_VALUE, 0, 0), new Ie(-n._MIN_DEPTH, n._MAX_DEPTH, 0, 0), new Ie(0, 0, 0, 0)], this._scene = t, this._engine = t.getEngine(), this._passCount = e, t.enablePrePassRenderer()) {
          for (var i = 0; i < this._layoutCacheFormat.length; ++i)
            this._layoutCache[i] = this._engine.buildTextureLayout(this._layoutCacheFormat[i]);
          this._renderPassIds = [], this.useRenderPasses = !1, this._prePassEffectConfiguration = new CN(), this._createTextures(), this._createEffects();
        } else
          q.Warn("Depth peeling for order independant transparency could not enable PrePass, aborting.");
      }
      return Object.defineProperty(n.prototype, "passCount", { get: function() {
        return this._passCount;
      }, set: function(t) {
        this._passCount !== t && (this._passCount = t, this._createRenderPassIds());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "useRenderPasses", { get: function() {
        return this._useRenderPasses;
      }, set: function(t) {
        this._useRenderPasses !== t && (this._useRenderPasses = t, this._createRenderPassIds());
      }, enumerable: !1, configurable: !0 }), n.prototype.addExcludedMesh = function(t) {
        this._excludedMeshes.indexOf(t.uniqueId) === -1 && this._excludedMeshes.push(t.uniqueId);
      }, n.prototype.removeExcludedMesh = function(t) {
        var e = this._excludedMeshes.indexOf(t.uniqueId);
        e !== -1 && this._excludedMeshes.splice(e, 1);
      }, n.prototype._createRenderPassIds = function() {
        if (this._releaseRenderPassIds(), this._useRenderPasses)
          for (var t = 0; t < this._passCount + 1; ++t)
            this._renderPassIds[t] || (this._renderPassIds[t] = this._engine.createRenderPassId("DepthPeelingRenderer - pass #".concat(t)));
      }, n.prototype._releaseRenderPassIds = function() {
        for (var t = 0; t < this._renderPassIds.length; ++t)
          this._engine.releaseRenderPassId(this._renderPassIds[t]);
        this._renderPassIds = [];
      }, n.prototype._createTextures = function() {
        var t = { width: this._engine.getRenderWidth(), height: this._engine.getRenderHeight() };
        this._depthMrts = [new Ja("depthPeelingDepth0MRT", t, 3, this._scene, void 0, ["depthPeelingDepth0MRT_depth", "depthPeelingDepth0MRT_frontColor", "depthPeelingDepth0MRT_backColor"]), new Ja("depthPeelingDepth1MRT", t, 3, this._scene, void 0, ["depthPeelingDepth1MRT_depth", "depthPeelingDepth1MRT_frontColor", "depthPeelingDepth1MRT_backColor"])], this._colorMrts = [new Ja("depthPeelingColor0MRT", t, 2, this._scene, { generateDepthBuffer: !1 }, ["depthPeelingColor0MRT_frontColor", "depthPeelingColor0MRT_backColor"]), new Ja("depthPeelingColor1MRT", t, 2, this._scene, { generateDepthBuffer: !1 }, ["depthPeelingColor1MRT_frontColor", "depthPeelingColor1MRT_backColor"])], this._blendBackMrt = new Ja("depthPeelingBackMRT", t, 1, this._scene, { generateDepthBuffer: !1 }, ["depthPeelingBackMRT_blendBack"]), this._outputRT = new Mi("depthPeelingOutputRTT", t, this._scene, !1);
        for (var e = [{ format: _.TEXTUREFORMAT_RG, samplingMode: _.TEXTURE_NEAREST_SAMPLINGMODE, type: this._engine.getCaps().textureFloatLinearFiltering ? _.TEXTURETYPE_FLOAT : _.TEXTURETYPE_HALF_FLOAT, label: "DepthPeelingRenderer-DepthTexture" }, { format: _.TEXTUREFORMAT_RGBA, samplingMode: _.TEXTURE_NEAREST_SAMPLINGMODE, type: _.TEXTURETYPE_HALF_FLOAT, label: "DepthPeelingRenderer-ColorTexture" }], i = 0; i < 2; i++) {
          var r = this._engine._createInternalTexture(t, e[0], !1), o = this._engine._createInternalTexture(t, e[1], !1), a = this._engine._createInternalTexture(t, e[1], !1);
          this._depthMrts[i].setInternalTexture(r, 0), this._depthMrts[i].setInternalTexture(o, 1), this._depthMrts[i].setInternalTexture(a, 2), this._colorMrts[i].setInternalTexture(o, 0), this._colorMrts[i].setInternalTexture(a, 1), this._thinTextures.push(new ms(r), new ms(o), new ms(a));
        }
      }, n.prototype._disposeTextures = function() {
        for (var t = 0; t < this._thinTextures.length; t++)
          t !== 6 && this._thinTextures[t].dispose();
        for (t = 0; t < 2; t++)
          this._depthMrts[t].dispose(!0), this._colorMrts[t].dispose(!0), this._blendBackMrt.dispose(!0);
        this._outputRT.dispose(), this._thinTextures = [], this._colorMrts = [], this._depthMrts = [];
      }, n.prototype._updateTextures = function() {
        return this._depthMrts[0].getSize().width === this._engine.getRenderWidth() && this._depthMrts[0].getSize().height === this._engine.getRenderHeight() || (this._disposeTextures(), this._createTextures()), this._updateTextureReferences();
      }, n.prototype._updateTextureReferences = function() {
        var t, e = this._scene.prePassRenderer;
        if (!e)
          return !1;
        var i = e.getIndex(_.PREPASS_COLOR_TEXTURE_TYPE), r = !((t = e.defaultRT.textures) === null || t === void 0) && t.length ? e.defaultRT.textures[i].getInternalTexture() : null;
        return !!r && (this._blendBackTexture !== r && (this._blendBackTexture = r, this._blendBackMrt.setInternalTexture(this._blendBackTexture, 0), this._thinTextures[6] && this._thinTextures[6].dispose(), this._thinTextures[6] = new ms(this._blendBackTexture), e.defaultRT.renderTarget._shareDepth(this._depthMrts[0].renderTarget)), !0);
      }, n.prototype._createEffects = function() {
        this._blendBackEffectWrapper = new Io({ fragmentShader: "oitBackBlend", useShaderStore: !0, engine: this._engine, samplerNames: ["uBackColor"], uniformNames: [] }), this._blendBackEffectWrapperPingPong = new Io({ fragmentShader: "oitBackBlend", useShaderStore: !0, engine: this._engine, samplerNames: ["uBackColor"], uniformNames: [] }), this._finalEffectWrapper = new Io({ fragmentShader: "oitFinal", useShaderStore: !0, engine: this._engine, samplerNames: ["uFrontColor", "uBackColor"], uniformNames: [] }), this._effectRenderer = new _c(this._engine);
      }, n.prototype.setPrePassRenderer = function(t) {
        t.addEffectConfiguration(this._prePassEffectConfiguration);
      }, n.prototype.bind = function(t) {
        t.setTexture("oitDepthSampler", this._thinTextures[3 * this._currentPingPongState]), t.setTexture("oitFrontColorSampler", this._thinTextures[3 * this._currentPingPongState + 1]);
      }, n.prototype._renderSubMeshes = function(t) {
        var e;
        this._useRenderPasses && (e = {});
        for (var i = 0; i < t.length; i++) {
          var r = t.data[i].getMaterial(), o = !0, a = !1, s = t.data[i], l = void 0, c = !1;
          if (this._useRenderPasses && (c = !(l = s._getDrawWrapper())), r && (o = r.allowShaderHotSwapping, a = r.backFaceCulling, r.allowShaderHotSwapping = !1, r.backFaceCulling = !1), s.render(!1), c && (l = s._getDrawWrapper()).materialContext) {
            var u = e[l.materialContext.uniqueId];
            u || (u = e[l.materialContext.uniqueId] = this._engine.createMaterialContext()), s._getDrawWrapper().materialContext = u;
          }
          r && (r.allowShaderHotSwapping = o, r.backFaceCulling = a);
        }
      }, n.prototype._finalCompose = function(t) {
        var e;
        !((e = this._scene.prePassRenderer) === null || e === void 0) && e.setCustomOutput(this._outputRT) ? this._engine.bindFramebuffer(this._outputRT.renderTarget) : this._engine.restoreDefaultFramebuffer(), this._engine.setAlphaMode(_.ALPHA_DISABLE), this._engine.applyStates(), this._engine.enableEffect(this._finalEffectWrapper._drawWrapper), this._finalEffectWrapper.effect.setTexture("uFrontColor", this._thinTextures[3 * t + 1]), this._finalEffectWrapper.effect.setTexture("uBackColor", this._thinTextures[6]), this._effectRenderer.render(this._finalEffectWrapper);
      }, n.prototype.isReady = function() {
        return this._blendBackEffectWrapper.effect.isReady() && this._blendBackEffectWrapperPingPong.effect.isReady() && this._finalEffectWrapper.effect.isReady() && this._updateTextures();
      }, n.prototype.render = function(t) {
        if (this._candidateSubMeshes.length = 0, this._excludedSubMeshes.length = 0, !this.isReady())
          return this._excludedSubMeshes;
        this._scene.activeCamera && this._engine.setViewport(this._scene.activeCamera.viewport);
        for (var e = 0; e < t.length; e++) {
          var i = t.data[e], r = i.getMaterial(), o = r && i.getRenderingMesh()._getRenderingFillMode(r.fillMode);
          !r || o !== Et.TriangleFanDrawMode && o !== Et.TriangleFillMode && o !== Et.TriangleStripDrawMode || this._excludedMeshes.indexOf(i.getMesh().uniqueId) !== -1 ? this._excludedSubMeshes.push(i) : this._candidateSubMeshes.push(i);
        }
        if (!this._candidateSubMeshes.length)
          return this._engine.bindFramebuffer(this._colorMrts[1].renderTarget), this._engine.bindAttachments(this._layoutCache[1]), this._engine.clear(this._colorCache[2], !0, !1, !1), this._engine.unBindFramebuffer(this._colorMrts[1].renderTarget), this._finalCompose(1), this._excludedSubMeshes;
        var a = this._engine.currentRenderPassId;
        this._scene.prePassRenderer._enabled = !1, this._useRenderPasses && (this._engine.currentRenderPassId = this._renderPassIds[0]), this._engine.bindFramebuffer(this._depthMrts[0].renderTarget), this._engine.bindAttachments(this._layoutCache[0]), this._engine.clear(this._colorCache[0], !0, !1, !1), this._engine.unBindFramebuffer(this._depthMrts[0].renderTarget), this._engine.bindFramebuffer(this._depthMrts[1].renderTarget), this._engine.bindAttachments(this._layoutCache[0]), this._engine.clear(this._colorCache[1], !0, !1, !1), this._engine.unBindFramebuffer(this._depthMrts[1].renderTarget), this._engine.bindFramebuffer(this._colorMrts[0].renderTarget), this._engine.bindAttachments(this._layoutCache[1]), this._engine.clear(this._colorCache[2], !0, !1, !1), this._engine.unBindFramebuffer(this._colorMrts[0].renderTarget), this._engine.bindFramebuffer(this._colorMrts[1].renderTarget), this._engine.bindAttachments(this._layoutCache[1]), this._engine.clear(this._colorCache[2], !0, !1, !1), this._engine.unBindFramebuffer(this._colorMrts[1].renderTarget), this._engine.bindFramebuffer(this._depthMrts[0].renderTarget), this._engine.bindAttachments(this._layoutCache[0]), this._engine.setAlphaMode(_.ALPHA_ONEONE_ONEONE), this._engine.setAlphaEquation(_.ALPHA_EQUATION_MAX), this._engine.depthCullingState.depthMask = !1, this._engine.depthCullingState.depthTest = !0, this._engine.applyStates(), this._currentPingPongState = 1, this._renderSubMeshes(this._candidateSubMeshes), this._engine.unBindFramebuffer(this._depthMrts[0].renderTarget), this._scene.resetCachedMaterial();
        var s = 0, l = 0;
        for (e = 0; e < this._passCount; e++) {
          l = 1 - (s = e % 2), this._currentPingPongState = s, this._useRenderPasses && (this._engine.currentRenderPassId = this._renderPassIds[e + 1]), this._scene.activeCamera && this._engine.setViewport(this._scene.activeCamera.viewport), this._engine.bindFramebuffer(this._depthMrts[l].renderTarget), this._engine.bindAttachments(this._layoutCache[0]), this._engine.clear(this._colorCache[0], !0, !1, !1), this._engine.unBindFramebuffer(this._depthMrts[l].renderTarget), this._engine.bindFramebuffer(this._colorMrts[l].renderTarget), this._engine.bindAttachments(this._layoutCache[1]), this._engine.clear(this._colorCache[2], !0, !1, !1), this._engine.unBindFramebuffer(this._colorMrts[l].renderTarget), this._engine.bindFramebuffer(this._depthMrts[l].renderTarget), this._engine.bindAttachments(this._layoutCache[2]), this._engine.setAlphaMode(_.ALPHA_ONEONE_ONEONE), this._engine.setAlphaEquation(_.ALPHA_EQUATION_MAX), this._engine.depthCullingState.depthTest = !1, this._engine.applyStates(), this._renderSubMeshes(this._candidateSubMeshes), this._engine.unBindFramebuffer(this._depthMrts[l].renderTarget), this._scene.resetCachedMaterial(), this._engine.bindFramebuffer(this._blendBackMrt.renderTarget), this._engine.bindAttachments(this._layoutCache[0]), this._engine.setAlphaEquation(_.ALPHA_EQUATION_ADD), this._engine.setAlphaMode(_.ALPHA_LAYER_ACCUMULATE), this._engine.applyStates();
          var c = l !== 0 && this._useRenderPasses ? this._blendBackEffectWrapperPingPong : this._blendBackEffectWrapper;
          this._engine.enableEffect(c._drawWrapper), c.effect.setTexture("uBackColor", this._thinTextures[3 * l + 2]), this._effectRenderer.render(c), this._engine.unBindFramebuffer(this._blendBackMrt.renderTarget);
        }
        return this._engine.currentRenderPassId = a, this._finalCompose(l), this._scene.prePassRenderer._enabled = !0, this._engine.depthCullingState.depthMask = !0, this._engine.depthCullingState.depthTest = !0, this._excludedSubMeshes;
      }, n.prototype.dispose = function() {
        this._disposeTextures(), this._blendBackEffectWrapper.dispose(), this._finalEffectWrapper.dispose(), this._effectRenderer.dispose(), this._releaseRenderPassIds();
      }, n._DEPTH_CLEAR_VALUE = -99999, n._MIN_DEPTH = 0, n._MAX_DEPTH = 1, n;
    }();
    Object.defineProperty(Ue.prototype, "depthPeelingRenderer", { get: function() {
      if (!this._depthPeelingRenderer) {
        var n = this._getComponent(we.NAME_DEPTHPEELINGRENDERER);
        n || (n = new vE(this), this._addComponent(n));
      }
      return this._depthPeelingRenderer;
    }, set: function(n) {
      this._depthPeelingRenderer = n;
    }, enumerable: !0, configurable: !0 }), Object.defineProperty(Ue.prototype, "useOrderIndependentTransparency", { get: function() {
      return this._useOrderIndependentTransparency;
    }, set: function(n) {
      var t;
      this._useOrderIndependentTransparency !== n && (this._useOrderIndependentTransparency = n, this.markAllMaterialsAsDirty(_.MATERIAL_AllDirtyFlag), (t = this.prePassRenderer) === null || t === void 0 || t.markAsDirty());
    }, enumerable: !0, configurable: !0 });
    var vE = function() {
      function n(t) {
        this.name = we.NAME_DEPTHPEELINGRENDERER, this.scene = t, t.depthPeelingRenderer = new gE(t);
      }
      return n.prototype.register = function() {
      }, n.prototype.rebuild = function() {
      }, n.prototype.dispose = function() {
        var t;
        (t = this.scene.depthPeelingRenderer) === null || t === void 0 || t.dispose(), this.scene.depthPeelingRenderer = null;
      }, n;
    }();
    re.ShadersStore.linePixelShader = `#include<clipPlaneFragmentDeclaration>
uniform vec4 color;
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void) {
#define CUSTOM_FRAGMENT_MAIN_BEGIN
#include<clipPlaneFragment>
gl_FragColor=color;
#define CUSTOM_FRAGMENT_MAIN_END
}`, re.ShadersStore.lineVertexShader = `#include<instancesDeclaration>
#include<clipPlaneVertexDeclaration>
attribute vec3 position;attribute vec4 normal;uniform mat4 viewProjection;uniform float width;uniform float aspectRatio;
#define CUSTOM_VERTEX_DEFINITIONS
void main(void) {
#define CUSTOM_VERTEX_MAIN_BEGIN
#include<instancesVertex>
mat4 worldViewProjection=viewProjection*finalWorld;vec4 viewPosition=worldViewProjection*vec4(position,1.0);vec4 viewPositionNext=worldViewProjection*vec4(normal.xyz,1.0);vec2 currentScreen=viewPosition.xy/viewPosition.w;vec2 nextScreen=viewPositionNext.xy/viewPositionNext.w;currentScreen.x*=aspectRatio;nextScreen.x*=aspectRatio;vec2 dir=normalize(nextScreen-currentScreen);vec2 normalDir=vec2(-dir.y,dir.x);normalDir*=width/2.0;normalDir.x/=aspectRatio;vec4 offset=vec4(normalDir*normal.w,0.0,0.0);gl_Position=viewPosition+offset;
#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
vec4 worldPos=finalWorld*vec4(position,1.0);
#include<clipPlaneVertex>
#endif
#define CUSTOM_VERTEX_MAIN_END
}`, Dt.prototype.disableEdgesRendering = function() {
      return this._edgesRenderer && (this._edgesRenderer.dispose(), this._edgesRenderer = null), this;
    }, Dt.prototype.enableEdgesRendering = function(n, t, e) {
      return n === void 0 && (n = 0.95), t === void 0 && (t = !1), this.disableEdgesRendering(), this._edgesRenderer = new fm(this, n, t, !0, e), this;
    }, Object.defineProperty(Dt.prototype, "edgesRenderer", { get: function() {
      return this._edgesRenderer;
    }, enumerable: !0, configurable: !0 }), El.prototype.enableEdgesRendering = function(n, t) {
      return n === void 0 && (n = 0.95), t === void 0 && (t = !1), this.disableEdgesRendering(), this._edgesRenderer = new yE(this, n, t), this;
    }, Rf.prototype.enableEdgesRendering = function(n, t) {
      return n === void 0 && (n = 0.95), t === void 0 && (t = !1), El.prototype.enableEdgesRendering.apply(this, arguments), this;
    };
    var PN = function() {
      this.edges = [], this.edgesConnectedCount = 0;
    }, fm = function() {
      function n(t, e, i, r, o) {
        e === void 0 && (e = 0.95), i === void 0 && (i = !1), r === void 0 && (r = !0);
        var a, s = this;
        this.edgesWidthScalerForOrthographic = 1e3, this.edgesWidthScalerForPerspective = 50, this._linesPositions = new Array(), this._linesNormals = new Array(), this._linesIndices = new Array(), this._buffers = {}, this._buffersForInstances = {}, this._checkVerticesInsteadOfIndices = !1, this.isEnabled = !0, this.customInstances = new en(32), this._source = t, this._checkVerticesInsteadOfIndices = i, this._options = o ?? null, this._epsilon = e, this._source.getScene().getEngine().isWebGPU && (this._drawWrapper = new Ei(t.getEngine())), this._prepareRessources(), r && ((a = o == null ? void 0 : o.useAlternateEdgeFinder) === null || a === void 0 || a ? this._generateEdgesLinesAlternate() : this._generateEdgesLines()), this._meshRebuildObserver = this._source.onRebuildObservable.add(function() {
          s._rebuild();
        }), this._meshDisposeObserver = this._source.onDisposeObservable.add(function() {
          s.dispose();
        });
      }
      return Object.defineProperty(n.prototype, "linesPositions", { get: function() {
        return this._linesPositions;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "linesNormals", { get: function() {
        return this._linesNormals;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "linesIndices", { get: function() {
        return this._linesIndices;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "lineShader", { get: function() {
        return this._lineShader;
      }, set: function(t) {
        this._lineShader = t;
      }, enumerable: !1, configurable: !0 }), n._GetShader = function(t) {
        if (!t._edgeRenderLineShader) {
          var e = new dr("lineShader", t, "line", { attributes: ["position", "normal"], uniforms: ["world", "viewProjection", "color", "width", "aspectRatio"] }, !1);
          e.disableDepthWrite = !0, e.backFaceCulling = !1, e.checkReadyOnEveryCall = t.getEngine().isWebGPU, t._edgeRenderLineShader = e;
        }
        return t._edgeRenderLineShader;
      }, n.prototype._prepareRessources = function() {
        this._lineShader || (this._lineShader = n._GetShader(this._source.getScene()));
      }, n.prototype._rebuild = function() {
        var t = this._buffers[P.PositionKind];
        t && t._rebuild(), (t = this._buffers[P.NormalKind]) && t._rebuild();
        var e = this._source.getScene().getEngine();
        this._ib = e.createIndexBuffer(this._linesIndices);
      }, n.prototype.dispose = function() {
        var t;
        this._source.onRebuildObservable.remove(this._meshRebuildObserver), this._source.onDisposeObservable.remove(this._meshDisposeObserver);
        var e = this._buffers[P.PositionKind];
        e && (e.dispose(), this._buffers[P.PositionKind] = null), (e = this._buffers[P.NormalKind]) && (e.dispose(), this._buffers[P.NormalKind] = null), this._ib && this._source.getScene().getEngine()._releaseBuffer(this._ib), this._lineShader.dispose(), (t = this._drawWrapper) === null || t === void 0 || t.dispose();
      }, n.prototype._processEdgeForAdjacencies = function(t, e, i, r, o) {
        return t === i && e === r || t === r && e === i ? 0 : t === r && e === o || t === o && e === r ? 1 : t === o && e === i || t === i && e === o ? 2 : -1;
      }, n.prototype._processEdgeForAdjacenciesWithVertices = function(t, e, i, r, o) {
        var a = 1e-10;
        return t.equalsWithEpsilon(i, a) && e.equalsWithEpsilon(r, a) || t.equalsWithEpsilon(r, a) && e.equalsWithEpsilon(i, a) ? 0 : t.equalsWithEpsilon(r, a) && e.equalsWithEpsilon(o, a) || t.equalsWithEpsilon(o, a) && e.equalsWithEpsilon(r, a) ? 1 : t.equalsWithEpsilon(o, a) && e.equalsWithEpsilon(i, a) || t.equalsWithEpsilon(i, a) && e.equalsWithEpsilon(o, a) ? 2 : -1;
      }, n.prototype._checkEdge = function(t, e, i, r, o) {
        (e === void 0 || v.Dot(i[t], i[e]) < this._epsilon) && this.createLine(r, o, this._linesPositions.length / 3);
      }, n.prototype.createLine = function(t, e, i) {
        this._linesPositions.push(t.x, t.y, t.z, t.x, t.y, t.z, e.x, e.y, e.z, e.x, e.y, e.z), this._linesNormals.push(e.x, e.y, e.z, -1, e.x, e.y, e.z, 1, t.x, t.y, t.z, -1, t.x, t.y, t.z, 1), this._linesIndices.push(i, i + 1, i + 2, i, i + 2, i + 3);
      }, n.prototype._tessellateTriangle = function(t, e, i, r) {
        var o = function(L, I, O) {
          O >= 0 && I.push(O);
          for (var w = 0; w < L.length; ++w)
            I.push(L[w][0]);
        }, a = 0;
        t[1].length >= t[0].length && t[1].length >= t[2].length ? a = 1 : t[2].length >= t[0].length && t[2].length >= t[1].length && (a = 2);
        for (var s = 0; s < 3; ++s)
          s === a ? t[s].sort(function(L, I) {
            return L[1] < I[1] ? -1 : L[1] > I[1] ? 1 : 0;
          }) : t[s].sort(function(L, I) {
            return L[1] > I[1] ? -1 : L[1] < I[1] ? 1 : 0;
          });
        var l = [], c = [];
        o(t[a], l, -1);
        for (var u = l.length, h = a + 2; h >= a + 1; --h)
          o(t[h % 3], c, h !== a + 2 ? r[i[e + (h + 1) % 3]] : -1);
        var d = c.length;
        i.push(r[i[e + a]], l[0], c[0]), i.push(r[i[e + (a + 1) % 3]], c[d - 1], l[u - 1]);
        for (var p = u <= d, f = p ? u : d, m = p ? d : u, g = p ? u - 1 : d - 1, y = p ? 0 : 1, b = u + d - 2, T = 0, S = 0, E = p ? l : c, A = p ? c : l, R = 0; b-- > 0; ) {
          y ? i.push(E[T], A[S]) : i.push(A[S], E[T]);
          var C = void 0;
          (R += f) >= m && T < g ? (C = E[++T], R -= m) : C = A[++S], i.push(C);
        }
        i[e + 0] = i[i.length - 3], i[e + 1] = i[i.length - 2], i[e + 2] = i[i.length - 1], i.length = i.length - 3;
      }, n.prototype._generateEdgesLinesAlternate = function() {
        var t, e, i, r, o, a, s, l, c, u, h = this._source.getVerticesData(P.PositionKind), d = this._source.getIndices();
        if (d && h) {
          Array.isArray(d) || (d = Array.from(d));
          var p = (e = (t = this._options) === null || t === void 0 ? void 0 : t.useFastVertexMerger) === null || e === void 0 || e, f = p ? Math.round(-Math.log((r = (i = this._options) === null || i === void 0 ? void 0 : i.epsilonVertexMerge) !== null && r !== void 0 ? r : 1e-6) / Math.log(10)) : (a = (o = this._options) === null || o === void 0 ? void 0 : o.epsilonVertexMerge) !== null && a !== void 0 ? a : 1e-6, m = [], g = [];
          if (p)
            for (var y = {}, b = 0; b < h.length; b += 3) {
              var T = h[b + 0], S = h[b + 1], E = h[b + 2];
              if (y[xt = T.toFixed(f) + "|" + S.toFixed(f) + "|" + E.toFixed(f)] !== void 0)
                m.push(y[xt]);
              else {
                var A = b / 3;
                y[xt] = A, m.push(A), g.push(A);
              }
            }
          else
            for (b = 0; b < h.length; b += 3) {
              T = h[b + 0], S = h[b + 1], E = h[b + 2];
              for (var R = !1, C = 0; C < b && !R; C += 3) {
                var L = h[C + 0], I = h[C + 1], O = h[C + 2];
                if (Math.abs(T - L) < f && Math.abs(S - I) < f && Math.abs(E - O) < f) {
                  m.push(C / 3), R = !0;
                  break;
                }
              }
              R || (m.push(b / 3), g.push(b / 3));
            }
          if (!((s = this._options) === null || s === void 0) && s.applyTessellation) {
            for (var w = (c = (l = this._options) === null || l === void 0 ? void 0 : l.epsilonVertexAligned) !== null && c !== void 0 ? c : 1e-6, z = [], V = 0; V < d.length; V += 3)
              for (var Y = void 0, ee = 0; ee < 3; ++ee) {
                var J = m[d[V + ee]], X = m[d[V + (ee + 1) % 3]], K = m[d[V + (ee + 2) % 3]];
                if (J !== X)
                  for (var te = h[3 * J + 0], se = h[3 * J + 1], _e = h[3 * J + 2], xe = h[3 * X + 0], Te = h[3 * X + 1], he = h[3 * X + 2], me = Math.sqrt((xe - te) * (xe - te) + (Te - se) * (Te - se) + (he - _e) * (he - _e)), Fe = 0; Fe < g.length - 1; Fe++) {
                    var Ce = g[Fe];
                    if (Ce !== J && Ce !== X && Ce !== K) {
                      var Re = h[3 * Ce + 0], Be = h[3 * Ce + 1], De = h[3 * Ce + 2], Ke = Math.sqrt((Re - te) * (Re - te) + (Be - se) * (Be - se) + (De - _e) * (De - _e)), ge = Math.sqrt((Re - xe) * (Re - xe) + (Be - Te) * (Be - Te) + (De - he) * (De - he));
                      Math.abs(Ke + ge - me) < w && (Y || (Y = { index: V, edgesPoints: [[], [], []] }, z.push(Y)), Y.edgesPoints[ee].push([Ce, Ke]));
                    }
                  }
              }
            for (var rt = 0; rt < z.length; ++rt) {
              var it = z[rt];
              this._tessellateTriangle(it.edgesPoints, it.index, d, m);
            }
            z.length = 0;
          }
          var He = {};
          for (V = 0; V < d.length; V += 3) {
            var Pt = void 0;
            for (ee = 0; ee < 3; ++ee)
              if (J = m[d[V + ee]], X = m[d[V + (ee + 1) % 3]], K = m[d[V + (ee + 2) % 3]], J !== X && (J !== K && X !== K || !(!((u = this._options) === null || u === void 0) && u.removeDegeneratedTriangles))) {
                if (F.Vector3[0].copyFromFloats(h[3 * J + 0], h[3 * J + 1], h[3 * J + 2]), F.Vector3[1].copyFromFloats(h[3 * X + 0], h[3 * X + 1], h[3 * X + 2]), F.Vector3[2].copyFromFloats(h[3 * K + 0], h[3 * K + 1], h[3 * K + 2]), Pt || (F.Vector3[1].subtractToRef(F.Vector3[0], F.Vector3[3]), F.Vector3[2].subtractToRef(F.Vector3[1], F.Vector3[4]), (Pt = v.Cross(F.Vector3[3], F.Vector3[4])).normalize()), J > X) {
                  var ke = J;
                  J = X, X = ke;
                }
                (Nt = He[xt = J + "_" + X]) ? Nt.done || (v.Dot(Pt, Nt.normal) < this._epsilon && this.createLine(F.Vector3[0], F.Vector3[1], this._linesPositions.length / 3), Nt.done = !0) : He[xt] = { normal: Pt, done: !1, index: V, i: ee };
              }
          }
          for (var xt in He) {
            var Nt;
            (Nt = He[xt]).done || (J = m[d[Nt.index + Nt.i]], X = m[d[Nt.index + (Nt.i + 1) % 3]], F.Vector3[0].copyFromFloats(h[3 * J + 0], h[3 * J + 1], h[3 * J + 2]), F.Vector3[1].copyFromFloats(h[3 * X + 0], h[3 * X + 1], h[3 * X + 2]), this.createLine(F.Vector3[0], F.Vector3[1], this._linesPositions.length / 3));
          }
          var $e = this._source.getScene().getEngine();
          this._buffers[P.PositionKind] = new P($e, this._linesPositions, P.PositionKind, !1), this._buffers[P.NormalKind] = new P($e, this._linesNormals, P.NormalKind, !1, !1, 4), this._buffersForInstances[P.PositionKind] = this._buffers[P.PositionKind], this._buffersForInstances[P.NormalKind] = this._buffers[P.NormalKind], this._ib = $e.createIndexBuffer(this._linesIndices), this._indicesCount = this._linesIndices.length;
        }
      }, n.prototype._generateEdgesLines = function() {
        var t = this._source.getVerticesData(P.PositionKind), e = this._source.getIndices();
        if (e && t) {
          var i, r, o = [], a = [];
          for (i = 0; i < e.length; i += 3) {
            r = new PN();
            var s = e[i], l = e[i + 1], c = e[i + 2];
            r.p0 = new v(t[3 * s], t[3 * s + 1], t[3 * s + 2]), r.p1 = new v(t[3 * l], t[3 * l + 1], t[3 * l + 2]), r.p2 = new v(t[3 * c], t[3 * c + 1], t[3 * c + 2]);
            var u = v.Cross(r.p1.subtract(r.p0), r.p2.subtract(r.p1));
            u.normalize(), a.push(u), o.push(r);
          }
          for (i = 0; i < o.length; i++) {
            r = o[i];
            for (var h = i + 1; h < o.length; h++) {
              var d = o[h];
              if (r.edgesConnectedCount === 3)
                break;
              if (d.edgesConnectedCount !== 3)
                for (var p = e[3 * h], f = e[3 * h + 1], m = e[3 * h + 2], g = 0; g < 3; g++) {
                  var y = 0;
                  if (r.edges[g] === void 0) {
                    switch (g) {
                      case 0:
                        y = this._checkVerticesInsteadOfIndices ? this._processEdgeForAdjacenciesWithVertices(r.p0, r.p1, d.p0, d.p1, d.p2) : this._processEdgeForAdjacencies(e[3 * i], e[3 * i + 1], p, f, m);
                        break;
                      case 1:
                        y = this._checkVerticesInsteadOfIndices ? this._processEdgeForAdjacenciesWithVertices(r.p1, r.p2, d.p0, d.p1, d.p2) : this._processEdgeForAdjacencies(e[3 * i + 1], e[3 * i + 2], p, f, m);
                        break;
                      case 2:
                        y = this._checkVerticesInsteadOfIndices ? this._processEdgeForAdjacenciesWithVertices(r.p2, r.p0, d.p0, d.p1, d.p2) : this._processEdgeForAdjacencies(e[3 * i + 2], e[3 * i], p, f, m);
                    }
                    if (y !== -1 && (r.edges[g] = h, d.edges[y] = i, r.edgesConnectedCount++, d.edgesConnectedCount++, r.edgesConnectedCount === 3))
                      break;
                  }
                }
            }
          }
          for (i = 0; i < o.length; i++) {
            var b = o[i];
            this._checkEdge(i, b.edges[0], a, b.p0, b.p1), this._checkEdge(i, b.edges[1], a, b.p1, b.p2), this._checkEdge(i, b.edges[2], a, b.p2, b.p0);
          }
          var T = this._source.getScene().getEngine();
          this._buffers[P.PositionKind] = new P(T, this._linesPositions, P.PositionKind, !1), this._buffers[P.NormalKind] = new P(T, this._linesNormals, P.NormalKind, !1, !1, 4), this._buffersForInstances[P.PositionKind] = this._buffers[P.PositionKind], this._buffersForInstances[P.NormalKind] = this._buffers[P.NormalKind], this._ib = T.createIndexBuffer(this._linesIndices), this._indicesCount = this._linesIndices.length;
        }
      }, n.prototype.isReady = function() {
        return this._lineShader.isReady(this._source, this._source.hasInstances && this.customInstances.length > 0 || this._source.hasThinInstances);
      }, n.prototype.render = function() {
        var t = this._source.getScene(), e = this._lineShader._getDrawWrapper();
        if (this._drawWrapper && this._lineShader._setDrawWrapper(this._drawWrapper), this.isReady() && t.activeCamera) {
          var i = this._source.hasInstances && this.customInstances.length > 0, r = i || this._source.hasThinInstances, o = 0;
          if (r)
            if (this._buffersForInstances.world0 = this._source.getVertexBuffer("world0"), this._buffersForInstances.world1 = this._source.getVertexBuffer("world1"), this._buffersForInstances.world2 = this._source.getVertexBuffer("world2"), this._buffersForInstances.world3 = this._source.getVertexBuffer("world3"), i) {
              var a = this._source._instanceDataStorage;
              if (o = this.customInstances.length, !a.instancesData)
                return void (this._source.getScene()._activeMeshesFrozen || this.customInstances.reset());
              if (!a.isFrozen) {
                for (var s = 0, l = 0; l < o; ++l)
                  this.customInstances.data[l].copyToArray(a.instancesData, s), s += 16;
                a.instancesBuffer.updateDirectly(a.instancesData, 0, o);
              }
            } else
              o = this._source.thinInstanceCount;
          var c = t.getEngine();
          this._lineShader._preBind(), this._source.edgesColor.a !== 1 ? c.setAlphaMode(_.ALPHA_COMBINE) : c.setAlphaMode(_.ALPHA_DISABLE), c.bindBuffers(r ? this._buffersForInstances : this._buffers, this._ib, this._lineShader.getEffect()), t.resetCachedMaterial(), this._lineShader.setColor4("color", this._source.edgesColor), t.activeCamera.mode === dt.ORTHOGRAPHIC_CAMERA ? this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForOrthographic) : this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForPerspective), this._lineShader.setFloat("aspectRatio", c.getAspectRatio(t.activeCamera)), this._lineShader.bind(this._source.getWorldMatrix()), c.drawElementsType(Et.TriangleFillMode, 0, this._indicesCount, o), this._lineShader.unbind(), r && c.unbindInstanceAttributes(), this._source.getScene()._activeMeshesFrozen || this.customInstances.reset(), this._lineShader._setDrawWrapper(e);
        } else
          this._lineShader._setDrawWrapper(e);
      }, n;
    }(), yE = function(n) {
      function t(e, i, r) {
        i === void 0 && (i = 0.95), r === void 0 && (r = !1);
        var o = n.call(this, e, i, r, !1) || this;
        return o._generateEdgesLines(), o;
      }
      return D(t, n), t.prototype._generateEdgesLines = function() {
        var e = this._source.getVerticesData(P.PositionKind), i = this._source.getIndices();
        if (i && e) {
          for (var r = F.Vector3[0], o = F.Vector3[1], a = i.length - 1, s = 0, l = 0; s < a; s += 2, l += 4)
            v.FromArrayToRef(e, 3 * i[s], r), v.FromArrayToRef(e, 3 * i[s + 1], o), this.createLine(r, o, l);
          var c = this._source.getScene().getEngine();
          this._buffers[P.PositionKind] = new P(c, this._linesPositions, P.PositionKind, !1), this._buffers[P.NormalKind] = new P(c, this._linesNormals, P.NormalKind, !1, !1, 4), this._ib = c.createIndexBuffer(this._linesIndices), this._indicesCount = this._linesIndices.length;
        }
      }, t;
    }(fm), IN = function(n) {
      function t(e, i, r, o, a, s) {
        var l = n.call(this, e, r, o, a, s) || this;
        return l._beforeCompositionPostProcesses = [], l._internalTextureDirty = !1, l.enabled = !1, l.renderTargetTexture = null, l.renderTargetTexture = i, l;
      }
      return D(t, n), t.prototype._createCompositionEffect = function() {
        this.imageProcessingPostProcess = new um("prePassComposition", 1, null, void 0, this._engine), this.imageProcessingPostProcess._updateParameters();
      }, t.prototype._checkSize = function() {
        var e = this._engine.getRenderWidth(!0), i = this._engine.getRenderHeight(!0), r = this.getRenderWidth(), o = this.getRenderHeight();
        r === e && o === i || (this.resize({ width: e, height: i }), this._internalTextureDirty = !0);
      }, t.prototype.updateCount = function(e, i, r) {
        n.prototype.updateCount.call(this, e, i, r), this._internalTextureDirty = !0;
      }, t.prototype._resetPostProcessChain = function() {
        this._beforeCompositionPostProcesses.length = 0;
      }, t.prototype.dispose = function() {
        var e = this._scene;
        if (n.prototype.dispose.call(this), e && e.prePassRenderer) {
          var i = e.prePassRenderer.renderTargets.indexOf(this);
          i !== -1 && e.prePassRenderer.renderTargets.splice(i, 1);
        }
        this.imageProcessingPostProcess && this.imageProcessingPostProcess.dispose(), this.renderTargetTexture && (this.renderTargetTexture._prePassRenderTarget = null), this._outputPostProcess && (this._outputPostProcess.autoClear = !0, this._outputPostProcess.restoreDefaultInputTexture());
      }, t;
    }(Ja), _m = function() {
      function n(t) {
        this.excludedSkinnedMesh = [], this.excludedMaterials = [], this.mrtCount = 0, this._mrtTypes = [], this._mrtFormats = [], this._mrtLayout = [], this._mrtNames = [], this._textureIndices = [], this._generateNormalsInWorldSpace = !1, this._useSpecificClearForDepthTexture = !1, this._isDirty = !0, this._effectConfigurations = [], this.doNotUseGeometryRendererFallback = !0, this.renderTargets = [], this._clearColor = new Ie(0, 0, 0, 0), this._clearDepthColor = new Ie(1e8, 0, 0, 1), this._enabled = !1, this._needsCompositionForThisPass = !1, this.disableGammaTransform = !1, this._scene = t, this._engine = t.getEngine();
        var e = _.TEXTURETYPE_UNSIGNED_BYTE;
        this._engine._caps.textureFloat && this._engine._caps.textureFloatLinearFiltering ? e = _.TEXTURETYPE_FLOAT : this._engine._caps.textureHalfFloat && this._engine._caps.textureHalfFloatLinearFiltering && (e = _.TEXTURETYPE_HALF_FLOAT);
        for (var i = 0; i < n.TextureFormats.length; ++i) {
          var r = n.TextureFormats[i].format;
          n.TextureFormats[i].type === _.TEXTURETYPE_FLOAT && (n.TextureFormats[_.PREPASS_DEPTH_TEXTURE_TYPE].type = e, r !== _.TEXTUREFORMAT_R && r !== _.TEXTUREFORMAT_RG && r !== _.TEXTUREFORMAT_RGBA || this._engine._caps.supportFloatTexturesResolve || (n.TextureFormats[_.PREPASS_DEPTH_TEXTURE_TYPE].type = _.TEXTURETYPE_HALF_FLOAT));
        }
        n._SceneComponentInitialization(this._scene), this.defaultRT = this._createRenderTarget("sceneprePassRT", null), this._currentTarget = this.defaultRT;
      }
      return Object.defineProperty(n.prototype, "generateNormalsInWorldSpace", { get: function() {
        return this._generateNormalsInWorldSpace;
      }, set: function(t) {
        this._generateNormalsInWorldSpace !== t && (this._generateNormalsInWorldSpace = t, this._markAllMaterialsAsPrePassDirty());
      }, enumerable: !1, configurable: !0 }), n.prototype.getIndex = function(t) {
        return this._textureIndices[t];
      }, Object.defineProperty(n.prototype, "samples", { get: function() {
        return this.defaultRT.samples;
      }, set: function(t) {
        this.defaultRT.samples = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "useSpecificClearForDepthTexture", { get: function() {
        return this._useSpecificClearForDepthTexture;
      }, set: function(t) {
        this._useSpecificClearForDepthTexture !== t && (this._useSpecificClearForDepthTexture = t, this._isDirty = !0);
      }, enumerable: !1, configurable: !0 }), n.prototype.getRenderTarget = function() {
        return this._currentTarget;
      }, n.prototype._setRenderTarget = function(t) {
        var e, i;
        t ? this._currentTarget = t : (this._currentTarget = this.defaultRT, this._engine.currentRenderPassId = (i = (e = this._scene.activeCamera) === null || e === void 0 ? void 0 : e.renderPassId) !== null && i !== void 0 ? i : this._currentTarget.renderPassId);
      }, Object.defineProperty(n.prototype, "currentRTisSceneRT", { get: function() {
        return this._currentTarget === this.defaultRT;
      }, enumerable: !1, configurable: !0 }), n.prototype._refreshGeometryBufferRendererLink = function() {
        if (this.doNotUseGeometryRendererFallback)
          this._geometryBuffer && this._geometryBuffer._unlinkPrePassRenderer(), this._geometryBuffer = null, this._scene.disableGeometryBufferRenderer();
        else {
          if (this._geometryBuffer = this._scene.enableGeometryBufferRenderer(), !this._geometryBuffer)
            return void (this.doNotUseGeometryRendererFallback = !0);
          this._geometryBuffer._linkPrePassRenderer(this);
        }
      }, Object.defineProperty(n.prototype, "enabled", { get: function() {
        return this._enabled;
      }, enumerable: !1, configurable: !0 }), n.prototype._createRenderTarget = function(t, e) {
        var i = new IN(t, e, { width: this._engine.getRenderWidth(), height: this._engine.getRenderHeight() }, 0, this._scene, { generateMipMaps: !1, generateStencilBuffer: this._engine.isStencilEnable, defaultType: _.TEXTURETYPE_UNSIGNED_INT, types: [], drawOnlyOnFirstAttachmentByDefault: !0 });
        return this.renderTargets.push(i), this._enabled && this._update(), i;
      }, Object.defineProperty(n.prototype, "isSupported", { get: function() {
        return this._scene.getEngine().getCaps().drawBuffersExtension;
      }, enumerable: !1, configurable: !0 }), n.prototype.bindAttachmentsForEffect = function(t, e) {
        var i = e.getMaterial(), r = i && i.isPrePassCapable, o = i && this.excludedMaterials.indexOf(i) !== -1;
        this.enabled && this._currentTarget.enabled && (t._multiTarget && r && !o ? this._engine.bindAttachments(this._multiRenderAttachments) : (this._engine._currentRenderTarget ? this._engine.bindAttachments(this._defaultAttachments) : this._engine.restoreSingleAttachment(), this._geometryBuffer && this.currentRTisSceneRT && !o && this._geometryBuffer.renderList.push(e.getRenderingMesh())));
      }, n.prototype._reinitializeAttachments = function() {
        for (var t = [], e = [!1], i = [!1], r = [!0], o = 0; o < this.mrtCount; o++)
          t.push(!0), o > 0 && (this._useSpecificClearForDepthTexture && this._mrtLayout[o] === _.PREPASS_DEPTH_TEXTURE_TYPE ? (e.push(!1), i.push(!0)) : (e.push(!0), i.push(!1)), r.push(!1));
        this._multiRenderAttachments = this._engine.buildTextureLayout(t), this._clearAttachments = this._engine.buildTextureLayout(e), this._clearDepthAttachments = this._engine.buildTextureLayout(i), this._defaultAttachments = this._engine.buildTextureLayout(r);
      }, n.prototype._resetLayout = function() {
        for (var t = 0; t < n.TextureFormats.length; t++)
          this._textureIndices[n.TextureFormats[t].purpose] = -1;
        this._textureIndices[_.PREPASS_COLOR_TEXTURE_TYPE] = 0, this._mrtLayout = [_.PREPASS_COLOR_TEXTURE_TYPE], this._mrtTypes = [n.TextureFormats[_.PREPASS_COLOR_TEXTURE_TYPE].type], this._mrtFormats = [n.TextureFormats[_.PREPASS_COLOR_TEXTURE_TYPE].format], this._mrtNames = [n.TextureFormats[_.PREPASS_COLOR_TEXTURE_TYPE].name], this.mrtCount = 1;
      }, n.prototype._updateGeometryBufferLayout = function() {
        if (this._refreshGeometryBufferRendererLink(), this._geometryBuffer) {
          this._geometryBuffer._resetLayout();
          for (var t = [], e = 0; e < this._mrtLayout.length; e++)
            t.push(!1);
          this._geometryBuffer._linkInternalTexture(this.defaultRT.getInternalTexture());
          var i = [{ prePassConstant: _.PREPASS_DEPTH_TEXTURE_TYPE, geometryBufferConstant: mr.DEPTH_TEXTURE_TYPE }, { prePassConstant: _.PREPASS_NORMAL_TEXTURE_TYPE, geometryBufferConstant: mr.NORMAL_TEXTURE_TYPE }, { prePassConstant: _.PREPASS_POSITION_TEXTURE_TYPE, geometryBufferConstant: mr.POSITION_TEXTURE_TYPE }, { prePassConstant: _.PREPASS_REFLECTIVITY_TEXTURE_TYPE, geometryBufferConstant: mr.REFLECTIVITY_TEXTURE_TYPE }, { prePassConstant: _.PREPASS_VELOCITY_TEXTURE_TYPE, geometryBufferConstant: mr.VELOCITY_TEXTURE_TYPE }];
          for (e = 0; e < i.length; e++) {
            var r = this._mrtLayout.indexOf(i[e].prePassConstant);
            r !== -1 && (this._geometryBuffer._forceTextureType(i[e].geometryBufferConstant, r), t[r] = !0);
          }
          this._geometryBuffer._setAttachments(this._engine.buildTextureLayout(t));
        }
      }, n.prototype.restoreAttachments = function() {
        this.enabled && this._currentTarget.enabled && this._defaultAttachments && (this._engine._currentRenderTarget ? this._engine.bindAttachments(this._defaultAttachments) : this._engine.restoreSingleAttachment());
      }, n.prototype._beforeDraw = function(t, e, i) {
        this._isDirty && this._update(), this._enabled && this._currentTarget.enabled && (this._geometryBuffer && (this._geometryBuffer.renderList = []), this._setupOutputForThisPass(this._currentTarget, t));
      }, n.prototype._prepareFrame = function(t, e, i) {
        t.renderTargetTexture ? t.renderTargetTexture._prepareFrame(this._scene, e, i, t.renderTargetTexture.useCameraPostProcesses) : this._postProcessesSourceForThisPass.length ? this._scene.postProcessManager._prepareFrame() : this._engine.restoreDefaultFramebuffer();
      }, n.prototype.setCustomOutput = function(t) {
        var e = this._postProcessesSourceForThisPass[0];
        return !!e && (e.inputTexture = t.renderTarget, !0);
      }, n.prototype._renderPostProcesses = function(t, e) {
        var i, r = this._postProcessesSourceForThisPass[0], o = r ? r.inputTexture : t.renderTargetTexture ? t.renderTargetTexture.renderTarget : null, a = this._currentTarget._beforeCompositionPostProcesses;
        this._needsCompositionForThisPass && (a = a.concat([this._currentTarget.imageProcessingPostProcess])), a.length && (this._scene.postProcessManager._prepareFrame((i = this._currentTarget.renderTarget) === null || i === void 0 ? void 0 : i.texture, a), this._scene.postProcessManager.directRender(a, o, !1, e));
      }, n.prototype._afterDraw = function(t, e) {
        this._enabled && this._currentTarget.enabled && (this._prepareFrame(this._currentTarget, t, e), this._renderPostProcesses(this._currentTarget, t));
      }, n.prototype._clear = function() {
        this._enabled && this._currentTarget.enabled && (this._bindFrameBuffer(), this._engine.bindAttachments(this._clearAttachments), this._engine.clear(this._clearColor, !0, !1, !1), this._useSpecificClearForDepthTexture && (this._engine.bindAttachments(this._clearDepthAttachments), this._engine.clear(this._clearDepthColor, !0, !1, !1)), this._engine.bindAttachments(this._defaultAttachments));
      }, n.prototype._bindFrameBuffer = function() {
        if (this._enabled && this._currentTarget.enabled) {
          this._currentTarget._checkSize();
          var t = this._currentTarget.renderTarget;
          t && this._engine.bindFramebuffer(t);
        }
      }, n.prototype._setEnabled = function(t) {
        this._enabled = t;
      }, n.prototype._setRenderTargetEnabled = function(t, e) {
        t.enabled = e, e || this._unlinkInternalTexture(t);
      }, n.prototype.addEffectConfiguration = function(t) {
        for (var e = 0; e < this._effectConfigurations.length; e++)
          if (this._effectConfigurations[e].name === t.name)
            return this._effectConfigurations[e];
        return this._effectConfigurations.push(t), t;
      }, n.prototype.getEffectConfiguration = function(t) {
        for (var e = 0; e < this._effectConfigurations.length; e++)
          if (this._effectConfigurations[e].name === t)
            return this._effectConfigurations[e];
        return null;
      }, n.prototype._enable = function() {
        for (var t = this.mrtCount, e = 0; e < this._effectConfigurations.length; e++)
          this._effectConfigurations[e].enabled && this._enableTextures(this._effectConfigurations[e].texturesRequired);
        for (e = 0; e < this.renderTargets.length; e++) {
          this.mrtCount === t && this.renderTargets[e].count === this.mrtCount || this.renderTargets[e].updateCount(this.mrtCount, { types: this._mrtTypes, formats: this._mrtFormats }, this._mrtNames.concat("prePass_DepthBuffer")), this.renderTargets[e]._resetPostProcessChain();
          for (var i = 0; i < this._effectConfigurations.length; i++)
            this._effectConfigurations[i].enabled && (!this._effectConfigurations[i].postProcess && this._effectConfigurations[i].createPostProcess && this._effectConfigurations[i].createPostProcess(), this._effectConfigurations[i].postProcess && this.renderTargets[e]._beforeCompositionPostProcesses.push(this._effectConfigurations[i].postProcess));
        }
        this._reinitializeAttachments(), this._setEnabled(!0), this._updateGeometryBufferLayout();
      }, n.prototype._disable = function() {
        this._setEnabled(!1);
        for (var t = 0; t < this.renderTargets.length; t++)
          this._setRenderTargetEnabled(this.renderTargets[t], !1);
        for (this._resetLayout(), t = 0; t < this._effectConfigurations.length; t++)
          this._effectConfigurations[t].enabled = !1;
      }, n.prototype._getPostProcessesSource = function(t, e) {
        if (e)
          return e._postProcesses;
        if (t.renderTargetTexture) {
          if (t.renderTargetTexture.useCameraPostProcesses) {
            var i = t.renderTargetTexture.activeCamera ? t.renderTargetTexture.activeCamera : this._scene.activeCamera;
            return i ? i._postProcesses : [];
          }
          return t.renderTargetTexture.postProcesses ? t.renderTargetTexture.postProcesses : [];
        }
        return this._scene.activeCamera ? this._scene.activeCamera._postProcesses : [];
      }, n.prototype._setupOutputForThisPass = function(t, e) {
        var i = e && this._scene.activeCameras && !!this._scene.activeCameras.length && this._scene.activeCameras.indexOf(e) !== 0;
        this._postProcessesSourceForThisPass = this._getPostProcessesSource(t, e), this._postProcessesSourceForThisPass = this._postProcessesSourceForThisPass.filter(function(l) {
          return l != null;
        }), this._scene.autoClear = !0;
        var r = this._hasImageProcessing(this._postProcessesSourceForThisPass);
        this._needsCompositionForThisPass = !r && !this.disableGammaTransform && this._needsImageProcessing() && !i;
        var o = this._getFirstPostProcess(this._postProcessesSourceForThisPass), a = t._beforeCompositionPostProcesses && t._beforeCompositionPostProcesses[0], s = null;
        this._scene.imageProcessingConfiguration.applyByPostProcess = this._needsCompositionForThisPass || r, this._needsCompositionForThisPass && !t.imageProcessingPostProcess && t._createCompositionEffect(), a ? s = a : this._needsCompositionForThisPass ? s = t.imageProcessingPostProcess : o && (s = o), this._bindFrameBuffer(), this._linkInternalTexture(t, s);
      }, n.prototype._linkInternalTexture = function(t, e) {
        e && (e.autoClear = !1, e.inputTexture = t.renderTarget), t._outputPostProcess !== e && (t._outputPostProcess && this._unlinkInternalTexture(t), t._outputPostProcess = e), t._internalTextureDirty && (this._updateGeometryBufferLayout(), t._internalTextureDirty = !1);
      }, n.prototype._unlinkInternalTexture = function(t) {
        t._outputPostProcess && (t._outputPostProcess.autoClear = !0, t._outputPostProcess.restoreDefaultInputTexture(), t._outputPostProcess = null);
      }, n.prototype._needsImageProcessing = function() {
        for (var t = 0; t < this._effectConfigurations.length; t++)
          if (this._effectConfigurations[t].enabled && this._effectConfigurations[t].needsImageProcessing)
            return !0;
        return !1;
      }, n.prototype._hasImageProcessing = function(t) {
        var e, i = !1;
        if (t) {
          for (var r = 0; r < t.length; r++)
            if (((e = t[r]) === null || e === void 0 ? void 0 : e.getClassName()) === "ImageProcessingPostProcess") {
              i = !0;
              break;
            }
        }
        return i;
      }, n.prototype._getFirstPostProcess = function(t) {
        for (var e = 0; e < t.length; e++)
          if (t[e] !== null)
            return t[e];
        return null;
      }, n.prototype.markAsDirty = function() {
        this._isDirty = !0;
      }, n.prototype._enableTextures = function(t) {
        this._scene.needsPreviousWorldMatrices = !1;
        for (var e = 0; e < t.length; e++) {
          var i = t[e];
          this._textureIndices[i] === -1 && (this._textureIndices[i] = this._mrtLayout.length, this._mrtLayout.push(i), this._mrtTypes.push(n.TextureFormats[i].type), this._mrtFormats.push(n.TextureFormats[i].format), this._mrtNames.push(n.TextureFormats[i].name), this.mrtCount++), i === _.PREPASS_VELOCITY_TEXTURE_TYPE && (this._scene.needsPreviousWorldMatrices = !0);
        }
      }, n.prototype.update = function() {
        this._isDirty && this._update();
      }, n.prototype._update = function() {
        this._disable();
        var t, e = !1;
        this._scene.imageProcessingConfiguration.applyByPostProcess = !1, this._scene._depthPeelingRenderer && this._scene.useOrderIndependentTransparency && (this._scene._depthPeelingRenderer.setPrePassRenderer(this), e = !0);
        for (var i = 0; i < this._scene.materials.length; i++)
          this._scene.materials[i].setPrePassRenderer(this) && (e = !0);
        for (e && this._setRenderTargetEnabled(this.defaultRT, !0), i = 0; i < this.renderTargets.length; i++) {
          if (this.renderTargets[i].renderTargetTexture)
            t = this._getPostProcessesSource(this.renderTargets[i]);
          else {
            var r = this._scene.activeCamera;
            if (!r)
              continue;
            t = r._postProcesses;
          }
          if (t && (t = t.filter(function(a) {
            return a != null;
          }))) {
            for (var o = 0; o < t.length; o++)
              t[o].setPrePassRenderer(this) && (this._setRenderTargetEnabled(this.renderTargets[i], !0), e = !0);
            this._hasImageProcessing(t) && (this._scene.imageProcessingConfiguration.applyByPostProcess = !0);
          }
        }
        this._markAllMaterialsAsPrePassDirty(), this._isDirty = !1, e && this._enable();
      }, n.prototype._markAllMaterialsAsPrePassDirty = function() {
        for (var t = this._scene.materials, e = 0; e < t.length; e++)
          t[e].markAsDirty(Et.PrePassDirtyFlag);
      }, n.prototype.dispose = function() {
        for (var t = this.renderTargets.length - 1; t >= 0; t--)
          this.renderTargets[t].dispose();
        for (t = 0; t < this._effectConfigurations.length; t++)
          this._effectConfigurations[t].dispose && this._effectConfigurations[t].dispose();
      }, n._SceneComponentInitialization = function(t) {
        throw et("PrePassRendererSceneComponent");
      }, n.TextureFormats = [{ purpose: _.PREPASS_IRRADIANCE_TEXTURE_TYPE, type: _.TEXTURETYPE_HALF_FLOAT, format: _.TEXTUREFORMAT_RGBA, name: "prePass_Irradiance" }, { purpose: _.PREPASS_POSITION_TEXTURE_TYPE, type: _.TEXTURETYPE_HALF_FLOAT, format: _.TEXTUREFORMAT_RGBA, name: "prePass_Position" }, { purpose: _.PREPASS_VELOCITY_TEXTURE_TYPE, type: _.TEXTURETYPE_UNSIGNED_INT, format: _.TEXTUREFORMAT_RGBA, name: "prePass_Velocity" }, { purpose: _.PREPASS_REFLECTIVITY_TEXTURE_TYPE, type: _.TEXTURETYPE_UNSIGNED_INT, format: _.TEXTUREFORMAT_RGBA, name: "prePass_Reflectivity" }, { purpose: _.PREPASS_COLOR_TEXTURE_TYPE, type: _.TEXTURETYPE_HALF_FLOAT, format: _.TEXTUREFORMAT_RGBA, name: "prePass_Color" }, { purpose: _.PREPASS_DEPTH_TEXTURE_TYPE, type: _.TEXTURETYPE_FLOAT, format: _.TEXTUREFORMAT_R, name: "prePass_Depth" }, { purpose: _.PREPASS_NORMAL_TEXTURE_TYPE, type: _.TEXTURETYPE_HALF_FLOAT, format: _.TEXTUREFORMAT_RGBA, name: "prePass_Normal" }, { purpose: _.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE, type: _.TEXTURETYPE_UNSIGNED_INT, format: _.TEXTUREFORMAT_RGBA, name: "prePass_Albedo" }], n;
    }();
    Object.defineProperty(Ue.prototype, "prePassRenderer", { get: function() {
      return this._prePassRenderer;
    }, set: function(n) {
      n && n.isSupported && (this._prePassRenderer = n);
    }, enumerable: !0, configurable: !0 }), Ue.prototype.enablePrePassRenderer = function() {
      return this._prePassRenderer || (this._prePassRenderer = new _m(this), this._prePassRenderer.isSupported || (this._prePassRenderer = null, q.Error(`PrePassRenderer needs WebGL 2 support.
Maybe you tried to use the following features that need the PrePassRenderer :
 + Subsurface Scattering`))), this._prePassRenderer;
    }, Ue.prototype.disablePrePassRenderer = function() {
      this._prePassRenderer && (this._prePassRenderer.dispose(), this._prePassRenderer = null);
    };
    var bE = function() {
      function n(t) {
        this.name = we.NAME_PREPASSRENDERER, this.scene = t;
      }
      return n.prototype.register = function() {
        this.scene._beforeCameraDrawStage.registerStep(we.STEP_BEFORECAMERADRAW_PREPASS, this, this._beforeCameraDraw), this.scene._afterCameraDrawStage.registerStep(we.STEP_AFTERCAMERADRAW_PREPASS, this, this._afterCameraDraw), this.scene._beforeRenderTargetDrawStage.registerStep(we.STEP_BEFORERENDERTARGETDRAW_PREPASS, this, this._beforeRenderTargetDraw), this.scene._afterRenderTargetDrawStage.registerStep(we.STEP_AFTERCAMERADRAW_PREPASS, this, this._afterRenderTargetDraw), this.scene._beforeClearStage.registerStep(we.STEP_BEFORECLEAR_PREPASS, this, this._beforeClearStage), this.scene._beforeRenderTargetClearStage.registerStep(we.STEP_BEFORERENDERTARGETCLEAR_PREPASS, this, this._beforeRenderTargetClearStage), this.scene._beforeRenderingMeshStage.registerStep(we.STEP_BEFORERENDERINGMESH_PREPASS, this, this._beforeRenderingMeshStage), this.scene._afterRenderingMeshStage.registerStep(we.STEP_AFTERRENDERINGMESH_PREPASS, this, this._afterRenderingMeshStage);
      }, n.prototype._beforeRenderTargetDraw = function(t, e, i) {
        this.scene.prePassRenderer && !t.noPrePassRenderer && (this.scene.prePassRenderer._setRenderTarget(t._prePassRenderTarget), this.scene.prePassRenderer._beforeDraw(void 0, e, i));
      }, n.prototype._afterRenderTargetDraw = function(t, e, i) {
        this.scene.prePassRenderer && !t.noPrePassRenderer && this.scene.prePassRenderer._afterDraw(e, i);
      }, n.prototype._beforeRenderTargetClearStage = function(t) {
        this.scene.prePassRenderer && !t.noPrePassRenderer && (t._prePassRenderTarget || (t._prePassRenderTarget = this.scene.prePassRenderer._createRenderTarget(t.name + "_prePassRTT", t)), this.scene.prePassRenderer._setRenderTarget(t._prePassRenderTarget), this.scene.prePassRenderer._clear());
      }, n.prototype._beforeCameraDraw = function(t) {
        this.scene.prePassRenderer && (this.scene.prePassRenderer._setRenderTarget(null), this.scene.prePassRenderer._beforeDraw(t));
      }, n.prototype._afterCameraDraw = function() {
        this.scene.prePassRenderer && this.scene.prePassRenderer._afterDraw();
      }, n.prototype._beforeClearStage = function() {
        this.scene.prePassRenderer && (this.scene.prePassRenderer._setRenderTarget(null), this.scene.prePassRenderer._clear());
      }, n.prototype._beforeRenderingMeshStage = function(t, e, i, r) {
        if (r) {
          var o = t.getScene();
          o.prePassRenderer && o.prePassRenderer.bindAttachmentsForEffect(r, e);
        }
      }, n.prototype._afterRenderingMeshStage = function(t) {
        var e = t.getScene();
        e.prePassRenderer && e.prePassRenderer.restoreAttachments();
      }, n.prototype.rebuild = function() {
        this.scene.disablePrePassRenderer(), this.scene.enablePrePassRenderer();
      }, n.prototype.dispose = function() {
        this.scene.disablePrePassRenderer();
      }, n;
    }();
    _m._SceneComponentInitialization = function(n) {
      var t = n._getComponent(we.NAME_PREPASSRENDERER);
      t || (t = new bE(n), n._addComponent(t));
    }, re.IncludesShadersStore.fibonacci = `#define rcp(x) 1./x
#define GOLDEN_RATIO 1.618033988749895
#define TWO_PI 6.2831855
vec2 Golden2dSeq(int i,float n)
{return vec2(float(i)/n+(0.5/n),fract(float(i)*rcp(GOLDEN_RATIO)));}
vec2 SampleDiskGolden(int i,int sampleCount)
{vec2 f=Golden2dSeq(i,float(sampleCount));return vec2(sqrt(f.x),TWO_PI*f.y);}`, re.IncludesShadersStore.diffusionProfile = "uniform vec3 diffusionS[5];uniform float diffusionD[5];uniform float filterRadii[5];", re.ShadersStore.subSurfaceScatteringPixelShader = `#include<fibonacci>
#include<helperFunctions>
#include<subSurfaceScatteringFunctions>
#include<diffusionProfile>
varying vec2 vUV;uniform vec2 texelSize;uniform sampler2D textureSampler;uniform sampler2D irradianceSampler;uniform sampler2D depthSampler;uniform sampler2D albedoSampler;uniform vec2 viewportSize;uniform float metersPerUnit;const float LOG2_E=1.4426950408889634;const float SSS_PIXELS_PER_SAMPLE=4.;const int _SssSampleBudget=40;
#define rcp(x) 1./x
#define Sq(x) x*x
#define SSS_BILATERAL_FILTER true
vec3 EvalBurleyDiffusionProfile(float r,vec3 S)
{vec3 exp_13=exp2(((LOG2_E*(-1.0/3.0))*r)*S); 
vec3 expSum=exp_13*(1.+exp_13*exp_13); 
return (S*rcp(8.*PI))*expSum; }
vec2 SampleBurleyDiffusionProfile(float u,float rcpS)
{u=1.-u; 
float g=1.+(4.*u)*(2.*u+sqrt(1.+(4.*u)*u));float n=exp2(log2(g)*(-1.0/3.0)); 
float p=(g*n)*n; 
float c=1.+p+n; 
float d=(3./LOG2_E*2.)+(3./LOG2_E)*log2(u); 
float x=(3./LOG2_E)*log2(c)-d; 
float rcpExp=((c*c)*c)*rcp((4.*u)*((c*c)+(4.*u)*(4.*u)));float r=x*rcpS;float rcpPdf=(8.*PI*rcpS)*rcpExp; 
return vec2(r,rcpPdf);}
vec3 ComputeBilateralWeight(float xy2,float z,float mmPerUnit,vec3 S,float rcpPdf)
{
#ifndef SSS_BILATERAL_FILTER
z=0.;
#endif
float r=sqrt(xy2+(z*mmPerUnit)*(z*mmPerUnit));float area=rcpPdf;
#if SSS_CLAMP_ARTIFACT
return clamp(EvalBurleyDiffusionProfile(r,S)*area,0.0,1.0);
#else
return EvalBurleyDiffusionProfile(r,S)*area;
#endif
}
void EvaluateSample(int i,int n,vec3 S,float d,vec3 centerPosVS,float mmPerUnit,float pixelsPerMm,
float phase,inout vec3 totalIrradiance,inout vec3 totalWeight)
{float scale =rcp(float(n));float offset=rcp(float(n))*0.5;float sinPhase,cosPhase;sinPhase=sin(phase);cosPhase=cos(phase);vec2 bdp=SampleBurleyDiffusionProfile(float(i)*scale+offset,d);float r=bdp.x;float rcpPdf=bdp.y;float phi=SampleDiskGolden(i,n).y;float sinPhi,cosPhi;sinPhi=sin(phi);cosPhi=cos(phi);float sinPsi=cosPhase*sinPhi+sinPhase*cosPhi; 
float cosPsi=cosPhase*cosPhi-sinPhase*sinPhi; 
vec2 vec=r*vec2(cosPsi,sinPsi);vec2 position; 
float xy2;position=vUV+round((pixelsPerMm*r)*vec2(cosPsi,sinPsi))*texelSize;xy2 =r*r;vec4 textureSample=texture2D(irradianceSampler,position);float viewZ=texture2D(depthSampler,position).r;vec3 irradiance =textureSample.rgb;if (testLightingForSSS(textureSample.a))
{float relZ=viewZ-centerPosVS.z;vec3 weight=ComputeBilateralWeight(xy2,relZ,mmPerUnit,S,rcpPdf);totalIrradiance+=weight*irradiance;totalWeight +=weight;}
else
{}}
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void) 
{vec4 irradianceAndDiffusionProfile =texture2D(irradianceSampler,vUV);vec3 centerIrradiance=irradianceAndDiffusionProfile.rgb;int diffusionProfileIndex=int(round(irradianceAndDiffusionProfile.a*255.));float centerDepth =0.;vec4 inputColor=texture2D(textureSampler,vUV);bool passedStencilTest=testLightingForSSS(irradianceAndDiffusionProfile.a);if (passedStencilTest)
{centerDepth=texture2D(depthSampler,vUV).r;}
if (!passedStencilTest) { 
gl_FragColor=inputColor;return;}
float distScale =1.;vec3 S =diffusionS[diffusionProfileIndex];float d =diffusionD[diffusionProfileIndex];float filterRadius=filterRadii[diffusionProfileIndex];vec2 centerPosNDC=vUV;vec2 cornerPosNDC=vUV+0.5*texelSize;vec3 centerPosVS =vec3(centerPosNDC*viewportSize,1.0)*centerDepth; 
vec3 cornerPosVS =vec3(cornerPosNDC*viewportSize,1.0)*centerDepth; 
float mmPerUnit =1000.*(metersPerUnit*rcp(distScale));float unitsPerMm=rcp(mmPerUnit);float unitsPerPixel=2.*abs(cornerPosVS.x-centerPosVS.x);float pixelsPerMm =rcp(unitsPerPixel)*unitsPerMm;float filterArea =PI*Sq(filterRadius*pixelsPerMm);int sampleCount =int(filterArea*rcp(SSS_PIXELS_PER_SAMPLE));int sampleBudget=_SssSampleBudget;int texturingMode=0;vec3 albedo =texture2D(albedoSampler,vUV).rgb;if (distScale==0. || sampleCount<1)
{
#ifdef DEBUG_SSS_SAMPLES
vec3 green=vec3(0.,1.,0.);gl_FragColor=vec4(green,1.0);return;
#endif
gl_FragColor=vec4(inputColor.rgb+albedo*centerIrradiance,1.0);return;}
#ifdef DEBUG_SSS_SAMPLES
vec3 red =vec3(1.,0.,0.);vec3 blue=vec3(0.,0.,1.);gl_FragColor=vec4(mix(blue,red,clamp(float(sampleCount)/float(sampleBudget),0.0,1.0)),1.0);return;
#endif
float phase=0.;int n=min(sampleCount,sampleBudget);vec3 centerWeight =vec3(0.); 
vec3 totalIrradiance=vec3(0.);vec3 totalWeight =vec3(0.);for (int i=0; i<n; i++)
{EvaluateSample(i,n,S,d,centerPosVS,mmPerUnit,pixelsPerMm,
phase,totalIrradiance,totalWeight);}
totalWeight=max(totalWeight,HALF_MIN);gl_FragColor=vec4(inputColor.rgb+albedo*max(totalIrradiance/totalWeight,vec3(0.0)),1.);}`;
    var MN = function(n) {
      function t(e, i, r, o, a, s, l, c) {
        o === void 0 && (o = null), c === void 0 && (c = _.TEXTURETYPE_UNSIGNED_INT);
        var u = n.call(this, e, "subSurfaceScattering", ["texelSize", "viewportSize", "metersPerUnit"], ["diffusionS", "diffusionD", "filterRadii", "irradianceSampler", "depthSampler", "albedoSampler"], r, o, a || ae.BILINEAR_SAMPLINGMODE, s, l, null, c, "postprocess", void 0, !0) || this;
        return u._scene = i, u.updateEffect(), u.onApplyObservable.add(function(h) {
          if (i.prePassRenderer && i.subSurfaceConfiguration) {
            var d = u.texelSize;
            h.setFloat("metersPerUnit", i.subSurfaceConfiguration.metersPerUnit), h.setFloat2("texelSize", d.x, d.y), h.setTexture("irradianceSampler", i.prePassRenderer.getRenderTarget().textures[i.prePassRenderer.getIndex(_.PREPASS_IRRADIANCE_TEXTURE_TYPE)]), h.setTexture("depthSampler", i.prePassRenderer.getRenderTarget().textures[i.prePassRenderer.getIndex(_.PREPASS_DEPTH_TEXTURE_TYPE)]), h.setTexture("albedoSampler", i.prePassRenderer.getRenderTarget().textures[i.prePassRenderer.getIndex(_.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE)]), h.setFloat2("viewportSize", Math.tan(i.activeCamera.fov / 2) * i.getEngine().getAspectRatio(i.activeCamera, !0), Math.tan(i.activeCamera.fov / 2)), h.setArray3("diffusionS", i.subSurfaceConfiguration.ssDiffusionS), h.setArray("diffusionD", i.subSurfaceConfiguration.ssDiffusionD), h.setArray("filterRadii", i.subSurfaceConfiguration.ssFilterRadii);
          } else
            q.Error("PrePass and subsurface configuration needs to be enabled for subsurface scattering.");
        }), u;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "SubSurfaceScatteringPostProcess";
      }, t;
    }(nt), cI = function() {
      function n(t) {
        this._ssDiffusionS = [], this._ssFilterRadii = [], this._ssDiffusionD = [], this.enabled = !1, this.needsImageProcessing = !0, this.name = we.NAME_SUBSURFACE, this.ssDiffusionProfileColors = [], this.metersPerUnit = 1, this.texturesRequired = [_.PREPASS_DEPTH_TEXTURE_TYPE, _.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE, _.PREPASS_COLOR_TEXTURE_TYPE, _.PREPASS_IRRADIANCE_TEXTURE_TYPE], this.addDiffusionProfile(new ne(1, 1, 1)), this._scene = t, n._SceneComponentInitialization(this._scene);
      }
      return Object.defineProperty(n.prototype, "ssDiffusionS", { get: function() {
        return this._ssDiffusionS;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "ssDiffusionD", { get: function() {
        return this._ssDiffusionD;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "ssFilterRadii", { get: function() {
        return this._ssFilterRadii;
      }, enumerable: !1, configurable: !0 }), n.prototype.addDiffusionProfile = function(t) {
        if (this.ssDiffusionD.length >= 5)
          return q.Error("You already reached the maximum number of diffusion profiles."), 0;
        for (var e = 0; e < this._ssDiffusionS.length / 3; e++)
          if (this._ssDiffusionS[3 * e] === t.r && this._ssDiffusionS[3 * e + 1] === t.g && this._ssDiffusionS[3 * e + 2] === t.b)
            return e;
        return this._ssDiffusionS.push(t.r, t.b, t.g), this._ssDiffusionD.push(Math.max(Math.max(t.r, t.b), t.g)), this._ssFilterRadii.push(this.getDiffusionProfileParameters(t)), this.ssDiffusionProfileColors.push(t), this._ssDiffusionD.length - 1;
      }, n.prototype.createPostProcess = function() {
        return this.postProcess = new MN("subSurfaceScattering", this._scene, 1, null, void 0, this._scene.getEngine()), this.postProcess.autoClear = !1, this.postProcess;
      }, n.prototype.clearAllDiffusionProfiles = function() {
        this._ssDiffusionD = [], this._ssDiffusionS = [], this._ssFilterRadii = [], this.ssDiffusionProfileColors = [];
      }, n.prototype.dispose = function() {
        this.clearAllDiffusionProfiles(), this.postProcess && this.postProcess.dispose();
      }, n.prototype.getDiffusionProfileParameters = function(t) {
        var e = Math.max(t.r, t.g, t.b);
        return this._sampleBurleyDiffusionProfile(0.997, e);
      }, n.prototype._sampleBurleyDiffusionProfile = function(t, e) {
        var i = 1 + 4 * (t = 1 - t) * (2 * t + Math.sqrt(1 + 4 * t * t)), r = Math.pow(i, -1 / 3), o = 1 + i * r * r + r;
        return 3 * Math.log(o / (4 * t)) * e;
      }, n._SceneComponentInitialization = function(t) {
        throw et("SubSurfaceSceneComponent");
      }, n;
    }();
    pe.AddParser(we.NAME_SUBSURFACE, function(n, t) {
      if (n.ssDiffusionProfileColors !== void 0 && n.ssDiffusionProfileColors !== null && (t.enableSubSurfaceForPrePass(), t.subSurfaceConfiguration))
        for (var e = 0, i = n.ssDiffusionProfileColors.length; e < i; e++) {
          var r = n.ssDiffusionProfileColors[e];
          t.subSurfaceConfiguration.addDiffusionProfile(new ne(r.r, r.g, r.b));
        }
    }), Object.defineProperty(Ue.prototype, "subSurfaceConfiguration", { get: function() {
      return this._subSurfaceConfiguration;
    }, set: function(n) {
      n && this.enablePrePassRenderer() && (this._subSurfaceConfiguration = n);
    }, enumerable: !0, configurable: !0 }), Ue.prototype.enableSubSurfaceForPrePass = function() {
      if (this._subSurfaceConfiguration)
        return this._subSurfaceConfiguration;
      var n = this.enablePrePassRenderer();
      return n ? (this._subSurfaceConfiguration = new cI(this), n.addEffectConfiguration(this._subSurfaceConfiguration), this._subSurfaceConfiguration) : null;
    }, Ue.prototype.disableSubSurfaceForPrePass = function() {
      this._subSurfaceConfiguration && (this._subSurfaceConfiguration.dispose(), this._subSurfaceConfiguration = null);
    };
    var TE = function() {
      function n(t) {
        this.name = we.NAME_PREPASSRENDERER, this.scene = t;
      }
      return n.prototype.register = function() {
      }, n.prototype.serialize = function(t) {
        if (this.scene.subSurfaceConfiguration) {
          var e = this.scene.subSurfaceConfiguration.ssDiffusionProfileColors;
          t.ssDiffusionProfileColors = [];
          for (var i = 0; i < e.length; i++)
            t.ssDiffusionProfileColors.push({ r: e[i].r, g: e[i].g, b: e[i].b });
        }
      }, n.prototype.addFromContainer = function() {
      }, n.prototype.removeFromContainer = function() {
        this.scene.prePassRenderer && this.scene.subSurfaceConfiguration && this.scene.subSurfaceConfiguration.clearAllDiffusionProfiles();
      }, n.prototype.rebuild = function() {
      }, n.prototype.dispose = function() {
      }, n;
    }();
    cI._SceneComponentInitialization = function(n) {
      var t = n._getComponent(we.NAME_SUBSURFACE);
      t || (t = new TE(n), n._addComponent(t));
    }, re.ShadersStore.outlinePixelShader = `#ifdef LOGARITHMICDEPTH
#extension GL_EXT_frag_depth : enable
#endif
uniform vec4 color;
#ifdef ALPHATEST
varying vec2 vUV;uniform sampler2D diffuseSampler;
#endif
#include<clipPlaneFragmentDeclaration>
#include<logDepthDeclaration>
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void) {
#define CUSTOM_FRAGMENT_MAIN_BEGIN
#include<clipPlaneFragment>
#ifdef ALPHATEST
if (texture2D(diffuseSampler,vUV).a<0.4)
discard;
#endif
#include<logDepthFragment>
gl_FragColor=color;
#define CUSTOM_FRAGMENT_MAIN_END
}`, re.ShadersStore.outlineVertexShader = `attribute vec3 position;attribute vec3 normal;
#include<bonesDeclaration>
#include<bakedVertexAnimationDeclaration>
#include<morphTargetsVertexGlobalDeclaration>
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
#include<clipPlaneVertexDeclaration>
uniform float offset;
#include<instancesDeclaration>
uniform mat4 viewProjection;
#ifdef ALPHATEST
varying vec2 vUV;uniform mat4 diffuseMatrix;
#ifdef UV1
attribute vec2 uv;
#endif
#ifdef UV2
attribute vec2 uv2;
#endif
#endif
#include<logDepthDeclaration>
#define CUSTOM_VERTEX_DEFINITIONS
void main(void)
{vec3 positionUpdated=position;vec3 normalUpdated=normal;
#ifdef UV1
vec2 uvUpdated=uv;
#endif
#include<morphTargetsVertexGlobal>
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
vec3 offsetPosition=positionUpdated+(normalUpdated*offset);
#include<instancesVertex>
#include<bonesVertex>
#include<bakedVertexAnimation>
vec4 worldPos=finalWorld*vec4(offsetPosition,1.0);gl_Position=viewProjection*worldPos;
#ifdef ALPHATEST
#ifdef UV1
vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
#endif
#ifdef UV2
vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
#endif
#endif
#include<clipPlaneVertex>
#include<logDepthVertex>
}
`, Ue.prototype.getOutlineRenderer = function() {
      return this._outlineRenderer || (this._outlineRenderer = new EE(this)), this._outlineRenderer;
    }, Object.defineProperty(ie.prototype, "renderOutline", { get: function() {
      return this._renderOutline;
    }, set: function(n) {
      n && this.getScene().getOutlineRenderer(), this._renderOutline = n;
    }, enumerable: !0, configurable: !0 }), Object.defineProperty(ie.prototype, "renderOverlay", { get: function() {
      return this._renderOverlay;
    }, set: function(n) {
      n && this.getScene().getOutlineRenderer(), this._renderOverlay = n;
    }, enumerable: !0, configurable: !0 });
    var gr, EE = function() {
      function n(t) {
        this.name = we.NAME_OUTLINERENDERER, this.zOffset = 1, this.zOffsetUnits = 4, this.scene = t, this._engine = t.getEngine(), this.scene._addComponent(this), this._passIdForDrawWrapper = [];
        for (var e = 0; e < 4; ++e)
          this._passIdForDrawWrapper[e] = this._engine.createRenderPassId("Outline Renderer (".concat(e, ")"));
      }
      return n.prototype.register = function() {
        this.scene._beforeRenderingMeshStage.registerStep(we.STEP_BEFORERENDERINGMESH_OUTLINE, this, this._beforeRenderingMesh), this.scene._afterRenderingMeshStage.registerStep(we.STEP_AFTERRENDERINGMESH_OUTLINE, this, this._afterRenderingMesh);
      }, n.prototype.rebuild = function() {
      }, n.prototype.dispose = function() {
        for (var t = 0; t < this._passIdForDrawWrapper.length; ++t)
          this._engine.releaseRenderPassId(this._passIdForDrawWrapper[t]);
      }, n.prototype.render = function(t, e, i, r) {
        i === void 0 && (i = !1), r = r ?? this._passIdForDrawWrapper[0];
        var o = this.scene, a = o.getEngine(), s = a.getCaps().instancedArrays && (e.visibleInstances[t._id] !== null && e.visibleInstances[t._id] !== void 0 || t.getRenderingMesh().hasThinInstances);
        if (this.isReady(t, s, r)) {
          var l = t.getMesh(), c = l._internalAbstractMeshDataInfo._actAsRegularMesh ? l : null, u = t.getRenderingMesh(), h = c || u, d = t.getMaterial();
          if (d && o.activeCamera) {
            var p = t._getDrawWrapper(r), f = Ei.GetEffect(p);
            if (a.enableEffect(p), d.useLogarithmicDepth && f.setFloat("logarithmicDepthConstant", 2 / (Math.log(o.activeCamera.maxZ + 1) / Math.LN2)), f.setFloat("offset", i ? 0 : u.outlineWidth), f.setColor4("color", i ? u.overlayColor : u.outlineColor, i ? u.overlayAlpha : d.alpha), f.setMatrix("viewProjection", o.getTransformMatrix()), f.setMatrix("world", h.getWorldMatrix()), u.useBones && u.computeBonesUsingShaders && u.skeleton && f.setMatrices("mBones", u.skeleton.getTransformMatrices(u)), u.morphTargetManager && u.morphTargetManager.isUsingTextureForTargets && u.morphTargetManager._bind(f), Se.BindMorphTargetParameters(u, f), s || u._bind(t, f, d.fillMode), d && d.needAlphaTesting()) {
              var m = d.getAlphaTestTexture();
              m && (f.setTexture("diffuseSampler", m), f.setMatrix("diffuseMatrix", m.getTextureMatrix()));
            }
            Ar(f, d, o), a.setZOffset(-this.zOffset), a.setZOffsetUnits(-this.zOffsetUnits), u._processRendering(h, t, f, d.fillMode, e, s, function(g, y) {
              f.setMatrix("world", y);
            }), a.setZOffset(0), a.setZOffsetUnits(0);
          }
        }
      }, n.prototype.isReady = function(t, e, i) {
        i = i ?? this._passIdForDrawWrapper[0];
        var r = [], o = [P.PositionKind, P.NormalKind], a = t.getMesh(), s = t.getMaterial();
        if (!s)
          return !1;
        var l = a.getScene();
        s.needAlphaTesting() && (r.push("#define ALPHATEST"), a.isVerticesDataPresent(P.UVKind) && (o.push(P.UVKind), r.push("#define UV1")), a.isVerticesDataPresent(P.UV2Kind) && (o.push(P.UV2Kind), r.push("#define UV2"))), s.useLogarithmicDepth && r.push("#define LOGARITHMICDEPTH"), aa(s, l, r), a.useBones && a.computeBonesUsingShaders ? (o.push(P.MatricesIndicesKind), o.push(P.MatricesWeightsKind), a.numBoneInfluencers > 4 && (o.push(P.MatricesIndicesExtraKind), o.push(P.MatricesWeightsExtraKind)), r.push("#define NUM_BONE_INFLUENCERS " + a.numBoneInfluencers), r.push("#define BonesPerMesh " + (a.skeleton ? a.skeleton.bones.length + 1 : 0))) : r.push("#define NUM_BONE_INFLUENCERS 0");
        var c = a.morphTargetManager, u = 0;
        c && c.numInfluencers > 0 && (u = c.numInfluencers, r.push("#define MORPHTARGETS"), r.push("#define NUM_MORPH_INFLUENCERS " + u), c.isUsingTextureForTargets && r.push("#define MORPHTARGETS_TEXTURE"), Se.PrepareAttributesForMorphTargetsInfluencers(o, a, u)), e && (r.push("#define INSTANCES"), Se.PushAttributesForInstances(o), t.getRenderingMesh().hasThinInstances && r.push("#define THIN_INSTANCES"));
        var h = t._getDrawWrapper(i, !0), d = h.defines, p = r.join(`
`);
        if (d !== p) {
          var f = ["world", "mBones", "viewProjection", "diffuseMatrix", "offset", "color", "logarithmicDepthConstant", "morphTargetInfluences", "morphTargetTextureInfo", "morphTargetTextureIndices"];
          Br(f), h.setEffect(this.scene.getEngine().createEffect("outline", o, f, ["diffuseSampler", "morphTargets"], p, void 0, void 0, void 0, { maxSimultaneousMorphTargets: u }), p);
        }
        return h.effect.isReady();
      }, n.prototype._beforeRenderingMesh = function(t, e, i) {
        if (this._savedDepthWrite = this._engine.getDepthWrite(), t.renderOutline) {
          var r = e.getMaterial();
          r && r.needAlphaBlendingForMesh(t) && (this._engine.cacheStencilState(), this._engine.setDepthWrite(!1), this._engine.setColorWrite(!1), this._engine.setStencilBuffer(!0), this._engine.setStencilOperationPass(_.REPLACE), this._engine.setStencilFunction(_.ALWAYS), this._engine.setStencilMask(n._StencilReference), this._engine.setStencilFunctionReference(n._StencilReference), this._engine.stencilStateComposer.useStencilGlobalOnly = !0, this.render(e, i, !0, this._passIdForDrawWrapper[1]), this._engine.setColorWrite(!0), this._engine.setStencilFunction(_.NOTEQUAL)), this._engine.setDepthWrite(!1), this.render(e, i, !1, this._passIdForDrawWrapper[0]), this._engine.setDepthWrite(this._savedDepthWrite), r && r.needAlphaBlendingForMesh(t) && (this._engine.stencilStateComposer.useStencilGlobalOnly = !1, this._engine.restoreStencilState());
        }
      }, n.prototype._afterRenderingMesh = function(t, e, i) {
        if (t.renderOverlay) {
          var r = this._engine.getAlphaMode(), o = this._engine.alphaState.alphaBlend;
          this._engine.setAlphaMode(_.ALPHA_COMBINE), this.render(e, i, !0, this._passIdForDrawWrapper[3]), this._engine.setAlphaMode(r), this._engine.setDepthWrite(this._savedDepthWrite), this._engine.alphaState.alphaBlend = o;
        }
        t.renderOutline && this._savedDepthWrite && (this._engine.setDepthWrite(!0), this._engine.setColorWrite(!1), this.render(e, i, !1, this._passIdForDrawWrapper[2]), this._engine.setColorWrite(!0));
      }, n._StencilReference = 4, n;
    }(), mm = function() {
      function n(t) {
        this.priority = 0, this._particleSize = 0.1, this.onParticleSizeChanged = new H(), this.particleThicknessAlpha = 0.05, this._useVelocity = !1, this._scene = t, this._engine = t.getEngine(), this._effectsAreDirty = !0, this._depthEffectWrapper = null, this._thicknessEffectWrapper = null;
      }
      return Object.defineProperty(n.prototype, "particleSize", { get: function() {
        return this._particleSize;
      }, set: function(t) {
        t !== this._particleSize && (this._particleSize = t, this.onParticleSizeChanged.notifyObservers(this));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "useInstancing", { get: function() {
        return !this.indexBuffer;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "useVelocity", { get: function() {
        return this._useVelocity;
      }, set: function(t) {
        this._useVelocity !== t && this._hasVelocity() && (this._useVelocity = t, this._effectsAreDirty = !0);
      }, enumerable: !1, configurable: !0 }), n.prototype._hasVelocity = function() {
        var t;
        return !!(!((t = this.vertexBuffers) === null || t === void 0) && t.velocity);
      }, Object.defineProperty(n.prototype, "indexBuffer", { get: function() {
        return null;
      }, enumerable: !1, configurable: !0 }), n.prototype.getClassName = function() {
        return "FluidRenderingObject";
      }, n.prototype._createEffects = function() {
        var t = ["view", "projection", "particleRadius", "size"], e = ["position", "offset"], i = [];
        this._effectsAreDirty = !1, this.useVelocity && (e.push("velocity"), i.push("#define FLUIDRENDERING_VELOCITY")), this._scene.useRightHandedSystem && i.push("#define FLUIDRENDERING_RHS"), this._depthEffectWrapper = new Io({ engine: this._engine, useShaderStore: !0, vertexShader: "fluidRenderingParticleDepth", fragmentShader: "fluidRenderingParticleDepth", attributeNames: e, uniformNames: t, samplerNames: [], defines: i }), t.push("particleAlpha"), this._thicknessEffectWrapper = new Io({ engine: this._engine, useShaderStore: !0, vertexShader: "fluidRenderingParticleThickness", fragmentShader: "fluidRenderingParticleThickness", attributeNames: ["position", "offset"], uniformNames: t, samplerNames: [] });
      }, n.prototype.isReady = function() {
        if (this._effectsAreDirty && this._createEffects(), !this._depthEffectWrapper || !this._thicknessEffectWrapper)
          return !1;
        var t = this._depthEffectWrapper._drawWrapper.effect, e = this._thicknessEffectWrapper._drawWrapper.effect;
        return t.isReady() && e.isReady();
      }, n.prototype.renderDepthTexture = function() {
        var t = this.numParticles;
        if (this._depthEffectWrapper && t !== 0) {
          var e = this._depthEffectWrapper._drawWrapper, i = e.effect;
          this._engine.enableEffect(e), this._engine.bindBuffers(this.vertexBuffers, this.indexBuffer, i), i.setMatrix("view", this._scene.getViewMatrix()), i.setMatrix("projection", this._scene.getProjectionMatrix()), i.setFloat2("size", this._particleSize, this._particleSize), i.setFloat("particleRadius", this._particleSize / 2), this.useInstancing ? this._engine.drawArraysType(_.MATERIAL_TriangleStripDrawMode, 0, 4, t) : this._engine.drawElementsType(_.MATERIAL_TriangleFillMode, 0, t);
        }
      }, n.prototype.renderThicknessTexture = function() {
        var t = this.numParticles;
        if (this._thicknessEffectWrapper && t !== 0) {
          var e = this._thicknessEffectWrapper._drawWrapper, i = e.effect;
          this._engine.setAlphaMode(_.ALPHA_ONEONE), this._engine.setDepthWrite(!1), this._engine.enableEffect(e), this._engine.bindBuffers(this.vertexBuffers, this.indexBuffer, i), i.setMatrix("view", this._scene.getViewMatrix()), i.setMatrix("projection", this._scene.getProjectionMatrix()), i.setFloat("particleAlpha", this.particleThicknessAlpha), i.setFloat2("size", this._particleSize, this._particleSize), this.useInstancing ? this._engine.drawArraysType(_.MATERIAL_TriangleStripDrawMode, 0, 4, t) : this._engine.drawElementsType(_.MATERIAL_TriangleFillMode, 0, t), this._engine.setDepthWrite(!0), this._engine.setAlphaMode(_.ALPHA_DISABLE);
        }
      }, n.prototype.renderDiffuseTexture = function() {
      }, n.prototype.dispose = function() {
        var t, e;
        (t = this._depthEffectWrapper) === null || t === void 0 || t.dispose(), (e = this._thicknessEffectWrapper) === null || e === void 0 || e.dispose();
      }, n;
    }(), SE = function(n) {
      function t(e, i) {
        var r = n.call(this, e) || this;
        return r._useTrueRenderingForDiffuseTexture = !0, r._particleSystem = i, r._originalRender = i.render.bind(i), r._blendMode = i.blendMode, r._onBeforeDrawParticleObserver = null, r._updateInAnimate = r._particleSystem.updateInAnimate, r._particleSystem.updateInAnimate = !0, r._particleSystem.render = function() {
          return 0;
        }, r.particleSize = (i.minSize + i.maxSize) / 2, r.useTrueRenderingForDiffuseTexture = !1, r;
      }
      return D(t, n), Object.defineProperty(t.prototype, "particleSystem", { get: function() {
        return this._particleSystem;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "FluidRenderingObjectParticleSystem";
      }, Object.defineProperty(t.prototype, "useTrueRenderingForDiffuseTexture", { get: function() {
        return this._useTrueRenderingForDiffuseTexture;
      }, set: function(e) {
        var i = this;
        this._useTrueRenderingForDiffuseTexture !== e && (this._useTrueRenderingForDiffuseTexture = e, e ? (this._particleSystem.blendMode = this._blendMode, this._particleSystem.onBeforeDrawParticlesObservable.remove(this._onBeforeDrawParticleObserver), this._onBeforeDrawParticleObserver = null) : (this._particleSystem.blendMode = -1, this._onBeforeDrawParticleObserver = this._particleSystem.onBeforeDrawParticlesObservable.add(function() {
          i._engine.setAlphaMode(_.ALPHA_COMBINE);
        })));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "vertexBuffers", { get: function() {
        return this._particleSystem.vertexBuffers;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "indexBuffer", { get: function() {
        return this._particleSystem.indexBuffer;
      }, enumerable: !1, configurable: !0 }), t.prototype.isReady = function() {
        return n.prototype.isReady.call(this) && this._particleSystem.isReady();
      }, Object.defineProperty(t.prototype, "numParticles", { get: function() {
        return this._particleSystem.getActiveCount();
      }, enumerable: !1, configurable: !0 }), t.prototype.renderDiffuseTexture = function() {
        this._originalRender();
      }, t.prototype.dispose = function() {
        n.prototype.dispose.call(this), this._particleSystem.onBeforeDrawParticlesObservable.remove(this._onBeforeDrawParticleObserver), this._onBeforeDrawParticleObserver = null, this._particleSystem.render = this._originalRender, this._particleSystem.blendMode = this._blendMode, this._particleSystem.updateInAnimate = this._updateInAnimate;
      }, t;
    }(mm), xE = function() {
      function n(t, e, i, r, o, a, s, l, c, u, h, d, p, f) {
        s === void 0 && (s = _.TEXTURETYPE_FLOAT), l === void 0 && (l = _.TEXTUREFORMAT_R), c === void 0 && (c = _.TEXTURETYPE_FLOAT), u === void 0 && (u = _.TEXTUREFORMAT_R), h === void 0 && (h = !1), d === void 0 && (d = null), p === void 0 && (p = !0), f === void 0 && (f = 1), this.enableBlur = !0, this.blurSizeDivisor = 1, this.blurFilterSize = 7, this._blurNumIterations = 3, this.blurMaxFilterSize = 100, this.blurDepthScale = 10, this.particleSize = 0.02, this.onDisposeObservable = new H(), this._name = t, this._scene = e, this._camera = d, this._engine = e.getEngine(), this._width = i, this._height = r, this._blurTextureSizeX = o, this._blurTextureSizeY = a, this._textureType = s, this._textureFormat = l, this._blurTextureType = c, this._blurTextureFormat = u, this._useStandardBlur = h, this._generateDepthBuffer = p, this._samples = f, this._postProcessRunningIndex = 0, this.enableBlur = o !== 0 && a !== 0, this._rt = null, this._texture = null, this._rtBlur = null, this._textureBlurred = null, this._blurPostProcesses = null;
      }
      return Object.defineProperty(n.prototype, "blurNumIterations", { get: function() {
        return this._blurNumIterations;
      }, set: function(t) {
        if (this._blurNumIterations !== t && (this._blurNumIterations = t, this._blurPostProcesses !== null)) {
          var e = this._blurPostProcesses[0], i = this._blurPostProcesses[1];
          this._blurPostProcesses = [];
          for (var r = 0; r < 2 * this._blurNumIterations; ++r)
            this._blurPostProcesses[r] = 1 & r ? i : e;
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "renderTarget", { get: function() {
        return this._rt;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "renderTargetBlur", { get: function() {
        return this._rtBlur;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "texture", { get: function() {
        return this._texture;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "textureBlur", { get: function() {
        return this._textureBlurred;
      }, enumerable: !1, configurable: !0 }), n.prototype.initialize = function() {
        if (this.dispose(), this._createRenderTarget(), this.enableBlur && this._texture) {
          var t = this._createBlurPostProcesses(this._texture, this._blurTextureType, this._blurTextureFormat, this.blurSizeDivisor, this._name, this._useStandardBlur), e = t[0], i = t[1], r = t[2];
          this._rtBlur = e, this._textureBlurred = i, this._blurPostProcesses = r;
        }
      }, n.prototype.applyBlurPostProcesses = function() {
        this.enableBlur && this._blurPostProcesses && (this._postProcessRunningIndex = 0, this._scene.postProcessManager.directRender(this._blurPostProcesses, this._rtBlur, !0), this._engine.unBindFramebuffer(this._rtBlur));
      }, n.prototype._createRenderTarget = function() {
        this._rt = this._engine.createRenderTargetTexture({ width: this._width, height: this._height }, { generateMipMaps: !1, type: this._textureType, format: this._textureFormat, samplingMode: _.TEXTURE_NEAREST_SAMPLINGMODE, generateDepthBuffer: this._generateDepthBuffer, generateStencilBuffer: !1, samples: this._samples, label: "FluidRenderingRTT-".concat(this._name) });
        var t = this._rt.texture;
        t.incrementReferences(), this._texture = new ae(null, this._scene), this._texture.name = "rtt" + this._name, this._texture._texture = t, this._texture.wrapU = ae.CLAMP_ADDRESSMODE, this._texture.wrapV = ae.CLAMP_ADDRESSMODE, this._texture.anisotropicFilteringLevel = 1;
      }, n.prototype._createBlurPostProcesses = function(t, e, i, r, o, a) {
        var s = this;
        a === void 0 && (a = !1);
        var l = this._scene.getEngine(), c = new fe(Math.floor(this._blurTextureSizeX / r), Math.floor(this._blurTextureSizeY / r)), u = e === _.TEXTURETYPE_FLOAT && l.getCaps().textureFloatLinearFiltering || e === _.TEXTURETYPE_HALF_FLOAT && l.getCaps().textureHalfFloatLinearFiltering, h = this._engine.createRenderTargetTexture({ width: c.x, height: c.y }, { generateMipMaps: !1, type: e, format: i, samplingMode: u ? _.TEXTURE_BILINEAR_SAMPLINGMODE : _.TEXTURE_NEAREST_SAMPLINGMODE, generateDepthBuffer: !1, generateStencilBuffer: !1, samples: this._samples, label: "FluidRenderingRTTBlur-".concat(o) }), d = h.texture;
        d.incrementReferences();
        var p = new ae(null, this._scene);
        if (p.name = "rttBlurred" + o, p._texture = d, p.wrapU = ae.CLAMP_ADDRESSMODE, p.wrapV = ae.CLAMP_ADDRESSMODE, p.anisotropicFilteringLevel = 1, a) {
          var f = new nt("BilateralBlurX", "fluidRenderingStandardBlur", ["filterSize", "blurDir"], null, 1, null, _.TEXTURE_NEAREST_SAMPLINGMODE, l, !0, null, e, void 0, void 0, void 0, i);
          f.samples = this._samples, f.externalTextureSamplerBinding = !0, f.onApplyObservable.add(function(E) {
            s._postProcessRunningIndex === 0 ? E.setTexture("textureSampler", t) : E._bindTexture("textureSampler", f.inputTexture.texture), E.setInt("filterSize", s.blurFilterSize), E.setFloat2("blurDir", 1 / s._blurTextureSizeX, 0), s._postProcessRunningIndex++;
          }), f.onSizeChangedObservable.add(function() {
            f._textures.forEach(function(E) {
              E.texture.wrapU = ae.CLAMP_ADDRESSMODE, E.texture.wrapV = ae.CLAMP_ADDRESSMODE;
            });
          }), this._fixReusablePostProcess(f);
          var m = new nt("BilateralBlurY", "fluidRenderingStandardBlur", ["filterSize", "blurDir"], null, 1, null, _.TEXTURE_NEAREST_SAMPLINGMODE, l, !0, null, e, void 0, void 0, void 0, i);
          m.samples = this._samples, m.onApplyObservable.add(function(E) {
            E.setInt("filterSize", s.blurFilterSize), E.setFloat2("blurDir", 0, 1 / s._blurTextureSizeY), s._postProcessRunningIndex++;
          }), m.onSizeChangedObservable.add(function() {
            m._textures.forEach(function(E) {
              E.texture.wrapU = ae.CLAMP_ADDRESSMODE, E.texture.wrapV = ae.CLAMP_ADDRESSMODE;
            });
          }), this._fixReusablePostProcess(m), f.autoClear = !1, m.autoClear = !1;
          for (var g = [], y = 0; y < 2 * this._blurNumIterations; ++y)
            g[y] = 1 & y ? m : f;
          return [h, p, g];
        }
        var b = ["maxFilterSize", "blurDir", "projectedParticleConstant", "depthThreshold"], T = new nt("BilateralBlurX", "fluidRenderingBilateralBlur", b, null, 1, null, _.TEXTURE_NEAREST_SAMPLINGMODE, l, !0, null, e, void 0, void 0, void 0, i);
        T.samples = this._samples, T.externalTextureSamplerBinding = !0, T.onApplyObservable.add(function(E) {
          s._postProcessRunningIndex === 0 ? E.setTexture("textureSampler", t) : E._bindTexture("textureSampler", T.inputTexture.texture), E.setInt("maxFilterSize", s.blurMaxFilterSize), E.setFloat2("blurDir", 1 / s._blurTextureSizeX, 0), E.setFloat("projectedParticleConstant", s._getProjectedParticleConstant()), E.setFloat("depthThreshold", s._getDepthThreshold()), s._postProcessRunningIndex++;
        }), T.onSizeChangedObservable.add(function() {
          T._textures.forEach(function(E) {
            E.texture.wrapU = ae.CLAMP_ADDRESSMODE, E.texture.wrapV = ae.CLAMP_ADDRESSMODE;
          });
        }), this._fixReusablePostProcess(T);
        var S = new nt("BilateralBlurY", "fluidRenderingBilateralBlur", b, null, 1, null, _.TEXTURE_NEAREST_SAMPLINGMODE, l, !0, null, e, void 0, void 0, void 0, i);
        for (S.samples = this._samples, S.onApplyObservable.add(function(E) {
          E.setInt("maxFilterSize", s.blurMaxFilterSize), E.setFloat2("blurDir", 0, 1 / s._blurTextureSizeY), E.setFloat("projectedParticleConstant", s._getProjectedParticleConstant()), E.setFloat("depthThreshold", s._getDepthThreshold()), s._postProcessRunningIndex++;
        }), S.onSizeChangedObservable.add(function() {
          S._textures.forEach(function(E) {
            E.texture.wrapU = ae.CLAMP_ADDRESSMODE, E.texture.wrapV = ae.CLAMP_ADDRESSMODE;
          });
        }), this._fixReusablePostProcess(S), T.autoClear = !1, S.autoClear = !1, g = [], y = 0; y < 2 * this._blurNumIterations; ++y)
          g[y] = 1 & y ? S : T;
        return [h, p, g];
      }, n.prototype._fixReusablePostProcess = function(t) {
        t.isReusable() && (t.onActivateObservable.add(function() {
          t._currentRenderTextureInd = (t._currentRenderTextureInd + 1) % 2;
        }), t.onApplyObservable.add(function() {
          t._currentRenderTextureInd = (t._currentRenderTextureInd + 1) % 2;
        }));
      }, n.prototype._getProjectedParticleConstant = function() {
        var t, e;
        return this.blurFilterSize * this.particleSize * 0.05 * (this._height / 2) / Math.tan(((e = (t = this._camera) === null || t === void 0 ? void 0 : t.fov) !== null && e !== void 0 ? e : 45 * Math.PI / 180) / 2);
      }, n.prototype._getDepthThreshold = function() {
        return this.particleSize / 2 * this.blurDepthScale;
      }, n.prototype.dispose = function() {
        var t, e, i, r;
        this.onDisposeObservable.hasObservers() && this.onDisposeObservable.notifyObservers(this), (t = this._rt) === null || t === void 0 || t.dispose(), this._rt = null, (e = this._texture) === null || e === void 0 || e.dispose(), this._texture = null, (i = this._rtBlur) === null || i === void 0 || i.dispose(), this._rtBlur = null, (r = this._textureBlurred) === null || r === void 0 || r.dispose(), this._textureBlurred = null, this._blurPostProcesses && (this._blurPostProcesses[0].dispose(), this._blurPostProcesses[1].dispose()), this._blurPostProcesses = null;
      }, n;
    }();
    (function(n) {
      n[n.DepthTexture = 0] = "DepthTexture", n[n.DepthBlurredTexture = 1] = "DepthBlurredTexture", n[n.ThicknessTexture = 2] = "ThicknessTexture", n[n.ThicknessBlurredTexture = 3] = "ThicknessBlurredTexture", n[n.DiffuseTexture = 4] = "DiffuseTexture", n[n.Normals = 5] = "Normals", n[n.DiffuseRendering = 6] = "DiffuseRendering";
    })(gr || (gr = {}));
    var fd, gm = function() {
      function n(t, e) {
        this._generateDiffuseTexture = !1, this.fluidColor = new ne(0.085, 0.6375, 0.765), this.density = 2, this.refractionStrength = 0.1, this.fresnelClamp = 1, this.specularPower = 250, this.minimumThickness = 0, this.dirLight = new v(-2, -1, 1).normalize(), this._debugFeature = gr.DepthBlurredTexture, this._debug = !1, this._enableBlurDepth = !0, this._blurDepthSizeDivisor = 1, this._blurDepthFilterSize = 7, this._blurDepthNumIterations = 3, this._blurDepthMaxFilterSize = 100, this._blurDepthDepthScale = 10, this._enableBlurThickness = !0, this._blurThicknessSizeDivisor = 1, this._blurThicknessFilterSize = 5, this._blurThicknessNumIterations = 1, this._useFixedThickness = !1, this._onUseVelocityChanged = new H(), this._useVelocity = !1, this._depthMapSize = null, this._thicknessMapSize = null, this._diffuseMapSize = null, this._samples = 1, this._scene = t, this._engine = t.getEngine(), this._camera = e ?? t.activeCamera, this._needInitialization = !0, this._bgDepthTexture = null, this._invProjectionMatrix = new B(), this._depthClearColor = new Ie(1e6, 1e6, 1e6, 1), this._thicknessClearColor = new Ie(0, 0, 0, 1), this._depthRenderTarget = null, this._diffuseRenderTarget = null, this._thicknessRenderTarget = null, this._renderPostProcess = null;
      }
      return Object.defineProperty(n.prototype, "needInitialization", { get: function() {
        return this._needInitialization;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "generateDiffuseTexture", { get: function() {
        return this._generateDiffuseTexture;
      }, set: function(t) {
        this._generateDiffuseTexture !== t && (this._generateDiffuseTexture = t, this._needInitialization = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "debugFeature", { get: function() {
        return this._debugFeature;
      }, set: function(t) {
        this._debugFeature !== t && (this._needInitialization = !0, this._debugFeature = t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "debug", { get: function() {
        return this._debug;
      }, set: function(t) {
        this._debug !== t && (this._debug = t, this._needInitialization = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "environmentMap", { get: function() {
        return this._environmentMap;
      }, set: function(t) {
        this._environmentMap !== t && (this._needInitialization = !0, this._environmentMap = t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "enableBlurDepth", { get: function() {
        return this._enableBlurDepth;
      }, set: function(t) {
        this._enableBlurDepth !== t && (this._enableBlurDepth = t, this._needInitialization = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "blurDepthSizeDivisor", { get: function() {
        return this._blurDepthSizeDivisor;
      }, set: function(t) {
        this._blurDepthSizeDivisor !== t && (this._blurDepthSizeDivisor = t, this._needInitialization = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "blurDepthFilterSize", { get: function() {
        return this._blurDepthFilterSize;
      }, set: function(t) {
        this._blurDepthFilterSize !== t && (this._blurDepthFilterSize = t, this._setBlurParameters());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "blurDepthNumIterations", { get: function() {
        return this._blurDepthNumIterations;
      }, set: function(t) {
        this._blurDepthNumIterations !== t && (this._blurDepthNumIterations = t, this._setBlurParameters());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "blurDepthMaxFilterSize", { get: function() {
        return this._blurDepthMaxFilterSize;
      }, set: function(t) {
        this._blurDepthMaxFilterSize !== t && (this._blurDepthMaxFilterSize = t, this._setBlurParameters());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "blurDepthDepthScale", { get: function() {
        return this._blurDepthDepthScale;
      }, set: function(t) {
        this._blurDepthDepthScale !== t && (this._blurDepthDepthScale = t, this._setBlurParameters());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "enableBlurThickness", { get: function() {
        return this._enableBlurThickness;
      }, set: function(t) {
        this._enableBlurThickness !== t && (this._enableBlurThickness = t, this._needInitialization = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "blurThicknessSizeDivisor", { get: function() {
        return this._blurThicknessSizeDivisor;
      }, set: function(t) {
        this._blurThicknessSizeDivisor !== t && (this._blurThicknessSizeDivisor = t, this._needInitialization = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "blurThicknessFilterSize", { get: function() {
        return this._blurThicknessFilterSize;
      }, set: function(t) {
        this._blurThicknessFilterSize !== t && (this._blurThicknessFilterSize = t, this._setBlurParameters());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "blurThicknessNumIterations", { get: function() {
        return this._blurThicknessNumIterations;
      }, set: function(t) {
        this._blurThicknessNumIterations !== t && (this._blurThicknessNumIterations = t, this._setBlurParameters());
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "useFixedThickness", { get: function() {
        return this._useFixedThickness;
      }, set: function(t) {
        this._useFixedThickness !== t && (this._useFixedThickness = t, this._needInitialization = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "useVelocity", { get: function() {
        return this._useVelocity;
      }, set: function(t) {
        this._useVelocity !== t && (this._useVelocity = t, this._needInitialization = !0, this._onUseVelocityChanged.notifyObservers(this));
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "depthMapSize", { get: function() {
        return this._depthMapSize;
      }, set: function(t) {
        this._depthMapSize !== t && (this._depthMapSize = t, this._needInitialization = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "thicknessMapSize", { get: function() {
        return this._thicknessMapSize;
      }, set: function(t) {
        this._thicknessMapSize !== t && (this._thicknessMapSize = t, this._needInitialization = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "diffuseMapSize", { get: function() {
        return this._diffuseMapSize;
      }, set: function(t) {
        this._diffuseMapSize !== t && (this._diffuseMapSize = t, this._needInitialization = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "samples", { get: function() {
        return this._samples;
      }, set: function(t) {
        this._samples !== t && (this._samples = t, this._needInitialization = !0);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "camera", { get: function() {
        return this._camera;
      }, enumerable: !1, configurable: !0 }), n.prototype._initialize = function() {
        var t, e, i;
        this.dispose(), this._needInitialization = !1;
        var r = (t = this._depthMapSize) !== null && t !== void 0 ? t : this._engine.getRenderWidth(), o = this._depthMapSize !== null ? Math.round(this._depthMapSize * this._engine.getRenderHeight() / this._engine.getRenderWidth()) : this._engine.getRenderHeight();
        if (this._depthRenderTarget = new xE("Depth", this._scene, r, o, r, o, _.TEXTURETYPE_FLOAT, _.TEXTUREFORMAT_RG, _.TEXTURETYPE_FLOAT, _.TEXTUREFORMAT_RG, !1, this._camera, !0, this._samples), this._initializeRenderTarget(this._depthRenderTarget), this.generateDiffuseTexture) {
          var a = (e = this._diffuseMapSize) !== null && e !== void 0 ? e : this._engine.getRenderWidth(), s = this._diffuseMapSize !== null ? Math.round(this._diffuseMapSize * this._engine.getRenderHeight() / this._engine.getRenderWidth()) : this._engine.getRenderHeight();
          this._diffuseRenderTarget = new xE("Diffuse", this._scene, a, s, 0, 0, _.TEXTURETYPE_UNSIGNED_BYTE, _.TEXTUREFORMAT_RGBA, _.TEXTURETYPE_UNSIGNED_BYTE, _.TEXTUREFORMAT_RGBA, !0, this._camera, !0, this._samples), this._initializeRenderTarget(this._diffuseRenderTarget);
        }
        var l = (i = this._thicknessMapSize) !== null && i !== void 0 ? i : this._engine.getRenderWidth(), c = this._thicknessMapSize !== null ? Math.round(this._thicknessMapSize * this._engine.getRenderHeight() / this._engine.getRenderWidth()) : this._engine.getRenderHeight();
        this._useFixedThickness || (this._thicknessRenderTarget = new xE("Thickness", this._scene, l, c, l, c, _.TEXTURETYPE_HALF_FLOAT, _.TEXTUREFORMAT_R, _.TEXTURETYPE_HALF_FLOAT, _.TEXTUREFORMAT_R, !0, this._camera, !1, this._samples), this._initializeRenderTarget(this._thicknessRenderTarget)), this._createLiquidRenderingPostProcess();
      }, n.prototype._setBlurParameters = function(t) {
        t === void 0 && (t = null), t !== null && t !== this._depthRenderTarget || this._setBlurDepthParameters(), t !== null && t !== this._thicknessRenderTarget || this._setBlurThicknessParameters();
      }, n.prototype._setBlurDepthParameters = function() {
        this._depthRenderTarget && (this._depthRenderTarget.blurFilterSize = this.blurDepthFilterSize, this._depthRenderTarget.blurMaxFilterSize = this.blurDepthMaxFilterSize, this._depthRenderTarget.blurNumIterations = this.blurDepthNumIterations, this._depthRenderTarget.blurDepthScale = this.blurDepthDepthScale);
      }, n.prototype._setBlurThicknessParameters = function() {
        this._thicknessRenderTarget && (this._thicknessRenderTarget.blurFilterSize = this.blurThicknessFilterSize, this._thicknessRenderTarget.blurNumIterations = this.blurThicknessNumIterations);
      }, n.prototype._initializeRenderTarget = function(t) {
        t !== this._diffuseRenderTarget && (t.enableBlur = t === this._depthRenderTarget ? this.enableBlurDepth : this.enableBlurThickness, t.blurSizeDivisor = t === this._depthRenderTarget ? this.blurDepthSizeDivisor : this.blurThicknessSizeDivisor), this._setBlurParameters(t), t.initialize();
      }, n.prototype._createLiquidRenderingPostProcess = function() {
        var t, e = this, i = this._scene.getEngine(), r = ["viewMatrix", "projectionMatrix", "invProjectionMatrix", "texelSize", "dirLight", "cameraFar", "density", "refractionStrength", "fresnelClamp", "specularPower"], o = ["depthSampler"], a = [];
        if (this.dispose(!0), this._camera) {
          var s = this._depthRenderTarget.enableBlur ? this._depthRenderTarget.textureBlur : this._depthRenderTarget.texture, l = new fe(1 / s.getSize().width, 1 / s.getSize().height);
          this._scene.useRightHandedSystem && a.push("#define FLUIDRENDERING_RHS"), this._environmentMap !== null && ((t = this._environmentMap) !== null && t !== void 0 ? t : this._scene.environmentTexture) && (o.push("reflectionSampler"), a.push("#define FLUIDRENDERING_ENVIRONMENT")), this._diffuseRenderTarget ? (o.push("diffuseSampler"), a.push("#define FLUIDRENDERING_DIFFUSETEXTURE")) : r.push("diffuseColor"), this._useVelocity && (o.push("velocitySampler"), a.push("#define FLUIDRENDERING_VELOCITY")), this._useFixedThickness ? (r.push("thickness"), o.push("bgDepthSampler"), a.push("#define FLUIDRENDERING_FIXED_THICKNESS")) : (r.push("minimumThickness"), o.push("thicknessSampler")), this._debug && (a.push("#define FLUIDRENDERING_DEBUG"), this._debugFeature === gr.Normals ? a.push("#define FLUIDRENDERING_DEBUG_SHOWNORMAL") : this._debugFeature === gr.DiffuseRendering ? a.push("#define FLUIDRENDERING_DEBUG_DIFFUSERENDERING") : (a.push("#define FLUIDRENDERING_DEBUG_TEXTURE"), o.push("debugSampler"), this._debugFeature !== gr.DepthTexture && this._debugFeature !== gr.DepthBlurredTexture || a.push("#define FLUIDRENDERING_DEBUG_DEPTH"))), this._renderPostProcess = new nt("FluidRendering", "fluidRenderingRender", r, o, 1, null, _.TEXTURE_BILINEAR_SAMPLINGMODE, i, !1, null, _.TEXTURETYPE_UNSIGNED_BYTE, void 0, void 0, !0, void 0), this._renderPostProcess.updateEffect(a.join(`
`)), this._renderPostProcess.samples = this._samples, this._renderPostProcess.onApplyObservable.add(function(c) {
            var u, h, d, p, f, m, g, y, b, T, S, E, A, R, C, L, I, O, w, z, V, Y, ee;
            if (e._invProjectionMatrix.copyFrom(e._scene.getProjectionMatrix()), e._invProjectionMatrix.invert(), i.isWebGPU && c.setTextureSampler("textureSamplerSampler", e._renderPostProcess.inputTexture.texture), e._depthRenderTarget.enableBlur ? (c.setTexture("depthSampler", e._depthRenderTarget.textureBlur), i.isWebGPU && c.setTextureSampler("depthSamplerSampler", (p = (d = e._depthRenderTarget.textureBlur) === null || d === void 0 ? void 0 : d.getInternalTexture()) !== null && p !== void 0 ? p : null)) : (c.setTexture("depthSampler", e._depthRenderTarget.texture), i.isWebGPU && c.setTextureSampler("depthSamplerSampler", (h = (u = e._depthRenderTarget.texture) === null || u === void 0 ? void 0 : u.getInternalTexture()) !== null && h !== void 0 ? h : null)), e._diffuseRenderTarget ? e._diffuseRenderTarget.enableBlur ? (c.setTexture("diffuseSampler", e._diffuseRenderTarget.textureBlur), i.isWebGPU && c.setTextureSampler("diffuseSamplerSampler", (y = (g = e._diffuseRenderTarget.textureBlur) === null || g === void 0 ? void 0 : g.getInternalTexture()) !== null && y !== void 0 ? y : null)) : (c.setTexture("diffuseSampler", e._diffuseRenderTarget.texture), i.isWebGPU && c.setTextureSampler("diffuseSamplerSampler", (m = (f = e._diffuseRenderTarget.texture) === null || f === void 0 ? void 0 : f.getInternalTexture()) !== null && m !== void 0 ? m : null)) : c.setColor3("diffuseColor", e.fluidColor), e._useFixedThickness ? (c.setFloat("thickness", e.minimumThickness), c._bindTexture("bgDepthSampler", e._bgDepthTexture), i.isWebGPU && c.setTextureSampler("bgDepthSamplerSampler", (b = e._bgDepthTexture) !== null && b !== void 0 ? b : null)) : (e._thicknessRenderTarget.enableBlur ? (c.setTexture("thicknessSampler", e._thicknessRenderTarget.textureBlur), i.isWebGPU && c.setTextureSampler("thicknessSamplerSampler", (A = (E = e._thicknessRenderTarget.textureBlur) === null || E === void 0 ? void 0 : E.getInternalTexture()) !== null && A !== void 0 ? A : null)) : (c.setTexture("thicknessSampler", e._thicknessRenderTarget.texture), i.isWebGPU && c.setTextureSampler("thicknessSamplerSampler", (S = (T = e._thicknessRenderTarget.texture) === null || T === void 0 ? void 0 : T.getInternalTexture()) !== null && S !== void 0 ? S : null)), c.setFloat("minimumThickness", e.minimumThickness)), e._environmentMap !== null) {
              var J = (R = e._environmentMap) !== null && R !== void 0 ? R : e._scene.environmentTexture;
              J && (c.setTexture("reflectionSampler", J), i.isWebGPU && c.setTextureSampler("reflectionSamplerSampler", (C = J == null ? void 0 : J.getInternalTexture()) !== null && C !== void 0 ? C : null));
            }
            if (c.setMatrix("viewMatrix", e._scene.getViewMatrix()), c.setMatrix("invProjectionMatrix", e._invProjectionMatrix), c.setMatrix("projectionMatrix", e._scene.getProjectionMatrix()), c.setVector2("texelSize", l), c.setFloat("density", e.density), c.setFloat("refractionStrength", e.refractionStrength), c.setFloat("fresnelClamp", e.fresnelClamp), c.setFloat("specularPower", e.specularPower), c.setVector3("dirLight", e.dirLight), c.setFloat("cameraFar", e._camera.maxZ), e._debug) {
              var X = null;
              switch (e._debugFeature) {
                case gr.DepthTexture:
                  X = e._depthRenderTarget.texture;
                  break;
                case gr.DepthBlurredTexture:
                  X = e._depthRenderTarget.enableBlur ? e._depthRenderTarget.textureBlur : e._depthRenderTarget.texture;
                  break;
                case gr.ThicknessTexture:
                  X = (I = (L = e._thicknessRenderTarget) === null || L === void 0 ? void 0 : L.texture) !== null && I !== void 0 ? I : null;
                  break;
                case gr.ThicknessBlurredTexture:
                  X = !((O = e._thicknessRenderTarget) === null || O === void 0) && O.enableBlur ? (z = (w = e._thicknessRenderTarget) === null || w === void 0 ? void 0 : w.textureBlur) !== null && z !== void 0 ? z : null : (Y = (V = e._thicknessRenderTarget) === null || V === void 0 ? void 0 : V.texture) !== null && Y !== void 0 ? Y : null;
                  break;
                case gr.DiffuseTexture:
                  e._diffuseRenderTarget && (X = e._diffuseRenderTarget.texture);
              }
              e._debugFeature !== gr.Normals && (c.setTexture("debugSampler", X), i.isWebGPU && c.setTextureSampler("debugSamplerSampler", (ee = X == null ? void 0 : X.getInternalTexture()) !== null && ee !== void 0 ? ee : null));
            }
          });
        }
      }, n.prototype._clearTargets = function() {
        var t, e, i;
        !((t = this._depthRenderTarget) === null || t === void 0) && t.renderTarget && (this._engine.bindFramebuffer(this._depthRenderTarget.renderTarget), this._engine.clear(this._depthClearColor, !0, !0, !1), this._engine.unBindFramebuffer(this._depthRenderTarget.renderTarget)), !((e = this._diffuseRenderTarget) === null || e === void 0) && e.renderTarget && (this._engine.bindFramebuffer(this._diffuseRenderTarget.renderTarget), this._engine.clear(this._thicknessClearColor, !0, !0, !1), this._engine.unBindFramebuffer(this._diffuseRenderTarget.renderTarget)), !((i = this._thicknessRenderTarget) === null || i === void 0) && i.renderTarget && (this._engine.bindFramebuffer(this._thicknessRenderTarget.renderTarget), this._engine.clear(this._thicknessClearColor, !0, !1, !1), this._engine.unBindFramebuffer(this._thicknessRenderTarget.renderTarget));
      }, n.prototype._render = function(t) {
        var e, i, r, o, a, s;
        if (!this._needInitialization && t.isReady()) {
          var l = this._engine._currentRenderTarget;
          this._engine.setState(!1, void 0, void 0, void 0, !0), this._engine.setDepthBuffer(!0), this._engine.setDepthWrite(!0), this._engine.setAlphaMode(_.ALPHA_DISABLE), !((e = this._depthRenderTarget) === null || e === void 0) && e.renderTarget && (this._engine.bindFramebuffer(this._depthRenderTarget.renderTarget), t.renderDepthTexture(), this._engine.unbindInstanceAttributes(), this._engine.unBindFramebuffer(this._depthRenderTarget.renderTarget)), !((i = this._diffuseRenderTarget) === null || i === void 0) && i.renderTarget && (this._engine.bindFramebuffer(this._diffuseRenderTarget.renderTarget), t.renderDiffuseTexture(), this._engine.unbindInstanceAttributes(), this._engine.unBindFramebuffer(this._diffuseRenderTarget.renderTarget)), !((r = this._thicknessRenderTarget) === null || r === void 0) && r.renderTarget && (this._engine.bindFramebuffer(this._thicknessRenderTarget.renderTarget), t.renderThicknessTexture(), this._engine.unbindInstanceAttributes(), this._engine.unBindFramebuffer(this._thicknessRenderTarget.renderTarget)), (o = this._depthRenderTarget) === null || o === void 0 || o.applyBlurPostProcesses(), (a = this._diffuseRenderTarget) === null || a === void 0 || a.applyBlurPostProcesses(), (s = this._thicknessRenderTarget) === null || s === void 0 || s.applyBlurPostProcesses(), l && this._engine.bindFramebuffer(l);
        }
      }, n.prototype.dispose = function(t) {
        var e, i, r, o;
        t === void 0 && (t = !1), t || ((e = this._depthRenderTarget) === null || e === void 0 || e.dispose(), this._depthRenderTarget = null, (i = this._diffuseRenderTarget) === null || i === void 0 || i.dispose(), this._diffuseRenderTarget = null, (r = this._thicknessRenderTarget) === null || r === void 0 || r.dispose(), this._thicknessRenderTarget = null), this._renderPostProcess && this._camera && this._camera.detachPostProcess(this._renderPostProcess), (o = this._renderPostProcess) === null || o === void 0 || o.dispose(), this._renderPostProcess = null, this._needInitialization = !1;
      }, n;
    }(), AE = function(n) {
      function t(e, i, r) {
        var o = n.call(this, e) || this;
        return o._numParticles = r, o._diffuseEffectWrapper = null, o._vertexBuffers = {}, o.addBuffers(i), o;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return "FluidRenderingObjectCustomParticles";
      }, Object.defineProperty(t.prototype, "vertexBuffers", { get: function() {
        return this._vertexBuffers;
      }, enumerable: !1, configurable: !0 }), t.prototype.addBuffers = function(e) {
        for (var i in e) {
          var r = void 0, o = !0;
          switch (i) {
            case "velocity":
              r = 3;
              break;
            case "offset":
              o = !1;
          }
          this._vertexBuffers[i] = new P(this._engine, e[i], i, !0, !1, r, o);
        }
      }, t.prototype._createEffects = function() {
        n.prototype._createEffects.call(this), this._diffuseEffectWrapper = new Io({ engine: this._engine, useShaderStore: !0, vertexShader: "fluidRenderingParticleDiffuse", fragmentShader: "fluidRenderingParticleDiffuse", attributeNames: ["position", "offset", "color"], uniformNames: ["view", "projection", "size"], samplerNames: [] });
      }, t.prototype.isReady = function() {
        var e, i;
        return this._vertexBuffers.offset || (this._vertexBuffers.offset = new P(this._engine, [0, 0, 1, 0, 0, 1, 1, 1], "offset", !1, !1, 2)), n.prototype.isReady.call(this) && (i = (e = this._diffuseEffectWrapper) === null || e === void 0 ? void 0 : e.effect.isReady()) !== null && i !== void 0 && i;
      }, Object.defineProperty(t.prototype, "numParticles", { get: function() {
        return this._numParticles;
      }, enumerable: !1, configurable: !0 }), t.prototype.setNumParticles = function(e) {
        this._numParticles = e;
      }, t.prototype.renderDiffuseTexture = function() {
        var e = this.numParticles;
        if (this._diffuseEffectWrapper && e !== 0) {
          var i = this._diffuseEffectWrapper._drawWrapper, r = i.effect;
          this._engine.enableEffect(i), this._engine.bindBuffers(this.vertexBuffers, this.indexBuffer, r), r.setMatrix("view", this._scene.getViewMatrix()), r.setMatrix("projection", this._scene.getProjectionMatrix()), this._particleSize !== null && r.setFloat2("size", this._particleSize, this._particleSize), this.useInstancing ? this._engine.drawArraysType(_.MATERIAL_TriangleStripDrawMode, 0, 4, e) : this._engine.drawElementsType(_.MATERIAL_TriangleFillMode, 0, e);
        }
      }, t.prototype.dispose = function() {
        var e;
        for (var i in n.prototype.dispose.call(this), (e = this._diffuseEffectWrapper) === null || e === void 0 || e.dispose(), this._vertexBuffers)
          this._vertexBuffers[i].dispose();
        this._vertexBuffers = {};
      }, t;
    }(mm);
    re.ShadersStore.copyTextureToTexturePixelShader = `uniform float conversion;uniform sampler2D textureSampler;varying vec2 vUV;
#include<helperFunctions>
void main(void) 
{vec4 color=texture2D(textureSampler,vUV);
#ifdef DEPTH_TEXTURE
gl_FragDepth=color.r;
#else
if (conversion==1.) {color=toLinearSpace(color);} else if (conversion==2.) {color=toGammaSpace(color);}
gl_FragColor=color;
#endif
}
`, function(n) {
      n[n.None = 0] = "None", n[n.ToLinearSpace = 1] = "ToLinearSpace", n[n.ToGammaSpace = 2] = "ToGammaSpace";
    }(fd || (fd = {}));
    var RE = function() {
      function n(t, e) {
        e === void 0 && (e = !1);
        var i = this;
        this._engine = t, this._isDepthTexture = e, this._renderer = new _c(t), this._effectWrapper = new Io({ engine: t, name: "CopyTextureToTexture", fragmentShader: "copyTextureToTexture", useShaderStore: !0, uniformNames: ["conversion"], samplerNames: ["textureSampler"], defines: e ? ["#define DEPTH_TEXTURE"] : [] }), this._effectWrapper.onApplyObservable.add(function() {
          e && (t.setState(!1), t.setDepthBuffer(!0), t.depthCullingState.depthMask = !0, t.depthCullingState.depthFunc = _.ALWAYS), i._textureIsInternal(i._source) ? i._effectWrapper.effect._bindTexture("textureSampler", i._source) : i._effectWrapper.effect.setTexture("textureSampler", i._source), i._effectWrapper.effect.setFloat("conversion", i._conversion);
        });
      }
      return n.prototype._textureIsInternal = function(t) {
        return t.getInternalTexture === void 0;
      }, n.prototype.isReady = function() {
        return this._effectWrapper.effect.isReady();
      }, n.prototype.copy = function(t, e, i) {
        if (i === void 0 && (i = fd.None), !this.isReady())
          return !1;
        this._source = t, this._conversion = i;
        var r = this._engine.depthCullingState.depthFunc;
        return this._renderer.render(this._effectWrapper, e), this._isDepthTexture && r && (this._engine.depthCullingState.depthFunc = r), !0;
      }, n.prototype.dispose = function() {
        this._effectWrapper.dispose(), this._renderer.dispose();
      }, n;
    }(), ON = function() {
      function n(t, e, i, r) {
        r === void 0 && (r = 1), this._engine = t, this._copyTextureToTexture = new RE(t, !0), this._depthRTWrapper = this._engine.createRenderTargetTexture({ width: e, height: i }, { generateMipMaps: !1, type: _.TEXTURETYPE_UNSIGNED_BYTE, format: _.TEXTUREFORMAT_R, samplingMode: _.TEXTURE_NEAREST_SAMPLINGMODE, generateDepthBuffer: !0, generateStencilBuffer: !1, samples: r, noColorAttachment: !0, label: "FluidRenderingDepthTextureCopyRTT" }), this._depthRTWrapper.createDepthStencilTexture(0, !1, !1, 1, void 0, "FluidRenderingDepthTextureCopyRTTDepthStencil").label = "FluidDepthTextureCopy".concat(e, "x").concat(i, "x").concat(r);
      }
      return Object.defineProperty(n.prototype, "depthRTWrapper", { get: function() {
        return this._depthRTWrapper;
      }, enumerable: !1, configurable: !0 }), n.prototype.copy = function(t) {
        return this._copyTextureToTexture.copy(t, this._depthRTWrapper);
      }, n.prototype.dispose = function() {
        this._depthRTWrapper.dispose(), this._copyTextureToTexture.dispose();
      }, n;
    }();
    re.ShadersStore.fluidRenderingParticleDepthVertexShader = `attribute vec3 position;attribute vec2 offset;uniform mat4 view;uniform mat4 projection;uniform vec2 size;varying vec2 uv;varying vec3 viewPos;varying float sphereRadius;
#ifdef FLUIDRENDERING_VELOCITY
attribute vec3 velocity;varying float velocityNorm;
#endif
void main(void) {vec3 cornerPos;cornerPos.xy=vec2(offset.x-0.5,offset.y-0.5)*size;cornerPos.z=0.0;viewPos=(view*vec4(position,1.0)).xyz;gl_Position=projection*vec4(viewPos+cornerPos,1.0);uv=offset;sphereRadius=size.x/2.0;
#ifdef FLUIDRENDERING_VELOCITY
velocityNorm=length(velocity);
#endif
}
`, re.ShadersStore.fluidRenderingParticleDepthPixelShader = `uniform mat4 projection;varying vec2 uv;varying vec3 viewPos;varying float sphereRadius;
#ifdef FLUIDRENDERING_VELOCITY
varying float velocityNorm;
#endif
void main(void) {vec3 normal;normal.xy=uv*2.0-1.0;float r2=dot(normal.xy,normal.xy);if (r2>1.0) discard;normal.z=sqrt(1.0-r2);
#ifndef FLUIDRENDERING_RHS
normal.z=-normal.z;
#endif
vec4 realViewPos=vec4(viewPos+normal*sphereRadius,1.0);vec4 clipSpacePos=projection*realViewPos;
#ifdef WEBGPU
gl_FragDepth=clipSpacePos.z/clipSpacePos.w;
#else
gl_FragDepth=(clipSpacePos.z/clipSpacePos.w)*0.5+0.5;
#endif
#ifdef FLUIDRENDERING_RHS
realViewPos.z=-realViewPos.z;
#endif
#ifdef FLUIDRENDERING_VELOCITY
glFragColor=vec4(realViewPos.z,velocityNorm,0.,1.);
#else
glFragColor=vec4(realViewPos.z,0.,0.,1.);
#endif
}
`, re.ShadersStore.fluidRenderingParticleThicknessVertexShader = `attribute vec3 position;attribute vec2 offset;uniform mat4 view;uniform mat4 projection;uniform vec2 size;varying vec2 uv;void main(void) {vec3 cornerPos;cornerPos.xy=vec2(offset.x-0.5,offset.y-0.5)*size;cornerPos.z=0.0;vec3 viewPos=(view*vec4(position,1.0)).xyz+cornerPos;gl_Position=projection*vec4(viewPos,1.0);uv=offset;}
`, re.ShadersStore.fluidRenderingParticleThicknessPixelShader = `uniform float particleAlpha;varying vec2 uv;void main(void) {vec3 normal;normal.xy=uv*2.0-1.0;float r2=dot(normal.xy,normal.xy);if (r2>1.0) discard;float thickness=sqrt(1.0-r2);glFragColor=vec4(vec3(particleAlpha*thickness),1.0);}
`, re.ShadersStore.fluidRenderingParticleDiffuseVertexShader = `attribute vec3 position;attribute vec2 offset;attribute vec4 color;uniform mat4 view;uniform mat4 projection;uniform vec2 size;varying vec2 uv;varying vec3 diffuseColor;void main(void) {vec3 cornerPos;cornerPos.xy=vec2(offset.x-0.5,offset.y-0.5)*size;cornerPos.z=0.0;vec3 viewPos=(view*vec4(position,1.0)).xyz+cornerPos;gl_Position=projection*vec4(viewPos,1.0);uv=offset;diffuseColor=color.rgb;}
`, re.ShadersStore.fluidRenderingParticleDiffusePixelShader = `uniform float particleAlpha;varying vec2 uv;varying vec3 diffuseColor;void main(void) {vec3 normal;normal.xy=uv*2.0-1.0;float r2=dot(normal.xy,normal.xy);if (r2>1.0) discard;glFragColor=vec4(diffuseColor,1.0);}
`, re.ShadersStore.fluidRenderingBilateralBlurPixelShader = `uniform sampler2D textureSampler;uniform int maxFilterSize;uniform vec2 blurDir;uniform float projectedParticleConstant;uniform float depthThreshold;varying vec2 vUV;void main(void) {float depth=textureLod(textureSampler,vUV,0.).x;if (depth>=1e6 || depth<=0.) {glFragColor=vec4(vec3(depth),1.);return;}
int filterSize=min(maxFilterSize,int(ceil(projectedParticleConstant/depth)));float sigma=float(filterSize)/3.0;float two_sigma2=2.0*sigma*sigma;float sigmaDepth=depthThreshold/3.0;float two_sigmaDepth2=2.0*sigmaDepth*sigmaDepth;float sum=0.;float wsum=0.;float sumVel=0.;for (int x=-filterSize; x<=filterSize; ++x) {vec2 coords=vec2(x);vec2 sampleDepthVel=textureLod(textureSampler,vUV+coords*blurDir,0.).rg;float r=dot(coords,coords);float w=exp(-r/two_sigma2);float rDepth=sampleDepthVel.r-depth;float wd=exp(-rDepth*rDepth/two_sigmaDepth2);sum+=sampleDepthVel.r*w*wd;sumVel+=sampleDepthVel.g*w*wd;wsum+=w*wd;}
glFragColor=vec4(sum/wsum,sumVel/wsum,0.,1.);}
`, re.ShadersStore.fluidRenderingStandardBlurPixelShader = `uniform sampler2D textureSampler;uniform int filterSize;uniform vec2 blurDir;varying vec2 vUV;void main(void) {vec4 s=textureLod(textureSampler,vUV,0.);if (s.r==0.) {glFragColor=vec4(0.,0.,0.,1.);return;}
float sigma=float(filterSize)/3.0;float twoSigma2=2.0*sigma*sigma;vec4 sum=vec4(0.);float wsum=0.;for (int x=-filterSize; x<=filterSize; ++x) {vec2 coords=vec2(x);vec4 sampl=textureLod(textureSampler,vUV+coords*blurDir,0.);float w=exp(-coords.x*coords.x/twoSigma2);sum+=sampl*w;wsum+=w;}
sum/=wsum;glFragColor=vec4(sum.rgb,1.);}
`;
    function DN(n) {
      return !!n.particleSystem;
    }
    re.ShadersStore.fluidRenderingRenderPixelShader = `/* disable_uniformity_analysis */
#define IOR 1.333
#define ETA 1.0/IOR
#define F0 0.02
uniform sampler2D textureSampler;uniform sampler2D depthSampler;
#ifdef FLUIDRENDERING_DIFFUSETEXTURE
uniform sampler2D diffuseSampler;
#else
uniform vec3 diffuseColor;
#endif
#ifdef FLUIDRENDERING_FIXED_THICKNESS
uniform float thickness;uniform sampler2D bgDepthSampler;
#else
uniform float minimumThickness;uniform sampler2D thicknessSampler;
#endif
#ifdef FLUIDRENDERING_ENVIRONMENT
uniform samplerCube reflectionSampler;
#endif
#if defined(FLUIDRENDERING_DEBUG) && defined(FLUIDRENDERING_DEBUG_TEXTURE)
uniform sampler2D debugSampler;
#endif
uniform mat4 viewMatrix;uniform mat4 projectionMatrix;uniform mat4 invProjectionMatrix;uniform vec2 texelSize;uniform vec3 dirLight;uniform float cameraFar;uniform float density;uniform float refractionStrength;uniform float fresnelClamp;uniform float specularPower;varying vec2 vUV;vec3 computeViewPosFromUVDepth(vec2 texCoord,float depth) {vec4 ndc;ndc.xy=texCoord*2.0-1.0;
#ifdef FLUIDRENDERING_RHS
ndc.z=-projectionMatrix[2].z+projectionMatrix[3].z/depth;
#else
ndc.z=projectionMatrix[2].z+projectionMatrix[3].z/depth;
#endif
ndc.w=1.0;vec4 eyePos=invProjectionMatrix*ndc;eyePos.xyz/=eyePos.w;return eyePos.xyz;}
vec3 getViewPosFromTexCoord(vec2 texCoord) {float depth=textureLod(depthSampler,texCoord,0.).x;return computeViewPosFromUVDepth(texCoord,depth);}
void main(void) {vec2 texCoord=vUV;
#if defined(FLUIDRENDERING_DEBUG) && defined(FLUIDRENDERING_DEBUG_TEXTURE)
vec4 color=texture2D(debugSampler,texCoord);
#ifdef FLUIDRENDERING_DEBUG_DEPTH
glFragColor=vec4(color.rgb/vec3(2.0),1.);if (color.r>0.999 && color.g>0.999) {glFragColor=texture2D(textureSampler,texCoord);}
#else
glFragColor=vec4(color.rgb,1.);if (color.r<0.001 && color.g<0.001 && color.b<0.001) {glFragColor=texture2D(textureSampler,texCoord);}
#endif
return;
#endif
vec2 depthVel=textureLod(depthSampler,texCoord,0.).rg;float depth=depthVel.r;
#ifndef FLUIDRENDERING_FIXED_THICKNESS
float thickness=texture2D(thicknessSampler,texCoord).x;
#else
float bgDepth=texture2D(bgDepthSampler,texCoord).x;float depthNonLinear=projectionMatrix[2].z+projectionMatrix[3].z/depth;depthNonLinear=depthNonLinear*0.5+0.5;
#endif
vec4 backColor=texture2D(textureSampler,texCoord);
#ifndef FLUIDRENDERING_FIXED_THICKNESS
if (depth>=cameraFar || depth<=0. || thickness<=minimumThickness) {
#else
if (depth>=cameraFar || depth<=0. || bgDepth<=depthNonLinear) {
#endif
glFragColor=backColor;return;}
vec3 viewPos=computeViewPosFromUVDepth(texCoord,depth);vec3 ddx=getViewPosFromTexCoord(texCoord+vec2(texelSize.x,0.))-viewPos;vec3 ddy=getViewPosFromTexCoord(texCoord+vec2(0.,texelSize.y))-viewPos;vec3 ddx2=viewPos-getViewPosFromTexCoord(texCoord+vec2(-texelSize.x,0.));if (abs(ddx.z)>abs(ddx2.z)) {ddx=ddx2;}
vec3 ddy2=viewPos-getViewPosFromTexCoord(texCoord+vec2(0.,-texelSize.y));if (abs(ddy.z)>abs(ddy2.z)) {ddy=ddy2;}
vec3 normal=normalize(cross(ddy,ddx));
#ifdef FLUIDRENDERING_RHS
normal=-normal;
#endif
#ifndef WEBGPU
if(isnan(normal.x) || isnan(normal.y) || isnan(normal.z) || isinf(normal.x) || isinf(normal.y) || isinf(normal.z)) {normal=vec3(0.,0.,-1.);}
#endif
#if defined(FLUIDRENDERING_DEBUG) && defined(FLUIDRENDERING_DEBUG_SHOWNORMAL)
glFragColor=vec4(normal*0.5+0.5,1.0);return;
#endif
vec3 rayDir=normalize(viewPos); 
#ifdef FLUIDRENDERING_DIFFUSETEXTURE
vec3 diffuseColor=textureLod(diffuseSampler,texCoord,0.0).rgb;
#endif
vec3 lightDir=normalize(vec3(viewMatrix*vec4(-dirLight,0.)));vec3 H =normalize(lightDir-rayDir);float specular=pow(max(0.0,dot(H,normal)),specularPower);
#ifdef FLUIDRENDERING_DEBUG_DIFFUSERENDERING
float diffuse =max(0.0,dot(lightDir,normal))*1.0;glFragColor=vec4(vec3(0.1) /*ambient*/+vec3(0.42,0.50,1.00)*diffuse+vec3(0,0,0.2)+specular,1.);return;
#endif
vec3 refractionDir=refract(rayDir,normal,ETA);vec4 transmitted=textureLod(textureSampler,vec2(texCoord+refractionDir.xy*thickness*refractionStrength),0.0);vec3 transmittance=exp(-density*thickness*(1.0-diffuseColor)); 
vec3 refractionColor=transmitted.rgb*transmittance;
#ifdef FLUIDRENDERING_ENVIRONMENT
vec3 reflectionDir=reflect(rayDir,normal);vec3 reflectionColor=(textureCube(reflectionSampler,reflectionDir).rgb);float fresnel=clamp(F0+(1.0-F0)*pow(1.0-dot(normal,-rayDir),5.0),0.,fresnelClamp);vec3 finalColor=mix(refractionColor,reflectionColor,fresnel)+specular;
#else
vec3 finalColor=refractionColor+specular;
#endif
#ifdef FLUIDRENDERING_VELOCITY
float velocity=depthVel.g;finalColor=mix(finalColor,vec3(1.0),smoothstep(0.3,1.0,velocity/6.0));
#endif
glFragColor=vec4(finalColor,transmitted.a);}
`, Object.defineProperty(Ue.prototype, "fluidRenderer", { get: function() {
      return this._fluidRenderer;
    }, set: function(n) {
      this._fluidRenderer = n;
    }, enumerable: !0, configurable: !0 }), Ue.prototype.enableFluidRenderer = function() {
      return this._fluidRenderer || (this._fluidRenderer = new PE(this)), this._fluidRenderer;
    }, Ue.prototype.disableFluidRenderer = function() {
      var n;
      (n = this._fluidRenderer) === null || n === void 0 || n.dispose(), this._fluidRenderer = null;
    };
    var CE = function() {
      function n(t) {
        this.name = we.NAME_FLUIDRENDERER, this.scene = t;
      }
      return n.prototype.register = function() {
        this.scene._gatherActiveCameraRenderTargetsStage.registerStep(we.STEP_GATHERACTIVECAMERARENDERTARGETS_FLUIDRENDERER, this, this._gatherActiveCameraRenderTargets), this.scene._afterCameraDrawStage.registerStep(we.STEP_AFTERCAMERADRAW_FLUIDRENDERER, this, this._afterCameraDraw);
      }, n.prototype._gatherActiveCameraRenderTargets = function(t) {
        var e;
        (e = this.scene.fluidRenderer) === null || e === void 0 || e._prepareRendering();
      }, n.prototype._afterCameraDraw = function(t) {
        var e;
        (e = this.scene.fluidRenderer) === null || e === void 0 || e._render(t);
      }, n.prototype.rebuild = function() {
        this.scene._fluidRenderer && (this.scene.disableFluidRenderer(), this.scene.enableFluidRenderer());
      }, n.prototype.dispose = function() {
        this.scene.disableFluidRenderer();
      }, n;
    }(), PE = function() {
      function n(t) {
        var e = this;
        this._scene = t, this._engine = t.getEngine(), this._onEngineResizeObserver = null, this.renderObjects = [], this.targetRenderers = [], this._cameras = /* @__PURE__ */ new Map(), n._SceneComponentInitialization(this._scene), this._onEngineResizeObserver = this._engine.onResizeObservable.add(function() {
          e._initialize();
        });
      }
      return n._SceneComponentInitialization = function(t) {
        var e = t._getComponent(we.NAME_FLUIDRENDERER);
        e || (e = new CE(t), t._addComponent(e));
      }, n.prototype.recreate = function() {
        this._sortRenderingObjects(), this._initialize();
      }, n.prototype.getRenderObjectFromParticleSystem = function(t) {
        var e = this._getParticleSystemIndex(t);
        return e !== -1 ? this.renderObjects[e] : null;
      }, n.prototype.addParticleSystem = function(t, e, i, r) {
        var o = this, a = new SE(this._scene, t);
        a.onParticleSizeChanged.add(function() {
          return o._setParticleSizeForRenderTargets();
        }), i || (i = new gm(this._scene, r), this.targetRenderers.push(i)), i._onUseVelocityChanged.hasObservers() || i._onUseVelocityChanged.add(function() {
          return o._setUseVelocityForRenderObject();
        }), e !== void 0 && (i.generateDiffuseTexture = e);
        var s = { object: a, targetRenderer: i };
        return this.renderObjects.push(s), this._sortRenderingObjects(), this._setParticleSizeForRenderTargets(), s;
      }, n.prototype.addCustomParticles = function(t, e, i, r, o) {
        var a = this, s = new AE(this._scene, t, e);
        s.onParticleSizeChanged.add(function() {
          return a._setParticleSizeForRenderTargets();
        }), r || (r = new gm(this._scene, o), this.targetRenderers.push(r)), r._onUseVelocityChanged.hasObservers() || r._onUseVelocityChanged.add(function() {
          return a._setUseVelocityForRenderObject();
        }), i !== void 0 && (r.generateDiffuseTexture = i);
        var l = { object: s, targetRenderer: r };
        return this.renderObjects.push(l), this._sortRenderingObjects(), this._setParticleSizeForRenderTargets(), l;
      }, n.prototype.removeRenderObject = function(t, e) {
        e === void 0 && (e = !0);
        var i = this.renderObjects.indexOf(t);
        return i !== -1 && (t.object.dispose(), this.renderObjects.splice(i, 1), e && this._removeUnusedTargetRenderers() ? this._initialize() : this._setParticleSizeForRenderTargets(), !0);
      }, n.prototype._sortRenderingObjects = function() {
        this.renderObjects.sort(function(t, e) {
          return t.object.priority < e.object.priority ? -1 : t.object.priority > e.object.priority ? 1 : 0;
        });
      }, n.prototype._removeUnusedTargetRenderers = function() {
        for (var t, e = {}, i = 0; i < this.renderObjects.length; ++i) {
          var r = this.renderObjects[i].targetRenderer;
          e[this.targetRenderers.indexOf(r)] = !0;
        }
        var o = !1, a = [];
        for (i = 0; i < this.targetRenderers.length; ++i)
          e[i] ? a.push(this.targetRenderers[i]) : (this.targetRenderers[i].dispose(), o = !0);
        return o && (this.targetRenderers.length = 0, (t = this.targetRenderers).push.apply(t, a)), o;
      }, n.prototype._getParticleSystemIndex = function(t) {
        for (var e = 0; e < this.renderObjects.length; ++e) {
          var i = this.renderObjects[e].object;
          if (DN(i) && i.particleSystem === t)
            return e;
        }
        return -1;
      }, n.prototype._initialize = function() {
        for (var t = this, e = 0; e < this.targetRenderers.length; ++e)
          this.targetRenderers[e].dispose();
        var i = /* @__PURE__ */ new Map();
        for (e = 0; e < this.targetRenderers.length; ++e) {
          var r = this.targetRenderers[e];
          r._initialize(), r.camera && r._renderPostProcess && ((l = i.get(r.camera)) || (l = [[], {}], i.set(r.camera, l)), l[0].push(r), r.camera.attachPostProcess(r._renderPostProcess, e));
        }
        for (var o = i.keys(), a = function(f) {
          var m = f.value, g = i.get(m), y = m._getFirstPostProcess();
          if (!y)
            return "continue";
          var b = g[0], T = g[1];
          y.onSizeChangedObservable.add(function() {
            var S;
            y.inputTexture.depthStencilTexture || y.inputTexture.createDepthStencilTexture(0, !0, t._engine.isStencilEnable, b[0].samples, t._engine.isStencilEnable ? _.TEXTUREFORMAT_DEPTH24_STENCIL8 : _.TEXTUREFORMAT_DEPTH32_FLOAT, "PostProcessRTTDepthStencil-".concat(y.name));
            for (var E = 0, A = b; E < A.length; E++) {
              var R = (S = A[E]._thicknessRenderTarget) === null || S === void 0 ? void 0 : S.renderTarget, C = R == null ? void 0 : R.texture;
              if (R && C) {
                var L = C.width + "_" + C.height, I = T[L];
                I || (I = T[L] = new ON(t._engine, C.width, C.height)), I.depthRTWrapper._shareDepth(R);
              }
            }
          });
        }, s = o.next(); s.done !== !0; s = o.next())
          a(s);
        for (s = (o = this._cameras.keys()).next(); s.done !== !0; s = o.next()) {
          var l, c = s.value, u = (l = this._cameras.get(c))[1], h = i.get(c);
          if (h)
            for (var d in u)
              h[1][d] || u[d].dispose();
          else
            for (var p in u)
              u[p].dispose();
        }
        this._cameras.clear(), this._cameras = i, this._setParticleSizeForRenderTargets();
      }, n.prototype._setParticleSizeForRenderTargets = function() {
        for (var t = /* @__PURE__ */ new Map(), e = 0; e < this.renderObjects.length; ++e) {
          var i = this.renderObjects[e], r = t.get(i.targetRenderer);
          r === void 0 && (r = 0), t.set(i.targetRenderer, Math.max(r, i.object.particleSize));
        }
        t.forEach(function(o, a) {
          a._depthRenderTarget && (a._depthRenderTarget.particleSize = o);
        });
      }, n.prototype._setUseVelocityForRenderObject = function() {
        for (var t = 0, e = this.renderObjects; t < e.length; t++) {
          var i = e[t];
          i.object.useVelocity = i.targetRenderer.useVelocity;
        }
      }, n.prototype._prepareRendering = function() {
        for (var t = 0, e = this.targetRenderers; t < e.length; t++)
          if (e[t].needInitialization)
            return void this._initialize();
      }, n.prototype._render = function(t) {
        for (var e, i = 0; i < this.targetRenderers.length; ++i)
          t && this.targetRenderers[i].camera !== t || this.targetRenderers[i]._clearTargets();
        for (var r = this._cameras.keys(), o = r.next(); o.done !== !0; o = r.next()) {
          var a = o.value, s = this._cameras.get(a);
          if (!t || a === t) {
            var l = a._getFirstPostProcess();
            if (l) {
              var c = (e = l.inputTexture) === null || e === void 0 ? void 0 : e.depthStencilTexture;
              if (c) {
                for (var u = s[0], h = s[1], d = 0, p = u; d < p.length; d++)
                  p[d]._bgDepthTexture = c;
                for (var f in h)
                  h[f].copy(c);
              }
            }
          }
        }
        for (i = 0; i < this.renderObjects.length; ++i) {
          var m = this.renderObjects[i];
          t && m.targetRenderer.camera !== t || m.targetRenderer._render(m.object);
        }
      }, n.prototype.dispose = function() {
        this._engine.onResizeObservable.remove(this._onEngineResizeObserver), this._onEngineResizeObserver = null;
        for (var t = 0; t < this.renderObjects.length; ++t)
          this.renderObjects[t].object.dispose();
        for (t = 0; t < this.targetRenderers.length; ++t)
          this.targetRenderers[t].dispose();
        this._cameras.forEach(function(e) {
          var i = e[1];
          for (var r in i)
            i[r].dispose();
        }), this.renderObjects = [], this.targetRenderers = [], this._cameras.clear();
      }, n;
    }(), IE = function(n) {
      function t(e, i) {
        var r = n.call(this) || this;
        return r.name = e, r.animations = new Array(), r.isPickable = !1, r.useAlphaForPicking = !1, r.onDisposeObservable = new H(), r._onAnimationEnd = null, r._endAnimation = function() {
          r._onAnimationEnd && r._onAnimationEnd(), r.disposeWhenFinishedAnimating && r.dispose();
        }, r.color = new Ie(1, 1, 1, 1), r.position = v.Zero(), r._manager = i, r._manager.sprites.push(r), r.uniqueId = r._manager.scene.getUniqueId(), r;
      }
      return D(t, n), Object.defineProperty(t.prototype, "size", { get: function() {
        return this.width;
      }, set: function(e) {
        this.width = e, this.height = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "manager", { get: function() {
        return this._manager;
      }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
        return "Sprite";
      }, Object.defineProperty(t.prototype, "fromIndex", { get: function() {
        return this._fromIndex;
      }, set: function(e) {
        this.playAnimation(e, this._toIndex, this._loopAnimation, this._delay, this._onAnimationEnd);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "toIndex", { get: function() {
        return this._toIndex;
      }, set: function(e) {
        this.playAnimation(this._fromIndex, e, this._loopAnimation, this._delay, this._onAnimationEnd);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "loopAnimation", { get: function() {
        return this._loopAnimation;
      }, set: function(e) {
        this.playAnimation(this._fromIndex, this._toIndex, e, this._delay, this._onAnimationEnd);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "delay", { get: function() {
        return Math.max(this._delay, 1);
      }, set: function(e) {
        this.playAnimation(this._fromIndex, this._toIndex, this._loopAnimation, e, this._onAnimationEnd);
      }, enumerable: !1, configurable: !0 }), t.prototype.playAnimation = function(e, i, r, o, a) {
        a === void 0 && (a = null), this._onAnimationEnd = a, n.prototype.playAnimation.call(this, e, i, r, o, this._endAnimation);
      }, t.prototype.dispose = function() {
        for (var e = 0; e < this._manager.sprites.length; e++)
          this._manager.sprites[e] == this && this._manager.sprites.splice(e, 1);
        this.onDisposeObservable.notifyObservers(this), this.onDisposeObservable.clear();
      }, t.prototype.serialize = function() {
        var e = {};
        return e.name = this.name, e.position = this.position.asArray(), e.color = this.color.asArray(), e.width = this.width, e.height = this.height, e.angle = this.angle, e.cellIndex = this.cellIndex, e.cellRef = this.cellRef, e.invertU = this.invertU, e.invertV = this.invertV, e.disposeWhenFinishedAnimating = this.disposeWhenFinishedAnimating, e.isPickable = this.isPickable, e.isVisible = this.isVisible, e.useAlphaForPicking = this.useAlphaForPicking, e.animationStarted = this.animationStarted, e.fromIndex = this.fromIndex, e.toIndex = this.toIndex, e.loopAnimation = this.loopAnimation, e.delay = this.delay, e;
      }, t.Parse = function(e, i) {
        var r = new t(e.name, i);
        return r.position = v.FromArray(e.position), r.color = Ie.FromArray(e.color), r.width = e.width, r.height = e.height, r.angle = e.angle, r.cellIndex = e.cellIndex, r.cellRef = e.cellRef, r.invertU = e.invertU, r.invertV = e.invertV, r.disposeWhenFinishedAnimating = e.disposeWhenFinishedAnimating, r.isPickable = e.isPickable, r.isVisible = e.isVisible, r.useAlphaForPicking = e.useAlphaForPicking, r._fromIndex = e.fromIndex, r._toIndex = e.toIndex, r._loopAnimation = e.loopAnimation, r._delay = e.delay, e.animationStarted && r.playAnimation(r.fromIndex, r.toIndex, r.loopAnimation, r.delay), r;
      }, t;
    }(function() {
      function n() {
        this.width = 1, this.height = 1, this.angle = 0, this.invertU = !1, this.invertV = !1, this.isVisible = !0, this._animationStarted = !1, this._loopAnimation = !1, this._fromIndex = 0, this._toIndex = 0, this._delay = 0, this._direction = 1, this._time = 0, this._onBaseAnimationEnd = null, this.position = { x: 1, y: 1, z: 1 }, this.color = { r: 1, g: 1, b: 1, a: 1 };
      }
      return Object.defineProperty(n.prototype, "animationStarted", { get: function() {
        return this._animationStarted;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "fromIndex", { get: function() {
        return this._fromIndex;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "toIndex", { get: function() {
        return this._toIndex;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "loopAnimation", { get: function() {
        return this._loopAnimation;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "delay", { get: function() {
        return Math.max(this._delay, 1);
      }, enumerable: !1, configurable: !0 }), n.prototype.playAnimation = function(t, e, i, r, o) {
        this._fromIndex = t, this._toIndex = e, this._loopAnimation = i, this._delay = r || 1, this._animationStarted = !0, this._onBaseAnimationEnd = o, t < e ? this._direction = 1 : (this._direction = -1, this._toIndex = t, this._fromIndex = e), this.cellIndex = t, this._time = 0;
      }, n.prototype.stopAnimation = function() {
        this._animationStarted = !1;
      }, n.prototype._animate = function(t) {
        this._animationStarted && (this._time += t, this._time > this._delay && (this._time = this._time % this._delay, this.cellIndex += this._direction, (this._direction > 0 && this.cellIndex > this._toIndex || this._direction < 0 && this.cellIndex < this._fromIndex) && (this._loopAnimation ? this.cellIndex = this._direction > 0 ? this._fromIndex : this._toIndex : (this.cellIndex = this._toIndex, this._animationStarted = !1, this._onBaseAnimationEnd && this._onBaseAnimationEnd()))));
      }, n;
    }());
    Ue.prototype._internalPickSprites = function(n, t, e, i) {
      if (!Ki)
        return null;
      var r = null;
      if (!i) {
        if (!this.activeCamera)
          return null;
        i = this.activeCamera;
      }
      if (this.spriteManagers && this.spriteManagers.length > 0)
        for (var o = 0; o < this.spriteManagers.length; o++) {
          var a = this.spriteManagers[o];
          if (a.isPickable) {
            var s = a.intersects(n, i, t, e);
            if (s && s.hit && (e || r == null || !(s.distance >= r.distance)) && (r = s, e))
              break;
          }
        }
      return r || new Ki();
    }, Ue.prototype._internalMultiPickSprites = function(n, t, e) {
      if (!Ki)
        return null;
      var i = [];
      if (!e) {
        if (!this.activeCamera)
          return null;
        e = this.activeCamera;
      }
      if (this.spriteManagers && this.spriteManagers.length > 0)
        for (var r = 0; r < this.spriteManagers.length; r++) {
          var o = this.spriteManagers[r];
          if (o.isPickable) {
            var a = o.multiIntersects(n, e, t);
            a !== null && (i = i.concat(a));
          }
        }
      return i;
    }, Ue.prototype.pickSprite = function(n, t, e, i, r) {
      if (!this._tempSpritePickingRay)
        return null;
      this.createPickingRayInCameraSpaceToRef(n, t, this._tempSpritePickingRay, r);
      var o = this._internalPickSprites(this._tempSpritePickingRay, e, i, r);
      return o && (o.ray = this.createPickingRayInCameraSpace(n, t, r)), o;
    }, Ue.prototype.pickSpriteWithRay = function(n, t, e, i) {
      if (!this._tempSpritePickingRay)
        return null;
      if (!i) {
        if (!this.activeCamera)
          return null;
        i = this.activeCamera;
      }
      gi.TransformToRef(n, i.getViewMatrix(), this._tempSpritePickingRay);
      var r = this._internalPickSprites(this._tempSpritePickingRay, t, e, i);
      return r && (r.ray = n), r;
    }, Ue.prototype.multiPickSprite = function(n, t, e, i) {
      return this.createPickingRayInCameraSpaceToRef(n, t, this._tempSpritePickingRay, i), this._internalMultiPickSprites(this._tempSpritePickingRay, e, i);
    }, Ue.prototype.multiPickSpriteWithRay = function(n, t, e) {
      if (!this._tempSpritePickingRay)
        return null;
      if (!e) {
        if (!this.activeCamera)
          return null;
        e = this.activeCamera;
      }
      return gi.TransformToRef(n, e.getViewMatrix(), this._tempSpritePickingRay), this._internalMultiPickSprites(this._tempSpritePickingRay, t, e);
    }, Ue.prototype.setPointerOverSprite = function(n) {
      this._pointerOverSprite !== n && (this._pointerOverSprite && this._pointerOverSprite.actionManager && this._pointerOverSprite.actionManager.processTrigger(_.ACTION_OnPointerOutTrigger, mi.CreateNewFromSprite(this._pointerOverSprite, this)), this._pointerOverSprite = n, this._pointerOverSprite && this._pointerOverSprite.actionManager && this._pointerOverSprite.actionManager.processTrigger(_.ACTION_OnPointerOverTrigger, mi.CreateNewFromSprite(this._pointerOverSprite, this)));
    }, Ue.prototype.getPointerOverSprite = function() {
      return this._pointerOverSprite;
    };
    var ME = function() {
      function n(t) {
        this.name = we.NAME_SPRITE, this.scene = t, this.scene.spriteManagers = [], this.scene._tempSpritePickingRay = gi ? gi.Zero() : null, this.scene.onBeforeSpritesRenderingObservable = new H(), this.scene.onAfterSpritesRenderingObservable = new H(), this._spritePredicate = function(e) {
          return !!e.actionManager && e.isPickable && e.actionManager.hasPointerTriggers;
        };
      }
      return n.prototype.register = function() {
        this.scene._pointerMoveStage.registerStep(we.STEP_POINTERMOVE_SPRITE, this, this._pointerMove), this.scene._pointerDownStage.registerStep(we.STEP_POINTERDOWN_SPRITE, this, this._pointerDown), this.scene._pointerUpStage.registerStep(we.STEP_POINTERUP_SPRITE, this, this._pointerUp);
      }, n.prototype.rebuild = function() {
      }, n.prototype.dispose = function() {
        this.scene.onBeforeSpritesRenderingObservable.clear(), this.scene.onAfterSpritesRenderingObservable.clear();
        var t = this.scene.spriteManagers;
        if (t)
          for (; t.length; )
            t[0].dispose();
      }, n.prototype._pickSpriteButKeepRay = function(t, e, i, r, o) {
        var a = this.scene.pickSprite(e, i, this._spritePredicate, r, o);
        return a && (a.ray = t ? t.ray : null), a;
      }, n.prototype._pointerMove = function(t, e, i, r, o) {
        var a = this.scene;
        return r ? a.setPointerOverSprite(null) : (i = this._pickSpriteButKeepRay(i, t, e, !1, a.cameraToUseForPointers || void 0)) && i.hit && i.pickedSprite ? (a.setPointerOverSprite(i.pickedSprite), !a.doNotHandleCursors && o && (a._pointerOverSprite && a._pointerOverSprite.actionManager && a._pointerOverSprite.actionManager.hoverCursor ? o.style.cursor = a._pointerOverSprite.actionManager.hoverCursor : o.style.cursor = a.hoverCursor)) : a.setPointerOverSprite(null), i;
      }, n.prototype._pointerDown = function(t, e, i, r) {
        var o = this.scene;
        if (o._pickedDownSprite = null, o.spriteManagers && o.spriteManagers.length > 0 && (i = o.pickSprite(t, e, this._spritePredicate, !1, o.cameraToUseForPointers || void 0)) && i.hit && i.pickedSprite && i.pickedSprite.actionManager) {
          switch (o._pickedDownSprite = i.pickedSprite, r.button) {
            case 0:
              i.pickedSprite.actionManager.processTrigger(_.ACTION_OnLeftPickTrigger, mi.CreateNewFromSprite(i.pickedSprite, o, r));
              break;
            case 1:
              i.pickedSprite.actionManager.processTrigger(_.ACTION_OnCenterPickTrigger, mi.CreateNewFromSprite(i.pickedSprite, o, r));
              break;
            case 2:
              i.pickedSprite.actionManager.processTrigger(_.ACTION_OnRightPickTrigger, mi.CreateNewFromSprite(i.pickedSprite, o, r));
          }
          i.pickedSprite.actionManager && i.pickedSprite.actionManager.processTrigger(_.ACTION_OnPickDownTrigger, mi.CreateNewFromSprite(i.pickedSprite, o, r));
        }
        return i;
      }, n.prototype._pointerUp = function(t, e, i, r, o) {
        var a = this.scene;
        if (a.spriteManagers && a.spriteManagers.length > 0) {
          var s = a.pickSprite(t, e, this._spritePredicate, !1, a.cameraToUseForPointers || void 0);
          s && (s.hit && s.pickedSprite && s.pickedSprite.actionManager && (s.pickedSprite.actionManager.processTrigger(_.ACTION_OnPickUpTrigger, mi.CreateNewFromSprite(s.pickedSprite, a, r)), s.pickedSprite.actionManager && (this.scene._inputManager._isPointerSwiping() || s.pickedSprite.actionManager.processTrigger(_.ACTION_OnPickTrigger, mi.CreateNewFromSprite(s.pickedSprite, a, r)), o && s.pickedSprite.actionManager.processTrigger(_.ACTION_OnDoublePickTrigger, mi.CreateNewFromSprite(s.pickedSprite, a, r)))), a._pickedDownSprite && a._pickedDownSprite.actionManager && a._pickedDownSprite !== s.pickedSprite && a._pickedDownSprite.actionManager.processTrigger(_.ACTION_OnPickOutTrigger, mi.CreateNewFromSprite(a._pickedDownSprite, a, r)));
        }
        return i;
      }, n;
    }();
    re.IncludesShadersStore.imageProcessingCompatibility = `#ifdef IMAGEPROCESSINGPOSTPROCESS
gl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(2.2));
#endif
`, re.ShadersStore.spritesPixelShader = `uniform bool alphaTest;varying vec4 vColor;varying vec2 vUV;uniform sampler2D diffuseSampler;
#include<fogFragmentDeclaration>
#define CUSTOM_FRAGMENT_DEFINITIONS
#ifdef PIXEL_PERFECT
vec2 uvPixelPerfect(vec2 uv) {vec2 res=vec2(textureSize(diffuseSampler,0));uv=uv*res;vec2 seam=floor(uv+0.5);uv=seam+clamp((uv-seam)/fwidth(uv),-0.5,0.5);return uv/res;}
#endif
void main(void) {
#define CUSTOM_FRAGMENT_MAIN_BEGIN
#ifdef PIXEL_PERFECT
vec2 uv=uvPixelPerfect(vUV);
#else
vec2 uv=vUV;
#endif
vec4 color=texture2D(diffuseSampler,uv);float fAlphaTest=float(alphaTest);if (fAlphaTest != 0.)
{if (color.a<0.95)
discard;}
color*=vColor;
#include<fogFragment>
gl_FragColor=color;
#include<imageProcessingCompatibility>
#define CUSTOM_FRAGMENT_MAIN_END
}`, re.ShadersStore.spritesVertexShader = `attribute vec4 position;attribute vec2 options;attribute vec2 offsets;attribute vec2 inverts;attribute vec4 cellInfo;attribute vec4 color;uniform mat4 view;uniform mat4 projection;varying vec2 vUV;varying vec4 vColor;
#include<fogVertexDeclaration>
#define CUSTOM_VERTEX_DEFINITIONS
void main(void) {
#define CUSTOM_VERTEX_MAIN_BEGIN
vec3 viewPos=(view*vec4(position.xyz,1.0)).xyz; 
vec2 cornerPos;float angle=position.w;vec2 size=vec2(options.x,options.y);vec2 offset=offsets.xy;cornerPos=vec2(offset.x-0.5,offset.y -0.5)*size;vec3 rotatedCorner;rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.z=0.;viewPos+=rotatedCorner;gl_Position=projection*vec4(viewPos,1.0); 
vColor=color;vec2 uvOffset=vec2(abs(offset.x-inverts.x),abs(1.0-offset.y-inverts.y));vec2 uvPlace=cellInfo.xy;vec2 uvSize=cellInfo.zw;vUV.x=uvPlace.x+uvSize.x*uvOffset.x;vUV.y=uvPlace.y+uvSize.y*uvOffset.y;
#ifdef FOG
vFogDistance=viewPos;
#endif
#define CUSTOM_VERTEX_MAIN_END
}`;
    var NN = function() {
      function n(t, e, i, r) {
        i === void 0 && (i = 0.01), r === void 0 && (r = null), this.blendMode = _.ALPHA_COMBINE, this.autoResetAlpha = !0, this.disableDepthWrite = !1, this.fogEnabled = !0, this._pixelPerfect = !1, this._useVAO = !1, this._useInstancing = !1, this._vertexBuffers = {}, this._capacity = e, this._epsilon = i, this._engine = t, this._useInstancing = t.getCaps().instancedArrays && t._features.supportSpriteInstancing, this._useVAO = t.getCaps().vertexArrayObject && !t.disableVertexArrayObjects, this._scene = r, this._useInstancing || this._buildIndexBuffer(), this._vertexBufferSize = this._useInstancing ? 16 : 18, this._vertexData = new Float32Array(e * this._vertexBufferSize * (this._useInstancing ? 1 : 4)), this._buffer = new Yi(t, this._vertexData, !0, this._vertexBufferSize);
        var o, a = this._buffer.createVertexBuffer(P.PositionKind, 0, 4, this._vertexBufferSize, this._useInstancing), s = this._buffer.createVertexBuffer("options", 4, 2, this._vertexBufferSize, this._useInstancing), l = 6;
        if (this._useInstancing) {
          var c = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]);
          this._spriteBuffer = new Yi(t, c, !1, 2), o = this._spriteBuffer.createVertexBuffer("offsets", 0, 2);
        } else
          o = this._buffer.createVertexBuffer("offsets", l, 2, this._vertexBufferSize, this._useInstancing), l += 2;
        var u = this._buffer.createVertexBuffer("inverts", l, 2, this._vertexBufferSize, this._useInstancing), h = this._buffer.createVertexBuffer("cellInfo", l + 2, 4, this._vertexBufferSize, this._useInstancing), d = this._buffer.createVertexBuffer(P.ColorKind, l + 6, 4, this._vertexBufferSize, this._useInstancing);
        this._vertexBuffers[P.PositionKind] = a, this._vertexBuffers.options = s, this._vertexBuffers.offsets = o, this._vertexBuffers.inverts = u, this._vertexBuffers.cellInfo = h, this._vertexBuffers[P.ColorKind] = d, this._createEffects();
      }
      return Object.defineProperty(n.prototype, "capacity", { get: function() {
        return this._capacity;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "pixelPerfect", { get: function() {
        return this._pixelPerfect;
      }, set: function(t) {
        this._pixelPerfect !== t && (this._pixelPerfect = t, this._createEffects());
      }, enumerable: !1, configurable: !0 }), n.prototype._createEffects = function() {
        var t, e, i, r;
        (t = this._drawWrapperBase) === null || t === void 0 || t.dispose(), (e = this._drawWrapperFog) === null || e === void 0 || e.dispose(), (i = this._drawWrapperDepth) === null || i === void 0 || i.dispose(), (r = this._drawWrapperFogDepth) === null || r === void 0 || r.dispose(), this._drawWrapperBase = new Ei(this._engine), this._drawWrapperFog = new Ei(this._engine), this._drawWrapperDepth = new Ei(this._engine, !1), this._drawWrapperFogDepth = new Ei(this._engine, !1), this._drawWrapperBase.drawContext && (this._drawWrapperBase.drawContext.useInstancing = this._useInstancing), this._drawWrapperFog.drawContext && (this._drawWrapperFog.drawContext.useInstancing = this._useInstancing), this._drawWrapperDepth.drawContext && (this._drawWrapperDepth.drawContext.useInstancing = this._useInstancing), this._drawWrapperFogDepth.drawContext && (this._drawWrapperFogDepth.drawContext.useInstancing = this._useInstancing);
        var o = this._pixelPerfect ? `#define PIXEL_PERFECT
` : "";
        this._drawWrapperBase.effect = this._engine.createEffect("sprites", [P.PositionKind, "options", "offsets", "inverts", "cellInfo", P.ColorKind], ["view", "projection", "textureInfos", "alphaTest"], ["diffuseSampler"], o), this._drawWrapperDepth.effect = this._drawWrapperBase.effect, this._drawWrapperDepth.materialContext = this._drawWrapperBase.materialContext, this._scene && (this._drawWrapperFog.effect = this._scene.getEngine().createEffect("sprites", [P.PositionKind, "options", "offsets", "inverts", "cellInfo", P.ColorKind], ["view", "projection", "textureInfos", "alphaTest", "vFogInfos", "vFogColor"], ["diffuseSampler"], o + "#define FOG"), this._drawWrapperFogDepth.effect = this._drawWrapperFog.effect, this._drawWrapperFogDepth.materialContext = this._drawWrapperFog.materialContext);
      }, n.prototype.render = function(t, e, i, r, o) {
        if (o === void 0 && (o = null), this.texture && this.texture.isReady() && t.length) {
          var a = this._drawWrapperBase, s = this._drawWrapperDepth, l = !1;
          this.fogEnabled && this._scene && this._scene.fogEnabled && this._scene.fogMode !== 0 && (a = this._drawWrapperFog, s = this._drawWrapperFogDepth, l = !0);
          var c = a.effect;
          if (c.isReady()) {
            for (var u = this._engine, h = !(!this._scene || !this._scene.useRightHandedSystem), d = this.texture.getBaseSize(), p = Math.min(this._capacity, t.length), f = 0, m = !0, g = 0; g < p; g++) {
              var y = t[g];
              y && y.isVisible && (m = !1, y._animate(e), this._appendSpriteVertex(f++, y, 0, 0, d, h, o), this._useInstancing || (this._appendSpriteVertex(f++, y, 1, 0, d, h, o), this._appendSpriteVertex(f++, y, 1, 1, d, h, o), this._appendSpriteVertex(f++, y, 0, 1, d, h, o)));
            }
            if (!m) {
              this._buffer.update(this._vertexData);
              var b = !!u.depthCullingState.cull, T = u.depthCullingState.zOffset, S = u.depthCullingState.zOffsetUnits;
              if (u.setState(b, T, !1, !1, void 0, void 0, S), u.enableEffect(a), c.setTexture("diffuseSampler", this.texture), c.setMatrix("view", i), c.setMatrix("projection", r), l) {
                var E = this._scene;
                c.setFloat4("vFogInfos", E.fogMode, E.fogStart, E.fogEnd, E.fogDensity), c.setColor3("vFogColor", E.fogColor);
              }
              this._useVAO ? (this._vertexArrayObject || (this._vertexArrayObject = u.recordVertexArrayObject(this._vertexBuffers, this._indexBuffer, c)), u.bindVertexArrayObject(this._vertexArrayObject, this._indexBuffer)) : u.bindBuffers(this._vertexBuffers, this._indexBuffer, c), u.depthCullingState.depthFunc = u.useReverseDepthBuffer ? _.GEQUAL : _.LEQUAL, this.disableDepthWrite || (c.setBool("alphaTest", !0), u.setColorWrite(!1), u.enableEffect(s), this._useInstancing ? u.drawArraysType(_.MATERIAL_TriangleStripDrawMode, 0, 4, f) : u.drawElementsType(_.MATERIAL_TriangleFillMode, 0, f / 4 * 6), u.enableEffect(a), u.setColorWrite(!0), c.setBool("alphaTest", !1)), u.setAlphaMode(this.blendMode), this._useInstancing ? u.drawArraysType(_.MATERIAL_TriangleStripDrawMode, 0, 4, f) : u.drawElementsType(_.MATERIAL_TriangleFillMode, 0, f / 4 * 6), this.autoResetAlpha && u.setAlphaMode(_.ALPHA_DISABLE), h && this._scene.getEngine().setState(b, T, !1, !0, void 0, void 0, S), u.unbindInstanceAttributes();
            }
          }
        }
      }, n.prototype._appendSpriteVertex = function(t, e, i, r, o, a, s) {
        var l = t * this._vertexBufferSize;
        if (i === 0 ? i = this._epsilon : i === 1 && (i = 1 - this._epsilon), r === 0 ? r = this._epsilon : r === 1 && (r = 1 - this._epsilon), s)
          s(e, o);
        else {
          e.cellIndex || (e.cellIndex = 0);
          var c = o.width / this.cellWidth, u = e.cellIndex / c >> 0;
          e._xOffset = (e.cellIndex - u * c) * this.cellWidth / o.width, e._yOffset = u * this.cellHeight / o.height, e._xSize = this.cellWidth, e._ySize = this.cellHeight;
        }
        this._vertexData[l] = e.position.x, this._vertexData[l + 1] = e.position.y, this._vertexData[l + 2] = e.position.z, this._vertexData[l + 3] = e.angle, this._vertexData[l + 4] = e.width, this._vertexData[l + 5] = e.height, this._useInstancing ? l -= 2 : (this._vertexData[l + 6] = i, this._vertexData[l + 7] = r), this._vertexData[l + 8] = a ? e.invertU ? 0 : 1 : e.invertU ? 1 : 0, this._vertexData[l + 9] = e.invertV ? 1 : 0, this._vertexData[l + 10] = e._xOffset, this._vertexData[l + 11] = e._yOffset, this._vertexData[l + 12] = e._xSize / o.width, this._vertexData[l + 13] = e._ySize / o.height, this._vertexData[l + 14] = e.color.r, this._vertexData[l + 15] = e.color.g, this._vertexData[l + 16] = e.color.b, this._vertexData[l + 17] = e.color.a;
      }, n.prototype._buildIndexBuffer = function() {
        for (var t = [], e = 0, i = 0; i < this._capacity; i++)
          t.push(e), t.push(e + 1), t.push(e + 2), t.push(e), t.push(e + 2), t.push(e + 3), e += 4;
        this._indexBuffer = this._engine.createIndexBuffer(t);
      }, n.prototype.rebuild = function() {
        var t;
        for (var e in this._indexBuffer && this._buildIndexBuffer(), this._useVAO && (this._vertexArrayObject = void 0), this._buffer._rebuild(), this._vertexBuffers)
          this._vertexBuffers[e]._rebuild();
        (t = this._spriteBuffer) === null || t === void 0 || t._rebuild();
      }, n.prototype.dispose = function() {
        this._buffer && (this._buffer.dispose(), this._buffer = null), this._spriteBuffer && (this._spriteBuffer.dispose(), this._spriteBuffer = null), this._indexBuffer && (this._engine._releaseBuffer(this._indexBuffer), this._indexBuffer = null), this._vertexArrayObject && (this._engine.releaseVertexArrayObject(this._vertexArrayObject), this._vertexArrayObject = null), this.texture && (this.texture.dispose(), this.texture = null), this._drawWrapperBase.dispose(), this._drawWrapperFog.dispose(), this._drawWrapperDepth.dispose(), this._drawWrapperFogDepth.dispose();
      }, n;
    }(), OE = function() {
      function n(t, e, i, r, o, a, s, l, c) {
        a === void 0 && (a = 0.01), s === void 0 && (s = ae.TRILINEAR_SAMPLINGMODE), l === void 0 && (l = !1), c === void 0 && (c = null);
        var u = this;
        this.name = t, this.sprites = [], this.renderingGroupId = 0, this.layerMask = 268435455, this.isPickable = !1, this.metadata = null, this._wasDispatched = !1, this.onDisposeObservable = new H(), this._disableDepthWrite = !1, this._packedAndReady = !1, this._customUpdate = function(d, p) {
          d.cellRef || (d.cellIndex = 0);
          var f = d.cellIndex;
          typeof f == "number" && isFinite(f) && Math.floor(f) === f && (d.cellRef = u._spriteMap[d.cellIndex]), d._xOffset = u._cellData[d.cellRef].frame.x / p.width, d._yOffset = u._cellData[d.cellRef].frame.y / p.height, d._xSize = u._cellData[d.cellRef].frame.w, d._ySize = u._cellData[d.cellRef].frame.h;
        }, o || (o = Me.LastCreatedScene), o._getComponent(we.NAME_SPRITE) || o._addComponent(new ME(o)), this._fromPacked = l, this._scene = o;
        var h = this._scene.getEngine();
        if (this._spriteRenderer = new NN(h, i, a, o), r.width && r.height)
          this.cellWidth = r.width, this.cellHeight = r.height;
        else {
          if (r === void 0)
            return void (this._spriteRenderer = null);
          this.cellWidth = r, this.cellHeight = r;
        }
        this._scene.spriteManagers && this._scene.spriteManagers.push(this), this.uniqueId = this.scene.getUniqueId(), e && (this.texture = new ae(e, o, !0, !1, s)), this._fromPacked && this._makePacked(e, c);
      }
      return Object.defineProperty(n.prototype, "onDispose", { set: function(t) {
        this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver), this._onDisposeObserver = this.onDisposeObservable.add(t);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "children", { get: function() {
        return this.sprites;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "scene", { get: function() {
        return this._scene;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "capacity", { get: function() {
        return this._spriteRenderer.capacity;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "texture", { get: function() {
        return this._spriteRenderer.texture;
      }, set: function(t) {
        t.wrapU = ae.CLAMP_ADDRESSMODE, t.wrapV = ae.CLAMP_ADDRESSMODE, this._spriteRenderer.texture = t, this._textureContent = null;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "cellWidth", { get: function() {
        return this._spriteRenderer.cellWidth;
      }, set: function(t) {
        this._spriteRenderer.cellWidth = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "cellHeight", { get: function() {
        return this._spriteRenderer.cellHeight;
      }, set: function(t) {
        this._spriteRenderer.cellHeight = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "fogEnabled", { get: function() {
        return this._spriteRenderer.fogEnabled;
      }, set: function(t) {
        this._spriteRenderer.fogEnabled = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "blendMode", { get: function() {
        return this._spriteRenderer.blendMode;
      }, set: function(t) {
        this._spriteRenderer.blendMode = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "disableDepthWrite", { get: function() {
        return this._disableDepthWrite;
      }, set: function(t) {
        this._disableDepthWrite = t, this._spriteRenderer.disableDepthWrite = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "pixelPerfect", { get: function() {
        return this._spriteRenderer.pixelPerfect;
      }, set: function(t) {
        this._spriteRenderer.pixelPerfect = t, t && this.texture.samplingMode !== _.TEXTURE_TRILINEAR_SAMPLINGMODE && this.texture.updateSamplingMode(_.TEXTURE_TRILINEAR_SAMPLINGMODE);
      }, enumerable: !1, configurable: !0 }), n.prototype.getClassName = function() {
        return "SpriteManager";
      }, n.prototype._makePacked = function(t, e) {
        var i = this;
        if (e !== null)
          try {
            var r = void 0;
            if ((r = typeof e == "string" ? JSON.parse(e) : e).frames.length) {
              for (var o = {}, a = 0; a < r.frames.length; a++) {
                var s = r.frames[a];
                if (typeof Object.keys(s)[0] != "string")
                  throw new Error("Invalid JSON Format.  Check the frame values and make sure the name is the first parameter.");
                o[s[Object.keys(s)[0]]] = s;
              }
              r.frames = o;
            }
            var l = Reflect.ownKeys(r.frames);
            this._spriteMap = l, this._packedAndReady = !0, this._cellData = r.frames;
          } catch {
            throw this._fromPacked = !1, this._packedAndReady = !1, new Error("Invalid JSON from string. Spritesheet managed with constant cell size.");
          }
        else {
          var c = /\./g, u = void 0;
          do
            u = c.lastIndex, c.test(t);
          while (c.lastIndex > 0);
          var h = t.substring(0, u - 1) + ".json";
          de.LoadFile(h, function(d) {
            try {
              var p = JSON.parse(d), f = Reflect.ownKeys(p.frames);
              i._spriteMap = f, i._packedAndReady = !0, i._cellData = p.frames;
            } catch {
              throw i._fromPacked = !1, i._packedAndReady = !1, new Error("Invalid JSON format. Please check documentation for format specifications.");
            }
          }, void 0, void 0, !1, function() {
            q.Error("JSON ERROR: Unable to load JSON file."), i._fromPacked = !1, i._packedAndReady = !1;
          });
        }
      }, n.prototype._checkTextureAlpha = function(t, e, i, r, o) {
        if (!t.useAlphaForPicking || !this.texture)
          return !0;
        var a = this.texture.getSize();
        this._textureContent || (this._textureContent = new Uint8Array(a.width * a.height * 4), this.texture.readPixels(0, 0, this._textureContent));
        var s = F.Vector3[0];
        s.copyFrom(e.direction), s.normalize(), s.scaleInPlace(i), s.addInPlace(e.origin);
        var l = (s.x - r.x) / (o.x - r.x), c = 1 - (s.y - r.y) / (o.y - r.y), u = t._xOffset * a.width + l * t._xSize | 0, h = t._yOffset * a.height + c * t._ySize | 0;
        return this._textureContent[4 * (u + h * a.width) + 3] > 0.5;
      }, n.prototype.intersects = function(t, e, i, r) {
        for (var o = Math.min(this.capacity, this.sprites.length), a = v.Zero(), s = v.Zero(), l = Number.MAX_VALUE, c = null, u = F.Vector3[0], h = F.Vector3[1], d = e.getViewMatrix(), p = t, f = t, m = 0; m < o; m++) {
          var g = this.sprites[m];
          if (g) {
            if (i) {
              if (!i(g))
                continue;
            } else if (!g.isPickable)
              continue;
            if (v.TransformCoordinatesToRef(g.position, d, h), g.angle ? (B.TranslationToRef(-h.x, -h.y, 0, F.Matrix[1]), B.TranslationToRef(h.x, h.y, 0, F.Matrix[2]), B.RotationZToRef(-g.angle, F.Matrix[3]), F.Matrix[1].multiplyToRef(F.Matrix[3], F.Matrix[4]), F.Matrix[4].multiplyToRef(F.Matrix[2], F.Matrix[0]), p = t.clone(), v.TransformCoordinatesToRef(t.origin, F.Matrix[0], p.origin), v.TransformNormalToRef(t.direction, F.Matrix[0], p.direction)) : p = t, a.copyFromFloats(h.x - g.width / 2, h.y - g.height / 2, h.z), s.copyFromFloats(h.x + g.width / 2, h.y + g.height / 2, h.z), p.intersectsBoxMinMax(a, s)) {
              var y = v.Distance(h, p.origin);
              if (l > y) {
                if (!this._checkTextureAlpha(g, p, y, a, s))
                  continue;
                if (f = p, l = y, c = g, r)
                  break;
              }
            }
          }
        }
        if (c) {
          var b = new Ki();
          d.invertToRef(F.Matrix[0]), b.hit = !0, b.pickedSprite = c, b.distance = l;
          var T = F.Vector3[2];
          return T.copyFrom(f.direction), T.normalize(), T.scaleInPlace(l), f.origin.addToRef(T, u), b.pickedPoint = v.TransformCoordinates(u, F.Matrix[0]), b;
        }
        return null;
      }, n.prototype.multiIntersects = function(t, e, i) {
        for (var r, o = Math.min(this.capacity, this.sprites.length), a = v.Zero(), s = v.Zero(), l = [], c = F.Vector3[0].copyFromFloats(0, 0, 0), u = F.Vector3[1].copyFromFloats(0, 0, 0), h = e.getViewMatrix(), d = 0; d < o; d++) {
          var p = this.sprites[d];
          if (p) {
            if (i) {
              if (!i(p))
                continue;
            } else if (!p.isPickable)
              continue;
            if (v.TransformCoordinatesToRef(p.position, h, u), a.copyFromFloats(u.x - p.width / 2, u.y - p.height / 2, u.z), s.copyFromFloats(u.x + p.width / 2, u.y + p.height / 2, u.z), t.intersectsBoxMinMax(a, s)) {
              if (r = v.Distance(u, t.origin), !this._checkTextureAlpha(p, t, r, a, s))
                continue;
              var f = new Ki();
              l.push(f), h.invertToRef(F.Matrix[0]), f.hit = !0, f.pickedSprite = p, f.distance = r;
              var m = F.Vector3[2];
              m.copyFrom(t.direction), m.normalize(), m.scaleInPlace(r), t.origin.addToRef(m, c), f.pickedPoint = v.TransformCoordinates(c, F.Matrix[0]);
            }
          }
        }
        return l;
      }, n.prototype.render = function() {
        if (!this._fromPacked || this._packedAndReady && this._spriteMap && this._cellData) {
          var t = this._scene.getEngine().getDeltaTime();
          this._packedAndReady ? this._spriteRenderer.render(this.sprites, t, this._scene.getViewMatrix(), this._scene.getProjectionMatrix(), this._customUpdate) : this._spriteRenderer.render(this.sprites, t, this._scene.getViewMatrix(), this._scene.getProjectionMatrix());
        }
      }, n.prototype.rebuild = function() {
        var t;
        (t = this._spriteRenderer) === null || t === void 0 || t.rebuild();
      }, n.prototype.dispose = function() {
        if (this._spriteRenderer && (this._spriteRenderer.dispose(), this._spriteRenderer = null), this._textureContent = null, this._scene.spriteManagers) {
          var t = this._scene.spriteManagers.indexOf(this);
          this._scene.spriteManagers.splice(t, 1);
        }
        this.onDisposeObservable.notifyObservers(this), this.onDisposeObservable.clear(), this.metadata = null;
      }, n.prototype.serialize = function(t) {
        t === void 0 && (t = !1);
        var e = {};
        e.name = this.name, e.capacity = this.capacity, e.cellWidth = this.cellWidth, e.cellHeight = this.cellHeight, e.fogEnabled = this.fogEnabled, e.blendMode = this.blendMode, e.disableDepthWrite = this.disableDepthWrite, e.pixelPerfect = this.pixelPerfect, this.texture && (t ? e.texture = this.texture.serialize() : (e.textureUrl = this.texture.name, e.invertY = this.texture._invertY)), e.sprites = [];
        for (var i = 0, r = this.sprites; i < r.length; i++) {
          var o = r[i];
          e.sprites.push(o.serialize());
        }
        return e.metadata = this.metadata, e;
      }, n.Parse = function(t, e, i) {
        var r = new n(t.name, "", t.capacity, { width: t.cellWidth, height: t.cellHeight }, e);
        t.fogEnabled !== void 0 && (r.fogEnabled = t.fogEnabled), t.blendMode !== void 0 && (r.blendMode = t.blendMode), t.disableDepthWrite !== void 0 && (r.disableDepthWrite = t.disableDepthWrite), t.pixelPerfect !== void 0 && (r.pixelPerfect = t.pixelPerfect), t.metadata !== void 0 && (r.metadata = t.metadata), t.texture ? r.texture = ae.Parse(t.texture, e, i) : t.textureName && (r.texture = new ae(i + t.textureUrl, e, !1, t.invertY === void 0 || t.invertY));
        for (var o = 0, a = t.sprites; o < a.length; o++) {
          var s = a[o];
          IE.Parse(s, r);
        }
        return r;
      }, n.ParseFromFileAsync = function(t, e, i, r) {
        return r === void 0 && (r = ""), new Promise(function(o, a) {
          var s = new _n();
          s.addEventListener("readystatechange", function() {
            if (s.readyState == 4)
              if (s.status == 200) {
                var l = JSON.parse(s.responseText), c = n.Parse(l, i || Me.LastCreatedScene, r);
                t && (c.name = t), o(c);
              } else
                a("Unable to load the sprite manager");
          }), s.open("GET", e), s.send();
        });
      }, n.ParseFromSnippetAsync = function(t, e, i) {
        var r = this;
        return i === void 0 && (i = ""), t === "_BLANK" ? Promise.resolve(new n("Default sprite manager", "//playground.babylonjs.com/textures/player.png", 500, 64, e)) : new Promise(function(o, a) {
          var s = new _n();
          s.addEventListener("readystatechange", function() {
            if (s.readyState == 4)
              if (s.status == 200) {
                var l = JSON.parse(JSON.parse(s.responseText).jsonPayload), c = JSON.parse(l.spriteManager), u = n.Parse(c, e || Me.LastCreatedScene, i);
                u.snippetId = t, o(u);
              } else
                a("Unable to load the snippet " + t);
          }), s.open("GET", r.SnippetUrl + "/" + t.replace(/#/g, "/")), s.send();
        });
      }, n.SnippetUrl = _.SnippetUrl, n.CreateFromSnippetAsync = n.ParseFromSnippetAsync, n;
    }();
    re.ShadersStore.spriteMapPixelShader = `#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
#define TEXTUREFUNC(s,c,l) texture2DLodEXT(s,c,l)
#else
#define TEXTUREFUNC(s,c,b) texture2D(s,c,b)
#endif
precision highp float;varying vec3 vPosition;varying vec2 vUV;varying vec2 tUV;uniform float time;uniform float spriteCount;uniform sampler2D spriteSheet;uniform vec2 spriteMapSize;uniform vec2 outputSize;uniform vec2 stageSize;uniform sampler2D frameMap;uniform sampler2D tileMaps[LAYERS];uniform sampler2D animationMap;uniform vec3 colorMul;float mt;const float fdStep=1./4.;const float aFrameSteps=1./MAX_ANIMATION_FRAMES;mat4 getFrameData(float frameID){float fX=frameID/spriteCount;return mat4(
texture2D(frameMap,vec2(fX,0.),0.),
texture2D(frameMap,vec2(fX,fdStep*1.),0.),
texture2D(frameMap,vec2(fX,fdStep*2.),0.),
vec4(0.)
);}
void main(){vec4 color=vec4(0.);vec2 tileUV=fract(tUV);
#ifdef FLIPU
tileUV.y=1.0-tileUV.y;
#endif
vec2 tileID=floor(tUV);vec2 sheetUnits=1./spriteMapSize;float spriteUnits=1./spriteCount;vec2 stageUnits=1./stageSize;for(int i=0; i<LAYERS; i++) {float frameID;
#define LAYER_ID_SWITCH
vec4 animationData=TEXTUREFUNC(animationMap,vec2((frameID+0.5)/spriteCount,0.),0.);if(animationData.y>0.) {mt=mod(time*animationData.z,1.0);for(float f=0.; f<MAX_ANIMATION_FRAMES; f++){if(animationData.y>mt){frameID=animationData.x;break;}
animationData=TEXTUREFUNC(animationMap,vec2((frameID+0.5)/spriteCount,aFrameSteps*f),0.);}}
mat4 frameData=getFrameData(frameID+0.5);vec2 frameSize=(frameData[0].zw)/spriteMapSize;vec2 offset=frameData[0].xy*sheetUnits;vec2 ratio=frameData[2].xy/frameData[0].zw;if (frameData[2].z==1.){tileUV.xy=tileUV.yx;}
vec4 nc=texture2D(spriteSheet,tileUV*frameSize+offset);if (i==0){color=nc;} else {float alpha=min(color.a+nc.a,1.0);vec3 mixed=mix(color.xyz,nc.xyz,nc.a);color=vec4(mixed,alpha);}}
color.xyz*=colorMul;gl_FragColor=color;}`, re.ShadersStore.spriteMapVertexShader = `precision highp float;attribute vec3 position;attribute vec3 normal;attribute vec2 uv;varying vec3 vPosition;varying vec2 vUV;varying vec2 tUV;varying vec2 stageUnits;varying vec2 levelUnits;varying vec2 tileID;uniform float time;uniform mat4 worldViewProjection;uniform vec2 outputSize;uniform vec2 stageSize;uniform vec2 spriteMapSize;uniform float stageScale;void main() {vec4 p=vec4( position,1. );vPosition=p.xyz;vUV=uv;tUV=uv*stageSize; 
gl_Position=worldViewProjection*p;}`;
    var Wo, uI = function() {
      function n(t, e, i, r, o) {
        var a = this;
        this.name = t, this.sprites = [], this.atlasJSON = e, this.sprites = this.atlasJSON.frames, this.spriteSheet = i, this.options = r, r.stageSize = r.stageSize || new fe(1, 1), r.outputSize = r.outputSize || r.stageSize, r.outputPosition = r.outputPosition || v.Zero(), r.outputRotation = r.outputRotation || v.Zero(), r.layerCount = r.layerCount || 1, r.maxAnimationFrames = r.maxAnimationFrames || 0, r.baseTile = r.baseTile || 0, r.flipU = r.flipU || !1, r.colorMultiply = r.colorMultiply || new v(1, 1, 1), this._scene = o, this._frameMap = this._createFrameBuffer(), this._tileMaps = new Array();
        for (var s = 0; s < r.layerCount; s++)
          this._tileMaps.push(this._createTileBuffer(null, s));
        this._animationMap = this._createTileAnimationBuffer(null);
        var l = [];
        l.push("#define LAYERS " + r.layerCount), r.flipU && l.push("#define FLIPU"), l.push("#define MAX_ANIMATION_FRAMES ".concat(r.maxAnimationFrames, ".0"));
        var c, u = Jt.ShadersStore.spriteMapPixelShader;
        if (o.getEngine()._features.supportSwitchCaseInShader) {
          for (c = "switch(i) {", s = 0; s < r.layerCount; s++)
            c += "case " + s + " : frameID = texture(tileMaps[" + s + "], (tileID + 0.5) / stageSize, 0.).x;", c += "break;";
          c += "}";
        } else
          for (c = "", s = 0; s < r.layerCount; s++)
            c += "if (".concat(s, " == i) { frameID = texture2D(tileMaps[").concat(s, "], (tileID + 0.5) / stageSize, 0.).x; }");
        Jt.ShadersStore["spriteMap" + this.name + "PixelShader"] = u.replace("#define LAYER_ID_SWITCH", c), this._material = new dr("spriteMap:" + this.name, this._scene, { vertex: "spriteMap", fragment: "spriteMap" + this.name }, { defines: l, attributes: ["position", "normal", "uv"], uniforms: ["worldViewProjection", "time", "stageSize", "outputSize", "spriteMapSize", "spriteCount", "time", "colorMul", "mousePosition", "curTile", "flipU"], samplers: ["spriteSheet", "frameMap", "tileMaps", "animationMap"], needAlphaBlending: !0 }), this._time = 0, this._material.setFloat("spriteCount", this.spriteCount), this._material.setVector2("stageSize", r.stageSize), this._material.setVector2("outputSize", r.outputSize), this._material.setTexture("spriteSheet", this.spriteSheet), this._material.setVector2("spriteMapSize", new fe(1, 1)), this._material.setVector3("colorMul", r.colorMultiply);
        var h = 0, d = function() {
          a.spriteSheet && a.spriteSheet.isReady() && a.spriteSheet._texture ? a._material.setVector2("spriteMapSize", new fe(a.spriteSheet._texture.baseWidth || 1, a.spriteSheet._texture.baseHeight || 1)) : h < 100 && setTimeout(function() {
            h++, d();
          }, 100);
        };
        d(), this._material.setVector3("colorMul", r.colorMultiply), this._material.setTexture("frameMap", this._frameMap), this._material.setTextureArray("tileMaps", this._tileMaps), this._material.setTexture("animationMap", this._animationMap), this._material.setFloat("time", this._time), this._output = Ro(t + ":output", { size: 1, updatable: !0 }, o), this._output.scaling.x = r.outputSize.x, this._output.scaling.y = r.outputSize.y, this.position = r.outputPosition, this.rotation = r.outputRotation, this._scene.onBeforeRenderObservable.add(function() {
          a._time += a._scene.getEngine().getDeltaTime(), a._material.setFloat("time", a._time);
        }), this._output.material = this._material;
      }
      return Object.defineProperty(n.prototype, "spriteCount", { get: function() {
        return this.sprites.length;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "position", { get: function() {
        return this._output.position;
      }, set: function(t) {
        this._output.position = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "rotation", { get: function() {
        return this._output.rotation;
      }, set: function(t) {
        this._output.rotation = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "animationMap", { get: function() {
        return this._animationMap;
      }, set: function(t) {
        var e = t._texture._bufferView, i = this._createTileAnimationBuffer(e);
        this._animationMap.dispose(), this._animationMap = i, this._material.setTexture("animationMap", this._animationMap);
      }, enumerable: !1, configurable: !0 }), n.prototype.getTileID = function() {
        var t = this.getMousePosition();
        return t.multiplyInPlace(this.options.stageSize || fe.Zero()), t.x = Math.floor(t.x), t.y = Math.floor(t.y), t;
      }, n.prototype.getMousePosition = function() {
        var t = this._output, e = this._scene.pick(this._scene.pointerX, this._scene.pointerY, function(i) {
          return i === t;
        });
        return e && e.hit && e.getTextureCoordinates && e.getTextureCoordinates() || new fe(-1, -1);
      }, n.prototype._createFrameBuffer = function() {
        for (var t = [], e = 0; e < this.spriteCount; e++)
          t.push(0, 0, 0, 0), t.push(0, 0, 0, 0), t.push(0, 0, 0, 0), t.push(0, 0, 0, 0);
        for (e = 0; e < this.spriteCount; e++) {
          var i = this.sprites[e].frame, r = this.sprites[e].spriteSourceSize, o = this.sprites[e].sourceSize, a = this.sprites[e].rotated ? 1 : 0, s = this.sprites[e].trimmed ? 1 : 0;
          t[4 * e] = i.x, t[4 * e + 1] = i.y, t[4 * e + 2] = i.w, t[4 * e + 3] = i.h, t[4 * e + 4 * this.spriteCount] = r.x, t[4 * e + 1 + 4 * this.spriteCount] = r.y, t[4 * e + 3 + 4 * this.spriteCount] = r.h, t[4 * e + 8 * this.spriteCount] = o.w, t[4 * e + 1 + 8 * this.spriteCount] = o.h, t[4 * e + 2 + 8 * this.spriteCount] = a, t[4 * e + 3 + 8 * this.spriteCount] = s;
        }
        var l = new Float32Array(t);
        return on.CreateRGBATexture(l, this.spriteCount, 4, this._scene, !1, !1, ae.NEAREST_NEAREST, ve.TEXTURETYPE_FLOAT);
      }, n.prototype._createTileBuffer = function(t, e) {
        e === void 0 && (e = 0);
        var i = [], r = this.options.stageSize.y || 0, o = this.options.stageSize.x || 0;
        if (t)
          i = t;
        else {
          var a = this.options.baseTile;
          e != 0 && (a = 0);
          for (var s = 0; s < r; s++)
            for (var l = 0; l < 4 * o; l += 4)
              i.push(a, 0, 0, 0);
        }
        var c = new Float32Array(i);
        return on.CreateRGBATexture(c, o, r, this._scene, !1, !1, ae.NEAREST_NEAREST, ve.TEXTURETYPE_FLOAT);
      }, n.prototype.changeTiles = function(t, e, i) {
        t === void 0 && (t = 0), i === void 0 && (i = 0);
        var r = this._tileMaps[t]._texture._bufferView;
        if (r !== null) {
          var o = [];
          e instanceof fe ? o.push(e) : o = e;
          for (var a = this.options.stageSize.x || 0, s = 0; s < o.length; s++) {
            var l = o[s];
            l.x = Math.floor(l.x), l.y = Math.floor(l.y), r[4 * l.x + l.y * (4 * a)] = i;
          }
          var c = this._createTileBuffer(r);
          this._tileMaps[t].dispose(), this._tileMaps[t] = c, this._material.setTextureArray("tileMap", this._tileMaps);
        }
      }, n.prototype._createTileAnimationBuffer = function(t) {
        var e, i = [];
        if (t)
          e = t;
        else {
          for (var r = 0; r < this.spriteCount; r++) {
            i.push(0, 0, 0, 0);
            for (var o = 1; o < (this.options.maxAnimationFrames || 4); )
              i.push(0, 0, 0, 0), o++;
          }
          e = new Float32Array(i);
        }
        return on.CreateRGBATexture(e, this.spriteCount, this.options.maxAnimationFrames || 4, this._scene, !1, !1, ae.NEAREST_NEAREST, ve.TEXTURETYPE_FLOAT);
      }, n.prototype.addAnimationToTile = function(t, e, i, r, o) {
        t === void 0 && (t = 0), e === void 0 && (e = 0), i === void 0 && (i = 0), r === void 0 && (r = 0), o === void 0 && (o = 1);
        var a = this._animationMap._texture._bufferView, s = 4 * t + 4 * this.spriteCount * e;
        if (a) {
          a[s] = i, a[s + 1] = r, a[s + 2] = o;
          var l = this._createTileAnimationBuffer(a);
          this._animationMap.dispose(), this._animationMap = l, this._material.setTexture("animationMap", this._animationMap);
        }
      }, n.prototype.saveTileMaps = function() {
        for (var t = "", e = 0; e < this._tileMaps.length; e++)
          e > 0 && (t += `
\r`), t += this._tileMaps[e]._texture._bufferView.toString();
        var i = document.createElement("a");
        i.href = "data:octet/stream;charset=utf-8," + encodeURI(t), i.target = "_blank", i.download = this.name + ".tilemaps", i.click(), i.remove();
      }, n.prototype.loadTileMaps = function(t) {
        var e = this, i = new XMLHttpRequest();
        i.open("GET", t);
        var r = this.options.layerCount || 0;
        i.onload = function() {
          for (var o = i.response.split(`
\r`), a = 0; a < r; a++) {
            var s = o[a].split(",").map(Number), l = e._createTileBuffer(s);
            e._tileMaps[a].dispose(), e._tileMaps[a] = l;
          }
          e._material.setTextureArray("tileMap", e._tileMaps);
        }, i.send();
      }, n.prototype.dispose = function() {
        this._output.dispose(), this._material.dispose(), this._animationMap.dispose(), this._tileMaps.forEach(function(t) {
          t.dispose();
        }), this._frameMap.dispose();
      }, n;
    }(), hI = function(n) {
      function t(e, i, r, o, a, s, l) {
        a === void 0 && (a = null), s === void 0 && (s = 0.01), l === void 0 && (l = ae.TRILINEAR_SAMPLINGMODE);
        var c = n.call(this, e, i, r, 64, o, s, l, !0, a) || this;
        return c.name = e, c;
      }
      return D(t, n), t;
    }(OE);
    (function(n) {
      n[n.INIT = 0] = "INIT", n[n.RUNNING = 1] = "RUNNING", n[n.DONE = 2] = "DONE", n[n.ERROR = 3] = "ERROR";
    })(Wo || (Wo = {}));
    var uo = function() {
      function n(t) {
        this.name = t, this._isCompleted = !1, this._taskState = Wo.INIT;
      }
      return Object.defineProperty(n.prototype, "isCompleted", { get: function() {
        return this._isCompleted;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "taskState", { get: function() {
        return this._taskState;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "errorObject", { get: function() {
        return this._errorObject;
      }, enumerable: !1, configurable: !0 }), n.prototype._setErrorObject = function(t, e) {
        this._errorObject || (this._errorObject = { message: t, exception: e });
      }, n.prototype.run = function(t, e, i) {
        var r = this;
        this._taskState = Wo.RUNNING, this.runTask(t, function() {
          r._onDoneCallback(e, i);
        }, function(o, a) {
          r._onErrorCallback(i, o, a);
        });
      }, n.prototype.runTask = function(t, e, i) {
        throw new Error("runTask is not implemented");
      }, n.prototype.reset = function() {
        this._taskState = Wo.INIT;
      }, n.prototype._onErrorCallback = function(t, e, i) {
        this._taskState = Wo.ERROR, this._errorObject = { message: e, exception: i }, this.onError && this.onError(this, e, i), t();
      }, n.prototype._onDoneCallback = function(t, e) {
        try {
          this._taskState = Wo.DONE, this._isCompleted = !0, this.onSuccess && this.onSuccess(this), t();
        } catch (i) {
          this._onErrorCallback(e, "Task is done, error executing success callback(s)", i);
        }
      }, n;
    }(), DE = function(n, t, e) {
      this.remainingCount = n, this.totalCount = t, this.task = e;
    }, NE = function(n) {
      function t(e, i, r, o, a) {
        var s = n.call(this, e) || this;
        return s.name = e, s.meshesNames = i, s.rootUrl = r, s.sceneFilename = o, s.extension = a, s;
      }
      return D(t, n), t.prototype.runTask = function(e, i, r) {
        var o = this;
        yi.LoadAssetContainer(this.rootUrl, this.sceneFilename, e, function(a) {
          o.loadedContainer = a, o.loadedMeshes = a.meshes, o.loadedTransformNodes = a.transformNodes, o.loadedParticleSystems = a.particleSystems, o.loadedSkeletons = a.skeletons, o.loadedAnimationGroups = a.animationGroups, i();
        }, null, function(a, s, l) {
          r(s, l);
        }, this.extension);
      }, t;
    }(uo), FE = function(n) {
      function t(e, i, r, o, a) {
        var s = n.call(this, e) || this;
        return s.name = e, s.meshesNames = i, s.rootUrl = r, s.sceneFilename = o, s.extension = a, s;
      }
      return D(t, n), t.prototype.runTask = function(e, i, r) {
        var o = this;
        yi.ImportMesh(this.meshesNames, this.rootUrl, this.sceneFilename, e, function(a, s, l, c, u) {
          o.loadedMeshes = a, o.loadedTransformNodes = u, o.loadedParticleSystems = s, o.loadedSkeletons = l, o.loadedAnimationGroups = c, i();
        }, null, function(a, s, l) {
          r(s, l);
        }, this.extension);
      }, t;
    }(uo), dI = function(n) {
      function t(e, i, r, o, a) {
        var s = n.call(this, e) || this;
        return s.name = e, s.rootUrl = i, s.filename = r, s.targetConverter = o, s.extension = a, s;
      }
      return D(t, n), t.prototype.runTask = function(e, i, r) {
        var o = this, a = e.animatables.length, s = e.animationGroups.length;
        this.loadedAnimatables = [], this.loadedAnimationGroups = [], yi.ImportAnimations(this.rootUrl, this.filename, e, !1, Po.NoSync, this.targetConverter, function() {
          o.loadedAnimatables = e.animatables.slice(a), o.loadedAnimationGroups = e.animationGroups.slice(s), i();
        }, null, function(l, c, u) {
          r(c, u);
        }, this.extension);
      }, t;
    }(uo), LE = function(n) {
      function t(e, i) {
        var r = n.call(this, e) || this;
        return r.name = e, r.url = i, r;
      }
      return D(t, n), t.prototype.runTask = function(e, i, r) {
        var o = this;
        e._loadFile(this.url, function(a) {
          o.text = a, i();
        }, void 0, !1, !1, function(a, s) {
          a && r(a.status + " " + a.statusText, s);
        });
      }, t;
    }(uo), wE = function(n) {
      function t(e, i) {
        var r = n.call(this, e) || this;
        return r.name = e, r.url = i, r;
      }
      return D(t, n), t.prototype.runTask = function(e, i, r) {
        var o = this;
        e._loadFile(this.url, function(a) {
          o.data = a, i();
        }, void 0, !0, !0, function(a, s) {
          a && r(a.status + " " + a.statusText, s);
        });
      }, t;
    }(uo), BE = function(n) {
      function t(e, i) {
        var r = n.call(this, e) || this;
        return r.name = e, r.url = i, r;
      }
      return D(t, n), t.prototype.runTask = function(e, i, r) {
        var o = this, a = new Image();
        de.SetCorsBehavior(this.url, a), a.onload = function() {
          o.image = a, i();
        }, a.onerror = function(s) {
          r("Error loading image", s);
        }, a.src = this.url;
      }, t;
    }(uo), UE = function(n) {
      function t(e, i, r, o, a) {
        o === void 0 && (o = !0), a === void 0 && (a = ae.TRILINEAR_SAMPLINGMODE);
        var s = n.call(this, e) || this;
        return s.name = e, s.url = i, s.noMipmap = r, s.invertY = o, s.samplingMode = a, s;
      }
      return D(t, n), t.prototype.runTask = function(e, i, r) {
        this.texture = new ae(this.url, e, this.noMipmap, this.invertY, this.samplingMode, function() {
          i();
        }, function(o, a) {
          r(o, a);
        });
      }, t;
    }(uo), VE = function(n) {
      function t(e, i, r, o, a, s) {
        var l = n.call(this, e) || this;
        return l.name = e, l.url = i, l.extensions = r, l.noMipmap = o, l.files = a, l.prefiltered = s, l;
      }
      return D(t, n), t.prototype.runTask = function(e, i, r) {
        this.texture = new Gr(this.url, e, this.extensions, this.noMipmap, this.files, function() {
          i();
        }, function(o, a) {
          r(o, a);
        }, void 0, this.prefiltered);
      }, t;
    }(uo), kE = function(n) {
      function t(e, i, r, o, a, s, l) {
        o === void 0 && (o = !1), a === void 0 && (a = !0), s === void 0 && (s = !1), l === void 0 && (l = !1);
        var c = n.call(this, e) || this;
        return c.name = e, c.url = i, c.size = r, c.noMipmap = o, c.generateHarmonics = a, c.gammaSpace = s, c.reserved = l, c;
      }
      return D(t, n), t.prototype.runTask = function(e, i, r) {
        this.texture = new $h(this.url, e, this.size, this.noMipmap, this.generateHarmonics, this.gammaSpace, this.reserved, function() {
          i();
        }, function(o, a) {
          r(o, a);
        });
      }, t;
    }(uo), GE = function(n) {
      function t(e, i, r, o, a) {
        o === void 0 && (o = !1), a === void 0 && (a = !0);
        var s = n.call(this, e) || this;
        return s.name = e, s.url = i, s.size = r, s.noMipmap = o, s.gammaSpace = a, s;
      }
      return D(t, n), t.prototype.runTask = function(e, i, r) {
        this.texture = new $y(this.url, e, this.size, this.noMipmap, this.gammaSpace, function() {
          i();
        }, function(o, a) {
          r(o, a);
        });
      }, t;
    }(uo), pI = function() {
      function n(t) {
        this._isLoading = !1, this._tasks = new Array(), this._waitingTasksCount = 0, this._totalTasksCount = 0, this.onTaskSuccessObservable = new H(), this.onTaskErrorObservable = new H(), this.onTasksDoneObservable = new H(), this.onProgressObservable = new H(), this.useDefaultLoadingScreen = !0, this.autoHideLoadingUI = !0, this._scene = t || Me.LastCreatedScene;
      }
      return n.prototype.addContainerTask = function(t, e, i, r, o) {
        var a = new NE(t, e, i, r, o);
        return this._tasks.push(a), a;
      }, n.prototype.addMeshTask = function(t, e, i, r, o) {
        var a = new FE(t, e, i, r, o);
        return this._tasks.push(a), a;
      }, n.prototype.addTextFileTask = function(t, e) {
        var i = new LE(t, e);
        return this._tasks.push(i), i;
      }, n.prototype.addBinaryFileTask = function(t, e) {
        var i = new wE(t, e);
        return this._tasks.push(i), i;
      }, n.prototype.addImageTask = function(t, e) {
        var i = new BE(t, e);
        return this._tasks.push(i), i;
      }, n.prototype.addTextureTask = function(t, e, i, r, o) {
        o === void 0 && (o = ae.TRILINEAR_SAMPLINGMODE);
        var a = new UE(t, e, i, r, o);
        return this._tasks.push(a), a;
      }, n.prototype.addCubeTextureTask = function(t, e, i, r, o, a) {
        var s = new VE(t, e, i, r, o, a);
        return this._tasks.push(s), s;
      }, n.prototype.addHDRCubeTextureTask = function(t, e, i, r, o, a, s) {
        r === void 0 && (r = !1), o === void 0 && (o = !0), a === void 0 && (a = !1), s === void 0 && (s = !1);
        var l = new kE(t, e, i, r, o, a, s);
        return this._tasks.push(l), l;
      }, n.prototype.addEquiRectangularCubeTextureAssetTask = function(t, e, i, r, o) {
        r === void 0 && (r = !1), o === void 0 && (o = !0);
        var a = new GE(t, e, i, r, o);
        return this._tasks.push(a), a;
      }, n.prototype.removeTask = function(t) {
        var e = this._tasks.indexOf(t);
        e > -1 && this._tasks.splice(e, 1);
      }, n.prototype._decreaseWaitingTasksCount = function(t) {
        this._waitingTasksCount--;
        try {
          this.onProgress && this.onProgress(this._waitingTasksCount, this._totalTasksCount, t), this.onProgressObservable.notifyObservers(new DE(this._waitingTasksCount, this._totalTasksCount, t));
        } catch (s) {
          q.Error("Error running progress callbacks."), console.log(s);
        }
        if (this._waitingTasksCount === 0) {
          try {
            var e = this._tasks.slice();
            this.onFinish && this.onFinish(e);
            for (var i = 0, r = e; i < r.length; i++) {
              var o = r[i];
              if (o.taskState === Wo.DONE) {
                var a = this._tasks.indexOf(o);
                a > -1 && this._tasks.splice(a, 1);
              }
            }
            this.onTasksDoneObservable.notifyObservers(this._tasks);
          } catch (s) {
            q.Error("Error running tasks-done callbacks."), console.log(s);
          }
          this._isLoading = !1, this.autoHideLoadingUI && this._scene.getEngine().hideLoadingUI();
        }
      }, n.prototype._runTask = function(t) {
        var e = this, i = function(r, o) {
          t._setErrorObject(r, o), e.onTaskError ? e.onTaskError(t) : t.onError || q.Error(e._formatTaskErrorMessage(t)), e.onTaskErrorObservable.notifyObservers(t), e._decreaseWaitingTasksCount(t);
        };
        t.run(this._scene, function() {
          try {
            e.onTaskSuccess && e.onTaskSuccess(t), e.onTaskSuccessObservable.notifyObservers(t), e._decreaseWaitingTasksCount(t);
          } catch (r) {
            i("Error executing task success callbacks", r);
          }
        }, i);
      }, n.prototype._formatTaskErrorMessage = function(t) {
        var e = "Unable to complete task " + t.name;
        return t.errorObject.message && (e += ": ".concat(t.errorObject.message)), t.errorObject.exception && (e += ": ".concat(t.errorObject.exception)), e;
      }, n.prototype.reset = function() {
        return this._isLoading = !1, this._tasks = new Array(), this;
      }, n.prototype.load = function() {
        if (this._isLoading)
          return this;
        if (this._isLoading = !0, this._waitingTasksCount = this._tasks.length, this._totalTasksCount = this._tasks.length, this._waitingTasksCount === 0)
          return this._isLoading = !1, this.onFinish && this.onFinish(this._tasks), this.onTasksDoneObservable.notifyObservers(this._tasks), this;
        this.useDefaultLoadingScreen && this._scene.getEngine().displayLoadingUI();
        for (var t = 0; t < this._tasks.length; t++) {
          var e = this._tasks[t];
          e.taskState === Wo.INIT && this._runTask(e);
        }
        return this;
      }, n.prototype.loadAsync = function() {
        var t = this;
        return new Promise(function(e, i) {
          t._isLoading ? e() : (t.onTasksDoneObservable.addOnce(function(r) {
            r && r.length ? i(r) : e();
          }), t.load());
        });
      }, n;
    }(), fI = function() {
      function n() {
        var t = this;
        this.promise = new Promise(function(e, i) {
          t._resolve = e, t._reject = i;
        });
      }
      return Object.defineProperty(n.prototype, "resolve", { get: function() {
        return this._resolve;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "reject", { get: function() {
        return this._reject;
      }, enumerable: !1, configurable: !0 }), n;
    }(), _I = function() {
      function n(t, e) {
        this._meshesOrigins = [], this._toCenterVectors = [], this._scaledDirection = new v(1, 1, 1), this._newPosition = v.Zero(), this._centerPosition = v.Zero(), this._meshes = t.slice(), e ? this._centerMesh = e : this._setCenterMesh(), this._centerMesh.computeWorldMatrix(!0);
        var i = this._meshes.indexOf(this._centerMesh);
        i >= 0 && this._meshes.splice(i, 1), this._centerPosition = this._centerMesh.getAbsolutePosition().clone();
        for (var r = 0; r < this._meshes.length; r++)
          if (this._meshes[r]) {
            var o = this._meshes[r];
            this._meshesOrigins[r] = o.getAbsolutePosition().clone(), this._toCenterVectors[r] = v.Zero(), o.hasBoundingInfo && this._centerMesh.hasBoundingInfo && (o.computeWorldMatrix(!0), o.getBoundingInfo().boundingBox.centerWorld.subtractToRef(this._centerMesh.getBoundingInfo().boundingBox.centerWorld, this._toCenterVectors[r]));
          }
      }
      return n.prototype._setCenterMesh = function() {
        for (var t = v.Zero(), e = v.Zero(), i = Number.MAX_VALUE, r = 0; r < this._meshes.length; r++)
          this._meshes[r] && (a = (o = this._meshes[r]).getBoundingInfo()) && e.addInPlace(a.boundingBox.centerWorld);
        for (t = e.scale(1 / this._meshes.length), r = 0; r < this._meshes.length; r++) {
          var o, a;
          if (this._meshes[r] && (a = (o = this._meshes[r]).getBoundingInfo())) {
            var s = a.boundingBox.centerWorld.subtract(t).lengthSquared();
            s < i && (this._centerMesh = o, i = s);
          }
        }
      }, n.prototype.getClassName = function() {
        return "MeshExploder";
      }, n.prototype.getMeshes = function() {
        var t = this._meshes.slice();
        return t.unshift(this._centerMesh), t;
      }, n.prototype.explode = function(t) {
        t === void 0 && (t = 1);
        for (var e = 0; e < this._meshes.length; e++)
          this._meshes[e] && this._meshesOrigins[e] && this._toCenterVectors[e] && (this._toCenterVectors[e].scaleToRef(t, this._scaledDirection), this._meshesOrigins[e].addToRef(this._scaledDirection, this._newPosition), this._meshes[e].setAbsolutePosition(this._newPosition));
        this._centerMesh.setAbsolutePosition(this._centerPosition);
      }, n;
    }(), mI = function() {
      function n(t, e, i, r, o, a, s, l, c, u) {
        u === void 0 && (u = !1);
        var h = this;
        this.useAppend = u, this.onProcessFileCallback = function() {
          return !0;
        }, this.displayLoadingUI = !0, this.loadAsync = function(d, p) {
          return h.useAppend ? yi.AppendAsync("file:", d, h._currentScene, p) : yi.LoadAsync("file:", d, h._engine, p);
        }, this._engine = t, this._currentScene = e, this._sceneLoadedCallback = i, this._progressCallback = r, this._additionalRenderLoopLogicCallback = o, this._textureLoadingCallback = a, this._startingProcessingFilesCallback = s, this._onReloadCallback = l, this._errorCallback = c;
      }
      return Object.defineProperty(n, "FilesToLoad", { get: function() {
        return tl.FilesToLoad;
      }, enumerable: !1, configurable: !0 }), n.prototype.monitorElementForDragNDrop = function(t) {
        var e = this;
        t && (this._elementToMonitor = t, this._dragEnterHandler = function(i) {
          e._drag(i);
        }, this._dragOverHandler = function(i) {
          e._drag(i);
        }, this._dropHandler = function(i) {
          e._drop(i);
        }, this._elementToMonitor.addEventListener("dragenter", this._dragEnterHandler, !1), this._elementToMonitor.addEventListener("dragover", this._dragOverHandler, !1), this._elementToMonitor.addEventListener("drop", this._dropHandler, !1));
      }, Object.defineProperty(n.prototype, "filesToLoad", { get: function() {
        return this._filesToLoad;
      }, enumerable: !1, configurable: !0 }), n.prototype.dispose = function() {
        this._elementToMonitor && (this._elementToMonitor.removeEventListener("dragenter", this._dragEnterHandler), this._elementToMonitor.removeEventListener("dragover", this._dragOverHandler), this._elementToMonitor.removeEventListener("drop", this._dropHandler));
      }, n.prototype._renderFunction = function() {
        if (this._additionalRenderLoopLogicCallback && this._additionalRenderLoopLogicCallback(), this._currentScene) {
          if (this._textureLoadingCallback) {
            var t = this._currentScene.getWaitingItemsCount();
            t > 0 && this._textureLoadingCallback(t);
          }
          this._currentScene.render();
        }
      }, n.prototype._drag = function(t) {
        t.stopPropagation(), t.preventDefault();
      }, n.prototype._drop = function(t) {
        t.stopPropagation(), t.preventDefault(), this.loadFiles(t);
      }, n.prototype._traverseFolder = function(t, e, i, r) {
        var o = this, a = t.createReader(), s = t.fullPath.replace(/^\//, "").replace(/(.+?)\/?$/, "$1/");
        a.readEntries(function(l) {
          i.count += l.length;
          for (var c = 0, u = l; c < u.length; c++) {
            var h = u[c];
            h.isFile ? h.file(function(d) {
              d.correctName = s + d.name, e.push(d), --i.count == 0 && r();
            }) : h.isDirectory && o._traverseFolder(h, e, i, r);
          }
          --i.count == 0 && r();
        });
      }, n.prototype._processFiles = function(t) {
        for (var e = this, i = 0; i < t.length; i++) {
          var r = t[i].correctName.toLowerCase(), o = r.split(".").pop();
          this.onProcessFileCallback(t[i], r, o, function(a) {
            return e._sceneFileToLoad = a;
          }) && (yi.IsPluginForExtensionAvailable("." + o) && (this._sceneFileToLoad = t[i]), n.FilesToLoad[r] = t[i]);
        }
      }, n.prototype.loadFiles = function(t) {
        var e = this;
        if (t && t.dataTransfer && t.dataTransfer.files && (this._filesToLoad = t.dataTransfer.files), t && t.target && t.target.files && (this._filesToLoad = t.target.files), this._filesToLoad && this._filesToLoad.length !== 0 && (this._startingProcessingFilesCallback && this._startingProcessingFilesCallback(this._filesToLoad), this._filesToLoad && this._filesToLoad.length > 0)) {
          for (var i = [], r = [], o = t.dataTransfer ? t.dataTransfer.items : null, a = 0; a < this._filesToLoad.length; a++) {
            var s = this._filesToLoad[a], l = s.name.toLowerCase(), c = void 0;
            if (s.correctName = l, o) {
              var u = o[a];
              u.getAsEntry ? c = u.getAsEntry() : u.webkitGetAsEntry && (c = u.webkitGetAsEntry());
            }
            c && c.isDirectory ? r.push(c) : i.push(s);
          }
          if (r.length === 0)
            this._processFiles(i), this._processReload();
          else
            for (var h = { count: r.length }, d = 0, p = r; d < p.length; d++) {
              var f = p[d];
              this._traverseFolder(f, i, h, function() {
                e._processFiles(i), h.count === 0 && e._processReload();
              });
            }
        }
      }, n.prototype._processReload = function() {
        this._onReloadCallback ? this._onReloadCallback(this._sceneFileToLoad) : this.reload();
      }, n.prototype.reload = function() {
        var t = this;
        this._sceneFileToLoad ? (this.useAppend || this._currentScene && (q.errorsCount > 0 && q.ClearLogCache(), this._engine.stopRenderLoop()), yi.ShowLoadingScreen = !1, this.displayLoadingUI && this._engine.displayLoadingUI(), this.loadAsync(this._sceneFileToLoad, this._progressCallback).then(function(e) {
          t.useAppend ? t.displayLoadingUI && t._engine.hideLoadingUI() : (t._currentScene && t._currentScene.dispose(), t._currentScene = e, t._currentScene.executeWhenReady(function() {
            t.displayLoadingUI && t._engine.hideLoadingUI(), t._engine.runRenderLoop(function() {
              t._renderFunction();
            });
          })), t._sceneLoadedCallback && t._currentScene && t._sceneLoadedCallback(t._sceneFileToLoad, t._currentScene);
        }).catch(function(e) {
          t.displayLoadingUI && t._engine.hideLoadingUI(), t._errorCallback && t._errorCallback(t._sceneFileToLoad, t._currentScene, e.message);
        })) : q.Error("Please provide a valid .babylon file.");
      }, n;
    }(), gI = function() {
      function n() {
      }
      return n.prototype.dispose = function() {
        if (this._observers && this._observables)
          for (var t = 0; t < this._observers.length; t++)
            this._observables[t].remove(this._observers[t]);
        this._observers = null, this._observables = null;
      }, n.Watch = function(t, e, i, r) {
        i === void 0 && (i = -1), r === void 0 && (r = null);
        var o = new n();
        o._observers = new Array(), o._observables = t;
        for (var a = 0, s = t; a < s.length; a++) {
          var l = s[a].add(e, i, !1, r);
          l && o._observers.push(l);
        }
        return o;
      }, n;
    }();
    H.prototype.notifyObserversWithPromise = function(n, t, e, i, r) {
      return t === void 0 && (t = -1), Ft(this, void 0, void 0, function() {
        var o, a, s = this;
        return Bt(this, function(l) {
          switch (l.label) {
            case 0:
              return o = Promise.resolve(n), this.observers.length ? ((a = this._eventState).mask = t, a.target = e, a.currentTarget = i, a.skipNextObservers = !1, a.userInfo = r, this.observers.forEach(function(c) {
                a.skipNextObservers || c._willBeUnregistered || c.mask & t && (o = c.scope ? o.then(function(u) {
                  return a.lastReturnValue = u, c.callback.apply(c.scope, [n, a]);
                }) : o.then(function(u) {
                  return a.lastReturnValue = u, c.callback(n, a);
                }), c.unregisterOnNextCall && s._deferUnregister(c));
              }), [4, o]) : [2, o];
            case 1:
              return l.sent(), [2, n];
          }
        });
      });
    };
    var Ho = function() {
      function n(t) {
        t === void 0 && (t = 0), this.priority = t;
      }
      return n.prototype.getDescription = function() {
        return "";
      }, n.prototype.apply = function(t, e) {
        return !0;
      }, n;
    }(), _d = function(n) {
      function t(e, i, r) {
        e === void 0 && (e = 0), i === void 0 && (i = 1024), r === void 0 && (r = 0.5);
        var o = n.call(this, e) || this;
        return o.priority = e, o.maximumSize = i, o.step = r, o;
      }
      return D(t, n), t.prototype.getDescription = function() {
        return "Reducing render target texture size to " + this.maximumSize;
      }, t.prototype.apply = function(e, i) {
        for (var r = !0, o = 0; o < e.textures.length; o++) {
          var a = e.textures[o];
          if (a.canRescale && !a.getContext) {
            var s = a.getSize();
            Math.max(s.width, s.height) > this.maximumSize && (a.scale(this.step), r = !1);
          }
        }
        return r;
      }, t;
    }(Ho), vm = function(n) {
      function t(e, i, r) {
        e === void 0 && (e = 0), i === void 0 && (i = 2), r === void 0 && (r = 0.25);
        var o = n.call(this, e) || this;
        return o.priority = e, o.maximumScale = i, o.step = r, o._currentScale = -1, o._directionOffset = 1, o;
      }
      return D(t, n), t.prototype.getDescription = function() {
        return "Setting hardware scaling level to " + this._currentScale;
      }, t.prototype.apply = function(e, i) {
        return this._currentScale === -1 && (this._currentScale = e.getEngine().getHardwareScalingLevel(), this._currentScale > this.maximumScale && (this._directionOffset = -1)), this._currentScale += this._directionOffset * this.step, e.getEngine().setHardwareScalingLevel(this._currentScale), this._directionOffset === 1 ? this._currentScale >= this.maximumScale : this._currentScale <= this.maximumScale;
      }, t;
    }(Ho), md = function(n) {
      function t() {
        return n !== null && n.apply(this, arguments) || this;
      }
      return D(t, n), t.prototype.getDescription = function() {
        return "Turning shadows on/off";
      }, t.prototype.apply = function(e, i) {
        return e.shadowsEnabled = i.isInImprovementMode, !0;
      }, t;
    }(Ho), gd = function(n) {
      function t() {
        return n !== null && n.apply(this, arguments) || this;
      }
      return D(t, n), t.prototype.getDescription = function() {
        return "Turning post-processes on/off";
      }, t.prototype.apply = function(e, i) {
        return e.postProcessesEnabled = i.isInImprovementMode, !0;
      }, t;
    }(Ho), vd = function(n) {
      function t() {
        return n !== null && n.apply(this, arguments) || this;
      }
      return D(t, n), t.prototype.getDescription = function() {
        return "Turning lens flares on/off";
      }, t.prototype.apply = function(e, i) {
        return e.lensFlaresEnabled = i.isInImprovementMode, !0;
      }, t;
    }(Ho), zE = function(n) {
      function t() {
        return n !== null && n.apply(this, arguments) || this;
      }
      return D(t, n), t.prototype.getDescription = function() {
        return this.onGetDescription ? this.onGetDescription() : "Running user defined callback";
      }, t.prototype.apply = function(e, i) {
        return !this.onApply || this.onApply(e, i);
      }, t;
    }(Ho), yd = function(n) {
      function t() {
        return n !== null && n.apply(this, arguments) || this;
      }
      return D(t, n), t.prototype.getDescription = function() {
        return "Turning particles on/off";
      }, t.prototype.apply = function(e, i) {
        return e.particlesEnabled = i.isInImprovementMode, !0;
      }, t;
    }(Ho), ym = function(n) {
      function t() {
        return n !== null && n.apply(this, arguments) || this;
      }
      return D(t, n), t.prototype.getDescription = function() {
        return "Turning render targets off";
      }, t.prototype.apply = function(e, i) {
        return e.renderTargetsEnabled = i.isInImprovementMode, !0;
      }, t;
    }(Ho), bd = function(n) {
      function t() {
        var e = n !== null && n.apply(this, arguments) || this;
        return e._canBeMerged = function(i) {
          if (!(i instanceof ie))
            return !1;
          var r = i;
          return !(r.isDisposed() || !r.isVisible || !r.isEnabled() || r.instances.length > 0 || r.skeleton || r.hasLODLevels || r.getTotalVertices() === 0);
        }, e;
      }
      return D(t, n), Object.defineProperty(t, "UpdateSelectionTree", { get: function() {
        return t._UpdateSelectionTree;
      }, set: function(e) {
        t._UpdateSelectionTree = e;
      }, enumerable: !1, configurable: !0 }), t.prototype.getDescription = function() {
        return "Merging similar meshes together";
      }, t.prototype.apply = function(e, i, r) {
        for (var o = e.meshes.slice(0), a = o.length, s = 0; s < a; s++) {
          var l = [], c = o[s];
          if (this._canBeMerged(c)) {
            l.push(c);
            for (var u = s + 1; u < a; u++) {
              var h = o[u];
              this._canBeMerged(h) && h.material === c.material && h.checkCollisions === c.checkCollisions && (l.push(h), a--, o.splice(u, 1), u--);
            }
            l.length < 2 || ie.MergeMeshes(l, void 0, !0);
          }
        }
        var d = e;
        return d.createOrUpdateSelectionOctree && (r != null ? r && d.createOrUpdateSelectionOctree() : t.UpdateSelectionTree && d.createOrUpdateSelectionOctree()), !0;
      }, t._UpdateSelectionTree = !1, t;
    }(Ho), bm = function() {
      function n(t, e) {
        t === void 0 && (t = 60), e === void 0 && (e = 2e3), this.targetFrameRate = t, this.trackerDuration = e, this.optimizations = [];
      }
      return n.prototype.addOptimization = function(t) {
        return this.optimizations.push(t), this;
      }, n.prototype.addCustomOptimization = function(t, e, i) {
        i === void 0 && (i = 0);
        var r = new zE(i);
        return r.onApply = t, r.onGetDescription = e, this.optimizations.push(r), this;
      }, n.LowDegradationAllowed = function(t) {
        var e = new n(t), i = 0;
        return e.addOptimization(new bd(i)), e.addOptimization(new md(i)), e.addOptimization(new vd(i)), i++, e.addOptimization(new gd(i)), e.addOptimization(new yd(i)), i++, e.addOptimization(new _d(i, 1024)), e;
      }, n.ModerateDegradationAllowed = function(t) {
        var e = new n(t), i = 0;
        return e.addOptimization(new bd(i)), e.addOptimization(new md(i)), e.addOptimization(new vd(i)), i++, e.addOptimization(new gd(i)), e.addOptimization(new yd(i)), i++, e.addOptimization(new _d(i, 512)), i++, e.addOptimization(new ym(i)), i++, e.addOptimization(new vm(i, 2)), e;
      }, n.HighDegradationAllowed = function(t) {
        var e = new n(t), i = 0;
        return e.addOptimization(new bd(i)), e.addOptimization(new md(i)), e.addOptimization(new vd(i)), i++, e.addOptimization(new gd(i)), e.addOptimization(new yd(i)), i++, e.addOptimization(new _d(i, 256)), i++, e.addOptimization(new ym(i)), i++, e.addOptimization(new vm(i, 4)), e;
      }, n;
    }(), vI = function() {
      function n(t, e, i, r) {
        i === void 0 && (i = !0), r === void 0 && (r = !1);
        var o = this;
        if (this._isRunning = !1, this._currentPriorityLevel = 0, this._targetFrameRate = 60, this._trackerDuration = 2e3, this._currentFrameRate = 0, this._improvementMode = !1, this.onSuccessObservable = new H(), this.onNewOptimizationAppliedObservable = new H(), this.onFailureObservable = new H(), this._options = e || new bm(), this._options.targetFrameRate && (this._targetFrameRate = this._options.targetFrameRate), this._options.trackerDuration && (this._trackerDuration = this._options.trackerDuration), i)
          for (var a = 0, s = 0, l = this._options.optimizations; s < l.length; s++)
            l[s].priority = a++;
        this._improvementMode = r, this._scene = t || Me.LastCreatedScene, this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function() {
          o._sceneDisposeObserver = null, o.dispose();
        });
      }
      return Object.defineProperty(n.prototype, "isInImprovementMode", { get: function() {
        return this._improvementMode;
      }, set: function(t) {
        this._improvementMode = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "currentPriorityLevel", { get: function() {
        return this._currentPriorityLevel;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "currentFrameRate", { get: function() {
        return this._currentFrameRate;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "targetFrameRate", { get: function() {
        return this._targetFrameRate;
      }, set: function(t) {
        this._targetFrameRate = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "trackerDuration", { get: function() {
        return this._trackerDuration;
      }, set: function(t) {
        this._trackerDuration = t;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "optimizations", { get: function() {
        return this._options.optimizations;
      }, enumerable: !1, configurable: !0 }), n.prototype.stop = function() {
        this._isRunning = !1;
      }, n.prototype.reset = function() {
        this._currentPriorityLevel = 0;
      }, n.prototype.start = function() {
        var t = this;
        this._isRunning || (this._isRunning = !0, this._scene.executeWhenReady(function() {
          setTimeout(function() {
            t._checkCurrentState();
          }, t._trackerDuration);
        }));
      }, n.prototype._checkCurrentState = function() {
        var t = this;
        if (this._isRunning) {
          var e = this._scene, i = this._options;
          if (this._currentFrameRate = Math.round(e.getEngine().getFps()), this._improvementMode && this._currentFrameRate <= this._targetFrameRate || !this._improvementMode && this._currentFrameRate >= this._targetFrameRate)
            return this._isRunning = !1, void this.onSuccessObservable.notifyObservers(this);
          for (var r = !0, o = !0, a = 0; a < i.optimizations.length; a++) {
            var s = i.optimizations[a];
            s.priority === this._currentPriorityLevel && (o = !1, r = r && s.apply(e, this), this.onNewOptimizationAppliedObservable.notifyObservers(s));
          }
          if (o)
            return this._isRunning = !1, void this.onFailureObservable.notifyObservers(this);
          r && this._currentPriorityLevel++, e.executeWhenReady(function() {
            setTimeout(function() {
              t._checkCurrentState();
            }, t._trackerDuration);
          });
        }
      }, n.prototype.dispose = function() {
        this.stop(), this.onSuccessObservable.clear(), this.onFailureObservable.clear(), this.onNewOptimizationAppliedObservable.clear(), this._sceneDisposeObserver && this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
      }, n.OptimizeAsync = function(t, e, i, r) {
        var o = new n(t, e || bm.ModerateDegradationAllowed(), !1);
        return i && o.onSuccessObservable.add(function() {
          i();
        }), r && o.onFailureObservable.add(function() {
          r();
        }), o.start(), o;
      }, n;
    }(), WE = [], HE = function(n, t) {
      n.doNotSerialize || (t.vertexData.push(n.serializeVerticeData()), WE[n.id] = !0);
    }, yI = function(n, t) {
      var e = {}, i = n._geometry;
      return i && (n.getScene().getGeometryById(i.id) || HE(i, t.geometries)), n.serialize && n.serialize(e), e;
    }, Td = function() {
      function n() {
      }
      return n.ClearCache = function() {
        WE = [];
      }, n.Serialize = function(t) {
        return n._Serialize(t);
      }, n._Serialize = function(t, e) {
        e === void 0 && (e = !0);
        var i, r, o, a = {};
        if (e && !t.getEngine()._features.supportSyncTextureRead && ae.ForceSerializeBuffers && console.warn("The serialization object may not contain the proper base64 encoded texture data! You should use the SerializeAsync method instead."), n.ClearCache(), a.useDelayedTextureLoading = t.useDelayedTextureLoading, a.autoClear = t.autoClear, a.clearColor = t.clearColor.asArray(), a.ambientColor = t.ambientColor.asArray(), a.gravity = t.gravity.asArray(), a.collisionsEnabled = t.collisionsEnabled, a.useRightHandedSystem = t.useRightHandedSystem, t.fogMode && t.fogMode !== 0 && (a.fogMode = t.fogMode, a.fogColor = t.fogColor.asArray(), a.fogStart = t.fogStart, a.fogEnd = t.fogEnd, a.fogDensity = t.fogDensity), t.isPhysicsEnabled && t.isPhysicsEnabled()) {
          var s = t.getPhysicsEngine();
          s && (a.physicsEnabled = !0, a.physicsGravity = s.gravity.asArray(), a.physicsEngine = s.getPhysicsPluginName());
        }
        t.metadata && (a.metadata = t.metadata), a.morphTargetManagers = [];
        for (var l = 0, c = t.meshes; l < c.length; l++) {
          var u = (T = c[l]).morphTargetManager;
          u && a.morphTargetManagers.push(u.serialize());
        }
        for (a.lights = [], i = 0; i < t.lights.length; i++)
          (r = t.lights[i]).doNotSerialize || a.lights.push(r.serialize());
        for (a.cameras = [], i = 0; i < t.cameras.length; i++) {
          var h = t.cameras[i];
          h.doNotSerialize || a.cameras.push(h.serialize());
        }
        if (t.activeCamera && (a.activeCameraID = t.activeCamera.id), Ne.AppendSerializedAnimations(t, a), t.animationGroups && t.animationGroups.length > 0) {
          a.animationGroups = [];
          for (var d = 0; d < t.animationGroups.length; d++) {
            var p = t.animationGroups[d];
            a.animationGroups.push(p.serialize());
          }
        }
        if (t.reflectionProbes && t.reflectionProbes.length > 0)
          for (a.reflectionProbes = [], i = 0; i < t.reflectionProbes.length; i++) {
            var f = t.reflectionProbes[i];
            a.reflectionProbes.push(f.serialize());
          }
        for (a.materials = [], a.multiMaterials = [], i = 0; i < t.materials.length; i++)
          (o = t.materials[i]).doNotSerialize || a.materials.push(o.serialize());
        for (a.multiMaterials = [], i = 0; i < t.multiMaterials.length; i++) {
          var m = t.multiMaterials[i];
          a.multiMaterials.push(m.serialize());
        }
        for (t.environmentTexture && (t.environmentTexture._files ? a.environmentTexture = t.environmentTexture.serialize() : (a.environmentTexture = t.environmentTexture.name, a.environmentTextureRotationY = t.environmentTexture.rotationY)), a.environmentIntensity = t.environmentIntensity, a.skeletons = [], i = 0; i < t.skeletons.length; i++) {
          var g = t.skeletons[i];
          g.doNotSerialize || a.skeletons.push(g.serialize());
        }
        for (a.transformNodes = [], i = 0; i < t.transformNodes.length; i++)
          t.transformNodes[i].doNotSerialize || a.transformNodes.push(t.transformNodes[i].serialize());
        a.geometries = {}, a.geometries.boxes = [], a.geometries.spheres = [], a.geometries.cylinders = [], a.geometries.toruses = [], a.geometries.grounds = [], a.geometries.planes = [], a.geometries.torusKnots = [], a.geometries.vertexData = [], WE = [];
        var y = t.getGeometries();
        for (i = 0; i < y.length; i++) {
          var b = y[i];
          b.isReady() && HE(b, a.geometries);
        }
        for (a.meshes = [], i = 0; i < t.meshes.length; i++) {
          var T;
          if ((T = t.meshes[i]) instanceof ie) {
            var S = T;
            S.doNotSerialize || S.delayLoadState !== _.DELAYLOADSTATE_LOADED && S.delayLoadState !== _.DELAYLOADSTATE_NONE || a.meshes.push(yI(S, a));
          }
        }
        for (a.particleSystems = [], i = 0; i < t.particleSystems.length; i++)
          a.particleSystems.push(t.particleSystems[i].serialize(!1));
        for (a.postProcesses = [], i = 0; i < t.postProcesses.length; i++)
          a.postProcesses.push(t.postProcesses[i].serialize());
        t.actionManager && (a.actions = t.actionManager.serialize("scene"));
        for (var E = 0, A = t._serializableComponents; E < A.length; E++)
          A[E].serialize(a);
        return a;
      }, n.SerializeAsync = function(t) {
        var e = n._Serialize(t, !1), i = [];
        return this._CollectPromises(e, i), Promise.all(i).then(function() {
          return e;
        });
      }, n._CollectPromises = function(t, e) {
        if (Array.isArray(t))
          for (var i = function(c) {
            var u = t[c];
            u instanceof Promise ? e.push(u.then(function(h) {
              return t[c] = h;
            })) : (u instanceof Object || Array.isArray(u)) && r._CollectPromises(u, e);
          }, r = this, o = 0; o < t.length; ++o)
            i(o);
        else if (t instanceof Object) {
          var a = function(c) {
            if (Object.prototype.hasOwnProperty.call(t, c)) {
              var u = t[c];
              u instanceof Promise ? e.push(u.then(function(h) {
                return t[c] = h;
              })) : (u instanceof Object || Array.isArray(u)) && s._CollectPromises(u, e);
            }
          }, s = this;
          for (var l in t)
            a(l);
        }
      }, n.SerializeMesh = function(t, e, i) {
        e === void 0 && (e = !1), i === void 0 && (i = !1);
        var r = { meshes: [], transformNodes: [], cameras: [], lights: [] };
        if (n.ClearCache(), t = t instanceof Array ? t : [t], e || i)
          for (var o = 0; o < t.length; ++o)
            i && t[o].getDescendants().forEach(function(a) {
              t.indexOf(a) < 0 && !a.doNotSerialize && t.push(a);
            }), e && t[o].parent && t.indexOf(t[o].parent) < 0 && !t[o].parent.doNotSerialize && t.push(t[o].parent);
        return t.forEach(function(a) {
          (function(s, l) {
            if (s._isMesh) {
              var c = s;
              if (c.delayLoadState === _.DELAYLOADSTATE_LOADED || c.delayLoadState === _.DELAYLOADSTATE_NONE) {
                var u = function(b) {
                  l.materials = l.materials || [], c.material && !l.materials.some(function(T) {
                    return T.id === c.material.id;
                  }) && l.materials.push(b.serialize());
                };
                if (c.material && !c.material.doNotSerialize)
                  if (c.material instanceof Ao) {
                    if (l.multiMaterials = l.multiMaterials || [], !l.multiMaterials.some(function(b) {
                      return b.id === c.material.id;
                    })) {
                      l.multiMaterials.push(c.material.serialize());
                      for (var h = 0, d = c.material.subMaterials; h < d.length; h++) {
                        var p = d[h];
                        p && u(p);
                      }
                    }
                  } else
                    u(c.material);
                else
                  c.material || u(c.getScene().defaultMaterial);
                var f = c._geometry;
                f && (l.geometries || (l.geometries = {}, l.geometries.boxes = [], l.geometries.spheres = [], l.geometries.cylinders = [], l.geometries.toruses = [], l.geometries.grounds = [], l.geometries.planes = [], l.geometries.torusKnots = [], l.geometries.vertexData = []), HE(f, l.geometries)), c.skeleton && !c.skeleton.doNotSerialize && (l.skeletons = l.skeletons || [], l.skeletons.push(c.skeleton.serialize())), l.meshes = l.meshes || [], l.meshes.push(yI(c, l));
              }
            } else if (s.getClassName() === "TransformNode") {
              var m = s;
              l.transformNodes.push(m.serialize());
            } else if (s.getClassName().indexOf("Camera") !== -1) {
              var g = s;
              l.cameras.push(g.serialize());
            } else if (s.getClassName().indexOf("Light") !== -1) {
              var y = s;
              l.lights.push(y.serialize());
            }
          })(a, r);
        }), r;
      }, n;
    }(), bI = function() {
      function n(t, e) {
        e === void 0 && (e = {});
        var i = this;
        if (!n.IsSupported(t))
          throw "Your browser does not support recording so far.";
        var r = t.getRenderingCanvas();
        if (!r)
          throw "The babylon engine must have a canvas to be recorded";
        this._canvas = r, this._canvas.isRecording = !1, this._options = je(je({}, n._DefaultOptions), e);
        var o = this._canvas.captureStream(this._options.fps);
        if (this._options.audioTracks)
          for (var a = 0, s = this._options.audioTracks; a < s.length; a++) {
            var l = s[a];
            o.addTrack(l);
          }
        this._mediaRecorder = new MediaRecorder(o, { mimeType: this._options.mimeType }), this._mediaRecorder.ondataavailable = function(c) {
          return i._handleDataAvailable(c);
        }, this._mediaRecorder.onerror = function(c) {
          return i._handleError(c);
        }, this._mediaRecorder.onstop = function() {
          return i._handleStop();
        };
      }
      return n.IsSupported = function(t) {
        var e = t.getRenderingCanvas();
        return !!e && typeof e.captureStream == "function";
      }, Object.defineProperty(n.prototype, "isRecording", { get: function() {
        return !!this._canvas && this._canvas.isRecording;
      }, enumerable: !1, configurable: !0 }), n.prototype.stopRecording = function() {
        this._canvas && this._mediaRecorder && this.isRecording && (this._canvas.isRecording = !1, this._mediaRecorder.stop());
      }, n.prototype.startRecording = function(t, e) {
        var i = this;
        if (t === void 0 && (t = "babylonjs.webm"), e === void 0 && (e = 7), !this._canvas || !this._mediaRecorder)
          throw "Recorder has already been disposed";
        if (this.isRecording)
          throw "Recording already in progress";
        return e > 0 && setTimeout(function() {
          i.stopRecording();
        }, 1e3 * e), this._fileName = t, this._recordedChunks = [], this._resolve = null, this._reject = null, this._canvas.isRecording = !0, this._mediaRecorder.start(this._options.recordChunckSize), new Promise(function(r, o) {
          i._resolve = r, i._reject = o;
        });
      }, n.prototype.dispose = function() {
        this._canvas = null, this._mediaRecorder = null, this._recordedChunks = [], this._fileName = null, this._resolve = null, this._reject = null;
      }, n.prototype._handleDataAvailable = function(t) {
        t.data.size > 0 && this._recordedChunks.push(t.data);
      }, n.prototype._handleError = function(t) {
        if (this.stopRecording(), !this._reject)
          throw new t.error();
        this._reject(t.error);
      }, n.prototype._handleStop = function() {
        this.stopRecording();
        var t = new Blob(this._recordedChunks);
        this._resolve && this._resolve(t), window.URL.createObjectURL(t), this._fileName && de.Download(t, this._fileName);
      }, n._DefaultOptions = { mimeType: "video/webm", fps: 25, recordChunckSize: 3e3 }, n;
    }(), Ls = null;
    function du(n, t, e, i, r, o, a) {
      r === void 0 && (r = "image/png"), o === void 0 && (o = !1);
      var s = TI(n, t, e), l = s.height, c = s.width;
      if (l && c) {
        Ls || (Ls = document.createElement("canvas")), Ls.width = c, Ls.height = l;
        var u = Ls.getContext("2d"), h = n.getRenderWidth() / n.getRenderHeight(), d = c, p = d / h;
        p > l && (d = (p = l) * h);
        var f = Math.max(0, c - d) / 2, m = Math.max(0, l - p) / 2;
        t.getScene().activeCamera !== t ? pu(n, t, e, function(g) {
          if (o) {
            var y = new Blob([g]);
            de.DownloadBlob(y), i && i("");
          } else
            i && i(g);
        }, r, 1, n.getCreationOptions().antialias, void 0, void 0, void 0, void 0, a) : n.onEndFrameObservable.addOnce(function() {
          var g = n.getRenderingCanvas();
          u && g && u.drawImage(g, f, m, d, p), Ls && (o ? (de.EncodeScreenshotCanvasData(Ls, void 0, r, void 0, a), i && i("")) : de.EncodeScreenshotCanvasData(Ls, i, r, void 0, a));
        });
      } else
        q.Error("Invalid 'size' parameter !");
    }
    function Tm(n, t, e, i, r) {
      return i === void 0 && (i = "image/png"), new Promise(function(o, a) {
        du(n, t, e, function(s) {
          s !== void 0 ? o(s) : a(new Error("Data is undefined"));
        }, i, void 0, r);
      });
    }
    function XE(n, t, e, i, r, o) {
      return r === void 0 && (r = "image/png"), new Promise(function(a) {
        du(n, t, { width: e, height: i }, function() {
          a();
        }, r, !0, o);
      });
    }
    function pu(n, t, e, i, r, o, a, s, l, c, u, h, d) {
      r === void 0 && (r = "image/png"), o === void 0 && (o = 1), a === void 0 && (a = !1), l === void 0 && (l = !1), c === void 0 && (c = !1), u === void 0 && (u = !0);
      var p = TI(n, t, e), f = p.height, m = p.width, g = p.finalWidth, y = p.finalHeight, b = { width: m, height: f };
      if (f && m) {
        var T = { width: n.getRenderWidth(), height: n.getRenderHeight() };
        n.setSize(m, f);
        var S = t.getScene(), E = new Mi("screenShot", b, S, !1, !1, _.TEXTURETYPE_UNSIGNED_INT, !1, ae.BILINEAR_SAMPLINGMODE, void 0, c, void 0, void 0, void 0, o);
        E.renderList = S.meshes.slice(), E.samples = o, E.renderSprites = l, E.activeCamera = t, E.forceLayerMaskCheck = u, d == null || d(E);
        var A = function() {
          E.isReadyForRendering() && t.isReady(!0) ? (n.onEndFrameObservable.addOnce(function() {
            g === m && y === f ? E.readPixels(void 0, void 0, void 0, !1).then(function(L) {
              la.DumpData(m, f, L, i, r, s, !0, void 0, h), E.dispose();
            }) : Oh("pass", E.getInternalTexture(), S, void 0, void 0, void 0, g, y).then(function(L) {
              n._readTexturePixels(L, g, y, -1, 0, null, !0, !1, 0, 0).then(function(I) {
                la.DumpData(g, y, I, i, r, s, !0, void 0, h), L.dispose();
              });
            });
          }), E.render(!0), S.incrementRenderId(), S.resetCachedMaterial(), n.setSize(T.width, T.height), t.getProjectionMatrix(!0), S.render()) : setTimeout(A, 16);
        }, R = function() {
          S.incrementRenderId(), S.resetCachedMaterial(), A();
        };
        if (a) {
          var C = new hu("antialiasing", 1, S.activeCamera);
          E.addPostProcess(C), C.getEffect().isReady() ? R() : C.getEffect().onCompiled = function() {
            R();
          };
        } else
          R();
      } else
        q.Error("Invalid 'size' parameter !");
    }
    function Em(n, t, e, i, r, o, a, s, l, c, u) {
      return i === void 0 && (i = "image/png"), r === void 0 && (r = 1), o === void 0 && (o = !1), s === void 0 && (s = !1), l === void 0 && (l = !1), c === void 0 && (c = !0), new Promise(function(h, d) {
        pu(n, t, e, function(p) {
          p !== void 0 ? h(p) : d(new Error("Data is undefined"));
        }, i, r, o, a, s, l, c, u);
      });
    }
    function TI(n, t, e) {
      var i = 0, r = 0, o = 0, a = 0;
      if (typeof e == "object") {
        var s = e.precision ? Math.abs(e.precision) : 1;
        e.width && e.height ? (i = e.height * s, r = e.width * s) : e.width && !e.height ? (r = e.width * s, i = Math.round(r / n.getAspectRatio(t))) : e.height && !e.width ? (i = e.height * s, r = Math.round(i * n.getAspectRatio(t))) : (r = Math.round(n.getRenderWidth() * s), i = Math.round(r / n.getAspectRatio(t))), e.finalWidth && e.finalHeight ? (a = e.finalHeight, o = e.finalWidth) : e.finalWidth && !e.finalHeight ? (o = e.finalWidth, a = Math.round(o / n.getAspectRatio(t))) : e.finalHeight && !e.finalWidth ? (a = e.finalHeight, o = Math.round(a * n.getAspectRatio(t))) : (o = r, a = i);
      } else
        isNaN(e) || (i = e, r = e, o = e, a = e);
      return r && (r = Math.floor(r)), i && (i = Math.floor(i)), o && (o = Math.floor(o)), a && (a = Math.floor(a)), { height: 0 | i, width: 0 | r, finalWidth: 0 | o, finalHeight: 0 | a };
    }
    var Sm, EI = { CreateScreenshot: du, CreateScreenshotAsync: Tm, CreateScreenshotWithResizeAsync: XE, CreateScreenshotUsingRenderTarget: pu, CreateScreenshotUsingRenderTargetAsync: Em };
    de.CreateScreenshot = du, de.CreateScreenshotAsync = Tm, de.CreateScreenshotUsingRenderTarget = pu, de.CreateScreenshotUsingRenderTargetAsync = Em, function(n) {
      n[n.Checkbox = 0] = "Checkbox", n[n.Slider = 1] = "Slider", n[n.Vector3 = 2] = "Vector3", n[n.Quaternion = 3] = "Quaternion", n[n.Color3 = 4] = "Color3", n[n.String = 5] = "String", n[n.Button = 6] = "Button", n[n.Options = 7] = "Options", n[n.Tab = 8] = "Tab", n[n.FileButton = 9] = "FileButton", n[n.Vector2 = 10] = "Vector2";
    }(Sm || (Sm = {}));
    var fu, SI = function() {
      function n(t) {
        this.byteOffset = 0, this.buffer = t;
      }
      return n.prototype.loadAsync = function(t) {
        var e = this;
        return this.buffer.readAsync(this.byteOffset, t).then(function(i) {
          e._dataView = new DataView(i.buffer, i.byteOffset, i.byteLength), e._dataByteOffset = 0;
        });
      }, n.prototype.readUint32 = function() {
        var t = this._dataView.getUint32(this._dataByteOffset, !0);
        return this._dataByteOffset += 4, this.byteOffset += 4, t;
      }, n.prototype.readUint8Array = function(t) {
        var e = new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + this._dataByteOffset, t);
        return this._dataByteOffset += t, this.byteOffset += t, e;
      }, n.prototype.readString = function(t) {
        return ep(this.readUint8Array(t));
      }, n.prototype.skipBytes = function(t) {
        this._dataByteOffset += t, this.byteOffset += t;
      }, n;
    }(), xI = function() {
      function n() {
      }
      return n._GetStorage = function() {
        try {
          return localStorage.setItem("test", ""), localStorage.removeItem("test"), localStorage;
        } catch {
          var t = {};
          return { getItem: function(i) {
            var r = t[i];
            return r === void 0 ? null : r;
          }, setItem: function(i, r) {
            t[i] = r;
          } };
        }
      }, n.ReadString = function(t, e) {
        var i = this._Storage.getItem(t);
        return i !== null ? i : e;
      }, n.WriteString = function(t, e) {
        this._Storage.setItem(t, e);
      }, n.ReadBoolean = function(t, e) {
        var i = this._Storage.getItem(t);
        return i !== null ? i === "true" : e;
      }, n.WriteBoolean = function(t, e) {
        this._Storage.setItem(t, e ? "true" : "false");
      }, n.ReadNumber = function(t, e) {
        var i = this._Storage.getItem(t);
        return i !== null ? parseFloat(i) : e;
      }, n.WriteNumber = function(t, e) {
        this._Storage.setItem(t, e.toString());
      }, n._Storage = n._GetStorage(), n;
    }(), AI = function() {
      function n() {
        this._trackedScene = null;
      }
      return n.prototype.track = function(t) {
        this._trackedScene = t, Ne.AllowLoadingUniqueId = !0, this._savedJSON = Td.Serialize(t), Ne.AllowLoadingUniqueId = !1;
      }, n.prototype.getDelta = function() {
        if (!this._trackedScene)
          return null;
        var t = ae.ForceSerializeBuffers;
        ae.ForceSerializeBuffers = !1, Ne.AllowLoadingUniqueId = !0;
        var e = Td.Serialize(this._trackedScene);
        Ne.AllowLoadingUniqueId = !1;
        var i = {};
        for (var r in e)
          this._compareCollections(r, this._savedJSON[r], e[r], i);
        return ae.ForceSerializeBuffers = t, i;
      }, n.prototype._compareArray = function(t, e, i, r) {
        if (e.length === 0 && i.length === 0)
          return !0;
        if (e.length && !isNaN(e[0]) || i.length && !isNaN(i[0])) {
          if (e.length !== i.length)
            return !1;
          if (e.length === 0)
            return !0;
          for (var o = 0; o < e.length; o++)
            if (e[o] !== i[o])
              return r[t] = i, !1;
          return !0;
        }
        var a = [], s = function(h) {
          var d = e[h], p = d.uniqueId;
          a.push(p);
          var f = i.filter(function(y) {
            return y.uniqueId === p;
          });
          if (f.length) {
            var m = f[0], g = {};
            l._compareObjects(d, m, g) || (r[t] || (r[t] = []), g.__state = { id: m.id || m.name }, r[t].push(g));
          } else
            g = { __state: { deleteId: d.id || d.name } }, r[t] || (r[t] = []), r[t].push(g);
        }, l = this;
        for (o = 0; o < e.length; o++)
          s(o);
        for (o = 0; o < i.length; o++) {
          var c = i[o], u = c.uniqueId;
          a.indexOf(u) === -1 && (r[t] || (r[t] = []), r[t].push(c));
        }
        return !0;
      }, n.prototype._compareObjects = function(t, e, i) {
        var r = !1;
        for (var o in t)
          if (Object.prototype.hasOwnProperty.call(t, o)) {
            var a = t[o], s = e[o], l = !1;
            if (Array.isArray(a))
              l = JSON.stringify(a) !== JSON.stringify(s);
            else if (isNaN(a) && Object.prototype.toString.call(a) != "[object String]") {
              if (typeof a == "object" && typeof s == "object") {
                var c = {};
                this._compareObjects(a, s, c) || (i[o] = c, r = !0);
              }
            } else
              l = a !== s;
            l && (r = !0, i[o] = s);
          }
        return !r;
      }, n.prototype._compareCollections = function(t, e, i, r) {
        if (e !== i && e && i) {
          if (Array.isArray(e) && Array.isArray(i)) {
            if (this._compareArray(t, e, i, r))
              return;
          } else if (typeof e == "object" && typeof i == "object") {
            var o = {};
            return void (this._compareObjects(e, i, o) || (r[t] = o));
          }
        }
      }, n.GetShadowGeneratorById = function(t, e) {
        for (var i = 0, r = t.lights.map(function(c) {
          return c.getShadowGenerators();
        }); i < r.length; i++) {
          var o = r[i];
          if (o)
            for (var a = o.values(), s = a.next(); s.done !== !0; s = a.next()) {
              var l = s.value;
              if (l && l.id === e)
                return l;
            }
        }
        return null;
      }, n.ApplyDelta = function(t, e) {
        var i = this;
        typeof t == "string" && (t = JSON.parse(t));
        var r = e;
        for (var o in t) {
          var a = t[o], s = r[o];
          if (Array.isArray(s) || o === "shadowGenerators")
            switch (o) {
              case "cameras":
                this._ApplyDeltaForEntity(a, e, e.getCameraById.bind(e), function(l) {
                  return dt.Parse(l, e);
                });
                break;
              case "lights":
                this._ApplyDeltaForEntity(a, e, e.getLightById.bind(e), function(l) {
                  return Kn.Parse(l, e);
                });
                break;
              case "shadowGenerators":
                this._ApplyDeltaForEntity(a, e, function(l) {
                  return i.GetShadowGeneratorById(e, l);
                }, function(l) {
                  return ar.Parse(l, e);
                });
                break;
              case "meshes":
                this._ApplyDeltaForEntity(a, e, e.getMeshById.bind(e), function(l) {
                  return ie.Parse(l, e, "");
                });
                break;
              case "skeletons":
                this._ApplyDeltaForEntity(a, e, e.getSkeletonById.bind(e), function(l) {
                  return oh.Parse(l, e);
                });
                break;
              case "materials":
                this._ApplyDeltaForEntity(a, e, e.getMaterialById.bind(e), function(l) {
                  return Et.Parse(l, e, "");
                });
                break;
              case "multiMaterials":
                this._ApplyDeltaForEntity(a, e, e.getMaterialById.bind(e), function(l) {
                  return Ao.Parse(l, e, "");
                });
                break;
              case "transformNodes":
                this._ApplyDeltaForEntity(a, e, e.getTransformNodeById.bind(e), function(l) {
                  return ai.Parse(l, e, "");
                });
                break;
              case "particleSystems":
                this._ApplyDeltaForEntity(a, e, e.getParticleSystemById.bind(e), function(l) {
                  return Ai.Parse(l, e, "");
                });
                break;
              case "morphTargetManagers":
                this._ApplyDeltaForEntity(a, e, e.getMorphTargetById.bind(e), function(l) {
                  return ed.Parse(l, e);
                });
                break;
              case "postProcesses":
                this._ApplyDeltaForEntity(a, e, e.getPostProcessByName.bind(e), function(l) {
                  return nt.Parse(l, e, "");
                });
            }
          else
            isNaN(s) ? s.fromArray && s.fromArray(a) : r[o] = a;
        }
      }, n._ApplyPropertiesToEntity = function(t, e) {
        for (var i in t) {
          var r = t[i], o = e[i];
          o !== void 0 && (!isNaN(o) || Array.isArray(o) ? e[i] = r : o.fromArray ? o.fromArray(r) : typeof o == "object" && o !== null && this._ApplyPropertiesToEntity(r, o));
        }
      }, n._ApplyDeltaForEntity = function(t, e, i, r) {
        for (var o = 0, a = t; o < a.length; o++) {
          var s = a[o];
          if (s.__state && s.__state.id !== void 0) {
            var l = i(s.__state.id);
            l && (this._ApplyPropertiesToEntity(s, l), Ne.ParseProperties(s, l, e, null));
          } else if (s.__state && s.__state.deleteId !== void 0) {
            var c = i(s.__state.deleteId);
            c == null || c.dispose();
          } else
            r(s);
        }
      }, n;
    }();
    (function(n) {
      var t = function() {
        function i(r, o, a, s) {
          var l;
          o === void 0 && (o = null), a === void 0 && (a = null), s === void 0 && (s = null), o = o ?? function() {
            return 1;
          }, a = a ?? function() {
            return 1;
          }, s = s ?? function(h, d) {
            return h === d ? 0 : 1;
          }, this._characterToIdx = /* @__PURE__ */ new Map(), this._insertionCosts = new Array(r.length), this._deletionCosts = new Array(r.length), this._substitutionCosts = new Array(r.length);
          for (var c = 0; c < r.length; ++c) {
            l = r[c], this._characterToIdx.set(l, c), this._insertionCosts[c] = o(l), this._deletionCosts[c] = a(l), this._substitutionCosts[c] = new Array(r.length);
            for (var u = c; u < r.length; ++u)
              this._substitutionCosts[c][u] = s(l, r[u]);
          }
        }
        return i.prototype.serialize = function() {
          var r = {}, o = new Array(this._characterToIdx.size);
          return this._characterToIdx.forEach(function(a, s) {
            o[a] = s;
          }), r.characters = o, r.insertionCosts = this._insertionCosts, r.deletionCosts = this._deletionCosts, r.substitutionCosts = this._substitutionCosts, JSON.stringify(r);
        }, i.Deserialize = function(r) {
          var o = JSON.parse(r), a = new i(o.characters);
          return a._insertionCosts = o.insertionCosts, a._deletionCosts = o.deletionCosts, a._substitutionCosts = o.substitutionCosts, a;
        }, i.prototype.getCharacterIdx = function(r) {
          return this._characterToIdx.get(r);
        }, i.prototype.getInsertionCost = function(r) {
          return this._insertionCosts[r];
        }, i.prototype.getDeletionCost = function(r) {
          return this._deletionCosts[r];
        }, i.prototype.getSubstitutionCost = function(r, o) {
          var a = Math.min(r, o), s = Math.max(r, o);
          return this._substitutionCosts[a][s];
        }, i;
      }();
      n.Alphabet = t;
      var e = function() {
        function i(r, o) {
          var a = this;
          if (r.length > i._MAX_SEQUENCE_LENGTH)
            throw new Error("Sequences longer than " + i._MAX_SEQUENCE_LENGTH + " not supported.");
          this._alphabet = o, this._characters = r.map(function(s) {
            return a._alphabet.getCharacterIdx(s);
          });
        }
        return i.prototype.serialize = function() {
          return JSON.stringify(this._characters);
        }, i.Deserialize = function(r, o) {
          var a = new i([], o);
          return a._characters = JSON.parse(r), a;
        }, i.prototype.distance = function(r) {
          return i._Distance(this, r);
        }, i._Distance = function(r, o) {
          var a = r._alphabet;
          if (a !== o._alphabet)
            throw new Error("Cannot Levenshtein compare Sequences built from different alphabets.");
          var s = r._characters, l = o._characters, c = s.length, u = l.length, h = i._CostMatrix;
          h[0][0] = 0;
          for (var d = 0; d < c; ++d)
            h[d + 1][0] = h[d][0] + a.getInsertionCost(s[d]);
          for (d = 0; d < u; ++d)
            h[0][d + 1] = h[0][d] + a.getInsertionCost(l[d]);
          for (var p = 0; p < c; ++p)
            for (var f = 0; f < u; ++f)
              i._InsertionCost = h[p + 1][f] + a.getInsertionCost(l[f]), i._DeletionCost = h[p][f + 1] + a.getDeletionCost(s[p]), i._SubstitutionCost = h[p][f] + a.getSubstitutionCost(s[p], l[f]), h[p + 1][f + 1] = Math.min(i._InsertionCost, i._DeletionCost, i._SubstitutionCost);
          return h[c][u];
        }, i._MAX_SEQUENCE_LENGTH = 256, i._CostMatrix = js([], Array(i._MAX_SEQUENCE_LENGTH + 1), !0).map(function() {
          return new Array(i._MAX_SEQUENCE_LENGTH + 1);
        }), i;
      }();
      n.Sequence = e;
    })(fu || (fu = {}));
    var RI = function() {
      function n(t) {
        t === void 0 && (t = 0.01), this._points = [], this._segmentLength = t;
      }
      return n.prototype.serialize = function() {
        return JSON.stringify(this);
      }, n.Deserialize = function(t) {
        var e = JSON.parse(t), i = new n(e._segmentLength);
        return i._points = e._points.map(function(r) {
          return new v(r._x, r._y, r._z);
        }), i;
      }, n.prototype.getLength = function() {
        return this._points.length * this._segmentLength;
      }, n.prototype.add = function(t) {
        var e = this, i = this._points.length;
        if (i === 0)
          this._points.push(t.clone());
        else
          for (var r = function() {
            return e._segmentLength / v.Distance(e._points[i - 1], t);
          }, o = r(); o <= 1; o = r()) {
            var a = this._points[i - 1].scale(1 - o);
            t.scaleAndAddToRef(o, a), this._points.push(a), ++i;
          }
      }, n.prototype.resampleAtTargetResolution = function(t) {
        var e = new n(this.getLength() / t);
        return this._points.forEach(function(i) {
          e.add(i);
        }), e;
      }, n.prototype.tokenize = function(t) {
        for (var e = [], i = new v(), r = 2; r < this._points.length; ++r)
          n._TransformSegmentDirToRef(this._points[r - 2], this._points[r - 1], this._points[r], i) && e.push(n._TokenizeSegment(i, t));
        return e;
      }, n._TransformSegmentDirToRef = function(t, e, i, r) {
        return e.subtractToRef(t, n._ForwardDir), n._ForwardDir.normalize(), e.scaleToRef(-1, n._InverseFromVec), n._InverseFromVec.normalize(), !(Math.abs(v.Dot(n._ForwardDir, n._InverseFromVec)) > 0.98 || (v.CrossToRef(n._ForwardDir, n._InverseFromVec, n._UpDir), n._UpDir.normalize(), B.LookAtLHToRef(t, e, n._UpDir, n._LookMatrix), i.subtractToRef(e, n._FromToVec), n._FromToVec.normalize(), v.TransformNormalToRef(n._FromToVec, n._LookMatrix, r), 0));
      }, n._TokenizeSegment = function(t, e) {
        n._BestMatch = 0, n._Score = v.Dot(t, e[0]), n._BestScore = n._Score;
        for (var i = 1; i < e.length; ++i)
          n._Score = v.Dot(t, e[i]), n._Score > n._BestScore && (n._BestMatch = i, n._BestScore = n._Score);
        return n._BestMatch;
      }, n._ForwardDir = new v(), n._InverseFromVec = new v(), n._UpDir = new v(), n._FromToVec = new v(), n._LookMatrix = new B(), n;
    }(), CI = function() {
      function n(t) {
        this.chars = new Array(t);
      }
      return n.Generate = function(t, e, i, r, o) {
        t === void 0 && (t = 64), e === void 0 && (e = 256), i === void 0 && (i = 0.1), r === void 0 && (r = 1e-3), o === void 0 && (o = []);
        for (var a, s, l = new n(t), c = 0; c < t; ++c)
          l.chars[c] = new v(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5), l.chars[c].normalize();
        for (c = 0; c < o.length; ++c)
          l.chars[c].copyFrom(o[c]);
        for (var u, h = new v(), d = new v(), p = 0; p < e; ++p) {
          a = (1 - (u = p / (e - 1))) * i + u * r;
          var f = function(m) {
            h.copyFromFloats(0, 0, 0), l.chars.forEach(function(g) {
              l.chars[m].subtractToRef(g, d), (s = d.lengthSquared()) > 1e-6 && d.scaleAndAddToRef(1 / (d.lengthSquared() * s), h);
            }), h.scaleInPlace(a), l.chars[m].addInPlace(h), l.chars[m].normalize();
          };
          for (c = o.length; c < l.chars.length; ++c)
            f(c);
        }
        return l;
      }, n.prototype.serialize = function() {
        return JSON.stringify(this.chars);
      }, n.Deserialize = function(t) {
        for (var e = JSON.parse(t), i = new n(e.length), r = 0; r < e.length; ++r)
          i.chars[r] = new v(e[r]._x, e[r]._y, e[r]._z);
        return i;
      }, n;
    }(), jE = function() {
      function n() {
        this._sequences = [];
      }
      return n.prototype.serialize = function() {
        return JSON.stringify(this._sequences.map(function(t) {
          return t.serialize();
        }));
      }, n.Deserialize = function(t, e) {
        var i = new n();
        return i._sequences = JSON.parse(t).map(function(r) {
          return fu.Sequence.Deserialize(r, e);
        }), i;
      }, n.CreateFromTrajectory = function(t, e, i) {
        return n.CreateFromTokenizationPyramid(n._GetTokenizationPyramid(t, e), i);
      }, n.CreateFromTokenizationPyramid = function(t, e) {
        var i = new n();
        return i._sequences = t.map(function(r) {
          return new fu.Sequence(r, e);
        }), i;
      }, n._GetTokenizationPyramid = function(t, e, i) {
        i === void 0 && (i = n._FINEST_DESCRIPTOR_RESOLUTION);
        for (var r = [], o = i; o > 4; o = Math.floor(o / 2))
          r.push(t.resampleAtTargetResolution(o).tokenize(e.chars));
        return r;
      }, n.prototype.distance = function(t) {
        for (var e = 0, i = 0; i < this._sequences.length; ++i)
          e += Math.pow(2, i) * this._sequences[i].distance(t._sequences[i]);
        return e;
      }, n._FINEST_DESCRIPTOR_RESOLUTION = 32, n;
    }(), PI = function() {
      function n(t) {
        t === void 0 && (t = []), this._descriptors = t, this._centroidIdx = -1, this._averageDistance = 0, this._refreshDescription();
      }
      return n.prototype.serialize = function() {
        var t = {};
        return t.descriptors = this._descriptors.map(function(e) {
          return e.serialize();
        }), t.centroidIdx = this._centroidIdx, t.averageDistance = this._averageDistance, JSON.stringify(t);
      }, n.Deserialize = function(t, e) {
        var i = JSON.parse(t), r = new n();
        return r._descriptors = i.descriptors.map(function(o) {
          return jE.Deserialize(o, e);
        }), r._centroidIdx = i.centroidIdx, r._averageDistance = i.averageDistance, r;
      }, n.prototype.add = function(t) {
        this._descriptors.push(t), this._refreshDescription();
      }, n.prototype.getMatchCost = function(t) {
        return t.distance(this._descriptors[this._centroidIdx]) / this._averageDistance;
      }, n.prototype.getMatchMinimumDistance = function(t) {
        return Math.min.apply(Math, this._descriptors.map(function(e) {
          return e.distance(t);
        }));
      }, n.prototype._refreshDescription = function() {
        var t, e = this;
        this._centroidIdx = -1;
        for (var i = this._descriptors.map(function(o) {
          return t = 0, e._descriptors.forEach(function(a) {
            t += o.distance(a);
          }), t;
        }), r = 0; r < i.length; ++r)
          (this._centroidIdx < 0 || i[r] < i[this._centroidIdx]) && (this._centroidIdx = r);
        this._averageDistance = 0, this._descriptors.forEach(function(o) {
          e._averageDistance += o.distance(e._descriptors[e._centroidIdx]);
        }), this._descriptors.length > 0 && (this._averageDistance = Math.max(this._averageDistance / this._descriptors.length, n._MIN_AVERAGE_DISTANCE));
      }, n._MIN_AVERAGE_DISTANCE = 1, n;
    }(), II = function() {
      function n() {
        this._maximumAllowableMatchCost = 4, this._nameToDescribedTrajectory = /* @__PURE__ */ new Map();
      }
      return n.prototype.serialize = function() {
        var t = {};
        return t.maximumAllowableMatchCost = this._maximumAllowableMatchCost, t.vector3Alphabet = this._vector3Alphabet.serialize(), t.levenshteinAlphabet = this._levenshteinAlphabet.serialize(), t.nameToDescribedTrajectory = [], this._nameToDescribedTrajectory.forEach(function(e, i) {
          t.nameToDescribedTrajectory.push(i), t.nameToDescribedTrajectory.push(e.serialize());
        }), JSON.stringify(t);
      }, n.Deserialize = function(t) {
        var e = JSON.parse(t), i = new n();
        i._maximumAllowableMatchCost = e.maximumAllowableMatchCost, i._vector3Alphabet = CI.Deserialize(e.vector3Alphabet), i._levenshteinAlphabet = fu.Alphabet.Deserialize(e.levenshteinAlphabet);
        for (var r = 0; r < e.nameToDescribedTrajectory.length; r += 2)
          i._nameToDescribedTrajectory.set(e.nameToDescribedTrajectory[r], PI.Deserialize(e.nameToDescribedTrajectory[r + 1], i._levenshteinAlphabet));
        return i;
      }, n.Generate = function() {
        for (var t = CI.Generate(64, 256, 0.1, 1e-3, [v.Forward()]), e = new Array(t.chars.length), i = 0; i < e.length; ++i)
          e[i] = i;
        var r = new fu.Alphabet(e, function(a) {
          return a === 0 ? 0 : 1;
        }, function(a) {
          return a === 0 ? 0 : 1;
        }, function(a, s) {
          return Math.min(1 - v.Dot(t.chars[a], t.chars[s]), 1);
        }), o = new n();
        return o._vector3Alphabet = t, o._levenshteinAlphabet = r, o;
      }, n.prototype.addTrajectoryToClassification = function(t, e) {
        this._nameToDescribedTrajectory.has(e) || this._nameToDescribedTrajectory.set(e, new PI()), this._nameToDescribedTrajectory.get(e).add(jE.CreateFromTrajectory(t, this._vector3Alphabet, this._levenshteinAlphabet));
      }, n.prototype.deleteClassification = function(t) {
        return this._nameToDescribedTrajectory.delete(t);
      }, n.prototype.classifyTrajectory = function(t) {
        var e = this, i = jE.CreateFromTrajectory(t, this._vector3Alphabet, this._levenshteinAlphabet), r = [];
        if (this._nameToDescribedTrajectory.forEach(function(c, u) {
          c.getMatchCost(i) < e._maximumAllowableMatchCost && r.push(u);
        }), r.length === 0)
          return null;
        for (var o, a = 0, s = this._nameToDescribedTrajectory.get(r[a]).getMatchMinimumDistance(i), l = 0; l < r.length; ++l)
          (o = this._nameToDescribedTrajectory.get(r[l]).getMatchMinimumDistance(i)) < s && (s = o, a = l);
        return r[a];
      }, n;
    }(), MI = function() {
      function n(t, e, i) {
        var r = this;
        this._scene = t, q.Log("[Reflector] Connecting to ws://".concat(e, ":").concat(i)), this._webSocket = new WebSocket("ws://".concat(e, ":").concat(i)), this._webSocket.onmessage = function(o) {
          var a = o.data;
          if (a.startsWith(n._SERVER_PREFIX)) {
            var s = a.substr(n._SERVER_PREFIX.length);
            return q.Log("[Reflector] Received server message: ".concat(s.substr(0, 64))), void r._handleServerMessage(s);
          }
          q.Log("[Reflector] Received client message: ".concat(a.substr(0, 64))), r._handleClientMessage();
        }, this._webSocket.onclose = function(o) {
          q.Log("[Reflector] Disconnected ".concat(o.code, " ").concat(o.reason));
        };
      }
      return n.prototype.close = function() {
        this._webSocket.close();
      }, n.prototype._handleServerMessage = function(t) {
        var e = this;
        t === "connected" && Td.SerializeAsync(this._scene).then(function(i) {
          e._webSocket.send("load|".concat(JSON.stringify(i)));
        });
      }, n.prototype._handleClientMessage = function() {
      }, n._SERVER_PREFIX = "$$", n;
    }(), YE = function() {
      function n(t) {
        var e = this;
        this._observer = null, this._currentState = [], this.onPressureChanged = new H(), n.IsAvailable && (this._observer = new PressureObserver(function(i) {
          e._currentState = i, e.onPressureChanged.notifyObservers(i);
        }, t));
      }
      return Object.defineProperty(n, "IsAvailable", { get: function() {
        return typeof PressureObserver < "u" && PressureObserver.supportedSources.includes("cpu");
      }, enumerable: !1, configurable: !0 }), n.prototype.observe = function(t) {
        var e;
        try {
          (e = this._observer) === null || e === void 0 || e.observe(t), this.onPressureChanged.notifyObservers(this._currentState);
        } catch {
        }
      }, n.prototype.unobserve = function(t) {
        var e;
        try {
          (e = this._observer) === null || e === void 0 || e.unobserve(t);
        } catch {
        }
      }, n.prototype.dispose = function() {
        var t;
        (t = this._observer) === null || t === void 0 || t.disconnect(), this._observer = null, this.onPressureChanged.clear();
      }, n;
    }(), Aa = function() {
      function n(t) {
        this._view = new Float32Array(t), this._itemLength = 0;
      }
      return Object.defineProperty(n.prototype, "itemLength", { get: function() {
        return this._itemLength;
      }, enumerable: !1, configurable: !0 }), n.prototype.at = function(t) {
        return t < 0 || t >= this._itemLength ? NaN : this._view[t];
      }, n.prototype.subarray = function(t, e) {
        return t >= e || t < 0 ? new Float32Array(0) : (e > this._itemLength && (e = this._itemLength), this._view.subarray(t, e));
      }, n.prototype.push = function(t) {
        this._view[this._itemLength] = t, this._itemLength++, this._itemLength >= this._view.length && this._growArray();
      }, n.prototype._growArray = function() {
        var t = Math.floor(1.5 * this._view.length), e = new Float32Array(t);
        e.set(this._view), this._view = e;
      }, n;
    }(), ws = 1800, OI = "timestamp", DI = "numPoints", FN = /\r/g, KE = function() {
      function n(t, e) {
        var i = this;
        this._scene = t, this._collectDataAtFrame = function() {
          var r = It.Now - i._startingTimestamp, o = i.datasets.ids.length, a = i.datasets.startingIndices.itemLength, s = 0;
          if (a > 0) {
            var l = i.datasets.startingIndices.at(a - 1);
            s = l + i.datasets.data.at(l + n.NumberOfPointsOffset) + n.SliceDataOffset;
          }
          if (i.datasets.startingIndices.push(s), i.datasets.data.push(r), i.datasets.data.push(o), i.datasets.ids.forEach(function(h) {
            var d = i._strategies.get(h);
            d && i.datasets.data.push(d.getData());
          }), i.datasetObservable.hasObservers()) {
            for (var c = [r, o], u = 0; u < o; u++)
              c.push(i.datasets.data.at(s + n.SliceDataOffset + u));
            i.datasetObservable.notifyObservers(c);
          }
        }, this.datasets = { ids: [], data: new Aa(ws), startingIndices: new Aa(ws) }, this._strategies = /* @__PURE__ */ new Map(), this._datasetMeta = /* @__PURE__ */ new Map(), this._eventRestoreSet = /* @__PURE__ */ new Set(), this._customEventObservable = new H(), this.datasetObservable = new H(), this.metadataObservable = new H(function(r) {
          return r.callback(i._datasetMeta, new Xe(0));
        }), e && this.addCollectionStrategies.apply(this, e);
      }
      return Object.defineProperty(n, "SliceDataOffset", { get: function() {
        return 2;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n, "NumberOfPointsOffset", { get: function() {
        return 1;
      }, enumerable: !1, configurable: !0 }), n.prototype.registerEvent = function(t, e, i) {
        var r, o = this;
        if (!this._strategies.has(t) || e) {
          this._strategies.has(t) && e && ((r = this._strategies.get(t)) === null || r === void 0 || r.dispose(), this._strategies.delete(t));
          var a = { name: t };
          return this._eventRestoreSet.add(t), this.addCollectionStrategies({ strategyCallback: function(s) {
            var l = 0, c = 0, u = s.onAfterRenderObservable.add(function() {
              c = l, l = 0;
            }), h = o._customEventObservable.add(function(d) {
              t === d.name && (d.value !== void 0 ? l = d.value : l++);
            });
            return { id: t, getData: function() {
              return c;
            }, dispose: function() {
              s.onAfterRenderObservable.remove(u), o._customEventObservable.remove(h);
            } };
          }, category: i }), a;
        }
      }, n.prototype.sendEvent = function(t) {
        this._customEventObservable.notifyObservers(t);
      }, n.prototype._restoreStringEvents = function() {
        var t = this;
        this._eventRestoreSet.size !== this._customEventObservable.observers.length && this._eventRestoreSet.forEach(function(e) {
          t.registerEvent(e, !0);
        });
      }, n.prototype.addCollectionStrategies = function() {
        for (var t = [], e = 0; e < arguments.length; e++)
          t[e] = arguments[e];
        for (var i = 0, r = t; i < r.length; i++) {
          var o = r[i], a = o.strategyCallback, s = o.category, l = o.hidden, c = a(this._scene);
          this._strategies.has(c.id) ? c.dispose() : (this.datasets.ids.push(c.id), s && (s = s.replace(new RegExp("@", "g"), "")), this._datasetMeta.set(c.id, { color: this._getHexColorFromId(c.id), category: s, hidden: l }), this._strategies.set(c.id, c));
        }
        this.metadataObservable.notifyObservers(this._datasetMeta);
      }, n.prototype._getHexColorFromId = function(t) {
        for (var e = 0, i = 0; i < t.length; i++)
          e = t.charCodeAt(i) + ((e << 5) - e);
        var r = "#";
        for (i = 0; i < 24; i += 8)
          r += ("0" + (e >> i & 255).toString(16)).substr(-2);
        return r;
      }, n.prototype.getCurrentSlice = function() {
        var t = this, e = [It.Now - this._startingTimestamp, this.datasets.ids.length];
        this.datasets.ids.forEach(function(i) {
          var r = t._strategies.get(i);
          r && t.datasetObservable.hasObservers() && e.push(r.getData());
        }), this.datasetObservable.hasObservers() && this.datasetObservable.notifyObservers(e);
      }, n.prototype.updateMetadata = function(t, e, i) {
        var r = this._datasetMeta.get(t);
        r && (r[e] = i, this.metadataObservable.notifyObservers(this._datasetMeta));
      }, n.prototype.clear = function(t) {
        this.datasets.data = new Aa(ws), this.datasets.ids.length = 0, this.datasets.startingIndices = new Aa(ws), this._datasetMeta.clear(), this._strategies.forEach(function(e) {
          return e.dispose();
        }), this._strategies.clear(), t || this._eventRestoreSet.clear(), this._hasLoadedData = !1;
      }, Object.defineProperty(n.prototype, "hasLoadedData", { get: function() {
        return this._hasLoadedData;
      }, enumerable: !1, configurable: !0 }), n.prototype.loadFromFileData = function(t, e) {
        var i = t.replace(FN, "").split(`
`).map(function(A) {
          return A.split(",").filter(function(R) {
            return R.length > 0;
          });
        }).filter(function(A) {
          return A.length > 0;
        }), r = n.NumberOfPointsOffset;
        if (i.length < 2)
          return !1;
        var o = { ids: [], data: new Aa(ws), startingIndices: new Aa(ws) }, a = i[0], s = i.slice(1);
        if (a.length < 2 || a[0] !== OI || a[r] !== DI)
          return !1;
        for (var l = /* @__PURE__ */ new Map(), c = n.SliceDataOffset; c < a.length; c++) {
          var u = a[c].split("@"), h = u[0], d = u[1];
          o.ids.push(h), l.set(h, d);
        }
        for (var p = 0, f = 0, m = s; f < m.length; f++) {
          var g = m[f];
          if (g.length < 2)
            return !1;
          var y = parseFloat(g[0]), b = parseInt(g[r]);
          if (isNaN(b) || isNaN(y) || (o.data.push(y), o.data.push(b), b + n.SliceDataOffset !== g.length))
            return !1;
          for (c = n.SliceDataOffset; c < g.length; c++) {
            var T = parseFloat(g[c]);
            if (isNaN(T))
              return !1;
            o.data.push(T);
          }
          o.startingIndices.push(p), p += g.length;
        }
        if (this.datasets.ids = o.ids, this.datasets.data = o.data, this.datasets.startingIndices = o.startingIndices, e || this._datasetMeta.clear(), this._strategies.forEach(function(A) {
          return A.dispose();
        }), this._strategies.clear(), !e)
          for (var S = 0, E = this.datasets.ids; S < E.length; S++)
            h = E[S], d = l.get(h), this._datasetMeta.set(h, { category: d, color: this._getHexColorFromId(h) });
        return this.metadataObservable.notifyObservers(this._datasetMeta), this._hasLoadedData = !0, !0;
      }, n.prototype.exportDataToCsv = function() {
        var t = "";
        t += "".concat(OI, ",").concat(DI);
        for (var e = 0; e < this.datasets.ids.length; e++)
          if (t += ",".concat(this.datasets.ids[e]), this._datasetMeta) {
            var i = this._datasetMeta.get(this.datasets.ids[e]);
            i != null && i.category && (t += "".concat("@").concat(i.category));
          }
        for (t += `
`, e = 0; e < this.datasets.startingIndices.itemLength; e++) {
          var r = this.datasets.startingIndices.at(e), o = this.datasets.data.at(r), a = this.datasets.data.at(r + n.NumberOfPointsOffset);
          t += "".concat(o, ",").concat(a);
          for (var s = 0; s < a; s++)
            t += ",".concat(this.datasets.data.at(r + n.SliceDataOffset + s));
          for (var l = 0; l < this.datasets.ids.length - a; l++)
            t += ",";
          t += `
`;
        }
        var c = "".concat((/* @__PURE__ */ new Date()).toISOString(), "-perfdata.csv");
        de.Download(new Blob([t], { type: "text/csv" }), c);
      }, n.prototype.start = function(t) {
        t ? this._startingTimestamp === void 0 && (this._startingTimestamp = It.Now) : (this.datasets.data = new Aa(ws), this.datasets.startingIndices = new Aa(ws), this._startingTimestamp = It.Now), this._scene.onAfterRenderObservable.add(this._collectDataAtFrame), this._restoreStringEvents(), this._isStarted = !0;
      }, n.prototype.stop = function() {
        this._scene.onAfterRenderObservable.removeCallback(this._collectDataAtFrame), this._isStarted = !1;
      }, Object.defineProperty(n.prototype, "isStarted", { get: function() {
        return this._isStarted;
      }, enumerable: !1, configurable: !0 }), n.prototype.dispose = function() {
        this._scene.onAfterRenderObservable.removeCallback(this._collectDataAtFrame), this._datasetMeta.clear(), this._strategies.forEach(function(t) {
          t.dispose();
        }), this.datasetObservable.clear(), this.metadataObservable.clear(), this._isStarted = !1, this.datasets = null;
      }, n;
    }(), ho = function() {
    }, NI = function() {
      function n() {
      }
      return n.FpsStrategy = function() {
        return function(t) {
          var e = t.getEngine();
          return { id: "FPS", getData: function() {
            return e.getFps();
          }, dispose: ho };
        };
      }, n.ThermalStrategy = function() {
        return this._PressureStrategy("Thermal utilization", "thermal");
      }, n.PowerSupplyStrategy = function() {
        return this._PressureStrategy("Power supply utilization", "power-supply");
      }, n.PressureStrategy = function() {
        return this._PressureStrategy("Pressure");
      }, n._PressureStrategy = function(t, e) {
        return e === void 0 && (e = null), function() {
          var i = 0, r = new YE();
          return r.observe("cpu"), r.onPressureChanged.add(function(o) {
            for (var a, s, l = 0, c = o; l < c.length; l++) {
              var u = c[l];
              if (e && u.factors.includes(e) || !e && ((s = (a = u.factors) === null || a === void 0 ? void 0 : a.length) !== null && s !== void 0 ? s : 0) === 0)
                switch (u.state) {
                  case "nominal":
                    i = 0;
                    break;
                  case "fair":
                    i = 0.25;
                    break;
                  case "serious":
                    i = 0.5;
                    break;
                  case "critical":
                    i = 1;
                }
            }
          }), { id: t, getData: function() {
            return i;
          }, dispose: function() {
            return r.dispose();
          } };
        };
      }, n.TotalMeshesStrategy = function() {
        return function(t) {
          return { id: "Total meshes", getData: function() {
            return t.meshes.length;
          }, dispose: ho };
        };
      }, n.ActiveMeshesStrategy = function() {
        return function(t) {
          return { id: "Active meshes", getData: function() {
            return t.getActiveMeshes().length;
          }, dispose: ho };
        };
      }, n.ActiveIndicesStrategy = function() {
        return function(t) {
          return { id: "Active indices", getData: function() {
            return t.getActiveIndices();
          }, dispose: ho };
        };
      }, n.ActiveFacesStrategy = function() {
        return function(t) {
          return { id: "Active faces", getData: function() {
            return t.getActiveIndices() / 3;
          }, dispose: ho };
        };
      }, n.ActiveBonesStrategy = function() {
        return function(t) {
          return { id: "Active bones", getData: function() {
            return t.getActiveBones();
          }, dispose: ho };
        };
      }, n.ActiveParticlesStrategy = function() {
        return function(t) {
          return { id: "Active particles", getData: function() {
            return t.getActiveParticles();
          }, dispose: ho };
        };
      }, n.DrawCallsStrategy = function() {
        return function(t) {
          var e = 0, i = t.onBeforeAnimationsObservable.add(function() {
            t.getEngine()._drawCalls.fetchNewFrame();
          }), r = t.onAfterRenderObservable.add(function() {
            e = t.getEngine()._drawCalls.current;
          });
          return { id: "Draw calls", getData: function() {
            return e;
          }, dispose: function() {
            t.onBeforeAnimationsObservable.remove(i), t.onAfterRenderObservable.remove(r);
          } };
        };
      }, n.TotalLightsStrategy = function() {
        return function(t) {
          return { id: "Total lights", getData: function() {
            return t.lights.length;
          }, dispose: ho };
        };
      }, n.TotalVerticesStrategy = function() {
        return function(t) {
          return { id: "Total vertices", getData: function() {
            return t.getTotalVertices();
          }, dispose: ho };
        };
      }, n.TotalMaterialsStrategy = function() {
        return function(t) {
          return { id: "Total materials", getData: function() {
            return t.materials.length;
          }, dispose: ho };
        };
      }, n.TotalTexturesStrategy = function() {
        return function(t) {
          return { id: "Total textures", getData: function() {
            return t.textures.length;
          }, dispose: ho };
        };
      }, n.AbsoluteFpsStrategy = function() {
        return function(t) {
          var e = new Uy(t);
          return e.captureFrameTime = !0, { id: "Absolute FPS", getData: function() {
            return 1e3 / e.frameTimeCounter.lastSecAverage;
          }, dispose: ho };
        };
      }, n.MeshesSelectionStrategy = function() {
        return function(t) {
          var e = It.Now, i = 0, r = t.onBeforeActiveMeshesEvaluationObservable.add(function() {
            e = It.Now;
          }), o = t.onAfterActiveMeshesEvaluationObservable.add(function() {
            i = It.Now - e;
          });
          return { id: "Meshes Selection", getData: function() {
            return i;
          }, dispose: function() {
            t.onBeforeActiveMeshesEvaluationObservable.remove(r), t.onAfterActiveMeshesEvaluationObservable.remove(o);
          } };
        };
      }, n.RenderTargetsStrategy = function() {
        return function(t) {
          var e = It.Now, i = 0, r = t.onBeforeRenderTargetsRenderObservable.add(function() {
            e = It.Now;
          }), o = t.onAfterRenderTargetsRenderObservable.add(function() {
            i = It.Now - e;
          });
          return { id: "Render Targets", getData: function() {
            return i;
          }, dispose: function() {
            t.onBeforeRenderTargetsRenderObservable.remove(r), t.onAfterRenderTargetsRenderObservable.remove(o);
          } };
        };
      }, n.ParticlesStrategy = function() {
        return function(t) {
          var e = It.Now, i = 0, r = t.onBeforeParticlesRenderingObservable.add(function() {
            e = It.Now;
          }), o = t.onAfterParticlesRenderingObservable.add(function() {
            i = It.Now - e;
          });
          return { id: "Particles", getData: function() {
            return i;
          }, dispose: function() {
            t.onBeforeParticlesRenderingObservable.remove(r), t.onAfterParticlesRenderingObservable.remove(o);
          } };
        };
      }, n.SpritesStrategy = function() {
        return function(t) {
          var e, i, r = It.Now, o = 0, a = (e = t.onBeforeSpritesRenderingObservable) === null || e === void 0 ? void 0 : e.add(function() {
            r = It.Now;
          }), s = (i = t.onAfterSpritesRenderingObservable) === null || i === void 0 ? void 0 : i.add(function() {
            o = It.Now - r;
          });
          return { id: "Sprites", getData: function() {
            return o;
          }, dispose: function() {
            var l, c;
            (l = t.onBeforeSpritesRenderingObservable) === null || l === void 0 || l.remove(a), (c = t.onAfterSpritesRenderingObservable) === null || c === void 0 || c.remove(s);
          } };
        };
      }, n.AnimationsStrategy = function() {
        return function(t) {
          var e = It.Now, i = 0, r = t.onBeforeAnimationsObservable.add(function() {
            e = It.Now;
          }), o = t.onAfterAnimationsObservable.add(function() {
            i = It.Now - e;
          });
          return { id: "Animations", getData: function() {
            return i;
          }, dispose: function() {
            t.onBeforeAnimationsObservable.remove(r), t.onAfterAnimationsObservable.remove(o);
          } };
        };
      }, n.PhysicsStrategy = function() {
        return function(t) {
          var e, i, r = It.Now, o = 0, a = (e = t.onBeforePhysicsObservable) === null || e === void 0 ? void 0 : e.add(function() {
            r = It.Now;
          }), s = (i = t.onAfterPhysicsObservable) === null || i === void 0 ? void 0 : i.add(function() {
            o = It.Now - r;
          });
          return { id: "Physics", getData: function() {
            return o;
          }, dispose: function() {
            var l, c;
            (l = t.onBeforePhysicsObservable) === null || l === void 0 || l.remove(a), (c = t.onAfterPhysicsObservable) === null || c === void 0 || c.remove(s);
          } };
        };
      }, n.RenderStrategy = function() {
        return function(t) {
          var e = It.Now, i = 0, r = t.onBeforeDrawPhaseObservable.add(function() {
            e = It.Now;
          }), o = t.onAfterDrawPhaseObservable.add(function() {
            i = It.Now - e;
          });
          return { id: "Render", getData: function() {
            return i;
          }, dispose: function() {
            t.onBeforeDrawPhaseObservable.remove(r), t.onAfterDrawPhaseObservable.remove(o);
          } };
        };
      }, n.FrameTotalStrategy = function() {
        return function(t) {
          var e = It.Now, i = 0, r = t.onBeforeAnimationsObservable.add(function() {
            e = It.Now;
          }), o = t.onAfterRenderObservable.add(function() {
            i = It.Now - e;
          });
          return { id: "Frame Total", getData: function() {
            return i;
          }, dispose: function() {
            t.onBeforeAnimationsObservable.remove(r), t.onAfterRenderObservable.remove(o);
          } };
        };
      }, n.InterFrameStrategy = function() {
        return function(t) {
          var e = It.Now, i = 0, r = t.onBeforeAnimationsObservable.add(function() {
            i = It.Now - e;
          }), o = t.onAfterRenderObservable.add(function() {
            e = It.Now;
          });
          return { id: "Inter-frame", getData: function() {
            return i;
          }, dispose: function() {
            t.onBeforeAnimationsObservable.remove(r), t.onAfterRenderObservable.remove(o);
          } };
        };
      }, n.GpuFrameTimeStrategy = function() {
        return function(t) {
          var e = new By(t.getEngine());
          return e.captureGPUFrameTime = !0, { id: "GPU frame time", getData: function() {
            return Math.max(1e-6 * e.gpuFrameTimeCounter.current, 0);
          }, dispose: function() {
            e.dispose();
          } };
        };
      }, n;
    }();
    Ue.prototype.getPerfCollector = function() {
      return this._perfCollector || (this._perfCollector = new KE(this)), this._perfCollector;
    }, H.prototype.runCoroutineAsync = function(n) {
      if (!this._coroutineScheduler) {
        var t = function(e) {
          var i = new Array(), r = new Array(), o = new Array(), a = e.add(function() {
            for (var s = i.length, l = 0; l < s; l++)
              sc(i.shift(), r.shift(), o.shift());
          });
          return { scheduler: function(s, l, c) {
            i.push(s), r.push(l), o.push(c);
          }, dispose: function() {
            e.remove(a);
          } };
        }(this);
        this._coroutineScheduler = t.scheduler, this._coroutineSchedulerDispose = t.dispose;
      }
      return Yu(n, this._coroutineScheduler);
    }, H.prototype.cancelAllCoroutines = function() {
      this._coroutineSchedulerDispose && this._coroutineSchedulerDispose(), this._coroutineScheduler = void 0, this._coroutineSchedulerDispose = void 0;
    };
    function FI(n, t) {
      var e, i;
      return Ft(this, void 0, void 0, function() {
        var r, o, a, s;
        return Bt(this, function(l) {
          return r = (e = t.probe) !== null && e !== void 0 ? e : new C_("tempProbe", t.size, n), (o = !!t.probe) || (t.position ? r.position = t.position.clone() : n.activeCamera && (r.position = n.activeCamera.position.clone())), a = t.meshesFilter ? n.meshes.filter(t.meshesFilter) : n.meshes, (i = r.renderList) === null || i === void 0 || i.push.apply(i, a), r.refreshRate = Mi.REFRESHRATE_RENDER_ONCE, r.cubeTexture.render(), (s = new ab("tempProceduralTexture", "equirectangularPanorama", { width: 2 * t.size, height: t.size }, n)).setTexture("cubeMap", r.cubeTexture), [2, new Promise(function(c, u) {
            s.onGeneratedObservable.addOnce(function() {
              var h = s.readPixels();
              if (!h)
                return u(new Error("No Pixel Data found on procedural texture")), s.dispose(), void (o || r.dispose());
              h.then(function(d) {
                s.dispose(), o || r.dispose(), t.filename ? (la.DumpData(2 * t.size, t.size, d, void 0, "image/png", t.filename), c(null)) : c(d);
              });
            });
          })];
        });
      });
    }
    re.ShadersStore.equirectangularPanoramaPixelShader = `#ifdef GL_ES
precision highp float;
#endif
#define M_PI 3.1415926535897932384626433832795
varying vec2 vUV;uniform samplerCube cubeMap;void main(void) {vec2 uv=vUV;float longitude=uv.x*2.*M_PI-M_PI+M_PI/2.;float latitude=(1.-uv.y)*M_PI;vec3 dir=vec3(
- sin( longitude )*sin( latitude ),
cos( latitude ),
- cos( longitude )*sin( latitude )
);normalize( dir );gl_FragColor=textureCube( cubeMap,dir );}`;
    var Ed = function(n) {
      function t(e, i) {
        i === void 0 && (i = {});
        var r = n.call(this, e) || this;
        return r.options = i, r._direction = new v(0, 0, -1), r._mat = new B(), r._onSelectEnabled = !1, r._origin = new v(0, 0, 0), r.lastNativeXRHitResults = [], r.onHitTestResultObservable = new H(), r._onHitTestResults = function(o) {
          var a = o.map(function(s) {
            var l = B.FromArray(s.hitMatrix);
            return r._xrSessionManager.scene.useRightHandedSystem || l.toggleModelMatrixHandInPlace(), r.options.worldParentNode && l.multiplyToRef(r.options.worldParentNode.getWorldMatrix(), l), { xrHitResult: s, transformationMatrix: l };
          });
          r.lastNativeXRHitResults = o, r.onHitTestResultObservable.notifyObservers(a);
        }, r._onSelect = function(o) {
          r._onSelectEnabled && t.XRHitTestWithSelectEvent(o, r._xrSessionManager.referenceSpace);
        }, r.xrNativeFeatureName = "hit-test", de.Warn("A newer version of this plugin is available"), r;
      }
      return D(t, n), t.XRHitTestWithRay = function(e, i, r, o) {
        return e.requestHitTest(i, r).then(function(a) {
          var s = o || function(l) {
            return !!l.hitMatrix;
          };
          return a.filter(s);
        });
      }, t.XRHitTestWithSelectEvent = function(e, i) {
        var r = e.frame.getPose(e.inputSource.targetRaySpace, i);
        if (!r)
          return Promise.resolve([]);
        var o = new XRRay(r.transform);
        return this.XRHitTestWithRay(e.frame.session, o, i);
      }, t.prototype.attach = function() {
        return !!n.prototype.attach.call(this) && (this.options.testOnPointerDownOnly && this._xrSessionManager.session.addEventListener("select", this._onSelect, !1), !0);
      }, t.prototype.detach = function() {
        return !!n.prototype.detach.call(this) && (this._onSelectEnabled = !1, this._xrSessionManager.session.removeEventListener("select", this._onSelect), !0);
      }, t.prototype.dispose = function() {
        n.prototype.dispose.call(this), this.onHitTestResultObservable.clear();
      }, t.prototype._onXRFrame = function(e) {
        if (this.attached && !this.options.testOnPointerDownOnly) {
          var i = e.getViewerPose(this._xrSessionManager.referenceSpace);
          if (i) {
            B.FromArrayToRef(i.transform.matrix, 0, this._mat), v.TransformCoordinatesFromFloatsToRef(0, 0, 0, this._mat, this._origin), v.TransformCoordinatesFromFloatsToRef(0, 0, -1, this._mat, this._direction), this._direction.subtractInPlace(this._origin), this._direction.normalize();
            var r = new XRRay({ x: this._origin.x, y: this._origin.y, z: this._origin.z, w: 0 }, { x: this._direction.x, y: this._direction.y, z: this._direction.z, w: 0 });
            t.XRHitTestWithRay(this._xrSessionManager.session, r, this._xrSessionManager.referenceSpace).then(this._onHitTestResults);
          }
        }
      }, t.Name = vi.HIT_TEST, t.Version = 1, t;
    }(Qi);
    Wi.AddWebXRFeature(Ed.Name, function(n, t) {
      return function() {
        return new Ed(n, t);
      };
    }, Ed.Version, !1);
    var LN = 0, Sd = function(n) {
      function t(e, i) {
        i === void 0 && (i = {});
        var r = n.call(this, e) || this;
        return r._options = i, r._lastFrameDetected = /* @__PURE__ */ new Set(), r._trackedAnchors = [], r._futureAnchors = [], r.onAnchorAddedObservable = new H(), r.onAnchorRemovedObservable = new H(), r.onAnchorUpdatedObservable = new H(), r._tmpVector = new v(), r._tmpQuaternion = new oe(), r.xrNativeFeatureName = "anchors", r;
      }
      return D(t, n), Object.defineProperty(t.prototype, "referenceSpaceForFrameAnchors", { set: function(e) {
        this._referenceSpaceForFrameAnchors = e;
      }, enumerable: !1, configurable: !0 }), t.prototype._populateTmpTransformation = function(e, i) {
        return this._tmpVector.copyFrom(e), this._tmpQuaternion.copyFrom(i), this._xrSessionManager.scene.useRightHandedSystem || (this._tmpVector.z *= -1, this._tmpQuaternion.z *= -1, this._tmpQuaternion.w *= -1), { position: this._tmpVector, rotationQuaternion: this._tmpQuaternion };
      }, t.prototype.addAnchorPointUsingHitTestResultAsync = function(e, i, r) {
        return i === void 0 && (i = new v()), r === void 0 && (r = new oe()), Ft(this, void 0, void 0, function() {
          var o, a, s, l = this;
          return Bt(this, function(c) {
            switch (c.label) {
              case 0:
                if (this._populateTmpTransformation(i, r), o = new XRRigidTransform({ x: this._tmpVector.x, y: this._tmpVector.y, z: this._tmpVector.z }, { x: this._tmpQuaternion.x, y: this._tmpQuaternion.y, z: this._tmpQuaternion.z, w: this._tmpQuaternion.w }), e.xrHitResult.createAnchor)
                  return [3, 1];
                throw this.detach(), new Error("Anchors not enabled in this environment/browser");
              case 1:
                return c.trys.push([1, 3, , 4]), [4, e.xrHitResult.createAnchor(o)];
              case 2:
                return a = c.sent(), [2, new Promise(function(u, h) {
                  l._futureAnchors.push({ nativeAnchor: a, resolved: !1, submitted: !0, xrTransformation: o, resolve: u, reject: h });
                })];
              case 3:
                throw s = c.sent(), new Error(s);
              case 4:
                return [2];
            }
          });
        });
      }, t.prototype.addAnchorAtPositionAndRotationAsync = function(e, i, r) {
        return i === void 0 && (i = new oe()), r === void 0 && (r = !1), Ft(this, void 0, void 0, function() {
          var o, a, s, l = this;
          return Bt(this, function(c) {
            switch (c.label) {
              case 0:
                return this._populateTmpTransformation(e, i), o = new XRRigidTransform({ x: this._tmpVector.x, y: this._tmpVector.y, z: this._tmpVector.z }, { x: this._tmpQuaternion.x, y: this._tmpQuaternion.y, z: this._tmpQuaternion.z, w: this._tmpQuaternion.w }), r && this.attached && this._xrSessionManager.currentFrame ? [4, this._createAnchorAtTransformation(o, this._xrSessionManager.currentFrame)] : [3, 2];
              case 1:
                return s = c.sent(), [3, 3];
              case 2:
                s = void 0, c.label = 3;
              case 3:
                return a = s, [2, new Promise(function(u, h) {
                  l._futureAnchors.push({ nativeAnchor: a, resolved: !1, submitted: !1, xrTransformation: o, resolve: u, reject: h });
                })];
            }
          });
        });
      }, Object.defineProperty(t.prototype, "anchors", { get: function() {
        return this._trackedAnchors;
      }, enumerable: !1, configurable: !0 }), t.prototype.detach = function() {
        if (!n.prototype.detach.call(this))
          return !1;
        if (!this._options.doNotRemoveAnchorsOnSessionEnded)
          for (; this._trackedAnchors.length; ) {
            var e = this._trackedAnchors.pop();
            if (e) {
              try {
                e.remove();
              } catch {
              }
              this.onAnchorRemovedObservable.notifyObservers(e);
            }
          }
        return !0;
      }, t.prototype.dispose = function() {
        this._futureAnchors.length = 0, n.prototype.dispose.call(this), this.onAnchorAddedObservable.clear(), this.onAnchorRemovedObservable.clear(), this.onAnchorUpdatedObservable.clear();
      }, t.prototype._onXRFrame = function(e) {
        var i = this;
        if (this.attached && e) {
          var r = e.trackedAnchors;
          if (r) {
            var o = this._trackedAnchors.filter(function(s) {
              return !r.has(s.xrAnchor);
            }).map(function(s) {
              return i._trackedAnchors.indexOf(s);
            }), a = 0;
            o.forEach(function(s) {
              var l = i._trackedAnchors.splice(s - a, 1)[0];
              i.onAnchorRemovedObservable.notifyObservers(l), a++;
            }), r.forEach(function(s) {
              if (i._lastFrameDetected.has(s)) {
                var l = i._findIndexInAnchorArray(s);
                u = i._trackedAnchors[l];
                try {
                  i._updateAnchorWithXRFrame(s, u, e), u.attachedNode && (u.attachedNode.rotationQuaternion = u.attachedNode.rotationQuaternion || new oe(), u.transformationMatrix.decompose(u.attachedNode.scaling, u.attachedNode.rotationQuaternion, u.attachedNode.position)), i.onAnchorUpdatedObservable.notifyObservers(u);
                } catch {
                  de.Warn("Anchor could not be updated");
                }
              } else {
                var c = { id: LN++, xrAnchor: s, remove: function() {
                  return s.delete();
                } }, u = i._updateAnchorWithXRFrame(s, c, e);
                i._trackedAnchors.push(u), i.onAnchorAddedObservable.notifyObservers(u);
                var h = i._futureAnchors.filter(function(d) {
                  return d.nativeAnchor === s;
                })[0];
                h && (h.resolve(u), h.resolved = !0);
              }
            }), this._lastFrameDetected = r;
          }
          this._futureAnchors.forEach(function(s) {
            s.resolved || s.submitted || (i._createAnchorAtTransformation(s.xrTransformation, e).then(function(l) {
              s.nativeAnchor = l;
            }, function(l) {
              s.resolved = !0, s.reject(l);
            }), s.submitted = !0);
          });
        }
      }, t.prototype._findIndexInAnchorArray = function(e) {
        for (var i = 0; i < this._trackedAnchors.length; ++i)
          if (this._trackedAnchors[i].xrAnchor === e)
            return i;
        return -1;
      }, t.prototype._updateAnchorWithXRFrame = function(e, i, r) {
        var o = r.getPose(e.anchorSpace, this._xrSessionManager.referenceSpace);
        if (o) {
          var a = i.transformationMatrix || new B();
          B.FromArrayToRef(o.transform.matrix, 0, a), this._xrSessionManager.scene.useRightHandedSystem || a.toggleModelMatrixHandInPlace(), i.transformationMatrix = a, this._options.worldParentNode && a.multiplyToRef(this._options.worldParentNode.getWorldMatrix(), a);
        }
        return i;
      }, t.prototype._createAnchorAtTransformation = function(e, i) {
        var r;
        return Ft(this, void 0, void 0, function() {
          return Bt(this, function(o) {
            if (!i.createAnchor)
              throw this.detach(), new Error("Anchors are not enabled in your browser");
            try {
              return [2, i.createAnchor(e, (r = this._referenceSpaceForFrameAnchors) !== null && r !== void 0 ? r : this._xrSessionManager.referenceSpace)];
            } catch (a) {
              throw new Error(a);
            }
            return [2];
          });
        });
      }, t.Name = vi.ANCHOR_SYSTEM, t.Version = 1, t;
    }(Qi);
    Wi.AddWebXRFeature(Sd.Name, function(n, t) {
      return function() {
        return new Sd(n, t);
      };
    }, Sd.Version);
    var wN = 0, xd = function(n) {
      function t(e, i) {
        i === void 0 && (i = {});
        var r = n.call(this, e) || this;
        return r._options = i, r._detectedPlanes = [], r._enabled = !1, r._lastFrameDetected = /* @__PURE__ */ new Set(), r.onPlaneAddedObservable = new H(), r.onPlaneRemovedObservable = new H(), r.onPlaneUpdatedObservable = new H(), r.xrNativeFeatureName = "plane-detection", r._xrSessionManager.session ? r._init() : r._xrSessionManager.onXRSessionInit.addOnce(function() {
          r._init();
        }), r;
      }
      return D(t, n), t.prototype.detach = function() {
        if (!n.prototype.detach.call(this))
          return !1;
        if (!this._options.doNotRemovePlanesOnSessionEnded)
          for (; this._detectedPlanes.length; ) {
            var e = this._detectedPlanes.pop();
            e && this.onPlaneRemovedObservable.notifyObservers(e);
          }
        return !0;
      }, t.prototype.dispose = function() {
        n.prototype.dispose.call(this), this.onPlaneAddedObservable.clear(), this.onPlaneRemovedObservable.clear(), this.onPlaneUpdatedObservable.clear();
      }, t.prototype.isCompatible = function() {
        return typeof XRPlane < "u";
      }, t.prototype.initiateRoomCapture = function() {
        return Ft(this, void 0, void 0, function() {
          return Bt(this, function(e) {
            return this._xrSessionManager.session.initiateRoomCapture ? [2, this._xrSessionManager.session.initiateRoomCapture()] : [2, Promise.reject("initiateRoomCapture is not supported on this session")];
          });
        });
      }, t.prototype._onXRFrame = function(e) {
        var i, r = this;
        if (this.attached && this._enabled && e) {
          var o = e.detectedPlanes || ((i = e.worldInformation) === null || i === void 0 ? void 0 : i.detectedPlanes);
          if (o) {
            for (var a = 0; a < this._detectedPlanes.length; a++) {
              var s = this._detectedPlanes[a];
              o.has(s.xrPlane) || (this._detectedPlanes.splice(a--, 1), this.onPlaneRemovedObservable.notifyObservers(s));
            }
            o.forEach(function(l) {
              if (r._lastFrameDetected.has(l)) {
                if (l.lastChangedTime === r._xrSessionManager.currentTimestamp) {
                  var c = r._findIndexInPlaneArray(l);
                  h = r._detectedPlanes[c], r._updatePlaneWithXRPlane(l, h, e), r.onPlaneUpdatedObservable.notifyObservers(h);
                }
              } else {
                var u = { id: wN++, xrPlane: l, polygonDefinition: [] }, h = r._updatePlaneWithXRPlane(l, u, e);
                r._detectedPlanes.push(h), r.onPlaneAddedObservable.notifyObservers(h);
              }
            }), this._lastFrameDetected = o;
          }
        }
      }, t.prototype._init = function() {
        var e = this, i = function() {
          e._enabled = !0, e._detectedPlanes.length && (e._detectedPlanes.length = 0);
        };
        this._xrSessionManager.isNative && this._options.preferredDetectorOptions && this._xrSessionManager.session.trySetPreferredPlaneDetectorOptions && this._xrSessionManager.session.trySetPreferredPlaneDetectorOptions(this._options.preferredDetectorOptions), this._xrSessionManager.session.updateWorldTrackingState && this._xrSessionManager.session.updateWorldTrackingState({ planeDetectionState: { enabled: !0 } }), i();
      }, t.prototype._updatePlaneWithXRPlane = function(e, i, r) {
        var o = this;
        i.polygonDefinition = e.polygon.map(function(l) {
          var c = o._xrSessionManager.scene.useRightHandedSystem ? 1 : -1;
          return new v(l.x, l.y, l.z * c);
        });
        var a = r.getPose(e.planeSpace, this._xrSessionManager.referenceSpace);
        if (a) {
          var s = i.transformationMatrix || new B();
          B.FromArrayToRef(a.transform.matrix, 0, s), this._xrSessionManager.scene.useRightHandedSystem || s.toggleModelMatrixHandInPlace(), i.transformationMatrix = s, this._options.worldParentNode && s.multiplyToRef(this._options.worldParentNode.getWorldMatrix(), s);
        }
        return i;
      }, t.prototype._findIndexInPlaneArray = function(e) {
        for (var i = 0; i < this._detectedPlanes.length; ++i)
          if (this._detectedPlanes[i].xrPlane === e)
            return i;
        return -1;
      }, t.Name = vi.PLANE_DETECTION, t.Version = 1, t;
    }(Qi);
    Wi.AddWebXRFeature(xd.Name, function(n, t) {
      return function() {
        return new xd(n, t);
      };
    }, xd.Version);
    var Ad = function(n) {
      function t(e, i) {
        i === void 0 && (i = {});
        var r = n.call(this, e) || this;
        return r.options = i, r.onBackgroundStateChangedObservable = new H(), r;
      }
      return D(t, n), t.prototype.attach = function() {
        return this._setBackgroundState(!1), n.prototype.attach.call(this);
      }, t.prototype.detach = function() {
        return this._setBackgroundState(!0), n.prototype.detach.call(this);
      }, t.prototype.dispose = function() {
        n.prototype.dispose.call(this), this.onBackgroundStateChangedObservable.clear();
      }, t.prototype._onXRFrame = function(e) {
      }, t.prototype._setBackgroundState = function(e) {
        var i = this._xrSessionManager.scene;
        if (!this.options.ignoreEnvironmentHelper)
          if (this.options.environmentHelperRemovalFlags) {
            if (this.options.environmentHelperRemovalFlags.skyBox) {
              var r = i.getMeshByName("BackgroundSkybox");
              r && r.setEnabled(e);
            }
            if (this.options.environmentHelperRemovalFlags.ground) {
              var o = i.getMeshByName("BackgroundPlane");
              o && o.setEnabled(e);
            }
          } else {
            var a = i.getMeshByName("BackgroundHelper");
            a && a.setEnabled(e);
          }
        this.options.backgroundMeshes && this.options.backgroundMeshes.forEach(function(s) {
          return s.setEnabled(e);
        }), this.onBackgroundStateChangedObservable.notifyObservers(e);
      }, t.Name = vi.BACKGROUND_REMOVER, t.Version = 1, t;
    }(Qi);
    Wi.AddWebXRFeature(Ad.Name, function(n, t) {
      return function() {
        return new Ad(n, t);
      };
    }, Ad.Version, !0);
    var LI = function() {
    }, Rd = function(n) {
      function t(e, i) {
        var r = n.call(this, e) || this;
        return r._options = i, r._attachController = function(o) {
          r._controllers[o.uniqueId] || (r._xrSessionManager.scene.isPhysicsEnabled() || q.Warn("physics engine not enabled, skipped. Please add this controller manually."), r._options.physicsProperties.useControllerMesh && o.inputSource.gamepad ? o.onMotionControllerInitObservable.addOnce(function(a) {
            a._doNotLoadControllerMesh ? r._createPhysicsImpostor(o) : a.onModelLoadedObservable.addOnce(function() {
              var s = new bt(a.rootMesh, bt.MeshImpostor, je({ mass: 0 }, r._options.physicsProperties)), l = o.grip || o.pointer;
              r._controllers[o.uniqueId] = { xrController: o, impostor: s, oldPos: l.position.clone(), oldRotation: l.rotationQuaternion.clone() };
            });
          }) : r._createPhysicsImpostor(o));
        }, r._controllers = {}, r._debugMode = !1, r._delta = 0, r._lastTimestamp = 0, r._tmpQuaternion = new oe(), r._tmpVector = new v(), r._options.physicsProperties || (r._options.physicsProperties = {}), r;
      }
      return D(t, n), t.prototype._createPhysicsImpostor = function(e) {
        var i = this._options.physicsProperties.impostorType || bt.SphereImpostor, r = this._options.physicsProperties.impostorSize || 0.1, o = yn("impostor-mesh-" + e.uniqueId, { diameterX: typeof r == "number" ? r : r.width, diameterY: typeof r == "number" ? r : r.height, diameterZ: typeof r == "number" ? r : r.depth });
        o.isVisible = this._debugMode, o.isPickable = !1, o.rotationQuaternion = new oe();
        var a = e.grip || e.pointer;
        o.position.copyFrom(a.position), o.rotationQuaternion.copyFrom(a.rotationQuaternion);
        var s = new bt(o, i, je({ mass: 0 }, this._options.physicsProperties));
        this._controllers[e.uniqueId] = { xrController: e, impostor: s, impostorMesh: o };
      }, t.prototype._enablePhysicsDebug = function() {
        var e = this;
        this._debugMode = !0, Object.keys(this._controllers).forEach(function(i) {
          var r = e._controllers[i];
          r.impostorMesh && (r.impostorMesh.isVisible = !0);
        });
      }, t.prototype.addController = function(e) {
        this._attachController(e);
      }, t.prototype.attach = function() {
        var e = this;
        if (!n.prototype.attach.call(this))
          return !1;
        if (!this._options.xrInput)
          return !0;
        if (this._options.xrInput.controllers.forEach(this._attachController), this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable, this._attachController), this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable, function(o) {
          e._detachController(o.uniqueId);
        }), this._options.enableHeadsetImpostor) {
          var i = this._options.headsetImpostorParams || { impostorType: bt.SphereImpostor, restitution: 0.8, impostorSize: 0.3 }, r = i.impostorSize || 0.3;
          this._headsetMesh = yn("headset-mesh", { diameterX: typeof r == "number" ? r : r.width, diameterY: typeof r == "number" ? r : r.height, diameterZ: typeof r == "number" ? r : r.depth }), this._headsetMesh.rotationQuaternion = new oe(), this._headsetMesh.isVisible = !1, this._headsetImpostor = new bt(this._headsetMesh, i.impostorType, je({ mass: 0 }, i));
        }
        return !0;
      }, t.prototype.detach = function() {
        var e = this;
        return !!n.prototype.detach.call(this) && (Object.keys(this._controllers).forEach(function(i) {
          e._detachController(i);
        }), this._headsetMesh && this._headsetMesh.dispose(), !0);
      }, t.prototype.getHeadsetImpostor = function() {
        return this._headsetImpostor;
      }, t.prototype.getImpostorForController = function(e) {
        var i = typeof e == "string" ? e : e.uniqueId;
        return this._controllers[i] ? this._controllers[i].impostor : null;
      }, t.prototype.setPhysicsProperties = function(e) {
        this._options.physicsProperties = je(je({}, this._options.physicsProperties), e);
      }, t.prototype._onXRFrame = function(e) {
        var i, r, o = this;
        if (this._delta = this._xrSessionManager.currentTimestamp - this._lastTimestamp, this._lastTimestamp = this._xrSessionManager.currentTimestamp, this._headsetMesh && this._headsetImpostor) {
          if (this._headsetMesh.position.copyFrom(this._options.xrInput.xrCamera.globalPosition), this._headsetMesh.rotationQuaternion.copyFrom(this._options.xrInput.xrCamera.absoluteRotation), (i = this._options.xrInput.xrCamera._lastXRViewerPose) === null || i === void 0 ? void 0 : i.linearVelocity) {
            var a = this._options.xrInput.xrCamera._lastXRViewerPose.linearVelocity;
            this._tmpVector.set(a.x, a.y, a.z), this._headsetImpostor.setLinearVelocity(this._tmpVector);
          }
          if (!((r = this._options.xrInput.xrCamera._lastXRViewerPose) === null || r === void 0) && r.angularVelocity) {
            var s = this._options.xrInput.xrCamera._lastXRViewerPose.angularVelocity;
            this._tmpVector.set(s.x, s.y, s.z), this._headsetImpostor.setAngularVelocity(this._tmpVector);
          }
        }
        Object.keys(this._controllers).forEach(function(l) {
          var c, u, h = o._controllers[l], d = h.xrController.grip || h.xrController.pointer, p = h.oldPos || h.impostorMesh.position;
          if (!((c = h.xrController._lastXRPose) === null || c === void 0) && c.linearVelocity) {
            var f = h.xrController._lastXRPose.linearVelocity;
            o._tmpVector.set(f.x, f.y, f.z), h.impostor.setLinearVelocity(o._tmpVector);
          } else
            d.position.subtractToRef(p, o._tmpVector), o._tmpVector.scaleInPlace(1e3 / o._delta), h.impostor.setLinearVelocity(o._tmpVector);
          p.copyFrom(d.position), o._debugMode && console.log(o._tmpVector, "linear");
          var m = h.oldRotation || h.impostorMesh.rotationQuaternion;
          if (!((u = h.xrController._lastXRPose) === null || u === void 0) && u.angularVelocity) {
            var g = h.xrController._lastXRPose.angularVelocity;
            o._tmpVector.set(g.x, g.y, g.z), h.impostor.setAngularVelocity(o._tmpVector);
          } else if (!m.equalsWithEpsilon(d.rotationQuaternion)) {
            m.conjugateInPlace().multiplyToRef(d.rotationQuaternion, o._tmpQuaternion);
            var y = Math.sqrt(o._tmpQuaternion.x * o._tmpQuaternion.x + o._tmpQuaternion.y * o._tmpQuaternion.y + o._tmpQuaternion.z * o._tmpQuaternion.z);
            if (o._tmpVector.set(o._tmpQuaternion.x, o._tmpQuaternion.y, o._tmpQuaternion.z), y < 1e-3)
              o._tmpVector.scaleInPlace(2);
            else {
              var b = 2 * Math.atan2(y, o._tmpQuaternion.w);
              o._tmpVector.scaleInPlace(b / (y * (o._delta / 1e3)));
            }
            h.impostor.setAngularVelocity(o._tmpVector);
          }
          m.copyFrom(d.rotationQuaternion), o._debugMode && console.log(o._tmpVector, o._tmpQuaternion, "angular");
        });
      }, t.prototype._detachController = function(e) {
        var i = this._controllers[e];
        i && (i.impostorMesh && i.impostorMesh.dispose(), delete this._controllers[e]);
      }, t.Name = vi.PHYSICS_CONTROLLERS, t.Version = 1, t;
    }(Qi);
    Wi.AddWebXRFeature(Rd.Name, function(n, t) {
      return function() {
        return new Rd(n, t);
      };
    }, Rd.Version, !0);
    var Cd = function(n) {
      function t(e, i) {
        i === void 0 && (i = {});
        var r = n.call(this, e) || this;
        return r.options = i, r._tmpMat = new B(), r._tmpPos = new v(), r._tmpQuat = new oe(), r._initHitTestSource = function(o) {
          if (o) {
            var a = new XRRay(r.options.offsetRay || {}), s = { space: r.options.useReferenceSpace ? o : r._xrSessionManager.viewerReferenceSpace, offsetRay: a };
            r.options.entityTypes && (s.entityTypes = r.options.entityTypes), s.space ? r._xrSessionManager.session.requestHitTestSource(s).then(function(l) {
              r._xrHitTestSource && r._xrHitTestSource.cancel(), r._xrHitTestSource = l;
            }) : de.Warn("waiting for viewer reference space to initialize");
          }
        }, r.autoCloneTransformation = !1, r.onHitTestResultObservable = new H(), r.paused = !1, r.xrNativeFeatureName = "hit-test", de.Warn("Hit test is an experimental and unstable feature."), r;
      }
      return D(t, n), t.prototype.attach = function() {
        var e = this;
        if (!n.prototype.attach.call(this) || !this._xrSessionManager.session.requestHitTestSource)
          return !1;
        if (this.options.disablePermanentHitTest || (this._xrSessionManager.referenceSpace && this._initHitTestSource(this._xrSessionManager.referenceSpace), this._xrSessionManager.onXRReferenceSpaceChanged.add(this._initHitTestSource)), this.options.enableTransientHitTest) {
          var i = new XRRay(this.options.transientOffsetRay || {});
          this._xrSessionManager.session.requestHitTestSourceForTransientInput({ profile: this.options.transientHitTestProfile || "generic-touchscreen", offsetRay: i, entityTypes: this.options.entityTypes }).then(function(r) {
            e._transientXrHitTestSource = r;
          });
        }
        return !0;
      }, t.prototype.detach = function() {
        return !!n.prototype.detach.call(this) && (this._xrHitTestSource && (this._xrHitTestSource.cancel(), this._xrHitTestSource = null), this._xrSessionManager.onXRReferenceSpaceChanged.removeCallback(this._initHitTestSource), this._transientXrHitTestSource && (this._transientXrHitTestSource.cancel(), this._transientXrHitTestSource = null), !0);
      }, t.prototype.dispose = function() {
        n.prototype.dispose.call(this), this.onHitTestResultObservable.clear();
      }, t.prototype._onXRFrame = function(e) {
        var i = this;
        if (this.attached && !this.paused) {
          if (this._xrHitTestSource) {
            var r = e.getHitTestResults(this._xrHitTestSource);
            this._processWebXRHitTestResult(r);
          }
          this._transientXrHitTestSource && e.getHitTestResultsForTransientInput(this._transientXrHitTestSource).forEach(function(o) {
            i._processWebXRHitTestResult(o.results, o.inputSource);
          });
        }
      }, t.prototype._processWebXRHitTestResult = function(e, i) {
        var r = this, o = [];
        e.forEach(function(a) {
          var s = a.getPose(r._xrSessionManager.referenceSpace);
          if (s) {
            var l = s.transform.position, c = s.transform.orientation;
            r._tmpPos.set(l.x, l.y, l.z), r._tmpQuat.set(c.x, c.y, c.z, c.w), B.FromFloat32ArrayToRefScaled(s.transform.matrix, 0, 1, r._tmpMat), r._xrSessionManager.scene.useRightHandedSystem || (r._tmpPos.z *= -1, r._tmpQuat.z *= -1, r._tmpQuat.w *= -1, r._tmpMat.toggleModelMatrixHandInPlace());
            var u = { position: r.autoCloneTransformation ? r._tmpPos.clone() : r._tmpPos, rotationQuaternion: r.autoCloneTransformation ? r._tmpQuat.clone() : r._tmpQuat, transformationMatrix: r.autoCloneTransformation ? r._tmpMat.clone() : r._tmpMat, inputSource: i, isTransient: !!i, xrHitResult: a };
            o.push(u);
          }
        }), this.onHitTestResultObservable.notifyObservers(o);
      }, t.Name = vi.HIT_TEST, t.Version = 2, t;
    }(Qi);
    Wi.AddWebXRFeature(Cd.Name, function(n, t) {
      return function() {
        return new Cd(n, t);
      };
    }, Cd.Version, !1);
    var Pd = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i._enabled = !1, i._featurePointCloud = [], i.onFeaturePointsAddedObservable = new H(), i.onFeaturePointsUpdatedObservable = new H(), i.xrNativeFeatureName = "bjsfeature-points", i._xrSessionManager.session ? i._init() : i._xrSessionManager.onXRSessionInit.addOnce(function() {
          i._init();
        }), i;
      }
      return D(t, n), Object.defineProperty(t.prototype, "featurePointCloud", { get: function() {
        return this._featurePointCloud;
      }, enumerable: !1, configurable: !0 }), t.prototype.detach = function() {
        return !!n.prototype.detach.call(this) && (this.featurePointCloud.length = 0, !0);
      }, t.prototype.dispose = function() {
        n.prototype.dispose.call(this), this._featurePointCloud.length = 0, this.onFeaturePointsUpdatedObservable.clear(), this.onFeaturePointsAddedObservable.clear();
      }, t.prototype._onXRFrame = function(e) {
        if (this.attached && this._enabled && e) {
          var i = e.featurePointCloud;
          if (i && i.length !== 0) {
            if (i.length % 5 != 0)
              throw new Error("Received malformed feature point cloud of length: " + i.length);
            for (var r = i.length / 5, o = [], a = [], s = 0; s < r; s++) {
              var l = 5 * s, c = i[l + 4];
              this._featurePointCloud[c] ? o.push(c) : (this._featurePointCloud[c] = { position: new v(), confidenceValue: 0 }, a.push(c)), this._featurePointCloud[c].position.x = i[l], this._featurePointCloud[c].position.y = i[l + 1], this._featurePointCloud[c].position.z = i[l + 2], this._featurePointCloud[c].confidenceValue = i[l + 3];
            }
            a.length > 0 && this.onFeaturePointsAddedObservable.notifyObservers(a), o.length > 0 && this.onFeaturePointsUpdatedObservable.notifyObservers(o);
          }
        }
      }, t.prototype._init = function() {
        this._xrSessionManager.session.trySetFeaturePointCloudEnabled && this._xrSessionManager.session.trySetFeaturePointCloudEnabled(!0) && (this._enabled = !0);
      }, t.Name = vi.FEATURE_POINTS, t.Version = 1, t;
    }(Qi);
    Wi.AddWebXRFeature(Pd.Name, function(n) {
      return function() {
        return new Pd(n);
      };
    }, Pd.Version);
    var Ra, BN = 0, Id = function(n) {
      function t(e, i) {
        i === void 0 && (i = {});
        var r = n.call(this, e) || this;
        return r._options = i, r._detectedMeshes = /* @__PURE__ */ new Map(), r.onMeshAddedObservable = new H(), r.onMeshRemovedObservable = new H(), r.onMeshUpdatedObservable = new H(), r.xrNativeFeatureName = "mesh-detection", r._xrSessionManager.session ? r._init() : r._xrSessionManager.onXRSessionInit.addOnce(function() {
          r._init();
        }), r;
      }
      return D(t, n), t.prototype.detach = function() {
        var e = this;
        return !!n.prototype.detach.call(this) && (this._xrSessionManager.isNative && this._xrSessionManager.session.trySetMeshDetectorEnabled && this._xrSessionManager.session.trySetMeshDetectorEnabled(!1), this._options.doNotRemoveMeshesOnSessionEnded || (this._detectedMeshes.forEach(function(i) {
          e.onMeshRemovedObservable.notifyObservers(i);
        }), this._detectedMeshes.clear()), !0);
      }, t.prototype.dispose = function() {
        n.prototype.dispose.call(this), this.onMeshAddedObservable.clear(), this.onMeshRemovedObservable.clear(), this.onMeshUpdatedObservable.clear();
      }, t.prototype._onXRFrame = function(e) {
        var i, r = this;
        try {
          if (!this.attached || !e)
            return;
          var o = (i = e.worldInformation) === null || i === void 0 ? void 0 : i.detectedMeshes;
          if (o) {
            var a = /* @__PURE__ */ new Set();
            this._detectedMeshes.forEach(function(s, l) {
              o.has(l) || a.add(l);
            }), a.forEach(function(s) {
              var l = r._detectedMeshes.get(s);
              l && (r.onMeshRemovedObservable.notifyObservers(l), r._detectedMeshes.delete(s));
            }), o.forEach(function(s) {
              if (r._detectedMeshes.has(s))
                s.lastChangedTime === r._xrSessionManager.currentTimestamp && (c = r._detectedMeshes.get(s)) && (r._updateVertexDataWithXRMesh(s, c, e), r.onMeshUpdatedObservable.notifyObservers(c));
              else {
                var l = { id: BN++, xrMesh: s }, c = r._updateVertexDataWithXRMesh(s, l, e);
                r._detectedMeshes.set(s, c), r.onMeshAddedObservable.notifyObservers(c);
              }
            });
          }
        } catch (s) {
          console.log(s.stack);
        }
      }, t.prototype._init = function() {
        this._xrSessionManager.isNative && (this._xrSessionManager.session.trySetMeshDetectorEnabled && this._xrSessionManager.session.trySetMeshDetectorEnabled(!0), this._options.preferredDetectorOptions && this._xrSessionManager.session.trySetPreferredMeshDetectorOptions && this._xrSessionManager.session.trySetPreferredMeshDetectorOptions(this._options.preferredDetectorOptions));
      }, t.prototype._updateVertexDataWithXRMesh = function(e, i, r) {
        if (i.xrMesh = e, i.worldParentNode = this._options.worldParentNode, this._options.convertCoordinateSystems) {
          if (this._xrSessionManager.scene.useRightHandedSystem)
            i.positions = e.positions, i.normals = e.normals;
          else {
            i.positions = new Float32Array(e.positions.length);
            for (var o = 0; o < e.positions.length; o += 3)
              i.positions[o] = e.positions[o], i.positions[o + 1] = e.positions[o + 1], i.positions[o + 2] = -1 * e.positions[o + 2];
            if (e.normals)
              for (i.normals = new Float32Array(e.normals.length), o = 0; o < e.normals.length; o += 3)
                i.normals[o] = e.normals[o], i.normals[o + 1] = e.normals[o + 1], i.normals[o + 2] = -1 * e.normals[o + 2];
          }
          i.indices = e.indices;
          var a = r.getPose(e.meshSpace, this._xrSessionManager.referenceSpace);
          if (a) {
            var s = i.transformationMatrix || new B();
            B.FromArrayToRef(a.transform.matrix, 0, s), this._xrSessionManager.scene.useRightHandedSystem || s.toggleModelMatrixHandInPlace(), i.transformationMatrix = s, this._options.worldParentNode && s.multiplyToRef(this._options.worldParentNode.getWorldMatrix(), s);
          }
        }
        return i;
      }, t.Name = vi.MESH_DETECTION, t.Version = 1, t;
    }(Qi);
    Wi.AddWebXRFeature(Id.Name, function(n, t) {
      return function() {
        return new Id(n, t);
      };
    }, Id.Version, !1), function(n) {
      n[n.NotReceived = 0] = "NotReceived", n[n.Waiting = 1] = "Waiting", n[n.Received = 2] = "Received";
    }(Ra || (Ra = {}));
    var Md = function(n) {
      function t(e, i) {
        var r = n.call(this, e) || this;
        return r.options = i, r.onUntrackableImageFoundObservable = new H(), r.onTrackableImageFoundObservable = new H(), r.onTrackedImageUpdatedObservable = new H(), r._trackableScoreStatus = Ra.NotReceived, r._trackedImages = [], r.xrNativeFeatureName = "image-tracking", r;
      }
      return D(t, n), t.prototype.attach = function() {
        return n.prototype.attach.call(this);
      }, t.prototype.detach = function() {
        return n.prototype.detach.call(this);
      }, t.prototype.getTrackedImageById = function(e) {
        return this._trackedImages[e] || null;
      }, t.prototype.dispose = function() {
        n.prototype.dispose.call(this), this._trackedImages.forEach(function(e) {
          e.originalBitmap.close();
        }), this._trackedImages.length = 0, this.onTrackableImageFoundObservable.clear(), this.onUntrackableImageFoundObservable.clear(), this.onTrackedImageUpdatedObservable.clear();
      }, t.prototype.getXRSessionInitExtension = function() {
        return Ft(this, void 0, void 0, function() {
          var e, i, r = this;
          return Bt(this, function(o) {
            switch (o.label) {
              case 0:
                if (!this.options.images || !this.options.images.length)
                  return [2, {}];
                e = this.options.images.map(function(a) {
                  return typeof a.src == "string" ? r._xrSessionManager.scene.getEngine()._createImageBitmapFromSource(a.src) : Promise.resolve(a.src);
                }), o.label = 1;
              case 1:
                return o.trys.push([1, 3, , 4]), [4, Promise.all(e)];
              case 2:
                return i = o.sent(), this._originalTrackingRequest = i.map(function(a, s) {
                  return { image: a, widthInMeters: r.options.images[s].estimatedRealWorldWidth };
                }), [2, { trackedImages: this._originalTrackingRequest }];
              case 3:
                return o.sent(), de.Error("Error loading images for tracking, WebXRImageTracking disabled for this session."), [2, {}];
              case 4:
                return [2];
            }
          });
        });
      }, t.prototype._onXRFrame = function(e) {
        if (e.getImageTrackingResults && this._trackableScoreStatus !== Ra.Waiting)
          if (this._trackableScoreStatus !== Ra.NotReceived)
            for (var i = 0, r = e.getImageTrackingResults(); i < r.length; i++) {
              var o = r[i], a = !1, s = o.index, l = this._trackedImages[s];
              if (l) {
                l.xrTrackingResult = o, l.realWorldWidth !== o.measuredWidthInMeters && (l.realWorldWidth = o.measuredWidthInMeters, a = !0);
                var c = e.getPose(o.imageSpace, this._xrSessionManager.referenceSpace);
                if (c) {
                  var u = l.transformationMatrix;
                  B.FromArrayToRef(c.transform.matrix, 0, u), this._xrSessionManager.scene.useRightHandedSystem || u.toggleModelMatrixHandInPlace(), a = !0;
                }
                var h = o.trackingState === "emulated";
                l.emulated !== h && (l.emulated = h, a = !0), a && this.onTrackedImageUpdatedObservable.notifyObservers(l);
              }
            }
          else
            this._checkScoresAsync();
      }, t.prototype._checkScoresAsync = function() {
        return Ft(this, void 0, void 0, function() {
          var e, i, r, o;
          return Bt(this, function(a) {
            switch (a.label) {
              case 0:
                return this._xrSessionManager.session.getTrackedImageScores && this._trackableScoreStatus === Ra.NotReceived ? (this._trackableScoreStatus = Ra.Waiting, [4, this._xrSessionManager.session.getTrackedImageScores()]) : [2];
              case 1:
                if (!(e = a.sent()) || e.length === 0)
                  return this._trackableScoreStatus = Ra.NotReceived, [2];
                for (i = 0; i < e.length; ++i)
                  e[i] == "untrackable" ? this.onUntrackableImageFoundObservable.notifyObservers(i) : (r = this._originalTrackingRequest[i].image, o = { id: i, originalBitmap: r, transformationMatrix: new B(), ratio: r.width / r.height }, this._trackedImages[i] = o, this.onTrackableImageFoundObservable.notifyObservers(o));
                return this._trackableScoreStatus = e.length > 0 ? Ra.Received : Ra.NotReceived, [2];
            }
          });
        });
      }, t.Name = vi.IMAGE_TRACKING, t.Version = 1, t;
    }(Qi);
    Wi.AddWebXRFeature(Md.Name, function(n, t) {
      return function() {
        return new Md(n, t);
      };
    }, Md.Version, !1);
    var Od = function(n) {
      function t(e, i) {
        var r = n.call(this, e) || this;
        return r.options = i, r._domOverlayType = null, r._beforeXRSelectListener = null, r._element = null, r.xrNativeFeatureName = "dom-overlay", de.Warn("dom-overlay is an experimental and unstable feature."), r;
      }
      return D(t, n), t.prototype.attach = function() {
        return !(!n.prototype.attach.call(this) || !this._xrSessionManager.session.domOverlayState || this._xrSessionManager.session.domOverlayState.type === null || (this._domOverlayType = this._xrSessionManager.session.domOverlayState.type, this._element !== null && this.options.supressXRSelectEvents === !0 && (this._beforeXRSelectListener = function(e) {
          e.preventDefault();
        }, this._element.addEventListener("beforexrselect", this._beforeXRSelectListener)), 0));
      }, Object.defineProperty(t.prototype, "domOverlayType", { get: function() {
        return this._domOverlayType;
      }, enumerable: !1, configurable: !0 }), t.prototype.dispose = function() {
        n.prototype.dispose.call(this), this._element !== null && this._beforeXRSelectListener && this._element.removeEventListener("beforexrselect", this._beforeXRSelectListener);
      }, t.prototype._onXRFrame = function(e) {
      }, t.prototype.getXRSessionInitExtension = function() {
        return Ft(this, void 0, void 0, function() {
          var e;
          return Bt(this, function(i) {
            if (this.options.element === void 0)
              return de.Warn('"element" option must be provided to attach xr-dom-overlay feature.'), [2, {}];
            if (typeof this.options.element == "string") {
              if ((e = document.querySelector(this.options.element)) === null)
                return de.Warn("element not found '".concat(this.options.element, "' (not requesting xr-dom-overlay)")), [2, {}];
              this._element = e;
            } else
              this._element = this.options.element;
            return [2, { domOverlay: { root: this._element } }];
          });
        });
      }, t.Name = vi.DOM_OVERLAY, t.Version = 1, t;
    }(Qi);
    Wi.AddWebXRFeature(Od.Name, function(n, t) {
      return function() {
        return new Od(n, t);
      };
    }, Od.Version, !1);
    var Dd = function(n) {
      function t(e, i) {
        var r, o, a, s, l, c, u = this;
        return (u = n.call(this, e) || this)._controllers = {}, u._currentRegistrationConfigurations = [], u._movementDirection = new oe(), u._tmpRotationMatrix = B.Identity(), u._tmpTranslationDirection = new v(), u._tmpMovementTranslation = new v(), u._tempCacheQuaternion = new oe(), u._attachController = function(h) {
          if (!u._controllers[h.uniqueId]) {
            u._controllers[h.uniqueId] = { xrController: h, registeredComponents: [] };
            var d = u._controllers[h.uniqueId];
            if (d.xrController.inputSource.targetRayMode === "tracked-pointer" && d.xrController.inputSource.gamepad) {
              var p = function() {
                if (h.motionController)
                  for (var f = function(y) {
                    var b = null;
                    if (y.allowedComponentTypes)
                      for (var T = 0, S = y.allowedComponentTypes; T < S.length; T++) {
                        var E = S[T], A = h.motionController.getComponentOfType(E);
                        if (A !== null) {
                          b = A;
                          break;
                        }
                      }
                    if (y.mainComponentOnly) {
                      var R = h.motionController.getMainComponent();
                      if (R === null)
                        return "continue";
                      b = R;
                    }
                    if (typeof y.componentSelectionPredicate == "function" && (b = y.componentSelectionPredicate(h)), b && y.forceHandedness && h.inputSource.handedness !== y.forceHandedness || b === null)
                      return "continue";
                    var C = { registrationConfiguration: y, component: b };
                    d.registeredComponents.push(C), "axisChangedHandler" in y && (C.onAxisChangedObserver = b.onAxisValueChangedObservable.add(function(L) {
                      y.axisChangedHandler(L, u._movementState, u._featureContext, u._xrInput);
                    })), "buttonChangedhandler" in y && (C.onButtonChangedObserver = b.onButtonStateChangedObservable.add(function() {
                      b.changes.pressed && y.buttonChangedhandler(b.changes.pressed, u._movementState, u._featureContext, u._xrInput);
                    }));
                  }, m = 0, g = u._currentRegistrationConfigurations; m < g.length; m++)
                    f(g[m]);
              };
              h.motionController ? p() : h.onMotionControllerInitObservable.addOnce(function() {
                p();
              });
            }
          }
        }, i && i.xrInput !== void 0 ? (Array.isArray(i.customRegistrationConfigurations) ? u._currentRegistrationConfigurations = i.customRegistrationConfigurations : u._currentRegistrationConfigurations = t.REGISTRATIONS.default, u._featureContext = { movementEnabled: i.movementEnabled || !0, movementOrientationFollowsViewerPose: (r = i.movementOrientationFollowsViewerPose) === null || r === void 0 || r, movementSpeed: (o = i.movementSpeed) !== null && o !== void 0 ? o : 1, movementThreshold: (a = i.movementThreshold) !== null && a !== void 0 ? a : 0.25, rotationEnabled: (s = i.rotationEnabled) === null || s === void 0 || s, rotationSpeed: (l = i.rotationSpeed) !== null && l !== void 0 ? l : 1, rotationThreshold: (c = i.rotationThreshold) !== null && c !== void 0 ? c : 0.25 }, u._movementState = { moveX: 0, moveY: 0, rotateX: 0, rotateY: 0 }, u._xrInput = i.xrInput, u) : (de.Error('WebXRControllerMovement feature requires "xrInput" option.'), u);
      }
      return D(t, n), Object.defineProperty(t.prototype, "movementDirection", { get: function() {
        return this._movementDirection;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "movementEnabled", { get: function() {
        return this._featureContext.movementEnabled;
      }, set: function(e) {
        this._featureContext.movementEnabled = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "movementOrientationFollowsViewerPose", { get: function() {
        return this._featureContext.movementOrientationFollowsViewerPose;
      }, set: function(e) {
        this._featureContext.movementOrientationFollowsViewerPose = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "movementSpeed", { get: function() {
        return this._featureContext.movementSpeed;
      }, set: function(e) {
        this._featureContext.movementSpeed = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "movementThreshold", { get: function() {
        return this._featureContext.movementThreshold;
      }, set: function(e) {
        this._featureContext.movementThreshold = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rotationEnabled", { get: function() {
        return this._featureContext.rotationEnabled;
      }, set: function(e) {
        this._featureContext.rotationEnabled = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rotationSpeed", { get: function() {
        return this._featureContext.rotationSpeed;
      }, set: function(e) {
        this._featureContext.rotationSpeed = e;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rotationThreshold", { get: function() {
        return this._featureContext.rotationThreshold;
      }, set: function(e) {
        this._featureContext.rotationThreshold = e;
      }, enumerable: !1, configurable: !0 }), t.prototype.attach = function() {
        var e = this;
        return !!n.prototype.attach.call(this) && (this._xrInput.controllers.forEach(this._attachController), this._addNewAttachObserver(this._xrInput.onControllerAddedObservable, this._attachController), this._addNewAttachObserver(this._xrInput.onControllerRemovedObservable, function(i) {
          e._detachController(i.uniqueId);
        }), !0);
      }, t.prototype.detach = function() {
        var e = this;
        return !!n.prototype.detach.call(this) && (Object.keys(this._controllers).forEach(function(i) {
          e._detachController(i);
        }), this._controllers = {}, !0);
      }, t.prototype._onXRFrame = function(e) {
        if (this.attached) {
          if (this._movementState.rotateX !== 0 && this._featureContext.rotationEnabled) {
            var i = 1e-3 * this._xrSessionManager.scene.getEngine().getDeltaTime() * this._featureContext.rotationSpeed * this._movementState.rotateX * (this._xrSessionManager.scene.useRightHandedSystem ? -1 : 1);
            this._featureContext.movementOrientationFollowsViewerPose ? (this._xrInput.xrCamera.cameraRotation.y += i, oe.RotationYawPitchRollToRef(i, 0, 0, this._tempCacheQuaternion), this._xrInput.xrCamera.rotationQuaternion.multiplyToRef(this._tempCacheQuaternion, this._movementDirection)) : (oe.RotationYawPitchRollToRef(3 * i, 0, 0, this._tempCacheQuaternion), this._movementDirection.multiplyInPlace(this._tempCacheQuaternion));
          } else
            this._featureContext.movementOrientationFollowsViewerPose && this._movementDirection.copyFrom(this._xrInput.xrCamera.rotationQuaternion);
          (this._movementState.moveX || this._movementState.moveY) && this._featureContext.movementEnabled && (B.FromQuaternionToRef(this._movementDirection, this._tmpRotationMatrix), this._tmpTranslationDirection.set(this._movementState.moveX, 0, this._movementState.moveY * (this._xrSessionManager.scene.useRightHandedSystem ? 1 : -1)), v.TransformCoordinatesToRef(this._tmpTranslationDirection, this._tmpRotationMatrix, this._tmpMovementTranslation), this._tmpMovementTranslation.scaleInPlace(this._xrInput.xrCamera._computeLocalCameraSpeed() * this._featureContext.movementSpeed), this._xrInput.xrCamera.cameraDirection.addInPlace(this._tmpMovementTranslation));
        }
      }, t.prototype._detachController = function(e) {
        var i = this._controllers[e];
        if (i) {
          for (var r = 0, o = i.registeredComponents; r < o.length; r++) {
            var a = o[r];
            a.onAxisChangedObserver && a.component.onAxisValueChangedObservable.remove(a.onAxisChangedObserver), a.onButtonChangedObserver && a.component.onButtonStateChangedObservable.remove(a.onButtonChangedObserver);
          }
          delete this._controllers[e];
        }
      }, t.Name = vi.MOVEMENT, t.REGISTRATIONS = { default: [{ allowedComponentTypes: [wo.THUMBSTICK_TYPE, wo.TOUCHPAD_TYPE], forceHandedness: "left", axisChangedHandler: function(e, i, r) {
        i.rotateX = Math.abs(e.x) > r.rotationThreshold ? e.x : 0, i.rotateY = Math.abs(e.y) > r.rotationThreshold ? e.y : 0;
      } }, { allowedComponentTypes: [wo.THUMBSTICK_TYPE, wo.TOUCHPAD_TYPE], forceHandedness: "right", axisChangedHandler: function(e, i, r) {
        i.moveX = Math.abs(e.x) > r.movementThreshold ? e.x : 0, i.moveY = Math.abs(e.y) > r.movementThreshold ? e.y : 0;
      } }] }, t.Version = 1, t;
    }(Qi);
    Wi.AddWebXRFeature(Dd.Name, function(n, t) {
      return function() {
        return new Dd(n, t);
      };
    }, Dd.Version, !0);
    var Nd = function(n) {
      function t(e, i) {
        var r = n.call(this, e) || this;
        return r.options = i, r._canvasContext = null, r._reflectionCubeMap = null, r._xrLightEstimate = null, r._xrLightProbe = null, r._xrWebGLBinding = null, r._lightDirection = v.Up().negateInPlace(), r._lightColor = ne.White(), r._intensity = 1, r._sphericalHarmonics = new Mh(), r._cubeMapPollTime = Date.now(), r._lightEstimationPollTime = Date.now(), r._reflectionCubeMapTextureSize = 16, r.directionalLight = null, r.onReflectionCubeMapUpdatedObservable = new H(), r._updateReflectionCubeMap = function() {
          var o;
          if (r._xrLightProbe) {
            if (r.options.cubeMapPollInterval) {
              var a = Date.now();
              if (a - r._cubeMapPollTime < r.options.cubeMapPollInterval)
                return;
              r._cubeMapPollTime = a;
            }
            var s = r._getXRGLBinding().getReflectionCubeMap(r._xrLightProbe);
            if (s && r._reflectionCubeMap) {
              if (r._reflectionCubeMap._texture)
                (o = r._reflectionCubeMap._texture._hardwareTexture) === null || o === void 0 || o.set(s), r._reflectionCubeMap._texture.getEngine().resetTextureCache();
              else {
                var l = new Ut(r._xrSessionManager.scene.getEngine(), ut.Unknown);
                l.isCube = !0, l.invertY = !1, l._useSRGBBuffer = r.options.reflectionFormat === "srgba8", l.format = _.TEXTUREFORMAT_RGBA, l.generateMipMaps = !0, l.type = r.options.reflectionFormat !== "srgba8" ? _.TEXTURETYPE_HALF_FLOAT : _.TEXTURETYPE_UNSIGNED_BYTE, l.samplingMode = _.TEXTURE_LINEAR_LINEAR_MIPLINEAR, l.width = r._reflectionCubeMapTextureSize, l.height = r._reflectionCubeMapTextureSize, l._cachedWrapU = _.TEXTURE_WRAP_ADDRESSMODE, l._cachedWrapV = _.TEXTURE_WRAP_ADDRESSMODE, l._hardwareTexture = new ds(s, r._getCanvasContext()), r._reflectionCubeMap._texture = l;
              }
              r._reflectionCubeMap._texture.isReady = !0, r.options.disablePreFiltering ? (r._xrSessionManager.scene.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag), r.onReflectionCubeMapUpdatedObservable.notifyObservers(r._reflectionCubeMap)) : (r._xrLightProbe.removeEventListener("reflectionchange", r._updateReflectionCubeMap), r._hdrFilter.prefilter(r._reflectionCubeMap).then(function() {
                r._xrSessionManager.scene.markAllMaterialsAsDirty(_.MATERIAL_TextureDirtyFlag), r.onReflectionCubeMapUpdatedObservable.notifyObservers(r._reflectionCubeMap), r._xrLightProbe.addEventListener("reflectionchange", r._updateReflectionCubeMap);
              }));
            }
          }
        }, r.xrNativeFeatureName = "light-estimation", r.options.createDirectionalLightSource && (r.directionalLight = new jh("light estimation directional", r._lightDirection, r._xrSessionManager.scene), r.directionalLight.position = new v(0, 8, 0), r.directionalLight.intensity = 0, r.directionalLight.falloffType = nn.FALLOFF_GLTF), r._hdrFilter = new S_(r._xrSessionManager.scene.getEngine()), de.Warn("light-estimation is an experimental and unstable feature."), r;
      }
      return D(t, n), Object.defineProperty(t.prototype, "reflectionCubeMapTexture", { get: function() {
        return this._reflectionCubeMap;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xrLightingEstimate", { get: function() {
        return this._xrLightEstimate ? { lightColor: this._lightColor, lightDirection: this._lightDirection, lightIntensity: this._intensity, sphericalHarmonics: this._sphericalHarmonics } : this._xrLightEstimate;
      }, enumerable: !1, configurable: !0 }), t.prototype._getCanvasContext = function() {
        return this._canvasContext === null && (this._canvasContext = this._xrSessionManager.scene.getEngine()._gl), this._canvasContext;
      }, t.prototype._getXRGLBinding = function() {
        if (this._xrWebGLBinding === null) {
          var e = this._getCanvasContext();
          this._xrWebGLBinding = new XRWebGLBinding(this._xrSessionManager.session, e);
        }
        return this._xrWebGLBinding;
      }, t.prototype.attach = function() {
        var e, i = this;
        if (!n.prototype.attach.call(this))
          return !1;
        var r = (e = this.options.reflectionFormat) !== null && e !== void 0 ? e : this._xrSessionManager.session.preferredReflectionFormat || "srgba8";
        return this.options.reflectionFormat = r, this._xrSessionManager.session.requestLightProbe({ reflectionFormat: r }).then(function(o) {
          i._xrLightProbe = o, i.options.disableCubeMapReflection || (i._reflectionCubeMap || (i._reflectionCubeMap = new Vn(i._xrSessionManager.scene), i._reflectionCubeMap._isCube = !0, i._reflectionCubeMap.coordinatesMode = _.TEXTURE_CUBIC_MODE, i.options.setSceneEnvironmentTexture && (i._xrSessionManager.scene.environmentTexture = i._reflectionCubeMap)), i._xrLightProbe.addEventListener("reflectionchange", i._updateReflectionCubeMap));
        }), !0;
      }, t.prototype.detach = function() {
        var e = n.prototype.detach.call(this);
        return this._xrLightProbe === null || this.options.disableCubeMapReflection || (this._xrLightProbe.removeEventListener("reflectionchange", this._updateReflectionCubeMap), this._xrLightProbe = null), this._canvasContext = null, this._xrLightEstimate = null, this._xrWebGLBinding = null, e;
      }, t.prototype.dispose = function() {
        n.prototype.dispose.call(this), this.onReflectionCubeMapUpdatedObservable.clear(), this.directionalLight && (this.directionalLight.dispose(), this.directionalLight = null), this._reflectionCubeMap !== null && (this._reflectionCubeMap._texture && this._reflectionCubeMap._texture.dispose(), this._reflectionCubeMap.dispose(), this._reflectionCubeMap = null);
      }, t.prototype._onXRFrame = function(e) {
        var i;
        if (this._xrLightProbe !== null) {
          if (this.options.lightEstimationPollInterval) {
            var r = Date.now();
            if (r - this._lightEstimationPollTime < this.options.lightEstimationPollInterval)
              return;
            this._lightEstimationPollTime = r;
          }
          if (this._xrLightEstimate = e.getLightEstimate(this._xrLightProbe), this._xrLightEstimate) {
            this._intensity = Math.max(1, this._xrLightEstimate.primaryLightIntensity.x, this._xrLightEstimate.primaryLightIntensity.y, this._xrLightEstimate.primaryLightIntensity.z);
            var o = this._xrSessionManager.scene.useRightHandedSystem ? 1 : -1;
            this.options.disableVectorReuse && (this._lightDirection = new v(), this._lightColor = new ne(), this.directionalLight && (this.directionalLight.direction = this._lightDirection, this.directionalLight.diffuse = this._lightColor)), this._lightDirection.copyFromFloats(this._xrLightEstimate.primaryLightDirection.x, this._xrLightEstimate.primaryLightDirection.y, this._xrLightEstimate.primaryLightDirection.z * o), this._lightColor.copyFromFloats(this._xrLightEstimate.primaryLightIntensity.x / this._intensity, this._xrLightEstimate.primaryLightIntensity.y / this._intensity, this._xrLightEstimate.primaryLightIntensity.z / this._intensity), this._sphericalHarmonics.updateFromFloatsArray(this._xrLightEstimate.sphericalHarmonicsCoefficients), this._reflectionCubeMap && !this.options.disableSphericalPolynomial && (this._reflectionCubeMap.sphericalPolynomial = this._reflectionCubeMap.sphericalPolynomial || new Sl(), (i = this._reflectionCubeMap.sphericalPolynomial) === null || i === void 0 || i.updateFromHarmonics(this._sphericalHarmonics)), this._lightDirection.negateInPlace(), this.directionalLight && (this.directionalLight.direction.copyFrom(this._lightDirection), this.directionalLight.intensity = Math.min(this._intensity, 1), this.directionalLight.diffuse.copyFrom(this._lightColor));
          }
        }
      }, t.Name = vi.LIGHT_ESTIMATION, t.Version = 1, t;
    }(Qi);
    Wi.AddWebXRFeature(Nd.Name, function(n, t) {
      return function() {
        return new Nd(n, t);
      };
    }, Nd.Version, !1);
    var Fd = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.onEyeTrackingStartedObservable = new H(), i.onEyeTrackingEndedObservable = new H(), i.onEyeTrackingFrameUpdateObservable = new H(), i._eyeTrackingStartListener = function(r) {
          i._latestEyeSpace = r.gazeSpace, i._gazeRay = new gi(v.Zero(), v.Forward()), i.onEyeTrackingStartedObservable.notifyObservers(i._gazeRay);
        }, i._eyeTrackingEndListener = function() {
          i._latestEyeSpace = null, i._gazeRay = null, i.onEyeTrackingEndedObservable.notifyObservers();
        }, i.xrNativeFeatureName = "eye-tracking", i._xrSessionManager.session ? i._init() : i._xrSessionManager.onXRSessionInit.addOnce(function() {
          i._init();
        }), i;
      }
      return D(t, n), t.prototype.dispose = function() {
        n.prototype.dispose.call(this), this._xrSessionManager.session.removeEventListener("eyetrackingstart", this._eyeTrackingStartListener), this._xrSessionManager.session.removeEventListener("eyetrackingend", this._eyeTrackingEndListener), this.onEyeTrackingStartedObservable.clear(), this.onEyeTrackingEndedObservable.clear(), this.onEyeTrackingFrameUpdateObservable.clear();
      }, Object.defineProperty(t.prototype, "isEyeGazeValid", { get: function() {
        return !!this._gazeRay;
      }, enumerable: !1, configurable: !0 }), t.prototype.getEyeGaze = function() {
        return this._gazeRay;
      }, t.prototype._onXRFrame = function(e) {
        if (this.attached && e && this._latestEyeSpace && this._gazeRay) {
          var i = e.getPose(this._latestEyeSpace, this._xrSessionManager.referenceSpace);
          if (i) {
            this._gazeRay.origin.set(i.transform.position.x, i.transform.position.y, i.transform.position.z);
            var r = i.transform.orientation;
            F.Quaternion[0].set(r.x, r.y, r.z, r.w), this._xrSessionManager.scene.useRightHandedSystem ? v.RightHandedForwardReadOnly.rotateByQuaternionToRef(F.Quaternion[0], this._gazeRay.direction) : (this._gazeRay.origin.z *= -1, F.Quaternion[0].z *= -1, F.Quaternion[0].w *= -1, v.LeftHandedForwardReadOnly.rotateByQuaternionToRef(F.Quaternion[0], this._gazeRay.direction)), this.onEyeTrackingFrameUpdateObservable.notifyObservers(this._gazeRay);
          }
        }
      }, t.prototype._init = function() {
        this._xrSessionManager.isNative && (this._xrSessionManager.session.addEventListener("eyetrackingstart", this._eyeTrackingStartListener), this._xrSessionManager.session.addEventListener("eyetrackingend", this._eyeTrackingEndListener));
      }, t.Name = vi.EYE_TRACKING, t.Version = 1, t;
    }(Qi);
    Wi.AddWebXRFeature(Fd.Name, function(n) {
      return function() {
        return new Fd(n);
      };
    }, Fd.Version, !1);
    var UN = function() {
      function n(t, e) {
        this._samples = [], this._idx = 0;
        for (var i = 0; i < t; ++i)
          this._samples.push(e ? e() : fe.Zero());
      }
      return Object.defineProperty(n.prototype, "length", { get: function() {
        return this._samples.length;
      }, enumerable: !1, configurable: !0 }), n.prototype.push = function(t, e) {
        this._idx = (this._idx + this._samples.length - 1) % this._samples.length, this.at(0).copyFromFloats(t, e);
      }, n.prototype.at = function(t) {
        if (t >= this._samples.length)
          throw new Error("Index out of bounds");
        return this._samples[(this._idx + t) % this._samples.length];
      }, n;
    }(), VN = function() {
      function n() {
        this._samples = new UN(20), this._entropy = 0, this.onFirstStepDetected = new H();
      }
      return n.prototype.update = function(t, e, i, r) {
        this._samples.push(t, e);
        var o = this._samples.at(0);
        if (this._entropy *= this._entropyDecayFactor, this._entropy += fe.Distance(o, this._samples.at(1)), !(this._entropy > this._entropyThreshold)) {
          var a;
          for (a = this._samePointCheckStartIdx; a < this._samples.length && !(fe.DistanceSquared(o, this._samples.at(a)) < this._samePointSquaredDistanceThreshold); ++a)
            ;
          if (a !== this._samples.length) {
            for (var s = -1, l = 0, c = void 0, u = 1; u < a; ++u)
              (c = fe.DistanceSquared(o, this._samples.at(u))) > s && (l = u, s = c);
            if (!(s < this._apexSquaredDistanceThreshold)) {
              var h = this._samples.at(l), d = h.subtract(o);
              d.normalize();
              var p, f = F.Vector2[0], m = 0;
              for (u = 1; u < a; ++u)
                this._samples.at(u).subtractToRef(o, f), p = fe.Dot(d, f), m += f.lengthSquared() - p * p;
              if (!(m > a * this._squaredProjectionDistanceThreshold)) {
                var g = F.Vector3[0];
                g.set(i, r, 0);
                var y = F.Vector3[1];
                y.set(d.x, d.y, 0);
                var b = v.Cross(g, y).z > 0, T = o.clone(), S = o.clone();
                h.subtractToRef(o, d), b ? (d.scaleAndAddToRef(this._axisToApexShrinkFactor, T), d.scaleAndAddToRef(this._axisToApexExtendFactor, S)) : (d.scaleAndAddToRef(this._axisToApexExtendFactor, T), d.scaleAndAddToRef(this._axisToApexShrinkFactor, S)), this.onFirstStepDetected.notifyObservers({ leftApex: T, rightApex: S, currentPosition: o, currentStepDirection: b ? "right" : "left" });
              }
            }
          }
        }
      }, n.prototype.reset = function() {
        for (var t = 0; t < this._samples.length; ++t)
          this._samples.at(t).copyFromFloats(0, 0);
      }, Object.defineProperty(n.prototype, "_samePointCheckStartIdx", { get: function() {
        return Math.floor(this._samples.length / 3);
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "_samePointSquaredDistanceThreshold", { get: function() {
        return 9e-4;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "_apexSquaredDistanceThreshold", { get: function() {
        return 81e-4;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "_squaredProjectionDistanceThreshold", { get: function() {
        return 9e-4;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "_axisToApexShrinkFactor", { get: function() {
        return 0.8;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "_axisToApexExtendFactor", { get: function() {
        return -1.6;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "_entropyDecayFactor", { get: function() {
        return 0.93;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "_entropyThreshold", { get: function() {
        return 0.4;
      }, enumerable: !1, configurable: !0 }), n;
    }(), kN = function() {
      function n(t, e, i, r) {
        this._leftApex = new fe(), this._rightApex = new fe(), this._currentPosition = new fe(), this._axis = new fe(), this._axisLength = -1, this._forward = new fe(), this._steppingLeft = !1, this._t = -1, this._maxT = -1, this._maxTPosition = new fe(), this._vitality = 0, this.onMovement = new H(), this.onFootfall = new H(), this._reset(t, e, i, r === "left");
      }
      return n.prototype._reset = function(t, e, i, r) {
        this._leftApex.copyFrom(t), this._rightApex.copyFrom(e), this._steppingLeft = r, this._steppingLeft ? (this._leftApex.subtractToRef(this._rightApex, this._axis), this._forward.copyFromFloats(-this._axis.y, this._axis.x)) : (this._rightApex.subtractToRef(this._leftApex, this._axis), this._forward.copyFromFloats(this._axis.y, -this._axis.x)), this._axisLength = this._axis.length(), this._forward.scaleInPlace(1 / this._axisLength), this._updateTAndVitality(i.x, i.y), this._maxT = this._t, this._maxTPosition.copyFrom(i), this._vitality = 1;
      }, n.prototype._updateTAndVitality = function(t, e) {
        this._currentPosition.copyFromFloats(t, e), this._steppingLeft ? this._currentPosition.subtractInPlace(this._rightApex) : this._currentPosition.subtractInPlace(this._leftApex);
        var i = this._t, r = fe.Dot(this._currentPosition, this._axis);
        this._t = r / (this._axisLength * this._axisLength);
        var o = this._currentPosition.lengthSquared() - r / this._axisLength * (r / this._axisLength);
        this._vitality *= 0.92 - 100 * Math.max(o - 16e-4, 0) + Math.max(this._t - i, 0);
      }, n.prototype.update = function(t, e) {
        if (this._vitality < this._vitalityThreshold)
          return !1;
        var i = this._t;
        return this._updateTAndVitality(t, e), this._t > this._maxT && (this._maxT = this._t, this._maxTPosition.copyFromFloats(t, e)), !(this._vitality < this._vitalityThreshold || (this._t > i && (this.onMovement.notifyObservers({ deltaT: this._t - i }), i < 0.5 && this._t >= 0.5 && this.onFootfall.notifyObservers({ foot: this._steppingLeft ? "left" : "right" })), this._t < 0.95 * this._maxT && (this._currentPosition.copyFromFloats(t, e), this._steppingLeft ? this._leftApex.copyFrom(this._maxTPosition) : this._rightApex.copyFrom(this._maxTPosition), this._reset(this._leftApex, this._rightApex, this._currentPosition, !this._steppingLeft)), this._axisLength < 0.03));
      }, Object.defineProperty(n.prototype, "_vitalityThreshold", { get: function() {
        return 0.1;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "forward", { get: function() {
        return this._forward;
      }, enumerable: !1, configurable: !0 }), n;
    }(), GN = function() {
      function n(t) {
        var e = this;
        this._detector = new VN(), this._walker = null, this._movement = new fe(), this._millisecondsSinceLastUpdate = n._MillisecondsPerUpdate, this.movementThisFrame = v.Zero(), this._engine = t, this._detector.onFirstStepDetected.add(function(i) {
          e._walker || (e._walker = new kN(i.leftApex, i.rightApex, i.currentPosition, i.currentStepDirection), e._walker.onFootfall.add(function() {
            console.log("Footfall!");
          }), e._walker.onMovement.add(function(r) {
            e._walker.forward.scaleAndAddToRef(0.024 * r.deltaT, e._movement);
          }));
        });
      }
      return Object.defineProperty(n, "_MillisecondsPerUpdate", { get: function() {
        return 1e3 / 15;
      }, enumerable: !1, configurable: !0 }), n.prototype.update = function(t, e) {
        e.y = 0, e.normalize(), this._millisecondsSinceLastUpdate += this._engine.getDeltaTime(), this._millisecondsSinceLastUpdate >= n._MillisecondsPerUpdate && (this._millisecondsSinceLastUpdate -= n._MillisecondsPerUpdate, this._detector.update(t.x, t.z, e.x, e.z), this._walker && (this._walker.update(t.x, t.z) || (this._walker = null)), this._movement.scaleInPlace(0.85)), this.movementThisFrame.set(this._movement.x, 0, this._movement.y);
      }, n;
    }(), Ld = function(n) {
      function t(e, i) {
        var r = n.call(this, e) || this;
        return r._up = new v(), r._forward = new v(), r._position = new v(), r._movement = new v(), r._sessionManager = e, r.locomotionTarget = i.locomotionTarget, r._isLocomotionTargetWebXRCamera && q.Warn("Using walking locomotion directly on a WebXRCamera may have unintended interactions with other XR techniques. Using an XR space parent is highly recommended"), r;
      }
      return D(t, n), Object.defineProperty(t, "Name", { get: function() {
        return vi.WALKING_LOCOMOTION;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "Version", { get: function() {
        return 1;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "locomotionTarget", { get: function() {
        return this._locomotionTarget;
      }, set: function(e) {
        this._locomotionTarget = e, this._isLocomotionTargetWebXRCamera = this._locomotionTarget.getClassName() === "WebXRCamera";
      }, enumerable: !1, configurable: !0 }), t.prototype.isCompatible = function() {
        return this._sessionManager.sessionMode === void 0 || this._sessionManager.sessionMode === "immersive-vr";
      }, t.prototype.attach = function() {
        return !(!this.isCompatible || !n.prototype.attach.call(this) || (this._walker = new GN(this._sessionManager.scene.getEngine()), 0));
      }, t.prototype.detach = function() {
        return !!n.prototype.detach.call(this) && (this._walker = null, !0);
      }, t.prototype._onXRFrame = function(e) {
        var i = e.getViewerPose(this._sessionManager.baseReferenceSpace);
        if (i) {
          var r = this.locomotionTarget.getScene().useRightHandedSystem ? 1 : -1, o = i.transform.matrix;
          this._up.copyFromFloats(o[4], o[5], r * o[6]), this._forward.copyFromFloats(o[8], o[9], r * o[10]), this._position.copyFromFloats(o[12], o[13], r * o[14]), this._forward.scaleAndAddToRef(0.05, this._position), this._up.scaleAndAddToRef(-0.05, this._position), this._walker.update(this._position, this._forward), this._movement.copyFrom(this._walker.movementThisFrame), this._isLocomotionTargetWebXRCamera || v.TransformNormalToRef(this._movement, this.locomotionTarget.getWorldMatrix(), this._movement), this.locomotionTarget.position.addInPlace(this._movement);
        }
      }, t;
    }(Qi);
    Wi.AddWebXRFeature(Ld.Name, function(n, t) {
      return function() {
        return new Ld(n, t);
      };
    }, Ld.Version, !1);
    var qE = function(n) {
      function t(e, i, r, o, a, s) {
        var l = n.call(this, e, i, r, o, s) || this;
        return l.getWidth = e, l.getHeight = i, l.layer = r, l.layerType = o, l.isMultiview = a, l.createRTTProvider = s, l;
      }
      return D(t, n), t;
    }(vv), zN = function(n) {
      function t(e, i, r) {
        var o = n.call(this, e.scene, r) || this;
        return o._xrSessionManager = e, o._xrWebGLBinding = i, o.layerWrapper = r, o._lastSubImages = /* @__PURE__ */ new Map(), o._compositionLayer = r.layer, o;
      }
      return D(t, n), t.prototype._getRenderTargetForSubImage = function(e, i) {
        var r, o, a, s, l = this._lastSubImages.get(i), c = i == "left" ? 0 : 1, u = (r = e.colorTextureWidth) !== null && r !== void 0 ? r : e.textureWidth, h = (o = e.colorTextureHeight) !== null && o !== void 0 ? o : e.textureHeight;
        if (!this._renderTargetTextures[c] || (l == null ? void 0 : l.textureWidth) !== u || (l == null ? void 0 : l.textureHeight) !== h) {
          var d = void 0, p = (a = e.depthStencilTextureWidth) !== null && a !== void 0 ? a : u, f = (s = e.depthStencilTextureHeight) !== null && s !== void 0 ? s : h;
          u !== p && h !== f || (d = e.depthStencilTexture), this._renderTargetTextures[c] = this._createRenderTargetTexture(u, h, null, e.colorTexture, d, this.layerWrapper.isMultiview), this._framebufferDimensions = { framebufferWidth: u, framebufferHeight: h };
        }
        return this._lastSubImages.set(i, e), this._renderTargetTextures[c];
      }, t.prototype._getSubImageForEye = function(e) {
        var i = this._xrSessionManager.currentFrame;
        return i ? this._xrWebGLBinding.getSubImage(this._compositionLayer, i, e) : null;
      }, t.prototype.getRenderTargetTextureForEye = function(e) {
        var i = this._getSubImageForEye(e);
        return i ? this._getRenderTargetForSubImage(i, e) : null;
      }, t.prototype.getRenderTargetTextureForView = function(e) {
        return this.getRenderTargetTextureForEye(e.eye);
      }, t.prototype._setViewportForSubImage = function(e, i) {
        var r, o, a = (r = i.colorTextureWidth) !== null && r !== void 0 ? r : i.textureWidth, s = (o = i.colorTextureWidth) !== null && o !== void 0 ? o : i.textureHeight, l = i.viewport;
        e.x = l.x / a, e.y = l.y / s, e.width = l.width / a, e.height = l.height / s;
      }, t.prototype.trySetViewportForView = function(e, i) {
        var r = this._lastSubImages.get(i.eye) || this._getSubImageForEye(i.eye);
        return !!r && (this._setViewportForSubImage(e, r), !0);
      }, t;
    }(yv), QE = function(n) {
      function t(e, i, r) {
        var o = n.call(this, function() {
          return e.textureWidth;
        }, function() {
          return e.textureHeight;
        }, e, "XRProjectionLayer", i, function(a) {
          return new WN(a, r, o);
        }) || this;
        return o.layer = e, o;
      }
      return D(t, n), t;
    }(qE), WN = function(n) {
      function t(e, i, r) {
        var o = n.call(this, e, i, r) || this;
        return o.layerWrapper = r, o._projectionLayer = r.layer, o;
      }
      return D(t, n), t.prototype._getSubImageForView = function(e) {
        return this._xrWebGLBinding.getViewSubImage(this._projectionLayer, e);
      }, t.prototype.getRenderTargetTextureForView = function(e) {
        return this._getRenderTargetForSubImage(this._getSubImageForView(e), e.eye);
      }, t.prototype.getRenderTargetTextureForEye = function(e) {
        var i = this._lastSubImages.get(e);
        return i ? this._getRenderTargetForSubImage(i, e) : null;
      }, t.prototype.trySetViewportForView = function(e, i) {
        var r = this._lastSubImages.get(i.eye) || this._getSubImageForView(i);
        return !!r && (this._setViewportForSubImage(e, r), !0);
      }, t;
    }(zN), HN = {}, wI = { textureType: "texture", colorFormat: 6408, depthFormat: 35056, scaleFactor: 1 }, wd = function(n) {
      function t(e, i) {
        i === void 0 && (i = {});
        var r = n.call(this, e) || this;
        return r._options = i, r._existingLayers = [], r.xrNativeFeatureName = "layers", r;
      }
      return D(t, n), t.prototype.attach = function() {
        if (!n.prototype.attach.call(this))
          return !1;
        var e = this._xrSessionManager.scene.getEngine();
        this._glContext = e._gl, this._xrWebGLBinding = new XRWebGLBinding(this._xrSessionManager.session, this._glContext), this._existingLayers.length = 0;
        var i = je({}, wI), r = this._options.preferMultiviewOnInit && e.getCaps().multiview;
        return r && (i.textureType = "texture-array"), this.addXRSessionLayer(this.createProjectionLayer(i, r)), !0;
      }, t.prototype.detach = function() {
        return !!n.prototype.detach.call(this) && (this._existingLayers.length = 0, !0);
      }, t.prototype.createXRWebGLLayer = function(e) {
        e === void 0 && (e = HN);
        var i = new XRWebGLLayer(this._xrSessionManager.session, this._glContext, e);
        return new bv(i);
      }, t.prototype.createProjectionLayer = function(e, i) {
        if (e === void 0 && (e = wI), i === void 0 && (i = !1), i && e.textureType !== "texture-array")
          throw new Error("Projection layers can only be made multiview if they use texture arrays. Set the textureType parameter to 'texture-array'.");
        if (!i && e.textureType === "texture-array")
          throw new Error("We currently only support multiview rendering when the textureType parameter is set to 'texture-array'.");
        var r = this._xrWebGLBinding.createProjectionLayer(e);
        return new QE(r, i, this._xrWebGLBinding);
      }, t.prototype.addXRSessionLayer = function(e) {
        this.setXRSessionLayers(js(js([], this._existingLayers, !0), [e], !1));
      }, t.prototype.setXRSessionLayers = function(e) {
        this._existingLayers = e;
        var i = je({}, this._xrSessionManager.session.renderState);
        i.baseLayer = void 0, i.layers = e.map(function(r) {
          return r.layer;
        }), this._xrSessionManager.updateRenderState(i), this._xrSessionManager._setBaseLayerWrapper(e.length > 0 ? e[0] : null);
      }, t.prototype.isCompatible = function() {
        return !this._xrSessionManager.isNative && typeof XRWebGLBinding < "u" && !!XRWebGLBinding.prototype.createProjectionLayer;
      }, t.prototype.dispose = function() {
        n.prototype.dispose.call(this);
      }, t.prototype._onXRFrame = function(e) {
      }, t.Name = vi.LAYERS, t.Version = 1, t;
    }(Qi);
    Wi.AddWebXRFeature(wd.Name, function(n, t) {
      return function() {
        return new wd(n, t);
      };
    }, wd.Version, !1);
    var Bd = function(n) {
      function t(e, i) {
        var r = n.call(this, e) || this;
        return r.options = i, r._width = null, r._height = null, r._rawValueToMeters = null, r._normDepthBufferFromNormView = null, r._cachedDepthBuffer = null, r._cachedWebGLTexture = null, r._cachedDepthImageTexture = null, r.onGetDepthInMetersAvailable = new H(), r.xrNativeFeatureName = "depth-sensing", de.Warn("depth-sensing is an experimental and unstable feature."), r;
      }
      return D(t, n), Object.defineProperty(t.prototype, "width", { get: function() {
        return this._width;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "height", { get: function() {
        return this._height;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rawValueToMeters", { get: function() {
        return this._rawValueToMeters;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "normDepthBufferFromNormView", { get: function() {
        return this._normDepthBufferFromNormView;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "depthUsage", { get: function() {
        switch (this._xrSessionManager.session.depthUsage) {
          case "cpu-optimized":
            return "cpu";
          case "gpu-optimized":
            return "gpu";
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "depthDataFormat", { get: function() {
        switch (this._xrSessionManager.session.depthDataFormat) {
          case "luminance-alpha":
            return "ushort";
          case "float32":
            return "float";
        }
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "latestInternalTexture", { get: function() {
        var e, i;
        if (!this._cachedWebGLTexture)
          return null;
        var r = this._xrSessionManager.scene.getEngine(), o = new Ut(r, ut.Unknown);
        return o.isCube = !1, o.invertY = !1, o._useSRGBBuffer = !1, o.format = this.depthDataFormat === "ushort" ? _.TEXTUREFORMAT_LUMINANCE_ALPHA : _.TEXTUREFORMAT_RGBA, o.generateMipMaps = !1, o.type = this.depthDataFormat === "ushort" ? _.TEXTURETYPE_UNSIGNED_SHORT : _.TEXTURETYPE_FLOAT, o.samplingMode = _.TEXTURE_NEAREST_LINEAR, o.width = (e = this.width) !== null && e !== void 0 ? e : 0, o.height = (i = this.height) !== null && i !== void 0 ? i : 0, o._cachedWrapU = _.TEXTURE_WRAP_ADDRESSMODE, o._cachedWrapV = _.TEXTURE_WRAP_ADDRESSMODE, o._hardwareTexture = new ds(this._cachedWebGLTexture, r._gl), o;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "latestDepthBuffer", { get: function() {
        return this._cachedDepthBuffer ? this.depthDataFormat === "ushort" ? new Uint16Array(this._cachedDepthBuffer) : new Float32Array(this._cachedDepthBuffer) : null;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "latestDepthImageTexture", { get: function() {
        return this._cachedDepthImageTexture;
      }, enumerable: !1, configurable: !0 }), t.prototype.attach = function(e) {
        return !!n.prototype.attach.call(this, e) && this._xrSessionManager.session.depthDataFormat != null && this._xrSessionManager.session.depthUsage != null && (this._glBinding = new XRWebGLBinding(this._xrSessionManager.session, this._xrSessionManager.scene.getEngine()._gl), !0);
      }, t.prototype.dispose = function() {
        var e;
        (e = this._cachedDepthImageTexture) === null || e === void 0 || e.dispose();
      }, t.prototype._onXRFrame = function(e) {
        var i = this._xrSessionManager.referenceSpace, r = e.getViewerPose(i);
        if (r != null)
          for (var o = 0, a = r.views; o < a.length; o++) {
            var s = a[o];
            switch (this.depthUsage) {
              case "cpu":
                this._updateDepthInformationAndTextureCPUDepthUsage(e, s, this.depthDataFormat);
                break;
              case "gpu":
                if (!this._glBinding)
                  break;
                this._updateDepthInformationAndTextureWebGLDepthUsage(this._glBinding, s, this.depthDataFormat);
                break;
              default:
                de.Error("Unknown depth usage"), this.detach();
            }
          }
      }, t.prototype._updateDepthInformationAndTextureCPUDepthUsage = function(e, i, r) {
        var o, a = e.getDepthInformation(i);
        if (a !== null) {
          var s = (o = a).data, l = o.width, c = o.height, u = o.rawValueToMeters, h = o.getDepthInMeters;
          switch (this._width = l, this._height = c, this._rawValueToMeters = u, this._cachedDepthBuffer = s, this.onGetDepthInMetersAvailable.notifyObservers(h.bind(a)), this._cachedDepthImageTexture || (this._cachedDepthImageTexture = on.CreateRTexture(null, l, c, this._xrSessionManager.scene, !1, !0, ae.NEAREST_SAMPLINGMODE, ve.TEXTURETYPE_FLOAT)), r) {
            case "ushort":
              this._cachedDepthImageTexture.update(Float32Array.from(new Uint16Array(s)).map(function(d) {
                return d * u;
              }));
              break;
            case "float":
              this._cachedDepthImageTexture.update(new Float32Array(s).map(function(d) {
                return d * u;
              }));
          }
        }
      }, t.prototype._updateDepthInformationAndTextureWebGLDepthUsage = function(e, i, r) {
        var o, a = e.getDepthInformation(i);
        if (a !== null) {
          var s = (o = a).texture, l = o.width, c = o.height;
          this._width = l, this._height = c, this._cachedWebGLTexture = s;
          var u = this._xrSessionManager.scene, h = u.getEngine().wrapWebGLTexture(s);
          this._cachedDepthImageTexture || (this._cachedDepthImageTexture = on.CreateRTexture(null, l, c, u, !1, !0, ae.NEAREST_SAMPLINGMODE, r === "ushort" ? ve.TEXTURETYPE_UNSIGNED_BYTE : ve.TEXTURETYPE_FLOAT)), this._cachedDepthImageTexture._texture = h;
        }
      }, t.prototype.getXRSessionInitExtension = function() {
        var e = this, i = this.options.usagePreference != null && this.options.usagePreference.length !== 0, r = this.options.dataFormatPreference != null && this.options.dataFormatPreference.length !== 0;
        return new Promise(function(o) {
          o(i && r ? { depthSensing: { usagePreference: e.options.usagePreference.map(function(a) {
            switch (a) {
              case "cpu":
                return "cpu-optimized";
              case "gpu":
                return "gpu-optimized";
            }
          }), dataFormatPreference: e.options.dataFormatPreference.map(function(a) {
            switch (a) {
              case "ushort":
                return "luminance-alpha";
              case "float":
                return "float32";
            }
          }) } } : {});
        });
      }, t.Name = vi.DEPTH_SENSING, t.Version = 1, t;
    }(Qi);
    Wi.AddWebXRFeature(Bd.Name, function(n, t) {
      return function() {
        return new Bd(n, t);
      };
    }, Bd.Version, !1), re.ShadersStore.velocityPixelShader = `precision highp float;
#define CUSTOM_FRAGMENT_BEGIN
varying vec4 clipPos;varying vec4 previousClipPos;
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void) {
#define CUSTOM_FRAGMENT_MAIN_BEGIN
highp vec4 motionVector=( clipPos/clipPos.w-previousClipPos/previousClipPos.w );gl_FragColor=motionVector;
#define CUSTOM_FRAGMENT_MAIN_END
}`, re.ShadersStore.velocityVertexShader = `#define CUSTOM_VERTEX_BEGIN
#define VELOCITY
attribute vec3 position;
#include<instancesDeclaration>
uniform mat4 viewProjection;uniform mat4 previousViewProjection;
#ifdef MULTIVIEW
uniform mat4 viewProjectionR;uniform mat4 previousViewProjectionR;
#endif
varying vec4 clipPos;varying vec4 previousClipPos;
#define CUSTOM_VERTEX_DEFINITIONS
void main(void) {
#define CUSTOM_VERTEX_MAIN_BEGIN
vec3 positionUpdated=position;
#include<instancesVertex>
vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);vec4 previousWorldPos=finalPreviousWorld*vec4(positionUpdated,1.0);
#ifdef MULTIVIEW
if (gl_ViewID_OVR==0u) {clipPos=viewProjection*worldPos;previousClipPos=previousViewProjection*previousWorldPos;gl_Position=clipPos;} else {clipPos=viewProjectionR*worldPos;previousClipPos=previousViewProjectionR*previousWorldPos;gl_Position=clipPos;}
#elif
clipPos=viewProjection*worldPos;previousClipPos=previousViewProjection*previousWorldPos;gl_Position=clipPos;
#endif
#define CUSTOM_VERTEX_MAIN_END
}`;
    var ZE = function(n) {
      function t(e, i, r, o) {
        o === void 0 && (o = 512);
        var a = n.call(this, "spacewarp rtt", o, r, !1, !0, _.TEXTURETYPE_HALF_FLOAT, !1, void 0, !1, !1, !0, void 0, !0) || this;
        return a._originalPairing = [], a._previousWorldMatrices = [], a._previousTransforms = [B.Identity(), B.Identity()], a._renderTarget = a.getScene().getEngine().createMultiviewRenderTargetTexture(a.getRenderWidth(), a.getRenderHeight(), e, i), a._renderTarget._disposeOnlyFramebuffers = !0, a._texture = a._renderTarget.texture, a._texture.isMultiview = !0, a._texture.format = _.TEXTUREFORMAT_RGBA, r && (a._velocityMaterial = new dr("velocity shader material", r, { vertex: "velocity", fragment: "velocity" }, { uniforms: ["world", "previousWorld", "viewProjection", "viewProjectionR", "previousViewProjection", "previousViewProjectionR"] }), a._velocityMaterial._materialHelperNeedsPreviousMatrices = !0, a._velocityMaterial.onBindObservable.add(function(s) {
          a._previousWorldMatrices[s.uniqueId] = a._previousWorldMatrices[s.uniqueId] || s.getWorldMatrix(), a._velocityMaterial.getEffect().setMatrix("previousWorld", a._previousWorldMatrices[s.uniqueId]), a._previousWorldMatrices[s.uniqueId] = s.getWorldMatrix(), a._velocityMaterial.getEffect().setMatrix("previousViewProjection", a._previousTransforms[0]), a._velocityMaterial.getEffect().setMatrix("previousViewProjectionR", a._previousTransforms[1]), a._previousTransforms[0].copyFrom(r.getTransformMatrix()), a._previousTransforms[1].copyFrom(r._transformMatrixR);
        }), a._velocityMaterial.freeze()), a;
      }
      return D(t, n), t.prototype.render = function(e, i) {
        var r = this;
        e === void 0 && (e = !1), i === void 0 && (i = !1), this._originalPairing.length = 0;
        var o = this.getScene();
        o && this._velocityMaterial && o.getActiveMeshes().forEach(function(a) {
          r._originalPairing.push([a, a.material]), a.material = r._velocityMaterial;
        }), n.prototype.render.call(this, e, i), this._originalPairing.forEach(function(a) {
          a[0].material = a[1];
        });
      }, t.prototype._bindFrameBuffer = function() {
        this._renderTarget && this.getScene().getEngine().bindSpaceWarpFramebuffer(this._renderTarget);
      }, t.prototype.getViewCount = function() {
        return 2;
      }, t.prototype.dispose = function() {
        n.prototype.dispose.call(this), this._velocityMaterial.dispose(), this._previousTransforms.length = 0, this._previousWorldMatrices.length = 0, this._originalPairing.length = 0;
      }, t;
    }(Mi), JE = function() {
      function n(t, e, i) {
        this._scene = t, this._xrSessionManager = e, this._xrWebGLBinding = i, this._lastSubImages = /* @__PURE__ */ new Map(), this._renderTargetTextures = /* @__PURE__ */ new Map(), this._engine = t.getEngine();
      }
      return n.prototype._getSubImageForView = function(t) {
        var e = this._xrSessionManager._getBaseLayerWrapper();
        if (!e)
          throw new Error("For Space Warp, the base layer should be a WebXR Projection Layer.");
        if (e.layerType !== "XRProjectionLayer")
          throw new Error('For Space Warp, the base layer type should "XRProjectionLayer".');
        var i = e.layer;
        return this._xrWebGLBinding.getViewSubImage(i, t);
      }, n.prototype._setViewportForSubImage = function(t, e) {
        t.x = 0, t.y = 0, t.width = e.motionVectorTextureWidth, t.height = e.motionVectorTextureHeight;
      }, n.prototype._createRenderTargetTexture = function(t, e, i, r, o) {
        if (!this._engine)
          throw new Error("Engine is disposed");
        var a = { width: t, height: e }, s = new ZE(r, o, this._scene, a), l = s.renderTarget;
        return i && (l._framebuffer = i), l._colorTextureArray = r, l._depthStencilTextureArray = o, s.disableRescaling(), s.renderListPredicate = function() {
          return !0;
        }, s;
      }, n.prototype._getRenderTargetForSubImage = function(t, e) {
        var i = this._lastSubImages.get(e), r = this._renderTargetTextures.get(e.eye), o = t.motionVectorTextureWidth, a = t.motionVectorTextureHeight;
        return r && (i == null ? void 0 : i.textureWidth) === o && (i == null ? void 0 : i.textureHeight) == a || (r = this._createRenderTargetTexture(o, a, null, t.motionVectorTexture, t.depthStencilTexture), this._renderTargetTextures.set(e.eye, r), this._framebufferDimensions = { framebufferWidth: o, framebufferHeight: a }), this._lastSubImages.set(e, t), r;
      }, n.prototype.trySetViewportForView = function(t, e) {
        var i = this._lastSubImages.get(e) || this._getSubImageForView(e);
        return !!i && (this._setViewportForSubImage(t, i), !0);
      }, n.prototype.accessMotionVector = function(t) {
        var e = this._getSubImageForView(t);
        e && (e.motionVectorTexture, e.depthStencilTexture);
      }, n.prototype.getRenderTargetTextureForEye = function(t) {
        return null;
      }, n.prototype.getRenderTargetTextureForView = function(t) {
        var e = this._getSubImageForView(t);
        return e ? this._getRenderTargetForSubImage(e, t) : null;
      }, n.prototype.dispose = function() {
        this._renderTargetTextures.forEach(function(t) {
          return t.dispose();
        }), this._renderTargetTextures.clear();
      }, n;
    }(), Ud = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i._onAfterRenderObserver = null, i.dependsOn = [vi.LAYERS], i.xrNativeFeatureName = "space-warp", i._xrSessionManager.scene.needsPreviousWorldMatrices = !0, i;
      }
      return D(t, n), t.prototype.attach = function() {
        var e = this;
        if (!n.prototype.attach.call(this))
          return !1;
        var i = this._xrSessionManager.scene.getEngine();
        return this._glContext = i._gl, this._xrWebGLBinding = new XRWebGLBinding(this._xrSessionManager.session, this._glContext), this.spaceWarpRTTProvider = new JE(this._xrSessionManager.scene, this._xrSessionManager, this._xrWebGLBinding), this._onAfterRenderObserver = this._xrSessionManager.scene.onAfterRenderObservable.add(function() {
          return e._onAfterRender();
        }), !0;
      }, t.prototype.detach = function() {
        return this._xrSessionManager.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver), n.prototype.detach.call(this);
      }, t.prototype._onAfterRender = function() {
        this.attached && this._renderTargetTexture && this._renderTargetTexture.render(!1, !1);
      }, t.prototype.isCompatible = function() {
        return this._xrSessionManager.scene.getEngine().getCaps().colorBufferHalfFloat || !1;
      }, t.prototype.dispose = function() {
        n.prototype.dispose.call(this);
      }, t.prototype._onXRFrame = function(e) {
        var i = e.getViewerPose(this._xrSessionManager.referenceSpace);
        if (i) {
          var r = i.views[0];
          this._renderTargetTexture = this._renderTargetTexture || this.spaceWarpRTTProvider.getRenderTargetTextureForView(r), this.spaceWarpRTTProvider.accessMotionVector(r);
        }
      }, t.Name = vi.SPACE_WARP, t.Version = 1, t;
    }(Qi);
    Wi.AddWebXRFeature(Ud.Name, function(n) {
      return function() {
        return new Ud(n);
      };
    }, Ud.Version, !1);
    var Vd = function(n) {
      function t(e, i) {
        i === void 0 && (i = {});
        var r = n.call(this, e) || this;
        return r.options = i, r._cachedInternalTextures = [], r.texturesData = [], r.viewIndex = [], r.cameraIntrinsics = [], r.onTexturesUpdatedObservable = new H(), r.xrNativeFeatureName = "camera-access", r;
      }
      return D(t, n), t.prototype.attach = function(e) {
        return !!n.prototype.attach.call(this, e) && (this._glContext = this._xrSessionManager.scene.getEngine()._gl, this._glBinding = new XRWebGLBinding(this._xrSessionManager.session, this._glContext), !0);
      }, t.prototype.detach = function() {
        return !!n.prototype.detach.call(this) && (this._glBinding = void 0, this.options.doNotDisposeOnDetach || (this._cachedInternalTextures.forEach(function(e) {
          return e.dispose();
        }), this.texturesData.forEach(function(e) {
          return e.dispose();
        }), this._cachedInternalTextures.length = 0, this.texturesData.length = 0, this.cameraIntrinsics.length = 0), !0);
      }, t.prototype.dispose = function() {
        n.prototype.dispose.call(this), this.onTexturesUpdatedObservable.clear();
      }, t.prototype._updateCameraIntrinsics = function(e, i) {
        var r = { width: e.camera.width, height: e.camera.height, x: 0, y: 0 }, o = e.projectionMatrix, a = (1 - o[8]) * r.width / 2 + r.x, s = (1 - o[9]) * r.height / 2 + r.y, l = r.width / 2 * o[0], c = r.height / 2 * o[5], u = r.width / 2 * o[4];
        this.cameraIntrinsics[i] = { u0: a, v0: s, ax: l, ay: c, gamma: u, width: r.width, height: r.height, viewportX: r.x, viewportY: r.y };
      }, t.prototype._updateInternalTextures = function(e, i) {
        var r, o;
        if (i === void 0 && (i = 0), !e.camera)
          return !1;
        this.viewIndex[i] = e.eye;
        var a = (r = this._glBinding) === null || r === void 0 ? void 0 : r.getCameraImage(e.camera);
        if (this._cachedInternalTextures[i])
          (o = this._cachedInternalTextures[i]._hardwareTexture) === null || o === void 0 || o.set(a);
        else {
          var s = new Ut(this._xrSessionManager.scene.getEngine(), ut.Unknown, !0);
          s.isCube = !0, s.invertY = !1, s.format = _.TEXTUREFORMAT_RGBA, s.generateMipMaps = !0, s.type = _.TEXTURETYPE_FLOAT, s.samplingMode = _.TEXTURE_LINEAR_LINEAR_MIPLINEAR, s.width = e.camera.width, s.height = e.camera.height, s._cachedWrapU = _.TEXTURE_WRAP_ADDRESSMODE, s._cachedWrapV = _.TEXTURE_WRAP_ADDRESSMODE, s._hardwareTexture = new ds(a, this._glContext), this._cachedInternalTextures[i] = s;
          var l = new Vn(this._xrSessionManager.scene);
          l.name = "WebXR Raw Camera Access (".concat(i, ")"), l._texture = this._cachedInternalTextures[i], this.texturesData[i] = l, this._updateCameraIntrinsics(e, i);
        }
        return this._cachedInternalTextures[i].isReady = !0, !0;
      }, t.prototype._onXRFrame = function(e) {
        var i = this, r = this._xrSessionManager.referenceSpace, o = e.getViewerPose(r);
        if (o && o.views) {
          var a = !0;
          o.views.forEach(function(s, l) {
            a = a && i._updateInternalTextures(s, l);
          }), a && this.onTexturesUpdatedObservable.notifyObservers(this.texturesData);
        }
      }, t.Name = vi.RAW_CAMERA_ACCESS, t.Version = 1, t;
    }(Qi);
    Wi.AddWebXRFeature(Vd.Name, function(n, t) {
      return function() {
        return new Vd(n, t);
      };
    }, Vd.Version, !1);
    var $E = function(n) {
      function t(e, i, r) {
        var o = n.call(this, e, XN[r], i, r, !0) || this;
        return o.profileId = "generic-hand-select-grasp", o;
      }
      return D(t, n), t.prototype._getFilenameAndPath = function() {
        return { filename: "generic.babylon", path: "https://controllers.babylonjs.com/generic/" };
      }, t.prototype._getModelLoadingConstraints = function() {
        return !0;
      }, t.prototype._processLoadedModel = function(e) {
      }, t.prototype._setRootMesh = function(e) {
      }, t.prototype._updateModel = function() {
      }, t;
    }(Cs);
    Qn.RegisterController("generic-hand-select-grasp", function(n, t) {
      return new $E(t, n.gamepad, n.handedness);
    });
    var XN = { left: { selectComponentId: "xr-standard-trigger", components: { "xr-standard-trigger": { type: "trigger", gamepadIndices: { button: 0 }, rootNodeName: "xr-standard-trigger", visualResponses: {} }, grasp: { type: "trigger", gamepadIndices: { button: 4 }, rootNodeName: "grasp", visualResponses: {} } }, gamepadMapping: "xr-standard", rootNodeName: "generic-hand-select-grasp-left", assetPath: "left.glb" }, right: { selectComponentId: "xr-standard-trigger", components: { "xr-standard-trigger": { type: "trigger", gamepadIndices: { button: 0 }, rootNodeName: "xr-standard-trigger", visualResponses: {} }, grasp: { type: "trigger", gamepadIndices: { button: 4 }, rootNodeName: "grasp", visualResponses: {} } }, gamepadMapping: "xr-standard", rootNodeName: "generic-hand-select-grasp-right", assetPath: "right.glb" }, none: { selectComponentId: "xr-standard-trigger", components: { "xr-standard-trigger": { type: "trigger", gamepadIndices: { button: 0 }, rootNodeName: "xr-standard-trigger", visualResponses: {} }, grasp: { type: "trigger", gamepadIndices: { button: 4 }, rootNodeName: "grasp", visualResponses: {} } }, gamepadMapping: "xr-standard", rootNodeName: "generic-hand-select-grasp-none", assetPath: "none.glb" } }, eS = function(n) {
      function t(e, i, r) {
        var o = n.call(this, e, jN["left-right"], i, r) || this;
        return o._mapping = { defaultButton: { valueNodeName: "VALUE", unpressedNodeName: "UNPRESSED", pressedNodeName: "PRESSED" }, defaultAxis: { valueNodeName: "VALUE", minNodeName: "MIN", maxNodeName: "MAX" }, buttons: { "xr-standard-trigger": { rootNodeName: "SELECT", componentProperty: "button", states: ["default", "touched", "pressed"] }, "xr-standard-squeeze": { rootNodeName: "GRASP", componentProperty: "state", states: ["pressed"] }, "xr-standard-touchpad": { rootNodeName: "TOUCHPAD_PRESS", labelAnchorNodeName: "squeeze-label", touchPointNodeName: "TOUCH" }, "xr-standard-thumbstick": { rootNodeName: "THUMBSTICK_PRESS", componentProperty: "state", states: ["pressed"] } }, axes: { "xr-standard-touchpad": { "x-axis": { rootNodeName: "TOUCHPAD_TOUCH_X" }, "y-axis": { rootNodeName: "TOUCHPAD_TOUCH_Y" } }, "xr-standard-thumbstick": { "x-axis": { rootNodeName: "THUMBSTICK_X" }, "y-axis": { rootNodeName: "THUMBSTICK_Y" } } } }, o.profileId = "microsoft-mixed-reality", o;
      }
      return D(t, n), t.prototype._getFilenameAndPath = function() {
        return { filename: this.handedness === "left" ? t.MODEL_LEFT_FILENAME : t.MODEL_RIGHT_FILENAME, path: t.MODEL_BASE_URL + "default/" };
      }, t.prototype._getModelLoadingConstraints = function() {
        var e = yi.IsPluginForExtensionAvailable(".glb");
        return e || q.Warn("glTF / glb loaded was not registered, using generic controller instead"), e;
      }, t.prototype._processLoadedModel = function(e) {
        var i = this;
        this.rootMesh && (this.getComponentIds().forEach(function(r, o) {
          if (!i.disableAnimation && r && i.rootMesh) {
            var a = i._mapping.buttons[r], s = a.rootNodeName;
            if (!s)
              return void q.Log("Skipping unknown button at index: " + o + " with mapped name: " + r);
            var l = i._getChildByName(i.rootMesh, s);
            if (!l)
              return void q.Warn("Missing button mesh with name: " + s);
            if (a.valueMesh = i._getImmediateChildByName(l, i._mapping.defaultButton.valueNodeName), a.pressedMesh = i._getImmediateChildByName(l, i._mapping.defaultButton.pressedNodeName), a.unpressedMesh = i._getImmediateChildByName(l, i._mapping.defaultButton.unpressedNodeName), a.valueMesh && a.pressedMesh && a.unpressedMesh) {
              var c = i.getComponent(r);
              c && c.onButtonStateChangedObservable.add(function(u) {
                i._lerpTransform(a, u.value);
              }, void 0, !0);
            } else
              q.Warn("Missing button submesh under mesh with name: " + s);
          }
        }), this.getComponentIds().forEach(function(r) {
          var o = i.getComponent(r);
          o.isAxes() && ["x-axis", "y-axis"].forEach(function(a) {
            if (i.rootMesh) {
              var s = i._mapping.axes[r][a], l = i._getChildByName(i.rootMesh, s.rootNodeName);
              l ? (s.valueMesh = i._getImmediateChildByName(l, i._mapping.defaultAxis.valueNodeName), s.minMesh = i._getImmediateChildByName(l, i._mapping.defaultAxis.minNodeName), s.maxMesh = i._getImmediateChildByName(l, i._mapping.defaultAxis.maxNodeName), s.valueMesh && s.minMesh && s.maxMesh ? o && o.onAxisValueChangedObservable.add(function(c) {
                var u = a === "x-axis" ? c.x : c.y;
                i._lerpTransform(s, u, !0);
              }, void 0, !0) : q.Warn("Missing axis submesh under mesh with name: " + s.rootNodeName)) : q.Warn("Missing axis mesh with name: " + s.rootNodeName);
            }
          });
        }));
      }, t.prototype._setRootMesh = function(e) {
        var i;
        this.rootMesh = new ie(this.profileId + " " + this.handedness, this.scene), this.rootMesh.isPickable = !1;
        for (var r = 0; r < e.length; r++) {
          var o = e[r];
          o.isPickable = !1, o.parent || (i = o);
        }
        i && i.setParent(this.rootMesh), this.scene.useRightHandedSystem || (this.rootMesh.rotationQuaternion = oe.FromEulerAngles(0, Math.PI, 0));
      }, t.prototype._updateModel = function() {
      }, t.MODEL_BASE_URL = "https://controllers.babylonjs.com/microsoft/", t.MODEL_LEFT_FILENAME = "left.glb", t.MODEL_RIGHT_FILENAME = "right.glb", t;
    }(Cs);
    Qn.RegisterController("windows-mixed-reality", function(n, t) {
      return new eS(t, n.gamepad, n.handedness);
    });
    var jN = { left: { selectComponentId: "xr-standard-trigger", components: { "xr-standard-trigger": { type: "trigger", gamepadIndices: { button: 0 }, rootNodeName: "xr_standard_trigger", visualResponses: { xr_standard_trigger_pressed: { componentProperty: "button", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_trigger_pressed_value", minNodeName: "xr_standard_trigger_pressed_min", maxNodeName: "xr_standard_trigger_pressed_max" } } }, "xr-standard-squeeze": { type: "squeeze", gamepadIndices: { button: 1 }, rootNodeName: "xr_standard_squeeze", visualResponses: { xr_standard_squeeze_pressed: { componentProperty: "button", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_squeeze_pressed_value", minNodeName: "xr_standard_squeeze_pressed_min", maxNodeName: "xr_standard_squeeze_pressed_max" } } }, "xr-standard-touchpad": { type: "touchpad", gamepadIndices: { button: 2, xAxis: 0, yAxis: 1 }, rootNodeName: "xr_standard_touchpad", visualResponses: { xr_standard_touchpad_pressed: { componentProperty: "button", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_touchpad_pressed_value", minNodeName: "xr_standard_touchpad_pressed_min", maxNodeName: "xr_standard_touchpad_pressed_max" }, xr_standard_touchpad_xaxis_pressed: { componentProperty: "xAxis", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_touchpad_xaxis_pressed_value", minNodeName: "xr_standard_touchpad_xaxis_pressed_min", maxNodeName: "xr_standard_touchpad_xaxis_pressed_max" }, xr_standard_touchpad_yaxis_pressed: { componentProperty: "yAxis", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_touchpad_yaxis_pressed_value", minNodeName: "xr_standard_touchpad_yaxis_pressed_min", maxNodeName: "xr_standard_touchpad_yaxis_pressed_max" }, xr_standard_touchpad_xaxis_touched: { componentProperty: "xAxis", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_touchpad_xaxis_touched_value", minNodeName: "xr_standard_touchpad_xaxis_touched_min", maxNodeName: "xr_standard_touchpad_xaxis_touched_max" }, xr_standard_touchpad_yaxis_touched: { componentProperty: "yAxis", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_touchpad_yaxis_touched_value", minNodeName: "xr_standard_touchpad_yaxis_touched_min", maxNodeName: "xr_standard_touchpad_yaxis_touched_max" }, xr_standard_touchpad_axes_touched: { componentProperty: "state", states: ["touched", "pressed"], valueNodeProperty: "visibility", valueNodeName: "xr_standard_touchpad_axes_touched_value" } }, touchPointNodeName: "xr_standard_touchpad_axes_touched_value" }, "xr-standard-thumbstick": { type: "thumbstick", gamepadIndices: { button: 3, xAxis: 2, yAxis: 3 }, rootNodeName: "xr_standard_thumbstick", visualResponses: { xr_standard_thumbstick_pressed: { componentProperty: "button", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_thumbstick_pressed_value", minNodeName: "xr_standard_thumbstick_pressed_min", maxNodeName: "xr_standard_thumbstick_pressed_max" }, xr_standard_thumbstick_xaxis_pressed: { componentProperty: "xAxis", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_thumbstick_xaxis_pressed_value", minNodeName: "xr_standard_thumbstick_xaxis_pressed_min", maxNodeName: "xr_standard_thumbstick_xaxis_pressed_max" }, xr_standard_thumbstick_yaxis_pressed: { componentProperty: "yAxis", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_thumbstick_yaxis_pressed_value", minNodeName: "xr_standard_thumbstick_yaxis_pressed_min", maxNodeName: "xr_standard_thumbstick_yaxis_pressed_max" } } } }, gamepadMapping: "xr-standard", rootNodeName: "microsoft-mixed-reality-left", assetPath: "left.glb" }, right: { selectComponentId: "xr-standard-trigger", components: { "xr-standard-trigger": { type: "trigger", gamepadIndices: { button: 0 }, rootNodeName: "xr_standard_trigger", visualResponses: { xr_standard_trigger_pressed: { componentProperty: "button", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_trigger_pressed_value", minNodeName: "xr_standard_trigger_pressed_min", maxNodeName: "xr_standard_trigger_pressed_max" } } }, "xr-standard-squeeze": { type: "squeeze", gamepadIndices: { button: 1 }, rootNodeName: "xr_standard_squeeze", visualResponses: { xr_standard_squeeze_pressed: { componentProperty: "button", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_squeeze_pressed_value", minNodeName: "xr_standard_squeeze_pressed_min", maxNodeName: "xr_standard_squeeze_pressed_max" } } }, "xr-standard-touchpad": { type: "touchpad", gamepadIndices: { button: 2, xAxis: 0, yAxis: 1 }, rootNodeName: "xr_standard_touchpad", visualResponses: { xr_standard_touchpad_pressed: { componentProperty: "button", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_touchpad_pressed_value", minNodeName: "xr_standard_touchpad_pressed_min", maxNodeName: "xr_standard_touchpad_pressed_max" }, xr_standard_touchpad_xaxis_pressed: { componentProperty: "xAxis", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_touchpad_xaxis_pressed_value", minNodeName: "xr_standard_touchpad_xaxis_pressed_min", maxNodeName: "xr_standard_touchpad_xaxis_pressed_max" }, xr_standard_touchpad_yaxis_pressed: { componentProperty: "yAxis", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_touchpad_yaxis_pressed_value", minNodeName: "xr_standard_touchpad_yaxis_pressed_min", maxNodeName: "xr_standard_touchpad_yaxis_pressed_max" }, xr_standard_touchpad_xaxis_touched: { componentProperty: "xAxis", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_touchpad_xaxis_touched_value", minNodeName: "xr_standard_touchpad_xaxis_touched_min", maxNodeName: "xr_standard_touchpad_xaxis_touched_max" }, xr_standard_touchpad_yaxis_touched: { componentProperty: "yAxis", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_touchpad_yaxis_touched_value", minNodeName: "xr_standard_touchpad_yaxis_touched_min", maxNodeName: "xr_standard_touchpad_yaxis_touched_max" }, xr_standard_touchpad_axes_touched: { componentProperty: "state", states: ["touched", "pressed"], valueNodeProperty: "visibility", valueNodeName: "xr_standard_touchpad_axes_touched_value" } }, touchPointNodeName: "xr_standard_touchpad_axes_touched_value" }, "xr-standard-thumbstick": { type: "thumbstick", gamepadIndices: { button: 3, xAxis: 2, yAxis: 3 }, rootNodeName: "xr_standard_thumbstick", visualResponses: { xr_standard_thumbstick_pressed: { componentProperty: "button", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_thumbstick_pressed_value", minNodeName: "xr_standard_thumbstick_pressed_min", maxNodeName: "xr_standard_thumbstick_pressed_max" }, xr_standard_thumbstick_xaxis_pressed: { componentProperty: "xAxis", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_thumbstick_xaxis_pressed_value", minNodeName: "xr_standard_thumbstick_xaxis_pressed_min", maxNodeName: "xr_standard_thumbstick_xaxis_pressed_max" }, xr_standard_thumbstick_yaxis_pressed: { componentProperty: "yAxis", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_thumbstick_yaxis_pressed_value", minNodeName: "xr_standard_thumbstick_yaxis_pressed_min", maxNodeName: "xr_standard_thumbstick_yaxis_pressed_max" } } } }, gamepadMapping: "xr-standard", rootNodeName: "microsoft-mixed-reality-right", assetPath: "right.glb" } }, xm = function(n) {
      function t(e, i, r, o, a) {
        a === void 0 && (a = !1);
        var s = n.call(this, e, YN[r], i, r) || this;
        return s._forceLegacyControllers = a, s.profileId = "oculus-touch", s;
      }
      return D(t, n), t.prototype._getFilenameAndPath = function() {
        return { filename: this.handedness === "left" ? t.MODEL_LEFT_FILENAME : t.MODEL_RIGHT_FILENAME, path: this._isQuest() ? t.QUEST_MODEL_BASE_URL : t.MODEL_BASE_URL };
      }, t.prototype._getModelLoadingConstraints = function() {
        return !0;
      }, t.prototype._processLoadedModel = function(e) {
        var i = this, r = this._isQuest(), o = this.handedness === "right" ? -1 : 1;
        this.getComponentIds().forEach(function(a) {
          var s = a && i.getComponent(a);
          s && s.onButtonStateChangedObservable.add(function(l) {
            if (i.rootMesh && !i.disableAnimation)
              switch (a) {
                case "xr-standard-trigger":
                  return void (r || (i._modelRootNode.getChildren()[3].rotation.x = 0.2 * -l.value, i._modelRootNode.getChildren()[3].position.y = 5e-3 * -l.value, i._modelRootNode.getChildren()[3].position.z = 5e-3 * -l.value));
                case "xr-standard-squeeze":
                  return void (r || (i._modelRootNode.getChildren()[4].position.x = o * l.value * 35e-4));
                case "xr-standard-thumbstick":
                  return;
                case "a-button":
                case "x-button":
                  return void (r || (l.pressed ? i._modelRootNode.getChildren()[1].position.y = -1e-3 : i._modelRootNode.getChildren()[1].position.y = 0));
                case "b-button":
                case "y-button":
                  return void (r || (l.pressed ? i._modelRootNode.getChildren()[2].position.y = -1e-3 : i._modelRootNode.getChildren()[2].position.y = 0));
              }
          }, void 0, !0);
        });
      }, t.prototype._setRootMesh = function(e) {
        this.rootMesh = new ie(this.profileId + " " + this.handedness, this.scene), this.scene.useRightHandedSystem || (this.rootMesh.rotationQuaternion = oe.FromEulerAngles(0, Math.PI, 0)), e.forEach(function(i) {
          i.isPickable = !1;
        }), this._isQuest() ? this._modelRootNode = e[0] : (this._modelRootNode = e[1], this.rootMesh.position.y = 0.034, this.rootMesh.position.z = 0.052), this._modelRootNode.parent = this.rootMesh;
      }, t.prototype._updateModel = function() {
      }, t.prototype._isQuest = function() {
        return !!navigator.userAgent.match(/Quest/gi) && !this._forceLegacyControllers;
      }, t.MODEL_BASE_URL = "https://controllers.babylonjs.com/oculus/", t.MODEL_LEFT_FILENAME = "left.babylon", t.MODEL_RIGHT_FILENAME = "right.babylon", t.QUEST_MODEL_BASE_URL = "https://controllers.babylonjs.com/oculusQuest/", t;
    }(Cs);
    Qn.RegisterController("oculus-touch", function(n, t) {
      return new xm(t, n.gamepad, n.handedness);
    }), Qn.RegisterController("oculus-touch-legacy", function(n, t) {
      return new xm(t, n.gamepad, n.handedness, !0);
    });
    var YN = { left: { selectComponentId: "xr-standard-trigger", components: { "xr-standard-trigger": { type: "trigger", gamepadIndices: { button: 0 }, rootNodeName: "xr_standard_trigger", visualResponses: {} }, "xr-standard-squeeze": { type: "squeeze", gamepadIndices: { button: 1 }, rootNodeName: "xr_standard_squeeze", visualResponses: {} }, "xr-standard-thumbstick": { type: "thumbstick", gamepadIndices: { button: 3, xAxis: 2, yAxis: 3 }, rootNodeName: "xr_standard_thumbstick", visualResponses: {} }, "x-button": { type: "button", gamepadIndices: { button: 4 }, rootNodeName: "x_button", visualResponses: {} }, "y-button": { type: "button", gamepadIndices: { button: 5 }, rootNodeName: "y_button", visualResponses: {} }, thumbrest: { type: "button", gamepadIndices: { button: 6 }, rootNodeName: "thumbrest", visualResponses: {} } }, gamepadMapping: "xr-standard", rootNodeName: "oculus-touch-v2-left", assetPath: "left.glb" }, right: { selectComponentId: "xr-standard-trigger", components: { "xr-standard-trigger": { type: "trigger", gamepadIndices: { button: 0 }, rootNodeName: "xr_standard_trigger", visualResponses: {} }, "xr-standard-squeeze": { type: "squeeze", gamepadIndices: { button: 1 }, rootNodeName: "xr_standard_squeeze", visualResponses: {} }, "xr-standard-thumbstick": { type: "thumbstick", gamepadIndices: { button: 3, xAxis: 2, yAxis: 3 }, rootNodeName: "xr_standard_thumbstick", visualResponses: {} }, "a-button": { type: "button", gamepadIndices: { button: 4 }, rootNodeName: "a_button", visualResponses: {} }, "b-button": { type: "button", gamepadIndices: { button: 5 }, rootNodeName: "b_button", visualResponses: {} }, thumbrest: { type: "button", gamepadIndices: { button: 6 }, rootNodeName: "thumbrest", visualResponses: {} } }, gamepadMapping: "xr-standard", rootNodeName: "oculus-touch-v2-right", assetPath: "right.glb" } }, tS = function(n) {
      function t(e, i, r) {
        var o = n.call(this, e, KN[r], i, r) || this;
        return o.profileId = "htc-vive", o;
      }
      return D(t, n), t.prototype._getFilenameAndPath = function() {
        return { filename: t.MODEL_FILENAME, path: t.MODEL_BASE_URL };
      }, t.prototype._getModelLoadingConstraints = function() {
        return !0;
      }, t.prototype._processLoadedModel = function(e) {
        var i = this;
        this.getComponentIds().forEach(function(r) {
          var o = r && i.getComponent(r);
          o && o.onButtonStateChangedObservable.add(function(a) {
            if (i.rootMesh && !i.disableAnimation)
              switch (r) {
                case "xr-standard-trigger":
                  return void (i._modelRootNode.getChildren()[6].rotation.x = 0.15 * -a.value);
                case "xr-standard-touchpad":
                case "xr-standard-squeeze":
                  return;
              }
          }, void 0, !0);
        });
      }, t.prototype._setRootMesh = function(e) {
        this.rootMesh = new ie(this.profileId + " " + this.handedness, this.scene), e.forEach(function(i) {
          i.isPickable = !1;
        }), this._modelRootNode = e[1], this._modelRootNode.parent = this.rootMesh, this.scene.useRightHandedSystem || (this.rootMesh.rotationQuaternion = oe.FromEulerAngles(0, Math.PI, 0));
      }, t.prototype._updateModel = function() {
      }, t.MODEL_BASE_URL = "https://controllers.babylonjs.com/vive/", t.MODEL_FILENAME = "wand.babylon", t;
    }(Cs);
    Qn.RegisterController("htc-vive", function(n, t) {
      return new tS(t, n.gamepad, n.handedness);
    });
    var Ca, KN = { left: { selectComponentId: "xr-standard-trigger", components: { "xr-standard-trigger": { type: "trigger", gamepadIndices: { button: 0 }, rootNodeName: "xr_standard_trigger", visualResponses: {} }, "xr-standard-squeeze": { type: "squeeze", gamepadIndices: { button: 1 }, rootNodeName: "xr_standard_squeeze", visualResponses: {} }, "xr-standard-touchpad": { type: "touchpad", gamepadIndices: { button: 2, xAxis: 0, yAxis: 1 }, rootNodeName: "xr_standard_touchpad", visualResponses: {} }, menu: { type: "button", gamepadIndices: { button: 4 }, rootNodeName: "menu", visualResponses: {} } }, gamepadMapping: "xr-standard", rootNodeName: "htc_vive_none", assetPath: "none.glb" }, right: { selectComponentId: "xr-standard-trigger", components: { "xr-standard-trigger": { type: "trigger", gamepadIndices: { button: 0 }, rootNodeName: "xr_standard_trigger", visualResponses: {} }, "xr-standard-squeeze": { type: "squeeze", gamepadIndices: { button: 1 }, rootNodeName: "xr_standard_squeeze", visualResponses: {} }, "xr-standard-touchpad": { type: "touchpad", gamepadIndices: { button: 2, xAxis: 0, yAxis: 1 }, rootNodeName: "xr_standard_touchpad", visualResponses: {} }, menu: { type: "button", gamepadIndices: { button: 4 }, rootNodeName: "menu", visualResponses: {} } }, gamepadMapping: "xr-standard", rootNodeName: "htc_vive_none", assetPath: "none.glb" }, none: { selectComponentId: "xr-standard-trigger", components: { "xr-standard-trigger": { type: "trigger", gamepadIndices: { button: 0 }, rootNodeName: "xr_standard_trigger", visualResponses: {} }, "xr-standard-squeeze": { type: "squeeze", gamepadIndices: { button: 1 }, rootNodeName: "xr_standard_squeeze", visualResponses: {} }, "xr-standard-touchpad": { type: "touchpad", gamepadIndices: { button: 2, xAxis: 0, yAxis: 1 }, rootNodeName: "xr_standard_touchpad", visualResponses: {} }, menu: { type: "button", gamepadIndices: { button: 4 }, rootNodeName: "menu", visualResponses: {} } }, gamepadMapping: "xr-standard", rootNodeName: "htc-vive-none", assetPath: "none.glb" } }, iS = function() {
      function n(t) {
        var e = this;
        this._nativeImpl = t, this._xrTransform = new XRRigidTransform(), this._xrPose = { transform: this._xrTransform, emulatedPosition: !1 }, this._xrPoseVectorData = new Float32Array(8), this.fillPoses = this._nativeImpl.fillPoses.bind(this._nativeImpl), this.getViewerPose = this._nativeImpl.getViewerPose.bind(this._nativeImpl), this.getHitTestResults = this._nativeImpl.getHitTestResults.bind(this._nativeImpl), this.getHitTestResultsForTransientInput = function() {
          throw new Error("XRFrame.getHitTestResultsForTransientInput not supported on native.");
        }, this.createAnchor = this._nativeImpl.createAnchor.bind(this._nativeImpl), this.getJointPose = this._nativeImpl.getJointPose.bind(this._nativeImpl), this.fillJointRadii = this._nativeImpl.fillJointRadii.bind(this._nativeImpl), this.getLightEstimate = function() {
          throw new Error("XRFrame.getLightEstimate not supported on native.");
        }, this.getImageTrackingResults = function() {
          var i;
          return (i = e._nativeImpl._imageTrackingResults) !== null && i !== void 0 ? i : [];
        };
      }
      return Object.defineProperty(n.prototype, "session", { get: function() {
        return this._nativeImpl.session;
      }, enumerable: !1, configurable: !0 }), n.prototype.getPose = function(t, e) {
        if (this._nativeImpl.getPoseData(t, e, this._xrPoseVectorData.buffer, this._xrTransform.matrix.buffer)) {
          var i = this._xrTransform.position;
          i.x = this._xrPoseVectorData[0], i.y = this._xrPoseVectorData[1], i.z = this._xrPoseVectorData[2], i.w = this._xrPoseVectorData[3];
          var r = this._xrTransform.orientation;
          return r.x = this._xrPoseVectorData[4], r.y = this._xrPoseVectorData[5], r.z = this._xrPoseVectorData[6], r.w = this._xrPoseVectorData[7], this._xrPose;
        }
      }, Object.defineProperty(n.prototype, "trackedAnchors", { get: function() {
        return this._nativeImpl.trackedAnchors;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "worldInformation", { get: function() {
        return this._nativeImpl.worldInformation;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "detectedPlanes", { get: function() {
        return this._nativeImpl.detectedPlanes;
      }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "featurePointCloud", { get: function() {
        return this._nativeImpl.featurePointCloud;
      }, enumerable: !1, configurable: !0 }), n.prototype.getDepthInformation = function(t) {
        throw new Error("This function is not available in Babylon Native");
      }, n;
    }();
    ry("NativeXRFrame", iS), function(n) {
      n[n.Input = 0] = "Input", n[n.Output = 1] = "Output";
    }(Ca || (Ca = {}));
    var nS = function() {
      function n(t, e, i) {
        this._ownerBlock = i, this._connectedPoint = [], this.uniqueId = ra(), this.connectedPointIds = [], this.name = t, this._connectionType = e;
      }
      return Object.defineProperty(n.prototype, "connectionType", { get: function() {
        return this._connectionType;
      }, enumerable: !1, configurable: !0 }), n.prototype._isSingularConnection = function() {
        return !0;
      }, n.prototype.isConnected = function() {
        return this._connectedPoint.length > 0;
      }, n.prototype.connectTo = function(t) {
        if (this._connectionType === t._connectionType)
          throw new Error("Cannot connect two points of type ".concat(this.connectionType));
        if (this._isSingularConnection() && this._connectedPoint.length > 0 || t._isSingularConnection() && t._connectedPoint.length > 0)
          throw new Error("Max number of connections for point reached");
        this._connectedPoint.push(t), t._connectedPoint.push(this);
      }, n.prototype.serialize = function(t) {
        t === void 0 && (t = {}), t.uniqueId = this.uniqueId, t.name = this.name, t._connectionType = this._connectionType, t.connectedPointIds = [], t.className = this.getClassName();
        for (var e = 0, i = this._connectedPoint; e < i.length; e++) {
          var r = i[e];
          t.connectedPointIds.push(r.uniqueId);
        }
      }, n.prototype.getClassName = function() {
        return "FGConnection";
      }, n.prototype.deserialize = function(t) {
        this.uniqueId = t.uniqueId, this.name = t.name, this._connectionType = t._connectionType, this.connectedPointIds = t.connectedPointIds;
      }, n.Parse = function(t, e) {
        t === void 0 && (t = {});
        var i = new (de.Instantiate(t.className))(t.name, t._connectionType, e);
        return i.deserialize(t), i;
      }, n;
    }(), Or = function() {
      function n(t, e) {
        this.typeName = t, this.defaultValue = e;
      }
      return n.prototype.serialize = function(t) {
        t.typeName = this.typeName, t.defaultValue = this.defaultValue;
      }, n.Parse = function(t) {
        return new n(t.typeName, t.defaultValue);
      }, n;
    }(), ln = new Or("any", void 0), _u = new Or("string", ""), Ae = new Or("number", 0), cn = new Or("boolean", !1), $i = new Or("Vector2", fe.Zero()), ii = new Or("Vector3", v.Zero()), pn = new Or("Vector4", lt.Zero()), Ri = new Or("Matrix", B.Identity()), rS = new Or("Color3", ne.Black()), oS = new Or("Color4", new Ie(0, 0, 0, 0)), mu = new Or("Quaternion", oe.Identity());
    function aS(n) {
      switch (typeof n) {
        case "string":
          return _u;
        case "number":
          return Ae;
        case "boolean":
          return cn;
        case "object":
          return n instanceof fe ? $i : n instanceof v ? ii : n instanceof lt ? pn : n instanceof ne ? rS : n instanceof Ie ? oS : n instanceof oe ? mu : ln;
        default:
          return ln;
      }
    }
    var sS = function(n) {
      function t(e, i, r, o) {
        var a = n.call(this, e, i, r) || this;
        return a.richType = o, a;
      }
      return D(t, n), t.prototype._isSingularConnection = function() {
        return this.connectionType === Ca.Input;
      }, t.prototype.setValue = function(e, i) {
        i._setConnectionValue(this, e);
      }, t.prototype.connectTo = function(e) {
        n.prototype.connectTo.call(this, e);
      }, t.prototype._getValueOrDefault = function(e) {
        return e._hasConnectionValue(this) ? e._getConnectionValue(this) : this.richType.defaultValue;
      }, t.prototype.getValue = function(e) {
        return this.connectionType === Ca.Output ? (e._notifyExecuteNode(this._ownerBlock), this._ownerBlock._updateOutputs(e), this._getValueOrDefault(e)) : this.isConnected() ? this._connectedPoint[0].getValue(e) : this._getValueOrDefault(e);
      }, t.prototype.getClassName = function() {
        return "FGDataConnection";
      }, t.prototype.serialize = function(e) {
        e === void 0 && (e = {}), n.prototype.serialize.call(this, e), e.richType = {}, this.richType.serialize(e.richType);
      }, t.Parse = function(e, i) {
        var r = nS.Parse(e, i);
        return r.richType = Or.Parse(e.richType), r;
      }, t;
    }(nS);
    j("FGDataConnection", sS);
    var bn = function() {
      function n(t) {
        this.config = t, this.uniqueId = ra(), this.configure();
      }
      return n.prototype.configure = function() {
        var t, e;
        this.name = (e = (t = this.config) === null || t === void 0 ? void 0 : t.name) !== null && e !== void 0 ? e : this.getClassName(), this.dataInputs = [], this.dataOutputs = [];
      }, n.prototype._updateOutputs = function(t) {
      }, n.prototype.registerDataInput = function(t, e) {
        var i = new sS(t, Ca.Input, this, e);
        return this.dataInputs.push(i), i;
      }, n.prototype.registerDataOutput = function(t, e) {
        var i = new sS(t, Ca.Output, this, e);
        return this.dataOutputs.push(i), i;
      }, n.prototype.getDataInput = function(t) {
        return this.dataInputs.find(function(e) {
          return e.name === t;
        });
      }, n.prototype.serialize = function(t) {
        t === void 0 && (t = {}), t.uniqueId = this.uniqueId, t.config = {}, this.config && (t.config.name = this.config.name), t.dataInputs = [], t.dataOutputs = [], t.className = this.getClassName();
        for (var e = 0, i = this.dataInputs; e < i.length; e++) {
          var r = {};
          i[e].serialize(r), t.dataInputs.push(r);
        }
        for (var o = 0, a = this.dataOutputs; o < a.length; o++) {
          var s = {};
          a[o].serialize(s), t.dataOutputs.push(s);
        }
      }, n.prototype.getClassName = function() {
        return "FGBlock";
      }, n.Parse = function(t) {
        var e = de.Instantiate(t.className), i = {};
        if (t.config)
          for (var r in t.config) {
            var o = t.config[r];
            if (o && o.className) {
              var a = de.Instantiate(o.className);
              i[r] = a.prototype.Parse(o);
            } else
              i[r] = o;
          }
        var s = new e(i);
        s.uniqueId = t.uniqueId;
        for (var l = 0; l < t.dataInputs.length; l++)
          s.dataInputs[l].deserialize(t.dataInputs[l]);
        for (l = 0; l < t.dataOutputs.length; l++)
          s.dataOutputs[l].deserialize(t.dataOutputs[l]);
        if (s instanceof po) {
          for (l = 0; l < t.signalInputs.length; l++)
            s.signalInputs[l].deserialize(t.signalInputs[l]);
          for (l = 0; l < t.signalOutputs.length; l++)
            s.signalOutputs[l].deserialize(t.signalOutputs[l]);
        }
        return s;
      }, n;
    }(), kd = function(n) {
      function t() {
        return n !== null && n.apply(this, arguments) || this;
      }
      return D(t, n), t.prototype._isSingularConnection = function() {
        return this.connectionType === Ca.Output;
      }, t.prototype._activateSignal = function(e) {
        var i;
        this.connectionType === Ca.Input ? (e._notifyExecuteNode(this._ownerBlock), this._ownerBlock._execute(e, this), e._increaseExecutionId()) : (i = this._connectedPoint[0]) === null || i === void 0 || i._activateSignal(e);
      }, t;
    }(nS);
    j("FlowGraphSignalConnection", kd);
    var po = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.onStart = i._registerSignalInput("onStart"), i;
      }
      return D(t, n), t.prototype.configure = function() {
        n.prototype.configure.call(this), this.signalInputs = [], this.signalOutputs = [];
      }, t.prototype._registerSignalInput = function(e) {
        var i = new kd(e, Ca.Input, this);
        return this.signalInputs.push(i), i;
      }, t.prototype._registerSignalOutput = function(e) {
        var i = new kd(e, Ca.Output, this);
        return this.signalOutputs.push(i), i;
      }, t.prototype.serialize = function(e) {
        e === void 0 && (e = {}), n.prototype.serialize.call(this, e), e.signalInputs = [], e.signalOutputs = [];
        for (var i = 0, r = this.signalInputs; i < r.length; i++) {
          var o = {};
          r[i].serialize(o), e.signalInputs.push(o);
        }
        for (var a = 0, s = this.signalOutputs; a < s.length; a++) {
          var l = {};
          s[a].serialize(l), e.signalOutputs.push(l);
        }
      }, t.prototype.getClassName = function() {
        return "FGExecutionBlock";
      }, t.Parse = function(e) {
        e === void 0 && (e = {});
        for (var i = n.Parse.call(this, e), r = 0; r < e.signalInputs.length; r++)
          i.signalInputs[r].deserialize(e.signalInputs[r]);
        for (r = 0; r < e.signalOutputs.length; r++)
          i.signalOutputs[r].deserialize(e.signalOutputs[r]);
        return i;
      }, t;
    }(bn), lS = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.onDone = i._registerSignalOutput("onDone"), i;
      }
      return D(t, n), t.prototype._startPendingTasks = function(e) {
        this._preparePendingTasks(e), e._addPendingBlock(this);
      }, t;
    }(po), Ll = function(n) {
      function t() {
        return n !== null && n.apply(this, arguments) || this;
      }
      return D(t, n), t.prototype._execute = function(e) {
        e._notifyExecuteNode(this), this.onDone._activateSignal(e);
      }, t;
    }(lS);
    function BI(n) {
      return n === "Mesh" || n === "AbstractMesh" || n === "GroundMesh" || n === "InstanceMesh" || n === "LinesMesh" || n === "GoldbergMesh" || n === "GreasedLineMesh" || n === "TrailMesh";
    }
    function UI(n) {
      return n === "Vector2" || n === "Vector3" || n === "Vector4" || n === "Quaternion";
    }
    function qN(n, t, e) {
      var i, r, o = (r = (i = t == null ? void 0 : t.getClassName) === null || i === void 0 ? void 0 : i.call(t)) !== null && r !== void 0 ? r : "";
      BI(o) ? e[n] = { name: t.name, className: o } : UI(o) ? e[n] = { value: t.asArray(), className: o } : e[n] = t;
    }
    function QN(n, t, e) {
      var i, r = t[n], o = r == null ? void 0 : r.className;
      return i = BI(o) ? e.getMeshByName(r.name) : UI(o) ? function(a, s) {
        if (a === "Vector2")
          return fe.FromArray(s);
        if (a === "Vector3")
          return v.FromArray(s);
        if (a === "Vector4")
          return lt.FromArray(s);
        if (a === "Quaternion")
          return oe.FromArray(s);
        throw new Error("Unknown vector class name ".concat(a));
      }(o, r.value) : r, i;
    }
    var is, Am = function() {
      function n(t) {
        this.uniqueId = ra(), this._userVariables = {}, this._executionVariables = {}, this._connectionValues = {}, this._pendingBlocks = [], this._executionId = 0, this.onNodeExecutedObservable = new H(), this._configuration = t;
      }
      return n.prototype.hasVariable = function(t) {
        return t in this._userVariables;
      }, n.prototype.setVariable = function(t, e) {
        this._userVariables[t] = e;
      }, n.prototype.getVariable = function(t) {
        return this._userVariables[t];
      }, n.prototype._getUniqueIdPrefixedName = function(t, e) {
        return "".concat(t.uniqueId, "_").concat(e);
      }, n.prototype._setExecutionVariable = function(t, e, i) {
        this._executionVariables[this._getUniqueIdPrefixedName(t, e)] = i;
      }, n.prototype._getExecutionVariable = function(t, e, i) {
        return this._hasExecutionVariable(t, e) ? this._executionVariables[this._getUniqueIdPrefixedName(t, e)] : i;
      }, n.prototype._deleteExecutionVariable = function(t, e) {
        delete this._executionVariables[this._getUniqueIdPrefixedName(t, e)];
      }, n.prototype._hasExecutionVariable = function(t, e) {
        return this._getUniqueIdPrefixedName(t, e) in this._executionVariables;
      }, n.prototype._hasConnectionValue = function(t) {
        return t.uniqueId in this._connectionValues;
      }, n.prototype._setConnectionValue = function(t, e) {
        this._connectionValues[t.uniqueId] = e;
      }, n.prototype._getConnectionValue = function(t) {
        return this._connectionValues[t.uniqueId];
      }, Object.defineProperty(n.prototype, "configuration", { get: function() {
        return this._configuration;
      }, enumerable: !1, configurable: !0 }), n.prototype._addPendingBlock = function(t) {
        this._pendingBlocks.push(t);
      }, n.prototype._removePendingBlock = function(t) {
        var e = this._pendingBlocks.indexOf(t);
        e !== -1 && this._pendingBlocks.splice(e, 1);
      }, n.prototype._clearPendingBlocks = function() {
        for (var t = 0, e = this._pendingBlocks; t < e.length; t++)
          e[t]._cancelPendingTasks(this);
        this._pendingBlocks.length = 0;
      }, n.prototype._notifyExecuteNode = function(t) {
        this.onNodeExecutedObservable.notifyObservers(t);
      }, n.prototype._increaseExecutionId = function() {
        this._executionId++;
      }, Object.defineProperty(n.prototype, "executionId", { get: function() {
        return this._executionId;
      }, enumerable: !1, configurable: !0 }), n.prototype.serialize = function(t, e) {
        for (var i in t === void 0 && (t = {}), e === void 0 && (e = qN), t.uniqueId = this.uniqueId, t._userVariables = {}, this._userVariables)
          e(i, this._userVariables[i], t._userVariables);
        for (var i in t._connectionValues = {}, this._connectionValues)
          e(i, this._connectionValues[i], t._connectionValues);
      }, n.prototype.getClassName = function() {
        return "FGContext";
      }, n.Parse = function(t, e, i) {
        t === void 0 && (t = {}), i === void 0 && (i = QN);
        var r = e.createContext();
        for (var o in r.uniqueId = t.uniqueId, t._userVariables) {
          var a = i(o, t._userVariables, r._configuration.scene);
          r._userVariables[o] = a;
        }
        for (var o in t._connectionValues)
          a = i(o, t._connectionValues, r._configuration.scene), r._connectionValues[o] = a;
        return r;
      }, x([N()], n.prototype, "uniqueId", void 0), n;
    }();
    (function(n) {
      n[n.Stopped = 0] = "Stopped", n[n.Started = 1] = "Started";
    })(is || (is = {}));
    var Rm = function() {
      function n(t) {
        var e = this;
        this._eventBlocks = [], this._executionContexts = [], this.state = is.Stopped, this._scene = t.scene, this._coordinator = t.coordinator, this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function() {
          return e.dispose();
        });
      }
      return n.prototype.createContext = function() {
        var t = new Am({ scene: this._scene, coordinator: this._coordinator });
        return this._executionContexts.push(t), t;
      }, n.prototype.addEventBlock = function(t) {
        this._eventBlocks.push(t);
      }, n.prototype.start = function() {
        if (this.state !== is.Started) {
          this.state = is.Started, this._executionContexts.length === 0 && this.createContext();
          for (var t = 0, e = this._executionContexts; t < e.length; t++)
            for (var i = e[t], r = 0, o = this._eventBlocks; r < o.length; r++)
              o[r]._startPendingTasks(i);
        }
      }, n.prototype.dispose = function() {
        if (this.state !== is.Stopped) {
          this.state = is.Stopped;
          for (var t = 0, e = this._executionContexts; t < e.length; t++)
            e[t]._clearPendingBlocks();
          this._executionContexts.length = 0, this._eventBlocks.length = 0, this._scene.onDisposeObservable.remove(this._sceneDisposeObserver), this._sceneDisposeObserver = null;
        }
      }, n.prototype.visitAllBlocks = function(t) {
        for (var e = [], i = /* @__PURE__ */ new Set(), r = 0, o = this._eventBlocks; r < o.length; r++) {
          var a = o[r];
          e.push(a), i.add(a.uniqueId);
        }
        for (; e.length > 0; ) {
          t(a = e.pop());
          for (var s = 0, l = a.dataInputs; s < l.length; s++)
            for (var c = 0, u = l[s]._connectedPoint; c < u.length; c++) {
              var h = u[c];
              i.has(h._ownerBlock.uniqueId) || (e.push(h._ownerBlock), i.add(h._ownerBlock.uniqueId));
            }
          if (a instanceof po)
            for (var d = 0, p = a.signalOutputs; d < p.length; d++)
              for (var f = 0, m = p[d]._connectedPoint; f < m.length; f++)
                h = m[f], i.has(h._ownerBlock.uniqueId) || (e.push(h._ownerBlock), i.add(h._ownerBlock.uniqueId));
        }
      }, n.prototype.serialize = function(t, e) {
        t === void 0 && (t = {}), t.variableDefinitions = {}, t.allBlocks = [], this.visitAllBlocks(function(a) {
          var s = {};
          a.serialize(s), t.allBlocks.push(s);
        }), t.executionContexts = [];
        for (var i = 0, r = this._executionContexts; i < r.length; i++) {
          var o = {};
          r[i].serialize(o, e), t.executionContexts.push(o);
        }
      }, n.GetDataOutConnectionByUniqueId = function(t, e) {
        for (var i = 0, r = t; i < r.length; i++)
          for (var o = 0, a = r[i].dataOutputs; o < a.length; o++) {
            var s = a[o];
            if (s.uniqueId === e)
              return s;
          }
        throw new Error("Could not find data out connection with unique id " + e);
      }, n.GetSignalInConnectionByUniqueId = function(t, e) {
        for (var i = 0, r = t; i < r.length; i++) {
          var o = r[i];
          if (o instanceof po)
            for (var a = 0, s = o.signalInputs; a < s.length; a++) {
              var l = s[a];
              if (l.uniqueId === e)
                return l;
            }
        }
        throw new Error("Could not find signal in connection with unique id " + e);
      }, n.Parse = function(t, e, i) {
        for (var r = e.createGraph(), o = [], a = 0, s = t.allBlocks; a < s.length; a++) {
          var l = s[a], c = bn.Parse(l);
          o.push(c), c instanceof Ll && r.addEventBlock(c);
        }
        for (var u = 0, h = o; u < h.length; u++) {
          for (var d = 0, p = (c = h[u]).dataInputs; d < p.length; d++)
            for (var f = p[d], m = 0, g = f.connectedPointIds; m < g.length; m++) {
              var y = g[m], b = n.GetDataOutConnectionByUniqueId(o, y);
              f.connectTo(b);
            }
          if (c instanceof po)
            for (var T = 0, S = c.signalOutputs; T < S.length; T++)
              for (var E = S[T], A = 0, R = E.connectedPointIds; A < R.length; A++)
                y = R[A], b = n.GetSignalInConnectionByUniqueId(o, y), E.connectTo(b);
        }
        for (var C = 0, L = t.executionContexts; C < L.length; C++) {
          var I = L[C];
          Am.Parse(I, r, i);
        }
        return r;
      }, n;
    }(), VI = function() {
    }, kI = function() {
      function n(t) {
        var e, i = this;
        this._config = t, this._flowGraphs = [], this._customEventsMap = /* @__PURE__ */ new Map(), this._config.scene.onDisposeObservable.add(function() {
          i.dispose();
        }), ((e = n.SceneCoordinators.get(this._config.scene)) !== null && e !== void 0 ? e : []).push(this);
      }
      return n.prototype.createGraph = function() {
        var t = new Rm({ scene: this._config.scene, coordinator: this });
        return this._flowGraphs.push(t), t;
      }, n.prototype.removeGraph = function(t) {
        var e = this._flowGraphs.indexOf(t);
        e !== -1 && (t.dispose(), this._flowGraphs.splice(e, 1));
      }, n.prototype.start = function() {
        this._flowGraphs.forEach(function(t) {
          return t.start();
        });
      }, n.prototype.dispose = function() {
        var t;
        this._flowGraphs.forEach(function(r) {
          return r.dispose();
        }), this._flowGraphs.length = 0;
        var e = (t = n.SceneCoordinators.get(this._config.scene)) !== null && t !== void 0 ? t : [], i = e.indexOf(this);
        i !== -1 && e.splice(i, 1);
      }, n.prototype.serialize = function(t, e) {
        t._flowGraphs = [], this._flowGraphs.forEach(function(i) {
          var r = {};
          i.serialize(r, e), t._flowGraphs.push(r);
        });
      }, n.Parse = function(t, e, i) {
        var r, o = new n({ scene: e });
        return (r = t._flowGraphs) === null || r === void 0 || r.forEach(function(a) {
          Rm.Parse(a, o, i);
        }), o;
      }, n.prototype.getCustomEventObservable = function(t) {
        var e = this._customEventsMap.get(t);
        return e || (e = new H(), this._customEventsMap.set(t, e)), e;
      }, n.prototype.notifyCustomEvent = function(t, e) {
        var i = this._customEventsMap.get(t);
        i && i.notifyObservers(e);
      }, n.SceneCoordinators = /* @__PURE__ */ new Map(), n;
    }(), GI = function(n) {
      this._context = n, this._context.onNodeExecutedObservable.add(function(t) {
        de.Log("Node executed: ".concat(t.getClassName()));
      });
    }, ZN = /([./])({?\w+}?)/g, cS = function() {
      function n(t) {
        this._templateSubstitutions = {}, this._pathParts = [], this._templateStrings = [], this.hasTemplateStrings = !1, this._path = t;
        var e = this._getPathPartsAndTemplateStrings(t), i = e.pathParts, r = e.templateStrings;
        this._pathParts = i, this._templateStrings = r, this.hasTemplateStrings = r.length > 0;
      }
      return n.prototype._getPathPartsAndTemplateStrings = function(t) {
        for (var e = t.matchAll(ZN), i = [], r = [], o = e.next(); !o.done; ) {
          var a = o.value, s = a[1], l = a[2], c = l, u = !1;
          l.startsWith("{") && l.endsWith("}") && (u = !0, c = l.slice(1, l.length - 1), r.indexOf(c) === -1 && r.push(c)), i.push({ value: l, isTemplate: u, valueWithoutBraces: c, separator: s }), o = e.next();
        }
        return { pathParts: i, templateStrings: r };
      }, n.prototype.getTemplateStrings = function() {
        return this._templateStrings;
      }, n.prototype.setTemplateSubstitution = function(t, e) {
        if (this._templateStrings.indexOf(t) === -1)
          throw new Error("Template string ".concat(t, " does not exist in path ").concat(this._path));
        this._templateSubstitutions[t] = e;
      }, n.prototype._evaluateTemplates = function() {
        for (var t = 0, e = this._pathParts; t < e.length; t++) {
          var i = e[t];
          if (i.isTemplate) {
            var r = this._templateSubstitutions[i.valueWithoutBraces];
            if (r === void 0)
              throw new Error("Template string ".concat(i.value, " was not substituted"));
            i.replacedValue = r.toString();
          }
        }
      }, n.prototype._getFinalPath = function() {
        for (var t = "", e = 0, i = this._pathParts; e < i.length; e++) {
          var r = i[e];
          t += r.separator, r.isTemplate ? t += r.replacedValue : t += r.value;
        }
        return t;
      }, n.prototype._evaluatePath = function(t) {
        this._evaluateTemplates();
        for (var e = [], i = [], r = t._userVariables, o = 0, a = this._pathParts; o < a.length; o++) {
          var s = a[o];
          if (r === void 0)
            throw new Error("Could not find path ".concat(this._getFinalPath(), " in target context"));
          var l = s.isTemplate ? s.replacedValue : s.value;
          if (!l)
            throw new Error("Invalid path ".concat(this._getFinalPath()));
          r = r[l], e.push(r), i.push(l);
        }
        return { entityChain: e, splitPath: i };
      }, n.prototype.getProperty = function(t) {
        var e = this._evaluatePath(t).entityChain;
        return e[e.length - 1];
      }, n.prototype.setProperty = function(t, e) {
        var i = this._evaluatePath(t), r = i.entityChain, o = i.splitPath;
        r[r.length - 2][o[o.length - 1]] = e;
      }, n.prototype.getClassName = function() {
        return "FGPath";
      }, n.prototype.serialize = function(t) {
        return t === void 0 && (t = {}), t.path = this._path, t.className = this.getClassName(), t;
      }, n.prototype.Parse = function(t) {
        return new n(t.path);
      }, n;
    }();
    j("FGPath", cS);
    var vr = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.onDone = i._registerSignalOutput("onDone"), i;
      }
      return D(t, n), t;
    }(po), uS = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.message = i.registerDataInput("message", ln), i;
      }
      return D(t, n), t.prototype._execute = function(e) {
        var i = this.message.getValue(e);
        console.log(i), this.onDone._activateSignal(e);
      }, t.prototype.getClassName = function() {
        return "FGLogBlock";
      }, t;
    }(vr);
    j("FGLogBlock", uS);
    var hS = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.variableName = i.registerDataInput("variableName", _u), i.input = i.registerDataInput("input", ln), i;
      }
      return D(t, n), t.prototype._execute = function(e) {
        var i = this.variableName.getValue(e), r = this.input.getValue(e);
        e.setVariable(i, r), this.onDone._activateSignal(e);
      }, t.prototype.getClassName = function() {
        return "FGSetVariableBlock";
      }, t;
    }(vr);
    j("FGSetVariableBlock", hS);
    var dS = function() {
      function n(t, e) {
        this.templateStringInputs = [], this.path = t, this.ownerBlock = e;
        for (var i = 0, r = t.getTemplateStrings(); i < r.length; i++) {
          var o = r[i];
          this.templateStringInputs.push(this.ownerBlock.registerDataInput(o, Ae));
        }
      }
      return n.prototype.substitutePath = function(t) {
        for (var e = 0, i = this.templateStringInputs; e < i.length; e++) {
          var r = i[e], o = r.getValue(t), a = r.name;
          this.path.setTemplateSubstitution(a, o);
        }
        return this.path;
      }, n.prototype.getProperty = function(t) {
        return this.substitutePath(t), this.path.getProperty(t);
      }, n.prototype.setProperty = function(t, e) {
        this.substitutePath(t), this.path.setProperty(t, e);
      }, n;
    }(), pS = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.config = e, i.value = i.registerDataInput("value", ln), i.templateComponent = new dS(e.path, i), i;
      }
      return D(t, n), t.prototype._execute = function(e) {
        var i = this.value.getValue(e);
        this.templateComponent.setProperty(e, i), this.onDone._activateSignal(e);
      }, t.prototype.serialize = function(e) {
        e === void 0 && (e = {}), n.prototype.serialize.call(this, e), e.config.path = this.config.path.serialize();
      }, t.prototype.getClassName = function() {
        return "FGSetPropertyBlock";
      }, t;
    }(vr);
    j("FGSetPropertyBlock", pS);
    var fS = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.eventId = i.registerDataInput("eventId", _u), i.eventData = i.registerDataInput("eventData", ln), i;
      }
      return D(t, n), t.prototype._execute = function(e) {
        var i = this.eventId.getValue(e), r = this.eventData.getValue(e);
        e.configuration.coordinator.notifyCustomEvent(i, r), this.onDone._activateSignal(e);
      }, t.prototype.getClassName = function() {
        return "FGSendCustomEventBlock";
      }, t;
    }(vr);
    j("FGSendCustomEventBlock", fS);
    var _S = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.condition = i.registerDataInput("condition", cn), i.onTrue = i._registerSignalOutput("onTrue"), i.onFalse = i._registerSignalOutput("onFalse"), i;
      }
      return D(t, n), t.prototype._execute = function(e) {
        this.condition.getValue(e) ? this.onTrue._activateSignal(e) : this.onFalse._activateSignal(e);
      }, t.prototype.getClassName = function() {
        return "FGBranchBlock";
      }, t;
    }(po);
    j("FGBranchBlock", _S);
    var mS = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.reset = i._registerSignalInput("reset"), i.maxNumberOfExecutions = i.registerDataInput("numberOfExecutions", Ae), i.currentCount = i.registerDataOutput("currentCount", Ae), i;
      }
      return D(t, n), t.prototype._execute = function(e, i) {
        if (i === this.reset)
          this.currentCount.setValue(0, e);
        else {
          var r = this.currentCount.getValue(e);
          r < this.maxNumberOfExecutions.getValue(e) && (this.currentCount.setValue(r + 1, e), this.onDone._activateSignal(e));
        }
      }, t.prototype.getClassName = function() {
        return "FGDoNBlock";
      }, t;
    }(vr);
    j("FGDoNBlock", mS);
    var gS = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.startIndex = i.registerDataInput("startIndex", Ae), i.endIndex = i.registerDataInput("endIndex", Ae), i.step = i.registerDataInput("step", Ae), i.index = i.registerDataOutput("index", Ae), i.onLoop = i._registerSignalOutput("onLoop"), i.onDone = i._registerSignalOutput("onDone"), i;
      }
      return D(t, n), t.prototype._executeLoop = function(e) {
        var i = e._getExecutionVariable(this, "index");
        i < e._getExecutionVariable(this, "endIndex") ? (this.index.setValue(i, e), this.onLoop._activateSignal(e), i += e._getExecutionVariable(this, "step", 1), e._setExecutionVariable(this, "index", i), this._executeLoop(e)) : this.onDone._activateSignal(e);
      }, t.prototype._execute = function(e) {
        var i = this.startIndex.getValue(e), r = this.endIndex.getValue(e), o = this.step.getValue(e);
        e._setExecutionVariable(this, "index", i), e._setExecutionVariable(this, "endIndex", r), e._setExecutionVariable(this, "step", o), this._executeLoop(e);
      }, t.prototype.getClassName = function() {
        return "FGForLoopBlock";
      }, t;
    }(vr);
    j("FGForLoopBlock", gS);
    var vS = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.reset = i._registerSignalInput("reset"), i.duration = i.registerDataInput("duration", Ae), i.timeRemaining = i.registerDataOutput("timeRemaining", Ae), i;
      }
      return D(t, n), t.prototype._execute = function(e, i) {
        var r = e._getExecutionVariable(this, "lastExecutedTime"), o = this.duration.getValue(e), a = Date.now();
        if (i === this.reset || r === void 0 || a - r > o)
          this.timeRemaining.setValue(0, e), this.onDone._activateSignal(e), e._setExecutionVariable(this, "lastExecutedTime", a);
        else {
          var s = o - (a - r);
          this.timeRemaining.setValue(s, e);
        }
      }, t.prototype.getClassName = function() {
        return "FGThrottleBlock";
      }, t;
    }(vr);
    j("FGThrottleBlock", vS);
    var yS = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.timeout = i.registerDataInput("timeout", Ae), i.onTimerDone = i._registerSignalOutput("onTimerDone"), i;
      }
      return D(t, n), t.prototype._preparePendingTasks = function(e) {
        var i = this, r = this.timeout.getValue(e);
        if (r !== void 0 && r >= 0) {
          var o = e._getExecutionVariable(this, "runningTimers") || [], a = e.configuration.scene, s = new Ly({ timeout: r, contextObservable: a.onBeforeRenderObservable, onEnded: function() {
            return i._onEnded(s, e);
          } });
          s.start(), o.push(s), e._setExecutionVariable(this, "runningTimers", o);
        }
      }, t.prototype._execute = function(e) {
        this._startPendingTasks(e), this.onDone._activateSignal(e);
      }, t.prototype._onEnded = function(e, i) {
        var r = i._getExecutionVariable(this, "runningTimers") || [], o = r.indexOf(e);
        o !== -1 ? r.splice(o, 1) : de.Warn("FlowGraphTimerBlock: Timer ended but was not found in the running timers list"), i._removePendingBlock(this), this.onTimerDone._activateSignal(i);
      }, t.prototype._cancelPendingTasks = function(e) {
        for (var i = 0, r = e._getExecutionVariable(this, "runningTimers") || []; i < r.length; i++)
          r[i].dispose();
        e._deleteExecutionVariable(this, "runningTimers");
      }, t.prototype.getClassName = function() {
        return "FGTimerBlock";
      }, t;
    }(lS);
    j("FGTimerBlock", yS);
    var bS = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.config = e, i._cachedUnusedIndexes = [], i.reset = i._registerSignalInput("reset"), i.currentIndex = i.registerDataOutput("currentIndex", Ae), i;
      }
      return D(t, n), t.prototype.configure = function() {
        n.prototype.configure.call(this), this.config.startIndex = this.config.startIndex !== void 0 ? this.config.startIndex : 0, this.config.startIndex = Math.max(0, Math.min(this.config.startIndex, this.config.numberOutputFlows - 1)), this.outFlows = [];
        for (var e = 0; e < this.config.numberOutputFlows; e++)
          this.outFlows.push(this._registerSignalOutput("out".concat(e)));
      }, t.prototype._getUnusedIndexes = function(e) {
        var i = this._cachedUnusedIndexes;
        if (i.length = 0, e._hasExecutionVariable(this, "unusedIndexes")) {
          var r = e._getExecutionVariable(this, "unusedIndexes");
          for (o = 0; o < r.length; o++)
            i.push(r[o]);
        } else
          for (var o = 0; o < this.config.numberOutputFlows; o++)
            i.push(o);
        return i;
      }, t.prototype._getNextOutput = function(e, i) {
        return this.config.isRandom ? i[Math.floor(Math.random() * i.length)] : e + 1;
      }, t.prototype._execute = function(e, i) {
        var r, o = (r = e._getExecutionVariable(this, "currentIndex")) !== null && r !== void 0 ? r : this.config.startIndex - 1, a = this._getUnusedIndexes(e);
        if (i === this.reset)
          return e._deleteExecutionVariable(this, "currentIndex"), void e._deleteExecutionVariable(this, "unusedIndexes");
        var s = this._getNextOutput(o, a);
        if (s >= this.config.numberOutputFlows && this.config.loop)
          s = 0;
        else if (s >= this.config.numberOutputFlows && !this.config.loop)
          return;
        if (a = a.filter(function(c) {
          return c !== s;
        }), a.length === 0)
          for (var l = 0; l < this.config.numberOutputFlows; l++)
            a.push(l);
        e._setExecutionVariable(this, "unusedIndexes", a), e._setExecutionVariable(this, "currentIndex", s), this.currentIndex.setValue(s, e), this.outFlows[s]._activateSignal(e);
      }, t.prototype.getClassName = function() {
        return "FGMultiGateBlock";
      }, t.prototype.serialize = function(e) {
        n.prototype.serialize.call(this, e), e.config.numberOutputFlows = this.config.numberOutputFlows, e.config.isRandom = this.config.isRandom, e.config.loop = this.config.loop, e.config.startIndex = this.config.startIndex;
      }, t;
    }(po);
    j("FGMultiGateBlock", bS);
    var TS = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.config = e, i.selection = i.registerDataInput("selection", ln), i;
      }
      return D(t, n), t.prototype.configure = function() {
        n.prototype.configure.call(this), this.outputFlows = [];
        for (var e = 0; e <= this.config.cases.length; e++)
          this.outputFlows.push(this._registerSignalOutput("out".concat(e)));
      }, t.prototype._execute = function(e, i) {
        for (var r = this.selection.getValue(e), o = 0; o < this.config.cases.length; o++)
          if (r === this.config.cases[o])
            return void this.outputFlows[o]._activateSignal(e);
        this.outputFlows[this.outputFlows.length - 1]._activateSignal(e);
      }, t.prototype.getClassName = function() {
        return "FGSwitchBlock";
      }, t.prototype.serialize = function(e) {
        n.prototype.serialize.call(this, e), e.cases = this.config.cases;
      }, t;
    }(po);
    j("FGSwitchBlock", TS);
    var ES = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.config = e, i.inFlows = [], i._cachedActivationState = [], i.reset = i._registerSignalInput("reset"), i;
      }
      return D(t, n), t.prototype.configure = function() {
        for (var e = 1; e < this.config.numberInputFlows; e++)
          this.inFlows.push(this._registerSignalInput("in".concat(e)));
      }, t.prototype._getCurrentActivationState = function(e) {
        var i = this._cachedActivationState;
        if (i.length = 0, e._hasExecutionVariable(this, "activationState")) {
          var r = e._getExecutionVariable(this, "activationState");
          for (o = 0; o < r.length; o++)
            i.push(r[o]);
        } else
          for (var o = 0; o < this.config.numberInputFlows; o++)
            i.push(!1);
        return i;
      }, t.prototype._execute = function(e, i) {
        var r = this._getCurrentActivationState(e);
        if (i === this.reset)
          for (var o = 0; o < this.config.numberInputFlows; o++)
            r[o] = !1;
        else if (i === this.onStart)
          r[0] = !0;
        else {
          var a = this.inFlows.indexOf(i);
          a >= 0 && (r[a + 1] = !0);
        }
        if (e._setExecutionVariable(this, "activationState", r.slice()), r.every(function(s) {
          return s;
        }))
          for (this.onDone._activateSignal(e), o = 0; o < this.config.numberInputFlows; o++)
            r[o] = !1;
      }, t.prototype.getClassName = function() {
        return "FGWaitAllBlock";
      }, t.prototype.serialize = function(e) {
        n.prototype.serialize.call(this, e), e.config.numberInputFlows = this.config.numberInputFlows;
      }, t;
    }(vr);
    j("FGWaitAllBlock", ES);
    var SS = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.count = i.registerDataOutput("count", Ae), i.reset = i._registerSignalInput("reset"), i;
      }
      return D(t, n), t.prototype._execute = function(e, i) {
        var r;
        if (i === this.reset)
          return e._setExecutionVariable(this, "count", 0), void this.count.setValue(0, e);
        var o = ((r = e._getExecutionVariable(this, "count")) !== null && r !== void 0 ? r : 0) + 1;
        e._setExecutionVariable(this, "count", o), this.count.setValue(o, e), this.onDone._activateSignal(e);
      }, t.prototype.getClassName = function() {
        return "FGCounterBlock";
      }, t;
    }(vr);
    j("FGCounterBlock", SS);
    var xS = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.config = e, i.condition = i.registerDataInput("condition", cn), i.loopBody = i._registerSignalOutput("loopBody"), i;
      }
      return D(t, n), t.prototype._execute = function(e, i) {
        var r, o = this.condition.getValue(e);
        for (((r = this.config) === null || r === void 0 ? void 0 : r.isDo) && !o && this.loopBody._activateSignal(e); o; )
          this.loopBody._activateSignal(e), o = this.condition.getValue(e);
        this.onDone._activateSignal(e);
      }, t.prototype.getClassName = function() {
        return "FGWhileLoopBlock";
      }, t.prototype.serialize = function(e) {
        var i;
        n.prototype.serialize.call(this, e), e.isDo = (i = this.config) === null || i === void 0 ? void 0 : i.isDo;
      }, t;
    }(vr);
    j("FGWhileLoopBlock", xS);
    var AS = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.count = i.registerDataInput("count", Ae), i.reset = i._registerSignalInput("reset"), i.currentCount = i.registerDataOutput("currentCount", Ae), i;
      }
      return D(t, n), t.prototype._execute = function(e, i) {
        if (i !== this.reset) {
          var r = this.count.getValue(e), o = e._getExecutionVariable(this, "debounceCount", 0) + 1;
          this.currentCount.setValue(o, e), e._setExecutionVariable(this, "debounceCount", o), o >= r && (this.onDone._activateSignal(e), e._setExecutionVariable(this, "debounceCount", 0));
        } else
          e._setExecutionVariable(this, "debounceCount", 0);
      }, t.prototype.getClassName = function() {
        return "FGDebounceBlock";
      }, t;
    }(vr);
    j("FGDebounceBlock", AS);
    var RS = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.onOn = i._registerSignalOutput("onOn"), i.onOff = i._registerSignalOutput("onOff"), i.isOn = i.registerDataOutput("isOn", cn), i;
      }
      return D(t, n), t.prototype._execute = function(e, i) {
        var r = e._getExecutionVariable(this, "value", !1);
        r = !r, e._setExecutionVariable(this, "value", r), this.isOn.setValue(r, e), r ? this.onOn._activateSignal(e) : this.onOff._activateSignal(e);
      }, t.prototype.getClassName = function() {
        return "FGFlipFlopBlock";
      }, t;
    }(po);
    j("FGFlipFlopBlock", RS);
    var CS = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.config = e, i.templateTargetComponent = new dS(e.targetPath, i), i.templateAnimationComponent = new dS(e.animationPath, i), i.speed = i.registerDataInput("speed", Ae), i.loop = i.registerDataInput("loop", cn), i.from = i.registerDataInput("from", Ae), i.to = i.registerDataInput("to", Ae), i.onAnimationEnd = i._registerSignalOutput("onAnimationEnd"), i.runningAnimatable = i.registerDataOutput("runningAnimatable", ln), i;
      }
      return D(t, n), t.prototype._preparePendingTasks = function(e) {
        var i, r = this, o = this.templateTargetComponent.getProperty(e), a = this.templateAnimationComponent.getProperty(e);
        if (!o || !a)
          throw new Error("Cannot play animation without target or animation");
        var s = (i = e._getExecutionVariable(this, "runningAnimatables")) !== null && i !== void 0 ? i : [], l = this.runningAnimatable.getValue(e);
        if (l && l.paused)
          l.restart();
        else {
          var c = e.configuration.scene.beginDirectAnimation(o, [a], this.from.getValue(e), this.to.getValue(e), this.loop.getValue(e), this.speed.getValue(e), function() {
            return r._onAnimationEnd(c, e);
          });
          this.runningAnimatable.setValue(c, e), s.push(c);
        }
        e._setExecutionVariable(this, "runningAnimatables", s);
      }, t.prototype._execute = function(e) {
        this._startPendingTasks(e), this.onDone._activateSignal(e);
      }, t.prototype._onAnimationEnd = function(e, i) {
        var r, o = (r = i._getExecutionVariable(this, "runningAnimatables")) !== null && r !== void 0 ? r : [], a = o.indexOf(e);
        a !== -1 && o.splice(a, 1), i._removePendingBlock(this), this.onAnimationEnd._activateSignal(i);
      }, t.prototype._cancelPendingTasks = function(e) {
        for (var i, r = 0, o = (i = e._getExecutionVariable(this, "runningAnimatables")) !== null && i !== void 0 ? i : []; r < o.length; r++)
          o[r].stop();
        e._deleteExecutionVariable(this, "runningAnimatables");
      }, t.prototype.getClassName = function() {
        return "FGPlayAnimationBlock";
      }, t.prototype.serialize = function(e) {
        e === void 0 && (e = {}), n.prototype.serialize.call(this, e), e.config.targetPath = this.config.targetPath.serialize(), e.config.animationPath = this.config.animationPath.serialize();
      }, t;
    }(lS);
    j("FGPlayAnimationBlock", CS);
    var PS = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.animationToStop = i.registerDataInput("animationToStop", ln), i;
      }
      return D(t, n), t.prototype._execute = function(e) {
        this.animationToStop.getValue(e).stop(), this.onDone._activateSignal(e);
      }, t.prototype.getClassName = function() {
        return "FGStopAnimationBlock";
      }, t;
    }(vr);
    j("FGStopAnimationBlock", PS);
    var IS = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.animationToPause = i.registerDataInput("animationToPause", ln), i;
      }
      return D(t, n), t.prototype._execute = function(e) {
        this.animationToPause.getValue(e).pause(), this.onDone._activateSignal(e);
      }, t.prototype.getClassName = function() {
        return "FGPauseAnimationBlock";
      }, t;
    }(vr);
    j("FGPauseAnimationBlock", IS);
    var MS = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.audio = i.registerDataInput("audio", ln), i;
      }
      return D(t, n), t.prototype._execute = function(e, i) {
        var r = this.audio.getValue(e);
        r instanceof _s && r.play(), this.onDone._activateSignal(e);
      }, t.prototype.getClassName = function() {
        return "FGPlayAudioBlock";
      }, t;
    }(vr);
    j("FGPlayAudioBlock", MS);
    var OS = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.audio = i.registerDataInput("audio", ln), i;
      }
      return D(t, n), t.prototype._execute = function(e, i) {
        var r = this.audio.getValue(e);
        r instanceof _s && r.stop();
      }, t.prototype.getClassName = function() {
        return "FGStopAudioBlock";
      }, t;
    }(vr);
    j("FGStopAudioBlock", OS);
    var DS = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.condition = i.registerDataInput("condition", cn), i.trueValue = i.registerDataInput("trueValue", ln), i.falseValue = i.registerDataInput("falseValue", ln), i.output = i.registerDataOutput("output", ln), i;
      }
      return D(t, n), t.prototype._updateOutputs = function(e) {
        this.output.setValue(this.condition.getValue(e) ? this.trueValue.getValue(e) : this.falseValue.getValue(e), e);
      }, t.prototype.getClassName = function() {
        return "FGConditionalDataBlock";
      }, t;
    }(bn);
    j("FGConditionalDataBlock", DS);
    var NS = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.variableName = i.registerDataInput("variableName", _u), i.output = i.registerDataOutput("output", ln), i;
      }
      return D(t, n), t.prototype._updateOutputs = function(e) {
        var i = this.variableName.getValue(e);
        e.hasVariable(i) && this.output.setValue(e.getVariable(i), e);
      }, t.prototype.getClassName = function() {
        return "FGGetVariableBlock";
      }, t;
    }(bn);
    j("FGGetVariableBlock", NS);
    var FS = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.sourceSystem = i.registerDataInput("sourceSystem", ln), i.destinationSystem = i.registerDataInput("destinationSystem", ln), i.inputCoordinates = i.registerDataInput("inputCoordinates", ii), i.outputCoordinates = i.registerDataOutput("outputCoordinates", ii), i;
      }
      return D(t, n), t.prototype._updateOutputs = function(e) {
        var i = this.sourceSystem.getValue(e), r = this.destinationSystem.getValue(e), o = this.inputCoordinates.getValue(e), a = i.getWorldMatrix(), s = r.getWorldMatrix(), l = F.Matrix[0].copyFrom(s);
        l.invert();
        var c = F.Matrix[1];
        l.multiplyToRef(a, c);
        var u = this.outputCoordinates.getValue(e);
        v.TransformCoordinatesToRef(o, c, u);
      }, t.prototype.getClassName = function() {
        return "FGCoordinateTransformBlock";
      }, t;
    }(bn);
    j("FGCoordinateTransformBlock", FS);
    var LS = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.config = e, i.output = i.registerDataOutput("output", aS(e.value)), i;
      }
      return D(t, n), t.prototype._updateOutputs = function(e) {
        this.output.setValue(this.config.value, e);
      }, t.prototype.getClassName = function() {
        return "FGConstantBlock";
      }, t;
    }(bn);
    j("FGConstantBlock", LS);
    var zI = "cachedOperationValue", WI = "cachedExecutionId", wS = function(n) {
      function t(e, i) {
        var r = n.call(this, i) || this;
        return r.output = r.registerDataOutput("output", e), r;
      }
      return D(t, n), t.prototype._updateOutputs = function(e) {
        var i = e._getExecutionVariable(this, WI), r = e._getExecutionVariable(this, zI);
        if (r !== void 0 && i === e.executionId)
          this.output.setValue(r, e);
        else {
          var o = this._doOperation(e);
          e._setExecutionVariable(this, zI, o), e._setExecutionVariable(this, WI, e.executionId), this.output.setValue(o, e);
        }
      }, t;
    }(bn), Mt = function(n) {
      function t(e, i, r, o, a, s) {
        var l = n.call(this, r, s) || this;
        return l._operation = o, l._className = a, l.leftInput = l.registerDataInput("leftInput", e), l.rightInput = l.registerDataInput("rightInput", i), l;
      }
      return D(t, n), t.prototype._doOperation = function(e) {
        return this._operation(this.leftInput.getValue(e), this.rightInput.getValue(e));
      }, t.prototype.getClassName = function() {
        return this._className;
      }, t;
    }(wS), Ci = function(n) {
      function t(e, i, r, o, a) {
        var s = n.call(this, i, a) || this;
        return s._operation = r, s._className = o, s.input = s.registerDataInput("input", e), s;
      }
      return D(t, n), t.prototype._doOperation = function(e) {
        return this._operation(this.input.getValue(e));
      }, t.prototype.getClassName = function() {
        return this._className;
      }, t;
    }(wS), lr = "FGBitwise", HI = "AndBlock", XI = "OrBlock", jI = "XorBlock", YI = "NotBlock", KI = "LeftShiftBlock", qI = "RightShiftBlock", QI = "CountLeadingZerosBlock", ZI = "CountTrailingZerosBlock", BS = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, Ae, function(i, r) {
          return i & r;
        }, "".concat(lr).concat(HI), e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j("".concat(lr).concat(HI), BS);
    var US = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, Ae, function(i, r) {
          return i | r;
        }, "".concat(lr).concat(XI), e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j("".concat(lr).concat(XI), US);
    var VS = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, Ae, function(i, r) {
          return i ^ r;
        }, "".concat(lr).concat(jI), e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j("".concat(lr).concat(jI), VS);
    var kS = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, function(i) {
          return ~i;
        }, "".concat(lr).concat(YI), e) || this;
      }
      return D(t, n), t;
    }(Ci);
    j("".concat(lr).concat(YI), kS);
    var GS = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, Ae, function(i, r) {
          return i << r;
        }, "".concat(lr).concat(KI), e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j("".concat(lr).concat(KI), GS);
    var zS = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, Ae, function(i, r) {
          return i >> r;
        }, "".concat(lr).concat(qI), e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j("".concat(lr).concat(qI), zS);
    var WS = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, function(i) {
          return Math.clz32(i);
        }, "".concat(lr).concat(QI), e) || this;
      }
      return D(t, n), t;
    }(Ci);
    j("".concat(lr).concat(QI), WS);
    var HS = function(n) {
      function t(e) {
        var i = n.call(this, Ae, Ae, function(r) {
          return i._ctrz(r);
        }, "".concat(lr).concat(ZI), e) || this;
        return i;
      }
      return D(t, n), t.prototype._ctrz = function(e) {
        return (e >>>= 0) == 0 ? 32 : (e &= -e, 31 - Math.clz32(e));
      }, t;
    }(Ci);
    j("".concat(lr).concat(ZI), HS);
    var gu = "FGLogic", JI = "AndBlock", $I = "OrBlock", eM = "NotBlock", XS = function(n) {
      function t(e) {
        return n.call(this, cn, cn, cn, function(i, r) {
          return i && r;
        }, "".concat(gu).concat(JI), e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j("".concat(gu).concat(JI), XS);
    var jS = function(n) {
      function t(e) {
        return n.call(this, cn, cn, cn, function(i, r) {
          return i || r;
        }, "".concat(gu).concat($I), e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j("".concat(gu).concat($I), jS);
    var YS = function(n) {
      function t(e) {
        return n.call(this, cn, cn, function(i) {
          return !i;
        }, "".concat(gu).concat(eM), e) || this;
      }
      return D(t, n), t;
    }(Ci);
    j("".concat(gu).concat(eM), YS);
    var tM = function(n) {
      function t(e, i, r, o) {
        var a = n.call(this, e, o) || this;
        return a._operation = i, a._className = r, a;
      }
      return D(t, n), t.prototype._doOperation = function(e) {
        return this._operation();
      }, t.prototype.getClassName = function() {
        return this._className;
      }, t;
    }(wS), iM = "FGAddNumberBlock", KS = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, Ae, function(i, r) {
          return i + r;
        }, iM, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(iM, KS);
    var nM = "FGSubtractNumberBlock", qS = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, Ae, function(i, r) {
          return i - r;
        }, nM, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(nM, qS);
    var rM = "FGMultiplyNumberBlock", QS = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, Ae, function(i, r) {
          return i * r;
        }, rM, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(rM, QS);
    var oM = "FGDivideNumberBlock", ZS = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, Ae, function(i, r) {
          return i / r;
        }, oM, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(oM, ZS);
    var aM = "FGModNumberBlock", JS = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, Ae, function(i, r) {
          return i % r;
        }, aM, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(aM, JS);
    var sM = "FGPowNumberBlock", $S = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, Ae, function(i, r) {
          return Math.pow(i, r);
        }, sM, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(sM, $S);
    var lM = "FGIsNaNNumberBlock", ex = function(n) {
      function t(e) {
        return n.call(this, Ae, cn, function(i) {
          return isNaN(i);
        }, lM, e) || this;
      }
      return D(t, n), t;
    }(Ci);
    j(lM, ex);
    var cM = "FGIsInfinityNumberBlock", tx = function(n) {
      function t(e) {
        return n.call(this, Ae, cn, function(i) {
          return !isFinite(i);
        }, cM, e) || this;
      }
      return D(t, n), t;
    }(Ci);
    j(cM, tx);
    var uM = "FGSqrtNumberBlock", ix = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, function(i) {
          return Math.sqrt(i);
        }, uM, e) || this;
      }
      return D(t, n), t;
    }(Ci);
    j(uM, ix);
    var hM = "FGAbsNumberBlock", nx = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, function(i) {
          return Math.abs(i);
        }, hM, e) || this;
      }
      return D(t, n), t;
    }(Ci);
    j(hM, nx);
    var dM = "FGNegateNumberBlock", rx = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, function(i) {
          return -i;
        }, dM, e) || this;
      }
      return D(t, n), t;
    }(Ci);
    j(dM, rx);
    var pM = "FGFloorNumberBlock", ox = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, function(i) {
          return Math.floor(i);
        }, pM, e) || this;
      }
      return D(t, n), t;
    }(Ci);
    j(pM, ox);
    var fM = "FGCeilNumberBlock", ax = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, function(i) {
          return Math.ceil(i);
        }, fM, e) || this;
      }
      return D(t, n), t;
    }(Ci);
    j(fM, ax);
    var _M = "FGRoundNumberBlock", sx = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, Ae, function(i, r) {
          return Math.round(i / Math.pow(10, r)) / Math.pow(10, r);
        }, _M, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(_M, sx);
    var mM = "FGTruncNumberBlock", lx = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, function(i) {
          return Math.trunc(i);
        }, mM, e) || this;
      }
      return D(t, n), t;
    }(Ci);
    j(mM, lx);
    var gM = "FGExpNumberBlock", cx = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, function(i) {
          return Math.exp(i);
        }, gM, e) || this;
      }
      return D(t, n), t;
    }(Ci);
    j(gM, cx);
    var vM = "FGLog10NumberBlock", ux = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, function(i) {
          return Math.log10(i);
        }, vM, e) || this;
      }
      return D(t, n), t;
    }(Ci);
    j(vM, ux);
    var yM = "FGLogNumberBlock", hx = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, function(i) {
          return Math.log(i);
        }, yM, e) || this;
      }
      return D(t, n), t;
    }(Ci);
    j(yM, hx);
    var bM = "FGLnNumberBlock", dx = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, function(i) {
          return Math.log(i) / Math.LN2;
        }, bM, e) || this;
      }
      return D(t, n), t;
    }(Ci);
    j(bM, dx);
    var TM = "FGSineNumberBlock", px = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, function(i) {
          return Math.sin(i);
        }, TM, e) || this;
      }
      return D(t, n), t;
    }(Ci);
    j(TM, px);
    var EM = "FGCosNumberBlock", fx = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, function(i) {
          return Math.cos(i);
        }, EM, e) || this;
      }
      return D(t, n), t;
    }(Ci);
    j(EM, fx);
    var SM = "FGTanNumberBlock", _x = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, function(i) {
          return Math.tan(i);
        }, SM, e) || this;
      }
      return D(t, n), t;
    }(Ci);
    j(SM, _x);
    var xM = "FGASineNumberBlock", mx = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, function(i) {
          return Math.asin(i);
        }, xM, e) || this;
      }
      return D(t, n), t;
    }(Ci);
    j(xM, mx);
    var AM = "FGACosNumberBlock", gx = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, function(i) {
          return Math.acos(i);
        }, AM, e) || this;
      }
      return D(t, n), t;
    }(Ci);
    j(AM, gx);
    var RM = "FGATanNumberBlock", vx = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, function(i) {
          return Math.atan(i);
        }, RM, e) || this;
      }
      return D(t, n), t;
    }(Ci);
    j(RM, vx);
    var CM = "FGENumberBlock", yx = function(n) {
      function t(e) {
        return n.call(this, Ae, function() {
          return Math.E;
        }, CM, e) || this;
      }
      return D(t, n), t;
    }(tM);
    j(CM, yx);
    var PM = "FGPiNumberBlock", bx = function(n) {
      function t(e) {
        return n.call(this, Ae, function() {
          return Math.PI;
        }, PM, e) || this;
      }
      return D(t, n), t;
    }(tM);
    j(PM, bx);
    var IM = "FGATan2NumberBlock", Tx = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, Ae, function(i, r) {
          return Math.atan2(i, r);
        }, IM, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(IM, Tx);
    var MM = "FGRandomNumberBlock", Ex = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, Ae, function(i, r) {
          return i + Math.random() * (r - i);
        }, MM, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(MM, Ex);
    var OM = "FGMinNumberBlock", Sx = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, Ae, function(i, r) {
          return Math.min(i, r);
        }, OM, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(OM, Sx);
    var DM = "FGMaxNumberBlock", xx = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, Ae, function(i, r) {
          return Math.max(i, r);
        }, DM, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(DM, xx);
    var NM = "FGEqualsNumberBlock", Ax = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, cn, function(i, r) {
          return i === r;
        }, NM, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(NM, Ax);
    var FM = "FGGreaterThanNumberBlock", Rx = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, cn, function(i, r) {
          return i > r;
        }, FM, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(FM, Rx);
    var LM = "FGGreaterThanOrEqualsNumberBlock", Cx = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, cn, function(i, r) {
          return i >= r;
        }, LM, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(LM, Cx);
    var wM = "FGLessThanNumberBlock", Px = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, cn, function(i, r) {
          return i < r;
        }, wM, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(wM, Px);
    var BM = "FGLessThanOrEqualsNumberBlock", Ix = function(n) {
      function t(e) {
        return n.call(this, Ae, Ae, cn, function(i, r) {
          return i <= r;
        }, BM, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(BM, Ix);
    var UM = "FGMixNumberBlock", Mx = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.leftInput = i.registerDataInput("leftInput", Ae), i.rightInput = i.registerDataInput("rightInput", Ae), i.alphaInput = i.registerDataInput("alphaInput", Ae), i.resultOutput = i.registerDataOutput("resultOutput", Ae), i;
      }
      return D(t, n), t.prototype._updateOutputs = function(e) {
        var i = this.leftInput.getValue(e), r = i + (this.rightInput.getValue(e) - i) * this.alphaInput.getValue(e);
        this.resultOutput.setValue(r, e);
      }, t.prototype.getClassName = function() {
        return UM;
      }, t;
    }(bn);
    j(UM, Mx);
    var VM = "FGAddVector2Block", Ox = function(n) {
      function t(e) {
        return n.call(this, $i, $i, $i, function(i, r) {
          return i.add(r);
        }, VM, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(VM, Ox);
    var kM = "FGSubtractVector2Block", Dx = function(n) {
      function t(e) {
        return n.call(this, $i, $i, $i, function(i, r) {
          return i.subtract(r);
        }, kM, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(kM, Dx);
    var GM = "FGMultiplyVector2Block", Nx = function(n) {
      function t(e) {
        return n.call(this, $i, $i, $i, function(i, r) {
          return i.multiply(r);
        }, GM, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(GM, Nx);
    var zM = "FGDivideVector2Block", Fx = function(n) {
      function t(e) {
        return n.call(this, $i, $i, $i, function(i, r) {
          return i.divide(r);
        }, zM, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(zM, Fx);
    var WM = "FGScaleVector2Block", Lx = function(n) {
      function t(e) {
        return n.call(this, $i, Ae, $i, function(i, r) {
          return i.scale(r);
        }, WM, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(WM, Lx);
    var HM = "FGLengthVector2Block", wx = function(n) {
      function t(e) {
        return n.call(this, $i, Ae, function(i) {
          return i.length();
        }, HM, e) || this;
      }
      return D(t, n), t;
    }(Ci);
    j(HM, wx);
    var XM = "FGNormalizeVector2Block", Bx = function(n) {
      function t(e) {
        return n.call(this, $i, $i, function(i) {
          var r = i.clone();
          return r.normalize(), r;
        }, XM, e) || this;
      }
      return D(t, n), t;
    }(Ci);
    j(XM, Bx);
    var Ux = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i._cachedVector = fe.Zero(), i.x = i.registerDataInput("x", Ae), i.y = i.registerDataInput("y", Ae), i.vector = i.registerDataOutput("vector", $i), i;
      }
      return D(t, n), t.prototype._updateOutputs = function(e) {
        this._cachedVector.x = this.x.getValue(e), this._cachedVector.y = this.y.getValue(e), this.vector.setValue(this._cachedVector, e);
      }, t;
    }(bn);
    j("FGCreateVector2Block", Ux);
    var Vx = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.vector = i.registerDataInput("vector", $i), i.x = i.registerDataOutput("x", Ae), i.y = i.registerDataOutput("y", Ae), i;
      }
      return D(t, n), t.prototype._updateOutputs = function(e) {
        var i = this.vector.getValue(e);
        this.x.setValue(i.x, e), this.y.setValue(i.y, e);
      }, t;
    }(bn);
    j("FGSplitVector2Block", Vx);
    var kx = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i._cachedVector = fe.Zero(), i.input = i.registerDataInput("input", $i), i.angle = i.registerDataInput("angle", Ae), i.output = i.registerDataOutput("output", $i), i;
      }
      return D(t, n), t.prototype._updateOutputs = function(e) {
        var i = this.input.getValue(e), r = this.angle.getValue(e);
        this._cachedVector.x = i.x * Math.cos(r) - i.y * Math.sin(r), this._cachedVector.y = i.x * Math.sin(r) + i.y * Math.cos(r), this.output.setValue(this._cachedVector, e);
      }, t;
    }(bn);
    j("FGRotate2dVector2Block", kx);
    var jM = "FGAddVector3Block", Gx = function(n) {
      function t(e) {
        return n.call(this, ii, ii, ii, function(i, r) {
          return i.add(r);
        }, jM, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(jM, Gx);
    var YM = "FGSubtractVector3Block", zx = function(n) {
      function t(e) {
        return n.call(this, ii, ii, ii, function(i, r) {
          return i.subtract(r);
        }, YM, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(YM, zx);
    var KM = "FGMultiplyVector3Block", Wx = function(n) {
      function t(e) {
        return n.call(this, ii, ii, ii, function(i, r) {
          return i.multiply(r);
        }, KM, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(KM, Wx);
    var qM = "FGDivideVector3Block", Hx = function(n) {
      function t(e) {
        return n.call(this, ii, ii, ii, function(i, r) {
          return i.divide(r);
        }, qM, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(qM, Hx);
    var QM = "FGScaleVector3Block", Xx = function(n) {
      function t(e) {
        return n.call(this, ii, Ae, ii, function(i, r) {
          return i.scale(r);
        }, QM, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(QM, Xx);
    var ZM = "FGLengthVector3Block", jx = function(n) {
      function t(e) {
        return n.call(this, ii, Ae, function(i) {
          return i.length();
        }, ZM, e) || this;
      }
      return D(t, n), t;
    }(Ci);
    j(ZM, jx);
    var JM = "FGNormalizeVector3Block", Yx = function(n) {
      function t(e) {
        return n.call(this, ii, ii, function(i) {
          return i.normalizeToNew();
        }, JM, e) || this;
      }
      return D(t, n), t;
    }(Ci);
    j(JM, Yx);
    var $M = "FGDotVector3Block", Kx = function(n) {
      function t(e) {
        return n.call(this, ii, ii, Ae, function(i, r) {
          return v.Dot(i, r);
        }, $M, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j($M, Kx);
    var eO = "FGCrossVector3Block", qx = function(n) {
      function t(e) {
        return n.call(this, ii, ii, ii, function(i, r) {
          return v.Cross(i, r);
        }, eO, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(eO, qx);
    var tO = "FGCreateVector3Block", Qx = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i._cachedVector = v.Zero(), i.x = i.registerDataInput("x", Ae), i.y = i.registerDataInput("y", Ae), i.z = i.registerDataInput("y", Ae), i.vector = i.registerDataOutput("vector", ii), i;
      }
      return D(t, n), t.prototype._updateOutputs = function(e) {
        this._cachedVector.x = this.x.getValue(e), this._cachedVector.y = this.y.getValue(e), this._cachedVector.z = this.z.getValue(e), this.vector.setValue(this._cachedVector, e);
      }, t.prototype.getClassName = function() {
        return tO;
      }, t;
    }(bn);
    j(tO, Qx);
    var iO = "FGSplitVector3Block", Zx = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.vector = i.registerDataInput("vector", ii), i.x = i.registerDataOutput("x", Ae), i.y = i.registerDataOutput("y", Ae), i.z = i.registerDataOutput("z", Ae), i;
      }
      return D(t, n), t.prototype._updateOutputs = function(e) {
        var i = this.vector.getValue(e);
        this.x.setValue(i.x, e), this.y.setValue(i.y, e), this.z.setValue(i.z, e);
      }, t.prototype.getClassName = function() {
        return iO;
      }, t;
    }(bn);
    j(iO, Zx);
    var nO = "FGRotateVector3Block", Jx = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i._cachedQuaternion = new oe(), i.input = i.registerDataInput("input", ii), i.angle = i.registerDataInput("angle", Ae), i.output = i.registerDataOutput("output", ii), i;
      }
      return D(t, n), t.prototype._updateOutputs = function(e) {
        var i = oe.RotationAxisToRef(this.axis.getValue(e), this.angle.getValue(e), this._cachedQuaternion), r = this.input.getValue(e), o = this.output.getValue(e);
        r.applyRotationQuaternionToRef(i, o);
      }, t.prototype.getClassName = function() {
        return nO;
      }, t;
    }(bn);
    j(nO, Jx);
    var rO = "FGTransformVector3Block", $x = function(n) {
      function t(e) {
        var i = n.call(this, Ri, ii, ii, function(r, o) {
          return v.TransformCoordinatesToRef(o, r, i._cachedResult);
        }, rO, e) || this;
        return i._cachedResult = v.Zero(), i;
      }
      return D(t, n), t;
    }(Mt);
    j(rO, $x);
    var oO = "FGAddVector4Block", eA = function(n) {
      function t(e) {
        return n.call(this, pn, pn, pn, function(i, r) {
          return i.add(r);
        }, oO, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(oO, eA);
    var aO = "FGSubtractVector4Block", tA = function(n) {
      function t(e) {
        return n.call(this, pn, pn, pn, function(i, r) {
          return i.subtract(r);
        }, aO, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(aO, tA);
    var sO = "FGMultiplyVector4Block", iA = function(n) {
      function t(e) {
        return n.call(this, pn, pn, pn, function(i, r) {
          return i.multiply(r);
        }, sO, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(sO, iA);
    var lO = "FGDivideVector4Block", nA = function(n) {
      function t(e) {
        return n.call(this, pn, pn, pn, function(i, r) {
          return i.divide(r);
        }, lO, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(lO, nA);
    var cO = "FGScaleVector4Block", rA = function(n) {
      function t(e) {
        return n.call(this, pn, Ae, pn, function(i, r) {
          return i.scale(r);
        }, cO, e) || this;
      }
      return D(t, n), t;
    }(Mt);
    j(cO, rA);
    var uO = "FGLengthVector4Block", oA = function(n) {
      function t(e) {
        return n.call(this, pn, Ae, function(i) {
          return i.length();
        }, uO, e) || this;
      }
      return D(t, n), t;
    }(Ci);
    j(uO, oA);
    var aA = "FGNormalizeVector4Block", sA = function(n) {
      function t(e) {
        return n.call(this, pn, pn, function(i) {
          var r = i.clone();
          return r.normalize(), r;
        }, aA, e) || this;
      }
      return D(t, n), t.prototype.getClassName = function() {
        return aA;
      }, t;
    }(Ci);
    j(aA, sA);
    var hO = "FGCreateVector4Block", lA = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i._cachedVector = lt.Zero(), i.x = i.registerDataInput("x", Ae), i.y = i.registerDataInput("y", Ae), i.z = i.registerDataInput("y", Ae), i.w = i.registerDataInput("w", Ae), i.vector = i.registerDataOutput("vector", pn), i;
      }
      return D(t, n), t.prototype._updateOutputs = function(e) {
        this._cachedVector.x = this.x.getValue(e), this._cachedVector.y = this.y.getValue(e), this._cachedVector.z = this.z.getValue(e), this._cachedVector.w = this.w.getValue(e), this.vector.setValue(this._cachedVector, e);
      }, t.prototype.getClassName = function() {
        return hO;
      }, t;
    }(bn);
    j(hO, lA);
    var dO = "FGSplitVector4Block", cA = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.vector = i.registerDataInput("vector", pn), i.x = i.registerDataOutput("x", Ae), i.y = i.registerDataOutput("y", Ae), i.z = i.registerDataOutput("z", Ae), i.w = i.registerDataOutput("w", Ae), i;
      }
      return D(t, n), t.prototype._updateOutputs = function(e) {
        var i = this.vector.getValue(e);
        this.x.setValue(i.x, e), this.y.setValue(i.y, e), this.z.setValue(i.z, e), this.w.setValue(i.w, e);
      }, t.prototype.getClassName = function() {
        return dO;
      }, t;
    }(bn);
    j(dO, cA);
    var pO = "FGAddMatrixBlock", uA = function(n) {
      function t(e) {
        var i = n.call(this, Ri, Ri, Ri, function(r, o) {
          return r.addToRef(o, i._cachedMatrix);
        }, pO, e) || this;
        return i._cachedMatrix = B.Zero(), i;
      }
      return D(t, n), t;
    }(Mt);
    j(pO, uA);
    var fO = "FGAddMatrixAndNumberBlock", hA = function(n) {
      function t(e) {
        var i = n.call(this, Ri, Ae, Ri, function(r, o) {
          for (var a = 0; a < r.m.length; a++)
            i._cachedArray[a] = r.m[a] + o;
          return B.FromArrayToRef(i._cachedArray, 0, i._cachedMatrix);
        }, fO, e) || this;
        return i._cachedArray = new Float32Array(16), i._cachedMatrix = B.Zero(), i;
      }
      return D(t, n), t;
    }(Mt);
    j(fO, hA);
    var _O = "FGSubtractMatrixBlock", dA = function(n) {
      function t(e) {
        var i = n.call(this, Ri, Ri, Ri, function(r, o) {
          return r.addToRef(o.scaleToRef(-1, F.Matrix[0]), i._cachedMatrix);
        }, _O, e) || this;
        return i._cachedMatrix = B.Zero(), i;
      }
      return D(t, n), t;
    }(Mt);
    j(_O, dA);
    var mO = "FGSubtractMatrixAndNumberBlock", pA = function(n) {
      function t(e) {
        var i = n.call(this, Ri, Ae, Ri, function(r, o) {
          for (var a = 0; a < r.m.length; a++)
            i._cachedArray[a] = r.m[a] - o;
          return B.FromArrayToRef(i._cachedArray, 0, i._cachedMatrix);
        }, mO, e) || this;
        return i._cachedArray = new Float32Array(16), i._cachedMatrix = B.Zero(), i;
      }
      return D(t, n), t;
    }(Mt);
    j(mO, pA);
    var gO = "FGMultiplyMatrixBlock", fA = function(n) {
      function t(e) {
        var i = n.call(this, Ri, Ri, Ri, function(r, o) {
          return r.multiplyToRef(o, i._cachedMatrix);
        }, gO, e) || this;
        return i._cachedMatrix = B.Zero(), i;
      }
      return D(t, n), t;
    }(Mt);
    j(gO, fA);
    var vO = "FGDivideMatrixBlock", _A = function(n) {
      function t(e) {
        var i = n.call(this, Ri, Ri, Ri, function(r, o) {
          return r.multiplyToRef(o.invertToRef(F.Matrix[0]), i._cachedResultMatrix);
        }, vO, e) || this;
        return i._cachedResultMatrix = B.Zero(), i;
      }
      return D(t, n), t;
    }(Mt);
    j(vO, _A);
    var yO = "FGDivideMatrixAndNumberBlock", mA = function(n) {
      function t(e) {
        var i = n.call(this, Ri, Ae, Ri, function(r, o) {
          for (var a = 0; a < r.m.length; a++)
            i._cachedArray[a] = r.m[a] / o;
          return B.FromArrayToRef(i._cachedArray, 0, i._cachedMatrix);
        }, yO, e) || this;
        return i._cachedArray = new Float32Array(16), i._cachedMatrix = B.Zero(), i;
      }
      return D(t, n), t;
    }(Mt);
    j(yO, mA);
    var bO = "FGScaleMatrixBlock", gA = function(n) {
      function t(e) {
        var i = n.call(this, Ri, Ae, Ri, function(r, o) {
          return r.scaleToRef(o, i._cachedMatrix);
        }, bO, e) || this;
        return i._cachedMatrix = B.Zero(), i;
      }
      return D(t, n), t;
    }(Mt);
    j(bO, gA);
    var TO = "FGClampMatrixBlock", vA = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i._cachedArray = new Float32Array(16), i._cachedMatrix = B.Identity(), i.input = i.registerDataInput("input", Ri), i.min = i.registerDataInput("min", Ae), i.max = i.registerDataInput("max", Ae), i.output = i.registerDataOutput("output", Ri), i;
      }
      return D(t, n), t.prototype._updateOutputs = function(e) {
        for (var i = this.input.getValue(e), r = this.min.getValue(e), o = this.max.getValue(e), a = 0; a < i.m.length; a++)
          this._cachedArray[a] = Math.min(Math.max(i.m[a], r), o);
        B.FromArrayToRef(this._cachedArray, 0, this._cachedMatrix), this.output.setValue(this._cachedMatrix, e);
      }, t.prototype.getClassName = function() {
        return TO;
      }, t;
    }(bn);
    j(TO, vA);
    var EO = "FGDecomposeMatrixBlock", yA = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i._cachedTranslation = new v(), i._cachedRotation = new oe(), i._cachedScale = new v(), i.input = i.registerDataInput("input", Ri), i.translation = i.registerDataOutput("translation", ii), i.rotation = i.registerDataOutput("rotation", mu), i.scale = i.registerDataOutput("scale", ii), i;
      }
      return D(t, n), t.prototype._updateOutputs = function(e) {
        this.input.getValue(e).decompose(this._cachedScale, this._cachedRotation, this._cachedTranslation), this.translation.setValue(this._cachedTranslation, e), this.rotation.setValue(this._cachedRotation, e), this.scale.setValue(this._cachedScale, e);
      }, t.prototype.getClassName = function() {
        return EO;
      }, t;
    }(bn);
    j(EO, yA);
    var SO = "FGComposeMatrixBlock", bA = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i._cachedMatrix = new B(), i.output = i.registerDataOutput("input", Ri), i.translation = i.registerDataInput("translation", ii), i.rotation = i.registerDataInput("rotation", mu), i.scale = i.registerDataInput("scale", ii), i;
      }
      return D(t, n), t.prototype._updateOutputs = function(e) {
        var i = this.translation.getValue(e), r = this.rotation.getValue(e), o = this.scale.getValue(e);
        B.ComposeToRef(o, r, i, this._cachedMatrix), this.output.setValue(this._cachedMatrix, e);
      }, t.prototype.getClassName = function() {
        return SO;
      }, t;
    }(bn);
    j(SO, bA);
    var xO = "FGQuaternionToRotationMatrixBlock", TA = function(n) {
      function t(e) {
        var i = n.call(this, mu, Ri, function(r) {
          return B.FromQuaternionToRef(r, i._cachedMatrix);
        }, xO, e) || this;
        return i._cachedMatrix = new B(), i;
      }
      return D(t, n), t;
    }(Ci);
    j(xO, TA);
    var AO = "FGGetTransformationMatrixBlock", EA = function(n) {
      function t(e) {
        var i = n.call(this, ln, ln, Ri, function(r, o) {
          var a = r.getWorldMatrix();
          return o.getWorldMatrix().invertToRef(F.Matrix[0]).multiplyToRef(a, i._cachedResult);
        }, AO, e) || this;
        return i._cachedResult = B.Zero(), i;
      }
      return D(t, n), t;
    }(Mt);
    j(AO, EA);
    var SA = function(n) {
      function t(e) {
        var i = this;
        return e.path.hasTemplateStrings && de.Warn("Template strings are not supported in the path of mesh pick event blocks."), (i = n.call(this, e) || this).config = e, i;
      }
      return D(t, n), t.prototype._preparePendingTasks = function(e) {
        var i = this, r = e._getExecutionVariable(this, "meshPickObserver");
        if (!r) {
          var o = this.config.path.getProperty(e);
          if (!(o && o instanceof Dt))
            throw new Error("Mesh pick event block requires a valid mesh");
          e._setExecutionVariable(this, "mesh", o), r = o.getScene().onPointerObservable.add(function(s) {
            var l;
            s.type === Le.POINTERPICK && ((l = s.pickInfo) === null || l === void 0 ? void 0 : l.pickedMesh) === o && i._execute(e);
          });
          var a = o.onDisposeObservable.add(function() {
            return i._onDispose;
          });
          e._setExecutionVariable(this, "meshPickObserver", r), e._setExecutionVariable(this, "meshDisposeObserver", a);
        }
      }, t.prototype._onDispose = function(e) {
        this._cancelPendingTasks(e), e._removePendingBlock(this);
      }, t.prototype._cancelPendingTasks = function(e) {
        var i = e._getExecutionVariable(this, "mesh"), r = e._getExecutionVariable(this, "meshPickObserver"), o = e._getExecutionVariable(this, "meshDisposeObserver");
        i.getScene().onPointerObservable.remove(r), i.onDisposeObservable.remove(o), e._deleteExecutionVariable(this, "mesh"), e._deleteExecutionVariable(this, "meshPickObserver"), e._deleteExecutionVariable(this, "meshDisposeObserver");
      }, t.prototype.getClassName = function() {
        return "FGMeshPickEventBlock";
      }, t.prototype.serialize = function(e) {
        n.prototype.serialize.call(this, e), e.config.path = this.config.path.serialize();
      }, t;
    }(Ll);
    j("FGMeshPickEventBlock", SA);
    var xA = function(n) {
      function t() {
        return n !== null && n.apply(this, arguments) || this;
      }
      return D(t, n), t.prototype._preparePendingTasks = function(e) {
        var i = this;
        if (!e._getExecutionVariable(this, "sceneReadyObserver")) {
          var r = e.configuration.scene.onReadyObservable.add(function() {
            i._execute(e);
          });
          e._setExecutionVariable(this, "sceneReadyObserver", r);
        }
      }, t.prototype._cancelPendingTasks = function(e) {
        var i = e._getExecutionVariable(this, "sceneReadyObserver");
        e.configuration.scene.onReadyObservable.remove(i), e._deleteExecutionVariable(this, "sceneReadyObserver");
      }, t.prototype.getClassName = function() {
        return "FGSceneReadyEventBlock";
      }, t;
    }(Ll);
    j("FGSceneReadyEventBlock", xA);
    var AA = function(n) {
      function t(e) {
        var i = n.call(this, e) || this;
        return i.config = e, i.eventData = i.registerDataOutput("eventData", ln), i;
      }
      return D(t, n), t.prototype._preparePendingTasks = function(e) {
        var i = this, r = e.configuration.coordinator.getCustomEventObservable(this.config.eventId);
        this._eventObserver = r.add(function(o) {
          i.eventData.setValue(o, e), i._execute(e);
        });
      }, t.prototype._cancelPendingTasks = function(e) {
        var i = e.configuration.coordinator.getCustomEventObservable(this.config.eventId);
        i ? i.remove(this._eventObserver) : de.Warn("FlowGraphReceiveCustomEventBlock: Missing observable for event ".concat(this.config.eventId));
      }, t.prototype.getClassName = function() {
        return "FGReceiveCustomEventBlock";
      }, t.prototype.serialize = function(e) {
        n.prototype.serialize.call(this, e), e.eventId = this.config.eventId;
      }, t;
    }(Ll);
    j("FGReceiveCustomEventBlock", AA);
    var RA = function(n) {
      function t() {
        return n !== null && n.apply(this, arguments) || this;
      }
      return D(t, n), t.prototype._preparePendingTasks = function(e) {
        var i = this;
        if (!e._getExecutionVariable(this, "sceneBeforeRender")) {
          var r = e.configuration.scene.onBeforeRenderObservable.add(function() {
            i._execute(e);
          });
          e._setExecutionVariable(this, "sceneBeforeRender", r);
        }
      }, t.prototype._cancelPendingTasks = function(e) {
        var i = e._getExecutionVariable(this, "sceneBeforeRender");
        e.configuration.scene.onBeforeRenderObservable.remove(i), e._deleteExecutionVariable(this, "sceneBeforeRender");
      }, t.prototype.getClassName = function() {
        return "FGSceneTickEventBlock";
      }, t;
    }(Ll);
    j("FGSceneTickEventBlock", RA);
    var Cm = G.g !== void 0 ? G.g : typeof window < "u" ? window : void 0;
    if (Cm !== void 0) {
      Cm.BABYLON = Cm.BABYLON || {};
      var wl = Cm.BABYLON;
      if (!wl.Debug)
        for (var Bl in wl.Debug = wl.Debug || {}, ce)
          wl.Debug[Bl] || (wl.Debug[Bl] = ce[Bl]);
      for (var Bl in le)
        wl[Bl] || (wl[Bl] = le[Bl]);
    }
    var JN = { AxesViewer: yl, BoneAxesViewer: yf, PhysicsViewer: Lf, SkeletonViewer: wf };
    const $N = be;
    return $.default;
  })());
})(h1);
var GL = h1.exports;
const Un = /* @__PURE__ */ kL(GL);
function zL(Z) {
  var k = Math.PI;
  return Z * (k / 180);
}
const WL = async function(Z, k, G) {
  const $ = new Un.Engine(Z, !0, { preserveDrawingBuffer: !0, stencil: !0 });
  $._caps.textureFloatRender = !0;
  const ce = new Un.Scene($), le = new Un.FreeCamera(
    "camera1",
    new Un.Vector3(0, 5, -10),
    ce
  );
  le.fov = zL(30), le.maxZ = 50, le.position.y += -1, le.position.z += -3, le.setTarget(Un.Vector3.Zero()), le.attachControl(Z, !0);
  const be = new Un.HemisphericLight(
    "light",
    new Un.Vector3(0, 1, 0),
    ce
  );
  be.intensity = 0.7, Un.MeshBuilder.CreateGround(
    "ground",
    { width: 500, height: 500 },
    ce
  ), Bm(ce);
  const pe = Bm(ce);
  pe.position.z += 100, pe.scaling.x = 500, pe.scaling.y = 500;
  const _ = Bm(ce);
  _.position.z += 30, _.scaling.x = 500, _.scaling.y = 500;
  var Ee = ce.enableDepthRenderer(le, !1), Xe = !1;
  Un.Effect.ShadersStore.depthbufferPixelShader = `#ifdef GL_ES
precision highp float;
#endif

varying vec2 vUV;
uniform sampler2D textureSampler;

void main(void)
{
vec4 depth = texture2D(textureSampler, vUV);
gl_FragColor = vec4(1.0 - depth.r, 1.0 - depth.r, 1.0 - depth.r, 1.0);
}`;
  var yt = new Un.PostProcess("depth_display", "depthbuffer", null, null, 1, null, null, $, !0);
  yt.onApply = function(ct) {
    ct._bindTexture("textureSampler", Ee.getDepthMap().getInternalTexture());
  }, Z.addEventListener("render", function(ct) {
    Un.Tools.CreateScreenshot($, le, { precision: 1 }, k);
  }), Z.addEventListener("rendermodetoggle", function(ct) {
    Xe = !Xe, Xe ? le.attachPostProcess(yt) : le.detachPostProcess(yt);
  }), ce.onPointerDown = function() {
    var ct = ce.createPickingRay(ce.pointerX, ce.pointerY, Un.Matrix.Identity(), le), Ht = ce.pickWithRay(ct);
    Ht.pickedMesh && (G == null || G(Ht.pickedMesh));
  };
  const H = 0.1, ue = new Un.DeviceSourceManager(ce.getEngine());
  return ue.onDeviceConnectedObservable.add((ct) => {
    if (ct.deviceType === Un.DeviceType.Keyboard) {
      const Ht = ue.getDeviceSource(Un.DeviceType.Keyboard);
      ce.beforeRender = () => {
        const gt = Ht.getInput(87), Ge = Ht.getInput(65), pt = Ht.getInput(83), Ve = Ht.getInput(68);
        var ot = le.getTarget().subtract(le.position).normalize(), ft = Un.Vector3.Cross(ot, le.upVector).normalize();
        gt === 1 && (le.position.x += H * ot.x, le.position.y += H * ot.y, le.position.z += H * ot.z), pt === 1 && (le.position.x -= H * ot.x, le.position.y -= H * ot.y, le.position.z -= H * ot.z), Ge === 1 && (le.position.x += H * ft.x, le.position.y += H * ft.y, le.position.z += H * ft.z), Ve === 1 && (le.position.x -= H * ft.x, le.position.y -= H * ft.y, le.position.z -= H * ft.z);
      };
    }
  }), $.runRenderLoop(function() {
    ce.render();
  }), window.addEventListener("resize", function() {
    $.resize();
  }), { scene: ce, camera: le, engine: $ };
};
function Bm(Z) {
  const k = [];
  for (let $ = 0; $ < 6; $++)
    k.push(new Un.Color3(Math.random(), Math.random(), Math.random()));
  return Un.MeshBuilder.CreateBox("box", { size: 1, faceColors: k }, Z);
}
function HL(Z) {
  return Z.clone();
}
const {
  SvelteComponent: XL,
  append: Ws,
  attr: Vl,
  bubble: jL,
  detach: FA,
  element: Su,
  init: YL,
  insert: LA,
  listen: Xs,
  noop: ZO,
  run_all: wA,
  safe_not_equal: KL,
  set_data: d1,
  set_input_value: JO,
  space: OA,
  stop_propagation: qL,
  text: p1,
  to_number: f1
} = window.__gradio__svelte__internal, { createEventDispatcher: QL } = window.__gradio__svelte__internal;
function ZL(Z) {
  let k, G = (
    /*value*/
    Z[0].toPrecision(2) + ""
  ), $, ce, le;
  return {
    c() {
      k = Su("div"), $ = p1(G), Vl(k, "class", "value svelte-13dvw3z");
    },
    m(be, pe) {
      LA(be, k, pe), Ws(k, $), ce || (le = [
        Xs(
          k,
          "pointerdown",
          /*handleMouseDown*/
          Z[4]
        ),
        Xs(
          k,
          "dblclick",
          /*handleDoubleClick*/
          Z[5]
        ),
        Xs(k, "click", qL(
          /*click_handler*/
          Z[9]
        ))
      ], ce = !0);
    },
    p(be, pe) {
      pe & /*value*/
      1 && G !== (G = /*value*/
      be[0].toPrecision(2) + "") && d1($, G);
    },
    d(be) {
      be && FA(k), ce = !1, wA(le);
    }
  };
}
function JL(Z) {
  let k, G, $;
  return {
    c() {
      k = Su("input"), Vl(k, "class", "value svelte-13dvw3z"), Vl(k, "type", "number");
    },
    m(ce, le) {
      LA(ce, k, le), JO(
        k,
        /*value*/
        Z[0]
      ), G || ($ = [
        Xs(
          k,
          "input",
          /*input_input_handler*/
          Z[10]
        ),
        Xs(
          k,
          "blur",
          /*toggleEdit*/
          Z[3]
        ),
        Xs(
          k,
          "keydown",
          /*keydown_handler*/
          Z[11]
        )
      ], G = !0);
    },
    p(ce, le) {
      le & /*value*/
      1 && f1(k.value) !== /*value*/
      ce[0] && JO(
        k,
        /*value*/
        ce[0]
      );
    },
    d(ce) {
      ce && FA(k), G = !1, wA($);
    }
  };
}
function $L(Z) {
  let k, G, $, ce, le, be, pe, _, Ee, Xe;
  function yt(ct, Ht) {
    return (
      /*editable*/
      ct[2] ? JL : ZL
    );
  }
  let H = yt(Z), ue = H(Z);
  return {
    c() {
      k = Su("div"), G = Su("span"), $ = p1(
        /*label*/
        Z[1]
      ), ce = OA(), le = Su("button"), le.textContent = "-", be = OA(), ue.c(), pe = OA(), _ = Su("button"), _.textContent = "+", Vl(G, "class", "label svelte-13dvw3z"), Vl(le, "class", "svelte-13dvw3z"), Vl(_, "class", "svelte-13dvw3z"), Vl(k, "class", "container svelte-13dvw3z");
    },
    m(ct, Ht) {
      LA(ct, k, Ht), Ws(k, G), Ws(G, $), Ws(k, ce), Ws(k, le), Ws(k, be), ue.m(k, null), Ws(k, pe), Ws(k, _), Ee || (Xe = [
        Xs(
          le,
          "click",
          /*decrement*/
          Z[7]
        ),
        Xs(
          _,
          "click",
          /*increment*/
          Z[6]
        )
      ], Ee = !0);
    },
    p(ct, [Ht]) {
      Ht & /*label*/
      2 && d1(
        $,
        /*label*/
        ct[1]
      ), H === (H = yt(ct)) && ue ? ue.p(ct, Ht) : (ue.d(1), ue = H(ct), ue && (ue.c(), ue.m(k, pe)));
    },
    i: ZO,
    o: ZO,
    d(ct) {
      ct && FA(k), ue.d(), Ee = !1, wA(Xe);
    }
  };
}
function ew(Z, k, G) {
  const $ = QL();
  let { label: ce = "" } = k, { value: le = 0 } = k, { scalingFactor: be = 2 } = k, pe = !1;
  function _() {
    $("change", { value: le });
  }
  function Ee() {
    G(2, pe = !pe), pe || _();
  }
  let Xe;
  function yt(ot) {
    Xe = ot.clientX, ot.target.addEventListener("mousemove", H), ot.target.addEventListener("mouseup", ue), ot.target.setPointerCapture(ot.pointerId);
  }
  function H(ot) {
    const ft = window.innerWidth, j = (ot.clientX - Xe) / ft;
    G(0, le += Math.sign(j) * be), Xe = ot.clientX, _();
  }
  function ue(ot) {
    ot.target.removeEventListener("mousemove", H), ot.target.removeEventListener("mouseup", ue);
  }
  function ct() {
    Ee();
  }
  function Ht() {
    G(0, le += 1), _();
  }
  function gt() {
    G(0, le -= 1), _();
  }
  function Ge(ot) {
    jL.call(this, Z, ot);
  }
  function pt() {
    le = f1(this.value), G(0, le);
  }
  const Ve = (ot) => {
    ot.key === "Enter" && Ee();
  };
  return Z.$$set = (ot) => {
    "label" in ot && G(1, ce = ot.label), "value" in ot && G(0, le = ot.value), "scalingFactor" in ot && G(8, be = ot.scalingFactor);
  }, [
    le,
    ce,
    pe,
    Ee,
    yt,
    ct,
    Ht,
    gt,
    be,
    Ge,
    pt,
    Ve
  ];
}
class Qo extends XL {
  constructor(k) {
    super(), YL(this, k, ew, $L, KL, { label: 1, value: 0, scalingFactor: 8 });
  }
}
const {
  SvelteComponent: tw,
  append: Qt,
  assign: iw,
  attr: Tn,
  binding_callbacks: nw,
  check_outros: $O,
  create_component: Dr,
  destroy_component: Nr,
  detach: Um,
  element: On,
  flush: Zo,
  get_spread_object: rw,
  get_spread_update: ow,
  group_outros: e1,
  init: aw,
  insert: Vm,
  listen: jd,
  mount_component: Fr,
  run_all: sw,
  safe_not_equal: lw,
  set_data: cw,
  space: fn,
  text: uw,
  transition_in: Dn,
  transition_out: Xn
} = window.__gradio__svelte__internal, { tick: hw } = window.__gradio__svelte__internal, { onMount: dw } = window.__gradio__svelte__internal;
function t1(Z) {
  let k, G;
  const $ = [
    { autoscroll: (
      /*gradio*/
      Z[0].autoscroll
    ) },
    { i18n: (
      /*gradio*/
      Z[0].i18n
    ) },
    /*loading_status*/
    Z[8]
  ];
  let ce = {};
  for (let le = 0; le < $.length; le += 1)
    ce = iw(ce, $[le]);
  return k = new VL({ props: ce }), {
    c() {
      Dr(k.$$.fragment);
    },
    m(le, be) {
      Fr(k, le, be), G = !0;
    },
    p(le, be) {
      const pe = be[0] & /*gradio, loading_status*/
      257 ? ow($, [
        be[0] & /*gradio*/
        1 && { autoscroll: (
          /*gradio*/
          le[0].autoscroll
        ) },
        be[0] & /*gradio*/
        1 && { i18n: (
          /*gradio*/
          le[0].i18n
        ) },
        be[0] & /*loading_status*/
        256 && rw(
          /*loading_status*/
          le[8]
        )
      ]) : {};
      k.$set(pe);
    },
    i(le) {
      G || (Dn(k.$$.fragment, le), G = !0);
    },
    o(le) {
      Xn(k.$$.fragment, le), G = !1;
    },
    d(le) {
      Nr(k, le);
    }
  };
}
function i1(Z) {
  let k, G;
  return k = new JF({
    props: {
      $$slots: { default: [pw] },
      $$scope: { ctx: Z }
    }
  }), {
    c() {
      Dr(k.$$.fragment);
    },
    m($, ce) {
      Fr(k, $, ce), G = !0;
    },
    p($, ce) {
      const le = {};
      ce[0] & /*label*/
      2 | ce[1] & /*$$scope*/
      4096 && (le.$$scope = { dirty: ce, ctx: $ }), k.$set(le);
    },
    i($) {
      G || (Dn(k.$$.fragment, $), G = !0);
    },
    o($) {
      Xn(k.$$.fragment, $), G = !1;
    },
    d($) {
      Nr(k, $);
    }
  };
}
function pw(Z) {
  let k;
  return {
    c() {
      k = uw(
        /*label*/
        Z[1]
      );
    },
    m(G, $) {
      Vm(G, k, $);
    },
    p(G, $) {
      $[0] & /*label*/
      2 && cw(
        k,
        /*label*/
        G[1]
      );
    },
    d(G) {
      G && Um(k);
    }
  };
}
function fw(Z) {
  var Gl, zl, Wl, Ks, Hl, Xl, qs, Pu, Ui, Qs, jl;
  let k, G, $, ce, le, be, pe, _, Ee, Xe, yt, H, ue, ct, Ht, gt, Ge, pt, Ve, ot, ft, j, Kt, Ti, Me, Zt, fe, v, lt, oe, B, ze, F, ur, En, br, Nn, Lr, ne, Ie, Ot, wt, mi, Tr, D, je, x, Ft, Bt, js, Jn, Ys, Qr, as, q, kl, hn = (
    /*loading_status*/
    Z[8] && t1(Z)
  ), dn = (
    /*show_label*/
    Z[5] && i1(Z)
  );
  return Ti = new Qo({
    props: {
      label: "Rx",
      value: (
        /*unscaledR*/
        Z[16](
          /*selectedMesh*/
          (Gl = Z[12]) == null ? void 0 : Gl.rotation.x
        )
      )
    }
  }), Ti.$on(
    "change",
    /*change_handler*/
    Z[27]
  ), Zt = new Qo({
    props: {
      label: "Ry",
      value: (
        /*unscaledR*/
        Z[16](
          /*selectedMesh*/
          (zl = Z[12]) == null ? void 0 : zl.rotation.y
        )
      )
    }
  }), Zt.$on(
    "change",
    /*change_handler_1*/
    Z[28]
  ), v = new Qo({
    props: {
      label: "Rz",
      value: (
        /*unscaledR*/
        Z[16](
          /*selectedMesh*/
          (Wl = Z[12]) == null ? void 0 : Wl.rotation.z
        )
      )
    }
  }), v.$on(
    "change",
    /*change_handler_2*/
    Z[29]
  ), F = new Qo({
    props: {
      label: "Tx",
      scalingFactor: 1,
      value: (
        /*unscaledT*/
        Z[18](
          /*selectedMesh*/
          (Ks = Z[12]) == null ? void 0 : Ks.position.x
        )
      )
    }
  }), F.$on(
    "change",
    /*change_handler_3*/
    Z[30]
  ), En = new Qo({
    props: {
      label: "Ty",
      scalingFactor: 1,
      value: (
        /*unscaledT*/
        Z[18](
          /*selectedMesh*/
          (Hl = Z[12]) == null ? void 0 : Hl.position.y
        )
      )
    }
  }), En.$on(
    "change",
    /*change_handler_4*/
    Z[31]
  ), Nn = new Qo({
    props: {
      label: "Tz",
      scalingFactor: 1,
      value: (
        /*unscaledT*/
        Z[18](
          /*selectedMesh*/
          (Xl = Z[12]) == null ? void 0 : Xl.position.z
        )
      )
    }
  }), Nn.$on(
    "change",
    /*change_handler_5*/
    Z[32]
  ), wt = new Qo({
    props: {
      label: "Sx",
      value: (
        /*unscaledS*/
        Z[20](
          /*selectedMesh*/
          (qs = Z[12]) == null ? void 0 : qs.scaling.x
        )
      )
    }
  }), wt.$on(
    "change",
    /*change_handler_6*/
    Z[33]
  ), Tr = new Qo({
    props: {
      label: "Sy",
      value: (
        /*unscaledS*/
        Z[20](
          /*selectedMesh*/
          (Pu = Z[12]) == null ? void 0 : Pu.scaling.y
        )
      )
    }
  }), Tr.$on(
    "change",
    /*change_handler_7*/
    Z[34]
  ), je = new Qo({
    props: {
      label: "Sz",
      value: (
        /*unscaledS*/
        Z[20](
          /*selectedMesh*/
          (Ui = Z[12]) == null ? void 0 : Ui.scaling.z
        )
      )
    }
  }), je.$on(
    "change",
    /*change_handler_8*/
    Z[35]
  ), Jn = new Qo({
    props: {
      label: "FoV",
      value: (
        /*unscaledR*/
        Z[16](
          /*camera*/
          (Qs = Z[11]) == null ? void 0 : Qs.fov
        )
      )
    }
  }), Jn.$on(
    "change",
    /*change_handler_9*/
    Z[36]
  ), Qr = new Qo({
    props: {
      label: "Z",
      value: (
        /*unscaledT*/
        Z[18](
          /*camera*/
          (jl = Z[11]) == null ? void 0 : jl.maxZ
        )
      )
    }
  }), Qr.$on(
    "change",
    /*change_handler_10*/
    Z[37]
  ), {
    c() {
      hn && hn.c(), k = fn(), dn && dn.c(), G = fn(), $ = On("div"), ce = On("div"), le = On("canvas"), be = fn(), pe = On("div"), _ = On("div"), Ee = On("button"), Ee.textContent = "Render", Xe = fn(), yt = On("button"), yt.textContent = "Toggle Mode", H = fn(), ue = On("div"), ct = On("button"), ct.textContent = "Add Box", Ht = fn(), gt = On("button"), gt.textContent = "Delete", Ge = fn(), pt = On("button"), pt.textContent = "Duplicate", Ve = fn(), ot = On("div"), ft = On("div"), j = On("div"), j.textContent = "Rotation", Kt = fn(), Dr(Ti.$$.fragment), Me = fn(), Dr(Zt.$$.fragment), fe = fn(), Dr(v.$$.fragment), lt = fn(), oe = On("div"), B = On("div"), B.textContent = "Translation", ze = fn(), Dr(F.$$.fragment), ur = fn(), Dr(En.$$.fragment), br = fn(), Dr(Nn.$$.fragment), Lr = fn(), ne = On("div"), Ie = On("div"), Ie.textContent = "Scale", Ot = fn(), Dr(wt.$$.fragment), mi = fn(), Dr(Tr.$$.fragment), D = fn(), Dr(je.$$.fragment), x = fn(), Ft = On("div"), Bt = On("div"), Bt.textContent = "Camera", js = fn(), Dr(Jn.$$.fragment), Ys = fn(), Dr(Qr.$$.fragment), Tn(le, "class", "svelte-5v5x1w"), Tn(ce, "class", "canvas-section svelte-5v5x1w"), Tn(ce, "id", "canvas"), Tn(Ee, "class", "svelte-5v5x1w"), Tn(yt, "class", "svelte-5v5x1w"), Tn(_, "class", "render-controls svelte-5v5x1w"), Tn(ct, "class", "svelte-5v5x1w"), Tn(gt, "class", "svelte-5v5x1w"), Tn(pt, "class", "svelte-5v5x1w"), Tn(ue, "class", "mesh-controls svelte-5v5x1w"), Tn(j, "class", "group-title svelte-5v5x1w"), Tn(ft, "class", "control-group rotation svelte-5v5x1w"), Tn(B, "class", "group-title svelte-5v5x1w"), Tn(oe, "class", "control-group translation svelte-5v5x1w"), Tn(Ie, "class", "group-title svelte-5v5x1w"), Tn(ne, "class", "control-group scale svelte-5v5x1w"), Tn(Bt, "class", "group-title svelte-5v5x1w"), Tn(Ft, "class", "control-group camera svelte-5v5x1w"), Tn(ot, "class", "transform-controls"), Tn(pe, "class", "controls-section svelte-5v5x1w"), Tn($, "class", "app-container svelte-5v5x1w");
    },
    m(mt, Vi) {
      hn && hn.m(mt, Vi), Vm(mt, k, Vi), dn && dn.m(mt, Vi), Vm(mt, G, Vi), Vm(mt, $, Vi), Qt($, ce), Qt(ce, le), Z[23](le), Qt($, be), Qt($, pe), Qt(pe, _), Qt(_, Ee), Qt(_, Xe), Qt(_, yt), Qt(pe, H), Qt(pe, ue), Qt(ue, ct), Qt(ue, Ht), Qt(ue, gt), Qt(ue, Ge), Qt(ue, pt), Qt(pe, Ve), Qt(pe, ot), Qt(ot, ft), Qt(ft, j), Qt(ft, Kt), Fr(Ti, ft, null), Qt(ft, Me), Fr(Zt, ft, null), Qt(ft, fe), Fr(v, ft, null), Qt(ot, lt), Qt(ot, oe), Qt(oe, B), Qt(oe, ze), Fr(F, oe, null), Qt(oe, ur), Fr(En, oe, null), Qt(oe, br), Fr(Nn, oe, null), Qt(ot, Lr), Qt(ot, ne), Qt(ne, Ie), Qt(ne, Ot), Fr(wt, ne, null), Qt(ne, mi), Fr(Tr, ne, null), Qt(ne, D), Fr(je, ne, null), Qt(ot, x), Qt(ot, Ft), Qt(Ft, Bt), Qt(Ft, js), Fr(Jn, Ft, null), Qt(Ft, Ys), Fr(Qr, Ft, null), as = !0, q || (kl = [
        jd(
          Ee,
          "click",
          /*render*/
          Z[13]
        ),
        jd(
          yt,
          "click",
          /*toggleRenderMode*/
          Z[14]
        ),
        jd(
          ct,
          "click",
          /*click_handler*/
          Z[24]
        ),
        jd(
          gt,
          "click",
          /*click_handler_1*/
          Z[25]
        ),
        jd(
          pt,
          "click",
          /*click_handler_2*/
          Z[26]
        )
      ], q = !0);
    },
    p(mt, Vi) {
      var ri, Jo, ss, ki, $o, Kl, ls, $s, ql, cs, Ql;
      /*loading_status*/
      mt[8] ? hn ? (hn.p(mt, Vi), Vi[0] & /*loading_status*/
      256 && Dn(hn, 1)) : (hn = t1(mt), hn.c(), Dn(hn, 1), hn.m(k.parentNode, k)) : hn && (e1(), Xn(hn, 1, 1, () => {
        hn = null;
      }), $O()), /*show_label*/
      mt[5] ? dn ? (dn.p(mt, Vi), Vi[0] & /*show_label*/
      32 && Dn(dn, 1)) : (dn = i1(mt), dn.c(), Dn(dn, 1), dn.m(G.parentNode, G)) : dn && (e1(), Xn(dn, 1, 1, () => {
        dn = null;
      }), $O());
      const Xt = {};
      Vi[0] & /*selectedMesh*/
      4096 && (Xt.value = /*unscaledR*/
      mt[16](
        /*selectedMesh*/
        (ri = mt[12]) == null ? void 0 : ri.rotation.x
      )), Ti.$set(Xt);
      const Iu = {};
      Vi[0] & /*selectedMesh*/
      4096 && (Iu.value = /*unscaledR*/
      mt[16](
        /*selectedMesh*/
        (Jo = mt[12]) == null ? void 0 : Jo.rotation.y
      )), Zt.$set(Iu);
      const et = {};
      Vi[0] & /*selectedMesh*/
      4096 && (et.value = /*unscaledR*/
      mt[16](
        /*selectedMesh*/
        (ss = mt[12]) == null ? void 0 : ss.rotation.z
      )), v.$set(et);
      const Zs = {};
      Vi[0] & /*selectedMesh*/
      4096 && (Zs.value = /*unscaledT*/
      mt[18](
        /*selectedMesh*/
        (ki = mt[12]) == null ? void 0 : ki.position.x
      )), F.$set(Zs);
      const Js = {};
      Vi[0] & /*selectedMesh*/
      4096 && (Js.value = /*unscaledT*/
      mt[18](
        /*selectedMesh*/
        ($o = mt[12]) == null ? void 0 : $o.position.y
      )), En.$set(Js);
      const Mu = {};
      Vi[0] & /*selectedMesh*/
      4096 && (Mu.value = /*unscaledT*/
      mt[18](
        /*selectedMesh*/
        (Kl = mt[12]) == null ? void 0 : Kl.position.z
      )), Nn.$set(Mu);
      const Yl = {};
      Vi[0] & /*selectedMesh*/
      4096 && (Yl.value = /*unscaledS*/
      mt[20](
        /*selectedMesh*/
        (ls = mt[12]) == null ? void 0 : ls.scaling.x
      )), wt.$set(Yl);
      const $n = {};
      Vi[0] & /*selectedMesh*/
      4096 && ($n.value = /*unscaledS*/
      mt[20](
        /*selectedMesh*/
        ($s = mt[12]) == null ? void 0 : $s.scaling.y
      )), Tr.$set($n);
      const ye = {};
      Vi[0] & /*selectedMesh*/
      4096 && (ye.value = /*unscaledS*/
      mt[20](
        /*selectedMesh*/
        (ql = mt[12]) == null ? void 0 : ql.scaling.z
      )), je.$set(ye);
      const N = {};
      Vi[0] & /*camera*/
      2048 && (N.value = /*unscaledR*/
      mt[16](
        /*camera*/
        (cs = mt[11]) == null ? void 0 : cs.fov
      )), Jn.$set(N);
      const St = {};
      Vi[0] & /*camera*/
      2048 && (St.value = /*unscaledT*/
      mt[18](
        /*camera*/
        (Ql = mt[11]) == null ? void 0 : Ql.maxZ
      )), Qr.$set(St);
    },
    i(mt) {
      as || (Dn(hn), Dn(dn), Dn(Ti.$$.fragment, mt), Dn(Zt.$$.fragment, mt), Dn(v.$$.fragment, mt), Dn(F.$$.fragment, mt), Dn(En.$$.fragment, mt), Dn(Nn.$$.fragment, mt), Dn(wt.$$.fragment, mt), Dn(Tr.$$.fragment, mt), Dn(je.$$.fragment, mt), Dn(Jn.$$.fragment, mt), Dn(Qr.$$.fragment, mt), as = !0);
    },
    o(mt) {
      Xn(hn), Xn(dn), Xn(Ti.$$.fragment, mt), Xn(Zt.$$.fragment, mt), Xn(v.$$.fragment, mt), Xn(F.$$.fragment, mt), Xn(En.$$.fragment, mt), Xn(Nn.$$.fragment, mt), Xn(wt.$$.fragment, mt), Xn(Tr.$$.fragment, mt), Xn(je.$$.fragment, mt), Xn(Jn.$$.fragment, mt), Xn(Qr.$$.fragment, mt), as = !1;
    },
    d(mt) {
      mt && (Um(k), Um(G), Um($)), hn && hn.d(mt), dn && dn.d(mt), Z[23](null), Nr(Ti), Nr(Zt), Nr(v), Nr(F), Nr(En), Nr(Nn), Nr(wt), Nr(Tr), Nr(je), Nr(Jn), Nr(Qr), q = !1, sw(kl);
    }
  };
}
function _w(Z) {
  let k, G;
  return k = new _F({
    props: {
      visible: (
        /*visible*/
        Z[4]
      ),
      elem_id: (
        /*elem_id*/
        Z[2]
      ),
      elem_classes: (
        /*elem_classes*/
        Z[3]
      ),
      scale: (
        /*scale*/
        Z[6]
      ),
      min_width: (
        /*min_width*/
        Z[7]
      ),
      allow_overflow: !1,
      padding: !0,
      $$slots: { default: [fw] },
      $$scope: { ctx: Z }
    }
  }), {
    c() {
      Dr(k.$$.fragment);
    },
    m($, ce) {
      Fr(k, $, ce), G = !0;
    },
    p($, ce) {
      const le = {};
      ce[0] & /*visible*/
      16 && (le.visible = /*visible*/
      $[4]), ce[0] & /*elem_id*/
      4 && (le.elem_id = /*elem_id*/
      $[2]), ce[0] & /*elem_classes*/
      8 && (le.elem_classes = /*elem_classes*/
      $[3]), ce[0] & /*scale*/
      64 && (le.scale = /*scale*/
      $[6]), ce[0] & /*min_width*/
      128 && (le.min_width = /*min_width*/
      $[7]), ce[0] & /*camera, selectedMesh, scene, el, label, show_label, gradio, loading_status*/
      7971 | ce[1] & /*$$scope*/
      4096 && (le.$$scope = { dirty: ce, ctx: $ }), k.$set(le);
    },
    i($) {
      G || (Dn(k.$$.fragment, $), G = !0);
    },
    o($) {
      Xn(k.$$.fragment, $), G = !1;
    },
    d($) {
      Nr(k, $);
    }
  };
}
function mw(Z, k, G) {
  let { gradio: $ } = k, { label: ce = "Editor3D" } = k, { elem_id: le = "" } = k, { elem_classes: be = [] } = k, { visible: pe = !0 } = k, { value: _ = "" } = k, { show_label: Ee } = k, { scale: Xe = null } = k, { min_width: yt = void 0 } = k, { loading_status: H = void 0 } = k, { interactive: ue } = k, ct;
  async function Ht() {
    await hw(), $.dispatch("change");
  }
  let gt, Ge, pt, Ve;
  const ot = (D) => {
    G(12, Ve = D);
  }, ft = (D) => {
    G(21, _ = D), Ht();
  }, j = () => {
    Un.Tools.CreateScreenshot(Ge, pt, { precision: 1 }, ft);
  }, Kt = () => {
    if (Ge) {
      const D = new CustomEvent("rendermodetoggle");
      ct.dispatchEvent(D);
    }
  };
  dw(async () => {
    G(10, { scene: gt, engine: Ge, camera: pt } = await WL(ct, ft, ot), gt, G(11, pt));
  });
  const Ti = (D) => D ? D * Math.PI / 180 : 0, Me = (D) => D ? D / Math.PI * 180 : 0, Zt = (D) => D ? D * 0.1 : 0, fe = (D) => D ? D / 0.1 : 0, v = (D) => D ? D * 0.1 : 0, lt = (D) => D ? D / 0.1 : 0;
  function oe(D) {
    nw[D ? "unshift" : "push"](() => {
      ct = D, G(9, ct);
    });
  }
  const B = () => {
    G(12, Ve = Bm(gt));
  }, ze = () => Ve == null ? void 0 : Ve.dispose(), F = () => {
    G(12, Ve = HL(Ve));
  }, ur = (D) => {
    Ve && G(12, Ve.rotation.x = Ti(D.detail.value), Ve);
  }, En = (D) => {
    Ve && G(12, Ve.rotation.y = Ti(D.detail.value), Ve);
  }, br = (D) => {
    Ve && G(12, Ve.rotation.z = Ti(D.detail.value), Ve);
  }, Nn = (D) => {
    Ve && G(12, Ve.position.x = Zt(D.detail.value), Ve);
  }, Lr = (D) => {
    Ve && G(12, Ve.position.y = Zt(D.detail.value), Ve);
  }, ne = (D) => {
    Ve && G(12, Ve.position.z = Zt(D.detail.value), Ve);
  }, Ie = (D) => {
    Ve && G(12, Ve.scaling.x = v(D.detail.value), Ve);
  }, Ot = (D) => {
    Ve && G(12, Ve.scaling.y = v(D.detail.value), Ve);
  }, wt = (D) => {
    Ve && G(12, Ve.scaling.z = v(D.detail.value), Ve);
  }, mi = (D) => {
    pt && G(11, pt.fov = Ti(D.detail.value), pt);
  }, Tr = (D) => {
    pt && G(11, pt.maxZ = Zt(D.detail.value), pt);
  };
  return Z.$$set = (D) => {
    "gradio" in D && G(0, $ = D.gradio), "label" in D && G(1, ce = D.label), "elem_id" in D && G(2, le = D.elem_id), "elem_classes" in D && G(3, be = D.elem_classes), "visible" in D && G(4, pe = D.visible), "value" in D && G(21, _ = D.value), "show_label" in D && G(5, Ee = D.show_label), "scale" in D && G(6, Xe = D.scale), "min_width" in D && G(7, yt = D.min_width), "loading_status" in D && G(8, H = D.loading_status), "interactive" in D && G(22, ue = D.interactive);
  }, [
    $,
    ce,
    le,
    be,
    pe,
    Ee,
    Xe,
    yt,
    H,
    ct,
    gt,
    pt,
    Ve,
    j,
    Kt,
    Ti,
    Me,
    Zt,
    fe,
    v,
    lt,
    _,
    ue,
    oe,
    B,
    ze,
    F,
    ur,
    En,
    br,
    Nn,
    Lr,
    ne,
    Ie,
    Ot,
    wt,
    mi,
    Tr
  ];
}
class gw extends tw {
  constructor(k) {
    super(), aw(
      this,
      k,
      mw,
      _w,
      lw,
      {
        gradio: 0,
        label: 1,
        elem_id: 2,
        elem_classes: 3,
        visible: 4,
        value: 21,
        show_label: 5,
        scale: 6,
        min_width: 7,
        loading_status: 8,
        interactive: 22
      },
      null,
      [-1, -1]
    );
  }
  get gradio() {
    return this.$$.ctx[0];
  }
  set gradio(k) {
    this.$$set({ gradio: k }), Zo();
  }
  get label() {
    return this.$$.ctx[1];
  }
  set label(k) {
    this.$$set({ label: k }), Zo();
  }
  get elem_id() {
    return this.$$.ctx[2];
  }
  set elem_id(k) {
    this.$$set({ elem_id: k }), Zo();
  }
  get elem_classes() {
    return this.$$.ctx[3];
  }
  set elem_classes(k) {
    this.$$set({ elem_classes: k }), Zo();
  }
  get visible() {
    return this.$$.ctx[4];
  }
  set visible(k) {
    this.$$set({ visible: k }), Zo();
  }
  get value() {
    return this.$$.ctx[21];
  }
  set value(k) {
    this.$$set({ value: k }), Zo();
  }
  get show_label() {
    return this.$$.ctx[5];
  }
  set show_label(k) {
    this.$$set({ show_label: k }), Zo();
  }
  get scale() {
    return this.$$.ctx[6];
  }
  set scale(k) {
    this.$$set({ scale: k }), Zo();
  }
  get min_width() {
    return this.$$.ctx[7];
  }
  set min_width(k) {
    this.$$set({ min_width: k }), Zo();
  }
  get loading_status() {
    return this.$$.ctx[8];
  }
  set loading_status(k) {
    this.$$set({ loading_status: k }), Zo();
  }
  get interactive() {
    return this.$$.ctx[22];
  }
  set interactive(k) {
    this.$$set({ interactive: k }), Zo();
  }
}
export {
  gw as default
};
