@tomorrowevening/hermes 0.0.41 → 0.0.43

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
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("three");require("@theatre/studio");const Sn=require("tweakpane"),xn=require("@tweakpane/plugin-essentials"),R=require("react"),en=require("framer-motion");function wn(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 On=wn(xn),tn=()=>{},Mn=()=>{};function Ge(t){return t.substring(0,1).toUpperCase()+t.substring(1)}function Tn(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 nn(){return Math.round(Math.random()*1e6).toString()}function _n(t){return t.r!==void 0&&t.g!==void 0&&t.b!==void 0}function an(t){const n=Math.round(t.r*255),a=Math.round(t.g*255),e=Math.round(t.b*255),o=d=>{const h=d.toString(16);return h.length===1?"0"+h:h},l=o(n),v=o(a),c=o(e);return"#"+l+v+c}function yt(t,n=1){return Number(t.toFixed(n))}exports.totalThreeObjects=0;const rn=()=>{exports.totalThreeObjects=0},Lt=t=>{if(!t)return;let n=t.name.replace(" ","");n.length===0&&(n=`obj_${exports.totalThreeObjects}`,exports.totalThreeObjects++),t.parent!==null&&(n=`${t.parent.uuid}.${n}`),t.uuid=n,t.children.forEach(a=>{Lt(a)})},An=t=>{t?.dispose()},on=t=>{t&&(Array.isArray(t)?t.forEach(n=>n.dispose()):t.dispose())},Ft=t=>{if(t){for(;t.children.length>0;){const n=t.children[0];n instanceof s.PositionalAudio?(n.pause(),n.parent&&n.parent.remove(n)):Ft(n)}if(t.parent&&t.parent.remove(t),t.isMesh){const n=t;n.geometry?.dispose(),on(n.material)}t.dispose!==void 0&&t.dispose()}};class Pn{components=new Map;listen;_debugEnabled;_broadcastChannel=void 0;_webSocket=void 0;_mode="app";_connected=!1;_useBC=!1;constructor(n,a,e=!0){this._debugEnabled=a,a&&(this._useBC=e,e?(this._broadcastChannel=new BroadcastChannel(n),this._broadcastChannel.addEventListener("message",this.messageHandler)):(this._webSocket=new WebSocket(n),this._webSocket.addEventListener("open",this.openHandler),this._webSocket.addEventListener("close",this.closeHandler),this._webSocket.addEventListener("message",this.messageHandler)))}init(){return new Promise(n=>{n()})}addComponent(n,a){this.components.set(n,a)}dispose(){this._broadcastChannel!==void 0&&this._broadcastChannel.removeEventListener("message",this.messageHandler),this._webSocket!==void 0&&(this._webSocket.removeEventListener("open",this.openHandler),this._webSocket.removeEventListener("close",this.closeHandler),this._webSocket.removeEventListener("message",this.messageHandler)),this.components.forEach(n=>{n.dispose()}),this.components.clear()}send(n){this._mode!==n.target&&(this._useBC?this._broadcastChannel?.postMessage(n):this._connected&&this._webSocket?.send(JSON.stringify(n)))}messageHandler=n=>{this.listen!==void 0&&(this._useBC?this.listen(n.data):this.listen(JSON.parse(n.data)))};openHandler=()=>{this._connected=!0};closeHandler=()=>{this._connected=!1};get connected(){return this._connected}get debugEnabled(){return this._debugEnabled}get mode(){return this._mode}get isApp(){return this._mode==="app"}get editor(){return this._mode==="editor"}set editor(n){n&&(this._mode="editor")}}const j=new s.EventDispatcher,I={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 Ct{app;constructor(n){this.app=n}dispose(){}handleApp(n){}handleEditor(n){}}class kn extends Ct{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}})}handleApp(n){switch(n.event){case"selectComponent":j.dispatchEvent({type:I.SELECT_DROPDOWN,value:n.data});break;case"draggableListUpdate":j.dispatchEvent({type:I.DRAG_UPDATE,value:n.data});break}}}let Ve;function Dn(t,n,a){if(t.editor){a.ui.restore(),a.onSelectionChange(v=>{v.length<1||v.forEach(c=>{let d=c.address.sheetId,h="setSheet",g={};switch(c.type){case"Theatre_Sheet_PublicAPI":h="setSheet",g={sheet:c.address.sheetId},Ve=n.sheets.get(c.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":h="setSheetObject",d+=`_${c.address.objectKey}`,g={id:d,sheet:c.address.sheetId,key:c.address.objectKey},Ve=n.sheets.get(c.address.sheetId);break}t.send({event:h,target:"app",data:g})})});let e=-1;const o=()=>{if(Ve!==void 0&&e!==Ve.sequence.position){e=Ve.sequence.position;const v=Ve;t.send({event:"updateTimeline",target:"app",data:{position:e,sheet:v.address.sheetId}})}},l=()=>{o(),requestAnimationFrame(l)};o(),l()}else a.ui.hide()}function jn(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 sn(t){const n={name:t.name,type:t.type,uuid:t.uuid,children:[]};return t.children.forEach(a=>{n.children.push(sn(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 ze(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],o=t[a];switch(e){case"boolean":case"number":case"string":n[a]=o;break;case"object":if(o!==null)if(n[a]=o,o.isTexture)if(o instanceof s.Texture){const l=o.source.toJSON();n[a]={src:l.url}}else o instanceof s.CubeTexture&&(console.log("env map"),console.log(o.source.data),console.log(o.source.toJSON()),n[a]={src:""});else a==="uniforms"&&(n[a]=In(n[a]));else n[a]={src:""};break}}return n}function kt(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 o=[];e.material.forEach(l=>{o.push(ze(l))}),n.material=o}else n.material=ze(e.material)}else if(a.search("points")>-1){const e=t;if(Array.isArray(e.material)){const o=[];e.material.forEach(l=>{o.push(ze(l))}),n.material=o}else n.material=ze(e.material)}else if(a.search("line")>-1){const e=t;if(Array.isArray(e.material)){const o=[];e.material.forEach(l=>{o.push(ze(l))}),n.material=o}else n.material=ze(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 Ln(t,n){const a=n.split(".");switch(a.length){case 1:return t[a[0]];case 2:return t[a[0]][a[1]];case 3:return t[a[0]][a[1]][a[2]];case 4:return t[a[0]][a[1]][a[2]][a[3]];case 5:return t[a[0]][a[1]][a[2]][a[3]][a[4]];case 6:return t[a[0]][a[1]][a[2]][a[3]][a[4]][a[5]]}}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 It(t){return new Promise((n,a)=>{const e=new Image;e.onload=()=>{const o=new s.Texture(e);o.wrapS=s.RepeatWrapping,o.wrapT=s.RepeatWrapping,o.needsUpdate=!0,n(o)},e.onerror=a,e.src=t})}class Fn extends Ct{scene=void 0;getObject(n){this.app.debugEnabled&&this.app.send({event:"getObject",target:"app",data:n})}setObject(n){const a=kt(n);this.app.send({event:"setObject",target:"editor",data:a})}requestMethod(n,a,e,o){this.app.send({event:"requestMethod",target:"app",data:{uuid:n,key:a,value:e,subitem:o}})}updateObject(n,a,e){this.app.send({event:"updateObject",target:"app",data:{uuid:n,key:a,value:e}})}createTexture(n,a,e){this.app.send({event:"createTexture",target:"app",data:{uuid:n,key:a,value:e}})}setScene(n){if(n===void 0||(this.scene=n,!this.app.debugEnabled))return;rn(),Lt(this.scene);const a=sn(this.scene);this.app.send({event:"setScene",target:"editor",data:a})}addCamera(n){if(!this.app.debugEnabled)return;const a=kt(n);this.app.send({event:"addCamera",target:"editor",data:a})}removeCamera(n){if(!this.app.debugEnabled)return;const a=kt(n);this.app.send({event:"removeCamera",target:"editor",data:a})}handleApp(n){switch(n.event){case"getObject":j.dispatchEvent({type:I.GET_OBJECT,value:n.data});break;case"updateObject":j.dispatchEvent({type:I.UPDATE_OBJECT,value:n.data});break;case"createTexture":j.dispatchEvent({type:I.CREATE_TEXTURE,value:n.data});break;case"requestMethod":j.dispatchEvent({type:I.REQUEST_METHOD,value:n.data});break}}handleEditor(n){switch(n.event){case"setObject":j.dispatchEvent({type:I.SET_OBJECT,value:n.data});break;case"setScene":j.dispatchEvent({type:I.SET_SCENE,value:n.data});break;case"addCamera":j.dispatchEvent({type:I.ADD_CAMERA,value:n.data});break;case"removeCamera":j.dispatchEvent({type:I.REMOVE_CAMERA,value:n.data});break}}}class Un extends Ct{bindCBs;buttonCBs;pane=void 0;appCallbacks=0;editorCallbacks=0;inspectorFolder=void 0;constructor(n){super(n),this.bindCBs=new Map,this.buttonCBs=new Map,n.editor&&this.createGUI()}createGUI(){this.pane=new Sn.Pane({title:"GUI"}),this.pane.registerPlugin(On)}dispose(){this.bindCBs.clear(),this.buttonCBs.clear(),this.appCallbacks=0,this.editorCallbacks=0,this.app.editor&&(this.pane?.dispose(),this.pane=void 0)}addFolder(n,a=void 0,e=void 0){if(this.app.editor)return this.pane===void 0&&this.createGUI(),(e!==void 0?e:this.pane).addFolder({title:n,...a});this.app.send({event:"addFolder",target:"app",data:{name:n,params:a,parent:e}})}get bindID(){return`debug_${Math.max(this.appCallbacks,this.editorCallbacks)}`}bind(n,a,e,o=void 0){const l=this.bindID,v=e.onChange!==void 0?e.onChange:tn;this.bindCBs.set(l,v),this.app.editor?(this.pane===void 0&&this.createGUI(),(o!==void 0?o:this.pane).addBinding(n,a,e).on("change",d=>{this.app.send({event:"updateBind",target:"app",data:{id:l,value:d.value}})}),this.editorCallbacks++):(this.app.send({event:"bindObject",target:"app",data:{id:l,name:a,params:e,parent:o}}),this.appCallbacks++)}triggerBind(n,a){const e=this.bindCBs.get(n);e!==void 0?e(a):console.warn(`No callback for: ${n}`,a)}button(n,a,e=void 0){const o=this.bindID;this.buttonCBs.set(o,a),this.app.editor?(this.pane===void 0&&this.createGUI(),(e!==void 0?e:this.pane).addButton({title:n}).on("click",()=>{this.app.send({event:"clickButton",target:"app",data:{id:o}})}),this.editorCallbacks++):(this.app.send({event:"addButton",target:"app",data:{id:o,name:n,callback:a,parent:e}}),this.appCallbacks++)}triggerButton(n){const a=this.buttonCBs.get(n);a!==void 0&&a()}createInspector(){this.inspectorFolder=this.addFolder("Inspector",this.pane)}clearInspector(){const n=this.inspectorFolder.children.length-1;for(let a=n;a>-1;--a)this.inspectorFolder.remove(this.inspectorFolder.children[a])}handleApp(n){switch(n.event){case"addFolder":this.addFolder(n.data.name,n.data.params,n.data.parent);break;case"bindObject":this.bind(n.data.name,n.data.params,n.data.parent);break;case"updateBind":this.triggerBind(n.data.id,n.data.value);break;case"addButton":this.button(n.data.name,n.data.callback,n.data.parent);break;case"clickButton":this.triggerButton(n.data.id);break}}}var Nt={exports:{}},Qe={};/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("three"),Ht=require("@theatre/studio"),On=require("tweakpane"),Mn=require("@tweakpane/plugin-essentials"),R=require("react"),nn=require("framer-motion");function Tn(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 Rn=Tn(Mn),Lt=()=>{},_n=()=>{};function He(t){return t.substring(0,1).toUpperCase()+t.substring(1)}function An(t,n,a){return Math.min(n,Math.max(t,a))}function Pn(t,n){const a=t-n;return Math.sqrt(a*a)}function an(){return Math.round(Math.random()*1e6).toString()}function rn(t){return t.r!==void 0&&t.g!==void 0&&t.b!==void 0}function on(t){const n=Math.round(t.r*255),a=Math.round(t.g*255),e=Math.round(t.b*255),o=d=>{const p=d.toString(16);return p.length===1?"0"+p:p},l=o(n),m=o(a),s=o(e);return"#"+l+m+s}function Et(t,n=1){return Number(t.toFixed(n))}exports.totalThreeObjects=0;const sn=()=>{exports.totalThreeObjects=0},Ft=t=>{if(!t)return;let n=t.name.replace(" ","");n.length===0&&(n=`obj_${exports.totalThreeObjects}`,exports.totalThreeObjects++),t.parent!==null&&(n=`${t.parent.uuid}.${n}`),t.uuid=n,t.children.forEach(a=>{Ft(a)})},kn=t=>{t?.dispose()},cn=t=>{t&&(Array.isArray(t)?t.forEach(n=>n.dispose()):t.dispose())},Ut=t=>{if(t){for(;t.children.length>0;){const n=t.children[0];n instanceof c.PositionalAudio?(n.pause(),n.parent&&n.parent.remove(n)):Ut(n)}if(t.parent&&t.parent.remove(t),t.isMesh){const n=t;n.geometry?.dispose(),cn(n.material)}t.dispose!==void 0&&t.dispose()}};class jn{components=new Map;listen;_debugEnabled;_broadcastChannel=void 0;_webSocket=void 0;_mode="app";_connected=!1;_useBC=!1;constructor(n,a,e=!0){this._debugEnabled=a,a&&(this._useBC=e,e?(this._broadcastChannel=new BroadcastChannel(n),this._broadcastChannel.addEventListener("message",this.messageHandler)):(this._webSocket=new WebSocket(n),this._webSocket.addEventListener("open",this.openHandler),this._webSocket.addEventListener("close",this.closeHandler),this._webSocket.addEventListener("message",this.messageHandler)))}addComponent(n,a){this.components.set(n,a)}dispose(){this._broadcastChannel!==void 0&&this._broadcastChannel.removeEventListener("message",this.messageHandler),this._webSocket!==void 0&&(this._webSocket.removeEventListener("open",this.openHandler),this._webSocket.removeEventListener("close",this.closeHandler),this._webSocket.removeEventListener("message",this.messageHandler)),this.components.forEach(n=>{n.dispose()}),this.components.clear()}send(n){this._mode!==n.target&&(this._useBC?this._broadcastChannel?.postMessage(n):this._connected&&this._webSocket?.send(JSON.stringify(n)))}messageHandler=n=>{this.listen!==void 0&&(this._useBC?this.listen(n.data):this.listen(JSON.parse(n.data)))};openHandler=()=>{this._connected=!0};closeHandler=()=>{this._connected=!1};get connected(){return this._connected}get debugEnabled(){return this._debugEnabled}get mode(){return this._mode}get isApp(){return this._mode==="app"}get editor(){return this._mode==="editor"}set editor(n){n&&(this._mode="editor")}}const D=new c.EventDispatcher,I={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 it{app;constructor(n){this.app=n}dispose(){}}class Dn extends it{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 In(t,n,a){switch(a.event){case"selectComponent":D.dispatchEvent({type:I.SELECT_DROPDOWN,value:a.data});break;case"draggableListUpdate":D.dispatchEvent({type:I.DRAG_UPDATE,value:a.data});break}}function Nn(t,n,a){let e;switch(a.event){case"setSheet":e=n.sheets.get(a.data.sheet),e!==void 0&&(n.activeSheet=e,Ht.setSelection([e]));break;case"setSheetObject":e=n.sheetObjects.get(`${a.data.sheet}_${a.data.key}`),e!==void 0&&Ht.setSelection([e]);break;case"updateSheetObject":e=n.sheets.get(a.data.sheet),e!==void 0&&e.sequence.pause(),e=n.sheetObjectCBs.get(a.data.sheetObject),e!==void 0&&e(a.data.values);break;case"updateTimeline":e=n.sheets.get(a.data.sheet),n.activeSheet!==void 0&&(n.activeSheet.sequence.position=a.data.position);break}}function Ln(t,n,a){if(t.editor)switch(a.event){case"playSheet":n.sheet(a.data.sheet)?.sequence.play(a.data.value);break;case"pauseSheet":n.sheet(a.data.sheet)?.sequence.pause();break}}function Fn(t,n,a){switch(a.event){case"getObject":D.dispatchEvent({type:I.GET_OBJECT,value:a.data});break;case"updateObject":D.dispatchEvent({type:I.UPDATE_OBJECT,value:a.data});break;case"createTexture":D.dispatchEvent({type:I.CREATE_TEXTURE,value:a.data});break;case"requestMethod":D.dispatchEvent({type:I.REQUEST_METHOD,value:a.data});break}}function Un(t,n,a){switch(a.event){case"setObject":D.dispatchEvent({type:I.SET_OBJECT,value:a.data});break;case"setScene":D.dispatchEvent({type:I.SET_SCENE,value:a.data});break;case"addCamera":D.dispatchEvent({type:I.ADD_CAMERA,value:a.data});break;case"removeCamera":D.dispatchEvent({type:I.REMOVE_CAMERA,value:a.data});break}}function Bn(t,n,a){switch(a.event){case"addFolder":n.addFolder(a.data.name,a.data.params,a.data.parent);break;case"bindObject":n.bind(a.data.name,a.data.params,a.data.parent);break;case"updateBind":n.triggerBind(a.data.id,a.data.value);break;case"addButton":n.button(a.data.name,a.data.callback,a.data.parent);break;case"clickButton":n.triggerButton(a.data.id);break}}class ln extends it{project;sheets=new Map;sheetObjects=new Map;sheetObjectCBs=new Map;sheetObjectUnsubscribe=new Map;activeSheet;static rafDriver=void 0;dispose(){this.project=void 0,this.sheets=new Map,this.sheetObjects=new Map,this.sheetObjectCBs=new Map,this.sheetObjectUnsubscribe=new Map}sheet(n){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}let a=this.sheets.get(n);return a!==void 0||(a=this.project?.sheet(n),this.sheets.set(n,a)),a}playSheet(n,a){this.sheet(n)?.sequence.play(a),this.app.send({event:"playSheet",target:"editor",data:{sheet:n,value:a}})}pauseSheet(n){this.sheet(n)?.sequence.pause(),this.app.send({event:"pauseSheet",target:"editor",data:{sheet:n}})}clearSheetObjects(n){this.sheetObjects.forEach((a,e)=>{e.search(`${n}_`)>-1&&this.unsubscribe(a)})}sheetObject(n,a,e,o){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const l=this.sheet(n);if(l===void 0)return;const m=`${n}_${a}`;let s=this.sheetObjects.get(m);s!==void 0?s=l.object(a,{...e,...s.value},{reconfigure:!0}):s=l.object(a,e),this.sheetObjects.set(m,s),this.sheetObjectCBs.set(m,o!==void 0?o:Lt);const d=s.onValuesChange(p=>{if(this.app.editor){for(const y in p){const S=p[y];typeof S=="object"&&rn(S)&&(p[y]={r:S.r,g:S.g,b:S.b,a:S.a})}this.app.send({event:"updateSheetObject",target:"app",data:{sheet:n,sheetObject:m,values:p}})}const g=this.sheetObjectCBs.get(m);g!==void 0&&g(p)});return this.sheetObjectUnsubscribe.set(m,d),s}unsubscribe(n){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const a=n.address.sheetId,e=n.address.objectKey;this.sheets.get(a)?.detachObject(e);const l=`${a}_${e}`,m=this.sheetObjectUnsubscribe.get(l);m!==void 0&&(this.sheetObjects.delete(l),this.sheetObjectCBs.delete(l),this.sheetObjectUnsubscribe.delete(l),m())}}function Vn(t,n,a){if(t.editor){a.ui.restore(),a.onSelectionChange(m=>{m.length<1||m.forEach(s=>{let d=s.address.sheetId,p="setSheet",g={};switch(s.type){case"Theatre_Sheet_PublicAPI":p="setSheet",g={sheet:s.address.sheetId},n.activeSheet=n.sheets.get(s.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":p="setSheetObject",d+=`_${s.address.objectKey}`,g={id:d,sheet:s.address.sheetId,key:s.address.objectKey},n.activeSheet=n.sheets.get(s.address.sheetId);break}t.send({event:p,target:"app",data:g})})});let e=-1;const o=()=>{if(ln.rafDriver?.tick(performance.now()),n.activeSheet!==void 0&&e!==n.activeSheet.sequence.position){e=n.activeSheet.sequence.position;const m=n.activeSheet;t.send({event:"updateTimeline",target:"app",data:{position:e,sheet:m.address.sheetId}})}},l=()=>{o(),requestAnimationFrame(l)};o(),l()}else a.ui.hide()}function zn(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 un(t){const n={name:t.name,type:t.type,uuid:t.uuid,children:[]};return t.children.forEach(a=>{n.children.push(un(a))}),n}function Yn(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 Hn(t){switch(t){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function Ve(t){const n={};for(const a in t){if(a.substring(0,1)==="_"||a.substring(0,2)==="is"||Hn(a))continue;const e=typeof t[a],o=t[a];switch(e){case"boolean":case"number":case"string":n[a]=o;break;case"object":if(o!==null)if(n[a]=o,o.isTexture)if(o instanceof c.Texture){const l=o.source.toJSON();n[a]={src:l.url}}else o instanceof c.CubeTexture&&(console.log("env map"),console.log(o.source.data),console.log(o.source.toJSON()),n[a]={src:""});else a==="uniforms"&&(n[a]=Yn(n[a]));else n[a]={src:""};break}}return n}function kt(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 o=[];e.material.forEach(l=>{o.push(Ve(l))}),n.material=o}else n.material=Ve(e.material)}else if(a.search("points")>-1){const e=t;if(Array.isArray(e.material)){const o=[];e.material.forEach(l=>{o.push(Ve(l))}),n.material=o}else n.material=Ve(e.material)}else if(a.search("line")>-1){const e=t;if(Array.isArray(e.material)){const o=[];e.material.forEach(l=>{o.push(Ve(l))}),n.material=o}else n.material=Ve(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 Gn(t,n){const a=n.split(".");switch(a.length){case 1:return t[a[0]];case 2:return t[a[0]][a[1]];case 3:return t[a[0]][a[1]][a[2]];case 4:return t[a[0]][a[1]][a[2]][a[3]];case 5:return t[a[0]][a[1]][a[2]][a[3]][a[4]];case 6:return t[a[0]][a[1]][a[2]][a[3]][a[4]][a[5]]}}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 It(t){return new Promise((n,a)=>{const e=new Image;e.onload=()=>{const o=new c.Texture(e);o.wrapS=c.RepeatWrapping,o.wrapT=c.RepeatWrapping,o.needsUpdate=!0,n(o)},e.onerror=a,e.src=t})}class Wn extends it{scene=void 0;getObject(n){this.app.debugEnabled&&this.app.send({event:"getObject",target:"app",data:n})}setObject(n){const a=kt(n);this.app.send({event:"setObject",target:"editor",data:a})}requestMethod(n,a,e,o){this.app.send({event:"requestMethod",target:"app",data:{uuid:n,key:a,value:e,subitem:o}})}updateObject(n,a,e){this.app.send({event:"updateObject",target:"app",data:{uuid:n,key:a,value:e}})}createTexture(n,a,e){this.app.send({event:"createTexture",target:"app",data:{uuid:n,key:a,value:e}})}setScene(n){if(n===void 0||(this.scene=n,!this.app.debugEnabled))return;sn(),Ft(this.scene);const a=un(this.scene);this.app.send({event:"setScene",target:"editor",data:a})}addCamera(n){if(!this.app.debugEnabled)return;const a=kt(n);this.app.send({event:"addCamera",target:"editor",data:a})}removeCamera(n){if(!this.app.debugEnabled)return;const a=kt(n);this.app.send({event:"removeCamera",target:"editor",data:a})}}class $n extends it{bindCBs;buttonCBs;pane=void 0;appCallbacks=0;editorCallbacks=0;inspectorFolder=void 0;constructor(n){super(n),this.bindCBs=new Map,this.buttonCBs=new Map,n.editor&&this.createGUI()}createGUI(){this.pane=new On.Pane({title:"GUI"}),this.pane.registerPlugin(Rn)}dispose(){this.bindCBs.clear(),this.buttonCBs.clear(),this.appCallbacks=0,this.editorCallbacks=0,this.app.editor&&(this.pane?.dispose(),this.pane=void 0)}addFolder(n,a=void 0,e=void 0){if(this.app.editor)return this.pane===void 0&&this.createGUI(),(e!==void 0?e:this.pane).addFolder({title:n,...a});this.app.send({event:"addFolder",target:"app",data:{name:n,params:a,parent:e}})}get bindID(){return`debug_${Math.max(this.appCallbacks,this.editorCallbacks)}`}bind(n,a,e,o=void 0){const l=this.bindID,m=e.onChange!==void 0?e.onChange:Lt;this.bindCBs.set(l,m),this.app.editor?(this.pane===void 0&&this.createGUI(),(o!==void 0?o:this.pane).addBinding(n,a,e).on("change",d=>{this.app.send({event:"updateBind",target:"app",data:{id:l,value:d.value}})}),this.editorCallbacks++):(this.app.send({event:"bindObject",target:"app",data:{id:l,name:a,params:e,parent:o}}),this.appCallbacks++)}triggerBind(n,a){const e=this.bindCBs.get(n);e!==void 0?e(a):console.warn(`No callback for: ${n}`,a)}button(n,a,e=void 0){const o=this.bindID;this.buttonCBs.set(o,a),this.app.editor?(this.pane===void 0&&this.createGUI(),(e!==void 0?e:this.pane).addButton({title:n}).on("click",()=>{this.app.send({event:"clickButton",target:"app",data:{id:o}})}),this.editorCallbacks++):(this.app.send({event:"addButton",target:"app",data:{id:o,name:n,callback:a,parent:e}}),this.appCallbacks++)}triggerButton(n){const a=this.buttonCBs.get(n);a!==void 0&&a()}createInspector(){this.inspectorFolder=this.addFolder("Inspector",this.pane)}clearInspector(){const n=this.inspectorFolder.children.length-1;for(let a=n;a>-1;--a)this.inspectorFolder.remove(this.inspectorFolder.children[a])}}var Nt={exports:{}},Qe={};/**
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 Yt;function Bn(){if(Yt)return Qe;Yt=1;var t=R,n=Symbol.for("react.element"),a=Symbol.for("react.fragment"),e=Object.prototype.hasOwnProperty,o=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function v(c,d,h){var g,y={},C=null,x=null;h!==void 0&&(C=""+h),d.key!==void 0&&(C=""+d.key),d.ref!==void 0&&(x=d.ref);for(g in d)e.call(d,g)&&!l.hasOwnProperty(g)&&(y[g]=d[g]);if(c&&c.defaultProps)for(g in d=c.defaultProps,d)y[g]===void 0&&(y[g]=d[g]);return{$$typeof:n,type:c,key:C,ref:x,props:y,_owner:o.current}}return Qe.Fragment=a,Qe.jsx=v,Qe.jsxs=v,Qe}var et={};/**
9
+ */var Gt;function qn(){if(Gt)return Qe;Gt=1;var t=R,n=Symbol.for("react.element"),a=Symbol.for("react.fragment"),e=Object.prototype.hasOwnProperty,o=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function m(s,d,p){var g,y={},S=null,w=null;p!==void 0&&(S=""+p),d.key!==void 0&&(S=""+d.key),d.ref!==void 0&&(w=d.ref);for(g in d)e.call(d,g)&&!l.hasOwnProperty(g)&&(y[g]=d[g]);if(s&&s.defaultProps)for(g in d=s.defaultProps,d)y[g]===void 0&&(y[g]=d[g]);return{$$typeof:n,type:s,key:S,ref:w,props:y,_owner:o.current}}return Qe.Fragment=a,Qe.jsx=m,Qe.jsxs=m,Qe}var et={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,95 +14,95 @@
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 Gt;function Vn(){return Gt||(Gt=1,process.env.NODE_ENV!=="production"&&function(){var t=R,n=Symbol.for("react.element"),a=Symbol.for("react.portal"),e=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),v=Symbol.for("react.provider"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),y=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),x=Symbol.for("react.offscreen"),T=Symbol.iterator,D="@@iterator";function q(r){if(r===null||typeof r!="object")return null;var p=T&&r[T]||r[D];return typeof p=="function"?p:null}var V=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(r){{for(var p=arguments.length,b=new Array(p>1?p-1:0),S=1;S<p;S++)b[S-1]=arguments[S];G("error",r,b)}}function G(r,p,b){{var S=V.ReactDebugCurrentFrame,N=S.getStackAddendum();N!==""&&(p+="%s",b=b.concat([N]));var B=b.map(function(k){return String(k)});B.unshift("Warning: "+p),Function.prototype.apply.call(console[r],console,B)}}var be=!1,le=!1,se=!1,f=!1,m=!1,O;O=Symbol.for("react.module.reference");function P(r){return!!(typeof r=="string"||typeof r=="function"||r===e||r===l||m||r===o||r===h||r===g||f||r===x||be||le||se||typeof r=="object"&&r!==null&&(r.$$typeof===C||r.$$typeof===y||r.$$typeof===v||r.$$typeof===c||r.$$typeof===d||r.$$typeof===O||r.getModuleId!==void 0))}function H(r,p,b){var S=r.displayName;if(S)return S;var N=p.displayName||p.name||"";return N!==""?b+"("+N+")":b}function z(r){return r.displayName||"Context"}function Y(r){if(r==null)return null;if(typeof r.tag=="number"&&w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case e:return"Fragment";case a:return"Portal";case l:return"Profiler";case o:return"StrictMode";case h:return"Suspense";case g:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case c:var p=r;return z(p)+".Consumer";case v:var b=r;return z(b._context)+".Provider";case d:return H(r,r.render,"ForwardRef");case y:var S=r.displayName||null;return S!==null?S:Y(r.type)||"Memo";case C:{var N=r,B=N._payload,k=N._init;try{return Y(k(B))}catch{return null}}}return null}var L=Object.assign,X=0,K,_,U,Q,he,ye,it;function He(){}He.__reactDisabledLog=!0;function wt(){{if(X===0){K=console.log,_=console.info,U=console.warn,Q=console.error,he=console.group,ye=console.groupCollapsed,it=console.groupEnd;var r={configurable:!0,enumerable:!0,value:He,writable:!0};Object.defineProperties(console,{info:r,log:r,warn:r,error:r,group:r,groupCollapsed:r,groupEnd:r})}X++}}function Ot(){{if(X--,X===0){var r={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:L({},r,{value:K}),info:L({},r,{value:_}),warn:L({},r,{value:U}),error:L({},r,{value:Q}),group:L({},r,{value:he}),groupCollapsed:L({},r,{value:ye}),groupEnd:L({},r,{value:it})})}X<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var We=V.ReactCurrentDispatcher,$e;function Le(r,p,b){{if($e===void 0)try{throw Error()}catch(N){var S=N.stack.trim().match(/\n( *(at )?)/);$e=S&&S[1]||""}return`
18
- `+$e+r}}var Fe=!1,Se;{var ot=typeof WeakMap=="function"?WeakMap:Map;Se=new ot}function st(r,p){if(!r||Fe)return"";{var b=Se.get(r);if(b!==void 0)return b}var S;Fe=!0;var N=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var B;B=We.current,We.current=null,wt();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(me){S=me}Reflect.construct(r,[],k)}else{try{k.call()}catch(me){S=me}r.call(k.prototype)}}else{try{throw Error()}catch(me){S=me}r()}}catch(me){if(me&&S&&typeof me.stack=="string"){for(var A=me.stack.split(`
19
- `),ce=S.stack.split(`
20
- `),J=A.length-1,ee=ce.length-1;J>=1&&ee>=0&&A[J]!==ce[ee];)ee--;for(;J>=1&&ee>=0;J--,ee--)if(A[J]!==ce[ee]){if(J!==1||ee!==1)do if(J--,ee--,ee<0||A[J]!==ce[ee]){var fe=`
21
- `+A[J].replace(" at new "," at ");return r.displayName&&fe.includes("<anonymous>")&&(fe=fe.replace("<anonymous>",r.displayName)),typeof r=="function"&&Se.set(r,fe),fe}while(J>=1&&ee>=0);break}}}finally{Fe=!1,We.current=B,Ot(),Error.prepareStackTrace=N}var Be=r?r.displayName||r.name:"",zt=Be?Le(Be):"";return typeof r=="function"&&Se.set(r,zt),zt}function Mt(r,p,b){return st(r,!1)}function ct(r){var p=r.prototype;return!!(p&&p.isReactComponent)}function xe(r,p,b){if(r==null)return"";if(typeof r=="function")return st(r,ct(r));if(typeof r=="string")return Le(r);switch(r){case h:return Le("Suspense");case g:return Le("SuspenseList")}if(typeof r=="object")switch(r.$$typeof){case d:return Mt(r.render);case y:return xe(r.type,p,b);case C:{var S=r,N=S._payload,B=S._init;try{return xe(B(N),p,b)}catch{}}}return""}var we=Object.prototype.hasOwnProperty,lt={},ut=V.ReactDebugCurrentFrame;function Oe(r){if(r){var p=r._owner,b=xe(r.type,r._source,p?p.type:null);ut.setExtraStackFrame(b)}else ut.setExtraStackFrame(null)}function qe(r,p,b,S,N){{var B=Function.call.bind(we);for(var k in r)if(B(r,k)){var A=void 0;try{if(typeof r[k]!="function"){var ce=Error((S||"React class")+": "+b+" type `"+k+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof r[k]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw ce.name="Invariant Violation",ce}A=r[k](p,k,S,b,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(J){A=J}A&&!(A instanceof Error)&&(Oe(N),w("%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).",S||"React class",b,k,typeof A),Oe(null)),A instanceof Error&&!(A.message in lt)&&(lt[A.message]=!0,Oe(N),w("Failed %s type: %s",b,A.message),Oe(null))}}}var Me=Array.isArray;function Xe(r){return Me(r)}function Tt(r){{var p=typeof Symbol=="function"&&Symbol.toStringTag,b=p&&r[Symbol.toStringTag]||r.constructor.name||"Object";return b}}function dt(r){try{return ft(r),!1}catch{return!0}}function ft(r){return""+r}function pt(r){if(dt(r))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Tt(r)),ft(r)}var Ee=V.ReactCurrentOwner,Ke={key:!0,ref:!0,__self:!0,__source:!0},Ze,ht,Ue;Ue={};function Rt(r){if(we.call(r,"ref")){var p=Object.getOwnPropertyDescriptor(r,"ref").get;if(p&&p.isReactWarning)return!1}return r.ref!==void 0}function _t(r){if(we.call(r,"key")){var p=Object.getOwnPropertyDescriptor(r,"key").get;if(p&&p.isReactWarning)return!1}return r.key!==void 0}function mt(r,p){if(typeof r.ref=="string"&&Ee.current&&p&&Ee.current.stateNode!==p){var b=Y(Ee.current.type);Ue[b]||(w('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',Y(Ee.current.type),r.ref),Ue[b]=!0)}}function Ce(r,p){{var b=function(){Ze||(Ze=!0,w("%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))};b.isReactWarning=!0,Object.defineProperty(r,"key",{get:b,configurable:!0})}}function Vt(r,p){{var b=function(){ht||(ht=!0,w("%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))};b.isReactWarning=!0,Object.defineProperty(r,"ref",{get:b,configurable:!0})}}var i=function(r,p,b,S,N,B,k){var A={$$typeof:n,type:r,key:p,ref:b,props:k,_owner:B};return A._store={},Object.defineProperty(A._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(A,"_self",{configurable:!1,enumerable:!1,writable:!1,value:S}),Object.defineProperty(A,"_source",{configurable:!1,enumerable:!1,writable:!1,value:N}),Object.freeze&&(Object.freeze(A.props),Object.freeze(A)),A};function E(r,p,b,S,N){{var B,k={},A=null,ce=null;b!==void 0&&(pt(b),A=""+b),_t(p)&&(pt(p.key),A=""+p.key),Rt(p)&&(ce=p.ref,mt(p,N));for(B in p)we.call(p,B)&&!Ke.hasOwnProperty(B)&&(k[B]=p[B]);if(r&&r.defaultProps){var J=r.defaultProps;for(B in J)k[B]===void 0&&(k[B]=J[B])}if(A||ce){var ee=typeof r=="function"?r.displayName||r.name||"Unknown":r;A&&Ce(k,ee),ce&&Vt(k,ee)}return i(r,A,ce,N,S,Ee.current,k)}}var M=V.ReactCurrentOwner,F=V.ReactDebugCurrentFrame;function Z(r){if(r){var p=r._owner,b=xe(r.type,r._source,p?p.type:null);F.setExtraStackFrame(b)}else F.setExtraStackFrame(null)}var ue;ue=!1;function re(r){return typeof r=="object"&&r!==null&&r.$$typeof===n}function At(){{if(M.current){var r=Y(M.current.type);if(r)return`
17
+ */var Wt;function Kn(){return Wt||(Wt=1,process.env.NODE_ENV!=="production"&&function(){var t=R,n=Symbol.for("react.element"),a=Symbol.for("react.portal"),e=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),m=Symbol.for("react.provider"),s=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),y=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),w=Symbol.for("react.offscreen"),T=Symbol.iterator,j="@@iterator";function q(i){if(i===null||typeof i!="object")return null;var h=T&&i[T]||i[j];return typeof h=="function"?h:null}var V=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function x(i){{for(var h=arguments.length,b=new Array(h>1?h-1:0),C=1;C<h;C++)b[C-1]=arguments[C];H("error",i,b)}}function H(i,h,b){{var C=V.ReactDebugCurrentFrame,N=C.getStackAddendum();N!==""&&(h+="%s",b=b.concat([N]));var B=b.map(function(k){return String(k)});B.unshift("Warning: "+h),Function.prototype.apply.call(console[i],console,B)}}var be=!1,le=!1,se=!1,f=!1,v=!1,O;O=Symbol.for("react.module.reference");function P(i){return!!(typeof i=="string"||typeof i=="function"||i===e||i===l||v||i===o||i===p||i===g||f||i===w||be||le||se||typeof i=="object"&&i!==null&&(i.$$typeof===S||i.$$typeof===y||i.$$typeof===m||i.$$typeof===s||i.$$typeof===d||i.$$typeof===O||i.getModuleId!==void 0))}function G(i,h,b){var C=i.displayName;if(C)return C;var N=h.displayName||h.name||"";return N!==""?b+"("+N+")":b}function z(i){return i.displayName||"Context"}function Y(i){if(i==null)return null;if(typeof i.tag=="number"&&x("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 l:return"Profiler";case o:return"StrictMode";case p:return"Suspense";case g:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case s:var h=i;return z(h)+".Consumer";case m:var b=i;return z(b._context)+".Provider";case d:return G(i,i.render,"ForwardRef");case y:var C=i.displayName||null;return C!==null?C:Y(i.type)||"Memo";case S:{var N=i,B=N._payload,k=N._init;try{return Y(k(B))}catch{return null}}}return null}var L=Object.assign,K=0,X,_,U,Q,he,ye,ot;function Ge(){}Ge.__reactDisabledLog=!0;function xt(){{if(K===0){X=console.log,_=console.info,U=console.warn,Q=console.error,he=console.group,ye=console.groupCollapsed,ot=console.groupEnd;var i={configurable:!0,enumerable:!0,value:Ge,writable:!0};Object.defineProperties(console,{info:i,log:i,warn:i,error:i,group:i,groupCollapsed:i,groupEnd:i})}K++}}function Ot(){{if(K--,K===0){var i={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:L({},i,{value:X}),info:L({},i,{value:_}),warn:L({},i,{value:U}),error:L({},i,{value:Q}),group:L({},i,{value:he}),groupCollapsed:L({},i,{value:ye}),groupEnd:L({},i,{value:ot})})}K<0&&x("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var We=V.ReactCurrentDispatcher,$e;function Le(i,h,b){{if($e===void 0)try{throw Error()}catch(N){var C=N.stack.trim().match(/\n( *(at )?)/);$e=C&&C[1]||""}return`
18
+ `+$e+i}}var Fe=!1,Ce;{var st=typeof WeakMap=="function"?WeakMap:Map;Ce=new st}function ct(i,h){if(!i||Fe)return"";{var b=Ce.get(i);if(b!==void 0)return b}var C;Fe=!0;var N=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var B;B=We.current,We.current=null,xt();try{if(h){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(me){C=me}Reflect.construct(i,[],k)}else{try{k.call()}catch(me){C=me}i.call(k.prototype)}}else{try{throw Error()}catch(me){C=me}i()}}catch(me){if(me&&C&&typeof me.stack=="string"){for(var A=me.stack.split(`
19
+ `),ce=C.stack.split(`
20
+ `),J=A.length-1,ee=ce.length-1;J>=1&&ee>=0&&A[J]!==ce[ee];)ee--;for(;J>=1&&ee>=0;J--,ee--)if(A[J]!==ce[ee]){if(J!==1||ee!==1)do if(J--,ee--,ee<0||A[J]!==ce[ee]){var pe=`
21
+ `+A[J].replace(" at new "," at ");return i.displayName&&pe.includes("<anonymous>")&&(pe=pe.replace("<anonymous>",i.displayName)),typeof i=="function"&&Ce.set(i,pe),pe}while(J>=1&&ee>=0);break}}}finally{Fe=!1,We.current=B,Ot(),Error.prepareStackTrace=N}var Be=i?i.displayName||i.name:"",Yt=Be?Le(Be):"";return typeof i=="function"&&Ce.set(i,Yt),Yt}function Mt(i,h,b){return ct(i,!1)}function lt(i){var h=i.prototype;return!!(h&&h.isReactComponent)}function we(i,h,b){if(i==null)return"";if(typeof i=="function")return ct(i,lt(i));if(typeof i=="string")return Le(i);switch(i){case p:return Le("Suspense");case g:return Le("SuspenseList")}if(typeof i=="object")switch(i.$$typeof){case d:return Mt(i.render);case y:return we(i.type,h,b);case S:{var C=i,N=C._payload,B=C._init;try{return we(B(N),h,b)}catch{}}}return""}var xe=Object.prototype.hasOwnProperty,ut={},dt=V.ReactDebugCurrentFrame;function Oe(i){if(i){var h=i._owner,b=we(i.type,i._source,h?h.type:null);dt.setExtraStackFrame(b)}else dt.setExtraStackFrame(null)}function qe(i,h,b,C,N){{var B=Function.call.bind(xe);for(var k in i)if(B(i,k)){var A=void 0;try{if(typeof i[k]!="function"){var ce=Error((C||"React class")+": "+b+" 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 ce.name="Invariant Violation",ce}A=i[k](h,k,C,b,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(J){A=J}A&&!(A instanceof Error)&&(Oe(N),x("%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).",C||"React class",b,k,typeof A),Oe(null)),A instanceof Error&&!(A.message in ut)&&(ut[A.message]=!0,Oe(N),x("Failed %s type: %s",b,A.message),Oe(null))}}}var Me=Array.isArray;function Ke(i){return Me(i)}function Tt(i){{var h=typeof Symbol=="function"&&Symbol.toStringTag,b=h&&i[Symbol.toStringTag]||i.constructor.name||"Object";return b}}function pt(i){try{return ft(i),!1}catch{return!0}}function ft(i){return""+i}function ht(i){if(pt(i))return x("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Tt(i)),ft(i)}var Ee=V.ReactCurrentOwner,Xe={key:!0,ref:!0,__self:!0,__source:!0},Ze,mt,Ue;Ue={};function Rt(i){if(xe.call(i,"ref")){var h=Object.getOwnPropertyDescriptor(i,"ref").get;if(h&&h.isReactWarning)return!1}return i.ref!==void 0}function _t(i){if(xe.call(i,"key")){var h=Object.getOwnPropertyDescriptor(i,"key").get;if(h&&h.isReactWarning)return!1}return i.key!==void 0}function vt(i,h){if(typeof i.ref=="string"&&Ee.current&&h&&Ee.current.stateNode!==h){var b=Y(Ee.current.type);Ue[b]||(x('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',Y(Ee.current.type),i.ref),Ue[b]=!0)}}function Se(i,h){{var b=function(){Ze||(Ze=!0,x("%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)",h))};b.isReactWarning=!0,Object.defineProperty(i,"key",{get:b,configurable:!0})}}function zt(i,h){{var b=function(){mt||(mt=!0,x("%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)",h))};b.isReactWarning=!0,Object.defineProperty(i,"ref",{get:b,configurable:!0})}}var r=function(i,h,b,C,N,B,k){var A={$$typeof:n,type:i,key:h,ref:b,props:k,_owner:B};return A._store={},Object.defineProperty(A._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(A,"_self",{configurable:!1,enumerable:!1,writable:!1,value:C}),Object.defineProperty(A,"_source",{configurable:!1,enumerable:!1,writable:!1,value:N}),Object.freeze&&(Object.freeze(A.props),Object.freeze(A)),A};function E(i,h,b,C,N){{var B,k={},A=null,ce=null;b!==void 0&&(ht(b),A=""+b),_t(h)&&(ht(h.key),A=""+h.key),Rt(h)&&(ce=h.ref,vt(h,N));for(B in h)xe.call(h,B)&&!Xe.hasOwnProperty(B)&&(k[B]=h[B]);if(i&&i.defaultProps){var J=i.defaultProps;for(B in J)k[B]===void 0&&(k[B]=J[B])}if(A||ce){var ee=typeof i=="function"?i.displayName||i.name||"Unknown":i;A&&Se(k,ee),ce&&zt(k,ee)}return r(i,A,ce,N,C,Ee.current,k)}}var M=V.ReactCurrentOwner,F=V.ReactDebugCurrentFrame;function Z(i){if(i){var h=i._owner,b=we(i.type,i._source,h?h.type:null);F.setExtraStackFrame(b)}else F.setExtraStackFrame(null)}var ue;ue=!1;function ie(i){return typeof i=="object"&&i!==null&&i.$$typeof===n}function At(){{if(M.current){var i=Y(M.current.type);if(i)return`
22
22
 
23
- Check the render method of \``+r+"`."}return""}}function Pt(r){{if(r!==void 0){var p=r.fileName.replace(/^.*[\\\/]/,""),b=r.lineNumber;return`
23
+ Check the render method of \``+i+"`."}return""}}function Pt(i){{if(i!==void 0){var h=i.fileName.replace(/^.*[\\\/]/,""),b=i.lineNumber;return`
24
24
 
25
- Check your code at `+p+":"+b+"."}return""}}var Je={};function pe(r){{var p=At();if(!p){var b=typeof r=="string"?r:r.displayName||r.name;b&&(p=`
25
+ Check your code at `+h+":"+b+"."}return""}}var Je={};function fe(i){{var h=At();if(!h){var b=typeof i=="string"?i:i.displayName||i.name;b&&(h=`
26
26
 
27
- Check the top-level render call using <`+b+">.")}return p}}function de(r,p){{if(!r._store||r._store.validated||r.key!=null)return;r._store.validated=!0;var b=pe(p);if(Je[b])return;Je[b]=!0;var S="";r&&r._owner&&r._owner!==M.current&&(S=" It was passed a child from "+Y(r._owner.type)+"."),Z(r),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',b,S),Z(null)}}function Te(r,p){{if(typeof r!="object")return;if(Xe(r))for(var b=0;b<r.length;b++){var S=r[b];re(S)&&de(S,p)}else if(re(r))r._store&&(r._store.validated=!0);else if(r){var N=q(r);if(typeof N=="function"&&N!==r.entries)for(var B=N.call(r),k;!(k=B.next()).done;)re(k.value)&&de(k.value,p)}}}function Re(r){{var p=r.type;if(p==null||typeof p=="string")return;var b;if(typeof p=="function")b=p.propTypes;else if(typeof p=="object"&&(p.$$typeof===d||p.$$typeof===y))b=p.propTypes;else return;if(b){var S=Y(p);qe(b,r.props,"prop",S,r)}else if(p.PropTypes!==void 0&&!ue){ue=!0;var N=Y(p);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",N||"Unknown")}typeof p.getDefaultProps=="function"&&!p.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function _e(r){{for(var p=Object.keys(r.props),b=0;b<p.length;b++){var S=p[b];if(S!=="children"&&S!=="key"){Z(r),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",S),Z(null);break}}r.ref!==null&&(Z(r),w("Invalid attribute `ref` supplied to `React.Fragment`."),Z(null))}}function Ae(r,p,b,S,N,B){{var k=P(r);if(!k){var A="";(r===void 0||typeof r=="object"&&r!==null&&Object.keys(r).length===0)&&(A+=" 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 ce=Pt(N);ce?A+=ce:A+=At();var J;r===null?J="null":Xe(r)?J="array":r!==void 0&&r.$$typeof===n?(J="<"+(Y(r.type)||"Unknown")+" />",A=" Did you accidentally export a JSX literal instead of a component?"):J=typeof r,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",J,A)}var ee=E(r,p,b,N,B);if(ee==null)return ee;if(k){var fe=p.children;if(fe!==void 0)if(S)if(Xe(fe)){for(var Be=0;Be<fe.length;Be++)Te(fe[Be],r);Object.freeze&&Object.freeze(fe)}else w("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 Te(fe,r)}return r===e?_e(ee):Re(ee),ee}}function bn(r,p,b){return Ae(r,p,b,!0)}function yn(r,p,b){return Ae(r,p,b,!1)}var En=yn,Cn=bn;et.Fragment=e,et.jsx=En,et.jsxs=Cn}()),et}process.env.NODE_ENV==="production"?Nt.exports=Bn():Nt.exports=Vn();var u=Nt.exports;function Ut(t){return t.title.search("<")>-1?u.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:t.title}}):u.jsx("button",{children:t.title})}const zn=u.jsxs("svg",{className:"closeIcon",width:"14",height:"14",fill:"none",stroke:"#666666",strokeMiterlimit:"10",children:[u.jsx("circle",{cx:"7",cy:"7",r:"6"}),u.jsx("line",{x1:"4",y1:"4",x2:"10",y2:"10"}),u.jsx("line",{x1:"4",y1:"10",x2:"10",y2:"4"})]}),Yn=u.jsx("svg",{className:"dragIcon",width:"14",height:"14",fill:"#666666",stroke:"none",children:u.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 <`+b+">.")}return h}}function de(i,h){{if(!i._store||i._store.validated||i.key!=null)return;i._store.validated=!0;var b=fe(h);if(Je[b])return;Je[b]=!0;var C="";i&&i._owner&&i._owner!==M.current&&(C=" It was passed a child from "+Y(i._owner.type)+"."),Z(i),x('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',b,C),Z(null)}}function Te(i,h){{if(typeof i!="object")return;if(Ke(i))for(var b=0;b<i.length;b++){var C=i[b];ie(C)&&de(C,h)}else if(ie(i))i._store&&(i._store.validated=!0);else if(i){var N=q(i);if(typeof N=="function"&&N!==i.entries)for(var B=N.call(i),k;!(k=B.next()).done;)ie(k.value)&&de(k.value,h)}}}function Re(i){{var h=i.type;if(h==null||typeof h=="string")return;var b;if(typeof h=="function")b=h.propTypes;else if(typeof h=="object"&&(h.$$typeof===d||h.$$typeof===y))b=h.propTypes;else return;if(b){var C=Y(h);qe(b,i.props,"prop",C,i)}else if(h.PropTypes!==void 0&&!ue){ue=!0;var N=Y(h);x("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",N||"Unknown")}typeof h.getDefaultProps=="function"&&!h.getDefaultProps.isReactClassApproved&&x("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function _e(i){{for(var h=Object.keys(i.props),b=0;b<h.length;b++){var C=h[b];if(C!=="children"&&C!=="key"){Z(i),x("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",C),Z(null);break}}i.ref!==null&&(Z(i),x("Invalid attribute `ref` supplied to `React.Fragment`."),Z(null))}}function Ae(i,h,b,C,N,B){{var k=P(i);if(!k){var A="";(i===void 0||typeof i=="object"&&i!==null&&Object.keys(i).length===0)&&(A+=" 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 ce=Pt(N);ce?A+=ce:A+=At();var J;i===null?J="null":Ke(i)?J="array":i!==void 0&&i.$$typeof===n?(J="<"+(Y(i.type)||"Unknown")+" />",A=" Did you accidentally export a JSX literal instead of a component?"):J=typeof i,x("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",J,A)}var ee=E(i,h,b,N,B);if(ee==null)return ee;if(k){var pe=h.children;if(pe!==void 0)if(C)if(Ke(pe)){for(var Be=0;Be<pe.length;Be++)Te(pe[Be],i);Object.freeze&&Object.freeze(pe)}else x("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 Te(pe,i)}return i===e?_e(ee):Re(ee),ee}}function Sn(i,h,b){return Ae(i,h,b,!0)}function Cn(i,h,b){return Ae(i,h,b,!1)}var wn=Cn,xn=Sn;et.Fragment=e,et.jsx=wn,et.jsxs=xn}()),et}process.env.NODE_ENV==="production"?Nt.exports=qn():Nt.exports=Kn();var u=Nt.exports;function Bt(t){return t.title.search("<")>-1?u.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:t.title}}):u.jsx("button",{children:t.title})}const Xn=u.jsxs("svg",{className:"closeIcon",width:"14",height:"14",fill:"none",stroke:"#666666",strokeMiterlimit:"10",children:[u.jsx("circle",{cx:"7",cy:"7",r:"6"}),u.jsx("line",{x1:"4",y1:"4",x2:"10",y2:"10"}),u.jsx("line",{x1:"4",y1:"10",x2:"10",y2:"4"})]}),Zn=u.jsx("svg",{className:"dragIcon",width:"14",height:"14",fill:"#666666",stroke:"none",children:u.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 cn(t){return u.jsx(en.Reorder.Item,{value:t.title,children:u.jsxs("div",{children:[Yn,u.jsx("span",{children:t.title}),u.jsx("button",{className:"closeIcon",onClick:()=>{t.onDelete(t.index)},children:zn})]})},t.title)}function ln(t){const[n,a]=R.useState(!1),[e,o]=R.useState(t.options),l=h=>{t.onDragComplete(h),o(h)},v=h=>{const g=[...e];g.splice(h,1),l(g)},c=[];e.forEach((h,g)=>{c.push(u.jsx(cn,{index:g,title:h,onDelete:v},h))});let d="dropdown draggable";return t.subdropdown&&(d+=" subdropdown"),u.jsxs("div",{className:d,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[u.jsx(Ut,{title:t.title}),u.jsx(en.Reorder.Group,{axis:"y",values:e,onReorder:l,style:{visibility:n?"visible":"hidden"},children:c})]})}function un(t){const[n,a]=R.useState(!1),e=[];t.options.map((l,v)=>{t.onSelect!==void 0&&(l.onSelect=t.onSelect),e.push(u.jsx(dn,{option:l},v))});let o="dropdown";return t.subdropdown&&(o+=" subdropdown"),u.jsxs("div",{className:o,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[u.jsx(Ut,{title:t.title}),u.jsx("ul",{style:{visibility:n?"visible":"hidden"},children:e})]})}function dn(t){const{option:n}=t,[a,e]=R.useState("");let o;switch(n.type){case"draggable":o=u.jsx(ln,{title:n.title,options:n.value,onDragComplete:l=>{n.onDragComplete!==void 0&&n.onDragComplete(l)},subdropdown:!0});break;case"dropdown":o=u.jsx(un,{title:n.title,options:n.value,onSelect:n.onSelect,subdropdown:!0});break;case"option":o=u.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 u.jsx("li",{className:a===n.title?"selected":"",children:o},nn())}function Gn(t){function n(e){switch(t.components.forEach(o=>{o.handleApp(e)}),e.event){case"custom":j.dispatchEvent({type:I.CUSTOM,value:e.data});break}}function a(e){switch(t.components.forEach(o=>{o.handleEditor(e)}),e.event){case"custom":j.dispatchEvent({type:I.CUSTOM,value:e.data});break}}t.listen=e=>{e.target==="editor"?a(e):n(e)}}const Hn=`out vec3 worldPosition;
30
- uniform float uDistance;
31
-
32
- void main() {
33
- // Scale the plane by the drawing distance
34
- worldPosition = position.xzy * uDistance;
35
- worldPosition.xz += cameraPosition.xz;
36
-
37
- gl_Position = projectionMatrix * modelViewMatrix * vec4(worldPosition, 1.0);
38
- }`,Wn=`out vec4 fragColor;
39
- in vec3 worldPosition;
40
-
41
- uniform float uDivisions;
42
- uniform float uScale;
43
- uniform vec3 uColor;
44
- uniform float uDistance;
45
- uniform float uSubgridOpacity;
46
- uniform float uGridOpacity;
47
-
48
- float getGrid(float gapSize) {
49
- vec2 worldPositionByDivision = worldPosition.xz / gapSize;
50
-
51
- // Inverted, 0 where line, >1 where there's no line
52
- // We use the worldPosition (which in this case we use similarly to UVs) differential to control the anti-aliasing
53
- // We need to do the -0.5)-0.5 trick because the result fades out from 0 to 1, and we want both
54
- // worldPositionByDivision == 0.3 and worldPositionByDivision == 0.7 to result in the same fade, i.e. 0.3,
55
- // otherwise only one side of the line will be anti-aliased
56
- vec2 grid = abs(fract(worldPositionByDivision-0.5)-0.5) / fwidth(worldPositionByDivision) / 2.0;
57
- float gridLine = min(grid.x, grid.y);
58
-
59
- // Uninvert and clamp
60
- return 1.0 - min(gridLine, 1.0);
61
- }
62
-
63
- void main() {
64
- float cameraDistanceToGridPlane = distance(cameraPosition.y, worldPosition.y);
65
- float cameraDistanceToFragmentOnGridPlane = distance(cameraPosition.xz, worldPosition.xz);
66
-
67
- // The size of the grid and subgrid are powers of each other and they are determined based on camera distance.
68
- // The current grid will become the next subgrid when it becomes too small, and its next power becomes the new grid.
69
- float subGridPower = pow(uDivisions, floor(log(cameraDistanceToGridPlane) / log(uDivisions)));
70
- float gridPower = subGridPower * uDivisions;
71
-
72
- // If we want to fade both the grid and its subgrid, we need to displays 3 different opacities, with the next grid being the third
73
- float nextGridPower = gridPower * uDivisions;
74
-
75
- // 1 where grid, 0 where no grid
76
- float subgrid = getGrid(subGridPower * uScale);
77
- float grid = getGrid(gridPower * uScale);
78
- float nextGrid = getGrid(nextGridPower * uScale);
79
-
80
- // Where we are between the introduction of the current grid power and when we switch to the next grid power
81
- float stepPercentage = (cameraDistanceToGridPlane - subGridPower)/(gridPower - subGridPower);
82
-
83
- // The last x percentage of the current step over which we want to fade
84
- float fadeRange = 0.3;
85
-
86
- // We calculate the fade percentage from the step percentage and the fade range
87
- float fadePercentage = max(stepPercentage - 1.0 + fadeRange, 0.0) / fadeRange;
88
-
89
- // Set base opacity based on how close we are to the drawing distance, with a cubic falloff
90
- float baseOpacity = subgrid * pow(1.0 - min(cameraDistanceToFragmentOnGridPlane / uDistance, 1.0), 3.0);
91
-
92
- // Shade the subgrid
93
- fragColor = vec4(uColor.rgb, (baseOpacity - fadePercentage) * uSubgridOpacity);
94
-
95
- // Somewhat arbitrary additional fade coefficient to counter anti-aliasing popping when switching between grid powers
96
- float fadeCoefficient = 0.5;
97
-
98
- // Shade the grid
99
- fragColor.a = mix(fragColor.a, baseOpacity * uGridOpacity - fadePercentage * (uGridOpacity - uSubgridOpacity) * fadeCoefficient, grid);
100
-
101
- // Shade the next grid
102
- fragColor.a = mix(fragColor.a, baseOpacity * uGridOpacity, nextGrid);
103
-
104
- if (fragColor.a <= 0.0) discard;
105
- }`;class $n extends s.ShaderMaterial{constructor(n){super({extensions:{derivatives:!0},glslVersion:s.GLSL3,side:s.DoubleSide,transparent:!0,uniforms:{uScale:{value:n?.scale!==void 0?n?.scale:.1},uDivisions:{value:n?.divisions!==void 0?n?.divisions:10},uColor:{value:n?.color!==void 0?n?.color:new s.Color(16777215)},uDistance:{value:n?.distance!==void 0?n?.distance:1e4},uSubgridOpacity:{value:n?.subgridOpacity!==void 0?n?.subgridOpacity:.15},uGridOpacity:{value:n?.gridOpacity!==void 0?n?.gridOpacity:.25}},vertexShader:Hn,fragmentShader:Wn,name:"InfiniteGrid",depthWrite:!1})}}class fn extends s.Mesh{gridMaterial;constructor(){const n=new $n;super(new s.PlaneGeometry(2,2),n),this.gridMaterial=n,this.frustumCulled=!1,this.name="InfiniteGridHelper",this.position.y=.1}update(){this.gridMaterial.needsUpdate=!0}}const qn=`#include <common>
29
+ C11,8.22,10.74,8,10.43,8z`})});function dn(t){return u.jsx(nn.Reorder.Item,{value:t.title,children:u.jsxs("div",{children:[Zn,u.jsx("span",{children:t.title}),u.jsx("button",{className:"closeIcon",onClick:()=>{t.onDelete(t.index)},children:Xn})]})},t.title)}function pn(t){const[n,a]=R.useState(!1),[e,o]=R.useState(t.options),l=p=>{t.onDragComplete(p),o(p)},m=p=>{const g=[...e];g.splice(p,1),l(g)},s=[];e.forEach((p,g)=>{s.push(u.jsx(dn,{index:g,title:p,onDelete:m},p))});let d="dropdown draggable";return t.subdropdown&&(d+=" subdropdown"),u.jsxs("div",{className:d,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[u.jsx(Bt,{title:t.title}),u.jsx(nn.Reorder.Group,{axis:"y",values:e,onReorder:l,style:{visibility:n?"visible":"hidden"},children:s})]})}function fn(t){const[n,a]=R.useState(!1),e=[];t.options.map((l,m)=>{t.onSelect!==void 0&&(l.onSelect=t.onSelect),e.push(u.jsx(hn,{option:l},m))});let o="dropdown";return t.subdropdown&&(o+=" subdropdown"),u.jsxs("div",{className:o,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[u.jsx(Bt,{title:t.title}),u.jsx("ul",{style:{visibility:n?"visible":"hidden"},children:e})]})}function hn(t){const{option:n}=t,[a,e]=R.useState("");let o;switch(n.type){case"draggable":o=u.jsx(pn,{title:n.title,options:n.value,onDragComplete:l=>{n.onDragComplete!==void 0&&n.onDragComplete(l)},subdropdown:!0});break;case"dropdown":o=u.jsx(fn,{title:n.title,options:n.value,onSelect:n.onSelect,subdropdown:!0});break;case"option":o=u.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 u.jsx("li",{className:a===n.title?"selected":"",children:o},an())}class Ye{appHandlers=[];editorHandlers=[];_app;static _instance;handleAppBroadcast=n=>{switch(this.appHandlers.forEach(a=>{a.callback(this._app,a.remote,n)}),n.event){case"custom":D.dispatchEvent({type:I.CUSTOM,value:n.data});break}};handleEditorBroadcast=n=>{switch(this.editorHandlers.forEach(a=>{a.callback(this._app,a.remote,n)}),n.event){case"custom":D.dispatchEvent({type:I.CUSTOM,value:n.data});break}};set app(n){this._app=n,n.listen=a=>{a.target==="editor"?this.handleEditorBroadcast(a):this.handleAppBroadcast(a)}}static get instance(){return Ye._instance===void 0&&(Ye._instance=new Ye),Ye._instance}}class Jn extends c.ShaderMaterial{constructor(n){super({extensions:{derivatives:!0},glslVersion:c.GLSL3,side:c.DoubleSide,transparent:!0,uniforms:{uScale:{value:n?.scale!==void 0?n?.scale:.1},uDivisions:{value:n?.divisions!==void 0?n?.divisions:10},uColor:{value:n?.color!==void 0?n?.color:new c.Color(16777215)},uDistance:{value:n?.distance!==void 0?n?.distance:1e4},uSubgridOpacity:{value:n?.subgridOpacity!==void 0?n?.subgridOpacity:.15},uGridOpacity:{value:n?.gridOpacity!==void 0?n?.gridOpacity:.25}},vertexShader:`out vec3 worldPosition;
30
+ uniform float uDistance;
31
+
32
+ void main() {
33
+ // Scale the plane by the drawing distance
34
+ worldPosition = position.xzy * uDistance;
35
+ worldPosition.xz += cameraPosition.xz;
36
+
37
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(worldPosition, 1.0);
38
+ }`,fragmentShader:`out vec4 fragColor;
39
+ in vec3 worldPosition;
40
+
41
+ uniform float uDivisions;
42
+ uniform float uScale;
43
+ uniform vec3 uColor;
44
+ uniform float uDistance;
45
+ uniform float uSubgridOpacity;
46
+ uniform float uGridOpacity;
47
+
48
+ float getGrid(float gapSize) {
49
+ vec2 worldPositionByDivision = worldPosition.xz / gapSize;
50
+
51
+ // Inverted, 0 where line, >1 where there's no line
52
+ // We use the worldPosition (which in this case we use similarly to UVs) differential to control the anti-aliasing
53
+ // We need to do the -0.5)-0.5 trick because the result fades out from 0 to 1, and we want both
54
+ // worldPositionByDivision == 0.3 and worldPositionByDivision == 0.7 to result in the same fade, i.e. 0.3,
55
+ // otherwise only one side of the line will be anti-aliased
56
+ vec2 grid = abs(fract(worldPositionByDivision-0.5)-0.5) / fwidth(worldPositionByDivision) / 2.0;
57
+ float gridLine = min(grid.x, grid.y);
58
+
59
+ // Uninvert and clamp
60
+ return 1.0 - min(gridLine, 1.0);
61
+ }
62
+
63
+ void main() {
64
+ float cameraDistanceToGridPlane = distance(cameraPosition.y, worldPosition.y);
65
+ float cameraDistanceToFragmentOnGridPlane = distance(cameraPosition.xz, worldPosition.xz);
66
+
67
+ // The size of the grid and subgrid are powers of each other and they are determined based on camera distance.
68
+ // The current grid will become the next subgrid when it becomes too small, and its next power becomes the new grid.
69
+ float subGridPower = pow(uDivisions, floor(log(cameraDistanceToGridPlane) / log(uDivisions)));
70
+ float gridPower = subGridPower * uDivisions;
71
+
72
+ // If we want to fade both the grid and its subgrid, we need to displays 3 different opacities, with the next grid being the third
73
+ float nextGridPower = gridPower * uDivisions;
74
+
75
+ // 1 where grid, 0 where no grid
76
+ float subgrid = getGrid(subGridPower * uScale);
77
+ float grid = getGrid(gridPower * uScale);
78
+ float nextGrid = getGrid(nextGridPower * uScale);
79
+
80
+ // Where we are between the introduction of the current grid power and when we switch to the next grid power
81
+ float stepPercentage = (cameraDistanceToGridPlane - subGridPower)/(gridPower - subGridPower);
82
+
83
+ // The last x percentage of the current step over which we want to fade
84
+ float fadeRange = 0.3;
85
+
86
+ // We calculate the fade percentage from the step percentage and the fade range
87
+ float fadePercentage = max(stepPercentage - 1.0 + fadeRange, 0.0) / fadeRange;
88
+
89
+ // Set base opacity based on how close we are to the drawing distance, with a cubic falloff
90
+ float baseOpacity = subgrid * pow(1.0 - min(cameraDistanceToFragmentOnGridPlane / uDistance, 1.0), 3.0);
91
+
92
+ // Shade the subgrid
93
+ fragColor = vec4(uColor.rgb, (baseOpacity - fadePercentage) * uSubgridOpacity);
94
+
95
+ // Somewhat arbitrary additional fade coefficient to counter anti-aliasing popping when switching between grid powers
96
+ float fadeCoefficient = 0.5;
97
+
98
+ // Shade the grid
99
+ fragColor.a = mix(fragColor.a, baseOpacity * uGridOpacity - fadePercentage * (uGridOpacity - uSubgridOpacity) * fadeCoefficient, grid);
100
+
101
+ // Shade the next grid
102
+ fragColor.a = mix(fragColor.a, baseOpacity * uGridOpacity, nextGrid);
103
+
104
+ if (fragColor.a <= 0.0) discard;
105
+ }`,name:"InfiniteGrid",depthWrite:!1})}}class mn extends c.Mesh{gridMaterial;constructor(){const n=new Jn;super(new c.PlaneGeometry(2,2),n),this.gridMaterial=n,this.frustumCulled=!1,this.name="InfiniteGridHelper",this.position.y=.1}update(){this.gridMaterial.needsUpdate=!0}}const Qn=`#include <common>
106
106
  #include <batching_pars_vertex>
107
107
  #include <uv_pars_vertex>
108
108
  #include <color_pars_vertex>
@@ -132,7 +132,7 @@ void main() {
132
132
  #include <logdepthbuf_vertex>
133
133
  #include <clipping_planes_vertex>
134
134
  #include <worldpos_vertex>
135
- }`,Xn=`
135
+ }`,ea=`
136
136
  #include <common>
137
137
  #include <uv_pars_fragment>
138
138
  #include <clipping_planes_pars_fragment>
@@ -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 pn extends s.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:qn,fragmentShader:Xn})}}function St(t){const[n,a]=R.useState(t.open!==void 0?t.open:!0),e=!n||t.children===void 0;return u.jsxs("div",{className:`accordion ${e?"hide":""}`,children:[u.jsxs("button",{className:"toggle",onClick:()=>{const o=!n;t.onToggle!==void 0&&t.onToggle(o),a(o)},children:[u.jsx("p",{className:`status ${n?"open":""}`,children:"Toggle"}),u.jsx("p",{className:"label",children:Ge(t.label)})]}),t.button,u.jsx("div",{className:n?"open":"",children:u.jsx("div",{children:t.children})})]})}function Bt(t){const[n,a]=R.useState(!1),e=t.child!==void 0&&t.child.children.length>0,o=[];return t.child!==void 0&&t.child.children.length>0&&t.child.children.map(l=>{o.push(u.jsx(Bt,{child:l,three:t.three},Math.random()))}),u.jsx(u.Fragment,{children:t.child!==void 0&&u.jsxs("div",{className:"childObject",children:[u.jsxs("div",{className:"child",children:[e?u.jsx("button",{className:"status",style:{backgroundPositionX:n?"-14px":"2px"},onClick:()=>{a(!n)}}):null,u.jsx("button",{className:"name",style:{left:e?"20px":"5px"},onClick:()=>{t.child!==void 0&&(t.three.getObject(t.child.uuid),n||a(!0))},children:t.child.name.length>0?`${t.child.name} (${t.child.type})`:`${t.child.type}::${t.child.uuid}`}),u.jsx("div",{className:`icon ${jn(t.child)}`})]}),u.jsx("div",{className:n?"open":"",children:u.jsx("div",{className:"container",children:o})})]},Math.random())})}function hn(t){const n=[];return t.child?.children.map(a=>{n.push(u.jsx(Bt,{child:a,three:t.three},Math.random()))}),u.jsx("div",{className:`scene ${t.class!==void 0?t.class:""}`,children:n})}const Kn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA5klEQVRoge2Y0Q6EIAwE6cX//+X6cCFpSMEKVTdk501OpRNKiyelFC0b8Ps6gCwoggZF0KAIGhRBgyJoUAQNiqCxjciR9SLV//eZiAyvK3U8i/QVaQO2YyLSFVvlkdTKDjJCukh2ykR5ZEW+kHmlatl90RaBtDkK/w7CYhuRUEO0ee3l+J3m55Vm+17vtwjTnV1V3QA8qfbeUXCzRWDpiLLS+OyzvRW7IzW9R+okvclsqR09743bo0yUpc1+lSJvNsa002+Euk9GKzV7SmZDRIMiaFAEDYqgQRE0KIIGRdCgCBoUQeMEMERadX7YUz8AAAAASUVORK5CYII=";function Zn(t){return"items"in t}function Ie(t){const n=[];return t.items.forEach(a=>{Zn(a)?n.push(u.jsx(Ie,{title:Ge(a.title),items:a.items},Math.random())):n.push(u.jsx(nt,{title:a.title,prop:a.prop,value:a.value,type:a.type,min:a.min,max:a.max,step:a.step,disabled:a.disabled,options:a.options,onChange:(e,o)=>{a.onChange!==void 0&&a.onChange(e,o)}},Math.random()))}),u.jsx(St,{label:t.title,open:t.expanded===!0,children:n})}function Jn(t){return!(t==="alphaHash"||t==="alphaToCoverage"||t==="attenuationDistance"||t==="blendDstAlpha"||t==="colorWrite"||t==="combine"||t==="defaultAttributeValues"||t==="depthFunc"||t==="forceSinglePass"||t==="glslVersion"||t==="linecap"||t==="linejoin"||t==="linewidth"||t==="normalMapType"||t==="precision"||t==="premultipliedAlpha"||t==="shadowSide"||t==="toneMapped"||t==="uniformsGroups"||t==="uniformsNeedUpdate"||t==="userData"||t==="vertexColors"||t==="version"||t==="wireframeLinecap"||t==="wireframeLinejoin"||t==="wireframeLinewidth"||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"blendAlpha":return"Blend Alpha";case"blendColor":return"Blend Color";case"blendDst":return"Blend Dst";case"blendDstAlpha":return"Blend Dst Alha";case"blendEquation":return"Blend Equation";case"blendEquationAlpha":return"Blend Equation Alpha";case"blending":return"Blending";case"blendSrc":return"Blend Src";case"blendSrcAlpha":return"Blend Src Alpha";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"side":return"Side";case"size":return"Size";case"sizeAttenuation":return"Size Attenuation";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 Qn(t){return t.toLowerCase().search("intensity")>-1||t==="anisotropyRotation"||t==="blendAlpha"||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],o=new FileReader;o.onload=function(l){n(l.target.result)},o.readAsDataURL(e)}}),t.click()})}const ta=[{title:"Front",value:s.FrontSide},{title:"Back",value:s.BackSide},{title:"Double",value:s.DoubleSide}],na=[{title:"No Blending",value:s.NoBlending},{title:"Normal",value:s.NormalBlending},{title:"Additive",value:s.AdditiveBlending},{title:"Subtractive",value:s.SubtractiveBlending},{title:"Multiply",value:s.MultiplyBlending},{title:"Custom",value:s.CustomBlending}],aa=[{title:"Add",value:s.AddEquation},{title:"Subtract",value:s.SubtractEquation},{title:"Reverse Subtract",value:s.ReverseSubtractEquation},{title:"Min",value:s.MinEquation},{title:"Max",value:s.MaxEquation}],ra=[{title:"Zero",valye:s.ZeroFactor},{title:"One",valye:s.OneFactor},{title:"Src Color",valye:s.SrcColorFactor},{title:"One Minus Src Color",valye:s.OneMinusSrcColorFactor},{title:"Src Alpha",valye:s.SrcAlphaFactor},{title:"One Minus Src Alpha",valye:s.OneMinusSrcAlphaFactor},{title:"Dst Alpha",valye:s.DstAlphaFactor},{title:"One Minus Dst Alpha",valye:s.OneMinusDstAlphaFactor},{title:"Dst Color",valye:s.DstColorFactor},{title:"One Minus Dst Color",valye:s.OneMinusDstColorFactor},{title:"Src Alpha Saturate",valye:s.SrcAlphaSaturateFactor},{title:"Constant Color",valye:s.ConstantColorFactor},{title:"One Minus Constant Color",valye:s.OneMinusConstantColorFactor},{title:"Constant Alpha",valye:s.ConstantAlphaFactor},{title:"One Minus Constant Alpha",valye:s.OneMinusConstantAlphaFactor}],ia=[{title:"Zero",valye:s.ZeroFactor},{title:"One",valye:s.OneFactor},{title:"Src Color",valye:s.SrcColorFactor},{title:"One Minus Src Color",valye:s.OneMinusSrcColorFactor},{title:"Src Alpha",valye:s.SrcAlphaFactor},{title:"One Minus Src Alpha",valye:s.OneMinusSrcAlphaFactor},{title:"Dst Alpha",valye:s.DstAlphaFactor},{title:"One Minus Dst Alpha",valye:s.OneMinusDstAlphaFactor},{title:"Dst Color",valye:s.DstColorFactor},{title:"One Minus Dst Color",valye:s.OneMinusDstColorFactor},{title:"Constant Color",valye:s.ConstantColorFactor},{title:"One Minus Constant Color",valye:s.OneMinusConstantColorFactor},{title:"Constant Alpha",valye:s.ConstantAlphaFactor},{title:"One Minus Constant Alpha",valye:s.OneMinusConstantAlphaFactor}];function tt(t,n){t.needsUpdate=!0,t.type="option",t.options=n}function Ht(t,n,a){const e=[];for(const o in t){if(!Jn(o))continue;const l=typeof t[o],v=t[o];if(l==="boolean"||l==="number"||l==="string"){const c={title:Pe(o),prop:o,type:l,value:v,min:void 0,max:void 0,needsUpdate:l==="boolean",onChange:(h,g)=>{a.updateObject(n.uuid,`material.${h}`,g),c.needsUpdate&&a.updateObject(n.uuid,"material.needsUpdate",!0);const y=a.scene?.getObjectByProperty("uuid",n.uuid);y!==void 0&&te(y,`material.${h}`,g)}};switch(o){case"blending":tt(c,na);break;case"blendDst":tt(c,ia);break;case"blendEquation":tt(c,aa);break;case"blendSrc":tt(c,ra);break;case"side":tt(c,ta);break}Qn(o)&&(c.value=Number(v),c.type="range",c.min=0,c.max=1,c.step=.01);const d=l==="string"&&(o==="vertexShader"||o==="fragmentShader");d&&(c.disabled=!1,c.latest=c.value,c.onChange=(h,g)=>{c.latest=g}),e.push(c),d&&e.push({title:`${Ge(o)} - Update`,type:"button",onChange:()=>{a.updateObject(n.uuid,`material.${o}`,c.latest),a.updateObject(n.uuid,"material.needsUpdate",!0);const h=a.scene?.getObjectByProperty("uuid",n.uuid);h!==void 0&&(te(h,`material.${o}`,c.latest),h.material.needsUpdate=!0)}})}else if(l==="object")if(v.isColor)e.push({title:Pe(o),prop:o,type:"color",value:v,onChange:(c,d)=>{const h=new s.Color(d);a.updateObject(n.uuid,`material.${c}`,h);const g=a.scene?.getObjectByProperty("uuid",n.uuid);g!==void 0&&te(g,`material.${c}`,h)}});else if(Array.isArray(v)){const c=[];for(const d in v)c.push({title:`${d}`,type:`${typeof v[d]}`,value:v[d],onChange:(h,g)=>{a.updateObject(n.uuid,`material.${o}`,g);const y=a.scene?.getObjectByProperty("uuid",n.uuid);y!==void 0&&te(y,`material.${o}`,g)}});e.push({title:Pe(o),items:c})}else{const c=[];for(const d in v){const h=v[d];switch(typeof h){case"boolean":case"number":case"string":d==="src"?e.push({title:Pe(o),type:"image",value:h,onChange:(y,C)=>{a.createTexture(n.uuid,`material.${o}`,C);const x=a.scene?.getObjectByProperty("uuid",n.uuid);x!==void 0&&It(C).then(T=>{te(x,`material.${o}`,T),te(x,"material.needsUpdate",!0)})}}):c.push({title:`${Pe(d)}`,prop:`material.${o}.${d}`,type:`${typeof t[o][d]}`,value:v[d],onChange:(y,C)=>{a.updateObject(n.uuid,`material.${o}.${d}`,C);const x=a.scene?.getObjectByProperty("uuid",n.uuid);x!==void 0&&te(x,`material.${o}.${d}`,C)}});break;case"object":if(h.value!==void 0&&h.value.src!==void 0)c.push({title:Pe(d),type:"image",value:h.value.src,onChange:(y,C)=>{a.createTexture(n.uuid,`material.${o}.${d}.value`,v);const x=a.scene?.getObjectByProperty("uuid",n.uuid);x!==void 0&&It(C).then(T=>{te(x,`material.${o}.${d}.value`,T)})}});else if(o==="uniforms"){const y=h.value,C=(x,T,D)=>({title:x,type:"number",value:D,step:.01,onChange:(q,V)=>{const w=`material.uniforms.${d}.value.${T}`;a.updateObject(n.uuid,w,V);const G=a.scene?.getObjectByProperty("uuid",n.uuid);G!==void 0&&te(G,w,V)}});if(typeof h.value=="number")c.push({title:d,type:"number",value:h.value,onChange:(x,T)=>{const D=`material.${o}.${x}.value`;a.updateObject(n.uuid,D,T);const q=a.scene?.getObjectByProperty("uuid",n.uuid);q!==void 0&&te(q,D,T)}});else if(y.r!==void 0&&y.g!==void 0&&y.b!==void 0)c.push({title:d,type:"color",value:h.value,onChange:(x,T)=>{const D=new s.Color(T),q=`material.${o}.${x}.value`;a.updateObject(n.uuid,q,D);const V=a.scene?.getObjectByProperty("uuid",n.uuid);V!==void 0&&te(V,q,D)}});else if(y.x!==void 0&&y.y!==void 0&&y.z===void 0&&y.w===void 0)c.push({title:d,items:[C("X","x",h.value.x),C("Y","y",h.value.y)]});else if(y.x!==void 0&&y.y!==void 0&&y.z!==void 0&&y.w===void 0)c.push({title:d,items:[C("X","x",h.value.x),C("Y","y",h.value.y),C("Z","z",h.value.z)]});else if(y.x!==void 0&&y.y!==void 0&&y.z!==void 0&&y.w!==void 0)c.push({title:d,items:[C("X","x",h.value.x),C("Y","y",h.value.y),C("Z","z",h.value.z),C("W","w",h.value.w)]});else if(y.elements!==void 0){const x=y.elements,T=[];for(let D=0;D<x.length;D++)T.push(C(D.toString(),D.toString(),x[D]));c.push({title:d,items:T})}else console.log(">>> need to add this format:",d,y)}else c.push({title:d,type:`${typeof h.value}`,value:h.value,onChange:(y,C)=>{a.updateObject(n.uuid,`material.${o}.${d}.value`,C);const x=a.scene?.getObjectByProperty("uuid",n.uuid);x!==void 0&&te(x,`material.${o}.${d}.value`,C)}});break}}c.length>0&&e.push({title:Pe(o),items:c})}else v!==void 0&&console.log("other:",o,l,v)}return e.sort((o,l)=>o.title<l.title?-1:o.title>l.title?1:0),e.push({title:"Update Material",type:"button",onChange:()=>{a.updateObject(n.uuid,"material.needsUpdate",!0)}}),e}function oa(t,n){const a=t.material;if(Array.isArray(a)){const e=[],o=a.length;for(let l=0;l<o;l++)e.push(u.jsx(Ie,{title:`Material ${l}`,items:Ht(a[l],t,n)},`Material ${l}`));return u.jsx(u.Fragment,{children:e})}else return u.jsx(Ie,{title:"Material",items:Ht(a,t,n)})}function nt(t){let n=t.value;n!==void 0&&n.isColor!==void 0&&(n=an(t.value));const[a,e]=R.useState(n),o=R.useRef(null),l=R.useRef(null),v=R.useRef(null);R.useEffect(()=>{let g=!1,y=-1,C=0,x=Number(a);const T=G=>{g=!0,C=x,y=G.clientX},D=G=>{if(!g)return;const be=t.step!==void 0?t.step:1,le=(G.clientX-y)*be;x=Number((C+le).toFixed(4)),l.current!==null&&(l.current.value=x.toString()),t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,x)},q=()=>{g=!1},V=()=>{g=!1},w=t.type==="number";return w&&(o.current?.addEventListener("mousedown",T,!1),document.addEventListener("mouseup",q,!1),document.addEventListener("mousemove",D,!1),document.addEventListener("contextmenu",V,!1)),()=>{w&&(o.current?.removeEventListener("mousedown",T),document.removeEventListener("mouseup",q),document.removeEventListener("mousemove",D),document.removeEventListener("contextmenu",V))}},[a]);const c=t.type==="string"&&(a.length>100||a.search(`
144
- `)>-1),d=c||t.type==="image",h=g=>{let y=g.target.value;t.type==="boolean"?y=g.target.checked:t.type==="option"&&(y=t.options[y].value),e(y),t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,y)};return u.jsxs("div",{className:`field ${d?"block":""}`,children:[t.type!=="button"&&u.jsx("label",{ref:o,children:Ge(t.title)},"fieldLabel"),t.type==="string"&&!c&&u.jsx("input",{type:"text",disabled:t.disabled,onChange:h,value:a}),t.type==="string"&&c&&u.jsx("textarea",{cols:50,rows:10,disabled:t.disabled!==void 0?t.disabled:!0,onChange:h,value:a}),t.type==="boolean"&&u.jsx("input",{type:"checkbox",disabled:t.disabled,onChange:h,checked:a}),t.type==="number"&&u.jsx("input",{ref:l,type:"number",value:a,min:t.min,max:t.max,step:t.step,disabled:t.disabled,onChange:h}),t.type==="range"&&u.jsxs(u.Fragment,{children:[u.jsx("input",{type:"text",value:a.toString(),onChange:h,disabled:t.disabled,className:"min"}),u.jsx("input",{disabled:t.disabled,type:"range",value:a,min:t.min,max:t.max,step:t.step,onChange:h})]}),t.type==="color"&&u.jsxs(u.Fragment,{children:[u.jsx("input",{type:"text",value:a.toString(),onChange:h,disabled:t.disabled,className:"color"}),u.jsx("input",{type:"color",value:a,onChange:h,disabled:t.disabled})]}),t.type==="button"&&u.jsx("button",{disabled:t.disabled,onClick:()=>{t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,!0)},children:t.title}),t.type==="image"&&u.jsx("img",{ref:v,onClick:()=>{ea().then(g=>{v.current.src=g,t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,g)})},src:a.length>0?a:Kn}),t.type==="option"&&u.jsx(u.Fragment,{children:u.jsx("select",{onChange:h,disabled:t.disabled,defaultValue:t.value,children:t.options?.map((g,y)=>u.jsx("option",{value:g.value,children:Ge(g.title)},y))})})]})}function Wt(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 sa(t,n){const a=[];if(t.perspectiveCameraInfo!==void 0)for(const e in t.perspectiveCameraInfo)a.push({title:Wt(e),prop:e,type:"number",step:.01,value:t.perspectiveCameraInfo[e],onChange:(o,l)=>{n.updateObject(t.uuid,o,l),n.requestMethod(t.uuid,"updateProjectionMatrix");const v=n.scene?.getObjectByProperty("uuid",t.uuid);v!==void 0&&(te(v,o,l),v.updateProjectionMatrix())}});else if(t.orthographicCameraInfo!==void 0)for(const e in t.orthographicCameraInfo)a.push({title:Wt(e),prop:e,type:"number",step:.01,value:t.perspectiveCameraInfo[e],onChange:(o,l)=>{n.updateObject(t.uuid,o,l),n.requestMethod(t.uuid,"updateProjectionMatrix");const v=n.scene?.getObjectByProperty("uuid",t.uuid);v!==void 0&&(te(v,o,l),v.updateProjectionMatrix())}});return u.jsx(Ie,{title:"Camera",items:a})}const ca=Math.PI/180,la=180/Math.PI;function Ye(t,n,a,e,o){return e+(t-n)*(o-e)/(a-n)}function ua(t){return t*ca}function Dt(t){return t*la}function da(t,n){const a=new s.Matrix4;a.elements=t.matrix;const e=new s.Vector3,o=new s.Euler,l=new s.Vector3;t.uuid.length>0&&(e.setFromMatrixPosition(a),o.setFromRotationMatrix(a),l.setFromMatrixScale(a));const v=(d,h)=>{n.updateObject(t.uuid,d,h);const g=n.scene?.getObjectByProperty("uuid",t.uuid);g!==void 0&&te(g,d,h)},c=(d,h)=>{v(d,ua(h))};return u.jsx(Ie,{title:"Transform",items:[{title:"Position X",prop:"position.x",type:"number",value:e.x,onChange:v},{title:"Position Y",prop:"position.y",type:"number",value:e.y,onChange:v},{title:"Position Z",prop:"position.z",type:"number",value:e.z,onChange:v},{title:"Rotation X",prop:"rotation.x",type:"number",value:yt(Dt(o.x)),min:-360,max:360,step:.1,onChange:c},{title:"Rotation Y",prop:"rotation.y",type:"number",value:yt(Dt(o.y)),min:-360,max:360,step:.1,onChange:c},{title:"Rotation Z",prop:"rotation.z",type:"number",value:yt(Dt(o.z)),min:-360,max:360,step:.1,onChange:c},{title:"Scale X",prop:"scale.x",type:"number",value:l.x,step:.01,onChange:v},{title:"Scale Y",prop:"scale.y",type:"number",value:l.y,step:.01,onChange:v},{title:"Scale Z",prop:"scale.z",type:"number",value:l.z,step:.01,onChange:v}]})}function $t(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 fa(t,n){const a=[];if(t.lightInfo!==void 0)for(const e in t.lightInfo){const o=t.lightInfo[e];o!==void 0&&(o.isColor!==void 0?a.push({title:$t(e),prop:e,type:"color",value:o,onChange:(l,v)=>{const c=new s.Color(v);n.updateObject(t.uuid,l,c);const d=n.scene?.getObjectByProperty("uuid",t.uuid);d!==void 0&&te(d,l,c)}}):a.push({title:$t(e),prop:e,type:typeof o,value:o,step:typeof o=="number"?.01:void 0,onChange:(l,v)=>{n.updateObject(t.uuid,l,v);const c=n.scene?.getObjectByProperty("uuid",t.uuid);c!==void 0&&te(c,l,v)}}))}return u.jsx(Ie,{title:"Light",items:a})}function pa(t,n){const a=[],e=[];let o=0;t.animations.forEach(c=>{o=Math.max(o,c.duration),c.duration>0&&e.push({title:c.name,items:[{title:"Duration",type:"number",value:c.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),a.push({title:"Animations",items:e});const l=n.scene?.getObjectByProperty("uuid",t.uuid);let v=!1;if(l!==void 0){const c=l.mixer;if(v=c!==void 0,v){const d=[{title:"Time Scale",type:"range",value:c.timeScale,step:.01,min:-1,max:2,onChange:(h,g)=>{c.timeScale=g,n.updateObject(t.uuid,"mixer.timeScale",g)}}];d.push({title:"Stop All",type:"button",onChange:()=>{c.stopAllAction(),n.requestMethod(t.uuid,"stopAllAction",void 0,"mixer")}}),a.push({title:"Mixer",items:d})}}return u.jsx(Ie,{title:"Animation",items:a})}const mn={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 ne={...mn};function vn(t){const[n,a]=R.useState(-1);R.useEffect(()=>{function v(d){ne={...d.value},a(Date.now())}function c(){ne={...mn},a(Date.now())}return j.addEventListener(I.SET_SCENE,c),j.addEventListener(I.SET_OBJECT,v),()=>{j.removeEventListener(I.SET_SCENE,c),j.removeEventListener(I.SET_OBJECT,v)}},[]);const e=ne.type.toLowerCase(),o=ne.animations.length>0||ne.mixer!==void 0,l=e.search("mesh")>-1||e.search("line")>-1||e.search("points")>-1;return u.jsx(St,{label:"Inspector",children:u.jsx("div",{id:"Inspector",className:t.class,children:ne.uuid.length>0&&u.jsxs(u.Fragment,{children:[u.jsxs(u.Fragment,{children:[u.jsx(nt,{type:"string",title:"Name",prop:"name",value:ne.name,disabled:!0}),u.jsx(nt,{type:"string",title:"Type",prop:"type",value:ne.type,disabled:!0}),u.jsx(nt,{type:"string",title:"UUID",prop:"uuid",value:ne.uuid,disabled:!0}),u.jsx(nt,{type:"boolean",title:"Visible",prop:"visible",value:ne.visible,onChange:(v,c)=>{t.three.updateObject(ne.uuid,v,c);const d=t.three.scene?.getObjectByProperty("uuid",ne.uuid);d!==void 0&&te(d,v,c)}})]}),u.jsxs(u.Fragment,{children:[da(ne,t.three),o?pa(ne,t.three):null,e.search("camera")>-1?sa(ne,t.three):null,e.search("light")>-1?fa(ne,t.three):null,l?oa(ne,t.three):null]})]})},n)},"Inspector")}function ha(t){const[n,a]=R.useState(t.scene);R.useEffect(()=>{const l=v=>{a(v.value)};return j.addEventListener(I.SET_SCENE,l),()=>{j.removeEventListener(I.SET_SCENE,l)}},[]);const e=n!==null,o="Hierarchy - "+(e?`${n?.name}`:"No Scene");return u.jsxs("div",{id:"SidePanel",children:[u.jsx(St,{label:o,open:!0,children:u.jsx(u.Fragment,{children:e&&u.jsx(hn,{child:n,three:t.three})})}),u.jsx(vn,{three:t.three})]},"SidePanel")}function ma(t){function n(){return t.three.scene===void 0?(console.log("No scene:",t.three),!1):!0}const a=c=>{if(!n())return;const d=t.three.scene?.getObjectByProperty("uuid",c.value);d!==void 0&&t.three.setObject(d)},e=(c,d,h)=>{if(!n())return;const g=t.three.scene?.getObjectByProperty("uuid",c);g!==void 0&&te(g,d,h)},o=c=>{if(!n())return;const d=c.value,{key:h,value:g,uuid:y}=d;e(y,h,g)},l=c=>{if(!n())return;const d=c.value;It(d.value).then(h=>{e(d.uuid,d.key,h),e(d.uuid,"material.needsUpdate",!0)})},v=c=>{if(!n())return;const{key:d,uuid:h,value:g,subitem:y}=c.value,C=t.three.scene?.getObjectByProperty("uuid",h);if(C!==void 0)try{y!==void 0?Ln(C,y)[d](g):C[d](g)}catch(x){console.log("Error requesting method:"),console.log(x),console.log(d),console.log(g)}};return R.useEffect(()=>(j.addEventListener(I.GET_OBJECT,a),j.addEventListener(I.UPDATE_OBJECT,o),j.addEventListener(I.CREATE_TEXTURE,l),j.addEventListener(I.REQUEST_METHOD,v),()=>{j.removeEventListener(I.GET_OBJECT,a),j.removeEventListener(I.UPDATE_OBJECT,o),j.removeEventListener(I.CREATE_TEXTURE,l),j.removeEventListener(I.REQUEST_METHOD,v)}),[]),null}const qt={type:"change"},jt={type:"start"},Xt={type:"end"},vt=new s.Ray,Kt=new s.Plane,va=Math.cos(70*s.MathUtils.DEG2RAD);class ga extends s.EventDispatcher{constructor(n,a){super(),this.object=n,this.domElement=a,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new s.Vector3,this.cursor=new s.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:s.MOUSE.ROTATE,MIDDLE:s.MOUSE.DOLLY,RIGHT:s.MOUSE.PAN},this.touches={ONE:s.TOUCH.ROTATE,TWO:s.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 c.phi},this.getAzimuthalAngle=function(){return c.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(i){i.addEventListener("keydown",Ke),this._domElementKeyEvents=i},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Ke),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(qt),e.update(),l=o.NONE},this.update=function(){const i=new s.Vector3,E=new s.Quaternion().setFromUnitVectors(n.up,new s.Vector3(0,1,0)),M=E.clone().invert(),F=new s.Vector3,Z=new s.Quaternion,ue=new s.Vector3,re=2*Math.PI;return function(Pt=null){const Je=e.object.position;i.copy(Je).sub(e.target),i.applyQuaternion(E),c.setFromVector3(i),e.autoRotate&&l===o.NONE&&z(P(Pt)),e.enableDamping?(c.theta+=d.theta*e.dampingFactor,c.phi+=d.phi*e.dampingFactor):(c.theta+=d.theta,c.phi+=d.phi);let pe=e.minAzimuthAngle,de=e.maxAzimuthAngle;isFinite(pe)&&isFinite(de)&&(pe<-Math.PI?pe+=re:pe>Math.PI&&(pe-=re),de<-Math.PI?de+=re:de>Math.PI&&(de-=re),pe<=de?c.theta=Math.max(pe,Math.min(de,c.theta)):c.theta=c.theta>(pe+de)/2?Math.max(pe,c.theta):Math.min(de,c.theta)),c.phi=Math.max(e.minPolarAngle,Math.min(e.maxPolarAngle,c.phi)),c.makeSafe(),e.enableDamping===!0?e.target.addScaledVector(g,e.dampingFactor):e.target.add(g),e.target.sub(e.cursor),e.target.clampLength(e.minTargetRadius,e.maxTargetRadius),e.target.add(e.cursor),e.zoomToCursor&&se||e.object.isOrthographicCamera?c.radius=he(c.radius):c.radius=he(c.radius*h),i.setFromSpherical(c),i.applyQuaternion(M),Je.copy(e.target).add(i),e.object.lookAt(e.target),e.enableDamping===!0?(d.theta*=1-e.dampingFactor,d.phi*=1-e.dampingFactor,g.multiplyScalar(1-e.dampingFactor)):(d.set(0,0,0),g.set(0,0,0));let Te=!1;if(e.zoomToCursor&&se){let Re=null;if(e.object.isPerspectiveCamera){const _e=i.length();Re=he(_e*h);const Ae=_e-Re;e.object.position.addScaledVector(be,Ae),e.object.updateMatrixWorld()}else if(e.object.isOrthographicCamera){const _e=new s.Vector3(le.x,le.y,0);_e.unproject(e.object),e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/h)),e.object.updateProjectionMatrix(),Te=!0;const Ae=new s.Vector3(le.x,le.y,0);Ae.unproject(e.object),e.object.position.sub(Ae).add(_e),e.object.updateMatrixWorld(),Re=i.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),e.zoomToCursor=!1;Re!==null&&(this.screenSpacePanning?e.target.set(0,0,-1).transformDirection(e.object.matrix).multiplyScalar(Re).add(e.object.position):(vt.origin.copy(e.object.position),vt.direction.set(0,0,-1).transformDirection(e.object.matrix),Math.abs(e.object.up.dot(vt.direction))<va?n.lookAt(e.target):(Kt.setFromNormalAndCoplanarPoint(e.object.up,e.target),vt.intersectPlane(Kt,e.target))))}else e.object.isOrthographicCamera&&(Te=h!==1,Te&&(e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/h)),e.object.updateProjectionMatrix()));return h=1,se=!1,Te||F.distanceToSquared(e.object.position)>v||8*(1-Z.dot(e.object.quaternion))>v||ue.distanceToSquared(e.target)>0?(e.dispatchEvent(qt),F.copy(e.object.position),Z.copy(e.object.quaternion),ue.copy(e.target),!0):!1}}(),this.dispose=function(){e.domElement.removeEventListener("contextmenu",Ue),e.domElement.removeEventListener("pointerdown",Oe),e.domElement.removeEventListener("pointercancel",Me),e.domElement.removeEventListener("wheel",dt),e.domElement.removeEventListener("pointermove",qe),e.domElement.removeEventListener("pointerup",Me),e._domElementKeyEvents!==null&&(e._domElementKeyEvents.removeEventListener("keydown",Ke),e._domElementKeyEvents=null)};const e=this,o={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let l=o.NONE;const v=1e-6,c=new s.Spherical,d=new s.Spherical;let h=1;const g=new s.Vector3,y=new s.Vector2,C=new s.Vector2,x=new s.Vector2,T=new s.Vector2,D=new s.Vector2,q=new s.Vector2,V=new s.Vector2,w=new s.Vector2,G=new s.Vector2,be=new s.Vector3,le=new s.Vector2;let se=!1;const f=[],m={};let O=!1;function P(i){return i!==null?2*Math.PI/60*e.autoRotateSpeed*i:2*Math.PI/60/60*e.autoRotateSpeed}function H(i){const E=Math.abs(i*.01);return Math.pow(.95,e.zoomSpeed*E)}function z(i){d.theta-=i}function Y(i){d.phi-=i}const L=function(){const i=new s.Vector3;return function(M,F){i.setFromMatrixColumn(F,0),i.multiplyScalar(-M),g.add(i)}}(),X=function(){const i=new s.Vector3;return function(M,F){e.screenSpacePanning===!0?i.setFromMatrixColumn(F,1):(i.setFromMatrixColumn(F,0),i.crossVectors(e.object.up,i)),i.multiplyScalar(M),g.add(i)}}(),K=function(){const i=new s.Vector3;return function(M,F){const Z=e.domElement;if(e.object.isPerspectiveCamera){const ue=e.object.position;i.copy(ue).sub(e.target);let re=i.length();re*=Math.tan(e.object.fov/2*Math.PI/180),L(2*M*re/Z.clientHeight,e.object.matrix),X(2*F*re/Z.clientHeight,e.object.matrix)}else e.object.isOrthographicCamera?(L(M*(e.object.right-e.object.left)/e.object.zoom/Z.clientWidth,e.object.matrix),X(F*(e.object.top-e.object.bottom)/e.object.zoom/Z.clientHeight,e.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),e.enablePan=!1)}}();function _(i){e.object.isPerspectiveCamera||e.object.isOrthographicCamera?h/=i:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function U(i){e.object.isPerspectiveCamera||e.object.isOrthographicCamera?h*=i:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function Q(i,E){if(!e.zoomToCursor)return;se=!0;const M=e.domElement.getBoundingClientRect(),F=i-M.left,Z=E-M.top,ue=M.width,re=M.height;le.x=F/ue*2-1,le.y=-(Z/re)*2+1,be.set(le.x,le.y,1).unproject(e.object).sub(e.object.position).normalize()}function he(i){return Math.max(e.minDistance,Math.min(e.maxDistance,i))}function ye(i){y.set(i.clientX,i.clientY)}function it(i){Q(i.clientX,i.clientX),V.set(i.clientX,i.clientY)}function He(i){T.set(i.clientX,i.clientY)}function wt(i){C.set(i.clientX,i.clientY),x.subVectors(C,y).multiplyScalar(e.rotateSpeed);const E=e.domElement;z(2*Math.PI*x.x/E.clientHeight),Y(2*Math.PI*x.y/E.clientHeight),y.copy(C),e.update()}function Ot(i){w.set(i.clientX,i.clientY),G.subVectors(w,V),G.y>0?_(H(G.y)):G.y<0&&U(H(G.y)),V.copy(w),e.update()}function We(i){D.set(i.clientX,i.clientY),q.subVectors(D,T).multiplyScalar(e.panSpeed),K(q.x,q.y),T.copy(D),e.update()}function $e(i){Q(i.clientX,i.clientY),i.deltaY<0?U(H(i.deltaY)):i.deltaY>0&&_(H(i.deltaY)),e.update()}function Le(i){let E=!1;switch(i.code){case e.keys.UP:i.ctrlKey||i.metaKey||i.shiftKey?Y(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):K(0,e.keyPanSpeed),E=!0;break;case e.keys.BOTTOM:i.ctrlKey||i.metaKey||i.shiftKey?Y(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):K(0,-e.keyPanSpeed),E=!0;break;case e.keys.LEFT:i.ctrlKey||i.metaKey||i.shiftKey?z(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):K(e.keyPanSpeed,0),E=!0;break;case e.keys.RIGHT:i.ctrlKey||i.metaKey||i.shiftKey?z(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):K(-e.keyPanSpeed,0),E=!0;break}E&&(i.preventDefault(),e.update())}function Fe(i){if(f.length===1)y.set(i.pageX,i.pageY);else{const E=Ce(i),M=.5*(i.pageX+E.x),F=.5*(i.pageY+E.y);y.set(M,F)}}function Se(i){if(f.length===1)T.set(i.pageX,i.pageY);else{const E=Ce(i),M=.5*(i.pageX+E.x),F=.5*(i.pageY+E.y);T.set(M,F)}}function ot(i){const E=Ce(i),M=i.pageX-E.x,F=i.pageY-E.y,Z=Math.sqrt(M*M+F*F);V.set(0,Z)}function st(i){e.enableZoom&&ot(i),e.enablePan&&Se(i)}function Mt(i){e.enableZoom&&ot(i),e.enableRotate&&Fe(i)}function ct(i){if(f.length==1)C.set(i.pageX,i.pageY);else{const M=Ce(i),F=.5*(i.pageX+M.x),Z=.5*(i.pageY+M.y);C.set(F,Z)}x.subVectors(C,y).multiplyScalar(e.rotateSpeed);const E=e.domElement;z(2*Math.PI*x.x/E.clientHeight),Y(2*Math.PI*x.y/E.clientHeight),y.copy(C)}function xe(i){if(f.length===1)D.set(i.pageX,i.pageY);else{const E=Ce(i),M=.5*(i.pageX+E.x),F=.5*(i.pageY+E.y);D.set(M,F)}q.subVectors(D,T).multiplyScalar(e.panSpeed),K(q.x,q.y),T.copy(D)}function we(i){const E=Ce(i),M=i.pageX-E.x,F=i.pageY-E.y,Z=Math.sqrt(M*M+F*F);w.set(0,Z),G.set(0,Math.pow(w.y/V.y,e.zoomSpeed)),_(G.y),V.copy(w);const ue=(i.pageX+E.x)*.5,re=(i.pageY+E.y)*.5;Q(ue,re)}function lt(i){e.enableZoom&&we(i),e.enablePan&&xe(i)}function ut(i){e.enableZoom&&we(i),e.enableRotate&&ct(i)}function Oe(i){e.enabled!==!1&&(f.length===0&&(e.domElement.setPointerCapture(i.pointerId),e.domElement.addEventListener("pointermove",qe),e.domElement.addEventListener("pointerup",Me)),Rt(i),i.pointerType==="touch"?Ze(i):Xe(i))}function qe(i){e.enabled!==!1&&(i.pointerType==="touch"?ht(i):Tt(i))}function Me(i){switch(_t(i),f.length){case 0:e.domElement.releasePointerCapture(i.pointerId),e.domElement.removeEventListener("pointermove",qe),e.domElement.removeEventListener("pointerup",Me),e.dispatchEvent(Xt),l=o.NONE;break;case 1:const E=f[0],M=m[E];Ze({pointerId:E,pageX:M.x,pageY:M.y});break}}function Xe(i){let E;switch(i.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 s.MOUSE.DOLLY:if(e.enableZoom===!1)return;it(i),l=o.DOLLY;break;case s.MOUSE.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(e.enablePan===!1)return;He(i),l=o.PAN}else{if(e.enableRotate===!1)return;ye(i),l=o.ROTATE}break;case s.MOUSE.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(e.enableRotate===!1)return;ye(i),l=o.ROTATE}else{if(e.enablePan===!1)return;He(i),l=o.PAN}break;default:l=o.NONE}l!==o.NONE&&e.dispatchEvent(jt)}function Tt(i){switch(l){case o.ROTATE:if(e.enableRotate===!1)return;wt(i);break;case o.DOLLY:if(e.enableZoom===!1)return;Ot(i);break;case o.PAN:if(e.enablePan===!1)return;We(i);break}}function dt(i){e.enabled===!1||e.enableZoom===!1||l!==o.NONE||(i.preventDefault(),e.dispatchEvent(jt),$e(ft(i)),e.dispatchEvent(Xt))}function ft(i){const E=i.deltaMode,M={clientX:i.clientX,clientY:i.clientY,deltaY:i.deltaY};switch(E){case 1:M.deltaY*=16;break;case 2:M.deltaY*=100;break}return i.ctrlKey&&!O&&(M.deltaY*=10),M}function pt(i){i.key==="Control"&&(O=!0,e.domElement.getRootNode().addEventListener("keyup",Ee,{passive:!0,capture:!0}))}function Ee(i){i.key==="Control"&&(O=!1,e.domElement.getRootNode().removeEventListener("keyup",Ee,{passive:!0,capture:!0}))}function Ke(i){e.enabled===!1||e.enablePan===!1||Le(i)}function Ze(i){switch(mt(i),f.length){case 1:switch(e.touches.ONE){case s.TOUCH.ROTATE:if(e.enableRotate===!1)return;Fe(i),l=o.TOUCH_ROTATE;break;case s.TOUCH.PAN:if(e.enablePan===!1)return;Se(i),l=o.TOUCH_PAN;break;default:l=o.NONE}break;case 2:switch(e.touches.TWO){case s.TOUCH.DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;st(i),l=o.TOUCH_DOLLY_PAN;break;case s.TOUCH.DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;Mt(i),l=o.TOUCH_DOLLY_ROTATE;break;default:l=o.NONE}break;default:l=o.NONE}l!==o.NONE&&e.dispatchEvent(jt)}function ht(i){switch(mt(i),l){case o.TOUCH_ROTATE:if(e.enableRotate===!1)return;ct(i),e.update();break;case o.TOUCH_PAN:if(e.enablePan===!1)return;xe(i),e.update();break;case o.TOUCH_DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;lt(i),e.update();break;case o.TOUCH_DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;ut(i),e.update();break;default:l=o.NONE}}function Ue(i){e.enabled!==!1&&i.preventDefault()}function Rt(i){f.push(i.pointerId)}function _t(i){delete m[i.pointerId];for(let E=0;E<f.length;E++)if(f[E]==i.pointerId){f.splice(E,1);return}}function mt(i){let E=m[i.pointerId];E===void 0&&(E=new s.Vector2,m[i.pointerId]=E),E.set(i.pageX,i.pageY)}function Ce(i){const E=i.pointerId===f[0]?f[1]:f[0];return m[E]}e.domElement.addEventListener("contextmenu",Ue),e.domElement.addEventListener("pointerdown",Oe),e.domElement.addEventListener("pointercancel",Me),e.domElement.addEventListener("wheel",dt,{passive:!1}),e.domElement.getRootNode().addEventListener("keydown",pt,{passive:!0,capture:!0}),this.update()}}const Et=t=>{const[n,a]=R.useState(t.options[t.index]),e=()=>{t.onToggle(!t.open)},o=l=>{l!==n&&(t.onSelect(l),a(l)),t.onToggle(!1)};return u.jsxs("div",{className:`dropdown ${t.up===!0?"up":""}`,children:[u.jsx("div",{className:"dropdown-toggle",onClick:e,children:n}),t.open&&u.jsx("ul",{className:"dropdown-menu",children:t.options.map(l=>u.jsx("li",{onClick:()=>o(l),children:l},l))})]})},ke=R.forwardRef(function(n,a){const[e,o]=R.useState(!1),l=n.options.indexOf(n.camera.name);return u.jsxs("div",{className:"CameraWindow",children:[u.jsx("div",{ref:a,className:"clickable",onClick:()=>{e&&o(!1)}}),u.jsx(Et,{index:l,open:e,options:n.options,onSelect:n.onSelect,onToggle:v=>{o(v)},up:!0})]})}),Zt=["Single","Side by Side","Stacked","Quad"],ae=new Map,ie=new Map,ve=new Map;function Ne(t,n){const a=new s.OrthographicCamera(-100,100,100,-100,50,3e3);return a.name=t,a.position.copy(n),a.lookAt(0,0,0),ae.set(t,a),a}Ne("Top",new s.Vector3(0,1e3,0));Ne("Bottom",new s.Vector3(0,-1e3,0));Ne("Left",new s.Vector3(-1e3,0,0));Ne("Right",new s.Vector3(1e3,0,0));Ne("Front",new s.Vector3(0,0,1e3));Ne("Back",new s.Vector3(0,0,-1e3));Ne("Orthographic",new s.Vector3(1e3,1e3,1e3));const xt=new s.PerspectiveCamera(60,1,50,3e3);xt.name="Debug";xt.position.set(500,500,500);xt.lookAt(0,0,0);ae.set("Debug",xt);const Jt=["Renderer","Depth","Normals","UVs","Wireframe"],ba=new s.MeshDepthMaterial,ya=new s.MeshNormalMaterial,Ea=new pn,Ca=new s.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0});let gt="Renderer";const $=new s.Scene;$.name="Debug Scene";let ge=new s.Scene;$.add(ge);const rt=new s.Group;rt.name="helpers";$.add(rt);const Sa=new fn;rt.add(Sa);const gn=new s.AxesHelper(500);gn.name="axisHelper";rt.add(gn);const at=new s.AxesHelper(100);at.name="interactionHelper";rt.add(at);at.visible=!1;let bt=!1,W=ae.get("Debug"),oe=ae.get("Orthographic"),De=ae.get("Front"),je=ae.get("Top"),Qt=!1;function xa(t){const[n,a]=R.useState(t.mode!==void 0?t.mode:"Single"),[e,o]=R.useState(null),[l,v]=R.useState(!1),[c,d]=R.useState(!1),[h,g]=R.useState(!1),[,y]=R.useState(Date.now()),C=R.useRef(null),x=R.useRef(null),T=R.useRef(null),D=R.useRef(null),q=R.useRef(null),V=R.useRef(null),w=(f,m)=>{const O=ie.get(f.name);O!==void 0&&O.dispose(),ie.delete(f.name);const P=ve.get(f.name);P!==void 0&&($.remove(P),P.dispose()),ve.delete(f.name);const H=new ga(f,m);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(ie.set(f.name,H),f instanceof s.PerspectiveCamera){const z=new s.CameraHelper(f);ve.set(f.name,z),$.add(z)}},G=f=>{const m=ve.get(f.name);m!==void 0&&($.remove(m),m.dispose(),ve.delete(f.name));const O=ie.get(f.name);O!==void 0&&(O.dispose(),ie.delete(f.name))},be=()=>{ie.forEach((f,m)=>{f.dispose();const O=ve.get(m);O!==void 0&&($.remove(O),O.dispose()),ve.delete(m),ie.delete(m)}),ie.clear(),ve.clear()},le=()=>{switch(n){case"Single":w(W,T.current);break;case"Side by Side":case"Stacked":w(W,T.current),w(oe,D.current);break;case"Quad":w(W,T.current),w(oe,D.current),w(De,q.current),w(je,V.current);break}};R.useEffect(()=>{const f=new s.WebGLRenderer({canvas:C.current,stencil:!1});f.autoClear=!1,f.shadowMap.enabled=!0,f.setPixelRatio(devicePixelRatio),f.setClearColor(0),o(f)},[]),R.useEffect(()=>{const f=P=>{Ft(ge),$.remove(ge);const H=t.scenes.get(P.value.name);if(H!==void 0){const z=new H;t.onSceneSet!==void 0&&t.onSceneSet(z),ge=z,t.three.scene=ge,$.add(ge),Qt=!0}},m=P=>{const H=P.value,z=t.three.scene?.getObjectByProperty("uuid",H.uuid);z!==void 0&&ae.set(H.name,z),y(Date.now())},O=P=>{ae.delete(P.value.name),y(Date.now())};return j.addEventListener(I.SET_SCENE,f),j.addEventListener(I.ADD_CAMERA,m),j.addEventListener(I.REMOVE_CAMERA,O),()=>{j.removeEventListener(I.SET_SCENE,f),j.removeEventListener(I.ADD_CAMERA,m),j.removeEventListener(I.REMOVE_CAMERA,O)}},[]),R.useEffect(()=>{if(e===null)return;let f=window.innerWidth,m=window.innerHeight,O=Math.floor(f/2),P=Math.floor(m/2),H=-1;const z=()=>{f=window.innerWidth-300,m=window.innerHeight,O=Math.floor(f/2),P=Math.floor(m/2),e.setSize(f,m);let _=f,U=m;switch(n){case"Side by Side":_=O,U=m;break;case"Stacked":_=f,U=P;break;case"Quad":_=O,U=P;break}ae.forEach(Q=>{Q instanceof s.OrthographicCamera?(Q.left=_/-2,Q.right=_/2,Q.top=U/2,Q.bottom=U/-2,Q.updateProjectionMatrix()):Q instanceof s.PerspectiveCamera&&(Q.aspect=_/U,Q.updateProjectionMatrix(),ve.get(Q.name)?.update())})},Y=()=>{e.setViewport(0,0,f,m),e.setScissor(0,0,f,m),e.render($,W)},L=()=>{if(n==="Side by Side")e.setViewport(0,0,O,m),e.setScissor(0,0,O,m),e.render($,W),e.setViewport(O,0,O,m),e.setScissor(O,0,O,m),e.render($,oe);else{const _=m-P;e.setViewport(0,_,f,P),e.setScissor(0,_,f,P),e.render($,W),e.setViewport(0,0,f,P),e.setScissor(0,0,f,P),e.render($,oe)}},X=()=>{let _=0,U=0;U=m-P,_=0,e.setViewport(_,U,O,P),e.setScissor(_,U,O,P),e.render($,W),_=O,e.setViewport(_,U,O,P),e.setScissor(_,U,O,P),e.render($,oe),U=0,_=0,e.setViewport(_,U,O,P),e.setScissor(_,U,O,P),e.render($,De),_=O,e.setViewport(_,U,O,P),e.setScissor(_,U,O,P),e.render($,je)},K=()=>{switch(ie.forEach(_=>{_.update()}),t.onSceneUpdate!==void 0&&Qt&&t.onSceneUpdate(ge),e.clear(),n){case"Single":Y();break;case"Side by Side":case"Stacked":L();break;case"Quad":X();break}H=requestAnimationFrame(K)};return le(),window.addEventListener("resize",z),z(),K(),()=>{window.removeEventListener("resize",z),cancelAnimationFrame(H),H=-1}},[n,e]),R.useEffect(()=>{if(e!==null){const f=new s.Raycaster,m=new s.Vector2,O=(Y,L,X,K)=>{switch(n){case"Quad":Y<X?L<K?f.setFromCamera(m,W):f.setFromCamera(m,De):L<K?f.setFromCamera(m,oe):f.setFromCamera(m,je);break;case"Side by Side":Y<X?f.setFromCamera(m,W):f.setFromCamera(m,oe);break;case"Single":f.setFromCamera(m,W);break;case"Stacked":L<K?f.setFromCamera(m,W):f.setFromCamera(m,oe);break}},P=Y=>{if(!bt)return;const L=new s.Vector2;e.getSize(L);const X=Math.min(Y.clientX,L.x),K=Math.min(Y.clientY,L.y);m.x=Ye(X,0,L.x,-1,1),m.y=Ye(K,0,L.y,1,-1);const _=L.x/2,U=L.y/2,Q=()=>{X<_?m.x=Ye(X,0,_,-1,1):m.x=Ye(X,_,L.x,-1,1)},he=()=>{K<U?m.y=Ye(K,0,U,1,-1):m.y=Ye(K,U,L.y,1,-1)};switch(n){case"Quad":Q(),he();break;case"Side by Side":Q();break;case"Stacked":he(),he();break}O(X,K,_,U);const ye=f.intersectObjects(ge.children);ye.length>0&&at.position.copy(ye[0].point)},H=Y=>{if(!bt)return;const L=new s.Vector2;if(e.getSize(L),Y.clientX>=L.x)return;P(Y);const X=f.intersectObjects(ge.children);X.length>0&&t.three.getObject(X[0].object.uuid)},z=x.current;return z.addEventListener("mousemove",P,!1),z.addEventListener("click",H,!1),()=>{z.removeEventListener("mousemove",P),z.removeEventListener("click",H)}}},[n,e]);const se=[];return ae.forEach((f,m)=>{se.push(m)}),u.jsxs("div",{className:"multiview",children:[u.jsx("canvas",{ref:C}),u.jsxs("div",{className:`cameras ${n==="Single"||n==="Stacked"?"single":""}`,ref:x,children:[n==="Single"&&u.jsx(u.Fragment,{children:u.jsx(ke,{camera:W,options:se,ref:T,onSelect:f=>{ie.get(W.name)?.dispose();const m=ae.get(f);m!==void 0&&(G(W),W=m,w(m,T.current))}})}),(n==="Side by Side"||n==="Stacked")&&u.jsxs(u.Fragment,{children:[u.jsx(ke,{camera:W,options:se,ref:T,onSelect:f=>{ie.get(W.name)?.dispose();const m=ae.get(f);m!==void 0&&(G(W),W=m,w(m,T.current))}}),u.jsx(ke,{camera:oe,options:se,ref:D,onSelect:f=>{ie.get(oe.name)?.dispose();const m=ae.get(f);m!==void 0&&(G(oe),oe=m,w(m,D.current))}})]}),n==="Quad"&&u.jsxs(u.Fragment,{children:[u.jsx(ke,{camera:W,options:se,ref:T,onSelect:f=>{ie.get(W.name)?.dispose();const m=ae.get(f);m!==void 0&&(G(W),W=m,w(m,T.current))}}),u.jsx(ke,{camera:oe,options:se,ref:D,onSelect:f=>{ie.get(oe.name)?.dispose();const m=ae.get(f);m!==void 0&&(G(oe),oe=m,w(m,D.current))}}),u.jsx(ke,{camera:De,options:se,ref:q,onSelect:f=>{ie.get(De.name)?.dispose();const m=ae.get(f);m!==void 0&&(G(De),De=m,w(m,q.current))}}),u.jsx(ke,{camera:je,options:se,ref:V,onSelect:f=>{ie.get(je.name)?.dispose();const m=ae.get(f);m!==void 0&&(G(je),je=m,w(m,V.current))}})]})]}),u.jsxs("div",{className:"settings",children:[u.jsx(Et,{index:Zt.indexOf(n),options:Zt,onSelect:f=>{f!==n&&(be(),a(f))},open:l,onToggle:f=>{v(f),c&&d(!1),h&&g(!1)}}),u.jsx(Et,{index:Jt.indexOf(gt),options:Jt,onSelect:f=>{if(f!==gt)switch(gt=f,gt){case"Depth":$.overrideMaterial=ba;break;case"Normals":$.overrideMaterial=ya;break;default:case"Renderer":$.overrideMaterial=null;break;case"Wireframe":$.overrideMaterial=Ca;break;case"UVs":$.overrideMaterial=Ea;break}},open:c,onToggle:f=>{l&&v(!1),d(f),h&&g(!1)}}),u.jsx(Et,{index:0,options:["Orbit Mode","Selection Mode"],onSelect:f=>{bt=f==="Selection Mode",at.visible=bt},open:h,onToggle:f=>{l&&v(!1),c&&d(!1),g(f)}})]})]})}function wa(t){return u.jsxs("div",{className:"editor",ref:t.ref,style:t.style,children:[u.jsx("header",{children:t.header}),t.children,u.jsx("footer",{children:t.footer})]})}exports.Accordion=St;exports.Application=Pn;exports.BaseRemote=Ct;exports.ChildObject=Bt;exports.ContainerObject=hn;exports.Draggable=ln;exports.DraggableItem=cn;exports.Dropdown=un;exports.DropdownItem=dn;exports.Editor=wa;exports.InfiniteGridHelper=fn;exports.Inspector=vn;exports.MultiView=xa;exports.NavButton=Ut;exports.RemoteComponents=kn;exports.RemoteController=Gn;exports.RemoteThree=Fn;exports.RemoteTweakpane=Un;exports.SceneInspector=ma;exports.SidePanel=ha;exports.ToolEvents=I;exports.UVMaterial=pn;exports.capitalize=Ge;exports.clamp=Tn;exports.colorToHex=an;exports.debugDispatcher=j;exports.defaultTheatreCallback=Mn;exports.dispose=Ft;exports.disposeMaterial=on;exports.disposeTexture=An;exports.distance=Rn;exports.hierarchyUUID=Lt;exports.isColor=_n;exports.noop=tn;exports.randomID=nn;exports.resetThreeObjects=rn;exports.round=yt;exports.theatreEditorApp=Dn;
143
+ }`;class vn extends c.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:Qn,fragmentShader:ea})}}function Ct(t){const[n,a]=R.useState(t.open!==void 0?t.open:!0),e=!n||t.children===void 0;return u.jsxs("div",{className:`accordion ${e?"hide":""}`,children:[u.jsxs("button",{className:"toggle",onClick:()=>{const o=!n;t.onToggle!==void 0&&t.onToggle(o),a(o)},children:[u.jsx("p",{className:`status ${n?"open":""}`,children:"Toggle"}),u.jsx("p",{className:"label",children:He(t.label)})]}),t.button,u.jsx("div",{className:n?"open":"",children:u.jsx("div",{children:t.children})})]})}function Vt(t){const[n,a]=R.useState(!1),e=t.child!==void 0&&t.child.children.length>0,o=[];return t.child!==void 0&&t.child.children.length>0&&t.child.children.map(l=>{o.push(u.jsx(Vt,{child:l,three:t.three},Math.random()))}),u.jsx(u.Fragment,{children:t.child!==void 0&&u.jsxs("div",{className:"childObject",children:[u.jsxs("div",{className:"child",children:[e?u.jsx("button",{className:"status",style:{backgroundPositionX:n?"-14px":"2px"},onClick:()=>{a(!n)}}):null,u.jsx("button",{className:"name",style:{left:e?"20px":"5px"},onClick:()=>{t.child!==void 0&&(t.three.getObject(t.child.uuid),n||a(!0))},children:t.child.name.length>0?`${t.child.name} (${t.child.type})`:`${t.child.type}::${t.child.uuid}`}),u.jsx("div",{className:`icon ${zn(t.child)}`})]}),u.jsx("div",{className:n?"open":"",children:u.jsx("div",{className:"container",children:o})})]},Math.random())})}function gn(t){const n=[];return t.child?.children.map(a=>{n.push(u.jsx(Vt,{child:a,three:t.three},Math.random()))}),u.jsx("div",{className:`scene ${t.class!==void 0?t.class:""}`,children:n})}const ta="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA5klEQVRoge2Y0Q6EIAwE6cX//+X6cCFpSMEKVTdk501OpRNKiyelFC0b8Ps6gCwoggZF0KAIGhRBgyJoUAQNiqCxjciR9SLV//eZiAyvK3U8i/QVaQO2YyLSFVvlkdTKDjJCukh2ykR5ZEW+kHmlatl90RaBtDkK/w7CYhuRUEO0ee3l+J3m55Vm+17vtwjTnV1V3QA8qfbeUXCzRWDpiLLS+OyzvRW7IzW9R+okvclsqR09743bo0yUpc1+lSJvNsa002+Euk9GKzV7SmZDRIMiaFAEDYqgQRE0KIIGRdCgCBoUQeMEMERadX7YUz8AAAAASUVORK5CYII=";function na(t){return"items"in t}function Ie(t){const n=[];return t.items.forEach(a=>{na(a)?n.push(u.jsx(Ie,{title:He(a.title),items:a.items},Math.random())):n.push(u.jsx(nt,{title:a.title,prop:a.prop,value:a.value,type:a.type,min:a.min,max:a.max,step:a.step,disabled:a.disabled,options:a.options,onChange:(e,o)=>{a.onChange!==void 0&&a.onChange(e,o)}},Math.random()))}),u.jsx(Ct,{label:t.title,open:t.expanded===!0,children:n})}function aa(t){return!(t==="alphaHash"||t==="alphaToCoverage"||t==="attenuationDistance"||t==="blendDstAlpha"||t==="colorWrite"||t==="combine"||t==="defaultAttributeValues"||t==="depthFunc"||t==="forceSinglePass"||t==="glslVersion"||t==="linecap"||t==="linejoin"||t==="linewidth"||t==="normalMapType"||t==="precision"||t==="premultipliedAlpha"||t==="shadowSide"||t==="toneMapped"||t==="uniformsGroups"||t==="uniformsNeedUpdate"||t==="userData"||t==="vertexColors"||t==="version"||t==="wireframeLinecap"||t==="wireframeLinejoin"||t==="wireframeLinewidth"||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"blendAlpha":return"Blend Alpha";case"blendColor":return"Blend Color";case"blendDst":return"Blend Dst";case"blendDstAlpha":return"Blend Dst Alha";case"blendEquation":return"Blend Equation";case"blendEquationAlpha":return"Blend Equation Alpha";case"blending":return"Blending";case"blendSrc":return"Blend Src";case"blendSrcAlpha":return"Blend Src Alpha";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"side":return"Side";case"size":return"Size";case"sizeAttenuation":return"Size Attenuation";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 ia(t){return t.toLowerCase().search("intensity")>-1||t==="anisotropyRotation"||t==="blendAlpha"||t==="bumpScale"||t==="clearcoatRoughness"||t==="displacementBias"||t==="displacementScale"||t==="metalness"||t==="opacity"||t==="reflectivity"||t==="refractionRatio"||t==="roughness"||t==="sheenRoughness"||t==="thickness"}function ra(){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],o=new FileReader;o.onload=function(l){n(l.target.result)},o.readAsDataURL(e)}}),t.click()})}const oa=[{title:"Front",value:c.FrontSide},{title:"Back",value:c.BackSide},{title:"Double",value:c.DoubleSide}],sa=[{title:"No Blending",value:c.NoBlending},{title:"Normal",value:c.NormalBlending},{title:"Additive",value:c.AdditiveBlending},{title:"Subtractive",value:c.SubtractiveBlending},{title:"Multiply",value:c.MultiplyBlending},{title:"Custom",value:c.CustomBlending}],ca=[{title:"Add",value:c.AddEquation},{title:"Subtract",value:c.SubtractEquation},{title:"Reverse Subtract",value:c.ReverseSubtractEquation},{title:"Min",value:c.MinEquation},{title:"Max",value:c.MaxEquation}],la=[{title:"Zero",valye:c.ZeroFactor},{title:"One",valye:c.OneFactor},{title:"Src Color",valye:c.SrcColorFactor},{title:"One Minus Src Color",valye:c.OneMinusSrcColorFactor},{title:"Src Alpha",valye:c.SrcAlphaFactor},{title:"One Minus Src Alpha",valye:c.OneMinusSrcAlphaFactor},{title:"Dst Alpha",valye:c.DstAlphaFactor},{title:"One Minus Dst Alpha",valye:c.OneMinusDstAlphaFactor},{title:"Dst Color",valye:c.DstColorFactor},{title:"One Minus Dst Color",valye:c.OneMinusDstColorFactor},{title:"Src Alpha Saturate",valye:c.SrcAlphaSaturateFactor},{title:"Constant Color",valye:c.ConstantColorFactor},{title:"One Minus Constant Color",valye:c.OneMinusConstantColorFactor},{title:"Constant Alpha",valye:c.ConstantAlphaFactor},{title:"One Minus Constant Alpha",valye:c.OneMinusConstantAlphaFactor}],ua=[{title:"Zero",valye:c.ZeroFactor},{title:"One",valye:c.OneFactor},{title:"Src Color",valye:c.SrcColorFactor},{title:"One Minus Src Color",valye:c.OneMinusSrcColorFactor},{title:"Src Alpha",valye:c.SrcAlphaFactor},{title:"One Minus Src Alpha",valye:c.OneMinusSrcAlphaFactor},{title:"Dst Alpha",valye:c.DstAlphaFactor},{title:"One Minus Dst Alpha",valye:c.OneMinusDstAlphaFactor},{title:"Dst Color",valye:c.DstColorFactor},{title:"One Minus Dst Color",valye:c.OneMinusDstColorFactor},{title:"Constant Color",valye:c.ConstantColorFactor},{title:"One Minus Constant Color",valye:c.OneMinusConstantColorFactor},{title:"Constant Alpha",valye:c.ConstantAlphaFactor},{title:"One Minus Constant Alpha",valye:c.OneMinusConstantAlphaFactor}];function tt(t,n){t.needsUpdate=!0,t.type="option",t.options=n}function $t(t,n,a){const e=[];for(const o in t){if(!aa(o))continue;const l=typeof t[o],m=t[o];if(l==="boolean"||l==="number"||l==="string"){const s={title:Pe(o),prop:o,type:l,value:m,min:void 0,max:void 0,needsUpdate:l==="boolean",onChange:(p,g)=>{a.updateObject(n.uuid,`material.${p}`,g),s.needsUpdate&&a.updateObject(n.uuid,"material.needsUpdate",!0);const y=a.scene?.getObjectByProperty("uuid",n.uuid);y!==void 0&&te(y,`material.${p}`,g)}};switch(o){case"blending":tt(s,sa);break;case"blendDst":tt(s,ua);break;case"blendEquation":tt(s,ca);break;case"blendSrc":tt(s,la);break;case"side":tt(s,oa);break}ia(o)&&(s.value=Number(m),s.type="range",s.min=0,s.max=1,s.step=.01);const d=l==="string"&&(o==="vertexShader"||o==="fragmentShader");d&&(s.disabled=!1,s.latest=s.value,s.onChange=(p,g)=>{s.latest=g}),e.push(s),d&&e.push({title:`${He(o)} - Update`,type:"button",onChange:()=>{a.updateObject(n.uuid,`material.${o}`,s.latest),a.updateObject(n.uuid,"material.needsUpdate",!0);const p=a.scene?.getObjectByProperty("uuid",n.uuid);p!==void 0&&(te(p,`material.${o}`,s.latest),p.material.needsUpdate=!0)}})}else if(l==="object")if(m.isColor)e.push({title:Pe(o),prop:o,type:"color",value:m,onChange:(s,d)=>{const p=new c.Color(d);a.updateObject(n.uuid,`material.${s}`,p);const g=a.scene?.getObjectByProperty("uuid",n.uuid);g!==void 0&&te(g,`material.${s}`,p)}});else if(Array.isArray(m)){const s=[];for(const d in m)s.push({title:`${d}`,type:`${typeof m[d]}`,value:m[d],onChange:(p,g)=>{a.updateObject(n.uuid,`material.${o}`,g);const y=a.scene?.getObjectByProperty("uuid",n.uuid);y!==void 0&&te(y,`material.${o}`,g)}});e.push({title:Pe(o),items:s})}else{const s=[];for(const d in m){const p=m[d];switch(typeof p){case"boolean":case"number":case"string":d==="src"?e.push({title:Pe(o),type:"image",value:p,onChange:(y,S)=>{a.createTexture(n.uuid,`material.${o}`,S);const w=a.scene?.getObjectByProperty("uuid",n.uuid);w!==void 0&&It(S).then(T=>{te(w,`material.${o}`,T),te(w,"material.needsUpdate",!0)})}}):s.push({title:`${Pe(d)}`,prop:`material.${o}.${d}`,type:`${typeof t[o][d]}`,value:m[d],onChange:(y,S)=>{a.updateObject(n.uuid,`material.${o}.${d}`,S);const w=a.scene?.getObjectByProperty("uuid",n.uuid);w!==void 0&&te(w,`material.${o}.${d}`,S)}});break;case"object":if(p.value!==void 0&&p.value.src!==void 0)s.push({title:Pe(d),type:"image",value:p.value.src,onChange:(y,S)=>{a.createTexture(n.uuid,`material.${o}.${d}.value`,m);const w=a.scene?.getObjectByProperty("uuid",n.uuid);w!==void 0&&It(S).then(T=>{te(w,`material.${o}.${d}.value`,T)})}});else if(o==="uniforms"){const y=p.value,S=(w,T,j)=>({title:w,type:"number",value:j,step:.01,onChange:(q,V)=>{const x=`material.uniforms.${d}.value.${T}`;a.updateObject(n.uuid,x,V);const H=a.scene?.getObjectByProperty("uuid",n.uuid);H!==void 0&&te(H,x,V)}});if(typeof p.value=="number")s.push({title:d,type:"number",value:p.value,onChange:(w,T)=>{const j=`material.${o}.${w}.value`;a.updateObject(n.uuid,j,T);const q=a.scene?.getObjectByProperty("uuid",n.uuid);q!==void 0&&te(q,j,T)}});else if(y.r!==void 0&&y.g!==void 0&&y.b!==void 0)s.push({title:d,type:"color",value:p.value,onChange:(w,T)=>{const j=new c.Color(T),q=`material.${o}.${w}.value`;a.updateObject(n.uuid,q,j);const V=a.scene?.getObjectByProperty("uuid",n.uuid);V!==void 0&&te(V,q,j)}});else if(y.x!==void 0&&y.y!==void 0&&y.z===void 0&&y.w===void 0)s.push({title:d,items:[S("X","x",p.value.x),S("Y","y",p.value.y)]});else if(y.x!==void 0&&y.y!==void 0&&y.z!==void 0&&y.w===void 0)s.push({title:d,items:[S("X","x",p.value.x),S("Y","y",p.value.y),S("Z","z",p.value.z)]});else if(y.x!==void 0&&y.y!==void 0&&y.z!==void 0&&y.w!==void 0)s.push({title:d,items:[S("X","x",p.value.x),S("Y","y",p.value.y),S("Z","z",p.value.z),S("W","w",p.value.w)]});else if(y.elements!==void 0){const w=y.elements,T=[];for(let j=0;j<w.length;j++)T.push(S(j.toString(),j.toString(),w[j]));s.push({title:d,items:T})}else console.log(">>> need to add this format:",d,y)}else s.push({title:d,type:`${typeof p.value}`,value:p.value,onChange:(y,S)=>{a.updateObject(n.uuid,`material.${o}.${d}.value`,S);const w=a.scene?.getObjectByProperty("uuid",n.uuid);w!==void 0&&te(w,`material.${o}.${d}.value`,S)}});break}}s.length>0&&e.push({title:Pe(o),items:s})}else m!==void 0&&console.log("other:",o,l,m)}return e.sort((o,l)=>o.title<l.title?-1:o.title>l.title?1:0),e.push({title:"Update Material",type:"button",onChange:()=>{a.updateObject(n.uuid,"material.needsUpdate",!0)}}),e}function da(t,n){const a=t.material;if(Array.isArray(a)){const e=[],o=a.length;for(let l=0;l<o;l++)e.push(u.jsx(Ie,{title:`Material ${l}`,items:$t(a[l],t,n)},`Material ${l}`));return u.jsx(u.Fragment,{children:e})}else return u.jsx(Ie,{title:"Material",items:$t(a,t,n)})}function nt(t){let n=t.value;n!==void 0&&n.isColor!==void 0&&(n=on(t.value));const[a,e]=R.useState(n),o=R.useRef(null),l=R.useRef(null),m=R.useRef(null);R.useEffect(()=>{let g=!1,y=-1,S=0,w=Number(a);const T=H=>{g=!0,S=w,y=H.clientX},j=H=>{if(!g)return;const be=t.step!==void 0?t.step:1,le=(H.clientX-y)*be;w=Number((S+le).toFixed(4)),l.current!==null&&(l.current.value=w.toString()),t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,w)},q=()=>{g=!1},V=()=>{g=!1},x=t.type==="number";return x&&(o.current?.addEventListener("mousedown",T,!1),document.addEventListener("mouseup",q,!1),document.addEventListener("mousemove",j,!1),document.addEventListener("contextmenu",V,!1)),()=>{x&&(o.current?.removeEventListener("mousedown",T),document.removeEventListener("mouseup",q),document.removeEventListener("mousemove",j),document.removeEventListener("contextmenu",V))}},[a]);const s=t.type==="string"&&(a.length>100||a.search(`
144
+ `)>-1),d=s||t.type==="image",p=g=>{let y=g.target.value;t.type==="boolean"?y=g.target.checked:t.type==="option"&&(y=t.options[y].value),e(y),t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,y)};return u.jsxs("div",{className:`field ${d?"block":""}`,children:[t.type!=="button"&&u.jsx("label",{ref:o,children:He(t.title)},"fieldLabel"),t.type==="string"&&!s&&u.jsx("input",{type:"text",disabled:t.disabled,onChange:p,value:a}),t.type==="string"&&s&&u.jsx("textarea",{cols:50,rows:10,disabled:t.disabled!==void 0?t.disabled:!0,onChange:p,value:a}),t.type==="boolean"&&u.jsx("input",{type:"checkbox",disabled:t.disabled,onChange:p,checked:a}),t.type==="number"&&u.jsx("input",{ref:l,type:"number",value:a,min:t.min,max:t.max,step:t.step,disabled:t.disabled,onChange:p}),t.type==="range"&&u.jsxs(u.Fragment,{children:[u.jsx("input",{type:"text",value:a.toString(),onChange:p,disabled:t.disabled,className:"min"}),u.jsx("input",{disabled:t.disabled,type:"range",value:a,min:t.min,max:t.max,step:t.step,onChange:p})]}),t.type==="color"&&u.jsxs(u.Fragment,{children:[u.jsx("input",{type:"text",value:a.toString(),onChange:p,disabled:t.disabled,className:"color"}),u.jsx("input",{type:"color",value:a,onChange:p,disabled:t.disabled})]}),t.type==="button"&&u.jsx("button",{disabled:t.disabled,onClick:()=>{t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,!0)},children:t.title}),t.type==="image"&&u.jsx("img",{ref:m,onClick:()=>{ra().then(g=>{m.current.src=g,t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,g)})},src:a.length>0?a:ta}),t.type==="option"&&u.jsx(u.Fragment,{children:u.jsx("select",{onChange:p,disabled:t.disabled,defaultValue:t.value,children:t.options?.map((g,y)=>u.jsx("option",{value:g.value,children:He(g.title)},y))})})]})}function qt(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 pa(t,n){const a=[];if(t.perspectiveCameraInfo!==void 0)for(const e in t.perspectiveCameraInfo)a.push({title:qt(e),prop:e,type:"number",step:.01,value:t.perspectiveCameraInfo[e],onChange:(o,l)=>{n.updateObject(t.uuid,o,l),n.requestMethod(t.uuid,"updateProjectionMatrix");const m=n.scene?.getObjectByProperty("uuid",t.uuid);m!==void 0&&(te(m,o,l),m.updateProjectionMatrix())}});else if(t.orthographicCameraInfo!==void 0)for(const e in t.orthographicCameraInfo)a.push({title:qt(e),prop:e,type:"number",step:.01,value:t.perspectiveCameraInfo[e],onChange:(o,l)=>{n.updateObject(t.uuid,o,l),n.requestMethod(t.uuid,"updateProjectionMatrix");const m=n.scene?.getObjectByProperty("uuid",t.uuid);m!==void 0&&(te(m,o,l),m.updateProjectionMatrix())}});return u.jsx(Ie,{title:"Camera",items:a})}const fa=Math.PI/180,ha=180/Math.PI;function ze(t,n,a,e,o){return e+(t-n)*(o-e)/(a-n)}function ma(t){return t*fa}function jt(t){return t*ha}function va(t,n){const a=new c.Matrix4;a.elements=t.matrix;const e=new c.Vector3,o=new c.Euler,l=new c.Vector3;t.uuid.length>0&&(e.setFromMatrixPosition(a),o.setFromRotationMatrix(a),l.setFromMatrixScale(a));const m=(d,p)=>{n.updateObject(t.uuid,d,p);const g=n.scene?.getObjectByProperty("uuid",t.uuid);g!==void 0&&te(g,d,p)},s=(d,p)=>{m(d,ma(p))};return u.jsx(Ie,{title:"Transform",items:[{title:"Position X",prop:"position.x",type:"number",value:e.x,onChange:m},{title:"Position Y",prop:"position.y",type:"number",value:e.y,onChange:m},{title:"Position Z",prop:"position.z",type:"number",value:e.z,onChange:m},{title:"Rotation X",prop:"rotation.x",type:"number",value:Et(jt(o.x)),min:-360,max:360,step:.1,onChange:s},{title:"Rotation Y",prop:"rotation.y",type:"number",value:Et(jt(o.y)),min:-360,max:360,step:.1,onChange:s},{title:"Rotation Z",prop:"rotation.z",type:"number",value:Et(jt(o.z)),min:-360,max:360,step:.1,onChange:s},{title:"Scale X",prop:"scale.x",type:"number",value:l.x,step:.01,onChange:m},{title:"Scale Y",prop:"scale.y",type:"number",value:l.y,step:.01,onChange:m},{title:"Scale Z",prop:"scale.z",type:"number",value:l.z,step:.01,onChange:m}]})}function Kt(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 ga(t,n){const a=[];if(t.lightInfo!==void 0)for(const e in t.lightInfo){const o=t.lightInfo[e];o!==void 0&&(o.isColor!==void 0?a.push({title:Kt(e),prop:e,type:"color",value:o,onChange:(l,m)=>{const s=new c.Color(m);n.updateObject(t.uuid,l,s);const d=n.scene?.getObjectByProperty("uuid",t.uuid);d!==void 0&&te(d,l,s)}}):a.push({title:Kt(e),prop:e,type:typeof o,value:o,step:typeof o=="number"?.01:void 0,onChange:(l,m)=>{n.updateObject(t.uuid,l,m);const s=n.scene?.getObjectByProperty("uuid",t.uuid);s!==void 0&&te(s,l,m)}}))}return u.jsx(Ie,{title:"Light",items:a})}function ba(t,n){const a=[],e=[];let o=0;t.animations.forEach(s=>{o=Math.max(o,s.duration),s.duration>0&&e.push({title:s.name,items:[{title:"Duration",type:"number",value:s.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),a.push({title:"Animations",items:e});const l=n.scene?.getObjectByProperty("uuid",t.uuid);let m=!1;if(l!==void 0){const s=l.mixer;if(m=s!==void 0,m){const d=[{title:"Time Scale",type:"range",value:s.timeScale,step:.01,min:-1,max:2,onChange:(p,g)=>{s.timeScale=g,n.updateObject(t.uuid,"mixer.timeScale",g)}}];d.push({title:"Stop All",type:"button",onChange:()=>{s.stopAllAction(),n.requestMethod(t.uuid,"stopAllAction",void 0,"mixer")}}),a.push({title:"Mixer",items:d})}}return u.jsx(Ie,{title:"Animation",items:a})}const bn={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 ne={...bn};function yn(t){const[n,a]=R.useState(-1);R.useEffect(()=>{function m(d){ne={...d.value},a(Date.now())}function s(){ne={...bn},a(Date.now())}return D.addEventListener(I.SET_SCENE,s),D.addEventListener(I.SET_OBJECT,m),()=>{D.removeEventListener(I.SET_SCENE,s),D.removeEventListener(I.SET_OBJECT,m)}},[]);const e=ne.type.toLowerCase(),o=ne.animations.length>0||ne.mixer!==void 0,l=e.search("mesh")>-1||e.search("line")>-1||e.search("points")>-1;return u.jsx(Ct,{label:"Inspector",children:u.jsx("div",{id:"Inspector",className:t.class,children:ne.uuid.length>0&&u.jsxs(u.Fragment,{children:[u.jsxs(u.Fragment,{children:[u.jsx(nt,{type:"string",title:"Name",prop:"name",value:ne.name,disabled:!0}),u.jsx(nt,{type:"string",title:"Type",prop:"type",value:ne.type,disabled:!0}),u.jsx(nt,{type:"string",title:"UUID",prop:"uuid",value:ne.uuid,disabled:!0}),u.jsx(nt,{type:"boolean",title:"Visible",prop:"visible",value:ne.visible,onChange:(m,s)=>{t.three.updateObject(ne.uuid,m,s);const d=t.three.scene?.getObjectByProperty("uuid",ne.uuid);d!==void 0&&te(d,m,s)}})]}),u.jsxs(u.Fragment,{children:[va(ne,t.three),o?ba(ne,t.three):null,e.search("camera")>-1?pa(ne,t.three):null,e.search("light")>-1?ga(ne,t.three):null,l?da(ne,t.three):null]})]})},n)},"Inspector")}function ya(t){const[n,a]=R.useState(t.scene);R.useEffect(()=>{const l=m=>{a(m.value)};return D.addEventListener(I.SET_SCENE,l),()=>{D.removeEventListener(I.SET_SCENE,l)}},[]);const e=n!==null,o="Hierarchy - "+(e?`${n?.name}`:"No Scene");return u.jsxs("div",{id:"SidePanel",children:[u.jsx(Ct,{label:o,open:!0,children:u.jsx(u.Fragment,{children:e&&u.jsx(gn,{child:n,three:t.three})})}),u.jsx(yn,{three:t.three})]},"SidePanel")}function Ea(t){function n(){return t.three.scene===void 0?(console.log("No scene:",t.three),!1):!0}const a=s=>{if(!n())return;const d=t.three.scene?.getObjectByProperty("uuid",s.value);d!==void 0&&t.three.setObject(d)},e=(s,d,p)=>{if(!n())return;const g=t.three.scene?.getObjectByProperty("uuid",s);g!==void 0&&te(g,d,p)},o=s=>{if(!n())return;const d=s.value,{key:p,value:g,uuid:y}=d;e(y,p,g)},l=s=>{if(!n())return;const d=s.value;It(d.value).then(p=>{e(d.uuid,d.key,p),e(d.uuid,"material.needsUpdate",!0)})},m=s=>{if(!n())return;const{key:d,uuid:p,value:g,subitem:y}=s.value,S=t.three.scene?.getObjectByProperty("uuid",p);if(S!==void 0)try{y!==void 0?Gn(S,y)[d](g):S[d](g)}catch(w){console.log("Error requesting method:"),console.log(w),console.log(d),console.log(g)}};return R.useEffect(()=>(D.addEventListener(I.GET_OBJECT,a),D.addEventListener(I.UPDATE_OBJECT,o),D.addEventListener(I.CREATE_TEXTURE,l),D.addEventListener(I.REQUEST_METHOD,m),()=>{D.removeEventListener(I.GET_OBJECT,a),D.removeEventListener(I.UPDATE_OBJECT,o),D.removeEventListener(I.CREATE_TEXTURE,l),D.removeEventListener(I.REQUEST_METHOD,m)}),[]),null}const Xt={type:"change"},Dt={type:"start"},Zt={type:"end"},gt=new c.Ray,Jt=new c.Plane,Sa=Math.cos(70*c.MathUtils.DEG2RAD);class Ca extends c.EventDispatcher{constructor(n,a){super(),this.object=n,this.domElement=a,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new c.Vector3,this.cursor=new c.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:c.MOUSE.ROTATE,MIDDLE:c.MOUSE.DOLLY,RIGHT:c.MOUSE.PAN},this.touches={ONE:c.TOUCH.ROTATE,TWO:c.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 s.phi},this.getAzimuthalAngle=function(){return s.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(r){r.addEventListener("keydown",Xe),this._domElementKeyEvents=r},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Xe),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(Xt),e.update(),l=o.NONE},this.update=function(){const r=new c.Vector3,E=new c.Quaternion().setFromUnitVectors(n.up,new c.Vector3(0,1,0)),M=E.clone().invert(),F=new c.Vector3,Z=new c.Quaternion,ue=new c.Vector3,ie=2*Math.PI;return function(Pt=null){const Je=e.object.position;r.copy(Je).sub(e.target),r.applyQuaternion(E),s.setFromVector3(r),e.autoRotate&&l===o.NONE&&z(P(Pt)),e.enableDamping?(s.theta+=d.theta*e.dampingFactor,s.phi+=d.phi*e.dampingFactor):(s.theta+=d.theta,s.phi+=d.phi);let fe=e.minAzimuthAngle,de=e.maxAzimuthAngle;isFinite(fe)&&isFinite(de)&&(fe<-Math.PI?fe+=ie:fe>Math.PI&&(fe-=ie),de<-Math.PI?de+=ie:de>Math.PI&&(de-=ie),fe<=de?s.theta=Math.max(fe,Math.min(de,s.theta)):s.theta=s.theta>(fe+de)/2?Math.max(fe,s.theta):Math.min(de,s.theta)),s.phi=Math.max(e.minPolarAngle,Math.min(e.maxPolarAngle,s.phi)),s.makeSafe(),e.enableDamping===!0?e.target.addScaledVector(g,e.dampingFactor):e.target.add(g),e.target.sub(e.cursor),e.target.clampLength(e.minTargetRadius,e.maxTargetRadius),e.target.add(e.cursor),e.zoomToCursor&&se||e.object.isOrthographicCamera?s.radius=he(s.radius):s.radius=he(s.radius*p),r.setFromSpherical(s),r.applyQuaternion(M),Je.copy(e.target).add(r),e.object.lookAt(e.target),e.enableDamping===!0?(d.theta*=1-e.dampingFactor,d.phi*=1-e.dampingFactor,g.multiplyScalar(1-e.dampingFactor)):(d.set(0,0,0),g.set(0,0,0));let Te=!1;if(e.zoomToCursor&&se){let Re=null;if(e.object.isPerspectiveCamera){const _e=r.length();Re=he(_e*p);const Ae=_e-Re;e.object.position.addScaledVector(be,Ae),e.object.updateMatrixWorld()}else if(e.object.isOrthographicCamera){const _e=new c.Vector3(le.x,le.y,0);_e.unproject(e.object),e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/p)),e.object.updateProjectionMatrix(),Te=!0;const Ae=new c.Vector3(le.x,le.y,0);Ae.unproject(e.object),e.object.position.sub(Ae).add(_e),e.object.updateMatrixWorld(),Re=r.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),e.zoomToCursor=!1;Re!==null&&(this.screenSpacePanning?e.target.set(0,0,-1).transformDirection(e.object.matrix).multiplyScalar(Re).add(e.object.position):(gt.origin.copy(e.object.position),gt.direction.set(0,0,-1).transformDirection(e.object.matrix),Math.abs(e.object.up.dot(gt.direction))<Sa?n.lookAt(e.target):(Jt.setFromNormalAndCoplanarPoint(e.object.up,e.target),gt.intersectPlane(Jt,e.target))))}else e.object.isOrthographicCamera&&(Te=p!==1,Te&&(e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/p)),e.object.updateProjectionMatrix()));return p=1,se=!1,Te||F.distanceToSquared(e.object.position)>m||8*(1-Z.dot(e.object.quaternion))>m||ue.distanceToSquared(e.target)>0?(e.dispatchEvent(Xt),F.copy(e.object.position),Z.copy(e.object.quaternion),ue.copy(e.target),!0):!1}}(),this.dispose=function(){e.domElement.removeEventListener("contextmenu",Ue),e.domElement.removeEventListener("pointerdown",Oe),e.domElement.removeEventListener("pointercancel",Me),e.domElement.removeEventListener("wheel",pt),e.domElement.removeEventListener("pointermove",qe),e.domElement.removeEventListener("pointerup",Me),e._domElementKeyEvents!==null&&(e._domElementKeyEvents.removeEventListener("keydown",Xe),e._domElementKeyEvents=null)};const e=this,o={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let l=o.NONE;const m=1e-6,s=new c.Spherical,d=new c.Spherical;let p=1;const g=new c.Vector3,y=new c.Vector2,S=new c.Vector2,w=new c.Vector2,T=new c.Vector2,j=new c.Vector2,q=new c.Vector2,V=new c.Vector2,x=new c.Vector2,H=new c.Vector2,be=new c.Vector3,le=new c.Vector2;let se=!1;const f=[],v={};let O=!1;function P(r){return r!==null?2*Math.PI/60*e.autoRotateSpeed*r:2*Math.PI/60/60*e.autoRotateSpeed}function G(r){const E=Math.abs(r*.01);return Math.pow(.95,e.zoomSpeed*E)}function z(r){d.theta-=r}function Y(r){d.phi-=r}const L=function(){const r=new c.Vector3;return function(M,F){r.setFromMatrixColumn(F,0),r.multiplyScalar(-M),g.add(r)}}(),K=function(){const r=new c.Vector3;return function(M,F){e.screenSpacePanning===!0?r.setFromMatrixColumn(F,1):(r.setFromMatrixColumn(F,0),r.crossVectors(e.object.up,r)),r.multiplyScalar(M),g.add(r)}}(),X=function(){const r=new c.Vector3;return function(M,F){const Z=e.domElement;if(e.object.isPerspectiveCamera){const ue=e.object.position;r.copy(ue).sub(e.target);let ie=r.length();ie*=Math.tan(e.object.fov/2*Math.PI/180),L(2*M*ie/Z.clientHeight,e.object.matrix),K(2*F*ie/Z.clientHeight,e.object.matrix)}else e.object.isOrthographicCamera?(L(M*(e.object.right-e.object.left)/e.object.zoom/Z.clientWidth,e.object.matrix),K(F*(e.object.top-e.object.bottom)/e.object.zoom/Z.clientHeight,e.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),e.enablePan=!1)}}();function _(r){e.object.isPerspectiveCamera||e.object.isOrthographicCamera?p/=r:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function U(r){e.object.isPerspectiveCamera||e.object.isOrthographicCamera?p*=r:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function Q(r,E){if(!e.zoomToCursor)return;se=!0;const M=e.domElement.getBoundingClientRect(),F=r-M.left,Z=E-M.top,ue=M.width,ie=M.height;le.x=F/ue*2-1,le.y=-(Z/ie)*2+1,be.set(le.x,le.y,1).unproject(e.object).sub(e.object.position).normalize()}function he(r){return Math.max(e.minDistance,Math.min(e.maxDistance,r))}function ye(r){y.set(r.clientX,r.clientY)}function ot(r){Q(r.clientX,r.clientX),V.set(r.clientX,r.clientY)}function Ge(r){T.set(r.clientX,r.clientY)}function xt(r){S.set(r.clientX,r.clientY),w.subVectors(S,y).multiplyScalar(e.rotateSpeed);const E=e.domElement;z(2*Math.PI*w.x/E.clientHeight),Y(2*Math.PI*w.y/E.clientHeight),y.copy(S),e.update()}function Ot(r){x.set(r.clientX,r.clientY),H.subVectors(x,V),H.y>0?_(G(H.y)):H.y<0&&U(G(H.y)),V.copy(x),e.update()}function We(r){j.set(r.clientX,r.clientY),q.subVectors(j,T).multiplyScalar(e.panSpeed),X(q.x,q.y),T.copy(j),e.update()}function $e(r){Q(r.clientX,r.clientY),r.deltaY<0?U(G(r.deltaY)):r.deltaY>0&&_(G(r.deltaY)),e.update()}function Le(r){let E=!1;switch(r.code){case e.keys.UP:r.ctrlKey||r.metaKey||r.shiftKey?Y(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):X(0,e.keyPanSpeed),E=!0;break;case e.keys.BOTTOM:r.ctrlKey||r.metaKey||r.shiftKey?Y(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):X(0,-e.keyPanSpeed),E=!0;break;case e.keys.LEFT:r.ctrlKey||r.metaKey||r.shiftKey?z(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):X(e.keyPanSpeed,0),E=!0;break;case e.keys.RIGHT:r.ctrlKey||r.metaKey||r.shiftKey?z(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):X(-e.keyPanSpeed,0),E=!0;break}E&&(r.preventDefault(),e.update())}function Fe(r){if(f.length===1)y.set(r.pageX,r.pageY);else{const E=Se(r),M=.5*(r.pageX+E.x),F=.5*(r.pageY+E.y);y.set(M,F)}}function Ce(r){if(f.length===1)T.set(r.pageX,r.pageY);else{const E=Se(r),M=.5*(r.pageX+E.x),F=.5*(r.pageY+E.y);T.set(M,F)}}function st(r){const E=Se(r),M=r.pageX-E.x,F=r.pageY-E.y,Z=Math.sqrt(M*M+F*F);V.set(0,Z)}function ct(r){e.enableZoom&&st(r),e.enablePan&&Ce(r)}function Mt(r){e.enableZoom&&st(r),e.enableRotate&&Fe(r)}function lt(r){if(f.length==1)S.set(r.pageX,r.pageY);else{const M=Se(r),F=.5*(r.pageX+M.x),Z=.5*(r.pageY+M.y);S.set(F,Z)}w.subVectors(S,y).multiplyScalar(e.rotateSpeed);const E=e.domElement;z(2*Math.PI*w.x/E.clientHeight),Y(2*Math.PI*w.y/E.clientHeight),y.copy(S)}function we(r){if(f.length===1)j.set(r.pageX,r.pageY);else{const E=Se(r),M=.5*(r.pageX+E.x),F=.5*(r.pageY+E.y);j.set(M,F)}q.subVectors(j,T).multiplyScalar(e.panSpeed),X(q.x,q.y),T.copy(j)}function xe(r){const E=Se(r),M=r.pageX-E.x,F=r.pageY-E.y,Z=Math.sqrt(M*M+F*F);x.set(0,Z),H.set(0,Math.pow(x.y/V.y,e.zoomSpeed)),_(H.y),V.copy(x);const ue=(r.pageX+E.x)*.5,ie=(r.pageY+E.y)*.5;Q(ue,ie)}function ut(r){e.enableZoom&&xe(r),e.enablePan&&we(r)}function dt(r){e.enableZoom&&xe(r),e.enableRotate&&lt(r)}function Oe(r){e.enabled!==!1&&(f.length===0&&(e.domElement.setPointerCapture(r.pointerId),e.domElement.addEventListener("pointermove",qe),e.domElement.addEventListener("pointerup",Me)),Rt(r),r.pointerType==="touch"?Ze(r):Ke(r))}function qe(r){e.enabled!==!1&&(r.pointerType==="touch"?mt(r):Tt(r))}function Me(r){switch(_t(r),f.length){case 0:e.domElement.releasePointerCapture(r.pointerId),e.domElement.removeEventListener("pointermove",qe),e.domElement.removeEventListener("pointerup",Me),e.dispatchEvent(Zt),l=o.NONE;break;case 1:const E=f[0],M=v[E];Ze({pointerId:E,pageX:M.x,pageY:M.y});break}}function Ke(r){let E;switch(r.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 c.MOUSE.DOLLY:if(e.enableZoom===!1)return;ot(r),l=o.DOLLY;break;case c.MOUSE.ROTATE:if(r.ctrlKey||r.metaKey||r.shiftKey){if(e.enablePan===!1)return;Ge(r),l=o.PAN}else{if(e.enableRotate===!1)return;ye(r),l=o.ROTATE}break;case c.MOUSE.PAN:if(r.ctrlKey||r.metaKey||r.shiftKey){if(e.enableRotate===!1)return;ye(r),l=o.ROTATE}else{if(e.enablePan===!1)return;Ge(r),l=o.PAN}break;default:l=o.NONE}l!==o.NONE&&e.dispatchEvent(Dt)}function Tt(r){switch(l){case o.ROTATE:if(e.enableRotate===!1)return;xt(r);break;case o.DOLLY:if(e.enableZoom===!1)return;Ot(r);break;case o.PAN:if(e.enablePan===!1)return;We(r);break}}function pt(r){e.enabled===!1||e.enableZoom===!1||l!==o.NONE||(r.preventDefault(),e.dispatchEvent(Dt),$e(ft(r)),e.dispatchEvent(Zt))}function ft(r){const E=r.deltaMode,M={clientX:r.clientX,clientY:r.clientY,deltaY:r.deltaY};switch(E){case 1:M.deltaY*=16;break;case 2:M.deltaY*=100;break}return r.ctrlKey&&!O&&(M.deltaY*=10),M}function ht(r){r.key==="Control"&&(O=!0,e.domElement.getRootNode().addEventListener("keyup",Ee,{passive:!0,capture:!0}))}function Ee(r){r.key==="Control"&&(O=!1,e.domElement.getRootNode().removeEventListener("keyup",Ee,{passive:!0,capture:!0}))}function Xe(r){e.enabled===!1||e.enablePan===!1||Le(r)}function Ze(r){switch(vt(r),f.length){case 1:switch(e.touches.ONE){case c.TOUCH.ROTATE:if(e.enableRotate===!1)return;Fe(r),l=o.TOUCH_ROTATE;break;case c.TOUCH.PAN:if(e.enablePan===!1)return;Ce(r),l=o.TOUCH_PAN;break;default:l=o.NONE}break;case 2:switch(e.touches.TWO){case c.TOUCH.DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;ct(r),l=o.TOUCH_DOLLY_PAN;break;case c.TOUCH.DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;Mt(r),l=o.TOUCH_DOLLY_ROTATE;break;default:l=o.NONE}break;default:l=o.NONE}l!==o.NONE&&e.dispatchEvent(Dt)}function mt(r){switch(vt(r),l){case o.TOUCH_ROTATE:if(e.enableRotate===!1)return;lt(r),e.update();break;case o.TOUCH_PAN:if(e.enablePan===!1)return;we(r),e.update();break;case o.TOUCH_DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;ut(r),e.update();break;case o.TOUCH_DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;dt(r),e.update();break;default:l=o.NONE}}function Ue(r){e.enabled!==!1&&r.preventDefault()}function Rt(r){f.push(r.pointerId)}function _t(r){delete v[r.pointerId];for(let E=0;E<f.length;E++)if(f[E]==r.pointerId){f.splice(E,1);return}}function vt(r){let E=v[r.pointerId];E===void 0&&(E=new c.Vector2,v[r.pointerId]=E),E.set(r.pageX,r.pageY)}function Se(r){const E=r.pointerId===f[0]?f[1]:f[0];return v[E]}e.domElement.addEventListener("contextmenu",Ue),e.domElement.addEventListener("pointerdown",Oe),e.domElement.addEventListener("pointercancel",Me),e.domElement.addEventListener("wheel",pt,{passive:!1}),e.domElement.getRootNode().addEventListener("keydown",ht,{passive:!0,capture:!0}),this.update()}}const St=t=>{const[n,a]=R.useState(t.options[t.index]),e=()=>{t.onToggle(!t.open)},o=l=>{l!==n&&(t.onSelect(l),a(l)),t.onToggle(!1)};return u.jsxs("div",{className:`dropdown ${t.up===!0?"up":""}`,children:[u.jsx("div",{className:"dropdown-toggle",onClick:e,children:n}),t.open&&u.jsx("ul",{className:"dropdown-menu",children:t.options.map(l=>u.jsx("li",{onClick:()=>o(l),children:l},l))})]})},ke=R.forwardRef(function(n,a){const[e,o]=R.useState(!1),l=n.options.indexOf(n.camera.name);return u.jsxs("div",{className:"CameraWindow",children:[u.jsx("div",{ref:a,className:"clickable",onClick:()=>{e&&o(!1)}}),u.jsx(St,{index:l,open:e,options:n.options,onSelect:n.onSelect,onToggle:m=>{o(m)},up:!0})]})}),Qt=["Single","Side by Side","Stacked","Quad"],ae=new Map,re=new Map,ve=new Map;function Ne(t,n){const a=new c.OrthographicCamera(-100,100,100,-100,50,3e3);return a.name=t,a.position.copy(n),a.lookAt(0,0,0),ae.set(t,a),a}Ne("Top",new c.Vector3(0,1e3,0));Ne("Bottom",new c.Vector3(0,-1e3,0));Ne("Left",new c.Vector3(-1e3,0,0));Ne("Right",new c.Vector3(1e3,0,0));Ne("Front",new c.Vector3(0,0,1e3));Ne("Back",new c.Vector3(0,0,-1e3));Ne("Orthographic",new c.Vector3(1e3,1e3,1e3));const wt=new c.PerspectiveCamera(60,1,50,3e3);wt.name="Debug";wt.position.set(500,500,500);wt.lookAt(0,0,0);ae.set("Debug",wt);const en=["Renderer","Depth","Normals","UVs","Wireframe"],wa=new c.MeshDepthMaterial,xa=new c.MeshNormalMaterial,Oa=new vn,Ma=new c.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0});let bt="Renderer";const $=new c.Scene;$.name="Debug Scene";let ge=new c.Scene;$.add(ge);const rt=new c.Group;rt.name="helpers";$.add(rt);const Ta=new mn;rt.add(Ta);const En=new c.AxesHelper(500);En.name="axisHelper";rt.add(En);const at=new c.AxesHelper(100);at.name="interactionHelper";rt.add(at);at.visible=!1;let yt=!1,W=ae.get("Debug"),oe=ae.get("Orthographic"),je=ae.get("Front"),De=ae.get("Top"),tn=!1;function Ra(t){const[n,a]=R.useState(t.mode!==void 0?t.mode:"Single"),[e,o]=R.useState(null),[l,m]=R.useState(!1),[s,d]=R.useState(!1),[p,g]=R.useState(!1),[,y]=R.useState(Date.now()),S=R.useRef(null),w=R.useRef(null),T=R.useRef(null),j=R.useRef(null),q=R.useRef(null),V=R.useRef(null),x=(f,v)=>{const O=re.get(f.name);O!==void 0&&O.dispose(),re.delete(f.name);const P=ve.get(f.name);P!==void 0&&($.remove(P),P.dispose()),ve.delete(f.name);const G=new Ca(f,v);switch(G.enableDamping=!0,G.dampingFactor=.05,f.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":G.enableRotate=!1;break}if(re.set(f.name,G),f instanceof c.PerspectiveCamera){const z=new c.CameraHelper(f);ve.set(f.name,z),$.add(z)}},H=f=>{const v=ve.get(f.name);v!==void 0&&($.remove(v),v.dispose(),ve.delete(f.name));const O=re.get(f.name);O!==void 0&&(O.dispose(),re.delete(f.name))},be=()=>{re.forEach((f,v)=>{f.dispose();const O=ve.get(v);O!==void 0&&($.remove(O),O.dispose()),ve.delete(v),re.delete(v)}),re.clear(),ve.clear()},le=()=>{switch(n){case"Single":x(W,T.current);break;case"Side by Side":case"Stacked":x(W,T.current),x(oe,j.current);break;case"Quad":x(W,T.current),x(oe,j.current),x(je,q.current),x(De,V.current);break}};R.useEffect(()=>{const f=new c.WebGLRenderer({canvas:S.current,stencil:!1});f.autoClear=!1,f.shadowMap.enabled=!0,f.setPixelRatio(devicePixelRatio),f.setClearColor(0),o(f)},[]),R.useEffect(()=>{const f=P=>{Ut(ge),$.remove(ge);const G=t.scenes.get(P.value.name);if(G!==void 0){const z=new G;t.onSceneSet!==void 0&&t.onSceneSet(z),ge=z,t.three.scene=ge,$.add(ge),tn=!0}},v=P=>{const G=P.value,z=t.three.scene?.getObjectByProperty("uuid",G.uuid);z!==void 0&&ae.set(G.name,z),y(Date.now())},O=P=>{ae.delete(P.value.name),y(Date.now())};return D.addEventListener(I.SET_SCENE,f),D.addEventListener(I.ADD_CAMERA,v),D.addEventListener(I.REMOVE_CAMERA,O),()=>{D.removeEventListener(I.SET_SCENE,f),D.removeEventListener(I.ADD_CAMERA,v),D.removeEventListener(I.REMOVE_CAMERA,O)}},[]),R.useEffect(()=>{if(e===null)return;let f=window.innerWidth,v=window.innerHeight,O=Math.floor(f/2),P=Math.floor(v/2),G=-1;const z=()=>{f=window.innerWidth-300,v=window.innerHeight,O=Math.floor(f/2),P=Math.floor(v/2),e.setSize(f,v);let _=f,U=v;switch(n){case"Side by Side":_=O,U=v;break;case"Stacked":_=f,U=P;break;case"Quad":_=O,U=P;break}ae.forEach(Q=>{Q instanceof c.OrthographicCamera?(Q.left=_/-2,Q.right=_/2,Q.top=U/2,Q.bottom=U/-2,Q.updateProjectionMatrix()):Q instanceof c.PerspectiveCamera&&(Q.aspect=_/U,Q.updateProjectionMatrix(),ve.get(Q.name)?.update())})},Y=()=>{e.setViewport(0,0,f,v),e.setScissor(0,0,f,v),e.render($,W)},L=()=>{if(n==="Side by Side")e.setViewport(0,0,O,v),e.setScissor(0,0,O,v),e.render($,W),e.setViewport(O,0,O,v),e.setScissor(O,0,O,v),e.render($,oe);else{const _=v-P;e.setViewport(0,_,f,P),e.setScissor(0,_,f,P),e.render($,W),e.setViewport(0,0,f,P),e.setScissor(0,0,f,P),e.render($,oe)}},K=()=>{let _=0,U=0;U=v-P,_=0,e.setViewport(_,U,O,P),e.setScissor(_,U,O,P),e.render($,W),_=O,e.setViewport(_,U,O,P),e.setScissor(_,U,O,P),e.render($,oe),U=0,_=0,e.setViewport(_,U,O,P),e.setScissor(_,U,O,P),e.render($,je),_=O,e.setViewport(_,U,O,P),e.setScissor(_,U,O,P),e.render($,De)},X=()=>{switch(re.forEach(_=>{_.update()}),t.onSceneUpdate!==void 0&&tn&&t.onSceneUpdate(ge),e.clear(),n){case"Single":Y();break;case"Side by Side":case"Stacked":L();break;case"Quad":K();break}G=requestAnimationFrame(X)};return le(),window.addEventListener("resize",z),z(),X(),()=>{window.removeEventListener("resize",z),cancelAnimationFrame(G),G=-1}},[n,e]),R.useEffect(()=>{if(e!==null){const f=new c.Raycaster,v=new c.Vector2,O=(Y,L,K,X)=>{switch(n){case"Quad":Y<K?L<X?f.setFromCamera(v,W):f.setFromCamera(v,je):L<X?f.setFromCamera(v,oe):f.setFromCamera(v,De);break;case"Side by Side":Y<K?f.setFromCamera(v,W):f.setFromCamera(v,oe);break;case"Single":f.setFromCamera(v,W);break;case"Stacked":L<X?f.setFromCamera(v,W):f.setFromCamera(v,oe);break}},P=Y=>{if(!yt)return;const L=new c.Vector2;e.getSize(L);const K=Math.min(Y.clientX,L.x),X=Math.min(Y.clientY,L.y);v.x=ze(K,0,L.x,-1,1),v.y=ze(X,0,L.y,1,-1);const _=L.x/2,U=L.y/2,Q=()=>{K<_?v.x=ze(K,0,_,-1,1):v.x=ze(K,_,L.x,-1,1)},he=()=>{X<U?v.y=ze(X,0,U,1,-1):v.y=ze(X,U,L.y,1,-1)};switch(n){case"Quad":Q(),he();break;case"Side by Side":Q();break;case"Stacked":he(),he();break}O(K,X,_,U);const ye=f.intersectObjects(ge.children);ye.length>0&&at.position.copy(ye[0].point)},G=Y=>{if(!yt)return;const L=new c.Vector2;if(e.getSize(L),Y.clientX>=L.x)return;P(Y);const K=f.intersectObjects(ge.children);K.length>0&&t.three.getObject(K[0].object.uuid)},z=w.current;return z.addEventListener("mousemove",P,!1),z.addEventListener("click",G,!1),()=>{z.removeEventListener("mousemove",P),z.removeEventListener("click",G)}}},[n,e]);const se=[];return ae.forEach((f,v)=>{se.push(v)}),u.jsxs("div",{className:"multiview",children:[u.jsx("canvas",{ref:S}),u.jsxs("div",{className:`cameras ${n==="Single"||n==="Stacked"?"single":""}`,ref:w,children:[n==="Single"&&u.jsx(u.Fragment,{children:u.jsx(ke,{camera:W,options:se,ref:T,onSelect:f=>{re.get(W.name)?.dispose();const v=ae.get(f);v!==void 0&&(H(W),W=v,x(v,T.current))}})}),(n==="Side by Side"||n==="Stacked")&&u.jsxs(u.Fragment,{children:[u.jsx(ke,{camera:W,options:se,ref:T,onSelect:f=>{re.get(W.name)?.dispose();const v=ae.get(f);v!==void 0&&(H(W),W=v,x(v,T.current))}}),u.jsx(ke,{camera:oe,options:se,ref:j,onSelect:f=>{re.get(oe.name)?.dispose();const v=ae.get(f);v!==void 0&&(H(oe),oe=v,x(v,j.current))}})]}),n==="Quad"&&u.jsxs(u.Fragment,{children:[u.jsx(ke,{camera:W,options:se,ref:T,onSelect:f=>{re.get(W.name)?.dispose();const v=ae.get(f);v!==void 0&&(H(W),W=v,x(v,T.current))}}),u.jsx(ke,{camera:oe,options:se,ref:j,onSelect:f=>{re.get(oe.name)?.dispose();const v=ae.get(f);v!==void 0&&(H(oe),oe=v,x(v,j.current))}}),u.jsx(ke,{camera:je,options:se,ref:q,onSelect:f=>{re.get(je.name)?.dispose();const v=ae.get(f);v!==void 0&&(H(je),je=v,x(v,q.current))}}),u.jsx(ke,{camera:De,options:se,ref:V,onSelect:f=>{re.get(De.name)?.dispose();const v=ae.get(f);v!==void 0&&(H(De),De=v,x(v,V.current))}})]})]}),u.jsxs("div",{className:"settings",children:[u.jsx(St,{index:Qt.indexOf(n),options:Qt,onSelect:f=>{f!==n&&(be(),a(f))},open:l,onToggle:f=>{m(f),s&&d(!1),p&&g(!1)}}),u.jsx(St,{index:en.indexOf(bt),options:en,onSelect:f=>{if(f!==bt)switch(bt=f,bt){case"Depth":$.overrideMaterial=wa;break;case"Normals":$.overrideMaterial=xa;break;default:case"Renderer":$.overrideMaterial=null;break;case"Wireframe":$.overrideMaterial=Ma;break;case"UVs":$.overrideMaterial=Oa;break}},open:s,onToggle:f=>{l&&m(!1),d(f),p&&g(!1)}}),u.jsx(St,{index:0,options:["Orbit Mode","Selection Mode"],onSelect:f=>{yt=f==="Selection Mode",at.visible=yt},open:p,onToggle:f=>{l&&m(!1),s&&d(!1),g(f)}})]})]})}function _a(t){return u.jsxs("div",{className:"editor",ref:t.ref,style:t.style,children:[u.jsx("header",{children:t.header}),t.children,u.jsx("footer",{children:t.footer})]})}exports.Accordion=Ct;exports.Application=jn;exports.BaseRemote=it;exports.ChildObject=Vt;exports.ContainerObject=gn;exports.Draggable=pn;exports.DraggableItem=dn;exports.Dropdown=fn;exports.DropdownItem=hn;exports.Editor=_a;exports.InfiniteGridHelper=mn;exports.Inspector=yn;exports.MultiView=Ra;exports.NavButton=Bt;exports.RemoteComponents=Dn;exports.RemoteController=Ye;exports.RemoteTheatre=ln;exports.RemoteThree=Wn;exports.RemoteTweakpane=$n;exports.SceneInspector=Ea;exports.SidePanel=ya;exports.ToolEvents=I;exports.UVMaterial=vn;exports.capitalize=He;exports.clamp=An;exports.colorToHex=on;exports.componentsApp=In;exports.debugDispatcher=D;exports.defaultTheatreCallback=_n;exports.dispose=Ut;exports.disposeMaterial=cn;exports.disposeTexture=kn;exports.distance=Pn;exports.hierarchyUUID=Ft;exports.isColor=rn;exports.noop=Lt;exports.randomID=an;exports.resetThreeObjects=sn;exports.round=Et;exports.theatreApp=Nn;exports.theatreEditor=Ln;exports.theatreEditorApp=Vn;exports.threeApp=Fn;exports.threeEditor=Un;exports.tweakpaneApp=Bn;