@tomorrowevening/hermes 0.0.97 → 0.0.98
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/hermes.cjs.js +8 -8
- package/dist/hermes.es.js +269 -270
- package/package.json +1 -1
package/dist/hermes.cjs.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("three"),T=require("react"),qi=require("framer-motion"),Ti=()=>{},gn=()=>{};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 _i(i,e,n){return(n-i)/(e-i)}function ei(i,e,n){return i*(1-n)+e*n}function _n(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 vi(i){const e=Math.round(i.r*255),n=Math.round(i.g*255),t=Math.round(i.b*255),s=d=>{const c=d.toString(16);return c.length===1?"0"+c:c},r=s(e),o=s(n),a=s(t);return"#"+r+o+a}function yi(i,e=1){return Number(i.toFixed(e))}exports.totalThreeObjects=0;const Ei=()=>{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))},vn=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 r=this.canvas.width/s.width,o=this.renderToCanvas(e);this.context.drawImage(o,0,0,s.width*r,s.height*r)}}return e.repeat.copy(n),e.offset.copy(t),this.canvas.toDataURL("image/png")}static renderToCanvas(e){if(this.material===null){this.camera=new f.OrthographicCamera(-.5,.5,.5,-.5,0,100),this.scene=new f.Scene,this.material=new f.MeshBasicMaterial;const n=new f.BufferGeometry;n.setAttribute("position",new f.Float32BufferAttribute([-.5,-.5,0,1.5,-.5,0,-.5,1.5,0],3)),n.setAttribute("normal",new f.Float32BufferAttribute([0,0,1,0,0,1],3)),n.setAttribute("uv",new f.Float32BufferAttribute([0,0,2,0,0,2],2));const t=new f.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=f.LinearSRGBColorSpace,e.colorSpace=f.LinearSRGBColorSpace,this.material.map=e,this.renderer.render(this.scene,this.camera),this.renderer.outputColorSpace=n,e.colorSpace=t}return this.renderer.domElement}}class yn{components=new Map;listen;_appID="";_debugEnabled;_broadcastChannel=void 0;_webSocket=void 0;_mode="app";_connected=!1;_useBC=!1;constructor(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 f.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 ni{app;constructor(e){this.app=e}dispose(){}handleApp(e,n,t){}handleEditor(e,n,t){}}class En extends ni{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 Bt extends ni{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){return new Promise(s=>{this.app.send({event:"playSheet",target:"editor",data:{sheet:e,instance:t,value:n}});const r={...n};r.rafDriver=Bt.rafDriver,this.sheet(e,t)?.sequence.play(r).then(o=>s(o))})}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,r){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const o=this.sheet(e,r);if(o===void 0)return;const d=`${this.getSheetInstance(e,r)}_${n}`;let c=this.sheetObjects.get(d);c!==void 0?c=o.object(n,{...t,...c.value},{reconfigure:!0}):c=o.object(n,t),this.sheetObjects.set(d,c),this.sheetObjectCBs.set(d,s!==void 0?s:Ti);const u=c.onValuesChange(p=>{if(this.app.editor){for(const y in p){const A=p[y];typeof A=="object"&&Qi(A)&&(p[y]={r:A.r,g:A.g,b:A.b,a:A.a})}this.app.send({event:"updateSheetObject",target:"app",data:{sheet:e,sheetObject:d,values:p}})}const _=this.sheetObjectCBs.get(d);_!==void 0&&_(p)});return this.sheetObjectUnsubscribe.set(d,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 r=`${n}_${t}`,o=this.sheetObjectUnsubscribe.get(r);o!==void 0&&(this.sheetObjects.delete(r),this.sheetObjectCBs.delete(r),this.sheetObjectUnsubscribe.delete(r),o())}handleApp(e,n,t){const s=n;let r;switch(t.event){case"setSheet":r=s.sheets.get(t.data.sheet),r!==void 0&&(s.activeSheet=r,this.studio?.setSelection([r]));break;case"setSheetObject":r=s.sheetObjects.get(`${t.data.sheet}_${t.data.key}`),r!==void 0&&this.studio?.setSelection([r]);break;case"updateSheetObject":r=s.sheets.get(t.data.sheet),r!==void 0&&r.sequence.pause(),r=s.sheetObjectCBs.get(t.data.sheetObject),r!==void 0&&r(t.data.values);break;case"updateTimeline":r=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(a=>{let d=a.address.sheetId,c="setSheet",u={};switch(a.type){case"Theatre_Sheet_PublicAPI":c="setSheet",u={sheet:a.address.sheetId},n.activeSheet=n.sheets.get(a.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":c="setSheetObject",d+=`_${a.address.objectKey}`,u={id:d,sheet:a.address.sheetId,key:a.address.objectKey},n.activeSheet=n.sheets.get(a.address.sheetId);break}e.send({event:c,target:"app",data:u})})});let t=-1;const s=()=>{if(Bt.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}})}},r=()=>{s(),requestAnimationFrame(r)};s(),r()}else this.studio?.ui.hide()}}function On(i,e,n){if(i.editor){n.ui.restore(),n.onSelectionChange(o=>{o.length<1||o.forEach(a=>{let d=a.address.sheetId,c="setSheet",u={};switch(a.type){case"Theatre_Sheet_PublicAPI":c="setSheet",u={sheet:a.address.sheetId},e.activeSheet=e.sheets.get(a.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":c="setSheetObject",d+=`_${a.address.objectKey}`,u={id:d,sheet:a.address.sheetId,key:a.address.objectKey},e.activeSheet=e.sheets.get(a.address.sheetId);break}i.send({event:c,target:"app",data:u})})});let t=-1;const s=()=>{if(Bt.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}})}},r=()=>{s(),requestAnimationFrame(r)};s(),r()}else n.ui.hide()}function bn(){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 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 i.anisotropy!==void 0&&(e.anisotropy=i.anisotropy),i.clearcoat!==void 0&&(e.clearcoat=i.clearcoat),i.iridescence!==void 0&&(e.iridescence=i.iridescence),i.dispersion!==void 0&&(e.dispersion=i.dispersion),i.sheen!==void 0&&(e.sheen=i.sheen),i.transmission!==void 0&&(e.transmission=i.transmission),i.transmission!==void 0&&(e.transmission=i.transmission),e}function oi(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(r=>{s.push(Et(r))}),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(r=>{s.push(Et(r))}),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(r=>{s.push(Et(r))}),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 pe(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 f.Texture(t);s.wrapS=f.RepeatWrapping,s.wrapT=f.RepeatWrapping,s.needsUpdate=!0,e(s)},t.onerror=n,t.src=i})}class Mn extends ni{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=oi(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;Ei(),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),Ei(),ti(e);const n=wt(e);this.app.send({event:"setScene",target:"editor",data:n})}addCamera(e){if(!this.app.debugEnabled)return;const n=oi(e);this.app.send({event:"addCamera",target:"editor",data:n})}removeCamera(e){if(!this.app.debugEnabled)return;const n=oi(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 r=JSON.parse(t.data);s.groups.get(r.group)?.onUpdate(r.prop,r.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 f.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}}var Oi={exports:{}},Rt={};/**
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("three"),T=require("react"),qi=require("framer-motion"),Ci=()=>{},gn=()=>{};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 gi(i,e,n){return(n-i)/(e-i)}function Qt(i,e,n){return i*(1-n)+e*n}function _n(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 _i(i){const e=Math.round(i.r*255),n=Math.round(i.g*255),t=Math.round(i.b*255),s=d=>{const c=d.toString(16);return c.length===1?"0"+c:c},r=s(e),o=s(n),a=s(t);return"#"+r+o+a}function vi(i,e=1){return Number(i.toFixed(e))}exports.totalThreeObjects=0;const yi=()=>{exports.totalThreeObjects=0},ei=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=>ei(n))},vn=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 r=this.canvas.width/s.width,o=this.renderToCanvas(e);this.context.drawImage(o,0,0,s.width*r,s.height*r)}}return e.repeat.copy(n),e.offset.copy(t),this.canvas.toDataURL("image/png")}static renderToCanvas(e){if(this.material===null){this.camera=new f.OrthographicCamera(-.5,.5,.5,-.5,0,100),this.scene=new f.Scene,this.material=new f.MeshBasicMaterial;const n=new f.BufferGeometry;n.setAttribute("position",new f.Float32BufferAttribute([-.5,-.5,0,1.5,-.5,0,-.5,1.5,0],3)),n.setAttribute("normal",new f.Float32BufferAttribute([0,0,1,0,0,1],3)),n.setAttribute("uv",new f.Float32BufferAttribute([0,0,2,0,0,2],2));const t=new f.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=f.LinearSRGBColorSpace,e.colorSpace=f.LinearSRGBColorSpace,this.material.map=e,this.renderer.render(this.scene,this.camera),this.renderer.outputColorSpace=n,e.colorSpace=t}return this.renderer.domElement}}class yn{components=new Map;listen;_appID="";_debugEnabled;_broadcastChannel=void 0;_webSocket=void 0;_mode="app";_connected=!1;_useBC=!1;constructor(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 f.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 ii{app;constructor(e){this.app=e}dispose(){}handleApp(e,n,t){}handleEditor(e,n,t){}}class En extends ii{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}}}function On(i,e,n){if(i.editor){n.ui.restore(),n.onSelectionChange(o=>{o.length<1||o.forEach(a=>{let d=a.address.sheetId,c="setSheet",u={};switch(a.type){case"Theatre_Sheet_PublicAPI":c="setSheet",u={sheet:a.address.sheetId},e.activeSheet=e.sheets.get(a.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":c="setSheetObject",d+=`_${a.address.objectKey}`,u={id:d,sheet:a.address.sheetId,key:a.address.objectKey},e.activeSheet=e.sheets.get(a.address.sheetId);break}i.send({event:c,target:"app",data:u})})});let t=-1;const s=()=>{if(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}})}},r=()=>{s(),requestAnimationFrame(r)};s(),r()}else n.ui.hide()}function bn(){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"}class Ti extends ii{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){return this.app.send({event:"playSheet",target:"editor",data:{sheet:e,instance:t,value:n}}),new Promise(s=>{const r=n!==void 0?{...n}:{};r.rafDriver=Ti.rafDriver,this.sheet(e,t)?.sequence.play(r).then(o=>s(o))})}pauseSheet(e,n){this.sheet(e,n)?.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,r){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const o=this.sheet(e,r);if(o===void 0)return;const d=`${this.getSheetInstance(e,r)}_${n}`;let c=this.sheetObjects.get(d);c!==void 0?c=o.object(n,{...t,...c.value},{reconfigure:!0}):c=o.object(n,t),this.sheetObjects.set(d,c),this.sheetObjectCBs.set(d,s!==void 0?s:Ci);const u=c.onValuesChange(p=>{if(this.app.editor){for(const y in p){const A=p[y];typeof A=="object"&&Qi(A)&&(p[y]={r:A.r,g:A.g,b:A.b,a:A.a})}this.app.send({event:"updateSheetObject",target:"app",data:{sheet:e,sheetObject:d,values:p}})}const _=this.sheetObjectCBs.get(d);_!==void 0&&_(p)});return this.sheetObjectUnsubscribe.set(d,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 r=`${n}_${t}`,o=this.sheetObjectUnsubscribe.get(r);o!==void 0&&(this.sheetObjects.delete(r),this.sheetObjectCBs.delete(r),this.sheetObjectUnsubscribe.delete(r),o())}handleApp(e,n,t){const s=n;let r;switch(t.event){case"setSheet":r=s.sheets.get(t.data.sheet),r!==void 0&&(s.activeSheet=r,this.studio?.setSelection([r]));break;case"setSheetObject":r=s.sheetObjects.get(`${t.data.sheet}_${t.data.key}`),r!==void 0&&this.studio?.setSelection([r]);break;case"updateSheetObject":r=s.sheets.get(t.data.sheet),r!==void 0&&r.sequence.pause(),r=s.sheetObjectCBs.get(t.data.sheetObject),r!==void 0&&r(t.data.values);break;case"updateTimeline":r=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(a=>{let d=a.address.sheetId,c="setSheet",u={};switch(a.type){case"Theatre_Sheet_PublicAPI":c="setSheet",u={sheet:a.address.sheetId},n.activeSheet=n.sheets.get(a.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":c="setSheetObject",d+=`_${a.address.objectKey}`,u={id:d,sheet:a.address.sheetId,key:a.address.objectKey},n.activeSheet=n.sheets.get(a.address.sheetId);break}e.send({event:c,target:"app",data:u})})});let t=-1;const s=()=>{if(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}})}},r=()=>{s(),requestAnimationFrame(r)};s(),r()}else this.studio?.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 i.anisotropy!==void 0&&(e.anisotropy=i.anisotropy),i.clearcoat!==void 0&&(e.clearcoat=i.clearcoat),i.iridescence!==void 0&&(e.iridescence=i.iridescence),i.dispersion!==void 0&&(e.dispersion=i.dispersion),i.sheen!==void 0&&(e.sheen=i.sheen),i.transmission!==void 0&&(e.transmission=i.transmission),i.transmission!==void 0&&(e.transmission=i.transmission),e}function ai(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(r=>{s.push(Et(r))}),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(r=>{s.push(Et(r))}),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(r=>{s.push(Et(r))}),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 pe(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 f.Texture(t);s.wrapS=f.RepeatWrapping,s.wrapT=f.RepeatWrapping,s.needsUpdate=!0,e(s)},t.onerror=n,t.src=i})}class Mn extends ii{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=ai(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;yi(),ei(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),yi(),ei(e);const n=wt(e);this.app.send({event:"setScene",target:"editor",data:n})}addCamera(e){if(!this.app.debugEnabled)return;const n=ai(e);this.app.send({event:"addCamera",target:"editor",data:n})}removeCamera(e){if(!this.app.debugEnabled)return;const n=ai(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 r=JSON.parse(t.data);s.groups.get(r.group)?.onUpdate(r.prop,r.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 f.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}}var Ei={exports:{}},Rt={};/**
|
2
2
|
* @license React
|
3
3
|
* react-jsx-runtime.production.min.js
|
4
4
|
*
|
@@ -18,21 +18,21 @@
|
|
18
18
|
`+Me+l}}var S=!1,P;{var N=typeof WeakMap=="function"?WeakMap:Map;P=new N}function ue(l,b){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=dt.current,dt.current=null,Ye();try{if(b){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
19
|
`),we=Y.stack.split(`
|
20
20
|
`),fe=W.length-1,ve=we.length-1;fe>=1&&ve>=0&&W[fe]!==we[ve];)ve--;for(;fe>=1&&ve>=0;fe--,ve--)if(W[fe]!==we[ve]){if(fe!==1||ve!==1)do if(fe--,ve--,ve<0||W[fe]!==we[ve]){var Be=`
|
21
|
-
`+W[fe].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(fe>=1&&ve>=0);break}}}finally{S=!1,dt.current=ce,Mt(),Error.prepareStackTrace=ne}var yt=l?l.displayName||l.name:"",Ri=yt?O(yt):"";return typeof l=="function"&&P.set(l,Ri),Ri}function X(l,b,M){return ue(l,!1)}function D(l){var b=l.prototype;return!!(b&&b.isReactComponent)}function k(l,b,M){if(l==null)return"";if(typeof l=="function")return ue(l,D(l));if(typeof l=="string")return O(l);switch(l){case c:return O("Suspense");case u:return O("SuspenseList")}if(typeof l=="object")switch(l.$$typeof){case d:return X(l.render);case p:return k(l.type,b,M);case _:{var Y=l,ne=Y._payload,ce=Y._init;try{return k(ce(ne),b,M)}catch{}}}return""}var me=Object.prototype.hasOwnProperty,Ee={},et=v.ReactDebugCurrentFrame;function be(l){if(l){var b=l._owner,M=k(l.type,l._source,b?b.type:null);et.setExtraStackFrame(M)}else et.setExtraStackFrame(null)}function xe(l,b,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](b,J,Y,M,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(fe){W=fe}W&&!(W instanceof Error)&&(be(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),be(null)),W instanceof Error&&!(W.message in Ee)&&(Ee[W.message]=!0,be(ne),E("Failed %s type: %s",M,W.message),be(null))}}}var Ae=Array.isArray;function se(l){return Ae(l)}function _e(l){{var b=typeof Symbol=="function"&&Symbol.toStringTag,M=b&&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=v.ReactCurrentOwner,Pe={key:!0,ref:!0,__self:!0,__source:!0},Fe,st,We;We={};function _t(l){if(me.call(l,"ref")){var b=Object.getOwnPropertyDescriptor(l,"ref").get;if(b&&b.isReactWarning)return!1}return l.ref!==void 0}function
|
21
|
+
`+W[fe].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(fe>=1&&ve>=0);break}}}finally{S=!1,dt.current=ce,Mt(),Error.prepareStackTrace=ne}var yt=l?l.displayName||l.name:"",Ri=yt?O(yt):"";return typeof l=="function"&&P.set(l,Ri),Ri}function X(l,b,M){return ue(l,!1)}function D(l){var b=l.prototype;return!!(b&&b.isReactComponent)}function k(l,b,M){if(l==null)return"";if(typeof l=="function")return ue(l,D(l));if(typeof l=="string")return O(l);switch(l){case c:return O("Suspense");case u:return O("SuspenseList")}if(typeof l=="object")switch(l.$$typeof){case d:return X(l.render);case p:return k(l.type,b,M);case _:{var Y=l,ne=Y._payload,ce=Y._init;try{return k(ce(ne),b,M)}catch{}}}return""}var me=Object.prototype.hasOwnProperty,Ee={},et=v.ReactDebugCurrentFrame;function be(l){if(l){var b=l._owner,M=k(l.type,l._source,b?b.type:null);et.setExtraStackFrame(M)}else et.setExtraStackFrame(null)}function xe(l,b,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](b,J,Y,M,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(fe){W=fe}W&&!(W instanceof Error)&&(be(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),be(null)),W instanceof Error&&!(W.message in Ee)&&(Ee[W.message]=!0,be(ne),E("Failed %s type: %s",M,W.message),be(null))}}}var Ae=Array.isArray;function se(l){return Ae(l)}function _e(l){{var b=typeof Symbol=="function"&&Symbol.toStringTag,M=b&&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=v.ReactCurrentOwner,Pe={key:!0,ref:!0,__self:!0,__source:!0},Fe,st,We;We={};function _t(l){if(me.call(l,"ref")){var b=Object.getOwnPropertyDescriptor(l,"ref").get;if(b&&b.isReactWarning)return!1}return l.ref!==void 0}function si(l){if(me.call(l,"key")){var b=Object.getOwnPropertyDescriptor(l,"key").get;if(b&&b.isReactWarning)return!1}return l.key!==void 0}function ri(l,b){if(typeof l.ref=="string"&&Q.current&&b&&Q.current.stateNode!==b){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 Ht(l,b){{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)",b))};M.isReactWarning=!0,Object.defineProperty(l,"key",{get:M,configurable:!0})}}function rt(l,b){{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)",b))};M.isReactWarning=!0,Object.defineProperty(l,"ref",{get:M,configurable:!0})}}var wi=function(l,b,M,Y,ne,ce,J){var W={$$typeof:e,type:l,key:b,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 h(l,b,M,Y,ne){{var ce,J={},W=null,we=null;M!==void 0&&(q(M),W=""+M),si(b)&&(q(b.key),W=""+b.key),_t(b)&&(we=b.ref,ri(b,ne));for(ce in b)me.call(b,ce)&&!Pe.hasOwnProperty(ce)&&(J[ce]=b[ce]);if(l&&l.defaultProps){var fe=l.defaultProps;for(ce in fe)J[ce]===void 0&&(J[ce]=fe[ce])}if(W||we){var ve=typeof l=="function"?l.displayName||l.name||"Unknown":l;W&&Ht(J,ve),we&&rt(J,ve)}return wi(l,W,we,ne,Y,Q.current,J)}}var R=v.ReactCurrentOwner,$=v.ReactDebugCurrentFrame;function ee(l){if(l){var b=l._owner,M=k(l.type,l._source,b?b.type:null);$.setExtraStackFrame(M)}else $.setExtraStackFrame(null)}var Oe;Oe=!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 b=l.fileName.replace(/^.*[\\\/]/,""),M=l.lineNumber;return`
|
24
24
|
|
25
|
-
Check your code at `+b+":"+M+"."}return""}}var
|
25
|
+
Check your code at `+b+":"+M+"."}return""}}var Vt={};function Yt(l){{var b=Se();if(!b){var M=typeof l=="string"?l:l.displayName||l.name;M&&(b=`
|
26
26
|
|
27
|
-
Check the top-level render call using <`+M+">.")}return b}}function Ne(l,b){{if(!l._store||l._store.validated||l.key!=null)return;l._store.validated=!0;var M=
|
27
|
+
Check the top-level render call using <`+M+">.")}return b}}function Ne(l,b){{if(!l._store||l._store.validated||l.key!=null)return;l._store.validated=!0;var M=Yt(b);if(Vt[M])return;Vt[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,b){{if(typeof l!="object")return;if(se(l))for(var M=0;M<l.length;M++){var Y=l[M];je(Y)&&Ne(Y,b)}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,b)}}}function ut(l){{var b=l.type;if(b==null||typeof b=="string")return;var M;if(typeof b=="function")M=b.propTypes;else if(typeof b=="object"&&(b.$$typeof===d||b.$$typeof===p))M=b.propTypes;else return;if(M){var Y=ye(b);xe(M,l.props,"prop",Y,l)}else if(b.PropTypes!==void 0&&!Oe){Oe=!0;var ne=ye(b);E("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ne||"Unknown")}typeof b.getDefaultProps=="function"&&!b.getDefaultProps.isReactClassApproved&&E("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ge(l){{for(var b=Object.keys(l.props),M=0;M<b.length;M++){var Y=b[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 at(l,b,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 fe;l===null?fe="null":se(l)?fe="array":l!==void 0&&l.$$typeof===e?(fe="<"+(ye(l.type)||"Unknown")+" />",W=" Did you accidentally export a JSX literal instead of a component?"):fe=typeof l,E("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",fe,W)}var ve=h(l,b,M,ne,ce);if(ve==null)return ve;if(J){var Be=b.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,b,M){return at(l,b,M,!0)}function Gt(l,b,M){return at(l,b,M,!1)}var fn=Gt,pn=vt;Dt.Fragment=t,Dt.jsx=fn,Dt.jsxs=pn}()),Dt}process.env.NODE_ENV==="production"?Ei.exports=Rn():Ei.exports=Dn();var m=Ei.exports;function xi(i){return i.title.search("<")>-1?m.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:i.title}}):m.jsx("button",{children:i.title})}const An=m.jsxs("svg",{className:"closeIcon",width:"14",height:"14",fill:"none",stroke:"#666666",strokeMiterlimit:"10",children:[m.jsx("circle",{cx:"7",cy:"7",r:"6"}),m.jsx("line",{x1:"4",y1:"4",x2:"10",y2:"10"}),m.jsx("line",{x1:"4",y1:"10",x2:"10",y2:"4"})]}),Pn=m.jsx("svg",{className:"dragIcon",width:"14",height:"14",fill:"#666666",stroke:"none",children:m.jsx("path",{d:`M10.43,4H3.57C3.26,4,3,4.22,3,4.5v1C3,5.78,3.26,6,3.57,6h6.86C10.74,6,11,5.78,11,5.5v-1
|
28
28
|
C11,4.22,10.74,4,10.43,4z M10.43,8H3.57C3.26,8,3,8.22,3,8.5v1C3,9.78,3.26,10,3.57,10h6.86C10.74,10,11,9.78,11,9.5v-1
|
29
|
-
C11,8.22,10.74,8,10.43,8z`})});function nn(i){return m.jsx(qi.Reorder.Item,{value:i.title,children:m.jsxs("div",{children:[Pn,m.jsx("span",{children:i.title}),m.jsx("button",{className:"closeIcon",onClick:()=>{i.onDelete(i.index)},children:An})]})},i.title)}function sn(i){const[e,n]=T.useState(!1),[t,s]=T.useState(i.options),r=c=>{i.onDragComplete(c),s(c)},o=c=>{const u=[...t];u.splice(c,1),r(u)},a=[];t.forEach((c,u)=>{a.push(m.jsx(nn,{index:u,title:c,onDelete:o},c))});let d="dropdown draggable";return i.subdropdown&&(d+=" subdropdown"),m.jsxs("div",{className:d,onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[m.jsx(xi,{title:i.title}),m.jsx(qi.Reorder.Group,{axis:"y",values:t,onReorder:r,style:{visibility:e?"visible":"hidden"},children:a})]})}function rn(i){const[e,n]=T.useState(!1),t=[];i.options.map((r,o)=>{i.onSelect!==void 0&&(r.onSelect=i.onSelect),t.push(m.jsx(an,{option:r},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 an(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:r=>{e.onDragComplete!==void 0&&e.onDragComplete(r)},subdropdown:!0});break;case"dropdown":s=m.jsx(rn,{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 Ln(i,e,n){function t(r){switch(e.forEach(o=>{o.callback(i,o.remote,r)}),r.event){case"custom":z.dispatchEvent({type:B.CUSTOM,value:r.data});break}}function s(r){switch(n.forEach(o=>{o.callback(i,o.remote,r)}),r.event){case"custom":z.dispatchEvent({type:B.CUSTOM,value:r.data});break}}i.listen=r=>{r.target==="editor"?s(r):t(r)}}function Ht(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 m.jsxs("div",{className:`accordion ${t?"hide":""}`,children:[m.jsxs("button",{className:"toggle",onClick:()=>{const r=!e;i.onToggle!==void 0&&i.onToggle(r),n(r)},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,r=[];return i.child!==void 0&&i.child.children.length>0&&i.child.children.map((o,a)=>{r.push(m.jsx(Si,{child:o,three:i.three},a))}),T.useEffect(()=>{if(i.child){const o=i.three.getScene(i.child.uuid);if(o!==null){const a=o.getObjectByProperty("uuid",i.child.uuid);a!==void 0&&(e.current.style.opacity=a.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 a=o.getObjectByProperty("uuid",i.child.uuid);if(a!==void 0){const d="visible",c=!a.visible;e.current.style.opacity=c?"1":"0.25",i.three.updateObject(i.child.uuid,d,c),pe(a,d,c)}}}}}),m.jsx("div",{className:`icon ${Cn(i.child)}`})]}),m.jsx("div",{className:n?"open":"",children:m.jsx("div",{className:"container",children:r})})]},Math.random())})}function bi(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 In(i){const[e,n]=T.useState(i.defaultValue);return T.useEffect(()=>{let t=!1,s=-1,r=0,o=i.defaultValue;const a=_=>{t=!0,r=Number(i.input.current?.value),s=_.clientX,document.addEventListener("mouseup",c,!1),document.addEventListener("mousemove",d,!1),document.addEventListener("contextmenu",c,!1)},d=_=>{if(!t)return;const y=i.step!==void 0?i.step:1,A=(_.clientX-s)*y;o=Number((r+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",d),document.removeEventListener("contextmenu",c)},u=_=>{const y=Number(_.target.value);n(y)},p=_=>{const y=Number(_.target.value);i.onChange!==void 0&&i.onChange(y),n(y)};return i.input.current?.addEventListener("input",u),i.label.current?.addEventListener("mousedown",a,!1),i.sliderRef!==void 0&&i.sliderRef.current?.addEventListener("input",p),()=>{i.input.current?.removeEventListener("input",u),i.label.current?.removeEventListener("mousedown",a),i.sliderRef!==void 0&&i.sliderRef.current?.removeEventListener("input",p),document.removeEventListener("mouseup",c),document.removeEventListener("mousemove",d),document.removeEventListener("contextmenu",c)}},[]),e}function gt(i){const e=T.useRef(null),n=T.useRef(null),t=In({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 r=Number(s.target.value);i.onChange!==void 0&&i.onChange(i.prop,r)}}),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 r=Number(s.target.value);i.onChange!==void 0&&i.onChange(i.prop,r)}}),m.jsx("input",{disabled:i.disabled,type:"range",value:t,min:i.min,max:i.max,step:i.step,ref:n,onChange:Ti})]})]})}function Un(i){const e=T.useRef(null),n=T.useRef(null),t=T.useRef(null),s=T.useRef(null),r=T.useRef(null),o=T.useRef(null),[a,d]=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))}),[p,_]=T.useState(!1);function y(){p||(window.addEventListener("mousemove",I),window.addEventListener("mouseup",A),window.addEventListener("mouseup",A),_(!0))}function A(){window.removeEventListener("mousemove",I),window.removeEventListener("mouseup",A),_(!1)}function I(C){const U=r.current.getBoundingClientRect(),L=ct(0,99,C.clientX-U.left)/99,x=ct(0,99,C.clientY-U.top)/99,oe=yi(ei(c.min,c.max,L),3),te=yi(ei(c.min,c.max,x),3);i.onChange({target:{value:{x:oe,y:te}}}),d({x:oe,y:te})}function F(C){let U=a.x,L=a.y;C.target===e.current?U=Number(C.target.value):L=Number(C.target.value),d({x:U,y:L})}function v(){const C=Number(t.current.value);u({min:C,max:c.max}),(a.x<C||a.y<C)&&d({x:ct(C,c.max,a.x),y:ct(C,c.max,a.y)})}function E(){const C=Number(s.current.value);u({min:c.min,max:C}),(a.x>C||a.y>C)&&d({x:ct(c.min,C,a.x),y:ct(c.min,C,a.y)})}T.useEffect(()=>{const C=_i(c.min,c.max,a.x),U=_i(c.min,c.max,a.y);o.current.style.left=`${C*100}%`,o.current.style.top=`${U*100}%`},[c,a]);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:a.x,min:c.min,max:c.max,step:w,onChange:F})]}),m.jsxs("div",{children:[m.jsx("label",{children:"Y:"}),m.jsx("input",{ref:n,type:"number",value:a.y,min:c.min,max:c.max,step:w,onChange:F})]}),m.jsxs("div",{children:[m.jsx("label",{children:"Min:"}),m.jsx("input",{ref:t,type:"number",value:c.min,step:w,onChange:v})]}),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:r,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.x!==void 0&&i.value.y!==void 0&&i.value.z!==void 0,n=i.value.isEuler!==void 0,t=i.value.elements!==void 0,s=i.step!==void 0?i.step:.01,r=[];if(e){const o=T.useMemo(()=>i.value,[]),a=(c,u)=>{o[c]=u,i.onChange({target:{value:o}})};["x","y","z"].forEach(c=>{const u=T.useRef(null);r.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:a})]},c))})}else if(n){const o=T.useMemo(()=>i.value,[]),a=(c,u)=>{o[c]=u,i.onChange({target:{value:o}})};["_x","_y","_z"].forEach(c=>{const u=T.useRef(null);r.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:a})]},c))})}else if(t){const o=T.useMemo(()=>i.value,[]),a=(d,c)=>{const u=Number(d);o.elements[u]=c,i.onChange({target:{value:o}})};for(let d=0;d<9;d++){const c=T.useRef(null);r.push(m.jsxs("div",{children:[m.jsx("label",{ref:c,children:d+1}),m.jsx(gt,{value:o.elements[d],type:"number",prop:d.toString(),step:s,labelRef:c,onChange:a})]},d.toString()))}}return m.jsx("div",{className:"grid3",children:r},Math.random().toString())}function kn(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,[]),r=(a,d)=>{s[a]=d,i.onChange({target:{value:s}})};["x","y","z","w"].forEach(a=>{const d=T.useRef(null);t.push(m.jsxs("div",{children:[m.jsx("label",{ref:d,children:a.toUpperCase()}),m.jsx(gt,{value:s.x,type:"number",prop:a,step:n,labelRef:d,onChange:r})]},a))})}else{const s=T.useMemo(()=>i.value,[]),r=(o,a)=>{const d=Number(o);s.elements[d]=a,i.onChange({target:{value:s}})};for(let o=0;o<16;o++){const a=T.useRef(null);t.push(m.jsxs("div",{children:[m.jsx("label",{ref:a,children:o+1}),m.jsx(gt,{value:s.elements[o],type:"number",prop:o.toString(),step:n,labelRef:a,onChange:r})]},o.toString()))}}return m.jsx("div",{className:"grid4",children:t})}function Fn(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 jn(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 si(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"}function Nn(){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(r){e(r.target.result)},s.readAsDataURL(t)}}),i.click()})}const zn=[{title:"Front",value:f.FrontSide},{title:"Back",value:f.BackSide},{title:"Double",value:f.DoubleSide}],Bn=[{title:"No Blending",value:f.NoBlending},{title:"Normal",value:f.NormalBlending},{title:"Additive",value:f.AdditiveBlending},{title:"Subtractive",value:f.SubtractiveBlending},{title:"Multiply",value:f.MultiplyBlending},{title:"Custom",value:f.CustomBlending}],Hn=[{title:"Add",value:f.AddEquation},{title:"Subtract",value:f.SubtractEquation},{title:"Reverse Subtract",value:f.ReverseSubtractEquation},{title:"Min",value:f.MinEquation},{title:"Max",value:f.MaxEquation}],Vn=[{title:"Zero",value:f.ZeroFactor},{title:"One",value:f.OneFactor},{title:"Src Color",value:f.SrcColorFactor},{title:"One Minus Src Color",value:f.OneMinusSrcColorFactor},{title:"Src Alpha",value:f.SrcAlphaFactor},{title:"One Minus Src Alpha",value:f.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:f.DstAlphaFactor},{title:"One Minus Dst Alpha",value:f.OneMinusDstAlphaFactor},{title:"Dst Color",value:f.DstColorFactor},{title:"One Minus Dst Color",value:f.OneMinusDstColorFactor},{title:"Src Alpha Saturate",value:f.SrcAlphaSaturateFactor},{title:"Constant Color",value:f.ConstantColorFactor},{title:"One Minus Constant Color",value:f.OneMinusConstantColorFactor},{title:"Constant Alpha",value:f.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:f.OneMinusConstantAlphaFactor}],Yn=[{title:"Zero",value:f.ZeroFactor},{title:"One",value:f.OneFactor},{title:"Src Color",value:f.SrcColorFactor},{title:"One Minus Src Color",value:f.OneMinusSrcColorFactor},{title:"Src Alpha",value:f.SrcAlphaFactor},{title:"One Minus Src Alpha",value:f.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:f.DstAlphaFactor},{title:"One Minus Dst Alpha",value:f.OneMinusDstAlphaFactor},{title:"Dst Color",value:f.DstColorFactor},{title:"One Minus Dst Color",value:f.OneMinusDstColorFactor},{title:"Constant Color",value:f.ConstantColorFactor},{title:"One Minus Constant Color",value:f.OneMinusConstantColorFactor},{title:"Constant Alpha",value:f.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:f.OneMinusConstantAlphaFactor}];function At(i,e){i.needsUpdate=!0,i.type="option",i.options=e}function Gn(i,e,n,t){return{type:"boolean",title:si(i),prop:i,value:e,needsUpdate:!0,onChange:(s,r)=>{t.updateObject(n.uuid,`material.${i}`,r),t.updateObject(n.uuid,"material.needsUpdate",!0);const o=t.getScene(n.uuid);if(o!==null){const a=o.getObjectByProperty("uuid",n.uuid);pe(a,`material.${i}`,r)}}}}function Zn(i,e,n,t){const s={type:"number",title:si(i),prop:i,value:e,min:void 0,max:void 0,step:.01,needsUpdate:!0,onChange:(r,o)=>{t.updateObject(n.uuid,`material.${i}`,o),t.updateObject(n.uuid,"material.needsUpdate",!0);const a=t.getScene(n.uuid);if(a!==null){const d=a.getObjectByProperty("uuid",n.uuid);pe(d,`material.${i}`,o)}}};switch(i){case"blending":At(s,Bn);break;case"blendDst":At(s,Yn);break;case"blendEquation":At(s,Hn);break;case"blendSrc":At(s,Vn);break;case"side":At(s,zn);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 $n(i,e,n,t){const s={type:"string",title:si(i),prop:i,value:e,needsUpdate:!0,onChange:(o,a)=>{t.updateObject(n.uuid,`material.${i}`,a),t.updateObject(n.uuid,"material.needsUpdate",!0);const d=t.getScene(n.uuid);if(d!==null){const c=d.getObjectByProperty("uuid",n.uuid);pe(c,`material.${i}`,a)}},onKeyDown:o=>{}};return(i==="vertexShader"||i==="fragmentShader")&&(s.disabled=!1,s.latest=s.value,s.onChange=(o,a)=>{s.latest=a,t.updateObject(n.uuid,`material.${i}`,a);const d=t.getScene(n.uuid);if(d!==null){const c=d.getObjectByProperty("uuid",n.uuid);pe(c,`material.${i}`,a)}},s.onKeyDown=o=>{if(o.key==="Enter"&&(o.altKey||o.metaKey)){t.updateObject(n.uuid,"material.needsUpdate",!0);const a=t.getScene(n.uuid);if(a!==null){const d=a.getObjectByProperty("uuid",n.uuid);pe(d,"material.needsUpdate",!0)}}}),s}function Wn(i){return i.x!==void 0&&i.y!==void 0&&i.z===void 0}function Kn(i){return i.x!==void 0&&i.y!==void 0&&i.z!==void 0&&i.w===void 0}function Xn(i){return i.x!==void 0&&i.y!==void 0&&i.z!==void 0&&i.w!==void 0}function Ci(i){i.sort((e,n)=>e.title<n.title?-1:e.title>n.title?1:0)}function Ft(i,e,n,t,s="",r=!1){const o=si(i).split(".")[0].replaceAll("[","").replaceAll("]",""),a=s.length>0?`${s}.${i}`:i,d=typeof e;if(d==="boolean"||d==="string")return{title:o,prop:a,type:d,value:e,disabled:r,onChange:(c,u)=>{t.updateObject(n.uuid,`material.${a}`,u);const p=t.getScene(n.uuid);if(p!==null){const _=p.getObjectByProperty("uuid",n.uuid);pe(_,`material.${a}`,u)}}};if(d==="number"){const c={title:o,prop:a,type:"number",value:e,step:.01,disabled:r,onChange:(u,p)=>{t.updateObject(n.uuid,`material.${a}`,p);const _=t.getScene(n.uuid);if(_!==null){const y=_.getObjectByProperty("uuid",n.uuid);pe(y,`material.${a}`,p)}}};return on(o)&&(c.type="range",c.min=0,c.max=1),c}else{if(e.isColor)return{title:o,prop:a,type:"color",value:e,disabled:r,onChange:(c,u)=>{const p=new f.Color(u);t.updateObject(n.uuid,`material.${a}`,p);const _=t.getScene(n.uuid);if(_!==null){const y=_.getObjectByProperty("uuid",n.uuid);pe(y,`material.${a}`,p)}}};if(Array.isArray(e)){const c=[];for(const u in e){const p=e[u],_=`[${u.toString()}]`;if(p.value!==void 0){const y=Ft(`${_}.value`,p.value,n,t,a,r);y!==void 0&&c.push(y)}else{const y=Ft(_,p,n,t,a,r);y!==void 0&&c.push(y)}}if(c.length>0)return Ci(c),{title:o,items:c}}else{if(Wn(e))return{title:o,prop:a,type:"vector2",value:e,disabled:r,onChange:(c,u)=>{t.updateObject(n.uuid,`material.${a}`,u);const p=t.getScene(n.uuid);if(p!==null){const _=p.getObjectByProperty("uuid",n.uuid);pe(_,`material.${a}`,u)}}};if(Kn(e))return{title:o,prop:a,type:"grid3",value:e,disabled:r,onChange:(c,u)=>{t.updateObject(n.uuid,`material.${a}`,u);const p=t.getScene(n.uuid);if(p!==null){const _=p.getObjectByProperty("uuid",n.uuid);pe(_,`material.${a}`,u)}}};if(Xn(e))return{title:o,prop:a,type:"grid4",value:e,disabled:r,onChange:(c,u)=>{t.updateObject(n.uuid,`material.${a}`,u);const p=t.getScene(n.uuid);if(p!==null){const _=p.getObjectByProperty("uuid",n.uuid);pe(_,`material.${a}`,u)}}};if(e.isEuler)return{title:o,prop:a,type:"euler",value:e,disabled:r,onChange:(c,u)=>{t.updateObject(n.uuid,`material.${a}`,u);const p=t.getScene(n.uuid);if(p!==null){const _=p.getObjectByProperty("uuid",n.uuid);pe(_,`material.${a}`,u)}}};if(e.src!==void 0)return{title:o,type:"image",value:e,disabled:r,onChange:(c,u)=>{const p=jn(i),_=s.length>0?`${s}.${p}`:p;t.createTexture(n.uuid,`material.${_}`,u);const y=t.getScene(n.uuid);if(y!==null){const A=y.getObjectByProperty("uuid",n.uuid);if(A!==void 0){const I=F=>{const v=A.material,E=_.split(".");switch(E.length){case 1:v[E[0]]=F;break;case 2:v[E[0]][E[1]]=F;break;case 3:v[E[0]][E[1]][E[2]]=F;break;case 4:v[E[0]][E[1]][E[2]][E[3]]=F;break;case 5:v[E[0]][E[1]][E[2]][E[3]][E[4]]=F;break}v.needsUpdate=!0};u.src.length>0?tn(u.src).then(F=>{F.offset.set(u.offset[0],u.offset[1]),F.repeat.set(u.repeat[0],u.repeat[1]),I(F)}):I(null)}}}};if(e.elements!==void 0)return{title:o,prop:a,type:e.elements.length>9?"grid4":"grid3",value:e,disabled:r,onChange:(c,u)=>{t.updateObject(n.uuid,`material.${a}`,u);const p=t.getScene(n.uuid);if(p!==null){const _=p.getObjectByProperty("uuid",n.uuid);pe(_,`material.${a}`,u)}}};{const c=[],u=i==="defines"||i==="extensions";try{for(const p in e){const _=e[p];if(_!==void 0)if(_.value!==void 0){const y=Ft(`${p}.value`,_.value,n,t,a,u);y!==void 0&&c.push(y)}else{const y=Ft(p,_,n,t,a,u);y!==void 0&&c.push(y)}}}catch{console.log("Issue cycling through material object:",i,e)}if(c.length>0)return Ci(c),{title:o,items:c}}}}}function Li(i,e,n){const t=[];for(const s in i){if(!Fn(s))continue;const r=typeof i[s],o=i[s];if(r==="boolean")t.push(Gn(s,o,e,n));else if(r==="number")t.push(Zn(s,o,e,n));else if(r==="string")t.push($n(s,o,e,n));else if(r==="object"){const a=Ft(s,o,e,n);a!==void 0&&t.push(a)}else o!==void 0&&console.log("other:",s,r,o)}return Ci(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 r=s.getObjectByProperty("uuid",e.uuid);pe(r,"material.needsUpdate",!0)}}}),t}function qn(i,e){const n=i.material;if(Array.isArray(n)){const t=[],s=n.length;for(let r=0;r<s;r++)t.push(m.jsx(lt,{title:`Material ${r}`,items:Li(n[r],i,e)},`Material ${r}`));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 Jn(i){const e=i.step!==void 0?i.step:.01,n=T.useRef(null),t=T.useRef(null),s=T.useRef(null),r=T.useRef(null),o=T.useRef(null),[a]=T.useState(i.value),[d,c]=T.useState(i.value.offset[0]),[u,p]=T.useState(i.value.offset[1]),[_,y]=T.useState(i.value.repeat[0]),[A,I]=T.useState(i.value.repeat[1]);function F(E,w,C,U,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:[U,L]})}}function v(E){const w=n.current.src,C=E.target.value;switch(E.target){case t.current:c(C),F(w,C,u,_,A);break;case s.current:p(C),F(w,d,C,_,A);break;case r.current:y(C),F(w,d,u,C,A);break;case o.current:I(C),F(w,d,u,_,C);break}}return m.jsxs("div",{className:"imageField",children:[m.jsx("img",{alt:i.title,ref:n,onClick:()=>{Nn().then(E=>{n.current.src=E,F(E,d,u,_,A)})},src:a.src.length>0?a.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:d,step:e,onChange:v}),m.jsx("input",{ref:s,type:"number",value:u,step:e,onChange:v})]}),m.jsxs("div",{children:[m.jsx("label",{children:"Repeat:"}),m.jsx("input",{ref:r,type:"number",value:_,step:e,onChange:v}),m.jsx("input",{ref:o,type:"number",value:A,step:e,onChange:v})]}),m.jsx("button",{onClick:()=>{F("",d,u,_,A),n.current.src=Ii},children:"Clear"})]})]})}function Qt(i){let e=i.value;e!==void 0&&(e.isColor!==void 0?e=vi(i.value):i.type==="color"&&(e=vi(new f.Color(i.value))));const[n,t]=T.useState(e),s=T.useRef(null),r=c=>{let u=c.target.value;if(i.type==="boolean")u=c.target.checked;else if(i.type==="option"&&(typeof i.value=="number"?u=Number(u):typeof i.value=="boolean"?u=!!u:typeof i.value=="object"&&(u=JSON.parse(u)),i.options!==void 0)){const p=i.options.length;for(let _=0;_<p&&i.options[_].value!==u;_++);}t(u),i.onChange!==void 0&&i.onChange(i.prop!==void 0?i.prop:i.title,u)},o={};i.disabled&&(o.opacity=.8);const a=i.type==="string"&&(n.length>100||n.search(`
|
30
|
-
`)>-1),d=a||i.type==="image"||i.type==="vector2";return m.jsxs("div",{className:`field ${d?"block":""}`,style:o,children:[i.type!=="button"&&m.jsx("label",{ref:s,children:Nt(i.title)},"fieldLabel"),i.type==="string"&&!a&&m.jsx("input",{type:"text",disabled:i.disabled,onChange:r,value:n}),i.type==="string"&&a&&m.jsx("textarea",{cols:50,rows:10,disabled:i.disabled!==void 0?i.disabled:!0,onChange:r,onKeyDown:c=>{i.onKeyDown!==void 0&&i.onKeyDown(c)},value:n}),i.type==="boolean"&&m.jsx("input",{type:"checkbox",disabled:i.disabled,onChange:r,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:r,disabled:i.disabled,className:"color"}),m.jsx("input",{type:"color",value:n,onChange:r,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(Jn,{title:i.title,prop:i.prop,value:i.value,onChange:i.onChange}),i.type==="option"&&m.jsx(m.Fragment,{children:m.jsx("select",{onChange:r,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:r}),i.type==="grid3"&&m.jsx(Pi,{step:i.step,value:n,onChange:r}),i.type==="grid4"&&m.jsx(kn,{step:i.step,value:n,onChange:r}),i.type==="euler"&&m.jsx(Pi,{step:i.step,value:n,onChange:r})]})}function Qn(i){return"items"in i}function lt(i){const e=[];return i.items.forEach(n=>{Qn(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(Ht,{label:i.title,open:i.expanded===!0,children:e})}function es(i){const[e]=T.useState([]),[n]=T.useState([]),[t,s]=T.useState(0);return T.useEffect(()=>{const r=a=>{const d=JSON.parse(a.value),c=[];d.items.forEach(u=>{c.push({type:u.type,prop:u.prop,title:u.title!==void 0?u.title:u.prop,value:u.value,min:u.min,max:u.max,step:u.step,options:u.options,disabled:u.disabled,onChange:(p,_)=>{i.three.updateGroup(d.title,p,_)}})}),e.push(m.jsx(lt,{title:d.title,items:c},Math.random())),n.push(d.title),s(Date.now())},o=a=>{const d=a.value,c=n.length;for(let u=0;u<c;u++)if(d===n[u]){e.splice(u,1),n.splice(u,1),s(Date.now());return}};return z.addEventListener(B.ADD_GROUP,r),z.addEventListener(B.REMOVE_GROUP,o),()=>{z.removeEventListener(B.ADD_GROUP,r),z.removeEventListener(B.REMOVE_GROUP,o)}},[]),m.jsx("div",{className:"customGroups",children:e},t)}function Ui(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 ts(i,e){const n=[];if(i.perspectiveCameraInfo!==void 0)for(const t in i.perspectiveCameraInfo)n.push({title:Ui(t),prop:t,type:"number",step:.01,value:i.perspectiveCameraInfo[t],onChange:(s,r)=>{e.updateObject(i.uuid,s,r),e.requestMethod(i.uuid,"updateProjectionMatrix");const o=e.getScene(i.uuid);if(o!==null){const a=o.getObjectByProperty("uuid",i.uuid);a!==void 0&&(pe(a,s,r),a.updateProjectionMatrix())}}});else if(i.orthographicCameraInfo!==void 0)for(const t in i.orthographicCameraInfo)n.push({title:Ui(t),prop:t,type:"number",step:.01,value:i.perspectiveCameraInfo[t],onChange:(s,r)=>{e.updateObject(i.uuid,s,r),e.requestMethod(i.uuid,"updateProjectionMatrix");const o=e.getScene(i.uuid);if(o!==null){const a=o.getObjectByProperty("uuid",i.uuid);a!==void 0&&(pe(a,s,r),a.updateProjectionMatrix())}}});return m.jsx(lt,{title:"Camera",items:n})}function is(i,e){const n=new f.Matrix4;n.elements=i.matrix;const t=new f.Vector3,s=new f.Euler,r=new f.Vector3;i.uuid.length>0&&(t.setFromMatrixPosition(n),s.setFromRotationMatrix(n),r.setFromMatrixScale(n));const o=(a,d)=>{const c=a==="rotation"?{x:d._x,y:d._y,z:d._z}:d;e.updateObject(i.uuid,a,c);const u=e.getScene(i.uuid);if(u!==null){const p=u.getObjectByProperty("uuid",i.uuid);pe(p,a,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:r,onChange:o},{title:"Visible",prop:"visible",type:"boolean",value:i.visible,onChange:o}]})}function ki(i){switch(i){case"color":return"Color";case"intensity":return"Intensity";case"decay":return"Decay";case"distance":return"Distance";case"angle":return"Angle";case"penumbra":return"Penumbra";case"groundColor":return"Ground Color";case"width":return"Width";case"height":return"Height"}return i}function ns(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:ki(t),prop:t,type:"color",value:s,onChange:(r,o)=>{const a=new f.Color(o);e.updateObject(i.uuid,r,a);const d=e.getScene(i.uuid);if(d!==null){const c=d.getObjectByProperty("uuid",i.uuid);pe(c,r,a)}}}):n.push({title:ki(t),prop:t,type:typeof s,value:s,step:typeof s=="number"?.01:void 0,onChange:(r,o)=>{e.updateObject(i.uuid,r,o);const a=e.getScene(i.uuid);if(a!==null){const d=a.getObjectByProperty("uuid",i.uuid);pe(d,r,o)}}}))}return m.jsx(lt,{title:"Light",items:n})}function ss(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 r=e.getScene(i.uuid);if(r!==null){const o=r.getObjectByProperty("uuid",i.uuid);let a=!1;if(o!==void 0){const d=o.mixer;if(a=d!==void 0,a){const c=[{title:"Time Scale",type:"range",value:d.timeScale,step:.01,min:-1,max:2,onChange:(u,p)=>{d.timeScale=p,e.updateObject(i.uuid,"mixer.timeScale",p)}}];c.push({title:"Stop All",type:"button",onChange:()=>{d.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 Re={...cn};function ln(i){const[e,n]=T.useState(-1);T.useEffect(()=>{function o(d){Re={...d.value},n(Date.now())}function a(){Re={...cn},n(Date.now())}return z.addEventListener(B.SET_SCENE,a),z.addEventListener(B.SET_OBJECT,o),()=>{z.removeEventListener(B.SET_SCENE,a),z.removeEventListener(B.SET_OBJECT,o)}},[]);const t=Re.type.toLowerCase(),s=Re.animations.length>0||Re.mixer!==void 0,r=t.search("mesh")>-1||t.search("line")>-1||t.search("points")>-1;return m.jsx(Ht,{label:"Inspector",children:m.jsx("div",{id:"Inspector",className:i.class,children:Re.uuid.length>0&&m.jsxs(m.Fragment,{children:[m.jsxs(m.Fragment,{children:[m.jsx(Qt,{type:"string",title:"Name",prop:"name",value:Re.name,disabled:!0}),m.jsx(Qt,{type:"string",title:"Type",prop:"type",value:Re.type,disabled:!0}),m.jsx(Qt,{type:"string",title:"UUID",prop:"uuid",value:Re.uuid,disabled:!0})]}),m.jsxs(m.Fragment,{children:[is(Re,i.three),s?ss(Re,i.three):null,t.search("camera")>-1?ts(Re,i.three):null,t.search("light")>-1?ns(Re,i.three):null,r?qn(Re,i.three):null]})]})},e)},"Inspector")}function hn(i){const[e]=T.useState([]),[n]=T.useState([]),[t,s]=T.useState(0),r=d=>{const c=d.value;e.push(c),n.push(m.jsx(Ht,{label:`Scene: ${c.name}`,scene:c,open:!0,onRefresh:()=>{i.three.refreshScene(c.name)},children:m.jsx(bi,{child:c,scene:c,three:i.three})},Math.random())),s(Date.now())},o=d=>{const c=d.value;for(let u=0;u<e.length;u++)if(c.uuid===e[u].uuid){e[u]=c,n[u]=m.jsx(Ht,{label:`Scene: ${c.name}`,scene:c,open:!0,onRefresh:()=>{i.three.refreshScene(c.name)},children:m.jsx(bi,{child:c,scene:c,three:i.three})},Math.random()),s(Date.now());return}},a=d=>{const c=d.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(()=>(z.addEventListener(B.ADD_SCENE,r),z.addEventListener(B.REFRESH_SCENE,o),z.addEventListener(B.REMOVE_SCENE,a),()=>{z.removeEventListener(B.ADD_SCENE,r),z.removeEventListener(B.REFRESH_SCENE,o),z.removeEventListener(B.REMOVE_SCENE,a)}),[]),m.jsxs("div",{id:"SidePanel",children:[m.jsx("div",{className:"scenes",children:n},t),m.jsx(ln,{three:i.three}),m.jsx(es,{three:i.three})]})}function rs(i){return T.useEffect(()=>{function e(a){let d=null;return i.three.scenes.forEach(c=>{a.search(c.uuid)>-1&&(d=c)}),d}const n=a=>{const d=a.value,u=e(d)?.getObjectByProperty("uuid",d);u!==void 0&&i.three.setObject(u)},t=(a,d,c)=>{const p=e(a)?.getObjectByProperty("uuid",a);p!==void 0&&pe(p,d,c)},s=a=>{const d=a.value,{key:c,value:u,uuid:p}=d;t(p,c,u)},r=a=>{const d=a.value,u=e(d.uuid)?.getObjectByProperty("uuid",d.uuid);if(u!==void 0){const p=_=>{const y=d.key.split(".");switch(y.length){case 1:u[y[0]]=_;break;case 2:u[y[0]][y[1]]=_;break;case 3:u[y[0]][y[1]][y[2]]=_;break;case 4:u[y[0]][y[1]][y[2]][y[3]]=_;break;case 5:u[y[0]][y[1]][y[2]][y[3]][y[4]]=_;break}u.material.needsUpdate=!0};d.value.src.length>0?tn(d.value.src).then(_=>{_.offset.set(d.value.offset[0],d.value.offset[1]),_.repeat.set(d.value.repeat[0],d.value.repeat[1]),p(_)}):p(null)}},o=a=>{const{key:d,uuid:c,value:u,subitem:p}=a.value,y=e(c)?.getObjectByProperty("uuid",c);if(y!==void 0)try{p!==void 0?Sn(y,p)[d](u):y[d](u)}catch(A){console.log("Error requesting method:"),console.log(A),console.log(d),console.log(u)}};return z.addEventListener(B.GET_OBJECT,n),z.addEventListener(B.UPDATE_OBJECT,s),z.addEventListener(B.CREATE_TEXTURE,r),z.addEventListener(B.REQUEST_METHOD,o),()=>{z.removeEventListener(B.GET_OBJECT,n),z.removeEventListener(B.UPDATE_OBJECT,s),z.removeEventListener(B.CREATE_TEXTURE,r),z.removeEventListener(B.REQUEST_METHOD,o)}},[]),null}class as extends f.Line{constructor(e,n){const t=[1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],s=new f.BufferGeometry;s.setAttribute("position",new f.Float32BufferAttribute(t,3)),s.computeBoundingSphere();const r=new f.LineBasicMaterial({fog:!1});super(s,r),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],a=new f.BufferGeometry;a.setAttribute("position",new f.Float32BufferAttribute(o,3)),a.computeBoundingSphere(),this.add(new f.Mesh(a,new f.MeshBasicMaterial({side:f.BackSide,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),this.color!==void 0)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const 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"},ci={type:"start"},ji={type:"end"},$t=new f.Ray,Ni=new f.Plane,os=Math.cos(70*f.MathUtils.DEG2RAD);class cs extends f.EventDispatcher{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new f.Vector3,this.cursor=new f.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:f.MOUSE.ROTATE,MIDDLE:f.MOUSE.DOLLY,RIGHT:f.MOUSE.PAN},this.touches={ONE:f.TOUCH.ROTATE,TWO:f.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return a.phi},this.getAzimuthalAngle=function(){return a.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(h){h.addEventListener("keydown",Pe),this._domElementKeyEvents=h},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(),r=s.NONE},this.update=function(){const h=new f.Vector3,R=new f.Quaternion().setFromUnitVectors(e.up,new f.Vector3(0,1,0)),$=R.clone().invert(),ee=new f.Vector3,Oe=new f.Quaternion,je=new f.Vector3,Se=2*Math.PI;return function(Yt=null){const Gt=t.object.position;h.copy(Gt).sub(t.target),h.applyQuaternion(R),a.setFromVector3(h),t.autoRotate&&r===s.NONE&&Ue($e(Yt)),t.enableDamping?(a.theta+=d.theta*t.dampingFactor,a.phi+=d.phi*t.dampingFactor):(a.theta+=d.theta,a.phi+=d.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?a.theta=Math.max(Ne,Math.min(ze,a.theta)):a.theta=a.theta>(Ne+ze)/2?Math.max(Ne,a.theta):Math.min(ze,a.theta)),a.phi=Math.max(t.minPolarAngle,Math.min(t.maxPolarAngle,a.phi)),a.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)a.radius=Qe(a.radius);else{const Ge=a.radius;a.radius=Qe(a.radius*c),ut=Ge!=a.radius}if(h.setFromSpherical(a),h.applyQuaternion($),Gt.copy(t.target).add(h),t.object.lookAt(t.target),t.enableDamping===!0?(d.theta*=1-t.dampingFactor,d.phi*=1-t.dampingFactor,u.multiplyScalar(1-t.dampingFactor)):(d.set(0,0,0),u.set(0,0,0)),t.zoomToCursor&&L){let Ge=null;if(t.object.isPerspectiveCamera){const at=h.length();Ge=Qe(at*c);const vt=at-Ge;t.object.position.addScaledVector(C,vt),t.object.updateMatrixWorld(),ut=!!vt}else if(t.object.isOrthographicCamera){const at=new f.Vector3(U.x,U.y,0);at.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 f.Vector3(U.x,U.y,0);Zt.unproject(t.object),t.object.position.sub(Zt).add(at),t.object.updateMatrixWorld(),Ge=h.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))<os?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-Oe.dot(t.object.quaternion))>o||je.distanceToSquared(t.target)>o?(t.dispatchEvent(Fi),ee.copy(t.object.position),Oe.copy(t.object.quaternion),je.copy(t.target),!0):!1}}(),this.dispose=function(){t.domElement.removeEventListener("contextmenu",We),t.domElement.removeEventListener("pointerdown",be),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 r=s.NONE;const o=1e-6,a=new f.Spherical,d=new f.Spherical;let c=1;const u=new f.Vector3,p=new f.Vector2,_=new f.Vector2,y=new f.Vector2,A=new f.Vector2,I=new f.Vector2,F=new f.Vector2,v=new f.Vector2,E=new f.Vector2,w=new f.Vector2,C=new f.Vector3,U=new f.Vector2;let L=!1;const x=[],oe={};let te=!1;function $e(h){return h!==null?2*Math.PI/60*t.autoRotateSpeed*h:2*Math.PI/60/60*t.autoRotateSpeed}function j(h){const R=Math.abs(h*.01);return Math.pow(.95,t.zoomSpeed*R)}function Ue(h){d.theta-=h}function ye(h){d.phi-=h}const Ce=function(){const h=new f.Vector3;return function($,ee){h.setFromMatrixColumn(ee,0),h.multiplyScalar(-$),u.add(h)}}(),Te=function(){const h=new f.Vector3;return function($,ee){t.screenSpacePanning===!0?h.setFromMatrixColumn(ee,1):(h.setFromMatrixColumn(ee,0),h.crossVectors(t.object.up,h)),h.multiplyScalar($),u.add(h)}}(),ke=function(){const h=new f.Vector3;return function($,ee){const Oe=t.domElement;if(t.object.isPerspectiveCamera){const je=t.object.position;h.copy(je).sub(t.target);let Se=h.length();Se*=Math.tan(t.object.fov/2*Math.PI/180),Ce(2*$*Se/Oe.clientHeight,t.object.matrix),Te(2*ee*Se/Oe.clientHeight,t.object.matrix)}else t.object.isOrthographicCamera?(Ce($*(t.object.right-t.object.left)/t.object.zoom/Oe.clientWidth,t.object.matrix),Te(ee*(t.object.top-t.object.bottom)/t.object.zoom/Oe.clientHeight,t.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),t.enablePan=!1)}}();function Ve(h){t.object.isPerspectiveCamera||t.object.isOrthographicCamera?c/=h:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),t.enableZoom=!1)}function it(h){t.object.isPerspectiveCamera||t.object.isOrthographicCamera?c*=h:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),t.enableZoom=!1)}function Je(h,R){if(!t.zoomToCursor)return;L=!0;const $=t.domElement.getBoundingClientRect(),ee=h-$.left,Oe=R-$.top,je=$.width,Se=$.height;U.x=ee/je*2-1,U.y=-(Oe/Se)*2+1,C.set(U.x,U.y,1).unproject(t.object).sub(t.object.position).normalize()}function Qe(h){return Math.max(t.minDistance,Math.min(t.maxDistance,h))}function ht(h){p.set(h.clientX,h.clientY)}function nt(h){Je(h.clientX,h.clientX),v.set(h.clientX,h.clientY)}function ge(h){A.set(h.clientX,h.clientY)}function Ye(h){_.set(h.clientX,h.clientY),y.subVectors(_,p).multiplyScalar(t.rotateSpeed);const R=t.domElement;Ue(2*Math.PI*y.x/R.clientHeight),ye(2*Math.PI*y.y/R.clientHeight),p.copy(_),t.update()}function Mt(h){E.set(h.clientX,h.clientY),w.subVectors(E,v),w.y>0?Ve(j(w.y)):w.y<0&&it(j(w.y)),v.copy(E),t.update()}function dt(h){I.set(h.clientX,h.clientY),F.subVectors(I,A).multiplyScalar(t.panSpeed),ke(F.x,F.y),A.copy(I),t.update()}function Me(h){Je(h.clientX,h.clientY),h.deltaY<0?it(j(h.deltaY)):h.deltaY>0&&Ve(j(h.deltaY)),t.update()}function O(h){let R=!1;switch(h.code){case t.keys.UP:h.ctrlKey||h.metaKey||h.shiftKey?ye(2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):ke(0,t.keyPanSpeed),R=!0;break;case t.keys.BOTTOM:h.ctrlKey||h.metaKey||h.shiftKey?ye(-2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):ke(0,-t.keyPanSpeed),R=!0;break;case t.keys.LEFT:h.ctrlKey||h.metaKey||h.shiftKey?Ue(2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):ke(t.keyPanSpeed,0),R=!0;break;case t.keys.RIGHT:h.ctrlKey||h.metaKey||h.shiftKey?Ue(-2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):ke(-t.keyPanSpeed,0),R=!0;break}R&&(h.preventDefault(),t.update())}function S(h){if(x.length===1)p.set(h.pageX,h.pageY);else{const R=rt(h),$=.5*(h.pageX+R.x),ee=.5*(h.pageY+R.y);p.set($,ee)}}function P(h){if(x.length===1)A.set(h.pageX,h.pageY);else{const R=rt(h),$=.5*(h.pageX+R.x),ee=.5*(h.pageY+R.y);A.set($,ee)}}function N(h){const R=rt(h),$=h.pageX-R.x,ee=h.pageY-R.y,Oe=Math.sqrt($*$+ee*ee);v.set(0,Oe)}function ue(h){t.enableZoom&&N(h),t.enablePan&&P(h)}function X(h){t.enableZoom&&N(h),t.enableRotate&&S(h)}function D(h){if(x.length==1)_.set(h.pageX,h.pageY);else{const $=rt(h),ee=.5*(h.pageX+$.x),Oe=.5*(h.pageY+$.y);_.set(ee,Oe)}y.subVectors(_,p).multiplyScalar(t.rotateSpeed);const R=t.domElement;Ue(2*Math.PI*y.x/R.clientHeight),ye(2*Math.PI*y.y/R.clientHeight),p.copy(_)}function k(h){if(x.length===1)I.set(h.pageX,h.pageY);else{const R=rt(h),$=.5*(h.pageX+R.x),ee=.5*(h.pageY+R.y);I.set($,ee)}F.subVectors(I,A).multiplyScalar(t.panSpeed),ke(F.x,F.y),A.copy(I)}function me(h){const R=rt(h),$=h.pageX-R.x,ee=h.pageY-R.y,Oe=Math.sqrt($*$+ee*ee);E.set(0,Oe),w.set(0,Math.pow(E.y/v.y,t.zoomSpeed)),Ve(w.y),v.copy(E);const je=(h.pageX+R.x)*.5,Se=(h.pageY+R.y)*.5;Je(je,Se)}function Ee(h){t.enableZoom&&me(h),t.enablePan&&k(h)}function et(h){t.enableZoom&&me(h),t.enableRotate&&D(h)}function be(h){t.enabled!==!1&&(x.length===0&&(t.domElement.setPointerCapture(h.pointerId),t.domElement.addEventListener("pointermove",xe),t.domElement.addEventListener("pointerup",Ae)),!ai(h)&&(_t(h),h.pointerType==="touch"?Fe(h):se(h)))}function xe(h){t.enabled!==!1&&(h.pointerType==="touch"?st(h):_e(h))}function Ae(h){switch(ri(h),x.length){case 0:t.domElement.releasePointerCapture(h.pointerId),t.domElement.removeEventListener("pointermove",xe),t.domElement.removeEventListener("pointerup",Ae),t.dispatchEvent(ji),r=s.NONE;break;case 1:const R=x[0],$=oe[R];Fe({pointerId:R,pageX:$.x,pageY:$.y});break}}function se(h){let R;switch(h.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 f.MOUSE.DOLLY:if(t.enableZoom===!1)return;nt(h),r=s.DOLLY;break;case f.MOUSE.ROTATE:if(h.ctrlKey||h.metaKey||h.shiftKey){if(t.enablePan===!1)return;ge(h),r=s.PAN}else{if(t.enableRotate===!1)return;ht(h),r=s.ROTATE}break;case f.MOUSE.PAN:if(h.ctrlKey||h.metaKey||h.shiftKey){if(t.enableRotate===!1)return;ht(h),r=s.ROTATE}else{if(t.enablePan===!1)return;ge(h),r=s.PAN}break;default:r=s.NONE}r!==s.NONE&&t.dispatchEvent(ci)}function _e(h){switch(r){case s.ROTATE:if(t.enableRotate===!1)return;Ye(h);break;case s.DOLLY:if(t.enableZoom===!1)return;Mt(h);break;case s.PAN:if(t.enablePan===!1)return;dt(h);break}}function G(h){t.enabled===!1||t.enableZoom===!1||r!==s.NONE||(h.preventDefault(),t.dispatchEvent(ci),Me(H(h)),t.dispatchEvent(ji))}function H(h){const R=h.deltaMode,$={clientX:h.clientX,clientY:h.clientY,deltaY:h.deltaY};switch(R){case 1:$.deltaY*=16;break;case 2:$.deltaY*=100;break}return h.ctrlKey&&!te&&($.deltaY*=10),$}function q(h){h.key==="Control"&&(te=!0,t.domElement.getRootNode().addEventListener("keyup",Q,{passive:!0,capture:!0}))}function Q(h){h.key==="Control"&&(te=!1,t.domElement.getRootNode().removeEventListener("keyup",Q,{passive:!0,capture:!0}))}function Pe(h){t.enabled===!1||t.enablePan===!1||O(h)}function Fe(h){switch(Vt(h),x.length){case 1:switch(t.touches.ONE){case f.TOUCH.ROTATE:if(t.enableRotate===!1)return;S(h),r=s.TOUCH_ROTATE;break;case f.TOUCH.PAN:if(t.enablePan===!1)return;P(h),r=s.TOUCH_PAN;break;default:r=s.NONE}break;case 2:switch(t.touches.TWO){case f.TOUCH.DOLLY_PAN:if(t.enableZoom===!1&&t.enablePan===!1)return;ue(h),r=s.TOUCH_DOLLY_PAN;break;case f.TOUCH.DOLLY_ROTATE:if(t.enableZoom===!1&&t.enableRotate===!1)return;X(h),r=s.TOUCH_DOLLY_ROTATE;break;default:r=s.NONE}break;default:r=s.NONE}r!==s.NONE&&t.dispatchEvent(ci)}function st(h){switch(Vt(h),r){case s.TOUCH_ROTATE:if(t.enableRotate===!1)return;D(h),t.update();break;case s.TOUCH_PAN:if(t.enablePan===!1)return;k(h),t.update();break;case s.TOUCH_DOLLY_PAN:if(t.enableZoom===!1&&t.enablePan===!1)return;Ee(h),t.update();break;case s.TOUCH_DOLLY_ROTATE:if(t.enableZoom===!1&&t.enableRotate===!1)return;et(h),t.update();break;default:r=s.NONE}}function We(h){t.enabled!==!1&&h.preventDefault()}function _t(h){x.push(h.pointerId)}function ri(h){delete oe[h.pointerId];for(let R=0;R<x.length;R++)if(x[R]==h.pointerId){x.splice(R,1);return}}function ai(h){for(let R=0;R<x.length;R++)if(x[R]==h.pointerId)return!0;return!1}function Vt(h){let R=oe[h.pointerId];R===void 0&&(R=new f.Vector2,oe[h.pointerId]=R),R.set(h.pageX,h.pageY)}function rt(h){const R=h.pointerId===x[0]?x[1]:x[0];return oe[R]}t.domElement.addEventListener("contextmenu",We),t.domElement.addEventListener("pointerdown",be),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 ls=Math.PI/180;function Ot(i,e,n,t,s){return t+(i-e)*(s-t)/(n-e)}function zi(i){return i*ls}/*!
|
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:[Pn,m.jsx("span",{children:i.title}),m.jsx("button",{className:"closeIcon",onClick:()=>{i.onDelete(i.index)},children:An})]})},i.title)}function sn(i){const[e,n]=T.useState(!1),[t,s]=T.useState(i.options),r=c=>{i.onDragComplete(c),s(c)},o=c=>{const u=[...t];u.splice(c,1),r(u)},a=[];t.forEach((c,u)=>{a.push(m.jsx(nn,{index:u,title:c,onDelete:o},c))});let d="dropdown draggable";return i.subdropdown&&(d+=" subdropdown"),m.jsxs("div",{className:d,onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[m.jsx(xi,{title:i.title}),m.jsx(qi.Reorder.Group,{axis:"y",values:t,onReorder:r,style:{visibility:e?"visible":"hidden"},children:a})]})}function rn(i){const[e,n]=T.useState(!1),t=[];i.options.map((r,o)=>{i.onSelect!==void 0&&(r.onSelect=i.onSelect),t.push(m.jsx(an,{option:r},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 an(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:r=>{e.onDragComplete!==void 0&&e.onDragComplete(r)},subdropdown:!0});break;case"dropdown":s=m.jsx(rn,{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 Ln(i,e,n){function t(r){switch(e.forEach(o=>{o.callback(i,o.remote,r)}),r.event){case"custom":z.dispatchEvent({type:B.CUSTOM,value:r.data});break}}function s(r){switch(n.forEach(o=>{o.callback(i,o.remote,r)}),r.event){case"custom":z.dispatchEvent({type:B.CUSTOM,value:r.data});break}}i.listen=r=>{r.target==="editor"?s(r):t(r)}}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 m.jsxs("div",{className:`accordion ${t?"hide":""}`,children:[m.jsxs("button",{className:"toggle",onClick:()=>{const r=!e;i.onToggle!==void 0&&i.onToggle(r),n(r)},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,r=[];return i.child!==void 0&&i.child.children.length>0&&i.child.children.map((o,a)=>{r.push(m.jsx(Si,{child:o,three:i.three},a))}),T.useEffect(()=>{if(i.child){const o=i.three.getScene(i.child.uuid);if(o!==null){const a=o.getObjectByProperty("uuid",i.child.uuid);a!==void 0&&(e.current.style.opacity=a.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 a=o.getObjectByProperty("uuid",i.child.uuid);if(a!==void 0){const d="visible",c=!a.visible;e.current.style.opacity=c?"1":"0.25",i.three.updateObject(i.child.uuid,d,c),pe(a,d,c)}}}}}),m.jsx("div",{className:`icon ${Cn(i.child)}`})]}),m.jsx("div",{className:n?"open":"",children:m.jsx("div",{className:"container",children:r})})]},Math.random())})}function Oi(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 In(i){const[e,n]=T.useState(i.defaultValue);return T.useEffect(()=>{let t=!1,s=-1,r=0,o=i.defaultValue;const a=_=>{t=!0,r=Number(i.input.current?.value),s=_.clientX,document.addEventListener("mouseup",c,!1),document.addEventListener("mousemove",d,!1),document.addEventListener("contextmenu",c,!1)},d=_=>{if(!t)return;const y=i.step!==void 0?i.step:1,A=(_.clientX-s)*y;o=Number((r+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",d),document.removeEventListener("contextmenu",c)},u=_=>{const y=Number(_.target.value);n(y)},p=_=>{const y=Number(_.target.value);i.onChange!==void 0&&i.onChange(y),n(y)};return i.input.current?.addEventListener("input",u),i.label.current?.addEventListener("mousedown",a,!1),i.sliderRef!==void 0&&i.sliderRef.current?.addEventListener("input",p),()=>{i.input.current?.removeEventListener("input",u),i.label.current?.removeEventListener("mousedown",a),i.sliderRef!==void 0&&i.sliderRef.current?.removeEventListener("input",p),document.removeEventListener("mouseup",c),document.removeEventListener("mousemove",d),document.removeEventListener("contextmenu",c)}},[]),e}function gt(i){const e=T.useRef(null),n=T.useRef(null),t=In({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 r=Number(s.target.value);i.onChange!==void 0&&i.onChange(i.prop,r)}}),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 r=Number(s.target.value);i.onChange!==void 0&&i.onChange(i.prop,r)}}),m.jsx("input",{disabled:i.disabled,type:"range",value:t,min:i.min,max:i.max,step:i.step,ref:n,onChange:Ci})]})]})}function Un(i){const e=T.useRef(null),n=T.useRef(null),t=T.useRef(null),s=T.useRef(null),r=T.useRef(null),o=T.useRef(null),[a,d]=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))}),[p,_]=T.useState(!1);function y(){p||(window.addEventListener("mousemove",I),window.addEventListener("mouseup",A),window.addEventListener("mouseup",A),_(!0))}function A(){window.removeEventListener("mousemove",I),window.removeEventListener("mouseup",A),_(!1)}function I(C){const U=r.current.getBoundingClientRect(),L=ct(0,99,C.clientX-U.left)/99,x=ct(0,99,C.clientY-U.top)/99,oe=vi(Qt(c.min,c.max,L),3),te=vi(Qt(c.min,c.max,x),3);i.onChange({target:{value:{x:oe,y:te}}}),d({x:oe,y:te})}function F(C){let U=a.x,L=a.y;C.target===e.current?U=Number(C.target.value):L=Number(C.target.value),d({x:U,y:L})}function v(){const C=Number(t.current.value);u({min:C,max:c.max}),(a.x<C||a.y<C)&&d({x:ct(C,c.max,a.x),y:ct(C,c.max,a.y)})}function E(){const C=Number(s.current.value);u({min:c.min,max:C}),(a.x>C||a.y>C)&&d({x:ct(c.min,C,a.x),y:ct(c.min,C,a.y)})}T.useEffect(()=>{const C=gi(c.min,c.max,a.x),U=gi(c.min,c.max,a.y);o.current.style.left=`${C*100}%`,o.current.style.top=`${U*100}%`},[c,a]);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:a.x,min:c.min,max:c.max,step:w,onChange:F})]}),m.jsxs("div",{children:[m.jsx("label",{children:"Y:"}),m.jsx("input",{ref:n,type:"number",value:a.y,min:c.min,max:c.max,step:w,onChange:F})]}),m.jsxs("div",{children:[m.jsx("label",{children:"Min:"}),m.jsx("input",{ref:t,type:"number",value:c.min,step:w,onChange:v})]}),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:r,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.x!==void 0&&i.value.y!==void 0&&i.value.z!==void 0,n=i.value.isEuler!==void 0,t=i.value.elements!==void 0,s=i.step!==void 0?i.step:.01,r=[];if(e){const o=T.useMemo(()=>i.value,[]),a=(c,u)=>{o[c]=u,i.onChange({target:{value:o}})};["x","y","z"].forEach(c=>{const u=T.useRef(null);r.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:a})]},c))})}else if(n){const o=T.useMemo(()=>i.value,[]),a=(c,u)=>{o[c]=u,i.onChange({target:{value:o}})};["_x","_y","_z"].forEach(c=>{const u=T.useRef(null);r.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:a})]},c))})}else if(t){const o=T.useMemo(()=>i.value,[]),a=(d,c)=>{const u=Number(d);o.elements[u]=c,i.onChange({target:{value:o}})};for(let d=0;d<9;d++){const c=T.useRef(null);r.push(m.jsxs("div",{children:[m.jsx("label",{ref:c,children:d+1}),m.jsx(gt,{value:o.elements[d],type:"number",prop:d.toString(),step:s,labelRef:c,onChange:a})]},d.toString()))}}return m.jsx("div",{className:"grid3",children:r},Math.random().toString())}function kn(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,[]),r=(a,d)=>{s[a]=d,i.onChange({target:{value:s}})};["x","y","z","w"].forEach(a=>{const d=T.useRef(null);t.push(m.jsxs("div",{children:[m.jsx("label",{ref:d,children:a.toUpperCase()}),m.jsx(gt,{value:s.x,type:"number",prop:a,step:n,labelRef:d,onChange:r})]},a))})}else{const s=T.useMemo(()=>i.value,[]),r=(o,a)=>{const d=Number(o);s.elements[d]=a,i.onChange({target:{value:s}})};for(let o=0;o<16;o++){const a=T.useRef(null);t.push(m.jsxs("div",{children:[m.jsx("label",{ref:a,children:o+1}),m.jsx(gt,{value:s.elements[o],type:"number",prop:o.toString(),step:n,labelRef:a,onChange:r})]},o.toString()))}}return m.jsx("div",{className:"grid4",children:t})}function Fn(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 jn(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 ni(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"}function Nn(){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(r){e(r.target.result)},s.readAsDataURL(t)}}),i.click()})}const zn=[{title:"Front",value:f.FrontSide},{title:"Back",value:f.BackSide},{title:"Double",value:f.DoubleSide}],Bn=[{title:"No Blending",value:f.NoBlending},{title:"Normal",value:f.NormalBlending},{title:"Additive",value:f.AdditiveBlending},{title:"Subtractive",value:f.SubtractiveBlending},{title:"Multiply",value:f.MultiplyBlending},{title:"Custom",value:f.CustomBlending}],Hn=[{title:"Add",value:f.AddEquation},{title:"Subtract",value:f.SubtractEquation},{title:"Reverse Subtract",value:f.ReverseSubtractEquation},{title:"Min",value:f.MinEquation},{title:"Max",value:f.MaxEquation}],Vn=[{title:"Zero",value:f.ZeroFactor},{title:"One",value:f.OneFactor},{title:"Src Color",value:f.SrcColorFactor},{title:"One Minus Src Color",value:f.OneMinusSrcColorFactor},{title:"Src Alpha",value:f.SrcAlphaFactor},{title:"One Minus Src Alpha",value:f.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:f.DstAlphaFactor},{title:"One Minus Dst Alpha",value:f.OneMinusDstAlphaFactor},{title:"Dst Color",value:f.DstColorFactor},{title:"One Minus Dst Color",value:f.OneMinusDstColorFactor},{title:"Src Alpha Saturate",value:f.SrcAlphaSaturateFactor},{title:"Constant Color",value:f.ConstantColorFactor},{title:"One Minus Constant Color",value:f.OneMinusConstantColorFactor},{title:"Constant Alpha",value:f.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:f.OneMinusConstantAlphaFactor}],Yn=[{title:"Zero",value:f.ZeroFactor},{title:"One",value:f.OneFactor},{title:"Src Color",value:f.SrcColorFactor},{title:"One Minus Src Color",value:f.OneMinusSrcColorFactor},{title:"Src Alpha",value:f.SrcAlphaFactor},{title:"One Minus Src Alpha",value:f.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:f.DstAlphaFactor},{title:"One Minus Dst Alpha",value:f.OneMinusDstAlphaFactor},{title:"Dst Color",value:f.DstColorFactor},{title:"One Minus Dst Color",value:f.OneMinusDstColorFactor},{title:"Constant Color",value:f.ConstantColorFactor},{title:"One Minus Constant Color",value:f.OneMinusConstantColorFactor},{title:"Constant Alpha",value:f.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:f.OneMinusConstantAlphaFactor}];function At(i,e){i.needsUpdate=!0,i.type="option",i.options=e}function Gn(i,e,n,t){return{type:"boolean",title:ni(i),prop:i,value:e,needsUpdate:!0,onChange:(s,r)=>{t.updateObject(n.uuid,`material.${i}`,r),t.updateObject(n.uuid,"material.needsUpdate",!0);const o=t.getScene(n.uuid);if(o!==null){const a=o.getObjectByProperty("uuid",n.uuid);pe(a,`material.${i}`,r)}}}}function Zn(i,e,n,t){const s={type:"number",title:ni(i),prop:i,value:e,min:void 0,max:void 0,step:.01,needsUpdate:!0,onChange:(r,o)=>{t.updateObject(n.uuid,`material.${i}`,o),t.updateObject(n.uuid,"material.needsUpdate",!0);const a=t.getScene(n.uuid);if(a!==null){const d=a.getObjectByProperty("uuid",n.uuid);pe(d,`material.${i}`,o)}}};switch(i){case"blending":At(s,Bn);break;case"blendDst":At(s,Yn);break;case"blendEquation":At(s,Hn);break;case"blendSrc":At(s,Vn);break;case"side":At(s,zn);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 $n(i,e,n,t){const s={type:"string",title:ni(i),prop:i,value:e,needsUpdate:!0,onChange:(o,a)=>{t.updateObject(n.uuid,`material.${i}`,a),t.updateObject(n.uuid,"material.needsUpdate",!0);const d=t.getScene(n.uuid);if(d!==null){const c=d.getObjectByProperty("uuid",n.uuid);pe(c,`material.${i}`,a)}},onKeyDown:o=>{}};return(i==="vertexShader"||i==="fragmentShader")&&(s.disabled=!1,s.latest=s.value,s.onChange=(o,a)=>{s.latest=a,t.updateObject(n.uuid,`material.${i}`,a);const d=t.getScene(n.uuid);if(d!==null){const c=d.getObjectByProperty("uuid",n.uuid);pe(c,`material.${i}`,a)}},s.onKeyDown=o=>{if(o.key==="Enter"&&(o.altKey||o.metaKey)){t.updateObject(n.uuid,"material.needsUpdate",!0);const a=t.getScene(n.uuid);if(a!==null){const d=a.getObjectByProperty("uuid",n.uuid);pe(d,"material.needsUpdate",!0)}}}),s}function Wn(i){return i.x!==void 0&&i.y!==void 0&&i.z===void 0}function Kn(i){return i.x!==void 0&&i.y!==void 0&&i.z!==void 0&&i.w===void 0}function Xn(i){return i.x!==void 0&&i.y!==void 0&&i.z!==void 0&&i.w!==void 0}function bi(i){i.sort((e,n)=>e.title<n.title?-1:e.title>n.title?1:0)}function Ft(i,e,n,t,s="",r=!1){const o=ni(i).split(".")[0].replaceAll("[","").replaceAll("]",""),a=s.length>0?`${s}.${i}`:i,d=typeof e;if(d==="boolean"||d==="string")return{title:o,prop:a,type:d,value:e,disabled:r,onChange:(c,u)=>{t.updateObject(n.uuid,`material.${a}`,u);const p=t.getScene(n.uuid);if(p!==null){const _=p.getObjectByProperty("uuid",n.uuid);pe(_,`material.${a}`,u)}}};if(d==="number"){const c={title:o,prop:a,type:"number",value:e,step:.01,disabled:r,onChange:(u,p)=>{t.updateObject(n.uuid,`material.${a}`,p);const _=t.getScene(n.uuid);if(_!==null){const y=_.getObjectByProperty("uuid",n.uuid);pe(y,`material.${a}`,p)}}};return on(o)&&(c.type="range",c.min=0,c.max=1),c}else{if(e.isColor)return{title:o,prop:a,type:"color",value:e,disabled:r,onChange:(c,u)=>{const p=new f.Color(u);t.updateObject(n.uuid,`material.${a}`,p);const _=t.getScene(n.uuid);if(_!==null){const y=_.getObjectByProperty("uuid",n.uuid);pe(y,`material.${a}`,p)}}};if(Array.isArray(e)){const c=[];for(const u in e){const p=e[u],_=`[${u.toString()}]`;if(p.value!==void 0){const y=Ft(`${_}.value`,p.value,n,t,a,r);y!==void 0&&c.push(y)}else{const y=Ft(_,p,n,t,a,r);y!==void 0&&c.push(y)}}if(c.length>0)return bi(c),{title:o,items:c}}else{if(Wn(e))return{title:o,prop:a,type:"vector2",value:e,disabled:r,onChange:(c,u)=>{t.updateObject(n.uuid,`material.${a}`,u);const p=t.getScene(n.uuid);if(p!==null){const _=p.getObjectByProperty("uuid",n.uuid);pe(_,`material.${a}`,u)}}};if(Kn(e))return{title:o,prop:a,type:"grid3",value:e,disabled:r,onChange:(c,u)=>{t.updateObject(n.uuid,`material.${a}`,u);const p=t.getScene(n.uuid);if(p!==null){const _=p.getObjectByProperty("uuid",n.uuid);pe(_,`material.${a}`,u)}}};if(Xn(e))return{title:o,prop:a,type:"grid4",value:e,disabled:r,onChange:(c,u)=>{t.updateObject(n.uuid,`material.${a}`,u);const p=t.getScene(n.uuid);if(p!==null){const _=p.getObjectByProperty("uuid",n.uuid);pe(_,`material.${a}`,u)}}};if(e.isEuler)return{title:o,prop:a,type:"euler",value:e,disabled:r,onChange:(c,u)=>{t.updateObject(n.uuid,`material.${a}`,u);const p=t.getScene(n.uuid);if(p!==null){const _=p.getObjectByProperty("uuid",n.uuid);pe(_,`material.${a}`,u)}}};if(e.src!==void 0)return{title:o,type:"image",value:e,disabled:r,onChange:(c,u)=>{const p=jn(i),_=s.length>0?`${s}.${p}`:p;t.createTexture(n.uuid,`material.${_}`,u);const y=t.getScene(n.uuid);if(y!==null){const A=y.getObjectByProperty("uuid",n.uuid);if(A!==void 0){const I=F=>{const v=A.material,E=_.split(".");switch(E.length){case 1:v[E[0]]=F;break;case 2:v[E[0]][E[1]]=F;break;case 3:v[E[0]][E[1]][E[2]]=F;break;case 4:v[E[0]][E[1]][E[2]][E[3]]=F;break;case 5:v[E[0]][E[1]][E[2]][E[3]][E[4]]=F;break}v.needsUpdate=!0};u.src.length>0?tn(u.src).then(F=>{F.offset.set(u.offset[0],u.offset[1]),F.repeat.set(u.repeat[0],u.repeat[1]),I(F)}):I(null)}}}};if(e.elements!==void 0)return{title:o,prop:a,type:e.elements.length>9?"grid4":"grid3",value:e,disabled:r,onChange:(c,u)=>{t.updateObject(n.uuid,`material.${a}`,u);const p=t.getScene(n.uuid);if(p!==null){const _=p.getObjectByProperty("uuid",n.uuid);pe(_,`material.${a}`,u)}}};{const c=[],u=i==="defines"||i==="extensions";try{for(const p in e){const _=e[p];if(_!==void 0)if(_.value!==void 0){const y=Ft(`${p}.value`,_.value,n,t,a,u);y!==void 0&&c.push(y)}else{const y=Ft(p,_,n,t,a,u);y!==void 0&&c.push(y)}}}catch{console.log("Issue cycling through material object:",i,e)}if(c.length>0)return bi(c),{title:o,items:c}}}}}function Li(i,e,n){const t=[];for(const s in i){if(!Fn(s))continue;const r=typeof i[s],o=i[s];if(r==="boolean")t.push(Gn(s,o,e,n));else if(r==="number")t.push(Zn(s,o,e,n));else if(r==="string")t.push($n(s,o,e,n));else if(r==="object"){const a=Ft(s,o,e,n);a!==void 0&&t.push(a)}else o!==void 0&&console.log("other:",s,r,o)}return bi(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 r=s.getObjectByProperty("uuid",e.uuid);pe(r,"material.needsUpdate",!0)}}}),t}function qn(i,e){const n=i.material;if(Array.isArray(n)){const t=[],s=n.length;for(let r=0;r<s;r++)t.push(m.jsx(lt,{title:`Material ${r}`,items:Li(n[r],i,e)},`Material ${r}`));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 Jn(i){const e=i.step!==void 0?i.step:.01,n=T.useRef(null),t=T.useRef(null),s=T.useRef(null),r=T.useRef(null),o=T.useRef(null),[a]=T.useState(i.value),[d,c]=T.useState(i.value.offset[0]),[u,p]=T.useState(i.value.offset[1]),[_,y]=T.useState(i.value.repeat[0]),[A,I]=T.useState(i.value.repeat[1]);function F(E,w,C,U,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:[U,L]})}}function v(E){const w=n.current.src,C=E.target.value;switch(E.target){case t.current:c(C),F(w,C,u,_,A);break;case s.current:p(C),F(w,d,C,_,A);break;case r.current:y(C),F(w,d,u,C,A);break;case o.current:I(C),F(w,d,u,_,C);break}}return m.jsxs("div",{className:"imageField",children:[m.jsx("img",{alt:i.title,ref:n,onClick:()=>{Nn().then(E=>{n.current.src=E,F(E,d,u,_,A)})},src:a.src.length>0?a.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:d,step:e,onChange:v}),m.jsx("input",{ref:s,type:"number",value:u,step:e,onChange:v})]}),m.jsxs("div",{children:[m.jsx("label",{children:"Repeat:"}),m.jsx("input",{ref:r,type:"number",value:_,step:e,onChange:v}),m.jsx("input",{ref:o,type:"number",value:A,step:e,onChange:v})]}),m.jsx("button",{onClick:()=>{F("",d,u,_,A),n.current.src=Ii},children:"Clear"})]})]})}function Jt(i){let e=i.value;e!==void 0&&(e.isColor!==void 0?e=_i(i.value):i.type==="color"&&(e=_i(new f.Color(i.value))));const[n,t]=T.useState(e),s=T.useRef(null),r=c=>{let u=c.target.value;if(i.type==="boolean")u=c.target.checked;else if(i.type==="option"&&(typeof i.value=="number"?u=Number(u):typeof i.value=="boolean"?u=!!u:typeof i.value=="object"&&(u=JSON.parse(u)),i.options!==void 0)){const p=i.options.length;for(let _=0;_<p&&i.options[_].value!==u;_++);}t(u),i.onChange!==void 0&&i.onChange(i.prop!==void 0?i.prop:i.title,u)},o={};i.disabled&&(o.opacity=.8);const a=i.type==="string"&&(n.length>100||n.search(`
|
30
|
+
`)>-1),d=a||i.type==="image"||i.type==="vector2";return m.jsxs("div",{className:`field ${d?"block":""}`,style:o,children:[i.type!=="button"&&m.jsx("label",{ref:s,children:Nt(i.title)},"fieldLabel"),i.type==="string"&&!a&&m.jsx("input",{type:"text",disabled:i.disabled,onChange:r,value:n}),i.type==="string"&&a&&m.jsx("textarea",{cols:50,rows:10,disabled:i.disabled!==void 0?i.disabled:!0,onChange:r,onKeyDown:c=>{i.onKeyDown!==void 0&&i.onKeyDown(c)},value:n}),i.type==="boolean"&&m.jsx("input",{type:"checkbox",disabled:i.disabled,onChange:r,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:r,disabled:i.disabled,className:"color"}),m.jsx("input",{type:"color",value:n,onChange:r,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(Jn,{title:i.title,prop:i.prop,value:i.value,onChange:i.onChange}),i.type==="option"&&m.jsx(m.Fragment,{children:m.jsx("select",{onChange:r,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:r}),i.type==="grid3"&&m.jsx(Pi,{step:i.step,value:n,onChange:r}),i.type==="grid4"&&m.jsx(kn,{step:i.step,value:n,onChange:r}),i.type==="euler"&&m.jsx(Pi,{step:i.step,value:n,onChange:r})]})}function Qn(i){return"items"in i}function lt(i){const e=[];return i.items.forEach(n=>{Qn(n)?e.push(m.jsx(lt,{title:Nt(n.title),items:n.items},Math.random())):e.push(m.jsx(Jt,{title:n.title,prop:n.prop,value:n.value,type:n.type,min:n.min,max:n.max,step:n.step,disabled:n.disabled,options:n.options,onChange:(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 es(i){const[e]=T.useState([]),[n]=T.useState([]),[t,s]=T.useState(0);return T.useEffect(()=>{const r=a=>{const d=JSON.parse(a.value),c=[];d.items.forEach(u=>{c.push({type:u.type,prop:u.prop,title:u.title!==void 0?u.title:u.prop,value:u.value,min:u.min,max:u.max,step:u.step,options:u.options,disabled:u.disabled,onChange:(p,_)=>{i.three.updateGroup(d.title,p,_)}})}),e.push(m.jsx(lt,{title:d.title,items:c},Math.random())),n.push(d.title),s(Date.now())},o=a=>{const d=a.value,c=n.length;for(let u=0;u<c;u++)if(d===n[u]){e.splice(u,1),n.splice(u,1),s(Date.now());return}};return z.addEventListener(B.ADD_GROUP,r),z.addEventListener(B.REMOVE_GROUP,o),()=>{z.removeEventListener(B.ADD_GROUP,r),z.removeEventListener(B.REMOVE_GROUP,o)}},[]),m.jsx("div",{className:"customGroups",children:e},t)}function Ui(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 ts(i,e){const n=[];if(i.perspectiveCameraInfo!==void 0)for(const t in i.perspectiveCameraInfo)n.push({title:Ui(t),prop:t,type:"number",step:.01,value:i.perspectiveCameraInfo[t],onChange:(s,r)=>{e.updateObject(i.uuid,s,r),e.requestMethod(i.uuid,"updateProjectionMatrix");const o=e.getScene(i.uuid);if(o!==null){const a=o.getObjectByProperty("uuid",i.uuid);a!==void 0&&(pe(a,s,r),a.updateProjectionMatrix())}}});else if(i.orthographicCameraInfo!==void 0)for(const t in i.orthographicCameraInfo)n.push({title:Ui(t),prop:t,type:"number",step:.01,value:i.perspectiveCameraInfo[t],onChange:(s,r)=>{e.updateObject(i.uuid,s,r),e.requestMethod(i.uuid,"updateProjectionMatrix");const o=e.getScene(i.uuid);if(o!==null){const a=o.getObjectByProperty("uuid",i.uuid);a!==void 0&&(pe(a,s,r),a.updateProjectionMatrix())}}});return m.jsx(lt,{title:"Camera",items:n})}function is(i,e){const n=new f.Matrix4;n.elements=i.matrix;const t=new f.Vector3,s=new f.Euler,r=new f.Vector3;i.uuid.length>0&&(t.setFromMatrixPosition(n),s.setFromRotationMatrix(n),r.setFromMatrixScale(n));const o=(a,d)=>{const c=a==="rotation"?{x:d._x,y:d._y,z:d._z}:d;e.updateObject(i.uuid,a,c);const u=e.getScene(i.uuid);if(u!==null){const p=u.getObjectByProperty("uuid",i.uuid);pe(p,a,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:r,onChange:o},{title:"Visible",prop:"visible",type:"boolean",value:i.visible,onChange:o}]})}function ki(i){switch(i){case"color":return"Color";case"intensity":return"Intensity";case"decay":return"Decay";case"distance":return"Distance";case"angle":return"Angle";case"penumbra":return"Penumbra";case"groundColor":return"Ground Color";case"width":return"Width";case"height":return"Height"}return i}function ns(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:ki(t),prop:t,type:"color",value:s,onChange:(r,o)=>{const a=new f.Color(o);e.updateObject(i.uuid,r,a);const d=e.getScene(i.uuid);if(d!==null){const c=d.getObjectByProperty("uuid",i.uuid);pe(c,r,a)}}}):n.push({title:ki(t),prop:t,type:typeof s,value:s,step:typeof s=="number"?.01:void 0,onChange:(r,o)=>{e.updateObject(i.uuid,r,o);const a=e.getScene(i.uuid);if(a!==null){const d=a.getObjectByProperty("uuid",i.uuid);pe(d,r,o)}}}))}return m.jsx(lt,{title:"Light",items:n})}function ss(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 r=e.getScene(i.uuid);if(r!==null){const o=r.getObjectByProperty("uuid",i.uuid);let a=!1;if(o!==void 0){const d=o.mixer;if(a=d!==void 0,a){const c=[{title:"Time Scale",type:"range",value:d.timeScale,step:.01,min:-1,max:2,onChange:(u,p)=>{d.timeScale=p,e.updateObject(i.uuid,"mixer.timeScale",p)}}];c.push({title:"Stop All",type:"button",onChange:()=>{d.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 Re={...cn};function ln(i){const[e,n]=T.useState(-1);T.useEffect(()=>{function o(d){Re={...d.value},n(Date.now())}function a(){Re={...cn},n(Date.now())}return z.addEventListener(B.SET_SCENE,a),z.addEventListener(B.SET_OBJECT,o),()=>{z.removeEventListener(B.SET_SCENE,a),z.removeEventListener(B.SET_OBJECT,o)}},[]);const t=Re.type.toLowerCase(),s=Re.animations.length>0||Re.mixer!==void 0,r=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:Re.uuid.length>0&&m.jsxs(m.Fragment,{children:[m.jsxs(m.Fragment,{children:[m.jsx(Jt,{type:"string",title:"Name",prop:"name",value:Re.name,disabled:!0}),m.jsx(Jt,{type:"string",title:"Type",prop:"type",value:Re.type,disabled:!0}),m.jsx(Jt,{type:"string",title:"UUID",prop:"uuid",value:Re.uuid,disabled:!0})]}),m.jsxs(m.Fragment,{children:[is(Re,i.three),s?ss(Re,i.three):null,t.search("camera")>-1?ts(Re,i.three):null,t.search("light")>-1?ns(Re,i.three):null,r?qn(Re,i.three):null]})]})},e)},"Inspector")}function hn(i){const[e]=T.useState([]),[n]=T.useState([]),[t,s]=T.useState(0),r=d=>{const c=d.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(Oi,{child:c,scene:c,three:i.three})},Math.random())),s(Date.now())},o=d=>{const c=d.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(Oi,{child:c,scene:c,three:i.three})},Math.random()),s(Date.now());return}},a=d=>{const c=d.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(()=>(z.addEventListener(B.ADD_SCENE,r),z.addEventListener(B.REFRESH_SCENE,o),z.addEventListener(B.REMOVE_SCENE,a),()=>{z.removeEventListener(B.ADD_SCENE,r),z.removeEventListener(B.REFRESH_SCENE,o),z.removeEventListener(B.REMOVE_SCENE,a)}),[]),m.jsxs("div",{id:"SidePanel",children:[m.jsx("div",{className:"scenes",children:n},t),m.jsx(ln,{three:i.three}),m.jsx(es,{three:i.three})]})}function rs(i){return T.useEffect(()=>{function e(a){let d=null;return i.three.scenes.forEach(c=>{a.search(c.uuid)>-1&&(d=c)}),d}const n=a=>{const d=a.value,u=e(d)?.getObjectByProperty("uuid",d);u!==void 0&&i.three.setObject(u)},t=(a,d,c)=>{const p=e(a)?.getObjectByProperty("uuid",a);p!==void 0&&pe(p,d,c)},s=a=>{const d=a.value,{key:c,value:u,uuid:p}=d;t(p,c,u)},r=a=>{const d=a.value,u=e(d.uuid)?.getObjectByProperty("uuid",d.uuid);if(u!==void 0){const p=_=>{const y=d.key.split(".");switch(y.length){case 1:u[y[0]]=_;break;case 2:u[y[0]][y[1]]=_;break;case 3:u[y[0]][y[1]][y[2]]=_;break;case 4:u[y[0]][y[1]][y[2]][y[3]]=_;break;case 5:u[y[0]][y[1]][y[2]][y[3]][y[4]]=_;break}u.material.needsUpdate=!0};d.value.src.length>0?tn(d.value.src).then(_=>{_.offset.set(d.value.offset[0],d.value.offset[1]),_.repeat.set(d.value.repeat[0],d.value.repeat[1]),p(_)}):p(null)}},o=a=>{const{key:d,uuid:c,value:u,subitem:p}=a.value,y=e(c)?.getObjectByProperty("uuid",c);if(y!==void 0)try{p!==void 0?Sn(y,p)[d](u):y[d](u)}catch(A){console.log("Error requesting method:"),console.log(A),console.log(d),console.log(u)}};return z.addEventListener(B.GET_OBJECT,n),z.addEventListener(B.UPDATE_OBJECT,s),z.addEventListener(B.CREATE_TEXTURE,r),z.addEventListener(B.REQUEST_METHOD,o),()=>{z.removeEventListener(B.GET_OBJECT,n),z.removeEventListener(B.UPDATE_OBJECT,s),z.removeEventListener(B.CREATE_TEXTURE,r),z.removeEventListener(B.REQUEST_METHOD,o)}},[]),null}class as extends f.Line{constructor(e,n){const t=[1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],s=new f.BufferGeometry;s.setAttribute("position",new f.Float32BufferAttribute(t,3)),s.computeBoundingSphere();const r=new f.LineBasicMaterial({fog:!1});super(s,r),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],a=new f.BufferGeometry;a.setAttribute("position",new f.Float32BufferAttribute(o,3)),a.computeBoundingSphere(),this.add(new f.Mesh(a,new f.MeshBasicMaterial({side:f.BackSide,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),this.color!==void 0)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const 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"},oi={type:"start"},ji={type:"end"},Zt=new f.Ray,Ni=new f.Plane,os=Math.cos(70*f.MathUtils.DEG2RAD);class cs extends f.EventDispatcher{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new f.Vector3,this.cursor=new f.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:f.MOUSE.ROTATE,MIDDLE:f.MOUSE.DOLLY,RIGHT:f.MOUSE.PAN},this.touches={ONE:f.TOUCH.ROTATE,TWO:f.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return a.phi},this.getAzimuthalAngle=function(){return a.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(h){h.addEventListener("keydown",Pe),this._domElementKeyEvents=h},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(),r=s.NONE},this.update=function(){const h=new f.Vector3,R=new f.Quaternion().setFromUnitVectors(e.up,new f.Vector3(0,1,0)),$=R.clone().invert(),ee=new f.Vector3,Oe=new f.Quaternion,je=new f.Vector3,Se=2*Math.PI;return function(Vt=null){const Yt=t.object.position;h.copy(Yt).sub(t.target),h.applyQuaternion(R),a.setFromVector3(h),t.autoRotate&&r===s.NONE&&Ue($e(Vt)),t.enableDamping?(a.theta+=d.theta*t.dampingFactor,a.phi+=d.phi*t.dampingFactor):(a.theta+=d.theta,a.phi+=d.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?a.theta=Math.max(Ne,Math.min(ze,a.theta)):a.theta=a.theta>(Ne+ze)/2?Math.max(Ne,a.theta):Math.min(ze,a.theta)),a.phi=Math.max(t.minPolarAngle,Math.min(t.maxPolarAngle,a.phi)),a.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)a.radius=Qe(a.radius);else{const Ge=a.radius;a.radius=Qe(a.radius*c),ut=Ge!=a.radius}if(h.setFromSpherical(a),h.applyQuaternion($),Yt.copy(t.target).add(h),t.object.lookAt(t.target),t.enableDamping===!0?(d.theta*=1-t.dampingFactor,d.phi*=1-t.dampingFactor,u.multiplyScalar(1-t.dampingFactor)):(d.set(0,0,0),u.set(0,0,0)),t.zoomToCursor&&L){let Ge=null;if(t.object.isPerspectiveCamera){const at=h.length();Ge=Qe(at*c);const vt=at-Ge;t.object.position.addScaledVector(C,vt),t.object.updateMatrixWorld(),ut=!!vt}else if(t.object.isOrthographicCamera){const at=new f.Vector3(U.x,U.y,0);at.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 Gt=new f.Vector3(U.x,U.y,0);Gt.unproject(t.object),t.object.position.sub(Gt).add(at),t.object.updateMatrixWorld(),Ge=h.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):(Zt.origin.copy(t.object.position),Zt.direction.set(0,0,-1).transformDirection(t.object.matrix),Math.abs(t.object.up.dot(Zt.direction))<os?e.lookAt(t.target):(Ni.setFromNormalAndCoplanarPoint(t.object.up,t.target),Zt.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-Oe.dot(t.object.quaternion))>o||je.distanceToSquared(t.target)>o?(t.dispatchEvent(Fi),ee.copy(t.object.position),Oe.copy(t.object.quaternion),je.copy(t.target),!0):!1}}(),this.dispose=function(){t.domElement.removeEventListener("contextmenu",We),t.domElement.removeEventListener("pointerdown",be),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 r=s.NONE;const o=1e-6,a=new f.Spherical,d=new f.Spherical;let c=1;const u=new f.Vector3,p=new f.Vector2,_=new f.Vector2,y=new f.Vector2,A=new f.Vector2,I=new f.Vector2,F=new f.Vector2,v=new f.Vector2,E=new f.Vector2,w=new f.Vector2,C=new f.Vector3,U=new f.Vector2;let L=!1;const x=[],oe={};let te=!1;function $e(h){return h!==null?2*Math.PI/60*t.autoRotateSpeed*h:2*Math.PI/60/60*t.autoRotateSpeed}function j(h){const R=Math.abs(h*.01);return Math.pow(.95,t.zoomSpeed*R)}function Ue(h){d.theta-=h}function ye(h){d.phi-=h}const Ce=function(){const h=new f.Vector3;return function($,ee){h.setFromMatrixColumn(ee,0),h.multiplyScalar(-$),u.add(h)}}(),Te=function(){const h=new f.Vector3;return function($,ee){t.screenSpacePanning===!0?h.setFromMatrixColumn(ee,1):(h.setFromMatrixColumn(ee,0),h.crossVectors(t.object.up,h)),h.multiplyScalar($),u.add(h)}}(),ke=function(){const h=new f.Vector3;return function($,ee){const Oe=t.domElement;if(t.object.isPerspectiveCamera){const je=t.object.position;h.copy(je).sub(t.target);let Se=h.length();Se*=Math.tan(t.object.fov/2*Math.PI/180),Ce(2*$*Se/Oe.clientHeight,t.object.matrix),Te(2*ee*Se/Oe.clientHeight,t.object.matrix)}else t.object.isOrthographicCamera?(Ce($*(t.object.right-t.object.left)/t.object.zoom/Oe.clientWidth,t.object.matrix),Te(ee*(t.object.top-t.object.bottom)/t.object.zoom/Oe.clientHeight,t.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),t.enablePan=!1)}}();function Ve(h){t.object.isPerspectiveCamera||t.object.isOrthographicCamera?c/=h:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),t.enableZoom=!1)}function it(h){t.object.isPerspectiveCamera||t.object.isOrthographicCamera?c*=h:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),t.enableZoom=!1)}function Je(h,R){if(!t.zoomToCursor)return;L=!0;const $=t.domElement.getBoundingClientRect(),ee=h-$.left,Oe=R-$.top,je=$.width,Se=$.height;U.x=ee/je*2-1,U.y=-(Oe/Se)*2+1,C.set(U.x,U.y,1).unproject(t.object).sub(t.object.position).normalize()}function Qe(h){return Math.max(t.minDistance,Math.min(t.maxDistance,h))}function ht(h){p.set(h.clientX,h.clientY)}function nt(h){Je(h.clientX,h.clientX),v.set(h.clientX,h.clientY)}function ge(h){A.set(h.clientX,h.clientY)}function Ye(h){_.set(h.clientX,h.clientY),y.subVectors(_,p).multiplyScalar(t.rotateSpeed);const R=t.domElement;Ue(2*Math.PI*y.x/R.clientHeight),ye(2*Math.PI*y.y/R.clientHeight),p.copy(_),t.update()}function Mt(h){E.set(h.clientX,h.clientY),w.subVectors(E,v),w.y>0?Ve(j(w.y)):w.y<0&&it(j(w.y)),v.copy(E),t.update()}function dt(h){I.set(h.clientX,h.clientY),F.subVectors(I,A).multiplyScalar(t.panSpeed),ke(F.x,F.y),A.copy(I),t.update()}function Me(h){Je(h.clientX,h.clientY),h.deltaY<0?it(j(h.deltaY)):h.deltaY>0&&Ve(j(h.deltaY)),t.update()}function O(h){let R=!1;switch(h.code){case t.keys.UP:h.ctrlKey||h.metaKey||h.shiftKey?ye(2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):ke(0,t.keyPanSpeed),R=!0;break;case t.keys.BOTTOM:h.ctrlKey||h.metaKey||h.shiftKey?ye(-2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):ke(0,-t.keyPanSpeed),R=!0;break;case t.keys.LEFT:h.ctrlKey||h.metaKey||h.shiftKey?Ue(2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):ke(t.keyPanSpeed,0),R=!0;break;case t.keys.RIGHT:h.ctrlKey||h.metaKey||h.shiftKey?Ue(-2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):ke(-t.keyPanSpeed,0),R=!0;break}R&&(h.preventDefault(),t.update())}function S(h){if(x.length===1)p.set(h.pageX,h.pageY);else{const R=rt(h),$=.5*(h.pageX+R.x),ee=.5*(h.pageY+R.y);p.set($,ee)}}function P(h){if(x.length===1)A.set(h.pageX,h.pageY);else{const R=rt(h),$=.5*(h.pageX+R.x),ee=.5*(h.pageY+R.y);A.set($,ee)}}function N(h){const R=rt(h),$=h.pageX-R.x,ee=h.pageY-R.y,Oe=Math.sqrt($*$+ee*ee);v.set(0,Oe)}function ue(h){t.enableZoom&&N(h),t.enablePan&&P(h)}function X(h){t.enableZoom&&N(h),t.enableRotate&&S(h)}function D(h){if(x.length==1)_.set(h.pageX,h.pageY);else{const $=rt(h),ee=.5*(h.pageX+$.x),Oe=.5*(h.pageY+$.y);_.set(ee,Oe)}y.subVectors(_,p).multiplyScalar(t.rotateSpeed);const R=t.domElement;Ue(2*Math.PI*y.x/R.clientHeight),ye(2*Math.PI*y.y/R.clientHeight),p.copy(_)}function k(h){if(x.length===1)I.set(h.pageX,h.pageY);else{const R=rt(h),$=.5*(h.pageX+R.x),ee=.5*(h.pageY+R.y);I.set($,ee)}F.subVectors(I,A).multiplyScalar(t.panSpeed),ke(F.x,F.y),A.copy(I)}function me(h){const R=rt(h),$=h.pageX-R.x,ee=h.pageY-R.y,Oe=Math.sqrt($*$+ee*ee);E.set(0,Oe),w.set(0,Math.pow(E.y/v.y,t.zoomSpeed)),Ve(w.y),v.copy(E);const je=(h.pageX+R.x)*.5,Se=(h.pageY+R.y)*.5;Je(je,Se)}function Ee(h){t.enableZoom&&me(h),t.enablePan&&k(h)}function et(h){t.enableZoom&&me(h),t.enableRotate&&D(h)}function be(h){t.enabled!==!1&&(x.length===0&&(t.domElement.setPointerCapture(h.pointerId),t.domElement.addEventListener("pointermove",xe),t.domElement.addEventListener("pointerup",Ae)),!ri(h)&&(_t(h),h.pointerType==="touch"?Fe(h):se(h)))}function xe(h){t.enabled!==!1&&(h.pointerType==="touch"?st(h):_e(h))}function Ae(h){switch(si(h),x.length){case 0:t.domElement.releasePointerCapture(h.pointerId),t.domElement.removeEventListener("pointermove",xe),t.domElement.removeEventListener("pointerup",Ae),t.dispatchEvent(ji),r=s.NONE;break;case 1:const R=x[0],$=oe[R];Fe({pointerId:R,pageX:$.x,pageY:$.y});break}}function se(h){let R;switch(h.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 f.MOUSE.DOLLY:if(t.enableZoom===!1)return;nt(h),r=s.DOLLY;break;case f.MOUSE.ROTATE:if(h.ctrlKey||h.metaKey||h.shiftKey){if(t.enablePan===!1)return;ge(h),r=s.PAN}else{if(t.enableRotate===!1)return;ht(h),r=s.ROTATE}break;case f.MOUSE.PAN:if(h.ctrlKey||h.metaKey||h.shiftKey){if(t.enableRotate===!1)return;ht(h),r=s.ROTATE}else{if(t.enablePan===!1)return;ge(h),r=s.PAN}break;default:r=s.NONE}r!==s.NONE&&t.dispatchEvent(oi)}function _e(h){switch(r){case s.ROTATE:if(t.enableRotate===!1)return;Ye(h);break;case s.DOLLY:if(t.enableZoom===!1)return;Mt(h);break;case s.PAN:if(t.enablePan===!1)return;dt(h);break}}function G(h){t.enabled===!1||t.enableZoom===!1||r!==s.NONE||(h.preventDefault(),t.dispatchEvent(oi),Me(H(h)),t.dispatchEvent(ji))}function H(h){const R=h.deltaMode,$={clientX:h.clientX,clientY:h.clientY,deltaY:h.deltaY};switch(R){case 1:$.deltaY*=16;break;case 2:$.deltaY*=100;break}return h.ctrlKey&&!te&&($.deltaY*=10),$}function q(h){h.key==="Control"&&(te=!0,t.domElement.getRootNode().addEventListener("keyup",Q,{passive:!0,capture:!0}))}function Q(h){h.key==="Control"&&(te=!1,t.domElement.getRootNode().removeEventListener("keyup",Q,{passive:!0,capture:!0}))}function Pe(h){t.enabled===!1||t.enablePan===!1||O(h)}function Fe(h){switch(Ht(h),x.length){case 1:switch(t.touches.ONE){case f.TOUCH.ROTATE:if(t.enableRotate===!1)return;S(h),r=s.TOUCH_ROTATE;break;case f.TOUCH.PAN:if(t.enablePan===!1)return;P(h),r=s.TOUCH_PAN;break;default:r=s.NONE}break;case 2:switch(t.touches.TWO){case f.TOUCH.DOLLY_PAN:if(t.enableZoom===!1&&t.enablePan===!1)return;ue(h),r=s.TOUCH_DOLLY_PAN;break;case f.TOUCH.DOLLY_ROTATE:if(t.enableZoom===!1&&t.enableRotate===!1)return;X(h),r=s.TOUCH_DOLLY_ROTATE;break;default:r=s.NONE}break;default:r=s.NONE}r!==s.NONE&&t.dispatchEvent(oi)}function st(h){switch(Ht(h),r){case s.TOUCH_ROTATE:if(t.enableRotate===!1)return;D(h),t.update();break;case s.TOUCH_PAN:if(t.enablePan===!1)return;k(h),t.update();break;case s.TOUCH_DOLLY_PAN:if(t.enableZoom===!1&&t.enablePan===!1)return;Ee(h),t.update();break;case s.TOUCH_DOLLY_ROTATE:if(t.enableZoom===!1&&t.enableRotate===!1)return;et(h),t.update();break;default:r=s.NONE}}function We(h){t.enabled!==!1&&h.preventDefault()}function _t(h){x.push(h.pointerId)}function si(h){delete oe[h.pointerId];for(let R=0;R<x.length;R++)if(x[R]==h.pointerId){x.splice(R,1);return}}function ri(h){for(let R=0;R<x.length;R++)if(x[R]==h.pointerId)return!0;return!1}function Ht(h){let R=oe[h.pointerId];R===void 0&&(R=new f.Vector2,oe[h.pointerId]=R),R.set(h.pageX,h.pageY)}function rt(h){const R=h.pointerId===x[0]?x[1]:x[0];return oe[R]}t.domElement.addEventListener("contextmenu",We),t.domElement.addEventListener("pointerdown",be),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 ls=Math.PI/180;function Ot(i,e,n,t,s){return t+(i-e)*(s-t)/(n-e)}function zi(i){return i*ls}/*!
|
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 de={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}),bt={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 he(i,e=dn){return Math.abs(i)<e}function re(i,e,n=dn){return he(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,r){t=Math.max(1e-4,t);const o=2/t,a=o*r,d=1/(1+a+.48*a*a+.235*a*a*a);let c=i-e;const u=e,p=s*t;c=Ze(c,-p,p),e=i-c;const _=(n.value+o*c)*r;n.value=(n.value-o*_)*d;let y=e+(c+_)*d;return u-i>0==y>u&&(y=u,n.value=(y-u)/r),y}function Vi(i,e,n,t,s=1/0,r,o){t=Math.max(1e-4,t);const a=2/t,d=a*r,c=1/(1+d+.48*d*d+.235*d*d*d);let u=e.x,p=e.y,_=e.z,y=i.x-u,A=i.y-p,I=i.z-_;const F=u,v=p,E=_,w=s*t,C=w*w,U=y*y+A*A+I*I;if(U>C){const Te=Math.sqrt(U);y=y/Te*w,A=A/Te*w,I=I/Te*w}u=i.x-y,p=i.y-A,_=i.z-I;const L=(n.x+a*y)*r,x=(n.y+a*A)*r,oe=(n.z+a*I)*r;n.x=(n.x-a*L)*c,n.y=(n.y-a*x)*c,n.z=(n.z-a*oe)*c,o.x=u+(y+L)*c,o.y=p+(A+x)*c,o.z=_+(I+oe)*c;const te=F-i.x,$e=v-i.y,j=E-i.z,Ue=o.x-F,ye=o.y-v,Ce=o.z-E;return te*Ue+$e*ye+j*Ce>0&&(o.x=F,o.y=v,o.z=E,n.x=(o.x-F)/r,n.y=(o.y-v)/r,n.z=(o.z-E)/r),o}function li(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 hs{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 r=s.indexOf(n);r!==-1&&s.splice(r,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 r=0,o=s.length;r<o;r++)s[r].call(this,e)}}}var di;const ds="2.9.0",Kt=1/8,us=/Mac/.test((di=globalThis?.navigator)===null||di===void 0?void 0:di.platform);let V,Yi,Xt,ui,De,Z,ie,Tt,Ut,Ke,Xe,ft,Gi,Zi,He,kt,xt,$i,mi,Wi,fi,pi,qt;class qe extends hs{static install(e){V=e.THREE,Yi=Object.freeze(new V.Vector3(0,0,0)),Xt=Object.freeze(new V.Vector3(0,1,0)),ui=Object.freeze(new V.Vector3(0,0,1)),De=new V.Vector2,Z=new V.Vector3,ie=new V.Vector3,Tt=new V.Vector3,Ut=new V.Vector3,Ke=new V.Vector3,Xe=new V.Vector3,ft=new V.Vector3,Gi=new V.Vector3,Zi=new V.Vector3,He=new V.Spherical,kt=new V.Spherical,xt=new V.Box3,$i=new V.Box3,mi=new V.Sphere,Wi=new V.Quaternion,fi=new V.Quaternion,pi=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=bt.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=(v,E,w)=>{let C,U;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*v*oe/this._elementRect.height,U=this.truckSpeed*E*oe/this._elementRect.height}else if(ot(this._camera)){const L=this._camera;C=v*(L.right-L.left)/L.zoom/this._elementRect.width,U=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(-U,!0)):w?this.setFocalOffset(this._focalOffsetEnd.x+C,this._focalOffsetEnd.y+U,this._focalOffsetEnd.z,!0):this.truck(C,U,!0)},this._rotateInternal=(v,E)=>{const w=Ct*this.azimuthRotateSpeed*v/this._elementRect.height,C=Ct*this.polarRotateSpeed*E/this._elementRect.height;this.rotate(w,C,!0)},this._dollyInternal=(v,E,w)=>{const C=Math.pow(.95,-v*this.dollySpeed),U=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)-U,this._dollyControlCoord.set(E,w)),this._lastDollyDirection=Math.sign(-v)},this._zoomInternal=(v,E,w)=>{const C=Math.pow(.95,v*this.dollySpeed),U=this._zoom,L=this._zoom*C;this.zoomTo(L,!0),this.dollyToCursor&&(this._changedZoom+=L-U,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,r=new V.Vector2,o=v=>{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(),U=v.clientX/C.width,L=v.clientY/C.height;if(U<this._interactiveArea.left||U>this._interactiveArea.right||L<this._interactiveArea.top||L>this._interactiveArea.bottom)return}const E=v.pointerType!=="mouse"?null:(v.buttons&de.LEFT)===de.LEFT?de.LEFT:(v.buttons&de.MIDDLE)===de.MIDDLE?de.MIDDLE:(v.buttons&de.RIGHT)===de.RIGHT?de.RIGHT:null;if(E!==null){const C=this._findPointerByMouseButton(E);C&&this._disposePointer(C)}if((v.buttons&de.LEFT)===de.LEFT&&this._lockedPointer)return;const w={pointerId:v.pointerId,clientX:v.clientX,clientY:v.clientY,deltaX:0,deltaY:0,mouseButton:E};this._activePointers.push(w),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",d),this._isDragging=!0,_(v)},a=v=>{v.cancelable&&v.preventDefault();const E=v.pointerId,w=this._lockedPointer||this._findPointerById(E);if(w){if(w.clientX=v.clientX,w.clientY=v.clientY,w.deltaX=v.movementX,w.deltaY=v.movementY,this._state=0,v.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&&(v.buttons&de.LEFT)===de.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(v.buttons&de.MIDDLE)===de.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(v.buttons&de.RIGHT)===de.RIGHT&&(this._state=this._state|this.mouseButtons.right);y()}},d=v=>{const E=this._findPointerById(v.pointerId);if(!(E&&E===this._lockedPointer)){if(E&&this._disposePointer(E),v.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=v=>{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=v.clientX/L.width,oe=v.clientY/L.height;if(x<this._interactiveArea.left||x>this._interactiveArea.right||oe<this._interactiveArea.top||oe>this._interactiveArea.bottom)return}if(v.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=us?-1:-3,w=v.deltaMode===1?v.deltaY/E:v.deltaY/(E*10),C=this.dollyToCursor?(v.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,U=this.dollyToCursor?(v.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case g.ROTATE:{this._rotateInternal(v.deltaX,v.deltaY),this._isUserControllingRotate=!0;break}case g.TRUCK:{this._truckInternal(v.deltaX,v.deltaY,!1),this._isUserControllingTruck=!0;break}case g.OFFSET:{this._truckInternal(v.deltaX,v.deltaY,!0),this._isUserControllingOffset=!0;break}case g.DOLLY:{this._dollyInternal(-w,C,U),this._isUserControllingDolly=!0;break}case g.ZOOM:{this._zoomInternal(-w,C,U),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},p=v=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===qe.ACTION.NONE){const E=v instanceof PointerEvent?v.pointerId:0,w=this._findPointerById(E);w&&this._disposePointer(w),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d);return}v.preventDefault()}},_=v=>{if(!this._enabled)return;if(li(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,U=Math.sqrt(w*w+C*C);r.set(0,U);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,!v)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in v&&v.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&&(v.buttons&de.LEFT)===de.LEFT&&(this._state=this._state|this.mouseButtons.left),(v.buttons&de.MIDDLE)===de.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(v.buttons&de.RIGHT)===de.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,li(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 U=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,U,L),this._isUserControllingDolly=!0):(this._zoomInternal(x*C*Kt,U,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 U=De.x-this._activePointers[1].clientX,L=De.y-this._activePointers[1].clientY,x=Math.sqrt(U*U+L*L),oe=r.y-x;r.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=()=>{li(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",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d),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",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",I),this._domElement.ownerDocument.addEventListener("pointerlockerror",F),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",d),_())},this.unlockPointer=()=>{var v,E,w;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(v=this._domElement)===null||v===void 0||v.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=v=>{this._domElement=v,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",o),this._domElement.addEventListener("pointercancel",d),this._domElement.addEventListener("wheel",u,{passive:!1}),this._domElement.addEventListener("contextmenu",p)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",o),this._domElement.removeEventListener("pointercancel",d),this._domElement.removeEventListener("wheel",u,{passive:!1}),this._domElement.removeEventListener("contextmenu",p),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d),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),r=Ze(n,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=s,this._sphericalEnd.phi=r,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,t||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const o=!t||re(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&re(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=bt.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(),a=re(o,this._spherical.radius);if(!(t>e)&&a)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 r=!n||re(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(r)}dollyInFixed(e,n=!1){this._targetEnd.add(this._getCameraDirection(Ut).multiplyScalar(e)),n||this._target.copy(this._targetEnd);const t=!n||re(this._target.x,this._targetEnd.x,this.restThreshold)&&re(this._target.y,this._targetEnd.y,this.restThreshold)&&re(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||re(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),r=ie.copy(this._targetEnd).add(s);return this.moveTo(r.x,r.y,r.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 r=Z.set(e,n,t).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,r,this.boundaryFriction),this._needsUpdate=!0,s||this._target.copy(this._targetEnd);const o=!s||re(this._target.x,this._targetEnd.x,this.restThreshold)&&re(this._target.y,this._targetEnd.y,this.restThreshold)&&re(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(o)}lookInDirectionOf(e,n,t,s=!1){const a=Z.set(e,n,t).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(a.x,a.y,a.z,s)}fitToBox(e,n,{cover:t=!1,paddingLeft:s=0,paddingRight:r=0,paddingBottom:o=0,paddingTop:a=0}={}){const d=[],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),p=Hi(this._sphericalEnd.phi,Bi);d.push(this.rotateTo(u,p,n));const _=Z.setFromSpherical(this._sphericalEnd).normalize(),y=Wi.setFromUnitVectors(_,ui),A=re(Math.abs(_.y),1);A&&y.multiply(fi.setFromAxisAngle(Xt,u)),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+=r,I.max.y+=a,y.setFromUnitVectors(ui,_),A&&y.premultiply(fi.invert()),y.premultiply(this._yAxisUpSpace);const F=I.getSize(Z),v=I.getCenter(ie).applyQuaternion(y);if(mt(this._camera)){const E=this.getDistanceToFitBox(F.x,F.y,F.z,t);d.push(this.moveTo(v.x,v.y,v.z,n)),d.push(this.dollyTo(E,n)),d.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,U=t?Math.max(w/F.x,C/F.y):Math.min(w/F.x,C/F.y);d.push(this.moveTo(v.x,v.y,v.z,n)),d.push(this.zoomTo(U,n)),d.push(this.setFocalOffset(0,0,0,n))}return Promise.all(d)}fitToSphere(e,n){const t=[],r="isObject3D"in e?qe.createBoundingSphere(e,mi):mi.copy(e);if(t.push(this.moveTo(r.center.x,r.center.y,r.center.z,n)),mt(this._camera)){const o=this.getDistanceToFitSphere(r.radius);t.push(this.dollyTo(o,n))}else if(ot(this._camera)){const o=this._camera.right-this._camera.left,a=this._camera.top-this._camera.bottom,d=2*r.radius,c=Math.min(o/d,a/d);t.push(this.zoomTo(c,n))}return t.push(this.setFocalOffset(0,0,0,n)),Promise.all(t)}setLookAt(e,n,t,s,r,o,a=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=bt.NONE,this._changedDolly=0;const d=ie.set(s,r,o),c=Z.set(e,n,t);this._targetEnd.copy(d),this._sphericalEnd.setFromVector3(c.sub(d).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,a||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const u=!a||re(this._target.x,this._targetEnd.x,this.restThreshold)&&re(this._target.y,this._targetEnd.y,this.restThreshold)&&re(this._target.z,this._targetEnd.z,this.restThreshold)&&re(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&re(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&re(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(u)}lerpLookAt(e,n,t,s,r,o,a,d,c,u,p,_,y,A=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=bt.NONE,this._changedDolly=0;const I=Z.set(s,r,o),F=ie.set(e,n,t);He.setFromVector3(F.sub(I).applyQuaternion(this._yAxisUpSpace));const v=Tt.set(u,p,_),E=ie.set(a,d,c);kt.setFromVector3(E.sub(v).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(I.lerp(v,y));const w=kt.theta-He.theta,C=kt.phi-He.phi,U=kt.radius-He.radius;this._sphericalEnd.set(He.radius+U*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||re(this._target.x,this._targetEnd.x,this.restThreshold)&&re(this._target.y,this._targetEnd.y,this.restThreshold)&&re(this._target.z,this._targetEnd.z,this.restThreshold)&&re(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&re(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&re(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 r=this.getPosition(Z),o=this.setLookAt(r.x,r.y,r.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 r=!s||re(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&re(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&re(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}setOrbitPoint(e,n,t){this._camera.updateMatrixWorld(),Ke.setFromMatrixColumn(this._camera.matrixWorldInverse,0),Xe.setFromMatrixColumn(this._camera.matrixWorldInverse,1),ft.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const s=Z.set(e,n,t),r=s.distanceTo(this._camera.position),o=s.sub(this._camera.position);Ke.multiplyScalar(o.x),Xe.multiplyScalar(o.y),ft.multiplyScalar(o.z),Z.copy(Ke).add(Xe).add(ft),Z.z=Z.z+r,this.dollyTo(r,!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 r=e/n,o=this._camera.getEffectiveFOV()*Pt,a=this._camera.aspect;return((s?r>a:r<a)?n:e/a)*.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(!re(this._camera.up.x,this._cameraUp0.x)||!re(this._camera.up.y,this._cameraUp0.y)||!re(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,r=Gi.subVectors(this._targetEnd,this._target),o=Zi.subVectors(this._focalOffsetEnd,this._focalOffset),a=this._zoomEnd-this._zoom;if(he(n))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const p=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=Wt(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,p,1/0,e),this._needsUpdate=!0}if(he(t))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const p=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=Wt(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,p,1/0,e),this._needsUpdate=!0}if(he(s))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const p=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=Wt(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,p,this.maxSpeed,e),this._needsUpdate=!0}if(he(r.x)&&he(r.y)&&he(r.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const p=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Vi(this._target,this._targetEnd,this._targetVelocity,p,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(he(o.x)&&he(o.y)&&he(o.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const p=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Vi(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,p,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(he(a))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const p=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=Wt(this._zoom,this._zoomEnd,this._zoomVelocity,p,1/0,e)}if(this.dollyToCursor){if(mt(this._camera)&&this._changedDolly!==0){const p=this._spherical.radius-this._lastDistance,_=this._camera,y=this._getCameraDirection(Ut),A=Z.copy(y).cross(_.up).normalize();A.lengthSq()===0&&(A.x=1);const I=ie.crossVectors(A,y),F=this._sphericalEnd.radius*Math.tan(_.getEffectiveFOV()*Pt*.5),E=(this._sphericalEnd.radius-p-this._sphericalEnd.radius)/this._sphericalEnd.radius,w=Tt.copy(this._targetEnd).add(A.multiplyScalar(this._dollyControlCoord.x*F*_.aspect)).add(I.multiplyScalar(this._dollyControlCoord.y*F)),C=Z.copy(this._targetEnd).lerp(w,E),U=this._lastDollyDirection===bt.IN&&this._spherical.radius<=this.minDistance,L=this._lastDollyDirection===bt.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(U||L)){this._sphericalEnd.radius-=p,this._spherical.radius-=p;const oe=ie.copy(y).multiplyScalar(-p);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-=p,he(this._changedDolly)&&(this._changedDolly=0)}else if(ot(this._camera)&&this._changedZoom!==0){const p=this._zoom-this._lastZoom,_=this._camera,y=Z.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(_.near+_.far)/(_.near-_.far)).unproject(_),A=ie.set(0,0,-1).applyQuaternion(_.quaternion),I=Tt.copy(y).add(A.multiplyScalar(-y.dot(_.up))),v=-(this._zoom-p-this._zoom)/this._zoom,E=this._getCameraDirection(Ut),w=this._targetEnd.dot(E),C=Z.copy(this._targetEnd).lerp(I,v),U=C.dot(E),L=E.multiplyScalar(U-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-=p,he(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 d=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,d),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!he(this._focalOffset.x)||!he(this._focalOffset.y)||!he(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),Ke.setFromMatrixColumn(this._camera.matrix,0),Xe.setFromMatrixColumn(this._camera.matrix,1),ft.setFromMatrixColumn(this._camera.matrix,2),Ke.multiplyScalar(this._focalOffset.x),Xe.multiplyScalar(-this._focalOffset.y),ft.multiplyScalar(this._focalOffset.z),Z.copy(Ke).add(Xe).add(ft),this._camera.position.add(Z)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),Z.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"}),he(n,this.restThreshold)&&he(t,this.restThreshold)&&he(s,this.restThreshold)&&he(r.x,this.restThreshold)&&he(r.y,this.restThreshold)&&he(r.z,this.restThreshold)&&he(o.x,this.restThreshold)&&he(o.y,this.restThreshold)&&he(o.z,this.restThreshold)&&he(a,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: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",ds),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 r=ie.copy(n).add(e),a=this._boundary.clampPoint(r,Tt).sub(r),d=a.lengthSq();if(d===0)return e.add(n);if(d===s)return e;if(t===0)return e.add(n).add(a);{const c=1+t*d/n.dot(a);return e.add(ie.copy(n).multiplyScalar(c)).add(a.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,r=s*e.aspect;this._nearPlaneCorners[0].set(-r,-s,0),this._nearPlaneCorners[1].set(r,-s,0),this._nearPlaneCorners[2].set(r,s,0),this._nearPlaneCorners[3].set(-r,s,0)}else if(ot(this._camera)){const e=this._camera,n=1/e.zoom,t=e.left*n,s=e.right*n,r=e.top*n,o=e.bottom*n;this._nearPlaneCorners[0].set(t,r,0),this._nearPlaneCorners[1].set(s,r,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(Ut);pi.lookAt(Yi,t,this._camera.up);for(let s=0;s<4;s++){const r=ie.copy(this._nearPlaneCorners[s]);r.applyMatrix4(pi);const o=Tt.addVectors(this._target,r);qt.set(o,t),qt.far=this._spherical.radius+1;const a=qt.intersectObjects(this.colliderMeshes);a.length!==0&&a[0].distance<e&&(e=a[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 r=0;return e.traverseVisible(o=>{if(!o.isMesh)return;const a=o,d=a.geometry.clone();d.applyMatrix4(a.matrixWorld);const u=d.attributes.position;for(let p=0,_=u.count;p<_;p++)Z.fromBufferAttribute(u,p),r=Math.max(r,s.distanceToSquared(Z))}),t.radius=Math.sqrt(r),t}}const ii=i=>{const[e,n]=T.useState(i.options[i.index]),t=()=>{i.onToggle(!i.open)},s=r=>{r!==e&&(i.onSelect(r),n(r)),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(r=>m.jsx("li",{onClick:()=>s(r),children:r},r))})]})},pt=T.forwardRef(function(e,n){const t=["Renderer","Depth","Normals","UVs","Wireframe"],[s,r]=T.useState("Renderer"),[o,a]=T.useState(!1),[d,c]=T.useState(!1),[u,p]=T.useState(!1);return m.jsxs("div",{className:"CameraWindow",children:[m.jsx("div",{ref:n,className:"clickable",onClick:()=>{u&&p(!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:_=>{p(_)},up:!0}),m.jsx(ii,{title:"Mode",index:t.indexOf(s),open:d,options:t,onSelect:_=>{if(_===s)return;const y=_;e.onSelectRenderMode(y),r(y)},onToggle:_=>{o&&a(!1),c(_)},up:!0})]})]})});class ms extends f.ShaderMaterial{constructor(e){super({extensions:{derivatives:!0},glslVersion:f.GLSL3,side:f.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 f.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 de={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}),bt={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 he(i,e=dn){return Math.abs(i)<e}function re(i,e,n=dn){return he(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 $t(i,e,n,t,s=1/0,r){t=Math.max(1e-4,t);const o=2/t,a=o*r,d=1/(1+a+.48*a*a+.235*a*a*a);let c=i-e;const u=e,p=s*t;c=Ze(c,-p,p),e=i-c;const _=(n.value+o*c)*r;n.value=(n.value-o*_)*d;let y=e+(c+_)*d;return u-i>0==y>u&&(y=u,n.value=(y-u)/r),y}function Vi(i,e,n,t,s=1/0,r,o){t=Math.max(1e-4,t);const a=2/t,d=a*r,c=1/(1+d+.48*d*d+.235*d*d*d);let u=e.x,p=e.y,_=e.z,y=i.x-u,A=i.y-p,I=i.z-_;const F=u,v=p,E=_,w=s*t,C=w*w,U=y*y+A*A+I*I;if(U>C){const Te=Math.sqrt(U);y=y/Te*w,A=A/Te*w,I=I/Te*w}u=i.x-y,p=i.y-A,_=i.z-I;const L=(n.x+a*y)*r,x=(n.y+a*A)*r,oe=(n.z+a*I)*r;n.x=(n.x-a*L)*c,n.y=(n.y-a*x)*c,n.z=(n.z-a*oe)*c,o.x=u+(y+L)*c,o.y=p+(A+x)*c,o.z=_+(I+oe)*c;const te=F-i.x,$e=v-i.y,j=E-i.z,Ue=o.x-F,ye=o.y-v,Ce=o.z-E;return te*Ue+$e*ye+j*Ce>0&&(o.x=F,o.y=v,o.z=E,n.x=(o.x-F)/r,n.y=(o.y-v)/r,n.z=(o.z-E)/r),o}function ci(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 li(i,e){return ot(i)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class hs{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 r=s.indexOf(n);r!==-1&&s.splice(r,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 r=0,o=s.length;r<o;r++)s[r].call(this,e)}}}var hi;const ds="2.9.0",Wt=1/8,us=/Mac/.test((hi=globalThis?.navigator)===null||hi===void 0?void 0:hi.platform);let V,Yi,Kt,di,De,Z,ie,Tt,Ut,Ke,Xe,ft,Gi,Zi,He,kt,xt,$i,ui,Wi,mi,fi,Xt;class qe extends hs{static install(e){V=e.THREE,Yi=Object.freeze(new V.Vector3(0,0,0)),Kt=Object.freeze(new V.Vector3(0,1,0)),di=Object.freeze(new V.Vector3(0,0,1)),De=new V.Vector2,Z=new V.Vector3,ie=new V.Vector3,Tt=new V.Vector3,Ut=new V.Vector3,Ke=new V.Vector3,Xe=new V.Vector3,ft=new V.Vector3,Gi=new V.Vector3,Zi=new V.Vector3,He=new V.Spherical,kt=new V.Spherical,xt=new V.Box3,$i=new V.Box3,ui=new V.Sphere,Wi=new V.Quaternion,mi=new V.Quaternion,fi=new V.Matrix4,Xt=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=bt.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=(v,E,w)=>{let C,U;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*v*oe/this._elementRect.height,U=this.truckSpeed*E*oe/this._elementRect.height}else if(ot(this._camera)){const L=this._camera;C=v*(L.right-L.left)/L.zoom/this._elementRect.width,U=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(-U,!0)):w?this.setFocalOffset(this._focalOffsetEnd.x+C,this._focalOffsetEnd.y+U,this._focalOffsetEnd.z,!0):this.truck(C,U,!0)},this._rotateInternal=(v,E)=>{const w=Ct*this.azimuthRotateSpeed*v/this._elementRect.height,C=Ct*this.polarRotateSpeed*E/this._elementRect.height;this.rotate(w,C,!0)},this._dollyInternal=(v,E,w)=>{const C=Math.pow(.95,-v*this.dollySpeed),U=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)-U,this._dollyControlCoord.set(E,w)),this._lastDollyDirection=Math.sign(-v)},this._zoomInternal=(v,E,w)=>{const C=Math.pow(.95,v*this.dollySpeed),U=this._zoom,L=this._zoom*C;this.zoomTo(L,!0),this.dollyToCursor&&(this._changedZoom+=L-U,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,Kt),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,r=new V.Vector2,o=v=>{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(),U=v.clientX/C.width,L=v.clientY/C.height;if(U<this._interactiveArea.left||U>this._interactiveArea.right||L<this._interactiveArea.top||L>this._interactiveArea.bottom)return}const E=v.pointerType!=="mouse"?null:(v.buttons&de.LEFT)===de.LEFT?de.LEFT:(v.buttons&de.MIDDLE)===de.MIDDLE?de.MIDDLE:(v.buttons&de.RIGHT)===de.RIGHT?de.RIGHT:null;if(E!==null){const C=this._findPointerByMouseButton(E);C&&this._disposePointer(C)}if((v.buttons&de.LEFT)===de.LEFT&&this._lockedPointer)return;const w={pointerId:v.pointerId,clientX:v.clientX,clientY:v.clientY,deltaX:0,deltaY:0,mouseButton:E};this._activePointers.push(w),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",d),this._isDragging=!0,_(v)},a=v=>{v.cancelable&&v.preventDefault();const E=v.pointerId,w=this._lockedPointer||this._findPointerById(E);if(w){if(w.clientX=v.clientX,w.clientY=v.clientY,w.deltaX=v.movementX,w.deltaY=v.movementY,this._state=0,v.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&&(v.buttons&de.LEFT)===de.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(v.buttons&de.MIDDLE)===de.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(v.buttons&de.RIGHT)===de.RIGHT&&(this._state=this._state|this.mouseButtons.right);y()}},d=v=>{const E=this._findPointerById(v.pointerId);if(!(E&&E===this._lockedPointer)){if(E&&this._disposePointer(E),v.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=v=>{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=v.clientX/L.width,oe=v.clientY/L.height;if(x<this._interactiveArea.left||x>this._interactiveArea.right||oe<this._interactiveArea.top||oe>this._interactiveArea.bottom)return}if(v.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=us?-1:-3,w=v.deltaMode===1?v.deltaY/E:v.deltaY/(E*10),C=this.dollyToCursor?(v.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,U=this.dollyToCursor?(v.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case g.ROTATE:{this._rotateInternal(v.deltaX,v.deltaY),this._isUserControllingRotate=!0;break}case g.TRUCK:{this._truckInternal(v.deltaX,v.deltaY,!1),this._isUserControllingTruck=!0;break}case g.OFFSET:{this._truckInternal(v.deltaX,v.deltaY,!0),this._isUserControllingOffset=!0;break}case g.DOLLY:{this._dollyInternal(-w,C,U),this._isUserControllingDolly=!0;break}case g.ZOOM:{this._zoomInternal(-w,C,U),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},p=v=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===qe.ACTION.NONE){const E=v instanceof PointerEvent?v.pointerId:0,w=this._findPointerById(E);w&&this._disposePointer(w),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d);return}v.preventDefault()}},_=v=>{if(!this._enabled)return;if(ci(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,U=Math.sqrt(w*w+C*C);r.set(0,U);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,!v)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in v&&v.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&&(v.buttons&de.LEFT)===de.LEFT&&(this._state=this._state|this.mouseButtons.left),(v.buttons&de.MIDDLE)===de.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(v.buttons&de.RIGHT)===de.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,ci(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 U=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*Wt,U,L),this._isUserControllingDolly=!0):(this._zoomInternal(x*C*Wt,U,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 U=De.x-this._activePointers[1].clientX,L=De.y-this._activePointers[1].clientY,x=Math.sqrt(U*U+L*L),oe=r.y-x;r.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*Wt,te,$e),this._isUserControllingDolly=!0):(this._zoomInternal(oe*Wt,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=()=>{ci(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",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d),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",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",I),this._domElement.ownerDocument.addEventListener("pointerlockerror",F),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",d),_())},this.unlockPointer=()=>{var v,E,w;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(v=this._domElement)===null||v===void 0||v.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=v=>{this._domElement=v,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",o),this._domElement.addEventListener("pointercancel",d),this._domElement.addEventListener("wheel",u,{passive:!1}),this._domElement.addEventListener("contextmenu",p)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",o),this._domElement.removeEventListener("pointercancel",d),this._domElement.removeEventListener("wheel",u,{passive:!1}),this._domElement.removeEventListener("contextmenu",p),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d),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),r=Ze(n,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=s,this._sphericalEnd.phi=r,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,t||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const o=!t||re(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&re(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=bt.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(),a=re(o,this._spherical.radius);if(!(t>e)&&a)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 r=!n||re(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(r)}dollyInFixed(e,n=!1){this._targetEnd.add(this._getCameraDirection(Ut).multiplyScalar(e)),n||this._target.copy(this._targetEnd);const t=!n||re(this._target.x,this._targetEnd.x,this.restThreshold)&&re(this._target.y,this._targetEnd.y,this.restThreshold)&&re(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||re(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),r=ie.copy(this._targetEnd).add(s);return this.moveTo(r.x,r.y,r.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 r=Z.set(e,n,t).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,r,this.boundaryFriction),this._needsUpdate=!0,s||this._target.copy(this._targetEnd);const o=!s||re(this._target.x,this._targetEnd.x,this.restThreshold)&&re(this._target.y,this._targetEnd.y,this.restThreshold)&&re(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(o)}lookInDirectionOf(e,n,t,s=!1){const a=Z.set(e,n,t).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(a.x,a.y,a.z,s)}fitToBox(e,n,{cover:t=!1,paddingLeft:s=0,paddingRight:r=0,paddingBottom:o=0,paddingTop:a=0}={}){const d=[],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),p=Hi(this._sphericalEnd.phi,Bi);d.push(this.rotateTo(u,p,n));const _=Z.setFromSpherical(this._sphericalEnd).normalize(),y=Wi.setFromUnitVectors(_,di),A=re(Math.abs(_.y),1);A&&y.multiply(mi.setFromAxisAngle(Kt,u)),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+=r,I.max.y+=a,y.setFromUnitVectors(di,_),A&&y.premultiply(mi.invert()),y.premultiply(this._yAxisUpSpace);const F=I.getSize(Z),v=I.getCenter(ie).applyQuaternion(y);if(mt(this._camera)){const E=this.getDistanceToFitBox(F.x,F.y,F.z,t);d.push(this.moveTo(v.x,v.y,v.z,n)),d.push(this.dollyTo(E,n)),d.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,U=t?Math.max(w/F.x,C/F.y):Math.min(w/F.x,C/F.y);d.push(this.moveTo(v.x,v.y,v.z,n)),d.push(this.zoomTo(U,n)),d.push(this.setFocalOffset(0,0,0,n))}return Promise.all(d)}fitToSphere(e,n){const t=[],r="isObject3D"in e?qe.createBoundingSphere(e,ui):ui.copy(e);if(t.push(this.moveTo(r.center.x,r.center.y,r.center.z,n)),mt(this._camera)){const o=this.getDistanceToFitSphere(r.radius);t.push(this.dollyTo(o,n))}else if(ot(this._camera)){const o=this._camera.right-this._camera.left,a=this._camera.top-this._camera.bottom,d=2*r.radius,c=Math.min(o/d,a/d);t.push(this.zoomTo(c,n))}return t.push(this.setFocalOffset(0,0,0,n)),Promise.all(t)}setLookAt(e,n,t,s,r,o,a=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=bt.NONE,this._changedDolly=0;const d=ie.set(s,r,o),c=Z.set(e,n,t);this._targetEnd.copy(d),this._sphericalEnd.setFromVector3(c.sub(d).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,a||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const u=!a||re(this._target.x,this._targetEnd.x,this.restThreshold)&&re(this._target.y,this._targetEnd.y,this.restThreshold)&&re(this._target.z,this._targetEnd.z,this.restThreshold)&&re(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&re(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&re(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(u)}lerpLookAt(e,n,t,s,r,o,a,d,c,u,p,_,y,A=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=bt.NONE,this._changedDolly=0;const I=Z.set(s,r,o),F=ie.set(e,n,t);He.setFromVector3(F.sub(I).applyQuaternion(this._yAxisUpSpace));const v=Tt.set(u,p,_),E=ie.set(a,d,c);kt.setFromVector3(E.sub(v).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(I.lerp(v,y));const w=kt.theta-He.theta,C=kt.phi-He.phi,U=kt.radius-He.radius;this._sphericalEnd.set(He.radius+U*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||re(this._target.x,this._targetEnd.x,this.restThreshold)&&re(this._target.y,this._targetEnd.y,this.restThreshold)&&re(this._target.z,this._targetEnd.z,this.restThreshold)&&re(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&re(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&re(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 r=this.getPosition(Z),o=this.setLookAt(r.x,r.y,r.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 r=!s||re(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&re(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&re(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}setOrbitPoint(e,n,t){this._camera.updateMatrixWorld(),Ke.setFromMatrixColumn(this._camera.matrixWorldInverse,0),Xe.setFromMatrixColumn(this._camera.matrixWorldInverse,1),ft.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const s=Z.set(e,n,t),r=s.distanceTo(this._camera.position),o=s.sub(this._camera.position);Ke.multiplyScalar(o.x),Xe.multiplyScalar(o.y),ft.multiplyScalar(o.z),Z.copy(Ke).add(Xe).add(ft),Z.z=Z.z+r,this.dollyTo(r,!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(li(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const r=e/n,o=this._camera.getEffectiveFOV()*Pt,a=this._camera.aspect;return((s?r>a:r<a)?n:e/a)*.5/Math.tan(o*.5)+t*.5}getDistanceToFitSphere(e){if(li(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(!re(this._camera.up.x,this._cameraUp0.x)||!re(this._camera.up.y,this._cameraUp0.y)||!re(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,Kt),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,r=Gi.subVectors(this._targetEnd,this._target),o=Zi.subVectors(this._focalOffsetEnd,this._focalOffset),a=this._zoomEnd-this._zoom;if(he(n))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const p=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=$t(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,p,1/0,e),this._needsUpdate=!0}if(he(t))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const p=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=$t(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,p,1/0,e),this._needsUpdate=!0}if(he(s))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const p=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=$t(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,p,this.maxSpeed,e),this._needsUpdate=!0}if(he(r.x)&&he(r.y)&&he(r.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const p=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Vi(this._target,this._targetEnd,this._targetVelocity,p,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(he(o.x)&&he(o.y)&&he(o.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const p=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Vi(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,p,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(he(a))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const p=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=$t(this._zoom,this._zoomEnd,this._zoomVelocity,p,1/0,e)}if(this.dollyToCursor){if(mt(this._camera)&&this._changedDolly!==0){const p=this._spherical.radius-this._lastDistance,_=this._camera,y=this._getCameraDirection(Ut),A=Z.copy(y).cross(_.up).normalize();A.lengthSq()===0&&(A.x=1);const I=ie.crossVectors(A,y),F=this._sphericalEnd.radius*Math.tan(_.getEffectiveFOV()*Pt*.5),E=(this._sphericalEnd.radius-p-this._sphericalEnd.radius)/this._sphericalEnd.radius,w=Tt.copy(this._targetEnd).add(A.multiplyScalar(this._dollyControlCoord.x*F*_.aspect)).add(I.multiplyScalar(this._dollyControlCoord.y*F)),C=Z.copy(this._targetEnd).lerp(w,E),U=this._lastDollyDirection===bt.IN&&this._spherical.radius<=this.minDistance,L=this._lastDollyDirection===bt.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(U||L)){this._sphericalEnd.radius-=p,this._spherical.radius-=p;const oe=ie.copy(y).multiplyScalar(-p);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-=p,he(this._changedDolly)&&(this._changedDolly=0)}else if(ot(this._camera)&&this._changedZoom!==0){const p=this._zoom-this._lastZoom,_=this._camera,y=Z.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(_.near+_.far)/(_.near-_.far)).unproject(_),A=ie.set(0,0,-1).applyQuaternion(_.quaternion),I=Tt.copy(y).add(A.multiplyScalar(-y.dot(_.up))),v=-(this._zoom-p-this._zoom)/this._zoom,E=this._getCameraDirection(Ut),w=this._targetEnd.dot(E),C=Z.copy(this._targetEnd).lerp(I,v),U=C.dot(E),L=E.multiplyScalar(U-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-=p,he(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 d=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,d),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!he(this._focalOffset.x)||!he(this._focalOffset.y)||!he(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),Ke.setFromMatrixColumn(this._camera.matrix,0),Xe.setFromMatrixColumn(this._camera.matrix,1),ft.setFromMatrixColumn(this._camera.matrix,2),Ke.multiplyScalar(this._focalOffset.x),Xe.multiplyScalar(-this._focalOffset.y),ft.multiplyScalar(this._focalOffset.z),Z.copy(Ke).add(Xe).add(ft),this._camera.position.add(Z)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),Z.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"}),he(n,this.restThreshold)&&he(t,this.restThreshold)&&he(s,this.restThreshold)&&he(r.x,this.restThreshold)&&he(r.y,this.restThreshold)&&he(r.z,this.restThreshold)&&he(o.x,this.restThreshold)&&he(o.y,this.restThreshold)&&he(o.z,this.restThreshold)&&he(a,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: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",ds),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 r=ie.copy(n).add(e),a=this._boundary.clampPoint(r,Tt).sub(r),d=a.lengthSq();if(d===0)return e.add(n);if(d===s)return e;if(t===0)return e.add(n).add(a);{const c=1+t*d/n.dot(a);return e.add(ie.copy(n).multiplyScalar(c)).add(a.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,r=s*e.aspect;this._nearPlaneCorners[0].set(-r,-s,0),this._nearPlaneCorners[1].set(r,-s,0),this._nearPlaneCorners[2].set(r,s,0),this._nearPlaneCorners[3].set(-r,s,0)}else if(ot(this._camera)){const e=this._camera,n=1/e.zoom,t=e.left*n,s=e.right*n,r=e.top*n,o=e.bottom*n;this._nearPlaneCorners[0].set(t,r,0),this._nearPlaneCorners[1].set(s,r,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)||li(this._camera,"_collisionTest"))return e;const t=this._getTargetDirection(Ut);fi.lookAt(Yi,t,this._camera.up);for(let s=0;s<4;s++){const r=ie.copy(this._nearPlaneCorners[s]);r.applyMatrix4(fi);const o=Tt.addVectors(this._target,r);Xt.set(o,t),Xt.far=this._spherical.radius+1;const a=Xt.intersectObjects(this.colliderMeshes);a.length!==0&&a[0].distance<e&&(e=a[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 r=0;return e.traverseVisible(o=>{if(!o.isMesh)return;const a=o,d=a.geometry.clone();d.applyMatrix4(a.matrixWorld);const u=d.attributes.position;for(let p=0,_=u.count;p<_;p++)Z.fromBufferAttribute(u,p),r=Math.max(r,s.distanceToSquared(Z))}),t.radius=Math.sqrt(r),t}}const ti=i=>{const[e,n]=T.useState(i.options[i.index]),t=()=>{i.onToggle(!i.open)},s=r=>{r!==e&&(i.onSelect(r),n(r)),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(r=>m.jsx("li",{onClick:()=>s(r),children:r},r))})]})},pt=T.forwardRef(function(e,n){const t=["Renderer","Depth","Normals","UVs","Wireframe"],[s,r]=T.useState("Renderer"),[o,a]=T.useState(!1),[d,c]=T.useState(!1),[u,p]=T.useState(!1);return m.jsxs("div",{className:"CameraWindow",children:[m.jsx("div",{ref:n,className:"clickable",onClick:()=>{u&&p(!1)}}),m.jsxs("div",{className:"options",children:[m.jsx(ti,{title:"Camera",index:e.options.indexOf(e.camera.name),open:u,options:e.options,onSelect:e.onSelectCamera,onToggle:_=>{p(_)},up:!0}),m.jsx(ti,{title:"Mode",index:t.indexOf(s),open:d,options:t,onSelect:_=>{if(_===s)return;const y=_;e.onSelectRenderMode(y),r(y)},onToggle:_=>{o&&a(!1),c(_)},up:!0})]})]})});class ms extends f.ShaderMaterial{constructor(e){super({extensions:{derivatives:!0},glslVersion:f.GLSL3,side:f.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 f.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() {
|
@@ -146,4 +146,4 @@ void main() {
|
|
146
146
|
void main() {
|
147
147
|
#include <clipping_planes_fragment>
|
148
148
|
gl_FragColor = vec4(vec3(vUv, 0.0), 1.0);
|
149
|
-
}`;class _s extends f.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:ps,fragmentShader:gs})}}let ae,gi=!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,[]),r=T.useMemo(()=>new Map,[]),o=T.useMemo(()=>new f.Scene,[]),a=T.useMemo(()=>new f.Group,[]),d=T.useMemo(()=>new fs,[]),c=T.useMemo(()=>new f.AxesHelper(500),[]),u=T.useMemo(()=>new f.AxesHelper(100),[]),p=T.useMemo(()=>new f.MeshDepthMaterial,[]),_=T.useMemo(()=>new f.MeshNormalMaterial,[]),y=T.useMemo(()=>new _s,[]),A=T.useMemo(()=>new f.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0}),[]);function I(O,S){const P=new f.OrthographicCamera(-100,100,100,-100,50,5e3);return P.name=O,P.position.copy(S),P.lookAt(0,0,0),n.set(O,P),P}const F=["Single","Side by Side","Stacked","Quad"],v=T.useRef(null),E=T.useRef(null),w=T.useRef(null),C=T.useRef(null),U=T.useRef(null),L=T.useRef(null),x=localStorage,oe=x.getItem(`${e}_mode`),[te,$e]=T.useState(oe!==null?oe:"Single"),[j,Ue]=T.useState(null),[ye,Ce]=T.useState(!1),[Te,ke]=T.useState(!1),[Ve,it]=T.useState("Orbit"),[Je,Qe]=T.useState(!1),[ht,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=(O,S)=>{const P=t.get(O.name);if(P!==void 0&&P.dispose(),t.delete(O.name),O.name==="UI")return;const N=new cs(O,S);switch(N.enableDamping=!0,N.dampingFactor=.05,O.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":N.enableRotate=!1;break}t.set(O.name,N)},Ye=O=>{const S=s.get(O.name);S!==void 0&&(o.remove(S),S.dispose(),s.delete(O.name));const P=t.get(O.name);P!==void 0&&(P.dispose(),t.delete(O.name))},Mt=()=>{t.forEach((O,S)=>{O.dispose();const P=s.get(S);P!==void 0&&(o.remove(P),P.dispose()),s.delete(S),t.delete(S)}),t.clear(),s.clear()},dt=()=>{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,U.current),ge(Ie,L.current);break}};T.useEffect(()=>{const O=new f.WebGLRenderer({canvas:v.current,stencil:!1});O.autoClear=!1,O.shadowMap.enabled=!0,O.setPixelRatio(devicePixelRatio),O.setClearColor(0),i.three.renderer=O,Ue(O)},[]),T.useEffect(()=>{o.name="Debug Scene",o.uuid="",a.name="helpers",o.add(a),a.add(d),c.name="axisHelper",a.add(c),u.name="interactionHelper",a.add(u),u.visible=!1,I("Top",new f.Vector3(0,1e3,0)),I("Bottom",new f.Vector3(0,-1e3,0)),I("Left",new f.Vector3(-1e3,0,0)),I("Right",new f.Vector3(1e3,0,0)),I("Front",new f.Vector3(0,0,1e3)),I("Back",new f.Vector3(0,0,-1e3)),I("Orthographic",new f.Vector3(1e3,1e3,1e3)),I("UI",new f.Vector3);const O=new f.PerspectiveCamera(60,1,50,5e3);O.name="Debug",O.position.set(500,500,500),O.lookAt(0,0,0),n.set("Debug",O),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 O=()=>{r.forEach(D=>{a.remove(D),D.dispose()}),r.clear()},S=()=>{ae.traverse(D=>{if(D.type.search("Light")>-1){let k;switch(D.type){case"DirectionalLight":k=new f.DirectionalLightHelper(D,100),k.name=`${D.name}Helper`,r.set(D.name,k),a.add(k);break;case"HemisphereLight":k=new f.HemisphereLightHelper(D,250),k.name=`${D.name}Helper`,r.set(D.name,k),a.add(k);break;case"RectAreaLight":k=new as(D),k.name=`${D.name}Helper`,r.set(D.name,k),a.add(k);break;case"PointLight":k=new f.PointLightHelper(D,100),k.name=`${D.name}Helper`,r.set(D.name,k),a.add(k);break;case"SpotLight":k=new f.SpotLightHelper(D),k.name=`${D.name}Helper`,r.set(D.name,k),a.add(k);break}}})},P=D=>{a.add(c),O(),zt(ae),o.remove(ae);const k=i.scenes.get(D.value.name);if(k!==void 0){const me=new k;i.onSceneSet!==void 0&&i.onSceneSet(me),ae=me,i.three.scene=ae,o.add(ae),gi=!0,S()}},N=D=>{const k=D.value,me=i.three.scene?.getObjectByProperty("uuid",k.uuid);if(me!==void 0&&n.set(k.name,me),me instanceof f.PerspectiveCamera){const Ee=new f.CameraHelper(me);s.set(me.name,Ee),o.add(Ee)}nt(Date.now())},ue=D=>{const k=s.get(D.value.name);k!==void 0&&(o.remove(k),k.dispose()),n.delete(D.value.name),nt(Date.now())},X=D=>{const k=ae.getObjectByProperty("uuid",D.value.uuid);k&&k.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 O=window.innerWidth,S=window.innerHeight,P=Math.floor(O/2),N=Math.floor(S/2),ue=-1;const X=new f.BufferGeometry,D=new f.MeshBasicMaterial,k=new f.Group,me=()=>{O=window.innerWidth-300,S=window.innerHeight,P=Math.floor(O/2),N=Math.floor(S/2),i.three.resize(O,S),i.onSceneResize!==void 0&&gi&&i.onSceneResize(ae,O,S);let se=O,_e=S;switch(te){case"Side by Side":se=P,_e=S;break;case"Stacked":se=O,_e=N;break;case"Quad":se=P,_e=N;break}const G=se/_e;n.forEach(H=>{H instanceof f.OrthographicCamera?(H.left=se/-2,H.right=se/2,H.top=_e/2,H.bottom=_e/-2,H.name==="UI"&&(H.position.x=O/2,H.position.y=S/-2,H.position.z=100),H.updateProjectionMatrix()):H instanceof f.PerspectiveCamera&&(H.aspect=G,H.updateProjectionMatrix(),s.get(H.name)?.update())})};function Ee(se){switch(se){case"Depth":return p;case"Normals":return _;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,O,S),j.setScissor(0,0,O,S),ae?.onBeforeRender(j,ae,K,X,D,k),j.render(o,K)},be=()=>{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),ae?.onBeforeRender(j,ae,K,X,D,k),j.render(o,K),o.overrideMaterial=_e,j.setViewport(P,0,P,S),j.setScissor(P,0,P,S),ae?.onBeforeRender(j,ae,le,X,D,k),j.render(o,le);else{const G=S-N;j.setViewport(0,G,O,N),j.setScissor(0,G,O,N),ae?.onBeforeRender(j,ae,K,X,D,k),j.render(o,K),o.overrideMaterial=_e,j.setViewport(0,0,O,N),j.setScissor(0,0,O,N),ae?.onBeforeRender(j,ae,le,X,D,k),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),ae?.onBeforeRender(j,ae,K,X,D,k),j.render(o,K),q=P,o.overrideMaterial=_e,j.setViewport(q,Q,P,N),j.setScissor(q,Q,P,N),ae?.onBeforeRender(j,ae,le,X,D,k),j.render(o,le),Q=0,q=0,o.overrideMaterial=G,j.setViewport(q,Q,P,N),j.setScissor(q,Q,P,N),ae?.onBeforeRender(j,ae,Le,X,D,k),j.render(o,Le),q=P,o.overrideMaterial=H,j.setViewport(q,Q,P,N),j.setScissor(q,Q,P,N),ae?.onBeforeRender(j,ae,Ie,X,D,k),j.render(o,Ie)},Ae=()=>{switch(t.forEach(se=>{se.update()}),s.forEach(se=>{se.update()}),r.forEach(se=>{se.update!==void 0&&se.update()}),i.onSceneUpdate!==void 0&&gi&&i.onSceneUpdate(ae),j.clear(),te){case"Single":et();break;case"Side by Side":case"Stacked":be();break;case"Quad":xe();break}ue=requestAnimationFrame(Ae)};return dt(),window.addEventListener("resize",me),me(),Ae(),()=>{window.removeEventListener("resize",me),cancelAnimationFrame(ue),ue=-1}},[te,j]),T.useEffect(()=>{if(j!==null){const O={Vector2:f.Vector2,Vector3:f.Vector3,Vector4:f.Vector4,Quaternion:f.Quaternion,Matrix4:f.Matrix4,Spherical:f.Spherical,Box3:f.Box3,Sphere:f.Sphere,Raycaster:f.Raycaster};qe.install({THREE:O});const S=new f.Raycaster,P=new f.Vector2;let N=K,ue=w,X,D,k=-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=U:N===Ie&&(ue=L)},Ee=G=>{const H=new f.Vector2;j.getSize(H);const q=Math.min(G.clientX,H.x),Q=Math.min(G.clientY,H.y);P.x=Ot(q,0,H.x,-1,1),P.y=Ot(Q,0,H.y,1,-1);const Pe=H.x/2,Fe=H.y/2,st=()=>{q<Pe?P.x=Ot(q,0,Pe,-1,1):P.x=Ot(q,Pe,H.x,-1,1)},We=()=>{Q<Fe?P.y=Ot(Q,0,Fe,1,-1):P.y=Ot(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(ae.children);_t.length>0&&u.position.copy(_t[0].point)},et=G=>{if(Ve==="Orbit")return;const H=new f.Vector2;if(j.getSize(H),G.clientX>=H.x)return;Ee(G);const q=S.intersectObjects(ae.children);q.length>0&&(i.three.getObject(q[0].object.uuid),u.visible=!1,it("Orbit"),nt(Date.now()))},be=(G,H=!1)=>{if(X===void 0)return;cancelAnimationFrame(k),k=-1,D&&(D.smoothTime=.1);const q=.15,Q=new f.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(k),k=-1,xe()):k=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 f.Mesh||X instanceof f.SkinnedMesh?(X.geometry.computeBoundingBox(),D.fitToBox(X.geometry.boundingBox,!0)):D.fitToSphere(X,!0),be(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),be(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),be(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),be(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),be(H)):G.key==="5"&&(xe(),D=new qe(N,ue.current),D.rotateTo(zi(45),zi(45),!0),be(H))}},se=G=>{X=ae.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((O,S)=>{Me.push(S)}),m.jsxs("div",{className:"multiview",children:[m.jsx("canvas",{ref:v}),j!==null&&m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:`cameras ${te==="Single"||te==="Stacked"?"single":""}`,ref:E,children:[te==="Single"&&m.jsx(m.Fragment,{children:m.jsx(pt,{camera:K,options:Me,ref:w,onSelectCamera:O=>{t.get(K.name)?.dispose();const S=n.get(O);S!==void 0&&(Ye(K),K=S,x.setItem(`${e}_tlCam`,S.name),ge(S,w.current))},onSelectRenderMode:O=>{St=O,x.setItem(`${e}_tlRender`,O)}})}),(te==="Side by Side"||te==="Stacked")&&m.jsxs(m.Fragment,{children:[m.jsx(pt,{camera:K,options:Me,ref:w,onSelectCamera:O=>{t.get(K.name)?.dispose();const S=n.get(O);S!==void 0&&(Ye(K),K=S,x.setItem(`${e}_tlCam`,S.name),ge(S,w.current))},onSelectRenderMode:O=>{St=O,x.setItem(`${e}_tlRender`,O)}}),m.jsx(pt,{camera:le,options:Me,ref:C,onSelectCamera:O=>{t.get(le.name)?.dispose();const S=n.get(O);S!==void 0&&(Ye(le),le=S,x.setItem(`${e}_trCam`,S.name),ge(S,C.current))},onSelectRenderMode:O=>{Jt=O,x.setItem(`${e}_trRender`,O)}})]}),te==="Quad"&&m.jsxs(m.Fragment,{children:[m.jsx(pt,{camera:K,options:Me,ref:w,onSelectCamera:O=>{t.get(K.name)?.dispose();const S=n.get(O);S!==void 0&&(Ye(K),K=S,x.setItem(`${e}_tlCam`,S.name),ge(S,w.current))},onSelectRenderMode:O=>{St=O,x.setItem(`${e}_tlRender`,O)}}),m.jsx(pt,{camera:le,options:Me,ref:C,onSelectCamera:O=>{t.get(le.name)?.dispose();const S=n.get(O);S!==void 0&&(Ye(le),le=S,x.setItem(`${e}_trCam`,S.name),ge(S,C.current))},onSelectRenderMode:O=>{Jt=O,x.setItem(`${e}_trRender`,O)}}),m.jsx(pt,{camera:Le,options:Me,ref:U,onSelectCamera:O=>{t.get(Le.name)?.dispose();const S=n.get(O);S!==void 0&&(Ye(Le),Le=S,x.setItem(`${e}_blCam`,S.name),ge(S,U.current))},onSelectRenderMode:O=>{Ki=O,x.setItem(`${e}_blRender`,O)}}),m.jsx(pt,{camera:Ie,options:Me,ref:L,onSelectCamera:O=>{t.get(Ie.name)?.dispose();const S=n.get(O);S!==void 0&&(Ye(Ie),Ie=S,x.setItem(`${e}_brCam`,S.name),ge(S,L.current))},onSelectRenderMode:O=>{Xi=O,x.setItem(`${e}_brRender`,O)}})]})]}),m.jsxs("div",{className:"settings",children:[m.jsx(ii,{title:"View",index:F.indexOf(te),options:F,onSelect:O=>{O!==te&&(Mt(),$e(O))},open:ye,onToggle:O=>{Ce(O),Te&&ke(!1),Je&&Qe(!1)}}),m.jsx(ii,{title:"Interact",index:Ve==="Orbit"?0:1,options:["Orbit Mode","Selection Mode"],onSelect:O=>{u.visible=O==="Selection Mode",it(u.visible?"Selection":"Orbit")},open:Je,onToggle:O=>{ye&&Ce(!1),Te&&ke(!1),Qe(O)}})]},ht)]})]})}function mn(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})]})}function vs(i){return m.jsx(mn,{children:m.jsxs(m.Fragment,{children:[m.jsx(un,{three:i.three,scenes:i.scenes,onSceneResize:i.onSceneResize,onSceneSet:i.onSceneSet,onSceneUpdate:i.onSceneUpdate}),m.jsx(hn,{three:i.three})]})})}exports.Accordion=Ht;exports.Application=yn;exports.BaseRemote=ni;exports.ChildObject=Si;exports.ContainerObject=bi;exports.Draggable=sn;exports.DraggableItem=nn;exports.Dropdown=rn;exports.DropdownItem=an;exports.Editor=mn;exports.ExportTexture=jt;exports.Inspector=ln;exports.MultiView=un;exports.NavButton=xi;exports.RemoteComponents=En;exports.RemoteController=Ln;exports.RemoteTheatre=Bt;exports.RemoteThree=Mn;exports.SceneInspector=rs;exports.SidePanel=hn;exports.ThreeEditor=vs;exports.ToolEvents=B;exports.capitalize=Nt;exports.clamp=ct;exports.colorToHex=vi;exports.customizeTheatreElements=bn;exports.debugDispatcher=z;exports.defaultTheatreCallback=gn;exports.dispose=zt;exports.disposeMaterial=en;exports.disposeTexture=vn;exports.distance=_n;exports.hierarchyUUID=ti;exports.isColor=Qi;exports.mix=ei;exports.noop=Ti;exports.normalize=_i;exports.randomID=Ji;exports.resetThreeObjects=Ei;exports.round=yi;exports.theatreEditorApp=On;
|
149
|
+
}`;class _s extends f.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:ps,fragmentShader:gs})}}let ae,pi=!1,K=null,le=null,Le=null,Ie=null,St="Renderer",qt="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,[]),r=T.useMemo(()=>new Map,[]),o=T.useMemo(()=>new f.Scene,[]),a=T.useMemo(()=>new f.Group,[]),d=T.useMemo(()=>new fs,[]),c=T.useMemo(()=>new f.AxesHelper(500),[]),u=T.useMemo(()=>new f.AxesHelper(100),[]),p=T.useMemo(()=>new f.MeshDepthMaterial,[]),_=T.useMemo(()=>new f.MeshNormalMaterial,[]),y=T.useMemo(()=>new _s,[]),A=T.useMemo(()=>new f.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0}),[]);function I(O,S){const P=new f.OrthographicCamera(-100,100,100,-100,50,5e3);return P.name=O,P.position.copy(S),P.lookAt(0,0,0),n.set(O,P),P}const F=["Single","Side by Side","Stacked","Quad"],v=T.useRef(null),E=T.useRef(null),w=T.useRef(null),C=T.useRef(null),U=T.useRef(null),L=T.useRef(null),x=localStorage,oe=x.getItem(`${e}_mode`),[te,$e]=T.useState(oe!==null?oe:"Single"),[j,Ue]=T.useState(null),[ye,Ce]=T.useState(!1),[Te,ke]=T.useState(!1),[Ve,it]=T.useState("Orbit"),[Je,Qe]=T.useState(!1),[ht,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=(O,S)=>{const P=t.get(O.name);if(P!==void 0&&P.dispose(),t.delete(O.name),O.name==="UI")return;const N=new cs(O,S);switch(N.enableDamping=!0,N.dampingFactor=.05,O.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":N.enableRotate=!1;break}t.set(O.name,N)},Ye=O=>{const S=s.get(O.name);S!==void 0&&(o.remove(S),S.dispose(),s.delete(O.name));const P=t.get(O.name);P!==void 0&&(P.dispose(),t.delete(O.name))},Mt=()=>{t.forEach((O,S)=>{O.dispose();const P=s.get(S);P!==void 0&&(o.remove(P),P.dispose()),s.delete(S),t.delete(S)}),t.clear(),s.clear()},dt=()=>{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,U.current),ge(Ie,L.current);break}};T.useEffect(()=>{const O=new f.WebGLRenderer({canvas:v.current,stencil:!1});O.autoClear=!1,O.shadowMap.enabled=!0,O.setPixelRatio(devicePixelRatio),O.setClearColor(0),i.three.renderer=O,Ue(O)},[]),T.useEffect(()=>{o.name="Debug Scene",o.uuid="",a.name="helpers",o.add(a),a.add(d),c.name="axisHelper",a.add(c),u.name="interactionHelper",a.add(u),u.visible=!1,I("Top",new f.Vector3(0,1e3,0)),I("Bottom",new f.Vector3(0,-1e3,0)),I("Left",new f.Vector3(-1e3,0,0)),I("Right",new f.Vector3(1e3,0,0)),I("Front",new f.Vector3(0,0,1e3)),I("Back",new f.Vector3(0,0,-1e3)),I("Orthographic",new f.Vector3(1e3,1e3,1e3)),I("UI",new f.Vector3);const O=new f.PerspectiveCamera(60,1,50,5e3);O.name="Debug",O.position.set(500,500,500),O.lookAt(0,0,0),n.set("Debug",O),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 O=()=>{r.forEach(D=>{a.remove(D),D.dispose()}),r.clear()},S=()=>{ae.traverse(D=>{if(D.type.search("Light")>-1){let k;switch(D.type){case"DirectionalLight":k=new f.DirectionalLightHelper(D,100),k.name=`${D.name}Helper`,r.set(D.name,k),a.add(k);break;case"HemisphereLight":k=new f.HemisphereLightHelper(D,250),k.name=`${D.name}Helper`,r.set(D.name,k),a.add(k);break;case"RectAreaLight":k=new as(D),k.name=`${D.name}Helper`,r.set(D.name,k),a.add(k);break;case"PointLight":k=new f.PointLightHelper(D,100),k.name=`${D.name}Helper`,r.set(D.name,k),a.add(k);break;case"SpotLight":k=new f.SpotLightHelper(D),k.name=`${D.name}Helper`,r.set(D.name,k),a.add(k);break}}})},P=D=>{a.add(c),O(),zt(ae),o.remove(ae);const k=i.scenes.get(D.value.name);if(k!==void 0){const me=new k;i.onSceneSet!==void 0&&i.onSceneSet(me),ae=me,i.three.scene=ae,o.add(ae),pi=!0,S()}},N=D=>{const k=D.value,me=i.three.scene?.getObjectByProperty("uuid",k.uuid);if(me!==void 0&&n.set(k.name,me),me instanceof f.PerspectiveCamera){const Ee=new f.CameraHelper(me);s.set(me.name,Ee),o.add(Ee)}nt(Date.now())},ue=D=>{const k=s.get(D.value.name);k!==void 0&&(o.remove(k),k.dispose()),n.delete(D.value.name),nt(Date.now())},X=D=>{const k=ae.getObjectByProperty("uuid",D.value.uuid);k&&k.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 O=window.innerWidth,S=window.innerHeight,P=Math.floor(O/2),N=Math.floor(S/2),ue=-1;const X=new f.BufferGeometry,D=new f.MeshBasicMaterial,k=new f.Group,me=()=>{O=window.innerWidth-300,S=window.innerHeight,P=Math.floor(O/2),N=Math.floor(S/2),i.three.resize(O,S),i.onSceneResize!==void 0&&pi&&i.onSceneResize(ae,O,S);let se=O,_e=S;switch(te){case"Side by Side":se=P,_e=S;break;case"Stacked":se=O,_e=N;break;case"Quad":se=P,_e=N;break}const G=se/_e;n.forEach(H=>{H instanceof f.OrthographicCamera?(H.left=se/-2,H.right=se/2,H.top=_e/2,H.bottom=_e/-2,H.name==="UI"&&(H.position.x=O/2,H.position.y=S/-2,H.position.z=100),H.updateProjectionMatrix()):H instanceof f.PerspectiveCamera&&(H.aspect=G,H.updateProjectionMatrix(),s.get(H.name)?.update())})};function Ee(se){switch(se){case"Depth":return p;case"Normals":return _;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,O,S),j.setScissor(0,0,O,S),ae?.onBeforeRender(j,ae,K,X,D,k),j.render(o,K)},be=()=>{const se=Ee(St),_e=Ee(qt);if(o.overrideMaterial=se,te==="Side by Side")j.setViewport(0,0,P,S),j.setScissor(0,0,P,S),ae?.onBeforeRender(j,ae,K,X,D,k),j.render(o,K),o.overrideMaterial=_e,j.setViewport(P,0,P,S),j.setScissor(P,0,P,S),ae?.onBeforeRender(j,ae,le,X,D,k),j.render(o,le);else{const G=S-N;j.setViewport(0,G,O,N),j.setScissor(0,G,O,N),ae?.onBeforeRender(j,ae,K,X,D,k),j.render(o,K),o.overrideMaterial=_e,j.setViewport(0,0,O,N),j.setScissor(0,0,O,N),ae?.onBeforeRender(j,ae,le,X,D,k),j.render(o,le)}},xe=()=>{const se=Ee(St),_e=Ee(qt),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),ae?.onBeforeRender(j,ae,K,X,D,k),j.render(o,K),q=P,o.overrideMaterial=_e,j.setViewport(q,Q,P,N),j.setScissor(q,Q,P,N),ae?.onBeforeRender(j,ae,le,X,D,k),j.render(o,le),Q=0,q=0,o.overrideMaterial=G,j.setViewport(q,Q,P,N),j.setScissor(q,Q,P,N),ae?.onBeforeRender(j,ae,Le,X,D,k),j.render(o,Le),q=P,o.overrideMaterial=H,j.setViewport(q,Q,P,N),j.setScissor(q,Q,P,N),ae?.onBeforeRender(j,ae,Ie,X,D,k),j.render(o,Ie)},Ae=()=>{switch(t.forEach(se=>{se.update()}),s.forEach(se=>{se.update()}),r.forEach(se=>{se.update!==void 0&&se.update()}),i.onSceneUpdate!==void 0&&pi&&i.onSceneUpdate(ae),j.clear(),te){case"Single":et();break;case"Side by Side":case"Stacked":be();break;case"Quad":xe();break}ue=requestAnimationFrame(Ae)};return dt(),window.addEventListener("resize",me),me(),Ae(),()=>{window.removeEventListener("resize",me),cancelAnimationFrame(ue),ue=-1}},[te,j]),T.useEffect(()=>{if(j!==null){const O={Vector2:f.Vector2,Vector3:f.Vector3,Vector4:f.Vector4,Quaternion:f.Quaternion,Matrix4:f.Matrix4,Spherical:f.Spherical,Box3:f.Box3,Sphere:f.Sphere,Raycaster:f.Raycaster};qe.install({THREE:O});const S=new f.Raycaster,P=new f.Vector2;let N=K,ue=w,X,D,k=-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=U:N===Ie&&(ue=L)},Ee=G=>{const H=new f.Vector2;j.getSize(H);const q=Math.min(G.clientX,H.x),Q=Math.min(G.clientY,H.y);P.x=Ot(q,0,H.x,-1,1),P.y=Ot(Q,0,H.y,1,-1);const Pe=H.x/2,Fe=H.y/2,st=()=>{q<Pe?P.x=Ot(q,0,Pe,-1,1):P.x=Ot(q,Pe,H.x,-1,1)},We=()=>{Q<Fe?P.y=Ot(Q,0,Fe,1,-1):P.y=Ot(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(ae.children);_t.length>0&&u.position.copy(_t[0].point)},et=G=>{if(Ve==="Orbit")return;const H=new f.Vector2;if(j.getSize(H),G.clientX>=H.x)return;Ee(G);const q=S.intersectObjects(ae.children);q.length>0&&(i.three.getObject(q[0].object.uuid),u.visible=!1,it("Orbit"),nt(Date.now()))},be=(G,H=!1)=>{if(X===void 0)return;cancelAnimationFrame(k),k=-1,D&&(D.smoothTime=.1);const q=.15,Q=new f.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=Qt(G.object.zoom,G.zoom0,q),G.object.updateProjectionMatrix(),G.dispatchEvent({type:"change"})),Q.getElapsedTime()>=.5?(cancelAnimationFrame(k),k=-1,xe()):k=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 f.Mesh||X instanceof f.SkinnedMesh?(X.geometry.computeBoundingBox(),D.fitToBox(X.geometry.boundingBox,!0)):D.fitToSphere(X,!0),be(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),be(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),be(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),be(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),be(H)):G.key==="5"&&(xe(),D=new qe(N,ue.current),D.rotateTo(zi(45),zi(45),!0),be(H))}},se=G=>{X=ae.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((O,S)=>{Me.push(S)}),m.jsxs("div",{className:"multiview",children:[m.jsx("canvas",{ref:v}),j!==null&&m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:`cameras ${te==="Single"||te==="Stacked"?"single":""}`,ref:E,children:[te==="Single"&&m.jsx(m.Fragment,{children:m.jsx(pt,{camera:K,options:Me,ref:w,onSelectCamera:O=>{t.get(K.name)?.dispose();const S=n.get(O);S!==void 0&&(Ye(K),K=S,x.setItem(`${e}_tlCam`,S.name),ge(S,w.current))},onSelectRenderMode:O=>{St=O,x.setItem(`${e}_tlRender`,O)}})}),(te==="Side by Side"||te==="Stacked")&&m.jsxs(m.Fragment,{children:[m.jsx(pt,{camera:K,options:Me,ref:w,onSelectCamera:O=>{t.get(K.name)?.dispose();const S=n.get(O);S!==void 0&&(Ye(K),K=S,x.setItem(`${e}_tlCam`,S.name),ge(S,w.current))},onSelectRenderMode:O=>{St=O,x.setItem(`${e}_tlRender`,O)}}),m.jsx(pt,{camera:le,options:Me,ref:C,onSelectCamera:O=>{t.get(le.name)?.dispose();const S=n.get(O);S!==void 0&&(Ye(le),le=S,x.setItem(`${e}_trCam`,S.name),ge(S,C.current))},onSelectRenderMode:O=>{qt=O,x.setItem(`${e}_trRender`,O)}})]}),te==="Quad"&&m.jsxs(m.Fragment,{children:[m.jsx(pt,{camera:K,options:Me,ref:w,onSelectCamera:O=>{t.get(K.name)?.dispose();const S=n.get(O);S!==void 0&&(Ye(K),K=S,x.setItem(`${e}_tlCam`,S.name),ge(S,w.current))},onSelectRenderMode:O=>{St=O,x.setItem(`${e}_tlRender`,O)}}),m.jsx(pt,{camera:le,options:Me,ref:C,onSelectCamera:O=>{t.get(le.name)?.dispose();const S=n.get(O);S!==void 0&&(Ye(le),le=S,x.setItem(`${e}_trCam`,S.name),ge(S,C.current))},onSelectRenderMode:O=>{qt=O,x.setItem(`${e}_trRender`,O)}}),m.jsx(pt,{camera:Le,options:Me,ref:U,onSelectCamera:O=>{t.get(Le.name)?.dispose();const S=n.get(O);S!==void 0&&(Ye(Le),Le=S,x.setItem(`${e}_blCam`,S.name),ge(S,U.current))},onSelectRenderMode:O=>{Ki=O,x.setItem(`${e}_blRender`,O)}}),m.jsx(pt,{camera:Ie,options:Me,ref:L,onSelectCamera:O=>{t.get(Ie.name)?.dispose();const S=n.get(O);S!==void 0&&(Ye(Ie),Ie=S,x.setItem(`${e}_brCam`,S.name),ge(S,L.current))},onSelectRenderMode:O=>{Xi=O,x.setItem(`${e}_brRender`,O)}})]})]}),m.jsxs("div",{className:"settings",children:[m.jsx(ti,{title:"View",index:F.indexOf(te),options:F,onSelect:O=>{O!==te&&(Mt(),$e(O))},open:ye,onToggle:O=>{Ce(O),Te&&ke(!1),Je&&Qe(!1)}}),m.jsx(ti,{title:"Interact",index:Ve==="Orbit"?0:1,options:["Orbit Mode","Selection Mode"],onSelect:O=>{u.visible=O==="Selection Mode",it(u.visible?"Selection":"Orbit")},open:Je,onToggle:O=>{ye&&Ce(!1),Te&&ke(!1),Qe(O)}})]},ht)]})]})}function mn(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})]})}function vs(i){return m.jsx(mn,{children:m.jsxs(m.Fragment,{children:[m.jsx(un,{three:i.three,scenes:i.scenes,onSceneResize:i.onSceneResize,onSceneSet:i.onSceneSet,onSceneUpdate:i.onSceneUpdate}),m.jsx(hn,{three:i.three})]})})}exports.Accordion=Bt;exports.Application=yn;exports.BaseRemote=ii;exports.ChildObject=Si;exports.ContainerObject=Oi;exports.Draggable=sn;exports.DraggableItem=nn;exports.Dropdown=rn;exports.DropdownItem=an;exports.Editor=mn;exports.ExportTexture=jt;exports.Inspector=ln;exports.MultiView=un;exports.NavButton=xi;exports.RemoteComponents=En;exports.RemoteController=Ln;exports.RemoteTheatre=Ti;exports.RemoteThree=Mn;exports.SceneInspector=rs;exports.SidePanel=hn;exports.ThreeEditor=vs;exports.ToolEvents=B;exports.capitalize=Nt;exports.clamp=ct;exports.colorToHex=_i;exports.customizeTheatreElements=bn;exports.debugDispatcher=z;exports.defaultTheatreCallback=gn;exports.dispose=zt;exports.disposeMaterial=en;exports.disposeTexture=vn;exports.distance=_n;exports.hierarchyUUID=ei;exports.isColor=Qi;exports.mix=Qt;exports.noop=Ci;exports.normalize=gi;exports.randomID=Ji;exports.resetThreeObjects=yi;exports.round=vi;exports.theatreEditorApp=On;
|