@tomorrowevening/hermes 0.0.87 → 0.0.88

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("three"),un=require("tweakpane"),mn=require("@tweakpane/plugin-essentials"),x=require("react"),Ki=require("framer-motion");function fn(i){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const n in i)if(n!=="default"){const e=Object.getOwnPropertyDescriptor(i,n);Object.defineProperty(t,n,e.get?e:{enumerable:!0,get:()=>i[n]})}}return t.default=i,Object.freeze(t)}const pn=fn(mn),ni=()=>{},_n=()=>{};function Nt(i){return i.substring(0,1).toUpperCase()+i.substring(1)}function ct(i,t,n){return Math.min(t,Math.max(i,n))}function vi(i,t,n){return(n-i)/(t-i)}function ei(i,t,n){return i*(1-n)+t*n}function gn(i,t){const n=i-t;return Math.sqrt(n*n)}function Xi(){return Math.round(Math.random()*1e6).toString()}function qi(i){return i.r!==void 0&&i.g!==void 0&&i.b!==void 0}function Qi(i){const t=Math.round(i.r*255),n=Math.round(i.g*255),e=Math.round(i.b*255),s=h=>{const c=h.toString(16);return c.length===1?"0"+c:c},a=s(t),o=s(n),r=s(e);return"#"+a+o+r}function yi(i,t=1){return Number(i.toFixed(t))}exports.totalThreeObjects=0;const Ei=()=>{exports.totalThreeObjects=0},ti=i=>{if(!i)return;let t=i.name.replaceAll(" ","").replaceAll("/",".");if(t.length===0&&(t=`obj_${exports.totalThreeObjects}`,exports.totalThreeObjects++),i.parent!==null&&i.parent.uuid.length>0&&(t=`${i.parent.uuid}.${t}`),i.uuid=t,i.isMesh!==void 0){const n=i;if(Array.isArray(n.material))n.material.forEach((e,s)=>{e.uuid=`${t}.material.${s}`});else{const e=n.material;e.uuid=`${t}.material`}}i.children.forEach(n=>ti(n))},vn=i=>{i?.dispose()},Ji=i=>{i&&(Array.isArray(i)?i.forEach(t=>t.dispose()):i.dispose())},zt=i=>{if(i){for(;i.children.length>0;){const t=i.children[0];t.type==="Audio"?(t.pause(),t.parent&&t.parent.remove(t)):zt(t)}if(i.parent&&i.parent.remove(i),i.isMesh){const t=i;t.geometry?.dispose(),Ji(t.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(t){this.init();const n=t.repeat.clone(),e=t.offset.clone();if(t.repeat.set(1,1),t.offset.set(0,0),this.context!==null){this.context.clearRect(0,0,this.width,this.height);const s=t.image;if(s!=null&&s.width>0){this.canvas.title=t.sourceFile;const a=this.canvas.width/s.width,o=this.renderToCanvas(t);this.context.drawImage(o,0,0,s.width*a,s.height*a)}}return t.repeat.copy(n),t.offset.copy(e),this.canvas.toDataURL("image/png")}static renderToCanvas(t){if(this.material===null){this.camera=new f.OrthographicCamera(-.5,.5,.5,-.5,0,100),this.scene=new f.Scene,this.material=new f.MeshBasicMaterial;const n=new f.BufferGeometry;n.setAttribute("position",new f.Float32BufferAttribute([-.5,-.5,0,1.5,-.5,0,-.5,1.5,0],3)),n.setAttribute("normal",new f.Float32BufferAttribute([0,0,1,0,0,1],3)),n.setAttribute("uv",new f.Float32BufferAttribute([0,0,2,0,0,2],2));const e=new f.Mesh(n,this.material);this.scene.add(e)}if(t.isRenderTargetTexture)this.material.map=t,this.renderer.render(this.scene,this.camera);else{const n=this.renderer.outputColorSpace,e=t.colorSpace;this.renderer.outputColorSpace=f.LinearSRGBColorSpace,t.colorSpace=f.LinearSRGBColorSpace,this.material.map=t,this.renderer.render(this.scene,this.camera),this.renderer.outputColorSpace=n,t.colorSpace=e}return this.renderer.domElement}}class yn{components=new Map;listen;_appID="";_debugEnabled;_broadcastChannel=void 0;_webSocket=void 0;_mode="app";_connected=!1;_useBC=!1;constructor(t,n,e=!0){this._appID=t,this._debugEnabled=n,n&&(this._useBC=e,e?(this._broadcastChannel=new BroadcastChannel(t),this._broadcastChannel.addEventListener("message",this.messageHandler)):(this._webSocket=new WebSocket(t),this._webSocket.addEventListener("open",this.openHandler),this._webSocket.addEventListener("close",this.closeHandler),this._webSocket.addEventListener("message",this.messageHandler)))}addComponent(t,n){this.components.set(t,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(t=>{t.dispose()}),this.components.clear()}send(t){this._mode!==t.target&&(this._useBC?this._broadcastChannel?.postMessage(t):this._connected&&this._webSocket?.send(JSON.stringify(t)))}messageHandler=t=>{this.listen!==void 0&&(this._useBC?this.listen(t.data):this.listen(JSON.parse(t.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(t){t&&(this._mode="editor")}}const H=new f.EventDispatcher,V={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 Ht{app;constructor(t){this.app=t}dispose(){}handleApp(t,n,e){}handleEditor(t,n,e){}}class En extends Ht{selectDropdown(t,n){this.app.send({event:"selectComponent",target:"app",data:{dropdown:t,value:n}})}updateDropdown(t,n){this.app.send({event:"draggableListUpdate",target:"app",data:{dropdown:t,value:n}})}handleApp(t,n,e){switch(e.event){case"selectComponent":H.dispatchEvent({type:V.SELECT_DROPDOWN,value:e.data});break;case"draggableListUpdate":H.dispatchEvent({type:V.DRAG_UPDATE,value:e.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(t,n){return n!==void 0?`${t}-${n}`:t}sheet(t,n){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const e=this.getSheetInstance(t,n);let s=this.sheets.get(e);return s!==void 0||(s=this.project?.sheet(t,n),this.sheets.set(e,s)),s}playSheet(t,n,e){this.sheet(t,e)?.sequence.play(n),this.app.send({event:"playSheet",target:"editor",data:{sheet:t,instance:e,value:n}})}pauseSheet(t,n){this.sheet(t)?.sequence.pause(),this.app.send({event:"pauseSheet",target:"editor",data:{sheet:t,instance:n}})}clearSheetObjects(t){this.sheetObjects.forEach((n,e)=>{e.search(`${t}_`)>-1&&this.unsubscribe(n)})}sheetObject(t,n,e,s,a){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const o=this.sheet(t,a);if(o===void 0)return;const h=`${this.getSheetInstance(t,a)}_${n}`;let c=this.sheetObjects.get(h);c!==void 0?c=o.object(n,{...e,...c.value},{reconfigure:!0}):c=o.object(n,e),this.sheetObjects.set(h,c),this.sheetObjectCBs.set(h,s!==void 0?s:ni);const m=c.onValuesChange(p=>{if(this.app.editor){for(const y in p){const D=p[y];typeof D=="object"&&qi(D)&&(p[y]={r:D.r,g:D.g,b:D.b,a:D.a})}this.app.send({event:"updateSheetObject",target:"app",data:{sheet:t,sheetObject:h,values:p}})}const v=this.sheetObjectCBs.get(h);v!==void 0&&v(p)});return this.sheetObjectUnsubscribe.set(h,m),c}unsubscribe(t){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const n=t.address.sheetId,e=t.address.objectKey;this.sheets.get(n)?.detachObject(e);const a=`${n}_${e}`,o=this.sheetObjectUnsubscribe.get(a);o!==void 0&&(this.sheetObjects.delete(a),this.sheetObjectCBs.delete(a),this.sheetObjectUnsubscribe.delete(a),o())}handleApp(t,n,e){const s=n;let a;switch(e.event){case"setSheet":a=s.sheets.get(e.data.sheet),a!==void 0&&(s.activeSheet=a,this.studio?.setSelection([a]));break;case"setSheetObject":a=s.sheetObjects.get(`${e.data.sheet}_${e.data.key}`),a!==void 0&&this.studio?.setSelection([a]);break;case"updateSheetObject":a=s.sheets.get(e.data.sheet),a!==void 0&&a.sequence.pause(),a=s.sheetObjectCBs.get(e.data.sheetObject),a!==void 0&&a(e.data.values);break;case"updateTimeline":a=s.sheets.get(e.data.sheet),s.activeSheet!==void 0&&(s.activeSheet.sequence.position=e.data.position);break}}handleEditor(t,n,e){if(t.editor){const s=n;switch(e.event){case"playSheet":s.sheet(e.data.sheet,e.data.instance)?.sequence.play(e.data.value);break;case"pauseSheet":s.sheet(e.data.sheet,e.data.instance)?.sequence.pause();break}}}handleEditorApp(t,n){if(t.editor){this.studio?.ui.restore(),this.studio?.onSelectionChange(o=>{o.length<1||o.forEach(r=>{let h=r.address.sheetId,c="setSheet",m={};switch(r.type){case"Theatre_Sheet_PublicAPI":c="setSheet",m={sheet:r.address.sheetId},n.activeSheet=n.sheets.get(r.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":c="setSheetObject",h+=`_${r.address.objectKey}`,m={id:h,sheet:r.address.sheetId,key:r.address.objectKey},n.activeSheet=n.sheets.get(r.address.sheetId);break}t.send({event:c,target:"app",data:m})})});let e=-1;const s=()=>{if(si.rafDriver?.tick(performance.now()),n.activeSheet!==void 0&&e!==n.activeSheet.sequence.position){e=n.activeSheet.sequence.position;const o=n.activeSheet;t.send({event:"updateTimeline",target:"app",data:{position:e,sheet:o.address.sheetId}})}},a=()=>{s(),requestAnimationFrame(a)};s(),a()}else this.studio?.ui.hide()}}function bn(i,t,n){if(i.editor){n.ui.restore(),n.onSelectionChange(o=>{o.length<1||o.forEach(r=>{let h=r.address.sheetId,c="setSheet",m={};switch(r.type){case"Theatre_Sheet_PublicAPI":c="setSheet",m={sheet:r.address.sheetId},t.activeSheet=t.sheets.get(r.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":c="setSheetObject",h+=`_${r.address.objectKey}`,m={id:h,sheet:r.address.sheetId,key:r.address.objectKey},t.activeSheet=t.sheets.get(r.address.sheetId);break}i.send({event:c,target:"app",data:m})})});let e=-1;const s=()=>{if(si.rafDriver?.tick(performance.now()),t.activeSheet!==void 0&&e!==t.activeSheet.sequence.position){e=t.activeSheet.sequence.position;const o=t.activeSheet;i.send({event:"updateTimeline",target:"app",data:{position:e,sheet:o.address.sheetId}})}},a=()=>{s(),requestAnimationFrame(a)};s(),a()}else n.ui.hide()}function On(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 t=i.type;return t.search("Helper")>-1?"icon_utils":t.search("Camera")>-1?"camera":t.search("Light")>-1?"light":"obj3D"}function wt(i){const t={name:i.name,type:i.type,uuid:i.uuid,children:[]};return i.children.forEach(n=>{t.children.push(wt(n))}),t}function Cn(i){const t={};for(const n in i){const e=i[n].value;t[n]={value:e},e===null?t[n].value={src:"",offset:[0,0],repeat:[1,1]}:e!==void 0&&e.isTexture&&(t[n].value={src:e.image.src,offset:[e.offset.x,e.offset.y],repeat:[e.repeat.x,e.repeat.y]})}return t}function Tn(i){switch(i){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function Et(i){const t={};for(const n in i){if(n.substring(0,1)==="_"||n.substring(0,2)==="is"||Tn(n))continue;const e=typeof i[n],s=i[n];switch(e){case"boolean":case"number":case"string":t[n]=s;break;case"object":s!==null?(t[n]=s,s.isTexture?t[n]={src:jt.renderToBlob(s),offset:[s.offset.x,s.offset.y],repeat:[s.repeat.x,s.repeat.y]}:n==="uniforms"&&(t[n]=Cn(t[n]))):t[n]={src:"",offset:[0,0],repeat:[1,1]};break}}return t}function ci(i){i.updateMatrix();const t={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(e=>{t.animations.push({name:e.name,duration:e.duration,blendMode:e.blendMode})});const n=i.type.toLowerCase();if(n.search("mesh")>-1){const e=i;if(Array.isArray(e.material)){const s=[];e.material.forEach(a=>{s.push(Et(a))}),t.material=s}else t.material=Et(e.material)}else if(n.search("points")>-1){const e=i;if(Array.isArray(e.material)){const s=[];e.material.forEach(a=>{s.push(Et(a))}),t.material=s}else t.material=Et(e.material)}else if(n.search("line")>-1){const e=i;if(Array.isArray(e.material)){const s=[];e.material.forEach(a=>{s.push(Et(a))}),t.material=s}else t.material=Et(e.material)}else n.search("camera")>-1?i.type==="PerspectiveCamera"?t.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"&&(t.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&&(t.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 t}function xn(i,t){const n=t.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 Sn(i,t){for(const n in t)i[n]=t[n]}function fe(i,t,n){if(i===void 0)return;const e=t.split("."),s=e.length;if(typeof n!="object")switch(s){case 1:i[e[0]]=n;break;case 2:i[e[0]][e[1]]=n;break;case 3:i[e[0]][e[1]][e[2]]=n;break;case 4:i[e[0]][e[1]][e[2]][e[3]]=n;break;case 5:i[e[0]][e[1]][e[2]][e[3]][e[4]]=n;break}else{let o;switch(s){case 1:o=i[e[0]];break;case 2:o=i[e[0]][e[1]];break;case 3:o=i[e[0]][e[1]][e[2]];break;case 4:o=i[e[0]][e[1]][e[2]][e[3]];break;case 5:o=i[e[0]][e[1]][e[2]][e[3]][e[4]];break}o!=null&&Sn(o,n)}}function en(i){return new Promise((t,n)=>{const e=new Image;e.onload=()=>{const s=new f.Texture(e);s.wrapS=f.RepeatWrapping,s.wrapT=f.RepeatWrapping,s.needsUpdate=!0,t(s)},e.onerror=n,e.src=i})}class wn extends Ht{scene=void 0;scenes=new Map;renderer=void 0;renderTargets=new Map;dispose(){this.scenes.forEach(t=>{zt(t)}),this.scenes.clear(),this.scene&&zt(this.scene),this.renderTargets.forEach(t=>{t.dispose()}),this.renderTargets.clear(),this.renderer?.dispose()}getObject(t){this.app.debugEnabled&&(this.renderer!==void 0&&(jt.renderer=this.renderer),this.app.send({event:"getObject",target:"app",data:t}))}setObject(t){this.renderer!==void 0&&(jt.renderer=this.renderer);const n=ci(t);this.app.send({event:"setObject",target:"editor",data:n})}requestMethod(t,n,e,s){this.app.send({event:"requestMethod",target:"app",data:{uuid:t,key:n,value:e,subitem:s}})}updateObject(t,n,e){this.app.send({event:"updateObject",target:"app",data:{uuid:t,key:n,value:e}})}createTexture(t,n,e){this.app.send({event:"createTexture",target:"app",data:{uuid:t,key:n,value:e}})}addScene(t){if(t===void 0||(this.scenes.set(t.name,t),!this.app.debugEnabled))return;Ei(),ti(t);const n=wt(t);this.app.send({event:"addScene",target:"editor",data:n})}refreshScene(t){if(!this.app.debugEnabled)return;const n=this.scenes.get(t);if(n!==void 0){const e=wt(n);this.app.send({event:"refreshScene",target:"app",data:e})}}removeScene(t){if(t===void 0||(this.scenes.delete(t.name),!this.app.debugEnabled))return;const n=wt(t);this.app.send({event:"removeScene",target:"editor",data:n})}removeAllScenes(){this.scenes.forEach(t=>this.removeScene(t))}getScene(t){let n=null;return this.scenes.forEach((e,s)=>{t.search(s)>-1&&(n=e)}),n}setScene(t){if(t===void 0||(this.scene=t,!this.app.debugEnabled))return;this.renderer!==void 0&&(jt.renderer=this.renderer),Ei(),ti(t);const n=wt(t);this.app.send({event:"setScene",target:"editor",data:n})}addCamera(t){if(!this.app.debugEnabled)return;const n=ci(t);this.app.send({event:"addCamera",target:"editor",data:n})}removeCamera(t){if(!this.app.debugEnabled)return;const n=ci(t);this.app.send({event:"removeCamera",target:"editor",data:n})}handleApp(t,n,e){switch(e.event){case"getObject":H.dispatchEvent({type:V.GET_OBJECT,value:e.data});break;case"updateObject":H.dispatchEvent({type:V.UPDATE_OBJECT,value:e.data});break;case"createTexture":H.dispatchEvent({type:V.CREATE_TEXTURE,value:e.data});break;case"requestMethod":H.dispatchEvent({type:V.REQUEST_METHOD,value:e.data});break;case"refreshScene":t.send({event:"refreshScene",target:"editor",data:wt(n.scenes.get(e.data.name))});break}}handleEditor(t,n,e){switch(e.event){case"setObject":H.dispatchEvent({type:V.SET_OBJECT,value:e.data});break;case"addScene":H.dispatchEvent({type:V.ADD_SCENE,value:e.data});break;case"refreshScene":H.dispatchEvent({type:V.REFRESH_SCENE,value:e.data});break;case"removeScene":H.dispatchEvent({type:V.REMOVE_SCENE,value:e.data});break;case"setScene":H.dispatchEvent({type:V.SET_SCENE,value:e.data});break;case"addCamera":H.dispatchEvent({type:V.ADD_CAMERA,value:e.data});break;case"removeCamera":H.dispatchEvent({type:V.REMOVE_CAMERA,value:e.data});break}}rendererWidth=300;rendererHeight=150;addRT(t,n){const e=new f.WebGLRenderTarget(32,32,n);e.texture.name=t,this.renderTargets.set(t,e)}resize(t,n){const e=this.dpr;this.rendererWidth=t,this.rendererHeight=n,this.renderTargets.forEach(s=>{s.setSize(t*e,n*e)}),this.renderer?.setSize(t,n)}set dpr(t){this.renderer?.setPixelRatio(ct(1,2,t))}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 Mn extends Ht{bindCBs;buttonCBs;pane=void 0;appCallbacks=0;editorCallbacks=0;inspectorFolder=void 0;constructor(t){super(t),this.bindCBs=new Map,this.buttonCBs=new Map,t.editor&&this.createGUI()}createGUI(){this.pane=new un.Pane({title:"GUI"}),this.pane.registerPlugin(pn)}dispose(){this.bindCBs.clear(),this.buttonCBs.clear(),this.appCallbacks=0,this.editorCallbacks=0,this.app.editor&&(this.pane?.dispose(),this.pane=void 0)}addFolder(t,n=void 0,e=void 0){if(this.app.editor)return this.pane===void 0&&this.createGUI(),(e!==void 0?e:this.pane).addFolder({title:t,...n});this.app.send({event:"addFolder",target:"app",data:{name:t,params:n,parent:e}})}get bindID(){return`debug_${Math.max(this.appCallbacks,this.editorCallbacks)}`}bind(t,n,e,s=void 0){const a=this.bindID,o=e.onChange!==void 0?e.onChange:ni;this.bindCBs.set(a,o),this.app.editor?(this.pane===void 0&&this.createGUI(),(s!==void 0?s:this.pane).addBinding(t,n,e).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:e,parent:s}}),this.appCallbacks++)}triggerBind(t,n){const e=this.bindCBs.get(t);e!==void 0?e(n):console.warn(`No callback for: ${t}`,n)}button(t,n,e=void 0){const s=this.bindID;this.buttonCBs.set(s,n),this.app.editor?(this.pane===void 0&&this.createGUI(),(e!==void 0?e:this.pane).addButton({title:t}).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:t,callback:n,parent:e}}),this.appCallbacks++)}triggerButton(t){const n=this.buttonCBs.get(t);n!==void 0&&n()}createInspector(){this.inspectorFolder=this.addFolder("Inspector",this.pane)}clearInspector(){const t=this.inspectorFolder.children.length-1;for(let n=t;n>-1;--n)this.inspectorFolder.remove(this.inspectorFolder.children[n])}handleApp(t,n,e){const s=n;switch(e.event){case"addFolder":s.addFolder(e.data.name,e.data.params,e.data.parent);break;case"bindObject":s.bind(e.data.name,e.data.params,e.data.parent);break;case"updateBind":s.triggerBind(e.data.id,e.data.value);break;case"addButton":s.button(e.data.name,e.data.callback,e.data.parent);break;case"clickButton":s.triggerButton(e.data.id);break}}}var bi={exports:{}},Rt={};/**
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 Ri;function Rn(){if(Ri)return Rt;Ri=1;var i=x,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),e=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 m,p={},v=null,y=null;c!==void 0&&(v=""+c),h.key!==void 0&&(v=""+h.key),h.ref!==void 0&&(y=h.ref);for(m in h)e.call(h,m)&&!a.hasOwnProperty(m)&&(p[m]=h[m]);if(r&&r.defaultProps)for(m in h=r.defaultProps,h)p[m]===void 0&&(p[m]=h[m]);return{$$typeof:t,type:r,key:v,ref:y,props:p,_owner:s.current}}return Rt.Fragment=n,Rt.jsx=o,Rt.jsxs=o,Rt}var Dt={};/**
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,25 +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 Di;function Dn(){return Di||(Di=1,process.env.NODE_ENV!=="production"&&function(){var i=x,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),e=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"),m=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),y=Symbol.for("react.offscreen"),D=Symbol.iterator,L="@@iterator";function U(l){if(l===null||typeof l!="object")return null;var O=D&&l[D]||l[L];return typeof O=="function"?O:null}var g=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),B=1;B<O;B++)M[B-1]=arguments[B];w("error",l,M)}}function w(l,O,M){{var B=g.ReactDebugCurrentFrame,ee=B.getStackAddendum();ee!==""&&(O+="%s",M=M.concat([ee]));var se=M.map(function(K){return String(K)});se.unshift("Warning: "+O),Function.prototype.apply.call(console[l],console,se)}}var C=!1,k=!1,I=!1,T=!1,ie=!1,q;q=Symbol.for("react.module.reference");function We(l){return!!(typeof l=="string"||typeof l=="function"||l===e||l===a||ie||l===s||l===c||l===m||T||l===y||C||k||I||typeof l=="object"&&l!==null&&(l.$$typeof===v||l.$$typeof===p||l.$$typeof===o||l.$$typeof===r||l.$$typeof===h||l.$$typeof===q||l.getModuleId!==void 0))}function Y(l,O,M){var B=l.displayName;if(B)return B;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 e:return"Fragment";case n:return"Portal";case a:return"Profiler";case s:return"StrictMode";case c:return"Suspense";case m: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 p:var B=l.displayName||null;return B!==null?B:Ee(l.type)||"Memo";case v:{var ee=l,se=ee._payload,K=ee._init;try{return Ee(K(se))}catch{return null}}}return null}var Ce=Object.assign,Te=0,Ie,Ve,nt,Qe,Je,lt,st;function pe(){}pe.__reactDisabledLog=!0;function Ye(){{if(Te===0){Ie=console.log,Ve=console.info,nt=console.warn,Qe=console.error,Je=console.group,lt=console.groupCollapsed,st=console.groupEnd;var l={configurable:!0,enumerable:!0,value:pe,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:Ie}),info:Ce({},l,{value:Ve}),warn:Ce({},l,{value:nt}),error:Ce({},l,{value:Qe}),group:Ce({},l,{value:Je}),groupCollapsed:Ce({},l,{value:lt}),groupEnd:Ce({},l,{value:st})})}Te<0&&E("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var dt=g.ReactCurrentDispatcher,we;function b(l,O,M){{if(we===void 0)try{throw Error()}catch(ee){var B=ee.stack.trim().match(/\n( *(at )?)/);we=B&&B[1]||""}return`
18
- `+we+l}}var S=!1,P;{var F=typeof WeakMap=="function"?WeakMap:Map;P=new F}function de(l,O){if(!l||S)return"";{var M=P.get(l);if(M!==void 0)return M}var B;S=!0;var ee=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var se;se=dt.current,dt.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){B=tt}Reflect.construct(l,[],K)}else{try{K.call()}catch(tt){B=tt}l.call(K.prototype)}}else{try{throw Error()}catch(tt){B=tt}l()}}catch(tt){if(tt&&B&&typeof tt.stack=="string"){for(var $=tt.stack.split(`
19
- `),Se=B.stack.split(`
20
- `),me=$.length-1,ye=Se.length-1;me>=1&&ye>=0&&$[me]!==Se[ye];)ye--;for(;me>=1&&ye>=0;me--,ye--)if($[me]!==Se[ye]){if(me!==1||ye!==1)do if(me--,ye--,ye<0||$[me]!==Se[ye]){var je=`
21
- `+$[me].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(me>=1&&ye>=0);break}}}finally{S=!1,dt.current=se,Mt(),Error.prepareStackTrace=ee}var yt=l?l.displayName||l.name:"",Mi=yt?b(yt):"";return typeof l=="function"&&P.set(l,Mi),Mi}function _e(l,O,M){return de(l,!1)}function A(l){var O=l.prototype;return!!(O&&O.isReactComponent)}function j(l,O,M){if(l==null)return"";if(typeof l=="function")return de(l,A(l));if(typeof l=="string")return b(l);switch(l){case c:return b("Suspense");case m:return b("SuspenseList")}if(typeof l=="object")switch(l.$$typeof){case h:return _e(l.render);case p:return j(l.type,O,M);case v:{var B=l,ee=B._payload,se=B._init;try{return j(se(ee),O,M)}catch{}}}return""}var ge=Object.prototype.hasOwnProperty,Ae={},Ke=g.ReactDebugCurrentFrame;function W(l){if(l){var O=l._owner,M=j(l.type,l._source,O?O.type:null);Ke.setExtraStackFrame(M)}else Ke.setExtraStackFrame(null)}function oe(l,O,M,B,ee){{var se=Function.call.bind(ge);for(var K in l)if(se(l,K)){var $=void 0;try{if(typeof l[K]!="function"){var Se=Error((B||"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}$=l[K](O,K,B,M,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(me){$=me}$&&!($ instanceof Error)&&(W(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).",B||"React class",M,K,typeof $),W(null)),$ instanceof Error&&!($.message in Ae)&&(Ae[$.message]=!0,W(ee),E("Failed %s type: %s",M,$.message),W(null))}}}var Oe=Array.isArray;function re(l){return Oe(l)}function he(l){{var O=typeof Symbol=="function"&&Symbol.toStringTag,M=O&&l[Symbol.toStringTag]||l.constructor.name||"Object";return M}}function z(l){try{return ne(l),!1}catch{return!0}}function ne(l){return""+l}function ve(l){if(z(l))return E("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",he(l)),ne(l)}var ue=g.ReactCurrentOwner,Me={key:!0,ref:!0,__self:!0,__source:!0},Le,et,Ze;Ze={};function gt(l){if(ge.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(ge.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);Ze[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),Ze[M]=!0)}}function Vt(l,O){{var M=function(){Le||(Le=!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(){et||(et=!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 Si=function(l,O,M,B,ee,se,K){var $={$$typeof:t,type:l,key:O,ref:M,props:K,_owner:se};return $._store={},Object.defineProperty($._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty($,"_self",{configurable:!1,enumerable:!1,writable:!1,value:B}),Object.defineProperty($,"_source",{configurable:!1,enumerable:!1,writable:!1,value:ee}),Object.freeze&&(Object.freeze($.props),Object.freeze($)),$};function d(l,O,M,B,ee){{var se,K={},$=null,Se=null;M!==void 0&&(ve(M),$=""+M),ri(O)&&(ve(O.key),$=""+O.key),gt(O)&&(Se=O.ref,oi(O,ee));for(se in O)ge.call(O,se)&&!Me.hasOwnProperty(se)&&(K[se]=O[se]);if(l&&l.defaultProps){var me=l.defaultProps;for(se in me)K[se]===void 0&&(K[se]=me[se])}if($||Se){var ye=typeof l=="function"?l.displayName||l.name||"Unknown":l;$&&Vt(K,ye),Se&&at(K,ye)}return Si(l,$,Se,ee,B,ue.current,K)}}var R=g.ReactCurrentOwner,G=g.ReactDebugCurrentFrame;function X(l){if(l){var O=l._owner,M=j(l.type,l._source,O?O.type:null);G.setExtraStackFrame(M)}else G.setExtraStackFrame(null)}var be;be=!1;function ke(l){return typeof l=="object"&&l!==null&&l.$$typeof===t}function xe(){{if(R.current){var l=Ee(R.current.type);if(l)return`
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 \``+l+"`."}return""}}function wi(l){{if(l!==void 0){var O=l.fileName.replace(/^.*[\\\/]/,""),M=l.lineNumber;return`
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 `+O+":"+M+"."}return""}}var Yt={};function Zt(l){{var O=xe();if(!O){var M=typeof l=="string"?l:l.displayName||l.name;M&&(O=`
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 <`+M+">.")}return O}}function Ue(l,O){{if(!l._store||l._store.validated||l.key!=null)return;l._store.validated=!0;var M=Zt(O);if(Yt[M])return;Yt[M]=!0;var B="";l&&l._owner&&l._owner!==R.current&&(B=" 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,B),X(null)}}function Fe(l,O){{if(typeof l!="object")return;if(re(l))for(var M=0;M<l.length;M++){var B=l[M];ke(B)&&Ue(B,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 se=ee.call(l),K;!(K=se.next()).done;)ke(K.value)&&Ue(K.value,O)}}}function ht(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===p))M=O.propTypes;else return;if(M){var B=Ee(O);oe(M,l.props,"prop",B,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 B=O[M];if(B!=="children"&&B!=="key"){X(l),E("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",B),X(null);break}}l.ref!==null&&(X(l),E("Invalid attribute `ref` supplied to `React.Fragment`."),X(null))}}function rt(l,O,M,B,ee,se){{var K=We(l);if(!K){var $="";(l===void 0||typeof l=="object"&&l!==null&&Object.keys(l).length===0)&&($+=" 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=wi(ee);Se?$+=Se:$+=xe();var me;l===null?me="null":re(l)?me="array":l!==void 0&&l.$$typeof===t?(me="<"+(Ee(l.type)||"Unknown")+" />",$=" Did you accidentally export a JSX literal instead of a component?"):me=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",me,$)}var ye=d(l,O,M,ee,se);if(ye==null)return ye;if(K){var je=O.children;if(je!==void 0)if(B)if(re(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===e?Ge(ye):ht(ye),ye}}function vt(l,O,M){return rt(l,O,M,!0)}function Gt(l,O,M){return rt(l,O,M,!1)}var dn=Gt,hn=vt;Dt.Fragment=e,Dt.jsx=dn,Dt.jsxs=hn}()),Dt}process.env.NODE_ENV==="production"?bi.exports=Rn():bi.exports=Dn();var u=bi.exports;function Ti(i){return i.title.search("<")>-1?u.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:i.title}}):u.jsx("button",{children:i.title})}const An=u.jsxs("svg",{className:"closeIcon",width:"14",height:"14",fill:"none",stroke:"#666666",strokeMiterlimit:"10",children:[u.jsx("circle",{cx:"7",cy:"7",r:"6"}),u.jsx("line",{x1:"4",y1:"4",x2:"10",y2:"10"}),u.jsx("line",{x1:"4",y1:"10",x2:"10",y2:"4"})]}),Pn=u.jsx("svg",{className:"dragIcon",width:"14",height:"14",fill:"#666666",stroke:"none",children:u.jsx("path",{d:`M10.43,4H3.57C3.26,4,3,4.22,3,4.5v1C3,5.78,3.26,6,3.57,6h6.86C10.74,6,11,5.78,11,5.5v-1
27
+ Check the top-level render call using <`+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 tn(i){return u.jsx(Ki.Reorder.Item,{value:i.title,children:u.jsxs("div",{children:[Pn,u.jsx("span",{children:i.title}),u.jsx("button",{className:"closeIcon",onClick:()=>{i.onDelete(i.index)},children:An})]})},i.title)}function nn(i){const[t,n]=x.useState(!1),[e,s]=x.useState(i.options),a=c=>{i.onDragComplete(c),s(c)},o=c=>{const m=[...e];m.splice(c,1),a(m)},r=[];e.forEach((c,m)=>{r.push(u.jsx(tn,{index:m,title:c,onDelete:o},c))});let h="dropdown draggable";return i.subdropdown&&(h+=" subdropdown"),u.jsxs("div",{className:h,onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[u.jsx(Ti,{title:i.title}),u.jsx(Ki.Reorder.Group,{axis:"y",values:e,onReorder:a,style:{visibility:t?"visible":"hidden"},children:r})]})}function sn(i){const[t,n]=x.useState(!1),e=[];i.options.map((a,o)=>{i.onSelect!==void 0&&(a.onSelect=i.onSelect),e.push(u.jsx(an,{option:a},o))});let s="dropdown";return i.subdropdown&&(s+=" subdropdown"),u.jsxs("div",{className:s,onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[u.jsx(Ti,{title:i.title}),u.jsx("ul",{style:{visibility:t?"visible":"hidden"},children:e})]})}function an(i){const{option:t}=i,[n,e]=x.useState("");let s;switch(t.type){case"draggable":s=u.jsx(nn,{title:t.title,options:t.value,onDragComplete:a=>{t.onDragComplete!==void 0&&t.onDragComplete(a)},subdropdown:!0});break;case"dropdown":s=u.jsx(sn,{title:t.title,options:t.value,onSelect:t.onSelect,subdropdown:!0});break;case"option":s=u.jsx("button",{onClick:()=>{t.onSelect!==void 0&&t.onSelect(t.value),t.selectable&&(n!==t.title?e(t.title):e(""))},children:t.title});break}return u.jsx("li",{className:n===t.title?"selected":"",children:s},Xi())}function In(i,t,n){function e(a){switch(t.forEach(o=>{o.callback(i,o.remote,a)}),a.event){case"custom":H.dispatchEvent({type:V.CUSTOM,value:a.data});break}}function s(a){switch(n.forEach(o=>{o.callback(i,o.remote,a)}),a.event){case"custom":H.dispatchEvent({type:V.CUSTOM,value:a.data});break}}i.listen=a=>{a.target==="editor"?s(a):e(a)}}function Bt(i){const[t,n]=x.useState(i.open!==void 0?i.open:!0),e=!t||i.children===void 0,s=()=>{H.dispatchEvent({type:V.REMOVE_SCENE,value:i.scene})};return u.jsxs("div",{className:`accordion ${e?"hide":""}`,children:[u.jsxs("button",{className:"toggle",onClick:()=>{const a=!t;i.onToggle!==void 0&&i.onToggle(a),n(a)},children:[u.jsx("p",{className:`status ${t?"open":""}`,children:"Toggle"}),u.jsx("p",{className:"label",children:Nt(i.label)})]}),i.onRefresh?u.jsxs(u.Fragment,{children:[u.jsx("button",{className:"refresh",onClick:i.onRefresh}),u.jsx("button",{className:"remove",onClick:s})]}):null,i.button,u.jsx("div",{className:t?"open":"",children:u.jsx("div",{children:i.children})},Math.random())]})}function xi(i){const t=x.useRef(null),[n,e]=x.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(u.jsx(xi,{child:o,three:i.three},r))}),x.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&&(t.current.style.opacity=r.visible?"1":"0.25")}}},[n]),u.jsx(u.Fragment,{children:i.child!==void 0&&u.jsxs("div",{className:"childObject",children:[u.jsxs("div",{className:"child",children:[s?u.jsx("button",{className:"status",style:{backgroundPositionX:n?"-14px":"2px"},onClick:()=>{e(!n)}}):null,u.jsx("button",{className:"name",style:{left:s?"20px":"5px"},onClick:()=>{i.child!==void 0&&(i.three.getObject(i.child.uuid),n||e(!0))},children:i.child.name.length>0?`${i.child.name} (${i.child.type})`:`${i.child.type}::${i.child.uuid}`}),u.jsx("button",{className:"visibility",ref:t,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;t.current.style.opacity=c?"1":"0.25",i.three.updateObject(i.child.uuid,h,c),fe(r,h,c)}}}}}),u.jsx("div",{className:`icon ${On(i.child)}`})]}),u.jsx("div",{className:n?"open":"",children:u.jsx("div",{className:"container",children:a})})]},Math.random())})}function Oi(i){const t=[];return i.child?.children.map((n,e)=>{t.push(u.jsx(xi,{child:n,scene:i.scene,three:i.three},e))}),u.jsx("div",{className:`scene ${i.class!==void 0?i.class:""}`,children:t})}function Ln(i){const[t,n]=x.useState(i.defaultValue);return x.useEffect(()=>{let e=!1,s=-1,a=0,o=i.defaultValue;const r=v=>{e=!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(!e)return;const y=i.step!==void 0?i.step:1,D=(v.clientX-s)*y;o=Number((a+D).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=()=>{e=!1,document.removeEventListener("mouseup",c),document.removeEventListener("mousemove",h),document.removeEventListener("contextmenu",c)},m=v=>{const y=Number(v.target.value);n(y)},p=v=>{const y=Number(v.target.value);i.onChange!==void 0&&i.onChange(y),n(y)};return i.input.current?.addEventListener("input",m),i.label.current?.addEventListener("mousedown",r,!1),i.sliderRef!==void 0&&i.sliderRef.current?.addEventListener("input",p),()=>{i.input.current?.removeEventListener("input",m),i.label.current?.removeEventListener("mousedown",r),i.sliderRef!==void 0&&i.sliderRef.current?.removeEventListener("input",p),document.removeEventListener("mouseup",c),document.removeEventListener("mousemove",h),document.removeEventListener("contextmenu",c)}},[]),t}function pt(i){const t=x.useRef(null),n=x.useRef(null),e=Ln({label:i.labelRef,input:t,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 u.jsxs(u.Fragment,{children:[i.type==="number"&&u.jsx("input",{alt:i.alt,className:i.className,ref:t,type:"number",value:e,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"&&u.jsxs(u.Fragment,{children:[u.jsx("input",{type:"text",value:e.toString(),disabled:i.disabled,ref:t,className:"min",onChange:s=>{const a=Number(s.target.value);i.onChange!==void 0&&i.onChange(i.prop,a)}}),u.jsx("input",{disabled:i.disabled,type:"range",value:e,min:i.min,max:i.max,step:i.step,ref:n,onChange:ni})]})]})}function kn(i){const t=x.useRef(null),n=x.useRef(null),e=x.useRef(null),s=x.useRef(null),a=x.useRef(null),o=x.useRef(null),[r,h]=x.useState(i.value),[c,m]=x.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))}),[p,v]=x.useState(!1);function y(){p||(window.addEventListener("mousemove",L),window.addEventListener("mouseup",D),window.addEventListener("mouseup",D),v(!0))}function D(){window.removeEventListener("mousemove",L),window.removeEventListener("mouseup",D),v(!1)}function L(C){const k=a.current.getBoundingClientRect(),I=ct(0,99,C.clientX-k.left)/99,T=ct(0,99,C.clientY-k.top)/99,ie=yi(ei(c.min,c.max,I),3),q=yi(ei(c.min,c.max,T),3);i.onChange({target:{value:{x:ie,y:q}}}),h({x:ie,y:q})}function U(C){let k=r.x,I=r.y;C.target===t.current?k=Number(C.target.value):I=Number(C.target.value),h({x:k,y:I})}function g(){const C=Number(e.current.value);m({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);m({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)})}x.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 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:t,type:"number",value:r.x,min:c.min,max:c.max,step:w,onChange:U})]}),u.jsxs("div",{children:[u.jsx("label",{children:"Y:"}),u.jsx("input",{ref:n,type:"number",value:r.y,min:c.min,max:c.max,step:w,onChange:U})]}),u.jsxs("div",{children:[u.jsx("label",{children:"Min:"}),u.jsx("input",{ref:e,type:"number",value:c.min,step:w,onChange:g})]}),u.jsxs("div",{children:[u.jsx("label",{children:"Max:"}),u.jsx("input",{ref:s,type:"number",value:c.max,step:w,onChange:E})]})]}),u.jsxs("div",{className:"input",ref:a,onMouseDown:y,onMouseUp:D,children:[u.jsx("div",{className:"x"}),u.jsx("div",{className:"y"}),u.jsx("div",{className:"pt",ref:o})]})]})}function Ai(i){const t=i.value.isVector3!==void 0,n=i.value.isEuler!==void 0,e=i.value.elements!==void 0,s=i.step!==void 0?i.step:.01,a=[];if(t){const o=x.useMemo(()=>i.value,[]),r=(c,m)=>{o[c]=m,i.onChange({target:{value:o}})};["x","y","z"].forEach(c=>{const m=x.useRef(null);a.push(u.jsxs("div",{children:[u.jsx("label",{ref:m,children:c.toUpperCase()}),u.jsx(pt,{value:o[c],type:"number",prop:c,step:s,labelRef:m,onChange:r})]},c))})}else if(n){const o=x.useMemo(()=>i.value,[]),r=(c,m)=>{o[c]=m,i.onChange({target:{value:o}})};["_x","_y","_z"].forEach(c=>{const m=x.useRef(null);a.push(u.jsxs("div",{children:[u.jsx("label",{ref:m,children:c.substring(1).toUpperCase()}),u.jsx(pt,{value:o[c],type:"number",prop:c,step:s,labelRef:m,onChange:r})]},c))})}else if(e){const o=x.useMemo(()=>i.value,[]),r=(h,c)=>{const m=Number(h);o.elements[m]=c,i.onChange({target:{value:o}})};for(let h=0;h<9;h++){const c=x.useRef(null);a.push(u.jsxs("div",{children:[u.jsx("label",{ref:c,children:h+1}),u.jsx(pt,{value:o.elements[h],type:"number",prop:h.toString(),step:s,labelRef:c,onChange:r})]},h.toString()))}}return u.jsx("div",{className:"grid3",children:a},Math.random().toString())}function Un(i){const t=i.value.x!==void 0,n=i.step!==void 0?i.step:.01,e=[];if(t){const s=x.useMemo(()=>i.value,[]),a=(r,h)=>{s[r]=h,i.onChange({target:{value:s}})};["x","y","z","w"].forEach(r=>{const h=x.useRef(null);e.push(u.jsxs("div",{children:[u.jsx("label",{ref:h,children:r.toUpperCase()}),u.jsx(pt,{value:s.x,type:"number",prop:r,step:n,labelRef:h,onChange:a})]},r))})}else{const s=x.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=x.useRef(null);e.push(u.jsxs("div",{children:[u.jsx("label",{ref:r,children:o+1}),u.jsx(pt,{value:s.elements[o],type:"number",prop:o.toString(),step:n,labelRef:r,onChange:a})]},o.toString()))}}return u.jsx("div",{className:"grid4",children:e})}function Fn(i){return"items"in i}function _t(i){const t=[];return i.items.forEach(n=>{Fn(n)?t.push(u.jsx(_t,{title:Nt(n.title),items:n.items},Math.random())):t.push(u.jsx(Jt,{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:(e,s)=>{n.onChange!==void 0&&n.onChange(e,s)},onKeyDown:e=>{n.onKeyDown!==void 0&&n.onKeyDown(e)}},Math.random()))}),u.jsx(Bt,{label:i.title,open:i.expanded===!0,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"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 rn(i){const t=i.toLowerCase();return t.search("intensity")>-1||t==="anisotropyrotation"||t==="blendalpha"||t==="bumpscale"||t==="clearcoatroughness"||t==="displacementbias"||t==="displacementscale"||t==="metalness"||t==="opacity"||t==="reflectivity"||t==="refractionratio"||t==="roughness"||t==="sheenroughness"||t==="thickness"}function zn(){const i=document.createElement("input");return i.type="file",new Promise((t,n)=>{i.addEventListener("change",function(){if(i.files===null)n();else{const e=i.files[0],s=new FileReader;s.onload=function(a){t(a.target.result)},s.readAsDataURL(e)}}),i.click()})}const Bn=[{title:"Front",value:f.FrontSide},{title:"Back",value:f.BackSide},{title:"Double",value:f.DoubleSide}],Hn=[{title:"No Blending",value:f.NoBlending},{title:"Normal",value:f.NormalBlending},{title:"Additive",value:f.AdditiveBlending},{title:"Subtractive",value:f.SubtractiveBlending},{title:"Multiply",value:f.MultiplyBlending},{title:"Custom",value:f.CustomBlending}],Vn=[{title:"Add",value:f.AddEquation},{title:"Subtract",value:f.SubtractEquation},{title:"Reverse Subtract",value:f.ReverseSubtractEquation},{title:"Min",value:f.MinEquation},{title:"Max",value:f.MaxEquation}],Yn=[{title:"Zero",valye:f.ZeroFactor},{title:"One",valye:f.OneFactor},{title:"Src Color",valye:f.SrcColorFactor},{title:"One Minus Src Color",valye:f.OneMinusSrcColorFactor},{title:"Src Alpha",valye:f.SrcAlphaFactor},{title:"One Minus Src Alpha",valye:f.OneMinusSrcAlphaFactor},{title:"Dst Alpha",valye:f.DstAlphaFactor},{title:"One Minus Dst Alpha",valye:f.OneMinusDstAlphaFactor},{title:"Dst Color",valye:f.DstColorFactor},{title:"One Minus Dst Color",valye:f.OneMinusDstColorFactor},{title:"Src Alpha Saturate",valye:f.SrcAlphaSaturateFactor},{title:"Constant Color",valye:f.ConstantColorFactor},{title:"One Minus Constant Color",valye:f.OneMinusConstantColorFactor},{title:"Constant Alpha",valye:f.ConstantAlphaFactor},{title:"One Minus Constant Alpha",valye:f.OneMinusConstantAlphaFactor}],Zn=[{title:"Zero",valye:f.ZeroFactor},{title:"One",valye:f.OneFactor},{title:"Src Color",valye:f.SrcColorFactor},{title:"One Minus Src Color",valye:f.OneMinusSrcColorFactor},{title:"Src Alpha",valye:f.SrcAlphaFactor},{title:"One Minus Src Alpha",valye:f.OneMinusSrcAlphaFactor},{title:"Dst Alpha",valye:f.DstAlphaFactor},{title:"One Minus Dst Alpha",valye:f.OneMinusDstAlphaFactor},{title:"Dst Color",valye:f.DstColorFactor},{title:"One Minus Dst Color",valye:f.OneMinusDstColorFactor},{title:"Constant Color",valye:f.ConstantColorFactor},{title:"One Minus Constant Color",valye:f.OneMinusConstantColorFactor},{title:"Constant Alpha",valye:f.ConstantAlphaFactor},{title:"One Minus Constant Alpha",valye:f.OneMinusConstantAlphaFactor}];function At(i,t){i.needsUpdate=!0,i.type="option",i.options=t}function Gn(i,t,n,e){return{type:"boolean",title:ai(i),prop:i,value:t,needsUpdate:!0,onChange:(s,a)=>{e.updateObject(n.uuid,`material.${i}`,a),e.updateObject(n.uuid,"material.needsUpdate",!0);const o=e.getScene(n.uuid);if(o!==null){const r=o.getObjectByProperty("uuid",n.uuid);fe(r,`material.${i}`,a)}}}}function $n(i,t,n,e){const s={type:"number",title:ai(i),prop:i,value:t,min:void 0,max:void 0,step:.01,needsUpdate:!0,onChange:(a,o)=>{e.updateObject(n.uuid,`material.${i}`,o),e.updateObject(n.uuid,"material.needsUpdate",!0);const r=e.getScene(n.uuid);if(r!==null){const h=r.getObjectByProperty("uuid",n.uuid);fe(h,`material.${i}`,o)}}};switch(i){case"blending":At(s,Hn);break;case"blendDst":At(s,Zn);break;case"blendEquation":At(s,Vn);break;case"blendSrc":At(s,Yn);break;case"side":At(s,Bn);break}return rn(i)&&(s.value=Number(t),s.type="range",s.min=Math.min(0,s.value),s.max=Math.max(1,s.value),s.step=.01),s}function Wn(i,t,n,e){const s={type:"string",title:ai(i),prop:i,value:t,needsUpdate:!0,onChange:(o,r)=>{e.updateObject(n.uuid,`material.${i}`,r),e.updateObject(n.uuid,"material.needsUpdate",!0);const h=e.getScene(n.uuid);if(h!==null){const c=h.getObjectByProperty("uuid",n.uuid);fe(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,e.updateObject(n.uuid,`material.${i}`,r);const h=e.getScene(n.uuid);if(h!==null){const c=h.getObjectByProperty("uuid",n.uuid);fe(c,`material.${i}`,r)}},s.onKeyDown=o=>{if(o.key==="Enter"&&(o.altKey||o.metaKey)){e.updateObject(n.uuid,"material.needsUpdate",!0);const r=e.getScene(n.uuid);if(r!==null){const h=r.getObjectByProperty("uuid",n.uuid);fe(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 Ci(i){i.sort((t,n)=>t.title<n.title?-1:t.title>n.title?1:0)}function Ft(i,t,n,e,s="",a=!1){const o=ai(i).split(".")[0].replaceAll("[","").replaceAll("]",""),r=s.length>0?`${s}.${i}`:i,h=typeof t;if(h==="boolean"||h==="string")return{title:o,prop:r,type:h,value:t,disabled:a,onChange:(c,m)=>{e.updateObject(n.uuid,`material.${r}`,m);const p=e.getScene(n.uuid);if(p!==null){const v=p.getObjectByProperty("uuid",n.uuid);fe(v,`material.${r}`,m)}}};if(h==="number"){const c={title:o,prop:r,type:"number",value:t,step:.01,disabled:a,onChange:(m,p)=>{e.updateObject(n.uuid,`material.${r}`,p);const v=e.getScene(n.uuid);if(v!==null){const y=v.getObjectByProperty("uuid",n.uuid);fe(y,`material.${r}`,p)}}};return rn(o)&&(c.type="range",c.min=0,c.max=1),c}else{if(t.isColor)return{title:o,prop:r,type:"color",value:t,disabled:a,onChange:(c,m)=>{const p=new f.Color(m);e.updateObject(n.uuid,`material.${r}`,p);const v=e.getScene(n.uuid);if(v!==null){const y=v.getObjectByProperty("uuid",n.uuid);fe(y,`material.${r}`,p)}}};if(Array.isArray(t)){const c=[];for(const m in t){const p=t[m],v=`[${m.toString()}]`;if(p.value!==void 0){const y=Ft(`${v}.value`,p.value,n,e,r,a);y!==void 0&&c.push(y)}else{const y=Ft(v,p,n,e,r,a);y!==void 0&&c.push(y)}}if(c.length>0)return Ci(c),{title:o,items:c}}else{if(Kn(t))return{title:o,prop:r,type:"vector2",value:t,disabled:a,onChange:(c,m)=>{e.updateObject(n.uuid,`material.${r}`,m);const p=e.getScene(n.uuid);if(p!==null){const v=p.getObjectByProperty("uuid",n.uuid);fe(v,`material.${r}`,m)}}};if(Xn(t))return{title:o,prop:r,type:"grid3",value:t,disabled:a,onChange:(c,m)=>{e.updateObject(n.uuid,`material.${r}`,m);const p=e.getScene(n.uuid);if(p!==null){const v=p.getObjectByProperty("uuid",n.uuid);fe(v,`material.${r}`,m)}}};if(qn(t))return{title:o,prop:r,type:"grid4",value:t,disabled:a,onChange:(c,m)=>{e.updateObject(n.uuid,`material.${r}`,m);const p=e.getScene(n.uuid);if(p!==null){const v=p.getObjectByProperty("uuid",n.uuid);fe(v,`material.${r}`,m)}}};if(t.isEuler)return{title:o,prop:r,type:"euler",value:t,disabled:a,onChange:(c,m)=>{e.updateObject(n.uuid,`material.${r}`,m);const p=e.getScene(n.uuid);if(p!==null){const v=p.getObjectByProperty("uuid",n.uuid);fe(v,`material.${r}`,m)}}};if(t.src!==void 0)return{title:o,type:"image",value:t,disabled:a,onChange:(c,m)=>{const p=Nn(i),v=s.length>0?`${s}.${p}`:p;e.createTexture(n.uuid,`material.${v}`,m);const y=e.getScene(n.uuid);if(y!==null){const D=y.getObjectByProperty("uuid",n.uuid);if(D!==void 0){const L=U=>{const g=D.material,E=v.split(".");switch(E.length){case 1:g[E[0]]=U;break;case 2:g[E[0]][E[1]]=U;break;case 3:g[E[0]][E[1]][E[2]]=U;break;case 4:g[E[0]][E[1]][E[2]][E[3]]=U;break;case 5:g[E[0]][E[1]][E[2]][E[3]][E[4]]=U;break}g.needsUpdate=!0};m.src.length>0?en(m.src).then(U=>{U.offset.set(m.offset[0],m.offset[1]),U.repeat.set(m.repeat[0],m.repeat[1]),L(U)}):L(null)}}}};if(t.elements!==void 0)return{title:o,prop:r,type:t.elements.length>9?"grid4":"grid3",value:t,disabled:a,onChange:(c,m)=>{e.updateObject(n.uuid,`material.${r}`,m);const p=e.getScene(n.uuid);if(p!==null){const v=p.getObjectByProperty("uuid",n.uuid);fe(v,`material.${r}`,m)}}};{const c=[],m=i==="defines"||i==="extensions";try{for(const p in t){const v=t[p];if(v!==void 0)if(v.value!==void 0){const y=Ft(`${p}.value`,v.value,n,e,r,m);y!==void 0&&c.push(y)}else{const y=Ft(p,v,n,e,r,m);y!==void 0&&c.push(y)}}}catch{console.log("Issue cycling through material object:",i,t)}if(c.length>0)return Ci(c),{title:o,items:c}}}}}function Pi(i,t,n){const e=[];for(const s in i){if(!jn(s))continue;const a=typeof i[s],o=i[s];if(a==="boolean")e.push(Gn(s,o,t,n));else if(a==="number")e.push($n(s,o,t,n));else if(a==="string")e.push(Wn(s,o,t,n));else if(a==="object"){const r=Ft(s,o,t,n);r!==void 0&&e.push(r)}else o!==void 0&&console.log("other:",s,a,o)}return Ci(e),e.push({title:"Update Material",type:"button",onChange:()=>{n.updateObject(t.uuid,"material.needsUpdate",!0);const s=n.getScene(t.uuid);if(s!==null){const a=s.getObjectByProperty("uuid",t.uuid);fe(a,"material.needsUpdate",!0)}}}),e}function Qn(i,t){const n=i.material;if(Array.isArray(n)){const e=[],s=n.length;for(let a=0;a<s;a++)e.push(u.jsx(_t,{title:`Material ${a}`,items:Pi(n[a],i,t)},`Material ${a}`));return u.jsx(u.Fragment,{children:e})}else return u.jsx(_t,{title:"Material",items:Pi(n,i,t)})}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 Jn(i){const t=i.step!==void 0?i.step:.01,n=x.useRef(null),e=x.useRef(null),s=x.useRef(null),a=x.useRef(null),o=x.useRef(null),[r]=x.useState(i.value),[h,c]=x.useState(i.value.offset[0]),[m,p]=x.useState(i.value.offset[1]),[v,y]=x.useState(i.value.repeat[0]),[D,L]=x.useState(i.value.repeat[1]);function U(E,w,C,k,I){if(i.onChange!==void 0){const T=i.prop!==void 0?i.prop:i.title;i.onChange(T,{src:E,offset:[w,C],repeat:[k,I]})}}function g(E){const w=n.current.src,C=E.target.value;switch(E.target){case e.current:c(C),U(w,C,m,v,D);break;case s.current:p(C),U(w,h,C,v,D);break;case a.current:y(C),U(w,h,m,C,D);break;case o.current:L(C),U(w,h,m,v,C);break}}return u.jsxs("div",{className:"imageField",children:[u.jsx("img",{alt:i.title,ref:n,onClick:()=>{zn().then(E=>{n.current.src=E,U(E,h,m,v,D)})},src:r.src.length>0?r.src:Ii}),u.jsxs("div",{className:"fields",children:[u.jsxs("div",{children:[u.jsx("label",{children:"Offset:"}),u.jsx("input",{ref:e,type:"number",value:h,step:t,onChange:g}),u.jsx("input",{ref:s,type:"number",value:m,step:t,onChange:g})]}),u.jsxs("div",{children:[u.jsx("label",{children:"Repeat:"}),u.jsx("input",{ref:a,type:"number",value:v,step:t,onChange:g}),u.jsx("input",{ref:o,type:"number",value:D,step:t,onChange:g})]}),u.jsx("button",{onClick:()=>{U("",h,m,v,D),n.current.src=Ii},children:"Clear"})]})]})}function Jt(i){let t=i.value;t!==void 0&&t.isColor!==void 0&&(t=Qi(i.value));const[n,e]=x.useState(t),s=x.useRef(null),a=c=>{let m=c.target.value;i.type==="boolean"?m=c.target.checked:i.type==="option"&&(m=i.options[m].value),e(m),i.onChange!==void 0&&i.onChange(i.prop!==void 0?i.prop:i.title,m)},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 u.jsxs("div",{className:`field ${h?"block":""}`,style:o,children:[i.type!=="button"&&u.jsx("label",{ref:s,children:Nt(i.title)},"fieldLabel"),i.type==="string"&&!r&&u.jsx("input",{type:"text",disabled:i.disabled,onChange:a,value:n}),i.type==="string"&&r&&u.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"&&u.jsx("input",{type:"checkbox",disabled:i.disabled,onChange:a,checked:n}),i.type==="number"&&u.jsx(pt,{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"&&u.jsx(pt,{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"&&u.jsxs(u.Fragment,{children:[u.jsx("input",{type:"text",value:n.toString(),onChange:a,disabled:i.disabled,className:"color"}),u.jsx("input",{type:"color",value:n,onChange:a,disabled:i.disabled})]}),i.type==="button"&&u.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"&&u.jsx(Jn,{title:i.title,prop:i.prop,value:i.value,onChange:i.onChange}),i.type==="option"&&u.jsx(u.Fragment,{children:u.jsx("select",{onChange:a,disabled:i.disabled,defaultValue:i.value,children:i.options?.map((c,m)=>u.jsx("option",{value:c.value,children:Nt(c.title)},m))})}),i.type==="vector2"&&u.jsx(kn,{step:i.step,value:n,min:0,max:1,onChange:a}),i.type==="grid3"&&u.jsx(Ai,{step:i.step,value:n,onChange:a}),i.type==="grid4"&&u.jsx(Un,{step:i.step,value:n,onChange:a}),i.type==="euler"&&u.jsx(Ai,{step:i.step,value:n,onChange:a})]})}function Li(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 es(i,t){const n=[];if(i.perspectiveCameraInfo!==void 0)for(const e in i.perspectiveCameraInfo)n.push({title:Li(e),prop:e,type:"number",step:.01,value:i.perspectiveCameraInfo[e],onChange:(s,a)=>{t.updateObject(i.uuid,s,a),t.requestMethod(i.uuid,"updateProjectionMatrix");const o=t.getScene(i.uuid);if(o!==null){const r=o.getObjectByProperty("uuid",i.uuid);r!==void 0&&(fe(r,s,a),r.updateProjectionMatrix())}}});else if(i.orthographicCameraInfo!==void 0)for(const e in i.orthographicCameraInfo)n.push({title:Li(e),prop:e,type:"number",step:.01,value:i.perspectiveCameraInfo[e],onChange:(s,a)=>{t.updateObject(i.uuid,s,a),t.requestMethod(i.uuid,"updateProjectionMatrix");const o=t.getScene(i.uuid);if(o!==null){const r=o.getObjectByProperty("uuid",i.uuid);r!==void 0&&(fe(r,s,a),r.updateProjectionMatrix())}}});return u.jsx(_t,{title:"Camera",items:n})}function ts(i,t){const n=new f.Matrix4;n.elements=i.matrix;const e=new f.Vector3,s=new f.Euler,a=new f.Vector3;i.uuid.length>0&&(e.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;t.updateObject(i.uuid,r,c);const m=t.getScene(i.uuid);if(m!==null){const p=m.getObjectByProperty("uuid",i.uuid);fe(p,r,c)}};return u.jsx(_t,{title:"Transform",items:[{title:"Position",prop:"position",type:"grid3",step:.1,value:e,onChange:o},{title:"Rotation",prop:"rotation",type:"grid3",value:s,onChange:o},{title:"Scale",prop:"scale",type:"grid3",value:a,onChange:o}]})}function ki(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 is(i,t){const n=[];if(i.lightInfo!==void 0)for(const e in i.lightInfo){const s=i.lightInfo[e];s!==void 0&&(s.isColor!==void 0?n.push({title:ki(e),prop:e,type:"color",value:s,onChange:(a,o)=>{const r=new f.Color(o);t.updateObject(i.uuid,a,r);const h=t.getScene(i.uuid);if(h!==null){const c=h.getObjectByProperty("uuid",i.uuid);fe(c,a,r)}}}):n.push({title:ki(e),prop:e,type:typeof s,value:s,step:typeof s=="number"?.01:void 0,onChange:(a,o)=>{t.updateObject(i.uuid,a,o);const r=t.getScene(i.uuid);if(r!==null){const h=r.getObjectByProperty("uuid",i.uuid);fe(h,a,o)}}}))}return u.jsx(_t,{title:"Light",items:n})}function ns(i,t){const n=[],e=[];let s=0;i.animations.forEach(o=>{s=Math.max(s,o.duration),o.duration>0&&e.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:e});const a=t.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:(m,p)=>{h.timeScale=p,t.updateObject(i.uuid,"mixer.timeScale",p)}}];c.push({title:"Stop All",type:"button",onChange:()=>{h.stopAllAction(),t.requestMethod(i.uuid,"stopAllAction",void 0,"mixer")}}),n.push({title:"Mixer",items:c})}}}return u.jsx(_t,{title:"Animation",items:n})}const on={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 Re={...on};function cn(i){const[t,n]=x.useState(-1);x.useEffect(()=>{function o(h){Re={...h.value},n(Date.now())}function r(){Re={...on},n(Date.now())}return H.addEventListener(V.SET_SCENE,r),H.addEventListener(V.SET_OBJECT,o),()=>{H.removeEventListener(V.SET_SCENE,r),H.removeEventListener(V.SET_OBJECT,o)}},[]);const e=Re.type.toLowerCase(),s=Re.animations.length>0||Re.mixer!==void 0,a=e.search("mesh")>-1||e.search("line")>-1||e.search("points")>-1;return u.jsx(Bt,{label:"Inspector",children:u.jsx("div",{id:"Inspector",className:i.class,children:Re.uuid.length>0&&u.jsxs(u.Fragment,{children:[u.jsxs(u.Fragment,{children:[u.jsx(Jt,{type:"string",title:"Name",prop:"name",value:Re.name,disabled:!0}),u.jsx(Jt,{type:"string",title:"Type",prop:"type",value:Re.type,disabled:!0}),u.jsx(Jt,{type:"string",title:"UUID",prop:"uuid",value:Re.uuid,disabled:!0})]}),u.jsxs(u.Fragment,{children:[ts(Re,i.three),s?ns(Re,i.three):null,e.search("camera")>-1?es(Re,i.three):null,e.search("light")>-1?is(Re,i.three):null,a?Qn(Re,i.three):null]})]})},t)},"Inspector")}function ss(i){const[t]=x.useState([]),[n]=x.useState([]),[e,s]=x.useState(0),a=h=>{const c=h.value;t.push(c),n.push(u.jsx(Bt,{label:`Scene: ${c.name}`,scene:c,open:!0,onRefresh:()=>{i.three.refreshScene(c.name)},children:u.jsx(Oi,{child:c,scene:c,three:i.three})},Math.random())),s(Date.now())},o=h=>{const c=h.value;for(let m=0;m<t.length;m++)if(c.uuid===t[m].uuid){t[m]=c,n[m]=u.jsx(Bt,{label:`Scene: ${c.name}`,scene:c,open:!0,onRefresh:()=>{i.three.refreshScene(c.name)},children:u.jsx(Oi,{child:c,scene:c,three:i.three})},Math.random()),s(Date.now());return}},r=h=>{const c=h.value;for(let m=0;m<t.length;m++)if(c.uuid===t[m].uuid){t.splice(m,1),n.splice(m,1),s(Date.now());return}};return x.useEffect(()=>(H.addEventListener(V.ADD_SCENE,a),H.addEventListener(V.REFRESH_SCENE,o),H.addEventListener(V.REMOVE_SCENE,r),()=>{H.removeEventListener(V.ADD_SCENE,a),H.removeEventListener(V.REFRESH_SCENE,o),H.removeEventListener(V.REMOVE_SCENE,r)}),[]),u.jsxs("div",{id:"SidePanel",children:[u.jsx("div",{children:n},e),u.jsx(cn,{three:i.three})]})}function as(i){return x.useEffect(()=>{function t(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,m=t(h)?.getObjectByProperty("uuid",h);m!==void 0&&i.three.setObject(m)},e=(r,h,c)=>{const p=t(r)?.getObjectByProperty("uuid",r);p!==void 0&&fe(p,h,c)},s=r=>{const h=r.value,{key:c,value:m,uuid:p}=h;e(p,c,m)},a=r=>{const h=r.value,m=t(h.uuid)?.getObjectByProperty("uuid",h.uuid);if(m!==void 0){const p=v=>{const y=h.key.split(".");switch(y.length){case 1:m[y[0]]=v;break;case 2:m[y[0]][y[1]]=v;break;case 3:m[y[0]][y[1]][y[2]]=v;break;case 4:m[y[0]][y[1]][y[2]][y[3]]=v;break;case 5:m[y[0]][y[1]][y[2]][y[3]][y[4]]=v;break}m.material.needsUpdate=!0};h.value.src.length>0?en(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]),p(v)}):p(null)}},o=r=>{const{key:h,uuid:c,value:m,subitem:p}=r.value,y=t(c)?.getObjectByProperty("uuid",c);if(y!==void 0)try{p!==void 0?xn(y,p)[h](m):y[h](m)}catch(D){console.log("Error requesting method:"),console.log(D),console.log(h),console.log(m)}};return H.addEventListener(V.GET_OBJECT,n),H.addEventListener(V.UPDATE_OBJECT,s),H.addEventListener(V.CREATE_TEXTURE,a),H.addEventListener(V.REQUEST_METHOD,o),()=>{H.removeEventListener(V.GET_OBJECT,n),H.removeEventListener(V.UPDATE_OBJECT,s),H.removeEventListener(V.CREATE_TEXTURE,a),H.removeEventListener(V.REQUEST_METHOD,o)}},[]),null}class rs extends f.Line{constructor(t,n){const e=[1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],s=new f.BufferGeometry;s.setAttribute("position",new f.Float32BufferAttribute(e,3)),s.computeBoundingSphere();const a=new f.LineBasicMaterial({fog:!1});super(s,a),this.light=t,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 f.BufferGeometry;r.setAttribute("position",new f.Float32BufferAttribute(o,3)),r.computeBoundingSphere(),this.add(new f.Mesh(r,new f.MeshBasicMaterial({side:f.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 t=this.material.color,n=Math.max(t.r,t.g,t.b);n>1&&t.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 Ui={type:"change"},li={type:"start"},Fi={type:"end"},$t=new f.Ray,ji=new f.Plane,os=Math.cos(70*f.MathUtils.DEG2RAD);class cs extends f.EventDispatcher{constructor(t,n){super(),this.object=t,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new f.Vector3,this.cursor=new f.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:f.MOUSE.ROTATE,MIDDLE:f.MOUSE.DOLLY,RIGHT:f.MOUSE.PAN},this.touches={ONE:f.TOUCH.ROTATE,TWO:f.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return 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",Me),this._domElementKeyEvents=d},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Me),this._domElementKeyEvents=null},this.saveState=function(){e.target0.copy(e.target),e.position0.copy(e.object.position),e.zoom0=e.object.zoom},this.reset=function(){e.target.copy(e.target0),e.object.position.copy(e.position0),e.object.zoom=e.zoom0,e.object.updateProjectionMatrix(),e.dispatchEvent(Ui),e.update(),a=s.NONE},this.update=function(){const d=new f.Vector3,R=new f.Quaternion().setFromUnitVectors(t.up,new f.Vector3(0,1,0)),G=R.clone().invert(),X=new f.Vector3,be=new f.Quaternion,ke=new f.Vector3,xe=2*Math.PI;return function(Yt=null){const Zt=e.object.position;d.copy(Zt).sub(e.target),d.applyQuaternion(R),r.setFromVector3(d),e.autoRotate&&a===s.NONE&&Pe(We(Yt)),e.enableDamping?(r.theta+=h.theta*e.dampingFactor,r.phi+=h.phi*e.dampingFactor):(r.theta+=h.theta,r.phi+=h.phi);let Ue=e.minAzimuthAngle,Fe=e.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(e.minPolarAngle,Math.min(e.maxPolarAngle,r.phi)),r.makeSafe(),e.enableDamping===!0?e.target.addScaledVector(m,e.dampingFactor):e.target.add(m),e.target.sub(e.cursor),e.target.clampLength(e.minTargetRadius,e.maxTargetRadius),e.target.add(e.cursor);let ht=!1;if(e.zoomToCursor&&I||e.object.isOrthographicCamera)r.radius=Je(r.radius);else{const Ge=r.radius;r.radius=Je(r.radius*c),ht=Ge!=r.radius}if(d.setFromSpherical(r),d.applyQuaternion(G),Zt.copy(e.target).add(d),e.object.lookAt(e.target),e.enableDamping===!0?(h.theta*=1-e.dampingFactor,h.phi*=1-e.dampingFactor,m.multiplyScalar(1-e.dampingFactor)):(h.set(0,0,0),m.set(0,0,0)),e.zoomToCursor&&I){let Ge=null;if(e.object.isPerspectiveCamera){const rt=d.length();Ge=Je(rt*c);const vt=rt-Ge;e.object.position.addScaledVector(C,vt),e.object.updateMatrixWorld(),ht=!!vt}else if(e.object.isOrthographicCamera){const rt=new f.Vector3(k.x,k.y,0);rt.unproject(e.object);const vt=e.object.zoom;e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/c)),e.object.updateProjectionMatrix(),ht=vt!==e.object.zoom;const Gt=new f.Vector3(k.x,k.y,0);Gt.unproject(e.object),e.object.position.sub(Gt).add(rt),e.object.updateMatrixWorld(),Ge=d.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),e.zoomToCursor=!1;Ge!==null&&(this.screenSpacePanning?e.target.set(0,0,-1).transformDirection(e.object.matrix).multiplyScalar(Ge).add(e.object.position):($t.origin.copy(e.object.position),$t.direction.set(0,0,-1).transformDirection(e.object.matrix),Math.abs(e.object.up.dot($t.direction))<os?t.lookAt(e.target):(ji.setFromNormalAndCoplanarPoint(e.object.up,e.target),$t.intersectPlane(ji,e.target))))}else if(e.object.isOrthographicCamera){const Ge=e.object.zoom;e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/c)),Ge!==e.object.zoom&&(e.object.updateProjectionMatrix(),ht=!0)}return c=1,I=!1,ht||X.distanceToSquared(e.object.position)>o||8*(1-be.dot(e.object.quaternion))>o||ke.distanceToSquared(e.target)>o?(e.dispatchEvent(Ui),X.copy(e.object.position),be.copy(e.object.quaternion),ke.copy(e.target),!0):!1}}(),this.dispose=function(){e.domElement.removeEventListener("contextmenu",Ze),e.domElement.removeEventListener("pointerdown",W),e.domElement.removeEventListener("pointercancel",Oe),e.domElement.removeEventListener("wheel",z),e.domElement.removeEventListener("pointermove",oe),e.domElement.removeEventListener("pointerup",Oe),e.domElement.getRootNode().removeEventListener("keydown",ve,{capture:!0}),e._domElementKeyEvents!==null&&(e._domElementKeyEvents.removeEventListener("keydown",Me),e._domElementKeyEvents=null)};const e=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 f.Spherical,h=new f.Spherical;let c=1;const m=new f.Vector3,p=new f.Vector2,v=new f.Vector2,y=new f.Vector2,D=new f.Vector2,L=new f.Vector2,U=new f.Vector2,g=new f.Vector2,E=new f.Vector2,w=new f.Vector2,C=new f.Vector3,k=new f.Vector2;let I=!1;const T=[],ie={};let q=!1;function We(d){return d!==null?2*Math.PI/60*e.autoRotateSpeed*d:2*Math.PI/60/60*e.autoRotateSpeed}function Y(d){const R=Math.abs(d*.01);return Math.pow(.95,e.zoomSpeed*R)}function Pe(d){h.theta-=d}function Ee(d){h.phi-=d}const Ce=function(){const d=new f.Vector3;return function(G,X){d.setFromMatrixColumn(X,0),d.multiplyScalar(-G),m.add(d)}}(),Te=function(){const d=new f.Vector3;return function(G,X){e.screenSpacePanning===!0?d.setFromMatrixColumn(X,1):(d.setFromMatrixColumn(X,0),d.crossVectors(e.object.up,d)),d.multiplyScalar(G),m.add(d)}}(),Ie=function(){const d=new f.Vector3;return function(G,X){const be=e.domElement;if(e.object.isPerspectiveCamera){const ke=e.object.position;d.copy(ke).sub(e.target);let xe=d.length();xe*=Math.tan(e.object.fov/2*Math.PI/180),Ce(2*G*xe/be.clientHeight,e.object.matrix),Te(2*X*xe/be.clientHeight,e.object.matrix)}else e.object.isOrthographicCamera?(Ce(G*(e.object.right-e.object.left)/e.object.zoom/be.clientWidth,e.object.matrix),Te(X*(e.object.top-e.object.bottom)/e.object.zoom/be.clientHeight,e.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),e.enablePan=!1)}}();function Ve(d){e.object.isPerspectiveCamera||e.object.isOrthographicCamera?c/=d:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function nt(d){e.object.isPerspectiveCamera||e.object.isOrthographicCamera?c*=d:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function Qe(d,R){if(!e.zoomToCursor)return;I=!0;const G=e.domElement.getBoundingClientRect(),X=d-G.left,be=R-G.top,ke=G.width,xe=G.height;k.x=X/ke*2-1,k.y=-(be/xe)*2+1,C.set(k.x,k.y,1).unproject(e.object).sub(e.object.position).normalize()}function Je(d){return Math.max(e.minDistance,Math.min(e.maxDistance,d))}function lt(d){p.set(d.clientX,d.clientY)}function st(d){Qe(d.clientX,d.clientX),g.set(d.clientX,d.clientY)}function pe(d){D.set(d.clientX,d.clientY)}function Ye(d){v.set(d.clientX,d.clientY),y.subVectors(v,p).multiplyScalar(e.rotateSpeed);const R=e.domElement;Pe(2*Math.PI*y.x/R.clientHeight),Ee(2*Math.PI*y.y/R.clientHeight),p.copy(v),e.update()}function Mt(d){E.set(d.clientX,d.clientY),w.subVectors(E,g),w.y>0?Ve(Y(w.y)):w.y<0&&nt(Y(w.y)),g.copy(E),e.update()}function dt(d){L.set(d.clientX,d.clientY),U.subVectors(L,D).multiplyScalar(e.panSpeed),Ie(U.x,U.y),D.copy(L),e.update()}function we(d){Qe(d.clientX,d.clientY),d.deltaY<0?nt(Y(d.deltaY)):d.deltaY>0&&Ve(Y(d.deltaY)),e.update()}function b(d){let R=!1;switch(d.code){case e.keys.UP:d.ctrlKey||d.metaKey||d.shiftKey?Ee(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):Ie(0,e.keyPanSpeed),R=!0;break;case e.keys.BOTTOM:d.ctrlKey||d.metaKey||d.shiftKey?Ee(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):Ie(0,-e.keyPanSpeed),R=!0;break;case e.keys.LEFT:d.ctrlKey||d.metaKey||d.shiftKey?Pe(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):Ie(e.keyPanSpeed,0),R=!0;break;case e.keys.RIGHT:d.ctrlKey||d.metaKey||d.shiftKey?Pe(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):Ie(-e.keyPanSpeed,0),R=!0;break}R&&(d.preventDefault(),e.update())}function S(d){if(T.length===1)p.set(d.pageX,d.pageY);else{const R=at(d),G=.5*(d.pageX+R.x),X=.5*(d.pageY+R.y);p.set(G,X)}}function P(d){if(T.length===1)D.set(d.pageX,d.pageY);else{const R=at(d),G=.5*(d.pageX+R.x),X=.5*(d.pageY+R.y);D.set(G,X)}}function F(d){const R=at(d),G=d.pageX-R.x,X=d.pageY-R.y,be=Math.sqrt(G*G+X*X);g.set(0,be)}function de(d){e.enableZoom&&F(d),e.enablePan&&P(d)}function _e(d){e.enableZoom&&F(d),e.enableRotate&&S(d)}function A(d){if(T.length==1)v.set(d.pageX,d.pageY);else{const G=at(d),X=.5*(d.pageX+G.x),be=.5*(d.pageY+G.y);v.set(X,be)}y.subVectors(v,p).multiplyScalar(e.rotateSpeed);const R=e.domElement;Pe(2*Math.PI*y.x/R.clientHeight),Ee(2*Math.PI*y.y/R.clientHeight),p.copy(v)}function j(d){if(T.length===1)L.set(d.pageX,d.pageY);else{const R=at(d),G=.5*(d.pageX+R.x),X=.5*(d.pageY+R.y);L.set(G,X)}U.subVectors(L,D).multiplyScalar(e.panSpeed),Ie(U.x,U.y),D.copy(L)}function ge(d){const R=at(d),G=d.pageX-R.x,X=d.pageY-R.y,be=Math.sqrt(G*G+X*X);E.set(0,be),w.set(0,Math.pow(E.y/g.y,e.zoomSpeed)),Ve(w.y),g.copy(E);const ke=(d.pageX+R.x)*.5,xe=(d.pageY+R.y)*.5;Qe(ke,xe)}function Ae(d){e.enableZoom&&ge(d),e.enablePan&&j(d)}function Ke(d){e.enableZoom&&ge(d),e.enableRotate&&A(d)}function W(d){e.enabled!==!1&&(T.length===0&&(e.domElement.setPointerCapture(d.pointerId),e.domElement.addEventListener("pointermove",oe),e.domElement.addEventListener("pointerup",Oe)),!oi(d)&&(gt(d),d.pointerType==="touch"?Le(d):re(d)))}function oe(d){e.enabled!==!1&&(d.pointerType==="touch"?et(d):he(d))}function Oe(d){switch(ri(d),T.length){case 0:e.domElement.releasePointerCapture(d.pointerId),e.domElement.removeEventListener("pointermove",oe),e.domElement.removeEventListener("pointerup",Oe),e.dispatchEvent(Fi),a=s.NONE;break;case 1:const R=T[0],G=ie[R];Le({pointerId:R,pageX:G.x,pageY:G.y});break}}function re(d){let R;switch(d.button){case 0:R=e.mouseButtons.LEFT;break;case 1:R=e.mouseButtons.MIDDLE;break;case 2:R=e.mouseButtons.RIGHT;break;default:R=-1}switch(R){case f.MOUSE.DOLLY:if(e.enableZoom===!1)return;st(d),a=s.DOLLY;break;case f.MOUSE.ROTATE:if(d.ctrlKey||d.metaKey||d.shiftKey){if(e.enablePan===!1)return;pe(d),a=s.PAN}else{if(e.enableRotate===!1)return;lt(d),a=s.ROTATE}break;case f.MOUSE.PAN:if(d.ctrlKey||d.metaKey||d.shiftKey){if(e.enableRotate===!1)return;lt(d),a=s.ROTATE}else{if(e.enablePan===!1)return;pe(d),a=s.PAN}break;default:a=s.NONE}a!==s.NONE&&e.dispatchEvent(li)}function he(d){switch(a){case s.ROTATE:if(e.enableRotate===!1)return;Ye(d);break;case s.DOLLY:if(e.enableZoom===!1)return;Mt(d);break;case s.PAN:if(e.enablePan===!1)return;dt(d);break}}function z(d){e.enabled===!1||e.enableZoom===!1||a!==s.NONE||(d.preventDefault(),e.dispatchEvent(li),we(ne(d)),e.dispatchEvent(Fi))}function ne(d){const R=d.deltaMode,G={clientX:d.clientX,clientY:d.clientY,deltaY:d.deltaY};switch(R){case 1:G.deltaY*=16;break;case 2:G.deltaY*=100;break}return d.ctrlKey&&!q&&(G.deltaY*=10),G}function ve(d){d.key==="Control"&&(q=!0,e.domElement.getRootNode().addEventListener("keyup",ue,{passive:!0,capture:!0}))}function ue(d){d.key==="Control"&&(q=!1,e.domElement.getRootNode().removeEventListener("keyup",ue,{passive:!0,capture:!0}))}function Me(d){e.enabled===!1||e.enablePan===!1||b(d)}function Le(d){switch(Vt(d),T.length){case 1:switch(e.touches.ONE){case f.TOUCH.ROTATE:if(e.enableRotate===!1)return;S(d),a=s.TOUCH_ROTATE;break;case f.TOUCH.PAN:if(e.enablePan===!1)return;P(d),a=s.TOUCH_PAN;break;default:a=s.NONE}break;case 2:switch(e.touches.TWO){case f.TOUCH.DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;de(d),a=s.TOUCH_DOLLY_PAN;break;case f.TOUCH.DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;_e(d),a=s.TOUCH_DOLLY_ROTATE;break;default:a=s.NONE}break;default:a=s.NONE}a!==s.NONE&&e.dispatchEvent(li)}function et(d){switch(Vt(d),a){case s.TOUCH_ROTATE:if(e.enableRotate===!1)return;A(d),e.update();break;case s.TOUCH_PAN:if(e.enablePan===!1)return;j(d),e.update();break;case s.TOUCH_DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;Ae(d),e.update();break;case s.TOUCH_DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;Ke(d),e.update();break;default:a=s.NONE}}function Ze(d){e.enabled!==!1&&d.preventDefault()}function gt(d){T.push(d.pointerId)}function ri(d){delete ie[d.pointerId];for(let R=0;R<T.length;R++)if(T[R]==d.pointerId){T.splice(R,1);return}}function oi(d){for(let R=0;R<T.length;R++)if(T[R]==d.pointerId)return!0;return!1}function Vt(d){let R=ie[d.pointerId];R===void 0&&(R=new f.Vector2,ie[d.pointerId]=R),R.set(d.pageX,d.pageY)}function at(d){const R=d.pointerId===T[0]?T[1]:T[0];return ie[R]}e.domElement.addEventListener("contextmenu",Ze),e.domElement.addEventListener("pointerdown",W),e.domElement.addEventListener("pointercancel",Oe),e.domElement.addEventListener("wheel",z,{passive:!1}),e.domElement.getRootNode().addEventListener("keydown",ve,{passive:!0,capture:!0}),this.update()}}function bt(i,t,n,e,s){return e+(i-t)*(s-e)/(n-t)}/*!
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
31
  * camera-controls
32
32
  * https://github.com/yomotsu/camera-controls
33
33
  * (c) 2017 @yomotsu
34
34
  * Released under the MIT License.
35
- */const ce={LEFT:1,RIGHT:2,MIDDLE:4},_=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 ut(i){return i.isPerspectiveCamera}function ot(i){return i.isOrthographicCamera}const Ct=Math.PI*2,Ni=Math.PI/2,ln=1e-5,Pt=Math.PI/180;function $e(i,t,n){return Math.max(t,Math.min(n,i))}function ae(i,t=ln){return Math.abs(i)<t}function te(i,t,n=ln){return ae(i-t,n)}function zi(i,t){return Math.round(i/t)*t}function It(i){return isFinite(i)?i:i<0?-Number.MAX_VALUE:Number.MAX_VALUE}function Lt(i){return Math.abs(i)<Number.MAX_VALUE?i:i*(1/0)}function Wt(i,t,n,e,s=1/0,a){e=Math.max(1e-4,e);const o=2/e,r=o*a,h=1/(1+r+.48*r*r+.235*r*r*r);let c=i-t;const m=t,p=s*e;c=$e(c,-p,p),t=i-c;const v=(n.value+o*c)*a;n.value=(n.value-o*v)*h;let y=t+(c+v)*h;return m-i>0==y>m&&(y=m,n.value=(y-m)/a),y}function Bi(i,t,n,e,s=1/0,a,o){e=Math.max(1e-4,e);const r=2/e,h=r*a,c=1/(1+h+.48*h*h+.235*h*h*h);let m=t.x,p=t.y,v=t.z,y=i.x-m,D=i.y-p,L=i.z-v;const U=m,g=p,E=v,w=s*e,C=w*w,k=y*y+D*D+L*L;if(k>C){const Te=Math.sqrt(k);y=y/Te*w,D=D/Te*w,L=L/Te*w}m=i.x-y,p=i.y-D,v=i.z-L;const I=(n.x+r*y)*a,T=(n.y+r*D)*a,ie=(n.z+r*L)*a;n.x=(n.x-r*I)*c,n.y=(n.y-r*T)*c,n.z=(n.z-r*ie)*c,o.x=m+(y+I)*c,o.y=p+(D+T)*c,o.z=v+(L+ie)*c;const q=U-i.x,We=g-i.y,Y=E-i.z,Pe=o.x-U,Ee=o.y-g,Ce=o.z-E;return q*Pe+We*Ee+Y*Ce>0&&(o.x=U,o.y=g,o.z=E,n.x=(o.x-U)/a,n.y=(o.y-g)/a,n.z=(o.z-E)/a),o}function di(i,t){t.set(0,0),i.forEach(n=>{t.x+=n.clientX,t.y+=n.clientY}),t.x/=i.length,t.y/=i.length}function hi(i,t){return ot(i)?(console.warn(`${t} is not supported in OrthographicCamera`),!0):!1}class ls{constructor(){this._listeners={}}addEventListener(t,n){const e=this._listeners;e[t]===void 0&&(e[t]=[]),e[t].indexOf(n)===-1&&e[t].push(n)}hasEventListener(t,n){const e=this._listeners;return e[t]!==void 0&&e[t].indexOf(n)!==-1}removeEventListener(t,n){const s=this._listeners[t];if(s!==void 0){const a=s.indexOf(n);a!==-1&&s.splice(a,1)}}removeAllEventListeners(t){if(!t){this._listeners={};return}Array.isArray(this._listeners[t])&&(this._listeners[t].length=0)}dispatchEvent(t){const e=this._listeners[t.type];if(e!==void 0){t.target=this;const s=e.slice(0);for(let a=0,o=s.length;a<o;a++)s[a].call(this,t)}}}var ui;const ds="2.9.0",Kt=1/8,hs=/Mac/.test((ui=globalThis?.navigator)===null||ui===void 0?void 0:ui.platform);let N,Hi,Xt,mi,De,Z,Q,Tt,kt,Xe,qe,mt,Vi,Yi,Ne,Ut,xt,Zi,fi,Gi,pi,_i,qt;class it extends ls{static install(t){N=t.THREE,Hi=Object.freeze(new N.Vector3(0,0,0)),Xt=Object.freeze(new N.Vector3(0,1,0)),mi=Object.freeze(new N.Vector3(0,0,1)),De=new N.Vector2,Z=new N.Vector3,Q=new N.Vector3,Tt=new N.Vector3,kt=new N.Vector3,Xe=new N.Vector3,qe=new N.Vector3,mt=new N.Vector3,Vi=new N.Vector3,Yi=new N.Vector3,Ne=new N.Spherical,Ut=new N.Spherical,xt=new N.Box3,Zi=new N.Box3,fi=new N.Sphere,Gi=new N.Quaternion,pi=new N.Quaternion,_i=new N.Matrix4,qt=new N.Raycaster}static get ACTION(){return _}constructor(t,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=_.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 N.Vector3,this._focalOffsetVelocity=new N.Vector3,this._zoomVelocity={value:0},this._truckInternal=(g,E,w)=>{let C,k;if(ut(this._camera)){const I=Z.copy(this._camera.position).sub(this._target),T=this._camera.getEffectiveFOV()*Pt,ie=I.length()*Math.tan(T*.5);C=this.truckSpeed*g*ie/this._elementRect.height,k=this.truckSpeed*E*ie/this._elementRect.height}else if(ot(this._camera)){const I=this._camera;C=g*(I.right-I.left)/I.zoom/this._elementRect.width,k=E*(I.top-I.bottom)/I.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=(g,E)=>{const w=Ct*this.azimuthRotateSpeed*g/this._elementRect.height,C=Ct*this.polarRotateSpeed*E/this._elementRect.height;this.rotate(w,C,!0)},this._dollyInternal=(g,E,w)=>{const C=Math.pow(.95,-g*this.dollySpeed),k=this._sphericalEnd.radius,I=this._sphericalEnd.radius*C,T=$e(I,this.minDistance,this.maxDistance),ie=T-I;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(I,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(ie,!0),this._dollyToNoClamp(T,!0)):this._dollyToNoClamp(T,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?I:T)-k,this._dollyControlCoord.set(E,w)),this._lastDollyDirection=Math.sign(-g)},this._zoomInternal=(g,E,w)=>{const C=Math.pow(.95,g*this.dollySpeed),k=this._zoom,I=this._zoom*C;this.zoomTo(I,!0),this.dollyToCursor&&(this._changedZoom+=I-k,this._dollyControlCoord.set(E,w))},typeof N>"u"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=t,this._yAxisUpSpace=new N.Quaternion().setFromUnitVectors(this._camera.up,Xt),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=_.NONE,this._target=new N.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new N.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new N.Spherical().setFromVector3(Z.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 N.Vector3,new N.Vector3,new N.Vector3,new N.Vector3],this._updateNearPlaneCorners(),this._boundary=new N.Box3(new N.Vector3(-1/0,-1/0,-1/0),new N.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 N.Vector2,this.mouseButtons={left:_.ROTATE,middle:_.DOLLY,right:_.TRUCK,wheel:ut(this._camera)?_.DOLLY:ot(this._camera)?_.ZOOM:_.NONE},this.touches={one:_.TOUCH_ROTATE,two:ut(this._camera)?_.TOUCH_DOLLY_TRUCK:ot(this._camera)?_.TOUCH_ZOOM_TRUCK:_.NONE,three:_.TOUCH_TRUCK};const e=new N.Vector2,s=new N.Vector2,a=new N.Vector2,o=g=>{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=g.clientX/C.width,I=g.clientY/C.height;if(k<this._interactiveArea.left||k>this._interactiveArea.right||I<this._interactiveArea.top||I>this._interactiveArea.bottom)return}const E=g.pointerType!=="mouse"?null:(g.buttons&ce.LEFT)===ce.LEFT?ce.LEFT:(g.buttons&ce.MIDDLE)===ce.MIDDLE?ce.MIDDLE:(g.buttons&ce.RIGHT)===ce.RIGHT?ce.RIGHT:null;if(E!==null){const C=this._findPointerByMouseButton(E);C&&this._disposePointer(C)}if((g.buttons&ce.LEFT)===ce.LEFT&&this._lockedPointer)return;const w={pointerId:g.pointerId,clientX:g.clientX,clientY:g.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(g)},r=g=>{g.cancelable&&g.preventDefault();const E=g.pointerId,w=this._lockedPointer||this._findPointerById(E);if(w){if(w.clientX=g.clientX,w.clientY=g.clientY,w.deltaX=g.movementX,w.deltaY=g.movementY,this._state=0,g.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&&(g.buttons&ce.LEFT)===ce.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(g.buttons&ce.MIDDLE)===ce.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(g.buttons&ce.RIGHT)===ce.RIGHT&&(this._state=this._state|this.mouseButtons.right);y()}},h=g=>{const E=this._findPointerById(g.pointerId);if(!(E&&E===this._lockedPointer)){if(E&&this._disposePointer(E),g.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=_.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=_.NONE;D()}};let c=-1;const m=g=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===_.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const I=this._domElement.getBoundingClientRect(),T=g.clientX/I.width,ie=g.clientY/I.height;if(T<this._interactiveArea.left||T>this._interactiveArea.right||ie<this._interactiveArea.top||ie>this._interactiveArea.bottom)return}if(g.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===_.ROTATE||this.mouseButtons.wheel===_.TRUCK){const I=performance.now();c-I<1e3&&this._getClientRect(this._elementRect),c=I}const E=hs?-1:-3,w=g.deltaMode===1?g.deltaY/E:g.deltaY/(E*10),C=this.dollyToCursor?(g.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,k=this.dollyToCursor?(g.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case _.ROTATE:{this._rotateInternal(g.deltaX,g.deltaY),this._isUserControllingRotate=!0;break}case _.TRUCK:{this._truckInternal(g.deltaX,g.deltaY,!1),this._isUserControllingTruck=!0;break}case _.OFFSET:{this._truckInternal(g.deltaX,g.deltaY,!0),this._isUserControllingOffset=!0;break}case _.DOLLY:{this._dollyInternal(-w,C,k),this._isUserControllingDolly=!0;break}case _.ZOOM:{this._zoomInternal(-w,C,k),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},p=g=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===it.ACTION.NONE){const E=g instanceof PointerEvent?g.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}g.preventDefault()}},v=g=>{if(!this._enabled)return;if(di(this._activePointers,De),this._getClientRect(this._elementRect),e.copy(De),s.copy(De),this._activePointers.length>=2){const w=De.x-this._activePointers[1].clientX,C=De.y-this._activePointers[1].clientY,k=Math.sqrt(w*w+C*C);a.set(0,k);const I=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,T=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;s.set(I,T)}if(this._state=0,!g)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in g&&g.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&&(g.buttons&ce.LEFT)===ce.LEFT&&(this._state=this._state|this.mouseButtons.left),(g.buttons&ce.MIDDLE)===ce.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(g.buttons&ce.RIGHT)===ce.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&_.ROTATE)===_.ROTATE||(this._state&_.TOUCH_ROTATE)===_.TOUCH_ROTATE||(this._state&_.TOUCH_DOLLY_ROTATE)===_.TOUCH_DOLLY_ROTATE||(this._state&_.TOUCH_ZOOM_ROTATE)===_.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&_.TRUCK)===_.TRUCK||(this._state&_.TOUCH_TRUCK)===_.TOUCH_TRUCK||(this._state&_.TOUCH_DOLLY_TRUCK)===_.TOUCH_DOLLY_TRUCK||(this._state&_.TOUCH_ZOOM_TRUCK)===_.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&_.DOLLY)===_.DOLLY||(this._state&_.TOUCH_DOLLY)===_.TOUCH_DOLLY||(this._state&_.TOUCH_DOLLY_TRUCK)===_.TOUCH_DOLLY_TRUCK||(this._state&_.TOUCH_DOLLY_OFFSET)===_.TOUCH_DOLLY_OFFSET||(this._state&_.TOUCH_DOLLY_ROTATE)===_.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&_.ZOOM)===_.ZOOM||(this._state&_.TOUCH_ZOOM)===_.TOUCH_ZOOM||(this._state&_.TOUCH_ZOOM_TRUCK)===_.TOUCH_ZOOM_TRUCK||(this._state&_.TOUCH_ZOOM_OFFSET)===_.TOUCH_ZOOM_OFFSET||(this._state&_.TOUCH_ZOOM_ROTATE)===_.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&_.OFFSET)===_.OFFSET||(this._state&_.TOUCH_OFFSET)===_.TOUCH_OFFSET||(this._state&_.TOUCH_DOLLY_OFFSET)===_.TOUCH_DOLLY_OFFSET||(this._state&_.TOUCH_ZOOM_OFFSET)===_.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,De);const E=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,w=E?-E.deltaX:s.x-De.x,C=E?-E.deltaY:s.y-De.y;if(s.copy(De),((this._state&_.ROTATE)===_.ROTATE||(this._state&_.TOUCH_ROTATE)===_.TOUCH_ROTATE||(this._state&_.TOUCH_DOLLY_ROTATE)===_.TOUCH_DOLLY_ROTATE||(this._state&_.TOUCH_ZOOM_ROTATE)===_.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(w,C),this._isUserControllingRotate=!0),(this._state&_.DOLLY)===_.DOLLY||(this._state&_.ZOOM)===_.ZOOM){const k=this.dollyToCursor?(e.x-this._elementRect.x)/this._elementRect.width*2-1:0,I=this.dollyToCursor?(e.y-this._elementRect.y)/this._elementRect.height*-2+1:0,T=this.dollyDragInverted?-1:1;(this._state&_.DOLLY)===_.DOLLY?(this._dollyInternal(T*C*Kt,k,I),this._isUserControllingDolly=!0):(this._zoomInternal(T*C*Kt,k,I),this._isUserControllingZoom=!0)}if((this._state&_.TOUCH_DOLLY)===_.TOUCH_DOLLY||(this._state&_.TOUCH_ZOOM)===_.TOUCH_ZOOM||(this._state&_.TOUCH_DOLLY_TRUCK)===_.TOUCH_DOLLY_TRUCK||(this._state&_.TOUCH_ZOOM_TRUCK)===_.TOUCH_ZOOM_TRUCK||(this._state&_.TOUCH_DOLLY_OFFSET)===_.TOUCH_DOLLY_OFFSET||(this._state&_.TOUCH_ZOOM_OFFSET)===_.TOUCH_ZOOM_OFFSET||(this._state&_.TOUCH_DOLLY_ROTATE)===_.TOUCH_DOLLY_ROTATE||(this._state&_.TOUCH_ZOOM_ROTATE)===_.TOUCH_ZOOM_ROTATE){const k=De.x-this._activePointers[1].clientX,I=De.y-this._activePointers[1].clientY,T=Math.sqrt(k*k+I*I),ie=a.y-T;a.set(0,T);const q=this.dollyToCursor?(s.x-this._elementRect.x)/this._elementRect.width*2-1:0,We=this.dollyToCursor?(s.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&_.TOUCH_DOLLY)===_.TOUCH_DOLLY||(this._state&_.TOUCH_DOLLY_ROTATE)===_.TOUCH_DOLLY_ROTATE||(this._state&_.TOUCH_DOLLY_TRUCK)===_.TOUCH_DOLLY_TRUCK||(this._state&_.TOUCH_DOLLY_OFFSET)===_.TOUCH_DOLLY_OFFSET?(this._dollyInternal(ie*Kt,q,We),this._isUserControllingDolly=!0):(this._zoomInternal(ie*Kt,q,We),this._isUserControllingZoom=!0)}((this._state&_.TRUCK)===_.TRUCK||(this._state&_.TOUCH_TRUCK)===_.TOUCH_TRUCK||(this._state&_.TOUCH_DOLLY_TRUCK)===_.TOUCH_DOLLY_TRUCK||(this._state&_.TOUCH_ZOOM_TRUCK)===_.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(w,C,!1),this._isUserControllingTruck=!0),((this._state&_.OFFSET)===_.OFFSET||(this._state&_.TOUCH_OFFSET)===_.TOUCH_OFFSET||(this._state&_.TOUCH_DOLLY_OFFSET)===_.TOUCH_DOLLY_OFFSET||(this._state&_.TOUCH_ZOOM_OFFSET)===_.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(w,C,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},D=()=>{di(this._activePointers,De),s.copy(De),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",L),this._domElement.ownerDocument.addEventListener("pointerlockerror",U),this._domElement.ownerDocument.addEventListener("pointermove",r,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",h),v())},this.unlockPointer=()=>{var g,E,w;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(g=this._domElement)===null||g===void 0||g.ownerDocument.exitPointerLock(),(E=this._domElement)===null||E===void 0||E.ownerDocument.removeEventListener("pointerlockchange",L),(w=this._domElement)===null||w===void 0||w.ownerDocument.removeEventListener("pointerlockerror",U),this.cancel()};const L=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},U=()=>{this.unlockPointer()};this._addAllEventListeners=g=>{this._domElement=g,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",m,{passive:!1}),this._domElement.addEventListener("contextmenu",p)},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",m,{passive:!1}),this._domElement.removeEventListener("contextmenu",p),this._domElement.ownerDocument.removeEventListener("pointermove",r,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.removeEventListener("pointerlockchange",L),this._domElement.ownerDocument.removeEventListener("pointerlockerror",U))},this.cancel=()=>{this._state!==_.NONE&&(this._state=_.NONE,this._activePointers.length=0,D())},n&&this.connect(n),this.update(0)}get camera(){return this._camera}set camera(t){this._camera=t,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(t){this._enabled=t,this._domElement&&(t?(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(t){this._spherical.radius===t&&this._sphericalEnd.radius===t||(this._spherical.radius=t,this._sphericalEnd.radius=t,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(t){this._spherical.theta===t&&this._sphericalEnd.theta===t||(this._spherical.theta=t,this._sphericalEnd.theta=t,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(t){this._spherical.phi===t&&this._sphericalEnd.phi===t||(this._spherical.phi=t,this._sphericalEnd.phi=t,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(t){this._boundaryEnclosesCamera=t,this._needsUpdate=!0}set interactiveArea(t){this._interactiveArea.width=$e(t.width,0,1),this._interactiveArea.height=$e(t.height,0,1),this._interactiveArea.x=$e(t.x,0,1-this._interactiveArea.width),this._interactiveArea.y=$e(t.y,0,1-this._interactiveArea.height)}addEventListener(t,n){super.addEventListener(t,n)}removeEventListener(t,n){super.removeEventListener(t,n)}rotate(t,n,e=!1){return this.rotateTo(this._sphericalEnd.theta+t,this._sphericalEnd.phi+n,e)}rotateAzimuthTo(t,n=!1){return this.rotateTo(t,this._sphericalEnd.phi,n)}rotatePolarTo(t,n=!1){return this.rotateTo(this._sphericalEnd.theta,t,n)}rotateTo(t,n,e=!1){this._isUserControllingRotate=!1;const s=$e(t,this.minAzimuthAngle,this.maxAzimuthAngle),a=$e(n,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=s,this._sphericalEnd.phi=a,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,e||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const o=!e||te(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&te(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(o)}dolly(t,n=!1){return this.dollyTo(this._sphericalEnd.radius-t,n)}dollyTo(t,n=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=Ot.NONE,this._changedDolly=0,this._dollyToNoClamp($e(t,this.minDistance,this.maxDistance),n)}_dollyToNoClamp(t,n=!1){const e=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const o=this._collisionTest(),r=te(o,this._spherical.radius);if(!(e>t)&&r)return Promise.resolve();this._sphericalEnd.radius=Math.min(t,o)}else this._sphericalEnd.radius=t;this._needsUpdate=!0,n||(this._spherical.radius=this._sphericalEnd.radius);const a=!n||te(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(a)}dollyInFixed(t,n=!1){this._targetEnd.add(this._getCameraDirection(kt).multiplyScalar(t)),n||this._target.copy(this._targetEnd);const e=!n||te(this._target.x,this._targetEnd.x,this.restThreshold)&&te(this._target.y,this._targetEnd.y,this.restThreshold)&&te(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(e)}zoom(t,n=!1){return this.zoomTo(this._zoomEnd+t,n)}zoomTo(t,n=!1){this._isUserControllingZoom=!1,this._zoomEnd=$e(t,this.minZoom,this.maxZoom),this._needsUpdate=!0,n||(this._zoom=this._zoomEnd);const e=!n||te(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(e)}pan(t,n,e=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(t,n,e)}truck(t,n,e=!1){this._camera.updateMatrix(),Xe.setFromMatrixColumn(this._camera.matrix,0),qe.setFromMatrixColumn(this._camera.matrix,1),Xe.multiplyScalar(t),qe.multiplyScalar(-n);const s=Z.copy(Xe).add(qe),a=Q.copy(this._targetEnd).add(s);return this.moveTo(a.x,a.y,a.z,e)}forward(t,n=!1){Z.setFromMatrixColumn(this._camera.matrix,0),Z.crossVectors(this._camera.up,Z),Z.multiplyScalar(t);const e=Q.copy(this._targetEnd).add(Z);return this.moveTo(e.x,e.y,e.z,n)}elevate(t,n=!1){return Z.copy(this._camera.up).multiplyScalar(t),this.moveTo(this._targetEnd.x+Z.x,this._targetEnd.y+Z.y,this._targetEnd.z+Z.z,n)}moveTo(t,n,e,s=!1){this._isUserControllingTruck=!1;const a=Z.set(t,n,e).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,a,this.boundaryFriction),this._needsUpdate=!0,s||this._target.copy(this._targetEnd);const o=!s||te(this._target.x,this._targetEnd.x,this.restThreshold)&&te(this._target.y,this._targetEnd.y,this.restThreshold)&&te(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(o)}lookInDirectionOf(t,n,e,s=!1){const r=Z.set(t,n,e).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(r.x,r.y,r.z,s)}fitToBox(t,n,{cover:e=!1,paddingLeft:s=0,paddingRight:a=0,paddingBottom:o=0,paddingTop:r=0}={}){const h=[],c=t.isBox3?xt.copy(t):xt.setFromObject(t);c.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const m=zi(this._sphericalEnd.theta,Ni),p=zi(this._sphericalEnd.phi,Ni);h.push(this.rotateTo(m,p,n));const v=Z.setFromSpherical(this._sphericalEnd).normalize(),y=Gi.setFromUnitVectors(v,mi),D=te(Math.abs(v.y),1);D&&y.multiply(pi.setFromAxisAngle(Xt,m)),y.multiply(this._yAxisUpSpaceInverse);const L=Zi.makeEmpty();Q.copy(c.min).applyQuaternion(y),L.expandByPoint(Q),Q.copy(c.min).setX(c.max.x).applyQuaternion(y),L.expandByPoint(Q),Q.copy(c.min).setY(c.max.y).applyQuaternion(y),L.expandByPoint(Q),Q.copy(c.max).setZ(c.min.z).applyQuaternion(y),L.expandByPoint(Q),Q.copy(c.min).setZ(c.max.z).applyQuaternion(y),L.expandByPoint(Q),Q.copy(c.max).setY(c.min.y).applyQuaternion(y),L.expandByPoint(Q),Q.copy(c.max).setX(c.min.x).applyQuaternion(y),L.expandByPoint(Q),Q.copy(c.max).applyQuaternion(y),L.expandByPoint(Q),L.min.x-=s,L.min.y-=o,L.max.x+=a,L.max.y+=r,y.setFromUnitVectors(mi,v),D&&y.premultiply(pi.invert()),y.premultiply(this._yAxisUpSpace);const U=L.getSize(Z),g=L.getCenter(Q).applyQuaternion(y);if(ut(this._camera)){const E=this.getDistanceToFitBox(U.x,U.y,U.z,e);h.push(this.moveTo(g.x,g.y,g.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=e?Math.max(w/U.x,C/U.y):Math.min(w/U.x,C/U.y);h.push(this.moveTo(g.x,g.y,g.z,n)),h.push(this.zoomTo(k,n)),h.push(this.setFocalOffset(0,0,0,n))}return Promise.all(h)}fitToSphere(t,n){const e=[],a="isObject3D"in t?it.createBoundingSphere(t,fi):fi.copy(t);if(e.push(this.moveTo(a.center.x,a.center.y,a.center.z,n)),ut(this._camera)){const o=this.getDistanceToFitSphere(a.radius);e.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);e.push(this.zoomTo(c,n))}return e.push(this.setFocalOffset(0,0,0,n)),Promise.all(e)}setLookAt(t,n,e,s,a,o,r=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ot.NONE,this._changedDolly=0;const h=Q.set(s,a,o),c=Z.set(t,n,e);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 m=!r||te(this._target.x,this._targetEnd.x,this.restThreshold)&&te(this._target.y,this._targetEnd.y,this.restThreshold)&&te(this._target.z,this._targetEnd.z,this.restThreshold)&&te(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&te(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&te(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(m)}lerpLookAt(t,n,e,s,a,o,r,h,c,m,p,v,y,D=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ot.NONE,this._changedDolly=0;const L=Z.set(s,a,o),U=Q.set(t,n,e);Ne.setFromVector3(U.sub(L).applyQuaternion(this._yAxisUpSpace));const g=Tt.set(m,p,v),E=Q.set(r,h,c);Ut.setFromVector3(E.sub(g).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(L.lerp(g,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,D||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const I=!D||te(this._target.x,this._targetEnd.x,this.restThreshold)&&te(this._target.y,this._targetEnd.y,this.restThreshold)&&te(this._target.z,this._targetEnd.z,this.restThreshold)&&te(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&te(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&te(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(I)}setPosition(t,n,e,s=!1){return this.setLookAt(t,n,e,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,s)}setTarget(t,n,e,s=!1){const a=this.getPosition(Z),o=this.setLookAt(a.x,a.y,a.z,t,n,e,s);return this._sphericalEnd.phi=$e(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),o}setFocalOffset(t,n,e,s=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(t,n,e),this._needsUpdate=!0,s||this._focalOffset.copy(this._focalOffsetEnd);const a=!s||te(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&te(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&te(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(a)}setOrbitPoint(t,n,e){this._camera.updateMatrixWorld(),Xe.setFromMatrixColumn(this._camera.matrixWorldInverse,0),qe.setFromMatrixColumn(this._camera.matrixWorldInverse,1),mt.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const s=Z.set(t,n,e),a=s.distanceTo(this._camera.position),o=s.sub(this._camera.position);Xe.multiplyScalar(o.x),qe.multiplyScalar(o.y),mt.multiplyScalar(o.z),Z.copy(Xe).add(qe).add(mt),Z.z=Z.z+a,this.dollyTo(a,!1),this.setFocalOffset(-Z.x,Z.y,-Z.z,!1),this.moveTo(t,n,e,!1)}setBoundary(t){if(!t){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(t),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(t,n,e,s){if(t===null){this._viewport=null;return}this._viewport=this._viewport||new N.Vector4,typeof t=="number"?this._viewport.set(t,n,e,s):this._viewport.copy(t)}getDistanceToFitBox(t,n,e,s=!1){if(hi(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const a=t/n,o=this._camera.getEffectiveFOV()*Pt,r=this._camera.aspect;return((s?a>r:a<r)?n:t/r)*.5/Math.tan(o*.5)+e*.5}getDistanceToFitSphere(t){if(hi(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const n=this._camera.getEffectiveFOV()*Pt,e=Math.atan(Math.tan(n*.5)*this._camera.aspect)*2,s=1<this._camera.aspect?n:e;return t/Math.sin(s*.5)}getTarget(t,n=!0){return(t&&t.isVector3?t:new N.Vector3).copy(n?this._targetEnd:this._target)}getPosition(t,n=!0){return(t&&t.isVector3?t:new N.Vector3).setFromSpherical(n?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(n?this._targetEnd:this._target)}getSpherical(t,n=!0){return(t||new N.Spherical).copy(n?this._sphericalEnd:this._spherical)}getFocalOffset(t,n=!0){return(t&&t.isVector3?t:new N.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(t=!1){if(!te(this._camera.up.x,this._cameraUp0.x)||!te(this._camera.up.y,this._cameraUp0.y)||!te(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const e=this.getPosition(Z);this.updateCameraUp(),this.setPosition(e.x,e.y,e.z)}const n=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,t),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,t),this.zoomTo(this._zoom0,t)];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 t=Z.subVectors(this._target,this._camera.position).normalize(),n=Q.crossVectors(t,this._camera.up);this._camera.up.crossVectors(n,t).normalize(),this._camera.updateMatrixWorld();const e=this.getPosition(Z);this.updateCameraUp(),this.setPosition(e.x,e.y,e.z)}update(t){const n=this._sphericalEnd.theta-this._spherical.theta,e=this._sphericalEnd.phi-this._spherical.phi,s=this._sphericalEnd.radius-this._spherical.radius,a=Vi.subVectors(this._targetEnd,this._target),o=Yi.subVectors(this._focalOffsetEnd,this._focalOffset),r=this._zoomEnd-this._zoom;if(ae(n))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const p=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=Wt(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,p,1/0,t),this._needsUpdate=!0}if(ae(e))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const p=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=Wt(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,p,1/0,t),this._needsUpdate=!0}if(ae(s))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const p=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=Wt(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,p,this.maxSpeed,t),this._needsUpdate=!0}if(ae(a.x)&&ae(a.y)&&ae(a.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const p=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Bi(this._target,this._targetEnd,this._targetVelocity,p,this.maxSpeed,t,this._target),this._needsUpdate=!0}if(ae(o.x)&&ae(o.y)&&ae(o.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const p=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Bi(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,p,this.maxSpeed,t,this._focalOffset),this._needsUpdate=!0}if(ae(r))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const p=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=Wt(this._zoom,this._zoomEnd,this._zoomVelocity,p,1/0,t)}if(this.dollyToCursor){if(ut(this._camera)&&this._changedDolly!==0){const p=this._spherical.radius-this._lastDistance,v=this._camera,y=this._getCameraDirection(kt),D=Z.copy(y).cross(v.up).normalize();D.lengthSq()===0&&(D.x=1);const L=Q.crossVectors(D,y),U=this._sphericalEnd.radius*Math.tan(v.getEffectiveFOV()*Pt*.5),E=(this._sphericalEnd.radius-p-this._sphericalEnd.radius)/this._sphericalEnd.radius,w=Tt.copy(this._targetEnd).add(D.multiplyScalar(this._dollyControlCoord.x*U*v.aspect)).add(L.multiplyScalar(this._dollyControlCoord.y*U)),C=Z.copy(this._targetEnd).lerp(w,E),k=this._lastDollyDirection===Ot.IN&&this._spherical.radius<=this.minDistance,I=this._lastDollyDirection===Ot.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(k||I)){this._sphericalEnd.radius-=p,this._spherical.radius-=p;const ie=Q.copy(y).multiplyScalar(-p);C.add(ie)}this._boundary.clampPoint(C,C);const T=Q.subVectors(C,this._targetEnd);this._targetEnd.copy(C),this._target.add(T),this._changedDolly-=p,ae(this._changedDolly)&&(this._changedDolly=0)}else if(ot(this._camera)&&this._changedZoom!==0){const p=this._zoom-this._lastZoom,v=this._camera,y=Z.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(v.near+v.far)/(v.near-v.far)).unproject(v),D=Q.set(0,0,-1).applyQuaternion(v.quaternion),L=Tt.copy(y).add(D.multiplyScalar(-y.dot(v.up))),g=-(this._zoom-p-this._zoom)/this._zoom,E=this._getCameraDirection(kt),w=this._targetEnd.dot(E),C=Z.copy(this._targetEnd).lerp(L,g),k=C.dot(E),I=E.multiplyScalar(k-w);C.sub(I),this._boundary.clampPoint(C,C);const T=Q.subVectors(C,this._targetEnd);this._targetEnd.copy(C),this._target.add(T),this._changedZoom-=p,ae(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),(!ae(this._focalOffset.x)||!ae(this._focalOffset.y)||!ae(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),Xe.setFromMatrixColumn(this._camera.matrix,0),qe.setFromMatrixColumn(this._camera.matrix,1),mt.setFromMatrixColumn(this._camera.matrix,2),Xe.multiplyScalar(this._focalOffset.x),qe.multiplyScalar(-this._focalOffset.y),mt.multiplyScalar(this._focalOffset.z),Z.copy(Xe).add(qe).add(mt),this._camera.position.add(Z)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),Z.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const m=this._needsUpdate;return m&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):m?(this.dispatchEvent({type:"update"}),ae(n,this.restThreshold)&&ae(e,this.restThreshold)&&ae(s,this.restThreshold)&&ae(a.x,this.restThreshold)&&ae(a.y,this.restThreshold)&&ae(a.z,this.restThreshold)&&ae(o.x,this.restThreshold)&&ae(o.y,this.restThreshold)&&ae(o.z,this.restThreshold)&&ae(r,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!m&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=m,this._needsUpdate=!1,m}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:It(this.maxDistance),minZoom:this.minZoom,maxZoom:It(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:It(this.maxPolarAngle),minAzimuthAngle:It(this.minAzimuthAngle),maxAzimuthAngle:It(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:Z.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(t,n=!1){const e=JSON.parse(t);this.enabled=e.enabled,this.minDistance=e.minDistance,this.maxDistance=Lt(e.maxDistance),this.minZoom=e.minZoom,this.maxZoom=Lt(e.maxZoom),this.minPolarAngle=e.minPolarAngle,this.maxPolarAngle=Lt(e.maxPolarAngle),this.minAzimuthAngle=Lt(e.minAzimuthAngle),this.maxAzimuthAngle=Lt(e.maxAzimuthAngle),this.smoothTime=e.smoothTime,this.draggingSmoothTime=e.draggingSmoothTime,this.dollySpeed=e.dollySpeed,this.truckSpeed=e.truckSpeed,this.dollyToCursor=e.dollyToCursor,this.verticalDragToForward=e.verticalDragToForward,this._target0.fromArray(e.target0),this._position0.fromArray(e.position0),this._zoom0=e.zoom0,this._focalOffset0.fromArray(e.focalOffset0),this.moveTo(e.target[0],e.target[1],e.target[2],n),Ne.setFromVector3(Z.fromArray(e.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(Ne.theta,Ne.phi,n),this.dollyTo(Ne.radius,n),this.zoomTo(e.zoom,n),this.setFocalOffset(e.focalOffset[0],e.focalOffset[1],e.focalOffset[2],n),this._needsUpdate=!0}connect(t){if(this._domElement){console.warn("camera-controls is already connected.");return}t.setAttribute("data-camera-controls-version",ds),this._addAllEventListeners(t),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(t){return t.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(t){return this._getTargetDirection(t).negate()}_findPointerById(t){return this._activePointers.find(n=>n.pointerId===t)}_findPointerByMouseButton(t){return this._activePointers.find(n=>n.mouseButton===t)}_disposePointer(t){this._activePointers.splice(this._activePointers.indexOf(t),1)}_encloseToBoundary(t,n,e){const s=n.lengthSq();if(s===0)return t;const a=Q.copy(n).add(t),r=this._boundary.clampPoint(a,Tt).sub(a),h=r.lengthSq();if(h===0)return t.add(n);if(h===s)return t;if(e===0)return t.add(n).add(r);{const c=1+e*h/n.dot(r);return t.add(Q.copy(n).multiplyScalar(c)).add(r.multiplyScalar(1-e))}}_updateNearPlaneCorners(){if(ut(this._camera)){const t=this._camera,n=t.near,e=t.getEffectiveFOV()*Pt,s=Math.tan(e*.5)*n,a=s*t.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 t=this._camera,n=1/t.zoom,e=t.left*n,s=t.right*n,a=t.top*n,o=t.bottom*n;this._nearPlaneCorners[0].set(e,a,0),this._nearPlaneCorners[1].set(s,a,0),this._nearPlaneCorners[2].set(s,o,0),this._nearPlaneCorners[3].set(e,o,0)}}_collisionTest(){let t=1/0;if(!(this.colliderMeshes.length>=1)||hi(this._camera,"_collisionTest"))return t;const e=this._getTargetDirection(kt);_i.lookAt(Hi,e,this._camera.up);for(let s=0;s<4;s++){const a=Q.copy(this._nearPlaneCorners[s]);a.applyMatrix4(_i);const o=Tt.addVectors(this._target,a);qt.set(o,e),qt.far=this._spherical.radius+1;const r=qt.intersectObjects(this.colliderMeshes);r.length!==0&&r[0].distance<t&&(t=r[0].distance)}return t}_getClientRect(t){if(!this._domElement)return;const n=this._domElement.getBoundingClientRect();return t.x=n.left,t.y=n.top,this._viewport?(t.x+=this._viewport.x,t.y+=n.height-this._viewport.w-this._viewport.y,t.width=this._viewport.z,t.height=this._viewport.w):(t.width=n.width,t.height=n.height),t}_createOnRestPromise(t){return t?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(n=>{const e=()=>{this.removeEventListener("rest",e),n()};this.addEventListener("rest",e)}))}_addAllEventListeners(t){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(t){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(t){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(t,n=new N.Sphere){const e=n,s=e.center;xt.makeEmpty(),t.traverseVisible(o=>{o.isMesh&&xt.expandByObject(o)}),xt.getCenter(s);let a=0;return t.traverseVisible(o=>{if(!o.isMesh)return;const r=o,h=r.geometry.clone();h.applyMatrix4(r.matrixWorld);const m=h.attributes.position;for(let p=0,v=m.count;p<v;p++)Z.fromBufferAttribute(m,p),a=Math.max(a,s.distanceToSquared(Z))}),e.radius=Math.sqrt(a),e}}const ii=i=>{const[t,n]=x.useState(i.options[i.index]),e=()=>{i.onToggle(!i.open)},s=a=>{a!==t&&(i.onSelect(a),n(a)),i.onToggle(!1)};return u.jsxs("div",{className:`dropdown ${i.up===!0?"up":""}`,children:[u.jsx("div",{className:"dropdown-toggle",onClick:e,children:`${i.title}: ${t}`}),i.open&&u.jsx("ul",{className:"dropdown-menu",children:i.options.map(a=>u.jsx("li",{onClick:()=>s(a),children:a},a))})]})},ft=x.forwardRef(function(t,n){const e=["Renderer","Depth","Normals","UVs","Wireframe"],[s,a]=x.useState("Renderer"),[o,r]=x.useState(!1),[h,c]=x.useState(!1),[m,p]=x.useState(!1);return u.jsxs("div",{className:"CameraWindow",children:[u.jsx("div",{ref:n,className:"clickable",onClick:()=>{m&&p(!1)}}),u.jsxs("div",{className:"options",children:[u.jsx(ii,{title:"Camera",index:t.options.indexOf(t.camera.name),open:m,options:t.options,onSelect:t.onSelectCamera,onToggle:v=>{p(v)},up:!0}),u.jsx(ii,{title:"Mode",index:e.indexOf(s),open:h,options:e,onSelect:v=>{if(v===s)return;const y=v;t.onSelectRenderMode(y),a(y)},onToggle:v=>{o&&r(!1),c(v)},up:!0})]})]})});class us extends f.ShaderMaterial{constructor(t){super({extensions:{derivatives:!0},glslVersion:f.GLSL3,side:f.DoubleSide,transparent:!0,uniforms:{uScale:{value:t?.scale!==void 0?t?.scale:.1},uDivisions:{value:t?.divisions!==void 0?t?.divisions:10},uColor:{value:t?.color!==void 0?t?.color:new f.Color(16777215)},uDistance:{value:t?.distance!==void 0?t?.distance:1e4},uSubgridOpacity:{value:t?.subgridOpacity!==void 0?t?.subgridOpacity:.15},uGridOpacity:{value:t?.gridOpacity!==void 0?t?.gridOpacity:.25}},vertexShader:`out vec3 worldPosition;
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;
36
36
  uniform float uDistance;
37
37
 
38
38
  void main() {
@@ -108,7 +108,7 @@ C11,8.22,10.74,8,10.43,8z`})});function tn(i){return u.jsx(Ki.Reorder.Item,{valu
108
108
  fragColor.a = mix(fragColor.a, baseOpacity * uGridOpacity, nextGrid);
109
109
 
110
110
  if (fragColor.a <= 0.0) discard;
111
- }`,name:"InfiniteGrid",depthWrite:!1})}}class ms extends f.Mesh{gridMaterial;constructor(){const t=new us;super(new f.PlaneGeometry(2,2),t),this.gridMaterial=t,this.frustumCulled=!1,this.name="InfiniteGridHelper",this.position.y=.1}update(){this.gridMaterial.needsUpdate=!0}}const fs=`#include <common>
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>
112
112
  #include <batching_pars_vertex>
113
113
  #include <uv_pars_vertex>
114
114
  #include <color_pars_vertex>
@@ -138,7 +138,7 @@ void main() {
138
138
  #include <logdepthbuf_vertex>
139
139
  #include <clipping_planes_vertex>
140
140
  #include <worldpos_vertex>
141
- }`,ps=`
141
+ }`,vs=`
142
142
  #include <common>
143
143
  #include <uv_pars_fragment>
144
144
  #include <clipping_planes_pars_fragment>
@@ -146,4 +146,4 @@ void main() {
146
146
  void main() {
147
147
  #include <clipping_planes_fragment>
148
148
  gl_FragColor = vec4(vec3(vUv, 0.0), 1.0);
149
- }`;class _s extends f.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:fs,fragmentShader:ps})}}let ze,gi=!1,J=null,le=null,Be=null,He=null,St="Renderer",Qt="Renderer",$i="Renderer",Wi="Renderer";function gs(i){const t=i.three.app.appID,n=x.useMemo(()=>new Map,[]),e=x.useMemo(()=>new Map,[]),s=x.useMemo(()=>new Map,[]),a=x.useMemo(()=>new Map,[]),o=x.useMemo(()=>new f.Scene,[]),r=x.useMemo(()=>new f.Group,[]),h=x.useMemo(()=>new ms,[]),c=x.useMemo(()=>new f.AxesHelper(500),[]),m=x.useMemo(()=>new f.AxesHelper(100),[]),p=x.useMemo(()=>new f.MeshDepthMaterial,[]),v=x.useMemo(()=>new f.MeshNormalMaterial,[]),y=x.useMemo(()=>new _s,[]),D=x.useMemo(()=>new f.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0}),[]);function L(b,S){const P=new f.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"],g=x.useRef(null),E=x.useRef(null),w=x.useRef(null),C=x.useRef(null),k=x.useRef(null),I=x.useRef(null),T=localStorage,ie=T.getItem(`${t}_mode`),[q,We]=x.useState(ie!==null?ie:"Single"),[Y,Pe]=x.useState(null),[Ee,Ce]=x.useState(!1),[Te,Ie]=x.useState(!1),[Ve,nt]=x.useState("Orbit"),[Qe,Je]=x.useState(!1),[lt,st]=x.useState(Date.now());T.setItem(`${t}_mode`,q),T.setItem(`${t}_tlCam`,T.getItem(`${t}_tlCam`)!==null?T.getItem(`${t}_tlCam`):"Debug"),T.setItem(`${t}_trCam`,T.getItem(`${t}_trCam`)!==null?T.getItem(`${t}_trCam`):"Orthographic"),T.setItem(`${t}_blCam`,T.getItem(`${t}_blCam`)!==null?T.getItem(`${t}_blCam`):"Front"),T.setItem(`${t}_brCam`,T.getItem(`${t}_brCam`)!==null?T.getItem(`${t}_brCam`):"Top"),T.setItem(`${t}_tlRender`,T.getItem(`${t}_tlRender`)!==null?T.getItem(`${t}_tlRender`):"Renderer"),T.setItem(`${t}_trRender`,T.getItem(`${t}_trRender`)!==null?T.getItem(`${t}_trRender`):"Renderer"),T.setItem(`${t}_blRender`,T.getItem(`${t}_blRender`)!==null?T.getItem(`${t}_blRender`):"Renderer"),T.setItem(`${t}_brRender`,T.getItem(`${t}_brRender`)!==null?T.getItem(`${t}_brRender`):"Renderer");const pe=(b,S)=>{const P=e.get(b.name);if(P!==void 0&&P.dispose(),e.delete(b.name),b.name==="UI")return;const F=new cs(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}e.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=e.get(b.name);P!==void 0&&(P.dispose(),e.delete(b.name))},Mt=()=>{e.forEach((b,S)=>{b.dispose();const P=s.get(S);P!==void 0&&(o.remove(P),P.dispose()),s.delete(S),e.delete(S)}),e.clear(),s.clear()},dt=()=>{switch(q){case"Single":pe(J,w.current);break;case"Side by Side":case"Stacked":pe(J,w.current),pe(le,C.current);break;case"Quad":pe(J,w.current),pe(le,C.current),pe(Be,k.current),pe(He,I.current);break}};x.useEffect(()=>{const b=new f.WebGLRenderer({canvas:g.current,stencil:!1});b.autoClear=!1,b.shadowMap.enabled=!0,b.setPixelRatio(devicePixelRatio),b.setClearColor(0),i.three.renderer=b,Pe(b)},[]),x.useEffect(()=>{o.name="Debug Scene",o.uuid="",r.name="helpers",o.add(r),r.add(h),c.name="axisHelper",r.add(c),m.name="interactionHelper",r.add(m),m.visible=!1,L("Top",new f.Vector3(0,1e3,0)),L("Bottom",new f.Vector3(0,-1e3,0)),L("Left",new f.Vector3(-1e3,0,0)),L("Right",new f.Vector3(1e3,0,0)),L("Front",new f.Vector3(0,0,1e3)),L("Back",new f.Vector3(0,0,-1e3)),L("Orthographic",new f.Vector3(1e3,1e3,1e3)),L("UI",new f.Vector3);const b=new f.PerspectiveCamera(60,1,50,5e3);b.name="Debug",b.position.set(500,500,500),b.lookAt(0,0,0),n.set("Debug",b),J=n.get(T.getItem(`${t}_tlCam`)),le=n.get(T.getItem(`${t}_trCam`)),Be=n.get(T.getItem(`${t}_blCam`)),He=n.get(T.getItem(`${t}_brCam`)),J===void 0&&(J=n.get("Debug")),le===void 0&&(le=n.get("Orthographic")),Be===void 0&&(Be=n.get("Front")),He===void 0&&(He=n.get("Top"))},[]),x.useEffect(()=>{const b=()=>{a.forEach(A=>{r.remove(A),A.dispose()}),a.clear()},S=()=>{ze.traverse(A=>{if(A.type.search("Light")>-1){let j;switch(A.type){case"DirectionalLight":j=new f.DirectionalLightHelper(A,100),j.name=`${A.name}Helper`,a.set(A.name,j),r.add(j);break;case"HemisphereLight":j=new f.HemisphereLightHelper(A,250),j.name=`${A.name}Helper`,a.set(A.name,j),r.add(j);break;case"RectAreaLight":j=new rs(A),j.name=`${A.name}Helper`,a.set(A.name,j),r.add(j);break;case"PointLight":j=new f.PointLightHelper(A,100),j.name=`${A.name}Helper`,a.set(A.name,j),r.add(j);break;case"SpotLight":j=new f.SpotLightHelper(A),j.name=`${A.name}Helper`,a.set(A.name,j),r.add(j);break}}})},P=A=>{r.add(c),b(),zt(ze),o.remove(ze);const j=i.scenes.get(A.value.name);if(j!==void 0){const ge=new j;i.onSceneSet!==void 0&&i.onSceneSet(ge),ze=ge,i.three.scene=ze,o.add(ze),gi=!0,S()}},F=A=>{const j=A.value,ge=i.three.scene?.getObjectByProperty("uuid",j.uuid);if(ge!==void 0&&n.set(j.name,ge),ge instanceof f.PerspectiveCamera){const Ae=new f.CameraHelper(ge);s.set(ge.name,Ae),o.add(Ae)}st(Date.now())},de=A=>{const j=s.get(A.value.name);j!==void 0&&(o.remove(j),j.dispose()),n.delete(A.value.name),st(Date.now())},_e=A=>{const j=ze.getObjectByProperty("uuid",A.value.uuid);j&&j.add(c)};return H.addEventListener(V.SET_SCENE,P),H.addEventListener(V.ADD_CAMERA,F),H.addEventListener(V.REMOVE_CAMERA,de),H.addEventListener(V.SET_OBJECT,_e),()=>{H.removeEventListener(V.SET_SCENE,P),H.removeEventListener(V.ADD_CAMERA,F),H.removeEventListener(V.REMOVE_CAMERA,de),H.removeEventListener(V.SET_OBJECT,_e)}},[]),x.useEffect(()=>{if(Y===null)return;let b=window.innerWidth,S=window.innerHeight,P=Math.floor(b/2),F=Math.floor(S/2),de=-1;const _e=()=>{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&&gi&&i.onSceneResize(ze,b,S);let W=b,oe=S;switch(q){case"Side by Side":W=P,oe=S;break;case"Stacked":W=b,oe=F;break;case"Quad":W=P,oe=F;break}const Oe=W/oe;n.forEach(re=>{re instanceof f.OrthographicCamera?(re.left=W/-2,re.right=W/2,re.top=oe/2,re.bottom=oe/-2,re.name==="UI"&&(re.position.x=b/2,re.position.y=S/-2,re.position.z=100),re.updateProjectionMatrix()):re instanceof f.PerspectiveCamera&&(re.aspect=Oe,re.updateProjectionMatrix(),s.get(re.name)?.update())})};function A(W){switch(W){case"Depth":return p;case"Normals":return v;case"Renderer":return null;case"UVs":return y;case"Wireframe":return D}return null}const j=()=>{const W=A(St);o.overrideMaterial=W,Y.setViewport(0,0,b,S),Y.setScissor(0,0,b,S),Y.render(o,J)},ge=()=>{const W=A(St),oe=A(Qt);if(o.overrideMaterial=W,q==="Side by Side")Y.setViewport(0,0,P,S),Y.setScissor(0,0,P,S),Y.render(o,J),o.overrideMaterial=oe,Y.setViewport(P,0,P,S),Y.setScissor(P,0,P,S),Y.render(o,le);else{const Oe=S-F;Y.setViewport(0,Oe,b,F),Y.setScissor(0,Oe,b,F),Y.render(o,J),o.overrideMaterial=oe,Y.setViewport(0,0,b,F),Y.setScissor(0,0,b,F),Y.render(o,le)}},Ae=()=>{const W=A(St),oe=A(Qt),Oe=A($i),re=A(Wi);let he=0,z=0;z=S-F,he=0,o.overrideMaterial=W,Y.setViewport(he,z,P,F),Y.setScissor(he,z,P,F),Y.render(o,J),he=P,o.overrideMaterial=oe,Y.setViewport(he,z,P,F),Y.setScissor(he,z,P,F),Y.render(o,le),z=0,he=0,o.overrideMaterial=Oe,Y.setViewport(he,z,P,F),Y.setScissor(he,z,P,F),Y.render(o,Be),he=P,o.overrideMaterial=re,Y.setViewport(he,z,P,F),Y.setScissor(he,z,P,F),Y.render(o,He)},Ke=()=>{switch(e.forEach(W=>{W.update()}),s.forEach(W=>{W.update()}),a.forEach(W=>{W.update!==void 0&&W.update()}),i.onSceneUpdate!==void 0&&gi&&i.onSceneUpdate(ze),Y.clear(),q){case"Single":j();break;case"Side by Side":case"Stacked":ge();break;case"Quad":Ae();break}de=requestAnimationFrame(Ke)};return dt(),window.addEventListener("resize",_e),_e(),Ke(),()=>{window.removeEventListener("resize",_e),cancelAnimationFrame(de),de=-1}},[q,Y]),x.useEffect(()=>{if(Y!==null){const b={Vector2:f.Vector2,Vector3:f.Vector3,Vector4:f.Vector4,Quaternion:f.Quaternion,Matrix4:f.Matrix4,Spherical:f.Spherical,Box3:f.Box3,Sphere:f.Sphere,Raycaster:f.Raycaster};it.install({THREE:b});const S=new f.Raycaster,P=new f.Vector2;let F=J,de=w,_e,A,j=-1;const ge=(z,ne,ve,ue)=>{switch(q){case"Quad":z<ve?ne<ue?(F=J,S.setFromCamera(P,J)):(F=Be,S.setFromCamera(P,Be)):ne<ue?(F=le,S.setFromCamera(P,le)):(F=He,S.setFromCamera(P,He));break;case"Side by Side":z<ve?(F=J,S.setFromCamera(P,J)):(F=le,S.setFromCamera(P,le));break;case"Single":F=J,S.setFromCamera(P,J);break;case"Stacked":ne<ue?(F=J,S.setFromCamera(P,J)):(F=le,S.setFromCamera(P,le));break}F===J?de=w:F===le?de=C:F===Be?de=k:F===He&&(de=I)},Ae=z=>{const ne=new f.Vector2;Y.getSize(ne);const ve=Math.min(z.clientX,ne.x),ue=Math.min(z.clientY,ne.y);P.x=bt(ve,0,ne.x,-1,1),P.y=bt(ue,0,ne.y,1,-1);const Me=ne.x/2,Le=ne.y/2,et=()=>{ve<Me?P.x=bt(ve,0,Me,-1,1):P.x=bt(ve,Me,ne.x,-1,1)},Ze=()=>{ue<Le?P.y=bt(ue,0,Le,1,-1):P.y=bt(ue,Le,ne.y,1,-1)};switch(q){case"Quad":et(),Ze();break;case"Side by Side":et();break;case"Stacked":Ze(),Ze();break}if(ge(ve,ue,Me,Le),Ve==="Orbit")return;const gt=S.intersectObjects(ze.children);gt.length>0&&m.position.copy(gt[0].point)},Ke=z=>{if(Ve==="Orbit")return;const ne=new f.Vector2;if(Y.getSize(ne),z.clientX>=ne.x)return;Ae(z);const ve=S.intersectObjects(ze.children);ve.length>0&&(i.three.getObject(ve[0].object.uuid),m.visible=!1,nt("Orbit"),st(Date.now()))},W=z=>{if(_e===void 0)return;clearInterval(j),A&&(A.smoothTime=.1);const ne=1/60,ve=Date.now();let ue=ve;_e.getWorldPosition(z.target0),j=setInterval(()=>{if(A){const Me=Date.now(),Le=(Me-ue)/1e3,et=(Me-ve)/1e3;ue=Me,A.update(Le),z&&(z.target.lerp(z.target0,.15),z.object.position.lerp(z.position0,.15),z.object.zoom=ei(z.object.zoom,z.zoom0,.15),z.object.updateProjectionMatrix(),z.dispatchEvent({type:"change"}),z.update()),et>=.5&&(clearInterval(j),j=-1,oe(),A=void 0)}},ne*1e3)},oe=()=>{A!==void 0&&(A.disconnect(),A.dispose(),A=void 0)},Oe=z=>{if(_e!==void 0&&z.ctrlKey){if(F.name==="UI")return;const ne=e.get(F.name);z.key==="0"?(oe(),A=new it(F,de.current),_e instanceof f.Mesh||_e instanceof f.SkinnedMesh?(_e.geometry.computeBoundingBox(),A.fitToBox(_e.geometry.boundingBox,!0)):A.fitToSphere(_e,!0),W(ne)):z.key==="1"?(oe(),A=new it(F,de.current),A.rotateTo(0,Math.PI*.5,!1),W(ne)):z.key==="2"?(oe(),A=new it(F,de.current),A.rotateTo(0,0,!1),W(ne)):z.key==="3"?(oe(),A=new it(F,de.current),A.rotateTo(Math.PI/2,Math.PI/2,!1),W(ne)):z.key==="4"&&(oe(),A=new it(F,de.current),A.rotateTo(Math.PI,Math.PI/2,!1),W(ne))}},re=z=>{_e=ze.getObjectByProperty("uuid",z.value.uuid)},he=E.current;return he.addEventListener("mousemove",Ae,!1),he.addEventListener("click",Ke,!1),window.addEventListener("keydown",Oe,!1),H.addEventListener(V.SET_OBJECT,re),()=>{he.removeEventListener("mousemove",Ae),he.removeEventListener("click",Ke),window.removeEventListener("keydown",Oe),H.removeEventListener(V.SET_OBJECT,re)}}},[q,Y,Ve]);const we=[];return n.forEach((b,S)=>{we.push(S)}),u.jsxs("div",{className:"multiview",children:[u.jsx("canvas",{ref:g}),Y!==null&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:`cameras ${q==="Single"||q==="Stacked"?"single":""}`,ref:E,children:[q==="Single"&&u.jsx(u.Fragment,{children:u.jsx(ft,{camera:J,options:we,ref:w,onSelectCamera:b=>{e.get(J.name)?.dispose();const S=n.get(b);S!==void 0&&(Ye(J),J=S,T.setItem(`${t}_tlCam`,S.name),pe(S,w.current))},onSelectRenderMode:b=>{St=b,T.setItem(`${t}_tlRender`,b)}})}),(q==="Side by Side"||q==="Stacked")&&u.jsxs(u.Fragment,{children:[u.jsx(ft,{camera:J,options:we,ref:w,onSelectCamera:b=>{e.get(J.name)?.dispose();const S=n.get(b);S!==void 0&&(Ye(J),J=S,T.setItem(`${t}_tlCam`,S.name),pe(S,w.current))},onSelectRenderMode:b=>{St=b,T.setItem(`${t}_tlRender`,b)}}),u.jsx(ft,{camera:le,options:we,ref:C,onSelectCamera:b=>{e.get(le.name)?.dispose();const S=n.get(b);S!==void 0&&(Ye(le),le=S,T.setItem(`${t}_trCam`,S.name),pe(S,C.current))},onSelectRenderMode:b=>{Qt=b,T.setItem(`${t}_trRender`,b)}})]}),q==="Quad"&&u.jsxs(u.Fragment,{children:[u.jsx(ft,{camera:J,options:we,ref:w,onSelectCamera:b=>{e.get(J.name)?.dispose();const S=n.get(b);S!==void 0&&(Ye(J),J=S,T.setItem(`${t}_tlCam`,S.name),pe(S,w.current))},onSelectRenderMode:b=>{St=b,T.setItem(`${t}_tlRender`,b)}}),u.jsx(ft,{camera:le,options:we,ref:C,onSelectCamera:b=>{e.get(le.name)?.dispose();const S=n.get(b);S!==void 0&&(Ye(le),le=S,T.setItem(`${t}_trCam`,S.name),pe(S,C.current))},onSelectRenderMode:b=>{Qt=b,T.setItem(`${t}_trRender`,b)}}),u.jsx(ft,{camera:Be,options:we,ref:k,onSelectCamera:b=>{e.get(Be.name)?.dispose();const S=n.get(b);S!==void 0&&(Ye(Be),Be=S,T.setItem(`${t}_blCam`,S.name),pe(S,k.current))},onSelectRenderMode:b=>{$i=b,T.setItem(`${t}_blRender`,b)}}),u.jsx(ft,{camera:He,options:we,ref:I,onSelectCamera:b=>{e.get(He.name)?.dispose();const S=n.get(b);S!==void 0&&(Ye(He),He=S,T.setItem(`${t}_brCam`,S.name),pe(S,I.current))},onSelectRenderMode:b=>{Wi=b,T.setItem(`${t}_brRender`,b)}})]})]}),u.jsxs("div",{className:"settings",children:[u.jsx(ii,{title:"View",index:U.indexOf(q),options:U,onSelect:b=>{b!==q&&(Mt(),We(b))},open:Ee,onToggle:b=>{Ce(b),Te&&Ie(!1),Qe&&Je(!1)}}),u.jsx(ii,{title:"Interact",index:Ve==="Orbit"?0:1,options:["Orbit Mode","Selection Mode"],onSelect:b=>{m.visible=b==="Selection Mode",nt(m.visible?"Selection":"Orbit")},open:Qe,onToggle:b=>{Ee&&Ce(!1),Te&&Ie(!1),Je(b)}})]},lt)]})]})}function vs(i){return u.jsxs("div",{className:"editor",ref:i.ref,style:i.style,children:[u.jsx("div",{className:"header",children:i.header}),i.children,u.jsx("div",{className:"footer",children:i.footer})]})}exports.Accordion=Bt;exports.Application=yn;exports.BaseRemote=Ht;exports.ChildObject=xi;exports.ContainerObject=Oi;exports.Draggable=nn;exports.DraggableItem=tn;exports.Dropdown=sn;exports.DropdownItem=an;exports.Editor=vs;exports.ExportTexture=jt;exports.Inspector=cn;exports.MultiView=gs;exports.NavButton=Ti;exports.RemoteComponents=En;exports.RemoteController=In;exports.RemoteTheatre=si;exports.RemoteThree=wn;exports.RemoteTweakpane=Mn;exports.SceneInspector=as;exports.SidePanel=ss;exports.ToolEvents=V;exports.capitalize=Nt;exports.clamp=ct;exports.colorToHex=Qi;exports.debugDispatcher=H;exports.defaultTheatreCallback=_n;exports.dispose=zt;exports.disposeMaterial=Ji;exports.disposeTexture=vn;exports.distance=gn;exports.hierarchyUUID=ti;exports.isColor=qi;exports.mix=ei;exports.noop=ni;exports.normalize=vi;exports.randomID=Xi;exports.resetThreeObjects=Ei;exports.round=yi;exports.theatreEditorApp=bn;
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;