UNPKG

vitessce

Version:

This package is the main `vitessce` package on NPM. It exports the `<Vitessce/>` from `@vitessce/all` for backwards compatibility.

1,317 lines 235 kB
import { G as Ge, M as J, T as di, a as vn, b as Bs, R as Ds, L as hi, c as Xe, F as Os, d as Re, V as k, C as Ue, S as pi, P as mi, D as gi, e as L, I as xi, Q as Fs, O as Fn, f as yi, g as vi, B as _t, h as Ai, i as Us, N as _i, j as Ti, k as wi, l as Wt, m as Si, n as An, o as bi, p as Ei, q as Mi, r as Jt, s as Li, t as Un, u as zs, v as ke, w as Ci, x as js, y as Pi, z as ze, A as Ri, E as Ii, H as Ni, J as Bi, K as Di, U as Hs, W as Oi, X as Fi, Y as Ui, Z as ks, _ as zi, $ as ji, a0 as Ve, a1 as qn, a2 as Hi, a3 as Kn, a4 as ki, a5 as at, a6 as Vi, a7 as Y, a8 as ct, a9 as Gi, aa as Wn, ab as _n, ac as Xi, ad as qi, ae as Tn, af as $n, ag as bt, ah as Ee, ai as Ki, aj as St, ak as Vs, al as vt, am as Gs, an as Wi, ao as N, ap as $i, aq as ue, ar as Yi, as as Zi, at as Qi, au as Ji, av as eo } from "./index-CiwyZ_Wn.js"; import * as C from "react"; import { useRef as Fe, useEffect as qt, useState as oe, forwardRef as to } from "react"; import { u as Ce, a as lt, c as Xs, e as qs, b as wn, O as no, C as so } from "./OrbitControls-gS0qAcAF.js"; const io = (r) => typeof r == "object" && typeof r.then == "function", Mt = []; function oo(r, e, t = (s, n) => s === n) { if (r === e) return !0; if (!r || !e) return !1; const s = r.length; if (e.length !== s) return !1; for (let n = 0; n < s; n++) if (!t(r[n], e[n])) return !1; return !0; } function ro(r, e = null, t = !1, s = {}) { e === null && (e = [r]); for (const i of Mt) if (oo(e, i.keys, i.equal)) { if (t) return; if (Object.prototype.hasOwnProperty.call(i, "error")) throw i.error; if (Object.prototype.hasOwnProperty.call(i, "response")) return s.lifespan && s.lifespan > 0 && (i.timeout && clearTimeout(i.timeout), i.timeout = setTimeout(i.remove, s.lifespan)), i.response; if (!t) throw i.promise; } const n = { keys: e, equal: s.equal, remove: () => { const i = Mt.indexOf(n); i !== -1 && Mt.splice(i, 1); }, promise: ( // Execute the promise (io(r) ? r : r(...e)).then((i) => { n.response = i, s.lifespan && s.lifespan > 0 && (n.timeout = setTimeout(n.remove, s.lifespan)); }).catch((i) => n.error = i) ) }; if (Mt.push(n), !t) throw n.promise; } const Yn = (r, e, t) => ro(r, e, !1, t); class ao extends Ge { constructor(e, t) { super(), this.inputSource = null, this.xrControllerModel = null, this.index = e, this.controller = t.xr.getController(e), this.grip = t.xr.getControllerGrip(e), this.hand = t.xr.getHand(e), this.grip.userData.name = "grip", this.controller.userData.name = "controller", this.hand.userData.name = "hand", this.visible = !1, this.add(this.controller, this.grip, this.hand), this._onConnected = this._onConnected.bind(this), this._onDisconnected = this._onDisconnected.bind(this), this.controller.addEventListener("connected", this._onConnected), this.controller.addEventListener("disconnected", this._onDisconnected); } _onConnected(e) { e.fake || e.data && (this.visible = !0, this.inputSource = e.data, this.dispatchEvent(e)); } _onDisconnected(e) { e.fake || (this.visible = !1, this.inputSource = null, this.dispatchEvent(e)); } dispose() { this.controller.removeEventListener("connected", this._onConnected), this.controller.removeEventListener("disconnected", this._onDisconnected); } } var Zn, Qn; const co = (r) => Array.from(new Set(r)), de = typeof window < "u" && ((Zn = window.document) != null && Zn.createElement || ((Qn = window.navigator) == null ? void 0 : Qn.product) === "ReactNative") ? C.useLayoutEffect : C.useEffect; function be(r) { const e = C.useRef(r); return de(() => void (e.current = r), [r]), e; } function We(r, e, { handedness: t } = {}) { const s = be(e), n = q((i) => i.controllers); de(() => { const i = n.map((o) => { if (t && o.inputSource && o.inputSource.handedness !== t) return; const c = (a) => s.current({ nativeEvent: a, target: o }); return o.controller.addEventListener(r, c), () => o.controller.removeEventListener(r, c); }); return () => i.forEach((o) => o?.()); }, [n, t, r]); } const Jn = new J(); function lo({ children: r }) { const e = Ce((f) => f.events), t = Ce((f) => f.get), s = Ce((f) => f.raycaster), n = q((f) => f.controllers), i = q((f) => f.interactions), o = q((f) => f.hoverState), c = q((f) => f.hasInteraction), a = q((f) => f.getInteraction), l = C.useCallback( (f) => { const d = Array.from(i.keys()); return Jn.identity().extractRotation(f.matrixWorld), s.ray.origin.setFromMatrixPosition(f.matrixWorld), s.ray.direction.set(0, 0, -1).applyMatrix4(Jn), s.intersectObjects(d, !0); }, [i, s] ); lt(() => { var f; if (i.size !== 0) for (const d of n) { if (!((f = d.inputSource) != null && f.handedness)) return; const h = o[d.inputSource.handedness], y = /* @__PURE__ */ new Set(); let A = l(d.controller); if (e.filter) A = e.filter(A, t()); else { const x = A.find((p) => p?.object); x && (A = [x]); } for (const x of A) { let p = x.object; for (; p; ) { if (c(p, "onHover") && !h.has(p)) { const g = a(p, "onHover"); for (const v of g) v({ target: d, intersection: x, intersections: A }); } const m = a(p, "onMove"); m?.forEach((g) => g({ target: d, intersection: x, intersections: A })), h.set(p, x), y.add(p.id), p = p.parent; } } for (const x of h.keys()) if (!y.has(x.id)) { h.delete(x); const p = a(x, "onBlur"); if (!p) continue; for (const m of p) m({ target: d, intersections: A }); } } }); const u = C.useCallback( (f) => (d) => { var h; if (!((h = d.target.inputSource) != null && h.handedness)) return; const y = o[d.target.inputSource.handedness], A = Array.from(new Set(y.values())); i.forEach((x, p) => { var m, g, v; if (y.has(p)) { if (!x[f]) return; for (const _ of x[f]) (m = _.current) == null || m.call(_, { target: d.target, intersection: y.get(p), intersections: A }); } else if (f === "onSelect" && x.onSelectMissed) for (const _ of x.onSelectMissed) (g = _.current) == null || g.call(_, { target: d.target, intersections: A }); else if (f === "onSqueeze" && x.onSqueezeMissed) for (const _ of x.onSqueezeMissed) (v = _.current) == null || v.call(_, { target: d.target, intersections: A }); }); }, [o, i] ); return We("select", u("onSelect")), We("selectstart", u("onSelectStart")), We("selectend", u("onSelectEnd")), We("squeeze", u("onSqueeze")), We("squeezeend", u("onSqueezeEnd")), We("squeezestart", u("onSqueezeStart")), /* @__PURE__ */ C.createElement(C.Fragment, null, r); } function xe(r, e, t) { const s = q((o) => o.addInteraction), n = q((o) => o.removeInteraction), i = be(t); de(() => { const o = r.current; if (!(!o || !i.current)) return s(o, e, i), () => n(o, e, i); }, [r, e, s, n]); } const uo = C.forwardRef(function({ onHover: e, onBlur: t, onSelectStart: s, onSelectEnd: n, onSelectMissed: i, onSelect: o, onSqueezeStart: c, onSqueezeEnd: a, onSqueezeMissed: l, onSqueeze: u, onMove: f, children: d }, h) { const y = C.useRef(null); return C.useImperativeHandle(h, () => y.current), xe(y, "onHover", e), xe(y, "onBlur", t), xe(y, "onSelectStart", s), xe(y, "onSelectEnd", n), xe(y, "onSelectMissed", i), xe(y, "onSelect", o), xe(y, "onSqueezeStart", c), xe(y, "onSqueezeEnd", a), xe(y, "onSqueezeMissed", l), xe(y, "onSqueeze", u), xe(y, "onMove", f), /* @__PURE__ */ C.createElement("group", { ref: y }, d); }), fo = C.forwardRef(function({ onSelectStart: e, onSelectEnd: t, children: s, ...n }, i) { const o = C.useRef(), c = C.useRef(null), a = C.useMemo(() => new J(), []); return C.useImperativeHandle(i, () => c.current), lt(() => { const l = o.current, u = c.current; l && (u.applyMatrix4(a), u.applyMatrix4(l.matrixWorld), u.updateMatrixWorld(), a.copy(l.matrixWorld).invert()); }), /* @__PURE__ */ C.createElement(uo, { ref: c, onSelectStart: (l) => { o.current = l.target.controller, a.copy(l.target.controller.matrixWorld).invert(), e?.(l); }, onSelectEnd: (l) => { l.target.controller === o.current && (o.current = void 0), t?.(l); }, ...n }, s); }), Ks = C.createContext(null), qe = Xs((r, e) => ({ set: r, get: e, session: null, referenceSpaceType: null })); function ho({ foveation: r = 0, frameRate: e = void 0, referenceSpace: t = "local-floor", onSessionStart: s, onSessionEnd: n, onVisibilityChange: i, onInputSourcesChange: o, children: c }) { const a = Ce((g) => g.gl), l = Ce((g) => g.camera), u = q((g) => g.player), f = q((g) => g.get), d = q((g) => g.set), h = q((g) => g.session), y = q((g) => g.controllers), A = be(s), x = be(n), p = be(i), m = be(o); return de(() => { const g = [0, 1].map((v) => { const _ = new ao(v, a), w = () => d((S) => ({ controllers: [...S.controllers, _] })), T = () => d((S) => ({ controllers: S.controllers.filter((b) => b !== _) })); return _.addEventListener("connected", w), _.addEventListener("disconnected", T), () => { _.removeEventListener("connected", w), _.removeEventListener("disconnected", T); }; }); return () => g.forEach((v) => v()); }, [a, d]), de(() => qe.subscribe(({ session: g }) => d(() => ({ session: g }))), [a.xr, d]), de(() => { a.xr.setFoveation(r), d(() => ({ foveation: r })); }, [a.xr, r, d]), de(() => { var g; try { e && ((g = h?.updateTargetFrameRate) == null || g.call(h, e)); } catch { } d(() => ({ frameRate: e })); }, [h, e, d]), de(() => { const g = qe.getState(); a.xr.setReferenceSpaceType(t), d(() => ({ referenceSpace: t })), g.set({ referenceSpaceType: t }); }, [a.xr, t, d]), de(() => { if (!h) return void a.xr.setSession(null); const g = (T) => { var S; d(() => ({ isPresenting: !0 })), (S = A.current) == null || S.call(A, { nativeEvent: { ...T, target: h }, target: h }); }, v = (T) => { var S; d(() => ({ isPresenting: !1, session: null })), qe.setState(() => ({ session: null })), (S = x.current) == null || S.call(x, { nativeEvent: { ...T, target: h }, target: h }); }, _ = (T) => { var S; (S = p.current) == null || S.call(p, { nativeEvent: T, target: h }); }, w = (T) => { var S; const b = Object.values(h.inputSources).some((E) => E.hand); d(() => ({ isHandTracking: b })), (S = m.current) == null || S.call(m, { nativeEvent: T, target: h }); }; return a.xr.addEventListener("sessionstart", g), a.xr.addEventListener("sessionend", v), h.addEventListener("visibilitychange", _), h.addEventListener("inputsourceschange", w), a.xr.setSession(h).then(() => { a.xr.setFoveation(f().foveation); }), () => { a.xr.removeEventListener("sessionstart", g), a.xr.removeEventListener("sessionend", v), h.removeEventListener("visibilitychange", _), h.removeEventListener("inputsourceschange", w); }; }, [h, a.xr, d, f]), /* @__PURE__ */ C.createElement(lo, null, /* @__PURE__ */ C.createElement("primitive", { object: u }, /* @__PURE__ */ C.createElement("primitive", { object: l }), y.map((g) => /* @__PURE__ */ C.createElement("primitive", { key: g.index, object: g }))), c); } function po(r) { const e = C.useMemo( () => Xs((t, s) => ({ set: t, get: s, controllers: [], isPresenting: !1, isHandTracking: !1, player: new Ge(), session: null, foveation: 0, referenceSpace: "local-floor", hoverState: { left: /* @__PURE__ */ new Map(), right: /* @__PURE__ */ new Map(), none: /* @__PURE__ */ new Map() }, interactions: /* @__PURE__ */ new Map(), hasInteraction(n, i) { var o; return !!((o = s().interactions.get(n)) != null && o[i].some((c) => c.current)); }, getInteraction(n, i) { var o; return (o = s().interactions.get(n)) == null ? void 0 : o[i].reduce((c, a) => (a.current && c.push(a.current), c), []); }, addInteraction(n, i, o) { const c = s().interactions; c.has(n) || c.set(n, { onHover: [], onBlur: [], onSelect: [], onSelectEnd: [], onSelectStart: [], onSelectMissed: [], onSqueeze: [], onSqueezeEnd: [], onSqueezeStart: [], onSqueezeMissed: [], onMove: [] }), c.get(n)[i].push(o); }, removeInteraction(n, i, o) { const c = s().interactions.get(n); if (c) { const a = c[i].indexOf(o); a !== -1 && c[i].splice(a, 1); } } })), [] ); return /* @__PURE__ */ C.createElement(Ks.Provider, { value: e }, /* @__PURE__ */ C.createElement(ho, { ...r })); } const mo = (r, e) => { var t; if (!(!r && !e)) return r && !e ? { optionalFeatures: [r] } : r && e ? { ...e, optionalFeatures: co([...(t = e.optionalFeatures) != null ? t : [], r]) } : e; }, go = async (r, e) => { const t = qe.getState(); if (t.session) { console.warn("@react-three/xr: session already started, please stop it first"); return; } const s = mo(t.referenceSpaceType, e), n = await navigator.xr.requestSession(r, s); return t.set(() => ({ session: n })), n; }, xo = async () => { const r = qe.getState(); if (!r.session) { console.warn("@react-three/xr: no session to stop, please start it first"); return; } await r.session.end(), r.set({ session: null }); }, yo = async (r, { sessionInit: e, enterOnly: t, exitOnly: s } = {}) => { const n = qe.getState(); if (!(n.session && t) && !(!n.session && s)) return n.session ? await xo() : await go(r, e); }, vo = (r, e, t) => { switch (r) { case "entered": return `Exit ${e}`; case "exited": return `Enter ${e}`; case "unsupported": default: switch (t) { case "https": return "HTTPS needed"; case "security": return `${e} blocked`; case "unknown": default: return `${e} unsupported`; } } }, zn = C.forwardRef(function({ mode: e, sessionInit: t, enterOnly: s = !1, exitOnly: n = !1, onClick: i, onError: o, children: c, ...a }, l) { var u; const [f, d] = C.useState("exited"), [h, y] = C.useState("unknown"), A = vo(f, e, h), x = e === "inline" ? e : `immersive-${e.toLowerCase()}`, p = be(o); de(() => { if (!navigator?.xr) return void d("unsupported"); navigator.xr.isSessionSupported(x).then((g) => { if (g) d("exited"); else { const v = location.protocol === "https:"; d("unsupported"), y(v ? "unknown" : "https"); } }).catch((g) => { d("unsupported"), "name" in g && g.name === "SecurityError" ? y("security") : y("unknown"); }); }, [x]), de( () => qe.subscribe((g) => { g.session ? d("entered") : f !== "unsupported" && d("exited"); }), [f] ); const m = C.useCallback( async (g) => { i?.(g); try { yo(x, { sessionInit: t, enterOnly: s, exitOnly: n }); } catch (v) { const _ = p.current; if (_ && v instanceof Error) _(v); else throw v; } }, [i, x, t, s, n, p] ); return /* @__PURE__ */ C.createElement("button", { ...a, ref: l, onClick: f === "unsupported" ? i : m }, (u = typeof c == "function" ? c(f) : c) != null ? u : A); }), Ws = { position: "absolute", bottom: "24px", left: "50%", transform: "translateX(-50%)", padding: "12px 24px", border: "1px solid white", borderRadius: "4px", background: "rgba(0, 0, 0, 0.1)", color: "white", font: "normal 0.8125rem sans-serif", outline: "none", zIndex: 99999, cursor: "pointer" }; C.forwardRef( ({ style: r = Ws, sessionInit: e = { domOverlay: typeof document < "u" ? { root: document.body } : void 0, optionalFeatures: ["hit-test", "dom-overlay", "dom-overlay-for-handheld-ar"] }, children: t, ...s }, n) => /* @__PURE__ */ C.createElement(zn, { ...s, ref: n, mode: "AR", style: r, sessionInit: e }, t) ); C.forwardRef( ({ style: r = Ws, sessionInit: e = { optionalFeatures: ["local-floor", "bounded-floor", "hand-tracking", "layers"] }, children: t, ...s }, n) => /* @__PURE__ */ C.createElement(zn, { ...s, ref: n, mode: "VR", style: r, sessionInit: e }, t) ); function q(r = (t) => t, e) { const t = C.useContext(Ks); if (!t) throw new Error("useXR must be used within an <XR /> component!"); return t(r, e); } function es(r, e) { if (e === di) return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), r; if (e === vn || e === Bs) { let t = r.getIndex(); if (t === null) { const o = [], c = r.getAttribute("position"); if (c !== void 0) { for (let a = 0; a < c.count; a++) o.push(a); r.setIndex(o), t = r.getIndex(); } else return console.error( "THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible." ), r; } const s = t.count - 2, n = []; if (t) if (e === vn) for (let o = 1; o <= s; o++) n.push(t.getX(0)), n.push(t.getX(o)), n.push(t.getX(o + 1)); else for (let o = 0; o < s; o++) o % 2 === 0 ? (n.push(t.getX(o)), n.push(t.getX(o + 1)), n.push(t.getX(o + 2))) : (n.push(t.getX(o + 2)), n.push(t.getX(o + 1)), n.push(t.getX(o))); n.length / 3 !== s && console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles."); const i = r.clone(); return i.setIndex(n), i.clearGroups(), i; } else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:", e), r; } const Ao = parseInt(Ds.replace(/\D+/g, "")); class $s extends hi { constructor(e) { super(e), this.dracoLoader = null, this.ktx2Loader = null, this.meshoptDecoder = null, this.pluginCallbacks = [], this.register(function(t) { return new bo(t); }), this.register(function(t) { return new No(t); }), this.register(function(t) { return new Bo(t); }), this.register(function(t) { return new Do(t); }), this.register(function(t) { return new Mo(t); }), this.register(function(t) { return new Lo(t); }), this.register(function(t) { return new Co(t); }), this.register(function(t) { return new Po(t); }), this.register(function(t) { return new So(t); }), this.register(function(t) { return new Ro(t); }), this.register(function(t) { return new Eo(t); }), this.register(function(t) { return new Io(t); }), this.register(function(t) { return new To(t); }), this.register(function(t) { return new Oo(t); }), this.register(function(t) { return new Fo(t); }); } load(e, t, s, n) { const i = this; let o; this.resourcePath !== "" ? o = this.resourcePath : this.path !== "" ? o = this.path : o = Xe.extractUrlBase(e), this.manager.itemStart(e); const c = function(l) { n ? n(l) : console.error(l), i.manager.itemError(e), i.manager.itemEnd(e); }, a = new Os(this.manager); a.setPath(this.path), a.setResponseType("arraybuffer"), a.setRequestHeader(this.requestHeader), a.setWithCredentials(this.withCredentials), a.load( e, function(l) { try { i.parse( l, o, function(u) { t(u), i.manager.itemEnd(e); }, c ); } catch (u) { c(u); } }, s, c ); } setDRACOLoader(e) { return this.dracoLoader = e, this; } setDDSLoader() { throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".'); } setKTX2Loader(e) { return this.ktx2Loader = e, this; } setMeshoptDecoder(e) { return this.meshoptDecoder = e, this; } register(e) { return this.pluginCallbacks.indexOf(e) === -1 && this.pluginCallbacks.push(e), this; } unregister(e) { return this.pluginCallbacks.indexOf(e) !== -1 && this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e), 1), this; } parse(e, t, s, n) { let i; const o = {}, c = {}; if (typeof e == "string") i = JSON.parse(e); else if (e instanceof ArrayBuffer) if (Xe.decodeText(new Uint8Array(e.slice(0, 4))) === Ys) { try { o[U.KHR_BINARY_GLTF] = new Uo(e); } catch (u) { n && n(u); return; } i = JSON.parse(o[U.KHR_BINARY_GLTF].content); } else i = JSON.parse(Xe.decodeText(new Uint8Array(e))); else i = e; if (i.asset === void 0 || i.asset.version[0] < 2) { n && n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")); return; } const a = new Zo(i, { path: t || this.resourcePath || "", crossOrigin: this.crossOrigin, requestHeader: this.requestHeader, manager: this.manager, ktx2Loader: this.ktx2Loader, meshoptDecoder: this.meshoptDecoder }); a.fileLoader.setRequestHeader(this.requestHeader); for (let l = 0; l < this.pluginCallbacks.length; l++) { const u = this.pluginCallbacks[l](a); c[u.name] = u, o[u.name] = !0; } if (i.extensionsUsed) for (let l = 0; l < i.extensionsUsed.length; ++l) { const u = i.extensionsUsed[l], f = i.extensionsRequired || []; switch (u) { case U.KHR_MATERIALS_UNLIT: o[u] = new wo(); break; case U.KHR_DRACO_MESH_COMPRESSION: o[u] = new zo(i, this.dracoLoader); break; case U.KHR_TEXTURE_TRANSFORM: o[u] = new jo(); break; case U.KHR_MESH_QUANTIZATION: o[u] = new Ho(); break; default: f.indexOf(u) >= 0 && c[u] === void 0 && console.warn('THREE.GLTFLoader: Unknown extension "' + u + '".'); } } a.setExtensions(o), a.setPlugins(c), a.parse(s, n); } parseAsync(e, t) { const s = this; return new Promise(function(n, i) { s.parse(e, t, n, i); }); } } function _o() { let r = {}; return { get: function(e) { return r[e]; }, add: function(e, t) { r[e] = t; }, remove: function(e) { delete r[e]; }, removeAll: function() { r = {}; } }; } const U = { KHR_BINARY_GLTF: "KHR_binary_glTF", KHR_DRACO_MESH_COMPRESSION: "KHR_draco_mesh_compression", KHR_LIGHTS_PUNCTUAL: "KHR_lights_punctual", KHR_MATERIALS_CLEARCOAT: "KHR_materials_clearcoat", KHR_MATERIALS_IOR: "KHR_materials_ior", KHR_MATERIALS_SHEEN: "KHR_materials_sheen", KHR_MATERIALS_SPECULAR: "KHR_materials_specular", KHR_MATERIALS_TRANSMISSION: "KHR_materials_transmission", KHR_MATERIALS_IRIDESCENCE: "KHR_materials_iridescence", KHR_MATERIALS_ANISOTROPY: "KHR_materials_anisotropy", KHR_MATERIALS_UNLIT: "KHR_materials_unlit", KHR_MATERIALS_VOLUME: "KHR_materials_volume", KHR_TEXTURE_BASISU: "KHR_texture_basisu", KHR_TEXTURE_TRANSFORM: "KHR_texture_transform", KHR_MESH_QUANTIZATION: "KHR_mesh_quantization", KHR_MATERIALS_EMISSIVE_STRENGTH: "KHR_materials_emissive_strength", EXT_TEXTURE_WEBP: "EXT_texture_webp", EXT_TEXTURE_AVIF: "EXT_texture_avif", EXT_MESHOPT_COMPRESSION: "EXT_meshopt_compression", EXT_MESH_GPU_INSTANCING: "EXT_mesh_gpu_instancing" }; class To { constructor(e) { this.parser = e, this.name = U.KHR_LIGHTS_PUNCTUAL, this.cache = { refs: {}, uses: {} }; } _markDefs() { const e = this.parser, t = this.parser.json.nodes || []; for (let s = 0, n = t.length; s < n; s++) { const i = t[s]; i.extensions && i.extensions[this.name] && i.extensions[this.name].light !== void 0 && e._addNodeRef(this.cache, i.extensions[this.name].light); } } _loadLight(e) { const t = this.parser, s = "light:" + e; let n = t.cache.get(s); if (n) return n; const i = t.json, a = ((i.extensions && i.extensions[this.name] || {}).lights || [])[e]; let l; const u = new Ue(16777215); a.color !== void 0 && u.fromArray(a.color); const f = a.range !== void 0 ? a.range : 0; switch (a.type) { case "directional": l = new gi(u), l.target.position.set(0, 0, -1), l.add(l.target); break; case "point": l = new mi(u), l.distance = f; break; case "spot": l = new pi(u), l.distance = f, a.spot = a.spot || {}, a.spot.innerConeAngle = a.spot.innerConeAngle !== void 0 ? a.spot.innerConeAngle : 0, a.spot.outerConeAngle = a.spot.outerConeAngle !== void 0 ? a.spot.outerConeAngle : Math.PI / 4, l.angle = a.spot.outerConeAngle, l.penumbra = 1 - a.spot.innerConeAngle / a.spot.outerConeAngle, l.target.position.set(0, 0, -1), l.add(l.target); break; default: throw new Error("THREE.GLTFLoader: Unexpected light type: " + a.type); } return l.position.set(0, 0, 0), l.decay = 2, Be(l, a), a.intensity !== void 0 && (l.intensity = a.intensity), l.name = t.createUniqueName(a.name || "light_" + e), n = Promise.resolve(l), t.cache.add(s, n), n; } getDependency(e, t) { if (e === "light") return this._loadLight(t); } createNodeAttachment(e) { const t = this, s = this.parser, i = s.json.nodes[e], c = (i.extensions && i.extensions[this.name] || {}).light; return c === void 0 ? null : this._loadLight(c).then(function(a) { return s._getNodeRef(t.cache, c, a); }); } } class wo { constructor() { this.name = U.KHR_MATERIALS_UNLIT; } getMaterialType() { return ke; } extendParams(e, t, s) { const n = []; e.color = new Ue(1, 1, 1), e.opacity = 1; const i = t.pbrMetallicRoughness; if (i) { if (Array.isArray(i.baseColorFactor)) { const o = i.baseColorFactor; e.color.fromArray(o), e.opacity = o[3]; } i.baseColorTexture !== void 0 && n.push(s.assignTexture(e, "map", i.baseColorTexture, 3001)); } return Promise.all(n); } } class So { constructor(e) { this.parser = e, this.name = U.KHR_MATERIALS_EMISSIVE_STRENGTH; } extendMaterialParams(e, t) { const n = this.parser.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return Promise.resolve(); const i = n.extensions[this.name].emissiveStrength; return i !== void 0 && (t.emissiveIntensity = i), Promise.resolve(); } } class bo { constructor(e) { this.parser = e, this.name = U.KHR_MATERIALS_CLEARCOAT; } getMaterialType(e) { const s = this.parser.json.materials[e]; return !s.extensions || !s.extensions[this.name] ? null : Re; } extendMaterialParams(e, t) { const s = this.parser, n = s.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return Promise.resolve(); const i = [], o = n.extensions[this.name]; if (o.clearcoatFactor !== void 0 && (t.clearcoat = o.clearcoatFactor), o.clearcoatTexture !== void 0 && i.push(s.assignTexture(t, "clearcoatMap", o.clearcoatTexture)), o.clearcoatRoughnessFactor !== void 0 && (t.clearcoatRoughness = o.clearcoatRoughnessFactor), o.clearcoatRoughnessTexture !== void 0 && i.push(s.assignTexture(t, "clearcoatRoughnessMap", o.clearcoatRoughnessTexture)), o.clearcoatNormalTexture !== void 0 && (i.push(s.assignTexture(t, "clearcoatNormalMap", o.clearcoatNormalTexture)), o.clearcoatNormalTexture.scale !== void 0)) { const c = o.clearcoatNormalTexture.scale; t.clearcoatNormalScale = new k(c, c); } return Promise.all(i); } } class Eo { constructor(e) { this.parser = e, this.name = U.KHR_MATERIALS_IRIDESCENCE; } getMaterialType(e) { const s = this.parser.json.materials[e]; return !s.extensions || !s.extensions[this.name] ? null : Re; } extendMaterialParams(e, t) { const s = this.parser, n = s.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return Promise.resolve(); const i = [], o = n.extensions[this.name]; return o.iridescenceFactor !== void 0 && (t.iridescence = o.iridescenceFactor), o.iridescenceTexture !== void 0 && i.push(s.assignTexture(t, "iridescenceMap", o.iridescenceTexture)), o.iridescenceIor !== void 0 && (t.iridescenceIOR = o.iridescenceIor), t.iridescenceThicknessRange === void 0 && (t.iridescenceThicknessRange = [100, 400]), o.iridescenceThicknessMinimum !== void 0 && (t.iridescenceThicknessRange[0] = o.iridescenceThicknessMinimum), o.iridescenceThicknessMaximum !== void 0 && (t.iridescenceThicknessRange[1] = o.iridescenceThicknessMaximum), o.iridescenceThicknessTexture !== void 0 && i.push( s.assignTexture(t, "iridescenceThicknessMap", o.iridescenceThicknessTexture) ), Promise.all(i); } } class Mo { constructor(e) { this.parser = e, this.name = U.KHR_MATERIALS_SHEEN; } getMaterialType(e) { const s = this.parser.json.materials[e]; return !s.extensions || !s.extensions[this.name] ? null : Re; } extendMaterialParams(e, t) { const s = this.parser, n = s.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return Promise.resolve(); const i = []; t.sheenColor = new Ue(0, 0, 0), t.sheenRoughness = 0, t.sheen = 1; const o = n.extensions[this.name]; return o.sheenColorFactor !== void 0 && t.sheenColor.fromArray(o.sheenColorFactor), o.sheenRoughnessFactor !== void 0 && (t.sheenRoughness = o.sheenRoughnessFactor), o.sheenColorTexture !== void 0 && i.push(s.assignTexture(t, "sheenColorMap", o.sheenColorTexture, 3001)), o.sheenRoughnessTexture !== void 0 && i.push(s.assignTexture(t, "sheenRoughnessMap", o.sheenRoughnessTexture)), Promise.all(i); } } class Lo { constructor(e) { this.parser = e, this.name = U.KHR_MATERIALS_TRANSMISSION; } getMaterialType(e) { const s = this.parser.json.materials[e]; return !s.extensions || !s.extensions[this.name] ? null : Re; } extendMaterialParams(e, t) { const s = this.parser, n = s.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return Promise.resolve(); const i = [], o = n.extensions[this.name]; return o.transmissionFactor !== void 0 && (t.transmission = o.transmissionFactor), o.transmissionTexture !== void 0 && i.push(s.assignTexture(t, "transmissionMap", o.transmissionTexture)), Promise.all(i); } } class Co { constructor(e) { this.parser = e, this.name = U.KHR_MATERIALS_VOLUME; } getMaterialType(e) { const s = this.parser.json.materials[e]; return !s.extensions || !s.extensions[this.name] ? null : Re; } extendMaterialParams(e, t) { const s = this.parser, n = s.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return Promise.resolve(); const i = [], o = n.extensions[this.name]; t.thickness = o.thicknessFactor !== void 0 ? o.thicknessFactor : 0, o.thicknessTexture !== void 0 && i.push(s.assignTexture(t, "thicknessMap", o.thicknessTexture)), t.attenuationDistance = o.attenuationDistance || 1 / 0; const c = o.attenuationColor || [1, 1, 1]; return t.attenuationColor = new Ue(c[0], c[1], c[2]), Promise.all(i); } } class Po { constructor(e) { this.parser = e, this.name = U.KHR_MATERIALS_IOR; } getMaterialType(e) { const s = this.parser.json.materials[e]; return !s.extensions || !s.extensions[this.name] ? null : Re; } extendMaterialParams(e, t) { const n = this.parser.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return Promise.resolve(); const i = n.extensions[this.name]; return t.ior = i.ior !== void 0 ? i.ior : 1.5, Promise.resolve(); } } class Ro { constructor(e) { this.parser = e, this.name = U.KHR_MATERIALS_SPECULAR; } getMaterialType(e) { const s = this.parser.json.materials[e]; return !s.extensions || !s.extensions[this.name] ? null : Re; } extendMaterialParams(e, t) { const s = this.parser, n = s.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return Promise.resolve(); const i = [], o = n.extensions[this.name]; t.specularIntensity = o.specularFactor !== void 0 ? o.specularFactor : 1, o.specularTexture !== void 0 && i.push(s.assignTexture(t, "specularIntensityMap", o.specularTexture)); const c = o.specularColorFactor || [1, 1, 1]; return t.specularColor = new Ue(c[0], c[1], c[2]), o.specularColorTexture !== void 0 && i.push( s.assignTexture(t, "specularColorMap", o.specularColorTexture, 3001) // sRGBEncoding ), Promise.all(i); } } class Io { constructor(e) { this.parser = e, this.name = U.KHR_MATERIALS_ANISOTROPY; } getMaterialType(e) { const s = this.parser.json.materials[e]; return !s.extensions || !s.extensions[this.name] ? null : Re; } extendMaterialParams(e, t) { const s = this.parser, n = s.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return Promise.resolve(); const i = [], o = n.extensions[this.name]; return o.anisotropyStrength !== void 0 && (t.anisotropy = o.anisotropyStrength), o.anisotropyRotation !== void 0 && (t.anisotropyRotation = o.anisotropyRotation), o.anisotropyTexture !== void 0 && i.push(s.assignTexture(t, "anisotropyMap", o.anisotropyTexture)), Promise.all(i); } } class No { constructor(e) { this.parser = e, this.name = U.KHR_TEXTURE_BASISU; } loadTexture(e) { const t = this.parser, s = t.json, n = s.textures[e]; if (!n.extensions || !n.extensions[this.name]) return null; const i = n.extensions[this.name], o = t.options.ktx2Loader; if (!o) { if (s.extensionsRequired && s.extensionsRequired.indexOf(this.name) >= 0) throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures"); return null; } return t.loadTextureImage(e, i.source, o); } } class Bo { constructor(e) { this.parser = e, this.name = U.EXT_TEXTURE_WEBP, this.isSupported = null; } loadTexture(e) { const t = this.name, s = this.parser, n = s.json, i = n.textures[e]; if (!i.extensions || !i.extensions[t]) return null; const o = i.extensions[t], c = n.images[o.source]; let a = s.textureLoader; if (c.uri) { const l = s.options.manager.getHandler(c.uri); l !== null && (a = l); } return this.detectSupport().then(function(l) { if (l) return s.loadTextureImage(e, o.source, a); if (n.extensionsRequired && n.extensionsRequired.indexOf(t) >= 0) throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported."); return s.loadTexture(e); }); } detectSupport() { return this.isSupported || (this.isSupported = new Promise(function(e) { const t = new Image(); t.src = "data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA", t.onload = t.onerror = function() { e(t.height === 1); }; })), this.isSupported; } } class Do { constructor(e) { this.parser = e, this.name = U.EXT_TEXTURE_AVIF, this.isSupported = null; } loadTexture(e) { const t = this.name, s = this.parser, n = s.json, i = n.textures[e]; if (!i.extensions || !i.extensions[t]) return null; const o = i.extensions[t], c = n.images[o.source]; let a = s.textureLoader; if (c.uri) { const l = s.options.manager.getHandler(c.uri); l !== null && (a = l); } return this.detectSupport().then(function(l) { if (l) return s.loadTextureImage(e, o.source, a); if (n.extensionsRequired && n.extensionsRequired.indexOf(t) >= 0) throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported."); return s.loadTexture(e); }); } detectSupport() { return this.isSupported || (this.isSupported = new Promise(function(e) { const t = new Image(); t.src = "data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=", t.onload = t.onerror = function() { e(t.height === 1); }; })), this.isSupported; } } class Oo { constructor(e) { this.name = U.EXT_MESHOPT_COMPRESSION, this.parser = e; } loadBufferView(e) { const t = this.parser.json, s = t.bufferViews[e]; if (s.extensions && s.extensions[this.name]) { const n = s.extensions[this.name], i = this.parser.getDependency("buffer", n.buffer), o = this.parser.options.meshoptDecoder; if (!o || !o.supported) { if (t.extensionsRequired && t.extensionsRequired.indexOf(this.name) >= 0) throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files"); return null; } return i.then(function(c) { const a = n.byteOffset || 0, l = n.byteLength || 0, u = n.count, f = n.byteStride, d = new Uint8Array(c, a, l); return o.decodeGltfBufferAsync ? o.decodeGltfBufferAsync(u, f, d, n.mode, n.filter).then(function(h) { return h.buffer; }) : o.ready.then(function() { const h = new ArrayBuffer(u * f); return o.decodeGltfBuffer( new Uint8Array(h), u, f, d, n.mode, n.filter ), h; }); }); } else return null; } } class Fo { constructor(e) { this.name = U.EXT_MESH_GPU_INSTANCING, this.parser = e; } createNodeMesh(e) { const t = this.parser.json, s = t.nodes[e]; if (!s.extensions || !s.extensions[this.name] || s.mesh === void 0) return null; const n = t.meshes[s.mesh]; for (const l of n.primitives) if (l.mode !== fe.TRIANGLES && l.mode !== fe.TRIANGLE_STRIP && l.mode !== fe.TRIANGLE_FAN && l.mode !== void 0) return null; const o = s.extensions[this.name].attributes, c = [], a = {}; for (const l in o) c.push( this.parser.getDependency("accessor", o[l]).then((u) => (a[l] = u, a[l])) ); return c.length < 1 ? null : (c.push(this.parser.createNodeMesh(e)), Promise.all(c).then((l) => { const u = l.pop(), f = u.isGroup ? u.children : [u], d = l[0].count, h = []; for (const y of f) { const A = new J(), x = new L(), p = new Fs(), m = new L(1, 1, 1), g = new xi(y.geometry, y.material, d); for (let v = 0; v < d; v++) a.TRANSLATION && x.fromBufferAttribute(a.TRANSLATION, v), a.ROTATION && p.fromBufferAttribute(a.ROTATION, v), a.SCALE && m.fromBufferAttribute(a.SCALE, v), g.setMatrixAt(v, A.compose(x, p, m)); for (const v in a) v !== "TRANSLATION" && v !== "ROTATION" && v !== "SCALE" && y.geometry.setAttribute(v, a[v]); Fn.prototype.copy.call(g, y), this.parser.assignFinalMaterial(g), h.push(g); } return u.isGroup ? (u.clear(), u.add(...h), u) : h[0]; })); } } const Ys = "glTF", dt = 12, ts = { JSON: 1313821514, BIN: 5130562 }; class Uo { constructor(e) { this.name = U.KHR_BINARY_GLTF, this.content = null, this.body = null; const t = new DataView(e, 0, dt); if (this.header = { magic: Xe.decodeText(new Uint8Array(e.slice(0, 4))), version: t.getUint32(4, !0), length: t.getUint32(8, !0) }, this.header.magic !== Ys) throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header."); if (this.header.version < 2) throw new Error("THREE.GLTFLoader: Legacy binary file detected."); const s = this.header.length - dt, n = new DataView(e, dt); let i = 0; for (; i < s; ) { const o = n.getUint32(i, !0); i += 4; const c = n.getUint32(i, !0); if (i += 4, c === ts.JSON) { const a = new Uint8Array(e, dt + i, o); this.content = Xe.decodeText(a); } else if (c === ts.BIN) { const a = dt + i; this.body = e.slice(a, a + o); } i += o; } if (this.content === null) throw new Error("THREE.GLTFLoader: JSON content not found."); } } class zo { constructor(e, t) { if (!t) throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided."); this.name = U.KHR_DRACO_MESH_COMPRESSION, this.json = e, this.dracoLoader = t, this.dracoLoader.preload(); } decodePrimitive(e, t) { const s = this.json, n = this.dracoLoader, i = e.extensions[this.name].bufferView, o = e.extensions[this.name].attributes, c = {}, a = {}, l = {}; for (const u in o) { const f = Sn[u] || u.toLowerCase(); c[f] = o[u]; } for (const u in e.attributes) { const f = Sn[u] || u.toLowerCase(); if (o[u] !== void 0) { const d = s.accessors[e.attributes[u]], h = rt[d.componentType]; l[f] = h.name, a[f] = d.normalized === !0; } } return t.getDependency("bufferView", i).then(function(u) { return new Promise(function(f) { n.decodeDracoFile( u, function(d) { for (const h in d.attributes) { const y = d.attributes[h], A = a[h]; A !== void 0 && (y.normalized = A); } f(d); }, c, l ); }); }); } } class jo { constructor() { this.name = U.KHR_TEXTURE_TRANSFORM; } extendTexture(e, t) { return (t.texCoord === void 0 || t.texCoord === e.channel) && t.offset === void 0 && t.rotation === void 0 && t.scale === void 0 || (e = e.clone(), t.texCoord !== void 0 && (e.channel = t.texCoord), t.offset !== void 0 && e.offset.fromArray(t.offset), t.rotation !== void 0 && (e.rotation = t.rotation), t.scale !== void 0 && e.repeat.fromArray(t.scale), e.needsUpdate = !0), e; } } class Ho { constructor() { this.name = U.KHR_MESH_QUANTIZATION; } } class Zs extends Vi { constructor(e, t, s, n) { super(e, t, s, n); } copySampleValue_(e) { const t = this.resultBuffer, s = this.sampleValues, n = this.valueSize, i = e * n * 3 + n; for (let o = 0; o !== n; o++) t[o] = s[i + o]; return t; } interpolate_(e, t, s, n) { const i = this.resultBuffer, o = this.sampleValues, c = this.valueSize, a = c * 2, l = c * 3, u = n - t, f = (s - t) / u, d = f * f, h = d * f, y = e * l, A = y - l, x = -2 * h + 3 * d, p = h - d, m = 1 - x, g = p - d + f; for (let v = 0; v !== c; v++) { const _ = o[A + v + c], w = o[A + v + a] * u, T = o[y + v + c], S = o[y + v] * u; i[v] = m * _ + g * w + x * T + p * S; } return i; } } const ko = new Fs(); class Vo extends Zs { interpolate_(e, t, s, n) { const i = super.interpolate_(e, t, s, n); return ko.fromArray(i).normalize().toArray(i), i; } } const fe = { POINTS: 0, LINES: 1, LINE_LOOP: 2, LINE_STRIP: 3, TRIANGLES: 4, TRIANGLE_STRIP: 5, TRIANGLE_FAN: 6 }, rt = { 5120: Int8Array, 5121: Uint8Array, 5122: Int16Array, 5123: Uint16Array, 5125: Uint32Array, 5126: Float32Array }, ns = { 9728: Si, 9729: Wt, 9984: wi, 9985: Ti, 9986: _i, 9987: Us }, ss = { 33071: Ei, 33648: bi, 10497: An }, en = { SCALAR: 1, VEC2: 2, VEC3: 3, VEC4: 4, MAT2: 4, MAT3: 9, MAT4: 16 }, Sn = { POSITION: "position", NORMAL: "normal", TANGENT: "tangent", // uv => uv1, 4 uv channels // https://github.com/mrdoob/three.js/pull/25943 // https://github.com/mrdoob/three.js/pull/25788 ...Ao >= 152 ? { TEXCOORD_0: "uv", TEXCOORD_1: "uv1", TEXCOORD_2: "uv2", TEXCOORD_3: "uv3" } : { TEXCOORD_0: "uv", TEXCOORD_1: "uv2" }, COLOR_0: "color", WEIGHTS_0: "skinWeight", JOINTS_0: "skinIndex" }, Ie = { scale: "scale", translation: "position", rotation: "quaternion", weights: "morphTargetInfluences" }, Go = { CUBICSPLINE: void 0, // We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each // keyframe track will be initialized with a default interpolation type, then modified. LINEAR: ks, STEP: Ui }, tn = { OPAQUE: "OPAQUE", MASK: "MASK", BLEND: "BLEND" }; function Xo(r) { return r.DefaultMaterial === void 0 && (r.DefaultMaterial = new Un({ color: 16777215, emissive: 0, metalness: 1, roughness: 1, transparent: !1, depthTest: !0, side: at })), r.DefaultMaterial; } function He(r, e, t) { for (const s in t.extensions) r[s] === void 0 && (e.userData.gltfExtensions = e.userData.gltfExtensions || {}, e.userData.gltfExtensions[s] = t.extensions[s]); } function Be(r, e) { e.extras !== void 0 && (typeof e.extras == "object" ? Object.assign(r.userData, e.extras) : console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, " + e.extras)); } function qo(r, e, t) { let s = !1, n = !1, i = !1; for (let l = 0, u = e.length; l < u; l++) { const f = e[l]; if (f.POSITION !== void 0 && (s = !0), f.NORMAL !== void 0 && (n = !0), f.COLOR_0 !== void 0 && (i = !0), s && n && i) break; } if (!s && !n && !i) return Promise.resolve(r); const o = [], c = [], a = []; for (let l = 0, u = e.length; l < u; l++) { const f = e[l]; if (s) { const d = f.POSITION !== void 0 ? t.getDependency("accessor", f.POSITION) : r.attributes.position; o.push(d); } if (n) { const d = f.NORMAL !== void 0 ? t.getDependency("accessor", f.NORMAL) : r.attributes.normal; c.push(d); } if (i) { const d = f.COLOR_0 !== void 0 ? t.getDependency("accessor", f.COLOR_0) : r.attributes.color; a.push(d); } } return Promise.all([ Promise.all(o), Promise.all(c), Promise.all(a) ]).then(function(l) { const u = l[0], f = l[1], d = l[2]; return s && (r.morphAttributes.position = u), n && (r.morphAttributes.normal = f), i && (r.morphAttributes.color = d), r.morphTargetsRelative = !0, r; }); } function Ko(r, e) { if (r.updateMorphTargets(), e.weights !== void 0) for (let t = 0, s = e.weights.length; t < s; t++) r.morphTargetInfluences[t] = e.weights[t]; if (e.extras && Array.isArray(e.extras.targetNames)) { const t = e.extras.targetNames; if (r.morphTargetInfluences.length === t.length) { r.morphTargetDictionary = {}; for (let s = 0, n = t.length; s < n; s++) r.morphTargetDictionary[t[s]] = s; } else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names."); } } function Wo(r) { let e; const t = r.extensions && r.extensions[U.KHR_DRACO_MESH_COMPRESSION]; if (t ? e = "draco:" + t.bufferView + ":" + t.indices + ":" + nn(t.attributes) : e = r.indices + ":" + nn(r.attributes) + ":" + r.mode, r.targets !== void 0) for (let s = 0, n = r.targets.length; s < n; s++) e += ":" + nn(r.targets[s]); return e; } function nn(r) { let e = ""; const t = Object.keys(r).sort(); for (let s = 0, n = t.length; s < n; s++) e += t[s] + ":" + r[t[s]] + ";"; return e; } function bn(r) { switch (r) { case Int8Array: return 1 / 127; case Uint8Array: return 1 / 255; case Int16Array: return 1 / 32767; case Uint16Array: return 1 / 65535; default: throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type."); } } function $o(r) { return r.search(/\.jpe?g($|\?)/i) > 0 || r.search(/^data\:image\/jpeg/) === 0 ? "image/jpeg" : r.search(/\.webp($|\?)/i) > 0 || r.search(/^data\:image\/webp/) === 0 ? "image/webp" : "image/png"; } const Yo = new J(); class Zo { constructor(e = {}, t = {}) { this.json = e, this.extensions = {}, this.plugins = {}, this.options = t, this.cache = new _o(), this.associations = /* @__PURE__ */ new Map(), this.primitiveCache = {}, this.nodeCache = {}, this.meshCache = { refs: {}, uses: {} }, this.cameraCache = { refs: {}, uses: {} }, this.lightCache = { refs: {}, uses: {} }, this.sourceCache = {}, this.textureCache = {}, this.nodeNamesUsed = {}; let s = !1, n = !1, i = -1; typeof navigator < "u" && typeof navigator.userAgent < "u" && (s = /^((?!chrome|android).)*safari/i.test(navigator.userAgent) === !0, n = navigator.userAgent.indexOf("Firefox") > -1, i = n ? navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1] : -1), typeof createImageBitmap > "u" || s || n && i < 98 ? this.textureLoader = new yi(this.options.manager) : this.textureLoader = new vi(this.options.manager), this.textureLoader.setCrossOrigin(this.options.crossOrigin), this.textureLoader.setRequestHeader(this.options.requestHeader), this.fileLoader = new Os(this.options.manager), this.fileLoader.setResponseType("arraybuffer"), this.options.crossOrigin === "use-credentials" && this.fileLoader.setWithCredentials(!0); } setExtensions(e) { this.extensions = e; } setPlugins(e) { this.plugins = e; } parse(e, t) { const s = this, n = this.json, i = this.extensions; this.cache.removeAll(), this.nodeCache = {}, this._invokeAll(function(o) { return o._markDefs && o._markDefs(); }), Promise.all( this._invokeAll(function(o) { return o.beforeRoot && o.beforeRoot(); }) ).then(function() { return