@tomorrowevening/hermes 0.0.90 → 0.0.92
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/hermes.cjs.js +15 -15
- package/dist/hermes.es.js +1309 -1284
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/types/editor/ThreeEditor.d.ts +11 -0
- package/types/editor/theatreUtils.d.ts +1 -0
- package/types/index.d.ts +1 -0
package/dist/hermes.cjs.js
CHANGED
@@ -1,4 +1,4 @@
|
|
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={};/**
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("three"),gn=require("tweakpane"),_n=require("@tweakpane/plugin-essentials"),T=require("react"),qi=require("framer-motion");function vn(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 yn=vn(_n),ni=()=>{},En=()=>{};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 bn(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))},On=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 Cn{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 z=new p.EventDispatcher,B={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 Tn 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":z.dispatchEvent({type:B.SELECT_DROPDOWN,value:t.data});break;case"draggableListUpdate":z.dispatchEvent({type:B.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 m=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,m),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",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}e.send({event:c,target:"app",data:m})})});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 xn(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",m={};switch(r.type){case"Theatre_Sheet_PublicAPI":c="setSheet",m={sheet:r.address.sheetId},e.activeSheet=e.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},e.activeSheet=e.sheets.get(r.address.sheetId);break}i.send({event:c,target:"app",data:m})})});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 Sn(){const i=document.getElementById("theatrejs-studio-root")?.shadowRoot?.getElementById("pointer-root")?.children[0],e=i?.children[1];e.style.justifyContent="left";const n=e.children[1];n.style.transform="translateX(10px)",n.removeChild(n.children[0]),n.removeChild(n.children[0]);const t=i?.children[3];t.style.top="0",t.style.right="300px"}function wn(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 Mn(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 Rn(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"||Rn(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]=Mn(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 Dn(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 An(i,e){for(const n in e)i[n]=e[n]}function fe(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&&An(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 Pn 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":z.dispatchEvent({type:B.GET_OBJECT,value:t.data});break;case"updateObject":z.dispatchEvent({type:B.UPDATE_OBJECT,value:t.data});break;case"createTexture":z.dispatchEvent({type:B.CREATE_TEXTURE,value:t.data});break;case"requestMethod":z.dispatchEvent({type:B.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":z.dispatchEvent({type:B.SET_OBJECT,value:t.data});break;case"addScene":z.dispatchEvent({type:B.ADD_SCENE,value:t.data});break;case"refreshScene":z.dispatchEvent({type:B.REFRESH_SCENE,value:t.data});break;case"removeScene":z.dispatchEvent({type:B.REMOVE_SCENE,value:t.data});break;case"setScene":z.dispatchEvent({type:B.SET_SCENE,value:t.data});break;case"addCamera":z.dispatchEvent({type:B.ADD_CAMERA,value:t.data});break;case"removeCamera":z.dispatchEvent({type:B.REMOVE_CAMERA,value:t.data});break;case"addGroup":z.dispatchEvent({type:B.ADD_GROUP,value:t.data});break;case"removeGroup":z.dispatchEvent({type:B.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 Ln 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 gn.Pane({title:"GUI"}),this.pane.registerPlugin(yn)}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 Di;function
|
9
|
+
*/var Di;function In(){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 m,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(m in h)t.call(h,m)&&!a.hasOwnProperty(m)&&(f[m]=h[m]);if(r&&r.defaultProps)for(m in h=r.defaultProps,h)f[m]===void 0&&(f[m]=h[m]);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 Ai;function
|
18
|
-
`+
|
19
|
-
`),
|
20
|
-
`),
|
21
|
-
`+W[
|
17
|
+
*/var Ai;function kn(){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"),m=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 F(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),Y=1;Y<O;Y++)M[Y-1]=arguments[Y];w("error",l,M)}}function w(l,O,M){{var Y=_.ReactDebugCurrentFrame,ne=Y.getStackAddendum();ne!==""&&(O+="%s",M=M.concat([ne]));var ce=M.map(function(J){return String(J)});ce.unshift("Warning: "+O),Function.prototype.apply.call(console[l],console,ce)}}var C=!1,k=!1,L=!1,x=!1,oe=!1,te;te=Symbol.for("react.module.reference");function $e(l){return!!(typeof l=="string"||typeof l=="function"||l===t||l===a||oe||l===s||l===c||l===m||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===te||l.getModuleId!==void 0))}function j(l,O,M){var Y=l.displayName;if(Y)return Y;var ne=O.displayName||O.name||"";return ne!==""?M+"("+ne+")":M}function ke(l){return l.displayName||"Context"}function ye(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 m:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case r:var O=l;return ke(O)+".Consumer";case o:var M=l;return ke(M._context)+".Provider";case h:return j(l,l.render,"ForwardRef");case f:var Y=l.displayName||null;return Y!==null?Y:ye(l.type)||"Memo";case v:{var ne=l,ce=ne._payload,J=ne._init;try{return ye(J(ce))}catch{return null}}}return null}var Ce=Object.assign,Te=0,Ue,Ve,it,Je,Qe,dt,nt;function ge(){}ge.__reactDisabledLog=!0;function Ye(){{if(Te===0){Ue=console.log,Ve=console.info,it=console.warn,Je=console.error,Qe=console.group,dt=console.groupCollapsed,nt=console.groupEnd;var l={configurable:!0,enumerable:!0,value:ge,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:Ue}),info:Ce({},l,{value:Ve}),warn:Ce({},l,{value:it}),error:Ce({},l,{value:Je}),group:Ce({},l,{value:Qe}),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,Me;function b(l,O,M){{if(Me===void 0)try{throw Error()}catch(ne){var Y=ne.stack.trim().match(/\n( *(at )?)/);Me=Y&&Y[1]||""}return`
|
18
|
+
`+Me+l}}var S=!1,P;{var N=typeof WeakMap=="function"?WeakMap:Map;P=new N}function ue(l,O){if(!l||S)return"";{var M=P.get(l);if(M!==void 0)return M}var Y;S=!0;var ne=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var ce;ce=ht.current,ht.current=null,Ye();try{if(O){var J=function(){throw Error()};if(Object.defineProperty(J.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(J,[])}catch(tt){Y=tt}Reflect.construct(l,[],J)}else{try{J.call()}catch(tt){Y=tt}l.call(J.prototype)}}else{try{throw Error()}catch(tt){Y=tt}l()}}catch(tt){if(tt&&Y&&typeof tt.stack=="string"){for(var W=tt.stack.split(`
|
19
|
+
`),we=Y.stack.split(`
|
20
|
+
`),pe=W.length-1,ve=we.length-1;pe>=1&&ve>=0&&W[pe]!==we[ve];)ve--;for(;pe>=1&&ve>=0;pe--,ve--)if(W[pe]!==we[ve]){if(pe!==1||ve!==1)do if(pe--,ve--,ve<0||W[pe]!==we[ve]){var Be=`
|
21
|
+
`+W[pe].replace(" at new "," at ");return l.displayName&&Be.includes("<anonymous>")&&(Be=Be.replace("<anonymous>",l.displayName)),typeof l=="function"&&P.set(l,Be),Be}while(pe>=1&&ve>=0);break}}}finally{S=!1,ht.current=ce,Mt(),Error.prepareStackTrace=ne}var yt=l?l.displayName||l.name:"",Ri=yt?b(yt):"";return typeof l=="function"&&P.set(l,Ri),Ri}function X(l,O,M){return ue(l,!1)}function D(l){var O=l.prototype;return!!(O&&O.isReactComponent)}function U(l,O,M){if(l==null)return"";if(typeof l=="function")return ue(l,D(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 X(l.render);case f:return U(l.type,O,M);case v:{var Y=l,ne=Y._payload,ce=Y._init;try{return U(ce(ne),O,M)}catch{}}}return""}var me=Object.prototype.hasOwnProperty,Ee={},et=_.ReactDebugCurrentFrame;function Oe(l){if(l){var O=l._owner,M=U(l.type,l._source,O?O.type:null);et.setExtraStackFrame(M)}else et.setExtraStackFrame(null)}function xe(l,O,M,Y,ne){{var ce=Function.call.bind(me);for(var J in l)if(ce(l,J)){var W=void 0;try{if(typeof l[J]!="function"){var we=Error((Y||"React class")+": "+M+" type `"+J+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof l[J]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw we.name="Invariant Violation",we}W=l[J](O,J,Y,M,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(pe){W=pe}W&&!(W instanceof Error)&&(Oe(ne),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).",Y||"React class",M,J,typeof W),Oe(null)),W instanceof Error&&!(W.message in Ee)&&(Ee[W.message]=!0,Oe(ne),E("Failed %s type: %s",M,W.message),Oe(null))}}}var Ae=Array.isArray;function se(l){return Ae(l)}function _e(l){{var O=typeof Symbol=="function"&&Symbol.toStringTag,M=O&&l[Symbol.toStringTag]||l.constructor.name||"Object";return M}}function G(l){try{return H(l),!1}catch{return!0}}function H(l){return""+l}function q(l){if(G(l))return E("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",_e(l)),H(l)}var Q=_.ReactCurrentOwner,Pe={key:!0,ref:!0,__self:!0,__source:!0},Fe,st,We;We={};function _t(l){if(me.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(me.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"&&Q.current&&O&&Q.current.stateNode!==O){var M=ye(Q.current.type);We[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',ye(Q.current.type),l.ref),We[M]=!0)}}function Vt(l,O){{var M=function(){Fe||(Fe=!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,Y,ne,ce,J){var W={$$typeof:e,type:l,key:O,ref:M,props:J,_owner:ce};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:Y}),Object.defineProperty(W,"_source",{configurable:!1,enumerable:!1,writable:!1,value:ne}),Object.freeze&&(Object.freeze(W.props),Object.freeze(W)),W};function d(l,O,M,Y,ne){{var ce,J={},W=null,we=null;M!==void 0&&(q(M),W=""+M),ri(O)&&(q(O.key),W=""+O.key),_t(O)&&(we=O.ref,oi(O,ne));for(ce in O)me.call(O,ce)&&!Pe.hasOwnProperty(ce)&&(J[ce]=O[ce]);if(l&&l.defaultProps){var pe=l.defaultProps;for(ce in pe)J[ce]===void 0&&(J[ce]=pe[ce])}if(W||we){var ve=typeof l=="function"?l.displayName||l.name||"Unknown":l;W&&Vt(J,ve),we&&at(J,ve)}return wi(l,W,we,ne,Y,Q.current,J)}}var R=_.ReactCurrentOwner,$=_.ReactDebugCurrentFrame;function ee(l){if(l){var O=l._owner,M=U(l.type,l._source,O?O.type:null);$.setExtraStackFrame(M)}else $.setExtraStackFrame(null)}var be;be=!1;function je(l){return typeof l=="object"&&l!==null&&l.$$typeof===e}function Se(){{if(R.current){var l=ye(R.current.type);if(l)return`
|
22
22
|
|
23
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 Gt(l){{var O=
|
25
|
+
Check your code at `+O+":"+M+"."}return""}}var Yt={};function Gt(l){{var O=Se();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
|
27
|
+
Check the top-level render call using <`+M+">.")}return O}}function Ne(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 Y="";l&&l._owner&&l._owner!==R.current&&(Y=" It was passed a child from "+ye(l._owner.type)+"."),ee(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,Y),ee(null)}}function ze(l,O){{if(typeof l!="object")return;if(se(l))for(var M=0;M<l.length;M++){var Y=l[M];je(Y)&&Ne(Y,O)}else if(je(l))l._store&&(l._store.validated=!0);else if(l){var ne=F(l);if(typeof ne=="function"&&ne!==l.entries)for(var ce=ne.call(l),J;!(J=ce.next()).done;)je(J.value)&&Ne(J.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 Y=ye(O);xe(M,l.props,"prop",Y,l)}else if(O.PropTypes!==void 0&&!be){be=!0;var ne=ye(O);E("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ne||"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 Y=O[M];if(Y!=="children"&&Y!=="key"){ee(l),E("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Y),ee(null);break}}l.ref!==null&&(ee(l),E("Invalid attribute `ref` supplied to `React.Fragment`."),ee(null))}}function rt(l,O,M,Y,ne,ce){{var J=$e(l);if(!J){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 we=Mi(ne);we?W+=we:W+=Se();var pe;l===null?pe="null":se(l)?pe="array":l!==void 0&&l.$$typeof===e?(pe="<"+(ye(l.type)||"Unknown")+" />",W=" Did you accidentally export a JSX literal instead of a component?"):pe=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",pe,W)}var ve=d(l,O,M,ne,ce);if(ve==null)return ve;if(J){var Be=O.children;if(Be!==void 0)if(Y)if(se(Be)){for(var yt=0;yt<Be.length;yt++)ze(Be[yt],l);Object.freeze&&Object.freeze(Be)}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 ze(Be,l)}return l===t?Ge(ve):ut(ve),ve}}function vt(l,O,M){return rt(l,O,M,!0)}function Zt(l,O,M){return rt(l,O,M,!1)}var pn=Zt,fn=vt;Dt.Fragment=t,Dt.jsx=pn,Dt.jsxs=fn}()),Dt}process.env.NODE_ENV==="production"?Oi.exports=In():Oi.exports=kn();var u=Oi.exports;function xi(i){return i.title.search("<")>-1?u.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:i.title}}):u.jsx("button",{children:i.title})}const Un=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"})]}),Fn=u.jsx("svg",{className:"dragIcon",width:"14",height:"14",fill:"#666666",stroke:"none",children:u.jsx("path",{d:`M10.43,4H3.57C3.26,4,3,4.22,3,4.5v1C3,5.78,3.26,6,3.57,6h6.86C10.74,6,11,5.78,11,5.5v-1
|
28
28
|
C11,4.22,10.74,4,10.43,4z M10.43,8H3.57C3.26,8,3,8.22,3,8.5v1C3,9.78,3.26,10,3.57,10h6.86C10.74,10,11,9.78,11,9.5v-1
|
29
|
-
C11,8.22,10.74,8,10.43,8z`})});function 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}/*!
|
29
|
+
C11,8.22,10.74,8,10.43,8z`})});function nn(i){return u.jsx(qi.Reorder.Item,{value:i.title,children:u.jsxs("div",{children:[Fn,u.jsx("span",{children:i.title}),u.jsx("button",{className:"closeIcon",onClick:()=>{i.onDelete(i.index)},children:Un})]})},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 m=[...t];m.splice(c,1),a(m)},r=[];t.forEach((c,m)=>{r.push(u.jsx(nn,{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(xi,{title:i.title}),u.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(u.jsx(rn,{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(xi,{title:i.title}),u.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=u.jsx(sn,{title:e.title,options:e.value,onDragComplete:a=>{e.onDragComplete!==void 0&&e.onDragComplete(a)},subdropdown:!0});break;case"dropdown":s=u.jsx(an,{title:e.title,options:e.value,onSelect:e.onSelect,subdropdown:!0});break;case"option":s=u.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 u.jsx("li",{className:n===e.title?"selected":"",children:s},Ji())}function jn(i,e,n){function t(a){switch(e.forEach(o=>{o.callback(i,o.remote,a)}),a.event){case"custom":z.dispatchEvent({type:B.CUSTOM,value:a.data});break}}function s(a){switch(n.forEach(o=>{o.callback(i,o.remote,a)}),a.event){case"custom":z.dispatchEvent({type:B.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=()=>{z.dispatchEvent({type:B.REMOVE_SCENE,value:i.scene})};return u.jsxs("div",{className:`accordion ${t?"hide":""}`,children:[u.jsxs("button",{className:"toggle",onClick:()=>{const a=!e;i.onToggle!==void 0&&i.onToggle(a),n(a)},children:[u.jsx("p",{className:`status ${e?"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:e?"open":"",children:u.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(u.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]),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:()=>{t(!n)}}):null,u.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}`}),u.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),fe(r,h,c)}}}}}),u.jsx("div",{className:`icon ${wn(i.child)}`})]}),u.jsx("div",{className:n?"open":"",children:u.jsx("div",{className:"container",children:a})})]},Math.random())})}function Ci(i){const e=[];return i.child?.children.map((n,t)=>{e.push(u.jsx(Si,{child:n,scene:i.scene,three:i.three},t))}),u.jsx("div",{className:`scene ${i.class!==void 0?i.class:""}`,children:e})}function Nn(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)},m=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",m),i.label.current?.addEventListener("mousedown",r,!1),i.sliderRef!==void 0&&i.sliderRef.current?.addEventListener("input",f),()=>{i.input.current?.removeEventListener("input",m),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=Nn({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 u.jsxs(u.Fragment,{children:[i.type==="number"&&u.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"&&u.jsxs(u.Fragment,{children:[u.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)}}),u.jsx("input",{disabled:i.disabled,type:"range",value:t,min:i.min,max:i.max,step:i.step,ref:n,onChange:ni})]})]})}function zn(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,m]=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,oe=Ei(ei(c.min,c.max,L),3),te=Ei(ei(c.min,c.max,x),3);i.onChange({target:{value:{x:oe,y:te}}}),h({x:oe,y:te})}function F(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);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)})}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 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:e,type:"number",value:r.x,min:c.min,max:c.max,step:w,onChange:F})]}),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:F})]}),u.jsxs("div",{children:[u.jsx("label",{children:"Min:"}),u.jsx("input",{ref:t,type:"number",value:c.min,step:w,onChange:_})]}),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:A,children:[u.jsx("div",{className:"x"}),u.jsx("div",{className:"y"}),u.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,m)=>{o[c]=m,i.onChange({target:{value:o}})};["x","y","z"].forEach(c=>{const m=T.useRef(null);a.push(u.jsxs("div",{children:[u.jsx("label",{ref:m,children:c.toUpperCase()}),u.jsx(gt,{value:o[c],type:"number",prop:c,step:s,labelRef:m,onChange:r})]},c))})}else if(n){const o=T.useMemo(()=>i.value,[]),r=(c,m)=>{o[c]=m,i.onChange({target:{value:o}})};["_x","_y","_z"].forEach(c=>{const m=T.useRef(null);a.push(u.jsxs("div",{children:[u.jsx("label",{ref:m,children:c.substring(1).toUpperCase()}),u.jsx(gt,{value:o[c],type:"number",prop:c,step:s,labelRef:m,onChange:r})]},c))})}else if(t){const o=T.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=T.useRef(null);a.push(u.jsxs("div",{children:[u.jsx("label",{ref:c,children:h+1}),u.jsx(gt,{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 Bn(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(u.jsxs("div",{children:[u.jsx("label",{ref:h,children:r.toUpperCase()}),u.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(u.jsxs("div",{children:[u.jsx("label",{ref:r,children:o+1}),u.jsx(gt,{value:s.elements[o],type:"number",prop:o.toString(),step:n,labelRef:r,onChange:a})]},o.toString()))}}return u.jsx("div",{className:"grid4",children:t})}function Hn(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 Vn(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 Yn(){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 Gn=[{title:"Front",value:p.FrontSide},{title:"Back",value:p.BackSide},{title:"Double",value:p.DoubleSide}],Zn=[{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}],$n=[{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}],Wn=[{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}],Kn=[{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 Xn(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);fe(r,`material.${i}`,a)}}}}function qn(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);fe(h,`material.${i}`,o)}}};switch(i){case"blending":At(s,Zn);break;case"blendDst":At(s,Kn);break;case"blendEquation":At(s,$n);break;case"blendSrc":At(s,Wn);break;case"side":At(s,Gn);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 Jn(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);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,t.updateObject(n.uuid,`material.${i}`,r);const h=t.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)){t.updateObject(n.uuid,"material.needsUpdate",!0);const r=t.getScene(n.uuid);if(r!==null){const h=r.getObjectByProperty("uuid",n.uuid);fe(h,"material.needsUpdate",!0)}}}),s}function Qn(i){return i.x!==void 0&&i.y!==void 0&&i.z===void 0}function es(i){return i.x!==void 0&&i.y!==void 0&&i.z!==void 0&&i.w===void 0}function ts(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,m)=>{t.updateObject(n.uuid,`material.${r}`,m);const f=t.getScene(n.uuid);if(f!==null){const v=f.getObjectByProperty("uuid",n.uuid);fe(v,`material.${r}`,m)}}};if(h==="number"){const c={title:o,prop:r,type:"number",value:e,step:.01,disabled:a,onChange:(m,f)=>{t.updateObject(n.uuid,`material.${r}`,f);const v=t.getScene(n.uuid);if(v!==null){const y=v.getObjectByProperty("uuid",n.uuid);fe(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,m)=>{const f=new p.Color(m);t.updateObject(n.uuid,`material.${r}`,f);const v=t.getScene(n.uuid);if(v!==null){const y=v.getObjectByProperty("uuid",n.uuid);fe(y,`material.${r}`,f)}}};if(Array.isArray(e)){const c=[];for(const m in e){const f=e[m],v=`[${m.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(Qn(e))return{title:o,prop:r,type:"vector2",value:e,disabled:a,onChange:(c,m)=>{t.updateObject(n.uuid,`material.${r}`,m);const f=t.getScene(n.uuid);if(f!==null){const v=f.getObjectByProperty("uuid",n.uuid);fe(v,`material.${r}`,m)}}};if(es(e))return{title:o,prop:r,type:"grid3",value:e,disabled:a,onChange:(c,m)=>{t.updateObject(n.uuid,`material.${r}`,m);const f=t.getScene(n.uuid);if(f!==null){const v=f.getObjectByProperty("uuid",n.uuid);fe(v,`material.${r}`,m)}}};if(ts(e))return{title:o,prop:r,type:"grid4",value:e,disabled:a,onChange:(c,m)=>{t.updateObject(n.uuid,`material.${r}`,m);const f=t.getScene(n.uuid);if(f!==null){const v=f.getObjectByProperty("uuid",n.uuid);fe(v,`material.${r}`,m)}}};if(e.isEuler)return{title:o,prop:r,type:"euler",value:e,disabled:a,onChange:(c,m)=>{t.updateObject(n.uuid,`material.${r}`,m);const f=t.getScene(n.uuid);if(f!==null){const v=f.getObjectByProperty("uuid",n.uuid);fe(v,`material.${r}`,m)}}};if(e.src!==void 0)return{title:o,type:"image",value:e,disabled:a,onChange:(c,m)=>{const f=Vn(i),v=s.length>0?`${s}.${f}`:f;t.createTexture(n.uuid,`material.${v}`,m);const y=t.getScene(n.uuid);if(y!==null){const A=y.getObjectByProperty("uuid",n.uuid);if(A!==void 0){const I=F=>{const _=A.material,E=v.split(".");switch(E.length){case 1:_[E[0]]=F;break;case 2:_[E[0]][E[1]]=F;break;case 3:_[E[0]][E[1]][E[2]]=F;break;case 4:_[E[0]][E[1]][E[2]][E[3]]=F;break;case 5:_[E[0]][E[1]][E[2]][E[3]][E[4]]=F;break}_.needsUpdate=!0};m.src.length>0?tn(m.src).then(F=>{F.offset.set(m.offset[0],m.offset[1]),F.repeat.set(m.repeat[0],m.repeat[1]),I(F)}):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,m)=>{t.updateObject(n.uuid,`material.${r}`,m);const f=t.getScene(n.uuid);if(f!==null){const v=f.getObjectByProperty("uuid",n.uuid);fe(v,`material.${r}`,m)}}};{const c=[],m=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,m);y!==void 0&&c.push(y)}else{const y=Ft(f,v,n,t,r,m);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(!Hn(s))continue;const a=typeof i[s],o=i[s];if(a==="boolean")t.push(Xn(s,o,e,n));else if(a==="number")t.push(qn(s,o,e,n));else if(a==="string")t.push(Jn(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);fe(a,"material.needsUpdate",!0)}}}),t}function is(i,e){const n=i.material;if(Array.isArray(n)){const t=[],s=n.length;for(let a=0;a<s;a++)t.push(u.jsx(lt,{title:`Material ${a}`,items:Li(n[a],i,e)},`Material ${a}`));return u.jsx(u.Fragment,{children:t})}else return u.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 ns(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]),[m,f]=T.useState(i.value.offset[1]),[v,y]=T.useState(i.value.repeat[0]),[A,I]=T.useState(i.value.repeat[1]);function F(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),F(w,C,m,v,A);break;case s.current:f(C),F(w,h,C,v,A);break;case a.current:y(C),F(w,h,m,C,A);break;case o.current:I(C),F(w,h,m,v,C);break}}return u.jsxs("div",{className:"imageField",children:[u.jsx("img",{alt:i.title,ref:n,onClick:()=>{Yn().then(E=>{n.current.src=E,F(E,h,m,v,A)})},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:t,type:"number",value:h,step:e,onChange:_}),u.jsx("input",{ref:s,type:"number",value:m,step:e,onChange:_})]}),u.jsxs("div",{children:[u.jsx("label",{children:"Repeat:"}),u.jsx("input",{ref:a,type:"number",value:v,step:e,onChange:_}),u.jsx("input",{ref:o,type:"number",value:A,step:e,onChange:_})]}),u.jsx("button",{onClick:()=>{F("",h,m,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 m=c.target.value;i.type==="boolean"?m=c.target.checked:i.type==="option"&&(m=i.options[m].value),t(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(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"&&u.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"&&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(ns,{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(zn,{step:i.step,value:n,min:0,max:1,onChange:a}),i.type==="grid3"&&u.jsx(Pi,{step:i.step,value:n,onChange:a}),i.type==="grid4"&&u.jsx(Bn,{step:i.step,value:n,onChange:a}),i.type==="euler"&&u.jsx(Pi,{step:i.step,value:n,onChange:a})]})}function ss(i){return"items"in i}function lt(i){const e=[];return i.items.forEach(n=>{ss(n)?e.push(u.jsx(lt,{title:Nt(n.title),items:n.items},Math.random())):e.push(u.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()))}),u.jsx(Bt,{label:i.title,open:i.expanded===!0,children:e})}function as(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(m=>{c.push({title:m.title,type:m.type,value:m.value,prop:m.prop,min:m.min,max:m.max,step:m.step,onChange:(f,v)=>{i.three.updateGroup(h.title,f,v)}})}),e.push(u.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 m=0;m<c;m++)if(h===n[m]){e.splice(m,1),n.splice(m,1),s(Date.now());return}};return z.addEventListener(B.ADD_GROUP,a),z.addEventListener(B.REMOVE_GROUP,o),()=>{z.removeEventListener(B.ADD_GROUP,a),z.removeEventListener(B.REMOVE_GROUP,o)}},[]),u.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 rs(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&&(fe(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&&(fe(r,s,a),r.updateProjectionMatrix())}}});return u.jsx(lt,{title:"Camera",items:n})}function os(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 m=e.getScene(i.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",i.uuid);fe(f,r,c)}};return u.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 cs(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);fe(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);fe(h,a,o)}}}))}return u.jsx(lt,{title:"Light",items:n})}function ls(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:(m,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 u.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 Re={...cn};function ln(i){const[e,n]=T.useState(-1);T.useEffect(()=>{function o(h){Re={...h.value},n(Date.now())}function r(){Re={...cn},n(Date.now())}return z.addEventListener(B.SET_SCENE,r),z.addEventListener(B.SET_OBJECT,o),()=>{z.removeEventListener(B.SET_SCENE,r),z.removeEventListener(B.SET_OBJECT,o)}},[]);const t=Re.type.toLowerCase(),s=Re.animations.length>0||Re.mixer!==void 0,a=t.search("mesh")>-1||t.search("line")>-1||t.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(Qt,{type:"string",title:"Name",prop:"name",value:Re.name,disabled:!0}),u.jsx(Qt,{type:"string",title:"Type",prop:"type",value:Re.type,disabled:!0}),u.jsx(Qt,{type:"string",title:"UUID",prop:"uuid",value:Re.uuid,disabled:!0})]}),u.jsxs(u.Fragment,{children:[os(Re,i.three),s?ls(Re,i.three):null,t.search("camera")>-1?rs(Re,i.three):null,t.search("light")>-1?cs(Re,i.three):null,a?is(Re,i.three):null]})]})},e)},"Inspector")}function dn(i){const[e]=T.useState([]),[n]=T.useState([]),[t,s]=T.useState(0),a=h=>{const c=h.value;e.push(c),n.push(u.jsx(Bt,{label:`Scene: ${c.name}`,scene:c,open:!0,onRefresh:()=>{i.three.refreshScene(c.name)},children:u.jsx(Ci,{child:c,scene:c,three:i.three})},Math.random())),s(Date.now())},o=h=>{const c=h.value;for(let m=0;m<e.length;m++)if(c.uuid===e[m].uuid){e[m]=c,n[m]=u.jsx(Bt,{label:`Scene: ${c.name}`,scene:c,open:!0,onRefresh:()=>{i.three.refreshScene(c.name)},children:u.jsx(Ci,{child:c,scene:c,three:i.three})},Math.random()),s(Date.now());return}},r=h=>{const c=h.value;for(let m=0;m<e.length;m++)if(c.uuid===e[m].uuid){e.splice(m,1),n.splice(m,1),s(Date.now());return}};return T.useEffect(()=>(z.addEventListener(B.ADD_SCENE,a),z.addEventListener(B.REFRESH_SCENE,o),z.addEventListener(B.REMOVE_SCENE,r),()=>{z.removeEventListener(B.ADD_SCENE,a),z.removeEventListener(B.REFRESH_SCENE,o),z.removeEventListener(B.REMOVE_SCENE,r)}),[]),u.jsxs("div",{id:"SidePanel",children:[u.jsx("div",{className:"scenes",children:n},t),u.jsx(ln,{three:i.three}),u.jsx(as,{three:i.three})]})}function ds(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,m=e(h)?.getObjectByProperty("uuid",h);m!==void 0&&i.three.setObject(m)},t=(r,h,c)=>{const f=e(r)?.getObjectByProperty("uuid",r);f!==void 0&&fe(f,h,c)},s=r=>{const h=r.value,{key:c,value:m,uuid:f}=h;t(f,c,m)},a=r=>{const h=r.value,m=e(h.uuid)?.getObjectByProperty("uuid",h.uuid);if(m!==void 0){const f=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?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:m,subitem:f}=r.value,y=e(c)?.getObjectByProperty("uuid",c);if(y!==void 0)try{f!==void 0?Dn(y,f)[h](m):y[h](m)}catch(A){console.log("Error requesting method:"),console.log(A),console.log(h),console.log(m)}};return z.addEventListener(B.GET_OBJECT,n),z.addEventListener(B.UPDATE_OBJECT,s),z.addEventListener(B.CREATE_TEXTURE,a),z.addEventListener(B.REQUEST_METHOD,o),()=>{z.removeEventListener(B.GET_OBJECT,n),z.removeEventListener(B.UPDATE_OBJECT,s),z.removeEventListener(B.CREATE_TEXTURE,a),z.removeEventListener(B.REQUEST_METHOD,o)}},[]),null}class hs 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,us=Math.cos(70*p.MathUtils.DEG2RAD);class ms 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",Pe),this._domElementKeyEvents=d},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Pe),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)),$=R.clone().invert(),ee=new p.Vector3,be=new p.Quaternion,je=new p.Vector3,Se=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&&ke($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 Ne=t.minAzimuthAngle,ze=t.maxAzimuthAngle;isFinite(Ne)&&isFinite(ze)&&(Ne<-Math.PI?Ne+=Se:Ne>Math.PI&&(Ne-=Se),ze<-Math.PI?ze+=Se:ze>Math.PI&&(ze-=Se),Ne<=ze?r.theta=Math.max(Ne,Math.min(ze,r.theta)):r.theta=r.theta>(Ne+ze)/2?Math.max(Ne,r.theta):Math.min(ze,r.theta)),r.phi=Math.max(t.minPolarAngle,Math.min(t.maxPolarAngle,r.phi)),r.makeSafe(),t.enableDamping===!0?t.target.addScaledVector(m,t.dampingFactor):t.target.add(m),t.target.sub(t.cursor),t.target.clampLength(t.minTargetRadius,t.maxTargetRadius),t.target.add(t.cursor);let ut=!1;if(t.zoomToCursor&&L||t.object.isOrthographicCamera)r.radius=Qe(r.radius);else{const Ge=r.radius;r.radius=Qe(r.radius*c),ut=Ge!=r.radius}if(d.setFromSpherical(r),d.applyQuaternion($),Gt.copy(t.target).add(d),t.object.lookAt(t.target),t.enableDamping===!0?(h.theta*=1-t.dampingFactor,h.phi*=1-t.dampingFactor,m.multiplyScalar(1-t.dampingFactor)):(h.set(0,0,0),m.set(0,0,0)),t.zoomToCursor&&L){let Ge=null;if(t.object.isPerspectiveCamera){const rt=d.length();Ge=Qe(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))<us?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||ee.distanceToSquared(t.object.position)>o||8*(1-be.dot(t.object.quaternion))>o||je.distanceToSquared(t.target)>o?(t.dispatchEvent(Fi),ee.copy(t.object.position),be.copy(t.object.quaternion),je.copy(t.target),!0):!1}}(),this.dispose=function(){t.domElement.removeEventListener("contextmenu",We),t.domElement.removeEventListener("pointerdown",Oe),t.domElement.removeEventListener("pointercancel",Ae),t.domElement.removeEventListener("wheel",G),t.domElement.removeEventListener("pointermove",xe),t.domElement.removeEventListener("pointerup",Ae),t.domElement.getRootNode().removeEventListener("keydown",q,{capture:!0}),t._domElementKeyEvents!==null&&(t._domElementKeyEvents.removeEventListener("keydown",Pe),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 m=new p.Vector3,f=new p.Vector2,v=new p.Vector2,y=new p.Vector2,A=new p.Vector2,I=new p.Vector2,F=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=[],oe={};let te=!1;function $e(d){return d!==null?2*Math.PI/60*t.autoRotateSpeed*d:2*Math.PI/60/60*t.autoRotateSpeed}function j(d){const R=Math.abs(d*.01);return Math.pow(.95,t.zoomSpeed*R)}function ke(d){h.theta-=d}function ye(d){h.phi-=d}const Ce=function(){const d=new p.Vector3;return function($,ee){d.setFromMatrixColumn(ee,0),d.multiplyScalar(-$),m.add(d)}}(),Te=function(){const d=new p.Vector3;return function($,ee){t.screenSpacePanning===!0?d.setFromMatrixColumn(ee,1):(d.setFromMatrixColumn(ee,0),d.crossVectors(t.object.up,d)),d.multiplyScalar($),m.add(d)}}(),Ue=function(){const d=new p.Vector3;return function($,ee){const be=t.domElement;if(t.object.isPerspectiveCamera){const je=t.object.position;d.copy(je).sub(t.target);let Se=d.length();Se*=Math.tan(t.object.fov/2*Math.PI/180),Ce(2*$*Se/be.clientHeight,t.object.matrix),Te(2*ee*Se/be.clientHeight,t.object.matrix)}else t.object.isOrthographicCamera?(Ce($*(t.object.right-t.object.left)/t.object.zoom/be.clientWidth,t.object.matrix),Te(ee*(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 Je(d,R){if(!t.zoomToCursor)return;L=!0;const $=t.domElement.getBoundingClientRect(),ee=d-$.left,be=R-$.top,je=$.width,Se=$.height;k.x=ee/je*2-1,k.y=-(be/Se)*2+1,C.set(k.x,k.y,1).unproject(t.object).sub(t.object.position).normalize()}function Qe(d){return Math.max(t.minDistance,Math.min(t.maxDistance,d))}function dt(d){f.set(d.clientX,d.clientY)}function nt(d){Je(d.clientX,d.clientX),_.set(d.clientX,d.clientY)}function ge(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;ke(2*Math.PI*y.x/R.clientHeight),ye(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(j(w.y)):w.y<0&&it(j(w.y)),_.copy(E),t.update()}function ht(d){I.set(d.clientX,d.clientY),F.subVectors(I,A).multiplyScalar(t.panSpeed),Ue(F.x,F.y),A.copy(I),t.update()}function Me(d){Je(d.clientX,d.clientY),d.deltaY<0?it(j(d.deltaY)):d.deltaY>0&&Ve(j(d.deltaY)),t.update()}function b(d){let R=!1;switch(d.code){case t.keys.UP:d.ctrlKey||d.metaKey||d.shiftKey?ye(2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):Ue(0,t.keyPanSpeed),R=!0;break;case t.keys.BOTTOM:d.ctrlKey||d.metaKey||d.shiftKey?ye(-2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):Ue(0,-t.keyPanSpeed),R=!0;break;case t.keys.LEFT:d.ctrlKey||d.metaKey||d.shiftKey?ke(2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):Ue(t.keyPanSpeed,0),R=!0;break;case t.keys.RIGHT:d.ctrlKey||d.metaKey||d.shiftKey?ke(-2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):Ue(-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),$=.5*(d.pageX+R.x),ee=.5*(d.pageY+R.y);f.set($,ee)}}function P(d){if(x.length===1)A.set(d.pageX,d.pageY);else{const R=at(d),$=.5*(d.pageX+R.x),ee=.5*(d.pageY+R.y);A.set($,ee)}}function N(d){const R=at(d),$=d.pageX-R.x,ee=d.pageY-R.y,be=Math.sqrt($*$+ee*ee);_.set(0,be)}function ue(d){t.enableZoom&&N(d),t.enablePan&&P(d)}function X(d){t.enableZoom&&N(d),t.enableRotate&&S(d)}function D(d){if(x.length==1)v.set(d.pageX,d.pageY);else{const $=at(d),ee=.5*(d.pageX+$.x),be=.5*(d.pageY+$.y);v.set(ee,be)}y.subVectors(v,f).multiplyScalar(t.rotateSpeed);const R=t.domElement;ke(2*Math.PI*y.x/R.clientHeight),ye(2*Math.PI*y.y/R.clientHeight),f.copy(v)}function U(d){if(x.length===1)I.set(d.pageX,d.pageY);else{const R=at(d),$=.5*(d.pageX+R.x),ee=.5*(d.pageY+R.y);I.set($,ee)}F.subVectors(I,A).multiplyScalar(t.panSpeed),Ue(F.x,F.y),A.copy(I)}function me(d){const R=at(d),$=d.pageX-R.x,ee=d.pageY-R.y,be=Math.sqrt($*$+ee*ee);E.set(0,be),w.set(0,Math.pow(E.y/_.y,t.zoomSpeed)),Ve(w.y),_.copy(E);const je=(d.pageX+R.x)*.5,Se=(d.pageY+R.y)*.5;Je(je,Se)}function Ee(d){t.enableZoom&&me(d),t.enablePan&&U(d)}function et(d){t.enableZoom&&me(d),t.enableRotate&&D(d)}function Oe(d){t.enabled!==!1&&(x.length===0&&(t.domElement.setPointerCapture(d.pointerId),t.domElement.addEventListener("pointermove",xe),t.domElement.addEventListener("pointerup",Ae)),!oi(d)&&(_t(d),d.pointerType==="touch"?Fe(d):se(d)))}function xe(d){t.enabled!==!1&&(d.pointerType==="touch"?st(d):_e(d))}function Ae(d){switch(ri(d),x.length){case 0:t.domElement.releasePointerCapture(d.pointerId),t.domElement.removeEventListener("pointermove",xe),t.domElement.removeEventListener("pointerup",Ae),t.dispatchEvent(ji),a=s.NONE;break;case 1:const R=x[0],$=oe[R];Fe({pointerId:R,pageX:$.x,pageY:$.y});break}}function se(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;ge(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;ge(d),a=s.PAN}break;default:a=s.NONE}a!==s.NONE&&t.dispatchEvent(li)}function _e(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 G(d){t.enabled===!1||t.enableZoom===!1||a!==s.NONE||(d.preventDefault(),t.dispatchEvent(li),Me(H(d)),t.dispatchEvent(ji))}function H(d){const R=d.deltaMode,$={clientX:d.clientX,clientY:d.clientY,deltaY:d.deltaY};switch(R){case 1:$.deltaY*=16;break;case 2:$.deltaY*=100;break}return d.ctrlKey&&!te&&($.deltaY*=10),$}function q(d){d.key==="Control"&&(te=!0,t.domElement.getRootNode().addEventListener("keyup",Q,{passive:!0,capture:!0}))}function Q(d){d.key==="Control"&&(te=!1,t.domElement.getRootNode().removeEventListener("keyup",Q,{passive:!0,capture:!0}))}function Pe(d){t.enabled===!1||t.enablePan===!1||b(d)}function Fe(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;ue(d),a=s.TOUCH_DOLLY_PAN;break;case p.TOUCH.DOLLY_ROTATE:if(t.enableZoom===!1&&t.enableRotate===!1)return;X(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;U(d),t.update();break;case s.TOUCH_DOLLY_PAN:if(t.enableZoom===!1&&t.enablePan===!1)return;Ee(d),t.update();break;case s.TOUCH_DOLLY_ROTATE:if(t.enableZoom===!1&&t.enableRotate===!1)return;et(d),t.update();break;default:a=s.NONE}}function We(d){t.enabled!==!1&&d.preventDefault()}function _t(d){x.push(d.pointerId)}function ri(d){delete oe[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=oe[d.pointerId];R===void 0&&(R=new p.Vector2,oe[d.pointerId]=R),R.set(d.pageX,d.pageY)}function at(d){const R=d.pointerId===x[0]?x[1]:x[0];return oe[R]}t.domElement.addEventListener("contextmenu",We),t.domElement.addEventListener("pointerdown",Oe),t.domElement.addEventListener("pointercancel",Ae),t.domElement.addEventListener("wheel",G,{passive:!1}),t.domElement.getRootNode().addEventListener("keydown",q,{passive:!0,capture:!0}),this.update()}}const ps=Math.PI/180;function bt(i,e,n,t,s){return t+(i-e)*(s-t)/(n-e)}function zi(i){return i*ps}/*!
|
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 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;
|
35
|
+
*/const he={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,hn=1e-5,Pt=Math.PI/180;function Ze(i,e,n){return Math.max(e,Math.min(n,i))}function de(i,e=hn){return Math.abs(i)<e}function ae(i,e,n=hn){return de(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 m=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 m-i>0==y>m&&(y=m,n.value=(y-m)/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 m=e.x,f=e.y,v=e.z,y=i.x-m,A=i.y-f,I=i.z-v;const F=m,_=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}m=i.x-y,f=i.y-A,v=i.z-I;const L=(n.x+r*y)*a,x=(n.y+r*A)*a,oe=(n.z+r*I)*a;n.x=(n.x-r*L)*c,n.y=(n.y-r*x)*c,n.z=(n.z-r*oe)*c,o.x=m+(y+L)*c,o.y=f+(A+x)*c,o.z=v+(I+oe)*c;const te=F-i.x,$e=_-i.y,j=E-i.z,ke=o.x-F,ye=o.y-_,Ce=o.z-E;return te*ke+$e*ye+j*Ce>0&&(o.x=F,o.y=_,o.z=E,n.x=(o.x-F)/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 fs{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 gs="2.9.0",Kt=1/8,_s=/Mac/.test((ui=globalThis?.navigator)===null||ui===void 0?void 0:ui.platform);let V,Yi,Xt,mi,De,Z,ie,Tt,kt,Ke,Xe,pt,Gi,Zi,He,Ut,xt,$i,pi,Wi,fi,gi,qt;class qe extends fs{static install(e){V=e.THREE,Yi=Object.freeze(new V.Vector3(0,0,0)),Xt=Object.freeze(new V.Vector3(0,1,0)),mi=Object.freeze(new V.Vector3(0,0,1)),De=new V.Vector2,Z=new V.Vector3,ie=new V.Vector3,Tt=new V.Vector3,kt=new V.Vector3,Ke=new V.Vector3,Xe=new V.Vector3,pt=new V.Vector3,Gi=new V.Vector3,Zi=new V.Vector3,He=new V.Spherical,Ut=new V.Spherical,xt=new V.Box3,$i=new V.Box3,pi=new V.Sphere,Wi=new V.Quaternion,fi=new V.Quaternion,gi=new V.Matrix4,qt=new V.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 V.Vector3,this._focalOffsetVelocity=new V.Vector3,this._zoomVelocity={value:0},this._truckInternal=(_,E,w)=>{let C,k;if(mt(this._camera)){const L=Z.copy(this._camera.position).sub(this._target),x=this._camera.getEffectiveFOV()*Pt,oe=L.length()*Math.tan(x*.5);C=this.truckSpeed*_*oe/this._elementRect.height,k=this.truckSpeed*E*oe/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),oe=x-L;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(L,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(oe,!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 V>"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 V.Quaternion().setFromUnitVectors(this._camera.up,Xt),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=g.NONE,this._target=new V.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new V.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new V.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 V.Vector3,new V.Vector3,new V.Vector3,new V.Vector3],this._updateNearPlaneCorners(),this._boundary=new V.Box3(new V.Vector3(-1/0,-1/0,-1/0),new V.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 V.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 V.Vector2,s=new V.Vector2,a=new V.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&he.LEFT)===he.LEFT?he.LEFT:(_.buttons&he.MIDDLE)===he.MIDDLE?he.MIDDLE:(_.buttons&he.RIGHT)===he.RIGHT?he.RIGHT:null;if(E!==null){const C=this._findPointerByMouseButton(E);C&&this._disposePointer(C)}if((_.buttons&he.LEFT)===he.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&he.LEFT)===he.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(_.buttons&he.MIDDLE)===he.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(_.buttons&he.RIGHT)===he.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 m=_=>{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,oe=_.clientY/L.height;if(x<this._interactiveArea.left||x>this._interactiveArea.right||oe<this._interactiveArea.top||oe>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=_s?-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===qe.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,De),this._getClientRect(this._elementRect),t.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 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&he.LEFT)===he.LEFT&&(this._state=this._state|this.mouseButtons.left),(_.buttons&he.MIDDLE)===he.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(_.buttons&he.RIGHT)===he.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,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&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=De.x-this._activePointers[1].clientX,L=De.y-this._activePointers[1].clientY,x=Math.sqrt(k*k+L*L),oe=a.y-x;a.set(0,x);const te=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(oe*Kt,te,$e),this._isUserControllingDolly=!0):(this._zoomInternal(oe*Kt,te,$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,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",I),this._domElement.ownerDocument.addEventListener("pointerlockerror",F),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",F),this.cancel()};const I=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},F=()=>{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",m,{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",m,{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",F))},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||ae(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&ae(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=ae(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||ae(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||ae(this._target.x,this._targetEnd.x,this.restThreshold)&&ae(this._target.y,this._targetEnd.y,this.restThreshold)&&ae(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||ae(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(),Ke.setFromMatrixColumn(this._camera.matrix,0),Xe.setFromMatrixColumn(this._camera.matrix,1),Ke.multiplyScalar(e),Xe.multiplyScalar(-n);const s=Z.copy(Ke).add(Xe),a=ie.copy(this._targetEnd).add(s);return this.moveTo(a.x,a.y,a.z,t)}forward(e,n=!1){Z.setFromMatrixColumn(this._camera.matrix,0),Z.crossVectors(this._camera.up,Z),Z.multiplyScalar(e);const t=ie.copy(this._targetEnd).add(Z);return this.moveTo(t.x,t.y,t.z,n)}elevate(e,n=!1){return Z.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+Z.x,this._targetEnd.y+Z.y,this._targetEnd.z+Z.z,n)}moveTo(e,n,t,s=!1){this._isUserControllingTruck=!1;const a=Z.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||ae(this._target.x,this._targetEnd.x,this.restThreshold)&&ae(this._target.y,this._targetEnd.y,this.restThreshold)&&ae(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(o)}lookInDirectionOf(e,n,t,s=!1){const r=Z.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 m=Hi(this._sphericalEnd.theta,Bi),f=Hi(this._sphericalEnd.phi,Bi);h.push(this.rotateTo(m,f,n));const v=Z.setFromSpherical(this._sphericalEnd).normalize(),y=Wi.setFromUnitVectors(v,mi),A=ae(Math.abs(v.y),1);A&&y.multiply(fi.setFromAxisAngle(Xt,m)),y.multiply(this._yAxisUpSpaceInverse);const I=$i.makeEmpty();ie.copy(c.min).applyQuaternion(y),I.expandByPoint(ie),ie.copy(c.min).setX(c.max.x).applyQuaternion(y),I.expandByPoint(ie),ie.copy(c.min).setY(c.max.y).applyQuaternion(y),I.expandByPoint(ie),ie.copy(c.max).setZ(c.min.z).applyQuaternion(y),I.expandByPoint(ie),ie.copy(c.min).setZ(c.max.z).applyQuaternion(y),I.expandByPoint(ie),ie.copy(c.max).setY(c.min.y).applyQuaternion(y),I.expandByPoint(ie),ie.copy(c.max).setX(c.min.x).applyQuaternion(y),I.expandByPoint(ie),ie.copy(c.max).applyQuaternion(y),I.expandByPoint(ie),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 F=I.getSize(Z),_=I.getCenter(ie).applyQuaternion(y);if(mt(this._camera)){const E=this.getDistanceToFitBox(F.x,F.y,F.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/F.x,C/F.y):Math.min(w/F.x,C/F.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?qe.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=ie.set(s,a,o),c=Z.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 m=!r||ae(this._target.x,this._targetEnd.x,this.restThreshold)&&ae(this._target.y,this._targetEnd.y,this.restThreshold)&&ae(this._target.z,this._targetEnd.z,this.restThreshold)&&ae(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&ae(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&ae(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(m)}lerpLookAt(e,n,t,s,a,o,r,h,c,m,f,v,y,A=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ot.NONE,this._changedDolly=0;const I=Z.set(s,a,o),F=ie.set(e,n,t);He.setFromVector3(F.sub(I).applyQuaternion(this._yAxisUpSpace));const _=Tt.set(m,f,v),E=ie.set(r,h,c);Ut.setFromVector3(E.sub(_).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(I.lerp(_,y));const w=Ut.theta-He.theta,C=Ut.phi-He.phi,k=Ut.radius-He.radius;this._sphericalEnd.set(He.radius+k*y,He.phi+C*y,He.theta+w*y),this.normalizeRotations(),this._needsUpdate=!0,A||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const L=!A||ae(this._target.x,this._targetEnd.x,this.restThreshold)&&ae(this._target.y,this._targetEnd.y,this.restThreshold)&&ae(this._target.z,this._targetEnd.z,this.restThreshold)&&ae(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&ae(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&ae(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(Z),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||ae(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&ae(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&ae(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(a)}setOrbitPoint(e,n,t){this._camera.updateMatrixWorld(),Ke.setFromMatrixColumn(this._camera.matrixWorldInverse,0),Xe.setFromMatrixColumn(this._camera.matrixWorldInverse,1),pt.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const s=Z.set(e,n,t),a=s.distanceTo(this._camera.position),o=s.sub(this._camera.position);Ke.multiplyScalar(o.x),Xe.multiplyScalar(o.y),pt.multiplyScalar(o.z),Z.copy(Ke).add(Xe).add(pt),Z.z=Z.z+a,this.dollyTo(a,!1),this.setFocalOffset(-Z.x,Z.y,-Z.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 V.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 V.Vector3).copy(n?this._targetEnd:this._target)}getPosition(e,n=!0){return(e&&e.isVector3?e:new V.Vector3).setFromSpherical(n?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(n?this._targetEnd:this._target)}getSpherical(e,n=!0){return(e||new V.Spherical).copy(n?this._sphericalEnd:this._spherical)}getFocalOffset(e,n=!0){return(e&&e.isVector3?e:new V.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(!ae(this._camera.up.x,this._cameraUp0.x)||!ae(this._camera.up.y,this._cameraUp0.y)||!ae(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const t=this.getPosition(Z);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=Z.subVectors(this._target,this._camera.position).normalize(),n=ie.crossVectors(e,this._camera.up);this._camera.up.crossVectors(n,e).normalize(),this._camera.updateMatrixWorld();const t=this.getPosition(Z);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(de(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(de(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(de(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(de(a.x)&&de(a.y)&&de(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(de(o.x)&&de(o.y)&&de(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(de(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=Z.copy(y).cross(v.up).normalize();A.lengthSq()===0&&(A.x=1);const I=ie.crossVectors(A,y),F=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*F*v.aspect)).add(I.multiplyScalar(this._dollyControlCoord.y*F)),C=Z.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 oe=ie.copy(y).multiplyScalar(-f);C.add(oe)}this._boundary.clampPoint(C,C);const x=ie.subVectors(C,this._targetEnd);this._targetEnd.copy(C),this._target.add(x),this._changedDolly-=f,de(this._changedDolly)&&(this._changedDolly=0)}else if(ot(this._camera)&&this._changedZoom!==0){const f=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),A=ie.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=Z.copy(this._targetEnd).lerp(I,_),k=C.dot(E),L=E.multiplyScalar(k-w);C.sub(L),this._boundary.clampPoint(C,C);const x=ie.subVectors(C,this._targetEnd);this._targetEnd.copy(C),this._target.add(x),this._changedZoom-=f,de(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),(!de(this._focalOffset.x)||!de(this._focalOffset.y)||!de(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),Ke.setFromMatrixColumn(this._camera.matrix,0),Xe.setFromMatrixColumn(this._camera.matrix,1),pt.setFromMatrixColumn(this._camera.matrix,2),Ke.multiplyScalar(this._focalOffset.x),Xe.multiplyScalar(-this._focalOffset.y),pt.multiplyScalar(this._focalOffset.z),Z.copy(Ke).add(Xe).add(pt),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"}),de(n,this.restThreshold)&&de(t,this.restThreshold)&&de(s,this.restThreshold)&&de(a.x,this.restThreshold)&&de(a.y,this.restThreshold)&&de(a.z,this.restThreshold)&&de(o.x,this.restThreshold)&&de(o.y,this.restThreshold)&&de(o.z,this.restThreshold)&&de(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: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: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(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),He.setFromVector3(Z.fromArray(t.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(He.theta,He.phi,n),this.dollyTo(He.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",gs),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=ie.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(ie.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=ie.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 V.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 m=h.attributes.position;for(let f=0,v=m.count;f<v;f++)Z.fromBufferAttribute(m,f),a=Math.max(a,s.distanceToSquared(Z))}),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 u.jsxs("div",{className:`dropdown ${i.up===!0?"up":""}`,children:[u.jsx("div",{className:"dropdown-toggle",onClick:t,children:`${i.title}: ${e}`}),i.open&&u.jsx("ul",{className:"dropdown-menu",children:i.options.map(a=>u.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),[m,f]=T.useState(!1);return u.jsxs("div",{className:"CameraWindow",children:[u.jsx("div",{ref:n,className:"clickable",onClick:()=>{m&&f(!1)}}),u.jsxs("div",{className:"options",children:[u.jsx(ii,{title:"Camera",index:e.options.indexOf(e.camera.name),open:m,options:e.options,onSelect:e.onSelectCamera,onToggle:v=>{f(v)},up:!0}),u.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 vs 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 nn(i){return m.jsx(qi.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
|
111
|
+
}`,name:"InfiniteGrid",depthWrite:!1})}}class ys extends p.Mesh{gridMaterial;constructor(){const e=new vs;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 Es=`#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
|
-
}`,
|
141
|
+
}`,bs=`
|
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 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;
|
149
|
+
}`;class Os extends p.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:Es,fragmentShader:bs})}}let re,_i=!1,K=null,le=null,Le=null,Ie=null,St="Renderer",Jt="Renderer",Ki="Renderer",Xi="Renderer";function un(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 ys,[]),c=T.useMemo(()=>new p.AxesHelper(500),[]),m=T.useMemo(()=>new p.AxesHelper(100),[]),f=T.useMemo(()=>new p.MeshDepthMaterial,[]),v=T.useMemo(()=>new p.MeshNormalMaterial,[]),y=T.useMemo(()=>new Os,[]),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 F=["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,oe=x.getItem(`${e}_mode`),[te,$e]=T.useState(oe!==null?oe:"Single"),[j,ke]=T.useState(null),[ye,Ce]=T.useState(!1),[Te,Ue]=T.useState(!1),[Ve,it]=T.useState("Orbit"),[Je,Qe]=T.useState(!1),[dt,nt]=T.useState(Date.now());x.setItem(`${e}_mode`,te),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 ge=(b,S)=>{const P=t.get(b.name);if(P!==void 0&&P.dispose(),t.delete(b.name),b.name==="UI")return;const N=new ms(b,S);switch(N.enableDamping=!0,N.dampingFactor=.05,b.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":N.enableRotate=!1;break}t.set(b.name,N)},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(te){case"Single":ge(K,w.current);break;case"Side by Side":case"Stacked":ge(K,w.current),ge(le,C.current);break;case"Quad":ge(K,w.current),ge(le,C.current),ge(Le,k.current),ge(Ie,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,ke(b)},[]),T.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,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),K=n.get(x.getItem(`${e}_tlCam`)),le=n.get(x.getItem(`${e}_trCam`)),Le=n.get(x.getItem(`${e}_blCam`)),Ie=n.get(x.getItem(`${e}_brCam`)),K===void 0&&(K=n.get("Debug")),le===void 0&&(le=n.get("Orthographic")),Le===void 0&&(Le=n.get("Front")),Ie===void 0&&(Ie=n.get("Top"))},[]),T.useEffect(()=>{const b=()=>{a.forEach(D=>{r.remove(D),D.dispose()}),a.clear()},S=()=>{re.traverse(D=>{if(D.type.search("Light")>-1){let U;switch(D.type){case"DirectionalLight":U=new p.DirectionalLightHelper(D,100),U.name=`${D.name}Helper`,a.set(D.name,U),r.add(U);break;case"HemisphereLight":U=new p.HemisphereLightHelper(D,250),U.name=`${D.name}Helper`,a.set(D.name,U),r.add(U);break;case"RectAreaLight":U=new hs(D),U.name=`${D.name}Helper`,a.set(D.name,U),r.add(U);break;case"PointLight":U=new p.PointLightHelper(D,100),U.name=`${D.name}Helper`,a.set(D.name,U),r.add(U);break;case"SpotLight":U=new p.SpotLightHelper(D),U.name=`${D.name}Helper`,a.set(D.name,U),r.add(U);break}}})},P=D=>{r.add(c),b(),zt(re),o.remove(re);const U=i.scenes.get(D.value.name);if(U!==void 0){const me=new U;i.onSceneSet!==void 0&&i.onSceneSet(me),re=me,i.three.scene=re,o.add(re),_i=!0,S()}},N=D=>{const U=D.value,me=i.three.scene?.getObjectByProperty("uuid",U.uuid);if(me!==void 0&&n.set(U.name,me),me instanceof p.PerspectiveCamera){const Ee=new p.CameraHelper(me);s.set(me.name,Ee),o.add(Ee)}nt(Date.now())},ue=D=>{const U=s.get(D.value.name);U!==void 0&&(o.remove(U),U.dispose()),n.delete(D.value.name),nt(Date.now())},X=D=>{const U=re.getObjectByProperty("uuid",D.value.uuid);U&&U.add(c)};return z.addEventListener(B.SET_SCENE,P),z.addEventListener(B.ADD_CAMERA,N),z.addEventListener(B.REMOVE_CAMERA,ue),z.addEventListener(B.SET_OBJECT,X),()=>{z.removeEventListener(B.SET_SCENE,P),z.removeEventListener(B.ADD_CAMERA,N),z.removeEventListener(B.REMOVE_CAMERA,ue),z.removeEventListener(B.SET_OBJECT,X)}},[]),T.useEffect(()=>{if(j===null)return;let b=window.innerWidth,S=window.innerHeight,P=Math.floor(b/2),N=Math.floor(S/2),ue=-1;const X=new p.BufferGeometry,D=new p.MeshBasicMaterial,U=new p.Group,me=()=>{b=window.innerWidth-300,S=window.innerHeight,P=Math.floor(b/2),N=Math.floor(S/2),i.three.resize(b,S),i.onSceneResize!==void 0&&_i&&i.onSceneResize(re,b,S);let se=b,_e=S;switch(te){case"Side by Side":se=P,_e=S;break;case"Stacked":se=b,_e=N;break;case"Quad":se=P,_e=N;break}const G=se/_e;n.forEach(H=>{H instanceof p.OrthographicCamera?(H.left=se/-2,H.right=se/2,H.top=_e/2,H.bottom=_e/-2,H.name==="UI"&&(H.position.x=b/2,H.position.y=S/-2,H.position.z=100),H.updateProjectionMatrix()):H instanceof p.PerspectiveCamera&&(H.aspect=G,H.updateProjectionMatrix(),s.get(H.name)?.update())})};function Ee(se){switch(se){case"Depth":return f;case"Normals":return v;case"Renderer":return null;case"UVs":return y;case"Wireframe":return A}return null}const et=()=>{const se=Ee(St);o.overrideMaterial=se,j.setViewport(0,0,b,S),j.setScissor(0,0,b,S),re?.onBeforeRender(j,re,K,X,D,U),j.render(o,K)},Oe=()=>{const se=Ee(St),_e=Ee(Jt);if(o.overrideMaterial=se,te==="Side by Side")j.setViewport(0,0,P,S),j.setScissor(0,0,P,S),re?.onBeforeRender(j,re,K,X,D,U),j.render(o,K),o.overrideMaterial=_e,j.setViewport(P,0,P,S),j.setScissor(P,0,P,S),re?.onBeforeRender(j,re,le,X,D,U),j.render(o,le);else{const G=S-N;j.setViewport(0,G,b,N),j.setScissor(0,G,b,N),re?.onBeforeRender(j,re,K,X,D,U),j.render(o,K),o.overrideMaterial=_e,j.setViewport(0,0,b,N),j.setScissor(0,0,b,N),re?.onBeforeRender(j,re,le,X,D,U),j.render(o,le)}},xe=()=>{const se=Ee(St),_e=Ee(Jt),G=Ee(Ki),H=Ee(Xi);let q=0,Q=0;Q=S-N,q=0,o.overrideMaterial=se,j.setViewport(q,Q,P,N),j.setScissor(q,Q,P,N),re?.onBeforeRender(j,re,K,X,D,U),j.render(o,K),q=P,o.overrideMaterial=_e,j.setViewport(q,Q,P,N),j.setScissor(q,Q,P,N),re?.onBeforeRender(j,re,le,X,D,U),j.render(o,le),Q=0,q=0,o.overrideMaterial=G,j.setViewport(q,Q,P,N),j.setScissor(q,Q,P,N),re?.onBeforeRender(j,re,Le,X,D,U),j.render(o,Le),q=P,o.overrideMaterial=H,j.setViewport(q,Q,P,N),j.setScissor(q,Q,P,N),re?.onBeforeRender(j,re,Ie,X,D,U),j.render(o,Ie)},Ae=()=>{switch(t.forEach(se=>{se.update()}),s.forEach(se=>{se.update()}),a.forEach(se=>{se.update!==void 0&&se.update()}),i.onSceneUpdate!==void 0&&_i&&i.onSceneUpdate(re),j.clear(),te){case"Single":et();break;case"Side by Side":case"Stacked":Oe();break;case"Quad":xe();break}ue=requestAnimationFrame(Ae)};return ht(),window.addEventListener("resize",me),me(),Ae(),()=>{window.removeEventListener("resize",me),cancelAnimationFrame(ue),ue=-1}},[te,j]),T.useEffect(()=>{if(j!==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};qe.install({THREE:b});const S=new p.Raycaster,P=new p.Vector2;let N=K,ue=w,X,D,U=-1;const me=(G,H,q,Q)=>{switch(te){case"Quad":G<q?H<Q?(N=K,S.setFromCamera(P,K)):(N=Le,S.setFromCamera(P,Le)):H<Q?(N=le,S.setFromCamera(P,le)):(N=Ie,S.setFromCamera(P,Ie));break;case"Side by Side":G<q?(N=K,S.setFromCamera(P,K)):(N=le,S.setFromCamera(P,le));break;case"Single":N=K,S.setFromCamera(P,K);break;case"Stacked":H<Q?(N=K,S.setFromCamera(P,K)):(N=le,S.setFromCamera(P,le));break}N===K?ue=w:N===le?ue=C:N===Le?ue=k:N===Ie&&(ue=L)},Ee=G=>{const H=new p.Vector2;j.getSize(H);const q=Math.min(G.clientX,H.x),Q=Math.min(G.clientY,H.y);P.x=bt(q,0,H.x,-1,1),P.y=bt(Q,0,H.y,1,-1);const Pe=H.x/2,Fe=H.y/2,st=()=>{q<Pe?P.x=bt(q,0,Pe,-1,1):P.x=bt(q,Pe,H.x,-1,1)},We=()=>{Q<Fe?P.y=bt(Q,0,Fe,1,-1):P.y=bt(Q,Fe,H.y,1,-1)};switch(te){case"Quad":st(),We();break;case"Side by Side":st();break;case"Stacked":We(),We();break}if(me(q,Q,Pe,Fe),Ve==="Orbit")return;const _t=S.intersectObjects(re.children);_t.length>0&&m.position.copy(_t[0].point)},et=G=>{if(Ve==="Orbit")return;const H=new p.Vector2;if(j.getSize(H),G.clientX>=H.x)return;Ee(G);const q=S.intersectObjects(re.children);q.length>0&&(i.three.getObject(q[0].object.uuid),m.visible=!1,it("Orbit"),nt(Date.now()))},Oe=(G,H=!1)=>{if(X===void 0)return;cancelAnimationFrame(U),U=-1,D&&(D.smoothTime=.1);const q=.15,Q=new p.Clock;Q.start(),X.getWorldPosition(G.target0);const Pe=()=>{const Fe=Q.getDelta();D&&D.update(Fe),H&&(G.target.lerp(G.target0,q),G.object.position.lerp(G.position0,q),G.object.zoom=ei(G.object.zoom,G.zoom0,q),G.object.updateProjectionMatrix(),G.dispatchEvent({type:"change"})),Q.getElapsedTime()>=.5?(cancelAnimationFrame(U),U=-1,xe()):U=requestAnimationFrame(Pe)};Pe()},xe=()=>{D!==void 0&&(D.disconnect(),D.dispose(),D=void 0)},Ae=G=>{if(X!==void 0&&G.ctrlKey){if(N.name==="UI")return;const H=t.get(N.name);G.key==="0"?(xe(),D=new qe(N,ue.current),X instanceof p.Mesh||X instanceof p.SkinnedMesh?(X.geometry.computeBoundingBox(),D.fitToBox(X.geometry.boundingBox,!0)):D.fitToSphere(X,!0),Oe(H,!0)):G.key==="1"?(xe(),D=new qe(N,ue.current),D.rotateTo(0,Math.PI*.5,!0),D.moveTo(X.position.x,X.position.y,0,!0),Oe(H)):G.key==="2"?(xe(),D=new qe(N,ue.current),D.rotateTo(0,0,!0),D.moveTo(X.position.x,0,X.position.z,!0),Oe(H)):G.key==="3"?(xe(),D=new qe(N,ue.current),D.rotateTo(Math.PI/2,Math.PI/2,!0),D.moveTo(0,X.position.y,X.position.z,!0),Oe(H)):G.key==="4"?(xe(),D=new qe(N,ue.current),D.rotateTo(Math.PI,Math.PI/2,!0),D.moveTo(X.position.x,X.position.y,0,!0),Oe(H)):G.key==="5"&&(xe(),D=new qe(N,ue.current),D.rotateTo(zi(45),zi(45),!0),Oe(H))}},se=G=>{X=re.getObjectByProperty("uuid",G.value.uuid)},_e=E.current;return _e.addEventListener("mousemove",Ee,!1),_e.addEventListener("click",et,!1),window.addEventListener("keydown",Ae,!1),z.addEventListener(B.SET_OBJECT,se),()=>{_e.removeEventListener("mousemove",Ee),_e.removeEventListener("click",et),window.removeEventListener("keydown",Ae),z.removeEventListener(B.SET_OBJECT,se)}}},[te,j,Ve]);const Me=[];return n.forEach((b,S)=>{Me.push(S)}),u.jsxs("div",{className:"multiview",children:[u.jsx("canvas",{ref:_}),j!==null&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:`cameras ${te==="Single"||te==="Stacked"?"single":""}`,ref:E,children:[te==="Single"&&u.jsx(u.Fragment,{children:u.jsx(ft,{camera:K,options:Me,ref:w,onSelectCamera:b=>{t.get(K.name)?.dispose();const S=n.get(b);S!==void 0&&(Ye(K),K=S,x.setItem(`${e}_tlCam`,S.name),ge(S,w.current))},onSelectRenderMode:b=>{St=b,x.setItem(`${e}_tlRender`,b)}})}),(te==="Side by Side"||te==="Stacked")&&u.jsxs(u.Fragment,{children:[u.jsx(ft,{camera:K,options:Me,ref:w,onSelectCamera:b=>{t.get(K.name)?.dispose();const S=n.get(b);S!==void 0&&(Ye(K),K=S,x.setItem(`${e}_tlCam`,S.name),ge(S,w.current))},onSelectRenderMode:b=>{St=b,x.setItem(`${e}_tlRender`,b)}}),u.jsx(ft,{camera:le,options:Me,ref:C,onSelectCamera:b=>{t.get(le.name)?.dispose();const S=n.get(b);S!==void 0&&(Ye(le),le=S,x.setItem(`${e}_trCam`,S.name),ge(S,C.current))},onSelectRenderMode:b=>{Jt=b,x.setItem(`${e}_trRender`,b)}})]}),te==="Quad"&&u.jsxs(u.Fragment,{children:[u.jsx(ft,{camera:K,options:Me,ref:w,onSelectCamera:b=>{t.get(K.name)?.dispose();const S=n.get(b);S!==void 0&&(Ye(K),K=S,x.setItem(`${e}_tlCam`,S.name),ge(S,w.current))},onSelectRenderMode:b=>{St=b,x.setItem(`${e}_tlRender`,b)}}),u.jsx(ft,{camera:le,options:Me,ref:C,onSelectCamera:b=>{t.get(le.name)?.dispose();const S=n.get(b);S!==void 0&&(Ye(le),le=S,x.setItem(`${e}_trCam`,S.name),ge(S,C.current))},onSelectRenderMode:b=>{Jt=b,x.setItem(`${e}_trRender`,b)}}),u.jsx(ft,{camera:Le,options:Me,ref:k,onSelectCamera:b=>{t.get(Le.name)?.dispose();const S=n.get(b);S!==void 0&&(Ye(Le),Le=S,x.setItem(`${e}_blCam`,S.name),ge(S,k.current))},onSelectRenderMode:b=>{Ki=b,x.setItem(`${e}_blRender`,b)}}),u.jsx(ft,{camera:Ie,options:Me,ref:L,onSelectCamera:b=>{t.get(Ie.name)?.dispose();const S=n.get(b);S!==void 0&&(Ye(Ie),Ie=S,x.setItem(`${e}_brCam`,S.name),ge(S,L.current))},onSelectRenderMode:b=>{Xi=b,x.setItem(`${e}_brRender`,b)}})]})]}),u.jsxs("div",{className:"settings",children:[u.jsx(ii,{title:"View",index:F.indexOf(te),options:F,onSelect:b=>{b!==te&&(Mt(),$e(b))},open:ye,onToggle:b=>{Ce(b),Te&&Ue(!1),Je&&Qe(!1)}}),u.jsx(ii,{title:"Interact",index:Ve==="Orbit"?0:1,options:["Orbit Mode","Selection Mode"],onSelect:b=>{m.visible=b==="Selection Mode",it(m.visible?"Selection":"Orbit")},open:Je,onToggle:b=>{ye&&Ce(!1),Te&&Ue(!1),Qe(b)}})]},dt)]})]})}function mn(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})]})}function Cs(i){return u.jsx(mn,{children:u.jsxs(u.Fragment,{children:[u.jsx(un,{three:i.three,scenes:i.scenes,onSceneResize:i.onSceneResize,onSceneSet:i.onSceneSet,onSceneUpdate:i.onSceneUpdate}),u.jsx(dn,{three:i.three})]})})}exports.Accordion=Bt;exports.Application=Cn;exports.BaseRemote=Ht;exports.ChildObject=Si;exports.ContainerObject=Ci;exports.Draggable=sn;exports.DraggableItem=nn;exports.Dropdown=an;exports.DropdownItem=rn;exports.Editor=mn;exports.ExportTexture=jt;exports.Inspector=ln;exports.MultiView=un;exports.NavButton=xi;exports.RemoteComponents=Tn;exports.RemoteController=jn;exports.RemoteTheatre=si;exports.RemoteThree=Pn;exports.RemoteTweakpane=Ln;exports.SceneInspector=ds;exports.SidePanel=dn;exports.ThreeEditor=Cs;exports.ToolEvents=B;exports.capitalize=Nt;exports.clamp=ct;exports.colorToHex=yi;exports.customizeTheatreElements=Sn;exports.debugDispatcher=z;exports.defaultTheatreCallback=En;exports.dispose=zt;exports.disposeMaterial=en;exports.disposeTexture=On;exports.distance=bn;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=xn;
|