@tomorrowevening/hermes
Version:
An extendable set of Web Tools controlled via a separate window for non-intereference with content.
40 lines (39 loc) • 879 kB
JavaScript
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("three"),pd=require("postprocessing"),W=require("react"),da=()=>{},f0=()=>{};function pa(a){return a.substring(0,1).toUpperCase()+a.substring(1)}function Qf(a){const e=JSON.stringify(a);return navigator.clipboard.writeText(e),e}function Kf(){return Math.round(Math.random()*1e6).toString()}function Jf(a){return a.r!==void 0&&a.g!==void 0&&a.b!==void 0}function ah(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 Bl(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 m0=["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 fd(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 em=typeof window>"u",Ps=(()=>{if(em)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 g0(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=Ps?.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 md extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}const Il=[],gd=[];function y0(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;)gd[h]=a.charCodeAt(r+h),Il[h]=++h;for(;u<i;)for(n=e.charCodeAt(r+u),o=u++,c=u,h=0;h<s;h++)l=n===gd[h]?o:o+1,o=Il[h],c=Il[h]=o>c?l>c?c+1:l:l>o?o+1:l;return c}function x0(a){return a!=null}const _0=({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"}={})=>Bl(void 0,void 0,void 0,function*(){const r={};if(em)return{tier:0,type:"SSR"};const{isIpad:o=!!Ps?.isIpad,isMobile:l=!!Ps?.isMobile,screenSize:c=window.screen,loadBenchmarks:h=S=>Bl(void 0,void 0,void 0,function*(){const M=yield fetch(`${n}/${S}`).then(w=>w.json());if(parseInt(M.shift().split(".")[0],10)<4)throw new md("Detect GPU benchmark data is out of date. Please update to version 4x");return M})}=t;let{renderer:u}=t;const d=(S,M,w,R,P)=>({device:P,fps:R,gpu:w,isMobile:l,tier:S,type:M});let p,f="";if(u)u=fd(u),p=[u];else{const S=s||function(w,R=!1){const P={alpha:!1,antialias:!1,depth:!1,failIfMajorPerformanceCaveat:R,powerPreference:"high-performance",stencil:!1};w&&delete P.powerPreference;const z=window.document.createElement("canvas"),$=z.getContext("webgl",P)||z.getContext("experimental-webgl",P);return $??void 0}(Ps?.isSafari12,i);if(!S)return d(0,"WEBGL_UNSUPPORTED");const M=Ps?.isFirefox?null:S.getExtension("WEBGL_debug_renderer_info");if(u=M?S.getParameter(M.UNMASKED_RENDERER_WEBGL):S.getParameter(S.RENDERER),!u)return d(1,"FALLBACK");f=u,u=fd(u),p=function(w,R,P){return R==="apple gpu"?g0(w,R,P):[R]}(S,u,l)}const m=(yield Promise.all(p.map(function(S){var M;return Bl(this,void 0,void 0,function*(){const w=(_e=>{const at=l?["adreno","apple","mali-t","mali","nvidia","powervr","samsung"]:["intel","apple","amd","radeon","nvidia","geforce","adreno"];for(const Dt of at)if(_e.includes(Dt))return Dt})(S);if(!w)return;const R=`${l?"m":"d"}-${w}${o?"-ipad":""}.json`,P=r[R]=(M=r[R])!==null&&M!==void 0?M:h(R);let z;try{z=yield P}catch(_e){if(_e instanceof md)throw _e;return}const $=function(_e){var at;const Dt=(_e=_e.replace(/\([^)]+\)/,"")).match(/\d+/)||_e.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return(at=Dt?.join("").replace(/\W|amd/g,""))!==null&&at!==void 0?at:""}(S);let q=z.filter(([,_e])=>_e===$);q.length||(q=z.filter(([_e])=>_e.includes(S)));const j=q.length;if(j===0)return;const X=S.split(/[.,()\[\]/\s]/g).sort().filter((_e,at,Dt)=>at===0||_e!==Dt[at-1]).join(" ");let Z,[ve,,,,ue]=j>1?q.map(_e=>[_e,y0(X,_e[2])]).sort(([,_e],[,at])=>_e-at)[0][0]:q[0],ge=Number.MAX_VALUE;const{devicePixelRatio:ie}=window,we=c.width*ie*c.height*ie;for(const _e of ue){const[at,Dt]=_e,_r=at*Dt,gn=Math.abs(we-_r);gn<ge&&(ge=gn,Z=_e)}if(!Z)return;const[,,ke,rt]=Z;return[ge,ke,ve,rt]})}))).filter(x0).sort(([S=Number.MAX_VALUE,M],[w=Number.MAX_VALUE,R])=>S===w?M-R:S-w);if(!m.length){const S=m0.find(M=>u.includes(M));return S?d(0,"BLOCKLISTED",S):d(1,"FALLBACK",`${u} (${f})`)}const[,y,g,_]=m[0];if(y===-1)return d(0,"BLOCKLISTED",g,y,_);const b=l?a:e;let T=0;for(let S=0;S<b.length;S++)y>=b[S]&&(T=S);return d(T,"BENCHMARK",g,y,_)});var tm=(a=>(a[a.High=0]="High",a[a.Medium=1]="Medium",a[a.Low=2]="Low",a))(tm||{});function sm(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 b0(a,e,t){return new Promise(s=>{_0().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),sm(l=>{o.fps=l,s(o)}),s(o)})})}function Ti(a,e,t){return Math.min(e,Math.max(a,t))}function Uo(a,e,t){return(t-a)/(e-a)}function rr(a,e,t){return a*(1-t)+e*t}function T0(a,e,t,s,i){return rr(t,s,Uo(a,e,i))}function S0(a,e){const t=a-e;return Math.sqrt(t*t)}function ss(a,e=1){return Number(a.toFixed(e))}function v0(a,e,t,s){return rr(a,e,1-Math.exp(-t*s))}function w0(a,e=1){return Number(a.toFixed(e))}function E0(a,e,t,s){return a===e&&t===s}function M0(a,e,t,s){return 1/(3*e*a*a+2*t*a+s)}function C0(a,e,t,s,i){return e*(a*a*a)+t*(a*a)+s*a+i}function A0(a,e,t,s,i){const n=a*a;return e*(n*a)+t*n+s*a+i}function R0(a,e,t,s,i){if(a<=0)return 0;if(a>=1)return 1;if(E0(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,_=3*h-6*l+3*r,b=3*l-3*r,T=r;let S=a;for(let M=0;M<5;M++){const w=C0(S,p,f,m,y);let R=M0(S,p,f,m);R===1/0&&(R=a),S-=(w-a)*R,S=Math.min(Math.max(S,0),1)}return A0(S,g,_,b,T)}const oh=a=>{a?.dispose()},jh=a=>{if(a)if(Array.isArray(a))a.forEach(e=>jh(e));else{for(const e in a){const t=a[e];t!==null&&t instanceof x.Texture&&oh(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 x.Texture&&oh(s.value)}}a.dispose()}},Is=a=>{if(a){for(;a.children.length>0;){const e=a.children[0];e.type==="Audio"?(e.pause(),e.parent&&e.parent.remove(e)):Is(e)}if(a.parent&&a.parent.remove(a),a.isMesh){const e=a;e.geometry?.dispose(),jh(e.material)}a.dispose!==void 0&&a.dispose()}};exports.totalThreeObjects=0;const lh=()=>{exports.totalThreeObjects=0},ko=a=>{if(!a)return;let e=a.name.replaceAll(" ","").replaceAll("/",".");if(e.length===0&&(e=`obj_${exports.totalThreeObjects}`,exports.totalThreeObjects++),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=>ko(t))};class Ri{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 x.OrthographicCamera(-.5,.5,.5,-.5,0,100),this.scene=new x.Scene,this.material=new x.MeshBasicMaterial;const t=new x.BufferGeometry;t.setAttribute("position",new x.Float32BufferAttribute([-.5,-.5,0,1.5,-.5,0,-.5,1.5,0],3)),t.setAttribute("normal",new x.Float32BufferAttribute([0,0,1,0,0,1],3)),t.setAttribute("uv",new x.Float32BufferAttribute([0,0,2,0,0,2],2));const s=new x.Mesh(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=x.LinearSRGBColorSpace,e.colorSpace=x.LinearSRGBColorSpace,this.material.map=e,this.renderer.render(this.scene,this.camera),this.renderer.outputColorSpace=t,e.colorSpace=s}return this.renderer.domElement}}function N0(a){return new Promise(e=>{const t=new x.ObjectLoader;t.parseAsync(a.scene).then(s=>{const i=new x.AnimationMixer(s);if(a.animations.length>0){const r=a.animations.map(l=>x.AnimationClip.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 ch=[];function P0(a,e){Ri.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 pd.EffectPass)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=Ri.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:.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 pd.ShaderPass){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=Ri.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:.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)}}),ch.push(r)})}function F0(a){ch.forEach(e=>{a.removeGroup(e)}),ch=[]}function D0(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 x.WebGLRenderTarget(s,s,{format:x.RGBAFormat,depthBuffer:!0,stencilBuffer:!1});t.outputBuffer=c,_n(a,c,e,"nx",t,s).then(()=>{_n(a,c,e,"ny",t,s).then(()=>{_n(a,c,e,"nz",t,s).then(()=>{_n(a,c,e,"px",t,s).then(()=>{_n(a,c,e,"py",t,s).then(()=>{_n(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 _n(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 bn=qh(["ctrlKey","metaKey","shiftKey","button","pointerId","pointerType","clientX","clientY","pageX","pageY"]),O0=qh(["clientX","clientY","deltaX","deltaY","deltaMode"]),B0=qh(["ctrlKey","metaKey","shiftKey","keyCode"]);function I0(a,e){a.preventDefault(),O0(a,e)}function L0(a){a.preventDefault()}function U0(a,e,t){for(const s of e)t[s]=a[s]}function qh(a){return function(t,s){const i={type:t.type};U0(t,a,i),s(i)}}function Ll(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 k0={37:!0,38:!0,39:!0,40:!0};function z0(a,e){const{keyCode:t}=a;k0[t]&&(a.preventDefault(),B0(a,e))}const G0={contextmenu:L0,mousedown:bn,mousemove:bn,mouseup:bn,pointerdown:bn,pointermove:bn,pointerup:bn,touchstart:Ll,touchmove:Ll,touchend:Ll,wheel:I0,keydown:z0};let V0=0;class H0{id;worker;constructor(e,t,s){this.id=V0++,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 im extends x.EventDispatcher{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}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:()=>({})}}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=da,e.stopPropagation=da,this.dispatchEvent(e)}focus(){}getRootNode(){return this}}class W0{targets={};constructor(){this.handleEvent=this.handleEvent.bind(this)}makeProxy(e){const{id:t}=e,s=new im;this.targets[t]=s}getProxy(e){return this.targets[e]}handleEvent(e){this.targets[e.id]?.handleEvent(e.data)}}var Q=(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))(Q||{});class $0 extends x.EventDispatcher{components=new Map;appHandlers=[];editorHandlers=[];_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()}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};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 j0{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)}onResize=e=>{this.resize(e.width,e.height)};onUpdate=()=>{this.update(),this.draw(),this.rafID=requestAnimationFrame(this.onUpdate)}}class q0 extends x.Scene{clock;cameras;lights;world;constructor(e){super(),this.name=e,this.clock=new x.Clock,this.lights=new x.Group,this.lights.name="lights",this.add(this.lights),this.cameras=new x.Group,this.cameras.name="cameras",this.add(this.cameras),this.world=new x.Group,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(){}get deltaTime(){return Math.min(this.clock.getDelta(),1/30)}}class ol{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 Y0 extends ol{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:Q.SELECT_DROPDOWN,value:e.data});break;case"draggableListUpdate":this.app.dispatchEvent({type:Q.DRAG_UPDATE,value:e.data});break}}}function X0(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 Z0(){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 Q0(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 K0(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 Q0(n,a.value,a.value+s,e.value+i,e.value)}class J0 extends ol{project;sheets=new Map;sheetObjects=new Map;sheetObjectCBs=new Map;sheetObjectUnsubscribe=new Map;activeSheet;studio=void 0;constructor(e){super(e),window.RemoteTheatre=this}dispose(){this.project=void 0,this.sheets=new Map,this.sheetObjects=new Map,this.sheetObjectCBs=new Map,this.sheetObjectUnsubscribe=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:da);const u=c.onValuesChange(d=>{if(this.app.editor){for(const f in d){const m=d[f];typeof m=="object"&&Jf(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=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,T)=>b.position<=m&&(f[T+1]?.position||1/0)>m),g=f.find(b=>b.position>m);if(!y)return g?.value||0;if(!g||y.position===m)return y.value;if(y.type==="bezier")return K0(y,g,m);const _=(m-y.position)/(g.position-y.position);return y.value+_*(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 ex(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 Hn(a){const e={name:a.name,type:a.type,uuid:a.uuid,children:[]};return a.children.forEach(t=>{e.children.push(Hn(t))}),e}function tx(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 sx(a){switch(a){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function Tn(a){const e={};for(const t in a){if(t.substring(0,1)==="_"||t.substring(0,2)==="is"||sx(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:Ri.renderToBlob(i),offset:[i.offset.x,i.offset.y],repeat:[i.repeat.x,i.repeat.y]}:t==="uniforms"&&(e[t]=tx(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 Ul(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(Tn(n))}),e.material=i}else e.material=Tn(s.material)}else if(t.search("points")>-1){const s=a;if(Array.isArray(s.material)){const i=[];s.material.forEach(n=>{i.push(Tn(n))}),e.material=i}else e.material=Tn(s.material)}else if(t.search("line")>-1){const s=a;if(Array.isArray(s.material)){const i=[];s.material.forEach(n=>{i.push(Tn(n))}),e.material=i}else e.material=Tn(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 ix(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 nx(a,e){for(const t in e)a[t]=e[t]}function qe(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&&nx(r,t)}}function nm(a){return new Promise((e,t)=>{const s=new Image;s.onload=()=>{const i=new x.Texture(s);i.wrapS=x.RepeatWrapping,i.wrapT=x.RepeatWrapping,i.needsUpdate=!0,e(i)},s.onerror=t,s.src=a})}class rx extends ol{canvas=null;inputElement=null;scene=void 0;scenes=new Map;renderer=void 0;renderTargets=new Map;groups=new Map;constructor(e){super(e),window.RemoteThree=this}dispose(){this.scenes.forEach(e=>{Is(e)}),this.scenes.clear(),this.scene&&Is(this.scene),this.renderTargets.forEach(e=>{e.dispose()}),this.renderTargets.clear(),this.renderer?.dispose()}getObject(e){this.app.debugEnabled&&(this.renderer!==void 0&&(Ri.renderer=this.renderer),this.app.send({event:"getObject",target:"app",data:e}))}setObject(e){this.renderer!==void 0&&(Ri.renderer=this.renderer);const t=Ul(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}})}createTexture(e,t,s){this.app.send({event:"createTexture",target:"app",data:{uuid:e,key:t,value:s}})}addGroup(e){this.groups.get(e.title)===void 0&&(this.groups.set(e.title,{title:e.title,onUpdate:e.onUpdate}),this.app.send({event:"addGroup",target:"editor",data:JSON.stringify(e)}))}removeGroup(e){this.groups.get(e)!==void 0&&(this.groups.delete(e),this.app.send({event:"removeGroup",target:"editor",data:e}))}updateGroup(e,t,s){this.app.send({event:"updateGroup",target:"app",data:JSON.stringify({group:e,prop:t,value:s})})}removeAllGroups(){this.groups.forEach(e=>{const t=e.title;this.groups.delete(t),this.app.send({event:"removeGroup",target:"editor",data:t})}),this.groups.clear()}addSpline(e){setTimeout(()=>{this.app.send({event:"addSpline",target:"editor",data:JSON.stringify(e.toJSON())})},1)}setRenderer(e,t=null){if(this.renderer=e,this.canvas=e.domElement,this.inputElement=t!==null?t:this.canvas,!this.app.debugEnabled)return;const s=`#${e.getClearColor(new x.Color).getHexString()}`;this.app.send({event:"addRenderer",target:"editor",data:{autoClear:e.autoClear,autoClearColor:e.autoClearColor,autoClearDepth:e.autoClearDepth,autoClearStencil:e.autoClearStencil,outputColorSpace:e.outputColorSpace,localClippingEnabled:e.localClippingEnabled,clearColor:s,clearAlpha:e.getClearAlpha(),colorManagement:x.ColorManagement.enabled,toneMapping:e.toneMapping,toneMappingExposure:e.toneMappingExposure,type:e.isWebGLRenderer?"WebGLRenderer":"WebGPURenderer"}})}updateRenderer(e){this.app.send({event:"updateRenderer",target:"app",data:e})}addScene(e){if(e===void 0||(this.scenes.set(e.name,e),!this.app.debugEnabled))return;lh(),ko(e);const t=Hn(e);this.app.send({event:"addScene",target:"editor",data:t})}refreshScene(e){if(!this.app.debugEnabled)return;const t=this.scenes.get(e);if(t!==void 0){const s=Hn(t);this.app.send({event:"refreshScene",target:"app",data:s})}}removeScene(e){if(e===void 0||(this.scenes.delete(e.name),!this.app.debugEnabled))return;const t=Hn(e);this.app.send({event:"removeScene",target:"editor",data:t})}removeAllScenes(){this.scenes.forEach(e=>this.removeScene(e))}getScene(e){let t=null;return this.scenes.forEach((s,i)=>{e.search(i)>-1&&(t=s)}),t}setScene(e){if(e===void 0||(this.scene=e,!this.app.debugEnabled))return;this.renderer!==void 0&&(Ri.renderer=this.renderer),lh(),ko(e);const t=Hn(e);this.app.send({event:"setScene",target:"editor",data:t})}addCamera(e){if(!this.app.debugEnabled)return;const t=Ul(e);this.app.send({event:"addCamera",target:"editor",data:t})}removeCamera(e){if(!this.app.debugEnabled)return;const t=Ul(e);this.app.send({event:"removeCamera",target:"editor",data:t})}handleApp(e){switch(e.event){case"getObject":this.app.dispatchEvent({type:Q.GET_OBJECT,value:e.data});break;case"updateObject":this.app.dispatchEvent({type:Q.UPDATE_OBJECT,value:e.data});break;case"createTexture":this.app.dispatchEvent({type:Q.CREATE_TEXTURE,value:e.data});break;case"requestMethod":this.app.dispatchEvent({type:Q.REQUEST_METHOD,value:e.data});break;case"refreshScene":this.app.send({event:"refreshScene",target:"editor",data:Hn(this.scenes.get(e.data.name))});break;case"updateRenderer":this.renderer&&(this.renderer.autoClearColor=e.data.autoClearColor,this.renderer.outputColorSpace=e.data.outputColorSpace,this.renderer.localClippingEnabled=e.data.localClippingEnabled,this.renderer.setClearColor(e.data.clearColor,e.data.clearAlpha),this.renderer.toneMapping=e.data.toneMapping,this.renderer.toneMappingExposure=e.data.toneMappingExposure,x.ColorManagement.enabled=e.data.colorManagement);break}if(e.event==="updateGroup"){const t=JSON.parse(e.data);this.groups.get(t.group)?.onUpdate(t.prop,t.value)}}handleEditor(e){switch(e.event){case"setObject":this.app.dispatchEvent({type:Q.SET_OBJECT,value:e.data});break;case"addScene":this.app.dispatchEvent({type:Q.ADD_SCENE,value:e.data});break;case"refreshScene":this.app.dispatchEvent({type:Q.REFRESH_SCENE,value:e.data});break;case"removeScene":this.app.dispatchEvent({type:Q.REMOVE_SCENE,value:e.data});break;case"setScene":this.app.dispatchEvent({type:Q.SET_SCENE,value:e.data});break;case"addCamera":this.app.dispatchEvent({type:Q.ADD_CAMERA,value:e.data});break;case"removeCamera":this.app.dispatchEvent({type:Q.REMOVE_CAMERA,value:e.data});break;case"addGroup":this.app.dispatchEvent({type:Q.ADD_GROUP,value:e.data});break;case"removeGroup":this.app.dispatchEvent({type:Q.REMOVE_GROUP,value:e.data});break;case"addSpline":this.app.dispatchEvent({type:Q.ADD_SPLINE,value:e.data});break;case"addRenderer":this.app.dispatchEvent({type:Q.ADD_RENDERER,value:e.data})}}addRT(e,t){const s=new x.WebGLRenderTarget(32,32,t);s.texture.name=e,this.renderTargets.set(e,s)}resize(e,t){const s=this.dpr;this.renderTargets.forEach(n=>{n.setSize(e*s,t*s)});const i=!(this.renderer?.domElement instanceof OffscreenCanvas);this.renderer?.setSize(e,t,i)}set dpr(e){this.renderer?.setPixelRatio(Ti(1,2,e))}get dpr(){return this.renderer!==void 0?this.renderer?.getPixelRatio():1}get width(){return this.renderer!==void 0?this.renderer.domElement.width/this.dpr:0}get height(){return this.renderer!==void 0?this.renderer.domElement.height/this.dpr:0}}var Fa={exports:{}},Tr={};/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var yd;function ax(){if(yd)return Tr;yd=1;var a=W,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,i=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,n={key:!0,ref:!0,__self:!0,__source:!0};function r(o,l,c){var h,u={},d=null,p=null;c!==void 0&&(d=""+c),l.key!==void 0&&(d=""+l.key),l.ref!==void 0&&(p=l.ref);for(h in l)s.call(l,h)&&!n.hasOwnProperty(h)&&(u[h]=l[h]);if(o&&o.defaultProps)for(h in l=o.defaultProps,l)u[h]===void 0&&(u[h]=l[h]);return{$$typeof:e,type:o,key:d,ref:p,props:u,_owner:i.current}}return Tr.Fragment=t,Tr.jsx=r,Tr.jsxs=r,Tr}var Sr={};/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var xd;function ox(){return xd||(xd=1,process.env.NODE_ENV!=="production"&&function(){var a=W,e=Symbol.for("react.element"),t=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),n=Symbol.for("react.profiler"),r=Symbol.for("react.provider"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),u=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),f=Symbol.iterator,m="@@iterator";function y(v){if(v===null||typeof v!="object")return null;var G=f&&v[f]||v[m];return typeof G=="function"?G:null}var g=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function _(v){{for(var G=arguments.length,Y=new Array(G>1?G-1:0),te=1;te<G;te++)Y[te-1]=arguments[te];b("error",v,Y)}}function b(v,G,Y){{var te=g.ReactDebugCurrentFrame,Me=te.getStackAddendum();Me!==""&&(G+="%s",Y=Y.concat([Me]));var Fe=Y.map(function(ye){return String(ye)});Fe.unshift("Warning: "+G),Function.prototype.apply.call(console[v],console,Fe)}}var T=!1,S=!1,M=!1,w=!1,R=!1,P;P=Symbol.for("react.module.reference");function z(v){return!!(typeof v=="string"||typeof v=="function"||v===s||v===n||R||v===i||v===c||v===h||w||v===p||T||S||M||typeof v=="object"&&v!==null&&(v.$$typeof===d||v.$$typeof===u||v.$$typeof===r||v.$$typeof===o||v.$$typeof===l||v.$$typeof===P||v.getModuleId!==void 0))}function $(v,G,Y){var te=v.displayName;if(te)return te;var Me=G.displayName||G.name||"";return Me!==""?Y+"("+Me+")":Y}function q(v){return v.displayName||"Context"}function j(v){if(v==null)return null;if(typeof v.tag=="number"&&_("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof v=="function")return v.displayName||v.name||null;if(typeof v=="string")return v;switch(v){case s:return"Fragment";case t:return"Portal";case n:return"Profiler";case i:return"StrictMode";case c:return"Suspense";case h:return"SuspenseList"}if(typeof v=="object")switch(v.$$typeof){case o:var G=v;return q(G)+".Consumer";case r:var Y=v;return q(Y._context)+".Provider";case l:return $(v,v.render,"ForwardRef");case u:var te=v.displayName||null;return te!==null?te:j(v.type)||"Memo";case d:{var Me=v,Fe=Me._payload,ye=Me._init;try{return j(ye(Fe))}catch{return null}}}return null}var X=Object.assign,Z=0,ve,ue,ge,ie,we,ke,rt;function _e(){}_e.__reactDisabledLog=!0;function at(){{if(Z===0){ve=console.log,ue=console.info,ge=console.warn,ie=console.error,we=console.group,ke=console.groupCollapsed,rt=console.groupEnd;var v={configurable:!0,enumerable:!0,value:_e,writable:!0};Object.defineProperties(console,{info:v,log:v,warn:v,error:v,group:v,groupCollapsed:v,groupEnd:v})}Z++}}function Dt(){{if(Z--,Z===0){var v={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:X({},v,{value:ve}),info:X({},v,{value:ue}),warn:X({},v,{value:ge}),error:X({},v,{value:ie}),group:X({},v,{value:we}),groupCollapsed:X({},v,{value:ke}),groupEnd:X({},v,{value:rt})})}Z<0&&_("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var _r=g.ReactCurrentDispatcher,gn;function Aa(v,G,Y){{if(gn===void 0)try{throw Error()}catch(Me){var te=Me.stack.trim().match(/\n( *(at )?)/);gn=te&&te[1]||""}return`
`+gn+v}}var Rl=!1,Ra;{var Hy=typeof WeakMap=="function"?WeakMap:Map;Ra=new Hy}function Ku(v,G){if(!v||Rl)return"";{var Y=Ra.get(v);if(Y!==void 0)return Y}var te;Rl=!0;var Me=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Fe;Fe=_r.current,_r.current=null,at();try{if(G){var ye=function(){throw Error()};if(Object.defineProperty(ye.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ye,[])}catch(Ot){te=Ot}Reflect.construct(v,[],ye)}else{try{ye.call()}catch(Ot){te=Ot}v.call(ye.prototype)}}else{try{throw Error()}catch(Ot){te=Ot}v()}}catch(Ot){if(Ot&&te&&typeof Ot.stack=="string"){for(var fe=Ot.stack.split(`
`),vt=te.stack.split(`
`),je=fe.length-1,Ze=vt.length-1;je>=1&&Ze>=0&&fe[je]!==vt[Ze];)Ze--;for(;je>=1&&Ze>=0;je--,Ze--)if(fe[je]!==vt[Ze]){if(je!==1||Ze!==1)do if(je--,Ze--,Ze<0||fe[je]!==vt[Ze]){var Kt=`
`+fe[je].replace(" at new "," at ");return v.displayName&&Kt.includes("<anonymous>")&&(Kt=Kt.replace("<anonymous>",v.displayName)),typeof v=="function"&&Ra.set(v,Kt),Kt}while(je>=1&&Ze>=0);break}}}finally{Rl=!1,_r.current=Fe,Dt(),Error.prepareStackTrace=Me}var xn=v?v.displayName||v.name:"",ki=xn?Aa(xn):"";return typeof v=="function"&&Ra.set(v,ki),ki}function Wy(v,G,Y){return Ku(v,!1)}function $y(v){var G=v.prototype;return!!(G&&G.isReactComponent)}function Na(v,G,Y){if(v==null)return"";if(typeof v=="function")return Ku(v,$y(v));if(typeof v=="string")return Aa(v);switch(v){case c:return Aa("Suspense");case h:return Aa("SuspenseList")}if(typeof v=="object")switch(v.$$typeof){case l:return Wy(v.render);case u:return Na(v.type,G,Y);case d:{var te=v,Me=te._payload,Fe=te._init;try{return Na(Fe(Me),G,Y)}catch{}}}return""}var br=Object.prototype.hasOwnProperty,Ju={},ed=g.ReactDebugCurrentFrame;function Pa(v){if(v){var G=v._owner,Y=Na(v.type,v._source,G?G.type:null);ed.setExtraStackFrame(Y)}else ed.setExtraStackFrame(null)}function jy(v,G,Y,te,Me){{var Fe=Function.call.bind(br);for(var ye in v)if(Fe(v,ye)){var fe=void 0;try{if(typeof v[ye]!="function"){var vt=Error((te||"React class")+": "+Y+" type `"+ye+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof v[ye]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw vt.name="Invariant Violation",vt}fe=v[ye](G,ye,te,Y,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(je){fe=je}fe&&!(fe instanceof Error)&&(Pa(Me),_("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",te||"React class",Y,ye,typeof fe),Pa(null)),fe instanceof Error&&!(fe.message in Ju)&&(Ju[fe.message]=!0,Pa(Me),_("Failed %s type: %s",Y,fe.message),Pa(null))}}}var qy=Array.isArray;function Nl(v){return qy(v)}function Yy(v){{var G=typeof Symbol=="function"&&Symbol.toStringTag,Y=G&&v[Symbol.toStringTag]||v.constructor.name||"Object";return Y}}function Xy(v){try{return td(v),!1}catch{return!0}}function td(v){return""+v}function sd(v){if(Xy(v))return _("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Yy(v)),td(v)}var id=g.ReactCurrentOwner,Zy={key:!0,ref:!0,__self:!0,__source:!0},nd,rd;function Qy(v){if(br.call(v,"ref")){var G=Object.getOwnPropertyDescriptor(v,"ref").get;if(G&&G.isReactWarning)return!1}return v.ref!==void 0}function Ky(v){if(br.call(v,"key")){var G=Object.getOwnPropertyDescriptor(v,"key").get;if(G&&G.isReactWarning)return!1}return v.key!==void 0}function Jy(v,G){typeof v.ref=="string"&&id.current}function e0(v,G){{var Y=function(){nd||(nd=!0,_("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",G))};Y.isReactWarning=!0,Object.defineProperty(v,"key",{get:Y,configurable:!0})}}function t0(v,G){{var Y=function(){rd||(rd=!0,_("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",G))};Y.isReactWarning=!0,Object.defineProperty(v,"ref",{get:Y,configurable:!0})}}var s0=function(v,G,Y,te,Me,Fe,ye){var fe={$$typeof:e,type:v,key:G,ref:Y,props:ye,_owner:Fe};return fe._store={},Object.defineProperty(fe._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(fe,"_self",{configurable:!1,enumerable:!1,writable:!1,value:te}),Object.defineProperty(fe,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Me}),Object.freeze&&(Object.freeze(fe.props),Object.freeze(fe)),fe};function i0(v,G,Y,te,Me){{var Fe,ye={},fe=null,vt=null;Y!==void 0&&(sd(Y),fe=""+Y),Ky(G)&&(sd(G.key),fe=""+G.key),Qy(G)&&(vt=G.ref,Jy(G,Me));for(Fe in G)br.call(G,Fe)&&!Zy.hasOwnProperty(Fe)&&(ye[Fe]=G[Fe]);if(v&&v.defaultProps){var je=v.defaultProps;for(Fe in je)ye[Fe]===void 0&&(ye[Fe]=je[Fe])}if(fe||vt){var Ze=typeof v=="function"?v.displayName||v.name||"Unknown":v;fe&&e0(ye,Ze),vt&&t0(ye,Ze)}return s0(v,fe,vt,Me,te,id.current,ye)}}var Pl=g.ReactCurrentOwner,ad=g.ReactDebugCurrentFrame;function yn(v){if(v){var G=v._owner,Y=Na(v.type,v._source,G?G.type:null);ad.setExtraStackFrame(Y)}else ad.setExtraStackFrame(null)}var Fl;Fl=!1;function Dl(v){return typeof v=="object"&&v!==null&&v.$$typeof===e}function od(){{if(Pl.current){var v=j(Pl.current.type);if(v)return`
Check the render method of \``+v+"`."}return""}}function n0(v){return""}var ld={};function r0(v){{var G=od();i