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