diff --git "a/src/backend/gradio_model4dgs/templates/component/index.js" "b/src/backend/gradio_model4dgs/templates/component/index.js" new file mode 100644--- /dev/null +++ "b/src/backend/gradio_model4dgs/templates/component/index.js" @@ -0,0 +1,20007 @@ +var wc = Object.defineProperty; +var Cc = (i, e, t) => e in i ? wc(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t; +var Pe = (i, e, t) => (Cc(i, typeof e != "symbol" ? e + "" : e, t), t); +new Intl.Collator(0, { numeric: 1 }).compare; +function Ul(i, e, t) { + if (i == null) + return null; + if (Array.isArray(i)) { + const n = []; + for (const r of i) + r == null ? n.push(null) : n.push(Ul(r, e, t)); + return n; + } + return i.is_stream ? t == null ? new ds({ + ...i, + url: e + "/stream/" + i.path + }) : new ds({ + ...i, + url: "/proxy=" + t + "stream/" + i.path + }) : new ds({ + ...i, + url: Pc(i.path, e, t) + }); +} +function Rc(i) { + try { + const e = new URL(i); + return e.protocol === "http:" || e.protocol === "https:"; + } catch { + return !1; + } +} +function Pc(i, e, t) { + return i == null ? t ? `/proxy=${t}file=` : `${e}/file=` : Rc(i) ? i : t ? `/proxy=${t}file=${i}` : `${e}/file=${i}`; +} +class ds { + constructor({ + path: e, + url: t, + orig_name: n, + size: r, + blob: s, + is_stream: a, + mime_type: o, + alt_text: l + }) { + this.path = e, this.url = t, this.orig_name = n, this.size = r, this.blob = t ? void 0 : s, this.is_stream = a, this.mime_type = o, this.alt_text = l; + } +} +const { + SvelteComponent: Lc, + assign: Dc, + create_slot: Ic, + detach: Uc, + element: Fc, + get_all_dirty_from_scope: Nc, + get_slot_changes: Bc, + get_spread_update: Oc, + init: zc, + insert: kc, + safe_not_equal: Gc, + set_dynamic_element_data: Po, + set_style: Dt, + toggle_class: Tn, + transition_in: Fl, + transition_out: Nl, + update_slot_base: Hc +} = window.__gradio__svelte__internal; +function Vc(i) { + let e, t, n; + const r = ( + /*#slots*/ + i[18].default + ), s = Ic( + r, + i, + /*$$scope*/ + i[17], + null + ); + let a = [ + { "data-testid": ( + /*test_id*/ + i[7] + ) }, + { id: ( + /*elem_id*/ + i[2] + ) }, + { + class: t = "block " + /*elem_classes*/ + i[3].join(" ") + " svelte-1t38q2d" + } + ], o = {}; + for (let l = 0; l < a.length; l += 1) + o = Dc(o, a[l]); + return { + c() { + e = Fc( + /*tag*/ + i[14] + ), s && s.c(), Po( + /*tag*/ + i[14] + )(e, o), Tn( + e, + "hidden", + /*visible*/ + i[10] === !1 + ), Tn( + e, + "padded", + /*padding*/ + i[6] + ), Tn( + e, + "border_focus", + /*border_mode*/ + i[5] === "focus" + ), Tn(e, "hide-container", !/*explicit_call*/ + i[8] && !/*container*/ + i[9]), Dt( + e, + "height", + /*get_dimension*/ + i[15]( + /*height*/ + i[0] + ) + ), Dt(e, "width", typeof /*width*/ + i[1] == "number" ? `calc(min(${/*width*/ + i[1]}px, 100%))` : ( + /*get_dimension*/ + i[15]( + /*width*/ + i[1] + ) + )), Dt( + e, + "border-style", + /*variant*/ + i[4] + ), Dt( + e, + "overflow", + /*allow_overflow*/ + i[11] ? "visible" : "hidden" + ), Dt( + e, + "flex-grow", + /*scale*/ + i[12] + ), Dt(e, "min-width", `calc(min(${/*min_width*/ + i[13]}px, 100%))`), Dt(e, "border-width", "var(--block-border-width)"); + }, + m(l, c) { + kc(l, e, c), s && s.m(e, null), n = !0; + }, + p(l, c) { + s && s.p && (!n || c & /*$$scope*/ + 131072) && Hc( + s, + r, + l, + /*$$scope*/ + l[17], + n ? Bc( + r, + /*$$scope*/ + l[17], + c, + null + ) : Nc( + /*$$scope*/ + l[17] + ), + null + ), Po( + /*tag*/ + l[14] + )(e, o = Oc(a, [ + (!n || c & /*test_id*/ + 128) && { "data-testid": ( + /*test_id*/ + l[7] + ) }, + (!n || c & /*elem_id*/ + 4) && { id: ( + /*elem_id*/ + l[2] + ) }, + (!n || c & /*elem_classes*/ + 8 && t !== (t = "block " + /*elem_classes*/ + l[3].join(" ") + " svelte-1t38q2d")) && { class: t } + ])), Tn( + e, + "hidden", + /*visible*/ + l[10] === !1 + ), Tn( + e, + "padded", + /*padding*/ + l[6] + ), Tn( + e, + "border_focus", + /*border_mode*/ + l[5] === "focus" + ), Tn(e, "hide-container", !/*explicit_call*/ + l[8] && !/*container*/ + l[9]), c & /*height*/ + 1 && Dt( + e, + "height", + /*get_dimension*/ + l[15]( + /*height*/ + l[0] + ) + ), c & /*width*/ + 2 && Dt(e, "width", typeof /*width*/ + l[1] == "number" ? `calc(min(${/*width*/ + l[1]}px, 100%))` : ( + /*get_dimension*/ + l[15]( + /*width*/ + l[1] + ) + )), c & /*variant*/ + 16 && Dt( + e, + "border-style", + /*variant*/ + l[4] + ), c & /*allow_overflow*/ + 2048 && Dt( + e, + "overflow", + /*allow_overflow*/ + l[11] ? "visible" : "hidden" + ), c & /*scale*/ + 4096 && Dt( + e, + "flex-grow", + /*scale*/ + l[12] + ), c & /*min_width*/ + 8192 && Dt(e, "min-width", `calc(min(${/*min_width*/ + l[13]}px, 100%))`); + }, + i(l) { + n || (Fl(s, l), n = !0); + }, + o(l) { + Nl(s, l), n = !1; + }, + d(l) { + l && Uc(e), s && s.d(l); + } + }; +} +function Wc(i) { + let e, t = ( + /*tag*/ + i[14] && Vc(i) + ); + return { + c() { + t && t.c(); + }, + m(n, r) { + t && t.m(n, r), e = !0; + }, + p(n, [r]) { + /*tag*/ + n[14] && t.p(n, r); + }, + i(n) { + e || (Fl(t, n), e = !0); + }, + o(n) { + Nl(t, n), e = !1; + }, + d(n) { + t && t.d(n); + } + }; +} +function Xc(i, e, t) { + let { $$slots: n = {}, $$scope: r } = e, { height: s = void 0 } = e, { width: a = void 0 } = e, { elem_id: o = "" } = e, { elem_classes: l = [] } = e, { variant: c = "solid" } = e, { border_mode: u = "base" } = e, { padding: f = !0 } = e, { type: h = "normal" } = e, { test_id: p = void 0 } = e, { explicit_call: g = !1 } = e, { container: v = !0 } = e, { visible: m = !0 } = e, { allow_overflow: d = !0 } = e, { scale: M = null } = e, { min_width: _ = 0 } = e, A = h === "fieldset" ? "fieldset" : "div"; + const C = (E) => { + if (E !== void 0) { + if (typeof E == "number") + return E + "px"; + if (typeof E == "string") + return E; + } + }; + return i.$$set = (E) => { + "height" in E && t(0, s = E.height), "width" in E && t(1, a = E.width), "elem_id" in E && t(2, o = E.elem_id), "elem_classes" in E && t(3, l = E.elem_classes), "variant" in E && t(4, c = E.variant), "border_mode" in E && t(5, u = E.border_mode), "padding" in E && t(6, f = E.padding), "type" in E && t(16, h = E.type), "test_id" in E && t(7, p = E.test_id), "explicit_call" in E && t(8, g = E.explicit_call), "container" in E && t(9, v = E.container), "visible" in E && t(10, m = E.visible), "allow_overflow" in E && t(11, d = E.allow_overflow), "scale" in E && t(12, M = E.scale), "min_width" in E && t(13, _ = E.min_width), "$$scope" in E && t(17, r = E.$$scope); + }, [ + s, + a, + o, + l, + c, + u, + f, + p, + g, + v, + m, + d, + M, + _, + A, + C, + h, + r, + n + ]; +} +class qc extends Lc { + constructor(e) { + super(), zc(this, e, Xc, Wc, Gc, { + height: 0, + width: 1, + elem_id: 2, + elem_classes: 3, + variant: 4, + border_mode: 5, + padding: 6, + type: 16, + test_id: 7, + explicit_call: 8, + container: 9, + visible: 10, + allow_overflow: 11, + scale: 12, + min_width: 13 + }); + } +} +const { + SvelteComponent: Yc, + append: ps, + attr: mr, + create_component: jc, + destroy_component: Kc, + detach: Qc, + element: Lo, + init: Zc, + insert: Jc, + mount_component: $c, + safe_not_equal: eu, + set_data: tu, + space: nu, + text: iu, + toggle_class: wn, + transition_in: ru, + transition_out: su +} = window.__gradio__svelte__internal; +function ou(i) { + let e, t, n, r, s, a; + return n = new /*Icon*/ + i[1]({}), { + c() { + e = Lo("label"), t = Lo("span"), jc(n.$$.fragment), r = nu(), s = iu( + /*label*/ + i[0] + ), mr(t, "class", "svelte-9gxdi0"), mr(e, "for", ""), mr(e, "data-testid", "block-label"), mr(e, "class", "svelte-9gxdi0"), wn(e, "hide", !/*show_label*/ + i[2]), wn(e, "sr-only", !/*show_label*/ + i[2]), wn( + e, + "float", + /*float*/ + i[4] + ), wn( + e, + "hide-label", + /*disable*/ + i[3] + ); + }, + m(o, l) { + Jc(o, e, l), ps(e, t), $c(n, t, null), ps(e, r), ps(e, s), a = !0; + }, + p(o, [l]) { + (!a || l & /*label*/ + 1) && tu( + s, + /*label*/ + o[0] + ), (!a || l & /*show_label*/ + 4) && wn(e, "hide", !/*show_label*/ + o[2]), (!a || l & /*show_label*/ + 4) && wn(e, "sr-only", !/*show_label*/ + o[2]), (!a || l & /*float*/ + 16) && wn( + e, + "float", + /*float*/ + o[4] + ), (!a || l & /*disable*/ + 8) && wn( + e, + "hide-label", + /*disable*/ + o[3] + ); + }, + i(o) { + a || (ru(n.$$.fragment, o), a = !0); + }, + o(o) { + su(n.$$.fragment, o), a = !1; + }, + d(o) { + o && Qc(e), Kc(n); + } + }; +} +function au(i, e, t) { + let { label: n = null } = e, { Icon: r } = e, { show_label: s = !0 } = e, { disable: a = !1 } = e, { float: o = !0 } = e; + return i.$$set = (l) => { + "label" in l && t(0, n = l.label), "Icon" in l && t(1, r = l.Icon), "show_label" in l && t(2, s = l.show_label), "disable" in l && t(3, a = l.disable), "float" in l && t(4, o = l.float); + }, [n, r, s, a, o]; +} +class uo extends Yc { + constructor(e) { + super(), Zc(this, e, au, ou, eu, { + label: 0, + Icon: 1, + show_label: 2, + disable: 3, + float: 4 + }); + } +} +const { + SvelteComponent: lu, + append: cu, + attr: ms, + binding_callbacks: uu, + create_slot: fu, + detach: hu, + element: Do, + get_all_dirty_from_scope: du, + get_slot_changes: pu, + init: mu, + insert: gu, + safe_not_equal: _u, + toggle_class: Cn, + transition_in: vu, + transition_out: xu, + update_slot_base: Su +} = window.__gradio__svelte__internal; +function Mu(i) { + let e, t, n; + const r = ( + /*#slots*/ + i[5].default + ), s = fu( + r, + i, + /*$$scope*/ + i[4], + null + ); + return { + c() { + e = Do("div"), t = Do("div"), s && s.c(), ms(t, "class", "icon svelte-3w3rth"), ms(e, "class", "empty svelte-3w3rth"), ms(e, "aria-label", "Empty value"), Cn( + e, + "small", + /*size*/ + i[0] === "small" + ), Cn( + e, + "large", + /*size*/ + i[0] === "large" + ), Cn( + e, + "unpadded_box", + /*unpadded_box*/ + i[1] + ), Cn( + e, + "small_parent", + /*parent_height*/ + i[3] + ); + }, + m(a, o) { + gu(a, e, o), cu(e, t), s && s.m(t, null), i[6](e), n = !0; + }, + p(a, [o]) { + s && s.p && (!n || o & /*$$scope*/ + 16) && Su( + s, + r, + a, + /*$$scope*/ + a[4], + n ? pu( + r, + /*$$scope*/ + a[4], + o, + null + ) : du( + /*$$scope*/ + a[4] + ), + null + ), (!n || o & /*size*/ + 1) && Cn( + e, + "small", + /*size*/ + a[0] === "small" + ), (!n || o & /*size*/ + 1) && Cn( + e, + "large", + /*size*/ + a[0] === "large" + ), (!n || o & /*unpadded_box*/ + 2) && Cn( + e, + "unpadded_box", + /*unpadded_box*/ + a[1] + ), (!n || o & /*parent_height*/ + 8) && Cn( + e, + "small_parent", + /*parent_height*/ + a[3] + ); + }, + i(a) { + n || (vu(s, a), n = !0); + }, + o(a) { + xu(s, a), n = !1; + }, + d(a) { + a && hu(e), s && s.d(a), i[6](null); + } + }; +} +function yu(i) { + let e, t = i[0], n = 1; + for (; n < i.length; ) { + const r = i[n], s = i[n + 1]; + if (n += 2, (r === "optionalAccess" || r === "optionalCall") && t == null) + return; + r === "access" || r === "optionalAccess" ? (e = t, t = s(t)) : (r === "call" || r === "optionalCall") && (t = s((...a) => t.call(e, ...a)), e = void 0); + } + return t; +} +function Au(i, e, t) { + let n, { $$slots: r = {}, $$scope: s } = e, { size: a = "small" } = e, { unpadded_box: o = !1 } = e, l; + function c(f) { + if (!f) + return !1; + const { height: h } = f.getBoundingClientRect(), { height: p } = yu([ + f, + "access", + (g) => g.parentElement, + "optionalAccess", + (g) => g.getBoundingClientRect, + "call", + (g) => g() + ]) || { height: h }; + return h > p + 2; + } + function u(f) { + uu[f ? "unshift" : "push"](() => { + l = f, t(2, l); + }); + } + return i.$$set = (f) => { + "size" in f && t(0, a = f.size), "unpadded_box" in f && t(1, o = f.unpadded_box), "$$scope" in f && t(4, s = f.$$scope); + }, i.$$.update = () => { + i.$$.dirty & /*el*/ + 4 && t(3, n = c(l)); + }, [a, o, l, n, s, r, u]; +} +class Eu extends lu { + constructor(e) { + super(), mu(this, e, Au, Mu, _u, { size: 0, unpadded_box: 1 }); + } +} +const { + SvelteComponent: bu, + append: Io, + attr: Ot, + detach: Tu, + init: wu, + insert: Cu, + noop: gs, + safe_not_equal: Ru, + svg_element: _s +} = window.__gradio__svelte__internal; +function Pu(i) { + let e, t, n; + return { + c() { + e = _s("svg"), t = _s("path"), n = _s("polyline"), Ot(t, "d", "M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"), Ot(n, "points", "13 2 13 9 20 9"), Ot(e, "xmlns", "http://www.w3.org/2000/svg"), Ot(e, "width", "100%"), Ot(e, "height", "100%"), Ot(e, "viewBox", "0 0 24 24"), Ot(e, "fill", "none"), Ot(e, "stroke", "currentColor"), Ot(e, "stroke-width", "1.5"), Ot(e, "stroke-linecap", "round"), Ot(e, "stroke-linejoin", "round"), Ot(e, "class", "feather feather-file"); + }, + m(r, s) { + Cu(r, e, s), Io(e, t), Io(e, n); + }, + p: gs, + i: gs, + o: gs, + d(r) { + r && Tu(e); + } + }; +} +class rs extends bu { + constructor(e) { + super(), wu(this, e, null, Pu, Ru, {}); + } +} +const Lu = [ + { 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 } +], Uo = { + 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" + } +}; +Lu.reduce( + (i, { color: e, primary: t, secondary: n }) => ({ + ...i, + [e]: { + primary: Uo[e][t], + secondary: Uo[e][n] + } + }), + {} +); +/** + * @license + * Copyright 2010-2023 Three.js Authors + * SPDX-License-Identifier: MIT + */ +const fo = "162", fi = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 }, hi = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 }, Du = 0, Fo = 1, Iu = 2, Bl = 1, Uu = 2, xn = 3, hn = 0, Pt = 1, en = 2, zn = 0, ri = 1, No = 2, Bo = 3, Oo = 4, Ol = 5, ei = 100, Fu = 101, Nu = 102, zo = 103, ko = 104, Bu = 200, Ou = 201, zu = 202, ku = 203, cr = 204, ur = 205, Gu = 206, Hu = 207, Vu = 208, Wu = 209, Xu = 210, qu = 211, Yu = 212, ju = 213, Ku = 214, Qu = 0, Zu = 1, Ju = 2, qr = 3, $u = 4, ef = 5, tf = 6, nf = 7, zl = 0, rf = 1, sf = 2, kn = 0, of = 1, af = 2, lf = 3, cf = 4, uf = 5, ff = 6, hf = 7, kl = 300, zi = 301, ki = 302, eo = 303, to = 304, ss = 306, no = 1e3, tn = 1001, io = 1002, vt = 1003, Go = 1004, er = 1005, Ct = 1006, vs = 1007, ni = 1008, Gn = 1009, df = 1010, pf = 1011, ho = 1012, Gl = 1013, nn = 1014, an = 1015, Gi = 1016, Hl = 1017, Vl = 1018, si = 1020, mf = 1021, Vt = 1023, gf = 1024, _f = 1025, Hn = 1026, Hi = 1027, vf = 1028, po = 1029, ro = 1030, Wl = 1031, mo = 1033, xs = 33776, Ss = 33777, Ms = 33778, ys = 33779, Ho = 35840, Vo = 35841, Wo = 35842, Xo = 35843, Xl = 36196, qo = 37492, Yo = 37496, jo = 37808, Ko = 37809, Qo = 37810, Zo = 37811, Jo = 37812, $o = 37813, ea = 37814, ta = 37815, na = 37816, ia = 37817, ra = 37818, sa = 37819, oa = 37820, aa = 37821, As = 36492, la = 36494, ca = 36495, xf = 36283, ua = 36284, fa = 36285, ha = 36286, Sf = 3200, Mf = 3201, yf = 0, Af = 1, Nn = "", sn = "srgb", Wn = "srgb-linear", go = "display-p3", os = "display-p3-linear", Yr = "linear", nt = "srgb", jr = "rec709", Kr = "p3", di = 7680, da = 519, Ef = 512, bf = 513, Tf = 514, ql = 515, wf = 516, Cf = 517, Rf = 518, Pf = 519, pa = 35044, Lf = 35048, ma = "300 es", so = 1035, Mn = 2e3, Qr = 2001; +class ui { + addEventListener(e, t) { + this._listeners === void 0 && (this._listeners = {}); + const n = this._listeners; + n[e] === void 0 && (n[e] = []), n[e].indexOf(t) === -1 && n[e].push(t); + } + hasEventListener(e, t) { + if (this._listeners === void 0) + return !1; + const n = this._listeners; + return n[e] !== void 0 && n[e].indexOf(t) !== -1; + } + removeEventListener(e, t) { + if (this._listeners === void 0) + return; + const r = this._listeners[e]; + if (r !== void 0) { + const s = r.indexOf(t); + s !== -1 && r.splice(s, 1); + } + } + dispatchEvent(e) { + if (this._listeners === void 0) + return; + const n = this._listeners[e.type]; + if (n !== void 0) { + e.target = this; + const r = n.slice(0); + for (let s = 0, a = r.length; s < a; s++) + r[s].call(this, e); + e.target = null; + } + } +} +const Mt = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "1a", "1b", "1c", "1d", "1e", "1f", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "2a", "2b", "2c", "2d", "2e", "2f", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "3a", "3b", "3c", "3d", "3e", "3f", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "4a", "4b", "4c", "4d", "4e", "4f", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "5a", "5b", "5c", "5d", "5e", "5f", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "6a", "6b", "6c", "6d", "6e", "6f", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "7a", "7b", "7c", "7d", "7e", "7f", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "8a", "8b", "8c", "8d", "8e", "8f", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "9a", "9b", "9c", "9d", "9e", "9f", "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "aa", "ab", "ac", "ad", "ae", "af", "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "ba", "bb", "bc", "bd", "be", "bf", "c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "ca", "cb", "cc", "cd", "ce", "cf", "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "da", "db", "dc", "dd", "de", "df", "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9", "ea", "eb", "ec", "ed", "ee", "ef", "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "fa", "fb", "fc", "fd", "fe", "ff"]; +let ga = 1234567; +const sr = Math.PI / 180, fr = 180 / Math.PI; +function Ki() { + const i = Math.random() * 4294967295 | 0, e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, n = Math.random() * 4294967295 | 0; + return (Mt[i & 255] + Mt[i >> 8 & 255] + Mt[i >> 16 & 255] + Mt[i >> 24 & 255] + "-" + Mt[e & 255] + Mt[e >> 8 & 255] + "-" + Mt[e >> 16 & 15 | 64] + Mt[e >> 24 & 255] + "-" + Mt[t & 63 | 128] + Mt[t >> 8 & 255] + "-" + Mt[t >> 16 & 255] + Mt[t >> 24 & 255] + Mt[n & 255] + Mt[n >> 8 & 255] + Mt[n >> 16 & 255] + Mt[n >> 24 & 255]).toLowerCase(); +} +function xt(i, e, t) { + return Math.max(e, Math.min(t, i)); +} +function _o(i, e) { + return (i % e + e) % e; +} +function Df(i, e, t, n, r) { + return n + (i - e) * (r - n) / (t - e); +} +function If(i, e, t) { + return i !== e ? (t - i) / (e - i) : 0; +} +function or(i, e, t) { + return (1 - t) * i + t * e; +} +function Uf(i, e, t, n) { + return or(i, e, 1 - Math.exp(-t * n)); +} +function Ff(i, e = 1) { + return e - Math.abs(_o(i, e * 2) - e); +} +function Nf(i, e, t) { + return i <= e ? 0 : i >= t ? 1 : (i = (i - e) / (t - e), i * i * (3 - 2 * i)); +} +function Bf(i, e, t) { + return i <= e ? 0 : i >= t ? 1 : (i = (i - e) / (t - e), i * i * i * (i * (i * 6 - 15) + 10)); +} +function Of(i, e) { + return i + Math.floor(Math.random() * (e - i + 1)); +} +function zf(i, e) { + return i + Math.random() * (e - i); +} +function kf(i) { + return i * (0.5 - Math.random()); +} +function Gf(i) { + i !== void 0 && (ga = i); + let e = ga += 1831565813; + return e = Math.imul(e ^ e >>> 15, e | 1), e ^= e + Math.imul(e ^ e >>> 7, e | 61), ((e ^ e >>> 14) >>> 0) / 4294967296; +} +function Hf(i) { + return i * sr; +} +function Vf(i) { + return i * fr; +} +function oo(i) { + return (i & i - 1) === 0 && i !== 0; +} +function Wf(i) { + return Math.pow(2, Math.ceil(Math.log(i) / Math.LN2)); +} +function Zr(i) { + return Math.pow(2, Math.floor(Math.log(i) / Math.LN2)); +} +function Xf(i, e, t, n, r) { + const s = Math.cos, a = Math.sin, o = s(t / 2), l = a(t / 2), c = s((e + n) / 2), u = a((e + n) / 2), f = s((e - n) / 2), h = a((e - n) / 2), p = s((n - e) / 2), g = a((n - e) / 2); + switch (r) { + case "XYX": + i.set(o * u, l * f, l * h, o * c); + break; + case "YZY": + i.set(l * h, o * u, l * f, o * c); + break; + case "ZXZ": + i.set(l * f, l * h, o * u, o * c); + break; + case "XZX": + i.set(o * u, l * g, l * p, o * c); + break; + case "YXY": + i.set(l * p, o * u, l * g, o * c); + break; + case "ZYZ": + i.set(l * g, l * p, o * u, o * c); + break; + default: + console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: " + r); + } +} +function Di(i, e) { + switch (e.constructor) { + case Float32Array: + return i; + case Uint32Array: + return i / 4294967295; + case Uint16Array: + return i / 65535; + case Uint8Array: + return i / 255; + case Int32Array: + return Math.max(i / 2147483647, -1); + case Int16Array: + return Math.max(i / 32767, -1); + case Int8Array: + return Math.max(i / 127, -1); + default: + throw new Error("Invalid component type."); + } +} +function Et(i, e) { + switch (e.constructor) { + case Float32Array: + return i; + case Uint32Array: + return Math.round(i * 4294967295); + case Uint16Array: + return Math.round(i * 65535); + case Uint8Array: + return Math.round(i * 255); + case Int32Array: + return Math.round(i * 2147483647); + case Int16Array: + return Math.round(i * 32767); + case Int8Array: + return Math.round(i * 127); + default: + throw new Error("Invalid component type."); + } +} +const Yl = { + DEG2RAD: sr, + RAD2DEG: fr, + generateUUID: Ki, + clamp: xt, + euclideanModulo: _o, + mapLinear: Df, + inverseLerp: If, + lerp: or, + damp: Uf, + pingpong: Ff, + smoothstep: Nf, + smootherstep: Bf, + randInt: Of, + randFloat: zf, + randFloatSpread: kf, + seededRandom: Gf, + degToRad: Hf, + radToDeg: Vf, + isPowerOfTwo: oo, + ceilPowerOfTwo: Wf, + floorPowerOfTwo: Zr, + setQuaternionFromProperEuler: Xf, + normalize: Et, + denormalize: Di +}; +class me { + constructor(e = 0, t = 0) { + me.prototype.isVector2 = !0, this.x = e, this.y = t; + } + get width() { + return this.x; + } + set width(e) { + this.x = e; + } + get height() { + return this.y; + } + set height(e) { + this.y = e; + } + set(e, t) { + return this.x = e, this.y = t, this; + } + setScalar(e) { + return this.x = e, this.y = e, this; + } + setX(e) { + return this.x = e, this; + } + setY(e) { + return this.y = e, this; + } + setComponent(e, t) { + switch (e) { + case 0: + this.x = t; + break; + case 1: + this.y = t; + break; + default: + throw new Error("index is out of range: " + e); + } + return this; + } + getComponent(e) { + switch (e) { + case 0: + return this.x; + case 1: + return this.y; + default: + throw new Error("index is out of range: " + e); + } + } + clone() { + return new this.constructor(this.x, this.y); + } + copy(e) { + return this.x = e.x, this.y = e.y, this; + } + add(e) { + return this.x += e.x, this.y += e.y, this; + } + addScalar(e) { + return this.x += e, this.y += e, this; + } + addVectors(e, t) { + return this.x = e.x + t.x, this.y = e.y + t.y, this; + } + addScaledVector(e, t) { + return this.x += e.x * t, this.y += e.y * t, this; + } + sub(e) { + return this.x -= e.x, this.y -= e.y, this; + } + subScalar(e) { + return this.x -= e, this.y -= e, this; + } + subVectors(e, t) { + return this.x = e.x - t.x, this.y = e.y - t.y, this; + } + multiply(e) { + return this.x *= e.x, this.y *= e.y, this; + } + multiplyScalar(e) { + return this.x *= e, this.y *= e, this; + } + divide(e) { + return this.x /= e.x, this.y /= e.y, this; + } + divideScalar(e) { + return this.multiplyScalar(1 / e); + } + applyMatrix3(e) { + const t = this.x, n = this.y, r = e.elements; + return this.x = r[0] * t + r[3] * n + r[6], this.y = r[1] * t + r[4] * n + r[7], this; + } + min(e) { + return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this; + } + max(e) { + return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this; + } + clamp(e, t) { + return this.x = Math.max(e.x, Math.min(t.x, this.x)), this.y = Math.max(e.y, Math.min(t.y, this.y)), this; + } + clampScalar(e, t) { + return this.x = Math.max(e, Math.min(t, this.x)), this.y = Math.max(e, Math.min(t, this.y)), this; + } + clampLength(e, t) { + const n = this.length(); + return this.divideScalar(n || 1).multiplyScalar(Math.max(e, Math.min(t, n))); + } + floor() { + return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this; + } + ceil() { + return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this; + } + round() { + return this.x = Math.round(this.x), this.y = Math.round(this.y), this; + } + roundToZero() { + return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this; + } + negate() { + return this.x = -this.x, this.y = -this.y, this; + } + dot(e) { + return this.x * e.x + this.y * e.y; + } + cross(e) { + return this.x * e.y - this.y * e.x; + } + lengthSq() { + return this.x * this.x + this.y * this.y; + } + length() { + return Math.sqrt(this.x * this.x + this.y * this.y); + } + manhattanLength() { + return Math.abs(this.x) + Math.abs(this.y); + } + normalize() { + return this.divideScalar(this.length() || 1); + } + angle() { + return Math.atan2(-this.y, -this.x) + Math.PI; + } + angleTo(e) { + const t = Math.sqrt(this.lengthSq() * e.lengthSq()); + if (t === 0) + return Math.PI / 2; + const n = this.dot(e) / t; + return Math.acos(xt(n, -1, 1)); + } + distanceTo(e) { + return Math.sqrt(this.distanceToSquared(e)); + } + distanceToSquared(e) { + const t = this.x - e.x, n = this.y - e.y; + return t * t + n * n; + } + manhattanDistanceTo(e) { + return Math.abs(this.x - e.x) + Math.abs(this.y - e.y); + } + setLength(e) { + return this.normalize().multiplyScalar(e); + } + lerp(e, t) { + return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this; + } + lerpVectors(e, t, n) { + return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this; + } + equals(e) { + return e.x === this.x && e.y === this.y; + } + fromArray(e, t = 0) { + return this.x = e[t], this.y = e[t + 1], this; + } + toArray(e = [], t = 0) { + return e[t] = this.x, e[t + 1] = this.y, e; + } + fromBufferAttribute(e, t) { + return this.x = e.getX(t), this.y = e.getY(t), this; + } + rotateAround(e, t) { + const n = Math.cos(t), r = Math.sin(t), s = this.x - e.x, a = this.y - e.y; + return this.x = s * n - a * r + e.x, this.y = s * r + a * n + e.y, this; + } + random() { + return this.x = Math.random(), this.y = Math.random(), this; + } + *[Symbol.iterator]() { + yield this.x, yield this.y; + } +} +class be { + constructor(e, t, n, r, s, a, o, l, c) { + be.prototype.isMatrix3 = !0, this.elements = [ + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1 + ], e !== void 0 && this.set(e, t, n, r, s, a, o, l, c); + } + set(e, t, n, r, s, a, o, l, c) { + const u = this.elements; + return u[0] = e, u[1] = r, u[2] = o, u[3] = t, u[4] = s, u[5] = l, u[6] = n, u[7] = a, u[8] = c, this; + } + identity() { + return this.set( + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1 + ), this; + } + copy(e) { + const t = this.elements, n = e.elements; + return t[0] = n[0], t[1] = n[1], t[2] = n[2], t[3] = n[3], t[4] = n[4], t[5] = n[5], t[6] = n[6], t[7] = n[7], t[8] = n[8], this; + } + extractBasis(e, t, n) { + return e.setFromMatrix3Column(this, 0), t.setFromMatrix3Column(this, 1), n.setFromMatrix3Column(this, 2), this; + } + setFromMatrix4(e) { + const t = e.elements; + return this.set( + t[0], + t[4], + t[8], + t[1], + t[5], + t[9], + t[2], + t[6], + t[10] + ), this; + } + multiply(e) { + return this.multiplyMatrices(this, e); + } + premultiply(e) { + return this.multiplyMatrices(e, this); + } + multiplyMatrices(e, t) { + const n = e.elements, r = t.elements, s = this.elements, a = n[0], o = n[3], l = n[6], c = n[1], u = n[4], f = n[7], h = n[2], p = n[5], g = n[8], v = r[0], m = r[3], d = r[6], M = r[1], _ = r[4], A = r[7], C = r[2], E = r[5], b = r[8]; + return s[0] = a * v + o * M + l * C, s[3] = a * m + o * _ + l * E, s[6] = a * d + o * A + l * b, s[1] = c * v + u * M + f * C, s[4] = c * m + u * _ + f * E, s[7] = c * d + u * A + f * b, s[2] = h * v + p * M + g * C, s[5] = h * m + p * _ + g * E, s[8] = h * d + p * A + g * b, this; + } + multiplyScalar(e) { + const t = this.elements; + return t[0] *= e, t[3] *= e, t[6] *= e, t[1] *= e, t[4] *= e, t[7] *= e, t[2] *= e, t[5] *= e, t[8] *= e, this; + } + determinant() { + const e = this.elements, t = e[0], n = e[1], r = e[2], s = e[3], a = e[4], o = e[5], l = e[6], c = e[7], u = e[8]; + return t * a * u - t * o * c - n * s * u + n * o * l + r * s * c - r * a * l; + } + invert() { + const e = this.elements, t = e[0], n = e[1], r = e[2], s = e[3], a = e[4], o = e[5], l = e[6], c = e[7], u = e[8], f = u * a - o * c, h = o * l - u * s, p = c * s - a * l, g = t * f + n * h + r * p; + if (g === 0) + return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0); + const v = 1 / g; + return e[0] = f * v, e[1] = (r * c - u * n) * v, e[2] = (o * n - r * a) * v, e[3] = h * v, e[4] = (u * t - r * l) * v, e[5] = (r * s - o * t) * v, e[6] = p * v, e[7] = (n * l - c * t) * v, e[8] = (a * t - n * s) * v, this; + } + transpose() { + let e; + const t = this.elements; + return e = t[1], t[1] = t[3], t[3] = e, e = t[2], t[2] = t[6], t[6] = e, e = t[5], t[5] = t[7], t[7] = e, this; + } + getNormalMatrix(e) { + return this.setFromMatrix4(e).invert().transpose(); + } + transposeIntoArray(e) { + const t = this.elements; + return e[0] = t[0], e[1] = t[3], e[2] = t[6], e[3] = t[1], e[4] = t[4], e[5] = t[7], e[6] = t[2], e[7] = t[5], e[8] = t[8], this; + } + setUvTransform(e, t, n, r, s, a, o) { + const l = Math.cos(s), c = Math.sin(s); + return this.set( + n * l, + n * c, + -n * (l * a + c * o) + a + e, + -r * c, + r * l, + -r * (-c * a + l * o) + o + t, + 0, + 0, + 1 + ), this; + } + // + scale(e, t) { + return this.premultiply(Es.makeScale(e, t)), this; + } + rotate(e) { + return this.premultiply(Es.makeRotation(-e)), this; + } + translate(e, t) { + return this.premultiply(Es.makeTranslation(e, t)), this; + } + // for 2D Transforms + makeTranslation(e, t) { + return e.isVector2 ? this.set( + 1, + 0, + e.x, + 0, + 1, + e.y, + 0, + 0, + 1 + ) : this.set( + 1, + 0, + e, + 0, + 1, + t, + 0, + 0, + 1 + ), this; + } + makeRotation(e) { + const t = Math.cos(e), n = Math.sin(e); + return this.set( + t, + -n, + 0, + n, + t, + 0, + 0, + 0, + 1 + ), this; + } + makeScale(e, t) { + return this.set( + e, + 0, + 0, + 0, + t, + 0, + 0, + 0, + 1 + ), this; + } + // + equals(e) { + const t = this.elements, n = e.elements; + for (let r = 0; r < 9; r++) + if (t[r] !== n[r]) + return !1; + return !0; + } + fromArray(e, t = 0) { + for (let n = 0; n < 9; n++) + this.elements[n] = e[n + t]; + return this; + } + toArray(e = [], t = 0) { + const n = this.elements; + return e[t] = n[0], e[t + 1] = n[1], e[t + 2] = n[2], e[t + 3] = n[3], e[t + 4] = n[4], e[t + 5] = n[5], e[t + 6] = n[6], e[t + 7] = n[7], e[t + 8] = n[8], e; + } + clone() { + return new this.constructor().fromArray(this.elements); + } +} +const Es = /* @__PURE__ */ new be(); +function jl(i) { + for (let e = i.length - 1; e >= 0; --e) + if (i[e] >= 65535) + return !0; + return !1; +} +function Jr(i) { + return document.createElementNS("http://www.w3.org/1999/xhtml", i); +} +function qf() { + const i = Jr("canvas"); + return i.style.display = "block", i; +} +const _a = {}; +function Yf(i) { + i in _a || (_a[i] = !0, console.warn(i)); +} +const va = /* @__PURE__ */ new be().set( + 0.8224621, + 0.177538, + 0, + 0.0331941, + 0.9668058, + 0, + 0.0170827, + 0.0723974, + 0.9105199 +), xa = /* @__PURE__ */ new be().set( + 1.2249401, + -0.2249404, + 0, + -0.0420569, + 1.0420571, + 0, + -0.0196376, + -0.0786361, + 1.0982735 +), gr = { + [Wn]: { + transfer: Yr, + primaries: jr, + toReference: (i) => i, + fromReference: (i) => i + }, + [sn]: { + transfer: nt, + primaries: jr, + toReference: (i) => i.convertSRGBToLinear(), + fromReference: (i) => i.convertLinearToSRGB() + }, + [os]: { + transfer: Yr, + primaries: Kr, + toReference: (i) => i.applyMatrix3(xa), + fromReference: (i) => i.applyMatrix3(va) + }, + [go]: { + transfer: nt, + primaries: Kr, + toReference: (i) => i.convertSRGBToLinear().applyMatrix3(xa), + fromReference: (i) => i.applyMatrix3(va).convertLinearToSRGB() + } +}, jf = /* @__PURE__ */ new Set([Wn, os]), Ze = { + enabled: !0, + _workingColorSpace: Wn, + get workingColorSpace() { + return this._workingColorSpace; + }, + set workingColorSpace(i) { + if (!jf.has(i)) + throw new Error(`Unsupported working color space, "${i}".`); + this._workingColorSpace = i; + }, + convert: function(i, e, t) { + if (this.enabled === !1 || e === t || !e || !t) + return i; + const n = gr[e].toReference, r = gr[t].fromReference; + return r(n(i)); + }, + fromWorkingColorSpace: function(i, e) { + return this.convert(i, this._workingColorSpace, e); + }, + toWorkingColorSpace: function(i, e) { + return this.convert(i, e, this._workingColorSpace); + }, + getPrimaries: function(i) { + return gr[i].primaries; + }, + getTransfer: function(i) { + return i === Nn ? Yr : gr[i].transfer; + } +}; +function Bi(i) { + return i < 0.04045 ? i * 0.0773993808 : Math.pow(i * 0.9478672986 + 0.0521327014, 2.4); +} +function bs(i) { + return i < 31308e-7 ? i * 12.92 : 1.055 * Math.pow(i, 0.41666) - 0.055; +} +let pi; +class Kl { + static getDataURL(e) { + if (/^data:/i.test(e.src) || typeof HTMLCanvasElement > "u") + return e.src; + let t; + if (e instanceof HTMLCanvasElement) + t = e; + else { + pi === void 0 && (pi = Jr("canvas")), pi.width = e.width, pi.height = e.height; + const n = pi.getContext("2d"); + e instanceof ImageData ? n.putImageData(e, 0, 0) : n.drawImage(e, 0, 0, e.width, e.height), t = pi; + } + return t.width > 2048 || t.height > 2048 ? (console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons", e), t.toDataURL("image/jpeg", 0.6)) : t.toDataURL("image/png"); + } + static sRGBToLinear(e) { + if (typeof HTMLImageElement < "u" && e instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && e instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && e instanceof ImageBitmap) { + const t = Jr("canvas"); + t.width = e.width, t.height = e.height; + const n = t.getContext("2d"); + n.drawImage(e, 0, 0, e.width, e.height); + const r = n.getImageData(0, 0, e.width, e.height), s = r.data; + for (let a = 0; a < s.length; a++) + s[a] = Bi(s[a] / 255) * 255; + return n.putImageData(r, 0, 0), t; + } else if (e.data) { + const t = e.data.slice(0); + for (let n = 0; n < t.length; n++) + t instanceof Uint8Array || t instanceof Uint8ClampedArray ? t[n] = Math.floor(Bi(t[n] / 255) * 255) : t[n] = Bi(t[n]); + return { + data: t, + width: e.width, + height: e.height + }; + } else + return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."), e; + } +} +let Kf = 0; +class Ql { + constructor(e = null) { + this.isSource = !0, Object.defineProperty(this, "id", { value: Kf++ }), this.uuid = Ki(), this.data = e, this.dataReady = !0, this.version = 0; + } + set needsUpdate(e) { + e === !0 && this.version++; + } + toJSON(e) { + const t = e === void 0 || typeof e == "string"; + if (!t && e.images[this.uuid] !== void 0) + return e.images[this.uuid]; + const n = { + uuid: this.uuid, + url: "" + }, r = this.data; + if (r !== null) { + let s; + if (Array.isArray(r)) { + s = []; + for (let a = 0, o = r.length; a < o; a++) + r[a].isDataTexture ? s.push(Ts(r[a].image)) : s.push(Ts(r[a])); + } else + s = Ts(r); + n.url = s; + } + return t || (e.images[this.uuid] = n), n; + } +} +function Ts(i) { + return typeof HTMLImageElement < "u" && i instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && i instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && i instanceof ImageBitmap ? Kl.getDataURL(i) : i.data ? { + data: Array.from(i.data), + width: i.width, + height: i.height, + type: i.data.constructor.name + } : (console.warn("THREE.Texture: Unable to serialize Texture."), {}); +} +let Qf = 0; +class Tt extends ui { + constructor(e = Tt.DEFAULT_IMAGE, t = Tt.DEFAULT_MAPPING, n = tn, r = tn, s = Ct, a = ni, o = Vt, l = Gn, c = Tt.DEFAULT_ANISOTROPY, u = Nn) { + super(), this.isTexture = !0, Object.defineProperty(this, "id", { value: Qf++ }), this.uuid = Ki(), this.name = "", this.source = new Ql(e), this.mipmaps = [], this.mapping = t, this.channel = 0, this.wrapS = n, this.wrapT = r, this.magFilter = s, this.minFilter = a, this.anisotropy = c, this.format = o, this.internalFormat = null, this.type = l, this.offset = new me(0, 0), this.repeat = new me(1, 1), this.center = new me(0, 0), this.rotation = 0, this.matrixAutoUpdate = !0, this.matrix = new be(), this.generateMipmaps = !0, this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, this.colorSpace = u, this.userData = {}, this.version = 0, this.onUpdate = null, this.isRenderTargetTexture = !1, this.needsPMREMUpdate = !1; + } + get image() { + return this.source.data; + } + set image(e = null) { + this.source.data = e; + } + updateMatrix() { + this.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y); + } + clone() { + return new this.constructor().copy(this); + } + copy(e) { + return this.name = e.name, this.source = e.source, this.mipmaps = e.mipmaps.slice(0), this.mapping = e.mapping, this.channel = e.channel, this.wrapS = e.wrapS, this.wrapT = e.wrapT, this.magFilter = e.magFilter, this.minFilter = e.minFilter, this.anisotropy = e.anisotropy, this.format = e.format, this.internalFormat = e.internalFormat, this.type = e.type, this.offset.copy(e.offset), this.repeat.copy(e.repeat), this.center.copy(e.center), this.rotation = e.rotation, this.matrixAutoUpdate = e.matrixAutoUpdate, this.matrix.copy(e.matrix), this.generateMipmaps = e.generateMipmaps, this.premultiplyAlpha = e.premultiplyAlpha, this.flipY = e.flipY, this.unpackAlignment = e.unpackAlignment, this.colorSpace = e.colorSpace, this.userData = JSON.parse(JSON.stringify(e.userData)), this.needsUpdate = !0, this; + } + toJSON(e) { + const t = e === void 0 || typeof e == "string"; + if (!t && e.textures[this.uuid] !== void 0) + return e.textures[this.uuid]; + const n = { + metadata: { + version: 4.6, + type: "Texture", + generator: "Texture.toJSON" + }, + uuid: this.uuid, + name: this.name, + image: this.source.toJSON(e).uuid, + mapping: this.mapping, + channel: this.channel, + repeat: [this.repeat.x, this.repeat.y], + offset: [this.offset.x, this.offset.y], + center: [this.center.x, this.center.y], + rotation: this.rotation, + wrap: [this.wrapS, this.wrapT], + format: this.format, + internalFormat: this.internalFormat, + type: this.type, + colorSpace: this.colorSpace, + minFilter: this.minFilter, + magFilter: this.magFilter, + anisotropy: this.anisotropy, + flipY: this.flipY, + generateMipmaps: this.generateMipmaps, + premultiplyAlpha: this.premultiplyAlpha, + unpackAlignment: this.unpackAlignment + }; + return Object.keys(this.userData).length > 0 && (n.userData = this.userData), t || (e.textures[this.uuid] = n), n; + } + dispose() { + this.dispatchEvent({ type: "dispose" }); + } + transformUv(e) { + if (this.mapping !== kl) + return e; + if (e.applyMatrix3(this.matrix), e.x < 0 || e.x > 1) + switch (this.wrapS) { + case no: + e.x = e.x - Math.floor(e.x); + break; + case tn: + e.x = e.x < 0 ? 0 : 1; + break; + case io: + Math.abs(Math.floor(e.x) % 2) === 1 ? e.x = Math.ceil(e.x) - e.x : e.x = e.x - Math.floor(e.x); + break; + } + if (e.y < 0 || e.y > 1) + switch (this.wrapT) { + case no: + e.y = e.y - Math.floor(e.y); + break; + case tn: + e.y = e.y < 0 ? 0 : 1; + break; + case io: + Math.abs(Math.floor(e.y) % 2) === 1 ? e.y = Math.ceil(e.y) - e.y : e.y = e.y - Math.floor(e.y); + break; + } + return this.flipY && (e.y = 1 - e.y), e; + } + set needsUpdate(e) { + e === !0 && (this.version++, this.source.needsUpdate = !0); + } +} +Tt.DEFAULT_IMAGE = null; +Tt.DEFAULT_MAPPING = kl; +Tt.DEFAULT_ANISOTROPY = 1; +class ut { + constructor(e = 0, t = 0, n = 0, r = 1) { + ut.prototype.isVector4 = !0, this.x = e, this.y = t, this.z = n, this.w = r; + } + get width() { + return this.z; + } + set width(e) { + this.z = e; + } + get height() { + return this.w; + } + set height(e) { + this.w = e; + } + set(e, t, n, r) { + return this.x = e, this.y = t, this.z = n, this.w = r, this; + } + setScalar(e) { + return this.x = e, this.y = e, this.z = e, this.w = e, this; + } + setX(e) { + return this.x = e, this; + } + setY(e) { + return this.y = e, this; + } + setZ(e) { + return this.z = e, this; + } + setW(e) { + return this.w = e, this; + } + setComponent(e, t) { + switch (e) { + case 0: + this.x = t; + break; + case 1: + this.y = t; + break; + case 2: + this.z = t; + break; + case 3: + this.w = t; + break; + default: + throw new Error("index is out of range: " + e); + } + return this; + } + getComponent(e) { + switch (e) { + case 0: + return this.x; + case 1: + return this.y; + case 2: + return this.z; + case 3: + return this.w; + default: + throw new Error("index is out of range: " + e); + } + } + clone() { + return new this.constructor(this.x, this.y, this.z, this.w); + } + copy(e) { + return this.x = e.x, this.y = e.y, this.z = e.z, this.w = e.w !== void 0 ? e.w : 1, this; + } + add(e) { + return this.x += e.x, this.y += e.y, this.z += e.z, this.w += e.w, this; + } + addScalar(e) { + return this.x += e, this.y += e, this.z += e, this.w += e, this; + } + addVectors(e, t) { + return this.x = e.x + t.x, this.y = e.y + t.y, this.z = e.z + t.z, this.w = e.w + t.w, this; + } + addScaledVector(e, t) { + return this.x += e.x * t, this.y += e.y * t, this.z += e.z * t, this.w += e.w * t, this; + } + sub(e) { + return this.x -= e.x, this.y -= e.y, this.z -= e.z, this.w -= e.w, this; + } + subScalar(e) { + return this.x -= e, this.y -= e, this.z -= e, this.w -= e, this; + } + subVectors(e, t) { + return this.x = e.x - t.x, this.y = e.y - t.y, this.z = e.z - t.z, this.w = e.w - t.w, this; + } + multiply(e) { + return this.x *= e.x, this.y *= e.y, this.z *= e.z, this.w *= e.w, this; + } + multiplyScalar(e) { + return this.x *= e, this.y *= e, this.z *= e, this.w *= e, this; + } + applyMatrix4(e) { + const t = this.x, n = this.y, r = this.z, s = this.w, a = e.elements; + return this.x = a[0] * t + a[4] * n + a[8] * r + a[12] * s, this.y = a[1] * t + a[5] * n + a[9] * r + a[13] * s, this.z = a[2] * t + a[6] * n + a[10] * r + a[14] * s, this.w = a[3] * t + a[7] * n + a[11] * r + a[15] * s, this; + } + divideScalar(e) { + return this.multiplyScalar(1 / e); + } + setAxisAngleFromQuaternion(e) { + this.w = 2 * Math.acos(e.w); + const t = Math.sqrt(1 - e.w * e.w); + return t < 1e-4 ? (this.x = 1, this.y = 0, this.z = 0) : (this.x = e.x / t, this.y = e.y / t, this.z = e.z / t), this; + } + setAxisAngleFromRotationMatrix(e) { + let t, n, r, s; + const l = e.elements, c = l[0], u = l[4], f = l[8], h = l[1], p = l[5], g = l[9], v = l[2], m = l[6], d = l[10]; + if (Math.abs(u - h) < 0.01 && Math.abs(f - v) < 0.01 && Math.abs(g - m) < 0.01) { + if (Math.abs(u + h) < 0.1 && Math.abs(f + v) < 0.1 && Math.abs(g + m) < 0.1 && Math.abs(c + p + d - 3) < 0.1) + return this.set(1, 0, 0, 0), this; + t = Math.PI; + const _ = (c + 1) / 2, A = (p + 1) / 2, C = (d + 1) / 2, E = (u + h) / 4, b = (f + v) / 4, I = (g + m) / 4; + return _ > A && _ > C ? _ < 0.01 ? (n = 0, r = 0.707106781, s = 0.707106781) : (n = Math.sqrt(_), r = E / n, s = b / n) : A > C ? A < 0.01 ? (n = 0.707106781, r = 0, s = 0.707106781) : (r = Math.sqrt(A), n = E / r, s = I / r) : C < 0.01 ? (n = 0.707106781, r = 0.707106781, s = 0) : (s = Math.sqrt(C), n = b / s, r = I / s), this.set(n, r, s, t), this; + } + let M = Math.sqrt((m - g) * (m - g) + (f - v) * (f - v) + (h - u) * (h - u)); + return Math.abs(M) < 1e-3 && (M = 1), this.x = (m - g) / M, this.y = (f - v) / M, this.z = (h - u) / M, this.w = Math.acos((c + p + d - 1) / 2), this; + } + min(e) { + return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this.z = Math.min(this.z, e.z), this.w = Math.min(this.w, e.w), this; + } + max(e) { + return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this.z = Math.max(this.z, e.z), this.w = Math.max(this.w, e.w), this; + } + clamp(e, t) { + return this.x = Math.max(e.x, Math.min(t.x, this.x)), this.y = Math.max(e.y, Math.min(t.y, this.y)), this.z = Math.max(e.z, Math.min(t.z, this.z)), this.w = Math.max(e.w, Math.min(t.w, this.w)), this; + } + clampScalar(e, t) { + return this.x = Math.max(e, Math.min(t, this.x)), this.y = Math.max(e, Math.min(t, this.y)), this.z = Math.max(e, Math.min(t, this.z)), this.w = Math.max(e, Math.min(t, this.w)), this; + } + clampLength(e, t) { + const n = this.length(); + return this.divideScalar(n || 1).multiplyScalar(Math.max(e, Math.min(t, n))); + } + floor() { + return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.z = Math.floor(this.z), this.w = Math.floor(this.w), this; + } + ceil() { + return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this.z = Math.ceil(this.z), this.w = Math.ceil(this.w), this; + } + round() { + return this.x = Math.round(this.x), this.y = Math.round(this.y), this.z = Math.round(this.z), this.w = Math.round(this.w), this; + } + roundToZero() { + return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this.z = Math.trunc(this.z), this.w = Math.trunc(this.w), this; + } + negate() { + return this.x = -this.x, this.y = -this.y, this.z = -this.z, this.w = -this.w, this; + } + dot(e) { + return this.x * e.x + this.y * e.y + this.z * e.z + this.w * e.w; + } + lengthSq() { + return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w; + } + length() { + return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w); + } + manhattanLength() { + return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z) + Math.abs(this.w); + } + normalize() { + return this.divideScalar(this.length() || 1); + } + setLength(e) { + return this.normalize().multiplyScalar(e); + } + lerp(e, t) { + return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this.z += (e.z - this.z) * t, this.w += (e.w - this.w) * t, this; + } + lerpVectors(e, t, n) { + return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this.z = e.z + (t.z - e.z) * n, this.w = e.w + (t.w - e.w) * n, this; + } + equals(e) { + return e.x === this.x && e.y === this.y && e.z === this.z && e.w === this.w; + } + fromArray(e, t = 0) { + return this.x = e[t], this.y = e[t + 1], this.z = e[t + 2], this.w = e[t + 3], this; + } + toArray(e = [], t = 0) { + return e[t] = this.x, e[t + 1] = this.y, e[t + 2] = this.z, e[t + 3] = this.w, e; + } + fromBufferAttribute(e, t) { + return this.x = e.getX(t), this.y = e.getY(t), this.z = e.getZ(t), this.w = e.getW(t), this; + } + random() { + return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this.w = Math.random(), this; + } + *[Symbol.iterator]() { + yield this.x, yield this.y, yield this.z, yield this.w; + } +} +class Zf extends ui { + constructor(e = 1, t = 1, n = {}) { + super(), this.isRenderTarget = !0, this.width = e, this.height = t, this.depth = 1, this.scissor = new ut(0, 0, e, t), this.scissorTest = !1, this.viewport = new ut(0, 0, e, t); + const r = { width: e, height: t, depth: 1 }; + n = Object.assign({ + generateMipmaps: !1, + internalFormat: null, + minFilter: Ct, + depthBuffer: !0, + stencilBuffer: !1, + depthTexture: null, + samples: 0, + count: 1 + }, n); + const s = new Tt(r, n.mapping, n.wrapS, n.wrapT, n.magFilter, n.minFilter, n.format, n.type, n.anisotropy, n.colorSpace); + s.flipY = !1, s.generateMipmaps = n.generateMipmaps, s.internalFormat = n.internalFormat, this.textures = []; + const a = n.count; + for (let o = 0; o < a; o++) + this.textures[o] = s.clone(), this.textures[o].isRenderTargetTexture = !0; + this.depthBuffer = n.depthBuffer, this.stencilBuffer = n.stencilBuffer, this.depthTexture = n.depthTexture, this.samples = n.samples; + } + get texture() { + return this.textures[0]; + } + set texture(e) { + this.textures[0] = e; + } + setSize(e, t, n = 1) { + if (this.width !== e || this.height !== t || this.depth !== n) { + this.width = e, this.height = t, this.depth = n; + for (let r = 0, s = this.textures.length; r < s; r++) + this.textures[r].image.width = e, this.textures[r].image.height = t, this.textures[r].image.depth = n; + this.dispose(); + } + this.viewport.set(0, 0, e, t), this.scissor.set(0, 0, e, t); + } + clone() { + return new this.constructor().copy(this); + } + copy(e) { + this.width = e.width, this.height = e.height, this.depth = e.depth, this.scissor.copy(e.scissor), this.scissorTest = e.scissorTest, this.viewport.copy(e.viewport), this.textures.length = 0; + for (let n = 0, r = e.textures.length; n < r; n++) + this.textures[n] = e.textures[n].clone(), this.textures[n].isRenderTargetTexture = !0; + const t = Object.assign({}, e.texture.image); + return this.texture.source = new Ql(t), this.depthBuffer = e.depthBuffer, this.stencilBuffer = e.stencilBuffer, e.depthTexture !== null && (this.depthTexture = e.depthTexture.clone()), this.samples = e.samples, this; + } + dispose() { + this.dispatchEvent({ type: "dispose" }); + } +} +class Vn extends Zf { + constructor(e = 1, t = 1, n = {}) { + super(e, t, n), this.isWebGLRenderTarget = !0; + } +} +class Zl extends Tt { + constructor(e = null, t = 1, n = 1, r = 1) { + super(null), this.isDataArrayTexture = !0, this.image = { data: e, width: t, height: n, depth: r }, this.magFilter = vt, this.minFilter = vt, this.wrapR = tn, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1; + } +} +class Jf extends Tt { + constructor(e = null, t = 1, n = 1, r = 1) { + super(null), this.isData3DTexture = !0, this.image = { data: e, width: t, height: n, depth: r }, this.magFilter = vt, this.minFilter = vt, this.wrapR = tn, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1; + } +} +class wt { + constructor(e = 0, t = 0, n = 0, r = 1) { + this.isQuaternion = !0, this._x = e, this._y = t, this._z = n, this._w = r; + } + static slerpFlat(e, t, n, r, s, a, o) { + let l = n[r + 0], c = n[r + 1], u = n[r + 2], f = n[r + 3]; + const h = s[a + 0], p = s[a + 1], g = s[a + 2], v = s[a + 3]; + if (o === 0) { + e[t + 0] = l, e[t + 1] = c, e[t + 2] = u, e[t + 3] = f; + return; + } + if (o === 1) { + e[t + 0] = h, e[t + 1] = p, e[t + 2] = g, e[t + 3] = v; + return; + } + if (f !== v || l !== h || c !== p || u !== g) { + let m = 1 - o; + const d = l * h + c * p + u * g + f * v, M = d >= 0 ? 1 : -1, _ = 1 - d * d; + if (_ > Number.EPSILON) { + const C = Math.sqrt(_), E = Math.atan2(C, d * M); + m = Math.sin(m * E) / C, o = Math.sin(o * E) / C; + } + const A = o * M; + if (l = l * m + h * A, c = c * m + p * A, u = u * m + g * A, f = f * m + v * A, m === 1 - o) { + const C = 1 / Math.sqrt(l * l + c * c + u * u + f * f); + l *= C, c *= C, u *= C, f *= C; + } + } + e[t] = l, e[t + 1] = c, e[t + 2] = u, e[t + 3] = f; + } + static multiplyQuaternionsFlat(e, t, n, r, s, a) { + const o = n[r], l = n[r + 1], c = n[r + 2], u = n[r + 3], f = s[a], h = s[a + 1], p = s[a + 2], g = s[a + 3]; + return e[t] = o * g + u * f + l * p - c * h, e[t + 1] = l * g + u * h + c * f - o * p, e[t + 2] = c * g + u * p + o * h - l * f, e[t + 3] = u * g - o * f - l * h - c * p, e; + } + get x() { + return this._x; + } + set x(e) { + this._x = e, this._onChangeCallback(); + } + get y() { + return this._y; + } + set y(e) { + this._y = e, this._onChangeCallback(); + } + get z() { + return this._z; + } + set z(e) { + this._z = e, this._onChangeCallback(); + } + get w() { + return this._w; + } + set w(e) { + this._w = e, this._onChangeCallback(); + } + set(e, t, n, r) { + return this._x = e, this._y = t, this._z = n, this._w = r, this._onChangeCallback(), this; + } + clone() { + return new this.constructor(this._x, this._y, this._z, this._w); + } + copy(e) { + return this._x = e.x, this._y = e.y, this._z = e.z, this._w = e.w, this._onChangeCallback(), this; + } + setFromEuler(e, t = !0) { + const n = e._x, r = e._y, s = e._z, a = e._order, o = Math.cos, l = Math.sin, c = o(n / 2), u = o(r / 2), f = o(s / 2), h = l(n / 2), p = l(r / 2), g = l(s / 2); + switch (a) { + case "XYZ": + this._x = h * u * f + c * p * g, this._y = c * p * f - h * u * g, this._z = c * u * g + h * p * f, this._w = c * u * f - h * p * g; + break; + case "YXZ": + this._x = h * u * f + c * p * g, this._y = c * p * f - h * u * g, this._z = c * u * g - h * p * f, this._w = c * u * f + h * p * g; + break; + case "ZXY": + this._x = h * u * f - c * p * g, this._y = c * p * f + h * u * g, this._z = c * u * g + h * p * f, this._w = c * u * f - h * p * g; + break; + case "ZYX": + this._x = h * u * f - c * p * g, this._y = c * p * f + h * u * g, this._z = c * u * g - h * p * f, this._w = c * u * f + h * p * g; + break; + case "YZX": + this._x = h * u * f + c * p * g, this._y = c * p * f + h * u * g, this._z = c * u * g - h * p * f, this._w = c * u * f - h * p * g; + break; + case "XZY": + this._x = h * u * f - c * p * g, this._y = c * p * f - h * u * g, this._z = c * u * g + h * p * f, this._w = c * u * f + h * p * g; + break; + default: + console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: " + a); + } + return t === !0 && this._onChangeCallback(), this; + } + setFromAxisAngle(e, t) { + const n = t / 2, r = Math.sin(n); + return this._x = e.x * r, this._y = e.y * r, this._z = e.z * r, this._w = Math.cos(n), this._onChangeCallback(), this; + } + setFromRotationMatrix(e) { + const t = e.elements, n = t[0], r = t[4], s = t[8], a = t[1], o = t[5], l = t[9], c = t[2], u = t[6], f = t[10], h = n + o + f; + if (h > 0) { + const p = 0.5 / Math.sqrt(h + 1); + this._w = 0.25 / p, this._x = (u - l) * p, this._y = (s - c) * p, this._z = (a - r) * p; + } else if (n > o && n > f) { + const p = 2 * Math.sqrt(1 + n - o - f); + this._w = (u - l) / p, this._x = 0.25 * p, this._y = (r + a) / p, this._z = (s + c) / p; + } else if (o > f) { + const p = 2 * Math.sqrt(1 + o - n - f); + this._w = (s - c) / p, this._x = (r + a) / p, this._y = 0.25 * p, this._z = (l + u) / p; + } else { + const p = 2 * Math.sqrt(1 + f - n - o); + this._w = (a - r) / p, this._x = (s + c) / p, this._y = (l + u) / p, this._z = 0.25 * p; + } + return this._onChangeCallback(), this; + } + setFromUnitVectors(e, t) { + let n = e.dot(t) + 1; + return n < Number.EPSILON ? (n = 0, Math.abs(e.x) > Math.abs(e.z) ? (this._x = -e.y, this._y = e.x, this._z = 0, this._w = n) : (this._x = 0, this._y = -e.z, this._z = e.y, this._w = n)) : (this._x = e.y * t.z - e.z * t.y, this._y = e.z * t.x - e.x * t.z, this._z = e.x * t.y - e.y * t.x, this._w = n), this.normalize(); + } + angleTo(e) { + return 2 * Math.acos(Math.abs(xt(this.dot(e), -1, 1))); + } + rotateTowards(e, t) { + const n = this.angleTo(e); + if (n === 0) + return this; + const r = Math.min(1, t / n); + return this.slerp(e, r), this; + } + identity() { + return this.set(0, 0, 0, 1); + } + invert() { + return this.conjugate(); + } + conjugate() { + return this._x *= -1, this._y *= -1, this._z *= -1, this._onChangeCallback(), this; + } + dot(e) { + return this._x * e._x + this._y * e._y + this._z * e._z + this._w * e._w; + } + lengthSq() { + return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w; + } + length() { + return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w); + } + normalize() { + let e = this.length(); + return e === 0 ? (this._x = 0, this._y = 0, this._z = 0, this._w = 1) : (e = 1 / e, this._x = this._x * e, this._y = this._y * e, this._z = this._z * e, this._w = this._w * e), this._onChangeCallback(), this; + } + multiply(e) { + return this.multiplyQuaternions(this, e); + } + premultiply(e) { + return this.multiplyQuaternions(e, this); + } + multiplyQuaternions(e, t) { + const n = e._x, r = e._y, s = e._z, a = e._w, o = t._x, l = t._y, c = t._z, u = t._w; + return this._x = n * u + a * o + r * c - s * l, this._y = r * u + a * l + s * o - n * c, this._z = s * u + a * c + n * l - r * o, this._w = a * u - n * o - r * l - s * c, this._onChangeCallback(), this; + } + slerp(e, t) { + if (t === 0) + return this; + if (t === 1) + return this.copy(e); + const n = this._x, r = this._y, s = this._z, a = this._w; + let o = a * e._w + n * e._x + r * e._y + s * e._z; + if (o < 0 ? (this._w = -e._w, this._x = -e._x, this._y = -e._y, this._z = -e._z, o = -o) : this.copy(e), o >= 1) + return this._w = a, this._x = n, this._y = r, this._z = s, this; + const l = 1 - o * o; + if (l <= Number.EPSILON) { + const p = 1 - t; + return this._w = p * a + t * this._w, this._x = p * n + t * this._x, this._y = p * r + t * this._y, this._z = p * s + t * this._z, this.normalize(), this; + } + const c = Math.sqrt(l), u = Math.atan2(c, o), f = Math.sin((1 - t) * u) / c, h = Math.sin(t * u) / c; + return this._w = a * f + this._w * h, this._x = n * f + this._x * h, this._y = r * f + this._y * h, this._z = s * f + this._z * h, this._onChangeCallback(), this; + } + slerpQuaternions(e, t, n) { + return this.copy(e).slerp(t, n); + } + random() { + const e = 2 * Math.PI * Math.random(), t = 2 * Math.PI * Math.random(), n = Math.random(), r = Math.sqrt(1 - n), s = Math.sqrt(n); + return this.set( + r * Math.sin(e), + r * Math.cos(e), + s * Math.sin(t), + s * Math.cos(t) + ); + } + equals(e) { + return e._x === this._x && e._y === this._y && e._z === this._z && e._w === this._w; + } + fromArray(e, t = 0) { + return this._x = e[t], this._y = e[t + 1], this._z = e[t + 2], this._w = e[t + 3], this._onChangeCallback(), this; + } + toArray(e = [], t = 0) { + return e[t] = this._x, e[t + 1] = this._y, e[t + 2] = this._z, e[t + 3] = this._w, e; + } + fromBufferAttribute(e, t) { + return this._x = e.getX(t), this._y = e.getY(t), this._z = e.getZ(t), this._w = e.getW(t), this._onChangeCallback(), this; + } + toJSON() { + return this.toArray(); + } + _onChange(e) { + return this._onChangeCallback = e, this; + } + _onChangeCallback() { + } + *[Symbol.iterator]() { + yield this._x, yield this._y, yield this._z, yield this._w; + } +} +class P { + constructor(e = 0, t = 0, n = 0) { + P.prototype.isVector3 = !0, this.x = e, this.y = t, this.z = n; + } + set(e, t, n) { + return n === void 0 && (n = this.z), this.x = e, this.y = t, this.z = n, this; + } + setScalar(e) { + return this.x = e, this.y = e, this.z = e, this; + } + setX(e) { + return this.x = e, this; + } + setY(e) { + return this.y = e, this; + } + setZ(e) { + return this.z = e, this; + } + setComponent(e, t) { + switch (e) { + case 0: + this.x = t; + break; + case 1: + this.y = t; + break; + case 2: + this.z = t; + break; + default: + throw new Error("index is out of range: " + e); + } + return this; + } + getComponent(e) { + switch (e) { + case 0: + return this.x; + case 1: + return this.y; + case 2: + return this.z; + default: + throw new Error("index is out of range: " + e); + } + } + clone() { + return new this.constructor(this.x, this.y, this.z); + } + copy(e) { + return this.x = e.x, this.y = e.y, this.z = e.z, this; + } + add(e) { + return this.x += e.x, this.y += e.y, this.z += e.z, this; + } + addScalar(e) { + return this.x += e, this.y += e, this.z += e, this; + } + addVectors(e, t) { + return this.x = e.x + t.x, this.y = e.y + t.y, this.z = e.z + t.z, this; + } + addScaledVector(e, t) { + return this.x += e.x * t, this.y += e.y * t, this.z += e.z * t, this; + } + sub(e) { + return this.x -= e.x, this.y -= e.y, this.z -= e.z, this; + } + subScalar(e) { + return this.x -= e, this.y -= e, this.z -= e, this; + } + subVectors(e, t) { + return this.x = e.x - t.x, this.y = e.y - t.y, this.z = e.z - t.z, this; + } + multiply(e) { + return this.x *= e.x, this.y *= e.y, this.z *= e.z, this; + } + multiplyScalar(e) { + return this.x *= e, this.y *= e, this.z *= e, this; + } + multiplyVectors(e, t) { + return this.x = e.x * t.x, this.y = e.y * t.y, this.z = e.z * t.z, this; + } + applyEuler(e) { + return this.applyQuaternion(Sa.setFromEuler(e)); + } + applyAxisAngle(e, t) { + return this.applyQuaternion(Sa.setFromAxisAngle(e, t)); + } + applyMatrix3(e) { + const t = this.x, n = this.y, r = this.z, s = e.elements; + return this.x = s[0] * t + s[3] * n + s[6] * r, this.y = s[1] * t + s[4] * n + s[7] * r, this.z = s[2] * t + s[5] * n + s[8] * r, this; + } + applyNormalMatrix(e) { + return this.applyMatrix3(e).normalize(); + } + applyMatrix4(e) { + const t = this.x, n = this.y, r = this.z, s = e.elements, a = 1 / (s[3] * t + s[7] * n + s[11] * r + s[15]); + return this.x = (s[0] * t + s[4] * n + s[8] * r + s[12]) * a, this.y = (s[1] * t + s[5] * n + s[9] * r + s[13]) * a, this.z = (s[2] * t + s[6] * n + s[10] * r + s[14]) * a, this; + } + applyQuaternion(e) { + const t = this.x, n = this.y, r = this.z, s = e.x, a = e.y, o = e.z, l = e.w, c = 2 * (a * r - o * n), u = 2 * (o * t - s * r), f = 2 * (s * n - a * t); + return this.x = t + l * c + a * f - o * u, this.y = n + l * u + o * c - s * f, this.z = r + l * f + s * u - a * c, this; + } + project(e) { + return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix); + } + unproject(e) { + return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld); + } + transformDirection(e) { + const t = this.x, n = this.y, r = this.z, s = e.elements; + return this.x = s[0] * t + s[4] * n + s[8] * r, this.y = s[1] * t + s[5] * n + s[9] * r, this.z = s[2] * t + s[6] * n + s[10] * r, this.normalize(); + } + divide(e) { + return this.x /= e.x, this.y /= e.y, this.z /= e.z, this; + } + divideScalar(e) { + return this.multiplyScalar(1 / e); + } + min(e) { + return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this.z = Math.min(this.z, e.z), this; + } + max(e) { + return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this.z = Math.max(this.z, e.z), this; + } + clamp(e, t) { + return this.x = Math.max(e.x, Math.min(t.x, this.x)), this.y = Math.max(e.y, Math.min(t.y, this.y)), this.z = Math.max(e.z, Math.min(t.z, this.z)), this; + } + clampScalar(e, t) { + return this.x = Math.max(e, Math.min(t, this.x)), this.y = Math.max(e, Math.min(t, this.y)), this.z = Math.max(e, Math.min(t, this.z)), this; + } + clampLength(e, t) { + const n = this.length(); + return this.divideScalar(n || 1).multiplyScalar(Math.max(e, Math.min(t, n))); + } + floor() { + return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.z = Math.floor(this.z), this; + } + ceil() { + return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this.z = Math.ceil(this.z), this; + } + round() { + return this.x = Math.round(this.x), this.y = Math.round(this.y), this.z = Math.round(this.z), this; + } + roundToZero() { + return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this.z = Math.trunc(this.z), this; + } + negate() { + return this.x = -this.x, this.y = -this.y, this.z = -this.z, this; + } + dot(e) { + return this.x * e.x + this.y * e.y + this.z * e.z; + } + // TODO lengthSquared? + lengthSq() { + return this.x * this.x + this.y * this.y + this.z * this.z; + } + length() { + return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); + } + manhattanLength() { + return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z); + } + normalize() { + return this.divideScalar(this.length() || 1); + } + setLength(e) { + return this.normalize().multiplyScalar(e); + } + lerp(e, t) { + return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this.z += (e.z - this.z) * t, this; + } + lerpVectors(e, t, n) { + return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this.z = e.z + (t.z - e.z) * n, this; + } + cross(e) { + return this.crossVectors(this, e); + } + crossVectors(e, t) { + const n = e.x, r = e.y, s = e.z, a = t.x, o = t.y, l = t.z; + return this.x = r * l - s * o, this.y = s * a - n * l, this.z = n * o - r * a, this; + } + projectOnVector(e) { + const t = e.lengthSq(); + if (t === 0) + return this.set(0, 0, 0); + const n = e.dot(this) / t; + return this.copy(e).multiplyScalar(n); + } + projectOnPlane(e) { + return ws.copy(this).projectOnVector(e), this.sub(ws); + } + reflect(e) { + return this.sub(ws.copy(e).multiplyScalar(2 * this.dot(e))); + } + angleTo(e) { + const t = Math.sqrt(this.lengthSq() * e.lengthSq()); + if (t === 0) + return Math.PI / 2; + const n = this.dot(e) / t; + return Math.acos(xt(n, -1, 1)); + } + distanceTo(e) { + return Math.sqrt(this.distanceToSquared(e)); + } + distanceToSquared(e) { + const t = this.x - e.x, n = this.y - e.y, r = this.z - e.z; + return t * t + n * n + r * r; + } + manhattanDistanceTo(e) { + return Math.abs(this.x - e.x) + Math.abs(this.y - e.y) + Math.abs(this.z - e.z); + } + setFromSpherical(e) { + return this.setFromSphericalCoords(e.radius, e.phi, e.theta); + } + setFromSphericalCoords(e, t, n) { + const r = Math.sin(t) * e; + return this.x = r * Math.sin(n), this.y = Math.cos(t) * e, this.z = r * Math.cos(n), this; + } + setFromCylindrical(e) { + return this.setFromCylindricalCoords(e.radius, e.theta, e.y); + } + setFromCylindricalCoords(e, t, n) { + return this.x = e * Math.sin(t), this.y = n, this.z = e * Math.cos(t), this; + } + setFromMatrixPosition(e) { + const t = e.elements; + return this.x = t[12], this.y = t[13], this.z = t[14], this; + } + setFromMatrixScale(e) { + const t = this.setFromMatrixColumn(e, 0).length(), n = this.setFromMatrixColumn(e, 1).length(), r = this.setFromMatrixColumn(e, 2).length(); + return this.x = t, this.y = n, this.z = r, this; + } + setFromMatrixColumn(e, t) { + return this.fromArray(e.elements, t * 4); + } + setFromMatrix3Column(e, t) { + return this.fromArray(e.elements, t * 3); + } + setFromEuler(e) { + return this.x = e._x, this.y = e._y, this.z = e._z, this; + } + setFromColor(e) { + return this.x = e.r, this.y = e.g, this.z = e.b, this; + } + equals(e) { + return e.x === this.x && e.y === this.y && e.z === this.z; + } + fromArray(e, t = 0) { + return this.x = e[t], this.y = e[t + 1], this.z = e[t + 2], this; + } + toArray(e = [], t = 0) { + return e[t] = this.x, e[t + 1] = this.y, e[t + 2] = this.z, e; + } + fromBufferAttribute(e, t) { + return this.x = e.getX(t), this.y = e.getY(t), this.z = e.getZ(t), this; + } + random() { + return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this; + } + randomDirection() { + const e = Math.random() * Math.PI * 2, t = Math.random() * 2 - 1, n = Math.sqrt(1 - t * t); + return this.x = n * Math.cos(e), this.y = t, this.z = n * Math.sin(e), this; + } + *[Symbol.iterator]() { + yield this.x, yield this.y, yield this.z; + } +} +const ws = /* @__PURE__ */ new P(), Sa = /* @__PURE__ */ new wt(); +class Rt { + constructor(e = new P(1 / 0, 1 / 0, 1 / 0), t = new P(-1 / 0, -1 / 0, -1 / 0)) { + this.isBox3 = !0, this.min = e, this.max = t; + } + set(e, t) { + return this.min.copy(e), this.max.copy(t), this; + } + setFromArray(e) { + this.makeEmpty(); + for (let t = 0, n = e.length; t < n; t += 3) + this.expandByPoint(jt.fromArray(e, t)); + return this; + } + setFromBufferAttribute(e) { + this.makeEmpty(); + for (let t = 0, n = e.count; t < n; t++) + this.expandByPoint(jt.fromBufferAttribute(e, t)); + return this; + } + setFromPoints(e) { + this.makeEmpty(); + for (let t = 0, n = e.length; t < n; t++) + this.expandByPoint(e[t]); + return this; + } + setFromCenterAndSize(e, t) { + const n = jt.copy(t).multiplyScalar(0.5); + return this.min.copy(e).sub(n), this.max.copy(e).add(n), this; + } + setFromObject(e, t = !1) { + return this.makeEmpty(), this.expandByObject(e, t); + } + clone() { + return new this.constructor().copy(this); + } + copy(e) { + return this.min.copy(e.min), this.max.copy(e.max), this; + } + makeEmpty() { + return this.min.x = this.min.y = this.min.z = 1 / 0, this.max.x = this.max.y = this.max.z = -1 / 0, this; + } + isEmpty() { + return this.max.x < this.min.x || this.max.y < this.min.y || this.max.z < this.min.z; + } + getCenter(e) { + return this.isEmpty() ? e.set(0, 0, 0) : e.addVectors(this.min, this.max).multiplyScalar(0.5); + } + getSize(e) { + return this.isEmpty() ? e.set(0, 0, 0) : e.subVectors(this.max, this.min); + } + expandByPoint(e) { + return this.min.min(e), this.max.max(e), this; + } + expandByVector(e) { + return this.min.sub(e), this.max.add(e), this; + } + expandByScalar(e) { + return this.min.addScalar(-e), this.max.addScalar(e), this; + } + expandByObject(e, t = !1) { + e.updateWorldMatrix(!1, !1); + const n = e.geometry; + if (n !== void 0) { + const s = n.getAttribute("position"); + if (t === !0 && s !== void 0 && e.isInstancedMesh !== !0) + for (let a = 0, o = s.count; a < o; a++) + e.isMesh === !0 ? e.getVertexPosition(a, jt) : jt.fromBufferAttribute(s, a), jt.applyMatrix4(e.matrixWorld), this.expandByPoint(jt); + else + e.boundingBox !== void 0 ? (e.boundingBox === null && e.computeBoundingBox(), _r.copy(e.boundingBox)) : (n.boundingBox === null && n.computeBoundingBox(), _r.copy(n.boundingBox)), _r.applyMatrix4(e.matrixWorld), this.union(_r); + } + const r = e.children; + for (let s = 0, a = r.length; s < a; s++) + this.expandByObject(r[s], t); + return this; + } + containsPoint(e) { + return !(e.x < this.min.x || e.x > this.max.x || e.y < this.min.y || e.y > this.max.y || e.z < this.min.z || e.z > this.max.z); + } + containsBox(e) { + return this.min.x <= e.min.x && e.max.x <= this.max.x && this.min.y <= e.min.y && e.max.y <= this.max.y && this.min.z <= e.min.z && e.max.z <= this.max.z; + } + getParameter(e, t) { + return t.set( + (e.x - this.min.x) / (this.max.x - this.min.x), + (e.y - this.min.y) / (this.max.y - this.min.y), + (e.z - this.min.z) / (this.max.z - this.min.z) + ); + } + intersectsBox(e) { + return !(e.max.x < this.min.x || e.min.x > this.max.x || e.max.y < this.min.y || e.min.y > this.max.y || e.max.z < this.min.z || e.min.z > this.max.z); + } + intersectsSphere(e) { + return this.clampPoint(e.center, jt), jt.distanceToSquared(e.center) <= e.radius * e.radius; + } + intersectsPlane(e) { + let t, n; + return e.normal.x > 0 ? (t = e.normal.x * this.min.x, n = e.normal.x * this.max.x) : (t = e.normal.x * this.max.x, n = e.normal.x * this.min.x), e.normal.y > 0 ? (t += e.normal.y * this.min.y, n += e.normal.y * this.max.y) : (t += e.normal.y * this.max.y, n += e.normal.y * this.min.y), e.normal.z > 0 ? (t += e.normal.z * this.min.z, n += e.normal.z * this.max.z) : (t += e.normal.z * this.max.z, n += e.normal.z * this.min.z), t <= -e.constant && n >= -e.constant; + } + intersectsTriangle(e) { + if (this.isEmpty()) + return !1; + this.getCenter(tr), vr.subVectors(this.max, tr), mi.subVectors(e.a, tr), gi.subVectors(e.b, tr), _i.subVectors(e.c, tr), Rn.subVectors(gi, mi), Pn.subVectors(_i, gi), Yn.subVectors(mi, _i); + let t = [ + 0, + -Rn.z, + Rn.y, + 0, + -Pn.z, + Pn.y, + 0, + -Yn.z, + Yn.y, + Rn.z, + 0, + -Rn.x, + Pn.z, + 0, + -Pn.x, + Yn.z, + 0, + -Yn.x, + -Rn.y, + Rn.x, + 0, + -Pn.y, + Pn.x, + 0, + -Yn.y, + Yn.x, + 0 + ]; + return !Cs(t, mi, gi, _i, vr) || (t = [1, 0, 0, 0, 1, 0, 0, 0, 1], !Cs(t, mi, gi, _i, vr)) ? !1 : (xr.crossVectors(Rn, Pn), t = [xr.x, xr.y, xr.z], Cs(t, mi, gi, _i, vr)); + } + clampPoint(e, t) { + return t.copy(e).clamp(this.min, this.max); + } + distanceToPoint(e) { + return this.clampPoint(e, jt).distanceTo(e); + } + getBoundingSphere(e) { + return this.isEmpty() ? e.makeEmpty() : (this.getCenter(e.center), e.radius = this.getSize(jt).length() * 0.5), e; + } + intersect(e) { + return this.min.max(e.min), this.max.min(e.max), this.isEmpty() && this.makeEmpty(), this; + } + union(e) { + return this.min.min(e.min), this.max.max(e.max), this; + } + applyMatrix4(e) { + return this.isEmpty() ? this : (pn[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(e), pn[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(e), pn[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(e), pn[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(e), pn[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(e), pn[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(e), pn[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(e), pn[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(e), this.setFromPoints(pn), this); + } + translate(e) { + return this.min.add(e), this.max.add(e), this; + } + equals(e) { + return e.min.equals(this.min) && e.max.equals(this.max); + } +} +const pn = [ + /* @__PURE__ */ new P(), + /* @__PURE__ */ new P(), + /* @__PURE__ */ new P(), + /* @__PURE__ */ new P(), + /* @__PURE__ */ new P(), + /* @__PURE__ */ new P(), + /* @__PURE__ */ new P(), + /* @__PURE__ */ new P() +], jt = /* @__PURE__ */ new P(), _r = /* @__PURE__ */ new Rt(), mi = /* @__PURE__ */ new P(), gi = /* @__PURE__ */ new P(), _i = /* @__PURE__ */ new P(), Rn = /* @__PURE__ */ new P(), Pn = /* @__PURE__ */ new P(), Yn = /* @__PURE__ */ new P(), tr = /* @__PURE__ */ new P(), vr = /* @__PURE__ */ new P(), xr = /* @__PURE__ */ new P(), jn = /* @__PURE__ */ new P(); +function Cs(i, e, t, n, r) { + for (let s = 0, a = i.length - 3; s <= a; s += 3) { + jn.fromArray(i, s); + const o = r.x * Math.abs(jn.x) + r.y * Math.abs(jn.y) + r.z * Math.abs(jn.z), l = e.dot(jn), c = t.dot(jn), u = n.dot(jn); + if (Math.max(-Math.max(l, c, u), Math.min(l, c, u)) > o) + return !1; + } + return !0; +} +const $f = /* @__PURE__ */ new Rt(), nr = /* @__PURE__ */ new P(), Rs = /* @__PURE__ */ new P(); +class vo { + constructor(e = new P(), t = -1) { + this.isSphere = !0, this.center = e, this.radius = t; + } + set(e, t) { + return this.center.copy(e), this.radius = t, this; + } + setFromPoints(e, t) { + const n = this.center; + t !== void 0 ? n.copy(t) : $f.setFromPoints(e).getCenter(n); + let r = 0; + for (let s = 0, a = e.length; s < a; s++) + r = Math.max(r, n.distanceToSquared(e[s])); + return this.radius = Math.sqrt(r), this; + } + copy(e) { + return this.center.copy(e.center), this.radius = e.radius, this; + } + isEmpty() { + return this.radius < 0; + } + makeEmpty() { + return this.center.set(0, 0, 0), this.radius = -1, this; + } + containsPoint(e) { + return e.distanceToSquared(this.center) <= this.radius * this.radius; + } + distanceToPoint(e) { + return e.distanceTo(this.center) - this.radius; + } + intersectsSphere(e) { + const t = this.radius + e.radius; + return e.center.distanceToSquared(this.center) <= t * t; + } + intersectsBox(e) { + return e.intersectsSphere(this); + } + intersectsPlane(e) { + return Math.abs(e.distanceToPoint(this.center)) <= this.radius; + } + clampPoint(e, t) { + const n = this.center.distanceToSquared(e); + return t.copy(e), n > this.radius * this.radius && (t.sub(this.center).normalize(), t.multiplyScalar(this.radius).add(this.center)), t; + } + getBoundingBox(e) { + return this.isEmpty() ? (e.makeEmpty(), e) : (e.set(this.center, this.center), e.expandByScalar(this.radius), e); + } + applyMatrix4(e) { + return this.center.applyMatrix4(e), this.radius = this.radius * e.getMaxScaleOnAxis(), this; + } + translate(e) { + return this.center.add(e), this; + } + expandByPoint(e) { + if (this.isEmpty()) + return this.center.copy(e), this.radius = 0, this; + nr.subVectors(e, this.center); + const t = nr.lengthSq(); + if (t > this.radius * this.radius) { + const n = Math.sqrt(t), r = (n - this.radius) * 0.5; + this.center.addScaledVector(nr, r / n), this.radius += r; + } + return this; + } + union(e) { + return e.isEmpty() ? this : this.isEmpty() ? (this.copy(e), this) : (this.center.equals(e.center) === !0 ? this.radius = Math.max(this.radius, e.radius) : (Rs.subVectors(e.center, this.center).setLength(e.radius), this.expandByPoint(nr.copy(e.center).add(Rs)), this.expandByPoint(nr.copy(e.center).sub(Rs))), this); + } + equals(e) { + return e.center.equals(this.center) && e.radius === this.radius; + } + clone() { + return new this.constructor().copy(this); + } +} +const mn = /* @__PURE__ */ new P(), Ps = /* @__PURE__ */ new P(), Sr = /* @__PURE__ */ new P(), Ln = /* @__PURE__ */ new P(), Ls = /* @__PURE__ */ new P(), Mr = /* @__PURE__ */ new P(), Ds = /* @__PURE__ */ new P(); +let Jl = class { + constructor(e = new P(), t = new P(0, 0, -1)) { + this.origin = e, this.direction = t; + } + set(e, t) { + return this.origin.copy(e), this.direction.copy(t), this; + } + copy(e) { + return this.origin.copy(e.origin), this.direction.copy(e.direction), this; + } + at(e, t) { + return t.copy(this.origin).addScaledVector(this.direction, e); + } + lookAt(e) { + return this.direction.copy(e).sub(this.origin).normalize(), this; + } + recast(e) { + return this.origin.copy(this.at(e, mn)), this; + } + closestPointToPoint(e, t) { + t.subVectors(e, this.origin); + const n = t.dot(this.direction); + return n < 0 ? t.copy(this.origin) : t.copy(this.origin).addScaledVector(this.direction, n); + } + distanceToPoint(e) { + return Math.sqrt(this.distanceSqToPoint(e)); + } + distanceSqToPoint(e) { + const t = mn.subVectors(e, this.origin).dot(this.direction); + return t < 0 ? this.origin.distanceToSquared(e) : (mn.copy(this.origin).addScaledVector(this.direction, t), mn.distanceToSquared(e)); + } + distanceSqToSegment(e, t, n, r) { + Ps.copy(e).add(t).multiplyScalar(0.5), Sr.copy(t).sub(e).normalize(), Ln.copy(this.origin).sub(Ps); + const s = e.distanceTo(t) * 0.5, a = -this.direction.dot(Sr), o = Ln.dot(this.direction), l = -Ln.dot(Sr), c = Ln.lengthSq(), u = Math.abs(1 - a * a); + let f, h, p, g; + if (u > 0) + if (f = a * l - o, h = a * o - l, g = s * u, f >= 0) + if (h >= -g) + if (h <= g) { + const v = 1 / u; + f *= v, h *= v, p = f * (f + a * h + 2 * o) + h * (a * f + h + 2 * l) + c; + } else + h = s, f = Math.max(0, -(a * h + o)), p = -f * f + h * (h + 2 * l) + c; + else + h = -s, f = Math.max(0, -(a * h + o)), p = -f * f + h * (h + 2 * l) + c; + else + h <= -g ? (f = Math.max(0, -(-a * s + o)), h = f > 0 ? -s : Math.min(Math.max(-s, -l), s), p = -f * f + h * (h + 2 * l) + c) : h <= g ? (f = 0, h = Math.min(Math.max(-s, -l), s), p = h * (h + 2 * l) + c) : (f = Math.max(0, -(a * s + o)), h = f > 0 ? s : Math.min(Math.max(-s, -l), s), p = -f * f + h * (h + 2 * l) + c); + else + h = a > 0 ? -s : s, f = Math.max(0, -(a * h + o)), p = -f * f + h * (h + 2 * l) + c; + return n && n.copy(this.origin).addScaledVector(this.direction, f), r && r.copy(Ps).addScaledVector(Sr, h), p; + } + intersectSphere(e, t) { + mn.subVectors(e.center, this.origin); + const n = mn.dot(this.direction), r = mn.dot(mn) - n * n, s = e.radius * e.radius; + if (r > s) + return null; + const a = Math.sqrt(s - r), o = n - a, l = n + a; + return l < 0 ? null : o < 0 ? this.at(l, t) : this.at(o, t); + } + intersectsSphere(e) { + return this.distanceSqToPoint(e.center) <= e.radius * e.radius; + } + distanceToPlane(e) { + const t = e.normal.dot(this.direction); + if (t === 0) + return e.distanceToPoint(this.origin) === 0 ? 0 : null; + const n = -(this.origin.dot(e.normal) + e.constant) / t; + return n >= 0 ? n : null; + } + intersectPlane(e, t) { + const n = this.distanceToPlane(e); + return n === null ? null : this.at(n, t); + } + intersectsPlane(e) { + const t = e.distanceToPoint(this.origin); + return t === 0 || e.normal.dot(this.direction) * t < 0; + } + intersectBox(e, t) { + let n, r, s, a, o, l; + const c = 1 / this.direction.x, u = 1 / this.direction.y, f = 1 / this.direction.z, h = this.origin; + return c >= 0 ? (n = (e.min.x - h.x) * c, r = (e.max.x - h.x) * c) : (n = (e.max.x - h.x) * c, r = (e.min.x - h.x) * c), u >= 0 ? (s = (e.min.y - h.y) * u, a = (e.max.y - h.y) * u) : (s = (e.max.y - h.y) * u, a = (e.min.y - h.y) * u), n > a || s > r || ((s > n || isNaN(n)) && (n = s), (a < r || isNaN(r)) && (r = a), f >= 0 ? (o = (e.min.z - h.z) * f, l = (e.max.z - h.z) * f) : (o = (e.max.z - h.z) * f, l = (e.min.z - h.z) * f), n > l || o > r) || ((o > n || n !== n) && (n = o), (l < r || r !== r) && (r = l), r < 0) ? null : this.at(n >= 0 ? n : r, t); + } + intersectsBox(e) { + return this.intersectBox(e, mn) !== null; + } + intersectTriangle(e, t, n, r, s) { + Ls.subVectors(t, e), Mr.subVectors(n, e), Ds.crossVectors(Ls, Mr); + let a = this.direction.dot(Ds), o; + if (a > 0) { + if (r) + return null; + o = 1; + } else if (a < 0) + o = -1, a = -a; + else + return null; + Ln.subVectors(this.origin, e); + const l = o * this.direction.dot(Mr.crossVectors(Ln, Mr)); + if (l < 0) + return null; + const c = o * this.direction.dot(Ls.cross(Ln)); + if (c < 0 || l + c > a) + return null; + const u = -o * Ln.dot(Ds); + return u < 0 ? null : this.at(u / a, s); + } + applyMatrix4(e) { + return this.origin.applyMatrix4(e), this.direction.transformDirection(e), this; + } + equals(e) { + return e.origin.equals(this.origin) && e.direction.equals(this.direction); + } + clone() { + return new this.constructor().copy(this); + } +}; +class ke { + constructor(e, t, n, r, s, a, o, l, c, u, f, h, p, g, v, m) { + ke.prototype.isMatrix4 = !0, this.elements = [ + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1 + ], e !== void 0 && this.set(e, t, n, r, s, a, o, l, c, u, f, h, p, g, v, m); + } + set(e, t, n, r, s, a, o, l, c, u, f, h, p, g, v, m) { + const d = this.elements; + return d[0] = e, d[4] = t, d[8] = n, d[12] = r, d[1] = s, d[5] = a, d[9] = o, d[13] = l, d[2] = c, d[6] = u, d[10] = f, d[14] = h, d[3] = p, d[7] = g, d[11] = v, d[15] = m, this; + } + identity() { + return this.set( + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1 + ), this; + } + clone() { + return new ke().fromArray(this.elements); + } + copy(e) { + const t = this.elements, n = e.elements; + return t[0] = n[0], t[1] = n[1], t[2] = n[2], t[3] = n[3], t[4] = n[4], t[5] = n[5], t[6] = n[6], t[7] = n[7], t[8] = n[8], t[9] = n[9], t[10] = n[10], t[11] = n[11], t[12] = n[12], t[13] = n[13], t[14] = n[14], t[15] = n[15], this; + } + copyPosition(e) { + const t = this.elements, n = e.elements; + return t[12] = n[12], t[13] = n[13], t[14] = n[14], this; + } + setFromMatrix3(e) { + const t = e.elements; + return this.set( + t[0], + t[3], + t[6], + 0, + t[1], + t[4], + t[7], + 0, + t[2], + t[5], + t[8], + 0, + 0, + 0, + 0, + 1 + ), this; + } + extractBasis(e, t, n) { + return e.setFromMatrixColumn(this, 0), t.setFromMatrixColumn(this, 1), n.setFromMatrixColumn(this, 2), this; + } + makeBasis(e, t, n) { + return this.set( + e.x, + t.x, + n.x, + 0, + e.y, + t.y, + n.y, + 0, + e.z, + t.z, + n.z, + 0, + 0, + 0, + 0, + 1 + ), this; + } + extractRotation(e) { + const t = this.elements, n = e.elements, r = 1 / vi.setFromMatrixColumn(e, 0).length(), s = 1 / vi.setFromMatrixColumn(e, 1).length(), a = 1 / vi.setFromMatrixColumn(e, 2).length(); + return t[0] = n[0] * r, t[1] = n[1] * r, t[2] = n[2] * r, t[3] = 0, t[4] = n[4] * s, t[5] = n[5] * s, t[6] = n[6] * s, t[7] = 0, t[8] = n[8] * a, t[9] = n[9] * a, t[10] = n[10] * a, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1, this; + } + makeRotationFromEuler(e) { + const t = this.elements, n = e.x, r = e.y, s = e.z, a = Math.cos(n), o = Math.sin(n), l = Math.cos(r), c = Math.sin(r), u = Math.cos(s), f = Math.sin(s); + if (e.order === "XYZ") { + const h = a * u, p = a * f, g = o * u, v = o * f; + t[0] = l * u, t[4] = -l * f, t[8] = c, t[1] = p + g * c, t[5] = h - v * c, t[9] = -o * l, t[2] = v - h * c, t[6] = g + p * c, t[10] = a * l; + } else if (e.order === "YXZ") { + const h = l * u, p = l * f, g = c * u, v = c * f; + t[0] = h + v * o, t[4] = g * o - p, t[8] = a * c, t[1] = a * f, t[5] = a * u, t[9] = -o, t[2] = p * o - g, t[6] = v + h * o, t[10] = a * l; + } else if (e.order === "ZXY") { + const h = l * u, p = l * f, g = c * u, v = c * f; + t[0] = h - v * o, t[4] = -a * f, t[8] = g + p * o, t[1] = p + g * o, t[5] = a * u, t[9] = v - h * o, t[2] = -a * c, t[6] = o, t[10] = a * l; + } else if (e.order === "ZYX") { + const h = a * u, p = a * f, g = o * u, v = o * f; + t[0] = l * u, t[4] = g * c - p, t[8] = h * c + v, t[1] = l * f, t[5] = v * c + h, t[9] = p * c - g, t[2] = -c, t[6] = o * l, t[10] = a * l; + } else if (e.order === "YZX") { + const h = a * l, p = a * c, g = o * l, v = o * c; + t[0] = l * u, t[4] = v - h * f, t[8] = g * f + p, t[1] = f, t[5] = a * u, t[9] = -o * u, t[2] = -c * u, t[6] = p * f + g, t[10] = h - v * f; + } else if (e.order === "XZY") { + const h = a * l, p = a * c, g = o * l, v = o * c; + t[0] = l * u, t[4] = -f, t[8] = c * u, t[1] = h * f + v, t[5] = a * u, t[9] = p * f - g, t[2] = g * f - p, t[6] = o * u, t[10] = v * f + h; + } + return t[3] = 0, t[7] = 0, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1, this; + } + makeRotationFromQuaternion(e) { + return this.compose(eh, e, th); + } + lookAt(e, t, n) { + const r = this.elements; + return It.subVectors(e, t), It.lengthSq() === 0 && (It.z = 1), It.normalize(), Dn.crossVectors(n, It), Dn.lengthSq() === 0 && (Math.abs(n.z) === 1 ? It.x += 1e-4 : It.z += 1e-4, It.normalize(), Dn.crossVectors(n, It)), Dn.normalize(), yr.crossVectors(It, Dn), r[0] = Dn.x, r[4] = yr.x, r[8] = It.x, r[1] = Dn.y, r[5] = yr.y, r[9] = It.y, r[2] = Dn.z, r[6] = yr.z, r[10] = It.z, this; + } + multiply(e) { + return this.multiplyMatrices(this, e); + } + premultiply(e) { + return this.multiplyMatrices(e, this); + } + multiplyMatrices(e, t) { + const n = e.elements, r = t.elements, s = this.elements, a = n[0], o = n[4], l = n[8], c = n[12], u = n[1], f = n[5], h = n[9], p = n[13], g = n[2], v = n[6], m = n[10], d = n[14], M = n[3], _ = n[7], A = n[11], C = n[15], E = r[0], b = r[4], I = r[8], W = r[12], S = r[1], T = r[5], Y = r[9], K = r[13], L = r[2], N = r[6], O = r[10], B = r[14], j = r[3], q = r[7], J = r[11], ne = r[15]; + return s[0] = a * E + o * S + l * L + c * j, s[4] = a * b + o * T + l * N + c * q, s[8] = a * I + o * Y + l * O + c * J, s[12] = a * W + o * K + l * B + c * ne, s[1] = u * E + f * S + h * L + p * j, s[5] = u * b + f * T + h * N + p * q, s[9] = u * I + f * Y + h * O + p * J, s[13] = u * W + f * K + h * B + p * ne, s[2] = g * E + v * S + m * L + d * j, s[6] = g * b + v * T + m * N + d * q, s[10] = g * I + v * Y + m * O + d * J, s[14] = g * W + v * K + m * B + d * ne, s[3] = M * E + _ * S + A * L + C * j, s[7] = M * b + _ * T + A * N + C * q, s[11] = M * I + _ * Y + A * O + C * J, s[15] = M * W + _ * K + A * B + C * ne, this; + } + multiplyScalar(e) { + const t = this.elements; + return t[0] *= e, t[4] *= e, t[8] *= e, t[12] *= e, t[1] *= e, t[5] *= e, t[9] *= e, t[13] *= e, t[2] *= e, t[6] *= e, t[10] *= e, t[14] *= e, t[3] *= e, t[7] *= e, t[11] *= e, t[15] *= e, this; + } + determinant() { + const e = this.elements, t = e[0], n = e[4], r = e[8], s = e[12], a = e[1], o = e[5], l = e[9], c = e[13], u = e[2], f = e[6], h = e[10], p = e[14], g = e[3], v = e[7], m = e[11], d = e[15]; + return g * (+s * l * f - r * c * f - s * o * h + n * c * h + r * o * p - n * l * p) + v * (+t * l * p - t * c * h + s * a * h - r * a * p + r * c * u - s * l * u) + m * (+t * c * f - t * o * p - s * a * f + n * a * p + s * o * u - n * c * u) + d * (-r * o * u - t * l * f + t * o * h + r * a * f - n * a * h + n * l * u); + } + transpose() { + const e = this.elements; + let t; + return t = e[1], e[1] = e[4], e[4] = t, t = e[2], e[2] = e[8], e[8] = t, t = e[6], e[6] = e[9], e[9] = t, t = e[3], e[3] = e[12], e[12] = t, t = e[7], e[7] = e[13], e[13] = t, t = e[11], e[11] = e[14], e[14] = t, this; + } + setPosition(e, t, n) { + const r = this.elements; + return e.isVector3 ? (r[12] = e.x, r[13] = e.y, r[14] = e.z) : (r[12] = e, r[13] = t, r[14] = n), this; + } + invert() { + const e = this.elements, t = e[0], n = e[1], r = e[2], s = e[3], a = e[4], o = e[5], l = e[6], c = e[7], u = e[8], f = e[9], h = e[10], p = e[11], g = e[12], v = e[13], m = e[14], d = e[15], M = f * m * c - v * h * c + v * l * p - o * m * p - f * l * d + o * h * d, _ = g * h * c - u * m * c - g * l * p + a * m * p + u * l * d - a * h * d, A = u * v * c - g * f * c + g * o * p - a * v * p - u * o * d + a * f * d, C = g * f * l - u * v * l - g * o * h + a * v * h + u * o * m - a * f * m, E = t * M + n * _ + r * A + s * C; + if (E === 0) + return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + const b = 1 / E; + return e[0] = M * b, e[1] = (v * h * s - f * m * s - v * r * p + n * m * p + f * r * d - n * h * d) * b, e[2] = (o * m * s - v * l * s + v * r * c - n * m * c - o * r * d + n * l * d) * b, e[3] = (f * l * s - o * h * s - f * r * c + n * h * c + o * r * p - n * l * p) * b, e[4] = _ * b, e[5] = (u * m * s - g * h * s + g * r * p - t * m * p - u * r * d + t * h * d) * b, e[6] = (g * l * s - a * m * s - g * r * c + t * m * c + a * r * d - t * l * d) * b, e[7] = (a * h * s - u * l * s + u * r * c - t * h * c - a * r * p + t * l * p) * b, e[8] = A * b, e[9] = (g * f * s - u * v * s - g * n * p + t * v * p + u * n * d - t * f * d) * b, e[10] = (a * v * s - g * o * s + g * n * c - t * v * c - a * n * d + t * o * d) * b, e[11] = (u * o * s - a * f * s - u * n * c + t * f * c + a * n * p - t * o * p) * b, e[12] = C * b, e[13] = (u * v * r - g * f * r + g * n * h - t * v * h - u * n * m + t * f * m) * b, e[14] = (g * o * r - a * v * r - g * n * l + t * v * l + a * n * m - t * o * m) * b, e[15] = (a * f * r - u * o * r + u * n * l - t * f * l - a * n * h + t * o * h) * b, this; + } + scale(e) { + const t = this.elements, n = e.x, r = e.y, s = e.z; + return t[0] *= n, t[4] *= r, t[8] *= s, t[1] *= n, t[5] *= r, t[9] *= s, t[2] *= n, t[6] *= r, t[10] *= s, t[3] *= n, t[7] *= r, t[11] *= s, this; + } + getMaxScaleOnAxis() { + const e = this.elements, t = e[0] * e[0] + e[1] * e[1] + e[2] * e[2], n = e[4] * e[4] + e[5] * e[5] + e[6] * e[6], r = e[8] * e[8] + e[9] * e[9] + e[10] * e[10]; + return Math.sqrt(Math.max(t, n, r)); + } + makeTranslation(e, t, n) { + return e.isVector3 ? this.set( + 1, + 0, + 0, + e.x, + 0, + 1, + 0, + e.y, + 0, + 0, + 1, + e.z, + 0, + 0, + 0, + 1 + ) : this.set( + 1, + 0, + 0, + e, + 0, + 1, + 0, + t, + 0, + 0, + 1, + n, + 0, + 0, + 0, + 1 + ), this; + } + makeRotationX(e) { + const t = Math.cos(e), n = Math.sin(e); + return this.set( + 1, + 0, + 0, + 0, + 0, + t, + -n, + 0, + 0, + n, + t, + 0, + 0, + 0, + 0, + 1 + ), this; + } + makeRotationY(e) { + const t = Math.cos(e), n = Math.sin(e); + return this.set( + t, + 0, + n, + 0, + 0, + 1, + 0, + 0, + -n, + 0, + t, + 0, + 0, + 0, + 0, + 1 + ), this; + } + makeRotationZ(e) { + const t = Math.cos(e), n = Math.sin(e); + return this.set( + t, + -n, + 0, + 0, + n, + t, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1 + ), this; + } + makeRotationAxis(e, t) { + const n = Math.cos(t), r = Math.sin(t), s = 1 - n, a = e.x, o = e.y, l = e.z, c = s * a, u = s * o; + return this.set( + c * a + n, + c * o - r * l, + c * l + r * o, + 0, + c * o + r * l, + u * o + n, + u * l - r * a, + 0, + c * l - r * o, + u * l + r * a, + s * l * l + n, + 0, + 0, + 0, + 0, + 1 + ), this; + } + makeScale(e, t, n) { + return this.set( + e, + 0, + 0, + 0, + 0, + t, + 0, + 0, + 0, + 0, + n, + 0, + 0, + 0, + 0, + 1 + ), this; + } + makeShear(e, t, n, r, s, a) { + return this.set( + 1, + n, + s, + 0, + e, + 1, + a, + 0, + t, + r, + 1, + 0, + 0, + 0, + 0, + 1 + ), this; + } + compose(e, t, n) { + const r = this.elements, s = t._x, a = t._y, o = t._z, l = t._w, c = s + s, u = a + a, f = o + o, h = s * c, p = s * u, g = s * f, v = a * u, m = a * f, d = o * f, M = l * c, _ = l * u, A = l * f, C = n.x, E = n.y, b = n.z; + return r[0] = (1 - (v + d)) * C, r[1] = (p + A) * C, r[2] = (g - _) * C, r[3] = 0, r[4] = (p - A) * E, r[5] = (1 - (h + d)) * E, r[6] = (m + M) * E, r[7] = 0, r[8] = (g + _) * b, r[9] = (m - M) * b, r[10] = (1 - (h + v)) * b, r[11] = 0, r[12] = e.x, r[13] = e.y, r[14] = e.z, r[15] = 1, this; + } + decompose(e, t, n) { + const r = this.elements; + let s = vi.set(r[0], r[1], r[2]).length(); + const a = vi.set(r[4], r[5], r[6]).length(), o = vi.set(r[8], r[9], r[10]).length(); + this.determinant() < 0 && (s = -s), e.x = r[12], e.y = r[13], e.z = r[14], Kt.copy(this); + const c = 1 / s, u = 1 / a, f = 1 / o; + return Kt.elements[0] *= c, Kt.elements[1] *= c, Kt.elements[2] *= c, Kt.elements[4] *= u, Kt.elements[5] *= u, Kt.elements[6] *= u, Kt.elements[8] *= f, Kt.elements[9] *= f, Kt.elements[10] *= f, t.setFromRotationMatrix(Kt), n.x = s, n.y = a, n.z = o, this; + } + makePerspective(e, t, n, r, s, a, o = Mn) { + const l = this.elements, c = 2 * s / (t - e), u = 2 * s / (n - r), f = (t + e) / (t - e), h = (n + r) / (n - r); + let p, g; + if (o === Mn) + p = -(a + s) / (a - s), g = -2 * a * s / (a - s); + else if (o === Qr) + p = -a / (a - s), g = -a * s / (a - s); + else + throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: " + o); + return l[0] = c, l[4] = 0, l[8] = f, l[12] = 0, l[1] = 0, l[5] = u, l[9] = h, l[13] = 0, l[2] = 0, l[6] = 0, l[10] = p, l[14] = g, l[3] = 0, l[7] = 0, l[11] = -1, l[15] = 0, this; + } + makeOrthographic(e, t, n, r, s, a, o = Mn) { + const l = this.elements, c = 1 / (t - e), u = 1 / (n - r), f = 1 / (a - s), h = (t + e) * c, p = (n + r) * u; + let g, v; + if (o === Mn) + g = (a + s) * f, v = -2 * f; + else if (o === Qr) + g = s * f, v = -1 * f; + else + throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: " + o); + return l[0] = 2 * c, l[4] = 0, l[8] = 0, l[12] = -h, l[1] = 0, l[5] = 2 * u, l[9] = 0, l[13] = -p, l[2] = 0, l[6] = 0, l[10] = v, l[14] = -g, l[3] = 0, l[7] = 0, l[11] = 0, l[15] = 1, this; + } + equals(e) { + const t = this.elements, n = e.elements; + for (let r = 0; r < 16; r++) + if (t[r] !== n[r]) + return !1; + return !0; + } + fromArray(e, t = 0) { + for (let n = 0; n < 16; n++) + this.elements[n] = e[n + t]; + return this; + } + toArray(e = [], t = 0) { + const n = this.elements; + return e[t] = n[0], e[t + 1] = n[1], e[t + 2] = n[2], e[t + 3] = n[3], e[t + 4] = n[4], e[t + 5] = n[5], e[t + 6] = n[6], e[t + 7] = n[7], e[t + 8] = n[8], e[t + 9] = n[9], e[t + 10] = n[10], e[t + 11] = n[11], e[t + 12] = n[12], e[t + 13] = n[13], e[t + 14] = n[14], e[t + 15] = n[15], e; + } +} +const vi = /* @__PURE__ */ new P(), Kt = /* @__PURE__ */ new ke(), eh = /* @__PURE__ */ new P(0, 0, 0), th = /* @__PURE__ */ new P(1, 1, 1), Dn = /* @__PURE__ */ new P(), yr = /* @__PURE__ */ new P(), It = /* @__PURE__ */ new P(), Ma = /* @__PURE__ */ new ke(), ya = /* @__PURE__ */ new wt(); +class bn { + constructor(e = 0, t = 0, n = 0, r = bn.DEFAULT_ORDER) { + this.isEuler = !0, this._x = e, this._y = t, this._z = n, this._order = r; + } + get x() { + return this._x; + } + set x(e) { + this._x = e, this._onChangeCallback(); + } + get y() { + return this._y; + } + set y(e) { + this._y = e, this._onChangeCallback(); + } + get z() { + return this._z; + } + set z(e) { + this._z = e, this._onChangeCallback(); + } + get order() { + return this._order; + } + set order(e) { + this._order = e, this._onChangeCallback(); + } + set(e, t, n, r = this._order) { + return this._x = e, this._y = t, this._z = n, this._order = r, this._onChangeCallback(), this; + } + clone() { + return new this.constructor(this._x, this._y, this._z, this._order); + } + copy(e) { + return this._x = e._x, this._y = e._y, this._z = e._z, this._order = e._order, this._onChangeCallback(), this; + } + setFromRotationMatrix(e, t = this._order, n = !0) { + const r = e.elements, s = r[0], a = r[4], o = r[8], l = r[1], c = r[5], u = r[9], f = r[2], h = r[6], p = r[10]; + switch (t) { + case "XYZ": + this._y = Math.asin(xt(o, -1, 1)), Math.abs(o) < 0.9999999 ? (this._x = Math.atan2(-u, p), this._z = Math.atan2(-a, s)) : (this._x = Math.atan2(h, c), this._z = 0); + break; + case "YXZ": + this._x = Math.asin(-xt(u, -1, 1)), Math.abs(u) < 0.9999999 ? (this._y = Math.atan2(o, p), this._z = Math.atan2(l, c)) : (this._y = Math.atan2(-f, s), this._z = 0); + break; + case "ZXY": + this._x = Math.asin(xt(h, -1, 1)), Math.abs(h) < 0.9999999 ? (this._y = Math.atan2(-f, p), this._z = Math.atan2(-a, c)) : (this._y = 0, this._z = Math.atan2(l, s)); + break; + case "ZYX": + this._y = Math.asin(-xt(f, -1, 1)), Math.abs(f) < 0.9999999 ? (this._x = Math.atan2(h, p), this._z = Math.atan2(l, s)) : (this._x = 0, this._z = Math.atan2(-a, c)); + break; + case "YZX": + this._z = Math.asin(xt(l, -1, 1)), Math.abs(l) < 0.9999999 ? (this._x = Math.atan2(-u, c), this._y = Math.atan2(-f, s)) : (this._x = 0, this._y = Math.atan2(o, p)); + break; + case "XZY": + this._z = Math.asin(-xt(a, -1, 1)), Math.abs(a) < 0.9999999 ? (this._x = Math.atan2(h, c), this._y = Math.atan2(o, s)) : (this._x = Math.atan2(-u, p), this._y = 0); + break; + default: + console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: " + t); + } + return this._order = t, n === !0 && this._onChangeCallback(), this; + } + setFromQuaternion(e, t, n) { + return Ma.makeRotationFromQuaternion(e), this.setFromRotationMatrix(Ma, t, n); + } + setFromVector3(e, t = this._order) { + return this.set(e.x, e.y, e.z, t); + } + reorder(e) { + return ya.setFromEuler(this), this.setFromQuaternion(ya, e); + } + equals(e) { + return e._x === this._x && e._y === this._y && e._z === this._z && e._order === this._order; + } + fromArray(e) { + return this._x = e[0], this._y = e[1], this._z = e[2], e[3] !== void 0 && (this._order = e[3]), this._onChangeCallback(), this; + } + toArray(e = [], t = 0) { + return e[t] = this._x, e[t + 1] = this._y, e[t + 2] = this._z, e[t + 3] = this._order, e; + } + _onChange(e) { + return this._onChangeCallback = e, this; + } + _onChangeCallback() { + } + *[Symbol.iterator]() { + yield this._x, yield this._y, yield this._z, yield this._order; + } +} +bn.DEFAULT_ORDER = "XYZ"; +class $l { + constructor() { + this.mask = 1; + } + set(e) { + this.mask = (1 << e | 0) >>> 0; + } + enable(e) { + this.mask |= 1 << e | 0; + } + enableAll() { + this.mask = -1; + } + toggle(e) { + this.mask ^= 1 << e | 0; + } + disable(e) { + this.mask &= ~(1 << e | 0); + } + disableAll() { + this.mask = 0; + } + test(e) { + return (this.mask & e.mask) !== 0; + } + isEnabled(e) { + return (this.mask & (1 << e | 0)) !== 0; + } +} +let nh = 0; +const Aa = /* @__PURE__ */ new P(), xi = /* @__PURE__ */ new wt(), gn = /* @__PURE__ */ new ke(), Ar = /* @__PURE__ */ new P(), ir = /* @__PURE__ */ new P(), ih = /* @__PURE__ */ new P(), rh = /* @__PURE__ */ new wt(), Ea = /* @__PURE__ */ new P(1, 0, 0), ba = /* @__PURE__ */ new P(0, 1, 0), Ta = /* @__PURE__ */ new P(0, 0, 1), sh = { type: "added" }, oh = { type: "removed" }, Is = { type: "childadded", child: null }, Us = { type: "childremoved", child: null }; +class gt extends ui { + constructor() { + super(), this.isObject3D = !0, Object.defineProperty(this, "id", { value: nh++ }), this.uuid = Ki(), this.name = "", this.type = "Object3D", this.parent = null, this.children = [], this.up = gt.DEFAULT_UP.clone(); + const e = new P(), t = new bn(), n = new wt(), r = new P(1, 1, 1); + function s() { + n.setFromEuler(t, !1); + } + function a() { + t.setFromQuaternion(n, void 0, !1); + } + t._onChange(s), n._onChange(a), Object.defineProperties(this, { + position: { + configurable: !0, + enumerable: !0, + value: e + }, + rotation: { + configurable: !0, + enumerable: !0, + value: t + }, + quaternion: { + configurable: !0, + enumerable: !0, + value: n + }, + scale: { + configurable: !0, + enumerable: !0, + value: r + }, + modelViewMatrix: { + value: new ke() + }, + normalMatrix: { + value: new be() + } + }), this.matrix = new ke(), this.matrixWorld = new ke(), this.matrixAutoUpdate = gt.DEFAULT_MATRIX_AUTO_UPDATE, this.matrixWorldAutoUpdate = gt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE, this.matrixWorldNeedsUpdate = !1, this.layers = new $l(), this.visible = !0, this.castShadow = !1, this.receiveShadow = !1, this.frustumCulled = !0, this.renderOrder = 0, this.animations = [], this.userData = {}; + } + onBeforeShadow() { + } + onAfterShadow() { + } + onBeforeRender() { + } + onAfterRender() { + } + applyMatrix4(e) { + this.matrixAutoUpdate && this.updateMatrix(), this.matrix.premultiply(e), this.matrix.decompose(this.position, this.quaternion, this.scale); + } + applyQuaternion(e) { + return this.quaternion.premultiply(e), this; + } + setRotationFromAxisAngle(e, t) { + this.quaternion.setFromAxisAngle(e, t); + } + setRotationFromEuler(e) { + this.quaternion.setFromEuler(e, !0); + } + setRotationFromMatrix(e) { + this.quaternion.setFromRotationMatrix(e); + } + setRotationFromQuaternion(e) { + this.quaternion.copy(e); + } + rotateOnAxis(e, t) { + return xi.setFromAxisAngle(e, t), this.quaternion.multiply(xi), this; + } + rotateOnWorldAxis(e, t) { + return xi.setFromAxisAngle(e, t), this.quaternion.premultiply(xi), this; + } + rotateX(e) { + return this.rotateOnAxis(Ea, e); + } + rotateY(e) { + return this.rotateOnAxis(ba, e); + } + rotateZ(e) { + return this.rotateOnAxis(Ta, e); + } + translateOnAxis(e, t) { + return Aa.copy(e).applyQuaternion(this.quaternion), this.position.add(Aa.multiplyScalar(t)), this; + } + translateX(e) { + return this.translateOnAxis(Ea, e); + } + translateY(e) { + return this.translateOnAxis(ba, e); + } + translateZ(e) { + return this.translateOnAxis(Ta, e); + } + localToWorld(e) { + return this.updateWorldMatrix(!0, !1), e.applyMatrix4(this.matrixWorld); + } + worldToLocal(e) { + return this.updateWorldMatrix(!0, !1), e.applyMatrix4(gn.copy(this.matrixWorld).invert()); + } + lookAt(e, t, n) { + e.isVector3 ? Ar.copy(e) : Ar.set(e, t, n); + const r = this.parent; + this.updateWorldMatrix(!0, !1), ir.setFromMatrixPosition(this.matrixWorld), this.isCamera || this.isLight ? gn.lookAt(ir, Ar, this.up) : gn.lookAt(Ar, ir, this.up), this.quaternion.setFromRotationMatrix(gn), r && (gn.extractRotation(r.matrixWorld), xi.setFromRotationMatrix(gn), this.quaternion.premultiply(xi.invert())); + } + add(e) { + if (arguments.length > 1) { + for (let t = 0; t < arguments.length; t++) + this.add(arguments[t]); + return this; + } + return e === this ? (console.error("THREE.Object3D.add: object can't be added as a child of itself.", e), this) : (e && e.isObject3D ? (e.parent !== null && e.parent.remove(e), e.parent = this, this.children.push(e), e.dispatchEvent(sh), Is.child = e, this.dispatchEvent(Is), Is.child = null) : console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.", e), this); + } + remove(e) { + if (arguments.length > 1) { + for (let n = 0; n < arguments.length; n++) + this.remove(arguments[n]); + return this; + } + const t = this.children.indexOf(e); + return t !== -1 && (e.parent = null, this.children.splice(t, 1), e.dispatchEvent(oh), Us.child = e, this.dispatchEvent(Us), Us.child = null), this; + } + removeFromParent() { + const e = this.parent; + return e !== null && e.remove(this), this; + } + clear() { + return this.remove(...this.children); + } + attach(e) { + return this.updateWorldMatrix(!0, !1), gn.copy(this.matrixWorld).invert(), e.parent !== null && (e.parent.updateWorldMatrix(!0, !1), gn.multiply(e.parent.matrixWorld)), e.applyMatrix4(gn), this.add(e), e.updateWorldMatrix(!1, !0), this; + } + getObjectById(e) { + return this.getObjectByProperty("id", e); + } + getObjectByName(e) { + return this.getObjectByProperty("name", e); + } + getObjectByProperty(e, t) { + if (this[e] === t) + return this; + for (let n = 0, r = this.children.length; n < r; n++) { + const a = this.children[n].getObjectByProperty(e, t); + if (a !== void 0) + return a; + } + } + getObjectsByProperty(e, t, n = []) { + this[e] === t && n.push(this); + const r = this.children; + for (let s = 0, a = r.length; s < a; s++) + r[s].getObjectsByProperty(e, t, n); + return n; + } + getWorldPosition(e) { + return this.updateWorldMatrix(!0, !1), e.setFromMatrixPosition(this.matrixWorld); + } + getWorldQuaternion(e) { + return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(ir, e, ih), e; + } + getWorldScale(e) { + return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(ir, rh, e), e; + } + getWorldDirection(e) { + this.updateWorldMatrix(!0, !1); + const t = this.matrixWorld.elements; + return e.set(t[8], t[9], t[10]).normalize(); + } + raycast() { + } + traverse(e) { + e(this); + const t = this.children; + for (let n = 0, r = t.length; n < r; n++) + t[n].traverse(e); + } + traverseVisible(e) { + if (this.visible === !1) + return; + e(this); + const t = this.children; + for (let n = 0, r = t.length; n < r; n++) + t[n].traverseVisible(e); + } + traverseAncestors(e) { + const t = this.parent; + t !== null && (e(t), t.traverseAncestors(e)); + } + updateMatrix() { + this.matrix.compose(this.position, this.quaternion, this.scale), this.matrixWorldNeedsUpdate = !0; + } + updateMatrixWorld(e) { + this.matrixAutoUpdate && this.updateMatrix(), (this.matrixWorldNeedsUpdate || e) && (this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix), this.matrixWorldNeedsUpdate = !1, e = !0); + const t = this.children; + for (let n = 0, r = t.length; n < r; n++) { + const s = t[n]; + (s.matrixWorldAutoUpdate === !0 || e === !0) && s.updateMatrixWorld(e); + } + } + updateWorldMatrix(e, t) { + const n = this.parent; + if (e === !0 && n !== null && n.matrixWorldAutoUpdate === !0 && n.updateWorldMatrix(!0, !1), this.matrixAutoUpdate && this.updateMatrix(), this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix), t === !0) { + const r = this.children; + for (let s = 0, a = r.length; s < a; s++) { + const o = r[s]; + o.matrixWorldAutoUpdate === !0 && o.updateWorldMatrix(!1, !0); + } + } + } + toJSON(e) { + const t = e === void 0 || typeof e == "string", n = {}; + t && (e = { + geometries: {}, + materials: {}, + textures: {}, + images: {}, + shapes: {}, + skeletons: {}, + animations: {}, + nodes: {} + }, n.metadata = { + version: 4.6, + type: "Object", + generator: "Object3D.toJSON" + }); + const r = {}; + r.uuid = this.uuid, r.type = this.type, this.name !== "" && (r.name = this.name), this.castShadow === !0 && (r.castShadow = !0), this.receiveShadow === !0 && (r.receiveShadow = !0), this.visible === !1 && (r.visible = !1), this.frustumCulled === !1 && (r.frustumCulled = !1), this.renderOrder !== 0 && (r.renderOrder = this.renderOrder), Object.keys(this.userData).length > 0 && (r.userData = this.userData), r.layers = this.layers.mask, r.matrix = this.matrix.toArray(), r.up = this.up.toArray(), this.matrixAutoUpdate === !1 && (r.matrixAutoUpdate = !1), this.isInstancedMesh && (r.type = "InstancedMesh", r.count = this.count, r.instanceMatrix = this.instanceMatrix.toJSON(), this.instanceColor !== null && (r.instanceColor = this.instanceColor.toJSON())), this.isBatchedMesh && (r.type = "BatchedMesh", r.perObjectFrustumCulled = this.perObjectFrustumCulled, r.sortObjects = this.sortObjects, r.drawRanges = this._drawRanges, r.reservedRanges = this._reservedRanges, r.visibility = this._visibility, r.active = this._active, r.bounds = this._bounds.map((o) => ({ + boxInitialized: o.boxInitialized, + boxMin: o.box.min.toArray(), + boxMax: o.box.max.toArray(), + sphereInitialized: o.sphereInitialized, + sphereRadius: o.sphere.radius, + sphereCenter: o.sphere.center.toArray() + })), r.maxGeometryCount = this._maxGeometryCount, r.maxVertexCount = this._maxVertexCount, r.maxIndexCount = this._maxIndexCount, r.geometryInitialized = this._geometryInitialized, r.geometryCount = this._geometryCount, r.matricesTexture = this._matricesTexture.toJSON(e), this.boundingSphere !== null && (r.boundingSphere = { + center: r.boundingSphere.center.toArray(), + radius: r.boundingSphere.radius + }), this.boundingBox !== null && (r.boundingBox = { + min: r.boundingBox.min.toArray(), + max: r.boundingBox.max.toArray() + })); + function s(o, l) { + return o[l.uuid] === void 0 && (o[l.uuid] = l.toJSON(e)), l.uuid; + } + if (this.isScene) + this.background && (this.background.isColor ? r.background = this.background.toJSON() : this.background.isTexture && (r.background = this.background.toJSON(e).uuid)), this.environment && this.environment.isTexture && this.environment.isRenderTargetTexture !== !0 && (r.environment = this.environment.toJSON(e).uuid); + else if (this.isMesh || this.isLine || this.isPoints) { + r.geometry = s(e.geometries, this.geometry); + const o = this.geometry.parameters; + if (o !== void 0 && o.shapes !== void 0) { + const l = o.shapes; + if (Array.isArray(l)) + for (let c = 0, u = l.length; c < u; c++) { + const f = l[c]; + s(e.shapes, f); + } + else + s(e.shapes, l); + } + } + if (this.isSkinnedMesh && (r.bindMode = this.bindMode, r.bindMatrix = this.bindMatrix.toArray(), this.skeleton !== void 0 && (s(e.skeletons, this.skeleton), r.skeleton = this.skeleton.uuid)), this.material !== void 0) + if (Array.isArray(this.material)) { + const o = []; + for (let l = 0, c = this.material.length; l < c; l++) + o.push(s(e.materials, this.material[l])); + r.material = o; + } else + r.material = s(e.materials, this.material); + if (this.children.length > 0) { + r.children = []; + for (let o = 0; o < this.children.length; o++) + r.children.push(this.children[o].toJSON(e).object); + } + if (this.animations.length > 0) { + r.animations = []; + for (let o = 0; o < this.animations.length; o++) { + const l = this.animations[o]; + r.animations.push(s(e.animations, l)); + } + } + if (t) { + const o = a(e.geometries), l = a(e.materials), c = a(e.textures), u = a(e.images), f = a(e.shapes), h = a(e.skeletons), p = a(e.animations), g = a(e.nodes); + o.length > 0 && (n.geometries = o), l.length > 0 && (n.materials = l), c.length > 0 && (n.textures = c), u.length > 0 && (n.images = u), f.length > 0 && (n.shapes = f), h.length > 0 && (n.skeletons = h), p.length > 0 && (n.animations = p), g.length > 0 && (n.nodes = g); + } + return n.object = r, n; + function a(o) { + const l = []; + for (const c in o) { + const u = o[c]; + delete u.metadata, l.push(u); + } + return l; + } + } + clone(e) { + return new this.constructor().copy(this, e); + } + copy(e, t = !0) { + if (this.name = e.name, this.up.copy(e.up), this.position.copy(e.position), this.rotation.order = e.rotation.order, this.quaternion.copy(e.quaternion), this.scale.copy(e.scale), this.matrix.copy(e.matrix), this.matrixWorld.copy(e.matrixWorld), this.matrixAutoUpdate = e.matrixAutoUpdate, this.matrixWorldAutoUpdate = e.matrixWorldAutoUpdate, this.matrixWorldNeedsUpdate = e.matrixWorldNeedsUpdate, this.layers.mask = e.layers.mask, this.visible = e.visible, this.castShadow = e.castShadow, this.receiveShadow = e.receiveShadow, this.frustumCulled = e.frustumCulled, this.renderOrder = e.renderOrder, this.animations = e.animations.slice(), this.userData = JSON.parse(JSON.stringify(e.userData)), t === !0) + for (let n = 0; n < e.children.length; n++) { + const r = e.children[n]; + this.add(r.clone()); + } + return this; + } +} +gt.DEFAULT_UP = /* @__PURE__ */ new P(0, 1, 0); +gt.DEFAULT_MATRIX_AUTO_UPDATE = !0; +gt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE = !0; +const Qt = /* @__PURE__ */ new P(), _n = /* @__PURE__ */ new P(), Fs = /* @__PURE__ */ new P(), vn = /* @__PURE__ */ new P(), Si = /* @__PURE__ */ new P(), Mi = /* @__PURE__ */ new P(), wa = /* @__PURE__ */ new P(), Ns = /* @__PURE__ */ new P(), Bs = /* @__PURE__ */ new P(), Os = /* @__PURE__ */ new P(); +class ln { + constructor(e = new P(), t = new P(), n = new P()) { + this.a = e, this.b = t, this.c = n; + } + static getNormal(e, t, n, r) { + r.subVectors(n, t), Qt.subVectors(e, t), r.cross(Qt); + const s = r.lengthSq(); + return s > 0 ? r.multiplyScalar(1 / Math.sqrt(s)) : r.set(0, 0, 0); + } + // static/instance method to calculate barycentric coordinates + // based on: http://www.blackpawn.com/texts/pointinpoly/default.html + static getBarycoord(e, t, n, r, s) { + Qt.subVectors(r, t), _n.subVectors(n, t), Fs.subVectors(e, t); + const a = Qt.dot(Qt), o = Qt.dot(_n), l = Qt.dot(Fs), c = _n.dot(_n), u = _n.dot(Fs), f = a * c - o * o; + if (f === 0) + return s.set(0, 0, 0), null; + const h = 1 / f, p = (c * l - o * u) * h, g = (a * u - o * l) * h; + return s.set(1 - p - g, g, p); + } + static containsPoint(e, t, n, r) { + return this.getBarycoord(e, t, n, r, vn) === null ? !1 : vn.x >= 0 && vn.y >= 0 && vn.x + vn.y <= 1; + } + static getInterpolation(e, t, n, r, s, a, o, l) { + return this.getBarycoord(e, t, n, r, vn) === null ? (l.x = 0, l.y = 0, "z" in l && (l.z = 0), "w" in l && (l.w = 0), null) : (l.setScalar(0), l.addScaledVector(s, vn.x), l.addScaledVector(a, vn.y), l.addScaledVector(o, vn.z), l); + } + static isFrontFacing(e, t, n, r) { + return Qt.subVectors(n, t), _n.subVectors(e, t), Qt.cross(_n).dot(r) < 0; + } + set(e, t, n) { + return this.a.copy(e), this.b.copy(t), this.c.copy(n), this; + } + setFromPointsAndIndices(e, t, n, r) { + return this.a.copy(e[t]), this.b.copy(e[n]), this.c.copy(e[r]), this; + } + setFromAttributeAndIndices(e, t, n, r) { + return this.a.fromBufferAttribute(e, t), this.b.fromBufferAttribute(e, n), this.c.fromBufferAttribute(e, r), this; + } + clone() { + return new this.constructor().copy(this); + } + copy(e) { + return this.a.copy(e.a), this.b.copy(e.b), this.c.copy(e.c), this; + } + getArea() { + return Qt.subVectors(this.c, this.b), _n.subVectors(this.a, this.b), Qt.cross(_n).length() * 0.5; + } + getMidpoint(e) { + return e.addVectors(this.a, this.b).add(this.c).multiplyScalar(1 / 3); + } + getNormal(e) { + return ln.getNormal(this.a, this.b, this.c, e); + } + getPlane(e) { + return e.setFromCoplanarPoints(this.a, this.b, this.c); + } + getBarycoord(e, t) { + return ln.getBarycoord(e, this.a, this.b, this.c, t); + } + getInterpolation(e, t, n, r, s) { + return ln.getInterpolation(e, this.a, this.b, this.c, t, n, r, s); + } + containsPoint(e) { + return ln.containsPoint(e, this.a, this.b, this.c); + } + isFrontFacing(e) { + return ln.isFrontFacing(this.a, this.b, this.c, e); + } + intersectsBox(e) { + return e.intersectsTriangle(this); + } + closestPointToPoint(e, t) { + const n = this.a, r = this.b, s = this.c; + let a, o; + Si.subVectors(r, n), Mi.subVectors(s, n), Ns.subVectors(e, n); + const l = Si.dot(Ns), c = Mi.dot(Ns); + if (l <= 0 && c <= 0) + return t.copy(n); + Bs.subVectors(e, r); + const u = Si.dot(Bs), f = Mi.dot(Bs); + if (u >= 0 && f <= u) + return t.copy(r); + const h = l * f - u * c; + if (h <= 0 && l >= 0 && u <= 0) + return a = l / (l - u), t.copy(n).addScaledVector(Si, a); + Os.subVectors(e, s); + const p = Si.dot(Os), g = Mi.dot(Os); + if (g >= 0 && p <= g) + return t.copy(s); + const v = p * c - l * g; + if (v <= 0 && c >= 0 && g <= 0) + return o = c / (c - g), t.copy(n).addScaledVector(Mi, o); + const m = u * g - p * f; + if (m <= 0 && f - u >= 0 && p - g >= 0) + return wa.subVectors(s, r), o = (f - u) / (f - u + (p - g)), t.copy(r).addScaledVector(wa, o); + const d = 1 / (m + v + h); + return a = v * d, o = h * d, t.copy(n).addScaledVector(Si, a).addScaledVector(Mi, o); + } + equals(e) { + return e.a.equals(this.a) && e.b.equals(this.b) && e.c.equals(this.c); + } +} +const ec = { + aliceblue: 15792383, + antiquewhite: 16444375, + aqua: 65535, + aquamarine: 8388564, + azure: 15794175, + beige: 16119260, + bisque: 16770244, + black: 0, + blanchedalmond: 16772045, + blue: 255, + blueviolet: 9055202, + brown: 10824234, + burlywood: 14596231, + cadetblue: 6266528, + chartreuse: 8388352, + chocolate: 13789470, + coral: 16744272, + cornflowerblue: 6591981, + cornsilk: 16775388, + crimson: 14423100, + cyan: 65535, + darkblue: 139, + darkcyan: 35723, + darkgoldenrod: 12092939, + darkgray: 11119017, + darkgreen: 25600, + darkgrey: 11119017, + darkkhaki: 12433259, + darkmagenta: 9109643, + darkolivegreen: 5597999, + darkorange: 16747520, + darkorchid: 10040012, + darkred: 9109504, + darksalmon: 15308410, + darkseagreen: 9419919, + darkslateblue: 4734347, + darkslategray: 3100495, + darkslategrey: 3100495, + darkturquoise: 52945, + darkviolet: 9699539, + deeppink: 16716947, + deepskyblue: 49151, + dimgray: 6908265, + dimgrey: 6908265, + dodgerblue: 2003199, + firebrick: 11674146, + floralwhite: 16775920, + forestgreen: 2263842, + fuchsia: 16711935, + gainsboro: 14474460, + ghostwhite: 16316671, + gold: 16766720, + goldenrod: 14329120, + gray: 8421504, + green: 32768, + greenyellow: 11403055, + grey: 8421504, + honeydew: 15794160, + hotpink: 16738740, + indianred: 13458524, + indigo: 4915330, + ivory: 16777200, + khaki: 15787660, + lavender: 15132410, + lavenderblush: 16773365, + lawngreen: 8190976, + lemonchiffon: 16775885, + lightblue: 11393254, + lightcoral: 15761536, + lightcyan: 14745599, + lightgoldenrodyellow: 16448210, + lightgray: 13882323, + lightgreen: 9498256, + lightgrey: 13882323, + lightpink: 16758465, + lightsalmon: 16752762, + lightseagreen: 2142890, + lightskyblue: 8900346, + lightslategray: 7833753, + lightslategrey: 7833753, + lightsteelblue: 11584734, + lightyellow: 16777184, + lime: 65280, + limegreen: 3329330, + linen: 16445670, + magenta: 16711935, + maroon: 8388608, + mediumaquamarine: 6737322, + mediumblue: 205, + mediumorchid: 12211667, + mediumpurple: 9662683, + mediumseagreen: 3978097, + mediumslateblue: 8087790, + mediumspringgreen: 64154, + mediumturquoise: 4772300, + mediumvioletred: 13047173, + midnightblue: 1644912, + mintcream: 16121850, + mistyrose: 16770273, + moccasin: 16770229, + navajowhite: 16768685, + navy: 128, + oldlace: 16643558, + olive: 8421376, + olivedrab: 7048739, + orange: 16753920, + orangered: 16729344, + orchid: 14315734, + palegoldenrod: 15657130, + palegreen: 10025880, + paleturquoise: 11529966, + palevioletred: 14381203, + papayawhip: 16773077, + peachpuff: 16767673, + peru: 13468991, + pink: 16761035, + plum: 14524637, + powderblue: 11591910, + purple: 8388736, + rebeccapurple: 6697881, + red: 16711680, + rosybrown: 12357519, + royalblue: 4286945, + saddlebrown: 9127187, + salmon: 16416882, + sandybrown: 16032864, + seagreen: 3050327, + seashell: 16774638, + sienna: 10506797, + silver: 12632256, + skyblue: 8900331, + slateblue: 6970061, + slategray: 7372944, + slategrey: 7372944, + snow: 16775930, + springgreen: 65407, + steelblue: 4620980, + tan: 13808780, + teal: 32896, + thistle: 14204888, + tomato: 16737095, + turquoise: 4251856, + violet: 15631086, + wheat: 16113331, + white: 16777215, + whitesmoke: 16119285, + yellow: 16776960, + yellowgreen: 10145074 +}, In = { h: 0, s: 0, l: 0 }, Er = { h: 0, s: 0, l: 0 }; +function zs(i, e, t) { + return t < 0 && (t += 1), t > 1 && (t -= 1), t < 1 / 6 ? i + (e - i) * 6 * t : t < 1 / 2 ? e : t < 2 / 3 ? i + (e - i) * 6 * (2 / 3 - t) : i; +} +class Qe { + constructor(e, t, n) { + return this.isColor = !0, this.r = 1, this.g = 1, this.b = 1, this.set(e, t, n); + } + set(e, t, n) { + if (t === void 0 && n === void 0) { + const r = e; + r && r.isColor ? this.copy(r) : typeof r == "number" ? this.setHex(r) : typeof r == "string" && this.setStyle(r); + } else + this.setRGB(e, t, n); + return this; + } + setScalar(e) { + return this.r = e, this.g = e, this.b = e, this; + } + setHex(e, t = sn) { + return e = Math.floor(e), this.r = (e >> 16 & 255) / 255, this.g = (e >> 8 & 255) / 255, this.b = (e & 255) / 255, Ze.toWorkingColorSpace(this, t), this; + } + setRGB(e, t, n, r = Ze.workingColorSpace) { + return this.r = e, this.g = t, this.b = n, Ze.toWorkingColorSpace(this, r), this; + } + setHSL(e, t, n, r = Ze.workingColorSpace) { + if (e = _o(e, 1), t = xt(t, 0, 1), n = xt(n, 0, 1), t === 0) + this.r = this.g = this.b = n; + else { + const s = n <= 0.5 ? n * (1 + t) : n + t - n * t, a = 2 * n - s; + this.r = zs(a, s, e + 1 / 3), this.g = zs(a, s, e), this.b = zs(a, s, e - 1 / 3); + } + return Ze.toWorkingColorSpace(this, r), this; + } + setStyle(e, t = sn) { + function n(s) { + s !== void 0 && parseFloat(s) < 1 && console.warn("THREE.Color: Alpha component of " + e + " will be ignored."); + } + let r; + if (r = /^(\w+)\(([^\)]*)\)/.exec(e)) { + let s; + const a = r[1], o = r[2]; + switch (a) { + case "rgb": + case "rgba": + if (s = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)) + return n(s[4]), this.setRGB( + Math.min(255, parseInt(s[1], 10)) / 255, + Math.min(255, parseInt(s[2], 10)) / 255, + Math.min(255, parseInt(s[3], 10)) / 255, + t + ); + if (s = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)) + return n(s[4]), this.setRGB( + Math.min(100, parseInt(s[1], 10)) / 100, + Math.min(100, parseInt(s[2], 10)) / 100, + Math.min(100, parseInt(s[3], 10)) / 100, + t + ); + break; + case "hsl": + case "hsla": + if (s = /^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)) + return n(s[4]), this.setHSL( + parseFloat(s[1]) / 360, + parseFloat(s[2]) / 100, + parseFloat(s[3]) / 100, + t + ); + break; + default: + console.warn("THREE.Color: Unknown color model " + e); + } + } else if (r = /^\#([A-Fa-f\d]+)$/.exec(e)) { + const s = r[1], a = s.length; + if (a === 3) + return this.setRGB( + parseInt(s.charAt(0), 16) / 15, + parseInt(s.charAt(1), 16) / 15, + parseInt(s.charAt(2), 16) / 15, + t + ); + if (a === 6) + return this.setHex(parseInt(s, 16), t); + console.warn("THREE.Color: Invalid hex color " + e); + } else if (e && e.length > 0) + return this.setColorName(e, t); + return this; + } + setColorName(e, t = sn) { + const n = ec[e.toLowerCase()]; + return n !== void 0 ? this.setHex(n, t) : console.warn("THREE.Color: Unknown color " + e), this; + } + clone() { + return new this.constructor(this.r, this.g, this.b); + } + copy(e) { + return this.r = e.r, this.g = e.g, this.b = e.b, this; + } + copySRGBToLinear(e) { + return this.r = Bi(e.r), this.g = Bi(e.g), this.b = Bi(e.b), this; + } + copyLinearToSRGB(e) { + return this.r = bs(e.r), this.g = bs(e.g), this.b = bs(e.b), this; + } + convertSRGBToLinear() { + return this.copySRGBToLinear(this), this; + } + convertLinearToSRGB() { + return this.copyLinearToSRGB(this), this; + } + getHex(e = sn) { + return Ze.fromWorkingColorSpace(yt.copy(this), e), Math.round(xt(yt.r * 255, 0, 255)) * 65536 + Math.round(xt(yt.g * 255, 0, 255)) * 256 + Math.round(xt(yt.b * 255, 0, 255)); + } + getHexString(e = sn) { + return ("000000" + this.getHex(e).toString(16)).slice(-6); + } + getHSL(e, t = Ze.workingColorSpace) { + Ze.fromWorkingColorSpace(yt.copy(this), t); + const n = yt.r, r = yt.g, s = yt.b, a = Math.max(n, r, s), o = Math.min(n, r, s); + let l, c; + const u = (o + a) / 2; + if (o === a) + l = 0, c = 0; + else { + const f = a - o; + switch (c = u <= 0.5 ? f / (a + o) : f / (2 - a - o), a) { + case n: + l = (r - s) / f + (r < s ? 6 : 0); + break; + case r: + l = (s - n) / f + 2; + break; + case s: + l = (n - r) / f + 4; + break; + } + l /= 6; + } + return e.h = l, e.s = c, e.l = u, e; + } + getRGB(e, t = Ze.workingColorSpace) { + return Ze.fromWorkingColorSpace(yt.copy(this), t), e.r = yt.r, e.g = yt.g, e.b = yt.b, e; + } + getStyle(e = sn) { + Ze.fromWorkingColorSpace(yt.copy(this), e); + const t = yt.r, n = yt.g, r = yt.b; + return e !== sn ? `color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})` : `rgb(${Math.round(t * 255)},${Math.round(n * 255)},${Math.round(r * 255)})`; + } + offsetHSL(e, t, n) { + return this.getHSL(In), this.setHSL(In.h + e, In.s + t, In.l + n); + } + add(e) { + return this.r += e.r, this.g += e.g, this.b += e.b, this; + } + addColors(e, t) { + return this.r = e.r + t.r, this.g = e.g + t.g, this.b = e.b + t.b, this; + } + addScalar(e) { + return this.r += e, this.g += e, this.b += e, this; + } + sub(e) { + return this.r = Math.max(0, this.r - e.r), this.g = Math.max(0, this.g - e.g), this.b = Math.max(0, this.b - e.b), this; + } + multiply(e) { + return this.r *= e.r, this.g *= e.g, this.b *= e.b, this; + } + multiplyScalar(e) { + return this.r *= e, this.g *= e, this.b *= e, this; + } + lerp(e, t) { + return this.r += (e.r - this.r) * t, this.g += (e.g - this.g) * t, this.b += (e.b - this.b) * t, this; + } + lerpColors(e, t, n) { + return this.r = e.r + (t.r - e.r) * n, this.g = e.g + (t.g - e.g) * n, this.b = e.b + (t.b - e.b) * n, this; + } + lerpHSL(e, t) { + this.getHSL(In), e.getHSL(Er); + const n = or(In.h, Er.h, t), r = or(In.s, Er.s, t), s = or(In.l, Er.l, t); + return this.setHSL(n, r, s), this; + } + setFromVector3(e) { + return this.r = e.x, this.g = e.y, this.b = e.z, this; + } + applyMatrix3(e) { + const t = this.r, n = this.g, r = this.b, s = e.elements; + return this.r = s[0] * t + s[3] * n + s[6] * r, this.g = s[1] * t + s[4] * n + s[7] * r, this.b = s[2] * t + s[5] * n + s[8] * r, this; + } + equals(e) { + return e.r === this.r && e.g === this.g && e.b === this.b; + } + fromArray(e, t = 0) { + return this.r = e[t], this.g = e[t + 1], this.b = e[t + 2], this; + } + toArray(e = [], t = 0) { + return e[t] = this.r, e[t + 1] = this.g, e[t + 2] = this.b, e; + } + fromBufferAttribute(e, t) { + return this.r = e.getX(t), this.g = e.getY(t), this.b = e.getZ(t), this; + } + toJSON() { + return this.getHex(); + } + *[Symbol.iterator]() { + yield this.r, yield this.g, yield this.b; + } +} +const yt = /* @__PURE__ */ new Qe(); +Qe.NAMES = ec; +let ah = 0; +class as extends ui { + constructor() { + super(), this.isMaterial = !0, Object.defineProperty(this, "id", { value: ah++ }), this.uuid = Ki(), this.name = "", this.type = "Material", this.blending = ri, this.side = hn, this.vertexColors = !1, this.opacity = 1, this.transparent = !1, this.alphaHash = !1, this.blendSrc = cr, this.blendDst = ur, this.blendEquation = ei, this.blendSrcAlpha = null, this.blendDstAlpha = null, this.blendEquationAlpha = null, this.blendColor = new Qe(0, 0, 0), this.blendAlpha = 0, this.depthFunc = qr, this.depthTest = !0, this.depthWrite = !0, this.stencilWriteMask = 255, this.stencilFunc = da, this.stencilRef = 0, this.stencilFuncMask = 255, this.stencilFail = di, this.stencilZFail = di, this.stencilZPass = di, this.stencilWrite = !1, this.clippingPlanes = null, this.clipIntersection = !1, this.clipShadows = !1, this.shadowSide = null, this.colorWrite = !0, this.precision = null, this.polygonOffset = !1, this.polygonOffsetFactor = 0, this.polygonOffsetUnits = 0, this.dithering = !1, this.alphaToCoverage = !1, this.premultipliedAlpha = !1, this.forceSinglePass = !1, this.visible = !0, this.toneMapped = !0, this.userData = {}, this.version = 0, this._alphaTest = 0; + } + get alphaTest() { + return this._alphaTest; + } + set alphaTest(e) { + this._alphaTest > 0 != e > 0 && this.version++, this._alphaTest = e; + } + onBuild() { + } + onBeforeRender() { + } + onBeforeCompile() { + } + customProgramCacheKey() { + return this.onBeforeCompile.toString(); + } + setValues(e) { + if (e !== void 0) + for (const t in e) { + const n = e[t]; + if (n === void 0) { + console.warn(`THREE.Material: parameter '${t}' has value of undefined.`); + continue; + } + const r = this[t]; + if (r === void 0) { + console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`); + continue; + } + r && r.isColor ? r.set(n) : r && r.isVector3 && n && n.isVector3 ? r.copy(n) : this[t] = n; + } + } + toJSON(e) { + const t = e === void 0 || typeof e == "string"; + t && (e = { + textures: {}, + images: {} + }); + const n = { + metadata: { + version: 4.6, + type: "Material", + generator: "Material.toJSON" + } + }; + n.uuid = this.uuid, n.type = this.type, this.name !== "" && (n.name = this.name), this.color && this.color.isColor && (n.color = this.color.getHex()), this.roughness !== void 0 && (n.roughness = this.roughness), this.metalness !== void 0 && (n.metalness = this.metalness), this.sheen !== void 0 && (n.sheen = this.sheen), this.sheenColor && this.sheenColor.isColor && (n.sheenColor = this.sheenColor.getHex()), this.sheenRoughness !== void 0 && (n.sheenRoughness = this.sheenRoughness), this.emissive && this.emissive.isColor && (n.emissive = this.emissive.getHex()), this.emissiveIntensity !== void 0 && this.emissiveIntensity !== 1 && (n.emissiveIntensity = this.emissiveIntensity), this.specular && this.specular.isColor && (n.specular = this.specular.getHex()), this.specularIntensity !== void 0 && (n.specularIntensity = this.specularIntensity), this.specularColor && this.specularColor.isColor && (n.specularColor = this.specularColor.getHex()), this.shininess !== void 0 && (n.shininess = this.shininess), this.clearcoat !== void 0 && (n.clearcoat = this.clearcoat), this.clearcoatRoughness !== void 0 && (n.clearcoatRoughness = this.clearcoatRoughness), this.clearcoatMap && this.clearcoatMap.isTexture && (n.clearcoatMap = this.clearcoatMap.toJSON(e).uuid), this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture && (n.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON(e).uuid), this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture && (n.clearcoatNormalMap = this.clearcoatNormalMap.toJSON(e).uuid, n.clearcoatNormalScale = this.clearcoatNormalScale.toArray()), this.iridescence !== void 0 && (n.iridescence = this.iridescence), this.iridescenceIOR !== void 0 && (n.iridescenceIOR = this.iridescenceIOR), this.iridescenceThicknessRange !== void 0 && (n.iridescenceThicknessRange = this.iridescenceThicknessRange), this.iridescenceMap && this.iridescenceMap.isTexture && (n.iridescenceMap = this.iridescenceMap.toJSON(e).uuid), this.iridescenceThicknessMap && this.iridescenceThicknessMap.isTexture && (n.iridescenceThicknessMap = this.iridescenceThicknessMap.toJSON(e).uuid), this.anisotropy !== void 0 && (n.anisotropy = this.anisotropy), this.anisotropyRotation !== void 0 && (n.anisotropyRotation = this.anisotropyRotation), this.anisotropyMap && this.anisotropyMap.isTexture && (n.anisotropyMap = this.anisotropyMap.toJSON(e).uuid), this.map && this.map.isTexture && (n.map = this.map.toJSON(e).uuid), this.matcap && this.matcap.isTexture && (n.matcap = this.matcap.toJSON(e).uuid), this.alphaMap && this.alphaMap.isTexture && (n.alphaMap = this.alphaMap.toJSON(e).uuid), this.lightMap && this.lightMap.isTexture && (n.lightMap = this.lightMap.toJSON(e).uuid, n.lightMapIntensity = this.lightMapIntensity), this.aoMap && this.aoMap.isTexture && (n.aoMap = this.aoMap.toJSON(e).uuid, n.aoMapIntensity = this.aoMapIntensity), this.bumpMap && this.bumpMap.isTexture && (n.bumpMap = this.bumpMap.toJSON(e).uuid, n.bumpScale = this.bumpScale), this.normalMap && this.normalMap.isTexture && (n.normalMap = this.normalMap.toJSON(e).uuid, n.normalMapType = this.normalMapType, n.normalScale = this.normalScale.toArray()), this.displacementMap && this.displacementMap.isTexture && (n.displacementMap = this.displacementMap.toJSON(e).uuid, n.displacementScale = this.displacementScale, n.displacementBias = this.displacementBias), this.roughnessMap && this.roughnessMap.isTexture && (n.roughnessMap = this.roughnessMap.toJSON(e).uuid), this.metalnessMap && this.metalnessMap.isTexture && (n.metalnessMap = this.metalnessMap.toJSON(e).uuid), this.emissiveMap && this.emissiveMap.isTexture && (n.emissiveMap = this.emissiveMap.toJSON(e).uuid), this.specularMap && this.specularMap.isTexture && (n.specularMap = this.specularMap.toJSON(e).uuid), this.specularIntensityMap && this.specularIntensityMap.isTexture && (n.specularIntensityMap = this.specularIntensityMap.toJSON(e).uuid), this.specularColorMap && this.specularColorMap.isTexture && (n.specularColorMap = this.specularColorMap.toJSON(e).uuid), this.envMap && this.envMap.isTexture && (n.envMap = this.envMap.toJSON(e).uuid, this.combine !== void 0 && (n.combine = this.combine)), this.envMapRotation !== void 0 && (n.envMapRotation = this.envMapRotation.toArray()), this.envMapIntensity !== void 0 && (n.envMapIntensity = this.envMapIntensity), this.reflectivity !== void 0 && (n.reflectivity = this.reflectivity), this.refractionRatio !== void 0 && (n.refractionRatio = this.refractionRatio), this.gradientMap && this.gradientMap.isTexture && (n.gradientMap = this.gradientMap.toJSON(e).uuid), this.transmission !== void 0 && (n.transmission = this.transmission), this.transmissionMap && this.transmissionMap.isTexture && (n.transmissionMap = this.transmissionMap.toJSON(e).uuid), this.thickness !== void 0 && (n.thickness = this.thickness), this.thicknessMap && this.thicknessMap.isTexture && (n.thicknessMap = this.thicknessMap.toJSON(e).uuid), this.attenuationDistance !== void 0 && this.attenuationDistance !== 1 / 0 && (n.attenuationDistance = this.attenuationDistance), this.attenuationColor !== void 0 && (n.attenuationColor = this.attenuationColor.getHex()), this.size !== void 0 && (n.size = this.size), this.shadowSide !== null && (n.shadowSide = this.shadowSide), this.sizeAttenuation !== void 0 && (n.sizeAttenuation = this.sizeAttenuation), this.blending !== ri && (n.blending = this.blending), this.side !== hn && (n.side = this.side), this.vertexColors === !0 && (n.vertexColors = !0), this.opacity < 1 && (n.opacity = this.opacity), this.transparent === !0 && (n.transparent = !0), this.blendSrc !== cr && (n.blendSrc = this.blendSrc), this.blendDst !== ur && (n.blendDst = this.blendDst), this.blendEquation !== ei && (n.blendEquation = this.blendEquation), this.blendSrcAlpha !== null && (n.blendSrcAlpha = this.blendSrcAlpha), this.blendDstAlpha !== null && (n.blendDstAlpha = this.blendDstAlpha), this.blendEquationAlpha !== null && (n.blendEquationAlpha = this.blendEquationAlpha), this.blendColor && this.blendColor.isColor && (n.blendColor = this.blendColor.getHex()), this.blendAlpha !== 0 && (n.blendAlpha = this.blendAlpha), this.depthFunc !== qr && (n.depthFunc = this.depthFunc), this.depthTest === !1 && (n.depthTest = this.depthTest), this.depthWrite === !1 && (n.depthWrite = this.depthWrite), this.colorWrite === !1 && (n.colorWrite = this.colorWrite), this.stencilWriteMask !== 255 && (n.stencilWriteMask = this.stencilWriteMask), this.stencilFunc !== da && (n.stencilFunc = this.stencilFunc), this.stencilRef !== 0 && (n.stencilRef = this.stencilRef), this.stencilFuncMask !== 255 && (n.stencilFuncMask = this.stencilFuncMask), this.stencilFail !== di && (n.stencilFail = this.stencilFail), this.stencilZFail !== di && (n.stencilZFail = this.stencilZFail), this.stencilZPass !== di && (n.stencilZPass = this.stencilZPass), this.stencilWrite === !0 && (n.stencilWrite = this.stencilWrite), this.rotation !== void 0 && this.rotation !== 0 && (n.rotation = this.rotation), this.polygonOffset === !0 && (n.polygonOffset = !0), this.polygonOffsetFactor !== 0 && (n.polygonOffsetFactor = this.polygonOffsetFactor), this.polygonOffsetUnits !== 0 && (n.polygonOffsetUnits = this.polygonOffsetUnits), this.linewidth !== void 0 && this.linewidth !== 1 && (n.linewidth = this.linewidth), this.dashSize !== void 0 && (n.dashSize = this.dashSize), this.gapSize !== void 0 && (n.gapSize = this.gapSize), this.scale !== void 0 && (n.scale = this.scale), this.dithering === !0 && (n.dithering = !0), this.alphaTest > 0 && (n.alphaTest = this.alphaTest), this.alphaHash === !0 && (n.alphaHash = !0), this.alphaToCoverage === !0 && (n.alphaToCoverage = !0), this.premultipliedAlpha === !0 && (n.premultipliedAlpha = !0), this.forceSinglePass === !0 && (n.forceSinglePass = !0), this.wireframe === !0 && (n.wireframe = !0), this.wireframeLinewidth > 1 && (n.wireframeLinewidth = this.wireframeLinewidth), this.wireframeLinecap !== "round" && (n.wireframeLinecap = this.wireframeLinecap), this.wireframeLinejoin !== "round" && (n.wireframeLinejoin = this.wireframeLinejoin), this.flatShading === !0 && (n.flatShading = !0), this.visible === !1 && (n.visible = !1), this.toneMapped === !1 && (n.toneMapped = !1), this.fog === !1 && (n.fog = !1), Object.keys(this.userData).length > 0 && (n.userData = this.userData); + function r(s) { + const a = []; + for (const o in s) { + const l = s[o]; + delete l.metadata, a.push(l); + } + return a; + } + if (t) { + const s = r(e.textures), a = r(e.images); + s.length > 0 && (n.textures = s), a.length > 0 && (n.images = a); + } + return n; + } + clone() { + return new this.constructor().copy(this); + } + copy(e) { + this.name = e.name, this.blending = e.blending, this.side = e.side, this.vertexColors = e.vertexColors, this.opacity = e.opacity, this.transparent = e.transparent, this.blendSrc = e.blendSrc, this.blendDst = e.blendDst, this.blendEquation = e.blendEquation, this.blendSrcAlpha = e.blendSrcAlpha, this.blendDstAlpha = e.blendDstAlpha, this.blendEquationAlpha = e.blendEquationAlpha, this.blendColor.copy(e.blendColor), this.blendAlpha = e.blendAlpha, this.depthFunc = e.depthFunc, this.depthTest = e.depthTest, this.depthWrite = e.depthWrite, this.stencilWriteMask = e.stencilWriteMask, this.stencilFunc = e.stencilFunc, this.stencilRef = e.stencilRef, this.stencilFuncMask = e.stencilFuncMask, this.stencilFail = e.stencilFail, this.stencilZFail = e.stencilZFail, this.stencilZPass = e.stencilZPass, this.stencilWrite = e.stencilWrite; + const t = e.clippingPlanes; + let n = null; + if (t !== null) { + const r = t.length; + n = new Array(r); + for (let s = 0; s !== r; ++s) + n[s] = t[s].clone(); + } + return this.clippingPlanes = n, this.clipIntersection = e.clipIntersection, this.clipShadows = e.clipShadows, this.shadowSide = e.shadowSide, this.colorWrite = e.colorWrite, this.precision = e.precision, this.polygonOffset = e.polygonOffset, this.polygonOffsetFactor = e.polygonOffsetFactor, this.polygonOffsetUnits = e.polygonOffsetUnits, this.dithering = e.dithering, this.alphaTest = e.alphaTest, this.alphaHash = e.alphaHash, this.alphaToCoverage = e.alphaToCoverage, this.premultipliedAlpha = e.premultipliedAlpha, this.forceSinglePass = e.forceSinglePass, this.visible = e.visible, this.toneMapped = e.toneMapped, this.userData = JSON.parse(JSON.stringify(e.userData)), this; + } + dispose() { + this.dispatchEvent({ type: "dispose" }); + } + set needsUpdate(e) { + e === !0 && this.version++; + } +} +class oi extends as { + constructor(e) { + super(), this.isMeshBasicMaterial = !0, this.type = "MeshBasicMaterial", this.color = new Qe(16777215), this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.specularMap = null, this.alphaMap = null, this.envMap = null, this.envMapRotation = new bn(), this.combine = zl, this.reflectivity = 1, this.refractionRatio = 0.98, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.fog = !0, this.setValues(e); + } + copy(e) { + return super.copy(e), this.color.copy(e.color), this.map = e.map, this.lightMap = e.lightMap, this.lightMapIntensity = e.lightMapIntensity, this.aoMap = e.aoMap, this.aoMapIntensity = e.aoMapIntensity, this.specularMap = e.specularMap, this.alphaMap = e.alphaMap, this.envMap = e.envMap, this.envMapRotation.copy(e.envMapRotation), this.combine = e.combine, this.reflectivity = e.reflectivity, this.refractionRatio = e.refractionRatio, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.wireframeLinecap = e.wireframeLinecap, this.wireframeLinejoin = e.wireframeLinejoin, this.fog = e.fog, this; + } +} +const Sn = /* @__PURE__ */ lh(); +function lh() { + const i = new ArrayBuffer(4), e = new Float32Array(i), t = new Uint32Array(i), n = new Uint32Array(512), r = new Uint32Array(512); + for (let l = 0; l < 256; ++l) { + const c = l - 127; + c < -27 ? (n[l] = 0, n[l | 256] = 32768, r[l] = 24, r[l | 256] = 24) : c < -14 ? (n[l] = 1024 >> -c - 14, n[l | 256] = 1024 >> -c - 14 | 32768, r[l] = -c - 1, r[l | 256] = -c - 1) : c <= 15 ? (n[l] = c + 15 << 10, n[l | 256] = c + 15 << 10 | 32768, r[l] = 13, r[l | 256] = 13) : c < 128 ? (n[l] = 31744, n[l | 256] = 64512, r[l] = 24, r[l | 256] = 24) : (n[l] = 31744, n[l | 256] = 64512, r[l] = 13, r[l | 256] = 13); + } + const s = new Uint32Array(2048), a = new Uint32Array(64), o = new Uint32Array(64); + for (let l = 1; l < 1024; ++l) { + let c = l << 13, u = 0; + for (; !(c & 8388608); ) + c <<= 1, u -= 8388608; + c &= -8388609, u += 947912704, s[l] = c | u; + } + for (let l = 1024; l < 2048; ++l) + s[l] = 939524096 + (l - 1024 << 13); + for (let l = 1; l < 31; ++l) + a[l] = l << 23; + a[31] = 1199570944, a[32] = 2147483648; + for (let l = 33; l < 63; ++l) + a[l] = 2147483648 + (l - 32 << 23); + a[63] = 3347054592; + for (let l = 1; l < 64; ++l) + l !== 32 && (o[l] = 1024); + return { + floatView: e, + uint32View: t, + baseTable: n, + shiftTable: r, + mantissaTable: s, + exponentTable: a, + offsetTable: o + }; +} +function ch(i) { + Math.abs(i) > 65504 && console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."), i = xt(i, -65504, 65504), Sn.floatView[0] = i; + const e = Sn.uint32View[0], t = e >> 23 & 511; + return Sn.baseTable[t] + ((e & 8388607) >> Sn.shiftTable[t]); +} +function uh(i) { + const e = i >> 10; + return Sn.uint32View[0] = Sn.mantissaTable[Sn.offsetTable[e] + (i & 1023)] + Sn.exponentTable[e], Sn.floatView[0]; +} +const $r = { + toHalfFloat: ch, + fromHalfFloat: uh +}, ct = /* @__PURE__ */ new P(), br = /* @__PURE__ */ new me(); +class Wt { + constructor(e, t, n = !1) { + if (Array.isArray(e)) + throw new TypeError("THREE.BufferAttribute: array should be a Typed Array."); + this.isBufferAttribute = !0, this.name = "", this.array = e, this.itemSize = t, this.count = e !== void 0 ? e.length / t : 0, this.normalized = n, this.usage = pa, this._updateRange = { offset: 0, count: -1 }, this.updateRanges = [], this.gpuType = an, this.version = 0; + } + onUploadCallback() { + } + set needsUpdate(e) { + e === !0 && this.version++; + } + get updateRange() { + return Yf("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."), this._updateRange; + } + setUsage(e) { + return this.usage = e, this; + } + addUpdateRange(e, t) { + this.updateRanges.push({ start: e, count: t }); + } + clearUpdateRanges() { + this.updateRanges.length = 0; + } + copy(e) { + return this.name = e.name, this.array = new e.array.constructor(e.array), this.itemSize = e.itemSize, this.count = e.count, this.normalized = e.normalized, this.usage = e.usage, this.gpuType = e.gpuType, this; + } + copyAt(e, t, n) { + e *= this.itemSize, n *= t.itemSize; + for (let r = 0, s = this.itemSize; r < s; r++) + this.array[e + r] = t.array[n + r]; + return this; + } + copyArray(e) { + return this.array.set(e), this; + } + applyMatrix3(e) { + if (this.itemSize === 2) + for (let t = 0, n = this.count; t < n; t++) + br.fromBufferAttribute(this, t), br.applyMatrix3(e), this.setXY(t, br.x, br.y); + else if (this.itemSize === 3) + for (let t = 0, n = this.count; t < n; t++) + ct.fromBufferAttribute(this, t), ct.applyMatrix3(e), this.setXYZ(t, ct.x, ct.y, ct.z); + return this; + } + applyMatrix4(e) { + for (let t = 0, n = this.count; t < n; t++) + ct.fromBufferAttribute(this, t), ct.applyMatrix4(e), this.setXYZ(t, ct.x, ct.y, ct.z); + return this; + } + applyNormalMatrix(e) { + for (let t = 0, n = this.count; t < n; t++) + ct.fromBufferAttribute(this, t), ct.applyNormalMatrix(e), this.setXYZ(t, ct.x, ct.y, ct.z); + return this; + } + transformDirection(e) { + for (let t = 0, n = this.count; t < n; t++) + ct.fromBufferAttribute(this, t), ct.transformDirection(e), this.setXYZ(t, ct.x, ct.y, ct.z); + return this; + } + set(e, t = 0) { + return this.array.set(e, t), this; + } + getComponent(e, t) { + let n = this.array[e * this.itemSize + t]; + return this.normalized && (n = Di(n, this.array)), n; + } + setComponent(e, t, n) { + return this.normalized && (n = Et(n, this.array)), this.array[e * this.itemSize + t] = n, this; + } + getX(e) { + let t = this.array[e * this.itemSize]; + return this.normalized && (t = Di(t, this.array)), t; + } + setX(e, t) { + return this.normalized && (t = Et(t, this.array)), this.array[e * this.itemSize] = t, this; + } + getY(e) { + let t = this.array[e * this.itemSize + 1]; + return this.normalized && (t = Di(t, this.array)), t; + } + setY(e, t) { + return this.normalized && (t = Et(t, this.array)), this.array[e * this.itemSize + 1] = t, this; + } + getZ(e) { + let t = this.array[e * this.itemSize + 2]; + return this.normalized && (t = Di(t, this.array)), t; + } + setZ(e, t) { + return this.normalized && (t = Et(t, this.array)), this.array[e * this.itemSize + 2] = t, this; + } + getW(e) { + let t = this.array[e * this.itemSize + 3]; + return this.normalized && (t = Di(t, this.array)), t; + } + setW(e, t) { + return this.normalized && (t = Et(t, this.array)), this.array[e * this.itemSize + 3] = t, this; + } + setXY(e, t, n) { + return e *= this.itemSize, this.normalized && (t = Et(t, this.array), n = Et(n, this.array)), this.array[e + 0] = t, this.array[e + 1] = n, this; + } + setXYZ(e, t, n, r) { + return e *= this.itemSize, this.normalized && (t = Et(t, this.array), n = Et(n, this.array), r = Et(r, this.array)), this.array[e + 0] = t, this.array[e + 1] = n, this.array[e + 2] = r, this; + } + setXYZW(e, t, n, r, s) { + return e *= this.itemSize, this.normalized && (t = Et(t, this.array), n = Et(n, this.array), r = Et(r, this.array), s = Et(s, this.array)), this.array[e + 0] = t, this.array[e + 1] = n, this.array[e + 2] = r, this.array[e + 3] = s, this; + } + onUpload(e) { + return this.onUploadCallback = e, this; + } + clone() { + return new this.constructor(this.array, this.itemSize).copy(this); + } + toJSON() { + const e = { + itemSize: this.itemSize, + type: this.array.constructor.name, + array: Array.from(this.array), + normalized: this.normalized + }; + return this.name !== "" && (e.name = this.name), this.usage !== pa && (e.usage = this.usage), e; + } +} +class tc extends Wt { + constructor(e, t, n) { + super(new Uint16Array(e), t, n); + } +} +class nc extends Wt { + constructor(e, t, n) { + super(new Uint32Array(e), t, n); + } +} +class Ft extends Wt { + constructor(e, t, n) { + super(new Float32Array(e), t, n); + } +} +let fh = 0; +const zt = /* @__PURE__ */ new ke(), ks = /* @__PURE__ */ new gt(), yi = /* @__PURE__ */ new P(), Ut = /* @__PURE__ */ new Rt(), rr = /* @__PURE__ */ new Rt(), pt = /* @__PURE__ */ new P(); +class Yt extends ui { + constructor() { + super(), this.isBufferGeometry = !0, Object.defineProperty(this, "id", { value: fh++ }), this.uuid = Ki(), this.name = "", this.type = "BufferGeometry", this.index = null, this.attributes = {}, this.morphAttributes = {}, this.morphTargetsRelative = !1, this.groups = [], this.boundingBox = null, this.boundingSphere = null, this.drawRange = { start: 0, count: 1 / 0 }, this.userData = {}; + } + getIndex() { + return this.index; + } + setIndex(e) { + return Array.isArray(e) ? this.index = new (jl(e) ? nc : tc)(e, 1) : this.index = e, this; + } + getAttribute(e) { + return this.attributes[e]; + } + setAttribute(e, t) { + return this.attributes[e] = t, this; + } + deleteAttribute(e) { + return delete this.attributes[e], this; + } + hasAttribute(e) { + return this.attributes[e] !== void 0; + } + addGroup(e, t, n = 0) { + this.groups.push({ + start: e, + count: t, + materialIndex: n + }); + } + clearGroups() { + this.groups = []; + } + setDrawRange(e, t) { + this.drawRange.start = e, this.drawRange.count = t; + } + applyMatrix4(e) { + const t = this.attributes.position; + t !== void 0 && (t.applyMatrix4(e), t.needsUpdate = !0); + const n = this.attributes.normal; + if (n !== void 0) { + const s = new be().getNormalMatrix(e); + n.applyNormalMatrix(s), n.needsUpdate = !0; + } + const r = this.attributes.tangent; + return r !== void 0 && (r.transformDirection(e), r.needsUpdate = !0), this.boundingBox !== null && this.computeBoundingBox(), this.boundingSphere !== null && this.computeBoundingSphere(), this; + } + applyQuaternion(e) { + return zt.makeRotationFromQuaternion(e), this.applyMatrix4(zt), this; + } + rotateX(e) { + return zt.makeRotationX(e), this.applyMatrix4(zt), this; + } + rotateY(e) { + return zt.makeRotationY(e), this.applyMatrix4(zt), this; + } + rotateZ(e) { + return zt.makeRotationZ(e), this.applyMatrix4(zt), this; + } + translate(e, t, n) { + return zt.makeTranslation(e, t, n), this.applyMatrix4(zt), this; + } + scale(e, t, n) { + return zt.makeScale(e, t, n), this.applyMatrix4(zt), this; + } + lookAt(e) { + return ks.lookAt(e), ks.updateMatrix(), this.applyMatrix4(ks.matrix), this; + } + center() { + return this.computeBoundingBox(), this.boundingBox.getCenter(yi).negate(), this.translate(yi.x, yi.y, yi.z), this; + } + setFromPoints(e) { + const t = []; + for (let n = 0, r = e.length; n < r; n++) { + const s = e[n]; + t.push(s.x, s.y, s.z || 0); + } + return this.setAttribute("position", new Ft(t, 3)), this; + } + computeBoundingBox() { + this.boundingBox === null && (this.boundingBox = new Rt()); + const e = this.attributes.position, t = this.morphAttributes.position; + if (e && e.isGLBufferAttribute) { + console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.", this), this.boundingBox.set( + new P(-1 / 0, -1 / 0, -1 / 0), + new P(1 / 0, 1 / 0, 1 / 0) + ); + return; + } + if (e !== void 0) { + if (this.boundingBox.setFromBufferAttribute(e), t) + for (let n = 0, r = t.length; n < r; n++) { + const s = t[n]; + Ut.setFromBufferAttribute(s), this.morphTargetsRelative ? (pt.addVectors(this.boundingBox.min, Ut.min), this.boundingBox.expandByPoint(pt), pt.addVectors(this.boundingBox.max, Ut.max), this.boundingBox.expandByPoint(pt)) : (this.boundingBox.expandByPoint(Ut.min), this.boundingBox.expandByPoint(Ut.max)); + } + } else + this.boundingBox.makeEmpty(); + (isNaN(this.boundingBox.min.x) || isNaN(this.boundingBox.min.y) || isNaN(this.boundingBox.min.z)) && console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this); + } + computeBoundingSphere() { + this.boundingSphere === null && (this.boundingSphere = new vo()); + const e = this.attributes.position, t = this.morphAttributes.position; + if (e && e.isGLBufferAttribute) { + console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.", this), this.boundingSphere.set(new P(), 1 / 0); + return; + } + if (e) { + const n = this.boundingSphere.center; + if (Ut.setFromBufferAttribute(e), t) + for (let s = 0, a = t.length; s < a; s++) { + const o = t[s]; + rr.setFromBufferAttribute(o), this.morphTargetsRelative ? (pt.addVectors(Ut.min, rr.min), Ut.expandByPoint(pt), pt.addVectors(Ut.max, rr.max), Ut.expandByPoint(pt)) : (Ut.expandByPoint(rr.min), Ut.expandByPoint(rr.max)); + } + Ut.getCenter(n); + let r = 0; + for (let s = 0, a = e.count; s < a; s++) + pt.fromBufferAttribute(e, s), r = Math.max(r, n.distanceToSquared(pt)); + if (t) + for (let s = 0, a = t.length; s < a; s++) { + const o = t[s], l = this.morphTargetsRelative; + for (let c = 0, u = o.count; c < u; c++) + pt.fromBufferAttribute(o, c), l && (yi.fromBufferAttribute(e, c), pt.add(yi)), r = Math.max(r, n.distanceToSquared(pt)); + } + this.boundingSphere.radius = Math.sqrt(r), isNaN(this.boundingSphere.radius) && console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this); + } + } + computeTangents() { + const e = this.index, t = this.attributes; + if (e === null || t.position === void 0 || t.normal === void 0 || t.uv === void 0) { + console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)"); + return; + } + const n = t.position, r = t.normal, s = t.uv; + this.hasAttribute("tangent") === !1 && this.setAttribute("tangent", new Wt(new Float32Array(4 * n.count), 4)); + const a = this.getAttribute("tangent"), o = [], l = []; + for (let I = 0; I < n.count; I++) + o[I] = new P(), l[I] = new P(); + const c = new P(), u = new P(), f = new P(), h = new me(), p = new me(), g = new me(), v = new P(), m = new P(); + function d(I, W, S) { + c.fromBufferAttribute(n, I), u.fromBufferAttribute(n, W), f.fromBufferAttribute(n, S), h.fromBufferAttribute(s, I), p.fromBufferAttribute(s, W), g.fromBufferAttribute(s, S), u.sub(c), f.sub(c), p.sub(h), g.sub(h); + const T = 1 / (p.x * g.y - g.x * p.y); + isFinite(T) && (v.copy(u).multiplyScalar(g.y).addScaledVector(f, -p.y).multiplyScalar(T), m.copy(f).multiplyScalar(p.x).addScaledVector(u, -g.x).multiplyScalar(T), o[I].add(v), o[W].add(v), o[S].add(v), l[I].add(m), l[W].add(m), l[S].add(m)); + } + let M = this.groups; + M.length === 0 && (M = [{ + start: 0, + count: e.count + }]); + for (let I = 0, W = M.length; I < W; ++I) { + const S = M[I], T = S.start, Y = S.count; + for (let K = T, L = T + Y; K < L; K += 3) + d( + e.getX(K + 0), + e.getX(K + 1), + e.getX(K + 2) + ); + } + const _ = new P(), A = new P(), C = new P(), E = new P(); + function b(I) { + C.fromBufferAttribute(r, I), E.copy(C); + const W = o[I]; + _.copy(W), _.sub(C.multiplyScalar(C.dot(W))).normalize(), A.crossVectors(E, W); + const T = A.dot(l[I]) < 0 ? -1 : 1; + a.setXYZW(I, _.x, _.y, _.z, T); + } + for (let I = 0, W = M.length; I < W; ++I) { + const S = M[I], T = S.start, Y = S.count; + for (let K = T, L = T + Y; K < L; K += 3) + b(e.getX(K + 0)), b(e.getX(K + 1)), b(e.getX(K + 2)); + } + } + computeVertexNormals() { + const e = this.index, t = this.getAttribute("position"); + if (t !== void 0) { + let n = this.getAttribute("normal"); + if (n === void 0) + n = new Wt(new Float32Array(t.count * 3), 3), this.setAttribute("normal", n); + else + for (let h = 0, p = n.count; h < p; h++) + n.setXYZ(h, 0, 0, 0); + const r = new P(), s = new P(), a = new P(), o = new P(), l = new P(), c = new P(), u = new P(), f = new P(); + if (e) + for (let h = 0, p = e.count; h < p; h += 3) { + const g = e.getX(h + 0), v = e.getX(h + 1), m = e.getX(h + 2); + r.fromBufferAttribute(t, g), s.fromBufferAttribute(t, v), a.fromBufferAttribute(t, m), u.subVectors(a, s), f.subVectors(r, s), u.cross(f), o.fromBufferAttribute(n, g), l.fromBufferAttribute(n, v), c.fromBufferAttribute(n, m), o.add(u), l.add(u), c.add(u), n.setXYZ(g, o.x, o.y, o.z), n.setXYZ(v, l.x, l.y, l.z), n.setXYZ(m, c.x, c.y, c.z); + } + else + for (let h = 0, p = t.count; h < p; h += 3) + r.fromBufferAttribute(t, h + 0), s.fromBufferAttribute(t, h + 1), a.fromBufferAttribute(t, h + 2), u.subVectors(a, s), f.subVectors(r, s), u.cross(f), n.setXYZ(h + 0, u.x, u.y, u.z), n.setXYZ(h + 1, u.x, u.y, u.z), n.setXYZ(h + 2, u.x, u.y, u.z); + this.normalizeNormals(), n.needsUpdate = !0; + } + } + normalizeNormals() { + const e = this.attributes.normal; + for (let t = 0, n = e.count; t < n; t++) + pt.fromBufferAttribute(e, t), pt.normalize(), e.setXYZ(t, pt.x, pt.y, pt.z); + } + toNonIndexed() { + function e(o, l) { + const c = o.array, u = o.itemSize, f = o.normalized, h = new c.constructor(l.length * u); + let p = 0, g = 0; + for (let v = 0, m = l.length; v < m; v++) { + o.isInterleavedBufferAttribute ? p = l[v] * o.data.stride + o.offset : p = l[v] * u; + for (let d = 0; d < u; d++) + h[g++] = c[p++]; + } + return new Wt(h, u, f); + } + if (this.index === null) + return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."), this; + const t = new Yt(), n = this.index.array, r = this.attributes; + for (const o in r) { + const l = r[o], c = e(l, n); + t.setAttribute(o, c); + } + const s = this.morphAttributes; + for (const o in s) { + const l = [], c = s[o]; + for (let u = 0, f = c.length; u < f; u++) { + const h = c[u], p = e(h, n); + l.push(p); + } + t.morphAttributes[o] = l; + } + t.morphTargetsRelative = this.morphTargetsRelative; + const a = this.groups; + for (let o = 0, l = a.length; o < l; o++) { + const c = a[o]; + t.addGroup(c.start, c.count, c.materialIndex); + } + return t; + } + toJSON() { + const e = { + metadata: { + version: 4.6, + type: "BufferGeometry", + generator: "BufferGeometry.toJSON" + } + }; + if (e.uuid = this.uuid, e.type = this.type, this.name !== "" && (e.name = this.name), Object.keys(this.userData).length > 0 && (e.userData = this.userData), this.parameters !== void 0) { + const l = this.parameters; + for (const c in l) + l[c] !== void 0 && (e[c] = l[c]); + return e; + } + e.data = { attributes: {} }; + const t = this.index; + t !== null && (e.data.index = { + type: t.array.constructor.name, + array: Array.prototype.slice.call(t.array) + }); + const n = this.attributes; + for (const l in n) { + const c = n[l]; + e.data.attributes[l] = c.toJSON(e.data); + } + const r = {}; + let s = !1; + for (const l in this.morphAttributes) { + const c = this.morphAttributes[l], u = []; + for (let f = 0, h = c.length; f < h; f++) { + const p = c[f]; + u.push(p.toJSON(e.data)); + } + u.length > 0 && (r[l] = u, s = !0); + } + s && (e.data.morphAttributes = r, e.data.morphTargetsRelative = this.morphTargetsRelative); + const a = this.groups; + a.length > 0 && (e.data.groups = JSON.parse(JSON.stringify(a))); + const o = this.boundingSphere; + return o !== null && (e.data.boundingSphere = { + center: o.center.toArray(), + radius: o.radius + }), e; + } + clone() { + return new this.constructor().copy(this); + } + copy(e) { + this.index = null, this.attributes = {}, this.morphAttributes = {}, this.groups = [], this.boundingBox = null, this.boundingSphere = null; + const t = {}; + this.name = e.name; + const n = e.index; + n !== null && this.setIndex(n.clone(t)); + const r = e.attributes; + for (const c in r) { + const u = r[c]; + this.setAttribute(c, u.clone(t)); + } + const s = e.morphAttributes; + for (const c in s) { + const u = [], f = s[c]; + for (let h = 0, p = f.length; h < p; h++) + u.push(f[h].clone(t)); + this.morphAttributes[c] = u; + } + this.morphTargetsRelative = e.morphTargetsRelative; + const a = e.groups; + for (let c = 0, u = a.length; c < u; c++) { + const f = a[c]; + this.addGroup(f.start, f.count, f.materialIndex); + } + const o = e.boundingBox; + o !== null && (this.boundingBox = o.clone()); + const l = e.boundingSphere; + return l !== null && (this.boundingSphere = l.clone()), this.drawRange.start = e.drawRange.start, this.drawRange.count = e.drawRange.count, this.userData = e.userData, this; + } + dispose() { + this.dispatchEvent({ type: "dispose" }); + } +} +const Ca = /* @__PURE__ */ new ke(), Kn = /* @__PURE__ */ new Jl(), Tr = /* @__PURE__ */ new vo(), Ra = /* @__PURE__ */ new P(), Ai = /* @__PURE__ */ new P(), Ei = /* @__PURE__ */ new P(), bi = /* @__PURE__ */ new P(), Gs = /* @__PURE__ */ new P(), wr = /* @__PURE__ */ new P(), Cr = /* @__PURE__ */ new me(), Rr = /* @__PURE__ */ new me(), Pr = /* @__PURE__ */ new me(), Pa = /* @__PURE__ */ new P(), La = /* @__PURE__ */ new P(), Da = /* @__PURE__ */ new P(), Lr = /* @__PURE__ */ new P(), Dr = /* @__PURE__ */ new P(); +class at extends gt { + constructor(e = new Yt(), t = new oi()) { + super(), this.isMesh = !0, this.type = "Mesh", this.geometry = e, this.material = t, this.updateMorphTargets(); + } + copy(e, t) { + return super.copy(e, t), e.morphTargetInfluences !== void 0 && (this.morphTargetInfluences = e.morphTargetInfluences.slice()), e.morphTargetDictionary !== void 0 && (this.morphTargetDictionary = Object.assign({}, e.morphTargetDictionary)), this.material = Array.isArray(e.material) ? e.material.slice() : e.material, this.geometry = e.geometry, this; + } + updateMorphTargets() { + const t = this.geometry.morphAttributes, n = Object.keys(t); + if (n.length > 0) { + const r = t[n[0]]; + if (r !== void 0) { + this.morphTargetInfluences = [], this.morphTargetDictionary = {}; + for (let s = 0, a = r.length; s < a; s++) { + const o = r[s].name || String(s); + this.morphTargetInfluences.push(0), this.morphTargetDictionary[o] = s; + } + } + } + } + getVertexPosition(e, t) { + const n = this.geometry, r = n.attributes.position, s = n.morphAttributes.position, a = n.morphTargetsRelative; + t.fromBufferAttribute(r, e); + const o = this.morphTargetInfluences; + if (s && o) { + wr.set(0, 0, 0); + for (let l = 0, c = s.length; l < c; l++) { + const u = o[l], f = s[l]; + u !== 0 && (Gs.fromBufferAttribute(f, e), a ? wr.addScaledVector(Gs, u) : wr.addScaledVector(Gs.sub(t), u)); + } + t.add(wr); + } + return t; + } + raycast(e, t) { + const n = this.geometry, r = this.material, s = this.matrixWorld; + r !== void 0 && (n.boundingSphere === null && n.computeBoundingSphere(), Tr.copy(n.boundingSphere), Tr.applyMatrix4(s), Kn.copy(e.ray).recast(e.near), !(Tr.containsPoint(Kn.origin) === !1 && (Kn.intersectSphere(Tr, Ra) === null || Kn.origin.distanceToSquared(Ra) > (e.far - e.near) ** 2)) && (Ca.copy(s).invert(), Kn.copy(e.ray).applyMatrix4(Ca), !(n.boundingBox !== null && Kn.intersectsBox(n.boundingBox) === !1) && this._computeIntersections(e, t, Kn))); + } + _computeIntersections(e, t, n) { + let r; + const s = this.geometry, a = this.material, o = s.index, l = s.attributes.position, c = s.attributes.uv, u = s.attributes.uv1, f = s.attributes.normal, h = s.groups, p = s.drawRange; + if (o !== null) + if (Array.isArray(a)) + for (let g = 0, v = h.length; g < v; g++) { + const m = h[g], d = a[m.materialIndex], M = Math.max(m.start, p.start), _ = Math.min(o.count, Math.min(m.start + m.count, p.start + p.count)); + for (let A = M, C = _; A < C; A += 3) { + const E = o.getX(A), b = o.getX(A + 1), I = o.getX(A + 2); + r = Ir(this, d, e, n, c, u, f, E, b, I), r && (r.faceIndex = Math.floor(A / 3), r.face.materialIndex = m.materialIndex, t.push(r)); + } + } + else { + const g = Math.max(0, p.start), v = Math.min(o.count, p.start + p.count); + for (let m = g, d = v; m < d; m += 3) { + const M = o.getX(m), _ = o.getX(m + 1), A = o.getX(m + 2); + r = Ir(this, a, e, n, c, u, f, M, _, A), r && (r.faceIndex = Math.floor(m / 3), t.push(r)); + } + } + else if (l !== void 0) + if (Array.isArray(a)) + for (let g = 0, v = h.length; g < v; g++) { + const m = h[g], d = a[m.materialIndex], M = Math.max(m.start, p.start), _ = Math.min(l.count, Math.min(m.start + m.count, p.start + p.count)); + for (let A = M, C = _; A < C; A += 3) { + const E = A, b = A + 1, I = A + 2; + r = Ir(this, d, e, n, c, u, f, E, b, I), r && (r.faceIndex = Math.floor(A / 3), r.face.materialIndex = m.materialIndex, t.push(r)); + } + } + else { + const g = Math.max(0, p.start), v = Math.min(l.count, p.start + p.count); + for (let m = g, d = v; m < d; m += 3) { + const M = m, _ = m + 1, A = m + 2; + r = Ir(this, a, e, n, c, u, f, M, _, A), r && (r.faceIndex = Math.floor(m / 3), t.push(r)); + } + } + } +} +function hh(i, e, t, n, r, s, a, o) { + let l; + if (e.side === Pt ? l = n.intersectTriangle(a, s, r, !0, o) : l = n.intersectTriangle(r, s, a, e.side === hn, o), l === null) + return null; + Dr.copy(o), Dr.applyMatrix4(i.matrixWorld); + const c = t.ray.origin.distanceTo(Dr); + return c < t.near || c > t.far ? null : { + distance: c, + point: Dr.clone(), + object: i + }; +} +function Ir(i, e, t, n, r, s, a, o, l, c) { + i.getVertexPosition(o, Ai), i.getVertexPosition(l, Ei), i.getVertexPosition(c, bi); + const u = hh(i, e, t, n, Ai, Ei, bi, Lr); + if (u) { + r && (Cr.fromBufferAttribute(r, o), Rr.fromBufferAttribute(r, l), Pr.fromBufferAttribute(r, c), u.uv = ln.getInterpolation(Lr, Ai, Ei, bi, Cr, Rr, Pr, new me())), s && (Cr.fromBufferAttribute(s, o), Rr.fromBufferAttribute(s, l), Pr.fromBufferAttribute(s, c), u.uv1 = ln.getInterpolation(Lr, Ai, Ei, bi, Cr, Rr, Pr, new me())), a && (Pa.fromBufferAttribute(a, o), La.fromBufferAttribute(a, l), Da.fromBufferAttribute(a, c), u.normal = ln.getInterpolation(Lr, Ai, Ei, bi, Pa, La, Da, new P()), u.normal.dot(n.direction) > 0 && u.normal.multiplyScalar(-1)); + const f = { + a: o, + b: l, + c, + normal: new P(), + materialIndex: 0 + }; + ln.getNormal(Ai, Ei, bi, f.normal), u.face = f; + } + return u; +} +class Qi extends Yt { + constructor(e = 1, t = 1, n = 1, r = 1, s = 1, a = 1) { + super(), this.type = "BoxGeometry", this.parameters = { + width: e, + height: t, + depth: n, + widthSegments: r, + heightSegments: s, + depthSegments: a + }; + const o = this; + r = Math.floor(r), s = Math.floor(s), a = Math.floor(a); + const l = [], c = [], u = [], f = []; + let h = 0, p = 0; + g("z", "y", "x", -1, -1, n, t, e, a, s, 0), g("z", "y", "x", 1, -1, n, t, -e, a, s, 1), g("x", "z", "y", 1, 1, e, n, t, r, a, 2), g("x", "z", "y", 1, -1, e, n, -t, r, a, 3), g("x", "y", "z", 1, -1, e, t, n, r, s, 4), g("x", "y", "z", -1, -1, e, t, -n, r, s, 5), this.setIndex(l), this.setAttribute("position", new Ft(c, 3)), this.setAttribute("normal", new Ft(u, 3)), this.setAttribute("uv", new Ft(f, 2)); + function g(v, m, d, M, _, A, C, E, b, I, W) { + const S = A / b, T = C / I, Y = A / 2, K = C / 2, L = E / 2, N = b + 1, O = I + 1; + let B = 0, j = 0; + const q = new P(); + for (let J = 0; J < O; J++) { + const ne = J * T - K; + for (let ue = 0; ue < N; ue++) { + const Z = ue * S - Y; + q[v] = Z * M, q[m] = ne * _, q[d] = L, c.push(q.x, q.y, q.z), q[v] = 0, q[m] = 0, q[d] = E > 0 ? 1 : -1, u.push(q.x, q.y, q.z), f.push(ue / b), f.push(1 - J / I), B += 1; + } + } + for (let J = 0; J < I; J++) + for (let ne = 0; ne < b; ne++) { + const ue = h + ne + N * J, Z = h + ne + N * (J + 1), H = h + (ne + 1) + N * (J + 1), ee = h + (ne + 1) + N * J; + l.push(ue, Z, ee), l.push(Z, H, ee), j += 6; + } + o.addGroup(p, j, W), p += j, h += B; + } + } + copy(e) { + return super.copy(e), this.parameters = Object.assign({}, e.parameters), this; + } + static fromJSON(e) { + return new Qi(e.width, e.height, e.depth, e.widthSegments, e.heightSegments, e.depthSegments); + } +} +function Vi(i) { + const e = {}; + for (const t in i) { + e[t] = {}; + for (const n in i[t]) { + const r = i[t][n]; + r && (r.isColor || r.isMatrix3 || r.isMatrix4 || r.isVector2 || r.isVector3 || r.isVector4 || r.isTexture || r.isQuaternion) ? r.isRenderTargetTexture ? (console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."), e[t][n] = null) : e[t][n] = r.clone() : Array.isArray(r) ? e[t][n] = r.slice() : e[t][n] = r; + } + } + return e; +} +function bt(i) { + const e = {}; + for (let t = 0; t < i.length; t++) { + const n = Vi(i[t]); + for (const r in n) + e[r] = n[r]; + } + return e; +} +function dh(i) { + const e = []; + for (let t = 0; t < i.length; t++) + e.push(i[t].clone()); + return e; +} +function ic(i) { + return i.getRenderTarget() === null ? i.outputColorSpace : Ze.workingColorSpace; +} +const ph = { clone: Vi, merge: bt }; +var mh = `void main() { + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); +}`, gh = `void main() { + gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 ); +}`; +class Xt extends as { + constructor(e) { + super(), this.isShaderMaterial = !0, this.type = "ShaderMaterial", this.defines = {}, this.uniforms = {}, this.uniformsGroups = [], this.vertexShader = mh, this.fragmentShader = gh, this.linewidth = 1, this.wireframe = !1, this.wireframeLinewidth = 1, this.fog = !1, this.lights = !1, this.clipping = !1, this.forceSinglePass = !0, this.extensions = { + derivatives: !1, + // set to use derivatives + fragDepth: !1, + // set to use fragment depth values + drawBuffers: !1, + // set to use draw buffers + shaderTextureLOD: !1, + // set to use shader texture LOD + clipCullDistance: !1, + // set to use vertex shader clipping + multiDraw: !1 + // set to use vertex shader multi_draw / enable gl_DrawID + }, this.defaultAttributeValues = { + color: [1, 1, 1], + uv: [0, 0], + uv1: [0, 0] + }, this.index0AttributeName = void 0, this.uniformsNeedUpdate = !1, this.glslVersion = null, e !== void 0 && this.setValues(e); + } + copy(e) { + return super.copy(e), this.fragmentShader = e.fragmentShader, this.vertexShader = e.vertexShader, this.uniforms = Vi(e.uniforms), this.uniformsGroups = dh(e.uniformsGroups), this.defines = Object.assign({}, e.defines), this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.fog = e.fog, this.lights = e.lights, this.clipping = e.clipping, this.extensions = Object.assign({}, e.extensions), this.glslVersion = e.glslVersion, this; + } + toJSON(e) { + const t = super.toJSON(e); + t.glslVersion = this.glslVersion, t.uniforms = {}; + for (const r in this.uniforms) { + const a = this.uniforms[r].value; + a && a.isTexture ? t.uniforms[r] = { + type: "t", + value: a.toJSON(e).uuid + } : a && a.isColor ? t.uniforms[r] = { + type: "c", + value: a.getHex() + } : a && a.isVector2 ? t.uniforms[r] = { + type: "v2", + value: a.toArray() + } : a && a.isVector3 ? t.uniforms[r] = { + type: "v3", + value: a.toArray() + } : a && a.isVector4 ? t.uniforms[r] = { + type: "v4", + value: a.toArray() + } : a && a.isMatrix3 ? t.uniforms[r] = { + type: "m3", + value: a.toArray() + } : a && a.isMatrix4 ? t.uniforms[r] = { + type: "m4", + value: a.toArray() + } : t.uniforms[r] = { + value: a + }; + } + Object.keys(this.defines).length > 0 && (t.defines = this.defines), t.vertexShader = this.vertexShader, t.fragmentShader = this.fragmentShader, t.lights = this.lights, t.clipping = this.clipping; + const n = {}; + for (const r in this.extensions) + this.extensions[r] === !0 && (n[r] = !0); + return Object.keys(n).length > 0 && (t.extensions = n), t; + } +} +class rc extends gt { + constructor() { + super(), this.isCamera = !0, this.type = "Camera", this.matrixWorldInverse = new ke(), this.projectionMatrix = new ke(), this.projectionMatrixInverse = new ke(), this.coordinateSystem = Mn; + } + copy(e, t) { + return super.copy(e, t), this.matrixWorldInverse.copy(e.matrixWorldInverse), this.projectionMatrix.copy(e.projectionMatrix), this.projectionMatrixInverse.copy(e.projectionMatrixInverse), this.coordinateSystem = e.coordinateSystem, this; + } + getWorldDirection(e) { + return super.getWorldDirection(e).negate(); + } + updateMatrixWorld(e) { + super.updateMatrixWorld(e), this.matrixWorldInverse.copy(this.matrixWorld).invert(); + } + updateWorldMatrix(e, t) { + super.updateWorldMatrix(e, t), this.matrixWorldInverse.copy(this.matrixWorld).invert(); + } + clone() { + return new this.constructor().copy(this); + } +} +const Un = /* @__PURE__ */ new P(), Ia = /* @__PURE__ */ new me(), Ua = /* @__PURE__ */ new me(); +class Ht extends rc { + constructor(e = 50, t = 1, n = 0.1, r = 2e3) { + super(), this.isPerspectiveCamera = !0, this.type = "PerspectiveCamera", this.fov = e, this.zoom = 1, this.near = n, this.far = r, this.focus = 10, this.aspect = t, this.view = null, this.filmGauge = 35, this.filmOffset = 0, this.updateProjectionMatrix(); + } + copy(e, t) { + return super.copy(e, t), this.fov = e.fov, this.zoom = e.zoom, this.near = e.near, this.far = e.far, this.focus = e.focus, this.aspect = e.aspect, this.view = e.view === null ? null : Object.assign({}, e.view), this.filmGauge = e.filmGauge, this.filmOffset = e.filmOffset, this; + } + /** + * Sets the FOV by focal length in respect to the current .filmGauge. + * + * The default film gauge is 35, so that the focal length can be specified for + * a 35mm (full frame) camera. + * + * Values for focal length and film gauge must have the same unit. + */ + setFocalLength(e) { + const t = 0.5 * this.getFilmHeight() / e; + this.fov = fr * 2 * Math.atan(t), this.updateProjectionMatrix(); + } + /** + * Calculates the focal length from the current .fov and .filmGauge. + */ + getFocalLength() { + const e = Math.tan(sr * 0.5 * this.fov); + return 0.5 * this.getFilmHeight() / e; + } + getEffectiveFOV() { + return fr * 2 * Math.atan( + Math.tan(sr * 0.5 * this.fov) / this.zoom + ); + } + getFilmWidth() { + return this.filmGauge * Math.min(this.aspect, 1); + } + getFilmHeight() { + return this.filmGauge / Math.max(this.aspect, 1); + } + /** + * Computes the 2D bounds of the camera's viewable rectangle at a given distance along the viewing direction. + * Sets minTarget and maxTarget to the coordinates of the lower-left and upper-right corners of the view rectangle. + */ + getViewBounds(e, t, n) { + Un.set(-1, -1, 0.5).applyMatrix4(this.projectionMatrixInverse), t.set(Un.x, Un.y).multiplyScalar(-e / Un.z), Un.set(1, 1, 0.5).applyMatrix4(this.projectionMatrixInverse), n.set(Un.x, Un.y).multiplyScalar(-e / Un.z); + } + /** + * Computes the width and height of the camera's viewable rectangle at a given distance along the viewing direction. + * Copies the result into the target Vector2, where x is width and y is height. + */ + getViewSize(e, t) { + return this.getViewBounds(e, Ia, Ua), t.subVectors(Ua, Ia); + } + /** + * Sets an offset in a larger frustum. This is useful for multi-window or + * multi-monitor/multi-machine setups. + * + * For example, if you have 3x2 monitors and each monitor is 1920x1080 and + * the monitors are in grid like this + * + * +---+---+---+ + * | A | B | C | + * +---+---+---+ + * | D | E | F | + * +---+---+---+ + * + * then for each monitor you would call it like this + * + * const w = 1920; + * const h = 1080; + * const fullWidth = w * 3; + * const fullHeight = h * 2; + * + * --A-- + * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h ); + * --B-- + * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h ); + * --C-- + * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h ); + * --D-- + * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h ); + * --E-- + * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h ); + * --F-- + * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h ); + * + * Note there is no reason monitors have to be the same size or in a grid. + */ + setViewOffset(e, t, n, r, s, a) { + this.aspect = e / t, this.view === null && (this.view = { + enabled: !0, + fullWidth: 1, + fullHeight: 1, + offsetX: 0, + offsetY: 0, + width: 1, + height: 1 + }), this.view.enabled = !0, this.view.fullWidth = e, this.view.fullHeight = t, this.view.offsetX = n, this.view.offsetY = r, this.view.width = s, this.view.height = a, this.updateProjectionMatrix(); + } + clearViewOffset() { + this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix(); + } + updateProjectionMatrix() { + const e = this.near; + let t = e * Math.tan(sr * 0.5 * this.fov) / this.zoom, n = 2 * t, r = this.aspect * n, s = -0.5 * r; + const a = this.view; + if (this.view !== null && this.view.enabled) { + const l = a.fullWidth, c = a.fullHeight; + s += a.offsetX * r / l, t -= a.offsetY * n / c, r *= a.width / l, n *= a.height / c; + } + const o = this.filmOffset; + o !== 0 && (s += e * o / this.getFilmWidth()), this.projectionMatrix.makePerspective(s, s + r, t, t - n, e, this.far, this.coordinateSystem), this.projectionMatrixInverse.copy(this.projectionMatrix).invert(); + } + toJSON(e) { + const t = super.toJSON(e); + return t.object.fov = this.fov, t.object.zoom = this.zoom, t.object.near = this.near, t.object.far = this.far, t.object.focus = this.focus, t.object.aspect = this.aspect, this.view !== null && (t.object.view = Object.assign({}, this.view)), t.object.filmGauge = this.filmGauge, t.object.filmOffset = this.filmOffset, t; + } +} +const Ti = -90, wi = 1; +class _h extends gt { + constructor(e, t, n) { + super(), this.type = "CubeCamera", this.renderTarget = n, this.coordinateSystem = null, this.activeMipmapLevel = 0; + const r = new Ht(Ti, wi, e, t); + r.layers = this.layers, this.add(r); + const s = new Ht(Ti, wi, e, t); + s.layers = this.layers, this.add(s); + const a = new Ht(Ti, wi, e, t); + a.layers = this.layers, this.add(a); + const o = new Ht(Ti, wi, e, t); + o.layers = this.layers, this.add(o); + const l = new Ht(Ti, wi, e, t); + l.layers = this.layers, this.add(l); + const c = new Ht(Ti, wi, e, t); + c.layers = this.layers, this.add(c); + } + updateCoordinateSystem() { + const e = this.coordinateSystem, t = this.children.concat(), [n, r, s, a, o, l] = t; + for (const c of t) + this.remove(c); + if (e === Mn) + n.up.set(0, 1, 0), n.lookAt(1, 0, 0), r.up.set(0, 1, 0), r.lookAt(-1, 0, 0), s.up.set(0, 0, -1), s.lookAt(0, 1, 0), a.up.set(0, 0, 1), a.lookAt(0, -1, 0), o.up.set(0, 1, 0), o.lookAt(0, 0, 1), l.up.set(0, 1, 0), l.lookAt(0, 0, -1); + else if (e === Qr) + n.up.set(0, -1, 0), n.lookAt(-1, 0, 0), r.up.set(0, -1, 0), r.lookAt(1, 0, 0), s.up.set(0, 0, 1), s.lookAt(0, 1, 0), a.up.set(0, 0, -1), a.lookAt(0, -1, 0), o.up.set(0, -1, 0), o.lookAt(0, 0, 1), l.up.set(0, -1, 0), l.lookAt(0, 0, -1); + else + throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: " + e); + for (const c of t) + this.add(c), c.updateMatrixWorld(); + } + update(e, t) { + this.parent === null && this.updateMatrixWorld(); + const { renderTarget: n, activeMipmapLevel: r } = this; + this.coordinateSystem !== e.coordinateSystem && (this.coordinateSystem = e.coordinateSystem, this.updateCoordinateSystem()); + const [s, a, o, l, c, u] = this.children, f = e.getRenderTarget(), h = e.getActiveCubeFace(), p = e.getActiveMipmapLevel(), g = e.xr.enabled; + e.xr.enabled = !1; + const v = n.texture.generateMipmaps; + n.texture.generateMipmaps = !1, e.setRenderTarget(n, 0, r), e.render(t, s), e.setRenderTarget(n, 1, r), e.render(t, a), e.setRenderTarget(n, 2, r), e.render(t, o), e.setRenderTarget(n, 3, r), e.render(t, l), e.setRenderTarget(n, 4, r), e.render(t, c), n.texture.generateMipmaps = v, e.setRenderTarget(n, 5, r), e.render(t, u), e.setRenderTarget(f, h, p), e.xr.enabled = g, n.texture.needsPMREMUpdate = !0; + } +} +class sc extends Tt { + constructor(e, t, n, r, s, a, o, l, c, u) { + e = e !== void 0 ? e : [], t = t !== void 0 ? t : zi, super(e, t, n, r, s, a, o, l, c, u), this.isCubeTexture = !0, this.flipY = !1; + } + get images() { + return this.image; + } + set images(e) { + this.image = e; + } +} +class vh extends Vn { + constructor(e = 1, t = {}) { + super(e, e, t), this.isWebGLCubeRenderTarget = !0; + const n = { width: e, height: e, depth: 1 }, r = [n, n, n, n, n, n]; + this.texture = new sc(r, t.mapping, t.wrapS, t.wrapT, t.magFilter, t.minFilter, t.format, t.type, t.anisotropy, t.colorSpace), this.texture.isRenderTargetTexture = !0, this.texture.generateMipmaps = t.generateMipmaps !== void 0 ? t.generateMipmaps : !1, this.texture.minFilter = t.minFilter !== void 0 ? t.minFilter : Ct; + } + fromEquirectangularTexture(e, t) { + this.texture.type = t.type, this.texture.colorSpace = t.colorSpace, this.texture.generateMipmaps = t.generateMipmaps, this.texture.minFilter = t.minFilter, this.texture.magFilter = t.magFilter; + const n = { + uniforms: { + tEquirect: { value: null } + }, + vertexShader: ( + /* glsl */ + ` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + ` + ), + fragmentShader: ( + /* glsl */ + ` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + ` + ) + }, r = new Qi(5, 5, 5), s = new Xt({ + name: "CubemapFromEquirect", + uniforms: Vi(n.uniforms), + vertexShader: n.vertexShader, + fragmentShader: n.fragmentShader, + side: Pt, + blending: zn + }); + s.uniforms.tEquirect.value = t; + const a = new at(r, s), o = t.minFilter; + return t.minFilter === ni && (t.minFilter = Ct), new _h(1, 10, this).update(e, a), t.minFilter = o, a.geometry.dispose(), a.material.dispose(), this; + } + clear(e, t, n, r) { + const s = e.getRenderTarget(); + for (let a = 0; a < 6; a++) + e.setRenderTarget(this, a), e.clear(t, n, r); + e.setRenderTarget(s); + } +} +const Hs = /* @__PURE__ */ new P(), xh = /* @__PURE__ */ new P(), Sh = /* @__PURE__ */ new be(); +class Fn { + constructor(e = new P(1, 0, 0), t = 0) { + this.isPlane = !0, this.normal = e, this.constant = t; + } + set(e, t) { + return this.normal.copy(e), this.constant = t, this; + } + setComponents(e, t, n, r) { + return this.normal.set(e, t, n), this.constant = r, this; + } + setFromNormalAndCoplanarPoint(e, t) { + return this.normal.copy(e), this.constant = -t.dot(this.normal), this; + } + setFromCoplanarPoints(e, t, n) { + const r = Hs.subVectors(n, t).cross(xh.subVectors(e, t)).normalize(); + return this.setFromNormalAndCoplanarPoint(r, e), this; + } + copy(e) { + return this.normal.copy(e.normal), this.constant = e.constant, this; + } + normalize() { + const e = 1 / this.normal.length(); + return this.normal.multiplyScalar(e), this.constant *= e, this; + } + negate() { + return this.constant *= -1, this.normal.negate(), this; + } + distanceToPoint(e) { + return this.normal.dot(e) + this.constant; + } + distanceToSphere(e) { + return this.distanceToPoint(e.center) - e.radius; + } + projectPoint(e, t) { + return t.copy(e).addScaledVector(this.normal, -this.distanceToPoint(e)); + } + intersectLine(e, t) { + const n = e.delta(Hs), r = this.normal.dot(n); + if (r === 0) + return this.distanceToPoint(e.start) === 0 ? t.copy(e.start) : null; + const s = -(e.start.dot(this.normal) + this.constant) / r; + return s < 0 || s > 1 ? null : t.copy(e.start).addScaledVector(n, s); + } + intersectsLine(e) { + const t = this.distanceToPoint(e.start), n = this.distanceToPoint(e.end); + return t < 0 && n > 0 || n < 0 && t > 0; + } + intersectsBox(e) { + return e.intersectsPlane(this); + } + intersectsSphere(e) { + return e.intersectsPlane(this); + } + coplanarPoint(e) { + return e.copy(this.normal).multiplyScalar(-this.constant); + } + applyMatrix4(e, t) { + const n = t || Sh.getNormalMatrix(e), r = this.coplanarPoint(Hs).applyMatrix4(e), s = this.normal.applyMatrix3(n).normalize(); + return this.constant = -r.dot(s), this; + } + translate(e) { + return this.constant -= e.dot(this.normal), this; + } + equals(e) { + return e.normal.equals(this.normal) && e.constant === this.constant; + } + clone() { + return new this.constructor().copy(this); + } +} +const Qn = /* @__PURE__ */ new vo(), Ur = /* @__PURE__ */ new P(); +class oc { + constructor(e = new Fn(), t = new Fn(), n = new Fn(), r = new Fn(), s = new Fn(), a = new Fn()) { + this.planes = [e, t, n, r, s, a]; + } + set(e, t, n, r, s, a) { + const o = this.planes; + return o[0].copy(e), o[1].copy(t), o[2].copy(n), o[3].copy(r), o[4].copy(s), o[5].copy(a), this; + } + copy(e) { + const t = this.planes; + for (let n = 0; n < 6; n++) + t[n].copy(e.planes[n]); + return this; + } + setFromProjectionMatrix(e, t = Mn) { + const n = this.planes, r = e.elements, s = r[0], a = r[1], o = r[2], l = r[3], c = r[4], u = r[5], f = r[6], h = r[7], p = r[8], g = r[9], v = r[10], m = r[11], d = r[12], M = r[13], _ = r[14], A = r[15]; + if (n[0].setComponents(l - s, h - c, m - p, A - d).normalize(), n[1].setComponents(l + s, h + c, m + p, A + d).normalize(), n[2].setComponents(l + a, h + u, m + g, A + M).normalize(), n[3].setComponents(l - a, h - u, m - g, A - M).normalize(), n[4].setComponents(l - o, h - f, m - v, A - _).normalize(), t === Mn) + n[5].setComponents(l + o, h + f, m + v, A + _).normalize(); + else if (t === Qr) + n[5].setComponents(o, f, v, _).normalize(); + else + throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: " + t); + return this; + } + intersectsObject(e) { + if (e.boundingSphere !== void 0) + e.boundingSphere === null && e.computeBoundingSphere(), Qn.copy(e.boundingSphere).applyMatrix4(e.matrixWorld); + else { + const t = e.geometry; + t.boundingSphere === null && t.computeBoundingSphere(), Qn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld); + } + return this.intersectsSphere(Qn); + } + intersectsSprite(e) { + return Qn.center.set(0, 0, 0), Qn.radius = 0.7071067811865476, Qn.applyMatrix4(e.matrixWorld), this.intersectsSphere(Qn); + } + intersectsSphere(e) { + const t = this.planes, n = e.center, r = -e.radius; + for (let s = 0; s < 6; s++) + if (t[s].distanceToPoint(n) < r) + return !1; + return !0; + } + intersectsBox(e) { + const t = this.planes; + for (let n = 0; n < 6; n++) { + const r = t[n]; + if (Ur.x = r.normal.x > 0 ? e.max.x : e.min.x, Ur.y = r.normal.y > 0 ? e.max.y : e.min.y, Ur.z = r.normal.z > 0 ? e.max.z : e.min.z, r.distanceToPoint(Ur) < 0) + return !1; + } + return !0; + } + containsPoint(e) { + const t = this.planes; + for (let n = 0; n < 6; n++) + if (t[n].distanceToPoint(e) < 0) + return !1; + return !0; + } + clone() { + return new this.constructor().copy(this); + } +} +function ac() { + let i = null, e = !1, t = null, n = null; + function r(s, a) { + t(s, a), n = i.requestAnimationFrame(r); + } + return { + start: function() { + e !== !0 && t !== null && (n = i.requestAnimationFrame(r), e = !0); + }, + stop: function() { + i.cancelAnimationFrame(n), e = !1; + }, + setAnimationLoop: function(s) { + t = s; + }, + setContext: function(s) { + i = s; + } + }; +} +function Mh(i, e) { + const t = e.isWebGL2, n = /* @__PURE__ */ new WeakMap(); + function r(c, u) { + const f = c.array, h = c.usage, p = f.byteLength, g = i.createBuffer(); + i.bindBuffer(u, g), i.bufferData(u, f, h), c.onUploadCallback(); + let v; + if (f instanceof Float32Array) + v = i.FLOAT; + else if (f instanceof Uint16Array) + if (c.isFloat16BufferAttribute) + if (t) + v = i.HALF_FLOAT; + else + throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2."); + else + v = i.UNSIGNED_SHORT; + else if (f instanceof Int16Array) + v = i.SHORT; + else if (f instanceof Uint32Array) + v = i.UNSIGNED_INT; + else if (f instanceof Int32Array) + v = i.INT; + else if (f instanceof Int8Array) + v = i.BYTE; + else if (f instanceof Uint8Array) + v = i.UNSIGNED_BYTE; + else if (f instanceof Uint8ClampedArray) + v = i.UNSIGNED_BYTE; + else + throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: " + f); + return { + buffer: g, + type: v, + bytesPerElement: f.BYTES_PER_ELEMENT, + version: c.version, + size: p + }; + } + function s(c, u, f) { + const h = u.array, p = u._updateRange, g = u.updateRanges; + if (i.bindBuffer(f, c), p.count === -1 && g.length === 0 && i.bufferSubData(f, 0, h), g.length !== 0) { + for (let v = 0, m = g.length; v < m; v++) { + const d = g[v]; + t ? i.bufferSubData( + f, + d.start * h.BYTES_PER_ELEMENT, + h, + d.start, + d.count + ) : i.bufferSubData( + f, + d.start * h.BYTES_PER_ELEMENT, + h.subarray(d.start, d.start + d.count) + ); + } + u.clearUpdateRanges(); + } + p.count !== -1 && (t ? i.bufferSubData( + f, + p.offset * h.BYTES_PER_ELEMENT, + h, + p.offset, + p.count + ) : i.bufferSubData( + f, + p.offset * h.BYTES_PER_ELEMENT, + h.subarray(p.offset, p.offset + p.count) + ), p.count = -1), u.onUploadCallback(); + } + function a(c) { + return c.isInterleavedBufferAttribute && (c = c.data), n.get(c); + } + function o(c) { + c.isInterleavedBufferAttribute && (c = c.data); + const u = n.get(c); + u && (i.deleteBuffer(u.buffer), n.delete(c)); + } + function l(c, u) { + if (c.isGLBufferAttribute) { + const h = n.get(c); + (!h || h.version < c.version) && n.set(c, { + buffer: c.buffer, + type: c.type, + bytesPerElement: c.elementSize, + version: c.version + }); + return; + } + c.isInterleavedBufferAttribute && (c = c.data); + const f = n.get(c); + if (f === void 0) + n.set(c, r(c, u)); + else if (f.version < c.version) { + if (f.size !== c.array.byteLength) + throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported."); + s(f.buffer, c, u), f.version = c.version; + } + } + return { + get: a, + remove: o, + update: l + }; +} +class Wi extends Yt { + constructor(e = 1, t = 1, n = 1, r = 1) { + super(), this.type = "PlaneGeometry", this.parameters = { + width: e, + height: t, + widthSegments: n, + heightSegments: r + }; + const s = e / 2, a = t / 2, o = Math.floor(n), l = Math.floor(r), c = o + 1, u = l + 1, f = e / o, h = t / l, p = [], g = [], v = [], m = []; + for (let d = 0; d < u; d++) { + const M = d * h - a; + for (let _ = 0; _ < c; _++) { + const A = _ * f - s; + g.push(A, -M, 0), v.push(0, 0, 1), m.push(_ / o), m.push(1 - d / l); + } + } + for (let d = 0; d < l; d++) + for (let M = 0; M < o; M++) { + const _ = M + c * d, A = M + c * (d + 1), C = M + 1 + c * (d + 1), E = M + 1 + c * d; + p.push(_, A, E), p.push(A, C, E); + } + this.setIndex(p), this.setAttribute("position", new Ft(g, 3)), this.setAttribute("normal", new Ft(v, 3)), this.setAttribute("uv", new Ft(m, 2)); + } + copy(e) { + return super.copy(e), this.parameters = Object.assign({}, e.parameters), this; + } + static fromJSON(e) { + return new Wi(e.width, e.height, e.widthSegments, e.heightSegments); + } +} +var yh = `#ifdef USE_ALPHAHASH + if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard; +#endif`, Ah = `#ifdef USE_ALPHAHASH + const float ALPHA_HASH_SCALE = 0.05; + float hash2D( vec2 value ) { + return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) ); + } + float hash3D( vec3 value ) { + return hash2D( vec2( hash2D( value.xy ), value.z ) ); + } + float getAlphaHashThreshold( vec3 position ) { + float maxDeriv = max( + length( dFdx( position.xyz ) ), + length( dFdy( position.xyz ) ) + ); + float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv ); + vec2 pixScales = vec2( + exp2( floor( log2( pixScale ) ) ), + exp2( ceil( log2( pixScale ) ) ) + ); + vec2 alpha = vec2( + hash3D( floor( pixScales.x * position.xyz ) ), + hash3D( floor( pixScales.y * position.xyz ) ) + ); + float lerpFactor = fract( log2( pixScale ) ); + float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y; + float a = min( lerpFactor, 1.0 - lerpFactor ); + vec3 cases = vec3( + x * x / ( 2.0 * a * ( 1.0 - a ) ), + ( x - 0.5 * a ) / ( 1.0 - a ), + 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) ) + ); + float threshold = ( x < ( 1.0 - a ) ) + ? ( ( x < a ) ? cases.x : cases.y ) + : cases.z; + return clamp( threshold , 1.0e-6, 1.0 ); + } +#endif`, Eh = `#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g; +#endif`, bh = `#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`, Th = `#ifdef USE_ALPHATEST + #ifdef ALPHA_TO_COVERAGE + diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a ); + if ( diffuseColor.a == 0.0 ) discard; + #else + if ( diffuseColor.a < alphaTest ) discard; + #endif +#endif`, wh = `#ifdef USE_ALPHATEST + uniform float alphaTest; +#endif`, Ch = `#ifdef USE_AOMAP + float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0; + reflectedLight.indirectDiffuse *= ambientOcclusion; + #if defined( USE_CLEARCOAT ) + clearcoatSpecularIndirect *= ambientOcclusion; + #endif + #if defined( USE_SHEEN ) + sheenSpecularIndirect *= ambientOcclusion; + #endif + #if defined( USE_ENVMAP ) && defined( STANDARD ) + float dotNV = saturate( dot( geometryNormal, geometryViewDir ) ); + reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness ); + #endif +#endif`, Rh = `#ifdef USE_AOMAP + uniform sampler2D aoMap; + uniform float aoMapIntensity; +#endif`, Ph = `#ifdef USE_BATCHING + attribute float batchId; + uniform highp sampler2D batchingTexture; + mat4 getBatchingMatrix( const in float i ) { + int size = textureSize( batchingTexture, 0 ).x; + int j = int( i ) * 4; + int x = j % size; + int y = j / size; + vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 ); + vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 ); + vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 ); + vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 ); + return mat4( v1, v2, v3, v4 ); + } +#endif`, Lh = `#ifdef USE_BATCHING + mat4 batchingMatrix = getBatchingMatrix( batchId ); +#endif`, Dh = `vec3 transformed = vec3( position ); +#ifdef USE_ALPHAHASH + vPosition = vec3( position ); +#endif`, Ih = `vec3 objectNormal = vec3( normal ); +#ifdef USE_TANGENT + vec3 objectTangent = vec3( tangent.xyz ); +#endif`, Uh = `float G_BlinnPhong_Implicit( ) { + return 0.25; +} +float D_BlinnPhong( const in float shininess, const in float dotNH ) { + return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess ); +} +vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( specularColor, 1.0, dotVH ); + float G = G_BlinnPhong_Implicit( ); + float D = D_BlinnPhong( shininess, dotNH ); + return F * ( G * D ); +} // validated`, Fh = `#ifdef USE_IRIDESCENCE + const mat3 XYZ_TO_REC709 = mat3( + 3.2404542, -0.9692660, 0.0556434, + -1.5371385, 1.8760108, -0.2040259, + -0.4985314, 0.0415560, 1.0572252 + ); + vec3 Fresnel0ToIor( vec3 fresnel0 ) { + vec3 sqrtF0 = sqrt( fresnel0 ); + return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 ); + } + vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) { + return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) ); + } + float IorToFresnel0( float transmittedIor, float incidentIor ) { + return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor )); + } + vec3 evalSensitivity( float OPD, vec3 shift ) { + float phase = 2.0 * PI * OPD * 1.0e-9; + vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 ); + vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 ); + vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 ); + vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var ); + xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) ); + xyz /= 1.0685e-7; + vec3 rgb = XYZ_TO_REC709 * xyz; + return rgb; + } + vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) { + vec3 I; + float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) ); + float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) ); + float cosTheta2Sq = 1.0 - sinTheta2Sq; + if ( cosTheta2Sq < 0.0 ) { + return vec3( 1.0 ); + } + float cosTheta2 = sqrt( cosTheta2Sq ); + float R0 = IorToFresnel0( iridescenceIOR, outsideIOR ); + float R12 = F_Schlick( R0, 1.0, cosTheta1 ); + float T121 = 1.0 - R12; + float phi12 = 0.0; + if ( iridescenceIOR < outsideIOR ) phi12 = PI; + float phi21 = PI - phi12; + vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR ); + vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 ); + vec3 phi23 = vec3( 0.0 ); + if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI; + if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI; + if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI; + float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2; + vec3 phi = vec3( phi21 ) + phi23; + vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 ); + vec3 r123 = sqrt( R123 ); + vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 ); + vec3 C0 = R12 + Rs; + I = C0; + vec3 Cm = Rs - T121; + for ( int m = 1; m <= 2; ++ m ) { + Cm *= r123; + vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi ); + I += Cm * Sm; + } + return max( I, vec3( 0.0 ) ); + } +#endif`, Nh = `#ifdef USE_BUMPMAP + uniform sampler2D bumpMap; + uniform float bumpScale; + vec2 dHdxy_fwd() { + vec2 dSTdx = dFdx( vBumpMapUv ); + vec2 dSTdy = dFdy( vBumpMapUv ); + float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x; + float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll; + float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll; + return vec2( dBx, dBy ); + } + vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) { + vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) ); + vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) ); + vec3 vN = surf_norm; + vec3 R1 = cross( vSigmaY, vN ); + vec3 R2 = cross( vN, vSigmaX ); + float fDet = dot( vSigmaX, R1 ) * faceDirection; + vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); + return normalize( abs( fDet ) * surf_norm - vGrad ); + } +#endif`, Bh = `#if NUM_CLIPPING_PLANES > 0 + vec4 plane; + #ifdef ALPHA_TO_COVERAGE + float distanceToPlane, distanceGradient; + float clipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + if ( clipOpacity == 0.0 ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + float unionClipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + } + #pragma unroll_loop_end + clipOpacity *= 1.0 - unionClipOpacity; + #endif + diffuseColor.a *= clipOpacity; + if ( diffuseColor.a == 0.0 ) discard; + #else + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif + #endif +#endif`, Oh = `#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`, zh = `#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`, kh = `#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`, Gh = `#if defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#elif defined( USE_COLOR ) + diffuseColor.rgb *= vColor; +#endif`, Hh = `#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) + varying vec3 vColor; +#endif`, Vh = `#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) + varying vec3 vColor; +#endif`, Wh = `#if defined( USE_COLOR_ALPHA ) + vColor = vec4( 1.0 ); +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) + vColor = vec3( 1.0 ); +#endif +#ifdef USE_COLOR + vColor *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.xyz *= instanceColor.xyz; +#endif`, Xh = `#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); +} +mat3 transposeMat3( const in mat3 m ) { + mat3 tmp; + tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); + tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); + tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); + return tmp; +} +float luminance( const in vec3 rgb ) { + const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 ); + return dot( weights, rgb ); +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} +float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} // validated`, qh = `#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`, Yh = `vec3 transformedNormal = objectNormal; +#ifdef USE_TANGENT + vec3 transformedTangent = objectTangent; +#endif +#ifdef USE_BATCHING + mat3 bm = mat3( batchingMatrix ); + transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); + transformedNormal = bm * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = bm * transformedTangent; + #endif +#endif +#ifdef USE_INSTANCING + mat3 im = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); + transformedNormal = im * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = im * transformedTangent; + #endif +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; + #ifdef FLIP_SIDED + transformedTangent = - transformedTangent; + #endif +#endif`, jh = `#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`, Kh = `#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`, Qh = `#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`, Zh = `#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`, Jh = "gl_FragColor = linearToOutputTexel( gl_FragColor );", $h = ` +const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3( + vec3( 0.8224621, 0.177538, 0.0 ), + vec3( 0.0331941, 0.9668058, 0.0 ), + vec3( 0.0170827, 0.0723974, 0.9105199 ) +); +const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3( + vec3( 1.2249401, - 0.2249404, 0.0 ), + vec3( - 0.0420569, 1.0420571, 0.0 ), + vec3( - 0.0196376, - 0.0786361, 1.0982735 ) +); +vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) { + return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a ); +} +vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) { + return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a ); +} +vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +vec4 sRGBTransferOETF( in vec4 value ) { + return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); +} +vec4 LinearToLinear( in vec4 value ) { + return value; +} +vec4 LinearTosRGB( in vec4 value ) { + return sRGBTransferOETF( value ); +}`, ed = `#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); + #else + vec4 envColor = vec4( 0.0 ); + #endif + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif +#endif`, td = `#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform float flipEnvMap; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif + +#endif`, nd = `#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`, id = `#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`, rd = `#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`, sd = `#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`, od = `#ifdef USE_FOG + varying float vFogDepth; +#endif`, ad = `#ifdef USE_FOG + #ifdef FOG_EXP2 + float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); + #else + float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); + #endif + gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); +#endif`, ld = `#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`, cd = `#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + vec2 fw = fwidth( coord ) * 0.5; + return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); + #endif +}`, ud = `#ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + reflectedLight.indirectDiffuse += lightMapIrradiance; +#endif`, fd = `#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`, hd = `LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`, dd = `varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`, pd = `uniform bool receiveShadow; +uniform vec3 ambientLightColor; +#if defined( USE_LIGHT_PROBES ) + uniform vec3 lightProbe[ 9 ]; +#endif +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + #if defined ( LEGACY_LIGHTS ) + if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) { + return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent ); + } + return 1.0; + #else + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; + #endif +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif`, md = `#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); + reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`, gd = `ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`, _d = `varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`, vd = `BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`, xd = `varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`, Sd = `PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + if( material.anisotropy == 0.0 ) { + anisotropyV = vec2( 1.0, 0.0 ); + } else { + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + } + material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); + material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; + material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; +#endif`, Md = `struct PhysicalMaterial { + vec3 diffuseColor; + float roughness; + vec3 specularColor; + float specularF90; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + float v = 0.5 / ( gv + gl ); + return saturate(v); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColor; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; + float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; + float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); + return saturate( DG * RECIPROCAL_PI ); +} +vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); + const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); + vec4 r = roughness * c0 + c1; + float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; + vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; + return fab; +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + vec2 fab = DFGApprox( normal, viewDir, roughness ); + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + vec2 fab = DFGApprox( normal, viewDir, roughness ); + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + #endif + vec3 singleScattering = vec3( 0.0 ); + vec3 multiScattering = vec3( 0.0 ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); + #endif + vec3 totalScattering = singleScattering + multiScattering; + vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); + reflectedLight.indirectSpecular += radiance * singleScattering; + reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; + reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`, yd = ` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`, Ad = `#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`, Ed = `#if defined( RE_IndirectDiffuse ) + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`, bd = `#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) + gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`, Td = `#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`, wd = `#ifdef USE_LOGDEPTHBUF + #ifdef USE_LOGDEPTHBUF_EXT + varying float vFragDepth; + varying float vIsPerspective; + #else + uniform float logDepthBufFC; + #endif +#endif`, Cd = `#ifdef USE_LOGDEPTHBUF + #ifdef USE_LOGDEPTHBUF_EXT + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); + #else + if ( isPerspectiveMatrix( projectionMatrix ) ) { + gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0; + gl_Position.z *= gl_Position.w; + } + #endif +#endif`, Rd = `#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w ); + + #endif + diffuseColor *= sampledDiffuseColor; +#endif`, Pd = `#ifdef USE_MAP + uniform sampler2D map; +#endif`, Ld = `#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`, Dd = `#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`, Id = `float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`, Ud = `#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`, Fd = `#ifdef USE_INSTANCING_MORPH + float morphTargetInfluences[MORPHTARGETS_COUNT]; + float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; + } +#endif`, Nd = `#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`, Bd = `#ifdef USE_MORPHNORMALS + objectNormal *= morphTargetBaseInfluence; + #ifdef MORPHTARGETS_TEXTURE + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; + } + #else + objectNormal += morphNormal0 * morphTargetInfluences[ 0 ]; + objectNormal += morphNormal1 * morphTargetInfluences[ 1 ]; + objectNormal += morphNormal2 * morphTargetInfluences[ 2 ]; + objectNormal += morphNormal3 * morphTargetInfluences[ 3 ]; + #endif +#endif`, Od = `#ifdef USE_MORPHTARGETS + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetBaseInfluence; + #endif + #ifdef MORPHTARGETS_TEXTURE + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + #endif + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } + #else + #ifndef USE_MORPHNORMALS + uniform float morphTargetInfluences[ 8 ]; + #else + uniform float morphTargetInfluences[ 4 ]; + #endif + #endif +#endif`, zd = `#ifdef USE_MORPHTARGETS + transformed *= morphTargetBaseInfluence; + #ifdef MORPHTARGETS_TEXTURE + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; + } + #else + transformed += morphTarget0 * morphTargetInfluences[ 0 ]; + transformed += morphTarget1 * morphTargetInfluences[ 1 ]; + transformed += morphTarget2 * morphTargetInfluences[ 2 ]; + transformed += morphTarget3 * morphTargetInfluences[ 3 ]; + #ifndef USE_MORPHNORMALS + transformed += morphTarget4 * morphTargetInfluences[ 4 ]; + transformed += morphTarget5 * morphTargetInfluences[ 5 ]; + transformed += morphTarget6 * morphTargetInfluences[ 6 ]; + transformed += morphTarget7 * morphTargetInfluences[ 7 ]; + #endif + #endif +#endif`, kd = `float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`, Gd = `#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`, Hd = `#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`, Vd = `#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`, Wd = `#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #endif +#endif`, Xd = `#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`, qd = `#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`, Yd = `#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`, jd = `#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`, Kd = `#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`, Qd = `#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`, Zd = `vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.; +const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. ); +const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. ); +const float ShiftRight8 = 1. / 256.; +vec4 packDepthToRGBA( const in float v ) { + vec4 r = vec4( fract( v * PackFactors ), v ); + r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale; +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors ); +} +vec2 packDepthToRG( in highp float v ) { + return packDepthToRGBA( v ).yx; +} +float unpackRGToDepth( const in highp vec2 v ) { + return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) ); +} +vec4 pack2HalfToRGBA( vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + return depth * ( near - far ) - near; +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + return ( near * far ) / ( ( far - near ) * depth - far ); +}`, Jd = `#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`, $d = `vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_BATCHING + mvPosition = batchingMatrix * mvPosition; +#endif +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`, ep = `#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`, tp = `#ifdef DITHERING + vec3 dithering( vec3 color ) { + float grid_position = rand( gl_FragCoord.xy ); + vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); + dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); + return color + dither_shift_RGB; + } +#endif`, np = `float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`, ip = `#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`, rp = `#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + struct SpotLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { + return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); + } + vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { + return unpackRGBATo2Half( texture2D( shadow, uv ) ); + } + float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ + float occlusion = 1.0; + vec2 distribution = texture2DDistribution( shadow, uv ); + float hard_shadow = step( compare , distribution.x ); + if (hard_shadow != 1.0 ) { + float distance = compare - distribution.x ; + float variance = max( 0.00000, distribution.y * distribution.y ); + float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); + } + return occlusion; + } + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + #if defined( SHADOWMAP_TYPE_PCF ) + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float dx0 = - texelSize.x * shadowRadius; + float dy0 = - texelSize.y * shadowRadius; + float dx1 = + texelSize.x * shadowRadius; + float dy1 = + texelSize.y * shadowRadius; + float dx2 = dx0 / 2.0; + float dy2 = dy0 / 2.0; + float dx3 = dx1 / 2.0; + float dy3 = dy1 / 2.0; + shadow = ( + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) + ) * ( 1.0 / 17.0 ); + #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float dx = texelSize.x; + float dy = texelSize.y; + vec2 uv = shadowCoord.xy; + vec2 f = fract( uv * shadowMapSize + 0.5 ); + uv -= f * texelSize; + shadow = ( + texture2DCompare( shadowMap, uv, shadowCoord.z ) + + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), + f.x ) + + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), + f.x ) + + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), + f.y ) + + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), + f.y ) + + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), + f.x ), + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), + f.x ), + f.y ) + ) * ( 1.0 / 9.0 ); + #elif defined( SHADOWMAP_TYPE_VSM ) + shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); + #else + shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); + #endif + } + return shadow; + } + vec2 cubeToUV( vec3 v, float texelSizeY ) { + vec3 absV = abs( v ); + float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); + absV *= scaleToCube; + v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); + vec2 planar = v.xy; + float almostATexel = 1.5 * texelSizeY; + float almostOne = 1.0 - almostATexel; + if ( absV.z >= almostOne ) { + if ( v.z > 0.0 ) + planar.x = 4.0 - v.x; + } else if ( absV.x >= almostOne ) { + float signX = sign( v.x ); + planar.x = v.z * signX + 2.0 * signX; + } else if ( absV.y >= almostOne ) { + float signY = sign( v.y ); + planar.x = v.x + 2.0 * signY + 2.0; + planar.y = v.z * signY - 2.0; + } + return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); + } + float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); + vec3 lightToPosition = shadowCoord.xyz; + float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) + vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; + return ( + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) + ) * ( 1.0 / 9.0 ); + #else + return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); + #endif + } +#endif`, sp = `#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`, op = `#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`, ap = `float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`, lp = `#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`, cp = `#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + mat4 getBoneMatrix( const in float i ) { + int size = textureSize( boneTexture, 0 ).x; + int j = int( i ) * 4; + int x = j % size; + int y = j / size; + vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); + vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); + vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); + vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); + return mat4( v1, v2, v3, v4 ); + } +#endif`, up = `#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`, fp = `#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`, hp = `float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`, dp = `#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`, pp = `#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`, mp = `#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 OptimizedCineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( + vec3( 1.6605, - 0.1246, - 0.0182 ), + vec3( - 0.5876, 1.1329, - 0.1006 ), + vec3( - 0.0728, - 0.0083, 1.1187 ) +); +const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( + vec3( 0.6274, 0.0691, 0.0164 ), + vec3( 0.3293, 0.9195, 0.0880 ), + vec3( 0.0433, 0.0113, 0.8956 ) +); +vec3 agxDefaultContrastApprox( vec3 x ) { + vec3 x2 = x * x; + vec3 x4 = x2 * x2; + return + 15.5 * x4 * x2 + - 40.14 * x4 * x + + 31.96 * x4 + - 6.868 * x2 * x + + 0.4298 * x2 + + 0.1191 * x + - 0.00232; +} +vec3 AgXToneMapping( vec3 color ) { + const mat3 AgXInsetMatrix = mat3( + vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), + vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), + vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) + ); + const mat3 AgXOutsetMatrix = mat3( + vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), + vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), + vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) + ); + const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; + color *= toneMappingExposure; + color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; + color = AgXInsetMatrix * color; + color = max( color, 1e-10 ); color = log2( color ); + color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); + color = clamp( color, 0.0, 1.0 ); + color = agxDefaultContrastApprox( color ); + color = AgXOutsetMatrix * color; + color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); + color = LINEAR_REC2020_TO_LINEAR_SRGB * color; + color = clamp( color, 0.0, 1.0 ); + return color; +} +vec3 NeutralToneMapping( vec3 color ) { + float startCompression = 0.8 - 0.04; + float desaturation = 0.15; + color *= toneMappingExposure; + float x = min(color.r, min(color.g, color.b)); + float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; + color -= offset; + float peak = max(color.r, max(color.g, color.b)); + if (peak < startCompression) return color; + float d = 1. - startCompression; + float newPeak = 1. - d * d / (peak + d - startCompression); + color *= newPeak / peak; + float g = 1. - 1. / (desaturation * (peak - newPeak) + 1.); + return mix(color, vec3(1, 1, 1), g); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`, gp = `#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = inverseTransformDirection( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`, _p = `#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`, vp = `#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`, xp = `#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`, Sp = `#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`, Mp = `#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 + vec4 worldPosition = vec4( transformed, 1.0 ); + #ifdef USE_BATCHING + worldPosition = batchingMatrix * worldPosition; + #endif + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`; +const yp = `varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`, Ap = `uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`, Ep = `varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`, bp = `#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float flipEnvMap; +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`, Tp = `varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`, wp = `uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`, Cp = `#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`, Rp = `#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #endif +}`, Pp = `#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`, Lp = `#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +#include +void main () { + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = packDepthToRGBA( dist ); +}`, Dp = `varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`, Ip = `uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`, Up = `uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`, Fp = `uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`, Np = `#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`, Bp = `uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`, Op = `#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`, zp = `#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`, kp = `#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`, Gp = `#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`, Hp = `#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`, Vp = `#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`, Wp = `#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`, Xp = `#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`, qp = `#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`, Yp = `#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); + outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect; + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`, jp = `#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`, Kp = `#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`, Qp = `uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif +void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #include + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`, Zp = `uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`, Jp = `#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`, $p = `uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include +}`, em = `uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 ); + vec2 scale; + scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) ); + scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`, tm = `uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`, We = { + alphahash_fragment: yh, + alphahash_pars_fragment: Ah, + alphamap_fragment: Eh, + alphamap_pars_fragment: bh, + alphatest_fragment: Th, + alphatest_pars_fragment: wh, + aomap_fragment: Ch, + aomap_pars_fragment: Rh, + batching_pars_vertex: Ph, + batching_vertex: Lh, + begin_vertex: Dh, + beginnormal_vertex: Ih, + bsdfs: Uh, + iridescence_fragment: Fh, + bumpmap_pars_fragment: Nh, + clipping_planes_fragment: Bh, + clipping_planes_pars_fragment: Oh, + clipping_planes_pars_vertex: zh, + clipping_planes_vertex: kh, + color_fragment: Gh, + color_pars_fragment: Hh, + color_pars_vertex: Vh, + color_vertex: Wh, + common: Xh, + cube_uv_reflection_fragment: qh, + defaultnormal_vertex: Yh, + displacementmap_pars_vertex: jh, + displacementmap_vertex: Kh, + emissivemap_fragment: Qh, + emissivemap_pars_fragment: Zh, + colorspace_fragment: Jh, + colorspace_pars_fragment: $h, + envmap_fragment: ed, + envmap_common_pars_fragment: td, + envmap_pars_fragment: nd, + envmap_pars_vertex: id, + envmap_physical_pars_fragment: md, + envmap_vertex: rd, + fog_vertex: sd, + fog_pars_vertex: od, + fog_fragment: ad, + fog_pars_fragment: ld, + gradientmap_pars_fragment: cd, + lightmap_fragment: ud, + lightmap_pars_fragment: fd, + lights_lambert_fragment: hd, + lights_lambert_pars_fragment: dd, + lights_pars_begin: pd, + lights_toon_fragment: gd, + lights_toon_pars_fragment: _d, + lights_phong_fragment: vd, + lights_phong_pars_fragment: xd, + lights_physical_fragment: Sd, + lights_physical_pars_fragment: Md, + lights_fragment_begin: yd, + lights_fragment_maps: Ad, + lights_fragment_end: Ed, + logdepthbuf_fragment: bd, + logdepthbuf_pars_fragment: Td, + logdepthbuf_pars_vertex: wd, + logdepthbuf_vertex: Cd, + map_fragment: Rd, + map_pars_fragment: Pd, + map_particle_fragment: Ld, + map_particle_pars_fragment: Dd, + metalnessmap_fragment: Id, + metalnessmap_pars_fragment: Ud, + morphinstance_vertex: Fd, + morphcolor_vertex: Nd, + morphnormal_vertex: Bd, + morphtarget_pars_vertex: Od, + morphtarget_vertex: zd, + normal_fragment_begin: kd, + normal_fragment_maps: Gd, + normal_pars_fragment: Hd, + normal_pars_vertex: Vd, + normal_vertex: Wd, + normalmap_pars_fragment: Xd, + clearcoat_normal_fragment_begin: qd, + clearcoat_normal_fragment_maps: Yd, + clearcoat_pars_fragment: jd, + iridescence_pars_fragment: Kd, + opaque_fragment: Qd, + packing: Zd, + premultiplied_alpha_fragment: Jd, + project_vertex: $d, + dithering_fragment: ep, + dithering_pars_fragment: tp, + roughnessmap_fragment: np, + roughnessmap_pars_fragment: ip, + shadowmap_pars_fragment: rp, + shadowmap_pars_vertex: sp, + shadowmap_vertex: op, + shadowmask_pars_fragment: ap, + skinbase_vertex: lp, + skinning_pars_vertex: cp, + skinning_vertex: up, + skinnormal_vertex: fp, + specularmap_fragment: hp, + specularmap_pars_fragment: dp, + tonemapping_fragment: pp, + tonemapping_pars_fragment: mp, + transmission_fragment: gp, + transmission_pars_fragment: _p, + uv_pars_fragment: vp, + uv_pars_vertex: xp, + uv_vertex: Sp, + worldpos_vertex: Mp, + background_vert: yp, + background_frag: Ap, + backgroundCube_vert: Ep, + backgroundCube_frag: bp, + cube_vert: Tp, + cube_frag: wp, + depth_vert: Cp, + depth_frag: Rp, + distanceRGBA_vert: Pp, + distanceRGBA_frag: Lp, + equirect_vert: Dp, + equirect_frag: Ip, + linedashed_vert: Up, + linedashed_frag: Fp, + meshbasic_vert: Np, + meshbasic_frag: Bp, + meshlambert_vert: Op, + meshlambert_frag: zp, + meshmatcap_vert: kp, + meshmatcap_frag: Gp, + meshnormal_vert: Hp, + meshnormal_frag: Vp, + meshphong_vert: Wp, + meshphong_frag: Xp, + meshphysical_vert: qp, + meshphysical_frag: Yp, + meshtoon_vert: jp, + meshtoon_frag: Kp, + points_vert: Qp, + points_frag: Zp, + shadow_vert: Jp, + shadow_frag: $p, + sprite_vert: em, + sprite_frag: tm +}, oe = { + common: { + diffuse: { value: /* @__PURE__ */ new Qe(16777215) }, + opacity: { value: 1 }, + map: { value: null }, + mapTransform: { value: /* @__PURE__ */ new be() }, + alphaMap: { value: null }, + alphaMapTransform: { value: /* @__PURE__ */ new be() }, + alphaTest: { value: 0 } + }, + specularmap: { + specularMap: { value: null }, + specularMapTransform: { value: /* @__PURE__ */ new be() } + }, + envmap: { + envMap: { value: null }, + envMapRotation: { value: /* @__PURE__ */ new be() }, + flipEnvMap: { value: -1 }, + reflectivity: { value: 1 }, + // basic, lambert, phong + ior: { value: 1.5 }, + // physical + refractionRatio: { value: 0.98 } + // basic, lambert, phong + }, + aomap: { + aoMap: { value: null }, + aoMapIntensity: { value: 1 }, + aoMapTransform: { value: /* @__PURE__ */ new be() } + }, + lightmap: { + lightMap: { value: null }, + lightMapIntensity: { value: 1 }, + lightMapTransform: { value: /* @__PURE__ */ new be() } + }, + bumpmap: { + bumpMap: { value: null }, + bumpMapTransform: { value: /* @__PURE__ */ new be() }, + bumpScale: { value: 1 } + }, + normalmap: { + normalMap: { value: null }, + normalMapTransform: { value: /* @__PURE__ */ new be() }, + normalScale: { value: /* @__PURE__ */ new me(1, 1) } + }, + displacementmap: { + displacementMap: { value: null }, + displacementMapTransform: { value: /* @__PURE__ */ new be() }, + displacementScale: { value: 1 }, + displacementBias: { value: 0 } + }, + emissivemap: { + emissiveMap: { value: null }, + emissiveMapTransform: { value: /* @__PURE__ */ new be() } + }, + metalnessmap: { + metalnessMap: { value: null }, + metalnessMapTransform: { value: /* @__PURE__ */ new be() } + }, + roughnessmap: { + roughnessMap: { value: null }, + roughnessMapTransform: { value: /* @__PURE__ */ new be() } + }, + gradientmap: { + gradientMap: { value: null } + }, + fog: { + fogDensity: { value: 25e-5 }, + fogNear: { value: 1 }, + fogFar: { value: 2e3 }, + fogColor: { value: /* @__PURE__ */ new Qe(16777215) } + }, + lights: { + ambientLightColor: { value: [] }, + lightProbe: { value: [] }, + directionalLights: { value: [], properties: { + direction: {}, + color: {} + } }, + directionalLightShadows: { value: [], properties: { + shadowBias: {}, + shadowNormalBias: {}, + shadowRadius: {}, + shadowMapSize: {} + } }, + directionalShadowMap: { value: [] }, + directionalShadowMatrix: { value: [] }, + spotLights: { value: [], properties: { + color: {}, + position: {}, + direction: {}, + distance: {}, + coneCos: {}, + penumbraCos: {}, + decay: {} + } }, + spotLightShadows: { value: [], properties: { + shadowBias: {}, + shadowNormalBias: {}, + shadowRadius: {}, + shadowMapSize: {} + } }, + spotLightMap: { value: [] }, + spotShadowMap: { value: [] }, + spotLightMatrix: { value: [] }, + pointLights: { value: [], properties: { + color: {}, + position: {}, + decay: {}, + distance: {} + } }, + pointLightShadows: { value: [], properties: { + shadowBias: {}, + shadowNormalBias: {}, + shadowRadius: {}, + shadowMapSize: {}, + shadowCameraNear: {}, + shadowCameraFar: {} + } }, + pointShadowMap: { value: [] }, + pointShadowMatrix: { value: [] }, + hemisphereLights: { value: [], properties: { + direction: {}, + skyColor: {}, + groundColor: {} + } }, + // TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src + rectAreaLights: { value: [], properties: { + color: {}, + position: {}, + width: {}, + height: {} + } }, + ltc_1: { value: null }, + ltc_2: { value: null } + }, + points: { + diffuse: { value: /* @__PURE__ */ new Qe(16777215) }, + opacity: { value: 1 }, + size: { value: 1 }, + scale: { value: 1 }, + map: { value: null }, + alphaMap: { value: null }, + alphaMapTransform: { value: /* @__PURE__ */ new be() }, + alphaTest: { value: 0 }, + uvTransform: { value: /* @__PURE__ */ new be() } + }, + sprite: { + diffuse: { value: /* @__PURE__ */ new Qe(16777215) }, + opacity: { value: 1 }, + center: { value: /* @__PURE__ */ new me(0.5, 0.5) }, + rotation: { value: 0 }, + map: { value: null }, + mapTransform: { value: /* @__PURE__ */ new be() }, + alphaMap: { value: null }, + alphaMapTransform: { value: /* @__PURE__ */ new be() }, + alphaTest: { value: 0 } + } +}, on = { + basic: { + uniforms: /* @__PURE__ */ bt([ + oe.common, + oe.specularmap, + oe.envmap, + oe.aomap, + oe.lightmap, + oe.fog + ]), + vertexShader: We.meshbasic_vert, + fragmentShader: We.meshbasic_frag + }, + lambert: { + uniforms: /* @__PURE__ */ bt([ + oe.common, + oe.specularmap, + oe.envmap, + oe.aomap, + oe.lightmap, + oe.emissivemap, + oe.bumpmap, + oe.normalmap, + oe.displacementmap, + oe.fog, + oe.lights, + { + emissive: { value: /* @__PURE__ */ new Qe(0) } + } + ]), + vertexShader: We.meshlambert_vert, + fragmentShader: We.meshlambert_frag + }, + phong: { + uniforms: /* @__PURE__ */ bt([ + oe.common, + oe.specularmap, + oe.envmap, + oe.aomap, + oe.lightmap, + oe.emissivemap, + oe.bumpmap, + oe.normalmap, + oe.displacementmap, + oe.fog, + oe.lights, + { + emissive: { value: /* @__PURE__ */ new Qe(0) }, + specular: { value: /* @__PURE__ */ new Qe(1118481) }, + shininess: { value: 30 } + } + ]), + vertexShader: We.meshphong_vert, + fragmentShader: We.meshphong_frag + }, + standard: { + uniforms: /* @__PURE__ */ bt([ + oe.common, + oe.envmap, + oe.aomap, + oe.lightmap, + oe.emissivemap, + oe.bumpmap, + oe.normalmap, + oe.displacementmap, + oe.roughnessmap, + oe.metalnessmap, + oe.fog, + oe.lights, + { + emissive: { value: /* @__PURE__ */ new Qe(0) }, + roughness: { value: 1 }, + metalness: { value: 0 }, + envMapIntensity: { value: 1 } + // temporary + } + ]), + vertexShader: We.meshphysical_vert, + fragmentShader: We.meshphysical_frag + }, + toon: { + uniforms: /* @__PURE__ */ bt([ + oe.common, + oe.aomap, + oe.lightmap, + oe.emissivemap, + oe.bumpmap, + oe.normalmap, + oe.displacementmap, + oe.gradientmap, + oe.fog, + oe.lights, + { + emissive: { value: /* @__PURE__ */ new Qe(0) } + } + ]), + vertexShader: We.meshtoon_vert, + fragmentShader: We.meshtoon_frag + }, + matcap: { + uniforms: /* @__PURE__ */ bt([ + oe.common, + oe.bumpmap, + oe.normalmap, + oe.displacementmap, + oe.fog, + { + matcap: { value: null } + } + ]), + vertexShader: We.meshmatcap_vert, + fragmentShader: We.meshmatcap_frag + }, + points: { + uniforms: /* @__PURE__ */ bt([ + oe.points, + oe.fog + ]), + vertexShader: We.points_vert, + fragmentShader: We.points_frag + }, + dashed: { + uniforms: /* @__PURE__ */ bt([ + oe.common, + oe.fog, + { + scale: { value: 1 }, + dashSize: { value: 1 }, + totalSize: { value: 2 } + } + ]), + vertexShader: We.linedashed_vert, + fragmentShader: We.linedashed_frag + }, + depth: { + uniforms: /* @__PURE__ */ bt([ + oe.common, + oe.displacementmap + ]), + vertexShader: We.depth_vert, + fragmentShader: We.depth_frag + }, + normal: { + uniforms: /* @__PURE__ */ bt([ + oe.common, + oe.bumpmap, + oe.normalmap, + oe.displacementmap, + { + opacity: { value: 1 } + } + ]), + vertexShader: We.meshnormal_vert, + fragmentShader: We.meshnormal_frag + }, + sprite: { + uniforms: /* @__PURE__ */ bt([ + oe.sprite, + oe.fog + ]), + vertexShader: We.sprite_vert, + fragmentShader: We.sprite_frag + }, + background: { + uniforms: { + uvTransform: { value: /* @__PURE__ */ new be() }, + t2D: { value: null }, + backgroundIntensity: { value: 1 } + }, + vertexShader: We.background_vert, + fragmentShader: We.background_frag + }, + backgroundCube: { + uniforms: { + envMap: { value: null }, + flipEnvMap: { value: -1 }, + backgroundBlurriness: { value: 0 }, + backgroundIntensity: { value: 1 }, + backgroundRotation: { value: /* @__PURE__ */ new be() } + }, + vertexShader: We.backgroundCube_vert, + fragmentShader: We.backgroundCube_frag + }, + cube: { + uniforms: { + tCube: { value: null }, + tFlip: { value: -1 }, + opacity: { value: 1 } + }, + vertexShader: We.cube_vert, + fragmentShader: We.cube_frag + }, + equirect: { + uniforms: { + tEquirect: { value: null } + }, + vertexShader: We.equirect_vert, + fragmentShader: We.equirect_frag + }, + distanceRGBA: { + uniforms: /* @__PURE__ */ bt([ + oe.common, + oe.displacementmap, + { + referencePosition: { value: /* @__PURE__ */ new P() }, + nearDistance: { value: 1 }, + farDistance: { value: 1e3 } + } + ]), + vertexShader: We.distanceRGBA_vert, + fragmentShader: We.distanceRGBA_frag + }, + shadow: { + uniforms: /* @__PURE__ */ bt([ + oe.lights, + oe.fog, + { + color: { value: /* @__PURE__ */ new Qe(0) }, + opacity: { value: 1 } + } + ]), + vertexShader: We.shadow_vert, + fragmentShader: We.shadow_frag + } +}; +on.physical = { + uniforms: /* @__PURE__ */ bt([ + on.standard.uniforms, + { + clearcoat: { value: 0 }, + clearcoatMap: { value: null }, + clearcoatMapTransform: { value: /* @__PURE__ */ new be() }, + clearcoatNormalMap: { value: null }, + clearcoatNormalMapTransform: { value: /* @__PURE__ */ new be() }, + clearcoatNormalScale: { value: /* @__PURE__ */ new me(1, 1) }, + clearcoatRoughness: { value: 0 }, + clearcoatRoughnessMap: { value: null }, + clearcoatRoughnessMapTransform: { value: /* @__PURE__ */ new be() }, + iridescence: { value: 0 }, + iridescenceMap: { value: null }, + iridescenceMapTransform: { value: /* @__PURE__ */ new be() }, + iridescenceIOR: { value: 1.3 }, + iridescenceThicknessMinimum: { value: 100 }, + iridescenceThicknessMaximum: { value: 400 }, + iridescenceThicknessMap: { value: null }, + iridescenceThicknessMapTransform: { value: /* @__PURE__ */ new be() }, + sheen: { value: 0 }, + sheenColor: { value: /* @__PURE__ */ new Qe(0) }, + sheenColorMap: { value: null }, + sheenColorMapTransform: { value: /* @__PURE__ */ new be() }, + sheenRoughness: { value: 1 }, + sheenRoughnessMap: { value: null }, + sheenRoughnessMapTransform: { value: /* @__PURE__ */ new be() }, + transmission: { value: 0 }, + transmissionMap: { value: null }, + transmissionMapTransform: { value: /* @__PURE__ */ new be() }, + transmissionSamplerSize: { value: /* @__PURE__ */ new me() }, + transmissionSamplerMap: { value: null }, + thickness: { value: 0 }, + thicknessMap: { value: null }, + thicknessMapTransform: { value: /* @__PURE__ */ new be() }, + attenuationDistance: { value: 0 }, + attenuationColor: { value: /* @__PURE__ */ new Qe(0) }, + specularColor: { value: /* @__PURE__ */ new Qe(1, 1, 1) }, + specularColorMap: { value: null }, + specularColorMapTransform: { value: /* @__PURE__ */ new be() }, + specularIntensity: { value: 1 }, + specularIntensityMap: { value: null }, + specularIntensityMapTransform: { value: /* @__PURE__ */ new be() }, + anisotropyVector: { value: /* @__PURE__ */ new me() }, + anisotropyMap: { value: null }, + anisotropyMapTransform: { value: /* @__PURE__ */ new be() } + } + ]), + vertexShader: We.meshphysical_vert, + fragmentShader: We.meshphysical_frag +}; +const Fr = { r: 0, b: 0, g: 0 }, Zn = /* @__PURE__ */ new bn(), nm = /* @__PURE__ */ new ke(); +function im(i, e, t, n, r, s, a) { + const o = new Qe(0); + let l = s === !0 ? 0 : 1, c, u, f = null, h = 0, p = null; + function g(m, d) { + let M = !1, _ = d.isScene === !0 ? d.background : null; + _ && _.isTexture && (_ = (d.backgroundBlurriness > 0 ? t : e).get(_)), _ === null ? v(o, l) : _ && _.isColor && (v(_, 1), M = !0); + const A = i.xr.getEnvironmentBlendMode(); + A === "additive" ? n.buffers.color.setClear(0, 0, 0, 1, a) : A === "alpha-blend" && n.buffers.color.setClear(0, 0, 0, 0, a), (i.autoClear || M) && i.clear(i.autoClearColor, i.autoClearDepth, i.autoClearStencil), _ && (_.isCubeTexture || _.mapping === ss) ? (u === void 0 && (u = new at( + new Qi(1, 1, 1), + new Xt({ + name: "BackgroundCubeMaterial", + uniforms: Vi(on.backgroundCube.uniforms), + vertexShader: on.backgroundCube.vertexShader, + fragmentShader: on.backgroundCube.fragmentShader, + side: Pt, + depthTest: !1, + depthWrite: !1, + fog: !1 + }) + ), u.geometry.deleteAttribute("normal"), u.geometry.deleteAttribute("uv"), u.onBeforeRender = function(C, E, b) { + this.matrixWorld.copyPosition(b.matrixWorld); + }, Object.defineProperty(u.material, "envMap", { + get: function() { + return this.uniforms.envMap.value; + } + }), r.update(u)), Zn.copy(d.backgroundRotation), Zn.x *= -1, Zn.y *= -1, Zn.z *= -1, _.isCubeTexture && _.isRenderTargetTexture === !1 && (Zn.y *= -1, Zn.z *= -1), u.material.uniforms.envMap.value = _, u.material.uniforms.flipEnvMap.value = _.isCubeTexture && _.isRenderTargetTexture === !1 ? -1 : 1, u.material.uniforms.backgroundBlurriness.value = d.backgroundBlurriness, u.material.uniforms.backgroundIntensity.value = d.backgroundIntensity, u.material.uniforms.backgroundRotation.value.setFromMatrix4(nm.makeRotationFromEuler(Zn)), u.material.toneMapped = Ze.getTransfer(_.colorSpace) !== nt, (f !== _ || h !== _.version || p !== i.toneMapping) && (u.material.needsUpdate = !0, f = _, h = _.version, p = i.toneMapping), u.layers.enableAll(), m.unshift(u, u.geometry, u.material, 0, 0, null)) : _ && _.isTexture && (c === void 0 && (c = new at( + new Wi(2, 2), + new Xt({ + name: "BackgroundMaterial", + uniforms: Vi(on.background.uniforms), + vertexShader: on.background.vertexShader, + fragmentShader: on.background.fragmentShader, + side: hn, + depthTest: !1, + depthWrite: !1, + fog: !1 + }) + ), c.geometry.deleteAttribute("normal"), Object.defineProperty(c.material, "map", { + get: function() { + return this.uniforms.t2D.value; + } + }), r.update(c)), c.material.uniforms.t2D.value = _, c.material.uniforms.backgroundIntensity.value = d.backgroundIntensity, c.material.toneMapped = Ze.getTransfer(_.colorSpace) !== nt, _.matrixAutoUpdate === !0 && _.updateMatrix(), c.material.uniforms.uvTransform.value.copy(_.matrix), (f !== _ || h !== _.version || p !== i.toneMapping) && (c.material.needsUpdate = !0, f = _, h = _.version, p = i.toneMapping), c.layers.enableAll(), m.unshift(c, c.geometry, c.material, 0, 0, null)); + } + function v(m, d) { + m.getRGB(Fr, ic(i)), n.buffers.color.setClear(Fr.r, Fr.g, Fr.b, d, a); + } + return { + getClearColor: function() { + return o; + }, + setClearColor: function(m, d = 1) { + o.set(m), l = d, v(o, l); + }, + getClearAlpha: function() { + return l; + }, + setClearAlpha: function(m) { + l = m, v(o, l); + }, + render: g + }; +} +function rm(i, e, t, n) { + const r = i.getParameter(i.MAX_VERTEX_ATTRIBS), s = n.isWebGL2 ? null : e.get("OES_vertex_array_object"), a = n.isWebGL2 || s !== null, o = {}, l = m(null); + let c = l, u = !1; + function f(L, N, O, B, j) { + let q = !1; + if (a) { + const J = v(B, O, N); + c !== J && (c = J, p(c.object)), q = d(L, B, O, j), q && M(L, B, O, j); + } else { + const J = N.wireframe === !0; + (c.geometry !== B.id || c.program !== O.id || c.wireframe !== J) && (c.geometry = B.id, c.program = O.id, c.wireframe = J, q = !0); + } + j !== null && t.update(j, i.ELEMENT_ARRAY_BUFFER), (q || u) && (u = !1, I(L, N, O, B), j !== null && i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, t.get(j).buffer)); + } + function h() { + return n.isWebGL2 ? i.createVertexArray() : s.createVertexArrayOES(); + } + function p(L) { + return n.isWebGL2 ? i.bindVertexArray(L) : s.bindVertexArrayOES(L); + } + function g(L) { + return n.isWebGL2 ? i.deleteVertexArray(L) : s.deleteVertexArrayOES(L); + } + function v(L, N, O) { + const B = O.wireframe === !0; + let j = o[L.id]; + j === void 0 && (j = {}, o[L.id] = j); + let q = j[N.id]; + q === void 0 && (q = {}, j[N.id] = q); + let J = q[B]; + return J === void 0 && (J = m(h()), q[B] = J), J; + } + function m(L) { + const N = [], O = [], B = []; + for (let j = 0; j < r; j++) + N[j] = 0, O[j] = 0, B[j] = 0; + return { + // for backward compatibility on non-VAO support browser + geometry: null, + program: null, + wireframe: !1, + newAttributes: N, + enabledAttributes: O, + attributeDivisors: B, + object: L, + attributes: {}, + index: null + }; + } + function d(L, N, O, B) { + const j = c.attributes, q = N.attributes; + let J = 0; + const ne = O.getAttributes(); + for (const ue in ne) + if (ne[ue].location >= 0) { + const H = j[ue]; + let ee = q[ue]; + if (ee === void 0 && (ue === "instanceMatrix" && L.instanceMatrix && (ee = L.instanceMatrix), ue === "instanceColor" && L.instanceColor && (ee = L.instanceColor)), H === void 0 || H.attribute !== ee || ee && H.data !== ee.data) + return !0; + J++; + } + return c.attributesNum !== J || c.index !== B; + } + function M(L, N, O, B) { + const j = {}, q = N.attributes; + let J = 0; + const ne = O.getAttributes(); + for (const ue in ne) + if (ne[ue].location >= 0) { + let H = q[ue]; + H === void 0 && (ue === "instanceMatrix" && L.instanceMatrix && (H = L.instanceMatrix), ue === "instanceColor" && L.instanceColor && (H = L.instanceColor)); + const ee = {}; + ee.attribute = H, H && H.data && (ee.data = H.data), j[ue] = ee, J++; + } + c.attributes = j, c.attributesNum = J, c.index = B; + } + function _() { + const L = c.newAttributes; + for (let N = 0, O = L.length; N < O; N++) + L[N] = 0; + } + function A(L) { + C(L, 0); + } + function C(L, N) { + const O = c.newAttributes, B = c.enabledAttributes, j = c.attributeDivisors; + O[L] = 1, B[L] === 0 && (i.enableVertexAttribArray(L), B[L] = 1), j[L] !== N && ((n.isWebGL2 ? i : e.get("ANGLE_instanced_arrays"))[n.isWebGL2 ? "vertexAttribDivisor" : "vertexAttribDivisorANGLE"](L, N), j[L] = N); + } + function E() { + const L = c.newAttributes, N = c.enabledAttributes; + for (let O = 0, B = N.length; O < B; O++) + N[O] !== L[O] && (i.disableVertexAttribArray(O), N[O] = 0); + } + function b(L, N, O, B, j, q, J) { + J === !0 ? i.vertexAttribIPointer(L, N, O, j, q) : i.vertexAttribPointer(L, N, O, B, j, q); + } + function I(L, N, O, B) { + if (n.isWebGL2 === !1 && (L.isInstancedMesh || B.isInstancedBufferGeometry) && e.get("ANGLE_instanced_arrays") === null) + return; + _(); + const j = B.attributes, q = O.getAttributes(), J = N.defaultAttributeValues; + for (const ne in q) { + const ue = q[ne]; + if (ue.location >= 0) { + let Z = j[ne]; + if (Z === void 0 && (ne === "instanceMatrix" && L.instanceMatrix && (Z = L.instanceMatrix), ne === "instanceColor" && L.instanceColor && (Z = L.instanceColor)), Z !== void 0) { + const H = Z.normalized, ee = Z.itemSize, pe = t.get(Z); + if (pe === void 0) + continue; + const Te = pe.buffer, xe = pe.type, ge = pe.bytesPerElement, Ke = n.isWebGL2 === !0 && (xe === i.INT || xe === i.UNSIGNED_INT || Z.gpuType === Gl); + if (Z.isInterleavedBufferAttribute) { + const we = Z.data, F = we.stride, lt = Z.offset; + if (we.isInstancedInterleavedBuffer) { + for (let Me = 0; Me < ue.locationSize; Me++) + C(ue.location + Me, we.meshPerAttribute); + L.isInstancedMesh !== !0 && B._maxInstanceCount === void 0 && (B._maxInstanceCount = we.meshPerAttribute * we.count); + } else + for (let Me = 0; Me < ue.locationSize; Me++) + A(ue.location + Me); + i.bindBuffer(i.ARRAY_BUFFER, Te); + for (let Me = 0; Me < ue.locationSize; Me++) + b( + ue.location + Me, + ee / ue.locationSize, + xe, + H, + F * ge, + (lt + ee / ue.locationSize * Me) * ge, + Ke + ); + } else { + if (Z.isInstancedBufferAttribute) { + for (let we = 0; we < ue.locationSize; we++) + C(ue.location + we, Z.meshPerAttribute); + L.isInstancedMesh !== !0 && B._maxInstanceCount === void 0 && (B._maxInstanceCount = Z.meshPerAttribute * Z.count); + } else + for (let we = 0; we < ue.locationSize; we++) + A(ue.location + we); + i.bindBuffer(i.ARRAY_BUFFER, Te); + for (let we = 0; we < ue.locationSize; we++) + b( + ue.location + we, + ee / ue.locationSize, + xe, + H, + ee * ge, + ee / ue.locationSize * we * ge, + Ke + ); + } + } else if (J !== void 0) { + const H = J[ne]; + if (H !== void 0) + switch (H.length) { + case 2: + i.vertexAttrib2fv(ue.location, H); + break; + case 3: + i.vertexAttrib3fv(ue.location, H); + break; + case 4: + i.vertexAttrib4fv(ue.location, H); + break; + default: + i.vertexAttrib1fv(ue.location, H); + } + } + } + } + E(); + } + function W() { + Y(); + for (const L in o) { + const N = o[L]; + for (const O in N) { + const B = N[O]; + for (const j in B) + g(B[j].object), delete B[j]; + delete N[O]; + } + delete o[L]; + } + } + function S(L) { + if (o[L.id] === void 0) + return; + const N = o[L.id]; + for (const O in N) { + const B = N[O]; + for (const j in B) + g(B[j].object), delete B[j]; + delete N[O]; + } + delete o[L.id]; + } + function T(L) { + for (const N in o) { + const O = o[N]; + if (O[L.id] === void 0) + continue; + const B = O[L.id]; + for (const j in B) + g(B[j].object), delete B[j]; + delete O[L.id]; + } + } + function Y() { + K(), u = !0, c !== l && (c = l, p(c.object)); + } + function K() { + l.geometry = null, l.program = null, l.wireframe = !1; + } + return { + setup: f, + reset: Y, + resetDefaultState: K, + dispose: W, + releaseStatesOfGeometry: S, + releaseStatesOfProgram: T, + initAttributes: _, + enableAttribute: A, + disableUnusedAttributes: E + }; +} +function sm(i, e, t, n) { + const r = n.isWebGL2; + let s; + function a(u) { + s = u; + } + function o(u, f) { + i.drawArrays(s, u, f), t.update(f, s, 1); + } + function l(u, f, h) { + if (h === 0) + return; + let p, g; + if (r) + p = i, g = "drawArraysInstanced"; + else if (p = e.get("ANGLE_instanced_arrays"), g = "drawArraysInstancedANGLE", p === null) { + console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays."); + return; + } + p[g](s, u, f, h), t.update(f, s, h); + } + function c(u, f, h) { + if (h === 0) + return; + const p = e.get("WEBGL_multi_draw"); + if (p === null) + for (let g = 0; g < h; g++) + this.render(u[g], f[g]); + else { + p.multiDrawArraysWEBGL(s, u, 0, f, 0, h); + let g = 0; + for (let v = 0; v < h; v++) + g += f[v]; + t.update(g, s, 1); + } + } + this.setMode = a, this.render = o, this.renderInstances = l, this.renderMultiDraw = c; +} +function om(i, e, t) { + let n; + function r() { + if (n !== void 0) + return n; + if (e.has("EXT_texture_filter_anisotropic") === !0) { + const b = e.get("EXT_texture_filter_anisotropic"); + n = i.getParameter(b.MAX_TEXTURE_MAX_ANISOTROPY_EXT); + } else + n = 0; + return n; + } + function s(b) { + if (b === "highp") { + if (i.getShaderPrecisionFormat(i.VERTEX_SHADER, i.HIGH_FLOAT).precision > 0 && i.getShaderPrecisionFormat(i.FRAGMENT_SHADER, i.HIGH_FLOAT).precision > 0) + return "highp"; + b = "mediump"; + } + return b === "mediump" && i.getShaderPrecisionFormat(i.VERTEX_SHADER, i.MEDIUM_FLOAT).precision > 0 && i.getShaderPrecisionFormat(i.FRAGMENT_SHADER, i.MEDIUM_FLOAT).precision > 0 ? "mediump" : "lowp"; + } + const a = typeof WebGL2RenderingContext < "u" && i.constructor.name === "WebGL2RenderingContext"; + let o = t.precision !== void 0 ? t.precision : "highp"; + const l = s(o); + l !== o && (console.warn("THREE.WebGLRenderer:", o, "not supported, using", l, "instead."), o = l); + const c = a || e.has("WEBGL_draw_buffers"), u = t.logarithmicDepthBuffer === !0, f = i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS), h = i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS), p = i.getParameter(i.MAX_TEXTURE_SIZE), g = i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE), v = i.getParameter(i.MAX_VERTEX_ATTRIBS), m = i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS), d = i.getParameter(i.MAX_VARYING_VECTORS), M = i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS), _ = h > 0, A = a || e.has("OES_texture_float"), C = _ && A, E = a ? i.getParameter(i.MAX_SAMPLES) : 0; + return { + isWebGL2: a, + drawBuffers: c, + getMaxAnisotropy: r, + getMaxPrecision: s, + precision: o, + logarithmicDepthBuffer: u, + maxTextures: f, + maxVertexTextures: h, + maxTextureSize: p, + maxCubemapSize: g, + maxAttributes: v, + maxVertexUniforms: m, + maxVaryings: d, + maxFragmentUniforms: M, + vertexTextures: _, + floatFragmentTextures: A, + floatVertexTextures: C, + maxSamples: E + }; +} +function am(i) { + const e = this; + let t = null, n = 0, r = !1, s = !1; + const a = new Fn(), o = new be(), l = { value: null, needsUpdate: !1 }; + this.uniform = l, this.numPlanes = 0, this.numIntersection = 0, this.init = function(f, h) { + const p = f.length !== 0 || h || // enable state of previous frame - the clipping code has to + // run another frame in order to reset the state: + n !== 0 || r; + return r = h, n = f.length, p; + }, this.beginShadows = function() { + s = !0, u(null); + }, this.endShadows = function() { + s = !1; + }, this.setGlobalState = function(f, h) { + t = u(f, h, 0); + }, this.setState = function(f, h, p) { + const g = f.clippingPlanes, v = f.clipIntersection, m = f.clipShadows, d = i.get(f); + if (!r || g === null || g.length === 0 || s && !m) + s ? u(null) : c(); + else { + const M = s ? 0 : n, _ = M * 4; + let A = d.clippingState || null; + l.value = A, A = u(g, h, _, p); + for (let C = 0; C !== _; ++C) + A[C] = t[C]; + d.clippingState = A, this.numIntersection = v ? this.numPlanes : 0, this.numPlanes += M; + } + }; + function c() { + l.value !== t && (l.value = t, l.needsUpdate = n > 0), e.numPlanes = n, e.numIntersection = 0; + } + function u(f, h, p, g) { + const v = f !== null ? f.length : 0; + let m = null; + if (v !== 0) { + if (m = l.value, g !== !0 || m === null) { + const d = p + v * 4, M = h.matrixWorldInverse; + o.getNormalMatrix(M), (m === null || m.length < d) && (m = new Float32Array(d)); + for (let _ = 0, A = p; _ !== v; ++_, A += 4) + a.copy(f[_]).applyMatrix4(M, o), a.normal.toArray(m, A), m[A + 3] = a.constant; + } + l.value = m, l.needsUpdate = !0; + } + return e.numPlanes = v, e.numIntersection = 0, m; + } +} +function lm(i) { + let e = /* @__PURE__ */ new WeakMap(); + function t(a, o) { + return o === eo ? a.mapping = zi : o === to && (a.mapping = ki), a; + } + function n(a) { + if (a && a.isTexture) { + const o = a.mapping; + if (o === eo || o === to) + if (e.has(a)) { + const l = e.get(a).texture; + return t(l, a.mapping); + } else { + const l = a.image; + if (l && l.height > 0) { + const c = new vh(l.height); + return c.fromEquirectangularTexture(i, a), e.set(a, c), a.addEventListener("dispose", r), t(c.texture, a.mapping); + } else + return null; + } + } + return a; + } + function r(a) { + const o = a.target; + o.removeEventListener("dispose", r); + const l = e.get(o); + l !== void 0 && (e.delete(o), l.dispose()); + } + function s() { + e = /* @__PURE__ */ new WeakMap(); + } + return { + get: n, + dispose: s + }; +} +class lc extends rc { + constructor(e = -1, t = 1, n = 1, r = -1, s = 0.1, a = 2e3) { + super(), this.isOrthographicCamera = !0, this.type = "OrthographicCamera", this.zoom = 1, this.view = null, this.left = e, this.right = t, this.top = n, this.bottom = r, this.near = s, this.far = a, this.updateProjectionMatrix(); + } + copy(e, t) { + return super.copy(e, t), this.left = e.left, this.right = e.right, this.top = e.top, this.bottom = e.bottom, this.near = e.near, this.far = e.far, this.zoom = e.zoom, this.view = e.view === null ? null : Object.assign({}, e.view), this; + } + setViewOffset(e, t, n, r, s, a) { + this.view === null && (this.view = { + enabled: !0, + fullWidth: 1, + fullHeight: 1, + offsetX: 0, + offsetY: 0, + width: 1, + height: 1 + }), this.view.enabled = !0, this.view.fullWidth = e, this.view.fullHeight = t, this.view.offsetX = n, this.view.offsetY = r, this.view.width = s, this.view.height = a, this.updateProjectionMatrix(); + } + clearViewOffset() { + this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix(); + } + updateProjectionMatrix() { + const e = (this.right - this.left) / (2 * this.zoom), t = (this.top - this.bottom) / (2 * this.zoom), n = (this.right + this.left) / 2, r = (this.top + this.bottom) / 2; + let s = n - e, a = n + e, o = r + t, l = r - t; + if (this.view !== null && this.view.enabled) { + const c = (this.right - this.left) / this.view.fullWidth / this.zoom, u = (this.top - this.bottom) / this.view.fullHeight / this.zoom; + s += c * this.view.offsetX, a = s + c * this.view.width, o -= u * this.view.offsetY, l = o - u * this.view.height; + } + this.projectionMatrix.makeOrthographic(s, a, o, l, this.near, this.far, this.coordinateSystem), this.projectionMatrixInverse.copy(this.projectionMatrix).invert(); + } + toJSON(e) { + const t = super.toJSON(e); + return t.object.zoom = this.zoom, t.object.left = this.left, t.object.right = this.right, t.object.top = this.top, t.object.bottom = this.bottom, t.object.near = this.near, t.object.far = this.far, this.view !== null && (t.object.view = Object.assign({}, this.view)), t; + } +} +const Ui = 4, Fa = [0.125, 0.215, 0.35, 0.446, 0.526, 0.582], ti = 20, Vs = /* @__PURE__ */ new lc(), Na = /* @__PURE__ */ new Qe(); +let Ws = null, Xs = 0, qs = 0; +const $n = (1 + Math.sqrt(5)) / 2, Ci = 1 / $n, Ba = [ + /* @__PURE__ */ new P(1, 1, 1), + /* @__PURE__ */ new P(-1, 1, 1), + /* @__PURE__ */ new P(1, 1, -1), + /* @__PURE__ */ new P(-1, 1, -1), + /* @__PURE__ */ new P(0, $n, Ci), + /* @__PURE__ */ new P(0, $n, -Ci), + /* @__PURE__ */ new P(Ci, 0, $n), + /* @__PURE__ */ new P(-Ci, 0, $n), + /* @__PURE__ */ new P($n, Ci, 0), + /* @__PURE__ */ new P(-$n, Ci, 0) +]; +class Oa { + constructor(e) { + this._renderer = e, this._pingPongRenderTarget = null, this._lodMax = 0, this._cubeSize = 0, this._lodPlanes = [], this._sizeLods = [], this._sigmas = [], this._blurMaterial = null, this._cubemapMaterial = null, this._equirectMaterial = null, this._compileMaterial(this._blurMaterial); + } + /** + * Generates a PMREM from a supplied Scene, which can be faster than using an + * image if networking bandwidth is low. Optional sigma specifies a blur radius + * in radians to be applied to the scene before PMREM generation. Optional near + * and far planes ensure the scene is rendered in its entirety (the cubeCamera + * is placed at the origin). + */ + fromScene(e, t = 0, n = 0.1, r = 100) { + Ws = this._renderer.getRenderTarget(), Xs = this._renderer.getActiveCubeFace(), qs = this._renderer.getActiveMipmapLevel(), this._setSize(256); + const s = this._allocateTargets(); + return s.depthBuffer = !0, this._sceneToCubeUV(e, n, r, s), t > 0 && this._blur(s, 0, 0, t), this._applyPMREM(s), this._cleanup(s), s; + } + /** + * Generates a PMREM from an equirectangular texture, which can be either LDR + * or HDR. The ideal input image size is 1k (1024 x 512), + * as this matches best with the 256 x 256 cubemap output. + * The smallest supported equirectangular image size is 64 x 32. + */ + fromEquirectangular(e, t = null) { + return this._fromTexture(e, t); + } + /** + * Generates a PMREM from an cubemap texture, which can be either LDR + * or HDR. The ideal input cube size is 256 x 256, + * as this matches best with the 256 x 256 cubemap output. + * The smallest supported cube size is 16 x 16. + */ + fromCubemap(e, t = null) { + return this._fromTexture(e, t); + } + /** + * Pre-compiles the cubemap shader. You can get faster start-up by invoking this method during + * your texture's network fetch for increased concurrency. + */ + compileCubemapShader() { + this._cubemapMaterial === null && (this._cubemapMaterial = Ga(), this._compileMaterial(this._cubemapMaterial)); + } + /** + * Pre-compiles the equirectangular shader. You can get faster start-up by invoking this method during + * your texture's network fetch for increased concurrency. + */ + compileEquirectangularShader() { + this._equirectMaterial === null && (this._equirectMaterial = ka(), this._compileMaterial(this._equirectMaterial)); + } + /** + * Disposes of the PMREMGenerator's internal memory. Note that PMREMGenerator is a static class, + * so you should not need more than one PMREMGenerator object. If you do, calling dispose() on + * one of them will cause any others to also become unusable. + */ + dispose() { + this._dispose(), this._cubemapMaterial !== null && this._cubemapMaterial.dispose(), this._equirectMaterial !== null && this._equirectMaterial.dispose(); + } + // private interface + _setSize(e) { + this._lodMax = Math.floor(Math.log2(e)), this._cubeSize = Math.pow(2, this._lodMax); + } + _dispose() { + this._blurMaterial !== null && this._blurMaterial.dispose(), this._pingPongRenderTarget !== null && this._pingPongRenderTarget.dispose(); + for (let e = 0; e < this._lodPlanes.length; e++) + this._lodPlanes[e].dispose(); + } + _cleanup(e) { + this._renderer.setRenderTarget(Ws, Xs, qs), e.scissorTest = !1, Nr(e, 0, 0, e.width, e.height); + } + _fromTexture(e, t) { + e.mapping === zi || e.mapping === ki ? this._setSize(e.image.length === 0 ? 16 : e.image[0].width || e.image[0].image.width) : this._setSize(e.image.width / 4), Ws = this._renderer.getRenderTarget(), Xs = this._renderer.getActiveCubeFace(), qs = this._renderer.getActiveMipmapLevel(); + const n = t || this._allocateTargets(); + return this._textureToCubeUV(e, n), this._applyPMREM(n), this._cleanup(n), n; + } + _allocateTargets() { + const e = 3 * Math.max(this._cubeSize, 112), t = 4 * this._cubeSize, n = { + magFilter: Ct, + minFilter: Ct, + generateMipmaps: !1, + type: Gi, + format: Vt, + colorSpace: Wn, + depthBuffer: !1 + }, r = za(e, t, n); + if (this._pingPongRenderTarget === null || this._pingPongRenderTarget.width !== e || this._pingPongRenderTarget.height !== t) { + this._pingPongRenderTarget !== null && this._dispose(), this._pingPongRenderTarget = za(e, t, n); + const { _lodMax: s } = this; + ({ sizeLods: this._sizeLods, lodPlanes: this._lodPlanes, sigmas: this._sigmas } = cm(s)), this._blurMaterial = um(s, e, t); + } + return r; + } + _compileMaterial(e) { + const t = new at(this._lodPlanes[0], e); + this._renderer.compile(t, Vs); + } + _sceneToCubeUV(e, t, n, r) { + const o = new Ht(90, 1, t, n), l = [1, -1, 1, 1, 1, 1], c = [1, 1, 1, -1, -1, -1], u = this._renderer, f = u.autoClear, h = u.toneMapping; + u.getClearColor(Na), u.toneMapping = kn, u.autoClear = !1; + const p = new oi({ + name: "PMREM.Background", + side: Pt, + depthWrite: !1, + depthTest: !1 + }), g = new at(new Qi(), p); + let v = !1; + const m = e.background; + m ? m.isColor && (p.color.copy(m), e.background = null, v = !0) : (p.color.copy(Na), v = !0); + for (let d = 0; d < 6; d++) { + const M = d % 3; + M === 0 ? (o.up.set(0, l[d], 0), o.lookAt(c[d], 0, 0)) : M === 1 ? (o.up.set(0, 0, l[d]), o.lookAt(0, c[d], 0)) : (o.up.set(0, l[d], 0), o.lookAt(0, 0, c[d])); + const _ = this._cubeSize; + Nr(r, M * _, d > 2 ? _ : 0, _, _), u.setRenderTarget(r), v && u.render(g, o), u.render(e, o); + } + g.geometry.dispose(), g.material.dispose(), u.toneMapping = h, u.autoClear = f, e.background = m; + } + _textureToCubeUV(e, t) { + const n = this._renderer, r = e.mapping === zi || e.mapping === ki; + r ? (this._cubemapMaterial === null && (this._cubemapMaterial = Ga()), this._cubemapMaterial.uniforms.flipEnvMap.value = e.isRenderTargetTexture === !1 ? -1 : 1) : this._equirectMaterial === null && (this._equirectMaterial = ka()); + const s = r ? this._cubemapMaterial : this._equirectMaterial, a = new at(this._lodPlanes[0], s), o = s.uniforms; + o.envMap.value = e; + const l = this._cubeSize; + Nr(t, 0, 0, 3 * l, 2 * l), n.setRenderTarget(t), n.render(a, Vs); + } + _applyPMREM(e) { + const t = this._renderer, n = t.autoClear; + t.autoClear = !1; + for (let r = 1; r < this._lodPlanes.length; r++) { + const s = Math.sqrt(this._sigmas[r] * this._sigmas[r] - this._sigmas[r - 1] * this._sigmas[r - 1]), a = Ba[(r - 1) % Ba.length]; + this._blur(e, r - 1, r, s, a); + } + t.autoClear = n; + } + /** + * This is a two-pass Gaussian blur for a cubemap. Normally this is done + * vertically and horizontally, but this breaks down on a cube. Here we apply + * the blur latitudinally (around the poles), and then longitudinally (towards + * the poles) to approximate the orthogonally-separable blur. It is least + * accurate at the poles, but still does a decent job. + */ + _blur(e, t, n, r, s) { + const a = this._pingPongRenderTarget; + this._halfBlur( + e, + a, + t, + n, + r, + "latitudinal", + s + ), this._halfBlur( + a, + e, + n, + n, + r, + "longitudinal", + s + ); + } + _halfBlur(e, t, n, r, s, a, o) { + const l = this._renderer, c = this._blurMaterial; + a !== "latitudinal" && a !== "longitudinal" && console.error( + "blur direction must be either latitudinal or longitudinal!" + ); + const u = 3, f = new at(this._lodPlanes[r], c), h = c.uniforms, p = this._sizeLods[n] - 1, g = isFinite(s) ? Math.PI / (2 * p) : 2 * Math.PI / (2 * ti - 1), v = s / g, m = isFinite(s) ? 1 + Math.floor(u * v) : ti; + m > ti && console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${ti}`); + const d = []; + let M = 0; + for (let b = 0; b < ti; ++b) { + const I = b / v, W = Math.exp(-I * I / 2); + d.push(W), b === 0 ? M += W : b < m && (M += 2 * W); + } + for (let b = 0; b < d.length; b++) + d[b] = d[b] / M; + h.envMap.value = e.texture, h.samples.value = m, h.weights.value = d, h.latitudinal.value = a === "latitudinal", o && (h.poleAxis.value = o); + const { _lodMax: _ } = this; + h.dTheta.value = g, h.mipInt.value = _ - n; + const A = this._sizeLods[r], C = 3 * A * (r > _ - Ui ? r - _ + Ui : 0), E = 4 * (this._cubeSize - A); + Nr(t, C, E, 3 * A, 2 * A), l.setRenderTarget(t), l.render(f, Vs); + } +} +function cm(i) { + const e = [], t = [], n = []; + let r = i; + const s = i - Ui + 1 + Fa.length; + for (let a = 0; a < s; a++) { + const o = Math.pow(2, r); + t.push(o); + let l = 1 / o; + a > i - Ui ? l = Fa[a - i + Ui - 1] : a === 0 && (l = 0), n.push(l); + const c = 1 / (o - 2), u = -c, f = 1 + c, h = [u, u, f, u, f, f, u, u, f, f, u, f], p = 6, g = 6, v = 3, m = 2, d = 1, M = new Float32Array(v * g * p), _ = new Float32Array(m * g * p), A = new Float32Array(d * g * p); + for (let E = 0; E < p; E++) { + const b = E % 3 * 2 / 3 - 1, I = E > 2 ? 0 : -1, W = [ + b, + I, + 0, + b + 2 / 3, + I, + 0, + b + 2 / 3, + I + 1, + 0, + b, + I, + 0, + b + 2 / 3, + I + 1, + 0, + b, + I + 1, + 0 + ]; + M.set(W, v * g * E), _.set(h, m * g * E); + const S = [E, E, E, E, E, E]; + A.set(S, d * g * E); + } + const C = new Yt(); + C.setAttribute("position", new Wt(M, v)), C.setAttribute("uv", new Wt(_, m)), C.setAttribute("faceIndex", new Wt(A, d)), e.push(C), r > Ui && r--; + } + return { lodPlanes: e, sizeLods: t, sigmas: n }; +} +function za(i, e, t) { + const n = new Vn(i, e, t); + return n.texture.mapping = ss, n.texture.name = "PMREM.cubeUv", n.scissorTest = !0, n; +} +function Nr(i, e, t, n, r) { + i.viewport.set(e, t, n, r), i.scissor.set(e, t, n, r); +} +function um(i, e, t) { + const n = new Float32Array(ti), r = new P(0, 1, 0); + return new Xt({ + name: "SphericalGaussianBlur", + defines: { + n: ti, + CUBEUV_TEXEL_WIDTH: 1 / e, + CUBEUV_TEXEL_HEIGHT: 1 / t, + CUBEUV_MAX_MIP: `${i}.0` + }, + uniforms: { + envMap: { value: null }, + samples: { value: 1 }, + weights: { value: n }, + latitudinal: { value: !1 }, + dTheta: { value: 0 }, + mipInt: { value: 0 }, + poleAxis: { value: r } + }, + vertexShader: xo(), + fragmentShader: ( + /* glsl */ + ` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + ` + ), + blending: zn, + depthTest: !1, + depthWrite: !1 + }); +} +function ka() { + return new Xt({ + name: "EquirectangularToCubeUV", + uniforms: { + envMap: { value: null } + }, + vertexShader: xo(), + fragmentShader: ( + /* glsl */ + ` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + ` + ), + blending: zn, + depthTest: !1, + depthWrite: !1 + }); +} +function Ga() { + return new Xt({ + name: "CubemapToCubeUV", + uniforms: { + envMap: { value: null }, + flipEnvMap: { value: -1 } + }, + vertexShader: xo(), + fragmentShader: ( + /* glsl */ + ` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + ` + ), + blending: zn, + depthTest: !1, + depthWrite: !1 + }); +} +function xo() { + return ( + /* glsl */ + ` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + ` + ); +} +function fm(i) { + let e = /* @__PURE__ */ new WeakMap(), t = null; + function n(o) { + if (o && o.isTexture) { + const l = o.mapping, c = l === eo || l === to, u = l === zi || l === ki; + if (c || u) + if (o.isRenderTargetTexture && o.needsPMREMUpdate === !0) { + o.needsPMREMUpdate = !1; + let f = e.get(o); + return t === null && (t = new Oa(i)), f = c ? t.fromEquirectangular(o, f) : t.fromCubemap(o, f), e.set(o, f), f.texture; + } else { + if (e.has(o)) + return e.get(o).texture; + { + const f = o.image; + if (c && f && f.height > 0 || u && f && r(f)) { + t === null && (t = new Oa(i)); + const h = c ? t.fromEquirectangular(o) : t.fromCubemap(o); + return e.set(o, h), o.addEventListener("dispose", s), h.texture; + } else + return null; + } + } + } + return o; + } + function r(o) { + let l = 0; + const c = 6; + for (let u = 0; u < c; u++) + o[u] !== void 0 && l++; + return l === c; + } + function s(o) { + const l = o.target; + l.removeEventListener("dispose", s); + const c = e.get(l); + c !== void 0 && (e.delete(l), c.dispose()); + } + function a() { + e = /* @__PURE__ */ new WeakMap(), t !== null && (t.dispose(), t = null); + } + return { + get: n, + dispose: a + }; +} +function hm(i) { + const e = {}; + function t(n) { + if (e[n] !== void 0) + return e[n]; + let r; + switch (n) { + case "WEBGL_depth_texture": + r = i.getExtension("WEBGL_depth_texture") || i.getExtension("MOZ_WEBGL_depth_texture") || i.getExtension("WEBKIT_WEBGL_depth_texture"); + break; + case "EXT_texture_filter_anisotropic": + r = i.getExtension("EXT_texture_filter_anisotropic") || i.getExtension("MOZ_EXT_texture_filter_anisotropic") || i.getExtension("WEBKIT_EXT_texture_filter_anisotropic"); + break; + case "WEBGL_compressed_texture_s3tc": + r = i.getExtension("WEBGL_compressed_texture_s3tc") || i.getExtension("MOZ_WEBGL_compressed_texture_s3tc") || i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"); + break; + case "WEBGL_compressed_texture_pvrtc": + r = i.getExtension("WEBGL_compressed_texture_pvrtc") || i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"); + break; + default: + r = i.getExtension(n); + } + return e[n] = r, r; + } + return { + has: function(n) { + return t(n) !== null; + }, + init: function(n) { + n.isWebGL2 ? (t("EXT_color_buffer_float"), t("WEBGL_clip_cull_distance")) : (t("WEBGL_depth_texture"), t("OES_texture_float"), t("OES_texture_half_float"), t("OES_texture_half_float_linear"), t("OES_standard_derivatives"), t("OES_element_index_uint"), t("OES_vertex_array_object"), t("ANGLE_instanced_arrays")), t("OES_texture_float_linear"), t("EXT_color_buffer_half_float"), t("WEBGL_multisampled_render_to_texture"); + }, + get: function(n) { + const r = t(n); + return r === null && console.warn("THREE.WebGLRenderer: " + n + " extension not supported."), r; + } + }; +} +function dm(i, e, t, n) { + const r = {}, s = /* @__PURE__ */ new WeakMap(); + function a(f) { + const h = f.target; + h.index !== null && e.remove(h.index); + for (const g in h.attributes) + e.remove(h.attributes[g]); + for (const g in h.morphAttributes) { + const v = h.morphAttributes[g]; + for (let m = 0, d = v.length; m < d; m++) + e.remove(v[m]); + } + h.removeEventListener("dispose", a), delete r[h.id]; + const p = s.get(h); + p && (e.remove(p), s.delete(h)), n.releaseStatesOfGeometry(h), h.isInstancedBufferGeometry === !0 && delete h._maxInstanceCount, t.memory.geometries--; + } + function o(f, h) { + return r[h.id] === !0 || (h.addEventListener("dispose", a), r[h.id] = !0, t.memory.geometries++), h; + } + function l(f) { + const h = f.attributes; + for (const g in h) + e.update(h[g], i.ARRAY_BUFFER); + const p = f.morphAttributes; + for (const g in p) { + const v = p[g]; + for (let m = 0, d = v.length; m < d; m++) + e.update(v[m], i.ARRAY_BUFFER); + } + } + function c(f) { + const h = [], p = f.index, g = f.attributes.position; + let v = 0; + if (p !== null) { + const M = p.array; + v = p.version; + for (let _ = 0, A = M.length; _ < A; _ += 3) { + const C = M[_ + 0], E = M[_ + 1], b = M[_ + 2]; + h.push(C, E, E, b, b, C); + } + } else if (g !== void 0) { + const M = g.array; + v = g.version; + for (let _ = 0, A = M.length / 3 - 1; _ < A; _ += 3) { + const C = _ + 0, E = _ + 1, b = _ + 2; + h.push(C, E, E, b, b, C); + } + } else + return; + const m = new (jl(h) ? nc : tc)(h, 1); + m.version = v; + const d = s.get(f); + d && e.remove(d), s.set(f, m); + } + function u(f) { + const h = s.get(f); + if (h) { + const p = f.index; + p !== null && h.version < p.version && c(f); + } else + c(f); + return s.get(f); + } + return { + get: o, + update: l, + getWireframeAttribute: u + }; +} +function pm(i, e, t, n) { + const r = n.isWebGL2; + let s; + function a(p) { + s = p; + } + let o, l; + function c(p) { + o = p.type, l = p.bytesPerElement; + } + function u(p, g) { + i.drawElements(s, g, o, p * l), t.update(g, s, 1); + } + function f(p, g, v) { + if (v === 0) + return; + let m, d; + if (r) + m = i, d = "drawElementsInstanced"; + else if (m = e.get("ANGLE_instanced_arrays"), d = "drawElementsInstancedANGLE", m === null) { + console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays."); + return; + } + m[d](s, g, o, p * l, v), t.update(g, s, v); + } + function h(p, g, v) { + if (v === 0) + return; + const m = e.get("WEBGL_multi_draw"); + if (m === null) + for (let d = 0; d < v; d++) + this.render(p[d] / l, g[d]); + else { + m.multiDrawElementsWEBGL(s, g, 0, o, p, 0, v); + let d = 0; + for (let M = 0; M < v; M++) + d += g[M]; + t.update(d, s, 1); + } + } + this.setMode = a, this.setIndex = c, this.render = u, this.renderInstances = f, this.renderMultiDraw = h; +} +function mm(i) { + const e = { + geometries: 0, + textures: 0 + }, t = { + frame: 0, + calls: 0, + triangles: 0, + points: 0, + lines: 0 + }; + function n(s, a, o) { + switch (t.calls++, a) { + case i.TRIANGLES: + t.triangles += o * (s / 3); + break; + case i.LINES: + t.lines += o * (s / 2); + break; + case i.LINE_STRIP: + t.lines += o * (s - 1); + break; + case i.LINE_LOOP: + t.lines += o * s; + break; + case i.POINTS: + t.points += o * s; + break; + default: + console.error("THREE.WebGLInfo: Unknown draw mode:", a); + break; + } + } + function r() { + t.calls = 0, t.triangles = 0, t.points = 0, t.lines = 0; + } + return { + memory: e, + render: t, + programs: null, + autoReset: !0, + reset: r, + update: n + }; +} +function gm(i, e) { + return i[0] - e[0]; +} +function _m(i, e) { + return Math.abs(e[1]) - Math.abs(i[1]); +} +function vm(i, e, t) { + const n = {}, r = new Float32Array(8), s = /* @__PURE__ */ new WeakMap(), a = new ut(), o = []; + for (let c = 0; c < 8; c++) + o[c] = [c, 0]; + function l(c, u, f) { + const h = c.morphTargetInfluences; + if (e.isWebGL2 === !0) { + const p = u.morphAttributes.position || u.morphAttributes.normal || u.morphAttributes.color, g = p !== void 0 ? p.length : 0; + let v = s.get(u); + if (v === void 0 || v.count !== g) { + let Y = function() { + S.dispose(), s.delete(u), u.removeEventListener("dispose", Y); + }; + v !== void 0 && v.texture.dispose(); + const m = u.morphAttributes.position !== void 0, d = u.morphAttributes.normal !== void 0, M = u.morphAttributes.color !== void 0, _ = u.morphAttributes.position || [], A = u.morphAttributes.normal || [], C = u.morphAttributes.color || []; + let E = 0; + m === !0 && (E = 1), d === !0 && (E = 2), M === !0 && (E = 3); + let b = u.attributes.position.count * E, I = 1; + b > e.maxTextureSize && (I = Math.ceil(b / e.maxTextureSize), b = e.maxTextureSize); + const W = new Float32Array(b * I * 4 * g), S = new Zl(W, b, I, g); + S.type = an, S.needsUpdate = !0; + const T = E * 4; + for (let K = 0; K < g; K++) { + const L = _[K], N = A[K], O = C[K], B = b * I * 4 * K; + for (let j = 0; j < L.count; j++) { + const q = j * T; + m === !0 && (a.fromBufferAttribute(L, j), W[B + q + 0] = a.x, W[B + q + 1] = a.y, W[B + q + 2] = a.z, W[B + q + 3] = 0), d === !0 && (a.fromBufferAttribute(N, j), W[B + q + 4] = a.x, W[B + q + 5] = a.y, W[B + q + 6] = a.z, W[B + q + 7] = 0), M === !0 && (a.fromBufferAttribute(O, j), W[B + q + 8] = a.x, W[B + q + 9] = a.y, W[B + q + 10] = a.z, W[B + q + 11] = O.itemSize === 4 ? a.w : 1); + } + } + v = { + count: g, + texture: S, + size: new me(b, I) + }, s.set(u, v), u.addEventListener("dispose", Y); + } + if (c.isInstancedMesh === !0 && c.morphTexture !== null) + f.getUniforms().setValue(i, "morphTexture", c.morphTexture, t); + else { + let m = 0; + for (let M = 0; M < h.length; M++) + m += h[M]; + const d = u.morphTargetsRelative ? 1 : 1 - m; + f.getUniforms().setValue(i, "morphTargetBaseInfluence", d), f.getUniforms().setValue(i, "morphTargetInfluences", h); + } + f.getUniforms().setValue(i, "morphTargetsTexture", v.texture, t), f.getUniforms().setValue(i, "morphTargetsTextureSize", v.size); + } else { + const p = h === void 0 ? 0 : h.length; + let g = n[u.id]; + if (g === void 0 || g.length !== p) { + g = []; + for (let _ = 0; _ < p; _++) + g[_] = [_, 0]; + n[u.id] = g; + } + for (let _ = 0; _ < p; _++) { + const A = g[_]; + A[0] = _, A[1] = h[_]; + } + g.sort(_m); + for (let _ = 0; _ < 8; _++) + _ < p && g[_][1] ? (o[_][0] = g[_][0], o[_][1] = g[_][1]) : (o[_][0] = Number.MAX_SAFE_INTEGER, o[_][1] = 0); + o.sort(gm); + const v = u.morphAttributes.position, m = u.morphAttributes.normal; + let d = 0; + for (let _ = 0; _ < 8; _++) { + const A = o[_], C = A[0], E = A[1]; + C !== Number.MAX_SAFE_INTEGER && E ? (v && u.getAttribute("morphTarget" + _) !== v[C] && u.setAttribute("morphTarget" + _, v[C]), m && u.getAttribute("morphNormal" + _) !== m[C] && u.setAttribute("morphNormal" + _, m[C]), r[_] = E, d += E) : (v && u.hasAttribute("morphTarget" + _) === !0 && u.deleteAttribute("morphTarget" + _), m && u.hasAttribute("morphNormal" + _) === !0 && u.deleteAttribute("morphNormal" + _), r[_] = 0); + } + const M = u.morphTargetsRelative ? 1 : 1 - d; + f.getUniforms().setValue(i, "morphTargetBaseInfluence", M), f.getUniforms().setValue(i, "morphTargetInfluences", r); + } + } + return { + update: l + }; +} +function xm(i, e, t, n) { + let r = /* @__PURE__ */ new WeakMap(); + function s(l) { + const c = n.render.frame, u = l.geometry, f = e.get(l, u); + if (r.get(f) !== c && (e.update(f), r.set(f, c)), l.isInstancedMesh && (l.hasEventListener("dispose", o) === !1 && l.addEventListener("dispose", o), r.get(l) !== c && (t.update(l.instanceMatrix, i.ARRAY_BUFFER), l.instanceColor !== null && t.update(l.instanceColor, i.ARRAY_BUFFER), r.set(l, c))), l.isSkinnedMesh) { + const h = l.skeleton; + r.get(h) !== c && (h.update(), r.set(h, c)); + } + return f; + } + function a() { + r = /* @__PURE__ */ new WeakMap(); + } + function o(l) { + const c = l.target; + c.removeEventListener("dispose", o), t.remove(c.instanceMatrix), c.instanceColor !== null && t.remove(c.instanceColor); + } + return { + update: s, + dispose: a + }; +} +class So extends Tt { + constructor(e, t, n, r, s, a, o, l, c, u) { + if (u = u !== void 0 ? u : Hn, u !== Hn && u !== Hi) + throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat"); + n === void 0 && u === Hn && (n = nn), n === void 0 && u === Hi && (n = si), super(null, r, s, a, o, l, u, n, c), this.isDepthTexture = !0, this.image = { width: e, height: t }, this.magFilter = o !== void 0 ? o : vt, this.minFilter = l !== void 0 ? l : vt, this.flipY = !1, this.generateMipmaps = !1, this.compareFunction = null; + } + copy(e) { + return super.copy(e), this.compareFunction = e.compareFunction, this; + } + toJSON(e) { + const t = super.toJSON(e); + return this.compareFunction !== null && (t.compareFunction = this.compareFunction), t; + } +} +const cc = /* @__PURE__ */ new Tt(), uc = /* @__PURE__ */ new So(1, 1); +uc.compareFunction = ql; +const fc = /* @__PURE__ */ new Zl(), hc = /* @__PURE__ */ new Jf(), dc = /* @__PURE__ */ new sc(), Ha = [], Va = [], Wa = new Float32Array(16), Xa = new Float32Array(9), qa = new Float32Array(4); +function Zi(i, e, t) { + const n = i[0]; + if (n <= 0 || n > 0) + return i; + const r = e * t; + let s = Ha[r]; + if (s === void 0 && (s = new Float32Array(r), Ha[r] = s), e !== 0) { + n.toArray(s, 0); + for (let a = 1, o = 0; a !== e; ++a) + o += t, i[a].toArray(s, o); + } + return s; +} +function ft(i, e) { + if (i.length !== e.length) + return !1; + for (let t = 0, n = i.length; t < n; t++) + if (i[t] !== e[t]) + return !1; + return !0; +} +function ht(i, e) { + for (let t = 0, n = e.length; t < n; t++) + i[t] = e[t]; +} +function ls(i, e) { + let t = Va[e]; + t === void 0 && (t = new Int32Array(e), Va[e] = t); + for (let n = 0; n !== e; ++n) + t[n] = i.allocateTextureUnit(); + return t; +} +function Sm(i, e) { + const t = this.cache; + t[0] !== e && (i.uniform1f(this.addr, e), t[0] = e); +} +function Mm(i, e) { + const t = this.cache; + if (e.x !== void 0) + (t[0] !== e.x || t[1] !== e.y) && (i.uniform2f(this.addr, e.x, e.y), t[0] = e.x, t[1] = e.y); + else { + if (ft(t, e)) + return; + i.uniform2fv(this.addr, e), ht(t, e); + } +} +function ym(i, e) { + const t = this.cache; + if (e.x !== void 0) + (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z) && (i.uniform3f(this.addr, e.x, e.y, e.z), t[0] = e.x, t[1] = e.y, t[2] = e.z); + else if (e.r !== void 0) + (t[0] !== e.r || t[1] !== e.g || t[2] !== e.b) && (i.uniform3f(this.addr, e.r, e.g, e.b), t[0] = e.r, t[1] = e.g, t[2] = e.b); + else { + if (ft(t, e)) + return; + i.uniform3fv(this.addr, e), ht(t, e); + } +} +function Am(i, e) { + const t = this.cache; + if (e.x !== void 0) + (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z || t[3] !== e.w) && (i.uniform4f(this.addr, e.x, e.y, e.z, e.w), t[0] = e.x, t[1] = e.y, t[2] = e.z, t[3] = e.w); + else { + if (ft(t, e)) + return; + i.uniform4fv(this.addr, e), ht(t, e); + } +} +function Em(i, e) { + const t = this.cache, n = e.elements; + if (n === void 0) { + if (ft(t, e)) + return; + i.uniformMatrix2fv(this.addr, !1, e), ht(t, e); + } else { + if (ft(t, n)) + return; + qa.set(n), i.uniformMatrix2fv(this.addr, !1, qa), ht(t, n); + } +} +function bm(i, e) { + const t = this.cache, n = e.elements; + if (n === void 0) { + if (ft(t, e)) + return; + i.uniformMatrix3fv(this.addr, !1, e), ht(t, e); + } else { + if (ft(t, n)) + return; + Xa.set(n), i.uniformMatrix3fv(this.addr, !1, Xa), ht(t, n); + } +} +function Tm(i, e) { + const t = this.cache, n = e.elements; + if (n === void 0) { + if (ft(t, e)) + return; + i.uniformMatrix4fv(this.addr, !1, e), ht(t, e); + } else { + if (ft(t, n)) + return; + Wa.set(n), i.uniformMatrix4fv(this.addr, !1, Wa), ht(t, n); + } +} +function wm(i, e) { + const t = this.cache; + t[0] !== e && (i.uniform1i(this.addr, e), t[0] = e); +} +function Cm(i, e) { + const t = this.cache; + if (e.x !== void 0) + (t[0] !== e.x || t[1] !== e.y) && (i.uniform2i(this.addr, e.x, e.y), t[0] = e.x, t[1] = e.y); + else { + if (ft(t, e)) + return; + i.uniform2iv(this.addr, e), ht(t, e); + } +} +function Rm(i, e) { + const t = this.cache; + if (e.x !== void 0) + (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z) && (i.uniform3i(this.addr, e.x, e.y, e.z), t[0] = e.x, t[1] = e.y, t[2] = e.z); + else { + if (ft(t, e)) + return; + i.uniform3iv(this.addr, e), ht(t, e); + } +} +function Pm(i, e) { + const t = this.cache; + if (e.x !== void 0) + (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z || t[3] !== e.w) && (i.uniform4i(this.addr, e.x, e.y, e.z, e.w), t[0] = e.x, t[1] = e.y, t[2] = e.z, t[3] = e.w); + else { + if (ft(t, e)) + return; + i.uniform4iv(this.addr, e), ht(t, e); + } +} +function Lm(i, e) { + const t = this.cache; + t[0] !== e && (i.uniform1ui(this.addr, e), t[0] = e); +} +function Dm(i, e) { + const t = this.cache; + if (e.x !== void 0) + (t[0] !== e.x || t[1] !== e.y) && (i.uniform2ui(this.addr, e.x, e.y), t[0] = e.x, t[1] = e.y); + else { + if (ft(t, e)) + return; + i.uniform2uiv(this.addr, e), ht(t, e); + } +} +function Im(i, e) { + const t = this.cache; + if (e.x !== void 0) + (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z) && (i.uniform3ui(this.addr, e.x, e.y, e.z), t[0] = e.x, t[1] = e.y, t[2] = e.z); + else { + if (ft(t, e)) + return; + i.uniform3uiv(this.addr, e), ht(t, e); + } +} +function Um(i, e) { + const t = this.cache; + if (e.x !== void 0) + (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z || t[3] !== e.w) && (i.uniform4ui(this.addr, e.x, e.y, e.z, e.w), t[0] = e.x, t[1] = e.y, t[2] = e.z, t[3] = e.w); + else { + if (ft(t, e)) + return; + i.uniform4uiv(this.addr, e), ht(t, e); + } +} +function Fm(i, e, t) { + const n = this.cache, r = t.allocateTextureUnit(); + n[0] !== r && (i.uniform1i(this.addr, r), n[0] = r); + const s = this.type === i.SAMPLER_2D_SHADOW ? uc : cc; + t.setTexture2D(e || s, r); +} +function Nm(i, e, t) { + const n = this.cache, r = t.allocateTextureUnit(); + n[0] !== r && (i.uniform1i(this.addr, r), n[0] = r), t.setTexture3D(e || hc, r); +} +function Bm(i, e, t) { + const n = this.cache, r = t.allocateTextureUnit(); + n[0] !== r && (i.uniform1i(this.addr, r), n[0] = r), t.setTextureCube(e || dc, r); +} +function Om(i, e, t) { + const n = this.cache, r = t.allocateTextureUnit(); + n[0] !== r && (i.uniform1i(this.addr, r), n[0] = r), t.setTexture2DArray(e || fc, r); +} +function zm(i) { + switch (i) { + case 5126: + return Sm; + case 35664: + return Mm; + case 35665: + return ym; + case 35666: + return Am; + case 35674: + return Em; + case 35675: + return bm; + case 35676: + return Tm; + case 5124: + case 35670: + return wm; + case 35667: + case 35671: + return Cm; + case 35668: + case 35672: + return Rm; + case 35669: + case 35673: + return Pm; + case 5125: + return Lm; + case 36294: + return Dm; + case 36295: + return Im; + case 36296: + return Um; + case 35678: + case 36198: + case 36298: + case 36306: + case 35682: + return Fm; + case 35679: + case 36299: + case 36307: + return Nm; + case 35680: + case 36300: + case 36308: + case 36293: + return Bm; + case 36289: + case 36303: + case 36311: + case 36292: + return Om; + } +} +function km(i, e) { + i.uniform1fv(this.addr, e); +} +function Gm(i, e) { + const t = Zi(e, this.size, 2); + i.uniform2fv(this.addr, t); +} +function Hm(i, e) { + const t = Zi(e, this.size, 3); + i.uniform3fv(this.addr, t); +} +function Vm(i, e) { + const t = Zi(e, this.size, 4); + i.uniform4fv(this.addr, t); +} +function Wm(i, e) { + const t = Zi(e, this.size, 4); + i.uniformMatrix2fv(this.addr, !1, t); +} +function Xm(i, e) { + const t = Zi(e, this.size, 9); + i.uniformMatrix3fv(this.addr, !1, t); +} +function qm(i, e) { + const t = Zi(e, this.size, 16); + i.uniformMatrix4fv(this.addr, !1, t); +} +function Ym(i, e) { + i.uniform1iv(this.addr, e); +} +function jm(i, e) { + i.uniform2iv(this.addr, e); +} +function Km(i, e) { + i.uniform3iv(this.addr, e); +} +function Qm(i, e) { + i.uniform4iv(this.addr, e); +} +function Zm(i, e) { + i.uniform1uiv(this.addr, e); +} +function Jm(i, e) { + i.uniform2uiv(this.addr, e); +} +function $m(i, e) { + i.uniform3uiv(this.addr, e); +} +function eg(i, e) { + i.uniform4uiv(this.addr, e); +} +function tg(i, e, t) { + const n = this.cache, r = e.length, s = ls(t, r); + ft(n, s) || (i.uniform1iv(this.addr, s), ht(n, s)); + for (let a = 0; a !== r; ++a) + t.setTexture2D(e[a] || cc, s[a]); +} +function ng(i, e, t) { + const n = this.cache, r = e.length, s = ls(t, r); + ft(n, s) || (i.uniform1iv(this.addr, s), ht(n, s)); + for (let a = 0; a !== r; ++a) + t.setTexture3D(e[a] || hc, s[a]); +} +function ig(i, e, t) { + const n = this.cache, r = e.length, s = ls(t, r); + ft(n, s) || (i.uniform1iv(this.addr, s), ht(n, s)); + for (let a = 0; a !== r; ++a) + t.setTextureCube(e[a] || dc, s[a]); +} +function rg(i, e, t) { + const n = this.cache, r = e.length, s = ls(t, r); + ft(n, s) || (i.uniform1iv(this.addr, s), ht(n, s)); + for (let a = 0; a !== r; ++a) + t.setTexture2DArray(e[a] || fc, s[a]); +} +function sg(i) { + switch (i) { + case 5126: + return km; + case 35664: + return Gm; + case 35665: + return Hm; + case 35666: + return Vm; + case 35674: + return Wm; + case 35675: + return Xm; + case 35676: + return qm; + case 5124: + case 35670: + return Ym; + case 35667: + case 35671: + return jm; + case 35668: + case 35672: + return Km; + case 35669: + case 35673: + return Qm; + case 5125: + return Zm; + case 36294: + return Jm; + case 36295: + return $m; + case 36296: + return eg; + case 35678: + case 36198: + case 36298: + case 36306: + case 35682: + return tg; + case 35679: + case 36299: + case 36307: + return ng; + case 35680: + case 36300: + case 36308: + case 36293: + return ig; + case 36289: + case 36303: + case 36311: + case 36292: + return rg; + } +} +class og { + constructor(e, t, n) { + this.id = e, this.addr = n, this.cache = [], this.type = t.type, this.setValue = zm(t.type); + } +} +class ag { + constructor(e, t, n) { + this.id = e, this.addr = n, this.cache = [], this.type = t.type, this.size = t.size, this.setValue = sg(t.type); + } +} +class lg { + constructor(e) { + this.id = e, this.seq = [], this.map = {}; + } + setValue(e, t, n) { + const r = this.seq; + for (let s = 0, a = r.length; s !== a; ++s) { + const o = r[s]; + o.setValue(e, t[o.id], n); + } + } +} +const Ys = /(\w+)(\])?(\[|\.)?/g; +function Ya(i, e) { + i.seq.push(e), i.map[e.id] = e; +} +function cg(i, e, t) { + const n = i.name, r = n.length; + for (Ys.lastIndex = 0; ; ) { + const s = Ys.exec(n), a = Ys.lastIndex; + let o = s[1]; + const l = s[2] === "]", c = s[3]; + if (l && (o = o | 0), c === void 0 || c === "[" && a + 2 === r) { + Ya(t, c === void 0 ? new og(o, i, e) : new ag(o, i, e)); + break; + } else { + let f = t.map[o]; + f === void 0 && (f = new lg(o), Ya(t, f)), t = f; + } + } +} +class Vr { + constructor(e, t) { + this.seq = [], this.map = {}; + const n = e.getProgramParameter(t, e.ACTIVE_UNIFORMS); + for (let r = 0; r < n; ++r) { + const s = e.getActiveUniform(t, r), a = e.getUniformLocation(t, s.name); + cg(s, a, this); + } + } + setValue(e, t, n, r) { + const s = this.map[t]; + s !== void 0 && s.setValue(e, n, r); + } + setOptional(e, t, n) { + const r = t[n]; + r !== void 0 && this.setValue(e, n, r); + } + static upload(e, t, n, r) { + for (let s = 0, a = t.length; s !== a; ++s) { + const o = t[s], l = n[o.id]; + l.needsUpdate !== !1 && o.setValue(e, l.value, r); + } + } + static seqWithValue(e, t) { + const n = []; + for (let r = 0, s = e.length; r !== s; ++r) { + const a = e[r]; + a.id in t && n.push(a); + } + return n; + } +} +function ja(i, e, t) { + const n = i.createShader(e); + return i.shaderSource(n, t), i.compileShader(n), n; +} +const ug = 37297; +let fg = 0; +function hg(i, e) { + const t = i.split(` +`), n = [], r = Math.max(e - 6, 0), s = Math.min(e + 6, t.length); + for (let a = r; a < s; a++) { + const o = a + 1; + n.push(`${o === e ? ">" : " "} ${o}: ${t[a]}`); + } + return n.join(` +`); +} +function dg(i) { + const e = Ze.getPrimaries(Ze.workingColorSpace), t = Ze.getPrimaries(i); + let n; + switch (e === t ? n = "" : e === Kr && t === jr ? n = "LinearDisplayP3ToLinearSRGB" : e === jr && t === Kr && (n = "LinearSRGBToLinearDisplayP3"), i) { + case Wn: + case os: + return [n, "LinearTransferOETF"]; + case sn: + case go: + return [n, "sRGBTransferOETF"]; + default: + return console.warn("THREE.WebGLProgram: Unsupported color space:", i), [n, "LinearTransferOETF"]; + } +} +function Ka(i, e, t) { + const n = i.getShaderParameter(e, i.COMPILE_STATUS), r = i.getShaderInfoLog(e).trim(); + if (n && r === "") + return ""; + const s = /ERROR: 0:(\d+)/.exec(r); + if (s) { + const a = parseInt(s[1]); + return t.toUpperCase() + ` + +` + r + ` + +` + hg(i.getShaderSource(e), a); + } else + return r; +} +function pg(i, e) { + const t = dg(e); + return `vec4 ${i}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`; +} +function mg(i, e) { + let t; + switch (e) { + case of: + t = "Linear"; + break; + case af: + t = "Reinhard"; + break; + case lf: + t = "OptimizedCineon"; + break; + case cf: + t = "ACESFilmic"; + break; + case ff: + t = "AgX"; + break; + case hf: + t = "Neutral"; + break; + case uf: + t = "Custom"; + break; + default: + console.warn("THREE.WebGLProgram: Unsupported toneMapping:", e), t = "Linear"; + } + return "vec3 " + i + "( vec3 color ) { return " + t + "ToneMapping( color ); }"; +} +function gg(i) { + return [ + i.extensionDerivatives || i.envMapCubeUVHeight || i.bumpMap || i.normalMapTangentSpace || i.clearcoatNormalMap || i.flatShading || i.alphaToCoverage || i.shaderID === "physical" ? "#extension GL_OES_standard_derivatives : enable" : "", + (i.extensionFragDepth || i.logarithmicDepthBuffer) && i.rendererExtensionFragDepth ? "#extension GL_EXT_frag_depth : enable" : "", + i.extensionDrawBuffers && i.rendererExtensionDrawBuffers ? "#extension GL_EXT_draw_buffers : require" : "", + (i.extensionShaderTextureLOD || i.envMap || i.transmission) && i.rendererExtensionShaderTextureLod ? "#extension GL_EXT_shader_texture_lod : enable" : "" + ].filter(Fi).join(` +`); +} +function _g(i) { + return [ + i.extensionClipCullDistance ? "#extension GL_ANGLE_clip_cull_distance : require" : "", + i.extensionMultiDraw ? "#extension GL_ANGLE_multi_draw : require" : "" + ].filter(Fi).join(` +`); +} +function vg(i) { + const e = []; + for (const t in i) { + const n = i[t]; + n !== !1 && e.push("#define " + t + " " + n); + } + return e.join(` +`); +} +function xg(i, e) { + const t = {}, n = i.getProgramParameter(e, i.ACTIVE_ATTRIBUTES); + for (let r = 0; r < n; r++) { + const s = i.getActiveAttrib(e, r), a = s.name; + let o = 1; + s.type === i.FLOAT_MAT2 && (o = 2), s.type === i.FLOAT_MAT3 && (o = 3), s.type === i.FLOAT_MAT4 && (o = 4), t[a] = { + type: s.type, + location: i.getAttribLocation(e, a), + locationSize: o + }; + } + return t; +} +function Fi(i) { + return i !== ""; +} +function Qa(i, e) { + const t = e.numSpotLightShadows + e.numSpotLightMaps - e.numSpotLightShadowsWithMaps; + return i.replace(/NUM_DIR_LIGHTS/g, e.numDirLights).replace(/NUM_SPOT_LIGHTS/g, e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g, e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g, t).replace(/NUM_RECT_AREA_LIGHTS/g, e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g, e.numPointLights).replace(/NUM_HEMI_LIGHTS/g, e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g, e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g, e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g, e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g, e.numPointLightShadows); +} +function Za(i, e) { + return i.replace(/NUM_CLIPPING_PLANES/g, e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g, e.numClippingPlanes - e.numClipIntersection); +} +const Sg = /^[ \t]*#include +<([\w\d./]+)>/gm; +function ao(i) { + return i.replace(Sg, yg); +} +const Mg = /* @__PURE__ */ new Map([ + ["encodings_fragment", "colorspace_fragment"], + // @deprecated, r154 + ["encodings_pars_fragment", "colorspace_pars_fragment"], + // @deprecated, r154 + ["output_fragment", "opaque_fragment"] + // @deprecated, r154 +]); +function yg(i, e) { + let t = We[e]; + if (t === void 0) { + const n = Mg.get(e); + if (n !== void 0) + t = We[n], console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.', e, n); + else + throw new Error("Can not resolve #include <" + e + ">"); + } + return ao(t); +} +const Ag = /#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g; +function Ja(i) { + return i.replace(Ag, Eg); +} +function Eg(i, e, t, n) { + let r = ""; + for (let s = parseInt(e); s < parseInt(t); s++) + r += n.replace(/\[\s*i\s*\]/g, "[ " + s + " ]").replace(/UNROLLED_LOOP_INDEX/g, s); + return r; +} +function $a(i) { + let e = `precision ${i.precision} float; + precision ${i.precision} int; + precision ${i.precision} sampler2D; + precision ${i.precision} samplerCube; + `; + return i.isWebGL2 && (e += `precision ${i.precision} sampler3D; + precision ${i.precision} sampler2DArray; + precision ${i.precision} sampler2DShadow; + precision ${i.precision} samplerCubeShadow; + precision ${i.precision} sampler2DArrayShadow; + precision ${i.precision} isampler2D; + precision ${i.precision} isampler3D; + precision ${i.precision} isamplerCube; + precision ${i.precision} isampler2DArray; + precision ${i.precision} usampler2D; + precision ${i.precision} usampler3D; + precision ${i.precision} usamplerCube; + precision ${i.precision} usampler2DArray; + `), i.precision === "highp" ? e += ` +#define HIGH_PRECISION` : i.precision === "mediump" ? e += ` +#define MEDIUM_PRECISION` : i.precision === "lowp" && (e += ` +#define LOW_PRECISION`), e; +} +function bg(i) { + let e = "SHADOWMAP_TYPE_BASIC"; + return i.shadowMapType === Bl ? e = "SHADOWMAP_TYPE_PCF" : i.shadowMapType === Uu ? e = "SHADOWMAP_TYPE_PCF_SOFT" : i.shadowMapType === xn && (e = "SHADOWMAP_TYPE_VSM"), e; +} +function Tg(i) { + let e = "ENVMAP_TYPE_CUBE"; + if (i.envMap) + switch (i.envMapMode) { + case zi: + case ki: + e = "ENVMAP_TYPE_CUBE"; + break; + case ss: + e = "ENVMAP_TYPE_CUBE_UV"; + break; + } + return e; +} +function wg(i) { + let e = "ENVMAP_MODE_REFLECTION"; + if (i.envMap) + switch (i.envMapMode) { + case ki: + e = "ENVMAP_MODE_REFRACTION"; + break; + } + return e; +} +function Cg(i) { + let e = "ENVMAP_BLENDING_NONE"; + if (i.envMap) + switch (i.combine) { + case zl: + e = "ENVMAP_BLENDING_MULTIPLY"; + break; + case rf: + e = "ENVMAP_BLENDING_MIX"; + break; + case sf: + e = "ENVMAP_BLENDING_ADD"; + break; + } + return e; +} +function Rg(i) { + const e = i.envMapCubeUVHeight; + if (e === null) + return null; + const t = Math.log2(e) - 2, n = 1 / e; + return { texelWidth: 1 / (3 * Math.max(Math.pow(2, t), 7 * 16)), texelHeight: n, maxMip: t }; +} +function Pg(i, e, t, n) { + const r = i.getContext(), s = t.defines; + let a = t.vertexShader, o = t.fragmentShader; + const l = bg(t), c = Tg(t), u = wg(t), f = Cg(t), h = Rg(t), p = t.isWebGL2 ? "" : gg(t), g = _g(t), v = vg(s), m = r.createProgram(); + let d, M, _ = t.glslVersion ? "#version " + t.glslVersion + ` +` : ""; + t.isRawShaderMaterial ? (d = [ + "#define SHADER_TYPE " + t.shaderType, + "#define SHADER_NAME " + t.shaderName, + v + ].filter(Fi).join(` +`), d.length > 0 && (d += ` +`), M = [ + p, + "#define SHADER_TYPE " + t.shaderType, + "#define SHADER_NAME " + t.shaderName, + v + ].filter(Fi).join(` +`), M.length > 0 && (M += ` +`)) : (d = [ + $a(t), + "#define SHADER_TYPE " + t.shaderType, + "#define SHADER_NAME " + t.shaderName, + v, + t.extensionClipCullDistance ? "#define USE_CLIP_DISTANCE" : "", + t.batching ? "#define USE_BATCHING" : "", + t.instancing ? "#define USE_INSTANCING" : "", + t.instancingColor ? "#define USE_INSTANCING_COLOR" : "", + t.instancingMorph ? "#define USE_INSTANCING_MORPH" : "", + t.useFog && t.fog ? "#define USE_FOG" : "", + t.useFog && t.fogExp2 ? "#define FOG_EXP2" : "", + t.map ? "#define USE_MAP" : "", + t.envMap ? "#define USE_ENVMAP" : "", + t.envMap ? "#define " + u : "", + t.lightMap ? "#define USE_LIGHTMAP" : "", + t.aoMap ? "#define USE_AOMAP" : "", + t.bumpMap ? "#define USE_BUMPMAP" : "", + t.normalMap ? "#define USE_NORMALMAP" : "", + t.normalMapObjectSpace ? "#define USE_NORMALMAP_OBJECTSPACE" : "", + t.normalMapTangentSpace ? "#define USE_NORMALMAP_TANGENTSPACE" : "", + t.displacementMap ? "#define USE_DISPLACEMENTMAP" : "", + t.emissiveMap ? "#define USE_EMISSIVEMAP" : "", + t.anisotropy ? "#define USE_ANISOTROPY" : "", + t.anisotropyMap ? "#define USE_ANISOTROPYMAP" : "", + t.clearcoatMap ? "#define USE_CLEARCOATMAP" : "", + t.clearcoatRoughnessMap ? "#define USE_CLEARCOAT_ROUGHNESSMAP" : "", + t.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "", + t.iridescenceMap ? "#define USE_IRIDESCENCEMAP" : "", + t.iridescenceThicknessMap ? "#define USE_IRIDESCENCE_THICKNESSMAP" : "", + t.specularMap ? "#define USE_SPECULARMAP" : "", + t.specularColorMap ? "#define USE_SPECULAR_COLORMAP" : "", + t.specularIntensityMap ? "#define USE_SPECULAR_INTENSITYMAP" : "", + t.roughnessMap ? "#define USE_ROUGHNESSMAP" : "", + t.metalnessMap ? "#define USE_METALNESSMAP" : "", + t.alphaMap ? "#define USE_ALPHAMAP" : "", + t.alphaHash ? "#define USE_ALPHAHASH" : "", + t.transmission ? "#define USE_TRANSMISSION" : "", + t.transmissionMap ? "#define USE_TRANSMISSIONMAP" : "", + t.thicknessMap ? "#define USE_THICKNESSMAP" : "", + t.sheenColorMap ? "#define USE_SHEEN_COLORMAP" : "", + t.sheenRoughnessMap ? "#define USE_SHEEN_ROUGHNESSMAP" : "", + // + t.mapUv ? "#define MAP_UV " + t.mapUv : "", + t.alphaMapUv ? "#define ALPHAMAP_UV " + t.alphaMapUv : "", + t.lightMapUv ? "#define LIGHTMAP_UV " + t.lightMapUv : "", + t.aoMapUv ? "#define AOMAP_UV " + t.aoMapUv : "", + t.emissiveMapUv ? "#define EMISSIVEMAP_UV " + t.emissiveMapUv : "", + t.bumpMapUv ? "#define BUMPMAP_UV " + t.bumpMapUv : "", + t.normalMapUv ? "#define NORMALMAP_UV " + t.normalMapUv : "", + t.displacementMapUv ? "#define DISPLACEMENTMAP_UV " + t.displacementMapUv : "", + t.metalnessMapUv ? "#define METALNESSMAP_UV " + t.metalnessMapUv : "", + t.roughnessMapUv ? "#define ROUGHNESSMAP_UV " + t.roughnessMapUv : "", + t.anisotropyMapUv ? "#define ANISOTROPYMAP_UV " + t.anisotropyMapUv : "", + t.clearcoatMapUv ? "#define CLEARCOATMAP_UV " + t.clearcoatMapUv : "", + t.clearcoatNormalMapUv ? "#define CLEARCOAT_NORMALMAP_UV " + t.clearcoatNormalMapUv : "", + t.clearcoatRoughnessMapUv ? "#define CLEARCOAT_ROUGHNESSMAP_UV " + t.clearcoatRoughnessMapUv : "", + t.iridescenceMapUv ? "#define IRIDESCENCEMAP_UV " + t.iridescenceMapUv : "", + t.iridescenceThicknessMapUv ? "#define IRIDESCENCE_THICKNESSMAP_UV " + t.iridescenceThicknessMapUv : "", + t.sheenColorMapUv ? "#define SHEEN_COLORMAP_UV " + t.sheenColorMapUv : "", + t.sheenRoughnessMapUv ? "#define SHEEN_ROUGHNESSMAP_UV " + t.sheenRoughnessMapUv : "", + t.specularMapUv ? "#define SPECULARMAP_UV " + t.specularMapUv : "", + t.specularColorMapUv ? "#define SPECULAR_COLORMAP_UV " + t.specularColorMapUv : "", + t.specularIntensityMapUv ? "#define SPECULAR_INTENSITYMAP_UV " + t.specularIntensityMapUv : "", + t.transmissionMapUv ? "#define TRANSMISSIONMAP_UV " + t.transmissionMapUv : "", + t.thicknessMapUv ? "#define THICKNESSMAP_UV " + t.thicknessMapUv : "", + // + t.vertexTangents && t.flatShading === !1 ? "#define USE_TANGENT" : "", + t.vertexColors ? "#define USE_COLOR" : "", + t.vertexAlphas ? "#define USE_COLOR_ALPHA" : "", + t.vertexUv1s ? "#define USE_UV1" : "", + t.vertexUv2s ? "#define USE_UV2" : "", + t.vertexUv3s ? "#define USE_UV3" : "", + t.pointsUvs ? "#define USE_POINTS_UV" : "", + t.flatShading ? "#define FLAT_SHADED" : "", + t.skinning ? "#define USE_SKINNING" : "", + t.morphTargets ? "#define USE_MORPHTARGETS" : "", + t.morphNormals && t.flatShading === !1 ? "#define USE_MORPHNORMALS" : "", + t.morphColors && t.isWebGL2 ? "#define USE_MORPHCOLORS" : "", + t.morphTargetsCount > 0 && t.isWebGL2 ? "#define MORPHTARGETS_TEXTURE" : "", + t.morphTargetsCount > 0 && t.isWebGL2 ? "#define MORPHTARGETS_TEXTURE_STRIDE " + t.morphTextureStride : "", + t.morphTargetsCount > 0 && t.isWebGL2 ? "#define MORPHTARGETS_COUNT " + t.morphTargetsCount : "", + t.doubleSided ? "#define DOUBLE_SIDED" : "", + t.flipSided ? "#define FLIP_SIDED" : "", + t.shadowMapEnabled ? "#define USE_SHADOWMAP" : "", + t.shadowMapEnabled ? "#define " + l : "", + t.sizeAttenuation ? "#define USE_SIZEATTENUATION" : "", + t.numLightProbes > 0 ? "#define USE_LIGHT_PROBES" : "", + t.useLegacyLights ? "#define LEGACY_LIGHTS" : "", + t.logarithmicDepthBuffer ? "#define USE_LOGDEPTHBUF" : "", + t.logarithmicDepthBuffer && t.rendererExtensionFragDepth ? "#define USE_LOGDEPTHBUF_EXT" : "", + "uniform mat4 modelMatrix;", + "uniform mat4 modelViewMatrix;", + "uniform mat4 projectionMatrix;", + "uniform mat4 viewMatrix;", + "uniform mat3 normalMatrix;", + "uniform vec3 cameraPosition;", + "uniform bool isOrthographic;", + "#ifdef USE_INSTANCING", + " attribute mat4 instanceMatrix;", + "#endif", + "#ifdef USE_INSTANCING_COLOR", + " attribute vec3 instanceColor;", + "#endif", + "#ifdef USE_INSTANCING_MORPH", + " uniform sampler2D morphTexture;", + "#endif", + "attribute vec3 position;", + "attribute vec3 normal;", + "attribute vec2 uv;", + "#ifdef USE_UV1", + " attribute vec2 uv1;", + "#endif", + "#ifdef USE_UV2", + " attribute vec2 uv2;", + "#endif", + "#ifdef USE_UV3", + " attribute vec2 uv3;", + "#endif", + "#ifdef USE_TANGENT", + " attribute vec4 tangent;", + "#endif", + "#if defined( USE_COLOR_ALPHA )", + " attribute vec4 color;", + "#elif defined( USE_COLOR )", + " attribute vec3 color;", + "#endif", + "#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )", + " attribute vec3 morphTarget0;", + " attribute vec3 morphTarget1;", + " attribute vec3 morphTarget2;", + " attribute vec3 morphTarget3;", + " #ifdef USE_MORPHNORMALS", + " attribute vec3 morphNormal0;", + " attribute vec3 morphNormal1;", + " attribute vec3 morphNormal2;", + " attribute vec3 morphNormal3;", + " #else", + " attribute vec3 morphTarget4;", + " attribute vec3 morphTarget5;", + " attribute vec3 morphTarget6;", + " attribute vec3 morphTarget7;", + " #endif", + "#endif", + "#ifdef USE_SKINNING", + " attribute vec4 skinIndex;", + " attribute vec4 skinWeight;", + "#endif", + ` +` + ].filter(Fi).join(` +`), M = [ + p, + $a(t), + "#define SHADER_TYPE " + t.shaderType, + "#define SHADER_NAME " + t.shaderName, + v, + t.useFog && t.fog ? "#define USE_FOG" : "", + t.useFog && t.fogExp2 ? "#define FOG_EXP2" : "", + t.alphaToCoverage ? "#define ALPHA_TO_COVERAGE" : "", + t.map ? "#define USE_MAP" : "", + t.matcap ? "#define USE_MATCAP" : "", + t.envMap ? "#define USE_ENVMAP" : "", + t.envMap ? "#define " + c : "", + t.envMap ? "#define " + u : "", + t.envMap ? "#define " + f : "", + h ? "#define CUBEUV_TEXEL_WIDTH " + h.texelWidth : "", + h ? "#define CUBEUV_TEXEL_HEIGHT " + h.texelHeight : "", + h ? "#define CUBEUV_MAX_MIP " + h.maxMip + ".0" : "", + t.lightMap ? "#define USE_LIGHTMAP" : "", + t.aoMap ? "#define USE_AOMAP" : "", + t.bumpMap ? "#define USE_BUMPMAP" : "", + t.normalMap ? "#define USE_NORMALMAP" : "", + t.normalMapObjectSpace ? "#define USE_NORMALMAP_OBJECTSPACE" : "", + t.normalMapTangentSpace ? "#define USE_NORMALMAP_TANGENTSPACE" : "", + t.emissiveMap ? "#define USE_EMISSIVEMAP" : "", + t.anisotropy ? "#define USE_ANISOTROPY" : "", + t.anisotropyMap ? "#define USE_ANISOTROPYMAP" : "", + t.clearcoat ? "#define USE_CLEARCOAT" : "", + t.clearcoatMap ? "#define USE_CLEARCOATMAP" : "", + t.clearcoatRoughnessMap ? "#define USE_CLEARCOAT_ROUGHNESSMAP" : "", + t.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "", + t.iridescence ? "#define USE_IRIDESCENCE" : "", + t.iridescenceMap ? "#define USE_IRIDESCENCEMAP" : "", + t.iridescenceThicknessMap ? "#define USE_IRIDESCENCE_THICKNESSMAP" : "", + t.specularMap ? "#define USE_SPECULARMAP" : "", + t.specularColorMap ? "#define USE_SPECULAR_COLORMAP" : "", + t.specularIntensityMap ? "#define USE_SPECULAR_INTENSITYMAP" : "", + t.roughnessMap ? "#define USE_ROUGHNESSMAP" : "", + t.metalnessMap ? "#define USE_METALNESSMAP" : "", + t.alphaMap ? "#define USE_ALPHAMAP" : "", + t.alphaTest ? "#define USE_ALPHATEST" : "", + t.alphaHash ? "#define USE_ALPHAHASH" : "", + t.sheen ? "#define USE_SHEEN" : "", + t.sheenColorMap ? "#define USE_SHEEN_COLORMAP" : "", + t.sheenRoughnessMap ? "#define USE_SHEEN_ROUGHNESSMAP" : "", + t.transmission ? "#define USE_TRANSMISSION" : "", + t.transmissionMap ? "#define USE_TRANSMISSIONMAP" : "", + t.thicknessMap ? "#define USE_THICKNESSMAP" : "", + t.vertexTangents && t.flatShading === !1 ? "#define USE_TANGENT" : "", + t.vertexColors || t.instancingColor ? "#define USE_COLOR" : "", + t.vertexAlphas ? "#define USE_COLOR_ALPHA" : "", + t.vertexUv1s ? "#define USE_UV1" : "", + t.vertexUv2s ? "#define USE_UV2" : "", + t.vertexUv3s ? "#define USE_UV3" : "", + t.pointsUvs ? "#define USE_POINTS_UV" : "", + t.gradientMap ? "#define USE_GRADIENTMAP" : "", + t.flatShading ? "#define FLAT_SHADED" : "", + t.doubleSided ? "#define DOUBLE_SIDED" : "", + t.flipSided ? "#define FLIP_SIDED" : "", + t.shadowMapEnabled ? "#define USE_SHADOWMAP" : "", + t.shadowMapEnabled ? "#define " + l : "", + t.premultipliedAlpha ? "#define PREMULTIPLIED_ALPHA" : "", + t.numLightProbes > 0 ? "#define USE_LIGHT_PROBES" : "", + t.useLegacyLights ? "#define LEGACY_LIGHTS" : "", + t.decodeVideoTexture ? "#define DECODE_VIDEO_TEXTURE" : "", + t.logarithmicDepthBuffer ? "#define USE_LOGDEPTHBUF" : "", + t.logarithmicDepthBuffer && t.rendererExtensionFragDepth ? "#define USE_LOGDEPTHBUF_EXT" : "", + "uniform mat4 viewMatrix;", + "uniform vec3 cameraPosition;", + "uniform bool isOrthographic;", + t.toneMapping !== kn ? "#define TONE_MAPPING" : "", + t.toneMapping !== kn ? We.tonemapping_pars_fragment : "", + // this code is required here because it is used by the toneMapping() function defined below + t.toneMapping !== kn ? mg("toneMapping", t.toneMapping) : "", + t.dithering ? "#define DITHERING" : "", + t.opaque ? "#define OPAQUE" : "", + We.colorspace_pars_fragment, + // this code is required here because it is used by the various encoding/decoding function defined below + pg("linearToOutputTexel", t.outputColorSpace), + t.useDepthPacking ? "#define DEPTH_PACKING " + t.depthPacking : "", + ` +` + ].filter(Fi).join(` +`)), a = ao(a), a = Qa(a, t), a = Za(a, t), o = ao(o), o = Qa(o, t), o = Za(o, t), a = Ja(a), o = Ja(o), t.isWebGL2 && t.isRawShaderMaterial !== !0 && (_ = `#version 300 es +`, d = [ + g, + "precision mediump sampler2DArray;", + "#define attribute in", + "#define varying out", + "#define texture2D texture" + ].join(` +`) + ` +` + d, M = [ + "precision mediump sampler2DArray;", + "#define varying in", + t.glslVersion === ma ? "" : "layout(location = 0) out highp vec4 pc_fragColor;", + t.glslVersion === ma ? "" : "#define gl_FragColor pc_fragColor", + "#define gl_FragDepthEXT gl_FragDepth", + "#define texture2D texture", + "#define textureCube texture", + "#define texture2DProj textureProj", + "#define texture2DLodEXT textureLod", + "#define texture2DProjLodEXT textureProjLod", + "#define textureCubeLodEXT textureLod", + "#define texture2DGradEXT textureGrad", + "#define texture2DProjGradEXT textureProjGrad", + "#define textureCubeGradEXT textureGrad" + ].join(` +`) + ` +` + M); + const A = _ + d + a, C = _ + M + o, E = ja(r, r.VERTEX_SHADER, A), b = ja(r, r.FRAGMENT_SHADER, C); + r.attachShader(m, E), r.attachShader(m, b), t.index0AttributeName !== void 0 ? r.bindAttribLocation(m, 0, t.index0AttributeName) : t.morphTargets === !0 && r.bindAttribLocation(m, 0, "position"), r.linkProgram(m); + function I(Y) { + if (i.debug.checkShaderErrors) { + const K = r.getProgramInfoLog(m).trim(), L = r.getShaderInfoLog(E).trim(), N = r.getShaderInfoLog(b).trim(); + let O = !0, B = !0; + if (r.getProgramParameter(m, r.LINK_STATUS) === !1) + if (O = !1, typeof i.debug.onShaderError == "function") + i.debug.onShaderError(r, m, E, b); + else { + const j = Ka(r, E, "vertex"), q = Ka(r, b, "fragment"); + console.error( + "THREE.WebGLProgram: Shader Error " + r.getError() + " - VALIDATE_STATUS " + r.getProgramParameter(m, r.VALIDATE_STATUS) + ` + +Material Name: ` + Y.name + ` +Material Type: ` + Y.type + ` + +Program Info Log: ` + K + ` +` + j + ` +` + q + ); + } + else + K !== "" ? console.warn("THREE.WebGLProgram: Program Info Log:", K) : (L === "" || N === "") && (B = !1); + B && (Y.diagnostics = { + runnable: O, + programLog: K, + vertexShader: { + log: L, + prefix: d + }, + fragmentShader: { + log: N, + prefix: M + } + }); + } + r.deleteShader(E), r.deleteShader(b), W = new Vr(r, m), S = xg(r, m); + } + let W; + this.getUniforms = function() { + return W === void 0 && I(this), W; + }; + let S; + this.getAttributes = function() { + return S === void 0 && I(this), S; + }; + let T = t.rendererExtensionParallelShaderCompile === !1; + return this.isReady = function() { + return T === !1 && (T = r.getProgramParameter(m, ug)), T; + }, this.destroy = function() { + n.releaseStatesOfProgram(this), r.deleteProgram(m), this.program = void 0; + }, this.type = t.shaderType, this.name = t.shaderName, this.id = fg++, this.cacheKey = e, this.usedTimes = 1, this.program = m, this.vertexShader = E, this.fragmentShader = b, this; +} +let Lg = 0; +class Dg { + constructor() { + this.shaderCache = /* @__PURE__ */ new Map(), this.materialCache = /* @__PURE__ */ new Map(); + } + update(e) { + const t = e.vertexShader, n = e.fragmentShader, r = this._getShaderStage(t), s = this._getShaderStage(n), a = this._getShaderCacheForMaterial(e); + return a.has(r) === !1 && (a.add(r), r.usedTimes++), a.has(s) === !1 && (a.add(s), s.usedTimes++), this; + } + remove(e) { + const t = this.materialCache.get(e); + for (const n of t) + n.usedTimes--, n.usedTimes === 0 && this.shaderCache.delete(n.code); + return this.materialCache.delete(e), this; + } + getVertexShaderID(e) { + return this._getShaderStage(e.vertexShader).id; + } + getFragmentShaderID(e) { + return this._getShaderStage(e.fragmentShader).id; + } + dispose() { + this.shaderCache.clear(), this.materialCache.clear(); + } + _getShaderCacheForMaterial(e) { + const t = this.materialCache; + let n = t.get(e); + return n === void 0 && (n = /* @__PURE__ */ new Set(), t.set(e, n)), n; + } + _getShaderStage(e) { + const t = this.shaderCache; + let n = t.get(e); + return n === void 0 && (n = new Ig(e), t.set(e, n)), n; + } +} +class Ig { + constructor(e) { + this.id = Lg++, this.code = e, this.usedTimes = 0; + } +} +function Ug(i, e, t, n, r, s, a) { + const o = new $l(), l = new Dg(), c = /* @__PURE__ */ new Set(), u = [], f = r.isWebGL2, h = r.logarithmicDepthBuffer, p = r.vertexTextures; + let g = r.precision; + const v = { + MeshDepthMaterial: "depth", + MeshDistanceMaterial: "distanceRGBA", + MeshNormalMaterial: "normal", + MeshBasicMaterial: "basic", + MeshLambertMaterial: "lambert", + MeshPhongMaterial: "phong", + MeshToonMaterial: "toon", + MeshStandardMaterial: "physical", + MeshPhysicalMaterial: "physical", + MeshMatcapMaterial: "matcap", + LineBasicMaterial: "basic", + LineDashedMaterial: "dashed", + PointsMaterial: "points", + ShadowMaterial: "shadow", + SpriteMaterial: "sprite" + }; + function m(S) { + return c.add(S), S === 0 ? "uv" : `uv${S}`; + } + function d(S, T, Y, K, L) { + const N = K.fog, O = L.geometry, B = S.isMeshStandardMaterial ? K.environment : null, j = (S.isMeshStandardMaterial ? t : e).get(S.envMap || B), q = j && j.mapping === ss ? j.image.height : null, J = v[S.type]; + S.precision !== null && (g = r.getMaxPrecision(S.precision), g !== S.precision && console.warn("THREE.WebGLProgram.getParameters:", S.precision, "not supported, using", g, "instead.")); + const ne = O.morphAttributes.position || O.morphAttributes.normal || O.morphAttributes.color, ue = ne !== void 0 ? ne.length : 0; + let Z = 0; + O.morphAttributes.position !== void 0 && (Z = 1), O.morphAttributes.normal !== void 0 && (Z = 2), O.morphAttributes.color !== void 0 && (Z = 3); + let H, ee, pe, Te; + if (J) { + const et = on[J]; + H = et.vertexShader, ee = et.fragmentShader; + } else + H = S.vertexShader, ee = S.fragmentShader, l.update(S), pe = l.getVertexShaderID(S), Te = l.getFragmentShaderID(S); + const xe = i.getRenderTarget(), ge = L.isInstancedMesh === !0, Ke = L.isBatchedMesh === !0, we = !!S.map, F = !!S.matcap, lt = !!j, Me = !!S.aoMap, Ne = !!S.lightMap, ye = !!S.bumpMap, qe = !!S.normalMap, Ie = !!S.displacementMap, Be = !!S.emissiveMap, Je = !!S.metalnessMap, w = !!S.roughnessMap, x = S.anisotropy > 0, X = S.clearcoat > 0, Q = S.iridescence > 0, te = S.sheen > 0, $ = S.transmission > 0, Le = x && !!S.anisotropyMap, Ae = X && !!S.clearcoatMap, se = X && !!S.clearcoatNormalMap, ce = X && !!S.clearcoatRoughnessMap, Re = Q && !!S.iridescenceMap, R = Q && !!S.iridescenceThicknessMap, le = te && !!S.sheenColorMap, ve = te && !!S.sheenRoughnessMap, fe = !!S.specularMap, he = !!S.specularColorMap, _e = !!S.specularIntensityMap, De = $ && !!S.transmissionMap, Ue = $ && !!S.thicknessMap, $e = !!S.gradientMap, D = !!S.alphaMap, re = S.alphaTest > 0, z = !!S.alphaHash, ie = !!S.extensions; + let ae = kn; + S.toneMapped && (xe === null || xe.isXRRenderTarget === !0) && (ae = i.toneMapping); + const Oe = { + isWebGL2: f, + shaderID: J, + shaderType: S.type, + shaderName: S.name, + vertexShader: H, + fragmentShader: ee, + defines: S.defines, + customVertexShaderID: pe, + customFragmentShaderID: Te, + isRawShaderMaterial: S.isRawShaderMaterial === !0, + glslVersion: S.glslVersion, + precision: g, + batching: Ke, + instancing: ge, + instancingColor: ge && L.instanceColor !== null, + instancingMorph: ge && L.morphTexture !== null, + supportsVertexTextures: p, + outputColorSpace: xe === null ? i.outputColorSpace : xe.isXRRenderTarget === !0 ? xe.texture.colorSpace : Wn, + alphaToCoverage: !!S.alphaToCoverage, + map: we, + matcap: F, + envMap: lt, + envMapMode: lt && j.mapping, + envMapCubeUVHeight: q, + aoMap: Me, + lightMap: Ne, + bumpMap: ye, + normalMap: qe, + displacementMap: p && Ie, + emissiveMap: Be, + normalMapObjectSpace: qe && S.normalMapType === Af, + normalMapTangentSpace: qe && S.normalMapType === yf, + metalnessMap: Je, + roughnessMap: w, + anisotropy: x, + anisotropyMap: Le, + clearcoat: X, + clearcoatMap: Ae, + clearcoatNormalMap: se, + clearcoatRoughnessMap: ce, + iridescence: Q, + iridescenceMap: Re, + iridescenceThicknessMap: R, + sheen: te, + sheenColorMap: le, + sheenRoughnessMap: ve, + specularMap: fe, + specularColorMap: he, + specularIntensityMap: _e, + transmission: $, + transmissionMap: De, + thicknessMap: Ue, + gradientMap: $e, + opaque: S.transparent === !1 && S.blending === ri && S.alphaToCoverage === !1, + alphaMap: D, + alphaTest: re, + alphaHash: z, + combine: S.combine, + // + mapUv: we && m(S.map.channel), + aoMapUv: Me && m(S.aoMap.channel), + lightMapUv: Ne && m(S.lightMap.channel), + bumpMapUv: ye && m(S.bumpMap.channel), + normalMapUv: qe && m(S.normalMap.channel), + displacementMapUv: Ie && m(S.displacementMap.channel), + emissiveMapUv: Be && m(S.emissiveMap.channel), + metalnessMapUv: Je && m(S.metalnessMap.channel), + roughnessMapUv: w && m(S.roughnessMap.channel), + anisotropyMapUv: Le && m(S.anisotropyMap.channel), + clearcoatMapUv: Ae && m(S.clearcoatMap.channel), + clearcoatNormalMapUv: se && m(S.clearcoatNormalMap.channel), + clearcoatRoughnessMapUv: ce && m(S.clearcoatRoughnessMap.channel), + iridescenceMapUv: Re && m(S.iridescenceMap.channel), + iridescenceThicknessMapUv: R && m(S.iridescenceThicknessMap.channel), + sheenColorMapUv: le && m(S.sheenColorMap.channel), + sheenRoughnessMapUv: ve && m(S.sheenRoughnessMap.channel), + specularMapUv: fe && m(S.specularMap.channel), + specularColorMapUv: he && m(S.specularColorMap.channel), + specularIntensityMapUv: _e && m(S.specularIntensityMap.channel), + transmissionMapUv: De && m(S.transmissionMap.channel), + thicknessMapUv: Ue && m(S.thicknessMap.channel), + alphaMapUv: D && m(S.alphaMap.channel), + // + vertexTangents: !!O.attributes.tangent && (qe || x), + vertexColors: S.vertexColors, + vertexAlphas: S.vertexColors === !0 && !!O.attributes.color && O.attributes.color.itemSize === 4, + pointsUvs: L.isPoints === !0 && !!O.attributes.uv && (we || D), + fog: !!N, + useFog: S.fog === !0, + fogExp2: !!N && N.isFogExp2, + flatShading: S.flatShading === !0, + sizeAttenuation: S.sizeAttenuation === !0, + logarithmicDepthBuffer: h, + skinning: L.isSkinnedMesh === !0, + morphTargets: O.morphAttributes.position !== void 0, + morphNormals: O.morphAttributes.normal !== void 0, + morphColors: O.morphAttributes.color !== void 0, + morphTargetsCount: ue, + morphTextureStride: Z, + numDirLights: T.directional.length, + numPointLights: T.point.length, + numSpotLights: T.spot.length, + numSpotLightMaps: T.spotLightMap.length, + numRectAreaLights: T.rectArea.length, + numHemiLights: T.hemi.length, + numDirLightShadows: T.directionalShadowMap.length, + numPointLightShadows: T.pointShadowMap.length, + numSpotLightShadows: T.spotShadowMap.length, + numSpotLightShadowsWithMaps: T.numSpotLightShadowsWithMaps, + numLightProbes: T.numLightProbes, + numClippingPlanes: a.numPlanes, + numClipIntersection: a.numIntersection, + dithering: S.dithering, + shadowMapEnabled: i.shadowMap.enabled && Y.length > 0, + shadowMapType: i.shadowMap.type, + toneMapping: ae, + useLegacyLights: i._useLegacyLights, + decodeVideoTexture: we && S.map.isVideoTexture === !0 && Ze.getTransfer(S.map.colorSpace) === nt, + premultipliedAlpha: S.premultipliedAlpha, + doubleSided: S.side === en, + flipSided: S.side === Pt, + useDepthPacking: S.depthPacking >= 0, + depthPacking: S.depthPacking || 0, + index0AttributeName: S.index0AttributeName, + extensionDerivatives: ie && S.extensions.derivatives === !0, + extensionFragDepth: ie && S.extensions.fragDepth === !0, + extensionDrawBuffers: ie && S.extensions.drawBuffers === !0, + extensionShaderTextureLOD: ie && S.extensions.shaderTextureLOD === !0, + extensionClipCullDistance: ie && S.extensions.clipCullDistance === !0 && n.has("WEBGL_clip_cull_distance"), + extensionMultiDraw: ie && S.extensions.multiDraw === !0 && n.has("WEBGL_multi_draw"), + rendererExtensionFragDepth: f || n.has("EXT_frag_depth"), + rendererExtensionDrawBuffers: f || n.has("WEBGL_draw_buffers"), + rendererExtensionShaderTextureLod: f || n.has("EXT_shader_texture_lod"), + rendererExtensionParallelShaderCompile: n.has("KHR_parallel_shader_compile"), + customProgramCacheKey: S.customProgramCacheKey() + }; + return Oe.vertexUv1s = c.has(1), Oe.vertexUv2s = c.has(2), Oe.vertexUv3s = c.has(3), c.clear(), Oe; + } + function M(S) { + const T = []; + if (S.shaderID ? T.push(S.shaderID) : (T.push(S.customVertexShaderID), T.push(S.customFragmentShaderID)), S.defines !== void 0) + for (const Y in S.defines) + T.push(Y), T.push(S.defines[Y]); + return S.isRawShaderMaterial === !1 && (_(T, S), A(T, S), T.push(i.outputColorSpace)), T.push(S.customProgramCacheKey), T.join(); + } + function _(S, T) { + S.push(T.precision), S.push(T.outputColorSpace), S.push(T.envMapMode), S.push(T.envMapCubeUVHeight), S.push(T.mapUv), S.push(T.alphaMapUv), S.push(T.lightMapUv), S.push(T.aoMapUv), S.push(T.bumpMapUv), S.push(T.normalMapUv), S.push(T.displacementMapUv), S.push(T.emissiveMapUv), S.push(T.metalnessMapUv), S.push(T.roughnessMapUv), S.push(T.anisotropyMapUv), S.push(T.clearcoatMapUv), S.push(T.clearcoatNormalMapUv), S.push(T.clearcoatRoughnessMapUv), S.push(T.iridescenceMapUv), S.push(T.iridescenceThicknessMapUv), S.push(T.sheenColorMapUv), S.push(T.sheenRoughnessMapUv), S.push(T.specularMapUv), S.push(T.specularColorMapUv), S.push(T.specularIntensityMapUv), S.push(T.transmissionMapUv), S.push(T.thicknessMapUv), S.push(T.combine), S.push(T.fogExp2), S.push(T.sizeAttenuation), S.push(T.morphTargetsCount), S.push(T.morphAttributeCount), S.push(T.numDirLights), S.push(T.numPointLights), S.push(T.numSpotLights), S.push(T.numSpotLightMaps), S.push(T.numHemiLights), S.push(T.numRectAreaLights), S.push(T.numDirLightShadows), S.push(T.numPointLightShadows), S.push(T.numSpotLightShadows), S.push(T.numSpotLightShadowsWithMaps), S.push(T.numLightProbes), S.push(T.shadowMapType), S.push(T.toneMapping), S.push(T.numClippingPlanes), S.push(T.numClipIntersection), S.push(T.depthPacking); + } + function A(S, T) { + o.disableAll(), T.isWebGL2 && o.enable(0), T.supportsVertexTextures && o.enable(1), T.instancing && o.enable(2), T.instancingColor && o.enable(3), T.instancingMorph && o.enable(4), T.matcap && o.enable(5), T.envMap && o.enable(6), T.normalMapObjectSpace && o.enable(7), T.normalMapTangentSpace && o.enable(8), T.clearcoat && o.enable(9), T.iridescence && o.enable(10), T.alphaTest && o.enable(11), T.vertexColors && o.enable(12), T.vertexAlphas && o.enable(13), T.vertexUv1s && o.enable(14), T.vertexUv2s && o.enable(15), T.vertexUv3s && o.enable(16), T.vertexTangents && o.enable(17), T.anisotropy && o.enable(18), T.alphaHash && o.enable(19), T.batching && o.enable(20), S.push(o.mask), o.disableAll(), T.fog && o.enable(0), T.useFog && o.enable(1), T.flatShading && o.enable(2), T.logarithmicDepthBuffer && o.enable(3), T.skinning && o.enable(4), T.morphTargets && o.enable(5), T.morphNormals && o.enable(6), T.morphColors && o.enable(7), T.premultipliedAlpha && o.enable(8), T.shadowMapEnabled && o.enable(9), T.useLegacyLights && o.enable(10), T.doubleSided && o.enable(11), T.flipSided && o.enable(12), T.useDepthPacking && o.enable(13), T.dithering && o.enable(14), T.transmission && o.enable(15), T.sheen && o.enable(16), T.opaque && o.enable(17), T.pointsUvs && o.enable(18), T.decodeVideoTexture && o.enable(19), T.alphaToCoverage && o.enable(20), S.push(o.mask); + } + function C(S) { + const T = v[S.type]; + let Y; + if (T) { + const K = on[T]; + Y = ph.clone(K.uniforms); + } else + Y = S.uniforms; + return Y; + } + function E(S, T) { + let Y; + for (let K = 0, L = u.length; K < L; K++) { + const N = u[K]; + if (N.cacheKey === T) { + Y = N, ++Y.usedTimes; + break; + } + } + return Y === void 0 && (Y = new Pg(i, T, S, s), u.push(Y)), Y; + } + function b(S) { + if (--S.usedTimes === 0) { + const T = u.indexOf(S); + u[T] = u[u.length - 1], u.pop(), S.destroy(); + } + } + function I(S) { + l.remove(S); + } + function W() { + l.dispose(); + } + return { + getParameters: d, + getProgramCacheKey: M, + getUniforms: C, + acquireProgram: E, + releaseProgram: b, + releaseShaderCache: I, + // Exposed for resource monitoring & error feedback via renderer.info: + programs: u, + dispose: W + }; +} +function Fg() { + let i = /* @__PURE__ */ new WeakMap(); + function e(s) { + let a = i.get(s); + return a === void 0 && (a = {}, i.set(s, a)), a; + } + function t(s) { + i.delete(s); + } + function n(s, a, o) { + i.get(s)[a] = o; + } + function r() { + i = /* @__PURE__ */ new WeakMap(); + } + return { + get: e, + remove: t, + update: n, + dispose: r + }; +} +function Ng(i, e) { + return i.groupOrder !== e.groupOrder ? i.groupOrder - e.groupOrder : i.renderOrder !== e.renderOrder ? i.renderOrder - e.renderOrder : i.material.id !== e.material.id ? i.material.id - e.material.id : i.z !== e.z ? i.z - e.z : i.id - e.id; +} +function el(i, e) { + return i.groupOrder !== e.groupOrder ? i.groupOrder - e.groupOrder : i.renderOrder !== e.renderOrder ? i.renderOrder - e.renderOrder : i.z !== e.z ? e.z - i.z : i.id - e.id; +} +function tl() { + const i = []; + let e = 0; + const t = [], n = [], r = []; + function s() { + e = 0, t.length = 0, n.length = 0, r.length = 0; + } + function a(f, h, p, g, v, m) { + let d = i[e]; + return d === void 0 ? (d = { + id: f.id, + object: f, + geometry: h, + material: p, + groupOrder: g, + renderOrder: f.renderOrder, + z: v, + group: m + }, i[e] = d) : (d.id = f.id, d.object = f, d.geometry = h, d.material = p, d.groupOrder = g, d.renderOrder = f.renderOrder, d.z = v, d.group = m), e++, d; + } + function o(f, h, p, g, v, m) { + const d = a(f, h, p, g, v, m); + p.transmission > 0 ? n.push(d) : p.transparent === !0 ? r.push(d) : t.push(d); + } + function l(f, h, p, g, v, m) { + const d = a(f, h, p, g, v, m); + p.transmission > 0 ? n.unshift(d) : p.transparent === !0 ? r.unshift(d) : t.unshift(d); + } + function c(f, h) { + t.length > 1 && t.sort(f || Ng), n.length > 1 && n.sort(h || el), r.length > 1 && r.sort(h || el); + } + function u() { + for (let f = e, h = i.length; f < h; f++) { + const p = i[f]; + if (p.id === null) + break; + p.id = null, p.object = null, p.geometry = null, p.material = null, p.group = null; + } + } + return { + opaque: t, + transmissive: n, + transparent: r, + init: s, + push: o, + unshift: l, + finish: u, + sort: c + }; +} +function Bg() { + let i = /* @__PURE__ */ new WeakMap(); + function e(n, r) { + const s = i.get(n); + let a; + return s === void 0 ? (a = new tl(), i.set(n, [a])) : r >= s.length ? (a = new tl(), s.push(a)) : a = s[r], a; + } + function t() { + i = /* @__PURE__ */ new WeakMap(); + } + return { + get: e, + dispose: t + }; +} +function Og() { + const i = {}; + return { + get: function(e) { + if (i[e.id] !== void 0) + return i[e.id]; + let t; + switch (e.type) { + case "DirectionalLight": + t = { + direction: new P(), + color: new Qe() + }; + break; + case "SpotLight": + t = { + position: new P(), + direction: new P(), + color: new Qe(), + distance: 0, + coneCos: 0, + penumbraCos: 0, + decay: 0 + }; + break; + case "PointLight": + t = { + position: new P(), + color: new Qe(), + distance: 0, + decay: 0 + }; + break; + case "HemisphereLight": + t = { + direction: new P(), + skyColor: new Qe(), + groundColor: new Qe() + }; + break; + case "RectAreaLight": + t = { + color: new Qe(), + position: new P(), + halfWidth: new P(), + halfHeight: new P() + }; + break; + } + return i[e.id] = t, t; + } + }; +} +function zg() { + const i = {}; + return { + get: function(e) { + if (i[e.id] !== void 0) + return i[e.id]; + let t; + switch (e.type) { + case "DirectionalLight": + t = { + shadowBias: 0, + shadowNormalBias: 0, + shadowRadius: 1, + shadowMapSize: new me() + }; + break; + case "SpotLight": + t = { + shadowBias: 0, + shadowNormalBias: 0, + shadowRadius: 1, + shadowMapSize: new me() + }; + break; + case "PointLight": + t = { + shadowBias: 0, + shadowNormalBias: 0, + shadowRadius: 1, + shadowMapSize: new me(), + shadowCameraNear: 1, + shadowCameraFar: 1e3 + }; + break; + } + return i[e.id] = t, t; + } + }; +} +let kg = 0; +function Gg(i, e) { + return (e.castShadow ? 2 : 0) - (i.castShadow ? 2 : 0) + (e.map ? 1 : 0) - (i.map ? 1 : 0); +} +function Hg(i, e) { + const t = new Og(), n = zg(), r = { + version: 0, + hash: { + directionalLength: -1, + pointLength: -1, + spotLength: -1, + rectAreaLength: -1, + hemiLength: -1, + numDirectionalShadows: -1, + numPointShadows: -1, + numSpotShadows: -1, + numSpotMaps: -1, + numLightProbes: -1 + }, + ambient: [0, 0, 0], + probe: [], + directional: [], + directionalShadow: [], + directionalShadowMap: [], + directionalShadowMatrix: [], + spot: [], + spotLightMap: [], + spotShadow: [], + spotShadowMap: [], + spotLightMatrix: [], + rectArea: [], + rectAreaLTC1: null, + rectAreaLTC2: null, + point: [], + pointShadow: [], + pointShadowMap: [], + pointShadowMatrix: [], + hemi: [], + numSpotLightShadowsWithMaps: 0, + numLightProbes: 0 + }; + for (let u = 0; u < 9; u++) + r.probe.push(new P()); + const s = new P(), a = new ke(), o = new ke(); + function l(u, f) { + let h = 0, p = 0, g = 0; + for (let Y = 0; Y < 9; Y++) + r.probe[Y].set(0, 0, 0); + let v = 0, m = 0, d = 0, M = 0, _ = 0, A = 0, C = 0, E = 0, b = 0, I = 0, W = 0; + u.sort(Gg); + const S = f === !0 ? Math.PI : 1; + for (let Y = 0, K = u.length; Y < K; Y++) { + const L = u[Y], N = L.color, O = L.intensity, B = L.distance, j = L.shadow && L.shadow.map ? L.shadow.map.texture : null; + if (L.isAmbientLight) + h += N.r * O * S, p += N.g * O * S, g += N.b * O * S; + else if (L.isLightProbe) { + for (let q = 0; q < 9; q++) + r.probe[q].addScaledVector(L.sh.coefficients[q], O); + W++; + } else if (L.isDirectionalLight) { + const q = t.get(L); + if (q.color.copy(L.color).multiplyScalar(L.intensity * S), L.castShadow) { + const J = L.shadow, ne = n.get(L); + ne.shadowBias = J.bias, ne.shadowNormalBias = J.normalBias, ne.shadowRadius = J.radius, ne.shadowMapSize = J.mapSize, r.directionalShadow[v] = ne, r.directionalShadowMap[v] = j, r.directionalShadowMatrix[v] = L.shadow.matrix, A++; + } + r.directional[v] = q, v++; + } else if (L.isSpotLight) { + const q = t.get(L); + q.position.setFromMatrixPosition(L.matrixWorld), q.color.copy(N).multiplyScalar(O * S), q.distance = B, q.coneCos = Math.cos(L.angle), q.penumbraCos = Math.cos(L.angle * (1 - L.penumbra)), q.decay = L.decay, r.spot[d] = q; + const J = L.shadow; + if (L.map && (r.spotLightMap[b] = L.map, b++, J.updateMatrices(L), L.castShadow && I++), r.spotLightMatrix[d] = J.matrix, L.castShadow) { + const ne = n.get(L); + ne.shadowBias = J.bias, ne.shadowNormalBias = J.normalBias, ne.shadowRadius = J.radius, ne.shadowMapSize = J.mapSize, r.spotShadow[d] = ne, r.spotShadowMap[d] = j, E++; + } + d++; + } else if (L.isRectAreaLight) { + const q = t.get(L); + q.color.copy(N).multiplyScalar(O), q.halfWidth.set(L.width * 0.5, 0, 0), q.halfHeight.set(0, L.height * 0.5, 0), r.rectArea[M] = q, M++; + } else if (L.isPointLight) { + const q = t.get(L); + if (q.color.copy(L.color).multiplyScalar(L.intensity * S), q.distance = L.distance, q.decay = L.decay, L.castShadow) { + const J = L.shadow, ne = n.get(L); + ne.shadowBias = J.bias, ne.shadowNormalBias = J.normalBias, ne.shadowRadius = J.radius, ne.shadowMapSize = J.mapSize, ne.shadowCameraNear = J.camera.near, ne.shadowCameraFar = J.camera.far, r.pointShadow[m] = ne, r.pointShadowMap[m] = j, r.pointShadowMatrix[m] = L.shadow.matrix, C++; + } + r.point[m] = q, m++; + } else if (L.isHemisphereLight) { + const q = t.get(L); + q.skyColor.copy(L.color).multiplyScalar(O * S), q.groundColor.copy(L.groundColor).multiplyScalar(O * S), r.hemi[_] = q, _++; + } + } + M > 0 && (e.isWebGL2 ? i.has("OES_texture_float_linear") === !0 ? (r.rectAreaLTC1 = oe.LTC_FLOAT_1, r.rectAreaLTC2 = oe.LTC_FLOAT_2) : (r.rectAreaLTC1 = oe.LTC_HALF_1, r.rectAreaLTC2 = oe.LTC_HALF_2) : i.has("OES_texture_float_linear") === !0 ? (r.rectAreaLTC1 = oe.LTC_FLOAT_1, r.rectAreaLTC2 = oe.LTC_FLOAT_2) : i.has("OES_texture_half_float_linear") === !0 ? (r.rectAreaLTC1 = oe.LTC_HALF_1, r.rectAreaLTC2 = oe.LTC_HALF_2) : console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")), r.ambient[0] = h, r.ambient[1] = p, r.ambient[2] = g; + const T = r.hash; + (T.directionalLength !== v || T.pointLength !== m || T.spotLength !== d || T.rectAreaLength !== M || T.hemiLength !== _ || T.numDirectionalShadows !== A || T.numPointShadows !== C || T.numSpotShadows !== E || T.numSpotMaps !== b || T.numLightProbes !== W) && (r.directional.length = v, r.spot.length = d, r.rectArea.length = M, r.point.length = m, r.hemi.length = _, r.directionalShadow.length = A, r.directionalShadowMap.length = A, r.pointShadow.length = C, r.pointShadowMap.length = C, r.spotShadow.length = E, r.spotShadowMap.length = E, r.directionalShadowMatrix.length = A, r.pointShadowMatrix.length = C, r.spotLightMatrix.length = E + b - I, r.spotLightMap.length = b, r.numSpotLightShadowsWithMaps = I, r.numLightProbes = W, T.directionalLength = v, T.pointLength = m, T.spotLength = d, T.rectAreaLength = M, T.hemiLength = _, T.numDirectionalShadows = A, T.numPointShadows = C, T.numSpotShadows = E, T.numSpotMaps = b, T.numLightProbes = W, r.version = kg++); + } + function c(u, f) { + let h = 0, p = 0, g = 0, v = 0, m = 0; + const d = f.matrixWorldInverse; + for (let M = 0, _ = u.length; M < _; M++) { + const A = u[M]; + if (A.isDirectionalLight) { + const C = r.directional[h]; + C.direction.setFromMatrixPosition(A.matrixWorld), s.setFromMatrixPosition(A.target.matrixWorld), C.direction.sub(s), C.direction.transformDirection(d), h++; + } else if (A.isSpotLight) { + const C = r.spot[g]; + C.position.setFromMatrixPosition(A.matrixWorld), C.position.applyMatrix4(d), C.direction.setFromMatrixPosition(A.matrixWorld), s.setFromMatrixPosition(A.target.matrixWorld), C.direction.sub(s), C.direction.transformDirection(d), g++; + } else if (A.isRectAreaLight) { + const C = r.rectArea[v]; + C.position.setFromMatrixPosition(A.matrixWorld), C.position.applyMatrix4(d), o.identity(), a.copy(A.matrixWorld), a.premultiply(d), o.extractRotation(a), C.halfWidth.set(A.width * 0.5, 0, 0), C.halfHeight.set(0, A.height * 0.5, 0), C.halfWidth.applyMatrix4(o), C.halfHeight.applyMatrix4(o), v++; + } else if (A.isPointLight) { + const C = r.point[p]; + C.position.setFromMatrixPosition(A.matrixWorld), C.position.applyMatrix4(d), p++; + } else if (A.isHemisphereLight) { + const C = r.hemi[m]; + C.direction.setFromMatrixPosition(A.matrixWorld), C.direction.transformDirection(d), m++; + } + } + } + return { + setup: l, + setupView: c, + state: r + }; +} +function nl(i, e) { + const t = new Hg(i, e), n = [], r = []; + function s() { + n.length = 0, r.length = 0; + } + function a(f) { + n.push(f); + } + function o(f) { + r.push(f); + } + function l(f) { + t.setup(n, f); + } + function c(f) { + t.setupView(n, f); + } + return { + init: s, + state: { + lightsArray: n, + shadowsArray: r, + lights: t + }, + setupLights: l, + setupLightsView: c, + pushLight: a, + pushShadow: o + }; +} +function Vg(i, e) { + let t = /* @__PURE__ */ new WeakMap(); + function n(s, a = 0) { + const o = t.get(s); + let l; + return o === void 0 ? (l = new nl(i, e), t.set(s, [l])) : a >= o.length ? (l = new nl(i, e), o.push(l)) : l = o[a], l; + } + function r() { + t = /* @__PURE__ */ new WeakMap(); + } + return { + get: n, + dispose: r + }; +} +class Wg extends as { + constructor(e) { + super(), this.isMeshDepthMaterial = !0, this.type = "MeshDepthMaterial", this.depthPacking = Sf, this.map = null, this.alphaMap = null, this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.wireframe = !1, this.wireframeLinewidth = 1, this.setValues(e); + } + copy(e) { + return super.copy(e), this.depthPacking = e.depthPacking, this.map = e.map, this.alphaMap = e.alphaMap, this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this; + } +} +class Xg extends as { + constructor(e) { + super(), this.isMeshDistanceMaterial = !0, this.type = "MeshDistanceMaterial", this.map = null, this.alphaMap = null, this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.setValues(e); + } + copy(e) { + return super.copy(e), this.map = e.map, this.alphaMap = e.alphaMap, this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this; + } +} +const qg = `void main() { + gl_Position = vec4( position, 1.0 ); +}`, Yg = `uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +#include +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + squared_mean = squared_mean / samples; + float std_dev = sqrt( squared_mean - mean * mean ); + gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); +}`; +function jg(i, e, t) { + let n = new oc(); + const r = new me(), s = new me(), a = new ut(), o = new Wg({ depthPacking: Mf }), l = new Xg(), c = {}, u = t.maxTextureSize, f = { [hn]: Pt, [Pt]: hn, [en]: en }, h = new Xt({ + defines: { + VSM_SAMPLES: 8 + }, + uniforms: { + shadow_pass: { value: null }, + resolution: { value: new me() }, + radius: { value: 4 } + }, + vertexShader: qg, + fragmentShader: Yg + }), p = h.clone(); + p.defines.HORIZONTAL_PASS = 1; + const g = new Yt(); + g.setAttribute( + "position", + new Wt( + new Float32Array([-1, -1, 0.5, 3, -1, 0.5, -1, 3, 0.5]), + 3 + ) + ); + const v = new at(g, h), m = this; + this.enabled = !1, this.autoUpdate = !0, this.needsUpdate = !1, this.type = Bl; + let d = this.type; + this.render = function(E, b, I) { + if (m.enabled === !1 || m.autoUpdate === !1 && m.needsUpdate === !1 || E.length === 0) + return; + const W = i.getRenderTarget(), S = i.getActiveCubeFace(), T = i.getActiveMipmapLevel(), Y = i.state; + Y.setBlending(zn), Y.buffers.color.setClear(1, 1, 1, 1), Y.buffers.depth.setTest(!0), Y.setScissorTest(!1); + const K = d !== xn && this.type === xn, L = d === xn && this.type !== xn; + for (let N = 0, O = E.length; N < O; N++) { + const B = E[N], j = B.shadow; + if (j === void 0) { + console.warn("THREE.WebGLShadowMap:", B, "has no shadow."); + continue; + } + if (j.autoUpdate === !1 && j.needsUpdate === !1) + continue; + r.copy(j.mapSize); + const q = j.getFrameExtents(); + if (r.multiply(q), s.copy(j.mapSize), (r.x > u || r.y > u) && (r.x > u && (s.x = Math.floor(u / q.x), r.x = s.x * q.x, j.mapSize.x = s.x), r.y > u && (s.y = Math.floor(u / q.y), r.y = s.y * q.y, j.mapSize.y = s.y)), j.map === null || K === !0 || L === !0) { + const ne = this.type !== xn ? { minFilter: vt, magFilter: vt } : {}; + j.map !== null && j.map.dispose(), j.map = new Vn(r.x, r.y, ne), j.map.texture.name = B.name + ".shadowMap", j.camera.updateProjectionMatrix(); + } + i.setRenderTarget(j.map), i.clear(); + const J = j.getViewportCount(); + for (let ne = 0; ne < J; ne++) { + const ue = j.getViewport(ne); + a.set( + s.x * ue.x, + s.y * ue.y, + s.x * ue.z, + s.y * ue.w + ), Y.viewport(a), j.updateMatrices(B, ne), n = j.getFrustum(), A(b, I, j.camera, B, this.type); + } + j.isPointLightShadow !== !0 && this.type === xn && M(j, I), j.needsUpdate = !1; + } + d = this.type, m.needsUpdate = !1, i.setRenderTarget(W, S, T); + }; + function M(E, b) { + const I = e.update(v); + h.defines.VSM_SAMPLES !== E.blurSamples && (h.defines.VSM_SAMPLES = E.blurSamples, p.defines.VSM_SAMPLES = E.blurSamples, h.needsUpdate = !0, p.needsUpdate = !0), E.mapPass === null && (E.mapPass = new Vn(r.x, r.y)), h.uniforms.shadow_pass.value = E.map.texture, h.uniforms.resolution.value = E.mapSize, h.uniforms.radius.value = E.radius, i.setRenderTarget(E.mapPass), i.clear(), i.renderBufferDirect(b, null, I, h, v, null), p.uniforms.shadow_pass.value = E.mapPass.texture, p.uniforms.resolution.value = E.mapSize, p.uniforms.radius.value = E.radius, i.setRenderTarget(E.map), i.clear(), i.renderBufferDirect(b, null, I, p, v, null); + } + function _(E, b, I, W) { + let S = null; + const T = I.isPointLight === !0 ? E.customDistanceMaterial : E.customDepthMaterial; + if (T !== void 0) + S = T; + else if (S = I.isPointLight === !0 ? l : o, i.localClippingEnabled && b.clipShadows === !0 && Array.isArray(b.clippingPlanes) && b.clippingPlanes.length !== 0 || b.displacementMap && b.displacementScale !== 0 || b.alphaMap && b.alphaTest > 0 || b.map && b.alphaTest > 0) { + const Y = S.uuid, K = b.uuid; + let L = c[Y]; + L === void 0 && (L = {}, c[Y] = L); + let N = L[K]; + N === void 0 && (N = S.clone(), L[K] = N, b.addEventListener("dispose", C)), S = N; + } + if (S.visible = b.visible, S.wireframe = b.wireframe, W === xn ? S.side = b.shadowSide !== null ? b.shadowSide : b.side : S.side = b.shadowSide !== null ? b.shadowSide : f[b.side], S.alphaMap = b.alphaMap, S.alphaTest = b.alphaTest, S.map = b.map, S.clipShadows = b.clipShadows, S.clippingPlanes = b.clippingPlanes, S.clipIntersection = b.clipIntersection, S.displacementMap = b.displacementMap, S.displacementScale = b.displacementScale, S.displacementBias = b.displacementBias, S.wireframeLinewidth = b.wireframeLinewidth, S.linewidth = b.linewidth, I.isPointLight === !0 && S.isMeshDistanceMaterial === !0) { + const Y = i.properties.get(S); + Y.light = I; + } + return S; + } + function A(E, b, I, W, S) { + if (E.visible === !1) + return; + if (E.layers.test(b.layers) && (E.isMesh || E.isLine || E.isPoints) && (E.castShadow || E.receiveShadow && S === xn) && (!E.frustumCulled || n.intersectsObject(E))) { + E.modelViewMatrix.multiplyMatrices(I.matrixWorldInverse, E.matrixWorld); + const K = e.update(E), L = E.material; + if (Array.isArray(L)) { + const N = K.groups; + for (let O = 0, B = N.length; O < B; O++) { + const j = N[O], q = L[j.materialIndex]; + if (q && q.visible) { + const J = _(E, q, W, S); + E.onBeforeShadow(i, E, b, I, K, J, j), i.renderBufferDirect(I, null, K, J, E, j), E.onAfterShadow(i, E, b, I, K, J, j); + } + } + } else if (L.visible) { + const N = _(E, L, W, S); + E.onBeforeShadow(i, E, b, I, K, N, null), i.renderBufferDirect(I, null, K, N, E, null), E.onAfterShadow(i, E, b, I, K, N, null); + } + } + const Y = E.children; + for (let K = 0, L = Y.length; K < L; K++) + A(Y[K], b, I, W, S); + } + function C(E) { + E.target.removeEventListener("dispose", C); + for (const I in c) { + const W = c[I], S = E.target.uuid; + S in W && (W[S].dispose(), delete W[S]); + } + } +} +function Kg(i, e, t) { + const n = t.isWebGL2; + function r() { + let D = !1; + const re = new ut(); + let z = null; + const ie = new ut(0, 0, 0, 0); + return { + setMask: function(ae) { + z !== ae && !D && (i.colorMask(ae, ae, ae, ae), z = ae); + }, + setLocked: function(ae) { + D = ae; + }, + setClear: function(ae, Oe, et, _t, Nt) { + Nt === !0 && (ae *= _t, Oe *= _t, et *= _t), re.set(ae, Oe, et, _t), ie.equals(re) === !1 && (i.clearColor(ae, Oe, et, _t), ie.copy(re)); + }, + reset: function() { + D = !1, z = null, ie.set(-1, 0, 0, 0); + } + }; + } + function s() { + let D = !1, re = null, z = null, ie = null; + return { + setTest: function(ae) { + ae ? ge(i.DEPTH_TEST) : Ke(i.DEPTH_TEST); + }, + setMask: function(ae) { + re !== ae && !D && (i.depthMask(ae), re = ae); + }, + setFunc: function(ae) { + if (z !== ae) { + switch (ae) { + case Qu: + i.depthFunc(i.NEVER); + break; + case Zu: + i.depthFunc(i.ALWAYS); + break; + case Ju: + i.depthFunc(i.LESS); + break; + case qr: + i.depthFunc(i.LEQUAL); + break; + case $u: + i.depthFunc(i.EQUAL); + break; + case ef: + i.depthFunc(i.GEQUAL); + break; + case tf: + i.depthFunc(i.GREATER); + break; + case nf: + i.depthFunc(i.NOTEQUAL); + break; + default: + i.depthFunc(i.LEQUAL); + } + z = ae; + } + }, + setLocked: function(ae) { + D = ae; + }, + setClear: function(ae) { + ie !== ae && (i.clearDepth(ae), ie = ae); + }, + reset: function() { + D = !1, re = null, z = null, ie = null; + } + }; + } + function a() { + let D = !1, re = null, z = null, ie = null, ae = null, Oe = null, et = null, _t = null, Nt = null; + return { + setTest: function(tt) { + D || (tt ? ge(i.STENCIL_TEST) : Ke(i.STENCIL_TEST)); + }, + setMask: function(tt) { + re !== tt && !D && (i.stencilMask(tt), re = tt); + }, + setFunc: function(tt, At, rn) { + (z !== tt || ie !== At || ae !== rn) && (i.stencilFunc(tt, At, rn), z = tt, ie = At, ae = rn); + }, + setOp: function(tt, At, rn) { + (Oe !== tt || et !== At || _t !== rn) && (i.stencilOp(tt, At, rn), Oe = tt, et = At, _t = rn); + }, + setLocked: function(tt) { + D = tt; + }, + setClear: function(tt) { + Nt !== tt && (i.clearStencil(tt), Nt = tt); + }, + reset: function() { + D = !1, re = null, z = null, ie = null, ae = null, Oe = null, et = null, _t = null, Nt = null; + } + }; + } + const o = new r(), l = new s(), c = new a(), u = /* @__PURE__ */ new WeakMap(), f = /* @__PURE__ */ new WeakMap(); + let h = {}, p = {}, g = /* @__PURE__ */ new WeakMap(), v = [], m = null, d = !1, M = null, _ = null, A = null, C = null, E = null, b = null, I = null, W = new Qe(0, 0, 0), S = 0, T = !1, Y = null, K = null, L = null, N = null, O = null; + const B = i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS); + let j = !1, q = 0; + const J = i.getParameter(i.VERSION); + J.indexOf("WebGL") !== -1 ? (q = parseFloat(/^WebGL (\d)/.exec(J)[1]), j = q >= 1) : J.indexOf("OpenGL ES") !== -1 && (q = parseFloat(/^OpenGL ES (\d)/.exec(J)[1]), j = q >= 2); + let ne = null, ue = {}; + const Z = i.getParameter(i.SCISSOR_BOX), H = i.getParameter(i.VIEWPORT), ee = new ut().fromArray(Z), pe = new ut().fromArray(H); + function Te(D, re, z, ie) { + const ae = new Uint8Array(4), Oe = i.createTexture(); + i.bindTexture(D, Oe), i.texParameteri(D, i.TEXTURE_MIN_FILTER, i.NEAREST), i.texParameteri(D, i.TEXTURE_MAG_FILTER, i.NEAREST); + for (let et = 0; et < z; et++) + n && (D === i.TEXTURE_3D || D === i.TEXTURE_2D_ARRAY) ? i.texImage3D(re, 0, i.RGBA, 1, 1, ie, 0, i.RGBA, i.UNSIGNED_BYTE, ae) : i.texImage2D(re + et, 0, i.RGBA, 1, 1, 0, i.RGBA, i.UNSIGNED_BYTE, ae); + return Oe; + } + const xe = {}; + xe[i.TEXTURE_2D] = Te(i.TEXTURE_2D, i.TEXTURE_2D, 1), xe[i.TEXTURE_CUBE_MAP] = Te(i.TEXTURE_CUBE_MAP, i.TEXTURE_CUBE_MAP_POSITIVE_X, 6), n && (xe[i.TEXTURE_2D_ARRAY] = Te(i.TEXTURE_2D_ARRAY, i.TEXTURE_2D_ARRAY, 1, 1), xe[i.TEXTURE_3D] = Te(i.TEXTURE_3D, i.TEXTURE_3D, 1, 1)), o.setClear(0, 0, 0, 1), l.setClear(1), c.setClear(0), ge(i.DEPTH_TEST), l.setFunc(qr), Ie(!1), Be(Fo), ge(i.CULL_FACE), ye(zn); + function ge(D) { + h[D] !== !0 && (i.enable(D), h[D] = !0); + } + function Ke(D) { + h[D] !== !1 && (i.disable(D), h[D] = !1); + } + function we(D, re) { + return p[D] !== re ? (i.bindFramebuffer(D, re), p[D] = re, n && (D === i.DRAW_FRAMEBUFFER && (p[i.FRAMEBUFFER] = re), D === i.FRAMEBUFFER && (p[i.DRAW_FRAMEBUFFER] = re)), !0) : !1; + } + function F(D, re) { + let z = v, ie = !1; + if (D) { + z = g.get(re), z === void 0 && (z = [], g.set(re, z)); + const ae = D.textures; + if (z.length !== ae.length || z[0] !== i.COLOR_ATTACHMENT0) { + for (let Oe = 0, et = ae.length; Oe < et; Oe++) + z[Oe] = i.COLOR_ATTACHMENT0 + Oe; + z.length = ae.length, ie = !0; + } + } else + z[0] !== i.BACK && (z[0] = i.BACK, ie = !0); + if (ie) + if (t.isWebGL2) + i.drawBuffers(z); + else if (e.has("WEBGL_draw_buffers") === !0) + e.get("WEBGL_draw_buffers").drawBuffersWEBGL(z); + else + throw new Error("THREE.WebGLState: Usage of gl.drawBuffers() require WebGL2 or WEBGL_draw_buffers extension"); + } + function lt(D) { + return m !== D ? (i.useProgram(D), m = D, !0) : !1; + } + const Me = { + [ei]: i.FUNC_ADD, + [Fu]: i.FUNC_SUBTRACT, + [Nu]: i.FUNC_REVERSE_SUBTRACT + }; + if (n) + Me[zo] = i.MIN, Me[ko] = i.MAX; + else { + const D = e.get("EXT_blend_minmax"); + D !== null && (Me[zo] = D.MIN_EXT, Me[ko] = D.MAX_EXT); + } + const Ne = { + [Bu]: i.ZERO, + [Ou]: i.ONE, + [zu]: i.SRC_COLOR, + [cr]: i.SRC_ALPHA, + [Xu]: i.SRC_ALPHA_SATURATE, + [Vu]: i.DST_COLOR, + [Gu]: i.DST_ALPHA, + [ku]: i.ONE_MINUS_SRC_COLOR, + [ur]: i.ONE_MINUS_SRC_ALPHA, + [Wu]: i.ONE_MINUS_DST_COLOR, + [Hu]: i.ONE_MINUS_DST_ALPHA, + [qu]: i.CONSTANT_COLOR, + [Yu]: i.ONE_MINUS_CONSTANT_COLOR, + [ju]: i.CONSTANT_ALPHA, + [Ku]: i.ONE_MINUS_CONSTANT_ALPHA + }; + function ye(D, re, z, ie, ae, Oe, et, _t, Nt, tt) { + if (D === zn) { + d === !0 && (Ke(i.BLEND), d = !1); + return; + } + if (d === !1 && (ge(i.BLEND), d = !0), D !== Ol) { + if (D !== M || tt !== T) { + if ((_ !== ei || E !== ei) && (i.blendEquation(i.FUNC_ADD), _ = ei, E = ei), tt) + switch (D) { + case ri: + i.blendFuncSeparate(i.ONE, i.ONE_MINUS_SRC_ALPHA, i.ONE, i.ONE_MINUS_SRC_ALPHA); + break; + case No: + i.blendFunc(i.ONE, i.ONE); + break; + case Bo: + i.blendFuncSeparate(i.ZERO, i.ONE_MINUS_SRC_COLOR, i.ZERO, i.ONE); + break; + case Oo: + i.blendFuncSeparate(i.ZERO, i.SRC_COLOR, i.ZERO, i.SRC_ALPHA); + break; + default: + console.error("THREE.WebGLState: Invalid blending: ", D); + break; + } + else + switch (D) { + case ri: + i.blendFuncSeparate(i.SRC_ALPHA, i.ONE_MINUS_SRC_ALPHA, i.ONE, i.ONE_MINUS_SRC_ALPHA); + break; + case No: + i.blendFunc(i.SRC_ALPHA, i.ONE); + break; + case Bo: + i.blendFuncSeparate(i.ZERO, i.ONE_MINUS_SRC_COLOR, i.ZERO, i.ONE); + break; + case Oo: + i.blendFunc(i.ZERO, i.SRC_COLOR); + break; + default: + console.error("THREE.WebGLState: Invalid blending: ", D); + break; + } + A = null, C = null, b = null, I = null, W.set(0, 0, 0), S = 0, M = D, T = tt; + } + return; + } + ae = ae || re, Oe = Oe || z, et = et || ie, (re !== _ || ae !== E) && (i.blendEquationSeparate(Me[re], Me[ae]), _ = re, E = ae), (z !== A || ie !== C || Oe !== b || et !== I) && (i.blendFuncSeparate(Ne[z], Ne[ie], Ne[Oe], Ne[et]), A = z, C = ie, b = Oe, I = et), (_t.equals(W) === !1 || Nt !== S) && (i.blendColor(_t.r, _t.g, _t.b, Nt), W.copy(_t), S = Nt), M = D, T = !1; + } + function qe(D, re) { + D.side === en ? Ke(i.CULL_FACE) : ge(i.CULL_FACE); + let z = D.side === Pt; + re && (z = !z), Ie(z), D.blending === ri && D.transparent === !1 ? ye(zn) : ye(D.blending, D.blendEquation, D.blendSrc, D.blendDst, D.blendEquationAlpha, D.blendSrcAlpha, D.blendDstAlpha, D.blendColor, D.blendAlpha, D.premultipliedAlpha), l.setFunc(D.depthFunc), l.setTest(D.depthTest), l.setMask(D.depthWrite), o.setMask(D.colorWrite); + const ie = D.stencilWrite; + c.setTest(ie), ie && (c.setMask(D.stencilWriteMask), c.setFunc(D.stencilFunc, D.stencilRef, D.stencilFuncMask), c.setOp(D.stencilFail, D.stencilZFail, D.stencilZPass)), w(D.polygonOffset, D.polygonOffsetFactor, D.polygonOffsetUnits), D.alphaToCoverage === !0 ? ge(i.SAMPLE_ALPHA_TO_COVERAGE) : Ke(i.SAMPLE_ALPHA_TO_COVERAGE); + } + function Ie(D) { + Y !== D && (D ? i.frontFace(i.CW) : i.frontFace(i.CCW), Y = D); + } + function Be(D) { + D !== Du ? (ge(i.CULL_FACE), D !== K && (D === Fo ? i.cullFace(i.BACK) : D === Iu ? i.cullFace(i.FRONT) : i.cullFace(i.FRONT_AND_BACK))) : Ke(i.CULL_FACE), K = D; + } + function Je(D) { + D !== L && (j && i.lineWidth(D), L = D); + } + function w(D, re, z) { + D ? (ge(i.POLYGON_OFFSET_FILL), (N !== re || O !== z) && (i.polygonOffset(re, z), N = re, O = z)) : Ke(i.POLYGON_OFFSET_FILL); + } + function x(D) { + D ? ge(i.SCISSOR_TEST) : Ke(i.SCISSOR_TEST); + } + function X(D) { + D === void 0 && (D = i.TEXTURE0 + B - 1), ne !== D && (i.activeTexture(D), ne = D); + } + function Q(D, re, z) { + z === void 0 && (ne === null ? z = i.TEXTURE0 + B - 1 : z = ne); + let ie = ue[z]; + ie === void 0 && (ie = { type: void 0, texture: void 0 }, ue[z] = ie), (ie.type !== D || ie.texture !== re) && (ne !== z && (i.activeTexture(z), ne = z), i.bindTexture(D, re || xe[D]), ie.type = D, ie.texture = re); + } + function te() { + const D = ue[ne]; + D !== void 0 && D.type !== void 0 && (i.bindTexture(D.type, null), D.type = void 0, D.texture = void 0); + } + function $() { + try { + i.compressedTexImage2D.apply(i, arguments); + } catch (D) { + console.error("THREE.WebGLState:", D); + } + } + function Le() { + try { + i.compressedTexImage3D.apply(i, arguments); + } catch (D) { + console.error("THREE.WebGLState:", D); + } + } + function Ae() { + try { + i.texSubImage2D.apply(i, arguments); + } catch (D) { + console.error("THREE.WebGLState:", D); + } + } + function se() { + try { + i.texSubImage3D.apply(i, arguments); + } catch (D) { + console.error("THREE.WebGLState:", D); + } + } + function ce() { + try { + i.compressedTexSubImage2D.apply(i, arguments); + } catch (D) { + console.error("THREE.WebGLState:", D); + } + } + function Re() { + try { + i.compressedTexSubImage3D.apply(i, arguments); + } catch (D) { + console.error("THREE.WebGLState:", D); + } + } + function R() { + try { + i.texStorage2D.apply(i, arguments); + } catch (D) { + console.error("THREE.WebGLState:", D); + } + } + function le() { + try { + i.texStorage3D.apply(i, arguments); + } catch (D) { + console.error("THREE.WebGLState:", D); + } + } + function ve() { + try { + i.texImage2D.apply(i, arguments); + } catch (D) { + console.error("THREE.WebGLState:", D); + } + } + function fe() { + try { + i.texImage3D.apply(i, arguments); + } catch (D) { + console.error("THREE.WebGLState:", D); + } + } + function he(D) { + ee.equals(D) === !1 && (i.scissor(D.x, D.y, D.z, D.w), ee.copy(D)); + } + function _e(D) { + pe.equals(D) === !1 && (i.viewport(D.x, D.y, D.z, D.w), pe.copy(D)); + } + function De(D, re) { + let z = f.get(re); + z === void 0 && (z = /* @__PURE__ */ new WeakMap(), f.set(re, z)); + let ie = z.get(D); + ie === void 0 && (ie = i.getUniformBlockIndex(re, D.name), z.set(D, ie)); + } + function Ue(D, re) { + const ie = f.get(re).get(D); + u.get(re) !== ie && (i.uniformBlockBinding(re, ie, D.__bindingPointIndex), u.set(re, ie)); + } + function $e() { + i.disable(i.BLEND), i.disable(i.CULL_FACE), i.disable(i.DEPTH_TEST), i.disable(i.POLYGON_OFFSET_FILL), i.disable(i.SCISSOR_TEST), i.disable(i.STENCIL_TEST), i.disable(i.SAMPLE_ALPHA_TO_COVERAGE), i.blendEquation(i.FUNC_ADD), i.blendFunc(i.ONE, i.ZERO), i.blendFuncSeparate(i.ONE, i.ZERO, i.ONE, i.ZERO), i.blendColor(0, 0, 0, 0), i.colorMask(!0, !0, !0, !0), i.clearColor(0, 0, 0, 0), i.depthMask(!0), i.depthFunc(i.LESS), i.clearDepth(1), i.stencilMask(4294967295), i.stencilFunc(i.ALWAYS, 0, 4294967295), i.stencilOp(i.KEEP, i.KEEP, i.KEEP), i.clearStencil(0), i.cullFace(i.BACK), i.frontFace(i.CCW), i.polygonOffset(0, 0), i.activeTexture(i.TEXTURE0), i.bindFramebuffer(i.FRAMEBUFFER, null), n === !0 && (i.bindFramebuffer(i.DRAW_FRAMEBUFFER, null), i.bindFramebuffer(i.READ_FRAMEBUFFER, null)), i.useProgram(null), i.lineWidth(1), i.scissor(0, 0, i.canvas.width, i.canvas.height), i.viewport(0, 0, i.canvas.width, i.canvas.height), h = {}, ne = null, ue = {}, p = {}, g = /* @__PURE__ */ new WeakMap(), v = [], m = null, d = !1, M = null, _ = null, A = null, C = null, E = null, b = null, I = null, W = new Qe(0, 0, 0), S = 0, T = !1, Y = null, K = null, L = null, N = null, O = null, ee.set(0, 0, i.canvas.width, i.canvas.height), pe.set(0, 0, i.canvas.width, i.canvas.height), o.reset(), l.reset(), c.reset(); + } + return { + buffers: { + color: o, + depth: l, + stencil: c + }, + enable: ge, + disable: Ke, + bindFramebuffer: we, + drawBuffers: F, + useProgram: lt, + setBlending: ye, + setMaterial: qe, + setFlipSided: Ie, + setCullFace: Be, + setLineWidth: Je, + setPolygonOffset: w, + setScissorTest: x, + activeTexture: X, + bindTexture: Q, + unbindTexture: te, + compressedTexImage2D: $, + compressedTexImage3D: Le, + texImage2D: ve, + texImage3D: fe, + updateUBOMapping: De, + uniformBlockBinding: Ue, + texStorage2D: R, + texStorage3D: le, + texSubImage2D: Ae, + texSubImage3D: se, + compressedTexSubImage2D: ce, + compressedTexSubImage3D: Re, + scissor: he, + viewport: _e, + reset: $e + }; +} +function Qg(i, e, t, n, r, s, a) { + const o = r.isWebGL2, l = e.has("WEBGL_multisampled_render_to_texture") ? e.get("WEBGL_multisampled_render_to_texture") : null, c = typeof navigator > "u" ? !1 : /OculusBrowser/g.test(navigator.userAgent), u = new me(), f = /* @__PURE__ */ new WeakMap(); + let h; + const p = /* @__PURE__ */ new WeakMap(); + let g = !1; + try { + g = typeof OffscreenCanvas < "u" && new OffscreenCanvas(1, 1).getContext("2d") !== null; + } catch { + } + function v(w, x) { + return g ? ( + // eslint-disable-next-line compat/compat + new OffscreenCanvas(w, x) + ) : Jr("canvas"); + } + function m(w, x, X, Q) { + let te = 1; + const $ = Je(w); + if (($.width > Q || $.height > Q) && (te = Q / Math.max($.width, $.height)), te < 1 || x === !0) + if (typeof HTMLImageElement < "u" && w instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && w instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && w instanceof ImageBitmap || typeof VideoFrame < "u" && w instanceof VideoFrame) { + const Le = x ? Zr : Math.floor, Ae = Le(te * $.width), se = Le(te * $.height); + h === void 0 && (h = v(Ae, se)); + const ce = X ? v(Ae, se) : h; + return ce.width = Ae, ce.height = se, ce.getContext("2d").drawImage(w, 0, 0, Ae, se), console.warn("THREE.WebGLRenderer: Texture has been resized from (" + $.width + "x" + $.height + ") to (" + Ae + "x" + se + ")."), ce; + } else + return "data" in w && console.warn("THREE.WebGLRenderer: Image in DataTexture is too big (" + $.width + "x" + $.height + ")."), w; + return w; + } + function d(w) { + const x = Je(w); + return oo(x.width) && oo(x.height); + } + function M(w) { + return o ? !1 : w.wrapS !== tn || w.wrapT !== tn || w.minFilter !== vt && w.minFilter !== Ct; + } + function _(w, x) { + return w.generateMipmaps && x && w.minFilter !== vt && w.minFilter !== Ct; + } + function A(w) { + i.generateMipmap(w); + } + function C(w, x, X, Q, te = !1) { + if (o === !1) + return x; + if (w !== null) { + if (i[w] !== void 0) + return i[w]; + console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '" + w + "'"); + } + let $ = x; + if (x === i.RED && (X === i.FLOAT && ($ = i.R32F), X === i.HALF_FLOAT && ($ = i.R16F), X === i.UNSIGNED_BYTE && ($ = i.R8)), x === i.RED_INTEGER && (X === i.UNSIGNED_BYTE && ($ = i.R8UI), X === i.UNSIGNED_SHORT && ($ = i.R16UI), X === i.UNSIGNED_INT && ($ = i.R32UI), X === i.BYTE && ($ = i.R8I), X === i.SHORT && ($ = i.R16I), X === i.INT && ($ = i.R32I)), x === i.RG && (X === i.FLOAT && ($ = i.RG32F), X === i.HALF_FLOAT && ($ = i.RG16F), X === i.UNSIGNED_BYTE && ($ = i.RG8)), x === i.RG_INTEGER && (X === i.UNSIGNED_BYTE && ($ = i.RG8UI), X === i.UNSIGNED_SHORT && ($ = i.RG16UI), X === i.UNSIGNED_INT && ($ = i.RG32UI), X === i.BYTE && ($ = i.RG8I), X === i.SHORT && ($ = i.RG16I), X === i.INT && ($ = i.RG32I)), x === i.RGBA) { + const Le = te ? Yr : Ze.getTransfer(Q); + X === i.FLOAT && ($ = i.RGBA32F), X === i.HALF_FLOAT && ($ = i.RGBA16F), X === i.UNSIGNED_BYTE && ($ = Le === nt ? i.SRGB8_ALPHA8 : i.RGBA8), X === i.UNSIGNED_SHORT_4_4_4_4 && ($ = i.RGBA4), X === i.UNSIGNED_SHORT_5_5_5_1 && ($ = i.RGB5_A1); + } + return ($ === i.R16F || $ === i.R32F || $ === i.RG16F || $ === i.RG32F || $ === i.RGBA16F || $ === i.RGBA32F) && e.get("EXT_color_buffer_float"), $; + } + function E(w, x, X) { + return _(w, X) === !0 || w.isFramebufferTexture && w.minFilter !== vt && w.minFilter !== Ct ? Math.log2(Math.max(x.width, x.height)) + 1 : w.mipmaps !== void 0 && w.mipmaps.length > 0 ? w.mipmaps.length : w.isCompressedTexture && Array.isArray(w.image) ? x.mipmaps.length : 1; + } + function b(w) { + return w === vt || w === Go || w === er ? i.NEAREST : i.LINEAR; + } + function I(w) { + const x = w.target; + x.removeEventListener("dispose", I), S(x), x.isVideoTexture && f.delete(x); + } + function W(w) { + const x = w.target; + x.removeEventListener("dispose", W), Y(x); + } + function S(w) { + const x = n.get(w); + if (x.__webglInit === void 0) + return; + const X = w.source, Q = p.get(X); + if (Q) { + const te = Q[x.__cacheKey]; + te.usedTimes--, te.usedTimes === 0 && T(w), Object.keys(Q).length === 0 && p.delete(X); + } + n.remove(w); + } + function T(w) { + const x = n.get(w); + i.deleteTexture(x.__webglTexture); + const X = w.source, Q = p.get(X); + delete Q[x.__cacheKey], a.memory.textures--; + } + function Y(w) { + const x = n.get(w); + if (w.depthTexture && w.depthTexture.dispose(), w.isWebGLCubeRenderTarget) + for (let Q = 0; Q < 6; Q++) { + if (Array.isArray(x.__webglFramebuffer[Q])) + for (let te = 0; te < x.__webglFramebuffer[Q].length; te++) + i.deleteFramebuffer(x.__webglFramebuffer[Q][te]); + else + i.deleteFramebuffer(x.__webglFramebuffer[Q]); + x.__webglDepthbuffer && i.deleteRenderbuffer(x.__webglDepthbuffer[Q]); + } + else { + if (Array.isArray(x.__webglFramebuffer)) + for (let Q = 0; Q < x.__webglFramebuffer.length; Q++) + i.deleteFramebuffer(x.__webglFramebuffer[Q]); + else + i.deleteFramebuffer(x.__webglFramebuffer); + if (x.__webglDepthbuffer && i.deleteRenderbuffer(x.__webglDepthbuffer), x.__webglMultisampledFramebuffer && i.deleteFramebuffer(x.__webglMultisampledFramebuffer), x.__webglColorRenderbuffer) + for (let Q = 0; Q < x.__webglColorRenderbuffer.length; Q++) + x.__webglColorRenderbuffer[Q] && i.deleteRenderbuffer(x.__webglColorRenderbuffer[Q]); + x.__webglDepthRenderbuffer && i.deleteRenderbuffer(x.__webglDepthRenderbuffer); + } + const X = w.textures; + for (let Q = 0, te = X.length; Q < te; Q++) { + const $ = n.get(X[Q]); + $.__webglTexture && (i.deleteTexture($.__webglTexture), a.memory.textures--), n.remove(X[Q]); + } + n.remove(w); + } + let K = 0; + function L() { + K = 0; + } + function N() { + const w = K; + return w >= r.maxTextures && console.warn("THREE.WebGLTextures: Trying to use " + w + " texture units while this GPU supports only " + r.maxTextures), K += 1, w; + } + function O(w) { + const x = []; + return x.push(w.wrapS), x.push(w.wrapT), x.push(w.wrapR || 0), x.push(w.magFilter), x.push(w.minFilter), x.push(w.anisotropy), x.push(w.internalFormat), x.push(w.format), x.push(w.type), x.push(w.generateMipmaps), x.push(w.premultiplyAlpha), x.push(w.flipY), x.push(w.unpackAlignment), x.push(w.colorSpace), x.join(); + } + function B(w, x) { + const X = n.get(w); + if (w.isVideoTexture && Ie(w), w.isRenderTargetTexture === !1 && w.version > 0 && X.__version !== w.version) { + const Q = w.image; + if (Q === null) + console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found."); + else if (Q.complete === !1) + console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete"); + else { + pe(X, w, x); + return; + } + } + t.bindTexture(i.TEXTURE_2D, X.__webglTexture, i.TEXTURE0 + x); + } + function j(w, x) { + const X = n.get(w); + if (w.version > 0 && X.__version !== w.version) { + pe(X, w, x); + return; + } + t.bindTexture(i.TEXTURE_2D_ARRAY, X.__webglTexture, i.TEXTURE0 + x); + } + function q(w, x) { + const X = n.get(w); + if (w.version > 0 && X.__version !== w.version) { + pe(X, w, x); + return; + } + t.bindTexture(i.TEXTURE_3D, X.__webglTexture, i.TEXTURE0 + x); + } + function J(w, x) { + const X = n.get(w); + if (w.version > 0 && X.__version !== w.version) { + Te(X, w, x); + return; + } + t.bindTexture(i.TEXTURE_CUBE_MAP, X.__webglTexture, i.TEXTURE0 + x); + } + const ne = { + [no]: i.REPEAT, + [tn]: i.CLAMP_TO_EDGE, + [io]: i.MIRRORED_REPEAT + }, ue = { + [vt]: i.NEAREST, + [Go]: i.NEAREST_MIPMAP_NEAREST, + [er]: i.NEAREST_MIPMAP_LINEAR, + [Ct]: i.LINEAR, + [vs]: i.LINEAR_MIPMAP_NEAREST, + [ni]: i.LINEAR_MIPMAP_LINEAR + }, Z = { + [Ef]: i.NEVER, + [Pf]: i.ALWAYS, + [bf]: i.LESS, + [ql]: i.LEQUAL, + [Tf]: i.EQUAL, + [Rf]: i.GEQUAL, + [wf]: i.GREATER, + [Cf]: i.NOTEQUAL + }; + function H(w, x, X) { + if (x.type === an && e.has("OES_texture_float_linear") === !1 && (x.magFilter === Ct || x.magFilter === vs || x.magFilter === er || x.magFilter === ni || x.minFilter === Ct || x.minFilter === vs || x.minFilter === er || x.minFilter === ni) && console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."), X ? (i.texParameteri(w, i.TEXTURE_WRAP_S, ne[x.wrapS]), i.texParameteri(w, i.TEXTURE_WRAP_T, ne[x.wrapT]), (w === i.TEXTURE_3D || w === i.TEXTURE_2D_ARRAY) && i.texParameteri(w, i.TEXTURE_WRAP_R, ne[x.wrapR]), i.texParameteri(w, i.TEXTURE_MAG_FILTER, ue[x.magFilter]), i.texParameteri(w, i.TEXTURE_MIN_FILTER, ue[x.minFilter])) : (i.texParameteri(w, i.TEXTURE_WRAP_S, i.CLAMP_TO_EDGE), i.texParameteri(w, i.TEXTURE_WRAP_T, i.CLAMP_TO_EDGE), (w === i.TEXTURE_3D || w === i.TEXTURE_2D_ARRAY) && i.texParameteri(w, i.TEXTURE_WRAP_R, i.CLAMP_TO_EDGE), (x.wrapS !== tn || x.wrapT !== tn) && console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."), i.texParameteri(w, i.TEXTURE_MAG_FILTER, b(x.magFilter)), i.texParameteri(w, i.TEXTURE_MIN_FILTER, b(x.minFilter)), x.minFilter !== vt && x.minFilter !== Ct && console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")), x.compareFunction && (i.texParameteri(w, i.TEXTURE_COMPARE_MODE, i.COMPARE_REF_TO_TEXTURE), i.texParameteri(w, i.TEXTURE_COMPARE_FUNC, Z[x.compareFunction])), e.has("EXT_texture_filter_anisotropic") === !0) { + if (x.magFilter === vt || x.minFilter !== er && x.minFilter !== ni || x.type === an && e.has("OES_texture_float_linear") === !1 || o === !1 && x.type === Gi && e.has("OES_texture_half_float_linear") === !1) + return; + if (x.anisotropy > 1 || n.get(x).__currentAnisotropy) { + const Q = e.get("EXT_texture_filter_anisotropic"); + i.texParameterf(w, Q.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(x.anisotropy, r.getMaxAnisotropy())), n.get(x).__currentAnisotropy = x.anisotropy; + } + } + } + function ee(w, x) { + let X = !1; + w.__webglInit === void 0 && (w.__webglInit = !0, x.addEventListener("dispose", I)); + const Q = x.source; + let te = p.get(Q); + te === void 0 && (te = {}, p.set(Q, te)); + const $ = O(x); + if ($ !== w.__cacheKey) { + te[$] === void 0 && (te[$] = { + texture: i.createTexture(), + usedTimes: 0 + }, a.memory.textures++, X = !0), te[$].usedTimes++; + const Le = te[w.__cacheKey]; + Le !== void 0 && (te[w.__cacheKey].usedTimes--, Le.usedTimes === 0 && T(x)), w.__cacheKey = $, w.__webglTexture = te[$].texture; + } + return X; + } + function pe(w, x, X) { + let Q = i.TEXTURE_2D; + (x.isDataArrayTexture || x.isCompressedArrayTexture) && (Q = i.TEXTURE_2D_ARRAY), x.isData3DTexture && (Q = i.TEXTURE_3D); + const te = ee(w, x), $ = x.source; + t.bindTexture(Q, w.__webglTexture, i.TEXTURE0 + X); + const Le = n.get($); + if ($.version !== Le.__version || te === !0) { + t.activeTexture(i.TEXTURE0 + X); + const Ae = Ze.getPrimaries(Ze.workingColorSpace), se = x.colorSpace === Nn ? null : Ze.getPrimaries(x.colorSpace), ce = x.colorSpace === Nn || Ae === se ? i.NONE : i.BROWSER_DEFAULT_WEBGL; + i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, x.flipY), i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL, x.premultiplyAlpha), i.pixelStorei(i.UNPACK_ALIGNMENT, x.unpackAlignment), i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL, ce); + const Re = M(x) && d(x.image) === !1; + let R = m(x.image, Re, !1, r.maxTextureSize); + R = Be(x, R); + const le = d(R) || o, ve = s.convert(x.format, x.colorSpace); + let fe = s.convert(x.type), he = C(x.internalFormat, ve, fe, x.colorSpace, x.isVideoTexture); + H(Q, x, le); + let _e; + const De = x.mipmaps, Ue = o && x.isVideoTexture !== !0 && he !== Xl, $e = Le.__version === void 0 || te === !0, D = $.dataReady, re = E(x, R, le); + if (x.isDepthTexture) + he = i.DEPTH_COMPONENT, o ? x.type === an ? he = i.DEPTH_COMPONENT32F : x.type === nn ? he = i.DEPTH_COMPONENT24 : x.type === si ? he = i.DEPTH24_STENCIL8 : he = i.DEPTH_COMPONENT16 : x.type === an && console.error("WebGLRenderer: Floating point depth texture requires WebGL2."), x.format === Hn && he === i.DEPTH_COMPONENT && x.type !== ho && x.type !== nn && (console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."), x.type = nn, fe = s.convert(x.type)), x.format === Hi && he === i.DEPTH_COMPONENT && (he = i.DEPTH_STENCIL, x.type !== si && (console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."), x.type = si, fe = s.convert(x.type))), $e && (Ue ? t.texStorage2D(i.TEXTURE_2D, 1, he, R.width, R.height) : t.texImage2D(i.TEXTURE_2D, 0, he, R.width, R.height, 0, ve, fe, null)); + else if (x.isDataTexture) + if (De.length > 0 && le) { + Ue && $e && t.texStorage2D(i.TEXTURE_2D, re, he, De[0].width, De[0].height); + for (let z = 0, ie = De.length; z < ie; z++) + _e = De[z], Ue ? D && t.texSubImage2D(i.TEXTURE_2D, z, 0, 0, _e.width, _e.height, ve, fe, _e.data) : t.texImage2D(i.TEXTURE_2D, z, he, _e.width, _e.height, 0, ve, fe, _e.data); + x.generateMipmaps = !1; + } else + Ue ? ($e && t.texStorage2D(i.TEXTURE_2D, re, he, R.width, R.height), D && t.texSubImage2D(i.TEXTURE_2D, 0, 0, 0, R.width, R.height, ve, fe, R.data)) : t.texImage2D(i.TEXTURE_2D, 0, he, R.width, R.height, 0, ve, fe, R.data); + else if (x.isCompressedTexture) + if (x.isCompressedArrayTexture) { + Ue && $e && t.texStorage3D(i.TEXTURE_2D_ARRAY, re, he, De[0].width, De[0].height, R.depth); + for (let z = 0, ie = De.length; z < ie; z++) + _e = De[z], x.format !== Vt ? ve !== null ? Ue ? D && t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY, z, 0, 0, 0, _e.width, _e.height, R.depth, ve, _e.data, 0, 0) : t.compressedTexImage3D(i.TEXTURE_2D_ARRAY, z, he, _e.width, _e.height, R.depth, 0, _e.data, 0, 0) : console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()") : Ue ? D && t.texSubImage3D(i.TEXTURE_2D_ARRAY, z, 0, 0, 0, _e.width, _e.height, R.depth, ve, fe, _e.data) : t.texImage3D(i.TEXTURE_2D_ARRAY, z, he, _e.width, _e.height, R.depth, 0, ve, fe, _e.data); + } else { + Ue && $e && t.texStorage2D(i.TEXTURE_2D, re, he, De[0].width, De[0].height); + for (let z = 0, ie = De.length; z < ie; z++) + _e = De[z], x.format !== Vt ? ve !== null ? Ue ? D && t.compressedTexSubImage2D(i.TEXTURE_2D, z, 0, 0, _e.width, _e.height, ve, _e.data) : t.compressedTexImage2D(i.TEXTURE_2D, z, he, _e.width, _e.height, 0, _e.data) : console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()") : Ue ? D && t.texSubImage2D(i.TEXTURE_2D, z, 0, 0, _e.width, _e.height, ve, fe, _e.data) : t.texImage2D(i.TEXTURE_2D, z, he, _e.width, _e.height, 0, ve, fe, _e.data); + } + else if (x.isDataArrayTexture) + Ue ? ($e && t.texStorage3D(i.TEXTURE_2D_ARRAY, re, he, R.width, R.height, R.depth), D && t.texSubImage3D(i.TEXTURE_2D_ARRAY, 0, 0, 0, 0, R.width, R.height, R.depth, ve, fe, R.data)) : t.texImage3D(i.TEXTURE_2D_ARRAY, 0, he, R.width, R.height, R.depth, 0, ve, fe, R.data); + else if (x.isData3DTexture) + Ue ? ($e && t.texStorage3D(i.TEXTURE_3D, re, he, R.width, R.height, R.depth), D && t.texSubImage3D(i.TEXTURE_3D, 0, 0, 0, 0, R.width, R.height, R.depth, ve, fe, R.data)) : t.texImage3D(i.TEXTURE_3D, 0, he, R.width, R.height, R.depth, 0, ve, fe, R.data); + else if (x.isFramebufferTexture) { + if ($e) + if (Ue) + t.texStorage2D(i.TEXTURE_2D, re, he, R.width, R.height); + else { + let z = R.width, ie = R.height; + for (let ae = 0; ae < re; ae++) + t.texImage2D(i.TEXTURE_2D, ae, he, z, ie, 0, ve, fe, null), z >>= 1, ie >>= 1; + } + } else if (De.length > 0 && le) { + if (Ue && $e) { + const z = Je(De[0]); + t.texStorage2D(i.TEXTURE_2D, re, he, z.width, z.height); + } + for (let z = 0, ie = De.length; z < ie; z++) + _e = De[z], Ue ? D && t.texSubImage2D(i.TEXTURE_2D, z, 0, 0, ve, fe, _e) : t.texImage2D(i.TEXTURE_2D, z, he, ve, fe, _e); + x.generateMipmaps = !1; + } else if (Ue) { + if ($e) { + const z = Je(R); + t.texStorage2D(i.TEXTURE_2D, re, he, z.width, z.height); + } + D && t.texSubImage2D(i.TEXTURE_2D, 0, 0, 0, ve, fe, R); + } else + t.texImage2D(i.TEXTURE_2D, 0, he, ve, fe, R); + _(x, le) && A(Q), Le.__version = $.version, x.onUpdate && x.onUpdate(x); + } + w.__version = x.version; + } + function Te(w, x, X) { + if (x.image.length !== 6) + return; + const Q = ee(w, x), te = x.source; + t.bindTexture(i.TEXTURE_CUBE_MAP, w.__webglTexture, i.TEXTURE0 + X); + const $ = n.get(te); + if (te.version !== $.__version || Q === !0) { + t.activeTexture(i.TEXTURE0 + X); + const Le = Ze.getPrimaries(Ze.workingColorSpace), Ae = x.colorSpace === Nn ? null : Ze.getPrimaries(x.colorSpace), se = x.colorSpace === Nn || Le === Ae ? i.NONE : i.BROWSER_DEFAULT_WEBGL; + i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, x.flipY), i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL, x.premultiplyAlpha), i.pixelStorei(i.UNPACK_ALIGNMENT, x.unpackAlignment), i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL, se); + const ce = x.isCompressedTexture || x.image[0].isCompressedTexture, Re = x.image[0] && x.image[0].isDataTexture, R = []; + for (let z = 0; z < 6; z++) + !ce && !Re ? R[z] = m(x.image[z], !1, !0, r.maxCubemapSize) : R[z] = Re ? x.image[z].image : x.image[z], R[z] = Be(x, R[z]); + const le = R[0], ve = d(le) || o, fe = s.convert(x.format, x.colorSpace), he = s.convert(x.type), _e = C(x.internalFormat, fe, he, x.colorSpace), De = o && x.isVideoTexture !== !0, Ue = $.__version === void 0 || Q === !0, $e = te.dataReady; + let D = E(x, le, ve); + H(i.TEXTURE_CUBE_MAP, x, ve); + let re; + if (ce) { + De && Ue && t.texStorage2D(i.TEXTURE_CUBE_MAP, D, _e, le.width, le.height); + for (let z = 0; z < 6; z++) { + re = R[z].mipmaps; + for (let ie = 0; ie < re.length; ie++) { + const ae = re[ie]; + x.format !== Vt ? fe !== null ? De ? $e && t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + z, ie, 0, 0, ae.width, ae.height, fe, ae.data) : t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + z, ie, _e, ae.width, ae.height, 0, ae.data) : console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()") : De ? $e && t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + z, ie, 0, 0, ae.width, ae.height, fe, he, ae.data) : t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + z, ie, _e, ae.width, ae.height, 0, fe, he, ae.data); + } + } + } else { + if (re = x.mipmaps, De && Ue) { + re.length > 0 && D++; + const z = Je(R[0]); + t.texStorage2D(i.TEXTURE_CUBE_MAP, D, _e, z.width, z.height); + } + for (let z = 0; z < 6; z++) + if (Re) { + De ? $e && t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + z, 0, 0, 0, R[z].width, R[z].height, fe, he, R[z].data) : t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + z, 0, _e, R[z].width, R[z].height, 0, fe, he, R[z].data); + for (let ie = 0; ie < re.length; ie++) { + const Oe = re[ie].image[z].image; + De ? $e && t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + z, ie + 1, 0, 0, Oe.width, Oe.height, fe, he, Oe.data) : t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + z, ie + 1, _e, Oe.width, Oe.height, 0, fe, he, Oe.data); + } + } else { + De ? $e && t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + z, 0, 0, 0, fe, he, R[z]) : t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + z, 0, _e, fe, he, R[z]); + for (let ie = 0; ie < re.length; ie++) { + const ae = re[ie]; + De ? $e && t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + z, ie + 1, 0, 0, fe, he, ae.image[z]) : t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + z, ie + 1, _e, fe, he, ae.image[z]); + } + } + } + _(x, ve) && A(i.TEXTURE_CUBE_MAP), $.__version = te.version, x.onUpdate && x.onUpdate(x); + } + w.__version = x.version; + } + function xe(w, x, X, Q, te, $) { + const Le = s.convert(X.format, X.colorSpace), Ae = s.convert(X.type), se = C(X.internalFormat, Le, Ae, X.colorSpace); + if (!n.get(x).__hasExternalTextures) { + const Re = Math.max(1, x.width >> $), R = Math.max(1, x.height >> $); + te === i.TEXTURE_3D || te === i.TEXTURE_2D_ARRAY ? t.texImage3D(te, $, se, Re, R, x.depth, 0, Le, Ae, null) : t.texImage2D(te, $, se, Re, R, 0, Le, Ae, null); + } + t.bindFramebuffer(i.FRAMEBUFFER, w), qe(x) ? l.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER, Q, te, n.get(X).__webglTexture, 0, ye(x)) : (te === i.TEXTURE_2D || te >= i.TEXTURE_CUBE_MAP_POSITIVE_X && te <= i.TEXTURE_CUBE_MAP_NEGATIVE_Z) && i.framebufferTexture2D(i.FRAMEBUFFER, Q, te, n.get(X).__webglTexture, $), t.bindFramebuffer(i.FRAMEBUFFER, null); + } + function ge(w, x, X) { + if (i.bindRenderbuffer(i.RENDERBUFFER, w), x.depthBuffer && !x.stencilBuffer) { + let Q = o === !0 ? i.DEPTH_COMPONENT24 : i.DEPTH_COMPONENT16; + if (X || qe(x)) { + const te = x.depthTexture; + te && te.isDepthTexture && (te.type === an ? Q = i.DEPTH_COMPONENT32F : te.type === nn && (Q = i.DEPTH_COMPONENT24)); + const $ = ye(x); + qe(x) ? l.renderbufferStorageMultisampleEXT(i.RENDERBUFFER, $, Q, x.width, x.height) : i.renderbufferStorageMultisample(i.RENDERBUFFER, $, Q, x.width, x.height); + } else + i.renderbufferStorage(i.RENDERBUFFER, Q, x.width, x.height); + i.framebufferRenderbuffer(i.FRAMEBUFFER, i.DEPTH_ATTACHMENT, i.RENDERBUFFER, w); + } else if (x.depthBuffer && x.stencilBuffer) { + const Q = ye(x); + X && qe(x) === !1 ? i.renderbufferStorageMultisample(i.RENDERBUFFER, Q, i.DEPTH24_STENCIL8, x.width, x.height) : qe(x) ? l.renderbufferStorageMultisampleEXT(i.RENDERBUFFER, Q, i.DEPTH24_STENCIL8, x.width, x.height) : i.renderbufferStorage(i.RENDERBUFFER, i.DEPTH_STENCIL, x.width, x.height), i.framebufferRenderbuffer(i.FRAMEBUFFER, i.DEPTH_STENCIL_ATTACHMENT, i.RENDERBUFFER, w); + } else { + const Q = x.textures; + for (let te = 0; te < Q.length; te++) { + const $ = Q[te], Le = s.convert($.format, $.colorSpace), Ae = s.convert($.type), se = C($.internalFormat, Le, Ae, $.colorSpace), ce = ye(x); + X && qe(x) === !1 ? i.renderbufferStorageMultisample(i.RENDERBUFFER, ce, se, x.width, x.height) : qe(x) ? l.renderbufferStorageMultisampleEXT(i.RENDERBUFFER, ce, se, x.width, x.height) : i.renderbufferStorage(i.RENDERBUFFER, se, x.width, x.height); + } + } + i.bindRenderbuffer(i.RENDERBUFFER, null); + } + function Ke(w, x) { + if (x && x.isWebGLCubeRenderTarget) + throw new Error("Depth Texture with cube render targets is not supported"); + if (t.bindFramebuffer(i.FRAMEBUFFER, w), !(x.depthTexture && x.depthTexture.isDepthTexture)) + throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture"); + (!n.get(x.depthTexture).__webglTexture || x.depthTexture.image.width !== x.width || x.depthTexture.image.height !== x.height) && (x.depthTexture.image.width = x.width, x.depthTexture.image.height = x.height, x.depthTexture.needsUpdate = !0), B(x.depthTexture, 0); + const Q = n.get(x.depthTexture).__webglTexture, te = ye(x); + if (x.depthTexture.format === Hn) + qe(x) ? l.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER, i.DEPTH_ATTACHMENT, i.TEXTURE_2D, Q, 0, te) : i.framebufferTexture2D(i.FRAMEBUFFER, i.DEPTH_ATTACHMENT, i.TEXTURE_2D, Q, 0); + else if (x.depthTexture.format === Hi) + qe(x) ? l.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER, i.DEPTH_STENCIL_ATTACHMENT, i.TEXTURE_2D, Q, 0, te) : i.framebufferTexture2D(i.FRAMEBUFFER, i.DEPTH_STENCIL_ATTACHMENT, i.TEXTURE_2D, Q, 0); + else + throw new Error("Unknown depthTexture format"); + } + function we(w) { + const x = n.get(w), X = w.isWebGLCubeRenderTarget === !0; + if (w.depthTexture && !x.__autoAllocateDepthBuffer) { + if (X) + throw new Error("target.depthTexture not supported in Cube render targets"); + Ke(x.__webglFramebuffer, w); + } else if (X) { + x.__webglDepthbuffer = []; + for (let Q = 0; Q < 6; Q++) + t.bindFramebuffer(i.FRAMEBUFFER, x.__webglFramebuffer[Q]), x.__webglDepthbuffer[Q] = i.createRenderbuffer(), ge(x.__webglDepthbuffer[Q], w, !1); + } else + t.bindFramebuffer(i.FRAMEBUFFER, x.__webglFramebuffer), x.__webglDepthbuffer = i.createRenderbuffer(), ge(x.__webglDepthbuffer, w, !1); + t.bindFramebuffer(i.FRAMEBUFFER, null); + } + function F(w, x, X) { + const Q = n.get(w); + x !== void 0 && xe(Q.__webglFramebuffer, w, w.texture, i.COLOR_ATTACHMENT0, i.TEXTURE_2D, 0), X !== void 0 && we(w); + } + function lt(w) { + const x = w.texture, X = n.get(w), Q = n.get(x); + w.addEventListener("dispose", W); + const te = w.textures, $ = w.isWebGLCubeRenderTarget === !0, Le = te.length > 1, Ae = d(w) || o; + if (Le || (Q.__webglTexture === void 0 && (Q.__webglTexture = i.createTexture()), Q.__version = x.version, a.memory.textures++), $) { + X.__webglFramebuffer = []; + for (let se = 0; se < 6; se++) + if (o && x.mipmaps && x.mipmaps.length > 0) { + X.__webglFramebuffer[se] = []; + for (let ce = 0; ce < x.mipmaps.length; ce++) + X.__webglFramebuffer[se][ce] = i.createFramebuffer(); + } else + X.__webglFramebuffer[se] = i.createFramebuffer(); + } else { + if (o && x.mipmaps && x.mipmaps.length > 0) { + X.__webglFramebuffer = []; + for (let se = 0; se < x.mipmaps.length; se++) + X.__webglFramebuffer[se] = i.createFramebuffer(); + } else + X.__webglFramebuffer = i.createFramebuffer(); + if (Le) + if (r.drawBuffers) + for (let se = 0, ce = te.length; se < ce; se++) { + const Re = n.get(te[se]); + Re.__webglTexture === void 0 && (Re.__webglTexture = i.createTexture(), a.memory.textures++); + } + else + console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension."); + if (o && w.samples > 0 && qe(w) === !1) { + X.__webglMultisampledFramebuffer = i.createFramebuffer(), X.__webglColorRenderbuffer = [], t.bindFramebuffer(i.FRAMEBUFFER, X.__webglMultisampledFramebuffer); + for (let se = 0; se < te.length; se++) { + const ce = te[se]; + X.__webglColorRenderbuffer[se] = i.createRenderbuffer(), i.bindRenderbuffer(i.RENDERBUFFER, X.__webglColorRenderbuffer[se]); + const Re = s.convert(ce.format, ce.colorSpace), R = s.convert(ce.type), le = C(ce.internalFormat, Re, R, ce.colorSpace, w.isXRRenderTarget === !0), ve = ye(w); + i.renderbufferStorageMultisample(i.RENDERBUFFER, ve, le, w.width, w.height), i.framebufferRenderbuffer(i.FRAMEBUFFER, i.COLOR_ATTACHMENT0 + se, i.RENDERBUFFER, X.__webglColorRenderbuffer[se]); + } + i.bindRenderbuffer(i.RENDERBUFFER, null), w.depthBuffer && (X.__webglDepthRenderbuffer = i.createRenderbuffer(), ge(X.__webglDepthRenderbuffer, w, !0)), t.bindFramebuffer(i.FRAMEBUFFER, null); + } + } + if ($) { + t.bindTexture(i.TEXTURE_CUBE_MAP, Q.__webglTexture), H(i.TEXTURE_CUBE_MAP, x, Ae); + for (let se = 0; se < 6; se++) + if (o && x.mipmaps && x.mipmaps.length > 0) + for (let ce = 0; ce < x.mipmaps.length; ce++) + xe(X.__webglFramebuffer[se][ce], w, x, i.COLOR_ATTACHMENT0, i.TEXTURE_CUBE_MAP_POSITIVE_X + se, ce); + else + xe(X.__webglFramebuffer[se], w, x, i.COLOR_ATTACHMENT0, i.TEXTURE_CUBE_MAP_POSITIVE_X + se, 0); + _(x, Ae) && A(i.TEXTURE_CUBE_MAP), t.unbindTexture(); + } else if (Le) { + for (let se = 0, ce = te.length; se < ce; se++) { + const Re = te[se], R = n.get(Re); + t.bindTexture(i.TEXTURE_2D, R.__webglTexture), H(i.TEXTURE_2D, Re, Ae), xe(X.__webglFramebuffer, w, Re, i.COLOR_ATTACHMENT0 + se, i.TEXTURE_2D, 0), _(Re, Ae) && A(i.TEXTURE_2D); + } + t.unbindTexture(); + } else { + let se = i.TEXTURE_2D; + if ((w.isWebGL3DRenderTarget || w.isWebGLArrayRenderTarget) && (o ? se = w.isWebGL3DRenderTarget ? i.TEXTURE_3D : i.TEXTURE_2D_ARRAY : console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")), t.bindTexture(se, Q.__webglTexture), H(se, x, Ae), o && x.mipmaps && x.mipmaps.length > 0) + for (let ce = 0; ce < x.mipmaps.length; ce++) + xe(X.__webglFramebuffer[ce], w, x, i.COLOR_ATTACHMENT0, se, ce); + else + xe(X.__webglFramebuffer, w, x, i.COLOR_ATTACHMENT0, se, 0); + _(x, Ae) && A(se), t.unbindTexture(); + } + w.depthBuffer && we(w); + } + function Me(w) { + const x = d(w) || o, X = w.textures; + for (let Q = 0, te = X.length; Q < te; Q++) { + const $ = X[Q]; + if (_($, x)) { + const Le = w.isWebGLCubeRenderTarget ? i.TEXTURE_CUBE_MAP : i.TEXTURE_2D, Ae = n.get($).__webglTexture; + t.bindTexture(Le, Ae), A(Le), t.unbindTexture(); + } + } + } + function Ne(w) { + if (o && w.samples > 0 && qe(w) === !1) { + const x = w.textures, X = w.width, Q = w.height; + let te = i.COLOR_BUFFER_BIT; + const $ = [], Le = w.stencilBuffer ? i.DEPTH_STENCIL_ATTACHMENT : i.DEPTH_ATTACHMENT, Ae = n.get(w), se = x.length > 1; + if (se) + for (let ce = 0; ce < x.length; ce++) + t.bindFramebuffer(i.FRAMEBUFFER, Ae.__webglMultisampledFramebuffer), i.framebufferRenderbuffer(i.FRAMEBUFFER, i.COLOR_ATTACHMENT0 + ce, i.RENDERBUFFER, null), t.bindFramebuffer(i.FRAMEBUFFER, Ae.__webglFramebuffer), i.framebufferTexture2D(i.DRAW_FRAMEBUFFER, i.COLOR_ATTACHMENT0 + ce, i.TEXTURE_2D, null, 0); + t.bindFramebuffer(i.READ_FRAMEBUFFER, Ae.__webglMultisampledFramebuffer), t.bindFramebuffer(i.DRAW_FRAMEBUFFER, Ae.__webglFramebuffer); + for (let ce = 0; ce < x.length; ce++) { + $.push(i.COLOR_ATTACHMENT0 + ce), w.depthBuffer && $.push(Le); + const Re = Ae.__ignoreDepthValues !== void 0 ? Ae.__ignoreDepthValues : !1; + if (Re === !1 && (w.depthBuffer && (te |= i.DEPTH_BUFFER_BIT), w.stencilBuffer && (te |= i.STENCIL_BUFFER_BIT)), se && i.framebufferRenderbuffer(i.READ_FRAMEBUFFER, i.COLOR_ATTACHMENT0, i.RENDERBUFFER, Ae.__webglColorRenderbuffer[ce]), Re === !0 && (i.invalidateFramebuffer(i.READ_FRAMEBUFFER, [Le]), i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER, [Le])), se) { + const R = n.get(x[ce]).__webglTexture; + i.framebufferTexture2D(i.DRAW_FRAMEBUFFER, i.COLOR_ATTACHMENT0, i.TEXTURE_2D, R, 0); + } + i.blitFramebuffer(0, 0, X, Q, 0, 0, X, Q, te, i.NEAREST), c && i.invalidateFramebuffer(i.READ_FRAMEBUFFER, $); + } + if (t.bindFramebuffer(i.READ_FRAMEBUFFER, null), t.bindFramebuffer(i.DRAW_FRAMEBUFFER, null), se) + for (let ce = 0; ce < x.length; ce++) { + t.bindFramebuffer(i.FRAMEBUFFER, Ae.__webglMultisampledFramebuffer), i.framebufferRenderbuffer(i.FRAMEBUFFER, i.COLOR_ATTACHMENT0 + ce, i.RENDERBUFFER, Ae.__webglColorRenderbuffer[ce]); + const Re = n.get(x[ce]).__webglTexture; + t.bindFramebuffer(i.FRAMEBUFFER, Ae.__webglFramebuffer), i.framebufferTexture2D(i.DRAW_FRAMEBUFFER, i.COLOR_ATTACHMENT0 + ce, i.TEXTURE_2D, Re, 0); + } + t.bindFramebuffer(i.DRAW_FRAMEBUFFER, Ae.__webglMultisampledFramebuffer); + } + } + function ye(w) { + return Math.min(r.maxSamples, w.samples); + } + function qe(w) { + const x = n.get(w); + return o && w.samples > 0 && e.has("WEBGL_multisampled_render_to_texture") === !0 && x.__useRenderToTexture !== !1; + } + function Ie(w) { + const x = a.render.frame; + f.get(w) !== x && (f.set(w, x), w.update()); + } + function Be(w, x) { + const X = w.colorSpace, Q = w.format, te = w.type; + return w.isCompressedTexture === !0 || w.isVideoTexture === !0 || w.format === so || X !== Wn && X !== Nn && (Ze.getTransfer(X) === nt ? o === !1 ? e.has("EXT_sRGB") === !0 && Q === Vt ? (w.format = so, w.minFilter = Ct, w.generateMipmaps = !1) : x = Kl.sRGBToLinear(x) : (Q !== Vt || te !== Gn) && console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.") : console.error("THREE.WebGLTextures: Unsupported texture color space:", X)), x; + } + function Je(w) { + return typeof HTMLImageElement < "u" && w instanceof HTMLImageElement ? (u.width = w.naturalWidth || w.width, u.height = w.naturalHeight || w.height) : typeof VideoFrame < "u" && w instanceof VideoFrame ? (u.width = w.displayWidth, u.height = w.displayHeight) : (u.width = w.width, u.height = w.height), u; + } + this.allocateTextureUnit = N, this.resetTextureUnits = L, this.setTexture2D = B, this.setTexture2DArray = j, this.setTexture3D = q, this.setTextureCube = J, this.rebindTextures = F, this.setupRenderTarget = lt, this.updateRenderTargetMipmap = Me, this.updateMultisampleRenderTarget = Ne, this.setupDepthRenderbuffer = we, this.setupFrameBufferTexture = xe, this.useMultisampledRTT = qe; +} +function Zg(i, e, t) { + const n = t.isWebGL2; + function r(s, a = Nn) { + let o; + const l = Ze.getTransfer(a); + if (s === Gn) + return i.UNSIGNED_BYTE; + if (s === Hl) + return i.UNSIGNED_SHORT_4_4_4_4; + if (s === Vl) + return i.UNSIGNED_SHORT_5_5_5_1; + if (s === df) + return i.BYTE; + if (s === pf) + return i.SHORT; + if (s === ho) + return i.UNSIGNED_SHORT; + if (s === Gl) + return i.INT; + if (s === nn) + return i.UNSIGNED_INT; + if (s === an) + return i.FLOAT; + if (s === Gi) + return n ? i.HALF_FLOAT : (o = e.get("OES_texture_half_float"), o !== null ? o.HALF_FLOAT_OES : null); + if (s === mf) + return i.ALPHA; + if (s === Vt) + return i.RGBA; + if (s === gf) + return i.LUMINANCE; + if (s === _f) + return i.LUMINANCE_ALPHA; + if (s === Hn) + return i.DEPTH_COMPONENT; + if (s === Hi) + return i.DEPTH_STENCIL; + if (s === so) + return o = e.get("EXT_sRGB"), o !== null ? o.SRGB_ALPHA_EXT : null; + if (s === vf) + return i.RED; + if (s === po) + return i.RED_INTEGER; + if (s === ro) + return i.RG; + if (s === Wl) + return i.RG_INTEGER; + if (s === mo) + return i.RGBA_INTEGER; + if (s === xs || s === Ss || s === Ms || s === ys) + if (l === nt) + if (o = e.get("WEBGL_compressed_texture_s3tc_srgb"), o !== null) { + if (s === xs) + return o.COMPRESSED_SRGB_S3TC_DXT1_EXT; + if (s === Ss) + return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; + if (s === Ms) + return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; + if (s === ys) + return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; + } else + return null; + else if (o = e.get("WEBGL_compressed_texture_s3tc"), o !== null) { + if (s === xs) + return o.COMPRESSED_RGB_S3TC_DXT1_EXT; + if (s === Ss) + return o.COMPRESSED_RGBA_S3TC_DXT1_EXT; + if (s === Ms) + return o.COMPRESSED_RGBA_S3TC_DXT3_EXT; + if (s === ys) + return o.COMPRESSED_RGBA_S3TC_DXT5_EXT; + } else + return null; + if (s === Ho || s === Vo || s === Wo || s === Xo) + if (o = e.get("WEBGL_compressed_texture_pvrtc"), o !== null) { + if (s === Ho) + return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG; + if (s === Vo) + return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG; + if (s === Wo) + return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; + if (s === Xo) + return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; + } else + return null; + if (s === Xl) + return o = e.get("WEBGL_compressed_texture_etc1"), o !== null ? o.COMPRESSED_RGB_ETC1_WEBGL : null; + if (s === qo || s === Yo) + if (o = e.get("WEBGL_compressed_texture_etc"), o !== null) { + if (s === qo) + return l === nt ? o.COMPRESSED_SRGB8_ETC2 : o.COMPRESSED_RGB8_ETC2; + if (s === Yo) + return l === nt ? o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : o.COMPRESSED_RGBA8_ETC2_EAC; + } else + return null; + if (s === jo || s === Ko || s === Qo || s === Zo || s === Jo || s === $o || s === ea || s === ta || s === na || s === ia || s === ra || s === sa || s === oa || s === aa) + if (o = e.get("WEBGL_compressed_texture_astc"), o !== null) { + if (s === jo) + return l === nt ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : o.COMPRESSED_RGBA_ASTC_4x4_KHR; + if (s === Ko) + return l === nt ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : o.COMPRESSED_RGBA_ASTC_5x4_KHR; + if (s === Qo) + return l === nt ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : o.COMPRESSED_RGBA_ASTC_5x5_KHR; + if (s === Zo) + return l === nt ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : o.COMPRESSED_RGBA_ASTC_6x5_KHR; + if (s === Jo) + return l === nt ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : o.COMPRESSED_RGBA_ASTC_6x6_KHR; + if (s === $o) + return l === nt ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : o.COMPRESSED_RGBA_ASTC_8x5_KHR; + if (s === ea) + return l === nt ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : o.COMPRESSED_RGBA_ASTC_8x6_KHR; + if (s === ta) + return l === nt ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : o.COMPRESSED_RGBA_ASTC_8x8_KHR; + if (s === na) + return l === nt ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : o.COMPRESSED_RGBA_ASTC_10x5_KHR; + if (s === ia) + return l === nt ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : o.COMPRESSED_RGBA_ASTC_10x6_KHR; + if (s === ra) + return l === nt ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : o.COMPRESSED_RGBA_ASTC_10x8_KHR; + if (s === sa) + return l === nt ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : o.COMPRESSED_RGBA_ASTC_10x10_KHR; + if (s === oa) + return l === nt ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : o.COMPRESSED_RGBA_ASTC_12x10_KHR; + if (s === aa) + return l === nt ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : o.COMPRESSED_RGBA_ASTC_12x12_KHR; + } else + return null; + if (s === As || s === la || s === ca) + if (o = e.get("EXT_texture_compression_bptc"), o !== null) { + if (s === As) + return l === nt ? o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : o.COMPRESSED_RGBA_BPTC_UNORM_EXT; + if (s === la) + return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT; + if (s === ca) + return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT; + } else + return null; + if (s === xf || s === ua || s === fa || s === ha) + if (o = e.get("EXT_texture_compression_rgtc"), o !== null) { + if (s === As) + return o.COMPRESSED_RED_RGTC1_EXT; + if (s === ua) + return o.COMPRESSED_SIGNED_RED_RGTC1_EXT; + if (s === fa) + return o.COMPRESSED_RED_GREEN_RGTC2_EXT; + if (s === ha) + return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT; + } else + return null; + return s === si ? n ? i.UNSIGNED_INT_24_8 : (o = e.get("WEBGL_depth_texture"), o !== null ? o.UNSIGNED_INT_24_8_WEBGL : null) : i[s] !== void 0 ? i[s] : null; + } + return { convert: r }; +} +class Jg extends Ht { + constructor(e = []) { + super(), this.isArrayCamera = !0, this.cameras = e; + } +} +class Br extends gt { + constructor() { + super(), this.isGroup = !0, this.type = "Group"; + } +} +const $g = { type: "move" }; +class js { + constructor() { + this._targetRay = null, this._grip = null, this._hand = null; + } + getHandSpace() { + return this._hand === null && (this._hand = new Br(), this._hand.matrixAutoUpdate = !1, this._hand.visible = !1, this._hand.joints = {}, this._hand.inputState = { pinching: !1 }), this._hand; + } + getTargetRaySpace() { + return this._targetRay === null && (this._targetRay = new Br(), this._targetRay.matrixAutoUpdate = !1, this._targetRay.visible = !1, this._targetRay.hasLinearVelocity = !1, this._targetRay.linearVelocity = new P(), this._targetRay.hasAngularVelocity = !1, this._targetRay.angularVelocity = new P()), this._targetRay; + } + getGripSpace() { + return this._grip === null && (this._grip = new Br(), this._grip.matrixAutoUpdate = !1, this._grip.visible = !1, this._grip.hasLinearVelocity = !1, this._grip.linearVelocity = new P(), this._grip.hasAngularVelocity = !1, this._grip.angularVelocity = new P()), this._grip; + } + dispatchEvent(e) { + return this._targetRay !== null && this._targetRay.dispatchEvent(e), this._grip !== null && this._grip.dispatchEvent(e), this._hand !== null && this._hand.dispatchEvent(e), this; + } + connect(e) { + if (e && e.hand) { + const t = this._hand; + if (t) + for (const n of e.hand.values()) + this._getHandJoint(t, n); + } + return this.dispatchEvent({ type: "connected", data: e }), this; + } + disconnect(e) { + return this.dispatchEvent({ type: "disconnected", data: e }), this._targetRay !== null && (this._targetRay.visible = !1), this._grip !== null && (this._grip.visible = !1), this._hand !== null && (this._hand.visible = !1), this; + } + update(e, t, n) { + let r = null, s = null, a = null; + const o = this._targetRay, l = this._grip, c = this._hand; + if (e && t.session.visibilityState !== "visible-blurred") { + if (c && e.hand) { + a = !0; + for (const v of e.hand.values()) { + const m = t.getJointPose(v, n), d = this._getHandJoint(c, v); + m !== null && (d.matrix.fromArray(m.transform.matrix), d.matrix.decompose(d.position, d.rotation, d.scale), d.matrixWorldNeedsUpdate = !0, d.jointRadius = m.radius), d.visible = m !== null; + } + const u = c.joints["index-finger-tip"], f = c.joints["thumb-tip"], h = u.position.distanceTo(f.position), p = 0.02, g = 5e-3; + c.inputState.pinching && h > p + g ? (c.inputState.pinching = !1, this.dispatchEvent({ + type: "pinchend", + handedness: e.handedness, + target: this + })) : !c.inputState.pinching && h <= p - g && (c.inputState.pinching = !0, this.dispatchEvent({ + type: "pinchstart", + handedness: e.handedness, + target: this + })); + } else + l !== null && e.gripSpace && (s = t.getPose(e.gripSpace, n), s !== null && (l.matrix.fromArray(s.transform.matrix), l.matrix.decompose(l.position, l.rotation, l.scale), l.matrixWorldNeedsUpdate = !0, s.linearVelocity ? (l.hasLinearVelocity = !0, l.linearVelocity.copy(s.linearVelocity)) : l.hasLinearVelocity = !1, s.angularVelocity ? (l.hasAngularVelocity = !0, l.angularVelocity.copy(s.angularVelocity)) : l.hasAngularVelocity = !1)); + o !== null && (r = t.getPose(e.targetRaySpace, n), r === null && s !== null && (r = s), r !== null && (o.matrix.fromArray(r.transform.matrix), o.matrix.decompose(o.position, o.rotation, o.scale), o.matrixWorldNeedsUpdate = !0, r.linearVelocity ? (o.hasLinearVelocity = !0, o.linearVelocity.copy(r.linearVelocity)) : o.hasLinearVelocity = !1, r.angularVelocity ? (o.hasAngularVelocity = !0, o.angularVelocity.copy(r.angularVelocity)) : o.hasAngularVelocity = !1, this.dispatchEvent($g))); + } + return o !== null && (o.visible = r !== null), l !== null && (l.visible = s !== null), c !== null && (c.visible = a !== null), this; + } + // private method + _getHandJoint(e, t) { + if (e.joints[t.jointName] === void 0) { + const n = new Br(); + n.matrixAutoUpdate = !1, n.visible = !1, e.joints[t.jointName] = n, e.add(n); + } + return e.joints[t.jointName]; + } +} +const e_ = ` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`, t_ = ` +uniform sampler2DArray depthColor; +uniform float depthWidth; +uniform float depthHeight; + +void main() { + + vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); + + if ( coord.x >= 1.0 ) { + + gl_FragDepthEXT = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; + + } else { + + gl_FragDepthEXT = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; + + } + +}`; +class n_ { + constructor() { + this.texture = null, this.mesh = null, this.depthNear = 0, this.depthFar = 0; + } + init(e, t, n) { + if (this.texture === null) { + const r = new Tt(), s = e.properties.get(r); + s.__webglTexture = t.texture, (t.depthNear != n.depthNear || t.depthFar != n.depthFar) && (this.depthNear = t.depthNear, this.depthFar = t.depthFar), this.texture = r; + } + } + render(e, t) { + if (this.texture !== null) { + if (this.mesh === null) { + const n = t.cameras[0].viewport, r = new Xt({ + extensions: { fragDepth: !0 }, + vertexShader: e_, + fragmentShader: t_, + uniforms: { + depthColor: { value: this.texture }, + depthWidth: { value: n.z }, + depthHeight: { value: n.w } + } + }); + this.mesh = new at(new Wi(20, 20), r); + } + e.render(this.mesh, t); + } + } + reset() { + this.texture = null, this.mesh = null; + } +} +class i_ extends ui { + constructor(e, t) { + super(); + const n = this; + let r = null, s = 1, a = null, o = "local-floor", l = 1, c = null, u = null, f = null, h = null, p = null, g = null; + const v = new n_(), m = t.getContextAttributes(); + let d = null, M = null; + const _ = [], A = [], C = new me(); + let E = null; + const b = new Ht(); + b.layers.enable(1), b.viewport = new ut(); + const I = new Ht(); + I.layers.enable(2), I.viewport = new ut(); + const W = [b, I], S = new Jg(); + S.layers.enable(1), S.layers.enable(2); + let T = null, Y = null; + this.cameraAutoUpdate = !0, this.enabled = !1, this.isPresenting = !1, this.getController = function(H) { + let ee = _[H]; + return ee === void 0 && (ee = new js(), _[H] = ee), ee.getTargetRaySpace(); + }, this.getControllerGrip = function(H) { + let ee = _[H]; + return ee === void 0 && (ee = new js(), _[H] = ee), ee.getGripSpace(); + }, this.getHand = function(H) { + let ee = _[H]; + return ee === void 0 && (ee = new js(), _[H] = ee), ee.getHandSpace(); + }; + function K(H) { + const ee = A.indexOf(H.inputSource); + if (ee === -1) + return; + const pe = _[ee]; + pe !== void 0 && (pe.update(H.inputSource, H.frame, c || a), pe.dispatchEvent({ type: H.type, data: H.inputSource })); + } + function L() { + r.removeEventListener("select", K), r.removeEventListener("selectstart", K), r.removeEventListener("selectend", K), r.removeEventListener("squeeze", K), r.removeEventListener("squeezestart", K), r.removeEventListener("squeezeend", K), r.removeEventListener("end", L), r.removeEventListener("inputsourceschange", N); + for (let H = 0; H < _.length; H++) { + const ee = A[H]; + ee !== null && (A[H] = null, _[H].disconnect(ee)); + } + T = null, Y = null, v.reset(), e.setRenderTarget(d), p = null, h = null, f = null, r = null, M = null, Z.stop(), n.isPresenting = !1, e.setPixelRatio(E), e.setSize(C.width, C.height, !1), n.dispatchEvent({ type: "sessionend" }); + } + this.setFramebufferScaleFactor = function(H) { + s = H, n.isPresenting === !0 && console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting."); + }, this.setReferenceSpaceType = function(H) { + o = H, n.isPresenting === !0 && console.warn("THREE.WebXRManager: Cannot change reference space type while presenting."); + }, this.getReferenceSpace = function() { + return c || a; + }, this.setReferenceSpace = function(H) { + c = H; + }, this.getBaseLayer = function() { + return h !== null ? h : p; + }, this.getBinding = function() { + return f; + }, this.getFrame = function() { + return g; + }, this.getSession = function() { + return r; + }, this.setSession = async function(H) { + if (r = H, r !== null) { + if (d = e.getRenderTarget(), r.addEventListener("select", K), r.addEventListener("selectstart", K), r.addEventListener("selectend", K), r.addEventListener("squeeze", K), r.addEventListener("squeezestart", K), r.addEventListener("squeezeend", K), r.addEventListener("end", L), r.addEventListener("inputsourceschange", N), m.xrCompatible !== !0 && await t.makeXRCompatible(), E = e.getPixelRatio(), e.getSize(C), r.renderState.layers === void 0 || e.capabilities.isWebGL2 === !1) { + const ee = { + antialias: r.renderState.layers === void 0 ? m.antialias : !0, + alpha: !0, + depth: m.depth, + stencil: m.stencil, + framebufferScaleFactor: s + }; + p = new XRWebGLLayer(r, t, ee), r.updateRenderState({ baseLayer: p }), e.setPixelRatio(1), e.setSize(p.framebufferWidth, p.framebufferHeight, !1), M = new Vn( + p.framebufferWidth, + p.framebufferHeight, + { + format: Vt, + type: Gn, + colorSpace: e.outputColorSpace, + stencilBuffer: m.stencil + } + ); + } else { + let ee = null, pe = null, Te = null; + m.depth && (Te = m.stencil ? t.DEPTH24_STENCIL8 : t.DEPTH_COMPONENT24, ee = m.stencil ? Hi : Hn, pe = m.stencil ? si : nn); + const xe = { + colorFormat: t.RGBA8, + depthFormat: Te, + scaleFactor: s + }; + f = new XRWebGLBinding(r, t), h = f.createProjectionLayer(xe), r.updateRenderState({ layers: [h] }), e.setPixelRatio(1), e.setSize(h.textureWidth, h.textureHeight, !1), M = new Vn( + h.textureWidth, + h.textureHeight, + { + format: Vt, + type: Gn, + depthTexture: new So(h.textureWidth, h.textureHeight, pe, void 0, void 0, void 0, void 0, void 0, void 0, ee), + stencilBuffer: m.stencil, + colorSpace: e.outputColorSpace, + samples: m.antialias ? 4 : 0 + } + ); + const ge = e.properties.get(M); + ge.__ignoreDepthValues = h.ignoreDepthValues; + } + M.isXRRenderTarget = !0, this.setFoveation(l), c = null, a = await r.requestReferenceSpace(o), Z.setContext(r), Z.start(), n.isPresenting = !0, n.dispatchEvent({ type: "sessionstart" }); + } + }, this.getEnvironmentBlendMode = function() { + if (r !== null) + return r.environmentBlendMode; + }; + function N(H) { + for (let ee = 0; ee < H.removed.length; ee++) { + const pe = H.removed[ee], Te = A.indexOf(pe); + Te >= 0 && (A[Te] = null, _[Te].disconnect(pe)); + } + for (let ee = 0; ee < H.added.length; ee++) { + const pe = H.added[ee]; + let Te = A.indexOf(pe); + if (Te === -1) { + for (let ge = 0; ge < _.length; ge++) + if (ge >= A.length) { + A.push(pe), Te = ge; + break; + } else if (A[ge] === null) { + A[ge] = pe, Te = ge; + break; + } + if (Te === -1) + break; + } + const xe = _[Te]; + xe && xe.connect(pe); + } + } + const O = new P(), B = new P(); + function j(H, ee, pe) { + O.setFromMatrixPosition(ee.matrixWorld), B.setFromMatrixPosition(pe.matrixWorld); + const Te = O.distanceTo(B), xe = ee.projectionMatrix.elements, ge = pe.projectionMatrix.elements, Ke = xe[14] / (xe[10] - 1), we = xe[14] / (xe[10] + 1), F = (xe[9] + 1) / xe[5], lt = (xe[9] - 1) / xe[5], Me = (xe[8] - 1) / xe[0], Ne = (ge[8] + 1) / ge[0], ye = Ke * Me, qe = Ke * Ne, Ie = Te / (-Me + Ne), Be = Ie * -Me; + ee.matrixWorld.decompose(H.position, H.quaternion, H.scale), H.translateX(Be), H.translateZ(Ie), H.matrixWorld.compose(H.position, H.quaternion, H.scale), H.matrixWorldInverse.copy(H.matrixWorld).invert(); + const Je = Ke + Ie, w = we + Ie, x = ye - Be, X = qe + (Te - Be), Q = F * we / w * Je, te = lt * we / w * Je; + H.projectionMatrix.makePerspective(x, X, Q, te, Je, w), H.projectionMatrixInverse.copy(H.projectionMatrix).invert(); + } + function q(H, ee) { + ee === null ? H.matrixWorld.copy(H.matrix) : H.matrixWorld.multiplyMatrices(ee.matrixWorld, H.matrix), H.matrixWorldInverse.copy(H.matrixWorld).invert(); + } + this.updateCamera = function(H) { + if (r === null) + return; + v.texture !== null && (H.near = v.depthNear, H.far = v.depthFar), S.near = I.near = b.near = H.near, S.far = I.far = b.far = H.far, (T !== S.near || Y !== S.far) && (r.updateRenderState({ + depthNear: S.near, + depthFar: S.far + }), T = S.near, Y = S.far, b.near = T, b.far = Y, I.near = T, I.far = Y, b.updateProjectionMatrix(), I.updateProjectionMatrix(), H.updateProjectionMatrix()); + const ee = H.parent, pe = S.cameras; + q(S, ee); + for (let Te = 0; Te < pe.length; Te++) + q(pe[Te], ee); + pe.length === 2 ? j(S, b, I) : S.projectionMatrix.copy(b.projectionMatrix), J(H, S, ee); + }; + function J(H, ee, pe) { + pe === null ? H.matrix.copy(ee.matrixWorld) : (H.matrix.copy(pe.matrixWorld), H.matrix.invert(), H.matrix.multiply(ee.matrixWorld)), H.matrix.decompose(H.position, H.quaternion, H.scale), H.updateMatrixWorld(!0), H.projectionMatrix.copy(ee.projectionMatrix), H.projectionMatrixInverse.copy(ee.projectionMatrixInverse), H.isPerspectiveCamera && (H.fov = fr * 2 * Math.atan(1 / H.projectionMatrix.elements[5]), H.zoom = 1); + } + this.getCamera = function() { + return S; + }, this.getFoveation = function() { + if (!(h === null && p === null)) + return l; + }, this.setFoveation = function(H) { + l = H, h !== null && (h.fixedFoveation = H), p !== null && p.fixedFoveation !== void 0 && (p.fixedFoveation = H); + }, this.hasDepthSensing = function() { + return v.texture !== null; + }; + let ne = null; + function ue(H, ee) { + if (u = ee.getViewerPose(c || a), g = ee, u !== null) { + const pe = u.views; + p !== null && (e.setRenderTargetFramebuffer(M, p.framebuffer), e.setRenderTarget(M)); + let Te = !1; + pe.length !== S.cameras.length && (S.cameras.length = 0, Te = !0); + for (let ge = 0; ge < pe.length; ge++) { + const Ke = pe[ge]; + let we = null; + if (p !== null) + we = p.getViewport(Ke); + else { + const lt = f.getViewSubImage(h, Ke); + we = lt.viewport, ge === 0 && (e.setRenderTargetTextures( + M, + lt.colorTexture, + h.ignoreDepthValues ? void 0 : lt.depthStencilTexture + ), e.setRenderTarget(M)); + } + let F = W[ge]; + F === void 0 && (F = new Ht(), F.layers.enable(ge), F.viewport = new ut(), W[ge] = F), F.matrix.fromArray(Ke.transform.matrix), F.matrix.decompose(F.position, F.quaternion, F.scale), F.projectionMatrix.fromArray(Ke.projectionMatrix), F.projectionMatrixInverse.copy(F.projectionMatrix).invert(), F.viewport.set(we.x, we.y, we.width, we.height), ge === 0 && (S.matrix.copy(F.matrix), S.matrix.decompose(S.position, S.quaternion, S.scale)), Te === !0 && S.cameras.push(F); + } + const xe = r.enabledFeatures; + if (xe && xe.includes("depth-sensing")) { + const ge = f.getDepthInformation(pe[0]); + ge && ge.isValid && ge.texture && v.init(e, ge, r.renderState); + } + } + for (let pe = 0; pe < _.length; pe++) { + const Te = A[pe], xe = _[pe]; + Te !== null && xe !== void 0 && xe.update(Te, ee, c || a); + } + v.render(e, S), ne && ne(H, ee), ee.detectedPlanes && n.dispatchEvent({ type: "planesdetected", data: ee }), g = null; + } + const Z = new ac(); + Z.setAnimationLoop(ue), this.setAnimationLoop = function(H) { + ne = H; + }, this.dispose = function() { + }; + } +} +const Jn = /* @__PURE__ */ new bn(), r_ = /* @__PURE__ */ new ke(); +function s_(i, e) { + function t(m, d) { + m.matrixAutoUpdate === !0 && m.updateMatrix(), d.value.copy(m.matrix); + } + function n(m, d) { + d.color.getRGB(m.fogColor.value, ic(i)), d.isFog ? (m.fogNear.value = d.near, m.fogFar.value = d.far) : d.isFogExp2 && (m.fogDensity.value = d.density); + } + function r(m, d, M, _, A) { + d.isMeshBasicMaterial || d.isMeshLambertMaterial ? s(m, d) : d.isMeshToonMaterial ? (s(m, d), f(m, d)) : d.isMeshPhongMaterial ? (s(m, d), u(m, d)) : d.isMeshStandardMaterial ? (s(m, d), h(m, d), d.isMeshPhysicalMaterial && p(m, d, A)) : d.isMeshMatcapMaterial ? (s(m, d), g(m, d)) : d.isMeshDepthMaterial ? s(m, d) : d.isMeshDistanceMaterial ? (s(m, d), v(m, d)) : d.isMeshNormalMaterial ? s(m, d) : d.isLineBasicMaterial ? (a(m, d), d.isLineDashedMaterial && o(m, d)) : d.isPointsMaterial ? l(m, d, M, _) : d.isSpriteMaterial ? c(m, d) : d.isShadowMaterial ? (m.color.value.copy(d.color), m.opacity.value = d.opacity) : d.isShaderMaterial && (d.uniformsNeedUpdate = !1); + } + function s(m, d) { + m.opacity.value = d.opacity, d.color && m.diffuse.value.copy(d.color), d.emissive && m.emissive.value.copy(d.emissive).multiplyScalar(d.emissiveIntensity), d.map && (m.map.value = d.map, t(d.map, m.mapTransform)), d.alphaMap && (m.alphaMap.value = d.alphaMap, t(d.alphaMap, m.alphaMapTransform)), d.bumpMap && (m.bumpMap.value = d.bumpMap, t(d.bumpMap, m.bumpMapTransform), m.bumpScale.value = d.bumpScale, d.side === Pt && (m.bumpScale.value *= -1)), d.normalMap && (m.normalMap.value = d.normalMap, t(d.normalMap, m.normalMapTransform), m.normalScale.value.copy(d.normalScale), d.side === Pt && m.normalScale.value.negate()), d.displacementMap && (m.displacementMap.value = d.displacementMap, t(d.displacementMap, m.displacementMapTransform), m.displacementScale.value = d.displacementScale, m.displacementBias.value = d.displacementBias), d.emissiveMap && (m.emissiveMap.value = d.emissiveMap, t(d.emissiveMap, m.emissiveMapTransform)), d.specularMap && (m.specularMap.value = d.specularMap, t(d.specularMap, m.specularMapTransform)), d.alphaTest > 0 && (m.alphaTest.value = d.alphaTest); + const M = e.get(d), _ = M.envMap, A = M.envMapRotation; + if (_ && (m.envMap.value = _, Jn.copy(A), Jn.x *= -1, Jn.y *= -1, Jn.z *= -1, _.isCubeTexture && _.isRenderTargetTexture === !1 && (Jn.y *= -1, Jn.z *= -1), m.envMapRotation.value.setFromMatrix4(r_.makeRotationFromEuler(Jn)), m.flipEnvMap.value = _.isCubeTexture && _.isRenderTargetTexture === !1 ? -1 : 1, m.reflectivity.value = d.reflectivity, m.ior.value = d.ior, m.refractionRatio.value = d.refractionRatio), d.lightMap) { + m.lightMap.value = d.lightMap; + const C = i._useLegacyLights === !0 ? Math.PI : 1; + m.lightMapIntensity.value = d.lightMapIntensity * C, t(d.lightMap, m.lightMapTransform); + } + d.aoMap && (m.aoMap.value = d.aoMap, m.aoMapIntensity.value = d.aoMapIntensity, t(d.aoMap, m.aoMapTransform)); + } + function a(m, d) { + m.diffuse.value.copy(d.color), m.opacity.value = d.opacity, d.map && (m.map.value = d.map, t(d.map, m.mapTransform)); + } + function o(m, d) { + m.dashSize.value = d.dashSize, m.totalSize.value = d.dashSize + d.gapSize, m.scale.value = d.scale; + } + function l(m, d, M, _) { + m.diffuse.value.copy(d.color), m.opacity.value = d.opacity, m.size.value = d.size * M, m.scale.value = _ * 0.5, d.map && (m.map.value = d.map, t(d.map, m.uvTransform)), d.alphaMap && (m.alphaMap.value = d.alphaMap, t(d.alphaMap, m.alphaMapTransform)), d.alphaTest > 0 && (m.alphaTest.value = d.alphaTest); + } + function c(m, d) { + m.diffuse.value.copy(d.color), m.opacity.value = d.opacity, m.rotation.value = d.rotation, d.map && (m.map.value = d.map, t(d.map, m.mapTransform)), d.alphaMap && (m.alphaMap.value = d.alphaMap, t(d.alphaMap, m.alphaMapTransform)), d.alphaTest > 0 && (m.alphaTest.value = d.alphaTest); + } + function u(m, d) { + m.specular.value.copy(d.specular), m.shininess.value = Math.max(d.shininess, 1e-4); + } + function f(m, d) { + d.gradientMap && (m.gradientMap.value = d.gradientMap); + } + function h(m, d) { + m.metalness.value = d.metalness, d.metalnessMap && (m.metalnessMap.value = d.metalnessMap, t(d.metalnessMap, m.metalnessMapTransform)), m.roughness.value = d.roughness, d.roughnessMap && (m.roughnessMap.value = d.roughnessMap, t(d.roughnessMap, m.roughnessMapTransform)), e.get(d).envMap && (m.envMapIntensity.value = d.envMapIntensity); + } + function p(m, d, M) { + m.ior.value = d.ior, d.sheen > 0 && (m.sheenColor.value.copy(d.sheenColor).multiplyScalar(d.sheen), m.sheenRoughness.value = d.sheenRoughness, d.sheenColorMap && (m.sheenColorMap.value = d.sheenColorMap, t(d.sheenColorMap, m.sheenColorMapTransform)), d.sheenRoughnessMap && (m.sheenRoughnessMap.value = d.sheenRoughnessMap, t(d.sheenRoughnessMap, m.sheenRoughnessMapTransform))), d.clearcoat > 0 && (m.clearcoat.value = d.clearcoat, m.clearcoatRoughness.value = d.clearcoatRoughness, d.clearcoatMap && (m.clearcoatMap.value = d.clearcoatMap, t(d.clearcoatMap, m.clearcoatMapTransform)), d.clearcoatRoughnessMap && (m.clearcoatRoughnessMap.value = d.clearcoatRoughnessMap, t(d.clearcoatRoughnessMap, m.clearcoatRoughnessMapTransform)), d.clearcoatNormalMap && (m.clearcoatNormalMap.value = d.clearcoatNormalMap, t(d.clearcoatNormalMap, m.clearcoatNormalMapTransform), m.clearcoatNormalScale.value.copy(d.clearcoatNormalScale), d.side === Pt && m.clearcoatNormalScale.value.negate())), d.iridescence > 0 && (m.iridescence.value = d.iridescence, m.iridescenceIOR.value = d.iridescenceIOR, m.iridescenceThicknessMinimum.value = d.iridescenceThicknessRange[0], m.iridescenceThicknessMaximum.value = d.iridescenceThicknessRange[1], d.iridescenceMap && (m.iridescenceMap.value = d.iridescenceMap, t(d.iridescenceMap, m.iridescenceMapTransform)), d.iridescenceThicknessMap && (m.iridescenceThicknessMap.value = d.iridescenceThicknessMap, t(d.iridescenceThicknessMap, m.iridescenceThicknessMapTransform))), d.transmission > 0 && (m.transmission.value = d.transmission, m.transmissionSamplerMap.value = M.texture, m.transmissionSamplerSize.value.set(M.width, M.height), d.transmissionMap && (m.transmissionMap.value = d.transmissionMap, t(d.transmissionMap, m.transmissionMapTransform)), m.thickness.value = d.thickness, d.thicknessMap && (m.thicknessMap.value = d.thicknessMap, t(d.thicknessMap, m.thicknessMapTransform)), m.attenuationDistance.value = d.attenuationDistance, m.attenuationColor.value.copy(d.attenuationColor)), d.anisotropy > 0 && (m.anisotropyVector.value.set(d.anisotropy * Math.cos(d.anisotropyRotation), d.anisotropy * Math.sin(d.anisotropyRotation)), d.anisotropyMap && (m.anisotropyMap.value = d.anisotropyMap, t(d.anisotropyMap, m.anisotropyMapTransform))), m.specularIntensity.value = d.specularIntensity, m.specularColor.value.copy(d.specularColor), d.specularColorMap && (m.specularColorMap.value = d.specularColorMap, t(d.specularColorMap, m.specularColorMapTransform)), d.specularIntensityMap && (m.specularIntensityMap.value = d.specularIntensityMap, t(d.specularIntensityMap, m.specularIntensityMapTransform)); + } + function g(m, d) { + d.matcap && (m.matcap.value = d.matcap); + } + function v(m, d) { + const M = e.get(d).light; + m.referencePosition.value.setFromMatrixPosition(M.matrixWorld), m.nearDistance.value = M.shadow.camera.near, m.farDistance.value = M.shadow.camera.far; + } + return { + refreshFogUniforms: n, + refreshMaterialUniforms: r + }; +} +function o_(i, e, t, n) { + let r = {}, s = {}, a = []; + const o = t.isWebGL2 ? i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS) : 0; + function l(M, _) { + const A = _.program; + n.uniformBlockBinding(M, A); + } + function c(M, _) { + let A = r[M.id]; + A === void 0 && (g(M), A = u(M), r[M.id] = A, M.addEventListener("dispose", m)); + const C = _.program; + n.updateUBOMapping(M, C); + const E = e.render.frame; + s[M.id] !== E && (h(M), s[M.id] = E); + } + function u(M) { + const _ = f(); + M.__bindingPointIndex = _; + const A = i.createBuffer(), C = M.__size, E = M.usage; + return i.bindBuffer(i.UNIFORM_BUFFER, A), i.bufferData(i.UNIFORM_BUFFER, C, E), i.bindBuffer(i.UNIFORM_BUFFER, null), i.bindBufferBase(i.UNIFORM_BUFFER, _, A), A; + } + function f() { + for (let M = 0; M < o; M++) + if (a.indexOf(M) === -1) + return a.push(M), M; + return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."), 0; + } + function h(M) { + const _ = r[M.id], A = M.uniforms, C = M.__cache; + i.bindBuffer(i.UNIFORM_BUFFER, _); + for (let E = 0, b = A.length; E < b; E++) { + const I = Array.isArray(A[E]) ? A[E] : [A[E]]; + for (let W = 0, S = I.length; W < S; W++) { + const T = I[W]; + if (p(T, E, W, C) === !0) { + const Y = T.__offset, K = Array.isArray(T.value) ? T.value : [T.value]; + let L = 0; + for (let N = 0; N < K.length; N++) { + const O = K[N], B = v(O); + typeof O == "number" || typeof O == "boolean" ? (T.__data[0] = O, i.bufferSubData(i.UNIFORM_BUFFER, Y + L, T.__data)) : O.isMatrix3 ? (T.__data[0] = O.elements[0], T.__data[1] = O.elements[1], T.__data[2] = O.elements[2], T.__data[3] = 0, T.__data[4] = O.elements[3], T.__data[5] = O.elements[4], T.__data[6] = O.elements[5], T.__data[7] = 0, T.__data[8] = O.elements[6], T.__data[9] = O.elements[7], T.__data[10] = O.elements[8], T.__data[11] = 0) : (O.toArray(T.__data, L), L += B.storage / Float32Array.BYTES_PER_ELEMENT); + } + i.bufferSubData(i.UNIFORM_BUFFER, Y, T.__data); + } + } + } + i.bindBuffer(i.UNIFORM_BUFFER, null); + } + function p(M, _, A, C) { + const E = M.value, b = _ + "_" + A; + if (C[b] === void 0) + return typeof E == "number" || typeof E == "boolean" ? C[b] = E : C[b] = E.clone(), !0; + { + const I = C[b]; + if (typeof E == "number" || typeof E == "boolean") { + if (I !== E) + return C[b] = E, !0; + } else if (I.equals(E) === !1) + return I.copy(E), !0; + } + return !1; + } + function g(M) { + const _ = M.uniforms; + let A = 0; + const C = 16; + for (let b = 0, I = _.length; b < I; b++) { + const W = Array.isArray(_[b]) ? _[b] : [_[b]]; + for (let S = 0, T = W.length; S < T; S++) { + const Y = W[S], K = Array.isArray(Y.value) ? Y.value : [Y.value]; + for (let L = 0, N = K.length; L < N; L++) { + const O = K[L], B = v(O), j = A % C; + j !== 0 && C - j < B.boundary && (A += C - j), Y.__data = new Float32Array(B.storage / Float32Array.BYTES_PER_ELEMENT), Y.__offset = A, A += B.storage; + } + } + } + const E = A % C; + return E > 0 && (A += C - E), M.__size = A, M.__cache = {}, this; + } + function v(M) { + const _ = { + boundary: 0, + // bytes + storage: 0 + // bytes + }; + return typeof M == "number" || typeof M == "boolean" ? (_.boundary = 4, _.storage = 4) : M.isVector2 ? (_.boundary = 8, _.storage = 8) : M.isVector3 || M.isColor ? (_.boundary = 16, _.storage = 12) : M.isVector4 ? (_.boundary = 16, _.storage = 16) : M.isMatrix3 ? (_.boundary = 48, _.storage = 48) : M.isMatrix4 ? (_.boundary = 64, _.storage = 64) : M.isTexture ? console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group.") : console.warn("THREE.WebGLRenderer: Unsupported uniform value type.", M), _; + } + function m(M) { + const _ = M.target; + _.removeEventListener("dispose", m); + const A = a.indexOf(_.__bindingPointIndex); + a.splice(A, 1), i.deleteBuffer(r[_.id]), delete r[_.id], delete s[_.id]; + } + function d() { + for (const M in r) + i.deleteBuffer(r[M]); + a = [], r = {}, s = {}; + } + return { + bind: l, + update: c, + dispose: d + }; +} +class pc { + constructor(e = {}) { + const { + canvas: t = qf(), + context: n = null, + depth: r = !0, + stencil: s = !0, + alpha: a = !1, + antialias: o = !1, + premultipliedAlpha: l = !0, + preserveDrawingBuffer: c = !1, + powerPreference: u = "default", + failIfMajorPerformanceCaveat: f = !1 + } = e; + this.isWebGLRenderer = !0; + let h; + n !== null ? h = n.getContextAttributes().alpha : h = a; + const p = new Uint32Array(4), g = new Int32Array(4); + let v = null, m = null; + const d = [], M = []; + this.domElement = t, this.debug = { + /** + * Enables error checking and reporting when shader programs are being compiled + * @type {boolean} + */ + checkShaderErrors: !0, + /** + * Callback for custom error reporting. + * @type {?Function} + */ + onShaderError: null + }, this.autoClear = !0, this.autoClearColor = !0, this.autoClearDepth = !0, this.autoClearStencil = !0, this.sortObjects = !0, this.clippingPlanes = [], this.localClippingEnabled = !1, this._outputColorSpace = sn, this._useLegacyLights = !1, this.toneMapping = kn, this.toneMappingExposure = 1; + const _ = this; + let A = !1, C = 0, E = 0, b = null, I = -1, W = null; + const S = new ut(), T = new ut(); + let Y = null; + const K = new Qe(0); + let L = 0, N = t.width, O = t.height, B = 1, j = null, q = null; + const J = new ut(0, 0, N, O), ne = new ut(0, 0, N, O); + let ue = !1; + const Z = new oc(); + let H = !1, ee = !1, pe = null; + const Te = new ke(), xe = new me(), ge = new P(), Ke = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: !0 }; + function we() { + return b === null ? B : 1; + } + let F = n; + function lt(y, U) { + for (let G = 0; G < y.length; G++) { + const V = y[G], k = t.getContext(V, U); + if (k !== null) + return k; + } + return null; + } + try { + const y = { + alpha: !0, + depth: r, + stencil: s, + antialias: o, + premultipliedAlpha: l, + preserveDrawingBuffer: c, + powerPreference: u, + failIfMajorPerformanceCaveat: f + }; + if ("setAttribute" in t && t.setAttribute("data-engine", `three.js r${fo}`), t.addEventListener("webglcontextlost", $e, !1), t.addEventListener("webglcontextrestored", D, !1), t.addEventListener("webglcontextcreationerror", re, !1), F === null) { + const U = ["webgl2", "webgl", "experimental-webgl"]; + if (_.isWebGL1Renderer === !0 && U.shift(), F = lt(U, y), F === null) + throw lt(U) ? new Error("Error creating WebGL context with your selected attributes.") : new Error("Error creating WebGL context."); + } + typeof WebGLRenderingContext < "u" && F instanceof WebGLRenderingContext && console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."), F.getShaderPrecisionFormat === void 0 && (F.getShaderPrecisionFormat = function() { + return { rangeMin: 1, rangeMax: 1, precision: 1 }; + }); + } catch (y) { + throw console.error("THREE.WebGLRenderer: " + y.message), y; + } + let Me, Ne, ye, qe, Ie, Be, Je, w, x, X, Q, te, $, Le, Ae, se, ce, Re, R, le, ve, fe, he, _e; + function De() { + Me = new hm(F), Ne = new om(F, Me, e), Me.init(Ne), fe = new Zg(F, Me, Ne), ye = new Kg(F, Me, Ne), qe = new mm(F), Ie = new Fg(), Be = new Qg(F, Me, ye, Ie, Ne, fe, qe), Je = new lm(_), w = new fm(_), x = new Mh(F, Ne), he = new rm(F, Me, x, Ne), X = new dm(F, x, qe, he), Q = new xm(F, X, x, qe), R = new vm(F, Ne, Be), se = new am(Ie), te = new Ug(_, Je, w, Me, Ne, he, se), $ = new s_(_, Ie), Le = new Bg(), Ae = new Vg(Me, Ne), Re = new im(_, Je, w, ye, Q, h, l), ce = new jg(_, Q, Ne), _e = new o_(F, qe, Ne, ye), le = new sm(F, Me, qe, Ne), ve = new pm(F, Me, qe, Ne), qe.programs = te.programs, _.capabilities = Ne, _.extensions = Me, _.properties = Ie, _.renderLists = Le, _.shadowMap = ce, _.state = ye, _.info = qe; + } + De(); + const Ue = new i_(_, F); + this.xr = Ue, this.getContext = function() { + return F; + }, this.getContextAttributes = function() { + return F.getContextAttributes(); + }, this.forceContextLoss = function() { + const y = Me.get("WEBGL_lose_context"); + y && y.loseContext(); + }, this.forceContextRestore = function() { + const y = Me.get("WEBGL_lose_context"); + y && y.restoreContext(); + }, this.getPixelRatio = function() { + return B; + }, this.setPixelRatio = function(y) { + y !== void 0 && (B = y, this.setSize(N, O, !1)); + }, this.getSize = function(y) { + return y.set(N, O); + }, this.setSize = function(y, U, G = !0) { + if (Ue.isPresenting) { + console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."); + return; + } + N = y, O = U, t.width = Math.floor(y * B), t.height = Math.floor(U * B), G === !0 && (t.style.width = y + "px", t.style.height = U + "px"), this.setViewport(0, 0, y, U); + }, this.getDrawingBufferSize = function(y) { + return y.set(N * B, O * B).floor(); + }, this.setDrawingBufferSize = function(y, U, G) { + N = y, O = U, B = G, t.width = Math.floor(y * G), t.height = Math.floor(U * G), this.setViewport(0, 0, y, U); + }, this.getCurrentViewport = function(y) { + return y.copy(S); + }, this.getViewport = function(y) { + return y.copy(J); + }, this.setViewport = function(y, U, G, V) { + y.isVector4 ? J.set(y.x, y.y, y.z, y.w) : J.set(y, U, G, V), ye.viewport(S.copy(J).multiplyScalar(B).round()); + }, this.getScissor = function(y) { + return y.copy(ne); + }, this.setScissor = function(y, U, G, V) { + y.isVector4 ? ne.set(y.x, y.y, y.z, y.w) : ne.set(y, U, G, V), ye.scissor(T.copy(ne).multiplyScalar(B).round()); + }, this.getScissorTest = function() { + return ue; + }, this.setScissorTest = function(y) { + ye.setScissorTest(ue = y); + }, this.setOpaqueSort = function(y) { + j = y; + }, this.setTransparentSort = function(y) { + q = y; + }, this.getClearColor = function(y) { + return y.copy(Re.getClearColor()); + }, this.setClearColor = function() { + Re.setClearColor.apply(Re, arguments); + }, this.getClearAlpha = function() { + return Re.getClearAlpha(); + }, this.setClearAlpha = function() { + Re.setClearAlpha.apply(Re, arguments); + }, this.clear = function(y = !0, U = !0, G = !0) { + let V = 0; + if (y) { + let k = !1; + if (b !== null) { + const de = b.texture.format; + k = de === mo || de === Wl || de === po; + } + if (k) { + const de = b.texture.type, Se = de === Gn || de === nn || de === ho || de === si || de === Hl || de === Vl, Ee = Re.getClearColor(), Ce = Re.getClearAlpha(), Xe = Ee.r, Fe = Ee.g, ze = Ee.b; + Se ? (p[0] = Xe, p[1] = Fe, p[2] = ze, p[3] = Ce, F.clearBufferuiv(F.COLOR, 0, p)) : (g[0] = Xe, g[1] = Fe, g[2] = ze, g[3] = Ce, F.clearBufferiv(F.COLOR, 0, g)); + } else + V |= F.COLOR_BUFFER_BIT; + } + U && (V |= F.DEPTH_BUFFER_BIT), G && (V |= F.STENCIL_BUFFER_BIT, this.state.buffers.stencil.setMask(4294967295)), F.clear(V); + }, this.clearColor = function() { + this.clear(!0, !1, !1); + }, this.clearDepth = function() { + this.clear(!1, !0, !1); + }, this.clearStencil = function() { + this.clear(!1, !1, !0); + }, this.dispose = function() { + t.removeEventListener("webglcontextlost", $e, !1), t.removeEventListener("webglcontextrestored", D, !1), t.removeEventListener("webglcontextcreationerror", re, !1), Le.dispose(), Ae.dispose(), Ie.dispose(), Je.dispose(), w.dispose(), Q.dispose(), he.dispose(), _e.dispose(), te.dispose(), Ue.dispose(), Ue.removeEventListener("sessionstart", Nt), Ue.removeEventListener("sessionend", tt), pe && (pe.dispose(), pe = null), At.stop(); + }; + function $e(y) { + y.preventDefault(), console.log("THREE.WebGLRenderer: Context Lost."), A = !0; + } + function D() { + console.log("THREE.WebGLRenderer: Context Restored."), A = !1; + const y = qe.autoReset, U = ce.enabled, G = ce.autoUpdate, V = ce.needsUpdate, k = ce.type; + De(), qe.autoReset = y, ce.enabled = U, ce.autoUpdate = G, ce.needsUpdate = V, ce.type = k; + } + function re(y) { + console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ", y.statusMessage); + } + function z(y) { + const U = y.target; + U.removeEventListener("dispose", z), ie(U); + } + function ie(y) { + ae(y), Ie.remove(y); + } + function ae(y) { + const U = Ie.get(y).programs; + U !== void 0 && (U.forEach(function(G) { + te.releaseProgram(G); + }), y.isShaderMaterial && te.releaseShaderCache(y)); + } + this.renderBufferDirect = function(y, U, G, V, k, de) { + U === null && (U = Ke); + const Se = k.isMesh && k.matrixWorld.determinant() < 0, Ee = Ac(y, U, G, V, k); + ye.setMaterial(V, Se); + let Ce = G.index, Xe = 1; + if (V.wireframe === !0) { + if (Ce = X.getWireframeAttribute(G), Ce === void 0) + return; + Xe = 2; + } + const Fe = G.drawRange, ze = G.attributes.position; + let ot = Fe.start * Xe, Lt = (Fe.start + Fe.count) * Xe; + de !== null && (ot = Math.max(ot, de.start * Xe), Lt = Math.min(Lt, (de.start + de.count) * Xe)), Ce !== null ? (ot = Math.max(ot, 0), Lt = Math.min(Lt, Ce.count)) : ze != null && (ot = Math.max(ot, 0), Lt = Math.min(Lt, ze.count)); + const dt = Lt - ot; + if (dt < 0 || dt === 1 / 0) + return; + he.setup(k, V, Ee, G, Ce); + let dn, rt = le; + if (Ce !== null && (dn = x.get(Ce), rt = ve, rt.setIndex(dn)), k.isMesh) + V.wireframe === !0 ? (ye.setLineWidth(V.wireframeLinewidth * we()), rt.setMode(F.LINES)) : rt.setMode(F.TRIANGLES); + else if (k.isLine) { + let Ve = V.linewidth; + Ve === void 0 && (Ve = 1), ye.setLineWidth(Ve * we()), k.isLineSegments ? rt.setMode(F.LINES) : k.isLineLoop ? rt.setMode(F.LINE_LOOP) : rt.setMode(F.LINE_STRIP); + } else + k.isPoints ? rt.setMode(F.POINTS) : k.isSprite && rt.setMode(F.TRIANGLES); + if (k.isBatchedMesh) + rt.renderMultiDraw(k._multiDrawStarts, k._multiDrawCounts, k._multiDrawCount); + else if (k.isInstancedMesh) + rt.renderInstances(ot, dt, k.count); + else if (G.isInstancedBufferGeometry) { + const Ve = G._maxInstanceCount !== void 0 ? G._maxInstanceCount : 1 / 0, cs = Math.min(G.instanceCount, Ve); + rt.renderInstances(ot, dt, cs); + } else + rt.render(ot, dt); + }; + function Oe(y, U, G) { + y.transparent === !0 && y.side === en && y.forceSinglePass === !1 ? (y.side = Pt, y.needsUpdate = !0, pr(y, U, G), y.side = hn, y.needsUpdate = !0, pr(y, U, G), y.side = en) : pr(y, U, G); + } + this.compile = function(y, U, G = null) { + G === null && (G = y), m = Ae.get(G), m.init(), M.push(m), G.traverseVisible(function(k) { + k.isLight && k.layers.test(U.layers) && (m.pushLight(k), k.castShadow && m.pushShadow(k)); + }), y !== G && y.traverseVisible(function(k) { + k.isLight && k.layers.test(U.layers) && (m.pushLight(k), k.castShadow && m.pushShadow(k)); + }), m.setupLights(_._useLegacyLights); + const V = /* @__PURE__ */ new Set(); + return y.traverse(function(k) { + const de = k.material; + if (de) + if (Array.isArray(de)) + for (let Se = 0; Se < de.length; Se++) { + const Ee = de[Se]; + Oe(Ee, G, k), V.add(Ee); + } + else + Oe(de, G, k), V.add(de); + }), M.pop(), m = null, V; + }, this.compileAsync = function(y, U, G = null) { + const V = this.compile(y, U, G); + return new Promise((k) => { + function de() { + if (V.forEach(function(Se) { + Ie.get(Se).currentProgram.isReady() && V.delete(Se); + }), V.size === 0) { + k(y); + return; + } + setTimeout(de, 10); + } + Me.get("KHR_parallel_shader_compile") !== null ? de() : setTimeout(de, 10); + }); + }; + let et = null; + function _t(y) { + et && et(y); + } + function Nt() { + At.stop(); + } + function tt() { + At.start(); + } + const At = new ac(); + At.setAnimationLoop(_t), typeof self < "u" && At.setContext(self), this.setAnimationLoop = function(y) { + et = y, Ue.setAnimationLoop(y), y === null ? At.stop() : At.start(); + }, Ue.addEventListener("sessionstart", Nt), Ue.addEventListener("sessionend", tt), this.render = function(y, U) { + if (U !== void 0 && U.isCamera !== !0) { + console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera."); + return; + } + if (A === !0) + return; + y.matrixWorldAutoUpdate === !0 && y.updateMatrixWorld(), U.parent === null && U.matrixWorldAutoUpdate === !0 && U.updateMatrixWorld(), Ue.enabled === !0 && Ue.isPresenting === !0 && (Ue.cameraAutoUpdate === !0 && Ue.updateCamera(U), U = Ue.getCamera()), y.isScene === !0 && y.onBeforeRender(_, y, U, b), m = Ae.get(y, M.length), m.init(), M.push(m), Te.multiplyMatrices(U.projectionMatrix, U.matrixWorldInverse), Z.setFromProjectionMatrix(Te), ee = this.localClippingEnabled, H = se.init(this.clippingPlanes, ee), v = Le.get(y, d.length), v.init(), d.push(v), rn(y, U, 0, _.sortObjects), v.finish(), _.sortObjects === !0 && v.sort(j, q), this.info.render.frame++, H === !0 && se.beginShadows(); + const G = m.state.shadowsArray; + if (ce.render(G, y, U), H === !0 && se.endShadows(), this.info.autoReset === !0 && this.info.reset(), (Ue.enabled === !1 || Ue.isPresenting === !1 || Ue.hasDepthSensing() === !1) && Re.render(v, y), m.setupLights(_._useLegacyLights), U.isArrayCamera) { + const V = U.cameras; + for (let k = 0, de = V.length; k < de; k++) { + const Se = V[k]; + Eo(v, y, Se, Se.viewport); + } + } else + Eo(v, y, U); + b !== null && (Be.updateMultisampleRenderTarget(b), Be.updateRenderTargetMipmap(b)), y.isScene === !0 && y.onAfterRender(_, y, U), he.resetDefaultState(), I = -1, W = null, M.pop(), M.length > 0 ? m = M[M.length - 1] : m = null, d.pop(), d.length > 0 ? v = d[d.length - 1] : v = null; + }; + function rn(y, U, G, V) { + if (y.visible === !1) + return; + if (y.layers.test(U.layers)) { + if (y.isGroup) + G = y.renderOrder; + else if (y.isLOD) + y.autoUpdate === !0 && y.update(U); + else if (y.isLight) + m.pushLight(y), y.castShadow && m.pushShadow(y); + else if (y.isSprite) { + if (!y.frustumCulled || Z.intersectsSprite(y)) { + V && ge.setFromMatrixPosition(y.matrixWorld).applyMatrix4(Te); + const Se = Q.update(y), Ee = y.material; + Ee.visible && v.push(y, Se, Ee, G, ge.z, null); + } + } else if ((y.isMesh || y.isLine || y.isPoints) && (!y.frustumCulled || Z.intersectsObject(y))) { + const Se = Q.update(y), Ee = y.material; + if (V && (y.boundingSphere !== void 0 ? (y.boundingSphere === null && y.computeBoundingSphere(), ge.copy(y.boundingSphere.center)) : (Se.boundingSphere === null && Se.computeBoundingSphere(), ge.copy(Se.boundingSphere.center)), ge.applyMatrix4(y.matrixWorld).applyMatrix4(Te)), Array.isArray(Ee)) { + const Ce = Se.groups; + for (let Xe = 0, Fe = Ce.length; Xe < Fe; Xe++) { + const ze = Ce[Xe], ot = Ee[ze.materialIndex]; + ot && ot.visible && v.push(y, Se, ot, G, ge.z, ze); + } + } else + Ee.visible && v.push(y, Se, Ee, G, ge.z, null); + } + } + const de = y.children; + for (let Se = 0, Ee = de.length; Se < Ee; Se++) + rn(de[Se], U, G, V); + } + function Eo(y, U, G, V) { + const k = y.opaque, de = y.transmissive, Se = y.transparent; + m.setupLightsView(G), H === !0 && se.setGlobalState(_.clippingPlanes, G), de.length > 0 && yc(k, de, U, G), V && ye.viewport(S.copy(V)), k.length > 0 && dr(k, U, G), de.length > 0 && dr(de, U, G), Se.length > 0 && dr(Se, U, G), ye.buffers.depth.setTest(!0), ye.buffers.depth.setMask(!0), ye.buffers.color.setMask(!0), ye.setPolygonOffset(!1); + } + function yc(y, U, G, V) { + if ((G.isScene === !0 ? G.overrideMaterial : null) !== null) + return; + const de = Ne.isWebGL2; + pe === null && (pe = new Vn(1, 1, { + generateMipmaps: !0, + type: Me.has("EXT_color_buffer_half_float") ? Gi : Gn, + minFilter: ni, + samples: de ? 4 : 0 + })), _.getDrawingBufferSize(xe), de ? pe.setSize(xe.x, xe.y) : pe.setSize(Zr(xe.x), Zr(xe.y)); + const Se = _.getRenderTarget(); + _.setRenderTarget(pe), _.getClearColor(K), L = _.getClearAlpha(), L < 1 && _.setClearColor(16777215, 0.5), _.clear(); + const Ee = _.toneMapping; + _.toneMapping = kn, dr(y, G, V), Be.updateMultisampleRenderTarget(pe), Be.updateRenderTargetMipmap(pe); + let Ce = !1; + for (let Xe = 0, Fe = U.length; Xe < Fe; Xe++) { + const ze = U[Xe], ot = ze.object, Lt = ze.geometry, dt = ze.material, dn = ze.group; + if (dt.side === en && ot.layers.test(V.layers)) { + const rt = dt.side; + dt.side = Pt, dt.needsUpdate = !0, bo(ot, G, V, Lt, dt, dn), dt.side = rt, dt.needsUpdate = !0, Ce = !0; + } + } + Ce === !0 && (Be.updateMultisampleRenderTarget(pe), Be.updateRenderTargetMipmap(pe)), _.setRenderTarget(Se), _.setClearColor(K, L), _.toneMapping = Ee; + } + function dr(y, U, G) { + const V = U.isScene === !0 ? U.overrideMaterial : null; + for (let k = 0, de = y.length; k < de; k++) { + const Se = y[k], Ee = Se.object, Ce = Se.geometry, Xe = V === null ? Se.material : V, Fe = Se.group; + Ee.layers.test(G.layers) && bo(Ee, U, G, Ce, Xe, Fe); + } + } + function bo(y, U, G, V, k, de) { + y.onBeforeRender(_, U, G, V, k, de), y.modelViewMatrix.multiplyMatrices(G.matrixWorldInverse, y.matrixWorld), y.normalMatrix.getNormalMatrix(y.modelViewMatrix), k.onBeforeRender(_, U, G, V, y, de), k.transparent === !0 && k.side === en && k.forceSinglePass === !1 ? (k.side = Pt, k.needsUpdate = !0, _.renderBufferDirect(G, U, V, k, y, de), k.side = hn, k.needsUpdate = !0, _.renderBufferDirect(G, U, V, k, y, de), k.side = en) : _.renderBufferDirect(G, U, V, k, y, de), y.onAfterRender(_, U, G, V, k, de); + } + function pr(y, U, G) { + U.isScene !== !0 && (U = Ke); + const V = Ie.get(y), k = m.state.lights, de = m.state.shadowsArray, Se = k.state.version, Ee = te.getParameters(y, k.state, de, U, G), Ce = te.getProgramCacheKey(Ee); + let Xe = V.programs; + V.environment = y.isMeshStandardMaterial ? U.environment : null, V.fog = U.fog, V.envMap = (y.isMeshStandardMaterial ? w : Je).get(y.envMap || V.environment), V.envMapRotation = V.environment !== null && y.envMap === null ? U.environmentRotation : y.envMapRotation, Xe === void 0 && (y.addEventListener("dispose", z), Xe = /* @__PURE__ */ new Map(), V.programs = Xe); + let Fe = Xe.get(Ce); + if (Fe !== void 0) { + if (V.currentProgram === Fe && V.lightsStateVersion === Se) + return wo(y, Ee), Fe; + } else + Ee.uniforms = te.getUniforms(y), y.onBuild(G, Ee, _), y.onBeforeCompile(Ee, _), Fe = te.acquireProgram(Ee, Ce), Xe.set(Ce, Fe), V.uniforms = Ee.uniforms; + const ze = V.uniforms; + return (!y.isShaderMaterial && !y.isRawShaderMaterial || y.clipping === !0) && (ze.clippingPlanes = se.uniform), wo(y, Ee), V.needsLights = bc(y), V.lightsStateVersion = Se, V.needsLights && (ze.ambientLightColor.value = k.state.ambient, ze.lightProbe.value = k.state.probe, ze.directionalLights.value = k.state.directional, ze.directionalLightShadows.value = k.state.directionalShadow, ze.spotLights.value = k.state.spot, ze.spotLightShadows.value = k.state.spotShadow, ze.rectAreaLights.value = k.state.rectArea, ze.ltc_1.value = k.state.rectAreaLTC1, ze.ltc_2.value = k.state.rectAreaLTC2, ze.pointLights.value = k.state.point, ze.pointLightShadows.value = k.state.pointShadow, ze.hemisphereLights.value = k.state.hemi, ze.directionalShadowMap.value = k.state.directionalShadowMap, ze.directionalShadowMatrix.value = k.state.directionalShadowMatrix, ze.spotShadowMap.value = k.state.spotShadowMap, ze.spotLightMatrix.value = k.state.spotLightMatrix, ze.spotLightMap.value = k.state.spotLightMap, ze.pointShadowMap.value = k.state.pointShadowMap, ze.pointShadowMatrix.value = k.state.pointShadowMatrix), V.currentProgram = Fe, V.uniformsList = null, Fe; + } + function To(y) { + if (y.uniformsList === null) { + const U = y.currentProgram.getUniforms(); + y.uniformsList = Vr.seqWithValue(U.seq, y.uniforms); + } + return y.uniformsList; + } + function wo(y, U) { + const G = Ie.get(y); + G.outputColorSpace = U.outputColorSpace, G.batching = U.batching, G.instancing = U.instancing, G.instancingColor = U.instancingColor, G.instancingMorph = U.instancingMorph, G.skinning = U.skinning, G.morphTargets = U.morphTargets, G.morphNormals = U.morphNormals, G.morphColors = U.morphColors, G.morphTargetsCount = U.morphTargetsCount, G.numClippingPlanes = U.numClippingPlanes, G.numIntersection = U.numClipIntersection, G.vertexAlphas = U.vertexAlphas, G.vertexTangents = U.vertexTangents, G.toneMapping = U.toneMapping; + } + function Ac(y, U, G, V, k) { + U.isScene !== !0 && (U = Ke), Be.resetTextureUnits(); + const de = U.fog, Se = V.isMeshStandardMaterial ? U.environment : null, Ee = b === null ? _.outputColorSpace : b.isXRRenderTarget === !0 ? b.texture.colorSpace : Wn, Ce = (V.isMeshStandardMaterial ? w : Je).get(V.envMap || Se), Xe = V.vertexColors === !0 && !!G.attributes.color && G.attributes.color.itemSize === 4, Fe = !!G.attributes.tangent && (!!V.normalMap || V.anisotropy > 0), ze = !!G.morphAttributes.position, ot = !!G.morphAttributes.normal, Lt = !!G.morphAttributes.color; + let dt = kn; + V.toneMapped && (b === null || b.isXRRenderTarget === !0) && (dt = _.toneMapping); + const dn = G.morphAttributes.position || G.morphAttributes.normal || G.morphAttributes.color, rt = dn !== void 0 ? dn.length : 0, Ve = Ie.get(V), cs = m.state.lights; + if (H === !0 && (ee === !0 || y !== W)) { + const Bt = y === W && V.id === I; + se.setState(V, y, Bt); + } + let it = !1; + V.version === Ve.__version ? (Ve.needsLights && Ve.lightsStateVersion !== cs.state.version || Ve.outputColorSpace !== Ee || k.isBatchedMesh && Ve.batching === !1 || !k.isBatchedMesh && Ve.batching === !0 || k.isInstancedMesh && Ve.instancing === !1 || !k.isInstancedMesh && Ve.instancing === !0 || k.isSkinnedMesh && Ve.skinning === !1 || !k.isSkinnedMesh && Ve.skinning === !0 || k.isInstancedMesh && Ve.instancingColor === !0 && k.instanceColor === null || k.isInstancedMesh && Ve.instancingColor === !1 && k.instanceColor !== null || k.isInstancedMesh && Ve.instancingMorph === !0 && k.morphTexture === null || k.isInstancedMesh && Ve.instancingMorph === !1 && k.morphTexture !== null || Ve.envMap !== Ce || V.fog === !0 && Ve.fog !== de || Ve.numClippingPlanes !== void 0 && (Ve.numClippingPlanes !== se.numPlanes || Ve.numIntersection !== se.numIntersection) || Ve.vertexAlphas !== Xe || Ve.vertexTangents !== Fe || Ve.morphTargets !== ze || Ve.morphNormals !== ot || Ve.morphColors !== Lt || Ve.toneMapping !== dt || Ne.isWebGL2 === !0 && Ve.morphTargetsCount !== rt) && (it = !0) : (it = !0, Ve.__version = V.version); + let Xn = Ve.currentProgram; + it === !0 && (Xn = pr(V, U, k)); + let Co = !1, $i = !1, us = !1; + const St = Xn.getUniforms(), qn = Ve.uniforms; + if (ye.useProgram(Xn.program) && (Co = !0, $i = !0, us = !0), V.id !== I && (I = V.id, $i = !0), Co || W !== y) { + St.setValue(F, "projectionMatrix", y.projectionMatrix), St.setValue(F, "viewMatrix", y.matrixWorldInverse); + const Bt = St.map.cameraPosition; + Bt !== void 0 && Bt.setValue(F, ge.setFromMatrixPosition(y.matrixWorld)), Ne.logarithmicDepthBuffer && St.setValue( + F, + "logDepthBufFC", + 2 / (Math.log(y.far + 1) / Math.LN2) + ), (V.isMeshPhongMaterial || V.isMeshToonMaterial || V.isMeshLambertMaterial || V.isMeshBasicMaterial || V.isMeshStandardMaterial || V.isShaderMaterial) && St.setValue(F, "isOrthographic", y.isOrthographicCamera === !0), W !== y && (W = y, $i = !0, us = !0); + } + if (k.isSkinnedMesh) { + St.setOptional(F, k, "bindMatrix"), St.setOptional(F, k, "bindMatrixInverse"); + const Bt = k.skeleton; + Bt && (Ne.floatVertexTextures ? (Bt.boneTexture === null && Bt.computeBoneTexture(), St.setValue(F, "boneTexture", Bt.boneTexture, Be)) : console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required.")); + } + k.isBatchedMesh && (St.setOptional(F, k, "batchingTexture"), St.setValue(F, "batchingTexture", k._matricesTexture, Be)); + const fs = G.morphAttributes; + if ((fs.position !== void 0 || fs.normal !== void 0 || fs.color !== void 0 && Ne.isWebGL2 === !0) && R.update(k, G, Xn), ($i || Ve.receiveShadow !== k.receiveShadow) && (Ve.receiveShadow = k.receiveShadow, St.setValue(F, "receiveShadow", k.receiveShadow)), V.isMeshGouraudMaterial && V.envMap !== null && (qn.envMap.value = Ce, qn.flipEnvMap.value = Ce.isCubeTexture && Ce.isRenderTargetTexture === !1 ? -1 : 1), $i && (St.setValue(F, "toneMappingExposure", _.toneMappingExposure), Ve.needsLights && Ec(qn, us), de && V.fog === !0 && $.refreshFogUniforms(qn, de), $.refreshMaterialUniforms(qn, V, B, O, pe), Vr.upload(F, To(Ve), qn, Be)), V.isShaderMaterial && V.uniformsNeedUpdate === !0 && (Vr.upload(F, To(Ve), qn, Be), V.uniformsNeedUpdate = !1), V.isSpriteMaterial && St.setValue(F, "center", k.center), St.setValue(F, "modelViewMatrix", k.modelViewMatrix), St.setValue(F, "normalMatrix", k.normalMatrix), St.setValue(F, "modelMatrix", k.matrixWorld), V.isShaderMaterial || V.isRawShaderMaterial) { + const Bt = V.uniformsGroups; + for (let hs = 0, Tc = Bt.length; hs < Tc; hs++) + if (Ne.isWebGL2) { + const Ro = Bt[hs]; + _e.update(Ro, Xn), _e.bind(Ro, Xn); + } else + console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2."); + } + return Xn; + } + function Ec(y, U) { + y.ambientLightColor.needsUpdate = U, y.lightProbe.needsUpdate = U, y.directionalLights.needsUpdate = U, y.directionalLightShadows.needsUpdate = U, y.pointLights.needsUpdate = U, y.pointLightShadows.needsUpdate = U, y.spotLights.needsUpdate = U, y.spotLightShadows.needsUpdate = U, y.rectAreaLights.needsUpdate = U, y.hemisphereLights.needsUpdate = U; + } + function bc(y) { + return y.isMeshLambertMaterial || y.isMeshToonMaterial || y.isMeshPhongMaterial || y.isMeshStandardMaterial || y.isShadowMaterial || y.isShaderMaterial && y.lights === !0; + } + this.getActiveCubeFace = function() { + return C; + }, this.getActiveMipmapLevel = function() { + return E; + }, this.getRenderTarget = function() { + return b; + }, this.setRenderTargetTextures = function(y, U, G) { + Ie.get(y.texture).__webglTexture = U, Ie.get(y.depthTexture).__webglTexture = G; + const V = Ie.get(y); + V.__hasExternalTextures = !0, V.__autoAllocateDepthBuffer = G === void 0, V.__autoAllocateDepthBuffer || Me.has("WEBGL_multisampled_render_to_texture") === !0 && (console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"), V.__useRenderToTexture = !1); + }, this.setRenderTargetFramebuffer = function(y, U) { + const G = Ie.get(y); + G.__webglFramebuffer = U, G.__useDefaultFramebuffer = U === void 0; + }, this.setRenderTarget = function(y, U = 0, G = 0) { + b = y, C = U, E = G; + let V = !0, k = null, de = !1, Se = !1; + if (y) { + const Ce = Ie.get(y); + Ce.__useDefaultFramebuffer !== void 0 ? (ye.bindFramebuffer(F.FRAMEBUFFER, null), V = !1) : Ce.__webglFramebuffer === void 0 ? Be.setupRenderTarget(y) : Ce.__hasExternalTextures && Be.rebindTextures(y, Ie.get(y.texture).__webglTexture, Ie.get(y.depthTexture).__webglTexture); + const Xe = y.texture; + (Xe.isData3DTexture || Xe.isDataArrayTexture || Xe.isCompressedArrayTexture) && (Se = !0); + const Fe = Ie.get(y).__webglFramebuffer; + y.isWebGLCubeRenderTarget ? (Array.isArray(Fe[U]) ? k = Fe[U][G] : k = Fe[U], de = !0) : Ne.isWebGL2 && y.samples > 0 && Be.useMultisampledRTT(y) === !1 ? k = Ie.get(y).__webglMultisampledFramebuffer : Array.isArray(Fe) ? k = Fe[G] : k = Fe, S.copy(y.viewport), T.copy(y.scissor), Y = y.scissorTest; + } else + S.copy(J).multiplyScalar(B).floor(), T.copy(ne).multiplyScalar(B).floor(), Y = ue; + if (ye.bindFramebuffer(F.FRAMEBUFFER, k) && Ne.drawBuffers && V && ye.drawBuffers(y, k), ye.viewport(S), ye.scissor(T), ye.setScissorTest(Y), de) { + const Ce = Ie.get(y.texture); + F.framebufferTexture2D(F.FRAMEBUFFER, F.COLOR_ATTACHMENT0, F.TEXTURE_CUBE_MAP_POSITIVE_X + U, Ce.__webglTexture, G); + } else if (Se) { + const Ce = Ie.get(y.texture), Xe = U || 0; + F.framebufferTextureLayer(F.FRAMEBUFFER, F.COLOR_ATTACHMENT0, Ce.__webglTexture, G || 0, Xe); + } + I = -1; + }, this.readRenderTargetPixels = function(y, U, G, V, k, de, Se) { + if (!(y && y.isWebGLRenderTarget)) { + console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget."); + return; + } + let Ee = Ie.get(y).__webglFramebuffer; + if (y.isWebGLCubeRenderTarget && Se !== void 0 && (Ee = Ee[Se]), Ee) { + ye.bindFramebuffer(F.FRAMEBUFFER, Ee); + try { + const Ce = y.texture, Xe = Ce.format, Fe = Ce.type; + if (Xe !== Vt && fe.convert(Xe) !== F.getParameter(F.IMPLEMENTATION_COLOR_READ_FORMAT)) { + console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."); + return; + } + const ze = Fe === Gi && (Me.has("EXT_color_buffer_half_float") || Ne.isWebGL2 && Me.has("EXT_color_buffer_float")); + if (Fe !== Gn && fe.convert(Fe) !== F.getParameter(F.IMPLEMENTATION_COLOR_READ_TYPE) && // Edge and Chrome Mac < 52 (#9513) + !(Fe === an && (Ne.isWebGL2 || Me.has("OES_texture_float") || Me.has("WEBGL_color_buffer_float"))) && // Chrome Mac >= 52 and Firefox + !ze) { + console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type."); + return; + } + U >= 0 && U <= y.width - V && G >= 0 && G <= y.height - k && F.readPixels(U, G, V, k, fe.convert(Xe), fe.convert(Fe), de); + } finally { + const Ce = b !== null ? Ie.get(b).__webglFramebuffer : null; + ye.bindFramebuffer(F.FRAMEBUFFER, Ce); + } + } + }, this.copyFramebufferToTexture = function(y, U, G = 0) { + const V = Math.pow(2, -G), k = Math.floor(U.image.width * V), de = Math.floor(U.image.height * V); + Be.setTexture2D(U, 0), F.copyTexSubImage2D(F.TEXTURE_2D, G, 0, 0, y.x, y.y, k, de), ye.unbindTexture(); + }, this.copyTextureToTexture = function(y, U, G, V = 0) { + const k = U.image.width, de = U.image.height, Se = fe.convert(G.format), Ee = fe.convert(G.type); + Be.setTexture2D(G, 0), F.pixelStorei(F.UNPACK_FLIP_Y_WEBGL, G.flipY), F.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL, G.premultiplyAlpha), F.pixelStorei(F.UNPACK_ALIGNMENT, G.unpackAlignment), U.isDataTexture ? F.texSubImage2D(F.TEXTURE_2D, V, y.x, y.y, k, de, Se, Ee, U.image.data) : U.isCompressedTexture ? F.compressedTexSubImage2D(F.TEXTURE_2D, V, y.x, y.y, U.mipmaps[0].width, U.mipmaps[0].height, Se, U.mipmaps[0].data) : F.texSubImage2D(F.TEXTURE_2D, V, y.x, y.y, Se, Ee, U.image), V === 0 && G.generateMipmaps && F.generateMipmap(F.TEXTURE_2D), ye.unbindTexture(); + }, this.copyTextureToTexture3D = function(y, U, G, V, k = 0) { + if (_.isWebGL1Renderer) { + console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2."); + return; + } + const de = Math.round(y.max.x - y.min.x), Se = Math.round(y.max.y - y.min.y), Ee = y.max.z - y.min.z + 1, Ce = fe.convert(V.format), Xe = fe.convert(V.type); + let Fe; + if (V.isData3DTexture) + Be.setTexture3D(V, 0), Fe = F.TEXTURE_3D; + else if (V.isDataArrayTexture || V.isCompressedArrayTexture) + Be.setTexture2DArray(V, 0), Fe = F.TEXTURE_2D_ARRAY; + else { + console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray."); + return; + } + F.pixelStorei(F.UNPACK_FLIP_Y_WEBGL, V.flipY), F.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL, V.premultiplyAlpha), F.pixelStorei(F.UNPACK_ALIGNMENT, V.unpackAlignment); + const ze = F.getParameter(F.UNPACK_ROW_LENGTH), ot = F.getParameter(F.UNPACK_IMAGE_HEIGHT), Lt = F.getParameter(F.UNPACK_SKIP_PIXELS), dt = F.getParameter(F.UNPACK_SKIP_ROWS), dn = F.getParameter(F.UNPACK_SKIP_IMAGES), rt = G.isCompressedTexture ? G.mipmaps[k] : G.image; + F.pixelStorei(F.UNPACK_ROW_LENGTH, rt.width), F.pixelStorei(F.UNPACK_IMAGE_HEIGHT, rt.height), F.pixelStorei(F.UNPACK_SKIP_PIXELS, y.min.x), F.pixelStorei(F.UNPACK_SKIP_ROWS, y.min.y), F.pixelStorei(F.UNPACK_SKIP_IMAGES, y.min.z), G.isDataTexture || G.isData3DTexture ? F.texSubImage3D(Fe, k, U.x, U.y, U.z, de, Se, Ee, Ce, Xe, rt.data) : V.isCompressedArrayTexture ? F.compressedTexSubImage3D(Fe, k, U.x, U.y, U.z, de, Se, Ee, Ce, rt.data) : F.texSubImage3D(Fe, k, U.x, U.y, U.z, de, Se, Ee, Ce, Xe, rt), F.pixelStorei(F.UNPACK_ROW_LENGTH, ze), F.pixelStorei(F.UNPACK_IMAGE_HEIGHT, ot), F.pixelStorei(F.UNPACK_SKIP_PIXELS, Lt), F.pixelStorei(F.UNPACK_SKIP_ROWS, dt), F.pixelStorei(F.UNPACK_SKIP_IMAGES, dn), k === 0 && V.generateMipmaps && F.generateMipmap(Fe), ye.unbindTexture(); + }, this.initTexture = function(y) { + y.isCubeTexture ? Be.setTextureCube(y, 0) : y.isData3DTexture ? Be.setTexture3D(y, 0) : y.isDataArrayTexture || y.isCompressedArrayTexture ? Be.setTexture2DArray(y, 0) : Be.setTexture2D(y, 0), ye.unbindTexture(); + }, this.resetState = function() { + C = 0, E = 0, b = null, ye.reset(), he.reset(); + }, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this })); + } + get coordinateSystem() { + return Mn; + } + get outputColorSpace() { + return this._outputColorSpace; + } + set outputColorSpace(e) { + this._outputColorSpace = e; + const t = this.getContext(); + t.drawingBufferColorSpace = e === go ? "display-p3" : "srgb", t.unpackColorSpace = Ze.workingColorSpace === os ? "display-p3" : "srgb"; + } + get useLegacyLights() { + return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."), this._useLegacyLights; + } + set useLegacyLights(e) { + console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."), this._useLegacyLights = e; + } +} +class a_ extends pc { +} +a_.prototype.isWebGL1Renderer = !0; +class l_ extends gt { + constructor() { + super(), this.isScene = !0, this.type = "Scene", this.background = null, this.environment = null, this.fog = null, this.backgroundBlurriness = 0, this.backgroundIntensity = 1, this.backgroundRotation = new bn(), this.environmentRotation = new bn(), this.overrideMaterial = null, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this })); + } + copy(e, t) { + return super.copy(e, t), e.background !== null && (this.background = e.background.clone()), e.environment !== null && (this.environment = e.environment.clone()), e.fog !== null && (this.fog = e.fog.clone()), this.backgroundBlurriness = e.backgroundBlurriness, this.backgroundIntensity = e.backgroundIntensity, this.backgroundRotation.copy(e.backgroundRotation), this.environmentRotation.copy(e.environmentRotation), e.overrideMaterial !== null && (this.overrideMaterial = e.overrideMaterial.clone()), this.matrixAutoUpdate = e.matrixAutoUpdate, this; + } + toJSON(e) { + const t = super.toJSON(e); + return this.fog !== null && (t.object.fog = this.fog.toJSON()), this.backgroundBlurriness > 0 && (t.object.backgroundBlurriness = this.backgroundBlurriness), this.backgroundIntensity !== 1 && (t.object.backgroundIntensity = this.backgroundIntensity), t.object.backgroundRotation = this.backgroundRotation.toArray(), t.object.environmentRotation = this.environmentRotation.toArray(), t; + } +} +class Or extends Tt { + constructor(e = null, t = 1, n = 1, r, s, a, o, l, c = vt, u = vt, f, h) { + super(null, a, o, l, c, u, r, s, f, h), this.isDataTexture = !0, this.image = { data: e, width: t, height: n }, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1; + } +} +class c_ extends Wt { + constructor(e, t, n, r = 1) { + super(e, t, n), this.isInstancedBufferAttribute = !0, this.meshPerAttribute = r; + } + copy(e) { + return super.copy(e), this.meshPerAttribute = e.meshPerAttribute, this; + } + toJSON() { + const e = super.toJSON(); + return e.meshPerAttribute = this.meshPerAttribute, e.isInstancedBufferAttribute = !0, e; + } +} +class hr extends Yt { + constructor(e = 1, t = 1, n = 1, r = 32, s = 1, a = !1, o = 0, l = Math.PI * 2) { + super(), this.type = "CylinderGeometry", this.parameters = { + radiusTop: e, + radiusBottom: t, + height: n, + radialSegments: r, + heightSegments: s, + openEnded: a, + thetaStart: o, + thetaLength: l + }; + const c = this; + r = Math.floor(r), s = Math.floor(s); + const u = [], f = [], h = [], p = []; + let g = 0; + const v = [], m = n / 2; + let d = 0; + M(), a === !1 && (e > 0 && _(!0), t > 0 && _(!1)), this.setIndex(u), this.setAttribute("position", new Ft(f, 3)), this.setAttribute("normal", new Ft(h, 3)), this.setAttribute("uv", new Ft(p, 2)); + function M() { + const A = new P(), C = new P(); + let E = 0; + const b = (t - e) / n; + for (let I = 0; I <= s; I++) { + const W = [], S = I / s, T = S * (t - e) + e; + for (let Y = 0; Y <= r; Y++) { + const K = Y / r, L = K * l + o, N = Math.sin(L), O = Math.cos(L); + C.x = T * N, C.y = -S * n + m, C.z = T * O, f.push(C.x, C.y, C.z), A.set(N, b, O).normalize(), h.push(A.x, A.y, A.z), p.push(K, 1 - S), W.push(g++); + } + v.push(W); + } + for (let I = 0; I < r; I++) + for (let W = 0; W < s; W++) { + const S = v[W][I], T = v[W + 1][I], Y = v[W + 1][I + 1], K = v[W][I + 1]; + u.push(S, T, K), u.push(T, Y, K), E += 6; + } + c.addGroup(d, E, 0), d += E; + } + function _(A) { + const C = g, E = new me(), b = new P(); + let I = 0; + const W = A === !0 ? e : t, S = A === !0 ? 1 : -1; + for (let Y = 1; Y <= r; Y++) + f.push(0, m * S, 0), h.push(0, S, 0), p.push(0.5, 0.5), g++; + const T = g; + for (let Y = 0; Y <= r; Y++) { + const L = Y / r * l + o, N = Math.cos(L), O = Math.sin(L); + b.x = W * O, b.y = m * S, b.z = W * N, f.push(b.x, b.y, b.z), h.push(0, S, 0), E.x = N * 0.5 + 0.5, E.y = O * 0.5 * S + 0.5, p.push(E.x, E.y), g++; + } + for (let Y = 0; Y < r; Y++) { + const K = C + Y, L = T + Y; + A === !0 ? u.push(L, L + 1, K) : u.push(L + 1, L, K), I += 3; + } + c.addGroup(d, I, A === !0 ? 1 : 2), d += I; + } + } + copy(e) { + return super.copy(e), this.parameters = Object.assign({}, e.parameters), this; + } + static fromJSON(e) { + return new hr(e.radiusTop, e.radiusBottom, e.height, e.radialSegments, e.heightSegments, e.openEnded, e.thetaStart, e.thetaLength); + } +} +class Mo extends hr { + constructor(e = 1, t = 1, n = 32, r = 1, s = !1, a = 0, o = Math.PI * 2) { + super(0, e, t, n, r, s, a, o), this.type = "ConeGeometry", this.parameters = { + radius: e, + height: t, + radialSegments: n, + heightSegments: r, + openEnded: s, + thetaStart: a, + thetaLength: o + }; + } + static fromJSON(e) { + return new Mo(e.radius, e.height, e.radialSegments, e.heightSegments, e.openEnded, e.thetaStart, e.thetaLength); + } +} +class es extends Yt { + constructor(e = 1, t = 32, n = 16, r = 0, s = Math.PI * 2, a = 0, o = Math.PI) { + super(), this.type = "SphereGeometry", this.parameters = { + radius: e, + widthSegments: t, + heightSegments: n, + phiStart: r, + phiLength: s, + thetaStart: a, + thetaLength: o + }, t = Math.max(3, Math.floor(t)), n = Math.max(2, Math.floor(n)); + const l = Math.min(a + o, Math.PI); + let c = 0; + const u = [], f = new P(), h = new P(), p = [], g = [], v = [], m = []; + for (let d = 0; d <= n; d++) { + const M = [], _ = d / n; + let A = 0; + d === 0 && a === 0 ? A = 0.5 / t : d === n && l === Math.PI && (A = -0.5 / t); + for (let C = 0; C <= t; C++) { + const E = C / t; + f.x = -e * Math.cos(r + E * s) * Math.sin(a + _ * o), f.y = e * Math.cos(a + _ * o), f.z = e * Math.sin(r + E * s) * Math.sin(a + _ * o), g.push(f.x, f.y, f.z), h.copy(f).normalize(), v.push(h.x, h.y, h.z), m.push(E + A, 1 - _), M.push(c++); + } + u.push(M); + } + for (let d = 0; d < n; d++) + for (let M = 0; M < t; M++) { + const _ = u[d][M + 1], A = u[d][M], C = u[d + 1][M], E = u[d + 1][M + 1]; + (d !== 0 || a > 0) && p.push(_, A, E), (d !== n - 1 || l < Math.PI) && p.push(A, C, E); + } + this.setIndex(p), this.setAttribute("position", new Ft(g, 3)), this.setAttribute("normal", new Ft(v, 3)), this.setAttribute("uv", new Ft(m, 2)); + } + copy(e) { + return super.copy(e), this.parameters = Object.assign({}, e.parameters), this; + } + static fromJSON(e) { + return new es(e.radius, e.widthSegments, e.heightSegments, e.phiStart, e.phiLength, e.thetaStart, e.thetaLength); + } +} +class u_ extends Yt { + constructor() { + super(), this.isInstancedBufferGeometry = !0, this.type = "InstancedBufferGeometry", this.instanceCount = 1 / 0; + } + copy(e) { + return super.copy(e), this.instanceCount = e.instanceCount, this; + } + toJSON() { + const e = super.toJSON(); + return e.instanceCount = this.instanceCount, e.isInstancedBufferGeometry = !0, e; + } +} +class il { + constructor(e = 1, t = 0, n = 0) { + return this.radius = e, this.phi = t, this.theta = n, this; + } + set(e, t, n) { + return this.radius = e, this.phi = t, this.theta = n, this; + } + copy(e) { + return this.radius = e.radius, this.phi = e.phi, this.theta = e.theta, this; + } + // restrict phi to be between EPS and PI-EPS + makeSafe() { + return this.phi = Math.max(1e-6, Math.min(Math.PI - 1e-6, this.phi)), this; + } + setFromVector3(e) { + return this.setFromCartesianCoords(e.x, e.y, e.z); + } + setFromCartesianCoords(e, t, n) { + return this.radius = Math.sqrt(e * e + t * t + n * n), this.radius === 0 ? (this.theta = 0, this.phi = 0) : (this.theta = Math.atan2(e, n), this.phi = Math.acos(xt(t / this.radius, -1, 1))), this; + } + clone() { + return new this.constructor().copy(this); + } +} +typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register", { detail: { + revision: fo +} })); +typeof window < "u" && (window.__THREE__ ? console.warn("WARNING: Multiple instances of Three.js being imported.") : window.__THREE__ = fo); +const Ye = class Ye { + constructor(e) { + Pe(this, "getSplatScaleAndRotation", function() { + const e = new ke(), t = new ke(), n = new ke(), r = new P(); + return function(s, a, o, l) { + const c = s * Ye.ScaleComponentCount; + a.set( + this.fbf(this.scaleArray[c]), + this.fbf(this.scaleArray[c + 1]), + this.fbf(this.scaleArray[c + 2]) + ); + const u = s * Ye.RotationComponentCount; + o.set( + this.fbf(this.rotationArray[u + 1]), + this.fbf(this.rotationArray[u + 2]), + this.fbf(this.rotationArray[u + 3]), + this.fbf(this.rotationArray[u]) + ), l && (e.makeScale(a.x, a.y, a.z), t.makeRotationFromQuaternion(o), n.copy(e).multiply(t).multiply(l), n.decompose(r, o, a)); + }; + }()); + this.headerBufferData = new ArrayBuffer(Ye.HeaderSizeBytes), this.headerArrayUint8 = new Uint8Array(this.headerBufferData), this.headerArrayUint32 = new Uint32Array(this.headerBufferData), this.headerArrayFloat32 = new Float32Array(this.headerBufferData), this.headerArrayUint8.set(new Uint8Array(e, 0, Ye.HeaderSizeBytes)), this.versionMajor = this.headerArrayUint8[0], this.versionMinor = this.headerArrayUint8[1], this.headerExtraK = this.headerArrayUint8[2], this.compressionLevel = this.headerArrayUint8[3], this.splatCount = this.headerArrayUint32[1], this.bucketSize = this.headerArrayUint32[2], this.bucketCount = this.headerArrayUint32[3], this.bucketBlockSize = this.headerArrayFloat32[4], this.halfBucketBlockSize = this.bucketBlockSize / 2, this.bytesPerBucket = this.headerArrayUint32[5], this.compressionScaleRange = this.headerArrayUint32[6] || Ye.CompressionLevels[this.compressionLevel].ScaleRange, this.compressionScaleFactor = this.halfBucketBlockSize / this.compressionScaleRange; + const t = e.byteLength - Ye.HeaderSizeBytes; + this.splatBufferData = new ArrayBuffer(t), new Uint8Array(this.splatBufferData).set(new Uint8Array(e, Ye.HeaderSizeBytes, t)), this.bytesPerCenter = Ye.CompressionLevels[this.compressionLevel].BytesPerCenter, this.bytesPerScale = Ye.CompressionLevels[this.compressionLevel].BytesPerScale, this.bytesPerColor = Ye.CompressionLevels[this.compressionLevel].BytesPerColor, this.bytesPerRotation = Ye.CompressionLevels[this.compressionLevel].BytesPerRotation, this.bytesPerSplat = this.bytesPerCenter + this.bytesPerScale + this.bytesPerColor + this.bytesPerRotation, this.linkBufferArrays(); + } + linkBufferArrays() { + let e = this.compressionLevel === 0 ? Float32Array : Uint16Array; + this.centerArray = new e(this.splatBufferData, 0, this.splatCount * Ye.CenterComponentCount), this.scaleArray = new e( + this.splatBufferData, + this.bytesPerCenter * this.splatCount, + this.splatCount * Ye.ScaleComponentCount + ), this.colorArray = new Uint8Array( + this.splatBufferData, + (this.bytesPerCenter + this.bytesPerScale) * this.splatCount, + this.splatCount * Ye.ColorComponentCount + ), this.rotationArray = new e( + this.splatBufferData, + (this.bytesPerCenter + this.bytesPerScale + this.bytesPerColor) * this.splatCount, + this.splatCount * Ye.RotationComponentCount + ), this.bucketsBase = this.splatCount * this.bytesPerSplat; + } + fbf(e) { + return this.compressionLevel === 0 ? e : $r.fromHalfFloat(e); + } + getHeaderBufferData() { + return this.headerBufferData; + } + getSplatBufferData() { + return this.splatBufferData; + } + getSplatCount() { + return this.splatCount; + } + getSplatCenter(e, t, n) { + let r = [0, 0, 0]; + const s = e * Ye.CenterComponentCount; + if (this.compressionLevel > 0) { + const a = this.compressionScaleFactor, o = this.compressionScaleRange, l = Math.floor(e / this.bucketSize); + r = new Float32Array(this.splatBufferData, this.bucketsBase + l * this.bytesPerBucket, 3), t.x = (this.centerArray[s] - o) * a + r[0], t.y = (this.centerArray[s + 1] - o) * a + r[1], t.z = (this.centerArray[s + 2] - o) * a + r[2]; + } else + t.x = this.centerArray[s], t.y = this.centerArray[s + 1], t.z = this.centerArray[s + 2]; + n && t.applyMatrix4(n); + } + getSplatColor(e, t, n) { + const r = e * Ye.ColorComponentCount; + t.set( + this.colorArray[r], + this.colorArray[r + 1], + this.colorArray[r + 2], + this.colorArray[r + 3] + ); + } + fillSplatCenterArray(e, t, n) { + const r = this.splatCount; + let s = [0, 0, 0]; + const a = new P(); + for (let o = 0; o < r; o++) { + const l = o * Ye.CenterComponentCount, c = (o + t) * Ye.CenterComponentCount; + if (this.compressionLevel > 0) { + const u = Math.floor(o / this.bucketSize); + s = new Float32Array(this.splatBufferData, this.bucketsBase + u * this.bytesPerBucket, 3); + const f = this.compressionScaleFactor, h = this.compressionScaleRange; + a.x = (this.centerArray[l] - h) * f + s[0], a.y = (this.centerArray[l + 1] - h) * f + s[1], a.z = (this.centerArray[l + 2] - h) * f + s[2]; + } else + a.x = this.centerArray[l], a.y = this.centerArray[l + 1], a.z = this.centerArray[l + 2]; + n && a.applyMatrix4(n), e[c] = a.x, e[c + 1] = a.y, e[c + 2] = a.z; + } + } + fillSplatCovarianceArray(e, t, n) { + const r = this.splatCount, s = new P(), a = new wt(), o = new be(), l = new be(), c = new be(), u = new be(), f = new be(), h = new be(), p = new ke(); + for (let g = 0; g < r; g++) { + const v = g * Ye.ScaleComponentCount; + s.set( + this.fbf(this.scaleArray[v]), + this.fbf(this.scaleArray[v + 1]), + this.fbf(this.scaleArray[v + 2]) + ), p.makeScale(s.x, s.y, s.z), l.setFromMatrix4(p); + const m = g * Ye.RotationComponentCount; + a.set( + this.fbf(this.rotationArray[m + 1]), + this.fbf(this.rotationArray[m + 2]), + this.fbf(this.rotationArray[m + 3]), + this.fbf(this.rotationArray[m]) + ), p.makeRotationFromQuaternion(a), o.setFromMatrix4(p), c.copy(o).multiply(l), u.copy(c).transpose().premultiply(c); + const d = Ye.CovarianceSizeFloats * (g + t); + n && (f.setFromMatrix4(n), h.copy(f).transpose(), u.multiply(h), u.premultiply(f)), e[d] = u.elements[0], e[d + 1] = u.elements[3], e[d + 2] = u.elements[6], e[d + 3] = u.elements[4], e[d + 4] = u.elements[7], e[d + 5] = u.elements[8]; + } + } + fillSplatColorArray(e, t, n) { + const r = this.splatCount; + for (let s = 0; s < r; s++) { + const a = s * Ye.ColorComponentCount, o = (s + t) * Ye.ColorComponentCount; + e[o] = this.colorArray[a], e[o + 1] = this.colorArray[a + 1], e[o + 2] = this.colorArray[a + 2], e[o + 3] = this.colorArray[a + 3]; + } + } +}; +Pe(Ye, "CenterComponentCount", 3), Pe(Ye, "ScaleComponentCount", 3), Pe(Ye, "RotationComponentCount", 4), Pe(Ye, "ColorComponentCount", 4), Pe(Ye, "CompressionLevels", { + 0: { + BytesPerCenter: 12, + BytesPerScale: 12, + BytesPerColor: 4, + BytesPerRotation: 16, + ScaleRange: 1 + }, + 1: { + BytesPerCenter: 6, + BytesPerScale: 6, + BytesPerColor: 4, + BytesPerRotation: 8, + ScaleRange: 32767 + } +}), Pe(Ye, "CovarianceSizeFloats", 6), Pe(Ye, "CovarianceSizeBytes", 24), Pe(Ye, "HeaderSizeBytes", 1024); +let $t = Ye; +class cn { + constructor(e, t) { + let n, r; + this.promise = new Promise((o, l) => { + n = o.bind(this), r = l.bind(this); + }); + const s = (...o) => { + n(...o); + }, a = (o) => { + r(o); + }; + e(s.bind(this), a.bind(this)), this.abortHandler = t; + } + then(e) { + return new cn((t, n) => { + this.promise = this.promise.then((...r) => { + const s = e(...r); + s instanceof Promise || s instanceof cn ? s.then((...a) => { + t(...a); + }) : t(s); + }).catch((r) => { + n(r); + }); + }, this.abortHandler); + } + catch(e) { + return new cn((t) => { + this.promise = this.promise.then((...n) => { + t(...n); + }).catch(e); + }, this.abortHandler); + } + abort() { + this.abortHandler && this.abortHandler(); + } + static resolve(e) { + return new cn((t) => { + t(e); + }); + } + static reject(e) { + return new cn((t, n) => { + n(e); + }); + } +} +(function() { + const i = new Float32Array(1), e = new Int32Array(i.buffer); + return function(t) { + i[0] = t; + const n = e[0]; + let r = n >> 16 & 32768, s = n >> 12 & 2047; + const a = n >> 23 & 255; + return a < 103 ? r : a > 142 ? (r |= 31744, r |= (a == 255 ? 0 : 1) && n & 8388607, r) : a < 113 ? (s |= 2048, r |= (s >> 114 - a) + (s >> 113 - a & 1), r) : (r |= a - 112 << 10 | s >> 1, r += s & 1, r); + }; +})(); +const Ks = function() { + const i = new Float32Array(1), e = new Int32Array(i.buffer); + return function(t) { + return i[0] = t, e[0]; + }; +}(), f_ = function(i, e, t, n) { + return i + (e << 8) + (t << 16) + (n << 24); +}, mc = function(i, e) { + const t = new AbortController(), n = t.signal; + let r = !1, s = null; + const a = () => { + t.abort(), s("Fetch aborted"), r = !0; + }; + return new cn((o, l) => { + s = l, fetch(i, { signal: n }).then(async (c) => { + const u = c.body.getReader(); + let f = 0, h = c.headers.get("Content-Length"), p = h ? parseInt(h) : void 0; + const g = []; + for (; !r; ) + try { + const { value: v, done: m } = await u.read(); + if (m) { + e && e(100, "100%", v); + const _ = new Blob(g).arrayBuffer(); + o(_); + break; + } + f += v.length; + let d, M; + p !== void 0 && (d = f / p * 100, M = `${d.toFixed(2)}%`), g.push(v), e && e(d, M, v); + } catch (v) { + l(v); + break; + } + }); + }, a); +}, Qs = function(i, e, t) { + return Math.max(Math.min(i, t), e); +}, Ri = function() { + return performance.now() / 1e3; +}, Ii = (i) => { + if (i.geometry && (i.geometry.dispose(), i.geometry = null), i.material && (i.material.dispose(), i.material = null), i.children) + for (let e of i.children) + Ii(e); +}, h_ = 256, d_ = 5; +class p_ { + constructor() { + this.splatCount = 0, this.scale_0 = [], this.scale_1 = [], this.scale_2 = [], this.rot_0 = [], this.rot_1 = [], this.rot_2 = [], this.rot_3 = [], this.x = [], this.y = [], this.z = [], this.f_dc_0 = [], this.f_dc_1 = [], this.f_dc_2 = [], this.opacity = []; + } + addSplat(e, t, n, r, s, a, o, l, c, u, f, h, p, g) { + this.x.push(e), this.y.push(t), this.z.push(n), this.scale_0.push(r), this.scale_1.push(s), this.scale_2.push(a), this.rot_0.push(o), this.rot_1.push(l), this.rot_2.push(c), this.rot_3.push(u), this.f_dc_0.push(f), this.f_dc_1.push(h), this.f_dc_2.push(p), this.opacity.push(g), this.splatCount++; + } +} +class Xi { + constructor(e = 0, t = 1, n = d_, r = h_) { + this.compressionLevel = e, this.minimumAlpha = t, this.bucketSize = r, this.blockSize = n; + } + static createEmptyUncompressedSplatArray() { + return new p_(); + } + uncompressedSplatArrayToSplatBuffer(e) { + const t = Xi.createEmptyUncompressedSplatArray(); + t.addSplat(0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0); + for (let L = 0; L < e.splatCount; L++) { + let N; + e.opacity[L] ? N = e.opacity[L] : N = 255, N >= this.minimumAlpha && t.addSplat( + e.x[L], + e.y[L], + e.z[L], + e.scale_0[L], + e.scale_1[L], + e.scale_2[L], + e.rot_0[L], + e.rot_1[L], + e.rot_2[L], + e.rot_3[L], + e.f_dc_0[L], + e.f_dc_1[L], + e.f_dc_2[L], + e.opacity[L] + ); + } + const n = this.computeBucketsForUncompressedSplatArray(t), r = n.length * this.bucketSize, s = $t.HeaderSizeBytes, a = new Uint8Array(new ArrayBuffer(s)); + a[3] = this.compressionLevel, new Uint32Array(a.buffer, 4, 1)[0] = r; + let o = $t.CompressionLevels[this.compressionLevel].BytesPerCenter, l = $t.CompressionLevels[this.compressionLevel].BytesPerScale, c = $t.CompressionLevels[this.compressionLevel].BytesPerColor, u = $t.CompressionLevels[this.compressionLevel].BytesPerRotation; + const f = new ArrayBuffer(o * r), h = new ArrayBuffer(l * r), p = new ArrayBuffer(c * r), g = new ArrayBuffer(u * r), v = this.blockSize / 2, m = $t.CompressionLevels[this.compressionLevel].ScaleRange, d = m / v, M = m * 2 + 1, _ = new P(), A = new P(); + let C = 0; + for (let L = 0; L < n.length; L++) { + const N = n[L]; + _.fromArray(N.center); + for (let O = 0; O < N.splats.length; O++) { + let B = N.splats[O], j = !1; + if (B === 0 && (j = !0), this.compressionLevel === 0) { + const J = new Float32Array(f, C * o, 3), ne = new Float32Array(h, C * l, 3), ue = new Float32Array(g, C * u, 4); + if (t.scale_0[B] !== void 0) { + const Z = new wt( + t.rot_1[B], + t.rot_2[B], + t.rot_3[B], + t.rot_0[B] + ); + Z.normalize(), ue.set([Z.w, Z.x, Z.y, Z.z]), ne.set([t.scale_0[B], t.scale_1[B], t.scale_2[B]]); + } else + ne.set([0.01, 0.01, 0.01]), ue.set([1, 0, 0, 0]); + J.set([t.x[B], t.y[B], t.z[B]]); + } else { + const J = new Uint16Array(f, C * o, 3), ne = new Uint16Array(h, C * l, 3), ue = new Uint16Array(g, C * u, 4), Z = $r.toHalfFloat.bind($r); + if (t.scale_0[B] !== void 0) { + const H = new wt( + t.rot_1[B], + t.rot_2[B], + t.rot_3[B], + t.rot_0[B] + ); + H.normalize(), ue.set([Z(H.w), Z(H.x), Z(H.y), Z(H.z)]), ne.set([Z(t.scale_0[B]), Z(t.scale_1[B]), Z(t.scale_2[B])]); + } else + ne.set([Z(0.01), Z(0.01), Z(0.01)]), ue.set([Z(1), 0, 0, 0]); + A.set(t.x[B], t.y[B], t.z[B]).sub(_), A.x = Math.round(A.x * d) + m, A.x = Qs(A.x, 0, M), A.y = Math.round(A.y * d) + m, A.y = Qs(A.y, 0, M), A.z = Math.round(A.z * d) + m, A.z = Qs(A.z, 0, M), J.set([A.x, A.y, A.z]); + } + const q = new Uint8ClampedArray(p, C * c, 4); + j ? (q[0] = 255, q[1] = 0, q[2] = 0, q[3] = 0) : (t.f_dc_0[B] !== void 0 ? q.set([t.f_dc_0[B], t.f_dc_1[B], t.f_dc_2[B]]) : q.set([255, 0, 0]), t.opacity[B] !== void 0 ? q[3] = t.opacity[B] : q[3] = 255), C++; + } + } + const E = 12, b = E * n.length, I = f.byteLength + h.byteLength + p.byteLength + g.byteLength, W = new Uint32Array(a.buffer), S = new Float32Array(a.buffer); + let T = s + I; + this.compressionLevel > 0 && (T += b, W[2] = this.bucketSize, W[3] = n.length, S[4] = this.blockSize, W[5] = E, W[6] = $t.CompressionLevels[this.compressionLevel].ScaleRange); + const Y = new ArrayBuffer(T); + if (new Uint8Array(Y, 0, s).set(a), new Uint8Array(Y, s, f.byteLength).set(new Uint8Array(f)), new Uint8Array(Y, s + f.byteLength, h.byteLength).set(new Uint8Array(h)), new Uint8Array( + Y, + s + f.byteLength + h.byteLength, + p.byteLength + ).set(new Uint8Array(p)), new Uint8Array( + Y, + s + f.byteLength + h.byteLength + p.byteLength, + g.byteLength + ).set(new Uint8Array(g)), this.compressionLevel > 0) { + const L = new Float32Array(Y, s + I, n.length * 3); + for (let N = 0; N < n.length; N++) { + const O = n[N], B = N * 3; + L[B] = O.center[0], L[B + 1] = O.center[1], L[B + 2] = O.center[2]; + } + } + return new $t(Y); + } + computeBucketsForUncompressedSplatArray(e) { + let t = e.splatCount; + const n = this.blockSize, r = n / 2, s = new P(), a = new P(); + for (let p = 1; p < t; p++) { + const g = [e.x[p], e.y[p], e.z[p]]; + (p === 0 || g[0] < s.x) && (s.x = g[0]), (p === 0 || g[0] > a.x) && (a.x = g[0]), (p === 0 || g[1] < s.y) && (s.y = g[1]), (p === 0 || g[1] > a.y) && (a.y = g[1]), (p === 0 || g[2] < s.z) && (s.z = g[2]), (p === 0 || g[2] > a.z) && (a.z = g[2]); + } + const o = new P().copy(a).sub(s), l = Math.ceil(o.y / n), c = Math.ceil(o.z / n), u = new P(), f = [], h = {}; + for (let p = 1; p < t; p++) { + const g = [e.x[p], e.y[p], e.z[p]], v = Math.ceil((g[0] - s.x) / n), m = Math.ceil((g[1] - s.y) / n), d = Math.ceil((g[2] - s.z) / n); + u.x = (v - 1) * n + s.x + r, u.y = (m - 1) * n + s.y + r, u.z = (d - 1) * n + s.z + r; + const M = v * (l * c) + m * c + d; + let _ = h[M]; + _ || (h[M] = _ = { + splats: [], + center: u.toArray() + }), _.splats.push(p), _.splats.length >= this.bucketSize && (f.push(_), h[M] = null); + } + for (let p in h) + if (h.hasOwnProperty(p)) { + const g = h[p]; + if (g) { + for (; g.splats.length < this.bucketSize; ) + g.splats.push(0); + f.push(g); + } + } + return f; + } +} +class m_ { + constructor(e) { + this.plyBuffer = e; + } + decodeHeader(e) { + const t = new TextDecoder(); + let n = 0, r = ""; + console.log(".PLY size: " + e.byteLength + " bytes"); + const s = 100; + for (; ; ) { + if (n + s >= e.byteLength) + throw new Error("End of file reached while searching for end of header"); + const f = new Uint8Array(e, n, s); + r += t.decode(f), n += s; + const h = new Uint8Array(e, Math.max(0, n - s * 2), s * 2); + if (t.decode(h).includes("end_header")) + break; + } + const a = r.split(` +`); + let o = 0, l = {}; + for (let f = 0; f < a.length; f++) { + const h = a[f].trim(); + if (h.startsWith("element vertex")) { + const p = h.match(/\d+/); + p && (o = parseInt(p[0])); + } else if (h.startsWith("property")) { + const p = h.match(/(\w+)\s+(\w+)\s+(\w+)/); + if (p) { + const g = p[2], v = p[3]; + l[v] = g; + } + } else if (h === "end_header") + break; + } + const c = r.indexOf("end_header") + 10 + 1, u = new DataView(e, c); + return { + splatCount: o, + propertyTypes: l, + vertexData: u, + headerOffset: n + }; + } + readRawVertexFast(e, t, n, r, s, a) { + let o = a || {}; + for (let l of r) { + const c = s[l]; + c === "float" ? o[l] = e.getFloat32(t + n[l], !0) : c === "uchar" && (o[l] = e.getUint8(t + n[l]) / 255); + } + } + parseToSplatBuffer(e, t, n, r) { + const s = performance.now(); + console.log("Parsing PLY to SPLAT..."); + const { splatCount: a, propertyTypes: o, vertexData: l } = this.decodeHeader(this.plyBuffer); + let c = 0; + for (const C in o) + C.startsWith("f_rest_") && (c += 1); + const u = c / 3; + console.log("Detected degree", 0, "with ", u, "coefficients per color"); + let h = 0, p = {}; + const g = { + double: 8, + int: 4, + uint: 4, + float: 4, + short: 2, + ushort: 2, + uchar: 1 + }; + for (let C in o) + if (o.hasOwnProperty(C)) { + const E = o[C]; + p[C] = h, h += g[E]; + } + let v = {}; + const m = [ + "scale_0", + "scale_1", + "scale_2", + "rot_0", + "rot_1", + "rot_2", + "rot_3", + "x", + "y", + "z", + "f_dc_0", + "f_dc_1", + "f_dc_2", + "opacity" + ], d = Xi.createEmptyUncompressedSplatArray(); + for (let C = 0; C < a; C++) { + if (this.readRawVertexFast(l, C * h, p, m, o, v), v.scale_0 !== void 0 ? (d.scale_0[C] = Math.exp(v.scale_0), d.scale_1[C] = Math.exp(v.scale_1), d.scale_2[C] = Math.exp(v.scale_2)) : (d.scale_0[C] = 0.01, d.scale_1[C] = 0.01, d.scale_2[C] = 0.01), v.f_dc_0 !== void 0) { + const E = 0.28209479177387814; + d.f_dc_0[C] = (0.5 + E * v.f_dc_0) * 255, d.f_dc_1[C] = (0.5 + E * v.f_dc_1) * 255, d.f_dc_2[C] = (0.5 + E * v.f_dc_2) * 255; + } else + d.f_dc_0[C] = 0, d.f_dc_1[C] = 0, d.f_dc_2[C] = 0; + v.opacity !== void 0 && (d.opacity[C] = 1 / (1 + Math.exp(-v.opacity)) * 255), d.rot_0[C] = v.rot_0, d.rot_1[C] = v.rot_1, d.rot_2[C] = v.rot_2, d.rot_3[C] = v.rot_3, d.x[C] = v.x, d.y[C] = v.y, d.z[C] = v.z, d.splatCount++; + } + const _ = new Xi(e, t, n, r).uncompressedSplatArrayToSplatBuffer(d); + console.log("Total valid splats: ", _.getSplatCount(), "out of", a); + const A = performance.now(); + return console.log("Parsing PLY to SPLAT complete!"), console.log("Total time: ", (A - s).toFixed(2) + " ms"), _; + } +} +class rl { + constructor() { + this.splatBuffer = null; + } + loadFromURL(e, t, n, r, s, a) { + return mc(e, t).then((o) => { + const c = new m_(o).parseToSplatBuffer(n, r, s, a); + return this.splatBuffer = c, c; + }); + } +} +const Wr = { + Splat: 0, + KSplat: 1, + Ply: 2 +}; +class Bn { + constructor(e = null) { + this.splatBuffer = e, this.downLoadLink = null; + } + static isFileSplatFormat(e) { + return Bn.isCustomSplatFormat(e) || Bn.isStandardSplatFormat(e); + } + static isCustomSplatFormat(e) { + return e.endsWith(".ksplat"); + } + static isStandardSplatFormat(e) { + return e.endsWith(".splat"); + } + loadFromURL(e, t, n, r, s, a, o) { + return mc(e, t).then((l) => { + const c = o === Wr.KSplat || Bn.isCustomSplatFormat(e); + let u; + if (c) + u = new $t(l); + else { + const f = new Xi(n, r, s, a), h = Bn.parseStandardSplatToUncompressedSplatArray(l); + u = f.uncompressedSplatArrayToSplatBuffer(h); + } + return u; + }); + } + static parseStandardSplatToUncompressedSplatArray(e) { + const n = e.byteLength / 32, r = Xi.createEmptyUncompressedSplatArray(); + for (let s = 0; s < n; s++) { + const c = s * 32, u = new Float32Array(e, c, 3), f = new Float32Array(e, c + 12, 3), h = new Uint8Array(e, c + 12 + 12, 4), p = new Uint8Array(e, c + 12 + 12 + 4, 4), g = new wt( + (p[1] - 128) / 128, + (p[2] - 128) / 128, + (p[3] - 128) / 128, + (p[0] - 128) / 128 + ); + g.normalize(), r.addSplat( + u[0], + u[1], + u[2], + f[0], + f[1], + f[2], + g.w, + g.x, + g.y, + g.z, + h[0], + h[1], + h[2], + h[3] + ); + } + return r; + } + setFromBuffer(e) { + this.splatBuffer = e; + } + downloadFile(e) { + const t = new Uint8Array(this.splatBuffer.getHeaderBufferData()), n = new Uint8Array(this.splatBuffer.getSplatBufferData()), r = new Blob([t.buffer, n.buffer], { + type: "application/octet-stream" + }); + this.downLoadLink || (this.downLoadLink = document.createElement("a"), document.body.appendChild(this.downLoadLink)), this.downLoadLink.download = e, this.downLoadLink.href = URL.createObjectURL(r), this.downLoadLink.click(); + } +} +const sl = { type: "change" }, Zs = { type: "start" }, ol = { type: "end" }, zr = new Jl(), al = new Fn(), g_ = Math.cos(70 * Yl.DEG2RAD); +class __ extends ui { + constructor(e, t) { + super(), this.object = e, this.domElement = t, this.domElement.style.touchAction = "none", this.enabled = !0, this.target = new P(), this.minDistance = 0, this.maxDistance = 1 / 0, this.minZoom = 0, this.maxZoom = 1 / 0, this.minPolarAngle = 0, this.maxPolarAngle = Math.PI, this.minAzimuthAngle = -1 / 0, this.maxAzimuthAngle = 1 / 0, this.enableDamping = !1, this.dampingFactor = 0.05, this.enableZoom = !0, this.zoomSpeed = 1, this.enableRotate = !0, this.rotateSpeed = 1, this.enablePan = !0, this.panSpeed = 1, this.screenSpacePanning = !0, this.keyPanSpeed = 7, this.zoomToCursor = !1, this.autoRotate = !1, this.autoRotateSpeed = 2, this.keys = { LEFT: "KeyA", UP: "KeyW", RIGHT: "KeyD", BOTTOM: "KeyS" }, this.mouseButtons = { LEFT: fi.ROTATE, MIDDLE: fi.DOLLY, RIGHT: fi.PAN }, this.touches = { ONE: hi.ROTATE, TWO: hi.DOLLY_PAN }, this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object.zoom, this._domElementKeyEvents = null, this.getPolarAngle = function() { + return o.phi; + }, this.getAzimuthalAngle = function() { + return o.theta; + }, this.getDistance = function() { + return this.object.position.distanceTo(this.target); + }, this.listenToKeyEvents = function(R) { + R.addEventListener("keydown", Q), this._domElementKeyEvents = R; + }, this.stopListenToKeyEvents = function() { + this._domElementKeyEvents.removeEventListener("keydown", Q), this._domElementKeyEvents = null; + }, this.saveState = function() { + n.target0.copy(n.target), n.position0.copy(n.object.position), n.zoom0 = n.object.zoom; + }, this.reset = function() { + n.target.copy(n.target0), n.object.position.copy(n.position0), n.object.zoom = n.zoom0, n.object.updateProjectionMatrix(), n.dispatchEvent(sl), n.update(), s = r.NONE; + }, this.update = function() { + const R = new P(), le = new wt().setFromUnitVectors(e.up, new P(0, 1, 0)), ve = le.clone().invert(), fe = new P(), he = new wt(), _e = new P(), De = 2 * Math.PI; + return function() { + le.setFromUnitVectors(e.up, new P(0, 1, 0)), ve.copy(le).invert(); + const $e = n.object.position; + R.copy($e).sub(n.target), R.applyQuaternion(le), o.setFromVector3(R), n.autoRotate && s === r.NONE && T(W()), n.enableDamping ? (o.theta += l.theta * n.dampingFactor, o.phi += l.phi * n.dampingFactor) : (o.theta += l.theta, o.phi += l.phi); + let D = n.minAzimuthAngle, re = n.maxAzimuthAngle; + isFinite(D) && isFinite(re) && (D < -Math.PI ? D += De : D > Math.PI && (D -= De), re < -Math.PI ? re += De : re > Math.PI && (re -= De), D <= re ? o.theta = Math.max(D, Math.min(re, o.theta)) : o.theta = o.theta > (D + re) / 2 ? Math.max(D, o.theta) : Math.min(re, o.theta)), o.phi = Math.max(n.minPolarAngle, Math.min(n.maxPolarAngle, o.phi)), o.makeSafe(), n.enableDamping === !0 ? n.target.addScaledVector(u, n.dampingFactor) : n.target.add(u), n.zoomToCursor && E || n.object.isOrthographicCamera ? o.radius = q(o.radius) : o.radius = q(o.radius * c), R.setFromSpherical(o), R.applyQuaternion(ve), $e.copy(n.target).add(R), n.object.lookAt(n.target), n.enableDamping === !0 ? (l.theta *= 1 - n.dampingFactor, l.phi *= 1 - n.dampingFactor, u.multiplyScalar(1 - n.dampingFactor)) : (l.set(0, 0, 0), u.set(0, 0, 0)); + let z = !1; + if (n.zoomToCursor && E) { + let ie = null; + if (n.object.isPerspectiveCamera) { + const ae = R.length(); + ie = q(ae * c); + const Oe = ae - ie; + n.object.position.addScaledVector(A, Oe), n.object.updateMatrixWorld(); + } else if (n.object.isOrthographicCamera) { + const ae = new P(C.x, C.y, 0); + ae.unproject(n.object), n.object.zoom = Math.max(n.minZoom, Math.min(n.maxZoom, n.object.zoom / c)), n.object.updateProjectionMatrix(), z = !0; + const Oe = new P(C.x, C.y, 0); + Oe.unproject(n.object), n.object.position.sub(Oe).add(ae), n.object.updateMatrixWorld(), ie = R.length(); + } else + console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."), n.zoomToCursor = !1; + ie !== null && (this.screenSpacePanning ? n.target.set(0, 0, -1).transformDirection(n.object.matrix).multiplyScalar(ie).add(n.object.position) : (zr.origin.copy(n.object.position), zr.direction.set(0, 0, -1).transformDirection(n.object.matrix), Math.abs(n.object.up.dot(zr.direction)) < g_ ? e.lookAt(n.target) : (al.setFromNormalAndCoplanarPoint(n.object.up, n.target), zr.intersectPlane(al, n.target)))); + } else + n.object.isOrthographicCamera && (n.object.zoom = Math.max(n.minZoom, Math.min(n.maxZoom, n.object.zoom / c)), n.object.updateProjectionMatrix(), z = !0); + return c = 1, E = !1, z || fe.distanceToSquared(n.object.position) > a || 8 * (1 - he.dot(n.object.quaternion)) > a || _e.distanceToSquared(n.target) > 0 ? (n.dispatchEvent(sl), fe.copy(n.object.position), he.copy(n.object.quaternion), _e.copy(n.target), z = !1, !0) : !1; + }; + }(), this.dispose = function() { + n.domElement.removeEventListener("contextmenu", Le), n.domElement.removeEventListener("pointerdown", Ie), n.domElement.removeEventListener("pointercancel", Je), n.domElement.removeEventListener("wheel", X), n.domElement.removeEventListener("pointermove", Be), n.domElement.removeEventListener("pointerup", Je), n._domElementKeyEvents !== null && (n._domElementKeyEvents.removeEventListener("keydown", Q), n._domElementKeyEvents = null); + }; + const n = this, r = { + NONE: -1, + ROTATE: 0, + DOLLY: 1, + PAN: 2, + TOUCH_ROTATE: 3, + TOUCH_PAN: 4, + TOUCH_DOLLY_PAN: 5, + TOUCH_DOLLY_ROTATE: 6 + }; + let s = r.NONE; + const a = 1e-6, o = new il(), l = new il(); + let c = 1; + const u = new P(), f = new me(), h = new me(), p = new me(), g = new me(), v = new me(), m = new me(), d = new me(), M = new me(), _ = new me(), A = new P(), C = new me(); + let E = !1; + const b = [], I = {}; + function W() { + return 2 * Math.PI / 60 / 60 * n.autoRotateSpeed; + } + function S() { + return Math.pow(0.95, n.zoomSpeed); + } + function T(R) { + l.theta -= R; + } + function Y(R) { + l.phi -= R; + } + const K = function() { + const R = new P(); + return function(ve, fe) { + R.setFromMatrixColumn(fe, 0), R.multiplyScalar(-ve), u.add(R); + }; + }(), L = function() { + const R = new P(); + return function(ve, fe) { + n.screenSpacePanning === !0 ? R.setFromMatrixColumn(fe, 1) : (R.setFromMatrixColumn(fe, 0), R.crossVectors(n.object.up, R)), R.multiplyScalar(ve), u.add(R); + }; + }(), N = function() { + const R = new P(); + return function(ve, fe) { + const he = n.domElement; + if (n.object.isPerspectiveCamera) { + const _e = n.object.position; + R.copy(_e).sub(n.target); + let De = R.length(); + De *= Math.tan(n.object.fov / 2 * Math.PI / 180), K(2 * ve * De / he.clientHeight, n.object.matrix), L(2 * fe * De / he.clientHeight, n.object.matrix); + } else + n.object.isOrthographicCamera ? (K(ve * (n.object.right - n.object.left) / n.object.zoom / he.clientWidth, n.object.matrix), L(fe * (n.object.top - n.object.bottom) / n.object.zoom / he.clientHeight, n.object.matrix)) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."), n.enablePan = !1); + }; + }(); + function O(R) { + n.object.isPerspectiveCamera || n.object.isOrthographicCamera ? c /= R : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), n.enableZoom = !1); + } + function B(R) { + n.object.isPerspectiveCamera || n.object.isOrthographicCamera ? c *= R : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), n.enableZoom = !1); + } + function j(R) { + if (!n.zoomToCursor) + return; + E = !0; + const le = n.domElement.getBoundingClientRect(), ve = R.clientX - le.left, fe = R.clientY - le.top, he = le.width, _e = le.height; + C.x = ve / he * 2 - 1, C.y = -(fe / _e) * 2 + 1, A.set(C.x, C.y, 1).unproject(e).sub(e.position).normalize(); + } + function q(R) { + return Math.max(n.minDistance, Math.min(n.maxDistance, R)); + } + function J(R) { + f.set(R.clientX, R.clientY); + } + function ne(R) { + j(R), d.set(R.clientX, R.clientY); + } + function ue(R) { + g.set(R.clientX, R.clientY); + } + function Z(R) { + h.set(R.clientX, R.clientY), p.subVectors(h, f).multiplyScalar(n.rotateSpeed); + const le = n.domElement; + T(2 * Math.PI * p.x / le.clientHeight), Y(2 * Math.PI * p.y / le.clientHeight), f.copy(h), n.update(); + } + function H(R) { + M.set(R.clientX, R.clientY), _.subVectors(M, d), _.y > 0 ? O(S()) : _.y < 0 && B(S()), d.copy(M), n.update(); + } + function ee(R) { + v.set(R.clientX, R.clientY), m.subVectors(v, g).multiplyScalar(n.panSpeed), N(m.x, m.y), g.copy(v), n.update(); + } + function pe(R) { + j(R), R.deltaY < 0 ? B(S()) : R.deltaY > 0 && O(S()), n.update(); + } + function Te(R) { + let le = !1; + switch (R.code) { + case n.keys.UP: + R.ctrlKey || R.metaKey || R.shiftKey ? Y(2 * Math.PI * n.rotateSpeed / n.domElement.clientHeight) : N(0, n.keyPanSpeed), le = !0; + break; + case n.keys.BOTTOM: + R.ctrlKey || R.metaKey || R.shiftKey ? Y(-2 * Math.PI * n.rotateSpeed / n.domElement.clientHeight) : N(0, -n.keyPanSpeed), le = !0; + break; + case n.keys.LEFT: + R.ctrlKey || R.metaKey || R.shiftKey ? T(2 * Math.PI * n.rotateSpeed / n.domElement.clientHeight) : N(n.keyPanSpeed, 0), le = !0; + break; + case n.keys.RIGHT: + R.ctrlKey || R.metaKey || R.shiftKey ? T(-2 * Math.PI * n.rotateSpeed / n.domElement.clientHeight) : N(-n.keyPanSpeed, 0), le = !0; + break; + } + le && (R.preventDefault(), n.update()); + } + function xe() { + if (b.length === 1) + f.set(b[0].pageX, b[0].pageY); + else { + const R = 0.5 * (b[0].pageX + b[1].pageX), le = 0.5 * (b[0].pageY + b[1].pageY); + f.set(R, le); + } + } + function ge() { + if (b.length === 1) + g.set(b[0].pageX, b[0].pageY); + else { + const R = 0.5 * (b[0].pageX + b[1].pageX), le = 0.5 * (b[0].pageY + b[1].pageY); + g.set(R, le); + } + } + function Ke() { + const R = b[0].pageX - b[1].pageX, le = b[0].pageY - b[1].pageY, ve = Math.sqrt(R * R + le * le); + d.set(0, ve); + } + function we() { + n.enableZoom && Ke(), n.enablePan && ge(); + } + function F() { + n.enableZoom && Ke(), n.enableRotate && xe(); + } + function lt(R) { + if (b.length == 1) + h.set(R.pageX, R.pageY); + else { + const ve = Re(R), fe = 0.5 * (R.pageX + ve.x), he = 0.5 * (R.pageY + ve.y); + h.set(fe, he); + } + p.subVectors(h, f).multiplyScalar(n.rotateSpeed); + const le = n.domElement; + T(2 * Math.PI * p.x / le.clientHeight), Y(2 * Math.PI * p.y / le.clientHeight), f.copy(h); + } + function Me(R) { + if (b.length === 1) + v.set(R.pageX, R.pageY); + else { + const le = Re(R), ve = 0.5 * (R.pageX + le.x), fe = 0.5 * (R.pageY + le.y); + v.set(ve, fe); + } + m.subVectors(v, g).multiplyScalar(n.panSpeed), N(m.x, m.y), g.copy(v); + } + function Ne(R) { + const le = Re(R), ve = R.pageX - le.x, fe = R.pageY - le.y, he = Math.sqrt(ve * ve + fe * fe); + M.set(0, he), _.set(0, Math.pow(M.y / d.y, n.zoomSpeed)), O(_.y), d.copy(M); + } + function ye(R) { + n.enableZoom && Ne(R), n.enablePan && Me(R); + } + function qe(R) { + n.enableZoom && Ne(R), n.enableRotate && lt(R); + } + function Ie(R) { + n.enabled !== !1 && (b.length === 0 && (n.domElement.setPointerCapture(R.pointerId), n.domElement.addEventListener("pointermove", Be), n.domElement.addEventListener("pointerup", Je)), Ae(R), R.pointerType === "touch" ? te(R) : w(R)); + } + function Be(R) { + n.enabled !== !1 && (R.pointerType === "touch" ? $(R) : x(R)); + } + function Je(R) { + se(R), b.length === 0 && (n.domElement.releasePointerCapture(R.pointerId), n.domElement.removeEventListener("pointermove", Be), n.domElement.removeEventListener("pointerup", Je)), n.dispatchEvent(ol), s = r.NONE; + } + function w(R) { + let le; + switch (R.button) { + case 0: + le = n.mouseButtons.LEFT; + break; + case 1: + le = n.mouseButtons.MIDDLE; + break; + case 2: + le = n.mouseButtons.RIGHT; + break; + default: + le = -1; + } + switch (le) { + case fi.DOLLY: + if (n.enableZoom === !1) + return; + ne(R), s = r.DOLLY; + break; + case fi.ROTATE: + if (R.ctrlKey || R.metaKey || R.shiftKey) { + if (n.enablePan === !1) + return; + ue(R), s = r.PAN; + } else { + if (n.enableRotate === !1) + return; + J(R), s = r.ROTATE; + } + break; + case fi.PAN: + if (R.ctrlKey || R.metaKey || R.shiftKey) { + if (n.enableRotate === !1) + return; + J(R), s = r.ROTATE; + } else { + if (n.enablePan === !1) + return; + ue(R), s = r.PAN; + } + break; + default: + s = r.NONE; + } + s !== r.NONE && n.dispatchEvent(Zs); + } + function x(R) { + switch (s) { + case r.ROTATE: + if (n.enableRotate === !1) + return; + Z(R); + break; + case r.DOLLY: + if (n.enableZoom === !1) + return; + H(R); + break; + case r.PAN: + if (n.enablePan === !1) + return; + ee(R); + break; + } + } + function X(R) { + n.enabled === !1 || n.enableZoom === !1 || s !== r.NONE || (R.preventDefault(), n.dispatchEvent(Zs), pe(R), n.dispatchEvent(ol)); + } + function Q(R) { + n.enabled === !1 || n.enablePan === !1 || Te(R); + } + function te(R) { + switch (ce(R), b.length) { + case 1: + switch (n.touches.ONE) { + case hi.ROTATE: + if (n.enableRotate === !1) + return; + xe(), s = r.TOUCH_ROTATE; + break; + case hi.PAN: + if (n.enablePan === !1) + return; + ge(), s = r.TOUCH_PAN; + break; + default: + s = r.NONE; + } + break; + case 2: + switch (n.touches.TWO) { + case hi.DOLLY_PAN: + if (n.enableZoom === !1 && n.enablePan === !1) + return; + we(), s = r.TOUCH_DOLLY_PAN; + break; + case hi.DOLLY_ROTATE: + if (n.enableZoom === !1 && n.enableRotate === !1) + return; + F(), s = r.TOUCH_DOLLY_ROTATE; + break; + default: + s = r.NONE; + } + break; + default: + s = r.NONE; + } + s !== r.NONE && n.dispatchEvent(Zs); + } + function $(R) { + switch (ce(R), s) { + case r.TOUCH_ROTATE: + if (n.enableRotate === !1) + return; + lt(R), n.update(); + break; + case r.TOUCH_PAN: + if (n.enablePan === !1) + return; + Me(R), n.update(); + break; + case r.TOUCH_DOLLY_PAN: + if (n.enableZoom === !1 && n.enablePan === !1) + return; + ye(R), n.update(); + break; + case r.TOUCH_DOLLY_ROTATE: + if (n.enableZoom === !1 && n.enableRotate === !1) + return; + qe(R), n.update(); + break; + default: + s = r.NONE; + } + } + function Le(R) { + n.enabled !== !1 && R.preventDefault(); + } + function Ae(R) { + b.push(R); + } + function se(R) { + delete I[R.pointerId]; + for (let le = 0; le < b.length; le++) + if (b[le].pointerId == R.pointerId) { + b.splice(le, 1); + return; + } + } + function ce(R) { + let le = I[R.pointerId]; + le === void 0 && (le = new me(), I[R.pointerId] = le), le.set(R.pageX, R.pageY); + } + function Re(R) { + const le = R.pointerId === b[0].pointerId ? b[1] : b[0]; + return I[le.pointerId]; + } + n.domElement.addEventListener("contextmenu", Le), n.domElement.addEventListener("pointerdown", Ie), n.domElement.addEventListener("pointercancel", Je), n.domElement.addEventListener("wheel", X, { passive: !1 }), this.update(); + } +} +class v_ { + constructor(e, t) { + this.message = e || "Loading...", this.container = t || document.body, this.spinnerDivContainerOuter = document.createElement("div"), this.spinnerDivContainerOuter.className = "outerContainer", this.spinnerDivContainerOuter.style.display = "none", this.spinnerDivContainer = document.createElement("div"), this.spinnerDivContainer.className = "container", this.spinnerDiv = document.createElement("div"), this.spinnerDiv.className = "loader", this.messageDiv = document.createElement("div"), this.messageDiv.className = "message", this.messageDiv.innerHTML = this.message, this.spinnerDivContainer.appendChild(this.spinnerDiv), this.spinnerDivContainer.appendChild(this.messageDiv), this.spinnerDivContainerOuter.appendChild(this.spinnerDivContainer), this.container.appendChild(this.spinnerDivContainerOuter); + const n = document.createElement("style"); + n.innerHTML = ` + + .message { + font-family: arial; + font-size: 12pt; + color: #ffffff; + text-align: center; + padding-top:15px; + width: 180px; + } + + .outerContainer { + width: 100%; + height: 100%; + } + + .container { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-80px, -80px); + width: 180px; + } + + .loader { + width: 120px; /* the size */ + padding: 15px; /* the border thickness */ + background: #07e8d6; /* the color */ + z-index:99999; + + aspect-ratio: 1; + border-radius: 50%; + --_m: + conic-gradient(#0000,#000), + linear-gradient(#000 0 0) content-box; + -webkit-mask: var(--_m); + mask: var(--_m); + -webkit-mask-composite: source-out; + mask-composite: subtract; + box-sizing: border-box; + animation: load 1s linear infinite; + margin-left: 30px; + } + + @keyframes load { + to{transform: rotate(1turn)} + } + + `, this.spinnerDivContainerOuter.appendChild(n); + } + show() { + this.spinnerDivContainerOuter.style.display = "block"; + } + hide() { + this.spinnerDivContainerOuter.style.display = "none"; + } + setContainer(e) { + this.container && this.container.removeChild(this.spinnerDivContainerOuter), this.container = e, this.container.appendChild(this.spinnerDivContainerOuter), this.spinnerDivContainerOuter.style.zIndex = this.container.style.zIndex + 1; + } + setMessage(e) { + this.messageDiv.innerHTML = e; + } +} +class x_ extends gt { + constructor(e = new P(0, 0, 1), t = new P(0, 0, 0), n = 1, r = 0.1, s = 16776960, a = n * 0.2, o = a * 0.2) { + super(), this.type = "ArrowHelper"; + const l = new hr(r, r, n, 32); + l.translate(0, n / 2, 0); + const c = new hr(0, o, a, 32); + c.translate(0, n, 0), this.position.copy(t), this.line = new at(l, new oi({ color: s, toneMapped: !1 })), this.line.matrixAutoUpdate = !1, this.add(this.line), this.cone = new at(c, new oi({ color: s, toneMapped: !1 })), this.cone.matrixAutoUpdate = !1, this.add(this.cone), this.setDirection(e); + } + setDirection(e) { + if (e.y > 0.99999) + this.quaternion.set(0, 0, 0, 1); + else if (e.y < -0.99999) + this.quaternion.set(1, 0, 0, 0); + else { + _axis.set(e.z, 0, -e.x).normalize(); + const t = Math.acos(e.y); + this.quaternion.setFromAxisAngle(_axis, t); + } + } + setColor(e) { + this.line.material.color.set(e), this.cone.material.color.set(e); + } + copy(e) { + return super.copy(e, !1), this.line.copy(e.line), this.cone.copy(e.cone), this; + } + dispose() { + this.line.geometry.dispose(), this.line.material.dispose(), this.cone.geometry.dispose(), this.cone.material.dispose(); + } +} +class ar { + constructor(e) { + Pe(this, "updateFocusMarker", function() { + const e = new P(), t = new ke(); + return function(n, r, s) { + t.copy(r.matrixWorld).invert(), e.copy(n).applyMatrix4(t), e.normalize().multiplyScalar(10), e.applyMatrix4(r.matrixWorld), this.focusMarker.position.copy(e), this.focusMarker.material.uniforms.realFocusPosition.value.copy(n), this.focusMarker.material.uniforms.viewport.value.copy(s), this.focusMarker.material.uniformsNeedUpdate = !0; + }; + }()); + Pe(this, "positionAndOrientControlPlane", function() { + const e = new wt(), t = new P(0, 1, 0); + return function(n, r) { + e.setFromUnitVectors(t, r), this.controlPlane.position.copy(n), this.controlPlane.quaternion.copy(e); + }; + }()); + this.threeScene = e, this.splatRenderTarget = null, this.renderTargetCopyQuad = null, this.renderTargetCopyCamera = null, this.meshCursor = null, this.focusMarker = null, this.controlPlane = null, this.debugRoot = null, this.secondaryDebugRoot = null; + } + updateSplatRenderTargetForRenderDimensions(e, t) { + this.destroySplatRendertarget(), this.splatRenderTarget = new Vn(e, t, { + format: Vt, + stencilBuffer: !1, + depthBuffer: !0 + }), this.splatRenderTarget.depthTexture = new So(e, t), this.splatRenderTarget.depthTexture.format = Hn, this.splatRenderTarget.depthTexture.type = nn; + } + destroySplatRendertarget() { + this.splatRenderTarget && (this.splatRenderTarget = null); + } + setupRenderTargetCopyObjects() { + const e = { + sourceColorTexture: { + type: "t", + value: null + }, + sourceDepthTexture: { + type: "t", + value: null + } + }, t = new Xt({ + vertexShader: ` + varying vec2 vUv; + void main() { + vUv = uv; + gl_Position = vec4( position.xy, 0.0, 1.0 ); + } + `, + fragmentShader: ` + #include + #include + varying vec2 vUv; + uniform sampler2D sourceColorTexture; + uniform sampler2D sourceDepthTexture; + void main() { + vec4 color = texture2D(sourceColorTexture, vUv); + float fragDepth = texture2D(sourceDepthTexture, vUv).x; + gl_FragDepth = fragDepth; + gl_FragColor = vec4(color.rgb, color.a * 2.0); + } + `, + uniforms: e, + depthWrite: !1, + depthTest: !1, + transparent: !0, + blending: Ol, + blendSrc: cr, + blendSrcAlpha: cr, + blendDst: ur, + blendDstAlpha: ur + }); + t.extensions.fragDepth = !0, this.renderTargetCopyQuad = new at(new Wi(2, 2), t), this.renderTargetCopyCamera = new lc(-1, 1, 1, -1, 0, 1); + } + destroyRenderTargetCopyObjects() { + this.renderTargetCopyQuad && (Ii(this.renderTargetCopyQuad), this.renderTargetCopyQuad = null); + } + setupMeshCursor() { + if (!this.meshCursor) { + const e = new Mo(0.5, 1.5, 32), t = new oi({ color: 16777215 }), n = new at(e, t); + n.rotation.set(0, 0, Math.PI), n.position.set(0, 1, 0); + const r = new at(e, t); + r.position.set(0, -1, 0); + const s = new at(e, t); + s.rotation.set(0, 0, Math.PI / 2), s.position.set(1, 0, 0); + const a = new at(e, t); + a.rotation.set(0, 0, -Math.PI / 2), a.position.set(-1, 0, 0), this.meshCursor = new gt(), this.meshCursor.add(n), this.meshCursor.add(r), this.meshCursor.add(s), this.meshCursor.add(a), this.meshCursor.scale.set(0.1, 0.1, 0.1), this.threeScene.add(this.meshCursor), this.meshCursor.visible = !1; + } + } + destroyMeshCursor() { + this.meshCursor && (Ii(this.meshCursor), this.threeScene.remove(this.meshCursor), this.meshCursor = null); + } + setMeshCursorVisibility(e) { + this.meshCursor.visible = e; + } + setMeshCursorPosition(e) { + this.meshCursor.position.copy(e); + } + positionAndOrientMeshCursor(e, t) { + this.meshCursor.position.copy(e), this.meshCursor.up.copy(t.up), this.meshCursor.lookAt(t.position); + } + setupFocusMarker() { + if (!this.focusMarker) { + const e = new es(0.5, 32, 32), t = ar.buildFocusMarkerMaterial(); + t.depthTest = !1, t.depthWrite = !1, t.transparent = !0, this.focusMarker = new at(e, t); + } + } + destroyFocusMarker() { + this.focusMarker && (Ii(this.focusMarker), this.focusMarker = null); + } + setFocusMarkerVisibility(e) { + this.focusMarker.visible = e; + } + setFocusMarkerOpacity(e) { + this.focusMarker.material.uniforms.opacity.value = e, this.focusMarker.material.uniformsNeedUpdate = !0; + } + getFocusMarkerOpacity() { + return this.focusMarker.material.uniforms.opacity.value; + } + setupControlPlane() { + if (!this.controlPlane) { + const e = new Wi(1, 1); + e.rotateX(-Math.PI / 2); + const t = new oi({ color: 16777215 }); + t.transparent = !0, t.opacity = 0.6, t.depthTest = !1, t.depthWrite = !1, t.side = en; + const n = new at(e, t), r = new P(0, 1, 0); + r.normalize(); + const s = new P(0, 0, 0), a = 0.5, o = 0.01, l = 56576, c = new x_(r, s, a, o, l, 0.1, 0.03); + this.controlPlane = new gt(), this.controlPlane.add(n), this.controlPlane.add(c); + } + } + destroyControlPlane() { + this.controlPlane && (Ii(this.controlPlane), this.controlPlane = null); + } + setControlPlaneVisibility(e) { + this.controlPlane.visible = e; + } + addDebugMeshes() { + this.debugRoot = this.createDebugMeshes(), this.secondaryDebugRoot = this.createSecondaryDebugMeshes(), this.threeScene.add(this.debugRoot), this.threeScene.add(this.secondaryDebugRoot); + } + destroyDebugMeshes() { + for (let e of [this.debugRoot, this.secondaryDebugRoot]) + e && (Ii(e), this.threeScene.remove(e)); + this.debugRoot = null, this.secondaryDebugRoot = null; + } + createDebugMeshes(e) { + const t = new es(1, 32, 32), n = new gt(), r = (s, a) => { + let o = new at(t, ar.buildDebugMaterial(s)); + o.renderOrder = e, n.add(o), o.position.fromArray(a); + }; + return r(16711680, [-50, 0, 0]), r(16711680, [50, 0, 0]), r(65280, [0, 0, -50]), r(65280, [0, 0, 50]), r(16755200, [5, 0, 5]), n; + } + createSecondaryDebugMeshes(e) { + const t = new Qi(3, 3, 3), n = new gt(); + let r = 12303291; + const s = (o) => { + let l = new at(t, ar.buildDebugMaterial(r)); + l.renderOrder = e, n.add(l), l.position.fromArray(o); + }; + let a = 10; + return s([-a, 0, -a]), s([-a, 0, a]), s([a, 0, -a]), s([a, 0, a]), n; + } + static buildDebugMaterial(e) { + const t = ` + #include + varying float ndcDepth; + + void main() { + gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position.xyz, 1.0); + ndcDepth = gl_Position.z / gl_Position.w; + gl_Position.x = gl_Position.x / gl_Position.w; + gl_Position.y = gl_Position.y / gl_Position.w; + gl_Position.z = 0.0; + gl_Position.w = 1.0; + + } + `, n = ` + #include + uniform vec3 color; + varying float ndcDepth; + void main() { + gl_FragDepth = (ndcDepth + 1.0) / 2.0; + gl_FragColor = vec4(color.rgb, 0.0); + } + `, r = { + color: { + type: "v3", + value: new Qe(e) + } + }, s = new Xt({ + uniforms: r, + vertexShader: t, + fragmentShader: n, + transparent: !1, + depthTest: !0, + depthWrite: !0, + side: hn + }); + return s.extensions.fragDepth = !0, s; + } + static buildFocusMarkerMaterial(e) { + const t = ` + #include + + uniform vec2 viewport; + uniform vec3 realFocusPosition; + + varying vec4 ndcPosition; + varying vec4 ndcCenter; + varying vec4 ndcFocusPosition; + + void main() { + float radius = 0.01; + + vec4 viewPosition = modelViewMatrix * vec4(position.xyz, 1.0); + vec4 viewCenter = modelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0); + + vec4 viewFocusPosition = modelViewMatrix * vec4(realFocusPosition, 1.0); + + ndcPosition = projectionMatrix * viewPosition; + ndcPosition = ndcPosition * vec4(1.0 / ndcPosition.w); + ndcCenter = projectionMatrix * viewCenter; + ndcCenter = ndcCenter * vec4(1.0 / ndcCenter.w); + + ndcFocusPosition = projectionMatrix * viewFocusPosition; + ndcFocusPosition = ndcFocusPosition * vec4(1.0 / ndcFocusPosition.w); + + gl_Position = projectionMatrix * viewPosition; + + } + `, n = ` + #include + uniform vec3 color; + uniform vec2 viewport; + uniform float opacity; + + varying vec4 ndcPosition; + varying vec4 ndcCenter; + varying vec4 ndcFocusPosition; + + void main() { + vec2 screenPosition = vec2(ndcPosition) * viewport; + vec2 screenCenter = vec2(ndcCenter) * viewport; + + vec2 screenVec = screenPosition - screenCenter; + + float projectedRadius = length(screenVec); + + float lineWidth = 0.0005 * viewport.y; + float aaRange = 0.0025 * viewport.y; + float radius = 0.06 * viewport.y; + float radDiff = abs(projectedRadius - radius) - lineWidth; + float alpha = 1.0 - clamp(radDiff / 5.0, 0.0, 1.0); + + gl_FragColor = vec4(color.rgb, alpha * opacity); + } + `, r = { + color: { + type: "v3", + value: new Qe(e) + }, + realFocusPosition: { + type: "v3", + value: new P() + }, + viewport: { + type: "v2", + value: new me() + }, + opacity: { + value: 0 + } + }; + return new Xt({ + uniforms: r, + vertexShader: t, + fragmentShader: n, + transparent: !0, + depthTest: !1, + depthWrite: !1, + side: hn + }); + } + dispose() { + this.destroyMeshCursor(), this.destroyFocusMarker(), this.destroyDebugMeshes(), this.destroyControlPlane(), this.destroyRenderTargetCopyObjects(), this.destroySplatRendertarget(); + } +} +const S_ = new P(1, 0, 0), M_ = new P(0, 1, 0), y_ = new P(0, 0, 1); +class Js { + constructor(e = new P(), t = new P()) { + Pe(this, "intersectBox", function() { + const e = new P(), t = [], n = [], r = []; + return function(s, a) { + if (n[0] = this.origin.x, n[1] = this.origin.y, n[2] = this.origin.z, r[0] = this.direction.x, r[1] = this.direction.y, r[2] = this.direction.z, this.boxContainsPoint(s, this.origin, 1e-4)) + return a && (a.origin.copy(this.origin), a.normal.set(0, 0, 0), a.distance = -1), !0; + for (let o = 0; o < 3; o++) { + if (r[o] == 0) + continue; + const l = o == 0 ? S_ : o == 1 ? M_ : y_, c = r[o] < 0 ? s.max : s.min; + let u = -Math.sign(r[o]); + t[0] = o == 0 ? c.x : o == 1 ? c.y : c.z; + let f = t[0] - n[o]; + if (f * u < 0) { + const h = (o + 1) % 3, p = (o + 2) % 3; + if (t[2] = r[h] / r[o] * f + n[h], t[1] = r[p] / r[o] * f + n[p], e.set( + t[o], + t[p], + t[h] + ), this.boxContainsPoint(s, e, 1e-4)) + return a && (a.origin.copy(e), a.normal.copy(l).multiplyScalar(u), a.distance = e.sub(this.origin).length()), !0; + } + } + return !1; + }; + }()); + Pe(this, "intersectSphere", function() { + const e = new P(); + return function(t, n, r) { + e.copy(t).sub(this.origin); + const s = e.dot(this.direction), a = s * s, l = e.dot(e) - a, c = n * n; + if (l > c) + return !1; + const u = Math.sqrt(c - l), f = s - u, h = s + u; + if (h < 0) + return !1; + let p = f < 0 ? h : f; + return r && (r.origin.copy(this.origin).addScaledVector(this.direction, p), r.normal.copy(r.origin).sub(t).normalize(), r.distance = p), !0; + }; + }()); + this.origin = new P(), this.direction = new P(), this.setParameters(e, t); + } + setParameters(e, t) { + this.origin.copy(e), this.direction.copy(t).normalize(); + } + boxContainsPoint(e, t, n) { + return !(t.x < e.min.x - n || t.x > e.max.x + n || t.y < e.min.y - n || t.y > e.max.y + n || t.z < e.min.z - n || t.z > e.max.z + n); + } +} +class yo { + constructor() { + this.origin = new P(), this.normal = new P(), this.distance = 0, this.splatIndex = 0; + } + set(e, t, n, r) { + this.origin.copy(e), this.normal.copy(t), this.distance = n, this.splatIndex = r; + } + clone() { + const e = new yo(); + return e.origin.copy(this.origin), e.normal.copy(this.normal), e.distance = this.distance, e.splatIndex = this.splatIndex, e; + } +} +class A_ { + constructor(e, t, n = !1) { + Pe(this, "setFromCameraAndScreenPosition", function() { + const e = new me(); + return function(t, n, r) { + if (e.x = n.x / r.x * 2 - 1, e.y = (r.y - n.y) / r.y * 2 - 1, t.isPerspectiveCamera) + this.ray.origin.setFromMatrixPosition(t.matrixWorld), this.ray.direction.set(e.x, e.y, 0.5).unproject(t).sub(this.ray.origin).normalize(), this.camera = t; + else if (t.isOrthographicCamera) + this.ray.origin.set( + n.x, + n.y, + (t.near + t.far) / (t.near - t.far) + ).unproject(t), this.ray.direction.set(0, 0, -1).transformDirection(t.matrixWorld), this.camera = t; + else + throw new Error("Raycaster::setFromCameraAndScreenPosition() -> Unsupported camera type"); + }; + }()); + Pe(this, "intersectSplatMesh", function() { + const e = new ke(), t = new ke(), n = new ke(), r = new Js(), s = new P(); + return function(a, o = []) { + const l = a.getSplatTree(); + for (let c = 0; c < l.subTrees.length; c++) { + const u = l.subTrees[c]; + t.copy(a.matrixWorld), a.getSceneTransform(c, n), t.multiply(n), e.copy(t).invert(), r.origin.copy(this.ray.origin).applyMatrix4(e), r.direction.copy(this.ray.origin).add(this.ray.direction), r.direction.applyMatrix4(e).sub(r.origin).normalize(); + const f = []; + u.rootNode && this.castRayAtSplatTreeNode(r, l, u.rootNode, f), f.forEach((h) => { + h.origin.applyMatrix4(t), h.normal.applyMatrix4(t).normalize(), h.distance = s.copy(h.origin).sub(this.ray.origin).length(); + }), o.push(...f); + } + return o.sort((c, u) => c.distance > u.distance ? 1 : -1), o; + }; + }()); + Pe(this, "castRayAtSplatTreeNode", function() { + const e = new ut(), t = new P(), n = new P(), r = new wt(), s = new yo(), a = 1e-7, o = new P(0, 0, 0), l = new ke(), c = new ke(), u = new ke(), f = new ke(), h = new ke(), p = new Js(); + return function(g, v, m, d = []) { + if (g.intersectBox(m.boundingBox)) { + if (m.data.indexes && m.data.indexes.length > 0) + for (let M = 0; M < m.data.indexes.length; M++) { + const _ = m.data.indexes[M]; + if (v.splatMesh.getSplatColor(_, e, !1), v.splatMesh.getSplatCenter(_, t, !1), v.splatMesh.getSplatScaleAndRotation(_, n, r, !1), !(n.x <= a || n.y <= a || n.z <= a)) + if (this.raycastAgainstTrueSplatEllipsoid) { + c.makeScale(n.x, n.y, n.z), u.makeRotationFromQuaternion(r); + const A = Math.log10(e.w) * 2; + if (l.makeScale(A, A, A), h.copy(l).multiply(u).multiply(c), f.copy(h).invert(), p.origin.copy(g.origin).sub(t).applyMatrix4(f), p.direction.copy(g.origin).add(g.direction).sub(t), p.direction.applyMatrix4(f).sub(p.origin).normalize(), p.intersectSphere(o, 1, s)) { + const C = s.clone(); + C.splatIndex = _, C.origin.applyMatrix4(h).add(t), d.push(C); + } + } else { + const A = (n.x + n.y + n.z) / 3; + if (g.intersectSphere(t, A, s)) { + const C = s.clone(); + C.splatIndex = _, d.push(C); + } + } + } + if (m.children && m.children.length > 0) + for (let M of m.children) + this.castRayAtSplatTreeNode(g, v, M, d); + return d; + } + }; + }()); + this.ray = new Js(e, t), this.raycastAgainstTrueSplatEllipsoid = n; + } +} +class E_ { + constructor(e, t = new P(), n = new wt(), r = new P(1, 1, 1)) { + this.splatBuffer = e, this.position = t.clone(), this.quaternion = n.clone(), this.scale = r.clone(), this.transform = new ke(), this.updateTransform(); + } + copyTransformData(e) { + this.position.copy(e.position), this.quaternion.copy(e.quaternion), this.scale.copy(e.scale), this.transform.copy(e.transform); + } + updateTransform() { + this.transform.compose(this.position, this.quaternion, this.scale); + } +} +let b_ = 0; +class ll { + constructor(e, t, n, r) { + this.min = new P().copy(e), this.max = new P().copy(t), this.boundingBox = new Rt(this.min, this.max), this.center = new P().copy(this.max).sub(this.min).multiplyScalar(0.5).add(this.min), this.depth = n, this.children = [], this.data = null, this.id = r || b_++; + } +} +class T_ { + constructor(e, t) { + this.maxDepth = e, this.maxCentersPerNode = t, this.sceneDimensions = new P(), this.sceneMin = new P(), this.sceneMax = new P(), this.splatMesh = null, this.rootNode = null, this.addedIndexes = {}, this.nodesWithIndexes = []; + } +} +class lr { + constructor(e, t) { + this.maxDepth = e, this.maxCentersPerNode = t, this.splatMesh = null, this.subTrees = []; + } + processSplatMesh(e, t = () => !0) { + this.splatMesh = e, this.subTrees = []; + const n = new P(), r = function(s, a, o, l) { + const c = new T_(o, l); + let u = 0; + const f = []; + for (let h = 0; h < a; h++) { + const p = h + s; + t(p) && (e.getSplatCenter(p, n), (u === 0 || n.x < c.sceneMin.x) && (c.sceneMin.x = n.x), (u === 0 || n.x > c.sceneMax.x) && (c.sceneMax.x = n.x), (u === 0 || n.y < c.sceneMin.y) && (c.sceneMin.y = n.y), (u === 0 || n.y > c.sceneMax.y) && (c.sceneMax.y = n.y), (u === 0 || n.z < c.sceneMin.z) && (c.sceneMin.z = n.z), (u === 0 || n.z > c.sceneMax.z) && (c.sceneMax.z = n.z), u++, f.push(p)); + } + return c.sceneDimensions.copy(c.sceneMax).sub(c.sceneMin), c.rootNode = new ll(c.sceneMin, c.sceneMax, 0), c.rootNode.data = { + indexes: f + }, c; + }; + if (e.dynamicMode) { + let s = 0; + for (let a = 0; a < e.scenes.length; a++) { + const l = e.getScene(a).splatBuffer.getSplatCount(), c = r(s, l, this.maxDepth, this.maxCentersPerNode); + this.subTrees[a] = c, lr.processNode(c, c.rootNode, e), s += l; + } + } else { + const s = r(0, e.getSplatCount(), this.maxDepth, this.maxCentersPerNode); + this.subTrees[0] = s, lr.processNode(s, s.rootNode, e); + } + } + static processNode(e, t, n) { + const r = t.data.indexes.length; + if (r < e.maxCentersPerNode || t.depth > e.maxDepth) { + const f = []; + for (let h = 0; h < t.data.indexes.length; h++) + e.addedIndexes[t.data.indexes[h]] || (f.push(t.data.indexes[h]), e.addedIndexes[t.data.indexes[h]] = !0); + t.data.indexes = f, e.nodesWithIndexes.push(t); + return; + } + const s = new P().copy(t.max).sub(t.min), a = new P().copy(s).multiplyScalar(0.5), o = new P().copy(t.min).add(a), l = [ + // top section, clockwise from upper-left (looking from above, +Y) + new Rt( + new P(o.x - a.x, o.y, o.z - a.z), + new P(o.x, o.y + a.y, o.z) + ), + new Rt( + new P(o.x, o.y, o.z - a.z), + new P(o.x + a.x, o.y + a.y, o.z) + ), + new Rt( + new P(o.x, o.y, o.z), + new P( + o.x + a.x, + o.y + a.y, + o.z + a.z + ) + ), + new Rt( + new P(o.x - a.x, o.y, o.z), + new P(o.x, o.y + a.y, o.z + a.z) + ), + // bottom section, clockwise from lower-left (looking from above, +Y) + new Rt( + new P( + o.x - a.x, + o.y - a.y, + o.z - a.z + ), + new P(o.x, o.y, o.z) + ), + new Rt( + new P(o.x, o.y - a.y, o.z - a.z), + new P(o.x + a.x, o.y, o.z) + ), + new Rt( + new P(o.x, o.y - a.y, o.z), + new P(o.x + a.x, o.y, o.z + a.z) + ), + new Rt( + new P(o.x - a.x, o.y - a.y, o.z), + new P(o.x, o.y, o.z + a.z) + ) + ], c = []; + for (let f = 0; f < l.length; f++) + c[f] = []; + const u = new P(); + for (let f = 0; f < r; f++) { + const h = t.data.indexes[f]; + n.getSplatCenter(h, u); + for (let p = 0; p < l.length; p++) + l[p].containsPoint(u) && c[p].push(h); + } + for (let f = 0; f < l.length; f++) { + const h = new ll(l[f].min, l[f].max, t.depth + 1); + h.data = { + indexes: c[f] + }, t.children.push(h); + } + t.data = {}; + for (let f of t.children) + lr.processNode(e, f, n); + } + countLeaves() { + let e = 0; + return this.visitLeaves(() => { + e++; + }), e; + } + visitLeaves(e) { + const t = (n, r) => { + n.children.length === 0 && r(n); + for (let s of n.children) + t(s, r); + }; + for (let n of this.subTrees) + t(n.rootNode, e); + } +} +class mt { +} +Pe(mt, "DepthMapRange", 65536), Pe(mt, "MemoryPageSize", 65536), Pe(mt, "BytesPerFloat", 4), Pe(mt, "BytesPerInt", 4), Pe(mt, "MaxScenes", 32); +const cl = new Yt(), w_ = new oi(); +class kt extends at { + constructor(t = !0, n = !1, r = 1, s = !0, a = !1) { + super(cl, w_); + Pe(this, "updateUniforms", function() { + const t = new me(); + return function(n, r, s) { + if (this.getSplatCount() > 0) { + if (t.set( + n.x * this.devicePixelRatio, + n.y * this.devicePixelRatio + ), this.material.uniforms.viewport.value.copy(t), this.material.uniforms.basisViewport.value.set(1 / t.x, 1 / t.y), this.material.uniforms.focal.value.set(r, s), this.dynamicMode) + for (let o = 0; o < this.scenes.length; o++) + this.material.uniforms.transforms.value[o].copy(this.getScene(o).transform); + this.material.uniformsNeedUpdate = !0; + } + }; + }()); + Pe(this, "setupDistancesComputationTransformFeedback", /* @__PURE__ */ function() { + let t, n; + return function() { + const r = this.getSplatCount(); + if (!this.renderer || t === this.renderer && n === r) + return; + const s = t !== this.renderer, a = n !== r; + s ? this.disposeDistancesComputationGPUResources() : a && this.disposeDistancesComputationGPUBufferResources(); + const o = this.renderer.getContext(), l = (p, g, v) => { + const m = p.createShader(g); + if (!m) + return console.error("Fatal error: gl could not create a shader object."), null; + if (p.shaderSource(m, v), p.compileShader(m), !p.getShaderParameter(m, p.COMPILE_STATUS)) { + let M = "unknown"; + g === p.VERTEX_SHADER ? M = "vertex shader" : g === p.FRAGMENT_SHADER && (M = "fragement shader"); + const _ = p.getShaderInfoLog(m); + return console.error("Failed to compile " + M + " with these errors:" + _), p.deleteShader(m), null; + } + return m; + }; + let c; + this.integerBasedDistancesComputation ? (c = `#version 300 es + in ivec4 center; + flat out int distance;`, this.dynamicMode ? c += ` + in uint transformIndex; + uniform ivec4 transforms[${mt.MaxScenes}]; + void main(void) { + ivec4 transform = transforms[transformIndex]; + distance = center.x * transform.x + center.y * transform.y + center.z * transform.z + transform.w * center.w; + } + ` : c += ` + uniform ivec3 modelViewProj; + void main(void) { + distance = center.x * modelViewProj.x + center.y * modelViewProj.y + center.z * modelViewProj.z; + } + `) : (c = `#version 300 es + in vec3 center; + flat out float distance;`, this.dynamicMode ? c += ` + in uint transformIndex; + uniform mat4 transforms[${mt.MaxScenes}]; + void main(void) { + vec4 transformedCenter = transforms[transformIndex] * vec4(center, 1.0); + distance = transformedCenter.z; + } + ` : c += ` + uniform vec3 modelViewProj; + void main(void) { + distance = center.x * modelViewProj.x + center.y * modelViewProj.y + center.z * modelViewProj.z; + } + `); + const u = `#version 300 es + precision lowp float; + out vec4 fragColor; + void main(){} + `, f = o.getParameter(o.VERTEX_ARRAY_BINDING), h = o.getParameter(o.CURRENT_PROGRAM); + if (s && (this.distancesTransformFeedback.vao = o.createVertexArray()), o.bindVertexArray(this.distancesTransformFeedback.vao), s) { + const p = o.createProgram(), g = l(o, o.VERTEX_SHADER, c), v = l(o, o.FRAGMENT_SHADER, u); + if (!g || !v) + throw new Error("Could not compile shaders for distances computation on GPU."); + if (o.attachShader(p, g), o.attachShader(p, v), o.transformFeedbackVaryings(p, ["distance"], o.SEPARATE_ATTRIBS), o.linkProgram(p), !o.getProgramParameter(p, o.LINK_STATUS)) { + const d = o.getProgramInfoLog(p); + throw console.error("Fatal error: Failed to link program: " + d), o.deleteProgram(p), o.deleteShader(v), o.deleteShader(g), new Error("Could not link shaders for distances computation on GPU."); + } + this.distancesTransformFeedback.program = p, this.distancesTransformFeedback.vertexShader = g, this.distancesTransformFeedback.vertexShader = v; + } + if (o.useProgram(this.distancesTransformFeedback.program), this.distancesTransformFeedback.centersLoc = o.getAttribLocation(this.distancesTransformFeedback.program, "center"), this.dynamicMode) { + this.distancesTransformFeedback.transformIndexesLoc = o.getAttribLocation(this.distancesTransformFeedback.program, "transformIndex"); + for (let p = 0; p < this.scenes.length; p++) + this.distancesTransformFeedback.transformsLocs[p] = o.getUniformLocation(this.distancesTransformFeedback.program, `transforms[${p}]`); + } else + this.distancesTransformFeedback.modelViewProjLoc = o.getUniformLocation(this.distancesTransformFeedback.program, "modelViewProj"); + (s || a) && (this.distancesTransformFeedback.centersBuffer = o.createBuffer(), o.bindBuffer(o.ARRAY_BUFFER, this.distancesTransformFeedback.centersBuffer), o.enableVertexAttribArray(this.distancesTransformFeedback.centersLoc), this.integerBasedDistancesComputation ? o.vertexAttribIPointer(this.distancesTransformFeedback.centersLoc, 4, o.INT, 0, 0) : o.vertexAttribPointer(this.distancesTransformFeedback.centersLoc, 3, o.FLOAT, !1, 0, 0), this.dynamicMode && (this.distancesTransformFeedback.transformIndexesBuffer = o.createBuffer(), o.bindBuffer(o.ARRAY_BUFFER, this.distancesTransformFeedback.transformIndexesBuffer), o.enableVertexAttribArray(this.distancesTransformFeedback.transformIndexesLoc), o.vertexAttribIPointer(this.distancesTransformFeedback.transformIndexesLoc, 1, o.UNSIGNED_INT, 0, 0))), (s || a) && (this.distancesTransformFeedback.outDistancesBuffer = o.createBuffer()), o.bindBuffer(o.ARRAY_BUFFER, this.distancesTransformFeedback.outDistancesBuffer), o.bufferData(o.ARRAY_BUFFER, r * 4, o.STATIC_READ), s && (this.distancesTransformFeedback.id = o.createTransformFeedback()), o.bindTransformFeedback(o.TRANSFORM_FEEDBACK, this.distancesTransformFeedback.id), o.bindBufferBase(o.TRANSFORM_FEEDBACK_BUFFER, 0, this.distancesTransformFeedback.outDistancesBuffer), h && o.useProgram(h), f && o.bindVertexArray(f), t = this.renderer, n = r; + }; + }()); + /** + * Fill 'array' with the transforms for each scene in this splat mesh. + * @param {Array} array Empty array to be filled with scene transforms. If not empty, contents will be overwritten. + */ + Pe(this, "fillTransformsArray", /* @__PURE__ */ function() { + const t = []; + return function(n) { + t.length !== n.length && (t.length = n.length); + for (let r = 0; r < this.scenes.length; r++) { + const a = this.getScene(r).transform.elements; + for (let o = 0; o < 16; o++) + t[r * 16 + o] = a[o]; + } + n.set(t); + }; + }()); + Pe(this, "computeDistancesOnGPU", function() { + const t = new ke(); + return function(n, r) { + if (!this.renderer) + return; + const s = this.renderer.getContext(), a = s.getParameter(s.VERTEX_ARRAY_BINDING), o = s.getParameter(s.CURRENT_PROGRAM); + if (s.bindVertexArray(this.distancesTransformFeedback.vao), s.useProgram(this.distancesTransformFeedback.program), s.enable(s.RASTERIZER_DISCARD), this.dynamicMode) + for (let u = 0; u < this.scenes.length; u++) + if (t.copy(this.getScene(u).transform), t.premultiply(n), this.integerBasedDistancesComputation) { + const f = kt.getIntegerMatrixArray(t), h = [f[2], f[6], f[10], f[14]]; + s.uniform4i( + this.distancesTransformFeedback.transformsLocs[u], + h[0], + h[1], + h[2], + h[3] + ); + } else + s.uniformMatrix4fv(this.distancesTransformFeedback.transformsLocs[u], !1, t.elements); + else if (this.integerBasedDistancesComputation) { + const u = kt.getIntegerMatrixArray(n), f = [u[2], u[6], u[10]]; + s.uniform3i(this.distancesTransformFeedback.modelViewProjLoc, f[0], f[1], f[2]); + } else { + const u = [n.elements[2], n.elements[6], n.elements[10]]; + s.uniform3f(this.distancesTransformFeedback.modelViewProjLoc, u[0], u[1], u[2]); + } + s.bindBuffer(s.ARRAY_BUFFER, this.distancesTransformFeedback.centersBuffer), s.enableVertexAttribArray(this.distancesTransformFeedback.centersLoc), this.integerBasedDistancesComputation ? s.vertexAttribIPointer(this.distancesTransformFeedback.centersLoc, 4, s.INT, 0, 0) : s.vertexAttribPointer(this.distancesTransformFeedback.centersLoc, 3, s.FLOAT, !1, 0, 0), this.dynamicMode && (s.bindBuffer(s.ARRAY_BUFFER, this.distancesTransformFeedback.transformIndexesBuffer), s.enableVertexAttribArray(this.distancesTransformFeedback.transformIndexesLoc), s.vertexAttribIPointer(this.distancesTransformFeedback.transformIndexesLoc, 1, s.UNSIGNED_INT, 0, 0)), s.bindTransformFeedback(s.TRANSFORM_FEEDBACK, this.distancesTransformFeedback.id), s.bindBufferBase(s.TRANSFORM_FEEDBACK_BUFFER, 0, this.distancesTransformFeedback.outDistancesBuffer), s.beginTransformFeedback(s.POINTS), s.drawArrays(s.POINTS, 0, this.getSplatCount()), s.endTransformFeedback(), s.bindBufferBase(s.TRANSFORM_FEEDBACK_BUFFER, 0, null), s.bindTransformFeedback(s.TRANSFORM_FEEDBACK, null), s.disable(s.RASTERIZER_DISCARD); + const l = s.fenceSync(s.SYNC_GPU_COMMANDS_COMPLETE, 0); + s.flush(); + const c = new Promise((u) => { + const f = () => { + switch (s.clientWaitSync(l, 0, 0)) { + case s.TIMEOUT_EXPIRED: + return setTimeout(f); + case s.WAIT_FAILED: + throw new Error("should never get here"); + default: + s.deleteSync(l); + const v = s.getParameter(s.VERTEX_ARRAY_BINDING); + s.bindVertexArray(this.distancesTransformFeedback.vao), s.bindBuffer(s.ARRAY_BUFFER, this.distancesTransformFeedback.outDistancesBuffer), s.getBufferSubData(s.ARRAY_BUFFER, 0, r), s.bindBuffer(s.ARRAY_BUFFER, null), v && s.bindVertexArray(v), u(); + } + }; + setTimeout(f); + }); + return o && s.useProgram(o), a && s.bindVertexArray(a), c; + }; + }()); + /** + * Get the center for a splat, transformed as appropriate. + * @param {number} globalIndex Global index of splat + * @param {THREE.Vector3} outCenter THREE.Vector3 instance in which to store splat center + * @param {boolean} applySceneTransform By default, if the splat mesh is static, the transform of the scene to which the splat at + * 'globalIndex' belongs will be applied to the splat center. If 'applySceneTransform' is true, + * the scene transform will always be applied and if 'applySceneTransform' is false, the + * scene transform will never be applied. If undefined, the default behavior will apply. + */ + Pe(this, "getSplatCenter", /* @__PURE__ */ function() { + const t = {}; + return function(n, r, s) { + this.getLocalSplatParameters(n, t, s), t.splatBuffer.getSplatCenter(t.localIndex, r, t.sceneTransform); + }; + }()); + /** + * Get the scale and rotation for a splat, transformed as appropriate. + * @param {number} globalIndex Global index of splat + * @param {THREE.Vector3} outScale THREE.Vector3 instance in which to store splat scale + * @param {THREE.Quaternion} outRotation THREE.Quaternion instance in which to store splat rotation + * @param {boolean} applySceneTransform By default, if the splat mesh is static, the transform of the scene to which the splat at + * 'globalIndex' belongs will be applied to the splat scale and rotation. If + * 'applySceneTransform' is true, the scene transform will always be applied and if + * 'applySceneTransform' is false, the scene transform will never be applied. If undefined, + * the default behavior will apply. + */ + Pe(this, "getSplatScaleAndRotation", /* @__PURE__ */ function() { + const t = {}; + return function(n, r, s, a) { + this.getLocalSplatParameters(n, t, a), t.splatBuffer.getSplatScaleAndRotation(t.localIndex, r, s, t.sceneTransform); + }; + }()); + /** + * Get the color for a splat. + * @param {number} globalIndex Global index of splat + * @param {THREE.Vector4} outColor THREE.Vector4 instance in which to store splat color + */ + Pe(this, "getSplatColor", /* @__PURE__ */ function() { + const t = {}; + return function(n, r) { + this.getLocalSplatParameters(n, t), t.splatBuffer.getSplatColor(t.localIndex, r, t.sceneTransform); + }; + }()); + this.renderer = void 0, this.halfPrecisionCovariancesOnGPU = n, this.dynamicMode = t, this.devicePixelRatio = r, this.enableDistancesComputationOnGPU = s, this.integerBasedDistancesComputation = a, this.scenes = [], this.splatTree = null, this.splatDataTextures = null, this.distancesTransformFeedback = { + id: null, + vertexShader: null, + fragmentShader: null, + program: null, + centersBuffer: null, + transformIndexesBuffer: null, + outDistancesBuffer: null, + centersLoc: -1, + modelViewProjLoc: -1, + transformIndexesLoc: -1, + transformsLocs: [] + }, this.globalSplatIndexToLocalSplatIndexMap = [], this.globalSplatIndexToSceneIndexMap = []; + } + /** + * Build the Three.js material that is used to render the splats. + * @param {number} dynamicMode If true, it means the scene geometry represented by this splat mesh is not stationary or + * that the splat count might change + * @return {THREE.ShaderMaterial} + */ + static buildMaterial(t = !1) { + let n = ` + precision highp float; + #include + + attribute uint splatIndex; + + uniform highp sampler2D covariancesTexture; + uniform highp usampler2D centersColorsTexture;`; + t && (n += ` + uniform highp usampler2D transformIndexesTexture; + uniform highp mat4 transforms[${mt.MaxScenes}]; + uniform vec2 transformIndexesTextureSize; + `), n += ` + uniform vec2 focal; + uniform vec2 viewport; + uniform vec2 basisViewport; + uniform vec2 covariancesTextureSize; + uniform vec2 centersColorsTextureSize; + + varying vec4 vColor; + varying vec2 vUv; + + varying vec2 vPosition; + + const float sqrt8 = sqrt(8.0); + + const vec4 encodeNorm4 = vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0); + const uvec4 mask4 = uvec4(uint(0x000000FF), uint(0x0000FF00), uint(0x00FF0000), uint(0xFF000000)); + const uvec4 shift4 = uvec4(0, 8, 16, 24); + vec4 uintToRGBAVec (uint u) { + uvec4 urgba = mask4 & u; + urgba = urgba >> shift4; + vec4 rgba = vec4(urgba) * encodeNorm4; + return rgba; + } + + vec2 getDataUV(in int stride, in int offset, in vec2 dimensions) { + vec2 samplerUV = vec2(0.0, 0.0); + float d = float(splatIndex * uint(stride) + uint(offset)) / dimensions.x; + samplerUV.y = float(floor(d)) / dimensions.y; + samplerUV.x = fract(d); + return samplerUV; + } + + void main () { + + uvec4 sampledCenterColor = texture(centersColorsTexture, getDataUV(1, 0, centersColorsTextureSize)); + vec3 splatCenter = uintBitsToFloat(uvec3(sampledCenterColor.gba));`, t ? n += ` + uint transformIndex = texture(transformIndexesTexture, getDataUV(1, 0, transformIndexesTextureSize)).r; + mat4 transform = transforms[transformIndex]; + mat4 transformModelViewMatrix = modelViewMatrix * transform; + ` : n += "mat4 transformModelViewMatrix = modelViewMatrix;", n += ` + vec4 viewCenter = transformModelViewMatrix * vec4(splatCenter, 1.0); + + vec4 clipCenter = projectionMatrix * viewCenter; + + float clip = 1.2 * clipCenter.w; + if (clipCenter.z < -clip || clipCenter.x < -clip || clipCenter.x > clip || clipCenter.y < -clip || clipCenter.y > clip) { + gl_Position = vec4(0.0, 0.0, 2.0, 1.0); + return; + } + + vPosition = position.xy; + vColor = uintToRGBAVec(sampledCenterColor.r); + + vec2 sampledCovarianceA = texture(covariancesTexture, getDataUV(3, 0, covariancesTextureSize)).rg; + vec2 sampledCovarianceB = texture(covariancesTexture, getDataUV(3, 1, covariancesTextureSize)).rg; + vec2 sampledCovarianceC = texture(covariancesTexture, getDataUV(3, 2, covariancesTextureSize)).rg; + + vec3 cov3D_M11_M12_M13 = vec3(sampledCovarianceA.rg, sampledCovarianceB.r); + vec3 cov3D_M22_M23_M33 = vec3(sampledCovarianceB.g, sampledCovarianceC.rg); + + // Construct the 3D covariance matrix + mat3 Vrk = mat3( + cov3D_M11_M12_M13.x, cov3D_M11_M12_M13.y, cov3D_M11_M12_M13.z, + cov3D_M11_M12_M13.y, cov3D_M22_M23_M33.x, cov3D_M22_M23_M33.y, + cov3D_M11_M12_M13.z, cov3D_M22_M23_M33.y, cov3D_M22_M23_M33.z + ); + + // Construct the Jacobian of the affine approximation of the projection matrix. It will be used to transform the + // 3D covariance matrix instead of using the actual projection matrix because that transformation would + // require a non-linear component (perspective division) which would yield a non-gaussian result. (This assumes + // the current projection is a perspective projection). + float s = 1.0 / (viewCenter.z * viewCenter.z); + mat3 J = mat3( + focal.x / viewCenter.z, 0., -(focal.x * viewCenter.x) * s, + 0., focal.y / viewCenter.z, -(focal.y * viewCenter.y) * s, + 0., 0., 0. + ); + + // Concatenate the projection approximation with the model-view transformation + mat3 W = transpose(mat3(transformModelViewMatrix)); + mat3 T = W * J; + + // Transform the 3D covariance matrix (Vrk) to compute the 2D covariance matrix + mat3 cov2Dm = transpose(T) * Vrk * T; + + cov2Dm[0][0] += 0.3; + cov2Dm[1][1] += 0.3; + + // We are interested in the upper-left 2x2 portion of the projected 3D covariance matrix because + // we only care about the X and Y values. We want the X-diagonal, cov2Dm[0][0], + // the Y-diagonal, cov2Dm[1][1], and the correlation between the two cov2Dm[0][1]. We don't + // need cov2Dm[1][0] because it is a symetric matrix. + vec3 cov2Dv = vec3(cov2Dm[0][0], cov2Dm[0][1], cov2Dm[1][1]); + + vec3 ndcCenter = clipCenter.xyz / clipCenter.w; + + // We now need to solve for the eigen-values and eigen vectors of the 2D covariance matrix + // so that we can determine the 2D basis for the splat. This is done using the method described + // here: https://people.math.harvard.edu/~knill/teaching/math21b2004/exhibits/2dmatrices/index.html + // After calculating the eigen-values and eigen-vectors, we calculate the basis for rendering the splat + // by normalizing the eigen-vectors and then multiplying them by (sqrt(8) * eigen-value), which is + // equal to scaling them by sqrt(8) standard deviations. + // + // This is a different approach than in the original work at INRIA. In that work they compute the + // max extents of the projected splat in screen space to form a screen-space aligned bounding rectangle + // which forms the geometry that is actually rasterized. The dimensions of that bounding box are 3.0 + // times the maximum eigen-value, or 3 standard deviations. They then use the inverse 2D covariance + // matrix (called 'conic') in the CUDA rendering thread to determine fragment opacity by calculating the + // full gaussian: exp(-0.5 * (X - mean) * conic * (X - mean)) * splat opacity + float a = cov2Dv.x; + float d = cov2Dv.z; + float b = cov2Dv.y; + float D = a * d - b * b; + float trace = a + d; + float traceOver2 = 0.5 * trace; + float term2 = sqrt(max(0.1f, traceOver2 * traceOver2 - D)); + float eigenValue1 = traceOver2 + term2; + float eigenValue2 = traceOver2 - term2; + + float transparentAdjust = step(1.0 / 255.0, vColor.a); + eigenValue2 = eigenValue2 * transparentAdjust; // hide splat if alpha is zero + + vec2 eigenVector1 = normalize(vec2(b, eigenValue1 - a)); + // since the eigen vectors are orthogonal, we derive the second one from the first + vec2 eigenVector2 = vec2(eigenVector1.y, -eigenVector1.x); + + // We use sqrt(8) standard deviations instead of 3 to eliminate more of the splat with a very low opacity. + vec2 basisVector1 = eigenVector1 * sqrt8 * sqrt(eigenValue1); + vec2 basisVector2 = eigenVector2 * sqrt8 * sqrt(eigenValue2); + + vec2 ndcOffset = vec2(vPosition.x * basisVector1 + vPosition.y * basisVector2) * basisViewport * 2.0; + + // Similarly scale the position data we send to the fragment shader + vPosition *= sqrt8; + + gl_Position = vec4(ndcCenter.xy + ndcOffset, ndcCenter.z, 1.0); + + }`; + const r = ` + precision highp float; + #include + + uniform vec3 debugColor; + + varying vec4 vColor; + varying vec2 vUv; + + varying vec2 vPosition; + + void main () { + // Compute the positional squared distance from the center of the splat to the current fragment. + float A = dot(vPosition, vPosition); + // Since the positional data in vPosition has been scaled by sqrt(8), the squared result will be + // scaled by a factor of 8. If the squared result is larger than 8, it means it is outside the ellipse + // defined by the rectangle formed by vPosition. It also means it's farther + // away than sqrt(8) standard deviations from the mean. + if (A > 8.0) discard; + vec3 color = vColor.rgb; + + // Since the rendered splat is scaled by sqrt(8), the inverse covariance matrix that is part of + // the gaussian formula becomes the identity matrix. We're then left with (X - mean) * (X - mean), + // and since 'mean' is zero, we have X * X, which is the same as A: + float opacity = exp(-0.5 * A) * vColor.a; + + gl_FragColor = vec4(color.rgb, opacity); + }`, s = { + covariancesTexture: { + type: "t", + value: null + }, + centersColorsTexture: { + type: "t", + value: null + }, + focal: { + type: "v2", + value: new me() + }, + viewport: { + type: "v2", + value: new me() + }, + basisViewport: { + type: "v2", + value: new me() + }, + debugColor: { + type: "v3", + value: new Qe() + }, + covariancesTextureSize: { + type: "v2", + value: new me(1024, 1024) + }, + centersColorsTextureSize: { + type: "v2", + value: new me(1024, 1024) + } + }; + if (t) { + s.transformIndexesTexture = { + type: "t", + value: null + }; + const o = []; + for (let l = 0; l < mt.MaxScenes; l++) + o.push(new ke()); + s.transforms = { + type: "mat4", + value: o + }, s.transformIndexesTextureSize = { + type: "v2", + value: new me(1024, 1024) + }; + } + return new Xt({ + uniforms: s, + vertexShader: n, + fragmentShader: r, + transparent: !0, + alphaTest: 1, + blending: ri, + depthTest: !0, + depthWrite: !1, + side: en + }); + } + /** + * Build the Three.js geometry that will be used to render the splats. The geometry is instanced and is made up of + * vertices for a single quad as well as an attribute buffer for the splat indexes. + * @param {number} maxSplatCount The maximum number of splats that the geometry will need to accomodate + * @return {THREE.InstancedBufferGeometry} + */ + static buildGeomtery(t) { + const n = new Yt(); + n.setIndex([0, 1, 2, 0, 2, 3]); + const r = new Float32Array(4 * 3), s = new Wt(r, 3); + n.setAttribute("position", s), s.setXYZ(0, -1, -1, 0), s.setXYZ(1, -1, 1, 0), s.setXYZ(2, 1, 1, 0), s.setXYZ(3, 1, -1, 0), s.needsUpdate = !0; + const a = new u_().copy(n), o = new Uint32Array(t), l = new c_(o, 1, !1); + return l.setUsage(Lf), a.setAttribute("splatIndex", l), a.instanceCount = t, a; + } + /** + * Build a container for each scene managed by this splat mesh based on an instance of SplatBuffer, along with optional + * transform data (position, scale, rotation) passed to the splat mesh during the build process. + * @param {Array} splatBuffers SplatBuffer instances containing splats for each scene + * @param {Array} sceneOptions Array of options objects: { + * + * position (Array): Position of the scene, acts as an offset from its default position, defaults to [0, 0, 0] + * + * rotation (Array): Rotation of the scene represented as a quaternion, defaults to [0, 0, 0, 1] + * + * scale (Array): Scene's scale, defaults to [1, 1, 1] + * } + * @return {Array} + */ + static buildScenes(t, n) { + const r = []; + r.length = t.length; + for (let s = 0; s < t.length; s++) { + const a = t[s], o = n[s] || {}; + let l = o.position || [0, 0, 0], c = o.rotation || [0, 0, 0, 1], u = o.scale || [1, 1, 1]; + const f = new P().fromArray(l), h = new wt().fromArray(c), p = new P().fromArray(u); + r[s] = kt.createScene(a, f, h, p); + } + return r; + } + static createScene(t, n, r, s) { + return new E_(t, n, r, s); + } + /** + * Build data structures that map global splat indexes (based on a unified index across all splat buffers) to + * local data within a single scene. + * @param {Array} splatBuffers Instances of SplatBuffer off which to build the maps + * @return {object} + */ + static buildSplatIndexMaps(t) { + const n = [], r = []; + let s = 0; + for (let a = 0; a < t.length; a++) { + const l = t[a].getSplatCount(); + for (let c = 0; c < l; c++) + n[s] = c, r[s] = a, s++; + } + return { + localSplatIndexMap: n, + sceneIndexMap: r + }; + } + /** + * Build an instance of SplatTree (a specialized octree) for the given splat mesh. + * @param {SplatMesh} splatMesh SplatMesh instance for which the splat tree will be built + * @param {Array} minAlphas Array of minimum splat slphas for each scene + * @return {SplatTree} + */ + static buildSplatTree(t, n = []) { + const r = new lr(8, 1e3); + console.time("SplatTree build"); + const s = new ut(); + r.processSplatMesh(t, (c) => { + t.getSplatColor(c, s); + const u = t.getSceneIndexForSplat(c), f = n[u] || 1; + return s.w >= f; + }), console.timeEnd("SplatTree build"); + let a = 0, o = 0, l = 0; + return r.visitLeaves((c) => { + const u = c.data.indexes.length; + u > 0 && (o += u, l++, a++); + }), console.log(`SplatTree leaves: ${r.countLeaves()}`), console.log(`SplatTree leaves with splats:${a}`), o = o / l, console.log(`Avg splat count per node: ${o}`), console.log(`Total splat count: ${t.getSplatCount()}`), r; + } + /** + * Construct this instance of SplatMesh. + * @param {Array} splatBuffers The base splat data, instances of SplatBuffer + * @param {Array} sceneOptions Dynamic options for each scene { + * + * splatAlphaRemovalThreshold: Ignore any splats with an alpha less than the specified + * value (valid range: 0 - 255), defaults to 1 + * + * position (Array): Position of the scene, acts as an offset from its default position, defaults to [0, 0, 0] + * + * rotation (Array): Rotation of the scene represented as a quaternion, defaults to [0, 0, 0, 1] + * + * scale (Array): Scene's scale, defaults to [1, 1, 1] + * + * } + * @param {Boolean} keepSceneTransforms For a scene that already exists and is being overwritten, this flag + * says to keep the transform from the existing scene. + */ + build(t, n, r = !0) { + this.disposeMeshData(); + const s = kt.getTotalSplatCountForSplatBuffers(t), a = kt.buildScenes(t, n); + if (r) + for (let l = 0; l < this.scenes.length && l < a.length; l++) { + const c = a[l], u = this.getScene(l); + c.copyTransformData(u); + } + this.scenes = a, this.geometry = kt.buildGeomtery(s), this.material = kt.buildMaterial(this.dynamicMode); + const o = kt.buildSplatIndexMaps(t); + this.globalSplatIndexToLocalSplatIndexMap = o.localSplatIndexMap, this.globalSplatIndexToSceneIndexMap = o.sceneIndexMap, this.splatTree = kt.buildSplatTree(this, n.map((l) => l.splatAlphaRemovalThreshold || 1)), this.enableDistancesComputationOnGPU && this.setupDistancesComputationTransformFeedback(), this.resetDataFromSplatBuffers(); + } + /** + * Dispose all resources held by the splat mesh + */ + dispose() { + this.disposeMeshData(), this.enableDistancesComputationOnGPU && this.disposeDistancesComputationGPUResources(); + } + /** + * Dispose of only the Three.js mesh resources (geometry, material, and texture) + */ + disposeMeshData() { + this.geometry && this.geometry !== cl && (this.geometry.dispose(), this.geometry = null); + for (let t in this.splatDataTextures) + if (this.splatDataTextures.hasOwnProperty(t)) { + const n = this.splatDataTextures[t]; + n.texture && (n.texture.dispose(), n.texture = null); + } + this.splatDataTextures = null, this.material && (this.material.dispose(), this.material = null), this.splatTree = null; + } + getSplatTree() { + return this.splatTree; + } + /** + * Refresh data textures and GPU buffers for splat distance pre-computation with data from the splat buffers for this mesh. + */ + resetDataFromSplatBuffers() { + this.uploadSplatDataToTextures(), this.enableDistancesComputationOnGPU && (this.updateGPUCentersBufferForDistancesComputation(), this.updateGPUTransformIndexesBufferForDistancesComputation()); + } + /** + * Refresh data textures with data from the splat buffers for this mesh. + */ + uploadSplatDataToTextures() { + const t = this.getSplatCount(), n = new Float32Array(t * 6), r = new Float32Array(t * 3), s = new Uint8Array(t * 4); + this.fillSplatDataArrays(n, r, s); + const a = 2, o = 4, l = 1, c = new me(4096, 1024); + for (; c.x * c.y * a < t * 6; ) + c.y *= 2; + const u = new me(4096, 1024); + for (; u.x * u.y * o < t * 4; ) + u.y *= 2; + let f, h; + if (this.halfPrecisionCovariancesOnGPU) { + h = new Uint16Array(c.x * c.y * a); + for (let v = 0; v < n.length; v++) + h[v] = $r.toHalfFloat(n[v]); + f = new Or( + h, + c.x, + c.y, + ro, + Gi + ); + } else + h = new Float32Array(c.x * c.y * a), h.set(n), f = new Or( + h, + c.x, + c.y, + ro, + an + ); + f.needsUpdate = !0, this.material.uniforms.covariancesTexture.value = f, this.material.uniforms.covariancesTextureSize.value.copy(c); + const p = new Uint32Array(u.x * u.y * o); + for (let v = 0; v < t; v++) { + const m = v * 4, d = v * 3, M = v * 4; + p[M] = f_( + s[m], + s[m + 1], + s[m + 2], + s[m + 3] + ), p[M + 1] = Ks(r[d]), p[M + 2] = Ks(r[d + 1]), p[M + 3] = Ks(r[d + 2]); + } + const g = new Or( + p, + u.x, + u.y, + mo, + nn + ); + if (g.internalFormat = "RGBA32UI", g.needsUpdate = !0, this.material.uniforms.centersColorsTexture.value = g, this.material.uniforms.centersColorsTextureSize.value.copy(u), this.material.uniformsNeedUpdate = !0, this.splatDataTextures = { + covariances: { + data: h, + texture: f, + size: c + }, + centerColors: { + data: p, + texture: g, + size: u + } + }, this.dynamicMode) { + const v = new me(4096, 1024); + for (; v.x * v.y * l < t; ) + v.y *= 2; + const m = new Uint32Array(v.x * v.y * l); + for (let M = 0; M < t; M++) + m[M] = this.globalSplatIndexToSceneIndexMap[M]; + const d = new Or( + m, + v.x, + v.y, + po, + nn + ); + d.internalFormat = "R32UI", d.needsUpdate = !0, this.material.uniforms.transformIndexesTexture.value = d, this.material.uniforms.transformIndexesTextureSize.value.copy(v), this.material.uniformsNeedUpdate = !0, this.splatDataTextures.tansformIndexes = { + data: m, + texture: d, + size: v + }; + } + } + /** + * Set the indexes of splats that should be rendered; should be sorted in desired render order. + * @param {Uint32Array} globalIndexes Sorted index list of splats to be rendered + * @param {number} renderSplatCount Total number of splats to be rendered. Necessary because we may not want to render + * every splat. + */ + updateRenderIndexes(t, n) { + const r = this.geometry; + r.attributes.splatIndex.set(t), r.attributes.splatIndex.needsUpdate = !0, r.instanceCount = n; + } + /** + * Update the transforms for each scene in this splat mesh from their individual components (position, + * quaternion, and scale) + */ + updateTransforms() { + for (let t = 0; t < this.scenes.length; t++) + this.getScene(t).updateTransform(); + } + getSplatDataTextures() { + return this.splatDataTextures; + } + getSplatCount() { + return kt.getTotalSplatCountForScenes(this.scenes); + } + static getTotalSplatCountForScenes(t) { + let n = 0; + for (let r of t) + r && r.splatBuffer && (n += r.splatBuffer.getSplatCount()); + return n; + } + static getTotalSplatCountForSplatBuffers(t) { + let n = 0; + for (let r of t) + n += r.getSplatCount(); + return n; + } + disposeDistancesComputationGPUResources() { + if (!this.renderer) + return; + const t = this.renderer.getContext(); + this.distancesTransformFeedback.vao && (t.deleteVertexArray(this.distancesTransformFeedback.vao), this.distancesTransformFeedback.vao = null), this.distancesTransformFeedback.program && (t.deleteProgram(this.distancesTransformFeedback.program), t.deleteShader(this.distancesTransformFeedback.vertexShader), t.deleteShader(this.distancesTransformFeedback.fragmentShader), this.distancesTransformFeedback.program = null, this.distancesTransformFeedback.vertexShader = null, this.distancesTransformFeedback.fragmentShader = null), this.disposeDistancesComputationGPUBufferResources(), this.distancesTransformFeedback.id && (t.deleteTransformFeedback(this.distancesTransformFeedback.id), this.distancesTransformFeedback.id = null); + } + disposeDistancesComputationGPUBufferResources() { + if (!this.renderer) + return; + const t = this.renderer.getContext(); + this.distancesTransformFeedback.centersBuffer && (this.distancesTransformFeedback.centersBuffer = null, t.deleteBuffer(this.distancesTransformFeedback.centersBuffer)), this.distancesTransformFeedback.outDistancesBuffer && (t.deleteBuffer(this.distancesTransformFeedback.outDistancesBuffer), this.distancesTransformFeedback.outDistancesBuffer = null); + } + /** + * Set the Three.js renderer used by this splat mesh + * @param {THREE.WebGLRenderer} renderer Instance of THREE.WebGLRenderer + */ + setRenderer(t) { + t !== this.renderer && (this.renderer = t, this.enableDistancesComputationOnGPU && this.getSplatCount() > 0 && (this.setupDistancesComputationTransformFeedback(), this.updateGPUCentersBufferForDistancesComputation(), this.updateGPUTransformIndexesBufferForDistancesComputation())); + } + /** + * Refresh GPU buffers used for computing splat distances with centers data from the scenes for this mesh. + */ + updateGPUCentersBufferForDistancesComputation() { + if (!this.renderer) + return; + const t = this.renderer.getContext(), n = t.getParameter(t.VERTEX_ARRAY_BINDING); + if (t.bindVertexArray(this.distancesTransformFeedback.vao), t.bindBuffer(t.ARRAY_BUFFER, this.distancesTransformFeedback.centersBuffer), this.integerBasedDistancesComputation) { + const r = this.getIntegerCenters(!0); + t.bufferData(t.ARRAY_BUFFER, r, t.STATIC_DRAW); + } else { + const r = this.getFloatCenters(!1); + t.bufferData(t.ARRAY_BUFFER, r, t.STATIC_DRAW); + } + t.bindBuffer(t.ARRAY_BUFFER, null), n && t.bindVertexArray(n); + } + /** + * Refresh GPU buffers used for pre-computing splat distances with centers data from the scenes for this mesh. + */ + updateGPUTransformIndexesBufferForDistancesComputation() { + if (!this.renderer || !this.dynamicMode) + return; + const t = this.renderer.getContext(), n = t.getParameter(t.VERTEX_ARRAY_BINDING); + t.bindVertexArray(this.distancesTransformFeedback.vao), t.bindBuffer(t.ARRAY_BUFFER, this.distancesTransformFeedback.transformIndexesBuffer), t.bufferData(t.ARRAY_BUFFER, this.getTransformIndexes(), t.STATIC_DRAW), t.bindBuffer(t.ARRAY_BUFFER, null), n && t.bindVertexArray(n); + } + /** + * Get a typed array containing a mapping from global splat indexes to their scene index. + * @return {Uint32Array} + */ + getTransformIndexes() { + const t = new Uint32Array(this.globalSplatIndexToSceneIndexMap.length); + return t.set(this.globalSplatIndexToSceneIndexMap), t; + } + /** + * Given a global splat index, return corresponding local data (splat buffer, index of splat in that splat + * buffer, and the corresponding transform) + * @param {number} globalIndex Global splat index + * @param {object} paramsObj Object in which to store local data + * @param {boolean} returnSceneTransform By default, the transform of the scene to which the splat at 'globalIndex' belongs will be + * returned via the 'sceneTransform' property of 'paramsObj' only if the splat mesh is static. + * If 'returnSceneTransform' is true, the 'sceneTransform' property will always contain the scene + * transform, and if 'returnSceneTransform' is false, the 'sceneTransform' property will always + * be null. + */ + getLocalSplatParameters(t, n, r) { + r == null && (r = !this.dynamicMode), n.splatBuffer = this.getSplatBufferForSplat(t), n.localIndex = this.getSplatLocalIndex(t), n.sceneTransform = r ? this.getSceneTransformForSplat(t) : null; + } + /** + * Fill arrays with splat data and apply transforms if appropriate. Each array is optional. + * @param {Float32Array} covariances Target storage for splat covariances + * @param {Float32Array} centers Target storage for splat centers + * @param {Uint8Array} colors Target storage for splat colors + * @param {boolean} applySceneTransform By default, scene transforms are applied to relevant splat data only if the splat mesh is + * static. If 'applySceneTransform' is true, scene transforms will always be applied and if + * it is false, they will never be applied. If undefined, the default behavior will apply. + */ + fillSplatDataArrays(t, n, r, s) { + let a = 0; + for (let o = 0; o < this.scenes.length; o++) { + s == null && (s = !this.dynamicMode); + const l = this.getScene(o), c = l.splatBuffer, u = s ? l.transform : null; + t && c.fillSplatCovarianceArray(t, a, u), n && c.fillSplatCenterArray(n, a, u), r && c.fillSplatColorArray(r, a, u), a += c.getSplatCount(); + } + } + /** + * Convert splat centers, which are floating point values, to an array of integers and multiply + * each by 1000. Centers will get transformed as appropriate before conversion to integer. + * @param {number} padFour Enforce alignement of 4 by inserting a 1000 after every 3 values + * @return {Int32Array} + */ + getIntegerCenters(t) { + const n = this.getSplatCount(), r = new Float32Array(n * 3); + this.fillSplatDataArrays(null, r, null); + let s, a = t ? 4 : 3; + s = new Int32Array(n * a); + for (let o = 0; o < n; o++) { + for (let l = 0; l < 3; l++) + s[o * a + l] = Math.round(r[o * 3 + l] * 1e3); + t && (s[o * a + 3] = 1e3); + } + return s; + } + /** + * Returns an array of splat centers, transformed as appropriate, optionally padded. + * @param {number} padFour Enforce alignement of 4 by inserting a 1 after every 3 values + * @return {Float32Array} + */ + getFloatCenters(t) { + const n = this.getSplatCount(), r = new Float32Array(n * 3); + if (this.fillSplatDataArrays(null, r, null), !t) + return r; + let s = new Float32Array(n * 4); + for (let a = 0; a < n; a++) { + for (let o = 0; o < 3; o++) + s[a * 4 + o] = r[a * 3 + o]; + s[a * 4 + 3] = 1; + } + return s; + } + /** + * Store the transform of the scene at 'sceneIndex' in 'outTransform'. + * @param {number} sceneIndex Index of the desired scene + * @param {THREE.Matrix4} outTransform Instance of THREE.Matrix4 in which to store the scene's transform + */ + getSceneTransform(t, n) { + const r = this.getScene(t); + r.updateTransform(), n.copy(r.transform); + } + /** + * Get the scene at 'sceneIndex'. + * @param {number} sceneIndex Index of the desired scene + * @return {SplatScene} + */ + getScene(t) { + if (t < 0 || t >= this.scenes.length) + throw new Error("SplatMesh::getScene() -> Invalid scene index."); + return this.scenes[t]; + } + getSplatBufferForSplat(t) { + return this.getScene(this.globalSplatIndexToSceneIndexMap[t]).splatBuffer; + } + getSceneIndexForSplat(t) { + return this.globalSplatIndexToSceneIndexMap[t]; + } + getSceneTransformForSplat(t) { + return this.getScene(this.globalSplatIndexToSceneIndexMap[t]).transform; + } + getSplatLocalIndex(t) { + return this.globalSplatIndexToLocalSplatIndexMap[t]; + } + static getIntegerMatrixArray(t) { + const n = t.elements, r = []; + for (let s = 0; s < 16; s++) + r[s] = Math.round(n[s] * 1e3); + return r; + } +} +var C_ = "AGFzbQEAAAAADAZkeWxpbmsAAAAAAAEbA2AAAGAQf39/f39/f39/f39/f39/fwBgAAF/AhIBA2VudgZtZW1vcnkCAwCAgAQDBAMAAQIHOQMRX193YXNtX2NhbGxfY3RvcnMAAAtzb3J0SW5kZXhlcwABE2Vtc2NyaXB0ZW5fdGxzX2luaXQAAgrHEAMDAAELuxAFAXwDewJ/A30CfiALIAprIQwCQCAOBEAgDQRAQfj///8HIQ5BiICAgHghDSALIAxNDQIgDCEBA0AgAyABQQJ0IgVqIAIgACAFaigCAEECdGooAgAiBTYCACAFIA4gBSAOSBshDiAFIA0gBSANShshDSABQQFqIgEgC0cNAAsMAgsgDwRAQfj///8HIQ5BiICAgHghDSALIAxNDQJBfyEPIAwhAgNAIA8gByAAIAJBAnQiFGooAgAiFUECdGooAgAiCkcEQAJ+IAX9CQIIIAggCkEGdGoiD/0JAgAgDyoCEP0gASAPKgIg/SACIA8qAjD9IAP95gEgBf0JAhggD/0JAgQgDyoCFP0gASAPKgIk/SACIA8qAjT9IAP95gH95AEgBf0JAiggD/0JAgggDyoCGP0gASAPKgIo/SACIA8qAjj9IAP95gH95AEgBf0JAjggD/0JAgwgDyoCHP0gASAPKgIs/SACIA8qAjz9IAP95gH95AEiEf0fArv9FCAR/R8Du/0iAf0MAAAAAABAj0AAAAAAAECPQCIS/fIBIhP9IQEiEJlEAAAAAAAA4ENjBEAgELAMAQtCgICAgICAgICAfwshGQJ+IBP9IQAiEJlEAAAAAAAA4ENjBEAgELAMAQtCgICAgICAgICAfwv9EiETAn4gEf0fALv9FCAR/R8Bu/0iASAS/fIBIhH9IQEiEJlEAAAAAAAA4ENjBEAgELAMAQtCgICAgICAgICAfwshGiATIBn9HgEhEgJ+IBH9IQAiEJlEAAAAAAAA4ENjBEAgELAMAQtCgICAgICAgICAfwv9EiAa/R4BIBL9DQABAgMICQoLEBESExgZGhshEiAKIQ8LIAMgFGogASAVQQR0av0AAAAgEv21ASIR/RsAIBH9GwFqIBH9GwJqIBH9GwNqIgo2AgAgCiAOIAogDkgbIQ4gCiANIAogDUobIQ0gAkEBaiICIAtHDQALDAILAn8gBSoCGLtEAAAAAABAj0CiIhCZRAAAAAAAAOBBYwRAIBCqDAELQYCAgIB4CyEKAn8gBSoCCLtEAAAAAABAj0CiIhCZRAAAAAAAAOBBYwRAIBCqDAELQYCAgIB4CyECAn8gBSoCKLtEAAAAAABAj0CiIhCZRAAAAAAAAOBBYwRAIBCqDAELQYCAgIB4CyEFQfj///8HIQ5BiICAgHghDSALIAxNDQEgAv0RIAr9HAEgBf0cAiESIAwhBQNAIAMgBUECdCICaiABIAAgAmooAgBBBHRq/QAAACAS/bUBIhH9GwAgEf0bAWogEf0bAmoiAjYCACACIA4gAiAOSBshDiACIA0gAiANShshDSAFQQFqIgUgC0cNAAsMAQsgDQRAQfj///8HIQ5BiICAgHghDSALIAxNDQEgDCEBA0AgAyABQQJ0IgVqAn8gAiAAIAVqKAIAQQJ0aioCALtEAAAAAAAAsECiIhCZRAAAAAAAAOBBYwRAIBCqDAELQYCAgIB4CyIKNgIAIAogDiAKIA5IGyEOIAogDSAKIA1KGyENIAFBAWoiASALRw0ACwwBCwJAIA9FBEAgCyAMSw0BQYiAgIB4IQ1B+P///wchDgwCC0H4////ByEOQYiAgIB4IQ0gCyAMTQ0BQX8hDyAMIQIDQCAPIAcgACACQQJ0IhRqKAIAQQJ0IhVqKAIAIgpHBEAgBf0JAgggCCAKQQZ0aiIP/QkCACAPKgIQ/SABIA8qAiD9IAIgDyoCMP0gA/3mASAF/QkCGCAP/QkCBCAPKgIU/SABIA8qAiT9IAIgDyoCNP0gA/3mAf3kASAF/QkCKCAP/QkCCCAPKgIY/SABIA8qAij9IAIgDyoCOP0gA/3mAf3kASAF/QkCOCAP/QkCDCAPKgIc/SABIA8qAiz9IAIgDyoCPP0gA/3mAf3kASERIAohDwsgAyAUagJ/IBEgASAVQQJ0IgpqKQIA/RL95gEiEv0fACAS/R8BkiARIBH9DQgJCgsMDQ4PAAAAAAAAAAAgASAKQQhyaikCAP0S/eYBIhL9HwCSIBL9HwGSu0QAAAAAAACwQKIiEJlEAAAAAAAA4EFjBEAgEKoMAQtBgICAgHgLIgo2AgAgCiAOIAogDkgbIQ4gCiANIAogDUobIQ0gAkEBaiICIAtHDQALDAELIAUqAighFiAFKgIYIRcgBSoCCCEYQfj///8HIQ5BiICAgHghDSAMIQUDQAJ/IBggASAAIAVBAnQiB2ooAgBBBHRqIgIqAgCUIBcgAioCBJSSIBYgAioCCJSSu0QAAAAAAACwQKIiEJlEAAAAAAAA4EFjBEAgEKoMAQtBgICAgHgLIQogAyAHaiAKNgIAIAogDiAKIA5IGyEOIAogDSAKIA1KGyENIAVBAWoiBSALRw0ACwsgCyAMSwRAIAlBAWuzIA2yIA6yk5UhFiAMIQ0DQAJ/IBYgAyANQQJ0aiIBKAIAIA5rspQiF4tDAAAAT10EQCAXqAwBC0GAgICAeAshCiABIAo2AgAgBCAKQQJ0aiIBIAEoAgBBAWo2AgAgDUEBaiINIAtHDQALCyAJQQJPBEAgBCgCACENQQEhDgNAIAQgDkECdGoiASABKAIAIA1qIg02AgAgDkEBaiIOIAlHDQALCyAMQQBKBEAgDCEOA0AgBiAOQQFrIgFBAnQiAmogACACaigCADYCACAOQQFKIQIgASEOIAINAAsLIAsgDEoEQCALIQ4DQCAGIAsgBCADIA5BAWsiDkECdCIBaigCAEECdGoiAigCACIFa0ECdGogACABaigCADYCACACIAVBAWs2AgAgDCAOSA0ACwsLBABBAAs="; +function R_(i) { + let e, t, n, r, s, a, o, l, c, u, f, h, p, g, v, m, d; + function M(_, A, C, E, b, I, W) { + const S = performance.now(); + if (!n && (new Uint32Array(t, o, b.byteLength / d.BytesPerInt).set(b), new Float32Array(t, u, W.byteLength / d.BytesPerFloat).set(W), E)) { + let O; + r ? O = new Int32Array( + t, + f, + I.byteLength / d.BytesPerInt + ) : O = new Float32Array( + t, + f, + I.byteLength / d.BytesPerFloat + ), O.set(I); + } + m || (m = new Uint32Array(d.DepthMapRange)), new Float32Array(t, v, 16).set(C), new Uint32Array(t, p, d.DepthMapRange).set(m), e.exports.sortIndexes( + o, + g, + f, + h, + p, + v, + l, + c, + u, + d.DepthMapRange, + _, + A, + a, + E, + r, + s + ); + const T = { + sortDone: !0, + splatSortCount: _, + splatRenderCount: A, + sortTime: 0 + }, Y = []; + if (!n) { + const L = new Uint32Array(t, l, A), N = new Uint32Array(A); + N.set(L), T.sortedIndexes = N.buffer, Y.push(N.buffer); + } + const K = performance.now(); + T.sortTime = K - S, i.postMessage(T, Y); + } + i.onmessage = (_) => { + if (_.data.centers) + centers = _.data.centers, transformIndexes = _.data.transformIndexes, r ? new Int32Array(t, g, a * 4).set(new Int32Array(centers)) : new Float32Array(t, g, a * 4).set(new Float32Array(centers)), s && new Uint32Array(t, c, a).set(new Uint32Array(transformIndexes)), i.postMessage({ + sortSetupComplete: !0 + }); + else if (_.data.sort) { + const A = _.data.sort.splatRenderCount || 0, C = _.data.sort.splatSortCount || 0, E = _.data.sort.usePrecomputedDistances; + let b, I, W; + n || (b = _.data.sort.indexesToSort, W = _.data.sort.transforms, E && (I = _.data.sort.precomputedDistances)), M( + C, + A, + _.data.sort.modelViewProj, + E, + b, + I, + W + ); + } else if (_.data.init) { + d = _.data.init.Constants, a = _.data.init.splatCount, n = _.data.init.useSharedMemory, r = _.data.init.integerBasedSort, s = _.data.init.dynamicMode; + const A = r ? d.BytesPerInt * 4 : d.BytesPerFloat * 4, C = new Uint8Array(_.data.init.sorterWasmBytes), E = 16 * d.BytesPerFloat, b = a * d.BytesPerInt, I = a * A, W = E, S = r ? a * d.BytesPerInt : a * d.BytesPerFloat, T = a * d.BytesPerInt, Y = a * d.BytesPerInt, K = d.DepthMapRange * d.BytesPerInt * 2, L = s ? a * d.BytesPerInt : 0, N = s ? d.MaxScenes * E : 0, O = d.MemoryPageSize * 32, B = b + I + W + S + T + K + Y + L + N + O, j = Math.floor(B / d.MemoryPageSize) + 1, q = { + module: {}, + env: { + memory: new WebAssembly.Memory({ + initial: j * 2, + maximum: j * 4, + shared: !0 + }) + } + }; + WebAssembly.compile(C).then((J) => WebAssembly.instantiate(J, q)).then((J) => { + e = J, o = 0, g = o + b, v = g + I, f = v + W, h = f + S, p = h + T, l = p + K, c = l + Y, u = c + L, t = q.env.memory.buffer, n ? i.postMessage({ + sortSetupPhase1Complete: !0, + indexesToSortBuffer: t, + indexesToSortOffset: o, + sortedIndexesBuffer: t, + sortedIndexesOffset: l, + precomputedDistancesBuffer: t, + precomputedDistancesOffset: f, + transformsBuffer: t, + transformsOffset: u + }) : i.postMessage({ + sortSetupPhase1Complete: !0 + }); + }); + } + }; +} +function P_(i, e, t, n) { + const r = new Worker( + URL.createObjectURL( + new Blob(["(", R_.toString(), ")(self)"], { + type: "application/javascript" + }) + ) + ), s = atob(C_), a = new Uint8Array(s.length); + for (let o = 0; o < s.length; o++) + a[o] = s.charCodeAt(o); + return r.postMessage({ + init: { + sorterWasmBytes: a.buffer, + splatCount: i, + useSharedMemory: e, + integerBasedSort: t, + dynamicMode: n, + // Super hacky + Constants: { + BytesPerFloat: mt.BytesPerFloat, + BytesPerInt: mt.BytesPerInt, + DepthMapRange: mt.DepthMapRange, + MemoryPageSize: mt.MemoryPageSize, + MaxScenes: mt.MaxScenes + } + } + }), r; +} +const kr = { + None: 0, + VR: 1, + AR: 2 +}; +class qi { + static createButton(e) { + const t = document.createElement("button"); + function n() { + let l = null; + async function c(h) { + h.addEventListener("end", u), await e.xr.setSession(h), t.textContent = "EXIT VR", l = h; + } + function u() { + l.removeEventListener("end", u), t.textContent = "ENTER VR", l = null; + } + t.style.display = "", t.style.cursor = "pointer", t.style.left = "calc(50% - 50px)", t.style.width = "100px", t.textContent = "ENTER VR"; + const f = { optionalFeatures: ["local-floor", "bounded-floor", "hand-tracking", "layers"] }; + t.onmouseenter = function() { + t.style.opacity = "1.0"; + }, t.onmouseleave = function() { + t.style.opacity = "0.5"; + }, t.onclick = function() { + l === null ? navigator.xr.requestSession("immersive-vr", f).then(c) : (l.end(), navigator.xr.offerSession !== void 0 && navigator.xr.offerSession("immersive-vr", f).then(c).catch((h) => { + console.warn(h); + })); + }, navigator.xr.offerSession !== void 0 && navigator.xr.offerSession("immersive-vr", f).then(c).catch((h) => { + console.warn(h); + }); + } + function r() { + t.style.display = "", t.style.cursor = "auto", t.style.left = "calc(50% - 75px)", t.style.width = "150px", t.onmouseenter = null, t.onmouseleave = null, t.onclick = null; + } + function s() { + r(), t.textContent = "VR NOT SUPPORTED"; + } + function a(l) { + r(), console.warn("Exception when trying to call xr.isSessionSupported", l), t.textContent = "VR NOT ALLOWED"; + } + function o(l) { + l.style.position = "absolute", l.style.bottom = "20px", l.style.padding = "12px 6px", l.style.border = "1px solid #fff", l.style.borderRadius = "4px", l.style.background = "rgba(0,0,0,0.1)", l.style.color = "#fff", l.style.font = "normal 13px sans-serif", l.style.textAlign = "center", l.style.opacity = "0.5", l.style.outline = "none", l.style.zIndex = "999"; + } + if ("xr" in navigator) + return t.id = "VRButton", t.style.display = "none", o(t), navigator.xr.isSessionSupported("immersive-vr").then(function(l) { + l ? n() : s(), l && qi.xrSessionIsGranted && t.click(); + }).catch(a), t; + { + const l = document.createElement("a"); + return window.isSecureContext === !1 ? (l.href = document.location.href.replace(/^http:/, "https:"), l.innerHTML = "WEBXR NEEDS HTTPS") : (l.href = "https://immersiveweb.dev/", l.innerHTML = "WEBXR NOT AVAILABLE"), l.style.left = "calc(50% - 90px)", l.style.width = "180px", l.style.textDecoration = "none", o(l), l; + } + } + static registerSessionGrantedListener() { + if (typeof navigator < "u" && "xr" in navigator) { + if (/WebXRViewer\//i.test(navigator.userAgent)) + return; + navigator.xr.addEventListener("sessiongranted", () => { + qi.xrSessionIsGranted = !0; + }); + } + } +} +qi.xrSessionIsGranted = !1; +qi.registerSessionGrantedListener(); +class L_ { + static createButton(e, t = {}) { + const n = document.createElement("button"); + function r() { + if (t.domOverlay === void 0) { + const h = document.createElement("div"); + h.style.display = "none", document.body.appendChild(h); + const p = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + p.setAttribute("width", 38), p.setAttribute("height", 38), p.style.position = "absolute", p.style.right = "20px", p.style.top = "20px", p.addEventListener("click", function() { + c.end(); + }), h.appendChild(p); + const g = document.createElementNS("http://www.w3.org/2000/svg", "path"); + g.setAttribute("d", "M 12,12 L 28,28 M 28,12 12,28"), g.setAttribute("stroke", "#fff"), g.setAttribute("stroke-width", 2), p.appendChild(g), t.optionalFeatures === void 0 && (t.optionalFeatures = []), t.optionalFeatures.push("dom-overlay"), t.domOverlay = { root: h }; + } + let c = null; + async function u(h) { + h.addEventListener("end", f), e.xr.setReferenceSpaceType("local"), await e.xr.setSession(h), n.textContent = "STOP AR", t.domOverlay.root.style.display = "", c = h; + } + function f() { + c.removeEventListener("end", f), n.textContent = "START AR", t.domOverlay.root.style.display = "none", c = null; + } + n.style.display = "", n.style.cursor = "pointer", n.style.left = "calc(50% - 50px)", n.style.width = "100px", n.textContent = "START AR", n.onmouseenter = function() { + n.style.opacity = "1.0"; + }, n.onmouseleave = function() { + n.style.opacity = "0.5"; + }, n.onclick = function() { + c === null ? navigator.xr.requestSession("immersive-ar", t).then(u) : (c.end(), navigator.xr.offerSession !== void 0 && navigator.xr.offerSession("immersive-ar", t).then(u).catch((h) => { + console.warn(h); + })); + }, navigator.xr.offerSession !== void 0 && navigator.xr.offerSession("immersive-ar", t).then(u).catch((h) => { + console.warn(h); + }); + } + function s() { + n.style.display = "", n.style.cursor = "auto", n.style.left = "calc(50% - 75px)", n.style.width = "150px", n.onmouseenter = null, n.onmouseleave = null, n.onclick = null; + } + function a() { + s(), n.textContent = "AR NOT SUPPORTED"; + } + function o(c) { + s(), console.warn("Exception when trying to call xr.isSessionSupported", c), n.textContent = "AR NOT ALLOWED"; + } + function l(c) { + c.style.position = "absolute", c.style.bottom = "20px", c.style.padding = "12px 6px", c.style.border = "1px solid #fff", c.style.borderRadius = "4px", c.style.background = "rgba(0,0,0,0.1)", c.style.color = "#fff", c.style.font = "normal 13px sans-serif", c.style.textAlign = "center", c.style.opacity = "0.5", c.style.outline = "none", c.style.zIndex = "999"; + } + if ("xr" in navigator) + return n.id = "ARButton", n.style.display = "none", l(n), navigator.xr.isSessionSupported("immersive-ar").then(function(c) { + c ? r() : a(); + }).catch(o), n; + { + const c = document.createElement("a"); + return window.isSecureContext === !1 ? (c.href = document.location.href.replace(/^http:/, "https:"), c.innerHTML = "WEBXR NEEDS HTTPS") : (c.href = "https://immersiveweb.dev/", c.innerHTML = "WEBXR NOT AVAILABLE"), c.style.left = "calc(50% - 90px)", c.style.width = "180px", c.style.textDecoration = "none", l(c), c; + } + } +} +const D_ = 50, I_ = 0.75; +class U_ { + constructor(e = {}) { + Pe(this, "onKeyDown", function() { + const e = new P(), t = new ke(), n = new ke(); + return function(r) { + switch (e.set(0, 0, -1), e.transformDirection(this.camera.matrixWorld), t.makeRotationAxis(e, Math.PI / 128), n.makeRotationAxis(e, -Math.PI / 128), r.code) { + case "ArrowLeft": + this.camera.up.transformDirection(t); + break; + case "ArrowRight": + this.camera.up.transformDirection(n); + break; + case "KeyC": + this.showMeshCursor = !this.showMeshCursor; + break; + case "KeyP": + this.showControlPlane = !this.showControlPlane; + break; + case "KeyI": + this.showInfo = !this.showInfo, this.showInfo ? this.infoPanel.style.display = "block" : this.infoPanel.style.display = "none"; + break; + } + }; + }()); + Pe(this, "onMouseUp", function() { + const e = new me(); + return function(t) { + e.copy(this.mousePosition).sub(this.mouseDownPosition), Ri() - this.mouseDownTime < 0.5 && e.length() < 2 && this.onMouseClick(t); + }; + }()); + Pe(this, "checkForFocalPointChange", function() { + const e = new me(), t = new P(), n = []; + return function() { + if (!this.transitioningCameraTarget && (this.getRenderDimensions(e), n.length = 0, this.raycaster.setFromCameraAndScreenPosition(this.camera, this.mousePosition, e), this.raycaster.intersectSplatMesh(this.splatMesh, n), n.length > 0)) { + const s = n[0].origin; + t.copy(s).sub(this.camera.position), t.length() > I_ && (this.previousCameraTarget.copy(this.controls.target), this.nextCameraTarget.copy(s), this.transitioningCameraTarget = !0, this.transitioningCameraTargetStartTime = Ri()); + } + }; + }()); + Pe(this, "updateSplatMesh", function() { + const e = new me(); + return function() { + if (!this.splatMesh) + return; + this.splatMesh.getSplatCount() > 0 && (this.splatMesh.updateTransforms(), this.getRenderDimensions(e), this.cameraFocalLengthX = this.camera.projectionMatrix.elements[0] * this.devicePixelRatio * e.x * 0.45, this.cameraFocalLengthY = this.camera.projectionMatrix.elements[5] * this.devicePixelRatio * e.y * 0.45, this.splatMesh.updateUniforms(e, this.cameraFocalLengthX, this.cameraFocalLengthY)); + }; + }()); + /** + * Add one or more instances of SplatBuffer to the SplatMesh instance managed by the viewer and set up the sorting web worker. + * This function will terminate the existing sort worker (if there is one). + */ + Pe(this, "addSplatBuffers", /* @__PURE__ */ function() { + let e, t = 0; + return function(n, r = [], s = !0) { + this.splatRenderingInitialized = !1, t++; + const a = () => new Promise((o) => { + s && (this.loadingSpinner.show(), this.loadingSpinner.setMessage("Processing splats...")), window.setTimeout(() => { + this.disposeSortWorker(), this.addSplatBuffersToMesh(n, r), this.setupSortWorker(this.splatMesh).then(() => { + t--, t === 0 && (s && this.loadingSpinner.hide(), this.splatRenderingInitialized = !0), o(); + }); + }, 1); + }); + return e ? e = e.then(() => a()) : e = a(), e; + }; + }()); + Pe(this, "render", /* @__PURE__ */ function() { + return function() { + if (!this.initialized || !this.splatRenderingInitialized) + return; + const e = (n) => { + for (let r of n.children) + if (r.visible) + return !0; + return !1; + }, t = this.renderer.autoClear; + this.renderer.autoClear = !1, e(this.threeScene) && this.renderer.render(this.threeScene, this.camera), this.renderer.render(this.splatMesh, this.camera), this.sceneHelper.getFocusMarkerOpacity() > 0 && this.renderer.render(this.sceneHelper.focusMarker, this.camera), this.showControlPlane && this.renderer.render(this.sceneHelper.controlPlane, this.camera), this.renderer.autoClear = t; + }; + }()); + Pe(this, "updateFPS", function() { + let e = Ri(), t = 0; + return function() { + const n = Ri(); + n - e >= 1 ? (this.currentFPS = t, t = 0, e = n) : t++; + }; + }()); + Pe(this, "updateForRendererSizeChanges", function() { + const e = new me(), t = new me(); + return function() { + this.renderer.getSize(t), (t.x !== e.x || t.y !== e.y) && (this.usingExternalCamera || (this.camera.aspect = t.x / t.y, this.camera.updateProjectionMatrix()), e.copy(t)); + }; + }()); + Pe(this, "timingSensitiveUpdates", /* @__PURE__ */ function() { + let e; + return function() { + const t = Ri(); + e || (e = t); + const n = t - e; + this.updateCameraTransition(t), this.updateFocusMarker(n), e = t; + }; + }()); + Pe(this, "updateCameraTransition", function() { + let e = new P(), t = new P(), n = new P(); + return function(r) { + if (this.transitioningCameraTarget) { + t.copy(this.previousCameraTarget).sub(this.camera.position).normalize(), n.copy(this.nextCameraTarget).sub(this.camera.position).normalize(); + const s = Math.acos(t.dot(n)), o = (s / (Math.PI / 3) * 0.65 + 0.3) / s * (r - this.transitioningCameraTargetStartTime); + e.copy(this.previousCameraTarget).lerp(this.nextCameraTarget, o), this.camera.lookAt(e), this.controls.target.copy(e), o >= 1 && (this.transitioningCameraTarget = !1); + } + }; + }()); + Pe(this, "updateFocusMarker", function() { + const e = new me(); + let t = !1; + return function(n) { + this.getRenderDimensions(e); + const r = 10, s = 2.5; + if (this.transitioningCameraTarget) { + this.sceneHelper.setFocusMarkerVisibility(!0); + const a = Math.max(this.sceneHelper.getFocusMarkerOpacity(), 0); + let o = Math.min(a + r * n, 1); + this.sceneHelper.setFocusMarkerOpacity(o), this.sceneHelper.updateFocusMarker(this.nextCameraTarget, this.camera, e), t = !0; + } else { + let a; + if (t ? a = 1 : a = Math.min(this.sceneHelper.getFocusMarkerOpacity(), 1), a > 0) { + this.sceneHelper.updateFocusMarker(this.nextCameraTarget, this.camera, e); + let o = Math.max(a - s * n, 0); + this.sceneHelper.setFocusMarkerOpacity(o), o === 0 && this.sceneHelper.setFocusMarkerVisibility(!1); + } + t = !1; + } + }; + }()); + Pe(this, "updateMeshCursor", function() { + const e = [], t = new me(); + return function() { + this.showMeshCursor ? (this.getRenderDimensions(t), e.length = 0, this.raycaster.setFromCameraAndScreenPosition(this.camera, this.mousePosition, t), this.raycaster.intersectSplatMesh(this.splatMesh, e), e.length > 0 ? (this.sceneHelper.setMeshCursorVisibility(!0), this.sceneHelper.positionAndOrientMeshCursor(e[0].origin, this.camera)) : this.sceneHelper.setMeshCursorVisibility(!1)) : this.sceneHelper.setMeshCursorVisibility(!1); + }; + }()); + Pe(this, "updateInfoPanel", function() { + const e = new me(); + return function() { + if (!this.showInfo) + return; + const t = this.splatMesh.getSplatCount(); + this.getRenderDimensions(e); + const n = this.camera.position, r = `[${n.x.toFixed(5)}, ${n.y.toFixed(5)}, ${n.z.toFixed(5)}]`; + if (this.infoPanelCells.cameraPosition.innerHTML = r, this.controls) { + const l = this.controls.target, c = `[${l.x.toFixed(5)}, ${l.y.toFixed(5)}, ${l.z.toFixed(5)}]`; + this.infoPanelCells.cameraLookAt.innerHTML = c; + } + const s = this.camera.up, a = `[${s.x.toFixed(5)}, ${s.y.toFixed(5)}, ${s.z.toFixed(5)}]`; + if (this.infoPanelCells.cameraUp.innerHTML = a, this.showMeshCursor) { + const l = this.sceneHelper.meshCursor.position, c = `[${l.x.toFixed(5)}, ${l.y.toFixed(5)}, ${l.z.toFixed(5)}]`; + this.infoPanelCells.cursorPosition.innerHTML = c; + } else + this.infoPanelCells.cursorPosition.innerHTML = "N/A"; + this.infoPanelCells.fps.innerHTML = this.currentFPS, this.infoPanelCells.renderWindow.innerHTML = `${e.x} x ${e.y}`; + const o = this.splatRenderCount / t * 100; + this.infoPanelCells.renderSplatCount.innerHTML = `${this.splatRenderCount} splats out of ${t} (${o.toFixed(2)}%)`, this.infoPanelCells.sortTime.innerHTML = `${this.lastSortTime.toFixed(3)} ms`; + }; + }()); + Pe(this, "updateSplatSort", function() { + const e = new ke(), t = [], n = new P(0, 0, -1), r = new P(0, 0, -1), s = new P(), a = new P(), o = []; + let l = 0; + const c = [ + { + angleThreshold: 0.55, + sortFractions: [0.125, 0.33333, 0.75] + }, + { + angleThreshold: 0.65, + sortFractions: [0.33333, 0.66667] + }, + { + angleThreshold: 0.8, + sortFractions: [0.5] + } + ]; + return async function(u = !1, f = !1) { + if (this.sortRunning || !this.initialized || !this.splatRenderingInitialized) + return; + let h = 0, p = 0, g = !1, v = !1; + if (r.set(0, 0, -1).applyQuaternion(this.camera.quaternion), h = r.dot(n), p = a.copy(this.camera.position).sub(s).length(), !u && !this.splatMesh.dynamicMode && o.length === 0 && l > 0 && (h <= 0.95 && (g = !0), p >= 1 && (v = !0), !g && !v)) + return; + if (this.sortRunning = !0, this.splatRenderCount = this.gatherSceneNodesForSort(f), this.sortPromise = new Promise((M) => { + this.sortPromiseResolver = M; + }), e.copy(this.camera.matrixWorld).invert(), e.premultiply(this.camera.projectionMatrix), e.multiply(this.splatMesh.matrixWorld), this.gpuAcceleratedSort && (o.length <= 1 || o.length % 2 === 0) && await this.splatMesh.computeDistancesOnGPU(e, this.sortWorkerPrecomputedDistances), this.splatMesh.dynamicMode) + o.push(this.splatRenderCount); + else if (o.length === 0) { + for (let M of c) + if (h < M.angleThreshold) { + for (let _ of M.sortFractions) + o.push(Math.floor(this.splatRenderCount * _)); + break; + } + o.push(this.splatRenderCount); + } + const m = Math.min(o.shift(), this.splatRenderCount); + t[0] = this.camera.position.x, t[1] = this.camera.position.y, t[2] = this.camera.position.z; + const d = { + modelViewProj: e.elements, + cameraPosition: t, + splatRenderCount: this.splatRenderCount, + splatSortCount: m, + usePrecomputedDistances: this.gpuAcceleratedSort + }; + this.splatMesh.dynamicMode && this.splatMesh.fillTransformsArray(this.sortWorkerTransforms), this.sharedMemoryForWorkers || (d.indexesToSort = this.sortWorkerIndexesToSort, d.transforms = this.sortWorkerTransforms, this.gpuAcceleratedSort && (d.precomputedDistances = this.sortWorkerPrecomputedDistances)), this.sortWorker.postMessage({ + sort: d + }), o.length === 0 && (s.copy(this.camera.position), n.copy(r)), l++; + }; + }()); + /** + * Determine which splats to render by checking which are inside or close to the view frustum + */ + Pe(this, "gatherSceneNodesForSort", function() { + const e = [], t = new P(), n = new P(), r = new P(), s = new ke(), a = new ke(), o = new ke(), l = new P(), c = new P(0, 0, -1), u = new P(), f = (p) => u.copy(p.max).sub(p.min).length(), h = 125; + return function(p) { + this.getRenderDimensions(l); + const g = l.y / 2 / Math.tan(this.camera.fov / 2 * Yl.DEG2RAD), v = Math.atan(l.x / 2 / g), m = Math.atan(l.y / 2 / g), d = Math.cos(v), M = Math.cos(m), _ = this.splatMesh.getSplatTree(); + a.copy(this.camera.matrixWorld).invert(), a.multiply(this.splatMesh.matrixWorld); + let A = 0, C = 0; + for (let b = 0; b < _.subTrees.length; b++) { + const I = _.subTrees[b]; + s.copy(a), this.splatMesh.dynamicMode && (this.splatMesh.getSceneTransform(b, o), s.multiply(o)); + const W = I.nodesWithIndexes.length; + for (let S = 0; S < W; S++) { + const T = I.nodesWithIndexes[S]; + r.copy(T.center).applyMatrix4(s); + const Y = r.length(); + r.normalize(), t.copy(r).setX(0).normalize(), n.copy(r).setY(0).normalize(); + const K = c.dot(n), L = c.dot(t), N = f(T), O = L < M - 0.6, B = K < d - 0.6; + !p && (B || O || Y > h) && Y > N || (C += T.data.indexes.length, e[A] = T, T.data.distanceToNode = Y, A++); + } + } + e.length = A, e.sort((b, I) => b.data.distanceToNode < I.data.distanceToNode ? -1 : 1); + let E = C * mt.BytesPerInt; + for (let b = 0; b < A; b++) { + const I = e[b], W = I.data.indexes.length, S = W * mt.BytesPerInt; + new Uint32Array(this.sortWorkerIndexesToSort.buffer, E - S, W).set(I.data.indexes), E -= S; + } + return C; + }; + }()); + e.cameraUp || (e.cameraUp = [0, 1, 0]), this.cameraUp = new P().fromArray(e.cameraUp), e.initialCameraPosition || (e.initialCameraPosition = [0, 10, 15]), this.initialCameraPosition = new P().fromArray(e.initialCameraPosition), e.initialCameraLookAt || (e.initialCameraLookAt = [0, 0, 0]), this.initialCameraLookAt = new P().fromArray(e.initialCameraLookAt), this.dropInMode = e.dropInMode || !1, (e.selfDrivenMode === void 0 || e.selfDrivenMode === null) && (e.selfDrivenMode = !0), this.selfDrivenMode = e.selfDrivenMode && !this.dropInMode, this.selfDrivenUpdateFunc = this.selfDrivenUpdate.bind(this), e.useBuiltInControls === void 0 && (e.useBuiltInControls = !0), this.useBuiltInControls = e.useBuiltInControls, this.rootElement = e.rootElement, this.ignoreDevicePixelRatio = e.ignoreDevicePixelRatio || !1, this.devicePixelRatio = this.ignoreDevicePixelRatio ? 1 : window.devicePixelRatio, (e.halfPrecisionCovariancesOnGPU === void 0 || e.halfPrecisionCovariancesOnGPU === null) && (e.halfPrecisionCovariancesOnGPU = !0), this.halfPrecisionCovariancesOnGPU = e.halfPrecisionCovariancesOnGPU, this.threeScene = e.threeScene, this.renderer = e.renderer, this.camera = e.camera, this.gpuAcceleratedSort = e.gpuAcceleratedSort, this.gpuAcceleratedSort !== !0 && this.gpuAcceleratedSort !== !1 && (this.isMobile() ? this.gpuAcceleratedSort = !1 : this.gpuAcceleratedSort = !0), (e.integerBasedSort === void 0 || e.integerBasedSort === null) && (e.integerBasedSort = !0), this.integerBasedSort = e.integerBasedSort, (e.sharedMemoryForWorkers === void 0 || e.sharedMemoryForWorkers === null) && (e.sharedMemoryForWorkers = !0), this.sharedMemoryForWorkers = e.sharedMemoryForWorkers; + const t = !!e.dynamicScene; + this.splatMesh = new kt( + t, + this.halfPrecisionCovariancesOnGPU, + this.devicePixelRatio, + this.gpuAcceleratedSort, + this.integerBasedSort + ), this.webXRMode = e.webXRMode || kr.None, this.controls = null, this.showMeshCursor = !1, this.showControlPlane = !1, this.showInfo = !1, this.sceneHelper = null, this.sortWorker = null, this.sortRunning = !1, this.splatRenderCount = 0, this.sortWorkerIndexesToSort = null, this.sortWorkerSortedIndexes = null, this.sortWorkerPrecomputedDistances = null, this.sortWorkerTransforms = null, this.selfDrivenModeRunning = !1, this.splatRenderingInitialized = !1, this.raycaster = new A_(), this.infoPanel = null, this.infoPanelCells = {}, this.currentFPS = 0, this.lastSortTime = 0, this.previousCameraTarget = new P(), this.nextCameraTarget = new P(), this.mousePosition = new me(), this.mouseDownPosition = new me(), this.mouseDownTime = null, this.resizeObserver = null, this.mouseMoveListener = null, this.mouseDownListener = null, this.mouseUpListener = null, this.keyDownListener = null, this.sortPromise = null, this.sortPromiseResolver = null, this.loadingSpinner = new v_(null, this.rootElement || document.body), this.loadingSpinner.hide(), this.usingExternalCamera = !!(this.dropInMode || this.camera), this.usingExternalRenderer = !!(this.dropInMode || this.renderer), this.initialized = !1, this.dropInMode || this.init(); + } + init() { + if (this.initialized) + return; + this.rootElement || (this.usingExternalRenderer ? this.rootElement = this.renderer.domElement.parentElement || document.body : (this.rootElement = document.createElement("div"), this.rootElement.style.width = "100%", this.rootElement.style.height = "100%", this.rootElement.style.position = "absolute", document.body.appendChild(this.rootElement))); + const e = new me(); + this.getRenderDimensions(e), this.usingExternalCamera || (this.camera = new Ht(D_, e.x / e.y, 0.1, 500), this.camera.position.copy(this.initialCameraPosition), this.camera.up.copy(this.cameraUp).normalize(), this.camera.lookAt(this.initialCameraLookAt)), this.usingExternalRenderer || (this.renderer = new pc({ + antialias: !1, + precision: "highp" + }), this.renderer.setPixelRatio(this.devicePixelRatio), this.renderer.autoClear = !0, this.renderer.setClearColor(new Qe(0), 0), this.renderer.setSize(e.x, e.y), this.resizeObserver = new ResizeObserver(() => { + this.getRenderDimensions(e), this.renderer.setSize(e.x, e.y); + }), this.resizeObserver.observe(this.rootElement), this.rootElement.appendChild(this.renderer.domElement)), this.webXRMode && (this.webXRMode === kr.VR ? this.rootElement.appendChild(qi.createButton(this.renderer)) : this.webXRMode === kr.AR && this.rootElement.appendChild(L_.createButton(this.renderer)), this.renderer.xr.enabled = !0, this.camera.up.copy(this.cameraUp).normalize(), this.camera.lookAt(this.initialCameraLookAt)), this.threeScene = this.threeScene || new l_(), this.sceneHelper = new ar(this.threeScene), this.sceneHelper.setupMeshCursor(), this.sceneHelper.setupFocusMarker(), this.sceneHelper.setupControlPlane(), this.useBuiltInControls && this.webXRMode === kr.None && (this.controls = new __(this.camera, this.renderer.domElement), this.controls.listenToKeyEvents(window), this.controls.rotateSpeed = 0.5, this.controls.maxPolarAngle = Math.PI * 0.75, this.controls.minPolarAngle = 0.1, this.controls.enableDamping = !0, this.controls.dampingFactor = 0.05, this.controls.target.copy(this.initialCameraLookAt), this.mouseMoveListener = this.onMouseMove.bind(this), this.rootElement.addEventListener("pointermove", this.mouseMoveListener, !1), this.mouseDownListener = this.onMouseDown.bind(this), this.rootElement.addEventListener("pointerdown", this.mouseDownListener, !1), this.mouseUpListener = this.onMouseUp.bind(this), this.rootElement.addEventListener("pointerup", this.mouseUpListener, !1), this.keyDownListener = this.onKeyDown.bind(this), window.addEventListener("keydown", this.keyDownListener, !1)), this.setupInfoPanel(), this.loadingSpinner.setContainer(this.rootElement), this.initialized = !0; + } + removeEventHandlers() { + this.useBuiltInControls && (this.rootElement.removeEventListener("pointermove", this.mouseMoveListener), this.mouseMoveListener = null, this.rootElement.removeEventListener("pointerdown", this.mouseDownListener), this.mouseDownListener = null, this.rootElement.removeEventListener("pointerup", this.mouseUpListener), this.mouseUpListener = null, window.removeEventListener("keydown", this.keyDownListener), this.keyDownListener = null); + } + onMouseMove(e) { + this.mousePosition.set(e.offsetX, e.offsetY); + } + onMouseDown() { + this.mouseDownPosition.copy(this.mousePosition), this.mouseDownTime = Ri(); + } + onMouseClick(e) { + this.mousePosition.set(e.offsetX, e.offsetY), this.checkForFocalPointChange(); + } + getRenderDimensions(e) { + this.rootElement ? (e.x = this.rootElement.offsetWidth, e.y = this.rootElement.offsetHeight) : this.renderer.getSize(e); + } + setupInfoPanel() { + this.infoPanel = document.createElement("div"), this.infoPanel.style.position = "absolute", this.infoPanel.style.padding = "10px", this.infoPanel.style.backgroundColor = "#cccccc", this.infoPanel.style.border = "#aaaaaa 1px solid", this.infoPanel.style.zIndex = 100, this.infoPanel.style.width = "375px", this.infoPanel.style.fontFamily = "arial", this.infoPanel.style.fontSize = "10pt", this.infoPanel.style.textAlign = "left"; + const e = [ + ["Camera position", "cameraPosition"], + ["Camera look-at", "cameraLookAt"], + ["Camera up", "cameraUp"], + ["Cursor position", "cursorPosition"], + ["FPS", "fps"], + ["Render window", "renderWindow"], + ["Rendering:", "renderSplatCount"], + ["Sort time", "sortTime"] + ], t = document.createElement("div"); + t.style.display = "table"; + for (let n of e) { + const r = document.createElement("div"); + r.style.display = "table-row"; + const s = document.createElement("div"); + s.style.display = "table-cell", s.style.width = "110px", s.innerHTML = `${n[0]}: `; + const a = document.createElement("div"); + a.style.display = "table-cell", a.style.width = "10px", a.innerHTML = " "; + const o = document.createElement("div"); + o.style.display = "table-cell", o.innerHTML = "", this.infoPanelCells[n[1]] = o, r.appendChild(s), r.appendChild(a), r.appendChild(o), t.appendChild(r); + } + this.infoPanel.appendChild(t), this.infoPanel.style.display = "none", this.renderer.domElement.parentElement.prepend(this.infoPanel); + } + /** + * Add a splat scene to the viewer. + * @param {string} path Path to splat scene to be loaded + * @param {object} options { + * + * splatAlphaRemovalThreshold: Ignore any splats with an alpha less than the specified + * value (valid range: 0 - 255), defaults to 1 + * + * showLoadingSpinner: Display a loading spinner while the scene is loading, defaults to true + * + * position (Array): Position of the scene, acts as an offset from its default position, defaults to [0, 0, 0] + * + * rotation (Array): Rotation of the scene represented as a quaternion, defaults to [0, 0, 0, 1] + * + * scale (Array): Scene's scale, defaults to [1, 1, 1] + * + * onProgress: Function to be called as file data are received + * + * } + * @return {AbortablePromise} + */ + addSplatScene(e, t = {}) { + t.showLoadingSpinner !== !1 && (t.showLoadingSpinner = !0), t.showLoadingSpinner && this.loadingSpinner.show(); + const n = (s, a) => { + if (t.showLoadingSpinner) + if (s == 100) + this.loadingSpinner.setMessage("Download complete!"); + else { + const o = a ? `: ${a}` : "..."; + this.loadingSpinner.setMessage(`Downloading${o}`); + } + t.onProgress && t.onProgress(s, a, "downloading"); + }, r = this.loadFileToSplatBuffer(e, t.splatAlphaRemovalThreshold, n, t.format); + return new cn((s, a) => { + r.then((o) => { + t.showLoadingSpinner && this.loadingSpinner.hide(), t.onProgress && t.onProgress(0, "0%", "processing"); + const l = { + rotation: t.rotation || t.orientation, + position: t.position, + scale: t.scale, + splatAlphaRemovalThreshold: t.splatAlphaRemovalThreshold + }; + this.addSplatBuffers([o], [l], t.showLoadingSpinner).then(() => { + t.onProgress && t.onProgress(100, "100%", "processing"), s(); + }); + }).catch(() => { + t.showLoadingSpinner && this.loadingSpinner.hide(), a(new Error(`Viewer::addSplatScene -> Could not load file ${e}`)); + }); + }, r.abortHandler); + } + /** + * Add multiple splat scenes to the viewer. + * @param {Array} sceneOptions Array of per-scene options: { + * + * path: Path to splat scene to be loaded + * + * splatAlphaRemovalThreshold: Ignore any splats with an alpha less than the specified + * value (valid range: 0 - 255), defaults to 1 + * + * position (Array): Position of the scene, acts as an offset from its default position, defaults to [0, 0, 0] + * + * rotation (Array): Rotation of the scene represented as a quaternion, defaults to [0, 0, 0, 1] + * + * scale (Array): Scene's scale, defaults to [1, 1, 1] + * } + * @param {boolean} showLoadingSpinner Display a loading spinner while the scene is loading, defaults to true + * @param {function} onProgress Function to be called as file data are received + * @return {AbortablePromise} + */ + addSplatScenes(e, t = !0, n = void 0) { + const r = e.length, s = []; + t && this.loadingSpinner.show(); + const a = (u, f, h) => { + s[u] = f; + let p = 0; + for (let g = 0; g < r; g++) + p += s[g] || 0; + p = p / r, h = `${p.toFixed(2)}%`, t && (p == 100 ? this.loadingSpinner.setMessage("Download complete!") : this.loadingSpinner.setMessage(`Downloading: ${h}`)), n && n(p, h, "downloading"); + }, o = [], l = []; + for (let u = 0; u < e.length; u++) { + const f = this.loadFileToSplatBuffer( + e[u].path, + e[u].splatAlphaRemovalThreshold, + a.bind(this, u), + e.format + ); + l.push(f.abortHandler), o.push(f.promise); + } + const c = () => { + for (let u of l) + u(); + }; + return new cn((u, f) => { + Promise.all(o).then((h) => { + t && this.loadingSpinner.hide(), n && options.onProgress(0, "0%", "processing"), this.addSplatBuffers(h, e, t).then(() => { + n && n(100, "100%", "processing"), u(); + }); + }).catch(() => { + t && this.loadingSpinner.hide(), f(new Error("Viewer::addSplatScenes -> Could not load one or more splat scenes.")); + }); + }, c); + } + /** + * + * @param {string} path Path to splat scene to be loaded + * @param {number} splatAlphaRemovalThreshold Ignore any splats with an alpha less than the specified + * value (valid range: 0 - 255), defaults to 1 + * + * @param {function} onProgress Function to be called as file data are received + * @param {string} format Optional format specifier, if not specified the format will be inferred from the file extension + * @return {AbortablePromise} + */ + loadFileToSplatBuffer(e, t = 1, n = void 0, r = void 0) { + const s = (a, o) => { + n && n(a, o, "downloading"); + }; + if (r != null) { + if (r === Wr.Splat || r === Wr.KSplat) + return new Bn().loadFromURL(e, s, 0, t, void 0, void 0, r); + if (r === Wr.Ply) + return new rl().loadFromURL(e, s, 0, t); + } else { + if (Bn.isFileSplatFormat(e)) + return new Bn().loadFromURL(e, s, 0, t); + if (e.endsWith(".ply")) + return new rl().loadFromURL(e, s, 0, t); + } + return cn.reject(new Error(`Viewer::loadFileToSplatBuffer -> File format not supported: ${e}`)); + } + disposeSortWorker() { + this.sortWorker && this.sortWorker.terminate(), this.sortWorker = null, this.sortRunning = !1; + } + /** + * Add one or more instances of SplatBuffer to the SplatMesh instance managed by the viewer. This function is additive; all splat + * buffers contained by the viewer's splat mesh before calling this function will be preserved. + * @param {Array} splatBuffers SplatBuffer instances + * @param {Array} splatBufferOptions Array of options objects: { + * + * splatAlphaRemovalThreshold: Ignore any splats with an alpha less than the specified + * value (valid range: 0 - 255), defaults to 1 + * + * position (Array): Position of the scene, acts as an offset from its default position, defaults to [0, 0, 0] + * + * rotation (Array): Rotation of the scene represented as a quaternion, defaults to [0, 0, 0, 1] + * + * scale (Array): Scene's scale, defaults to [1, 1, 1] + * } + */ + addSplatBuffersToMesh(e, t) { + const n = this.splatMesh.splatBuffers || [], r = this.splatMesh.splatBufferOptions || []; + n.push(...e), r.push(...t), this.splatMesh.build(n, r, !0), this.renderer && this.splatMesh.setRenderer(this.renderer), this.splatMesh.frustumCulled = !1; + } + /** + * Set up the splat sorting web worker. + * @param {SplatMesh} splatMesh SplatMesh instance that contains the splats to be sorted + * @return {Promise} + */ + setupSortWorker(e) { + return new Promise((t) => { + const n = this.integerBasedSort ? Int32Array : Float32Array, r = e.getSplatCount(), s = P_(r, this.sharedMemoryForWorkers, this.integerBasedSort, this.splatMesh.dynamicMode); + s.onmessage = (a) => { + if (a.data.sortDone) { + if (this.sortRunning = !1, this.sharedMemoryForWorkers) + this.splatMesh.updateRenderIndexes(this.sortWorkerSortedIndexes, a.data.splatRenderCount); + else { + const o = new Uint32Array(a.data.sortedIndexes, 0, a.data.splatRenderCount); + this.splatMesh.updateRenderIndexes(o, a.data.splatRenderCount); + } + this.lastSortTime = a.data.sortTime, this.sortPromiseResolver(), this.sortPromise = null, this.sortPromiseResolver = null; + } else if (a.data.sortCanceled) + this.sortRunning = !1; + else if (a.data.sortSetupPhase1Complete) { + console.log("Sorting web worker WASM setup complete."); + const o = this.integerBasedSort ? this.splatMesh.getIntegerCenters(!0) : this.splatMesh.getFloatCenters(!0), l = this.splatMesh.getTransformIndexes(); + s.postMessage({ + centers: o.buffer, + transformIndexes: l.buffer + }), this.sharedMemoryForWorkers ? (this.sortWorkerSortedIndexes = new Uint32Array( + a.data.sortedIndexesBuffer, + a.data.sortedIndexesOffset, + r + ), this.sortWorkerIndexesToSort = new Uint32Array( + a.data.indexesToSortBuffer, + a.data.indexesToSortOffset, + r + ), this.sortWorkerPrecomputedDistances = new n( + a.data.precomputedDistancesBuffer, + a.data.precomputedDistancesOffset, + r + ), this.sortWorkerTransforms = new Float32Array( + a.data.transformsBuffer, + a.data.transformsOffset, + mt.MaxScenes * 16 + )) : (this.sortWorkerIndexesToSort = new Uint32Array(r), this.sortWorkerPrecomputedDistances = new n(r), this.sortWorkerTransforms = new Float32Array(mt.MaxScenes * 16)); + for (let c = 0; c < r; c++) + this.sortWorkerIndexesToSort[c] = c; + } else if (a.data.sortSetupComplete) { + console.log("Sorting web worker ready."); + const o = this.splatMesh.getSplatDataTextures(), l = o.covariances.size, c = o.centerColors.size; + console.log("Covariances texture size: " + l.x + " x " + l.y), console.log("Centers/colors texture size: " + c.x + " x " + c.y), this.sortWorker = s, t(); + } + }; + }); + } + /** + * Start self-driven mode + */ + start() { + if (this.selfDrivenMode) + this.webXRMode ? this.renderer.setAnimationLoop(this.selfDrivenUpdateFunc) : this.requestFrameId = requestAnimationFrame(this.selfDrivenUpdateFunc), this.selfDrivenModeRunning = !0; + else + throw new Error("Cannot start viewer unless it is in self driven mode."); + } + /** + * Stop self-driven mode + */ + stop() { + this.selfDrivenMode && this.selfDrivenModeRunning && (this.webXRMode || cancelAnimationFrame(this.requestFrameId), this.selfDrivenModeRunning = !1); + } + /** + * Dispose of all resources held directly and indirectly by this viewer. + */ + async dispose() { + this.sortPromise && await this.sortPromise, this.stop(), this.controls && (this.controls.dispose(), this.controls = null), this.splatMesh && (this.splatMesh.dispose(), this.splatMesh = null), this.sceneHelper && (this.sceneHelper.dispose(), this.sceneHelper = null), this.resizeObserver && (this.resizeObserver.unobserve(this.rootElement), this.resizeObserver = null), this.renderer && (this.usingExternalRenderer || this.renderer.dispose(), this.renderer = null), this.disposeSortWorker(), this.removeEventHandlers(), this.camera = null, this.threeScene = null, this.splatRenderingInitialized = !1, this.initialized = !1; + } + selfDrivenUpdate() { + this.selfDrivenMode && !this.webXRMode && (this.requestFrameId = requestAnimationFrame(this.selfDrivenUpdateFunc)), this.update(), this.render(); + } + update(e, t) { + this.dropInMode && this.updateForDropInMode(e, t), !(!this.initialized || !this.splatRenderingInitialized) && (this.controls && this.controls.update(), this.updateSplatSort(), this.updateForRendererSizeChanges(), this.updateSplatMesh(), this.updateMeshCursor(), this.updateFPS(), this.timingSensitiveUpdates(), this.updateInfoPanel(), this.updateControlPlane()); + } + updateForDropInMode(e, t) { + this.renderer = e, this.splatMesh && this.splatMesh.setRenderer(this.renderer), this.camera = t, this.controls && (this.controls.object = t), this.init(); + } + updateControlPlane() { + this.showControlPlane ? (this.sceneHelper.setControlPlaneVisibility(!0), this.sceneHelper.positionAndOrientControlPlane(this.controls.target, this.camera.up)) : this.sceneHelper.setControlPlaneVisibility(!1); + } + getSplatMesh() { + return this.splatMesh; + } + /** + * Get a reference to a splat scene. + * @param {number} sceneIndex The index of the scene to which the reference will be returned + * @return {SplatScene} + */ + getSplatScene(e) { + return this.splatMesh.getScene(e); + } + isMobile() { + return navigator.userAgent.includes("Mobi"); + } +} +const { + SvelteComponent: F_, + attr: N_, + create_component: B_, + destroy_component: O_, + detach: ul, + element: z_, + init: k_, + insert: fl, + mount_component: G_, + safe_not_equal: H_, + space: V_, + transition_in: W_, + transition_out: X_ +} = window.__gradio__svelte__internal, { onMount: q_ } = window.__gradio__svelte__internal; +function Y_(i) { + let e, t, n, r; + return e = new uo({ + props: { + show_label: ( + /*show_label*/ + i[1] + ), + Icon: rs, + label: ( + /*label*/ + i[0] || /*i18n*/ + i[2]("4DGS_model.splat") + ) + } + }), { + c() { + B_(e.$$.fragment), t = V_(), n = z_("div"), n.innerHTML = "", N_(n, "class", "model4DGS svelte-jfv6j3"); + }, + m(s, a) { + G_(e, s, a), fl(s, t, a), fl(s, n, a), r = !0; + }, + p(s, [a]) { + const o = {}; + a & /*show_label*/ + 2 && (o.show_label = /*show_label*/ + s[1]), a & /*label, i18n*/ + 5 && (o.label = /*label*/ + s[0] || /*i18n*/ + s[2]("4DGS_model.splat")), e.$set(o); + }, + i(s) { + r || (W_(e.$$.fragment, s), r = !0); + }, + o(s) { + X_(e.$$.fragment, s), r = !1; + }, + d(s) { + s && (ul(t), ul(n)), O_(e, s); + } + }; +} +function j_(i, e, t) { + let { value: n } = e, { root: r } = e, { proxy_url: s } = e, { label: a = "" } = e, { show_label: o } = e, { i18n: l } = e, c = 0, u = 1; + var f = []; + const h = new P(1.25, 1.25, 1.25), p = new P(0.01, 0.01, 0.01); + return q_(() => { + if (n != null && n.files != null) { + const g = document.querySelector(".model4DGS"), v = new U_({ + cameraUp: [0, 1, 0], + initialCameraPosition: [0, 0, 4], + initialCameraLookAt: [0, 0, -1], + dynamicScene: !0, + sharedMemoryForWorkers: !1, + rootElement: g + }); + u = n.files.length; + let m = n.files; + for (let d = 0; d < m.length; d++) { + let M = { + path: Ul(m[d], r, s).url, + scale: [p, p, p] + }; + f.push(M); + } + v.addSplatScenes(f, !0).then(() => { + v.start(); + let d = performance.now(); + requestAnimationFrame(M); + function M() { + requestAnimationFrame(M), performance.now() - d > 150 && (v.getSplatScene(c).scale.copy(p), d = performance.now(), c++, c >= u && (c = 0), v.getSplatScene(c).scale.copy(h)); + } + }); + } + }), i.$$set = (g) => { + "value" in g && t(3, n = g.value), "root" in g && t(4, r = g.root), "proxy_url" in g && t(5, s = g.proxy_url), "label" in g && t(0, a = g.label), "show_label" in g && t(1, o = g.show_label), "i18n" in g && t(2, l = g.i18n); + }, [a, o, l, n, r, s]; +} +class K_ extends F_ { + constructor(e) { + super(), k_(this, e, j_, Y_, H_, { + value: 3, + root: 4, + proxy_url: 5, + label: 0, + show_label: 1, + i18n: 2 + }); + } +} +function Ni(i) { + let e = ["", "k", "M", "G", "T", "P", "E", "Z"], t = 0; + for (; i > 1e3 && t < e.length - 1; ) + i /= 1e3, t++; + let n = e[t]; + return (Number.isInteger(i) ? i : i.toFixed(1)) + n; +} +function Xr() { +} +function Q_(i, e) { + return i != i ? e == e : i !== e || i && typeof i == "object" || typeof i == "function"; +} +const gc = typeof window < "u"; +let hl = gc ? () => window.performance.now() : () => Date.now(), _c = gc ? (i) => requestAnimationFrame(i) : Xr; +const Oi = /* @__PURE__ */ new Set(); +function vc(i) { + Oi.forEach((e) => { + e.c(i) || (Oi.delete(e), e.f()); + }), Oi.size !== 0 && _c(vc); +} +function Z_(i) { + let e; + return Oi.size === 0 && _c(vc), { + promise: new Promise((t) => { + Oi.add(e = { c: i, f: t }); + }), + abort() { + Oi.delete(e); + } + }; +} +const Pi = []; +function J_(i, e = Xr) { + let t; + const n = /* @__PURE__ */ new Set(); + function r(o) { + if (Q_(i, o) && (i = o, t)) { + const l = !Pi.length; + for (const c of n) + c[1](), Pi.push(c, i); + if (l) { + for (let c = 0; c < Pi.length; c += 2) + Pi[c][0](Pi[c + 1]); + Pi.length = 0; + } + } + } + function s(o) { + r(o(i)); + } + function a(o, l = Xr) { + const c = [o, l]; + return n.add(c), n.size === 1 && (t = e(r, s) || Xr), o(i), () => { + n.delete(c), n.size === 0 && t && (t(), t = null); + }; + } + return { set: r, update: s, subscribe: a }; +} +function dl(i) { + return Object.prototype.toString.call(i) === "[object Date]"; +} +function lo(i, e, t, n) { + if (typeof t == "number" || dl(t)) { + const r = n - t, s = (t - e) / (i.dt || 1 / 60), a = i.opts.stiffness * r, o = i.opts.damping * s, l = (a - o) * i.inv_mass, c = (s + l) * i.dt; + return Math.abs(c) < i.opts.precision && Math.abs(r) < i.opts.precision ? n : (i.settled = !1, dl(t) ? new Date(t.getTime() + c) : t + c); + } else { + if (Array.isArray(t)) + return t.map( + (r, s) => lo(i, e[s], t[s], n[s]) + ); + if (typeof t == "object") { + const r = {}; + for (const s in t) + r[s] = lo(i, e[s], t[s], n[s]); + return r; + } else + throw new Error(`Cannot spring ${typeof t} values`); + } +} +function pl(i, e = {}) { + const t = J_(i), { stiffness: n = 0.15, damping: r = 0.8, precision: s = 0.01 } = e; + let a, o, l, c = i, u = i, f = 1, h = 0, p = !1; + function g(m, d = {}) { + u = m; + const M = l = {}; + return i == null || d.hard || v.stiffness >= 1 && v.damping >= 1 ? (p = !0, a = hl(), c = m, t.set(i = u), Promise.resolve()) : (d.soft && (h = 1 / ((d.soft === !0 ? 0.5 : +d.soft) * 60), f = 0), o || (a = hl(), p = !1, o = Z_((_) => { + if (p) + return p = !1, o = null, !1; + f = Math.min(f + h, 1); + const A = { + inv_mass: f, + opts: v, + settled: !0, + dt: (_ - a) * 60 / 1e3 + }, C = lo(A, c, i, u); + return a = _, c = i, t.set(i = C), A.settled && (o = null), !A.settled; + })), new Promise((_) => { + o.promise.then(() => { + M === l && _(); + }); + })); + } + const v = { + set: g, + update: (m, d) => g(m(u, i), d), + subscribe: t.subscribe, + stiffness: n, + damping: r, + precision: s + }; + return v; +} +const { + SvelteComponent: $_, + append: Zt, + attr: je, + component_subscribe: ml, + detach: e0, + element: t0, + init: n0, + insert: i0, + noop: gl, + safe_not_equal: r0, + set_style: Gr, + svg_element: Jt, + toggle_class: _l +} = window.__gradio__svelte__internal, { onMount: s0 } = window.__gradio__svelte__internal; +function o0(i) { + let e, t, n, r, s, a, o, l, c, u, f, h; + return { + c() { + e = t0("div"), t = Jt("svg"), n = Jt("g"), r = Jt("path"), s = Jt("path"), a = Jt("path"), o = Jt("path"), l = Jt("g"), c = Jt("path"), u = Jt("path"), f = Jt("path"), h = Jt("path"), je(r, "d", "M255.926 0.754768L509.702 139.936V221.027L255.926 81.8465V0.754768Z"), je(r, "fill", "#FF7C00"), je(r, "fill-opacity", "0.4"), je(r, "class", "svelte-43sxxs"), je(s, "d", "M509.69 139.936L254.981 279.641V361.255L509.69 221.55V139.936Z"), je(s, "fill", "#FF7C00"), je(s, "class", "svelte-43sxxs"), je(a, "d", "M0.250138 139.937L254.981 279.641V361.255L0.250138 221.55V139.937Z"), je(a, "fill", "#FF7C00"), je(a, "fill-opacity", "0.4"), je(a, "class", "svelte-43sxxs"), je(o, "d", "M255.923 0.232622L0.236328 139.936V221.55L255.923 81.8469V0.232622Z"), je(o, "fill", "#FF7C00"), je(o, "class", "svelte-43sxxs"), Gr(n, "transform", "translate(" + /*$top*/ + i[1][0] + "px, " + /*$top*/ + i[1][1] + "px)"), je(c, "d", "M255.926 141.5L509.702 280.681V361.773L255.926 222.592V141.5Z"), je(c, "fill", "#FF7C00"), je(c, "fill-opacity", "0.4"), je(c, "class", "svelte-43sxxs"), je(u, "d", "M509.69 280.679L254.981 420.384V501.998L509.69 362.293V280.679Z"), je(u, "fill", "#FF7C00"), je(u, "class", "svelte-43sxxs"), je(f, "d", "M0.250138 280.681L254.981 420.386V502L0.250138 362.295V280.681Z"), je(f, "fill", "#FF7C00"), je(f, "fill-opacity", "0.4"), je(f, "class", "svelte-43sxxs"), je(h, "d", "M255.923 140.977L0.236328 280.68V362.294L255.923 222.591V140.977Z"), je(h, "fill", "#FF7C00"), je(h, "class", "svelte-43sxxs"), Gr(l, "transform", "translate(" + /*$bottom*/ + i[2][0] + "px, " + /*$bottom*/ + i[2][1] + "px)"), je(t, "viewBox", "-1200 -1200 3000 3000"), je(t, "fill", "none"), je(t, "xmlns", "http://www.w3.org/2000/svg"), je(t, "class", "svelte-43sxxs"), je(e, "class", "svelte-43sxxs"), _l( + e, + "margin", + /*margin*/ + i[0] + ); + }, + m(p, g) { + i0(p, e, g), Zt(e, t), Zt(t, n), Zt(n, r), Zt(n, s), Zt(n, a), Zt(n, o), Zt(t, l), Zt(l, c), Zt(l, u), Zt(l, f), Zt(l, h); + }, + p(p, [g]) { + g & /*$top*/ + 2 && Gr(n, "transform", "translate(" + /*$top*/ + p[1][0] + "px, " + /*$top*/ + p[1][1] + "px)"), g & /*$bottom*/ + 4 && Gr(l, "transform", "translate(" + /*$bottom*/ + p[2][0] + "px, " + /*$bottom*/ + p[2][1] + "px)"), g & /*margin*/ + 1 && _l( + e, + "margin", + /*margin*/ + p[0] + ); + }, + i: gl, + o: gl, + d(p) { + p && e0(e); + } + }; +} +function a0(i, e, t) { + let n, r, { margin: s = !0 } = e; + const a = pl([0, 0]); + ml(i, a, (h) => t(1, n = h)); + const o = pl([0, 0]); + ml(i, o, (h) => t(2, r = h)); + let l; + async function c() { + await Promise.all([a.set([125, 140]), o.set([-125, -140])]), await Promise.all([a.set([-125, 140]), o.set([125, -140])]), await Promise.all([a.set([-125, 0]), o.set([125, -0])]), await Promise.all([a.set([125, 0]), o.set([-125, 0])]); + } + async function u() { + await c(), l || u(); + } + async function f() { + await Promise.all([a.set([125, 0]), o.set([-125, 0])]), u(); + } + return s0(() => (f(), () => l = !0)), i.$$set = (h) => { + "margin" in h && t(0, s = h.margin); + }, [s, n, r, a, o]; +} +class l0 extends $_ { + constructor(e) { + super(), n0(this, e, a0, o0, r0, { margin: 0 }); + } +} +const { + SvelteComponent: c0, + append: ii, + attr: un, + binding_callbacks: vl, + check_outros: xc, + create_component: u0, + create_slot: f0, + destroy_component: h0, + destroy_each: Sc, + detach: Ge, + element: yn, + empty: Ji, + ensure_array_like: ts, + get_all_dirty_from_scope: d0, + get_slot_changes: p0, + group_outros: Mc, + init: m0, + insert: He, + mount_component: g0, + noop: co, + safe_not_equal: _0, + set_data: qt, + set_style: On, + space: fn, + text: st, + toggle_class: Gt, + transition_in: Yi, + transition_out: ji, + update_slot_base: v0 +} = window.__gradio__svelte__internal, { tick: x0 } = window.__gradio__svelte__internal, { onDestroy: S0 } = window.__gradio__svelte__internal, M0 = (i) => ({}), xl = (i) => ({}); +function Sl(i, e, t) { + const n = i.slice(); + return n[38] = e[t], n[40] = t, n; +} +function Ml(i, e, t) { + const n = i.slice(); + return n[38] = e[t], n; +} +function y0(i) { + let e, t = ( + /*i18n*/ + i[1]("common.error") + "" + ), n, r, s; + const a = ( + /*#slots*/ + i[29].error + ), o = f0( + a, + i, + /*$$scope*/ + i[28], + xl + ); + return { + c() { + e = yn("span"), n = st(t), r = fn(), o && o.c(), un(e, "class", "error svelte-1txqlrd"); + }, + m(l, c) { + He(l, e, c), ii(e, n), He(l, r, c), o && o.m(l, c), s = !0; + }, + p(l, c) { + (!s || c[0] & /*i18n*/ + 2) && t !== (t = /*i18n*/ + l[1]("common.error") + "") && qt(n, t), o && o.p && (!s || c[0] & /*$$scope*/ + 268435456) && v0( + o, + a, + l, + /*$$scope*/ + l[28], + s ? p0( + a, + /*$$scope*/ + l[28], + c, + M0 + ) : d0( + /*$$scope*/ + l[28] + ), + xl + ); + }, + i(l) { + s || (Yi(o, l), s = !0); + }, + o(l) { + ji(o, l), s = !1; + }, + d(l) { + l && (Ge(e), Ge(r)), o && o.d(l); + } + }; +} +function A0(i) { + let e, t, n, r, s, a, o, l, c, u = ( + /*variant*/ + i[8] === "default" && /*show_eta_bar*/ + i[18] && /*show_progress*/ + i[6] === "full" && yl(i) + ); + function f(_, A) { + if ( + /*progress*/ + _[7] + ) + return T0; + if ( + /*queue_position*/ + _[2] !== null && /*queue_size*/ + _[3] !== void 0 && /*queue_position*/ + _[2] >= 0 + ) + return b0; + if ( + /*queue_position*/ + _[2] === 0 + ) + return E0; + } + let h = f(i), p = h && h(i), g = ( + /*timer*/ + i[5] && bl(i) + ); + const v = [P0, R0], m = []; + function d(_, A) { + return ( + /*last_progress_level*/ + _[15] != null ? 0 : ( + /*show_progress*/ + _[6] === "full" ? 1 : -1 + ) + ); + } + ~(s = d(i)) && (a = m[s] = v[s](i)); + let M = !/*timer*/ + i[5] && Dl(i); + return { + c() { + u && u.c(), e = fn(), t = yn("div"), p && p.c(), n = fn(), g && g.c(), r = fn(), a && a.c(), o = fn(), M && M.c(), l = Ji(), un(t, "class", "progress-text svelte-1txqlrd"), Gt( + t, + "meta-text-center", + /*variant*/ + i[8] === "center" + ), Gt( + t, + "meta-text", + /*variant*/ + i[8] === "default" + ); + }, + m(_, A) { + u && u.m(_, A), He(_, e, A), He(_, t, A), p && p.m(t, null), ii(t, n), g && g.m(t, null), He(_, r, A), ~s && m[s].m(_, A), He(_, o, A), M && M.m(_, A), He(_, l, A), c = !0; + }, + p(_, A) { + /*variant*/ + _[8] === "default" && /*show_eta_bar*/ + _[18] && /*show_progress*/ + _[6] === "full" ? u ? u.p(_, A) : (u = yl(_), u.c(), u.m(e.parentNode, e)) : u && (u.d(1), u = null), h === (h = f(_)) && p ? p.p(_, A) : (p && p.d(1), p = h && h(_), p && (p.c(), p.m(t, n))), /*timer*/ + _[5] ? g ? g.p(_, A) : (g = bl(_), g.c(), g.m(t, null)) : g && (g.d(1), g = null), (!c || A[0] & /*variant*/ + 256) && Gt( + t, + "meta-text-center", + /*variant*/ + _[8] === "center" + ), (!c || A[0] & /*variant*/ + 256) && Gt( + t, + "meta-text", + /*variant*/ + _[8] === "default" + ); + let C = s; + s = d(_), s === C ? ~s && m[s].p(_, A) : (a && (Mc(), ji(m[C], 1, 1, () => { + m[C] = null; + }), xc()), ~s ? (a = m[s], a ? a.p(_, A) : (a = m[s] = v[s](_), a.c()), Yi(a, 1), a.m(o.parentNode, o)) : a = null), /*timer*/ + _[5] ? M && (M.d(1), M = null) : M ? M.p(_, A) : (M = Dl(_), M.c(), M.m(l.parentNode, l)); + }, + i(_) { + c || (Yi(a), c = !0); + }, + o(_) { + ji(a), c = !1; + }, + d(_) { + _ && (Ge(e), Ge(t), Ge(r), Ge(o), Ge(l)), u && u.d(_), p && p.d(), g && g.d(), ~s && m[s].d(_), M && M.d(_); + } + }; +} +function yl(i) { + let e, t = `translateX(${/*eta_level*/ + (i[17] || 0) * 100 - 100}%)`; + return { + c() { + e = yn("div"), un(e, "class", "eta-bar svelte-1txqlrd"), On(e, "transform", t); + }, + m(n, r) { + He(n, e, r); + }, + p(n, r) { + r[0] & /*eta_level*/ + 131072 && t !== (t = `translateX(${/*eta_level*/ + (n[17] || 0) * 100 - 100}%)`) && On(e, "transform", t); + }, + d(n) { + n && Ge(e); + } + }; +} +function E0(i) { + let e; + return { + c() { + e = st("processing |"); + }, + m(t, n) { + He(t, e, n); + }, + p: co, + d(t) { + t && Ge(e); + } + }; +} +function b0(i) { + let e, t = ( + /*queue_position*/ + i[2] + 1 + "" + ), n, r, s, a; + return { + c() { + e = st("queue: "), n = st(t), r = st("/"), s = st( + /*queue_size*/ + i[3] + ), a = st(" |"); + }, + m(o, l) { + He(o, e, l), He(o, n, l), He(o, r, l), He(o, s, l), He(o, a, l); + }, + p(o, l) { + l[0] & /*queue_position*/ + 4 && t !== (t = /*queue_position*/ + o[2] + 1 + "") && qt(n, t), l[0] & /*queue_size*/ + 8 && qt( + s, + /*queue_size*/ + o[3] + ); + }, + d(o) { + o && (Ge(e), Ge(n), Ge(r), Ge(s), Ge(a)); + } + }; +} +function T0(i) { + let e, t = ts( + /*progress*/ + i[7] + ), n = []; + for (let r = 0; r < t.length; r += 1) + n[r] = El(Ml(i, t, r)); + return { + c() { + for (let r = 0; r < n.length; r += 1) + n[r].c(); + e = Ji(); + }, + m(r, s) { + for (let a = 0; a < n.length; a += 1) + n[a] && n[a].m(r, s); + He(r, e, s); + }, + p(r, s) { + if (s[0] & /*progress*/ + 128) { + t = ts( + /*progress*/ + r[7] + ); + let a; + for (a = 0; a < t.length; a += 1) { + const o = Ml(r, t, a); + n[a] ? n[a].p(o, s) : (n[a] = El(o), n[a].c(), n[a].m(e.parentNode, e)); + } + for (; a < n.length; a += 1) + n[a].d(1); + n.length = t.length; + } + }, + d(r) { + r && Ge(e), Sc(n, r); + } + }; +} +function Al(i) { + let e, t = ( + /*p*/ + i[38].unit + "" + ), n, r, s = " ", a; + function o(u, f) { + return ( + /*p*/ + u[38].length != null ? C0 : w0 + ); + } + let l = o(i), c = l(i); + return { + c() { + c.c(), e = fn(), n = st(t), r = st(" | "), a = st(s); + }, + m(u, f) { + c.m(u, f), He(u, e, f), He(u, n, f), He(u, r, f), He(u, a, f); + }, + p(u, f) { + l === (l = o(u)) && c ? c.p(u, f) : (c.d(1), c = l(u), c && (c.c(), c.m(e.parentNode, e))), f[0] & /*progress*/ + 128 && t !== (t = /*p*/ + u[38].unit + "") && qt(n, t); + }, + d(u) { + u && (Ge(e), Ge(n), Ge(r), Ge(a)), c.d(u); + } + }; +} +function w0(i) { + let e = Ni( + /*p*/ + i[38].index || 0 + ) + "", t; + return { + c() { + t = st(e); + }, + m(n, r) { + He(n, t, r); + }, + p(n, r) { + r[0] & /*progress*/ + 128 && e !== (e = Ni( + /*p*/ + n[38].index || 0 + ) + "") && qt(t, e); + }, + d(n) { + n && Ge(t); + } + }; +} +function C0(i) { + let e = Ni( + /*p*/ + i[38].index || 0 + ) + "", t, n, r = Ni( + /*p*/ + i[38].length + ) + "", s; + return { + c() { + t = st(e), n = st("/"), s = st(r); + }, + m(a, o) { + He(a, t, o), He(a, n, o), He(a, s, o); + }, + p(a, o) { + o[0] & /*progress*/ + 128 && e !== (e = Ni( + /*p*/ + a[38].index || 0 + ) + "") && qt(t, e), o[0] & /*progress*/ + 128 && r !== (r = Ni( + /*p*/ + a[38].length + ) + "") && qt(s, r); + }, + d(a) { + a && (Ge(t), Ge(n), Ge(s)); + } + }; +} +function El(i) { + let e, t = ( + /*p*/ + i[38].index != null && Al(i) + ); + return { + c() { + t && t.c(), e = Ji(); + }, + m(n, r) { + t && t.m(n, r), He(n, e, r); + }, + p(n, r) { + /*p*/ + n[38].index != null ? t ? t.p(n, r) : (t = Al(n), t.c(), t.m(e.parentNode, e)) : t && (t.d(1), t = null); + }, + d(n) { + n && Ge(e), t && t.d(n); + } + }; +} +function bl(i) { + let e, t = ( + /*eta*/ + i[0] ? `/${/*formatted_eta*/ + i[19]}` : "" + ), n, r; + return { + c() { + e = st( + /*formatted_timer*/ + i[20] + ), n = st(t), r = st("s"); + }, + m(s, a) { + He(s, e, a), He(s, n, a), He(s, r, a); + }, + p(s, a) { + a[0] & /*formatted_timer*/ + 1048576 && qt( + e, + /*formatted_timer*/ + s[20] + ), a[0] & /*eta, formatted_eta*/ + 524289 && t !== (t = /*eta*/ + s[0] ? `/${/*formatted_eta*/ + s[19]}` : "") && qt(n, t); + }, + d(s) { + s && (Ge(e), Ge(n), Ge(r)); + } + }; +} +function R0(i) { + let e, t; + return e = new l0({ + props: { margin: ( + /*variant*/ + i[8] === "default" + ) } + }), { + c() { + u0(e.$$.fragment); + }, + m(n, r) { + g0(e, n, r), t = !0; + }, + p(n, r) { + const s = {}; + r[0] & /*variant*/ + 256 && (s.margin = /*variant*/ + n[8] === "default"), e.$set(s); + }, + i(n) { + t || (Yi(e.$$.fragment, n), t = !0); + }, + o(n) { + ji(e.$$.fragment, n), t = !1; + }, + d(n) { + h0(e, n); + } + }; +} +function P0(i) { + let e, t, n, r, s, a = `${/*last_progress_level*/ + i[15] * 100}%`, o = ( + /*progress*/ + i[7] != null && Tl(i) + ); + return { + c() { + e = yn("div"), t = yn("div"), o && o.c(), n = fn(), r = yn("div"), s = yn("div"), un(t, "class", "progress-level-inner svelte-1txqlrd"), un(s, "class", "progress-bar svelte-1txqlrd"), On(s, "width", a), un(r, "class", "progress-bar-wrap svelte-1txqlrd"), un(e, "class", "progress-level svelte-1txqlrd"); + }, + m(l, c) { + He(l, e, c), ii(e, t), o && o.m(t, null), ii(e, n), ii(e, r), ii(r, s), i[30](s); + }, + p(l, c) { + /*progress*/ + l[7] != null ? o ? o.p(l, c) : (o = Tl(l), o.c(), o.m(t, null)) : o && (o.d(1), o = null), c[0] & /*last_progress_level*/ + 32768 && a !== (a = `${/*last_progress_level*/ + l[15] * 100}%`) && On(s, "width", a); + }, + i: co, + o: co, + d(l) { + l && Ge(e), o && o.d(), i[30](null); + } + }; +} +function Tl(i) { + let e, t = ts( + /*progress*/ + i[7] + ), n = []; + for (let r = 0; r < t.length; r += 1) + n[r] = Ll(Sl(i, t, r)); + return { + c() { + for (let r = 0; r < n.length; r += 1) + n[r].c(); + e = Ji(); + }, + m(r, s) { + for (let a = 0; a < n.length; a += 1) + n[a] && n[a].m(r, s); + He(r, e, s); + }, + p(r, s) { + if (s[0] & /*progress_level, progress*/ + 16512) { + t = ts( + /*progress*/ + r[7] + ); + let a; + for (a = 0; a < t.length; a += 1) { + const o = Sl(r, t, a); + n[a] ? n[a].p(o, s) : (n[a] = Ll(o), n[a].c(), n[a].m(e.parentNode, e)); + } + for (; a < n.length; a += 1) + n[a].d(1); + n.length = t.length; + } + }, + d(r) { + r && Ge(e), Sc(n, r); + } + }; +} +function wl(i) { + let e, t, n, r, s = ( + /*i*/ + i[40] !== 0 && L0() + ), a = ( + /*p*/ + i[38].desc != null && Cl(i) + ), o = ( + /*p*/ + i[38].desc != null && /*progress_level*/ + i[14] && /*progress_level*/ + i[14][ + /*i*/ + i[40] + ] != null && Rl() + ), l = ( + /*progress_level*/ + i[14] != null && Pl(i) + ); + return { + c() { + s && s.c(), e = fn(), a && a.c(), t = fn(), o && o.c(), n = fn(), l && l.c(), r = Ji(); + }, + m(c, u) { + s && s.m(c, u), He(c, e, u), a && a.m(c, u), He(c, t, u), o && o.m(c, u), He(c, n, u), l && l.m(c, u), He(c, r, u); + }, + p(c, u) { + /*p*/ + c[38].desc != null ? a ? a.p(c, u) : (a = Cl(c), a.c(), a.m(t.parentNode, t)) : a && (a.d(1), a = null), /*p*/ + c[38].desc != null && /*progress_level*/ + c[14] && /*progress_level*/ + c[14][ + /*i*/ + c[40] + ] != null ? o || (o = Rl(), o.c(), o.m(n.parentNode, n)) : o && (o.d(1), o = null), /*progress_level*/ + c[14] != null ? l ? l.p(c, u) : (l = Pl(c), l.c(), l.m(r.parentNode, r)) : l && (l.d(1), l = null); + }, + d(c) { + c && (Ge(e), Ge(t), Ge(n), Ge(r)), s && s.d(c), a && a.d(c), o && o.d(c), l && l.d(c); + } + }; +} +function L0(i) { + let e; + return { + c() { + e = st(" /"); + }, + m(t, n) { + He(t, e, n); + }, + d(t) { + t && Ge(e); + } + }; +} +function Cl(i) { + let e = ( + /*p*/ + i[38].desc + "" + ), t; + return { + c() { + t = st(e); + }, + m(n, r) { + He(n, t, r); + }, + p(n, r) { + r[0] & /*progress*/ + 128 && e !== (e = /*p*/ + n[38].desc + "") && qt(t, e); + }, + d(n) { + n && Ge(t); + } + }; +} +function Rl(i) { + let e; + return { + c() { + e = st("-"); + }, + m(t, n) { + He(t, e, n); + }, + d(t) { + t && Ge(e); + } + }; +} +function Pl(i) { + let e = (100 * /*progress_level*/ + (i[14][ + /*i*/ + i[40] + ] || 0)).toFixed(1) + "", t, n; + return { + c() { + t = st(e), n = st("%"); + }, + m(r, s) { + He(r, t, s), He(r, n, s); + }, + p(r, s) { + s[0] & /*progress_level*/ + 16384 && e !== (e = (100 * /*progress_level*/ + (r[14][ + /*i*/ + r[40] + ] || 0)).toFixed(1) + "") && qt(t, e); + }, + d(r) { + r && (Ge(t), Ge(n)); + } + }; +} +function Ll(i) { + let e, t = ( + /*p*/ + (i[38].desc != null || /*progress_level*/ + i[14] && /*progress_level*/ + i[14][ + /*i*/ + i[40] + ] != null) && wl(i) + ); + return { + c() { + t && t.c(), e = Ji(); + }, + m(n, r) { + t && t.m(n, r), He(n, e, r); + }, + p(n, r) { + /*p*/ + n[38].desc != null || /*progress_level*/ + n[14] && /*progress_level*/ + n[14][ + /*i*/ + n[40] + ] != null ? t ? t.p(n, r) : (t = wl(n), t.c(), t.m(e.parentNode, e)) : t && (t.d(1), t = null); + }, + d(n) { + n && Ge(e), t && t.d(n); + } + }; +} +function Dl(i) { + let e, t; + return { + c() { + e = yn("p"), t = st( + /*loading_text*/ + i[9] + ), un(e, "class", "loading svelte-1txqlrd"); + }, + m(n, r) { + He(n, e, r), ii(e, t); + }, + p(n, r) { + r[0] & /*loading_text*/ + 512 && qt( + t, + /*loading_text*/ + n[9] + ); + }, + d(n) { + n && Ge(e); + } + }; +} +function D0(i) { + let e, t, n, r, s; + const a = [A0, y0], o = []; + function l(c, u) { + return ( + /*status*/ + c[4] === "pending" ? 0 : ( + /*status*/ + c[4] === "error" ? 1 : -1 + ) + ); + } + return ~(t = l(i)) && (n = o[t] = a[t](i)), { + c() { + e = yn("div"), n && n.c(), un(e, "class", r = "wrap " + /*variant*/ + i[8] + " " + /*show_progress*/ + i[6] + " svelte-1txqlrd"), Gt(e, "hide", !/*status*/ + i[4] || /*status*/ + i[4] === "complete" || /*show_progress*/ + i[6] === "hidden"), Gt( + e, + "translucent", + /*variant*/ + i[8] === "center" && /*status*/ + (i[4] === "pending" || /*status*/ + i[4] === "error") || /*translucent*/ + i[11] || /*show_progress*/ + i[6] === "minimal" + ), Gt( + e, + "generating", + /*status*/ + i[4] === "generating" + ), Gt( + e, + "border", + /*border*/ + i[12] + ), On( + e, + "position", + /*absolute*/ + i[10] ? "absolute" : "static" + ), On( + e, + "padding", + /*absolute*/ + i[10] ? "0" : "var(--size-8) 0" + ); + }, + m(c, u) { + He(c, e, u), ~t && o[t].m(e, null), i[31](e), s = !0; + }, + p(c, u) { + let f = t; + t = l(c), t === f ? ~t && o[t].p(c, u) : (n && (Mc(), ji(o[f], 1, 1, () => { + o[f] = null; + }), xc()), ~t ? (n = o[t], n ? n.p(c, u) : (n = o[t] = a[t](c), n.c()), Yi(n, 1), n.m(e, null)) : n = null), (!s || u[0] & /*variant, show_progress*/ + 320 && r !== (r = "wrap " + /*variant*/ + c[8] + " " + /*show_progress*/ + c[6] + " svelte-1txqlrd")) && un(e, "class", r), (!s || u[0] & /*variant, show_progress, status, show_progress*/ + 336) && Gt(e, "hide", !/*status*/ + c[4] || /*status*/ + c[4] === "complete" || /*show_progress*/ + c[6] === "hidden"), (!s || u[0] & /*variant, show_progress, variant, status, translucent, show_progress*/ + 2384) && Gt( + e, + "translucent", + /*variant*/ + c[8] === "center" && /*status*/ + (c[4] === "pending" || /*status*/ + c[4] === "error") || /*translucent*/ + c[11] || /*show_progress*/ + c[6] === "minimal" + ), (!s || u[0] & /*variant, show_progress, status*/ + 336) && Gt( + e, + "generating", + /*status*/ + c[4] === "generating" + ), (!s || u[0] & /*variant, show_progress, border*/ + 4416) && Gt( + e, + "border", + /*border*/ + c[12] + ), u[0] & /*absolute*/ + 1024 && On( + e, + "position", + /*absolute*/ + c[10] ? "absolute" : "static" + ), u[0] & /*absolute*/ + 1024 && On( + e, + "padding", + /*absolute*/ + c[10] ? "0" : "var(--size-8) 0" + ); + }, + i(c) { + s || (Yi(n), s = !0); + }, + o(c) { + ji(n), s = !1; + }, + d(c) { + c && Ge(e), ~t && o[t].d(), i[31](null); + } + }; +} +let Hr = [], $s = !1; +async function I0(i, e = !0) { + if (!(window.__gradio_mode__ === "website" || window.__gradio_mode__ !== "app" && e !== !0)) { + if (Hr.push(i), !$s) + $s = !0; + else + return; + await x0(), requestAnimationFrame(() => { + let t = [0, 0]; + for (let n = 0; n < Hr.length; n++) { + const s = Hr[n].getBoundingClientRect(); + (n === 0 || s.top + window.scrollY <= t[0]) && (t[0] = s.top + window.scrollY, t[1] = n); + } + window.scrollTo({ top: t[0] - 20, behavior: "smooth" }), $s = !1, Hr = []; + }); + } +} +function U0(i, e, t) { + let n, { $$slots: r = {}, $$scope: s } = e, { i18n: a } = e, { eta: o = null } = e, { queue_position: l } = e, { queue_size: c } = e, { status: u } = e, { scroll_to_output: f = !1 } = e, { timer: h = !0 } = e, { show_progress: p = "full" } = e, { message: g = null } = e, { progress: v = null } = e, { variant: m = "default" } = e, { loading_text: d = "Loading..." } = e, { absolute: M = !0 } = e, { translucent: _ = !1 } = e, { border: A = !1 } = e, { autoscroll: C } = e, E, b = !1, I = 0, W = 0, S = null, T = null, Y = 0, K = null, L, N = null, O = !0; + const B = () => { + t(0, o = t(26, S = t(19, J = null))), t(24, I = performance.now()), t(25, W = 0), b = !0, j(); + }; + function j() { + requestAnimationFrame(() => { + t(25, W = (performance.now() - I) / 1e3), b && j(); + }); + } + function q() { + t(25, W = 0), t(0, o = t(26, S = t(19, J = null))), b && (b = !1); + } + S0(() => { + b && q(); + }); + let J = null; + function ne(Z) { + vl[Z ? "unshift" : "push"](() => { + N = Z, t(16, N), t(7, v), t(14, K), t(15, L); + }); + } + function ue(Z) { + vl[Z ? "unshift" : "push"](() => { + E = Z, t(13, E); + }); + } + return i.$$set = (Z) => { + "i18n" in Z && t(1, a = Z.i18n), "eta" in Z && t(0, o = Z.eta), "queue_position" in Z && t(2, l = Z.queue_position), "queue_size" in Z && t(3, c = Z.queue_size), "status" in Z && t(4, u = Z.status), "scroll_to_output" in Z && t(21, f = Z.scroll_to_output), "timer" in Z && t(5, h = Z.timer), "show_progress" in Z && t(6, p = Z.show_progress), "message" in Z && t(22, g = Z.message), "progress" in Z && t(7, v = Z.progress), "variant" in Z && t(8, m = Z.variant), "loading_text" in Z && t(9, d = Z.loading_text), "absolute" in Z && t(10, M = Z.absolute), "translucent" in Z && t(11, _ = Z.translucent), "border" in Z && t(12, A = Z.border), "autoscroll" in Z && t(23, C = Z.autoscroll), "$$scope" in Z && t(28, s = Z.$$scope); + }, i.$$.update = () => { + i.$$.dirty[0] & /*eta, old_eta, timer_start, eta_from_start*/ + 218103809 && (o === null && t(0, o = S), o != null && S !== o && (t(27, T = (performance.now() - I) / 1e3 + o), t(19, J = T.toFixed(1)), t(26, S = o))), i.$$.dirty[0] & /*eta_from_start, timer_diff*/ + 167772160 && t(17, Y = T === null || T <= 0 || !W ? null : Math.min(W / T, 1)), i.$$.dirty[0] & /*progress*/ + 128 && v != null && t(18, O = !1), i.$$.dirty[0] & /*progress, progress_level, progress_bar, last_progress_level*/ + 114816 && (v != null ? t(14, K = v.map((Z) => { + if (Z.index != null && Z.length != null) + return Z.index / Z.length; + if (Z.progress != null) + return Z.progress; + })) : t(14, K = null), K ? (t(15, L = K[K.length - 1]), N && (L === 0 ? t(16, N.style.transition = "0", N) : t(16, N.style.transition = "150ms", N))) : t(15, L = void 0)), i.$$.dirty[0] & /*status*/ + 16 && (u === "pending" ? B() : q()), i.$$.dirty[0] & /*el, scroll_to_output, status, autoscroll*/ + 10493968 && E && f && (u === "pending" || u === "complete") && I0(E, C), i.$$.dirty[0] & /*status, message*/ + 4194320, i.$$.dirty[0] & /*timer_diff*/ + 33554432 && t(20, n = W.toFixed(1)); + }, [ + o, + a, + l, + c, + u, + h, + p, + v, + m, + d, + M, + _, + A, + E, + K, + L, + N, + Y, + O, + J, + n, + f, + g, + C, + I, + W, + S, + T, + s, + r, + ne, + ue + ]; +} +class F0 extends c0 { + constructor(e) { + super(), m0( + this, + e, + U0, + D0, + _0, + { + i18n: 1, + eta: 0, + queue_position: 2, + queue_size: 3, + status: 4, + scroll_to_output: 21, + timer: 5, + show_progress: 6, + message: 22, + progress: 7, + variant: 8, + loading_text: 9, + absolute: 10, + translucent: 11, + border: 12, + autoscroll: 23 + }, + null, + [-1, -1] + ); + } +} +const { + SvelteComponent: N0, + append: B0, + attr: O0, + detach: z0, + element: k0, + init: G0, + insert: H0, + noop: Il, + safe_not_equal: V0, + set_data: W0, + text: X0, + toggle_class: Li +} = window.__gradio__svelte__internal; +function q0(i) { + let e, t; + return { + c() { + e = k0("div"), t = X0( + /*value*/ + i[0] + ), O0(e, "class", "svelte-1gecy8w"), Li( + e, + "table", + /*type*/ + i[1] === "table" + ), Li( + e, + "gallery", + /*type*/ + i[1] === "gallery" + ), Li( + e, + "selected", + /*selected*/ + i[2] + ); + }, + m(n, r) { + H0(n, e, r), B0(e, t); + }, + p(n, [r]) { + r & /*value*/ + 1 && W0( + t, + /*value*/ + n[0] + ), r & /*type*/ + 2 && Li( + e, + "table", + /*type*/ + n[1] === "table" + ), r & /*type*/ + 2 && Li( + e, + "gallery", + /*type*/ + n[1] === "gallery" + ), r & /*selected*/ + 4 && Li( + e, + "selected", + /*selected*/ + n[2] + ); + }, + i: Il, + o: Il, + d(n) { + n && z0(e); + } + }; +} +function Y0(i, e, t) { + let { value: n } = e, { type: r } = e, { selected: s = !1 } = e; + return i.$$set = (a) => { + "value" in a && t(0, n = a.value), "type" in a && t(1, r = a.type), "selected" in a && t(2, s = a.selected); + }, [n, r, s]; +} +class pv extends N0 { + constructor(e) { + super(), G0(this, e, Y0, q0, V0, { value: 0, type: 1, selected: 2 }); + } +} +const { + SvelteComponent: j0, + add_flush_callback: K0, + assign: Q0, + bind: Z0, + binding_callbacks: J0, + check_outros: $0, + create_component: ai, + destroy_component: li, + detach: ns, + empty: ev, + get_spread_object: tv, + get_spread_update: nv, + group_outros: iv, + init: rv, + insert: is, + mount_component: ci, + safe_not_equal: sv, + space: Ao, + transition_in: An, + transition_out: En +} = window.__gradio__svelte__internal; +function ov(i) { + let e, t, n, r; + return e = new uo({ + props: { + show_label: ( + /*show_label*/ + i[8] + ), + Icon: rs, + label: ( + /*label*/ + i[7] || "Splat" + ) + } + }), n = new Eu({ + props: { + unpadded_box: !0, + size: "large", + $$slots: { default: [lv] }, + $$scope: { ctx: i } + } + }), { + c() { + ai(e.$$.fragment), t = Ao(), ai(n.$$.fragment); + }, + m(s, a) { + ci(e, s, a), is(s, t, a), ci(n, s, a), r = !0; + }, + p(s, a) { + const o = {}; + a & /*show_label*/ + 256 && (o.show_label = /*show_label*/ + s[8]), a & /*label*/ + 128 && (o.label = /*label*/ + s[7] || "Splat"), e.$set(o); + const l = {}; + a & /*$$scope*/ + 32768 && (l.$$scope = { dirty: a, ctx: s }), n.$set(l); + }, + i(s) { + r || (An(e.$$.fragment, s), An(n.$$.fragment, s), r = !0); + }, + o(s) { + En(e.$$.fragment, s), En(n.$$.fragment, s), r = !1; + }, + d(s) { + s && ns(t), li(e, s), li(n, s); + } + }; +} +function av(i) { + let e, t, n, r, s; + e = new uo({ + props: { + show_label: ( + /*show_label*/ + i[8] + ), + Icon: rs, + label: ( + /*label*/ + i[7] || "Splat" + ) + } + }); + function a(l) { + i[14](l); + } + let o = { + i18n: ( + /*gradio*/ + i[12].i18n + ), + label: ( + /*label*/ + i[7] + ), + show_label: ( + /*show_label*/ + i[8] + ), + root: ( + /*root*/ + i[4] + ), + proxy_url: ( + /*proxy_url*/ + i[5] + ) + }; + return ( + /*value*/ + i[0] !== void 0 && (o.value = /*value*/ + i[0]), n = new K_({ props: o }), J0.push(() => Z0(n, "value", a)), { + c() { + ai(e.$$.fragment), t = Ao(), ai(n.$$.fragment); + }, + m(l, c) { + ci(e, l, c), is(l, t, c), ci(n, l, c), s = !0; + }, + p(l, c) { + const u = {}; + c & /*show_label*/ + 256 && (u.show_label = /*show_label*/ + l[8]), c & /*label*/ + 128 && (u.label = /*label*/ + l[7] || "Splat"), e.$set(u); + const f = {}; + c & /*gradio*/ + 4096 && (f.i18n = /*gradio*/ + l[12].i18n), c & /*label*/ + 128 && (f.label = /*label*/ + l[7]), c & /*show_label*/ + 256 && (f.show_label = /*show_label*/ + l[8]), c & /*root*/ + 16 && (f.root = /*root*/ + l[4]), c & /*proxy_url*/ + 32 && (f.proxy_url = /*proxy_url*/ + l[5]), !r && c & /*value*/ + 1 && (r = !0, f.value = /*value*/ + l[0], K0(() => r = !1)), n.$set(f); + }, + i(l) { + s || (An(e.$$.fragment, l), An(n.$$.fragment, l), s = !0); + }, + o(l) { + En(e.$$.fragment, l), En(n.$$.fragment, l), s = !1; + }, + d(l) { + l && ns(t), li(e, l), li(n, l); + } + } + ); +} +function lv(i) { + let e, t; + return e = new rs({}), { + c() { + ai(e.$$.fragment); + }, + m(n, r) { + ci(e, n, r), t = !0; + }, + i(n) { + t || (An(e.$$.fragment, n), t = !0); + }, + o(n) { + En(e.$$.fragment, n), t = !1; + }, + d(n) { + li(e, n); + } + }; +} +function cv(i) { + let e, t, n, r, s, a; + const o = [ + { + autoscroll: ( + /*gradio*/ + i[12].autoscroll + ) + }, + { i18n: ( + /*gradio*/ + i[12].i18n + ) }, + /*loading_status*/ + i[6] + ]; + let l = {}; + for (let h = 0; h < o.length; h += 1) + l = Q0(l, o[h]); + e = new F0({ props: l }); + const c = [av, ov], u = []; + function f(h, p) { + return ( + /*value*/ + h[0] ? 0 : 1 + ); + } + return n = f(i), r = u[n] = c[n](i), { + c() { + ai(e.$$.fragment), t = Ao(), r.c(), s = ev(); + }, + m(h, p) { + ci(e, h, p), is(h, t, p), u[n].m(h, p), is(h, s, p), a = !0; + }, + p(h, p) { + const g = p & /*gradio, loading_status*/ + 4160 ? nv(o, [ + p & /*gradio*/ + 4096 && { + autoscroll: ( + /*gradio*/ + h[12].autoscroll + ) + }, + p & /*gradio*/ + 4096 && { i18n: ( + /*gradio*/ + h[12].i18n + ) }, + p & /*loading_status*/ + 64 && tv( + /*loading_status*/ + h[6] + ) + ]) : {}; + e.$set(g); + let v = n; + n = f(h), n === v ? u[n].p(h, p) : (iv(), En(u[v], 1, 1, () => { + u[v] = null; + }), $0(), r = u[n], r ? r.p(h, p) : (r = u[n] = c[n](h), r.c()), An(r, 1), r.m(s.parentNode, s)); + }, + i(h) { + a || (An(e.$$.fragment, h), An(r), a = !0); + }, + o(h) { + En(e.$$.fragment, h), En(r), a = !1; + }, + d(h) { + h && (ns(t), ns(s)), li(e, h), u[n].d(h); + } + }; +} +function uv(i) { + let e, t; + return e = new qc({ + props: { + visible: ( + /*visible*/ + i[3] + ), + variant: ( + /*value*/ + i[0] === null ? "dashed" : "solid" + ), + border_mode: "base", + padding: !1, + elem_id: ( + /*elem_id*/ + i[1] + ), + elem_classes: ( + /*elem_classes*/ + i[2] + ), + container: ( + /*container*/ + i[9] + ), + scale: ( + /*scale*/ + i[10] + ), + min_width: ( + /*min_width*/ + i[11] + ), + height: ( + /*height*/ + i[13] + ), + $$slots: { default: [cv] }, + $$scope: { ctx: i } + } + }), { + c() { + ai(e.$$.fragment); + }, + m(n, r) { + ci(e, n, r), t = !0; + }, + p(n, [r]) { + const s = {}; + r & /*visible*/ + 8 && (s.visible = /*visible*/ + n[3]), r & /*value*/ + 1 && (s.variant = /*value*/ + n[0] === null ? "dashed" : "solid"), r & /*elem_id*/ + 2 && (s.elem_id = /*elem_id*/ + n[1]), r & /*elem_classes*/ + 4 && (s.elem_classes = /*elem_classes*/ + n[2]), r & /*container*/ + 512 && (s.container = /*container*/ + n[9]), r & /*scale*/ + 1024 && (s.scale = /*scale*/ + n[10]), r & /*min_width*/ + 2048 && (s.min_width = /*min_width*/ + n[11]), r & /*height*/ + 8192 && (s.height = /*height*/ + n[13]), r & /*$$scope, gradio, label, show_label, root, proxy_url, value, loading_status*/ + 37361 && (s.$$scope = { dirty: r, ctx: n }), e.$set(s); + }, + i(n) { + t || (An(e.$$.fragment, n), t = !0); + }, + o(n) { + En(e.$$.fragment, n), t = !1; + }, + d(n) { + li(e, n); + } + }; +} +function fv(i, e, t) { + let { elem_id: n = "" } = e, { elem_classes: r = [] } = e, { visible: s = !0 } = e, { value: a = null } = e, { root: o } = e, { proxy_url: l } = e, { loading_status: c } = e, { label: u } = e, { show_label: f } = e, { container: h = !0 } = e, { scale: p = null } = e, { min_width: g = void 0 } = e, { gradio: v } = e, { height: m = void 0 } = e; + function d(M) { + a = M, t(0, a); + } + return i.$$set = (M) => { + "elem_id" in M && t(1, n = M.elem_id), "elem_classes" in M && t(2, r = M.elem_classes), "visible" in M && t(3, s = M.visible), "value" in M && t(0, a = M.value), "root" in M && t(4, o = M.root), "proxy_url" in M && t(5, l = M.proxy_url), "loading_status" in M && t(6, c = M.loading_status), "label" in M && t(7, u = M.label), "show_label" in M && t(8, f = M.show_label), "container" in M && t(9, h = M.container), "scale" in M && t(10, p = M.scale), "min_width" in M && t(11, g = M.min_width), "gradio" in M && t(12, v = M.gradio), "height" in M && t(13, m = M.height); + }, [ + a, + n, + r, + s, + o, + l, + c, + u, + f, + h, + p, + g, + v, + m, + d + ]; +} +class mv extends j0 { + constructor(e) { + super(), rv(this, e, fv, uv, sv, { + elem_id: 1, + elem_classes: 2, + visible: 3, + value: 0, + root: 4, + proxy_url: 5, + loading_status: 6, + label: 7, + show_label: 8, + container: 9, + scale: 10, + min_width: 11, + gradio: 12, + height: 13 + }); + } +} +export { + pv as BaseExample, + K_ as BaseModel4DGS, + mv as default +};