@tomorrowevening/hermes 0.0.86 → 0.0.88
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/hermes.cjs.js +20 -15
- package/dist/hermes.es.js +3951 -2440
- package/dist/style.css +1 -1
- package/package.json +2 -1
- package/types/core/remote/RemoteThree.d.ts +6 -1
- package/types/core/types.d.ts +20 -1
- package/types/editor/global.d.ts +2 -0
- package/types/editor/multiView/CameraWindow.d.ts +1 -0
- package/types/editor/sidePanel/CustomAccordion.d.ts +6 -0
package/dist/hermes.cjs.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("three"),Sn=require("tweakpane"),xn=require("@tweakpane/plugin-essentials"),b=require("react"),sn=require("framer-motion");function Cn(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const t=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(n,a,t.get?t:{enumerable:!0,get:()=>e[a]})}}return n.default=e,Object.freeze(n)}const wn=Cn(xn),Ot=()=>{},Mn=()=>{};function dt(e){return e.substring(0,1).toUpperCase()+e.substring(1)}function Ve(e,n,a){return Math.min(n,Math.max(e,a))}function jt(e,n,a){return(a-e)/(n-e)}function Nt(e,n,a){return e*(1-a)+n*a}function On(e,n){const a=e-n;return Math.sqrt(a*a)}function on(){return Math.round(Math.random()*1e6).toString()}function cn(e){return e.r!==void 0&&e.g!==void 0&&e.b!==void 0}function ln(e){const n=Math.round(e.r*255),a=Math.round(e.g*255),t=Math.round(e.b*255),i=f=>{const d=f.toString(16);return d.length===1?"0"+d:d},o=i(n),l=i(a),s=i(t);return"#"+o+l+s}function Lt(e,n=1){return Number(e.toFixed(n))}exports.totalThreeObjects=0;const Ft=()=>{exports.totalThreeObjects=0},wt=e=>{if(!e)return;let n=e.name.replaceAll(" ","").replaceAll("/",".");if(n.length===0&&(n=`obj_${exports.totalThreeObjects}`,exports.totalThreeObjects++),e.parent!==null&&e.parent.uuid.length>0&&(n=`${e.parent.uuid}.${n}`),e.uuid=n,e.isMesh!==void 0){const a=e;if(Array.isArray(a.material))a.material.forEach((t,i)=>{t.uuid=`${n}.material.${i}`});else{const t=a.material;t.uuid=`${n}.material`}}e.children.forEach(a=>wt(a))},Rn=e=>{e?.dispose()},un=e=>{e&&(Array.isArray(e)?e.forEach(n=>n.dispose()):e.dispose())},ht=e=>{if(e){for(;e.children.length>0;){const n=e.children[0];n.type==="Audio"?(n.pause(),n.parent&&n.parent.remove(n)):ht(n)}if(e.parent&&e.parent.remove(e),e.isMesh){const n=e;n.geometry?.dispose(),un(n.material)}e.dispose!==void 0&&e.dispose()}};class ut{static renderer;static canvas;static context=null;static scene=null;static camera=null;static material=null;static inited=!1;static width=100;static height=100;static init(){this.inited||(this.canvas=document.createElement("canvas"),this.canvas.width=this.width,this.canvas.height=this.height,this.context=this.canvas.getContext("2d"),this.inited=!0)}static renderToBlob(n){this.init();const a=n.repeat.clone(),t=n.offset.clone();if(n.repeat.set(1,1),n.offset.set(0,0),this.context!==null){this.context.clearRect(0,0,this.width,this.height);const i=n.image;if(i!=null&&i.width>0){this.canvas.title=n.sourceFile;const o=this.canvas.width/i.width,l=this.renderToCanvas(n);this.context.drawImage(l,0,0,i.width*o,i.height*o)}}return n.repeat.copy(a),n.offset.copy(t),this.canvas.toDataURL("image/png")}static renderToCanvas(n){if(this.material===null){this.camera=new h.OrthographicCamera(-.5,.5,.5,-.5,0,100),this.scene=new h.Scene,this.material=new h.MeshBasicMaterial;const a=new h.BufferGeometry;a.setAttribute("position",new h.Float32BufferAttribute([-.5,-.5,0,1.5,-.5,0,-.5,1.5,0],3)),a.setAttribute("normal",new h.Float32BufferAttribute([0,0,1,0,0,1],3)),a.setAttribute("uv",new h.Float32BufferAttribute([0,0,2,0,0,2],2));const t=new h.Mesh(a,this.material);this.scene.add(t)}if(n.isRenderTargetTexture)this.material.map=n,this.renderer.render(this.scene,this.camera);else{const a=this.renderer.outputColorSpace,t=n.colorSpace;this.renderer.outputColorSpace=h.LinearSRGBColorSpace,n.colorSpace=h.LinearSRGBColorSpace,this.material.map=n,this.renderer.render(this.scene,this.camera),this.renderer.outputColorSpace=a,n.colorSpace=t}return this.renderer.domElement}}class Tn{components=new Map;listen;_appID="";_debugEnabled;_broadcastChannel=void 0;_webSocket=void 0;_mode="app";_connected=!1;_useBC=!1;constructor(n,a,t=!0){this._appID=n,this._debugEnabled=a,a&&(this._useBC=t,t?(this._broadcastChannel=new BroadcastChannel(n),this._broadcastChannel.addEventListener("message",this.messageHandler)):(this._webSocket=new WebSocket(n),this._webSocket.addEventListener("open",this.openHandler),this._webSocket.addEventListener("close",this.closeHandler),this._webSocket.addEventListener("message",this.messageHandler)))}addComponent(n,a){this.components.set(n,a)}dispose(){this._broadcastChannel!==void 0&&this._broadcastChannel.removeEventListener("message",this.messageHandler),this._webSocket!==void 0&&(this._webSocket.removeEventListener("open",this.openHandler),this._webSocket.removeEventListener("close",this.closeHandler),this._webSocket.removeEventListener("message",this.messageHandler)),this.components.forEach(n=>{n.dispose()}),this.components.clear()}send(n){this._mode!==n.target&&(this._useBC?this._broadcastChannel?.postMessage(n):this._connected&&this._webSocket?.send(JSON.stringify(n)))}messageHandler=n=>{this.listen!==void 0&&(this._useBC?this.listen(n.data):this.listen(JSON.parse(n.data)))};openHandler=()=>{this._connected=!0};closeHandler=()=>{this._connected=!1};get appID(){return this._appID}get connected(){return this._connected}get debugEnabled(){return this._debugEnabled}get mode(){return this._mode}get isApp(){return this._mode==="app"}get editor(){return this._mode==="editor"}set editor(n){n&&(this._mode="editor")}}const D=new h.EventDispatcher,A={CUSTOM:"ToolEvents::custom",SELECT_DROPDOWN:"ToolEvents::selectDropdown",DRAG_UPDATE:"ToolEvents::dragUpdate",ADD_SCENE:"ToolEvents::addScene",REFRESH_SCENE:"ToolEvents::refreshScene",REMOVE_SCENE:"ToolEvents::removeScene",SET_SCENE:"ToolEvents::setScene",GET_OBJECT:"ToolEvents::getObject",SET_OBJECT:"ToolEvents::setObject",UPDATE_OBJECT:"ToolEvents::updateObject",CREATE_TEXTURE:"ToolEvents::createTexture",REQUEST_METHOD:"ToolEvents::requestMethod",ADD_CAMERA:"ToolEvents::addCamera",REMOVE_CAMERA:"ToolEvents::removeCamera"};class mt{app;constructor(n){this.app=n}dispose(){}handleApp(n,a,t){}handleEditor(n,a,t){}}class _n extends mt{selectDropdown(n,a){this.app.send({event:"selectComponent",target:"app",data:{dropdown:n,value:a}})}updateDropdown(n,a){this.app.send({event:"draggableListUpdate",target:"app",data:{dropdown:n,value:a}})}handleApp(n,a,t){switch(t.event){case"selectComponent":D.dispatchEvent({type:A.SELECT_DROPDOWN,value:t.data});break;case"draggableListUpdate":D.dispatchEvent({type:A.DRAG_UPDATE,value:t.data});break}}}class Rt extends mt{project;sheets=new Map;sheetObjects=new Map;sheetObjectCBs=new Map;sheetObjectUnsubscribe=new Map;activeSheet;studio=void 0;static rafDriver=void 0;dispose(){this.project=void 0,this.sheets=new Map,this.sheetObjects=new Map,this.sheetObjectCBs=new Map,this.sheetObjectUnsubscribe=new Map}getSheetInstance(n,a){return a!==void 0?`${n}-${a}`:n}sheet(n,a){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const t=this.getSheetInstance(n,a);let i=this.sheets.get(t);return i!==void 0||(i=this.project?.sheet(n,a),this.sheets.set(t,i)),i}playSheet(n,a,t){this.sheet(n,t)?.sequence.play(a),this.app.send({event:"playSheet",target:"editor",data:{sheet:n,instance:t,value:a}})}pauseSheet(n,a){this.sheet(n)?.sequence.pause(),this.app.send({event:"pauseSheet",target:"editor",data:{sheet:n,instance:a}})}clearSheetObjects(n){this.sheetObjects.forEach((a,t)=>{t.search(`${n}_`)>-1&&this.unsubscribe(a)})}sheetObject(n,a,t,i,o){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const l=this.sheet(n,o);if(l===void 0)return;const f=`${this.getSheetInstance(n,o)}_${a}`;let d=this.sheetObjects.get(f);d!==void 0?d=l.object(a,{...t,...d.value},{reconfigure:!0}):d=l.object(a,t),this.sheetObjects.set(f,d),this.sheetObjectCBs.set(f,i!==void 0?i:Ot);const m=d.onValuesChange(y=>{if(this.app.editor){for(const C in y){const I=y[C];typeof I=="object"&&cn(I)&&(y[C]={r:I.r,g:I.g,b:I.b,a:I.a})}this.app.send({event:"updateSheetObject",target:"app",data:{sheet:n,sheetObject:f,values:y}})}const E=this.sheetObjectCBs.get(f);E!==void 0&&E(y)});return this.sheetObjectUnsubscribe.set(f,m),d}unsubscribe(n){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const a=n.address.sheetId,t=n.address.objectKey;this.sheets.get(a)?.detachObject(t);const o=`${a}_${t}`,l=this.sheetObjectUnsubscribe.get(o);l!==void 0&&(this.sheetObjects.delete(o),this.sheetObjectCBs.delete(o),this.sheetObjectUnsubscribe.delete(o),l())}handleApp(n,a,t){const i=a;let o;switch(t.event){case"setSheet":o=i.sheets.get(t.data.sheet),o!==void 0&&(i.activeSheet=o,this.studio?.setSelection([o]));break;case"setSheetObject":o=i.sheetObjects.get(`${t.data.sheet}_${t.data.key}`),o!==void 0&&this.studio?.setSelection([o]);break;case"updateSheetObject":o=i.sheets.get(t.data.sheet),o!==void 0&&o.sequence.pause(),o=i.sheetObjectCBs.get(t.data.sheetObject),o!==void 0&&o(t.data.values);break;case"updateTimeline":o=i.sheets.get(t.data.sheet),i.activeSheet!==void 0&&(i.activeSheet.sequence.position=t.data.position);break}}handleEditor(n,a,t){if(n.editor){const i=a;switch(t.event){case"playSheet":i.sheet(t.data.sheet,t.data.instance)?.sequence.play(t.data.value);break;case"pauseSheet":i.sheet(t.data.sheet,t.data.instance)?.sequence.pause();break}}}handleEditorApp(n,a){if(n.editor){this.studio?.ui.restore(),this.studio?.onSelectionChange(l=>{l.length<1||l.forEach(s=>{let f=s.address.sheetId,d="setSheet",m={};switch(s.type){case"Theatre_Sheet_PublicAPI":d="setSheet",m={sheet:s.address.sheetId},a.activeSheet=a.sheets.get(s.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":d="setSheetObject",f+=`_${s.address.objectKey}`,m={id:f,sheet:s.address.sheetId,key:s.address.objectKey},a.activeSheet=a.sheets.get(s.address.sheetId);break}n.send({event:d,target:"app",data:m})})});let t=-1;const i=()=>{if(Rt.rafDriver?.tick(performance.now()),a.activeSheet!==void 0&&t!==a.activeSheet.sequence.position){t=a.activeSheet.sequence.position;const l=a.activeSheet;n.send({event:"updateTimeline",target:"app",data:{position:t,sheet:l.address.sheetId}})}},o=()=>{i(),requestAnimationFrame(o)};i(),o()}else this.studio?.ui.hide()}}function kn(e,n,a){if(e.editor){a.ui.restore(),a.onSelectionChange(l=>{l.length<1||l.forEach(s=>{let f=s.address.sheetId,d="setSheet",m={};switch(s.type){case"Theatre_Sheet_PublicAPI":d="setSheet",m={sheet:s.address.sheetId},n.activeSheet=n.sheets.get(s.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":d="setSheetObject",f+=`_${s.address.objectKey}`,m={id:f,sheet:s.address.sheetId,key:s.address.objectKey},n.activeSheet=n.sheets.get(s.address.sheetId);break}e.send({event:d,target:"app",data:m})})});let t=-1;const i=()=>{if(Rt.rafDriver?.tick(performance.now()),n.activeSheet!==void 0&&t!==n.activeSheet.sequence.position){t=n.activeSheet.sequence.position;const l=n.activeSheet;e.send({event:"updateTimeline",target:"app",data:{position:t,sheet:l.address.sheetId}})}},o=()=>{i(),requestAnimationFrame(o)};i(),o()}else a.ui.hide()}function Dn(e){if(e.name==="cameras")return"camera";if(e.name==="interactive")return"interactive";if(e.name==="lights")return"light";if(e.name==="ui")return"ui";if(e.name==="utils")return"utils";const n=e.type;return n.search("Helper")>-1?"icon_utils":n.search("Camera")>-1?"camera":n.search("Light")>-1?"light":"obj3D"}function et(e){const n={name:e.name,type:e.type,uuid:e.uuid,children:[]};return e.children.forEach(a=>{n.children.push(et(a))}),n}function An(e){const n={};for(const a in e){const t=e[a].value;n[a]={value:t},t===null?n[a].value={src:"",offset:[0,0],repeat:[1,1]}:t!==void 0&&t.isTexture&&(n[a].value={src:t.image.src,offset:[t.offset.x,t.offset.y],repeat:[t.repeat.x,t.repeat.y]})}return n}function Pn(e){switch(e){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function Ze(e){const n={};for(const a in e){if(a.substring(0,1)==="_"||a.substring(0,2)==="is"||Pn(a))continue;const t=typeof e[a],i=e[a];switch(t){case"boolean":case"number":case"string":n[a]=i;break;case"object":i!==null?(n[a]=i,i.isTexture?n[a]={src:ut.renderToBlob(i),offset:[i.offset.x,i.offset.y],repeat:[i.repeat.x,i.repeat.y]}:a==="uniforms"&&(n[a]=An(n[a]))):n[a]={src:"",offset:[0,0],repeat:[1,1]};break}}return n}function At(e){e.updateMatrix();const n={name:e.name,type:e.type,uuid:e.uuid,visible:e.visible,matrix:e.matrix.elements,animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};e.animations.forEach(t=>{n.animations.push({name:t.name,duration:t.duration,blendMode:t.blendMode})});const a=e.type.toLowerCase();if(a.search("mesh")>-1){const t=e;if(Array.isArray(t.material)){const i=[];t.material.forEach(o=>{i.push(Ze(o))}),n.material=i}else n.material=Ze(t.material)}else if(a.search("points")>-1){const t=e;if(Array.isArray(t.material)){const i=[];t.material.forEach(o=>{i.push(Ze(o))}),n.material=i}else n.material=Ze(t.material)}else if(a.search("line")>-1){const t=e;if(Array.isArray(t.material)){const i=[];t.material.forEach(o=>{i.push(Ze(o))}),n.material=i}else n.material=Ze(t.material)}else a.search("camera")>-1?e.type==="PerspectiveCamera"?n.perspectiveCameraInfo={fov:e.fov,zoom:e.zoom,near:e.near,far:e.far,focus:e.focus,aspect:e.aspect,filmGauge:e.filmGauge,filmOffset:e.filmOffset}:e.type==="OrthographicCamera"&&(n.orthographicCameraInfo={zoom:e.zoom,near:e.near,far:e.far,left:e.left,right:e.right,top:e.top,bottom:e.bottom}):a.search("light")>-1&&(n.lightInfo={color:e.color,intensity:e.intensity,decay:e.decay,distance:e.distance,angle:e.angle,penumbra:e.penumbra,groundColor:e.groundColor,width:e.width,height:e.height});return n}function In(e,n){const a=n.split(".");switch(a.length){case 1:return e[a[0]];case 2:return e[a[0]][a[1]];case 3:return e[a[0]][a[1]][a[2]];case 4:return e[a[0]][a[1]][a[2]][a[3]];case 5:return e[a[0]][a[1]][a[2]][a[3]][a[4]];case 6:return e[a[0]][a[1]][a[2]][a[3]][a[4]][a[5]]}}function jn(e,n){for(const a in n)e[a]=n[a]}function Q(e,n,a){if(e===void 0)return;const t=n.split("."),i=t.length;if(typeof a!="object")switch(i){case 1:e[t[0]]=a;break;case 2:e[t[0]][t[1]]=a;break;case 3:e[t[0]][t[1]][t[2]]=a;break;case 4:e[t[0]][t[1]][t[2]][t[3]]=a;break;case 5:e[t[0]][t[1]][t[2]][t[3]][t[4]]=a;break}else{let l;switch(i){case 1:l=e[t[0]];break;case 2:l=e[t[0]][t[1]];break;case 3:l=e[t[0]][t[1]][t[2]];break;case 4:l=e[t[0]][t[1]][t[2]][t[3]];break;case 5:l=e[t[0]][t[1]][t[2]][t[3]][t[4]];break}l!=null&&jn(l,a)}}function dn(e){return new Promise((n,a)=>{const t=new Image;t.onload=()=>{const i=new h.Texture(t);i.wrapS=h.RepeatWrapping,i.wrapT=h.RepeatWrapping,i.needsUpdate=!0,n(i)},t.onerror=a,t.src=e})}class Nn extends mt{scene=void 0;scenes=new Map;renderer=void 0;renderTargets=new Map;dispose(){this.scenes.forEach(n=>{ht(n)}),this.scenes.clear(),this.scene&&ht(this.scene),this.renderTargets.forEach(n=>{n.dispose()}),this.renderTargets.clear(),this.renderer?.dispose()}getObject(n){this.app.debugEnabled&&(this.renderer!==void 0&&(ut.renderer=this.renderer),this.app.send({event:"getObject",target:"app",data:n}))}setObject(n){this.renderer!==void 0&&(ut.renderer=this.renderer);const a=At(n);this.app.send({event:"setObject",target:"editor",data:a})}requestMethod(n,a,t,i){this.app.send({event:"requestMethod",target:"app",data:{uuid:n,key:a,value:t,subitem:i}})}updateObject(n,a,t){this.app.send({event:"updateObject",target:"app",data:{uuid:n,key:a,value:t}})}createTexture(n,a,t){this.app.send({event:"createTexture",target:"app",data:{uuid:n,key:a,value:t}})}addScene(n){if(n===void 0||(this.scenes.set(n.name,n),!this.app.debugEnabled))return;Ft(),wt(n);const a=et(n);this.app.send({event:"addScene",target:"editor",data:a})}refreshScene(n){if(!this.app.debugEnabled)return;const a=this.scenes.get(n);if(a!==void 0){const t=et(a);this.app.send({event:"refreshScene",target:"app",data:t})}}removeScene(n){if(n===void 0||(this.scenes.delete(n.name),!this.app.debugEnabled))return;const a=et(n);this.app.send({event:"removeScene",target:"editor",data:a})}removeAllScenes(){this.scenes.forEach(n=>this.removeScene(n))}getScene(n){let a=null;return this.scenes.forEach((t,i)=>{n.search(i)>-1&&(a=t)}),a}setScene(n){if(n===void 0||(this.scene=n,!this.app.debugEnabled))return;this.renderer!==void 0&&(ut.renderer=this.renderer),Ft(),wt(n);const a=et(n);this.app.send({event:"setScene",target:"editor",data:a})}addCamera(n){if(!this.app.debugEnabled)return;const a=At(n);this.app.send({event:"addCamera",target:"editor",data:a})}removeCamera(n){if(!this.app.debugEnabled)return;const a=At(n);this.app.send({event:"removeCamera",target:"editor",data:a})}handleApp(n,a,t){switch(t.event){case"getObject":D.dispatchEvent({type:A.GET_OBJECT,value:t.data});break;case"updateObject":D.dispatchEvent({type:A.UPDATE_OBJECT,value:t.data});break;case"createTexture":D.dispatchEvent({type:A.CREATE_TEXTURE,value:t.data});break;case"requestMethod":D.dispatchEvent({type:A.REQUEST_METHOD,value:t.data});break;case"refreshScene":n.send({event:"refreshScene",target:"editor",data:et(a.scenes.get(t.data.name))});break}}handleEditor(n,a,t){switch(t.event){case"setObject":D.dispatchEvent({type:A.SET_OBJECT,value:t.data});break;case"addScene":D.dispatchEvent({type:A.ADD_SCENE,value:t.data});break;case"refreshScene":D.dispatchEvent({type:A.REFRESH_SCENE,value:t.data});break;case"removeScene":D.dispatchEvent({type:A.REMOVE_SCENE,value:t.data});break;case"setScene":D.dispatchEvent({type:A.SET_SCENE,value:t.data});break;case"addCamera":D.dispatchEvent({type:A.ADD_CAMERA,value:t.data});break;case"removeCamera":D.dispatchEvent({type:A.REMOVE_CAMERA,value:t.data});break}}rendererWidth=300;rendererHeight=150;addRT(n,a){const t=new h.WebGLRenderTarget(32,32,a);t.texture.name=n,this.renderTargets.set(n,t)}resize(n,a){const t=this.dpr;this.rendererWidth=n,this.rendererHeight=a,this.renderTargets.forEach(i=>{i.setSize(n*t,a*t)}),this.renderer?.setSize(n,a)}set dpr(n){this.renderer?.setPixelRatio(Ve(1,2,n))}get dpr(){return this.renderer!==void 0?this.renderer?.getPixelRatio():1}get width(){return this.rendererWidth}get height(){return this.rendererHeight}get canvas(){return this.renderer!==void 0?this.renderer?.domElement:null}}class Ln extends mt{bindCBs;buttonCBs;pane=void 0;appCallbacks=0;editorCallbacks=0;inspectorFolder=void 0;constructor(n){super(n),this.bindCBs=new Map,this.buttonCBs=new Map,n.editor&&this.createGUI()}createGUI(){this.pane=new Sn.Pane({title:"GUI"}),this.pane.registerPlugin(wn)}dispose(){this.bindCBs.clear(),this.buttonCBs.clear(),this.appCallbacks=0,this.editorCallbacks=0,this.app.editor&&(this.pane?.dispose(),this.pane=void 0)}addFolder(n,a=void 0,t=void 0){if(this.app.editor)return this.pane===void 0&&this.createGUI(),(t!==void 0?t:this.pane).addFolder({title:n,...a});this.app.send({event:"addFolder",target:"app",data:{name:n,params:a,parent:t}})}get bindID(){return`debug_${Math.max(this.appCallbacks,this.editorCallbacks)}`}bind(n,a,t,i=void 0){const o=this.bindID,l=t.onChange!==void 0?t.onChange:Ot;this.bindCBs.set(o,l),this.app.editor?(this.pane===void 0&&this.createGUI(),(i!==void 0?i:this.pane).addBinding(n,a,t).on("change",f=>{this.app.send({event:"updateBind",target:"app",data:{id:o,value:f.value}})}),this.editorCallbacks++):(this.app.send({event:"bindObject",target:"app",data:{id:o,name:a,params:t,parent:i}}),this.appCallbacks++)}triggerBind(n,a){const t=this.bindCBs.get(n);t!==void 0?t(a):console.warn(`No callback for: ${n}`,a)}button(n,a,t=void 0){const i=this.bindID;this.buttonCBs.set(i,a),this.app.editor?(this.pane===void 0&&this.createGUI(),(t!==void 0?t:this.pane).addButton({title:n}).on("click",()=>{this.app.send({event:"clickButton",target:"app",data:{id:i}})}),this.editorCallbacks++):(this.app.send({event:"addButton",target:"app",data:{id:i,name:n,callback:a,parent:t}}),this.appCallbacks++)}triggerButton(n){const a=this.buttonCBs.get(n);a!==void 0&&a()}createInspector(){this.inspectorFolder=this.addFolder("Inspector",this.pane)}clearInspector(){const n=this.inspectorFolder.children.length-1;for(let a=n;a>-1;--a)this.inspectorFolder.remove(this.inspectorFolder.children[a])}handleApp(n,a,t){const i=a;switch(t.event){case"addFolder":i.addFolder(t.data.name,t.data.params,t.data.parent);break;case"bindObject":i.bind(t.data.name,t.data.params,t.data.parent);break;case"updateBind":i.triggerBind(t.data.id,t.data.value);break;case"addButton":i.button(t.data.name,t.data.callback,t.data.parent);break;case"clickButton":i.triggerButton(t.data.id);break}}}var Bt={exports:{}},st={};/**
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("three"),mn=require("tweakpane"),pn=require("@tweakpane/plugin-essentials"),T=require("react"),qi=require("framer-motion");function fn(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const n in i)if(n!=="default"){const t=Object.getOwnPropertyDescriptor(i,n);Object.defineProperty(e,n,t.get?t:{enumerable:!0,get:()=>i[n]})}}return e.default=i,Object.freeze(e)}const gn=fn(pn),ni=()=>{},_n=()=>{};function Nt(i){return i.substring(0,1).toUpperCase()+i.substring(1)}function ct(i,e,n){return Math.min(e,Math.max(i,n))}function vi(i,e,n){return(n-i)/(e-i)}function ei(i,e,n){return i*(1-n)+e*n}function vn(i,e){const n=i-e;return Math.sqrt(n*n)}function Ji(){return Math.round(Math.random()*1e6).toString()}function Qi(i){return i.r!==void 0&&i.g!==void 0&&i.b!==void 0}function yi(i){const e=Math.round(i.r*255),n=Math.round(i.g*255),t=Math.round(i.b*255),s=h=>{const c=h.toString(16);return c.length===1?"0"+c:c},a=s(e),o=s(n),r=s(t);return"#"+a+o+r}function Ei(i,e=1){return Number(i.toFixed(e))}exports.totalThreeObjects=0;const bi=()=>{exports.totalThreeObjects=0},ti=i=>{if(!i)return;let e=i.name.replaceAll(" ","").replaceAll("/",".");if(e.length===0&&(e=`obj_${exports.totalThreeObjects}`,exports.totalThreeObjects++),i.parent!==null&&i.parent.uuid.length>0&&(e=`${i.parent.uuid}.${e}`),i.uuid=e,i.isMesh!==void 0){const n=i;if(Array.isArray(n.material))n.material.forEach((t,s)=>{t.uuid=`${e}.material.${s}`});else{const t=n.material;t.uuid=`${e}.material`}}i.children.forEach(n=>ti(n))},yn=i=>{i?.dispose()},en=i=>{i&&(Array.isArray(i)?i.forEach(e=>e.dispose()):i.dispose())},zt=i=>{if(i){for(;i.children.length>0;){const e=i.children[0];e.type==="Audio"?(e.pause(),e.parent&&e.parent.remove(e)):zt(e)}if(i.parent&&i.parent.remove(i),i.isMesh){const e=i;e.geometry?.dispose(),en(e.material)}i.dispose!==void 0&&i.dispose()}};class jt{static renderer;static canvas;static context=null;static scene=null;static camera=null;static material=null;static inited=!1;static width=100;static height=100;static init(){this.inited||(this.canvas=document.createElement("canvas"),this.canvas.width=this.width,this.canvas.height=this.height,this.context=this.canvas.getContext("2d"),this.inited=!0)}static renderToBlob(e){this.init();const n=e.repeat.clone(),t=e.offset.clone();if(e.repeat.set(1,1),e.offset.set(0,0),this.context!==null){this.context.clearRect(0,0,this.width,this.height);const s=e.image;if(s!=null&&s.width>0){this.canvas.title=e.sourceFile;const a=this.canvas.width/s.width,o=this.renderToCanvas(e);this.context.drawImage(o,0,0,s.width*a,s.height*a)}}return e.repeat.copy(n),e.offset.copy(t),this.canvas.toDataURL("image/png")}static renderToCanvas(e){if(this.material===null){this.camera=new p.OrthographicCamera(-.5,.5,.5,-.5,0,100),this.scene=new p.Scene,this.material=new p.MeshBasicMaterial;const n=new p.BufferGeometry;n.setAttribute("position",new p.Float32BufferAttribute([-.5,-.5,0,1.5,-.5,0,-.5,1.5,0],3)),n.setAttribute("normal",new p.Float32BufferAttribute([0,0,1,0,0,1],3)),n.setAttribute("uv",new p.Float32BufferAttribute([0,0,2,0,0,2],2));const t=new p.Mesh(n,this.material);this.scene.add(t)}if(e.isRenderTargetTexture)this.material.map=e,this.renderer.render(this.scene,this.camera);else{const n=this.renderer.outputColorSpace,t=e.colorSpace;this.renderer.outputColorSpace=p.LinearSRGBColorSpace,e.colorSpace=p.LinearSRGBColorSpace,this.material.map=e,this.renderer.render(this.scene,this.camera),this.renderer.outputColorSpace=n,e.colorSpace=t}return this.renderer.domElement}}class En{components=new Map;listen;_appID="";_debugEnabled;_broadcastChannel=void 0;_webSocket=void 0;_mode="app";_connected=!1;_useBC=!1;constructor(e,n,t=!0){this._appID=e,this._debugEnabled=n,n&&(this._useBC=t,t?(this._broadcastChannel=new BroadcastChannel(e),this._broadcastChannel.addEventListener("message",this.messageHandler)):(this._webSocket=new WebSocket(e),this._webSocket.addEventListener("open",this.openHandler),this._webSocket.addEventListener("close",this.closeHandler),this._webSocket.addEventListener("message",this.messageHandler)))}addComponent(e,n){this.components.set(e,n)}dispose(){this._broadcastChannel!==void 0&&this._broadcastChannel.removeEventListener("message",this.messageHandler),this._webSocket!==void 0&&(this._webSocket.removeEventListener("open",this.openHandler),this._webSocket.removeEventListener("close",this.closeHandler),this._webSocket.removeEventListener("message",this.messageHandler)),this.components.forEach(e=>{e.dispose()}),this.components.clear()}send(e){this._mode!==e.target&&(this._useBC?this._broadcastChannel?.postMessage(e):this._connected&&this._webSocket?.send(JSON.stringify(e)))}messageHandler=e=>{this.listen!==void 0&&(this._useBC?this.listen(e.data):this.listen(JSON.parse(e.data)))};openHandler=()=>{this._connected=!0};closeHandler=()=>{this._connected=!1};get appID(){return this._appID}get connected(){return this._connected}get debugEnabled(){return this._debugEnabled}get mode(){return this._mode}get isApp(){return this._mode==="app"}get editor(){return this._mode==="editor"}set editor(e){e&&(this._mode="editor")}}const j=new p.EventDispatcher,N={CUSTOM:"ToolEvents::custom",SELECT_DROPDOWN:"ToolEvents::selectDropdown",DRAG_UPDATE:"ToolEvents::dragUpdate",ADD_SCENE:"ToolEvents::addScene",REFRESH_SCENE:"ToolEvents::refreshScene",REMOVE_SCENE:"ToolEvents::removeScene",SET_SCENE:"ToolEvents::setScene",GET_OBJECT:"ToolEvents::getObject",SET_OBJECT:"ToolEvents::setObject",UPDATE_OBJECT:"ToolEvents::updateObject",CREATE_TEXTURE:"ToolEvents::createTexture",REQUEST_METHOD:"ToolEvents::requestMethod",ADD_CAMERA:"ToolEvents::addCamera",REMOVE_CAMERA:"ToolEvents::removeCamera",ADD_GROUP:"ToolEvents::addGroup",REMOVE_GROUP:"ToolEvents::removeGroup"};class Ht{app;constructor(e){this.app=e}dispose(){}handleApp(e,n,t){}handleEditor(e,n,t){}}class bn extends Ht{selectDropdown(e,n){this.app.send({event:"selectComponent",target:"app",data:{dropdown:e,value:n}})}updateDropdown(e,n){this.app.send({event:"draggableListUpdate",target:"app",data:{dropdown:e,value:n}})}handleApp(e,n,t){switch(t.event){case"selectComponent":j.dispatchEvent({type:N.SELECT_DROPDOWN,value:t.data});break;case"draggableListUpdate":j.dispatchEvent({type:N.DRAG_UPDATE,value:t.data});break}}}class si extends Ht{project;sheets=new Map;sheetObjects=new Map;sheetObjectCBs=new Map;sheetObjectUnsubscribe=new Map;activeSheet;studio=void 0;static rafDriver=void 0;dispose(){this.project=void 0,this.sheets=new Map,this.sheetObjects=new Map,this.sheetObjectCBs=new Map,this.sheetObjectUnsubscribe=new Map}getSheetInstance(e,n){return n!==void 0?`${e}-${n}`:e}sheet(e,n){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const t=this.getSheetInstance(e,n);let s=this.sheets.get(t);return s!==void 0||(s=this.project?.sheet(e,n),this.sheets.set(t,s)),s}playSheet(e,n,t){this.sheet(e,t)?.sequence.play(n),this.app.send({event:"playSheet",target:"editor",data:{sheet:e,instance:t,value:n}})}pauseSheet(e,n){this.sheet(e)?.sequence.pause(),this.app.send({event:"pauseSheet",target:"editor",data:{sheet:e,instance:n}})}clearSheetObjects(e){this.sheetObjects.forEach((n,t)=>{t.search(`${e}_`)>-1&&this.unsubscribe(n)})}sheetObject(e,n,t,s,a){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const o=this.sheet(e,a);if(o===void 0)return;const h=`${this.getSheetInstance(e,a)}_${n}`;let c=this.sheetObjects.get(h);c!==void 0?c=o.object(n,{...t,...c.value},{reconfigure:!0}):c=o.object(n,t),this.sheetObjects.set(h,c),this.sheetObjectCBs.set(h,s!==void 0?s:ni);const u=c.onValuesChange(f=>{if(this.app.editor){for(const y in f){const A=f[y];typeof A=="object"&&Qi(A)&&(f[y]={r:A.r,g:A.g,b:A.b,a:A.a})}this.app.send({event:"updateSheetObject",target:"app",data:{sheet:e,sheetObject:h,values:f}})}const v=this.sheetObjectCBs.get(h);v!==void 0&&v(f)});return this.sheetObjectUnsubscribe.set(h,u),c}unsubscribe(e){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const n=e.address.sheetId,t=e.address.objectKey;this.sheets.get(n)?.detachObject(t);const a=`${n}_${t}`,o=this.sheetObjectUnsubscribe.get(a);o!==void 0&&(this.sheetObjects.delete(a),this.sheetObjectCBs.delete(a),this.sheetObjectUnsubscribe.delete(a),o())}handleApp(e,n,t){const s=n;let a;switch(t.event){case"setSheet":a=s.sheets.get(t.data.sheet),a!==void 0&&(s.activeSheet=a,this.studio?.setSelection([a]));break;case"setSheetObject":a=s.sheetObjects.get(`${t.data.sheet}_${t.data.key}`),a!==void 0&&this.studio?.setSelection([a]);break;case"updateSheetObject":a=s.sheets.get(t.data.sheet),a!==void 0&&a.sequence.pause(),a=s.sheetObjectCBs.get(t.data.sheetObject),a!==void 0&&a(t.data.values);break;case"updateTimeline":a=s.sheets.get(t.data.sheet),s.activeSheet!==void 0&&(s.activeSheet.sequence.position=t.data.position);break}}handleEditor(e,n,t){if(e.editor){const s=n;switch(t.event){case"playSheet":s.sheet(t.data.sheet,t.data.instance)?.sequence.play(t.data.value);break;case"pauseSheet":s.sheet(t.data.sheet,t.data.instance)?.sequence.pause();break}}}handleEditorApp(e,n){if(e.editor){this.studio?.ui.restore(),this.studio?.onSelectionChange(o=>{o.length<1||o.forEach(r=>{let h=r.address.sheetId,c="setSheet",u={};switch(r.type){case"Theatre_Sheet_PublicAPI":c="setSheet",u={sheet:r.address.sheetId},n.activeSheet=n.sheets.get(r.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":c="setSheetObject",h+=`_${r.address.objectKey}`,u={id:h,sheet:r.address.sheetId,key:r.address.objectKey},n.activeSheet=n.sheets.get(r.address.sheetId);break}e.send({event:c,target:"app",data:u})})});let t=-1;const s=()=>{if(si.rafDriver?.tick(performance.now()),n.activeSheet!==void 0&&t!==n.activeSheet.sequence.position){t=n.activeSheet.sequence.position;const o=n.activeSheet;e.send({event:"updateTimeline",target:"app",data:{position:t,sheet:o.address.sheetId}})}},a=()=>{s(),requestAnimationFrame(a)};s(),a()}else this.studio?.ui.hide()}}function On(i,e,n){if(i.editor){n.ui.restore(),n.onSelectionChange(o=>{o.length<1||o.forEach(r=>{let h=r.address.sheetId,c="setSheet",u={};switch(r.type){case"Theatre_Sheet_PublicAPI":c="setSheet",u={sheet:r.address.sheetId},e.activeSheet=e.sheets.get(r.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":c="setSheetObject",h+=`_${r.address.objectKey}`,u={id:h,sheet:r.address.sheetId,key:r.address.objectKey},e.activeSheet=e.sheets.get(r.address.sheetId);break}i.send({event:c,target:"app",data:u})})});let t=-1;const s=()=>{if(si.rafDriver?.tick(performance.now()),e.activeSheet!==void 0&&t!==e.activeSheet.sequence.position){t=e.activeSheet.sequence.position;const o=e.activeSheet;i.send({event:"updateTimeline",target:"app",data:{position:t,sheet:o.address.sheetId}})}},a=()=>{s(),requestAnimationFrame(a)};s(),a()}else n.ui.hide()}function Cn(i){if(i.name==="cameras")return"camera";if(i.name==="interactive")return"interactive";if(i.name==="lights")return"light";if(i.name==="ui")return"ui";if(i.name==="utils")return"utils";const e=i.type;return e.search("Helper")>-1?"icon_utils":e.search("Camera")>-1?"camera":e.search("Light")>-1?"light":"obj3D"}function wt(i){const e={name:i.name,type:i.type,uuid:i.uuid,children:[]};return i.children.forEach(n=>{e.children.push(wt(n))}),e}function Tn(i){const e={};for(const n in i){const t=i[n].value;e[n]={value:t},t===null?e[n].value={src:"",offset:[0,0],repeat:[1,1]}:t!==void 0&&t.isTexture&&(e[n].value={src:t.image.src,offset:[t.offset.x,t.offset.y],repeat:[t.repeat.x,t.repeat.y]})}return e}function xn(i){switch(i){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function Et(i){const e={};for(const n in i){if(n.substring(0,1)==="_"||n.substring(0,2)==="is"||xn(n))continue;const t=typeof i[n],s=i[n];switch(t){case"boolean":case"number":case"string":e[n]=s;break;case"object":s!==null?(e[n]=s,s.isTexture?e[n]={src:jt.renderToBlob(s),offset:[s.offset.x,s.offset.y],repeat:[s.repeat.x,s.repeat.y]}:n==="uniforms"&&(e[n]=Tn(e[n]))):n==="glslVersion"?e[n]="":e[n]={src:"",offset:[0,0],repeat:[1,1]};break}}return e}function ci(i){i.updateMatrix();const e={name:i.name,type:i.type,uuid:i.uuid,visible:i.visible,matrix:i.matrix.elements,animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};i.animations.forEach(t=>{e.animations.push({name:t.name,duration:t.duration,blendMode:t.blendMode})});const n=i.type.toLowerCase();if(n.search("mesh")>-1){const t=i;if(Array.isArray(t.material)){const s=[];t.material.forEach(a=>{s.push(Et(a))}),e.material=s}else e.material=Et(t.material)}else if(n.search("points")>-1){const t=i;if(Array.isArray(t.material)){const s=[];t.material.forEach(a=>{s.push(Et(a))}),e.material=s}else e.material=Et(t.material)}else if(n.search("line")>-1){const t=i;if(Array.isArray(t.material)){const s=[];t.material.forEach(a=>{s.push(Et(a))}),e.material=s}else e.material=Et(t.material)}else n.search("camera")>-1?i.type==="PerspectiveCamera"?e.perspectiveCameraInfo={fov:i.fov,zoom:i.zoom,near:i.near,far:i.far,focus:i.focus,aspect:i.aspect,filmGauge:i.filmGauge,filmOffset:i.filmOffset}:i.type==="OrthographicCamera"&&(e.orthographicCameraInfo={zoom:i.zoom,near:i.near,far:i.far,left:i.left,right:i.right,top:i.top,bottom:i.bottom}):n.search("light")>-1&&(e.lightInfo={color:i.color,intensity:i.intensity,decay:i.decay,distance:i.distance,angle:i.angle,penumbra:i.penumbra,groundColor:i.groundColor,width:i.width,height:i.height});return e}function Sn(i,e){const n=e.split(".");switch(n.length){case 1:return i[n[0]];case 2:return i[n[0]][n[1]];case 3:return i[n[0]][n[1]][n[2]];case 4:return i[n[0]][n[1]][n[2]][n[3]];case 5:return i[n[0]][n[1]][n[2]][n[3]][n[4]];case 6:return i[n[0]][n[1]][n[2]][n[3]][n[4]][n[5]]}}function wn(i,e){for(const n in e)i[n]=e[n]}function ge(i,e,n){if(i===void 0)return;const t=e.split("."),s=t.length;if(typeof n!="object")switch(s){case 1:i[t[0]]=n;break;case 2:i[t[0]][t[1]]=n;break;case 3:i[t[0]][t[1]][t[2]]=n;break;case 4:i[t[0]][t[1]][t[2]][t[3]]=n;break;case 5:i[t[0]][t[1]][t[2]][t[3]][t[4]]=n;break}else{let o;switch(s){case 1:o=i[t[0]];break;case 2:o=i[t[0]][t[1]];break;case 3:o=i[t[0]][t[1]][t[2]];break;case 4:o=i[t[0]][t[1]][t[2]][t[3]];break;case 5:o=i[t[0]][t[1]][t[2]][t[3]][t[4]];break}o!=null&&wn(o,n)}}function tn(i){return new Promise((e,n)=>{const t=new Image;t.onload=()=>{const s=new p.Texture(t);s.wrapS=p.RepeatWrapping,s.wrapT=p.RepeatWrapping,s.needsUpdate=!0,e(s)},t.onerror=n,t.src=i})}class Mn extends Ht{scene=void 0;scenes=new Map;renderer=void 0;renderTargets=new Map;groups=new Map;dispose(){this.scenes.forEach(e=>{zt(e)}),this.scenes.clear(),this.scene&&zt(this.scene),this.renderTargets.forEach(e=>{e.dispose()}),this.renderTargets.clear(),this.renderer?.dispose()}getObject(e){this.app.debugEnabled&&(this.renderer!==void 0&&(jt.renderer=this.renderer),this.app.send({event:"getObject",target:"app",data:e}))}setObject(e){this.renderer!==void 0&&(jt.renderer=this.renderer);const n=ci(e);this.app.send({event:"setObject",target:"editor",data:n})}requestMethod(e,n,t,s){this.app.send({event:"requestMethod",target:"app",data:{uuid:e,key:n,value:t,subitem:s}})}updateObject(e,n,t){this.app.send({event:"updateObject",target:"app",data:{uuid:e,key:n,value:t}})}createTexture(e,n,t){this.app.send({event:"createTexture",target:"app",data:{uuid:e,key:n,value:t}})}addGroup(e){this.groups.get(e.title)===void 0&&(this.groups.set(e.title,{title:e.title,onUpdate:e.onUpdate}),this.app.send({event:"addGroup",target:"editor",data:JSON.stringify(e)}))}removeGroup(e){this.groups.get(e)!==void 0&&(this.groups.delete(e),this.app.send({event:"removeGroup",target:"editor",data:e}))}updateGroup(e,n,t){this.app.send({event:"updateGroup",target:"app",data:JSON.stringify({group:e,prop:n,value:t})})}removeAllGroups(){this.groups.forEach(e=>{const n=e.title;this.groups.delete(n),this.app.send({event:"removeGroup",target:"editor",data:n})}),this.groups.clear()}addScene(e){if(e===void 0||(this.scenes.set(e.name,e),!this.app.debugEnabled))return;bi(),ti(e);const n=wt(e);this.app.send({event:"addScene",target:"editor",data:n})}refreshScene(e){if(!this.app.debugEnabled)return;const n=this.scenes.get(e);if(n!==void 0){const t=wt(n);this.app.send({event:"refreshScene",target:"app",data:t})}}removeScene(e){if(e===void 0||(this.scenes.delete(e.name),!this.app.debugEnabled))return;const n=wt(e);this.app.send({event:"removeScene",target:"editor",data:n})}removeAllScenes(){this.scenes.forEach(e=>this.removeScene(e))}getScene(e){let n=null;return this.scenes.forEach((t,s)=>{e.search(s)>-1&&(n=t)}),n}setScene(e){if(e===void 0||(this.scene=e,!this.app.debugEnabled))return;this.renderer!==void 0&&(jt.renderer=this.renderer),bi(),ti(e);const n=wt(e);this.app.send({event:"setScene",target:"editor",data:n})}addCamera(e){if(!this.app.debugEnabled)return;const n=ci(e);this.app.send({event:"addCamera",target:"editor",data:n})}removeCamera(e){if(!this.app.debugEnabled)return;const n=ci(e);this.app.send({event:"removeCamera",target:"editor",data:n})}handleApp(e,n,t){const s=n;switch(t.event){case"getObject":j.dispatchEvent({type:N.GET_OBJECT,value:t.data});break;case"updateObject":j.dispatchEvent({type:N.UPDATE_OBJECT,value:t.data});break;case"createTexture":j.dispatchEvent({type:N.CREATE_TEXTURE,value:t.data});break;case"requestMethod":j.dispatchEvent({type:N.REQUEST_METHOD,value:t.data});break;case"refreshScene":e.send({event:"refreshScene",target:"editor",data:wt(s.scenes.get(t.data.name))});break}if(t.event==="updateGroup"){const a=JSON.parse(t.data);s.groups.get(a.group)?.onUpdate(a.prop,a.value)}}handleEditor(e,n,t){switch(t.event){case"setObject":j.dispatchEvent({type:N.SET_OBJECT,value:t.data});break;case"addScene":j.dispatchEvent({type:N.ADD_SCENE,value:t.data});break;case"refreshScene":j.dispatchEvent({type:N.REFRESH_SCENE,value:t.data});break;case"removeScene":j.dispatchEvent({type:N.REMOVE_SCENE,value:t.data});break;case"setScene":j.dispatchEvent({type:N.SET_SCENE,value:t.data});break;case"addCamera":j.dispatchEvent({type:N.ADD_CAMERA,value:t.data});break;case"removeCamera":j.dispatchEvent({type:N.REMOVE_CAMERA,value:t.data});break;case"addGroup":j.dispatchEvent({type:N.ADD_GROUP,value:t.data});break;case"removeGroup":j.dispatchEvent({type:N.REMOVE_GROUP,value:t.data});break}}rendererWidth=300;rendererHeight=150;addRT(e,n){const t=new p.WebGLRenderTarget(32,32,n);t.texture.name=e,this.renderTargets.set(e,t)}resize(e,n){const t=this.dpr;this.rendererWidth=e,this.rendererHeight=n,this.renderTargets.forEach(s=>{s.setSize(e*t,n*t)}),this.renderer?.setSize(e,n)}set dpr(e){this.renderer?.setPixelRatio(ct(1,2,e))}get dpr(){return this.renderer!==void 0?this.renderer?.getPixelRatio():1}get width(){return this.rendererWidth}get height(){return this.rendererHeight}get canvas(){return this.renderer!==void 0?this.renderer?.domElement:null}}class Rn extends Ht{bindCBs;buttonCBs;pane=void 0;appCallbacks=0;editorCallbacks=0;inspectorFolder=void 0;constructor(e){super(e),this.bindCBs=new Map,this.buttonCBs=new Map,e.editor&&this.createGUI()}createGUI(){this.pane=new mn.Pane({title:"GUI"}),this.pane.registerPlugin(gn)}dispose(){this.bindCBs.clear(),this.buttonCBs.clear(),this.appCallbacks=0,this.editorCallbacks=0,this.app.editor&&(this.pane?.dispose(),this.pane=void 0)}addFolder(e,n=void 0,t=void 0){if(this.app.editor)return this.pane===void 0&&this.createGUI(),(t!==void 0?t:this.pane).addFolder({title:e,...n});this.app.send({event:"addFolder",target:"app",data:{name:e,params:n,parent:t}})}get bindID(){return`debug_${Math.max(this.appCallbacks,this.editorCallbacks)}`}bind(e,n,t,s=void 0){const a=this.bindID,o=t.onChange!==void 0?t.onChange:ni;this.bindCBs.set(a,o),this.app.editor?(this.pane===void 0&&this.createGUI(),(s!==void 0?s:this.pane).addBinding(e,n,t).on("change",h=>{this.app.send({event:"updateBind",target:"app",data:{id:a,value:h.value}})}),this.editorCallbacks++):(this.app.send({event:"bindObject",target:"app",data:{id:a,name:n,params:t,parent:s}}),this.appCallbacks++)}triggerBind(e,n){const t=this.bindCBs.get(e);t!==void 0?t(n):console.warn(`No callback for: ${e}`,n)}button(e,n,t=void 0){const s=this.bindID;this.buttonCBs.set(s,n),this.app.editor?(this.pane===void 0&&this.createGUI(),(t!==void 0?t:this.pane).addButton({title:e}).on("click",()=>{this.app.send({event:"clickButton",target:"app",data:{id:s}})}),this.editorCallbacks++):(this.app.send({event:"addButton",target:"app",data:{id:s,name:e,callback:n,parent:t}}),this.appCallbacks++)}triggerButton(e){const n=this.buttonCBs.get(e);n!==void 0&&n()}createInspector(){this.inspectorFolder=this.addFolder("Inspector",this.pane)}clearInspector(){const e=this.inspectorFolder.children.length-1;for(let n=e;n>-1;--n)this.inspectorFolder.remove(this.inspectorFolder.children[n])}handleApp(e,n,t){const s=n;switch(t.event){case"addFolder":s.addFolder(t.data.name,t.data.params,t.data.parent);break;case"bindObject":s.bind(t.data.name,t.data.params,t.data.parent);break;case"updateBind":s.triggerBind(t.data.id,t.data.value);break;case"addButton":s.button(t.data.name,t.data.callback,t.data.parent);break;case"clickButton":s.triggerButton(t.data.id);break}}}var Oi={exports:{}},Rt={};/**
|
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 Di;function Dn(){if(Di)return Rt;Di=1;var i=T,e=Symbol.for("react.element"),n=Symbol.for("react.fragment"),t=Object.prototype.hasOwnProperty,s=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function o(r,h,c){var u,f={},v=null,y=null;c!==void 0&&(v=""+c),h.key!==void 0&&(v=""+h.key),h.ref!==void 0&&(y=h.ref);for(u in h)t.call(h,u)&&!a.hasOwnProperty(u)&&(f[u]=h[u]);if(r&&r.defaultProps)for(u in h=r.defaultProps,h)f[u]===void 0&&(f[u]=h[u]);return{$$typeof:e,type:r,key:v,ref:y,props:f,_owner:s.current}}return Rt.Fragment=n,Rt.jsx=o,Rt.jsxs=o,Rt}var Dt={};/**
|
10
10
|
* @license React
|
11
11
|
* react-jsx-runtime.development.js
|
12
12
|
*
|
@@ -14,20 +14,25 @@
|
|
14
14
|
*
|
15
15
|
* This source code is licensed under the MIT license found in the
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
17
|
-
*/var
|
18
|
-
`+
|
19
|
-
`),
|
20
|
-
`),
|
21
|
-
`+
|
17
|
+
*/var Ai;function An(){return Ai||(Ai=1,process.env.NODE_ENV!=="production"&&function(){var i=T,e=Symbol.for("react.element"),n=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),r=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),y=Symbol.for("react.offscreen"),A=Symbol.iterator,I="@@iterator";function U(l){if(l===null||typeof l!="object")return null;var O=A&&l[A]||l[I];return typeof O=="function"?O:null}var _=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function E(l){{for(var O=arguments.length,M=new Array(O>1?O-1:0),H=1;H<O;H++)M[H-1]=arguments[H];w("error",l,M)}}function w(l,O,M){{var H=_.ReactDebugCurrentFrame,ee=H.getStackAddendum();ee!==""&&(O+="%s",M=M.concat([ee]));var ae=M.map(function(K){return String(K)});ae.unshift("Warning: "+O),Function.prototype.apply.call(console[l],console,ae)}}var C=!1,k=!1,L=!1,x=!1,ne=!1,q;q=Symbol.for("react.module.reference");function $e(l){return!!(typeof l=="string"||typeof l=="function"||l===t||l===a||ne||l===s||l===c||l===u||x||l===y||C||k||L||typeof l=="object"&&l!==null&&(l.$$typeof===v||l.$$typeof===f||l.$$typeof===o||l.$$typeof===r||l.$$typeof===h||l.$$typeof===q||l.getModuleId!==void 0))}function Y(l,O,M){var H=l.displayName;if(H)return H;var ee=O.displayName||O.name||"";return ee!==""?M+"("+ee+")":M}function Pe(l){return l.displayName||"Context"}function Ee(l){if(l==null)return null;if(typeof l.tag=="number"&&E("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof l=="function")return l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case t:return"Fragment";case n:return"Portal";case a:return"Profiler";case s:return"StrictMode";case c:return"Suspense";case u:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case r:var O=l;return Pe(O)+".Consumer";case o:var M=l;return Pe(M._context)+".Provider";case h:return Y(l,l.render,"ForwardRef");case f:var H=l.displayName||null;return H!==null?H:Ee(l.type)||"Memo";case v:{var ee=l,ae=ee._payload,K=ee._init;try{return Ee(K(ae))}catch{return null}}}return null}var Ce=Object.assign,Te=0,Le,Ve,it,Qe,et,dt,nt;function _e(){}_e.__reactDisabledLog=!0;function Ye(){{if(Te===0){Le=console.log,Ve=console.info,it=console.warn,Qe=console.error,et=console.group,dt=console.groupCollapsed,nt=console.groupEnd;var l={configurable:!0,enumerable:!0,value:_e,writable:!0};Object.defineProperties(console,{info:l,log:l,warn:l,error:l,group:l,groupCollapsed:l,groupEnd:l})}Te++}}function Mt(){{if(Te--,Te===0){var l={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:Ce({},l,{value:Le}),info:Ce({},l,{value:Ve}),warn:Ce({},l,{value:it}),error:Ce({},l,{value:Qe}),group:Ce({},l,{value:et}),groupCollapsed:Ce({},l,{value:dt}),groupEnd:Ce({},l,{value:nt})})}Te<0&&E("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ht=_.ReactCurrentDispatcher,we;function b(l,O,M){{if(we===void 0)try{throw Error()}catch(ee){var H=ee.stack.trim().match(/\n( *(at )?)/);we=H&&H[1]||""}return`
|
18
|
+
`+we+l}}var S=!1,P;{var F=typeof WeakMap=="function"?WeakMap:Map;P=new F}function he(l,O){if(!l||S)return"";{var M=P.get(l);if(M!==void 0)return M}var H;S=!0;var ee=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var ae;ae=ht.current,ht.current=null,Ye();try{if(O){var K=function(){throw Error()};if(Object.defineProperty(K.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(K,[])}catch(tt){H=tt}Reflect.construct(l,[],K)}else{try{K.call()}catch(tt){H=tt}l.call(K.prototype)}}else{try{throw Error()}catch(tt){H=tt}l()}}catch(tt){if(tt&&H&&typeof tt.stack=="string"){for(var W=tt.stack.split(`
|
19
|
+
`),Se=H.stack.split(`
|
20
|
+
`),fe=W.length-1,ye=Se.length-1;fe>=1&&ye>=0&&W[fe]!==Se[ye];)ye--;for(;fe>=1&&ye>=0;fe--,ye--)if(W[fe]!==Se[ye]){if(fe!==1||ye!==1)do if(fe--,ye--,ye<0||W[fe]!==Se[ye]){var je=`
|
21
|
+
`+W[fe].replace(" at new "," at ");return l.displayName&&je.includes("<anonymous>")&&(je=je.replace("<anonymous>",l.displayName)),typeof l=="function"&&P.set(l,je),je}while(fe>=1&&ye>=0);break}}}finally{S=!1,ht.current=ae,Mt(),Error.prepareStackTrace=ee}var yt=l?l.displayName||l.name:"",Ri=yt?b(yt):"";return typeof l=="function"&&P.set(l,Ri),Ri}function se(l,O,M){return he(l,!1)}function D(l){var O=l.prototype;return!!(O&&O.isReactComponent)}function z(l,O,M){if(l==null)return"";if(typeof l=="function")return he(l,D(l));if(typeof l=="string")return b(l);switch(l){case c:return b("Suspense");case u:return b("SuspenseList")}if(typeof l=="object")switch(l.$$typeof){case h:return se(l.render);case f:return z(l.type,O,M);case v:{var H=l,ee=H._payload,ae=H._init;try{return z(ae(ee),O,M)}catch{}}}return""}var ve=Object.prototype.hasOwnProperty,De={},We=_.ReactDebugCurrentFrame;function $(l){if(l){var O=l._owner,M=z(l.type,l._source,O?O.type:null);We.setExtraStackFrame(M)}else We.setExtraStackFrame(null)}function oe(l,O,M,H,ee){{var ae=Function.call.bind(ve);for(var K in l)if(ae(l,K)){var W=void 0;try{if(typeof l[K]!="function"){var Se=Error((H||"React class")+": "+M+" type `"+K+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof l[K]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Se.name="Invariant Violation",Se}W=l[K](O,K,H,M,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(fe){W=fe}W&&!(W instanceof Error)&&($(ee),E("%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).",H||"React class",M,K,typeof W),$(null)),W instanceof Error&&!(W.message in De)&&(De[W.message]=!0,$(ee),E("Failed %s type: %s",M,W.message),$(null))}}}var Oe=Array.isArray;function ce(l){return Oe(l)}function me(l){{var O=typeof Symbol=="function"&&Symbol.toStringTag,M=O&&l[Symbol.toStringTag]||l.constructor.name||"Object";return M}}function V(l){try{return te(l),!1}catch{return!0}}function te(l){return""+l}function pe(l){if(V(l))return E("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",me(l)),te(l)}var ue=_.ReactCurrentOwner,Ae={key:!0,ref:!0,__self:!0,__source:!0},Ie,st,Ke;Ke={};function _t(l){if(ve.call(l,"ref")){var O=Object.getOwnPropertyDescriptor(l,"ref").get;if(O&&O.isReactWarning)return!1}return l.ref!==void 0}function ri(l){if(ve.call(l,"key")){var O=Object.getOwnPropertyDescriptor(l,"key").get;if(O&&O.isReactWarning)return!1}return l.key!==void 0}function oi(l,O){if(typeof l.ref=="string"&&ue.current&&O&&ue.current.stateNode!==O){var M=Ee(ue.current.type);Ke[M]||(E('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',Ee(ue.current.type),l.ref),Ke[M]=!0)}}function Vt(l,O){{var M=function(){Ie||(Ie=!0,E("%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)",O))};M.isReactWarning=!0,Object.defineProperty(l,"key",{get:M,configurable:!0})}}function at(l,O){{var M=function(){st||(st=!0,E("%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)",O))};M.isReactWarning=!0,Object.defineProperty(l,"ref",{get:M,configurable:!0})}}var wi=function(l,O,M,H,ee,ae,K){var W={$$typeof:e,type:l,key:O,ref:M,props:K,_owner:ae};return W._store={},Object.defineProperty(W._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(W,"_self",{configurable:!1,enumerable:!1,writable:!1,value:H}),Object.defineProperty(W,"_source",{configurable:!1,enumerable:!1,writable:!1,value:ee}),Object.freeze&&(Object.freeze(W.props),Object.freeze(W)),W};function d(l,O,M,H,ee){{var ae,K={},W=null,Se=null;M!==void 0&&(pe(M),W=""+M),ri(O)&&(pe(O.key),W=""+O.key),_t(O)&&(Se=O.ref,oi(O,ee));for(ae in O)ve.call(O,ae)&&!Ae.hasOwnProperty(ae)&&(K[ae]=O[ae]);if(l&&l.defaultProps){var fe=l.defaultProps;for(ae in fe)K[ae]===void 0&&(K[ae]=fe[ae])}if(W||Se){var ye=typeof l=="function"?l.displayName||l.name||"Unknown":l;W&&Vt(K,ye),Se&&at(K,ye)}return wi(l,W,Se,ee,H,ue.current,K)}}var R=_.ReactCurrentOwner,Z=_.ReactDebugCurrentFrame;function X(l){if(l){var O=l._owner,M=z(l.type,l._source,O?O.type:null);Z.setExtraStackFrame(M)}else Z.setExtraStackFrame(null)}var be;be=!1;function ke(l){return typeof l=="object"&&l!==null&&l.$$typeof===e}function xe(){{if(R.current){var l=Ee(R.current.type);if(l)return`
|
22
22
|
|
23
|
-
Check the render method of \``+
|
23
|
+
Check the render method of \``+l+"`."}return""}}function Mi(l){{if(l!==void 0){var O=l.fileName.replace(/^.*[\\\/]/,""),M=l.lineNumber;return`
|
24
24
|
|
25
|
-
Check your code at `+
|
25
|
+
Check your code at `+O+":"+M+"."}return""}}var Yt={};function Gt(l){{var O=xe();if(!O){var M=typeof l=="string"?l:l.displayName||l.name;M&&(O=`
|
26
26
|
|
27
|
-
Check the top-level render call using <`+
|
27
|
+
Check the top-level render call using <`+M+">.")}return O}}function Ue(l,O){{if(!l._store||l._store.validated||l.key!=null)return;l._store.validated=!0;var M=Gt(O);if(Yt[M])return;Yt[M]=!0;var H="";l&&l._owner&&l._owner!==R.current&&(H=" It was passed a child from "+Ee(l._owner.type)+"."),X(l),E('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',M,H),X(null)}}function Fe(l,O){{if(typeof l!="object")return;if(ce(l))for(var M=0;M<l.length;M++){var H=l[M];ke(H)&&Ue(H,O)}else if(ke(l))l._store&&(l._store.validated=!0);else if(l){var ee=U(l);if(typeof ee=="function"&&ee!==l.entries)for(var ae=ee.call(l),K;!(K=ae.next()).done;)ke(K.value)&&Ue(K.value,O)}}}function ut(l){{var O=l.type;if(O==null||typeof O=="string")return;var M;if(typeof O=="function")M=O.propTypes;else if(typeof O=="object"&&(O.$$typeof===h||O.$$typeof===f))M=O.propTypes;else return;if(M){var H=Ee(O);oe(M,l.props,"prop",H,l)}else if(O.PropTypes!==void 0&&!be){be=!0;var ee=Ee(O);E("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ee||"Unknown")}typeof O.getDefaultProps=="function"&&!O.getDefaultProps.isReactClassApproved&&E("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ge(l){{for(var O=Object.keys(l.props),M=0;M<O.length;M++){var H=O[M];if(H!=="children"&&H!=="key"){X(l),E("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",H),X(null);break}}l.ref!==null&&(X(l),E("Invalid attribute `ref` supplied to `React.Fragment`."),X(null))}}function rt(l,O,M,H,ee,ae){{var K=$e(l);if(!K){var W="";(l===void 0||typeof l=="object"&&l!==null&&Object.keys(l).length===0)&&(W+=" 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 Se=Mi(ee);Se?W+=Se:W+=xe();var fe;l===null?fe="null":ce(l)?fe="array":l!==void 0&&l.$$typeof===e?(fe="<"+(Ee(l.type)||"Unknown")+" />",W=" Did you accidentally export a JSX literal instead of a component?"):fe=typeof l,E("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",fe,W)}var ye=d(l,O,M,ee,ae);if(ye==null)return ye;if(K){var je=O.children;if(je!==void 0)if(H)if(ce(je)){for(var yt=0;yt<je.length;yt++)Fe(je[yt],l);Object.freeze&&Object.freeze(je)}else E("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 Fe(je,l)}return l===t?Ge(ye):ut(ye),ye}}function vt(l,O,M){return rt(l,O,M,!0)}function Zt(l,O,M){return rt(l,O,M,!1)}var hn=Zt,un=vt;Dt.Fragment=t,Dt.jsx=hn,Dt.jsxs=un}()),Dt}process.env.NODE_ENV==="production"?Oi.exports=Dn():Oi.exports=An();var m=Oi.exports;function xi(i){return i.title.search("<")>-1?m.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:i.title}}):m.jsx("button",{children:i.title})}const Pn=m.jsxs("svg",{className:"closeIcon",width:"14",height:"14",fill:"none",stroke:"#666666",strokeMiterlimit:"10",children:[m.jsx("circle",{cx:"7",cy:"7",r:"6"}),m.jsx("line",{x1:"4",y1:"4",x2:"10",y2:"10"}),m.jsx("line",{x1:"4",y1:"10",x2:"10",y2:"4"})]}),Ln=m.jsx("svg",{className:"dragIcon",width:"14",height:"14",fill:"#666666",stroke:"none",children:m.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 hn(e){return u.jsx(sn.Reorder.Item,{value:e.title,children:u.jsxs("div",{children:[Vn,u.jsx("span",{children:e.title}),u.jsx("button",{className:"closeIcon",onClick:()=>{e.onDelete(e.index)},children:Un})]})},e.title)}function fn(e){const[n,a]=b.useState(!1),[t,i]=b.useState(e.options),o=d=>{e.onDragComplete(d),i(d)},l=d=>{const m=[...t];m.splice(d,1),o(m)},s=[];t.forEach((d,m)=>{s.push(u.jsx(hn,{index:m,title:d,onDelete:l},d))});let f="dropdown draggable";return e.subdropdown&&(f+=" subdropdown"),u.jsxs("div",{className:f,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[u.jsx(zt,{title:e.title}),u.jsx(sn.Reorder.Group,{axis:"y",values:t,onReorder:o,style:{visibility:n?"visible":"hidden"},children:s})]})}function mn(e){const[n,a]=b.useState(!1),t=[];e.options.map((o,l)=>{e.onSelect!==void 0&&(o.onSelect=e.onSelect),t.push(u.jsx(pn,{option:o},l))});let i="dropdown";return e.subdropdown&&(i+=" subdropdown"),u.jsxs("div",{className:i,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[u.jsx(zt,{title:e.title}),u.jsx("ul",{style:{visibility:n?"visible":"hidden"},children:t})]})}function pn(e){const{option:n}=e,[a,t]=b.useState("");let i;switch(n.type){case"draggable":i=u.jsx(fn,{title:n.title,options:n.value,onDragComplete:o=>{n.onDragComplete!==void 0&&n.onDragComplete(o)},subdropdown:!0});break;case"dropdown":i=u.jsx(mn,{title:n.title,options:n.value,onSelect:n.onSelect,subdropdown:!0});break;case"option":i=u.jsx("button",{onClick:()=>{n.onSelect!==void 0&&n.onSelect(n.value),n.selectable&&(a!==n.title?t(n.title):t(""))},children:n.title});break}return u.jsx("li",{className:a===n.title?"selected":"",children:i},on())}function zn(e,n,a){function t(o){switch(n.forEach(l=>{l.callback(e,l.remote,o)}),o.event){case"custom":D.dispatchEvent({type:A.CUSTOM,value:o.data});break}}function i(o){switch(a.forEach(l=>{l.callback(e,l.remote,o)}),o.event){case"custom":D.dispatchEvent({type:A.CUSTOM,value:o.data});break}}e.listen=o=>{o.target==="editor"?i(o):t(o)}}function ft(e){const[n,a]=b.useState(e.open!==void 0?e.open:!0),t=!n||e.children===void 0,i=()=>{D.dispatchEvent({type:A.REMOVE_SCENE,value:e.scene})};return u.jsxs("div",{className:`accordion ${t?"hide":""}`,children:[u.jsxs("button",{className:"toggle",onClick:()=>{const o=!n;e.onToggle!==void 0&&e.onToggle(o),a(o)},children:[u.jsx("p",{className:`status ${n?"open":""}`,children:"Toggle"}),u.jsx("p",{className:"label",children:dt(e.label)})]}),e.onRefresh?u.jsxs(u.Fragment,{children:[u.jsx("button",{className:"refresh",onClick:e.onRefresh}),u.jsx("button",{className:"remove",onClick:i})]}):null,e.button,u.jsx("div",{className:n?"open":"",children:u.jsx("div",{children:e.children})},Math.random())]})}function $t(e){const n=b.useRef(null),[a,t]=b.useState(!1),i=e.child!==void 0&&e.child.children.length>0,o=[];return e.child!==void 0&&e.child.children.length>0&&e.child.children.map((l,s)=>{o.push(u.jsx($t,{child:l,three:e.three},s))}),b.useEffect(()=>{if(e.child){const l=e.three.getScene(e.child.uuid);if(l!==null){const s=l.getObjectByProperty("uuid",e.child.uuid);s!==void 0&&(n.current.style.opacity=s.visible?"1":"0.25")}}},[a]),u.jsx(u.Fragment,{children:e.child!==void 0&&u.jsxs("div",{className:"childObject",children:[u.jsxs("div",{className:"child",children:[i?u.jsx("button",{className:"status",style:{backgroundPositionX:a?"-14px":"2px"},onClick:()=>{t(!a)}}):null,u.jsx("button",{className:"name",style:{left:i?"20px":"5px"},onClick:()=>{e.child!==void 0&&(e.three.getObject(e.child.uuid),a||t(!0))},children:e.child.name.length>0?`${e.child.name} (${e.child.type})`:`${e.child.type}::${e.child.uuid}`}),u.jsx("button",{className:"visibility",ref:n,onClick:()=>{if(e.child){const l=e.three.getScene(e.child.uuid);if(l!==null){const s=l.getObjectByProperty("uuid",e.child.uuid);if(s!==void 0){const f="visible",d=!s.visible;n.current.style.opacity=d?"1":"0.25",e.three.updateObject(e.child.uuid,f,d),Q(s,f,d)}}}}}),u.jsx("div",{className:`icon ${Dn(e.child)}`})]}),u.jsx("div",{className:a?"open":"",children:u.jsx("div",{className:"container",children:o})})]},Math.random())})}function Ut(e){const n=[];return e.child?.children.map((a,t)=>{n.push(u.jsx($t,{child:a,scene:e.scene,three:e.three},t))}),u.jsx("div",{className:`scene ${e.class!==void 0?e.class:""}`,children:n})}function $n(e){const[n,a]=b.useState(e.defaultValue);return b.useEffect(()=>{let t=!1,i=-1,o=0,l=e.defaultValue;const s=E=>{t=!0,o=Number(e.input.current?.value),i=E.clientX,document.addEventListener("mouseup",d,!1),document.addEventListener("mousemove",f,!1),document.addEventListener("contextmenu",d,!1)},f=E=>{if(!t)return;const C=e.step!==void 0?e.step:1,I=(E.clientX-i)*C;l=Number((o+I).toFixed(4)),e.min!==void 0&&(l=Math.max(l,e.min)),e.max!==void 0&&(l=Math.min(l,e.max)),e.onChange!==void 0&&e.onChange(l),a(l)},d=()=>{t=!1,document.removeEventListener("mouseup",d),document.removeEventListener("mousemove",f),document.removeEventListener("contextmenu",d)},m=E=>{const C=Number(E.target.value);a(C)},y=E=>{const C=Number(E.target.value);e.onChange!==void 0&&e.onChange(C),a(C)};return e.input.current?.addEventListener("input",m),e.label.current?.addEventListener("mousedown",s,!1),e.sliderRef!==void 0&&e.sliderRef.current?.addEventListener("input",y),()=>{e.input.current?.removeEventListener("input",m),e.label.current?.removeEventListener("mousedown",s),e.sliderRef!==void 0&&e.sliderRef.current?.removeEventListener("input",y),document.removeEventListener("mouseup",d),document.removeEventListener("mousemove",f),document.removeEventListener("contextmenu",d)}},[]),n}function We(e){const n=b.useRef(null),a=b.useRef(null),t=$n({label:e.labelRef,input:n,sliderRef:a,defaultValue:e.value,min:e.min,max:e.max,step:e.step,onChange:i=>{e.onChange!==void 0&&e.onChange(e.prop,i)}});return u.jsxs(u.Fragment,{children:[e.type==="number"&&u.jsx("input",{alt:e.alt,className:e.className,ref:n,type:"number",value:t,min:e.min,max:e.max,step:e.step,disabled:e.disabled,onChange:i=>{const o=Number(i.target.value);e.onChange!==void 0&&e.onChange(e.prop,o)}}),e.type==="range"&&u.jsxs(u.Fragment,{children:[u.jsx("input",{type:"text",value:t.toString(),disabled:e.disabled,ref:n,className:"min",onChange:i=>{const o=Number(i.target.value);e.onChange!==void 0&&e.onChange(e.prop,o)}}),u.jsx("input",{disabled:e.disabled,type:"range",value:t,min:e.min,max:e.max,step:e.step,ref:a,onChange:Ot})]})]})}function Gn(e){const n=b.useRef(null),a=b.useRef(null),t=b.useRef(null),i=b.useRef(null),o=b.useRef(null),l=b.useRef(null),[s,f]=b.useState(e.value),[d,m]=b.useState({min:Math.min(e.min,Math.min(e.value.x,e.value.y)),max:Math.max(e.max,Math.max(e.value.x,e.value.y))}),[y,E]=b.useState(!1);function C(){y||(window.addEventListener("mousemove",K),window.addEventListener("mouseup",I),window.addEventListener("mouseup",I),E(!0))}function I(){window.removeEventListener("mousemove",K),window.removeEventListener("mouseup",I),E(!1)}function K(k){const Z=o.current.getBoundingClientRect(),se=Ve(0,99,k.clientX-Z.left)/99,w=Ve(0,99,k.clientY-Z.top)/99,ge=Lt(Nt(d.min,d.max,se),3),Y=Lt(Nt(d.min,d.max,w),3);e.onChange({target:{value:{x:ge,y:Y}}}),f({x:ge,y:Y})}function z(k){let Z=s.x,se=s.y;k.target===n.current?Z=Number(k.target.value):se=Number(k.target.value),f({x:Z,y:se})}function H(){const k=Number(t.current.value);m({min:k,max:d.max}),(s.x<k||s.y<k)&&f({x:Ve(k,d.max,s.x),y:Ve(k,d.max,s.y)})}function O(){const k=Number(i.current.value);m({min:d.min,max:k}),(s.x>k||s.y>k)&&f({x:Ve(d.min,k,s.x),y:Ve(d.min,k,s.y)})}b.useEffect(()=>{const k=jt(d.min,d.max,s.x),Z=jt(d.min,d.max,s.y);l.current.style.left=`${k*100}%`,l.current.style.top=`${Z*100}%`},[d,s]);const V=e.step!==void 0?e.step:.01;return u.jsxs("div",{className:"vector2",children:[u.jsxs("div",{className:"fields",children:[u.jsxs("div",{children:[u.jsx("label",{children:"X:"}),u.jsx("input",{ref:n,type:"number",value:s.x,min:d.min,max:d.max,step:V,onChange:z})]}),u.jsxs("div",{children:[u.jsx("label",{children:"Y:"}),u.jsx("input",{ref:a,type:"number",value:s.y,min:d.min,max:d.max,step:V,onChange:z})]}),u.jsxs("div",{children:[u.jsx("label",{children:"Min:"}),u.jsx("input",{ref:t,type:"number",value:d.min,step:V,onChange:H})]}),u.jsxs("div",{children:[u.jsx("label",{children:"Max:"}),u.jsx("input",{ref:i,type:"number",value:d.max,step:V,onChange:O})]})]}),u.jsxs("div",{className:"input",ref:o,onMouseDown:C,onMouseUp:I,children:[u.jsx("div",{className:"x"}),u.jsx("div",{className:"y"}),u.jsx("div",{className:"pt",ref:l})]})]})}function Kt(e){const n=e.value.isVector3!==void 0,a=e.value.isEuler!==void 0,t=e.value.elements!==void 0,i=e.step!==void 0?e.step:.01,o=[];if(n){const l=b.useMemo(()=>e.value,[]),s=(d,m)=>{l[d]=m,e.onChange({target:{value:l}})};["x","y","z"].forEach(d=>{const m=b.useRef(null);o.push(u.jsxs("div",{children:[u.jsx("label",{ref:m,children:d.toUpperCase()}),u.jsx(We,{value:l[d],type:"number",prop:d,step:i,labelRef:m,onChange:s})]},d))})}else if(a){const l=b.useMemo(()=>e.value,[]),s=(d,m)=>{l[d]=m,e.onChange({target:{value:l}})};["_x","_y","_z"].forEach(d=>{const m=b.useRef(null);o.push(u.jsxs("div",{children:[u.jsx("label",{ref:m,children:d.substring(1).toUpperCase()}),u.jsx(We,{value:l[d],type:"number",prop:d,step:i,labelRef:m,onChange:s})]},d))})}else if(t){const l=b.useMemo(()=>e.value,[]),s=(f,d)=>{const m=Number(f);l.elements[m]=d,e.onChange({target:{value:l}})};for(let f=0;f<9;f++){const d=b.useRef(null);o.push(u.jsxs("div",{children:[u.jsx("label",{ref:d,children:f+1}),u.jsx(We,{value:l.elements[f],type:"number",prop:f.toString(),step:i,labelRef:d,onChange:s})]},f.toString()))}}return u.jsx("div",{className:"grid3",children:o},Math.random().toString())}function Hn(e){const n=e.value.x!==void 0,a=e.step!==void 0?e.step:.01,t=[];if(n){const i=b.useMemo(()=>e.value,[]),o=(s,f)=>{i[s]=f,e.onChange({target:{value:i}})};["x","y","z","w"].forEach(s=>{const f=b.useRef(null);t.push(u.jsxs("div",{children:[u.jsx("label",{ref:f,children:s.toUpperCase()}),u.jsx(We,{value:i.x,type:"number",prop:s,step:a,labelRef:f,onChange:o})]},s))})}else{const i=b.useMemo(()=>e.value,[]),o=(l,s)=>{const f=Number(l);i.elements[f]=s,e.onChange({target:{value:i}})};for(let l=0;l<16;l++){const s=b.useRef(null);t.push(u.jsxs("div",{children:[u.jsx("label",{ref:s,children:l+1}),u.jsx(We,{value:i.elements[l],type:"number",prop:l.toString(),step:a,labelRef:s,onChange:o})]},l.toString()))}}return u.jsx("div",{className:"grid4",children:t})}function Wn(e){return"items"in e}function Ye(e){const n=[];return e.items.forEach(a=>{Wn(a)?n.push(u.jsx(Ye,{title:dt(a.title),items:a.items},Math.random())):n.push(u.jsx(Ct,{title:a.title,prop:a.prop,value:a.value,type:a.type,min:a.min,max:a.max,step:a.step,disabled:a.disabled,options:a.options,onChange:(t,i)=>{a.onChange!==void 0&&a.onChange(t,i)},onKeyDown:t=>{a.onKeyDown!==void 0&&a.onKeyDown(t)}},Math.random()))}),u.jsx(ft,{label:e.title,open:e.expanded===!0,children:n})}function Yn(e){return!(e==="alphaHash"||e==="alphaToCoverage"||e==="blendAlpha"||e==="blendColor"||e==="blendDstAlpha"||e==="colorWrite"||e==="combine"||e==="defaultAttributeValues"||e==="depthFunc"||e==="forceSinglePass"||e==="glslVersion"||e==="linecap"||e==="linejoin"||e==="linewidth"||e==="normalMapType"||e==="precision"||e==="premultipliedAlpha"||e==="shadowSide"||e==="toneMapped"||e==="uniformsGroups"||e==="uniformsNeedUpdate"||e==="userData"||e==="vertexColors"||e==="version"||e==="wireframeLinecap"||e==="wireframeLinejoin"||e==="wireframeLinewidth"||e.slice(0,4)==="clip"||e.slice(0,7)==="polygon"||e.slice(0,7)==="stencil"||e.slice(0,2)==="is")}function qn(e){switch(e){case"Alpha Map":return"alphaMap";case"Anisotropy Map":return"anisotropyMap";case"AO Map":return"aoMap";case"Bump Map":return"bumpMap";case"Clearcoat Map":return"clearcoatMap";case"Clearcoat Normal Map":return"clearcoatNormalMap";case"Clearcoat Roughness Map":return"clearcoatRoughnessMap";case"Displacement Map":return"displacementMap";case"Emissive Map":return"emissiveMap";case"Gradient Map":return"gradientMap";case"Iridescence Map":return"iridescenceMap";case"Iridescence Thickness Map":return"iridescenceThicknessMap";case"Map":return"map";case"Matcap":return"matcap";case"Normal Map":return"normalMap";case"Roughness Map":return"roughnessMap";case"Sheen Color Map":return"sheenColorMap";case"Sheen Roughness Map":return"sheenRoughnessMap";case"Specular Color Map":return"specularColorMap";case"Specular Map Intensity":return"specularIntensityMap";case"Thickness Map":return"thicknessMap";case"Transmission Map":return"transmissionMap"}return e}function Tt(e){switch(e){case"alphaMap":return"Alpha Map";case"anisotropy":return"Anisotropy";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"attenuationDistance":return"Attenuation Distance";case"blendAlpha":return"Blend Alpha";case"blendColor":return"Blend Color";case"blendDst":return"Blend Dst";case"blendDstAlpha":return"Blend Dst Alha";case"blendEquation":return"Blend Equation";case"blendEquationAlpha":return"Blend Equation Alpha";case"blending":return"Blending";case"blendSrc":return"Blend Src";case"blendSrcAlpha":return"Blend Src Alpha";case"bumpMap":return"Bump Map";case"bumpScale":return"Bump Scale";case"clearcoat":return"Clearcoat";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"dispersion":return"Dispersion";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"envMapRotation":return"Environment Map Rotation";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"iridescence":return"Iridescence";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"sheen":return"Sheen";case"sheenColor":return"Sheen Color";case"sheenColorMap":return"Sheen Color Map";case"sheenRoughness":return"Sheen Roughness";case"sheenRoughnessMap":return"Sheen Roughness Map";case"shininess":return"Shininess";case"side":return"Side";case"size":return"Size";case"sizeAttenuation":return"Size Attenuation";case"specular":return"Specular";case"specularColor":return"Specular Color";case"specularColorMap":return"Specular Color Map";case"specularIntensity":return"Specular Intensity";case"specularIntensityMap":return"Specular Map Intensity";case"thickness":return"Thickness";case"thicknessMap":return"Thickness Map";case"transmission":return"Transmission";case"transmissionMap":return"Transmission Map";case"transparent":return"Transparent";case"type":return"Type";case"uuid":return"UUID";case"uniforms":return"Uniforms";case"vertexShader":return"Vertex Shader";case"visible":return"Visible";case"wireframe":return"Wireframe"}return e}function gn(e){const n=e.toLowerCase();return n.search("intensity")>-1||n==="anisotropyrotation"||n==="blendalpha"||n==="bumpscale"||n==="clearcoatroughness"||n==="displacementbias"||n==="displacementscale"||n==="metalness"||n==="opacity"||n==="reflectivity"||n==="refractionratio"||n==="roughness"||n==="sheenroughness"||n==="thickness"}function Kn(){const e=document.createElement("input");return e.type="file",new Promise((n,a)=>{e.addEventListener("change",function(){if(e.files===null)a();else{const t=e.files[0],i=new FileReader;i.onload=function(o){n(o.target.result)},i.readAsDataURL(t)}}),e.click()})}const Xn=[{title:"Front",value:h.FrontSide},{title:"Back",value:h.BackSide},{title:"Double",value:h.DoubleSide}],Zn=[{title:"No Blending",value:h.NoBlending},{title:"Normal",value:h.NormalBlending},{title:"Additive",value:h.AdditiveBlending},{title:"Subtractive",value:h.SubtractiveBlending},{title:"Multiply",value:h.MultiplyBlending},{title:"Custom",value:h.CustomBlending}],Jn=[{title:"Add",value:h.AddEquation},{title:"Subtract",value:h.SubtractEquation},{title:"Reverse Subtract",value:h.ReverseSubtractEquation},{title:"Min",value:h.MinEquation},{title:"Max",value:h.MaxEquation}],Qn=[{title:"Zero",valye:h.ZeroFactor},{title:"One",valye:h.OneFactor},{title:"Src Color",valye:h.SrcColorFactor},{title:"One Minus Src Color",valye:h.OneMinusSrcColorFactor},{title:"Src Alpha",valye:h.SrcAlphaFactor},{title:"One Minus Src Alpha",valye:h.OneMinusSrcAlphaFactor},{title:"Dst Alpha",valye:h.DstAlphaFactor},{title:"One Minus Dst Alpha",valye:h.OneMinusDstAlphaFactor},{title:"Dst Color",valye:h.DstColorFactor},{title:"One Minus Dst Color",valye:h.OneMinusDstColorFactor},{title:"Src Alpha Saturate",valye:h.SrcAlphaSaturateFactor},{title:"Constant Color",valye:h.ConstantColorFactor},{title:"One Minus Constant Color",valye:h.OneMinusConstantColorFactor},{title:"Constant Alpha",valye:h.ConstantAlphaFactor},{title:"One Minus Constant Alpha",valye:h.OneMinusConstantAlphaFactor}],ea=[{title:"Zero",valye:h.ZeroFactor},{title:"One",valye:h.OneFactor},{title:"Src Color",valye:h.SrcColorFactor},{title:"One Minus Src Color",valye:h.OneMinusSrcColorFactor},{title:"Src Alpha",valye:h.SrcAlphaFactor},{title:"One Minus Src Alpha",valye:h.OneMinusSrcAlphaFactor},{title:"Dst Alpha",valye:h.DstAlphaFactor},{title:"One Minus Dst Alpha",valye:h.OneMinusDstAlphaFactor},{title:"Dst Color",valye:h.DstColorFactor},{title:"One Minus Dst Color",valye:h.OneMinusDstColorFactor},{title:"Constant Color",valye:h.ConstantColorFactor},{title:"One Minus Constant Color",valye:h.OneMinusConstantColorFactor},{title:"Constant Alpha",valye:h.ConstantAlphaFactor},{title:"One Minus Constant Alpha",valye:h.OneMinusConstantAlphaFactor}];function ct(e,n){e.needsUpdate=!0,e.type="option",e.options=n}function ta(e,n,a,t){return{type:"boolean",title:Tt(e),prop:e,value:n,needsUpdate:!0,onChange:(i,o)=>{t.updateObject(a.uuid,`material.${e}`,o),t.updateObject(a.uuid,"material.needsUpdate",!0);const l=t.getScene(a.uuid);if(l!==null){const s=l.getObjectByProperty("uuid",a.uuid);Q(s,`material.${e}`,o)}}}}function na(e,n,a,t){const i={type:"number",title:Tt(e),prop:e,value:n,min:void 0,max:void 0,step:.01,needsUpdate:!0,onChange:(o,l)=>{t.updateObject(a.uuid,`material.${e}`,l),t.updateObject(a.uuid,"material.needsUpdate",!0);const s=t.getScene(a.uuid);if(s!==null){const f=s.getObjectByProperty("uuid",a.uuid);Q(f,`material.${e}`,l)}}};switch(e){case"blending":ct(i,Zn);break;case"blendDst":ct(i,ea);break;case"blendEquation":ct(i,Jn);break;case"blendSrc":ct(i,Qn);break;case"side":ct(i,Xn);break}return gn(e)&&(i.value=Number(n),i.type="range",i.min=Math.min(0,i.value),i.max=Math.max(1,i.value),i.step=.01),i}function aa(e,n,a,t){const i={type:"string",title:Tt(e),prop:e,value:n,needsUpdate:!0,onChange:(l,s)=>{t.updateObject(a.uuid,`material.${e}`,s),t.updateObject(a.uuid,"material.needsUpdate",!0);const f=t.getScene(a.uuid);if(f!==null){const d=f.getObjectByProperty("uuid",a.uuid);Q(d,`material.${e}`,s)}},onKeyDown:l=>{}};return(e==="vertexShader"||e==="fragmentShader")&&(i.disabled=!1,i.latest=i.value,i.onChange=(l,s)=>{i.latest=s,t.updateObject(a.uuid,`material.${e}`,s);const f=t.getScene(a.uuid);if(f!==null){const d=f.getObjectByProperty("uuid",a.uuid);Q(d,`material.${e}`,s)}},i.onKeyDown=l=>{if(l.key==="Enter"&&(l.altKey||l.metaKey)){t.updateObject(a.uuid,"material.needsUpdate",!0);const s=t.getScene(a.uuid);if(s!==null){const f=s.getObjectByProperty("uuid",a.uuid);Q(f,"material.needsUpdate",!0)}}}),i}function ia(e){return e.x!==void 0&&e.y!==void 0&&e.z===void 0}function ra(e){return e.x!==void 0&&e.y!==void 0&&e.z!==void 0&&e.w===void 0}function sa(e){return e.x!==void 0&&e.y!==void 0&&e.z!==void 0&&e.w!==void 0}function Vt(e){e.sort((n,a)=>n.title<a.title?-1:n.title>a.title?1:0)}function lt(e,n,a,t,i="",o=!1){const l=Tt(e).split(".")[0].replaceAll("[","").replaceAll("]",""),s=i.length>0?`${i}.${e}`:e,f=typeof n;if(f==="boolean"||f==="string")return{title:l,prop:s,type:f,value:n,disabled:o,onChange:(d,m)=>{t.updateObject(a.uuid,`material.${s}`,m);const y=t.getScene(a.uuid);if(y!==null){const E=y.getObjectByProperty("uuid",a.uuid);Q(E,`material.${s}`,m)}}};if(f==="number"){const d={title:l,prop:s,type:"number",value:n,step:.01,disabled:o,onChange:(m,y)=>{t.updateObject(a.uuid,`material.${s}`,y);const E=t.getScene(a.uuid);if(E!==null){const C=E.getObjectByProperty("uuid",a.uuid);Q(C,`material.${s}`,y)}}};return gn(l)&&(d.type="range",d.min=0,d.max=1),d}else{if(n.isColor)return{title:l,prop:s,type:"color",value:n,disabled:o,onChange:(d,m)=>{const y=new h.Color(m);t.updateObject(a.uuid,`material.${s}`,y);const E=t.getScene(a.uuid);if(E!==null){const C=E.getObjectByProperty("uuid",a.uuid);Q(C,`material.${s}`,y)}}};if(Array.isArray(n)){const d=[];for(const m in n){const y=n[m],E=`[${m.toString()}]`;if(y.value!==void 0){const C=lt(`${E}.value`,y.value,a,t,s,o);C!==void 0&&d.push(C)}else{const C=lt(E,y,a,t,s,o);C!==void 0&&d.push(C)}}if(d.length>0)return Vt(d),{title:l,items:d}}else{if(ia(n))return{title:l,prop:s,type:"vector2",value:n,disabled:o,onChange:(d,m)=>{t.updateObject(a.uuid,`material.${s}`,m);const y=t.getScene(a.uuid);if(y!==null){const E=y.getObjectByProperty("uuid",a.uuid);Q(E,`material.${s}`,m)}}};if(ra(n))return{title:l,prop:s,type:"grid3",value:n,disabled:o,onChange:(d,m)=>{t.updateObject(a.uuid,`material.${s}`,m);const y=t.getScene(a.uuid);if(y!==null){const E=y.getObjectByProperty("uuid",a.uuid);Q(E,`material.${s}`,m)}}};if(sa(n))return{title:l,prop:s,type:"grid4",value:n,disabled:o,onChange:(d,m)=>{t.updateObject(a.uuid,`material.${s}`,m);const y=t.getScene(a.uuid);if(y!==null){const E=y.getObjectByProperty("uuid",a.uuid);Q(E,`material.${s}`,m)}}};if(n.isEuler)return{title:l,prop:s,type:"euler",value:n,disabled:o,onChange:(d,m)=>{t.updateObject(a.uuid,`material.${s}`,m);const y=t.getScene(a.uuid);if(y!==null){const E=y.getObjectByProperty("uuid",a.uuid);Q(E,`material.${s}`,m)}}};if(n.src!==void 0)return{title:l,type:"image",value:n,disabled:o,onChange:(d,m)=>{const y=qn(e),E=i.length>0?`${i}.${y}`:y;t.createTexture(a.uuid,`material.${E}`,m);const C=t.getScene(a.uuid);if(C!==null){const I=C.getObjectByProperty("uuid",a.uuid);if(I!==void 0){const K=z=>{const H=I.material,O=E.split(".");switch(O.length){case 1:H[O[0]]=z;break;case 2:H[O[0]][O[1]]=z;break;case 3:H[O[0]][O[1]][O[2]]=z;break;case 4:H[O[0]][O[1]][O[2]][O[3]]=z;break;case 5:H[O[0]][O[1]][O[2]][O[3]][O[4]]=z;break}H.needsUpdate=!0};m.src.length>0?dn(m.src).then(z=>{z.offset.set(m.offset[0],m.offset[1]),z.repeat.set(m.repeat[0],m.repeat[1]),K(z)}):K(null)}}}};if(n.elements!==void 0)return{title:l,prop:s,type:n.elements.length>9?"grid4":"grid3",value:n,disabled:o,onChange:(d,m)=>{t.updateObject(a.uuid,`material.${s}`,m);const y=t.getScene(a.uuid);if(y!==null){const E=y.getObjectByProperty("uuid",a.uuid);Q(E,`material.${s}`,m)}}};{const d=[],m=e==="defines"||e==="extensions";try{for(const y in n){const E=n[y];if(E!==void 0)if(E.value!==void 0){const C=lt(`${y}.value`,E.value,a,t,s,m);C!==void 0&&d.push(C)}else{const C=lt(y,E,a,t,s,m);C!==void 0&&d.push(C)}}}catch{console.log("Issue cycling through material object:",e,n)}if(d.length>0)return Vt(d),{title:l,items:d}}}}}function Xt(e,n,a){const t=[];for(const i in e){if(!Yn(i))continue;const o=typeof e[i],l=e[i];if(o==="boolean")t.push(ta(i,l,n,a));else if(o==="number")t.push(na(i,l,n,a));else if(o==="string")t.push(aa(i,l,n,a));else if(o==="object"){const s=lt(i,l,n,a);s!==void 0&&t.push(s)}else l!==void 0&&console.log("other:",i,o,l)}return Vt(t),t.push({title:"Update Material",type:"button",onChange:()=>{a.updateObject(n.uuid,"material.needsUpdate",!0);const i=a.getScene(n.uuid);if(i!==null){const o=i.getObjectByProperty("uuid",n.uuid);Q(o,"material.needsUpdate",!0)}}}),t}function oa(e,n){const a=e.material;if(Array.isArray(a)){const t=[],i=a.length;for(let o=0;o<i;o++)t.push(u.jsx(Ye,{title:`Material ${o}`,items:Xt(a[o],e,n)},`Material ${o}`));return u.jsx(u.Fragment,{children:t})}else return u.jsx(Ye,{title:"Material",items:Xt(a,e,n)})}const Zt="data:image/gif;base64,R0lGODlhDgFkAIAAAP///wAAACH/C1hNUCBEYXRhWE1QPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgOS4xLWMwMDIgNzkuZGJhM2RhM2I1LCAyMDIzLzEyLzE1LTEwOjQyOjM3ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgMjUuNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDoyMDk3M0NEODAxQjQxMUVGODVGNENDMkUyMUExNDk1NSIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDoyMDk3M0NEOTAxQjQxMUVGODVGNENDMkUyMUExNDk1NSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkE4ODc3Qzg5MDFCMzExRUY4NUY0Q0MyRTIxQTE0OTU1IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkE4ODc3QzhBMDFCMzExRUY4NUY0Q0MyRTIxQTE0OTU1Ii8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+Af/+/fz7+vn49/b19PPy8fDv7u3s6+rp6Ofm5eTj4uHg397d3Nva2djX1tXU09LR0M/OzczLysnIx8bFxMPCwcC/vr28u7q5uLe2tbSzsrGwr66trKuqqainpqWko6KhoJ+enZybmpmYl5aVlJOSkZCPjo2Mi4qJiIeGhYSDgoGAf359fHt6eXh3dnV0c3JxcG9ubWxramloZ2ZlZGNiYWBfXl1cW1pZWFdWVVRTUlFQT05NTEtKSUhHRkVEQ0JBQD8+PTw7Ojk4NzY1NDMyMTAvLi0sKyopKCcmJSQjIiEgHx4dHBsaGRgXFhUUExIREA8ODQwLCgkIBwYFBAMCAQAAIfkEAAAAAAAsAAAAAA4BZAAAAv+Mj6nL7Q+jnLTai7PevPsPhuJIluaJpurKtu4Lx/JM1/aN5/rO9/4PDAqHxKLxiEwql8ym8wmNSqfUqvWKzWq33K73Cw6Lx+Sy+YxOq9fstvsNj8vn9Lr9js/r9/y+/w8YKDhIWGh4iJiouMjY6PgIGSk5SVlpeYmZqTkJAGDQ+dnpuekmGgAKejpKuiZqmprKqoZKGyrbOlqrejub6xvLGyw8TFzcprurGuvqybxq7ETbrItsCz0l7Zpc+6p9/cS967w9/S2FTF0u/mzehK4Oqz3eTl9vf4+fr7/P3+//DzCgwIEECxo8iDChwoUMGzp8CDGixIkUK1q8iDGjxo0XHDt6/AgypMiRJEuaPIkypcqVLFt+KwAAOw==";function ca(e){const n=e.step!==void 0?e.step:.01,a=b.useRef(null),t=b.useRef(null),i=b.useRef(null),o=b.useRef(null),l=b.useRef(null),[s]=b.useState(e.value),[f,d]=b.useState(e.value.offset[0]),[m,y]=b.useState(e.value.offset[1]),[E,C]=b.useState(e.value.repeat[0]),[I,K]=b.useState(e.value.repeat[1]);function z(O,V,k,Z,se){if(e.onChange!==void 0){const w=e.prop!==void 0?e.prop:e.title;e.onChange(w,{src:O,offset:[V,k],repeat:[Z,se]})}}function H(O){const V=a.current.src,k=O.target.value;switch(O.target){case t.current:d(k),z(V,k,m,E,I);break;case i.current:y(k),z(V,f,k,E,I);break;case o.current:C(k),z(V,f,m,k,I);break;case l.current:K(k),z(V,f,m,E,k);break}}return u.jsxs("div",{className:"imageField",children:[u.jsx("img",{alt:e.title,ref:a,onClick:()=>{Kn().then(O=>{a.current.src=O,z(O,f,m,E,I)})},src:s.src.length>0?s.src:Zt}),u.jsxs("div",{className:"fields",children:[u.jsxs("div",{children:[u.jsx("label",{children:"Offset:"}),u.jsx("input",{ref:t,type:"number",value:f,step:n,onChange:H}),u.jsx("input",{ref:i,type:"number",value:m,step:n,onChange:H})]}),u.jsxs("div",{children:[u.jsx("label",{children:"Repeat:"}),u.jsx("input",{ref:o,type:"number",value:E,step:n,onChange:H}),u.jsx("input",{ref:l,type:"number",value:I,step:n,onChange:H})]}),u.jsx("button",{onClick:()=>{z("",f,m,E,I),a.current.src=Zt},children:"Clear"})]})]})}function Ct(e){let n=e.value;n!==void 0&&n.isColor!==void 0&&(n=ln(e.value));const[a,t]=b.useState(n),i=b.useRef(null),o=d=>{let m=d.target.value;e.type==="boolean"?m=d.target.checked:e.type==="option"&&(m=e.options[m].value),t(m),e.onChange!==void 0&&e.onChange(e.prop!==void 0?e.prop:e.title,m)},l={};e.disabled&&(l.opacity=.8);const s=e.type==="string"&&(a.length>100||a.search(`
|
30
|
-
`)>-1),f=s||e.type==="image"||e.type==="vector2";return u.jsxs("div",{className:`field ${f?"block":""}`,style:l,children:[e.type!=="button"&&u.jsx("label",{ref:i,children:dt(e.title)},"fieldLabel"),e.type==="string"&&!s&&u.jsx("input",{type:"text",disabled:e.disabled,onChange:o,value:a}),e.type==="string"&&s&&u.jsx("textarea",{cols:50,rows:10,disabled:e.disabled!==void 0?e.disabled:!0,onChange:o,onKeyDown:d=>{e.onKeyDown!==void 0&&e.onKeyDown(d)},value:a}),e.type==="boolean"&&u.jsx("input",{type:"checkbox",disabled:e.disabled,onChange:o,checked:a}),e.type==="number"&&u.jsx(We,{value:a,type:e.type,prop:e.prop!==void 0?e.prop:e.title,min:e.min,max:e.max,step:e.step,disabled:e.disabled,labelRef:i,onChange:e.onChange}),e.type==="range"&&u.jsx(We,{value:a,type:e.type,prop:e.prop!==void 0?e.prop:e.title,min:e.min,max:e.max,step:e.step,disabled:e.disabled,labelRef:i,onChange:e.onChange}),e.type==="color"&&u.jsxs(u.Fragment,{children:[u.jsx("input",{type:"text",value:a.toString(),onChange:o,disabled:e.disabled,className:"color"}),u.jsx("input",{type:"color",value:a,onChange:o,disabled:e.disabled})]}),e.type==="button"&&u.jsx("button",{disabled:e.disabled,onClick:()=>{e.onChange!==void 0&&e.onChange(e.prop!==void 0?e.prop:e.title,!0)},children:e.title}),e.type==="image"&&u.jsx(ca,{title:e.title,prop:e.prop,value:e.value,onChange:e.onChange}),e.type==="option"&&u.jsx(u.Fragment,{children:u.jsx("select",{onChange:o,disabled:e.disabled,defaultValue:e.value,children:e.options?.map((d,m)=>u.jsx("option",{value:d.value,children:dt(d.title)},m))})}),e.type==="vector2"&&u.jsx(Gn,{step:e.step,value:a,min:0,max:1,onChange:o}),e.type==="grid3"&&u.jsx(Kt,{step:e.step,value:a,onChange:o}),e.type==="grid4"&&u.jsx(Hn,{step:e.step,value:a,onChange:o}),e.type==="euler"&&u.jsx(Kt,{step:e.step,value:a,onChange:o})]})}function Jt(e){switch(e){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 e}function la(e,n){const a=[];if(e.perspectiveCameraInfo!==void 0)for(const t in e.perspectiveCameraInfo)a.push({title:Jt(t),prop:t,type:"number",step:.01,value:e.perspectiveCameraInfo[t],onChange:(i,o)=>{n.updateObject(e.uuid,i,o),n.requestMethod(e.uuid,"updateProjectionMatrix");const l=n.getScene(e.uuid);if(l!==null){const s=l.getObjectByProperty("uuid",e.uuid);s!==void 0&&(Q(s,i,o),s.updateProjectionMatrix())}}});else if(e.orthographicCameraInfo!==void 0)for(const t in e.orthographicCameraInfo)a.push({title:Jt(t),prop:t,type:"number",step:.01,value:e.perspectiveCameraInfo[t],onChange:(i,o)=>{n.updateObject(e.uuid,i,o),n.requestMethod(e.uuid,"updateProjectionMatrix");const l=n.getScene(e.uuid);if(l!==null){const s=l.getObjectByProperty("uuid",e.uuid);s!==void 0&&(Q(s,i,o),s.updateProjectionMatrix())}}});return u.jsx(Ye,{title:"Camera",items:a})}function ua(e,n){const a=new h.Matrix4;a.elements=e.matrix;const t=new h.Vector3,i=new h.Euler,o=new h.Vector3;e.uuid.length>0&&(t.setFromMatrixPosition(a),i.setFromRotationMatrix(a),o.setFromMatrixScale(a));const l=(s,f)=>{const d=s==="rotation"?{x:f._x,y:f._y,z:f._z}:f;n.updateObject(e.uuid,s,d);const m=n.getScene(e.uuid);if(m!==null){const y=m.getObjectByProperty("uuid",e.uuid);Q(y,s,d)}};return u.jsx(Ye,{title:"Transform",items:[{title:"Position",prop:"position",type:"grid3",step:.1,value:t,onChange:l},{title:"Rotation",prop:"rotation",type:"grid3",value:i,onChange:l},{title:"Scale",prop:"scale",type:"grid3",value:o,onChange:l}]})}function Qt(e){switch(e){case"color":return"Color";case"intensity":return"Intensity";case"decay":return"Decay";case"distance":return"Distance";case"angle":return"Angle";case"penumbra":return"Penumbra";case"groundColor":return"Ground Color";case"width":return"Width";case"height":return"Height"}return e}function da(e,n){const a=[];if(e.lightInfo!==void 0)for(const t in e.lightInfo){const i=e.lightInfo[t];i!==void 0&&(i.isColor!==void 0?a.push({title:Qt(t),prop:t,type:"color",value:i,onChange:(o,l)=>{const s=new h.Color(l);n.updateObject(e.uuid,o,s);const f=n.getScene(e.uuid);if(f!==null){const d=f.getObjectByProperty("uuid",e.uuid);Q(d,o,s)}}}):a.push({title:Qt(t),prop:t,type:typeof i,value:i,step:typeof i=="number"?.01:void 0,onChange:(o,l)=>{n.updateObject(e.uuid,o,l);const s=n.getScene(e.uuid);if(s!==null){const f=s.getObjectByProperty("uuid",e.uuid);Q(f,o,l)}}}))}return u.jsx(Ye,{title:"Light",items:a})}function ha(e,n){const a=[],t=[];let i=0;e.animations.forEach(l=>{i=Math.max(i,l.duration),l.duration>0&&t.push({title:l.name,items:[{title:"Duration",type:"number",value:l.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),a.push({title:"Animations",items:t});const o=n.getScene(e.uuid);if(o!==null){const l=o.getObjectByProperty("uuid",e.uuid);let s=!1;if(l!==void 0){const f=l.mixer;if(s=f!==void 0,s){const d=[{title:"Time Scale",type:"range",value:f.timeScale,step:.01,min:-1,max:2,onChange:(m,y)=>{f.timeScale=y,n.updateObject(e.uuid,"mixer.timeScale",y)}}];d.push({title:"Stop All",type:"button",onChange:()=>{f.stopAllAction(),n.requestMethod(e.uuid,"stopAllAction",void 0,"mixer")}}),a.push({title:"Mixer",items:d})}}}return u.jsx(Ye,{title:"Animation",items:a})}const vn={name:"",uuid:"",type:"",visible:!1,matrix:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};let pe={...vn};function bn(e){const[n,a]=b.useState(-1);b.useEffect(()=>{function l(f){pe={...f.value},a(Date.now())}function s(){pe={...vn},a(Date.now())}return D.addEventListener(A.SET_SCENE,s),D.addEventListener(A.SET_OBJECT,l),()=>{D.removeEventListener(A.SET_SCENE,s),D.removeEventListener(A.SET_OBJECT,l)}},[]);const t=pe.type.toLowerCase(),i=pe.animations.length>0||pe.mixer!==void 0,o=t.search("mesh")>-1||t.search("line")>-1||t.search("points")>-1;return u.jsx(ft,{label:"Inspector",children:u.jsx("div",{id:"Inspector",className:e.class,children:pe.uuid.length>0&&u.jsxs(u.Fragment,{children:[u.jsxs(u.Fragment,{children:[u.jsx(Ct,{type:"string",title:"Name",prop:"name",value:pe.name,disabled:!0}),u.jsx(Ct,{type:"string",title:"Type",prop:"type",value:pe.type,disabled:!0}),u.jsx(Ct,{type:"string",title:"UUID",prop:"uuid",value:pe.uuid,disabled:!0})]}),u.jsxs(u.Fragment,{children:[ua(pe,e.three),i?ha(pe,e.three):null,t.search("camera")>-1?la(pe,e.three):null,t.search("light")>-1?da(pe,e.three):null,o?oa(pe,e.three):null]})]})},n)},"Inspector")}function fa(e){const[n]=b.useState([]),[a]=b.useState([]),[t,i]=b.useState(0),o=f=>{const d=f.value;n.push(d),a.push(u.jsx(ft,{label:`Scene: ${d.name}`,scene:d,open:!0,onRefresh:()=>{e.three.refreshScene(d.name)},children:u.jsx(Ut,{child:d,scene:d,three:e.three})},Math.random())),i(Date.now())},l=f=>{const d=f.value;for(let m=0;m<n.length;m++)if(d.uuid===n[m].uuid){n[m]=d,a[m]=u.jsx(ft,{label:`Scene: ${d.name}`,scene:d,open:!0,onRefresh:()=>{e.three.refreshScene(d.name)},children:u.jsx(Ut,{child:d,scene:d,three:e.three})},Math.random()),i(Date.now());return}},s=f=>{const d=f.value;for(let m=0;m<n.length;m++)if(d.uuid===n[m].uuid){n.splice(m,1),a.splice(m,1),i(Date.now());return}};return b.useEffect(()=>(D.addEventListener(A.ADD_SCENE,o),D.addEventListener(A.REFRESH_SCENE,l),D.addEventListener(A.REMOVE_SCENE,s),()=>{D.removeEventListener(A.ADD_SCENE,o),D.removeEventListener(A.REFRESH_SCENE,l),D.removeEventListener(A.REMOVE_SCENE,s)}),[]),u.jsxs("div",{id:"SidePanel",children:[u.jsx("div",{children:a},t),u.jsx(bn,{three:e.three})]})}function ma(e){return b.useEffect(()=>{function n(s){let f=null;return e.three.scenes.forEach(d=>{s.search(d.uuid)>-1&&(f=d)}),f}const a=s=>{const f=s.value,m=n(f)?.getObjectByProperty("uuid",f);m!==void 0&&e.three.setObject(m)},t=(s,f,d)=>{const y=n(s)?.getObjectByProperty("uuid",s);y!==void 0&&Q(y,f,d)},i=s=>{const f=s.value,{key:d,value:m,uuid:y}=f;t(y,d,m)},o=s=>{const f=s.value,m=n(f.uuid)?.getObjectByProperty("uuid",f.uuid);if(m!==void 0){const y=E=>{const C=f.key.split(".");switch(C.length){case 1:m[C[0]]=E;break;case 2:m[C[0]][C[1]]=E;break;case 3:m[C[0]][C[1]][C[2]]=E;break;case 4:m[C[0]][C[1]][C[2]][C[3]]=E;break;case 5:m[C[0]][C[1]][C[2]][C[3]][C[4]]=E;break}m.material.needsUpdate=!0};f.value.src.length>0?dn(f.value.src).then(E=>{E.offset.set(f.value.offset[0],f.value.offset[1]),E.repeat.set(f.value.repeat[0],f.value.repeat[1]),y(E)}):y(null)}},l=s=>{const{key:f,uuid:d,value:m,subitem:y}=s.value,C=n(d)?.getObjectByProperty("uuid",d);if(C!==void 0)try{y!==void 0?In(C,y)[f](m):C[f](m)}catch(I){console.log("Error requesting method:"),console.log(I),console.log(f),console.log(m)}};return D.addEventListener(A.GET_OBJECT,a),D.addEventListener(A.UPDATE_OBJECT,i),D.addEventListener(A.CREATE_TEXTURE,o),D.addEventListener(A.REQUEST_METHOD,l),()=>{D.removeEventListener(A.GET_OBJECT,a),D.removeEventListener(A.UPDATE_OBJECT,i),D.removeEventListener(A.CREATE_TEXTURE,o),D.removeEventListener(A.REQUEST_METHOD,l)}},[]),null}class pa extends h.Line{constructor(n,a){const t=[1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],i=new h.BufferGeometry;i.setAttribute("position",new h.Float32BufferAttribute(t,3)),i.computeBoundingSphere();const o=new h.LineBasicMaterial({fog:!1});super(i,o),this.light=n,this.color=a,this.type="RectAreaLightHelper";const l=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],s=new h.BufferGeometry;s.setAttribute("position",new h.Float32BufferAttribute(l,3)),s.computeBoundingSphere(),this.add(new h.Mesh(s,new h.MeshBasicMaterial({side:h.BackSide,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),this.color!==void 0)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const n=this.material.color,a=Math.max(n.r,n.g,n.b);a>1&&n.multiplyScalar(1/a),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const en={type:"change"},Pt={type:"start"},tn={type:"end"},St=new h.Ray,nn=new h.Plane,ga=Math.cos(70*h.MathUtils.DEG2RAD);class va extends h.EventDispatcher{constructor(n,a){super(),this.object=n,this.domElement=a,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new h.Vector3,this.cursor=new h.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT: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(c){c.addEventListener("keydown",it),this._domElementKeyEvents=c},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",it),this._domElementKeyEvents=null},this.saveState=function(){t.target0.copy(t.target),t.position0.copy(t.object.position),t.zoom0=t.object.zoom},this.reset=function(){t.target.copy(t.target0),t.object.position.copy(t.position0),t.object.zoom=t.zoom0,t.object.updateProjectionMatrix(),t.dispatchEvent(en),t.update(),o=i.NONE},this.update=function(){const c=new h.Vector3,x=new h.Quaternion().setFromUnitVectors(n.up,new h.Vector3(0,1,0)),j=x.clone().invert(),U=new h.Vector3,ie=new h.Quaternion,Ee=new h.Vector3,de=2*Math.PI;return function(bt=null){const yt=t.object.position;c.copy(yt).sub(t.target),c.applyQuaternion(x),s.setFromVector3(c),t.autoRotate&&o===i.NONE&&_e(tt(bt)),t.enableDamping?(s.theta+=f.theta*t.dampingFactor,s.phi+=f.phi*t.dampingFactor):(s.theta+=f.theta,s.phi+=f.phi);let Se=t.minAzimuthAngle,xe=t.maxAzimuthAngle;isFinite(Se)&&isFinite(xe)&&(Se<-Math.PI?Se+=de:Se>Math.PI&&(Se-=de),xe<-Math.PI?xe+=de:xe>Math.PI&&(xe-=de),Se<=xe?s.theta=Math.max(Se,Math.min(xe,s.theta)):s.theta=s.theta>(Se+xe)/2?Math.max(Se,s.theta):Math.min(xe,s.theta)),s.phi=Math.max(t.minPolarAngle,Math.min(t.maxPolarAngle,s.phi)),s.makeSafe(),t.enableDamping===!0?t.target.addScaledVector(m,t.dampingFactor):t.target.add(m),t.target.sub(t.cursor),t.target.clampLength(t.minTargetRadius,t.maxTargetRadius),t.target.add(t.cursor);let Ge=!1;if(t.zoomToCursor&&se||t.object.isOrthographicCamera)s.radius=Ie(s.radius);else{const Re=s.radius;s.radius=Ie(s.radius*d),Ge=Re!=s.radius}if(c.setFromSpherical(s),c.applyQuaternion(j),yt.copy(t.target).add(c),t.object.lookAt(t.target),t.enableDamping===!0?(f.theta*=1-t.dampingFactor,f.phi*=1-t.dampingFactor,m.multiplyScalar(1-t.dampingFactor)):(f.set(0,0,0),m.set(0,0,0)),t.zoomToCursor&&se){let Re=null;if(t.object.isPerspectiveCamera){const Ue=c.length();Re=Ie(Ue*d);const Ke=Ue-Re;t.object.position.addScaledVector(k,Ke),t.object.updateMatrixWorld(),Ge=!!Ke}else if(t.object.isOrthographicCamera){const Ue=new h.Vector3(Z.x,Z.y,0);Ue.unproject(t.object);const Ke=t.object.zoom;t.object.zoom=Math.max(t.minZoom,Math.min(t.maxZoom,t.object.zoom/d)),t.object.updateProjectionMatrix(),Ge=Ke!==t.object.zoom;const Et=new h.Vector3(Z.x,Z.y,0);Et.unproject(t.object),t.object.position.sub(Et).add(Ue),t.object.updateMatrixWorld(),Re=c.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),t.zoomToCursor=!1;Re!==null&&(this.screenSpacePanning?t.target.set(0,0,-1).transformDirection(t.object.matrix).multiplyScalar(Re).add(t.object.position):(St.origin.copy(t.object.position),St.direction.set(0,0,-1).transformDirection(t.object.matrix),Math.abs(t.object.up.dot(St.direction))<ga?n.lookAt(t.target):(nn.setFromNormalAndCoplanarPoint(t.object.up,t.target),St.intersectPlane(nn,t.target))))}else if(t.object.isOrthographicCamera){const Re=t.object.zoom;t.object.zoom=Math.max(t.minZoom,Math.min(t.maxZoom,t.object.zoom/d)),Re!==t.object.zoom&&(t.object.updateProjectionMatrix(),Ge=!0)}return d=1,se=!1,Ge||U.distanceToSquared(t.object.position)>l||8*(1-ie.dot(t.object.quaternion))>l||Ee.distanceToSquared(t.target)>l?(t.dispatchEvent(en),U.copy(t.object.position),ie.copy(t.object.quaternion),Ee.copy(t.target),!0):!1}}(),this.dispose=function(){t.domElement.removeEventListener("contextmenu",qe),t.domElement.removeEventListener("pointerdown",F),t.domElement.removeEventListener("pointercancel",$),t.domElement.removeEventListener("wheel",ue),t.domElement.removeEventListener("pointermove",te),t.domElement.removeEventListener("pointerup",$),t.domElement.getRootNode().removeEventListener("keydown",at,{capture:!0}),t._domElementKeyEvents!==null&&(t._domElementKeyEvents.removeEventListener("keydown",it),t._domElementKeyEvents=null)};const t=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let o=i.NONE;const l=1e-6,s=new h.Spherical,f=new h.Spherical;let d=1;const m=new h.Vector3,y=new h.Vector2,E=new h.Vector2,C=new h.Vector2,I=new h.Vector2,K=new h.Vector2,z=new h.Vector2,H=new h.Vector2,O=new h.Vector2,V=new h.Vector2,k=new h.Vector3,Z=new h.Vector2;let se=!1;const w=[],ge={};let Y=!1;function tt(c){return c!==null?2*Math.PI/60*t.autoRotateSpeed*c:2*Math.PI/60/60*t.autoRotateSpeed}function P(c){const x=Math.abs(c*.01);return Math.pow(.95,t.zoomSpeed*x)}function _e(c){f.theta-=c}function oe(c){f.phi-=c}const ve=function(){const c=new h.Vector3;return function(j,U){c.setFromMatrixColumn(U,0),c.multiplyScalar(-j),m.add(c)}}(),we=function(){const c=new h.Vector3;return function(j,U){t.screenSpacePanning===!0?c.setFromMatrixColumn(U,1):(c.setFromMatrixColumn(U,0),c.crossVectors(t.object.up,c)),c.multiplyScalar(j),m.add(c)}}(),be=function(){const c=new h.Vector3;return function(j,U){const ie=t.domElement;if(t.object.isPerspectiveCamera){const Ee=t.object.position;c.copy(Ee).sub(t.target);let de=c.length();de*=Math.tan(t.object.fov/2*Math.PI/180),ve(2*j*de/ie.clientHeight,t.object.matrix),we(2*U*de/ie.clientHeight,t.object.matrix)}else t.object.isOrthographicCamera?(ve(j*(t.object.right-t.object.left)/t.object.zoom/ie.clientWidth,t.object.matrix),we(U*(t.object.top-t.object.bottom)/t.object.zoom/ie.clientHeight,t.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),t.enablePan=!1)}}();function Me(c){t.object.isPerspectiveCamera||t.object.isOrthographicCamera?d/=c:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),t.enableZoom=!1)}function Ne(c){t.object.isPerspectiveCamera||t.object.isOrthographicCamera?d*=c:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),t.enableZoom=!1)}function Pe(c,x){if(!t.zoomToCursor)return;se=!0;const j=t.domElement.getBoundingClientRect(),U=c-j.left,ie=x-j.top,Ee=j.width,de=j.height;Z.x=U/Ee*2-1,Z.y=-(ie/de)*2+1,k.set(Z.x,Z.y,1).unproject(t.object).sub(t.object.position).normalize()}function Ie(c){return Math.max(t.minDistance,Math.min(t.maxDistance,c))}function ze(c){y.set(c.clientX,c.clientY)}function Le(c){Pe(c.clientX,c.clientX),H.set(c.clientX,c.clientY)}function ee(c){I.set(c.clientX,c.clientY)}function Oe(c){E.set(c.clientX,c.clientY),C.subVectors(E,y).multiplyScalar(t.rotateSpeed);const x=t.domElement;_e(2*Math.PI*C.x/x.clientHeight),oe(2*Math.PI*C.y/x.clientHeight),y.copy(E),t.update()}function nt(c){O.set(c.clientX,c.clientY),V.subVectors(O,H),V.y>0?Me(P(V.y)):V.y<0&&Ne(P(V.y)),H.copy(O),t.update()}function $e(c){K.set(c.clientX,c.clientY),z.subVectors(K,I).multiplyScalar(t.panSpeed),be(z.x,z.y),I.copy(K),t.update()}function fe(c){Pe(c.clientX,c.clientY),c.deltaY<0?Ne(P(c.deltaY)):c.deltaY>0&&Me(P(c.deltaY)),t.update()}function p(c){let x=!1;switch(c.code){case t.keys.UP:c.ctrlKey||c.metaKey||c.shiftKey?oe(2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):be(0,t.keyPanSpeed),x=!0;break;case t.keys.BOTTOM:c.ctrlKey||c.metaKey||c.shiftKey?oe(-2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):be(0,-t.keyPanSpeed),x=!0;break;case t.keys.LEFT:c.ctrlKey||c.metaKey||c.shiftKey?_e(2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):be(t.keyPanSpeed,0),x=!0;break;case t.keys.RIGHT:c.ctrlKey||c.metaKey||c.shiftKey?_e(-2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):be(-t.keyPanSpeed,0),x=!0;break}x&&(c.preventDefault(),t.update())}function v(c){if(w.length===1)y.set(c.pageX,c.pageY);else{const x=Be(c),j=.5*(c.pageX+x.x),U=.5*(c.pageY+x.y);y.set(j,U)}}function T(c){if(w.length===1)I.set(c.pageX,c.pageY);else{const x=Be(c),j=.5*(c.pageX+x.x),U=.5*(c.pageY+x.y);I.set(j,U)}}function L(c){const x=Be(c),j=c.pageX-x.x,U=c.pageY-x.y,ie=Math.sqrt(j*j+U*U);H.set(0,ie)}function me(c){t.enableZoom&&L(c),t.enablePan&&T(c)}function le(c){t.enableZoom&&L(c),t.enableRotate&&v(c)}function R(c){if(w.length==1)E.set(c.pageX,c.pageY);else{const j=Be(c),U=.5*(c.pageX+j.x),ie=.5*(c.pageY+j.y);E.set(U,ie)}C.subVectors(E,y).multiplyScalar(t.rotateSpeed);const x=t.domElement;_e(2*Math.PI*C.x/x.clientHeight),oe(2*Math.PI*C.y/x.clientHeight),y.copy(E)}function M(c){if(w.length===1)K.set(c.pageX,c.pageY);else{const x=Be(c),j=.5*(c.pageX+x.x),U=.5*(c.pageY+x.y);K.set(j,U)}z.subVectors(K,I).multiplyScalar(t.panSpeed),be(z.x,z.y),I.copy(K)}function W(c){const x=Be(c),j=c.pageX-x.x,U=c.pageY-x.y,ie=Math.sqrt(j*j+U*U);O.set(0,ie),V.set(0,Math.pow(O.y/H.y,t.zoomSpeed)),Me(V.y),H.copy(O);const Ee=(c.pageX+x.x)*.5,de=(c.pageY+x.y)*.5;Pe(Ee,de)}function ae(c){t.enableZoom&&W(c),t.enablePan&&M(c)}function ye(c){t.enableZoom&&W(c),t.enableRotate&&R(c)}function F(c){t.enabled!==!1&&(w.length===0&&(t.domElement.setPointerCapture(c.pointerId),t.domElement.addEventListener("pointermove",te),t.domElement.addEventListener("pointerup",$)),!Dt(c)&&(_t(c),c.pointerType==="touch"?rt(c):ke(c)))}function te(c){t.enabled!==!1&&(c.pointerType==="touch"?gt(c):ce(c))}function $(c){switch(kt(c),w.length){case 0:t.domElement.releasePointerCapture(c.pointerId),t.domElement.removeEventListener("pointermove",te),t.domElement.removeEventListener("pointerup",$),t.dispatchEvent(tn),o=i.NONE;break;case 1:const x=w[0],j=ge[x];rt({pointerId:x,pageX:j.x,pageY:j.y});break}}function ke(c){let x;switch(c.button){case 0:x=t.mouseButtons.LEFT;break;case 1:x=t.mouseButtons.MIDDLE;break;case 2:x=t.mouseButtons.RIGHT;break;default:x=-1}switch(x){case h.MOUSE.DOLLY:if(t.enableZoom===!1)return;Le(c),o=i.DOLLY;break;case h.MOUSE.ROTATE:if(c.ctrlKey||c.metaKey||c.shiftKey){if(t.enablePan===!1)return;ee(c),o=i.PAN}else{if(t.enableRotate===!1)return;ze(c),o=i.ROTATE}break;case h.MOUSE.PAN:if(c.ctrlKey||c.metaKey||c.shiftKey){if(t.enableRotate===!1)return;ze(c),o=i.ROTATE}else{if(t.enablePan===!1)return;ee(c),o=i.PAN}break;default:o=i.NONE}o!==i.NONE&&t.dispatchEvent(Pt)}function ce(c){switch(o){case i.ROTATE:if(t.enableRotate===!1)return;Oe(c);break;case i.DOLLY:if(t.enableZoom===!1)return;nt(c);break;case i.PAN:if(t.enablePan===!1)return;$e(c);break}}function ue(c){t.enabled===!1||t.enableZoom===!1||o!==i.NONE||(c.preventDefault(),t.dispatchEvent(Pt),fe(pt(c)),t.dispatchEvent(tn))}function pt(c){const x=c.deltaMode,j={clientX:c.clientX,clientY:c.clientY,deltaY:c.deltaY};switch(x){case 1:j.deltaY*=16;break;case 2:j.deltaY*=100;break}return c.ctrlKey&&!Y&&(j.deltaY*=10),j}function at(c){c.key==="Control"&&(Y=!0,t.domElement.getRootNode().addEventListener("keyup",Fe,{passive:!0,capture:!0}))}function Fe(c){c.key==="Control"&&(Y=!1,t.domElement.getRootNode().removeEventListener("keyup",Fe,{passive:!0,capture:!0}))}function it(c){t.enabled===!1||t.enablePan===!1||p(c)}function rt(c){switch(vt(c),w.length){case 1:switch(t.touches.ONE){case h.TOUCH.ROTATE:if(t.enableRotate===!1)return;v(c),o=i.TOUCH_ROTATE;break;case h.TOUCH.PAN:if(t.enablePan===!1)return;T(c),o=i.TOUCH_PAN;break;default:o=i.NONE}break;case 2:switch(t.touches.TWO){case h.TOUCH.DOLLY_PAN:if(t.enableZoom===!1&&t.enablePan===!1)return;me(c),o=i.TOUCH_DOLLY_PAN;break;case h.TOUCH.DOLLY_ROTATE:if(t.enableZoom===!1&&t.enableRotate===!1)return;le(c),o=i.TOUCH_DOLLY_ROTATE;break;default:o=i.NONE}break;default:o=i.NONE}o!==i.NONE&&t.dispatchEvent(Pt)}function gt(c){switch(vt(c),o){case i.TOUCH_ROTATE:if(t.enableRotate===!1)return;R(c),t.update();break;case i.TOUCH_PAN:if(t.enablePan===!1)return;M(c),t.update();break;case i.TOUCH_DOLLY_PAN:if(t.enableZoom===!1&&t.enablePan===!1)return;ae(c),t.update();break;case i.TOUCH_DOLLY_ROTATE:if(t.enableZoom===!1&&t.enableRotate===!1)return;ye(c),t.update();break;default:o=i.NONE}}function qe(c){t.enabled!==!1&&c.preventDefault()}function _t(c){w.push(c.pointerId)}function kt(c){delete ge[c.pointerId];for(let x=0;x<w.length;x++)if(w[x]==c.pointerId){w.splice(x,1);return}}function Dt(c){for(let x=0;x<w.length;x++)if(w[x]==c.pointerId)return!0;return!1}function vt(c){let x=ge[c.pointerId];x===void 0&&(x=new h.Vector2,ge[c.pointerId]=x),x.set(c.pageX,c.pageY)}function Be(c){const x=c.pointerId===w[0]?w[1]:w[0];return ge[x]}t.domElement.addEventListener("contextmenu",qe),t.domElement.addEventListener("pointerdown",F),t.domElement.addEventListener("pointercancel",$),t.domElement.addEventListener("wheel",ue,{passive:!1}),t.domElement.getRootNode().addEventListener("keydown",at,{passive:!0,capture:!0}),this.update()}}function Je(e,n,a,t,i){return t+(e-n)*(i-t)/(a-n)}const Mt=e=>{const[n,a]=b.useState(e.options[e.index]),t=()=>{e.onToggle(!e.open)},i=o=>{o!==n&&(e.onSelect(o),a(o)),e.onToggle(!1)};return u.jsxs("div",{className:`dropdown ${e.up===!0?"up":""}`,children:[u.jsx("div",{className:"dropdown-toggle",onClick:t,children:n}),e.open&&u.jsx("ul",{className:"dropdown-menu",children:e.options.map(o=>u.jsx("li",{onClick:()=>i(o),children:o},o))})]})},He=b.forwardRef(function(n,a){const t=["Renderer","Depth","Normals","UVs","Wireframe"],[i,o]=b.useState("Renderer"),[l,s]=b.useState(!1),[f,d]=b.useState(!1),[m,y]=b.useState(!1);return u.jsxs("div",{className:"CameraWindow",children:[u.jsx("div",{ref:a,className:"clickable",onClick:()=>{m&&y(!1)}}),u.jsx(Mt,{index:t.indexOf(i),open:f,options:t,onSelect:E=>{if(E===i)return;const C=E;n.onSelectRenderMode(C),o(C)},onToggle:E=>{l&&s(!1),d(E)},up:!0}),u.jsx(Mt,{index:n.options.indexOf(n.camera.name),open:m,options:n.options,onSelect:n.onSelectCamera,onToggle:E=>{y(E)},up:!0})]})});class ba extends h.ShaderMaterial{constructor(n){super({extensions:{derivatives:!0},glslVersion:h.GLSL3,side:h.DoubleSide,transparent:!0,uniforms:{uScale:{value:n?.scale!==void 0?n?.scale:.1},uDivisions:{value:n?.divisions!==void 0?n?.divisions:10},uColor:{value:n?.color!==void 0?n?.color:new h.Color(16777215)},uDistance:{value:n?.distance!==void 0?n?.distance:1e4},uSubgridOpacity:{value:n?.subgridOpacity!==void 0?n?.subgridOpacity:.15},uGridOpacity:{value:n?.gridOpacity!==void 0?n?.gridOpacity:.25}},vertexShader:`out vec3 worldPosition;
|
29
|
+
C11,8.22,10.74,8,10.43,8z`})});function nn(i){return m.jsx(qi.Reorder.Item,{value:i.title,children:m.jsxs("div",{children:[Ln,m.jsx("span",{children:i.title}),m.jsx("button",{className:"closeIcon",onClick:()=>{i.onDelete(i.index)},children:Pn})]})},i.title)}function sn(i){const[e,n]=T.useState(!1),[t,s]=T.useState(i.options),a=c=>{i.onDragComplete(c),s(c)},o=c=>{const u=[...t];u.splice(c,1),a(u)},r=[];t.forEach((c,u)=>{r.push(m.jsx(nn,{index:u,title:c,onDelete:o},c))});let h="dropdown draggable";return i.subdropdown&&(h+=" subdropdown"),m.jsxs("div",{className:h,onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[m.jsx(xi,{title:i.title}),m.jsx(qi.Reorder.Group,{axis:"y",values:t,onReorder:a,style:{visibility:e?"visible":"hidden"},children:r})]})}function an(i){const[e,n]=T.useState(!1),t=[];i.options.map((a,o)=>{i.onSelect!==void 0&&(a.onSelect=i.onSelect),t.push(m.jsx(rn,{option:a},o))});let s="dropdown";return i.subdropdown&&(s+=" subdropdown"),m.jsxs("div",{className:s,onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[m.jsx(xi,{title:i.title}),m.jsx("ul",{style:{visibility:e?"visible":"hidden"},children:t})]})}function rn(i){const{option:e}=i,[n,t]=T.useState("");let s;switch(e.type){case"draggable":s=m.jsx(sn,{title:e.title,options:e.value,onDragComplete:a=>{e.onDragComplete!==void 0&&e.onDragComplete(a)},subdropdown:!0});break;case"dropdown":s=m.jsx(an,{title:e.title,options:e.value,onSelect:e.onSelect,subdropdown:!0});break;case"option":s=m.jsx("button",{onClick:()=>{e.onSelect!==void 0&&e.onSelect(e.value),e.selectable&&(n!==e.title?t(e.title):t(""))},children:e.title});break}return m.jsx("li",{className:n===e.title?"selected":"",children:s},Ji())}function In(i,e,n){function t(a){switch(e.forEach(o=>{o.callback(i,o.remote,a)}),a.event){case"custom":j.dispatchEvent({type:N.CUSTOM,value:a.data});break}}function s(a){switch(n.forEach(o=>{o.callback(i,o.remote,a)}),a.event){case"custom":j.dispatchEvent({type:N.CUSTOM,value:a.data});break}}i.listen=a=>{a.target==="editor"?s(a):t(a)}}function Bt(i){const[e,n]=T.useState(i.open!==void 0?i.open:!0),t=!e||i.children===void 0,s=()=>{j.dispatchEvent({type:N.REMOVE_SCENE,value:i.scene})};return m.jsxs("div",{className:`accordion ${t?"hide":""}`,children:[m.jsxs("button",{className:"toggle",onClick:()=>{const a=!e;i.onToggle!==void 0&&i.onToggle(a),n(a)},children:[m.jsx("p",{className:`status ${e?"open":""}`,children:"Toggle"}),m.jsx("p",{className:"label",children:Nt(i.label)})]}),i.onRefresh?m.jsxs(m.Fragment,{children:[m.jsx("button",{className:"refresh",onClick:i.onRefresh}),m.jsx("button",{className:"remove",onClick:s})]}):null,i.button,m.jsx("div",{className:e?"open":"",children:m.jsx("div",{children:i.children})},Math.random())]})}function Si(i){const e=T.useRef(null),[n,t]=T.useState(!1),s=i.child!==void 0&&i.child.children.length>0,a=[];return i.child!==void 0&&i.child.children.length>0&&i.child.children.map((o,r)=>{a.push(m.jsx(Si,{child:o,three:i.three},r))}),T.useEffect(()=>{if(i.child){const o=i.three.getScene(i.child.uuid);if(o!==null){const r=o.getObjectByProperty("uuid",i.child.uuid);r!==void 0&&(e.current.style.opacity=r.visible?"1":"0.25")}}},[n]),m.jsx(m.Fragment,{children:i.child!==void 0&&m.jsxs("div",{className:"childObject",children:[m.jsxs("div",{className:"child",children:[s?m.jsx("button",{className:"status",style:{backgroundPositionX:n?"-14px":"2px"},onClick:()=>{t(!n)}}):null,m.jsx("button",{className:"name",style:{left:s?"20px":"5px"},onClick:()=>{i.child!==void 0&&(i.three.getObject(i.child.uuid),n||t(!0))},children:i.child.name.length>0?`${i.child.name} (${i.child.type})`:`${i.child.type}::${i.child.uuid}`}),m.jsx("button",{className:"visibility",ref:e,onClick:()=>{if(i.child){const o=i.three.getScene(i.child.uuid);if(o!==null){const r=o.getObjectByProperty("uuid",i.child.uuid);if(r!==void 0){const h="visible",c=!r.visible;e.current.style.opacity=c?"1":"0.25",i.three.updateObject(i.child.uuid,h,c),ge(r,h,c)}}}}}),m.jsx("div",{className:`icon ${Cn(i.child)}`})]}),m.jsx("div",{className:n?"open":"",children:m.jsx("div",{className:"container",children:a})})]},Math.random())})}function Ci(i){const e=[];return i.child?.children.map((n,t)=>{e.push(m.jsx(Si,{child:n,scene:i.scene,three:i.three},t))}),m.jsx("div",{className:`scene ${i.class!==void 0?i.class:""}`,children:e})}function kn(i){const[e,n]=T.useState(i.defaultValue);return T.useEffect(()=>{let t=!1,s=-1,a=0,o=i.defaultValue;const r=v=>{t=!0,a=Number(i.input.current?.value),s=v.clientX,document.addEventListener("mouseup",c,!1),document.addEventListener("mousemove",h,!1),document.addEventListener("contextmenu",c,!1)},h=v=>{if(!t)return;const y=i.step!==void 0?i.step:1,A=(v.clientX-s)*y;o=Number((a+A).toFixed(4)),i.min!==void 0&&(o=Math.max(o,i.min)),i.max!==void 0&&(o=Math.min(o,i.max)),i.onChange!==void 0&&i.onChange(o),n(o)},c=()=>{t=!1,document.removeEventListener("mouseup",c),document.removeEventListener("mousemove",h),document.removeEventListener("contextmenu",c)},u=v=>{const y=Number(v.target.value);n(y)},f=v=>{const y=Number(v.target.value);i.onChange!==void 0&&i.onChange(y),n(y)};return i.input.current?.addEventListener("input",u),i.label.current?.addEventListener("mousedown",r,!1),i.sliderRef!==void 0&&i.sliderRef.current?.addEventListener("input",f),()=>{i.input.current?.removeEventListener("input",u),i.label.current?.removeEventListener("mousedown",r),i.sliderRef!==void 0&&i.sliderRef.current?.removeEventListener("input",f),document.removeEventListener("mouseup",c),document.removeEventListener("mousemove",h),document.removeEventListener("contextmenu",c)}},[]),e}function gt(i){const e=T.useRef(null),n=T.useRef(null),t=kn({label:i.labelRef,input:e,sliderRef:n,defaultValue:i.value,min:i.min,max:i.max,step:i.step,onChange:s=>{i.onChange!==void 0&&i.onChange(i.prop,s)}});return m.jsxs(m.Fragment,{children:[i.type==="number"&&m.jsx("input",{alt:i.alt,className:i.className,ref:e,type:"number",value:t,min:i.min,max:i.max,step:i.step,disabled:i.disabled,onChange:s=>{const a=Number(s.target.value);i.onChange!==void 0&&i.onChange(i.prop,a)}}),i.type==="range"&&m.jsxs(m.Fragment,{children:[m.jsx("input",{type:"text",value:t.toString(),disabled:i.disabled,ref:e,className:"min",onChange:s=>{const a=Number(s.target.value);i.onChange!==void 0&&i.onChange(i.prop,a)}}),m.jsx("input",{disabled:i.disabled,type:"range",value:t,min:i.min,max:i.max,step:i.step,ref:n,onChange:ni})]})]})}function Un(i){const e=T.useRef(null),n=T.useRef(null),t=T.useRef(null),s=T.useRef(null),a=T.useRef(null),o=T.useRef(null),[r,h]=T.useState(i.value),[c,u]=T.useState({min:Math.min(i.min,Math.min(i.value.x,i.value.y)),max:Math.max(i.max,Math.max(i.value.x,i.value.y))}),[f,v]=T.useState(!1);function y(){f||(window.addEventListener("mousemove",I),window.addEventListener("mouseup",A),window.addEventListener("mouseup",A),v(!0))}function A(){window.removeEventListener("mousemove",I),window.removeEventListener("mouseup",A),v(!1)}function I(C){const k=a.current.getBoundingClientRect(),L=ct(0,99,C.clientX-k.left)/99,x=ct(0,99,C.clientY-k.top)/99,ne=Ei(ei(c.min,c.max,L),3),q=Ei(ei(c.min,c.max,x),3);i.onChange({target:{value:{x:ne,y:q}}}),h({x:ne,y:q})}function U(C){let k=r.x,L=r.y;C.target===e.current?k=Number(C.target.value):L=Number(C.target.value),h({x:k,y:L})}function _(){const C=Number(t.current.value);u({min:C,max:c.max}),(r.x<C||r.y<C)&&h({x:ct(C,c.max,r.x),y:ct(C,c.max,r.y)})}function E(){const C=Number(s.current.value);u({min:c.min,max:C}),(r.x>C||r.y>C)&&h({x:ct(c.min,C,r.x),y:ct(c.min,C,r.y)})}T.useEffect(()=>{const C=vi(c.min,c.max,r.x),k=vi(c.min,c.max,r.y);o.current.style.left=`${C*100}%`,o.current.style.top=`${k*100}%`},[c,r]);const w=i.step!==void 0?i.step:.01;return m.jsxs("div",{className:"vector2",children:[m.jsxs("div",{className:"fields",children:[m.jsxs("div",{children:[m.jsx("label",{children:"X:"}),m.jsx("input",{ref:e,type:"number",value:r.x,min:c.min,max:c.max,step:w,onChange:U})]}),m.jsxs("div",{children:[m.jsx("label",{children:"Y:"}),m.jsx("input",{ref:n,type:"number",value:r.y,min:c.min,max:c.max,step:w,onChange:U})]}),m.jsxs("div",{children:[m.jsx("label",{children:"Min:"}),m.jsx("input",{ref:t,type:"number",value:c.min,step:w,onChange:_})]}),m.jsxs("div",{children:[m.jsx("label",{children:"Max:"}),m.jsx("input",{ref:s,type:"number",value:c.max,step:w,onChange:E})]})]}),m.jsxs("div",{className:"input",ref:a,onMouseDown:y,onMouseUp:A,children:[m.jsx("div",{className:"x"}),m.jsx("div",{className:"y"}),m.jsx("div",{className:"pt",ref:o})]})]})}function Pi(i){const e=i.value.isVector3!==void 0,n=i.value.isEuler!==void 0,t=i.value.elements!==void 0,s=i.step!==void 0?i.step:.01,a=[];if(e){const o=T.useMemo(()=>i.value,[]),r=(c,u)=>{o[c]=u,i.onChange({target:{value:o}})};["x","y","z"].forEach(c=>{const u=T.useRef(null);a.push(m.jsxs("div",{children:[m.jsx("label",{ref:u,children:c.toUpperCase()}),m.jsx(gt,{value:o[c],type:"number",prop:c,step:s,labelRef:u,onChange:r})]},c))})}else if(n){const o=T.useMemo(()=>i.value,[]),r=(c,u)=>{o[c]=u,i.onChange({target:{value:o}})};["_x","_y","_z"].forEach(c=>{const u=T.useRef(null);a.push(m.jsxs("div",{children:[m.jsx("label",{ref:u,children:c.substring(1).toUpperCase()}),m.jsx(gt,{value:o[c],type:"number",prop:c,step:s,labelRef:u,onChange:r})]},c))})}else if(t){const o=T.useMemo(()=>i.value,[]),r=(h,c)=>{const u=Number(h);o.elements[u]=c,i.onChange({target:{value:o}})};for(let h=0;h<9;h++){const c=T.useRef(null);a.push(m.jsxs("div",{children:[m.jsx("label",{ref:c,children:h+1}),m.jsx(gt,{value:o.elements[h],type:"number",prop:h.toString(),step:s,labelRef:c,onChange:r})]},h.toString()))}}return m.jsx("div",{className:"grid3",children:a},Math.random().toString())}function Fn(i){const e=i.value.x!==void 0,n=i.step!==void 0?i.step:.01,t=[];if(e){const s=T.useMemo(()=>i.value,[]),a=(r,h)=>{s[r]=h,i.onChange({target:{value:s}})};["x","y","z","w"].forEach(r=>{const h=T.useRef(null);t.push(m.jsxs("div",{children:[m.jsx("label",{ref:h,children:r.toUpperCase()}),m.jsx(gt,{value:s.x,type:"number",prop:r,step:n,labelRef:h,onChange:a})]},r))})}else{const s=T.useMemo(()=>i.value,[]),a=(o,r)=>{const h=Number(o);s.elements[h]=r,i.onChange({target:{value:s}})};for(let o=0;o<16;o++){const r=T.useRef(null);t.push(m.jsxs("div",{children:[m.jsx("label",{ref:r,children:o+1}),m.jsx(gt,{value:s.elements[o],type:"number",prop:o.toString(),step:n,labelRef:r,onChange:a})]},o.toString()))}}return m.jsx("div",{className:"grid4",children:t})}function jn(i){return!(i==="defaultAttributeValues"||i==="forceSinglePass"||i==="linecap"||i==="linejoin"||i==="linewidth"||i==="normalMapType"||i==="precision"||i==="shadowSide"||i==="uniformsGroups"||i==="uniformsNeedUpdate"||i==="userData"||i==="version"||i==="wireframeLinecap"||i==="wireframeLinejoin"||i==="wireframeLinewidth"||i.slice(0,4)==="clip"||i.slice(0,7)==="polygon"||i.slice(0,7)==="stencil"||i.slice(0,2)==="is")}function Nn(i){switch(i){case"Alpha Map":return"alphaMap";case"Anisotropy Map":return"anisotropyMap";case"AO Map":return"aoMap";case"Bump Map":return"bumpMap";case"Clearcoat Map":return"clearcoatMap";case"Clearcoat Normal Map":return"clearcoatNormalMap";case"Clearcoat Roughness Map":return"clearcoatRoughnessMap";case"Displacement Map":return"displacementMap";case"Emissive Map":return"emissiveMap";case"Gradient Map":return"gradientMap";case"Iridescence Map":return"iridescenceMap";case"Iridescence Thickness Map":return"iridescenceThicknessMap";case"Map":return"map";case"Matcap":return"matcap";case"Normal Map":return"normalMap";case"Roughness Map":return"roughnessMap";case"Sheen Color Map":return"sheenColorMap";case"Sheen Roughness Map":return"sheenRoughnessMap";case"Specular Color Map":return"specularColorMap";case"Specular Map Intensity":return"specularIntensityMap";case"Thickness Map":return"thicknessMap";case"Transmission Map":return"transmissionMap"}return i}function ai(i){switch(i){case"alphaHash":return"Alpha Hash";case"alphaMap":return"Alpha Map";case"alphaToCoverage":return"Alpha To Coverage";case"anisotropy":return"Anisotropy";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"attenuationDistance":return"Attenuation Distance";case"blendAlpha":return"Blend Alpha";case"blendColor":return"Blend Color";case"blendDst":return"Blend Dst";case"blendDstAlpha":return"Blend Dst Alha";case"blendEquation":return"Blend Equation";case"blendEquationAlpha":return"Blend Equation Alpha";case"blending":return"Blending";case"blendSrc":return"Blend Src";case"blendSrcAlpha":return"Blend Src Alpha";case"bumpMap":return"Bump Map";case"bumpScale":return"Bump Scale";case"clearcoat":return"Clearcoat";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"colorWrite":return"Color Write";case"defines":return"Defines";case"depthFunc":return"Depth Func";case"depthTest":return"Depth Test";case"depthWrite":return"Depth Write";case"dispersion":return"Dispersion";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"envMapRotation":return"Environment Map Rotation";case"extensions":return"Extensions";case"flatShading":return"Flat Shading";case"fragmentShader":return"Fragment Shader";case"fog":return"Fog";case"glslVersion":return"GLSL Version";case"gradientMap":return"Gradient Map";case"ior":return"IOR";case"iridescence":return"Iridescence";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"premultipliedAlpha":return"Premultiplied Alpha";case"opacity":return"Opacity";case"reflectivity":return"Reflectivity";case"refractionRatio":return"Refraction Ratio";case"roughness":return"Roughness";case"roughnessMap":return"Roughness Map";case"sheen":return"Sheen";case"sheenColor":return"Sheen Color";case"sheenColorMap":return"Sheen Color Map";case"sheenRoughness":return"Sheen Roughness";case"sheenRoughnessMap":return"Sheen Roughness Map";case"shininess":return"Shininess";case"side":return"Side";case"size":return"Size";case"sizeAttenuation":return"Size Attenuation";case"specular":return"Specular";case"specularColor":return"Specular Color";case"specularColorMap":return"Specular Color Map";case"specularIntensity":return"Specular Intensity";case"specularIntensityMap":return"Specular Map Intensity";case"thickness":return"Thickness";case"thicknessMap":return"Thickness Map";case"toneMapped":return"Tone Mapped";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"vertexColors":return"Vertex Colors";case"vertexShader":return"Vertex Shader";case"visible":return"Visible";case"wireframe":return"Wireframe"}return i}function on(i){const e=i.toLowerCase();return e.search("intensity")>-1||e==="anisotropyrotation"||e==="blendalpha"||e==="bumpscale"||e==="clearcoatroughness"||e==="displacementbias"||e==="displacementscale"||e==="metalness"||e==="opacity"||e==="reflectivity"||e==="refractionratio"||e==="roughness"||e==="sheenroughness"||e==="thickness"}function zn(){const i=document.createElement("input");return i.type="file",new Promise((e,n)=>{i.addEventListener("change",function(){if(i.files===null)n();else{const t=i.files[0],s=new FileReader;s.onload=function(a){e(a.target.result)},s.readAsDataURL(t)}}),i.click()})}const Bn=[{title:"Front",value:p.FrontSide},{title:"Back",value:p.BackSide},{title:"Double",value:p.DoubleSide}],Hn=[{title:"No Blending",value:p.NoBlending},{title:"Normal",value:p.NormalBlending},{title:"Additive",value:p.AdditiveBlending},{title:"Subtractive",value:p.SubtractiveBlending},{title:"Multiply",value:p.MultiplyBlending},{title:"Custom",value:p.CustomBlending}],Vn=[{title:"Add",value:p.AddEquation},{title:"Subtract",value:p.SubtractEquation},{title:"Reverse Subtract",value:p.ReverseSubtractEquation},{title:"Min",value:p.MinEquation},{title:"Max",value:p.MaxEquation}],Yn=[{title:"Zero",valye:p.ZeroFactor},{title:"One",valye:p.OneFactor},{title:"Src Color",valye:p.SrcColorFactor},{title:"One Minus Src Color",valye:p.OneMinusSrcColorFactor},{title:"Src Alpha",valye:p.SrcAlphaFactor},{title:"One Minus Src Alpha",valye:p.OneMinusSrcAlphaFactor},{title:"Dst Alpha",valye:p.DstAlphaFactor},{title:"One Minus Dst Alpha",valye:p.OneMinusDstAlphaFactor},{title:"Dst Color",valye:p.DstColorFactor},{title:"One Minus Dst Color",valye:p.OneMinusDstColorFactor},{title:"Src Alpha Saturate",valye:p.SrcAlphaSaturateFactor},{title:"Constant Color",valye:p.ConstantColorFactor},{title:"One Minus Constant Color",valye:p.OneMinusConstantColorFactor},{title:"Constant Alpha",valye:p.ConstantAlphaFactor},{title:"One Minus Constant Alpha",valye:p.OneMinusConstantAlphaFactor}],Gn=[{title:"Zero",valye:p.ZeroFactor},{title:"One",valye:p.OneFactor},{title:"Src Color",valye:p.SrcColorFactor},{title:"One Minus Src Color",valye:p.OneMinusSrcColorFactor},{title:"Src Alpha",valye:p.SrcAlphaFactor},{title:"One Minus Src Alpha",valye:p.OneMinusSrcAlphaFactor},{title:"Dst Alpha",valye:p.DstAlphaFactor},{title:"One Minus Dst Alpha",valye:p.OneMinusDstAlphaFactor},{title:"Dst Color",valye:p.DstColorFactor},{title:"One Minus Dst Color",valye:p.OneMinusDstColorFactor},{title:"Constant Color",valye:p.ConstantColorFactor},{title:"One Minus Constant Color",valye:p.OneMinusConstantColorFactor},{title:"Constant Alpha",valye:p.ConstantAlphaFactor},{title:"One Minus Constant Alpha",valye:p.OneMinusConstantAlphaFactor}];function At(i,e){i.needsUpdate=!0,i.type="option",i.options=e}function Zn(i,e,n,t){return{type:"boolean",title:ai(i),prop:i,value:e,needsUpdate:!0,onChange:(s,a)=>{t.updateObject(n.uuid,`material.${i}`,a),t.updateObject(n.uuid,"material.needsUpdate",!0);const o=t.getScene(n.uuid);if(o!==null){const r=o.getObjectByProperty("uuid",n.uuid);ge(r,`material.${i}`,a)}}}}function $n(i,e,n,t){const s={type:"number",title:ai(i),prop:i,value:e,min:void 0,max:void 0,step:.01,needsUpdate:!0,onChange:(a,o)=>{t.updateObject(n.uuid,`material.${i}`,o),t.updateObject(n.uuid,"material.needsUpdate",!0);const r=t.getScene(n.uuid);if(r!==null){const h=r.getObjectByProperty("uuid",n.uuid);ge(h,`material.${i}`,o)}}};switch(i){case"blending":At(s,Hn);break;case"blendDst":At(s,Gn);break;case"blendEquation":At(s,Vn);break;case"blendSrc":At(s,Yn);break;case"side":At(s,Bn);break}return on(i)&&(s.value=Number(e),s.type="range",s.min=Math.min(0,s.value),s.max=Math.max(1,s.value),s.step=.01),s}function Wn(i,e,n,t){const s={type:"string",title:ai(i),prop:i,value:e,needsUpdate:!0,onChange:(o,r)=>{t.updateObject(n.uuid,`material.${i}`,r),t.updateObject(n.uuid,"material.needsUpdate",!0);const h=t.getScene(n.uuid);if(h!==null){const c=h.getObjectByProperty("uuid",n.uuid);ge(c,`material.${i}`,r)}},onKeyDown:o=>{}};return(i==="vertexShader"||i==="fragmentShader")&&(s.disabled=!1,s.latest=s.value,s.onChange=(o,r)=>{s.latest=r,t.updateObject(n.uuid,`material.${i}`,r);const h=t.getScene(n.uuid);if(h!==null){const c=h.getObjectByProperty("uuid",n.uuid);ge(c,`material.${i}`,r)}},s.onKeyDown=o=>{if(o.key==="Enter"&&(o.altKey||o.metaKey)){t.updateObject(n.uuid,"material.needsUpdate",!0);const r=t.getScene(n.uuid);if(r!==null){const h=r.getObjectByProperty("uuid",n.uuid);ge(h,"material.needsUpdate",!0)}}}),s}function Kn(i){return i.x!==void 0&&i.y!==void 0&&i.z===void 0}function Xn(i){return i.x!==void 0&&i.y!==void 0&&i.z!==void 0&&i.w===void 0}function qn(i){return i.x!==void 0&&i.y!==void 0&&i.z!==void 0&&i.w!==void 0}function Ti(i){i.sort((e,n)=>e.title<n.title?-1:e.title>n.title?1:0)}function Ft(i,e,n,t,s="",a=!1){const o=ai(i).split(".")[0].replaceAll("[","").replaceAll("]",""),r=s.length>0?`${s}.${i}`:i,h=typeof e;if(h==="boolean"||h==="string")return{title:o,prop:r,type:h,value:e,disabled:a,onChange:(c,u)=>{t.updateObject(n.uuid,`material.${r}`,u);const f=t.getScene(n.uuid);if(f!==null){const v=f.getObjectByProperty("uuid",n.uuid);ge(v,`material.${r}`,u)}}};if(h==="number"){const c={title:o,prop:r,type:"number",value:e,step:.01,disabled:a,onChange:(u,f)=>{t.updateObject(n.uuid,`material.${r}`,f);const v=t.getScene(n.uuid);if(v!==null){const y=v.getObjectByProperty("uuid",n.uuid);ge(y,`material.${r}`,f)}}};return on(o)&&(c.type="range",c.min=0,c.max=1),c}else{if(e.isColor)return{title:o,prop:r,type:"color",value:e,disabled:a,onChange:(c,u)=>{const f=new p.Color(u);t.updateObject(n.uuid,`material.${r}`,f);const v=t.getScene(n.uuid);if(v!==null){const y=v.getObjectByProperty("uuid",n.uuid);ge(y,`material.${r}`,f)}}};if(Array.isArray(e)){const c=[];for(const u in e){const f=e[u],v=`[${u.toString()}]`;if(f.value!==void 0){const y=Ft(`${v}.value`,f.value,n,t,r,a);y!==void 0&&c.push(y)}else{const y=Ft(v,f,n,t,r,a);y!==void 0&&c.push(y)}}if(c.length>0)return Ti(c),{title:o,items:c}}else{if(Kn(e))return{title:o,prop:r,type:"vector2",value:e,disabled:a,onChange:(c,u)=>{t.updateObject(n.uuid,`material.${r}`,u);const f=t.getScene(n.uuid);if(f!==null){const v=f.getObjectByProperty("uuid",n.uuid);ge(v,`material.${r}`,u)}}};if(Xn(e))return{title:o,prop:r,type:"grid3",value:e,disabled:a,onChange:(c,u)=>{t.updateObject(n.uuid,`material.${r}`,u);const f=t.getScene(n.uuid);if(f!==null){const v=f.getObjectByProperty("uuid",n.uuid);ge(v,`material.${r}`,u)}}};if(qn(e))return{title:o,prop:r,type:"grid4",value:e,disabled:a,onChange:(c,u)=>{t.updateObject(n.uuid,`material.${r}`,u);const f=t.getScene(n.uuid);if(f!==null){const v=f.getObjectByProperty("uuid",n.uuid);ge(v,`material.${r}`,u)}}};if(e.isEuler)return{title:o,prop:r,type:"euler",value:e,disabled:a,onChange:(c,u)=>{t.updateObject(n.uuid,`material.${r}`,u);const f=t.getScene(n.uuid);if(f!==null){const v=f.getObjectByProperty("uuid",n.uuid);ge(v,`material.${r}`,u)}}};if(e.src!==void 0)return{title:o,type:"image",value:e,disabled:a,onChange:(c,u)=>{const f=Nn(i),v=s.length>0?`${s}.${f}`:f;t.createTexture(n.uuid,`material.${v}`,u);const y=t.getScene(n.uuid);if(y!==null){const A=y.getObjectByProperty("uuid",n.uuid);if(A!==void 0){const I=U=>{const _=A.material,E=v.split(".");switch(E.length){case 1:_[E[0]]=U;break;case 2:_[E[0]][E[1]]=U;break;case 3:_[E[0]][E[1]][E[2]]=U;break;case 4:_[E[0]][E[1]][E[2]][E[3]]=U;break;case 5:_[E[0]][E[1]][E[2]][E[3]][E[4]]=U;break}_.needsUpdate=!0};u.src.length>0?tn(u.src).then(U=>{U.offset.set(u.offset[0],u.offset[1]),U.repeat.set(u.repeat[0],u.repeat[1]),I(U)}):I(null)}}}};if(e.elements!==void 0)return{title:o,prop:r,type:e.elements.length>9?"grid4":"grid3",value:e,disabled:a,onChange:(c,u)=>{t.updateObject(n.uuid,`material.${r}`,u);const f=t.getScene(n.uuid);if(f!==null){const v=f.getObjectByProperty("uuid",n.uuid);ge(v,`material.${r}`,u)}}};{const c=[],u=i==="defines"||i==="extensions";try{for(const f in e){const v=e[f];if(v!==void 0)if(v.value!==void 0){const y=Ft(`${f}.value`,v.value,n,t,r,u);y!==void 0&&c.push(y)}else{const y=Ft(f,v,n,t,r,u);y!==void 0&&c.push(y)}}}catch{console.log("Issue cycling through material object:",i,e)}if(c.length>0)return Ti(c),{title:o,items:c}}}}}function Li(i,e,n){const t=[];for(const s in i){if(!jn(s))continue;const a=typeof i[s],o=i[s];if(a==="boolean")t.push(Zn(s,o,e,n));else if(a==="number")t.push($n(s,o,e,n));else if(a==="string")t.push(Wn(s,o,e,n));else if(a==="object"){const r=Ft(s,o,e,n);r!==void 0&&t.push(r)}else o!==void 0&&console.log("other:",s,a,o)}return Ti(t),t.push({title:"Update Material",type:"button",onChange:()=>{n.updateObject(e.uuid,"material.needsUpdate",!0);const s=n.getScene(e.uuid);if(s!==null){const a=s.getObjectByProperty("uuid",e.uuid);ge(a,"material.needsUpdate",!0)}}}),t}function Jn(i,e){const n=i.material;if(Array.isArray(n)){const t=[],s=n.length;for(let a=0;a<s;a++)t.push(m.jsx(lt,{title:`Material ${a}`,items:Li(n[a],i,e)},`Material ${a}`));return m.jsx(m.Fragment,{children:t})}else return m.jsx(lt,{title:"Material",items:Li(n,i,e)})}const Ii="data:image/gif;base64,R0lGODlhDgFkAIAAAP///wAAACH/C1hNUCBEYXRhWE1QPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgOS4xLWMwMDIgNzkuZGJhM2RhM2I1LCAyMDIzLzEyLzE1LTEwOjQyOjM3ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgMjUuNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDoyMDk3M0NEODAxQjQxMUVGODVGNENDMkUyMUExNDk1NSIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDoyMDk3M0NEOTAxQjQxMUVGODVGNENDMkUyMUExNDk1NSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkE4ODc3Qzg5MDFCMzExRUY4NUY0Q0MyRTIxQTE0OTU1IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkE4ODc3QzhBMDFCMzExRUY4NUY0Q0MyRTIxQTE0OTU1Ii8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+Af/+/fz7+vn49/b19PPy8fDv7u3s6+rp6Ofm5eTj4uHg397d3Nva2djX1tXU09LR0M/OzczLysnIx8bFxMPCwcC/vr28u7q5uLe2tbSzsrGwr66trKuqqainpqWko6KhoJ+enZybmpmYl5aVlJOSkZCPjo2Mi4qJiIeGhYSDgoGAf359fHt6eXh3dnV0c3JxcG9ubWxramloZ2ZlZGNiYWBfXl1cW1pZWFdWVVRTUlFQT05NTEtKSUhHRkVEQ0JBQD8+PTw7Ojk4NzY1NDMyMTAvLi0sKyopKCcmJSQjIiEgHx4dHBsaGRgXFhUUExIREA8ODQwLCgkIBwYFBAMCAQAAIfkEAAAAAAAsAAAAAA4BZAAAAv+Mj6nL7Q+jnLTai7PevPsPhuJIluaJpurKtu4Lx/JM1/aN5/rO9/4PDAqHxKLxiEwql8ym8wmNSqfUqvWKzWq33K73Cw6Lx+Sy+YxOq9fstvsNj8vn9Lr9js/r9/y+/w8YKDhIWGh4iJiouMjY6PgIGSk5SVlpeYmZqTkJAGDQ+dnpuekmGgAKejpKuiZqmprKqoZKGyrbOlqrejub6xvLGyw8TFzcprurGuvqybxq7ETbrItsCz0l7Zpc+6p9/cS967w9/S2FTF0u/mzehK4Oqz3eTl9vf4+fr7/P3+//DzCgwIEECxo8iDChwoUMGzp8CDGixIkUK1q8iDGjxo0XHDt6/AgypMiRJEuaPIkypcqVLFt+KwAAOw==";function Qn(i){const e=i.step!==void 0?i.step:.01,n=T.useRef(null),t=T.useRef(null),s=T.useRef(null),a=T.useRef(null),o=T.useRef(null),[r]=T.useState(i.value),[h,c]=T.useState(i.value.offset[0]),[u,f]=T.useState(i.value.offset[1]),[v,y]=T.useState(i.value.repeat[0]),[A,I]=T.useState(i.value.repeat[1]);function U(E,w,C,k,L){if(i.onChange!==void 0){const x=i.prop!==void 0?i.prop:i.title;i.onChange(x,{src:E,offset:[w,C],repeat:[k,L]})}}function _(E){const w=n.current.src,C=E.target.value;switch(E.target){case t.current:c(C),U(w,C,u,v,A);break;case s.current:f(C),U(w,h,C,v,A);break;case a.current:y(C),U(w,h,u,C,A);break;case o.current:I(C),U(w,h,u,v,C);break}}return m.jsxs("div",{className:"imageField",children:[m.jsx("img",{alt:i.title,ref:n,onClick:()=>{zn().then(E=>{n.current.src=E,U(E,h,u,v,A)})},src:r.src.length>0?r.src:Ii}),m.jsxs("div",{className:"fields",children:[m.jsxs("div",{children:[m.jsx("label",{children:"Offset:"}),m.jsx("input",{ref:t,type:"number",value:h,step:e,onChange:_}),m.jsx("input",{ref:s,type:"number",value:u,step:e,onChange:_})]}),m.jsxs("div",{children:[m.jsx("label",{children:"Repeat:"}),m.jsx("input",{ref:a,type:"number",value:v,step:e,onChange:_}),m.jsx("input",{ref:o,type:"number",value:A,step:e,onChange:_})]}),m.jsx("button",{onClick:()=>{U("",h,u,v,A),n.current.src=Ii},children:"Clear"})]})]})}function Qt(i){let e=i.value;e!==void 0&&(e.isColor!==void 0?e=yi(i.value):i.type==="color"&&(e=yi(new p.Color(i.value))));const[n,t]=T.useState(e),s=T.useRef(null),a=c=>{let u=c.target.value;i.type==="boolean"?u=c.target.checked:i.type==="option"&&(u=i.options[u].value),t(u),i.onChange!==void 0&&i.onChange(i.prop!==void 0?i.prop:i.title,u)},o={};i.disabled&&(o.opacity=.8);const r=i.type==="string"&&(n.length>100||n.search(`
|
30
|
+
`)>-1),h=r||i.type==="image"||i.type==="vector2";return m.jsxs("div",{className:`field ${h?"block":""}`,style:o,children:[i.type!=="button"&&m.jsx("label",{ref:s,children:Nt(i.title)},"fieldLabel"),i.type==="string"&&!r&&m.jsx("input",{type:"text",disabled:i.disabled,onChange:a,value:n}),i.type==="string"&&r&&m.jsx("textarea",{cols:50,rows:10,disabled:i.disabled!==void 0?i.disabled:!0,onChange:a,onKeyDown:c=>{i.onKeyDown!==void 0&&i.onKeyDown(c)},value:n}),i.type==="boolean"&&m.jsx("input",{type:"checkbox",disabled:i.disabled,onChange:a,checked:n}),i.type==="number"&&m.jsx(gt,{value:n,type:i.type,prop:i.prop!==void 0?i.prop:i.title,min:i.min,max:i.max,step:i.step,disabled:i.disabled,labelRef:s,onChange:i.onChange}),i.type==="range"&&m.jsx(gt,{value:n,type:i.type,prop:i.prop!==void 0?i.prop:i.title,min:i.min,max:i.max,step:i.step,disabled:i.disabled,labelRef:s,onChange:i.onChange}),i.type==="color"&&m.jsxs(m.Fragment,{children:[m.jsx("input",{type:"text",value:n.toString(),onChange:a,disabled:i.disabled,className:"color"}),m.jsx("input",{type:"color",value:n,onChange:a,disabled:i.disabled})]}),i.type==="button"&&m.jsx("button",{disabled:i.disabled,onClick:()=>{i.onChange!==void 0&&i.onChange(i.prop!==void 0?i.prop:i.title,!0)},children:i.title}),i.type==="image"&&m.jsx(Qn,{title:i.title,prop:i.prop,value:i.value,onChange:i.onChange}),i.type==="option"&&m.jsx(m.Fragment,{children:m.jsx("select",{onChange:a,disabled:i.disabled,defaultValue:i.value,children:i.options?.map((c,u)=>m.jsx("option",{value:c.value,children:Nt(c.title)},u))})}),i.type==="vector2"&&m.jsx(Un,{step:i.step,value:n,min:0,max:1,onChange:a}),i.type==="grid3"&&m.jsx(Pi,{step:i.step,value:n,onChange:a}),i.type==="grid4"&&m.jsx(Fn,{step:i.step,value:n,onChange:a}),i.type==="euler"&&m.jsx(Pi,{step:i.step,value:n,onChange:a})]})}function es(i){return"items"in i}function lt(i){const e=[];return i.items.forEach(n=>{es(n)?e.push(m.jsx(lt,{title:Nt(n.title),items:n.items},Math.random())):e.push(m.jsx(Qt,{title:n.title,prop:n.prop,value:n.value,type:n.type,min:n.min,max:n.max,step:n.step,disabled:n.disabled,options:n.options,onChange:(t,s)=>{n.onChange!==void 0&&n.onChange(t,s)},onKeyDown:t=>{n.onKeyDown!==void 0&&n.onKeyDown(t)}},Math.random()))}),m.jsx(Bt,{label:i.title,open:i.expanded===!0,children:e})}function ts(i){const[e]=T.useState([]),[n]=T.useState([]),[t,s]=T.useState(0);return T.useEffect(()=>{const a=r=>{const h=JSON.parse(r.value),c=[];h.items.forEach(u=>{c.push({title:u.title,type:u.type,value:u.value,prop:u.prop,min:u.min,max:u.max,step:u.step,onChange:(f,v)=>{i.three.updateGroup(h.title,f,v)}})}),e.push(m.jsx(lt,{title:h.title,items:c},Math.random())),n.push(h.title),s(Date.now())},o=r=>{const h=r.value,c=n.length;for(let u=0;u<c;u++)if(h===n[u]){e.splice(u,1),n.splice(u,1),s(Date.now());return}};return j.addEventListener(N.ADD_GROUP,a),j.addEventListener(N.REMOVE_GROUP,o),()=>{j.removeEventListener(N.ADD_GROUP,a),j.removeEventListener(N.REMOVE_GROUP,o)}},[]),m.jsx("div",{className:"customGroups",children:e},t)}function ki(i){switch(i){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 i}function is(i,e){const n=[];if(i.perspectiveCameraInfo!==void 0)for(const t in i.perspectiveCameraInfo)n.push({title:ki(t),prop:t,type:"number",step:.01,value:i.perspectiveCameraInfo[t],onChange:(s,a)=>{e.updateObject(i.uuid,s,a),e.requestMethod(i.uuid,"updateProjectionMatrix");const o=e.getScene(i.uuid);if(o!==null){const r=o.getObjectByProperty("uuid",i.uuid);r!==void 0&&(ge(r,s,a),r.updateProjectionMatrix())}}});else if(i.orthographicCameraInfo!==void 0)for(const t in i.orthographicCameraInfo)n.push({title:ki(t),prop:t,type:"number",step:.01,value:i.perspectiveCameraInfo[t],onChange:(s,a)=>{e.updateObject(i.uuid,s,a),e.requestMethod(i.uuid,"updateProjectionMatrix");const o=e.getScene(i.uuid);if(o!==null){const r=o.getObjectByProperty("uuid",i.uuid);r!==void 0&&(ge(r,s,a),r.updateProjectionMatrix())}}});return m.jsx(lt,{title:"Camera",items:n})}function ns(i,e){const n=new p.Matrix4;n.elements=i.matrix;const t=new p.Vector3,s=new p.Euler,a=new p.Vector3;i.uuid.length>0&&(t.setFromMatrixPosition(n),s.setFromRotationMatrix(n),a.setFromMatrixScale(n));const o=(r,h)=>{const c=r==="rotation"?{x:h._x,y:h._y,z:h._z}:h;e.updateObject(i.uuid,r,c);const u=e.getScene(i.uuid);if(u!==null){const f=u.getObjectByProperty("uuid",i.uuid);ge(f,r,c)}};return m.jsx(lt,{title:"Transform",items:[{title:"Position",prop:"position",type:"grid3",step:.1,value:t,onChange:o},{title:"Rotation",prop:"rotation",type:"grid3",value:s,onChange:o},{title:"Scale",prop:"scale",type:"grid3",value:a,onChange:o}]})}function Ui(i){switch(i){case"color":return"Color";case"intensity":return"Intensity";case"decay":return"Decay";case"distance":return"Distance";case"angle":return"Angle";case"penumbra":return"Penumbra";case"groundColor":return"Ground Color";case"width":return"Width";case"height":return"Height"}return i}function ss(i,e){const n=[];if(i.lightInfo!==void 0)for(const t in i.lightInfo){const s=i.lightInfo[t];s!==void 0&&(s.isColor!==void 0?n.push({title:Ui(t),prop:t,type:"color",value:s,onChange:(a,o)=>{const r=new p.Color(o);e.updateObject(i.uuid,a,r);const h=e.getScene(i.uuid);if(h!==null){const c=h.getObjectByProperty("uuid",i.uuid);ge(c,a,r)}}}):n.push({title:Ui(t),prop:t,type:typeof s,value:s,step:typeof s=="number"?.01:void 0,onChange:(a,o)=>{e.updateObject(i.uuid,a,o);const r=e.getScene(i.uuid);if(r!==null){const h=r.getObjectByProperty("uuid",i.uuid);ge(h,a,o)}}}))}return m.jsx(lt,{title:"Light",items:n})}function as(i,e){const n=[],t=[];let s=0;i.animations.forEach(o=>{s=Math.max(s,o.duration),o.duration>0&&t.push({title:o.name,items:[{title:"Duration",type:"number",value:o.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),n.push({title:"Animations",items:t});const a=e.getScene(i.uuid);if(a!==null){const o=a.getObjectByProperty("uuid",i.uuid);let r=!1;if(o!==void 0){const h=o.mixer;if(r=h!==void 0,r){const c=[{title:"Time Scale",type:"range",value:h.timeScale,step:.01,min:-1,max:2,onChange:(u,f)=>{h.timeScale=f,e.updateObject(i.uuid,"mixer.timeScale",f)}}];c.push({title:"Stop All",type:"button",onChange:()=>{h.stopAllAction(),e.requestMethod(i.uuid,"stopAllAction",void 0,"mixer")}}),n.push({title:"Mixer",items:c})}}}return m.jsx(lt,{title:"Animation",items:n})}const cn={name:"",uuid:"",type:"",visible:!1,matrix:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};let Me={...cn};function ln(i){const[e,n]=T.useState(-1);T.useEffect(()=>{function o(h){Me={...h.value},n(Date.now())}function r(){Me={...cn},n(Date.now())}return j.addEventListener(N.SET_SCENE,r),j.addEventListener(N.SET_OBJECT,o),()=>{j.removeEventListener(N.SET_SCENE,r),j.removeEventListener(N.SET_OBJECT,o)}},[]);const t=Me.type.toLowerCase(),s=Me.animations.length>0||Me.mixer!==void 0,a=t.search("mesh")>-1||t.search("line")>-1||t.search("points")>-1;return m.jsx(Bt,{label:"Inspector",children:m.jsx("div",{id:"Inspector",className:i.class,children:Me.uuid.length>0&&m.jsxs(m.Fragment,{children:[m.jsxs(m.Fragment,{children:[m.jsx(Qt,{type:"string",title:"Name",prop:"name",value:Me.name,disabled:!0}),m.jsx(Qt,{type:"string",title:"Type",prop:"type",value:Me.type,disabled:!0}),m.jsx(Qt,{type:"string",title:"UUID",prop:"uuid",value:Me.uuid,disabled:!0})]}),m.jsxs(m.Fragment,{children:[ns(Me,i.three),s?as(Me,i.three):null,t.search("camera")>-1?is(Me,i.three):null,t.search("light")>-1?ss(Me,i.three):null,a?Jn(Me,i.three):null]})]})},e)},"Inspector")}function rs(i){const[e]=T.useState([]),[n]=T.useState([]),[t,s]=T.useState(0),a=h=>{const c=h.value;e.push(c),n.push(m.jsx(Bt,{label:`Scene: ${c.name}`,scene:c,open:!0,onRefresh:()=>{i.three.refreshScene(c.name)},children:m.jsx(Ci,{child:c,scene:c,three:i.three})},Math.random())),s(Date.now())},o=h=>{const c=h.value;for(let u=0;u<e.length;u++)if(c.uuid===e[u].uuid){e[u]=c,n[u]=m.jsx(Bt,{label:`Scene: ${c.name}`,scene:c,open:!0,onRefresh:()=>{i.three.refreshScene(c.name)},children:m.jsx(Ci,{child:c,scene:c,three:i.three})},Math.random()),s(Date.now());return}},r=h=>{const c=h.value;for(let u=0;u<e.length;u++)if(c.uuid===e[u].uuid){e.splice(u,1),n.splice(u,1),s(Date.now());return}};return T.useEffect(()=>(j.addEventListener(N.ADD_SCENE,a),j.addEventListener(N.REFRESH_SCENE,o),j.addEventListener(N.REMOVE_SCENE,r),()=>{j.removeEventListener(N.ADD_SCENE,a),j.removeEventListener(N.REFRESH_SCENE,o),j.removeEventListener(N.REMOVE_SCENE,r)}),[]),m.jsxs("div",{id:"SidePanel",children:[m.jsx("div",{className:"scenes",children:n},t),m.jsx(ln,{three:i.three}),m.jsx(ts,{three:i.three})]})}function os(i){return T.useEffect(()=>{function e(r){let h=null;return i.three.scenes.forEach(c=>{r.search(c.uuid)>-1&&(h=c)}),h}const n=r=>{const h=r.value,u=e(h)?.getObjectByProperty("uuid",h);u!==void 0&&i.three.setObject(u)},t=(r,h,c)=>{const f=e(r)?.getObjectByProperty("uuid",r);f!==void 0&&ge(f,h,c)},s=r=>{const h=r.value,{key:c,value:u,uuid:f}=h;t(f,c,u)},a=r=>{const h=r.value,u=e(h.uuid)?.getObjectByProperty("uuid",h.uuid);if(u!==void 0){const f=v=>{const y=h.key.split(".");switch(y.length){case 1:u[y[0]]=v;break;case 2:u[y[0]][y[1]]=v;break;case 3:u[y[0]][y[1]][y[2]]=v;break;case 4:u[y[0]][y[1]][y[2]][y[3]]=v;break;case 5:u[y[0]][y[1]][y[2]][y[3]][y[4]]=v;break}u.material.needsUpdate=!0};h.value.src.length>0?tn(h.value.src).then(v=>{v.offset.set(h.value.offset[0],h.value.offset[1]),v.repeat.set(h.value.repeat[0],h.value.repeat[1]),f(v)}):f(null)}},o=r=>{const{key:h,uuid:c,value:u,subitem:f}=r.value,y=e(c)?.getObjectByProperty("uuid",c);if(y!==void 0)try{f!==void 0?Sn(y,f)[h](u):y[h](u)}catch(A){console.log("Error requesting method:"),console.log(A),console.log(h),console.log(u)}};return j.addEventListener(N.GET_OBJECT,n),j.addEventListener(N.UPDATE_OBJECT,s),j.addEventListener(N.CREATE_TEXTURE,a),j.addEventListener(N.REQUEST_METHOD,o),()=>{j.removeEventListener(N.GET_OBJECT,n),j.removeEventListener(N.UPDATE_OBJECT,s),j.removeEventListener(N.CREATE_TEXTURE,a),j.removeEventListener(N.REQUEST_METHOD,o)}},[]),null}class cs extends p.Line{constructor(e,n){const t=[1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],s=new p.BufferGeometry;s.setAttribute("position",new p.Float32BufferAttribute(t,3)),s.computeBoundingSphere();const a=new p.LineBasicMaterial({fog:!1});super(s,a),this.light=e,this.color=n,this.type="RectAreaLightHelper";const o=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],r=new p.BufferGeometry;r.setAttribute("position",new p.Float32BufferAttribute(o,3)),r.computeBoundingSphere(),this.add(new p.Mesh(r,new p.MeshBasicMaterial({side:p.BackSide,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),this.color!==void 0)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const e=this.material.color,n=Math.max(e.r,e.g,e.b);n>1&&e.multiplyScalar(1/n),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const Fi={type:"change"},li={type:"start"},ji={type:"end"},$t=new p.Ray,Ni=new p.Plane,ls=Math.cos(70*p.MathUtils.DEG2RAD);class ds extends p.EventDispatcher{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new p.Vector3,this.cursor=new p.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:p.MOUSE.ROTATE,MIDDLE:p.MOUSE.DOLLY,RIGHT:p.MOUSE.PAN},this.touches={ONE:p.TOUCH.ROTATE,TWO:p.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 r.phi},this.getAzimuthalAngle=function(){return r.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(d){d.addEventListener("keydown",Ae),this._domElementKeyEvents=d},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Ae),this._domElementKeyEvents=null},this.saveState=function(){t.target0.copy(t.target),t.position0.copy(t.object.position),t.zoom0=t.object.zoom},this.reset=function(){t.target.copy(t.target0),t.object.position.copy(t.position0),t.object.zoom=t.zoom0,t.object.updateProjectionMatrix(),t.dispatchEvent(Fi),t.update(),a=s.NONE},this.update=function(){const d=new p.Vector3,R=new p.Quaternion().setFromUnitVectors(e.up,new p.Vector3(0,1,0)),Z=R.clone().invert(),X=new p.Vector3,be=new p.Quaternion,ke=new p.Vector3,xe=2*Math.PI;return function(Yt=null){const Gt=t.object.position;d.copy(Gt).sub(t.target),d.applyQuaternion(R),r.setFromVector3(d),t.autoRotate&&a===s.NONE&&Pe($e(Yt)),t.enableDamping?(r.theta+=h.theta*t.dampingFactor,r.phi+=h.phi*t.dampingFactor):(r.theta+=h.theta,r.phi+=h.phi);let Ue=t.minAzimuthAngle,Fe=t.maxAzimuthAngle;isFinite(Ue)&&isFinite(Fe)&&(Ue<-Math.PI?Ue+=xe:Ue>Math.PI&&(Ue-=xe),Fe<-Math.PI?Fe+=xe:Fe>Math.PI&&(Fe-=xe),Ue<=Fe?r.theta=Math.max(Ue,Math.min(Fe,r.theta)):r.theta=r.theta>(Ue+Fe)/2?Math.max(Ue,r.theta):Math.min(Fe,r.theta)),r.phi=Math.max(t.minPolarAngle,Math.min(t.maxPolarAngle,r.phi)),r.makeSafe(),t.enableDamping===!0?t.target.addScaledVector(u,t.dampingFactor):t.target.add(u),t.target.sub(t.cursor),t.target.clampLength(t.minTargetRadius,t.maxTargetRadius),t.target.add(t.cursor);let ut=!1;if(t.zoomToCursor&&L||t.object.isOrthographicCamera)r.radius=et(r.radius);else{const Ge=r.radius;r.radius=et(r.radius*c),ut=Ge!=r.radius}if(d.setFromSpherical(r),d.applyQuaternion(Z),Gt.copy(t.target).add(d),t.object.lookAt(t.target),t.enableDamping===!0?(h.theta*=1-t.dampingFactor,h.phi*=1-t.dampingFactor,u.multiplyScalar(1-t.dampingFactor)):(h.set(0,0,0),u.set(0,0,0)),t.zoomToCursor&&L){let Ge=null;if(t.object.isPerspectiveCamera){const rt=d.length();Ge=et(rt*c);const vt=rt-Ge;t.object.position.addScaledVector(C,vt),t.object.updateMatrixWorld(),ut=!!vt}else if(t.object.isOrthographicCamera){const rt=new p.Vector3(k.x,k.y,0);rt.unproject(t.object);const vt=t.object.zoom;t.object.zoom=Math.max(t.minZoom,Math.min(t.maxZoom,t.object.zoom/c)),t.object.updateProjectionMatrix(),ut=vt!==t.object.zoom;const Zt=new p.Vector3(k.x,k.y,0);Zt.unproject(t.object),t.object.position.sub(Zt).add(rt),t.object.updateMatrixWorld(),Ge=d.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),t.zoomToCursor=!1;Ge!==null&&(this.screenSpacePanning?t.target.set(0,0,-1).transformDirection(t.object.matrix).multiplyScalar(Ge).add(t.object.position):($t.origin.copy(t.object.position),$t.direction.set(0,0,-1).transformDirection(t.object.matrix),Math.abs(t.object.up.dot($t.direction))<ls?e.lookAt(t.target):(Ni.setFromNormalAndCoplanarPoint(t.object.up,t.target),$t.intersectPlane(Ni,t.target))))}else if(t.object.isOrthographicCamera){const Ge=t.object.zoom;t.object.zoom=Math.max(t.minZoom,Math.min(t.maxZoom,t.object.zoom/c)),Ge!==t.object.zoom&&(t.object.updateProjectionMatrix(),ut=!0)}return c=1,L=!1,ut||X.distanceToSquared(t.object.position)>o||8*(1-be.dot(t.object.quaternion))>o||ke.distanceToSquared(t.target)>o?(t.dispatchEvent(Fi),X.copy(t.object.position),be.copy(t.object.quaternion),ke.copy(t.target),!0):!1}}(),this.dispose=function(){t.domElement.removeEventListener("contextmenu",Ke),t.domElement.removeEventListener("pointerdown",$),t.domElement.removeEventListener("pointercancel",Oe),t.domElement.removeEventListener("wheel",V),t.domElement.removeEventListener("pointermove",oe),t.domElement.removeEventListener("pointerup",Oe),t.domElement.getRootNode().removeEventListener("keydown",pe,{capture:!0}),t._domElementKeyEvents!==null&&(t._domElementKeyEvents.removeEventListener("keydown",Ae),t._domElementKeyEvents=null)};const t=this,s={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let a=s.NONE;const o=1e-6,r=new p.Spherical,h=new p.Spherical;let c=1;const u=new p.Vector3,f=new p.Vector2,v=new p.Vector2,y=new p.Vector2,A=new p.Vector2,I=new p.Vector2,U=new p.Vector2,_=new p.Vector2,E=new p.Vector2,w=new p.Vector2,C=new p.Vector3,k=new p.Vector2;let L=!1;const x=[],ne={};let q=!1;function $e(d){return d!==null?2*Math.PI/60*t.autoRotateSpeed*d:2*Math.PI/60/60*t.autoRotateSpeed}function Y(d){const R=Math.abs(d*.01);return Math.pow(.95,t.zoomSpeed*R)}function Pe(d){h.theta-=d}function Ee(d){h.phi-=d}const Ce=function(){const d=new p.Vector3;return function(Z,X){d.setFromMatrixColumn(X,0),d.multiplyScalar(-Z),u.add(d)}}(),Te=function(){const d=new p.Vector3;return function(Z,X){t.screenSpacePanning===!0?d.setFromMatrixColumn(X,1):(d.setFromMatrixColumn(X,0),d.crossVectors(t.object.up,d)),d.multiplyScalar(Z),u.add(d)}}(),Le=function(){const d=new p.Vector3;return function(Z,X){const be=t.domElement;if(t.object.isPerspectiveCamera){const ke=t.object.position;d.copy(ke).sub(t.target);let xe=d.length();xe*=Math.tan(t.object.fov/2*Math.PI/180),Ce(2*Z*xe/be.clientHeight,t.object.matrix),Te(2*X*xe/be.clientHeight,t.object.matrix)}else t.object.isOrthographicCamera?(Ce(Z*(t.object.right-t.object.left)/t.object.zoom/be.clientWidth,t.object.matrix),Te(X*(t.object.top-t.object.bottom)/t.object.zoom/be.clientHeight,t.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),t.enablePan=!1)}}();function Ve(d){t.object.isPerspectiveCamera||t.object.isOrthographicCamera?c/=d:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),t.enableZoom=!1)}function it(d){t.object.isPerspectiveCamera||t.object.isOrthographicCamera?c*=d:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),t.enableZoom=!1)}function Qe(d,R){if(!t.zoomToCursor)return;L=!0;const Z=t.domElement.getBoundingClientRect(),X=d-Z.left,be=R-Z.top,ke=Z.width,xe=Z.height;k.x=X/ke*2-1,k.y=-(be/xe)*2+1,C.set(k.x,k.y,1).unproject(t.object).sub(t.object.position).normalize()}function et(d){return Math.max(t.minDistance,Math.min(t.maxDistance,d))}function dt(d){f.set(d.clientX,d.clientY)}function nt(d){Qe(d.clientX,d.clientX),_.set(d.clientX,d.clientY)}function _e(d){A.set(d.clientX,d.clientY)}function Ye(d){v.set(d.clientX,d.clientY),y.subVectors(v,f).multiplyScalar(t.rotateSpeed);const R=t.domElement;Pe(2*Math.PI*y.x/R.clientHeight),Ee(2*Math.PI*y.y/R.clientHeight),f.copy(v),t.update()}function Mt(d){E.set(d.clientX,d.clientY),w.subVectors(E,_),w.y>0?Ve(Y(w.y)):w.y<0&&it(Y(w.y)),_.copy(E),t.update()}function ht(d){I.set(d.clientX,d.clientY),U.subVectors(I,A).multiplyScalar(t.panSpeed),Le(U.x,U.y),A.copy(I),t.update()}function we(d){Qe(d.clientX,d.clientY),d.deltaY<0?it(Y(d.deltaY)):d.deltaY>0&&Ve(Y(d.deltaY)),t.update()}function b(d){let R=!1;switch(d.code){case t.keys.UP:d.ctrlKey||d.metaKey||d.shiftKey?Ee(2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):Le(0,t.keyPanSpeed),R=!0;break;case t.keys.BOTTOM:d.ctrlKey||d.metaKey||d.shiftKey?Ee(-2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):Le(0,-t.keyPanSpeed),R=!0;break;case t.keys.LEFT:d.ctrlKey||d.metaKey||d.shiftKey?Pe(2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):Le(t.keyPanSpeed,0),R=!0;break;case t.keys.RIGHT:d.ctrlKey||d.metaKey||d.shiftKey?Pe(-2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):Le(-t.keyPanSpeed,0),R=!0;break}R&&(d.preventDefault(),t.update())}function S(d){if(x.length===1)f.set(d.pageX,d.pageY);else{const R=at(d),Z=.5*(d.pageX+R.x),X=.5*(d.pageY+R.y);f.set(Z,X)}}function P(d){if(x.length===1)A.set(d.pageX,d.pageY);else{const R=at(d),Z=.5*(d.pageX+R.x),X=.5*(d.pageY+R.y);A.set(Z,X)}}function F(d){const R=at(d),Z=d.pageX-R.x,X=d.pageY-R.y,be=Math.sqrt(Z*Z+X*X);_.set(0,be)}function he(d){t.enableZoom&&F(d),t.enablePan&&P(d)}function se(d){t.enableZoom&&F(d),t.enableRotate&&S(d)}function D(d){if(x.length==1)v.set(d.pageX,d.pageY);else{const Z=at(d),X=.5*(d.pageX+Z.x),be=.5*(d.pageY+Z.y);v.set(X,be)}y.subVectors(v,f).multiplyScalar(t.rotateSpeed);const R=t.domElement;Pe(2*Math.PI*y.x/R.clientHeight),Ee(2*Math.PI*y.y/R.clientHeight),f.copy(v)}function z(d){if(x.length===1)I.set(d.pageX,d.pageY);else{const R=at(d),Z=.5*(d.pageX+R.x),X=.5*(d.pageY+R.y);I.set(Z,X)}U.subVectors(I,A).multiplyScalar(t.panSpeed),Le(U.x,U.y),A.copy(I)}function ve(d){const R=at(d),Z=d.pageX-R.x,X=d.pageY-R.y,be=Math.sqrt(Z*Z+X*X);E.set(0,be),w.set(0,Math.pow(E.y/_.y,t.zoomSpeed)),Ve(w.y),_.copy(E);const ke=(d.pageX+R.x)*.5,xe=(d.pageY+R.y)*.5;Qe(ke,xe)}function De(d){t.enableZoom&&ve(d),t.enablePan&&z(d)}function We(d){t.enableZoom&&ve(d),t.enableRotate&&D(d)}function $(d){t.enabled!==!1&&(x.length===0&&(t.domElement.setPointerCapture(d.pointerId),t.domElement.addEventListener("pointermove",oe),t.domElement.addEventListener("pointerup",Oe)),!oi(d)&&(_t(d),d.pointerType==="touch"?Ie(d):ce(d)))}function oe(d){t.enabled!==!1&&(d.pointerType==="touch"?st(d):me(d))}function Oe(d){switch(ri(d),x.length){case 0:t.domElement.releasePointerCapture(d.pointerId),t.domElement.removeEventListener("pointermove",oe),t.domElement.removeEventListener("pointerup",Oe),t.dispatchEvent(ji),a=s.NONE;break;case 1:const R=x[0],Z=ne[R];Ie({pointerId:R,pageX:Z.x,pageY:Z.y});break}}function ce(d){let R;switch(d.button){case 0:R=t.mouseButtons.LEFT;break;case 1:R=t.mouseButtons.MIDDLE;break;case 2:R=t.mouseButtons.RIGHT;break;default:R=-1}switch(R){case p.MOUSE.DOLLY:if(t.enableZoom===!1)return;nt(d),a=s.DOLLY;break;case p.MOUSE.ROTATE:if(d.ctrlKey||d.metaKey||d.shiftKey){if(t.enablePan===!1)return;_e(d),a=s.PAN}else{if(t.enableRotate===!1)return;dt(d),a=s.ROTATE}break;case p.MOUSE.PAN:if(d.ctrlKey||d.metaKey||d.shiftKey){if(t.enableRotate===!1)return;dt(d),a=s.ROTATE}else{if(t.enablePan===!1)return;_e(d),a=s.PAN}break;default:a=s.NONE}a!==s.NONE&&t.dispatchEvent(li)}function me(d){switch(a){case s.ROTATE:if(t.enableRotate===!1)return;Ye(d);break;case s.DOLLY:if(t.enableZoom===!1)return;Mt(d);break;case s.PAN:if(t.enablePan===!1)return;ht(d);break}}function V(d){t.enabled===!1||t.enableZoom===!1||a!==s.NONE||(d.preventDefault(),t.dispatchEvent(li),we(te(d)),t.dispatchEvent(ji))}function te(d){const R=d.deltaMode,Z={clientX:d.clientX,clientY:d.clientY,deltaY:d.deltaY};switch(R){case 1:Z.deltaY*=16;break;case 2:Z.deltaY*=100;break}return d.ctrlKey&&!q&&(Z.deltaY*=10),Z}function pe(d){d.key==="Control"&&(q=!0,t.domElement.getRootNode().addEventListener("keyup",ue,{passive:!0,capture:!0}))}function ue(d){d.key==="Control"&&(q=!1,t.domElement.getRootNode().removeEventListener("keyup",ue,{passive:!0,capture:!0}))}function Ae(d){t.enabled===!1||t.enablePan===!1||b(d)}function Ie(d){switch(Vt(d),x.length){case 1:switch(t.touches.ONE){case p.TOUCH.ROTATE:if(t.enableRotate===!1)return;S(d),a=s.TOUCH_ROTATE;break;case p.TOUCH.PAN:if(t.enablePan===!1)return;P(d),a=s.TOUCH_PAN;break;default:a=s.NONE}break;case 2:switch(t.touches.TWO){case p.TOUCH.DOLLY_PAN:if(t.enableZoom===!1&&t.enablePan===!1)return;he(d),a=s.TOUCH_DOLLY_PAN;break;case p.TOUCH.DOLLY_ROTATE:if(t.enableZoom===!1&&t.enableRotate===!1)return;se(d),a=s.TOUCH_DOLLY_ROTATE;break;default:a=s.NONE}break;default:a=s.NONE}a!==s.NONE&&t.dispatchEvent(li)}function st(d){switch(Vt(d),a){case s.TOUCH_ROTATE:if(t.enableRotate===!1)return;D(d),t.update();break;case s.TOUCH_PAN:if(t.enablePan===!1)return;z(d),t.update();break;case s.TOUCH_DOLLY_PAN:if(t.enableZoom===!1&&t.enablePan===!1)return;De(d),t.update();break;case s.TOUCH_DOLLY_ROTATE:if(t.enableZoom===!1&&t.enableRotate===!1)return;We(d),t.update();break;default:a=s.NONE}}function Ke(d){t.enabled!==!1&&d.preventDefault()}function _t(d){x.push(d.pointerId)}function ri(d){delete ne[d.pointerId];for(let R=0;R<x.length;R++)if(x[R]==d.pointerId){x.splice(R,1);return}}function oi(d){for(let R=0;R<x.length;R++)if(x[R]==d.pointerId)return!0;return!1}function Vt(d){let R=ne[d.pointerId];R===void 0&&(R=new p.Vector2,ne[d.pointerId]=R),R.set(d.pageX,d.pageY)}function at(d){const R=d.pointerId===x[0]?x[1]:x[0];return ne[R]}t.domElement.addEventListener("contextmenu",Ke),t.domElement.addEventListener("pointerdown",$),t.domElement.addEventListener("pointercancel",Oe),t.domElement.addEventListener("wheel",V,{passive:!1}),t.domElement.getRootNode().addEventListener("keydown",pe,{passive:!0,capture:!0}),this.update()}}const hs=Math.PI/180;function bt(i,e,n,t,s){return t+(i-e)*(s-t)/(n-e)}function zi(i){return i*hs}/*!
|
31
|
+
* camera-controls
|
32
|
+
* https://github.com/yomotsu/camera-controls
|
33
|
+
* (c) 2017 @yomotsu
|
34
|
+
* Released under the MIT License.
|
35
|
+
*/const le={LEFT:1,RIGHT:2,MIDDLE:4},g=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,OFFSET:4,DOLLY:8,ZOOM:16,TOUCH_ROTATE:32,TOUCH_TRUCK:64,TOUCH_OFFSET:128,TOUCH_DOLLY:256,TOUCH_ZOOM:512,TOUCH_DOLLY_TRUCK:1024,TOUCH_DOLLY_OFFSET:2048,TOUCH_DOLLY_ROTATE:4096,TOUCH_ZOOM_TRUCK:8192,TOUCH_ZOOM_OFFSET:16384,TOUCH_ZOOM_ROTATE:32768}),Ot={NONE:0,IN:1,OUT:-1};function mt(i){return i.isPerspectiveCamera}function ot(i){return i.isOrthographicCamera}const Ct=Math.PI*2,Bi=Math.PI/2,dn=1e-5,Pt=Math.PI/180;function Ze(i,e,n){return Math.max(e,Math.min(n,i))}function re(i,e=dn){return Math.abs(i)<e}function ie(i,e,n=dn){return re(i-e,n)}function Hi(i,e){return Math.round(i/e)*e}function Lt(i){return isFinite(i)?i:i<0?-Number.MAX_VALUE:Number.MAX_VALUE}function It(i){return Math.abs(i)<Number.MAX_VALUE?i:i*(1/0)}function Wt(i,e,n,t,s=1/0,a){t=Math.max(1e-4,t);const o=2/t,r=o*a,h=1/(1+r+.48*r*r+.235*r*r*r);let c=i-e;const u=e,f=s*t;c=Ze(c,-f,f),e=i-c;const v=(n.value+o*c)*a;n.value=(n.value-o*v)*h;let y=e+(c+v)*h;return u-i>0==y>u&&(y=u,n.value=(y-u)/a),y}function Vi(i,e,n,t,s=1/0,a,o){t=Math.max(1e-4,t);const r=2/t,h=r*a,c=1/(1+h+.48*h*h+.235*h*h*h);let u=e.x,f=e.y,v=e.z,y=i.x-u,A=i.y-f,I=i.z-v;const U=u,_=f,E=v,w=s*t,C=w*w,k=y*y+A*A+I*I;if(k>C){const Te=Math.sqrt(k);y=y/Te*w,A=A/Te*w,I=I/Te*w}u=i.x-y,f=i.y-A,v=i.z-I;const L=(n.x+r*y)*a,x=(n.y+r*A)*a,ne=(n.z+r*I)*a;n.x=(n.x-r*L)*c,n.y=(n.y-r*x)*c,n.z=(n.z-r*ne)*c,o.x=u+(y+L)*c,o.y=f+(A+x)*c,o.z=v+(I+ne)*c;const q=U-i.x,$e=_-i.y,Y=E-i.z,Pe=o.x-U,Ee=o.y-_,Ce=o.z-E;return q*Pe+$e*Ee+Y*Ce>0&&(o.x=U,o.y=_,o.z=E,n.x=(o.x-U)/a,n.y=(o.y-_)/a,n.z=(o.z-E)/a),o}function di(i,e){e.set(0,0),i.forEach(n=>{e.x+=n.clientX,e.y+=n.clientY}),e.x/=i.length,e.y/=i.length}function hi(i,e){return ot(i)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class us{constructor(){this._listeners={}}addEventListener(e,n){const t=this._listeners;t[e]===void 0&&(t[e]=[]),t[e].indexOf(n)===-1&&t[e].push(n)}hasEventListener(e,n){const t=this._listeners;return t[e]!==void 0&&t[e].indexOf(n)!==-1}removeEventListener(e,n){const s=this._listeners[e];if(s!==void 0){const a=s.indexOf(n);a!==-1&&s.splice(a,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){const t=this._listeners[e.type];if(t!==void 0){e.target=this;const s=t.slice(0);for(let a=0,o=s.length;a<o;a++)s[a].call(this,e)}}}var ui;const ms="2.9.0",Kt=1/8,ps=/Mac/.test((ui=globalThis?.navigator)===null||ui===void 0?void 0:ui.platform);let B,Yi,Xt,mi,Re,G,J,Tt,kt,Xe,qe,pt,Gi,Zi,Ne,Ut,xt,$i,pi,Wi,fi,gi,qt;class Je extends us{static install(e){B=e.THREE,Yi=Object.freeze(new B.Vector3(0,0,0)),Xt=Object.freeze(new B.Vector3(0,1,0)),mi=Object.freeze(new B.Vector3(0,0,1)),Re=new B.Vector2,G=new B.Vector3,J=new B.Vector3,Tt=new B.Vector3,kt=new B.Vector3,Xe=new B.Vector3,qe=new B.Vector3,pt=new B.Vector3,Gi=new B.Vector3,Zi=new B.Vector3,Ne=new B.Spherical,Ut=new B.Spherical,xt=new B.Box3,$i=new B.Box3,pi=new B.Sphere,Wi=new B.Quaternion,fi=new B.Quaternion,gi=new B.Matrix4,qt=new B.Raycaster}static get ACTION(){return g}constructor(e,n){super(),this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.minDistance=Number.EPSILON,this.maxDistance=1/0,this.infinityDolly=!1,this.minZoom=.01,this.maxZoom=1/0,this.smoothTime=.25,this.draggingSmoothTime=.125,this.maxSpeed=1/0,this.azimuthRotateSpeed=1,this.polarRotateSpeed=1,this.dollySpeed=1,this.dollyDragInverted=!1,this.truckSpeed=2,this.dollyToCursor=!1,this.dragToOffset=!1,this.verticalDragToForward=!1,this.boundaryFriction=0,this.restThreshold=.01,this.colliderMeshes=[],this.cancel=()=>{},this._enabled=!0,this._state=g.NONE,this._viewport=null,this._changedDolly=0,this._changedZoom=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=new DOMRect,this._isDragging=!1,this._dragNeedsUpdate=!0,this._activePointers=[],this._lockedPointer=null,this._interactiveArea=new DOMRect(0,0,1,1),this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._isUserControllingOffset=!1,this._isUserControllingZoom=!1,this._lastDollyDirection=Ot.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new B.Vector3,this._focalOffsetVelocity=new B.Vector3,this._zoomVelocity={value:0},this._truckInternal=(_,E,w)=>{let C,k;if(mt(this._camera)){const L=G.copy(this._camera.position).sub(this._target),x=this._camera.getEffectiveFOV()*Pt,ne=L.length()*Math.tan(x*.5);C=this.truckSpeed*_*ne/this._elementRect.height,k=this.truckSpeed*E*ne/this._elementRect.height}else if(ot(this._camera)){const L=this._camera;C=_*(L.right-L.left)/L.zoom/this._elementRect.width,k=E*(L.top-L.bottom)/L.zoom/this._elementRect.height}else return;this.verticalDragToForward?(w?this.setFocalOffset(this._focalOffsetEnd.x+C,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(C,0,!0),this.forward(-k,!0)):w?this.setFocalOffset(this._focalOffsetEnd.x+C,this._focalOffsetEnd.y+k,this._focalOffsetEnd.z,!0):this.truck(C,k,!0)},this._rotateInternal=(_,E)=>{const w=Ct*this.azimuthRotateSpeed*_/this._elementRect.height,C=Ct*this.polarRotateSpeed*E/this._elementRect.height;this.rotate(w,C,!0)},this._dollyInternal=(_,E,w)=>{const C=Math.pow(.95,-_*this.dollySpeed),k=this._sphericalEnd.radius,L=this._sphericalEnd.radius*C,x=Ze(L,this.minDistance,this.maxDistance),ne=x-L;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(L,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(ne,!0),this._dollyToNoClamp(x,!0)):this._dollyToNoClamp(x,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?L:x)-k,this._dollyControlCoord.set(E,w)),this._lastDollyDirection=Math.sign(-_)},this._zoomInternal=(_,E,w)=>{const C=Math.pow(.95,_*this.dollySpeed),k=this._zoom,L=this._zoom*C;this.zoomTo(L,!0),this.dollyToCursor&&(this._changedZoom+=L-k,this._dollyControlCoord.set(E,w))},typeof B>"u"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=e,this._yAxisUpSpace=new B.Quaternion().setFromUnitVectors(this._camera.up,Xt),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=g.NONE,this._target=new B.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new B.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new B.Spherical().setFromVector3(G.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._lastDistance=this._spherical.radius,this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._lastZoom=this._zoom,this._nearPlaneCorners=[new B.Vector3,new B.Vector3,new B.Vector3,new B.Vector3],this._updateNearPlaneCorners(),this._boundary=new B.Box3(new B.Vector3(-1/0,-1/0,-1/0),new B.Vector3(1/0,1/0,1/0)),this._cameraUp0=this._camera.up.clone(),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlCoord=new B.Vector2,this.mouseButtons={left:g.ROTATE,middle:g.DOLLY,right:g.TRUCK,wheel:mt(this._camera)?g.DOLLY:ot(this._camera)?g.ZOOM:g.NONE},this.touches={one:g.TOUCH_ROTATE,two:mt(this._camera)?g.TOUCH_DOLLY_TRUCK:ot(this._camera)?g.TOUCH_ZOOM_TRUCK:g.NONE,three:g.TOUCH_TRUCK};const t=new B.Vector2,s=new B.Vector2,a=new B.Vector2,o=_=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const C=this._domElement.getBoundingClientRect(),k=_.clientX/C.width,L=_.clientY/C.height;if(k<this._interactiveArea.left||k>this._interactiveArea.right||L<this._interactiveArea.top||L>this._interactiveArea.bottom)return}const E=_.pointerType!=="mouse"?null:(_.buttons&le.LEFT)===le.LEFT?le.LEFT:(_.buttons&le.MIDDLE)===le.MIDDLE?le.MIDDLE:(_.buttons&le.RIGHT)===le.RIGHT?le.RIGHT:null;if(E!==null){const C=this._findPointerByMouseButton(E);C&&this._disposePointer(C)}if((_.buttons&le.LEFT)===le.LEFT&&this._lockedPointer)return;const w={pointerId:_.pointerId,clientX:_.clientX,clientY:_.clientY,deltaX:0,deltaY:0,mouseButton:E};this._activePointers.push(w),this._domElement.ownerDocument.removeEventListener("pointermove",r,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.addEventListener("pointermove",r,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",h),this._isDragging=!0,v(_)},r=_=>{_.cancelable&&_.preventDefault();const E=_.pointerId,w=this._lockedPointer||this._findPointerById(E);if(w){if(w.clientX=_.clientX,w.clientY=_.clientY,w.deltaX=_.movementX,w.deltaY=_.movementY,this._state=0,_.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(_.buttons&le.LEFT)===le.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(_.buttons&le.MIDDLE)===le.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(_.buttons&le.RIGHT)===le.RIGHT&&(this._state=this._state|this.mouseButtons.right);y()}},h=_=>{const E=this._findPointerById(_.pointerId);if(!(E&&E===this._lockedPointer)){if(E&&this._disposePointer(E),_.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=g.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=g.NONE;A()}};let c=-1;const u=_=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===g.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const L=this._domElement.getBoundingClientRect(),x=_.clientX/L.width,ne=_.clientY/L.height;if(x<this._interactiveArea.left||x>this._interactiveArea.right||ne<this._interactiveArea.top||ne>this._interactiveArea.bottom)return}if(_.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===g.ROTATE||this.mouseButtons.wheel===g.TRUCK){const L=performance.now();c-L<1e3&&this._getClientRect(this._elementRect),c=L}const E=ps?-1:-3,w=_.deltaMode===1?_.deltaY/E:_.deltaY/(E*10),C=this.dollyToCursor?(_.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,k=this.dollyToCursor?(_.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case g.ROTATE:{this._rotateInternal(_.deltaX,_.deltaY),this._isUserControllingRotate=!0;break}case g.TRUCK:{this._truckInternal(_.deltaX,_.deltaY,!1),this._isUserControllingTruck=!0;break}case g.OFFSET:{this._truckInternal(_.deltaX,_.deltaY,!0),this._isUserControllingOffset=!0;break}case g.DOLLY:{this._dollyInternal(-w,C,k),this._isUserControllingDolly=!0;break}case g.ZOOM:{this._zoomInternal(-w,C,k),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},f=_=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===Je.ACTION.NONE){const E=_ instanceof PointerEvent?_.pointerId:0,w=this._findPointerById(E);w&&this._disposePointer(w),this._domElement.ownerDocument.removeEventListener("pointermove",r,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h);return}_.preventDefault()}},v=_=>{if(!this._enabled)return;if(di(this._activePointers,Re),this._getClientRect(this._elementRect),t.copy(Re),s.copy(Re),this._activePointers.length>=2){const w=Re.x-this._activePointers[1].clientX,C=Re.y-this._activePointers[1].clientY,k=Math.sqrt(w*w+C*C);a.set(0,k);const L=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,x=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;s.set(L,x)}if(this._state=0,!_)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in _&&_.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(_.buttons&le.LEFT)===le.LEFT&&(this._state=this._state|this.mouseButtons.left),(_.buttons&le.MIDDLE)===le.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(_.buttons&le.RIGHT)===le.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&g.ROTATE)===g.ROTATE||(this._state&g.TOUCH_ROTATE)===g.TOUCH_ROTATE||(this._state&g.TOUCH_DOLLY_ROTATE)===g.TOUCH_DOLLY_ROTATE||(this._state&g.TOUCH_ZOOM_ROTATE)===g.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&g.TRUCK)===g.TRUCK||(this._state&g.TOUCH_TRUCK)===g.TOUCH_TRUCK||(this._state&g.TOUCH_DOLLY_TRUCK)===g.TOUCH_DOLLY_TRUCK||(this._state&g.TOUCH_ZOOM_TRUCK)===g.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&g.DOLLY)===g.DOLLY||(this._state&g.TOUCH_DOLLY)===g.TOUCH_DOLLY||(this._state&g.TOUCH_DOLLY_TRUCK)===g.TOUCH_DOLLY_TRUCK||(this._state&g.TOUCH_DOLLY_OFFSET)===g.TOUCH_DOLLY_OFFSET||(this._state&g.TOUCH_DOLLY_ROTATE)===g.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&g.ZOOM)===g.ZOOM||(this._state&g.TOUCH_ZOOM)===g.TOUCH_ZOOM||(this._state&g.TOUCH_ZOOM_TRUCK)===g.TOUCH_ZOOM_TRUCK||(this._state&g.TOUCH_ZOOM_OFFSET)===g.TOUCH_ZOOM_OFFSET||(this._state&g.TOUCH_ZOOM_ROTATE)===g.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&g.OFFSET)===g.OFFSET||(this._state&g.TOUCH_OFFSET)===g.TOUCH_OFFSET||(this._state&g.TOUCH_DOLLY_OFFSET)===g.TOUCH_DOLLY_OFFSET||(this._state&g.TOUCH_ZOOM_OFFSET)===g.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},y=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,di(this._activePointers,Re);const E=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,w=E?-E.deltaX:s.x-Re.x,C=E?-E.deltaY:s.y-Re.y;if(s.copy(Re),((this._state&g.ROTATE)===g.ROTATE||(this._state&g.TOUCH_ROTATE)===g.TOUCH_ROTATE||(this._state&g.TOUCH_DOLLY_ROTATE)===g.TOUCH_DOLLY_ROTATE||(this._state&g.TOUCH_ZOOM_ROTATE)===g.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(w,C),this._isUserControllingRotate=!0),(this._state&g.DOLLY)===g.DOLLY||(this._state&g.ZOOM)===g.ZOOM){const k=this.dollyToCursor?(t.x-this._elementRect.x)/this._elementRect.width*2-1:0,L=this.dollyToCursor?(t.y-this._elementRect.y)/this._elementRect.height*-2+1:0,x=this.dollyDragInverted?-1:1;(this._state&g.DOLLY)===g.DOLLY?(this._dollyInternal(x*C*Kt,k,L),this._isUserControllingDolly=!0):(this._zoomInternal(x*C*Kt,k,L),this._isUserControllingZoom=!0)}if((this._state&g.TOUCH_DOLLY)===g.TOUCH_DOLLY||(this._state&g.TOUCH_ZOOM)===g.TOUCH_ZOOM||(this._state&g.TOUCH_DOLLY_TRUCK)===g.TOUCH_DOLLY_TRUCK||(this._state&g.TOUCH_ZOOM_TRUCK)===g.TOUCH_ZOOM_TRUCK||(this._state&g.TOUCH_DOLLY_OFFSET)===g.TOUCH_DOLLY_OFFSET||(this._state&g.TOUCH_ZOOM_OFFSET)===g.TOUCH_ZOOM_OFFSET||(this._state&g.TOUCH_DOLLY_ROTATE)===g.TOUCH_DOLLY_ROTATE||(this._state&g.TOUCH_ZOOM_ROTATE)===g.TOUCH_ZOOM_ROTATE){const k=Re.x-this._activePointers[1].clientX,L=Re.y-this._activePointers[1].clientY,x=Math.sqrt(k*k+L*L),ne=a.y-x;a.set(0,x);const q=this.dollyToCursor?(s.x-this._elementRect.x)/this._elementRect.width*2-1:0,$e=this.dollyToCursor?(s.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&g.TOUCH_DOLLY)===g.TOUCH_DOLLY||(this._state&g.TOUCH_DOLLY_ROTATE)===g.TOUCH_DOLLY_ROTATE||(this._state&g.TOUCH_DOLLY_TRUCK)===g.TOUCH_DOLLY_TRUCK||(this._state&g.TOUCH_DOLLY_OFFSET)===g.TOUCH_DOLLY_OFFSET?(this._dollyInternal(ne*Kt,q,$e),this._isUserControllingDolly=!0):(this._zoomInternal(ne*Kt,q,$e),this._isUserControllingZoom=!0)}((this._state&g.TRUCK)===g.TRUCK||(this._state&g.TOUCH_TRUCK)===g.TOUCH_TRUCK||(this._state&g.TOUCH_DOLLY_TRUCK)===g.TOUCH_DOLLY_TRUCK||(this._state&g.TOUCH_ZOOM_TRUCK)===g.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(w,C,!1),this._isUserControllingTruck=!0),((this._state&g.OFFSET)===g.OFFSET||(this._state&g.TOUCH_OFFSET)===g.TOUCH_OFFSET||(this._state&g.TOUCH_DOLLY_OFFSET)===g.TOUCH_DOLLY_OFFSET||(this._state&g.TOUCH_ZOOM_OFFSET)===g.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(w,C,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},A=()=>{di(this._activePointers,Re),s.copy(Re),this._dragNeedsUpdate=!1,(this._activePointers.length===0||this._activePointers.length===1&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),this._activePointers.length===0&&this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointermove",r,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",r,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",I),this._domElement.ownerDocument.addEventListener("pointerlockerror",U),this._domElement.ownerDocument.addEventListener("pointermove",r,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",h),v())},this.unlockPointer=()=>{var _,E,w;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(_=this._domElement)===null||_===void 0||_.ownerDocument.exitPointerLock(),(E=this._domElement)===null||E===void 0||E.ownerDocument.removeEventListener("pointerlockchange",I),(w=this._domElement)===null||w===void 0||w.ownerDocument.removeEventListener("pointerlockerror",U),this.cancel()};const I=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},U=()=>{this.unlockPointer()};this._addAllEventListeners=_=>{this._domElement=_,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",o),this._domElement.addEventListener("pointercancel",h),this._domElement.addEventListener("wheel",u,{passive:!1}),this._domElement.addEventListener("contextmenu",f)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",o),this._domElement.removeEventListener("pointercancel",h),this._domElement.removeEventListener("wheel",u,{passive:!1}),this._domElement.removeEventListener("contextmenu",f),this._domElement.ownerDocument.removeEventListener("pointermove",r,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.removeEventListener("pointerlockchange",I),this._domElement.ownerDocument.removeEventListener("pointerlockerror",U))},this.cancel=()=>{this._state!==g.NONE&&(this._state=g.NONE,this._activePointers.length=0,A())},n&&this.connect(n),this.update(0)}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._domElement&&(e?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}set interactiveArea(e){this._interactiveArea.width=Ze(e.width,0,1),this._interactiveArea.height=Ze(e.height,0,1),this._interactiveArea.x=Ze(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=Ze(e.y,0,1-this._interactiveArea.height)}addEventListener(e,n){super.addEventListener(e,n)}removeEventListener(e,n){super.removeEventListener(e,n)}rotate(e,n,t=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+n,t)}rotateAzimuthTo(e,n=!1){return this.rotateTo(e,this._sphericalEnd.phi,n)}rotatePolarTo(e,n=!1){return this.rotateTo(this._sphericalEnd.theta,e,n)}rotateTo(e,n,t=!1){this._isUserControllingRotate=!1;const s=Ze(e,this.minAzimuthAngle,this.maxAzimuthAngle),a=Ze(n,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=s,this._sphericalEnd.phi=a,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,t||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const o=!t||ie(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&ie(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(o)}dolly(e,n=!1){return this.dollyTo(this._sphericalEnd.radius-e,n)}dollyTo(e,n=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=Ot.NONE,this._changedDolly=0,this._dollyToNoClamp(Ze(e,this.minDistance,this.maxDistance),n)}_dollyToNoClamp(e,n=!1){const t=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const o=this._collisionTest(),r=ie(o,this._spherical.radius);if(!(t>e)&&r)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,o)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,n||(this._spherical.radius=this._sphericalEnd.radius);const a=!n||ie(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(a)}dollyInFixed(e,n=!1){this._targetEnd.add(this._getCameraDirection(kt).multiplyScalar(e)),n||this._target.copy(this._targetEnd);const t=!n||ie(this._target.x,this._targetEnd.x,this.restThreshold)&&ie(this._target.y,this._targetEnd.y,this.restThreshold)&&ie(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(t)}zoom(e,n=!1){return this.zoomTo(this._zoomEnd+e,n)}zoomTo(e,n=!1){this._isUserControllingZoom=!1,this._zoomEnd=Ze(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,n||(this._zoom=this._zoomEnd);const t=!n||ie(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(t)}pan(e,n,t=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,n,t)}truck(e,n,t=!1){this._camera.updateMatrix(),Xe.setFromMatrixColumn(this._camera.matrix,0),qe.setFromMatrixColumn(this._camera.matrix,1),Xe.multiplyScalar(e),qe.multiplyScalar(-n);const s=G.copy(Xe).add(qe),a=J.copy(this._targetEnd).add(s);return this.moveTo(a.x,a.y,a.z,t)}forward(e,n=!1){G.setFromMatrixColumn(this._camera.matrix,0),G.crossVectors(this._camera.up,G),G.multiplyScalar(e);const t=J.copy(this._targetEnd).add(G);return this.moveTo(t.x,t.y,t.z,n)}elevate(e,n=!1){return G.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+G.x,this._targetEnd.y+G.y,this._targetEnd.z+G.z,n)}moveTo(e,n,t,s=!1){this._isUserControllingTruck=!1;const a=G.set(e,n,t).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,a,this.boundaryFriction),this._needsUpdate=!0,s||this._target.copy(this._targetEnd);const o=!s||ie(this._target.x,this._targetEnd.x,this.restThreshold)&&ie(this._target.y,this._targetEnd.y,this.restThreshold)&&ie(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(o)}lookInDirectionOf(e,n,t,s=!1){const r=G.set(e,n,t).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(r.x,r.y,r.z,s)}fitToBox(e,n,{cover:t=!1,paddingLeft:s=0,paddingRight:a=0,paddingBottom:o=0,paddingTop:r=0}={}){const h=[],c=e.isBox3?xt.copy(e):xt.setFromObject(e);c.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const u=Hi(this._sphericalEnd.theta,Bi),f=Hi(this._sphericalEnd.phi,Bi);h.push(this.rotateTo(u,f,n));const v=G.setFromSpherical(this._sphericalEnd).normalize(),y=Wi.setFromUnitVectors(v,mi),A=ie(Math.abs(v.y),1);A&&y.multiply(fi.setFromAxisAngle(Xt,u)),y.multiply(this._yAxisUpSpaceInverse);const I=$i.makeEmpty();J.copy(c.min).applyQuaternion(y),I.expandByPoint(J),J.copy(c.min).setX(c.max.x).applyQuaternion(y),I.expandByPoint(J),J.copy(c.min).setY(c.max.y).applyQuaternion(y),I.expandByPoint(J),J.copy(c.max).setZ(c.min.z).applyQuaternion(y),I.expandByPoint(J),J.copy(c.min).setZ(c.max.z).applyQuaternion(y),I.expandByPoint(J),J.copy(c.max).setY(c.min.y).applyQuaternion(y),I.expandByPoint(J),J.copy(c.max).setX(c.min.x).applyQuaternion(y),I.expandByPoint(J),J.copy(c.max).applyQuaternion(y),I.expandByPoint(J),I.min.x-=s,I.min.y-=o,I.max.x+=a,I.max.y+=r,y.setFromUnitVectors(mi,v),A&&y.premultiply(fi.invert()),y.premultiply(this._yAxisUpSpace);const U=I.getSize(G),_=I.getCenter(J).applyQuaternion(y);if(mt(this._camera)){const E=this.getDistanceToFitBox(U.x,U.y,U.z,t);h.push(this.moveTo(_.x,_.y,_.z,n)),h.push(this.dollyTo(E,n)),h.push(this.setFocalOffset(0,0,0,n))}else if(ot(this._camera)){const E=this._camera,w=E.right-E.left,C=E.top-E.bottom,k=t?Math.max(w/U.x,C/U.y):Math.min(w/U.x,C/U.y);h.push(this.moveTo(_.x,_.y,_.z,n)),h.push(this.zoomTo(k,n)),h.push(this.setFocalOffset(0,0,0,n))}return Promise.all(h)}fitToSphere(e,n){const t=[],a="isObject3D"in e?Je.createBoundingSphere(e,pi):pi.copy(e);if(t.push(this.moveTo(a.center.x,a.center.y,a.center.z,n)),mt(this._camera)){const o=this.getDistanceToFitSphere(a.radius);t.push(this.dollyTo(o,n))}else if(ot(this._camera)){const o=this._camera.right-this._camera.left,r=this._camera.top-this._camera.bottom,h=2*a.radius,c=Math.min(o/h,r/h);t.push(this.zoomTo(c,n))}return t.push(this.setFocalOffset(0,0,0,n)),Promise.all(t)}setLookAt(e,n,t,s,a,o,r=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ot.NONE,this._changedDolly=0;const h=J.set(s,a,o),c=G.set(e,n,t);this._targetEnd.copy(h),this._sphericalEnd.setFromVector3(c.sub(h).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,r||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const u=!r||ie(this._target.x,this._targetEnd.x,this.restThreshold)&&ie(this._target.y,this._targetEnd.y,this.restThreshold)&&ie(this._target.z,this._targetEnd.z,this.restThreshold)&&ie(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&ie(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&ie(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(u)}lerpLookAt(e,n,t,s,a,o,r,h,c,u,f,v,y,A=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ot.NONE,this._changedDolly=0;const I=G.set(s,a,o),U=J.set(e,n,t);Ne.setFromVector3(U.sub(I).applyQuaternion(this._yAxisUpSpace));const _=Tt.set(u,f,v),E=J.set(r,h,c);Ut.setFromVector3(E.sub(_).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(I.lerp(_,y));const w=Ut.theta-Ne.theta,C=Ut.phi-Ne.phi,k=Ut.radius-Ne.radius;this._sphericalEnd.set(Ne.radius+k*y,Ne.phi+C*y,Ne.theta+w*y),this.normalizeRotations(),this._needsUpdate=!0,A||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const L=!A||ie(this._target.x,this._targetEnd.x,this.restThreshold)&&ie(this._target.y,this._targetEnd.y,this.restThreshold)&&ie(this._target.z,this._targetEnd.z,this.restThreshold)&&ie(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&ie(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&ie(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(L)}setPosition(e,n,t,s=!1){return this.setLookAt(e,n,t,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,s)}setTarget(e,n,t,s=!1){const a=this.getPosition(G),o=this.setLookAt(a.x,a.y,a.z,e,n,t,s);return this._sphericalEnd.phi=Ze(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),o}setFocalOffset(e,n,t,s=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,n,t),this._needsUpdate=!0,s||this._focalOffset.copy(this._focalOffsetEnd);const a=!s||ie(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&ie(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&ie(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(a)}setOrbitPoint(e,n,t){this._camera.updateMatrixWorld(),Xe.setFromMatrixColumn(this._camera.matrixWorldInverse,0),qe.setFromMatrixColumn(this._camera.matrixWorldInverse,1),pt.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const s=G.set(e,n,t),a=s.distanceTo(this._camera.position),o=s.sub(this._camera.position);Xe.multiplyScalar(o.x),qe.multiplyScalar(o.y),pt.multiplyScalar(o.z),G.copy(Xe).add(qe).add(pt),G.z=G.z+a,this.dollyTo(a,!1),this.setFocalOffset(-G.x,G.y,-G.z,!1),this.moveTo(e,n,t,!1)}setBoundary(e){if(!e){this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),this._needsUpdate=!0;return}this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,n,t,s){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new B.Vector4,typeof e=="number"?this._viewport.set(e,n,t,s):this._viewport.copy(e)}getDistanceToFitBox(e,n,t,s=!1){if(hi(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const a=e/n,o=this._camera.getEffectiveFOV()*Pt,r=this._camera.aspect;return((s?a>r:a<r)?n:e/r)*.5/Math.tan(o*.5)+t*.5}getDistanceToFitSphere(e){if(hi(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const n=this._camera.getEffectiveFOV()*Pt,t=Math.atan(Math.tan(n*.5)*this._camera.aspect)*2,s=1<this._camera.aspect?n:t;return e/Math.sin(s*.5)}getTarget(e,n=!0){return(e&&e.isVector3?e:new B.Vector3).copy(n?this._targetEnd:this._target)}getPosition(e,n=!0){return(e&&e.isVector3?e:new B.Vector3).setFromSpherical(n?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(n?this._targetEnd:this._target)}getSpherical(e,n=!0){return(e||new B.Spherical).copy(n?this._sphericalEnd:this._spherical)}getFocalOffset(e,n=!0){return(e&&e.isVector3?e:new B.Vector3).copy(n?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%Ct,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=Ct),this._spherical.theta+=Ct*Math.round((this._sphericalEnd.theta-this._spherical.theta)/Ct)}stop(){this._focalOffset.copy(this._focalOffsetEnd),this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd),this._zoom=this._zoomEnd}reset(e=!1){if(!ie(this._camera.up.x,this._cameraUp0.x)||!ie(this._camera.up.y,this._cameraUp0.y)||!ie(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const t=this.getPosition(G);this.updateCameraUp(),this.setPosition(t.x,t.y,t.z)}const n=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,e),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,e),this.zoomTo(this._zoom0,e)];return Promise.all(n)}saveState(){this._cameraUp0.copy(this._camera.up),this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,Xt),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=G.subVectors(this._target,this._camera.position).normalize(),n=J.crossVectors(e,this._camera.up);this._camera.up.crossVectors(n,e).normalize(),this._camera.updateMatrixWorld();const t=this.getPosition(G);this.updateCameraUp(),this.setPosition(t.x,t.y,t.z)}update(e){const n=this._sphericalEnd.theta-this._spherical.theta,t=this._sphericalEnd.phi-this._spherical.phi,s=this._sphericalEnd.radius-this._spherical.radius,a=Gi.subVectors(this._targetEnd,this._target),o=Zi.subVectors(this._focalOffsetEnd,this._focalOffset),r=this._zoomEnd-this._zoom;if(re(n))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const f=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=Wt(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,f,1/0,e),this._needsUpdate=!0}if(re(t))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const f=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=Wt(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,f,1/0,e),this._needsUpdate=!0}if(re(s))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const f=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=Wt(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,f,this.maxSpeed,e),this._needsUpdate=!0}if(re(a.x)&&re(a.y)&&re(a.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const f=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Vi(this._target,this._targetEnd,this._targetVelocity,f,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(re(o.x)&&re(o.y)&&re(o.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const f=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Vi(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,f,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(re(r))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const f=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=Wt(this._zoom,this._zoomEnd,this._zoomVelocity,f,1/0,e)}if(this.dollyToCursor){if(mt(this._camera)&&this._changedDolly!==0){const f=this._spherical.radius-this._lastDistance,v=this._camera,y=this._getCameraDirection(kt),A=G.copy(y).cross(v.up).normalize();A.lengthSq()===0&&(A.x=1);const I=J.crossVectors(A,y),U=this._sphericalEnd.radius*Math.tan(v.getEffectiveFOV()*Pt*.5),E=(this._sphericalEnd.radius-f-this._sphericalEnd.radius)/this._sphericalEnd.radius,w=Tt.copy(this._targetEnd).add(A.multiplyScalar(this._dollyControlCoord.x*U*v.aspect)).add(I.multiplyScalar(this._dollyControlCoord.y*U)),C=G.copy(this._targetEnd).lerp(w,E),k=this._lastDollyDirection===Ot.IN&&this._spherical.radius<=this.minDistance,L=this._lastDollyDirection===Ot.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(k||L)){this._sphericalEnd.radius-=f,this._spherical.radius-=f;const ne=J.copy(y).multiplyScalar(-f);C.add(ne)}this._boundary.clampPoint(C,C);const x=J.subVectors(C,this._targetEnd);this._targetEnd.copy(C),this._target.add(x),this._changedDolly-=f,re(this._changedDolly)&&(this._changedDolly=0)}else if(ot(this._camera)&&this._changedZoom!==0){const f=this._zoom-this._lastZoom,v=this._camera,y=G.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(v.near+v.far)/(v.near-v.far)).unproject(v),A=J.set(0,0,-1).applyQuaternion(v.quaternion),I=Tt.copy(y).add(A.multiplyScalar(-y.dot(v.up))),_=-(this._zoom-f-this._zoom)/this._zoom,E=this._getCameraDirection(kt),w=this._targetEnd.dot(E),C=G.copy(this._targetEnd).lerp(I,_),k=C.dot(E),L=E.multiplyScalar(k-w);C.sub(L),this._boundary.clampPoint(C,C);const x=J.subVectors(C,this._targetEnd);this._targetEnd.copy(C),this._target.add(x),this._changedZoom-=f,re(this._changedZoom)&&(this._changedZoom=0)}}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0),this._dragNeedsUpdate=!0;const h=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,h),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!re(this._focalOffset.x)||!re(this._focalOffset.y)||!re(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),Xe.setFromMatrixColumn(this._camera.matrix,0),qe.setFromMatrixColumn(this._camera.matrix,1),pt.setFromMatrixColumn(this._camera.matrix,2),Xe.multiplyScalar(this._focalOffset.x),qe.multiplyScalar(-this._focalOffset.y),pt.multiplyScalar(this._focalOffset.z),G.copy(Xe).add(qe).add(pt),this._camera.position.add(G)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),G.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const u=this._needsUpdate;return u&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):u?(this.dispatchEvent({type:"update"}),re(n,this.restThreshold)&&re(t,this.restThreshold)&&re(s,this.restThreshold)&&re(a.x,this.restThreshold)&&re(a.y,this.restThreshold)&&re(a.z,this.restThreshold)&&re(o.x,this.restThreshold)&&re(o.y,this.restThreshold)&&re(o.z,this.restThreshold)&&re(r,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!u&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=u,this._needsUpdate=!1,u}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:Lt(this.maxDistance),minZoom:this.minZoom,maxZoom:Lt(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:Lt(this.maxPolarAngle),minAzimuthAngle:Lt(this.minAzimuthAngle),maxAzimuthAngle:Lt(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,verticalDragToForward:this.verticalDragToForward,target:this._targetEnd.toArray(),position:G.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),zoom:this._zoomEnd,focalOffset:this._focalOffsetEnd.toArray(),target0:this._target0.toArray(),position0:this._position0.toArray(),zoom0:this._zoom0,focalOffset0:this._focalOffset0.toArray()})}fromJSON(e,n=!1){const t=JSON.parse(e);this.enabled=t.enabled,this.minDistance=t.minDistance,this.maxDistance=It(t.maxDistance),this.minZoom=t.minZoom,this.maxZoom=It(t.maxZoom),this.minPolarAngle=t.minPolarAngle,this.maxPolarAngle=It(t.maxPolarAngle),this.minAzimuthAngle=It(t.minAzimuthAngle),this.maxAzimuthAngle=It(t.maxAzimuthAngle),this.smoothTime=t.smoothTime,this.draggingSmoothTime=t.draggingSmoothTime,this.dollySpeed=t.dollySpeed,this.truckSpeed=t.truckSpeed,this.dollyToCursor=t.dollyToCursor,this.verticalDragToForward=t.verticalDragToForward,this._target0.fromArray(t.target0),this._position0.fromArray(t.position0),this._zoom0=t.zoom0,this._focalOffset0.fromArray(t.focalOffset0),this.moveTo(t.target[0],t.target[1],t.target[2],n),Ne.setFromVector3(G.fromArray(t.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(Ne.theta,Ne.phi,n),this.dollyTo(Ne.radius,n),this.zoomTo(t.zoom,n),this.setFocalOffset(t.focalOffset[0],t.focalOffset[1],t.focalOffset[2],n),this._needsUpdate=!0}connect(e){if(this._domElement){console.warn("camera-controls is already connected.");return}e.setAttribute("data-camera-controls-version",ms),this._addAllEventListeners(e),this._getClientRect(this._elementRect)}disconnect(){this.cancel(),this._removeAllEventListeners(),this._domElement&&(this._domElement.removeAttribute("data-camera-controls-version"),this._domElement=void 0)}dispose(){this.removeAllEventListeners(),this.disconnect()}_getTargetDirection(e){return e.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(e){return this._getTargetDirection(e).negate()}_findPointerById(e){return this._activePointers.find(n=>n.pointerId===e)}_findPointerByMouseButton(e){return this._activePointers.find(n=>n.mouseButton===e)}_disposePointer(e){this._activePointers.splice(this._activePointers.indexOf(e),1)}_encloseToBoundary(e,n,t){const s=n.lengthSq();if(s===0)return e;const a=J.copy(n).add(e),r=this._boundary.clampPoint(a,Tt).sub(a),h=r.lengthSq();if(h===0)return e.add(n);if(h===s)return e;if(t===0)return e.add(n).add(r);{const c=1+t*h/n.dot(r);return e.add(J.copy(n).multiplyScalar(c)).add(r.multiplyScalar(1-t))}}_updateNearPlaneCorners(){if(mt(this._camera)){const e=this._camera,n=e.near,t=e.getEffectiveFOV()*Pt,s=Math.tan(t*.5)*n,a=s*e.aspect;this._nearPlaneCorners[0].set(-a,-s,0),this._nearPlaneCorners[1].set(a,-s,0),this._nearPlaneCorners[2].set(a,s,0),this._nearPlaneCorners[3].set(-a,s,0)}else if(ot(this._camera)){const e=this._camera,n=1/e.zoom,t=e.left*n,s=e.right*n,a=e.top*n,o=e.bottom*n;this._nearPlaneCorners[0].set(t,a,0),this._nearPlaneCorners[1].set(s,a,0),this._nearPlaneCorners[2].set(s,o,0),this._nearPlaneCorners[3].set(t,o,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||hi(this._camera,"_collisionTest"))return e;const t=this._getTargetDirection(kt);gi.lookAt(Yi,t,this._camera.up);for(let s=0;s<4;s++){const a=J.copy(this._nearPlaneCorners[s]);a.applyMatrix4(gi);const o=Tt.addVectors(this._target,a);qt.set(o,t),qt.far=this._spherical.radius+1;const r=qt.intersectObjects(this.colliderMeshes);r.length!==0&&r[0].distance<e&&(e=r[0].distance)}return e}_getClientRect(e){if(!this._domElement)return;const n=this._domElement.getBoundingClientRect();return e.x=n.left,e.y=n.top,this._viewport?(e.x+=this._viewport.x,e.y+=n.height-this._viewport.w-this._viewport.y,e.width=this._viewport.z,e.height=this._viewport.w):(e.width=n.width,e.height=n.height),e}_createOnRestPromise(e){return e?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(n=>{const t=()=>{this.removeEventListener("rest",t),n()};this.addEventListener("rest",t)}))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(e){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(e){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(e,n=new B.Sphere){const t=n,s=t.center;xt.makeEmpty(),e.traverseVisible(o=>{o.isMesh&&xt.expandByObject(o)}),xt.getCenter(s);let a=0;return e.traverseVisible(o=>{if(!o.isMesh)return;const r=o,h=r.geometry.clone();h.applyMatrix4(r.matrixWorld);const u=h.attributes.position;for(let f=0,v=u.count;f<v;f++)G.fromBufferAttribute(u,f),a=Math.max(a,s.distanceToSquared(G))}),t.radius=Math.sqrt(a),t}}const ii=i=>{const[e,n]=T.useState(i.options[i.index]),t=()=>{i.onToggle(!i.open)},s=a=>{a!==e&&(i.onSelect(a),n(a)),i.onToggle(!1)};return m.jsxs("div",{className:`dropdown ${i.up===!0?"up":""}`,children:[m.jsx("div",{className:"dropdown-toggle",onClick:t,children:`${i.title}: ${e}`}),i.open&&m.jsx("ul",{className:"dropdown-menu",children:i.options.map(a=>m.jsx("li",{onClick:()=>s(a),children:a},a))})]})},ft=T.forwardRef(function(e,n){const t=["Renderer","Depth","Normals","UVs","Wireframe"],[s,a]=T.useState("Renderer"),[o,r]=T.useState(!1),[h,c]=T.useState(!1),[u,f]=T.useState(!1);return m.jsxs("div",{className:"CameraWindow",children:[m.jsx("div",{ref:n,className:"clickable",onClick:()=>{u&&f(!1)}}),m.jsxs("div",{className:"options",children:[m.jsx(ii,{title:"Camera",index:e.options.indexOf(e.camera.name),open:u,options:e.options,onSelect:e.onSelectCamera,onToggle:v=>{f(v)},up:!0}),m.jsx(ii,{title:"Mode",index:t.indexOf(s),open:h,options:t,onSelect:v=>{if(v===s)return;const y=v;e.onSelectRenderMode(y),a(y)},onToggle:v=>{o&&r(!1),c(v)},up:!0})]})]})});class fs extends p.ShaderMaterial{constructor(e){super({extensions:{derivatives:!0},glslVersion:p.GLSL3,side:p.DoubleSide,transparent:!0,uniforms:{uScale:{value:e?.scale!==void 0?e?.scale:.1},uDivisions:{value:e?.divisions!==void 0?e?.divisions:10},uColor:{value:e?.color!==void 0?e?.color:new p.Color(16777215)},uDistance:{value:e?.distance!==void 0?e?.distance:1e4},uSubgridOpacity:{value:e?.subgridOpacity!==void 0?e?.subgridOpacity:.15},uGridOpacity:{value:e?.gridOpacity!==void 0?e?.gridOpacity:.25}},vertexShader:`out vec3 worldPosition;
|
31
36
|
uniform float uDistance;
|
32
37
|
|
33
38
|
void main() {
|
@@ -103,7 +108,7 @@ C11,8.22,10.74,8,10.43,8z`})});function hn(e){return u.jsx(sn.Reorder.Item,{valu
|
|
103
108
|
fragColor.a = mix(fragColor.a, baseOpacity * uGridOpacity, nextGrid);
|
104
109
|
|
105
110
|
if (fragColor.a <= 0.0) discard;
|
106
|
-
}`,name:"InfiniteGrid",depthWrite:!1})}}class
|
111
|
+
}`,name:"InfiniteGrid",depthWrite:!1})}}class gs extends p.Mesh{gridMaterial;constructor(){const e=new fs;super(new p.PlaneGeometry(2,2),e),this.gridMaterial=e,this.frustumCulled=!1,this.name="InfiniteGridHelper",this.position.y=.1}update(){this.gridMaterial.needsUpdate=!0}}const _s=`#include <common>
|
107
112
|
#include <batching_pars_vertex>
|
108
113
|
#include <uv_pars_vertex>
|
109
114
|
#include <color_pars_vertex>
|
@@ -133,7 +138,7 @@ void main() {
|
|
133
138
|
#include <logdepthbuf_vertex>
|
134
139
|
#include <clipping_planes_vertex>
|
135
140
|
#include <worldpos_vertex>
|
136
|
-
}`,
|
141
|
+
}`,vs=`
|
137
142
|
#include <common>
|
138
143
|
#include <uv_pars_fragment>
|
139
144
|
#include <clipping_planes_pars_fragment>
|
@@ -141,4 +146,4 @@ void main() {
|
|
141
146
|
void main() {
|
142
147
|
#include <clipping_planes_fragment>
|
143
148
|
gl_FragColor = vec4(vec3(vUv, 0.0), 1.0);
|
144
|
-
}`;class xa extends h.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:Ea,fragmentShader:Sa})}}let Te,It=!1,X=null,re=null,De=null,Ae=null,Qe="Renderer",xt="Renderer",an="Renderer",rn="Renderer";function Ca(e){const n=e.three.app.appID,a=b.useMemo(()=>new Map,[]),t=b.useMemo(()=>new Map,[]),i=b.useMemo(()=>new Map,[]),o=b.useMemo(()=>new Map,[]),l=b.useMemo(()=>new h.Scene,[]),s=b.useMemo(()=>new h.Group,[]),f=b.useMemo(()=>new ya,[]),d=b.useMemo(()=>new h.AxesHelper(500),[]),m=b.useMemo(()=>new h.AxesHelper(100),[]),y=b.useMemo(()=>new h.MeshDepthMaterial,[]),E=b.useMemo(()=>new h.MeshNormalMaterial,[]),C=b.useMemo(()=>new xa,[]),I=b.useMemo(()=>new h.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0}),[]);function K(p,v){const T=new h.OrthographicCamera(-100,100,100,-100,50,5e3);return T.name=p,T.position.copy(v),T.lookAt(0,0,0),a.set(p,T),T}const z=["Single","Side by Side","Stacked","Quad"],H=b.useRef(null),O=b.useRef(null),V=b.useRef(null),k=b.useRef(null),Z=b.useRef(null),se=b.useRef(null),w=localStorage,ge=w.getItem(`${n}_mode`),[Y,tt]=b.useState(ge!==null?ge:"Single"),[P,_e]=b.useState(null),[oe,ve]=b.useState(!1),[we,be]=b.useState(!1),[Me,Ne]=b.useState("Orbit"),[Pe,Ie]=b.useState(!1),[ze,Le]=b.useState(Date.now());w.setItem(`${n}_mode`,Y),w.setItem(`${n}_tlCam`,w.getItem(`${n}_tlCam`)!==null?w.getItem(`${n}_tlCam`):"Debug"),w.setItem(`${n}_trCam`,w.getItem(`${n}_trCam`)!==null?w.getItem(`${n}_trCam`):"Orthographic"),w.setItem(`${n}_blCam`,w.getItem(`${n}_blCam`)!==null?w.getItem(`${n}_blCam`):"Front"),w.setItem(`${n}_brCam`,w.getItem(`${n}_brCam`)!==null?w.getItem(`${n}_brCam`):"Top"),w.setItem(`${n}_tlRender`,w.getItem(`${n}_tlRender`)!==null?w.getItem(`${n}_tlRender`):"Renderer"),w.setItem(`${n}_trRender`,w.getItem(`${n}_trRender`)!==null?w.getItem(`${n}_trRender`):"Renderer"),w.setItem(`${n}_blRender`,w.getItem(`${n}_blRender`)!==null?w.getItem(`${n}_blRender`):"Renderer"),w.setItem(`${n}_brRender`,w.getItem(`${n}_brRender`)!==null?w.getItem(`${n}_brRender`):"Renderer");const ee=(p,v)=>{const T=t.get(p.name);if(T!==void 0&&T.dispose(),t.delete(p.name),p.name==="UI")return;const L=new va(p,v);switch(L.enableDamping=!0,L.dampingFactor=.05,p.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":L.enableRotate=!1;break}t.set(p.name,L)},Oe=p=>{const v=i.get(p.name);v!==void 0&&(l.remove(v),v.dispose(),i.delete(p.name));const T=t.get(p.name);T!==void 0&&(T.dispose(),t.delete(p.name))},nt=()=>{t.forEach((p,v)=>{p.dispose();const T=i.get(v);T!==void 0&&(l.remove(T),T.dispose()),i.delete(v),t.delete(v)}),t.clear(),i.clear()},$e=()=>{switch(Y){case"Single":ee(X,V.current);break;case"Side by Side":case"Stacked":ee(X,V.current),ee(re,k.current);break;case"Quad":ee(X,V.current),ee(re,k.current),ee(De,Z.current),ee(Ae,se.current);break}};b.useEffect(()=>{const p=new h.WebGLRenderer({canvas:H.current,stencil:!1});p.autoClear=!1,p.shadowMap.enabled=!0,p.setPixelRatio(devicePixelRatio),p.setClearColor(0),e.three.renderer=p,_e(p)},[]),b.useEffect(()=>{l.name="Debug Scene",l.uuid="",s.name="helpers",l.add(s),s.add(f),d.name="axisHelper",s.add(d),m.name="interactionHelper",s.add(m),m.visible=!1,K("Top",new h.Vector3(0,1e3,0)),K("Bottom",new h.Vector3(0,-1e3,0)),K("Left",new h.Vector3(-1e3,0,0)),K("Right",new h.Vector3(1e3,0,0)),K("Front",new h.Vector3(0,0,1e3)),K("Back",new h.Vector3(0,0,-1e3)),K("Orthographic",new h.Vector3(1e3,1e3,1e3)),K("UI",new h.Vector3);const p=new h.PerspectiveCamera(60,1,50,5e3);p.name="Debug",p.position.set(500,500,500),p.lookAt(0,0,0),a.set("Debug",p),X=a.get(w.getItem(`${n}_tlCam`)),re=a.get(w.getItem(`${n}_trCam`)),De=a.get(w.getItem(`${n}_blCam`)),Ae=a.get(w.getItem(`${n}_brCam`)),X===void 0&&(X=a.get("Debug")),re===void 0&&(re=a.get("Orthographic")),De===void 0&&(De=a.get("Front")),Ae===void 0&&(Ae=a.get("Top"))},[]),b.useEffect(()=>{const p=()=>{o.forEach(R=>{s.remove(R),R.dispose()}),o.clear()},v=()=>{Te.traverse(R=>{if(R.type.search("Light")>-1){let M;switch(R.type){case"DirectionalLight":M=new h.DirectionalLightHelper(R,100),M.name=`${R.name}Helper`,o.set(R.name,M),s.add(M);break;case"HemisphereLight":M=new h.HemisphereLightHelper(R,250),M.name=`${R.name}Helper`,o.set(R.name,M),s.add(M);break;case"RectAreaLight":M=new pa(R),M.name=`${R.name}Helper`,o.set(R.name,M),s.add(M);break;case"PointLight":M=new h.PointLightHelper(R,100),M.name=`${R.name}Helper`,o.set(R.name,M),s.add(M);break;case"SpotLight":M=new h.SpotLightHelper(R),M.name=`${R.name}Helper`,o.set(R.name,M),s.add(M);break}}})},T=R=>{s.add(d),p(),ht(Te),l.remove(Te);const M=e.scenes.get(R.value.name);if(M!==void 0){const W=new M;e.onSceneSet!==void 0&&e.onSceneSet(W),Te=W,e.three.scene=Te,l.add(Te),It=!0,v()}},L=R=>{const M=R.value,W=e.three.scene?.getObjectByProperty("uuid",M.uuid);if(W!==void 0&&a.set(M.name,W),W instanceof h.PerspectiveCamera){const ae=new h.CameraHelper(W);i.set(W.name,ae),l.add(ae)}Le(Date.now())},me=R=>{const M=i.get(R.value.name);M!==void 0&&(l.remove(M),M.dispose()),a.delete(R.value.name),Le(Date.now())},le=R=>{const M=Te.getObjectByProperty("uuid",R.value.uuid);M&&M.add(d)};return D.addEventListener(A.SET_SCENE,T),D.addEventListener(A.ADD_CAMERA,L),D.addEventListener(A.REMOVE_CAMERA,me),D.addEventListener(A.SET_OBJECT,le),()=>{D.removeEventListener(A.SET_SCENE,T),D.removeEventListener(A.ADD_CAMERA,L),D.removeEventListener(A.REMOVE_CAMERA,me),D.removeEventListener(A.SET_OBJECT,le)}},[]),b.useEffect(()=>{if(P===null)return;let p=window.innerWidth,v=window.innerHeight,T=Math.floor(p/2),L=Math.floor(v/2),me=-1;const le=()=>{p=window.innerWidth-300,v=window.innerHeight,T=Math.floor(p/2),L=Math.floor(v/2),e.three.resize(p,v),e.onSceneResize!==void 0&&It&&e.onSceneResize(Te,p,v);let F=p,te=v;switch(Y){case"Side by Side":F=T,te=v;break;case"Stacked":F=p,te=L;break;case"Quad":F=T,te=L;break}a.forEach($=>{$ instanceof h.OrthographicCamera?($.left=F/-2,$.right=F/2,$.top=te/2,$.bottom=te/-2,$.name==="UI"&&($.position.x=p/2,$.position.y=v/-2,$.position.z=100),$.updateProjectionMatrix()):$ instanceof h.PerspectiveCamera&&($.aspect=F/te,$.updateProjectionMatrix(),i.get($.name)?.update())})};function R(F){switch(F){case"Depth":return y;case"Normals":return E;case"Renderer":return null;case"UVs":return C;case"Wireframe":return I}return null}const M=()=>{const F=R(Qe);l.overrideMaterial=F,P.setViewport(0,0,p,v),P.setScissor(0,0,p,v),P.render(l,X)},W=()=>{const F=R(Qe),te=R(xt);if(l.overrideMaterial=F,Y==="Side by Side")P.setViewport(0,0,T,v),P.setScissor(0,0,T,v),P.render(l,X),l.overrideMaterial=te,P.setViewport(T,0,T,v),P.setScissor(T,0,T,v),P.render(l,re);else{const $=v-L;P.setViewport(0,$,p,L),P.setScissor(0,$,p,L),P.render(l,X),l.overrideMaterial=te,P.setViewport(0,0,p,L),P.setScissor(0,0,p,L),P.render(l,re)}},ae=()=>{const F=R(Qe),te=R(xt),$=R(an),ke=R(rn);let ce=0,ue=0;ue=v-L,ce=0,l.overrideMaterial=F,P.setViewport(ce,ue,T,L),P.setScissor(ce,ue,T,L),P.render(l,X),ce=T,l.overrideMaterial=te,P.setViewport(ce,ue,T,L),P.setScissor(ce,ue,T,L),P.render(l,re),ue=0,ce=0,l.overrideMaterial=$,P.setViewport(ce,ue,T,L),P.setScissor(ce,ue,T,L),P.render(l,De),ce=T,l.overrideMaterial=ke,P.setViewport(ce,ue,T,L),P.setScissor(ce,ue,T,L),P.render(l,Ae)},ye=()=>{switch(t.forEach(F=>{F.update()}),i.forEach(F=>{F.update()}),o.forEach(F=>{F.update!==void 0&&F.update()}),e.onSceneUpdate!==void 0&&It&&e.onSceneUpdate(Te),P.clear(),Y){case"Single":M();break;case"Side by Side":case"Stacked":W();break;case"Quad":ae();break}me=requestAnimationFrame(ye)};return $e(),window.addEventListener("resize",le),le(),ye(),()=>{window.removeEventListener("resize",le),cancelAnimationFrame(me),me=-1}},[Y,P]),b.useEffect(()=>{if(P!==null){const p=new h.Raycaster,v=new h.Vector2,T=(R,M,W,ae)=>{switch(Y){case"Quad":R<W?M<ae?p.setFromCamera(v,X):p.setFromCamera(v,De):M<ae?p.setFromCamera(v,re):p.setFromCamera(v,Ae);break;case"Side by Side":R<W?p.setFromCamera(v,X):p.setFromCamera(v,re);break;case"Single":p.setFromCamera(v,X);break;case"Stacked":M<ae?p.setFromCamera(v,X):p.setFromCamera(v,re);break}},L=R=>{if(Me==="Orbit")return;const M=new h.Vector2;P.getSize(M);const W=Math.min(R.clientX,M.x),ae=Math.min(R.clientY,M.y);v.x=Je(W,0,M.x,-1,1),v.y=Je(ae,0,M.y,1,-1);const ye=M.x/2,F=M.y/2,te=()=>{W<ye?v.x=Je(W,0,ye,-1,1):v.x=Je(W,ye,M.x,-1,1)},$=()=>{ae<F?v.y=Je(ae,0,F,1,-1):v.y=Je(ae,F,M.y,1,-1)};switch(Y){case"Quad":te(),$();break;case"Side by Side":te();break;case"Stacked":$(),$();break}T(W,ae,ye,F);const ke=p.intersectObjects(Te.children);ke.length>0&&m.position.copy(ke[0].point)},me=R=>{if(Me==="Orbit")return;const M=new h.Vector2;if(P.getSize(M),R.clientX>=M.x)return;L(R);const W=p.intersectObjects(Te.children);W.length>0&&(e.three.getObject(W[0].object.uuid),m.visible=!1,Ne("Orbit"),Le(Date.now()))},le=O.current;return le.addEventListener("mousemove",L,!1),le.addEventListener("click",me,!1),()=>{le.removeEventListener("mousemove",L),le.removeEventListener("click",me)}}},[Y,P,Me]);const fe=[];return a.forEach((p,v)=>{fe.push(v)}),u.jsxs("div",{className:"multiview",children:[u.jsx("canvas",{ref:H}),P!==null&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:`cameras ${Y==="Single"||Y==="Stacked"?"single":""}`,ref:O,children:[Y==="Single"&&u.jsx(u.Fragment,{children:u.jsx(He,{camera:X,options:fe,ref:V,onSelectCamera:p=>{t.get(X.name)?.dispose();const v=a.get(p);v!==void 0&&(Oe(X),X=v,w.setItem(`${n}_tlCam`,v.name),ee(v,V.current))},onSelectRenderMode:p=>{Qe=p,w.setItem(`${n}_tlRender`,p)}})}),(Y==="Side by Side"||Y==="Stacked")&&u.jsxs(u.Fragment,{children:[u.jsx(He,{camera:X,options:fe,ref:V,onSelectCamera:p=>{t.get(X.name)?.dispose();const v=a.get(p);v!==void 0&&(Oe(X),X=v,w.setItem(`${n}_tlCam`,v.name),ee(v,V.current))},onSelectRenderMode:p=>{Qe=p,w.setItem(`${n}_tlRender`,p)}}),u.jsx(He,{camera:re,options:fe,ref:k,onSelectCamera:p=>{t.get(re.name)?.dispose();const v=a.get(p);v!==void 0&&(Oe(re),re=v,w.setItem(`${n}_trCam`,v.name),ee(v,k.current))},onSelectRenderMode:p=>{xt=p,w.setItem(`${n}_trRender`,p)}})]}),Y==="Quad"&&u.jsxs(u.Fragment,{children:[u.jsx(He,{camera:X,options:fe,ref:V,onSelectCamera:p=>{t.get(X.name)?.dispose();const v=a.get(p);v!==void 0&&(Oe(X),X=v,w.setItem(`${n}_tlCam`,v.name),ee(v,V.current))},onSelectRenderMode:p=>{Qe=p,w.setItem(`${n}_tlRender`,p)}}),u.jsx(He,{camera:re,options:fe,ref:k,onSelectCamera:p=>{t.get(re.name)?.dispose();const v=a.get(p);v!==void 0&&(Oe(re),re=v,w.setItem(`${n}_trCam`,v.name),ee(v,k.current))},onSelectRenderMode:p=>{xt=p,w.setItem(`${n}_trRender`,p)}}),u.jsx(He,{camera:De,options:fe,ref:Z,onSelectCamera:p=>{t.get(De.name)?.dispose();const v=a.get(p);v!==void 0&&(Oe(De),De=v,w.setItem(`${n}_blCam`,v.name),ee(v,Z.current))},onSelectRenderMode:p=>{an=p,w.setItem(`${n}_blRender`,p)}}),u.jsx(He,{camera:Ae,options:fe,ref:se,onSelectCamera:p=>{t.get(Ae.name)?.dispose();const v=a.get(p);v!==void 0&&(Oe(Ae),Ae=v,w.setItem(`${n}_brCam`,v.name),ee(v,se.current))},onSelectRenderMode:p=>{rn=p,w.setItem(`${n}_brRender`,p)}})]})]}),u.jsxs("div",{className:"settings",children:[u.jsx(Mt,{index:z.indexOf(Y),options:z,onSelect:p=>{p!==Y&&(nt(),tt(p))},open:oe,onToggle:p=>{ve(p),we&&be(!1),Pe&&Ie(!1)}}),u.jsx(Mt,{index:Me==="Orbit"?0:1,options:["Orbit Mode","Selection Mode"],onSelect:p=>{m.visible=p==="Selection Mode",Ne(m.visible?"Selection":"Orbit")},open:Pe,onToggle:p=>{oe&&ve(!1),we&&be(!1),Ie(p)}})]},ze)]})]})}function wa(e){return u.jsxs("div",{className:"editor",ref:e.ref,style:e.style,children:[u.jsx("div",{className:"header",children:e.header}),e.children,u.jsx("div",{className:"footer",children:e.footer})]})}exports.Accordion=ft;exports.Application=Tn;exports.BaseRemote=mt;exports.ChildObject=$t;exports.ContainerObject=Ut;exports.Draggable=fn;exports.DraggableItem=hn;exports.Dropdown=mn;exports.DropdownItem=pn;exports.Editor=wa;exports.ExportTexture=ut;exports.Inspector=bn;exports.MultiView=Ca;exports.NavButton=zt;exports.RemoteComponents=_n;exports.RemoteController=zn;exports.RemoteTheatre=Rt;exports.RemoteThree=Nn;exports.RemoteTweakpane=Ln;exports.SceneInspector=ma;exports.SidePanel=fa;exports.ToolEvents=A;exports.capitalize=dt;exports.clamp=Ve;exports.colorToHex=ln;exports.debugDispatcher=D;exports.defaultTheatreCallback=Mn;exports.dispose=ht;exports.disposeMaterial=un;exports.disposeTexture=Rn;exports.distance=On;exports.hierarchyUUID=wt;exports.isColor=cn;exports.mix=Nt;exports.noop=Ot;exports.normalize=jt;exports.randomID=on;exports.resetThreeObjects=Ft;exports.round=Lt;exports.theatreEditorApp=kn;
|
149
|
+
}`;class ys extends p.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:_s,fragmentShader:vs})}}let ze,_i=!1,Q=null,de=null,Be=null,He=null,St="Renderer",Jt="Renderer",Ki="Renderer",Xi="Renderer";function Es(i){const e=i.three.app.appID,n=T.useMemo(()=>new Map,[]),t=T.useMemo(()=>new Map,[]),s=T.useMemo(()=>new Map,[]),a=T.useMemo(()=>new Map,[]),o=T.useMemo(()=>new p.Scene,[]),r=T.useMemo(()=>new p.Group,[]),h=T.useMemo(()=>new gs,[]),c=T.useMemo(()=>new p.AxesHelper(500),[]),u=T.useMemo(()=>new p.AxesHelper(100),[]),f=T.useMemo(()=>new p.MeshDepthMaterial,[]),v=T.useMemo(()=>new p.MeshNormalMaterial,[]),y=T.useMemo(()=>new ys,[]),A=T.useMemo(()=>new p.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0}),[]);function I(b,S){const P=new p.OrthographicCamera(-100,100,100,-100,50,5e3);return P.name=b,P.position.copy(S),P.lookAt(0,0,0),n.set(b,P),P}const U=["Single","Side by Side","Stacked","Quad"],_=T.useRef(null),E=T.useRef(null),w=T.useRef(null),C=T.useRef(null),k=T.useRef(null),L=T.useRef(null),x=localStorage,ne=x.getItem(`${e}_mode`),[q,$e]=T.useState(ne!==null?ne:"Single"),[Y,Pe]=T.useState(null),[Ee,Ce]=T.useState(!1),[Te,Le]=T.useState(!1),[Ve,it]=T.useState("Orbit"),[Qe,et]=T.useState(!1),[dt,nt]=T.useState(Date.now());x.setItem(`${e}_mode`,q),x.setItem(`${e}_tlCam`,x.getItem(`${e}_tlCam`)!==null?x.getItem(`${e}_tlCam`):"Debug"),x.setItem(`${e}_trCam`,x.getItem(`${e}_trCam`)!==null?x.getItem(`${e}_trCam`):"Orthographic"),x.setItem(`${e}_blCam`,x.getItem(`${e}_blCam`)!==null?x.getItem(`${e}_blCam`):"Front"),x.setItem(`${e}_brCam`,x.getItem(`${e}_brCam`)!==null?x.getItem(`${e}_brCam`):"Top"),x.setItem(`${e}_tlRender`,x.getItem(`${e}_tlRender`)!==null?x.getItem(`${e}_tlRender`):"Renderer"),x.setItem(`${e}_trRender`,x.getItem(`${e}_trRender`)!==null?x.getItem(`${e}_trRender`):"Renderer"),x.setItem(`${e}_blRender`,x.getItem(`${e}_blRender`)!==null?x.getItem(`${e}_blRender`):"Renderer"),x.setItem(`${e}_brRender`,x.getItem(`${e}_brRender`)!==null?x.getItem(`${e}_brRender`):"Renderer");const _e=(b,S)=>{const P=t.get(b.name);if(P!==void 0&&P.dispose(),t.delete(b.name),b.name==="UI")return;const F=new ds(b,S);switch(F.enableDamping=!0,F.dampingFactor=.05,b.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":F.enableRotate=!1;break}t.set(b.name,F)},Ye=b=>{const S=s.get(b.name);S!==void 0&&(o.remove(S),S.dispose(),s.delete(b.name));const P=t.get(b.name);P!==void 0&&(P.dispose(),t.delete(b.name))},Mt=()=>{t.forEach((b,S)=>{b.dispose();const P=s.get(S);P!==void 0&&(o.remove(P),P.dispose()),s.delete(S),t.delete(S)}),t.clear(),s.clear()},ht=()=>{switch(q){case"Single":_e(Q,w.current);break;case"Side by Side":case"Stacked":_e(Q,w.current),_e(de,C.current);break;case"Quad":_e(Q,w.current),_e(de,C.current),_e(Be,k.current),_e(He,L.current);break}};T.useEffect(()=>{const b=new p.WebGLRenderer({canvas:_.current,stencil:!1});b.autoClear=!1,b.shadowMap.enabled=!0,b.setPixelRatio(devicePixelRatio),b.setClearColor(0),i.three.renderer=b,Pe(b)},[]),T.useEffect(()=>{o.name="Debug Scene",o.uuid="",r.name="helpers",o.add(r),r.add(h),c.name="axisHelper",r.add(c),u.name="interactionHelper",r.add(u),u.visible=!1,I("Top",new p.Vector3(0,1e3,0)),I("Bottom",new p.Vector3(0,-1e3,0)),I("Left",new p.Vector3(-1e3,0,0)),I("Right",new p.Vector3(1e3,0,0)),I("Front",new p.Vector3(0,0,1e3)),I("Back",new p.Vector3(0,0,-1e3)),I("Orthographic",new p.Vector3(1e3,1e3,1e3)),I("UI",new p.Vector3);const b=new p.PerspectiveCamera(60,1,50,5e3);b.name="Debug",b.position.set(500,500,500),b.lookAt(0,0,0),n.set("Debug",b),Q=n.get(x.getItem(`${e}_tlCam`)),de=n.get(x.getItem(`${e}_trCam`)),Be=n.get(x.getItem(`${e}_blCam`)),He=n.get(x.getItem(`${e}_brCam`)),Q===void 0&&(Q=n.get("Debug")),de===void 0&&(de=n.get("Orthographic")),Be===void 0&&(Be=n.get("Front")),He===void 0&&(He=n.get("Top"))},[]),T.useEffect(()=>{const b=()=>{a.forEach(D=>{r.remove(D),D.dispose()}),a.clear()},S=()=>{ze.traverse(D=>{if(D.type.search("Light")>-1){let z;switch(D.type){case"DirectionalLight":z=new p.DirectionalLightHelper(D,100),z.name=`${D.name}Helper`,a.set(D.name,z),r.add(z);break;case"HemisphereLight":z=new p.HemisphereLightHelper(D,250),z.name=`${D.name}Helper`,a.set(D.name,z),r.add(z);break;case"RectAreaLight":z=new cs(D),z.name=`${D.name}Helper`,a.set(D.name,z),r.add(z);break;case"PointLight":z=new p.PointLightHelper(D,100),z.name=`${D.name}Helper`,a.set(D.name,z),r.add(z);break;case"SpotLight":z=new p.SpotLightHelper(D),z.name=`${D.name}Helper`,a.set(D.name,z),r.add(z);break}}})},P=D=>{r.add(c),b(),zt(ze),o.remove(ze);const z=i.scenes.get(D.value.name);if(z!==void 0){const ve=new z;i.onSceneSet!==void 0&&i.onSceneSet(ve),ze=ve,i.three.scene=ze,o.add(ze),_i=!0,S()}},F=D=>{const z=D.value,ve=i.three.scene?.getObjectByProperty("uuid",z.uuid);if(ve!==void 0&&n.set(z.name,ve),ve instanceof p.PerspectiveCamera){const De=new p.CameraHelper(ve);s.set(ve.name,De),o.add(De)}nt(Date.now())},he=D=>{const z=s.get(D.value.name);z!==void 0&&(o.remove(z),z.dispose()),n.delete(D.value.name),nt(Date.now())},se=D=>{const z=ze.getObjectByProperty("uuid",D.value.uuid);z&&z.add(c)};return j.addEventListener(N.SET_SCENE,P),j.addEventListener(N.ADD_CAMERA,F),j.addEventListener(N.REMOVE_CAMERA,he),j.addEventListener(N.SET_OBJECT,se),()=>{j.removeEventListener(N.SET_SCENE,P),j.removeEventListener(N.ADD_CAMERA,F),j.removeEventListener(N.REMOVE_CAMERA,he),j.removeEventListener(N.SET_OBJECT,se)}},[]),T.useEffect(()=>{if(Y===null)return;let b=window.innerWidth,S=window.innerHeight,P=Math.floor(b/2),F=Math.floor(S/2),he=-1;const se=()=>{b=window.innerWidth-300,S=window.innerHeight,P=Math.floor(b/2),F=Math.floor(S/2),i.three.resize(b,S),i.onSceneResize!==void 0&&_i&&i.onSceneResize(ze,b,S);let $=b,oe=S;switch(q){case"Side by Side":$=P,oe=S;break;case"Stacked":$=b,oe=F;break;case"Quad":$=P,oe=F;break}const Oe=$/oe;n.forEach(ce=>{ce instanceof p.OrthographicCamera?(ce.left=$/-2,ce.right=$/2,ce.top=oe/2,ce.bottom=oe/-2,ce.name==="UI"&&(ce.position.x=b/2,ce.position.y=S/-2,ce.position.z=100),ce.updateProjectionMatrix()):ce instanceof p.PerspectiveCamera&&(ce.aspect=Oe,ce.updateProjectionMatrix(),s.get(ce.name)?.update())})};function D($){switch($){case"Depth":return f;case"Normals":return v;case"Renderer":return null;case"UVs":return y;case"Wireframe":return A}return null}const z=()=>{const $=D(St);o.overrideMaterial=$,Y.setViewport(0,0,b,S),Y.setScissor(0,0,b,S),Y.render(o,Q)},ve=()=>{const $=D(St),oe=D(Jt);if(o.overrideMaterial=$,q==="Side by Side")Y.setViewport(0,0,P,S),Y.setScissor(0,0,P,S),Y.render(o,Q),o.overrideMaterial=oe,Y.setViewport(P,0,P,S),Y.setScissor(P,0,P,S),Y.render(o,de);else{const Oe=S-F;Y.setViewport(0,Oe,b,F),Y.setScissor(0,Oe,b,F),Y.render(o,Q),o.overrideMaterial=oe,Y.setViewport(0,0,b,F),Y.setScissor(0,0,b,F),Y.render(o,de)}},De=()=>{const $=D(St),oe=D(Jt),Oe=D(Ki),ce=D(Xi);let me=0,V=0;V=S-F,me=0,o.overrideMaterial=$,Y.setViewport(me,V,P,F),Y.setScissor(me,V,P,F),Y.render(o,Q),me=P,o.overrideMaterial=oe,Y.setViewport(me,V,P,F),Y.setScissor(me,V,P,F),Y.render(o,de),V=0,me=0,o.overrideMaterial=Oe,Y.setViewport(me,V,P,F),Y.setScissor(me,V,P,F),Y.render(o,Be),me=P,o.overrideMaterial=ce,Y.setViewport(me,V,P,F),Y.setScissor(me,V,P,F),Y.render(o,He)},We=()=>{switch(t.forEach($=>{$.update()}),s.forEach($=>{$.update()}),a.forEach($=>{$.update!==void 0&&$.update()}),i.onSceneUpdate!==void 0&&_i&&i.onSceneUpdate(ze),Y.clear(),q){case"Single":z();break;case"Side by Side":case"Stacked":ve();break;case"Quad":De();break}he=requestAnimationFrame(We)};return ht(),window.addEventListener("resize",se),se(),We(),()=>{window.removeEventListener("resize",se),cancelAnimationFrame(he),he=-1}},[q,Y]),T.useEffect(()=>{if(Y!==null){const b={Vector2:p.Vector2,Vector3:p.Vector3,Vector4:p.Vector4,Quaternion:p.Quaternion,Matrix4:p.Matrix4,Spherical:p.Spherical,Box3:p.Box3,Sphere:p.Sphere,Raycaster:p.Raycaster};Je.install({THREE:b});const S=new p.Raycaster,P=new p.Vector2;let F=Q,he=w,se,D,z=-1;const ve=(V,te,pe,ue)=>{switch(q){case"Quad":V<pe?te<ue?(F=Q,S.setFromCamera(P,Q)):(F=Be,S.setFromCamera(P,Be)):te<ue?(F=de,S.setFromCamera(P,de)):(F=He,S.setFromCamera(P,He));break;case"Side by Side":V<pe?(F=Q,S.setFromCamera(P,Q)):(F=de,S.setFromCamera(P,de));break;case"Single":F=Q,S.setFromCamera(P,Q);break;case"Stacked":te<ue?(F=Q,S.setFromCamera(P,Q)):(F=de,S.setFromCamera(P,de));break}F===Q?he=w:F===de?he=C:F===Be?he=k:F===He&&(he=L)},De=V=>{const te=new p.Vector2;Y.getSize(te);const pe=Math.min(V.clientX,te.x),ue=Math.min(V.clientY,te.y);P.x=bt(pe,0,te.x,-1,1),P.y=bt(ue,0,te.y,1,-1);const Ae=te.x/2,Ie=te.y/2,st=()=>{pe<Ae?P.x=bt(pe,0,Ae,-1,1):P.x=bt(pe,Ae,te.x,-1,1)},Ke=()=>{ue<Ie?P.y=bt(ue,0,Ie,1,-1):P.y=bt(ue,Ie,te.y,1,-1)};switch(q){case"Quad":st(),Ke();break;case"Side by Side":st();break;case"Stacked":Ke(),Ke();break}if(ve(pe,ue,Ae,Ie),Ve==="Orbit")return;const _t=S.intersectObjects(ze.children);_t.length>0&&u.position.copy(_t[0].point)},We=V=>{if(Ve==="Orbit")return;const te=new p.Vector2;if(Y.getSize(te),V.clientX>=te.x)return;De(V);const pe=S.intersectObjects(ze.children);pe.length>0&&(i.three.getObject(pe[0].object.uuid),u.visible=!1,it("Orbit"),nt(Date.now()))},$=(V,te=!1)=>{if(se===void 0)return;cancelAnimationFrame(z),z=-1,D&&(D.smoothTime=.1);const pe=.15,ue=new p.Clock;ue.start(),se.getWorldPosition(V.target0);const Ae=()=>{const Ie=ue.getDelta();D&&D.update(Ie),te&&(V.target.lerp(V.target0,pe),V.object.position.lerp(V.position0,pe),V.object.zoom=ei(V.object.zoom,V.zoom0,pe),V.object.updateProjectionMatrix(),V.dispatchEvent({type:"change"})),ue.getElapsedTime()>=.5?(cancelAnimationFrame(z),z=-1,oe()):z=requestAnimationFrame(Ae)};Ae()},oe=()=>{D!==void 0&&(D.disconnect(),D.dispose(),D=void 0)},Oe=V=>{if(se!==void 0&&V.ctrlKey){if(F.name==="UI")return;const te=t.get(F.name);V.key==="0"?(oe(),D=new Je(F,he.current),se instanceof p.Mesh||se instanceof p.SkinnedMesh?(se.geometry.computeBoundingBox(),D.fitToBox(se.geometry.boundingBox,!0)):D.fitToSphere(se,!0),$(te,!0)):V.key==="1"?(oe(),D=new Je(F,he.current),D.rotateTo(0,Math.PI*.5,!0),D.moveTo(se.position.x,se.position.y,0,!0),$(te)):V.key==="2"?(oe(),D=new Je(F,he.current),D.rotateTo(0,0,!0),D.moveTo(se.position.x,0,se.position.z,!0),$(te)):V.key==="3"?(oe(),D=new Je(F,he.current),D.rotateTo(Math.PI/2,Math.PI/2,!0),D.moveTo(0,se.position.y,se.position.z,!0),$(te)):V.key==="4"?(oe(),D=new Je(F,he.current),D.rotateTo(Math.PI,Math.PI/2,!0),D.moveTo(se.position.x,se.position.y,0,!0),$(te)):V.key==="5"&&(oe(),D=new Je(F,he.current),D.rotateTo(zi(45),zi(45),!0),$(te))}},ce=V=>{se=ze.getObjectByProperty("uuid",V.value.uuid)},me=E.current;return me.addEventListener("mousemove",De,!1),me.addEventListener("click",We,!1),window.addEventListener("keydown",Oe,!1),j.addEventListener(N.SET_OBJECT,ce),()=>{me.removeEventListener("mousemove",De),me.removeEventListener("click",We),window.removeEventListener("keydown",Oe),j.removeEventListener(N.SET_OBJECT,ce)}}},[q,Y,Ve]);const we=[];return n.forEach((b,S)=>{we.push(S)}),m.jsxs("div",{className:"multiview",children:[m.jsx("canvas",{ref:_}),Y!==null&&m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:`cameras ${q==="Single"||q==="Stacked"?"single":""}`,ref:E,children:[q==="Single"&&m.jsx(m.Fragment,{children:m.jsx(ft,{camera:Q,options:we,ref:w,onSelectCamera:b=>{t.get(Q.name)?.dispose();const S=n.get(b);S!==void 0&&(Ye(Q),Q=S,x.setItem(`${e}_tlCam`,S.name),_e(S,w.current))},onSelectRenderMode:b=>{St=b,x.setItem(`${e}_tlRender`,b)}})}),(q==="Side by Side"||q==="Stacked")&&m.jsxs(m.Fragment,{children:[m.jsx(ft,{camera:Q,options:we,ref:w,onSelectCamera:b=>{t.get(Q.name)?.dispose();const S=n.get(b);S!==void 0&&(Ye(Q),Q=S,x.setItem(`${e}_tlCam`,S.name),_e(S,w.current))},onSelectRenderMode:b=>{St=b,x.setItem(`${e}_tlRender`,b)}}),m.jsx(ft,{camera:de,options:we,ref:C,onSelectCamera:b=>{t.get(de.name)?.dispose();const S=n.get(b);S!==void 0&&(Ye(de),de=S,x.setItem(`${e}_trCam`,S.name),_e(S,C.current))},onSelectRenderMode:b=>{Jt=b,x.setItem(`${e}_trRender`,b)}})]}),q==="Quad"&&m.jsxs(m.Fragment,{children:[m.jsx(ft,{camera:Q,options:we,ref:w,onSelectCamera:b=>{t.get(Q.name)?.dispose();const S=n.get(b);S!==void 0&&(Ye(Q),Q=S,x.setItem(`${e}_tlCam`,S.name),_e(S,w.current))},onSelectRenderMode:b=>{St=b,x.setItem(`${e}_tlRender`,b)}}),m.jsx(ft,{camera:de,options:we,ref:C,onSelectCamera:b=>{t.get(de.name)?.dispose();const S=n.get(b);S!==void 0&&(Ye(de),de=S,x.setItem(`${e}_trCam`,S.name),_e(S,C.current))},onSelectRenderMode:b=>{Jt=b,x.setItem(`${e}_trRender`,b)}}),m.jsx(ft,{camera:Be,options:we,ref:k,onSelectCamera:b=>{t.get(Be.name)?.dispose();const S=n.get(b);S!==void 0&&(Ye(Be),Be=S,x.setItem(`${e}_blCam`,S.name),_e(S,k.current))},onSelectRenderMode:b=>{Ki=b,x.setItem(`${e}_blRender`,b)}}),m.jsx(ft,{camera:He,options:we,ref:L,onSelectCamera:b=>{t.get(He.name)?.dispose();const S=n.get(b);S!==void 0&&(Ye(He),He=S,x.setItem(`${e}_brCam`,S.name),_e(S,L.current))},onSelectRenderMode:b=>{Xi=b,x.setItem(`${e}_brRender`,b)}})]})]}),m.jsxs("div",{className:"settings",children:[m.jsx(ii,{title:"View",index:U.indexOf(q),options:U,onSelect:b=>{b!==q&&(Mt(),$e(b))},open:Ee,onToggle:b=>{Ce(b),Te&&Le(!1),Qe&&et(!1)}}),m.jsx(ii,{title:"Interact",index:Ve==="Orbit"?0:1,options:["Orbit Mode","Selection Mode"],onSelect:b=>{u.visible=b==="Selection Mode",it(u.visible?"Selection":"Orbit")},open:Qe,onToggle:b=>{Ee&&Ce(!1),Te&&Le(!1),et(b)}})]},dt)]})]})}function bs(i){return m.jsxs("div",{className:"editor",ref:i.ref,style:i.style,children:[m.jsx("div",{className:"header",children:i.header}),i.children,m.jsx("div",{className:"footer",children:i.footer})]})}exports.Accordion=Bt;exports.Application=En;exports.BaseRemote=Ht;exports.ChildObject=Si;exports.ContainerObject=Ci;exports.Draggable=sn;exports.DraggableItem=nn;exports.Dropdown=an;exports.DropdownItem=rn;exports.Editor=bs;exports.ExportTexture=jt;exports.Inspector=ln;exports.MultiView=Es;exports.NavButton=xi;exports.RemoteComponents=bn;exports.RemoteController=In;exports.RemoteTheatre=si;exports.RemoteThree=Mn;exports.RemoteTweakpane=Rn;exports.SceneInspector=os;exports.SidePanel=rs;exports.ToolEvents=N;exports.capitalize=Nt;exports.clamp=ct;exports.colorToHex=yi;exports.debugDispatcher=j;exports.defaultTheatreCallback=_n;exports.dispose=zt;exports.disposeMaterial=en;exports.disposeTexture=yn;exports.distance=vn;exports.hierarchyUUID=ti;exports.isColor=Qi;exports.mix=ei;exports.noop=ni;exports.normalize=vi;exports.randomID=Ji;exports.resetThreeObjects=bi;exports.round=Ei;exports.theatreEditorApp=On;
|