UNPKG

@tomorrowevening/hermes

Version:

An extendable set of Web Tools controlled via a separate window for non-intereference with content.

1,580 lines (1,579 loc) 1.71 MB
import { Texture as Rh, OrthographicCamera as Nh, Scene as yu, MeshBasicMaterial as bn, BufferGeometry as Tn, Float32BufferAttribute as gn, Mesh as Y, LinearSRGBColorSpace as Pa, ObjectLoader as ox, AnimationMixer as lx, AnimationClip as cx, WebGLRenderTarget as Fm, RGBAFormat as hx, EventDispatcher as xu, Clock as Dm, Group as jo, RepeatWrapping as zd, Color as vn, ColorManagement as ir, FrontSide as ux, BackSide as Om, DoubleSide as _u, ZeroFactor as Im, OneFactor as Bm, SrcColorFactor as Lm, OneMinusSrcColorFactor as Um, SrcAlphaFactor as km, OneMinusSrcAlphaFactor as zm, DstAlphaFactor as Gm, OneMinusDstAlphaFactor as Vm, DstColorFactor as Hm, OneMinusDstColorFactor as Wm, SrcAlphaSaturateFactor as dx, ConstantColorFactor as $m, OneMinusConstantColorFactor as jm, ConstantAlphaFactor as qm, OneMinusConstantAlphaFactor as Ym, AddEquation as px, SubtractEquation as fx, ReverseSubtractEquation as mx, MinEquation as gx, MaxEquation as yx, NoBlending as xx, NormalBlending as _x, AdditiveBlending as bx, SubtractiveBlending as Tx, MultiplyBlending as Sx, CustomBlending as vx, Line as Ls, LineBasicMaterial as bu, Controls as Xm, Vector3 as Z, MOUSE as ur, TOUCH as nr, Quaternion as Jt, Spherical as Ph, Vector2 as yt, Ray as wx, Plane as Ex, MathUtils as Cx, ShaderMaterial as Zm, GLSL3 as Mx, PlaneGeometry as Km, Raycaster as Fa, Object3D as Tr, CylinderGeometry as kt, BoxGeometry as bt, OctahedronGeometry as Qa, TorusGeometry as Lr, SphereGeometry as Qm, Euler as Jm, Matrix4 as Rl, CatmullRomCurve3 as Gd, AxesHelper as Ax, MeshDepthMaterial as Rx, MeshNormalMaterial as Nx, Sphere as Px, Box3 as Fx, Vector4 as Dx, WebGLRenderer as da, PerspectiveCamera as Vd, CameraHelper as Ox, SkinnedMesh as Ix, SpotLightHelper as Bx, PointLightHelper as Lx, HemisphereLightHelper as Ux, DirectionalLightHelper as kx, SkeletonHelper as zx, SRGBColorSpace as Hd, NoToneMapping as Wd, NoColorSpace as Gx, LinearToneMapping as Vx, ReinhardToneMapping as Hx, CineonToneMapping as Wx, ACESFilmicToneMapping as $x, AgXToneMapping as jx, NeutralToneMapping as qx, CustomToneMapping as Yx } from "three"; import { EffectPass as Xx, ShaderPass as Zx } from "postprocessing"; import eg, { useState as Re, useRef as We, useEffect as wn, useMemo as Sa, Component as Va, createRef as Ai, forwardRef as Kx } from "react"; const rl = () => { }, iP = () => { }; function al(a) { return a.substring(0, 1).toUpperCase() + a.substring(1); } function Qx(a) { const e = JSON.stringify(a); return navigator.clipboard.writeText(e), e; } function Jx() { return Math.round(Math.random() * 1e6).toString(); } function e_(a) { return a.r !== void 0 && a.g !== void 0 && a.b !== void 0; } function $d(a) { const e = Math.round(a.r * 255), t = Math.round(a.g * 255), s = Math.round(a.b * 255), i = (l) => { const c = l.toString(16); return c.length === 1 ? "0" + c : c; }, n = i(e), r = i(t), o = i(s); return "#" + n + r + o; } function ic(a, e, t, s) { return new (t || (t = Promise))(function(i, n) { function r(c) { try { l(s.next(c)); } catch (h) { n(h); } } function o(c) { try { l(s.throw(c)); } catch (h) { n(h); } } function l(c) { var h; c.done ? i(c.value) : (h = c.value, h instanceof t ? h : new t(function(u) { u(h); })).then(r, o); } l((s = s.apply(a, [])).next()); }); } const t_ = ["geforce 320m", "geforce 8600", "geforce 8600m gt", "geforce 8800 gs", "geforce 8800 gt", "geforce 9400", "geforce 9400m g", "geforce 9400m", "geforce 9600m gt", "geforce 9600m", "geforce fx go5200", "geforce gt 120", "geforce gt 130", "geforce gt 330m", "geforce gtx 285", "google swiftshader", "intel g41", "intel g45", "intel gma 4500mhd", "intel gma x3100", "intel hd 3000", "intel q45", "legacy", "mali-2", "mali-3", "mali-4", "quadro fx 1500", "quadro fx 4", "quadro fx 5", "radeon hd 2400", "radeon hd 2600", "radeon hd 4670", "radeon hd 4850", "radeon hd 4870", "radeon hd 5670", "radeon hd 5750", "radeon hd 6290", "radeon hd 6300", "radeon hd 6310", "radeon hd 6320", "radeon hd 6490m", "radeon hd 6630m", "radeon hd 6750m", "radeon hd 6770m", "radeon hd 6970m", "sgx 543", "sgx543"]; function jd(a) { return a = a.toLowerCase().replace(/.*angle ?\((.+)\)(?: on vulkan [0-9.]+)?$/i, "$1").replace(/\s(\d{1,2}gb|direct3d.+$)|\(r\)| \([^)]+\)$/g, "").replace(/(?:vulkan|opengl) \d+\.\d+(?:\.\d+)?(?: \((.*)\))?/, "$1"); } const tg = typeof window > "u", Us = (() => { if (tg) return; const { userAgent: a, platform: e, maxTouchPoints: t } = window.navigator, s = /(iphone|ipod|ipad)/i.test(a), i = e === "iPad" || e === "MacIntel" && t > 0 && !window.MSStream; return { isIpad: i, isMobile: /android/i.test(a) || s || i, isSafari12: /Version\/12.+Safari/.test(a), isFirefox: /Firefox/.test(a) }; })(); function s_(a, e, t) { if (!t) return [e]; const s = function(c) { const h = ` precision highp float; attribute vec3 aPosition; varying float vvv; void main() { vvv = 0.31622776601683794; gl_Position = vec4(aPosition, 1.0); } `, u = ` precision highp float; varying float vvv; void main() { vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * vvv; enc = fract(enc); enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0); gl_FragColor = enc; } `, d = c.createShader(35633), p = c.createShader(35632), f = c.createProgram(); if (!(p && d && f)) return; c.shaderSource(d, h), c.shaderSource(p, u), c.compileShader(d), c.compileShader(p), c.attachShader(f, d), c.attachShader(f, p), c.linkProgram(f), c.detachShader(f, d), c.detachShader(f, p), c.deleteShader(d), c.deleteShader(p), c.useProgram(f); const m = c.createBuffer(); c.bindBuffer(34962, m), c.bufferData(34962, new Float32Array([-1, -1, 0, 3, -1, 0, -1, 3, 0]), 35044); const y = c.getAttribLocation(f, "aPosition"); c.vertexAttribPointer(y, 3, 5126, !1, 0, 0), c.enableVertexAttribArray(y), c.clearColor(1, 1, 1, 1), c.clear(16384), c.viewport(0, 0, 1, 1), c.drawArrays(4, 0, 3); const g = new Uint8Array(4); return c.readPixels(0, 0, 1, 1, 6408, 5121, g), c.deleteProgram(f), c.deleteBuffer(m), g.join(""); }(a), i = "801621810", n = "8016218135", r = "80162181161", o = Us?.isIpad ? [["a7", r, 12], ["a8", n, 15], ["a8x", n, 15], ["a9", n, 15], ["a9x", n, 15], ["a10", n, 15], ["a10x", n, 15], ["a12", i, 15], ["a12x", i, 15], ["a12z", i, 15], ["a14", i, 15], ["a15", i, 15], ["m1", i, 15], ["m2", i, 15]] : [["a7", r, 12], ["a8", n, 12], ["a9", n, 15], ["a10", n, 15], ["a11", i, 15], ["a12", i, 15], ["a13", i, 15], ["a14", i, 15], ["a15", i, 15], ["a16", i, 15], ["a17", i, 15]]; let l; return s === "80162181255" ? l = o.filter(([, , c]) => c >= 14) : (l = o.filter(([, c]) => c === s), l.length || (l = o)), l.map(([c]) => `apple ${c} gpu`); } class qd extends Error { constructor(e) { super(e), Object.setPrototypeOf(this, new.target.prototype); } } const nc = [], Yd = []; function i_(a, e) { if (a === e) return 0; const t = a; a.length > e.length && (a = e, e = t); let s = a.length, i = e.length; for (; s > 0 && a.charCodeAt(~-s) === e.charCodeAt(~-i); ) s--, i--; let n, r = 0; for (; r < s && a.charCodeAt(r) === e.charCodeAt(r); ) r++; if (s -= r, i -= r, s === 0) return i; let o, l, c = 0, h = 0, u = 0; for (; h < s; ) Yd[h] = a.charCodeAt(r + h), nc[h] = ++h; for (; u < i; ) for (n = e.charCodeAt(r + u), o = u++, c = u, h = 0; h < s; h++) l = n === Yd[h] ? o : o + 1, o = nc[h], c = nc[h] = o > c ? l > c ? c + 1 : l : l > o ? o + 1 : l; return c; } function n_(a) { return a != null; } const r_ = ({ mobileTiers: a = [0, 15, 30, 60], desktopTiers: e = [0, 15, 30, 60], override: t = {}, glContext: s, failIfMajorPerformanceCaveat: i = !1, benchmarksURL: n = "https://unpkg.com/detect-gpu@5.0.70/dist/benchmarks" } = {}) => ic(void 0, void 0, void 0, function* () { const r = {}; if (tg) return { tier: 0, type: "SSR" }; const { isIpad: o = !!Us?.isIpad, isMobile: l = !!Us?.isMobile, screenSize: c = window.screen, loadBenchmarks: h = (T) => ic(void 0, void 0, void 0, function* () { const E = yield fetch(`${n}/${T}`).then((v) => v.json()); if (parseInt(E.shift().split(".")[0], 10) < 4) throw new qd("Detect GPU benchmark data is out of date. Please update to version 4x"); return E; }) } = t; let { renderer: u } = t; const d = (T, E, v, A, N) => ({ device: N, fps: A, gpu: v, isMobile: l, tier: T, type: E }); let p, f = ""; if (u) u = jd(u), p = [u]; else { const T = s || function(v, A = !1) { const N = { alpha: !1, antialias: !1, depth: !1, failIfMajorPerformanceCaveat: A, powerPreference: "high-performance", stencil: !1 }; v && delete N.powerPreference; const k = window.document.createElement("canvas"), H = k.getContext("webgl", N) || k.getContext("experimental-webgl", N); return H ?? void 0; }(Us?.isSafari12, i); if (!T) return d(0, "WEBGL_UNSUPPORTED"); const E = Us?.isFirefox ? null : T.getExtension("WEBGL_debug_renderer_info"); if (u = E ? T.getParameter(E.UNMASKED_RENDERER_WEBGL) : T.getParameter(T.RENDERER), !u) return d(1, "FALLBACK"); f = u, u = jd(u), p = function(v, A, N) { return A === "apple gpu" ? s_(v, A, N) : [A]; }(T, u, l); } const m = (yield Promise.all(p.map(function(T) { var E; return ic(this, void 0, void 0, function* () { const v = ((_e) => { const ot = l ? ["adreno", "apple", "mali-t", "mali", "nvidia", "powervr", "samsung"] : ["intel", "apple", "amd", "radeon", "nvidia", "geforce", "adreno"]; for (const Lt of ot) if (_e.includes(Lt)) return Lt; })(T); if (!v) return; const A = `${l ? "m" : "d"}-${v}${o ? "-ipad" : ""}.json`, N = r[A] = (E = r[A]) !== null && E !== void 0 ? E : h(A); let k; try { k = yield N; } catch (_e) { if (_e instanceof qd) throw _e; return; } const H = function(_e) { var ot; const Lt = (_e = _e.replace(/\([^)]+\)/, "")).match(/\d+/) || _e.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g); return (ot = Lt?.join("").replace(/\W|amd/g, "")) !== null && ot !== void 0 ? ot : ""; }(T); let $ = k.filter(([, _e]) => _e === H); $.length || ($ = k.filter(([_e]) => _e.includes(T))); const W = $.length; if (W === 0) return; const q = T.split(/[.,()\[\]/\s]/g).sort().filter((_e, ot, Lt) => ot === 0 || _e !== Lt[ot - 1]).join(" "); let X, [ve, , , , ue] = W > 1 ? $.map((_e) => [_e, i_(q, _e[2])]).sort(([, _e], [, ot]) => _e - ot)[0][0] : $[0], ge = Number.MAX_VALUE; const { devicePixelRatio: ie } = window, we = c.width * ie * c.height * ie; for (const _e of ue) { const [ot, Lt] = _e, Ir = ot * Lt, Rn = Math.abs(we - Ir); Rn < ge && (ge = Rn, X = _e); } if (!X) return; const [, , ze, at] = X; return [ge, ze, ve, at]; }); }))).filter(n_).sort(([T = Number.MAX_VALUE, E], [v = Number.MAX_VALUE, A]) => T === v ? E - A : T - v); if (!m.length) { const T = t_.find((E) => u.includes(E)); return T ? d(0, "BLOCKLISTED", T) : d(1, "FALLBACK", `${u} (${f})`); } const [, y, g, x] = m[0]; if (y === -1) return d(0, "BLOCKLISTED", g, y, x); const _ = l ? a : e; let b = 0; for (let T = 0; T < _.length; T++) y >= _[T] && (b = T); return d(b, "BENCHMARK", g, y, x); }); var a_ = /* @__PURE__ */ ((a) => (a[a.High = 0] = "High", a[a.Medium = 1] = "Medium", a[a.Low = 2] = "Low", a))(a_ || {}); function o_(a) { let e = 0; const t = performance.now(); function s() { e++; const i = performance.now(); if (i - t >= 100) { const n = e / ((i - t) / 1e3), r = Math.round(n / 30) * 30; a(r); } else requestAnimationFrame(s); } requestAnimationFrame(s); } function nP(a, e, t) { return new Promise((s) => { r_().then((i) => { let n = !1; const r = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); if (n = "transferControlToOffscreen" in a, r) { const l = navigator.userAgent.match(/version\/(\d+)/i); n = (l ? parseInt(l[1]) : 0) >= 17; } const o = { dpr: devicePixelRatio, fps: 30, width: innerWidth, height: innerHeight, mobile: i.isMobile !== void 0 ? i.isMobile : !1, supportOffScreenCanvas: n, quality: 2, dev: e, editor: t }; i.tier === 3 ? o.quality = 0 : i.tier === 2 && (o.quality = 1), o_((l) => { o.fps = l, s(o); }), s(o); }); }); } function rn(a, e, t) { return Math.min(e, Math.max(a, t)); } function Fh(a, e, t) { return (t - a) / (e - a); } function Da(a, e, t) { return a * (1 - t) + e * t; } function rP(a, e, t, s, i) { return Da(t, s, Fh(a, e, i)); } function aP(a, e) { const t = a - e; return Math.sqrt(t * t); } function vs(a, e = 1) { return Number(a.toFixed(e)); } function oP(a, e, t, s) { return Da(a, e, 1 - Math.exp(-t * s)); } function lP(a, e = 1) { return Number(a.toFixed(e)); } function l_(a, e, t, s) { return a === e && t === s; } function c_(a, e, t, s) { return 1 / (3 * e * a * a + 2 * t * a + s); } function h_(a, e, t, s, i) { return e * (a * a * a) + t * (a * a) + s * a + i; } function u_(a, e, t, s, i) { const n = a * a; return e * (n * a) + t * n + s * a + i; } function cP(a, e, t, s, i) { if (a <= 0) return 0; if (a >= 1) return 1; if (l_(e, t, s, i)) return a; const n = 0, r = 0, o = e, l = t, c = s, h = i, u = 1, d = 1, p = u - 3 * c + 3 * o - n, f = 3 * c - 6 * o + 3 * n, m = 3 * o - 3 * n, y = n, g = d - 3 * h + 3 * l - r, x = 3 * h - 6 * l + 3 * r, _ = 3 * l - 3 * r, b = r; let T = a; for (let E = 0; E < 5; E++) { const v = h_(T, p, f, m, y); let A = c_(T, p, f, m); A === 1 / 0 && (A = a), T -= (v - a) * A, T = Math.min(Math.max(T, 0), 1); } return u_(T, g, x, _, b); } const Xd = (a) => { a?.dispose(); }, sg = (a) => { if (a) if (Array.isArray(a)) a.forEach((e) => sg(e)); else { for (const e in a) { const t = a[e]; t !== null && t instanceof Rh && Xd(t); } if (a.isShaderMaterial === !0) { const e = a; for (const t in e.uniforms) { const s = e.uniforms[t]; s.value !== null && s.value instanceof Rh && Xd(s.value); } } a.dispose(); } }, hi = (a) => { if (a) { for (; a.children.length > 0; ) { const e = a.children[0]; e.type === "Audio" ? (e.pause(), e.parent && e.parent.remove(e)) : hi(e); } if (a.parent && a.parent.remove(a), a.isMesh) { const e = a; e.geometry?.dispose(), sg(e.material); } a.dispose !== void 0 && a.dispose(); } }; let Dh = 0; const Zd = () => { Dh = 0; }, Oh = (a) => { if (!a) return; let e = a.name.replaceAll(" ", "").replaceAll("/", "."); if (e.length === 0 && (e = `obj_${Dh}`, Dh++), a.parent !== null && a.parent.uuid.length > 0 && (e = `${a.parent.uuid}.${e}`), a.uuid = e, a.isMesh !== void 0) { const t = a; if (Array.isArray(t.material)) t.material.forEach((s, i) => { s.uuid = `${e}.material.${i}`; }); else { const s = t.material; s.uuid = `${e}.material`; } } a.children.forEach((t) => Oh(t)); }; class yn { static renderer; static canvas; static context = null; static scene = null; static camera = null; static material = null; static inited = !1; static width = 100; static height = 100; static init() { this.inited || (this.canvas = document.createElement("canvas"), this.canvas.width = this.width, this.canvas.height = this.height, this.context = this.canvas.getContext("2d"), this.inited = !0); } static renderToBlob(e) { this.init(); const t = e.repeat.clone(), s = e.offset.clone(); if (e.repeat.set(1, 1), e.offset.set(0, 0), this.context !== null) { this.context.clearRect(0, 0, this.width, this.height); const i = e.image; if (i != null && i.width > 0) { this.canvas.title = e.sourceFile; const n = this.canvas.width / i.width, r = this.renderToCanvas(e); this.context.drawImage(r, 0, 0, i.width * n, i.height * n); } } return e.repeat.copy(t), e.offset.copy(s), this.canvas.toDataURL("image/png"); } static renderToCanvas(e) { if (this.material === null) { this.camera = new Nh(-0.5, 0.5, 0.5, -0.5, 0, 100), this.scene = new yu(), this.material = new bn(); const t = new Tn(); t.setAttribute("position", new gn([-0.5, -0.5, 0, 1.5, -0.5, 0, -0.5, 1.5, 0], 3)), t.setAttribute("normal", new gn([0, 0, 1, 0, 0, 1], 3)), t.setAttribute("uv", new gn([0, 0, 2, 0, 0, 2], 2)); const s = new Y(t, this.material); this.scene.add(s); } if (e.isRenderTargetTexture) this.material.map = e, this.renderer.render(this.scene, this.camera); else { const t = this.renderer.outputColorSpace, s = e.colorSpace; this.renderer.outputColorSpace = Pa, e.colorSpace = Pa, this.material.map = e, this.renderer.render(this.scene, this.camera), this.renderer.outputColorSpace = t, e.colorSpace = s; } return this.renderer.domElement; } } function hP(a) { return new Promise((e) => { const t = new ox(); t.parseAsync(a.scene).then((s) => { const i = new lx(s); if (a.animations.length > 0) { const r = a.animations.map((l) => cx.parse(l)); i.clipAction(r[0]).play(), i.getRoot().animations = a.animations, i.getRoot().mixer = i; } const n = []; a.cameras && a.cameras.length > 0 && a.cameras.forEach((r) => { const o = t.parse(r); n.push(o); }), e({ animations: a.animations, model: s, mixer: i, cameras: n }); }); }); } let Ih = []; function uP(a, e) { yn.renderer = e.renderer, a.passes.forEach((t, s) => { const i = []; i.push({ type: "boolean", prop: "Enabled", value: t.enabled }); let n = (o, l) => { console.log("Default Handle Pass:", o, l); }; if (t instanceof Xx) t.effects.forEach((o, l) => { o.uniforms.size > 0 && o.uniforms.forEach((c, h) => { const u = `${o.name.replace("Effect", "")} ${h}`; if (c.value === null) i.push({ prop: h, title: u, type: "image", value: { offset: [0, 0], repeat: [1, 1], src: "" } }); else if (c.value.isTexture) { const d = c.value, p = yn.renderToBlob(d); i.push({ prop: h, title: u, type: "image", value: { offset: [d.offset.x, d.offset.y], repeat: [d.repeat.x, d.repeat.y], src: p } }); } else typeof c.value == "number" ? i.push({ prop: h, title: u, type: "number", value: c.value, step: 0.01 }) : typeof c.value == "string" ? i.push({ prop: h, title: u, type: "string", value: c.value }) : typeof c.value == "boolean" && i.push({ prop: h, title: u, type: "boolean", value: c.value }); }); }), n = (o, l) => { t.effects.forEach((c) => { c.uniforms.size > 0 && c.uniforms.forEach((h, u) => { u === o && (h.value = l); }); }); }; else if (t instanceof Zx) { const o = t.fullscreenMaterial; for (const l in o.uniforms) { const c = o.uniforms[l], h = `${o.name.replace("Material", "")} ${l}`; if (c.value === null) i.push({ title: h, prop: l, type: "image", value: { offset: [0, 0], repeat: [1, 1], src: "" } }); else if (c.value.isTexture) { const u = c.value, d = yn.renderToBlob(u); i.push({ title: h, prop: l, type: "image", value: { offset: [u.offset.x, u.offset.y], repeat: [u.repeat.x, u.repeat.y], src: d } }); } else typeof c.value == "number" ? i.push({ title: h, prop: l, type: "number", value: c.value, step: 0.01 }) : typeof c.value == "string" ? i.push({ title: h, prop: l, type: "string", value: c.value }) : typeof c.value == "boolean" && i.push({ title: h, prop: l, type: "boolean", value: c.value }); } n = (l, c) => { const h = o.uniforms[l]; h.value = c; }; } else return; const r = `Pass: ${t.name}`; e.addGroup({ title: r, items: i, onUpdate: (o, l) => { o === "Enabled" ? t.enabled = l : n(o, l); } }), Ih.push(r); }); } function dP(a) { Ih.forEach((e) => { a.removeGroup(e); }), Ih = []; } function pP(a, e, t, s = 1024) { return new Promise((i) => { const n = e.aspect, r = e.fov, o = e.rotation.clone(), l = t.outputBuffer; e.aspect = 1, e.fov = 90, e.updateProjectionMatrix(); const c = new Fm(s, s, { format: hx, depthBuffer: !0, stencilBuffer: !1 }); t.outputBuffer = c, Fn(a, c, e, "nx", t, s).then(() => { Fn(a, c, e, "ny", t, s).then(() => { Fn(a, c, e, "nz", t, s).then(() => { Fn(a, c, e, "px", t, s).then(() => { Fn(a, c, e, "py", t, s).then(() => { Fn(a, c, e, "pz", t, s).then(() => { e.aspect = n, e.fov = r, e.rotation.copy(o), e.updateMatrixWorld(), e.updateProjectionMatrix(), t.outputBuffer = l, c.dispose(), i(); }); }); }); }); }); }); }); } function Fn(a, e, t, s, i, n) { return new Promise((r) => { const o = Math.PI / 2; switch (s) { case "nx": t.rotation.set(0, -o, 0); break; case "ny": t.rotation.set(-o, 0, Math.PI); break; case "nz": t.rotation.set(0, 0, 0); break; case "px": t.rotation.set(0, o, 0); break; case "py": t.rotation.set(o, 0, Math.PI); break; case "pz": t.rotation.set(0, Math.PI, 0); break; } t.updateMatrixWorld(), i.render(); const l = new Uint8Array(n * n * 4); a.readRenderTargetPixels(e, 0, 0, n, n, l); const c = document.createElement("canvas"); c.width = c.height = n; const h = c.getContext("2d"), u = h.createImageData(n, n); u.data.set(l), h.putImageData(u, 0, 0); const d = document.createElement("canvas"); d.width = d.height = n; const p = d.getContext("2d"); p.translate(0, n), p.scale(1, -1), p.drawImage(c, 0, 0); const f = d.toDataURL("image/png"), m = document.createElement("a"); m.href = f, m.download = `${t.name}_${s}.png`, document.body.appendChild(m), m.click(), m.remove(), r(); }); } const Dn = Tu([ "ctrlKey", "metaKey", "shiftKey", "button", "pointerId", "pointerType", "clientX", "clientY", "pageX", "pageY" ]), d_ = Tu([ "clientX", "clientY", "deltaX", "deltaY", "deltaMode" ]), p_ = Tu([ "ctrlKey", "metaKey", "shiftKey", "keyCode" ]); function f_(a, e) { a.preventDefault(), d_(a, e); } function m_(a) { a.preventDefault(); } function g_(a, e, t) { for (const s of e) t[s] = a[s]; } function Tu(a) { return function(t, s) { const i = { type: t.type }; g_(t, a, i), s(i); }; } function rc(a, e) { const t = [], s = { type: a.type, touches: t }; for (let i = 0; i < a.touches.length; ++i) { const n = a.touches[i]; t.push({ pageX: n.pageX, pageY: n.pageY }); } e(s); } const y_ = { 37: !0, // left 38: !0, // up 39: !0, // right 40: !0 // down }; function x_(a, e) { const { keyCode: t } = a; y_[t] && (a.preventDefault(), p_(a, e)); } const fP = { contextmenu: m_, mousedown: Dn, mousemove: Dn, mouseup: Dn, pointerdown: Dn, pointermove: Dn, pointerup: Dn, touchstart: rc, touchmove: rc, touchend: rc, wheel: f_, keydown: x_ }; let __ = 0; class mP { id; worker; constructor(e, t, s) { this.id = __++, this.worker = t; const i = (r) => { this.worker.postMessage({ type: "event", id: this.id, data: r }); }; t.postMessage({ type: "makeProxy", id: this.id }); for (const [r, o] of Object.entries(s)) e.addEventListener(r, (l) => { o(l, i); }); function n() { i({ type: "resize", left: 0, top: 0, width: innerWidth, height: innerHeight }); } window.addEventListener("resize", n), n(); } } class b_ extends xu { style = {}; left = 0; top = 0; width = 0; height = 0; ownerDocument = void 0; constructor() { super(), this.ownerDocument = this; } get clientWidth() { return this.width; } set clientWidth(e) { this.width = e; } get clientHeight() { return this.height; } set clientHeight(e) { this.height = e; } // OrbitControls call these as of r132. Implementing as no-ops setPointerCapture() { } releasePointerCapture() { } getBoundingClientRect() { return { x: this.left, y: this.top, left: this.left, top: this.top, width: this.width, height: this.height, right: this.left + this.width, bottom: this.top + this.height, toJSON: () => ({}) // Satisfies the DOMRect interface }; } handleEvent(e) { if (e.type === "size") { this.left = e.left, this.top = e.top, this.width = e.width, this.height = e.height; return; } e.preventDefault = rl, e.stopPropagation = rl, this.dispatchEvent(e); } focus() { } getRootNode() { return this; } } class gP { targets = {}; constructor() { this.handleEvent = this.handleEvent.bind(this); } makeProxy(e) { const { id: t } = e, s = new b_(); this.targets[t] = s; } getProxy(e) { return this.targets[e]; } handleEvent(e) { this.targets[e.id]?.handleEvent(e.data); } } var K = /* @__PURE__ */ ((a) => (a.CUSTOM = "ToolEvents::custom", a.SELECT_DROPDOWN = "ToolEvents::selectDropdown", a.DRAG_UPDATE = "ToolEvents::dragUpdate", a.ADD_SCENE = "ToolEvents::addScene", a.REFRESH_SCENE = "ToolEvents::refreshScene", a.REMOVE_SCENE = "ToolEvents::removeScene", a.SET_SCENE = "ToolEvents::setScene", a.GET_OBJECT = "ToolEvents::getObject", a.SET_OBJECT = "ToolEvents::setObject", a.UPDATE_OBJECT = "ToolEvents::updateObject", a.CREATE_TEXTURE = "ToolEvents::createTexture", a.REQUEST_METHOD = "ToolEvents::requestMethod", a.ADD_CAMERA = "ToolEvents::addCamera", a.REMOVE_CAMERA = "ToolEvents::removeCamera", a.ADD_GROUP = "ToolEvents::addGroup", a.REMOVE_GROUP = "ToolEvents::removeGroup", a.ADD_SPLINE = "ToolEvents::addSpline", a.ADD_RENDERER = "ToolEvents::addRenderer", a.UPDATE_RENDERER = "ToolEvents::updateRenderer", a))(K || {}); class yP extends xu { components = /* @__PURE__ */ new Map(); appHandlers = []; editorHandlers = []; // Protected _appID = ""; _debugEnabled; _broadcastChannel = void 0; _webSocket = void 0; _mode = "app"; _connected = !1; _useBC = !1; constructor(e, t, s, i = !0) { super(), this._appID = e, this._debugEnabled = t, this.editor = s, t && (this._useBC = i, i ? (this._broadcastChannel = new BroadcastChannel(e), this._broadcastChannel.addEventListener("message", this.messageHandler)) : (this._webSocket = new WebSocket(e), this._webSocket.addEventListener("open", this.openHandler), this._webSocket.addEventListener("close", this.closeHandler), this._webSocket.addEventListener("message", this.messageHandler))); } addComponent(e, t) { this.components.set(e, t); } dispose() { this._broadcastChannel !== void 0 && this._broadcastChannel.removeEventListener("message", this.messageHandler), this._webSocket !== void 0 && (this._webSocket.removeEventListener("open", this.openHandler), this._webSocket.removeEventListener("close", this.closeHandler), this._webSocket.removeEventListener("message", this.messageHandler)), this.components.forEach((e) => { e.dispose(); }), this.components.clear(); } // Remote send(e) { this._mode !== e.target && (this._useBC ? this._broadcastChannel?.postMessage(e) : this._connected && this._webSocket?.send(JSON.stringify(e))); } messageHandler = (e) => { let t = e.data; this._useBC || (t = JSON.parse(e.data)), t.target === "editor" ? this.handleEditorBroadcast(t) : this.handleAppBroadcast(t); }; handleAppBroadcast(e) { switch (this.appHandlers.forEach((t) => { t.callback(e); }), e.event) { case "custom": this.dispatchEvent({ type: "ToolEvents::custom", value: e.data }); break; } } handleEditorBroadcast(e) { switch (this.editorHandlers.forEach((t) => { t.callback(e); }), e.event) { case "custom": this.dispatchEvent({ type: "ToolEvents::custom", value: e.data }); break; } } openHandler = () => { this._connected = !0; }; closeHandler = () => { this._connected = !1; }; // Getters / Setters get appID() { return this._appID; } get connected() { return this._connected; } get debugEnabled() { return this._debugEnabled; } get mode() { return this._mode; } get isApp() { return this._mode === "app"; } get editor() { return this._mode === "editor"; } set editor(e) { e && (this._mode = "editor"); } } class xP { canvas; inputElement; settings; playing = !1; rafID = -1; constructor(e, t, s) { this.canvas = e, this.inputElement = t, this.settings = s; } dispose() { this.stop(); } play() { this.playing || (this.playing = !0, this.onUpdate()); } stop() { this.playing && (this.playing = !1, cancelAnimationFrame(this.rafID), this.rafID = -1); } update() { } draw() { } resize(e, t) { this.settings.supportOffScreenCanvas && (this.inputElement.clientWidth = e, this.inputElement.clientHeight = t, this.inputElement.width = e, this.inputElement.height = t); } // Events onResize = (e) => { this.resize(e.width, e.height); }; onUpdate = () => { this.update(), this.draw(), this.rafID = requestAnimationFrame(this.onUpdate); }; } class _P extends yu { clock; cameras; lights; world; constructor(e) { super(), this.name = e, this.clock = new Dm(), this.lights = new jo(), this.lights.name = "lights", this.add(this.lights), this.cameras = new jo(), this.cameras.name = "cameras", this.add(this.cameras), this.world = new jo(), this.world.name = "world", this.add(this.world); } init() { return new Promise((e) => { this.setupLights().then(() => this.setupCameras()).then(() => this.setupWorld()).then(() => this.setupPost()).then(() => this.setupAnimation()).then(() => this.setupDebug()).then(() => e()); }); } setupLights() { return new Promise((e) => { e(); }); } setupCameras() { return new Promise((e) => { e(); }); } setupWorld() { return new Promise((e) => { e(); }); } setupPost() { return new Promise((e) => { e(); }); } setupAnimation() { return new Promise((e) => { e(); }); } setupDebug() { return new Promise((e) => { e(); }); } dispose() { } update() { } draw(e) { } postDraw() { } resize(e, t, s) { } show() { this.clock.start(), this.showComplete(); } showComplete() { this.enable(); } hide() { this.disable(), this.hideComplete(); } hideComplete() { this.clock.stop(); } enable() { } disable() { } // Getters get deltaTime() { return Math.min(this.clock.getDelta(), 1 / 30); } } class Su { app; constructor(e) { this.app = e, this.app.appHandlers.push({ remote: this, callback: this.handleApp.bind(this) }), this.app.editorHandlers.push({ remote: this, callback: this.handleEditor.bind(this) }); } dispose() { const e = this.app.appHandlers.findIndex((t) => t.remote === this); e > -1 && (this.app.appHandlers.splice(e, 1), this.app.editorHandlers.splice(e, 1)); } handleApp(e) { } handleEditor(e) { } } class bP extends Su { selectDropdown(e, t) { this.app.send({ event: "selectComponent", target: "app", data: { dropdown: e, value: t } }); } updateDropdown(e, t) { this.app.send({ event: "draggableListUpdate", target: "app", data: { dropdown: e, value: t } }); } handleApp(e) { switch (e.event) { case "selectComponent": this.app.dispatchEvent({ type: K.SELECT_DROPDOWN, value: e.data }); break; case "draggableListUpdate": this.app.dispatchEvent({ type: K.DRAG_UPDATE, value: e.data }); break; } } } function TP(a, e, t) { if (a.editor) { t.ui.restore(), t.onSelectionChange((r) => { r.length < 1 || r.forEach((o) => { let l = o.address.sheetId, c = "setSheet", h = {}; switch (o.type) { case "Theatre_Sheet_PublicAPI": c = "setSheet", h = { sheet: o.address.sheetId }, e.activeSheet = e.sheets.get(o.address.sheetId); break; case "Theatre_SheetObject_PublicAPI": c = "setSheetObject", l += `_${o.address.objectKey}`, h = { id: l, sheet: o.address.sheetId, key: o.address.objectKey }, e.activeSheet = e.sheets.get(o.address.sheetId); break; } a.send({ event: c, target: "app", data: h }); }); }); let s = -1; const i = () => { if (e.activeSheet !== void 0 && s !== e.activeSheet.sequence.position) { s = e.activeSheet.sequence.position; const r = e.activeSheet; a.send({ event: "updateTimeline", target: "app", data: { position: s, sheet: r.address.sheetId } }); } }, n = () => { i(), requestAnimationFrame(n); }; i(), n(); } else t.ui.hide(); } async function SP() { for (; !document.getElementById("theatrejs-studio-root"); ) await new Promise((i) => setTimeout(i, 100)); const a = document.getElementById("theatrejs-studio-root"); if (a === null || a.shadowRoot === null) return; const e = a.shadowRoot.getElementById("pointer-root"); if (e === null) return; const t = e.children[0]; if (t === null) return; const s = t.children[1]; s.style.justifyContent = "left"; try { const i = s.children[1]; for (i.style.transform = "translateX(10px)"; i.children.length > 1; ) i.removeChild(i.children[0]); } catch { } try { const i = t.children[3]; i.style.top = "0", i.style.right = "300px"; } catch { } } function T_(a, e, t, s, i) { const n = 1 - a; return n * n * n * e + 3 * n * n * a * t + 3 * n * a * a * s + a * a * a * i; } function S_(a, e, t) { if (a.type !== "bezier" || a.handles.length !== 4) throw new Error("Invalid keyframe data for Bézier interpolation."); const [s, i] = a.handles, n = (t - a.position) / (e.position - a.position); return T_( n, a.value, a.value + s, e.value + i, e.value ); } class vP extends Su { project; sheets = /* @__PURE__ */ new Map(); sheetObjects = /* @__PURE__ */ new Map(); sheetObjectCBs = /* @__PURE__ */ new Map(); sheetObjectUnsubscribe = /* @__PURE__ */ new Map(); activeSheet; studio = void 0; constructor(e) { super(e), window.RemoteTheatre = this; } dispose() { this.project = void 0, this.sheets = /* @__PURE__ */ new Map(), this.sheetObjects = /* @__PURE__ */ new Map(), this.sheetObjectCBs = /* @__PURE__ */ new Map(), this.sheetObjectUnsubscribe = /* @__PURE__ */ new Map(); } getSheetInstance(e, t) { return t !== void 0 ? `${e}-${t}` : e; } sheet(e, t) { if (this.project === void 0) { console.error("Theatre Project hasn't been created yet."); return; } const s = this.getSheetInstance(e, t); let i = this.sheets.get(s); return i !== void 0 || (i = this.project?.sheet(e, t), this.sheets.set(s, i)), i; } playSheet(e, t, s) { return new Promise((i) => { const n = t !== void 0 ? { ...t } : {}; this.sheet(e, s)?.sequence.play(n).then((r) => i(r)), this.app.send({ event: "playSheet", target: "editor", data: { sheet: e, instance: s, value: t } }); }); } pauseSheet(e, t) { this.sheet(e, t)?.sequence.pause(), this.app.send({ event: "pauseSheet", target: "editor", data: { sheet: e, instance: t } }); } clearSheetObjects(e) { this.sheetObjects.forEach((t, s) => { s.search(`${e}_`) > -1 && this.unsubscribe(t); }); } sheetObject(e, t, s, i, n) { if (this.project === void 0) { console.error("Theatre Project hasn't been created yet."); return; } const r = this.sheet(e, n); if (r === void 0) return; const l = `${this.getSheetInstance(e, n)}_${t}`; let c = this.sheetObjects.get(l), h = s; c !== void 0 && (h = { ...s, ...c.value }), c = r.object(t, h), this.sheetObjects.set(l, c), this.sheetObjectCBs.set(l, i !== void 0 ? i : rl); const u = c.onValuesChange((d) => { if (this.app.editor) { for (const f in d) { const m = d[f]; typeof m == "object" && e_(m) && (d[f] = { r: m.r, g: m.g, b: m.b, a: m.a }); } this.app.send({ event: "updateSheetObject", target: "app", data: { sheet: e, sheetObject: l, values: d } }); } const p = this.sheetObjectCBs.get(l); p !== void 0 && p(d); }); return this.sheetObjectUnsubscribe.set(l, u), c; } getSheetObjectKeyframes(e, t, s) { const i = this.sheet(e); if (i === void 0) return []; const n = `${e}_${t}`, r = this.sheetObjects.get(n); return r === void 0 ? [] : i.sequence.__experimental_getKeyframes(r.props[s]); } getSheetObjectVectors(e, t) { const s = this.sheet(e); if (s === void 0) return []; const i = `${e}_${t}`, n = this.sheetObjects.get(i); if (n === void 0) return []; const r = [], o = s.sequence.__experimental_getKeyframes(n.props.x), l = s.sequence.__experimental_getKeyframes(n.props.y), c = s.sequence.__experimental_getKeyframes(n.props.z), h = /* @__PURE__ */ new Set(); return o.forEach((d) => h.add(d.position)), l.forEach((d) => h.add(d.position)), c.forEach((d) => h.add(d.position)), Array.from(h).sort((d, p) => d - p).forEach((d) => { const p = (f, m) => { const y = f.find((_, b) => _.position <= m && (f[b + 1]?.position || 1 / 0) > m), g = f.find((_) => _.position > m); if (!y) return g?.value || 0; if (!g || y.position === m) return y.value; if (y.type === "bezier") return S_(y, g, m); const x = (m - y.position) / (g.position - y.position); return y.value + x * (g.value - y.value); }; r.push({ position: d, x: p(o, d), y: p(l, d), z: p(c, d) }); }), r; } unsubscribe(e) { if (this.project === void 0) { console.error("Theatre Project hasn't been created yet."); return; } const t = e.address.sheetId, s = e.address.objectKey; this.sheets.get(t)?.detachObject(s); const n = `${t}_${s}`, r = this.sheetObjectUnsubscribe.get(n); r !== void 0 && (this.sheetObjects.delete(n), this.sheetObjectCBs.delete(n), this.sheetObjectUnsubscribe.delete(n), r()); } handleApp(e) { let t; switch (e.event) { case "setSheet": t = this.sheets.get(e.data.sheet), t !== void 0 && (this.activeSheet = t, this.studio?.setSelection([t])); break; case "setSheetObject": t = this.sheetObjects.get(`${e.data.sheet}_${e.data.key}`), t !== void 0 && this.studio?.setSelection([t]); break; case "updateSheetObject": t = this.sheets.get(e.data.sheet), t !== void 0 && t.sequence.pause(), t = this.sheetObjectCBs.get(e.data.sheetObject), t !== void 0 && t(e.data.values); break; case "updateTimeline": t = this.sheets.get(e.data.sheet), this.activeSheet !== void 0 && (this.activeSheet.sequence.position = e.data.position); break; } } handleEditor(e) { if (this.app.editor) switch (e.event) { case "playSheet": this.sheet(e.data.sheet, e.data.instance)?.sequence.play(e.data.value); break; case "pauseSheet": this.sheet(e.data.sheet, e.data.instance)?.sequence.pause(); break; } } handleEditorApp() { if (this.app.editor) { this.studio?.ui.restore(), this.studio?.onSelectionChange((i) => { i.length < 1 || i.forEach((n) => { let r = n.address.sheetId, o = "setSheet", l = {}; switch (n.type) { case "Theatre_Sheet_PublicAPI": o = "setSheet", l = { sheet: n.address.sheetId }, this.activeSheet = this.sheets.get(n.address.sheetId); break; case "Theatre_SheetObject_PublicAPI": o = "setSheetObject", r += `_${n.address.objectKey}`, l = { id: r, sheet: n.address.sheetId, key: n.address.objectKey }, this.activeSheet = this.sheets.get(n.address.sheetId); break; } this.app.send({ event: o, target: "app", data: l }); }); }); let e = -1; const t = () => { if (this.activeSheet !== void 0 && e !== this.activeSheet.sequence.position) { e = this.activeSheet.sequence.position; const i = this.activeSheet; this.app.send({ event: "updateTimeline", target: "app", data: { position: e, sheet: i.address.sheetId } }); } }, s = () => { t(), requestAnimationFrame(s); }; t(), s(); } else this.studio?.ui.hide(); } } function v_(a) { if (a.name === "cameras") return "camera"; if (a.name === "interactive") return "interactive"; if (a.name === "lights") return "light"; if (a.name === "ui") return "ui"; if (a.name === "utils") return "utils"; const e = a.type; return e.search("Helper") > -1 ? "icon_utils" : e.search("Camera") > -1 ? "camera" : e.search("Light") > -1 ? "light" : "obj3D"; } function sr(a) { const e = { name: a.name, type: a.type, uuid: a.uuid, children: [] }; return a.children.forEach((t) => { e.children.push(sr(t)); }), e; } function w_(a) { const e = {}; for (const t in a) { const s = a[t].value; e[t] = { value: s }, s === null ? e[t].value = { src: "", offset: [0, 0], repeat: [1, 1] } : s !== void 0 && s.isTexture && (e[t].value = { src: s.image.src, offset: [s.offset.x, s.offset.y], repeat: [s.repeat.x, s.repeat.y] }); } return e; } function E_(a) { switch (a) { case "blendSrcAlpha": case "blendDstAlpha": case "blendEquationAlpha": case "clippingPlanes": case "shadowSide": case "precision": return !0; } return !1; } function On(a) { const e = {}; for (const t in a) { if (t.substring(0, 1) === "_" || t.substring(0, 2) === "is" || E_(t)) continue; const s = typeof a[t], i = a[t]; switch (s) { case "boolean": case "number": case "string": e[t] = i; break; case "object": i !== null ? (e[t] = i, i.isTexture ? e[t] = { src: yn.renderToBlob(i), offset: [i.offset.x, i.offset.y], repeat: [i.repeat.x, i.repeat.y] } : t === "uniforms" && (e[t] = w_(e[t]))) : t === "glslVersion" ? e[t] = "" : e[t] = { src: "", offset: [0, 0], repeat: [1, 1] }; break; } } return a.anisotropy !== void 0 && (e.anisotropy = a.anisotropy), a.clearcoat !== void 0 && (e.clearcoat = a.clearcoat), a.iridescence !== void 0 && (e.iridescence = a.iridescence), a.dispersion !== void 0 && (e.dispersion = a.dispersion), a.sheen !== void 0 && (e.sheen = a.sheen), a.transmission !== void 0 && (e.transmission = a.transmission), a.transmission !== void 0 && (e.transmission = a.transmission), e; } function ac(a) { a.updateMatrix(); const e = { name: a.name, type: a.type, uuid: a.uuid, visible: a.visible, matrix: a.matrix.elements, animations: [], material: void 0, perspectiveCameraInfo: void 0, orthographicCameraInfo: void 0, lightInfo: void 0, children: [] }; a.animations.forEach((s) => { e.animations.push({ name: s.name, duration: s.duration, blendMode: s.blendMode }); }); const t = a.type.toLowerCase(); if (t.search("mesh") > -1) { const s = a; if (Array.isArray(s.material)) { const i = []; s.material.forEach((n) => { i.push(On(n)); }), e.material = i; } else e.material = On(s.material); } else if (t.search("points") > -1) { const s = a; if (Array.isArray(s.material)) { const i = []; s.material.forEach((n) => { i.push(On(n)); }), e.material = i; } else e.material = On(s.material); } else if (t.search("line") > -1) { const s = a; if (Array.isArray(s.material)) { const i = []; s.material.forEach((n) => { i.push(On(n)); }), e.material = i; } else e.material = On(s.material); } else t.search("camera") > -1 ? a.type === "PerspectiveCamera" ? e.perspectiveCameraInfo = { fov: a.fov, zoom: a.zoom, near: a.near, far: a.far, focus: a.focus, aspect: a.aspect, filmGauge: a.filmGauge, filmOffset: a.filmOffset } : a.type === "OrthographicCamera" && (e.orthographicCameraInfo = { zoom: a.zoom, near: a.near, far: a.far, left: a.left, right: a.right, top: a.top, bottom: a.bottom }) : t.search("light") > -1 && (e.lightInfo = { color: a.color, intensity: a.intensity, decay: a.decay, distance: a.distance, angle: a.angle, penumbra: a.penumbra, groundColor: a.groundColor, width: a.width, height: a.height }); return e; } function C_(a, e) { const t = e.split("."); switch (t.length) { case 1: return a[t[0]]; case 2: return a[t[0]][t[1]]; case 3: return a[t[0]][t[1]][t[2]]; case 4: return a[t[0]][t[1]][t[2]][t[3]]; case 5: return a[t[0]][t[1]][t[2]][t[3]][t[4]]; case 6: return a[t[0]][t[1]][t[2]][t[3]][t[4]][t[5]]; } } function M_(a, e) { for (const t in e) a[t] = e[t]; } function Xe(a, e, t) { if (a === void 0) return; const s = e.split("."), i = s.length; if (typeof t != "object") switch (i) { case 1: a[s[0]] = t; break; case 2: a[s[0]][s[1]] = t; break; case 3: a[s[0]][s[1]][s[2]] = t; break; case 4: a[s[0]][s[1]][s[2]][s[3]] = t; break; case 5: a[s[0]][s[1]][s[2]][s[3]][s[4]] = t; break; } else { let r; switch (i) { case 1: r = a[s[0]]; break; case 2: r = a[s[0]][s[1]]; break; case 3: r = a[s[0]][s[1]][s[2]]; break; case 4: r = a[s[0]][s[1]][s[2]][s[3]]; break; case 5: r = a[s[0]][s[1]][s[2]][s[3]][s[4]]; break; } r != null && M_(r, t); } } function ig(a) { return new Promise((e, t) => { const s = new Image(); s.onload = () => { const i = new Rh(s); i.wrapS = zd, i.wrapT = zd, i.needsUpdate = !0, e(i); }, s.onerror = t, s.src = a; }); } class wP extends Su { canvas = null; // Canvas or OffscreenCanvas inputElement = null; // reference this to receive events scene = void 0; scenes = /* @__PURE__ */ new Map(); renderer = void 0; renderTargets = /* @__PURE__ */ new Map(); groups = /* @__PURE__ */ new Map(); constructor(e) { super(e), window.RemoteThree = this; } dispose() { this.scenes.forEach((e) => { hi(e); }), this.scenes.clear(), this.scene && hi(this.scene), this.renderTargets.forEach((e) => { e.dispose(); }), this.renderTargets.clear(), this.renderer?.dispose(); } getObject(e) { this.app.debugEnabled && (this.renderer !== void 0 && (yn.renderer = this.renderer), this.app.send({ event: "getObject", target: "app", data: e })); } setObject(e) { this.renderer !== void 0 && (yn.renderer = this.renderer); const t = ac(e); this.app.send({ event: "setObject", target: "editor", data: t }); } requestMethod(e, t, s, i) { this.app.send({ event: "requestMethod", target: "app", data: { uuid: e, key: t, value: s, subitem: i } }); } updateObject(e, t, s) { this.app.send({ event: "updateObject", target: "app", data: { uuid: e, key: t, value: s }