@tomorrowevening/hermes 0.0.14 → 0.0.16

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.
@@ -1,4 +1,4 @@
1
- (function(w,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("three"),require("@theatre/core"),require("@theatre/studio"),require("tweakpane"),require("@tweakpane/plugin-essentials"),require("react"),require("framer-motion")):typeof define=="function"&&define.amd?define(["exports","three","@theatre/core","@theatre/studio","tweakpane","@tweakpane/plugin-essentials","react","framer-motion"],d):(w=typeof globalThis<"u"?globalThis:w||self,d(w.Hermes={},w.Three,w["Theatre Core"],w["Theatre Studio"],w.tweakpane,w["tweakpane-plugin-essentials"],w.React,w["framer-motion"]))})(this,function(w,d,Me,We,wn,Cn,M,Ft){"use strict";var Ta=Object.defineProperty;var Ma=(w,d,Me)=>d in w?Ta(w,d,{enumerable:!0,configurable:!0,writable:!0,value:Me}):w[d]=Me;var $=(w,d,Me)=>(Ma(w,typeof d!="symbol"?d+"":d,Me),Me);function Sn(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const e=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(n,a,e.get?e:{enumerable:!0,get:()=>t[a]})}}return n.default=t,Object.freeze(n)}const xn=Sn(Cn);function On(t,n,a){return Math.min(n,Math.max(t,a))}function Tn(t,n){const a=t-n;return Math.sqrt(a*a)}function Vt(){return Math.round(Math.random()*1e6).toString()}function Bt(t){return t.r!==void 0&&t.g!==void 0&&t.b!==void 0}function Gt(t){const n=Math.round(t.r*255),a=Math.round(t.g*255),e=Math.round(t.b*255),r=f=>{const m=f.toString(16);return m.length===1?"0"+m:m},s=r(n),u=r(a),l=r(e);return"#"+s+u+l}function ot(t,n=1){return Number(t.toFixed(n))}w.totalThreeObjects=0;const Ht=()=>{w.totalThreeObjects=0},xt=t=>{if(!t)return;let n=t.name.replace(" ","");n.length===0&&(n=`obj_${w.totalThreeObjects}`,w.totalThreeObjects++),t.parent!==null&&(n=`${t.parent.uuid}.${n}`),t.uuid=n,t.children.forEach(a=>{xt(a)})},Mn=t=>{t==null||t.dispose()},zt=t=>{t&&(Array.isArray(t)?t.forEach(n=>n.dispose()):t.dispose())},Ot=t=>{var n;if(t){for(;t.children.length>0;){const a=t.children[0];a instanceof d.PositionalAudio?(a.pause(),a.parent&&a.parent.remove(a)):Ot(a)}if(t.parent&&t.parent.remove(t),t.isMesh){const a=t;(n=a.geometry)==null||n.dispose(),zt(a.material)}t.dispose!==void 0&&t.dispose()}};class Rn{constructor(n,a,e="editor"){$(this,"channel");$(this,"components",new Map);$(this,"_mode","app");this.editor=a&&document.location.hash.search(e)>-1,a&&(this.channel=new BroadcastChannel(n))}addComponent(n,a){this.components.set(n,a)}dispose(){this.components.forEach(n=>{n.dispose()}),this.components.clear()}send(n){this.channel!==void 0&&this._mode!==n.target&&this.channel.postMessage(n)}listen(n){this.channel!==void 0&&(this.channel.onmessage=a=>{n(a.data)})}get mode(){return this._mode}get editor(){return this._mode==="editor"}set editor(n){n&&(this._mode="editor",document.title+=" - Editor")}}const D=new d.EventDispatcher,A={CUSTOM:"ToolEvents::custom",SELECT_DROPDOWN:"ToolEvents::selectDropdown",DRAG_UPDATE:"ToolEvents::dragUpdate",SET_SCENE:"ToolEvents::setScene",GET_OBJECT:"ToolEvents::getObject",SET_OBJECT:"ToolEvents::setObject",UPDATE_OBJECT:"ToolEvents::updateObject",CREATE_TEXTURE:"ToolEvents::createTexture",REQUEST_METHOD:"ToolEvents::requestMethod",ADD_CAMERA:"ToolEvents::addCamera",REMOVE_CAMERA:"ToolEvents::removeCamera"};class Ke{constructor(n){$(this,"app");this.app=n}dispose(){}}class Pn extends Ke{selectDropdown(n,a){this.app.send({event:"selectComponent",target:"app",data:{dropdown:n,value:a}})}updateDropdown(n,a){this.app.send({event:"draggableListUpdate",target:"app",data:{dropdown:n,value:a}})}}function jn(t,n){switch(n.event){case"selectComponent":D.dispatchEvent({type:A.SELECT_DROPDOWN,value:n.data});break;case"draggableListUpdate":D.dispatchEvent({type:A.DRAG_UPDATE,value:n.data});break}}const Yt=()=>{};class Tt extends Ke{constructor(a,e,r){super(a);$(this,"project");$(this,"sheets");$(this,"sheetObjects");$(this,"sheetObjectCBs");$(this,"sheetObjectUnsubscribe");this.project=Me.getProject(e,r),this.sheets=new Map,this.sheetObjects=new Map,this.sheetObjectCBs=new Map,this.sheetObjectUnsubscribe=new Map}dispose(){this.project=void 0,this.sheets=new Map,this.sheetObjects=new Map,this.sheetObjectCBs=new Map,this.sheetObjectUnsubscribe=new Map}sheet(a){var r;if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}let e=this.sheets.get(a);return e!==void 0||(e=(r=this.project)==null?void 0:r.sheet(a),this.sheets.set(a,e)),e}sheetObject(a,e,r,s){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const u=this.sheets.get(a);if(u===void 0)return;const l=`${a}_${e}`;let f=this.sheetObjects.get(l);if(f!==void 0)return f=u.object(e,{...r,...f.value},{reconfigure:!0}),f;f=u.object(e,r),this.sheetObjects.set(l,f),this.sheetObjectCBs.set(l,s!==void 0?s:Yt);const m=f.onValuesChange(b=>{if(this.app.editor){for(const C in b){const S=b[C];typeof S=="object"&&Bt(S)&&(b[C]={r:S.r,g:S.g,b:S.b,a:S.a})}this.app.send({event:"updateSheetObject",target:"app",data:{sheetObject:l,values:b}})}else{const C=this.sheetObjectCBs.get(l);C!==void 0&&C(b)}});return this.sheetObjectUnsubscribe.set(l,m),f}unsubscribe(a){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const e=`${a.address.sheetId}_${a.address.objectKey}`,r=this.sheetObjectUnsubscribe.get(e);r!==void 0&&r()}}let Se;function _n(t,n){t.components.forEach(a=>{if(a instanceof Tt){let e;const r=a;switch(n.event){case"setSheet":e=r.sheets.get(n.data.sheet),e!==void 0&&(Se=e,We.setSelection([e]));break;case"setSheetObject":e=r.sheetObjects.get(`${n.data.sheet}_${n.data.key}`),e!==void 0&&We.setSelection([e]);break;case"updateSheetObject":e=r.sheetObjectCBs.get(n.data.sheetObject),e!==void 0&&e(n.data.values);break;case"updateTimeline":e=r.sheets.get(n.data.sheet),Se!==void 0&&(Se.sequence.position=n.data.position);break}}})}function kn(t){if(t.editor){let n;t.components.forEach(s=>{s instanceof Tt&&(n=s)}),We.ui.restore(),We.onSelectionChange(s=>{s.length<1||s.forEach(u=>{let l=u.address.sheetId,f="setSheet",m={};switch(u.type){case"Theatre_Sheet_PublicAPI":f="setSheet",m={sheet:u.address.sheetId},Se=n.sheets.get(u.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":f="setSheetObject",l+=`_${u.address.objectKey}`,m={id:l,sheet:u.address.sheetId,key:u.address.objectKey};break}t.send({event:f,target:"app",data:m})})});let a=0;const e=()=>{if(Se!==void 0&&a!==Se.sequence.position){a=Se.sequence.position;const s=Se;t.send({event:"updateTimeline",target:"app",data:{position:a,sheet:s.address.sheetId}})}},r=()=>{e(),requestAnimationFrame(r)};e(),r()}else We.ui.hide()}function Dn(t){if(t.name==="cameras")return"camera";if(t.name==="interactive")return"interactive";if(t.name==="lights")return"light";if(t.name==="ui")return"ui";if(t.name==="utils")return"utils";const n=t.type;return n.search("Helper")>-1?"icon_utils":n.search("Camera")>-1?"camera":n.search("Light")>-1?"light":"obj3D"}function Wt(t){const n={name:t.name,type:t.type,uuid:t.uuid,children:[]};return t.children.forEach(a=>{n.children.push(Wt(a))}),n}function An(t){const n={};for(const a in t){const e=t[a].value;n[a]={value:e},e===null?n[a].value={src:""}:e.isTexture&&(n[a].value={src:e.image.src})}return n}function In(t){switch(t){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function Kt(t){const n={};for(const a in t){if(a.substring(0,1)==="_"||a.substring(0,2)==="is"||In(a))continue;const e=typeof t[a],r=t[a];switch(e){case"boolean":case"number":case"string":n[a]=r;break;case"object":if(r!==null)if(n[a]=r,r.isTexture)if(r instanceof d.Texture){const s=r.source.toJSON();n[a]={src:s.url}}else r instanceof d.CubeTexture&&(console.log("env map"),console.log(r.source.data),console.log(r.source.toJSON()),n[a]={src:""});else a==="uniforms"&&(n[a]=An(n[a]));else n[a]={src:""};break}}return n}function Mt(t){t.updateMatrix();const n={name:t.name,type:t.type,uuid:t.uuid,visible:t.visible,matrix:t.matrix.elements,animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0};t.animations.forEach(e=>{n.animations.push({name:e.name,duration:e.duration,blendMode:e.blendMode})});const a=t.type.toLowerCase();if(a.search("mesh")>-1){const e=t;if(Array.isArray(e.material)){const r=[];e.material.forEach(s=>{r.push(Kt(s))}),n.material=r}else n.material=Kt(e.material)}else a.search("camera")>-1?t.type==="PerspectiveCamera"?n.perspectiveCameraInfo={fov:t.fov,zoom:t.zoom,near:t.near,far:t.far,focus:t.focus,aspect:t.aspect,filmGauge:t.filmGauge,filmOffset:t.filmOffset}:t.type==="OrthographicCamera"&&(n.orthographicCameraInfo={zoom:t.zoom,near:t.near,far:t.far,left:t.left,right:t.right,top:t.top,bottom:t.bottom}):a.search("light")>-1&&(n.lightInfo={color:t.color,intensity:t.intensity,decay:t.decay,distance:t.distance,angle:t.angle,penumbra:t.penumbra,groundColor:t.groundColor});return n}function te(t,n,a){const e=n.split(".");switch(e.length){case 1:t[e[0]]=a;break;case 2:t[e[0]][e[1]]=a;break;case 3:t[e[0]][e[1]][e[2]]=a;break;case 4:t[e[0]][e[1]][e[2]][e[3]]=a;break;case 5:t[e[0]][e[1]][e[2]][e[3]][e[4]]=a;break}}function Rt(t){return new Promise((n,a)=>{const e=new Image;e.onload=()=>{const r=new d.Texture(e);r.wrapS=d.RepeatWrapping,r.wrapT=d.RepeatWrapping,r.needsUpdate=!0,n(r)},e.onerror=a,e.src=t})}class Nn extends Ke{constructor(){super(...arguments);$(this,"scene")}getObject(a){this.app.send({event:"getObject",target:"app",data:a})}setObject(a){const e=Mt(a);this.app.send({event:"setObject",target:"editor",data:e})}requestMethod(a,e,r){this.app.send({event:"requestMethod",target:"app",data:{uuid:a,key:e,value:r}})}updateObject(a,e,r){this.app.send({event:"updateObject",target:"app",data:{uuid:a,key:e,value:r}})}createTexture(a,e,r){this.app.send({event:"createTexture",target:"app",data:{uuid:a,key:e,value:r}})}setScene(a){if(a===void 0)return;this.scene=a,Ht(),xt(this.scene);const e=Wt(this.scene);this.app.send({event:"setScene",target:"editor",data:e})}addCamera(a){const e=Mt(a);this.app.send({event:"addCamera",target:"editor",data:e})}removeCamera(a){const e=Mt(a);this.app.send({event:"removeCamera",target:"editor",data:e})}}function Ln(t,n){switch(n.event){case"getObject":D.dispatchEvent({type:A.GET_OBJECT,value:n.data});break;case"updateObject":D.dispatchEvent({type:A.UPDATE_OBJECT,value:n.data});break;case"createTexture":D.dispatchEvent({type:A.CREATE_TEXTURE,value:n.data});break;case"requestMethod":D.dispatchEvent({type:A.REQUEST_METHOD,value:n.data});break}}function Un(t,n){switch(n.event){case"setObject":D.dispatchEvent({type:A.SET_OBJECT,value:n.data});break;case"setScene":D.dispatchEvent({type:A.SET_SCENE,value:n.data});break;case"addCamera":D.dispatchEvent({type:A.ADD_CAMERA,value:n.data});break;case"removeCamera":D.dispatchEvent({type:A.REMOVE_CAMERA,value:n.data});break}}class Xt extends Ke{constructor(a){super(a);$(this,"bindCBs");$(this,"buttonCBs");$(this,"pane");$(this,"appCallbacks",0);$(this,"editorCallbacks",0);$(this,"inspectorFolder");this.bindCBs=new Map,this.buttonCBs=new Map,a.editor&&this.createGUI()}createGUI(){this.pane=new wn.Pane({title:"GUI"}),this.pane.registerPlugin(xn)}dispose(){var a;this.bindCBs.clear(),this.buttonCBs.clear(),this.appCallbacks=0,this.editorCallbacks=0,this.app.editor&&((a=this.pane)==null||a.dispose(),this.pane=void 0)}addFolder(a,e=void 0,r=void 0){if(this.app.editor)return this.pane===void 0&&this.createGUI(),(r!==void 0?r:this.pane).addFolder({title:a,...e});this.app.send({event:"addFolder",target:"app",data:{name:a,params:e,parent:r}})}get bindID(){return`debug_${Math.max(this.appCallbacks,this.editorCallbacks)}`}bind(a,e,r,s=void 0){const u=this.bindID,l=r.onChange!==void 0?r.onChange:Yt;this.bindCBs.set(u,l),this.app.editor?(this.pane===void 0&&this.createGUI(),(s!==void 0?s:this.pane).addBinding(a,e,r).on("change",m=>{this.app.send({event:"updateBind",target:"app",data:{id:u,value:m.value}})}),this.editorCallbacks++):(this.app.send({event:"bindObject",target:"app",data:{id:u,name:e,params:r,parent:s}}),this.appCallbacks++)}triggerBind(a,e){const r=this.bindCBs.get(a);r!==void 0?r(e):console.warn(`No callback for: ${a}`,e)}button(a,e,r=void 0){const s=this.bindID;this.buttonCBs.set(s,e),this.app.editor?(this.pane===void 0&&this.createGUI(),(r!==void 0?r:this.pane).addButton({title:a}).on("click",()=>{this.app.send({event:"clickButton",target:"app",data:{id:s}})}),this.editorCallbacks++):(this.app.send({event:"addButton",target:"app",data:{id:s,name:a,callback:e,parent:r}}),this.appCallbacks++)}triggerButton(a){const e=this.buttonCBs.get(a);e!==void 0&&e()}createInspector(){this.inspectorFolder=this.addFolder("Inspector",this.pane)}clearInspector(){const a=this.inspectorFolder.children.length-1;for(let e=a;e>-1;--e)this.inspectorFolder.remove(this.inspectorFolder.children[e])}}function Fn(t,n){t.components.forEach(a=>{if(a instanceof Xt){const e=a;switch(n.event){case"addFolder":e.addFolder(n.data.name,n.data.params,n.data.parent);break;case"bindObject":e.bind(n.data.name,n.data.params,n.data.parent);break;case"updateBind":e.triggerBind(n.data.id,n.data.value);break;case"addButton":e.button(n.data.name,n.data.callback,n.data.parent);break;case"clickButton":e.triggerButton(n.data.id);break}return}})}var Pt={exports:{}},Xe={};/**
1
+ (function(w,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("three"),require("@theatre/core"),require("@theatre/studio"),require("tweakpane"),require("@tweakpane/plugin-essentials"),require("react"),require("framer-motion")):typeof define=="function"&&define.amd?define(["exports","three","@theatre/core","@theatre/studio","tweakpane","@tweakpane/plugin-essentials","react","framer-motion"],u):(w=typeof globalThis<"u"?globalThis:w||self,u(w.Hermes={},w.Three,w["Theatre Core"],w["Theatre Studio"],w.tweakpane,w["tweakpane-plugin-essentials"],w.React,w["framer-motion"]))})(this,function(w,u,Me,We,Sn,xn,M,Vt){"use strict";var Ta=Object.defineProperty;var Ma=(w,u,Me)=>u in w?Ta(w,u,{enumerable:!0,configurable:!0,writable:!0,value:Me}):w[u]=Me;var $=(w,u,Me)=>(Ma(w,typeof u!="symbol"?u+"":u,Me),Me);function On(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const e=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(n,a,e.get?e:{enumerable:!0,get:()=>t[a]})}}return n.default=t,Object.freeze(n)}const Tn=On(xn);function Mn(t,n,a){return Math.min(n,Math.max(t,a))}function Rn(t,n){const a=t-n;return Math.sqrt(a*a)}function Bt(){return Math.round(Math.random()*1e6).toString()}function Gt(t){return t.r!==void 0&&t.g!==void 0&&t.b!==void 0}function Ht(t){const n=Math.round(t.r*255),a=Math.round(t.g*255),e=Math.round(t.b*255),r=d=>{const m=d.toString(16);return m.length===1?"0"+m:m},s=r(n),h=r(a),l=r(e);return"#"+s+h+l}function ot(t,n=1){return Number(t.toFixed(n))}w.totalThreeObjects=0;const zt=()=>{w.totalThreeObjects=0},Ot=t=>{if(!t)return;let n=t.name.replace(" ","");n.length===0&&(n=`obj_${w.totalThreeObjects}`,w.totalThreeObjects++),t.parent!==null&&(n=`${t.parent.uuid}.${n}`),t.uuid=n,t.children.forEach(a=>{Ot(a)})},Pn=t=>{t==null||t.dispose()},Yt=t=>{t&&(Array.isArray(t)?t.forEach(n=>n.dispose()):t.dispose())},Tt=t=>{var n;if(t){for(;t.children.length>0;){const a=t.children[0];a instanceof u.PositionalAudio?(a.pause(),a.parent&&a.parent.remove(a)):Tt(a)}if(t.parent&&t.parent.remove(t),t.isMesh){const a=t;(n=a.geometry)==null||n.dispose(),Yt(a.material)}t.dispose!==void 0&&t.dispose()}};class jn{constructor(n,a,e="editor"){$(this,"channel");$(this,"components",new Map);$(this,"_mode","app");this.editor=a&&document.location.hash.search(e)>-1,a&&(this.channel=new BroadcastChannel(n))}addComponent(n,a){this.components.set(n,a)}dispose(){this.components.forEach(n=>{n.dispose()}),this.components.clear()}send(n){this.channel!==void 0&&this._mode!==n.target&&this.channel.postMessage(n)}listen(n){this.channel!==void 0&&(this.channel.onmessage=a=>{n(a.data)})}get mode(){return this._mode}get isApp(){return this._mode==="app"}get editor(){return this._mode==="editor"}set editor(n){n&&(this._mode="editor",document.title+=" - Editor")}}const D=new u.EventDispatcher,A={CUSTOM:"ToolEvents::custom",SELECT_DROPDOWN:"ToolEvents::selectDropdown",DRAG_UPDATE:"ToolEvents::dragUpdate",SET_SCENE:"ToolEvents::setScene",GET_OBJECT:"ToolEvents::getObject",SET_OBJECT:"ToolEvents::setObject",UPDATE_OBJECT:"ToolEvents::updateObject",CREATE_TEXTURE:"ToolEvents::createTexture",REQUEST_METHOD:"ToolEvents::requestMethod",ADD_CAMERA:"ToolEvents::addCamera",REMOVE_CAMERA:"ToolEvents::removeCamera"};class Ke{constructor(n){$(this,"app");this.app=n}dispose(){}}class Wt extends Ke{selectDropdown(n,a){this.app.send({event:"selectComponent",target:"app",data:{dropdown:n,value:a}})}updateDropdown(n,a){this.app.send({event:"draggableListUpdate",target:"app",data:{dropdown:n,value:a}})}}function _n(t,n){switch(n.event){case"selectComponent":D.dispatchEvent({type:A.SELECT_DROPDOWN,value:n.data});break;case"draggableListUpdate":D.dispatchEvent({type:A.DRAG_UPDATE,value:n.data});break}}const Kt=()=>{};class st extends Ke{constructor(){super(...arguments);$(this,"project");$(this,"sheets",new Map);$(this,"sheetObjects",new Map);$(this,"sheetObjectCBs",new Map);$(this,"sheetObjectUnsubscribe",new Map)}init(a,e){this.project=Me.getProject(a,e)}dispose(){this.project=void 0,this.sheets=new Map,this.sheetObjects=new Map,this.sheetObjectCBs=new Map,this.sheetObjectUnsubscribe=new Map}sheet(a){var r;if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}let e=this.sheets.get(a);return e!==void 0||(e=(r=this.project)==null?void 0:r.sheet(a),this.sheets.set(a,e)),e}sheetObject(a,e,r,s){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const h=this.sheets.get(a);if(h===void 0)return;const l=`${a}_${e}`;let d=this.sheetObjects.get(l);if(d!==void 0)return d=h.object(e,{...r,...d.value},{reconfigure:!0}),d;d=h.object(e,r),this.sheetObjects.set(l,d),this.sheetObjectCBs.set(l,s!==void 0?s:Kt);const m=d.onValuesChange(b=>{if(this.app.editor){for(const C in b){const S=b[C];typeof S=="object"&&Gt(S)&&(b[C]={r:S.r,g:S.g,b:S.b,a:S.a})}this.app.send({event:"updateSheetObject",target:"app",data:{sheetObject:l,values:b}})}else{const C=this.sheetObjectCBs.get(l);C!==void 0&&C(b)}});return this.sheetObjectUnsubscribe.set(l,m),d}unsubscribe(a){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const e=`${a.address.sheetId}_${a.address.objectKey}`,r=this.sheetObjectUnsubscribe.get(e);r!==void 0&&r()}}let Se;function kn(t,n){t.components.forEach(a=>{if(a instanceof st){let e;const r=a;switch(n.event){case"setSheet":e=r.sheets.get(n.data.sheet),e!==void 0&&(Se=e,We.setSelection([e]));break;case"setSheetObject":e=r.sheetObjects.get(`${n.data.sheet}_${n.data.key}`),e!==void 0&&We.setSelection([e]);break;case"updateSheetObject":e=r.sheetObjectCBs.get(n.data.sheetObject),e!==void 0&&e(n.data.values);break;case"updateTimeline":e=r.sheets.get(n.data.sheet),Se!==void 0&&(Se.sequence.position=n.data.position);break}}})}function Dn(t){if(t.editor){let n;t.components.forEach(s=>{s instanceof st&&(n=s)}),We.ui.restore(),We.onSelectionChange(s=>{s.length<1||s.forEach(h=>{let l=h.address.sheetId,d="setSheet",m={};switch(h.type){case"Theatre_Sheet_PublicAPI":d="setSheet",m={sheet:h.address.sheetId},Se=n.sheets.get(h.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":d="setSheetObject",l+=`_${h.address.objectKey}`,m={id:l,sheet:h.address.sheetId,key:h.address.objectKey};break}t.send({event:d,target:"app",data:m})})});let a=0;const e=()=>{if(Se!==void 0&&a!==Se.sequence.position){a=Se.sequence.position;const s=Se;t.send({event:"updateTimeline",target:"app",data:{position:a,sheet:s.address.sheetId}})}},r=()=>{e(),requestAnimationFrame(r)};e(),r()}else We.ui.hide()}function An(t){if(t.name==="cameras")return"camera";if(t.name==="interactive")return"interactive";if(t.name==="lights")return"light";if(t.name==="ui")return"ui";if(t.name==="utils")return"utils";const n=t.type;return n.search("Helper")>-1?"icon_utils":n.search("Camera")>-1?"camera":n.search("Light")>-1?"light":"obj3D"}function Xt(t){const n={name:t.name,type:t.type,uuid:t.uuid,children:[]};return t.children.forEach(a=>{n.children.push(Xt(a))}),n}function In(t){const n={};for(const a in t){const e=t[a].value;n[a]={value:e},e===null?n[a].value={src:""}:e.isTexture&&(n[a].value={src:e.image.src})}return n}function Nn(t){switch(t){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function Zt(t){const n={};for(const a in t){if(a.substring(0,1)==="_"||a.substring(0,2)==="is"||Nn(a))continue;const e=typeof t[a],r=t[a];switch(e){case"boolean":case"number":case"string":n[a]=r;break;case"object":if(r!==null)if(n[a]=r,r.isTexture)if(r instanceof u.Texture){const s=r.source.toJSON();n[a]={src:s.url}}else r instanceof u.CubeTexture&&(console.log("env map"),console.log(r.source.data),console.log(r.source.toJSON()),n[a]={src:""});else a==="uniforms"&&(n[a]=In(n[a]));else n[a]={src:""};break}}return n}function Mt(t){t.updateMatrix();const n={name:t.name,type:t.type,uuid:t.uuid,visible:t.visible,matrix:t.matrix.elements,animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0};t.animations.forEach(e=>{n.animations.push({name:e.name,duration:e.duration,blendMode:e.blendMode})});const a=t.type.toLowerCase();if(a.search("mesh")>-1){const e=t;if(Array.isArray(e.material)){const r=[];e.material.forEach(s=>{r.push(Zt(s))}),n.material=r}else n.material=Zt(e.material)}else a.search("camera")>-1?t.type==="PerspectiveCamera"?n.perspectiveCameraInfo={fov:t.fov,zoom:t.zoom,near:t.near,far:t.far,focus:t.focus,aspect:t.aspect,filmGauge:t.filmGauge,filmOffset:t.filmOffset}:t.type==="OrthographicCamera"&&(n.orthographicCameraInfo={zoom:t.zoom,near:t.near,far:t.far,left:t.left,right:t.right,top:t.top,bottom:t.bottom}):a.search("light")>-1&&(n.lightInfo={color:t.color,intensity:t.intensity,decay:t.decay,distance:t.distance,angle:t.angle,penumbra:t.penumbra,groundColor:t.groundColor});return n}function te(t,n,a){const e=n.split(".");switch(e.length){case 1:t[e[0]]=a;break;case 2:t[e[0]][e[1]]=a;break;case 3:t[e[0]][e[1]][e[2]]=a;break;case 4:t[e[0]][e[1]][e[2]][e[3]]=a;break;case 5:t[e[0]][e[1]][e[2]][e[3]][e[4]]=a;break}}function Rt(t){return new Promise((n,a)=>{const e=new Image;e.onload=()=>{const r=new u.Texture(e);r.wrapS=u.RepeatWrapping,r.wrapT=u.RepeatWrapping,r.needsUpdate=!0,n(r)},e.onerror=a,e.src=t})}class Jt extends Ke{constructor(){super(...arguments);$(this,"scene")}getObject(a){this.app.send({event:"getObject",target:"app",data:a})}setObject(a){const e=Mt(a);this.app.send({event:"setObject",target:"editor",data:e})}requestMethod(a,e,r){this.app.send({event:"requestMethod",target:"app",data:{uuid:a,key:e,value:r}})}updateObject(a,e,r){this.app.send({event:"updateObject",target:"app",data:{uuid:a,key:e,value:r}})}createTexture(a,e,r){this.app.send({event:"createTexture",target:"app",data:{uuid:a,key:e,value:r}})}setScene(a){if(a===void 0)return;this.scene=a,zt(),Ot(this.scene);const e=Xt(this.scene);this.app.send({event:"setScene",target:"editor",data:e})}addCamera(a){const e=Mt(a);this.app.send({event:"addCamera",target:"editor",data:e})}removeCamera(a){const e=Mt(a);this.app.send({event:"removeCamera",target:"editor",data:e})}}function Ln(t,n){switch(n.event){case"getObject":D.dispatchEvent({type:A.GET_OBJECT,value:n.data});break;case"updateObject":D.dispatchEvent({type:A.UPDATE_OBJECT,value:n.data});break;case"createTexture":D.dispatchEvent({type:A.CREATE_TEXTURE,value:n.data});break;case"requestMethod":D.dispatchEvent({type:A.REQUEST_METHOD,value:n.data});break}}function Un(t,n){switch(n.event){case"setObject":D.dispatchEvent({type:A.SET_OBJECT,value:n.data});break;case"setScene":D.dispatchEvent({type:A.SET_SCENE,value:n.data});break;case"addCamera":D.dispatchEvent({type:A.ADD_CAMERA,value:n.data});break;case"removeCamera":D.dispatchEvent({type:A.REMOVE_CAMERA,value:n.data});break}}class Pt extends Ke{constructor(a){super(a);$(this,"bindCBs");$(this,"buttonCBs");$(this,"pane");$(this,"appCallbacks",0);$(this,"editorCallbacks",0);$(this,"inspectorFolder");this.bindCBs=new Map,this.buttonCBs=new Map,a.editor&&this.createGUI()}createGUI(){this.pane=new Sn.Pane({title:"GUI"}),this.pane.registerPlugin(Tn)}dispose(){var a;this.bindCBs.clear(),this.buttonCBs.clear(),this.appCallbacks=0,this.editorCallbacks=0,this.app.editor&&((a=this.pane)==null||a.dispose(),this.pane=void 0)}addFolder(a,e=void 0,r=void 0){if(this.app.editor)return this.pane===void 0&&this.createGUI(),(r!==void 0?r:this.pane).addFolder({title:a,...e});this.app.send({event:"addFolder",target:"app",data:{name:a,params:e,parent:r}})}get bindID(){return`debug_${Math.max(this.appCallbacks,this.editorCallbacks)}`}bind(a,e,r,s=void 0){const h=this.bindID,l=r.onChange!==void 0?r.onChange:Kt;this.bindCBs.set(h,l),this.app.editor?(this.pane===void 0&&this.createGUI(),(s!==void 0?s:this.pane).addBinding(a,e,r).on("change",m=>{this.app.send({event:"updateBind",target:"app",data:{id:h,value:m.value}})}),this.editorCallbacks++):(this.app.send({event:"bindObject",target:"app",data:{id:h,name:e,params:r,parent:s}}),this.appCallbacks++)}triggerBind(a,e){const r=this.bindCBs.get(a);r!==void 0?r(e):console.warn(`No callback for: ${a}`,e)}button(a,e,r=void 0){const s=this.bindID;this.buttonCBs.set(s,e),this.app.editor?(this.pane===void 0&&this.createGUI(),(r!==void 0?r:this.pane).addButton({title:a}).on("click",()=>{this.app.send({event:"clickButton",target:"app",data:{id:s}})}),this.editorCallbacks++):(this.app.send({event:"addButton",target:"app",data:{id:s,name:a,callback:e,parent:r}}),this.appCallbacks++)}triggerButton(a){const e=this.buttonCBs.get(a);e!==void 0&&e()}createInspector(){this.inspectorFolder=this.addFolder("Inspector",this.pane)}clearInspector(){const a=this.inspectorFolder.children.length-1;for(let e=a;e>-1;--e)this.inspectorFolder.remove(this.inspectorFolder.children[e])}}function Fn(t,n){t.components.forEach(a=>{if(a instanceof Pt){const e=a;switch(n.event){case"addFolder":e.addFolder(n.data.name,n.data.params,n.data.parent);break;case"bindObject":e.bind(n.data.name,n.data.params,n.data.parent);break;case"updateBind":e.triggerBind(n.data.id,n.data.value);break;case"addButton":e.button(n.data.name,n.data.callback,n.data.parent);break;case"clickButton":e.triggerButton(n.data.id);break}return}})}var jt={exports:{}},Xe={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var Zt;function Vn(){if(Zt)return Xe;Zt=1;var t=M,n=Symbol.for("react.element"),a=Symbol.for("react.fragment"),e=Object.prototype.hasOwnProperty,r=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function u(l,f,m){var b,C={},S=null,_=null;m!==void 0&&(S=""+m),f.key!==void 0&&(S=""+f.key),f.ref!==void 0&&(_=f.ref);for(b in f)e.call(f,b)&&!s.hasOwnProperty(b)&&(C[b]=f[b]);if(l&&l.defaultProps)for(b in f=l.defaultProps,f)C[b]===void 0&&(C[b]=f[b]);return{$$typeof:n,type:l,key:S,ref:_,props:C,_owner:r.current}}return Xe.Fragment=a,Xe.jsx=u,Xe.jsxs=u,Xe}var Ze={};/**
9
+ */var Qt;function Vn(){if(Qt)return Xe;Qt=1;var t=M,n=Symbol.for("react.element"),a=Symbol.for("react.fragment"),e=Object.prototype.hasOwnProperty,r=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function h(l,d,m){var b,C={},S=null,_=null;m!==void 0&&(S=""+m),d.key!==void 0&&(S=""+d.key),d.ref!==void 0&&(_=d.ref);for(b in d)e.call(d,b)&&!s.hasOwnProperty(b)&&(C[b]=d[b]);if(l&&l.defaultProps)for(b in d=l.defaultProps,d)C[b]===void 0&&(C[b]=d[b]);return{$$typeof:n,type:l,key:S,ref:_,props:C,_owner:r.current}}return Xe.Fragment=a,Xe.jsx=h,Xe.jsxs=h,Xe}var Ze={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,19 +14,19 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var Jt;function Bn(){return Jt||(Jt=1,process.env.NODE_ENV!=="production"&&function(){var t=M,n=Symbol.for("react.element"),a=Symbol.for("react.portal"),e=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),l=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),b=Symbol.for("react.suspense_list"),C=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),_=Symbol.for("react.offscreen"),P=Symbol.iterator,K="@@iterator";function ce(i){if(i===null||typeof i!="object")return null;var p=P&&i[P]||i[K];return typeof p=="function"?p:null}var Z=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function O(i){{for(var p=arguments.length,v=new Array(p>1?p-1:0),x=1;x<p;x++)v[x-1]=arguments[x];J("error",i,v)}}function J(i,p,v){{var x=Z.ReactDebugCurrentFrame,I=x.getStackAddendum();I!==""&&(p+="%s",v=v.concat([I]));var V=v.map(function(k){return String(k)});V.unshift("Warning: "+p),Function.prototype.apply.call(console[i],console,V)}}var fe=!1,ue=!1,ae=!1,h=!1,g=!1,y;y=Symbol.for("react.module.reference");function T(i){return!!(typeof i=="string"||typeof i=="function"||i===e||i===s||g||i===r||i===m||i===b||h||i===_||fe||ue||ae||typeof i=="object"&&i!==null&&(i.$$typeof===S||i.$$typeof===C||i.$$typeof===u||i.$$typeof===l||i.$$typeof===f||i.$$typeof===y||i.getModuleId!==void 0))}function H(i,p,v){var x=i.displayName;if(x)return x;var I=p.displayName||p.name||"";return I!==""?v+"("+I+")":v}function z(i){return i.displayName||"Context"}function B(i){if(i==null)return null;if(typeof i.tag=="number"&&O("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case e:return"Fragment";case a:return"Portal";case s:return"Profiler";case r:return"StrictMode";case m:return"Suspense";case b:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case l:var p=i;return z(p)+".Consumer";case u:var v=i;return z(v._context)+".Provider";case f:return H(i,i.render,"ForwardRef");case C:var x=i.displayName||null;return x!==null?x:B(i.type)||"Memo";case S:{var I=i,V=I._payload,k=I._init;try{return B(k(V))}catch{return null}}}return null}var L=Object.assign,G=0,ee,j,U,Q,me,Ae,$e;function ht(){}ht.__reactDisabledLog=!0;function At(){{if(G===0){ee=console.log,j=console.info,U=console.warn,Q=console.error,me=console.group,Ae=console.groupCollapsed,$e=console.groupEnd;var i={configurable:!0,enumerable:!0,value:ht,writable:!0};Object.defineProperties(console,{info:i,log:i,warn:i,error:i,group:i,groupCollapsed:i,groupEnd:i})}G++}}function It(){{if(G--,G===0){var i={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:L({},i,{value:ee}),info:L({},i,{value:j}),warn:L({},i,{value:U}),error:L({},i,{value:Q}),group:L({},i,{value:me}),groupCollapsed:L({},i,{value:Ae}),groupEnd:L({},i,{value:$e})})}G<0&&O("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var et=Z.ReactCurrentDispatcher,tt;function Ie(i,p,v){{if(tt===void 0)try{throw Error()}catch(I){var x=I.stack.trim().match(/\n( *(at )?)/);tt=x&&x[1]||""}return`
18
- `+tt+i}}var Be=!1,Ne;{var Nt=typeof WeakMap=="function"?WeakMap:Map;Ne=new Nt}function pt(i,p){if(!i||Be)return"";{var v=Ne.get(i);if(v!==void 0)return v}var x;Be=!0;var I=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var V;V=et.current,et.current=null,At();try{if(p){var k=function(){throw Error()};if(Object.defineProperty(k.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(k,[])}catch(Ce){x=Ce}Reflect.construct(i,[],k)}else{try{k.call()}catch(Ce){x=Ce}i.call(k.prototype)}}else{try{throw Error()}catch(Ce){x=Ce}i()}}catch(Ce){if(Ce&&x&&typeof Ce.stack=="string"){for(var R=Ce.stack.split(`
17
+ */var qt;function Bn(){return qt||(qt=1,process.env.NODE_ENV!=="production"&&function(){var t=M,n=Symbol.for("react.element"),a=Symbol.for("react.portal"),e=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),h=Symbol.for("react.provider"),l=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),b=Symbol.for("react.suspense_list"),C=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),_=Symbol.for("react.offscreen"),P=Symbol.iterator,K="@@iterator";function ce(i){if(i===null||typeof i!="object")return null;var p=P&&i[P]||i[K];return typeof p=="function"?p:null}var Z=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function O(i){{for(var p=arguments.length,v=new Array(p>1?p-1:0),x=1;x<p;x++)v[x-1]=arguments[x];J("error",i,v)}}function J(i,p,v){{var x=Z.ReactDebugCurrentFrame,I=x.getStackAddendum();I!==""&&(p+="%s",v=v.concat([I]));var V=v.map(function(k){return String(k)});V.unshift("Warning: "+p),Function.prototype.apply.call(console[i],console,V)}}var fe=!1,ue=!1,ae=!1,f=!1,g=!1,y;y=Symbol.for("react.module.reference");function T(i){return!!(typeof i=="string"||typeof i=="function"||i===e||i===s||g||i===r||i===m||i===b||f||i===_||fe||ue||ae||typeof i=="object"&&i!==null&&(i.$$typeof===S||i.$$typeof===C||i.$$typeof===h||i.$$typeof===l||i.$$typeof===d||i.$$typeof===y||i.getModuleId!==void 0))}function H(i,p,v){var x=i.displayName;if(x)return x;var I=p.displayName||p.name||"";return I!==""?v+"("+I+")":v}function z(i){return i.displayName||"Context"}function B(i){if(i==null)return null;if(typeof i.tag=="number"&&O("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case e:return"Fragment";case a:return"Portal";case s:return"Profiler";case r:return"StrictMode";case m:return"Suspense";case b:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case l:var p=i;return z(p)+".Consumer";case h:var v=i;return z(v._context)+".Provider";case d:return H(i,i.render,"ForwardRef");case C:var x=i.displayName||null;return x!==null?x:B(i.type)||"Memo";case S:{var I=i,V=I._payload,k=I._init;try{return B(k(V))}catch{return null}}}return null}var L=Object.assign,G=0,ee,j,U,Q,me,Ae,$e;function pt(){}pt.__reactDisabledLog=!0;function It(){{if(G===0){ee=console.log,j=console.info,U=console.warn,Q=console.error,me=console.group,Ae=console.groupCollapsed,$e=console.groupEnd;var i={configurable:!0,enumerable:!0,value:pt,writable:!0};Object.defineProperties(console,{info:i,log:i,warn:i,error:i,group:i,groupCollapsed:i,groupEnd:i})}G++}}function Nt(){{if(G--,G===0){var i={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:L({},i,{value:ee}),info:L({},i,{value:j}),warn:L({},i,{value:U}),error:L({},i,{value:Q}),group:L({},i,{value:me}),groupCollapsed:L({},i,{value:Ae}),groupEnd:L({},i,{value:$e})})}G<0&&O("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var et=Z.ReactCurrentDispatcher,tt;function Ie(i,p,v){{if(tt===void 0)try{throw Error()}catch(I){var x=I.stack.trim().match(/\n( *(at )?)/);tt=x&&x[1]||""}return`
18
+ `+tt+i}}var Be=!1,Ne;{var Lt=typeof WeakMap=="function"?WeakMap:Map;Ne=new Lt}function mt(i,p){if(!i||Be)return"";{var v=Ne.get(i);if(v!==void 0)return v}var x;Be=!0;var I=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var V;V=et.current,et.current=null,It();try{if(p){var k=function(){throw Error()};if(Object.defineProperty(k.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(k,[])}catch(Ce){x=Ce}Reflect.construct(i,[],k)}else{try{k.call()}catch(Ce){x=Ce}i.call(k.prototype)}}else{try{throw Error()}catch(Ce){x=Ce}i()}}catch(Ce){if(Ce&&x&&typeof Ce.stack=="string"){for(var R=Ce.stack.split(`
19
19
  `),le=x.stack.split(`
20
20
  `),X=R.length-1,q=le.length-1;X>=1&&q>=0&&R[X]!==le[q];)q--;for(;X>=1&&q>=0;X--,q--)if(R[X]!==le[q]){if(X!==1||q!==1)do if(X--,q--,q<0||R[X]!==le[q]){var ge=`
21
- `+R[X].replace(" at new "," at ");return i.displayName&&ge.includes("<anonymous>")&&(ge=ge.replace("<anonymous>",i.displayName)),typeof i=="function"&&Ne.set(i,ge),ge}while(X>=1&&q>=0);break}}}finally{Be=!1,et.current=V,It(),Error.prepareStackTrace=I}var Ye=i?i.displayName||i.name:"",En=Ye?Ie(Ye):"";return typeof i=="function"&&Ne.set(i,En),En}function mt(i,p,v){return pt(i,!1)}function gt(i){var p=i.prototype;return!!(p&&p.isReactComponent)}function Le(i,p,v){if(i==null)return"";if(typeof i=="function")return pt(i,gt(i));if(typeof i=="string")return Ie(i);switch(i){case m:return Ie("Suspense");case b:return Ie("SuspenseList")}if(typeof i=="object")switch(i.$$typeof){case f:return mt(i.render);case C:return Le(i.type,p,v);case S:{var x=i,I=x._payload,V=x._init;try{return Le(V(I),p,v)}catch{}}}return""}var Ge=Object.prototype.hasOwnProperty,vt={},nt=Z.ReactDebugCurrentFrame;function xe(i){if(i){var p=i._owner,v=Le(i.type,i._source,p?p.type:null);nt.setExtraStackFrame(v)}else nt.setExtraStackFrame(null)}function Ue(i,p,v,x,I){{var V=Function.call.bind(Ge);for(var k in i)if(V(i,k)){var R=void 0;try{if(typeof i[k]!="function"){var le=Error((x||"React class")+": "+v+" type `"+k+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof i[k]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw le.name="Invariant Violation",le}R=i[k](p,k,x,v,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(X){R=X}R&&!(R instanceof Error)&&(xe(I),O("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",x||"React class",v,k,typeof R),xe(null)),R instanceof Error&&!(R.message in vt)&&(vt[R.message]=!0,xe(I),O("Failed %s type: %s",v,R.message),xe(null))}}}var Lt=Array.isArray;function at(i){return Lt(i)}function bt(i){{var p=typeof Symbol=="function"&&Symbol.toStringTag,v=p&&i[Symbol.toStringTag]||i.constructor.name||"Object";return v}}function it(i){try{return yt(i),!1}catch{return!0}}function yt(i){return""+i}function Et(i){if(it(i))return O("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",bt(i)),yt(i)}var Oe=Z.ReactCurrentOwner,Ut={key:!0,ref:!0,__self:!0,__source:!0},wt,rt,ve;ve={};function o(i){if(Ge.call(i,"ref")){var p=Object.getOwnPropertyDescriptor(i,"ref").get;if(p&&p.isReactWarning)return!1}return i.ref!==void 0}function E(i){if(Ge.call(i,"key")){var p=Object.getOwnPropertyDescriptor(i,"key").get;if(p&&p.isReactWarning)return!1}return i.key!==void 0}function N(i,p){if(typeof i.ref=="string"&&Oe.current&&p&&Oe.current.stateNode!==p){var v=B(Oe.current.type);ve[v]||(O('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',B(Oe.current.type),i.ref),ve[v]=!0)}}function F(i,p){{var v=function(){wt||(wt=!0,O("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",p))};v.isReactWarning=!0,Object.defineProperty(i,"key",{get:v,configurable:!0})}}function ie(i,p){{var v=function(){rt||(rt=!0,O("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",p))};v.isReactWarning=!0,Object.defineProperty(i,"ref",{get:v,configurable:!0})}}var be=function(i,p,v,x,I,V,k){var R={$$typeof:n,type:i,key:p,ref:v,props:k,_owner:V};return R._store={},Object.defineProperty(R._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(R,"_self",{configurable:!1,enumerable:!1,writable:!1,value:x}),Object.defineProperty(R,"_source",{configurable:!1,enumerable:!1,writable:!1,value:I}),Object.freeze&&(Object.freeze(R.props),Object.freeze(R)),R};function de(i,p,v,x,I){{var V,k={},R=null,le=null;v!==void 0&&(Et(v),R=""+v),E(p)&&(Et(p.key),R=""+p.key),o(p)&&(le=p.ref,N(p,I));for(V in p)Ge.call(p,V)&&!Ut.hasOwnProperty(V)&&(k[V]=p[V]);if(i&&i.defaultProps){var X=i.defaultProps;for(V in X)k[V]===void 0&&(k[V]=X[V])}if(R||le){var q=typeof i=="function"?i.displayName||i.name||"Unknown":i;R&&F(k,q),le&&ie(k,q)}return be(i,R,le,I,x,Oe.current,k)}}var Ct=Z.ReactCurrentOwner,St=Z.ReactDebugCurrentFrame;function we(i){if(i){var p=i._owner,v=Le(i.type,i._source,p?p.type:null);St.setExtraStackFrame(v)}else St.setExtraStackFrame(null)}var he;he=!1;function pe(i){return typeof i=="object"&&i!==null&&i.$$typeof===n}function He(){{if(Ct.current){var i=B(Ct.current.type);if(i)return`
21
+ `+R[X].replace(" at new "," at ");return i.displayName&&ge.includes("<anonymous>")&&(ge=ge.replace("<anonymous>",i.displayName)),typeof i=="function"&&Ne.set(i,ge),ge}while(X>=1&&q>=0);break}}}finally{Be=!1,et.current=V,Nt(),Error.prepareStackTrace=I}var Ye=i?i.displayName||i.name:"",Cn=Ye?Ie(Ye):"";return typeof i=="function"&&Ne.set(i,Cn),Cn}function gt(i,p,v){return mt(i,!1)}function vt(i){var p=i.prototype;return!!(p&&p.isReactComponent)}function Le(i,p,v){if(i==null)return"";if(typeof i=="function")return mt(i,vt(i));if(typeof i=="string")return Ie(i);switch(i){case m:return Ie("Suspense");case b:return Ie("SuspenseList")}if(typeof i=="object")switch(i.$$typeof){case d:return gt(i.render);case C:return Le(i.type,p,v);case S:{var x=i,I=x._payload,V=x._init;try{return Le(V(I),p,v)}catch{}}}return""}var Ge=Object.prototype.hasOwnProperty,bt={},nt=Z.ReactDebugCurrentFrame;function xe(i){if(i){var p=i._owner,v=Le(i.type,i._source,p?p.type:null);nt.setExtraStackFrame(v)}else nt.setExtraStackFrame(null)}function Ue(i,p,v,x,I){{var V=Function.call.bind(Ge);for(var k in i)if(V(i,k)){var R=void 0;try{if(typeof i[k]!="function"){var le=Error((x||"React class")+": "+v+" type `"+k+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof i[k]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw le.name="Invariant Violation",le}R=i[k](p,k,x,v,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(X){R=X}R&&!(R instanceof Error)&&(xe(I),O("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",x||"React class",v,k,typeof R),xe(null)),R instanceof Error&&!(R.message in bt)&&(bt[R.message]=!0,xe(I),O("Failed %s type: %s",v,R.message),xe(null))}}}var Ut=Array.isArray;function at(i){return Ut(i)}function yt(i){{var p=typeof Symbol=="function"&&Symbol.toStringTag,v=p&&i[Symbol.toStringTag]||i.constructor.name||"Object";return v}}function it(i){try{return Et(i),!1}catch{return!0}}function Et(i){return""+i}function wt(i){if(it(i))return O("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",yt(i)),Et(i)}var Oe=Z.ReactCurrentOwner,Ft={key:!0,ref:!0,__self:!0,__source:!0},Ct,rt,ve;ve={};function o(i){if(Ge.call(i,"ref")){var p=Object.getOwnPropertyDescriptor(i,"ref").get;if(p&&p.isReactWarning)return!1}return i.ref!==void 0}function E(i){if(Ge.call(i,"key")){var p=Object.getOwnPropertyDescriptor(i,"key").get;if(p&&p.isReactWarning)return!1}return i.key!==void 0}function N(i,p){if(typeof i.ref=="string"&&Oe.current&&p&&Oe.current.stateNode!==p){var v=B(Oe.current.type);ve[v]||(O('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',B(Oe.current.type),i.ref),ve[v]=!0)}}function F(i,p){{var v=function(){Ct||(Ct=!0,O("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",p))};v.isReactWarning=!0,Object.defineProperty(i,"key",{get:v,configurable:!0})}}function ie(i,p){{var v=function(){rt||(rt=!0,O("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",p))};v.isReactWarning=!0,Object.defineProperty(i,"ref",{get:v,configurable:!0})}}var be=function(i,p,v,x,I,V,k){var R={$$typeof:n,type:i,key:p,ref:v,props:k,_owner:V};return R._store={},Object.defineProperty(R._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(R,"_self",{configurable:!1,enumerable:!1,writable:!1,value:x}),Object.defineProperty(R,"_source",{configurable:!1,enumerable:!1,writable:!1,value:I}),Object.freeze&&(Object.freeze(R.props),Object.freeze(R)),R};function de(i,p,v,x,I){{var V,k={},R=null,le=null;v!==void 0&&(wt(v),R=""+v),E(p)&&(wt(p.key),R=""+p.key),o(p)&&(le=p.ref,N(p,I));for(V in p)Ge.call(p,V)&&!Ft.hasOwnProperty(V)&&(k[V]=p[V]);if(i&&i.defaultProps){var X=i.defaultProps;for(V in X)k[V]===void 0&&(k[V]=X[V])}if(R||le){var q=typeof i=="function"?i.displayName||i.name||"Unknown":i;R&&F(k,q),le&&ie(k,q)}return be(i,R,le,I,x,Oe.current,k)}}var St=Z.ReactCurrentOwner,xt=Z.ReactDebugCurrentFrame;function we(i){if(i){var p=i._owner,v=Le(i.type,i._source,p?p.type:null);xt.setExtraStackFrame(v)}else xt.setExtraStackFrame(null)}var he;he=!1;function pe(i){return typeof i=="object"&&i!==null&&i.$$typeof===n}function He(){{if(St.current){var i=B(St.current.type);if(i)return`
22
22
 
23
23
  Check the render method of \``+i+"`."}return""}}function Fe(i){{if(i!==void 0){var p=i.fileName.replace(/^.*[\\\/]/,""),v=i.lineNumber;return`
24
24
 
25
25
  Check your code at `+p+":"+v+"."}return""}}var Te={};function ze(i){{var p=He();if(!p){var v=typeof i=="string"?i:i.displayName||i.name;v&&(p=`
26
26
 
27
- Check the top-level render call using <`+v+">.")}return p}}function vn(i,p){{if(!i._store||i._store.validated||i.key!=null)return;i._store.validated=!0;var v=ze(p);if(Te[v])return;Te[v]=!0;var x="";i&&i._owner&&i._owner!==Ct.current&&(x=" It was passed a child from "+B(i._owner.type)+"."),we(i),O('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',v,x),we(null)}}function bn(i,p){{if(typeof i!="object")return;if(at(i))for(var v=0;v<i.length;v++){var x=i[v];pe(x)&&vn(x,p)}else if(pe(i))i._store&&(i._store.validated=!0);else if(i){var I=ce(i);if(typeof I=="function"&&I!==i.entries)for(var V=I.call(i),k;!(k=V.next()).done;)pe(k.value)&&vn(k.value,p)}}}function Ea(i){{var p=i.type;if(p==null||typeof p=="string")return;var v;if(typeof p=="function")v=p.propTypes;else if(typeof p=="object"&&(p.$$typeof===f||p.$$typeof===C))v=p.propTypes;else return;if(v){var x=B(p);Ue(v,i.props,"prop",x,i)}else if(p.PropTypes!==void 0&&!he){he=!0;var I=B(p);O("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",I||"Unknown")}typeof p.getDefaultProps=="function"&&!p.getDefaultProps.isReactClassApproved&&O("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function wa(i){{for(var p=Object.keys(i.props),v=0;v<p.length;v++){var x=p[v];if(x!=="children"&&x!=="key"){we(i),O("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",x),we(null);break}}i.ref!==null&&(we(i),O("Invalid attribute `ref` supplied to `React.Fragment`."),we(null))}}function yn(i,p,v,x,I,V){{var k=T(i);if(!k){var R="";(i===void 0||typeof i=="object"&&i!==null&&Object.keys(i).length===0)&&(R+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var le=Fe(I);le?R+=le:R+=He();var X;i===null?X="null":at(i)?X="array":i!==void 0&&i.$$typeof===n?(X="<"+(B(i.type)||"Unknown")+" />",R=" Did you accidentally export a JSX literal instead of a component?"):X=typeof i,O("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",X,R)}var q=de(i,p,v,I,V);if(q==null)return q;if(k){var ge=p.children;if(ge!==void 0)if(x)if(at(ge)){for(var Ye=0;Ye<ge.length;Ye++)bn(ge[Ye],i);Object.freeze&&Object.freeze(ge)}else O("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else bn(ge,i)}return i===e?wa(q):Ea(q),q}}function Ca(i,p,v){return yn(i,p,v,!0)}function Sa(i,p,v){return yn(i,p,v,!1)}var xa=Sa,Oa=Ca;Ze.Fragment=e,Ze.jsx=xa,Ze.jsxs=Oa}()),Ze}process.env.NODE_ENV==="production"?Pt.exports=Vn():Pt.exports=Bn();var c=Pt.exports;function jt(t){return t.title.search("<")>-1?c.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:t.title}}):c.jsx("button",{children:t.title})}const Gn=c.jsxs("svg",{className:"closeIcon",width:"14",height:"14",fill:"none",stroke:"#666666",strokeMiterlimit:"10",children:[c.jsx("circle",{cx:"7",cy:"7",r:"6"}),c.jsx("line",{x1:"4",y1:"4",x2:"10",y2:"10"}),c.jsx("line",{x1:"4",y1:"10",x2:"10",y2:"4"})]}),Hn=c.jsx("svg",{className:"dragIcon",width:"14",height:"14",fill:"#666666",stroke:"none",children:c.jsx("path",{d:`M10.43,4H3.57C3.26,4,3,4.22,3,4.5v1C3,5.78,3.26,6,3.57,6h6.86C10.74,6,11,5.78,11,5.5v-1
27
+ Check the top-level render call using <`+v+">.")}return p}}function yn(i,p){{if(!i._store||i._store.validated||i.key!=null)return;i._store.validated=!0;var v=ze(p);if(Te[v])return;Te[v]=!0;var x="";i&&i._owner&&i._owner!==St.current&&(x=" It was passed a child from "+B(i._owner.type)+"."),we(i),O('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',v,x),we(null)}}function En(i,p){{if(typeof i!="object")return;if(at(i))for(var v=0;v<i.length;v++){var x=i[v];pe(x)&&yn(x,p)}else if(pe(i))i._store&&(i._store.validated=!0);else if(i){var I=ce(i);if(typeof I=="function"&&I!==i.entries)for(var V=I.call(i),k;!(k=V.next()).done;)pe(k.value)&&yn(k.value,p)}}}function Ea(i){{var p=i.type;if(p==null||typeof p=="string")return;var v;if(typeof p=="function")v=p.propTypes;else if(typeof p=="object"&&(p.$$typeof===d||p.$$typeof===C))v=p.propTypes;else return;if(v){var x=B(p);Ue(v,i.props,"prop",x,i)}else if(p.PropTypes!==void 0&&!he){he=!0;var I=B(p);O("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",I||"Unknown")}typeof p.getDefaultProps=="function"&&!p.getDefaultProps.isReactClassApproved&&O("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function wa(i){{for(var p=Object.keys(i.props),v=0;v<p.length;v++){var x=p[v];if(x!=="children"&&x!=="key"){we(i),O("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",x),we(null);break}}i.ref!==null&&(we(i),O("Invalid attribute `ref` supplied to `React.Fragment`."),we(null))}}function wn(i,p,v,x,I,V){{var k=T(i);if(!k){var R="";(i===void 0||typeof i=="object"&&i!==null&&Object.keys(i).length===0)&&(R+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var le=Fe(I);le?R+=le:R+=He();var X;i===null?X="null":at(i)?X="array":i!==void 0&&i.$$typeof===n?(X="<"+(B(i.type)||"Unknown")+" />",R=" Did you accidentally export a JSX literal instead of a component?"):X=typeof i,O("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",X,R)}var q=de(i,p,v,I,V);if(q==null)return q;if(k){var ge=p.children;if(ge!==void 0)if(x)if(at(ge)){for(var Ye=0;Ye<ge.length;Ye++)En(ge[Ye],i);Object.freeze&&Object.freeze(ge)}else O("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else En(ge,i)}return i===e?wa(q):Ea(q),q}}function Ca(i,p,v){return wn(i,p,v,!0)}function Sa(i,p,v){return wn(i,p,v,!1)}var xa=Sa,Oa=Ca;Ze.Fragment=e,Ze.jsx=xa,Ze.jsxs=Oa}()),Ze}process.env.NODE_ENV==="production"?jt.exports=Vn():jt.exports=Bn();var c=jt.exports;function _t(t){return t.title.search("<")>-1?c.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:t.title}}):c.jsx("button",{children:t.title})}const Gn=c.jsxs("svg",{className:"closeIcon",width:"14",height:"14",fill:"none",stroke:"#666666",strokeMiterlimit:"10",children:[c.jsx("circle",{cx:"7",cy:"7",r:"6"}),c.jsx("line",{x1:"4",y1:"4",x2:"10",y2:"10"}),c.jsx("line",{x1:"4",y1:"10",x2:"10",y2:"4"})]}),Hn=c.jsx("svg",{className:"dragIcon",width:"14",height:"14",fill:"#666666",stroke:"none",children:c.jsx("path",{d:`M10.43,4H3.57C3.26,4,3,4.22,3,4.5v1C3,5.78,3.26,6,3.57,6h6.86C10.74,6,11,5.78,11,5.5v-1
28
28
  C11,4.22,10.74,4,10.43,4z M10.43,8H3.57C3.26,8,3,8.22,3,8.5v1C3,9.78,3.26,10,3.57,10h6.86C10.74,10,11,9.78,11,9.5v-1
29
- C11,8.22,10.74,8,10.43,8z`})});function Qt(t){return c.jsx(Ft.Reorder.Item,{value:t.title,children:c.jsxs("div",{children:[Hn,c.jsx("span",{children:t.title}),c.jsx("button",{className:"closeIcon",onClick:()=>{t.onDelete(t.index)},children:Gn})]})},t.title)}function qt(t){const[n,a]=M.useState(!1),[e,r]=M.useState(t.options),s=m=>{t.onDragComplete(m),r(m)},u=m=>{const b=[...e];b.splice(m,1),s(b)},l=[];e.forEach((m,b)=>{l.push(c.jsx(Qt,{index:b,title:m,onDelete:u},m))});let f="dropdown draggable";return t.subdropdown&&(f+=" subdropdown"),c.jsxs("div",{className:f,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[c.jsx(jt,{title:t.title}),c.jsx(Ft.Reorder.Group,{axis:"y",values:e,onReorder:s,style:{visibility:n?"visible":"hidden"},children:l})]})}function $t(t){const[n,a]=M.useState(!1),e=[];t.options.map((s,u)=>{t.onSelect!==void 0&&(s.onSelect=t.onSelect),e.push(c.jsx(en,{option:s},u))});let r="dropdown";return t.subdropdown&&(r+=" subdropdown"),c.jsxs("div",{className:r,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[c.jsx(jt,{title:t.title}),c.jsx("ul",{style:{visibility:n?"visible":"hidden"},children:e})]})}function en(t){const{option:n}=t,[a,e]=M.useState("");let r;switch(n.type){case"draggable":r=c.jsx(qt,{title:n.title,options:n.value,onDragComplete:s=>{n.onDragComplete!==void 0&&n.onDragComplete(s)},subdropdown:!0});break;case"dropdown":r=c.jsx($t,{title:n.title,options:n.value,onSelect:n.onSelect,subdropdown:!0});break;case"option":r=c.jsx("button",{onClick:()=>{n.onSelect!==void 0&&n.onSelect(n.value),n.selectable&&(a!==n.title?e(n.title):e(""))},children:n.title});break}return c.jsx("li",{className:a===n.title?"selected":"",children:r},Vt())}function zn(t,n){const a=[],e=[];n.components&&a.push(jn),n.theatre&&(a.push(_n),kn(t)),n.three&&(a.push(Ln),e.push(Un)),n.tweakpane&&a.push(Fn);function r(u){switch(a.forEach(l=>l(t,u)),u.event){case"custom":D.dispatchEvent({type:A.CUSTOM,value:u.data});break}}function s(u){switch(e.forEach(l=>l(t,u)),u.event){case"custom":D.dispatchEvent({type:A.CUSTOM,value:u.data});break}}t.listen(u=>{t.editor?s(u):r(u)})}const Yn=`out vec3 worldPosition;
29
+ C11,8.22,10.74,8,10.43,8z`})});function $t(t){return c.jsx(Vt.Reorder.Item,{value:t.title,children:c.jsxs("div",{children:[Hn,c.jsx("span",{children:t.title}),c.jsx("button",{className:"closeIcon",onClick:()=>{t.onDelete(t.index)},children:Gn})]})},t.title)}function en(t){const[n,a]=M.useState(!1),[e,r]=M.useState(t.options),s=m=>{t.onDragComplete(m),r(m)},h=m=>{const b=[...e];b.splice(m,1),s(b)},l=[];e.forEach((m,b)=>{l.push(c.jsx($t,{index:b,title:m,onDelete:h},m))});let d="dropdown draggable";return t.subdropdown&&(d+=" subdropdown"),c.jsxs("div",{className:d,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[c.jsx(_t,{title:t.title}),c.jsx(Vt.Reorder.Group,{axis:"y",values:e,onReorder:s,style:{visibility:n?"visible":"hidden"},children:l})]})}function tn(t){const[n,a]=M.useState(!1),e=[];t.options.map((s,h)=>{t.onSelect!==void 0&&(s.onSelect=t.onSelect),e.push(c.jsx(nn,{option:s},h))});let r="dropdown";return t.subdropdown&&(r+=" subdropdown"),c.jsxs("div",{className:r,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[c.jsx(_t,{title:t.title}),c.jsx("ul",{style:{visibility:n?"visible":"hidden"},children:e})]})}function nn(t){const{option:n}=t,[a,e]=M.useState("");let r;switch(n.type){case"draggable":r=c.jsx(en,{title:n.title,options:n.value,onDragComplete:s=>{n.onDragComplete!==void 0&&n.onDragComplete(s)},subdropdown:!0});break;case"dropdown":r=c.jsx(tn,{title:n.title,options:n.value,onSelect:n.onSelect,subdropdown:!0});break;case"option":r=c.jsx("button",{onClick:()=>{n.onSelect!==void 0&&n.onSelect(n.value),n.selectable&&(a!==n.title?e(n.title):e(""))},children:n.title});break}return c.jsx("li",{className:a===n.title?"selected":"",children:r},Bt())}function zn(t){const n=[],a=[];t.components.forEach(s=>{s instanceof Wt?n.push(_n):s instanceof st?(n.push(kn),Dn(t)):s instanceof Jt?(n.push(Ln),a.push(Un)):s instanceof Pt&&n.push(Fn)});function e(s){switch(n.forEach(h=>h(t,s)),s.event){case"custom":D.dispatchEvent({type:A.CUSTOM,value:s.data});break}}function r(s){switch(a.forEach(h=>h(t,s)),s.event){case"custom":D.dispatchEvent({type:A.CUSTOM,value:s.data});break}}t.listen(s=>{t.editor?r(s):e(s)})}const Yn=`out vec3 worldPosition;
30
30
  uniform float uDistance;
31
31
 
32
32
  void main() {
@@ -102,7 +102,7 @@ void main() {
102
102
  fragColor.a = mix(fragColor.a, baseOpacity * uGridOpacity, nextGrid);
103
103
 
104
104
  if (fragColor.a <= 0.0) discard;
105
- }`;class Kn extends d.ShaderMaterial{constructor(n){super({extensions:{derivatives:!0},glslVersion:d.GLSL3,side:d.DoubleSide,transparent:!0,uniforms:{uScale:{value:(n==null?void 0:n.scale)!==void 0?n==null?void 0:n.scale:.1},uDivisions:{value:(n==null?void 0:n.divisions)!==void 0?n==null?void 0:n.divisions:10},uColor:{value:(n==null?void 0:n.color)!==void 0?n==null?void 0:n.color:new d.Color(16777215)},uDistance:{value:(n==null?void 0:n.distance)!==void 0?n==null?void 0:n.distance:1e4},uSubgridOpacity:{value:(n==null?void 0:n.subgridOpacity)!==void 0?n==null?void 0:n.subgridOpacity:.15},uGridOpacity:{value:(n==null?void 0:n.gridOpacity)!==void 0?n==null?void 0:n.gridOpacity:.25}},vertexShader:Yn,fragmentShader:Wn,name:"InfiniteGrid",depthWrite:!1})}}class tn extends d.Mesh{constructor(){const a=new Kn;super(new d.PlaneGeometry(2,2),a);$(this,"gridMaterial");this.gridMaterial=a,this.frustumCulled=!1,this.name="InfiniteGridHelper",this.position.y=.1}update(){this.gridMaterial.needsUpdate=!0}}const Xn=`#include <common>
105
+ }`;class Kn extends u.ShaderMaterial{constructor(n){super({extensions:{derivatives:!0},glslVersion:u.GLSL3,side:u.DoubleSide,transparent:!0,uniforms:{uScale:{value:(n==null?void 0:n.scale)!==void 0?n==null?void 0:n.scale:.1},uDivisions:{value:(n==null?void 0:n.divisions)!==void 0?n==null?void 0:n.divisions:10},uColor:{value:(n==null?void 0:n.color)!==void 0?n==null?void 0:n.color:new u.Color(16777215)},uDistance:{value:(n==null?void 0:n.distance)!==void 0?n==null?void 0:n.distance:1e4},uSubgridOpacity:{value:(n==null?void 0:n.subgridOpacity)!==void 0?n==null?void 0:n.subgridOpacity:.15},uGridOpacity:{value:(n==null?void 0:n.gridOpacity)!==void 0?n==null?void 0:n.gridOpacity:.25}},vertexShader:Yn,fragmentShader:Wn,name:"InfiniteGrid",depthWrite:!1})}}class an extends u.Mesh{constructor(){const a=new Kn;super(new u.PlaneGeometry(2,2),a);$(this,"gridMaterial");this.gridMaterial=a,this.frustumCulled=!1,this.name="InfiniteGridHelper",this.position.y=.1}update(){this.gridMaterial.needsUpdate=!0}}const Xn=`#include <common>
106
106
  #include <batching_pars_vertex>
107
107
  #include <uv_pars_vertex>
108
108
  #include <color_pars_vertex>
@@ -140,5 +140,5 @@ void main() {
140
140
  void main() {
141
141
  #include <clipping_planes_fragment>
142
142
  gl_FragColor = vec4(vec3(vUv, 0.0), 1.0);
143
- }`;class nn extends d.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:Xn,fragmentShader:Zn})}}const Ra="";function st(t){const[n,a]=M.useState(t.open!==void 0?t.open:!0),e=!n||t.children===void 0;return c.jsxs("div",{className:`accordion ${e?"hide":""}`,children:[c.jsxs("button",{className:"toggle",onClick:()=>{const r=!n;t.onToggle!==void 0&&t.onToggle(r),a(r)},children:[c.jsx("p",{className:`status ${n?"open":""}`,children:"Toggle"}),c.jsx("p",{className:"label",children:t.label})]}),t.button,c.jsx("div",{className:n?"open":"",children:c.jsx("div",{children:t.children})})]})}function _t(t){const[n,a]=M.useState(!1),e=t.child.children.length>0,r=[];return t.child.children.length>0&&t.child.children.map(s=>{r.push(c.jsx(_t,{child:s,three:t.three},Math.random()))}),c.jsxs("div",{className:"childObject",children:[c.jsxs("div",{className:"child",children:[e?c.jsx("button",{className:"status",style:{backgroundPositionX:n?"-14px":"2px"},onClick:()=>{a(!n)}}):null,c.jsx("button",{className:"name",style:{left:e?"20px":"5px"},onClick:()=>{t.three.getObject(t.child.uuid)},children:t.child.name.length>0?`${t.child.name} (${t.child.type})`:`${t.child.type}::${t.child.uuid}`}),c.jsx("div",{className:`icon ${Dn(t.child)}`})]}),c.jsx("div",{className:n?"open":"",children:c.jsx("div",{className:"container",children:r})})]},Math.random())}function an(t){const n=[];return t.child.children.map(a=>{n.push(c.jsx(_t,{child:a,three:t.three},Math.random()))}),c.jsx("div",{className:`scene ${t.class!==void 0?t.class:""}`,children:n})}const Pa="",Jn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA5klEQVRoge2Y0Q6EIAwE6cX//+X6cCFpSMEKVTdk501OpRNKiyelFC0b8Ps6gCwoggZF0KAIGhRBgyJoUAQNiqCxjciR9SLV//eZiAyvK3U8i/QVaQO2YyLSFVvlkdTKDjJCukh2ykR5ZEW+kHmlatl90RaBtDkK/w7CYhuRUEO0ee3l+J3m55Vm+17vtwjTnV1V3QA8qfbeUXCzRWDpiLLS+OyzvRW7IzW9R+okvclsqR09743bo0yUpc1+lSJvNsa002+Euk9GKzV7SmZDRIMiaFAEDYqgQRE0KIIGRdCgCBoUQeMEMERadX7YUz8AAAAASUVORK5CYII=";function Qn(t){return"items"in t}function Re(t){const n=[];return t.items.forEach(a=>{Qn(a)?n.push(c.jsx(Re,{title:a.title,items:a.items},Math.random())):n.push(c.jsx(Je,{title:a.title,prop:a.prop,value:a.value,type:a.type,min:a.min,max:a.max,step:a.step,disabled:a.disabled,onChange:(e,r)=>{a.onChange!==void 0&&a.onChange(e,r)}},Math.random()))}),c.jsx(st,{label:t.title,open:t.expanded===!0,children:n})}function qn(t){return!(t==="alphaHash"||t==="alphaToCoverage"||t==="attenuationDistance"||t==="colorWrite"||t==="combine"||t==="defaultAttributeValues"||t==="depthFunc"||t==="forceSinglePass"||t==="glslVersion"||t==="linewidth"||t==="normalMapType"||t==="precision"||t==="premultipliedAlpha"||t==="shadowSide"||t==="side"||t==="toneMapped"||t==="uniformsGroups"||t==="uniformsNeedUpdate"||t==="userData"||t==="vertexColors"||t==="version"||t==="wireframeLinecap"||t==="wireframeLinejoin"||t==="wireframeLinewidth"||t.slice(0,5)==="blend"||t.slice(0,4)==="clip"||t.slice(0,7)==="polygon"||t.slice(0,7)==="stencil"||t.slice(0,2)==="is")}function Pe(t){switch(t){case"alphaMap":return"Alpha Map";case"anisotropyMap":return"Anisotropy Map";case"anisotropyRotation":return"Anisotropy Rotation";case"aoMap":return"AO Map";case"aoMapIntensity":return"AO Map Intensity";case"attenuationColor":return"Attenuation Color";case"bumpMap":return"Bump Map";case"bumpScale":return"Bump Scale";case"clearcoatMap":return"Clearcoat Map";case"clearcoatNormalMap":return"Clearcoat Normal Map";case"clearcoatNormalScale":return"Clearcoat Normal Scale";case"clearcoatRoughness":return"Clearcoat Roughness";case"clearcoatRoughnessMap":return"Clearcoat Roughness Map";case"color":return"Color";case"defines":return"Defines";case"depthTest":return"Depth Test";case"depthWrite":return"Depth Write";case"displacementBias":return"Displacement Bias";case"displacementMap":return"Displacement Map";case"displacementScale":return"Displacement Scale";case"dithering":return"Dithering";case"emissive":return"Emissive";case"emissiveMap":return"Emissive Map";case"emissiveIntensity":return"Emissive Intensity";case"envMap":return"Environment Map";case"envMapIntensity":return"Environment Map Intensity";case"extensions":return"Extensions";case"flatShading":return"Flat Shading";case"fragmentShader":return"Fragment Shader";case"fog":return"Fog";case"gradientMap":return"Gradient Map";case"ior":return"IOR";case"iridescenceIOR":return"Iridescence IOR";case"iridescenceMap":return"Iridescence Map";case"iridescenceThicknessMap":return"Iridescence Thickness Map";case"iridescenceThicknessRange":return"Iridescence Thickness Range";case"lights":return"Lights";case"lightMap":return"Light Map";case"lightMapIntensity":return"Light Map Intensity";case"map":return"Map";case"matcap":return"Matcap";case"metalness":return"Metalness";case"metalnessMap":return"Metalness Map";case"name":return"Name";case"normalMap":return"Normal Map";case"normalScale":return"Normal Scale";case"opacity":return"Opacity";case"reflectivity":return"Reflectivity";case"refractionRatio":return"Refraction Ratio";case"roughness":return"Roughness";case"roughnessMap":return"Roughness Map";case"sheenColor":return"Sheen Color";case"sheenColorMap":return"Sheen Color Map";case"sheenRoughness":return"Sheen Roughness";case"sheenRoughnessMap":return"Sheen Roughness Map";case"shininess":return"Shininess";case"specular":return"Specular";case"specularColor":return"Specular Color";case"specularColorMap":return"Specular Color Map";case"specularIntensity":return"Specular Intensity";case"specularIntensityMap":return"Specular Map Intensity";case"thickness":return"Thickness";case"thicknessMap":return"Thickness Map";case"transmission":return"Transmission";case"transmissionMap":return"Transmission Map";case"transparent":return"Transparent";case"type":return"Type";case"uuid":return"UUID";case"uniforms":return"Uniforms";case"vertexShader":return"Vertex Shader";case"visible":return"Visible";case"wireframe":return"Wireframe"}return t}function $n(t){return t.toLowerCase().search("intensity")>-1||t==="anisotropyRotation"||t==="bumpScale"||t==="clearcoatRoughness"||t==="displacementBias"||t==="displacementScale"||t==="metalness"||t==="opacity"||t==="reflectivity"||t==="refractionRatio"||t==="roughness"||t==="sheenRoughness"||t==="thickness"}function ea(){const t=document.createElement("input");return t.type="file",new Promise((n,a)=>{t.addEventListener("change",function(){if(t.files===null)a();else{const e=t.files[0],r=new FileReader;r.onload=function(s){n(s.target.result)},r.readAsDataURL(e)}}),t.click()})}function rn(t,n,a){const e=[];for(const r in t){if(!qn(r))continue;const s=typeof t[r],u=t[r];if(s==="boolean"||s==="number"||s==="string"){const l={title:Pe(r),prop:r,type:s,value:u,min:void 0,max:void 0,onChange:(f,m)=>{var C;a.updateObject(n.uuid,`material.${f}`,m),s==="boolean"&&a.updateObject(n.uuid,"material.needsUpdate",!0);const b=(C=a.scene)==null?void 0:C.getObjectByProperty("uuid",n.uuid);b!==void 0&&te(b,`material.${f}`,m)}};$n(r)&&(l.value=Number(u),l.type="range",l.min=0,l.max=1,l.step=.01),e.push(l)}else if(s==="object")if(u.isColor)e.push({title:Pe(r),prop:r,type:"color",value:u,onChange:(l,f)=>{var C;const m=new d.Color(f);a.updateObject(n.uuid,`material.${l}`,m);const b=(C=a.scene)==null?void 0:C.getObjectByProperty("uuid",n.uuid);b!==void 0&&te(b,`material.${l}`,m)}});else if(Array.isArray(u)){const l=[];for(const f in u)l.push({title:`${f}`,type:`${typeof u[f]}`,value:u[f],onChange:(m,b)=>{var S;a.updateObject(n.uuid,`material.${r}`,b);const C=(S=a.scene)==null?void 0:S.getObjectByProperty("uuid",n.uuid);C!==void 0&&te(C,`material.${r}`,b)}});e.push({title:Pe(r),items:l})}else{const l=[];for(const f in u){const m=u[f];switch(typeof m){case"boolean":case"number":case"string":f==="src"?e.push({title:Pe(r),type:"image",value:m,onChange:(C,S)=>{var P;a.createTexture(n.uuid,`material.${r}`,S);const _=(P=a.scene)==null?void 0:P.getObjectByProperty("uuid",n.uuid);_!==void 0&&Rt(S).then(K=>{te(_,`material.${r}`,K),te(_,"material.needsUpdate",!0)})}}):l.push({title:`${Pe(f)}`,prop:`material.${r}.${f}`,type:`${typeof t[r][f]}`,value:u[f],onChange:(C,S)=>{var P;a.updateObject(n.uuid,`material.${r}.${f}`,S);const _=(P=a.scene)==null?void 0:P.getObjectByProperty("uuid",n.uuid);_!==void 0&&te(_,`material.${r}.${f}`,S)}});break;case"object":m.value!==void 0&&m.value.src!==void 0?l.push({title:Pe(f),type:"image",value:m.value.src,onChange:(C,S)=>{var P;a.createTexture(n.uuid,`material.${r}.${f}.value`,S);const _=(P=a.scene)==null?void 0:P.getObjectByProperty("uuid",n.uuid);_!==void 0&&Rt(S).then(K=>{te(_,`material.${r}.${f}.value`,K)})}}):l.push({title:f,type:`${typeof m.value}`,value:m.value,onChange:(C,S)=>{var P;a.updateObject(n.uuid,`material.${r}.${f}.value`,S);const _=(P=a.scene)==null?void 0:P.getObjectByProperty("uuid",n.uuid);_!==void 0&&te(_,`material.${r}.${f}.value`,S)}});break}}l.length>0&&e.push({title:Pe(r),items:l})}else u!==void 0&&console.log("other:",r,s,u)}return e.sort((r,s)=>r.title<s.title?-1:r.title>s.title?1:0),e.push({title:"Update Material",type:"button",onChange:()=>{a.updateObject(n.uuid,"material.needsUpdate",!0)}}),e}function ta(t,n){const a=t.material;if(Array.isArray(a)){const e=[],r=a.length;for(let s=0;s<r;s++)e.push(c.jsx(Re,{title:`Material ${s}`,items:rn(a[s],t,n)},`Material ${s}`));return c.jsx(c.Fragment,{children:e})}else return c.jsx(Re,{title:"Material",items:rn(a,t,n)})}function Je(t){let n=t.value;n!==void 0&&n.isColor!==void 0&&(n=Gt(t.value));const[a,e]=M.useState(n),r=M.useRef(null),s=M.useRef(null),u=M.useRef(null);M.useEffect(()=>{var J;let b=!1,C=-1,S=0,_=Number(a);const P=fe=>{b=!0,S=_,C=fe.clientX},K=fe=>{if(!b)return;const ue=t.step!==void 0?t.step:1,ae=(fe.clientX-C)*ue;_=Number((S+ae).toFixed(4)),s.current!==null&&(s.current.value=_.toString()),t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,_)},ce=()=>{b=!1},Z=()=>{b=!1},O=t.type==="number";return O&&((J=r.current)==null||J.addEventListener("mousedown",P,!1),document.addEventListener("mouseup",ce,!1),document.addEventListener("mousemove",K,!1),document.addEventListener("contextmenu",Z,!1)),()=>{var fe;O&&((fe=r.current)==null||fe.removeEventListener("mousedown",P),document.removeEventListener("mouseup",ce),document.removeEventListener("mousemove",K),document.removeEventListener("contextmenu",Z))}},[a]);const l=t.type==="string"&&(a.length>100||a.search(`
144
- `)>-1),f=l||t.type==="image",m=b=>{let C=b.target.value;t.type==="boolean"&&(C=b.target.checked),e(C),t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,C)};return c.jsxs("div",{className:`field ${f?"block":""}`,children:[t.type!=="button"&&c.jsx("label",{ref:r,children:t.title},"fieldLabel"),t.type==="string"&&!l&&c.jsx("input",{type:"text",disabled:t.disabled,onChange:m,value:a}),t.type==="string"&&l&&c.jsx("textarea",{cols:50,rows:10,disabled:!0,onChange:m,value:a}),t.type==="boolean"&&c.jsx("input",{type:"checkbox",disabled:t.disabled,onChange:m,checked:a}),t.type==="number"&&c.jsx("input",{ref:s,type:"number",value:a,min:t.min,max:t.max,step:t.step,onChange:m}),t.type==="range"&&c.jsxs(c.Fragment,{children:[c.jsx("input",{type:"text",value:a.toString(),onChange:m,className:"min"}),c.jsx("input",{disabled:t.disabled,type:"range",value:a,min:t.min,max:t.max,step:t.step,onChange:m})]}),t.type==="color"&&c.jsxs(c.Fragment,{children:[c.jsx("input",{type:"text",value:a.toString(),onChange:m,className:"color"}),c.jsx("input",{type:"color",value:a,onChange:m})]}),t.type==="button"&&c.jsx("button",{onClick:()=>{t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,!0)},children:t.title}),t.type==="image"&&c.jsx("img",{ref:u,onClick:()=>{ea().then(b=>{u.current.src=b,t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,b)})},src:a.length>0?a:Jn})]})}function on(t){switch(t){case"fov":return"FOV";case"zoom":return"Zoom";case"near":return"Near";case"far":return"Far";case"focus":return"Focus";case"aspect":return"Aspect";case"filmGauge":return"Film Gauge";case"filmOffset":return"Film Offset";case"left":return"Left";case"right":return"Right";case"top":return"Top";case"bottom":return"Bottom"}return t}function na(t,n){const a=[];if(t.perspectiveCameraInfo!==void 0)for(const e in t.perspectiveCameraInfo)a.push({title:on(e),prop:e,type:"number",step:.01,value:t.perspectiveCameraInfo[e],onChange:(r,s)=>{var l;n.updateObject(t.uuid,r,s),n.requestMethod(t.uuid,"updateProjectionMatrix");const u=(l=n.scene)==null?void 0:l.getObjectByProperty("uuid",t.uuid);u!==void 0&&(te(u,r,s),u.updateProjectionMatrix())}});else if(t.orthographicCameraInfo!==void 0)for(const e in t.orthographicCameraInfo)a.push({title:on(e),prop:e,type:"number",step:.01,value:t.perspectiveCameraInfo[e],onChange:(r,s)=>{var l;n.updateObject(t.uuid,r,s),n.requestMethod(t.uuid,"updateProjectionMatrix");const u=(l=n.scene)==null?void 0:l.getObjectByProperty("uuid",t.uuid);u!==void 0&&(te(u,r,s),u.updateProjectionMatrix())}});return c.jsx(Re,{title:"Camera",items:a})}const aa=Math.PI/180,ia=180/Math.PI;function Ve(t,n,a,e,r){return e+(t-n)*(r-e)/(a-n)}function ra(t){return t*aa}function kt(t){return t*ia}function oa(t,n){const a=new d.Matrix4;a.elements=t.matrix;const e=new d.Vector3,r=new d.Euler,s=new d.Vector3;t.uuid.length>0&&(e.setFromMatrixPosition(a),r.setFromRotationMatrix(a),s.setFromMatrixScale(a));const u=(f,m)=>{var C;n.updateObject(t.uuid,f,m);const b=(C=n.scene)==null?void 0:C.getObjectByProperty("uuid",t.uuid);b!==void 0&&te(b,f,m)},l=(f,m)=>{u(f,ra(m))};return c.jsx(Re,{title:"Transform",items:[{title:"Position X",prop:"position.x",type:"number",value:e.x,onChange:u},{title:"Position Y",prop:"position.y",type:"number",value:e.y,onChange:u},{title:"Position Z",prop:"position.z",type:"number",value:e.z,onChange:u},{title:"Rotation X",prop:"rotation.x",type:"number",value:ot(kt(r.x)),min:-360,max:360,step:.1,onChange:l},{title:"Rotation Y",prop:"rotation.y",type:"number",value:ot(kt(r.y)),min:-360,max:360,step:.1,onChange:l},{title:"Rotation Z",prop:"rotation.z",type:"number",value:ot(kt(r.z)),min:-360,max:360,step:.1,onChange:l},{title:"Scale X",prop:"scale.x",type:"number",value:s.x,step:.01,onChange:u},{title:"Scale Y",prop:"scale.y",type:"number",value:s.y,step:.01,onChange:u},{title:"Scale Z",prop:"scale.z",type:"number",value:s.z,step:.01,onChange:u}]})}function sn(t){switch(t){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"}return t}function sa(t,n){const a=[];if(t.lightInfo!==void 0)for(const e in t.lightInfo){const r=t.lightInfo[e];r!==void 0&&(r.isColor!==void 0?a.push({title:sn(e),prop:e,type:"color",value:r,onChange:(s,u)=>{var m;const l=new d.Color(u);n.updateObject(t.uuid,s,l);const f=(m=n.scene)==null?void 0:m.getObjectByProperty("uuid",t.uuid);f!==void 0&&te(f,s,l)}}):a.push({title:sn(e),prop:e,type:typeof r,value:r,step:typeof r=="number"?.01:void 0,onChange:(s,u)=>{var f;n.updateObject(t.uuid,s,u);const l=(f=n.scene)==null?void 0:f.getObjectByProperty("uuid",t.uuid);l!==void 0&&te(l,s,u)}}))}return c.jsx(Re,{title:"Light",items:a})}function ca(t,n){const a=[];return t.animations.forEach(e=>{a.push({title:"Name",type:"string",prop:"name",value:e.name,disabled:!0,onChange:(r,s)=>{var l;n.updateObject(t.uuid,r,s);const u=(l=n.scene)==null?void 0:l.getObjectByProperty("uuid",t.uuid);u!==void 0&&te(u,r,s)}}),a.push({title:"Duration",type:"number",prop:"duration",value:e.duration,disabled:!0,onChange:(r,s)=>{var l;n.updateObject(t.uuid,r,s);const u=(l=n.scene)==null?void 0:l.getObjectByProperty("uuid",t.uuid);u!==void 0&&te(u,r,s)}}),a.push({title:"Blend Mode",type:"number",prop:"blendMode",value:e.blendMode,disabled:!0,onChange:(r,s)=>{var l;n.updateObject(t.uuid,r,s);const u=(l=n.scene)==null?void 0:l.getObjectByProperty("uuid",t.uuid);u!==void 0&&te(u,r,s)}})}),c.jsx(Re,{title:"Animations",items:a})}const cn={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};let re={...cn};function ln(t){const[n,a]=M.useState(-1);M.useEffect(()=>{function r(u){re={...u.value},a(Date.now())}function s(){re={...cn},a(Date.now())}return D.addEventListener(A.SET_SCENE,s),D.addEventListener(A.SET_OBJECT,r),()=>{D.removeEventListener(A.SET_SCENE,s),D.removeEventListener(A.SET_OBJECT,r)}},[]);const e=re.type.toLowerCase();return c.jsx(st,{label:"Inspector",children:c.jsx("div",{id:"Inspector",className:t.class,children:re.uuid.length>0&&c.jsxs(c.Fragment,{children:[c.jsxs(c.Fragment,{children:[c.jsx(Je,{type:"string",title:"Name",prop:"name",value:re.name,disabled:!0}),c.jsx(Je,{type:"string",title:"Type",prop:"type",value:re.type,disabled:!0}),c.jsx(Je,{type:"string",title:"UUID",prop:"uuid",value:re.uuid,disabled:!0}),c.jsx(Je,{type:"boolean",title:"Visible",prop:"visible",value:re.visible,onChange:(r,s)=>{var l;t.three.updateObject(re.uuid,r,s);const u=(l=t.three.scene)==null?void 0:l.getObjectByProperty("uuid",re.uuid);u!==void 0&&te(u,r,s)}})]}),c.jsxs(c.Fragment,{children:[oa(re,t.three),re.animations.length>0?ca(re,t.three):null,e.search("camera")>-1?na(re,t.three):null,e.search("light")>-1?sa(re,t.three):null,e.search("mesh")>-1?ta(re,t.three):null]})]})},n)},"Inspector")}class la extends M.Component{constructor(a){super(a);$(this,"three");$(this,"setScene",a=>{this.setState(()=>({scene:a.value}))});this.state={scene:a.scene!==void 0?a.scene:null},this.three=a.three,D.addEventListener(A.SET_SCENE,this.setScene)}componentWillUnmount(){D.removeEventListener(A.SET_SCENE,this.setScene)}render(){var r;const a=this.componentState.scene!==null,e="Hierarchy - "+(a?`${(r=this.componentState.scene)==null?void 0:r.name}`:"No Scene");return c.jsx("div",{id:"SidePanel",children:c.jsxs(c.Fragment,{children:[c.jsx(st,{label:e,open:!0,children:c.jsx(c.Fragment,{children:a&&c.jsx(an,{child:this.componentState.scene,three:this.three})})}),c.jsx(ln,{three:this.three})]})},"SidePanel")}get componentState(){return this.state}}function ua(t){function n(){return t.three.scene===void 0?(console.log("No scene:",t.three),!1):!0}const a=l=>{var m;if(!n())return;const f=(m=t.three.scene)==null?void 0:m.getObjectByProperty("uuid",l.value);f!==void 0&&t.three.setObject(f)},e=(l,f,m)=>{var C;if(!n())return;const b=(C=t.three.scene)==null?void 0:C.getObjectByProperty("uuid",l);b!==void 0&&te(b,f,m)},r=l=>{if(!n())return;const f=l.value,{key:m,value:b,uuid:C}=f;e(C,m,b)},s=l=>{if(!n())return;const f=l.value;Rt(f.value).then(m=>{e(f.uuid,f.key,m),e(f.uuid,"material.needsUpdate",!0)})},u=l=>{var S;if(!n())return;const{key:f,uuid:m,value:b}=l.value,C=(S=t.three.scene)==null?void 0:S.getObjectByProperty("uuid",m);if(C!==void 0)try{C[f](b)}catch(_){console.log("Error requesting method:"),console.log(_),console.log(f),console.log(b)}};return M.useEffect(()=>(D.addEventListener(A.GET_OBJECT,a),D.addEventListener(A.UPDATE_OBJECT,r),D.addEventListener(A.CREATE_TEXTURE,s),D.addEventListener(A.REQUEST_METHOD,u),()=>{D.removeEventListener(A.GET_OBJECT,a),D.removeEventListener(A.UPDATE_OBJECT,r),D.removeEventListener(A.CREATE_TEXTURE,s),D.removeEventListener(A.REQUEST_METHOD,u)}),[]),null}const un={type:"change"},Dt={type:"start"},dn={type:"end"},ct=new d.Ray,fn=new d.Plane,da=Math.cos(70*d.MathUtils.DEG2RAD);class fa extends d.EventDispatcher{constructor(n,a){super(),this.object=n,this.domElement=a,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new d.Vector3,this.cursor=new d.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:d.MOUSE.ROTATE,MIDDLE:d.MOUSE.DOLLY,RIGHT:d.MOUSE.PAN},this.touches={ONE:d.TOUCH.ROTATE,TWO:d.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return l.phi},this.getAzimuthalAngle=function(){return l.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(o){o.addEventListener("keydown",it),this._domElementKeyEvents=o},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",it),this._domElementKeyEvents=null},this.saveState=function(){e.target0.copy(e.target),e.position0.copy(e.object.position),e.zoom0=e.object.zoom},this.reset=function(){e.target.copy(e.target0),e.object.position.copy(e.position0),e.object.zoom=e.zoom0,e.object.updateProjectionMatrix(),e.dispatchEvent(un),e.update(),s=r.NONE},this.update=function(){const o=new d.Vector3,E=new d.Quaternion().setFromUnitVectors(n.up,new d.Vector3(0,1,0)),N=E.clone().invert(),F=new d.Vector3,ie=new d.Quaternion,be=new d.Vector3,de=2*Math.PI;return function(St=null){const we=e.object.position;o.copy(we).sub(e.target),o.applyQuaternion(E),l.setFromVector3(o),e.autoRotate&&s===r.NONE&&H(y(St)),e.enableDamping?(l.theta+=f.theta*e.dampingFactor,l.phi+=f.phi*e.dampingFactor):(l.theta+=f.theta,l.phi+=f.phi);let he=e.minAzimuthAngle,pe=e.maxAzimuthAngle;isFinite(he)&&isFinite(pe)&&(he<-Math.PI?he+=de:he>Math.PI&&(he-=de),pe<-Math.PI?pe+=de:pe>Math.PI&&(pe-=de),he<=pe?l.theta=Math.max(he,Math.min(pe,l.theta)):l.theta=l.theta>(he+pe)/2?Math.max(he,l.theta):Math.min(pe,l.theta)),l.phi=Math.max(e.minPolarAngle,Math.min(e.maxPolarAngle,l.phi)),l.makeSafe(),e.enableDamping===!0?e.target.addScaledVector(b,e.dampingFactor):e.target.add(b),e.target.sub(e.cursor),e.target.clampLength(e.minTargetRadius,e.maxTargetRadius),e.target.add(e.cursor),e.zoomToCursor&&ae||e.object.isOrthographicCamera?l.radius=Q(l.radius):l.radius=Q(l.radius*m),o.setFromSpherical(l),o.applyQuaternion(N),we.copy(e.target).add(o),e.object.lookAt(e.target),e.enableDamping===!0?(f.theta*=1-e.dampingFactor,f.phi*=1-e.dampingFactor,b.multiplyScalar(1-e.dampingFactor)):(f.set(0,0,0),b.set(0,0,0));let He=!1;if(e.zoomToCursor&&ae){let Fe=null;if(e.object.isPerspectiveCamera){const Te=o.length();Fe=Q(Te*m);const ze=Te-Fe;e.object.position.addScaledVector(fe,ze),e.object.updateMatrixWorld()}else if(e.object.isOrthographicCamera){const Te=new d.Vector3(ue.x,ue.y,0);Te.unproject(e.object),e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/m)),e.object.updateProjectionMatrix(),He=!0;const ze=new d.Vector3(ue.x,ue.y,0);ze.unproject(e.object),e.object.position.sub(ze).add(Te),e.object.updateMatrixWorld(),Fe=o.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),e.zoomToCursor=!1;Fe!==null&&(this.screenSpacePanning?e.target.set(0,0,-1).transformDirection(e.object.matrix).multiplyScalar(Fe).add(e.object.position):(ct.origin.copy(e.object.position),ct.direction.set(0,0,-1).transformDirection(e.object.matrix),Math.abs(e.object.up.dot(ct.direction))<da?n.lookAt(e.target):(fn.setFromNormalAndCoplanarPoint(e.object.up,e.target),ct.intersectPlane(fn,e.target))))}else e.object.isOrthographicCamera&&(e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/m)),e.object.updateProjectionMatrix(),He=!0);return m=1,ae=!1,He||F.distanceToSquared(e.object.position)>u||8*(1-ie.dot(e.object.quaternion))>u||be.distanceToSquared(e.target)>0?(e.dispatchEvent(un),F.copy(e.object.position),ie.copy(e.object.quaternion),be.copy(e.target),!0):!1}}(),this.dispose=function(){e.domElement.removeEventListener("contextmenu",Oe),e.domElement.removeEventListener("pointerdown",nt),e.domElement.removeEventListener("pointercancel",Ue),e.domElement.removeEventListener("wheel",bt),e.domElement.removeEventListener("pointermove",xe),e.domElement.removeEventListener("pointerup",Ue),e._domElementKeyEvents!==null&&(e._domElementKeyEvents.removeEventListener("keydown",it),e._domElementKeyEvents=null)};const e=this,r={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=r.NONE;const u=1e-6,l=new d.Spherical,f=new d.Spherical;let m=1;const b=new d.Vector3,C=new d.Vector2,S=new d.Vector2,_=new d.Vector2,P=new d.Vector2,K=new d.Vector2,ce=new d.Vector2,Z=new d.Vector2,O=new d.Vector2,J=new d.Vector2,fe=new d.Vector3,ue=new d.Vector2;let ae=!1;const h=[],g={};function y(o){return o!==null?2*Math.PI/60*e.autoRotateSpeed*o:2*Math.PI/60/60*e.autoRotateSpeed}function T(o){const E=Math.abs(o)/(100*(window.devicePixelRatio|0));return Math.pow(.95,e.zoomSpeed*E)}function H(o){f.theta-=o}function z(o){f.phi-=o}const B=function(){const o=new d.Vector3;return function(N,F){o.setFromMatrixColumn(F,0),o.multiplyScalar(-N),b.add(o)}}(),L=function(){const o=new d.Vector3;return function(N,F){e.screenSpacePanning===!0?o.setFromMatrixColumn(F,1):(o.setFromMatrixColumn(F,0),o.crossVectors(e.object.up,o)),o.multiplyScalar(N),b.add(o)}}(),G=function(){const o=new d.Vector3;return function(N,F){const ie=e.domElement;if(e.object.isPerspectiveCamera){const be=e.object.position;o.copy(be).sub(e.target);let de=o.length();de*=Math.tan(e.object.fov/2*Math.PI/180),B(2*N*de/ie.clientHeight,e.object.matrix),L(2*F*de/ie.clientHeight,e.object.matrix)}else e.object.isOrthographicCamera?(B(N*(e.object.right-e.object.left)/e.object.zoom/ie.clientWidth,e.object.matrix),L(F*(e.object.top-e.object.bottom)/e.object.zoom/ie.clientHeight,e.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),e.enablePan=!1)}}();function ee(o){e.object.isPerspectiveCamera||e.object.isOrthographicCamera?m/=o:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function j(o){e.object.isPerspectiveCamera||e.object.isOrthographicCamera?m*=o:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function U(o,E){if(!e.zoomToCursor)return;ae=!0;const N=e.domElement.getBoundingClientRect(),F=o-N.left,ie=E-N.top,be=N.width,de=N.height;ue.x=F/be*2-1,ue.y=-(ie/de)*2+1,fe.set(ue.x,ue.y,1).unproject(e.object).sub(e.object.position).normalize()}function Q(o){return Math.max(e.minDistance,Math.min(e.maxDistance,o))}function me(o){C.set(o.clientX,o.clientY)}function Ae(o){U(o.clientX,o.clientX),Z.set(o.clientX,o.clientY)}function $e(o){P.set(o.clientX,o.clientY)}function ht(o){S.set(o.clientX,o.clientY),_.subVectors(S,C).multiplyScalar(e.rotateSpeed);const E=e.domElement;H(2*Math.PI*_.x/E.clientHeight),z(2*Math.PI*_.y/E.clientHeight),C.copy(S),e.update()}function At(o){O.set(o.clientX,o.clientY),J.subVectors(O,Z),J.y>0?ee(T(J.y)):J.y<0&&j(T(J.y)),Z.copy(O),e.update()}function It(o){K.set(o.clientX,o.clientY),ce.subVectors(K,P).multiplyScalar(e.panSpeed),G(ce.x,ce.y),P.copy(K),e.update()}function et(o){U(o.clientX,o.clientY),o.deltaY<0?j(T(o.deltaY)):o.deltaY>0&&ee(T(o.deltaY)),e.update()}function tt(o){let E=!1;switch(o.code){case e.keys.UP:o.ctrlKey||o.metaKey||o.shiftKey?z(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):G(0,e.keyPanSpeed),E=!0;break;case e.keys.BOTTOM:o.ctrlKey||o.metaKey||o.shiftKey?z(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):G(0,-e.keyPanSpeed),E=!0;break;case e.keys.LEFT:o.ctrlKey||o.metaKey||o.shiftKey?H(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):G(e.keyPanSpeed,0),E=!0;break;case e.keys.RIGHT:o.ctrlKey||o.metaKey||o.shiftKey?H(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):G(-e.keyPanSpeed,0),E=!0;break}E&&(o.preventDefault(),e.update())}function Ie(o){if(h.length===1)C.set(o.pageX,o.pageY);else{const E=ve(o),N=.5*(o.pageX+E.x),F=.5*(o.pageY+E.y);C.set(N,F)}}function Be(o){if(h.length===1)P.set(o.pageX,o.pageY);else{const E=ve(o),N=.5*(o.pageX+E.x),F=.5*(o.pageY+E.y);P.set(N,F)}}function Ne(o){const E=ve(o),N=o.pageX-E.x,F=o.pageY-E.y,ie=Math.sqrt(N*N+F*F);Z.set(0,ie)}function Nt(o){e.enableZoom&&Ne(o),e.enablePan&&Be(o)}function pt(o){e.enableZoom&&Ne(o),e.enableRotate&&Ie(o)}function mt(o){if(h.length==1)S.set(o.pageX,o.pageY);else{const N=ve(o),F=.5*(o.pageX+N.x),ie=.5*(o.pageY+N.y);S.set(F,ie)}_.subVectors(S,C).multiplyScalar(e.rotateSpeed);const E=e.domElement;H(2*Math.PI*_.x/E.clientHeight),z(2*Math.PI*_.y/E.clientHeight),C.copy(S)}function gt(o){if(h.length===1)K.set(o.pageX,o.pageY);else{const E=ve(o),N=.5*(o.pageX+E.x),F=.5*(o.pageY+E.y);K.set(N,F)}ce.subVectors(K,P).multiplyScalar(e.panSpeed),G(ce.x,ce.y),P.copy(K)}function Le(o){const E=ve(o),N=o.pageX-E.x,F=o.pageY-E.y,ie=Math.sqrt(N*N+F*F);O.set(0,ie),J.set(0,Math.pow(O.y/Z.y,e.zoomSpeed)),ee(J.y),Z.copy(O);const be=(o.pageX+E.x)*.5,de=(o.pageY+E.y)*.5;U(be,de)}function Ge(o){e.enableZoom&&Le(o),e.enablePan&&gt(o)}function vt(o){e.enableZoom&&Le(o),e.enableRotate&&mt(o)}function nt(o){e.enabled!==!1&&(h.length===0&&(e.domElement.setPointerCapture(o.pointerId),e.domElement.addEventListener("pointermove",xe),e.domElement.addEventListener("pointerup",Ue)),Ut(o),o.pointerType==="touch"?yt(o):Lt(o))}function xe(o){e.enabled!==!1&&(o.pointerType==="touch"?Et(o):at(o))}function Ue(o){wt(o),h.length===0&&(e.domElement.releasePointerCapture(o.pointerId),e.domElement.removeEventListener("pointermove",xe),e.domElement.removeEventListener("pointerup",Ue)),e.dispatchEvent(dn),s=r.NONE}function Lt(o){let E;switch(o.button){case 0:E=e.mouseButtons.LEFT;break;case 1:E=e.mouseButtons.MIDDLE;break;case 2:E=e.mouseButtons.RIGHT;break;default:E=-1}switch(E){case d.MOUSE.DOLLY:if(e.enableZoom===!1)return;Ae(o),s=r.DOLLY;break;case d.MOUSE.ROTATE:if(o.ctrlKey||o.metaKey||o.shiftKey){if(e.enablePan===!1)return;$e(o),s=r.PAN}else{if(e.enableRotate===!1)return;me(o),s=r.ROTATE}break;case d.MOUSE.PAN:if(o.ctrlKey||o.metaKey||o.shiftKey){if(e.enableRotate===!1)return;me(o),s=r.ROTATE}else{if(e.enablePan===!1)return;$e(o),s=r.PAN}break;default:s=r.NONE}s!==r.NONE&&e.dispatchEvent(Dt)}function at(o){switch(s){case r.ROTATE:if(e.enableRotate===!1)return;ht(o);break;case r.DOLLY:if(e.enableZoom===!1)return;At(o);break;case r.PAN:if(e.enablePan===!1)return;It(o);break}}function bt(o){e.enabled===!1||e.enableZoom===!1||s!==r.NONE||(o.preventDefault(),e.dispatchEvent(Dt),et(o),e.dispatchEvent(dn))}function it(o){e.enabled===!1||e.enablePan===!1||tt(o)}function yt(o){switch(rt(o),h.length){case 1:switch(e.touches.ONE){case d.TOUCH.ROTATE:if(e.enableRotate===!1)return;Ie(o),s=r.TOUCH_ROTATE;break;case d.TOUCH.PAN:if(e.enablePan===!1)return;Be(o),s=r.TOUCH_PAN;break;default:s=r.NONE}break;case 2:switch(e.touches.TWO){case d.TOUCH.DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;Nt(o),s=r.TOUCH_DOLLY_PAN;break;case d.TOUCH.DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;pt(o),s=r.TOUCH_DOLLY_ROTATE;break;default:s=r.NONE}break;default:s=r.NONE}s!==r.NONE&&e.dispatchEvent(Dt)}function Et(o){switch(rt(o),s){case r.TOUCH_ROTATE:if(e.enableRotate===!1)return;mt(o),e.update();break;case r.TOUCH_PAN:if(e.enablePan===!1)return;gt(o),e.update();break;case r.TOUCH_DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;Ge(o),e.update();break;case r.TOUCH_DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;vt(o),e.update();break;default:s=r.NONE}}function Oe(o){e.enabled!==!1&&o.preventDefault()}function Ut(o){h.push(o.pointerId)}function wt(o){delete g[o.pointerId];for(let E=0;E<h.length;E++)if(h[E]==o.pointerId){h.splice(E,1);return}}function rt(o){let E=g[o.pointerId];E===void 0&&(E=new d.Vector2,g[o.pointerId]=E),E.set(o.pageX,o.pageY)}function ve(o){const E=o.pointerId===h[0]?h[1]:h[0];return g[E]}e.domElement.addEventListener("contextmenu",Oe),e.domElement.addEventListener("pointerdown",nt),e.domElement.addEventListener("pointercancel",Ue),e.domElement.addEventListener("wheel",bt,{passive:!1}),this.update()}}const lt=t=>{const[n,a]=M.useState(t.options[t.index]),e=()=>{t.onToggle(!t.open)},r=s=>{s!==n&&(t.onSelect(s),a(s)),t.onToggle(!1)};return c.jsxs("div",{className:`dropdown ${t.up===!0?"up":""}`,children:[c.jsx("div",{className:"dropdown-toggle",onClick:e,children:n}),t.open&&c.jsx("ul",{className:"dropdown-menu",children:t.options.map(s=>c.jsx("li",{onClick:()=>r(s),children:s},s))})]})},je=M.forwardRef(function(n,a){const[e,r]=M.useState(!1),s=n.options.indexOf(n.camera.name);return c.jsxs("div",{className:"CameraWindow",children:[c.jsx("div",{ref:a,className:"clickable",onClick:()=>{e&&r(!1)}}),c.jsx(lt,{index:s,open:e,options:n.options,onSelect:n.onSelect,onToggle:u=>{r(u)},up:!0})]})}),hn=["Single","Side by Side","Stacked","Quad"],ne=new Map,oe=new Map,ye=new Map;function _e(t,n){const a=new d.OrthographicCamera(-100,100,100,-100,50,3e3);return a.name=t,a.position.copy(n),a.lookAt(0,0,0),ne.set(t,a),a}_e("Top",new d.Vector3(0,1e3,0)),_e("Bottom",new d.Vector3(0,-1e3,0)),_e("Left",new d.Vector3(-1e3,0,0)),_e("Right",new d.Vector3(1e3,0,0)),_e("Front",new d.Vector3(0,0,1e3)),_e("Back",new d.Vector3(0,0,-1e3)),_e("Orthographic",new d.Vector3(1e3,1e3,1e3));const ut=new d.PerspectiveCamera(60,1,50,3e3);ut.name="Debug",ut.position.set(500,500,500),ut.lookAt(0,0,0),ne.set("Debug",ut);const pn=["Renderer","Depth","Normals","UVs","Wireframe"],ha=new d.MeshDepthMaterial,pa=new d.MeshNormalMaterial,ma=new nn,ga=new d.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0}),ja="";let dt="Renderer";const Y=new d.Scene;Y.name="Debug Scene";let Ee=new d.Scene;Y.add(Ee);const Qe=new d.Group;Qe.name="helpers",Y.add(Qe);const va=new tn;Qe.add(va);const mn=new d.AxesHelper(500);mn.name="axisHelper",Qe.add(mn);const qe=new d.AxesHelper(100);qe.name="interactionHelper",Qe.add(qe),qe.visible=!1;let ft=!1,W=ne.get("Debug"),se=ne.get("Orthographic"),ke=ne.get("Front"),De=ne.get("Top"),gn=!1;function ba(t){const[n,a]=M.useState(t.mode!==void 0?t.mode:"Single"),[e,r]=M.useState(null),[s,u]=M.useState(!1),[l,f]=M.useState(!1),[m,b]=M.useState(!1),[,C]=M.useState(Date.now()),S=M.useRef(null),_=M.useRef(null),P=M.useRef(null),K=M.useRef(null),ce=M.useRef(null),Z=M.useRef(null),O=(h,g)=>{const y=oe.get(h.name);y!==void 0&&y.dispose(),oe.delete(h.name);const T=ye.get(h.name);T!==void 0&&(Y.remove(T),T.dispose()),ye.delete(h.name);const H=new fa(h,g);switch(H.enableDamping=!0,H.dampingFactor=.05,h.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":H.enableRotate=!1;break}if(oe.set(h.name,H),h instanceof d.PerspectiveCamera){const z=new d.CameraHelper(h);ye.set(h.name,z),Y.add(z)}},J=h=>{const g=ye.get(h.name);g!==void 0&&(Y.remove(g),g.dispose(),ye.delete(h.name));const y=oe.get(h.name);y!==void 0&&(y.dispose(),oe.delete(h.name))},fe=()=>{oe.forEach((h,g)=>{h.dispose();const y=ye.get(g);y!==void 0&&(Y.remove(y),y.dispose()),ye.delete(g),oe.delete(g)}),oe.clear(),ye.clear()},ue=()=>{switch(n){case"Single":O(W,P.current);break;case"Side by Side":case"Stacked":O(W,P.current),O(se,K.current);break;case"Quad":O(W,P.current),O(se,K.current),O(ke,ce.current),O(De,Z.current);break}};M.useEffect(()=>{const h=new d.WebGLRenderer({canvas:S.current,stencil:!1});h.autoClear=!1,h.shadowMap.enabled=!0,h.setPixelRatio(devicePixelRatio),h.setClearColor(0),r(h)},[]),M.useEffect(()=>{const h=T=>{Ot(Ee),Y.remove(Ee);const H=t.scenes.get(T.value.name);if(H!==void 0){const z=new H;t.onSceneSet!==void 0&&t.onSceneSet(z),Ee=z,t.three.scene=Ee,Y.add(Ee),gn=!0}},g=T=>{var B;const H=T.value,z=(B=t.three.scene)==null?void 0:B.getObjectByProperty("uuid",H.uuid);z!==void 0&&ne.set(H.name,z),C(Date.now())},y=T=>{ne.delete(T.value.name),C(Date.now())};return D.addEventListener(A.SET_SCENE,h),D.addEventListener(A.ADD_CAMERA,g),D.addEventListener(A.REMOVE_CAMERA,y),()=>{D.removeEventListener(A.SET_SCENE,h),D.removeEventListener(A.ADD_CAMERA,g),D.removeEventListener(A.REMOVE_CAMERA,y)}},[]),M.useEffect(()=>{if(e===null)return;let h=window.innerWidth,g=window.innerHeight,y=Math.floor(h/2),T=Math.floor(g/2),H=-1;const z=()=>{h=window.innerWidth-300,g=window.innerHeight,y=Math.floor(h/2),T=Math.floor(g/2),e.setSize(h,g);let j=h,U=g;switch(n){case"Side by Side":j=y,U=g;break;case"Stacked":j=h,U=T;break;case"Quad":j=y,U=T;break}ne.forEach(Q=>{var me;Q instanceof d.OrthographicCamera?(Q.left=j/-2,Q.right=j/2,Q.top=U/2,Q.bottom=U/-2,Q.updateProjectionMatrix()):Q instanceof d.PerspectiveCamera&&(Q.aspect=j/U,Q.updateProjectionMatrix(),(me=ye.get(Q.name))==null||me.update())})},B=()=>{e.setViewport(0,0,h,g),e.setScissor(0,0,h,g),e.render(Y,W)},L=()=>{if(n==="Side by Side")e.setViewport(0,0,y,g),e.setScissor(0,0,y,g),e.render(Y,W),e.setViewport(y,0,y,g),e.setScissor(y,0,y,g),e.render(Y,se);else{const j=g-T;e.setViewport(0,j,h,T),e.setScissor(0,j,h,T),e.render(Y,W),e.setViewport(0,0,h,T),e.setScissor(0,0,h,T),e.render(Y,se)}},G=()=>{let j=0,U=0;U=g-T,j=0,e.setViewport(j,U,y,T),e.setScissor(j,U,y,T),e.render(Y,W),j=y,e.setViewport(j,U,y,T),e.setScissor(j,U,y,T),e.render(Y,se),U=0,j=0,e.setViewport(j,U,y,T),e.setScissor(j,U,y,T),e.render(Y,ke),j=y,e.setViewport(j,U,y,T),e.setScissor(j,U,y,T),e.render(Y,De)},ee=()=>{switch(oe.forEach(j=>{j.update()}),t.onSceneUpdate!==void 0&&gn&&t.onSceneUpdate(Ee),e.clear(),n){case"Single":B();break;case"Side by Side":case"Stacked":L();break;case"Quad":G();break}H=requestAnimationFrame(ee)};return ue(),window.addEventListener("resize",z),z(),ee(),()=>{window.removeEventListener("resize",z),cancelAnimationFrame(H),H=-1}},[n,e]),M.useEffect(()=>{if(e!==null){const h=new d.Raycaster,g=new d.Vector2,y=(B,L,G,ee)=>{switch(n){case"Quad":B<G?L<ee?h.setFromCamera(g,W):h.setFromCamera(g,ke):L<ee?h.setFromCamera(g,se):h.setFromCamera(g,De);break;case"Side by Side":B<G?h.setFromCamera(g,W):h.setFromCamera(g,se);break;case"Single":h.setFromCamera(g,W);break;case"Stacked":L<ee?h.setFromCamera(g,W):h.setFromCamera(g,se);break}},T=B=>{if(!ft)return;const L=new d.Vector2;e.getSize(L);const G=Math.min(B.clientX,L.x),ee=Math.min(B.clientY,L.y);g.x=Ve(G,0,L.x,-1,1),g.y=Ve(ee,0,L.y,1,-1);const j=L.x/2,U=L.y/2,Q=()=>{G<j?g.x=Ve(G,0,j,-1,1):g.x=Ve(G,j,L.x,-1,1)},me=()=>{ee<U?g.y=Ve(ee,0,U,1,-1):g.y=Ve(ee,U,L.y,1,-1)};switch(n){case"Quad":Q(),me();break;case"Side by Side":Q();break;case"Stacked":me(),me();break}y(G,ee,j,U);const Ae=h.intersectObjects(Ee.children);Ae.length>0&&qe.position.copy(Ae[0].point)},H=B=>{if(!ft)return;const L=new d.Vector2;if(e.getSize(L),B.clientX>=L.x)return;T(B);const G=h.intersectObjects(Ee.children);G.length>0&&t.three.getObject(G[0].object.uuid)},z=_.current;return z.addEventListener("mousemove",T,!1),z.addEventListener("click",H,!1),()=>{z.removeEventListener("mousemove",T),z.removeEventListener("click",H)}}},[n,e]);const ae=[];return ne.forEach((h,g)=>{ae.push(g)}),c.jsxs("div",{className:"multiview",children:[c.jsx("canvas",{ref:S}),c.jsxs("div",{className:`cameras ${n==="Single"||n==="Stacked"?"single":""}`,ref:_,children:[n==="Single"&&c.jsx(c.Fragment,{children:c.jsx(je,{camera:W,options:ae,ref:P,onSelect:h=>{var y;(y=oe.get(W.name))==null||y.dispose();const g=ne.get(h);g!==void 0&&(J(W),W=g,O(g,P.current))}})}),(n==="Side by Side"||n==="Stacked")&&c.jsxs(c.Fragment,{children:[c.jsx(je,{camera:W,options:ae,ref:P,onSelect:h=>{var y;(y=oe.get(W.name))==null||y.dispose();const g=ne.get(h);g!==void 0&&(J(W),W=g,O(g,P.current))}}),c.jsx(je,{camera:se,options:ae,ref:K,onSelect:h=>{var y;(y=oe.get(se.name))==null||y.dispose();const g=ne.get(h);g!==void 0&&(J(se),se=g,O(g,K.current))}})]}),n==="Quad"&&c.jsxs(c.Fragment,{children:[c.jsx(je,{camera:W,options:ae,ref:P,onSelect:h=>{var y;(y=oe.get(W.name))==null||y.dispose();const g=ne.get(h);g!==void 0&&(J(W),W=g,O(g,P.current))}}),c.jsx(je,{camera:se,options:ae,ref:K,onSelect:h=>{var y;(y=oe.get(se.name))==null||y.dispose();const g=ne.get(h);g!==void 0&&(J(se),se=g,O(g,K.current))}}),c.jsx(je,{camera:ke,options:ae,ref:ce,onSelect:h=>{var y;(y=oe.get(ke.name))==null||y.dispose();const g=ne.get(h);g!==void 0&&(J(ke),ke=g,O(g,ce.current))}}),c.jsx(je,{camera:De,options:ae,ref:Z,onSelect:h=>{var y;(y=oe.get(De.name))==null||y.dispose();const g=ne.get(h);g!==void 0&&(J(De),De=g,O(g,Z.current))}})]})]}),c.jsxs("div",{className:"settings",children:[c.jsx(lt,{index:hn.indexOf(n),options:hn,onSelect:h=>{h!==n&&(fe(),a(h))},open:s,onToggle:h=>{u(h),l&&f(!1),m&&b(!1)}}),c.jsx(lt,{index:pn.indexOf(dt),options:pn,onSelect:h=>{if(h!==dt)switch(dt=h,dt){case"Depth":Y.overrideMaterial=ha;break;case"Normals":Y.overrideMaterial=pa;break;default:case"Renderer":Y.overrideMaterial=null;break;case"Wireframe":Y.overrideMaterial=ga;break;case"UVs":Y.overrideMaterial=ma;break}},open:l,onToggle:h=>{s&&u(!1),f(h),m&&b(!1)}}),c.jsx(lt,{index:0,options:["Orbit Mode","Selection Mode"],onSelect:h=>{ft=h==="Selection Mode",qe.visible=ft},open:m,onToggle:h=>{s&&u(!1),l&&f(!1),b(h)}})]})]})}const _a="";function ya(t){return c.jsxs("div",{className:"editor",ref:t.ref,style:t.style,children:[c.jsx("header",{children:t.header}),t.children,c.jsx("footer",{children:t.footer})]})}w.Accordion=st,w.Application=Rn,w.BaseRemote=Ke,w.ChildObject=_t,w.ContainerObject=an,w.Draggable=qt,w.DraggableItem=Qt,w.Dropdown=$t,w.DropdownItem=en,w.Editor=ya,w.InfiniteGridHelper=tn,w.Inspector=ln,w.MultiView=ba,w.NavButton=jt,w.RemoteComponents=Pn,w.RemoteController=zn,w.RemoteTheatre=Tt,w.RemoteThree=Nn,w.RemoteTweakpane=Xt,w.SceneInspector=ua,w.SidePanel=la,w.ToolEvents=A,w.UVMaterial=nn,w.clamp=On,w.colorToHex=Gt,w.debugDispatcher=D,w.dispose=Ot,w.disposeMaterial=zt,w.disposeTexture=Mn,w.distance=Tn,w.hierarchyUUID=xt,w.isColor=Bt,w.randomID=Vt,w.resetThreeObjects=Ht,w.round=ot,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
143
+ }`;class rn extends u.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:Xn,fragmentShader:Zn})}}const Ra="";function ct(t){const[n,a]=M.useState(t.open!==void 0?t.open:!0),e=!n||t.children===void 0;return c.jsxs("div",{className:`accordion ${e?"hide":""}`,children:[c.jsxs("button",{className:"toggle",onClick:()=>{const r=!n;t.onToggle!==void 0&&t.onToggle(r),a(r)},children:[c.jsx("p",{className:`status ${n?"open":""}`,children:"Toggle"}),c.jsx("p",{className:"label",children:t.label})]}),t.button,c.jsx("div",{className:n?"open":"",children:c.jsx("div",{children:t.children})})]})}function kt(t){const[n,a]=M.useState(!1),e=t.child.children.length>0,r=[];return t.child.children.length>0&&t.child.children.map(s=>{r.push(c.jsx(kt,{child:s,three:t.three},Math.random()))}),c.jsxs("div",{className:"childObject",children:[c.jsxs("div",{className:"child",children:[e?c.jsx("button",{className:"status",style:{backgroundPositionX:n?"-14px":"2px"},onClick:()=>{a(!n)}}):null,c.jsx("button",{className:"name",style:{left:e?"20px":"5px"},onClick:()=>{t.three.getObject(t.child.uuid)},children:t.child.name.length>0?`${t.child.name} (${t.child.type})`:`${t.child.type}::${t.child.uuid}`}),c.jsx("div",{className:`icon ${An(t.child)}`})]}),c.jsx("div",{className:n?"open":"",children:c.jsx("div",{className:"container",children:r})})]},Math.random())}function on(t){const n=[];return t.child.children.map(a=>{n.push(c.jsx(kt,{child:a,three:t.three},Math.random()))}),c.jsx("div",{className:`scene ${t.class!==void 0?t.class:""}`,children:n})}const Pa="",Jn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA5klEQVRoge2Y0Q6EIAwE6cX//+X6cCFpSMEKVTdk501OpRNKiyelFC0b8Ps6gCwoggZF0KAIGhRBgyJoUAQNiqCxjciR9SLV//eZiAyvK3U8i/QVaQO2YyLSFVvlkdTKDjJCukh2ykR5ZEW+kHmlatl90RaBtDkK/w7CYhuRUEO0ee3l+J3m55Vm+17vtwjTnV1V3QA8qfbeUXCzRWDpiLLS+OyzvRW7IzW9R+okvclsqR09743bo0yUpc1+lSJvNsa002+Euk9GKzV7SmZDRIMiaFAEDYqgQRE0KIIGRdCgCBoUQeMEMERadX7YUz8AAAAASUVORK5CYII=";function Qn(t){return"items"in t}function Re(t){const n=[];return t.items.forEach(a=>{Qn(a)?n.push(c.jsx(Re,{title:a.title,items:a.items},Math.random())):n.push(c.jsx(Je,{title:a.title,prop:a.prop,value:a.value,type:a.type,min:a.min,max:a.max,step:a.step,disabled:a.disabled,onChange:(e,r)=>{a.onChange!==void 0&&a.onChange(e,r)}},Math.random()))}),c.jsx(ct,{label:t.title,open:t.expanded===!0,children:n})}function qn(t){return!(t==="alphaHash"||t==="alphaToCoverage"||t==="attenuationDistance"||t==="colorWrite"||t==="combine"||t==="defaultAttributeValues"||t==="depthFunc"||t==="forceSinglePass"||t==="glslVersion"||t==="linewidth"||t==="normalMapType"||t==="precision"||t==="premultipliedAlpha"||t==="shadowSide"||t==="side"||t==="toneMapped"||t==="uniformsGroups"||t==="uniformsNeedUpdate"||t==="userData"||t==="vertexColors"||t==="version"||t==="wireframeLinecap"||t==="wireframeLinejoin"||t==="wireframeLinewidth"||t.slice(0,5)==="blend"||t.slice(0,4)==="clip"||t.slice(0,7)==="polygon"||t.slice(0,7)==="stencil"||t.slice(0,2)==="is")}function Pe(t){switch(t){case"alphaMap":return"Alpha Map";case"anisotropyMap":return"Anisotropy Map";case"anisotropyRotation":return"Anisotropy Rotation";case"aoMap":return"AO Map";case"aoMapIntensity":return"AO Map Intensity";case"attenuationColor":return"Attenuation Color";case"bumpMap":return"Bump Map";case"bumpScale":return"Bump Scale";case"clearcoatMap":return"Clearcoat Map";case"clearcoatNormalMap":return"Clearcoat Normal Map";case"clearcoatNormalScale":return"Clearcoat Normal Scale";case"clearcoatRoughness":return"Clearcoat Roughness";case"clearcoatRoughnessMap":return"Clearcoat Roughness Map";case"color":return"Color";case"defines":return"Defines";case"depthTest":return"Depth Test";case"depthWrite":return"Depth Write";case"displacementBias":return"Displacement Bias";case"displacementMap":return"Displacement Map";case"displacementScale":return"Displacement Scale";case"dithering":return"Dithering";case"emissive":return"Emissive";case"emissiveMap":return"Emissive Map";case"emissiveIntensity":return"Emissive Intensity";case"envMap":return"Environment Map";case"envMapIntensity":return"Environment Map Intensity";case"extensions":return"Extensions";case"flatShading":return"Flat Shading";case"fragmentShader":return"Fragment Shader";case"fog":return"Fog";case"gradientMap":return"Gradient Map";case"ior":return"IOR";case"iridescenceIOR":return"Iridescence IOR";case"iridescenceMap":return"Iridescence Map";case"iridescenceThicknessMap":return"Iridescence Thickness Map";case"iridescenceThicknessRange":return"Iridescence Thickness Range";case"lights":return"Lights";case"lightMap":return"Light Map";case"lightMapIntensity":return"Light Map Intensity";case"map":return"Map";case"matcap":return"Matcap";case"metalness":return"Metalness";case"metalnessMap":return"Metalness Map";case"name":return"Name";case"normalMap":return"Normal Map";case"normalScale":return"Normal Scale";case"opacity":return"Opacity";case"reflectivity":return"Reflectivity";case"refractionRatio":return"Refraction Ratio";case"roughness":return"Roughness";case"roughnessMap":return"Roughness Map";case"sheenColor":return"Sheen Color";case"sheenColorMap":return"Sheen Color Map";case"sheenRoughness":return"Sheen Roughness";case"sheenRoughnessMap":return"Sheen Roughness Map";case"shininess":return"Shininess";case"specular":return"Specular";case"specularColor":return"Specular Color";case"specularColorMap":return"Specular Color Map";case"specularIntensity":return"Specular Intensity";case"specularIntensityMap":return"Specular Map Intensity";case"thickness":return"Thickness";case"thicknessMap":return"Thickness Map";case"transmission":return"Transmission";case"transmissionMap":return"Transmission Map";case"transparent":return"Transparent";case"type":return"Type";case"uuid":return"UUID";case"uniforms":return"Uniforms";case"vertexShader":return"Vertex Shader";case"visible":return"Visible";case"wireframe":return"Wireframe"}return t}function $n(t){return t.toLowerCase().search("intensity")>-1||t==="anisotropyRotation"||t==="bumpScale"||t==="clearcoatRoughness"||t==="displacementBias"||t==="displacementScale"||t==="metalness"||t==="opacity"||t==="reflectivity"||t==="refractionRatio"||t==="roughness"||t==="sheenRoughness"||t==="thickness"}function ea(){const t=document.createElement("input");return t.type="file",new Promise((n,a)=>{t.addEventListener("change",function(){if(t.files===null)a();else{const e=t.files[0],r=new FileReader;r.onload=function(s){n(s.target.result)},r.readAsDataURL(e)}}),t.click()})}function sn(t,n,a){const e=[];for(const r in t){if(!qn(r))continue;const s=typeof t[r],h=t[r];if(s==="boolean"||s==="number"||s==="string"){const l={title:Pe(r),prop:r,type:s,value:h,min:void 0,max:void 0,onChange:(d,m)=>{var C;a.updateObject(n.uuid,`material.${d}`,m),s==="boolean"&&a.updateObject(n.uuid,"material.needsUpdate",!0);const b=(C=a.scene)==null?void 0:C.getObjectByProperty("uuid",n.uuid);b!==void 0&&te(b,`material.${d}`,m)}};$n(r)&&(l.value=Number(h),l.type="range",l.min=0,l.max=1,l.step=.01),e.push(l)}else if(s==="object")if(h.isColor)e.push({title:Pe(r),prop:r,type:"color",value:h,onChange:(l,d)=>{var C;const m=new u.Color(d);a.updateObject(n.uuid,`material.${l}`,m);const b=(C=a.scene)==null?void 0:C.getObjectByProperty("uuid",n.uuid);b!==void 0&&te(b,`material.${l}`,m)}});else if(Array.isArray(h)){const l=[];for(const d in h)l.push({title:`${d}`,type:`${typeof h[d]}`,value:h[d],onChange:(m,b)=>{var S;a.updateObject(n.uuid,`material.${r}`,b);const C=(S=a.scene)==null?void 0:S.getObjectByProperty("uuid",n.uuid);C!==void 0&&te(C,`material.${r}`,b)}});e.push({title:Pe(r),items:l})}else{const l=[];for(const d in h){const m=h[d];switch(typeof m){case"boolean":case"number":case"string":d==="src"?e.push({title:Pe(r),type:"image",value:m,onChange:(C,S)=>{var P;a.createTexture(n.uuid,`material.${r}`,S);const _=(P=a.scene)==null?void 0:P.getObjectByProperty("uuid",n.uuid);_!==void 0&&Rt(S).then(K=>{te(_,`material.${r}`,K),te(_,"material.needsUpdate",!0)})}}):l.push({title:`${Pe(d)}`,prop:`material.${r}.${d}`,type:`${typeof t[r][d]}`,value:h[d],onChange:(C,S)=>{var P;a.updateObject(n.uuid,`material.${r}.${d}`,S);const _=(P=a.scene)==null?void 0:P.getObjectByProperty("uuid",n.uuid);_!==void 0&&te(_,`material.${r}.${d}`,S)}});break;case"object":m.value!==void 0&&m.value.src!==void 0?l.push({title:Pe(d),type:"image",value:m.value.src,onChange:(C,S)=>{var P;a.createTexture(n.uuid,`material.${r}.${d}.value`,S);const _=(P=a.scene)==null?void 0:P.getObjectByProperty("uuid",n.uuid);_!==void 0&&Rt(S).then(K=>{te(_,`material.${r}.${d}.value`,K)})}}):l.push({title:d,type:`${typeof m.value}`,value:m.value,onChange:(C,S)=>{var P;a.updateObject(n.uuid,`material.${r}.${d}.value`,S);const _=(P=a.scene)==null?void 0:P.getObjectByProperty("uuid",n.uuid);_!==void 0&&te(_,`material.${r}.${d}.value`,S)}});break}}l.length>0&&e.push({title:Pe(r),items:l})}else h!==void 0&&console.log("other:",r,s,h)}return e.sort((r,s)=>r.title<s.title?-1:r.title>s.title?1:0),e.push({title:"Update Material",type:"button",onChange:()=>{a.updateObject(n.uuid,"material.needsUpdate",!0)}}),e}function ta(t,n){const a=t.material;if(Array.isArray(a)){const e=[],r=a.length;for(let s=0;s<r;s++)e.push(c.jsx(Re,{title:`Material ${s}`,items:sn(a[s],t,n)},`Material ${s}`));return c.jsx(c.Fragment,{children:e})}else return c.jsx(Re,{title:"Material",items:sn(a,t,n)})}function Je(t){let n=t.value;n!==void 0&&n.isColor!==void 0&&(n=Ht(t.value));const[a,e]=M.useState(n),r=M.useRef(null),s=M.useRef(null),h=M.useRef(null);M.useEffect(()=>{var J;let b=!1,C=-1,S=0,_=Number(a);const P=fe=>{b=!0,S=_,C=fe.clientX},K=fe=>{if(!b)return;const ue=t.step!==void 0?t.step:1,ae=(fe.clientX-C)*ue;_=Number((S+ae).toFixed(4)),s.current!==null&&(s.current.value=_.toString()),t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,_)},ce=()=>{b=!1},Z=()=>{b=!1},O=t.type==="number";return O&&((J=r.current)==null||J.addEventListener("mousedown",P,!1),document.addEventListener("mouseup",ce,!1),document.addEventListener("mousemove",K,!1),document.addEventListener("contextmenu",Z,!1)),()=>{var fe;O&&((fe=r.current)==null||fe.removeEventListener("mousedown",P),document.removeEventListener("mouseup",ce),document.removeEventListener("mousemove",K),document.removeEventListener("contextmenu",Z))}},[a]);const l=t.type==="string"&&(a.length>100||a.search(`
144
+ `)>-1),d=l||t.type==="image",m=b=>{let C=b.target.value;t.type==="boolean"&&(C=b.target.checked),e(C),t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,C)};return c.jsxs("div",{className:`field ${d?"block":""}`,children:[t.type!=="button"&&c.jsx("label",{ref:r,children:t.title},"fieldLabel"),t.type==="string"&&!l&&c.jsx("input",{type:"text",disabled:t.disabled,onChange:m,value:a}),t.type==="string"&&l&&c.jsx("textarea",{cols:50,rows:10,disabled:!0,onChange:m,value:a}),t.type==="boolean"&&c.jsx("input",{type:"checkbox",disabled:t.disabled,onChange:m,checked:a}),t.type==="number"&&c.jsx("input",{ref:s,type:"number",value:a,min:t.min,max:t.max,step:t.step,onChange:m}),t.type==="range"&&c.jsxs(c.Fragment,{children:[c.jsx("input",{type:"text",value:a.toString(),onChange:m,className:"min"}),c.jsx("input",{disabled:t.disabled,type:"range",value:a,min:t.min,max:t.max,step:t.step,onChange:m})]}),t.type==="color"&&c.jsxs(c.Fragment,{children:[c.jsx("input",{type:"text",value:a.toString(),onChange:m,className:"color"}),c.jsx("input",{type:"color",value:a,onChange:m})]}),t.type==="button"&&c.jsx("button",{onClick:()=>{t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,!0)},children:t.title}),t.type==="image"&&c.jsx("img",{ref:h,onClick:()=>{ea().then(b=>{h.current.src=b,t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,b)})},src:a.length>0?a:Jn})]})}function cn(t){switch(t){case"fov":return"FOV";case"zoom":return"Zoom";case"near":return"Near";case"far":return"Far";case"focus":return"Focus";case"aspect":return"Aspect";case"filmGauge":return"Film Gauge";case"filmOffset":return"Film Offset";case"left":return"Left";case"right":return"Right";case"top":return"Top";case"bottom":return"Bottom"}return t}function na(t,n){const a=[];if(t.perspectiveCameraInfo!==void 0)for(const e in t.perspectiveCameraInfo)a.push({title:cn(e),prop:e,type:"number",step:.01,value:t.perspectiveCameraInfo[e],onChange:(r,s)=>{var l;n.updateObject(t.uuid,r,s),n.requestMethod(t.uuid,"updateProjectionMatrix");const h=(l=n.scene)==null?void 0:l.getObjectByProperty("uuid",t.uuid);h!==void 0&&(te(h,r,s),h.updateProjectionMatrix())}});else if(t.orthographicCameraInfo!==void 0)for(const e in t.orthographicCameraInfo)a.push({title:cn(e),prop:e,type:"number",step:.01,value:t.perspectiveCameraInfo[e],onChange:(r,s)=>{var l;n.updateObject(t.uuid,r,s),n.requestMethod(t.uuid,"updateProjectionMatrix");const h=(l=n.scene)==null?void 0:l.getObjectByProperty("uuid",t.uuid);h!==void 0&&(te(h,r,s),h.updateProjectionMatrix())}});return c.jsx(Re,{title:"Camera",items:a})}const aa=Math.PI/180,ia=180/Math.PI;function Ve(t,n,a,e,r){return e+(t-n)*(r-e)/(a-n)}function ra(t){return t*aa}function Dt(t){return t*ia}function oa(t,n){const a=new u.Matrix4;a.elements=t.matrix;const e=new u.Vector3,r=new u.Euler,s=new u.Vector3;t.uuid.length>0&&(e.setFromMatrixPosition(a),r.setFromRotationMatrix(a),s.setFromMatrixScale(a));const h=(d,m)=>{var C;n.updateObject(t.uuid,d,m);const b=(C=n.scene)==null?void 0:C.getObjectByProperty("uuid",t.uuid);b!==void 0&&te(b,d,m)},l=(d,m)=>{h(d,ra(m))};return c.jsx(Re,{title:"Transform",items:[{title:"Position X",prop:"position.x",type:"number",value:e.x,onChange:h},{title:"Position Y",prop:"position.y",type:"number",value:e.y,onChange:h},{title:"Position Z",prop:"position.z",type:"number",value:e.z,onChange:h},{title:"Rotation X",prop:"rotation.x",type:"number",value:ot(Dt(r.x)),min:-360,max:360,step:.1,onChange:l},{title:"Rotation Y",prop:"rotation.y",type:"number",value:ot(Dt(r.y)),min:-360,max:360,step:.1,onChange:l},{title:"Rotation Z",prop:"rotation.z",type:"number",value:ot(Dt(r.z)),min:-360,max:360,step:.1,onChange:l},{title:"Scale X",prop:"scale.x",type:"number",value:s.x,step:.01,onChange:h},{title:"Scale Y",prop:"scale.y",type:"number",value:s.y,step:.01,onChange:h},{title:"Scale Z",prop:"scale.z",type:"number",value:s.z,step:.01,onChange:h}]})}function ln(t){switch(t){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"}return t}function sa(t,n){const a=[];if(t.lightInfo!==void 0)for(const e in t.lightInfo){const r=t.lightInfo[e];r!==void 0&&(r.isColor!==void 0?a.push({title:ln(e),prop:e,type:"color",value:r,onChange:(s,h)=>{var m;const l=new u.Color(h);n.updateObject(t.uuid,s,l);const d=(m=n.scene)==null?void 0:m.getObjectByProperty("uuid",t.uuid);d!==void 0&&te(d,s,l)}}):a.push({title:ln(e),prop:e,type:typeof r,value:r,step:typeof r=="number"?.01:void 0,onChange:(s,h)=>{var d;n.updateObject(t.uuid,s,h);const l=(d=n.scene)==null?void 0:d.getObjectByProperty("uuid",t.uuid);l!==void 0&&te(l,s,h)}}))}return c.jsx(Re,{title:"Light",items:a})}function ca(t,n){const a=[];return t.animations.forEach(e=>{a.push({title:"Name",type:"string",prop:"name",value:e.name,disabled:!0,onChange:(r,s)=>{var l;n.updateObject(t.uuid,r,s);const h=(l=n.scene)==null?void 0:l.getObjectByProperty("uuid",t.uuid);h!==void 0&&te(h,r,s)}}),a.push({title:"Duration",type:"number",prop:"duration",value:e.duration,disabled:!0,onChange:(r,s)=>{var l;n.updateObject(t.uuid,r,s);const h=(l=n.scene)==null?void 0:l.getObjectByProperty("uuid",t.uuid);h!==void 0&&te(h,r,s)}}),a.push({title:"Blend Mode",type:"number",prop:"blendMode",value:e.blendMode,disabled:!0,onChange:(r,s)=>{var l;n.updateObject(t.uuid,r,s);const h=(l=n.scene)==null?void 0:l.getObjectByProperty("uuid",t.uuid);h!==void 0&&te(h,r,s)}})}),c.jsx(Re,{title:"Animations",items:a})}const un={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};let re={...un};function dn(t){const[n,a]=M.useState(-1);M.useEffect(()=>{function r(h){re={...h.value},a(Date.now())}function s(){re={...un},a(Date.now())}return D.addEventListener(A.SET_SCENE,s),D.addEventListener(A.SET_OBJECT,r),()=>{D.removeEventListener(A.SET_SCENE,s),D.removeEventListener(A.SET_OBJECT,r)}},[]);const e=re.type.toLowerCase();return c.jsx(ct,{label:"Inspector",children:c.jsx("div",{id:"Inspector",className:t.class,children:re.uuid.length>0&&c.jsxs(c.Fragment,{children:[c.jsxs(c.Fragment,{children:[c.jsx(Je,{type:"string",title:"Name",prop:"name",value:re.name,disabled:!0}),c.jsx(Je,{type:"string",title:"Type",prop:"type",value:re.type,disabled:!0}),c.jsx(Je,{type:"string",title:"UUID",prop:"uuid",value:re.uuid,disabled:!0}),c.jsx(Je,{type:"boolean",title:"Visible",prop:"visible",value:re.visible,onChange:(r,s)=>{var l;t.three.updateObject(re.uuid,r,s);const h=(l=t.three.scene)==null?void 0:l.getObjectByProperty("uuid",re.uuid);h!==void 0&&te(h,r,s)}})]}),c.jsxs(c.Fragment,{children:[oa(re,t.three),re.animations.length>0?ca(re,t.three):null,e.search("camera")>-1?na(re,t.three):null,e.search("light")>-1?sa(re,t.three):null,e.search("mesh")>-1?ta(re,t.three):null]})]})},n)},"Inspector")}class la extends M.Component{constructor(a){super(a);$(this,"three");$(this,"setScene",a=>{this.setState(()=>({scene:a.value}))});this.state={scene:a.scene!==void 0?a.scene:null},this.three=a.three,D.addEventListener(A.SET_SCENE,this.setScene)}componentWillUnmount(){D.removeEventListener(A.SET_SCENE,this.setScene)}render(){var r;const a=this.componentState.scene!==null,e="Hierarchy - "+(a?`${(r=this.componentState.scene)==null?void 0:r.name}`:"No Scene");return c.jsx("div",{id:"SidePanel",children:c.jsxs(c.Fragment,{children:[c.jsx(ct,{label:e,open:!0,children:c.jsx(c.Fragment,{children:a&&c.jsx(on,{child:this.componentState.scene,three:this.three})})}),c.jsx(dn,{three:this.three})]})},"SidePanel")}get componentState(){return this.state}}function ua(t){function n(){return t.three.scene===void 0?(console.log("No scene:",t.three),!1):!0}const a=l=>{var m;if(!n())return;const d=(m=t.three.scene)==null?void 0:m.getObjectByProperty("uuid",l.value);d!==void 0&&t.three.setObject(d)},e=(l,d,m)=>{var C;if(!n())return;const b=(C=t.three.scene)==null?void 0:C.getObjectByProperty("uuid",l);b!==void 0&&te(b,d,m)},r=l=>{if(!n())return;const d=l.value,{key:m,value:b,uuid:C}=d;e(C,m,b)},s=l=>{if(!n())return;const d=l.value;Rt(d.value).then(m=>{e(d.uuid,d.key,m),e(d.uuid,"material.needsUpdate",!0)})},h=l=>{var S;if(!n())return;const{key:d,uuid:m,value:b}=l.value,C=(S=t.three.scene)==null?void 0:S.getObjectByProperty("uuid",m);if(C!==void 0)try{C[d](b)}catch(_){console.log("Error requesting method:"),console.log(_),console.log(d),console.log(b)}};return M.useEffect(()=>(D.addEventListener(A.GET_OBJECT,a),D.addEventListener(A.UPDATE_OBJECT,r),D.addEventListener(A.CREATE_TEXTURE,s),D.addEventListener(A.REQUEST_METHOD,h),()=>{D.removeEventListener(A.GET_OBJECT,a),D.removeEventListener(A.UPDATE_OBJECT,r),D.removeEventListener(A.CREATE_TEXTURE,s),D.removeEventListener(A.REQUEST_METHOD,h)}),[]),null}const fn={type:"change"},At={type:"start"},hn={type:"end"},lt=new u.Ray,pn=new u.Plane,da=Math.cos(70*u.MathUtils.DEG2RAD);class fa extends u.EventDispatcher{constructor(n,a){super(),this.object=n,this.domElement=a,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new u.Vector3,this.cursor=new u.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:u.MOUSE.ROTATE,MIDDLE:u.MOUSE.DOLLY,RIGHT:u.MOUSE.PAN},this.touches={ONE:u.TOUCH.ROTATE,TWO:u.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return l.phi},this.getAzimuthalAngle=function(){return l.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(o){o.addEventListener("keydown",it),this._domElementKeyEvents=o},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",it),this._domElementKeyEvents=null},this.saveState=function(){e.target0.copy(e.target),e.position0.copy(e.object.position),e.zoom0=e.object.zoom},this.reset=function(){e.target.copy(e.target0),e.object.position.copy(e.position0),e.object.zoom=e.zoom0,e.object.updateProjectionMatrix(),e.dispatchEvent(fn),e.update(),s=r.NONE},this.update=function(){const o=new u.Vector3,E=new u.Quaternion().setFromUnitVectors(n.up,new u.Vector3(0,1,0)),N=E.clone().invert(),F=new u.Vector3,ie=new u.Quaternion,be=new u.Vector3,de=2*Math.PI;return function(xt=null){const we=e.object.position;o.copy(we).sub(e.target),o.applyQuaternion(E),l.setFromVector3(o),e.autoRotate&&s===r.NONE&&H(y(xt)),e.enableDamping?(l.theta+=d.theta*e.dampingFactor,l.phi+=d.phi*e.dampingFactor):(l.theta+=d.theta,l.phi+=d.phi);let he=e.minAzimuthAngle,pe=e.maxAzimuthAngle;isFinite(he)&&isFinite(pe)&&(he<-Math.PI?he+=de:he>Math.PI&&(he-=de),pe<-Math.PI?pe+=de:pe>Math.PI&&(pe-=de),he<=pe?l.theta=Math.max(he,Math.min(pe,l.theta)):l.theta=l.theta>(he+pe)/2?Math.max(he,l.theta):Math.min(pe,l.theta)),l.phi=Math.max(e.minPolarAngle,Math.min(e.maxPolarAngle,l.phi)),l.makeSafe(),e.enableDamping===!0?e.target.addScaledVector(b,e.dampingFactor):e.target.add(b),e.target.sub(e.cursor),e.target.clampLength(e.minTargetRadius,e.maxTargetRadius),e.target.add(e.cursor),e.zoomToCursor&&ae||e.object.isOrthographicCamera?l.radius=Q(l.radius):l.radius=Q(l.radius*m),o.setFromSpherical(l),o.applyQuaternion(N),we.copy(e.target).add(o),e.object.lookAt(e.target),e.enableDamping===!0?(d.theta*=1-e.dampingFactor,d.phi*=1-e.dampingFactor,b.multiplyScalar(1-e.dampingFactor)):(d.set(0,0,0),b.set(0,0,0));let He=!1;if(e.zoomToCursor&&ae){let Fe=null;if(e.object.isPerspectiveCamera){const Te=o.length();Fe=Q(Te*m);const ze=Te-Fe;e.object.position.addScaledVector(fe,ze),e.object.updateMatrixWorld()}else if(e.object.isOrthographicCamera){const Te=new u.Vector3(ue.x,ue.y,0);Te.unproject(e.object),e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/m)),e.object.updateProjectionMatrix(),He=!0;const ze=new u.Vector3(ue.x,ue.y,0);ze.unproject(e.object),e.object.position.sub(ze).add(Te),e.object.updateMatrixWorld(),Fe=o.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),e.zoomToCursor=!1;Fe!==null&&(this.screenSpacePanning?e.target.set(0,0,-1).transformDirection(e.object.matrix).multiplyScalar(Fe).add(e.object.position):(lt.origin.copy(e.object.position),lt.direction.set(0,0,-1).transformDirection(e.object.matrix),Math.abs(e.object.up.dot(lt.direction))<da?n.lookAt(e.target):(pn.setFromNormalAndCoplanarPoint(e.object.up,e.target),lt.intersectPlane(pn,e.target))))}else e.object.isOrthographicCamera&&(e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/m)),e.object.updateProjectionMatrix(),He=!0);return m=1,ae=!1,He||F.distanceToSquared(e.object.position)>h||8*(1-ie.dot(e.object.quaternion))>h||be.distanceToSquared(e.target)>0?(e.dispatchEvent(fn),F.copy(e.object.position),ie.copy(e.object.quaternion),be.copy(e.target),!0):!1}}(),this.dispose=function(){e.domElement.removeEventListener("contextmenu",Oe),e.domElement.removeEventListener("pointerdown",nt),e.domElement.removeEventListener("pointercancel",Ue),e.domElement.removeEventListener("wheel",yt),e.domElement.removeEventListener("pointermove",xe),e.domElement.removeEventListener("pointerup",Ue),e._domElementKeyEvents!==null&&(e._domElementKeyEvents.removeEventListener("keydown",it),e._domElementKeyEvents=null)};const e=this,r={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=r.NONE;const h=1e-6,l=new u.Spherical,d=new u.Spherical;let m=1;const b=new u.Vector3,C=new u.Vector2,S=new u.Vector2,_=new u.Vector2,P=new u.Vector2,K=new u.Vector2,ce=new u.Vector2,Z=new u.Vector2,O=new u.Vector2,J=new u.Vector2,fe=new u.Vector3,ue=new u.Vector2;let ae=!1;const f=[],g={};function y(o){return o!==null?2*Math.PI/60*e.autoRotateSpeed*o:2*Math.PI/60/60*e.autoRotateSpeed}function T(o){const E=Math.abs(o)/(100*(window.devicePixelRatio|0));return Math.pow(.95,e.zoomSpeed*E)}function H(o){d.theta-=o}function z(o){d.phi-=o}const B=function(){const o=new u.Vector3;return function(N,F){o.setFromMatrixColumn(F,0),o.multiplyScalar(-N),b.add(o)}}(),L=function(){const o=new u.Vector3;return function(N,F){e.screenSpacePanning===!0?o.setFromMatrixColumn(F,1):(o.setFromMatrixColumn(F,0),o.crossVectors(e.object.up,o)),o.multiplyScalar(N),b.add(o)}}(),G=function(){const o=new u.Vector3;return function(N,F){const ie=e.domElement;if(e.object.isPerspectiveCamera){const be=e.object.position;o.copy(be).sub(e.target);let de=o.length();de*=Math.tan(e.object.fov/2*Math.PI/180),B(2*N*de/ie.clientHeight,e.object.matrix),L(2*F*de/ie.clientHeight,e.object.matrix)}else e.object.isOrthographicCamera?(B(N*(e.object.right-e.object.left)/e.object.zoom/ie.clientWidth,e.object.matrix),L(F*(e.object.top-e.object.bottom)/e.object.zoom/ie.clientHeight,e.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),e.enablePan=!1)}}();function ee(o){e.object.isPerspectiveCamera||e.object.isOrthographicCamera?m/=o:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function j(o){e.object.isPerspectiveCamera||e.object.isOrthographicCamera?m*=o:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function U(o,E){if(!e.zoomToCursor)return;ae=!0;const N=e.domElement.getBoundingClientRect(),F=o-N.left,ie=E-N.top,be=N.width,de=N.height;ue.x=F/be*2-1,ue.y=-(ie/de)*2+1,fe.set(ue.x,ue.y,1).unproject(e.object).sub(e.object.position).normalize()}function Q(o){return Math.max(e.minDistance,Math.min(e.maxDistance,o))}function me(o){C.set(o.clientX,o.clientY)}function Ae(o){U(o.clientX,o.clientX),Z.set(o.clientX,o.clientY)}function $e(o){P.set(o.clientX,o.clientY)}function pt(o){S.set(o.clientX,o.clientY),_.subVectors(S,C).multiplyScalar(e.rotateSpeed);const E=e.domElement;H(2*Math.PI*_.x/E.clientHeight),z(2*Math.PI*_.y/E.clientHeight),C.copy(S),e.update()}function It(o){O.set(o.clientX,o.clientY),J.subVectors(O,Z),J.y>0?ee(T(J.y)):J.y<0&&j(T(J.y)),Z.copy(O),e.update()}function Nt(o){K.set(o.clientX,o.clientY),ce.subVectors(K,P).multiplyScalar(e.panSpeed),G(ce.x,ce.y),P.copy(K),e.update()}function et(o){U(o.clientX,o.clientY),o.deltaY<0?j(T(o.deltaY)):o.deltaY>0&&ee(T(o.deltaY)),e.update()}function tt(o){let E=!1;switch(o.code){case e.keys.UP:o.ctrlKey||o.metaKey||o.shiftKey?z(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):G(0,e.keyPanSpeed),E=!0;break;case e.keys.BOTTOM:o.ctrlKey||o.metaKey||o.shiftKey?z(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):G(0,-e.keyPanSpeed),E=!0;break;case e.keys.LEFT:o.ctrlKey||o.metaKey||o.shiftKey?H(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):G(e.keyPanSpeed,0),E=!0;break;case e.keys.RIGHT:o.ctrlKey||o.metaKey||o.shiftKey?H(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):G(-e.keyPanSpeed,0),E=!0;break}E&&(o.preventDefault(),e.update())}function Ie(o){if(f.length===1)C.set(o.pageX,o.pageY);else{const E=ve(o),N=.5*(o.pageX+E.x),F=.5*(o.pageY+E.y);C.set(N,F)}}function Be(o){if(f.length===1)P.set(o.pageX,o.pageY);else{const E=ve(o),N=.5*(o.pageX+E.x),F=.5*(o.pageY+E.y);P.set(N,F)}}function Ne(o){const E=ve(o),N=o.pageX-E.x,F=o.pageY-E.y,ie=Math.sqrt(N*N+F*F);Z.set(0,ie)}function Lt(o){e.enableZoom&&Ne(o),e.enablePan&&Be(o)}function mt(o){e.enableZoom&&Ne(o),e.enableRotate&&Ie(o)}function gt(o){if(f.length==1)S.set(o.pageX,o.pageY);else{const N=ve(o),F=.5*(o.pageX+N.x),ie=.5*(o.pageY+N.y);S.set(F,ie)}_.subVectors(S,C).multiplyScalar(e.rotateSpeed);const E=e.domElement;H(2*Math.PI*_.x/E.clientHeight),z(2*Math.PI*_.y/E.clientHeight),C.copy(S)}function vt(o){if(f.length===1)K.set(o.pageX,o.pageY);else{const E=ve(o),N=.5*(o.pageX+E.x),F=.5*(o.pageY+E.y);K.set(N,F)}ce.subVectors(K,P).multiplyScalar(e.panSpeed),G(ce.x,ce.y),P.copy(K)}function Le(o){const E=ve(o),N=o.pageX-E.x,F=o.pageY-E.y,ie=Math.sqrt(N*N+F*F);O.set(0,ie),J.set(0,Math.pow(O.y/Z.y,e.zoomSpeed)),ee(J.y),Z.copy(O);const be=(o.pageX+E.x)*.5,de=(o.pageY+E.y)*.5;U(be,de)}function Ge(o){e.enableZoom&&Le(o),e.enablePan&&vt(o)}function bt(o){e.enableZoom&&Le(o),e.enableRotate&&gt(o)}function nt(o){e.enabled!==!1&&(f.length===0&&(e.domElement.setPointerCapture(o.pointerId),e.domElement.addEventListener("pointermove",xe),e.domElement.addEventListener("pointerup",Ue)),Ft(o),o.pointerType==="touch"?Et(o):Ut(o))}function xe(o){e.enabled!==!1&&(o.pointerType==="touch"?wt(o):at(o))}function Ue(o){Ct(o),f.length===0&&(e.domElement.releasePointerCapture(o.pointerId),e.domElement.removeEventListener("pointermove",xe),e.domElement.removeEventListener("pointerup",Ue)),e.dispatchEvent(hn),s=r.NONE}function Ut(o){let E;switch(o.button){case 0:E=e.mouseButtons.LEFT;break;case 1:E=e.mouseButtons.MIDDLE;break;case 2:E=e.mouseButtons.RIGHT;break;default:E=-1}switch(E){case u.MOUSE.DOLLY:if(e.enableZoom===!1)return;Ae(o),s=r.DOLLY;break;case u.MOUSE.ROTATE:if(o.ctrlKey||o.metaKey||o.shiftKey){if(e.enablePan===!1)return;$e(o),s=r.PAN}else{if(e.enableRotate===!1)return;me(o),s=r.ROTATE}break;case u.MOUSE.PAN:if(o.ctrlKey||o.metaKey||o.shiftKey){if(e.enableRotate===!1)return;me(o),s=r.ROTATE}else{if(e.enablePan===!1)return;$e(o),s=r.PAN}break;default:s=r.NONE}s!==r.NONE&&e.dispatchEvent(At)}function at(o){switch(s){case r.ROTATE:if(e.enableRotate===!1)return;pt(o);break;case r.DOLLY:if(e.enableZoom===!1)return;It(o);break;case r.PAN:if(e.enablePan===!1)return;Nt(o);break}}function yt(o){e.enabled===!1||e.enableZoom===!1||s!==r.NONE||(o.preventDefault(),e.dispatchEvent(At),et(o),e.dispatchEvent(hn))}function it(o){e.enabled===!1||e.enablePan===!1||tt(o)}function Et(o){switch(rt(o),f.length){case 1:switch(e.touches.ONE){case u.TOUCH.ROTATE:if(e.enableRotate===!1)return;Ie(o),s=r.TOUCH_ROTATE;break;case u.TOUCH.PAN:if(e.enablePan===!1)return;Be(o),s=r.TOUCH_PAN;break;default:s=r.NONE}break;case 2:switch(e.touches.TWO){case u.TOUCH.DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;Lt(o),s=r.TOUCH_DOLLY_PAN;break;case u.TOUCH.DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;mt(o),s=r.TOUCH_DOLLY_ROTATE;break;default:s=r.NONE}break;default:s=r.NONE}s!==r.NONE&&e.dispatchEvent(At)}function wt(o){switch(rt(o),s){case r.TOUCH_ROTATE:if(e.enableRotate===!1)return;gt(o),e.update();break;case r.TOUCH_PAN:if(e.enablePan===!1)return;vt(o),e.update();break;case r.TOUCH_DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;Ge(o),e.update();break;case r.TOUCH_DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;bt(o),e.update();break;default:s=r.NONE}}function Oe(o){e.enabled!==!1&&o.preventDefault()}function Ft(o){f.push(o.pointerId)}function Ct(o){delete g[o.pointerId];for(let E=0;E<f.length;E++)if(f[E]==o.pointerId){f.splice(E,1);return}}function rt(o){let E=g[o.pointerId];E===void 0&&(E=new u.Vector2,g[o.pointerId]=E),E.set(o.pageX,o.pageY)}function ve(o){const E=o.pointerId===f[0]?f[1]:f[0];return g[E]}e.domElement.addEventListener("contextmenu",Oe),e.domElement.addEventListener("pointerdown",nt),e.domElement.addEventListener("pointercancel",Ue),e.domElement.addEventListener("wheel",yt,{passive:!1}),this.update()}}const ut=t=>{const[n,a]=M.useState(t.options[t.index]),e=()=>{t.onToggle(!t.open)},r=s=>{s!==n&&(t.onSelect(s),a(s)),t.onToggle(!1)};return c.jsxs("div",{className:`dropdown ${t.up===!0?"up":""}`,children:[c.jsx("div",{className:"dropdown-toggle",onClick:e,children:n}),t.open&&c.jsx("ul",{className:"dropdown-menu",children:t.options.map(s=>c.jsx("li",{onClick:()=>r(s),children:s},s))})]})},je=M.forwardRef(function(n,a){const[e,r]=M.useState(!1),s=n.options.indexOf(n.camera.name);return c.jsxs("div",{className:"CameraWindow",children:[c.jsx("div",{ref:a,className:"clickable",onClick:()=>{e&&r(!1)}}),c.jsx(ut,{index:s,open:e,options:n.options,onSelect:n.onSelect,onToggle:h=>{r(h)},up:!0})]})}),mn=["Single","Side by Side","Stacked","Quad"],ne=new Map,oe=new Map,ye=new Map;function _e(t,n){const a=new u.OrthographicCamera(-100,100,100,-100,50,3e3);return a.name=t,a.position.copy(n),a.lookAt(0,0,0),ne.set(t,a),a}_e("Top",new u.Vector3(0,1e3,0)),_e("Bottom",new u.Vector3(0,-1e3,0)),_e("Left",new u.Vector3(-1e3,0,0)),_e("Right",new u.Vector3(1e3,0,0)),_e("Front",new u.Vector3(0,0,1e3)),_e("Back",new u.Vector3(0,0,-1e3)),_e("Orthographic",new u.Vector3(1e3,1e3,1e3));const dt=new u.PerspectiveCamera(60,1,50,3e3);dt.name="Debug",dt.position.set(500,500,500),dt.lookAt(0,0,0),ne.set("Debug",dt);const gn=["Renderer","Depth","Normals","UVs","Wireframe"],ha=new u.MeshDepthMaterial,pa=new u.MeshNormalMaterial,ma=new rn,ga=new u.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0}),ja="";let ft="Renderer";const Y=new u.Scene;Y.name="Debug Scene";let Ee=new u.Scene;Y.add(Ee);const Qe=new u.Group;Qe.name="helpers",Y.add(Qe);const va=new an;Qe.add(va);const vn=new u.AxesHelper(500);vn.name="axisHelper",Qe.add(vn);const qe=new u.AxesHelper(100);qe.name="interactionHelper",Qe.add(qe),qe.visible=!1;let ht=!1,W=ne.get("Debug"),se=ne.get("Orthographic"),ke=ne.get("Front"),De=ne.get("Top"),bn=!1;function ba(t){const[n,a]=M.useState(t.mode!==void 0?t.mode:"Single"),[e,r]=M.useState(null),[s,h]=M.useState(!1),[l,d]=M.useState(!1),[m,b]=M.useState(!1),[,C]=M.useState(Date.now()),S=M.useRef(null),_=M.useRef(null),P=M.useRef(null),K=M.useRef(null),ce=M.useRef(null),Z=M.useRef(null),O=(f,g)=>{const y=oe.get(f.name);y!==void 0&&y.dispose(),oe.delete(f.name);const T=ye.get(f.name);T!==void 0&&(Y.remove(T),T.dispose()),ye.delete(f.name);const H=new fa(f,g);switch(H.enableDamping=!0,H.dampingFactor=.05,f.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":H.enableRotate=!1;break}if(oe.set(f.name,H),f instanceof u.PerspectiveCamera){const z=new u.CameraHelper(f);ye.set(f.name,z),Y.add(z)}},J=f=>{const g=ye.get(f.name);g!==void 0&&(Y.remove(g),g.dispose(),ye.delete(f.name));const y=oe.get(f.name);y!==void 0&&(y.dispose(),oe.delete(f.name))},fe=()=>{oe.forEach((f,g)=>{f.dispose();const y=ye.get(g);y!==void 0&&(Y.remove(y),y.dispose()),ye.delete(g),oe.delete(g)}),oe.clear(),ye.clear()},ue=()=>{switch(n){case"Single":O(W,P.current);break;case"Side by Side":case"Stacked":O(W,P.current),O(se,K.current);break;case"Quad":O(W,P.current),O(se,K.current),O(ke,ce.current),O(De,Z.current);break}};M.useEffect(()=>{const f=new u.WebGLRenderer({canvas:S.current,stencil:!1});f.autoClear=!1,f.shadowMap.enabled=!0,f.setPixelRatio(devicePixelRatio),f.setClearColor(0),r(f)},[]),M.useEffect(()=>{const f=T=>{Tt(Ee),Y.remove(Ee);const H=t.scenes.get(T.value.name);if(H!==void 0){const z=new H;t.onSceneSet!==void 0&&t.onSceneSet(z),Ee=z,t.three.scene=Ee,Y.add(Ee),bn=!0}},g=T=>{var B;const H=T.value,z=(B=t.three.scene)==null?void 0:B.getObjectByProperty("uuid",H.uuid);z!==void 0&&ne.set(H.name,z),C(Date.now())},y=T=>{ne.delete(T.value.name),C(Date.now())};return D.addEventListener(A.SET_SCENE,f),D.addEventListener(A.ADD_CAMERA,g),D.addEventListener(A.REMOVE_CAMERA,y),()=>{D.removeEventListener(A.SET_SCENE,f),D.removeEventListener(A.ADD_CAMERA,g),D.removeEventListener(A.REMOVE_CAMERA,y)}},[]),M.useEffect(()=>{if(e===null)return;let f=window.innerWidth,g=window.innerHeight,y=Math.floor(f/2),T=Math.floor(g/2),H=-1;const z=()=>{f=window.innerWidth-300,g=window.innerHeight,y=Math.floor(f/2),T=Math.floor(g/2),e.setSize(f,g);let j=f,U=g;switch(n){case"Side by Side":j=y,U=g;break;case"Stacked":j=f,U=T;break;case"Quad":j=y,U=T;break}ne.forEach(Q=>{var me;Q instanceof u.OrthographicCamera?(Q.left=j/-2,Q.right=j/2,Q.top=U/2,Q.bottom=U/-2,Q.updateProjectionMatrix()):Q instanceof u.PerspectiveCamera&&(Q.aspect=j/U,Q.updateProjectionMatrix(),(me=ye.get(Q.name))==null||me.update())})},B=()=>{e.setViewport(0,0,f,g),e.setScissor(0,0,f,g),e.render(Y,W)},L=()=>{if(n==="Side by Side")e.setViewport(0,0,y,g),e.setScissor(0,0,y,g),e.render(Y,W),e.setViewport(y,0,y,g),e.setScissor(y,0,y,g),e.render(Y,se);else{const j=g-T;e.setViewport(0,j,f,T),e.setScissor(0,j,f,T),e.render(Y,W),e.setViewport(0,0,f,T),e.setScissor(0,0,f,T),e.render(Y,se)}},G=()=>{let j=0,U=0;U=g-T,j=0,e.setViewport(j,U,y,T),e.setScissor(j,U,y,T),e.render(Y,W),j=y,e.setViewport(j,U,y,T),e.setScissor(j,U,y,T),e.render(Y,se),U=0,j=0,e.setViewport(j,U,y,T),e.setScissor(j,U,y,T),e.render(Y,ke),j=y,e.setViewport(j,U,y,T),e.setScissor(j,U,y,T),e.render(Y,De)},ee=()=>{switch(oe.forEach(j=>{j.update()}),t.onSceneUpdate!==void 0&&bn&&t.onSceneUpdate(Ee),e.clear(),n){case"Single":B();break;case"Side by Side":case"Stacked":L();break;case"Quad":G();break}H=requestAnimationFrame(ee)};return ue(),window.addEventListener("resize",z),z(),ee(),()=>{window.removeEventListener("resize",z),cancelAnimationFrame(H),H=-1}},[n,e]),M.useEffect(()=>{if(e!==null){const f=new u.Raycaster,g=new u.Vector2,y=(B,L,G,ee)=>{switch(n){case"Quad":B<G?L<ee?f.setFromCamera(g,W):f.setFromCamera(g,ke):L<ee?f.setFromCamera(g,se):f.setFromCamera(g,De);break;case"Side by Side":B<G?f.setFromCamera(g,W):f.setFromCamera(g,se);break;case"Single":f.setFromCamera(g,W);break;case"Stacked":L<ee?f.setFromCamera(g,W):f.setFromCamera(g,se);break}},T=B=>{if(!ht)return;const L=new u.Vector2;e.getSize(L);const G=Math.min(B.clientX,L.x),ee=Math.min(B.clientY,L.y);g.x=Ve(G,0,L.x,-1,1),g.y=Ve(ee,0,L.y,1,-1);const j=L.x/2,U=L.y/2,Q=()=>{G<j?g.x=Ve(G,0,j,-1,1):g.x=Ve(G,j,L.x,-1,1)},me=()=>{ee<U?g.y=Ve(ee,0,U,1,-1):g.y=Ve(ee,U,L.y,1,-1)};switch(n){case"Quad":Q(),me();break;case"Side by Side":Q();break;case"Stacked":me(),me();break}y(G,ee,j,U);const Ae=f.intersectObjects(Ee.children);Ae.length>0&&qe.position.copy(Ae[0].point)},H=B=>{if(!ht)return;const L=new u.Vector2;if(e.getSize(L),B.clientX>=L.x)return;T(B);const G=f.intersectObjects(Ee.children);G.length>0&&t.three.getObject(G[0].object.uuid)},z=_.current;return z.addEventListener("mousemove",T,!1),z.addEventListener("click",H,!1),()=>{z.removeEventListener("mousemove",T),z.removeEventListener("click",H)}}},[n,e]);const ae=[];return ne.forEach((f,g)=>{ae.push(g)}),c.jsxs("div",{className:"multiview",children:[c.jsx("canvas",{ref:S}),c.jsxs("div",{className:`cameras ${n==="Single"||n==="Stacked"?"single":""}`,ref:_,children:[n==="Single"&&c.jsx(c.Fragment,{children:c.jsx(je,{camera:W,options:ae,ref:P,onSelect:f=>{var y;(y=oe.get(W.name))==null||y.dispose();const g=ne.get(f);g!==void 0&&(J(W),W=g,O(g,P.current))}})}),(n==="Side by Side"||n==="Stacked")&&c.jsxs(c.Fragment,{children:[c.jsx(je,{camera:W,options:ae,ref:P,onSelect:f=>{var y;(y=oe.get(W.name))==null||y.dispose();const g=ne.get(f);g!==void 0&&(J(W),W=g,O(g,P.current))}}),c.jsx(je,{camera:se,options:ae,ref:K,onSelect:f=>{var y;(y=oe.get(se.name))==null||y.dispose();const g=ne.get(f);g!==void 0&&(J(se),se=g,O(g,K.current))}})]}),n==="Quad"&&c.jsxs(c.Fragment,{children:[c.jsx(je,{camera:W,options:ae,ref:P,onSelect:f=>{var y;(y=oe.get(W.name))==null||y.dispose();const g=ne.get(f);g!==void 0&&(J(W),W=g,O(g,P.current))}}),c.jsx(je,{camera:se,options:ae,ref:K,onSelect:f=>{var y;(y=oe.get(se.name))==null||y.dispose();const g=ne.get(f);g!==void 0&&(J(se),se=g,O(g,K.current))}}),c.jsx(je,{camera:ke,options:ae,ref:ce,onSelect:f=>{var y;(y=oe.get(ke.name))==null||y.dispose();const g=ne.get(f);g!==void 0&&(J(ke),ke=g,O(g,ce.current))}}),c.jsx(je,{camera:De,options:ae,ref:Z,onSelect:f=>{var y;(y=oe.get(De.name))==null||y.dispose();const g=ne.get(f);g!==void 0&&(J(De),De=g,O(g,Z.current))}})]})]}),c.jsxs("div",{className:"settings",children:[c.jsx(ut,{index:mn.indexOf(n),options:mn,onSelect:f=>{f!==n&&(fe(),a(f))},open:s,onToggle:f=>{h(f),l&&d(!1),m&&b(!1)}}),c.jsx(ut,{index:gn.indexOf(ft),options:gn,onSelect:f=>{if(f!==ft)switch(ft=f,ft){case"Depth":Y.overrideMaterial=ha;break;case"Normals":Y.overrideMaterial=pa;break;default:case"Renderer":Y.overrideMaterial=null;break;case"Wireframe":Y.overrideMaterial=ga;break;case"UVs":Y.overrideMaterial=ma;break}},open:l,onToggle:f=>{s&&h(!1),d(f),m&&b(!1)}}),c.jsx(ut,{index:0,options:["Orbit Mode","Selection Mode"],onSelect:f=>{ht=f==="Selection Mode",qe.visible=ht},open:m,onToggle:f=>{s&&h(!1),l&&d(!1),b(f)}})]})]})}const _a="";function ya(t){return c.jsxs("div",{className:"editor",ref:t.ref,style:t.style,children:[c.jsx("header",{children:t.header}),t.children,c.jsx("footer",{children:t.footer})]})}w.Accordion=ct,w.Application=jn,w.BaseRemote=Ke,w.ChildObject=kt,w.ContainerObject=on,w.Draggable=en,w.DraggableItem=$t,w.Dropdown=tn,w.DropdownItem=nn,w.Editor=ya,w.InfiniteGridHelper=an,w.Inspector=dn,w.MultiView=ba,w.NavButton=_t,w.RemoteComponents=Wt,w.RemoteController=zn,w.RemoteTheatre=st,w.RemoteThree=Jt,w.RemoteTweakpane=Pt,w.SceneInspector=ua,w.SidePanel=la,w.ToolEvents=A,w.UVMaterial=rn,w.clamp=Mn,w.colorToHex=Ht,w.debugDispatcher=D,w.dispose=Tt,w.disposeMaterial=Yt,w.disposeTexture=Pn,w.distance=Rn,w.hierarchyUUID=Ot,w.isColor=Gt,w.randomID=Bt,w.resetThreeObjects=zt,w.round=ot,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "module": "./dist/hermes.js",
8
8
  "types": "./types/index.d.ts",
9
9
  "type": "module",
10
- "version": "0.0.14",
10
+ "version": "0.0.16",
11
11
  "homepage": "https://github.com/tomorrowevening/hermes#readme",
12
12
  "bugs": {
13
13
  "url": "https://github.com/tomorrowevening/hermes/issues"
@@ -48,6 +48,10 @@ export default class Application {
48
48
  return this._mode;
49
49
  }
50
50
 
51
+ get isApp(): boolean {
52
+ return this._mode === 'app';
53
+ }
54
+
51
55
  get editor(): boolean {
52
56
  return this._mode === 'editor';
53
57
  }
@@ -2,38 +2,30 @@
2
2
  import Application from './Application';
3
3
  import { ToolEvents, debugDispatcher } from '@/editor/global';
4
4
  import type { BroadcastData } from './types';
5
- import { HandleAppRemoteComponents } from './remote/RemoteComponents';
6
- import { HandleAppRemoteTheatre, HandleEditorRemoteTheatre } from './remote/RemoteTheatre';
7
- import { HandleAppRemoteThree, HandleEditorRemoteThree } from './remote/RemoteThree';
8
- import { HandleAppRemoteTweakpane } from './remote/RemoteTweakpane';
5
+ import BaseRemote from './remote/BaseRemote';
6
+ import RemoteComponents, { HandleAppRemoteComponents } from './remote/RemoteComponents';
7
+ import RemoteTheatre, { HandleAppRemoteTheatre, HandleEditorRemoteTheatre } from './remote/RemoteTheatre';
8
+ import RemoteThree, { HandleAppRemoteThree, HandleEditorRemoteThree } from './remote/RemoteThree';
9
+ import RemoteTweakpane, { HandleAppRemoteTweakpane } from './remote/RemoteTweakpane';
9
10
 
10
- interface RemoteHandlers {
11
- components?: boolean
12
- theatre?: boolean
13
- three?: boolean
14
- tweakpane?: boolean
15
- }
16
-
17
- export default function RemoteController(app: Application, handlers: RemoteHandlers) {
11
+ export default function RemoteController(app: Application) {
18
12
  const appHandlers: any[] = [];
19
13
  const editorHandlers: any[] = [];
20
14
 
21
- if (handlers.components) {
22
- appHandlers.push(HandleAppRemoteComponents);
23
- }
24
-
25
- if (handlers.theatre) {
26
- appHandlers.push(HandleAppRemoteTheatre);
27
- HandleEditorRemoteTheatre(app);
28
- }
29
-
30
- if (handlers.three) {
31
- appHandlers.push(HandleAppRemoteThree);
32
- editorHandlers.push(HandleEditorRemoteThree);
33
- }
34
- if (handlers.tweakpane) {
35
- appHandlers.push(HandleAppRemoteTweakpane);
36
- }
15
+ // Correct handlers based on the App's components
16
+ app.components.forEach((value: BaseRemote) => {
17
+ if (value instanceof RemoteComponents) {
18
+ appHandlers.push(HandleAppRemoteComponents);
19
+ } else if (value instanceof RemoteTheatre) {
20
+ appHandlers.push(HandleAppRemoteTheatre);
21
+ HandleEditorRemoteTheatre(app);
22
+ } else if (value instanceof RemoteThree) {
23
+ appHandlers.push(HandleAppRemoteThree);
24
+ editorHandlers.push(HandleEditorRemoteThree);
25
+ } else if (value instanceof RemoteTweakpane) {
26
+ appHandlers.push(HandleAppRemoteTweakpane);
27
+ }
28
+ });
37
29
 
38
30
  function handleAppBroadcast(msg: BroadcastData) {
39
31
  appHandlers.forEach((handler: any) => handler(app, msg));
@@ -12,18 +12,13 @@ import type { DataUpdateCallback, VoidCallback } from '../types';
12
12
 
13
13
  export default class RemoteTheatre extends BaseRemote {
14
14
  project: IProject | undefined;
15
- sheets: Map<string, ISheet>;
16
- sheetObjects: Map<string, ISheetObject>;
17
- sheetObjectCBs: Map<string, DataUpdateCallback>;
18
- sheetObjectUnsubscribe: Map<string, VoidCallback>;
15
+ sheets: Map<string, ISheet> = new Map();
16
+ sheetObjects: Map<string, ISheetObject> = new Map();
17
+ sheetObjectCBs: Map<string, DataUpdateCallback> = new Map();
18
+ sheetObjectUnsubscribe: Map<string, VoidCallback> = new Map();
19
19
 
20
- constructor(app: Application, projectName: string, projectConfig?: IProjectConfig | undefined) {
21
- super(app);
20
+ init(projectName: string, projectConfig?: IProjectConfig | undefined) {
22
21
  this.project = getProject(projectName, projectConfig);
23
- this.sheets = new Map();
24
- this.sheetObjects = new Map();
25
- this.sheetObjectCBs = new Map();
26
- this.sheetObjectUnsubscribe = new Map();
27
22
  }
28
23
 
29
24
  override dispose(): void {
@@ -10,6 +10,7 @@ export default class Application {
10
10
  send(data: BroadcastData): void;
11
11
  listen(callback: BroadcastCallback): void;
12
12
  get mode(): ApplicationMode;
13
+ get isApp(): boolean;
13
14
  get editor(): boolean;
14
15
  set editor(value: boolean);
15
16
  }
@@ -1,9 +1,2 @@
1
1
  import Application from './Application';
2
- interface RemoteHandlers {
3
- components?: boolean;
4
- theatre?: boolean;
5
- three?: boolean;
6
- tweakpane?: boolean;
7
- }
8
- export default function RemoteController(app: Application, handlers: RemoteHandlers): void;
9
- export {};
2
+ export default function RemoteController(app: Application): void;
@@ -9,7 +9,7 @@ export default class RemoteTheatre extends BaseRemote {
9
9
  sheetObjects: Map<string, ISheetObject>;
10
10
  sheetObjectCBs: Map<string, DataUpdateCallback>;
11
11
  sheetObjectUnsubscribe: Map<string, VoidCallback>;
12
- constructor(app: Application, projectName: string, projectConfig?: IProjectConfig | undefined);
12
+ init(projectName: string, projectConfig?: IProjectConfig | undefined): void;
13
13
  dispose(): void;
14
14
  sheet(name: string): ISheet | undefined;
15
15
  sheetObject(sheetName: string, key: string, props: any, onUpdate?: DataUpdateCallback): ISheetObject | undefined;