@tomorrowevening/hermes 0.0.151 → 0.0.153
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +78 -2
- package/dist/hermes.cjs.js +5 -3
- package/dist/hermes.es.js +15 -8
- package/package.json +1 -1
- package/types/core/remote/RemoteTheatre.d.ts +36 -36
- package/types/utils/detectSettings.d.ts +19 -18
package/README.md
CHANGED
|
@@ -1,9 +1,85 @@
|
|
|
1
1
|
# Hermes
|
|
2
2
|
|
|
3
|
-
An extendable set of Web Tools controlled
|
|
3
|
+
An extendable set of Web Tools controlled over a separate window for non-intereference with content (like a remote controller!)
|
|
4
4
|
|
|
5
5
|
Open the [Application](https://hermes-lovat.vercel.app/) and [editor](https://hermes-lovat.vercel.app/#editor) side-by-side.
|
|
6
6
|
|
|
7
|
+
## Setup
|
|
8
|
+
|
|
9
|
+
This example uses [React](https://react.dev/), [ThreeJS](https://threejs.org/), and [TheatreJS](https://theatrejs.com/), and will default to using `BroadcastChannel` instead of `WebSocket` for simplicity.
|
|
10
|
+
|
|
11
|
+
### Create an `Application`
|
|
12
|
+
|
|
13
|
+
This acts as the Remote Controller between all components.
|
|
14
|
+
|
|
15
|
+
The `CustomEditor` is used as a multi-view editor for [ThreeJS](https://threejs.org/), and should be limited to only the Editor app.
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
export default function AppWrapper() {
|
|
19
|
+
const [app, setApp] = useState<Application | null>(null);
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const IS_DEV = true;
|
|
23
|
+
const IS_EDITOR = IS_DEV && document.location.hash.search('editor') > -1;
|
|
24
|
+
const instance = new Application('My App');
|
|
25
|
+
instance.detectSettings(IS_DEV, IS_EDITOR).then(() => {
|
|
26
|
+
if (IS_DEV) instance.setupRemote();
|
|
27
|
+
instance.addComponent('theatre', new RemoteTheatre(instance));
|
|
28
|
+
instance.addComponent('three', new RemoteThree(instance));
|
|
29
|
+
setApp(instance);
|
|
30
|
+
});
|
|
31
|
+
}, []);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<>
|
|
35
|
+
{app !== null && (
|
|
36
|
+
<>
|
|
37
|
+
{app.debugEnabled && <RemoteSetup app={app} />}
|
|
38
|
+
{app.editor && <CustomEditor app={app} />}
|
|
39
|
+
<Wrapper app={app} />
|
|
40
|
+
</>
|
|
41
|
+
)}
|
|
42
|
+
</>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Custom remote commands
|
|
48
|
+
|
|
49
|
+
This component is added only in debug-mode to add extra support for remote-components.
|
|
50
|
+
|
|
51
|
+
In this example it's added to add custom Remote Component support for:
|
|
52
|
+
|
|
53
|
+
- [ThreeJS](https://threejs.org/) - `SceneInspector` communicates with the Multi-view editor
|
|
54
|
+
- [TheatreJS](https://theatrejs.com/) - Communicates with the `studio` instance
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
type RemoteProps = {
|
|
58
|
+
app: Application
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default function RemoteSetup(props: RemoteProps) {
|
|
62
|
+
const app = props.app;
|
|
63
|
+
const three = app.components.get('three') as RemoteThree;
|
|
64
|
+
|
|
65
|
+
// Remote Theatre setup
|
|
66
|
+
const theatre = app.components.get('theatre') as RemoteTheatre;
|
|
67
|
+
theatre.studio = studio;
|
|
68
|
+
theatre.handleEditorApp();
|
|
69
|
+
|
|
70
|
+
// Custom component support (optional)
|
|
71
|
+
app.addComponent('components', new RemoteComponents(app));
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<>
|
|
75
|
+
{app.debugEnabled ? <SceneInspector app={app} three={three} /> : null}
|
|
76
|
+
</>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Editor
|
|
82
|
+
|
|
7
83
|
### Tools for:
|
|
8
84
|
|
|
9
85
|
- Customizable Navigation Dropdowns + Draggable components for Triggers/Event Dispatching
|
|
@@ -11,7 +87,7 @@ Open the [Application](https://hermes-lovat.vercel.app/) and [editor](https://he
|
|
|
11
87
|
- [ThreeJS](https://threejs.org/)
|
|
12
88
|
- Custom ThreeJS Scene + Object Inspector
|
|
13
89
|
|
|
14
|
-
###
|
|
90
|
+
### ThreeJS Editor
|
|
15
91
|
|
|
16
92
|
| Action | Keys |
|
|
17
93
|
| ------ | ------ |
|
package/dist/hermes.cjs.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);
|
|
16
16
|
gl_FragColor = enc;
|
|
17
17
|
}
|
|
18
|
-
`,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 gd extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}const Il=[],yd=[];function _0(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),Il[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=Il[h],c=Il[h]=o>c?l>c?c+1:l:l>o?o+1:l;return c}function b0(a){return a!=null}const T0=({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(tm)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 gd("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=md(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=md(u),p=function(w,R,P){return R==="apple gpu"?x0(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 Ft of at)if(_e.includes(Ft))return Ft})(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 gd)throw _e;return}const $=function(_e){var at;const Ft=(_e=_e.replace(/\([^)]+\)/,"")).match(/\d+/)||_e.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return(at=Ft?.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,Ft)=>at===0||_e!==Ft[at-1]).join(" ");let Z,[ve,,,,ue]=j>1?q.map(_e=>[_e,_0(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,Ft]=_e,_r=at*Ft,gn=Math.abs(we-_r);gn<ge&&(ge=gn,Z=_e)}if(!Z)return;const[,,ke,rt]=Z;return[ge,ke,ve,rt]})}))).filter(b0).sort(([S=Number.MAX_VALUE,M],[w=Number.MAX_VALUE,R])=>S===w?M-R:S-w);if(!m.length){const S=y0.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 jh=(a=>(a[a.High=0]="High",a[a.Medium=1]="Medium",a[a.Low=2]="Low",a))(jh||{});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 im(a=!1,e=!1){return new Promise(t=>{T0().then(s=>{let i=!1;const n=document.createElement("canvas"),r=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);if(i="transferControlToOffscreen"in n,r){const l=navigator.userAgent.match(/version\/(\d+)/i);i=(l?parseInt(l[1]):0)>=17}const o={dpr:devicePixelRatio,fps:30,width:innerWidth,height:innerHeight,mobile:s.isMobile!==void 0?s.isMobile:!1,supportOffScreenCanvas:i,quality:2,dev:a,editor:e};s.tier===3?o.quality=0:s.tier===2&&(o.quality=1),sm(l=>{o.fps=l,t(o)}),t(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 S0(a,e,t,s,i){return rr(t,s,Uo(a,e,i))}function v0(a,e){const t=a-e;return Math.sqrt(t*t)}function ss(a,e=1){return Number(a.toFixed(e))}function w0(a,e,t,s){return rr(a,e,1-Math.exp(-t*s))}function E0(a,e=1){return Number(a.toFixed(e))}function M0(a,e,t,s){return a===e&&t===s}function C0(a,e,t,s){return 1/(3*e*a*a+2*t*a+s)}function A0(a,e,t,s,i){return e*(a*a*a)+t*(a*a)+s*a+i}function R0(a,e,t,s,i){const n=a*a;return e*(n*a)+t*n+s*a+i}function N0(a,e,t,s,i){if(a<=0)return 0;if(a>=1)return 1;if(M0(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=A0(S,p,f,m,y);let R=C0(S,p,f,m);R===1/0&&(R=a),S-=(w-a)*R,S=Math.min(Math.max(S,0),1)}return R0(S,g,_,b,T)}const oh=a=>{a?.dispose()},qh=a=>{if(a)if(Array.isArray(a))a.forEach(e=>qh(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()}},ii=a=>{if(a){for(;a.children.length>0;){const e=a.children[0];e.type==="Audio"?(e.pause(),e.parent&&e.parent.remove(e)):ii(e)}if(a.parent&&a.parent.remove(a),a.isMesh){const e=a;e.geometry?.dispose(),qh(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 P0(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 D0(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 fd.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 fd.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 O0(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=Yh(["ctrlKey","metaKey","shiftKey","button","pointerId","pointerType","clientX","clientY","pageX","pageY"]),B0=Yh(["clientX","clientY","deltaX","deltaY","deltaMode"]),I0=Yh(["ctrlKey","metaKey","shiftKey","keyCode"]);function L0(a,e){a.preventDefault(),B0(a,e)}function U0(a){a.preventDefault()}function k0(a,e,t){for(const s of e)t[s]=a[s]}function Yh(a){return function(t,s){const i={type:t.type};k0(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 z0={37:!0,38:!0,39:!0,40:!0};function G0(a,e){const{keyCode:t}=a;z0[t]&&(a.preventDefault(),I0(a,e))}const V0={contextmenu:U0,mousedown:bn,mousemove:bn,mouseup:bn,pointerdown:bn,pointermove:bn,pointerup:bn,touchstart:Ll,touchmove:Ll,touchend:Ll,wheel:L0,keydown:G0};let H0=0;class W0{id;worker;constructor(e,t,s){this.id=H0++,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 nm 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 $0{targets={};constructor(){this.handleEvent=this.handleEvent.bind(this)}makeProxy(e){const{id:t}=e,s=new nm;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 j0 extends x.EventDispatcher{assets={audio:new Map,image:new Map,json:new Map,model:new Map,video:new Map};components=new Map;settings={dpr:1,fps:30,width:0,height:0,mobile:!1,supportOffScreenCanvas:!1,quality:jh.Low,dev:!1,editor:!1};appHandlers=[];editorHandlers=[];onUpdateCallback;_appID="";_mode="app";_broadcastChannel=void 0;_webSocket=void 0;_connected=!1;_useBC=!1;playing=!1;rafID=-1;constructor(e){super(),this._appID=e}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()}detectSettings(e=!1,t=!1){return this._mode=t?"editor":"app",new Promise(s=>{im(e,t).then(i=>{this.settings=i,s()})})}update(){}draw(){}play=()=>{this.playing||(this.playing=!0,this.onUpdate())};pause=()=>{this.playing&&(this.playing=!1,cancelAnimationFrame(this.rafID),this.rafID=-1)};onUpdate=()=>{this.update(),this.isApp&&this.draw(),this.onUpdateCallback&&this.onUpdateCallback(),this.rafID=requestAnimationFrame(this.onUpdate)};setupRemote(e=!0){this.settings.dev&&(this._useBC=e,e?(this._broadcastChannel=new BroadcastChannel(this._appID),this._broadcastChannel.addEventListener("message",this.messageHandler)):(this._webSocket=new WebSocket(this._appID),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)}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.settings.dev}get mode(){return this._mode}get isApp(){return!this.editor}set isApp(e){this.editor=!e}get editor(){return this.settings.editor}set editor(e){this.settings.editor=e,this._mode=e?"editor":"app"}}class q0{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 Y0 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 X0 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 Z0(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 Q0(){for(;!document.getElementById("theatrejs-studio-root");)await new Promise(s=>setTimeout(s,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){try{const i=t.children[1].children[1];i.parentElement?.removeChild(i)}catch{}try{const s=t.children[3];s.style.top="0",s.style.right="300px"}catch{}}}function K0(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 J0(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 K0(n,a.value,a.value+s,e.value+i,e.value)}class ex extends ol{project;sheets=new Map;sheetObjects=new Map;sheetObjectCBs=new Map;sheetObjectUnsubscribe=new Map;activeSheet;studio=void 0;rafDriver=void 0;constructor(e,t=!1){super(e),t&&(this.rafDriver=m0.createRafDriver())}dispose(){this.project=void 0,this.sheets=new Map,this.sheetObjects=new Map,this.sheetObjectCBs=new Map,this.sheetObjectUnsubscribe=new Map}update(){this.rafDriver?.tick(performance.now())}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}:{};n.rafDriver=this.rafDriver,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"&&em(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)},this.rafDriver);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 J0(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 tx(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 sx(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 ix(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"||ix(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]=sx(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 nx(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 rx(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&&rx(r,t)}}function rm(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 ax extends ol{canvas=null;inputElement=null;scene=void 0;scenes=new Map;renderer=void 0;renderTargets=new Map;renderTargetsResize=new Map;groups=new Map;dispose(){this.scenes.forEach(e=>{ii(e)}),this.scenes.clear(),this.scene&&ii(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=!0,s){const i=new x.WebGLRenderTarget(32,32,s);i.texture.name=e,this.renderTargets.set(e,i),this.renderTargetsResize.set(e,t)}removeRT(e){this.renderTargets.delete(e),this.renderTargetsResize.delete(e)}resize(e,t){const s=this.dpr;this.renderTargets.forEach((n,r)=>{this.renderTargetsResize.get(r)&&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 Da={exports:{}},Tr={};/**
|
|
18
|
+
`,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 gd extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}const Il=[],yd=[];function _0(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),Il[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=Il[h],c=Il[h]=o>c?l>c?c+1:l:l>o?o+1:l;return c}function b0(a){return a!=null}const T0=({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(tm)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 gd("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=md(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=md(u),p=function(w,R,P){return R==="apple gpu"?x0(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 Ft of at)if(_e.includes(Ft))return Ft})(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 gd)throw _e;return}const $=function(_e){var at;const Ft=(_e=_e.replace(/\([^)]+\)/,"")).match(/\d+/)||_e.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return(at=Ft?.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,Ft)=>at===0||_e!==Ft[at-1]).join(" ");let Z,[ve,,,,ue]=j>1?q.map(_e=>[_e,_0(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,Ft]=_e,_r=at*Ft,gn=Math.abs(we-_r);gn<ge&&(ge=gn,Z=_e)}if(!Z)return;const[,,ke,rt]=Z;return[ge,ke,ve,rt]})}))).filter(b0).sort(([S=Number.MAX_VALUE,M],[w=Number.MAX_VALUE,R])=>S===w?M-R:S-w);if(!m.length){const S=y0.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 jh=(a=>(a[a.High=0]="High",a[a.Medium=1]="Medium",a[a.Low=2]="Low",a))(jh||{});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 im(a=!1,e=!1){return new Promise(t=>{T0().then(s=>{let i=!1;const n=document.createElement("canvas"),r=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);if(i="transferControlToOffscreen"in n,r){const l=navigator.userAgent.match(/version\/(\d+)/i);i=(l?parseInt(l[1]):0)>=17}const o={dpr:devicePixelRatio,fps:30,width:innerWidth,height:innerHeight,mobile:s.isMobile!==void 0?s.isMobile:!1,supportOffScreenCanvas:i,supportWebGPU:!!navigator.gpu,quality:2,dev:a,editor:e};s.tier===3?o.quality=0:s.tier===2&&(o.quality=1),sm(l=>{o.fps=l,t(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 S0(a,e,t,s,i){return rr(t,s,Uo(a,e,i))}function v0(a,e){const t=a-e;return Math.sqrt(t*t)}function ss(a,e=1){return Number(a.toFixed(e))}function w0(a,e,t,s){return rr(a,e,1-Math.exp(-t*s))}function E0(a,e=1){return Number(a.toFixed(e))}function M0(a,e,t,s){return a===e&&t===s}function C0(a,e,t,s){return 1/(3*e*a*a+2*t*a+s)}function A0(a,e,t,s,i){return e*(a*a*a)+t*(a*a)+s*a+i}function R0(a,e,t,s,i){const n=a*a;return e*(n*a)+t*n+s*a+i}function N0(a,e,t,s,i){if(a<=0)return 0;if(a>=1)return 1;if(M0(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=A0(S,p,f,m,y);let R=C0(S,p,f,m);R===1/0&&(R=a),S-=(w-a)*R,S=Math.min(Math.max(S,0),1)}return R0(S,g,_,b,T)}const oh=a=>{a?.dispose()},qh=a=>{if(a)if(Array.isArray(a))a.forEach(e=>qh(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()}},ii=a=>{if(a){for(;a.children.length>0;){const e=a.children[0];e.type==="Audio"?(e.pause(),e.parent&&e.parent.remove(e)):ii(e)}if(a.parent&&a.parent.remove(a),a.isMesh){const e=a;e.geometry?.dispose(),qh(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 P0(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 D0(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 fd.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 fd.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 O0(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=Yh(["ctrlKey","metaKey","shiftKey","button","pointerId","pointerType","clientX","clientY","pageX","pageY"]),B0=Yh(["clientX","clientY","deltaX","deltaY","deltaMode"]),I0=Yh(["ctrlKey","metaKey","shiftKey","keyCode"]);function L0(a,e){a.preventDefault(),B0(a,e)}function U0(a){a.preventDefault()}function k0(a,e,t){for(const s of e)t[s]=a[s]}function Yh(a){return function(t,s){const i={type:t.type};k0(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 z0={37:!0,38:!0,39:!0,40:!0};function G0(a,e){const{keyCode:t}=a;z0[t]&&(a.preventDefault(),I0(a,e))}const V0={contextmenu:U0,mousedown:bn,mousemove:bn,mouseup:bn,pointerdown:bn,pointermove:bn,pointerup:bn,touchstart:Ll,touchmove:Ll,touchend:Ll,wheel:L0,keydown:G0};let H0=0;class W0{id;worker;constructor(e,t,s){this.id=H0++,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 nm 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 $0{targets={};constructor(){this.handleEvent=this.handleEvent.bind(this)}makeProxy(e){const{id:t}=e,s=new nm;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 j0 extends x.EventDispatcher{assets={audio:new Map,image:new Map,json:new Map,model:new Map,video:new Map};components=new Map;settings={dpr:1,fps:30,width:0,height:0,mobile:!1,supportOffScreenCanvas:!1,supportWebGPU:!1,quality:jh.Low,dev:!1,editor:!1};appHandlers=[];editorHandlers=[];onUpdateCallback;_appID="";_mode="app";_broadcastChannel=void 0;_webSocket=void 0;_connected=!1;_useBC=!1;playing=!1;rafID=-1;constructor(e){super(),this._appID=e}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()}detectSettings(e=!1,t=!1){return this._mode=t?"editor":"app",new Promise(s=>{im(e,t).then(i=>{this.settings=i,s()})})}update(){}draw(){}play=()=>{this.playing||(this.playing=!0,this.onUpdate())};pause=()=>{this.playing&&(this.playing=!1,cancelAnimationFrame(this.rafID),this.rafID=-1)};onUpdate=()=>{this.update(),this.isApp&&this.draw(),this.onUpdateCallback&&this.onUpdateCallback(),this.rafID=requestAnimationFrame(this.onUpdate)};setupRemote(e=!0){this.settings.dev&&(this._useBC=e,e?(this._broadcastChannel=new BroadcastChannel(this._appID),this._broadcastChannel.addEventListener("message",this.messageHandler)):(this._webSocket=new WebSocket(this._appID),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)}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.settings.dev}get mode(){return this._mode}get isApp(){return!this.editor}set isApp(e){this.editor=!e}get editor(){return this.settings.editor}set editor(e){this.settings.editor=e,this._mode=e?"editor":"app"}}class q0{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 Y0 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 X0 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 Z0(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 Q0(){for(;!document.getElementById("theatrejs-studio-root");)await new Promise(s=>setTimeout(s,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){try{const i=t.children[1].children[1];i.parentElement?.removeChild(i)}catch{}try{const s=t.children[3];s.style.top="0",s.style.right="300px"}catch{}}}function K0(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 J0(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 K0(n,a.value,a.value+s,e.value+i,e.value)}class ex extends ol{project;sheets=new Map;sheetObjects=new Map;sheetObjectCBs=new Map;sheetObjectUnsubscribe=new Map;activeSheet;studio=void 0;rafDriver=void 0;constructor(e,t=!1){super(e),t&&(this.rafDriver=m0.createRafDriver())}dispose(){this.project=void 0,this.sheets=new Map,this.sheetObjects=new Map,this.sheetObjectCBs=new Map,this.sheetObjectUnsubscribe=new Map}update(e){this.rafDriver?.tick(e)}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}:{};n.rafDriver=this.rafDriver,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"&&em(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)},this.rafDriver);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 J0(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,rafDriver:this.rafDriver});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 tx(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 sx(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 ix(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"||ix(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]=sx(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 nx(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 rx(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&&rx(r,t)}}function rm(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 ax extends ol{canvas=null;inputElement=null;scene=void 0;scenes=new Map;renderer=void 0;renderTargets=new Map;renderTargetsResize=new Map;groups=new Map;dispose(){this.scenes.forEach(e=>{ii(e)}),this.scenes.clear(),this.scene&&ii(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=!0,s){const i=new x.WebGLRenderTarget(32,32,s);i.texture.name=e,this.renderTargets.set(e,i),this.renderTargetsResize.set(e,t)}removeRT(e){this.renderTargets.delete(e),this.renderTargetsResize.delete(e)}resize(e,t){const s=this.dpr;this.renderTargets.forEach((n,r)=>{this.renderTargetsResize.get(r)&&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 Da={exports:{}},Tr={};/**
|
|
19
19
|
* @license React
|
|
20
20
|
* react-jsx-runtime.production.min.js
|
|
21
21
|
*
|
|
@@ -500,6 +500,8 @@ uniform float uDistance;
|
|
|
500
500
|
uniform float uGridOpacity;
|
|
501
501
|
uniform float uSubgridOpacity;
|
|
502
502
|
|
|
503
|
+
#define minAlpha 0.00784313725490196
|
|
504
|
+
|
|
503
505
|
float getGrid(float gapSize) {
|
|
504
506
|
vec2 worldPositionByDivision = worldPosition.xz / gapSize;
|
|
505
507
|
|
|
@@ -556,7 +558,7 @@ void main() {
|
|
|
556
558
|
// Shade the next grid
|
|
557
559
|
fragColor.a = mix(fragColor.a, baseOpacity * uGridOpacity, nextGrid);
|
|
558
560
|
|
|
559
|
-
if (fragColor.a <=
|
|
561
|
+
if (fragColor.a <= minAlpha) discard;
|
|
560
562
|
}`;class nN extends x.ShaderMaterial{constructor(e){super({extensions:{derivatives:!0},uniforms:{uScale:{value:e?.scale!==void 0?e?.scale:.1},uDivisions:{value:e?.divisions!==void 0?e?.divisions:10},uColor:{value:e?.color!==void 0?e?.color:new x.Color(16777215)},uDistance:{value:e?.distance!==void 0?e?.distance:1e4},uSubgridOpacity:{value:e?.subgridOpacity!==void 0?e?.subgridOpacity:.15},uGridOpacity:{value:e?.gridOpacity!==void 0?e?.gridOpacity:.25}},glslVersion:x.GLSL3,side:x.DoubleSide,transparent:!0,name:"InfiniteGrid",vertexShader:sN,fragmentShader:iN})}}class rN extends x.Mesh{gridMaterial;constructor(e){const t=new nN(e);super(new x.PlaneGeometry,t),this.gridMaterial=t,this.frustumCulled=!1,this.name="InfiniteGridHelper"}update(){this.gridMaterial.needsUpdate=!0}}function sh(a){const[e,t]=W.useState(a.selected),s="toggle"+(e?" selected":"");return C.jsx("button",{className:s,onClick:()=>{const i=!e;t(i),a.onClick(i)},style:{backgroundImage:`url(${a.icon})`,backgroundPositionX:"center",backgroundPositionY:a.top!==void 0?`${a.top}px`:"center",backgroundSize:`${a.width!==void 0?`${a.width}px`:"26px"} ${a.height}px`}},a.name)}const aN=`#include <common>
|
|
561
563
|
#include <batching_pars_vertex>
|
|
562
564
|
#include <uv_pars_vertex>
|
|
@@ -595,4 +597,4 @@ void main() {
|
|
|
595
597
|
void main() {
|
|
596
598
|
#include <clipping_planes_fragment>
|
|
597
599
|
gl_FragColor = vec4(vec3(vUv, 0.0), 1.0);
|
|
598
|
-
}`;class lN extends x.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:aN,fragmentShader:oN})}}const Qi=new x.Raycaster,yt=new x.Vector3,_i=new x.Vector3,Ve=new x.Quaternion,Hf={X:new x.Vector3(1,0,0),Y:new x.Vector3(0,1,0),Z:new x.Vector3(0,0,1)},ih={type:"change"},Wf={type:"mouseDown",mode:null},$f={type:"mouseUp",mode:null},jf={type:"objectChange"};class cN extends x.Controls{constructor(e,t=null){super(void 0,t);const s=new mN(this);this._root=s;const i=new gN;this._gizmo=i,s.add(i);const n=new yN;this._plane=n,s.add(n);const r=this;function o(b,T){let S=T;Object.defineProperty(r,b,{get:function(){return S!==void 0?S:T},set:function(M){S!==M&&(S=M,n[b]=M,i[b]=M,r.dispatchEvent({type:b+"-changed",value:M}),r.dispatchEvent(ih))}}),r[b]=T,n[b]=T,i[b]=T}o("camera",e),o("object",void 0),o("enabled",!0),o("axis",null),o("mode","translate"),o("translationSnap",null),o("rotationSnap",null),o("scaleSnap",null),o("space","world"),o("size",1),o("dragging",!1),o("showX",!0),o("showY",!0),o("showZ",!0),o("minX",-1/0),o("maxX",1/0),o("minY",-1/0),o("maxY",1/0),o("minZ",-1/0),o("maxZ",1/0);const l=new x.Vector3,c=new x.Vector3,h=new x.Quaternion,u=new x.Quaternion,d=new x.Vector3,p=new x.Quaternion,f=new x.Vector3,m=new x.Vector3,y=new x.Vector3,g=0,_=new x.Vector3;o("worldPosition",l),o("worldPositionStart",c),o("worldQuaternion",h),o("worldQuaternionStart",u),o("cameraPosition",d),o("cameraQuaternion",p),o("pointStart",f),o("pointEnd",m),o("rotationAxis",y),o("rotationAngle",g),o("eye",_),this._offset=new x.Vector3,this._startNorm=new x.Vector3,this._endNorm=new x.Vector3,this._cameraScale=new x.Vector3,this._parentPosition=new x.Vector3,this._parentQuaternion=new x.Quaternion,this._parentQuaternionInv=new x.Quaternion,this._parentScale=new x.Vector3,this._worldScaleStart=new x.Vector3,this._worldQuaternionInv=new x.Quaternion,this._worldScale=new x.Vector3,this._positionStart=new x.Vector3,this._quaternionStart=new x.Quaternion,this._scaleStart=new x.Vector3,this._getPointer=hN.bind(this),this._onPointerDown=dN.bind(this),this._onPointerHover=uN.bind(this),this._onPointerMove=pN.bind(this),this._onPointerUp=fN.bind(this),t!==null&&this.connect(t)}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&Qi.setFromCamera(e,this.camera);const t=nh(this._gizmo.picker[this.mode],Qi);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&Qi.setFromCamera(e,this.camera);const t=nh(this._plane,Qi,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,Wf.mode=this.mode,this.dispatchEvent(Wf)}}pointerMove(e){const t=this.axis,s=this.mode,i=this.object;let n=this.space;if(s==="scale"?n="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(n="world"),i===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&Qi.setFromCamera(e,this.camera);const r=nh(this._plane,Qi,!0);if(r){if(this.pointEnd.copy(r.point).sub(this.worldPositionStart),s==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),n==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),n==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),i.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(n==="local"&&(i.position.applyQuaternion(Ve.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this._quaternionStart)),n==="world"&&(i.parent&&i.position.add(yt.setFromMatrixPosition(i.parent.matrixWorld)),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(yt.setFromMatrixPosition(i.parent.matrixWorld)))),i.position.x=Math.max(this.minX,Math.min(this.maxX,i.position.x)),i.position.y=Math.max(this.minY,Math.min(this.maxY,i.position.y)),i.position.z=Math.max(this.minZ,Math.min(this.maxZ,i.position.z));else if(s==="scale"){if(t.search("XYZ")!==-1){let o=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(o*=-1),_i.set(o,o,o)}else yt.copy(this.pointStart),_i.copy(this.pointEnd),yt.applyQuaternion(this._worldQuaternionInv),_i.applyQuaternion(this._worldQuaternionInv),_i.divide(yt),t.search("X")===-1&&(_i.x=1),t.search("Y")===-1&&(_i.y=1),t.search("Z")===-1&&(_i.z=1);i.scale.copy(this._scaleStart).multiply(_i),this.scaleSnap&&(t.search("X")!==-1&&(i.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(i.scale.z=Math.round(i.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(s==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const o=20/this.worldPosition.distanceTo(yt.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(yt.copy(this.rotationAxis).cross(this.eye))*o):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(Hf[t]),yt.copy(Hf[t]),n==="local"&&yt.applyQuaternion(this.worldQuaternion),yt.cross(this.eye),yt.length()===0?l=!0:this.rotationAngle=this._offset.dot(yt.normalize())*o),(t==="E"||l)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),n==="local"&&t!=="E"&&t!=="XYZE"?(i.quaternion.copy(this._quaternionStart),i.quaternion.multiply(Ve.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),i.quaternion.copy(Ve.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(ih),this.dispatchEvent(jf)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&($f.mode=this.mode,this.dispatchEvent($f)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(ih),this.dispatchEvent(jf),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Qi}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}}function hN(a){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:a.button};{const e=this.domElement.getBoundingClientRect();return{x:(a.clientX-e.left)/e.width*2-1,y:-(a.clientY-e.top)/e.height*2+1,button:a.button}}}function uN(a){if(this.enabled)switch(a.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(a));break}}function dN(a){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(a.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(a)),this.pointerDown(this._getPointer(a)))}function pN(a){this.enabled&&this.pointerMove(this._getPointer(a))}function fN(a){this.enabled&&(this.domElement.releasePointerCapture(a.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(a)))}function nh(a,e,t){const s=e.intersectObject(a,!0);for(let i=0;i<s.length;i++)if(s[i].object.visible||t)return s[i];return!1}const To=new x.Euler,Fe=new x.Vector3(0,1,0),qf=new x.Vector3(0,0,0),Yf=new x.Matrix4,So=new x.Quaternion,Io=new x.Quaternion,Rs=new x.Vector3,Xf=new x.Matrix4,sa=new x.Vector3(1,0,0),sn=new x.Vector3(0,1,0),ia=new x.Vector3(0,0,1),vo=new x.Vector3,qr=new x.Vector3,Yr=new x.Vector3;class mN extends x.Object3D{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),super.updateMatrixWorld(e)}dispose(){this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}}class gN extends x.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new x.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new x.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),s=e.clone();s.opacity=.15;const i=t.clone();i.opacity=.5;const n=e.clone();n.color.setHex(16711680);const r=e.clone();r.color.setHex(65280);const o=e.clone();o.color.setHex(255);const l=e.clone();l.color.setHex(16711680),l.opacity=.5;const c=e.clone();c.color.setHex(65280),c.opacity=.5;const h=e.clone();h.color.setHex(255),h.opacity=.5;const u=e.clone();u.opacity=.25;const d=e.clone();d.color.setHex(16776960),d.opacity=.25,e.clone().color.setHex(16776960);const f=e.clone();f.color.setHex(7895160);const m=new x.CylinderGeometry(0,.04,.1,12);m.translate(0,.05,0);const y=new x.BoxGeometry(.08,.08,.08);y.translate(0,.04,0);const g=new x.BufferGeometry;g.setAttribute("position",new x.Float32BufferAttribute([0,0,0,1,0,0],3));const _=new x.CylinderGeometry(.0075,.0075,.5,3);_.translate(0,.25,0);function b(Z,ve){const ue=new x.TorusGeometry(Z,.0075,3,64,ve*Math.PI*2);return ue.rotateY(Math.PI/2),ue.rotateX(Math.PI/2),ue}function T(){const Z=new x.BufferGeometry;return Z.setAttribute("position",new x.Float32BufferAttribute([0,0,0,1,1,1],3)),Z}const S={X:[[new x.Mesh(m,n),[.5,0,0],[0,0,-Math.PI/2]],[new x.Mesh(m,n),[-.5,0,0],[0,0,Math.PI/2]],[new x.Mesh(_,n),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new x.Mesh(m,r),[0,.5,0]],[new x.Mesh(m,r),[0,-.5,0],[Math.PI,0,0]],[new x.Mesh(_,r)]],Z:[[new x.Mesh(m,o),[0,0,.5],[Math.PI/2,0,0]],[new x.Mesh(m,o),[0,0,-.5],[-Math.PI/2,0,0]],[new x.Mesh(_,o),null,[Math.PI/2,0,0]]],XYZ:[[new x.Mesh(new x.OctahedronGeometry(.1,0),u.clone()),[0,0,0]]],XY:[[new x.Mesh(new x.BoxGeometry(.15,.15,.01),h.clone()),[.15,.15,0]]],YZ:[[new x.Mesh(new x.BoxGeometry(.15,.15,.01),l.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new x.Mesh(new x.BoxGeometry(.15,.15,.01),c.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},M={X:[[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new x.Mesh(new x.OctahedronGeometry(.2,0),s)]],XY:[[new x.Mesh(new x.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new x.Mesh(new x.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new x.Mesh(new x.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]]},w={START:[[new x.Mesh(new x.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],END:[[new x.Mesh(new x.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],DELTA:[[new x.Line(T(),i),null,null,null,"helper"]],X:[[new x.Line(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new x.Line(g,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new x.Line(g,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},R={XYZE:[[new x.Mesh(b(.5,1),f),null,[0,Math.PI/2,0]]],X:[[new x.Mesh(b(.5,.5),n)]],Y:[[new x.Mesh(b(.5,.5),r),null,[0,0,-Math.PI/2]]],Z:[[new x.Mesh(b(.5,.5),o),null,[0,Math.PI/2,0]]],E:[[new x.Mesh(b(.75,1),d),null,[0,Math.PI/2,0]]]},P={AXIS:[[new x.Line(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},z={XYZE:[[new x.Mesh(new x.SphereGeometry(.25,10,8),s)]],X:[[new x.Mesh(new x.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new x.Mesh(new x.TorusGeometry(.5,.1,4,24),s),[0,0,0],[Math.PI/2,0,0]]],Z:[[new x.Mesh(new x.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,0,-Math.PI/2]]],E:[[new x.Mesh(new x.TorusGeometry(.75,.1,2,24),s)]]},$={X:[[new x.Mesh(y,n),[.5,0,0],[0,0,-Math.PI/2]],[new x.Mesh(_,n),[0,0,0],[0,0,-Math.PI/2]],[new x.Mesh(y,n),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new x.Mesh(y,r),[0,.5,0]],[new x.Mesh(_,r)],[new x.Mesh(y,r),[0,-.5,0],[0,0,Math.PI]]],Z:[[new x.Mesh(y,o),[0,0,.5],[Math.PI/2,0,0]],[new x.Mesh(_,o),[0,0,0],[Math.PI/2,0,0]],[new x.Mesh(y,o),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new x.Mesh(new x.BoxGeometry(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new x.Mesh(new x.BoxGeometry(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new x.Mesh(new x.BoxGeometry(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new x.Mesh(new x.BoxGeometry(.1,.1,.1),u.clone())]]},q={X:[[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new x.Mesh(new x.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new x.Mesh(new x.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new x.Mesh(new x.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new x.Mesh(new x.BoxGeometry(.2,.2,.2),s),[0,0,0]]]},j={X:[[new x.Line(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new x.Line(g,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new x.Line(g,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function X(Z){const ve=new x.Object3D;for(const ue in Z)for(let ge=Z[ue].length;ge--;){const ie=Z[ue][ge][0].clone(),we=Z[ue][ge][1],ke=Z[ue][ge][2],rt=Z[ue][ge][3],_e=Z[ue][ge][4];ie.name=ue,ie.tag=_e,we&&ie.position.set(we[0],we[1],we[2]),ke&&ie.rotation.set(ke[0],ke[1],ke[2]),rt&&ie.scale.set(rt[0],rt[1],rt[2]),ie.updateMatrix();const at=ie.geometry.clone();at.applyMatrix4(ie.matrix),ie.geometry=at,ie.renderOrder=1/0,ie.position.set(0,0,0),ie.rotation.set(0,0,0),ie.scale.set(1,1,1),ve.add(ie)}return ve}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=X(S)),this.add(this.gizmo.rotate=X(R)),this.add(this.gizmo.scale=X($)),this.add(this.picker.translate=X(M)),this.add(this.picker.rotate=X(z)),this.add(this.picker.scale=X(q)),this.add(this.helper.translate=X(w)),this.add(this.helper.rotate=X(P)),this.add(this.helper.scale=X(j)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const s=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:Io;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(let n=0;n<i.length;n++){const r=i[n];r.visible=!0,r.rotation.set(0,0,0),r.position.copy(this.worldPosition);let o;if(this.camera.isOrthographicCamera?o=(this.camera.top-this.camera.bottom)/this.camera.zoom:o=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),r.scale.set(1,1,1).multiplyScalar(o*this.size/4),r.tag==="helper"){r.visible=!1,r.name==="AXIS"?(r.visible=!!this.axis,this.axis==="X"&&(Ve.setFromEuler(To.set(0,0,0)),r.quaternion.copy(s).multiply(Ve),Math.abs(Fe.copy(sa).applyQuaternion(s).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Y"&&(Ve.setFromEuler(To.set(0,0,Math.PI/2)),r.quaternion.copy(s).multiply(Ve),Math.abs(Fe.copy(sn).applyQuaternion(s).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Z"&&(Ve.setFromEuler(To.set(0,Math.PI/2,0)),r.quaternion.copy(s).multiply(Ve),Math.abs(Fe.copy(ia).applyQuaternion(s).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="XYZE"&&(Ve.setFromEuler(To.set(0,Math.PI/2,0)),Fe.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix(Yf.lookAt(qf,Fe,sn)),r.quaternion.multiply(Ve),r.visible=this.dragging),this.axis==="E"&&(r.visible=!1)):r.name==="START"?(r.position.copy(this.worldPositionStart),r.visible=this.dragging):r.name==="END"?(r.position.copy(this.worldPosition),r.visible=this.dragging):r.name==="DELTA"?(r.position.copy(this.worldPositionStart),r.quaternion.copy(this.worldQuaternionStart),yt.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),yt.applyQuaternion(this.worldQuaternionStart.clone().invert()),r.scale.copy(yt),r.visible=this.dragging):(r.quaternion.copy(s),this.dragging?r.position.copy(this.worldPositionStart):r.position.copy(this.worldPosition),this.axis&&(r.visible=this.axis.search(r.name)!==-1));continue}r.quaternion.copy(s),this.mode==="translate"||this.mode==="scale"?(r.name==="X"&&Math.abs(Fe.copy(sa).applyQuaternion(s).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Y"&&Math.abs(Fe.copy(sn).applyQuaternion(s).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Z"&&Math.abs(Fe.copy(ia).applyQuaternion(s).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XY"&&Math.abs(Fe.copy(ia).applyQuaternion(s).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="YZ"&&Math.abs(Fe.copy(sa).applyQuaternion(s).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XZ"&&Math.abs(Fe.copy(sn).applyQuaternion(s).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1)):this.mode==="rotate"&&(So.copy(s),Fe.copy(this.eye).applyQuaternion(Ve.copy(s).invert()),r.name.search("E")!==-1&&r.quaternion.setFromRotationMatrix(Yf.lookAt(this.eye,qf,sn)),r.name==="X"&&(Ve.setFromAxisAngle(sa,Math.atan2(-Fe.y,Fe.z)),Ve.multiplyQuaternions(So,Ve),r.quaternion.copy(Ve)),r.name==="Y"&&(Ve.setFromAxisAngle(sn,Math.atan2(Fe.x,Fe.z)),Ve.multiplyQuaternions(So,Ve),r.quaternion.copy(Ve)),r.name==="Z"&&(Ve.setFromAxisAngle(ia,Math.atan2(Fe.y,Fe.x)),Ve.multiplyQuaternions(So,Ve),r.quaternion.copy(Ve))),r.visible=r.visible&&(r.name.indexOf("X")===-1||this.showX),r.visible=r.visible&&(r.name.indexOf("Y")===-1||this.showY),r.visible=r.visible&&(r.name.indexOf("Z")===-1||this.showZ),r.visible=r.visible&&(r.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),r.material._color=r.material._color||r.material.color.clone(),r.material._opacity=r.material._opacity||r.material.opacity,r.material.color.copy(r.material._color),r.material.opacity=r.material._opacity,this.enabled&&this.axis&&(r.name===this.axis||this.axis.split("").some(function(l){return r.name===l}))&&(r.material.color.setHex(16776960),r.material.opacity=1)}super.updateMatrixWorld(e)}}class yN extends x.Mesh{constructor(){super(new x.PlaneGeometry(1e5,1e5,2,2),new x.MeshBasicMaterial({visible:!1,wireframe:!0,side:x.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),vo.copy(sa).applyQuaternion(t==="local"?this.worldQuaternion:Io),qr.copy(sn).applyQuaternion(t==="local"?this.worldQuaternion:Io),Yr.copy(ia).applyQuaternion(t==="local"?this.worldQuaternion:Io),Fe.copy(qr),this.mode){case"translate":case"scale":switch(this.axis){case"X":Fe.copy(this.eye).cross(vo),Rs.copy(vo).cross(Fe);break;case"Y":Fe.copy(this.eye).cross(qr),Rs.copy(qr).cross(Fe);break;case"Z":Fe.copy(this.eye).cross(Yr),Rs.copy(Yr).cross(Fe);break;case"XY":Rs.copy(Yr);break;case"YZ":Rs.copy(vo);break;case"XZ":Fe.copy(Yr),Rs.copy(qr);break;case"XYZ":case"E":Rs.set(0,0,0);break}break;case"rotate":default:Rs.set(0,0,0)}Rs.length()===0?this.quaternion.copy(this.cameraQuaternion):(Xf.lookAt(yt.set(0,0,0),Rs,Fe),this.quaternion.setFromRotationMatrix(Xf)),super.updateMatrixWorld(e)}}class xt extends x.EventDispatcher{static DRAG_START="Transform::dragStart";static DRAG_END="Transform::dragEnd";static _instance;app;three;activeCamera;controls=new Map;visibility=new Map;setApp(e,t){this.app=e,this.three=t,this.app.addEventListener(Q.SET_SCENE,this.setScene)}clear(){for(const e of this.controls.values()){e.detach(),e.disconnect();const t=e.getHelper();ii(t)}this.controls=new Map,this.visibility=new Map}add(e){let t=this.controls.get(e);if(t===void 0){const s=document.querySelector(".clickable");t=new cN(this.activeCamera,s),t.getHelper().name=e,t.setSize(.25),t.setSpace("local"),this.controls.set(e,t),this.visibility.set(e,!0),t.addEventListener("mouseDown",()=>{this.dispatchEvent({type:xt.DRAG_START})}),t.addEventListener("mouseUp",()=>{this.dispatchEvent({type:xt.DRAG_END})}),t.addEventListener("dragging-changed",i=>{et.instance?.toggleOrbitControls(i.value)})}return t}get(e){return this.controls.get(e)}remove(e){const t=this.get(e);return t===void 0?!1:(t.detach(),t.disconnect(),ii(t.getHelper()),this.controls.delete(e),!0)}enabled(e){this.controls.forEach(t=>{t.enabled=e})}updateCamera(e,t){this.activeCamera=e,this.controls.forEach(s=>{s.camera!==e&&(s.camera=e,e.getWorldPosition(s.cameraPosition),e.getWorldQuaternion(s.cameraQuaternion)),s.domElement!==t&&(s.disconnect(),s.domElement=t,s.connect(t))})}show(){this.controls.forEach(e=>{const t=e.getHelper(),s=this.visibility.get(t.name);s!==void 0&&(t.visible=s)})}hide(){this.controls.forEach(e=>{const t=e.getHelper();this.visibility.set(t.name,t.visible),t.visible=!1})}setScene=()=>{this.clear()};static get instance(){return xt._instance||(xt._instance=new xt),xt._instance}}const xN=new x.BoxGeometry,rh=new x.Vector2;class Lo extends x.Object3D{curve=new x.CatmullRomCurve3;line;draggable;curvePos;tension=.5;closed=!1;subdivide=50;curveType;offset=1;lineMaterial;_camera;_curvePercentage=0;_draggableScale=10;_transform;raycaster;draggedMat=new x.MeshBasicMaterial;parentGroup;group;constructor(e,t){const s=new x.Color(Ni(.5,1,Math.random()),Ni(.5,1,Math.random()),Ni(.5,1,Math.random()));super(),this.name=e,this.lineMaterial=new x.LineBasicMaterial({color:s}),this.line=new x.Line(new x.BufferGeometry,this.lineMaterial),this.line.name="line",this.line.visible=!1,this.add(this.line),this._camera=t,this.curveType="catmullrom",this.draggedMat.color=s,this.draggable=new x.Object3D,this.draggable.name="draggablePoints",this.add(this.draggable),this.curvePos=new x.Mesh(new x.SphereGeometry(1.5),new x.MeshBasicMaterial({color:s})),this.curvePos.name="curvePos",this.curvePos.scale.setScalar(this._draggableScale),this.curvePos.visible=!1,this.add(this.curvePos),this.raycaster=new x.Raycaster,this.raycaster.params.Line.threshold=3,this.enable()}enable(){document.addEventListener("pointerdown",this.onMouseClick)}disable(){document.removeEventListener("pointerdown",this.onMouseClick)}dispose=()=>{this._transform&&(this._transform.removeEventListener("objectChange",this.updateSpline),xt.instance.remove(this.name)),this.disable(),this.parentGroup.removeGroup(this.name)};hideTransform=()=>{this._transform?.detach()};exportSpline=()=>{const e=[];this.draggable.children.forEach(t=>{e.push([ss(t.position.x,3),ss(t.position.y,3),ss(t.position.z,3)])}),Kf({name:this.name,points:e,tension:this.tension,closed:this.closed,subdivide:this.subdivide,type:this.curveType}),console.log("Spline copied!")};showPoints=(e=!0)=>{this.draggable.visible=e};addPoints=(e=[])=>{if(e.length>0){const t=e.length-1;for(let s=0;s<t;s++)this.addPoint(e[s],!1);this.addPoint(e[t])}};addPoint=(e,t=!0)=>{const s=this.draggable.children.length,i=new x.Mesh(xN,this.draggedMat);i.name=`point_${s}`,i.position.copy(e),i.scale.setScalar(this._draggableScale),this.draggable.add(i),this._transform?.attach(i);const n=this.points.length>1;return n&&t&&this.updateSpline(),this.line.visible=n,this.updateCurrentPoint(),i};addNextPt=()=>{const e=this.draggable.children.length,t=e>1?this.draggable.children[e-1].position.clone():new x.Vector3,s=this.addPoint(t);this.group.current?.setField("Current Point",s.position)};removePoint=e=>{if(this._transform?.object===e){this._transform?.detach();const t=this.draggable.children[this.draggable.children.length-1];this._transform?.attach(t),this.group.current?.setField("Current Point",t.position)}ii(e),this.updateSpline()};removePointAt=e=>{const t=this.draggable.children[e];this.removePoint(t)};removeSelectedPt=()=>{this._transform?.object!==void 0&&this.removePoint(this._transform?.object)};updateLastPoint(e){const t=this.draggable.children.length;t>0&&(this.draggable.children[t-1].position.copy(e),this.updateSpline())}updateSpline=()=>{this.points.length<2||(this.curve=new x.CatmullRomCurve3(this.points,this.closed,this.curveType,this.tension),this.line.geometry.dispose(),this.line.geometry=new x.BufferGeometry().setFromPoints(this.curve.getPoints(this.subdivide)),this.curvePos.position.copy(this.getPointAt(this._curvePercentage)))};onMouseClick=e=>{if(!et.instance||!et.instance.currentWindow||this._transform&&!this._transform.getHelper().visible)return;const s=et.instance.currentWindow.current.getBoundingClientRect();rh.x=(e.clientX-s.x)/s.width*2-1,rh.y=-((e.clientY-s.y)/s.height)*2+1,this.raycaster.setFromCamera(rh,this.camera);const i=this.raycaster.intersectObjects(this.draggable.children,!1);if(i.length>0){const n=i[0].object;n!==this._transform?.object&&(this._transform?.attach(n),this.group.current?.setField("Current Point",n.position))}};getPointAt(e){return this.curve.points.length>1?this.curve.getPointAt(e):this.curve.points.length===1?this.curve.points[0]:new x.Vector3}getTangentAt(e){return this.curve.getTangentAt(e)}get points(){const e=[];return this.draggable.children.forEach(t=>{e.push(t.position)}),e}get total(){return this.draggable.children.length}get draggableScale(){return this._draggableScale}set draggableScale(e){this._draggableScale=e,this.draggable.children.forEach(t=>t.scale.setScalar(e)),this.curvePos.scale.setScalar(e)}get camera(){return this._camera}set camera(e){this._camera=e,this._transform!==void 0&&(this._transform.camera=e)}get curvePercentage(){return this._curvePercentage}set curvePercentage(e){this._curvePercentage=e,this.curvePos.position.copy(this.getPointAt(e))}updateCurrentPoint(){if(this._transform?.object&&this.group){const e=this._transform?.object;e.name.search("point")>-1&&this.group.current?.setField("Current Point",e.position)}}onUpdateTransform=()=>{this.updateCurrentPoint(),this.updateSpline()};initDebug(e){const t=this.draggable.children;this.parentGroup=e,this._transform=xt.instance.add(this.name),this._transform.camera=this._camera,this._transform.addEventListener("objectChange",this.onUpdateTransform),t.length>0&&this._transform.attach(t[t.length-1]),et.instance?.helpersContainer.add(this._transform.getHelper());const s=t.length>0?t[t.length-1].position:{x:0,y:0,z:0};this.group=e.addGroup({title:this.name,expanded:!0,items:[{prop:"Closed",type:"boolean",value:this.closed},{prop:"Visible",type:"boolean",value:this.visible},{prop:"Show Position",type:"boolean",value:this.curvePos.visible},{prop:"Show Points",type:"boolean",value:this.draggable.visible},{prop:"Color",type:"color",value:`#${this.draggedMat.color.getHexString()}`},{prop:"Curve",type:"option",options:[{title:"Catmullrom",value:"catmullrom"},{title:"Centripetal",value:"centripetal"},{title:"Chordal",value:"chordal"}]},{prop:"Draggable Scale",type:"range",min:.01,max:100,step:.01,value:this._draggableScale},{prop:"Subdivide",type:"range",min:1,max:1e3,step:1,value:this.subdivide},{prop:"Tension",type:"range",min:0,max:1,step:.01,value:this.tension},{prop:"New Pt Offset",type:"range",min:0,max:10,value:this.offset},{prop:"Curve At",type:"range",min:0,max:1,step:.01,value:0},{prop:"Toggle Transform",type:"button"},{prop:"Add Point",type:"button"},{prop:"Remove Point",type:"button"},{prop:"Export",type:"button"},{prop:"Delete",type:"button"},{prop:"Current Point",type:"grid3",value:s}],onUpdate:(i,n)=>{switch(i){case"Closed":this.closed=n,this.updateSpline();break;case"Visible":this.visible=n;break;case"Color":this.lineMaterial.color.setStyle(n),this.draggedMat.color.setStyle(n);break;case"Curve":this.curveType=n,this.updateSpline();break;case"Draggable Scale":this.draggableScale=n;break;case"Subdivide":this.subdivide=n,this.updateSpline();break;case"Tension":this.tension=n,this.updateSpline();break;case"New Pt Offset":this.offset=n;break;case"Curve At":this.curvePos.position.copy(this.getPointAt(n));break;case"Show Position":this.curvePos.visible=n;break;case"Show Points":this.draggable.visible=n;break;case"Toggle Transform":this._transform&&(this._transform.getHelper().visible=!this._transform.getHelper().visible);break;case"Add Point":this.addNextPt();break;case"Remove Point":this.removeSelectedPt();break;case"Export":this.exportSpline();break;case"Delete":this.parent.currentSpline=null,ii(this);break;case"Current Point":if(this.group.current&&this._transform?.object){const r=this._transform?.object;r.name.search("point")>-1&&(r.position.copy(n),this.updateSpline())}break}}}),this.draggable.children.forEach(i=>{this.debugPoint(i)})}debugPoint=e=>{e.name,e.visible=this.draggable.visible}}let wo=0;class zy extends x.Object3D{defaultScale=10;currentSpline=null;_camera;group=null;app;splineDataText="";constructor(e,t){super(),this.name="Spline Editor",this._camera=e,this.app=t,this.app.addEventListener(Q.ADD_SPLINE,this.onAddSpline)}initDebug(){this.group=Re.addEditorGroup({title:this.name,items:[{type:"field",prop:"Spline Data",value:"",disabled:!1},{type:"button",prop:"Import Spline"},{type:"button",prop:"New Spline"},{type:"boolean",prop:"Show Points",value:!0},{type:"boolean",prop:"Draw Mode",value:!1},{type:"boolean",prop:"Visible",value:this.visible},{type:"range",prop:"Default Scale",min:0,max:50,step:.01,value:this.defaultScale}],onUpdate:(e,t)=>{switch(e){case"New Spline":this.createSpline();break;case"Spline Data":this.splineDataText=t;break;case"Import Spline":this.createSplineFromJSON(JSON.parse(this.splineDataText));break;case"Show Points":this.showPoints(t);break;case"Visible":this.visible=t;break;case"Default Scale":this.defaultScale=t;break;case"Draw Mode":t?this.enableClickToDraw():this.disableClickToDraw();break}}})}dispose(){this.app.removeEventListener(Q.ADD_SPLINE,this.onAddSpline),Re.removeEditorGroup(this.name)}addSpline(e){e.draggableScale=this.defaultScale,e.hideTransform(),this.group?.current!==null&&e.initDebug(this.group.current),this.add(e),this.currentSpline=e}createSpline=(e=[])=>{const t=`Spline ${wo+1}`,s=new Lo(t,this._camera);return s.addPoints(e),this.addSpline(s),wo++,s};createSplineFromArray=e=>{const t=[];return e.forEach(s=>{t.push(new x.Vector3(s[0],s[1],s[2]))}),this.createSpline(t)};createSplineFromCatmullRom=e=>this.createSpline(e.points);createSplineFromJSON=e=>{const t=[];e.points.forEach(i=>{t.push(new x.Vector3(i[0],i[1],i[2]))});const s=new Lo(e.name,this._camera);return s.closed=e.closed,s.subdivide=e.subdivide,s.tension=e.tension,s.type=e.type,s.addPoints(t),s.updateSpline(),this.addSpline(s),s};showPoints=(e=!0)=>{this.children.forEach(t=>{t.showPoints(e)})};onAddSpline=e=>{const t=JSON.parse(e.value),s=`Spline ${wo+1}`,i=[];t.points.forEach(r=>{i.push(new x.Vector3(r[0],r[1],r[2]))});const n=new Lo(s,this.camera);n.addPoints(i),this.addSpline(n),wo++};isMouseDown=!1;enableClickToDraw(){document.querySelectorAll(".clickable").forEach(e=>{e.addEventListener("mousedown",this.onClickCanvas),e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("mouseup",this.onMouseUp)})}disableClickToDraw(){document.querySelectorAll(".clickable").forEach(e=>{e.removeEventListener("mousedown",this.onClickCanvas),e.removeEventListener("mousemove",this.onMouseMove),e.removeEventListener("mouseup",this.onMouseUp)})}onClickCanvas=e=>{if(e.button!==0)return;if(this._camera.type!=="OrthographicCamera"){console.warn("Spline Editor - 3D Camera not supported in Draw Mode");return}const s=e.target.getBoundingClientRect(),i=(e.clientX-s.left)/s.width*2-1,n=-((e.clientY-s.top)/s.height)*2+1;if(et.instance){const o=new x.Raycaster;o.setFromCamera(new x.Vector2(i,n),this._camera);const l=o.intersectObjects(et.instance.helpersContainer.children,!0);for(let c=0;c<l.length;c++){const h=l[c];if(!(h.object.isLine||h.object.isTransformControlsPlane)&&h.object.isObject3D)return}}this.currentSpline===null&&(this.currentSpline=this.createSpline());const r=this.mouseToSplinePos(i,n,s.width,s.height);this.currentSpline?.addPoint(r),this.isMouseDown=!0};onMouseMove=e=>{if(!this.isMouseDown)return;const s=e.target.getBoundingClientRect(),i=(e.clientX-s.left)/s.width*2-1,n=-((e.clientY-s.top)/s.height)*2+1,r=this.mouseToSplinePos(i,n,s.width,s.height);this.currentSpline?.updateLastPoint(r)};onMouseUp=()=>{this.isMouseDown=!1};mouseToSplinePos(e,t,s,i){const n=new x.Vector3,r=Math.PI/2,o=this._camera,l=o.zoom,c=o.rotation.x===-6123233995736766e-32&&o.rotation.y===0&&o.rotation.z===0,h=o.rotation.x===-Math.PI&&o.rotation.y===12246467991473532e-32&&o.rotation.z===Math.PI,u=o.rotation.x===-6162975822039155e-48&&o.rotation.y===-r&&o.rotation.z===0,d=o.rotation.x===-6162975822039155e-48&&o.rotation.y===r&&o.rotation.z===0,p=o.rotation.x===-1.5707953264174506&&o.rotation.y===0&&o.rotation.z===0,f=o.rotation.x===1.5707953264174506&&o.rotation.y===0&&o.rotation.z===0;let m=e,y=t;h||d?m*=-1:p&&(y*=-1);const g=s/2/l,_=i/2/l;if(this.currentSpline===null&&(this.currentSpline=this.createSpline()),c||h){const b=m*g+o.position.x,T=y*_+o.position.y;n.set(b,T,0)}else if(u||d){const b=m*g+o.position.z,T=y*_+o.position.y;n.set(0,T,b)}else if(p||f){const b=m*g+o.position.x,T=y*_+o.position.z;n.set(b,0,T)}return n}get camera(){return this._camera}set camera(e){this._camera=e,this.children.forEach(t=>{const s=t;s.camera=e})}}const Zf=["Single","Side by Side","Stacked","Quad"],_N="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAC60lEQVRYhe2YT4hNcRTHP48xpmYaNAvRyEQxEhnKQljYsRm9/EmSyJiMFAsMZWNhJYoNIUVJ2VGiyb9ZzIpMpkQSahbGv9GMYWrM+1rc2zjvzvvdd+99rzdvMd+6de75nd+5387vnN/v/G5KEuWMKRNNIB8mCRaKiiL5qQb2ApuBuUAV0Ad0AJeB3sSeJRX6LJbULTf6JTUn9Z+KWMUpPyp/Avoa4CNQZ3Sj/lNpdL/xottR7AjOkHRUUpekN5I6JbVLavDH75lIfZN0UFKTpCWS0pJem/HeJBEMG6yV1ONYtgFJbZJ+GF1jDh+zJb03NuliEuwMkMo4yErS2RA/LcbuYVyCrm1mA7Dal/8Cu4FG4JD/HsTTkCy6a+SVMTPQuc1sBKb78nHghi+/A+YBxwL2lbhRY+ThuARdEVxu5JdGFvACr0otdoZ8Y4+Rn0Sn5sFFsMvI6YB9MzA1YJ8mN8k1wAHzfj4uQVdyrpI0aJL7oqTtkq4FiqPLyCOSbktqlbRL0jlJQ2b8QdwCUZ4qvhRStZL0XFK1pMd57CRvq5mfhKBriRfiFUMY6oD7eOdwPlQAN4G10dfWg+uouwXsiOssAj4AC+JMcEWwvnAuOTEr7gTXPmg34zagOwkbIIOXAo9CbDYBrcBXYN+4UUdy2sRflyS5zVNlfPX7ugpJW5V9nI7mmh+lYU0lCZ2B3TOnAVuAk0BTwC5nuhWro46KauBOQJch5OpRaoIW34GreGf+YZdRqS9NAj4Bp4ClQDvwOWxCqSM4ADQEdKE5XvbXzlITrAVe4TW+M6NMKDXBFLAMuAD0ACfIc7pMZBXXA2cY3/xmodQRHAL2A2+NLtj8ZiEKwUL/z2WMPAJcAVYALWSf8dZuDFGWeBHwKxm3sWYhiGG8Tfo6sA2vSfiSy4GrH3wGrDcfKSSKKf6v1E9yF0XK9Q1XBPuMXMw8HXTonQFwETwNzMFr64v1jzgFHIk9ybHEZYPJo65QlD3Bf2/Q/eaHPiSWAAAAAElFTkSuQmCC",bN="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAETklEQVRYhe2YXYhVVRTHf3d0/JhyUrMpFbImM+whSa3Mynww+4AeIgiKoozooQ+KyMyXIAujF6OXqHyI6iEKKYgIP/owsjSFqCkprdDUTEcjbWZ0HHV+Pex1ucfb9Z57Z9REXHA4Z++99l7/s/ZZ/7X2KaiczNLwfwPIk9MA+yunNMAG4DHgV+BvoB3YFff2TPstYEyfrajVroI6Sr1GvahsbJC63HzZq04pmztSvU5tVRuqYRiYg78JeBR4HPg5ntdmxovz9wJfA3uAxuibDLQCA+IqynnAQuBuYCnwMLC1rx48U12U8cZqdWqMDcx4cI16qTpYbVKHqa+ovWUeHKsujn7VL9ULq2HI+wY7gVeBJdGeFu3J4ZUiy/cAXeHRRuAQsC/GC0B3eG4BcH/0tUV7czUAeVsMsBF4Kha9HZgCvAncAuwPnXHA0wFuGLANuDrGuoGDwFxgTqzzQ7RX5FrP2eLsdb76vnogtme6+nE8H1YPlQXHwbi3q9eqn0e7Tb25VrsF68vFY0lb1AGcDTwItGQ8tQM4AIwGmqP/EPAu8A0wElgJfFGzxTo8mKWXu9Rd4ZF96jvqjSbauEC9Sn1O3R463epLaku99voCsFXdkAH3kNpcQW+IiT/bQne3eufxBtioPqP2mKhioXpWzpxb1T8C5Ifh4ZptVoriRmAIKdrI3Lujf3bobAPeJpF0NVkKrAFuI9HTOBIxnxFrF4OgQKKr/dnJlQA+AcwABgOHA4zAamA5cE7orQL+zAEHiWI+A2bFC7aSguheYCgpqAphZz3wSB7AecCICv2TgH8oFRib4gVqka0k0h8CXAxMBW6ooDejFoCvA9OBQUAvKWM0kDz4XUZvNKXtyZMWUl7vBbaQXq457PeEziDgx/KJlQAuIPFdMcEXv5OdYWBP9M8k8VpnDQCvB4aTSrCNJB5cSdrW3tBpIJVnR0qdUTxAfdGUOVTnmwqEanNmqltC/9OgqePKg5eom8PgdvW+oJ9Kupera0O3U50TL3lcAaI+oHaF4R3qa6Z822wq0Saq89T1lmSxOrxeW/Xm4uGkiqQDmECKuKHxHW0HdpMiewSpvGqKeR8Ay0iBsYIjg6261PE2o9Q3Yqv+MqWxO9R1Hl12qs+q49Vlppy82pSr+5xJKsko4AXgHlJ0t5NIeg3wLXAlqZhtIUV8J6nmWwX8QiLjdhL5TwMWkY4R6/rrwYKlMr1Y321QZ/vfwBijPqm+rF4Wc7PjE9QllurGVeoV5gRNHsAm9fnMom3qrKPoTjKdMXaYyrFygEWQ72XWW24qhPu8xcUc2UU6O8wFPjmK7jhgPHAuMJGUGQ6U6WwE5sfzTXGvei7KA9hFOiR9D/wOfFVFt4dS2tpfRe83Ur7/CPiJakfOGgBCypubatArl2r8VfOax/LfzABKtePAzHO/5FgC7KBEzB2kOrDfUm8mOeFySv9+OyFyGmB/5aQH+C9BVKmVCNuMZgAAAABJRU5ErkJggg==",TN="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAQ0lEQVQ4jWP8////fwYqAxYozUhFM/8zkaKYWIWkGEq0b0ZdSjQY5i79TyWagRGaTUdzFEEw6lLqGzqwLoVVJ1StpwA9sBwbUqAh5gAAAABJRU5ErkJggg==";class et extends W.Component{static instance=null;app;scene;renderer;currentScene;scenes=new Map;cameras=new Map;controls=new Map;currentCamera;currentWindow;helpersContainer=new x.Group;cameraHelpers=new Map;lightHelpers=new Map;grid=new rN;interactionHelper=new x.AxesHelper(25);currentTransform;splineEditor;depthMaterial=new x.MeshDepthMaterial;normalsMaterial=new x.MeshNormalMaterial;uvMaterial=new lN;wireframeMaterial=new x.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0});playing=!1;rafID=-1;cameraControlsRafID=-1;width=0;height=0;tlCam=null;trCam=null;blCam=null;brCam=null;tlRender="Renderer";trRender="Renderer";blRender="Renderer";brRender="Renderer";cameraVisibility=!0;lightVisibility=!0;gridVisibility=!0;selectedItem=void 0;debugCamera;raycaster=new x.Raycaster;pointer=new x.Vector2;cameraControls=void 0;canvasRef;containerRef;tlWindow;trWindow;blWindow;brWindow;constructor(e){super(e),this.app=e.app,this.app.addEventListener(Q.ADD_RENDERER,this.setupRenderer),this.scene=new x.Scene,this.scene.name=this.scene.uuid="Debug Scene",this.canvasRef=W.createRef(),this.containerRef=W.createRef(),this.tlWindow=W.createRef(),this.trWindow=W.createRef(),this.blWindow=W.createRef(),this.brWindow=W.createRef();const t=e.three.app.appID,s=localStorage,i=s.getItem(`${t}_mode`);this.state={mode:i!==null?i:"Single",modeOpen:!1,renderModeOpen:!1,interactionMode:"Orbit",interactionModeOpen:!1,lastUpdate:Date.now()},s.setItem(`${t}_mode`,this.state.mode),s.setItem(`${t}_tlCam`,s.getItem(`${t}_tlCam`)!==null?s.getItem(`${t}_tlCam`):"Debug"),s.setItem(`${t}_trCam`,s.getItem(`${t}_trCam`)!==null?s.getItem(`${t}_trCam`):"Orthographic"),s.setItem(`${t}_blCam`,s.getItem(`${t}_blCam`)!==null?s.getItem(`${t}_blCam`):"Front"),s.setItem(`${t}_brCam`,s.getItem(`${t}_brCam`)!==null?s.getItem(`${t}_brCam`):"Top"),s.setItem(`${t}_tlRender`,s.getItem(`${t}_tlRender`)!==null?s.getItem(`${t}_tlRender`):"Renderer"),s.setItem(`${t}_trRender`,s.getItem(`${t}_trRender`)!==null?s.getItem(`${t}_trRender`):"Renderer"),s.setItem(`${t}_blRender`,s.getItem(`${t}_blRender`)!==null?s.getItem(`${t}_blRender`):"Renderer"),s.setItem(`${t}_brRender`,s.getItem(`${t}_brRender`)!==null?s.getItem(`${t}_brRender`):"Renderer");const n={Vector2:x.Vector2,Vector3:x.Vector3,Vector4:x.Vector4,Quaternion:x.Quaternion,Matrix4:x.Matrix4,Spherical:x.Spherical,Box3:x.Box3,Sphere:x.Sphere,Raycaster:x.Raycaster};Ds.install({THREE:n}),this.setupScene(),this.setupTools();const r=localStorage.getItem(this.expandedCameraVisibility);r!==null&&(this.cameraVisibility=r==="open"),this.saveExpandedCameraVisibility();const o=localStorage.getItem(this.expandedLightVisibility);o!==null&&(this.lightVisibility=o==="open"),this.saveExpandedLightVisibility();const l=localStorage.getItem(this.expandedGridVisibility);l!==null&&(this.gridVisibility=l==="open"),this.grid.visible=this.gridVisibility,this.saveExpandedGridVisibility(),et.instance=this}componentDidMount(){this.enable(),this.assignControls(),this.resize(),this.play(),xt.instance.setApp(this.props.app,this.props.three),xt.instance.activeCamera=this.debugCamera}componentDidUpdate(e,t,s){t.mode!==this.state.mode&&(this.assignControls(),this.resize())}componentWillUnmount(){this.disable(),Re.removeEditorGroup("View Settings")}render(){const e=[];return this.cameras.forEach((t,s)=>{e.push(s)}),C.jsxs("div",{className:"multiview",children:[C.jsx("canvas",{ref:this.canvasRef}),C.jsxs("div",{className:`cameras ${this.state.mode==="Single"||this.state.mode==="Stacked"?"single":""}`,ref:this.containerRef,children:[this.state.mode==="Single"&&C.jsx(C.Fragment,{children:C.jsx(Zi,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}})}),(this.state.mode==="Side by Side"||this.state.mode==="Stacked")&&C.jsxs(C.Fragment,{children:[C.jsx(Zi,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),C.jsx(Zi,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.trCam),this.trCam=s,localStorage.setItem(`${this.appID}_trCam`,s.name),this.createControls(s,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}})]}),this.state.mode==="Quad"&&C.jsxs(C.Fragment,{children:[C.jsx(Zi,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),C.jsx(Zi,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.trCam),this.trCam=s,localStorage.setItem(`${this.appID}_trCam`,s.name),this.createControls(s,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}}),C.jsx(Zi,{name:"bl",camera:this.blCam,options:e,ref:this.blWindow,onSelectCamera:t=>{this.controls.get(this.blCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.blCam),this.blCam=s,localStorage.setItem(`${this.appID}_blCam`,s.name),this.createControls(s,this.blWindow.current))},onSelectRenderMode:t=>{this.blRender=t,localStorage.setItem(`${this.appID}_blRender`,t)}}),C.jsx(Zi,{name:"br",camera:this.brCam,options:e,ref:this.brWindow,onSelectCamera:t=>{this.controls.get(this.brCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.brCam),this.brCam=s,localStorage.setItem(`${this.appID}_brCam`,s.name),this.createControls(s,this.brWindow.current))},onSelectRenderMode:t=>{this.brRender=t,localStorage.setItem(`${this.appID}_brRender`,t)}})]})]}),C.jsxs("div",{className:"settings",children:[C.jsx(al,{title:"View",index:Zf.indexOf(this.state.mode),options:Zf,onSelect:t=>{t!==this.state.mode&&(this.killControls(),this.setState({mode:t}),localStorage.setItem(`${this.appID}_mode`,t))},open:this.state.modeOpen,onToggle:t=>{this.setState({modeOpen:t,renderModeOpen:!1,interactionModeOpen:!1})}}),C.jsx(al,{title:"Interact",index:this.state.interactionMode==="Orbit"?0:1,options:["Orbit Mode","Selection Mode"],onSelect:t=>{this.interactionHelper.visible=t==="Selection Mode",this.setState({interactionMode:this.interactionHelper.visible?"Selection":"Orbit"})},open:this.state.interactionModeOpen,onToggle:t=>{this.setState({modeOpen:!1,renderModeOpen:!1,interactionModeOpen:t})}}),C.jsx(sh,{name:"cameraHelper",icon:_N,selected:this.cameraVisibility,height:24,top:2,onClick:t=>{if(this.cameraVisibility=t,this.saveExpandedCameraVisibility(),this.cameraHelpers.forEach(s=>{s.visible=t}),this.selectedItem!==void 0&&!t){const s=this.cameraHelpers.get(this.selectedItem.name);s!==void 0&&(s.visible=!0)}}}),C.jsx(sh,{name:"lightHelper",icon:bN,selected:this.lightVisibility,height:24,top:4,onClick:t=>{if(this.lightVisibility=t,this.saveExpandedLightVisibility(),this.lightHelpers.forEach(s=>{s.visible=t}),this.selectedItem!==void 0&&!t&&this.selectedItem.isLight===!0){const s=this.lightHelpers.get(this.selectedItem.name);s!==void 0&&(s.visible=!0)}}}),C.jsx(sh,{name:"gridHelper",icon:TN,selected:this.gridVisibility,height:21,width:21,onClick:t=>{this.gridVisibility=t,this.saveExpandedGridVisibility(),this.grid.visible=t}})]},this.state.lastUpdate)]})}setupRenderer=e=>{this.renderer&&this.renderer.dispose();const t=this.canvasRef.current;this.props.three.canvas=t;const s=e.value;s.type==="WebGLRenderer"?(this.renderer=new x.WebGLRenderer({canvas:t,stencil:!1}),this.grid.visible=!0):s.type==="WebGPURenderer"&&(this.renderer=new mo({canvas:t,stencil:!1}),this.grid.visible=!1),this.renderer&&(this.renderer.autoClear=!1,this.renderer.shadowMap.enabled=!0,this.renderer.setPixelRatio(devicePixelRatio),this.renderer.setClearColor(0),this.resize(),this.props.three.renderer=this.renderer)};setupScene(){this.scene.name="Debug Scene",this.scene.uuid="Debug Scene",this.helpersContainer.name="helpers",this.scene.add(this.helpersContainer),this.grid.position.y=-1,this.scene.add(this.grid),this.interactionHelper.name="interactionHelper",this.interactionHelper.visible=!1,this.helpersContainer.add(this.interactionHelper);const e=(n,r)=>{const o=new x.OrthographicCamera(-100,100,100,-100,0,3e3);return o.name=n,o.position.copy(r),o.lookAt(0,0,0),this.cameras.set(n,o),o},t=1e3;e("Top",new x.Vector3(0,t,0)),e("Bottom",new x.Vector3(0,-t,0)),e("Left",new x.Vector3(-t,0,0)),e("Right",new x.Vector3(t,0,0)),e("Front",new x.Vector3(0,0,t)),e("Back",new x.Vector3(0,0,-t)),e("Orthographic",new x.Vector3(t,t,t)),e("UI",new x.Vector3),this.debugCamera=new x.PerspectiveCamera(60,1,.01,5e3),this.debugCamera.name="Debug",this.debugCamera.position.set(500,500,500),this.debugCamera.lookAt(0,0,0),this.cameras.set("Debug",this.debugCamera),this.currentCamera=this.debugCamera;const s=localStorage,i=this.props.three.app.appID;this.tlCam=this.cameras.get(s.getItem(`${i}_tlCam`)),this.trCam=this.cameras.get(s.getItem(`${i}_trCam`)),this.blCam=this.cameras.get(s.getItem(`${i}_blCam`)),this.brCam=this.cameras.get(s.getItem(`${i}_brCam`)),this.tlCam===void 0&&(this.tlCam=this.cameras.get("Debug")),this.trCam===void 0&&(this.trCam=this.cameras.get("Orthographic")),this.blCam===void 0&&(this.blCam=this.cameras.get("Front")),this.brCam===void 0&&(this.brCam=this.cameras.get("Top"))}setupTools(){this.splineEditor=new zy(this.currentCamera,this.app),this.splineEditor.initDebug(),this.helpersContainer.add(this.splineEditor)}play(){this.playing=!0,this.onUpdate()}pause(){this.playing=!1,cancelAnimationFrame(this.rafID),this.rafID=-1}toggleOrbitControls(e){this.controls.forEach(t=>{t.enabled=!e})}update(){this.renderer&&(this.renderer instanceof x.WebGLRenderer?this.renderer?.clear():this.renderer instanceof mo&&this.renderer?.clearAsync()),this.controls.forEach(e=>e.update()),this.cameraHelpers.forEach(e=>e.update()),this.lightHelpers.forEach(e=>{e.update!==void 0&&e.update()}),this.props.onSceneUpdate!==void 0&&this.currentScene!==void 0&&this.props.onSceneUpdate(this.currentScene)}draw(){switch(this.renderer&&(this.renderer instanceof x.WebGLRenderer?this.renderer?.clear():this.renderer instanceof mo&&this.renderer?.clearAsync()),this.state.mode){case"Single":this.drawSingle();break;case"Side by Side":case"Stacked":this.drawDouble();break;case"Quad":this.drawQuad();break}}onUpdate=()=>{this.playing&&(this.update(),this.draw(),this.rafID=requestAnimationFrame(this.onUpdate))};enable(){const e=this.containerRef.current;e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("click",this.onClick),window.addEventListener("keydown",this.onKey),window.addEventListener("resize",this.resize),this.app.addEventListener(Q.ADD_SCENE,this.addScene),this.app.addEventListener(Q.SET_SCENE,this.sceneUpdate),this.app.addEventListener(Q.ADD_CAMERA,this.addCamera),this.app.addEventListener(Q.REMOVE_CAMERA,this.removeCamera),this.app.addEventListener(Q.SET_OBJECT,this.onSetSelectedItem)}disable(){const e=this.containerRef.current;e.removeEventListener("mousemove",this.onMouseMove),e.removeEventListener("click",this.onClick),window.removeEventListener("keydown",this.onKey),window.removeEventListener("resize",this.resize),this.app.removeEventListener(Q.ADD_SCENE,this.addScene),this.app.removeEventListener(Q.SET_SCENE,this.sceneUpdate),this.app.removeEventListener(Q.ADD_CAMERA,this.addCamera),this.app.removeEventListener(Q.REMOVE_CAMERA,this.removeCamera),this.app.removeEventListener(Q.SET_OBJECT,this.onSetSelectedItem)}resize=()=>{this.width=window.innerWidth-300,this.height=window.innerHeight,this.renderer?.setSize(this.width,this.height);const e=Math.floor(this.width/2),t=Math.floor(this.height/2);this.props.three.resize(this.width,this.height),this.props.onSceneResize!==void 0&&this.currentScene!==void 0&&this.props.onSceneResize(this.currentScene,this.width,this.height);let s=this.width,i=this.height;switch(this.state.mode){case"Side by Side":s=e,i=this.height;break;case"Stacked":s=this.width,i=t;break;case"Quad":s=e,i=t;break}const n=s/i;this.cameras.forEach(r=>{r instanceof x.OrthographicCamera?(r.left=s/-2,r.right=s/2,r.top=i/2,r.bottom=i/-2,r.name==="UI"&&(r.position.x=this.width/2,r.position.y=this.height/-2,r.position.z=100),r.updateProjectionMatrix()):r instanceof x.PerspectiveCamera&&(r.aspect=n,r.updateProjectionMatrix()),this.cameraHelpers.get(r.name)?.update()})};addScene=e=>{const t=this.props.scenes.get(e.value.name);if(t!==void 0){const s=new t;s.visible=!1,this.props.onSceneSet!==void 0&&this.props.onSceneSet(s),this.props.three.scene=s,this.scenes.set(e.value.name,s),this.scene.add(s)}};sceneUpdate=e=>{this.currentScene!==void 0&&(this.currentScene.visible=!1,this.clearLightHelpers());const t=this.scene.getObjectByName(e.value.name);t!==void 0&&(this.currentScene=t,this.currentScene.visible=!0,this.addLightHelpers(this.currentScene))};addCamera=e=>{const t=e.value,s=`${this.props.three.scene?.name}_${t.name}`,i=this.props.three.scene?.getObjectByProperty("uuid",t.uuid);if(i!==void 0){const n=i;this.cameras.set(s,n);const r=new x.CameraHelper(n);r.visible=this.cameraVisibility,this.cameraHelpers.set(s,r),this.helpersContainer.add(r),this.setState({lastUpdate:Date.now()})}};removeCamera=e=>{const t=this.cameraHelpers.get(e.value.name);t!==void 0&&(this.helpersContainer.remove(t),t.dispose()),this.cameras.delete(e.value.name),this.setState({lastUpdate:Date.now()})};onMouseMove=e=>{const t=new x.Vector2;this.renderer?.getSize(t);const s=Math.min(e.clientX,t.x),i=Math.min(e.clientY,t.y);this.pointer.x=Ki(s,0,t.x,-1,1),this.pointer.y=Ki(i,0,t.y,1,-1);const n=t.x/2,r=t.y/2,o=()=>{s<n?this.pointer.x=Ki(s,0,n,-1,1):this.pointer.x=Ki(s,n,t.x,-1,1)},l=()=>{i<r?this.pointer.y=Ki(i,0,r,1,-1):this.pointer.y=Ki(i,r,t.y,1,-1)};switch(this.state.mode){case"Quad":o(),l();break;case"Side by Side":o();break;case"Stacked":l(),l();break}if(this.updateCamera(s,i,n,r),this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const c=this.raycaster.intersectObjects(this.currentScene.children);c.length>0&&this.interactionHelper.position.copy(c[0].point)};onClick=e=>{if(this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const t=new x.Vector2;if(this.renderer.getSize(t),e.clientX>=t.x)return;this.onMouseMove(e);const s=this.raycaster.intersectObjects(this.currentScene.children);s.length>0&&(this.props.three.getObject(s[0].object.uuid),this.interactionHelper.visible=!1,this.setState({interactionMode:"Orbit",lastUpdate:Date.now()}))};onKey=e=>{if(this.selectedItem!==void 0){if(e.ctrlKey){if(this.currentCamera.name==="UI")return;const t=this.controls.get(this.currentCamera.name);e.key==="0"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Ds(this.currentCamera,this.currentWindow.current),this.selectedItem instanceof x.Mesh||this.selectedItem instanceof x.SkinnedMesh?(this.selectedItem.geometry.computeBoundingBox(),this.cameraControls.fitToBox(this.selectedItem.geometry.boundingBox,!0)):this.cameraControls.fitToSphere(this.selectedItem,!0),this.updateCameraControls(t,!0)):e.key==="1"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Ds(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,Math.PI*.5,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="2"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Ds(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,0,!0),this.cameraControls.moveTo(this.selectedItem.position.x,0,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="3"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Ds(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI/2,Math.PI/2,!0),this.cameraControls.moveTo(0,this.selectedItem.position.y,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="4"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Ds(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI,Math.PI/2,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="5"&&(e.preventDefault(),this.clearControls(),this.cameraControls=new Ds(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(zo(45),zo(45),!0),this.updateCameraControls(t))}else if(this.currentTransform!==void 0)switch(e.key){case"r":this.currentTransform.setMode("rotate");break;case"s":this.currentTransform.setMode("scale");break;case"t":this.currentTransform.setMode("translate");break;case"q":this.currentTransform.setSpace(this.currentTransform.space==="local"?"world":"local");break}}};onSetSelectedItem=e=>{this.selectedItem!==void 0&&this.updateSelectedItemHelper(!1),this.selectedItem=this.currentScene.getObjectByProperty("uuid",e.value.uuid),this.selectedItem!==void 0&&(this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),xt.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=xt.instance.add(e.value.name),this.currentTransform.attach(this.selectedItem),this.helpersContainer.add(this.currentTransform.getHelper()),this.currentTransform.addEventListener("objectChange",this.onUpdateTransform),this.updateSelectedItemHelper(!0))};updateSelectedItemHelper(e){if(this.selectedItem!==void 0)if(this.cameraVisibility){if(this.selectedItem.isLight===!0&&!this.lightVisibility){const t=this.lightHelpers.get(this.selectedItem.name);t!==void 0&&(t.visible=e)}}else{const t=this.cameraHelpers.get(this.selectedItem.name);t!==void 0&&(t.visible=e)}}onUpdateTransform=()=>{this.selectedItem!==void 0&&(this.props.three.updateObject(this.selectedItem.uuid,"position",this.selectedItem.position),this.props.three.updateObject(this.selectedItem.uuid,"rotation",{x:this.selectedItem.rotation.x,y:this.selectedItem.rotation.y,z:this.selectedItem.rotation.z}),this.props.three.updateObject(this.selectedItem.uuid,"scale",this.selectedItem.scale),Al.instance.update())};clearLightHelpers=()=>{this.lightHelpers.forEach(e=>{this.helpersContainer.remove(e),e.dispose()}),this.lightHelpers.clear()};addLightHelpers=e=>{e.traverse(t=>{if(t.type.search("Light")>-1){let s;switch(t.type){case"DirectionalLight":s=new x.DirectionalLightHelper(t,100),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"HemisphereLight":s=new x.HemisphereLightHelper(t,250),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"RectAreaLight":s=new UR(t),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"PointLight":s=new x.PointLightHelper(t,100),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"SpotLight":s=new x.SpotLightHelper(t),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break}}})};createControls(e,t){const s=this.controls.get(e.name);if(s!==void 0&&s.dispose(),this.controls.delete(e.name),e.name==="UI")return;const i=new zR(e,t);switch(i.enableDamping=!0,i.dampingFactor=.05,e.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":i.enableRotate=!1;break}this.controls.set(e.name,i)}clearCamera(e){const t=this.cameraHelpers.get(e.name);t!==void 0&&(this.helpersContainer.remove(t),t.dispose(),this.cameraHelpers.delete(e.name));const s=this.controls.get(e.name);s!==void 0&&(s.dispose(),this.controls.delete(e.name))}killControls(){this.controls.forEach((e,t)=>{e.dispose();const s=this.cameraHelpers.get(t);s!==void 0&&(this.helpersContainer.remove(s),s.dispose()),this.cameraHelpers.delete(t),this.controls.delete(t)}),this.controls.clear(),this.cameraHelpers.clear()}assignControls(){switch(this.state.mode){case"Single":this.createControls(this.tlCam,this.tlWindow.current);break;case"Side by Side":case"Stacked":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current);break;case"Quad":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current),this.createControls(this.blCam,this.blWindow.current),this.createControls(this.brCam,this.brWindow.current);break}}updateCamera=(e,t,s,i)=>{switch(this.state.mode){case"Quad":t<i?e<s?this.currentCamera=this.tlCam:this.currentCamera=this.trCam:e<s?this.currentCamera=this.blCam:this.currentCamera=this.brCam;break;case"Side by Side":e<s?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break;case"Single":this.currentCamera=this.tlCam;break;case"Stacked":t<i?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break}this.splineEditor.camera=this.currentCamera,this.raycaster.setFromCamera(this.pointer,this.currentCamera),this.currentCamera===this.tlCam?this.currentWindow=this.tlWindow:this.currentCamera===this.trCam?this.currentWindow=this.trWindow:this.currentCamera===this.blCam?this.currentWindow=this.blWindow:this.currentCamera===this.brCam&&(this.currentWindow=this.brWindow),xt.instance.updateCamera(this.currentCamera,this.currentWindow.current)};updateCameraControls=(e,t=!1)=>{if(this.selectedItem===void 0)return;cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.cameraControls&&(this.cameraControls.smoothTime=.1);const s=.15,i=new x.Clock;i.start(),this.selectedItem.getWorldPosition(e.target0);const n=()=>{const r=i.getDelta();this.cameraControls&&this.cameraControls.update(r),t&&(e.target.lerp(e.target0,s),e.object.position.lerp(e.position0,s),e.object.zoom=rr(e.object.zoom,e.zoom0,s),e.object.updateProjectionMatrix(),e.dispatchEvent({type:"change"})),i.getElapsedTime()>=.5?(cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.clearControls()):this.cameraControlsRafID=requestAnimationFrame(n)};n()};clearControls=()=>{this.cameraControls!==void 0&&(this.cameraControls.disconnect(),this.cameraControls.dispose(),this.cameraControls=void 0)};saveExpandedCameraVisibility(){localStorage.setItem(this.expandedCameraVisibility,this.cameraVisibility?"open":"closed")}saveExpandedLightVisibility(){localStorage.setItem(this.expandedLightVisibility,this.lightVisibility?"open":"closed")}saveExpandedGridVisibility(){localStorage.setItem(this.expandedGridVisibility,this.gridVisibility?"open":"closed")}getSceneOverride(e){switch(e){case"Depth":return this.depthMaterial;case"Normals":return this.normalsMaterial;case"Renderer":return null;case"UVs":return this.uvMaterial;case"Wireframe":return this.wireframeMaterial}return null}drawTo(e,t,s,i,n,r){switch(n.name){case"Left":case"Right":this.grid.rotation.z=Math.PI/2;break;case"Front":case"Back":this.grid.rotation.x=Math.PI/2;break}this.scene.overrideMaterial=r,this.renderer&&(this.renderer?.setViewport(e,t,s,i),this.renderer?.setScissor(e,t,s,i),this.renderer instanceof x.WebGLRenderer?this.renderer?.render(this.scene,n):this.renderer instanceof mo&&this.renderer?.renderAsync(this.scene,n)),this.grid.rotation.set(0,0,0)}drawSingle(){const e=this.getSceneOverride(this.tlRender);this.drawTo(0,0,this.width,this.height,this.tlCam,e)}drawDouble=()=>{const e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),s=Math.floor(this.width/2),i=Math.floor(this.height/2);if(this.state.mode==="Side by Side")this.drawTo(0,0,s,this.height,this.tlCam,e),this.drawTo(s,0,s,this.height,this.trCam,t);else{const n=this.height-i;this.drawTo(0,n,this.width,i,this.tlCam,e),this.drawTo(0,0,this.width,i,this.trCam,t)}};drawQuad=()=>{const e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),s=this.getSceneOverride(this.blRender),i=this.getSceneOverride(this.brRender),n=Math.floor(this.width/2),r=Math.floor(this.height/2);let o=0,l=0;l=this.height-r,o=0,this.drawTo(o,l,n,r,this.tlCam,e),o=n,this.drawTo(o,l,n,r,this.trCam,t),l=0,o=0,this.scene.overrideMaterial=s,this.drawTo(o,l,n,r,this.blCam,s),o=n,this.drawTo(o,l,n,r,this.brCam,i)};get appID(){return this.props.three.app.appID}get mode(){return this.state.mode}get three(){return this.props.three}get expandedCameraVisibility(){return`${this.appID}_multiviewCameraVisibility`}get expandedLightVisibility(){return`${this.appID}_multiviewLightVisibility`}get expandedGridVisibility(){return`${this.appID}_multiviewGridVisibility`}}class Al extends W.Component{static instance;app;matrix=new x.Matrix4;position=new x.Vector3;rotation=new x.Euler;scale=new x.Vector3;open=!1;constructor(e){super(e),this.app=e.app;const t=localStorage.getItem(this.expandedName),s=t!==null?t==="open":!1;this.open=s,this.saveExpanded(),this.state={lastUpdated:0,expanded:s},this.matrix.elements=e.object.matrix,e.object.uuid.length>0&&(this.position.setFromMatrixPosition(this.matrix),this.rotation.setFromRotationMatrix(this.matrix),this.scale.setFromMatrixScale(this.matrix)),Al.instance=this}update(){if(et.instance){const e=et.instance.selectedItem;if(e===void 0)return;this.position.x=ss(e.position.x,3),this.position.y=ss(e.position.y,3),this.position.z=ss(e.position.z,3),this.rotation.copy(e.rotation),this.scale.x=ss(e.scale.x,3),this.scale.y=ss(e.scale.y,3),this.scale.z=ss(e.scale.z,3),this.setState({lastUpdated:Date.now()})}}render(){return C.jsx(cs,{app:this.app,title:"Transform",expanded:this.open,items:[{title:"Position",prop:"position",type:"grid3",step:.1,value:this.position,onChange:this.updateTransform},{title:"Rotation",prop:"rotation",type:"euler",value:this.rotation,onChange:this.updateTransform},{title:"Scale",prop:"scale",type:"grid3",value:this.scale,onChange:this.updateTransform},{title:"Visible",prop:"visible",type:"boolean",value:this.props.object.visible,onChange:this.updateTransform}],onToggle:e=>{this.open=e,this.saveExpanded()}},this.state.lastUpdated)}updateTransform=(e,t)=>{const s=e==="rotation"?{x:t._x,y:t._y,z:t._z}:t;this.props.three.updateObject(this.props.object.uuid,e,s);const i=this.props.three.getScene(this.props.object.uuid);if(i){const n=i.getObjectByProperty("uuid",this.props.object.uuid);qe(n,e,s)}};saveExpanded(){localStorage.setItem(this.expandedName,this.open?"open":"closed")}get expandedName(){return`${this.props.three.app.appID}_transform`}}function Qf(a){switch(a){case"color":return"Color";case"intensity":return"Intensity";case"decay":return"Decay";case"distance":return"Distance";case"angle":return"Angle";case"penumbra":return"Penumbra";case"groundColor":return"Ground Color";case"width":return"Width";case"height":return"Height"}return a}function SN(a,e,t){function s(){return`${t.app.appID}_light`}const i=localStorage.getItem(s()),n=i!==null?i==="open":!1;function r(l){localStorage.setItem(s(),l?"open":"closed")}const o=[];if(a.lightInfo!==void 0)for(const l in a.lightInfo){const c=a.lightInfo[l];c!==void 0&&(c.isColor!==void 0?o.push({title:Qf(l),prop:l,type:"color",value:c,onChange:(h,u)=>{const d=new x.Color(u);t.updateObject(a.uuid,h,d);const p=t.getScene(a.uuid);if(p!==null){const f=p.getObjectByProperty("uuid",a.uuid);qe(f,h,d)}}}):o.push({title:Qf(l),prop:l,type:typeof c,value:c,step:typeof c=="number"?.01:void 0,onChange:(h,u)=>{t.updateObject(a.uuid,h,u);const d=t.getScene(a.uuid);if(d!==null){const p=d.getObjectByProperty("uuid",a.uuid);qe(p,h,u)}}}))}return C.jsx(cs,{app:e,title:"Light",items:o,expanded:n,onToggle:l=>{r(l)}})}function vN(a){const e=a.object,t=a.three;function s(){return`${t.app.appID}_animation`}const i=localStorage.getItem(s()),n=i!==null?i==="open":!1;function r(d){localStorage.setItem(s(),d?"open":"closed")}const o=[],l=[];let c=0;e.animations.forEach(d=>{c=Math.max(c,d.duration),d.duration>0&&l.push({title:d.name,items:[{title:"Duration",type:"number",value:d.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),o.push({title:"Animations",items:l});let h;const u=t.getScene(e.uuid);if(u!==null){const d=u.getObjectByProperty("uuid",e.uuid);if(d!==void 0){const p=d.mixer;if(p!==void 0){const m=[{title:"Time Scale",type:"range",value:p.timeScale,step:.01,min:-1,max:2,onChange:(y,g)=>{p.timeScale=g,t.updateObject(e.uuid,"mixer.timeScale",g)}}];m.push({title:"Stop All",type:"button",onChange:()=>{p.stopAllAction(),t.requestMethod(e.uuid,"stopAllAction",void 0,"mixer")}}),o.push({title:"Mixer",items:m}),h=new x.SkeletonHelper(d),et.instance?.scene.add(h)}}}return W.useEffect(()=>()=>{h!==void 0&&ii(h)},[]),C.jsx(cs,{app:a.app,title:"Animation",items:o,expanded:n,onToggle:d=>{r(d)}})}const $h={name:"",uuid:"",type:"",visible:!1,matrix:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};let ft={...$h};function Gy(a){const[e,t]=W.useState(-1);W.useEffect(()=>{function r(l){ft={...l.value},t(Date.now())}function o(){ft={...$h},t(Date.now())}return a.app.addEventListener(Q.SET_SCENE,o),a.app.addEventListener(Q.SET_OBJECT,r),()=>{a.app.removeEventListener(Q.SET_SCENE,o),a.app.removeEventListener(Q.SET_OBJECT,r)}},[]);const s=ft.type.toLowerCase(),i=ft.animations.length>0||ft.mixer!==void 0,n=s.search("mesh")>-1||s.search("line")>-1||s.search("points")>-1;return C.jsx(fa,{app:a.app,label:"Inspector",button:ft.uuid.length>0?C.jsx("button",{className:"remove",onClick:()=>{xt.instance.remove(ft.name),ft={...$h},t(Date.now())}}):void 0,children:C.jsx("div",{id:"Inspector",className:a.class,children:ft.uuid.length>0&&C.jsxs(C.Fragment,{children:[C.jsxs(C.Fragment,{children:[C.jsx(Eo,{type:"string",title:"Name",prop:"name",value:ft.name,disabled:!0}),C.jsx(Eo,{type:"string",title:"Type",prop:"type",value:ft.type,disabled:!0}),C.jsx(Eo,{type:"string",title:"UUID",prop:"uuid",value:ft.uuid,disabled:!0})]}),C.jsxs(C.Fragment,{children:[C.jsx(Al,{object:ft,app:a.app,three:a.three}),i?C.jsx(vN,{app:a.app,object:ft,three:a.three}):null,s.search("camera")>-1?$x(ft,a.app,a.three):null,s.search("light")>-1?SN(ft,a.app,a.three):null,n?Vx(ft,a.app,a.three):null]})]})},e)},"Inspector")}class wN extends W.Component{app;autoClear=!0;autoClearColor=!0;autoClearDepth=!0;autoClearStencil=!0;outputColorSpace=x.SRGBColorSpace;localClippingEnabled=!1;clearColor=new x.Color(0);clearAlpha=1;toneMapping=x.NoToneMapping;toneMappingExposure=1;type="";constructor(e){super(e),this.app=e.app;const t=localStorage.getItem(this.expandedName),s=t!==null?t==="open":!1;if(this.state={expanded:s,lastUpdated:Date.now()},this.saveExpanded(s),et.instance){const i=et.instance.renderer;i&&(this.autoClear=i.autoClear,this.autoClearColor=i.autoClearColor,this.autoClearDepth=i.autoClearDepth,this.autoClearStencil=i.autoClearStencil,this.clearAlpha=i.getClearAlpha(),this.toneMapping=i.toneMapping,this.toneMappingExposure=i.toneMappingExposure,i instanceof x.WebGLRenderer&&(this.localClippingEnabled=i.localClippingEnabled,i.getClearColor(this.clearColor)))}this.app.addEventListener(Q.ADD_RENDERER,this.onAddRenderer)}componentwillunmount(){this.app.removeEventListener(Q.ADD_RENDERER,this.onAddRenderer)}onAddRenderer=e=>{const t=e.value;if(this.autoClear=t.autoClear,this.autoClearColor=t.autoClearColor,this.autoClearDepth=t.autoClearDepth,this.autoClearStencil=t.autoClearStencil,this.outputColorSpace=t.outputColorSpace,this.localClippingEnabled=t.localClippingEnabled,this.clearAlpha=t.clearAlpha,this.type=t.type,this.toneMapping=t.toneMapping,this.toneMappingExposure=t.toneMappingExposure,this.clearColor.setStyle(t.clearColor,x.LinearSRGBColorSpace),x.ColorManagement.enabled=t.colorManagement,et.instance){const s=et.instance.renderer;s&&(s.autoClearColor=this.autoClearColor,s.outputColorSpace=this.outputColorSpace,s.localClippingEnabled=this.localClippingEnabled,s.toneMapping=this.toneMapping,s.toneMappingExposure=this.toneMappingExposure,s.setClearColor(t.clearColor,this.clearAlpha))}this.setState({lastUpdated:Date.now()})};render(){const e=()=>{if(et.instance){const t=et.instance.renderer;t&&(t.autoClearColor=this.autoClearColor,t.outputColorSpace=this.outputColorSpace,t.localClippingEnabled=this.localClippingEnabled,t.toneMapping=this.toneMapping,t.toneMappingExposure=this.toneMappingExposure,t.setClearColor(this.clearColor.getStyle(),this.clearAlpha),this.props.three.updateRenderer({autoClear:this.autoClear,autoClearColor:this.autoClearColor,autoClearDepth:this.autoClearDepth,autoClearStencil:this.autoClearStencil,outputColorSpace:this.outputColorSpace,localClippingEnabled:this.localClippingEnabled,clearAlpha:this.clearAlpha,clearColor:this.clearColor.getStyle(),colorManagement:x.ColorManagement.enabled,toneMapping:this.toneMapping,toneMappingExposure:this.toneMappingExposure}))}};return C.jsx(cs,{app:this.app,title:"Renderer",expanded:this.state.expanded,items:[{type:"boolean",title:"Auto Clear",value:this.autoClear,onChange:(t,s)=>{this.autoClear=s}},{type:"boolean",title:"Auto Clear Color",value:this.autoClearColor,onChange:(t,s)=>{this.autoClearColor=s,e()}},{type:"boolean",title:"Auto Clear Depth",value:this.autoClearDepth,onChange:(t,s)=>{this.autoClearDepth=s,e()}},{type:"boolean",title:"Auto Clear Stencil",value:this.autoClearStencil,onChange:(t,s)=>{this.autoClearStencil=s,e()}},{type:"boolean",title:"Local Clipping",value:this.localClippingEnabled,onChange:(t,s)=>{this.localClippingEnabled=s,e()}},{type:"color",title:"Clear Color",value:`#${this.clearColor.getHexString()}`,onChange:(t,s)=>{this.clearColor.setStyle(s),e()}},{type:"range",title:"Clear Alpha",min:0,max:1,step:.01,value:this.clearAlpha,onChange:(t,s)=>{this.clearAlpha=s,e()}},{type:"boolean",title:"Clear Management",value:x.ColorManagement.enabled,onChange:(t,s)=>{x.ColorManagement.enabled=s,e()}},{type:"option",title:"Color Space",value:this.outputColorSpace,options:[{title:"No Color Space",value:x.NoColorSpace},{title:"SRB Color Space",value:x.SRGBColorSpace},{title:"Linear SRB Color Space",value:x.LinearSRGBColorSpace}],onChange:(t,s)=>{this.outputColorSpace=s,e()}},{type:"option",title:"Tone Mapping",value:this.toneMapping,options:[{title:"None ",value:x.NoToneMapping},{title:"Linear ",value:x.LinearToneMapping},{title:"Reinhard",value:x.ReinhardToneMapping},{title:"Cineon ",value:x.CineonToneMapping},{title:"ACES Filmic",value:x.ACESFilmicToneMapping},{title:"AgX",value:x.AgXToneMapping},{title:"Neutral",value:x.NeutralToneMapping},{title:"Custom",value:x.CustomToneMapping}],onChange:(t,s)=>{this.toneMapping=s,e()}},{type:"range",title:"Tone Mapping Exposure",value:this.toneMappingExposure,min:0,max:2,step:.01,onChange:(t,s)=>{this.toneMappingExposure=s,e()}},{type:"string",title:"Type",value:this.type,disabled:!0}],onToggle:t=>{this.setState({expanded:t}),this.saveExpanded(t)}},Math.random())}saveExpanded(e){localStorage.setItem(this.expandedName,e?"open":"closed")}get expandedName(){return`${this.props.three.app.appID}_renderer`}}function Vy(a){const[e]=W.useState([]),[t]=W.useState([]),[s,i]=W.useState(0),n=l=>{const c=l.value;e.push(c),t.push(C.jsx(fa,{app:a.app,label:`Scene: ${c.name}`,scene:c,open:!0,onRefresh:()=>{a.three.refreshScene(c.name)},children:C.jsx(hh,{app:a.app,child:c,scene:c,three:a.three})},Math.random())),i(Date.now())},r=l=>{const c=l.value;for(let h=0;h<e.length;h++)if(c.uuid===e[h].uuid){e[h]=c,t[h]=C.jsx(fa,{app:a.app,label:`Scene: ${c.name}`,scene:c,open:!0,onRefresh:()=>{a.three.refreshScene(c.name)},children:C.jsx(hh,{app:a.app,child:c,scene:c,three:a.three})},Math.random()),i(Date.now());return}},o=l=>{const c=l.value;for(let h=0;h<e.length;h++)if(c.uuid===e[h].uuid){e.splice(h,1),t.splice(h,1),i(Date.now());return}};return W.useEffect(()=>(a.app.addEventListener(Q.ADD_SCENE,n),a.app.addEventListener(Q.REFRESH_SCENE,r),a.app.addEventListener(Q.REMOVE_SCENE,o),()=>{a.app.removeEventListener(Q.ADD_SCENE,n),a.app.removeEventListener(Q.REFRESH_SCENE,r),a.app.removeEventListener(Q.REMOVE_SCENE,o)}),[]),C.jsxs("div",{id:"SidePanel",children:[C.jsx("div",{className:"scenes",children:t},s),C.jsx(Gy,{app:a.app,three:a.three}),C.jsx(wN,{app:a.app,three:a.three}),C.jsx(Re,{app:a.app,three:a.three})]})}function EN(a){return W.useEffect(()=>{function e(o){let l=null;return a.three.scenes.forEach(c=>{o.search(c.uuid)>-1&&(l=c)}),l}const t=o=>{const l=o.value,c=e(l),h=c?.getObjectByProperty("uuid",l);h!==void 0?a.three.setObject(h):console.log(`Hermes - can't find object: ${l}`,c)},s=(o,l,c)=>{const h=e(o),u=h?.getObjectByProperty("uuid",o);u!==void 0?qe(u,l,c):console.log(`Hermes - can't set object: ${o}`,h)},i=o=>{const l=o.value,{key:c,value:h,uuid:u}=l;s(u,c,h)},n=o=>{const l=o.value,h=e(l.uuid)?.getObjectByProperty("uuid",l.uuid);if(h!==void 0){const u=d=>{const p=l.key.split(".");switch(p.length){case 1:h[p[0]]=d;break;case 2:h[p[0]][p[1]]=d;break;case 3:h[p[0]][p[1]][p[2]]=d;break;case 4:h[p[0]][p[1]][p[2]][p[3]]=d;break;case 5:h[p[0]][p[1]][p[2]][p[3]][p[4]]=d;break}h.material.needsUpdate=!0};l.value.src.length>0?rm(l.value.src).then(d=>{d.offset.set(l.value.offset[0],l.value.offset[1]),d.repeat.set(l.value.repeat[0],l.value.repeat[1]),u(d)}):u(null)}},r=o=>{const{key:l,uuid:c,value:h,subitem:u}=o.value,p=e(c)?.getObjectByProperty("uuid",c);if(p!==void 0)try{u!==void 0?nx(p,u)[l](h):p[l](h)}catch(f){console.log("Error requesting method:"),console.log(f),console.log(l),console.log(h)}};return a.app.addEventListener(Q.GET_OBJECT,t),a.app.addEventListener(Q.UPDATE_OBJECT,i),a.app.addEventListener(Q.CREATE_TEXTURE,n),a.app.addEventListener(Q.REQUEST_METHOD,r),()=>{a.app.removeEventListener(Q.GET_OBJECT,t),a.app.removeEventListener(Q.UPDATE_OBJECT,i),a.app.removeEventListener(Q.CREATE_TEXTURE,n),a.app.removeEventListener(Q.REQUEST_METHOD,r)}},[]),null}function Hy(a){return C.jsxs("div",{className:"editor",ref:a.ref,style:a.style,children:[C.jsx("div",{className:"header",children:a.header}),a.children,C.jsx("div",{className:"footer",children:a.footer})]})}function MN(a){return C.jsx(Hy,{children:C.jsxs(C.Fragment,{children:[C.jsx(et,{app:a.app,three:a.three,scenes:a.scenes,onSceneResize:a.onSceneResize,onSceneSet:a.onSceneSet,onSceneUpdate:a.onSceneUpdate}),C.jsx(Vy,{app:a.app,three:a.three})]})})}exports.Accordion=fa;exports.AppRunner=q0;exports.Application=j0;exports.BaseRemote=ol;exports.BaseScene=Y0;exports.ChildObject=Zh;exports.ContainerObject=hh;exports.Draggable=om;exports.DraggableItem=am;exports.Dropdown=lm;exports.DropdownItem=cm;exports.Editor=Hy;exports.ElementProxy=W0;exports.ElementProxyReceiver=nm;exports.ExportTexture=Ri;exports.Inspector=Gy;exports.MultiView=et;exports.NavButton=Xh;exports.ProxyManager=$0;exports.QualityType=jh;exports.RemoteComponents=X0;exports.RemoteTheatre=ex;exports.RemoteThree=ax;exports.SceneInspector=EN;exports.SidePanel=Vy;exports.Spline=Lo;exports.SplineEditor=zy;exports.ThreeEditor=MN;exports.ToolEvents=Q;exports.Transform=xt;exports.WebworkerEventHandlers=V0;exports.capitalize=pa;exports.clamp=Ti;exports.clearComposerGroups=F0;exports.colorToHex=ah;exports.copyToClipboard=Kf;exports.cubicBezier=N0;exports.customizeTheatreElements=Q0;exports.damp=w0;exports.defaultTheatreCallback=g0;exports.detectMaxFrameRate=sm;exports.detectSettings=im;exports.dispose=ii;exports.disposeMaterial=qh;exports.disposeTexture=oh;exports.distance=v0;exports.generateCubemap=O0;exports.hierarchyUUID=ko;exports.inspectComposer=D0;exports.isColor=em;exports.map=S0;exports.mix=rr;exports.noop=da;exports.normalize=Uo;exports.parseModelLite=P0;exports.randomID=Jf;exports.resetThreeObjects=lh;exports.round=ss;exports.roundTo=E0;exports.theatreEditorApp=Z0;
|
|
600
|
+
}`;class lN extends x.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:aN,fragmentShader:oN})}}const Qi=new x.Raycaster,yt=new x.Vector3,_i=new x.Vector3,Ve=new x.Quaternion,Hf={X:new x.Vector3(1,0,0),Y:new x.Vector3(0,1,0),Z:new x.Vector3(0,0,1)},ih={type:"change"},Wf={type:"mouseDown",mode:null},$f={type:"mouseUp",mode:null},jf={type:"objectChange"};class cN extends x.Controls{constructor(e,t=null){super(void 0,t);const s=new mN(this);this._root=s;const i=new gN;this._gizmo=i,s.add(i);const n=new yN;this._plane=n,s.add(n);const r=this;function o(b,T){let S=T;Object.defineProperty(r,b,{get:function(){return S!==void 0?S:T},set:function(M){S!==M&&(S=M,n[b]=M,i[b]=M,r.dispatchEvent({type:b+"-changed",value:M}),r.dispatchEvent(ih))}}),r[b]=T,n[b]=T,i[b]=T}o("camera",e),o("object",void 0),o("enabled",!0),o("axis",null),o("mode","translate"),o("translationSnap",null),o("rotationSnap",null),o("scaleSnap",null),o("space","world"),o("size",1),o("dragging",!1),o("showX",!0),o("showY",!0),o("showZ",!0),o("minX",-1/0),o("maxX",1/0),o("minY",-1/0),o("maxY",1/0),o("minZ",-1/0),o("maxZ",1/0);const l=new x.Vector3,c=new x.Vector3,h=new x.Quaternion,u=new x.Quaternion,d=new x.Vector3,p=new x.Quaternion,f=new x.Vector3,m=new x.Vector3,y=new x.Vector3,g=0,_=new x.Vector3;o("worldPosition",l),o("worldPositionStart",c),o("worldQuaternion",h),o("worldQuaternionStart",u),o("cameraPosition",d),o("cameraQuaternion",p),o("pointStart",f),o("pointEnd",m),o("rotationAxis",y),o("rotationAngle",g),o("eye",_),this._offset=new x.Vector3,this._startNorm=new x.Vector3,this._endNorm=new x.Vector3,this._cameraScale=new x.Vector3,this._parentPosition=new x.Vector3,this._parentQuaternion=new x.Quaternion,this._parentQuaternionInv=new x.Quaternion,this._parentScale=new x.Vector3,this._worldScaleStart=new x.Vector3,this._worldQuaternionInv=new x.Quaternion,this._worldScale=new x.Vector3,this._positionStart=new x.Vector3,this._quaternionStart=new x.Quaternion,this._scaleStart=new x.Vector3,this._getPointer=hN.bind(this),this._onPointerDown=dN.bind(this),this._onPointerHover=uN.bind(this),this._onPointerMove=pN.bind(this),this._onPointerUp=fN.bind(this),t!==null&&this.connect(t)}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&Qi.setFromCamera(e,this.camera);const t=nh(this._gizmo.picker[this.mode],Qi);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&Qi.setFromCamera(e,this.camera);const t=nh(this._plane,Qi,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,Wf.mode=this.mode,this.dispatchEvent(Wf)}}pointerMove(e){const t=this.axis,s=this.mode,i=this.object;let n=this.space;if(s==="scale"?n="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(n="world"),i===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&Qi.setFromCamera(e,this.camera);const r=nh(this._plane,Qi,!0);if(r){if(this.pointEnd.copy(r.point).sub(this.worldPositionStart),s==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),n==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),n==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),i.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(n==="local"&&(i.position.applyQuaternion(Ve.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this._quaternionStart)),n==="world"&&(i.parent&&i.position.add(yt.setFromMatrixPosition(i.parent.matrixWorld)),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(yt.setFromMatrixPosition(i.parent.matrixWorld)))),i.position.x=Math.max(this.minX,Math.min(this.maxX,i.position.x)),i.position.y=Math.max(this.minY,Math.min(this.maxY,i.position.y)),i.position.z=Math.max(this.minZ,Math.min(this.maxZ,i.position.z));else if(s==="scale"){if(t.search("XYZ")!==-1){let o=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(o*=-1),_i.set(o,o,o)}else yt.copy(this.pointStart),_i.copy(this.pointEnd),yt.applyQuaternion(this._worldQuaternionInv),_i.applyQuaternion(this._worldQuaternionInv),_i.divide(yt),t.search("X")===-1&&(_i.x=1),t.search("Y")===-1&&(_i.y=1),t.search("Z")===-1&&(_i.z=1);i.scale.copy(this._scaleStart).multiply(_i),this.scaleSnap&&(t.search("X")!==-1&&(i.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(i.scale.z=Math.round(i.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(s==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const o=20/this.worldPosition.distanceTo(yt.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(yt.copy(this.rotationAxis).cross(this.eye))*o):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(Hf[t]),yt.copy(Hf[t]),n==="local"&&yt.applyQuaternion(this.worldQuaternion),yt.cross(this.eye),yt.length()===0?l=!0:this.rotationAngle=this._offset.dot(yt.normalize())*o),(t==="E"||l)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),n==="local"&&t!=="E"&&t!=="XYZE"?(i.quaternion.copy(this._quaternionStart),i.quaternion.multiply(Ve.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),i.quaternion.copy(Ve.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(ih),this.dispatchEvent(jf)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&($f.mode=this.mode,this.dispatchEvent($f)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(ih),this.dispatchEvent(jf),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Qi}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}}function hN(a){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:a.button};{const e=this.domElement.getBoundingClientRect();return{x:(a.clientX-e.left)/e.width*2-1,y:-(a.clientY-e.top)/e.height*2+1,button:a.button}}}function uN(a){if(this.enabled)switch(a.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(a));break}}function dN(a){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(a.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(a)),this.pointerDown(this._getPointer(a)))}function pN(a){this.enabled&&this.pointerMove(this._getPointer(a))}function fN(a){this.enabled&&(this.domElement.releasePointerCapture(a.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(a)))}function nh(a,e,t){const s=e.intersectObject(a,!0);for(let i=0;i<s.length;i++)if(s[i].object.visible||t)return s[i];return!1}const To=new x.Euler,Fe=new x.Vector3(0,1,0),qf=new x.Vector3(0,0,0),Yf=new x.Matrix4,So=new x.Quaternion,Io=new x.Quaternion,Rs=new x.Vector3,Xf=new x.Matrix4,sa=new x.Vector3(1,0,0),sn=new x.Vector3(0,1,0),ia=new x.Vector3(0,0,1),vo=new x.Vector3,qr=new x.Vector3,Yr=new x.Vector3;class mN extends x.Object3D{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),super.updateMatrixWorld(e)}dispose(){this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}}class gN extends x.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new x.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new x.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),s=e.clone();s.opacity=.15;const i=t.clone();i.opacity=.5;const n=e.clone();n.color.setHex(16711680);const r=e.clone();r.color.setHex(65280);const o=e.clone();o.color.setHex(255);const l=e.clone();l.color.setHex(16711680),l.opacity=.5;const c=e.clone();c.color.setHex(65280),c.opacity=.5;const h=e.clone();h.color.setHex(255),h.opacity=.5;const u=e.clone();u.opacity=.25;const d=e.clone();d.color.setHex(16776960),d.opacity=.25,e.clone().color.setHex(16776960);const f=e.clone();f.color.setHex(7895160);const m=new x.CylinderGeometry(0,.04,.1,12);m.translate(0,.05,0);const y=new x.BoxGeometry(.08,.08,.08);y.translate(0,.04,0);const g=new x.BufferGeometry;g.setAttribute("position",new x.Float32BufferAttribute([0,0,0,1,0,0],3));const _=new x.CylinderGeometry(.0075,.0075,.5,3);_.translate(0,.25,0);function b(Z,ve){const ue=new x.TorusGeometry(Z,.0075,3,64,ve*Math.PI*2);return ue.rotateY(Math.PI/2),ue.rotateX(Math.PI/2),ue}function T(){const Z=new x.BufferGeometry;return Z.setAttribute("position",new x.Float32BufferAttribute([0,0,0,1,1,1],3)),Z}const S={X:[[new x.Mesh(m,n),[.5,0,0],[0,0,-Math.PI/2]],[new x.Mesh(m,n),[-.5,0,0],[0,0,Math.PI/2]],[new x.Mesh(_,n),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new x.Mesh(m,r),[0,.5,0]],[new x.Mesh(m,r),[0,-.5,0],[Math.PI,0,0]],[new x.Mesh(_,r)]],Z:[[new x.Mesh(m,o),[0,0,.5],[Math.PI/2,0,0]],[new x.Mesh(m,o),[0,0,-.5],[-Math.PI/2,0,0]],[new x.Mesh(_,o),null,[Math.PI/2,0,0]]],XYZ:[[new x.Mesh(new x.OctahedronGeometry(.1,0),u.clone()),[0,0,0]]],XY:[[new x.Mesh(new x.BoxGeometry(.15,.15,.01),h.clone()),[.15,.15,0]]],YZ:[[new x.Mesh(new x.BoxGeometry(.15,.15,.01),l.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new x.Mesh(new x.BoxGeometry(.15,.15,.01),c.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},M={X:[[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new x.Mesh(new x.OctahedronGeometry(.2,0),s)]],XY:[[new x.Mesh(new x.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new x.Mesh(new x.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new x.Mesh(new x.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]]},w={START:[[new x.Mesh(new x.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],END:[[new x.Mesh(new x.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],DELTA:[[new x.Line(T(),i),null,null,null,"helper"]],X:[[new x.Line(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new x.Line(g,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new x.Line(g,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},R={XYZE:[[new x.Mesh(b(.5,1),f),null,[0,Math.PI/2,0]]],X:[[new x.Mesh(b(.5,.5),n)]],Y:[[new x.Mesh(b(.5,.5),r),null,[0,0,-Math.PI/2]]],Z:[[new x.Mesh(b(.5,.5),o),null,[0,Math.PI/2,0]]],E:[[new x.Mesh(b(.75,1),d),null,[0,Math.PI/2,0]]]},P={AXIS:[[new x.Line(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},z={XYZE:[[new x.Mesh(new x.SphereGeometry(.25,10,8),s)]],X:[[new x.Mesh(new x.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new x.Mesh(new x.TorusGeometry(.5,.1,4,24),s),[0,0,0],[Math.PI/2,0,0]]],Z:[[new x.Mesh(new x.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,0,-Math.PI/2]]],E:[[new x.Mesh(new x.TorusGeometry(.75,.1,2,24),s)]]},$={X:[[new x.Mesh(y,n),[.5,0,0],[0,0,-Math.PI/2]],[new x.Mesh(_,n),[0,0,0],[0,0,-Math.PI/2]],[new x.Mesh(y,n),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new x.Mesh(y,r),[0,.5,0]],[new x.Mesh(_,r)],[new x.Mesh(y,r),[0,-.5,0],[0,0,Math.PI]]],Z:[[new x.Mesh(y,o),[0,0,.5],[Math.PI/2,0,0]],[new x.Mesh(_,o),[0,0,0],[Math.PI/2,0,0]],[new x.Mesh(y,o),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new x.Mesh(new x.BoxGeometry(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new x.Mesh(new x.BoxGeometry(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new x.Mesh(new x.BoxGeometry(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new x.Mesh(new x.BoxGeometry(.1,.1,.1),u.clone())]]},q={X:[[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new x.Mesh(new x.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new x.Mesh(new x.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new x.Mesh(new x.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new x.Mesh(new x.BoxGeometry(.2,.2,.2),s),[0,0,0]]]},j={X:[[new x.Line(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new x.Line(g,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new x.Line(g,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function X(Z){const ve=new x.Object3D;for(const ue in Z)for(let ge=Z[ue].length;ge--;){const ie=Z[ue][ge][0].clone(),we=Z[ue][ge][1],ke=Z[ue][ge][2],rt=Z[ue][ge][3],_e=Z[ue][ge][4];ie.name=ue,ie.tag=_e,we&&ie.position.set(we[0],we[1],we[2]),ke&&ie.rotation.set(ke[0],ke[1],ke[2]),rt&&ie.scale.set(rt[0],rt[1],rt[2]),ie.updateMatrix();const at=ie.geometry.clone();at.applyMatrix4(ie.matrix),ie.geometry=at,ie.renderOrder=1/0,ie.position.set(0,0,0),ie.rotation.set(0,0,0),ie.scale.set(1,1,1),ve.add(ie)}return ve}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=X(S)),this.add(this.gizmo.rotate=X(R)),this.add(this.gizmo.scale=X($)),this.add(this.picker.translate=X(M)),this.add(this.picker.rotate=X(z)),this.add(this.picker.scale=X(q)),this.add(this.helper.translate=X(w)),this.add(this.helper.rotate=X(P)),this.add(this.helper.scale=X(j)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const s=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:Io;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(let n=0;n<i.length;n++){const r=i[n];r.visible=!0,r.rotation.set(0,0,0),r.position.copy(this.worldPosition);let o;if(this.camera.isOrthographicCamera?o=(this.camera.top-this.camera.bottom)/this.camera.zoom:o=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),r.scale.set(1,1,1).multiplyScalar(o*this.size/4),r.tag==="helper"){r.visible=!1,r.name==="AXIS"?(r.visible=!!this.axis,this.axis==="X"&&(Ve.setFromEuler(To.set(0,0,0)),r.quaternion.copy(s).multiply(Ve),Math.abs(Fe.copy(sa).applyQuaternion(s).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Y"&&(Ve.setFromEuler(To.set(0,0,Math.PI/2)),r.quaternion.copy(s).multiply(Ve),Math.abs(Fe.copy(sn).applyQuaternion(s).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Z"&&(Ve.setFromEuler(To.set(0,Math.PI/2,0)),r.quaternion.copy(s).multiply(Ve),Math.abs(Fe.copy(ia).applyQuaternion(s).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="XYZE"&&(Ve.setFromEuler(To.set(0,Math.PI/2,0)),Fe.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix(Yf.lookAt(qf,Fe,sn)),r.quaternion.multiply(Ve),r.visible=this.dragging),this.axis==="E"&&(r.visible=!1)):r.name==="START"?(r.position.copy(this.worldPositionStart),r.visible=this.dragging):r.name==="END"?(r.position.copy(this.worldPosition),r.visible=this.dragging):r.name==="DELTA"?(r.position.copy(this.worldPositionStart),r.quaternion.copy(this.worldQuaternionStart),yt.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),yt.applyQuaternion(this.worldQuaternionStart.clone().invert()),r.scale.copy(yt),r.visible=this.dragging):(r.quaternion.copy(s),this.dragging?r.position.copy(this.worldPositionStart):r.position.copy(this.worldPosition),this.axis&&(r.visible=this.axis.search(r.name)!==-1));continue}r.quaternion.copy(s),this.mode==="translate"||this.mode==="scale"?(r.name==="X"&&Math.abs(Fe.copy(sa).applyQuaternion(s).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Y"&&Math.abs(Fe.copy(sn).applyQuaternion(s).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Z"&&Math.abs(Fe.copy(ia).applyQuaternion(s).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XY"&&Math.abs(Fe.copy(ia).applyQuaternion(s).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="YZ"&&Math.abs(Fe.copy(sa).applyQuaternion(s).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XZ"&&Math.abs(Fe.copy(sn).applyQuaternion(s).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1)):this.mode==="rotate"&&(So.copy(s),Fe.copy(this.eye).applyQuaternion(Ve.copy(s).invert()),r.name.search("E")!==-1&&r.quaternion.setFromRotationMatrix(Yf.lookAt(this.eye,qf,sn)),r.name==="X"&&(Ve.setFromAxisAngle(sa,Math.atan2(-Fe.y,Fe.z)),Ve.multiplyQuaternions(So,Ve),r.quaternion.copy(Ve)),r.name==="Y"&&(Ve.setFromAxisAngle(sn,Math.atan2(Fe.x,Fe.z)),Ve.multiplyQuaternions(So,Ve),r.quaternion.copy(Ve)),r.name==="Z"&&(Ve.setFromAxisAngle(ia,Math.atan2(Fe.y,Fe.x)),Ve.multiplyQuaternions(So,Ve),r.quaternion.copy(Ve))),r.visible=r.visible&&(r.name.indexOf("X")===-1||this.showX),r.visible=r.visible&&(r.name.indexOf("Y")===-1||this.showY),r.visible=r.visible&&(r.name.indexOf("Z")===-1||this.showZ),r.visible=r.visible&&(r.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),r.material._color=r.material._color||r.material.color.clone(),r.material._opacity=r.material._opacity||r.material.opacity,r.material.color.copy(r.material._color),r.material.opacity=r.material._opacity,this.enabled&&this.axis&&(r.name===this.axis||this.axis.split("").some(function(l){return r.name===l}))&&(r.material.color.setHex(16776960),r.material.opacity=1)}super.updateMatrixWorld(e)}}class yN extends x.Mesh{constructor(){super(new x.PlaneGeometry(1e5,1e5,2,2),new x.MeshBasicMaterial({visible:!1,wireframe:!0,side:x.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),vo.copy(sa).applyQuaternion(t==="local"?this.worldQuaternion:Io),qr.copy(sn).applyQuaternion(t==="local"?this.worldQuaternion:Io),Yr.copy(ia).applyQuaternion(t==="local"?this.worldQuaternion:Io),Fe.copy(qr),this.mode){case"translate":case"scale":switch(this.axis){case"X":Fe.copy(this.eye).cross(vo),Rs.copy(vo).cross(Fe);break;case"Y":Fe.copy(this.eye).cross(qr),Rs.copy(qr).cross(Fe);break;case"Z":Fe.copy(this.eye).cross(Yr),Rs.copy(Yr).cross(Fe);break;case"XY":Rs.copy(Yr);break;case"YZ":Rs.copy(vo);break;case"XZ":Fe.copy(Yr),Rs.copy(qr);break;case"XYZ":case"E":Rs.set(0,0,0);break}break;case"rotate":default:Rs.set(0,0,0)}Rs.length()===0?this.quaternion.copy(this.cameraQuaternion):(Xf.lookAt(yt.set(0,0,0),Rs,Fe),this.quaternion.setFromRotationMatrix(Xf)),super.updateMatrixWorld(e)}}class xt extends x.EventDispatcher{static DRAG_START="Transform::dragStart";static DRAG_END="Transform::dragEnd";static _instance;app;three;activeCamera;controls=new Map;visibility=new Map;setApp(e,t){this.app=e,this.three=t,this.app.addEventListener(Q.SET_SCENE,this.setScene)}clear(){for(const e of this.controls.values()){e.detach(),e.disconnect();const t=e.getHelper();ii(t)}this.controls=new Map,this.visibility=new Map}add(e){let t=this.controls.get(e);if(t===void 0){const s=document.querySelector(".clickable");t=new cN(this.activeCamera,s),t.getHelper().name=e,t.setSize(.5),t.setSpace("local"),this.controls.set(e,t),this.visibility.set(e,!0),t.addEventListener("mouseDown",()=>{this.dispatchEvent({type:xt.DRAG_START})}),t.addEventListener("mouseUp",()=>{this.dispatchEvent({type:xt.DRAG_END})}),t.addEventListener("dragging-changed",i=>{et.instance?.toggleOrbitControls(i.value)})}return t}get(e){return this.controls.get(e)}remove(e){const t=this.get(e);return t===void 0?!1:(t.detach(),t.disconnect(),ii(t.getHelper()),this.controls.delete(e),!0)}enabled(e){this.controls.forEach(t=>{t.enabled=e})}updateCamera(e,t){this.activeCamera=e,this.controls.forEach(s=>{s.camera!==e&&(s.camera=e,e.getWorldPosition(s.cameraPosition),e.getWorldQuaternion(s.cameraQuaternion)),s.domElement!==t&&(s.disconnect(),s.domElement=t,s.connect(t))})}show(){this.controls.forEach(e=>{const t=e.getHelper(),s=this.visibility.get(t.name);s!==void 0&&(t.visible=s)})}hide(){this.controls.forEach(e=>{const t=e.getHelper();this.visibility.set(t.name,t.visible),t.visible=!1})}setScene=()=>{this.clear()};static get instance(){return xt._instance||(xt._instance=new xt),xt._instance}}const xN=new x.BoxGeometry,rh=new x.Vector2;class Lo extends x.Object3D{curve=new x.CatmullRomCurve3;line;draggable;curvePos;tension=.5;closed=!1;subdivide=50;curveType;offset=1;lineMaterial;_camera;_curvePercentage=0;_draggableScale=10;_transform;raycaster;draggedMat=new x.MeshBasicMaterial;parentGroup;group;constructor(e,t){const s=new x.Color(Ni(.5,1,Math.random()),Ni(.5,1,Math.random()),Ni(.5,1,Math.random()));super(),this.name=e,this.lineMaterial=new x.LineBasicMaterial({color:s}),this.line=new x.Line(new x.BufferGeometry,this.lineMaterial),this.line.name="line",this.line.visible=!1,this.add(this.line),this._camera=t,this.curveType="catmullrom",this.draggedMat.color=s,this.draggable=new x.Object3D,this.draggable.name="draggablePoints",this.add(this.draggable),this.curvePos=new x.Mesh(new x.SphereGeometry(1.5),new x.MeshBasicMaterial({color:s})),this.curvePos.name="curvePos",this.curvePos.scale.setScalar(this._draggableScale),this.curvePos.visible=!1,this.add(this.curvePos),this.raycaster=new x.Raycaster,this.raycaster.params.Line.threshold=3,this.enable()}enable(){document.addEventListener("pointerdown",this.onMouseClick)}disable(){document.removeEventListener("pointerdown",this.onMouseClick)}dispose=()=>{this._transform&&(this._transform.removeEventListener("objectChange",this.updateSpline),xt.instance.remove(this.name)),this.disable(),this.parentGroup.removeGroup(this.name)};hideTransform=()=>{this._transform?.detach()};exportSpline=()=>{const e=[];this.draggable.children.forEach(t=>{e.push([ss(t.position.x,3),ss(t.position.y,3),ss(t.position.z,3)])}),Kf({name:this.name,points:e,tension:this.tension,closed:this.closed,subdivide:this.subdivide,type:this.curveType}),console.log("Spline copied!")};showPoints=(e=!0)=>{this.draggable.visible=e};addPoints=(e=[])=>{if(e.length>0){const t=e.length-1;for(let s=0;s<t;s++)this.addPoint(e[s],!1);this.addPoint(e[t])}};addPoint=(e,t=!0)=>{const s=this.draggable.children.length,i=new x.Mesh(xN,this.draggedMat);i.name=`point_${s}`,i.position.copy(e),i.scale.setScalar(this._draggableScale),this.draggable.add(i),this._transform?.attach(i);const n=this.points.length>1;return n&&t&&this.updateSpline(),this.line.visible=n,this.updateCurrentPoint(),i};addNextPt=()=>{const e=this.draggable.children.length,t=e>1?this.draggable.children[e-1].position.clone():new x.Vector3,s=this.addPoint(t);this.group.current?.setField("Current Point",s.position)};removePoint=e=>{if(this._transform?.object===e){this._transform?.detach();const t=this.draggable.children[this.draggable.children.length-1];this._transform?.attach(t),this.group.current?.setField("Current Point",t.position)}ii(e),this.updateSpline()};removePointAt=e=>{const t=this.draggable.children[e];this.removePoint(t)};removeSelectedPt=()=>{this._transform?.object!==void 0&&this.removePoint(this._transform?.object)};updateLastPoint(e){const t=this.draggable.children.length;t>0&&(this.draggable.children[t-1].position.copy(e),this.updateSpline())}updateSpline=()=>{this.points.length<2||(this.curve=new x.CatmullRomCurve3(this.points,this.closed,this.curveType,this.tension),this.line.geometry.dispose(),this.line.geometry=new x.BufferGeometry().setFromPoints(this.curve.getPoints(this.subdivide)),this.curvePos.position.copy(this.getPointAt(this._curvePercentage)))};onMouseClick=e=>{if(!et.instance||!et.instance.currentWindow||this._transform&&!this._transform.getHelper().visible)return;const s=et.instance.currentWindow.current.getBoundingClientRect();rh.x=(e.clientX-s.x)/s.width*2-1,rh.y=-((e.clientY-s.y)/s.height)*2+1,this.raycaster.setFromCamera(rh,this.camera);const i=this.raycaster.intersectObjects(this.draggable.children,!1);if(i.length>0){const n=i[0].object;n!==this._transform?.object&&(this._transform?.attach(n),this.group.current?.setField("Current Point",n.position))}};getPointAt(e){return this.curve.points.length>1?this.curve.getPointAt(e):this.curve.points.length===1?this.curve.points[0]:new x.Vector3}getTangentAt(e){return this.curve.getTangentAt(e)}get points(){const e=[];return this.draggable.children.forEach(t=>{e.push(t.position)}),e}get total(){return this.draggable.children.length}get draggableScale(){return this._draggableScale}set draggableScale(e){this._draggableScale=e,this.draggable.children.forEach(t=>t.scale.setScalar(e)),this.curvePos.scale.setScalar(e)}get camera(){return this._camera}set camera(e){this._camera=e,this._transform!==void 0&&(this._transform.camera=e)}get curvePercentage(){return this._curvePercentage}set curvePercentage(e){this._curvePercentage=e,this.curvePos.position.copy(this.getPointAt(e))}updateCurrentPoint(){if(this._transform?.object&&this.group){const e=this._transform?.object;e.name.search("point")>-1&&this.group.current?.setField("Current Point",e.position)}}onUpdateTransform=()=>{this.updateCurrentPoint(),this.updateSpline()};initDebug(e){const t=this.draggable.children;this.parentGroup=e,this._transform=xt.instance.add(this.name),this._transform.camera=this._camera,this._transform.addEventListener("objectChange",this.onUpdateTransform),t.length>0&&this._transform.attach(t[t.length-1]),et.instance?.helpersContainer.add(this._transform.getHelper());const s=t.length>0?t[t.length-1].position:{x:0,y:0,z:0};this.group=e.addGroup({title:this.name,expanded:!0,items:[{prop:"Closed",type:"boolean",value:this.closed},{prop:"Visible",type:"boolean",value:this.visible},{prop:"Show Position",type:"boolean",value:this.curvePos.visible},{prop:"Show Points",type:"boolean",value:this.draggable.visible},{prop:"Color",type:"color",value:`#${this.draggedMat.color.getHexString()}`},{prop:"Curve",type:"option",options:[{title:"Catmullrom",value:"catmullrom"},{title:"Centripetal",value:"centripetal"},{title:"Chordal",value:"chordal"}]},{prop:"Draggable Scale",type:"range",min:.01,max:100,step:.01,value:this._draggableScale},{prop:"Subdivide",type:"range",min:1,max:1e3,step:1,value:this.subdivide},{prop:"Tension",type:"range",min:0,max:1,step:.01,value:this.tension},{prop:"New Pt Offset",type:"range",min:0,max:10,value:this.offset},{prop:"Curve At",type:"range",min:0,max:1,step:.01,value:0},{prop:"Toggle Transform",type:"button"},{prop:"Add Point",type:"button"},{prop:"Remove Point",type:"button"},{prop:"Export",type:"button"},{prop:"Delete",type:"button"},{prop:"Current Point",type:"grid3",value:s}],onUpdate:(i,n)=>{switch(i){case"Closed":this.closed=n,this.updateSpline();break;case"Visible":this.visible=n;break;case"Color":this.lineMaterial.color.setStyle(n),this.draggedMat.color.setStyle(n);break;case"Curve":this.curveType=n,this.updateSpline();break;case"Draggable Scale":this.draggableScale=n;break;case"Subdivide":this.subdivide=n,this.updateSpline();break;case"Tension":this.tension=n,this.updateSpline();break;case"New Pt Offset":this.offset=n;break;case"Curve At":this.curvePos.position.copy(this.getPointAt(n));break;case"Show Position":this.curvePos.visible=n;break;case"Show Points":this.draggable.visible=n;break;case"Toggle Transform":this._transform&&(this._transform.getHelper().visible=!this._transform.getHelper().visible);break;case"Add Point":this.addNextPt();break;case"Remove Point":this.removeSelectedPt();break;case"Export":this.exportSpline();break;case"Delete":this.parent.currentSpline=null,ii(this);break;case"Current Point":if(this.group.current&&this._transform?.object){const r=this._transform?.object;r.name.search("point")>-1&&(r.position.copy(n),this.updateSpline())}break}}}),this.draggable.children.forEach(i=>{this.debugPoint(i)})}debugPoint=e=>{e.name,e.visible=this.draggable.visible}}let wo=0;class zy extends x.Object3D{defaultScale=10;currentSpline=null;_camera;group=null;app;splineDataText="";constructor(e,t){super(),this.name="Spline Editor",this._camera=e,this.app=t,this.app.addEventListener(Q.ADD_SPLINE,this.onAddSpline)}initDebug(){this.group=Re.addEditorGroup({title:this.name,items:[{type:"field",prop:"Spline Data",value:"",disabled:!1},{type:"button",prop:"Import Spline"},{type:"button",prop:"New Spline"},{type:"boolean",prop:"Show Points",value:!0},{type:"boolean",prop:"Draw Mode",value:!1},{type:"boolean",prop:"Visible",value:this.visible},{type:"range",prop:"Default Scale",min:0,max:50,step:.01,value:this.defaultScale}],onUpdate:(e,t)=>{switch(e){case"New Spline":this.createSpline();break;case"Spline Data":this.splineDataText=t;break;case"Import Spline":this.createSplineFromJSON(JSON.parse(this.splineDataText));break;case"Show Points":this.showPoints(t);break;case"Visible":this.visible=t;break;case"Default Scale":this.defaultScale=t;break;case"Draw Mode":t?this.enableClickToDraw():this.disableClickToDraw();break}}})}dispose(){this.app.removeEventListener(Q.ADD_SPLINE,this.onAddSpline),Re.removeEditorGroup(this.name)}addSpline(e){e.draggableScale=this.defaultScale,e.hideTransform(),this.group?.current!==null&&e.initDebug(this.group.current),this.add(e),this.currentSpline=e}createSpline=(e=[])=>{const t=`Spline ${wo+1}`,s=new Lo(t,this._camera);return s.addPoints(e),this.addSpline(s),wo++,s};createSplineFromArray=e=>{const t=[];return e.forEach(s=>{t.push(new x.Vector3(s[0],s[1],s[2]))}),this.createSpline(t)};createSplineFromCatmullRom=e=>this.createSpline(e.points);createSplineFromJSON=e=>{const t=[];e.points.forEach(i=>{t.push(new x.Vector3(i[0],i[1],i[2]))});const s=new Lo(e.name,this._camera);return s.closed=e.closed,s.subdivide=e.subdivide,s.tension=e.tension,s.type=e.type,s.addPoints(t),s.updateSpline(),this.addSpline(s),s};showPoints=(e=!0)=>{this.children.forEach(t=>{t.showPoints(e)})};onAddSpline=e=>{const t=JSON.parse(e.value),s=`Spline ${wo+1}`,i=[];t.points.forEach(r=>{i.push(new x.Vector3(r[0],r[1],r[2]))});const n=new Lo(s,this.camera);n.addPoints(i),this.addSpline(n),wo++};isMouseDown=!1;enableClickToDraw(){document.querySelectorAll(".clickable").forEach(e=>{e.addEventListener("mousedown",this.onClickCanvas),e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("mouseup",this.onMouseUp)})}disableClickToDraw(){document.querySelectorAll(".clickable").forEach(e=>{e.removeEventListener("mousedown",this.onClickCanvas),e.removeEventListener("mousemove",this.onMouseMove),e.removeEventListener("mouseup",this.onMouseUp)})}onClickCanvas=e=>{if(e.button!==0)return;if(this._camera.type!=="OrthographicCamera"){console.warn("Spline Editor - 3D Camera not supported in Draw Mode");return}const s=e.target.getBoundingClientRect(),i=(e.clientX-s.left)/s.width*2-1,n=-((e.clientY-s.top)/s.height)*2+1;if(et.instance){const o=new x.Raycaster;o.setFromCamera(new x.Vector2(i,n),this._camera);const l=o.intersectObjects(et.instance.helpersContainer.children,!0);for(let c=0;c<l.length;c++){const h=l[c];if(!(h.object.isLine||h.object.isTransformControlsPlane)&&h.object.isObject3D)return}}this.currentSpline===null&&(this.currentSpline=this.createSpline());const r=this.mouseToSplinePos(i,n,s.width,s.height);this.currentSpline?.addPoint(r),this.isMouseDown=!0};onMouseMove=e=>{if(!this.isMouseDown)return;const s=e.target.getBoundingClientRect(),i=(e.clientX-s.left)/s.width*2-1,n=-((e.clientY-s.top)/s.height)*2+1,r=this.mouseToSplinePos(i,n,s.width,s.height);this.currentSpline?.updateLastPoint(r)};onMouseUp=()=>{this.isMouseDown=!1};mouseToSplinePos(e,t,s,i){const n=new x.Vector3,r=Math.PI/2,o=this._camera,l=o.zoom,c=o.rotation.x===-6123233995736766e-32&&o.rotation.y===0&&o.rotation.z===0,h=o.rotation.x===-Math.PI&&o.rotation.y===12246467991473532e-32&&o.rotation.z===Math.PI,u=o.rotation.x===-6162975822039155e-48&&o.rotation.y===-r&&o.rotation.z===0,d=o.rotation.x===-6162975822039155e-48&&o.rotation.y===r&&o.rotation.z===0,p=o.rotation.x===-1.5707953264174506&&o.rotation.y===0&&o.rotation.z===0,f=o.rotation.x===1.5707953264174506&&o.rotation.y===0&&o.rotation.z===0;let m=e,y=t;h||d?m*=-1:p&&(y*=-1);const g=s/2/l,_=i/2/l;if(this.currentSpline===null&&(this.currentSpline=this.createSpline()),c||h){const b=m*g+o.position.x,T=y*_+o.position.y;n.set(b,T,0)}else if(u||d){const b=m*g+o.position.z,T=y*_+o.position.y;n.set(0,T,b)}else if(p||f){const b=m*g+o.position.x,T=y*_+o.position.z;n.set(b,0,T)}return n}get camera(){return this._camera}set camera(e){this._camera=e,this.children.forEach(t=>{const s=t;s.camera=e})}}const Zf=["Single","Side by Side","Stacked","Quad"],_N="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAC60lEQVRYhe2YT4hNcRTHP48xpmYaNAvRyEQxEhnKQljYsRm9/EmSyJiMFAsMZWNhJYoNIUVJ2VGiyb9ZzIpMpkQSahbGv9GMYWrM+1rc2zjvzvvdd+99rzdvMd+6de75nd+5387vnN/v/G5KEuWMKRNNIB8mCRaKiiL5qQb2ApuBuUAV0Ad0AJeB3sSeJRX6LJbULTf6JTUn9Z+KWMUpPyp/Avoa4CNQZ3Sj/lNpdL/xottR7AjOkHRUUpekN5I6JbVLavDH75lIfZN0UFKTpCWS0pJem/HeJBEMG6yV1ONYtgFJbZJ+GF1jDh+zJb03NuliEuwMkMo4yErS2RA/LcbuYVyCrm1mA7Dal/8Cu4FG4JD/HsTTkCy6a+SVMTPQuc1sBKb78nHghi+/A+YBxwL2lbhRY+ThuARdEVxu5JdGFvACr0otdoZ8Y4+Rn0Sn5sFFsMvI6YB9MzA1YJ8mN8k1wAHzfj4uQVdyrpI0aJL7oqTtkq4FiqPLyCOSbktqlbRL0jlJQ2b8QdwCUZ4qvhRStZL0XFK1pMd57CRvq5mfhKBriRfiFUMY6oD7eOdwPlQAN4G10dfWg+uouwXsiOssAj4AC+JMcEWwvnAuOTEr7gTXPmg34zagOwkbIIOXAo9CbDYBrcBXYN+4UUdy2sRflyS5zVNlfPX7ugpJW5V9nI7mmh+lYU0lCZ2B3TOnAVuAk0BTwC5nuhWro46KauBOQJch5OpRaoIW34GreGf+YZdRqS9NAj4Bp4ClQDvwOWxCqSM4ADQEdKE5XvbXzlITrAVe4TW+M6NMKDXBFLAMuAD0ACfIc7pMZBXXA2cY3/xmodQRHAL2A2+NLtj8ZiEKwUL/z2WMPAJcAVYALWSf8dZuDFGWeBHwKxm3sWYhiGG8Tfo6sA2vSfiSy4GrH3wGrDcfKSSKKf6v1E9yF0XK9Q1XBPuMXMw8HXTonQFwETwNzMFr64v1jzgFHIk9ybHEZYPJo65QlD3Bf2/Q/eaHPiSWAAAAAElFTkSuQmCC",bN="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAETklEQVRYhe2YXYhVVRTHf3d0/JhyUrMpFbImM+whSa3Mynww+4AeIgiKoozooQ+KyMyXIAujF6OXqHyI6iEKKYgIP/owsjSFqCkprdDUTEcjbWZ0HHV+Pex1ucfb9Z57Z9REXHA4Z++99l7/s/ZZ/7X2KaiczNLwfwPIk9MA+yunNMAG4DHgV+BvoB3YFff2TPstYEyfrajVroI6Sr1GvahsbJC63HzZq04pmztSvU5tVRuqYRiYg78JeBR4HPg5ntdmxovz9wJfA3uAxuibDLQCA+IqynnAQuBuYCnwMLC1rx48U12U8cZqdWqMDcx4cI16qTpYbVKHqa+ovWUeHKsujn7VL9ULq2HI+wY7gVeBJdGeFu3J4ZUiy/cAXeHRRuAQsC/GC0B3eG4BcH/0tUV7czUAeVsMsBF4Kha9HZgCvAncAuwPnXHA0wFuGLANuDrGuoGDwFxgTqzzQ7RX5FrP2eLsdb76vnogtme6+nE8H1YPlQXHwbi3q9eqn0e7Tb25VrsF68vFY0lb1AGcDTwItGQ8tQM4AIwGmqP/EPAu8A0wElgJfFGzxTo8mKWXu9Rd4ZF96jvqjSbauEC9Sn1O3R463epLaku99voCsFXdkAH3kNpcQW+IiT/bQne3eufxBtioPqP2mKhioXpWzpxb1T8C5Ifh4ZptVoriRmAIKdrI3Lujf3bobAPeJpF0NVkKrAFuI9HTOBIxnxFrF4OgQKKr/dnJlQA+AcwABgOHA4zAamA5cE7orQL+zAEHiWI+A2bFC7aSguheYCgpqAphZz3wSB7AecCICv2TgH8oFRib4gVqka0k0h8CXAxMBW6ooDejFoCvA9OBQUAvKWM0kDz4XUZvNKXtyZMWUl7vBbaQXq457PeEziDgx/KJlQAuIPFdMcEXv5OdYWBP9M8k8VpnDQCvB4aTSrCNJB5cSdrW3tBpIJVnR0qdUTxAfdGUOVTnmwqEanNmqltC/9OgqePKg5eom8PgdvW+oJ9Kupera0O3U50TL3lcAaI+oHaF4R3qa6Z822wq0Saq89T1lmSxOrxeW/Xm4uGkiqQDmECKuKHxHW0HdpMiewSpvGqKeR8Ay0iBsYIjg6261PE2o9Q3Yqv+MqWxO9R1Hl12qs+q49Vlppy82pSr+5xJKsko4AXgHlJ0t5NIeg3wLXAlqZhtIUV8J6nmWwX8QiLjdhL5TwMWkY4R6/rrwYKlMr1Y321QZ/vfwBijPqm+rF4Wc7PjE9QllurGVeoV5gRNHsAm9fnMom3qrKPoTjKdMXaYyrFygEWQ72XWW24qhPu8xcUc2UU6O8wFPjmK7jhgPHAuMJGUGQ6U6WwE5sfzTXGvei7KA9hFOiR9D/wOfFVFt4dS2tpfRe83Ur7/CPiJakfOGgBCypubatArl2r8VfOax/LfzABKtePAzHO/5FgC7KBEzB2kOrDfUm8mOeFySv9+OyFyGmB/5aQH+C9BVKmVCNuMZgAAAABJRU5ErkJggg==",TN="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAQ0lEQVQ4jWP8////fwYqAxYozUhFM/8zkaKYWIWkGEq0b0ZdSjQY5i79TyWagRGaTUdzFEEw6lLqGzqwLoVVJ1StpwA9sBwbUqAh5gAAAABJRU5ErkJggg==";class et extends W.Component{static instance=null;app;scene;renderer;currentScene;scenes=new Map;cameras=new Map;controls=new Map;currentCamera;currentWindow;helpersContainer=new x.Group;cameraHelpers=new Map;lightHelpers=new Map;grid=new rN;interactionHelper=new x.AxesHelper(25);currentTransform;splineEditor;depthMaterial=new x.MeshDepthMaterial;normalsMaterial=new x.MeshNormalMaterial;uvMaterial=new lN;wireframeMaterial=new x.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0});playing=!1;rafID=-1;cameraControlsRafID=-1;width=0;height=0;tlCam=null;trCam=null;blCam=null;brCam=null;tlRender="Renderer";trRender="Renderer";blRender="Renderer";brRender="Renderer";cameraVisibility=!0;lightVisibility=!0;gridVisibility=!0;selectedItem=void 0;debugCamera;raycaster=new x.Raycaster;pointer=new x.Vector2;cameraControls=void 0;canvasRef;containerRef;tlWindow;trWindow;blWindow;brWindow;constructor(e){super(e),this.app=e.app,this.app.addEventListener(Q.ADD_RENDERER,this.setupRenderer),this.scene=new x.Scene,this.scene.name=this.scene.uuid="Debug Scene",this.canvasRef=W.createRef(),this.containerRef=W.createRef(),this.tlWindow=W.createRef(),this.trWindow=W.createRef(),this.blWindow=W.createRef(),this.brWindow=W.createRef();const t=e.three.app.appID,s=localStorage,i=s.getItem(`${t}_mode`);this.state={mode:i!==null?i:"Single",modeOpen:!1,renderModeOpen:!1,interactionMode:"Orbit",interactionModeOpen:!1,lastUpdate:Date.now()},s.setItem(`${t}_mode`,this.state.mode),s.setItem(`${t}_tlCam`,s.getItem(`${t}_tlCam`)!==null?s.getItem(`${t}_tlCam`):"Debug"),s.setItem(`${t}_trCam`,s.getItem(`${t}_trCam`)!==null?s.getItem(`${t}_trCam`):"Orthographic"),s.setItem(`${t}_blCam`,s.getItem(`${t}_blCam`)!==null?s.getItem(`${t}_blCam`):"Front"),s.setItem(`${t}_brCam`,s.getItem(`${t}_brCam`)!==null?s.getItem(`${t}_brCam`):"Top"),s.setItem(`${t}_tlRender`,s.getItem(`${t}_tlRender`)!==null?s.getItem(`${t}_tlRender`):"Renderer"),s.setItem(`${t}_trRender`,s.getItem(`${t}_trRender`)!==null?s.getItem(`${t}_trRender`):"Renderer"),s.setItem(`${t}_blRender`,s.getItem(`${t}_blRender`)!==null?s.getItem(`${t}_blRender`):"Renderer"),s.setItem(`${t}_brRender`,s.getItem(`${t}_brRender`)!==null?s.getItem(`${t}_brRender`):"Renderer");const n={Vector2:x.Vector2,Vector3:x.Vector3,Vector4:x.Vector4,Quaternion:x.Quaternion,Matrix4:x.Matrix4,Spherical:x.Spherical,Box3:x.Box3,Sphere:x.Sphere,Raycaster:x.Raycaster};Ds.install({THREE:n}),this.setupScene(),this.setupTools();const r=localStorage.getItem(this.expandedCameraVisibility);r!==null&&(this.cameraVisibility=r==="open"),this.saveExpandedCameraVisibility();const o=localStorage.getItem(this.expandedLightVisibility);o!==null&&(this.lightVisibility=o==="open"),this.saveExpandedLightVisibility();const l=localStorage.getItem(this.expandedGridVisibility);l!==null&&(this.gridVisibility=l==="open"),this.grid.visible=this.gridVisibility,this.saveExpandedGridVisibility(),et.instance=this}componentDidMount(){this.enable(),this.assignControls(),this.resize(),this.play(),xt.instance.setApp(this.props.app,this.props.three),xt.instance.activeCamera=this.debugCamera}componentDidUpdate(e,t,s){t.mode!==this.state.mode&&(this.assignControls(),this.resize())}componentWillUnmount(){this.disable(),Re.removeEditorGroup("View Settings")}render(){const e=[];return this.cameras.forEach((t,s)=>{e.push(s)}),C.jsxs("div",{className:"multiview",children:[C.jsx("canvas",{ref:this.canvasRef}),C.jsxs("div",{className:`cameras ${this.state.mode==="Single"||this.state.mode==="Stacked"?"single":""}`,ref:this.containerRef,children:[this.state.mode==="Single"&&C.jsx(C.Fragment,{children:C.jsx(Zi,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}})}),(this.state.mode==="Side by Side"||this.state.mode==="Stacked")&&C.jsxs(C.Fragment,{children:[C.jsx(Zi,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),C.jsx(Zi,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.trCam),this.trCam=s,localStorage.setItem(`${this.appID}_trCam`,s.name),this.createControls(s,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}})]}),this.state.mode==="Quad"&&C.jsxs(C.Fragment,{children:[C.jsx(Zi,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),C.jsx(Zi,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.trCam),this.trCam=s,localStorage.setItem(`${this.appID}_trCam`,s.name),this.createControls(s,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}}),C.jsx(Zi,{name:"bl",camera:this.blCam,options:e,ref:this.blWindow,onSelectCamera:t=>{this.controls.get(this.blCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.blCam),this.blCam=s,localStorage.setItem(`${this.appID}_blCam`,s.name),this.createControls(s,this.blWindow.current))},onSelectRenderMode:t=>{this.blRender=t,localStorage.setItem(`${this.appID}_blRender`,t)}}),C.jsx(Zi,{name:"br",camera:this.brCam,options:e,ref:this.brWindow,onSelectCamera:t=>{this.controls.get(this.brCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.brCam),this.brCam=s,localStorage.setItem(`${this.appID}_brCam`,s.name),this.createControls(s,this.brWindow.current))},onSelectRenderMode:t=>{this.brRender=t,localStorage.setItem(`${this.appID}_brRender`,t)}})]})]}),C.jsxs("div",{className:"settings",children:[C.jsx(al,{title:"View",index:Zf.indexOf(this.state.mode),options:Zf,onSelect:t=>{t!==this.state.mode&&(this.killControls(),this.setState({mode:t}),localStorage.setItem(`${this.appID}_mode`,t))},open:this.state.modeOpen,onToggle:t=>{this.setState({modeOpen:t,renderModeOpen:!1,interactionModeOpen:!1})}}),C.jsx(al,{title:"Interact",index:this.state.interactionMode==="Orbit"?0:1,options:["Orbit Mode","Selection Mode"],onSelect:t=>{this.interactionHelper.visible=t==="Selection Mode",this.setState({interactionMode:this.interactionHelper.visible?"Selection":"Orbit"})},open:this.state.interactionModeOpen,onToggle:t=>{this.setState({modeOpen:!1,renderModeOpen:!1,interactionModeOpen:t})}}),C.jsx(sh,{name:"cameraHelper",icon:_N,selected:this.cameraVisibility,height:24,top:2,onClick:t=>{if(this.cameraVisibility=t,this.saveExpandedCameraVisibility(),this.cameraHelpers.forEach(s=>{s.visible=t}),this.selectedItem!==void 0&&!t){const s=this.cameraHelpers.get(this.selectedItem.name);s!==void 0&&(s.visible=!0)}}}),C.jsx(sh,{name:"lightHelper",icon:bN,selected:this.lightVisibility,height:24,top:4,onClick:t=>{if(this.lightVisibility=t,this.saveExpandedLightVisibility(),this.lightHelpers.forEach(s=>{s.visible=t}),this.selectedItem!==void 0&&!t&&this.selectedItem.isLight===!0){const s=this.lightHelpers.get(this.selectedItem.name);s!==void 0&&(s.visible=!0)}}}),C.jsx(sh,{name:"gridHelper",icon:TN,selected:this.gridVisibility,height:21,width:21,onClick:t=>{this.gridVisibility=t,this.saveExpandedGridVisibility(),this.grid.visible=t}})]},this.state.lastUpdate)]})}setupRenderer=e=>{this.renderer&&this.renderer.dispose();const t=this.canvasRef.current;this.props.three.canvas=t;const s=e.value;s.type==="WebGLRenderer"?(this.renderer=new x.WebGLRenderer({canvas:t,stencil:!1}),this.grid.visible=!0):s.type==="WebGPURenderer"&&(this.renderer=new mo({canvas:t,stencil:!1}),this.grid.visible=!1),this.renderer&&(this.renderer.autoClear=!1,this.renderer.shadowMap.enabled=!0,this.renderer.setPixelRatio(devicePixelRatio),this.renderer.setClearColor(0),this.resize(),this.props.three.renderer=this.renderer)};setupScene(){this.scene.name="Debug Scene",this.scene.uuid="Debug Scene",this.helpersContainer.name="helpers",this.scene.add(this.helpersContainer),this.grid.position.y=-1,this.scene.add(this.grid),this.interactionHelper.name="interactionHelper",this.interactionHelper.visible=!1,this.helpersContainer.add(this.interactionHelper);const e=(n,r)=>{const o=new x.OrthographicCamera(-100,100,100,-100,0,3e3);return o.name=n,o.position.copy(r),o.lookAt(0,0,0),this.cameras.set(n,o),o},t=1e3;e("Top",new x.Vector3(0,t,0)),e("Bottom",new x.Vector3(0,-t,0)),e("Left",new x.Vector3(-t,0,0)),e("Right",new x.Vector3(t,0,0)),e("Front",new x.Vector3(0,0,t)),e("Back",new x.Vector3(0,0,-t)),e("Orthographic",new x.Vector3(t,t,t)),e("UI",new x.Vector3),this.debugCamera=new x.PerspectiveCamera(60,1,.01,3e3),this.debugCamera.name="Debug",this.debugCamera.position.set(300,300,300),this.debugCamera.lookAt(0,0,0),this.cameras.set("Debug",this.debugCamera),this.currentCamera=this.debugCamera;const s=localStorage,i=this.props.three.app.appID;this.tlCam=this.cameras.get(s.getItem(`${i}_tlCam`)),this.trCam=this.cameras.get(s.getItem(`${i}_trCam`)),this.blCam=this.cameras.get(s.getItem(`${i}_blCam`)),this.brCam=this.cameras.get(s.getItem(`${i}_brCam`)),this.tlCam===void 0&&(this.tlCam=this.cameras.get("Debug")),this.trCam===void 0&&(this.trCam=this.cameras.get("Orthographic")),this.blCam===void 0&&(this.blCam=this.cameras.get("Front")),this.brCam===void 0&&(this.brCam=this.cameras.get("Top"))}setupTools(){this.splineEditor=new zy(this.currentCamera,this.app),this.splineEditor.initDebug(),this.helpersContainer.add(this.splineEditor)}play(){this.playing=!0,this.onUpdate()}pause(){this.playing=!1,cancelAnimationFrame(this.rafID),this.rafID=-1}toggleOrbitControls(e){this.controls.forEach(t=>{t.enabled=!e})}update(){this.renderer&&(this.renderer instanceof x.WebGLRenderer?this.renderer?.clear():this.renderer instanceof mo&&this.renderer?.clearAsync()),this.controls.forEach(e=>e.update()),this.cameraHelpers.forEach(e=>e.update()),this.lightHelpers.forEach(e=>{e.update!==void 0&&e.update()}),this.props.onSceneUpdate!==void 0&&this.currentScene!==void 0&&this.props.onSceneUpdate(this.currentScene)}draw(){switch(this.renderer&&(this.renderer instanceof x.WebGLRenderer?this.renderer?.clear():this.renderer instanceof mo&&this.renderer?.clearAsync()),this.state.mode){case"Single":this.drawSingle();break;case"Side by Side":case"Stacked":this.drawDouble();break;case"Quad":this.drawQuad();break}}onUpdate=()=>{this.playing&&(this.update(),this.draw(),this.rafID=requestAnimationFrame(this.onUpdate))};enable(){const e=this.containerRef.current;e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("click",this.onClick),window.addEventListener("keydown",this.onKey),window.addEventListener("resize",this.resize),this.app.addEventListener(Q.ADD_SCENE,this.addScene),this.app.addEventListener(Q.SET_SCENE,this.sceneUpdate),this.app.addEventListener(Q.ADD_CAMERA,this.addCamera),this.app.addEventListener(Q.REMOVE_CAMERA,this.removeCamera),this.app.addEventListener(Q.SET_OBJECT,this.onSetSelectedItem)}disable(){const e=this.containerRef.current;e.removeEventListener("mousemove",this.onMouseMove),e.removeEventListener("click",this.onClick),window.removeEventListener("keydown",this.onKey),window.removeEventListener("resize",this.resize),this.app.removeEventListener(Q.ADD_SCENE,this.addScene),this.app.removeEventListener(Q.SET_SCENE,this.sceneUpdate),this.app.removeEventListener(Q.ADD_CAMERA,this.addCamera),this.app.removeEventListener(Q.REMOVE_CAMERA,this.removeCamera),this.app.removeEventListener(Q.SET_OBJECT,this.onSetSelectedItem)}resize=()=>{this.width=window.innerWidth-300,this.height=window.innerHeight,this.renderer?.setSize(this.width,this.height);const e=Math.floor(this.width/2),t=Math.floor(this.height/2);this.props.three.resize(this.width,this.height),this.props.onSceneResize!==void 0&&this.currentScene!==void 0&&this.props.onSceneResize(this.currentScene,this.width,this.height);let s=this.width,i=this.height;switch(this.state.mode){case"Side by Side":s=e,i=this.height;break;case"Stacked":s=this.width,i=t;break;case"Quad":s=e,i=t;break}const n=s/i;this.cameras.forEach(r=>{r instanceof x.OrthographicCamera?(r.left=s/-2,r.right=s/2,r.top=i/2,r.bottom=i/-2,r.name==="UI"&&(r.position.x=this.width/2,r.position.y=this.height/-2,r.position.z=100),r.updateProjectionMatrix()):r instanceof x.PerspectiveCamera&&(r.aspect=n,r.updateProjectionMatrix()),this.cameraHelpers.get(r.name)?.update()})};addScene=e=>{const t=this.props.scenes.get(e.value.name);if(t!==void 0){const s=new t;s.visible=!1,this.props.onSceneSet!==void 0&&this.props.onSceneSet(s),this.props.three.scene=s,this.scenes.set(e.value.name,s),this.scene.add(s)}};sceneUpdate=e=>{this.currentScene!==void 0&&(this.currentScene.visible=!1,this.clearLightHelpers());const t=this.scene.getObjectByName(e.value.name);t!==void 0&&(this.currentScene=t,this.currentScene.visible=!0,this.addLightHelpers(this.currentScene))};addCamera=e=>{const t=e.value,s=`${this.props.three.scene?.name}_${t.name}`,i=this.props.three.scene?.getObjectByProperty("uuid",t.uuid);if(i!==void 0){const n=i;this.cameras.set(s,n);const r=new x.CameraHelper(n);r.visible=this.cameraVisibility,this.cameraHelpers.set(s,r),this.helpersContainer.add(r),this.setState({lastUpdate:Date.now()})}};removeCamera=e=>{const t=this.cameraHelpers.get(e.value.name);t!==void 0&&(this.helpersContainer.remove(t),t.dispose()),this.cameras.delete(e.value.name),this.setState({lastUpdate:Date.now()})};onMouseMove=e=>{const t=new x.Vector2;this.renderer?.getSize(t);const s=Math.min(e.clientX,t.x),i=Math.min(e.clientY,t.y);this.pointer.x=Ki(s,0,t.x,-1,1),this.pointer.y=Ki(i,0,t.y,1,-1);const n=t.x/2,r=t.y/2,o=()=>{s<n?this.pointer.x=Ki(s,0,n,-1,1):this.pointer.x=Ki(s,n,t.x,-1,1)},l=()=>{i<r?this.pointer.y=Ki(i,0,r,1,-1):this.pointer.y=Ki(i,r,t.y,1,-1)};switch(this.state.mode){case"Quad":o(),l();break;case"Side by Side":o();break;case"Stacked":l(),l();break}if(this.updateCamera(s,i,n,r),this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const c=this.raycaster.intersectObjects(this.currentScene.children);c.length>0&&this.interactionHelper.position.copy(c[0].point)};onClick=e=>{if(this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const t=new x.Vector2;if(this.renderer.getSize(t),e.clientX>=t.x)return;this.onMouseMove(e);const s=this.raycaster.intersectObjects(this.currentScene.children);s.length>0&&(this.props.three.getObject(s[0].object.uuid),this.interactionHelper.visible=!1,this.setState({interactionMode:"Orbit",lastUpdate:Date.now()}))};onKey=e=>{if(this.selectedItem!==void 0){if(e.ctrlKey){if(this.currentCamera.name==="UI")return;const t=this.controls.get(this.currentCamera.name);e.key==="0"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Ds(this.currentCamera,this.currentWindow.current),this.selectedItem instanceof x.Mesh||this.selectedItem instanceof x.SkinnedMesh?(this.selectedItem.geometry.computeBoundingBox(),this.cameraControls.fitToBox(this.selectedItem.geometry.boundingBox,!0)):this.cameraControls.fitToSphere(this.selectedItem,!0),this.updateCameraControls(t,!0)):e.key==="1"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Ds(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,Math.PI*.5,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="2"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Ds(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,0,!0),this.cameraControls.moveTo(this.selectedItem.position.x,0,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="3"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Ds(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI/2,Math.PI/2,!0),this.cameraControls.moveTo(0,this.selectedItem.position.y,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="4"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Ds(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI,Math.PI/2,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="5"&&(e.preventDefault(),this.clearControls(),this.cameraControls=new Ds(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(zo(45),zo(45),!0),this.updateCameraControls(t))}else if(this.currentTransform!==void 0)switch(e.key){case"r":this.currentTransform.setMode("rotate");break;case"s":this.currentTransform.setMode("scale");break;case"t":this.currentTransform.setMode("translate");break;case"q":this.currentTransform.setSpace(this.currentTransform.space==="local"?"world":"local");break}}};onSetSelectedItem=e=>{this.selectedItem!==void 0&&this.updateSelectedItemHelper(!1),this.selectedItem=this.currentScene.getObjectByProperty("uuid",e.value.uuid),this.selectedItem!==void 0&&(this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),xt.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=xt.instance.add(e.value.name),this.currentTransform.attach(this.selectedItem),this.helpersContainer.add(this.currentTransform.getHelper()),this.currentTransform.addEventListener("objectChange",this.onUpdateTransform),this.updateSelectedItemHelper(!0))};updateSelectedItemHelper(e){if(this.selectedItem!==void 0)if(this.cameraVisibility){if(this.selectedItem.isLight===!0&&!this.lightVisibility){const t=this.lightHelpers.get(this.selectedItem.name);t!==void 0&&(t.visible=e)}}else{const t=this.cameraHelpers.get(this.selectedItem.name);t!==void 0&&(t.visible=e)}}onUpdateTransform=()=>{this.selectedItem!==void 0&&(this.props.three.updateObject(this.selectedItem.uuid,"position",this.selectedItem.position),this.props.three.updateObject(this.selectedItem.uuid,"rotation",{x:this.selectedItem.rotation.x,y:this.selectedItem.rotation.y,z:this.selectedItem.rotation.z}),this.props.three.updateObject(this.selectedItem.uuid,"scale",this.selectedItem.scale),Al.instance.update())};clearLightHelpers=()=>{this.lightHelpers.forEach(e=>{this.helpersContainer.remove(e),e.dispose()}),this.lightHelpers.clear()};addLightHelpers=e=>{e.traverse(t=>{if(t.type.search("Light")>-1){let s;switch(t.type){case"DirectionalLight":s=new x.DirectionalLightHelper(t,100),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"HemisphereLight":s=new x.HemisphereLightHelper(t,250),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"RectAreaLight":s=new UR(t),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"PointLight":s=new x.PointLightHelper(t,100),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"SpotLight":s=new x.SpotLightHelper(t),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break}}})};createControls(e,t){const s=this.controls.get(e.name);if(s!==void 0&&s.dispose(),this.controls.delete(e.name),e.name==="UI")return;const i=new zR(e,t);switch(i.enableDamping=!0,i.dampingFactor=.2,e.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":i.enableRotate=!1;break}this.controls.set(e.name,i)}clearCamera(e){const t=this.cameraHelpers.get(e.name);t!==void 0&&(this.helpersContainer.remove(t),t.dispose(),this.cameraHelpers.delete(e.name));const s=this.controls.get(e.name);s!==void 0&&(s.dispose(),this.controls.delete(e.name))}killControls(){this.controls.forEach((e,t)=>{e.dispose();const s=this.cameraHelpers.get(t);s!==void 0&&(this.helpersContainer.remove(s),s.dispose()),this.cameraHelpers.delete(t),this.controls.delete(t)}),this.controls.clear(),this.cameraHelpers.clear()}assignControls(){switch(this.state.mode){case"Single":this.createControls(this.tlCam,this.tlWindow.current);break;case"Side by Side":case"Stacked":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current);break;case"Quad":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current),this.createControls(this.blCam,this.blWindow.current),this.createControls(this.brCam,this.brWindow.current);break}}updateCamera=(e,t,s,i)=>{switch(this.state.mode){case"Quad":t<i?e<s?this.currentCamera=this.tlCam:this.currentCamera=this.trCam:e<s?this.currentCamera=this.blCam:this.currentCamera=this.brCam;break;case"Side by Side":e<s?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break;case"Single":this.currentCamera=this.tlCam;break;case"Stacked":t<i?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break}this.splineEditor.camera=this.currentCamera,this.raycaster.setFromCamera(this.pointer,this.currentCamera),this.currentCamera===this.tlCam?this.currentWindow=this.tlWindow:this.currentCamera===this.trCam?this.currentWindow=this.trWindow:this.currentCamera===this.blCam?this.currentWindow=this.blWindow:this.currentCamera===this.brCam&&(this.currentWindow=this.brWindow),xt.instance.updateCamera(this.currentCamera,this.currentWindow.current)};updateCameraControls=(e,t=!1)=>{if(this.selectedItem===void 0)return;cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.cameraControls&&(this.cameraControls.smoothTime=.1);const s=.15,i=new x.Clock;i.start(),this.selectedItem.getWorldPosition(e.target0);const n=()=>{const r=i.getDelta();this.cameraControls&&this.cameraControls.update(r),t&&(e.target.lerp(e.target0,s),e.object.position.lerp(e.position0,s),e.object.zoom=rr(e.object.zoom,e.zoom0,s),e.object.updateProjectionMatrix(),e.dispatchEvent({type:"change"})),i.getElapsedTime()>=.5?(cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.clearControls()):this.cameraControlsRafID=requestAnimationFrame(n)};n()};clearControls=()=>{this.cameraControls!==void 0&&(this.cameraControls.disconnect(),this.cameraControls.dispose(),this.cameraControls=void 0)};saveExpandedCameraVisibility(){localStorage.setItem(this.expandedCameraVisibility,this.cameraVisibility?"open":"closed")}saveExpandedLightVisibility(){localStorage.setItem(this.expandedLightVisibility,this.lightVisibility?"open":"closed")}saveExpandedGridVisibility(){localStorage.setItem(this.expandedGridVisibility,this.gridVisibility?"open":"closed")}getSceneOverride(e){switch(e){case"Depth":return this.depthMaterial;case"Normals":return this.normalsMaterial;case"Renderer":return null;case"UVs":return this.uvMaterial;case"Wireframe":return this.wireframeMaterial}return null}drawTo(e,t,s,i,n,r){switch(n.name){case"Left":case"Right":this.grid.rotation.z=Math.PI/2;break;case"Front":case"Back":this.grid.rotation.x=Math.PI/2;break}this.scene.overrideMaterial=r,this.renderer&&(this.renderer?.setViewport(e,t,s,i),this.renderer?.setScissor(e,t,s,i),this.renderer instanceof x.WebGLRenderer?this.renderer?.render(this.scene,n):this.renderer instanceof mo&&this.renderer?.renderAsync(this.scene,n)),this.grid.rotation.set(0,0,0)}drawSingle(){const e=this.getSceneOverride(this.tlRender);this.drawTo(0,0,this.width,this.height,this.tlCam,e)}drawDouble=()=>{const e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),s=Math.floor(this.width/2),i=Math.floor(this.height/2);if(this.state.mode==="Side by Side")this.drawTo(0,0,s,this.height,this.tlCam,e),this.drawTo(s,0,s,this.height,this.trCam,t);else{const n=this.height-i;this.drawTo(0,n,this.width,i,this.tlCam,e),this.drawTo(0,0,this.width,i,this.trCam,t)}};drawQuad=()=>{const e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),s=this.getSceneOverride(this.blRender),i=this.getSceneOverride(this.brRender),n=Math.floor(this.width/2),r=Math.floor(this.height/2);let o=0,l=0;l=this.height-r,o=0,this.drawTo(o,l,n,r,this.tlCam,e),o=n,this.drawTo(o,l,n,r,this.trCam,t),l=0,o=0,this.scene.overrideMaterial=s,this.drawTo(o,l,n,r,this.blCam,s),o=n,this.drawTo(o,l,n,r,this.brCam,i)};get appID(){return this.props.three.app.appID}get mode(){return this.state.mode}get three(){return this.props.three}get expandedCameraVisibility(){return`${this.appID}_multiviewCameraVisibility`}get expandedLightVisibility(){return`${this.appID}_multiviewLightVisibility`}get expandedGridVisibility(){return`${this.appID}_multiviewGridVisibility`}}class Al extends W.Component{static instance;app;matrix=new x.Matrix4;position=new x.Vector3;rotation=new x.Euler;scale=new x.Vector3;open=!1;constructor(e){super(e),this.app=e.app;const t=localStorage.getItem(this.expandedName),s=t!==null?t==="open":!1;this.open=s,this.saveExpanded(),this.state={lastUpdated:0,expanded:s},this.matrix.elements=e.object.matrix,e.object.uuid.length>0&&(this.position.setFromMatrixPosition(this.matrix),this.rotation.setFromRotationMatrix(this.matrix),this.scale.setFromMatrixScale(this.matrix)),Al.instance=this}update(){if(et.instance){const e=et.instance.selectedItem;if(e===void 0)return;this.position.x=ss(e.position.x,3),this.position.y=ss(e.position.y,3),this.position.z=ss(e.position.z,3),this.rotation.copy(e.rotation),this.scale.x=ss(e.scale.x,3),this.scale.y=ss(e.scale.y,3),this.scale.z=ss(e.scale.z,3),this.setState({lastUpdated:Date.now()})}}render(){return C.jsx(cs,{app:this.app,title:"Transform",expanded:this.open,items:[{title:"Position",prop:"position",type:"grid3",step:.1,value:this.position,onChange:this.updateTransform},{title:"Rotation",prop:"rotation",type:"euler",value:this.rotation,onChange:this.updateTransform},{title:"Scale",prop:"scale",type:"grid3",value:this.scale,onChange:this.updateTransform},{title:"Visible",prop:"visible",type:"boolean",value:this.props.object.visible,onChange:this.updateTransform}],onToggle:e=>{this.open=e,this.saveExpanded()}},this.state.lastUpdated)}updateTransform=(e,t)=>{const s=e==="rotation"?{x:t._x,y:t._y,z:t._z}:t;this.props.three.updateObject(this.props.object.uuid,e,s);const i=this.props.three.getScene(this.props.object.uuid);if(i){const n=i.getObjectByProperty("uuid",this.props.object.uuid);qe(n,e,s)}};saveExpanded(){localStorage.setItem(this.expandedName,this.open?"open":"closed")}get expandedName(){return`${this.props.three.app.appID}_transform`}}function Qf(a){switch(a){case"color":return"Color";case"intensity":return"Intensity";case"decay":return"Decay";case"distance":return"Distance";case"angle":return"Angle";case"penumbra":return"Penumbra";case"groundColor":return"Ground Color";case"width":return"Width";case"height":return"Height"}return a}function SN(a,e,t){function s(){return`${t.app.appID}_light`}const i=localStorage.getItem(s()),n=i!==null?i==="open":!1;function r(l){localStorage.setItem(s(),l?"open":"closed")}const o=[];if(a.lightInfo!==void 0)for(const l in a.lightInfo){const c=a.lightInfo[l];c!==void 0&&(c.isColor!==void 0?o.push({title:Qf(l),prop:l,type:"color",value:c,onChange:(h,u)=>{const d=new x.Color(u);t.updateObject(a.uuid,h,d);const p=t.getScene(a.uuid);if(p!==null){const f=p.getObjectByProperty("uuid",a.uuid);qe(f,h,d)}}}):o.push({title:Qf(l),prop:l,type:typeof c,value:c,step:typeof c=="number"?.01:void 0,onChange:(h,u)=>{t.updateObject(a.uuid,h,u);const d=t.getScene(a.uuid);if(d!==null){const p=d.getObjectByProperty("uuid",a.uuid);qe(p,h,u)}}}))}return C.jsx(cs,{app:e,title:"Light",items:o,expanded:n,onToggle:l=>{r(l)}})}function vN(a){const e=a.object,t=a.three;function s(){return`${t.app.appID}_animation`}const i=localStorage.getItem(s()),n=i!==null?i==="open":!1;function r(d){localStorage.setItem(s(),d?"open":"closed")}const o=[],l=[];let c=0;e.animations.forEach(d=>{c=Math.max(c,d.duration),d.duration>0&&l.push({title:d.name,items:[{title:"Duration",type:"number",value:d.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),o.push({title:"Animations",items:l});let h;const u=t.getScene(e.uuid);if(u!==null){const d=u.getObjectByProperty("uuid",e.uuid);if(d!==void 0){const p=d.mixer;if(p!==void 0){const m=[{title:"Time Scale",type:"range",value:p.timeScale,step:.01,min:-1,max:2,onChange:(y,g)=>{p.timeScale=g,t.updateObject(e.uuid,"mixer.timeScale",g)}}];m.push({title:"Stop All",type:"button",onChange:()=>{p.stopAllAction(),t.requestMethod(e.uuid,"stopAllAction",void 0,"mixer")}}),o.push({title:"Mixer",items:m}),h=new x.SkeletonHelper(d),et.instance?.scene.add(h)}}}return W.useEffect(()=>()=>{h!==void 0&&ii(h)},[]),C.jsx(cs,{app:a.app,title:"Animation",items:o,expanded:n,onToggle:d=>{r(d)}})}const $h={name:"",uuid:"",type:"",visible:!1,matrix:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};let ft={...$h};function Gy(a){const[e,t]=W.useState(-1);W.useEffect(()=>{function r(l){ft={...l.value},t(Date.now())}function o(){ft={...$h},t(Date.now())}return a.app.addEventListener(Q.SET_SCENE,o),a.app.addEventListener(Q.SET_OBJECT,r),()=>{a.app.removeEventListener(Q.SET_SCENE,o),a.app.removeEventListener(Q.SET_OBJECT,r)}},[]);const s=ft.type.toLowerCase(),i=ft.animations.length>0||ft.mixer!==void 0,n=s.search("mesh")>-1||s.search("line")>-1||s.search("points")>-1;return C.jsx(fa,{app:a.app,label:"Inspector",button:ft.uuid.length>0?C.jsx("button",{className:"remove",onClick:()=>{xt.instance.remove(ft.name),ft={...$h},t(Date.now())}}):void 0,children:C.jsx("div",{id:"Inspector",className:a.class,children:ft.uuid.length>0&&C.jsxs(C.Fragment,{children:[C.jsxs(C.Fragment,{children:[C.jsx(Eo,{type:"string",title:"Name",prop:"name",value:ft.name,disabled:!0}),C.jsx(Eo,{type:"string",title:"Type",prop:"type",value:ft.type,disabled:!0}),C.jsx(Eo,{type:"string",title:"UUID",prop:"uuid",value:ft.uuid,disabled:!0})]}),C.jsxs(C.Fragment,{children:[C.jsx(Al,{object:ft,app:a.app,three:a.three}),i?C.jsx(vN,{app:a.app,object:ft,three:a.three}):null,s.search("camera")>-1?$x(ft,a.app,a.three):null,s.search("light")>-1?SN(ft,a.app,a.three):null,n?Vx(ft,a.app,a.three):null]})]})},e)},"Inspector")}class wN extends W.Component{app;autoClear=!0;autoClearColor=!0;autoClearDepth=!0;autoClearStencil=!0;outputColorSpace=x.SRGBColorSpace;localClippingEnabled=!1;clearColor=new x.Color(0);clearAlpha=1;toneMapping=x.NoToneMapping;toneMappingExposure=1;type="";constructor(e){super(e),this.app=e.app;const t=localStorage.getItem(this.expandedName),s=t!==null?t==="open":!1;if(this.state={expanded:s,lastUpdated:Date.now()},this.saveExpanded(s),et.instance){const i=et.instance.renderer;i&&(this.autoClear=i.autoClear,this.autoClearColor=i.autoClearColor,this.autoClearDepth=i.autoClearDepth,this.autoClearStencil=i.autoClearStencil,this.clearAlpha=i.getClearAlpha(),this.toneMapping=i.toneMapping,this.toneMappingExposure=i.toneMappingExposure,i instanceof x.WebGLRenderer&&(this.localClippingEnabled=i.localClippingEnabled,i.getClearColor(this.clearColor)))}this.app.addEventListener(Q.ADD_RENDERER,this.onAddRenderer)}componentwillunmount(){this.app.removeEventListener(Q.ADD_RENDERER,this.onAddRenderer)}onAddRenderer=e=>{const t=e.value;if(this.autoClear=t.autoClear,this.autoClearColor=t.autoClearColor,this.autoClearDepth=t.autoClearDepth,this.autoClearStencil=t.autoClearStencil,this.outputColorSpace=t.outputColorSpace,this.localClippingEnabled=t.localClippingEnabled,this.clearAlpha=t.clearAlpha,this.type=t.type,this.toneMapping=t.toneMapping,this.toneMappingExposure=t.toneMappingExposure,this.clearColor.setStyle(t.clearColor,x.LinearSRGBColorSpace),x.ColorManagement.enabled=t.colorManagement,et.instance){const s=et.instance.renderer;s&&(s.autoClearColor=this.autoClearColor,s.outputColorSpace=this.outputColorSpace,s.localClippingEnabled=this.localClippingEnabled,s.toneMapping=this.toneMapping,s.toneMappingExposure=this.toneMappingExposure,s.setClearColor(t.clearColor,this.clearAlpha))}this.setState({lastUpdated:Date.now()})};render(){const e=()=>{if(et.instance){const t=et.instance.renderer;t&&(t.autoClearColor=this.autoClearColor,t.outputColorSpace=this.outputColorSpace,t.localClippingEnabled=this.localClippingEnabled,t.toneMapping=this.toneMapping,t.toneMappingExposure=this.toneMappingExposure,t.setClearColor(this.clearColor.getStyle(),this.clearAlpha),this.props.three.updateRenderer({autoClear:this.autoClear,autoClearColor:this.autoClearColor,autoClearDepth:this.autoClearDepth,autoClearStencil:this.autoClearStencil,outputColorSpace:this.outputColorSpace,localClippingEnabled:this.localClippingEnabled,clearAlpha:this.clearAlpha,clearColor:this.clearColor.getStyle(),colorManagement:x.ColorManagement.enabled,toneMapping:this.toneMapping,toneMappingExposure:this.toneMappingExposure}))}};return C.jsx(cs,{app:this.app,title:"Renderer",expanded:this.state.expanded,items:[{type:"boolean",title:"Auto Clear",value:this.autoClear,onChange:(t,s)=>{this.autoClear=s}},{type:"boolean",title:"Auto Clear Color",value:this.autoClearColor,onChange:(t,s)=>{this.autoClearColor=s,e()}},{type:"boolean",title:"Auto Clear Depth",value:this.autoClearDepth,onChange:(t,s)=>{this.autoClearDepth=s,e()}},{type:"boolean",title:"Auto Clear Stencil",value:this.autoClearStencil,onChange:(t,s)=>{this.autoClearStencil=s,e()}},{type:"boolean",title:"Local Clipping",value:this.localClippingEnabled,onChange:(t,s)=>{this.localClippingEnabled=s,e()}},{type:"color",title:"Clear Color",value:`#${this.clearColor.getHexString()}`,onChange:(t,s)=>{this.clearColor.setStyle(s),e()}},{type:"range",title:"Clear Alpha",min:0,max:1,step:.01,value:this.clearAlpha,onChange:(t,s)=>{this.clearAlpha=s,e()}},{type:"boolean",title:"Clear Management",value:x.ColorManagement.enabled,onChange:(t,s)=>{x.ColorManagement.enabled=s,e()}},{type:"option",title:"Color Space",value:this.outputColorSpace,options:[{title:"No Color Space",value:x.NoColorSpace},{title:"SRB Color Space",value:x.SRGBColorSpace},{title:"Linear SRB Color Space",value:x.LinearSRGBColorSpace}],onChange:(t,s)=>{this.outputColorSpace=s,e()}},{type:"option",title:"Tone Mapping",value:this.toneMapping,options:[{title:"None ",value:x.NoToneMapping},{title:"Linear ",value:x.LinearToneMapping},{title:"Reinhard",value:x.ReinhardToneMapping},{title:"Cineon ",value:x.CineonToneMapping},{title:"ACES Filmic",value:x.ACESFilmicToneMapping},{title:"AgX",value:x.AgXToneMapping},{title:"Neutral",value:x.NeutralToneMapping},{title:"Custom",value:x.CustomToneMapping}],onChange:(t,s)=>{this.toneMapping=s,e()}},{type:"range",title:"Tone Mapping Exposure",value:this.toneMappingExposure,min:0,max:2,step:.01,onChange:(t,s)=>{this.toneMappingExposure=s,e()}},{type:"string",title:"Type",value:this.type,disabled:!0}],onToggle:t=>{this.setState({expanded:t}),this.saveExpanded(t)}},Math.random())}saveExpanded(e){localStorage.setItem(this.expandedName,e?"open":"closed")}get expandedName(){return`${this.props.three.app.appID}_renderer`}}function Vy(a){const[e]=W.useState([]),[t]=W.useState([]),[s,i]=W.useState(0),n=l=>{const c=l.value;e.push(c),t.push(C.jsx(fa,{app:a.app,label:`Scene: ${c.name}`,scene:c,open:!0,onRefresh:()=>{a.three.refreshScene(c.name)},children:C.jsx(hh,{app:a.app,child:c,scene:c,three:a.three})},Math.random())),i(Date.now())},r=l=>{const c=l.value;for(let h=0;h<e.length;h++)if(c.uuid===e[h].uuid){e[h]=c,t[h]=C.jsx(fa,{app:a.app,label:`Scene: ${c.name}`,scene:c,open:!0,onRefresh:()=>{a.three.refreshScene(c.name)},children:C.jsx(hh,{app:a.app,child:c,scene:c,three:a.three})},Math.random()),i(Date.now());return}},o=l=>{const c=l.value;for(let h=0;h<e.length;h++)if(c.uuid===e[h].uuid){e.splice(h,1),t.splice(h,1),i(Date.now());return}};return W.useEffect(()=>(a.app.addEventListener(Q.ADD_SCENE,n),a.app.addEventListener(Q.REFRESH_SCENE,r),a.app.addEventListener(Q.REMOVE_SCENE,o),()=>{a.app.removeEventListener(Q.ADD_SCENE,n),a.app.removeEventListener(Q.REFRESH_SCENE,r),a.app.removeEventListener(Q.REMOVE_SCENE,o)}),[]),C.jsxs("div",{id:"SidePanel",children:[C.jsx("div",{className:"scenes",children:t},s),C.jsx(Gy,{app:a.app,three:a.three}),C.jsx(wN,{app:a.app,three:a.three}),C.jsx(Re,{app:a.app,three:a.three})]})}function EN(a){return W.useEffect(()=>{function e(o){let l=null;return a.three.scenes.forEach(c=>{o.search(c.uuid)>-1&&(l=c)}),l}const t=o=>{const l=o.value,c=e(l),h=c?.getObjectByProperty("uuid",l);h!==void 0?a.three.setObject(h):console.log(`Hermes - can't find object: ${l}`,c)},s=(o,l,c)=>{const h=e(o),u=h?.getObjectByProperty("uuid",o);u!==void 0?qe(u,l,c):console.log(`Hermes - can't set object: ${o}`,h)},i=o=>{const l=o.value,{key:c,value:h,uuid:u}=l;s(u,c,h)},n=o=>{const l=o.value,h=e(l.uuid)?.getObjectByProperty("uuid",l.uuid);if(h!==void 0){const u=d=>{const p=l.key.split(".");switch(p.length){case 1:h[p[0]]=d;break;case 2:h[p[0]][p[1]]=d;break;case 3:h[p[0]][p[1]][p[2]]=d;break;case 4:h[p[0]][p[1]][p[2]][p[3]]=d;break;case 5:h[p[0]][p[1]][p[2]][p[3]][p[4]]=d;break}h.material.needsUpdate=!0};l.value.src.length>0?rm(l.value.src).then(d=>{d.offset.set(l.value.offset[0],l.value.offset[1]),d.repeat.set(l.value.repeat[0],l.value.repeat[1]),u(d)}):u(null)}},r=o=>{const{key:l,uuid:c,value:h,subitem:u}=o.value,p=e(c)?.getObjectByProperty("uuid",c);if(p!==void 0)try{u!==void 0?nx(p,u)[l](h):p[l](h)}catch(f){console.log("Error requesting method:"),console.log(f),console.log(l),console.log(h)}};return a.app.addEventListener(Q.GET_OBJECT,t),a.app.addEventListener(Q.UPDATE_OBJECT,i),a.app.addEventListener(Q.CREATE_TEXTURE,n),a.app.addEventListener(Q.REQUEST_METHOD,r),()=>{a.app.removeEventListener(Q.GET_OBJECT,t),a.app.removeEventListener(Q.UPDATE_OBJECT,i),a.app.removeEventListener(Q.CREATE_TEXTURE,n),a.app.removeEventListener(Q.REQUEST_METHOD,r)}},[]),null}function Hy(a){return C.jsxs("div",{className:"editor",ref:a.ref,style:a.style,children:[C.jsx("div",{className:"header",children:a.header}),a.children,C.jsx("div",{className:"footer",children:a.footer})]})}function MN(a){return C.jsx(Hy,{children:C.jsxs(C.Fragment,{children:[C.jsx(et,{app:a.app,three:a.three,scenes:a.scenes,onSceneResize:a.onSceneResize,onSceneSet:a.onSceneSet,onSceneUpdate:a.onSceneUpdate}),C.jsx(Vy,{app:a.app,three:a.three})]})})}exports.Accordion=fa;exports.AppRunner=q0;exports.Application=j0;exports.BaseRemote=ol;exports.BaseScene=Y0;exports.ChildObject=Zh;exports.ContainerObject=hh;exports.Draggable=om;exports.DraggableItem=am;exports.Dropdown=lm;exports.DropdownItem=cm;exports.Editor=Hy;exports.ElementProxy=W0;exports.ElementProxyReceiver=nm;exports.ExportTexture=Ri;exports.Inspector=Gy;exports.MultiView=et;exports.NavButton=Xh;exports.ProxyManager=$0;exports.QualityType=jh;exports.RemoteComponents=X0;exports.RemoteTheatre=ex;exports.RemoteThree=ax;exports.SceneInspector=EN;exports.SidePanel=Vy;exports.Spline=Lo;exports.SplineEditor=zy;exports.ThreeEditor=MN;exports.ToolEvents=Q;exports.Transform=xt;exports.WebworkerEventHandlers=V0;exports.capitalize=pa;exports.clamp=Ti;exports.clearComposerGroups=F0;exports.colorToHex=ah;exports.copyToClipboard=Kf;exports.cubicBezier=N0;exports.customizeTheatreElements=Q0;exports.damp=w0;exports.defaultTheatreCallback=g0;exports.detectMaxFrameRate=sm;exports.detectSettings=im;exports.dispose=ii;exports.disposeMaterial=qh;exports.disposeTexture=oh;exports.distance=v0;exports.generateCubemap=O0;exports.hierarchyUUID=ko;exports.inspectComposer=D0;exports.isColor=em;exports.map=S0;exports.mix=rr;exports.noop=da;exports.normalize=Uo;exports.parseModelLite=P0;exports.randomID=Jf;exports.resetThreeObjects=lh;exports.round=ss;exports.roundTo=E0;exports.theatreEditorApp=Z0;
|
package/dist/hermes.es.js
CHANGED
|
@@ -220,13 +220,14 @@ function c_(a = !1, e = !1) {
|
|
|
220
220
|
height: innerHeight,
|
|
221
221
|
mobile: s.isMobile !== void 0 ? s.isMobile : !1,
|
|
222
222
|
supportOffScreenCanvas: i,
|
|
223
|
+
supportWebGPU: !!navigator.gpu,
|
|
223
224
|
quality: 2,
|
|
224
225
|
dev: a,
|
|
225
226
|
editor: e
|
|
226
227
|
};
|
|
227
228
|
s.tier === 3 ? o.quality = 0 : s.tier === 2 && (o.quality = 1), l_((l) => {
|
|
228
229
|
o.fps = l, t(o);
|
|
229
|
-
})
|
|
230
|
+
});
|
|
230
231
|
});
|
|
231
232
|
});
|
|
232
233
|
}
|
|
@@ -789,6 +790,7 @@ class _P extends xu {
|
|
|
789
790
|
height: 0,
|
|
790
791
|
mobile: !1,
|
|
791
792
|
supportOffScreenCanvas: !1,
|
|
793
|
+
supportWebGPU: !1,
|
|
792
794
|
quality: sg.Low,
|
|
793
795
|
dev: !1,
|
|
794
796
|
editor: !1
|
|
@@ -1146,8 +1148,8 @@ class EP extends Su {
|
|
|
1146
1148
|
dispose() {
|
|
1147
1149
|
this.project = void 0, this.sheets = /* @__PURE__ */ new Map(), this.sheetObjects = /* @__PURE__ */ new Map(), this.sheetObjectCBs = /* @__PURE__ */ new Map(), this.sheetObjectUnsubscribe = /* @__PURE__ */ new Map();
|
|
1148
1150
|
}
|
|
1149
|
-
update() {
|
|
1150
|
-
this.rafDriver?.tick(
|
|
1151
|
+
update(e) {
|
|
1152
|
+
this.rafDriver?.tick(e);
|
|
1151
1153
|
}
|
|
1152
1154
|
getSheetInstance(e, t) {
|
|
1153
1155
|
return t !== void 0 ? `${e}-${t}` : e;
|
|
@@ -1287,7 +1289,10 @@ class EP extends Su {
|
|
|
1287
1289
|
if (this.app.editor)
|
|
1288
1290
|
switch (e.event) {
|
|
1289
1291
|
case "playSheet":
|
|
1290
|
-
this.sheet(e.data.sheet, e.data.instance)?.sequence.play(
|
|
1292
|
+
this.sheet(e.data.sheet, e.data.instance)?.sequence.play({
|
|
1293
|
+
...e.data.value,
|
|
1294
|
+
rafDriver: this.rafDriver
|
|
1295
|
+
});
|
|
1291
1296
|
break;
|
|
1292
1297
|
case "pauseSheet":
|
|
1293
1298
|
this.sheet(e.data.sheet, e.data.instance)?.sequence.pause();
|
|
@@ -41664,6 +41669,8 @@ uniform float uDistance;
|
|
|
41664
41669
|
uniform float uGridOpacity;
|
|
41665
41670
|
uniform float uSubgridOpacity;
|
|
41666
41671
|
|
|
41672
|
+
#define minAlpha 0.00784313725490196
|
|
41673
|
+
|
|
41667
41674
|
float getGrid(float gapSize) {
|
|
41668
41675
|
vec2 worldPositionByDivision = worldPosition.xz / gapSize;
|
|
41669
41676
|
|
|
@@ -41720,7 +41727,7 @@ void main() {
|
|
|
41720
41727
|
// Shade the next grid
|
|
41721
41728
|
fragColor.a = mix(fragColor.a, baseOpacity * uGridOpacity, nextGrid);
|
|
41722
41729
|
|
|
41723
|
-
if (fragColor.a <=
|
|
41730
|
+
if (fragColor.a <= minAlpha) discard;
|
|
41724
41731
|
}`;
|
|
41725
41732
|
class PN extends Zm {
|
|
41726
41733
|
constructor(e) {
|
|
@@ -42406,7 +42413,7 @@ class Pt extends xu {
|
|
|
42406
42413
|
let t = this.controls.get(e);
|
|
42407
42414
|
if (t === void 0) {
|
|
42408
42415
|
const s = document.querySelector(".clickable");
|
|
42409
|
-
t = new BN(this.activeCamera, s), t.getHelper().name = e, t.setSize(0.
|
|
42416
|
+
t = new BN(this.activeCamera, s), t.getHelper().name = e, t.setSize(0.5), t.setSpace("local"), this.controls.set(e, t), this.visibility.set(e, !0), t.addEventListener("mouseDown", () => {
|
|
42410
42417
|
this.dispatchEvent({ type: Pt.DRAG_START });
|
|
42411
42418
|
}), t.addEventListener("mouseUp", () => {
|
|
42412
42419
|
this.dispatchEvent({ type: Pt.DRAG_END });
|
|
@@ -43318,7 +43325,7 @@ class ht extends Va {
|
|
|
43318
43325
|
const o = new Nh(-100, 100, 100, -100, 0, 3e3);
|
|
43319
43326
|
return o.name = n, o.position.copy(r), o.lookAt(0, 0, 0), this.cameras.set(n, o), o;
|
|
43320
43327
|
}, t = 1e3;
|
|
43321
|
-
e("Top", new Z(0, t, 0)), e("Bottom", new Z(0, -t, 0)), e("Left", new Z(-t, 0, 0)), e("Right", new Z(t, 0, 0)), e("Front", new Z(0, 0, t)), e("Back", new Z(0, 0, -t)), e("Orthographic", new Z(t, t, t)), e("UI", new Z()), this.debugCamera = new Vd(60, 1, 0.01,
|
|
43328
|
+
e("Top", new Z(0, t, 0)), e("Bottom", new Z(0, -t, 0)), e("Left", new Z(-t, 0, 0)), e("Right", new Z(t, 0, 0)), e("Front", new Z(0, 0, t)), e("Back", new Z(0, 0, -t)), e("Orthographic", new Z(t, t, t)), e("UI", new Z()), this.debugCamera = new Vd(60, 1, 0.01, 3e3), this.debugCamera.name = "Debug", this.debugCamera.position.set(300, 300, 300), this.debugCamera.lookAt(0, 0, 0), this.cameras.set("Debug", this.debugCamera), this.currentCamera = this.debugCamera;
|
|
43322
43329
|
const s = localStorage, i = this.props.three.app.appID;
|
|
43323
43330
|
this.tlCam = this.cameras.get(s.getItem(`${i}_tlCam`)), this.trCam = this.cameras.get(s.getItem(`${i}_trCam`)), this.blCam = this.cameras.get(s.getItem(`${i}_blCam`)), this.brCam = this.cameras.get(s.getItem(`${i}_brCam`)), this.tlCam === void 0 && (this.tlCam = this.cameras.get("Debug")), this.trCam === void 0 && (this.trCam = this.cameras.get("Orthographic")), this.blCam === void 0 && (this.blCam = this.cameras.get("Front")), this.brCam === void 0 && (this.brCam = this.cameras.get("Top"));
|
|
43324
43331
|
}
|
|
@@ -43527,7 +43534,7 @@ class ht extends Va {
|
|
|
43527
43534
|
const s = this.controls.get(e.name);
|
|
43528
43535
|
if (s !== void 0 && s.dispose(), this.controls.delete(e.name), e.name === "UI") return;
|
|
43529
43536
|
const i = new pN(e, t);
|
|
43530
|
-
switch (i.enableDamping = !0, i.dampingFactor = 0.
|
|
43537
|
+
switch (i.enableDamping = !0, i.dampingFactor = 0.2, e.name) {
|
|
43531
43538
|
case "Top":
|
|
43532
43539
|
case "Bottom":
|
|
43533
43540
|
case "Left":
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"module": "./dist/hermes.esm.js",
|
|
8
8
|
"types": "./types/index.d.ts",
|
|
9
9
|
"type": "module",
|
|
10
|
-
"version": "0.0.
|
|
10
|
+
"version": "0.0.153",
|
|
11
11
|
"homepage": "https://github.com/tomorrowevening/hermes#readme",
|
|
12
12
|
"bugs": {
|
|
13
13
|
"url": "https://github.com/tomorrowevening/hermes/issues"
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { IProject, IRafDriver, ISheet, ISheetObject } from '@theatre/core';
|
|
2
|
-
import { Application } from '../Application';
|
|
3
|
-
import BaseRemote from './BaseRemote';
|
|
4
|
-
import { BroadcastData, DataUpdateCallback, VoidCallback } from '../types';
|
|
5
|
-
type KeyframeVector = {
|
|
6
|
-
position: number;
|
|
7
|
-
x: number;
|
|
8
|
-
y: number;
|
|
9
|
-
z: number;
|
|
10
|
-
};
|
|
11
|
-
export default class RemoteTheatre extends BaseRemote {
|
|
12
|
-
project: IProject | undefined;
|
|
13
|
-
sheets: Map<string, ISheet>;
|
|
14
|
-
sheetObjects: Map<string, ISheetObject>;
|
|
15
|
-
sheetObjectCBs: Map<string, DataUpdateCallback>;
|
|
16
|
-
sheetObjectUnsubscribe: Map<string, VoidCallback>;
|
|
17
|
-
activeSheet: ISheet | undefined;
|
|
18
|
-
studio: any;
|
|
19
|
-
rafDriver?: IRafDriver;
|
|
20
|
-
constructor(app: Application, createRaf?: boolean);
|
|
21
|
-
dispose(): void;
|
|
22
|
-
update(): void;
|
|
23
|
-
getSheetInstance(name: string, instanceId?: string): string;
|
|
24
|
-
sheet(name: string, instanceId?: string): ISheet | undefined;
|
|
25
|
-
playSheet(name: string, params?: any, instanceId?: string): Promise<boolean>;
|
|
26
|
-
pauseSheet(name: string, instanceId?: string): void;
|
|
27
|
-
clearSheetObjects(sheetName: string): void;
|
|
28
|
-
sheetObject(sheetName: string, key: string, props: any, onUpdate?: DataUpdateCallback, instanceId?: string): ISheetObject | undefined;
|
|
29
|
-
getSheetObjectKeyframes(sheetName: string, sheetObject: string, prop: string): any[];
|
|
30
|
-
getSheetObjectVectors(sheetName: string, sheetObject: string): KeyframeVector[];
|
|
31
|
-
unsubscribe(sheetObject: ISheetObject): undefined;
|
|
32
|
-
handleApp(msg: BroadcastData): void;
|
|
33
|
-
handleEditor(msg: BroadcastData): void;
|
|
34
|
-
handleEditorApp(): void;
|
|
35
|
-
}
|
|
36
|
-
export {};
|
|
1
|
+
import { IProject, IRafDriver, ISheet, ISheetObject } from '@theatre/core';
|
|
2
|
+
import { Application } from '../Application';
|
|
3
|
+
import BaseRemote from './BaseRemote';
|
|
4
|
+
import { BroadcastData, DataUpdateCallback, VoidCallback } from '../types';
|
|
5
|
+
type KeyframeVector = {
|
|
6
|
+
position: number;
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
z: number;
|
|
10
|
+
};
|
|
11
|
+
export default class RemoteTheatre extends BaseRemote {
|
|
12
|
+
project: IProject | undefined;
|
|
13
|
+
sheets: Map<string, ISheet>;
|
|
14
|
+
sheetObjects: Map<string, ISheetObject>;
|
|
15
|
+
sheetObjectCBs: Map<string, DataUpdateCallback>;
|
|
16
|
+
sheetObjectUnsubscribe: Map<string, VoidCallback>;
|
|
17
|
+
activeSheet: ISheet | undefined;
|
|
18
|
+
studio: any;
|
|
19
|
+
rafDriver?: IRafDriver;
|
|
20
|
+
constructor(app: Application, createRaf?: boolean);
|
|
21
|
+
dispose(): void;
|
|
22
|
+
update(now: number): void;
|
|
23
|
+
getSheetInstance(name: string, instanceId?: string): string;
|
|
24
|
+
sheet(name: string, instanceId?: string): ISheet | undefined;
|
|
25
|
+
playSheet(name: string, params?: any, instanceId?: string): Promise<boolean>;
|
|
26
|
+
pauseSheet(name: string, instanceId?: string): void;
|
|
27
|
+
clearSheetObjects(sheetName: string): void;
|
|
28
|
+
sheetObject(sheetName: string, key: string, props: any, onUpdate?: DataUpdateCallback, instanceId?: string): ISheetObject | undefined;
|
|
29
|
+
getSheetObjectKeyframes(sheetName: string, sheetObject: string, prop: string): any[];
|
|
30
|
+
getSheetObjectVectors(sheetName: string, sheetObject: string): KeyframeVector[];
|
|
31
|
+
unsubscribe(sheetObject: ISheetObject): undefined;
|
|
32
|
+
handleApp(msg: BroadcastData): void;
|
|
33
|
+
handleEditor(msg: BroadcastData): void;
|
|
34
|
+
handleEditorApp(): void;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
export declare enum QualityType {
|
|
2
|
-
'High' = 0,
|
|
3
|
-
'Medium' = 1,
|
|
4
|
-
'Low' = 2
|
|
5
|
-
}
|
|
6
|
-
export type AppSettings = {
|
|
7
|
-
dpr: number;
|
|
8
|
-
fps: number;
|
|
9
|
-
width: number;
|
|
10
|
-
height: number;
|
|
11
|
-
mobile: boolean;
|
|
12
|
-
supportOffScreenCanvas: boolean;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export declare function
|
|
1
|
+
export declare enum QualityType {
|
|
2
|
+
'High' = 0,
|
|
3
|
+
'Medium' = 1,
|
|
4
|
+
'Low' = 2
|
|
5
|
+
}
|
|
6
|
+
export type AppSettings = {
|
|
7
|
+
dpr: number;
|
|
8
|
+
fps: number;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
mobile: boolean;
|
|
12
|
+
supportOffScreenCanvas: boolean;
|
|
13
|
+
supportWebGPU: boolean;
|
|
14
|
+
quality: QualityType;
|
|
15
|
+
dev: boolean;
|
|
16
|
+
editor: boolean;
|
|
17
|
+
};
|
|
18
|
+
export declare function detectMaxFrameRate(callback: (fps: number) => void): void;
|
|
19
|
+
export declare function detectSettings(dev?: boolean, editor?: boolean): Promise<AppSettings>;
|