@tomorrowevening/hermes 0.0.6 → 0.0.8
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 +786 -737
- package/dist/hermes.umd.cjs +13 -13
- package/package.json +1 -1
- package/src/editor/sceneHierarchy/ChildObject.tsx +1 -1
- package/src/editor/sceneHierarchy/inspector/Inspector.tsx +53 -38
- package/src/editor/sceneHierarchy/inspector/utils/InspectCamera.tsx +1 -1
- package/src/editor/sceneHierarchy/inspector/utils/InspectLight.tsx +3 -3
- package/src/editor/sceneHierarchy/inspector/utils/InspectMaterial.tsx +24 -8
- package/src/editor/sceneHierarchy/utils.ts +29 -23
- package/types/editor/sceneHierarchy/inspector/utils/InspectCamera.d.ts +1 -1
- package/types/editor/sceneHierarchy/inspector/utils/InspectLight.d.ts +1 -1
- package/types/editor/sceneHierarchy/inspector/utils/InspectMaterial.d.ts +1 -1
package/dist/hermes.umd.cjs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
(function(S,
|
1
|
+
(function(S,h){typeof exports=="object"&&typeof module<"u"?h(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"],h):(S=typeof globalThis<"u"?globalThis:S||self,h(S.Hermes={},S.Three,S["Theatre Core"],S.tweakpane,S["tweakpane-plugin-essentials"],S.React,S["framer-motion"],S["Theatre Studio"]))})(this,function(S,h,me,Jt,Qt,I,Ct,_e){"use strict";var Hn=Object.defineProperty;var Wn=(S,h,me)=>h in S?Hn(S,h,{enumerable:!0,configurable:!0,writable:!0,value:me}):S[h]=me;var z=(S,h,me)=>(Wn(S,typeof h!="symbol"?h+"":h,me),me);function qt(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 $t=qt(Qt);function en(t,n,i){return Math.min(n,Math.max(t,i))}function tn(t,n){const i=t-n;return Math.sqrt(i*i)}function St(){return Math.round(Math.random()*1e6).toString()}function Ot(t){return t.r!==void 0&&t.g!==void 0&&t.b!==void 0}function Tt(t){const n=Math.round(t.r*255),i=Math.round(t.g*255),e=Math.round(t.b*255),r=l=>{const p=l.toString(16);return p.length===1?"0"+p:p},d=r(n),c=r(i),s=r(e);return"#"+d+c+s}let xt=0;const lt=t=>{if(!t)return;let n=t.name.replace(" ","");n.length===0&&(n=`obj_${xt}`),t.parent!==null&&(n=`${t.parent.uuid}.${n}`),t.uuid=n,xt++,t.children.forEach(i=>{lt(i)})};class nn{constructor(n,i,e){z(this,"channel");z(this,"components",new Map);z(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 L=new h.EventDispatcher,U={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 Ie{constructor(n){z(this,"app");this.app=n}dispose(){}}class an extends Ie{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 Rt=()=>{};class rn extends Ie{constructor(i,e,r){super(i);z(this,"project");z(this,"sheets");z(this,"sheetObjects");z(this,"sheetObjectCBs");z(this,"sheetObjectUnsubscribe");this.project=me.getProject(e,r),this.sheets=new Map,this.sheetObjects=new Map,this.sheetObjectCBs=new Map,this.sheetObjectUnsubscribe=new Map}dispose(){this.project=void 0,this.sheets=new Map,this.sheetObjects=new Map,this.sheetObjectCBs=new Map,this.sheetObjectUnsubscribe=new Map}sheet(i){var r;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=(r=this.project)==null?void 0:r.sheet(i),this.sheets.set(i,e)),e}sheetObject(i,e,r,d){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 l=this.sheetObjects.get(s);if(l!==void 0)return l=c.object(e,{...r,...l.value},{reconfigure:!0}),l;l=c.object(e,r),this.sheetObjects.set(s,l),this.sheetObjectCBs.set(s,d!==void 0?d:Rt);const p=l.onValuesChange(m=>{if(this.app.editor){for(const v in m){const w=m[v];typeof w=="object"&&Ot(w)&&(m[v]={r:w.r,g:w.g,b:w.b,a:w.a})}this.app.send({event:"updateSheetObject",target:"app",data:{sheetObject:s,values:m}})}else{const v=this.sheetObjectCBs.get(s);v!==void 0&&v(m)}});return this.sheetObjectUnsubscribe.set(s,p),l}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}`,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 Mt(t){const n={name:t.name,type:t.type,uuid:t.uuid,children:[]};return t.children.forEach(i=>{n.children.push(Mt(i))}),n}function sn(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 cn(t){switch(t){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function Pt(t){const n={};for(const i in t){if(i.substring(0,1)==="_"||i.substring(0,2)==="is"||cn(i))continue;const e=typeof t[i],r=t[i];switch(e){case"boolean":case"number":case"string":n[i]=r;break;case"object":if(r!==null)if(n[i]=r,r.isTexture)if(r instanceof h.Texture){const d=r.source.toJSON();n[i]={src:d.url}}else r instanceof h.CubeTexture&&(console.log("env map"),console.log(r.source.data),console.log(r.source.toJSON()),n[i]={src:""});else i==="uniforms"&&(n[i]=sn(n[i]));else n[i]={src:""};break}}return n}function ln(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 r=[];e.material.forEach(d=>{r.push(Pt(d))}),n.material=r}else n.material=Pt(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 J(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 ut(t){return new Promise((n,i)=>{const e=new Image;e.onload=()=>{const r=new h.Texture(e);r.wrapS=h.RepeatWrapping,r.wrapT=h.RepeatWrapping,r.needsUpdate=!0,n(r)},e.onerror=i,e.src=t})}class un extends Ie{constructor(){super(...arguments);z(this,"scene")}getObject(i){this.app.send({event:"getObject",target:"app",data:i})}setObject(i){const e=ln(i);this.app.send({event:"setObject",target:"editor",data:e})}requestMethod(i,e,r){this.app.send({event:"requestMethod",target:"app",data:{uuid:i,key:e,value:r}})}updateObject(i,e,r){this.app.send({event:"updateObject",target:"app",data:{uuid:i,key:e,value:r}})}createTexture(i,e,r){this.app.send({event:"createTexture",target:"app",data:{uuid:i,key:e,value:r}})}getScene(){this.app.send({event:"getScene",target:"app"})}setScene(i){this.scene=i,lt(i);const e=Mt(i);this.app.send({event:"setScene",target:"editor",data:e})}}class dn extends Ie{constructor(i){super(i);z(this,"bindCBs");z(this,"buttonCBs");z(this,"pane");z(this,"appCallbacks",0);z(this,"editorCallbacks",0);z(this,"inspectorFolder");this.bindCBs=new Map,this.buttonCBs=new Map,i.editor&&this.createGUI()}createGUI(){this.pane=new Jt.Pane({title:"GUI"}),this.pane.registerPlugin($t)}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,r=void 0){if(this.app.editor)return this.pane===void 0&&this.createGUI(),(r!==void 0?r:this.pane).addFolder({title:i,...e});this.app.send({event:"addFolder",target:"app",data:{name:i,params:e,parent:r}})}get bindID(){return`debug_${Math.max(this.appCallbacks,this.editorCallbacks)}`}bind(i,e,r,d=void 0){const c=this.bindID,s=r.onChange!==void 0?r.onChange:Rt;this.bindCBs.set(c,s),this.app.editor?(this.pane===void 0&&this.createGUI(),(d!==void 0?d:this.pane).addBinding(i,e,r).on("change",p=>{this.app.send({event:"updateBind",target:"app",data:{id:c,value:p.value}})}),this.editorCallbacks++):(this.app.send({event:"bindObject",target:"app",data:{id:c,name:e,params:r,parent:d}}),this.appCallbacks++)}triggerBind(i,e){const r=this.bindCBs.get(i);r!==void 0?r(e):console.warn(`No callback for: ${i}`,e)}button(i,e,r=void 0){const d=this.bindID;this.buttonCBs.set(d,e),this.app.editor?(this.pane===void 0&&this.createGUI(),(r!==void 0?r:this.pane).addButton({title:i}).on("click",()=>{this.app.send({event:"clickButton",target:"app",data:{id:d}})}),this.editorCallbacks++):(this.app.send({event:"addButton",target:"app",data:{id:d,name:i,callback:e,parent:r}}),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 dt={exports:{}},Ae={};/**
|
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 jt;function fn(){if(jt)return Ae;jt=1;var t=I,n=Symbol.for("react.element"),i=Symbol.for("react.fragment"),e=Object.prototype.hasOwnProperty,r=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,d={key:!0,ref:!0,__self:!0,__source:!0};function c(s,l,p){var m,v={},w=null,T=null;p!==void 0&&(w=""+p),l.key!==void 0&&(w=""+l.key),l.ref!==void 0&&(T=l.ref);for(m in l)e.call(l,m)&&!d.hasOwnProperty(m)&&(v[m]=l[m]);if(s&&s.defaultProps)for(m in l=s.defaultProps,l)v[m]===void 0&&(v[m]=l[m]);return{$$typeof:n,type:s,key:w,ref:T,props:v,_owner:r.current}}return Ae.Fragment=i,Ae.jsx=c,Ae.jsxs=c,Ae}var Ne={};/**
|
10
10
|
* @license React
|
11
11
|
* react-jsx-runtime.development.js
|
12
12
|
*
|
@@ -14,20 +14,20 @@
|
|
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 kt;function hn(){return kt||(kt=1,process.env.NODE_ENV!=="production"&&function(){var t=
|
18
|
-
`+Ye+a}}var
|
19
|
-
`)
|
20
|
-
`),Y=x.length-1,W
|
21
|
-
`+x[Y].replace(" at new "," at ");return a.displayName&&ie.includes("<anonymous>")&&(ie=ie.replace("<anonymous>",a.displayName)),typeof a=="function"&&Ee.set(a,ie),ie}while(Y>=1&&W>=0);break}}}finally{
|
17
|
+
*/var kt;function hn(){return kt||(kt=1,process.env.NODE_ENV!=="production"&&function(){var t=I,n=Symbol.for("react.element"),i=Symbol.for("react.portal"),e=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),s=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),m=Symbol.for("react.suspense_list"),v=Symbol.for("react.memo"),w=Symbol.for("react.lazy"),T=Symbol.for("react.offscreen"),j=Symbol.iterator,A="@@iterator";function E(a){if(a===null||typeof a!="object")return null;var f=j&&a[j]||a[A];return typeof f=="function"?f:null}var y=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(a){{for(var f=arguments.length,g=new Array(f>1?f-1:0),O=1;O<f;O++)g[O-1]=arguments[O];R("error",a,g)}}function R(a,f,g){{var O=y.ReactDebugCurrentFrame,_=O.getStackAddendum();_!==""&&(f+="%s",g=g.concat([_]));var N=g.map(function(P){return String(P)});N.unshift("Warning: "+f),Function.prototype.apply.call(console[a],console,N)}}var k=!1,K=!1,ne=!1,M=!1,le=!1,Re;Re=Symbol.for("react.module.reference");function se(a){return!!(typeof a=="string"||typeof a=="function"||a===e||a===d||le||a===r||a===p||a===m||M||a===T||k||K||ne||typeof a=="object"&&a!==null&&(a.$$typeof===w||a.$$typeof===v||a.$$typeof===c||a.$$typeof===s||a.$$typeof===l||a.$$typeof===Re||a.getModuleId!==void 0))}function D(a,f,g){var O=a.displayName;if(O)return O;var _=f.displayName||f.name||"";return _!==""?g+"("+_+")":g}function F(a){return a.displayName||"Context"}function B(a){if(a==null)return null;if(typeof a.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case e:return"Fragment";case i:return"Portal";case d:return"Profiler";case r:return"StrictMode";case p:return"Suspense";case m:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case s:var f=a;return F(f)+".Consumer";case c:var g=a;return F(g._context)+".Provider";case l:return D(a,a.render,"ForwardRef");case v:var O=a.displayName||null;return O!==null?O:B(a.type)||"Memo";case w:{var _=a,N=_._payload,P=_._init;try{return B(P(N))}catch{return null}}}return null}var ee=Object.assign,ae=0,Me,Ue,Fe,Pe,Be,qe,Ve;function $e(){}$e.__reactDisabledLog=!0;function vt(){{if(ae===0){Me=console.log,Ue=console.info,Fe=console.warn,Pe=console.error,Be=console.group,qe=console.groupCollapsed,Ve=console.groupEnd;var a={configurable:!0,enumerable:!0,value:$e,writable:!0};Object.defineProperties(console,{info:a,log:a,warn:a,error:a,group:a,groupCollapsed:a,groupEnd:a})}ae++}}function bt(){{if(ae--,ae===0){var a={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:ee({},a,{value:Me}),info:ee({},a,{value:Ue}),warn:ee({},a,{value:Fe}),error:ee({},a,{value:Pe}),group:ee({},a,{value:Be}),groupCollapsed:ee({},a,{value:qe}),groupEnd:ee({},a,{value:Ve})})}ae<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Ge=y.ReactCurrentDispatcher,Ye;function ye(a,f,g){{if(Ye===void 0)try{throw Error()}catch(_){var O=_.stack.trim().match(/\n( *(at )?)/);Ye=O&&O[1]||""}return`
|
18
|
+
`+Ye+a}}var je=!1,Ee;{var yt=typeof WeakMap=="function"?WeakMap:Map;Ee=new yt}function et(a,f){if(!a||je)return"";{var g=Ee.get(a);if(g!==void 0)return g}var O;je=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var N;N=Ge.current,Ge.current=null,vt();try{if(f){var P=function(){throw Error()};if(Object.defineProperty(P.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(P,[])}catch(ce){O=ce}Reflect.construct(a,[],P)}else{try{P.call()}catch(ce){O=ce}a.call(P.prototype)}}else{try{throw Error()}catch(ce){O=ce}a()}}catch(ce){if(ce&&O&&typeof ce.stack=="string"){for(var x=ce.stack.split(`
|
19
|
+
`),$=O.stack.split(`
|
20
|
+
`),Y=x.length-1,W=$.length-1;Y>=1&&W>=0&&x[Y]!==$[W];)W--;for(;Y>=1&&W>=0;Y--,W--)if(x[Y]!==$[W]){if(Y!==1||W!==1)do if(Y--,W--,W<0||x[Y]!==$[W]){var ie=`
|
21
|
+
`+x[Y].replace(" at new "," at ");return a.displayName&&ie.includes("<anonymous>")&&(ie=ie.replace("<anonymous>",a.displayName)),typeof a=="function"&&Ee.set(a,ie),ie}while(Y>=1&&W>=0);break}}}finally{je=!1,Ge.current=N,bt(),Error.prepareStackTrace=_}var De=a?a.displayName||a.name:"",Zt=De?ye(De):"";return typeof a=="function"&&Ee.set(a,Zt),Zt}function tt(a,f,g){return et(a,!1)}function nt(a){var f=a.prototype;return!!(f&&f.isReactComponent)}function we(a,f,g){if(a==null)return"";if(typeof a=="function")return et(a,nt(a));if(typeof a=="string")return ye(a);switch(a){case p:return ye("Suspense");case m:return ye("SuspenseList")}if(typeof a=="object")switch(a.$$typeof){case l:return tt(a.render);case v:return we(a.type,f,g);case w:{var O=a,_=O._payload,N=O._init;try{return we(N(_),f,g)}catch{}}}return""}var ke=Object.prototype.hasOwnProperty,at={},ze=y.ReactDebugCurrentFrame;function ue(a){if(a){var f=a._owner,g=we(a.type,a._source,f?f.type:null);ze.setExtraStackFrame(g)}else ze.setExtraStackFrame(null)}function Ce(a,f,g,O,_){{var N=Function.call.bind(ke);for(var P in a)if(N(a,P)){var x=void 0;try{if(typeof a[P]!="function"){var $=Error((O||"React class")+": "+g+" type `"+P+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof a[P]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw $.name="Invariant Violation",$}x=a[P](f,P,O,g,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Y){x=Y}x&&!(x instanceof Error)&&(ue(_),b("%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).",O||"React class",g,P,typeof x),ue(null)),x instanceof Error&&!(x.message in at)&&(at[x.message]=!0,ue(_),b("Failed %s type: %s",g,x.message),ue(null))}}}var Et=Array.isArray;function He(a){return Et(a)}function it(a){{var f=typeof Symbol=="function"&&Symbol.toStringTag,g=f&&a[Symbol.toStringTag]||a.constructor.name||"Object";return g}}function We(a){try{return rt(a),!1}catch{return!0}}function rt(a){return""+a}function ot(a){if(We(a))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",it(a)),rt(a)}var de=y.ReactCurrentOwner,wt={key:!0,ref:!0,__self:!0,__source:!0},st,Ke,Se;Se={};function o(a){if(ke.call(a,"ref")){var f=Object.getOwnPropertyDescriptor(a,"ref").get;if(f&&f.isReactWarning)return!1}return a.ref!==void 0}function C(a){if(ke.call(a,"key")){var f=Object.getOwnPropertyDescriptor(a,"key").get;if(f&&f.isReactWarning)return!1}return a.key!==void 0}function V(a,f){if(typeof a.ref=="string"&&de.current&&f&&de.current.stateNode!==f){var g=B(de.current.type);Se[g]||(b('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',B(de.current.type),a.ref),Se[g]=!0)}}function G(a,f){{var g=function(){st||(st=!0,b("%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)",f))};g.isReactWarning=!0,Object.defineProperty(a,"key",{get:g,configurable:!0})}}function q(a,f){{var g=function(){Ke||(Ke=!0,b("%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)",f))};g.isReactWarning=!0,Object.defineProperty(a,"ref",{get:g,configurable:!0})}}var fe=function(a,f,g,O,_,N,P){var x={$$typeof:n,type:a,key:f,ref:g,props:P,_owner:N};return x._store={},Object.defineProperty(x._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(x,"_self",{configurable:!1,enumerable:!1,writable:!1,value:O}),Object.defineProperty(x,"_source",{configurable:!1,enumerable:!1,writable:!1,value:_}),Object.freeze&&(Object.freeze(x.props),Object.freeze(x)),x};function re(a,f,g,O,_){{var N,P={},x=null,$=null;g!==void 0&&(ot(g),x=""+g),C(f)&&(ot(f.key),x=""+f.key),o(f)&&($=f.ref,V(f,_));for(N in f)ke.call(f,N)&&!wt.hasOwnProperty(N)&&(P[N]=f[N]);if(a&&a.defaultProps){var Y=a.defaultProps;for(N in Y)P[N]===void 0&&(P[N]=Y[N])}if(x||$){var W=typeof a=="function"?a.displayName||a.name||"Unknown":a;x&&G(P,W),$&&q(P,W)}return fe(a,x,$,_,O,de.current,P)}}var ct=y.ReactCurrentOwner,Xe=y.ReactDebugCurrentFrame;function Z(a){if(a){var f=a._owner,g=we(a.type,a._source,f?f.type:null);Xe.setExtraStackFrame(g)}else Xe.setExtraStackFrame(null)}var te;te=!1;function he(a){return typeof a=="object"&&a!==null&&a.$$typeof===n}function pe(){{if(ct.current){var a=B(ct.current.type);if(a)return`
|
22
22
|
|
23
|
-
Check the render method of \``+a+"`."}return""}}function Oe(a){{if(a!==void 0){var
|
23
|
+
Check the render method of \``+a+"`."}return""}}function Oe(a){{if(a!==void 0){var f=a.fileName.replace(/^.*[\\\/]/,""),g=a.lineNumber;return`
|
24
24
|
|
25
|
-
Check your code at `+
|
25
|
+
Check your code at `+f+":"+g+"."}return""}}var Te={};function Un(a){{var f=pe();if(!f){var g=typeof a=="string"?a:a.displayName||a.name;g&&(f=`
|
26
26
|
|
27
|
-
Check the top-level render call using <`+g+">.")}return
|
27
|
+
Check the top-level render call using <`+g+">.")}return f}}function Wt(a,f){{if(!a._store||a._store.validated||a.key!=null)return;a._store.validated=!0;var g=Un(f);if(Te[g])return;Te[g]=!0;var O="";a&&a._owner&&a._owner!==ct.current&&(O=" It was passed a child from "+B(a._owner.type)+"."),Z(a),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',g,O),Z(null)}}function Kt(a,f){{if(typeof a!="object")return;if(He(a))for(var g=0;g<a.length;g++){var O=a[g];he(O)&&Wt(O,f)}else if(he(a))a._store&&(a._store.validated=!0);else if(a){var _=E(a);if(typeof _=="function"&&_!==a.entries)for(var N=_.call(a),P;!(P=N.next()).done;)he(P.value)&&Wt(P.value,f)}}}function Fn(a){{var f=a.type;if(f==null||typeof f=="string")return;var g;if(typeof f=="function")g=f.propTypes;else if(typeof f=="object"&&(f.$$typeof===l||f.$$typeof===v))g=f.propTypes;else return;if(g){var O=B(f);Ce(g,a.props,"prop",O,a)}else if(f.PropTypes!==void 0&&!te){te=!0;var _=B(f);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",_||"Unknown")}typeof f.getDefaultProps=="function"&&!f.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Bn(a){{for(var f=Object.keys(a.props),g=0;g<f.length;g++){var O=f[g];if(O!=="children"&&O!=="key"){Z(a),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",O),Z(null);break}}a.ref!==null&&(Z(a),b("Invalid attribute `ref` supplied to `React.Fragment`."),Z(null))}}function Xt(a,f,g,O,_,N){{var P=se(a);if(!P){var x="";(a===void 0||typeof a=="object"&&a!==null&&Object.keys(a).length===0)&&(x+=" 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 $=Oe(_);$?x+=$:x+=pe();var Y;a===null?Y="null":He(a)?Y="array":a!==void 0&&a.$$typeof===n?(Y="<"+(B(a.type)||"Unknown")+" />",x=" Did you accidentally export a JSX literal instead of a component?"):Y=typeof a,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Y,x)}var W=re(a,f,g,_,N);if(W==null)return W;if(P){var ie=f.children;if(ie!==void 0)if(O)if(He(ie)){for(var De=0;De<ie.length;De++)Kt(ie[De],a);Object.freeze&&Object.freeze(ie)}else b("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 Kt(ie,a)}return a===e?Bn(W):Fn(W),W}}function Vn(a,f,g){return Xt(a,f,g,!0)}function Gn(a,f,g){return Xt(a,f,g,!1)}var Yn=Gn,zn=Vn;Ne.Fragment=e,Ne.jsx=Yn,Ne.jsxs=zn}()),Ne}process.env.NODE_ENV==="production"?dt.exports=fn():dt.exports=hn();var u=dt.exports;function ft(t){return t.title.search("<")>-1?u.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:t.title}}):u.jsx("button",{children:t.title})}const pn=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"})]}),mn=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 Dt(t){return d.jsx(Ct.Reorder.Item,{value:t.title,children:d.jsxs("div",{children:[pn,d.jsx("span",{children:t.title}),d.jsx("button",{className:"closeIcon",onClick:()=>{t.onDelete(t.index)},children:mn})]})},t.title)}function _t(t){const[n,i]=A.useState(!1),[e,r]=A.useState(t.options),l=m=>{t.onDragComplete(m),r(m)},c=m=>{const p=[...e];p.splice(m,1),l(p)},s=[];e.forEach((m,p)=>{s.push(d.jsx(Dt,{index:p,title:m,onDelete:c},m))});let u="dropdown draggable";return t.subdropdown&&(u+=" subdropdown"),d.jsxs("div",{className:u,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[d.jsx(ft,{title:t.title}),d.jsx(Ct.Reorder.Group,{axis:"y",values:e,onReorder:l,style:{visibility:n?"visible":"hidden"},children:s})]})}function At(t){const[n,i]=A.useState(!1),e=[];t.options.map((l,c)=>{t.onSelect!==void 0&&(l.onSelect=t.onSelect),e.push(d.jsx(It,{option:l},c))});let r="dropdown";return t.subdropdown&&(r+=" subdropdown"),d.jsxs("div",{className:r,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[d.jsx(ft,{title:t.title}),d.jsx("ul",{style:{visibility:n?"visible":"hidden"},children:e})]})}function It(t){const{option:n}=t,[i,e]=A.useState("");let r;switch(n.type){case"draggable":r=d.jsx(_t,{title:n.title,options:n.value,onDragComplete:l=>{n.onDragComplete!==void 0&&n.onDragComplete(l)},subdropdown:!0});break;case"dropdown":r=d.jsx(At,{title:n.title,options:n.value,onSelect:n.onSelect,subdropdown:!0});break;case"option":r=d.jsx("button",{onClick:()=>{n.onSelect!==void 0&&n.onSelect(n.value),n.selectable&&(i!==n.title?e(n.title):e(""))},children:n.title});break}return d.jsx("li",{className:i===n.title?"selected":"",children:r},St())}function gn(t){let n;function i(c){var u,m,p,v,w,T,M,I,E;let s;switch(c.event){case"custom":L.dispatchEvent({type:U.CUSTOM,value:c.data});break;case"selectComponent":L.dispatchEvent({type:U.SELECT_DROPDOWN,value:c.data});break;case"draggableListUpdate":L.dispatchEvent({type:U.DRAG_UPDATE,value:c.data});break;case"addFolder":(u=t.components.get("debug"))==null||u.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":(p=t.components.get("debug"))==null||p.triggerBind(c.data.id,c.data.value);break;case"addButton":(v=t.components.get("debug"))==null||v.button(c.data.name,c.data.callback,c.data.parent);break;case"clickButton":(w=t.components.get("debug"))==null||w.triggerButton(c.data.id);break;case"setSheet":s=(T=t.components.get("theatre"))==null?void 0:T.sheets.get(c.data.sheet),s!==void 0&&(n=s,_e.setSelection([s]));break;case"setSheetObject":s=(M=t.components.get("theatre"))==null?void 0:M.sheetObjects.get(`${c.data.sheet}_${c.data.key}`),s!==void 0&&_e.setSelection([s]);break;case"updateSheetObject":s=(I=t.components.get("theatre"))==null?void 0:I.sheetObjectCBs.get(c.data.sheetObject),s!==void 0&&s(c.data.values);break;case"updateTimeline":n=(E=t.components.get("theatre"))==null?void 0:E.sheets.get(c.data.sheet),n!==void 0&&(n.sequence.position=c.data.position);break;case"getScene":L.dispatchEvent({type:U.GET_SCENE});break;case"getObject":L.dispatchEvent({type:U.GET_OBJECT,value:c.data});break;case"updateObject":L.dispatchEvent({type:U.UPDATE_OBJECT,value:c.data});break;case"createTexture":L.dispatchEvent({type:U.CREATE_TEXTURE,value:c.data});break;case"requestMethod":L.dispatchEvent({type:U.REQUEST_METHOD,value:c.data});break}}function e(c){switch(c.event){case"custom":L.dispatchEvent({type:U.CUSTOM,value:c.data});break;case"setObject":L.dispatchEvent({type:U.SET_OBJECT,value:c.data});break;case"setScene":L.dispatchEvent({type:U.SET_SCENE,value:c.data});break}}function r(){_e.ui.hide()}function l(){_e.ui.restore(),_e.onSelectionChange(m=>{m.length<1||m.forEach(p=>{var M;let v=p.address.sheetId,w="setSheet",T={};switch(p.type){case"Theatre_Sheet_PublicAPI":w="setSheet",T={sheet:p.address.sheetId},n=(M=t.components.get("theatre"))==null?void 0:M.sheets.get(p.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":w="setSheetObject",v+=`_${p.address.objectKey}`,T={id:v,sheet:p.address.sheetId,key:p.address.objectKey};break}t.send({event:w,target:"app",data:T})})});let c=0;const s=()=>{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}})}},u=()=>{s(),requestAnimationFrame(u)};s(),u()}t.listen(c=>{t.editor?e(c):i(c)}),t.editor?l():r()}const Kn="";function Ze(t){const[n,i]=A.useState(t.open!==void 0?t.open:!0),e=!n||t.children===void 0;return d.jsxs("div",{className:`accordion ${e?"hide":""}`,children:[d.jsxs("button",{className:"toggle",onClick:()=>{const r=!n;t.onToggle!==void 0&&t.onToggle(r),i(r)},children:[d.jsx("p",{className:`status ${n?"open":""}`,children:"Toggle"}),d.jsx("p",{className:"label",children:t.label})]}),t.button,d.jsx("div",{className:n?"open":"",children:d.jsx("div",{children:t.children})})]})}function ht(t){const[n,i]=A.useState(t.child.children.length>0),e=t.child.children.length>0,r=[];return t.child.children.length>0&&t.child.children.map(l=>{r.push(d.jsx(ht,{child:l,three:t.three},Math.random()))}),d.jsxs("div",{className:"childObject",children:[d.jsxs("div",{className:"child",children:[e?d.jsx("button",{className:"status",style:{backgroundPositionX:n?"-14px":"2px"},onClick:()=>{i(!n)}}):null,d.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}`}),d.jsx("div",{className:`icon ${on(t.child)}`})]}),d.jsx("div",{className:n?"open":"",children:d.jsx("div",{className:"container",children:r})})]},Math.random())}function Nt(t){const n=[];return t.child.children.map(i=>{n.push(d.jsx(ht,{child:i,three:t.three},Math.random()))}),d.jsx("div",{className:`scene ${t.class!==void 0?t.class:""}`,children:n})}const Xn="",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 xe(t){function n(e,r){console.log("onChange:",e,r)}const i=[];return t.items.forEach(e=>{bn(e)?i.push(d.jsx(xe,{title:e.title,items:e.items},Math.random())):i.push(d.jsx(Le,{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,l)=>{e.onChange!==void 0?e.onChange(r,l):n(r,l)}},Math.random()))}),d.jsx(Ze,{label:t.title,open:!1,children:i})}function yn(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 ge(t){switch(t){case"alphaMap":return"Alpha 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"clearcoatNormalScale":return"Clearcoat Normal Scale";case"clearcoatRoughness":return"Clearcoat Roughness";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"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"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"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"sheenColor":return"Sheen Color";case"sheenRoughness":return"Sheen Roughness";case"shininess":return"Shininess";case"specular":return"Specular";case"specularColor":return"Specular Color";case"specularIntensity":return"Specular Intensity";case"thickness":return"Thickness";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 En(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 wn(){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],r=new FileReader;r.onload=function(l){n(l.target.result)},r.readAsDataURL(e)}}),t.click()})}function Lt(t,n,i){const e=[];for(const r in t){if(!yn(r))continue;const l=typeof t[r],c=t[r];if(l==="boolean"||l==="number"||l==="string"){const s={title:ge(r),prop:r,type:l,value:c,min:void 0,max:void 0,onChange:(u,m)=>{var v;i.updateObject(n.uuid,`material.${u}`,m),l==="boolean"&&i.updateObject(n.uuid,"material.needsUpdate",!0);const p=(v=i.scene)==null?void 0:v.getObjectByProperty("uuid",n.uuid);p!==void 0&&$(p,`material.${u}`,m)}};En(r)&&(s.value=Number(c),s.type="range",s.min=0,s.max=1,s.step=.01),e.push(s)}else if(l==="object")if(c.isColor)e.push({title:ge(r),prop:r,type:"color",value:c,onChange:(s,u)=>{var v;const m=new f.Color(u);i.updateObject(n.uuid,`material.${s}`,m);const p=(v=i.scene)==null?void 0:v.getObjectByProperty("uuid",n.uuid);p!==void 0&&$(p,`material.${s}`,m)}});else if(Array.isArray(c)){const s=[];for(const u in c)s.push({title:`${u}`,type:`${typeof c[u]}`,value:c[u],onChange:(m,p)=>{var w;i.updateObject(n.uuid,`material.${r}`,p);const v=(w=i.scene)==null?void 0:w.getObjectByProperty("uuid",n.uuid);v!==void 0&&$(v,`material.${r}`,p)}});e.push({title:ge(r),items:s})}else{const s=[];for(const u in c){const m=c[u];switch(typeof m){case"boolean":case"number":case"string":u==="src"?e.push({title:ge(r),type:"image",value:m,onChange:(v,w)=>{var M;i.createTexture(n.uuid,`material.${r}`,w);const T=(M=i.scene)==null?void 0:M.getObjectByProperty("uuid",n.uuid);T!==void 0&&ut(w).then(I=>{$(T,`material.${r}`,I),$(T,"material.needsUpdate",!0)})}}):s.push({title:`${ge(u)}`,prop:`material.${r}.${u}`,type:`${typeof t[r][u]}`,value:c[u],onChange:(v,w)=>{var M;i.updateObject(n.uuid,`material.${r}.${u}`,w);const T=(M=i.scene)==null?void 0:M.getObjectByProperty("uuid",n.uuid);T!==void 0&&$(T,`material.${r}.${u}`,w)}});break;case"object":m.value!==void 0&&m.value.src!==void 0?s.push({title:ge(u),type:"image",value:m.value.src,onChange:(v,w)=>{var M;i.createTexture(n.uuid,`material.${r}.${u}.value`,w);const T=(M=i.scene)==null?void 0:M.getObjectByProperty("uuid",n.uuid);T!==void 0&&ut(w).then(I=>{$(T,`material.${r}.${u}.value`,I)})}}):s.push({title:u,type:`${typeof m.value}`,value:m.value,onChange:(v,w)=>{var M;i.updateObject(n.uuid,`material.${r}.${u}.value`,w);const T=(M=i.scene)==null?void 0:M.getObjectByProperty("uuid",n.uuid);T!==void 0&&$(T,`material.${r}.${u}.value`,w)}});break}}s.length>0&&e.push({title:ge(r),items:s})}else c!==void 0&&console.log("other:",r,l,c)}return e.sort((r,l)=>r.title<l.title?-1:r.title>l.title?1:0),e.push({title:"Update Material",type:"button",onChange:()=>{i.updateObject(n.uuid,"material.needsUpdate",!0)}}),e}function Cn(t,n){const i=t.material;if(Array.isArray(i)){const e=[],r=i.length;for(let l=0;l<r;l++)e.push(d.jsx(xe,{title:`Material ${l}`,items:Lt(i[l],t,n)}));return d.jsx(d.Fragment,{children:e})}else return d.jsx(xe,{title:"Material",items:Lt(i,t,n)})}function Le(t){let n=t.value;n!==void 0&&n.isColor!==void 0&&(n=Tt(t.value));const[i,e]=A.useState(n),r=A.useRef(null),l=A.useRef(null),c=A.useRef(null);A.useEffect(()=>{var R;let p=!1,v=-1,w=0,T=Number(i);const M=k=>{p=!0,w=T,v=k.clientX},I=k=>{if(!p)return;const K=t.step!==void 0?t.step:1,ne=(k.clientX-v)*K;T=Number((w+ne).toFixed(4)),l.current!==null&&(l.current.value=T.toString()),t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,T)},E=()=>{p=!1},y=()=>{p=!1},b=t.type==="number";return b&&((R=r.current)==null||R.addEventListener("mousedown",M,!1),document.addEventListener("mouseup",E,!1),document.addEventListener("mousemove",I,!1),document.addEventListener("contextmenu",y,!1)),()=>{var k;b&&((k=r.current)==null||k.removeEventListener("mousedown",M),document.removeEventListener("mouseup",E),document.removeEventListener("mousemove",I),document.removeEventListener("contextmenu",y))}},[i]);const s=t.type==="string"&&(i.length>100||i.search(`
|
30
|
-
`)>-1),u=s||t.type==="image",m=p=>{let v=p.target.value;t.type==="boolean"&&(v=p.target.checked),e(v),t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,v)};return d.jsxs("div",{className:`field ${u?"block":""}`,children:[t.type!=="button"&&d.jsx("label",{ref:r,children:t.title},"fieldLabel"),t.type==="string"&&!s&&d.jsx("input",{type:"text",disabled:t.disabled,onChange:m,value:i}),t.type==="string"&&s&&d.jsx("textarea",{cols:50,rows:10,disabled:!0,onChange:m,value:i}),t.type==="boolean"&&d.jsx("input",{type:"checkbox",disabled:t.disabled,onChange:m,checked:i}),t.type==="number"&&d.jsx("input",{ref:l,type:"number",value:i,min:t.min,max:t.max,step:t.step,onChange:m}),t.type==="range"&&d.jsxs(d.Fragment,{children:[d.jsx("input",{type:"text",value:i.toString(),onChange:m,className:"min"}),d.jsx("input",{disabled:t.disabled,type:"range",value:i,min:t.min,max:t.max,step:t.step,onChange:m})]}),t.type==="color"&&d.jsxs(d.Fragment,{children:[d.jsx("input",{type:"text",value:i.toString(),onChange:m,className:"color"}),d.jsx("input",{type:"color",value:i,onChange:m})]}),t.type==="button"&&d.jsx("button",{onClick:()=>{t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,!0)},children:t.title}),t.type==="image"&&d.jsx("img",{ref:c,onClick:()=>{wn().then(p=>{c.current.src=p,t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,p)})},src:i.length>0?i:vn})]})}function Ut(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 Sn(t,n){const i=[];if(t.perspectiveCameraInfo!==void 0)for(const e in t.perspectiveCameraInfo)i.push({title:Ut(e),prop:e,type:"number",step:.01,value:t.perspectiveCameraInfo[e],onChange:(r,l)=>{var s;n.updateObject(t.uuid,r,l),n.requestMethod(t.uuid,"updateProjectionMatrix");const c=(s=n.scene)==null?void 0:s.getObjectByProperty("uuid",t.uuid);c!==void 0&&($(c,r,l),c.updateProjectionMatrix())}});else if(t.orthographicCameraInfo!==void 0)for(const e in t.orthographicCameraInfo)i.push({title:Ut(e),prop:e,type:"number",step:.01,value:t.perspectiveCameraInfo[e],onChange:(r,l)=>{var s;n.updateObject(t.uuid,r,l),n.requestMethod(t.uuid,"updateProjectionMatrix");const c=(s=n.scene)==null?void 0:s.getObjectByProperty("uuid",t.uuid);c!==void 0&&($(c,r,l),c.updateProjectionMatrix())}});return d.jsx(xe,{title:"Camera",items:i})}function On(t,n){const i=new f.Matrix4;i.elements=t.matrix;const e=new f.Vector3,r=new f.Euler,l=new f.Vector3;t.uuid.length>0&&(e.setFromMatrixPosition(i),r.setFromRotationMatrix(i),l.setFromMatrixScale(i));const c=(u,m)=>{var v;n.updateObject(t.uuid,u,m);const p=(v=n.scene)==null?void 0:v.getObjectByProperty("uuid",t.uuid);p!==void 0&&$(p,u,m)},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:r.x,min:-Math.PI,max:Math.PI,step:.01,onChange:c},{title:"Y",prop:"rotation.y",type:"number",value:r.y,min:-Math.PI,max:Math.PI,step:.01,onChange:c},{title:"Z",prop:"rotation.z",type:"number",value:r.z,min:-Math.PI,max:Math.PI,step:.01,onChange:c}]},{title:"Scale",items:[{title:"X",prop:"scale.x",type:"number",value:l.x,step:.01,onChange:c},{title:"Y",prop:"scale.y",type:"number",value:l.y,step:.01,onChange:c},{title:"Z",prop:"scale.z",type:"number",value:l.z,step:.01,onChange:c}]}];return d.jsx(xe,{title:"Transform",items:s})}function Ft(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 Tn(t,n){const i=[];if(t.lightInfo!==void 0)for(const e in t.lightInfo){const r=t.lightInfo[e];r!==void 0&&(r.isColor!==void 0?i.push({title:Ft(e),prop:e,type:"color",value:r,onChange:(l,c)=>{var m;const s=new f.Color(c);n.updateObject(t.uuid,l,s);const u=(m=n.scene)==null?void 0:m.getObjectByProperty("uuid",t.uuid);u!==void 0&&$(u,l,s)}}):i.push({title:Ft(e),prop:e,type:typeof r,value:r,step:typeof r=="number"?.01:void 0,onChange:(l,c)=>{var u;n.updateObject(t.uuid,l,c);const s=(u=n.scene)==null?void 0:u.getObjectByProperty("uuid",t.uuid);s!==void 0&&$(s,l,c)}}))}return d.jsx(xe,{title:"Light",items:i})}function Bt(t){const[n,i]=A.useState(-1),[e,r]=A.useState({name:"",uuid:"",type:"",visible:!1,matrix:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]});return A.useEffect(()=>{function l(c){const s=c.value;r(s),i(Date.now())}return L.addEventListener(U.SET_OBJECT,l),()=>{L.removeEventListener(U.SET_OBJECT,l)}},[]),d.jsx("div",{id:"Inspector",className:t.class,children:e.uuid.length>0&&d.jsxs(d.Fragment,{children:[d.jsx(Le,{type:"string",title:"Name",prop:"name",value:e.name,disabled:!0}),d.jsx(Le,{type:"string",title:"Type",prop:"type",value:e.type,disabled:!0}),d.jsx(Le,{type:"string",title:"UUID",prop:"uuid",value:e.uuid,disabled:!0}),d.jsx(Le,{type:"boolean",title:"Visible",prop:"visible",value:e.visible,onChange:(l,c)=>{t.three.updateObject(e.uuid,l,c)}}),On(e,t.three),e.type.search("Camera")>-1?Sn(e,t.three):null,e.type.search("Light")>-1?Tn(e,t.three):null,e.material!==void 0?Cn(e,t.three):null]})},n)}class xn extends A.Component{constructor(i){super(i);z(this,"three");z(this,"onRefresh",()=>{this.three.getScene()});z(this,"setScene",i=>{this.setState(()=>({scene:i.value}))});this.state={scene:i.scene!==void 0?i.scene:null},this.three=i.three,L.addEventListener(U.SET_SCENE,this.setScene)}componentDidMount(){this.onRefresh()}componentWillUnmount(){L.removeEventListener(U.SET_SCENE,this.setScene)}render(){var r;const i=this.componentState.scene!==null,e="Hierarchy"+(i?`: ${(r=this.componentState.scene)==null?void 0:r.name}`:"");return d.jsx("div",{id:"SceneHierarchy",children:d.jsxs(d.Fragment,{children:[i&&d.jsx(Ze,{label:e,button:d.jsx("button",{className:"icon refresh hideText",onClick:this.onRefresh,children:"Refresh"}),open:!0,children:d.jsx(Nt,{child:this.componentState.scene,three:this.three})}),d.jsx(Ze,{label:"Inspector",children:d.jsx(Bt,{three:this.three},"Inspector")})]})},"SceneHierarchy")}get componentState(){return this.state}}function Rn(t){const n=s=>{const u=t.scene.getObjectByProperty("uuid",s.value);u!==void 0&&t.three.setObject(u)},i=(s,u,m)=>{const p=t.scene.getObjectByProperty("uuid",s);p!==void 0&&$(p,u,m)},e=s=>{const u=s.value,{key:m,value:p,uuid:v}=u;i(v,m,p)},r=s=>{const u=s.value;ut(u.value).then(m=>{i(u.uuid,u.key,m),i(u.uuid,"material.needsUpdate",!0)})},l=()=>{t.three.setScene(t.scene)},c=s=>{const{key:u,uuid:m,value:p}=s.value,v=t.scene.getObjectByProperty("uuid",m);if(v!==void 0)try{v[u](p)}catch(w){console.log("Error requesting method:"),console.log(w),console.log(u),console.log(p)}};return A.useEffect(()=>(L.addEventListener(U.GET_OBJECT,n),L.addEventListener(U.GET_SCENE,l),L.addEventListener(U.UPDATE_OBJECT,e),L.addEventListener(U.CREATE_TEXTURE,r),L.addEventListener(U.REQUEST_METHOD,c),()=>{L.removeEventListener(U.GET_OBJECT,n),L.removeEventListener(U.GET_SCENE,l),L.removeEventListener(U.UPDATE_OBJECT,e),L.removeEventListener(U.CREATE_TEXTURE,r),L.removeEventListener(U.REQUEST_METHOD,c)}),[]),null}const Vt={type:"change"},mt={type:"start"},Gt={type:"end"},Je=new f.Ray,Yt=new f.Plane,Pn=Math.cos(70*f.MathUtils.DEG2RAD);class jn extends f.EventDispatcher{constructor(n,i){super(),this.object=n,this.domElement=i,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new f.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=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 s.phi},this.getAzimuthalAngle=function(){return s.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(o){o.addEventListener("keydown",We),this._domElementKeyEvents=o},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",We),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(Vt),e.update(),l=r.NONE},this.update=function(){const o=new f.Vector3,C=new f.Quaternion().setFromUnitVectors(n.up,new f.Vector3(0,1,0)),V=C.clone().invert(),G=new f.Vector3,Q=new f.Quaternion,fe=new f.Vector3,re=2*Math.PI;return function(){const Xe=e.object.position;o.copy(Xe).sub(e.target),o.applyQuaternion(C),s.setFromVector3(o),e.autoRotate&&l===r.NONE&&D(Re()),e.enableDamping?(s.theta+=u.theta*e.dampingFactor,s.phi+=u.phi*e.dampingFactor):(s.theta+=u.theta,s.phi+=u.phi);let Z=e.minAzimuthAngle,te=e.maxAzimuthAngle;isFinite(Z)&&isFinite(te)&&(Z<-Math.PI?Z+=re:Z>Math.PI&&(Z-=re),te<-Math.PI?te+=re:te>Math.PI&&(te-=re),Z<=te?s.theta=Math.max(Z,Math.min(te,s.theta)):s.theta=s.theta>(Z+te)/2?Math.max(Z,s.theta):Math.min(te,s.theta)),s.phi=Math.max(e.minPolarAngle,Math.min(e.maxPolarAngle,s.phi)),s.makeSafe(),e.enableDamping===!0?e.target.addScaledVector(p,e.dampingFactor):e.target.add(p),e.zoomToCursor&&ne||e.object.isOrthographicCamera?s.radius=je(s.radius):s.radius=je(s.radius*m),o.setFromSpherical(s),o.applyQuaternion(V),Xe.copy(e.target).add(o),e.object.lookAt(e.target),e.enableDamping===!0?(u.theta*=1-e.dampingFactor,u.phi*=1-e.dampingFactor,p.multiplyScalar(1-e.dampingFactor)):(u.set(0,0,0),p.set(0,0,0));let he=!1;if(e.zoomToCursor&&ne){let me=null;if(e.object.isPerspectiveCamera){const Oe=o.length();me=je(Oe*m);const Te=Oe-me;e.object.position.addScaledVector(k,Te),e.object.updateMatrixWorld()}else if(e.object.isOrthographicCamera){const Oe=new f.Vector3(K.x,K.y,0);Oe.unproject(e.object),e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/m)),e.object.updateProjectionMatrix(),he=!0;const Te=new f.Vector3(K.x,K.y,0);Te.unproject(e.object),e.object.position.sub(Te).add(Oe),e.object.updateMatrixWorld(),me=o.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),e.zoomToCursor=!1;me!==null&&(this.screenSpacePanning?e.target.set(0,0,-1).transformDirection(e.object.matrix).multiplyScalar(me).add(e.object.position):(Je.origin.copy(e.object.position),Je.direction.set(0,0,-1).transformDirection(e.object.matrix),Math.abs(e.object.up.dot(Je.direction))<Pn?n.lookAt(e.target):(Yt.setFromNormalAndCoplanarPoint(e.object.up,e.target),Je.intersectPlane(Yt,e.target))))}else e.object.isOrthographicCamera&&(e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/m)),e.object.updateProjectionMatrix(),he=!0);return m=1,ne=!1,he||G.distanceToSquared(e.object.position)>c||8*(1-Q.dot(e.object.quaternion))>c||fe.distanceToSquared(e.target)>0?(e.dispatchEvent(Vt),G.copy(e.object.position),Q.copy(e.object.quaternion),fe.copy(e.target),he=!1,!0):!1}}(),this.dispose=function(){e.domElement.removeEventListener("contextmenu",de),e.domElement.removeEventListener("pointerdown",ze),e.domElement.removeEventListener("pointercancel",Ce),e.domElement.removeEventListener("wheel",it),e.domElement.removeEventListener("pointermove",ue),e.domElement.removeEventListener("pointerup",Ce),e._domElementKeyEvents!==null&&(e._domElementKeyEvents.removeEventListener("keydown",We),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 l=r.NONE;const c=1e-6,s=new f.Spherical,u=new f.Spherical;let m=1;const p=new f.Vector3,v=new f.Vector2,w=new f.Vector2,T=new f.Vector2,M=new f.Vector2,I=new f.Vector2,E=new f.Vector2,y=new f.Vector2,b=new f.Vector2,R=new f.Vector2,k=new f.Vector3,K=new f.Vector2;let ne=!1;const P=[],le={};function Re(){return 2*Math.PI/60/60*e.autoRotateSpeed}function se(){return Math.pow(.95,e.zoomSpeed)}function D(o){u.theta-=o}function F(o){u.phi-=o}const B=function(){const o=new f.Vector3;return function(V,G){o.setFromMatrixColumn(G,0),o.multiplyScalar(-V),p.add(o)}}(),ee=function(){const o=new f.Vector3;return function(V,G){e.screenSpacePanning===!0?o.setFromMatrixColumn(G,1):(o.setFromMatrixColumn(G,0),o.crossVectors(e.object.up,o)),o.multiplyScalar(V),p.add(o)}}(),ae=function(){const o=new f.Vector3;return function(V,G){const Q=e.domElement;if(e.object.isPerspectiveCamera){const fe=e.object.position;o.copy(fe).sub(e.target);let re=o.length();re*=Math.tan(e.object.fov/2*Math.PI/180),B(2*V*re/Q.clientHeight,e.object.matrix),ee(2*G*re/Q.clientHeight,e.object.matrix)}else e.object.isOrthographicCamera?(B(V*(e.object.right-e.object.left)/e.object.zoom/Q.clientWidth,e.object.matrix),ee(G*(e.object.top-e.object.bottom)/e.object.zoom/Q.clientHeight,e.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),e.enablePan=!1)}}();function Pe(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 Ue(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 Fe(o){if(!e.zoomToCursor)return;ne=!0;const C=e.domElement.getBoundingClientRect(),V=o.clientX-C.left,G=o.clientY-C.top,Q=C.width,fe=C.height;K.x=V/Q*2-1,K.y=-(G/fe)*2+1,k.set(K.x,K.y,1).unproject(n).sub(n.position).normalize()}function je(o){return Math.max(e.minDistance,Math.min(e.maxDistance,o))}function Be(o){v.set(o.clientX,o.clientY)}function qe(o){Fe(o),y.set(o.clientX,o.clientY)}function Ve(o){M.set(o.clientX,o.clientY)}function $e(o){w.set(o.clientX,o.clientY),T.subVectors(w,v).multiplyScalar(e.rotateSpeed);const C=e.domElement;D(2*Math.PI*T.x/C.clientHeight),F(2*Math.PI*T.y/C.clientHeight),v.copy(w),e.update()}function vt(o){b.set(o.clientX,o.clientY),R.subVectors(b,y),R.y>0?Pe(se()):R.y<0&&Ue(se()),y.copy(b),e.update()}function bt(o){I.set(o.clientX,o.clientY),E.subVectors(I,M).multiplyScalar(e.panSpeed),ae(E.x,E.y),M.copy(I),e.update()}function Ge(o){Fe(o),o.deltaY<0?Ue(se()):o.deltaY>0&&Pe(se()),e.update()}function Ye(o){let C=!1;switch(o.code){case e.keys.UP:o.ctrlKey||o.metaKey||o.shiftKey?F(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):ae(0,e.keyPanSpeed),C=!0;break;case e.keys.BOTTOM:o.ctrlKey||o.metaKey||o.shiftKey?F(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):ae(0,-e.keyPanSpeed),C=!0;break;case e.keys.LEFT:o.ctrlKey||o.metaKey||o.shiftKey?D(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):ae(e.keyPanSpeed,0),C=!0;break;case e.keys.RIGHT:o.ctrlKey||o.metaKey||o.shiftKey?D(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):ae(-e.keyPanSpeed,0),C=!0;break}C&&(o.preventDefault(),e.update())}function ye(){if(P.length===1)v.set(P[0].pageX,P[0].pageY);else{const o=.5*(P[0].pageX+P[1].pageX),C=.5*(P[0].pageY+P[1].pageY);v.set(o,C)}}function Me(){if(P.length===1)M.set(P[0].pageX,P[0].pageY);else{const o=.5*(P[0].pageX+P[1].pageX),C=.5*(P[0].pageY+P[1].pageY);M.set(o,C)}}function Ee(){const o=P[0].pageX-P[1].pageX,C=P[0].pageY-P[1].pageY,V=Math.sqrt(o*o+C*C);y.set(0,V)}function yt(){e.enableZoom&&Ee(),e.enablePan&&Me()}function et(){e.enableZoom&&Ee(),e.enableRotate&&ye()}function tt(o){if(P.length==1)w.set(o.pageX,o.pageY);else{const V=Se(o),G=.5*(o.pageX+V.x),Q=.5*(o.pageY+V.y);w.set(G,Q)}T.subVectors(w,v).multiplyScalar(e.rotateSpeed);const C=e.domElement;D(2*Math.PI*T.x/C.clientHeight),F(2*Math.PI*T.y/C.clientHeight),v.copy(w)}function nt(o){if(P.length===1)I.set(o.pageX,o.pageY);else{const C=Se(o),V=.5*(o.pageX+C.x),G=.5*(o.pageY+C.y);I.set(V,G)}E.subVectors(I,M).multiplyScalar(e.panSpeed),ae(E.x,E.y),M.copy(I)}function we(o){const C=Se(o),V=o.pageX-C.x,G=o.pageY-C.y,Q=Math.sqrt(V*V+G*G);b.set(0,Q),R.set(0,Math.pow(b.y/y.y,e.zoomSpeed)),Pe(R.y),y.copy(b)}function ke(o){e.enableZoom&&we(o),e.enablePan&&nt(o)}function at(o){e.enableZoom&&we(o),e.enableRotate&&tt(o)}function ze(o){e.enabled!==!1&&(P.length===0&&(e.domElement.setPointerCapture(o.pointerId),e.domElement.addEventListener("pointermove",ue),e.domElement.addEventListener("pointerup",Ce)),wt(o),o.pointerType==="touch"?rt(o):Et(o))}function ue(o){e.enabled!==!1&&(o.pointerType==="touch"?ot(o):He(o))}function Ce(o){st(o),P.length===0&&(e.domElement.releasePointerCapture(o.pointerId),e.domElement.removeEventListener("pointermove",ue),e.domElement.removeEventListener("pointerup",Ce)),e.dispatchEvent(Gt),l=r.NONE}function Et(o){let C;switch(o.button){case 0:C=e.mouseButtons.LEFT;break;case 1:C=e.mouseButtons.MIDDLE;break;case 2:C=e.mouseButtons.RIGHT;break;default:C=-1}switch(C){case f.MOUSE.DOLLY:if(e.enableZoom===!1)return;qe(o),l=r.DOLLY;break;case f.MOUSE.ROTATE:if(o.ctrlKey||o.metaKey||o.shiftKey){if(e.enablePan===!1)return;Ve(o),l=r.PAN}else{if(e.enableRotate===!1)return;Be(o),l=r.ROTATE}break;case f.MOUSE.PAN:if(o.ctrlKey||o.metaKey||o.shiftKey){if(e.enableRotate===!1)return;Be(o),l=r.ROTATE}else{if(e.enablePan===!1)return;Ve(o),l=r.PAN}break;default:l=r.NONE}l!==r.NONE&&e.dispatchEvent(mt)}function He(o){switch(l){case r.ROTATE:if(e.enableRotate===!1)return;$e(o);break;case r.DOLLY:if(e.enableZoom===!1)return;vt(o);break;case r.PAN:if(e.enablePan===!1)return;bt(o);break}}function it(o){e.enabled===!1||e.enableZoom===!1||l!==r.NONE||(o.preventDefault(),e.dispatchEvent(mt),Ge(o),e.dispatchEvent(Gt))}function We(o){e.enabled===!1||e.enablePan===!1||Ye(o)}function rt(o){switch(Ke(o),P.length){case 1:switch(e.touches.ONE){case f.TOUCH.ROTATE:if(e.enableRotate===!1)return;ye(),l=r.TOUCH_ROTATE;break;case f.TOUCH.PAN:if(e.enablePan===!1)return;Me(),l=r.TOUCH_PAN;break;default:l=r.NONE}break;case 2:switch(e.touches.TWO){case f.TOUCH.DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;yt(),l=r.TOUCH_DOLLY_PAN;break;case f.TOUCH.DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;et(),l=r.TOUCH_DOLLY_ROTATE;break;default:l=r.NONE}break;default:l=r.NONE}l!==r.NONE&&e.dispatchEvent(mt)}function ot(o){switch(Ke(o),l){case r.TOUCH_ROTATE:if(e.enableRotate===!1)return;tt(o),e.update();break;case r.TOUCH_PAN:if(e.enablePan===!1)return;nt(o),e.update();break;case r.TOUCH_DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;ke(o),e.update();break;case r.TOUCH_DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;at(o),e.update();break;default:l=r.NONE}}function de(o){e.enabled!==!1&&o.preventDefault()}function wt(o){P.push(o)}function st(o){delete le[o.pointerId];for(let C=0;C<P.length;C++)if(P[C].pointerId==o.pointerId){P.splice(C,1);return}}function Ke(o){let C=le[o.pointerId];C===void 0&&(C=new f.Vector2,le[o.pointerId]=C),C.set(o.pageX,o.pageY)}function Se(o){const C=o.pointerId===P[0].pointerId?P[1]:P[0];return le[C.pointerId]}e.domElement.addEventListener("contextmenu",de),e.domElement.addEventListener("pointerdown",ze),e.domElement.addEventListener("pointercancel",Ce),e.domElement.addEventListener("wheel",it,{passive:!1}),this.update()}}const pt=t=>{const[n,i]=A.useState(!1),[e,r]=A.useState(t.options[t.index]),l=()=>{i(!n)},c=s=>{s!==e&&(t.onSelect(s),r(s)),i(!1)};return d.jsxs("div",{className:`dropdown ${t.up===!0?"up":""}`,children:[d.jsx("div",{className:"dropdown-toggle",onClick:l,children:e}),n&&d.jsx("ul",{className:"dropdown-menu",children:t.options.map(s=>d.jsx("li",{onClick:()=>c(s),children:s},s))})]})},ve=A.forwardRef(function(n,i){const e=n.options.indexOf(n.camera.name);return d.jsxs("div",{className:"CameraWindow",children:[d.jsx("div",{ref:i,className:"clickable"}),d.jsx(pt,{index:e,options:n.options,onSelect:n.onSelect,up:!0})]})}),Mn=`out vec3 worldPosition;
|
29
|
+
C11,8.22,10.74,8,10.43,8z`})});function Dt(t){return u.jsx(Ct.Reorder.Item,{value:t.title,children:u.jsxs("div",{children:[mn,u.jsx("span",{children:t.title}),u.jsx("button",{className:"closeIcon",onClick:()=>{t.onDelete(t.index)},children:pn})]})},t.title)}function _t(t){const[n,i]=I.useState(!1),[e,r]=I.useState(t.options),d=p=>{t.onDragComplete(p),r(p)},c=p=>{const m=[...e];m.splice(p,1),d(m)},s=[];e.forEach((p,m)=>{s.push(u.jsx(Dt,{index:m,title:p,onDelete:c},p))});let l="dropdown draggable";return t.subdropdown&&(l+=" subdropdown"),u.jsxs("div",{className:l,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[u.jsx(ft,{title:t.title}),u.jsx(Ct.Reorder.Group,{axis:"y",values:e,onReorder:d,style:{visibility:n?"visible":"hidden"},children:s})]})}function It(t){const[n,i]=I.useState(!1),e=[];t.options.map((d,c)=>{t.onSelect!==void 0&&(d.onSelect=t.onSelect),e.push(u.jsx(At,{option:d},c))});let r="dropdown";return t.subdropdown&&(r+=" subdropdown"),u.jsxs("div",{className:r,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[u.jsx(ft,{title:t.title}),u.jsx("ul",{style:{visibility:n?"visible":"hidden"},children:e})]})}function At(t){const{option:n}=t,[i,e]=I.useState("");let r;switch(n.type){case"draggable":r=u.jsx(_t,{title:n.title,options:n.value,onDragComplete:d=>{n.onDragComplete!==void 0&&n.onDragComplete(d)},subdropdown:!0});break;case"dropdown":r=u.jsx(It,{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&&(i!==n.title?e(n.title):e(""))},children:n.title});break}return u.jsx("li",{className:i===n.title?"selected":"",children:r},St())}function gn(t){let n;function i(c){var l,p,m,v,w,T,j,A,E;let s;switch(c.event){case"custom":L.dispatchEvent({type:U.CUSTOM,value:c.data});break;case"selectComponent":L.dispatchEvent({type:U.SELECT_DROPDOWN,value:c.data});break;case"draggableListUpdate":L.dispatchEvent({type:U.DRAG_UPDATE,value:c.data});break;case"addFolder":(l=t.components.get("debug"))==null||l.addFolder(c.data.name,c.data.params,c.data.parent);break;case"bindObject":(p=t.components.get("debug"))==null||p.bind(c.data.name,c.data.params,c.data.parent);break;case"updateBind":(m=t.components.get("debug"))==null||m.triggerBind(c.data.id,c.data.value);break;case"addButton":(v=t.components.get("debug"))==null||v.button(c.data.name,c.data.callback,c.data.parent);break;case"clickButton":(w=t.components.get("debug"))==null||w.triggerButton(c.data.id);break;case"setSheet":s=(T=t.components.get("theatre"))==null?void 0:T.sheets.get(c.data.sheet),s!==void 0&&(n=s,_e.setSelection([s]));break;case"setSheetObject":s=(j=t.components.get("theatre"))==null?void 0:j.sheetObjects.get(`${c.data.sheet}_${c.data.key}`),s!==void 0&&_e.setSelection([s]);break;case"updateSheetObject":s=(A=t.components.get("theatre"))==null?void 0:A.sheetObjectCBs.get(c.data.sheetObject),s!==void 0&&s(c.data.values);break;case"updateTimeline":n=(E=t.components.get("theatre"))==null?void 0:E.sheets.get(c.data.sheet),n!==void 0&&(n.sequence.position=c.data.position);break;case"getScene":L.dispatchEvent({type:U.GET_SCENE});break;case"getObject":L.dispatchEvent({type:U.GET_OBJECT,value:c.data});break;case"updateObject":L.dispatchEvent({type:U.UPDATE_OBJECT,value:c.data});break;case"createTexture":L.dispatchEvent({type:U.CREATE_TEXTURE,value:c.data});break;case"requestMethod":L.dispatchEvent({type:U.REQUEST_METHOD,value:c.data});break}}function e(c){switch(c.event){case"custom":L.dispatchEvent({type:U.CUSTOM,value:c.data});break;case"setObject":L.dispatchEvent({type:U.SET_OBJECT,value:c.data});break;case"setScene":L.dispatchEvent({type:U.SET_SCENE,value:c.data});break}}function r(){_e.ui.hide()}function d(){_e.ui.restore(),_e.onSelectionChange(p=>{p.length<1||p.forEach(m=>{var j;let v=m.address.sheetId,w="setSheet",T={};switch(m.type){case"Theatre_Sheet_PublicAPI":w="setSheet",T={sheet:m.address.sheetId},n=(j=t.components.get("theatre"))==null?void 0:j.sheets.get(m.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":w="setSheetObject",v+=`_${m.address.objectKey}`,T={id:v,sheet:m.address.sheetId,key:m.address.objectKey};break}t.send({event:w,target:"app",data:T})})});let c=0;const s=()=>{if(n!==void 0&&c!==n.sequence.position){c=n.sequence.position;const p=n;t.send({event:"updateTimeline",target:"app",data:{position:c,sheet:p.address.sheetId}})}},l=()=>{s(),requestAnimationFrame(l)};s(),l()}t.listen(c=>{t.editor?e(c):i(c)}),t.editor?d():r()}const Kn="";function Ze(t){const[n,i]=I.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),i(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 ht(t){const[n,i]=I.useState(!1),e=t.child.children.length>0,r=[];return t.child.children.length>0&&t.child.children.map(d=>{r.push(u.jsx(ht,{child:d,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:()=>{i(!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 Nt(t){const n=[];return t.child.children.map(i=>{n.push(u.jsx(ht,{child:i,three:t.three},Math.random()))}),u.jsx("div",{className:`scene ${t.class!==void 0?t.class:""}`,children:n})}const Xn="",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 xe(t){function n(e,r){console.log("onChange:",e,r)}const i=[];return t.items.forEach(e=>{bn(e)?i.push(u.jsx(xe,{title:e.title,items:e.items},Math.random())):i.push(u.jsx(Le,{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,d)=>{e.onChange!==void 0?e.onChange(r,d):n(r,d)}},Math.random()))}),u.jsx(Ze,{label:t.title,open:!1,children:i})}function yn(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 ge(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 En(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 wn(){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],r=new FileReader;r.onload=function(d){n(d.target.result)},r.readAsDataURL(e)}}),t.click()})}function Lt(t,n,i){const e=[];for(const r in t){if(!yn(r))continue;const d=typeof t[r],c=t[r];if(d==="boolean"||d==="number"||d==="string"){const s={title:ge(r),prop:r,type:d,value:c,min:void 0,max:void 0,onChange:(l,p)=>{var v;i.updateObject(n.uuid,`material.${l}`,p),d==="boolean"&&i.updateObject(n.uuid,"material.needsUpdate",!0);const m=(v=i.scene)==null?void 0:v.getObjectByProperty("uuid",n.uuid);m!==void 0&&J(m,`material.${l}`,p)}};En(r)&&(s.value=Number(c),s.type="range",s.min=0,s.max=1,s.step=.01),e.push(s)}else if(d==="object")if(c.isColor)e.push({title:ge(r),prop:r,type:"color",value:c,onChange:(s,l)=>{var v;const p=new h.Color(l);i.updateObject(n.uuid,`material.${s}`,p);const m=(v=i.scene)==null?void 0:v.getObjectByProperty("uuid",n.uuid);m!==void 0&&J(m,`material.${s}`,p)}});else if(Array.isArray(c)){const s=[];for(const l in c)s.push({title:`${l}`,type:`${typeof c[l]}`,value:c[l],onChange:(p,m)=>{var w;i.updateObject(n.uuid,`material.${r}`,m);const v=(w=i.scene)==null?void 0:w.getObjectByProperty("uuid",n.uuid);v!==void 0&&J(v,`material.${r}`,m)}});e.push({title:ge(r),items:s})}else{const s=[];for(const l in c){const p=c[l];switch(typeof p){case"boolean":case"number":case"string":l==="src"?e.push({title:ge(r),type:"image",value:p,onChange:(v,w)=>{var j;i.createTexture(n.uuid,`material.${r}`,w);const T=(j=i.scene)==null?void 0:j.getObjectByProperty("uuid",n.uuid);T!==void 0&&ut(w).then(A=>{J(T,`material.${r}`,A),J(T,"material.needsUpdate",!0)})}}):s.push({title:`${ge(l)}`,prop:`material.${r}.${l}`,type:`${typeof t[r][l]}`,value:c[l],onChange:(v,w)=>{var j;i.updateObject(n.uuid,`material.${r}.${l}`,w);const T=(j=i.scene)==null?void 0:j.getObjectByProperty("uuid",n.uuid);T!==void 0&&J(T,`material.${r}.${l}`,w)}});break;case"object":p.value!==void 0&&p.value.src!==void 0?s.push({title:ge(l),type:"image",value:p.value.src,onChange:(v,w)=>{var j;i.createTexture(n.uuid,`material.${r}.${l}.value`,w);const T=(j=i.scene)==null?void 0:j.getObjectByProperty("uuid",n.uuid);T!==void 0&&ut(w).then(A=>{J(T,`material.${r}.${l}.value`,A)})}}):s.push({title:l,type:`${typeof p.value}`,value:p.value,onChange:(v,w)=>{var j;i.updateObject(n.uuid,`material.${r}.${l}.value`,w);const T=(j=i.scene)==null?void 0:j.getObjectByProperty("uuid",n.uuid);T!==void 0&&J(T,`material.${r}.${l}.value`,w)}});break}}s.length>0&&e.push({title:ge(r),items:s})}else c!==void 0&&console.log("other:",r,d,c)}return e.sort((r,d)=>r.title<d.title?-1:r.title>d.title?1:0),e.push({title:"Update Material",type:"button",onChange:()=>{i.updateObject(n.uuid,"material.needsUpdate",!0)}}),e}function Cn(t,n){const i=t.material;if(Array.isArray(i)){const e=[],r=i.length;for(let d=0;d<r;d++)e.push(u.jsx(xe,{title:`Material ${d}`,items:Lt(i[d],t,n)}));return u.jsx(u.Fragment,{children:e})}else return u.jsx(xe,{title:"Material",items:Lt(i,t,n)})}function Le(t){let n=t.value;n!==void 0&&n.isColor!==void 0&&(n=Tt(t.value));const[i,e]=I.useState(n),r=I.useRef(null),d=I.useRef(null),c=I.useRef(null);I.useEffect(()=>{var R;let m=!1,v=-1,w=0,T=Number(i);const j=k=>{m=!0,w=T,v=k.clientX},A=k=>{if(!m)return;const K=t.step!==void 0?t.step:1,ne=(k.clientX-v)*K;T=Number((w+ne).toFixed(4)),d.current!==null&&(d.current.value=T.toString()),t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,T)},E=()=>{m=!1},y=()=>{m=!1},b=t.type==="number";return b&&((R=r.current)==null||R.addEventListener("mousedown",j,!1),document.addEventListener("mouseup",E,!1),document.addEventListener("mousemove",A,!1),document.addEventListener("contextmenu",y,!1)),()=>{var k;b&&((k=r.current)==null||k.removeEventListener("mousedown",j),document.removeEventListener("mouseup",E),document.removeEventListener("mousemove",A),document.removeEventListener("contextmenu",y))}},[i]);const s=t.type==="string"&&(i.length>100||i.search(`
|
30
|
+
`)>-1),l=s||t.type==="image",p=m=>{let v=m.target.value;t.type==="boolean"&&(v=m.target.checked),e(v),t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,v)};return u.jsxs("div",{className:`field ${l?"block":""}`,children:[t.type!=="button"&&u.jsx("label",{ref:r,children:t.title},"fieldLabel"),t.type==="string"&&!s&&u.jsx("input",{type:"text",disabled:t.disabled,onChange:p,value:i}),t.type==="string"&&s&&u.jsx("textarea",{cols:50,rows:10,disabled:!0,onChange:p,value:i}),t.type==="boolean"&&u.jsx("input",{type:"checkbox",disabled:t.disabled,onChange:p,checked:i}),t.type==="number"&&u.jsx("input",{ref:d,type:"number",value:i,min:t.min,max:t.max,step:t.step,onChange:p}),t.type==="range"&&u.jsxs(u.Fragment,{children:[u.jsx("input",{type:"text",value:i.toString(),onChange:p,className:"min"}),u.jsx("input",{disabled:t.disabled,type:"range",value:i,min:t.min,max:t.max,step:t.step,onChange:p})]}),t.type==="color"&&u.jsxs(u.Fragment,{children:[u.jsx("input",{type:"text",value:i.toString(),onChange:p,className:"color"}),u.jsx("input",{type:"color",value:i,onChange:p})]}),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:()=>{wn().then(m=>{c.current.src=m,t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,m)})},src:i.length>0?i:vn})]})}function Ut(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 Sn(t,n){const i=[];if(t.perspectiveCameraInfo!==void 0)for(const e in t.perspectiveCameraInfo)i.push({title:Ut(e),prop:e,type:"number",step:.01,value:t.perspectiveCameraInfo[e],onChange:(r,d)=>{var s;n.updateObject(t.uuid,r,d),n.requestMethod(t.uuid,"updateProjectionMatrix");const c=(s=n.scene)==null?void 0:s.getObjectByProperty("uuid",t.uuid);c!==void 0&&(J(c,r,d),c.updateProjectionMatrix())}});else if(t.orthographicCameraInfo!==void 0)for(const e in t.orthographicCameraInfo)i.push({title:Ut(e),prop:e,type:"number",step:.01,value:t.perspectiveCameraInfo[e],onChange:(r,d)=>{var s;n.updateObject(t.uuid,r,d),n.requestMethod(t.uuid,"updateProjectionMatrix");const c=(s=n.scene)==null?void 0:s.getObjectByProperty("uuid",t.uuid);c!==void 0&&(J(c,r,d),c.updateProjectionMatrix())}});return u.jsx(xe,{title:"Camera",items:i})}function On(t,n){const i=new h.Matrix4;i.elements=t.matrix;const e=new h.Vector3,r=new h.Euler,d=new h.Vector3;t.uuid.length>0&&(e.setFromMatrixPosition(i),r.setFromRotationMatrix(i),d.setFromMatrixScale(i));const c=(l,p)=>{var v;n.updateObject(t.uuid,l,p);const m=(v=n.scene)==null?void 0:v.getObjectByProperty("uuid",t.uuid);m!==void 0&&J(m,l,p)},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:r.x,min:-Math.PI,max:Math.PI,step:.01,onChange:c},{title:"Y",prop:"rotation.y",type:"number",value:r.y,min:-Math.PI,max:Math.PI,step:.01,onChange:c},{title:"Z",prop:"rotation.z",type:"number",value:r.z,min:-Math.PI,max:Math.PI,step:.01,onChange:c}]},{title:"Scale",items:[{title:"X",prop:"scale.x",type:"number",value:d.x,step:.01,onChange:c},{title:"Y",prop:"scale.y",type:"number",value:d.y,step:.01,onChange:c},{title:"Z",prop:"scale.z",type:"number",value:d.z,step:.01,onChange:c}]}];return u.jsx(xe,{title:"Transform",items:s})}function Ft(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 Tn(t,n){const i=[];if(t.lightInfo!==void 0)for(const e in t.lightInfo){const r=t.lightInfo[e];r!==void 0&&(r.isColor!==void 0?i.push({title:Ft(e),prop:e,type:"color",value:r,onChange:(d,c)=>{var p;const s=new h.Color(c);n.updateObject(t.uuid,d,s);const l=(p=n.scene)==null?void 0:p.getObjectByProperty("uuid",t.uuid);l!==void 0&&J(l,d,s)}}):i.push({title:Ft(e),prop:e,type:typeof r,value:r,step:typeof r=="number"?.01:void 0,onChange:(d,c)=>{var l;n.updateObject(t.uuid,d,c);const s=(l=n.scene)==null?void 0:l.getObjectByProperty("uuid",t.uuid);s!==void 0&&J(s,d,c)}}))}return u.jsx(xe,{title:"Light",items:i})}function Bt(t){const[n,i]=I.useState(-1),[e,r]=I.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});I.useEffect(()=>{function c(s){const l=s.value;r(l),i(Date.now())}return L.addEventListener(U.SET_OBJECT,c),()=>{L.removeEventListener(U.SET_OBJECT,c)}},[]);const d=e.type.toLowerCase();return 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(Le,{type:"string",title:"Name",prop:"name",value:e.name,disabled:!0}),u.jsx(Le,{type:"string",title:"Type",prop:"type",value:e.type,disabled:!0}),u.jsx(Le,{type:"string",title:"UUID",prop:"uuid",value:e.uuid,disabled:!0}),u.jsx(Le,{type:"boolean",title:"Visible",prop:"visible",value:e.visible,onChange:(c,s)=>{var p;t.three.updateObject(e.uuid,c,s);const l=(p=t.three.scene)==null?void 0:p.getObjectByProperty("uuid",e.uuid);l!==void 0&&J(l,c,s)}})]}),u.jsxs(u.Fragment,{children:[On(e,t.three),d.search("camera")>-1?Sn(e,t.three):null,d.search("light")>-1?Tn(e,t.three):null,d.search("mesh")>-1?Cn(e,t.three):null]})]})},n)}class xn extends I.Component{constructor(i){super(i);z(this,"three");z(this,"onRefresh",()=>{this.three.getScene()});z(this,"setScene",i=>{this.setState(()=>({scene:i.value}))});this.state={scene:i.scene!==void 0?i.scene:null},this.three=i.three,L.addEventListener(U.SET_SCENE,this.setScene)}componentDidMount(){this.onRefresh()}componentWillUnmount(){L.removeEventListener(U.SET_SCENE,this.setScene)}render(){var r;const i=this.componentState.scene!==null,e="Hierarchy"+(i?`: ${(r=this.componentState.scene)==null?void 0:r.name}`:"");return u.jsx("div",{id:"SceneHierarchy",children:u.jsxs(u.Fragment,{children:[i&&u.jsx(Ze,{label:e,button:u.jsx("button",{className:"icon refresh hideText",onClick:this.onRefresh,children:"Refresh"}),open:!0,children:u.jsx(Nt,{child:this.componentState.scene,three:this.three})}),u.jsx(Ze,{label:"Inspector",children:u.jsx(Bt,{three:this.three},"Inspector")})]})},"SceneHierarchy")}get componentState(){return this.state}}function Rn(t){const n=s=>{const l=t.scene.getObjectByProperty("uuid",s.value);l!==void 0&&t.three.setObject(l)},i=(s,l,p)=>{const m=t.scene.getObjectByProperty("uuid",s);m!==void 0&&J(m,l,p)},e=s=>{const l=s.value,{key:p,value:m,uuid:v}=l;i(v,p,m)},r=s=>{const l=s.value;ut(l.value).then(p=>{i(l.uuid,l.key,p),i(l.uuid,"material.needsUpdate",!0)})},d=()=>{t.three.setScene(t.scene)},c=s=>{const{key:l,uuid:p,value:m}=s.value,v=t.scene.getObjectByProperty("uuid",p);if(v!==void 0)try{v[l](m)}catch(w){console.log("Error requesting method:"),console.log(w),console.log(l),console.log(m)}};return I.useEffect(()=>(L.addEventListener(U.GET_OBJECT,n),L.addEventListener(U.GET_SCENE,d),L.addEventListener(U.UPDATE_OBJECT,e),L.addEventListener(U.CREATE_TEXTURE,r),L.addEventListener(U.REQUEST_METHOD,c),()=>{L.removeEventListener(U.GET_OBJECT,n),L.removeEventListener(U.GET_SCENE,d),L.removeEventListener(U.UPDATE_OBJECT,e),L.removeEventListener(U.CREATE_TEXTURE,r),L.removeEventListener(U.REQUEST_METHOD,c)}),[]),null}const Vt={type:"change"},pt={type:"start"},Gt={type:"end"},Je=new h.Ray,Yt=new h.Plane,Mn=Math.cos(70*h.MathUtils.DEG2RAD);class Pn extends h.EventDispatcher{constructor(n,i){super(),this.object=n,this.domElement=i,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new h.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=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:h.MOUSE.ROTATE,MIDDLE:h.MOUSE.DOLLY,RIGHT:h.MOUSE.PAN},this.touches={ONE:h.TOUCH.ROTATE,TWO:h.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(o){o.addEventListener("keydown",We),this._domElementKeyEvents=o},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",We),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(Vt),e.update(),d=r.NONE},this.update=function(){const o=new h.Vector3,C=new h.Quaternion().setFromUnitVectors(n.up,new h.Vector3(0,1,0)),V=C.clone().invert(),G=new h.Vector3,q=new h.Quaternion,fe=new h.Vector3,re=2*Math.PI;return function(){const Xe=e.object.position;o.copy(Xe).sub(e.target),o.applyQuaternion(C),s.setFromVector3(o),e.autoRotate&&d===r.NONE&&D(Re()),e.enableDamping?(s.theta+=l.theta*e.dampingFactor,s.phi+=l.phi*e.dampingFactor):(s.theta+=l.theta,s.phi+=l.phi);let Z=e.minAzimuthAngle,te=e.maxAzimuthAngle;isFinite(Z)&&isFinite(te)&&(Z<-Math.PI?Z+=re:Z>Math.PI&&(Z-=re),te<-Math.PI?te+=re:te>Math.PI&&(te-=re),Z<=te?s.theta=Math.max(Z,Math.min(te,s.theta)):s.theta=s.theta>(Z+te)/2?Math.max(Z,s.theta):Math.min(te,s.theta)),s.phi=Math.max(e.minPolarAngle,Math.min(e.maxPolarAngle,s.phi)),s.makeSafe(),e.enableDamping===!0?e.target.addScaledVector(m,e.dampingFactor):e.target.add(m),e.zoomToCursor&&ne||e.object.isOrthographicCamera?s.radius=Pe(s.radius):s.radius=Pe(s.radius*p),o.setFromSpherical(s),o.applyQuaternion(V),Xe.copy(e.target).add(o),e.object.lookAt(e.target),e.enableDamping===!0?(l.theta*=1-e.dampingFactor,l.phi*=1-e.dampingFactor,m.multiplyScalar(1-e.dampingFactor)):(l.set(0,0,0),m.set(0,0,0));let he=!1;if(e.zoomToCursor&&ne){let pe=null;if(e.object.isPerspectiveCamera){const Oe=o.length();pe=Pe(Oe*p);const Te=Oe-pe;e.object.position.addScaledVector(k,Te),e.object.updateMatrixWorld()}else if(e.object.isOrthographicCamera){const Oe=new h.Vector3(K.x,K.y,0);Oe.unproject(e.object),e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/p)),e.object.updateProjectionMatrix(),he=!0;const Te=new h.Vector3(K.x,K.y,0);Te.unproject(e.object),e.object.position.sub(Te).add(Oe),e.object.updateMatrixWorld(),pe=o.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),e.zoomToCursor=!1;pe!==null&&(this.screenSpacePanning?e.target.set(0,0,-1).transformDirection(e.object.matrix).multiplyScalar(pe).add(e.object.position):(Je.origin.copy(e.object.position),Je.direction.set(0,0,-1).transformDirection(e.object.matrix),Math.abs(e.object.up.dot(Je.direction))<Mn?n.lookAt(e.target):(Yt.setFromNormalAndCoplanarPoint(e.object.up,e.target),Je.intersectPlane(Yt,e.target))))}else e.object.isOrthographicCamera&&(e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/p)),e.object.updateProjectionMatrix(),he=!0);return p=1,ne=!1,he||G.distanceToSquared(e.object.position)>c||8*(1-q.dot(e.object.quaternion))>c||fe.distanceToSquared(e.target)>0?(e.dispatchEvent(Vt),G.copy(e.object.position),q.copy(e.object.quaternion),fe.copy(e.target),he=!1,!0):!1}}(),this.dispose=function(){e.domElement.removeEventListener("contextmenu",de),e.domElement.removeEventListener("pointerdown",ze),e.domElement.removeEventListener("pointercancel",Ce),e.domElement.removeEventListener("wheel",it),e.domElement.removeEventListener("pointermove",ue),e.domElement.removeEventListener("pointerup",Ce),e._domElementKeyEvents!==null&&(e._domElementKeyEvents.removeEventListener("keydown",We),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 d=r.NONE;const c=1e-6,s=new h.Spherical,l=new h.Spherical;let p=1;const m=new h.Vector3,v=new h.Vector2,w=new h.Vector2,T=new h.Vector2,j=new h.Vector2,A=new h.Vector2,E=new h.Vector2,y=new h.Vector2,b=new h.Vector2,R=new h.Vector2,k=new h.Vector3,K=new h.Vector2;let ne=!1;const M=[],le={};function Re(){return 2*Math.PI/60/60*e.autoRotateSpeed}function se(){return Math.pow(.95,e.zoomSpeed)}function D(o){l.theta-=o}function F(o){l.phi-=o}const B=function(){const o=new h.Vector3;return function(V,G){o.setFromMatrixColumn(G,0),o.multiplyScalar(-V),m.add(o)}}(),ee=function(){const o=new h.Vector3;return function(V,G){e.screenSpacePanning===!0?o.setFromMatrixColumn(G,1):(o.setFromMatrixColumn(G,0),o.crossVectors(e.object.up,o)),o.multiplyScalar(V),m.add(o)}}(),ae=function(){const o=new h.Vector3;return function(V,G){const q=e.domElement;if(e.object.isPerspectiveCamera){const fe=e.object.position;o.copy(fe).sub(e.target);let re=o.length();re*=Math.tan(e.object.fov/2*Math.PI/180),B(2*V*re/q.clientHeight,e.object.matrix),ee(2*G*re/q.clientHeight,e.object.matrix)}else e.object.isOrthographicCamera?(B(V*(e.object.right-e.object.left)/e.object.zoom/q.clientWidth,e.object.matrix),ee(G*(e.object.top-e.object.bottom)/e.object.zoom/q.clientHeight,e.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),e.enablePan=!1)}}();function Me(o){e.object.isPerspectiveCamera||e.object.isOrthographicCamera?p/=o:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function Ue(o){e.object.isPerspectiveCamera||e.object.isOrthographicCamera?p*=o:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function Fe(o){if(!e.zoomToCursor)return;ne=!0;const C=e.domElement.getBoundingClientRect(),V=o.clientX-C.left,G=o.clientY-C.top,q=C.width,fe=C.height;K.x=V/q*2-1,K.y=-(G/fe)*2+1,k.set(K.x,K.y,1).unproject(n).sub(n.position).normalize()}function Pe(o){return Math.max(e.minDistance,Math.min(e.maxDistance,o))}function Be(o){v.set(o.clientX,o.clientY)}function qe(o){Fe(o),y.set(o.clientX,o.clientY)}function Ve(o){j.set(o.clientX,o.clientY)}function $e(o){w.set(o.clientX,o.clientY),T.subVectors(w,v).multiplyScalar(e.rotateSpeed);const C=e.domElement;D(2*Math.PI*T.x/C.clientHeight),F(2*Math.PI*T.y/C.clientHeight),v.copy(w),e.update()}function vt(o){b.set(o.clientX,o.clientY),R.subVectors(b,y),R.y>0?Me(se()):R.y<0&&Ue(se()),y.copy(b),e.update()}function bt(o){A.set(o.clientX,o.clientY),E.subVectors(A,j).multiplyScalar(e.panSpeed),ae(E.x,E.y),j.copy(A),e.update()}function Ge(o){Fe(o),o.deltaY<0?Ue(se()):o.deltaY>0&&Me(se()),e.update()}function Ye(o){let C=!1;switch(o.code){case e.keys.UP:o.ctrlKey||o.metaKey||o.shiftKey?F(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):ae(0,e.keyPanSpeed),C=!0;break;case e.keys.BOTTOM:o.ctrlKey||o.metaKey||o.shiftKey?F(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):ae(0,-e.keyPanSpeed),C=!0;break;case e.keys.LEFT:o.ctrlKey||o.metaKey||o.shiftKey?D(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):ae(e.keyPanSpeed,0),C=!0;break;case e.keys.RIGHT:o.ctrlKey||o.metaKey||o.shiftKey?D(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):ae(-e.keyPanSpeed,0),C=!0;break}C&&(o.preventDefault(),e.update())}function ye(){if(M.length===1)v.set(M[0].pageX,M[0].pageY);else{const o=.5*(M[0].pageX+M[1].pageX),C=.5*(M[0].pageY+M[1].pageY);v.set(o,C)}}function je(){if(M.length===1)j.set(M[0].pageX,M[0].pageY);else{const o=.5*(M[0].pageX+M[1].pageX),C=.5*(M[0].pageY+M[1].pageY);j.set(o,C)}}function Ee(){const o=M[0].pageX-M[1].pageX,C=M[0].pageY-M[1].pageY,V=Math.sqrt(o*o+C*C);y.set(0,V)}function yt(){e.enableZoom&&Ee(),e.enablePan&&je()}function et(){e.enableZoom&&Ee(),e.enableRotate&&ye()}function tt(o){if(M.length==1)w.set(o.pageX,o.pageY);else{const V=Se(o),G=.5*(o.pageX+V.x),q=.5*(o.pageY+V.y);w.set(G,q)}T.subVectors(w,v).multiplyScalar(e.rotateSpeed);const C=e.domElement;D(2*Math.PI*T.x/C.clientHeight),F(2*Math.PI*T.y/C.clientHeight),v.copy(w)}function nt(o){if(M.length===1)A.set(o.pageX,o.pageY);else{const C=Se(o),V=.5*(o.pageX+C.x),G=.5*(o.pageY+C.y);A.set(V,G)}E.subVectors(A,j).multiplyScalar(e.panSpeed),ae(E.x,E.y),j.copy(A)}function we(o){const C=Se(o),V=o.pageX-C.x,G=o.pageY-C.y,q=Math.sqrt(V*V+G*G);b.set(0,q),R.set(0,Math.pow(b.y/y.y,e.zoomSpeed)),Me(R.y),y.copy(b)}function ke(o){e.enableZoom&&we(o),e.enablePan&&nt(o)}function at(o){e.enableZoom&&we(o),e.enableRotate&&tt(o)}function ze(o){e.enabled!==!1&&(M.length===0&&(e.domElement.setPointerCapture(o.pointerId),e.domElement.addEventListener("pointermove",ue),e.domElement.addEventListener("pointerup",Ce)),wt(o),o.pointerType==="touch"?rt(o):Et(o))}function ue(o){e.enabled!==!1&&(o.pointerType==="touch"?ot(o):He(o))}function Ce(o){st(o),M.length===0&&(e.domElement.releasePointerCapture(o.pointerId),e.domElement.removeEventListener("pointermove",ue),e.domElement.removeEventListener("pointerup",Ce)),e.dispatchEvent(Gt),d=r.NONE}function Et(o){let C;switch(o.button){case 0:C=e.mouseButtons.LEFT;break;case 1:C=e.mouseButtons.MIDDLE;break;case 2:C=e.mouseButtons.RIGHT;break;default:C=-1}switch(C){case h.MOUSE.DOLLY:if(e.enableZoom===!1)return;qe(o),d=r.DOLLY;break;case h.MOUSE.ROTATE:if(o.ctrlKey||o.metaKey||o.shiftKey){if(e.enablePan===!1)return;Ve(o),d=r.PAN}else{if(e.enableRotate===!1)return;Be(o),d=r.ROTATE}break;case h.MOUSE.PAN:if(o.ctrlKey||o.metaKey||o.shiftKey){if(e.enableRotate===!1)return;Be(o),d=r.ROTATE}else{if(e.enablePan===!1)return;Ve(o),d=r.PAN}break;default:d=r.NONE}d!==r.NONE&&e.dispatchEvent(pt)}function He(o){switch(d){case r.ROTATE:if(e.enableRotate===!1)return;$e(o);break;case r.DOLLY:if(e.enableZoom===!1)return;vt(o);break;case r.PAN:if(e.enablePan===!1)return;bt(o);break}}function it(o){e.enabled===!1||e.enableZoom===!1||d!==r.NONE||(o.preventDefault(),e.dispatchEvent(pt),Ge(o),e.dispatchEvent(Gt))}function We(o){e.enabled===!1||e.enablePan===!1||Ye(o)}function rt(o){switch(Ke(o),M.length){case 1:switch(e.touches.ONE){case h.TOUCH.ROTATE:if(e.enableRotate===!1)return;ye(),d=r.TOUCH_ROTATE;break;case h.TOUCH.PAN:if(e.enablePan===!1)return;je(),d=r.TOUCH_PAN;break;default:d=r.NONE}break;case 2:switch(e.touches.TWO){case h.TOUCH.DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;yt(),d=r.TOUCH_DOLLY_PAN;break;case h.TOUCH.DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;et(),d=r.TOUCH_DOLLY_ROTATE;break;default:d=r.NONE}break;default:d=r.NONE}d!==r.NONE&&e.dispatchEvent(pt)}function ot(o){switch(Ke(o),d){case r.TOUCH_ROTATE:if(e.enableRotate===!1)return;tt(o),e.update();break;case r.TOUCH_PAN:if(e.enablePan===!1)return;nt(o),e.update();break;case r.TOUCH_DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;ke(o),e.update();break;case r.TOUCH_DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;at(o),e.update();break;default:d=r.NONE}}function de(o){e.enabled!==!1&&o.preventDefault()}function wt(o){M.push(o)}function st(o){delete le[o.pointerId];for(let C=0;C<M.length;C++)if(M[C].pointerId==o.pointerId){M.splice(C,1);return}}function Ke(o){let C=le[o.pointerId];C===void 0&&(C=new h.Vector2,le[o.pointerId]=C),C.set(o.pageX,o.pageY)}function Se(o){const C=o.pointerId===M[0].pointerId?M[1]:M[0];return le[C.pointerId]}e.domElement.addEventListener("contextmenu",de),e.domElement.addEventListener("pointerdown",ze),e.domElement.addEventListener("pointercancel",Ce),e.domElement.addEventListener("wheel",it,{passive:!1}),this.update()}}const mt=t=>{const[n,i]=I.useState(!1),[e,r]=I.useState(t.options[t.index]),d=()=>{i(!n)},c=s=>{s!==e&&(t.onSelect(s),r(s)),i(!1)};return u.jsxs("div",{className:`dropdown ${t.up===!0?"up":""}`,children:[u.jsx("div",{className:"dropdown-toggle",onClick:d,children:e}),n&&u.jsx("ul",{className:"dropdown-menu",children:t.options.map(s=>u.jsx("li",{onClick:()=>c(s),children:s},s))})]})},ve=I.forwardRef(function(n,i){const e=n.options.indexOf(n.camera.name);return u.jsxs("div",{className:"CameraWindow",children:[u.jsx("div",{ref:i,className:"clickable"}),u.jsx(mt,{index:e,options:n.options,onSelect:n.onSelect,up:!0})]})}),jn=`out vec3 worldPosition;
|
31
31
|
uniform float uDistance;
|
32
32
|
|
33
33
|
void main() {
|
@@ -103,4 +103,4 @@ void main() {
|
|
103
103
|
fragColor.a = mix(fragColor.a, baseOpacity * uGridOpacity, nextGrid);
|
104
104
|
|
105
105
|
if (fragColor.a <= 0.0) discard;
|
106
|
-
}`;class Dn extends
|
106
|
+
}`;class Dn extends h.ShaderMaterial{constructor(n){super({extensions:{derivatives:!0},glslVersion:h.GLSL3,side:h.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 h.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:jn,fragmentShader:kn,name:"InfiniteGrid",depthWrite:!1})}}class zt extends h.Mesh{constructor(){const i=new Dn;super(new h.PlaneGeometry(2,2),i);z(this,"gridMaterial");this.gridMaterial=i,this.frustumCulled=!1,this.name="InfiniteGridHelper",this.position.y=.1}update(){this.gridMaterial.needsUpdate=!0}}const Zn="",Ht=["Single","Side by Side","Stacked","Quad"],Q=new Map,X=new Map,oe=new Map;function be(t,n){const i=new h.OrthographicCamera(-100,100,100,-100,50,3e3);return i.name=t,i.position.copy(n),i.lookAt(0,0,0),Q.set(t,i),i}be("Top",new h.Vector3(0,1e3,0)),be("Bottom",new h.Vector3(0,-1e3,0)),be("Left",new h.Vector3(-1e3,0,0)),be("Right",new h.Vector3(1e3,0,0)),be("Front",new h.Vector3(0,0,1e3)),be("Back",new h.Vector3(0,0,-1e3)),be("Orthographic",new h.Vector3(1e3,1e3,1e3));const Qe=new h.PerspectiveCamera(60,1,50,3e3);Qe.name="Debug",Qe.position.set(500,500,500),Qe.lookAt(0,0,0),Q.set("Debug",Qe);let gt="Default";const _n=["Default","Normals","Wireframe"],In=new h.MeshNormalMaterial,An=new h.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0}),H=new h.Scene;function Nn(t){const[n,i]=I.useState(t.mode!==void 0?t.mode:"Quad"),e=I.useRef(null),r=I.useRef(null),d=I.useRef(null),c=I.useRef(null);let s=Q.get("Debug"),l=Q.get("Orthographic"),p=Q.get("Front"),m=Q.get("Top");const v=(E,y)=>{const b=X.get(E.name);b!==void 0&&b.dispose(),X.delete(E.name);const R=oe.get(E.name);R!==void 0&&(H.remove(R),R.dispose()),oe.delete(E.name);const k=new Pn(E,y);switch(E.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":k.enableRotate=!1;break}if(X.set(E.name,k),E instanceof h.PerspectiveCamera){const K=new h.CameraHelper(E);oe.set(E.name,K),H.add(K)}},w=E=>{const y=oe.get(E.name);y!==void 0&&(H.remove(y),y.dispose(),oe.delete(E.name));const b=X.get(E.name);b!==void 0&&(b.dispose(),X.delete(E.name))},T=()=>{X.forEach((E,y)=>{E.dispose();const b=oe.get(y);b!==void 0&&(H.remove(b),b.dispose()),oe.delete(y),X.delete(y)}),X.clear(),oe.clear()},j=()=>{switch(n){case"Single":v(s,e.current);break;case"Side by Side":case"Stacked":v(s,e.current),v(l,r.current);break;case"Quad":v(s,e.current),v(l,r.current),v(p,d.current),v(m,c.current);break}};I.useEffect(()=>{H.name="Debug Scene",H.add(t.scene);const E=new zt;H.add(E);const y=new h.AxesHelper(500);y.name="axisHelper",H.add(y)},[]),I.useEffect(()=>{const E=t.renderer.getSize(new h.Vector2);let y=E.x,b=E.y,R=Math.floor(y/2),k=Math.floor(b/2),K=-1;const ne=()=>{y=window.innerWidth-300,b=window.innerHeight,R=Math.floor(y/2),k=Math.floor(b/2);let D=y,F=b;switch(n){case"Side by Side":D=R,F=b;break;case"Stacked":D=y,F=k;break;case"Quad":D=R,F=k;break}Q.forEach(B=>{var ee;B instanceof h.OrthographicCamera?(B.left=D/-2,B.right=D/2,B.top=F/2,B.bottom=F/-2,B.updateProjectionMatrix()):B instanceof h.PerspectiveCamera&&(B.aspect=D/F,B.updateProjectionMatrix(),(ee=oe.get(B.name))==null||ee.update())})},M=()=>{t.renderer.setViewport(0,0,y,b),t.renderer.setScissor(0,0,y,b),t.renderer.render(H,s)},le=()=>{if(n==="Side by Side")t.renderer.setViewport(0,0,R,b),t.renderer.setScissor(0,0,R,b),t.renderer.render(H,s),t.renderer.setViewport(R,0,R,b),t.renderer.setScissor(R,0,R,b),t.renderer.render(H,l);else{const D=b-k;t.renderer.setViewport(0,D,y,k),t.renderer.setScissor(0,D,y,k),t.renderer.render(H,s),t.renderer.setViewport(0,0,y,k),t.renderer.setScissor(0,0,y,k),t.renderer.render(H,l)}},Re=()=>{let D=0,F=0;F=b-k,D=0,t.renderer.setViewport(D,F,R,k),t.renderer.setScissor(D,F,R,k),t.renderer.render(H,s),D=R,t.renderer.setViewport(D,F,R,k),t.renderer.setScissor(D,F,R,k),t.renderer.render(H,l),F=0,D=0,t.renderer.setViewport(D,F,R,k),t.renderer.setScissor(D,F,R,k),t.renderer.render(H,p),D=R,t.renderer.setViewport(D,F,R,k),t.renderer.setScissor(D,F,R,k),t.renderer.render(H,m)},se=()=>{switch(X.forEach(D=>{D.update()}),t.scene.update(),t.renderer.clear(),n){case"Single":M();break;case"Side by Side":case"Stacked":le();break;case"Quad":Re();break}K=requestAnimationFrame(se)};return j(),window.addEventListener("resize",ne),ne(),se(),()=>{window.removeEventListener("resize",ne),cancelAnimationFrame(K),K=-1}},[n]);const A=["Top","Bottom","Left","Right","Front","Back","Orthographic","Debug"];return t.cameras.forEach(E=>{Q.set(E.name,E),A.push(E.name)}),u.jsxs("div",{className:"multiview",children:[u.jsxs("div",{className:`cameras ${n==="Single"||n==="Stacked"?"single":""}`,children:[n==="Single"&&u.jsx(u.Fragment,{children:u.jsx(ve,{camera:s,options:A,ref:e,onSelect:E=>{var b;(b=X.get(s.name))==null||b.dispose();const y=Q.get(E);y!==void 0&&(w(s),s=y,v(y,e.current))}})}),(n==="Side by Side"||n==="Stacked")&&u.jsxs(u.Fragment,{children:[u.jsx(ve,{camera:s,options:A,ref:e,onSelect:E=>{var b;(b=X.get(s.name))==null||b.dispose();const y=Q.get(E);y!==void 0&&(w(s),s=y,v(y,e.current))}}),u.jsx(ve,{camera:l,options:A,ref:r,onSelect:E=>{var b;(b=X.get(l.name))==null||b.dispose();const y=Q.get(E);y!==void 0&&(w(l),l=y,v(y,r.current))}})]}),n==="Quad"&&u.jsxs(u.Fragment,{children:[u.jsx(ve,{camera:s,options:A,ref:e,onSelect:E=>{var b;(b=X.get(s.name))==null||b.dispose();const y=Q.get(E);y!==void 0&&(w(s),s=y,v(y,e.current))}}),u.jsx(ve,{camera:l,options:A,ref:r,onSelect:E=>{var b;(b=X.get(l.name))==null||b.dispose();const y=Q.get(E);y!==void 0&&(w(l),l=y,v(y,r.current))}}),u.jsx(ve,{camera:p,options:A,ref:d,onSelect:E=>{var b;(b=X.get(p.name))==null||b.dispose();const y=Q.get(E);y!==void 0&&(w(p),p=y,v(y,d.current))}}),u.jsx(ve,{camera:m,options:A,ref:c,onSelect:E=>{var b;(b=X.get(m.name))==null||b.dispose();const y=Q.get(E);y!==void 0&&(w(m),m=y,v(y,c.current))}})]})]}),u.jsxs("div",{className:"settings",children:[u.jsx(mt,{index:Ht.indexOf(n),options:Ht,onSelect:E=>{E!==n&&(T(),i(E))}}),u.jsx(mt,{index:0,options:_n,onSelect:E=>{if(E!==gt)switch(gt=E,gt){case"Default":H.overrideMaterial=null;break;case"Normals":H.overrideMaterial=In;break;case"Wireframe":H.overrideMaterial=An;break}}})]})]})}const Jn="";function Ln(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})]})}S.Accordion=Ze,S.Application=nn,S.BaseRemote=Ie,S.ChildObject=ht,S.ContainerObject=Nt,S.Draggable=_t,S.DraggableItem=Dt,S.Dropdown=It,S.DropdownItem=At,S.Editor=Ln,S.InfiniteGridHelper=zt,S.Inspector=Bt,S.MultiView=Nn,S.NavButton=ft,S.RemoteComponents=an,S.RemoteController=gn,S.RemoteTheatre=rn,S.RemoteThree=un,S.RemoteTweakpane=dn,S.SceneHierarchy=xn,S.SceneInspector=Rn,S.ToolEvents=U,S.clamp=en,S.colorToHex=Tt,S.debugDispatcher=L,S.distance=tn,S.hierarchyUUID=lt,S.isColor=Ot,S.randomID=St,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
"module": "./dist/hermes.js",
|
8
8
|
"types": "./types/index.d.ts",
|
9
9
|
"type": "module",
|
10
|
-
"version": "0.0.
|
10
|
+
"version": "0.0.8",
|
11
11
|
"homepage": "https://github.com/tomorrowevening/hermes#readme",
|
12
12
|
"bugs": {
|
13
13
|
"url": "https://github.com/tomorrowevening/hermes/issues"
|
@@ -7,7 +7,7 @@ import { ChildObjectProps } from './types';
|
|
7
7
|
import { determineIcon } from './utils';
|
8
8
|
|
9
9
|
export default function ChildObject(props: ChildObjectProps) {
|
10
|
-
const [open, setOpen] = useState(
|
10
|
+
const [open, setOpen] = useState(false);
|
11
11
|
|
12
12
|
const hasChildren = props.child.children.length > 0;
|
13
13
|
const children: Array<any> = [];
|
@@ -8,6 +8,7 @@ import { InspectCamera } from "./utils/InspectCamera";
|
|
8
8
|
import { InspectMaterial } from "./utils/InspectMaterial";
|
9
9
|
import { InspectTransform } from "./utils/InspectTransform";
|
10
10
|
import { InspectLight } from "./utils/InspectLight";
|
11
|
+
import { setItemProps } from "../utils";
|
11
12
|
|
12
13
|
export default function Inspector(props: CoreComponentProps) {
|
13
14
|
const [lastRefresh, setLastRefresh] = useState(-1);
|
@@ -17,6 +18,10 @@ export default function Inspector(props: CoreComponentProps) {
|
|
17
18
|
type: '',
|
18
19
|
visible: false,
|
19
20
|
matrix: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],
|
21
|
+
material: undefined,
|
22
|
+
perspectiveCameraInfo: undefined,
|
23
|
+
orthographicCameraInfo: undefined,
|
24
|
+
lightInfo: undefined,
|
20
25
|
});
|
21
26
|
|
22
27
|
useEffect(() => {
|
@@ -32,49 +37,59 @@ export default function Inspector(props: CoreComponentProps) {
|
|
32
37
|
};
|
33
38
|
}, []);
|
34
39
|
|
40
|
+
const objType = currentObject.type.toLowerCase();
|
41
|
+
|
35
42
|
return (
|
36
43
|
<div id="Inspector" className={props.class} key={lastRefresh}>
|
37
44
|
{currentObject.uuid.length > 0 && (
|
38
45
|
<>
|
39
46
|
{/* Core */}
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
{
|
76
|
-
|
77
|
-
|
47
|
+
<>
|
48
|
+
<InspectorField
|
49
|
+
type="string"
|
50
|
+
title="Name"
|
51
|
+
prop="name"
|
52
|
+
value={currentObject.name}
|
53
|
+
disabled={true}
|
54
|
+
/>
|
55
|
+
<InspectorField
|
56
|
+
type="string"
|
57
|
+
title="Type"
|
58
|
+
prop="type"
|
59
|
+
value={currentObject.type}
|
60
|
+
disabled={true}
|
61
|
+
/>
|
62
|
+
<InspectorField
|
63
|
+
type="string"
|
64
|
+
title="UUID"
|
65
|
+
prop="uuid"
|
66
|
+
value={currentObject.uuid}
|
67
|
+
disabled={true}
|
68
|
+
/>
|
69
|
+
<InspectorField
|
70
|
+
type="boolean"
|
71
|
+
title="Visible"
|
72
|
+
prop="visible"
|
73
|
+
value={currentObject.visible}
|
74
|
+
onChange={(key: string, value: any) => {
|
75
|
+
props.three.updateObject(currentObject.uuid, key, value);
|
76
|
+
const child = props.three.scene?.getObjectByProperty('uuid', currentObject.uuid);
|
77
|
+
if (child !== undefined) setItemProps(child, key, value);
|
78
|
+
}}
|
79
|
+
/>
|
80
|
+
</>
|
81
|
+
|
82
|
+
{/* Data */}
|
83
|
+
<>
|
84
|
+
{/* Transform */}
|
85
|
+
{InspectTransform(currentObject, props.three)}
|
86
|
+
{/* Cameras */}
|
87
|
+
{objType.search('camera') > -1 ? InspectCamera(currentObject, props.three) : null}
|
88
|
+
{/* Lights */}
|
89
|
+
{objType.search('light') > -1 ? InspectLight(currentObject, props.three) : null}
|
90
|
+
{/* Material */}
|
91
|
+
{objType.search('mesh') > -1 ? InspectMaterial(currentObject, props.three) : null}
|
92
|
+
</>
|
78
93
|
</>
|
79
94
|
)}
|
80
95
|
</div>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import RemoteThree from '@/core/remote/RemoteThree';
|
2
2
|
import InspectorGroup from '../InspectorGroup';
|
3
|
-
import { RemoteObject } from
|
3
|
+
import { RemoteObject } from '../../types';
|
4
4
|
import { setItemProps } from '../../utils';
|
5
5
|
|
6
6
|
function prettyName(name: string): string {
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import
|
2
|
-
import { RemoteObject } from "../../types";
|
1
|
+
import { Color } from 'three';
|
3
2
|
import RemoteThree from '@/core/remote/RemoteThree';
|
3
|
+
import InspectorGroup from '../InspectorGroup';
|
4
|
+
import { RemoteObject } from '../../types';
|
4
5
|
import { setItemProps } from '../../utils';
|
5
|
-
import { Color } from 'three';
|
6
6
|
|
7
7
|
function prettyName(value: string): string {
|
8
8
|
switch (value) {
|